1import{i as S,ag as P,r,j as e,L as C,N as E,t as a,ah as R}from"./index-Dm8RZsL9.js";import{E as h}from"./eye-off-BR9QyHvV.js";import{E as b}from"./eye-BQaoAMPw.js";async function z(i,u){const s=await fetch(`${R}${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}),t=await s.json().catch(()=>({}));if(!s.ok||t?.success===!1)throw new Error(t?.error||t?.message||`Request failed (${s.status})`);return t?.data??t}function T(){const i=S(),s=P({from:"/reset-password"}).token??"",[t,m]=r.useState(s),[n,g]=r.useState(""),[p,w]=r.useState(""),[d,y]=r.useState(!1),[l,j]=r.useState(!1),[x,f]=r.useState(!1),[c,N]=r.useState(!1);r.useEffect(()=>{s&&m(s)},[s]);async function v(o){if(o.preventDefault(),!t.trim())return a.error("Enter the reset code from your email");if(n.length<8)return a.error("Password must be at least 8 characters");if(n!==p)return a.error("Passwords do not match");f(!0);try{await z("/auth/reset-password",{token:t.trim(),new_password:n}),N(!0),a.success("Password updated! You can now sign in.")}catch(k){a.error(k.message)}finally{f(!1)}}return e.jsx("div",{className:"min-h-[calc(100vh-180px)] grid place-items-center px-4 py-10",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:c?"Password updated":"Reset password"}),e.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground",children:c?"Your password has been reset successfully.":s?"Enter your new password below.":"Enter the reset code from your email and your new password."})]}),e.jsx("div",{className:"rounded-2xl border border-border bg-card p-6 shadow-soft",children:c?e.jsx("div",{className:"text-center space-y-4",children:e.jsx("button",{type:"button",onClick:()=>i({to:"/login"}),className:"w-full rounded-full brand-gradient py-3 text-sm font-semibold text-primary-foreground shadow-soft hover:opacity-95 transition",children:"Sign in"})}):e.jsxs("form",{onSubmit:v,className:"space-y-4",children:[!s&&e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-semibold text-foreground/80",children:"Reset code"}),e.jsx("input",{type:"text",value:t,onChange:o=>m(o.target.value),placeholder:"Enter code from email",required:!0,className:"mt-1.5 w-full rounded-xl border border-border bg-background px-4 py-2.5 text-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-semibold text-foreground/80",children:"New password"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx("input",{type:d?"text":"password",value:n,onChange:o=>g(o.target.value),placeholder:"At least 8 characters",autoComplete:"new-password",required:!0,className:"w-full rounded-xl border border-border bg-background px-4 py-2.5 text-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20 pr-10"}),e.jsx("button",{type:"button",onClick:()=>y(!d),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition",children:d?e.jsx(h,{size:18}):e.jsx(b,{size:18})})]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-semibold text-foreground/80",children:"Confirm password"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx("input",{type:l?"text":"password",value:p,onChange:o=>w(o.target.value),placeholder:"Re-enter password",autoComplete:"new-password",required:!0,className:"w-full rounded-xl border border-border bg-background px-4 py-2.5 text-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/20 pr-10"}),e.jsx("button",{type:"button",onClick:()=>j(!l),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition",children:l?e.jsx(h,{size:18}):e.jsx(b,{size:18})})]})]}),e.jsx("button",{type:"submit",disabled:x,className:"w-full rounded-full brand-gradient py-3 text-sm font-semibold text-primary-foreground shadow-soft hover:opacity-95 transition disabled:opacity-60",children:x?"Updating...":"Update password"})]})}),e.jsx("p",{className:"mt-6 text-center text-sm text-muted-foreground",children:e.jsxs(C,{to:"/login",className:"inline-flex items-center gap-1 hover:text-foreground transition",children:[e.jsx(E,{size:14})," Back to sign in"]})})]})})}export{T as component};
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.