PageSourceSearch

https://www.d1v.ai/assets/ResetPasswordDialog-DWoOKU6v.js

js d1v.ai collected 2026-10-05 15:32:27 UTC 3,792 bytes, 1 lines download raw bytes

1import{j as e}from"./jsx-runtime-BjG_zV1W.js";import{r as t}from"./index-DeA8mjT8.js";import{B as P}from"./button-BGG7fLGV.js";import{D as k,a as T,b as M,c as B,e as U}from"./dialog-DGaV7CJ3.js";import{I as p}from"./input-Dr_6t5gv.js";import{L as f}from"./label-ufv-s6CK.js";import{t as o}from"./toast--axIgTaB.js";import{t as E}from"./error-toast-C6yWlb1L.js";import{u as q,a as z}from"./hooks-gSRFWfA6.js";import{p as A,k as H}from"./request-DgUJLOl6.js";import{g as _}from"./utils-DVq-zWX3.js";import{L as N}from"./loader-circle-DWpmGfxY.js";function G(d){const[n,i]=t.useState(0),a=t.useRef(null);return t.useEffect(()=>()=>{a.current&&window.clearInterval(a.current)},[]),{left:n,start:()=>{a.current&&window.clearInterval(a.current),i(d),a.current=window.setInterval(()=>{i(l=>l<=1?(a.current&&window.clearInterval(a.current),a.current=null,0):l-1)},1e3)},running:n>0}}function te({open:d,onOpenChange:n,initialEmail:i,hideEmail:a}){const[u,l]=t.useState(i||""),[m,j]=t.useState(""),[c,v]=t.useState(""),[y,S]=t.useState(""),[g,R]=t.useState(!1),[x,b]=t.useState(!1),h=G(60),s=q(),D=z();t.useEffect(()=>{d&&(l(i||""),j(""),v(""),S(""))},[d,i]);const w=t.useMemo(()=>String(u||"").trim(),[u]),C=t.useMemo(()=>/.+@.+\..+/.test(w),[w]),I=async()=>{if(!C){o.error(s("auth.resetPassword.toast.invalidEmail"));return}R(!0);try{await A(w,D),o.success(s("auth.resetPassword.toast.codeSent")),h.start()}catch(r){const F=_(r);F?o.info(F):E(r,s("auth.resetPassword.toast.sendFailed"))}finally{R(!1)}},L=async()=>{if(!C){o.error(s("auth.resetPassword.toast.invalidEmail"));return}if(!m||m.length<4){o.error(s("auth.resetPassword.toast.codeRequired"));return}if(!c||c.length<6){o.error(s("auth.resetPassword.toast.passwordTooShort"));return}if(c!==y){o.error(s("auth.resetPassword.toast.passwordMismatch"));return}b(!0);try{await H(w,m,c),o.success(s("auth.resetPassword.toast.success")),n(!1)}catch(r){E(r,s("auth.resetPassword.toast.failed"))}finally{b(!1)}};return e.jsx(k,{open:d,onOpenChange:n,children:e.jsxs(T,{className:"sm:max-w-[420px]",children:[e.jsx(M,{children:e.jsx(B,{children:s("auth.resetPassword.title")})}),e.jsxs("div",{className:"grid gap-3 py-2",children:[!a&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(f,{htmlFor:"rp-email",children:s("auth.resetPassword.field.email")}),e.jsx(p,{id:"rp-email",type:"email",value:u,onChange:r=>l(r.target.value),placeholder:s("login.email.placeholder.email")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(f,{htmlFor:"rp-code",children:s("auth.resetPassword.field.code")}),e.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2",children:[e.jsx(p,{id:"rp-code",value:m,onChange:r=>j(r.target.value),placeholder:s("auth.resetPassword.placeholder.code")}),e.jsxs(P,{onClick:I,disabled:g||h.running,"aria-busy":g,children:[g&&e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"}),h.running?s("auth.resetPassword.button.resendIn",{seconds:h.left}):s("auth.resetPassword.button.sendCode")]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(f,{htmlFor:"rp-pwd",children:s("auth.resetPassword.field.newPassword")}),e.jsx(p,{id:"rp-pwd",type:"password",value:c,onChange:r=>v(r.target.value),placeholder:s("auth.resetPassword.placeholder.newPassword")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(f,{htmlFor:"rp-pwd2",children:s("auth.resetPassword.field.confirmPassword")}),e.jsx(p,{id:"rp-pwd2",type:"password",value:y,onChange:r=>S(r.target.value),placeholder:s("auth.resetPassword.placeholder.confirmPassword")})]})]}),e.jsxs(U,{children:[e.jsx(P,{variant:"ghost",onClick:()=>n(!1),children:s("auth.resetPassword.button.cancel")}),e.jsxs(P,{onClick:L,disabled:x,"aria-busy":x,children:[x&&e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"}),s("auth.resetPassword.button.submit")]})]})]})})}export{te as R};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.