1import{u as v,b as n,s as c,j as e}from"./index-Dvey7Sg9.js";import{C as w}from"./circle-check-MBnQeT0E.js";import{C as y}from"./circle-x-BXD5Ntrt.js";function k(a){let t=0;return a.length>=8&&t++,a.length>=12&&t++,/[A-Z]/.test(a)&&t++,/[0-9]/.test(a)&&t++,/[^A-Za-z0-9]/.test(a)&&t++,t<=1?{score:t,label:"Weak",color:"bg-red-500"}:t<=2?{score:t,label:"Fair",color:"bg-amber-500"}:t<=3?{score:t,label:"Good",color:"bg-blue-500"}:{score:t,label:"Strong",color:"bg-emerald-500"}}function P(){const a=v(),[t,u]=n.useState(!1),[r,f]=n.useState(""),[o,h]=n.useState(""),[m,d]=n.useState(null),[x,p]=n.useState(!1);n.useEffect(()=>{c.auth.getSession().then(({data:l})=>u(!!l.session));const{data:s}=c.auth.onAuthStateChange((l,N)=>u(!!N));return()=>s.subscription.unsubscribe()},[]);const i=k(r),b=[{label:"At least 8 characters",pass:r.length>=8},{label:"At least one uppercase letter",pass:/[A-Z]/.test(r)},{label:"At least one number",pass:/[0-9]/.test(r)},{label:"Passwords match",pass:o.length>0&&r===o}],g=b.every(s=>s.pass);async function j(s){if(s.preventDefault(),!g){d("Please satisfy all password requirements.");return}p(!0),d(null);const{error:l}=await c.auth.updateUser({password:r});p(!1),l?d(l.message):a({to:"/"})}return e.jsx("div",{className:"min-h-screen grid place-items-center bg-background p-8",children:e.jsxs("div",{className:"w-full max-w-sm",children:[e.jsx("div",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground mb-2",children:"Recovery"}),e.jsxs("h1",{className:"text-3xl font-light tracking-tight mb-8",children:["Choose a new ",e.jsx("span",{className:"font-bold",children:"password"})]}),t?e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"New password"}),e.jsx("input",{type:"password",minLength:8,required:!0,value:r,onChange:s=>f(s.target.value),className:"mt-2 w-full bg-card border border-border rounded-sm px-3 py-2.5 text-sm outline-none focus:border-accent"}),r.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex gap-1 mb-1",children:[1,2,3,4].map(s=>e.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${s<=i.score?i.color:"bg-border"}`},s))}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[i.label," password"]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Confirm password"}),e.jsx("input",{type:"password",minLength:8,required:!0,value:o,onChange:s=>h(s.target.value),className:"mt-2 w-full bg-card border border-border rounded-sm px-3 py-2.5 text-sm outline-none focus:border-accent"})]}),e.jsx("div",{className:"space-y-1.5 p-3 bg-muted/30 border border-border rounded-sm",children:b.map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[s.pass?e.jsx(w,{className:"size-3.5 text-emerald-500 flex-shrink-0"}):e.jsx(y,{className:"size-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:`text-[11px] ${s.pass?"text-foreground":"text-muted-foreground"}`,children:s.label})]},s.label))}),m&&e.jsx("div",{className:"text-xs text-red-500 border border-red-500/30 bg-red-500/5 px-3 py-2 rounded-sm",children:m}),e.jsx("button",{disabled:x||!g,type:"submit",className:"w-full py-3 bg-foreground text-background text-sm font-bold uppercase tracking-widest rounded-sm disabled:opacity-40 transition",children:x?"Updatingâ¦":"Update password"})]}):e.jsx("div",{className:"text-xs text-muted-foreground",children:"Verifying recovery linkâ¦"})]})})}export{P 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.