import{ao as t,e3 as N,f9 as P,ck as T,L as b,bq as j,bN as w,c4 as A,bc as M,az as f,aj as v,dZ as U,cb as u,cf as d,m as F}from"./app-k0jcl5PQ.js";import{F as E}from"./C3DvQ1wU.chunk.js";import{S as _}from"./EHuWazu9.chunk.js";import{S as p}from"./BpDDe8SM.chunk.js";import{l as g}from"./DLmnDxSd.chunk.js";import"./CCtuxSlD.chunk.js";import"./CPXlV0fg.chunk.js";import"./ApI7cEru.chunk.js";import"./DXxHdeNz.chunk.js";import"./CpGXOT1_.chunk.js";import"./DkDkjje4.chunk.js";import"./hKqzfsO4.chunk.js";import"./fstW5ZQE.chunk.js";import"./9ls1F1Ve.chunk.js";import"./DRKUY7jf.chunk.js";import"./CW7x8M-z.chunk.js";const I=[5,6,7,8,9,10,11,12];function h(e){function r(n,s){n.preventDefault(),!(s<e.minLength)&&e.setMinimumPasswordLength(s)}function i(n){let s="btn border";return n===e.currentValue?s+=" btn-dark":s+=" btn-outline-dark",n<e.minLength&&(s+=" disabled"),s}return t.jsxs("div",{className:"pb-2",children:[t.jsx("h3",{className:"h6",children:e.headingText}),t.jsx("div",{className:"btn-group mb-1",children:I.map(n=>t.jsx("button",{className:i(n),onClick:s=>r(s,n),type:"button",children:n},n))}),t.jsx("p",{dangerouslySetInnerHTML:{__html:e.minPasswordLengthText}})]})}const V="settings.passwordSecuritySettings",a=b.encloseNamespace(V),k=5,C=8,D=8;function R(){const e=N(),r=P(e);return t.jsxs(T,{children:[t.jsx("h2",{className:"h4",children:a("heading")}),t.jsx(h,{currentValue:e.values.minStudentLength,headingText:a("studentSubheading"),minLength:k,minPasswordLengthText:a("minimumStudentLength",{length:e.values.minStudentLength}),setMinimumPasswordLength:i=>e.setFieldValue("minStudentLength",i)}),t.jsx(h,{currentValue:e.values.minStaffLength,headingText:a("staffSubheading"),minLength:C,minPasswordLengthText:a("minimumStaffLength",{length:e.values.minStaffLength}),setMinimumPasswordLength:i=>e.setFieldValue("minStaffLength",i)}),t.jsx(h,{currentValue:e.values.minAdminLength,headingText:a("adminSubheading"),minLength:D,minPasswordLengthText:a("minimumAdminLength",{length:e.values.minAdminLength}),setMinimumPasswordLength:i=>e.setFieldValue("minAdminLength",i)}),t.jsx("div",{className:"d-flex",children:t.jsx(j,{type:"submit",variant:"dark",disabled:!r,showSpinner:e.isSubmitting,children:a("saveChanges")})})]})}const q=g.object().shape({minStudentLength:g.number().required(),minStaffLength:g.number().required(),minAdminLength:g.number().required()}).noUnknown(),H="settings.securitySettings",c=b.encloseNamespace(H);function ae(){w({title:c("pageTitle")});const e=A(),r=M(),i=f(v.currentUser()),n=f(i.data&&p.getCustomerSecuritySettings(i.data.customerId)),{getMinimumPasswordLength:s}=U,l=s(n.data,u.Learner,d.User),S=s(n.data,u.Staff,d.User),L=s(n.data,u.Staff,d.Admin);function x(m,y){const o={securitySettings:[]};l!==m.minStudentLength&&o.securitySettings.push({userType:u.Learner,userRole:d.User,minPasswordLength:m.minStudentLength}),S!==m.minStaffLength&&o.securitySettings.push({userType:u.Staff,userRole:d.User,minPasswordLength:m.minStaffLength}),L!==m.minAdminLength&&o.securitySettings.push({userType:u.Staff,userRole:d.Admin,minPasswordLength:m.minAdminLength}),F(e,p.setCustomerSecuritySettings(i.data.customerId,o,()=>{r.success(c("success"))},()=>{r.error(c("error")),y({reset:!0})}))}return!!i.data&&!!n.data?t.jsx(_,{heading:c("heading"),breadcrumbs:[c("breadcrumb")],children:t.jsx(E,{initialValues:{minStudentLength:l,minStaffLength:S,minAdminLength:L},validationSchema:q,onSubmit:x,children:t.jsx(R,{})})}):t.jsx(t.Fragment,{})}export{ae as SecuritySettingsView};
//# sourceMappingURL=ayoTVI9p.chunk.js.map
