import{F as L,ai as U,L as D,aF as Q,K as M,c8 as H,J,M as N,r as j,m as b,P as f,Q as p,R as o,X as l,T as V,e,Y as O,_ as I,W as K,a5 as y,a6 as W,a1 as w,a2 as $,a0 as r,ag as X}from"./vendor-BmRNukEL.js";import{a7 as Y,aq as G,i as Z,am as x,co as B}from"./index-CfcNWeCf.js";import{u as ee,_ as se}from"./password-tips.vue_vue_type_script_setup_true_lang-ojWEKkfM.js";const oe=L({__name:"reset-password-form",props:{userId:{},token:{},mode:{default:"reset"}},emits:["succeeded"],setup(T,{emit:S}){const R=S,a=T,{t:h}=U(),{resetPassword:k,loading:_}=Y(),{passwordRequirements:d}=ee(),{translate:u}=G("identity_error"),q=D(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:q,initialValues:{password:"",confirmPassword:""},validateOnMount:!1}),{value:g}=N("password"),{value:c}=N("confirmPassword"),v=j(),C=b(()=>a.mode==="reset"),F=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 E=f("VcInput"),z=f("VcAlert"),A=f("VcButton");return o(),p("form",{class:"text-start",onSubmit:i[2]||(i[2]=(...t)=>e(F)&&e(F)(...t))},[l(E,{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(E,{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(),I(se,{key:0,requirements:e(d)},null,8,["requirements"])):K("",!0),(o(!0),p(y,null,W(v.value?.errors,t=>(o(),I(z,{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(A,{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)}}}),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=L({__name:"reset-password",setup(T){const S=X(),{t:R}=U();Z({title:R("pages.reset_password.meta.title")});const a=j(!1),h=x("userId"),k=x("token"),_=b(()=>!!(h.value&&k.value)),d=b(()=>S.name==="ResetPassword"),u=b(()=>d.value?"reset_password":"set_password"),q=b(()=>_.value?a.value?B.success:B.secondary:B.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(),I(v,{icon:"outline-security",image:d.value?"sign-in.jpg":"reg.jpg","status-color":q.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]=C=>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-CazK89jA.js.map
