import{j as e}from"./query-PJ0ZdjbV.js";import{j as S,u as y,a as t}from"./vendor-CWhr2lg4.js";import{j as C,d as h,h as p,i as w,R as i,e as E,f as b,g as R,I as j,B as k,k as I,l as O}from"./index-BSPIaiZU.js";import"./ui-aO-W1bxx.js";function F(){const[f]=S(),o=f.get("token")??"",g=y(),[a,N]=t.useState(""),[c,v]=t.useState(""),[l,n]=t.useState(""),[m,u]=t.useState([]),d=C(),P=s=>{if(s.preventDefault(),n(""),u([]),a!==c){n("Passwords do not match.");return}d.mutate({token:o,new_password:a},{onSuccess:()=>g(`${i.LOGIN}?reset=1`),onError:r=>{const x=I(r,"new_password");x.length?u(x):n(O(r,"Invalid or expired link. Please request a new one."))}})};return o?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-muted/50",children:e.jsxs(h,{className:"w-full max-w-md",children:[e.jsxs(E,{className:"text-center",children:[e.jsx(b,{children:"Set New Password"}),e.jsx(R,{children:"Enter a new password for your account"})]}),e.jsxs("form",{onSubmit:P,children:[e.jsxs(p,{className:"space-y-4",children:[l&&e.jsx("p",{className:"text-sm text-destructive",children:l}),m.length>0&&e.jsx("ul",{className:"space-y-1 rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:m.map((s,r)=>e.jsxs("li",{className:"flex gap-1.5",children:[e.jsx("span",{"aria-hidden":!0,children:"•"}),e.jsx("span",{children:s})]},r))}),e.jsx(j,{type:"password",placeholder:"New password",value:a,onChange:s=>N(s.target.value),required:!0,minLength:8}),e.jsx(j,{type:"password",placeholder:"Confirm new password",value:c,onChange:s=>v(s.target.value),required:!0,minLength:8})]}),e.jsxs(w,{className:"flex flex-col gap-3",children:[e.jsx(k,{type:"submit",className:"w-full",disabled:d.isPending,children:d.isPending?"Saving...":"Set New Password"}),e.jsx("a",{href:i.LOGIN,className:"text-sm text-primary hover:underline",children:"Back to login"})]})]})]})}):e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-muted/50",children:e.jsxs(h,{className:"w-full max-w-md",children:[e.jsx(p,{className:"pt-6",children:e.jsx("p",{className:"text-center text-sm text-destructive",children:"Invalid reset link. Please request a new password reset."})}),e.jsx(w,{className:"justify-center",children:e.jsx("a",{href:i.FORGOT_PASSWORD,className:"text-sm text-primary hover:underline",children:"Request reset link"})})]})})}export{F as ResetPasswordPage};
