1import{n as C,r,s as l,j as s,t as o}from"./index-SQp96gdX.js";import{B as f}from"./button-De9EF_oZ.js";import{I as x}from"./input-soQZrY2x.js";import{L as j}from"./label-CojLASnb.js";import{C as P,b as E,c as L,d as k,a as R}from"./card-CPIFjzul.js";import{z as F}from"./zeus-logo.png.asset-4yFwNq7V.js";import{S as I}from"./SEO-D1eI9kMy.js";import{s as T,Z as U}from"./types-ByNwzYMu.js";import"./index-D9ZMubZj.js";import"./Helmet-CM9up7_x.js";import"./index-Gl_aRnoi.js";const Z=T().min(6,{message:"Password must be at least 6 characters"}),_="zeus_pw_recovery",J=()=>{const u=C(),[t,g]=r.useState(""),[m,v]=r.useState(""),[p,w]=r.useState(!1),[y,i]=r.useState(!1),[S,h]=r.useState(!1);r.useEffect(()=>{let e=!0;const{data:{subscription:a}}=l.auth.onAuthStateChange((c,d)=>{e&&d&&(h(!0),i(!0))});return(async()=>{for(let c=0;c<10;c++){const{data:{session:d}}=await l.auth.getSession();if(d){e&&(h(!0),i(!0));return}await new Promise(b=>setTimeout(b,400))}e&&i(!0)})(),()=>{e=!1,a.unsubscribe()}},[]);const N=async e=>{if(e.preventDefault(),t!==m){o({title:"Validation Error",description:"Passwords do not match",variant:"destructive"});return}try{Z.parse(t)}catch(n){if(n instanceof U){o({title:"Validation Error",description:n.issues[0].message,variant:"destructive"});return}}w(!0);const{error:a}=await l.auth.updateUser({password:t});if(w(!1),a){o({title:"Error",description:a.message,variant:"destructive"});return}try{localStorage.removeItem(_)}catch{}o({title:"Success",description:"Password updated successfully!"}),u("/auth",{replace:!0})};return s.jsxs(s.Fragment,{children:[s.jsx(I,{title:"Reset Password",description:"Set a new password for your Zeus Motor Solutions account.",noindex:!0}),s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:s.jsxs(P,{className:"w-full max-w-md",children:[s.jsxs(E,{className:"text-center",children:[s.jsx("img",{src:F.url,alt:"Zeus Motor Solutions logo",width:56,height:56,className:"mx-auto mb-3 h-14 w-14 rounded-xl object-cover shadow-sm"}),s.jsx(L,{className:"text-2xl",children:"Set a New Password"}),s.jsx(k,{children:"Choose a new password for your account"})]}),s.jsx(R,{children:y?S?s.jsxs("form",{onSubmit:N,className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(j,{htmlFor:"new-password",children:"New Password"}),s.jsx(x,{id:"new-password",type:"password",placeholder:"Enter new password",value:t,onChange:e=>g(e.target.value),required:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(j,{htmlFor:"confirm-password",children:"Confirm Password"}),s.jsx(x,{id:"confirm-password",type:"password",placeholder:"Confirm new password",value:m,onChange:e=>v(e.target.value),required:!0})]}),s.jsx(f,{type:"submit",className:"w-full",disabled:p,children:p?"Updating...":"Update Password"})]}):s.jsxs("div",{className:"space-y-4 text-center",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"This password reset link is invalid or has expired. Please request a new one."}),s.jsx(f,{className:"w-full",onClick:()=>u("/auth",{replace:!0}),children:"Back to Login"})]}):s.jsx("div",{className:"flex justify-center py-8",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})})]})})]})};export{_ as RECOVERY_FLAG,J 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.