import{_ as z}from"./BK_BLNxW.js";import{_ as A}from"./B-gxyKwS.js";import{g as F,Y as T,Z as j,v as B,r as E,$ as _,J as I,j as D,y as M,c as d,o as i,b as c,a as e,t as u,m as n,C as $,l as w,z as g,A as h,F as y,n as q,d as P,w as U,I as H}from"./CQHo_aHN.js";import{u as J}from"./DvQbTo8L.js";import{u as L}from"./BBkQyLon.js";import{a as Y}from"./DTD-Bmou.js";import"./DlAUqK2U.js";import"./CU-5m29H.js";import"./pwbP0T5r.js";const Z={class:"flex min-h-screen items-center justify-center bg-gray-50 px-4 py-12 sm:px-6 lg:px-8"},G={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}=F(),v=T(),C=j(),l=B(),{sanitizeText:p}=J(),{handlePasswordRecoveryError:k}=L(),a=E(!1),r=_({password:"",confirmPassword:""}),o=_({password:"",confirmPassword:""}),m=I(()=>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}=Y();await s(t),l.success("Senha alterada com sucesso!"),setTimeout(()=>{v.push("/")},2e3)}catch(t){k(t,l)}finally{a.value=!1}}};return D(()=>{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(H,null,[c(V),e("div",Z,[e("div",G,[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:$(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:q({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};
