1import{u as v,r as a,s as i,j as e,L as m,a as p,I as h,B as x,t as n}from"./index-DUiXJ36l.js";function S(){const w=v(),[l,f]=a.useState("request"),[d,g]=a.useState(""),[c,y]=a.useState(""),[r,o]=a.useState(!1);a.useEffect(()=>{const{data:{subscription:t}}=i.auth.onAuthStateChange(s=>{s==="PASSWORD_RECOVERY"&&f("recover")});return()=>t.unsubscribe()},[]);const j=async t=>{t.preventDefault(),o(!0);try{const s=typeof window<"u"?`${window.location.origin}/reset-password`:void 0,{error:u}=await i.auth.resetPasswordForEmail(d,{redirectTo:s});if(u)throw u;n.success("Check your email for the reset link.")}catch(s){n.error(s.message??"Failed to send reset email")}finally{o(!1)}},b=async t=>{t.preventDefault(),o(!0);try{const{error:s}=await i.auth.updateUser({password:c});if(s)throw s;n.success("Password updated. You're signed in."),w({to:"/account",replace:!0})}catch(s){n.error(s.message??"Failed to update password")}finally{o(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-muted/40 px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl bg-card p-8 shadow-lg ring-1 ring-border",children:[e.jsx(m,{to:"/",className:"block text-center text-xl font-bold text-primary",children:"BuySellProperty"}),e.jsx("h1",{className:"mt-6 text-2xl font-bold text-foreground",children:l==="recover"?"Set a new password":"Reset your password"}),l==="request"?e.jsxs("form",{onSubmit:j,className:"mt-6 space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter your account email â we'll send you a secure reset link."}),e.jsxs("div",{children:[e.jsx(p,{htmlFor:"rp-email",children:"Email"}),e.jsx(h,{id:"rp-email",type:"email",required:!0,value:d,onChange:t=>g(t.target.value),autoComplete:"email"})]}),e.jsx(x,{type:"submit",className:"w-full",size:"lg",disabled:r,children:r?"Sendingâ¦":"Send reset link"}),e.jsx("div",{className:"text-center text-sm",children:e.jsx(m,{to:"/auth",className:"font-semibold text-primary hover:underline",children:"Back to sign in"})})]}):e.jsxs("form",{onSubmit:b,className:"mt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{htmlFor:"rp-pw",children:"New password"}),e.jsx(h,{id:"rp-pw",type:"password",required:!0,minLength:8,value:c,onChange:t=>y(t.target.value),autoComplete:"new-password"})]}),e.jsx(x,{type:"submit",className:"w-full",size:"lg",disabled:r,children:r?"Updatingâ¦":"Update password"})]})]})})}export{S 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.