unleash-server 7.2.1 → 7.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/frontend/build/index.html +1 -1
  2. package/frontend/build/static/{AdvancedPlayground-CUkOz1YF.js → AdvancedPlayground-D2Y0O_LK.js} +1 -1
  3. package/frontend/build/static/{BackendConnections-Bi1Fsohi.js → BackendConnections-C9HcQ9To.js} +1 -1
  4. package/frontend/build/static/{ChartItem-Ci-KFL7s.js → ChartItem-COMyVdgD.js} +1 -1
  5. package/frontend/build/static/{CreateProject-COHPsP3X.js → CreateProject-jRfRrbUO.js} +1 -1
  6. package/frontend/build/static/{FeatureMetricsChart-ClbKeGOa.js → FeatureMetricsChart-CQkGp91T.js} +1 -1
  7. package/frontend/build/static/{FeatureStaleDialog-DZvKjxPB.js → FeatureStaleDialog-DKeGFuL1.js} +1 -1
  8. package/frontend/build/static/{FeatureViewLazyExport-yCIrczZt.js → FeatureViewLazyExport-CgntSCvS.js} +2 -2
  9. package/frontend/build/static/{FlagMetricsChart-D0GI-ltv.js → FlagMetricsChart-oDTQTkxU.js} +1 -1
  10. package/frontend/build/static/{FrontendNetworkTrafficUsage-DlRkx8CV.js → FrontendNetworkTrafficUsage-E4pIeMFQ.js} +1 -1
  11. package/frontend/build/static/{ImpactMetricsPage-BYcbHNWC.js → ImpactMetricsPage-B3STis_H.js} +1 -1
  12. package/frontend/build/static/{LazyAdminExport-BjSYZTvt.js → LazyAdminExport-CsCsRIwk.js} +2 -2
  13. package/frontend/build/static/{LazyProjectExport-9mNkV9Jq.js → LazyProjectExport-DkN0UegC.js} +2 -2
  14. package/frontend/build/static/{LifecycleChartComponent-BigwXcU3.js → LifecycleChartComponent-Dz1wdYkW.js} +1 -1
  15. package/frontend/build/static/{LineChartComponent-CPcDsiNa.js → LineChartComponent-DG1LdcL_.js} +1 -1
  16. package/frontend/build/static/{MarkCompletedDialogue-CS-kM4vW.js → MarkCompletedDialogue-Bw9Iccid.js} +1 -1
  17. package/frontend/build/static/{NetworkConnectedEdges-C2nfTRKM.js → NetworkConnectedEdges-HU923-QZ.js} +1 -1
  18. package/frontend/build/static/{NetworkOverview-BKozpi8w.js → NetworkOverview-_igGCPCJ.js} +1 -1
  19. package/frontend/build/static/{NetworkPrometheusAPIWarning-wqCXwcem.js → NetworkPrometheusAPIWarning-BS9PGbzI.js} +1 -1
  20. package/frontend/build/static/{NetworkTraffic-Co7oakIE.js → NetworkTraffic-BpNEMFBl.js} +1 -1
  21. package/frontend/build/static/{NetworkTrafficUsage-DNDJZGXi.js → NetworkTrafficUsage-bSUVPjoc.js} +1 -1
  22. package/frontend/build/static/{ReactJSONEditor-BDMT4-_1.js → ReactJSONEditor-DZ9l5V9S.js} +1 -1
  23. package/frontend/build/static/{RoleCell-COtuTPWk.js → RoleCell-C-hJFmul.js} +1 -1
  24. package/frontend/build/static/{aggregateFeatureMetrics-ClblY5Ev.js → aggregateFeatureMetrics-Dli6i5No.js} +1 -1
  25. package/frontend/build/static/{formatTickValue-DojfJagm.js → formatTickValue-D3KZyzeb.js} +1 -1
  26. package/frontend/build/static/{index-CqYZiU1N.js → index-A5We7bvX.js} +9 -9
  27. package/frontend/build/static/{networkTrafficUsageHighlightPlugin-BMMmh5e_.js → networkTrafficUsageHighlightPlugin-DLE_BBMN.js} +1 -1
  28. package/frontend/build/static/{useApiTokens-B6vbGXUF.js → useApiTokens-DNIDLJlc.js} +1 -1
  29. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{dF as Wn,j as e,dG as ve,dH as Ys,dI as Js,dJ as Ae,aC as te,aD as se,ax as ce,dK as zn,dL as qn,dM as va,dN as Ca,dO as Ot,dP as wa,x as Hn,dQ as Ta,s as h,bR as ka,e as K,bc as q,bt as Ce,r as u,cS as $t,bK as ke,dR as Vn,dS as ks,h as V,dT as Ie,A as Yn,l as X,C as w,dU as Jn,ba as _t,b9 as ne,dV as Ea,dW as Kn,bb as ue,dX as Me,ds as f,dY as re,dZ as ge,F as Nt,u as xe,d_ as Xe,V as J,I as Ra,S as Da,M as Fe,i as z,aY as Q,T as R,d$ as Zn,ci as Ee,L as ae,B as F,cc as Pt,dk as Es,e0 as et,e1 as Aa,cV as tt,cW as _,e2 as Qn,E as Mt,e3 as st,e4 as Xn,e5 as jt,e6 as eo,e7 as to,e8 as Ia,e9 as Pa,d as Rs,ea as Ba,eb as Ds,ec as La,N as xt,ed as Ua,ac as G,ad as fe,ak as oe,ae as Oa,af as $a,ag as As,ah as gt,ai as _a,ay as de,ee as je,D as Oe,ef as Na,bd as Ma,eg as ee,bs as so,eh as Fa,ei as no,ej as oo,ek as le,bv as ao,dv as Ks,el as io,em as ro,G as Ft,H as Gt,J as lo,y as we,a_ as co,a$ as uo,b0 as ls,b1 as ft,b2 as It,b3 as Pe,bm as Ga,bn as Wa,b4 as Wt,en as za,eo as Is,b8 as Zs,ep as Bt,eq as qa,er as Ha,es as Va,et as Ya,eu as Ja,ev as cs,m as zt,n as Ka,o as Za,ew as We,an as Se,ap as ye,bC as ho,cX as qt,ex as po,at as mo,al as me,dr as Be,ey as Ps,bh as Ht,ez as Qa,az as _e,w as ze,dE as Xa,t as ei,eA as ti,eB as si,c2 as Ze,eC as ni,eD as oi,aQ as Vt,eE as Bs,aE as Ls,ar as ai,b as yt,eF as $e,eG as ii,aw as nt,cC as Le,eH as ri,eI as li,eJ as ci,eK as di,d6 as Qs,eL as xo,v as ui,as as Us,eM as hi,du as ot,dh as go,di as jo,av as fo,eN as Xs,eO as Ue,eP as Qe,eQ as en,bZ as pi,cG as yo,eR as bo,bp as So,cH as vo,eS as mi,eT as Co,eU as xi,eV as wo,eW as gi,eX as ji,cZ as fi,eY as yi,eZ as bi,e_ as Si,e$ as To,aj as ko,f0 as vi,ao as bt,f1 as tn,f2 as Ci,f3 as Eo,f4 as Lt,f5 as Ro,f6 as wi,c0 as Os,f7 as Ti,f8 as sn,f9 as Yt,fa as ds,fb as ki,fc as Ei,fd as Ri,aT as Do,b5 as Di,fe as Ai,ff as Jt,fg as Ao,fh as Ii,fi as Pi,fj as Bi,fk as Li,au as Kt,fl as Ui,fm as Oi,fn as $i,dC as _i,dD as Ni,fo as Mi,cK as Fi,fp as Io,K as Po,fq as Bo,aq as Gi,dx as Wi,aA as zi,dz as nn,fr as Lo,fs as Uo,ft as qi,fu as Hi,fv as Vi,fw as Oo,fx as Yi,fy as Ji,fz as Ki,fA as Zi}from"./index-CqYZiU1N.js";import{u as Qi,C as Xi,A as er,a as tr,R as sr,S as nr,T as or,b as ar,c as ir,d as rr,e as lr,E as cr,f as dr,m as ur,g as St,h as Zt,i as $s}from"./RoleCell-COtuTPWk.js";import{u as Qt}from"./useApiTokens-B6vbGXUF.js";const hr=()=>{const{tokens:t,loading:s,refetch:n}=Qt(),{deleteToken:o}=Wn(),{headerGroups:a,rows:i,prepareRow:r,state:{globalFilter:c},setGlobalFilter:l,setHiddenColumns:m,columns:p}=Qi(t,d=>{const g=d.row.original.type==="client"?Ys:d.row.original.type==="frontend"?Js:Ae,x=d.row.original.type==="client"?va:d.row.original.type==="frontend"?Ca:Ae;return e.jsxs(Ot,{children:[e.jsx(tr,{token:d.row.original,permission:g}),e.jsx(sr,{token:d.row.original,permission:x,onRemove:async()=>{await o(d.row.original.secret),n()}})]})});return e.jsx(ve,{permissions:[Ys,Js,Ae],children:e.jsx(te,{header:e.jsx(se,{title:`API access (${i.length})`,actions:e.jsxs(e.Fragment,{children:[e.jsx(ce,{initialValue:c,onChange:l}),e.jsx(se.Divider,{}),e.jsx(Xi,{permission:[zn,qn,Ae],path:"/admin/api/create-token"})]})}),children:e.jsx(er,{loading:s,headerGroups:a,setHiddenColumns:m,prepareRow:r,rows:i,columns:p,globalFilter:c})})})},pr=({type:t,projects:s,setProjects:n,errors:o,clearErrors:a})=>{const i=wa("projectId"),{projects:r}=Hn(),c=r.map(l=>({value:l.id,label:l.name}));return i?null:e.jsxs(e.Fragment,{children:[e.jsx(nr,{children:"Which project do you want to give access to?"}),e.jsx(Ta,{disabled:t===or.ADMIN,options:c,defaultValue:s,onChange:n,error:o==null?void 0:o.projects,onFocus:()=>a("projects")})]})},on="Create API token",mr=h(ka)(({theme:t})=>({margin:t.spacing(2,0,4)})),xr=()=>{const{tokens:t,loading:s}=Qt(),{uiConfig:n,loading:o}=q(),a=n.resourceLimits.apiTokens;return{limit:a,currentValue:t.length,limitReached:t.length>=a,loading:o||s}},gr=({modal:t=!1})=>{const{setToastApiError:s}=K(),{uiConfig:n}=q(),o=Ce(),[a,i]=u.useState(!1),[r,c]=u.useState(""),{limit:l,currentValue:m,limitReached:p,loading:d}=xr(),{getApiTokenPayload:g,tokenName:x,type:j,projects:b,environment:y,setTokenName:S,setTokenType:k,setProjects:E,setEnvironment:D,isValid:v,errors:P,clearErrors:L,apiTokenTypes:C}=ar(),{createToken:W,loading:I}=Wn(),{refetch:U}=Qt();$t(on);const T="api/admin/api-tokens",A=async O=>{if(O.preventDefault(),!!v())try{const M=g();await W(M).then(N=>N.json()).then(N=>{ks(),c(N.secret),i(!0),U()})}catch(M){s(V(M))}},B=()=>{i(!1),o(Ie)},$=()=>`curl --location --request POST '${n.unleashUrl}/${T}' \\
1
+ import{dF as Wn,j as e,dG as ve,dH as Ys,dI as Js,dJ as Ae,aC as te,aD as se,ax as ce,dK as zn,dL as qn,dM as va,dN as Ca,dO as Ot,dP as wa,x as Hn,dQ as Ta,s as h,bR as ka,e as K,bc as q,bt as Ce,r as u,cS as $t,bK as ke,dR as Vn,dS as ks,h as V,dT as Ie,A as Yn,l as X,C as w,dU as Jn,ba as _t,b9 as ne,dV as Ea,dW as Kn,bb as ue,dX as Me,ds as f,dY as re,dZ as ge,F as Nt,u as xe,d_ as Xe,V as J,I as Ra,S as Da,M as Fe,i as z,aY as Q,T as R,d$ as Zn,ci as Ee,L as ae,B as F,cc as Pt,dk as Es,e0 as et,e1 as Aa,cV as tt,cW as _,e2 as Qn,E as Mt,e3 as st,e4 as Xn,e5 as jt,e6 as eo,e7 as to,e8 as Ia,e9 as Pa,d as Rs,ea as Ba,eb as Ds,ec as La,N as xt,ed as Ua,ac as G,ad as fe,ak as oe,ae as Oa,af as $a,ag as As,ah as gt,ai as _a,ay as de,ee as je,D as Oe,ef as Na,bd as Ma,eg as ee,bs as so,eh as Fa,ei as no,ej as oo,ek as le,bv as ao,dv as Ks,el as io,em as ro,G as Ft,H as Gt,J as lo,y as we,a_ as co,a$ as uo,b0 as ls,b1 as ft,b2 as It,b3 as Pe,bm as Ga,bn as Wa,b4 as Wt,en as za,eo as Is,b8 as Zs,ep as Bt,eq as qa,er as Ha,es as Va,et as Ya,eu as Ja,ev as cs,m as zt,n as Ka,o as Za,ew as We,an as Se,ap as ye,bC as ho,cX as qt,ex as po,at as mo,al as me,dr as Be,ey as Ps,bh as Ht,ez as Qa,az as _e,w as ze,dE as Xa,t as ei,eA as ti,eB as si,c2 as Ze,eC as ni,eD as oi,aQ as Vt,eE as Bs,aE as Ls,ar as ai,b as yt,eF as $e,eG as ii,aw as nt,cC as Le,eH as ri,eI as li,eJ as ci,eK as di,d6 as Qs,eL as xo,v as ui,as as Us,eM as hi,du as ot,dh as go,di as jo,av as fo,eN as Xs,eO as Ue,eP as Qe,eQ as en,bZ as pi,cG as yo,eR as bo,bp as So,cH as vo,eS as mi,eT as Co,eU as xi,eV as wo,eW as gi,eX as ji,cZ as fi,eY as yi,eZ as bi,e_ as Si,e$ as To,aj as ko,f0 as vi,ao as bt,f1 as tn,f2 as Ci,f3 as Eo,f4 as Lt,f5 as Ro,f6 as wi,c0 as Os,f7 as Ti,f8 as sn,f9 as Yt,fa as ds,fb as ki,fc as Ei,fd as Ri,aT as Do,b5 as Di,fe as Ai,ff as Jt,fg as Ao,fh as Ii,fi as Pi,fj as Bi,fk as Li,au as Kt,fl as Ui,fm as Oi,fn as $i,dC as _i,dD as Ni,fo as Mi,cK as Fi,fp as Io,K as Po,fq as Bo,aq as Gi,dx as Wi,aA as zi,dz as nn,fr as Lo,fs as Uo,ft as qi,fu as Hi,fv as Vi,fw as Oo,fx as Yi,fy as Ji,fz as Ki,fA as Zi}from"./index-A5We7bvX.js";import{u as Qi,C as Xi,A as er,a as tr,R as sr,S as nr,T as or,b as ar,c as ir,d as rr,e as lr,E as cr,f as dr,m as ur,g as St,h as Zt,i as $s}from"./RoleCell-C-hJFmul.js";import{u as Qt}from"./useApiTokens-DNIDLJlc.js";const hr=()=>{const{tokens:t,loading:s,refetch:n}=Qt(),{deleteToken:o}=Wn(),{headerGroups:a,rows:i,prepareRow:r,state:{globalFilter:c},setGlobalFilter:l,setHiddenColumns:m,columns:p}=Qi(t,d=>{const g=d.row.original.type==="client"?Ys:d.row.original.type==="frontend"?Js:Ae,x=d.row.original.type==="client"?va:d.row.original.type==="frontend"?Ca:Ae;return e.jsxs(Ot,{children:[e.jsx(tr,{token:d.row.original,permission:g}),e.jsx(sr,{token:d.row.original,permission:x,onRemove:async()=>{await o(d.row.original.secret),n()}})]})});return e.jsx(ve,{permissions:[Ys,Js,Ae],children:e.jsx(te,{header:e.jsx(se,{title:`API access (${i.length})`,actions:e.jsxs(e.Fragment,{children:[e.jsx(ce,{initialValue:c,onChange:l}),e.jsx(se.Divider,{}),e.jsx(Xi,{permission:[zn,qn,Ae],path:"/admin/api/create-token"})]})}),children:e.jsx(er,{loading:s,headerGroups:a,setHiddenColumns:m,prepareRow:r,rows:i,columns:p,globalFilter:c})})})},pr=({type:t,projects:s,setProjects:n,errors:o,clearErrors:a})=>{const i=wa("projectId"),{projects:r}=Hn(),c=r.map(l=>({value:l.id,label:l.name}));return i?null:e.jsxs(e.Fragment,{children:[e.jsx(nr,{children:"Which project do you want to give access to?"}),e.jsx(Ta,{disabled:t===or.ADMIN,options:c,defaultValue:s,onChange:n,error:o==null?void 0:o.projects,onFocus:()=>a("projects")})]})},on="Create API token",mr=h(ka)(({theme:t})=>({margin:t.spacing(2,0,4)})),xr=()=>{const{tokens:t,loading:s}=Qt(),{uiConfig:n,loading:o}=q(),a=n.resourceLimits.apiTokens;return{limit:a,currentValue:t.length,limitReached:t.length>=a,loading:o||s}},gr=({modal:t=!1})=>{const{setToastApiError:s}=K(),{uiConfig:n}=q(),o=Ce(),[a,i]=u.useState(!1),[r,c]=u.useState(""),{limit:l,currentValue:m,limitReached:p,loading:d}=xr(),{getApiTokenPayload:g,tokenName:x,type:j,projects:b,environment:y,setTokenName:S,setTokenType:k,setProjects:E,setEnvironment:D,isValid:v,errors:P,clearErrors:L,apiTokenTypes:C}=ar(),{createToken:W,loading:I}=Wn(),{refetch:U}=Qt();$t(on);const T="api/admin/api-tokens",A=async O=>{if(O.preventDefault(),!!v())try{const M=g();await W(M).then(N=>N.json()).then(N=>{ks(),c(N.secret),i(!0),U()})}catch(M){s(V(M))}},B=()=>{i(!1),o(Ie)},$=()=>`curl --location --request POST '${n.unleashUrl}/${T}' \\
2
2
  --header 'Authorization: INSERT_API_KEY' \\
3
3
  --header 'Content-Type: application/json' \\
4
4
  --data-raw '${JSON.stringify(g(),void 0,2)}'`,Y=()=>{o(Ie)};return e.jsxs(ke,{loading:I,title:on,modal:t,description:"Unleash SDKs use API tokens to authenticate with the Unleash API. An SDK must be configured with a token of the corresponding type, so they can fetch feature flags and post usage metrics.",documentationLink:"https://docs.getunleash.io/reference/api-tokens-and-client-keys",documentationLinkLabel:"API tokens documentation",formatApiCode:$,children:[e.jsxs(ir,{handleSubmit:A,handleCancel:Y,mode:"Create",actions:e.jsx(Vn,{name:"token",permission:[Ae,qn,zn],disabled:p||d||I}),children:[e.jsx(rr,{tokenName:x,setTokenName:S,errors:P,clearErrors:L}),e.jsx(lr,{type:j,setType:k,apiTokenTypes:C}),e.jsx(pr,{type:j,projects:b,setProjects:E,errors:P,clearErrors:L}),e.jsx(cr,{type:j,environment:y,setEnvironment:D}),e.jsx(mr,{name:"API tokens",shortName:"tokens",currentValue:m,limit:l})]}),e.jsx(dr,{open:a,setOpen:i,closeConfirm:B,token:r,type:j})]})},jr=h("div")(({theme:t})=>({display:"flex",flexDirection:"column","& > span:last-of-type":{fontSize:t.fontSizes.smallerBody,color:t.palette.text.secondary}})),Xt=({roles:t,value:s,setValue:n,required:o,hideDescription:a,...i})=>{const r=(c,l)=>e.jsx("li",{...c,children:e.jsxs(jr,{children:[e.jsx("span",{children:l.name}),e.jsx("span",{children:l.description})]})});return e.jsxs(e.Fragment,{children:[e.jsx(Yn,{openOnFocus:!0,size:"small",value:s,onChange:(c,l)=>n(l||null),options:t,renderOption:r,getOptionLabel:c=>c.name,renderInput:c=>e.jsx(X,{...c,label:"Role",required:o}),...i}),e.jsx(w,{condition:!!s&&!a,show:()=>e.jsx(Jn,{sx:{marginTop:1},roleId:s.id})})]})},vt=()=>{const{isEnterprise:t}=q(),{data:s,error:n,mutate:o}=_t(t(),{roles:[],projectRoles:[]},ne("api/admin/roles"),fr);return u.useMemo(()=>({roles:(s==null?void 0:s.roles.filter(({type:a})=>Ea.includes(a)).sort(an))??[],projectRoles:(s==null?void 0:s.roles.filter(({type:a})=>Kn.includes(a)).sort(an))??[],loading:!n&&!s,refetch:()=>o(),error:n}),[s,n,o])},fr=t=>fetch(t).then(ue("Roles")).then(s=>s.json()),an=(t,s)=>Me.includes(t.type)&&!Me.includes(s.type)?-1:!Me.includes(t.type)&&Me.includes(s.type)?1:t.name.localeCompare(s.name),$o=({data:t={enabled:!1,autoCreate:!1},setValue:s,onUpdateRole:n,disabled:o=!1})=>{const{roles:a}=vt(),i=()=>{s("autoCreate",!t.autoCreate)},r=l=>{s(l.target.name,l.target.value)},c=({defaultRootRole:l,defaultRootRoleId:m})=>m?a.find(({id:p})=>p===m)||null:a.find(({name:p})=>p===l)||null;return e.jsxs(u.Fragment,{children:[e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Auto-create users"}),e.jsx("p",{children:"Enable automatic creation of new users when signing in."})]}),e.jsx(f,{item:!0,md:6,style:{padding:"20px"},children:e.jsx(re,{control:e.jsx(ge,{onChange:i,name:"enabled",checked:t.autoCreate,disabled:!t.enabled||o}),label:"Auto-create users"})})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Default Root Role"}),e.jsx("p",{children:"Choose which root role the user should get when no explicit role mapping exists."})]}),e.jsx(f,{item:!0,md:6,children:e.jsx(Nt,{style:{width:"400px"},children:e.jsx(Xt,{roles:a,value:c(t),setValue:n,disabled:!t.autoCreate||!t.enabled||o,required:!0,hideDescription:!0})})})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Email domains"}),e.jsx("p",{children:"Comma separated list of email domains that should be allowed to sign in."})]}),e.jsx(f,{item:!0,md:6,children:e.jsx(X,{onChange:r,label:"Email domains",name:"emailDomains",disabled:!t.autoCreate||!t.enabled||o,required:!!t.autoCreate,value:t.emailDomains||"",placeholder:"@company.com, @anotherCompany.com",style:{width:"400px"},rows:2,variant:"outlined",size:"small"})})]})]})},yr=async(t,s)=>{var n,o;if(t){if(s){const a=await s.json(),i=((o=(n=a.details)==null?void 0:n[0])==null?void 0:o.message)??a.message;throw t({message:i}),new Error(i)}throw new Error}},es=t=>{const{makeRequest:s,createRequest:n,errors:o,loading:a}=xe({propagateErrors:!0,handleBadRequest:yr});return{updateSettings:async r=>{const c=`api/admin/auth/${t}/settings`,l=n(c,{method:"POST",body:JSON.stringify(r)});await s(l.caller,l.id)},errors:o,loading:a}},_s=t=>{const n=Object.entries(t).filter(([,o])=>o!=="");return Object.fromEntries(n)},_o=({ssoType:t,data:s={enabled:!1,enableGroupSyncing:!1,groupJsonPath:"",addGroupsScope:!1},setValue:n,disabled:o=!1})=>{const a=()=>{n("enableGroupSyncing",!s.enableGroupSyncing)},i=c=>{n(c.target.name,c.target.value)},r=()=>{n("addGroupsScope",!s.addGroupsScope)};return e.jsxs(e.Fragment,{children:[e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Enable Group Syncing"}),e.jsxs("p",{children:["Enables automatically syncing of users from the"," ",t," provider when a user logs in."]})]}),e.jsx(f,{item:!0,md:6,style:{padding:"20px"},children:e.jsx(re,{control:e.jsx(ge,{onChange:a,value:s.enableGroupSyncing,name:"enableGroupSyncing",checked:s.enableGroupSyncing,disabled:!s.enabled||o}),label:s.enableGroupSyncing?"Enabled":"Disabled"})})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Group Field JSON Path"}),e.jsxs("p",{children:["Specifies the path in the ",t," token response from which to read the groups the user belongs to."]})]}),e.jsx(f,{item:!0,md:6,children:e.jsx(X,{onChange:i,label:"Group JSON Path",name:"groupJsonPath",value:s.groupJsonPath,disabled:!s.enableGroupSyncing||o,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),e.jsx(w,{condition:t==="OIDC",show:e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Request 'groups' Scope"}),e.jsx("p",{children:"When enabled Unleash will also request the 'groups' scope as part of the login request."})]}),e.jsx(f,{item:!0,md:6,style:{padding:"20px"},children:e.jsx(re,{control:e.jsx(ge,{onChange:r,value:s.addGroupsScope,disabled:!s.enableGroupSyncing||o,name:"addGroupsScope",checked:s.addGroupsScope}),label:s.addGroupsScope?"Enabled":"Disabled"})})]})})]})},br={enabled:!1,enableSingleSignOut:!1,addGroupsScope:!1,enableGroupSyncing:!1,autoCreate:!1,unleashHostname:location.hostname,groupJsonPath:"",clientId:"",discoverUrl:"",secret:"",acrValues:"",idTokenSigningAlgorithm:"RS256"},Sr=()=>{const{setToastData:t,setToastApiError:s}=K(),{uiConfig:n}=q(),{oidcConfiguredThroughEnv:o}=n,[a,i]=u.useState(br),{config:r}=Xe("oidc"),{updateSettings:c,errors:l,loading:m}=es("oidc");u.useEffect(()=>{r.discoverUrl&&i(r)},[r]);const p=S=>{j(S.target.name,S.target.value)},d=S=>{j(S.target.name,S.target.value.trim())},g=()=>{i({...a,enabled:!a.enabled})},x=()=>{i({...a,enableSingleSignOut:!a.enableSingleSignOut})},j=(S,k)=>{i({...a,[S]:k})},b=S=>{i({...a,defaultRootRole:void 0,defaultRootRoleId:S==null?void 0:S.id})},y=async S=>{S.preventDefault();try{await c(_s(a)),t({text:"Settings stored",type:"success"})}catch(k){s(V(k))}};return e.jsxs(e.Fragment,{children:[e.jsx(f,{container:!0,sx:{mb:3},children:e.jsxs(f,{item:!0,md:12,children:[e.jsx(w,{condition:!!o,show:e.jsxs(J,{sx:{mb:2},severity:"warning",children:["OIDC is currently configured via environment variables. Please refer to the"," ",e.jsx("a",{href:"https://www.unleash-hosted.com/docs/enterprise-authentication",target:"_blank",rel:"noreferrer",children:"documentation"})," ","for detailed instructions on how to set up OIDC using these variables."]})}),e.jsxs(J,{severity:"info",children:["Please read the"," ",e.jsx("a",{href:"https://www.unleash-hosted.com/docs/enterprise-authentication",target:"_blank",rel:"noreferrer",children:"documentation"})," ","to learn how to integrate with specific OpenID Connect providers (such as Okta and Keycloak). ",e.jsx("br",{}),"Callback URL:"," ",e.jsxs("code",{children:[n.unleashUrl,"/auth/oidc/callback"]})]})]})}),e.jsxs("form",{onSubmit:y,children:[e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Enable"}),e.jsx("p",{children:"Enable Open Id Connect Authentication."})]}),e.jsx(f,{item:!0,md:6,style:{padding:"20px"},children:e.jsx(re,{control:e.jsx(ge,{onChange:g,value:a.enabled,name:"enabled",checked:a.enabled}),label:a.enabled?"Enabled":"Disabled",disabled:o})})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Discover URL"}),e.jsx("p",{children:"(Required) Issuer discover metadata URL"})]}),e.jsx(f,{item:!0,md:6,children:e.jsx(X,{onChange:d,label:"Discover URL",name:"discoverUrl",value:a.discoverUrl,disabled:!a.enabled||o,style:{width:"400px"},variant:"outlined",size:"small"})})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Client ID"}),e.jsx("p",{children:"(Required) Client ID of your OpenID application"})]}),e.jsx(f,{item:!0,md:6,children:e.jsx(X,{onChange:d,label:"Client ID",name:"clientId",value:a.clientId,disabled:!a.enabled||o,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),e.jsxs(f,{container:!0,spacing:3,mb:4,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Client secret"}),e.jsxs("p",{children:["(Required) Client secret of your OpenID application."," "]})]}),e.jsx(f,{item:!0,md:6,children:e.jsx(X,{onChange:d,label:"Client Secret",name:"secret",value:a.secret,disabled:!a.enabled||o,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),e.jsx("h3",{children:"Optional Configuration"}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Enable Single Sign-Out"}),e.jsx("p",{children:"If you enable Single Sign-Out Unleash will redirect the user to the IDP as part of the Sign-out process."})]}),e.jsx(f,{item:!0,md:6,style:{padding:"20px"},children:e.jsx(re,{control:e.jsx(ge,{onChange:x,value:a.enableSingleSignOut,disabled:!a.enabled||o,name:"enableSingleSignOut",checked:a.enableSingleSignOut}),label:a.enableSingleSignOut?"Enabled":"Disabled"})})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"ACR Values"}),e.jsx("p",{children:'Requested Authentication Context Class Reference values. If multiple values are specified they should be "space" separated. Will be sent as "acr_values" as part of the authentication request. Unleash will validate the acr value in the id token claims against the list of acr values.'})]}),e.jsx(f,{item:!0,md:6,children:e.jsx(X,{onChange:p,label:"ACR Values",name:"acrValues",value:a.acrValues,disabled:!a.enabled||o,style:{width:"400px"},variant:"outlined",size:"small"})})]}),e.jsx(_o,{ssoType:"OIDC",data:a,setValue:j,disabled:o}),e.jsx($o,{data:a,setValue:j,onUpdateRole:b,disabled:o}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"ID Signing algorithm"}),e.jsxs("p",{children:["Which signing algorithm to use. ",e.jsx("br",{}),' Leave this alone unless you see errors that look like "unexpected JWT alg received, expected RS256, got: RS512" in your logs.']})]}),e.jsx(f,{item:!0,md:6,children:e.jsxs(Nt,{style:{minWidth:"200px"},children:[e.jsx(Ra,{id:"defaultRootRole-label",children:"Signing algorithm"}),e.jsxs(Da,{label:"Signing algorithm",labelId:"idTokenSigningAlgorithm-label",id:"idTokenSigningAlgorithm",name:"idTokenSigningAlgorithm",value:a.idTokenSigningAlgorithm||"RS256",onChange:S=>j("idTokenSigningAlgorithm",S.target.value),disabled:o,children:[e.jsx(Fe,{value:"RS256",children:"RS256"}),e.jsx(Fe,{value:"RS384",children:"RS384"}),e.jsx(Fe,{value:"RS512",children:"RS512"})]})]})})]}),e.jsx(f,{container:!0,spacing:3,children:e.jsxs(f,{item:!0,md:12,children:[e.jsx(z,{variant:"contained",color:"primary",type:"submit",disabled:m||o,children:"Save"})," ",e.jsx("p",{children:e.jsx("small",{style:{color:"red"},children:l==null?void 0:l.message})})]})})]})]})},vr={enabled:!1,autoCreate:!1,enableGroupSyncing:!1,addGroupsScope:!1,unleashHostname:location.hostname,entityId:"",signOnUrl:"",certificate:"",signOutUrl:"",spCertificate:"",groupJsonPath:""},Cr=()=>{const{setToastData:t,setToastApiError:s}=K(),{uiConfig:n}=q(),{samlConfiguredThroughEnv:o}=n,[a,i]=u.useState(vr),{config:r}=Xe("saml"),{updateSettings:c,errors:l,loading:m}=es("saml");u.useEffect(()=>{r.entityId&&i(r)},[r]);const p=y=>{x(y.target.name,y.target.value)},d=y=>{x(y.target.name,y.target.value.trim())},g=()=>{i({...a,enabled:!a.enabled})},x=(y,S)=>{i({...a,[y]:S})},j=y=>{i({...a,defaultRootRole:void 0,defaultRootRoleId:y==null?void 0:y.id})},b=async y=>{y.preventDefault();try{await c(_s(a)),t({text:"Settings stored",type:"success"})}catch(S){s(V(S))}};return e.jsxs(e.Fragment,{children:[e.jsx(f,{container:!0,sx:{mb:3},children:e.jsxs(f,{item:!0,md:12,children:[e.jsx(w,{condition:!!o,show:e.jsxs(J,{sx:{mb:2},severity:"warning",children:["SAML is currently configured via environment variables. Please refer to the"," ",e.jsx("a",{href:"https://www.unleash-hosted.com/docs/enterprise-authentication",target:"_blank",rel:"noreferrer",children:"documentation"})," ","for detailed instructions on how to set up SAML using these variables."]})}),e.jsxs(J,{severity:"info",children:["Please read the"," ",e.jsx("a",{href:"https://www.unleash-hosted.com/docs/enterprise-authentication",target:"_blank",rel:"noreferrer",children:"documentation"})," ","to learn how to integrate with specific SAML 2.0 providers (such as Okta, Keycloak, and Microsoft Entra ID). ",e.jsx("br",{}),"Callback URL:"," ",e.jsxs("code",{children:[n.unleashUrl,"/auth/saml/callback"]})]})]})}),e.jsxs("form",{onSubmit:b,children:[e.jsxs(f,{container:!0,spacing:3,children:[e.jsxs(f,{item:!0,md:5,mb:2,children:[e.jsx("strong",{children:"Enable"}),e.jsx("p",{children:"Enable SAML 2.0 Authentication."})]}),e.jsx(f,{item:!0,md:6,children:e.jsx(re,{control:e.jsx(ge,{onChange:g,value:a.enabled,name:"enabled",checked:a.enabled,disabled:o}),label:a.enabled?"Enabled":"Disabled"})})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Entity ID"}),e.jsx("p",{children:"(Required) The Entity Identity provider issuer."})]}),e.jsx(f,{item:!0,md:6,children:e.jsx(X,{onChange:d,label:"Entity ID",name:"entityId",value:a.entityId,disabled:!a.enabled||o,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Single Sign-On URL"}),e.jsx("p",{children:"(Required) The url to redirect the user to for signing in."})]}),e.jsx(f,{item:!0,md:6,children:e.jsx(X,{onChange:d,label:"Single Sign-On URL",name:"signOnUrl",value:a.signOnUrl,disabled:!a.enabled||o,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),e.jsxs(f,{container:!0,spacing:3,mb:4,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"X.509 Certificate"}),e.jsx("p",{children:"(Required) The certificate used to sign the SAML 2.0 request."})]}),e.jsx(f,{item:!0,md:7,children:e.jsx(X,{onChange:p,label:"X.509 Certificate",name:"certificate",value:a.certificate,disabled:!a.enabled||o,style:{width:"100%"},InputProps:{style:{fontSize:"0.6em",fontFamily:"monospace"}},multiline:!0,rows:14,maxRows:14,variant:"outlined",size:"small",required:!0})})]}),e.jsx("h3",{children:"Optional Configuration"}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Single Sign-out URL"}),e.jsx("p",{children:"(Optional) The url to redirect the user to for signing out of the IDP."})]}),e.jsx(f,{item:!0,md:6,children:e.jsx(X,{onChange:d,label:"Single Sign-out URL",name:"signOutUrl",value:a.signOutUrl,disabled:!a.enabled||o,style:{width:"400px"},variant:"outlined",size:"small"})})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Service Provider X.509 Certificate"}),e.jsx("p",{children:"(Optional) The private certificate used by the Service Provider used to sign the SAML 2.0 request towards the IDP. E.g. used to sign single logout requests (SLO)."})]}),e.jsx(f,{item:!0,md:7,children:e.jsx(X,{onChange:p,label:"X.509 Certificate",name:"spCertificate",value:a.spCertificate,disabled:!a.enabled||o,style:{width:"100%"},InputProps:{style:{fontSize:"0.6em",fontFamily:"monospace"}},multiline:!0,rows:14,maxRows:14,variant:"outlined",size:"small"})})]}),e.jsx(_o,{ssoType:"SAML",data:a,setValue:x,disabled:o}),e.jsx($o,{data:a,setValue:x,onUpdateRole:j,disabled:o}),e.jsx(f,{container:!0,spacing:3,children:e.jsxs(f,{item:!0,md:5,children:[e.jsx(z,{variant:"contained",color:"primary",type:"submit",disabled:m||o,children:"Save"})," ",e.jsx("p",{children:e.jsx("small",{style:{color:"red"},children:l==null?void 0:l.message})})]})})]})]})},wr=h(J)(({theme:t})=>({marginBottom:t.spacing(3)})),Tr=({open:t,setOpen:s,onConfirm:n})=>e.jsx(Q,{open:t,secondaryButtonText:"Close",onClose:(o,a)=>{a||s(!1)},primaryButtonText:"Generate new token",onClick:n,title:"Generate new SCIM API token?",children:e.jsxs(wr,{severity:"error",children:["Generating a new token will ",e.jsx("strong",{children:"immediately revoke"})," the current one, which may break any existing provision integrations currently using it."]})}),kr=h(J)(({theme:t})=>({marginBottom:t.spacing(3)})),Er=({open:t,setOpen:s,token:n})=>e.jsxs(Q,{open:t,secondaryButtonText:"Close",onClose:(o,a)=>{a||s(!1)},title:"SCIM API token created",children:[e.jsx(kr,{severity:"info",children:"Make sure to copy your SCIM API token now. You won't be able to see it again!"}),e.jsx(R,{variant:"body1",children:"Your token:"}),e.jsx(Zn,{token:n||""})]}),rn="api/admin/scim-settings",Rr=()=>{const{loading:t,makeRequest:s,createRequest:n,errors:o}=xe({propagateErrors:!0});return{saveSettings:async r=>{const l=n(rn,{method:"POST",body:JSON.stringify(r)},"saveSettings");await s(l.caller,l.id)},generateNewToken:async()=>{const c=n(`${rn}/generate-new-token`,{method:"POST"},"generateNewToken"),l=await s(c.caller,c.id),{token:m}=await l.json();return m},errors:o,loading:t}},Dr="api/admin/scim-settings",ln={enabled:!1,hasToken:!1},Ct=()=>{const{isEnterprise:t}=q(),{data:s,error:n,mutate:o}=_t(t(),ln,ne(Dr),Ar);return u.useMemo(()=>({settings:s??ln,loading:!n&&!s,refetch:()=>o(),error:n}),[s,n,o])},Ar=t=>fetch(t).then(ue("SCIM settings")).then(s=>s.json());h(J)(({theme:t})=>({marginBottom:t.spacing(3)}));const cn=({open:t,closeDialog:s,deleteEntities:n,entityType:o})=>e.jsx(Q,{open:t,primaryButtonText:`Delete SCIM ${o}`,secondaryButtonText:"Cancel",title:`Do you really want to delete ALL SCIM ${o}?`,onClose:s,onClick:n,children:e.jsxs(R,{variant:"body1",children:["This will delete all ",o.toLocaleLowerCase()," created or managed by SCIM."]})}),Ut="removeUser",qe=()=>{const{loading:t,makeRequest:s,createRequest:n,errors:o}=xe({propagateErrors:!0});return{addUser:async d=>{const x=n("api/admin/user-admin",{method:"POST",body:JSON.stringify(d)},"addUser");return s(x.caller,x.id)},updateUser:async d=>{const x=n(`api/admin/user-admin/${d.id}`,{method:"PUT",body:JSON.stringify(d)},"updateUser");return s(x.caller,x.id)},removeUser:async d=>{const x=n(`api/admin/user-admin/${d}`,{method:"DELETE"},"removeUser");return s(x.caller,x.id)},changePassword:async(d,g)=>{const j=n(`api/admin/user-admin/${d}/change-password`,{method:"POST",body:JSON.stringify({password:g})},"changePassword");return s(j.caller,j.id)},validatePassword:async d=>{const x=n("api/admin/user-admin/validate-password",{method:"POST",body:JSON.stringify({password:d})},"validatePassword");return s(x.caller,x.id)},resetPassword:async d=>{const x=n("api/admin/user-admin/reset-password",{method:"POST",body:JSON.stringify({id:d})},"resetPassword");return s(x.caller,x.id)},deleteScimUsers:async()=>{const g=n("api/admin/user-admin/scim-users",{method:"DELETE"},"deleteScimUsers");return s(g.caller,g.id)},userApiErrors:o,userLoading:t}},at=()=>{const{makeRequest:t,createRequest:s,errors:n,loading:o}=xe({propagateErrors:!0});return{createGroup:async l=>{const p=s("api/admin/groups",{method:"POST",body:JSON.stringify(l)});return(await t(p.caller,p.id)).json()},updateGroup:async(l,m)=>{const p=`api/admin/groups/${l}`,d=s(p,{method:"PUT",body:JSON.stringify(m)});await t(d.caller,d.id)},removeGroup:async l=>{const m=`api/admin/groups/${l}`,p=s(m,{method:"DELETE"});await t(p.caller,p.id)},deleteScimGroups:async()=>{const m=s("api/admin/groups/scim-groups",{method:"DELETE"});await t(m.caller,m.id)},errors:n,loading:o}},Ir=h("div")(({theme:t})=>({padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),us=h("div")(({theme:t})=>({marginBottom:t.spacing(1)})),Pr=()=>{const{uiConfig:t}=q(),{setToastData:s,setToastApiError:n}=K(),[o,a]=u.useState(""),[i,r]=u.useState(!1),[c,l]=u.useState(!1),[m,p]=u.useState(!1),[d,g]=u.useState(!1),{settings:x,refetch:j}=Ct(),{deleteScimUsers:b}=qe(),{deleteScimGroups:y}=at(),[S,k]=u.useState(x.enabled??!0);u.useEffect(()=>{k(x.enabled??!1)},[x]);const{saveSettings:E,generateNewToken:D,errors:v,loading:P}=Rr(),L=async()=>{r(!0)},C=async()=>{try{await y(),s({text:"Scim Groups have been deleted",type:"success"}),l(!1),j()}catch(T){n(V(T))}},W=async()=>{try{await b(),s({text:"Scim Users have been deleted",type:"success"}),p(!1),j()}catch(T){n(V(T))}},I=async()=>{r(!1);const T=await D();a(T),g(!0)},U=async T=>{try{if(k(T),await E({enabled:T}),T&&!x.hasToken){const A=await D();a(A),g(!0)}s({text:"Settings stored",type:"success"}),await j()}catch(A){n(V(A))}};return e.jsxs(e.Fragment,{children:[e.jsx(f,{container:!0,sx:{mb:3},children:e.jsx(f,{item:!0,md:12,children:e.jsxs(J,{severity:"info",children:["Please read the"," ",e.jsx("a",{href:"https://docs.getunleash.io/reference/scim",target:"_blank",rel:"noreferrer",children:"documentation"})," ","to learn how to integrate with specific SCIM clients (Microsoft Entra, Okta, etc). ",e.jsx("br",{}),"SCIM API URL: ",e.jsxs("code",{children:[t.unleashUrl,"/scim"]})]})})}),e.jsxs(Ir,{children:[e.jsxs(f,{container:!0,spacing:3,children:[e.jsxs(f,{item:!0,md:10.5,mb:2,children:[e.jsx(us,{children:e.jsx("strong",{children:"SCIM provisioning"})}),e.jsx("p",{children:"Enables SCIM provisioning. If SCIM provisioning has not previously been enabled here this will also set up a new auth token to use with your SCIM client, and display it to the user. After the dialog has been closed, this token will not be displayed again. If you need a new token you can click the Generate new token button below which will replace the old token with a new token, and similarly display the new token one time to the user."})]}),e.jsx(f,{item:!0,md:1.5,children:e.jsx(re,{control:e.jsx(ge,{onChange:(T,A)=>{U(A)},value:S,name:"enabled",checked:S}),label:S?"Enabled":"Disabled"})})]}),e.jsx(f,{container:!0,spacing:3,children:e.jsx(f,{item:!0,md:5,mb:2,children:e.jsx(w,{condition:!!x.hasToken,show:e.jsx(z,{variant:"outlined",color:"error",disabled:P,onClick:L,children:"Generate new token"})})})}),e.jsxs(f,{container:!0,spacing:3,children:[e.jsxs(f,{item:!0,md:10.5,mb:2,children:[e.jsx(us,{children:e.jsx("strong",{children:"Delete SCIM Users"})}),e.jsx("p",{children:"This will remove all SCIM users from the Unleash database. This action cannot be undone through Unleash but the upstream SCIM provider may re sync these users."})]}),e.jsx(f,{item:!0,md:1.5,children:e.jsx(z,{variant:"outlined",color:"error",disabled:P,onClick:()=>{p(!0)},children:"Delete Users"})}),e.jsxs(f,{item:!0,md:10.5,mb:2,children:[e.jsx(us,{children:e.jsx("strong",{children:"Delete SCIM Groups"})}),e.jsx("p",{children:"This will remove all SCIM groups from the Unleash database. This action cannot be undone through Unleash but the upstream SCIM provider may re sync these groups. Note that this may affect the permissions of users present in those groups."})]}),e.jsx(f,{item:!0,md:1.5,children:e.jsx(z,{variant:"outlined",color:"error",disabled:P,onClick:()=>{l(!0)},children:"Delete Groups"})})]}),e.jsx(Tr,{open:i,setOpen:r,onConfirm:I}),e.jsx(Er,{open:d,setOpen:g,token:o}),e.jsx(cn,{open:m,closeDialog:()=>p(!1),deleteEntities:W,entityType:"Users"}),e.jsx(cn,{open:c,closeDialog:()=>l(!1),deleteEntities:C,entityType:"Groups"})]})]})},Br=()=>{const{data:t,error:s,mutate:n}=Ee(ne("api/admin/user-admin/admin-count"),Lr);return{data:t,loading:!s&&!t,refetch:()=>n(),error:s}},Lr=t=>fetch(t).then(ue("Admin count")).then(s=>s.json()),Ur=({open:t,setOpen:s,onClick:n,adminCount:o,tokens:a})=>e.jsxs(Q,{open:t,onClose:()=>{s(!1)},onClick:n,title:"Disable password based login?",primaryButtonText:"Disable password based login",secondaryButtonText:"Cancel",children:[e.jsxs(J,{severity:"warning",children:[e.jsx("strong",{children:"Warning!"})," Disabling password based login may lock you out of the system permanently if you do not have any alternative admin credentials (such as an admin SSO account or admin API token) secured beforehand.",e.jsx("br",{}),e.jsx("br",{}),e.jsx("strong",{children:"Password based administrators: "})," ",o==null?void 0:o.password,e.jsx("br",{}),e.jsx("strong",{children:"Other administrators: "})," ",o==null?void 0:o.noPassword,e.jsx("br",{}),e.jsx("strong",{children:"Admin service accounts: "})," ",o==null?void 0:o.service,e.jsx("br",{}),e.jsx("strong",{children:"Admin API tokens: "})," ",a.filter(({type:i})=>i==="admin").length]}),e.jsx(R,{sx:{mt:3},children:"You are about to disable password based login. Are you sure you want to proceed?"})]}),Or=()=>{const{setToastData:t,setToastApiError:s}=K(),{config:n,refetch:o}=Xe("simple"),[a,i]=u.useState(!1),{updateSettings:r,errors:c,loading:l}=es("simple"),[m,p]=u.useState(!1),{data:d}=Br(),{tokens:g}=Qt();u.useEffect(()=>{i(!!n.disabled)},[n.disabled]);const x=()=>{i(!a)},j=async y=>{y.preventDefault(),!n.disabled&&a?p(!0):b()},b=async()=>{try{await r({disabled:a}),o(),t({text:"Password authentication settings stored",autoHideDuration:4e3,type:"success",show:!0})}catch(y){s(V(y)),i(n.disabled)}};return e.jsx(e.Fragment,{children:e.jsxs("form",{onSubmit:j,children:[e.jsxs(J,{severity:"info",sx:{mb:3},children:["Overview of administrators on your Unleash instance:",e.jsx("br",{}),e.jsx("br",{}),e.jsx("strong",{children:"Password based administrators: "})," ",e.jsx(ae,{to:"/admin/users",children:d==null?void 0:d.password}),e.jsx("br",{}),e.jsx("strong",{children:"Other administrators: "})," ",e.jsx(ae,{to:"/admin/users",children:d==null?void 0:d.noPassword}),e.jsx("br",{}),e.jsx("strong",{children:"Admin service accounts: "})," ",e.jsx(ae,{to:"/admin/service-accounts",children:d==null?void 0:d.service}),e.jsx("br",{}),e.jsx("strong",{children:"Admin API tokens: "})," ",e.jsx(ae,{to:"/admin/api",children:g.filter(({type:y})=>y==="admin").length})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Password based login"}),e.jsx("p",{children:"Allow users to login with username & password"})]}),e.jsx(f,{item:!0,md:6,style:{padding:"20px"},children:e.jsx(re,{control:e.jsx(ge,{onChange:x,value:!a,name:"disabled",checked:!a}),label:a?"Disabled":"Enabled"})})]}),e.jsx(f,{container:!0,spacing:3,children:e.jsxs(f,{item:!0,md:12,children:[e.jsx(z,{variant:"contained",color:"primary",type:"submit",disabled:l,children:"Save"})," ",e.jsx("p",{children:e.jsx("small",{style:{color:"red"},children:c==null?void 0:c.message})})]})}),e.jsx(Ur,{open:m,setOpen:p,onClick:()=>{p(!1),b()},adminCount:d,tokens:g})]})})},$r={enabled:!1,autoCreate:!1,unleashHostname:location.hostname,clientId:"",clientSecret:"",emailDomains:""},_r=()=>{const{setToastData:t,setToastApiError:s}=K(),{uiConfig:n}=q(),[o,a]=u.useState($r),{config:i}=Xe("google"),{updateSettings:r,errors:c,loading:l}=es("google");u.useEffect(()=>{i.clientId&&a(i)},[i]);const m=x=>{a({...o,[x.target.name]:x.target.value})},p=()=>{a({...o,enabled:!o.enabled})},d=()=>{a({...o,autoCreate:!o.autoCreate})},g=async x=>{x.preventDefault();try{await r(_s(o)),t({text:"Settings stored",type:"success"})}catch(j){s(V(j))}};return e.jsxs(e.Fragment,{children:[e.jsxs(F,{children:[e.jsxs(J,{severity:"error",sx:{mb:2},children:["This integration is deprecated and will be removed in next major version. Please use ",e.jsx("strong",{children:"OpenID Connect"})," to enable Google SSO."]}),e.jsxs(J,{severity:"info",sx:{mb:3},children:["Read the"," ",e.jsx("a",{href:"https://www.unleash-hosted.com/docs/enterprise-authentication/google",target:"_blank",rel:"noreferrer",children:"documentation"})," ","to learn how to integrate with Google OAuth 2.0. ",e.jsx("br",{}),"Callback URL:"," ",e.jsxs("code",{children:[n.unleashUrl,"/auth/google/callback"]})]})]}),e.jsxs("form",{onSubmit:g,children:[e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,xs:5,children:[e.jsx("strong",{children:"Enable"}),e.jsx("p",{children:"Enable Google users to login. Value is ignored if Client ID and Client Secret are not defined."})]}),e.jsx(f,{item:!0,xs:6,style:{padding:"20px"},children:e.jsx(re,{control:e.jsx(ge,{onChange:p,value:o.enabled,name:"enabled",checked:o.enabled}),label:o.enabled?"Enabled":"Disabled"})})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,xs:5,children:[e.jsx("strong",{children:"Client ID"}),e.jsx("p",{children:"(Required) The Client ID provided by Google when registering the application."})]}),e.jsx(f,{item:!0,xs:6,children:e.jsx(X,{onChange:m,label:"Client ID",name:"clientId",placeholder:"",value:o.clientId,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Client Secret"}),e.jsx("p",{children:"(Required) Client Secret provided by Google when registering the application."})]}),e.jsx(f,{item:!0,md:6,children:e.jsx(X,{onChange:m,label:"Client Secret",name:"clientSecret",value:o.clientSecret,placeholder:"",style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Unleash hostname"}),e.jsxs("p",{children:["(Required) The hostname you are running Unleash on that Google should send the user back to. The final callback URL will be"," ",e.jsx("small",{children:e.jsx("code",{children:"https://[unleash.hostname.com]/auth/google/callback"})})]})]}),e.jsx(f,{item:!0,md:6,children:e.jsx(X,{onChange:m,label:"Unleash Hostname",name:"unleashHostname",placeholder:"",value:o.unleashHostname||"",style:{width:"400px"},variant:"outlined",size:"small"})})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Auto-create users"}),e.jsx("p",{children:"Enable automatic creation of new users when signing in with Google."})]}),e.jsx(f,{item:!0,md:6,style:{padding:"20px"},children:e.jsx(ge,{onChange:d,name:"enabled",checked:o.autoCreate})})]}),e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Email domains"}),e.jsx("p",{children:"(Optional) Comma separated list of email domains that should be allowed to sign in."})]}),e.jsx(f,{item:!0,md:6,children:e.jsx(X,{onChange:m,label:"Email domains",name:"emailDomains",value:o.emailDomains,placeholder:"@company.com, @anotherCompany.com",style:{width:"400px"},rows:2,multiline:!0,variant:"outlined",size:"small"})})]}),e.jsx(f,{container:!0,spacing:3,children:e.jsxs(f,{item:!0,md:5,children:[e.jsx(z,{variant:"contained",color:"primary",type:"submit",disabled:l,children:"Save"})," ",e.jsx("p",{children:e.jsx("small",{style:{color:"error.dark"},children:c==null?void 0:c.message})})]})})]})]})},Nr=()=>{var i;const{isEnterprise:t}=q(),s=Pt("googleAuthEnabled"),n=[{label:"Single sign-on: OpenID Connect",path:"/admin/auth/oidc"},{label:"Single sign-on: SAML 2.0",path:"/admin/auth/saml"},{label:"Password login",path:"/admin/auth/password"},{label:"Single sign-on: Google",path:"/admin/auth/google"},{label:"Single sign-on: SCIM",path:"/admin/auth/scim"}],{pathname:o}=Es(),a=((i=n.find(r=>o===r.path))==null?void 0:i.label)||"Single sign-on: OpenID Connect";return $t(a),t()?e.jsx("div",{children:e.jsx(ve,{permissions:[Ae,Aa],children:e.jsx(te,{header:a,children:e.jsxs(tt,{children:[e.jsx(_,{path:"/",index:!0,element:e.jsx(Qn,{to:"/admin/auth/oidc"})}),e.jsx(_,{path:"/oidc",index:!0,element:e.jsx(Sr,{})}),e.jsx(_,{path:"/saml",element:e.jsx(Cr,{})}),e.jsx(_,{path:"/password",element:e.jsx(Or,{})}),s&&e.jsx(_,{path:"/google",element:e.jsx(_r,{})}),e.jsx(_,{path:"/scim",element:e.jsx(Pr,{})})]})})})}):e.jsx(et,{feature:"sso",page:!0})},Mr=ne("api/admin/invoices"),Fr=h(z)(({theme:t})=>({width:"100%",marginBottom:t.spacing(1.5)})),Gr=({update:t})=>e.jsx(Fr,{href:`${Mr}/${t?"portal":"checkout"}`,variant:t?"outlined":"contained",children:t?"Update billing information":"Add billing information"}),dn=h("aside")(({theme:t})=>({padding:t.spacing(4),height:"100%",borderRadius:t.shape.borderRadiusLarge,backgroundColor:t.palette.background.elevation2})),Wr=h(R)(({theme:t})=>({marginBottom:t.spacing(4)})),zr=h(J)(({theme:t})=>({marginBottom:t.spacing(4)})),hs=h(R)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),qr=h(Mt)(({theme:t})=>({margin:`${t.spacing(2.5)} 0`,borderColor:t.palette.divider})),Hr=()=>{const{instanceStatus:t}=st(),{uiConfig:{billing:s}}=q(),n=s==="pay-as-you-go";if(!t)return e.jsx(f,{item:!0,xs:12,md:5,children:e.jsx(dn,{"data-loading":!0,sx:{flex:1,height:"400px"}})});const o=`${t.plan}${n?" Pay-as-You-Go":""}`,a=t.state!==Xn.ACTIVE,{isCustomBilling:i}=t;return e.jsx(f,{item:!0,xs:12,md:5,children:e.jsxs(dn,{children:[e.jsx(Wr,{variant:"body1",children:"Billing information"}),e.jsx(w,{condition:!!i,show:e.jsx(hs,{children:"Your billing is managed by Unleash"}),elseShow:e.jsxs(e.Fragment,{children:[e.jsx(w,{condition:a,show:e.jsxs(zr,{severity:"warning",children:["In order to"," ",e.jsx("strong",{children:"Upgrade trial"})," you need to provide us your billing information."]})}),e.jsx(Gr,{update:!a}),e.jsx(hs,{children:a?"Once we have received your billing information we will upgrade your trial within 1 business day":"Update your credit card and business information and change which email address we send invoices to"})]})}),e.jsx(qr,{}),e.jsxs(hs,{children:[e.jsx("a",{href:`mailto:support@getunleash.io?subject=${o} plan clarifications`,children:"Get in touch with us"})," ","for any clarification"]})]})})},Vr=h(f)(({theme:t})=>({flexWrap:"nowrap",gap:t.spacing(1)})),Te=({sx:t,children:s})=>e.jsx(Vr,{container:!0,item:!0,justifyContent:"space-between",alignItems:"center",sx:t,children:s}),ie=({children:t,vertical:s=!1})=>e.jsx(f,{container:s,item:!0,display:"flex",alignItems:s?"start":"center",direction:s?"column":void 0,children:t}),Yr=h("span")(({theme:t})=>({fontSize:t.fontSizes.smallBody,marginLeft:t.spacing(1)})),pt=({children:t})=>e.jsxs(Yr,{children:["(",t,")"]}),be=()=>{const{data:t,error:s,mutate:n}=Ee(ne("api/admin/user-admin"),Jr);return u.useMemo(()=>({users:(t==null?void 0:t.users)??[],roles:(t==null?void 0:t.rootRoles)??[],loading:!s&&!t,refetch:()=>n(),error:s}),[t,s,n])},Jr=t=>fetch(t).then(ue("Users")).then(s=>s.json()),No=new Date,am=jt(No,"yyyy-MM");eo(No);const im=t=>jt(t,"yyyy-MM"),rm=t=>jt(t,"yyyy-MM-dd"),lm=t=>to(t,"yyyy-MM",new Date),Kr=t=>to(t,"yyyy-MM-dd",new Date),Ns=5,Ms=1e6,Zr=Kr("2024-05-01"),Qr=["/api/admin","/api/frontend","/api/client"],Xr=t=>{const{apiData:s,...n}=t;return{apiData:s.filter(a=>Qr.includes(a.apiPath)).map(a=>(a.dataPoints=a.dataPoints.filter(({period:i})=>new Date(i)>=Zr),a)),...n}},el=(t,s)=>t.reduce((n,o)=>{const a=o.dataPoints.find(({period:r})=>r===s),i=(a==null?void 0:a.trafficTypes.reduce((r,c)=>r+c.count,0))??0;return n+i},0),Mo=t=>t.flatMap(s=>s.dataPoints.flatMap(n=>n.trafficTypes.map(o=>o.count))).reduce((s,n)=>s+n,0),tl=t=>{const{grouping:s,apiData:n}=t;if(s==="monthly"){const o=jt(new Date(t.dateRange.to),"yyyy-MM");return el(n,o)}else return Mo(n)},sl=(t,s=Ns,n=Ms)=>Math.ceil(t/n)*s,Fo=(t,s,n=Ns,o=Ms)=>{if(t===0)return 0;const a=Math.floor((t-s)/o)*o;return a>0?sl(a,n,o):0},nl=({dayOfMonth:t,daysInMonth:s,trafficData:n})=>{if(t<5)return 0;const o=n.map(i=>({...i,dataPoints:i.dataPoints.filter(r=>Number(r.period.slice(-2))<t)}));return Mo(o)/(t-1)*s},cm=(t,s,n,o=Ns,a=Ms)=>{if(!t)return 0;const i=n.getDate(),r=eo(n),c=nl({dayOfMonth:i,daysInMonth:r,trafficData:t});return Fo(c,s,o,a)},ol=(t,{from:s,to:n})=>{const o=`api/admin/metrics/traffic?grouping=${t}&from=${s}&to=${n}`,{data:a,error:i,mutate:r}=Ee(ne(o),al);return u.useMemo(()=>{const c=a?{state:"success",data:Xr(a)}:i?{state:"error",error:i}:{state:"loading"};return{refetch:()=>r(),result:c}},[a,i,r])},al=t=>fetch(t).then(ue("Instance Metrics")).then(s=>s.json()),Go=t=>{var m,p;const s=new Date,n=d=>jt(d,"yyyy-MM-dd"),o=n(Ia(s)),a=n(Pa(s)),{instanceStatus:i}=st(),r=((p=(m=i==null?void 0:i.prices)==null?void 0:m[(i==null?void 0:i.billing)==="pay-as-you-go"?"payg":"pro"])==null?void 0:p.traffic)??Fs,{result:c}=ol("daily",{from:o,to:a});return u.useMemo(()=>{if(c.state!=="success")return 0;const d=tl(c.data);return Fo(d,t,r)},[t,JSON.stringify(c),r])},ps=h(R)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),il=h(Rs)(({theme:t})=>({fontSize:"1rem",marginRight:t.spacing(1)})),rl=h(Mt)(({theme:t})=>({margin:`${t.spacing(3)} 0`})),ll=({instanceStatus:t})=>{var x,j,b,y,S,k;const{users:s,loading:n}=be(),o=s.filter(E=>E.email),a=((j=(x=t.prices)==null?void 0:x.pro)==null?void 0:j.base)??Wo,i=((y=(b=t.prices)==null?void 0:b.pro)==null?void 0:y.seat)??zo,r=((k=(S=t.prices)==null?void 0:S.pro)==null?void 0:k.traffic)??Fs,c=qo,l=Math.min(o.length,c),m=o.length-l,p=i*m,d=Go(Ho),g=a+p+d;return n?null:e.jsxs(e.Fragment,{children:[e.jsxs(f,{container:!0,children:[e.jsxs(Te,{sx:E=>({marginBottom:E.spacing(1.5)}),children:[e.jsxs(ie,{vertical:!0,children:[e.jsxs(R,{children:[e.jsx("strong",{children:"Included members"}),e.jsx(pt,{children:e.jsxs(ae,{to:"/admin/users",children:[l," of ",c," assigned"]})})]}),e.jsxs(ps,{children:["You have ",c," team members included in your PRO plan"]})]}),e.jsxs(ie,{children:[e.jsx(il,{}),e.jsx(R,{variant:"body2",children:"included"})]})]}),e.jsxs(Te,{sx:E=>({marginBottom:E.spacing(1.5)}),children:[e.jsxs(ie,{vertical:!0,children:[e.jsxs(R,{children:[e.jsx("strong",{children:"Paid members"}),e.jsx(pt,{children:e.jsxs(ae,{to:"/admin/users",children:[m," assigned"]})})]}),e.jsxs(ps,{children:["$",i,"/month per paid member"]})]}),e.jsx(ie,{children:e.jsxs(R,{sx:E=>({fontSize:E.fontSizes.mainHeader}),children:["$",p.toFixed(2)]})})]}),e.jsx(w,{condition:d>0,show:e.jsxs(Te,{children:[e.jsxs(ie,{vertical:!0,children:[e.jsxs(R,{children:[e.jsx("strong",{children:"Accrued traffic charges"}),e.jsx(pt,{children:e.jsx(ae,{to:"/admin/network/data-usage",children:"view details"})})]}),e.jsxs(ps,{children:["$",r," per 1 million started above included data"]})]}),e.jsx(ie,{children:e.jsxs(R,{sx:E=>({fontSize:E.fontSizes.mainHeader}),children:["$",d.toFixed(2)]})})]})})]}),e.jsx(rl,{}),e.jsx(f,{container:!0,children:e.jsxs(Te,{children:[e.jsx(ie,{children:e.jsx(R,{sx:E=>({fontWeight:E.fontWeight.bold,fontSize:E.fontSizes.mainHeader}),children:"Total"})}),e.jsx(ie,{children:e.jsxs(R,{sx:E=>({fontWeight:E.fontWeight.bold,fontSize:"2rem"}),children:["$",g.toFixed(2)]})})]})})]})},un=h(R)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),cl=h(Mt)(({theme:t})=>({margin:`${t.spacing(3)} 0`})),dl=({instanceStatus:t})=>{var d,g,x,j;const{users:s,loading:n}=be(),o=s.filter(b=>b.email),a=((g=(d=t.prices)==null?void 0:d.payg)==null?void 0:g.seat)??ml,i=((j=(x=t.prices)==null?void 0:x.payg)==null?void 0:j.traffic)??Fs,r=t.minSeats??xl,c=Math.max(o.length,r),l=a*c,m=Go(Ho),p=l+m;return n?null:e.jsxs(e.Fragment,{children:[e.jsxs(f,{container:!0,children:[e.jsxs(Te,{sx:b=>({marginBottom:b.spacing(1.5)}),children:[e.jsxs(ie,{vertical:!0,children:[e.jsxs(R,{children:[e.jsx("strong",{children:"Paid members"}),e.jsx(pt,{children:e.jsxs(ae,{to:"/admin/users",children:[o.length," assigned of"," ",r," minimum"]})})]}),e.jsxs(un,{children:["$",a,"/month per paid member"]})]}),e.jsx(ie,{children:e.jsxs(R,{sx:b=>({fontSize:b.fontSizes.mainHeader}),children:["$",l.toFixed(2)]})})]}),e.jsx(w,{condition:m>0,show:e.jsxs(Te,{children:[e.jsxs(ie,{vertical:!0,children:[e.jsxs(R,{children:[e.jsx("strong",{children:"Accrued traffic charges"}),e.jsx(pt,{children:e.jsx(ae,{to:"/admin/network/data-usage",children:"view details"})})]}),e.jsxs(un,{children:["$",i," per 1 million started above included data"]})]}),e.jsx(ie,{children:e.jsxs(R,{sx:b=>({fontSize:b.fontSizes.mainHeader}),children:["$",m.toFixed(2)]})})]})})]}),e.jsx(cl,{}),e.jsx(f,{container:!0,children:e.jsxs(Te,{children:[e.jsx(ie,{children:e.jsx(R,{sx:b=>({fontWeight:b.fontWeight.bold,fontSize:b.fontSizes.mainHeader}),children:"Total"})}),e.jsx(ie,{children:e.jsxs(R,{sx:b=>({fontWeight:b.fontWeight.bold,fontSize:"2rem"}),children:["$",p.toFixed(2)]})})]})})]})};h(R)(({theme:t})=>({fontSize:t.fontSizes.smallerBody,color:t.palette.text.secondary}));const ul=h(z)(({theme:t})=>({marginTop:t.spacing(1),display:"inline-flex",alignItems:"center"})),hl=()=>{const t=ne("api/admin/invoices/portal");return e.jsx(e.Fragment,{children:e.jsx(f,{container:!0,children:e.jsx(Te,{sx:s=>({marginBottom:s.spacing(3)}),children:e.jsx(ie,{vertical:!0,children:e.jsx(ul,{href:t,variant:"outlined",endIcon:e.jsx(Ba,{}),children:"View usage charges"})})})})})},pl=({instanceStatus:t,isPAYG:s,isEnterpriseConsumption:n})=>s?e.jsx(dl,{instanceStatus:t}):t.plan===Ds.PRO?e.jsx(ll,{instanceStatus:t}):n?e.jsx(hl,{}):null,Wo=80,zo=15,ml=75,Fs=5,xl=5,qo=5,Ho=53e6,hn=h("aside")(({theme:t})=>({padding:t.spacing(2.5),height:"100%",borderRadius:t.shape.borderRadiusLarge,boxShadow:t.boxShadows.elevated,[t.breakpoints.up("md")]:{padding:t.spacing(6.5)}})),gl=h("span")(({theme:t})=>({fontSize:"3.25rem",lineHeight:1,color:t.palette.primary.main,fontWeight:800,marginRight:t.spacing(1.5)})),jl=h("span")(({theme:t})=>({fontWeight:t.fontWeight.bold})),fl=h("span")(({theme:t})=>({fontWeight:t.fontWeight.bold})),yl=h("span")(({theme:t})=>({color:t.palette.primary.main,fontSize:t.fontSizes.mainHeader,fontWeight:t.fontWeight.bold})),bl=h(J)(({theme:t})=>({fontSize:t.fontSizes.smallerBody,marginBottom:t.spacing(3),marginTop:t.spacing(-1.5),[t.breakpoints.up("md")]:{marginTop:t.spacing(-4.5)}})),Sl=()=>{var m,p;const{uiConfig:{billing:t}}=q(),{instanceStatus:s}=st(),n=(s==null?void 0:s.plan)&&(s==null?void 0:s.plan)===Ds.PRO,o=t==="pay-as-you-go",a=t==="enterprise-consumption";if(!s)return e.jsx(f,{item:!0,xs:12,md:7,children:e.jsx(hn,{"data-loading":!0,sx:{flex:1,height:"400px"}})});const i=La(s),r=((p=(m=s.prices)==null?void 0:m.pro)==null?void 0:p.base)??Wo,c=`${s.plan}${o?" Pay-as-You-Go":""}`,l=s.state!==Xn.ACTIVE;return e.jsx(f,{item:!0,xs:12,md:7,children:e.jsxs(hn,{children:[e.jsx(w,{condition:l,show:e.jsxs(bl,{severity:"info",children:["After you have sent your billing information, your instance will be upgraded - you don't have to do anything."," ",e.jsx("a",{href:`mailto:support@getunleash.io?subject=${c} plan clarifications`,children:"Get in touch with us"})," ","for any clarification"]})}),e.jsx(xt,{color:"success",children:"Current plan"}),e.jsxs(f,{container:!0,sx:d=>({marginBottom:d.spacing(3)}),children:[e.jsxs(Te,{children:[e.jsxs(ie,{children:[e.jsx(gl,{children:s.plan}),e.jsx(w,{condition:Ua(s),show:e.jsx(fl,{sx:d=>({color:i?d.palette.error.dark:d.palette.warning.dark}),children:i?"Trial expired":s.trialExtended?"Extended Trial":"Trial"})})]}),e.jsx(ie,{children:e.jsx(w,{condition:!!n,show:e.jsxs(yl,{children:["$",r.toFixed(2)]})})})]}),e.jsx(Te,{children:e.jsx(w,{condition:o||a,show:e.jsxs(jl,{children:["Pay-as-You-Go"," ",a?"Consumption":""]})})})]}),e.jsx(pl,{instanceStatus:s,isPAYG:o,isEnterpriseConsumption:a})]})})},vl=()=>e.jsxs(f,{container:!0,spacing:4,children:[e.jsx(Hr,{}),e.jsx(Sl,{})]}),Cl=h(R)(({theme:t})=>({marginTop:t.spacing(6),marginBottom:t.spacing(2.5),fontSize:t.fontSizes.mainHeader})),wl=[{Header:"Amount",accessor:"amountFormatted"},{Header:"Status",accessor:"status",disableGlobalFilter:!0},{Header:"Created date",accessor:"created",Cell:je,disableGlobalFilter:!0},{Header:"Due date",accessor:"dueDate",Cell:je,disableGlobalFilter:!0},{Header:"Download",accessor:"invoicePDF",align:"center",Cell:({value:t})=>e.jsx(F,{sx:{display:"flex",justifyContent:"center"},"data-loading":!0,children:e.jsx(Oe,{href:t,children:e.jsx(Na,{})})}),width:100,disableGlobalFilter:!0,disableSortBy:!0}],Tl=({data:t,isLoading:s=!1})=>{const n=u.useMemo(()=>({sortBy:[{id:"created",desc:!0}]}),[]),{getTableProps:o,getTableBodyProps:a,headerGroups:i,rows:r,prepareRow:c}=G.useTable({columns:wl,data:t,initialState:n,sortTypes:fe,autoResetGlobalFilter:!1,disableSortRemove:!0,defaultColumn:{Cell:oe}},G.useGlobalFilter,G.useSortBy);return e.jsxs(te,{isLoading:s,disablePadding:!0,children:[e.jsx(Cl,{children:"Payment history"}),e.jsxs(Oa,{...o(),children:[e.jsx($a,{headerGroups:i}),e.jsx(As,{...a(),children:r.map(l=>{c(l);const{key:m,...p}=l.getRowProps();return e.jsx(gt,{hover:!0,...p,children:l.cells.map(d=>{const{key:g,...x}=d.getCellProps();return e.jsx(_a,{...x,children:d.render("Cell")},g)})},m)})})]}),e.jsx(w,{condition:r.length===0,show:e.jsx(de,{children:"No invoices to show."})})]})},Ts="api/admin/invoices",kl=ne(Ts),Vo=(t={})=>{const s=()=>fetch(kl,{method:"GET"}).then(ue("Invoices")).then(c=>c.json()),{data:n,error:o}=Ee(Ts,s,t),[a,i]=u.useState(!o&&!n),r=()=>{Ma(Ts)};return u.useEffect(()=>{i(!o&&!n)},[n,o]),{invoices:(n==null?void 0:n.invoices)||[],error:o,loading:a,refetchInvoices:r}},El=()=>{const{isBilling:t,refetchInstanceStatus:s,refresh:n,loading:o}=st(),{invoices:a}=Vo();return u.useEffect(()=>{(async()=>{await n(),s()})()},[s,n]),e.jsx("div",{children:e.jsx(te,{header:"Billing",isLoading:o,children:e.jsx(w,{condition:t,show:e.jsx(ve,{permissions:ee,children:e.jsxs(e.Fragment,{children:[e.jsx(vl,{}),e.jsx(Tl,{data:a})]})}),elseShow:e.jsx(J,{severity:"error",children:"Billing is not enabled for this instance."})})})})},Rl=ne("api/admin/invoices/portal"),Dl=()=>{const{refetchInvoices:t,invoices:s}=Vo(),[n,o]=u.useState(!1),{locationSettings:a}=so();return u.useEffect(()=>{t(),o(!0)},[]),e.jsx(w,{condition:s.length>0,show:e.jsx(te,{header:e.jsx(se,{title:"Invoices",actions:e.jsx(z,{href:Rl,rel:"noreferrer",target:"_blank",endIcon:e.jsx(Fa,{}),children:"Billing portal"})}),children:e.jsx("div",{children:e.jsxs(no,{children:[e.jsx(oo,{children:e.jsxs(gt,{children:[e.jsx(le,{children:"Amount"}),e.jsx(le,{children:"Status"}),e.jsx(le,{children:"Due date"}),e.jsx(le,{children:"PDF"}),e.jsx(le,{children:"Link"})]})}),e.jsx(As,{children:s.map(i=>e.jsxs(gt,{style:{backgroundColor:i.status==="past-due"?"error.dark":"inherit"},children:[e.jsx(le,{style:{textAlign:"left"},children:i.amountFormatted}),e.jsx(le,{style:{textAlign:"left"},children:i.status}),e.jsx(le,{style:{textAlign:"left"},children:i.dueDate&&ao(i.dueDate,a.locale)}),e.jsx(le,{style:{textAlign:"left"},children:e.jsx("a",{href:i.invoicePDF,children:"PDF"})}),e.jsx(le,{style:{textAlign:"left"},children:e.jsx("a",{href:i.invoiceURL,target:"_blank",rel:"noreferrer",children:"Payment link"})})]},i.invoiceURL))})]})})}),elseShow:e.jsx(te,{children:n&&"No invoices to show."})})},Al=()=>e.jsx("div",{children:e.jsx(ve,{permissions:ee,children:e.jsx(Dl,{})})}),Il=()=>{const{uiConfig:t,loading:s}=q();return s?null:t.flags.UNLEASH_CLOUD?e.jsx(Qn,{to:"/admin/billing",replace:!0}):e.jsx(Al,{})},Pl=()=>e.jsxs(J,{severity:"info",children:[e.jsxs("p",{children:["Use this page to configure allowed CORS origins for the Frontend API (",e.jsx("code",{children:"/api/frontend"}),")."]}),e.jsxs("p",{children:["This configuration will not affect the Admin API (",e.jsx("code",{children:"/api/admin"}),") nor the Client API (",e.jsx("code",{children:"/api/client"}),")."]}),e.jsxs("p",{children:["An asterisk (",e.jsx("code",{children:"*"}),") may be used to allow API calls from any origin."]}),e.jsx("br",{}),e.jsx("p",{children:"Be aware that changes here will take up to two minutes to be updated. In addition, there is a maxAge on the Access-Control-Allow-Origin header that will instruct browsers to cache this header for some time. The cache period is set to the maxium that the browser allows (2h for Chrome, 24h for Firefox)."})]}),Bl=()=>{const{makeRequest:t,createRequest:s,errors:n,loading:o}=xe({propagateErrors:!0});return{setCors:async i=>{const r=s("api/admin/ui-config/cors",{method:"POST",body:JSON.stringify({frontendApiOrigins:i})},"setCors");await t(r.caller,r.id)},loading:o,errors:n}},Ll=({frontendApiOrigins:t})=>{const{setCors:s}=Bl(),{setToastData:n,setToastApiError:o}=K(),[a,i]=u.useState(pn(t)),r=Ks(),c=Ks(),l=async m=>{try{const p=Ul(a);m.preventDefault(),await s(p),i(pn(p)),n({text:"Settings saved",type:"success"})}catch(p){o(V(p))}};return e.jsx("form",{onSubmit:l,children:e.jsxs(F,{sx:{display:"grid",gap:1},children:[e.jsxs("label",{htmlFor:r,children:["Which origins should be allowed to call the Frontend API? Add only one origin per line. The CORS specification does not support wildcard for subdomains, it needs to be a fully qualified domain, including the protocol.",e.jsx("br",{}),e.jsx("br",{}),'If you specify "*" it will be the chosen origin.',e.jsx("br",{}),e.jsx("br",{}),"Example:"]}),e.jsxs("code",{style:{fontSize:"0.7em"},children:["https://www.example.com",e.jsx("br",{}),"https://www.example2.com"]}),e.jsx(X,{id:r,"aria-describedby":c,placeholder:Ol,value:a,onChange:m=>i(m.target.value),multiline:!0,rows:12,variant:"outlined",fullWidth:!0,InputProps:{style:{fontFamily:"monospace",fontSize:"0.8em"}}}),e.jsx(io,{permission:[Ae,ro]})]})})},Ul=t=>t.split(/[,\n\s]+/).map(s=>s.replace(/\/$/,"")).filter(Boolean),pn=t=>(t==null?void 0:t.join(`
@@ -12,7 +12,7 @@ import{dF as Wn,j as e,dG as ve,dH as Ys,dI as Js,dJ as Ae,aC as te,aD as se,ax
12
12
  --data-raw '${JSON.stringify(j(),void 0,2)}'`,L=()=>{o(Ie)},C=T=>T.length,W=T=>!(k!=null&&k.filter(A=>A.name===T).length),I=C(a)&&W(a),U=T=>{b(),W(T)||S({name:"A group with that name already exists."}),i(T)};return e.jsx(ke,{loading:D,title:"Create group",description:"Groups is the best and easiest way to organize users and then use them in projects to assign a specific role in one go to all the users in a group.",documentationLink:"https://docs.getunleash.io/reference/rbac#user-groups",documentationLinkLabel:"Groups documentation",formatApiCode:P,children:e.jsx(Xo,{name:a,description:r,mappingsSSO:l,rootRole:g,users:p,setName:U,setDescription:c,setMappingsSSO:m,setRootRole:x,setUsers:d,errors:y,handleSubmit:v,handleCancel:L,mode:ni,isScimGroup:!1,children:e.jsx(z,{type:"submit",variant:"contained",color:"primary",disabled:!I,"data-testid":oi,children:"Create group"})})})},Tc=()=>{const t=Number(Vt("groupId")),{group:s,refetchGroup:n}=Zt(t);return s?e.jsx(kc,{group:s,groupId:t,refetchGroup:n}):null},kc=({group:t,groupId:s,refetchGroup:n})=>{const{refetchGroups:o}=Ge(),{setToastData:a,setToastApiError:i}=K(),{uiConfig:r}=q(),c=Ce(),{settings:{enabled:l}}=Ct(),m=l&&!!(t!=null&&t.scimId),{name:p,setName:d,description:g,setDescription:x,mappingsSSO:j,setMappingsSSO:b,users:y,setUsers:S,rootRole:k,setRootRole:E,getGroupPayload:D,clearErrors:v,errors:P,setErrors:L}=Ws(t==null?void 0:t.name,t==null?void 0:t.description,t==null?void 0:t.mappingsSSO,t==null?void 0:t.users,t==null?void 0:t.rootRole),{groups:C}=Ge(),{updateGroup:W,loading:I}=at(),U=async M=>{M.preventDefault(),v();const N=D();try{await W(s,N),n(),o(),c(Ie),a({text:"Group updated successfully",type:"success"})}catch(he){i(V(he))}},T=()=>`curl --location --request PUT '${r.unleashUrl}/api/admin/groups/${s}' \\
13
13
  --header 'Authorization: INSERT_API_KEY' \\
14
14
  --header 'Content-Type: application/json' \\
15
- --data-raw '${JSON.stringify(D(),void 0,2)}'`,A=()=>{c(Ie)},B=M=>M.length,$=M=>!(C!=null&&C.filter(N=>N.name===M&&N.id!==s).length),Y=B(p)&&$(p),O=M=>{v(),$(M)||L({name:"A group with that name already exists."}),d(M)};return e.jsx(ke,{loading:I,title:"Edit group",description:"Groups is the best and easiest way to organize users and then use them in projects to assign a specific role in one go to all the users in a group.",documentationLink:"https://docs.getunleash.io/reference/rbac#user-groups",documentationLinkLabel:"Groups documentation",formatApiCode:T,children:e.jsx(Xo,{name:p,description:g,mappingsSSO:j,users:y,rootRole:k,setName:O,setDescription:x,setMappingsSSO:b,setUsers:S,setRootRole:E,errors:P,handleSubmit:U,handleCancel:A,mode:Bs,isScimGroup:m,children:e.jsx(we,{title:m?mt:"",arrow:!0,children:e.jsx("div",{children:e.jsx(z,{type:"submit",variant:"contained",color:"primary",disabled:!Y,"data-testid":po,children:"Save"})})})})})},Ec=h(Ls)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(2.5,4),boxShadow:"none",marginBottom:t.spacing(2),fontSize:t.fontSizes.smallBody})),Rc=h("div")(({theme:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),Dc=h("h1")(({theme:t})=>({fontSize:t.fontSizes.mainHeader})),Ac=h("div")(({theme:t})=>({display:"flex"})),Ic=h("span")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginLeft:t.spacing(1)})),Pc=({title:t,description:s,actions:n})=>($t(t),e.jsxs(Ec,{children:[e.jsxs(Rc,{children:[e.jsx(Dc,{children:t}),e.jsx(Ac,{children:n})]}),e.jsx(w,{condition:!!(s!=null&&s.length),show:e.jsxs(e.Fragment,{children:["Description:",e.jsx(Ic,{children:s})]})})]})),Bc=({open:t,setOpen:s,user:n,group:o})=>{const{refetchGroup:a}=Zt(o.id),{updateGroup:i}=at(),{setToastData:r,setToastApiError:c}=K(),l=async()=>{try{const p={...o,users:o.users.filter(({id:d})=>d!==(n==null?void 0:n.id)).map(({id:d})=>({user:{id:d}}))};await i(o.id,p),a(),s(!1),r({text:"User removed from group successfully",type:"success"})}catch(p){c(V(p))}},m=(n==null?void 0:n.name)||(n==null?void 0:n.username)||(n==null?void 0:n.email);return e.jsx(Q,{open:t&&!!n,primaryButtonText:"Remove user",secondaryButtonText:"Cancel",onClick:l,onClose:()=>{s(!1)},title:"Remove user from group?",children:e.jsxs(R,{children:["Do you really want to remove ",e.jsx("strong",{children:m})," from"," ",e.jsx("strong",{children:o.name}),"? ",e.jsx("strong",{children:m})," will lose all access rights granted by this group."]})})},Lc=Array(15).fill({name:"Name of the user",username:"Username of the user"}),Uc={id:"joinedAt",desc:!0},{value:xn,setValue:Oc}=ai("Group:v1",Uc),$c=()=>{const t=Number(Vt("groupId")),s=yt(),n=me(s.breakpoints.down("md")),{group:o,loading:a}=Zt(t),[i,r]=u.useState(!1),[c,l]=u.useState(!1),[m,p]=u.useState(!1),[d,g]=u.useState(),{settings:{enabled:x}}=Ct(),j=x&&!!(o!=null&&o.scimId),b=u.useMemo(()=>[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:A}})=>e.jsx(oe,{children:e.jsx(We,{user:A})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:A=>A.name||"",Cell:({value:A,row:{original:B}})=>e.jsx(Se,{value:A,subtitle:B.email||B.username}),minWidth:100,searchable:!0},{Header:"Joined",accessor:"joinedAt",Cell:je,maxWidth:150},{id:"createdBy",Header:"Added by",accessor:"createdBy",Cell:Se,minWidth:90,searchable:!0},{Header:"Last login",accessor:"seenAt",Cell:$e,maxWidth:150},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:A}})=>e.jsx(Ot,{children:e.jsx(we,{title:j?mt:"Remove user from group",arrow:!0,describeChild:!0,children:e.jsx("span",{children:e.jsx(Oe,{"data-testid":`${ii}-${A.id}`,onClick:()=>{g(A),p(!0)},disabled:j,children:e.jsx(Pe,{})})})})}),maxWidth:100,disableSortBy:!0},{accessor:A=>A.username||"",Header:"Username",searchable:!0},{accessor:A=>A.email||"",Header:"Email",searchable:!0}],[g,p]),[y,S]=mo(),[k]=u.useState(()=>({sortBy:[{id:y.get("sort")||xn.id,desc:y.has("order")?y.get("order")==="desc":xn.desc}],hiddenColumns:["Username","Email"],globalFilter:y.get("search")||""})),[E,D]=u.useState(k.globalFilter),{data:v,getSearchText:P,getSearchContext:L}=nt(b,E,(o==null?void 0:o.users)??[]),C=u.useMemo(()=>(v==null?void 0:v.length)===0&&a?Lc:v,[v,a]),{headerGroups:W,rows:I,prepareRow:U,state:{sortBy:T}}=G.useTable({columns:b,data:C,initialState:k,sortTypes:fe,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},G.useSortBy,G.useFlexLayout);return u.useEffect(()=>{const A={};A.sort=T[0].id,T[0].desc&&(A.order="desc"),E&&(A.search=E),S(A,{replace:!0}),Oc({id:T[0].id,desc:T[0].desc||!1})},[T,E,S]),e.jsx(w,{condition:!!o,show:e.jsxs(e.Fragment,{children:[e.jsx(Pc,{title:o==null?void 0:o.name,description:o==null?void 0:o.description,actions:e.jsxs(e.Fragment,{children:[e.jsx(Le,{"data-testid":ri,to:`/admin/groups/${t}/edit`,component:ae,"data-loading":!0,permission:ee,tooltipProps:{title:j?mt:"Edit group"},children:e.jsx(ft,{})}),e.jsx(Le,{"data-testid":li,"data-loading":!0,onClick:()=>r(!0),permission:ee,tooltipProps:{title:"Delete group"},children:e.jsx(Pe,{})})]})}),e.jsxs(te,{isLoading:a,header:e.jsx(se,{secondary:!0,title:`Users (${I.length<C.length?`${I.length} of ${C.length}`:C.length})`,actions:e.jsxs(e.Fragment,{children:[e.jsx(w,{condition:!n,show:e.jsxs(e.Fragment,{children:[e.jsx(ce,{initialValue:E,onChange:D,hasFilters:!0,getSearchContext:L}),e.jsx(se.Divider,{})]})}),e.jsx(Ps,{"data-testid":ci,onClick:()=>{l(!0)},maxWidth:"700px",Icon:Ht,permission:ee,disabled:j,tooltipProps:{title:j?mt:""},children:"Edit users"})]}),children:e.jsx(w,{condition:n,show:e.jsx(ce,{initialValue:E,onChange:D,hasFilters:!0,getSearchContext:L})})}),children:[e.jsx(_e,{value:P(E),children:e.jsx(ye,{rows:I,headerGroups:W,prepareRow:U})}),e.jsx(w,{condition:I.length===0,show:e.jsx(w,{condition:(E==null?void 0:E.length)>0,show:e.jsxs(de,{children:["No users found matching “",E,"” in this group."]}),elseShow:e.jsx(de,{children:"This group is empty. Get started by adding a user to the group."})})}),e.jsx(Qo,{open:i,setOpen:r,group:o}),e.jsx(Zo,{open:c,setOpen:l,group:o}),e.jsx(Bc,{open:m,setOpen:p,user:d,group:o})]})]})})},_c=()=>{const{uiConfig:t,isEnterprise:s}=q();return s()||t.flags[di]===!0?e.jsx("div",{children:e.jsx(ve,{permissions:Ae,children:e.jsxs(tt,{children:[e.jsx(_,{index:!0,element:e.jsx(mc,{})}),e.jsx(_,{path:"create-group",element:e.jsx(wc,{})}),e.jsx(_,{path:":groupId/edit",element:e.jsx(Tc,{})}),e.jsx(_,{path:":groupId",element:e.jsx($c,{})})]})})}):e.jsx(et,{feature:"groups",page:!0})},ea=()=>{const{data:t,error:s,mutate:n}=Ee(ne("api/admin/instance-admin/statistics"),Nc);return u.useMemo(()=>({stats:t,loading:!s&&!t,refetchGroup:()=>n(),error:s}),[t,s,n])},Nc=t=>fetch(t).then(ue("Instance Stats")).then(s=>s.json()),Mc=()=>{var i,r,c;const{stats:t}=ea();let s,n;t!=null&&t.versionEnterprise?(s="Unleash Enterprise version",n=t.versionEnterprise):(s="Unleash OSS version",n=t==null?void 0:t.versionOSS);const o=Object.values((t==null?void 0:t.apiTokens)??{}).reduce((l,m)=>l+m,0),a=[{title:"Instance Id",value:t==null?void 0:t.instanceId,offset:!1},{title:s,value:n},{title:"Users",value:t==null?void 0:t.users},{title:"Feature flags",value:t==null?void 0:t.featureToggles},{title:"Projects",value:t==null?void 0:t.projects},{title:"Environments",value:t==null?void 0:t.environments},{title:"Roles",value:t==null?void 0:t.roles},{title:"Groups",value:t==null?void 0:t.groups},{title:"Context fields",value:t==null?void 0:t.contextFields},{title:"Strategies",value:t==null?void 0:t.strategies},{title:"Feature exports",value:t==null?void 0:t.featureExports},{title:"Feature imports",value:t==null?void 0:t.featureImports},{title:"Admin API tokens",value:(i=t==null?void 0:t.apiTokens)==null?void 0:i.admin},{title:"Client API tokens",value:(r=t==null?void 0:t.apiTokens)==null?void 0:r.client},{title:"Frontend API tokens",value:(c=t==null?void 0:t.apiTokens)==null?void 0:c.frontend},{title:"API tokens total",value:o},{title:"Segments",value:t==null?void 0:t.segments},{title:"Highest number of strategies used for a single flag in a single environment",value:t==null?void 0:t.maxEnvironmentStrategies},{title:"Highest number of constraints used on a single strategy",value:t==null?void 0:t.maxConstraints},{title:"Highest number of values used for a single constraint",value:t==null?void 0:t.maxConstraintValues},{title:"Release templates",value:t==null?void 0:t.releaseTemplates},{title:"Release plans",value:t==null?void 0:t.releasePlans}];return t!=null&&t.versionEnterprise&&a.push({title:"SAML enabled",value:t!=null&&t.SAMLenabled?"Yes":"No"},{title:"OIDC enabled",value:t!=null&&t.OIDCenabled?"Yes":"No"}),e.jsx(te,{header:e.jsx(se,{title:"Instance Statistics"}),children:e.jsxs(Qs,{sx:{display:"grid",gap:4},children:[e.jsxs(no,{"aria-label":"Instance statistics",children:[e.jsx(oo,{children:e.jsxs(gt,{children:[e.jsx(le,{children:"Field"}),e.jsx(le,{align:"right",children:"Value"})]})}),e.jsx(As,{children:a.map(l=>e.jsxs(gt,{children:[e.jsx(le,{component:"th",scope:"row",children:e.jsx(Qs,{component:"span",sx:m=>({marginLeft:l.offset?m.spacing(2):0}),children:l.title})}),e.jsx(le,{align:"right",children:l.value})]},l.title))})]}),e.jsx("span",{style:{textAlign:"center"},children:e.jsx(z,{startIcon:e.jsx(xo,{}),"aria-label":"Download instance statistics",color:"primary",variant:"contained",target:"_blank",rel:"noreferrer",href:ne("/api/admin/instance-admin/statistics/csv"),children:"Download"})})]})})},Fc=()=>e.jsx("div",{children:e.jsx(Mc,{})}),Gc=h("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),Wc=h(F)(()=>({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"})),zc=h(F)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),qc=h("p")(({theme:t})=>({display:"table-cell",fontWeight:t.fontWeight.bold,paddingTop:t.spacing(2)})),Hc=h("p")(({theme:t})=>({display:"table-cell",paddingTop:t.spacing(2),paddingLeft:t.spacing(4)})),Vc=h("div")(({theme:t})=>({display:"table-cell",width:"75%",paddingTop:t.spacing(2),paddingBottom:t.spacing(2)})),Yc=h("div")(({theme:t})=>({display:"table-cell"})),Jc=h("span")(({theme:t})=>({display:"block",textAlign:"right",color:t.palette.neutral.dark})),Kc=h("div")(({theme:t})=>({maxWidth:t.spacing(50),color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody})),Zc=h("div")(()=>({display:"table-row"})),gn=h("div")(()=>({display:"table"})),Qc=h("div")(()=>({display:"table-cell"})),Xc=({changeInfoText:t,variablesText:s,dependsOnText:n})=>e.jsxs(Kc,{children:[e.jsx(jn,{children:t}),e.jsx(ed,{children:e.jsx("div",{children:s})}),e.jsx(w,{condition:!!n,show:e.jsx(jn,{children:n})})]}),ed=h("code")(({theme:t})=>({display:"block",color:t.palette.text.primary,backgroundColor:t.palette.background.application,fontSize:t.fontSizes.smallerBody,marginTop:t.spacing(1),padding:t.spacing(1),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadius,borderWidth:1,wordWrap:"break-word",whiteSpace:"pre-wrap",fontFamily:"monospace",lineHeight:1.5})),jn=h("p")(({theme:t})=>({color:t.palette.text.primary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1)})),fn=({title:t,infoText:s,concreteDetails:n,enabled:o,changeInfoText:a,variablesText:i,dependsOnText:r})=>e.jsxs(Gc,{children:[e.jsxs(Wc,{children:[e.jsx("b",{children:t}),e.jsx(Yc,{children:e.jsx(w,{condition:o,show:e.jsx(xt,{color:"success",icon:e.jsx(Rs,{}),children:"Data is collected"}),elseShow:e.jsx(xt,{color:"neutral",icon:e.jsx(ui,{}),children:"No data is collected"})})})]}),e.jsxs(zc,{children:[e.jsxs(gn,{children:[e.jsx(Vc,{children:s}),e.jsx(Qc,{children:e.jsx(Jc,{children:e.jsx(Wt,{tooltip:e.jsx(Xc,{changeInfoText:a,variablesText:i,dependsOnText:r}),children:o?"How to disable collecting data?":"How to enable collecting data?"})})})]}),e.jsx(gn,{children:Object.entries(n).map(([c,l])=>e.jsxs(Zc,{children:[e.jsx(qc,{children:c}),e.jsx(Hc,{children:l})]},c))})]})]}),td=()=>{const{data:t,error:s,mutate:n}=Ee(ne("api/admin/telemetry/settings"),sd);return u.useMemo(()=>({settings:t,loading:!s&&!t,refetchGroup:()=>n(),error:s}),[t,s,n])},sd=t=>fetch(t).then(ue("Telemetry Settings")).then(s=>s.json()),nd=h(F)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),ms={title:"Version data collection",infoText:"We collect the version of Unleash that you're using. We use this information to inform your Unleash instance of latest updates and critical security patches.",concreteDetails:{"Instance ID":"A unique ID generated for your instance",Version:"The version of Unleash that you're using"}},xs={title:"Feature data collection",infoText:"We collect data about your instance to improve the Unleash product user experience. We may also use the data in case you need help from our support team. Data collection is for internal use only and is not shared with third parties outside Unleash. As we want you to be in control of your data, we will leave it up to you to allow us to collect your data.",concreteDetails:{"Feature flags":"The number of feature flags in your instance",Users:"The number of users registered in your instance",Projects:"The number of projects in your instance","Context Fields":"The number of custom context fields in use",Groups:"The number of groups present in your instance",Roles:"The number of custom roles defined in your instance","Custom Root Roles":"The number of custom root roles defined in your instance","Custom Root Roles In Use":"The number of custom root roles that are in use by entities (users, groups, service accounts)",Environments:"The number of environments in your instance",Segments:"The number of segments defined in your instance",Strategies:"The number of strategies defined in your instance","Feature Exports":"The number of feature exports performed","Feature Imports":"The number of feature imports performed","Custom Strategies":"The number of custom strategies defined in your instance","Custom Strategies In Use":"The number of custom strategies that are in use by feature flags"}},yn={enabled:{environmentVariables:"CHECK_VERSION=false",changeInfoText:"Version info collection can be disabled by setting the environment variable `CHECK_VERSION` to `false` and restarting Unleash."},disabled:{environmentVariables:"CHECK_VERSION=true",changeInfoText:"Version info collection can be enabled by setting the environment variable to true and restarting Unleash."}},bn={enabled:{environmentVariables:"SEND_TELEMETRY=false",changeInfoText:"Feature usage collection can be disabled by setting the environment variable to false and restarting Unleash."},disabled:{environmentVariables:"SEND_TELEMETRY=true",changeInfoText:"To enable feature usage collection set the environment variable to true and restart Unleash."}},od=()=>{const{settings:t}=td(),{loading:s}=q();if(s)return null;const n=t!=null&&t.versionInfoCollectionEnabled?yn.enabled:yn.disabled,o=t!=null&&t.featureInfoCollectionEnabled?bn.enabled:bn.disabled;let a;return t!=null&&t.versionInfoCollectionEnabled||(a=t!=null&&t.featureInfoCollectionEnabled?"Note: Feature usage collection is enabled, but for it to be active you must also enable version info collection":"When you enable feature usage collection you must also enable version info collection"),e.jsx(te,{header:e.jsx(se,{title:"Instance Privacy"}),children:e.jsxs(nd,{children:[e.jsx(fn,{title:ms.title,infoText:ms.infoText,concreteDetails:ms.concreteDetails,enabled:t==null?void 0:t.versionInfoCollectionEnabled,changeInfoText:n.changeInfoText,variablesText:n.environmentVariables}),e.jsx(fn,{title:xs.title,infoText:xs.infoText,concreteDetails:xs.concreteDetails,enabled:(t==null?void 0:t.featureInfoCollectionEnabled)&&(t==null?void 0:t.versionInfoCollectionEnabled),changeInfoText:o.changeInfoText,variablesText:o.environmentVariables,dependsOnText:a})]})})},ad=()=>e.jsx(J,{severity:"warning",children:e.jsxs("p",{children:[e.jsx("b",{children:"Heads up!"})," If you enable maintenance mode, edit access in the entire system will be disabled for all the users (admins, editors, custom roles, etc). During this time nobody will be able to do changes or to make new configurations."]})}),id=()=>{const{data:t,error:s,mutate:n}=Ee(ne("api/admin/maintenance"),rd);return u.useMemo(()=>({enabled:!!(t!=null&&t.enabled),loading:!s&&!t,refetchMaintenance:n,error:s}),[t,s,n])},rd=t=>fetch(t).then(ue("Maintenance")).then(s=>s.json()),ld=()=>{const{makeRequest:t,createRequest:s,errors:n,loading:o}=xe({propagateErrors:!0});return{toggleMaintenance:async i=>{const c=s("api/admin/maintenance",{method:"POST",body:JSON.stringify(i)});await t(c.caller,c.id)},errors:n,loading:o}},cd=h("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),dd=h(F)({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"}),ud=h(F)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),hd=h(R)(({theme:t})=>({fontSize:t.fontSizes.smallBody})),pd=()=>{const{enabled:t,refetchMaintenance:s}=id(),{refetch:n}=q(),{toggleMaintenance:o}=ld(),{trackEvent:a}=Us(),{setToastData:i}=K(),r=async()=>{i({type:"success",text:`Maintenance mode has been successfully ${t?"disabled":"enabled"}`}),a("maintenance",{props:{eventType:`maintenance ${t?"de":""}activated`}}),await o({enabled:!t}),s(),n()};return e.jsxs(cd,{children:[e.jsxs(dd,{children:[e.jsx("b",{children:"Maintenance Mode"}),e.jsx(re,{sx:{margin:0},control:e.jsx(ge,{onChange:r,value:t,name:"enabled",checked:t}),label:e.jsx(hd,{children:t?"Enabled":"Disabled"})})]}),e.jsx(ud,{children:"Maintenance Mode is useful when you want to freeze your system so nobody can do any changes during this time. When enabled it will show a banner at the top of the applications and only an admin can enable it or disable it."})]})},md=()=>e.jsx("div",{children:e.jsx(ve,{permissions:[ee,hi],children:e.jsx(gd,{})})}),xd=h(F)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),gd=()=>{const{loading:t}=q();return t?null:e.jsx(te,{header:e.jsx(se,{title:"Maintenance"}),children:e.jsxs(xd,{children:[e.jsx(ad,{}),e.jsx(pd,{})]})})},jd=h(ae)(({theme:t})=>({display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",textDecoration:"none",color:"inherit",padding:t.spacing(0,5),"&.active":{fontWeight:"bold"}})),ta=({to:t,children:s})=>e.jsx(jd,{to:t,children:s}),fd=u.lazy(()=>ot(()=>import("./NetworkOverview-BKozpi8w.js"),[])),yd=u.lazy(()=>ot(()=>import("./NetworkConnectedEdges-C2nfTRKM.js"),[])),bd=u.lazy(()=>ot(()=>import("./NetworkTraffic-Co7oakIE.js"),[])),Sd=u.lazy(()=>ot(()=>import("./NetworkTrafficUsage-DNDJZGXi.js"),[])),vd=u.lazy(()=>ot(()=>import("./BackendConnections-Bi1Fsohi.js"),[])),Cd=u.lazy(()=>ot(()=>import("./FrontendNetworkTrafficUsage-DlRkx8CV.js"),[])),Sn=[{label:"Overview",path:"/admin/network"},{label:"Traffic",path:"/admin/network/traffic"},{label:"Connected Edges",path:"/admin/network/connected-edges"}],wd=[{label:"Data Usage",path:"/admin/network/data-usage"}],Td=[{label:"Backend Connections",path:"/admin/network/backend-connections"},{label:"Frontend Traffic",path:"/admin/network/frontend-data-usage"}],kd=()=>{const{pathname:t}=Es(),s=Pt("edgeObservability"),a=(Pt("consumptionModelUI")?[...Sn,...Td]:[...Sn,...wd]).filter(({label:i})=>i!=="Connected Edges"||s);return e.jsx("div",{children:e.jsx(te,{withTabs:!0,header:e.jsx(go,{value:t,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:a.map(({label:i,path:r})=>e.jsx(jo,{value:r,label:e.jsx(ta,{to:r,children:e.jsx("span",{children:i})}),sx:{padding:0}},i))}),children:e.jsxs(tt,{children:[e.jsx(_,{path:"*",element:e.jsx(fd,{})}),e.jsx(_,{path:"traffic",element:e.jsx(bd,{})}),s&&e.jsx(_,{path:"connected-edges",element:e.jsx(yd,{})}),e.jsx(_,{path:"data-usage",element:e.jsx(Sd,{})}),e.jsx(_,{path:"backend-connections",element:e.jsx(vd,{})}),e.jsx(_,{path:"frontend-data-usage",element:e.jsx(Cd,{})})]})})})},Ed=h(F)(()=>({display:"flex",justifyContent:"center"})),Rd=({role:t,onEdit:s,onDelete:n})=>{const o=Me.includes(t.type);return e.jsxs(Ed,{children:[e.jsx(Le,{"data-loading":!0,onClick:s,permission:ee,disabled:o,tooltipProps:{title:o?"You cannot edit a predefined role":"Edit role"},children:e.jsx(ft,{})}),e.jsx(Le,{"data-loading":!0,onClick:n,permission:ee,disabled:o,tooltipProps:{title:o?"You cannot remove a predefined role":"Remove role"},children:e.jsx(Pe,{})})]})},Dd=h(xt)(({theme:t})=>({marginLeft:t.spacing(1)})),Ad=({role:t})=>e.jsx(Se,{value:t.name,subtitle:t.description,afterTitle:e.jsx(w,{condition:Me.includes(t.type),show:e.jsx(Dd,{color:"success",children:"Predefined"})})}),Id=({users:t})=>{const[s]=u.useState(()=>({sortBy:[{id:"last-login",desc:!0}]})),n=u.useMemo(()=>[{id:"name",Header:"Name",accessor:r=>r.name||"",minWidth:200,Cell:({row:{original:r}})=>e.jsx(Se,{value:r.name,subtitle:r.email||r.username})},{Header:"Created",accessor:"createdAt",Cell:je,width:120,maxWidth:120},{id:"last-login",Header:"Last login",accessor:"seenAt",Cell:$e,maxWidth:150}],[]),{headerGroups:o,rows:a,prepareRow:i}=G.useTable({columns:n,data:t,initialState:s,sortTypes:fe,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},G.useSortBy,G.useFlexLayout);return e.jsx(ye,{rows:a,headerGroups:o,prepareRow:i})},Pd=h(R)(({theme:t})=>({fontSize:t.fontSizes.smallerBody})),sa=({serviceAccount:t,value:s,onCreateToken:n})=>{var a,i,r;const{searchQuery:o}=Is();return!t.tokens||t.tokens.length===0?n?e.jsx(fo,{title:"Create token",onClick:n}):e.jsx(oe,{children:"0 tokens"}):e.jsx(oe,{children:e.jsx(Wt,{tooltip:e.jsx(e.Fragment,{children:(a=t.tokens)==null?void 0:a.map(({id:c,description:l})=>e.jsx(Pd,{children:e.jsx(Bt,{search:o,children:l})},c))}),highlighted:o.length>0&&s.toLowerCase().includes(o.toLowerCase()),children:((i=t.tokens)==null?void 0:i.length)===1?"1 token":`${(r=t.tokens)==null?void 0:r.length} tokens`})})},Bd=({serviceAccounts:t})=>{const[s]=u.useState(()=>({sortBy:[{id:"seenAt",desc:!0}]})),n=u.useMemo(()=>[{id:"name",Header:"Name",accessor:r=>r.name||"",minWidth:200,Cell:({row:{original:r}})=>e.jsx(Se,{value:r.name,subtitle:r.username})},{id:"tokens",Header:"Tokens",accessor:r=>{var c;return((c=r.tokens)==null?void 0:c.map(({description:l})=>l).join(`
15
+ --data-raw '${JSON.stringify(D(),void 0,2)}'`,A=()=>{c(Ie)},B=M=>M.length,$=M=>!(C!=null&&C.filter(N=>N.name===M&&N.id!==s).length),Y=B(p)&&$(p),O=M=>{v(),$(M)||L({name:"A group with that name already exists."}),d(M)};return e.jsx(ke,{loading:I,title:"Edit group",description:"Groups is the best and easiest way to organize users and then use them in projects to assign a specific role in one go to all the users in a group.",documentationLink:"https://docs.getunleash.io/reference/rbac#user-groups",documentationLinkLabel:"Groups documentation",formatApiCode:T,children:e.jsx(Xo,{name:p,description:g,mappingsSSO:j,users:y,rootRole:k,setName:O,setDescription:x,setMappingsSSO:b,setUsers:S,setRootRole:E,errors:P,handleSubmit:U,handleCancel:A,mode:Bs,isScimGroup:m,children:e.jsx(we,{title:m?mt:"",arrow:!0,children:e.jsx("div",{children:e.jsx(z,{type:"submit",variant:"contained",color:"primary",disabled:!Y,"data-testid":po,children:"Save"})})})})})},Ec=h(Ls)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(2.5,4),boxShadow:"none",marginBottom:t.spacing(2),fontSize:t.fontSizes.smallBody})),Rc=h("div")(({theme:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),Dc=h("h1")(({theme:t})=>({fontSize:t.fontSizes.mainHeader})),Ac=h("div")(({theme:t})=>({display:"flex"})),Ic=h("span")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginLeft:t.spacing(1)})),Pc=({title:t,description:s,actions:n})=>($t(t),e.jsxs(Ec,{children:[e.jsxs(Rc,{children:[e.jsx(Dc,{children:t}),e.jsx(Ac,{children:n})]}),e.jsx(w,{condition:!!(s!=null&&s.length),show:e.jsxs(e.Fragment,{children:["Description:",e.jsx(Ic,{children:s})]})})]})),Bc=({open:t,setOpen:s,user:n,group:o})=>{const{refetchGroup:a}=Zt(o.id),{updateGroup:i}=at(),{setToastData:r,setToastApiError:c}=K(),l=async()=>{try{const p={...o,users:o.users.filter(({id:d})=>d!==(n==null?void 0:n.id)).map(({id:d})=>({user:{id:d}}))};await i(o.id,p),a(),s(!1),r({text:"User removed from group successfully",type:"success"})}catch(p){c(V(p))}},m=(n==null?void 0:n.name)||(n==null?void 0:n.username)||(n==null?void 0:n.email);return e.jsx(Q,{open:t&&!!n,primaryButtonText:"Remove user",secondaryButtonText:"Cancel",onClick:l,onClose:()=>{s(!1)},title:"Remove user from group?",children:e.jsxs(R,{children:["Do you really want to remove ",e.jsx("strong",{children:m})," from"," ",e.jsx("strong",{children:o.name}),"? ",e.jsx("strong",{children:m})," will lose all access rights granted by this group."]})})},Lc=Array(15).fill({name:"Name of the user",username:"Username of the user"}),Uc={id:"joinedAt",desc:!0},{value:xn,setValue:Oc}=ai("Group:v1",Uc),$c=()=>{const t=Number(Vt("groupId")),s=yt(),n=me(s.breakpoints.down("md")),{group:o,loading:a}=Zt(t),[i,r]=u.useState(!1),[c,l]=u.useState(!1),[m,p]=u.useState(!1),[d,g]=u.useState(),{settings:{enabled:x}}=Ct(),j=x&&!!(o!=null&&o.scimId),b=u.useMemo(()=>[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:A}})=>e.jsx(oe,{children:e.jsx(We,{user:A})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:A=>A.name||"",Cell:({value:A,row:{original:B}})=>e.jsx(Se,{value:A,subtitle:B.email||B.username}),minWidth:100,searchable:!0},{Header:"Joined",accessor:"joinedAt",Cell:je,maxWidth:150},{id:"createdBy",Header:"Added by",accessor:"createdBy",Cell:Se,minWidth:90,searchable:!0},{Header:"Last login",accessor:"seenAt",Cell:$e,maxWidth:150},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:A}})=>e.jsx(Ot,{children:e.jsx(we,{title:j?mt:"Remove user from group",arrow:!0,describeChild:!0,children:e.jsx("span",{children:e.jsx(Oe,{"data-testid":`${ii}-${A.id}`,onClick:()=>{g(A),p(!0)},disabled:j,children:e.jsx(Pe,{})})})})}),maxWidth:100,disableSortBy:!0},{accessor:A=>A.username||"",Header:"Username",searchable:!0},{accessor:A=>A.email||"",Header:"Email",searchable:!0}],[g,p]),[y,S]=mo(),[k]=u.useState(()=>({sortBy:[{id:y.get("sort")||xn.id,desc:y.has("order")?y.get("order")==="desc":xn.desc}],hiddenColumns:["Username","Email"],globalFilter:y.get("search")||""})),[E,D]=u.useState(k.globalFilter),{data:v,getSearchText:P,getSearchContext:L}=nt(b,E,(o==null?void 0:o.users)??[]),C=u.useMemo(()=>(v==null?void 0:v.length)===0&&a?Lc:v,[v,a]),{headerGroups:W,rows:I,prepareRow:U,state:{sortBy:T}}=G.useTable({columns:b,data:C,initialState:k,sortTypes:fe,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},G.useSortBy,G.useFlexLayout);return u.useEffect(()=>{const A={};A.sort=T[0].id,T[0].desc&&(A.order="desc"),E&&(A.search=E),S(A,{replace:!0}),Oc({id:T[0].id,desc:T[0].desc||!1})},[T,E,S]),e.jsx(w,{condition:!!o,show:e.jsxs(e.Fragment,{children:[e.jsx(Pc,{title:o==null?void 0:o.name,description:o==null?void 0:o.description,actions:e.jsxs(e.Fragment,{children:[e.jsx(Le,{"data-testid":ri,to:`/admin/groups/${t}/edit`,component:ae,"data-loading":!0,permission:ee,tooltipProps:{title:j?mt:"Edit group"},children:e.jsx(ft,{})}),e.jsx(Le,{"data-testid":li,"data-loading":!0,onClick:()=>r(!0),permission:ee,tooltipProps:{title:"Delete group"},children:e.jsx(Pe,{})})]})}),e.jsxs(te,{isLoading:a,header:e.jsx(se,{secondary:!0,title:`Users (${I.length<C.length?`${I.length} of ${C.length}`:C.length})`,actions:e.jsxs(e.Fragment,{children:[e.jsx(w,{condition:!n,show:e.jsxs(e.Fragment,{children:[e.jsx(ce,{initialValue:E,onChange:D,hasFilters:!0,getSearchContext:L}),e.jsx(se.Divider,{})]})}),e.jsx(Ps,{"data-testid":ci,onClick:()=>{l(!0)},maxWidth:"700px",Icon:Ht,permission:ee,disabled:j,tooltipProps:{title:j?mt:""},children:"Edit users"})]}),children:e.jsx(w,{condition:n,show:e.jsx(ce,{initialValue:E,onChange:D,hasFilters:!0,getSearchContext:L})})}),children:[e.jsx(_e,{value:P(E),children:e.jsx(ye,{rows:I,headerGroups:W,prepareRow:U})}),e.jsx(w,{condition:I.length===0,show:e.jsx(w,{condition:(E==null?void 0:E.length)>0,show:e.jsxs(de,{children:["No users found matching “",E,"” in this group."]}),elseShow:e.jsx(de,{children:"This group is empty. Get started by adding a user to the group."})})}),e.jsx(Qo,{open:i,setOpen:r,group:o}),e.jsx(Zo,{open:c,setOpen:l,group:o}),e.jsx(Bc,{open:m,setOpen:p,user:d,group:o})]})]})})},_c=()=>{const{uiConfig:t,isEnterprise:s}=q();return s()||t.flags[di]===!0?e.jsx("div",{children:e.jsx(ve,{permissions:Ae,children:e.jsxs(tt,{children:[e.jsx(_,{index:!0,element:e.jsx(mc,{})}),e.jsx(_,{path:"create-group",element:e.jsx(wc,{})}),e.jsx(_,{path:":groupId/edit",element:e.jsx(Tc,{})}),e.jsx(_,{path:":groupId",element:e.jsx($c,{})})]})})}):e.jsx(et,{feature:"groups",page:!0})},ea=()=>{const{data:t,error:s,mutate:n}=Ee(ne("api/admin/instance-admin/statistics"),Nc);return u.useMemo(()=>({stats:t,loading:!s&&!t,refetchGroup:()=>n(),error:s}),[t,s,n])},Nc=t=>fetch(t).then(ue("Instance Stats")).then(s=>s.json()),Mc=()=>{var i,r,c;const{stats:t}=ea();let s,n;t!=null&&t.versionEnterprise?(s="Unleash Enterprise version",n=t.versionEnterprise):(s="Unleash OSS version",n=t==null?void 0:t.versionOSS);const o=Object.values((t==null?void 0:t.apiTokens)??{}).reduce((l,m)=>l+m,0),a=[{title:"Instance Id",value:t==null?void 0:t.instanceId,offset:!1},{title:s,value:n},{title:"Users",value:t==null?void 0:t.users},{title:"Feature flags",value:t==null?void 0:t.featureToggles},{title:"Projects",value:t==null?void 0:t.projects},{title:"Environments",value:t==null?void 0:t.environments},{title:"Roles",value:t==null?void 0:t.roles},{title:"Groups",value:t==null?void 0:t.groups},{title:"Context fields",value:t==null?void 0:t.contextFields},{title:"Strategies",value:t==null?void 0:t.strategies},{title:"Feature exports",value:t==null?void 0:t.featureExports},{title:"Feature imports",value:t==null?void 0:t.featureImports},{title:"Admin API tokens",value:(i=t==null?void 0:t.apiTokens)==null?void 0:i.admin},{title:"Client API tokens",value:(r=t==null?void 0:t.apiTokens)==null?void 0:r.client},{title:"Frontend API tokens",value:(c=t==null?void 0:t.apiTokens)==null?void 0:c.frontend},{title:"API tokens total",value:o},{title:"Segments",value:t==null?void 0:t.segments},{title:"Highest number of strategies used for a single flag in a single environment",value:t==null?void 0:t.maxEnvironmentStrategies},{title:"Highest number of constraints used on a single strategy",value:t==null?void 0:t.maxConstraints},{title:"Highest number of values used for a single constraint",value:t==null?void 0:t.maxConstraintValues},{title:"Release templates",value:t==null?void 0:t.releaseTemplates},{title:"Release plans",value:t==null?void 0:t.releasePlans}];return t!=null&&t.versionEnterprise&&a.push({title:"SAML enabled",value:t!=null&&t.SAMLenabled?"Yes":"No"},{title:"OIDC enabled",value:t!=null&&t.OIDCenabled?"Yes":"No"}),e.jsx(te,{header:e.jsx(se,{title:"Instance Statistics"}),children:e.jsxs(Qs,{sx:{display:"grid",gap:4},children:[e.jsxs(no,{"aria-label":"Instance statistics",children:[e.jsx(oo,{children:e.jsxs(gt,{children:[e.jsx(le,{children:"Field"}),e.jsx(le,{align:"right",children:"Value"})]})}),e.jsx(As,{children:a.map(l=>e.jsxs(gt,{children:[e.jsx(le,{component:"th",scope:"row",children:e.jsx(Qs,{component:"span",sx:m=>({marginLeft:l.offset?m.spacing(2):0}),children:l.title})}),e.jsx(le,{align:"right",children:l.value})]},l.title))})]}),e.jsx("span",{style:{textAlign:"center"},children:e.jsx(z,{startIcon:e.jsx(xo,{}),"aria-label":"Download instance statistics",color:"primary",variant:"contained",target:"_blank",rel:"noreferrer",href:ne("/api/admin/instance-admin/statistics/csv"),children:"Download"})})]})})},Fc=()=>e.jsx("div",{children:e.jsx(Mc,{})}),Gc=h("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),Wc=h(F)(()=>({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"})),zc=h(F)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),qc=h("p")(({theme:t})=>({display:"table-cell",fontWeight:t.fontWeight.bold,paddingTop:t.spacing(2)})),Hc=h("p")(({theme:t})=>({display:"table-cell",paddingTop:t.spacing(2),paddingLeft:t.spacing(4)})),Vc=h("div")(({theme:t})=>({display:"table-cell",width:"75%",paddingTop:t.spacing(2),paddingBottom:t.spacing(2)})),Yc=h("div")(({theme:t})=>({display:"table-cell"})),Jc=h("span")(({theme:t})=>({display:"block",textAlign:"right",color:t.palette.neutral.dark})),Kc=h("div")(({theme:t})=>({maxWidth:t.spacing(50),color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody})),Zc=h("div")(()=>({display:"table-row"})),gn=h("div")(()=>({display:"table"})),Qc=h("div")(()=>({display:"table-cell"})),Xc=({changeInfoText:t,variablesText:s,dependsOnText:n})=>e.jsxs(Kc,{children:[e.jsx(jn,{children:t}),e.jsx(ed,{children:e.jsx("div",{children:s})}),e.jsx(w,{condition:!!n,show:e.jsx(jn,{children:n})})]}),ed=h("code")(({theme:t})=>({display:"block",color:t.palette.text.primary,backgroundColor:t.palette.background.application,fontSize:t.fontSizes.smallerBody,marginTop:t.spacing(1),padding:t.spacing(1),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadius,borderWidth:1,wordWrap:"break-word",whiteSpace:"pre-wrap",fontFamily:"monospace",lineHeight:1.5})),jn=h("p")(({theme:t})=>({color:t.palette.text.primary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1)})),fn=({title:t,infoText:s,concreteDetails:n,enabled:o,changeInfoText:a,variablesText:i,dependsOnText:r})=>e.jsxs(Gc,{children:[e.jsxs(Wc,{children:[e.jsx("b",{children:t}),e.jsx(Yc,{children:e.jsx(w,{condition:o,show:e.jsx(xt,{color:"success",icon:e.jsx(Rs,{}),children:"Data is collected"}),elseShow:e.jsx(xt,{color:"neutral",icon:e.jsx(ui,{}),children:"No data is collected"})})})]}),e.jsxs(zc,{children:[e.jsxs(gn,{children:[e.jsx(Vc,{children:s}),e.jsx(Qc,{children:e.jsx(Jc,{children:e.jsx(Wt,{tooltip:e.jsx(Xc,{changeInfoText:a,variablesText:i,dependsOnText:r}),children:o?"How to disable collecting data?":"How to enable collecting data?"})})})]}),e.jsx(gn,{children:Object.entries(n).map(([c,l])=>e.jsxs(Zc,{children:[e.jsx(qc,{children:c}),e.jsx(Hc,{children:l})]},c))})]})]}),td=()=>{const{data:t,error:s,mutate:n}=Ee(ne("api/admin/telemetry/settings"),sd);return u.useMemo(()=>({settings:t,loading:!s&&!t,refetchGroup:()=>n(),error:s}),[t,s,n])},sd=t=>fetch(t).then(ue("Telemetry Settings")).then(s=>s.json()),nd=h(F)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),ms={title:"Version data collection",infoText:"We collect the version of Unleash that you're using. We use this information to inform your Unleash instance of latest updates and critical security patches.",concreteDetails:{"Instance ID":"A unique ID generated for your instance",Version:"The version of Unleash that you're using"}},xs={title:"Feature data collection",infoText:"We collect data about your instance to improve the Unleash product user experience. We may also use the data in case you need help from our support team. Data collection is for internal use only and is not shared with third parties outside Unleash. As we want you to be in control of your data, we will leave it up to you to allow us to collect your data.",concreteDetails:{"Feature flags":"The number of feature flags in your instance",Users:"The number of users registered in your instance",Projects:"The number of projects in your instance","Context Fields":"The number of custom context fields in use",Groups:"The number of groups present in your instance",Roles:"The number of custom roles defined in your instance","Custom Root Roles":"The number of custom root roles defined in your instance","Custom Root Roles In Use":"The number of custom root roles that are in use by entities (users, groups, service accounts)",Environments:"The number of environments in your instance",Segments:"The number of segments defined in your instance",Strategies:"The number of strategies defined in your instance","Feature Exports":"The number of feature exports performed","Feature Imports":"The number of feature imports performed","Custom Strategies":"The number of custom strategies defined in your instance","Custom Strategies In Use":"The number of custom strategies that are in use by feature flags"}},yn={enabled:{environmentVariables:"CHECK_VERSION=false",changeInfoText:"Version info collection can be disabled by setting the environment variable `CHECK_VERSION` to `false` and restarting Unleash."},disabled:{environmentVariables:"CHECK_VERSION=true",changeInfoText:"Version info collection can be enabled by setting the environment variable to true and restarting Unleash."}},bn={enabled:{environmentVariables:"SEND_TELEMETRY=false",changeInfoText:"Feature usage collection can be disabled by setting the environment variable to false and restarting Unleash."},disabled:{environmentVariables:"SEND_TELEMETRY=true",changeInfoText:"To enable feature usage collection set the environment variable to true and restart Unleash."}},od=()=>{const{settings:t}=td(),{loading:s}=q();if(s)return null;const n=t!=null&&t.versionInfoCollectionEnabled?yn.enabled:yn.disabled,o=t!=null&&t.featureInfoCollectionEnabled?bn.enabled:bn.disabled;let a;return t!=null&&t.versionInfoCollectionEnabled||(a=t!=null&&t.featureInfoCollectionEnabled?"Note: Feature usage collection is enabled, but for it to be active you must also enable version info collection":"When you enable feature usage collection you must also enable version info collection"),e.jsx(te,{header:e.jsx(se,{title:"Instance Privacy"}),children:e.jsxs(nd,{children:[e.jsx(fn,{title:ms.title,infoText:ms.infoText,concreteDetails:ms.concreteDetails,enabled:t==null?void 0:t.versionInfoCollectionEnabled,changeInfoText:n.changeInfoText,variablesText:n.environmentVariables}),e.jsx(fn,{title:xs.title,infoText:xs.infoText,concreteDetails:xs.concreteDetails,enabled:(t==null?void 0:t.featureInfoCollectionEnabled)&&(t==null?void 0:t.versionInfoCollectionEnabled),changeInfoText:o.changeInfoText,variablesText:o.environmentVariables,dependsOnText:a})]})})},ad=()=>e.jsx(J,{severity:"warning",children:e.jsxs("p",{children:[e.jsx("b",{children:"Heads up!"})," If you enable maintenance mode, edit access in the entire system will be disabled for all the users (admins, editors, custom roles, etc). During this time nobody will be able to do changes or to make new configurations."]})}),id=()=>{const{data:t,error:s,mutate:n}=Ee(ne("api/admin/maintenance"),rd);return u.useMemo(()=>({enabled:!!(t!=null&&t.enabled),loading:!s&&!t,refetchMaintenance:n,error:s}),[t,s,n])},rd=t=>fetch(t).then(ue("Maintenance")).then(s=>s.json()),ld=()=>{const{makeRequest:t,createRequest:s,errors:n,loading:o}=xe({propagateErrors:!0});return{toggleMaintenance:async i=>{const c=s("api/admin/maintenance",{method:"POST",body:JSON.stringify(i)});await t(c.caller,c.id)},errors:n,loading:o}},cd=h("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),dd=h(F)({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"}),ud=h(F)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),hd=h(R)(({theme:t})=>({fontSize:t.fontSizes.smallBody})),pd=()=>{const{enabled:t,refetchMaintenance:s}=id(),{refetch:n}=q(),{toggleMaintenance:o}=ld(),{trackEvent:a}=Us(),{setToastData:i}=K(),r=async()=>{i({type:"success",text:`Maintenance mode has been successfully ${t?"disabled":"enabled"}`}),a("maintenance",{props:{eventType:`maintenance ${t?"de":""}activated`}}),await o({enabled:!t}),s(),n()};return e.jsxs(cd,{children:[e.jsxs(dd,{children:[e.jsx("b",{children:"Maintenance Mode"}),e.jsx(re,{sx:{margin:0},control:e.jsx(ge,{onChange:r,value:t,name:"enabled",checked:t}),label:e.jsx(hd,{children:t?"Enabled":"Disabled"})})]}),e.jsx(ud,{children:"Maintenance Mode is useful when you want to freeze your system so nobody can do any changes during this time. When enabled it will show a banner at the top of the applications and only an admin can enable it or disable it."})]})},md=()=>e.jsx("div",{children:e.jsx(ve,{permissions:[ee,hi],children:e.jsx(gd,{})})}),xd=h(F)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),gd=()=>{const{loading:t}=q();return t?null:e.jsx(te,{header:e.jsx(se,{title:"Maintenance"}),children:e.jsxs(xd,{children:[e.jsx(ad,{}),e.jsx(pd,{})]})})},jd=h(ae)(({theme:t})=>({display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",textDecoration:"none",color:"inherit",padding:t.spacing(0,5),"&.active":{fontWeight:"bold"}})),ta=({to:t,children:s})=>e.jsx(jd,{to:t,children:s}),fd=u.lazy(()=>ot(()=>import("./NetworkOverview-_igGCPCJ.js"),[])),yd=u.lazy(()=>ot(()=>import("./NetworkConnectedEdges-HU923-QZ.js"),[])),bd=u.lazy(()=>ot(()=>import("./NetworkTraffic-BpNEMFBl.js"),[])),Sd=u.lazy(()=>ot(()=>import("./NetworkTrafficUsage-bSUVPjoc.js"),[])),vd=u.lazy(()=>ot(()=>import("./BackendConnections-C9HcQ9To.js"),[])),Cd=u.lazy(()=>ot(()=>import("./FrontendNetworkTrafficUsage-E4pIeMFQ.js"),[])),Sn=[{label:"Overview",path:"/admin/network"},{label:"Traffic",path:"/admin/network/traffic"},{label:"Connected Edges",path:"/admin/network/connected-edges"}],wd=[{label:"Data Usage",path:"/admin/network/data-usage"}],Td=[{label:"Backend Connections",path:"/admin/network/backend-connections"},{label:"Frontend Traffic",path:"/admin/network/frontend-data-usage"}],kd=()=>{const{pathname:t}=Es(),s=Pt("edgeObservability"),a=(Pt("consumptionModelUI")?[...Sn,...Td]:[...Sn,...wd]).filter(({label:i})=>i!=="Connected Edges"||s);return e.jsx("div",{children:e.jsx(te,{withTabs:!0,header:e.jsx(go,{value:t,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:a.map(({label:i,path:r})=>e.jsx(jo,{value:r,label:e.jsx(ta,{to:r,children:e.jsx("span",{children:i})}),sx:{padding:0}},i))}),children:e.jsxs(tt,{children:[e.jsx(_,{path:"*",element:e.jsx(fd,{})}),e.jsx(_,{path:"traffic",element:e.jsx(bd,{})}),s&&e.jsx(_,{path:"connected-edges",element:e.jsx(yd,{})}),e.jsx(_,{path:"data-usage",element:e.jsx(Sd,{})}),e.jsx(_,{path:"backend-connections",element:e.jsx(vd,{})}),e.jsx(_,{path:"frontend-data-usage",element:e.jsx(Cd,{})})]})})})},Ed=h(F)(()=>({display:"flex",justifyContent:"center"})),Rd=({role:t,onEdit:s,onDelete:n})=>{const o=Me.includes(t.type);return e.jsxs(Ed,{children:[e.jsx(Le,{"data-loading":!0,onClick:s,permission:ee,disabled:o,tooltipProps:{title:o?"You cannot edit a predefined role":"Edit role"},children:e.jsx(ft,{})}),e.jsx(Le,{"data-loading":!0,onClick:n,permission:ee,disabled:o,tooltipProps:{title:o?"You cannot remove a predefined role":"Remove role"},children:e.jsx(Pe,{})})]})},Dd=h(xt)(({theme:t})=>({marginLeft:t.spacing(1)})),Ad=({role:t})=>e.jsx(Se,{value:t.name,subtitle:t.description,afterTitle:e.jsx(w,{condition:Me.includes(t.type),show:e.jsx(Dd,{color:"success",children:"Predefined"})})}),Id=({users:t})=>{const[s]=u.useState(()=>({sortBy:[{id:"last-login",desc:!0}]})),n=u.useMemo(()=>[{id:"name",Header:"Name",accessor:r=>r.name||"",minWidth:200,Cell:({row:{original:r}})=>e.jsx(Se,{value:r.name,subtitle:r.email||r.username})},{Header:"Created",accessor:"createdAt",Cell:je,width:120,maxWidth:120},{id:"last-login",Header:"Last login",accessor:"seenAt",Cell:$e,maxWidth:150}],[]),{headerGroups:o,rows:a,prepareRow:i}=G.useTable({columns:n,data:t,initialState:s,sortTypes:fe,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},G.useSortBy,G.useFlexLayout);return e.jsx(ye,{rows:a,headerGroups:o,prepareRow:i})},Pd=h(R)(({theme:t})=>({fontSize:t.fontSizes.smallerBody})),sa=({serviceAccount:t,value:s,onCreateToken:n})=>{var a,i,r;const{searchQuery:o}=Is();return!t.tokens||t.tokens.length===0?n?e.jsx(fo,{title:"Create token",onClick:n}):e.jsx(oe,{children:"0 tokens"}):e.jsx(oe,{children:e.jsx(Wt,{tooltip:e.jsx(e.Fragment,{children:(a=t.tokens)==null?void 0:a.map(({id:c,description:l})=>e.jsx(Pd,{children:e.jsx(Bt,{search:o,children:l})},c))}),highlighted:o.length>0&&s.toLowerCase().includes(o.toLowerCase()),children:((i=t.tokens)==null?void 0:i.length)===1?"1 token":`${(r=t.tokens)==null?void 0:r.length} tokens`})})},Bd=({serviceAccounts:t})=>{const[s]=u.useState(()=>({sortBy:[{id:"seenAt",desc:!0}]})),n=u.useMemo(()=>[{id:"name",Header:"Name",accessor:r=>r.name||"",minWidth:200,Cell:({row:{original:r}})=>e.jsx(Se,{value:r.name,subtitle:r.username})},{id:"tokens",Header:"Tokens",accessor:r=>{var c;return((c=r.tokens)==null?void 0:c.map(({description:l})=>l).join(`
16
16
  `))||""},Cell:({row:{original:r},value:c})=>e.jsx(sa,{serviceAccount:r,value:c}),maxWidth:100},{Header:"Created",accessor:"createdAt",Cell:je,width:120,maxWidth:120},{id:"seenAt",Header:"Last seen",accessor:r=>{var c;return(c=r.tokens.sort((l,m)=>{const p=new Date(l.seenAt||0),d=new Date(m.seenAt||0);return(d==null?void 0:d.getTime())-(p==null?void 0:p.getTime())})[0])==null?void 0:c.seenAt},Cell:$e,maxWidth:150}],[]),{headerGroups:o,rows:a,prepareRow:i}=G.useTable({columns:n,data:t,initialState:s,sortTypes:fe,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},G.useSortBy,G.useFlexLayout);return e.jsx(ye,{rows:a,headerGroups:o,prepareRow:i})},Ld=({groups:t})=>{const[s]=u.useState(()=>({sortBy:[{id:"createdAt",desc:!0}]})),n=u.useMemo(()=>[{id:"name",Header:"Name",accessor:r=>r.name||"",minWidth:200,Cell:({row:{original:r}})=>e.jsx(Se,{value:r.name,subtitle:r.description})},{Header:"Created",accessor:"createdAt",Cell:je,width:120,maxWidth:120},{id:"users",Header:"Users",accessor:r=>r.users.length===1?"1 user":`${r.users.length} users`,Cell:oe,maxWidth:150}],[]),{headerGroups:o,rows:a,prepareRow:i}=G.useTable({columns:n,data:t,initialState:s,sortTypes:fe,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},G.useSortBy,G.useFlexLayout);return e.jsx(ye,{rows:a,headerGroups:o,prepareRow:i})},gs=h("div")(({theme:t})=>({marginTop:t.spacing(1.5)})),js=h("p")(({theme:t})=>({marginTop:t.spacing(3)})),Ud=({role:t,open:s,setOpen:n,onConfirm:o})=>{const{users:a}=be(),{serviceAccounts:i}=St(),{groups:r}=Ge(),c=a.filter(({rootRole:d})=>d===(t==null?void 0:t.id)),l=i.filter(({rootRole:d})=>d===(t==null?void 0:t.id)),m=r==null?void 0:r.filter(({rootRole:d})=>d===(t==null?void 0:t.id)),p=!!(c.length||l.length||m!=null&&m.length);return e.jsx(Q,{title:"Delete root role?",open:s,primaryButtonText:"Delete role",secondaryButtonText:"Cancel",disabledPrimaryButton:p,onClick:()=>o(t),onClose:()=>{n(!1)},children:e.jsx(w,{condition:p,show:e.jsxs(e.Fragment,{children:[e.jsx(J,{severity:"error",children:"You are not allowed to delete a role that is currently in use. Please change the role of the following entities first:"}),e.jsx(w,{condition:!!c.length,show:e.jsxs(e.Fragment,{children:[e.jsxs(js,{children:["Users (",c.length,"):"]}),e.jsx(gs,{children:e.jsx(Id,{users:c})})]})}),e.jsx(w,{condition:!!l.length,show:e.jsxs(e.Fragment,{children:[e.jsxs(js,{children:["Service accounts (",l.length,"):"]}),e.jsx(gs,{children:e.jsx(Bd,{serviceAccounts:l})})]})}),e.jsx(w,{condition:!!(m!=null&&m.length),show:e.jsxs(e.Fragment,{children:[e.jsxs(js,{children:["Groups (",m==null?void 0:m.length,"):"]}),e.jsx(gs,{children:e.jsx(Ld,{groups:m})})]})})]}),elseShow:e.jsxs("p",{children:["You are about to delete role:"," ",e.jsx("strong",{children:t==null?void 0:t.name})]})})})},Od=t=>{const{isEnterprise:s}=q(),{data:n,error:o,mutate:a}=_t(s()&&t,{projects:[]},ne(`api/admin/projects/roles/${t}/access`),$d);return u.useMemo(()=>({projects:(n==null?void 0:n.projects)??[],loading:!o&&!n,refetch:()=>a(),error:o}),[n,o,a])},$d=t=>fetch(t).then(ue("Project role usage")).then(s=>s.json()),_d=({projects:t})=>{const[s]=u.useState(()=>({sortBy:[{id:"name"}]})),n=u.useMemo(()=>[{id:"name",Header:"Project name",accessor:r=>r.project||"",minWidth:200,Cell:({row:{original:r}})=>e.jsx(fo,{title:r.project,to:`/projects/${r.project}`})},{id:"users",Header:"Assigned users",accessor:r=>r.userCount===1?"1 user":`${r.userCount} users`,Cell:oe,maxWidth:150},{id:"serviceAccounts",Header:"Service accounts",accessor:r=>r.serviceAccountCount===1?"1 account":`${r.serviceAccountCount} accounts`,Cell:oe,maxWidth:150},{id:"groups",Header:"Assigned groups",accessor:r=>r.groupCount===1?"1 group":`${r.groupCount} groups`,Cell:oe,maxWidth:150}],[]),{headerGroups:o,rows:a,prepareRow:i}=G.useTable({columns:n,data:t,initialState:s,sortTypes:fe,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},G.useSortBy,G.useFlexLayout);return e.jsx(ye,{rows:a,headerGroups:o,prepareRow:i})},Nd=h("div")(({theme:t})=>({marginTop:t.spacing(1.5)})),Md=h("p")(({theme:t})=>({marginTop:t.spacing(3)})),Fd=({role:t,open:s,setOpen:n,onConfirm:o})=>{const{projects:a}=Od(t==null?void 0:t.id),i=!!(a!=null&&a.length);return e.jsx(Q,{title:"Delete project role?",open:s,primaryButtonText:"Delete role",secondaryButtonText:"Cancel",disabledPrimaryButton:i,onClick:()=>o(t),onClose:()=>{n(!1)},maxWidth:"md",children:e.jsx(w,{condition:i,show:e.jsxs(e.Fragment,{children:[e.jsx(J,{severity:"error",children:"You are not allowed to delete a role that is currently in use. Please change the role of the following entities first:"}),e.jsx(w,{condition:!!(a!=null&&a.length),show:e.jsxs(e.Fragment,{children:[e.jsxs(Md,{children:["Role assigned in ",a==null?void 0:a.length," ","projects:"]}),e.jsx(Nd,{children:e.jsx(_d,{projects:a})})]})})]}),elseShow:e.jsxs("p",{children:["You are about to delete role:"," ",e.jsx("strong",{children:t==null?void 0:t.name})]})})})},Gd="custom",Wd=({role:t,open:s,setOpen:n,onConfirm:o})=>(t==null?void 0:t.type)===Gd?e.jsx(Fd,{role:t,open:s,setOpen:n,onConfirm:o}):e.jsx(Ud,{role:t,open:s,setOpen:n,onConfirm:o}),na=()=>{const{loading:t,makeRequest:s,createRequest:n,errors:o}=xe({propagateErrors:!0});return{addRole:async l=>{const p=n("api/admin/roles",{method:"POST",body:JSON.stringify(l)},"addRole");return(await s(p.caller,p.id)).json()},updateRole:async(l,m)=>{const d=n(`api/admin/roles/${l}`,{method:"PUT",body:JSON.stringify(m)},"updateRole");await s(d.caller,d.id)},removeRole:async l=>{const p=n(`api/admin/roles/${l}`,{method:"DELETE"},"removeRole");await s(p.caller,p.id)},validateRole:async l=>{const p=n("api/admin/roles/validate",{method:"POST",body:JSON.stringify(l)},"validateRole");await s(p.caller,p.id)},errors:o,loading:t}},vn={name:void 0,description:void 0,permissions:void 0},zd=(t="",s="",n=[])=>{const{roles:o,projectRoles:a}=vt(),[i,r]=u.useState(t),c=T=>r(T.trim()),[l,m]=u.useState(s),[p,d]=u.useState({}),[g,x]=u.useState(vn),[j,b]=u.useState(!1);u.useEffect(()=>{r(t)},[t]),u.useEffect(()=>{m(s)},[s]),u.useEffect(()=>{const T=Xs(n);d(T)},[n.length]);const y=(T=Ue)=>({name:i,description:l,type:T===Ue?"root-custom":"custom",permissions:Object.values(p).map(({name:A,environment:B})=>({name:A,environment:B}))}),S=T=>![...o,...a].some(A=>A.name!==t&&A.name.toLowerCase()===T.toLowerCase()),k=T=>T.length,E=T=>Object.keys(T).length>0,D=T=>{x(A=>({...A,[T]:void 0}))},v=(T,A)=>{x(B=>({...B,[T]:A}))},P=T=>{const A=T.trim();return k(A)?S(A)?(D("name"),!0):(v("name","Name must be unique."),!1):(v("name","Name is required."),!1)},L=T=>{const A=T.trim();return k(A)?(D("description"),!0):(v("description","Description is required."),!1)},C=T=>E(T)?(D("permissions"),!0):(v("permissions","You must select at least one permission."),!1),W=()=>{const T=P(i),A=L(l),B=C(p);return b(!0),T&&A&&B},I=j&&Object.values(g).some(Boolean);return{name:i,setName:c,validateName:P,description:l,setDescription:m,validateDescription:L,checkedPermissions:p,setCheckedPermissions:d,validatePermissions:C,getRolePayload:y,errors:g,showErrors:I,validate:W,reload:()=>{r(t),m(s),d(Xs(n)),b(!1),x(vn)}}};var zs={},qd=Gt;Object.defineProperty(zs,"__esModule",{value:!0});var oa=zs.default=void 0,Hd=qd(Ft()),Vd=e,Yd=(0,Hd.default)((0,Vd.jsx)("path",{d:"M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-6 10H6v-2h8v2zm4-4H6v-2h12v2z"}),"Topic");oa=zs.default=Yd;const Jd=({permissions:t,checkedPermissions:s,onPermissionChange:n})=>e.jsx(F,{display:"grid",gridTemplateColumns:{sm:"1fr 1fr",xs:"1fr"},children:t==null?void 0:t.map(o=>e.jsx(re,{"data-testid":Qe(o),control:e.jsx(zt,{checked:!!s[Qe(o)],onChange:()=>n(o),color:"primary"}),label:o.displayName},Qe(o)))}),aa=t=>{const s=(t==null?void 0:t.map(i=>Qe(i)).sort())||[],n=en.flatMap(i=>i.permissions.map(([r])=>r)).sort(),o=s.filter(i=>!n.includes(i));return[...en,{label:"Other",permissions:o.map(i=>[i])}].map(i=>({label:i.label,permissions:i.permissions.filter(([r])=>s.includes(r)).map(([r,c])=>[t.find(l=>Qe(l)===r),c])})).filter(i=>i.permissions.length>0)},Kd=({permission:t,onChange:s,isChecked:n,hasParentPermission:o,isParentPermissionChecked:a})=>e.jsx(F,{sx:i=>({marginLeft:o?i.spacing(1.5):0}),children:e.jsx(re,{"data-testid":t,control:e.jsx(zt,{checked:!!(n||a),onChange:s,color:"primary",disabled:a}),label:t.displayName},t.name)}),Zd=h("div")(({theme:t})=>({display:"grid",gridTemplateColumns:"1fr 1fr",gap:t.spacing(1),[t.breakpoints.down("md")]:{gridTemplateColumns:"1fr"}})),Qd=h(R)(({theme:t})=>({fontWeight:t.typography.fontWeightBold,marginTop:t.spacing(2),marginBottom:t.spacing(1)})),Xd=({permissions:t,checkedPermissions:s,onPermissionChange:n})=>{const o=u.useMemo(()=>aa(t),[t]);return e.jsx(Zd,{children:o.map(a=>e.jsxs("div",{children:[e.jsx(Qd,{children:a.label}),e.jsx("div",{children:a.permissions.map(([i,r])=>e.jsx(Kd,{permission:i,onChange:()=>n(i),isChecked:!!s[i.name],hasParentPermission:!!r,isParentPermissionChecked:!!(r&&s[r])}))})]}))})},eu=h(F)(({theme:t})=>({display:"flex",alignItems:"center",[t.breakpoints.down(500)]:{flexDirection:"column",alignItems:"flex-start"}})),tu=h(pi)(({theme:t})=>({fontWeight:t.typography.fontWeightBold,marginRight:t.spacing(1)})),su=({title:t,permissions:s,checkedPermissions:n,Icon:o,isInitiallyExpanded:a=!1,context:i,children:r,onCheckAll:c})=>{const[l,m]=u.useState(a),p=u.useMemo(()=>(s==null?void 0:s.reduce((x,j)=>(x[Qe(j)]=!0,x),{}))||{},[s]),d=u.useMemo(()=>Object.keys(n).filter(x=>p[x]).length||0,[n,p]),g=u.useMemo(()=>d===(s==null?void 0:s.length),[d,s]);return e.jsx(F,{sx:{my:2,pb:1},children:e.jsxs(yo,{expanded:l,onChange:()=>m(!l),sx:{boxShadow:"none",px:3,py:1,border:x=>`1px solid ${x.palette.divider}`,borderRadius:x=>`${x.shape.borderRadiusLarge}px`},children:[e.jsx(bo,{expandIcon:e.jsx(Oe,{children:e.jsx(So,{titleAccess:"Toggle"})}),sx:{boxShadow:"none",padding:"0"},children:e.jsxs(eu,{children:[o,e.jsx(tu,{text:t,maxWidth:"120",maxLength:25})," ",e.jsxs(R,{variant:"body2",color:"text.secondary",children:["(",d," / ",s==null?void 0:s.length," ","permissions)"]})]})}),e.jsxs(vo,{sx:{px:0,py:1,flexWrap:"wrap"},children:[e.jsx(Mt,{sx:{mb:1}}),e.jsxs(z,{variant:"text",size:"small",onClick:c,sx:{fontWeight:x=>x.typography.fontWeightRegular},children:[g?"Unselect ":"Select ","all ",i," permissions"]}),r]})]})})},nu=({type:t,checkedPermissions:s,setCheckedPermissions:n,validatePermissions:o})=>{const{permissions:a}=mi({revalidateIfStale:!1,revalidateOnReconnect:!1,revalidateOnFocus:!1}),i=Kn.includes(t),r=u.useMemo(()=>i?Co(xi(a.project,a.environments)):wo(a.root),[a,i]),c=m=>{const p=bi(s,m);o(p),n(p)},l=m=>{const p=Si(s,m);o(p),n(p)};return u.useMemo(()=>e.jsx(e.Fragment,{children:r.map(({label:m,type:p,permissions:d})=>e.jsx(su,{title:m,context:m.toLowerCase(),Icon:p===gi?e.jsx(oa,{color:"disabled",sx:{mr:1}}):p===ji?e.jsx(fi,{color:"disabled",sx:{mr:1}}):e.jsx(yi,{color:"disabled",sx:{mr:1}}),permissions:d,checkedPermissions:s,onCheckAll:()=>l(d),children:p==="project"?e.jsx(Xd,{permissions:d,checkedPermissions:s,onPermissionChange:c}):e.jsx(Jd,{permissions:d,checkedPermissions:s,onPermissionChange:c})},m))}),[r,s])},fs=h("p")(({theme:t})=>({display:"flex",color:t.palette.text.primary,marginBottom:t.spacing(1),"&:not(:first-of-type)":{marginTop:t.spacing(4)}})),ou=h(ze)(({theme:t})=>({width:"100%",maxWidth:t.spacing(50)})),au=h(ze)({width:"100%"}),iu=({type:t=Ue,name:s,setName:n,description:o,setDescription:a,checkedPermissions:i,setCheckedPermissions:r,errors:c,showErrors:l,validateName:m,validateDescription:p,validatePermissions:d})=>{const g=x=>{setTimeout(()=>x(),300)};return e.jsxs("div",{children:[e.jsx(fs,{children:"What is your new role name?"}),e.jsx(ou,{autoFocus:!0,label:"Role name *",error:!!c.name,errorText:c.name,value:s,onChange:x=>{m(x.target.value),n(x.target.value)},onBlur:x=>g(()=>m(x.target.value)),autoComplete:"off"}),e.jsx(fs,{children:"What is your new role description?"}),e.jsx(au,{label:"Role description *",error:!!c.description,errorText:c.description,value:o,onChange:x=>{p(x.target.value),a(x.target.value)},onBlur:x=>g(()=>p(x.target.value)),autoComplete:"off"}),e.jsx(fs,{children:"What is your role allowed to do?"}),e.jsx(J,{severity:"info",children:"You must select at least one permission."}),e.jsx(nu,{type:t,checkedPermissions:i,setCheckedPermissions:r,validatePermissions:d}),e.jsx(w,{condition:l,show:()=>e.jsx(J,{severity:"error",icon:!1,children:e.jsx("ul",{children:Object.values(c).filter(Boolean).map(x=>e.jsx("li",{children:x},x))})})})]})},ru=h("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),lu=h("div")(({theme:t})=>({marginTop:"auto",display:"flex",justifyContent:"flex-end",paddingTop:t.spacing(4)})),cu=h(z)(({theme:t})=>({marginLeft:t.spacing(3)})),du=({type:t=Ue,roleId:s,open:n,setOpen:o})=>{const{role:a,refetch:i}=To(s==null?void 0:s.toString()),{name:r,setName:c,validateName:l,description:m,setDescription:p,validateDescription:d,checkedPermissions:g,setCheckedPermissions:x,validatePermissions:j,getRolePayload:b,errors:y,showErrors:S,validate:k,reload:E}=zd(a==null?void 0:a.name,a==null?void 0:a.description,a==null?void 0:a.permissions),{refetch:D}=vt(),{addRole:v,updateRole:P,loading:L}=na(),{setToastData:C,setToastApiError:W}=K(),{uiConfig:I}=q(),U=a!==void 0,T=b(t),A=()=>`curl --location --request ${U?"PUT":"POST"} '${I.unleashUrl}/api/admin/roles${U?`/${a.id}`:""}' \\
17
17
  --header 'Authorization: INSERT_API_KEY' \\
18
18
  --header 'Content-Type: application/json' \\