import{F as L,ai as U,L as D,aE as Q,M,c8 as H,J,K as N,r as j,P as f,Q as p,R as o,X as l,T as b,e,Y as O,_ as q,W as K,a5 as V,a6 as W,a1 as w,a2 as h,a0 as r,m as y,ag as X}from"./vendor-D8NNcBCx.js";import{a6 as Y,ap as G,h as Z,al as x,ct as I}from"./index-CiAiYnez.js";import{u as ee,_ as se}from"./password-tips.vue_vue_type_script_setup_true_lang-D3YWHYpR.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:$}=U(),{resetPassword:k,loading:_}=Y(),{passwordRequirements:d}=ee(),{translate:u}=G("identity_error"),B=D(Q({password:M().required(),confirmPassword:M().required().oneOf([H("password")],$("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=j(),C=y(()=>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"),z=f("VcAlert"),A=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"]),b("div",null,[e(d)?(o(),q(se,{key:0,requirements:e(d)},null,8,["requirements"])):K("",!0),(o(!0),p(V,null,W(v.value?.errors,t=>(o(),q(z,{key:t.code,class:"my-5 text-xs",color:"danger",size:"sm",variant:"solid-light",icon:""},{default:w(()=>[h(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(()=>[h(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),$=x("userId"),k=x("token"),_=y(()=>!!($.value&&k.value)),d=y(()=>S.name==="ResetPassword"),u=y(()=>d.value?"reset_password":"set_password"),B=y(()=>_.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(()=>[b("div",ae,[l(g,{tag:"h1",class:"order-first mb-3"},{default:w(()=>[h(r(s.$t(`pages.${u.value}.header`)),1)]),_:1}),_.value?(o(),p(V,{key:0},[a.value?(o(),p(V,{key:1},[b("div",re,r(s.$t(`pages.${u.value}.success_message`)),1),l(c,{to:{name:"SignIn"},"min-width":"12rem"},{default:w(()=>[h(r(s.$t(`pages.${u.value}.log_in_button`)),1)]),_:1})],64)):(o(),p(V,{key:0},[b("div",te,r(s.$t(`pages.${u.value}.enter_new_password_message`)),1),l(e(oe),{"user-id":e($),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(V,{key:1},[b("div",ne,r(s.$t("common.messages.invalid_user_id_or_token")),1),l(c,{to:"/","min-width":"12rem"},{default:w(()=>[h(r(s.$t("common.buttons.home")),1)]),_:1})],64))])]),_:1},8,["image","status-color","hide-mobile-side"])}}});export{me as default};
//# sourceMappingURL=reset-password-CqJ80F27.js.map
