import{F as x,ag as D,L as A,aD as Q,K as M,c7 as H,J,M as N,r as L,m as b,P as f,Q as p,R as o,X as l,T as V,e,Y as O,_ as q,W as K,a6 as y,a7 as W,a1 as w,a2 as $,a0 as r,af as X}from"./vendor-d3O24IFR.js";import{a4 as Y,av as G,f as Z,aj as j,bC as I}from"./index-DHcvdVIa.js";import{u as ee,_ as se}from"./password-tips.vue_vue_type_script_setup_true_lang-CcGf0gaX.js";const oe=x({__name:"reset-password-form",props:{userId:{},token:{},mode:{default:"reset"}},emits:["succeeded"],setup(C,{emit:S}){const R=S,a=C,{t:h}=D(),{resetPassword:k,loading:_}=Y(),{passwordRequirements:d}=ee(),{translate:u}=G("identity_error"),B=A(Q({password:M().required(),confirmPassword:M().required().oneOf([H("password")],h("common.messages.passwords_do_not_match"))})),{errors:m,meta:s,handleSubmit:P}=J({validationSchema:B,initialValues:{password:"",confirmPassword:""},validateOnMount:!1}),{value:g}=N("password"),{value:c}=N("confirmPassword"),v=L(),T=b(()=>a.mode==="reset"),E=P(async n=>{v.value=await k({userId:a.userId,token:a.token,password:`${n.password}`}),v.value.succeeded&&R("succeeded")});return(n,i)=>{const F=f("VcInput"),U=f("VcAlert"),z=f("VcButton");return o(),p("form",{class:"text-start",onSubmit:i[2]||(i[2]=(...t)=>e(E)&&e(E)(...t))},[l(F,{modelValue:e(g),"onUpdate:modelValue":i[0]||(i[0]=t=>O(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(F,{modelValue:e(c),"onUpdate:modelValue":i[1]||(i[1]=t=>O(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(se,{key:0,requirements:e(d)},null,8,["requirements"])):K("",!0),(o(!0),p(y,null,W(v.value?.errors,t=>(o(),q(U,{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(z,{type:"submit",class:"mt-6 w-full lg:w-52",loading:e(_),disabled:!e(s).valid||e(s).pending},{default:w(()=>[$(r(n.$t(T.value?"common.buttons.reset_password":"common.buttons.save")),1)]),_:1},8,["loading","disabled"])])],32)}}}),ae={class:"w-full sm:pe-12 md:pe-24"},te={class:"mb-4 text-base font-bold"},re={class:"mb-3 text-base sm:mb-6"},ne={class:"mb-3 text-base font-bold text-danger sm:mb-6"},me=x({__name:"reset-password",setup(C){const S=X(),{t:R}=D();Z({title:R("pages.reset_password.meta.title")});const a=L(!1),h=j("userId"),k=j("token"),_=b(()=>!!(h.value&&k.value)),d=b(()=>S.name==="ResetPassword"),u=b(()=>d.value?"reset_password":"set_password"),B=b(()=>_.value?a.value?I.success:I.secondary:I.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":B.value,"hide-mobile-side":_.value&&!a.value},{default:w(()=>[V("div",ae,[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",re,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",te,r(s.$t(`pages.${u.value}.enter_new_password_message`)),1),l(e(oe),{"user-id":e(h),token:e(k),mode:d.value?"reset":"set",class:"w-full",onSucceeded:P[0]||(P[0]=T=>m())},null,8,["user-id","token","mode"])],64))],64)):(o(),p(y,{key:1},[V("div",ne,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{me as default};
//# sourceMappingURL=reset-password-CrByu6vz.js.map
