import{j as t,at as b,aA as m,h as a,i as r,aw as D,R as N,aq as g,Y as T,dj as k,g as P,b8 as L,o as E,G as w,e9 as W}from"./app-BgLa5dit.js";import{W as M}from"./DJ0pq8J_.chunk.js";import{C as G}from"./CCcwLDvu.chunk.js";import{E as y}from"./BUT90D7O.chunk.js";import{O as U}from"./u6fIQ8Ti.chunk.js";function V(e){return t.jsx(b,{svg:y,className:"w-fit text-decoration-none",appLink:e.appLink,children:t.jsx("span",{className:"ms-2",children:"Cancel and Exit"})})}const q=m.object().shape({mapTo:m.string().required("External ID is required")}),F=m.object().shape({idpId:m.string().required("SSO provider is required")});var O=(e=>(e.PROVIDER="provider",e.IDP_MAPPING="idp_mapping",e.REVIEW="review",e))(O||{});const l={provider:{id:"provider",label:"Select an IPD provider",nextStep:e=>e.orgId?"review":"idp_mapping",appLink:{application:r.CRM_STUDIO,action:a.CrmStudio.ORGANISATION_SSO_WIZARD_PROVIDER},previousStep:null,schema:F},idp_mapping:{id:"idp_mapping",label:"Add IDP mapping",nextStep:"review",appLink:{application:r.CRM_STUDIO,action:a.CrmStudio.ORGANISATION_SSO_WIZARD_MAPPING},previousStep:"provider",schema:q},review:{id:"review",label:"Review and confirm",nextStep:null,previousStep:e=>e.orgId?"provider":"idp_mapping",appLink:{application:r.CRM_STUDIO,action:a.CrmStudio.ORGANISATION_SSO_WIZARD_REVIEW},schema:null}},I={getSsoWizardSteps(e,n){const o=[],c=!!n.orgId;return Object.values(l).forEach(s=>{const i={id:s.id,text:s.label,disabled:c&&s.id===O.IDP_MAPPING,appLink:{...s.appLink,args:[e],params:n}};o.push(i)}),o},convertQueryParamsToData(e){return e},convertDataToQueryParams(e){return e}};function H(e){const n=D(),[o,c]=N.useState(!1),s=!n.isValid,i=l[e.currentStep],v=g.isFunction(i.previousStep)?i.previousStep(n.values):i.previousStep,p=!!i.previousStep,S=p?{...l[v].appLink,args:[e.id],params:I.convertDataToQueryParams(n.values)}:null,d=e.currentStep===O.PROVIDER,_={application:r.CRM_STUDIO,action:a.CrmStudio.ORGANISATION_SSO,args:[e.id]},x=!!i.nextStep,f=g.isFunction(i.nextStep)?i.nextStep(n.values):i.nextStep,R=x?{...l[f].appLink,args:[e.id],params:I.convertDataToQueryParams(n.values)}:null;function C(){P.trigger(R)}function j(){c(!0),e.onComplete(n.values)}return t.jsxs("div",{className:"d-flex justify-content-end border-top p-4",children:[(p||d)&&t.jsx(T,{className:"me-2 btn btn-dark-outline",appLink:d?_:S,children:`${d?"Cancel":"Back"}`}),t.jsx(k,{showSpinner:o,disabled:s,onClick:R?C:j,variant:"dark",className:s?"btn btn-dark":"",children:R?"Next":"Complete setup"})]})}const Z="_container_1q4ji_1",z="_subHeader_1q4ji_4",B="_main_1q4ji_7",Q="_leftNav_1q4ji_10",u={container:Z,subHeader:z,main:B,leftNav:Q},h="organisation-sso-wizard",A=[{application:r.CRM_STUDIO,action:a.CrmStudio.ORGANISATION_SSO_WIZARD},{application:r.CRM_STUDIO,action:a.CrmStudio.ORGANISATION_SSO_WIZARD_PROVIDER},{application:r.CRM_STUDIO,action:a.CrmStudio.ORGANISATION_SSO_WIZARD_MAPPING},{application:r.CRM_STUDIO,action:a.CrmStudio.ORGANISATION_SSO_WIZARD_REVIEW},{application:r.CRM_STUDIO,action:a.CrmStudio.CUSTOMER_SSO}];function ee(e){var S,d;const n=L(),o=()=>n.unlock(h),c=E(U.organisation(e.id)),s=(S=c.data)==null?void 0:S.name,i=l[e.currentStepId],v=I.getSsoWizardSteps(e.id,e.queryParams),p=I.convertQueryParamsToData(e.queryParams);return N.useEffect(()=>{const _=e.currentStepId!==O.REVIEW?A:[...A,{application:r.CRM_STUDIO,action:a.CrmStudio.ORGANISATION_SSO,args:[e.id]}];if(Object.values(p).some(x=>!!x)){n.lock({id:h,title:"Are you sure you want to leave?",text:"The changes you have made will not be saved.",appLinkWhitelist:_});return}o()},[p]),N.useEffect(()=>()=>{o()},[]),c.hasCompleted?t.jsxs(t.Fragment,{children:[t.jsx(G,{}),t.jsxs("div",{className:`row g-0 border-bottom ${u.container}`,children:[t.jsxs("div",{className:`border-end ${u.leftNav} px-3 pt-5 pb-3 d-flex flex-column justify-content-between`,children:[t.jsxs("div",{children:[t.jsx("p",{className:`${u.subHeader} mb-2`,children:"ORGNISATION SSO SETUP WIZARD"}),t.jsx(M,{steps:v,currentStep:e.currentStepId,theme:{itemsContainer:"mt-4",itemContent:"px-3 w-100",item:"mb-1",isSelectedOverride:"bg-light-blue fw-normal"}})]}),t.jsx(V,{appLink:{application:r.CRM_STUDIO,action:a.CrmStudio.ORGANISATION_SSO,args:[e.id]}})]}),t.jsx(w,{initialValues:p,validationSchema:i.schema,onSubmit:null,children:t.jsxs("div",{className:`${u.main} d-flex flex-column justify-content-between`,children:[t.jsxs("div",{className:"p-5",children:[t.jsxs("div",{className:"d-flex flex-row justify-content-between",children:[t.jsxs("p",{children:[s," - ",(d=c.data)==null?void 0:d.id]}),e.rightContent&&t.jsx("div",{children:e.rightContent})]}),e.isLoading?t.jsx(W,{}):e.children]}),t.jsx(H,{id:e.id,currentStep:e.currentStepId,onComplete:e.onSubmit})]})})]})]}):t.jsx(t.Fragment,{})}export{ee as O,O as a};
//# sourceMappingURL=FnDeqFLV.chunk.js.map
