1import{r as t,i as O,aC as M,j as e,aY as L,an as b,ao as g,ap as j,az as V,Q as w,aF as _}from"./vendor-B2NdOGN4.js";import{u as B,s as m,S as z,H as G,B as v,g as U,h as N,j as S,k as y,l as k,I as C,m as E,F as H,p as W,n as Y}from"./index-g3EbtdSc.js";const q=V({password:w().min(8,"A senha deve ter pelo menos 8 caracteres").max(100,"A senha deve ter no máximo 100 caracteres"),confirmPassword:w().min(8,"Confirme sua senha")}).refine(a=>a.password===a.confirmPassword,{message:"As senhas não coincidem",path:["confirmPassword"]});function K(){const[a,P]=t.useState(!1),[o,F]=t.useState(!1),[u,h]=t.useState(!1),[x,I]=t.useState(!1),[T,l]=t.useState(!1),[R,p]=t.useState(!0),{toast:d}=B(),f=O(),n=M({resolver:_(q),defaultValues:{password:"",confirmPassword:""}});t.useEffect(()=>{let s=!0;const r=new URLSearchParams(window.location.hash.substring(1));r.get("type")==="recovery"&&r.get("access_token")&&l(!0),m.auth.getSession().then(({data:c})=>{s&&c.session&&l(!0)}).finally(()=>{s&&p(!1)});const{data:{subscription:i}}=m.auth.onAuthStateChange((c,D)=>{(c==="PASSWORD_RECOVERY"||c==="SIGNED_IN"&&D)&&(l(!0),p(!1))});return()=>{s=!1,i.unsubscribe()}},[]);const A=async s=>{h(!0);try{const{error:r}=await m.auth.updateUser({password:s.password});if(r){const i=W(r.message);d({title:i.title,description:i.description,variant:"destructive"});return}I(!0),Y({eventType:"PASSWORD_RESET_COMPLETED"}),d({title:"Senha redefinida!",description:"Sua senha foi atualizada com sucesso."}),setTimeout(()=>f("/area-do-membro",{replace:!0}),2e3)}catch{d({title:"Erro",description:"Tente novamente mais tarde.",variant:"destructive"})}finally{h(!1)}};return R?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx("div",{className:"w-8 h-8 border-2 border-ibesg border-t-transparent rounded-full animate-spin"})}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(z,{title:"Defina sua senha | IBESG",description:"Defina sua senha de acesso à área de membro do Instituto Brasileiro de ESG.",noindex:!0}),e.jsx(G,{}),e.jsx("main",{className:"pt-28 pb-16 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-display font-black text-foreground tracking-tight text-balance mb-4",children:"Defina sua senha"}),e.jsx("p",{className:"text-muted-foreground",children:x?"Senha salva!":"Crie sua senha de acesso à área de membro."})]}),e.jsx("div",{className:"bg-card rounded-sm ring-1 ring-hairline/14 border border-border p-6 sm:p-8",children:x?e.jsxs("div",{className:"text-center space-y-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-ibesg/10 flex items-center justify-center mx-auto",children:e.jsx(L,{className:"w-8 h-8 text-ibesg"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-display font-black text-foreground tracking-tight mb-2",children:"Senha salva"}),e.jsx("p",{className:"text-muted-foreground",children:"Você será redirecionado para a Ãrea do Membro em instantes."})]})]}):T?e.jsx(U,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(A),className:"space-y-6",children:[e.jsx(N,{control:n.control,name:"password",render:({field:s})=>e.jsxs(S,{children:[e.jsx(y,{className:"text-base font-semibold text-foreground",children:"Senha"}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-5 w-5 text-muted-foreground"}),e.jsx(k,{children:e.jsx(C,{type:a?"text":"password",placeholder:"MÃnimo 8 caracteres",autoComplete:"new-password",className:"h-12 text-base bg-background border-input pl-10 pr-12",...s})}),e.jsx("button",{type:"button",onClick:()=>P(!a),"aria-label":a?"Ocultar senha":"Mostrar senha",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:a?e.jsx(g,{className:"h-5 w-5"}):e.jsx(j,{className:"h-5 w-5"})})]}),e.jsx(E,{})]})}),e.jsx(N,{control:n.control,name:"confirmPassword",render:({field:s})=>e.jsxs(S,{children:[e.jsx(y,{className:"text-base font-semibold text-foreground",children:"Confirmar senha"}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-5 w-5 text-muted-foreground"}),e.jsx(k,{children:e.jsx(C,{type:o?"text":"password",placeholder:"Repita a senha",autoComplete:"new-password",className:"h-12 text-base bg-background border-input pl-10 pr-12",...s})}),e.jsx("button",{type:"button",onClick:()=>F(!o),"aria-label":o?"Ocultar senha":"Mostrar senha",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:o?e.jsx(g,{className:"h-5 w-5"}):e.jsx(j,{className:"h-5 w-5"})})]}),e.jsx(E,{})]})}),e.jsx(v,{type:"submit",disabled:u,className:"w-full h-14 text-lg font-semibold bg-ibesg hover:bg-ibesg-dark text-ibesg-foreground shadow-lg transition-opacity",children:u?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Salvando..."]}):"Salvar senha"})]})}):e.jsxs("div",{className:"text-center space-y-6",children:[e.jsx("p",{className:"text-muted-foreground",children:"Este link não está mais ativo: ele funciona uma única vez e por tempo limitado. Se você já o abriu antes, peça um novo link e use-o assim que chegar."}),e.jsx(v,{onClick:()=>f("/recuperar-senha"),className:"w-full h-12 bg-ibesg hover:bg-ibesg-dark text-ibesg-foreground",children:"Solicitar Novo Link"})]})})]})}),e.jsx(H,{})]})}
1export{K 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.