1import{r as n,j as e,L as A}from"./react-daO8XSXc.js";import{u as R}from"./useFocoInicial-B7rNVo93.js";import{s as f,U as P,Q as _}from"./index-B58ZFblL.js";import{v as w,a4 as v,w as D,a as b}from"./lucide-DgiROqw5.js";import"./supabase-CWGMQrOR.js";import"./framer-CJI0BPWU.js";const x=8,L=4e3;function T(){if(typeof window>"u")return{temToken:!1};const o=new URLSearchParams(window.location.hash.replace(/^#/,"")),t=o.get("error_code"),s=o.get("error_description");return t||o.get("error")?{temToken:!0,erro:t==="otp_expired"?"Este link já foi usado ou expirou.":(s==null?void 0:s.replace(/\+/g," "))||"O link não pôde ser validado."}:{temToken:!!o.get("access_token")}}const z=()=>{const o=n.useRef(T()).current,[t,s]=n.useState(o.erro||!o.temToken?"invalido":"verificando"),[c,j]=n.useState(""),[h,g]=n.useState(!1),[i,N]=n.useState(""),k=R(),[p,S]=n.useState(""),[d,r]=n.useState(o.erro??"");n.useEffect(()=>{if(t!=="verificando")return;let a=!0;const{data:l}=f.auth.onAuthStateChange((C,m)=>{!a||C!=="PASSWORD_RECOVERY"||!m||(j(m.user.email??""),g(P(m.user.app_metadata)),s("pronto"))}),E=setTimeout(()=>{a&&(r("Não conseguimos validar o link. Ele pode já ter sido usado ou expirado."),s("invalido"))},L);return()=>{a=!1,clearTimeout(E),l.subscription.unsubscribe()}},[t]);const y=async a=>{if(a.preventDefault(),r(""),i.length<x){r(`A senha precisa ter pelo menos ${x} caracteres.`);return}if(i!==p){r("As senhas não conferem.");return}s("salvando");const{error:l}=await f.auth.updateUser({password:i});if(l){r(l.message),s("pronto");return}s("sucesso")},u="w-full bg-white/5 border border-white/10 rounded-xl pl-11 pr-4 py-3.5 text-sm text-white placeholder:text-white/30 focus:border-crimson focus:outline-none transition-colors";return e.jsxs(e.Fragment,{children:[e.jsxs(_,{children:[e.jsx("title",{children:"Definir senha â Growth Conference"}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsx("section",{className:"min-h-[75vh] flex items-center justify-center px-6 py-20",children:e.jsxs("div",{className:"w-full max-w-md",children:[t==="verificando"&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx(w,{className:"w-7 h-7 animate-spin text-crimson mx-auto mb-5"}),e.jsx("p",{className:"text-white/50 text-sm",children:"Validando seu linkâ¦"})]}),t==="invalido"&&e.jsxs("div",{className:"text-center",children:[e.jsx(v,{className:"w-10 h-10 text-crimson mx-auto mb-5"}),e.jsx("h1",{className:"text-2xl font-bold text-white mb-3",children:"Não foi possÃvel continuar"}),e.jsxs("p",{className:"text-white/50 text-sm leading-relaxed mb-8",children:[d||"Abra esta página pelo link que enviamos por e-mail."," Links de recuperação valem por tempo limitado e só podem ser usados uma vez."]}),e.jsx(A,{to:"/?login=1",className:"inline-block bg-white text-black px-7 py-3.5 rounded-xl text-xs font-bold uppercase tracking-widest hover:bg-white/90 transition-colors",children:"Pedir um novo link"})]}),t==="sucesso"&&e.jsxs("div",{className:"text-center",children:[e.jsx(D,{className:"w-10 h-10 text-emerald-400 mx-auto mb-5"}),e.jsx("h1",{className:"text-2xl font-bold text-white mb-3",children:"Senha alterada"}),e.jsxs("p",{className:"text-white/50 text-sm leading-relaxed mb-8",children:["A senha de ",e.jsx("span",{className:"text-white",children:c})," já está valendo."]}),e.jsx("a",{href:h?"/dashboard":"/",className:"inline-block bg-crimson text-white px-7 py-3.5 rounded-xl text-xs font-bold uppercase tracking-widest hover:bg-[#ff0022]/80 transition-colors",children:h?"Ir para o painel":"Voltar ao site"})]}),(t==="pronto"||t==="salvando")&&e.jsxs("form",{onSubmit:y,children:[e.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"Defina sua senha"}),e.jsxs("p",{className:"text-white/50 text-sm mb-8",children:["Você está definindo a senha de ",e.jsx("span",{className:"text-white",children:c}),". MÃnimo de ",x," caracteres."]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(b,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-white/30"}),e.jsx("input",{ref:k,type:"password",value:i,onChange:a=>N(a.target.value),placeholder:"Nova senha",autoComplete:"new-password",className:u,"aria-label":"Nova senha"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-white/30"}),e.jsx("input",{type:"password",value:p,onChange:a=>S(a.target.value),placeholder:"Repita a senha",autoComplete:"new-password",className:u,"aria-label":"Repita a nova senha"})]})]}),d&&e.jsxs("p",{className:"flex items-start gap-2 text-crimson text-xs mt-4 leading-relaxed",children:[e.jsx(v,{className:"w-4 h-4 shrink-0 mt-px"}),d]}),e.jsx("button",{type:"submit",disabled:t==="salvando",className:"w-full mt-8 bg-crimson text-white py-4 rounded-xl text-xs font-bold uppercase tracking-widest hover:bg-[#ff0022]/80 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",children:t==="salvando"?e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"w-4 h-4 animate-spin"})," Salvandoâ¦"]}):"Salvar senha"})]})]})})]})};export{z 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.