1import{k as P,g as k,l as S,r as h,u as C,i as F,j as e,B as d,L as u}from"./index-DqGUay4R.js";import{u as L,F as E,a as x,b as f,L as p,c as j,d as w,t as T,o as R,p as V,s as q}from"./form-BghMAYdC.js";import{N as I,F as B}from"./layout-kbI5kgxJ.js";import{I as v}from"./input-CAD2LJ82.js";import{C as O,b as U,c as z,d as M,a as $}from"./card-9pV9uJD0.js";import{L as A}from"./link-Bv_tRi8i.js";import{E as D,a as H}from"./eye-B3uMVStX.js";import"./slug-B4_u_JAc.js";const J=R({newPassword:V,confirmPassword:q()}).refine(t=>t.newPassword===t.confirmPassword,{message:"As senhas não coincidem",path:["confirmPassword"]});function ee(){const t=P(),a=new URLSearchParams(t).get("token")??"",[,i]=k(),{toast:N}=S(),[o,g]=h.useState(!1),{data:y,isLoading:l}=C({queryKey:["/api/password-reset/verify",a],queryFn:async()=>{const s=await fetch(`/api/password-reset/verify?token=${encodeURIComponent(a)}`);return s.ok?s.json():{valid:!1}},enabled:a.length>0,retry:!1}),n=L({resolver:T(J),defaultValues:{newPassword:"",confirmPassword:""}}),r=F({mutationFn:async s=>{const m=await fetch("/api/password-reset/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:a,newPassword:s.newPassword})});if(!m.ok){const b=await m.json().catch(()=>({}));throw new Error(b.message||"Não foi possÃvel redefinir a senha.")}},onSuccess:()=>{N({title:"Senha redefinida",description:"Faça login com a nova senha.",variant:"success"}),i("/auth")}});h.useEffect(()=>{a||i("/esqueci-senha")},[a,i]);const c=!!a&&y?.valid===!0;return e.jsxs("div",{className:"min-h-screen flex flex-col pt-16",children:[e.jsx(I,{}),e.jsx("main",{className:"flex-1 flex items-center justify-center p-4",children:e.jsxs(O,{className:"w-full max-w-sm border-hairline/10 bg-panel/40 backdrop-blur-md",children:[e.jsxs(U,{className:"text-center",children:[e.jsx(z,{className:"font-mono text-2xl text-primary",children:"Nova senha"}),e.jsx(M,{children:c?"Escolha uma senha com no mÃnimo 8 caracteres":"Verificando o link"})]}),e.jsxs($,{children:[l&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Verificando o link..."}),!l&&!c&&e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxs("div",{role:"alert",className:"flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/10 p-3",children:[e.jsx(A,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-destructive",children:"Link inválido ou expirado"}),e.jsx("p",{className:"text-muted-foreground",children:"Links de redefinição valem por 30 minutos e só podem ser usados uma vez."})]})]}),e.jsx(d,{asChild:!0,className:"w-full",children:e.jsx(u,{href:"/esqueci-senha",children:"Solicitar um novo link"})})]}),c&&e.jsx(E,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(s=>r.mutate(s)),className:"space-y-4",children:[e.jsx(x,{control:n.control,name:"newPassword",render:({field:s})=>e.jsxs(f,{children:[e.jsx(p,{children:"Nova senha"}),e.jsx(j,{children:e.jsxs("div",{className:"relative",children:[e.jsx(v,{type:o?"text":"password",className:"pr-10",...s}),e.jsx(d,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>g(!o),children:o?e.jsx(D,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(H,{className:"h-4 w-4 text-muted-foreground"})})]})}),e.jsx(w,{})]})}),e.jsx(x,{control:n.control,name:"confirmPassword",render:({field:s})=>e.jsxs(f,{children:[e.jsx(p,{children:"Confirme a nova senha"}),e.jsx(j,{children:e.jsx(v,{type:o?"text":"password",...s})}),e.jsx(w,{})]})}),r.isError&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:r.error.message}),e.jsx(d,{type:"submit",className:"w-full",disabled:r.isPending,children:r.isPending?"Salvando...":"Redefinir senha"})]})}),e.jsx("p",{className:"mt-4 text-center text-sm",children:e.jsx(u,{href:"/auth",className:"text-muted-foreground underline-offset-4 hover:text-primary hover:underline",children:"Voltar para o login"})})]})]})}),e.jsx(B,{})]})}export{ee 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.