import{F as R,ai as U,L,aE as M,M as i,c8 as b,J as X,K as w,r as D,P as p,Q as v,R as n,X as l,_ as q,W as G,T as H,e,Y as _,a5 as J,a6 as K,a1 as y,a2 as $,a0 as S}from"./vendor-CHzKNe_Q.js";import{a6 as Q,ap as W}from"./index-D6o2tNli.js";import{u as Y,_ as j}from"./password-tips.vue_vue_type_script_setup_true_lang-DymvRM8V.js";const z={class:"mt-5 max-sm:text-center"},f=64,oe=R({__name:"change-password-form",emits:["succeeded"],setup(Z,{emit:B}){const k=B,{t:h}=U(),{changePassword:x,loading:F,user:N}=Q(),{passwordRequirements:P}=Y(),{translate:T}=W("identity_error"),A=L(M({oldPassword:i().required(),newPassword:i().required().when("oldPassword",{is:s=>!!s,then:s=>s.required().notOneOf([b("oldPassword")],h("common.messages.password_new_same_old"))}),confirmPassword:i().required().oneOf([b("newPassword")],h("common.messages.passwords_do_not_match"))})),{errors:r,meta:g,handleSubmit:C,resetForm:E}=X({validationSchema:A,initialValues:{oldPassword:"",newPassword:"",confirmPassword:""},validateOnMount:!1}),{value:t}=w("oldPassword"),{value:d}=w("newPassword"),{value:m}=w("confirmPassword"),c=D(),V=C(async s=>{c.value=await x({userId:N.value.id,newPassword:s.newPassword,oldPassword:s.oldPassword}),c.value.succeeded&&(E(),k("succeeded"))});return(s,o)=>{const u=p("VcInput"),I=p("VcAlert"),O=p("VcButton");return n(),v("form",{class:"w-full text-start",onSubmit:o[3]||(o[3]=(...a)=>e(V)&&e(V)(...a))},[l(u,{modelValue:e(t),"onUpdate:modelValue":o[0]||(o[0]=a=>_(t)?t.value=a:null),class:"mb-5",label:s.$t("shared.account.change_password_form.current_pass_label"),placeholder:s.$t("shared.account.change_password_form.current_pass_placeholder"),type:"password",required:"",message:e(r).oldPassword,error:!!e(r).oldPassword,autocomplete:"off",maxlength:f},null,8,["modelValue","label","placeholder","message","error"]),l(u,{modelValue:e(d),"onUpdate:modelValue":o[1]||(o[1]=a=>_(d)?d.value=a:null),class:"mb-5",label:s.$t("shared.account.change_password_form.new_pass_label"),placeholder:s.$t("shared.account.change_password_form.new_pass_placeholder"),type:"password",required:"",message:e(r).newPassword,error:!!e(r).newPassword,autocomplete:"off",maxlength:f},null,8,["modelValue","label","placeholder","message","error"]),l(u,{modelValue:e(m),"onUpdate:modelValue":o[2]||(o[2]=a=>_(m)?m.value=a:null),class:"mb-5",label:s.$t("shared.account.change_password_form.confirm_new_pass_label"),placeholder:s.$t("shared.account.change_password_form.confirm_new_pass_placeholder"),type:"password",required:"",message:e(r).confirmPassword,error:!!e(r).confirmPassword,autocomplete:"off",maxlength:f},null,8,["modelValue","label","placeholder","message","error"]),e(P)?(n(),q(j,{key:0,requirements:e(P)},null,8,["requirements"])):G("",!0),(n(!0),v(J,null,K(c.value?.errors,a=>(n(),q(I,{key:a.code,color:"danger",class:"my-5 text-xs",icon:""},{default:y(()=>[$(S(e(T)(a)),1)]),_:2},1024))),128)),H("div",z,[l(O,{disabled:!e(g).valid||e(g).pending,loading:e(F),type:"submit","min-width":"12rem"},{default:y(()=>[$(S(s.$t("common.buttons.change")),1)]),_:1},8,["disabled","loading"])])],32)}}});export{oe as _};
//# sourceMappingURL=change-password-form.vue_vue_type_script_setup_true_lang-Bg0QeM4x.js.map
