import{_ as A}from"./Cx_OC0SQ.js";import{_ as F}from"./DChqHtgW.js";import{g as z,N as T,a1 as j,A as B,r as D,a2 as _,M as E,j as M,C as I,c as d,o as i,b as c,a as e,t as u,p as n,G as q,x as w,l as g,D as h,n as x,m as U,d as P,w as $,F as G}from"./UpFGpe05.js";import{u as H}from"./DvQbTo8L.js";import{u as L}from"./CBd1T9Qn.js";import{a as J}from"./B2llNqhU.js";import"./DlAUqK2U.js";import"./DsXiT_L-.js";import"./zbMs9D6X.js";const K={class:"flex min-h-screen items-center justify-center bg-gray-50 px-4 py-12 sm:px-6 lg:px-8"},O={class:"w-full max-w-md space-y-8"},Q={class:"mx-auto flex h-12 w-auto justify-center"},W={class:"text-3xl font-bold",style:{color:"var(--primary)"}},X={class:"space-y-4"},Y={class:"relative"},Z={class:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3"},ee={key:0,class:"mt-1 text-sm text-red-600"},se={class:"relative"},oe={class:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3"},re={key:0,class:"mt-1 text-sm text-red-600"},te=["disabled"],ae={key:0,class:"absolute inset-y-0 left-0 flex items-center pl-3"},ne={class:"text-center"},ye={__name:"[code]",setup(le){const{$externalConf:y}=z(),b=T(),C=j(),l=B(),{sanitizeText:p}=H(),{handlePasswordRecoveryError:k}=L(),a=D(!1),r=_({password:"",confirmPassword:""}),o=_({password:"",confirmPassword:""}),m=E(()=>C.params.code),N=()=>{o.password="",o.confirmPassword="";let t=!0;return r.password?r.password.length<6&&(o.password="Senha deve ter pelo menos 6 caracteres",t=!1):(o.password="Senha é obrigatória",t=!1),r.confirmPassword?r.password!==r.confirmPassword&&(o.confirmPassword="Senhas não coincidem",t=!1):(o.confirmPassword="Confirmação de senha é obrigatória",t=!1),t},S=async()=>{if(N()){if(!m.value){l.error("Código de recuperação inválido");return}a.value=!0;try{const t={password:p(r.password),confirmPassword:p(r.confirmPassword),login:p(m.value)},{resetPasswordConfirm:s}=J();await s(t),l.success("Senha alterada com sucesso!"),setTimeout(()=>{b.push("/")},2e3)}catch(t){k(t,l)}finally{a.value=!1}}};return M(()=>{m.value||(l.error("Código de recuperação não encontrado"),b.push("/"))}),(t,s)=>{const V=A,v=I("FontAwesomeIcon"),R=F;return i(),d(G,null,[c(V),e("div",K,[e("div",O,[e("div",null,[e("div",Q,[e("h1",W,u(n(y).siglaEmpresa),1)]),s[2]||(s[2]=e("h2",{class:"mt-6 text-center text-3xl font-extrabold",style:{color:"var(--primary)"}}," Recuperar senha ",-1)),s[3]||(s[3]=e("p",{class:"mt-2 text-center text-sm text-gray-600"}," Informe a nova senha para poder ter acesso ao Faixa de Domínio. ",-1))]),e("form",{class:"mt-8 space-y-6",onSubmit:q(S,["prevent"])},[e("div",X,[e("div",null,[s[4]||(s[4]=e("label",{for:"password",class:"sr-only"},"Nova senha",-1)),e("div",Y,[e("div",Z,[c(v,{icon:["fas","lock"],class:"h-5 w-5 text-gray-400"})]),g(e("input",{id:"password","onUpdate:modelValue":s[0]||(s[0]=f=>r.password=f),name:"password",type:"password",required:"",class:x(["relative block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 pl-10 text-gray-900 placeholder-gray-500 focus:z-10 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500 sm:text-sm",{"border-red-500":o.password}]),placeholder:"Nova senha"},null,2),[[h,r.password]])]),o.password?(i(),d("p",ee,u(o.password),1)):w("",!0)]),e("div",null,[s[5]||(s[5]=e("label",{for:"confirmPassword",class:"sr-only"},"Confirmar senha",-1)),e("div",se,[e("div",oe,[c(v,{icon:["fas","lock"],class:"h-5 w-5 text-gray-400"})]),g(e("input",{id:"confirmPassword","onUpdate:modelValue":s[1]||(s[1]=f=>r.confirmPassword=f),name:"confirmPassword",type:"password",required:"",class:x(["relative block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 pl-10 text-gray-900 placeholder-gray-500 focus:z-10 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500 sm:text-sm",{"border-red-500":o.confirmPassword}]),placeholder:"Repetir senha"},null,2),[[h,r.confirmPassword]])]),o.confirmPassword?(i(),d("p",re,u(o.confirmPassword),1)):w("",!0)])]),e("div",null,[e("button",{type:"submit",disabled:n(a),class:x(["group relative flex w-full justify-center rounded-md border border-transparent px-4 py-2 text-sm font-medium text-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",[n(a)?"bg-gray-400":"bg-blue-600 hover:bg-blue-700"]]),style:U({backgroundColor:n(a)?void 0:n(y).colors.primary})},[n(a)?(i(),d("span",ae,s[6]||(s[6]=[e("div",{class:"h-5 w-5 rounded-full border-b-2 border-white"},null,-1)]))):w("",!0),P(" "+u(n(a)?"Alterando...":"Alterar Senha"),1)],14,te)]),e("div",ne,[c(R,{to:"/login",class:"font-medium",style:{color:"var(--primary)"}},{default:$(()=>s[7]||(s[7]=[P(" Voltar ao login ")])),_:1,__:[7]})])],32)])])],64)}}};export{ye as default};
