import{_ as A}from"./BEzNrT7f.js";import{_ as z}from"./DhjIdhCy.js";import{g as E,Y as T,Z as B,q as F,r as I,$ as _,J as j,G as q,v as D,c as d,o as i,b as c,a as e,t as u,k as n,A as M,C as w,x as g,y as h,E as y,n as $,d as P,w as U,I as G}from"./BpDVC-Oo.js";import{u as H}from"./DvQbTo8L.js";import{u as J}from"./BBkQyLon.js";import{a as L}from"./ChaLeZb-.js";import"./DlAUqK2U.js";import"./Bbtohs3j.js";import"./C0JZ2vpu.js";const Y={class:"flex min-h-screen items-center justify-center bg-gray-50 px-4 py-12 sm:px-6 lg:px-8"},Z={class:"w-full max-w-md space-y-8"},K={class:"mx-auto flex h-12 w-auto justify-center"},O={class:"text-3xl font-bold",style:{color:"var(--primary)"}},Q={class:"space-y-4"},W={class:"relative"},X={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"},xe={__name:"[code]",setup(le){const{$externalConf:x}=E(),v=T(),k=B(),l=F(),{sanitizeText:p}=H(),{handlePasswordRecoveryError:C}=J(),a=I(!1),r=_({password:"",confirmPassword:""}),o=_({password:"",confirmPassword:""}),m=j(()=>k.params.code),S=()=>{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},N=async()=>{if(S()){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}=L();await s(t),l.success("Senha alterada com sucesso!"),setTimeout(()=>{v.push("/")},2e3)}catch(t){C(t,l)}finally{a.value=!1}}};return q(()=>{m.value||(l.error("Código de recuperação não encontrado"),v.push("/"))}),(t,s)=>{const V=A,b=D("FontAwesomeIcon"),R=z;return i(),d(G,null,[c(V),e("div",Y,[e("div",Z,[e("div",null,[e("div",K,[e("h1",O,u(n(x).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 SisDemanda. ",-1))]),e("form",{class:"mt-8 space-y-6",onSubmit:M(N,["prevent"])},[e("div",Q,[e("div",null,[s[4]||(s[4]=e("label",{for:"password",class:"sr-only"},"Nova senha",-1)),e("div",W,[e("div",X,[c(b,{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:y(["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(b,{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:y(["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:y(["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:$({backgroundColor:n(a)?void 0:n(x).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:U(()=>s[7]||(s[7]=[P(" Voltar ao login ")])),_:1,__:[7]})])],32)])])],64)}}};export{xe as default};
