import{C as U,V as D,an as L,ao as M,ap as i,ck as v,aq as Q,ar as w,r as G,N as p,D as q,E as n,Q as l,K as y,a3 as H,P as J,u as e,at as _,F as K,J as X,O as $,S,R as k}from"./vendor-BGtMsOoo.js";import{Q as j,an as z}from"./index-CRze-aDK.js";import{u as W,_ as Y}from"./password-tips.vue_vue_type_script_setup_true_lang-B130jHb2.js";const Z={class:"mt-5 max-sm:text-center"},f=64,re=U({__name:"change-password-form",emits:["succeeded"],setup(ee,{emit:B}){const N=B,{t:h}=D(),{changePassword:x,loading:C,user:F}=j(),{passwordRequirements:P}=W(),{translate:O}=z("identity_error"),A=L(M({oldPassword:i().required(),newPassword:i().required().when("oldPassword",{is:s=>!!s,then:s=>s.required().notOneOf([v("oldPassword")],h("common.messages.password_new_same_old"))}),confirmPassword:i().required().oneOf([v("newPassword")],h("common.messages.passwords_do_not_match"))})),{errors:r,meta:g,handleSubmit:E,resetForm:I}=Q({validationSchema:A,initialValues:{oldPassword:"",newPassword:"",confirmPassword:""},validateOnMount:!1}),{value:t}=w("oldPassword"),{value:d}=w("newPassword"),{value:m}=w("confirmPassword"),c=G(),V=E(async s=>{c.value=await x({userId:F.value.id,newPassword:s.newPassword,oldPassword:s.oldPassword}),c.value.succeeded&&(I(),N("succeeded"))});return(s,o)=>{var b;const u=p("VcInput"),R=p("VcAlert"),T=p("VcButton");return n(),q("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(),y(Y,{key:0,requirements:e(P)},null,8,["requirements"])):H("",!0),(n(!0),q(K,null,X((b=c.value)==null?void 0:b.errors,a=>(n(),y(R,{key:a.code,color:"danger",class:"my-5 text-xs",icon:""},{default:$(()=>[S(k(e(O)(a)),1)]),_:2},1024))),128)),J("div",Z,[l(T,{disabled:!e(g).valid||e(g).pending,loading:e(C),type:"submit","min-width":"12rem"},{default:$(()=>[S(k(s.$t("common.buttons.change")),1)]),_:1},8,["disabled","loading"])])],32)}}});export{re as _};
//# sourceMappingURL=change-password-form.vue_vue_type_script_setup_true_lang-BxW19iEF.js.map
