import{F as U,ag as E,L,aD as M,K as i,c7 as b,J as D,M as w,r as X,P as p,Q as v,R as n,X as l,_ as q,W as G,T as H,e,Y as _,a6 as J,a7 as K,a1 as y,a2 as $,a0 as S}from"./vendor-d3O24IFR.js";import{a4 as Q,av as W}from"./index-Bi4pIh8m.js";import{u as Y,_ as j}from"./password-tips.vue_vue_type_script_setup_true_lang-CVYlZXh9.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 k=B,{t:h}=E(),{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:I}=D({validationSchema:A,initialValues:{oldPassword:"",newPassword:"",confirmPassword:""},validateOnMount:!1}),{value:t}=w("oldPassword"),{value:d}=w("newPassword"),{value:m}=w("confirmPassword"),c=X(),V=C(async s=>{c.value=await x({userId:N.value.id,newPassword:s.newPassword,oldPassword:s.oldPassword}),c.value.succeeded&&(I(),k("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(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-B1hbDE06.js.map
