import{ao as s,aI as G,e3 as L,ck as k,L as F,aQ as U,aq as l,cc as A,cd as $,az as j,aj as H,b0 as R,bc as P,bN as w,aU as m,aP as E,ar as C,aG as y,aH as z}from"./app-k0jcl5PQ.js";import{F as D}from"./C3DvQ1wU.chunk.js";import{S as Y}from"./EHuWazu9.chunk.js";import{F as B}from"./DzRq1F5-.chunk.js";import{F as T}from"./DV1GpLCe.chunk.js";import{U as b}from"./9ls1F1Ve.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"./DRKUY7jf.chunk.js";import"./Di9d6zcy.chunk.js";import"./CKctgafI.chunk.js";const q="_partialList_rmdrc_1",O="_partialField_rmdrc_1",V="_partialInput_rmdrc_5",Q="_partialLabel_rmdrc_17",g={partialList:q,partialField:O,partialInput:V,partialLabel:Q};function W(){return s.jsx("div",{className:`d-flex flex-wrap ${g.partialList}`,children:Array(6).fill(null).map((a,r)=>s.jsxs("div",{className:g.partialField,children:[s.jsx("div",{className:`${g.partialLabel} partial-loading-background`}),s.jsx("div",{className:`${g.partialInput} rounded partial-loading-background`})]},r))})}const J="_list_1syjz_1",K="_field_1syjz_4",X="_input_1syjz_7",Z="_buttons_1syjz_23",h={list:J,field:K,input:X,buttons:Z},N="settings.ssoYearGroupMappingForm",S=F.encloseNamespace(N),M=a=>{var r;return((r=a.yearGroup)==null?void 0:r.id)||"staff"},ss=95,as=a=>A($.MDDown)?"100%":`${ss*Math.ceil(a/2)}px`;function es(){const[a,r]=G.useState(!1),n=L();function x(e,i){const o=i.target.value;n.setFieldValue("mappings",n.values.mappings.map(t=>M(t)!==M(e)?t:{...e,ssoMapping:o}))}function d(){if(a)return;const e=n.values.mappings,i=e.map((o,t)=>{var p;return t===0?{...o,ssoMapping:""}:t===e.length-1?o:{...o,ssoMapping:((p=e[t-1])==null?void 0:p.ssoMapping)||""}});n.setFieldValue("mappings",i),r(!0)}const f=as(n.values.mappings.length);return s.jsxs(k,{children:[s.jsx("div",{className:`d-flex flex-wrap ${h.list}`,style:{maxHeight:f},children:n.values.mappings.map(e=>{const i=M(e),o=e.yearGroup.name;return s.jsxs("div",{className:`mb-2 ${h.field}`,children:[s.jsx("label",{htmlFor:i,children:o}),s.jsx(T,{id:i,name:i,className:`form-control ${h.input}`,placeholder:e.canBeSsoMapped?S("placeholder"):"",onChange:t=>x(e,t),value:e.ssoMapping,disabled:!e.canBeSsoMapped})]},i)})}),s.jsxs("div",{className:`${h.buttons} d-flex justify-content-end`,children:[s.jsx(U,{title:S("rolloverDisabled"),disable:!a,spanHack:!0,trigger:"hover",children:s.jsx("button",{type:"button",className:"btn btn-link info-link",onClick:d,disabled:a,children:s.jsx(l,{namespace:N,phrase:"rollover"})})}),s.jsx(B,{variant:"dark",isNew:!1,className:"ms-3"})]})]})}const ts=["Glow","RM Unify"],c="settings.ssoYearGroupMapping",u=F.encloseNamespace(c),rs=[u("breadcrumb")];function ys(){var t;const a=j(H.currentUser()),r=j(a.data&&b.getSsoMappings(a.data.customerId)),n=j(a.data&&b.getAuthenticationMethods(a.data.customerId)),x=R(),d=P(),f=((t=n.data)==null?void 0:t.some(p=>ts.includes(p.displayName)))??!1;w({title:u("title")});function e(p,v){const I=p.mappings.map(_=>({yearGroupId:_.yearGroup.id,ssoMapping:_.ssoMapping}));x(b.updateSsoMappings(a.data.customerId,I)).then(()=>d.success(u("updateSuccess"))).catch(()=>d.error(u("updateError"))).finally(v)}const i=!!a.data&&!!r.data&&!!n.data;function o(){return i?f?s.jsxs(m,{children:[s.jsx(m.Image,{src:E.UserManager.SSO_WARNING,size:"small"}),s.jsx(m.Heading,{children:s.jsx(l,{namespace:c,phrase:"unsupportedIdpHeading"})}),s.jsx(m.Info,{className:"w-50 mb-3",children:s.jsx(l,{namespace:c,phrase:"unsupportedIdpInfo"})}),s.jsx(C,{className:"btn btn-dark",href:y.getSupportRequestUrl(),newTab:!0,children:s.jsx(l,{namespace:c,phrase:"contactSupport"})})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"mb-0",children:s.jsx(l,{namespace:c,phrase:"info"})}),s.jsx("a",{className:"info-link",href:y.getLiteArticle(z.ManageSsoYearGroups),target:"_blank",children:s.jsx(l,{namespace:c,phrase:"helpArticle"})}),s.jsx("hr",{}),s.jsx(D,{initialValues:{mappings:r.data},onSubmit:e,children:s.jsx(es,{})})]}):s.jsx(W,{})}return s.jsx(Y,{heading:u("heading"),breadcrumbs:rs,children:o()})}export{ys as SsoYearGroupMappingView};
//# sourceMappingURL=BFmMX3J_.chunk.js.map
