import{F as U,ai as E,L,aF as M,K as i,c8 as b,J as X,M 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-D0AQuxPe.js";import{a3 as Q,an as W}from"./index-BZGh_npj.js";import{u as Y,_ as j}from"./password-tips.vue_vue_type_script_setup_true_lang-M3fNVJKj.js";const z={class:"mt-5 max-sm:text-center"},f=64,oe=U({__name:"change-password-form",emits:["succeeded"],setup(Z,{emit:B}){const F=B,{t:h}=E(),{changePassword:k,loading:x,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:I}=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 k({userId:N.value.id,newPassword:s.newPassword,oldPassword:s.oldPassword}),c.value.succeeded&&(I(),F("succeeded"))});return(s,o)=>{const u=p("VcInput"),O=p("VcAlert"),R=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(O,{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(R,{disabled:!e(g).valid||e(g).pending,loading:e(x),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-CCQyGLJE.js.map
