import{j as e,b7 as C,o as n,l as f,k as y,E as L,aL as j,G as I,bT as S}from"./app-BgLa5dit.js";import{g as U,C as F}from"./kFxxSUq3.chunk.js";import{C as r,U as b}from"./q-IBKcuF.chunk.js";import"./w68yffRy.chunk.js";import"./DUpYPoLs.chunk.js";import"./EZim8aq-.chunk.js";import"./BD9MrUJP.chunk.js";import"./s6cGcwlA.chunk.js";import"./Zwjmkasg.chunk.js";import"./4qGb1BIY.chunk.js";import"./DnXDEnAR.chunk.js";import"./DpUpv6rY.chunk.js";import"./CG7zbly5.chunk.js";import"./m4aqaK_l.chunk.js";import"./MEkA24R1.chunk.js";import"./C53kfXmd.chunk.js";const k="userManager.changePasswordSsoWarning";function M(){return e.jsx("div",{className:"alert alert-warning",children:e.jsx(C,{namespace:k,phrase:"ssoWarning"})})}const N={newPassword:"",confirmPassword:"",changeOnNextLogin:!0};function Q(s){var u,m,l;const i=r.getUser(s.customerId,s.userId),a=n(i),c=n(r.passwordPolicy(s.customerId));n(r.getAuthenticationMethodsByUserIds(s.customerId,[s.userId],i.normalizeOptions.namespace));const t=(u=a.data)==null?void 0:u.userType,h=(l=(m=a.data)==null?void 0:m.userProfile)==null?void 0:l.role,d=f(),g=y();function w(p){const x=r.changeUserPassword(s.customerId,s.userId,t,p.newPassword,p.changeOnNextLogin);g(x).then(()=>d.success("Successfully updated password")).catch(()=>d.error("Failed to update password. Please try again.")).finally(s.closePopup)}const P=b.getMinimumPasswordLength(c.data,t,h),o=!!c.data&&!!a.data;return e.jsxs(L,{title:"Change password",closePopup:s.closePopup,showLoadingSpinner:!o,children:[!!o&&j.hasSso(a.data)&&e.jsx(M,{}),e.jsx(I,{initialValues:N,onSubmit:w,validationSchema:U(P),children:o&&e.jsx(F,{onClickCancel:s.closePopup,submitVariant:"dark",showChangeOnNextLogin:t===S.Learner,hideCurrentPassword:!0})})]})}export{Q as ChangePasswordView};
//# sourceMappingURL=D4lu-lFc.chunk.js.map
