1import{d as J,S as K,o as Q,r as w,G as l,j as W,b as o,f as $,w as C,u as c,c as d,k as a,l as u,i,y as g,h as R,F as V,q as X,x as Y,e as ee}from"./vue.2b748c1d.js";import{c as se,u as re,a as ae,b as oe,P as N,A as te,C as ne,d as le,e as m,r as M,f as T,g as de,U as F,_ as ue}from"./index.64c41bef.js";import"./lottie.1d8d55a8.js";async function ie(q){await se.put("v1.0/users/password",q)}const we={key:0,class:"mx-auto max-w-md"},ce={class:"rounded-lg bg-green-100 p-6 text-green-900"},me={class:"mb-4"},ve={class:"mx-auto max-w-md"},pe={class:"mb-8"},ge={key:0,class:"mb-6 rounded-lg bg-error-200 p-4 text-error-900"},_e=["onSubmit"],he={class:"mb-6"},fe={class:"mb-2"},be={key:0,class:"mb-4 rounded-lg bg-error-200 p-3 text-caption text-error-900",role:"alert"},Pe={class:"mb-6 flex flex-col gap-2"},ke={key:2,class:"inline-block h-3 w-3 rounded-full border-2 border-brand-brown/40"},ye={key:1,class:"mb-6 text-caption text-error-600"},xe={key:2,class:"mb-6 text-caption text-error-600"},$e={class:"mb-6"},Ce={key:0,class:"mt-1 text-caption text-error-600"},Ve=J({__name:"ChangePasswordView",setup(q){const{isEmailPasswordLogin:S}=le(),Z=K(),{t:n}=re(),j=ae();Q(()=>{S||(j.error(n("shared.generic_error")),Z.push({name:"onboarding"}))});const e=w({currentPassword:"",newPassword:"",confirmNewPassword:""}),b=w(!1),P=w(!1),k=w(!1),_=w(!1),y=w(!1),h=w(!1),v=w(""),L=l(()=>e.value.newPassword.length>=8),A=l(()=>/[A-Z]/.test(e.value.newPassword)),E=l(()=>/[a-z]/.test(e.value.newPassword)),U=l(()=>/[0-9]/.test(e.value.newPassword)),z=l(()=>/[^a-zA-Z0-9]/.test(e.value.newPassword)),x=l(()=>e.value.newPassword.length>128),B=l(()=>L.value&&A.value&&E.value&&U.value&&z.value&&!x.value),D=l(()=>[{key:"rule_min_length",met:L.value},{key:"rule_uppercase",met:A.value},{key:"rule_lowercase",met:E.value},{key:"rule_number",met:U.value},{key:"rule_special",met:z.value}]),G=l(()=>e.value.confirmNewPassword.length>0&&e.value.confirmNewPassword!==e.value.newPassword),I=l(()=>e.value.newPassword.length>0&&e.value.newPassword===e.value.currentPassword),O=l(()=>({currentPassword:{required:m.withMessage(n("register.password_requirements"),M)},newPassword:{required:m.withMessage(n("register.password_requirements"),M),maxLength:m.withMessage(n("register.error_max_length"),()=>!x.value),valid:m.withMessage(n("register.password_requirements"),()=>B.value),different:m.withMessage(n("change_password.error_same_password"),()=>!I.value)},confirmNewPassword:{required:m.withMessage(n("register.confirm_mismatch"),M),match:m.withMessage(n("register.confirm_mismatch"),s=>s===e.value.newPassword)}})),p=oe(O,e),H=async()=>{if(h.value=!0,await p.value.$validate(),!p.value.$error){_.value=!0,v.value="";try{await ie({currentPassword:e.value.currentPassword,newPassword:e.value.newPassword}),y.value=!0}catch(s){const f=de(s)?.id?.toUpperCase();f===F.InvalidCurrentPassword?(v.value=n("change_password.error_invalid_current"),e.value.currentPassword=""):f===F.SamePassword?(v.value=n("change_password.error_same_password"),e.value.newPassword="",e.value.confirmNewPassword=""):(v.value=n("change_password.error_generic"),e.value.currentPassword="",e.value.newPassword="",e.value.confirmNewPassword=""),p.value.$reset()}finally{_.value=!1}}};return(s,t)=>{const f=W("RouterLink");return o(),$(ne,{class:"pt-container"},{default:C(()=>[c(S)?(o(),d(V,{key:0},[a(" Success state "),y.value?(o(),d("div",we,[u("div",ce,[u("p",me,i(s.$t("change_password.success")),1),g(f,{to:{name:"onboarding"},class:"underline hover:opacity-80"},{default:C(()=>[R(i(s.$t("change_password.back_to_onboarding")),1)]),_:1})])])):(o(),d(V,{key:1},[a(" Form "),u("div",ve,[u("h2",pe,i(s.$t("change_password.title")),1),a(" Error banner "),v.value?(o(),d("div",ge,[u("p",null,i(v.value),1)])):a("v-if",!0),u("form",{onSubmit:X(H,["prevent"])},[a(" Current password field "),u("div",he,[g(N,{modelValue:e.value.currentPassword,"onUpdate:modelValue":t[0]||(t[0]=r=>e.value.currentPassword=r),label:s.$t("change_password.current_password_label"),show:b.value,autocomplete:"current-password",onToggle:t[1]||(t[1]=r=>b.value=!b.value)},null,8,["modelValue","label","show"])]),a(" New password field "),u("div",fe,[g(N,{modelValue:e.value.newPassword,"onUpdate:modelValue":t[2]||(t[2]=r=>e.value.newPassword=r),label:s.$t("change_password.new_password_label"),show:P.value,autocomplete:"new-password",onToggle:t[3]||(t[3]=r=>P.value=!P.value)},null,8,["modelValue","label","show"])]),a(" Inline warning shown after a failed submit attempt "),h.value&&!c(B)?(o(),d("div",be,i(s.$t("register.error_requirements_not_met")),1)):a("v-if",!0),a(" Password requirements checklist "),u("div",Pe,[(o(!0),d(V,null,Y(c(D),r=>(o(),d("div",{key:r.key,class:"flex items-center gap-2"},[r.met?(o(),$(T,{key:0,name:"check",size:"xs",color:"text-brand-green"})):h.value?(o(),$(T,{key:1,name:"close",size:"xs",color:"text-error-600"})):(o(),d("span",ke)),u("span",{class:ee([r.met?"text-brand-green":h.value?"text-error-600":"text-brand-brown/70","text-caption"])},i(s.$t(`register.${r.key}`)),3)]))),128))]),c(x)||c(p).newPassword.$errors.some(r=>r.$validator==="maxLength")?(o(),d("div",ye,i(s.$t("register.error_max_length")),1)):a("v-if",!0),c(I)?(o(),d("div",xe,i(s.$t("change_password.error_same_password")),1)):a("v-if",!0),a(" Confirm new password field "),u("div",$e,[g(N,{modelValue:e.value.confirmNewPassword,"onUpdate:modelValue":t[4]||(t[4]=r=>e.value.confirmNewPassword=r),label:s.$t("change_password.confirm_new_password_label"),show:k.value,autocomplete:"new-password",onToggle:t[5]||
1(t[5]=r=>k.value=!k.value)},null,8,["modelValue","label","show"]),c(G)||c(p).confirmNewPassword.$error?(o(),d("div",Ce,i(s.$t("register.confirm_mismatch")),1)):a("v-if",!0)]),a(" Submit button "),g(te,{component:"button",variant:"secondary",class:"mt-16 mb-8 w-full",loading:_.value,disabled:_.value||y.value},{default:C(()=>[R(i(s.$t("change_password.submit")),1)]),_:1},8,["loading","disabled"])],40,_e)])],2112))],64)):a("v-if",!0)]),_:1})}}}),Se=ue(Ve,[["__file","/codebuild/output/src2067005452/src/src/views/ChangePasswordView.vue"]]);export{Se as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.