import{_ as z}from"./DkDGCI7w.js";import{_ as A}from"./65lde3ZN.js";import{g as E,M as T,a0 as j,v as B,r as D,D as _,E as F,j as I,y as M,c as d,o as i,b as c,a as e,t as u,m as n,C as q,l as w,z as g,A as h,I as y,n as U,d as P,w as $,G}from"./Bh30i5oR.js";import{u as H}from"./DvQbTo8L.js";import{u as L}from"./CBd1T9Qn.js";import{a as J}from"./DJivVT1h.js";import"./DlAUqK2U.js";import"./BP8_MOlH.js";import"./Hxx5iRvK.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"},xe={__name:"[code]",setup(le){const{$externalConf:x}=E(),v=T(),C=j(),l=B(),{sanitizeText:p}=H(),{handlePasswordRecoveryError:k}=L(),a=D(!1),r=_({password:"",confirmPassword:""}),o=_({password:"",confirmPassword:""}),m=F(()=>C.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}=J();await s(t),l.success("Senha alterada com sucesso!"),setTimeout(()=>{v.push("/")},2e3)}catch(t){k(t,l)}finally{a.value=!1}}};return I(()=>{m.value||(l.error("Código de recuperação não encontrado"),v.push("/"))}),(t,s)=>{const V=z,b=M("FontAwesomeIcon"),R=A;return i(),d(G,null,[c(V),e("div",K,[e("div",O,[e("div",null,[e("div",Q,[e("h1",W,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:q(N,["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(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:U({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:$(()=>s[7]||(s[7]=[P(" Voltar ao login ")])),_:1,__:[7]})])],32)])])],64)}}};export{xe as default};
