1import{r as t,j as e}from"./query-vendor-Dp9tfhuh.js";import{a as y,d as E}from"./react-vendor-DfslLuwi.js";import{h as g,i as k,k as v,l as b,m as N,L as w,B as f,n as C,a as p,d as R,e as L}from"./index-CgOeqv80.js";import{I as x}from"./input-go5takyh.js";import{M as F}from"./mail-CObWevXE.js";import{A as S}from"./arrow-left-BmX2tYO6.js";import"./ui-vendor-DW4RoVmg.js";import"./chart-vendor-BoynbIzZ.js";const B=({onSuccess:d})=>{const[r,n]=t.useState(""),[o,a]=t.useState(!1),m=y(),c=async i=>{i.preventDefault(),a(!0);try{const s=await fetch(C("/api/auth/password-reset/request"),{method:"POST",credentials:"include",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({email:r.trim()})}),u=await s.json();if(!s.ok)throw new Error(u.error||"Password reset could not be started.");p.success("Check your email for a secure password reset link."),d(u.developmentResetToken)}catch(s){p.error(s instanceof Error?s.message:"Password reset could not be started.")}finally{a(!1)}};return e.jsx("main",{className:"min-h-screen bg-slate-50 px-4 py-12",children:e.jsxs(g,{className:"mx-auto w-full max-w-md border-slate-200 shadow-lg",children:[e.jsxs(k,{children:[e.jsx("div",{className:"mb-2 flex h-11 w-11 items-center justify-center rounded-md bg-emerald-950 text-white",children:e.jsx(F,{className:"h-5 w-5"})}),e.jsx(v,{children:"Reset your password"}),e.jsx(b,{children:"Enter your account email. For privacy, the response is the same whether or not an account exists."})]}),e.jsx(N,{children:e.jsxs("form",{className:"space-y-4",onSubmit:c,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"resetEmail",children:"Email address"}),e.jsx(x,{id:"resetEmail",type:"email",autoComplete:"email",value:r,onChange:i=>n(i.target.value),required:!0})]}),e.jsx(f,{type:"submit",className:"w-full",disabled:o,children:o?"Preparing secure link...":"Send reset link"}),e.jsxs(f,{type:"button",variant:"ghost",className:"w-full",onClick:()=>m("/auth"),children:[e.jsx(S,{className:"mr-2 h-4 w-4"}),"Back to sign in"]})]})})]})})},A=({initialToken:d,onBack:r})=>{const[n,o]=t.useState(d),[a,m]=t.useState(""),[c,i]=t.useState(""),[s,u]=t.useState(!1),{refreshSession:P}=R(),T=y(),q=async l=>{if(l.preventDefault(),a!==c){p.error("Passwords do not match.");return}u(!0);try{const h=await fetch(C("/api/auth/password-reset/confirm"),{method:"POST",credentials:"include",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({token:n.trim(),password:a})}),j=await h.json();if(!h.ok||!j.authenticated)throw new Error(j.error||"This password reset link is invalid or expired.");await P(),p.success("Password updated. You are signed in."),T("/dashboard",{replace:!0})}catch(h){p.error(h instanceof Error?h.message:"Password reset could not be completed.")}finally{u(!1)}};return e.jsx("main",{className:"min-h-screen bg-slate-50 px-4 py-12",children:e.jsxs(g,{className:"mx-auto w-full max-w-md border-slate-200 shadow-lg",children:[e.jsxs(k,{children:[e.jsx("div",{className:"mb-2 flex h-11 w-11 items-center justify-center rounded-md bg-emerald-950 text-white",children:e.jsx(L,{className:"h-5 w-5"})}),e.jsx(v,{children:"Choose a new password"}),e.jsx(b,{children:"The secure reset token is single-use and expires after 30 minutes."})]}),e.jsx(N,{children:e.jsxs("form",{className:"space-y-4",onSubmit:q,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"resetToken",children:"Reset token"}),e.jsx(x,{id:"resetToken",autoComplete:"off",value:n,onChange:l=>o(l.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"resetPassword",children:"New password"}),e.jsx(x,{id:"resetPassword",type:"password",autoComplete:"new-password",minLength:10,value:a,onChange:l=>m(l.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"resetPasswordConfirm",children:"Confirm new password"}),e.jsx(x,{id:"resetPasswordConfirm",type:"password",autoComplete:"new-password",minLength:10,value:c,onChange:l=>i(l.target.value),required:!0})]}),e.jsx(f,{type:"submit",className:"w-full",disabled:s,children:s?"Updating password...":"Update password"}),e.jsxs(f,{type:"button",variant:"ghost",className:"w-full",onClick:r,children:[e.jsx(S,{className:"mr-2 h-4 w-4"}),"Request another link"]})]})})]})})},Y=()=>{const[d]=E(),r=d.get("token")||"",[n,o]=t.useState(r?"verify":"request"),[a,m]=t.useState(r),c=s=>{m(s||""),o("verify")},i=()=>{o("request")};return e.jsxs(e.Fragment,{children:[n==="request"&&e.jsx(B,{onSuccess:c}),n==="verify"&&e.jsx(A,{initialToken:a,onBack:i})]})};export{Y as default};
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.