import{K as F,Z as L,at as Q,aB as H,as as M,c9 as K,ar as W,au as U,r as j,B as b,S as f,L as p,M as o,V as l,U as V,b as e,az as x,P as q,a7 as X,N as y,O as Z,T as w,X as $,W as r,aP as G}from"./vendor-bSWkQivH.js";import{Q as J,aT as Y,i as ee,a7 as z,aV as R}from"./index-Dqv5IkpS.js";import{u as se,_ as oe}from"./password-tips.vue_vue_type_script_setup_true_lang-B1kt45HN.js";const ae=F({__name:"reset-password-form",props:{userId:{},token:{},mode:{default:"reset"}},emits:["succeeded"],setup(T,{emit:S}){const B=S,a=T,{t:h}=L(),{resetPassword:k,loading:_}=J(),{passwordRequirements:d}=se(),{translate:u}=Y("identity_error"),I=Q(H({password:M().required(),confirmPassword:M().required().oneOf([K("password")],h("common.messages.passwords_do_not_match"))})),{errors:m,meta:s,handleSubmit:P}=W({validationSchema:I,initialValues:{password:"",confirmPassword:""},validateOnMount:!1}),{value:g}=U("password"),{value:c}=U("confirmPassword"),v=j(),C=b(()=>a.mode==="reset"),N=P(async n=>{v.value=await k({userId:a.userId,token:a.token,password:`${n.password}`}),v.value.succeeded&&B("succeeded")});return(n,i)=>{var E;const O=f("VcInput"),A=f("VcAlert"),D=f("VcButton");return o(),p("form",{class:"text-start",onSubmit:i[2]||(i[2]=(...t)=>e(N)&&e(N)(...t))},[l(O,{modelValue:e(g),"onUpdate:modelValue":i[0]||(i[0]=t=>x(g)?g.value=t:null),class:"mb-4 w-full",label:n.$t("common.labels.password"),placeholder:n.$t("common.placeholders.password"),type:"password",required:"",message:e(m).password,error:!!e(m).password,autocomplete:"new-password",maxlength:64},null,8,["modelValue","label","placeholder","message","error"]),l(O,{modelValue:e(c),"onUpdate:modelValue":i[1]||(i[1]=t=>x(c)?c.value=t:null),class:"mb-4 w-full",label:n.$t("common.labels.confirm_password"),placeholder:n.$t("common.placeholders.confirm_password"),type:"password",required:"",message:e(m).confirmPassword,error:!!e(m).confirmPassword,autocomplete:"off",maxlength:64},null,8,["modelValue","label","placeholder","message","error"]),V("div",null,[e(d)?(o(),q(oe,{key:0,requirements:e(d)},null,8,["requirements"])):X("",!0),(o(!0),p(y,null,Z((E=v.value)==null?void 0:E.errors,t=>(o(),q(A,{key:t.code,class:"my-5 text-xs",color:"danger",size:"sm",variant:"solid-light",icon:""},{default:w(()=>[$(r(e(u)(t)),1)]),_:2},1024))),128)),l(D,{type:"submit",class:"mt-6 w-full lg:w-52",loading:e(_),disabled:!e(s).valid||e(s).pending},{default:w(()=>[$(r(n.$t(C.value?"common.buttons.reset_password":"common.buttons.save")),1)]),_:1},8,["loading","disabled"])])],32)}}}),te={class:"w-full sm:pe-12 md:pe-24"},re={class:"mb-4 text-base font-bold"},ne={class:"mb-3 text-base sm:mb-6"},le={class:"mb-3 text-base font-bold text-danger sm:mb-6"},ce=F({__name:"reset-password",setup(T){const S=G(),{t:B}=L();ee({title:B("pages.reset_password.meta.title")});const a=j(!1),h=z("userId"),k=z("token"),_=b(()=>!!(h.value&&k.value)),d=b(()=>S.name==="ResetPassword"),u=b(()=>d.value?"reset_password":"set_password"),I=b(()=>_.value?a.value?R.success:R.secondary:R.danger);function m(){a.value=!0,window.scroll(0,0)}return(s,P)=>{const g=f("VcTypography"),c=f("VcButton"),v=f("VcEmptyPage");return o(),q(v,{icon:"outline-security",image:d.value?"sign-in.jpg":"reg.jpg","status-color":I.value,"hide-mobile-side":_.value&&!a.value},{default:w(()=>[V("div",te,[l(g,{tag:"h1",class:"order-first mb-3"},{default:w(()=>[$(r(s.$t(`pages.${u.value}.header`)),1)]),_:1}),_.value?(o(),p(y,{key:0},[a.value?(o(),p(y,{key:1},[V("div",ne,r(s.$t(`pages.${u.value}.success_message`)),1),l(c,{to:{name:"SignIn"},"min-width":"12rem"},{default:w(()=>[$(r(s.$t(`pages.${u.value}.log_in_button`)),1)]),_:1})],64)):(o(),p(y,{key:0},[V("div",re,r(s.$t(`pages.${u.value}.enter_new_password_message`)),1),l(e(ae),{"user-id":e(h),token:e(k),mode:d.value?"reset":"set",class:"w-full",onSucceeded:P[0]||(P[0]=C=>m())},null,8,["user-id","token","mode"])],64))],64)):(o(),p(y,{key:1},[V("div",le,r(s.$t("common.messages.invalid_user_id_or_token")),1),l(c,{to:"/","min-width":"12rem"},{default:w(()=>[$(r(s.$t("common.buttons.home")),1)]),_:1})],64))])]),_:1},8,["image","status-color","hide-mobile-side"])}}});export{ce as default};
//# sourceMappingURL=reset-password-DZs_OogZ.js.map
