1import{c as I,R as j,j as e,q as c,o as U,L as k,I as C,E,B as F,u as W,n as Z,p as $,a as G,r as n,C as J,s as K,v as Q,w as X,t as ee,x as te,A as L,k as A,l as R,S as ae}from"./index-3729243f.js";import{L as T,E as _}from"./lock-3cfc180b.js";const se=I("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),re=I("ShieldAlert",[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),V=j.memo(({password:a})=>{let t=0;a.length>=8&&t++,a.match(/[A-Z]/)&&t++,a.match(/[a-z]/)&&t++,a.match(/[0-9]/)&&t++,a.match(/[^A-Za-z0-9]/)&&t++;const d=["bg-red-500","bg-red-500","bg-orange-500","bg-yellow-500","bg-green-500","bg-green-600"],h=["Too Weak","Weak","Okay","Good","Strong","Very Strong"];return e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex h-1.5 w-full rounded-full overflow-hidden bg-[hsl(var(--royaltix-input-bg))]",children:[...Array(5)].map((m,s)=>e.jsx("div",{className:`h-full flex-1 transition-all duration-300 ${s<t?d[t]:"bg-[hsl(var(--royaltix-input-bg))]"}`,style:{marginRight:s<4?"2px":"0"}},s))}),a.length>0&&e.jsxs("p",{className:`text-xs mt-1.5 ${t<=2?"text-red-500":t<=3?"text-yellow-500":"text-green-500"}`,children:["Password strength: ",h[t]]})]})});V.displayName="PasswordStrengthIndicator";const M=j.memo(({transition:a})=>e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-screen bg-gradient-to-br from-[hsl(var(--royaltix-bg-start))] to-[hsl(var(--royaltix-bg-end))] p-4 text-center",children:[e.jsx(c.div,{initial:{opacity:0}
1,animate:{opacity:1},transition:{delay:.1,...a},children:e.jsx(U,{className:"h-16 w-auto text-[hsl(var(--royaltix-accent))] mb-6"})}),e.jsx(c.p,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.2,...a},className:"text-xl font-medium text-[hsl(var(--royaltix-text-primary))]",children:"Verifying reset link"}),e.jsx(c.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3,...a},className:"mt-3",children:e.jsx(se,{className:"h-6 w-6 text-[hsl(var(--royaltix-accent))] animate-spin"})})]}));M.displayName="LoadingState";const Y=j.memo(({onSubmit:a,password:t,setPassword:d,confirmPassword:h,setConfirmPassword:m,showPassword:s,setShowPassword:i,showConfirmPassword:o,setShowConfirmPassword:y,formLoading:p,pageState:g,transition:v})=>e.jsxs(c.form,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2,...v},onSubmit:a,className:"space-y-5 text-left",children:[e.jsxs("div",{children:[e.jsx(k,{htmlFor:"new-password",className:"text-[hsl(var(--royaltix-text-secondary))]",children:"New Password"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx(T,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-5 w-5 text-[hsl(var(--royaltix-text-muted))]"}),e.jsx(C,{id:"new-password",type:s?"text":"password",placeholder:"Minimum 8 characters",value:t,onChange:u=>d(u.target.value),required:!0,className:"pl-10 pr-10"}),e.jsx("button",{type:"button",onClick:()=>i(!s),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[hsl(var(--royaltix-text-muted))] hover:text-[hsl(var(--royaltix-text-primary))]","aria-label":s?"Hide password":"Show password",children:s?e.jsx(_,{className:"h-5 w-5"}):e.jsx(E,{className:"h-5 w-5"})})]}),e.jsx(V,{password:t})]}),e.jsxs("div",{children:[e.jsx(k,{htmlFor:"confirm-password",className:"text-[hsl(var(--royaltix-text-secondary))]",children:"Confirm New Password"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx(T,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-5 w-5 text-[hsl(var(--royaltix-text-muted))]"}),e.jsx(C,{id:"confirm-password",type:o?"text":"password",placeholder:"Re-enter your new password",value:h,onChange:u=>m(u.target.value),required:!0,className:"pl-10 pr-10"}),e.jsx("button",{type:"button",onClick:()=>y(!o),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[hsl(var(--royaltix-text-muted))] hover:text-[hsl(var(--royaltix-text-primary))]","aria-label":o?"Hide confirm password":"Show confirm password",children:o?e.jsx(_,{className:"h-5 w-5"}):e.jsx(E,{className:"h-5 w-5"})})]})]}),e.jsx(F,{type:"submit",disabled:p||g!=="ready",className:"w-full bg-[hsl(var(--royaltix-primary))] hover:bg-[hsl(var(--royaltix-primary)_/_0.9)] text-[hsl(var(--background))] py-3 text-md font-semibold",children:p?"Updating Password...":"Set New Password"})]},"form"));Y.displayName="PasswordUpdateForm";const le=()=>{const{updateUser:a,session:t,authEvent:d,loading:h}=W(),m=Z(),s=$(),{toast:i}=G(),[o,y]=n.useState(""),[p,g]=n.useState(""),[v,u]=n.useState(!1),[N,l]=n.useState(null),[S,P]=n.useState(null),[q,B]=n.useState(!1),[O,D]=n.useState(!1),[r,x]=n.useState("verifying");n.useEffect(()=>{if(h){x("verifying");return}if(d==="PASSWORD_RECOVERY"&&(t!=null&&t.user))x("ready"),l(null),i({title:"Verification Successful",description:"You can now set a new password.",className:"bg-green-600 text-white border-green-600"});else if(t!=null&&t.user&&!s.hash.includes("type=recovery"))x("ready"),l(null),i({title:"Update Password",description:"You are already logged in. You can update your password here if you wish.",variant:"default"});else if(!(t!=null&&t.user)&&s.hash.includes("type=recovery")){const w=setTimeout(()=>{!(t!=null&&t.user)&&r==="verifying"&&(l("Invalid or expired password reset link. The link may have already been used or is incorrect. Please request a new one if needed."),x("error"))},3e3);return()=>clearTimeout(w)}else!(t!=null&&t.user)&&!s.hash.includes("type=recovery")&&(l("No password reset token found or you are not logged in. Please use the link from your password reset email or log in to update your password."),x("error"))},[t,d,h,s.hash,i,r]);const H=async w=>{if(w.preventDefault(),l(null),P(null),r!=="ready"){l("Cannot update password. The session is not ready for this action."),i({title:"Session Error",description:"Password update cannot proceed. Please try again or use a valid reset link.",variant:"destructive"});return}if(o!==p){l("Passwords do not match."),i({title:"Input Error",description:"Passwords do not match.",variant:"destructive"});return}if(o.length<8){l("Password must be at least 8 characters long."),i({title:"Input Error",description:"Password must be at least 8 characters long.",variant:"destructive"});return}u(!0);const{error:b}=await a({password:o});u(!1),b?(l(b.message),i({title:"Password Update Failed",description:b.message,variant:"destructive"})):(P("Password updated successfully! You will be redirected to the login page shortly."),x("success_redirecting"),i({title:"Password Updated!",description:"Your new password has been set.",className:"bg-green-600 text-white border-green-600"}),y(""),g(""),setTimeout(()=>m("/auth",{replace:!0}),3e3))},z={initial:{opacity:0,y:20},in:{opacity:1,y:0},out:{opacity:0,y:-20}},f={duration:.4,ease:"easeInOut"};return r==="verifying"?e.jsx(M,{transition:f}):e.jsx("div",{className:"flex flex-col items-center justify-center min-h-screen bg-gradient-to-br from-[hsl(var(--royaltix-bg-start))] to-[hsl(var(--royaltix-bg-end))] p-4 sm:p-6",children:e.jsx(c.div,{variants:z,initial:"initial",animate:"in",exit:"out",transition:f,className:"w-full max-w-md",children:e.jsxs(J,{className:"bg-[hsl(var(--royaltix-card-bg))] border-[hsl(var(--royaltix-card-border))] shadow-2xl",children:[e.jsxs(K,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(U,{className:"h-10 w-auto text-[hsl(var(--royaltix-accent))]"})}),e.jsx(Q,{className:"text-2xl sm:text-3xl",children:"Set New Password"}),e.jsxs(X,{className:"pt-1",children:[r==="ready"&&"Create a strong, new password for your account.",r==="success_redirecting"&&"Redirecting you to login...",r==="error"&&"Please address the issue below to proceed."]})]}),e.jsxs(ee,{className:"px-6 sm:px-8 pb-6 sm:pb-8",children:[e.jsxs(te,{mode:"wait",children:[N&&r==="error"&&e.jsx(c.div,{initial:{opacity:0,height:0}
1,animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3},children:e.jsxs(L,{variant:"destructive",className:"mb-6 text-left",children:[e.jsx(re,{className:"h-5 w-5"}),e.jsx(A,{children:"Verification Failed"}),e.jsx(R,{children:N})]})},"error"),S&&r==="success_redirecting"&&e.jsx(c.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3},children:e.jsxs(L,{variant:"default",className:"mb-6 text-left bg-green-600/10 border-green-600/30 text-green-700 dark:text-green-300",children:[e.jsx(ae,{className:"h-5 w-5 text-green-500"}),e.jsx(A,{children:"Success!"}),e.jsx(R,{children:S})]})},"success")]}),r==="ready"&&e.jsx(Y,{onSubmit:H,password:o,setPassword:y,confirmPassword:p,setConfirmPassword:g,showPassword:q,setShowPassword:B,showConfirmPassword:O,setShowConfirmPassword:D,formLoading:v,pageState:r,transition:f}),(r==="error"||r==="success_redirecting")&&e.jsx(c.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},className:"mt-6",children:e.jsx(F,{onClick:()=>m("/auth",{replace:!0}),variant:"outline",className:"w-full text-md py-3 border-[hsl(var(--royaltix-card-border))] text-[hsl(var(--royaltix-text-secondary))] hover:text-[hsl(var(--royaltix-text-primary))] hover:border-[hsl(var(--royaltix-accent)_/_0.7)]",children:"Back to Login"})})]})]})})})};export{le 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.