1import{r as t,j as s}from"./vendor-react-1XjzX-BQ.js";import{g as N,co as S,cU as k,a5 as T,a6 as _,cp as x,s as b,j as E,ac as I}from"./app-shared-BMK96jHo.js";import{Z as R,o as C,s as v}from"./types-CNSWNUP2.js";import"./vendor-supabase-DWUKxp_c.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new e.Error().stack;i&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[i]="c185dbcc-8e00-40d2-981c-90b1c92d3c73",e._sentryDebugIdIdentifier="sentry-dbid-c185dbcc-8e00-40d2-981c-90b1c92d3c73")}catch{}})();const L=C({password:v().min(6,{message:"Password must be at least 6 characters"}),confirmPassword:v()}).refine(e=>e.password===e.confirmPassword,{message:"Passwords must match",path:["confirmPassword"]}),q=()=>{const[e,i]=t.useState(""),[c,j]=t.useState(""),[p,w]=t.useState(!1),[l,h]=t.useState(!0),{updatePassword:y,session:u}=N(),{toast:o}=S(),d=k();t.useEffect(()=>{window.scrollTo(0,0);const r=window.location.hash;if(r.includes("error=")){const n=new URLSearchParams(r.
1substring(1)),g=n.get("error"),m=n.get("error_description");let f="An error occurred while resetting the password";g==="access_denied"&&(m!=null&&m.includes("otp_expired"))?f="Password reset link has expired. Generate a new link.":g==="access_denied"&&(f="Password reset link is invalid or has expired."),o({variant:"destructive",title:"Password reset error",description:f}),d("/login")}r.includes("access_token=")?(console.log("[ResetPassword] Access token found in URL, waiting for session..."),setTimeout(()=>{h(!1)},2e3)):h(!1)},[o,d]),t.useEffect(()=>{!l&&!u?(console.log("[ResetPassword] No session found, redirecting to login"),d("/login")):u&&console.log("[ResetPassword] Session found, user can reset password")},[u,d,l]);const P=async r=>{r.preventDefault(),w(!0);try{const a=L.parse({password:e,confirmPassword:c}),{error:n}=await y(a.password);if(n)throw n;o({title:"Password changed",description:"Your password has been successfully changed."})}catch(a){a instanceof R?o({variant:"destructive",title:"Validation error",description:a.errors[0].message}):o({variant:"destructive",title:"Error",description:a.message||"Failed to change password"})}finally{w(!1)}};return s.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[s.jsx(T,{}),s.jsx("div",{className:"flex-1 flex items-center justify-center px-4 pt-20 pb-12",children:s.jsx(_,{className:"w-full max-w-md p-8",children:l?s.jsxs("div",{className:"text-center py-8",children:[s.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4"}),s.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("h1",{className:"text-3xl font-bold text-foreground mb-2",children:"Set new password"}),s.jsx("p",{className:"text-muted-foreground",children:"Enter your new password below"})]}),s.jsxs("form",{onSubmit:P,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(x,{htmlFor:"password",children:"New password"}),s.jsx(b,{id:"password",type:"password",value:e,onChange:r=>i(r.target.value),placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",className:"mt-2",required:!0})]}),s.jsxs("div",{children:[s.jsx(x,{htmlFor:"confirmPassword",children:"Confirm password"}),s.jsx(b,{id:"confirmPassword",type:"password",value:c,onChange:r=>j(r.target.value),placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",className:"mt-2",required:!0})]}),s.jsx(E,{type:"submit",className:"w-full",size:"lg",disabled:p,children:p?"Saving...":"Change password"})]})]})})}),s.jsx(I,{})]})};export{q 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.