1import{r as t,l as G,n as J,j as e,B as b,s as n}from"./index-BjKOGBuM.js";import{u as K,F as Q,a as N,b as v,c as k,d as P,e as S,o as W,s as C,t as X}from"./form-DtcIUWpf.js";import{I as T}from"./input-C6wURs3Y.js";import{C as V,a as E,b as F,c as I,d as _}from"./card-AzYCNV74.js";import{L as q,E as H}from"./lock-h0vJw6vs.js";import{E as L}from"./eye-off-BLemZTgR.js";import"./label-BHP8zKja.js";const Z=W({password:C().min(6,"Password must be at least 6 characters"),confirmPassword:C().min(6,"Password must be at least 6 characters")}).refine(r=>r.password===r.confirmPassword,{message:"Passwords don't match",path:["confirmPassword"]});function ce(){const[r,R]=t.useState(!1),[l,U]=t.useState(!1),[m,h]=t.useState(!1),[O,d]=t.useState(!1),i=G(),{toast:o}=J(),[p,f]=t.useState(!1),[B,w]=t.useState(!1),[x,Y]=t.useState(null),c=K({resolver:X(Z),defaultValues:{password:"",confirmPassword:""}});t.useEffect(()=>{(async()=>{const a=new URLSearchParams(window.location.search),y=a.get("token_hash");if(a.get("type")==="recovery"&&y){Y(y),w(!0);return}const u=new URLSearchParams(window.location.hash.substring(1)),j=u.get("access_token"),g=u.get("refresh_token");if(u.get("type")==="recovery"&&j&&g){const{error:A}=await n.auth.setSession({access_token:j,refresh_token:g});if(!A){d(!0),window.history.replaceState(null,"",window.location.pathname);return}}const{data:{session:z}}=await n.auth.getSession();z?d(!0):(o({title:"Invalid or expired link",description:"Please request a new password reset link.",variant:"destructive"}),i("/auth"))})()},[i,o]);const D=async()=>{if(x){f(!0);try{const{error:s}=await n.auth.verifyOtp({type:"recovery",token_hash:x});if(s){o({title:"Invalid or expired link",description:"Please request a new password reset link.",variant:"destructive"}),i("/auth");return}const{data:{session:a}}=await n.auth.getSession();if(!a){o({title:"Invalid or expired link",description:"Please request a new password reset link.",variant:"destructive"}),i("/auth");return}w(!1),d(!0),window.history.replaceState(null,"",window.location.pathname)}finally{f(!1)}}},M=async s=>{h(!0);try{const{error:a}=await n.auth.updateUser({password:s.password});a?o({title:"Error updating password",description:a.message,variant:"destructive"}):(o({title:"Password updated!",description:"Your password has been successfully changed. You can now sign in."}),await n.auth.signOut(),i("/auth"))}finally{h(!1)}};return B?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/10 to-secondary p-4",children:e.jsxs(V,{className:"w-full max-w-md
1shadow-xl border-0",children:[e.jsxs(E,{className:"space-y-2 text-center pb-6",children:[e.jsx(F,{className:"text-2xl font-bold text-primary",children:"Verify reset link"}),e.jsx(I,{className:"text-muted-foreground",children:"Click continue to securely open your reset session."})]}),e.jsx(_,{className:"space-y-4",children:e.jsx(b,{type:"button",className:"w-full",onClick:D,disabled:p,children:p?"Verifying...":"Continue"})})]})}):O?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/10 to-secondary p-4",children:e.jsxs(V,{className:"w-full max-w-md shadow-xl border-0",children:[e.jsxs(E,{className:"space-y-2 text-center pb-6",children:[e.jsx(F,{className:"text-2xl font-bold text-primary",children:"Set New Password"}),e.jsx(I,{className:"text-muted-foreground",children:"Enter your new password below"})]}),e.jsx(_,{children:e.jsx(Q,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(M),className:"space-y-5",children:[e.jsx(N,{control:c.control,name:"password",render:({field:s})=>e.jsxs(v,{children:[e.jsx(k,{className:"text-foreground",children:"New Password"}),e.jsx(P,{children:e.jsxs("div",{className:"relative",children:[e.jsx(q,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(T,{placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",type:r?"text":"password",className:"pl-10 pr-10",...s}),e.jsx("button",{type:"button",onClick:()=>R(!r),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:r?e.jsx(L,{className:"h-4 w-4"}):e.jsx(H,{className:"h-4 w-4"})})]})}),e.jsx(S,{})]})}),e.jsx(N,{control:c.control,name:"confirmPassword",render:({field:s})=>e.jsxs(v,{children:[e.jsx(k,{className:"text-foreground",children:"Confirm Password"}),e.jsx(P,{children:e.jsxs("div",{className:"relative",children:[e.jsx(q,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(T,{placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",type:l?"text":"password",className:"pl-10 pr-10",...s}),e.jsx("button",{type:"button",onClick:()=>U(!l),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:l?e.jsx(L,{className:"h-4 w-4"}):e.jsx(H,{className:"h-4 w-4"})})]})}),e.jsx(S,{})]})}),e.jsx(b,{type:"submit",className:"w-full",disabled:m,children:m?"Updating...":"Update Password"})]})})})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/10 to-secondary p-4",children:e.jsx("div",{className:"animate-pulse text-primary",children:"Verifying..."})})}export{ce 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.