unleash-server 7.6.2 → 7.6.3

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 (35) hide show
  1. package/dist/lib/types/experimental.d.ts +1 -1
  2. package/dist/lib/types/experimental.d.ts.map +1 -1
  3. package/dist/lib/types/experimental.js +1 -0
  4. package/dist/lib/types/experimental.js.map +1 -1
  5. package/frontend/build/index.html +1 -1
  6. package/frontend/build/static/{AdvancedPlayground-BTPrG6RW.js → AdvancedPlayground-D7wyJyhf.js} +1 -1
  7. package/frontend/build/static/{BackendConnections-CRh8Vxoe.js → BackendConnections-B2fwWxNM.js} +1 -1
  8. package/frontend/build/static/{CreateProject-DEMalH1j.js → CreateProject-DCsDw61O.js} +1 -1
  9. package/frontend/build/static/{EnterpriseEdge-Cp-pGMa0.js → EnterpriseEdge-Bzf3ZWSM.js} +1 -1
  10. package/frontend/build/static/{FeatureMetricsChart-DQOE71LA.js → FeatureMetricsChart-CA7ccj4F.js} +1 -1
  11. package/frontend/build/static/{FeatureStaleDialog-B6BfnDiQ.js → FeatureStaleDialog-DFGtgX-I.js} +1 -1
  12. package/frontend/build/static/{FeatureViewLazyExport-BkNTNFqK.js → FeatureViewLazyExport-CVIpdGgg.js} +3 -3
  13. package/frontend/build/static/{FlagMetricsChart-zYDF9bet.js → FlagMetricsChart-Dcc3RwL2.js} +1 -1
  14. package/frontend/build/static/{FrontendNetworkTrafficUsage-CbxdFXH7.js → FrontendNetworkTrafficUsage-C6ZZ-igE.js} +1 -1
  15. package/frontend/build/static/{GridLayoutWrapper-Cq6Bzm36.js → GridLayoutWrapper-mu3C2OC4.js} +1 -1
  16. package/frontend/build/static/{ImpactMetricsPage-CFYXYXPb.js → ImpactMetricsPage-DQ3DugFo.js} +1 -1
  17. package/frontend/build/static/{LazyAdminExport-ByTh4iFa.js → LazyAdminExport-CEik6N0e.js} +3 -3
  18. package/frontend/build/static/{LazyProjectExport-K12Xy3w9.js → LazyProjectExport-C8B0wkkW.js} +2 -2
  19. package/frontend/build/static/{LifecycleChartComponent-DHvlFNd2.js → LifecycleChartComponent-DgMY7X0Z.js} +1 -1
  20. package/frontend/build/static/{LineChartComponent-BlhKm3cw.js → LineChartComponent-FVKRZKUW.js} +1 -1
  21. package/frontend/build/static/{MarkCompletedDialogue-apmlFjVY.js → MarkCompletedDialogue-BFMzJ-VW.js} +1 -1
  22. package/frontend/build/static/{NetworkOverview-BiLOuQ4c.js → NetworkOverview-D8wtNaRF.js} +1 -1
  23. package/frontend/build/static/{NetworkPrometheusAPIWarning-CYo3j2Tj.js → NetworkPrometheusAPIWarning-D5-OGJsP.js} +1 -1
  24. package/frontend/build/static/{NetworkTraffic-DONL5oIx.js → NetworkTraffic-3cnRG5P0.js} +1 -1
  25. package/frontend/build/static/{NetworkTrafficUsage-DjQiYq0S.js → NetworkTrafficUsage-CSiuPn9W.js} +1 -1
  26. package/frontend/build/static/{PercentageDonut-CA9hYg3v.js → PercentageDonut-C51wuJjA.js} +1 -1
  27. package/frontend/build/static/{ReactJSONEditor-9cJL1vJY.js → ReactJSONEditor-BFCTTSFc.js} +1 -1
  28. package/frontend/build/static/{RoleCell-ZzU5Oqy8.js → RoleCell-CIeC6DEg.js} +1 -1
  29. package/frontend/build/static/{Safeguard-DY1N4aPz.js → Safeguard-C9U0j0cL.js} +1 -1
  30. package/frontend/build/static/{aggregateFeatureMetrics-D6bHft_C.js → aggregateFeatureMetrics-B-7cFh4G.js} +1 -1
  31. package/frontend/build/static/{formatTickValue-BcLsqREh.js → formatTickValue-CaA_jBqg.js} +1 -1
  32. package/frontend/build/static/{index-CoLhlfXP.js → index-C0tV9tYB.js} +10 -10
  33. package/frontend/build/static/{networkTrafficUsageHighlightPlugin-CqEM-cK_.js → networkTrafficUsageHighlightPlugin-D5DxaVbe.js} +1 -1
  34. package/frontend/build/static/{useApiTokens-ClWvohC9.js → useApiTokens-DDEZMbRy.js} +1 -1
  35. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{dE as So,j as e,dF as Se,dG as xn,dH as mn,dI as Pe,az as ne,aC as oe,at as ue,dJ as vo,dK as Co,dL as si,dM as ni,dN as Kt,dO as oi,v as wo,dP as ai,f as Y,b9 as W,bq as we,r as u,cz as Zt,bG as Ae,dQ as To,dR as Be,dS as Gs,h as G,s as d,bM as ii,A as ko,l as se,C as k,dT as Eo,b7 as Qt,b6 as X,dU as Ao,dV as ri,b8 as le,dW as ze,de as f,dX as re,dY as xe,dZ as Xt,u as pe,d_ as ot,Q as V,d$ as li,e0 as Ro,aX as Me,i as N,aU as ee,T,e1 as Do,cp as ve,L as ae,B as _,cg as Ht,d5 as zs,e2 as at,e3 as ci,cC as it,cD as M,e4 as Hs,e5 as Ke,e6 as Vs,aA as Fe,D as rt,e7 as Et,e8 as Io,e9 as Po,ea as di,eb as ui,ec as es,d as Ys,ed as pi,ee as Js,ef as Lo,K as Le,eg as Bo,a9 as F,ah as te,aa as fe,eh as me,ab as hi,ac as gi,ad as Ks,ae as kt,af as xi,av as ce,x as Re,ei as mi,ba as ji,E as lt,F as ct,dz as tt,bm as ts,co as ss,ej as fi,cn as ns,cd as os,aq as At,bg as yi,ao as as,ek as Q,el as bi,em as Si,en as vi,eo as Ci,ep as wi,eq as Ti,bp as Uo,er as $o,es as Oo,et as de,bs as _o,eu as ki,cc as jn,ev as Mo,ew as No,w as Te,aV as Fo,aW as Wo,aY as Cs,aZ as Rt,a_ as Gt,a$ as Ee,J as qo,bj as Ei,b0 as is,ex as Ai,bk as Ri,ey as Zs,b4 as fn,ez as Vt,eA as Di,eB as Ii,eC as Pi,eD as Li,eE as Bi,eF as ws,m as rs,n as Ui,o as $i,eG as We,aj as Ce,am as ye,bz as Go,cE as ls,eH as zo,ap as Ho,ai as je,dd as Ue,au as qe,eI as Qs,eJ as Oi,bf as cs,y as Ze,dq as _i,t as Mi,eK as Ni,eL as Fi,c5 as st,eM as Wi,eN as qi,aN as ds,eO as Xs,b as Dt,eP as Ne,eQ as Gi,as as dt,cX as $e,eR as zi,eS as Hi,eT as Vi,aw as Yi,eU as Ji,cR as yn,eV as Vo,z as Ki,eW as Zi,d6 as Yo,d7 as Jo,ck as ut,ar as Ko,eX as bn,eY as Oe,eZ as nt,e_ as Sn,e$ as Qi,f0 as Xi,f1 as Zo,f2 as er,f3 as Qo,f4 as tr,f5 as sr,cN as nr,f6 as or,f7 as ar,f8 as ir,f9 as Xo,ag as ea,fa as rr,al as It,fb as vn,fc as lr,fd as ta,fe as Yt,ff as sa,fg as cr,cL as en,fh as dr,fi as Cn,fj as us,fk as ur,fl as pr,fm as hr,G as na,b5 as gr,fn as Ts,fo as xr,fp as ps,fq as mr,fr as jr,fs as oa,ft as fr,fu as yr,fv as br,fw as Sr,fx as vr,dm as Cr,dn as wr,fy as Tr,fz as kr,cq as aa,fA as ia,H as ra,fB as la,an as Er,dh as Ar,dl as wn,ax as Rr,fC as ca,fD as da,fE as Dr,fF as Ir,fG as Pr,fH as ua,fI as Lr,fJ as Br,fK as Ur,fL as $r,dD as Or,fM as _r}from"./index-CoLhlfXP.js";import{u as Mr,A as Nr,C as Fr,a as Wr,R as qr,S as Gr,T as zr,b as Hr,c as Vr,d as Yr,e as Jr,E as Kr,f as Zr,m as Qr,g as Pt,h as hs,i as tn}from"./RoleCell-ZzU5Oqy8.js";import{u as gs}from"./useApiTokens-ClWvohC9.js";import{P as Xr}from"./PercentageDonut-CA9hYg3v.js";const el=()=>{const{tokens:t,loading:s,refetch:n}=gs(),{deleteToken:o}=So(),{headerGroups:a,rows:i,prepareRow:r,state:{globalFilter:c},setGlobalFilter:l,setHiddenColumns:g,columns:p}=Mr(t,h=>{const x=h.row.original.type==="client"?xn:h.row.original.type==="frontend"?mn:Pe,m=h.row.original.type==="client"?si:h.row.original.type==="frontend"?ni:Pe;return e.jsxs(Kt,{children:[e.jsx(Wr,{token:h.row.original,permission:x}),e.jsx(qr,{token:h.row.original,permission:m,onRemove:async()=>{await o(h.row.original.secret),n()}})]})});return e.jsx(Se,{permissions:[xn,mn,Pe],children:e.jsx(ne,{header:e.jsx(oe,{title:`API access (${i.length})`,actions:e.jsxs(e.Fragment,{children:[e.jsx(ue,{initialValue:c,onChange:l}),e.jsx(oe.Divider,{}),e.jsx(Fr,{permission:[vo,Co,Pe],path:"/admin/api/create-token"})]})}),children:e.jsx(Nr,{loading:s,headerGroups:a,setHiddenColumns:g,prepareRow:r,rows:i,columns:p,globalFilter:c})})})},tl=({type:t,projects:s,setProjects:n,errors:o,clearErrors:a})=>{const i=oi("projectId"),{projects:r}=wo(),c=r.map(l=>({value:l.id,label:l.name}));return i?null:e.jsxs(e.Fragment,{children:[e.jsx(Gr,{children:"Which project do you want to give access to?"}),e.jsx(ai,{disabled:t===zr.ADMIN,options:c,defaultValue:s,onChange:n,error:o==null?void 0:o.projects,onFocus:()=>a("projects")})]})},Tn="Create API token",sl=d(ii)(({theme:t})=>({margin:t.spacing(2,0,4)})),nl=()=>{const{tokens:t,loading:s}=gs(),{uiConfig:n,loading:o}=W(),a=n.resourceLimits.apiTokens;return{limit:a,currentValue:t.length,limitReached:t.length>=a,loading:o||s}},ol=({modal:t=!1})=>{const{setToastApiError:s}=Y(),{uiConfig:n}=W(),o=we(),[a,i]=u.useState(!1),[r,c]=u.useState(""),{limit:l,currentValue:g,limitReached:p,loading:h}=nl(),{getApiTokenPayload:x,tokenName:m,type:j,projects:b,environment:y,setTokenName:v,setTokenType:A,setProjects:C,setEnvironment:D,isValid:S,errors:U,clearErrors:$,apiTokenTypes:w}=Hr(),{createToken:P,loading:I}=So(),{refetch:L}=gs();Zt(Tn);const R="api/admin/api-tokens",B=async J=>{if(J.preventDefault(),!!S())try{const K=x();await P(K).then(q=>q.json()).then(q=>{Gs(),c(q.secret),i(!0),L()})}catch(K){s(G(K))}},E=()=>{i(!1),o(Be)},O=()=>`curl --location --request POST '${n.unleashUrl}/${R}' \\
1
+ import{dE as So,j as e,dF as Se,dG as xn,dH as mn,dI as Pe,az as ne,aC as oe,at as ue,dJ as vo,dK as Co,dL as si,dM as ni,dN as Kt,dO as oi,v as wo,dP as ai,f as Y,b9 as W,bq as we,r as u,cz as Zt,bG as Ae,dQ as To,dR as Be,dS as Gs,h as G,s as d,bM as ii,A as ko,l as se,C as k,dT as Eo,b7 as Qt,b6 as X,dU as Ao,dV as ri,b8 as le,dW as ze,de as f,dX as re,dY as xe,dZ as Xt,u as pe,d_ as ot,Q as V,d$ as li,e0 as Ro,aX as Me,i as N,aU as ee,T,e1 as Do,cp as ve,L as ae,B as _,cg as Ht,d5 as zs,e2 as at,e3 as ci,cC as it,cD as M,e4 as Hs,e5 as Ke,e6 as Vs,aA as Fe,D as rt,e7 as Et,e8 as Io,e9 as Po,ea as di,eb as ui,ec as es,d as Ys,ed as pi,ee as Js,ef as Lo,K as Le,eg as Bo,a9 as F,ah as te,aa as fe,eh as me,ab as hi,ac as gi,ad as Ks,ae as kt,af as xi,av as ce,x as Re,ei as mi,ba as ji,E as lt,F as ct,dz as tt,bm as ts,co as ss,ej as fi,cn as ns,cd as os,aq as At,bg as yi,ao as as,ek as Q,el as bi,em as Si,en as vi,eo as Ci,ep as wi,eq as Ti,bp as Uo,er as $o,es as Oo,et as de,bs as _o,eu as ki,cc as jn,ev as Mo,ew as No,w as Te,aV as Fo,aW as Wo,aY as Cs,aZ as Rt,a_ as Gt,a$ as Ee,J as qo,bj as Ei,b0 as is,ex as Ai,bk as Ri,ey as Zs,b4 as fn,ez as Vt,eA as Di,eB as Ii,eC as Pi,eD as Li,eE as Bi,eF as ws,m as rs,n as Ui,o as $i,eG as We,aj as Ce,am as ye,bz as Go,cE as ls,eH as zo,ap as Ho,ai as je,dd as Ue,au as qe,eI as Qs,eJ as Oi,bf as cs,y as Ze,dq as _i,t as Mi,eK as Ni,eL as Fi,c5 as st,eM as Wi,eN as qi,aN as ds,eO as Xs,b as Dt,eP as Ne,eQ as Gi,as as dt,cX as $e,eR as zi,eS as Hi,eT as Vi,aw as Yi,eU as Ji,cR as yn,eV as Vo,z as Ki,eW as Zi,d6 as Yo,d7 as Jo,ck as ut,ar as Ko,eX as bn,eY as Oe,eZ as nt,e_ as Sn,e$ as Qi,f0 as Xi,f1 as Zo,f2 as er,f3 as Qo,f4 as tr,f5 as sr,cN as nr,f6 as or,f7 as ar,f8 as ir,f9 as Xo,ag as ea,fa as rr,al as It,fb as vn,fc as lr,fd as ta,fe as Yt,ff as sa,fg as cr,cL as en,fh as dr,fi as Cn,fj as us,fk as ur,fl as pr,fm as hr,G as na,b5 as gr,fn as Ts,fo as xr,fp as ps,fq as mr,fr as jr,fs as oa,ft as fr,fu as yr,fv as br,fw as Sr,fx as vr,dm as Cr,dn as wr,fy as Tr,fz as kr,cq as aa,fA as ia,H as ra,fB as la,an as Er,dh as Ar,dl as wn,ax as Rr,fC as ca,fD as da,fE as Dr,fF as Ir,fG as Pr,fH as ua,fI as Lr,fJ as Br,fK as Ur,fL as $r,dD as Or,fM as _r}from"./index-C0tV9tYB.js";import{u as Mr,A as Nr,C as Fr,a as Wr,R as qr,S as Gr,T as zr,b as Hr,c as Vr,d as Yr,e as Jr,E as Kr,f as Zr,m as Qr,g as Pt,h as hs,i as tn}from"./RoleCell-CIeC6DEg.js";import{u as gs}from"./useApiTokens-DDEZMbRy.js";import{P as Xr}from"./PercentageDonut-C51wuJjA.js";const el=()=>{const{tokens:t,loading:s,refetch:n}=gs(),{deleteToken:o}=So(),{headerGroups:a,rows:i,prepareRow:r,state:{globalFilter:c},setGlobalFilter:l,setHiddenColumns:g,columns:p}=Mr(t,h=>{const x=h.row.original.type==="client"?xn:h.row.original.type==="frontend"?mn:Pe,m=h.row.original.type==="client"?si:h.row.original.type==="frontend"?ni:Pe;return e.jsxs(Kt,{children:[e.jsx(Wr,{token:h.row.original,permission:x}),e.jsx(qr,{token:h.row.original,permission:m,onRemove:async()=>{await o(h.row.original.secret),n()}})]})});return e.jsx(Se,{permissions:[xn,mn,Pe],children:e.jsx(ne,{header:e.jsx(oe,{title:`API access (${i.length})`,actions:e.jsxs(e.Fragment,{children:[e.jsx(ue,{initialValue:c,onChange:l}),e.jsx(oe.Divider,{}),e.jsx(Fr,{permission:[vo,Co,Pe],path:"/admin/api/create-token"})]})}),children:e.jsx(Nr,{loading:s,headerGroups:a,setHiddenColumns:g,prepareRow:r,rows:i,columns:p,globalFilter:c})})})},tl=({type:t,projects:s,setProjects:n,errors:o,clearErrors:a})=>{const i=oi("projectId"),{projects:r}=wo(),c=r.map(l=>({value:l.id,label:l.name}));return i?null:e.jsxs(e.Fragment,{children:[e.jsx(Gr,{children:"Which project do you want to give access to?"}),e.jsx(ai,{disabled:t===zr.ADMIN,options:c,defaultValue:s,onChange:n,error:o==null?void 0:o.projects,onFocus:()=>a("projects")})]})},Tn="Create API token",sl=d(ii)(({theme:t})=>({margin:t.spacing(2,0,4)})),nl=()=>{const{tokens:t,loading:s}=gs(),{uiConfig:n,loading:o}=W(),a=n.resourceLimits.apiTokens;return{limit:a,currentValue:t.length,limitReached:t.length>=a,loading:o||s}},ol=({modal:t=!1})=>{const{setToastApiError:s}=Y(),{uiConfig:n}=W(),o=we(),[a,i]=u.useState(!1),[r,c]=u.useState(""),{limit:l,currentValue:g,limitReached:p,loading:h}=nl(),{getApiTokenPayload:x,tokenName:m,type:j,projects:b,environment:y,setTokenName:v,setTokenType:A,setProjects:C,setEnvironment:D,isValid:S,errors:U,clearErrors:$,apiTokenTypes:w}=Hr(),{createToken:P,loading:I}=So(),{refetch:L}=gs();Zt(Tn);const R="api/admin/api-tokens",B=async J=>{if(J.preventDefault(),!!S())try{const K=x();await P(K).then(q=>q.json()).then(q=>{Gs(),c(q.secret),i(!0),L()})}catch(K){s(G(K))}},E=()=>{i(!1),o(Be)},O=()=>`curl --location --request POST '${n.unleashUrl}/${R}' \\
2
2
  --header 'Authorization: INSERT_API_KEY' \\
3
3
  --header 'Content-Type: application/json' \\
4
4
  --data-raw '${JSON.stringify(x(),void 0,2)}'`,H=()=>{o(Be)};return e.jsxs(Ae,{loading:I,title:Tn,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/concepts/api-tokens-and-client-keys",documentationLinkLabel:"API tokens documentation",formatApiCode:O,children:[e.jsxs(Vr,{handleSubmit:B,handleCancel:H,mode:"Create",actions:e.jsx(To,{name:"token",permission:[Pe,Co,vo],disabled:p||h||I}),children:[e.jsx(Yr,{tokenName:m,setTokenName:v,errors:U,clearErrors:$}),e.jsx(Jr,{type:j,setType:A,apiTokenTypes:w}),e.jsx(tl,{type:j,projects:b,setProjects:C,errors:U,clearErrors:$}),e.jsx(Kr,{type:j,environment:y,setEnvironment:D}),e.jsx(sl,{name:"API tokens",shortName:"tokens",currentValue:g,limit:l})]}),e.jsx(Zr,{open:a,setOpen:i,closeConfirm:E,token:r,type:j})]})},al=d("div")(({theme:t})=>({display:"flex",flexDirection:"column","& > span:last-of-type":{fontSize:t.fontSizes.smallerBody,color:t.palette.text.secondary}})),xs=({roles:t,value:s,setValue:n,required:o,hideDescription:a,...i})=>{const r=(c,l)=>e.jsx("li",{...c,children:e.jsxs(al,{children:[e.jsx("span",{children:l.name}),e.jsx("span",{children:l.description})]})});return e.jsxs(e.Fragment,{children:[e.jsx(ko,{openOnFocus:!0,size:"small",value:s,onChange:(c,l)=>n(l||null),options:t,renderOption:r,getOptionLabel:c=>c.name,renderInput:c=>e.jsx(se,{...c,label:"Role",required:o}),...i}),e.jsx(k,{condition:!!s&&!a,show:()=>e.jsx(Eo,{sx:{marginTop:1},roleId:s.id})})]})},Lt=()=>{const{isEnterprise:t}=W(),{data:s,error:n,mutate:o}=Qt(t(),{roles:[],projectRoles:[]},X("api/admin/roles"),il);return u.useMemo(()=>({roles:(s==null?void 0:s.roles.filter(({type:a})=>ri.includes(a)).sort(kn))??[],projectRoles:(s==null?void 0:s.roles.filter(({type:a})=>Ao.includes(a)).sort(kn))??[],loading:!n&&!s,refetch:()=>o(),error:n}),[s,n,o])},il=t=>fetch(t).then(le("Roles")).then(s=>s.json()),kn=(t,s)=>ze.includes(t.type)&&!ze.includes(s.type)?-1:!ze.includes(t.type)&&ze.includes(s.type)?1:t.name.localeCompare(s.name),pa=({data:t={enabled:!1,autoCreate:!1},setValue:s,onUpdateRole:n,disabled:o=!1})=>{const{roles:a}=Lt(),i=()=>{s("autoCreate",!t.autoCreate)},r=l=>{s(l.target.name,l.target.value)},c=({defaultRootRole:l,defaultRootRoleId:g})=>g?a.find(({id:p})=>p===g)||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(xe,{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(Xt,{style:{width:"400px"},children:e.jsx(xs,{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(se,{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"})})]})]})},rl=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}},ms=t=>{const{makeRequest:s,createRequest:n,errors:o,loading:a}=pe({propagateErrors:!0,handleBadRequest:rl});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}},sn=t=>{const n=Object.entries(t).filter(([,o])=>o!=="");return Object.fromEntries(n)},ha=({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(xe,{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(se,{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(k,{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(xe,{onChange:r,value:s.addGroupsScope,disabled:!s.enableGroupSyncing||o,name:"addGroupsScope",checked:s.addGroupsScope}),label:s.addGroupsScope?"Enabled":"Disabled"})})]})})]})},ll={enabled:!1,enableSingleSignOut:!1,addGroupsScope:!1,enableGroupSyncing:!1,autoCreate:!1,unleashHostname:location.hostname,groupJsonPath:"",clientId:"",discoverUrl:"",secret:"",acrValues:"",idTokenSigningAlgorithm:"RS256",enablePkce:!1},cl=()=>{var A;const{setToastData:t,setToastApiError:s}=Y(),{uiConfig:n}=W(),{oidcConfiguredThroughEnv:o}=n,a=!!((A=n.flags)!=null&&A.oidcPkceSupport),[i,r]=u.useState(ll),{config:c}=ot("oidc"),{updateSettings:l,errors:g,loading:p}=ms("oidc");u.useEffect(()=>{c.discoverUrl&&r(c)},[c]);const h=C=>{b(C.target.name,C.target.value)},x=C=>{b(C.target.name,C.target.value.trim())},m=()=>{r({...i,enabled:!i.enabled})},j=()=>{r({...i,enableSingleSignOut:!i.enableSingleSignOut})},b=(C,D)=>{r({...i,[C]:D})},y=C=>{r({...i,defaultRootRole:void 0,defaultRootRoleId:C==null?void 0:C.id})},v=async C=>{C.preventDefault();try{await l(sn(i)),t({text:"Settings stored",type:"success"})}catch(D){s(G(D))}};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(k,{condition:!!o,show:e.jsxs(V,{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(V,{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:v,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(xe,{onChange:m,value:i.enabled,name:"enabled",checked:i.enabled}),label:i.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(se,{onChange:x,label:"Discover URL",name:"discoverUrl",value:i.discoverUrl,disabled:!i.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(se,{onChange:x,label:"Client ID",name:"clientId",value:i.clientId,disabled:!i.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(se,{onChange:x,label:"Client Secret",name:"secret",value:i.secret,disabled:!i.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(xe,{onChange:j,value:i.enableSingleSignOut,disabled:!i.enabled||o,name:"enableSingleSignOut",checked:i.enableSingleSignOut}),label:i.enableSingleSignOut?"Enabled":"Disabled"})})]}),e.jsx(k,{condition:a,show:e.jsxs(f,{container:!0,spacing:3,mb:2,children:[e.jsxs(f,{item:!0,md:5,children:[e.jsx("strong",{children:"Enable PKCE"}),e.jsx("p",{children:"Require Proof Key for Code Exchange (PKCE) to add an extra layer of security for the authorization code flow."})]}),e.jsx(f,{item:!0,md:6,style:{padding:"20px"},children:e.jsx(re,{control:e.jsx(xe,{onChange:C=>b("enablePkce",C.target.checked),name:"enablePkce",checked:!!i.enablePkce,disabled:!i.enabled||o}),label:i.enablePkce?"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(se,{onChange:h,label:"ACR Values",name:"acrValues",value:i.acrValues,disabled:!i.enabled||o,style:{width:"400px"},variant:"outlined",size:"small"})})]}),e.jsx(ha,{ssoType:"OIDC",data:i,setValue:b,disabled:o}),e.jsx(pa,{data:i,setValue:b,onUpdateRole:y,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(Xt,{style:{minWidth:"200px"},children:[e.jsx(li,{id:"defaultRootRole-label",children:"Signing algorithm"}),e.jsxs(Ro,{label:"Signing algorithm",labelId:"idTokenSigningAlgorithm-label",id:"idTokenSigningAlgorithm",name:"idTokenSigningAlgorithm",value:i.idTokenSigningAlgorithm||"RS256",onChange:C=>b("idTokenSigningAlgorithm",C.target.value),disabled:o,children:[e.jsx(Me,{value:"RS256",children:"RS256"}),e.jsx(Me,{value:"RS384",children:"RS384"}),e.jsx(Me,{value:"RS512",children:"RS512"})]})]})})]}),e.jsx(f,{container:!0,spacing:3,children:e.jsxs(f,{item:!0,md:12,children:[e.jsx(N,{variant:"contained",color:"primary",type:"submit",disabled:p||o,children:"Save"})," ",e.jsx("p",{children:e.jsx("small",{style:{color:"red"},children:g==null?void 0:g.message})})]})})]})]})},dl={enabled:!1,autoCreate:!1,enableGroupSyncing:!1,addGroupsScope:!1,unleashHostname:location.hostname,entityId:"",signOnUrl:"",certificate:"",signOutUrl:"",spCertificate:"",groupJsonPath:""},ul=()=>{const{setToastData:t,setToastApiError:s}=Y(),{uiConfig:n}=W(),{samlConfiguredThroughEnv:o}=n,[a,i]=u.useState(dl),{config:r}=ot("saml"),{updateSettings:c,errors:l,loading:g}=ms("saml");u.useEffect(()=>{r.entityId&&i(r)},[r]);const p=y=>{m(y.target.name,y.target.value)},h=y=>{m(y.target.name,y.target.value.trim())},x=()=>{i({...a,enabled:!a.enabled})},m=(y,v)=>{i({...a,[y]:v})},j=y=>{i({...a,defaultRootRole:void 0,defaultRootRoleId:y==null?void 0:y.id})},b=async y=>{y.preventDefault();try{await c(sn(a)),t({text:"Settings stored",type:"success"})}catch(v){s(G(v))}};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(k,{condition:!!o,show:e.jsxs(V,{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(V,{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(xe,{onChange:x,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(se,{onChange:h,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(se,{onChange:h,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(se,{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(se,{onChange:h,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(se,{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(ha,{ssoType:"SAML",data:a,setValue:m,disabled:o}),e.jsx(pa,{data:a,setValue:m,onUpdateRole:j,disabled:o}),e.jsx(f,{container:!0,spacing:3,children:e.jsxs(f,{item:!0,md:5,children:[e.jsx(N,{variant:"contained",color:"primary",type:"submit",disabled:g||o,children:"Save"})," ",e.jsx("p",{children:e.jsx("small",{style:{color:"red"},children:l==null?void 0:l.message})})]})})]})]})},pl=d(V)(({theme:t})=>({marginBottom:t.spacing(3)})),hl=({open:t,setOpen:s,onConfirm:n})=>e.jsx(ee,{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(pl,{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."]})}),gl=d(V)(({theme:t})=>({marginBottom:t.spacing(3)})),xl=({open:t,setOpen:s,token:n})=>e.jsxs(ee,{open:t,secondaryButtonText:"Close",onClose:(o,a)=>{a||s(!1)},title:"SCIM API token created",children:[e.jsx(gl,{severity:"info",children:"Make sure to copy your SCIM API token now. You won't be able to see it again!"}),e.jsx(T,{variant:"body1",children:"Your token:"}),e.jsx(Do,{token:n||""})]}),En="api/admin/scim-settings",ml=()=>{const{loading:t,makeRequest:s,createRequest:n,errors:o}=pe({propagateErrors:!0});return{saveSettings:async r=>{const l=n(En,{method:"POST",body:JSON.stringify(r)},"saveSettings");await s(l.caller,l.id)},generateNewToken:async()=>{const c=n(`${En}/generate-new-token`,{method:"POST"},"generateNewToken"),l=await s(c.caller,c.id),{token:g}=await l.json();return g},errors:o,loading:t}},jl="api/admin/scim-settings",An={enabled:!1,hasToken:!1},Bt=()=>{const{isEnterprise:t}=W(),{data:s,error:n,mutate:o}=Qt(t(),An,X(jl),fl);return u.useMemo(()=>({settings:s??An,loading:!n&&!s,refetch:()=>o(),error:n}),[s,n,o])},fl=t=>fetch(t).then(le("SCIM settings")).then(s=>s.json());d(V)(({theme:t})=>({marginBottom:t.spacing(3)}));const Rn=({open:t,closeDialog:s,deleteEntities:n,entityType:o})=>e.jsx(ee,{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(T,{variant:"body1",children:["This will delete all ",o.toLocaleLowerCase()," created or managed by SCIM."]})}),Jt="removeUser",Qe=()=>{const{loading:t,makeRequest:s,createRequest:n,errors:o}=pe({propagateErrors:!0});return{addUser:async h=>{const m=n("api/admin/user-admin",{method:"POST",body:JSON.stringify(h)},"addUser");return s(m.caller,m.id)},updateUser:async h=>{const m=n(`api/admin/user-admin/${h.id}`,{method:"PUT",body:JSON.stringify(h)},"updateUser");return s(m.caller,m.id)},removeUser:async h=>{const m=n(`api/admin/user-admin/${h}`,{method:"DELETE"},"removeUser");return s(m.caller,m.id)},changePassword:async(h,x)=>{const j=n(`api/admin/user-admin/${h}/change-password`,{method:"POST",body:JSON.stringify({password:x})},"changePassword");return s(j.caller,j.id)},validatePassword:async h=>{const m=n("api/admin/user-admin/validate-password",{method:"POST",body:JSON.stringify({password:h})},"validatePassword");return s(m.caller,m.id)},resetPassword:async h=>{const m=n("api/admin/user-admin/reset-password",{method:"POST",body:JSON.stringify({id:h})},"resetPassword");return s(m.caller,m.id)},deleteScimUsers:async()=>{const x=n("api/admin/user-admin/scim-users",{method:"DELETE"},"deleteScimUsers");return s(x.caller,x.id)},userApiErrors:o,userLoading:t}},pt=()=>{const{makeRequest:t,createRequest:s,errors:n,loading:o}=pe({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,g)=>{const p=`api/admin/groups/${l}`,h=s(p,{method:"PUT",body:JSON.stringify(g)});await t(h.caller,h.id)},removeGroup:async l=>{const g=`api/admin/groups/${l}`,p=s(g,{method:"DELETE"});await t(p.caller,p.id)},deleteScimGroups:async()=>{const g=s("api/admin/groups/scim-groups",{method:"DELETE"});await t(g.caller,g.id)},errors:n,loading:o}},yl=d("div")(({theme:t})=>({padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),ks=d("div")(({theme:t})=>({marginBottom:t.spacing(1)})),bl=()=>{const{uiConfig:t}=W(),{setToastData:s,setToastApiError:n}=Y(),[o,a]=u.useState(""),[i,r]=u.useState(!1),[c,l]=u.useState(!1),[g,p]=u.useState(!1),[h,x]=u.useState(!1),{settings:m,refetch:j}=Bt(),{deleteScimUsers:b}=Qe(),{deleteScimGroups:y}=pt(),[v,A]=u.useState(m.enabled??!0);u.useEffect(()=>{A(m.enabled??!1)},[m]);const{saveSettings:C,generateNewToken:D,loading:S}=ml(),U=async()=>{r(!0)},$=async()=>{try{await y(),s({text:"Scim Groups have been deleted",type:"success"}),l(!1),j()}catch(L){n(G(L))}},w=async()=>{try{await b(),s({text:"Scim Users have been deleted",type:"success"}),p(!1),j()}catch(L){n(G(L))}},P=async()=>{r(!1);const L=await D();a(L),x(!0)},I=async L=>{try{if(A(L),await C({enabled:L}),L&&!m.hasToken){const R=await D();a(R),x(!0)}s({text:"Settings stored",type:"success"}),await j()}catch(R){n(G(R))}};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(V,{severity:"info",children:["Please read the"," ",e.jsx("a",{href:"https://docs.getunleash.io/concepts/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(yl,{children:[e.jsxs(f,{container:!0,spacing:3,children:[e.jsxs(f,{item:!0,md:10.5,mb:2,children:[e.jsx(ks,{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(xe,{onChange:(L,R)=>{I(R)},value:v,name:"enabled",checked:v}),label:v?"Enabled":"Disabled"})})]}),e.jsx(f,{container:!0,spacing:3,children:e.jsx(f,{item:!0,md:5,mb:2,children:e.jsx(k,{condition:!!m.hasToken,show:e.jsx(N,{variant:"outlined",color:"error",disabled:S,onClick:U,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(ks,{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(N,{variant:"outlined",color:"error",disabled:S,onClick:()=>{p(!0)},children:"Delete Users"})}),e.jsxs(f,{item:!0,md:10.5,mb:2,children:[e.jsx(ks,{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(N,{variant:"outlined",color:"error",disabled:S,onClick:()=>{l(!0)},children:"Delete Groups"})})]}),e.jsx(hl,{open:i,setOpen:r,onConfirm:P}),e.jsx(xl,{open:h,setOpen:x,token:o}),e.jsx(Rn,{open:g,closeDialog:()=>p(!1),deleteEntities:w,entityType:"Users"}),e.jsx(Rn,{open:c,closeDialog:()=>l(!1),deleteEntities:$,entityType:"Groups"})]})]})},Sl=()=>{const{data:t,error:s,mutate:n}=ve(X("api/admin/user-admin/admin-count"),vl);return{data:t,loading:!s&&!t,refetch:()=>n(),error:s}},vl=t=>fetch(t).then(le("Admin count")).then(s=>s.json()),Cl=({open:t,setOpen:s,onClick:n,adminCount:o,tokens:a})=>e.jsxs(ee,{open:t,onClose:()=>{s(!1)},onClick:n,title:"Disable password based login?",primaryButtonText:"Disable password based login",secondaryButtonText:"Cancel",children:[e.jsxs(V,{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(T,{sx:{mt:3},children:"You are about to disable password based login. Are you sure you want to proceed?"})]}),wl=()=>{const{setToastData:t,setToastApiError:s}=Y(),{config:n,refetch:o}=ot("simple"),[a,i]=u.useState(!1),{updateSettings:r,errors:c,loading:l}=ms("simple"),[g,p]=u.useState(!1),{data:h}=Sl(),{tokens:x}=gs();u.useEffect(()=>{i(!!n.disabled)},[n.disabled]);const m=()=>{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(G(y)),i(n.disabled)}};return e.jsx(e.Fragment,{children:e.jsxs("form",{onSubmit:j,children:[e.jsxs(V,{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:h==null?void 0:h.password}),e.jsx("br",{}),e.jsx("strong",{children:"Other administrators: "})," ",e.jsx(ae,{to:"/admin/users",children:h==null?void 0:h.noPassword}),e.jsx("br",{}),e.jsx("strong",{children:"Admin service accounts: "})," ",e.jsx(ae,{to:"/admin/service-accounts",children:h==null?void 0:h.service}),e.jsx("br",{}),e.jsx("strong",{children:"Admin API tokens: "})," ",e.jsx(ae,{to:"/admin/api",children:x.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(xe,{onChange:m,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(N,{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(Cl,{open:g,setOpen:p,onClick:()=>{p(!1),b()},adminCount:h,tokens:x})]})})},Tl={enabled:!1,autoCreate:!1,unleashHostname:location.hostname,clientId:"",clientSecret:"",emailDomains:""},kl=()=>{const{setToastData:t,setToastApiError:s}=Y(),{uiConfig:n}=W(),[o,a]=u.useState(Tl),{config:i}=ot("google"),{updateSettings:r,errors:c,loading:l}=ms("google");u.useEffect(()=>{i.clientId&&a(i)},[i]);const g=m=>{a({...o,[m.target.name]:m.target.value})},p=()=>{a({...o,enabled:!o.enabled})},h=()=>{a({...o,autoCreate:!o.autoCreate})},x=async m=>{m.preventDefault();try{await r(sn(o)),t({text:"Settings stored",type:"success"})}catch(j){s(G(j))}};return e.jsxs(e.Fragment,{children:[e.jsxs(_,{children:[e.jsxs(V,{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(V,{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:x,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(xe,{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(se,{onChange:g,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(se,{onChange:g,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(se,{onChange:g,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(xe,{onChange:h,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(se,{onChange:g,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(N,{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})})]})})]})]})},El=()=>{var i;const{isEnterprise:t}=W(),s=Ht("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}=zs(),a=((i=n.find(r=>o===r.path))==null?void 0:i.label)||"Single sign-on: OpenID Connect";return Zt(a),t()?e.jsx("div",{children:e.jsx(Se,{permissions:[Pe,ci],children:e.jsx(ne,{header:a,children:e.jsxs(it,{children:[e.jsx(M,{path:"/",index:!0,element:e.jsx(Hs,{to:"/admin/auth/oidc"})}),e.jsx(M,{path:"/oidc",index:!0,element:e.jsx(cl,{})}),e.jsx(M,{path:"/saml",element:e.jsx(ul,{})}),e.jsx(M,{path:"/password",element:e.jsx(wl,{})}),s&&e.jsx(M,{path:"/google",element:e.jsx(kl,{})}),e.jsx(M,{path:"/scim",element:e.jsx(bl,{})})]})})})}):e.jsx(at,{feature:"sso",page:!0})},Al=X("api/admin/invoices"),Rl=d(N)(({theme:t})=>({width:"100%",marginBottom:t.spacing(1.5)})),Dl=({update:t})=>e.jsx(Rl,{href:`${Al}/${t?"portal":"checkout"}`,variant:t?"outlined":"contained",children:t?"Update billing information":"Add billing information"}),Dn=d(Fe)(({theme:t})=>({padding:t.spacing(4),height:"100%",borderRadius:t.shape.borderRadiusLarge,backgroundColor:t.palette.background.paper})),Il=d(T)(({theme:t})=>({marginBottom:t.spacing(4)})),Pl=d(V)(({theme:t})=>({marginBottom:t.spacing(4)})),Es=d(T)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),Ll=d(rt)(({theme:t})=>({margin:`${t.spacing(2.5)} 0`,borderColor:t.palette.divider})),Bl=()=>{const{instanceStatus:t}=Ke(),{uiConfig:{billing:s}}=W(),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!==Vs.ACTIVE,{isCustomBilling:i}=t;return e.jsx(f,{item:!0,xs:12,md:5,children:e.jsxs(Dn,{children:[e.jsx(Il,{variant:"body1",children:"Billing information"}),e.jsx(k,{condition:!!i,show:e.jsx(Es,{children:"Your billing is managed by Unleash"}),elseShow:e.jsxs(e.Fragment,{children:[e.jsx(k,{condition:a,show:e.jsxs(Pl,{severity:"warning",children:["In order to"," ",e.jsx("strong",{children:"Upgrade trial"})," you need to provide us your billing information."]})}),e.jsx(Dl,{update:!a}),e.jsx(Es,{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(Ll,{}),e.jsxs(Es,{children:[e.jsx("a",{href:`mailto:support@getunleash.io?subject=${o} plan clarifications`,children:"Get in touch with us"})," ","for any clarification"]})]})})},Ul=d(f)(({theme:t})=>({flexWrap:"nowrap",gap:t.spacing(1)})),ke=({sx:t,children:s})=>e.jsx(Ul,{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}),$l=d("span")(({theme:t})=>({fontSize:t.fontSizes.smallBody,marginLeft:t.spacing(1)})),wt=({children:t})=>e.jsxs($l,{children:["(",t,")"]}),be=()=>{const{data:t,error:s,mutate:n}=ve(X("api/admin/user-admin"),Ol);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])},Ol=t=>fetch(t).then(le("Users")).then(s=>s.json()),ga=new Date,hm=Et(ga,"yyyy-MM");Po(ga);const gm=t=>Et(t,"yyyy-MM"),xm=t=>Et(t,"yyyy-MM-dd"),mm=t=>Io(t,"yyyy-MM",new Date),_l=t=>Io(t,"yyyy-MM-dd",new Date),nn=5,on=1e6,Ml=_l("2024-05-01"),Nl=["/api/admin","/api/frontend","/api/client"],Fl=t=>{const{apiData:s,...n}=t;return{apiData:s.filter(a=>Nl.includes(a.apiPath)).map(a=>(a.dataPoints=a.dataPoints.filter(({period:i})=>new Date(i)>=Ml),a)),...n}},Wl=(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),xa=t=>t.flatMap(s=>s.dataPoints.flatMap(n=>n.trafficTypes.map(o=>o.count))).reduce((s,n)=>s+n,0),ql=t=>{const{grouping:s,apiData:n}=t;if(s==="monthly"){const o=Et(new Date(t.dateRange.to),"yyyy-MM");return Wl(n,o)}else return xa(n)},Gl=(t,s=nn,n=on)=>Math.ceil(t/n)*s,ma=(t,s,n=nn,o=on)=>{if(t===0)return 0;const a=Math.floor((t-s)/o)*o;return a>0?Gl(a,n,o):0},zl=({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 xa(o)/(t-1)*s},jm=(t,s,n,o=nn,a=on)=>{if(!t)return 0;const i=n.getDate(),r=Po(n),c=zl({dayOfMonth:i,daysInMonth:r,trafficData:t});return ma(c,s,o,a)},Hl=(t,{from:s,to:n})=>{const o=`api/admin/metrics/traffic?grouping=${t}&from=${s}&to=${n}`,{data:a,error:i,mutate:r}=ve(X(o),Vl);return u.useMemo(()=>{const c=a?{state:"success",data:Fl(a)}:i?{state:"error",error:i}:{state:"loading"};return{refetch:()=>r(),result:c}},[a,i,r])},Vl=t=>fetch(t).then(le("Instance Metrics")).then(s=>s.json()),ja=t=>{const s=new Date,n=p=>Et(p,"yyyy-MM-dd"),o=n(di(s)),a=n(ui(s)),{instanceStatus:i}=Ke(),{instancePrices:r}=es(),c=(i==null?void 0:i.billing)==="pay-as-you-go"?r.payg.traffic:r.pro.traffic,{result:l}=Hl("daily",{from:o,to:a});return u.useMemo(()=>{if(l.state!=="success")return 0;const p=ql(l.data);return ma(p,t,c)},[t,JSON.stringify(l),c])},As=d(T)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),Yl=d(Ys)(({theme:t})=>({fontSize:"1rem",marginRight:t.spacing(1)})),Jl=d(rt)(({theme:t})=>({margin:`${t.spacing(3)} 0`})),Kl=({instancePrices:t})=>{const{users:s,loading:n}=be(),o=s.filter(m=>m.email),a=t.pro.base,i=t.pro.seat,r=t.pro.traffic,c=fa,l=Math.min(o.length,c),g=o.length-l,p=i*g,h=ja(ya),x=a+p+h;return n?null:e.jsxs(e.Fragment,{children:[e.jsxs(f,{container:!0,children:[e.jsxs(ke,{sx:m=>({marginBottom:m.spacing(1.5)}),children:[e.jsxs(ie,{vertical:!0,children:[e.jsxs(T,{children:[e.jsx("strong",{children:"Included members"}),e.jsx(wt,{children:e.jsxs(ae,{to:"/admin/users",children:[l," of ",c," assigned"]})})]}),e.jsxs(As,{children:["You have ",c," team members included in your PRO plan"]})]}),e.jsxs(ie,{children:[e.jsx(Yl,{}),e.jsx(T,{variant:"body2",children:"included"})]})]}),e.jsxs(ke,{sx:m=>({marginBottom:m.spacing(1.5)}),children:[e.jsxs(ie,{vertical:!0,children:[e.jsxs(T,{children:[e.jsx("strong",{children:"Paid members"}),e.jsx(wt,{children:e.jsxs(ae,{to:"/admin/users",children:[g," assigned"]})})]}),e.jsxs(As,{children:["$",i,"/month per paid member"]})]}),e.jsx(ie,{children:e.jsxs(T,{sx:m=>({fontSize:m.fontSizes.mainHeader}),children:["$",p.toFixed(2)]})})]}),e.jsx(k,{condition:h>0,show:e.jsxs(ke,{children:[e.jsxs(ie,{vertical:!0,children:[e.jsxs(T,{children:[e.jsx("strong",{children:"Accrued traffic charges"}),e.jsx(wt,{children:e.jsx(ae,{to:"/admin/network/data-usage",children:"view details"})})]}),e.jsxs(As,{children:["$",r," per 1 million started above included data"]})]}),e.jsx(ie,{children:e.jsxs(T,{sx:m=>({fontSize:m.fontSizes.mainHeader}),children:["$",h.toFixed(2)]})})]})})]}),e.jsx(Jl,{}),e.jsx(f,{container:!0,children:e.jsxs(ke,{children:[e.jsx(ie,{children:e.jsx(T,{sx:m=>({fontWeight:m.fontWeight.bold,fontSize:m.fontSizes.mainHeader}),children:"Total"})}),e.jsx(ie,{children:e.jsxs(T,{sx:m=>({fontWeight:m.fontWeight.bold,fontSize:"2rem"}),children:["$",x.toFixed(2)]})})]})})]})},In=d(T)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),Zl=d(rt)(({theme:t})=>({margin:`${t.spacing(3)} 0`})),Ql=({instanceStatus:t,instancePrices:s})=>{const{users:n,loading:o}=be(),a=n.filter(x=>x.email),i=s.payg.seat,r=s.payg.traffic,c=t.minSeats??sc,l=Math.max(a.length,c),g=i*l,p=ja(ya),h=g+p;return o?null:e.jsxs(e.Fragment,{children:[e.jsxs(f,{container:!0,children:[e.jsxs(ke,{sx:x=>({marginBottom:x.spacing(1.5)}),children:[e.jsxs(ie,{vertical:!0,children:[e.jsxs(T,{children:[e.jsx("strong",{children:"Paid members"}),e.jsx(wt,{children:e.jsxs(ae,{to:"/admin/users",children:[a.length," assigned of"," ",c," minimum"]})})]}),e.jsxs(In,{children:["$",i,"/month per paid member"]})]}),e.jsx(ie,{children:e.jsxs(T,{sx:x=>({fontSize:x.fontSizes.mainHeader}),children:["$",g.toFixed(2)]})})]}),e.jsx(k,{condition:p>0,show:e.jsxs(ke,{children:[e.jsxs(ie,{vertical:!0,children:[e.jsxs(T,{children:[e.jsx("strong",{children:"Accrued traffic charges"}),e.jsx(wt,{children:e.jsx(ae,{to:"/admin/network/data-usage",children:"view details"})})]}),e.jsxs(In,{children:["$",r," per 1 million started above included data"]})]}),e.jsx(ie,{children:e.jsxs(T,{sx:x=>({fontSize:x.fontSizes.mainHeader}),children:["$",p.toFixed(2)]})})]})})]}),e.jsx(Zl,{}),e.jsx(f,{container:!0,children:e.jsxs(ke,{children:[e.jsx(ie,{children:e.jsx(T,{sx:x=>({fontWeight:x.fontWeight.bold,fontSize:x.fontSizes.mainHeader}),children:"Total"})}),e.jsx(ie,{children:e.jsxs(T,{sx:x=>({fontWeight:x.fontWeight.bold,fontSize:"2rem"}),children:["$",h.toFixed(2)]})})]})})]})};d(T)(({theme:t})=>({fontSize:t.fontSizes.smallerBody,color:t.palette.text.secondary}));const Xl=d(N)(({theme:t})=>({marginTop:t.spacing(1),display:"inline-flex",alignItems:"center"})),ec=()=>{const t=X("api/admin/invoices/portal");return e.jsx(e.Fragment,{children:e.jsx(f,{container:!0,children:e.jsx(ke,{sx:s=>({marginBottom:s.spacing(3)}),children:e.jsx(ie,{vertical:!0,children:e.jsx(Xl,{href:t,variant:"outlined",endIcon:e.jsx(pi,{}),children:"View usage charges"})})})})})},tc=({instanceStatus:t,instancePrices:s,isPAYG:n,isEnterpriseConsumption:o})=>n?e.jsx(Ql,{instanceStatus:t,instancePrices:s}):t.plan===Js.PRO?e.jsx(Kl,{instancePrices:s}):o?e.jsx(ec,{}):null,sc=5,fa=5,ya=53e6,Pn=d(Fe)(({theme:t})=>({padding:t.spacing(4),height:"100%",borderRadius:t.shape.borderRadiusLarge,backgroundColor:t.palette.background.paper})),nc=d("span")(({theme:t})=>({fontSize:"3.25rem",lineHeight:1,color:t.palette.primary.main,fontWeight:800,marginRight:t.spacing(1.5)})),oc=d("span")(({theme:t})=>({fontWeight:t.fontWeight.bold})),ac=d("span")(({theme:t})=>({fontWeight:t.fontWeight.bold})),ic=d("span")(({theme:t})=>({color:t.palette.primary.main,fontSize:t.fontSizes.mainHeader,fontWeight:t.fontWeight.bold})),rc=d(V)(({theme:t})=>({fontSize:t.fontSizes.smallerBody,marginBottom:t.spacing(3),marginTop:t.spacing(-1.5),[t.breakpoints.up("md")]:{marginTop:t.spacing(-4.5)}})),lc=()=>{const{uiConfig:{billing:t}}=W(),{instanceStatus:s}=Ke(),{instancePrices:n}=es(),o=(s==null?void 0:s.plan)&&(s==null?void 0:s.plan)===Js.PRO,a=t==="pay-as-you-go",i=t==="enterprise-consumption";if(!s)return e.jsx(f,{item:!0,xs:12,md:7,children:e.jsx(Pn,{"data-loading":!0,sx:{flex:1,height:"400px"}})});const r=Lo(s),c=n.pro.base,l=`${s.plan}${a?" Pay-as-You-Go":""}`,g=s.state!==Vs.ACTIVE;return e.jsx(f,{item:!0,xs:12,md:7,children:e.jsxs(Pn,{children:[e.jsx(k,{condition:g,show:e.jsxs(rc,{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=${l} plan clarifications`,children:"Get in touch with us"})," ","for any clarification"]})}),e.jsx(Le,{color:"success",children:"Current plan"}),e.jsxs(f,{container:!0,sx:p=>({marginBottom:p.spacing(3)}),children:[e.jsxs(ke,{children:[e.jsxs(ie,{children:[e.jsx(nc,{children:s.plan}),e.jsx(k,{condition:Bo(s),show:e.jsx(ac,{sx:p=>({color:r?p.palette.error.dark:p.palette.warning.dark}),children:r?"Trial expired":s.trialExtended?"Extended Trial":"Trial"})})]}),e.jsx(ie,{children:e.jsx(k,{condition:!!o,show:e.jsxs(ic,{children:["$",c.toFixed(2)]})})})]}),e.jsx(ke,{children:e.jsx(k,{condition:a||i,show:e.jsxs(oc,{children:["Pay-as-You-Go"," ",i?"Consumption":""]})})})]}),e.jsx(tc,{instanceStatus:s,instancePrices:n,isPAYG:a,isEnterpriseConsumption:i})]})})},cc=()=>e.jsxs(f,{container:!0,spacing:2,children:[e.jsx(Bl,{}),e.jsx(lc,{})]}),dc=d(T)(({theme:t})=>({marginTop:t.spacing(6),marginBottom:t.spacing(2.5),fontSize:t.fontSizes.mainHeader})),uc=[{Header:"Amount",accessor:"amountFormatted"},{Header:"Status",accessor:"status",disableGlobalFilter:!0},{Header:"Created date",accessor:"created",Cell:me,disableGlobalFilter:!0},{Header:"Due date",accessor:"dueDate",Cell:me,disableGlobalFilter:!0},{Header:"Download",accessor:"invoicePDF",align:"center",Cell:({value:t})=>e.jsx(_,{sx:{display:"flex",justifyContent:"center"},"data-loading":!0,children:e.jsx(Re,{href:t,children:e.jsx(mi,{})})}),width:100,disableGlobalFilter:!0,disableSortBy:!0}],pc=({data:t,isLoading:s=!1})=>{const n=u.useMemo(()=>({sortBy:[{id:"created",desc:!0}]}),[]),{getTableProps:o,getTableBodyProps:a,headerGroups:i,rows:r,prepareRow:c}=F.useTable({columns:uc,data:t,initialState:n,sortTypes:fe,autoResetGlobalFilter:!1,disableSortRemove:!0,defaultColumn:{Cell:te}},F.useGlobalFilter,F.useSortBy);return e.jsxs(ne,{isLoading:s,disablePadding:!0,children:[e.jsx(dc,{children:"Payment history"}),e.jsxs(hi,{...o(),children:[e.jsx(gi,{headerGroups:i}),e.jsx(Ks,{...a(),children:r.map(l=>{c(l);const{key:g,...p}=l.getRowProps();return e.jsx(kt,{hover:!0,...p,children:l.cells.map(h=>{const{key:x,...m}=h.getCellProps();return e.jsx(xi,{...m,children:h.render("Cell")},x)})},g)})})]}),e.jsx(k,{condition:r.length===0,show:e.jsx(ce,{children:"No invoices to show."})})]})},qs="api/admin/invoices",hc=X(qs),ba=(t={})=>{const s=()=>fetch(hc,{method:"GET"}).then(le("Invoices")).then(c=>c.json()),{data:n,error:o}=ve(qs,s,t),[a,i]=u.useState(!o&&!n),r=()=>{ji(qs)};return u.useEffect(()=>{i(!o&&!n)},[n,o]),{invoices:(n==null?void 0:n.invoices)||[],error:o,loading:a,refetchInvoices:r}};var an={},gc=ct;Object.defineProperty(an,"__esModule",{value:!0});var Sa=an.default=void 0,xc=gc(lt()),mc=e,jc=(0,xc.default)((0,mc.jsx)("path",{d:"M19 9h-4V3H9v6H5l7 7 7-7zm-8 2V5h2v6h1.17L12 13.17 9.83 11H11zm-6 7h14v2H5z"}),"DownloadOutlined");Sa=an.default=jc;const Ve=(t,s)=>s&&s.toLocaleLowerCase()==="usd"?`$${t.toLocaleString("en-US")}`:s&&s.toLocaleLowerCase()==="eur"?`€ ${t.toLocaleString("no-NO")}`:`${t}${s?" ":""}${s||""}`,va=d("div",{shouldForwardProp:t=>t!=="withBackground"})(({theme:t,withBackground:s})=>({display:"grid",gridTemplateColumns:"subgrid",gridColumn:"1 / -1",background:s?t.palette.background.elevation1:"transparent",margin:t.spacing(.5,0),padding:s?t.spacing(2,2,3):t.spacing(.5,2,1.5),borderRadius:t.shape.borderRadiusLarge,gap:t.spacing(2)})),Ye=d("div")(({theme:t})=>({textAlign:"right",paddingRight:t.spacing(1.5)})),Ca=d("div",{shouldForwardProp:t=>t!=="expand"})(({expand:t})=>({display:"flex",flexDirection:"column",gridColumn:t?"1 / span 2":void 0})),fc=d(va)(({theme:t})=>({gridColumn:"3 / -1",padding:t.spacing(1,1,0,0),gap:0})),Rs=d("div")(({theme:t,last:s})=>({marginRight:t.spacing(1),display:"grid",gridColumn:"1 / -1",gridTemplateColumns:"subgrid",...s?{fontWeight:t.typography.fontWeightBold}:{borderBottom:`1px solid ${t.palette.divider}`},padding:t.spacing(1.25,0)})),He=d("div",{shouldForwardProp:t=>t!=="colSpan"})(({theme:t,colSpan:s})=>({padding:t.spacing(0,0,0,.5),...s?{gridColumn:`span ${s}`}:{}})),yc=({value:t,percentage:s,currency:n,status:o})=>{if(t===void 0)return e.jsx(He,{colSpan:2,children:"Customer tax is exempt"});const i=o==="estimate"&&s!==void 0?`Tax (${s}%)`:"Tax";return e.jsxs(e.Fragment,{children:[e.jsx(He,{children:i}),e.jsx(He,{children:e.jsx(Ye,{children:Ve(t,n)})})]})},bc=({subTotal:t,taxAmount:s,taxPercentage:n,totalAmount:o,currency:a,status:i})=>e.jsxs(fc,{children:[e.jsxs(Rs,{children:[e.jsx(He,{children:"Sub total"}),e.jsx(He,{children:e.jsx(Ye,{children:Ve(t||0,a)})})]}),e.jsx(Rs,{children:e.jsx(yc,{value:s,percentage:n,currency:a,status:i})}),e.jsxs(Rs,{last:!0,children:[e.jsx(He,{children:"Total"}),e.jsx(He,{children:e.jsx(Ye,{children:Ve(o,a)})})]})]}),Sc=({percentage:t})=>e.jsx(Xr,{percentage:t,size:"1.25rem",strokeRatio:.3}),rn=(t,s)=>!!(t&&s),Ln=(t,s)=>rn(t,s)?Math.floor(Math.max(0,t-s)):0,vc=(t,s)=>rn(t,s)?Math.min(t,s):t,Cc=d("div")(({theme:t})=>({display:"flex",alignItems:"center",gap:t.spacing(1),maxHeight:t.spacing(2.5)})),wc=({quantity:t,consumption:s,limit:n,description:o,totalAmount:a,unitPrice:i,invoiceCurrency:r,invoiceStatus:c})=>{const l=n&&n>0?Math.min(100,Math.round((s||0)/n*100)):void 0,g=c==="estimate",p=rn(s,n),h=g&&p?Ln(s,n):t,x=g&&p?vc(s,n):s,j=g&&i&&p?Math.ceil(Ln(s,n)/1e6)*i:a,b=j&&j>0,y=p,v=()=>x!==void 0&&n!==void 0?`${tt(x)}/${tt(n)}`:x!==void 0?tt(x):n!==void 0?tt(n):"–";return e.jsxs(e.Fragment,{children:[e.jsx(Ca,{children:o}),y?e.jsxs(Cc,{children:[e.jsx(Sc,{percentage:l||0}),e.jsx("div",{children:v()})]}):e.jsx("div",{}),e.jsx("div",{children:h?tt(h):""}),b?e.jsx(Ye,{children:Ve(j,r)}):e.jsx("div",{})]})},Tc=d(T)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.typography.caption.fontSize})),kc=({quantity:t,description:s,currency:n,totalAmount:o,startDate:a,endDate:i,invoiceCurrency:r})=>{const c=a?new Date(a).toLocaleDateString(void 0,{month:"short",day:"numeric"}):void 0,l=i?new Date(i).toLocaleDateString(void 0,{month:"short",day:"numeric"}):void 0;return e.jsxs(e.Fragment,{children:[e.jsxs(Ca,{expand:!0,children:[e.jsx("div",{children:s}),c||l?e.jsxs(Tc,{children:[c," - ",l]}):null]}),e.jsx("div",{children:t?tt(t):"–"}),e.jsx(Ye,{children:Ve(o||0,r)})]})},Ec=(t,s,n,o,a,i,r)=>{if(t!=="estimate")return{subtotal:s,taxAmount:n,totalAmount:o};const c=i.reduce((m,j)=>m+(j.totalAmount||0),0),l=1e6,g=r.reduce((m,j)=>{const b=j.consumption&&j.limit?Math.ceil(Math.max(0,j.consumption-j.limit)/l):0;return m+b*(j.unitPrice||0)},0),p=c+g,h=a?p*(a/100):0,x=p+h;return{subtotal:p,taxAmount:h,totalAmount:x}},Ac=d(ns)(({theme:t})=>({background:t.palette.background.paper,borderRadius:t.shape.borderRadiusLarge,boxShadow:t.boxShadows.card,"&:before":{display:"none"},"&.MuiAccordion-root":{margin:0,border:"none"}})),Rc=d(os)(({theme:t})=>({padding:t.spacing(2,4),gap:t.spacing(1.5),"& .MuiAccordionSummary-content":{margin:0,display:"flex",alignItems:"center",gap:t.spacing(1.5),"&.Mui-expanded":{margin:0}}})),Dc=d("div")(({theme:t})=>({display:"flex",alignItems:"center",gap:t.spacing(1.5),flex:1,minWidth:0})),Ic=d("div")(({theme:t})=>({display:"flex",alignItems:"center",gap:t.spacing(2)})),Pc=d("div")(({theme:t})=>({display:"grid",gridTemplateColumns:"45% 20% 15% 20%",padding:t.spacing(0,2,2)})),_e=d("div")(({theme:t})=>({fontSize:t.typography.body2.fontSize,fontWeight:t.typography.fontWeightMedium,color:t.palette.text.secondary})),Bn=({children:t,title:s})=>e.jsx(va,{withBackground:!!s,children:t}),$t=d("div")(({theme:t})=>({display:"grid",gridColumn:"1 / -1",gridTemplateColumns:"subgrid"})),Lc=d("span")(({theme:t})=>({color:t.palette.text.primary,fontSize:t.typography.body1.fontSize})),Bc=d(rt)(({theme:t})=>({gridColumn:"1 / -1",margin:t.spacing(0,2)})),Uc=d("div")(({theme:t})=>({display:"flex",justifyContent:"flex-end",gap:t.spacing(1),padding:t.spacing(0,2,2)})),$c=({status:t,invoiceDate:s,invoicePDF:n,invoiceURL:o,totalAmount:a,subtotal:i,taxAmount:r,taxPercentage:c,currency:l,mainLines:g,usageLines:p,monthText:h,defaultExpanded:x})=>{const m=s?new Date(s).toLocaleDateString(void 0,{month:"long",day:"numeric"}):"",b=new Date(s).getFullYear()===new Date().getFullYear()?`, ${new Date(s).getFullYear()}`:"",{subtotal:y,taxAmount:v,totalAmount:A}=Ec(t,i,r,a,c,g,p);return e.jsxs(Ac,{defaultExpanded:!!x,children:[e.jsxs(Rc,{expandIcon:e.jsx(ts,{}),id:`billing-invoice-${m}-header`,children:[e.jsx(Dc,{children:e.jsxs(T,{variant:"h2",component:"h3",sx:{fontWeight:700},children:[m,b]})}),e.jsxs(Ic,{children:[t==="estimate"?e.jsx(Le,{color:"disabled",children:"Estimate"}):null,t==="upcoming"?e.jsx(Le,{color:"info",children:"Next invoice"}):null,t==="invoiced"?e.jsx(Le,{color:"success",children:"Invoiced"}):null,t==="paid"?e.jsx(Le,{color:"success",children:"Paid"}):null,e.jsx(T,{variant:"body1",sx:{fontWeight:700},children:Ve(A,l)})]})]}),e.jsxs(ss,{sx:C=>({padding:C.spacing(2,0,0),borderTop:`1px solid ${C.palette.divider}`}),children:[e.jsxs(Pc,{children:[e.jsxs(Bn,{children:[e.jsxs($t,{children:[e.jsx(_e,{children:"Description"}),e.jsx(_e,{}),e.jsx(_e,{children:"Quantity"}),e.jsx(_e,{children:e.jsx(Ye,{children:"Amount"})})]}),g.map(C=>e.jsx($t,{children:e.jsx(kc,{...C,invoiceCurrency:l})},C.description))]}),p.length?e.jsxs(Bn,{title:"Usage",children:[e.jsxs($t,{children:[e.jsx(_e,{children:e.jsxs(Lc,{children:["Usage – ",h]})}),e.jsx(_e,{children:"Included"}),e.jsx(_e,{children:"Overages"}),e.jsx(_e,{children:e.jsx(Ye,{children:"Amount"})})]}),p.map(C=>e.jsx($t,{children:e.jsx(wc,{...C,invoiceCurrency:l,invoiceStatus:t})},C.description))]},"usage"):e.jsx(Bc,{}),e.jsx(bc,{subTotal:y,taxAmount:v,taxPercentage:c,totalAmount:A,currency:l,status:t})]}),o||n?e.jsxs(Uc,{children:[o?e.jsx(N,{variant:"outlined",href:o,target:"_blank",rel:"noreferrer",startIcon:e.jsx(fi,{}),children:"View invoice"}):null,n?e.jsx(N,{variant:"outlined",href:n,target:"_blank",rel:"noreferrer",startIcon:e.jsx(Sa,{}),children:"Download PDF"}):null]}):null]})]})},Oc=d(ns)(({theme:t})=>({background:t.palette.background.paper,borderRadius:t.shape.borderRadiusLarge})),_c=d(os)(({theme:t})=>({padding:t.spacing(2,4),gap:t.spacing(1.5)})),Mc=d("div")(({theme:t})=>({display:"flex",alignItems:"center",gap:t.spacing(1.5),flex:1,minWidth:0})),Nc=d("div")(({theme:t})=>({display:"flex",alignItems:"center",gap:t.spacing(2)})),Fc=d("div")(({theme:t})=>({height:t.spacing(2.5),backgroundColor:t.palette.action.hover,borderRadius:t.spacing(.5),margin:t.spacing(.5,0)})),Wc=d("div")(({theme:t})=>({height:t.spacing(3),width:t.spacing(10),backgroundColor:t.palette.action.hover,borderRadius:t.spacing(1.5)})),qc=d("div")(({theme:t})=>({height:t.spacing(3),width:t.spacing(12.5),backgroundColor:t.palette.action.hover,borderRadius:t.spacing(.5)})),Gc=d("div")(({theme:t})=>({height:t.spacing(25),backgroundColor:t.palette.action.hover,borderRadius:t.spacing(.5),margin:t.spacing(2,4)})),zc=()=>e.jsxs(Oc,{defaultExpanded:!0,"data-loading":!0,children:[e.jsxs(_c,{expandIcon:e.jsx(ts,{}),children:[e.jsx(Mc,{children:e.jsx(Fc,{sx:{width:t=>t.spacing(15),height:t=>t.spacing(4)}})}),e.jsxs(Nc,{children:[e.jsx(Wc,{}),e.jsx(qc,{})]})]}),e.jsx(ss,{children:e.jsx(Gc,{})})]}),wa="api/admin/invoices/list",Hc=X(wa),Ta=(t={})=>{const s=()=>fetch(Hc,{method:"GET"}).then(le("Detailed invoices")).then(l=>l.json()),{data:n,error:o,isLoading:a}=ve(wa,s,t),i=u.useMemo(()=>(n==null?void 0:n.invoices)??[],[n]),r=n==null?void 0:n.planPrice,c=n==null?void 0:n.planCurrency;return{invoices:i,planPrice:r,planCurrency:c,error:o,loading:a}},Un=d(_)(({theme:t})=>({display:"flex",flexDirection:"column",gap:t.spacing(2)})),Vc=()=>{const{invoices:t,loading:s}=Ta(),n=At(s);return s?e.jsx(Un,{ref:n,children:[1,2,3].map(o=>e.jsx(zc,{},o))}):e.jsx(Un,{children:t.length>0?e.jsx(e.Fragment,{children:t.map((o,a)=>e.jsx($c,{defaultExpanded:a===0,...o},o.invoiceDate))}):e.jsx(ce,{children:"There are no invoices or estimates available right now."})})};var ln={},Yc=ct;Object.defineProperty(ln,"__esModule",{value:!0});var ka=ln.default=void 0,Jc=Yc(lt()),Kc=e,Zc=(0,Jc.default)((0,Kc.jsx)("path",{d:"M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4v-6h16v6zm0-10H4V6h16v2z"}),"CreditCard");ka=ln.default=Zc;const Qc=d(Fe)(({theme:t})=>({padding:t.spacing(2),borderRadius:t.shape.borderRadiusLarge,display:"flex",flexDirection:"column",gap:t.spacing(1)})),$n=d("div")(({theme:t})=>({display:"flex",justifyContent:"space-between",fontSize:t.typography.body2.fontSize})),Ot=d("div")(({theme:t})=>({height:t.spacing(2.5),backgroundColor:t.palette.action.hover,borderRadius:t.spacing(.5),margin:t.spacing(.5,0)})),Xc=d("div")(({theme:t})=>({height:t.spacing(4),backgroundColor:t.palette.action.hover,borderRadius:t.spacing(.5),margin:t.spacing(.5,0),width:t.spacing(20)})),ed=d("div")(({theme:t})=>({height:t.spacing(5),backgroundColor:t.palette.action.hover,borderRadius:t.spacing(.5),margin:t.spacing(1,0),width:"100%"})),td=d("div")(({theme:t})=>({height:t.spacing(.125),backgroundColor:t.palette.action.hover,borderRadius:t.spacing(.5),margin:t.spacing(1.5,0),width:"100%"})),On=d("div")(({theme:t})=>({height:t.spacing(2),backgroundColor:t.palette.action.hover,borderRadius:t.spacing(.5),margin:t.spacing(.5,0),width:t.spacing(25)})),sd=()=>e.jsxs(Qc,{"data-loading":!0,children:[e.jsx(Xc,{}),e.jsxs($n,{children:[e.jsx(Ot,{sx:{width:t=>t.spacing(12)}}),e.jsx(Ot,{sx:{width:t=>t.spacing(8)}})]}),e.jsxs($n,{children:[e.jsx(Ot,{sx:{width:t=>t.spacing(10)}}),e.jsx(Ot,{sx:{width:t=>t.spacing(6)}})]}),e.jsx(td,{}),e.jsx(ed,{}),e.jsx(On,{}),e.jsx(On,{sx:{width:t=>t.spacing(20)}})]}),nd=X("api/admin/invoices"),Ds=d(Fe)(({theme:t})=>({padding:t.spacing(2),borderRadius:t.shape.borderRadiusLarge,boxShadow:t.boxShadows.card,display:"flex",flexDirection:"column",gap:t.spacing(1)})),_n=d("div")(({theme:t})=>({display:"flex",justifyContent:"space-between",fontSize:t.typography.body2.fontSize})),Mn=d("span")(({theme:t})=>({color:t.palette.text.secondary,whiteSpace:"nowrap"})),Nn=d("span")(({theme:t})=>({textAlign:"right"})),od=d(N)(({theme:t})=>({margin:t.spacing(0,0,1,0)})),zt=d(T)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),ad=d(rt)(({theme:t})=>({margin:t.spacing(1.5,0),borderColor:t.palette.divider})),Is=()=>e.jsxs(zt,{children:[e.jsx("a",{href:"mailto:support@getunleash.io?subject=Billing plan clarifications",children:"Get in touch with us"})," ","for any clarification"]}),id=()=>{const{instanceStatus:t,loading:s}=Ke(),{uiConfig:{billing:n}}=W(),{planPrice:o,planCurrency:a,loading:i}=Ta();if(s||i)return e.jsx(sd,{});if(!t)return e.jsxs(Ds,{children:[e.jsx(T,{variant:"h3",children:"Billing details"}),e.jsx(zt,{children:"Your billing is managed by Unleash"}),e.jsx(Is,{})]});const r=n==="pay-as-you-go",c=t.state!==Vs.ACTIVE,{isCustomBilling:l}=t;return l?e.jsxs(Ds,{children:[e.jsx(T,{variant:"h3",children:"Billing details"}),e.jsx(zt,{children:"Your billing is managed by Unleash"}),e.jsx(Is,{})]}):e.jsxs(Ds,{children:[e.jsx(T,{variant:"h3",children:"Billing details"}),e.jsxs(_n,{children:[e.jsx(Mn,{children:"Current plan"})," ",e.jsx(Nn,{children:r?"Pay-as-You-Go":"Consumption"})]}),e.jsxs(_n,{children:[e.jsx(Mn,{children:"Plan price"})," ",e.jsx(Nn,{children:o!==void 0?`${Ve(o,a)} ${r?"per seat":"/ month"}`:"-"})]}),e.jsx(ad,{}),e.jsx(od,{href:`${nd}/${c?"checkout":"portal"}`,variant:c?"contained":"outlined",startIcon:e.jsx(ka,{}),children:c?"Add billing details":"Edit billing details"}),c?e.jsx(zt,{children:"Once we have received your billing information we will upgrade your trial within 1 business day."}):null,e.jsx(Is,{})]})},rd=d("div")(({theme:t})=>({marginTop:t.spacing(2),marginBottom:t.spacing(3),borderRadius:t.shape.borderRadiusMedium,padding:t.spacing(1.5,4,1.5,3),border:`1px solid ${t.palette.secondary.border}`,backgroundColor:t.palette.secondary.light,display:"flex",justifyContent:"space-between",alignItems:"center"})),ld=d(_)(({theme:t})=>({marginBottom:t.spacing(1)})),cd=d("span")(({theme:t})=>({fontWeight:t.typography.fontWeightBold,fontSize:t.fontSizes.largeHeader})),dd=d(_)(({theme:t})=>({margin:0,padding:0,marginLeft:t.spacing(2.5),marginTop:t.spacing(1)})),ud=d("ul")(({theme:t})=>({display:"flex",margin:0,padding:0,gap:t.spacing(3.5)})),pd=d("div")(({theme:t})=>({display:"flex",alignItems:"center",marginTop:t.spacing(.75),padding:t.spacing(0,.25),gap:t.spacing(2),color:t.palette.text.secondary})),hd=()=>{const{hasAccess:t}=u.useContext(yi),{instancePrices:s}=es(),{instanceStatus:n}=Ke(),{trackEvent:o}=as(),a=()=>{o("upgrade_trial_billing_page",{props:{eventType:"upgrade_click"}}),window.location.assign(X("api/admin/invoices/checkout"))},i=t(Q),r=s.payg.seat,c=Lo(n);return e.jsxs(e.Fragment,{children:[e.jsx(T,{variant:"h2",sx:{mb:1},children:c?"Upgrade to continue using Unleash":"14 day free trial"}),e.jsx(bi,{}),i?e.jsxs(rd,{children:[e.jsxs(ld,{children:[e.jsxs(T,{children:[e.jsxs(cd,{children:["$",r]})," per user billed monthly"]}),e.jsx(dd,{children:e.jsxs(ud,{children:[e.jsx("li",{children:"Pay by credit card"}),e.jsx("li",{children:"Cancel anytime"})]})})]}),a&&e.jsx(N,{variant:"contained",onClick:a,children:"Upgrade now"})]}):e.jsx(V,{severity:"info",sx:{mt:3,mb:2},children:"Contact your account admin to request an upgrade."}),e.jsx(T,{color:"text.secondary",children:"Trusted by enterprises like"}),e.jsxs(pd,{children:[e.jsx(Si,{}),e.jsx(vi,{}),e.jsx(Ci,{}),e.jsx(wi,{}),e.jsx(Ti,{})]})]})},Fn=d(T)(({theme:t})=>({fontSize:t.fontSizes.mainHeader,color:t.palette.text.primary})),gd=d(_)(({theme:t})=>({display:"grid",gridTemplateColumns:"1fr 320px",gap:t.spacing(2),[t.breakpoints.down("md")]:{display:"flex",flexDirection:"column-reverse"}})),Wn=d(_)(({theme:t})=>({display:"flex",flexDirection:"column",gap:t.spacing(4)})),xd=d(Fe)(({theme:t})=>({padding:t.spacing(3,4,4),borderRadius:t.shape.borderRadius})),md=()=>{const{isBilling:t,instanceStatus:s,refetchInstanceStatus:n,refresh:o,loading:a}=Ke(),{invoices:i}=ba(),{uiConfig:{billing:r}}=W(),c=r==="pay-as-you-go"||r==="enterprise-consumption";return u.useEffect(()=>{(async()=>{await o(),n()})()},[n,o]),Bo(s)&&c&&i.length===0?e.jsxs(Wn,{children:[e.jsx(Fn,{children:"Billing"}),e.jsx(xd,{elevation:1,children:e.jsx(hd,{})})]}):c?e.jsxs(Wn,{children:[e.jsx(Fn,{children:"Usage and invoices"}),e.jsxs(gd,{children:[e.jsx(Vc,{}),e.jsx("div",{children:e.jsx(id,{})})]})]}):e.jsx("div",{children:e.jsx(ne,{header:"Billing",isLoading:a,children:e.jsx(k,{condition:t,show:e.jsx(Se,{permissions:Q,children:e.jsxs(e.Fragment,{children:[e.jsx(cc,{}),e.jsx(pc,{data:i})]})}),elseShow:e.jsx(V,{severity:"error",children:"Billing is not enabled for this instance."})})})})},jd=X("api/admin/invoices/portal"),fd=()=>{const{refetchInvoices:t,invoices:s}=ba(),[n,o]=u.useState(!1),{locationSettings:a}=Uo();return u.useEffect(()=>{t(),o(!0)},[]),e.jsx(k,{condition:s.length>0,show:e.jsx(ne,{header:e.jsx(oe,{title:"Invoices",actions:e.jsx(N,{href:jd,rel:"noreferrer",target:"_blank",endIcon:e.jsx(ki,{}),children:"Billing portal"})}),children:e.jsx("div",{children:e.jsxs($o,{children:[e.jsx(Oo,{children:e.jsxs(kt,{children:[e.jsx(de,{children:"Amount"}),e.jsx(de,{children:"Status"}),e.jsx(de,{children:"Due date"}),e.jsx(de,{children:"PDF"}),e.jsx(de,{children:"Link"})]})}),e.jsx(Ks,{children:s.map(i=>e.jsxs(kt,{style:{backgroundColor:i.status==="past-due"?"error.dark":"inherit"},children:[e.jsx(de,{style:{textAlign:"left"},children:i.amountFormatted}),e.jsx(de,{style:{textAlign:"left"},children:i.status}),e.jsx(de,{style:{textAlign:"left"},children:i.dueDate&&_o(i.dueDate,a.locale)}),e.jsx(de,{style:{textAlign:"left"},children:e.jsx("a",{href:i.invoicePDF,children:"PDF"})}),e.jsx(de,{style:{textAlign:"left"},children:e.jsx("a",{href:i.invoiceURL,target:"_blank",rel:"noreferrer",children:"Payment link"})})]},i.invoiceURL))})]})})}),elseShow:e.jsx(ne,{children:n&&"No invoices to show."})})},yd=()=>e.jsx("div",{children:e.jsx(Se,{permissions:Q,children:e.jsx(fd,{})})}),bd=()=>{const{uiConfig:t,loading:s}=W();return s?null:t.flags.UNLEASH_CLOUD?e.jsx(Hs,{to:"/admin/billing",replace:!0}):e.jsx(yd,{})},Sd=()=>e.jsxs(V,{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)."})]}),vd=()=>{const{makeRequest:t,createRequest:s,errors:n,loading:o}=pe({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}},Cd=({frontendApiOrigins:t})=>{const{setCors:s}=vd(),{setToastData:n,setToastApiError:o}=Y(),[a,i]=u.useState(qn(t)),r=jn(),c=jn(),l=async g=>{try{const p=wd(a);g.preventDefault(),await s(p),i(qn(p)),n({text:"Settings saved",type:"success"})}catch(p){o(G(p))}};return e.jsx("form",{onSubmit:l,children:e.jsxs(_,{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(se,{id:r,"aria-describedby":c,placeholder:Td,value:a,onChange:g=>i(g.target.value),multiline:!0,rows:12,variant:"outlined",fullWidth:!0,InputProps:{style:{fontFamily:"monospace",fontSize:"0.8em"}}}),e.jsx(Mo,{permission:[Pe,No]})]})})},wd=t=>t.split(/[,\n\s]+/).map(s=>s.replace(/\/$/,"")).filter(Boolean),qn=t=>(t==null?void 0:t.join(`
@@ -12,7 +12,7 @@ import{dE as So,j as e,dF as Se,dG as xn,dH as mn,dI as Pe,az as ne,aC as oe,at
12
12
  --data-raw '${JSON.stringify(j(),void 0,2)}'`,$=()=>{o(Be)},w=R=>R.length,P=R=>!(A!=null&&A.filter(B=>B.name===R).length),I=w(a)&&P(a),L=R=>{b(),P(R)||v({name:"A group with that name already exists."}),i(R)};return e.jsx(Ae,{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/concepts/rbac#user-groups",documentationLinkLabel:"Groups documentation",formatApiCode:U,children:e.jsx(Pa,{name:a,description:r,mappingsSSO:l,rootRole:x,users:p,setName:L,setDescription:c,setMappingsSSO:g,setRootRole:m,setUsers:h,errors:y,handleSubmit:S,handleCancel:$,mode:Wi,isScimGroup:!1,children:e.jsx(N,{type:"submit",variant:"contained",color:"primary",disabled:!I,"data-testid":qi,children:"Create group"})})})},gu=()=>{const t=Number(ds("groupId")),{group:s,refetchGroup:n}=hs(t);return s?e.jsx(xu,{group:s,groupId:t,refetchGroup:n}):null},xu=({group:t,groupId:s,refetchGroup:n})=>{const{refetchGroups:o}=Je(),{setToastData:a,setToastApiError:i}=Y(),{uiConfig:r}=W(),c=we(),{settings:{enabled:l}}=Bt(),g=l&&!!(t!=null&&t.scimId),{name:p,setName:h,description:x,setDescription:m,mappingsSSO:j,setMappingsSSO:b,users:y,setUsers:v,rootRole:A,setRootRole:C,getGroupPayload:D,clearErrors:S,errors:U,setErrors:$}=dn(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:w}=Je(),{updateGroup:P,loading:I}=pt(),L=async K=>{K.preventDefault(),S();const q=D();try{await P(s,q),n(),o(),c(Be),a({text:"Group updated successfully",type:"success"})}catch(he){i(G(he))}},R=()=>`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)}'`,B=()=>{c(Be)},E=K=>K.length,O=K=>!(w!=null&&w.filter(q=>q.name===K&&q.id!==s).length),H=E(p)&&O(p),J=K=>{S(),O(K)||$({name:"A group with that name already exists."}),h(K)};return e.jsx(Ae,{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/concepts/rbac#user-groups",documentationLinkLabel:"Groups documentation",formatApiCode:R,children:e.jsx(Pa,{name:p,description:x,mappingsSSO:j,users:y,rootRole:A,setName:J,setDescription:m,setMappingsSSO:b,setUsers:v,setRootRole:C,errors:U,handleSubmit:L,handleCancel:B,mode:Xs,isScimGroup:g,children:e.jsx(Te,{title:g?Tt:"",arrow:!0,children:e.jsx("div",{children:e.jsx(N,{type:"submit",variant:"contained",color:"primary",disabled:!H,"data-testid":zo,children:"Save"})})})})})},mu=d(Fe)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(2.5,4),boxShadow:"none",marginBottom:t.spacing(2),fontSize:t.fontSizes.smallBody})),ju=d("div")(({theme:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),fu=d("div")(({theme:t})=>({display:"flex"})),yu=d("span")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginLeft:t.spacing(1)})),bu=({title:t,description:s,actions:n})=>(Zt(t),e.jsxs(mu,{children:[e.jsxs(ju,{children:[e.jsx(T,{variant:"h1",component:"h1",children:t}),e.jsx(fu,{children:n})]}),e.jsx(k,{condition:!!(s!=null&&s.length),show:e.jsxs(e.Fragment,{children:["Description:",e.jsx(yu,{children:s})]})})]})),Su=({open:t,setOpen:s,user:n,group:o})=>{const{refetchGroup:a}=hs(o.id),{updateGroup:i}=pt(),{setToastData:r,setToastApiError:c}=Y(),l=async()=>{try{const p={...o,users:o.users.filter(({id:h})=>h!==(n==null?void 0:n.id)).map(({id:h})=>({user:{id:h}}))};await i(o.id,p),a(),s(!1),r({text:"User removed from group successfully",type:"success"})}catch(p){c(G(p))}},g=(n==null?void 0:n.name)||(n==null?void 0:n.username)||(n==null?void 0:n.email);return e.jsx(ee,{open:t&&!!n,primaryButtonText:"Remove user",secondaryButtonText:"Cancel",onClick:l,onClose:()=>{s(!1)},title:"Remove user from group?",children:e.jsxs(T,{children:["Do you really want to remove ",e.jsx("strong",{children:g})," from"," ",e.jsx("strong",{children:o.name}),"? ",e.jsx("strong",{children:g})," will lose all access rights granted by this group."]})})},vu=Array(15).fill({name:"Name of the user",username:"Username of the user"}),Cu={id:"joinedAt",desc:!0},{value:zn,setValue:wu}=Yi("Group:v1",Cu),Tu=()=>{const t=Number(ds("groupId")),s=Dt(),n=je(s.breakpoints.down("md")),{group:o,loading:a}=hs(t),[i,r]=u.useState(!1),[c,l]=u.useState(!1),[g,p]=u.useState(!1),[h,x]=u.useState(),{settings:{enabled:m}}=Bt(),j=m&&!!(o!=null&&o.scimId),b=u.useMemo(()=>[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:B}})=>e.jsx(te,{children:e.jsx(We,{user:B})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:B=>B.name||"",Cell:({value:B,row:{original:E}})=>e.jsx(Ce,{value:B,subtitle:E.email||E.username}),minWidth:100,searchable:!0},{Header:"Joined",accessor:"joinedAt",Cell:me,maxWidth:150},{id:"createdBy",Header:"Added by",accessor:"createdBy",Cell:Ce,minWidth:90,searchable:!0},{Header:"Last login",accessor:"seenAt",Cell:Ne,maxWidth:150},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:B}})=>e.jsx(Kt,{children:e.jsx(Te,{title:j?Tt:"Remove user from group",arrow:!0,describeChild:!0,children:e.jsx("span",{children:e.jsx(Re,{"data-testid":`${Gi}-${B.id}`,onClick:()=>{x(B),p(!0)},disabled:j,children:e.jsx(Ee,{})})})})}),maxWidth:100,disableSortBy:!0},{accessor:B=>B.username||"",Header:"Username",searchable:!0},{accessor:B=>B.email||"",Header:"Email",searchable:!0}],[x,p]),[y,v]=Ho(),[A]=u.useState(()=>({sortBy:[{id:y.get("sort")||zn.id,desc:y.has("order")?y.get("order")==="desc":zn.desc}],hiddenColumns:["Username","Email"],globalFilter:y.get("search")||""})),[C,D]=u.useState(A.globalFilter),{data:S,getSearchText:U,getSearchContext:$}=dt(b,C,(o==null?void 0:o.users)??[]),w=u.useMemo(()=>(S==null?void 0:S.length)===0&&a?vu:S,[S,a]),{headerGroups:P,rows:I,prepareRow:L,state:{sortBy:R}}=F.useTable({columns:b,data:w,initialState:A,sortTypes:fe,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},F.useSortBy,F.useFlexLayout);return u.useEffect(()=>{const B={};B.sort=R[0].id,R[0].desc&&(B.order="desc"),C&&(B.search=C),v(B,{replace:!0}),wu({id:R[0].id,desc:R[0].desc||!1})},[R,C,v]),e.jsx(k,{condition:!!o,show:e.jsxs(e.Fragment,{children:[e.jsx(bu,{title:o==null?void 0:o.name,description:o==null?void 0:o.description,actions:e.jsxs(e.Fragment,{children:[e.jsx($e,{"data-testid":zi,to:`/admin/groups/${t}/edit`,component:ae,"data-loading":!0,permission:Q,tooltipProps:{title:j?Tt:"Edit group"},children:e.jsx(Rt,{})}),e.jsx($e,{"data-testid":Hi,"data-loading":!0,onClick:()=>r(!0),permission:Q,tooltipProps:{title:"Delete group"},children:e.jsx(Ee,{})})]})}),e.jsxs(ne,{isLoading:a,header:e.jsx(oe,{secondary:!0,title:`Users (${I.length<w.length?`${I.length} of ${w.length}`:w.length})`,actions:e.jsxs(e.Fragment,{children:[e.jsx(k,{condition:!n,show:e.jsxs(e.Fragment,{children:[e.jsx(ue,{initialValue:C,onChange:D,hasFilters:!0,getSearchContext:$}),e.jsx(oe.Divider,{})]})}),e.jsx(Qs,{"data-testid":Vi,onClick:()=>{l(!0)},maxWidth:"700px",Icon:cs,permission:Q,disabled:j,tooltipProps:{title:j?Tt:""},children:"Edit users"})]}),children:e.jsx(k,{condition:n,show:e.jsx(ue,{initialValue:C,onChange:D,hasFilters:!0,getSearchContext:$})})}),children:[e.jsx(qe,{value:U(C),children:e.jsx(ye,{rows:I,headerGroups:P,prepareRow:L})}),e.jsx(k,{condition:I.length===0,show:e.jsx(k,{condition:(C==null?void 0:C.length)>0,show:e.jsxs(ce,{children:["No users found matching “",C,"” in this group."]}),elseShow:e.jsx(ce,{children:"This group is empty. Get started by adding a user to the group."})})}),e.jsx(Ia,{open:i,setOpen:r,group:o}),e.jsx(Da,{open:c,setOpen:l,group:o}),e.jsx(Su,{open:g,setOpen:p,user:h,group:o})]})]})})},ku=()=>{const{uiConfig:t,isEnterprise:s}=W();return s()||t.flags[Ji]===!0?e.jsx("div",{children:e.jsx(Se,{permissions:Pe,children:e.jsxs(it,{children:[e.jsx(M,{index:!0,element:e.jsx(nu,{})}),e.jsx(M,{path:"create-group",element:e.jsx(hu,{})}),e.jsx(M,{path:":groupId/edit",element:e.jsx(gu,{})}),e.jsx(M,{path:":groupId",element:e.jsx(Tu,{})})]})})}):e.jsx(at,{feature:"groups",page:!0})},La=()=>{const{data:t,error:s,mutate:n}=ve(X("api/admin/instance-admin/statistics"),Eu);return u.useMemo(()=>({stats:t,loading:!s&&!t,refetchGroup:()=>n(),error:s}),[t,s,n])},Eu=t=>fetch(t).then(le("Instance Stats")).then(s=>s.json()),Au=()=>{var i,r,c;const{stats:t}=La();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,g)=>l+g,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(ne,{header:e.jsx(oe,{title:"Instance Statistics"}),children:e.jsxs(yn,{sx:{display:"grid",gap:4},children:[e.jsxs($o,{"aria-label":"Instance statistics",children:[e.jsx(Oo,{children:e.jsxs(kt,{children:[e.jsx(de,{children:"Field"}),e.jsx(de,{align:"right",children:"Value"})]})}),e.jsx(Ks,{children:a.map(l=>e.jsxs(kt,{sx:{"&:hover":{backgroundColor:"unset !important"}},children:[e.jsx(de,{component:"th",scope:"row",children:e.jsx(yn,{component:"span",sx:g=>({marginLeft:l.offset?g.spacing(2):0}),children:l.title})}),e.jsx(de,{align:"right",children:l.value})]},l.title))})]}),e.jsx("span",{style:{textAlign:"center"},children:e.jsx(N,{startIcon:e.jsx(Vo,{}),"aria-label":"Download instance statistics",color:"primary",variant:"contained",target:"_blank",rel:"noreferrer",href:X("/api/admin/instance-admin/statistics/csv"),children:"Download"})})]})})},Ru=()=>e.jsx("div",{children:e.jsx(Au,{})}),Du=d("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),Iu=d(_)(()=>({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"})),Pu=d(_)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),Lu=d("p")(({theme:t})=>({display:"table-cell",fontWeight:t.fontWeight.bold,paddingTop:t.spacing(2)})),Bu=d("p")(({theme:t})=>({display:"table-cell",paddingTop:t.spacing(2),paddingLeft:t.spacing(4)})),Uu=d("div")(({theme:t})=>({display:"table-cell",width:"75%",paddingTop:t.spacing(2),paddingBottom:t.spacing(2)})),$u=d("div")(({theme:t})=>({display:"table-cell"})),Ou=d("span")(({theme:t})=>({display:"block",textAlign:"right",color:t.palette.neutral.dark})),_u=d("div")(({theme:t})=>({maxWidth:t.spacing(50),color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody})),Mu=d("div")(()=>({display:"table-row"})),Hn=d("div")(()=>({display:"table"})),Nu=d("div")(()=>({display:"table-cell"})),Fu=({changeInfoText:t,variablesText:s,dependsOnText:n})=>e.jsxs(_u,{children:[e.jsx(Vn,{children:t}),e.jsx(Wu,{children:e.jsx("div",{children:s})}),e.jsx(k,{condition:!!n,show:e.jsx(Vn,{children:n})})]}),Wu=d("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})),Vn=d("p")(({theme:t})=>({color:t.palette.text.primary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1)})),Yn=({title:t,infoText:s,concreteDetails:n,enabled:o,changeInfoText:a,variablesText:i,dependsOnText:r})=>e.jsxs(Du,{children:[e.jsxs(Iu,{children:[e.jsx("b",{children:t}),e.jsx($u,{children:e.jsx(k,{condition:o,show:e.jsx(Le,{color:"success",icon:e.jsx(Ys,{}),children:"Data is collected"}),elseShow:e.jsx(Le,{color:"neutral",icon:e.jsx(Ki,{}),children:"No data is collected"})})})]}),e.jsxs(Pu,{children:[e.jsxs(Hn,{children:[e.jsx(Uu,{children:s}),e.jsx(Nu,{children:e.jsx(Ou,{children:e.jsx(is,{tooltip:e.jsx(Fu,{changeInfoText:a,variablesText:i,dependsOnText:r}),children:o?"How to disable collecting data?":"How to enable collecting data?"})})})]}),e.jsx(Hn,{children:Object.entries(n).map(([c,l])=>e.jsxs(Mu,{children:[e.jsx(Lu,{children:c}),e.jsx(Bu,{children:l})]},c))})]})]}),qu=()=>{const{data:t,error:s,mutate:n}=ve(X("api/admin/telemetry/settings"),Gu);return u.useMemo(()=>({settings:t,loading:!s&&!t,refetchGroup:()=>n(),error:s}),[t,s,n])},Gu=t=>fetch(t).then(le("Telemetry Settings")).then(s=>s.json()),zu=d(_)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),Ps={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"}},Ls={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"}},Jn={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."}},Kn={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."}},Hu=()=>{const{settings:t}=qu(),{loading:s}=W();if(s)return null;const n=t!=null&&t.versionInfoCollectionEnabled?Jn.enabled:Jn.disabled,o=t!=null&&t.featureInfoCollectionEnabled?Kn.enabled:Kn.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(ne,{header:e.jsx(oe,{title:"Instance Privacy"}),children:e.jsxs(zu,{children:[e.jsx(Yn,{title:Ps.title,infoText:Ps.infoText,concreteDetails:Ps.concreteDetails,enabled:t==null?void 0:t.versionInfoCollectionEnabled,changeInfoText:n.changeInfoText,variablesText:n.environmentVariables}),e.jsx(Yn,{title:Ls.title,infoText:Ls.infoText,concreteDetails:Ls.concreteDetails,enabled:(t==null?void 0:t.featureInfoCollectionEnabled)&&(t==null?void 0:t.versionInfoCollectionEnabled),changeInfoText:o.changeInfoText,variablesText:o.environmentVariables,dependsOnText:a})]})})},Vu=()=>e.jsx(V,{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."]})}),Yu=()=>{const{data:t,error:s,mutate:n}=ve(X("api/admin/maintenance"),Ju);return u.useMemo(()=>({enabled:!!(t!=null&&t.enabled),loading:!s&&!t,refetchMaintenance:n,error:s}),[t,s,n])},Ju=t=>fetch(t).then(le("Maintenance")).then(s=>s.json()),Ku=()=>{const{makeRequest:t,createRequest:s,errors:n,loading:o}=pe({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}},Zu=d("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),Qu=d(_)({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"}),Xu=d(_)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),ep=d(T)(({theme:t})=>({fontSize:t.fontSizes.smallBody})),tp=()=>{const{enabled:t,refetchMaintenance:s}=Yu(),{refetch:n}=W(),{toggleMaintenance:o}=Ku(),{trackEvent:a}=as(),{setToastData:i}=Y(),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(Zu,{children:[e.jsxs(Qu,{children:[e.jsx("b",{children:"Maintenance Mode"}),e.jsx(re,{sx:{margin:0},control:e.jsx(xe,{onChange:r,value:t,name:"enabled",checked:t}),label:e.jsx(ep,{children:t?"Enabled":"Disabled"})})]}),e.jsx(Xu,{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."})]})},sp=()=>e.jsx("div",{children:e.jsx(Se,{permissions:[Q,Zi],children:e.jsx(op,{})})}),np=d(_)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),op=()=>{const{loading:t}=W();return t?null:e.jsx(ne,{header:e.jsx(oe,{title:"Maintenance"}),children:e.jsxs(np,{children:[e.jsx(Vu,{}),e.jsx(tp,{})]})})},ap=d(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"}})),Ba=({to:t,children:s})=>e.jsx(ap,{to:t,children:s}),ip=u.lazy(()=>ut(()=>import("./NetworkOverview-BiLOuQ4c.js"),[])),rp=u.lazy(()=>ut(()=>import("./NetworkTraffic-DONL5oIx.js"),[])),lp=u.lazy(()=>ut(()=>import("./NetworkTrafficUsage-DjQiYq0S.js"),[])),cp=u.lazy(()=>ut(()=>import("./BackendConnections-CRh8Vxoe.js"),[])),dp=u.lazy(()=>ut(()=>import("./FrontendNetworkTrafficUsage-CbxdFXH7.js"),[])),Zn=[{label:"Overview",path:"/admin/network"},{label:"Traffic",path:"/admin/network/traffic"}],up=[{label:"Data Usage",path:"/admin/network/data-usage"}],pp=[{label:"Backend Connections",path:"/admin/network/backend-connections"},{label:"Frontend Traffic",path:"/admin/network/frontend-data-usage"}],hp=()=>{const{pathname:t}=zs(),n=Ht("consumptionModelUI")?[...Zn,...pp]:[...Zn,...up];return e.jsx("div",{children:e.jsx(ne,{withTabs:!0,header:e.jsx(Yo,{value:t,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:n.map(({label:o,path:a})=>e.jsx(Jo,{value:a,label:e.jsx(Ba,{to:a,children:e.jsx("span",{children:o})}),sx:{padding:0}},o))}),children:e.jsxs(it,{children:[e.jsx(M,{path:"*",element:e.jsx(ip,{})}),e.jsx(M,{path:"traffic",element:e.jsx(rp,{})}),e.jsx(M,{path:"connected-edges",element:e.jsx(Hs,{to:"/admin/enterprise-edge",replace:!0})}),e.jsx(M,{path:"data-usage",element:e.jsx(lp,{})}),e.jsx(M,{path:"backend-connections",element:e.jsx(cp,{})}),e.jsx(M,{path:"frontend-data-usage",element:e.jsx(dp,{})})]})})})},gp=d(_)(()=>({display:"flex",justifyContent:"center"})),xp=({role:t,onEdit:s,onDelete:n})=>{const o=ze.includes(t.type);return e.jsxs(gp,{children:[e.jsx($e,{"data-loading":!0,onClick:s,permission:Q,disabled:o,tooltipProps:{title:o?"You cannot edit a predefined role":"Edit role"},children:e.jsx(Rt,{})}),e.jsx($e,{"data-loading":!0,onClick:n,permission:Q,disabled:o,tooltipProps:{title:o?"You cannot remove a predefined role":"Remove role"},children:e.jsx(Ee,{})})]})},mp=d(Le)(({theme:t})=>({marginLeft:t.spacing(1)})),jp=({role:t})=>e.jsx(Ce,{value:t.name,subtitle:t.description,afterTitle:e.jsx(k,{condition:ze.includes(t.type),show:e.jsx(mp,{color:"success",children:"Predefined"})})}),fp=({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(Ce,{value:r.name,subtitle:r.email||r.username})},{Header:"Created",accessor:"createdAt",Cell:me,width:120,maxWidth:120},{id:"last-login",Header:"Last login",accessor:"seenAt",Cell:Ne,maxWidth:150}],[]),{headerGroups:o,rows:a,prepareRow:i}=F.useTable({columns:n,data:t,initialState:s,sortTypes:fe,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},F.useSortBy,F.useFlexLayout);return e.jsx(ye,{rows:a,headerGroups:o,prepareRow:i})},yp=d(T)(({theme:t})=>({fontSize:t.fontSizes.smallerBody})),Ua=({serviceAccount:t,value:s,onCreateToken:n})=>{var a,i,r;const{searchQuery:o}=Zs();return!t.tokens||t.tokens.length===0?n?e.jsx(Ko,{title:"Create token",onClick:n}):e.jsx(te,{children:"0 tokens"}):e.jsx(te,{children:e.jsx(is,{tooltip:e.jsx(e.Fragment,{children:(a=t.tokens)==null?void 0:a.map(({id:c,description:l})=>e.jsx(yp,{children:e.jsx(Vt,{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`})})},bp=({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(Ce,{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)}'`,B=()=>{c(Be)},E=K=>K.length,O=K=>!(w!=null&&w.filter(q=>q.name===K&&q.id!==s).length),H=E(p)&&O(p),J=K=>{S(),O(K)||$({name:"A group with that name already exists."}),h(K)};return e.jsx(Ae,{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/concepts/rbac#user-groups",documentationLinkLabel:"Groups documentation",formatApiCode:R,children:e.jsx(Pa,{name:p,description:x,mappingsSSO:j,users:y,rootRole:A,setName:J,setDescription:m,setMappingsSSO:b,setUsers:v,setRootRole:C,errors:U,handleSubmit:L,handleCancel:B,mode:Xs,isScimGroup:g,children:e.jsx(Te,{title:g?Tt:"",arrow:!0,children:e.jsx("div",{children:e.jsx(N,{type:"submit",variant:"contained",color:"primary",disabled:!H,"data-testid":zo,children:"Save"})})})})})},mu=d(Fe)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(2.5,4),boxShadow:"none",marginBottom:t.spacing(2),fontSize:t.fontSizes.smallBody})),ju=d("div")(({theme:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),fu=d("div")(({theme:t})=>({display:"flex"})),yu=d("span")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginLeft:t.spacing(1)})),bu=({title:t,description:s,actions:n})=>(Zt(t),e.jsxs(mu,{children:[e.jsxs(ju,{children:[e.jsx(T,{variant:"h1",component:"h1",children:t}),e.jsx(fu,{children:n})]}),e.jsx(k,{condition:!!(s!=null&&s.length),show:e.jsxs(e.Fragment,{children:["Description:",e.jsx(yu,{children:s})]})})]})),Su=({open:t,setOpen:s,user:n,group:o})=>{const{refetchGroup:a}=hs(o.id),{updateGroup:i}=pt(),{setToastData:r,setToastApiError:c}=Y(),l=async()=>{try{const p={...o,users:o.users.filter(({id:h})=>h!==(n==null?void 0:n.id)).map(({id:h})=>({user:{id:h}}))};await i(o.id,p),a(),s(!1),r({text:"User removed from group successfully",type:"success"})}catch(p){c(G(p))}},g=(n==null?void 0:n.name)||(n==null?void 0:n.username)||(n==null?void 0:n.email);return e.jsx(ee,{open:t&&!!n,primaryButtonText:"Remove user",secondaryButtonText:"Cancel",onClick:l,onClose:()=>{s(!1)},title:"Remove user from group?",children:e.jsxs(T,{children:["Do you really want to remove ",e.jsx("strong",{children:g})," from"," ",e.jsx("strong",{children:o.name}),"? ",e.jsx("strong",{children:g})," will lose all access rights granted by this group."]})})},vu=Array(15).fill({name:"Name of the user",username:"Username of the user"}),Cu={id:"joinedAt",desc:!0},{value:zn,setValue:wu}=Yi("Group:v1",Cu),Tu=()=>{const t=Number(ds("groupId")),s=Dt(),n=je(s.breakpoints.down("md")),{group:o,loading:a}=hs(t),[i,r]=u.useState(!1),[c,l]=u.useState(!1),[g,p]=u.useState(!1),[h,x]=u.useState(),{settings:{enabled:m}}=Bt(),j=m&&!!(o!=null&&o.scimId),b=u.useMemo(()=>[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:B}})=>e.jsx(te,{children:e.jsx(We,{user:B})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:B=>B.name||"",Cell:({value:B,row:{original:E}})=>e.jsx(Ce,{value:B,subtitle:E.email||E.username}),minWidth:100,searchable:!0},{Header:"Joined",accessor:"joinedAt",Cell:me,maxWidth:150},{id:"createdBy",Header:"Added by",accessor:"createdBy",Cell:Ce,minWidth:90,searchable:!0},{Header:"Last login",accessor:"seenAt",Cell:Ne,maxWidth:150},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:B}})=>e.jsx(Kt,{children:e.jsx(Te,{title:j?Tt:"Remove user from group",arrow:!0,describeChild:!0,children:e.jsx("span",{children:e.jsx(Re,{"data-testid":`${Gi}-${B.id}`,onClick:()=>{x(B),p(!0)},disabled:j,children:e.jsx(Ee,{})})})})}),maxWidth:100,disableSortBy:!0},{accessor:B=>B.username||"",Header:"Username",searchable:!0},{accessor:B=>B.email||"",Header:"Email",searchable:!0}],[x,p]),[y,v]=Ho(),[A]=u.useState(()=>({sortBy:[{id:y.get("sort")||zn.id,desc:y.has("order")?y.get("order")==="desc":zn.desc}],hiddenColumns:["Username","Email"],globalFilter:y.get("search")||""})),[C,D]=u.useState(A.globalFilter),{data:S,getSearchText:U,getSearchContext:$}=dt(b,C,(o==null?void 0:o.users)??[]),w=u.useMemo(()=>(S==null?void 0:S.length)===0&&a?vu:S,[S,a]),{headerGroups:P,rows:I,prepareRow:L,state:{sortBy:R}}=F.useTable({columns:b,data:w,initialState:A,sortTypes:fe,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},F.useSortBy,F.useFlexLayout);return u.useEffect(()=>{const B={};B.sort=R[0].id,R[0].desc&&(B.order="desc"),C&&(B.search=C),v(B,{replace:!0}),wu({id:R[0].id,desc:R[0].desc||!1})},[R,C,v]),e.jsx(k,{condition:!!o,show:e.jsxs(e.Fragment,{children:[e.jsx(bu,{title:o==null?void 0:o.name,description:o==null?void 0:o.description,actions:e.jsxs(e.Fragment,{children:[e.jsx($e,{"data-testid":zi,to:`/admin/groups/${t}/edit`,component:ae,"data-loading":!0,permission:Q,tooltipProps:{title:j?Tt:"Edit group"},children:e.jsx(Rt,{})}),e.jsx($e,{"data-testid":Hi,"data-loading":!0,onClick:()=>r(!0),permission:Q,tooltipProps:{title:"Delete group"},children:e.jsx(Ee,{})})]})}),e.jsxs(ne,{isLoading:a,header:e.jsx(oe,{secondary:!0,title:`Users (${I.length<w.length?`${I.length} of ${w.length}`:w.length})`,actions:e.jsxs(e.Fragment,{children:[e.jsx(k,{condition:!n,show:e.jsxs(e.Fragment,{children:[e.jsx(ue,{initialValue:C,onChange:D,hasFilters:!0,getSearchContext:$}),e.jsx(oe.Divider,{})]})}),e.jsx(Qs,{"data-testid":Vi,onClick:()=>{l(!0)},maxWidth:"700px",Icon:cs,permission:Q,disabled:j,tooltipProps:{title:j?Tt:""},children:"Edit users"})]}),children:e.jsx(k,{condition:n,show:e.jsx(ue,{initialValue:C,onChange:D,hasFilters:!0,getSearchContext:$})})}),children:[e.jsx(qe,{value:U(C),children:e.jsx(ye,{rows:I,headerGroups:P,prepareRow:L})}),e.jsx(k,{condition:I.length===0,show:e.jsx(k,{condition:(C==null?void 0:C.length)>0,show:e.jsxs(ce,{children:["No users found matching “",C,"” in this group."]}),elseShow:e.jsx(ce,{children:"This group is empty. Get started by adding a user to the group."})})}),e.jsx(Ia,{open:i,setOpen:r,group:o}),e.jsx(Da,{open:c,setOpen:l,group:o}),e.jsx(Su,{open:g,setOpen:p,user:h,group:o})]})]})})},ku=()=>{const{uiConfig:t,isEnterprise:s}=W();return s()||t.flags[Ji]===!0?e.jsx("div",{children:e.jsx(Se,{permissions:Pe,children:e.jsxs(it,{children:[e.jsx(M,{index:!0,element:e.jsx(nu,{})}),e.jsx(M,{path:"create-group",element:e.jsx(hu,{})}),e.jsx(M,{path:":groupId/edit",element:e.jsx(gu,{})}),e.jsx(M,{path:":groupId",element:e.jsx(Tu,{})})]})})}):e.jsx(at,{feature:"groups",page:!0})},La=()=>{const{data:t,error:s,mutate:n}=ve(X("api/admin/instance-admin/statistics"),Eu);return u.useMemo(()=>({stats:t,loading:!s&&!t,refetchGroup:()=>n(),error:s}),[t,s,n])},Eu=t=>fetch(t).then(le("Instance Stats")).then(s=>s.json()),Au=()=>{var i,r,c;const{stats:t}=La();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,g)=>l+g,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(ne,{header:e.jsx(oe,{title:"Instance Statistics"}),children:e.jsxs(yn,{sx:{display:"grid",gap:4},children:[e.jsxs($o,{"aria-label":"Instance statistics",children:[e.jsx(Oo,{children:e.jsxs(kt,{children:[e.jsx(de,{children:"Field"}),e.jsx(de,{align:"right",children:"Value"})]})}),e.jsx(Ks,{children:a.map(l=>e.jsxs(kt,{sx:{"&:hover":{backgroundColor:"unset !important"}},children:[e.jsx(de,{component:"th",scope:"row",children:e.jsx(yn,{component:"span",sx:g=>({marginLeft:l.offset?g.spacing(2):0}),children:l.title})}),e.jsx(de,{align:"right",children:l.value})]},l.title))})]}),e.jsx("span",{style:{textAlign:"center"},children:e.jsx(N,{startIcon:e.jsx(Vo,{}),"aria-label":"Download instance statistics",color:"primary",variant:"contained",target:"_blank",rel:"noreferrer",href:X("/api/admin/instance-admin/statistics/csv"),children:"Download"})})]})})},Ru=()=>e.jsx("div",{children:e.jsx(Au,{})}),Du=d("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),Iu=d(_)(()=>({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"})),Pu=d(_)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),Lu=d("p")(({theme:t})=>({display:"table-cell",fontWeight:t.fontWeight.bold,paddingTop:t.spacing(2)})),Bu=d("p")(({theme:t})=>({display:"table-cell",paddingTop:t.spacing(2),paddingLeft:t.spacing(4)})),Uu=d("div")(({theme:t})=>({display:"table-cell",width:"75%",paddingTop:t.spacing(2),paddingBottom:t.spacing(2)})),$u=d("div")(({theme:t})=>({display:"table-cell"})),Ou=d("span")(({theme:t})=>({display:"block",textAlign:"right",color:t.palette.neutral.dark})),_u=d("div")(({theme:t})=>({maxWidth:t.spacing(50),color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody})),Mu=d("div")(()=>({display:"table-row"})),Hn=d("div")(()=>({display:"table"})),Nu=d("div")(()=>({display:"table-cell"})),Fu=({changeInfoText:t,variablesText:s,dependsOnText:n})=>e.jsxs(_u,{children:[e.jsx(Vn,{children:t}),e.jsx(Wu,{children:e.jsx("div",{children:s})}),e.jsx(k,{condition:!!n,show:e.jsx(Vn,{children:n})})]}),Wu=d("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})),Vn=d("p")(({theme:t})=>({color:t.palette.text.primary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1)})),Yn=({title:t,infoText:s,concreteDetails:n,enabled:o,changeInfoText:a,variablesText:i,dependsOnText:r})=>e.jsxs(Du,{children:[e.jsxs(Iu,{children:[e.jsx("b",{children:t}),e.jsx($u,{children:e.jsx(k,{condition:o,show:e.jsx(Le,{color:"success",icon:e.jsx(Ys,{}),children:"Data is collected"}),elseShow:e.jsx(Le,{color:"neutral",icon:e.jsx(Ki,{}),children:"No data is collected"})})})]}),e.jsxs(Pu,{children:[e.jsxs(Hn,{children:[e.jsx(Uu,{children:s}),e.jsx(Nu,{children:e.jsx(Ou,{children:e.jsx(is,{tooltip:e.jsx(Fu,{changeInfoText:a,variablesText:i,dependsOnText:r}),children:o?"How to disable collecting data?":"How to enable collecting data?"})})})]}),e.jsx(Hn,{children:Object.entries(n).map(([c,l])=>e.jsxs(Mu,{children:[e.jsx(Lu,{children:c}),e.jsx(Bu,{children:l})]},c))})]})]}),qu=()=>{const{data:t,error:s,mutate:n}=ve(X("api/admin/telemetry/settings"),Gu);return u.useMemo(()=>({settings:t,loading:!s&&!t,refetchGroup:()=>n(),error:s}),[t,s,n])},Gu=t=>fetch(t).then(le("Telemetry Settings")).then(s=>s.json()),zu=d(_)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),Ps={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"}},Ls={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"}},Jn={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."}},Kn={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."}},Hu=()=>{const{settings:t}=qu(),{loading:s}=W();if(s)return null;const n=t!=null&&t.versionInfoCollectionEnabled?Jn.enabled:Jn.disabled,o=t!=null&&t.featureInfoCollectionEnabled?Kn.enabled:Kn.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(ne,{header:e.jsx(oe,{title:"Instance Privacy"}),children:e.jsxs(zu,{children:[e.jsx(Yn,{title:Ps.title,infoText:Ps.infoText,concreteDetails:Ps.concreteDetails,enabled:t==null?void 0:t.versionInfoCollectionEnabled,changeInfoText:n.changeInfoText,variablesText:n.environmentVariables}),e.jsx(Yn,{title:Ls.title,infoText:Ls.infoText,concreteDetails:Ls.concreteDetails,enabled:(t==null?void 0:t.featureInfoCollectionEnabled)&&(t==null?void 0:t.versionInfoCollectionEnabled),changeInfoText:o.changeInfoText,variablesText:o.environmentVariables,dependsOnText:a})]})})},Vu=()=>e.jsx(V,{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."]})}),Yu=()=>{const{data:t,error:s,mutate:n}=ve(X("api/admin/maintenance"),Ju);return u.useMemo(()=>({enabled:!!(t!=null&&t.enabled),loading:!s&&!t,refetchMaintenance:n,error:s}),[t,s,n])},Ju=t=>fetch(t).then(le("Maintenance")).then(s=>s.json()),Ku=()=>{const{makeRequest:t,createRequest:s,errors:n,loading:o}=pe({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}},Zu=d("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),Qu=d(_)({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"}),Xu=d(_)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),ep=d(T)(({theme:t})=>({fontSize:t.fontSizes.smallBody})),tp=()=>{const{enabled:t,refetchMaintenance:s}=Yu(),{refetch:n}=W(),{toggleMaintenance:o}=Ku(),{trackEvent:a}=as(),{setToastData:i}=Y(),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(Zu,{children:[e.jsxs(Qu,{children:[e.jsx("b",{children:"Maintenance Mode"}),e.jsx(re,{sx:{margin:0},control:e.jsx(xe,{onChange:r,value:t,name:"enabled",checked:t}),label:e.jsx(ep,{children:t?"Enabled":"Disabled"})})]}),e.jsx(Xu,{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."})]})},sp=()=>e.jsx("div",{children:e.jsx(Se,{permissions:[Q,Zi],children:e.jsx(op,{})})}),np=d(_)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),op=()=>{const{loading:t}=W();return t?null:e.jsx(ne,{header:e.jsx(oe,{title:"Maintenance"}),children:e.jsxs(np,{children:[e.jsx(Vu,{}),e.jsx(tp,{})]})})},ap=d(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"}})),Ba=({to:t,children:s})=>e.jsx(ap,{to:t,children:s}),ip=u.lazy(()=>ut(()=>import("./NetworkOverview-D8wtNaRF.js"),[])),rp=u.lazy(()=>ut(()=>import("./NetworkTraffic-3cnRG5P0.js"),[])),lp=u.lazy(()=>ut(()=>import("./NetworkTrafficUsage-CSiuPn9W.js"),[])),cp=u.lazy(()=>ut(()=>import("./BackendConnections-B2fwWxNM.js"),[])),dp=u.lazy(()=>ut(()=>import("./FrontendNetworkTrafficUsage-C6ZZ-igE.js"),[])),Zn=[{label:"Overview",path:"/admin/network"},{label:"Traffic",path:"/admin/network/traffic"}],up=[{label:"Data Usage",path:"/admin/network/data-usage"}],pp=[{label:"Backend Connections",path:"/admin/network/backend-connections"},{label:"Frontend Traffic",path:"/admin/network/frontend-data-usage"}],hp=()=>{const{pathname:t}=zs(),n=Ht("consumptionModelUI")?[...Zn,...pp]:[...Zn,...up];return e.jsx("div",{children:e.jsx(ne,{withTabs:!0,header:e.jsx(Yo,{value:t,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:n.map(({label:o,path:a})=>e.jsx(Jo,{value:a,label:e.jsx(Ba,{to:a,children:e.jsx("span",{children:o})}),sx:{padding:0}},o))}),children:e.jsxs(it,{children:[e.jsx(M,{path:"*",element:e.jsx(ip,{})}),e.jsx(M,{path:"traffic",element:e.jsx(rp,{})}),e.jsx(M,{path:"connected-edges",element:e.jsx(Hs,{to:"/admin/enterprise-edge",replace:!0})}),e.jsx(M,{path:"data-usage",element:e.jsx(lp,{})}),e.jsx(M,{path:"backend-connections",element:e.jsx(cp,{})}),e.jsx(M,{path:"frontend-data-usage",element:e.jsx(dp,{})})]})})})},gp=d(_)(()=>({display:"flex",justifyContent:"center"})),xp=({role:t,onEdit:s,onDelete:n})=>{const o=ze.includes(t.type);return e.jsxs(gp,{children:[e.jsx($e,{"data-loading":!0,onClick:s,permission:Q,disabled:o,tooltipProps:{title:o?"You cannot edit a predefined role":"Edit role"},children:e.jsx(Rt,{})}),e.jsx($e,{"data-loading":!0,onClick:n,permission:Q,disabled:o,tooltipProps:{title:o?"You cannot remove a predefined role":"Remove role"},children:e.jsx(Ee,{})})]})},mp=d(Le)(({theme:t})=>({marginLeft:t.spacing(1)})),jp=({role:t})=>e.jsx(Ce,{value:t.name,subtitle:t.description,afterTitle:e.jsx(k,{condition:ze.includes(t.type),show:e.jsx(mp,{color:"success",children:"Predefined"})})}),fp=({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(Ce,{value:r.name,subtitle:r.email||r.username})},{Header:"Created",accessor:"createdAt",Cell:me,width:120,maxWidth:120},{id:"last-login",Header:"Last login",accessor:"seenAt",Cell:Ne,maxWidth:150}],[]),{headerGroups:o,rows:a,prepareRow:i}=F.useTable({columns:n,data:t,initialState:s,sortTypes:fe,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},F.useSortBy,F.useFlexLayout);return e.jsx(ye,{rows:a,headerGroups:o,prepareRow:i})},yp=d(T)(({theme:t})=>({fontSize:t.fontSizes.smallerBody})),Ua=({serviceAccount:t,value:s,onCreateToken:n})=>{var a,i,r;const{searchQuery:o}=Zs();return!t.tokens||t.tokens.length===0?n?e.jsx(Ko,{title:"Create token",onClick:n}):e.jsx(te,{children:"0 tokens"}):e.jsx(te,{children:e.jsx(is,{tooltip:e.jsx(e.Fragment,{children:(a=t.tokens)==null?void 0:a.map(({id:c,description:l})=>e.jsx(yp,{children:e.jsx(Vt,{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`})})},bp=({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(Ce,{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(Ua,{serviceAccount:r,value:c}),maxWidth:100},{Header:"Created",accessor:"createdAt",Cell:me,width:120,maxWidth:120},{id:"seenAt",Header:"Last seen",accessor:r=>{var c;return(c=r.tokens.sort((l,g)=>{const p=new Date(l.seenAt||0),h=new Date(g.seenAt||0);return(h==null?void 0:h.getTime())-(p==null?void 0:p.getTime())})[0])==null?void 0:c.seenAt},Cell:Ne,maxWidth:150}],[]),{headerGroups:o,rows:a,prepareRow:i}=F.useTable({columns:n,data:t,initialState:s,sortTypes:fe,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},F.useSortBy,F.useFlexLayout);return e.jsx(ye,{rows:a,headerGroups:o,prepareRow:i})},Sp=({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(Ce,{value:r.name,subtitle:r.description})},{Header:"Created",accessor:"createdAt",Cell:me,width:120,maxWidth:120},{id:"users",Header:"Users",accessor:r=>r.users.length===1?"1 user":`${r.users.length} users`,Cell:te,maxWidth:150}],[]),{headerGroups:o,rows:a,prepareRow:i}=F.useTable({columns:n,data:t,initialState:s,sortTypes:fe,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},F.useSortBy,F.useFlexLayout);return e.jsx(ye,{rows:a,headerGroups:o,prepareRow:i})},Bs=d("div")(({theme:t})=>({marginTop:t.spacing(1.5)})),Us=d("p")(({theme:t})=>({marginTop:t.spacing(3)})),vp=({role:t,open:s,setOpen:n,onConfirm:o})=>{const{users:a}=be(),{serviceAccounts:i}=Pt(),{groups:r}=Je(),c=a.filter(({rootRole:h})=>h===(t==null?void 0:t.id)),l=i.filter(({rootRole:h})=>h===(t==null?void 0:t.id)),g=r==null?void 0:r.filter(({rootRole:h})=>h===(t==null?void 0:t.id)),p=!!(c.length||l.length||g!=null&&g.length);return e.jsx(ee,{title:"Delete root role?",open:s,primaryButtonText:"Delete role",secondaryButtonText:"Cancel",disabledPrimaryButton:p,onClick:()=>o(t),onClose:()=>{n(!1)},children:e.jsx(k,{condition:p,show:e.jsxs(e.Fragment,{children:[e.jsx(V,{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(k,{condition:!!c.length,show:e.jsxs(e.Fragment,{children:[e.jsxs(Us,{children:["Users (",c.length,"):"]}),e.jsx(Bs,{children:e.jsx(fp,{users:c})})]})}),e.jsx(k,{condition:!!l.length,show:e.jsxs(e.Fragment,{children:[e.jsxs(Us,{children:["Service accounts (",l.length,"):"]}),e.jsx(Bs,{children:e.jsx(bp,{serviceAccounts:l})})]})}),e.jsx(k,{condition:!!(g!=null&&g.length),show:e.jsxs(e.Fragment,{children:[e.jsxs(Us,{children:["Groups (",g==null?void 0:g.length,"):"]}),e.jsx(Bs,{children:e.jsx(Sp,{groups:g})})]})})]}),elseShow:e.jsxs("p",{children:["You are about to delete role:"," ",e.jsx("strong",{children:t==null?void 0:t.name})]})})})},Cp=t=>{const{isEnterprise:s}=W(),{data:n,error:o,mutate:a}=Qt(s()&&t,{projects:[]},X(`api/admin/projects/roles/${t}/access`),wp);return u.useMemo(()=>({projects:(n==null?void 0:n.projects)??[],loading:!o&&!n,refetch:()=>a(),error:o}),[n,o,a])},wp=t=>fetch(t).then(le("Project role usage")).then(s=>s.json()),Tp=({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(Ko,{title:r.project,to:`/projects/${r.project}`})},{id:"users",Header:"Assigned users",accessor:r=>r.userCount===1?"1 user":`${r.userCount} users`,Cell:te,maxWidth:150},{id:"serviceAccounts",Header:"Service accounts",accessor:r=>r.serviceAccountCount===1?"1 account":`${r.serviceAccountCount} accounts`,Cell:te,maxWidth:150},{id:"groups",Header:"Assigned groups",accessor:r=>r.groupCount===1?"1 group":`${r.groupCount} groups`,Cell:te,maxWidth:150}],[]),{headerGroups:o,rows:a,prepareRow:i}=F.useTable({columns:n,data:t,initialState:s,sortTypes:fe,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},F.useSortBy,F.useFlexLayout);return e.jsx(ye,{rows:a,headerGroups:o,prepareRow:i})},kp=d("div")(({theme:t})=>({marginTop:t.spacing(1.5)})),Ep=d("p")(({theme:t})=>({marginTop:t.spacing(3)})),Ap=({role:t,open:s,setOpen:n,onConfirm:o})=>{const{projects:a}=Cp(t==null?void 0:t.id),i=!!(a!=null&&a.length);return e.jsx(ee,{title:"Delete project role?",open:s,primaryButtonText:"Delete role",secondaryButtonText:"Cancel",disabledPrimaryButton:i,onClick:()=>o(t),onClose:()=>{n(!1)},maxWidth:"md",children:e.jsx(k,{condition:i,show:e.jsxs(e.Fragment,{children:[e.jsx(V,{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(k,{condition:!!(a!=null&&a.length),show:e.jsxs(e.Fragment,{children:[e.jsxs(Ep,{children:["Role assigned in ",a==null?void 0:a.length," ","projects:"]}),e.jsx(kp,{children:e.jsx(Tp,{projects:a})})]})})]}),elseShow:e.jsxs("p",{children:["You are about to delete role:"," ",e.jsx("strong",{children:t==null?void 0:t.name})]})})})},Rp="custom",Dp=({role:t,open:s,setOpen:n,onConfirm:o})=>(t==null?void 0:t.type)===Rp?e.jsx(Ap,{role:t,open:s,setOpen:n,onConfirm:o}):e.jsx(vp,{role:t,open:s,setOpen:n,onConfirm:o}),$a=()=>{const{loading:t,makeRequest:s,createRequest:n,errors:o}=pe({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,g)=>{const h=n(`api/admin/roles/${l}`,{method:"PUT",body:JSON.stringify(g)},"updateRole");await s(h.caller,h.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}},Qn={name:void 0,description:void 0,permissions:void 0},Ip=(t="",s="",n=[])=>{const{roles:o,projectRoles:a}=Lt(),[i,r]=u.useState(t),c=R=>r(R.trim()),[l,g]=u.useState(s),[p,h]=u.useState({}),[x,m]=u.useState(Qn),[j,b]=u.useState(!1);u.useEffect(()=>{r(t)},[t]),u.useEffect(()=>{g(s)},[s]),u.useEffect(()=>{const R=bn(n);h(R)},[n.length]);const y=(R=Oe)=>({name:i,description:l,type:R===Oe?"root-custom":"custom",permissions:Object.values(p).map(({name:B,environment:E})=>({name:B,environment:E}))}),v=R=>![...o,...a].some(B=>B.name!==t&&B.name.toLowerCase()===R.toLowerCase()),A=R=>R.length,C=R=>Object.keys(R).length>0,D=R=>{m(B=>({...B,[R]:void 0}))},S=(R,B)=>{m(E=>({...E,[R]:B}))},U=R=>{const B=R.trim();return A(B)?v(B)?(D("name"),!0):(S("name","Name must be unique."),!1):(S("name","Name is required."),!1)},$=R=>{const B=R.trim();return A(B)?(D("description"),!0):(S("description","Description is required."),!1)},w=R=>C(R)?(D("permissions"),!0):(S("permissions","You must select at least one permission."),!1),P=()=>{const R=U(i),B=$(l),E=w(p);return b(!0),R&&B&&E},I=j&&Object.values(x).some(Boolean);return{name:i,setName:c,validateName:U,description:l,setDescription:g,validateDescription:$,checkedPermissions:p,setCheckedPermissions:h,validatePermissions:w,getRolePayload:y,errors:x,showErrors:I,validate:P,reload:()=>{r(t),g(s),h(bn(n)),b(!1),m(Qn)}}};var un={},Pp=ct;Object.defineProperty(un,"__esModule",{value:!0});var Oa=un.default=void 0,Lp=Pp(lt()),Bp=e,Up=(0,Lp.default)((0,Bp.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=un.default=Up;const $p=({permissions:t,checkedPermissions:s,onPermissionChange:n})=>e.jsx(_,{display:"grid",gridTemplateColumns:{sm:"1fr 1fr",xs:"1fr"},children:t==null?void 0:t.map(o=>e.jsx(re,{"data-testid":nt(o),control:e.jsx(rs,{checked:!!s[nt(o)],onChange:()=>n(o),color:"primary"}),label:o.displayName},nt(o)))}),_a=t=>{const s=(t==null?void 0:t.map(i=>nt(i)).sort())||[],n=Sn.flatMap(i=>i.permissions.map(([r])=>r)).sort(),o=s.filter(i=>!n.includes(i));return[...Sn,{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=>nt(l)===r),c])})).filter(i=>i.permissions.length>0)},Op=({permission:t,onChange:s,isChecked:n,hasParentPermission:o,isParentPermissionChecked:a})=>e.jsx(_,{sx:i=>({marginLeft:o?i.spacing(1.5):0}),children:e.jsx(re,{"data-testid":t,control:e.jsx(rs,{checked:!!(n||a),onChange:s,color:"primary",disabled:a}),label:t.displayName},t.name)}),_p=d("div")(({theme:t})=>({display:"grid",gridTemplateColumns:"1fr 1fr",gap:t.spacing(1),[t.breakpoints.down("md")]:{gridTemplateColumns:"1fr"}})),Mp=d(T)(({theme:t})=>({fontWeight:t.typography.fontWeightBold,marginTop:t.spacing(2),marginBottom:t.spacing(1)})),Np=({permissions:t,checkedPermissions:s,onPermissionChange:n})=>{const o=u.useMemo(()=>_a(t),[t]);return e.jsx(_p,{children:o.map(a=>e.jsxs("div",{children:[e.jsx(Mp,{children:a.label}),e.jsx("div",{children:a.permissions.map(([i,r])=>e.jsx(Op,{permission:i,onChange:()=>n(i),isChecked:!!s[i.name],hasParentPermission:!!r,isParentPermissionChecked:!!(r&&s[r])}))})]}))})},Fp=d(_)(({theme:t})=>({display:"flex",alignItems:"center",[t.breakpoints.down(500)]:{flexDirection:"column",alignItems:"flex-start"}})),Wp=d(Qi)(({theme:t})=>({fontWeight:t.typography.fontWeightBold,marginRight:t.spacing(1)})),qp=({title:t,permissions:s,checkedPermissions:n,Icon:o,isInitiallyExpanded:a=!1,context:i,children:r,onCheckAll:c})=>{const[l,g]=u.useState(a),p=u.useMemo(()=>(s==null?void 0:s.reduce((m,j)=>(m[nt(j)]=!0,m),{}))||{},[s]),h=u.useMemo(()=>Object.keys(n).filter(m=>p[m]).length||0,[n,p]),x=u.useMemo(()=>h===(s==null?void 0:s.length),[h,s]);return e.jsx(_,{sx:{my:2,pb:1},children:e.jsxs(ns,{expanded:l,onChange:()=>g(!l),sx:{boxShadow:"none",px:3,py:1,border:m=>`1px solid ${m.palette.divider}`,borderRadius:m=>`${m.shape.borderRadiusLarge}px`},children:[e.jsx(os,{expandIcon:e.jsx(Re,{children:e.jsx(ts,{titleAccess:"Toggle"})}),sx:{boxShadow:"none",padding:"0"},children:e.jsxs(Fp,{children:[o,e.jsx(Wp,{text:t,maxWidth:"120",maxLength:25})," ",e.jsxs(T,{variant:"body2",color:"text.secondary",children:["(",h," / ",s==null?void 0:s.length," ","permissions)"]})]})}),e.jsxs(ss,{sx:{px:0,py:1,flexWrap:"wrap"},children:[e.jsx(rt,{sx:{mb:1}}),e.jsxs(N,{variant:"text",size:"small",onClick:c,sx:{fontWeight:m=>m.typography.fontWeightRegular},children:[x?"Unselect ":"Select ","all ",i," permissions"]}),r]})]})})},Gp=({type:t,checkedPermissions:s,setCheckedPermissions:n,validatePermissions:o})=>{const{permissions:a}=Xi({revalidateIfStale:!1,revalidateOnReconnect:!1,revalidateOnFocus:!1}),i=Ao.includes(t),r=u.useMemo(()=>i?Zo(er(a.project,a.environments)):Qo(a.root),[a,i]),c=g=>{const p=ar(s,g);o(p),n(p)},l=g=>{const p=ir(s,g);o(p),n(p)};return u.useMemo(()=>e.jsx(e.Fragment,{children:r.map(({label:g,type:p,permissions:h})=>e.jsx(qp,{title:g,context:g.toLowerCase(),Icon:p===tr?e.jsx(Oa,{color:"disabled",sx:{mr:1}}):p===sr?e.jsx(nr,{color:"disabled",sx:{mr:1}}):e.jsx(or,{color:"disabled",sx:{mr:1}}),permissions:h,checkedPermissions:s,onCheckAll:()=>l(h),children:p==="project"?e.jsx(Np,{permissions:h,checkedPermissions:s,onPermissionChange:c}):e.jsx($p,{permissions:h,checkedPermissions:s,onPermissionChange:c})},g))}),[r,s])},$s=d("p")(({theme:t})=>({display:"flex",color:t.palette.text.primary,marginBottom:t.spacing(1),"&:not(:first-of-type)":{marginTop:t.spacing(4)}})),zp=d(Ze)(({theme:t})=>({width:"100%",maxWidth:t.spacing(50)})),Hp=d(Ze)({width:"100%"}),Vp=({type:t=Oe,name:s,setName:n,description:o,setDescription:a,checkedPermissions:i,setCheckedPermissions:r,errors:c,showErrors:l,validateName:g,validateDescription:p,validatePermissions:h})=>{const x=m=>{setTimeout(()=>m(),300)};return e.jsxs("div",{children:[e.jsx($s,{children:"What is your new role name?"}),e.jsx(zp,{autoFocus:!0,label:"Role name *",error:!!c.name,errorText:c.name,value:s,onChange:m=>{g(m.target.value),n(m.target.value)},onBlur:m=>x(()=>g(m.target.value)),autoComplete:"off"}),e.jsx($s,{children:"What is your new role description?"}),e.jsx(Hp,{label:"Role description *",error:!!c.description,errorText:c.description,value:o,onChange:m=>{p(m.target.value),a(m.target.value)},onBlur:m=>x(()=>p(m.target.value)),autoComplete:"off"}),e.jsx($s,{children:"What is your role allowed to do?"}),e.jsx(V,{severity:"info",children:"You must select at least one permission."}),e.jsx(Gp,{type:t,checkedPermissions:i,setCheckedPermissions:r,validatePermissions:h}),e.jsx(k,{condition:l,show:()=>e.jsx(V,{severity:"error",icon:!1,children:e.jsx("ul",{children:Object.values(c).filter(Boolean).map(m=>e.jsx("li",{children:m},m))})})})]})},Yp=d("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),Jp=d("div")(({theme:t})=>({marginTop:"auto",display:"flex",justifyContent:"flex-end",paddingTop:t.spacing(4)})),Kp=d(N)(({theme:t})=>({marginLeft:t.spacing(3)})),Zp=({type:t=Oe,roleId:s,open:n,setOpen:o})=>{const{role:a,refetch:i}=Xo(s==null?void 0:s.toString()),{name:r,setName:c,validateName:l,description:g,setDescription:p,validateDescription:h,checkedPermissions:x,setCheckedPermissions:m,validatePermissions:j,getRolePayload:b,errors:y,showErrors:v,validate:A,reload:C}=Ip(a==null?void 0:a.name,a==null?void 0:a.description,a==null?void 0:a.permissions),{refetch:D}=Lt(),{addRole:S,updateRole:U,loading:$}=$a(),{setToastData:w,setToastApiError:P}=Y(),{uiConfig:I}=W(),L=a!==void 0,R=b(t),B=()=>`curl --location --request ${L?"PUT":"POST"} '${I.unleashUrl}/api/admin/roles${L?`/${a.id}`:""}' \\
17
17
  --header 'Authorization: INSERT_API_KEY' \\
18
18
  --header 'Content-Type: application/json' \\
@@ -35,4 +35,4 @@ import{dE as So,j as e,dF as Se,dG as xn,dH as mn,dI as Pe,az as ne,aC as oe,at
35
35
  --data-raw '${JSON.stringify(v(),void 0,2)}'`,U=async w=>{w.preventDefault();const P=v();if(A())try{await r({...P,id:o}),i(),l("/admin/users"),s({text:"User information updated",type:"success"})}catch(L){n(G(L))}},$=()=>{l(Be)};return e.jsx(Ae,{loading:c,title:"Edit user",description:"In order for a user to get access to Unleash, they need to be assigned a root role, such as Viewer, Editor, or Admin.",documentationLink:"https://docs.getunleash.io/concepts/rbac#predefined-roles",documentationLinkLabel:"User management documentation",formatApiCode:S,children:e.jsx(qa,{errors:C,handleSubmit:U,handleCancel:$,name:g,setName:p,email:h,setEmail:x,sendEmail:m,setSendEmail:j,rootRole:b,setRootRole:y,clearErrors:D,mode:Xs,children:e.jsx(Mo,{permission:Q})})})},zg=()=>{const{data:t,error:s,mutate:n}=ve(X("api/admin/user-admin/inactive"),Hg);return u.useMemo(()=>({inactiveUsers:(t==null?void 0:t.inactiveUsers)??[],error:s,refetchInactiveUsers:()=>n(),loading:!s&&!t}),[t,s,n])},Hg=t=>fetch(t).then(le("User")).then(s=>s.json()),po="delInactiveUsers",Vg=()=>{const{makeRequest:t,createRequest:s,errors:n,loading:o}=pe({propagateErrors:!0});return{deleteInactiveUsers:async i=>{const c=s("api/admin/user-admin/inactive/delete",{method:"POST",body:JSON.stringify({ids:i})});return t(c.caller,c.id)},errors:n,loading:o}},Yg=d(_)(()=>({display:"flex",justifyContent:"center"})),Jg=({onDelete:t})=>e.jsx(Yg,{children:e.jsx($e,{"data-loading":!0,onClick:t,permission:Q,tooltipProps:{title:"Remove user"},children:e.jsx(Ee,{})})}),Kg=({showDialog:t,closeDialog:s,user:n,userLoading:o,removeUser:a,userApiErrors:i})=>{const r=At(o),{classes:c}=ps();return e.jsx(ee,{open:t,title:"Really delete user?",onClose:s,onClick:a,primaryButtonText:"Delete user",secondaryButtonText:"Cancel",children:e.jsxs("div",{ref:r,children:[e.jsx(k,{condition:!!i[Jt],show:e.jsx(V,{"data-loading":!0,severity:"error",style:{margin:"1rem 0"},children:i[Jt]})}),e.jsx("div",{"data-loading":!0,className:c.flexRow,children:e.jsx(T,{variant:"subtitle1",style:{marginLeft:"1rem"},children:n.username||n.email})}),e.jsxs(T,{"data-loading":!0,variant:"body1",style:{marginTop:"1rem"},children:["Are you sure you want to delete"," ",`${n.name||"user"} (${n.email||n.username})`]})]})})},Zg=({showDialog:t,closeDialog:s,inactiveUsersLoading:n,removeInactiveUsers:o,inactiveUserApiErrors:a,inactiveUsers:i})=>{const r=At(n);return e.jsx(ee,{open:t,title:"Really delete all inactive users?",onClose:s,onClick:o,primaryButtonText:"Delete all inactive users",secondaryButtonText:"Cancel",children:e.jsxs("div",{ref:r,children:[e.jsx(k,{condition:!!a[po],show:e.jsx(V,{"data-loading":!0,severity:"error",style:{margin:"1rem 0"},children:a[po]})}),e.jsx("div",{style:Er,children:e.jsxs(T,{variant:"subtitle1",children:["You will be deleting"," ",i.length===1?"1 inactive user":`${i.length} inactive users`]})})]})})},Qg=()=>{const{removeUser:t,userApiErrors:s}=Qe(),{deleteInactiveUsers:n,errors:o}=Vg(),{setToastData:a,setToastApiError:i}=Y(),{inactiveUsers:r,refetchInactiveUsers:c,loading:l}=zg(),{users:g,roles:p,loading:h}=be(),[x,m]=u.useState(!1),[j,b]=u.useState(),[y,v]=u.useState(!1),A=()=>{m(!1),b(void 0)},C=E=>O=>{O.preventDefault(),m(!0),b(E)},D=E=>{E.preventDefault(),v(!0)},S=()=>{v(!1)},U=async()=>{try{await n(r.map(E=>E.id)),a({text:"Inactive users has been deleted",type:"success"}),v(!1),c()}catch(E){i(G(E))}},$=async E=>{try{await t(E),a({text:"User has been deleted",type:"success"}),c(),A()}catch(O){i(G(O))}},w=u.useMemo(()=>r.map(E=>{const O=g.find(H=>H.id===E.id);return{...E,rootRole:O==null?void 0:O.rootRole}}),[r,g]),P=u.useMemo(()=>[{id:"name",Header:"Name",accessor:E=>E.name||"",minWidth:200,Cell:({row:{original:E}})=>e.jsx(Ce,{value:E.name,subtitle:E.email||E.username}),searchable:!0},{id:"role",Header:"Role",accessor:E=>{var O;return((O=p.find(H=>H.id===E.rootRole))==null?void 0:O.name)||""},Cell:({row:{original:E},value:O})=>e.jsx(tn,{value:O,role:E.rootRole}),maxWidth:120},{Header:"Created",accessor:"createdAt",Cell:me,width:120,maxWidth:120},{id:"last-login",Header:"Last login",accessor:"seenAt",Cell:Ne,maxWidth:150},{id:"pat-last-login",Header:"PAT last used",accessor:"patSeenAt",Cell:Ne,maxWidth:150},{id:"Actions",Header:"Actions",align:"center",Cell:({row:{original:E}})=>e.jsx(Jg,{onDelete:C(E)}),width:200,disableSortBy:!0}],[p]),I=u.useMemo(()=>({sortBy:[{id:"createdAt",desc:!0}],hiddenColumns:["username","email"]}),[]),{headerGroups:L,rows:R,prepareRow:B}=F.useTable({columns:P,data:w,initialState:I,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0,defaultColumn:{Cell:te}},F.useSortBy,F.useFlexLayout);return e.jsxs(ne,{isLoading:l,header:e.jsx(oe,{title:`Inactive users (${R.length})`,actions:e.jsx(e.Fragment,{children:e.jsx(N,{variant:"contained",color:"primary",onClick:D,disabled:r.length===0,children:"Delete all inactive users"})})}),children:[e.jsx(Ya,{children:e.jsx(ae,{to:"/admin/users",children:"View all users"})}),e.jsx(ye,{rows:R,headerGroups:L,prepareRow:B}),e.jsx(k,{condition:R.length===0,show:e.jsx(ce,{children:"No inactive users found."})}),e.jsx(k,{condition:!!j,show:e.jsx(Kg,{showDialog:x,closeDialog:A,user:j,userLoading:h,removeUser:()=>$(j.id),userApiErrors:s})}),e.jsx(Zg,{showDialog:y,closeDialog:S,inactiveUsersLoading:l,inactiveUserApiErrors:o,inactiveUsers:r,removeInactiveUsers:U})]})},ho=({label:t,options:s,value:n,setValue:o,...a})=>e.jsx(ko,{options:s,value:n,onChange:(i,r)=>o(r),renderInput:i=>e.jsx(se,{...i,label:t,fullWidth:!0}),size:"small",fullWidth:!0,...a}),Xg=(t,s,n)=>{const o=`${s?`?project=${s}`:""}${n?`${s?"&":"?"}environment=${n}`:""}`,a=`api/admin/user-admin/${t}/permissions${o}`,{data:i,error:r,mutate:c}=ve(X(a),ex);return u.useMemo(()=>({overview:i==null?void 0:i.overview,projectRoles:i==null?void 0:i.projectRoles,rootRole:i==null?void 0:i.rootRole,user:i==null?void 0:i.user,loading:!r&&!i,refetch:()=>c(),error:r}),[i,r,c])},ex=t=>fetch(t).then(le("User access matrix")).then(s=>s.json()),go=d("ul")(({theme:t})=>({listStyle:"none",padding:0,margin:0,fontSize:t.fontSizes.smallBody,"& > li":{display:"flex",justifyContent:"space-between",padding:t.spacing(2),borderBottom:`1px solid ${t.palette.divider}`},"& ul li":{paddingLeft:t.spacing(4)},"& ul:last-of-type > li:last-child":{borderBottom:"none"}})),tx=d("div",{shouldForwardProp:t=>t!=="hasPermission"})(({theme:t,hasPermission:s})=>({display:"flex",gap:t.spacing(1),alignItems:"center",width:t.spacing(17.5),color:s?t.palette.text.primary:t.palette.text.secondary,"& > svg":{color:s?t.palette.success.main:t.palette.error.main}})),sx=({categories:t})=>{const{searchQuery:s}=Zs();return e.jsx(_,{sx:{maxHeight:500,overflow:"auto"},children:e.jsx(go,{children:t.map(n=>e.jsxs(e.Fragment,{children:[e.jsx("li",{children:e.jsx("strong",{children:n.label})},n.label),e.jsx(go,{children:n.permissions.map(o=>e.jsxs("li",{children:[e.jsx("div",{children:e.jsx(Vt,{search:s,children:o.displayName})}),e.jsx(nx,{hasPermission:o.hasPermission})]},o.name))})]}))})})},nx=({hasPermission:t})=>e.jsx(tx,{hasPermission:t,children:t?e.jsxs(e.Fragment,{children:[e.jsx(Ys,{}),"Has permission"]}):e.jsxs(e.Fragment,{children:[e.jsx(ra,{}),"No permission"]})}),ox=d(ns)(({theme:t})=>({border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge,overflow:"hidden",boxShadow:"none",margin:0,"&:before":{display:"none"}})),ax=d(os)(({theme:t})=>({backgroundColor:t.palette.background.elevation1,"& .MuiAccordionSummary-content":{justifyContent:"space-between",alignItems:"center",minHeight:"30px"}})),ix=d("div")(({theme:t})=>({display:"flex",alignItems:"start",flexDirection:"column",gap:t.spacing(.5)})),rx=d("span")(({theme:t})=>({fontWeight:t.fontWeight.bold})),lx=d("span")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginRight:t.spacing(1)})),cx=d(ss)(({theme:t})=>({padding:0})),Os=({categories:t,children:s})=>{const n=t.flatMap(({permissions:o})=>o);return e.jsxs(ox,{children:[e.jsxs(ax,{expandIcon:e.jsx(ts,{}),children:[e.jsx(ix,{children:e.jsx(rx,{children:s})}),e.jsxs(lx,{children:[n.filter(({hasPermission:o})=>o).length,"/",n.length," permissions"]})]}),e.jsx(cx,{children:e.jsx(sx,{categories:t})})]})},dx=d("div")(({theme:t})=>({display:"flex",flex:1,gap:t.spacing(1),maxWidth:800,[t.breakpoints.down("md")]:{flexDirection:"column",maxWidth:"100%"},"& > div":{width:"100%"}})),ux=d("div")(({theme:t})=>({display:"flex",flexDirection:"column",gap:t.spacing(2)})),_s=(t,s)=>{const n=s.toLowerCase(),o=t.permissions.filter(({displayName:a})=>a.toLowerCase().includes(n));if(o.length)return{...t,permissions:o}},px=()=>{const t=ds("id"),[s,n]=Ar({project:wn,environment:wn}),{projects:o}=wo(),{environments:a}=Rr(),{user:i,loading:r}=la(t),c=je(Ue.breakpoints.down("md")),[l,g]=u.useState(""),[p,h]=u.useState(s.project??""),[x,m]=u.useState(s.environment??void 0),{overview:j,rootRole:b,projectRoles:y}=Xg(t,p,x);u.useEffect(()=>{n({project:p||void 0,environment:x},"replace")},[p,x]);const v=e.jsxs(dx,{children:[e.jsx(ue,{initialValue:l,onChange:g}),e.jsx(ho,{label:"Project",options:o,getOptionLabel:S=>(S==null?void 0:S.name)??"",value:o.find(({id:S})=>S===p),setValue:S=>h((S==null?void 0:S.id)??"")}),e.jsx(ho,{label:"Environment",options:a,getOptionLabel:S=>(S==null?void 0:S.name.concat(S.enabled?"":" - deprecated"))??"",value:a.find(({name:S})=>S===x),setValue:S=>m(S==null?void 0:S.name)})]}),A=u.useMemo(()=>{const S=Qo((j==null?void 0:j.root)??[]);return l?S.map(U=>_s(U,l)).filter(Boolean):S},[j==null?void 0:j.root,l]),C=u.useMemo(()=>_a((j==null?void 0:j.project)??[]).map(({label:U,permissions:$})=>({label:U,permissions:$.map(([w])=>w)})).map(U=>_s(U,l)).filter(Boolean),[j==null?void 0:j.project,l]),D=u.useMemo(()=>Zo((j==null?void 0:j.environment)??[]).map(U=>_s(U,l)).filter(Boolean),[j==null?void 0:j.environment,l]);return e.jsx(ne,{isLoading:r,header:e.jsx(oe,{title:`Access overview for ${i.name||i.email||i.username}`,actions:e.jsx(k,{condition:!c,show:v}),children:e.jsx(k,{condition:c,show:v})}),children:e.jsx(ux,{children:e.jsxs(qe,{value:l,children:[e.jsxs(Os,{categories:A,children:["Root permissions for role ",b==null?void 0:b.name]}),e.jsxs(Os,{categories:C,children:["Project permissions",p?` for project ${p}${y!=null&&y.length?` with project role${y.length!==1?"s":""} ${y==null?void 0:y.map(S=>S.name).join(", ")}`:""}`:""]}),x&&e.jsxs(Os,{categories:D,children:["Environment permissions for ",x]})]})})})},hx=()=>{const{isEnterprise:t}=W();return e.jsx("div",{children:e.jsx(Se,{permissions:Q,children:e.jsxs(it,{children:[e.jsx(M,{index:!0,element:e.jsx(e.Fragment,{children:e.jsx(qg,{})})}),e.jsx(M,{path:":id/edit",element:e.jsx(Gg,{})}),e.jsx(M,{path:":id/access",element:e.jsx(px,{})}),e.jsx(M,{path:"inactive",element:e.jsx(k,{condition:t(),show:e.jsx(Qg,{}),elseShow:e.jsx(at,{feature:"inactive-users",page:!0})})}),e.jsx(M,{path:"*",element:e.jsx(ca,{})})]})})})},bt="api/admin/banners",Ka=()=>{const{loading:t,makeRequest:s,createRequest:n,errors:o}=pe({propagateErrors:!0}),a=async p=>{const x=n(bt,{method:"POST",body:JSON.stringify(p)},"addBanner");return(await s(x.caller,x.id)).json()},i=async(p,h)=>{const m=n(`${bt}/${p}`,{method:"PUT",body:JSON.stringify(h)},"updateBanner");await s(m.caller,m.id)},r=async p=>{const x=n(`${bt}/${p}/on`,{method:"POST"},"enableBanner");await s(x.caller,x.id)},c=async p=>{const x=n(`${bt}/${p}/off`,{method:"POST"},"disableBanner");await s(x.caller,x.id)};return{addBanner:a,updateBanner:i,removeBanner:async p=>{const x=n(`${bt}/${p}`,{method:"DELETE"},"removeBanner");await s(x.caller,x.id)},toggleBanner:async(p,h)=>{h?await r(p):await c(p)},errors:o,loading:t}},gx=d(_)(()=>({display:"flex",justifyContent:"center"})),xx=({onEdit:t,onDelete:s})=>e.jsxs(gx,{children:[e.jsx($e,{"data-loading":!0,onClick:t,permission:Q,tooltipProps:{title:"Edit banner"},children:e.jsx(Rt,{})}),e.jsx($e,{"data-loading":!0,onClick:s,permission:Q,tooltipProps:{title:"Remove banner"},children:e.jsx(Ee,{})})]}),mx=({banner:t,open:s,setOpen:n,onConfirm:o})=>e.jsx(ee,{title:"Delete banner?",open:s,primaryButtonText:"Delete banner",secondaryButtonText:"Cancel",onClick:()=>o(t),onClose:()=>{n(!1)},children:e.jsxs("p",{children:["You are about to delete banner: ",e.jsx("strong",{children:t==null?void 0:t.message})]})}),jx=d("div")(({theme:t})=>({display:"flex",flexDirection:"column",gap:t.spacing(4)})),fx=d("div")(({theme:t})=>({display:"flex",flexDirection:"column",alignItems:"center",padding:t.spacing(1.5),gap:t.spacing(1.5),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusMedium})),yx=d("p")(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),bx=d("div")(({theme:t})=>({background:t.palette.background.elevation1,padding:t.spacing(2,3),borderRadius:t.shape.borderRadiusLarge})),Ms=d("div")(({theme:t})=>({display:"flex",flexDirection:"column",gap:t.spacing(1.5)})),Ns=d("p")(({theme:t})=>({fontWeight:t.fontWeight.bold})),De=d("div")(({theme:t})=>({display:"flex",flexDirection:"column",gap:t.spacing(1)})),Ie=d("p")(({theme:t})=>({display:"flex",color:t.palette.text.primary})),et=d(Ze)({width:"100%"}),Fs=d("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(.5),gap:t.spacing(.5)})),Ws=d(na)(({theme:t})=>({width:"100%",maxWidth:t.spacing(50)})),Sx=d(N)(({theme:t})=>({marginRight:"auto"})),vx=[{key:"info",label:"Information"},{key:"warning",label:"Warning"},{key:"error",label:"Error"},{key:"success",label:"Success"}],xo=t=>t===""?"Default":t==="none"?"None":"Custom",mo=t=>t===""?"None":t==="dialog"?"Dialog":"Link",Cx=({enabled:t,message:s,variant:n,sticky:o,icon:a,link:i,linkText:r,dialogTitle:c,dialog:l,setEnabled:g,setMessage:p,setVariant:h,setSticky:x,setIcon:m,setLink:j,setLinkText:b,setDialogTitle:y,setDialog:v})=>{const[A,C]=u.useState(!1),[D,S]=u.useState(()=>xo(a)),[U,$]=u.useState(()=>mo(i));return u.useEffect(()=>{S(xo(a)),$(mo(i))},[a,i]),e.jsxs(jx,{children:[e.jsxs(fx,{children:[e.jsx(yx,{children:"Banner preview:"}),e.jsx(da,{banner:{message:s||"*No message set. Please enter a message below.*",variant:n,sticky:!1,icon:a,link:i,linkText:r,dialogTitle:c,dialog:l},inline:!0})]}),e.jsx(bx,{children:e.jsx(Dr,{checked:t,setChecked:g,children:"Banner status"})}),e.jsxs(Ms,{children:[e.jsx(Ns,{children:"Configuration"}),e.jsxs(De,{children:[e.jsx(Ie,{children:"What type of banner is it?"}),e.jsx(Ws,{size:"small",value:n,onChange:w=>h(w),options:vx})]}),e.jsxs(De,{children:[e.jsx(Ie,{children:"What icon should be displayed on the banner?"}),e.jsx(Ws,{size:"small",value:D,onChange:w=>{S(w),m(w==="None"?"none":"")},options:["Default","Custom","None"].map(w=>({key:w,label:w}))})]}),e.jsx(k,{condition:D==="Custom",show:e.jsxs(De,{children:[e.jsxs(Ie,{children:["Which custom icon?",e.jsx(st,{htmlTooltip:!0,tooltip:e.jsxs(Fs,{children:[e.jsxs("p",{children:["Choose an icon from"," ",e.jsx("a",{href:"https://fonts.google.com/icons",target:"_blank",rel:"noreferrer",children:"Material Symbols"}),"."]}),e.jsx("p",{children:'For example, if you want to display the "Rocket Launch" icon, you can enter "rocket_launch" in the field below.'})]})})]}),e.jsx(et,{label:"Banner icon",value:a,onChange:w=>m(w.target.value),autoComplete:"off"})]})}),e.jsxs(De,{children:[e.jsxs(Ie,{children:["What is your banner message?",e.jsx(st,{htmlTooltip:!0,tooltip:e.jsx(Fs,{children:e.jsxs("p",{children:[e.jsx("a",{href:"https://www.markdownguide.org/basic-syntax/",target:"_blank",rel:"noreferrer",children:"Markdown"})," ","is supported."]})})})]}),e.jsx(et,{autoFocus:!0,label:"Banner message",multiline:!0,minRows:2,maxRows:6,value:s,onChange:w=>p(w.target.value),autoComplete:"off",required:!0})]})]}),e.jsxs(Ms,{children:[e.jsx(Ns,{children:"Banner action"}),e.jsxs(De,{children:[e.jsx(Ie,{children:"What action should be available in the banner?"}),e.jsx(Ws,{size:"small",value:U,onChange:w=>{$(w),j(w==="Dialog"?"dialog":""),b(""),y(""),v("")},options:["None","Link","Dialog"].map(w=>({key:w,label:w}))})]}),e.jsx(k,{condition:U==="Link",show:e.jsxs(De,{children:[e.jsx(Ie,{children:"What URL should be opened?"}),e.jsx(et,{label:"URL",value:i,onChange:w=>j(w.target.value),onBlur:()=>{r||b(i)},autoComplete:"off"})]})}),e.jsx(k,{condition:U!=="None",show:e.jsxs(De,{children:[e.jsx(Ie,{children:"What is the action text?"}),e.jsx(et,{label:"Action text",value:r,onChange:w=>b(w.target.value),autoComplete:"off"})]})}),e.jsx(k,{condition:U==="Dialog",show:e.jsxs(e.Fragment,{children:[e.jsxs(De,{children:[e.jsx(Ie,{children:"What is the dialog title?"}),e.jsx(et,{label:"Dialog title",value:c,onChange:w=>y(w.target.value),autoComplete:"off"})]}),e.jsxs(De,{children:[e.jsxs(Ie,{children:["What is the dialog content?",e.jsx(st,{htmlTooltip:!0,tooltip:e.jsx(Fs,{children:e.jsxs("p",{children:[e.jsx("a",{href:"https://www.markdownguide.org/basic-syntax/",target:"_blank",rel:"noreferrer",children:"Markdown"})," ","is supported."]})})})]}),e.jsx(et,{label:"Dialog content",multiline:!0,minRows:4,value:l,onChange:w=>v(w.target.value),autoComplete:"off"})]}),e.jsx(Sx,{variant:"outlined",color:"primary",startIcon:e.jsx(Ir,{}),onClick:()=>C(!0),children:"Preview dialog"}),e.jsx(Pr,{open:A,setOpen:C,title:c||r,children:l})]})})]}),e.jsxs(Ms,{children:[e.jsx(Ns,{children:"Sticky banner"}),e.jsx(re,{control:e.jsx(rs,{checked:o,onChange:w=>x(w.target.checked)}),label:"Make the banner sticky on the screen when scrolling"})]})]})},wx=d("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),Tx=d("div")(({theme:t})=>({marginTop:"auto",display:"flex",justifyContent:"flex-end",paddingTop:t.spacing(4)})),kx=d(N)(({theme:t})=>({marginLeft:t.spacing(3)})),Ex=({banner:t,open:s,setOpen:n})=>{const{refetch:o}=ua(),{addBanner:a,updateBanner:i,loading:r}=Ka(),{setToastData:c,setToastApiError:l}=Y(),{uiConfig:g}=W(),[p,h]=u.useState(!0),[x,m]=u.useState(""),[j,b]=u.useState("info"),[y,v]=u.useState(!1),[A,C]=u.useState(""),[D,S]=u.useState(""),[U,$]=u.useState(""),[w,P]=u.useState(""),[I,L]=u.useState("");u.useEffect(()=>{h((t==null?void 0:t.enabled)??!0),m((t==null?void 0:t.message)||""),b((t==null?void 0:t.variant)||"info"),v((t==null?void 0:t.sticky)||!1),C((t==null?void 0:t.icon)||""),S((t==null?void 0:t.link)||""),$((t==null?void 0:t.linkText)||""),P((t==null?void 0:t.dialogTitle)||""),L(typeof(t==null?void 0:t.dialog)=="string"?t==null?void 0:t.dialog:"")},[s,t]);const R=t!==void 0,B=R?"Edit banner":"New banner",E=x.length,O={enabled:p,variant:j,icon:A,message:x,link:D,linkText:U,dialogTitle:w,dialog:I,sticky:y},H=()=>`curl --location --request ${R?"PUT":"POST"} '${g.unleashUrl}/api/admin/banners${R?`/${t.id}`:""}' \\
36
36
  --header 'Authorization: INSERT_API_KEY' \\
37
37
  --header 'Content-Type: application/json' \\
38
- --data-raw '${JSON.stringify(O,void 0,2)}'`,J=async K=>{if(K.preventDefault(),!!E)try{R?await i(t.id,O):await a(O),c({text:`Banner ${R?"updated":"added"} successfully`,type:"success"}),o(),n(!1)}catch(q){l(G(q))}};return e.jsx(ls,{open:s,onClose:()=>{n(!1)},label:B,children:e.jsx(Ae,{loading:r,modal:!0,title:B,description:"Banners allow you to display messages to other users inside your Unleash instance.",documentationLink:"https://docs.getunleash.io/concepts/banners",documentationLinkLabel:"Banners documentation",formatApiCode:H,children:e.jsxs(wx,{onSubmit:J,children:[e.jsx(Cx,{enabled:p,message:x,variant:j,sticky:y,icon:A,link:D,linkText:U,dialogTitle:w,dialog:I,setEnabled:h,setMessage:m,setVariant:b,setSticky:v,setIcon:C,setLink:S,setLinkText:$,setDialogTitle:P,setDialog:L}),e.jsxs(Tx,{children:[e.jsxs(N,{type:"submit",variant:"contained",color:"primary",disabled:!E,children:[R?"Save":"Add"," banner"]}),e.jsx(kx,{onClick:()=>{n(!1)},children:"Cancel"})]})]})})})},Ax=()=>{const{setToastData:t,setToastApiError:s}=Y(),{banners:n,refetch:o,loading:a}=ua(),{toggleBanner:i,removeBanner:r}=Ka(),[c,l]=u.useState(""),[g,p]=u.useState(!1),[h,x]=u.useState(!1),[m,j]=u.useState(),b=async(I,L)=>{try{await i(I.id,L),t({text:`"${I.message}" has been ${L?"enabled":"disabled"}`,type:"success"}),o()}catch(R){s(G(R))}},y=async I=>{try{await r(I.id),t({text:`"${I.message}" has been deleted`,type:"success"}),o(),x(!1)}catch(L){s(G(L))}},v=je(Ue.breakpoints.down("md")),A=u.useMemo(()=>[{Header:"Banner",accessor:"message",Cell:({row:{original:I}})=>e.jsx(da,{banner:{...I,sticky:!1},inline:!0,maxHeight:42}),disableSortBy:!0,minWidth:200,searchable:!0},{Header:"Created",accessor:"createdAt",Cell:me,width:120,maxWidth:120},{Header:"Enabled",accessor:"enabled",Cell:({row:{original:I}})=>e.jsx(Lr,{checked:I.enabled,setChecked:L=>b(I,L)}),sortType:"boolean",width:90,maxWidth:90},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:I}})=>e.jsx(xx,{onEdit:()=>{j(I),p(!0)},onDelete:()=>{j(I),x(!0)}}),width:100,disableSortBy:!0}],[]),[C]=u.useState({sortBy:[{id:"createdAt",desc:!0}]}),{data:D,getSearchText:S}=dt(A,c,n),{headerGroups:U,rows:$,prepareRow:w,setHiddenColumns:P}=F.useTable({columns:A,data:D,initialState:C,sortTypes:fe,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0,defaultColumn:{Cell:te}},F.useSortBy,F.useFlexLayout);return It([{condition:v,columns:["createdAt"]}],P,A),e.jsxs(ne,{isLoading:a,header:e.jsx(oe,{title:`Banners (${$.length})`,actions:e.jsxs(e.Fragment,{children:[e.jsx(k,{condition:!v,show:e.jsxs(e.Fragment,{children:[e.jsx(ue,{initialValue:c,onChange:l}),e.jsx(oe.Divider,{})]})}),e.jsx(N,{variant:"contained",color:"primary",onClick:()=>{j(void 0),p(!0)},children:"New banner"})]}),children:e.jsx(k,{condition:v,show:e.jsx(ue,{initialValue:c,onChange:l})})}),children:[e.jsx(qe,{value:S(c),children:e.jsx(ye,{rows:$,headerGroups:U,prepareRow:w})}),e.jsx(k,{condition:$.length===0,show:e.jsx(k,{condition:(c==null?void 0:c.length)>0,show:e.jsxs(ce,{children:["No banners found matching “",c,"”"]}),elseShow:e.jsx(ce,{children:"No banners available. Get started by adding one."})})}),e.jsx(Ex,{banner:m,open:g,setOpen:p}),e.jsx(mx,{banner:m,open:h,setOpen:x,onConfirm:y})]})},Rx=()=>{const{isEnterprise:t}=W();return t()?e.jsx("div",{children:e.jsx(Se,{permissions:[Q,Br],children:e.jsx(Ax,{})})}):e.jsx(at,{feature:"banners",page:!0})},Dx=async(t,s)=>{if(t){if(s){const n=await s.json();throw t({message:n.message}),new Error(n.message)}throw new Error("Did not receive a response from the server.")}},Ix=()=>{const{makeRequest:t,createRequest:s,errors:n,loading:o}=pe({propagateErrors:!0,handleBadRequest:Dx});return{updateLicenseKey:async i=>{const c=s("api/admin/license",{method:"POST",body:JSON.stringify({token:i})});await t(c.caller,c.id)},errors:n,loading:o}},Px=d(_)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),St=d("div")(()=>({display:"table-row"})),vt=d("p")(({theme:t})=>({display:"table-cell",fontWeight:t.fontWeight.bold,paddingTop:t.spacing(2)})),Ct=d("p")(({theme:t})=>({display:"table-cell",paddingTop:t.spacing(2),paddingLeft:t.spacing(4)})),Lx=()=>{const{setToastData:t,setToastApiError:s}=Y(),{license:n,error:o,refetchLicense:a}=Ur(),{reCheckLicense:i}=$r(),{loading:r}=W(),{locationSettings:c}=Uo(),[l,g]=u.useState(""),{updateLicenseKey:p}=Ix(),h=j=>{g(j.target.value.trim())};if(r||!n)return null;const x=async j=>{j.preventDefault();try{await p(l),t({text:"License key updated",type:"success"}),a(),i()}catch(b){s(G(b))}},m={Seats:n.resources.seats,"Release templates":n.resources.releaseTemplates,"Edge instances":n.resources.edgeInstances};return e.jsx(ne,{header:e.jsx(oe,{title:"Unleash Enterprise License"}),children:e.jsxs(Px,{children:[e.jsx(k,{condition:!!n.token,show:e.jsxs("div",{children:[e.jsxs(St,{children:[e.jsx(vt,{children:"Customer"}),e.jsx(Ct,{children:n.customer})]}),e.jsxs(St,{children:[e.jsx(vt,{children:"Instance Name"}),e.jsx(Ct,{children:n.instanceName})]}),e.jsxs(St,{children:[e.jsx(vt,{children:"Plan"}),e.jsx(Ct,{children:n.plan})]}),Object.entries(m).map(([j,b])=>b&&e.jsxs(St,{children:[e.jsx(vt,{children:j}),e.jsx(Ct,{children:b})]},j)),e.jsxs(St,{children:[e.jsx(vt,{children:"Expire at"}),e.jsx(Ct,{children:_o(n.expireAt,c.locale)})]})]}),elseShow:e.jsx("p",{children:"You do not have a registered Unleash Enterprise License."})}),e.jsxs("form",{onSubmit:x,children:[e.jsx(se,{onChange:h,label:"New license key",name:"licenseKey",value:l,style:{width:"100%"},variant:"outlined",size:"small",multiline:!0,rows:6,required:!0}),e.jsx(f,{container:!0,spacing:3,marginTop:2,children:e.jsxs(f,{item:!0,md:5,children:[e.jsx(N,{variant:"contained",color:"primary",type:"submit",disabled:r,children:"Update license key"})," ",e.jsx("p",{children:e.jsx("small",{style:{color:"red"},children:o==null?void 0:o.message})})]})})]})]})})},Bx=()=>e.jsx("div",{children:e.jsx(Se,{permissions:[Q],children:e.jsx(Lx,{})})});var gn={},Ux=ct;Object.defineProperty(gn,"__esModule",{value:!0});var Za=gn.default=void 0,$x=Ux(lt()),Ox=e,_x=(0,$x.default)((0,Ox.jsx)("path",{d:"M6 6v2h8.59L5 17.59 6.41 19 16 9.41V18h2V6z"}),"ArrowOutward");Za=gn.default=_x;const Mx="/static/easyToDeploy-rluTX8sF.png",Nx=t=>u.createElement("svg",{width:312,height:145,viewBox:"0 0 312 145",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},u.createElement("rect",{width:312,height:144.519,rx:8,fill:"#F1F0FC"}),u.createElement("g",{opacity:.2},u.createElement("circle",{cx:159.392,cy:72.1494,r:59.9326,stroke:"#657A80",strokeWidth:1.35669,strokeLinecap:"square"}),u.createElement("ellipse",{cx:159.392,cy:72.2595,rx:43.5873,ry:60.2595,stroke:"#657A80",strokeWidth:1.35669,strokeLinecap:"square"}),u.createElement("ellipse",{cx:159.828,cy:72.1494,rx:27.2421,ry:59.9326,stroke:"#657A80",strokeWidth:1.35669,strokeLinecap:"square"}),u.createElement("ellipse",{cx:159.828,cy:72.1494,rx:10.8968,ry:59.9326,stroke:"#657A80",strokeWidth:1.35669,strokeLinecap:"square"})),u.createElement("g",{opacity:.2},u.createElement("mask",{id:"mask0_35832_1341",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:99,y:12,width:121,height:121},u.createElement("circle",{cx:159.392,cy:72.1494,r:59.2542,fill:"#92A1A5",stroke:"#657A80",strokeWidth:1.35669})),u.createElement("g",{mask:"url(#mask0_35832_1341)"},u.createElement("path",{d:"M99.4591 48.1777C99.4591 48.1777 112.535 59.2925 159.392 59.2925C206.248 59.2925 219.324 48.1777 219.324 48.1777",stroke:"#657A80",strokeWidth:1.35669}),u.createElement("path",{d:"M99.4591 28.3438C99.4591 28.3438 112.535 45.7787 159.392 45.7787C206.248 45.7787 219.324 28.3438 219.324 28.3438",stroke:"#657A80",strokeWidth:1.35669}),u.createElement("path",{d:"M99.4591 2.19141C99.4591 2.19141 112.535 33.1384 159.392 33.1384C206.248 33.1384 219.324 2.19141 219.324 2.19141",stroke:"#657A80",strokeWidth:1.35669}),u.createElement("path",{d:"M99.4591 -39.4336C99.4591 -39.4336 112.535 21.3707 159.392 21.3707C206.248 21.3707 219.324 -39.4336 219.324 -39.4336",stroke:"#657A80",strokeWidth:1.35669}),u.createElement("line",{x1:99.4591,y1:71.472,x2:219.324,y2:71.472,stroke:"#657A80",strokeWidth:1.35669}),u.createElement("path",{d:"M219.325 95.6855C219.325 95.6855 206.249 84.5708 159.392 84.5708C112.536 84.5708 99.4596 95.6855 99.4596 95.6855",stroke:"#657A80",strokeWidth:1.35669}),u.createElement("path",{d:"M219.325 115.518C219.325 115.518 206.249 98.0826 159.392 98.0826C112.536 98.0826 99.4596 115.518 99.4596 115.518",stroke:"#657A80",strokeWidth:1.35669}),u.createElement("path",{d:"M219.325 141.672C219.325 141.672 206.249 110.725 159.392 110.725C112.536 110.725 99.4596 141.672 99.4596 141.672",stroke:"#657A80",strokeWidth:1.35669}),u.createElement("path",{d:"M219.325 183.297C219.325 183.297 206.248 122.493 159.392 122.493C112.536 122.493 99.4594 183.297 99.4594 183.297",stroke:"#657A80",strokeWidth:1.35669}))),u.createElement("rect",{x:184.932,y:83.9727,width:51.1664,height:25.5832,rx:12.7916,transform:"rotate(-180 184.932 83.9727)",fill:"url(#paint0_linear_35832_1341)"}),u.createElement("ellipse",{cx:172.107,cy:71.1803,rx:12.8251,ry:12.7916,fill:"#817AFE"}),u.createElement("path",{d:"M175.693 67.627H168.587V74.7334H175.693V67.627Z",fill:"white"}),u.createElement("path",{d:"M139.097 58.4531L139.004 51.4804L133.012 55.0473L139.097 58.4531ZM123.133 50.0488L129.385 53.1377L128.934 46.1789L123.133 50.0488ZM136.317 53.7832L136.728 53.3399C135.792 52.474 134.566 51.5847 132.963 50.7408L132.682 51.2751L132.4 51.8095C133.918 52.6085 135.055 53.4382 135.907 54.2265L136.317 53.7832ZM132.682 51.2751L132.963 50.7408C131.36 49.8968 129.933 49.3899 128.69 49.1084L128.556 49.6974L128.423 50.2864C129.555 50.5427 130.883 51.0105 132.4 51.8095L132.682 51.2751Z",fill:"#6C65E5"}),u.createElement("path",{d:"M183.041 43.7773L176.874 40.5221L177.139 47.4904L183.041 43.7773ZM167.263 56.659L172.082 51.6188L165.308 49.9655L167.263 56.659ZM177.61 43.9834L177.42 43.4101C175.852 43.9294 174.048 44.8631 172.087 46.4639L172.469 46.9317L172.851 47.3995C174.707 45.8841 176.383 45.026 177.8 44.5567L177.61 43.9834ZM172.469 46.9317L172.087 46.4639C170.126 48.0648 168.851 49.6454 168.028 51.0778L168.552 51.3785L169.076 51.6792C169.819 50.3847 170.995 48.9149 172.851 47.3995L172.469 46.9317Z",fill:"#6C65E5"}),u.createElement("path",{d:"M161.818 87.9746L165.538 93.8726L158.57 94.1455L161.818 87.9746ZM152.37 104.338L156.09 98.4405L159.338 104.611L152.37 104.338ZM162.03 93.4062L162.617 93.5508C162.284 94.9012 161.682 96.4622 160.667 98.2196L160.144 97.9176L159.621 97.6157C160.584 95.948 161.14 94.4924 161.444 93.2617L162.03 93.4062ZM160.144 97.9176L160.667 98.2196C159.652 99.977 158.602 101.279 157.599 102.242L157.18 101.807L156.762 101.371C157.676 100.493 158.658 99.2834 159.621 97.6157L160.144 97.9176Z",fill:"#6C65E5"}),u.createElement("rect",{x:122.135,y:56.5781,width:29.4595,height:14.7297,rx:7.36487,transform:"rotate(-180 122.135 56.5781)",fill:"url(#paint1_linear_35832_1341)"}),u.createElement("ellipse",{cx:114.751,cy:49.2125,rx:7.38412,ry:7.36487,fill:"#1A4049"}),u.createElement("path",{d:"M116.816 47.168H112.724V51.2596H116.816V47.168Z",fill:"#EDF0F1"}),u.createElement("rect",{x:215.746,y:51.1504,width:29.4595,height:14.7297,rx:7.36487,transform:"rotate(-180 215.746 51.1504)",fill:"url(#paint2_linear_35832_1341)"}),u.createElement("ellipse",{cx:208.362,cy:43.7848,rx:7.38412,ry:7.36487,fill:"#1A4049"}),u.createElement("path",{d:"M210.428 41.7383H206.336V45.8299H210.428V41.7383Z",fill:"#EDF0F1"}),u.createElement("rect",{x:150.626,y:116.271,width:29.4595,height:14.7297,rx:7.36487,transform:"rotate(-180 150.626 116.271)",fill:"url(#paint3_linear_35832_1341)"}),u.createElement("ellipse",{cx:143.241,cy:108.906,rx:7.38412,ry:7.36487,fill:"#1A4049"}),u.createElement("path",{d:"M145.306 106.859H141.215V110.951H145.306V106.859Z",fill:"#EDF0F1"}),u.createElement("defs",null,u.createElement("linearGradient",{id:"paint0_linear_35832_1341",x1:184.921,y1:96.703,x2:236.126,y2:96.703,gradientUnits:"userSpaceOnUse"},u.createElement("stop",{stopColor:"#1A4049",stopOpacity:0}),u.createElement("stop",{offset:1,stopColor:"#0E1A1D"})),u.createElement("linearGradient",{id:"paint1_linear_35832_1341",x1:122.129,y1:63.9077,x2:151.611,y2:63.9077,gradientUnits:"userSpaceOnUse"},u.createElement("stop",{stopColor:"#657A80",stopOpacity:0}),u.createElement("stop",{offset:1,stopColor:"#1A4049",stopOpacity:.75})),u.createElement("linearGradient",{id:"paint2_linear_35832_1341",x1:215.74,y1:58.48,x2:245.222,y2:58.48,gradientUnits:"userSpaceOnUse"},u.createElement("stop",{stopColor:"#657A80",stopOpacity:0}),u.createElement("stop",{offset:1,stopColor:"#1A4049",stopOpacity:.75})),u.createElement("linearGradient",{id:"paint3_linear_35832_1341",x1:150.619,y1:123.601,x2:180.101,y2:123.601,gradientUnits:"userSpaceOnUse"},u.createElement("stop",{stopColor:"#657A80",stopOpacity:0}),u.createElement("stop",{offset:1,stopColor:"#1A4049",stopOpacity:.75})))),Fx=d(V)(({theme:t})=>({fontSize:t.typography.body1.fontSize,"& > .MuiAlert-icon":{paddingBlock:"7px"},"& > .MuiAlert-message":{padding:t.spacing(1),display:"flex",flexFlow:"row wrap",justifyContent:"space-between",width:"100%",gap:t.spacing(1)},"&.MuiPaper-root":{backgroundColor:t.palette.secondary.light,color:t.palette.text.primary,border:`1px solid ${t.palette.secondary.border}`}})),Wx=d("div")(({theme:t})=>({width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:t.spacing(2)})),jo=d("div")(({theme:t})=>({display:"flex",flexDirection:"column",alignItems:"start",gap:t.spacing(1),flex:"1 1 auto"})),qx=d(N)(({theme:t})=>({"&&":{marginTop:t.spacing(1),color:"white"}})),Gx=d(Nx)(({theme:t})=>({flex:0,width:"auto",display:"block",[t.breakpoints.down("md")]:{display:"none"}})),zx=({...t})=>{const[s,n]=aa("enterpriseEdgeUIDismissibleAlert","open");return e.jsx(Or,{in:s==="open",children:e.jsx(Fx,{onClose:()=>n("closed"),icon:!1,...t,children:e.jsxs(Wx,{children:[e.jsxs(jo,{children:[e.jsx(T,{variant:"h3",children:"Instant flag updates worldwide"}),e.jsx(T,{variant:"body2",color:"text.secondary",children:"Enterprise Edge is a high-performance proxy between your SDKs and Unleash, giving you global reach, minimal latency, and making flag changes instantly available to your users."}),e.jsx(qx,{component:ae,to:"/admin/enterprise-edge",variant:"contained",children:"Check out Enterprise Edge"})]}),e.jsx(jo,{sx:{alignItems:"end"},children:e.jsx(Gx,{})})]})})})},ht=1505,Hx=d(f)(({theme:t})=>({display:"flex",flexDirection:"column",gap:t.spacing(2)})),Vx=d(Fe)(({theme:t})=>({position:"relative",height:t.spacing(44),padding:t.spacing(3),borderRadius:`${t.shape.borderRadiusLarge}px`,boxShadow:"none",color:"white",backgroundColor:t.palette.web.main,overflow:"hidden",[t.breakpoints.down(ht)]:{height:t.spacing(28),paddingBottom:t.spacing(6)},[t.breakpoints.down(800)]:{height:t.spacing(34)}})),Yx=d(Fe)(({theme:t})=>({minHeight:t.spacing(44),padding:t.spacing(3),borderRadius:`${t.shape.borderRadiusLarge}px`,boxShadow:"none",[t.breakpoints.up("md")]:{flexDirection:"row",flexWrap:"nowrap"}})),Jx=d(T)(({theme:t})=>({width:"100%",fontSize:t.fontSizes.largeHeader,fontWeight:"bold",marginBottom:t.spacing(1)})),Kx=d("div")(({theme:t})=>({marginBottom:t.spacing(6),[t.breakpoints.down(ht)]:{marginBottom:t.spacing()}})),fo=d(T)(({theme:t})=>({fontSize:t.fontSizes.bodySize,marginTop:t.spacing(2),marginBottom:t.spacing(2),flexDirection:"row",display:"flex",gap:t.spacing(1),justifyContent:"space-between",[t.breakpoints.down(ht)]:{maxWidth:t.spacing(65)},[t.breakpoints.down(800)]:{flexDirection:"column",justifyContent:"start"}})),yo=d("span")(({theme:t})=>({fontSize:t.fontSizes.bodySize,fontWeight:"bold"})),bo=d("span")({color:"white"}),Zx=d(T)(({theme:t})=>({fontSize:t.fontSizes.mainHeader,marginTop:t.spacing(2),marginBottom:t.spacing(4)})),Qx=d(f)(({theme:t})=>({display:"flex",flexDirection:"row",gap:t.spacing(2),justifyContent:"space-between",marginBottom:t.spacing(7)})),Nt=d(f)(({theme:t})=>({width:t.spacing(16),aspectRatio:"1 / 1",padding:t.spacing(2),alignItems:"center",borderRadius:"50%",backgroundColor:t.mode==="light"?"#F1F0FC":"#302E42"})),Ft=d(_)({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}),Wt=d(T)(({theme:t})=>({color:t.palette.primary.main,fontSize:t.fontSizes.largeHeader,fontWeight:"bold",marginTop:t.spacing(1)})),qt=d(T)(({theme:t})=>({color:t.palette.text.primary,fontSize:t.fontSizes.bodySize})),Xx=d("div")(({theme:t})=>({display:"flex",justifyContent:"flex-start",marginTop:t.spacing(3)})),em=d("div")(({theme:t})=>({position:"absolute",left:t.spacing(2.5),bottom:t.spacing(3),[t.breakpoints.down(ht)]:{position:"static",marginTop:t.spacing(2)}})),tm=d(ae)(({theme:t})=>({color:t.palette.common.white,textDecoration:"underline !important",fontSize:t.typography.body2.fontSize,display:"flex",alignItems:"center",gap:t.spacing(1)})),sm=d("div")(({theme:t})=>({display:"flex",justifyContent:"flex-end",marginTop:t.spacing(-6),marginRight:t.spacing(-10),[t.breakpoints.down(ht)]:{marginTop:t.spacing(-22),marginRight:t.spacing(-12),paddingTop:t.spacing(1)},[t.breakpoints.down(800)]:{paddingTop:0}})),nm=d("img")(({theme:t})=>({width:t.spacing(33),transform:"rotate(180deg)",clipPath:"polygon(21% 28%, 100% 28%, 21% 94%)"})),om=({plan:t,instanceId:s,version:n})=>e.jsxs(Vx,{children:[e.jsxs(Kx,{children:[e.jsx("div",{children:"Current plan"}),e.jsx(Jx,{variant:"h3",children:t})]}),e.jsxs(fo,{children:[e.jsx(yo,{children:"Instance id"}),e.jsx(bo,{children:s})]}),e.jsxs(fo,{children:[e.jsx(yo,{children:"Unleash version"}),e.jsx(bo,{children:n})]}),e.jsx(em,{children:e.jsxs(tm,{to:"https://docs.getunleash.io/availability#versioning",target:"_blank",rel:"noopener noreferrer",children:[e.jsx(_r,{sx:{color:o=>o.palette.common.white}}),"Learn about versioning"]})}),e.jsx(sm,{children:e.jsx(nm,{src:ia(Mx)})})]}),am=({users:t,featureToggles:s,projects:n,environments:o})=>{const a=we();return e.jsxs(Yx,{children:[e.jsx(Zx,{children:"Instance statistics"}),e.jsxs(Qx,{container:!0,children:[e.jsx(Nt,{item:!0,children:e.jsxs(Ft,{children:[e.jsx(Wt,{children:t}),e.jsx(qt,{children:"Users"})]})}),e.jsx(Nt,{item:!0,children:e.jsxs(Ft,{children:[e.jsx(Wt,{children:s}),e.jsx(qt,{children:"Feature flags"})]})}),e.jsx(Nt,{item:!0,children:e.jsxs(Ft,{children:[e.jsx(Wt,{children:n}),e.jsx(qt,{children:"Projects"})]})}),e.jsx(Nt,{item:!0,children:e.jsxs(Ft,{children:[e.jsx(Wt,{children:o}),e.jsx(qt,{children:"Environments"})]})})]}),e.jsx(Xx,{children:e.jsx(N,{rel:"noreferrer",endIcon:e.jsx(Za,{}),onClick:()=>{a("/admin/instance")},children:"View all instance statistics"})})]})},im=()=>{var g,p,h,x,m,j;const t=La(),s=Dt(),n=je(s.breakpoints.down(ht)),o=n?12:7,a=n?12:5,{isOss:i,isPro:r,isEnterprise:c}=W(),l=i()?"Open source":r()?"Pro":c()?"Enterprise":"Unknown";return e.jsxs(Hx,{children:[e.jsx(zx,{}),t&&!t.loading&&e.jsxs(f,{container:!0,spacing:3,children:[e.jsx(f,{item:!0,md:a,sm:12,xs:12,children:e.jsx(om,{plan:l,instanceId:((g=t.stats)==null?void 0:g.instanceId)??"unknown",version:((p=t.stats)==null?void 0:p.versionEnterprise)??"unknown"})}),e.jsx(f,{item:!0,md:o,sm:12,xs:12,children:e.jsx(am,{environments:((h=t.stats)==null?void 0:h.environments)??0,featureToggles:((x=t.stats)==null?void 0:x.featureToggles)??0,projects:((m=t.stats)==null?void 0:m.projects)??0,users:((j=t.stats)==null?void 0:j.users)??0})})]})]})},rm=u.lazy(()=>ut(()=>import("./EnterpriseEdge-Cp-pGMa0.js"),[])),lm=()=>e.jsx(e.Fragment,{children:e.jsxs(it,{children:[e.jsx(M,{index:!0,element:e.jsx(im,{})}),e.jsx(M,{path:"users/*",element:e.jsx(hx,{})}),e.jsx(M,{path:"api",element:e.jsx(el,{})}),e.jsx(M,{path:"api/create-token",element:e.jsx(ol,{})}),e.jsx(M,{path:"service-accounts",element:e.jsx(Th,{})}),e.jsx(M,{path:"create-user",element:e.jsx(Oh,{})}),e.jsx(M,{path:"invite-link",element:e.jsx(Mh,{})}),e.jsx(M,{path:"groups/*",element:e.jsx(ku,{})}),e.jsx(M,{path:"roles/*",element:e.jsx(nh,{})}),e.jsx(M,{path:"instance",element:e.jsx(Ru,{})}),e.jsx(M,{path:"enterprise-edge",element:e.jsx(rm,{})}),e.jsx(M,{path:"network/*",element:e.jsx(hp,{})}),e.jsx(M,{path:"maintenance",element:e.jsx(sp,{})}),e.jsx(M,{path:"banners",element:e.jsx(Rx,{})}),e.jsx(M,{path:"license",element:e.jsx(Bx,{})}),e.jsx(M,{path:"cors",element:e.jsx(kd,{})}),e.jsx(M,{path:"auth/*",element:e.jsx(El,{})}),e.jsx(M,{path:"admin-invoices",element:e.jsx(bd,{})}),e.jsx(M,{path:"billing",element:e.jsx(md,{})}),e.jsx(M,{path:"instance-privacy",element:e.jsx(Hu,{})}),e.jsx(M,{path:"*",element:e.jsx(ca,{})})]})}),fm=Object.freeze(Object.defineProperty({__proto__:null,default:lm},Symbol.toStringTag,{value:"Module"}));export{fm as L,Nx as S,Ml as T,ga as a,_l as b,hm as c,xm as d,ql as e,gm as f,jm as g,ma as h,mm as p,Hl as u};
38
+ --data-raw '${JSON.stringify(O,void 0,2)}'`,J=async K=>{if(K.preventDefault(),!!E)try{R?await i(t.id,O):await a(O),c({text:`Banner ${R?"updated":"added"} successfully`,type:"success"}),o(),n(!1)}catch(q){l(G(q))}};return e.jsx(ls,{open:s,onClose:()=>{n(!1)},label:B,children:e.jsx(Ae,{loading:r,modal:!0,title:B,description:"Banners allow you to display messages to other users inside your Unleash instance.",documentationLink:"https://docs.getunleash.io/concepts/banners",documentationLinkLabel:"Banners documentation",formatApiCode:H,children:e.jsxs(wx,{onSubmit:J,children:[e.jsx(Cx,{enabled:p,message:x,variant:j,sticky:y,icon:A,link:D,linkText:U,dialogTitle:w,dialog:I,setEnabled:h,setMessage:m,setVariant:b,setSticky:v,setIcon:C,setLink:S,setLinkText:$,setDialogTitle:P,setDialog:L}),e.jsxs(Tx,{children:[e.jsxs(N,{type:"submit",variant:"contained",color:"primary",disabled:!E,children:[R?"Save":"Add"," banner"]}),e.jsx(kx,{onClick:()=>{n(!1)},children:"Cancel"})]})]})})})},Ax=()=>{const{setToastData:t,setToastApiError:s}=Y(),{banners:n,refetch:o,loading:a}=ua(),{toggleBanner:i,removeBanner:r}=Ka(),[c,l]=u.useState(""),[g,p]=u.useState(!1),[h,x]=u.useState(!1),[m,j]=u.useState(),b=async(I,L)=>{try{await i(I.id,L),t({text:`"${I.message}" has been ${L?"enabled":"disabled"}`,type:"success"}),o()}catch(R){s(G(R))}},y=async I=>{try{await r(I.id),t({text:`"${I.message}" has been deleted`,type:"success"}),o(),x(!1)}catch(L){s(G(L))}},v=je(Ue.breakpoints.down("md")),A=u.useMemo(()=>[{Header:"Banner",accessor:"message",Cell:({row:{original:I}})=>e.jsx(da,{banner:{...I,sticky:!1},inline:!0,maxHeight:42}),disableSortBy:!0,minWidth:200,searchable:!0},{Header:"Created",accessor:"createdAt",Cell:me,width:120,maxWidth:120},{Header:"Enabled",accessor:"enabled",Cell:({row:{original:I}})=>e.jsx(Lr,{checked:I.enabled,setChecked:L=>b(I,L)}),sortType:"boolean",width:90,maxWidth:90},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:I}})=>e.jsx(xx,{onEdit:()=>{j(I),p(!0)},onDelete:()=>{j(I),x(!0)}}),width:100,disableSortBy:!0}],[]),[C]=u.useState({sortBy:[{id:"createdAt",desc:!0}]}),{data:D,getSearchText:S}=dt(A,c,n),{headerGroups:U,rows:$,prepareRow:w,setHiddenColumns:P}=F.useTable({columns:A,data:D,initialState:C,sortTypes:fe,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0,defaultColumn:{Cell:te}},F.useSortBy,F.useFlexLayout);return It([{condition:v,columns:["createdAt"]}],P,A),e.jsxs(ne,{isLoading:a,header:e.jsx(oe,{title:`Banners (${$.length})`,actions:e.jsxs(e.Fragment,{children:[e.jsx(k,{condition:!v,show:e.jsxs(e.Fragment,{children:[e.jsx(ue,{initialValue:c,onChange:l}),e.jsx(oe.Divider,{})]})}),e.jsx(N,{variant:"contained",color:"primary",onClick:()=>{j(void 0),p(!0)},children:"New banner"})]}),children:e.jsx(k,{condition:v,show:e.jsx(ue,{initialValue:c,onChange:l})})}),children:[e.jsx(qe,{value:S(c),children:e.jsx(ye,{rows:$,headerGroups:U,prepareRow:w})}),e.jsx(k,{condition:$.length===0,show:e.jsx(k,{condition:(c==null?void 0:c.length)>0,show:e.jsxs(ce,{children:["No banners found matching “",c,"”"]}),elseShow:e.jsx(ce,{children:"No banners available. Get started by adding one."})})}),e.jsx(Ex,{banner:m,open:g,setOpen:p}),e.jsx(mx,{banner:m,open:h,setOpen:x,onConfirm:y})]})},Rx=()=>{const{isEnterprise:t}=W();return t()?e.jsx("div",{children:e.jsx(Se,{permissions:[Q,Br],children:e.jsx(Ax,{})})}):e.jsx(at,{feature:"banners",page:!0})},Dx=async(t,s)=>{if(t){if(s){const n=await s.json();throw t({message:n.message}),new Error(n.message)}throw new Error("Did not receive a response from the server.")}},Ix=()=>{const{makeRequest:t,createRequest:s,errors:n,loading:o}=pe({propagateErrors:!0,handleBadRequest:Dx});return{updateLicenseKey:async i=>{const c=s("api/admin/license",{method:"POST",body:JSON.stringify({token:i})});await t(c.caller,c.id)},errors:n,loading:o}},Px=d(_)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),St=d("div")(()=>({display:"table-row"})),vt=d("p")(({theme:t})=>({display:"table-cell",fontWeight:t.fontWeight.bold,paddingTop:t.spacing(2)})),Ct=d("p")(({theme:t})=>({display:"table-cell",paddingTop:t.spacing(2),paddingLeft:t.spacing(4)})),Lx=()=>{const{setToastData:t,setToastApiError:s}=Y(),{license:n,error:o,refetchLicense:a}=Ur(),{reCheckLicense:i}=$r(),{loading:r}=W(),{locationSettings:c}=Uo(),[l,g]=u.useState(""),{updateLicenseKey:p}=Ix(),h=j=>{g(j.target.value.trim())};if(r||!n)return null;const x=async j=>{j.preventDefault();try{await p(l),t({text:"License key updated",type:"success"}),a(),i()}catch(b){s(G(b))}},m={Seats:n.resources.seats,"Release templates":n.resources.releaseTemplates,"Edge instances":n.resources.edgeInstances};return e.jsx(ne,{header:e.jsx(oe,{title:"Unleash Enterprise License"}),children:e.jsxs(Px,{children:[e.jsx(k,{condition:!!n.token,show:e.jsxs("div",{children:[e.jsxs(St,{children:[e.jsx(vt,{children:"Customer"}),e.jsx(Ct,{children:n.customer})]}),e.jsxs(St,{children:[e.jsx(vt,{children:"Instance Name"}),e.jsx(Ct,{children:n.instanceName})]}),e.jsxs(St,{children:[e.jsx(vt,{children:"Plan"}),e.jsx(Ct,{children:n.plan})]}),Object.entries(m).map(([j,b])=>b&&e.jsxs(St,{children:[e.jsx(vt,{children:j}),e.jsx(Ct,{children:b})]},j)),e.jsxs(St,{children:[e.jsx(vt,{children:"Expire at"}),e.jsx(Ct,{children:_o(n.expireAt,c.locale)})]})]}),elseShow:e.jsx("p",{children:"You do not have a registered Unleash Enterprise License."})}),e.jsxs("form",{onSubmit:x,children:[e.jsx(se,{onChange:h,label:"New license key",name:"licenseKey",value:l,style:{width:"100%"},variant:"outlined",size:"small",multiline:!0,rows:6,required:!0}),e.jsx(f,{container:!0,spacing:3,marginTop:2,children:e.jsxs(f,{item:!0,md:5,children:[e.jsx(N,{variant:"contained",color:"primary",type:"submit",disabled:r,children:"Update license key"})," ",e.jsx("p",{children:e.jsx("small",{style:{color:"red"},children:o==null?void 0:o.message})})]})})]})]})})},Bx=()=>e.jsx("div",{children:e.jsx(Se,{permissions:[Q],children:e.jsx(Lx,{})})});var gn={},Ux=ct;Object.defineProperty(gn,"__esModule",{value:!0});var Za=gn.default=void 0,$x=Ux(lt()),Ox=e,_x=(0,$x.default)((0,Ox.jsx)("path",{d:"M6 6v2h8.59L5 17.59 6.41 19 16 9.41V18h2V6z"}),"ArrowOutward");Za=gn.default=_x;const Mx="/static/easyToDeploy-rluTX8sF.png",Nx=t=>u.createElement("svg",{width:312,height:145,viewBox:"0 0 312 145",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},u.createElement("rect",{width:312,height:144.519,rx:8,fill:"#F1F0FC"}),u.createElement("g",{opacity:.2},u.createElement("circle",{cx:159.392,cy:72.1494,r:59.9326,stroke:"#657A80",strokeWidth:1.35669,strokeLinecap:"square"}),u.createElement("ellipse",{cx:159.392,cy:72.2595,rx:43.5873,ry:60.2595,stroke:"#657A80",strokeWidth:1.35669,strokeLinecap:"square"}),u.createElement("ellipse",{cx:159.828,cy:72.1494,rx:27.2421,ry:59.9326,stroke:"#657A80",strokeWidth:1.35669,strokeLinecap:"square"}),u.createElement("ellipse",{cx:159.828,cy:72.1494,rx:10.8968,ry:59.9326,stroke:"#657A80",strokeWidth:1.35669,strokeLinecap:"square"})),u.createElement("g",{opacity:.2},u.createElement("mask",{id:"mask0_35832_1341",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:99,y:12,width:121,height:121},u.createElement("circle",{cx:159.392,cy:72.1494,r:59.2542,fill:"#92A1A5",stroke:"#657A80",strokeWidth:1.35669})),u.createElement("g",{mask:"url(#mask0_35832_1341)"},u.createElement("path",{d:"M99.4591 48.1777C99.4591 48.1777 112.535 59.2925 159.392 59.2925C206.248 59.2925 219.324 48.1777 219.324 48.1777",stroke:"#657A80",strokeWidth:1.35669}),u.createElement("path",{d:"M99.4591 28.3438C99.4591 28.3438 112.535 45.7787 159.392 45.7787C206.248 45.7787 219.324 28.3438 219.324 28.3438",stroke:"#657A80",strokeWidth:1.35669}),u.createElement("path",{d:"M99.4591 2.19141C99.4591 2.19141 112.535 33.1384 159.392 33.1384C206.248 33.1384 219.324 2.19141 219.324 2.19141",stroke:"#657A80",strokeWidth:1.35669}),u.createElement("path",{d:"M99.4591 -39.4336C99.4591 -39.4336 112.535 21.3707 159.392 21.3707C206.248 21.3707 219.324 -39.4336 219.324 -39.4336",stroke:"#657A80",strokeWidth:1.35669}),u.createElement("line",{x1:99.4591,y1:71.472,x2:219.324,y2:71.472,stroke:"#657A80",strokeWidth:1.35669}),u.createElement("path",{d:"M219.325 95.6855C219.325 95.6855 206.249 84.5708 159.392 84.5708C112.536 84.5708 99.4596 95.6855 99.4596 95.6855",stroke:"#657A80",strokeWidth:1.35669}),u.createElement("path",{d:"M219.325 115.518C219.325 115.518 206.249 98.0826 159.392 98.0826C112.536 98.0826 99.4596 115.518 99.4596 115.518",stroke:"#657A80",strokeWidth:1.35669}),u.createElement("path",{d:"M219.325 141.672C219.325 141.672 206.249 110.725 159.392 110.725C112.536 110.725 99.4596 141.672 99.4596 141.672",stroke:"#657A80",strokeWidth:1.35669}),u.createElement("path",{d:"M219.325 183.297C219.325 183.297 206.248 122.493 159.392 122.493C112.536 122.493 99.4594 183.297 99.4594 183.297",stroke:"#657A80",strokeWidth:1.35669}))),u.createElement("rect",{x:184.932,y:83.9727,width:51.1664,height:25.5832,rx:12.7916,transform:"rotate(-180 184.932 83.9727)",fill:"url(#paint0_linear_35832_1341)"}),u.createElement("ellipse",{cx:172.107,cy:71.1803,rx:12.8251,ry:12.7916,fill:"#817AFE"}),u.createElement("path",{d:"M175.693 67.627H168.587V74.7334H175.693V67.627Z",fill:"white"}),u.createElement("path",{d:"M139.097 58.4531L139.004 51.4804L133.012 55.0473L139.097 58.4531ZM123.133 50.0488L129.385 53.1377L128.934 46.1789L123.133 50.0488ZM136.317 53.7832L136.728 53.3399C135.792 52.474 134.566 51.5847 132.963 50.7408L132.682 51.2751L132.4 51.8095C133.918 52.6085 135.055 53.4382 135.907 54.2265L136.317 53.7832ZM132.682 51.2751L132.963 50.7408C131.36 49.8968 129.933 49.3899 128.69 49.1084L128.556 49.6974L128.423 50.2864C129.555 50.5427 130.883 51.0105 132.4 51.8095L132.682 51.2751Z",fill:"#6C65E5"}),u.createElement("path",{d:"M183.041 43.7773L176.874 40.5221L177.139 47.4904L183.041 43.7773ZM167.263 56.659L172.082 51.6188L165.308 49.9655L167.263 56.659ZM177.61 43.9834L177.42 43.4101C175.852 43.9294 174.048 44.8631 172.087 46.4639L172.469 46.9317L172.851 47.3995C174.707 45.8841 176.383 45.026 177.8 44.5567L177.61 43.9834ZM172.469 46.9317L172.087 46.4639C170.126 48.0648 168.851 49.6454 168.028 51.0778L168.552 51.3785L169.076 51.6792C169.819 50.3847 170.995 48.9149 172.851 47.3995L172.469 46.9317Z",fill:"#6C65E5"}),u.createElement("path",{d:"M161.818 87.9746L165.538 93.8726L158.57 94.1455L161.818 87.9746ZM152.37 104.338L156.09 98.4405L159.338 104.611L152.37 104.338ZM162.03 93.4062L162.617 93.5508C162.284 94.9012 161.682 96.4622 160.667 98.2196L160.144 97.9176L159.621 97.6157C160.584 95.948 161.14 94.4924 161.444 93.2617L162.03 93.4062ZM160.144 97.9176L160.667 98.2196C159.652 99.977 158.602 101.279 157.599 102.242L157.18 101.807L156.762 101.371C157.676 100.493 158.658 99.2834 159.621 97.6157L160.144 97.9176Z",fill:"#6C65E5"}),u.createElement("rect",{x:122.135,y:56.5781,width:29.4595,height:14.7297,rx:7.36487,transform:"rotate(-180 122.135 56.5781)",fill:"url(#paint1_linear_35832_1341)"}),u.createElement("ellipse",{cx:114.751,cy:49.2125,rx:7.38412,ry:7.36487,fill:"#1A4049"}),u.createElement("path",{d:"M116.816 47.168H112.724V51.2596H116.816V47.168Z",fill:"#EDF0F1"}),u.createElement("rect",{x:215.746,y:51.1504,width:29.4595,height:14.7297,rx:7.36487,transform:"rotate(-180 215.746 51.1504)",fill:"url(#paint2_linear_35832_1341)"}),u.createElement("ellipse",{cx:208.362,cy:43.7848,rx:7.38412,ry:7.36487,fill:"#1A4049"}),u.createElement("path",{d:"M210.428 41.7383H206.336V45.8299H210.428V41.7383Z",fill:"#EDF0F1"}),u.createElement("rect",{x:150.626,y:116.271,width:29.4595,height:14.7297,rx:7.36487,transform:"rotate(-180 150.626 116.271)",fill:"url(#paint3_linear_35832_1341)"}),u.createElement("ellipse",{cx:143.241,cy:108.906,rx:7.38412,ry:7.36487,fill:"#1A4049"}),u.createElement("path",{d:"M145.306 106.859H141.215V110.951H145.306V106.859Z",fill:"#EDF0F1"}),u.createElement("defs",null,u.createElement("linearGradient",{id:"paint0_linear_35832_1341",x1:184.921,y1:96.703,x2:236.126,y2:96.703,gradientUnits:"userSpaceOnUse"},u.createElement("stop",{stopColor:"#1A4049",stopOpacity:0}),u.createElement("stop",{offset:1,stopColor:"#0E1A1D"})),u.createElement("linearGradient",{id:"paint1_linear_35832_1341",x1:122.129,y1:63.9077,x2:151.611,y2:63.9077,gradientUnits:"userSpaceOnUse"},u.createElement("stop",{stopColor:"#657A80",stopOpacity:0}),u.createElement("stop",{offset:1,stopColor:"#1A4049",stopOpacity:.75})),u.createElement("linearGradient",{id:"paint2_linear_35832_1341",x1:215.74,y1:58.48,x2:245.222,y2:58.48,gradientUnits:"userSpaceOnUse"},u.createElement("stop",{stopColor:"#657A80",stopOpacity:0}),u.createElement("stop",{offset:1,stopColor:"#1A4049",stopOpacity:.75})),u.createElement("linearGradient",{id:"paint3_linear_35832_1341",x1:150.619,y1:123.601,x2:180.101,y2:123.601,gradientUnits:"userSpaceOnUse"},u.createElement("stop",{stopColor:"#657A80",stopOpacity:0}),u.createElement("stop",{offset:1,stopColor:"#1A4049",stopOpacity:.75})))),Fx=d(V)(({theme:t})=>({fontSize:t.typography.body1.fontSize,"& > .MuiAlert-icon":{paddingBlock:"7px"},"& > .MuiAlert-message":{padding:t.spacing(1),display:"flex",flexFlow:"row wrap",justifyContent:"space-between",width:"100%",gap:t.spacing(1)},"&.MuiPaper-root":{backgroundColor:t.palette.secondary.light,color:t.palette.text.primary,border:`1px solid ${t.palette.secondary.border}`}})),Wx=d("div")(({theme:t})=>({width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:t.spacing(2)})),jo=d("div")(({theme:t})=>({display:"flex",flexDirection:"column",alignItems:"start",gap:t.spacing(1),flex:"1 1 auto"})),qx=d(N)(({theme:t})=>({"&&":{marginTop:t.spacing(1),color:"white"}})),Gx=d(Nx)(({theme:t})=>({flex:0,width:"auto",display:"block",[t.breakpoints.down("md")]:{display:"none"}})),zx=({...t})=>{const[s,n]=aa("enterpriseEdgeUIDismissibleAlert","open");return e.jsx(Or,{in:s==="open",children:e.jsx(Fx,{onClose:()=>n("closed"),icon:!1,...t,children:e.jsxs(Wx,{children:[e.jsxs(jo,{children:[e.jsx(T,{variant:"h3",children:"Instant flag updates worldwide"}),e.jsx(T,{variant:"body2",color:"text.secondary",children:"Enterprise Edge is a high-performance proxy between your SDKs and Unleash, giving you global reach, minimal latency, and making flag changes instantly available to your users."}),e.jsx(qx,{component:ae,to:"/admin/enterprise-edge",variant:"contained",children:"Check out Enterprise Edge"})]}),e.jsx(jo,{sx:{alignItems:"end"},children:e.jsx(Gx,{})})]})})})},ht=1505,Hx=d(f)(({theme:t})=>({display:"flex",flexDirection:"column",gap:t.spacing(2)})),Vx=d(Fe)(({theme:t})=>({position:"relative",height:t.spacing(44),padding:t.spacing(3),borderRadius:`${t.shape.borderRadiusLarge}px`,boxShadow:"none",color:"white",backgroundColor:t.palette.web.main,overflow:"hidden",[t.breakpoints.down(ht)]:{height:t.spacing(28),paddingBottom:t.spacing(6)},[t.breakpoints.down(800)]:{height:t.spacing(34)}})),Yx=d(Fe)(({theme:t})=>({minHeight:t.spacing(44),padding:t.spacing(3),borderRadius:`${t.shape.borderRadiusLarge}px`,boxShadow:"none",[t.breakpoints.up("md")]:{flexDirection:"row",flexWrap:"nowrap"}})),Jx=d(T)(({theme:t})=>({width:"100%",fontSize:t.fontSizes.largeHeader,fontWeight:"bold",marginBottom:t.spacing(1)})),Kx=d("div")(({theme:t})=>({marginBottom:t.spacing(6),[t.breakpoints.down(ht)]:{marginBottom:t.spacing()}})),fo=d(T)(({theme:t})=>({fontSize:t.fontSizes.bodySize,marginTop:t.spacing(2),marginBottom:t.spacing(2),flexDirection:"row",display:"flex",gap:t.spacing(1),justifyContent:"space-between",[t.breakpoints.down(ht)]:{maxWidth:t.spacing(65)},[t.breakpoints.down(800)]:{flexDirection:"column",justifyContent:"start"}})),yo=d("span")(({theme:t})=>({fontSize:t.fontSizes.bodySize,fontWeight:"bold"})),bo=d("span")({color:"white"}),Zx=d(T)(({theme:t})=>({fontSize:t.fontSizes.mainHeader,marginTop:t.spacing(2),marginBottom:t.spacing(4)})),Qx=d(f)(({theme:t})=>({display:"flex",flexDirection:"row",gap:t.spacing(2),justifyContent:"space-between",marginBottom:t.spacing(7)})),Nt=d(f)(({theme:t})=>({width:t.spacing(16),aspectRatio:"1 / 1",padding:t.spacing(2),alignItems:"center",borderRadius:"50%",backgroundColor:t.mode==="light"?"#F1F0FC":"#302E42"})),Ft=d(_)({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}),Wt=d(T)(({theme:t})=>({color:t.palette.primary.main,fontSize:t.fontSizes.largeHeader,fontWeight:"bold",marginTop:t.spacing(1)})),qt=d(T)(({theme:t})=>({color:t.palette.text.primary,fontSize:t.fontSizes.bodySize})),Xx=d("div")(({theme:t})=>({display:"flex",justifyContent:"flex-start",marginTop:t.spacing(3)})),em=d("div")(({theme:t})=>({position:"absolute",left:t.spacing(2.5),bottom:t.spacing(3),[t.breakpoints.down(ht)]:{position:"static",marginTop:t.spacing(2)}})),tm=d(ae)(({theme:t})=>({color:t.palette.common.white,textDecoration:"underline !important",fontSize:t.typography.body2.fontSize,display:"flex",alignItems:"center",gap:t.spacing(1)})),sm=d("div")(({theme:t})=>({display:"flex",justifyContent:"flex-end",marginTop:t.spacing(-6),marginRight:t.spacing(-10),[t.breakpoints.down(ht)]:{marginTop:t.spacing(-22),marginRight:t.spacing(-12),paddingTop:t.spacing(1)},[t.breakpoints.down(800)]:{paddingTop:0}})),nm=d("img")(({theme:t})=>({width:t.spacing(33),transform:"rotate(180deg)",clipPath:"polygon(21% 28%, 100% 28%, 21% 94%)"})),om=({plan:t,instanceId:s,version:n})=>e.jsxs(Vx,{children:[e.jsxs(Kx,{children:[e.jsx("div",{children:"Current plan"}),e.jsx(Jx,{variant:"h3",children:t})]}),e.jsxs(fo,{children:[e.jsx(yo,{children:"Instance id"}),e.jsx(bo,{children:s})]}),e.jsxs(fo,{children:[e.jsx(yo,{children:"Unleash version"}),e.jsx(bo,{children:n})]}),e.jsx(em,{children:e.jsxs(tm,{to:"https://docs.getunleash.io/availability#versioning",target:"_blank",rel:"noopener noreferrer",children:[e.jsx(_r,{sx:{color:o=>o.palette.common.white}}),"Learn about versioning"]})}),e.jsx(sm,{children:e.jsx(nm,{src:ia(Mx)})})]}),am=({users:t,featureToggles:s,projects:n,environments:o})=>{const a=we();return e.jsxs(Yx,{children:[e.jsx(Zx,{children:"Instance statistics"}),e.jsxs(Qx,{container:!0,children:[e.jsx(Nt,{item:!0,children:e.jsxs(Ft,{children:[e.jsx(Wt,{children:t}),e.jsx(qt,{children:"Users"})]})}),e.jsx(Nt,{item:!0,children:e.jsxs(Ft,{children:[e.jsx(Wt,{children:s}),e.jsx(qt,{children:"Feature flags"})]})}),e.jsx(Nt,{item:!0,children:e.jsxs(Ft,{children:[e.jsx(Wt,{children:n}),e.jsx(qt,{children:"Projects"})]})}),e.jsx(Nt,{item:!0,children:e.jsxs(Ft,{children:[e.jsx(Wt,{children:o}),e.jsx(qt,{children:"Environments"})]})})]}),e.jsx(Xx,{children:e.jsx(N,{rel:"noreferrer",endIcon:e.jsx(Za,{}),onClick:()=>{a("/admin/instance")},children:"View all instance statistics"})})]})},im=()=>{var g,p,h,x,m,j;const t=La(),s=Dt(),n=je(s.breakpoints.down(ht)),o=n?12:7,a=n?12:5,{isOss:i,isPro:r,isEnterprise:c}=W(),l=i()?"Open source":r()?"Pro":c()?"Enterprise":"Unknown";return e.jsxs(Hx,{children:[e.jsx(zx,{}),t&&!t.loading&&e.jsxs(f,{container:!0,spacing:3,children:[e.jsx(f,{item:!0,md:a,sm:12,xs:12,children:e.jsx(om,{plan:l,instanceId:((g=t.stats)==null?void 0:g.instanceId)??"unknown",version:((p=t.stats)==null?void 0:p.versionEnterprise)??"unknown"})}),e.jsx(f,{item:!0,md:o,sm:12,xs:12,children:e.jsx(am,{environments:((h=t.stats)==null?void 0:h.environments)??0,featureToggles:((x=t.stats)==null?void 0:x.featureToggles)??0,projects:((m=t.stats)==null?void 0:m.projects)??0,users:((j=t.stats)==null?void 0:j.users)??0})})]})]})},rm=u.lazy(()=>ut(()=>import("./EnterpriseEdge-Bzf3ZWSM.js"),[])),lm=()=>e.jsx(e.Fragment,{children:e.jsxs(it,{children:[e.jsx(M,{index:!0,element:e.jsx(im,{})}),e.jsx(M,{path:"users/*",element:e.jsx(hx,{})}),e.jsx(M,{path:"api",element:e.jsx(el,{})}),e.jsx(M,{path:"api/create-token",element:e.jsx(ol,{})}),e.jsx(M,{path:"service-accounts",element:e.jsx(Th,{})}),e.jsx(M,{path:"create-user",element:e.jsx(Oh,{})}),e.jsx(M,{path:"invite-link",element:e.jsx(Mh,{})}),e.jsx(M,{path:"groups/*",element:e.jsx(ku,{})}),e.jsx(M,{path:"roles/*",element:e.jsx(nh,{})}),e.jsx(M,{path:"instance",element:e.jsx(Ru,{})}),e.jsx(M,{path:"enterprise-edge",element:e.jsx(rm,{})}),e.jsx(M,{path:"network/*",element:e.jsx(hp,{})}),e.jsx(M,{path:"maintenance",element:e.jsx(sp,{})}),e.jsx(M,{path:"banners",element:e.jsx(Rx,{})}),e.jsx(M,{path:"license",element:e.jsx(Bx,{})}),e.jsx(M,{path:"cors",element:e.jsx(kd,{})}),e.jsx(M,{path:"auth/*",element:e.jsx(El,{})}),e.jsx(M,{path:"admin-invoices",element:e.jsx(bd,{})}),e.jsx(M,{path:"billing",element:e.jsx(md,{})}),e.jsx(M,{path:"instance-privacy",element:e.jsx(Hu,{})}),e.jsx(M,{path:"*",element:e.jsx(ca,{})})]})}),fm=Object.freeze(Object.defineProperty({__proto__:null,default:lm},Symbol.toStringTag,{value:"Module"}));export{fm as L,Nx as S,Ml as T,ga as a,_l as b,hm as c,xm as d,ql as e,gm as f,jm as g,ma as h,mm as p,Hl as u};