unleash-server 4.22.2 → 4.22.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 (36) hide show
  1. package/dist/lib/db/project-store.js +2 -1
  2. package/dist/lib/db/project-store.js.map +1 -1
  3. package/dist/lib/services/project-service.js +1 -1
  4. package/dist/lib/services/project-service.js.map +1 -1
  5. package/dist/lib/types/model.d.ts +1 -1
  6. package/dist/test/e2e/api/admin/project/features.e2e.test.js +6 -1
  7. package/dist/test/e2e/api/admin/project/features.e2e.test.js.map +1 -1
  8. package/dist/test/e2e/api/proxy/proxy.e2e.test.js +1 -1
  9. package/dist/test/e2e/api/proxy/proxy.e2e.test.js.map +1 -1
  10. package/dist/test/e2e/services/api-token-service.e2e.test.js +1 -0
  11. package/dist/test/e2e/services/api-token-service.e2e.test.js.map +1 -1
  12. package/dist/test/e2e/services/project-service.e2e.test.js +44 -0
  13. package/dist/test/e2e/services/project-service.e2e.test.js.map +1 -1
  14. package/dist/test/fixtures/fake-project-store.js +1 -0
  15. package/dist/test/fixtures/fake-project-store.js.map +1 -1
  16. package/frontend/build/index.html +1 -1
  17. package/frontend/build/static/{CreateProject-51932050.js → CreateProject-a2c9a780.js} +1 -1
  18. package/frontend/build/static/{Error-e6e1194a.js → Error-38b8cdc0.js} +1 -1
  19. package/frontend/build/static/{ExpandMore-d71bbced.js → ExpandMore-ee840700.js} +1 -1
  20. package/frontend/build/static/{FeatureArchiveDialog-fd71aac2.js → FeatureArchiveDialog-0d7ae6c3.js} +1 -1
  21. package/frontend/build/static/{FeatureMetricsChart-66e2ebdf.js → FeatureMetricsChart-ed667dfd.js} +1 -1
  22. package/frontend/build/static/FeatureViewLazyExport-1b33033a.js +7 -0
  23. package/frontend/build/static/{LazyAdminExport-17ef1739.js → LazyAdminExport-f1db04ed.js} +2 -2
  24. package/frontend/build/static/{LazyProjectExport-96365c31.js → LazyProjectExport-984413bf.js} +1 -1
  25. package/frontend/build/static/{NetworkOverview-02d7cec9.js → NetworkOverview-c9972cf4.js} +1 -1
  26. package/frontend/build/static/{NetworkTraffic-ea8ea762.js → NetworkTraffic-b4d65658.js} +1 -1
  27. package/frontend/build/static/{Playground-1b14c01c.js → Playground-82d86aa7.js} +1 -1
  28. package/frontend/build/static/{StrategyItemContainer-7ce39bda.js → StrategyItemContainer-72e360fd.js} +1 -1
  29. package/frontend/build/static/{chartjs-adapter-date-fns.esm-8ccfeb24.js → chartjs-adapter-date-fns.esm-00d0c032.js} +1 -1
  30. package/frontend/build/static/{index-17782336.js → index-78310b22.js} +1 -1
  31. package/frontend/build/static/{index-1d165488.js → index-99d4171f.js} +61 -61
  32. package/frontend/build/static/{index-96dcc77e.js → index-c65a88d1.js} +1 -1
  33. package/frontend/build/static/{unknownify-132fbce3.js → unknownify-9d8df72f.js} +1 -1
  34. package/frontend/build/static/{useProjectRole-f048973d.js → useProjectRole-dba93dda.js} +1 -1
  35. package/package.json +1 -1
  36. package/frontend/build/static/FeatureViewLazyExport-3403c2b4.js +0 -7
@@ -1,4 +1,4 @@
1
- import{s as f,r as p,aD as yo,cH as bo,aE as So,j as e,aF as vn,cI as Kt,cJ as Tt,cK as vo,cL as Co,cM as wo,cN as xo,c as ut,cO as Cn,cP as Oe,cQ as It,aS as oe,aR as Te,aT as Ce,bj as he,cR as wn,C as k,cS as Zt,ak as Q,al as te,f as r,F,V as ye,cT as xn,cU as $e,cV as ht,cW as ko,cX as To,ae as Ao,cY as Eo,a2 as K,H as Y,ar as ae,bL as kn,av as we,ax as Ot,cZ as Nt,a4 as V,aA as me,bo as y,bR as ie,bT as be,a5 as Ze,a6 as Ro,a7 as Po,a8 as He,ac as X,Z as Ie,c_ as We,c$ as z,A as _,a9 as M,a as j,d0 as Do,T as I,af as Gt,d1 as Tn,a1 as Io,d2 as Uo,d3 as Me,B as Ut,d4 as Bo,aO as Re,d as Z,e as je,l as Se,g as An,S as En,h as pt,i as qe,k as Rn,W as ge,c6 as Ne,m as Fe,d5 as Lo,aU as $t,d6 as jt,bw as Pn,d7 as Oo,d8 as Dn,d9 as In,da as ne,bx as Un,db as No,c8 as Xt,dc as Ft,bF as Bn,ad as Go,dd as $o,de as At,c1 as Ln,cG as jo,cE as Fo,N as ve,c5 as Ge,df as ze,R as xe,b9 as Pe,aY as De,U as Xe,Y as Qe,bS as Ve,bJ as zt,w as zo,dg as Mo,dh as Ho,bK as Wo,di as qo,dj as _o,dk as Vo,aI as mt,dl as Mt,dm as On,ah as Nn,a_ as se,bO as Gn,K as Yo,u as Ht,dn as gt,dp as Jo,L as $n,Q as Wt,aM as ke,dq as Ko,aP as et,dr as Zo,ds as jn,dt as Xo,X as Ye,P as Fn,du as Qo,bd as Et,bf as Rt,dv as ea,dw as ta,dx as na,as as qt,dy as oa,ci as zn,co as Mn,cg as de,bM as Hn,bN as J,x as aa,br as ra,bs as ia,bt as sa,bV as la,dz as ca,bH as Pt,I as da,dA as Wn,dB as ct,dC as qn,dD as ua,dE as ha,dF as dt,dG as Bt,bE as _n,dH as pa,O as ma,dI as ga,dJ as fa,dK as ya,dL as ba,dM as Sa,dN as va,dO as Ca,dP as wa,c4 as xa,aZ as ka,dQ as Vn,dR as Ta,dS as Aa,dT as Ea,dU as Ra,dV as Qt,M as Yn,be as Pa,by as Dt,dW as Da}from"./index-1d165488.js";import{u as Ia,C as Ua,A as Ba,a as La,R as Oa,S as Na,T as Ga,b as $a,c as ja,d as Fa,e as za,E as Ma,f as Ha,m as Wa,g as ft,M as qa,B as _a,h as en}from"./useProjectRole-f048973d.js";import{E as Va}from"./ExpandMore-d71bbced.js";import{a as Ya}from"./index-96dcc77e.js";import{a as Ja}from"./index-17782336.js";const Ka=["component","direction","spacing","divider","children"];function Za(t,n){const o=p.Children.toArray(t).filter(Boolean);return o.reduce((a,i,s)=>(a.push(i),s<o.length-1&&a.push(p.cloneElement(n,{key:`separator-${s}`})),a),[])}const Xa=t=>({row:"Left","row-reverse":"Right",column:"Top","column-reverse":"Bottom"})[t],Qa=({ownerState:t,theme:n})=>{let o=vn({display:"flex",flexDirection:"column"},Kt({theme:n},Tt({values:t.direction,breakpoints:n.breakpoints.values}),a=>({flexDirection:a})));if(t.spacing){const a=vo(n),i=Object.keys(n.breakpoints.values).reduce((l,c)=>((typeof t.spacing=="object"&&t.spacing[c]!=null||typeof t.direction=="object"&&t.direction[c]!=null)&&(l[c]=!0),l),{}),s=Tt({values:t.direction,base:i}),d=Tt({values:t.spacing,base:i});typeof s=="object"&&Object.keys(s).forEach((l,c,u)=>{if(!s[l]){const b=c>0?s[u[c-1]]:"column";s[l]=b}}),o=Co(o,Kt({theme:n},d,(l,c)=>({"& > :not(style) + :not(style)":{margin:0,[`margin${Xa(c?s[c]:t.direction)}`]:xo(a,l)}})))}return o=wo(n.breakpoints,o),o},er=f("div",{name:"MuiStack",slot:"Root",overridesResolver:(t,n)=>[n.root]})(Qa),tr=p.forwardRef(function(n,o){const a=yo({props:n,name:"MuiStack"}),i=bo(a),{component:s="div",direction:d="column",spacing:h=0,divider:l,children:c}=i,u=So(i,Ka);return e(er,vn({as:s,ownerState:{direction:d,spacing:h},ref:o},u,{children:l?Za(c,l):c}))}),nr=tr,or=ut(e("path",{d:"M11.8 10.9c-2.27-.59-3-1.2-3-2.15 0-1.09 1.01-1.85 2.7-1.85 1.42 0 2.13.54 2.39 1.4.12.4.45.7.87.7h.3c.66 0 1.13-.65.9-1.27-.42-1.18-1.4-2.16-2.96-2.54V4.5c0-.83-.67-1.5-1.5-1.5S10 3.67 10 4.5v.66c-1.94.42-3.5 1.68-3.5 3.61 0 2.31 1.91 3.46 4.7 4.13 2.5.6 3 1.48 3 2.41 0 .69-.49 1.79-2.7 1.79-1.65 0-2.5-.59-2.83-1.43-.15-.39-.49-.67-.9-.67h-.28c-.67 0-1.14.68-.89 1.3.57 1.39 1.9 2.21 3.4 2.53v.67c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5v-.65c1.95-.37 3.5-1.5 3.5-3.55 0-2.84-2.43-3.81-4.7-4.4z"}),"AttachMoneyRounded"),ar=ut(e("path",{d:"M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5s-3 1.34-3 3 1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V18c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-1.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05.02.01.03.03.04.04 1.14.83 1.93 1.94 1.93 3.41V18c0 .35-.07.69-.18 1H22c.55 0 1-.45 1-1v-1.5c0-2.33-4.67-3.5-7-3.5z"}),"GroupRounded"),rr=ut(e("path",{d:"M11.99 2c-5.52 0-10 4.48-10 10s4.48 10 10 10 10-4.48 10-10-4.48-10-10-10zm3.61 6.34c1.07 0 1.93.86 1.93 1.93 0 1.07-.86 1.93-1.93 1.93-1.07 0-1.93-.86-1.93-1.93-.01-1.07.86-1.93 1.93-1.93zm-6-1.58c1.3 0 2.36 1.06 2.36 2.36 0 1.3-1.06 2.36-2.36 2.36s-2.36-1.06-2.36-2.36c0-1.31 1.05-2.36 2.36-2.36zm0 9.13v3.75c-2.4-.75-4.3-2.6-5.14-4.96 1.05-1.12 3.67-1.69 5.14-1.69.53 0 1.2.08 1.9.22-1.64.87-1.9 2.02-1.9 2.68zM11.99 20c-.27 0-.53-.01-.79-.04v-4.07c0-1.42 2.94-2.13 4.4-2.13 1.07 0 2.92.39 3.84 1.15-1.17 2.97-4.06 5.09-7.45 5.09z"}),"SupervisedUserCircle"),ir=ut(e("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");function st(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?st=function(o){return typeof o}:st=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},st(t)}function lt(t,n){if(Cn(2,arguments),!n||st(n)!=="object")return new Date(NaN);var o=n.years?Oe(n.years):0,a=n.months?Oe(n.months):0,i=n.weeks?Oe(n.weeks):0,s=n.days?Oe(n.days):0,d=n.hours?Oe(n.hours):0,h=n.minutes?Oe(n.minutes):0,l=n.seconds?Oe(n.seconds):0,c=It(t),u=a||o?Ja(c,a+o*12):c,m=s||i?Ya(u,s+i*7):u,b=h+d*60,v=l+b*60,g=v*1e3,C=new Date(m.getTime()+g);return C}function tn(t,n){Cn(2,arguments);var o=It(t),a=It(n);return o.getTime()>a.getTime()}const Jn=(t={})=>{const n=oe("api/admin/api-tokens"),{data:o,error:a,mutate:i}=Te(n,sr,t),s=p.useMemo(()=>o??[],[o]),d=p.useCallback(()=>{i().catch(console.warn)},[i]);return{tokens:s,error:a,loading:!a&&!o,refetch:d}},sr=async t=>(await(await fetch(t).then(Ce("Api tokens"))).json()).tokens,lr=()=>{const{hasAccess:t}=p.useContext(he),{tokens:n,loading:o,refetch:a}=Jn(),{deleteToken:i}=wn(),{getTableProps:s,getTableBodyProps:d,headerGroups:h,rows:l,prepareRow:c,state:{globalFilter:u},setGlobalFilter:m,setHiddenColumns:b,columns:v}=Ia(n,g=>r(ht,{children:[e(La,{token:g.row.original,permission:Zt}),e(Oa,{token:g.row.original,permission:ko,onRemove:async()=>{await i(g.row.original.secret),a()}})]}));return e(k,{condition:t(Zt),show:()=>e(Q,{header:e(te,{title:`API access (${l.length})`,actions:r(F,{children:[e(ye,{initialValue:u,onChange:m}),e(te.Divider,{}),e(Ua,{permission:xn,path:"/admin/api/create-token"})]})}),children:e(Ba,{loading:o,headerGroups:h,setHiddenColumns:b,prepareRow:c,getTableBodyProps:d,getTableProps:s,rows:l,columns:v,globalFilter:u})}),elseShow:()=>e($e,{})})},cr=({type:t,projects:n,setProjects:o,errors:a,clearErrors:i})=>{const s=To("projectId"),{projects:d}=Ao(),h=d.map(l=>({value:l.id,label:l.name}));return s?null:r(F,{children:[e(Na,{children:"Which project do you want to give access to?"}),e(Eo,{disabled:t===Ga.ADMIN,options:h,defaultValue:n,onChange:o,error:a==null?void 0:a.projects,onFocus:()=>i("projects")})]})},nn="Create API token",dr=({modal:t=!1})=>{const{setToastApiError:n}=K(),{uiConfig:o}=Y(),a=ae(),[i,s]=p.useState(!1),[d,h]=p.useState(""),{getApiTokenPayload:l,username:c,type:u,projects:m,environment:b,setUsername:v,setTokenType:g,setProjects:C,setEnvironment:w,isValid:S,errors:x,clearErrors:P}=$a(),{createToken:L,loading:T}=wn(),{refetch:R}=Jn();kn(nn);const U="api/admin/api-tokens";return r(we,{loading:T,title:nn,modal:t,description:"Unleash SDKs use API tokens to authenticate to the Unleash API. Client SDKs need a token with 'client privileges', which allows them to fetch feature toggle configurations and post usage metrics.",documentationLink:"https://docs.getunleash.io/reference/api-tokens-and-client-keys",documentationLinkLabel:"API tokens documentation",formatApiCode:()=>`curl --location --request POST '${o.unleashUrl}/${U}' \\
1
+ import{s as f,r as p,aD as yo,cH as bo,aE as So,j as e,aF as vn,cI as Kt,cJ as Tt,cK as vo,cL as Co,cM as wo,cN as xo,c as ut,cO as Cn,cP as Oe,cQ as It,aS as oe,aR as Te,aT as Ce,bj as he,cR as wn,C as k,cS as Zt,ak as Q,al as te,f as r,F,V as ye,cT as xn,cU as $e,cV as ht,cW as ko,cX as To,ae as Ao,cY as Eo,a2 as K,H as Y,ar as ae,bL as kn,av as we,ax as Ot,cZ as Nt,a4 as V,aA as me,bo as y,bR as ie,bT as be,a5 as Ze,a6 as Ro,a7 as Po,a8 as He,ac as X,Z as Ie,c_ as We,c$ as z,A as _,a9 as M,a as j,d0 as Do,T as I,af as Gt,d1 as Tn,a1 as Io,d2 as Uo,d3 as Me,B as Ut,d4 as Bo,aO as Re,d as Z,e as je,l as Se,g as An,S as En,h as pt,i as qe,k as Rn,W as ge,c6 as Ne,m as Fe,d5 as Lo,aU as $t,d6 as jt,bw as Pn,d7 as Oo,d8 as Dn,d9 as In,da as ne,bx as Un,db as No,c8 as Xt,dc as Ft,bF as Bn,ad as Go,dd as $o,de as At,c1 as Ln,cG as jo,cE as Fo,N as ve,c5 as Ge,df as ze,R as xe,b9 as Pe,aY as De,U as Xe,Y as Qe,bS as Ve,bJ as zt,w as zo,dg as Mo,dh as Ho,bK as Wo,di as qo,dj as _o,dk as Vo,aI as mt,dl as Mt,dm as On,ah as Nn,a_ as se,bO as Gn,K as Yo,u as Ht,dn as gt,dp as Jo,L as $n,Q as Wt,aM as ke,dq as Ko,aP as et,dr as Zo,ds as jn,dt as Xo,X as Ye,P as Fn,du as Qo,bd as Et,bf as Rt,dv as ea,dw as ta,dx as na,as as qt,dy as oa,ci as zn,co as Mn,cg as de,bM as Hn,bN as J,x as aa,br as ra,bs as ia,bt as sa,bV as la,dz as ca,bH as Pt,I as da,dA as Wn,dB as ct,dC as qn,dD as ua,dE as ha,dF as dt,dG as Bt,bE as _n,dH as pa,O as ma,dI as ga,dJ as fa,dK as ya,dL as ba,dM as Sa,dN as va,dO as Ca,dP as wa,c4 as xa,aZ as ka,dQ as Vn,dR as Ta,dS as Aa,dT as Ea,dU as Ra,dV as Qt,M as Yn,be as Pa,by as Dt,dW as Da}from"./index-99d4171f.js";import{u as Ia,C as Ua,A as Ba,a as La,R as Oa,S as Na,T as Ga,b as $a,c as ja,d as Fa,e as za,E as Ma,f as Ha,m as Wa,g as ft,M as qa,B as _a,h as en}from"./useProjectRole-dba93dda.js";import{E as Va}from"./ExpandMore-ee840700.js";import{a as Ya}from"./index-c65a88d1.js";import{a as Ja}from"./index-78310b22.js";const Ka=["component","direction","spacing","divider","children"];function Za(t,n){const o=p.Children.toArray(t).filter(Boolean);return o.reduce((a,i,s)=>(a.push(i),s<o.length-1&&a.push(p.cloneElement(n,{key:`separator-${s}`})),a),[])}const Xa=t=>({row:"Left","row-reverse":"Right",column:"Top","column-reverse":"Bottom"})[t],Qa=({ownerState:t,theme:n})=>{let o=vn({display:"flex",flexDirection:"column"},Kt({theme:n},Tt({values:t.direction,breakpoints:n.breakpoints.values}),a=>({flexDirection:a})));if(t.spacing){const a=vo(n),i=Object.keys(n.breakpoints.values).reduce((l,c)=>((typeof t.spacing=="object"&&t.spacing[c]!=null||typeof t.direction=="object"&&t.direction[c]!=null)&&(l[c]=!0),l),{}),s=Tt({values:t.direction,base:i}),d=Tt({values:t.spacing,base:i});typeof s=="object"&&Object.keys(s).forEach((l,c,u)=>{if(!s[l]){const b=c>0?s[u[c-1]]:"column";s[l]=b}}),o=Co(o,Kt({theme:n},d,(l,c)=>({"& > :not(style) + :not(style)":{margin:0,[`margin${Xa(c?s[c]:t.direction)}`]:xo(a,l)}})))}return o=wo(n.breakpoints,o),o},er=f("div",{name:"MuiStack",slot:"Root",overridesResolver:(t,n)=>[n.root]})(Qa),tr=p.forwardRef(function(n,o){const a=yo({props:n,name:"MuiStack"}),i=bo(a),{component:s="div",direction:d="column",spacing:h=0,divider:l,children:c}=i,u=So(i,Ka);return e(er,vn({as:s,ownerState:{direction:d,spacing:h},ref:o},u,{children:l?Za(c,l):c}))}),nr=tr,or=ut(e("path",{d:"M11.8 10.9c-2.27-.59-3-1.2-3-2.15 0-1.09 1.01-1.85 2.7-1.85 1.42 0 2.13.54 2.39 1.4.12.4.45.7.87.7h.3c.66 0 1.13-.65.9-1.27-.42-1.18-1.4-2.16-2.96-2.54V4.5c0-.83-.67-1.5-1.5-1.5S10 3.67 10 4.5v.66c-1.94.42-3.5 1.68-3.5 3.61 0 2.31 1.91 3.46 4.7 4.13 2.5.6 3 1.48 3 2.41 0 .69-.49 1.79-2.7 1.79-1.65 0-2.5-.59-2.83-1.43-.15-.39-.49-.67-.9-.67h-.28c-.67 0-1.14.68-.89 1.3.57 1.39 1.9 2.21 3.4 2.53v.67c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5v-.65c1.95-.37 3.5-1.5 3.5-3.55 0-2.84-2.43-3.81-4.7-4.4z"}),"AttachMoneyRounded"),ar=ut(e("path",{d:"M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5s-3 1.34-3 3 1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V18c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-1.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05.02.01.03.03.04.04 1.14.83 1.93 1.94 1.93 3.41V18c0 .35-.07.69-.18 1H22c.55 0 1-.45 1-1v-1.5c0-2.33-4.67-3.5-7-3.5z"}),"GroupRounded"),rr=ut(e("path",{d:"M11.99 2c-5.52 0-10 4.48-10 10s4.48 10 10 10 10-4.48 10-10-4.48-10-10-10zm3.61 6.34c1.07 0 1.93.86 1.93 1.93 0 1.07-.86 1.93-1.93 1.93-1.07 0-1.93-.86-1.93-1.93-.01-1.07.86-1.93 1.93-1.93zm-6-1.58c1.3 0 2.36 1.06 2.36 2.36 0 1.3-1.06 2.36-2.36 2.36s-2.36-1.06-2.36-2.36c0-1.31 1.05-2.36 2.36-2.36zm0 9.13v3.75c-2.4-.75-4.3-2.6-5.14-4.96 1.05-1.12 3.67-1.69 5.14-1.69.53 0 1.2.08 1.9.22-1.64.87-1.9 2.02-1.9 2.68zM11.99 20c-.27 0-.53-.01-.79-.04v-4.07c0-1.42 2.94-2.13 4.4-2.13 1.07 0 2.92.39 3.84 1.15-1.17 2.97-4.06 5.09-7.45 5.09z"}),"SupervisedUserCircle"),ir=ut(e("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");function st(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?st=function(o){return typeof o}:st=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},st(t)}function lt(t,n){if(Cn(2,arguments),!n||st(n)!=="object")return new Date(NaN);var o=n.years?Oe(n.years):0,a=n.months?Oe(n.months):0,i=n.weeks?Oe(n.weeks):0,s=n.days?Oe(n.days):0,d=n.hours?Oe(n.hours):0,h=n.minutes?Oe(n.minutes):0,l=n.seconds?Oe(n.seconds):0,c=It(t),u=a||o?Ja(c,a+o*12):c,m=s||i?Ya(u,s+i*7):u,b=h+d*60,v=l+b*60,g=v*1e3,C=new Date(m.getTime()+g);return C}function tn(t,n){Cn(2,arguments);var o=It(t),a=It(n);return o.getTime()>a.getTime()}const Jn=(t={})=>{const n=oe("api/admin/api-tokens"),{data:o,error:a,mutate:i}=Te(n,sr,t),s=p.useMemo(()=>o??[],[o]),d=p.useCallback(()=>{i().catch(console.warn)},[i]);return{tokens:s,error:a,loading:!a&&!o,refetch:d}},sr=async t=>(await(await fetch(t).then(Ce("Api tokens"))).json()).tokens,lr=()=>{const{hasAccess:t}=p.useContext(he),{tokens:n,loading:o,refetch:a}=Jn(),{deleteToken:i}=wn(),{getTableProps:s,getTableBodyProps:d,headerGroups:h,rows:l,prepareRow:c,state:{globalFilter:u},setGlobalFilter:m,setHiddenColumns:b,columns:v}=Ia(n,g=>r(ht,{children:[e(La,{token:g.row.original,permission:Zt}),e(Oa,{token:g.row.original,permission:ko,onRemove:async()=>{await i(g.row.original.secret),a()}})]}));return e(k,{condition:t(Zt),show:()=>e(Q,{header:e(te,{title:`API access (${l.length})`,actions:r(F,{children:[e(ye,{initialValue:u,onChange:m}),e(te.Divider,{}),e(Ua,{permission:xn,path:"/admin/api/create-token"})]})}),children:e(Ba,{loading:o,headerGroups:h,setHiddenColumns:b,prepareRow:c,getTableBodyProps:d,getTableProps:s,rows:l,columns:v,globalFilter:u})}),elseShow:()=>e($e,{})})},cr=({type:t,projects:n,setProjects:o,errors:a,clearErrors:i})=>{const s=To("projectId"),{projects:d}=Ao(),h=d.map(l=>({value:l.id,label:l.name}));return s?null:r(F,{children:[e(Na,{children:"Which project do you want to give access to?"}),e(Eo,{disabled:t===Ga.ADMIN,options:h,defaultValue:n,onChange:o,error:a==null?void 0:a.projects,onFocus:()=>i("projects")})]})},nn="Create API token",dr=({modal:t=!1})=>{const{setToastApiError:n}=K(),{uiConfig:o}=Y(),a=ae(),[i,s]=p.useState(!1),[d,h]=p.useState(""),{getApiTokenPayload:l,username:c,type:u,projects:m,environment:b,setUsername:v,setTokenType:g,setProjects:C,setEnvironment:w,isValid:S,errors:x,clearErrors:P}=$a(),{createToken:L,loading:T}=wn(),{refetch:R}=Jn();kn(nn);const U="api/admin/api-tokens";return r(we,{loading:T,title:nn,modal:t,description:"Unleash SDKs use API tokens to authenticate to the Unleash API. Client SDKs need a token with 'client privileges', which allows them to fetch feature toggle configurations and post usage metrics.",documentationLink:"https://docs.getunleash.io/reference/api-tokens-and-client-keys",documentationLinkLabel:"API tokens documentation",formatApiCode:()=>`curl --location --request POST '${o.unleashUrl}/${U}' \\
2
2
  --header 'Authorization: INSERT_API_KEY' \\
3
3
  --header 'Content-Type: application/json' \\
4
4
  --data-raw '${JSON.stringify(l(),void 0,2)}'`,children:[r(ja,{handleSubmit:async q=>{if(q.preventDefault(),!!S())try{const E=l();await L(E).then(N=>N.json()).then(N=>{Nt(),h(N.secret),s(!0),R()})}catch(E){n(V(E))}},handleCancel:()=>{a(me)},mode:"Create",actions:e(Ot,{name:"token",permission:xn}),children:[e(Fa,{username:c,setUsername:v,errors:x,clearErrors:P}),e(za,{type:u,setType:g}),e(cr,{type:u,projects:m,setProjects:C,errors:x,clearErrors:P}),e(Ma,{type:u,environment:b,setEnvironment:w})]}),e(Ha,{open:i,closeConfirm:()=>{s(!1),a(me)},token:d,type:u})]})},Kn=({data:t={enabled:!1,autoCreate:!1},setValue:n})=>{const o=()=>{n("autoCreate",!t.autoCreate)},a=s=>{n("defaultRootRole",s.target.value)},i=s=>{n(s.target.name,s.target.value)};return r(p.Fragment,{children:[r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Auto-create users"}),e("p",{children:"Enable automatic creation of new users when signing in."})]}),e(y,{item:!0,md:6,style:{padding:"20px"},children:e(ie,{control:e(be,{onChange:o,name:"enabled",checked:t.autoCreate,disabled:!t.enabled}),label:"Auto-create users"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Default Root Role"}),e("p",{children:"Choose which root role the user should get when no explicit role mapping exists."})]}),e(y,{item:!0,md:6,children:r(Ze,{style:{minWidth:"200px"},children:[e(Ro,{id:"defaultRootRole-label",children:"Default Role"}),r(Po,{label:"Default Role",labelId:"defaultRootRole-label",id:"defaultRootRole",name:"defaultRootRole",disabled:!t.autoCreate||!t.enabled,value:t.defaultRootRole||"Editor",onChange:a,children:[e(He,{value:"Viewer",children:"Viewer"}),e(He,{value:"Editor",children:"Editor"}),e(He,{value:"Admin",children:"Admin"})]})]})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Email domains"}),e("p",{children:"Comma separated list of email domains that should be allowed to sign in."})]}),e(y,{item:!0,md:6,children:e(X,{onChange:i,label:"Email domains",name:"emailDomains",disabled:!t.autoCreate||!t.enabled,required:Boolean(t.autoCreate),value:t.emailDomains||"",placeholder:"@company.com, @anotherCompany.com",style:{width:"400px"},rows:2,variant:"outlined",size:"small"})})]})]})},ur=async(t,n)=>{if(t){if(n){const o=await n.json();throw t({message:o.message}),new Error(o.message)}throw new Error}},yt=t=>{const{makeRequest:n,createRequest:o,errors:a,loading:i}=Ie({propagateErrors:!0,handleBadRequest:ur});return{updateSettings:async d=>{const h=`api/admin/auth/${t}/settings`,l=o(h,{method:"POST",body:JSON.stringify(d)});try{await n(l.caller,l.id)}catch(c){throw c}},errors:a,loading:i}},_t=t=>{const o=Object.entries(t).filter(([,a])=>a!=="");return Object.fromEntries(o)},Zn=({ssoType:t,data:n={enabled:!1,enableGroupSyncing:!1,groupJsonPath:""},setValue:o})=>{const a=()=>{o("enableGroupSyncing",!n.enableGroupSyncing)},i=s=>{o(s.target.name,s.target.value)};return r(F,{children:[r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Enable Group Syncing"}),r("p",{children:["Enables automatically syncing of users from the"," ",t,"provider when a user logs in."]})]}),e(y,{item:!0,md:6,style:{padding:"20px"},children:e(ie,{control:e(be,{onChange:a,value:n.enableGroupSyncing,name:"enableGroupSyncing",checked:n.enableGroupSyncing,disabled:!n.enabled}),label:n.enableGroupSyncing?"Enabled":"Disabled"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Group Field JSON Path"}),r("p",{children:["Specifies the path in the ",t," token response from which to read the groups the user belongs to."]})]}),e(y,{item:!0,md:6,children:e(X,{onChange:i,label:"Group JSON Path",name:"groupJsonPath",value:n.groupJsonPath,disabled:!n.enableGroupSyncing,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]})]})},hr={enabled:!1,enableSingleSignOut:!1,enableGroupSyncing:!1,autoCreate:!1,unleashHostname:location.hostname,groupJsonPath:"",clientId:"",discoverUrl:"",secret:"",acrValues:""},pr=()=>{const{setToastData:t,setToastApiError:n}=K(),{uiConfig:o}=Y(),[a,i]=p.useState(hr),{hasAccess:s}=p.useContext(he),{config:d}=We("oidc"),{updateSettings:h,errors:l,loading:c}=yt("oidc");if(p.useEffect(()=>{d.discoverUrl&&i(d)},[d]),!s(z))return e(_,{severity:"error",children:"You need to be a root admin to access this section."});const u=C=>{v(C.target.name,C.target.value)},m=()=>{i({...a,enabled:!a.enabled})},b=()=>{i({...a,enableSingleSignOut:!a.enableSingleSignOut})},v=(C,w)=>{i({...a,[C]:w})},g=async C=>{C.preventDefault();try{await h(_t(a)),t({title:"Settings stored",type:"success"})}catch(w){n(V(w))}};return r(Q,{children:[e(y,{container:!0,style:{marginBottom:"1rem"},children:e(y,{item:!0,md:12,children:r(_,{severity:"info",children:["Please read the"," ",e("a",{href:"https://www.unleash-hosted.com/docs/enterprise-authentication",target:"_blank",rel:"noreferrer",children:"documentation"})," ","to learn how to integrate with specific Open Id Connect providers (Okta, Keycloak, Google, etc). ",e("br",{}),"Callback URL:"," ",r("code",{children:[o.unleashUrl,"/auth/oidc/callback"]})]})})}),r("form",{onSubmit:g,children:[r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Enable"}),e("p",{children:"Enable Open Id Connect Authentication."})]}),e(y,{item:!0,md:6,style:{padding:"20px"},children:e(ie,{control:e(be,{onChange:m,value:a.enabled,name:"enabled",checked:a.enabled}),label:a.enabled?"Enabled":"Disabled"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Discover URL"}),e("p",{children:"(Required) Issuer discover metadata URL"})]}),e(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Discover URL",name:"discoverUrl",value:a.discoverUrl,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Client ID"}),e("p",{children:"(Required) Client ID of your OpenID application"})]}),e(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Client ID",name:"clientId",value:a.clientId,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(y,{container:!0,spacing:3,mb:4,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Client secret"}),r("p",{children:["(Required) Client secret of your OpenID application."," "]})]}),e(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Client Secret",name:"secret",value:a.secret,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),e("h3",{children:"Optional Configuration"}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Enable Single Sign-Out"}),e("p",{children:"If you enable Single Sign-Out Unleash will redirect the user to the IDP as part of the Sign-out process."})]}),e(y,{item:!0,md:6,style:{padding:"20px"},children:e(ie,{control:e(be,{onChange:b,value:a.enableSingleSignOut,disabled:!a.enabled,name:"enableSingleSignOut",checked:a.enableSingleSignOut}),label:a.enableSingleSignOut?"Enabled":"Disabled"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"ACR Values"}),e("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(y,{item:!0,md:6,children:e(X,{onChange:u,label:"ACR Values",name:"acrValues",value:a.acrValues,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small"})})]}),e(Zn,{ssoType:"OIDC",data:a,setValue:v}),e(Kn,{data:a,setValue:v}),e(y,{container:!0,spacing:3,children:r(y,{item:!0,md:12,children:[e(M,{variant:"contained",color:"primary",type:"submit",disabled:c,children:"Save"})," ",e("p",{children:e("small",{style:{color:"red"},children:l==null?void 0:l.message})})]})})]})]})},mr={enabled:!1,autoCreate:!1,enableGroupSyncing:!1,unleashHostname:location.hostname,entityId:"",signOnUrl:"",certificate:"",signOutUrl:"",spCertificate:"",groupJsonPath:""},gr=()=>{const{setToastData:t,setToastApiError:n}=K(),{uiConfig:o}=Y(),[a,i]=p.useState(mr),{hasAccess:s}=p.useContext(he),{config:d}=We("saml"),{updateSettings:h,errors:l,loading:c}=yt("saml");if(p.useEffect(()=>{d.entityId&&i(d)},[d]),!s(z))return e(_,{severity:"error",children:"You need to be a root admin to access this section."});const u=g=>{b(g.target.name,g.target.value)},m=()=>{i({...a,enabled:!a.enabled})},b=(g,C)=>{i({...a,[g]:C})},v=async g=>{g.preventDefault();try{await h(_t(a)),t({title:"Settings stored",type:"success"})}catch(C){n(V(C))}};return r(Q,{children:[e(y,{container:!0,style:{marginBottom:"1rem"},children:e(y,{item:!0,md:12,children:r(_,{severity:"info",children:["Please read the"," ",e("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 (Okta, Keycloak, etc). ",e("br",{}),"Callback URL:"," ",r("code",{children:[o.unleashUrl,"/auth/saml/callback"]})]})})}),r("form",{onSubmit:v,children:[r(y,{container:!0,spacing:3,children:[r(y,{item:!0,md:5,mb:2,children:[e("strong",{children:"Enable"}),e("p",{children:"Enable SAML 2.0 Authentication."})]}),e(y,{item:!0,md:6,children:e(ie,{control:e(be,{onChange:m,value:a.enabled,name:"enabled",checked:a.enabled}),label:a.enabled?"Enabled":"Disabled"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Entity ID"}),e("p",{children:"(Required) The Entity Identity provider issuer."})]}),e(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Entity ID",name:"entityId",value:a.entityId,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Single Sign-On URL"}),e("p",{children:"(Required) The url to redirect the user to for signing in."})]}),e(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Single Sign-On URL",name:"signOnUrl",value:a.signOnUrl,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(y,{container:!0,spacing:3,mb:4,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"X.509 Certificate"}),e("p",{children:"(Required) The certificate used to sign the SAML 2.0 request."})]}),e(y,{item:!0,md:7,children:e(X,{onChange:u,label:"X.509 Certificate",name:"certificate",value:a.certificate,disabled:!a.enabled,style:{width:"100%"},InputProps:{style:{fontSize:"0.6em",fontFamily:"monospace"}},multiline:!0,rows:14,maxRows:14,variant:"outlined",size:"small",required:!0})})]}),e("h3",{children:"Optional Configuration"}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Single Sign-out URL"}),e("p",{children:"(Optional) The url to redirect the user to for signing out of the IDP."})]}),e(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Single Sign-out URL",name:"signOutUrl",value:a.signOutUrl,disabled:!a.enabled,style:{width:"400px"},variant:"outlined",size:"small"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Service Provider X.509 Certificate"}),e("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(y,{item:!0,md:7,children:e(X,{onChange:u,label:"X.509 Certificate",name:"spCertificate",value:a.spCertificate,disabled:!a.enabled,style:{width:"100%"},InputProps:{style:{fontSize:"0.6em",fontFamily:"monospace"}},multiline:!0,rows:14,maxRows:14,variant:"outlined",size:"small"})})]}),e(Zn,{ssoType:"SAML",data:a,setValue:b}),e(Kn,{data:a,setValue:b}),e(y,{container:!0,spacing:3,children:r(y,{item:!0,md:5,children:[e(M,{variant:"contained",color:"primary",type:"submit",disabled:c,children:"Save"})," ",e("p",{children:e("small",{style:{color:"red"},children:l==null?void 0:l.message})})]})})]})]})},fr=()=>{const{setToastData:t,setToastApiError:n}=K(),{config:o}=We("simple"),[a,i]=p.useState(!1),{updateSettings:s,errors:d,loading:h}=yt("simple"),{hasAccess:l}=p.useContext(he);return p.useEffect(()=>{i(!!o.disabled)},[o.disabled]),l(z)?e(Q,{children:r("form",{onSubmit:async m=>{m.preventDefault();try{await s({disabled:a}),t({title:"Successfully saved",text:"Password authentication settings stored.",autoHideDuration:4e3,type:"success",show:!0})}catch(b){n(V(b)),i(o.disabled)}},children:[r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Password based login"}),e("p",{children:"Allow users to login with username & password"})]}),e(y,{item:!0,md:6,style:{padding:"20px"},children:e(ie,{control:e(be,{onChange:()=>{i(!a)},value:!a,name:"disabled",checked:!a}),label:a?"Disabled":"Enabled"})})]}),e(y,{container:!0,spacing:3,children:r(y,{item:!0,md:12,children:[e(M,{variant:"contained",color:"primary",type:"submit",disabled:h,children:"Save"})," ",e("p",{children:e("small",{style:{color:"red"},children:d==null?void 0:d.message})})]})})]})}):e(_,{severity:"error",children:"You need to be a root admin to access this section."})},yr={enabled:!1,autoCreate:!1,unleashHostname:location.hostname,clientId:"",clientSecret:"",emailDomains:""},br=()=>{const{setToastData:t,setToastApiError:n}=K(),{uiConfig:o}=Y(),[a,i]=p.useState(yr),{hasAccess:s}=p.useContext(he),{config:d}=We("google"),{updateSettings:h,errors:l,loading:c}=yt("google");if(p.useEffect(()=>{d.clientId&&i(d)},[d]),!s(z))return e("span",{children:"You need admin privileges to access this section."});const u=g=>{i({...a,[g.target.name]:g.target.value})},m=()=>{i({...a,enabled:!a.enabled})},b=()=>{i({...a,autoCreate:!a.autoCreate})},v=async g=>{g.preventDefault();try{await h(_t(a)),t({title:"Settings stored",type:"success"})}catch(C){n(V(C))}};return r(Q,{children:[r(j,{children:[r(_,{severity:"error",sx:{mb:2},children:["This integration is deprecated and will be removed in next major version. Please use ",e("strong",{children:"OpenID Connect"})," to enable Google SSO."]}),r(_,{severity:"info",sx:{mb:3},children:["Read the"," ",e("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("br",{}),"Callback URL:"," ",r("code",{children:[o.unleashUrl,"/auth/google/callback"]})]})]}),r("form",{onSubmit:v,children:[r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,xs:5,children:[e("strong",{children:"Enable"}),e("p",{children:"Enable Google users to login. Value is ignored if Client ID and Client Secret are not defined."})]}),e(y,{item:!0,xs:6,style:{padding:"20px"},children:e(ie,{control:e(be,{onChange:m,value:a.enabled,name:"enabled",checked:a.enabled}),label:a.enabled?"Enabled":"Disabled"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,xs:5,children:[e("strong",{children:"Client ID"}),e("p",{children:"(Required) The Client ID provided by Google when registering the application."})]}),e(y,{item:!0,xs:6,children:e(X,{onChange:u,label:"Client ID",name:"clientId",placeholder:"",value:a.clientId,style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Client Secret"}),e("p",{children:"(Required) Client Secret provided by Google when registering the application."})]}),e(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Client Secret",name:"clientSecret",value:a.clientSecret,placeholder:"",style:{width:"400px"},variant:"outlined",size:"small",required:!0})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Unleash hostname"}),r("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("small",{children:e("code",{children:"https://[unleash.hostname.com]/auth/google/callback"})})]})]}),e(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Unleash Hostname",name:"unleashHostname",placeholder:"",value:a.unleashHostname||"",style:{width:"400px"},variant:"outlined",size:"small"})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Auto-create users"}),e("p",{children:"Enable automatic creation of new users when signing in with Google."})]}),e(y,{item:!0,md:6,style:{padding:"20px"},children:e(be,{onChange:b,name:"enabled",checked:a.autoCreate})})]}),r(y,{container:!0,spacing:3,mb:2,children:[r(y,{item:!0,md:5,children:[e("strong",{children:"Email domains"}),e("p",{children:"(Optional) Comma separated list of email domains that should be allowed to sign in."})]}),e(y,{item:!0,md:6,children:e(X,{onChange:u,label:"Email domains",name:"emailDomains",value:a.emailDomains,placeholder:"@company.com, @anotherCompany.com",style:{width:"400px"},rows:2,multiline:!0,variant:"outlined",size:"small"})})]}),e(y,{container:!0,spacing:3,children:r(y,{item:!0,md:5,children:[e(M,{variant:"contained",color:"primary",type:"submit",disabled:c,children:"Save"})," ",e("p",{children:e("small",{style:{color:"error.dark"},children:l==null?void 0:l.message})})]})})]})]})},Sr=()=>{const{authenticationType:t}=Y().uiConfig;return e("div",{children:r(Q,{header:"Single Sign-On",children:[e(k,{condition:t==="enterprise",show:e(Do,{tabData:[{label:"OpenID Connect",component:e(pr,{})},{label:"SAML 2.0",component:e(gr,{})},{label:"Password",component:e(fr,{})},{label:"Google",component:e(br,{})}]})}),e(k,{condition:t==="open-source",show:e(_,{severity:"warning",children:"You are running the open-source version of Unleash. You have to use the Enterprise edition in order configure Single Sign-on."})}),e(k,{condition:t==="demo",show:e(_,{severity:"warning",children:"You are running Unleash in demo mode. You have to use the Enterprise edition in order configure Single Sign-on."})}),e(k,{condition:t==="custom",show:e(_,{severity:"warning",children:"You have decided to use custom authentication type. You have to use the Enterprise edition in order configure Single Sign-on from the user interface."})}),e(k,{condition:t==="hosted",show:e(_,{severity:"info",children:"Your Unleash instance is managed by the Unleash team."})})]})})},vr=oe("api/admin/invoices"),Cr=f(M)(({theme:t})=>({width:"100%",marginBottom:t.spacing(1.5)})),wr=({update:t})=>e(Cr,{href:`${vr}/${t?"portal":"checkout"}`,variant:t?"outlined":"contained",children:t?"Update billing information":"Add billing information"}),xr=f("aside")(({theme:t})=>({padding:t.spacing(4),height:"100%",borderRadius:t.shape.borderRadiusLarge,backgroundColor:t.palette.background.elevation2})),kr=f(I)(({theme:t})=>({marginBottom:t.spacing(4)})),Tr=f(_)(({theme:t})=>({marginBottom:t.spacing(4)})),on=f(I)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),Ar=f(Gt)(({theme:t})=>({margin:`${t.spacing(2.5)} 0`,borderColor:t.palette.divider})),Er=({instanceStatus:t})=>{const n=t.state!==Tn.ACTIVE;return e(y,{item:!0,xs:12,md:5,children:r(xr,{children:[e(kr,{variant:"body1",children:"Billing information"}),e(k,{condition:n,show:r(Tr,{severity:"warning",children:["In order to ",e("strong",{children:"Upgrade trial"})," you need to provide us your billing information."]})}),e(wr,{update:!n}),e(on,{children:n?"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(Ar,{}),r(on,{children:[e("a",{href:"mailto:elise@getunleash.ai?subject=PRO plan clarifications",children:"Get in touch with us"})," ","for any clarification"]})]})})},Ue=()=>{const{data:t,error:n,mutate:o}=Te(oe("api/admin/user-admin"),Rr);return p.useMemo(()=>({users:(t==null?void 0:t.users)??[],roles:(t==null?void 0:t.rootRoles)??[],loading:!n&&!t,refetch:()=>o(),error:n}),[t,n,o])},Rr=t=>fetch(t).then(Ce("Users")).then(n=>n.json()),Pr=f(y)(({theme:t})=>({flexWrap:"nowrap",gap:t.spacing(1)})),nt=({sx:t,children:n})=>e(Pr,{container:!0,item:!0,justifyContent:"space-between",alignItems:"center",sx:t,children:n}),Ee=({children:t,vertical:n=!1})=>e(y,{container:n,item:!0,display:"flex",alignItems:n?"start":"center",direction:n?"column":void 0,children:t}),Dr=f("span")(({theme:t})=>({fontSize:t.fontSizes.smallBody,marginLeft:t.spacing(1)})),an=({children:t})=>r(Dr,{children:["(",t,")"]}),Ir=f("aside")(({theme:t})=>({padding:t.spacing(2.5),height:"100%",borderRadius:t.shape.borderRadiusLarge,boxShadow:t.boxShadows.elevated,[t.breakpoints.up("md")]:{padding:t.spacing(6.5)}})),rn=f(I)(({theme:t})=>({fontSize:t.fontSizes.smallBody,color:t.palette.text.secondary})),Ur=f("span")(({theme:t})=>({fontSize:"3.25rem",lineHeight:1,color:t.palette.primary.main,fontWeight:800})),Br=f("span")(({theme:t})=>({marginLeft:t.spacing(1.5),fontWeight:t.fontWeight.bold})),Lr=f("span")(({theme:t})=>({color:t.palette.primary.main,fontSize:t.fontSizes.mainHeader,fontWeight:t.fontWeight.bold})),Or=f(_)(({theme:t})=>({fontSize:t.fontSizes.smallerBody,marginBottom:t.spacing(3),marginTop:t.spacing(-1.5),[t.breakpoints.up("md")]:{marginTop:t.spacing(-4.5)}})),Nr=f(Io)(({theme:t})=>({fontSize:"1rem",marginRight:t.spacing(1)})),Gr=f(Gt)(({theme:t})=>({margin:`${t.spacing(3)} 0`})),$r=({instanceStatus:t})=>{var v;const{users:n}=Ue(),o=Uo(t),{uiConfig:a}=Y(),i=n.filter(g=>g.email),s={[Me.PRO]:80,[Me.COMPANY]:0,[Me.TEAM]:0,[Me.UNKNOWN]:0,user:15},d=s[t.plan],h=t.seats??5,l=Math.min(i.length,h),c=i.length-l,u=s.user*c,m=d+u,b=t.state!==Tn.ACTIVE;return e(y,{item:!0,xs:12,md:7,children:r(Ir,{children:[e(k,{condition:b,show:r(Or,{severity:"info",children:["After you have sent your billing information, your instance will be upgraded - you don't have to do anything."," ",e("a",{href:"mailto:elise@getunleash.ai?subject=PRO plan clarifications",children:"Get in touch with us"})," ","for any clarification"]})}),e(Ut,{color:"success",children:"Current plan"}),e(y,{container:!0,children:r(nt,{sx:g=>({marginBottom:g.spacing(3)}),children:[r(Ee,{children:[e(Ur,{children:t.plan}),e(k,{condition:Bo(t),show:e(Br,{sx:g=>({color:o?g.palette.error.dark:g.palette.warning.dark}),children:o?"Trial expired":t.trialExtended?"Extended Trial":"Trial"})})]}),e(Ee,{children:e(k,{condition:d>0,show:r(Lr,{children:["$",d.toFixed(2)]})})})]})}),e(k,{condition:Boolean(((v=a==null?void 0:a.flags)==null?void 0:v.proPlanAutoCharge)&&t.plan===Me.PRO),show:r(F,{children:[r(y,{container:!0,children:[r(nt,{sx:g=>({marginBottom:g.spacing(1.5)}),children:[r(Ee,{vertical:!0,children:[r(I,{children:[e("strong",{children:"Included members"}),e(an,{children:r(Re,{to:"/admin/users",children:[l," of 5 assigned"]})})]}),e(rn,{children:"You have 5 team members included in your PRO plan"})]}),r(Ee,{children:[e(Nr,{}),e(I,{variant:"body2",children:"included"})]})]}),r(nt,{children:[r(Ee,{vertical:!0,children:[r(I,{children:[e("strong",{children:"Paid members"}),e(an,{children:r(Re,{to:"/admin/users",children:[c," assigned"]})})]}),e(rn,{children:"$15/month per paid member"})]}),e(Ee,{children:r(I,{sx:g=>({fontSize:g.fontSizes.mainHeader}),children:["$",u.toFixed(2)]})})]})]}),e(Gr,{}),e(y,{container:!0,children:r(nt,{children:[e(Ee,{children:e(I,{sx:g=>({fontWeight:g.fontWeight.bold,fontSize:g.fontSizes.mainHeader}),children:"Total per month"})}),e(Ee,{children:r(I,{sx:g=>({fontWeight:g.fontWeight.bold,fontSize:"2rem"}),children:["$",m.toFixed(2)]})})]})})]})})]})})},jr=({instanceStatus:t})=>r(y,{container:!0,spacing:4,children:[e(Er,{instanceStatus:t}),e($r,{instanceStatus:t})]}),Fr=f(I)(({theme:t})=>({marginTop:t.spacing(6),marginBottom:t.spacing(2.5),fontSize:t.fontSizes.mainHeader})),zr=[{Header:"Amount",accessor:"amountFormatted"},{Header:"Status",accessor:"status",disableGlobalFilter:!0},{Header:"Created date",accessor:"created",Cell:Ne,sortType:"date",disableGlobalFilter:!0},{Header:"Due date",accessor:"dueDate",Cell:Ne,sortType:"date",disableGlobalFilter:!0},{Header:"Download",accessor:"invoicePDF",align:"center",Cell:({value:t})=>e(j,{sx:{display:"flex",justifyContent:"center"},"data-loading":!0,children:e(Fe,{href:t,children:e(Lo,{})})}),width:100,disableGlobalFilter:!0,disableSortBy:!0}],Mr=({data:t,isLoading:n=!1})=>{const o=p.useMemo(()=>({sortBy:[{id:"created"}]}),[]),{getTableProps:a,getTableBodyProps:i,headerGroups:s,rows:d,prepareRow:h}=Z.useTable({columns:zr,data:t,initialState:o,sortTypes:je,autoResetGlobalFilter:!1,disableSortRemove:!0,defaultColumn:{Cell:Se}},Z.useGlobalFilter,Z.useSortBy);return r(Q,{isLoading:n,disablePadding:!0,children:[e(Fr,{children:"Payment history"}),r(An,{...a(),children:[e(En,{headerGroups:s}),e(pt,{...i(),children:d.map(l=>(h(l),e(qe,{hover:!0,...l.getRowProps(),children:l.cells.map(c=>e(Rn,{...c.getCellProps(),children:c.render("Cell")}))})))})]}),e(k,{condition:d.length===0,show:e(ge,{children:"No invoices to show."})})]})},Lt="api/admin/invoices",Hr=oe(Lt),Xn=(t={})=>{const n=()=>fetch(Hr,{method:"GET"}).then(Ce("Invoices")).then(h=>h.json()),{data:o,error:a}=Te(Lt,n,t),[i,s]=p.useState(!a&&!o),d=()=>{$t(Lt)};return p.useEffect(()=>{s(!a&&!o)},[o,a]),{invoices:(o==null?void 0:o.invoices)||[],error:a,loading:i,refetchInvoices:d}},Wr=()=>{const{instanceStatus:t,isBilling:n,refetchInstanceStatus:o,refresh:a,loading:i}=jt(),{invoices:s}=Xn(),{hasAccess:d}=p.useContext(he);return p.useEffect(()=>{(async()=>{await a(),o()})()},[o,a]),e("div",{children:e(Q,{header:"Billing",isLoading:i,children:e(k,{condition:n,show:e(k,{condition:d(z),show:()=>r(F,{children:[e(jr,{instanceStatus:t}),e(Mr,{data:s})]}),elseShow:()=>e($e,{})}),elseShow:e(_,{severity:"error",children:"Billing is not enabled for this instance."})})})})},qr=oe("api/admin/invoices/portal"),_r=()=>{const{refetchInvoices:t,invoices:n}=Xn(),[o,a]=p.useState(!1),{locationSettings:i}=Pn();return p.useEffect(()=>{t(),a(!0)},[]),e(k,{condition:n.length>0,show:e(Q,{header:e(te,{title:"Invoices",actions:e(M,{href:qr,rel:"noreferrer",target:"_blank",endIcon:e(Oo,{}),children:"Billing portal"})}),children:e("div",{children:r(Dn,{children:[e(In,{children:r(qe,{children:[e(ne,{children:"Amount"}),e(ne,{children:"Status"}),e(ne,{children:"Due date"}),e(ne,{children:"PDF"}),e(ne,{children:"Link"})]})}),e(pt,{children:n.map(s=>r(qe,{style:{backgroundColor:s.status==="past-due"?"error.dark":"inherit"},children:[e(ne,{style:{textAlign:"left"},children:s.amountFormatted}),e(ne,{style:{textAlign:"left"},children:s.status}),e(ne,{style:{textAlign:"left"},children:s.dueDate&&Un(s.dueDate,i.locale)}),e(ne,{style:{textAlign:"left"},children:e("a",{href:s.invoicePDF,children:"PDF"})}),e(ne,{style:{textAlign:"left"},children:e("a",{href:s.invoiceURL,target:"_blank",rel:"noreferrer",children:"Payment link"})})]},s.invoiceURL))})]})})}),elseShow:e("div",{children:o&&"No invoices to show."})})},Vr=()=>{const{hasAccess:t}=p.useContext(he);return e("div",{children:e(k,{condition:t(z),show:e(_r,{}),elseShow:e(_,{severity:"error",children:"You need to be instance admin to access this section."})})})},Yr=()=>{const{uiConfig:t,loading:n}=Y();return n?null:t.flags.UNLEASH_CLOUD?e(No,{to:"/admin/billing",replace:!0}):e(Vr,{})},Jr=()=>r(_,{severity:"info",children:[r("p",{children:["Use this page to configure allowed CORS origins for the Frontend API (",e("code",{children:"/api/frontend"}),")."]}),r("p",{children:["This configuration will not affect the Admin API (",e("code",{children:"/api/admin"}),") nor the Client API (",e("code",{children:"/api/client"}),")."]}),r("p",{children:["An asterisk (",e("code",{children:"*"}),") may be used to allow API calls from any origin."]}),e("br",{}),e("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)."})]}),Kr=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=Ie({propagateErrors:!0});return{setFrontendSettings:async s=>{const h=n("api/admin/ui-config",{method:"POST",body:JSON.stringify({frontendSettings:{frontendApiOrigins:s}})},"setFrontendSettings");await t(h.caller,h.id)},loading:a,errors:o}},Zr=({frontendApiOrigins:t})=>{const{setFrontendSettings:n}=Kr(),{setToastData:o,setToastApiError:a}=K(),[i,s]=p.useState(sn(t)),d=Xt(),h=Xt();return e("form",{onSubmit:async c=>{try{const u=Xr(i);c.preventDefault(),await n(u),s(sn(u)),o({title:"Settings saved",type:"success"})}catch(u){a(V(u))}},children:r(j,{sx:{display:"grid",gap:1},children:[r("label",{htmlFor:d,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("br",{}),e("br",{}),'If you specify "*" it will be the chosen origin.',e("br",{}),e("br",{}),"Example:"]}),r("code",{style:{fontSize:"0.7em"},children:["https://www.example.com",e("br",{}),"https://www.example2.com"]}),e(X,{id:d,"aria-describedby":h,placeholder:Qr,value:i,onChange:c=>s(c.target.value),multiline:!0,rows:12,variant:"outlined",fullWidth:!0,InputProps:{style:{fontFamily:"monospace",fontSize:"0.8em"}}}),e(Ft,{permission:z})]})})},Xr=t=>t.split(/[,\n\s]+/).map(n=>n.replace(/\/$/,"")).filter(Boolean),sn=t=>(t==null?void 0:t.join(`
@@ -12,7 +12,7 @@ import{s as f,r as p,aD as yo,cH as bo,aE as So,j as e,aF as vn,cI as Kt,cJ as T
12
12
  --data-raw '${JSON.stringify(w(),void 0,2)}'`,H=()=>{h(me)},B=E=>E.length,D=E=>!(L!=null&&L.filter(N=>N.name===E&&N.id!==n).length),O=B(l)&&D(l);return e(we,{loading:R,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/advanced/groups",documentationLinkLabel:"Groups documentation",formatApiCode:A,children:e(to,{name:l,description:u,mappingsSSO:b,users:g,setName:E=>{S(),D(E)||P({name:"A group with that name already exists."}),c(E)},setDescription:m,setMappingsSSO:v,setUsers:C,errors:x,handleSubmit:U,handleCancel:H,mode:Mt,children:e(M,{type:"submit",variant:"contained",color:"primary",disabled:!O,"data-testid":On,children:"Save"})})})},Ci=f(Nn)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(2.5,4),boxShadow:"none",marginBottom:t.spacing(2),fontSize:t.fontSizes.smallBody})),wi=f("div")(({theme:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),xi=f("h1")(({theme:t})=>({fontSize:t.fontSizes.mainHeader})),ki=f("div")(({theme:t})=>({display:"flex"})),Ti=f("span")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginLeft:t.spacing(1)})),Ai=({title:t,description:n,actions:o})=>(kn(t),r(Ci,{children:[r(wi,{children:[e(xi,{children:t}),e(ki,{children:o})]}),e(k,{condition:Boolean(n==null?void 0:n.length),show:r(F,{children:["Description:",e(Ti,{children:n})]})})]})),no=({open:t,setOpen:n,group:o})=>{const{refetchGroups:a}=_e(),{removeGroup:i}=tt(),{setToastData:s,setToastApiError:d}=K(),h=ae();return e(se,{open:t,primaryButtonText:"Delete group",secondaryButtonText:"Cancel",onClick:async()=>{try{await i(o.id),a(),n(!1),h("/admin/groups"),s({title:"Group removed successfully",type:"success"})}catch(c){d(V(c))}},onClose:()=>{n(!1)},title:"Delete group?",children:r(I,{children:["Do you really want to delete ",e("strong",{children:o.name}),"? Users who are granted access to projects only via this group will lose access to those projects."]})})},Ei=f("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),Ri=f("p")(({theme:t})=>({color:t.palette.text.secondary,marginBottom:t.spacing(1)})),Pi=f("div")(()=>({marginTop:"auto",display:"flex",justifyContent:"flex-end"})),Di=f(M)(({theme:t})=>({marginLeft:t.spacing(3)})),Ii=f(j)(({theme:t})=>({marginTop:t.spacing(2)})),oo=({open:t,setOpen:n,group:o})=>{const{refetchGroup:a}=ft(o.id),{refetchGroups:i}=_e(),{updateGroup:s,loading:d}=tt(),{setToastData:h,setToastApiError:l}=K(),{uiConfig:c}=Y(),{users:u,setUsers:m,getGroupPayload:b}=Vt(o.name,o.description,o.mappingsSSO,o.users);return p.useEffect(()=>{m(o.users)},[o.users,t,m]),e(Gn,{open:t,onClose:()=>{n(!1)},label:"Edit users",children:e(we,{loading:d,modal:!0,title:"Edit users",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/advanced/groups",documentationLinkLabel:"Groups documentation",formatApiCode:()=>`curl --location --request PUT '${c.unleashUrl}/api/admin/groups/${o.id}' \\
13
13
  --header 'Authorization: INSERT_API_KEY' \\
14
14
  --header 'Content-Type: application/json' \\
15
- --data-raw '${JSON.stringify(b(),void 0,2)}'`,children:r(Ei,{onSubmit:async C=>{C.preventDefault();try{await s(o.id,b()),a(),i(),n(!1),h({title:"Group users saved successfully",type:"success"})}catch(w){l(V(w))}},children:[r("div",{children:[e(Ri,{children:"Edit users in this group"}),e(Qn,{users:u,setUsers:m}),e(eo,{users:u,setUsers:m})]}),e(Pi,{children:r(Ii,{children:[e(M,{type:"submit",variant:"contained",color:"primary","data-testid":On,children:"Save"}),e(Di,{onClick:()=>{n(!1)},children:"Cancel"})]})})]})})})},Ui=({open:t,setOpen:n,user:o,group:a})=>{const{refetchGroup:i}=ft(a.id),{updateGroup:s}=tt(),{setToastData:d,setToastApiError:h}=K(),l=async()=>{try{const u={...a,users:a.users.filter(({id:m})=>m!==(o==null?void 0:o.id)).map(({id:m})=>({user:{id:m}}))};await s(a.id,u),i(),n(!1),d({title:"User removed from group successfully",type:"success"})}catch(u){h(V(u))}},c=(o==null?void 0:o.name)||(o==null?void 0:o.username)||(o==null?void 0:o.email);return e(se,{open:t&&Boolean(o),primaryButtonText:"Remove user",secondaryButtonText:"Cancel",onClick:l,onClose:()=>{n(!1)},title:"Remove user from group?",children:r(I,{children:["Do you really want to remove ",e("strong",{children:c})," from"," ",e("strong",{children:a.name}),"? ",e("strong",{children:c})," will lose all access rights granted by this group."]})})},Bi=Array(15).fill({name:"Name of the user",username:"Username of the user"}),Li={id:"joinedAt"},{value:cn,setValue:Oi}=Yo("Group:v1",Li),Ni=()=>{const t=Number(mt("groupId")),n=Ht(),o=ve(n.breakpoints.down("md")),{group:a,loading:i}=ft(t),[s,d]=p.useState(!1),[h,l]=p.useState(!1),[c,u]=p.useState(!1),[m,b]=p.useState(),v=p.useMemo(()=>[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:D}})=>e(Se,{children:e(ze,{user:D})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:D=>D.name||"",Cell:xe,minWidth:100,searchable:!0},{id:"username",Header:"Username",accessor:D=>D.username||D.email,Cell:xe,minWidth:100,searchable:!0},{Header:"Joined",accessor:"joinedAt",Cell:Ne,sortType:"date",maxWidth:150},{id:"createdBy",Header:"Added by",accessor:"createdBy",Cell:xe,minWidth:90,searchable:!0},{Header:"Last login",accessor:D=>D.seenAt||"",Cell:({row:{original:D}})=>e(gt,{value:D.seenAt,emptyText:"Never",title:O=>`Last login: ${O}`}),sortType:"date",maxWidth:150},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:D}})=>e(ht,{children:e(Pe,{title:"Remove user from group",arrow:!0,describeChild:!0,children:e("span",{children:e(Fe,{"data-testid":`${Jo}-${D.id}`,onClick:()=>{b(D),u(!0)},children:e(De,{})})})})}),maxWidth:100,disableSortBy:!0}],[b,u]),[g,C]=$n(),[w]=p.useState(()=>({sortBy:[{id:g.get("sort")||cn.id,desc:g.has("order")?g.get("order")==="desc":cn.desc}],hiddenColumns:["description"],globalFilter:g.get("search")||""})),[S,x]=p.useState(w.globalFilter),{data:P,getSearchText:L,getSearchContext:T}=Wt(v,S,(a==null?void 0:a.users)??[]),R=p.useMemo(()=>(P==null?void 0:P.length)===0&&i?Bi:P,[P,i]),{headerGroups:U,rows:A,prepareRow:H,state:{sortBy:B}}=Z.useTable({columns:v,data:R,initialState:w,sortTypes:je,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},Z.useSortBy,Z.useFlexLayout);return p.useEffect(()=>{const D={};D.sort=B[0].id,B[0].desc&&(D.order="desc"),S&&(D.search=S),C(D,{replace:!0}),Oi({id:B[0].id,desc:B[0].desc||!1})},[B,S,C]),e(k,{condition:Boolean(a),show:r(F,{children:[e(Ai,{title:a==null?void 0:a.name,description:a==null?void 0:a.description,actions:r(F,{children:[e(ke,{"data-testid":Ko,to:`/admin/groups/${t}/edit`,component:Re,"data-loading":!0,permission:z,tooltipProps:{title:"Edit group"},children:e(et,{})}),e(ke,{"data-testid":Zo,"data-loading":!0,onClick:()=>d(!0),permission:z,tooltipProps:{title:"Delete group"},children:e(De,{})})]})}),r(Q,{isLoading:i,header:e(te,{secondary:!0,title:`Users (${A.length<R.length?`${A.length} of ${R.length}`:R.length})`,actions:r(F,{children:[e(k,{condition:!o,show:r(F,{children:[e(ye,{initialValue:S,onChange:x,hasFilters:!0,getSearchContext:T}),e(te.Divider,{})]})}),e(jn,{"data-testid":Xo,onClick:()=>{l(!0)},maxWidth:"700px",Icon:zt,permission:z,children:"Edit users"})]}),children:e(k,{condition:o,show:e(ye,{initialValue:S,onChange:x,hasFilters:!0,getSearchContext:T})})}),children:[e(Ye,{value:L(S),children:e(Qe,{rows:A,headerGroups:U,prepareRow:H})}),e(k,{condition:A.length===0,show:e(k,{condition:(S==null?void 0:S.length)>0,show:r(ge,{children:["No users found matching “",S,"” in this group."]}),elseShow:e(ge,{children:"This group is empty. Get started by adding a user to the group."})})}),e(no,{open:s,setOpen:d,group:a}),e(oo,{open:h,setOpen:l,group:a}),e(Ui,{open:c,setOpen:u,user:m,group:a})]})]})})},Gi=f(Fn)(({theme:t})=>({pointerEvents:"none",".MuiPaper-root":{padding:t.spacing(2)}})),$i=f("div")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1)})),ji=({user:t,open:n,anchorEl:o,onPopoverClose:a})=>r(Gi,{open:n,anchorEl:o,onClose:a,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:[e($i,{children:(t==null?void 0:t.name)||(t==null?void 0:t.username)}),e("div",{children:t==null?void 0:t.email})]}),Fi=f("div")(({theme:t})=>({display:"inline-flex",alignItems:"center",flexWrap:"wrap",marginLeft:t.spacing(1)})),dn=f(ze)(({theme:t})=>({outline:`${t.spacing(.25)} solid ${t.palette.background.paper}`,marginLeft:t.spacing(-1),"&:hover":{outlineColor:t.palette.primary.main}})),zi=({users:t})=>{const n=p.useMemo(()=>t.sort((c,u)=>(u==null?void 0:u.joinedAt.getTime())-(c==null?void 0:c.joinedAt.getTime())).slice(0,9),[t]),[o,a]=p.useState(null),[i,s]=p.useState(),d=c=>{a(c.currentTarget)},h=()=>{a(null)},l=Boolean(o);return r(Fi,{children:[n.map(c=>e(dn,{user:c,onMouseEnter:u=>{d(u),s(c)},onMouseLeave:h},c.id)),e(k,{condition:t.length>9,show:r(dn,{children:["+",t.length-n.length]})}),e(ji,{open:l,user:i,anchorEl:o,onPopoverClose:h})]})},Mi=f("div")(({theme:t})=>({display:"flex",justifyContent:"center",transform:"translate3d(8px, -6px, 0)"})),Hi=f(Fn)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(1,1.5)})),Wi=({groupId:t,onEditUsers:n,onRemove:o})=>{const[a,i]=p.useState(null),s=Boolean(a),d=u=>{i(u.currentTarget)},h=()=>{i(null)},l=`feature-${t}-actions`,c=`${l}-menu`;return r(Mi,{onClick:u=>{u.preventDefault(),u.stopPropagation()},children:[e(Pe,{title:"Group actions",arrow:!0,describeChild:!0,children:e(Fe,{id:l,"aria-controls":s?c:void 0,"aria-haspopup":"true","aria-expanded":s?"true":void 0,onClick:d,type:"button",children:e(qa,{})})}),e(Hi,{id:c,anchorEl:a,open:s,onClose:h,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,children:r(Qo,{"aria-labelledby":l,children:[r(He,{onClick:h,component:Re,to:`/admin/groups/${t}/edit`,children:[e(Et,{children:e(et,{})}),e(Rt,{children:e(I,{variant:"body2",children:"Edit group"})})]}),r(He,{onClick:()=>{n(),h()},children:[e(Et,{children:e(ar,{})}),e(Rt,{children:e(I,{variant:"body2",children:"Edit group users"})})]}),r(He,{onClick:()=>{o(),h()},children:[e(Et,{children:e(De,{})}),e(Rt,{children:e(I,{variant:"body2",children:"Delete group"})})]})]})})]})},qi=f(Re)(({theme:t})=>({textDecoration:"none",color:t.palette.text.primary})),_i=f("aside")(({theme:t})=>({padding:t.spacing(2.5),height:"100%",border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge,boxShadow:t.boxShadows.card,display:"flex",flexDirection:"column",[t.breakpoints.up("md")]:{padding:t.spacing(4)},"&:hover":{transition:"background-color 0.2s ease-in-out",backgroundColor:t.palette.neutral.light}})),ao=f("div")(()=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),Vi=f(ao)(()=>({alignItems:"flex-start"})),Yi=f(ao)(()=>({marginTop:"auto"})),Ji=f("h2")(({theme:t})=>({fontSize:t.fontSizes.mainHeader,fontWeight:t.fontWeight.medium})),Ki=f("div")(({theme:t})=>({display:"flex",alignItems:"center",color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody})),Zi=f("p")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1),marginBottom:t.spacing(4)})),Xi=f("span")(({theme:t})=>({color:t.palette.text.secondary,marginLeft:t.spacing(1)})),Qi=f("div")(({theme:t})=>({maxWidth:"50%",display:"flex",justifyContent:"flex-end",gap:t.spacing(.5),flexWrap:"wrap"})),es=({group:t,onEditUsers:n,onRemoveGroup:o})=>{var i;const a=ae();return e(F,{children:e(qi,{to:`/admin/groups/${t.id}`,children:r(_i,{children:[r(Vi,{children:[e(Ji,{children:t.name}),e(Ki,{children:e(Wi,{groupId:t.id,onEditUsers:()=>n(t),onRemove:()=>o(t)})})]}),e(Zi,{children:t.description}),r(Yi,{children:[e(k,{condition:((i=t.users)==null?void 0:i.length)>0,show:e(zi,{users:t.users}),elseShow:e(Xi,{children:"This group has no users."})}),e(Qi,{children:e(k,{condition:t.projects.length>0,show:t.projects.map(s=>e(Pe,{title:"View project",arrow:!0,placement:"bottom-end",describeChild:!0,children:e(Ut,{onClick:d=>{d.preventDefault(),a(`/projects/${s}/settings/access`)},color:"secondary",icon:e(ea,{}),children:s})},s)),elseShow:e(Pe,{title:"This group is not used in any project",arrow:!0,describeChild:!0,children:e(Ut,{children:"Not used"})})})})]})]})},t.id)})},ts=()=>{const t=f("div")(({theme:o})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:o.spacing(6),marginLeft:"auto",marginRight:"auto"})),n=f(I)(({theme:o})=>({fontSize:o.fontSizes.bodySize,marginBottom:o.spacing(2.5)}));return r(t,{children:[e(n,{children:"No groups available. Get started by adding a new group."}),e(M,{to:"/admin/groups/create-group",component:Re,variant:"outlined",color:"primary",children:"Create your first group"})]})},ns=(t,n)=>{var i,s,d,h,l,c;const o=n.toLowerCase(),a={names:(i=t.users)==null?void 0:i.map(u=>{var m;return((m=u.name)==null?void 0:m.toLowerCase())||""}),usernames:(s=t.users)==null?void 0:s.map(u=>{var m;return((m=u.username)==null?void 0:m.toLowerCase())||""}),emails:(d=t.users)==null?void 0:d.map(u=>{var m;return((m=u.email)==null?void 0:m.toLowerCase())||""})};return t.name.toLowerCase().includes(o)||t.description.toLowerCase().includes(o)||((h=a.names)==null?void 0:h.some(u=>u.includes(o)))||((l=a.usernames)==null?void 0:l.some(u=>u.includes(o)))||((c=a.emails)==null?void 0:c.some(u=>u.includes(o)))},os=()=>{const t=ae(),[n,o]=p.useState(!1),[a,i]=p.useState(!1),[s,d]=p.useState(void 0),{groups:h=[],loading:l}=_e(),[c,u]=$n(),[m,b]=p.useState(c.get("search")||""),v=ve(Ge.breakpoints.down("md"));p.useEffect(()=>{const S={};m&&(S.search=m),u(S,{replace:!0})},[m,u]);const g=p.useMemo(()=>{const S=h.sort((x,P)=>x.name.localeCompare(P.name));return m?S.filter(x=>ns(x,m)):S},[h,m]),C=S=>{d(S),o(!0)},w=S=>{d(S),i(!0)};return r(Q,{isLoading:l,header:e(te,{title:`Groups (${g.length})`,actions:r(F,{children:[e(k,{condition:!v,show:r(F,{children:[e(ye,{initialValue:m,onChange:b}),e(te.Divider,{})]})}),e(jn,{onClick:()=>t("/admin/groups/create-group"),maxWidth:"700px",Icon:zt,permission:z,"data-testid":ta,children:"New group"})]}),children:e(k,{condition:v,show:e(ye,{initialValue:m,onChange:b})})}),children:[e(Ye,{value:m,children:e(y,{container:!0,spacing:2,children:g.map(S=>e(y,{item:!0,xs:12,md:6,children:e(es,{group:S,onEditUsers:C,onRemoveGroup:w})},S.id))})}),e(k,{condition:!l&&g.length===0,show:e(k,{condition:(m==null?void 0:m.length)>0,show:r(ge,{children:["No groups found matching “",m,"”"]}),elseShow:e(ts,{})})}),e(k,{condition:Boolean(s),show:e(oo,{open:n,setOpen:o,group:s})}),e(k,{condition:Boolean(s),show:e(no,{open:a,setOpen:i,group:s})})]})},as=()=>e("div",{children:e(os,{})}),rs=()=>{const{data:t,error:n,mutate:o}=Te(oe("api/admin/instance-admin/statistics"),is);return p.useMemo(()=>({stats:t,loading:!n&&!t,refetchGroup:()=>o(),error:n}),[t,n,o])},is=t=>fetch(t).then(Ce("Instance Stats")).then(n=>n.json()),ss=()=>{const{stats:t}=rs();let n,o;t!=null&&t.versionEnterprise?(n="Unleash Enterprise version",o=t.versionEnterprise):(n="Unleash OSS version",o=t==null?void 0:t.versionOSS);const a=[{title:"Instance Id",value:t==null?void 0:t.instanceId},{title:n,value:o},{title:"Users",value:t==null?void 0:t.users},{title:"Feature toggles",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}];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(Q,{header:e(te,{title:"Instance Statistics"}),children:r(_a,{sx:{display:"grid",gap:4},children:[r(Dn,{"aria-label":"Instance statistics",children:[e(In,{children:r(qe,{children:[e(ne,{children:"Field"}),e(ne,{align:"right",children:"Value"})]})}),e(pt,{children:a.map(i=>r(qe,{children:[e(ne,{component:"th",scope:"row",children:i.title}),e(ne,{align:"right",children:i.value})]},i.title))})]}),e("span",{style:{textAlign:"center"},children:e(M,{startIcon:e(na,{}),"aria-label":"Download instance statistics",color:"primary",variant:"contained",target:"_blank",href:oe("/api/admin/instance-admin/statistics/csv"),children:"Download"})})]})})},ls=()=>e("div",{children:e(ss,{})}),cs=()=>e(_,{severity:"warning",children:r("p",{children:[e("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."]})}),ds=()=>{const{data:t,error:n,mutate:o}=Te(oe("api/admin/maintenance"),us);return p.useMemo(()=>({enabled:Boolean(t==null?void 0:t.enabled),loading:!n&&!t,refetchMaintenance:o,error:n}),[t,n,o])},us=t=>fetch(t).then(Ce("Maintenance")).then(n=>n.json()),hs=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=Ie({propagateErrors:!0});return{toggleMaintenance:async s=>{const h=n("api/admin/maintenance",{method:"POST",body:JSON.stringify(s)});try{await t(h.caller,h.id)}catch(l){throw l}},errors:o,loading:a}},ps=f("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),ms=f(j)(({theme:t})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"})),gs=f(j)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),fs=f(I)(({theme:t})=>({fontSize:t.fontSizes.smallBody})),ys=()=>{const{enabled:t,refetchMaintenance:n}=ds(),{toggleMaintenance:o}=hs(),{trackEvent:a}=qt(),{setToastData:i}=K();return r(ps,{children:[r(ms,{children:[e("b",{children:"Maintenance Mode"}),e(ie,{sx:{margin:0},control:e(be,{onChange:async()=>{i({type:"success",title:`Maintenance mode has been successfully ${t?"disabled":"enabled"}`}),a("maintenance",{props:{eventType:`maintenance ${t?"de":""}activated`}}),await o({enabled:!t}),n()},value:t,name:"enabled",checked:t}),label:e(fs,{children:t?"Enabled":"Disabled"})})]}),e(gs,{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."})]})},bs=()=>{const{hasAccess:t}=p.useContext(he);return e("div",{children:e(k,{condition:t(z),show:e(vs,{}),elseShow:e($e,{})})})},Ss=f(j)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),vs=()=>{const{loading:t}=Y();return t?null:e(Q,{header:e(te,{title:"Maintenance"}),children:r(Ss,{children:[e(cs,{}),e(ys,{})]})})},Cs=t=>{const n={display:"flex",justifyContent:"center",alignItems:"center",width:"100%",textDecoration:"none",color:"inherit",padding:t.theme.spacing(1.5,3)},o={fontWeight:"bold",borderRadius:"3px",padding:t.theme.spacing(1.5,3)};return t.isActive?{...n,...o}:n},ue=({to:t,children:n})=>{const o=Ht();return e(oa,{to:t,style:({isActive:a})=>Cs({isActive:a,theme:o}),children:n})},ws=f(Nn)(({theme:t})=>({marginBottom:"1rem",borderRadius:"12.5px",boxShadow:"none",padding:"0 2rem"}));function xs(){const{uiConfig:t,isEnterprise:n}=Y(),{pathname:o}=zn(),{isBilling:a}=jt(),{flags:i,networkViewEnabled:s}=t,d=o.split("/")[2];return e(ws,{children:r(Mn,{value:d,variant:"scrollable",scrollButtons:"auto",allowScrollButtonsMobile:!0,children:[e(de,{value:"users",label:e(ue,{to:"/admin/users",children:e("span",{children:"Users"})})}),n()&&e(de,{value:"service-accounts",label:e(ue,{to:"/admin/service-accounts",children:e("span",{children:"Service accounts"})})}),i.UG&&e(de,{value:"groups",label:e(ue,{to:"/admin/groups",children:e("span",{children:"Groups"})})}),i.RE&&e(de,{value:"roles",label:e(ue,{to:"/admin/roles",children:e("span",{children:"Project roles"})})}),e(de,{value:"api",label:e(ue,{to:"/admin/api",children:"API access"})}),t.flags.embedProxyFrontend&&e(de,{value:"cors",label:e(ue,{to:"/admin/cors",children:"CORS origins"})}),e(de,{value:"auth",label:e(ue,{to:"/admin/auth",children:"Single sign-on"})}),e(de,{value:"instance",label:e(ue,{to:"/admin/instance",children:"Instance stats"})}),s&&e(de,{value:"network",label:e(ue,{to:"/admin/network",children:"Network"})}),e(de,{value:"maintenance",label:e(ue,{to:"/admin/maintenance",children:"Maintenance"})}),a&&e(de,{value:"billing",label:e(ue,{to:"/admin/billing",children:"Billing"})})]})})}const ks=p.lazy(()=>import("./NetworkOverview-02d7cec9.js")),Ts=p.lazy(()=>import("./NetworkTraffic-ea8ea762.js")),As=f(Q)(()=>({".page-header":{padding:0}})),Es=[{label:"Overview",path:"/admin/network"},{label:"Traffic",path:"/admin/network/traffic"}],Rs=()=>{const{pathname:t}=zn();return e("div",{children:e(As,{headerClass:"page-header",header:e(Mn,{value:t,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:Es.map(({label:n,path:o})=>e(de,{value:o,label:e(ue,{to:o,children:e("span",{children:n})})},n))}),children:r(Hn,{children:[e(J,{path:"traffic",element:e(Ts,{})}),e(J,{path:"*",element:e(ks,{})})]})})})},St=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=Ie({propagateErrors:!0});return{createRole:async l=>{const u=n("api/admin/roles",{method:"POST",body:JSON.stringify(l)});try{return await t(u.caller,u.id)}catch(m){throw m}},deleteRole:async l=>{const c=`api/admin/roles/${l}`,u=n(c,{method:"DELETE"});try{return await t(u.caller,u.id)}catch(m){throw m}},editRole:async(l,c)=>{const u=`api/admin/roles/${l}`,m=n(u,{method:"PUT",body:JSON.stringify(c)});try{return await t(m.caller,m.id)}catch(b){throw b}},validateRole:async l=>{const u=n("api/admin/roles/validate",{method:"POST",body:JSON.stringify(l)});try{return await t(u.caller,u.id)}catch(m){throw m}},errors:o,loading:a}},Ps=f(j)(({theme:t})=>({display:"flex",alignItems:"center",[t.breakpoints.down(500)]:{flexDirection:"column",alignItems:"flex-start"}})),Ds=f(aa)(({theme:t})=>({fontWeight:t.typography.fontWeightBold,marginRight:t.spacing(1)})),un=({title:t,permissions:n,checkedPermissions:o,Icon:a,isInitiallyExpanded:i,context:s,onPermissionChange:d,onCheckAll:h,getRoleKey:l})=>{const[c,u]=p.useState(i),m=p.useMemo(()=>(n==null?void 0:n.reduce((g,C)=>(g[l(C)]=!0,g),{}))||{},[n]),b=p.useMemo(()=>Object.keys(o).filter(g=>m[g]).length||0,[o,m]),v=p.useMemo(()=>b===(n==null?void 0:n.length),[b,n]);return e(j,{sx:{my:2,pb:1},children:r(ra,{expanded:c,onChange:()=>u(!c),sx:{boxShadow:"none",px:3,py:1,border:g=>`1px solid ${g.palette.divider}`,borderRadius:g=>`${g.shape.borderRadiusLarge}px`},children:[e(ia,{expandIcon:e(Fe,{children:e(Va,{titleAccess:"Toggle"})}),sx:{boxShadow:"none",padding:"0"},children:r(Ps,{children:[a,e(Ds,{text:t,maxWidth:"120",maxLength:25})," ",r(I,{variant:"body2",color:"text.secondary",children:["(",b," / ",n==null?void 0:n.length," ","permissions)"]})]})}),r(sa,{sx:{px:0,py:1,flexWrap:"wrap"},children:[e(Gt,{sx:{mb:1}}),r(M,{variant:"text",size:"small",onClick:h,sx:{fontWeight:g=>g.typography.fontWeightRegular},children:[v?"Unselect ":"Select ","all ",s," permissions"]}),e(j,{children:n==null?void 0:n.map(g=>e(ie,{sx:{minWidth:{sm:"300px",xs:"auto"}},control:e(Ln,{checked:!!o[l(g)],onChange:()=>d(g),color:"primary"}),label:g.displayName},l(g)))})]})]})})},ro=({children:t,roleName:n,roleDesc:o,checkedPermissions:a,errors:i,permissions:s,onSubmit:d,onCancel:h,setRoleName:l,setRoleDesc:c,handlePermissionChange:u,checkAllProjectPermissions:m,checkAllEnvironmentPermissions:b,validateNameUniqueness:v,clearErrors:g,getRoleKey:C})=>{const{project:w,environments:S}=s;return r("form",{onSubmit:d,children:[r(j,{sx:{maxWidth:"400px"},children:[e(I,{sx:{mb:1},children:"What is your role name?"}),e(Ve,{label:"Role name",value:n,onChange:x=>l(x.target.value),error:Boolean(i.name),errorText:i.name,onFocus:()=>g(),onBlur:v,autoFocus:!0,sx:{width:"100%",marginBottom:"1rem"}}),e(I,{sx:{mb:1},children:"What is this role for?"}),e(X,{label:"Role description",variant:"outlined",multiline:!0,maxRows:4,value:o,onChange:x=>c(x.target.value),sx:{width:"100%",marginBottom:"1rem"}})]}),e("div",{children:e(k,{condition:Boolean(i.permissions),show:e(I,{variant:"body2",color:"error.main",children:"You must select at least one permission for a role."})})}),e(un,{isInitiallyExpanded:!0,title:"Project permissions",Icon:e(ir,{color:"disabled",sx:{mr:1}}),permissions:w,checkedPermissions:a,onPermissionChange:x=>u(x),onCheckAll:m,getRoleKey:C,context:"project"}),e("div",{children:S.map(x=>e(un,{title:x.name,Icon:e(la,{sx:{mr:1},color:"disabled"}),permissions:x.permissions,checkedPermissions:a,onPermissionChange:P=>u(P),onCheckAll:()=>b(x.name),getRoleKey:C,context:"environment"},x.name))}),r(j,{sx:{marginTop:"auto",display:"flex",justifyContent:"flex-end"},children:[t,e(M,{onClick:h,sx:{marginLeft:2},children:"Cancel"})]})]})},pe=t=>t.environment?`${t.id}-${t.environment}`:`${t.id}`,io=(t="",n="",o=[])=>{const{permissions:a}=ca({revalidateIfStale:!1,revalidateOnReconnect:!1,revalidateOnFocus:!1}),[i,s]=p.useState(t),[d,h]=p.useState(n),[l,c]=p.useState({});p.useEffect(()=>{o.length>0&&c(o==null?void 0:o.reduce((T,R)=>(T[pe(R)]=R,T),{}))},[o==null?void 0:o.length]);const[u,m]=p.useState({}),{validateRole:b}=St();p.useEffect(()=>{s(t)},[t]),p.useEffect(()=>{h(n)},[n]);const v=T=>{let R=Pt(l);R[pe(T)]?delete R[pe(T)]:R[pe(T)]={...T},c(R)},g=()=>{const{project:T}=a;let R=Pt(l);T.every(A=>R[pe(A)])?T.forEach(A=>{delete R[pe(A)]}):T.forEach(A=>{R[pe(A)]={...A}}),c(R)},C=T=>{const{environments:R}=a,U=Pt(l),A=R.find(B=>B.name===T);if(!A)return;A.permissions.every(B=>U[pe(B)])?A.permissions.forEach(B=>{delete U[pe(B)]}):A.permissions.forEach(B=>{U[pe(B)]={...B}}),c(U)},w=()=>({name:i,description:d,permissions:Object.values(l)});return{roleName:i,roleDesc:d,errors:u,checkedPermissions:l,permissions:a,setRoleName:s,setRoleDesc:h,handlePermissionChange:v,onToggleAllProjectPermissions:g,onToggleAllEnvironmentPermissions:C,getProjectRolePayload:w,validatePermissions:()=>Object.keys(l).length===0?(m(T=>({...T,permissions:"You must include at least one permission."})),!1):!0,validateName:()=>i.length===0?(m(T=>({...T,name:"Name can not be empty."})),!1):!0,clearErrors:()=>{m({})},validateNameUniqueness:async()=>{const T=w();try{await b(T)}catch(R){m(U=>({...U,name:V(R)}))}},getRoleKey:pe}},Is=()=>{const{setToastData:t,setToastApiError:n}=K(),{uiConfig:o}=Y(),a=ae(),{roleName:i,roleDesc:s,permissions:d,checkedPermissions:h,errors:l,setRoleName:c,setRoleDesc:u,handlePermissionChange:m,onToggleAllProjectPermissions:b,onToggleAllEnvironmentPermissions:v,getProjectRolePayload:g,validatePermissions:C,validateName:w,validateNameUniqueness:S,clearErrors:x,getRoleKey:P}=io(),{createRole:L,loading:T}=St();return e(we,{loading:T,title:"Create project role",description:`A project role can be
15
+ --data-raw '${JSON.stringify(b(),void 0,2)}'`,children:r(Ei,{onSubmit:async C=>{C.preventDefault();try{await s(o.id,b()),a(),i(),n(!1),h({title:"Group users saved successfully",type:"success"})}catch(w){l(V(w))}},children:[r("div",{children:[e(Ri,{children:"Edit users in this group"}),e(Qn,{users:u,setUsers:m}),e(eo,{users:u,setUsers:m})]}),e(Pi,{children:r(Ii,{children:[e(M,{type:"submit",variant:"contained",color:"primary","data-testid":On,children:"Save"}),e(Di,{onClick:()=>{n(!1)},children:"Cancel"})]})})]})})})},Ui=({open:t,setOpen:n,user:o,group:a})=>{const{refetchGroup:i}=ft(a.id),{updateGroup:s}=tt(),{setToastData:d,setToastApiError:h}=K(),l=async()=>{try{const u={...a,users:a.users.filter(({id:m})=>m!==(o==null?void 0:o.id)).map(({id:m})=>({user:{id:m}}))};await s(a.id,u),i(),n(!1),d({title:"User removed from group successfully",type:"success"})}catch(u){h(V(u))}},c=(o==null?void 0:o.name)||(o==null?void 0:o.username)||(o==null?void 0:o.email);return e(se,{open:t&&Boolean(o),primaryButtonText:"Remove user",secondaryButtonText:"Cancel",onClick:l,onClose:()=>{n(!1)},title:"Remove user from group?",children:r(I,{children:["Do you really want to remove ",e("strong",{children:c})," from"," ",e("strong",{children:a.name}),"? ",e("strong",{children:c})," will lose all access rights granted by this group."]})})},Bi=Array(15).fill({name:"Name of the user",username:"Username of the user"}),Li={id:"joinedAt"},{value:cn,setValue:Oi}=Yo("Group:v1",Li),Ni=()=>{const t=Number(mt("groupId")),n=Ht(),o=ve(n.breakpoints.down("md")),{group:a,loading:i}=ft(t),[s,d]=p.useState(!1),[h,l]=p.useState(!1),[c,u]=p.useState(!1),[m,b]=p.useState(),v=p.useMemo(()=>[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:D}})=>e(Se,{children:e(ze,{user:D})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:D=>D.name||"",Cell:xe,minWidth:100,searchable:!0},{id:"username",Header:"Username",accessor:D=>D.username||D.email,Cell:xe,minWidth:100,searchable:!0},{Header:"Joined",accessor:"joinedAt",Cell:Ne,sortType:"date",maxWidth:150},{id:"createdBy",Header:"Added by",accessor:"createdBy",Cell:xe,minWidth:90,searchable:!0},{Header:"Last login",accessor:D=>D.seenAt||"",Cell:({row:{original:D}})=>e(gt,{value:D.seenAt,emptyText:"Never",title:O=>`Last login: ${O}`}),sortType:"date",maxWidth:150},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:D}})=>e(ht,{children:e(Pe,{title:"Remove user from group",arrow:!0,describeChild:!0,children:e("span",{children:e(Fe,{"data-testid":`${Jo}-${D.id}`,onClick:()=>{b(D),u(!0)},children:e(De,{})})})})}),maxWidth:100,disableSortBy:!0}],[b,u]),[g,C]=$n(),[w]=p.useState(()=>({sortBy:[{id:g.get("sort")||cn.id,desc:g.has("order")?g.get("order")==="desc":cn.desc}],hiddenColumns:["description"],globalFilter:g.get("search")||""})),[S,x]=p.useState(w.globalFilter),{data:P,getSearchText:L,getSearchContext:T}=Wt(v,S,(a==null?void 0:a.users)??[]),R=p.useMemo(()=>(P==null?void 0:P.length)===0&&i?Bi:P,[P,i]),{headerGroups:U,rows:A,prepareRow:H,state:{sortBy:B}}=Z.useTable({columns:v,data:R,initialState:w,sortTypes:je,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},Z.useSortBy,Z.useFlexLayout);return p.useEffect(()=>{const D={};D.sort=B[0].id,B[0].desc&&(D.order="desc"),S&&(D.search=S),C(D,{replace:!0}),Oi({id:B[0].id,desc:B[0].desc||!1})},[B,S,C]),e(k,{condition:Boolean(a),show:r(F,{children:[e(Ai,{title:a==null?void 0:a.name,description:a==null?void 0:a.description,actions:r(F,{children:[e(ke,{"data-testid":Ko,to:`/admin/groups/${t}/edit`,component:Re,"data-loading":!0,permission:z,tooltipProps:{title:"Edit group"},children:e(et,{})}),e(ke,{"data-testid":Zo,"data-loading":!0,onClick:()=>d(!0),permission:z,tooltipProps:{title:"Delete group"},children:e(De,{})})]})}),r(Q,{isLoading:i,header:e(te,{secondary:!0,title:`Users (${A.length<R.length?`${A.length} of ${R.length}`:R.length})`,actions:r(F,{children:[e(k,{condition:!o,show:r(F,{children:[e(ye,{initialValue:S,onChange:x,hasFilters:!0,getSearchContext:T}),e(te.Divider,{})]})}),e(jn,{"data-testid":Xo,onClick:()=>{l(!0)},maxWidth:"700px",Icon:zt,permission:z,children:"Edit users"})]}),children:e(k,{condition:o,show:e(ye,{initialValue:S,onChange:x,hasFilters:!0,getSearchContext:T})})}),children:[e(Ye,{value:L(S),children:e(Qe,{rows:A,headerGroups:U,prepareRow:H})}),e(k,{condition:A.length===0,show:e(k,{condition:(S==null?void 0:S.length)>0,show:r(ge,{children:["No users found matching “",S,"” in this group."]}),elseShow:e(ge,{children:"This group is empty. Get started by adding a user to the group."})})}),e(no,{open:s,setOpen:d,group:a}),e(oo,{open:h,setOpen:l,group:a}),e(Ui,{open:c,setOpen:u,user:m,group:a})]})]})})},Gi=f(Fn)(({theme:t})=>({pointerEvents:"none",".MuiPaper-root":{padding:t.spacing(2)}})),$i=f("div")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1)})),ji=({user:t,open:n,anchorEl:o,onPopoverClose:a})=>r(Gi,{open:n,anchorEl:o,onClose:a,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:[e($i,{children:(t==null?void 0:t.name)||(t==null?void 0:t.username)}),e("div",{children:t==null?void 0:t.email})]}),Fi=f("div")(({theme:t})=>({display:"inline-flex",alignItems:"center",flexWrap:"wrap",marginLeft:t.spacing(1)})),dn=f(ze)(({theme:t})=>({outline:`${t.spacing(.25)} solid ${t.palette.background.paper}`,marginLeft:t.spacing(-1),"&:hover":{outlineColor:t.palette.primary.main}})),zi=({users:t})=>{const n=p.useMemo(()=>t.sort((c,u)=>(u==null?void 0:u.joinedAt.getTime())-(c==null?void 0:c.joinedAt.getTime())).slice(0,9),[t]),[o,a]=p.useState(null),[i,s]=p.useState(),d=c=>{a(c.currentTarget)},h=()=>{a(null)},l=Boolean(o);return r(Fi,{children:[n.map(c=>e(dn,{user:c,onMouseEnter:u=>{d(u),s(c)},onMouseLeave:h},c.id)),e(k,{condition:t.length>9,show:r(dn,{children:["+",t.length-n.length]})}),e(ji,{open:l,user:i,anchorEl:o,onPopoverClose:h})]})},Mi=f("div")(({theme:t})=>({display:"flex",justifyContent:"center",transform:"translate3d(8px, -6px, 0)"})),Hi=f(Fn)(({theme:t})=>({borderRadius:t.shape.borderRadiusLarge,padding:t.spacing(1,1.5)})),Wi=({groupId:t,onEditUsers:n,onRemove:o})=>{const[a,i]=p.useState(null),s=Boolean(a),d=u=>{i(u.currentTarget)},h=()=>{i(null)},l=`feature-${t}-actions`,c=`${l}-menu`;return r(Mi,{onClick:u=>{u.preventDefault(),u.stopPropagation()},children:[e(Pe,{title:"Group actions",arrow:!0,describeChild:!0,children:e(Fe,{id:l,"aria-controls":s?c:void 0,"aria-haspopup":"true","aria-expanded":s?"true":void 0,onClick:d,type:"button",children:e(qa,{})})}),e(Hi,{id:c,anchorEl:a,open:s,onClose:h,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,children:r(Qo,{"aria-labelledby":l,children:[r(He,{onClick:h,component:Re,to:`/admin/groups/${t}/edit`,children:[e(Et,{children:e(et,{})}),e(Rt,{children:e(I,{variant:"body2",children:"Edit group"})})]}),r(He,{onClick:()=>{n(),h()},children:[e(Et,{children:e(ar,{})}),e(Rt,{children:e(I,{variant:"body2",children:"Edit group users"})})]}),r(He,{onClick:()=>{o(),h()},children:[e(Et,{children:e(De,{})}),e(Rt,{children:e(I,{variant:"body2",children:"Delete group"})})]})]})})]})},qi=f(Re)(({theme:t})=>({textDecoration:"none",color:t.palette.text.primary})),_i=f("aside")(({theme:t})=>({padding:t.spacing(2.5),height:"100%",border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge,boxShadow:t.boxShadows.card,display:"flex",flexDirection:"column",[t.breakpoints.up("md")]:{padding:t.spacing(4)},"&:hover":{transition:"background-color 0.2s ease-in-out",backgroundColor:t.palette.neutral.light}})),ao=f("div")(()=>({display:"flex",alignItems:"center",justifyContent:"space-between"})),Vi=f(ao)(()=>({alignItems:"flex-start"})),Yi=f(ao)(()=>({marginTop:"auto"})),Ji=f("h2")(({theme:t})=>({fontSize:t.fontSizes.mainHeader,fontWeight:t.fontWeight.medium})),Ki=f("div")(({theme:t})=>({display:"flex",alignItems:"center",color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody})),Zi=f("p")(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(1),marginBottom:t.spacing(4)})),Xi=f("span")(({theme:t})=>({color:t.palette.text.secondary,marginLeft:t.spacing(1)})),Qi=f("div")(({theme:t})=>({maxWidth:"50%",display:"flex",justifyContent:"flex-end",gap:t.spacing(.5),flexWrap:"wrap"})),es=({group:t,onEditUsers:n,onRemoveGroup:o})=>{var i;const a=ae();return e(F,{children:e(qi,{to:`/admin/groups/${t.id}`,children:r(_i,{children:[r(Vi,{children:[e(Ji,{children:t.name}),e(Ki,{children:e(Wi,{groupId:t.id,onEditUsers:()=>n(t),onRemove:()=>o(t)})})]}),e(Zi,{children:t.description}),r(Yi,{children:[e(k,{condition:((i=t.users)==null?void 0:i.length)>0,show:e(zi,{users:t.users}),elseShow:e(Xi,{children:"This group has no users."})}),e(Qi,{children:e(k,{condition:t.projects.length>0,show:t.projects.map(s=>e(Pe,{title:"View project",arrow:!0,placement:"bottom-end",describeChild:!0,children:e(Ut,{onClick:d=>{d.preventDefault(),a(`/projects/${s}/settings/access`)},color:"secondary",icon:e(ea,{}),children:s})},s)),elseShow:e(Pe,{title:"This group is not used in any project",arrow:!0,describeChild:!0,children:e(Ut,{children:"Not used"})})})})]})]})},t.id)})},ts=()=>{const t=f("div")(({theme:o})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:o.spacing(6),marginLeft:"auto",marginRight:"auto"})),n=f(I)(({theme:o})=>({fontSize:o.fontSizes.bodySize,marginBottom:o.spacing(2.5)}));return r(t,{children:[e(n,{children:"No groups available. Get started by adding a new group."}),e(M,{to:"/admin/groups/create-group",component:Re,variant:"outlined",color:"primary",children:"Create your first group"})]})},ns=(t,n)=>{var i,s,d,h,l,c;const o=n.toLowerCase(),a={names:(i=t.users)==null?void 0:i.map(u=>{var m;return((m=u.name)==null?void 0:m.toLowerCase())||""}),usernames:(s=t.users)==null?void 0:s.map(u=>{var m;return((m=u.username)==null?void 0:m.toLowerCase())||""}),emails:(d=t.users)==null?void 0:d.map(u=>{var m;return((m=u.email)==null?void 0:m.toLowerCase())||""})};return t.name.toLowerCase().includes(o)||t.description.toLowerCase().includes(o)||((h=a.names)==null?void 0:h.some(u=>u.includes(o)))||((l=a.usernames)==null?void 0:l.some(u=>u.includes(o)))||((c=a.emails)==null?void 0:c.some(u=>u.includes(o)))},os=()=>{const t=ae(),[n,o]=p.useState(!1),[a,i]=p.useState(!1),[s,d]=p.useState(void 0),{groups:h=[],loading:l}=_e(),[c,u]=$n(),[m,b]=p.useState(c.get("search")||""),v=ve(Ge.breakpoints.down("md"));p.useEffect(()=>{const S={};m&&(S.search=m),u(S,{replace:!0})},[m,u]);const g=p.useMemo(()=>{const S=h.sort((x,P)=>x.name.localeCompare(P.name));return m?S.filter(x=>ns(x,m)):S},[h,m]),C=S=>{d(S),o(!0)},w=S=>{d(S),i(!0)};return r(Q,{isLoading:l,header:e(te,{title:`Groups (${g.length})`,actions:r(F,{children:[e(k,{condition:!v,show:r(F,{children:[e(ye,{initialValue:m,onChange:b}),e(te.Divider,{})]})}),e(jn,{onClick:()=>t("/admin/groups/create-group"),maxWidth:"700px",Icon:zt,permission:z,"data-testid":ta,children:"New group"})]}),children:e(k,{condition:v,show:e(ye,{initialValue:m,onChange:b})})}),children:[e(Ye,{value:m,children:e(y,{container:!0,spacing:2,children:g.map(S=>e(y,{item:!0,xs:12,md:6,children:e(es,{group:S,onEditUsers:C,onRemoveGroup:w})},S.id))})}),e(k,{condition:!l&&g.length===0,show:e(k,{condition:(m==null?void 0:m.length)>0,show:r(ge,{children:["No groups found matching “",m,"”"]}),elseShow:e(ts,{})})}),e(k,{condition:Boolean(s),show:e(oo,{open:n,setOpen:o,group:s})}),e(k,{condition:Boolean(s),show:e(no,{open:a,setOpen:i,group:s})})]})},as=()=>e("div",{children:e(os,{})}),rs=()=>{const{data:t,error:n,mutate:o}=Te(oe("api/admin/instance-admin/statistics"),is);return p.useMemo(()=>({stats:t,loading:!n&&!t,refetchGroup:()=>o(),error:n}),[t,n,o])},is=t=>fetch(t).then(Ce("Instance Stats")).then(n=>n.json()),ss=()=>{const{stats:t}=rs();let n,o;t!=null&&t.versionEnterprise?(n="Unleash Enterprise version",o=t.versionEnterprise):(n="Unleash OSS version",o=t==null?void 0:t.versionOSS);const a=[{title:"Instance Id",value:t==null?void 0:t.instanceId},{title:n,value:o},{title:"Users",value:t==null?void 0:t.users},{title:"Feature toggles",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}];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(Q,{header:e(te,{title:"Instance Statistics"}),children:r(_a,{sx:{display:"grid",gap:4},children:[r(Dn,{"aria-label":"Instance statistics",children:[e(In,{children:r(qe,{children:[e(ne,{children:"Field"}),e(ne,{align:"right",children:"Value"})]})}),e(pt,{children:a.map(i=>r(qe,{children:[e(ne,{component:"th",scope:"row",children:i.title}),e(ne,{align:"right",children:i.value})]},i.title))})]}),e("span",{style:{textAlign:"center"},children:e(M,{startIcon:e(na,{}),"aria-label":"Download instance statistics",color:"primary",variant:"contained",target:"_blank",href:oe("/api/admin/instance-admin/statistics/csv"),children:"Download"})})]})})},ls=()=>e("div",{children:e(ss,{})}),cs=()=>e(_,{severity:"warning",children:r("p",{children:[e("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."]})}),ds=()=>{const{data:t,error:n,mutate:o}=Te(oe("api/admin/maintenance"),us);return p.useMemo(()=>({enabled:Boolean(t==null?void 0:t.enabled),loading:!n&&!t,refetchMaintenance:o,error:n}),[t,n,o])},us=t=>fetch(t).then(Ce("Maintenance")).then(n=>n.json()),hs=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=Ie({propagateErrors:!0});return{toggleMaintenance:async s=>{const h=n("api/admin/maintenance",{method:"POST",body:JSON.stringify(s)});try{await t(h.caller,h.id)}catch(l){throw l}},errors:o,loading:a}},ps=f("div")(({theme:t})=>({display:"flex",flexDirection:"column",padding:t.spacing(3),border:`1px solid ${t.palette.divider}`,borderRadius:t.shape.borderRadiusLarge})),ms=f(j)(({theme:t})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"})),gs=f(j)(({theme:t})=>({color:t.palette.text.secondary,fontSize:t.fontSizes.smallBody,marginTop:t.spacing(2)})),fs=f(I)(({theme:t})=>({fontSize:t.fontSizes.smallBody})),ys=()=>{const{enabled:t,refetchMaintenance:n}=ds(),{toggleMaintenance:o}=hs(),{trackEvent:a}=qt(),{setToastData:i}=K();return r(ps,{children:[r(ms,{children:[e("b",{children:"Maintenance Mode"}),e(ie,{sx:{margin:0},control:e(be,{onChange:async()=>{i({type:"success",title:`Maintenance mode has been successfully ${t?"disabled":"enabled"}`}),a("maintenance",{props:{eventType:`maintenance ${t?"de":""}activated`}}),await o({enabled:!t}),n()},value:t,name:"enabled",checked:t}),label:e(fs,{children:t?"Enabled":"Disabled"})})]}),e(gs,{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."})]})},bs=()=>{const{hasAccess:t}=p.useContext(he);return e("div",{children:e(k,{condition:t(z),show:e(vs,{}),elseShow:e($e,{})})})},Ss=f(j)(({theme:t})=>({display:"grid",gap:t.spacing(4)})),vs=()=>{const{loading:t}=Y();return t?null:e(Q,{header:e(te,{title:"Maintenance"}),children:r(Ss,{children:[e(cs,{}),e(ys,{})]})})},Cs=t=>{const n={display:"flex",justifyContent:"center",alignItems:"center",width:"100%",textDecoration:"none",color:"inherit",padding:t.theme.spacing(1.5,3)},o={fontWeight:"bold",borderRadius:"3px",padding:t.theme.spacing(1.5,3)};return t.isActive?{...n,...o}:n},ue=({to:t,children:n})=>{const o=Ht();return e(oa,{to:t,style:({isActive:a})=>Cs({isActive:a,theme:o}),children:n})},ws=f(Nn)(({theme:t})=>({marginBottom:"1rem",borderRadius:"12.5px",boxShadow:"none",padding:"0 2rem"}));function xs(){const{uiConfig:t,isEnterprise:n}=Y(),{pathname:o}=zn(),{isBilling:a}=jt(),{flags:i,networkViewEnabled:s}=t,d=o.split("/")[2];return e(ws,{children:r(Mn,{value:d,variant:"scrollable",scrollButtons:"auto",allowScrollButtonsMobile:!0,children:[e(de,{value:"users",label:e(ue,{to:"/admin/users",children:e("span",{children:"Users"})})}),n()&&e(de,{value:"service-accounts",label:e(ue,{to:"/admin/service-accounts",children:e("span",{children:"Service accounts"})})}),i.UG&&e(de,{value:"groups",label:e(ue,{to:"/admin/groups",children:e("span",{children:"Groups"})})}),i.RE&&e(de,{value:"roles",label:e(ue,{to:"/admin/roles",children:e("span",{children:"Project roles"})})}),e(de,{value:"api",label:e(ue,{to:"/admin/api",children:"API access"})}),t.flags.embedProxyFrontend&&e(de,{value:"cors",label:e(ue,{to:"/admin/cors",children:"CORS origins"})}),e(de,{value:"auth",label:e(ue,{to:"/admin/auth",children:"Single sign-on"})}),e(de,{value:"instance",label:e(ue,{to:"/admin/instance",children:"Instance stats"})}),s&&e(de,{value:"network",label:e(ue,{to:"/admin/network",children:"Network"})}),e(de,{value:"maintenance",label:e(ue,{to:"/admin/maintenance",children:"Maintenance"})}),a&&e(de,{value:"billing",label:e(ue,{to:"/admin/billing",children:"Billing"})})]})})}const ks=p.lazy(()=>import("./NetworkOverview-c9972cf4.js")),Ts=p.lazy(()=>import("./NetworkTraffic-b4d65658.js")),As=f(Q)(()=>({".page-header":{padding:0}})),Es=[{label:"Overview",path:"/admin/network"},{label:"Traffic",path:"/admin/network/traffic"}],Rs=()=>{const{pathname:t}=zn();return e("div",{children:e(As,{headerClass:"page-header",header:e(Mn,{value:t,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:Es.map(({label:n,path:o})=>e(de,{value:o,label:e(ue,{to:o,children:e("span",{children:n})})},n))}),children:r(Hn,{children:[e(J,{path:"traffic",element:e(Ts,{})}),e(J,{path:"*",element:e(ks,{})})]})})})},St=()=>{const{makeRequest:t,createRequest:n,errors:o,loading:a}=Ie({propagateErrors:!0});return{createRole:async l=>{const u=n("api/admin/roles",{method:"POST",body:JSON.stringify(l)});try{return await t(u.caller,u.id)}catch(m){throw m}},deleteRole:async l=>{const c=`api/admin/roles/${l}`,u=n(c,{method:"DELETE"});try{return await t(u.caller,u.id)}catch(m){throw m}},editRole:async(l,c)=>{const u=`api/admin/roles/${l}`,m=n(u,{method:"PUT",body:JSON.stringify(c)});try{return await t(m.caller,m.id)}catch(b){throw b}},validateRole:async l=>{const u=n("api/admin/roles/validate",{method:"POST",body:JSON.stringify(l)});try{return await t(u.caller,u.id)}catch(m){throw m}},errors:o,loading:a}},Ps=f(j)(({theme:t})=>({display:"flex",alignItems:"center",[t.breakpoints.down(500)]:{flexDirection:"column",alignItems:"flex-start"}})),Ds=f(aa)(({theme:t})=>({fontWeight:t.typography.fontWeightBold,marginRight:t.spacing(1)})),un=({title:t,permissions:n,checkedPermissions:o,Icon:a,isInitiallyExpanded:i,context:s,onPermissionChange:d,onCheckAll:h,getRoleKey:l})=>{const[c,u]=p.useState(i),m=p.useMemo(()=>(n==null?void 0:n.reduce((g,C)=>(g[l(C)]=!0,g),{}))||{},[n]),b=p.useMemo(()=>Object.keys(o).filter(g=>m[g]).length||0,[o,m]),v=p.useMemo(()=>b===(n==null?void 0:n.length),[b,n]);return e(j,{sx:{my:2,pb:1},children:r(ra,{expanded:c,onChange:()=>u(!c),sx:{boxShadow:"none",px:3,py:1,border:g=>`1px solid ${g.palette.divider}`,borderRadius:g=>`${g.shape.borderRadiusLarge}px`},children:[e(ia,{expandIcon:e(Fe,{children:e(Va,{titleAccess:"Toggle"})}),sx:{boxShadow:"none",padding:"0"},children:r(Ps,{children:[a,e(Ds,{text:t,maxWidth:"120",maxLength:25})," ",r(I,{variant:"body2",color:"text.secondary",children:["(",b," / ",n==null?void 0:n.length," ","permissions)"]})]})}),r(sa,{sx:{px:0,py:1,flexWrap:"wrap"},children:[e(Gt,{sx:{mb:1}}),r(M,{variant:"text",size:"small",onClick:h,sx:{fontWeight:g=>g.typography.fontWeightRegular},children:[v?"Unselect ":"Select ","all ",s," permissions"]}),e(j,{children:n==null?void 0:n.map(g=>e(ie,{sx:{minWidth:{sm:"300px",xs:"auto"}},control:e(Ln,{checked:!!o[l(g)],onChange:()=>d(g),color:"primary"}),label:g.displayName},l(g)))})]})]})})},ro=({children:t,roleName:n,roleDesc:o,checkedPermissions:a,errors:i,permissions:s,onSubmit:d,onCancel:h,setRoleName:l,setRoleDesc:c,handlePermissionChange:u,checkAllProjectPermissions:m,checkAllEnvironmentPermissions:b,validateNameUniqueness:v,clearErrors:g,getRoleKey:C})=>{const{project:w,environments:S}=s;return r("form",{onSubmit:d,children:[r(j,{sx:{maxWidth:"400px"},children:[e(I,{sx:{mb:1},children:"What is your role name?"}),e(Ve,{label:"Role name",value:n,onChange:x=>l(x.target.value),error:Boolean(i.name),errorText:i.name,onFocus:()=>g(),onBlur:v,autoFocus:!0,sx:{width:"100%",marginBottom:"1rem"}}),e(I,{sx:{mb:1},children:"What is this role for?"}),e(X,{label:"Role description",variant:"outlined",multiline:!0,maxRows:4,value:o,onChange:x=>c(x.target.value),sx:{width:"100%",marginBottom:"1rem"}})]}),e("div",{children:e(k,{condition:Boolean(i.permissions),show:e(I,{variant:"body2",color:"error.main",children:"You must select at least one permission for a role."})})}),e(un,{isInitiallyExpanded:!0,title:"Project permissions",Icon:e(ir,{color:"disabled",sx:{mr:1}}),permissions:w,checkedPermissions:a,onPermissionChange:x=>u(x),onCheckAll:m,getRoleKey:C,context:"project"}),e("div",{children:S.map(x=>e(un,{title:x.name,Icon:e(la,{sx:{mr:1},color:"disabled"}),permissions:x.permissions,checkedPermissions:a,onPermissionChange:P=>u(P),onCheckAll:()=>b(x.name),getRoleKey:C,context:"environment"},x.name))}),r(j,{sx:{marginTop:"auto",display:"flex",justifyContent:"flex-end"},children:[t,e(M,{onClick:h,sx:{marginLeft:2},children:"Cancel"})]})]})},pe=t=>t.environment?`${t.id}-${t.environment}`:`${t.id}`,io=(t="",n="",o=[])=>{const{permissions:a}=ca({revalidateIfStale:!1,revalidateOnReconnect:!1,revalidateOnFocus:!1}),[i,s]=p.useState(t),[d,h]=p.useState(n),[l,c]=p.useState({});p.useEffect(()=>{o.length>0&&c(o==null?void 0:o.reduce((T,R)=>(T[pe(R)]=R,T),{}))},[o==null?void 0:o.length]);const[u,m]=p.useState({}),{validateRole:b}=St();p.useEffect(()=>{s(t)},[t]),p.useEffect(()=>{h(n)},[n]);const v=T=>{let R=Pt(l);R[pe(T)]?delete R[pe(T)]:R[pe(T)]={...T},c(R)},g=()=>{const{project:T}=a;let R=Pt(l);T.every(A=>R[pe(A)])?T.forEach(A=>{delete R[pe(A)]}):T.forEach(A=>{R[pe(A)]={...A}}),c(R)},C=T=>{const{environments:R}=a,U=Pt(l),A=R.find(B=>B.name===T);if(!A)return;A.permissions.every(B=>U[pe(B)])?A.permissions.forEach(B=>{delete U[pe(B)]}):A.permissions.forEach(B=>{U[pe(B)]={...B}}),c(U)},w=()=>({name:i,description:d,permissions:Object.values(l)});return{roleName:i,roleDesc:d,errors:u,checkedPermissions:l,permissions:a,setRoleName:s,setRoleDesc:h,handlePermissionChange:v,onToggleAllProjectPermissions:g,onToggleAllEnvironmentPermissions:C,getProjectRolePayload:w,validatePermissions:()=>Object.keys(l).length===0?(m(T=>({...T,permissions:"You must include at least one permission."})),!1):!0,validateName:()=>i.length===0?(m(T=>({...T,name:"Name can not be empty."})),!1):!0,clearErrors:()=>{m({})},validateNameUniqueness:async()=>{const T=w();try{await b(T)}catch(R){m(U=>({...U,name:V(R)}))}},getRoleKey:pe}},Is=()=>{const{setToastData:t,setToastApiError:n}=K(),{uiConfig:o}=Y(),a=ae(),{roleName:i,roleDesc:s,permissions:d,checkedPermissions:h,errors:l,setRoleName:c,setRoleDesc:u,handlePermissionChange:m,onToggleAllProjectPermissions:b,onToggleAllEnvironmentPermissions:v,getProjectRolePayload:g,validatePermissions:C,validateName:w,validateNameUniqueness:S,clearErrors:x,getRoleKey:P}=io(),{createRole:L,loading:T}=St();return e(we,{loading:T,title:"Create project role",description:`A project role can be
16
16
  customised to limit access
17
17
  to resources within a project`,documentationLink:"https://docs.getunleash.io/reference/rbac#custom-project-roles",documentationLinkLabel:"Project roles documentation",formatApiCode:()=>`curl --location --request POST '${o.unleashUrl}/api/admin/roles' \\
18
18
  --header 'Authorization: INSERT_API_KEY' \\
@@ -1,4 +1,4 @@
1
- import{c as W1,j as t,cO as j0,cP as D0,s as p,cj as O0,cg as Ke,g as n2,r as d,d$ as $0,l as i1,d as r1,f as s,S as a2,h as r2,i as o2,k as i2,bS as B0,a_ as ke,A as U1,aR as ie,aS as q1,aT as G1,e0 as Ct,aI as Q,e1 as k1,bL as T1,a2 as u1,ca as P1,au as s2,H as l1,e2 as _0,R as Ee,cV as J2,bC as Y2,e3 as E1,al as s1,V as x1,ak as p1,C,aO as R1,X as se,W as y1,ce as F0,K as c2,e4 as V0,a as A,e5 as C1,e6 as M0,bD as L0,cB as ce,cC as le,cD as de,b9 as K1,m as B1,e7 as z0,P as l2,du as d2,e8 as X1,ck as Q2,a8 as H1,e9 as k2,bd as ee,dN as H0,bf as te,T as B,cm as St,aN as p2,af as wt,c1 as X2,u as h1,N as g1,ea as N0,F as G,eb as xt,as as I1,a9 as v1,ec as W0,a4 as f1,bG as U0,bE as e3,cn as q0,ed as Tt,ds as At,bu as G0,ar as _1,L as t3,aV as u2,ee as K0,bB as J0,ch as Y0,ef as Q0,eg as X0,eh as en,ei as Et,ej as Rt,O as kt,ek as tn,c6 as h2,Q as m2,d5 as nn,cf as an,bJ as Pt,Y as g2,el as rn,D as It,aQ as on,cb as sn,M as Zt,em as cn,ah as F1,en as jt,ag as Dt,eo as Ot,ai as ln,ep as dn,eq as pn,aU as $t,er as n3,a1 as un,es as Bt,et as hn,eu as mn,ev as gn,ew as fn,by as _t,ex as Ft,ey as Vt,e as Pe,U as f2,ez as vn,eA as yn,aK as bn,bk as Cn,eB as Ie,eC as Mt,eD as Sn,aB as pe,aC as J1,aL as Z1,aD as ue,aG as he,aH as me,eE as wn,c7 as Ae,bI as Lt,eF as zt,eG as xn,bj as ge,aq as Ht,b1 as a3,b0 as r3,aZ as o3,eH as Tn,eI as An,ac as Je,eJ as En,eK as Rn,eL as kn,df as v2,bq as Pn,c5 as In,dn as Ye,eM as Zn,co as i3,eN as y2,bO as ne,aM as N1,aP as s3,aY as c3,aA as $1,av as Nt,eO as jn,ad as A3,eP as Dn,de as Ve,eQ as On,eR as $n,cG as Bn,cE as _n,dI as Fn,eS as Vn,eT as Mn,eU as Ln,bM as Ze,bN as n1,eV as zn,c4 as Wt,d_ as Ut,Z as l3,ax as Hn,eW as Nn,cZ as Wn,eX as Un,eY as qn,eZ as Gn,ci as qt,e_ as Kn,db as Gt,e$ as ae,f0 as J,f1 as Jn,f2 as Yn,f3 as Qn,f4 as Xn,f5 as e4,di as t4,f6 as n4,f7 as a4,f8 as r4,f9 as o4}from"./index-1d165488.js";import{A as i4,e as Kt,W as E3,c as s4,b as Jt,T as c4,d as l4,u as d4,E as p4,V as u4,a as h4,g as m4,C as g4,U as f4}from"./FeatureArchiveDialog-fd71aac2.js";import{M as v4,m as y4,h as b4,b as C4,c as S4,d as w4,e as x4,E as T4,f as A4,u as E4,a as R4,R as k4,C as P4,A as I4,B as Yt}from"./useProjectRole-f048973d.js";import{a as Z4}from"./index-96dcc77e.js";import{E as j4}from"./Error-e6e1194a.js";const D4=W1(t("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"}),"ArrowUpward"),O4=W1(t("path",{d:"M9 5v2h6.59L4 18.59 5.41 20 17 8.41V15h2V5z"}),"CallMade"),$4=W1(t("path",{d:"M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"}),"FileDownload"),B4=W1(t("path",{d:"M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"}),"FileUpload"),_4=W1(t("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM7 13.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"}),"Pending"),F4=W1(t("path",{d:"M12 5.99 19.53 19H4.47L12 5.99M12 2 1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),V4=W1(t("path",{d:"M19 9h-2v6.59L5.41 4 4 5.41 15.59 17H9v2h10V9z"}),"SouthEast");function M4(e,n){j0(2,arguments);var a=D0(n);return Z4(e,-a)}const Me=p("div")(()=>({display:"flex"})),L4=p("div")(()=>({display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%"})),z4=p("div")(()=>({display:"flex",flexDirection:"column"})),H4=p("span")(({theme:e})=>({fontSize:e.typography.h1.fontSize,textOverflow:"ellipsis",whiteSpace:"nowrap"})),z2=p("span")(({theme:e})=>({fontSize:e.fontSizes.smallBody,fontWeight:"normal"})),R3=p(z2)(({theme:e})=>({color:e.palette.neutral.dark})),N4=p(O0)(({theme:e})=>({marginLeft:e.spacing(-1.5)})),W4=p("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),U4=p("div")(({theme:e})=>({padding:e.spacing(2.5,5),display:"flex",flexDirection:"column",alignItems:"start"})),k3=p("span")(({theme:e})=>({margin:0,width:"100%",fontSize:e.fontSizes.mainHeader,fontWeight:"bold",display:"flex",justifyContent:"space-between",alignItems:"center",gap:e.spacing(2)})),q4=p("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.divider,height:"1px"})),G4=p("div")(({theme:e})=>({padding:e.spacing(0,4)})),K4=p(Ke)(({theme:e})=>({textTransform:"none",fontSize:e.fontSizes.bodySize,flexGrow:1,flexBasis:0,[e.breakpoints.down("md")]:{paddingLeft:e.spacing(1),paddingRight:e.spacing(1)},[e.breakpoints.up("md")]:{minWidth:160}})),J4=e=>e.reduce((n,a)=>a.enabled?n+1:n,0),Y4=p(n2)(({theme:e})=>({marginTop:e.spacing(3)})),Q4=p("p",{shouldForwardProp:e=>e!=="warning"})(({theme:e,warning:n})=>({color:n?e.palette.error.dark:e.palette.text.primary,textAlign:"center"})),X4=({environment:e,warnEnabledToggles:n})=>{const a=d.useMemo(()=>[{id:"Icon",width:"1%",Cell:({row:{original:h}})=>t($0,{environment:h})},{Header:"Name",accessor:"name",Cell:i1},{Header:"Type",accessor:"type",Cell:i1},{Header:"Toggles enabled",accessor:"projectEnabledToggleCount",Cell:({value:h})=>t(i1,{children:t(Q4,{warning:h>0,children:h===1?"1 toggle":`${h} toggles`})}),align:"center"}],[n]),{getTableProps:r,getTableBodyProps:o,headerGroups:i,rows:c,prepareRow:l}=r1.useTable({columns:a,data:[e],disableSortBy:!0});return s(Y4,{...r(),rowHeight:"compact",children:[t(a2,{headerGroups:i}),t(r2,{...o(),children:c.map(h=>(l(h),t(o2,{hover:!0,...h.getRowProps(),children:h.cells.map(u=>t(i2,{...u.getCellProps(),children:u.render("Cell")}))})))})]})},ea=p("p")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1.5)})),ta=p(B0)(()=>({width:"100%"})),na=({environment:e,open:n,setOpen:a,onConfirm:r})=>{const[o,i]=d.useState("");return d.useEffect(()=>{i("")},[n]),s(ke,{title:"Hide environment and disable feature toggles?",open:n,primaryButtonText:"Hide environment and disable feature toggles",disabledPrimaryButton:(e==null?void 0:e.name)!==o,secondaryButtonText:"Close",onClick:r,onClose:()=>{a(!1)},children:[s(U1,{severity:"error",children:[t("strong",{children:"Danger!"})," Hiding an environment will disable all the feature toggles that are enabled in this environment and it can impact client applications connected to the environment."]}),t(X4,{environment:e}),s(ea,{children:["In order to hide this environment, please enter the id of the environment in the textfield below:"," ",t("strong",{children:e==null?void 0:e.name})]}),t(ta,{label:"Environment name",value:o,onChange:c=>i(c.target.value)})]})},aa=e=>{const{data:n,error:a,mutate:r}=ie(q1(`api/admin/environments/project/${e}`),ra),o=d.useMemo(()=>n||[],[n]),i=d.useCallback(async()=>{await r()},[r]);return{environments:o,refetchEnvironments:i,loading:!a&&!n,error:a}},ra=async e=>(await fetch(e).then(G1("Environments")).then(a=>a.json())).environments.sort((a,r)=>a.sortOrder-r.sortOrder),oa=p(U1)(({theme:e})=>({marginBottom:e.spacing(4)})),ia=p("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",[e.breakpoints.down("sm")]:{justifyContent:"center"}})),sa=p(Ct)(({theme:e})=>({maxWidth:"400px",marginBottom:e.spacing(2)})),Qt=()=>{const e=Q("projectId"),n=k1(e);T1(`Project environments – ${n}`);const{setToastData:a,setToastApiError:r}=u1(),{environments:o,loading:i,error:c,refetchEnvironments:l}=aa(e),{project:h,refetch:u}=P1(e),{removeEnvironmentFromProject:g,addEnvironmentToProject:f}=s2(),[m,b]=d.useState(),[S,x]=d.useState(!1),{isOss:Z}=l1(),v=d.useMemo(()=>o.map(I=>({...I,projectVisible:h==null?void 0:h.environments.includes(I.name)})),[o,h==null?void 0:h.environments]),j=()=>{l(),u()},H=()=>t(sa,{onClick:j,text:"Error fetching environments"}),z=I=>`Got an API error when trying to set the environment as ${I?"visible":"hidden"}`,U=async I=>{if(I.projectVisible){if(J4(v)>1){b(I),x(!0);return}a({title:"One environment must be visible",text:"You must always have at least one visible environment per project",type:"error"})}else try{await f(e,I.name),j(),a({title:"Environment set as visible",text:"Environment successfully set as visible.",type:"success"})}catch{r(z(!0))}},w=async()=>{if(m)try{await g(e,m.name),j(),a({title:"Environment set as hidden",text:"Environment successfully set as hidden.",type:"success"})}catch{r(z(!1))}finally{x(!1)}},D=I=>Z()&&I==="default",O=d.useMemo(()=>[{Header:"Name",accessor:"name",Cell:({row:{original:I}})=>t(_0,{environment:I})},{Header:"Type",accessor:"type",Cell:Ee},{Header:"Project API tokens",accessor:I=>I.projectApiTokenCount===1?"1 token":`${I.projectApiTokenCount} tokens`,Cell:i1},{Header:"Visible in project",accessor:"enabled",align:"center",width:1,Cell:({row:{original:I}})=>t(J2,{children:t(Y2,{tooltip:I.projectVisible?"Hide environment and disable feature toggles":"Make it visible",size:"medium",disabled:D(I.name),projectId:e,permission:E1,checked:I.projectVisible,onChange:()=>U(I)})}),disableGlobalFilter:!0}],[v]),{getTableProps:F,getTableBodyProps:N,headerGroups:_,rows:K,prepareRow:Y,state:{globalFilter:y},setGlobalFilter:T}=r1.useTable({columns:O,data:v,disableSortBy:!0},r1.useGlobalFilter),V=t(s1,{title:`Environments (${K.length})`,actions:t(x1,{initialValue:y,onChange:T})});return t(p1,{header:V,isLoading:i,children:s(ia,{children:[t(C,{condition:Boolean(c),show:H()}),s(oa,{severity:"info",children:[t("strong",{children:"Important!"})," In order for your application to retrieve configured activation strategies for a specific environment, the application must use an environment specific API token. You can look up the environment-specific"," ",t(R1,{to:"/admin/api",children:"API tokens here"}),".",t("br",{}),t("br",{}),"Your administrator can configure an environment-specific API token to be used in the SDK. If you are an administrator you can ",t(R1,{to:"/admin/api",children:"create a new API token here"}),"."]}),t(se,{value:y,children:s(n2,{...F(),rowHeight:"compact",children:[t(a2,{headerGroups:_}),t(r2,{...N(),children:K.map(I=>(Y(I),t(o2,{hover:!0,...I.getRowProps(),children:I.cells.map(W=>t(i2,{...W.getCellProps(),children:W.render("Cell")}))})))})]})}),t(C,{condition:K.length===0,show:t(C,{condition:(y==null?void 0:y.length)>0,show:s(y1,{children:["No environments found matching “",y,"”"]}),elseShow:t(y1,{children:"No environments available. Get started by adding one."})})}),t(na,{environment:m,open:S,setOpen:x,onConfirm:w})]})})},ca={id:"archivedAt"},la=({projectId:e})=>{const{archivedFeatures:n,loading:a,refetchArchived:r}=F0(e),{value:o,setValue:i}=c2(`${e}:ProjectFeaturesArchiveTable`,ca);return t(V0,{title:"Project archive",archivedFeatures:n||[],loading:a,storedParams:o,setStoredParams:i,refetch:r,projectId:e})},da=()=>{const e=Q("projectId"),n=k1(e);return T1(`Project archive – ${n}`),t(la,{projectId:e})},pa=(e=[])=>{var a;const n=d.useRef(e);return(e==null?void 0:e.join(""))!==((a=n.current)==null?void 0:a.join(""))&&(n.current=e),n.current},ua=p(A)(()=>({mx:"auto",...C1})),ha=({projectId:e,featureName:n,environmentName:a,value:r,onToggle:o})=>{const[i,c,l]=M0(r);return t(ua,{children:t(Y2,{checked:r,environmentId:a,projectId:e,permission:L0,inputProps:{"aria-label":a},onClick:()=>{c(!i),o(e,n,a,!i).catch(l)},disabled:i!==r})},`${n}-${a}`)};var d3={},ma=le;Object.defineProperty(d3,"__esModule",{value:!0});var Xt=d3.default=void 0,ga=ma(ce()),fa=de,va=(0,ga.default)((0,fa.jsx)("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM12 17.5 6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z"}),"Archive");Xt=d3.default=va;var p3={},ya=le;Object.defineProperty(p3,"__esModule",{value:!0});var e0=p3.default=void 0,ba=ya(ce()),Ca=de,Sa=(0,ba.default)((0,Ca.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm4.2 14.2L11 13V7h1.5v5.2l4.5 2.7-.8 1.3z"}),"WatchLater");e0=p3.default=Sa;const wa=p(A)(({theme:e})=>({display:"flex",justifyContent:"center",paddingRight:e.spacing(2)})),xa=({projectId:e,row:n,onOpenArchiveDialog:a,onOpenStaleDialog:r})=>{const[o,i]=d.useState(null),{original:{name:c,stale:l}}=n,h=Boolean(o),u=b=>{i(b.currentTarget)},g=()=>{i(null)},f=`feature-${c}-actions`,m=`${f}-menu`;return s(wa,{children:[t(K1,{title:"Feature toggle actions",arrow:!0,describeChild:!0,children:t(B1,{id:f,"aria-controls":h?m:void 0,"aria-haspopup":"true","aria-expanded":h?"true":void 0,onClick:u,type:"button",children:t(z0,{})})}),t(l2,{id:m,anchorEl:o,open:h,onClose:g,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:b=>({borderRadius:`${b.shape.borderRadius}px`,padding:b.spacing(1,1.5)})},children:s(d2,{"aria-labelledby":f,children:[t(X1,{projectId:e,permission:Q2,children:({hasAccess:b})=>s(H1,{sx:k2,onClick:g,disabled:!b,component:R1,to:`/projects/${e}/features/${c}/strategies/copy`,children:[t(ee,{children:t(H0,{})}),t(te,{children:t(B,{variant:"body2",children:"Copy"})})]})}),t(X1,{projectId:e,permission:St,children:({hasAccess:b})=>s(H1,{sx:k2,onClick:()=>{a(c),g()},disabled:!b,children:[t(ee,{children:t(Xt,{})}),t(te,{children:t(B,{variant:"body2",children:"Archive"})})]})}),t(X1,{projectId:e,permission:p2,children:({hasAccess:b})=>s(H1,{sx:k2,onClick:()=>{g(),r({featureId:c,stale:l===!0})},disabled:!b,children:[t(ee,{children:t(e0,{})}),t(te,{children:s(B,{variant:"body2",children:[l?"Un-mark":"Mark"," as stale"]})})]})})]})})]})};var u3={},Ta=le;Object.defineProperty(u3,"__esModule",{value:!0});var t0=u3.default=void 0,Aa=Ta(ce()),Ea=de,Ra=(0,Aa.default)((0,Ea.jsx)("path",{d:"M5.33 20H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h1.33c1.1 0 2 .9 2 2v12c0 1.1-.89 2-2 2zM22 18V6c0-1.1-.9-2-2-2h-1.33c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2H20c1.11 0 2-.9 2-2zm-7.33 0V6c0-1.1-.9-2-2-2h-1.33c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h1.33c1.1 0 2-.9 2-2z"}),"ViewWeek");t0=u3.default=Ra;const ka=p(A)(()=>({...C1,justifyContent:"center"})),Pa=p(B1)(({theme:e})=>({margin:e.spacing(-1,0)})),Ia=p(A)(({theme:e})=>({...C1,justifyContent:"space-between",padding:e.spacing(1,1,0,4)})),Za=p(H1)(({theme:e})=>({padding:e.spacing(0,2),margin:e.spacing(0,2),borderRadius:e.shape.borderRadius})),P3=p(wt)(({theme:e})=>({"&.MuiDivider-root.MuiDivider-fullWidth":{margin:e.spacing(.75,0)}})),ja=p(X2)(({theme:e})=>({padding:e.spacing(.75,1)})),Da={favorite:"Favorite"},Oa=({allColumns:e,staticColumns:n=[],dividerBefore:a=[],dividerAfter:r=[],isCustomized:o=!1,setHiddenColumns:i})=>{const[c,l]=d.useState(null),h=h1(),u=g1(h.breakpoints.down("sm")),g=g1(h.breakpoints.down("md")),f=g1(h.breakpoints.down("lg"));d.useEffect(()=>{if(o)return;const v=(j,H=0)=>{const z=e.filter(({id:w})=>w.startsWith("environments.")!==!1).map(({id:w})=>w).slice(0,H),U=e.map(({id:w})=>w).filter(w=>!j.includes(w)).filter(w=>!n.includes(w)).filter(w=>!z.includes(w));i(U)};if(u)return v(["createdAt"]);if(g)return v(["createdAt"],1);if(f)return v(["type","createdAt"],1);v(["lastSeenAt","type","createdAt"],3)},[u,g,f]);const m=v=>{l(v.currentTarget)},b=()=>{l(null)},S=Boolean(c),x="columns-menu",Z=`columns-menu-list-${x}`;return s(ka,{children:[t(K1,{title:"Select columns",arrow:!0,describeChild:!0,children:t(Pa,{id:x,"aria-controls":S?Z:void 0,"aria-haspopup":"true","aria-expanded":S?"true":void 0,onClick:m,type:"button",size:"large","data-loading":!0,children:t(t0,{})})}),s(l2,{id:Z,open:S,anchorEl:c,onClose:b,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},disableScrollLock:!0,PaperProps:{sx:v=>({borderRadius:v.shape.borderRadius,paddingBottom:v.spacing(2)})},children:[s(Ia,{children:[t(B,{variant:"body2",children:t("strong",{children:"Columns"})}),t(B1,{onClick:b,children:t(N0,{})})]}),t(d2,{children:e.filter(({hideInMenu:v})=>!v).map(v=>[t(C,{condition:a.includes(v.id),show:t(P3,{})}),s(Za,{onClick:()=>v.toggleHidden(v.isVisible),disabled:n.includes(v.id),children:[t(ee,{children:t(ja,{edge:"start",checked:v.isVisible,disableRipple:!0,inputProps:{"aria-labelledby":v.id},size:"medium"})}),t(te,{id:v.id,primary:t(B,{variant:"body2",children:t(C,{condition:Boolean(typeof v.Header=="string"&&v.Header),show:()=>t(G,{children:v.Header}),elseShow:()=>Da[v.id]||v.id})})})]}),t(C,{condition:r.includes(v.id),show:t(P3,{})})])})]})]})},$a=xt()(e=>({container:{boxShadow:"none",marginLeft:"1rem",minHeight:"100%",width:"calc(100% - 1rem)",position:"relative",[e.breakpoints.down("md")]:{marginLeft:"0",paddingBottom:"4rem",width:"inherit"}}})),Ba=({projectId:e,features:n})=>{const{refetch:a}=P1(e),[r,o]=d.useState(!1),{trackEvent:i}=I1();return s(G,{children:[t(X1,{projectId:e,permission:St,children:({hasAccess:l})=>t(v1,{disabled:!l||r,startIcon:t(i4,{}),variant:"outlined",size:"small",onClick:()=>o(!0),children:"Archive"})}),t(Kt,{projectId:e,featureIds:n,onConfirm:async()=>{o(!1),await a(),i("batch_operations",{props:{eventType:"features archived"}})},isOpen:r,onClose:()=>o(!1)})]})},Le="selection-actions-menu",_a=({projectId:e,data:n})=>{const{refetch:a}=P1(e),[r,o]=d.useState(null),{staleFeatures:i}=s2(),{setToastData:c,setToastApiError:l}=u1(),{trackEvent:h}=I1(),u=Boolean(r),g=n.map(({name:v})=>v),f=v=>{o(v.currentTarget)},m=()=>{o(null)},b=n.some(({stale:v})=>v===!0),S=n.some(({stale:v})=>v===!1),x=async()=>{try{m(),await i(e,g),await a(),c({title:"State updated",text:"Feature toggles marked as stale",type:"success"}),h("batch_operations",{props:{eventType:"features staled"}})}catch(v){l(f1(v))}},Z=async()=>{try{m(),await i(e,g,!1),await a(),c({title:"State updated",text:"Feature toggles unmarked as stale",type:"success"}),h("batch_operations",{props:{eventType:"features unstaled"}})}catch(v){l(f1(v))}};return s(G,{children:[t(K1,{title:"More bulk actions",arrow:!0,describeChild:!0,children:t(B1,{id:Le,"aria-controls":u?Le:void 0,"aria-haspopup":"true","aria-expanded":u?"true":void 0,onClick:f,type:"button","data-testid":W0,children:t(v4,{})})}),t(l2,{id:`${Le}-menu`,anchorEl:r,open:u,onClose:m,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:v=>({borderRadius:`${v.shape.borderRadius}px`,padding:v.spacing(1,1.5)})},children:t(d2,{"aria-labelledby":`${Le}-menu`,children:t(X1,{projectId:e,permission:p2,children:({hasAccess:v})=>s(G,{children:[t(C,{condition:S,show:()=>s(H1,{onClick:x,disabled:!v,sx:{borderRadius:j=>`${j.shape.borderRadius}px`},children:[t(ee,{children:t(E3,{})}),t(te,{children:t(B,{variant:"body2",children:"Mark as stale"})})]})}),t(C,{condition:b,show:()=>s(H1,{onClick:Z,disabled:!v,sx:{borderRadius:j=>`${j.shape.borderRadius}px`},children:[t(ee,{children:t(E3,{})}),t(te,{children:t(B,{variant:"body2",children:"Un-mark as stale"})})]})})]})})})})]})},Fa=p("section")(({theme:e})=>({["& > *"]:{margin:e.spacing(1,0)}})),I3="manage-tags-form",Z3=(e,n)=>[...e,...e.some(a=>a.value===n.value&&a.type===n.type)?[]:[n]],j3=(e,n)=>e.filter(a=>!(a.value===n.value&&a.type===n.type)),Va=(e,n)=>{switch(n.type){case"add":return{...e,addedTags:Z3(e.addedTags,n.payload),removedTags:j3(e.removedTags,n.payload)};case"remove":return{...e,addedTags:j3(e.addedTags,n.payload),removedTags:Z3(e.removedTags,n.payload)};case"clear":return{addedTags:[],removedTags:n.payload};default:return e}},D3={name:"",description:"",icon:""},Ma=({open:e,initialValues:n,initialIndeterminateValues:a,onCancel:r,onSubmit:o})=>{const{tagTypes:i,loading:c}=U0(),[l,h]=d.useState(D3),[u,g]=d.useState([]),[f,m]=d.useState([]),{tags:b,refetch:S}=s4(l.name),{createTag:x}=Jt(),Z=b.map(({value:O})=>({title:O})),[v,j]=d.useReducer(Va,{addedTags:[],removedTags:[]}),H=(O=i.length>0?i[0]:D3)=>{h(O);const F=a.filter(({type:N})=>N===O.name);g(n.filter(({type:N})=>N===O.name).filter(({type:N,value:_})=>!F.some(K=>K.value===_&&K.type===N)).map(({value:N})=>({title:N}))),m(F.map(({value:N})=>({title:N}))),j({type:"clear",payload:[]})};d.useEffect(()=>{i.length>0&&H()},[c]);const z=(O,F)=>{F!=null&&typeof F!="string"&&(O.preventDefault(),H(F))},U=(O,F)=>x({value:O,type:F}).then(async()=>{await S(),g(N=>[...N,{title:O}]),j({type:"add",payload:{value:O,type:F}})}),w=(O,F,N,_)=>{N==="selectOption"?F.forEach(K=>{if(typeof K!="string"&&typeof K.inputValue=="string"&&K.inputValue&&K.title.startsWith("Create new value"))return U(K.inputValue,l.name);g(F),m(Y=>Y.filter(({title:y})=>y!==K.title)),_!=null&&_.option&&j({type:"add",payload:{value:_.option.title,type:l.name}})}):N==="clear"?(g([]),j({type:"clear",payload:n})):N==="removeOption"&&(g(F),_!=null&&_.option&&j({type:"remove",payload:{value:_.option.title,type:l.name}}))},D=()=>{H(),r()};return s(ke,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update tags to feature toggle",onClick:()=>o(v),disabledPrimaryButton:v.addedTags.length===0&&v.removedTags.length===0,onClose:D,formId:I3,children:[t(B,{paragraph:!0,sx:{marginBottom:O=>O.spacing(2.5)},children:"Tags allow you to group features together"}),t("form",{id:I3,onSubmit:()=>o(v),children:s(Fa,{children:[t(c4,{options:i,disabled:c||i.length===0,value:l,onChange:z},c?"loading":i.length),t(C,{condition:!c&&i.length===0,show:s(B,{variant:"body1",children:["No"," ",t(e3,{component:R1,to:"/tag-types",children:"tag types"})," ","available."]}),elseShow:t(l4,{disabled:c,options:Z,existingTags:n,indeterminateOptions:f,tagType:l,selectedOptions:u,onChange:w})})]})})]})},La=({projectId:e,data:n})=>{const{bulkUpdateTags:a}=Jt(),{refetch:r}=P1(e),{setToastData:o,setToastApiError:i}=u1(),{trackEvent:c}=I1(),[l,h]=d.useState(!1),[u,g]=d.useMemo(()=>{const m=n.flatMap(({tags:S})=>S||[]).reduce((S,x)=>[...S,...S.some(Z=>Z.type===x.type&&Z.value===x.value)?[]:[x]],[]),b=m.filter(S=>!n.every(({tags:x})=>x==null?void 0:x.some(Z=>Z.type===S.type&&Z.value===S.value)));return[m,b]},[n]);return s(G,{children:[t(X1,{projectId:e,permission:p2,children:({hasAccess:m})=>t(v1,{disabled:!m||l,startIcon:t(q0,{}),variant:"outlined",size:"small",onClick:()=>h(!0),children:"Tags"})}),t(Ma,{open:l,onCancel:()=>h(!1),onSubmit:async({addedTags:m,removedTags:b})=>{const S=n.map(({name:Z})=>Z),x={features:S,tags:{addedTags:m,removedTags:b}};try{await a(x),r();const Z=m.length?`Added tags: ${m.map(({type:j,value:H})=>`${j}:${H}`).join(", ")}.`:"",v=b.length?`Removed tags: ${b.map(({type:j,value:H})=>`${j}:${H}`).join(", ")}.`:"";o({title:"Tags updated",text:`${S.length} feature toggles updated. ${Z} ${v}`,type:"success",autoHideDuration:12e3}),c("batch_operations",{props:{eventType:"tags updated"}})}catch(Z){i(f1(Z))}h(!1)},initialValues:u,initialIndeterminateValues:g},n.length)]})},za=({selectedIds:e,data:n,projectId:a})=>{var g,f;const{uiConfig:r}=l1(),[o,i]=d.useState(!1),{trackEvent:c}=I1(),l=d.useMemo(()=>n.filter(m=>e.includes(m.name)),[n,e]),h=d.useMemo(()=>{const m=l.flatMap(b=>b.environments).map(b=>b==null?void 0:b.name).filter(b=>b!==void 0);return Array.from(new Set(m))},[l]),u=()=>{c("batch_operations",{props:{eventType:"features exported"}})};return s(G,{children:[t(Ba,{projectId:a,features:e}),t(C,{condition:Boolean((g=r==null?void 0:r.flags)==null?void 0:g.featuresExportImport),show:t(v1,{startIcon:t($4,{}),variant:"outlined",size:"small",onClick:()=>i(!0),children:"Export"})}),t(La,{projectId:a,data:l}),t(_a,{projectId:a,data:l}),t(C,{condition:Boolean((f=r==null?void 0:r.flags)==null?void 0:f.featuresExportImport),show:t(Tt,{showExportDialog:o,data:l,onClose:()=>i(!1),environments:h,onConfirm:u})})]})},Ha=p(At)(()=>({whiteSpace:"nowrap"})),Na=p("div",{shouldForwardProp:e=>e!=="hasWarning"})(({theme:e,hasWarning:n})=>({flexGrow:0,...C1,justifyContent:"center",...n&&{"::before":{content:'""',display:"block",width:e.spacing(2)}}})),ze=["Select","Actions","name","favorite"],Wa={id:"createdAt"},Ua=({features:e,loading:n,environments:a=[]})=>{var E,$;const{classes:r}=$a(),o=h1(),i=g1(o.breakpoints.down("md")),[c,l]=d.useState({open:!1,featureId:"",environmentName:""}),[h,u]=d.useState({}),[g,f]=d.useState(),m=Q("projectId"),{value:b,setValue:S}=c2(`${m}:FeatureToggleListTable:v1`,Wa),{value:x,setValue:Z}=G0(),v=_1(),[j,H]=t3(),{isChangeRequestConfigured:z}=u2(m),U=pa(n?["a","b","c"]:a),{refetch:w}=P1(m),{setToastData:D,setToastApiError:O}=u1(),{isFavoritesPinned:F,sortTypes:N,onChangeIsFavoritePinned:_}=K0(j.has("favorites")?j.get("favorites")==="true":x.favorites),{toggleFeatureEnvironmentOn:K,toggleFeatureEnvironmentOff:Y}=J0(),{favorite:y,unfavorite:T}=Y0(),{onChangeRequestToggle:V,onChangeRequestToggleClose:I,onChangeRequestToggleConfirm:W,changeRequestDialogDetails:k}=d4(m),[X,c1]=d.useState(!1),{uiConfig:a1}=l1(),m1=d.useCallback(async(P,R,M,L)=>{if(z(M))throw V(R,M,L),new Error("Additional approval required");try{L?await K(P,R,M):await Y(P,R,M),w()}catch(e1){const O1=f1(e1);throw O1===p4?l({open:!0,featureId:R,environmentName:M}):O(O1),e1}D({type:"success",title:"Updated toggle status",text:"Successfully updated toggle status."}),w()},[Y,K,z]),j1=d.useCallback(async P=>{P!=null&&P.favorite?await T(m,P.name):await y(m,P.name),w()},[m,w]),Oe=d.useMemo(()=>e.some(P=>{var R;return(R=P==null?void 0:P.tags)==null?void 0:R.length}),[e]),b1=d.useMemo(()=>{var P;return[...(P=a1==null?void 0:a1.flags)!=null&&P.bulkOperations?[{id:"Select",Header:({getToggleAllRowsSelectedProps:R})=>t(X2,{...R()}),Cell:({row:R})=>{var M;return t(Q0,{...(M=R==null?void 0:R.getToggleRowSelectedProps)==null?void 0:M.call(R)})},maxWidth:50,disableSortBy:!0,hideInMenu:!0}]:[],{id:"favorite",Header:t(X0,{isActive:F,onClick:_}),accessor:"favorite",Cell:({row:{original:R}})=>t(en,{value:R==null?void 0:R.favorite,onClick:()=>j1(R)}),maxWidth:50,disableSortBy:!0,hideInMenu:!0},{Header:"Seen",accessor:"lastSeenAt",Cell:Et,sortType:"date",align:"center",maxWidth:80},{Header:"Type",accessor:"type",Cell:Rt,align:"center",maxWidth:80},{Header:"Name",accessor:"name",Cell:({value:R})=>t(kt,{title:R,to:`/projects/${m}/features/${R}`}),minWidth:100,sortType:"alphanumeric",searchable:!0},...Oe?[{id:"tags",Header:"Tags",accessor:R=>{var M;return((M=R.tags)==null?void 0:M.map(({type:L,value:e1})=>`${L}:${e1}`).join(`
1
+ import{c as W1,j as t,cO as j0,cP as D0,s as p,cj as O0,cg as Ke,g as n2,r as d,d$ as $0,l as i1,d as r1,f as s,S as a2,h as r2,i as o2,k as i2,bS as B0,a_ as ke,A as U1,aR as ie,aS as q1,aT as G1,e0 as Ct,aI as Q,e1 as k1,bL as T1,a2 as u1,ca as P1,au as s2,H as l1,e2 as _0,R as Ee,cV as J2,bC as Y2,e3 as E1,al as s1,V as x1,ak as p1,C,aO as R1,X as se,W as y1,ce as F0,K as c2,e4 as V0,a as A,e5 as C1,e6 as M0,bD as L0,cB as ce,cC as le,cD as de,b9 as K1,m as B1,e7 as z0,P as l2,du as d2,e8 as X1,ck as Q2,a8 as H1,e9 as k2,bd as ee,dN as H0,bf as te,T as B,cm as St,aN as p2,af as wt,c1 as X2,u as h1,N as g1,ea as N0,F as G,eb as xt,as as I1,a9 as v1,ec as W0,a4 as f1,bG as U0,bE as e3,cn as q0,ed as Tt,ds as At,bu as G0,ar as _1,L as t3,aV as u2,ee as K0,bB as J0,ch as Y0,ef as Q0,eg as X0,eh as en,ei as Et,ej as Rt,O as kt,ek as tn,c6 as h2,Q as m2,d5 as nn,cf as an,bJ as Pt,Y as g2,el as rn,D as It,aQ as on,cb as sn,M as Zt,em as cn,ah as F1,en as jt,ag as Dt,eo as Ot,ai as ln,ep as dn,eq as pn,aU as $t,er as n3,a1 as un,es as Bt,et as hn,eu as mn,ev as gn,ew as fn,by as _t,ex as Ft,ey as Vt,e as Pe,U as f2,ez as vn,eA as yn,aK as bn,bk as Cn,eB as Ie,eC as Mt,eD as Sn,aB as pe,aC as J1,aL as Z1,aD as ue,aG as he,aH as me,eE as wn,c7 as Ae,bI as Lt,eF as zt,eG as xn,bj as ge,aq as Ht,b1 as a3,b0 as r3,aZ as o3,eH as Tn,eI as An,ac as Je,eJ as En,eK as Rn,eL as kn,df as v2,bq as Pn,c5 as In,dn as Ye,eM as Zn,co as i3,eN as y2,bO as ne,aM as N1,aP as s3,aY as c3,aA as $1,av as Nt,eO as jn,ad as A3,eP as Dn,de as Ve,eQ as On,eR as $n,cG as Bn,cE as _n,dI as Fn,eS as Vn,eT as Mn,eU as Ln,bM as Ze,bN as n1,eV as zn,c4 as Wt,d_ as Ut,Z as l3,ax as Hn,eW as Nn,cZ as Wn,eX as Un,eY as qn,eZ as Gn,ci as qt,e_ as Kn,db as Gt,e$ as ae,f0 as J,f1 as Jn,f2 as Yn,f3 as Qn,f4 as Xn,f5 as e4,di as t4,f6 as n4,f7 as a4,f8 as r4,f9 as o4}from"./index-99d4171f.js";import{A as i4,e as Kt,W as E3,c as s4,b as Jt,T as c4,d as l4,u as d4,E as p4,V as u4,a as h4,g as m4,C as g4,U as f4}from"./FeatureArchiveDialog-0d7ae6c3.js";import{M as v4,m as y4,h as b4,b as C4,c as S4,d as w4,e as x4,E as T4,f as A4,u as E4,a as R4,R as k4,C as P4,A as I4,B as Yt}from"./useProjectRole-dba93dda.js";import{a as Z4}from"./index-c65a88d1.js";import{E as j4}from"./Error-38b8cdc0.js";const D4=W1(t("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"}),"ArrowUpward"),O4=W1(t("path",{d:"M9 5v2h6.59L4 18.59 5.41 20 17 8.41V15h2V5z"}),"CallMade"),$4=W1(t("path",{d:"M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"}),"FileDownload"),B4=W1(t("path",{d:"M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"}),"FileUpload"),_4=W1(t("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM7 13.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"}),"Pending"),F4=W1(t("path",{d:"M12 5.99 19.53 19H4.47L12 5.99M12 2 1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),V4=W1(t("path",{d:"M19 9h-2v6.59L5.41 4 4 5.41 15.59 17H9v2h10V9z"}),"SouthEast");function M4(e,n){j0(2,arguments);var a=D0(n);return Z4(e,-a)}const Me=p("div")(()=>({display:"flex"})),L4=p("div")(()=>({display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%"})),z4=p("div")(()=>({display:"flex",flexDirection:"column"})),H4=p("span")(({theme:e})=>({fontSize:e.typography.h1.fontSize,textOverflow:"ellipsis",whiteSpace:"nowrap"})),z2=p("span")(({theme:e})=>({fontSize:e.fontSizes.smallBody,fontWeight:"normal"})),R3=p(z2)(({theme:e})=>({color:e.palette.neutral.dark})),N4=p(O0)(({theme:e})=>({marginLeft:e.spacing(-1.5)})),W4=p("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),U4=p("div")(({theme:e})=>({padding:e.spacing(2.5,5),display:"flex",flexDirection:"column",alignItems:"start"})),k3=p("span")(({theme:e})=>({margin:0,width:"100%",fontSize:e.fontSizes.mainHeader,fontWeight:"bold",display:"flex",justifyContent:"space-between",alignItems:"center",gap:e.spacing(2)})),q4=p("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.divider,height:"1px"})),G4=p("div")(({theme:e})=>({padding:e.spacing(0,4)})),K4=p(Ke)(({theme:e})=>({textTransform:"none",fontSize:e.fontSizes.bodySize,flexGrow:1,flexBasis:0,[e.breakpoints.down("md")]:{paddingLeft:e.spacing(1),paddingRight:e.spacing(1)},[e.breakpoints.up("md")]:{minWidth:160}})),J4=e=>e.reduce((n,a)=>a.enabled?n+1:n,0),Y4=p(n2)(({theme:e})=>({marginTop:e.spacing(3)})),Q4=p("p",{shouldForwardProp:e=>e!=="warning"})(({theme:e,warning:n})=>({color:n?e.palette.error.dark:e.palette.text.primary,textAlign:"center"})),X4=({environment:e,warnEnabledToggles:n})=>{const a=d.useMemo(()=>[{id:"Icon",width:"1%",Cell:({row:{original:h}})=>t($0,{environment:h})},{Header:"Name",accessor:"name",Cell:i1},{Header:"Type",accessor:"type",Cell:i1},{Header:"Toggles enabled",accessor:"projectEnabledToggleCount",Cell:({value:h})=>t(i1,{children:t(Q4,{warning:h>0,children:h===1?"1 toggle":`${h} toggles`})}),align:"center"}],[n]),{getTableProps:r,getTableBodyProps:o,headerGroups:i,rows:c,prepareRow:l}=r1.useTable({columns:a,data:[e],disableSortBy:!0});return s(Y4,{...r(),rowHeight:"compact",children:[t(a2,{headerGroups:i}),t(r2,{...o(),children:c.map(h=>(l(h),t(o2,{hover:!0,...h.getRowProps(),children:h.cells.map(u=>t(i2,{...u.getCellProps(),children:u.render("Cell")}))})))})]})},ea=p("p")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1.5)})),ta=p(B0)(()=>({width:"100%"})),na=({environment:e,open:n,setOpen:a,onConfirm:r})=>{const[o,i]=d.useState("");return d.useEffect(()=>{i("")},[n]),s(ke,{title:"Hide environment and disable feature toggles?",open:n,primaryButtonText:"Hide environment and disable feature toggles",disabledPrimaryButton:(e==null?void 0:e.name)!==o,secondaryButtonText:"Close",onClick:r,onClose:()=>{a(!1)},children:[s(U1,{severity:"error",children:[t("strong",{children:"Danger!"})," Hiding an environment will disable all the feature toggles that are enabled in this environment and it can impact client applications connected to the environment."]}),t(X4,{environment:e}),s(ea,{children:["In order to hide this environment, please enter the id of the environment in the textfield below:"," ",t("strong",{children:e==null?void 0:e.name})]}),t(ta,{label:"Environment name",value:o,onChange:c=>i(c.target.value)})]})},aa=e=>{const{data:n,error:a,mutate:r}=ie(q1(`api/admin/environments/project/${e}`),ra),o=d.useMemo(()=>n||[],[n]),i=d.useCallback(async()=>{await r()},[r]);return{environments:o,refetchEnvironments:i,loading:!a&&!n,error:a}},ra=async e=>(await fetch(e).then(G1("Environments")).then(a=>a.json())).environments.sort((a,r)=>a.sortOrder-r.sortOrder),oa=p(U1)(({theme:e})=>({marginBottom:e.spacing(4)})),ia=p("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",[e.breakpoints.down("sm")]:{justifyContent:"center"}})),sa=p(Ct)(({theme:e})=>({maxWidth:"400px",marginBottom:e.spacing(2)})),Qt=()=>{const e=Q("projectId"),n=k1(e);T1(`Project environments – ${n}`);const{setToastData:a,setToastApiError:r}=u1(),{environments:o,loading:i,error:c,refetchEnvironments:l}=aa(e),{project:h,refetch:u}=P1(e),{removeEnvironmentFromProject:g,addEnvironmentToProject:f}=s2(),[m,b]=d.useState(),[S,x]=d.useState(!1),{isOss:Z}=l1(),v=d.useMemo(()=>o.map(I=>({...I,projectVisible:h==null?void 0:h.environments.includes(I.name)})),[o,h==null?void 0:h.environments]),j=()=>{l(),u()},H=()=>t(sa,{onClick:j,text:"Error fetching environments"}),z=I=>`Got an API error when trying to set the environment as ${I?"visible":"hidden"}`,U=async I=>{if(I.projectVisible){if(J4(v)>1){b(I),x(!0);return}a({title:"One environment must be visible",text:"You must always have at least one visible environment per project",type:"error"})}else try{await f(e,I.name),j(),a({title:"Environment set as visible",text:"Environment successfully set as visible.",type:"success"})}catch{r(z(!0))}},w=async()=>{if(m)try{await g(e,m.name),j(),a({title:"Environment set as hidden",text:"Environment successfully set as hidden.",type:"success"})}catch{r(z(!1))}finally{x(!1)}},D=I=>Z()&&I==="default",O=d.useMemo(()=>[{Header:"Name",accessor:"name",Cell:({row:{original:I}})=>t(_0,{environment:I})},{Header:"Type",accessor:"type",Cell:Ee},{Header:"Project API tokens",accessor:I=>I.projectApiTokenCount===1?"1 token":`${I.projectApiTokenCount} tokens`,Cell:i1},{Header:"Visible in project",accessor:"enabled",align:"center",width:1,Cell:({row:{original:I}})=>t(J2,{children:t(Y2,{tooltip:I.projectVisible?"Hide environment and disable feature toggles":"Make it visible",size:"medium",disabled:D(I.name),projectId:e,permission:E1,checked:I.projectVisible,onChange:()=>U(I)})}),disableGlobalFilter:!0}],[v]),{getTableProps:F,getTableBodyProps:N,headerGroups:_,rows:K,prepareRow:Y,state:{globalFilter:y},setGlobalFilter:T}=r1.useTable({columns:O,data:v,disableSortBy:!0},r1.useGlobalFilter),V=t(s1,{title:`Environments (${K.length})`,actions:t(x1,{initialValue:y,onChange:T})});return t(p1,{header:V,isLoading:i,children:s(ia,{children:[t(C,{condition:Boolean(c),show:H()}),s(oa,{severity:"info",children:[t("strong",{children:"Important!"})," In order for your application to retrieve configured activation strategies for a specific environment, the application must use an environment specific API token. You can look up the environment-specific"," ",t(R1,{to:"/admin/api",children:"API tokens here"}),".",t("br",{}),t("br",{}),"Your administrator can configure an environment-specific API token to be used in the SDK. If you are an administrator you can ",t(R1,{to:"/admin/api",children:"create a new API token here"}),"."]}),t(se,{value:y,children:s(n2,{...F(),rowHeight:"compact",children:[t(a2,{headerGroups:_}),t(r2,{...N(),children:K.map(I=>(Y(I),t(o2,{hover:!0,...I.getRowProps(),children:I.cells.map(W=>t(i2,{...W.getCellProps(),children:W.render("Cell")}))})))})]})}),t(C,{condition:K.length===0,show:t(C,{condition:(y==null?void 0:y.length)>0,show:s(y1,{children:["No environments found matching “",y,"”"]}),elseShow:t(y1,{children:"No environments available. Get started by adding one."})})}),t(na,{environment:m,open:S,setOpen:x,onConfirm:w})]})})},ca={id:"archivedAt"},la=({projectId:e})=>{const{archivedFeatures:n,loading:a,refetchArchived:r}=F0(e),{value:o,setValue:i}=c2(`${e}:ProjectFeaturesArchiveTable`,ca);return t(V0,{title:"Project archive",archivedFeatures:n||[],loading:a,storedParams:o,setStoredParams:i,refetch:r,projectId:e})},da=()=>{const e=Q("projectId"),n=k1(e);return T1(`Project archive – ${n}`),t(la,{projectId:e})},pa=(e=[])=>{var a;const n=d.useRef(e);return(e==null?void 0:e.join(""))!==((a=n.current)==null?void 0:a.join(""))&&(n.current=e),n.current},ua=p(A)(()=>({mx:"auto",...C1})),ha=({projectId:e,featureName:n,environmentName:a,value:r,onToggle:o})=>{const[i,c,l]=M0(r);return t(ua,{children:t(Y2,{checked:r,environmentId:a,projectId:e,permission:L0,inputProps:{"aria-label":a},onClick:()=>{c(!i),o(e,n,a,!i).catch(l)},disabled:i!==r})},`${n}-${a}`)};var d3={},ma=le;Object.defineProperty(d3,"__esModule",{value:!0});var Xt=d3.default=void 0,ga=ma(ce()),fa=de,va=(0,ga.default)((0,fa.jsx)("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM12 17.5 6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z"}),"Archive");Xt=d3.default=va;var p3={},ya=le;Object.defineProperty(p3,"__esModule",{value:!0});var e0=p3.default=void 0,ba=ya(ce()),Ca=de,Sa=(0,ba.default)((0,Ca.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm4.2 14.2L11 13V7h1.5v5.2l4.5 2.7-.8 1.3z"}),"WatchLater");e0=p3.default=Sa;const wa=p(A)(({theme:e})=>({display:"flex",justifyContent:"center",paddingRight:e.spacing(2)})),xa=({projectId:e,row:n,onOpenArchiveDialog:a,onOpenStaleDialog:r})=>{const[o,i]=d.useState(null),{original:{name:c,stale:l}}=n,h=Boolean(o),u=b=>{i(b.currentTarget)},g=()=>{i(null)},f=`feature-${c}-actions`,m=`${f}-menu`;return s(wa,{children:[t(K1,{title:"Feature toggle actions",arrow:!0,describeChild:!0,children:t(B1,{id:f,"aria-controls":h?m:void 0,"aria-haspopup":"true","aria-expanded":h?"true":void 0,onClick:u,type:"button",children:t(z0,{})})}),t(l2,{id:m,anchorEl:o,open:h,onClose:g,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:b=>({borderRadius:`${b.shape.borderRadius}px`,padding:b.spacing(1,1.5)})},children:s(d2,{"aria-labelledby":f,children:[t(X1,{projectId:e,permission:Q2,children:({hasAccess:b})=>s(H1,{sx:k2,onClick:g,disabled:!b,component:R1,to:`/projects/${e}/features/${c}/strategies/copy`,children:[t(ee,{children:t(H0,{})}),t(te,{children:t(B,{variant:"body2",children:"Copy"})})]})}),t(X1,{projectId:e,permission:St,children:({hasAccess:b})=>s(H1,{sx:k2,onClick:()=>{a(c),g()},disabled:!b,children:[t(ee,{children:t(Xt,{})}),t(te,{children:t(B,{variant:"body2",children:"Archive"})})]})}),t(X1,{projectId:e,permission:p2,children:({hasAccess:b})=>s(H1,{sx:k2,onClick:()=>{g(),r({featureId:c,stale:l===!0})},disabled:!b,children:[t(ee,{children:t(e0,{})}),t(te,{children:s(B,{variant:"body2",children:[l?"Un-mark":"Mark"," as stale"]})})]})})]})})]})};var u3={},Ta=le;Object.defineProperty(u3,"__esModule",{value:!0});var t0=u3.default=void 0,Aa=Ta(ce()),Ea=de,Ra=(0,Aa.default)((0,Ea.jsx)("path",{d:"M5.33 20H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h1.33c1.1 0 2 .9 2 2v12c0 1.1-.89 2-2 2zM22 18V6c0-1.1-.9-2-2-2h-1.33c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2H20c1.11 0 2-.9 2-2zm-7.33 0V6c0-1.1-.9-2-2-2h-1.33c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h1.33c1.1 0 2-.9 2-2z"}),"ViewWeek");t0=u3.default=Ra;const ka=p(A)(()=>({...C1,justifyContent:"center"})),Pa=p(B1)(({theme:e})=>({margin:e.spacing(-1,0)})),Ia=p(A)(({theme:e})=>({...C1,justifyContent:"space-between",padding:e.spacing(1,1,0,4)})),Za=p(H1)(({theme:e})=>({padding:e.spacing(0,2),margin:e.spacing(0,2),borderRadius:e.shape.borderRadius})),P3=p(wt)(({theme:e})=>({"&.MuiDivider-root.MuiDivider-fullWidth":{margin:e.spacing(.75,0)}})),ja=p(X2)(({theme:e})=>({padding:e.spacing(.75,1)})),Da={favorite:"Favorite"},Oa=({allColumns:e,staticColumns:n=[],dividerBefore:a=[],dividerAfter:r=[],isCustomized:o=!1,setHiddenColumns:i})=>{const[c,l]=d.useState(null),h=h1(),u=g1(h.breakpoints.down("sm")),g=g1(h.breakpoints.down("md")),f=g1(h.breakpoints.down("lg"));d.useEffect(()=>{if(o)return;const v=(j,H=0)=>{const z=e.filter(({id:w})=>w.startsWith("environments.")!==!1).map(({id:w})=>w).slice(0,H),U=e.map(({id:w})=>w).filter(w=>!j.includes(w)).filter(w=>!n.includes(w)).filter(w=>!z.includes(w));i(U)};if(u)return v(["createdAt"]);if(g)return v(["createdAt"],1);if(f)return v(["type","createdAt"],1);v(["lastSeenAt","type","createdAt"],3)},[u,g,f]);const m=v=>{l(v.currentTarget)},b=()=>{l(null)},S=Boolean(c),x="columns-menu",Z=`columns-menu-list-${x}`;return s(ka,{children:[t(K1,{title:"Select columns",arrow:!0,describeChild:!0,children:t(Pa,{id:x,"aria-controls":S?Z:void 0,"aria-haspopup":"true","aria-expanded":S?"true":void 0,onClick:m,type:"button",size:"large","data-loading":!0,children:t(t0,{})})}),s(l2,{id:Z,open:S,anchorEl:c,onClose:b,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},disableScrollLock:!0,PaperProps:{sx:v=>({borderRadius:v.shape.borderRadius,paddingBottom:v.spacing(2)})},children:[s(Ia,{children:[t(B,{variant:"body2",children:t("strong",{children:"Columns"})}),t(B1,{onClick:b,children:t(N0,{})})]}),t(d2,{children:e.filter(({hideInMenu:v})=>!v).map(v=>[t(C,{condition:a.includes(v.id),show:t(P3,{})}),s(Za,{onClick:()=>v.toggleHidden(v.isVisible),disabled:n.includes(v.id),children:[t(ee,{children:t(ja,{edge:"start",checked:v.isVisible,disableRipple:!0,inputProps:{"aria-labelledby":v.id},size:"medium"})}),t(te,{id:v.id,primary:t(B,{variant:"body2",children:t(C,{condition:Boolean(typeof v.Header=="string"&&v.Header),show:()=>t(G,{children:v.Header}),elseShow:()=>Da[v.id]||v.id})})})]}),t(C,{condition:r.includes(v.id),show:t(P3,{})})])})]})]})},$a=xt()(e=>({container:{boxShadow:"none",marginLeft:"1rem",minHeight:"100%",width:"calc(100% - 1rem)",position:"relative",[e.breakpoints.down("md")]:{marginLeft:"0",paddingBottom:"4rem",width:"inherit"}}})),Ba=({projectId:e,features:n})=>{const{refetch:a}=P1(e),[r,o]=d.useState(!1),{trackEvent:i}=I1();return s(G,{children:[t(X1,{projectId:e,permission:St,children:({hasAccess:l})=>t(v1,{disabled:!l||r,startIcon:t(i4,{}),variant:"outlined",size:"small",onClick:()=>o(!0),children:"Archive"})}),t(Kt,{projectId:e,featureIds:n,onConfirm:async()=>{o(!1),await a(),i("batch_operations",{props:{eventType:"features archived"}})},isOpen:r,onClose:()=>o(!1)})]})},Le="selection-actions-menu",_a=({projectId:e,data:n})=>{const{refetch:a}=P1(e),[r,o]=d.useState(null),{staleFeatures:i}=s2(),{setToastData:c,setToastApiError:l}=u1(),{trackEvent:h}=I1(),u=Boolean(r),g=n.map(({name:v})=>v),f=v=>{o(v.currentTarget)},m=()=>{o(null)},b=n.some(({stale:v})=>v===!0),S=n.some(({stale:v})=>v===!1),x=async()=>{try{m(),await i(e,g),await a(),c({title:"State updated",text:"Feature toggles marked as stale",type:"success"}),h("batch_operations",{props:{eventType:"features staled"}})}catch(v){l(f1(v))}},Z=async()=>{try{m(),await i(e,g,!1),await a(),c({title:"State updated",text:"Feature toggles unmarked as stale",type:"success"}),h("batch_operations",{props:{eventType:"features unstaled"}})}catch(v){l(f1(v))}};return s(G,{children:[t(K1,{title:"More bulk actions",arrow:!0,describeChild:!0,children:t(B1,{id:Le,"aria-controls":u?Le:void 0,"aria-haspopup":"true","aria-expanded":u?"true":void 0,onClick:f,type:"button","data-testid":W0,children:t(v4,{})})}),t(l2,{id:`${Le}-menu`,anchorEl:r,open:u,onClose:m,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,PaperProps:{sx:v=>({borderRadius:`${v.shape.borderRadius}px`,padding:v.spacing(1,1.5)})},children:t(d2,{"aria-labelledby":`${Le}-menu`,children:t(X1,{projectId:e,permission:p2,children:({hasAccess:v})=>s(G,{children:[t(C,{condition:S,show:()=>s(H1,{onClick:x,disabled:!v,sx:{borderRadius:j=>`${j.shape.borderRadius}px`},children:[t(ee,{children:t(E3,{})}),t(te,{children:t(B,{variant:"body2",children:"Mark as stale"})})]})}),t(C,{condition:b,show:()=>s(H1,{onClick:Z,disabled:!v,sx:{borderRadius:j=>`${j.shape.borderRadius}px`},children:[t(ee,{children:t(E3,{})}),t(te,{children:t(B,{variant:"body2",children:"Un-mark as stale"})})]})})]})})})})]})},Fa=p("section")(({theme:e})=>({["& > *"]:{margin:e.spacing(1,0)}})),I3="manage-tags-form",Z3=(e,n)=>[...e,...e.some(a=>a.value===n.value&&a.type===n.type)?[]:[n]],j3=(e,n)=>e.filter(a=>!(a.value===n.value&&a.type===n.type)),Va=(e,n)=>{switch(n.type){case"add":return{...e,addedTags:Z3(e.addedTags,n.payload),removedTags:j3(e.removedTags,n.payload)};case"remove":return{...e,addedTags:j3(e.addedTags,n.payload),removedTags:Z3(e.removedTags,n.payload)};case"clear":return{addedTags:[],removedTags:n.payload};default:return e}},D3={name:"",description:"",icon:""},Ma=({open:e,initialValues:n,initialIndeterminateValues:a,onCancel:r,onSubmit:o})=>{const{tagTypes:i,loading:c}=U0(),[l,h]=d.useState(D3),[u,g]=d.useState([]),[f,m]=d.useState([]),{tags:b,refetch:S}=s4(l.name),{createTag:x}=Jt(),Z=b.map(({value:O})=>({title:O})),[v,j]=d.useReducer(Va,{addedTags:[],removedTags:[]}),H=(O=i.length>0?i[0]:D3)=>{h(O);const F=a.filter(({type:N})=>N===O.name);g(n.filter(({type:N})=>N===O.name).filter(({type:N,value:_})=>!F.some(K=>K.value===_&&K.type===N)).map(({value:N})=>({title:N}))),m(F.map(({value:N})=>({title:N}))),j({type:"clear",payload:[]})};d.useEffect(()=>{i.length>0&&H()},[c]);const z=(O,F)=>{F!=null&&typeof F!="string"&&(O.preventDefault(),H(F))},U=(O,F)=>x({value:O,type:F}).then(async()=>{await S(),g(N=>[...N,{title:O}]),j({type:"add",payload:{value:O,type:F}})}),w=(O,F,N,_)=>{N==="selectOption"?F.forEach(K=>{if(typeof K!="string"&&typeof K.inputValue=="string"&&K.inputValue&&K.title.startsWith("Create new value"))return U(K.inputValue,l.name);g(F),m(Y=>Y.filter(({title:y})=>y!==K.title)),_!=null&&_.option&&j({type:"add",payload:{value:_.option.title,type:l.name}})}):N==="clear"?(g([]),j({type:"clear",payload:n})):N==="removeOption"&&(g(F),_!=null&&_.option&&j({type:"remove",payload:{value:_.option.title,type:l.name}}))},D=()=>{H(),r()};return s(ke,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update tags to feature toggle",onClick:()=>o(v),disabledPrimaryButton:v.addedTags.length===0&&v.removedTags.length===0,onClose:D,formId:I3,children:[t(B,{paragraph:!0,sx:{marginBottom:O=>O.spacing(2.5)},children:"Tags allow you to group features together"}),t("form",{id:I3,onSubmit:()=>o(v),children:s(Fa,{children:[t(c4,{options:i,disabled:c||i.length===0,value:l,onChange:z},c?"loading":i.length),t(C,{condition:!c&&i.length===0,show:s(B,{variant:"body1",children:["No"," ",t(e3,{component:R1,to:"/tag-types",children:"tag types"})," ","available."]}),elseShow:t(l4,{disabled:c,options:Z,existingTags:n,indeterminateOptions:f,tagType:l,selectedOptions:u,onChange:w})})]})})]})},La=({projectId:e,data:n})=>{const{bulkUpdateTags:a}=Jt(),{refetch:r}=P1(e),{setToastData:o,setToastApiError:i}=u1(),{trackEvent:c}=I1(),[l,h]=d.useState(!1),[u,g]=d.useMemo(()=>{const m=n.flatMap(({tags:S})=>S||[]).reduce((S,x)=>[...S,...S.some(Z=>Z.type===x.type&&Z.value===x.value)?[]:[x]],[]),b=m.filter(S=>!n.every(({tags:x})=>x==null?void 0:x.some(Z=>Z.type===S.type&&Z.value===S.value)));return[m,b]},[n]);return s(G,{children:[t(X1,{projectId:e,permission:p2,children:({hasAccess:m})=>t(v1,{disabled:!m||l,startIcon:t(q0,{}),variant:"outlined",size:"small",onClick:()=>h(!0),children:"Tags"})}),t(Ma,{open:l,onCancel:()=>h(!1),onSubmit:async({addedTags:m,removedTags:b})=>{const S=n.map(({name:Z})=>Z),x={features:S,tags:{addedTags:m,removedTags:b}};try{await a(x),r();const Z=m.length?`Added tags: ${m.map(({type:j,value:H})=>`${j}:${H}`).join(", ")}.`:"",v=b.length?`Removed tags: ${b.map(({type:j,value:H})=>`${j}:${H}`).join(", ")}.`:"";o({title:"Tags updated",text:`${S.length} feature toggles updated. ${Z} ${v}`,type:"success",autoHideDuration:12e3}),c("batch_operations",{props:{eventType:"tags updated"}})}catch(Z){i(f1(Z))}h(!1)},initialValues:u,initialIndeterminateValues:g},n.length)]})},za=({selectedIds:e,data:n,projectId:a})=>{var g,f;const{uiConfig:r}=l1(),[o,i]=d.useState(!1),{trackEvent:c}=I1(),l=d.useMemo(()=>n.filter(m=>e.includes(m.name)),[n,e]),h=d.useMemo(()=>{const m=l.flatMap(b=>b.environments).map(b=>b==null?void 0:b.name).filter(b=>b!==void 0);return Array.from(new Set(m))},[l]),u=()=>{c("batch_operations",{props:{eventType:"features exported"}})};return s(G,{children:[t(Ba,{projectId:a,features:e}),t(C,{condition:Boolean((g=r==null?void 0:r.flags)==null?void 0:g.featuresExportImport),show:t(v1,{startIcon:t($4,{}),variant:"outlined",size:"small",onClick:()=>i(!0),children:"Export"})}),t(La,{projectId:a,data:l}),t(_a,{projectId:a,data:l}),t(C,{condition:Boolean((f=r==null?void 0:r.flags)==null?void 0:f.featuresExportImport),show:t(Tt,{showExportDialog:o,data:l,onClose:()=>i(!1),environments:h,onConfirm:u})})]})},Ha=p(At)(()=>({whiteSpace:"nowrap"})),Na=p("div",{shouldForwardProp:e=>e!=="hasWarning"})(({theme:e,hasWarning:n})=>({flexGrow:0,...C1,justifyContent:"center",...n&&{"::before":{content:'""',display:"block",width:e.spacing(2)}}})),ze=["Select","Actions","name","favorite"],Wa={id:"createdAt"},Ua=({features:e,loading:n,environments:a=[]})=>{var E,$;const{classes:r}=$a(),o=h1(),i=g1(o.breakpoints.down("md")),[c,l]=d.useState({open:!1,featureId:"",environmentName:""}),[h,u]=d.useState({}),[g,f]=d.useState(),m=Q("projectId"),{value:b,setValue:S}=c2(`${m}:FeatureToggleListTable:v1`,Wa),{value:x,setValue:Z}=G0(),v=_1(),[j,H]=t3(),{isChangeRequestConfigured:z}=u2(m),U=pa(n?["a","b","c"]:a),{refetch:w}=P1(m),{setToastData:D,setToastApiError:O}=u1(),{isFavoritesPinned:F,sortTypes:N,onChangeIsFavoritePinned:_}=K0(j.has("favorites")?j.get("favorites")==="true":x.favorites),{toggleFeatureEnvironmentOn:K,toggleFeatureEnvironmentOff:Y}=J0(),{favorite:y,unfavorite:T}=Y0(),{onChangeRequestToggle:V,onChangeRequestToggleClose:I,onChangeRequestToggleConfirm:W,changeRequestDialogDetails:k}=d4(m),[X,c1]=d.useState(!1),{uiConfig:a1}=l1(),m1=d.useCallback(async(P,R,M,L)=>{if(z(M))throw V(R,M,L),new Error("Additional approval required");try{L?await K(P,R,M):await Y(P,R,M),w()}catch(e1){const O1=f1(e1);throw O1===p4?l({open:!0,featureId:R,environmentName:M}):O(O1),e1}D({type:"success",title:"Updated toggle status",text:"Successfully updated toggle status."}),w()},[Y,K,z]),j1=d.useCallback(async P=>{P!=null&&P.favorite?await T(m,P.name):await y(m,P.name),w()},[m,w]),Oe=d.useMemo(()=>e.some(P=>{var R;return(R=P==null?void 0:P.tags)==null?void 0:R.length}),[e]),b1=d.useMemo(()=>{var P;return[...(P=a1==null?void 0:a1.flags)!=null&&P.bulkOperations?[{id:"Select",Header:({getToggleAllRowsSelectedProps:R})=>t(X2,{...R()}),Cell:({row:R})=>{var M;return t(Q0,{...(M=R==null?void 0:R.getToggleRowSelectedProps)==null?void 0:M.call(R)})},maxWidth:50,disableSortBy:!0,hideInMenu:!0}]:[],{id:"favorite",Header:t(X0,{isActive:F,onClick:_}),accessor:"favorite",Cell:({row:{original:R}})=>t(en,{value:R==null?void 0:R.favorite,onClick:()=>j1(R)}),maxWidth:50,disableSortBy:!0,hideInMenu:!0},{Header:"Seen",accessor:"lastSeenAt",Cell:Et,sortType:"date",align:"center",maxWidth:80},{Header:"Type",accessor:"type",Cell:Rt,align:"center",maxWidth:80},{Header:"Name",accessor:"name",Cell:({value:R})=>t(kt,{title:R,to:`/projects/${m}/features/${R}`}),minWidth:100,sortType:"alphanumeric",searchable:!0},...Oe?[{id:"tags",Header:"Tags",accessor:R=>{var M;return((M=R.tags)==null?void 0:M.map(({type:L,value:e1})=>`${L}:${e1}`).join(`
2
2
  `))||""},Cell:tn,width:80,searchable:!0}]:[],{Header:"Created",accessor:"createdAt",Cell:h2,sortType:"date",minWidth:120},...U.map(R=>({Header:n?()=>"":R,maxWidth:90,id:`environments.${R}`,accessor:M=>{var L;return(L=M.environments[R])==null?void 0:L.enabled},align:"center",Cell:({value:M,row:{original:L}})=>{const e1=L.someEnabledEnvironmentHasVariants&&L.environments[R].variantCount===0&&L.environments[R].enabled;return s(Na,{hasWarning:e1,children:[t(ha,{value:M,projectId:m,featureName:L==null?void 0:L.name,environmentName:R,onToggle:m1}),t(C,{condition:e1,show:t(u4,{})})]})},sortType:"boolean",filterName:R,filterParsing:M=>M?"enabled":"disabled"})),{id:"Actions",maxWidth:56,width:56,Cell:R=>t(xa,{projectId:m,onOpenArchiveDialog:f,onOpenStaleDialog:u,...R}),disableSortBy:!0,hideInMenu:!0}]},[m,U,n,m1]),[d1,Se]=d.useState(j.get("search")||""),$e=d.useMemo(()=>e.map(P=>{var R;return{...P,environments:Object.fromEntries(U.map(M=>{const L=P==null?void 0:P.environments.find(e1=>(e1==null?void 0:e1.name)===M);return[M,{name:M,enabled:(L==null?void 0:L.enabled)||!1,variantCount:(L==null?void 0:L.variantCount)||0}]})),someEnabledEnvironmentHasVariants:((R=P.environments)==null?void 0:R.some(M=>M.variantCount>0&&M.enabled))||!1}}),[e,U]),{data:V1,getSearchText:Y1,getSearchContext:A1}=m2(b1,d1,$e),we=d.useMemo(()=>n?Array(6).fill({type:"-",name:"Feature name",createdAt:new Date,environments:{production:{name:"production",enabled:!1}}}):V1,[n,V1]),Be=d.useMemo(()=>{var M;const P=b1.map(L=>(L==null?void 0:L.accessor)||(L==null?void 0:L.id));let R=U.filter((L,e1)=>e1>=3).map(L=>`environments.${L}`);if(j.has("columns")){const L=((M=j.get("columns"))==null?void 0:M.split(","))||[],e1=[...ze,...L];R=P.filter(O1=>!e1.includes(O1))}else if(b.columns){const L=[...ze,...b.columns];R=P.filter(e1=>!L.includes(e1))}return{sortBy:[{id:j.get("sort")||"createdAt",desc:j.has("order")?j.get("order")==="desc":b.desc}],hiddenColumns:R,selectedRowIds:{}}},[U]),_e=d.useCallback(P=>P.name,[]),{allColumns:xe,headerGroups:D1,rows:M1,state:{selectedRowIds:L1,sortBy:S1,hiddenColumns:Q1},prepareRow:C2,setHiddenColumns:S2}=r1.useTable({columns:b1,data:we,initialState:Be,sortTypes:N,autoResetHiddenColumns:!1,disableSortRemove:!0,autoResetSortBy:!1,getRowId:_e},r1.useFlexLayout,r1.useSortBy,r1.useRowSelect);return d.useEffect(()=>{if(n)return;const P={};P.sort=S1[0].id,S1[0].desc&&(P.order="desc"),d1&&(P.search=d1),F&&(P.favorites="true"),P.columns=xe.map(({id:R})=>R).filter(R=>!ze.includes(R)&&!(Q1!=null&&Q1.includes(R))).join(","),H(P,{replace:!0}),S(R=>({...R,id:S1[0].id,desc:S1[0].desc||!1,columns:P.columns.split(",")})),Z(R=>({...R,favorites:Boolean(F)}))},[n,S1,Q1,d1,H,F]),s(G,{children:[s(p1,{isLoading:n,className:r.container,header:t(s1,{titleElement:`Feature toggles (${M1.length})`,actions:s(G,{children:[t(C,{condition:!i,show:t(x1,{initialValue:d1,onChange:Se,hasFilters:!0,getSearchContext:A1})}),t(Oa,{allColumns:xe,staticColumns:ze,dividerAfter:["createdAt"],dividerBefore:["Actions"],isCustomized:Boolean(b.columns),setHiddenColumns:S2}),t(s1.Divider,{sx:{marginLeft:0}}),t(C,{condition:Boolean((E=a1==null?void 0:a1.flags)==null?void 0:E.featuresExportImport),show:t(K1,{title:"Export toggles visible in the table below",arrow:!0,children:t(B1,{onClick:()=>c1(!0),sx:P=>({marginRight:P.spacing(2)}),children:t(nn,{})})})}),t(Ha,{onClick:()=>v(an(m)),maxWidth:"960px",Icon:Pt,projectId:m,permission:Q2,"data-testid":"NAVIGATE_TO_CREATE_FEATURE",children:"New feature toggle"})]}),children:t(C,{condition:i,show:t(x1,{initialValue:d1,onChange:Se,hasFilters:!0,getSearchContext:A1})})}),children:[t(se,{value:Y1(d1),children:t(g2,{rows:M1,headerGroups:D1,prepareRow:C2})}),t(C,{condition:M1.length===0,show:t(C,{condition:(d1==null?void 0:d1.length)>0,show:s(y1,{children:["No feature toggles found matching “",d1,"”"]}),elseShow:t(y1,{children:"No feature toggles available. Get started by adding a new feature toggle."})})}),t(h4,{onClose:()=>l(P=>({...P,open:!1})),projectId:m,...c}),t(m4,{isStale:h.stale===!0,isOpen:Boolean(h.featureId),onClose:()=>{u({}),w()},featureId:h.featureId||"",projectId:m}),t(Kt,{isOpen:Boolean(g),onConfirm:()=>{w()},onClose:()=>{f(void 0)},featureIds:[g||""],projectId:m})," ",t(g4,{isOpen:k.isOpen,onClose:I,environment:k==null?void 0:k.environment,onConfirm:W,messageComponent:t(f4,{featureName:k.featureName,enabled:k.enabled,environment:k==null?void 0:k.environment})}),t(C,{condition:Boolean(($=a1==null?void 0:a1.flags)==null?void 0:$.featuresExportImport)&&!n,show:t(Tt,{showExportDialog:X,data:we,onClose:()=>c1(!1),environments:U})})]}),t(rn,{count:Object.keys(L1).length,children:t(za,{selectedIds:Object.keys(L1),data:e,projectId:m})})]})},fe=p("div")(({theme:e})=>({margin:"0",textAlign:"center",backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,width:"100%",minWidth:225,padding:e.spacing(3),[e.breakpoints.down("md")]:{display:"flex",flexDirection:"column",position:"relative",padding:e.spacing(1.5)}})),je=p("p")(({theme:e})=>({marginBottom:e.spacing(2.5)})),h3=p("span")(({theme:e})=>({fontSize:e.typography.h2.fontSize,fontWeight:"bold",color:e.palette.text.primary})),b2=({children:e,to:n})=>t(B,{variant:"body2",textAlign:"center",sx:{paddingTop:a=>a.spacing(2.5),marginTop:"auto",justifySelf:"flex-end"},children:t(e3,{component:R1,to:n,children:e})}),qa=p("p")(({theme:e})=>({fontSize:"1.5rem",[e.breakpoints.down("md")]:{fontSize:e.fontSizes.bodySize,marginBottom:e.spacing(4)}})),Ga=p("p")(({theme:e})=>({fontSize:"1.5rem",[e.breakpoints.down("md")]:{fontSize:e.fontSizes.bodySize}})),Ka=({projectId:e,health:n})=>s(fe,{children:[t(je,{"data-loading":!0,children:"Project health"}),s(A,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:a=>a.spacing(2)},children:[t(Ga,{children:t(It,{percentage:n})}),s(qa,{"data-loading":!0,children:[n,"%"]})]}),t(b2,{to:`/projects/${e}/health`,children:"View project health"})]}),Ja=p(h3)(({theme:e})=>({marginLeft:"auto",fontWeight:e.typography.fontWeightRegular,color:e.palette.text.secondary})),Ya=p("div")(({theme:e})=>({display:"flex",gap:e.spacing(1.5),width:"100%",gridTemplateColumns:`${e.spacing(2.5)} auto auto`,margin:e.spacing(1,0),fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,alignItems:"center",[e.breakpoints.down("md")]:{margin:0}})),Qa=({type:e,Icon:n,count:a})=>s(Ya,{"data-loading":!0,children:[t(n,{fontSize:"small","data-loading":!0}),t("div",{children:(o=>o.charAt(0).toUpperCase()+o.slice(1).replace("-"," "))(e)}),t(Ja,{children:a})]}),Xa=({features:e})=>{const n=d.useMemo(()=>{const a=(e==null?void 0:e.filter(l=>l.type==="release").length)||0,r=(e==null?void 0:e.filter(l=>l.type==="experiment").length)||0,o=(e==null?void 0:e.filter(l=>l.type==="operational").length)||0,i=(e==null?void 0:e.filter(l=>l.type==="kill-switch").length)||0,c=(e==null?void 0:e.filter(l=>l.type==="permission").length)||0;return{release:a,experiment:r,operational:o,"kill-switch":i,permission:c}},[e]);return s(fe,{sx:{padding:a=>a.spacing(3)},children:[t(je,{children:"Toggle types used"}),Object.keys(n).map(a=>t(Qa,{type:a,Icon:on(a),count:n[a]},a))]})},er=p("div")(({theme:e})=>({textAlign:"left",borderRadius:`${e.shape.borderRadius}px`,backgroundColor:`${e.palette.background.elevation2}`,padding:e.spacing(.5,2),fontSize:e.typography.body2.fontSize})),tr=({id:e,description:n})=>s(fe,{children:[t(je,{children:"Project Meta"}),s(er,{children:[t(B,{component:"span",variant:"body2",color:"text.secondary",children:"ID:"})," ",t("code",{"data-loading":!0,children:e||"__________"})]}),t(C,{condition:Boolean(n),show:t(B,{variant:"body2",sx:{marginTop:a=>a.spacing(1.5),marginBottom:0,textAlign:"left"},children:n})}),t(C,{condition:!Boolean(n),show:t(b2,{to:`/projects/${e}/edit`,children:"Add description"})})]}),nr=p(B)(({theme:e})=>({marginBottom:e.spacing(2.5)})),ar=p(A)(({theme:e})=>({fontSize:e.fontSizes.largeHeader})),P2=p(A)(({theme:e})=>({...C1,flexDirection:"column",alignItems:"center",marginLeft:e.spacing(2.5)})),O3=p(B)(({theme:e})=>({color:e.palette.text.secondary,fontSize:e.typography.body2.fontSize})),rr=p(B)(({theme:e})=>({marginLeft:e.spacing(1),fontSize:e.typography.body1.fontSize,fontWeight:e.typography.fontWeightBold})),or=e=>e>0?t(O4,{sx:{color:"success.dark",height:20,width:20}}):t(V4,{sx:{color:"warning.dark",height:20,width:20}}),ir=e=>e>0?"success.dark":"warning.dark",Te=({title:e,boxText:n,change:a,percentage:r,children:o,customChangeElement:i})=>s(G,{children:[t(C,{condition:Boolean(e),show:t(nr,{children:e})}),o,s(A,{sx:{...C1,justifyContent:"center",width:"auto"},children:[t(ar,{children:n}),t(C,{condition:Boolean(i),show:t(P2,{children:i}),elseShow:t(C,{condition:a!==void 0&&a!==0,show:s(P2,{children:[s(A,{sx:{...C1},children:[or(a),s(rr,{color:ir(a),children:[a>0?"+":"",a,r?"%":""]})]}),t(O3,{children:"this month"})]}),elseShow:t(P2,{children:t(O3,{children:"No change"})})})})]})]}),sr=({projectId:e,memberCount:n,change:a=0})=>{var i,c;const{uiConfig:r}=l1();let o="/admin/users";return(c=(i=r==null?void 0:r.versionInfo)==null?void 0:i.current)!=null&&c.enterprise&&(o=`/projects/${e}/settings/access`),s(fe,{children:[t(je,{"data-loading":!0,children:"Project members"}),t(A,{sx:{display:"flex",justifyContent:"center"},children:t(Te,{boxText:`${n}`,change:a})}),t(b2,{to:o,children:"View all members"})]})},cr=e=>fetch(e).then(G1("ChangeRequest")).then(n=>n.json()),n0=e=>{const{data:n,error:a,mutate:r}=sn([],q1(`api/admin/projects/${e}/change-requests`),cr);return d.useMemo(()=>({changeRequests:n,loading:!a&&!n,refetch:r,error:a}),[n,a,r])},We="change-requests-widget",lr=p(A)(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing(1.5)})),$3=p(A)(({theme:e})=>({flex:1,textAlign:"left",padding:e.spacing(1.5),borderRadius:e.shape.borderRadiusMedium,alignItems:"center",minWidth:175})),B3=p(A)(({theme:e})=>({display:"flex",alignItems:"center"})),dr=p(h3)(({theme:e})=>({background:e.palette.seen.recent,padding:e.spacing(0,1),marginRight:e.spacing(.5),borderRadius:e.shape.borderRadius})),pr=p(h3)(({theme:e})=>({background:e.palette.seen.primary,padding:e.spacing(0,1),marginRight:e.spacing(.5),borderRadius:e.shape.borderRadius})),_3=p(B)(({theme:e})=>({fontSize:e.typography.body2.fontSize,marginBottom:e.spacing(.5)})),F3=()=>t(B,{component:"span",variant:"body2",color:"text.secondary",lineHeight:1,"data-loading":We,children:"change requests"}),ur=({projectId:e})=>{const{changeRequests:n,loading:a}=n0(e),r=Zt(a,`[data-loading="${We}"]`),o=n==null?void 0:n.filter(c=>(c==null?void 0:c.state)==="Approved").length,i=n==null?void 0:n.filter(c=>(c==null?void 0:c.state)==="In review").length;return s(fe,{ref:r,children:[t(je,{children:"Open change requests"}),s(lr,{children:[s($3,{sx:{background:c=>c.palette.success.light},children:[t(_3,{children:"To be applied"}),s(B3,{children:[t(dr,{"data-loading":We,children:o||0})," ",t(F3,{})]})]}),s($3,{sx:{background:c=>c.palette.secondary.light},children:[t(_3,{children:"To be reviewed"}),s(B3,{children:[t(pr,{"data-loading":We,children:i||0})," ",t(F3,{})]})]})]}),t(b2,{to:`/projects/${e}/change-requests`,children:"View change requests"})]})};var m3={},hr=le;Object.defineProperty(m3,"__esModule",{value:!0});var g3=m3.default=void 0,mr=hr(ce()),gr=de,fr=(0,mr.default)((0,gr.jsx)("path",{d:"m12 4-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"}),"ArrowForward");g3=m3.default=fr;const vr=p("p")(({theme:e})=>({fontSize:"1.5rem",[e.breakpoints.down("md")]:{fontSize:e.fontSizes.bodySize,marginBottom:e.spacing(4)}})),yr=p("div")(()=>({display:"flex",justifyContent:"center"})),br=p(R1)(({theme:e})=>({textDecoration:"none",...C1,justifyContent:"center",color:e.palette.primary.main,[e.breakpoints.down("md")]:{position:"absolute",bottom:e.spacing(1.5),right:e.spacing(1.5)}})),Cr=p("p")(({theme:e})=>({[e.breakpoints.down("md")]:{display:"none"}})),Sr=p(g3)(({theme:e})=>({color:e.palette.primary.main,marginLeft:e.spacing(1)})),wr=({projectId:e,health:n})=>s(fe,{children:[t(yr,{children:t(It,{percentage:n})}),t(B,{"data-loading":!0,sx:{marginTop:a=>a.spacing(2)},children:"Overall health rating"}),t(A,{sx:{marginBottom:a=>a.spacing(2.5)},children:s(vr,{"data-loading":!0,children:[n,"%"]})}),s(br,{"data-loading":!0,to:`/projects/${e}/health`,children:[t(Cr,{"data-loading":!0,children:"view more "}),t(Sr,{"data-loading":!0})]})]}),xr=p("div")(({theme:e})=>({textAlign:"center",backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,width:"100%",padding:e.spacing(3,2,3,2),[e.breakpoints.down("md")]:{...C1,flexDirection:"column",justifyContent:"center",fontSize:e.fontSizes.smallBody,position:"relative",padding:e.spacing(1.5)}})),Tr=p("p")(({theme:e})=>({marginBottom:e.spacing(2)})),Ar=p("p")(({theme:e})=>({fontSize:"1.5rem",marginBottom:e.spacing(2),[e.breakpoints.down("md")]:{fontSize:e.fontSizes.bodySize,marginBottom:e.spacing(4)}})),Er=p("p")(({theme:e})=>({[e.breakpoints.down("md")]:{display:"none"}})),Rr=p(R1)(({theme:e})=>({textDecoration:"none",...C1,justifyContent:"center",color:e.palette.primary.main,[e.breakpoints.down("md")]:{position:"absolute",right:e.spacing(1.5),bottom:e.spacing(1.5)}})),kr=p(g3)(({theme:e})=>({color:e.palette.primary.main,marginLeft:e.spacing(1)})),Pr=({projectId:e,memberCount:n})=>{var o,i;const{uiConfig:a}=l1();let r="/admin/users";return(i=(o=a==null?void 0:a.versionInfo)==null?void 0:o.current)!=null&&i.enterprise&&(r=`/projects/${e}/settings/access`),s(xr,{children:[t(Tr,{"data-loading":!0,children:"Project members"}),t(Ar,{"data-loading":!0,children:n}),s(Rr,{"data-loading":!0,to:r,children:[t(Er,{"data-loading":!0,children:"view more "}),t(kr,{"data-loading":!0})]})]})},Ir=p(A)(({theme:e})=>({...C1,width:"225px",flexDirection:"column",gap:e.spacing(2),boxShadow:"none",[e.breakpoints.down("md")]:{display:"grid",width:"100%",alignItems:"stretch",marginBottom:e.spacing(2)},[e.breakpoints.down("sm")]:{display:"flex"}})),Zr=({id:e,description:n,memberCount:a,health:r,features:o,stats:i})=>{const{uiConfig:c,isEnterprise:l}=l1(),h=h1(),u=g1(h.breakpoints.down("md")),{isChangeRequestConfiguredInAnyEnv:g}=u2(e),f=l()&&g(),m=e!==cn,b=!f&&!m||u&&f&&m;return Boolean(c==null?void 0:c.flags.newProjectOverview)?t("aside",{children:s(Ir,{sx:b?{gridTemplateColumns:"repeat(auto-fill, minmax(225px, 1fr))"}:{gridTemplateColumns:"repeat(2, 1fr)"},children:[t(C,{condition:f,show:t(A,{sx:{gridColumnStart:m?"span 2":"span 1",flex:1,display:"flex"},children:t(ur,{projectId:e})})}),t(tr,{id:e,description:n}),t(Ka,{projectId:e,health:r}),t(C,{condition:m,show:t(sr,{projectId:e,memberCount:a,change:i==null?void 0:i.projectMembersAddedCurrentWindow})}),t(Xa,{features:o})]})}):t("aside",{children:s(A,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(225px, 1fr))",gap:S=>S.spacing(2),paddingBottom:S=>S.spacing(2)},children:[t(wr,{projectId:e,health:r}),t(C,{condition:m,show:t(Pr,{projectId:e,memberCount:a})})]})})},jr=p(F1)(({theme:e})=>({padding:e.spacing(3,3),maxWidth:"350px",borderRadius:`${e.shape.borderRadiusMedium}px`,border:`1px solid ${e.palette.neutral.border}`,fontSize:e.typography.body2.fontSize})),V3=({children:e,id:n})=>{const[a,r]=d.useState(null),o=l=>r(l.currentTarget),i=()=>r(null),c=Boolean(a);return s(A,{sx:{position:"absolute",top:l=>l.spacing(.5),right:l=>l.spacing(.5)},children:[t(B1,{onClick:o,"aria-describedby":n,size:"small",children:t(jt,{sx:{fontSize:l=>l.typography.body1.fontSize}})}),t(Dt,{id:n,open:c,anchorEl:a,sx:l=>({zIndex:l.zIndex.tooltip}),children:t(Ot,{onClickAway:i,children:s(jr,{elevation:3,children:[t(B1,{onClick:i,sx:{position:"absolute",right:4,top:4},children:t(ln,{sx:{fontSize:l=>l.typography.body1.fontSize}})}),e,t(dn,{id:n,eventName:"project_overview",localStorageKey:"ProjectOverviewFeedback"})]})})})]})},Dr=p(A)(({theme:e})=>({padding:e.spacing(0,0,2,2),display:"grid",gap:e.spacing(2),gridTemplateColumns:"repeat(4, 1fr)",flexWrap:"wrap",[e.breakpoints.down("lg")]:{gridTemplateColumns:"repeat(2, 1fr)"},[e.breakpoints.down("md")]:{padding:e.spacing(0,0,2)},[e.breakpoints.down("sm")]:{flexDirection:"column"}})),He=p(A)(({theme:e})=>({position:"relative",padding:e.spacing(3),backgroundColor:e.palette.background.paper,flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:`${e.shape.borderRadiusLarge}px`,[e.breakpoints.down("lg")]:{padding:e.spacing(2)}})),Or=p(B)(({theme:e})=>({color:e.palette.text.secondary,fontSize:e.typography.body2.fontSize,lineHeight:e.typography.body2.lineHeight})),$r=({stats:e})=>{if(Object.keys(e).length===0)return null;const{avgTimeToProdCurrentWindow:n,projectActivityCurrentWindow:a,projectActivityPastWindow:r,createdCurrentWindow:o,createdPastWindow:i,archivedCurrentWindow:c,archivedPastWindow:l}=e;return s(Dr,{children:[t(He,{children:t(Te,{title:"Total changes",boxText:String(a),change:a-r,children:t(V3,{id:"total-changes",children:"Sum of all configuration and state modifications in the project."})})}),t(He,{children:t(Te,{title:"Avg. time to production",boxText:s(A,{sx:{display:"flex",alignItems:"center",gap:h=>h.spacing(1)},children:[n," ",t(B,{component:"span",children:"days"})]}),customChangeElement:t(Or,{children:"In project life"}),percentage:!0,children:t(V3,{id:"avg-time-to-prod",children:'How long did it take on average from a feature toggle was created until it was enabled in an environment of type production. This is calculated only from feature toggles with the type of "release".'})})}),t(He,{children:t(Te,{title:"Features created",boxText:String(o),change:o-i})}),t(He,{children:t(Te,{title:"Features archived",boxText:String(c),change:c-l})})]})},Br=15*1e3,_r=p("div")(({theme:e})=>({display:"flex",[e.breakpoints.down("md")]:{flexDirection:"column"}})),Fr=p("div")(()=>({width:"100%",minWidth:0})),Vr=p(A)(()=>({display:"flex",flexDirection:"column",width:"100%",minWidth:0})),Mr=()=>{const e=Q("projectId"),n=k1(e),{project:a,loading:r}=P1(e,{refreshInterval:Br}),{members:o,features:i,health:c,description:l,environments:h,stats:u}=a;T1(`Project overview – ${n}`);const{setLastViewed:g}=pn(),{uiConfig:f}=l1();return d.useEffect(()=>{g(e)},[e,g]),s(_r,{children:[t(Zr,{id:e,description:l,memberCount:o,health:c,features:i,stats:u}),s(Vr,{children:[t(C,{condition:Boolean(f==null?void 0:f.flags.newProjectOverview),show:t($r,{stats:a.stats})}),t(Fr,{children:t(Ua,{features:i,environments:h,loading:r})})]})]})},Lr=(e,n)=>{const a=q1(`api/admin/projects/${e}/health-report`),{data:r,error:o}=ie(a,zr,n),i=d.useCallback(()=>{$t(a).catch(console.warn)},[a]);return{healthReport:r,refetchHealthReport:i,loading:!o&&!r,error:o}},zr=e=>fetch(e).then(G1("Health report")).then(n=>n.json());var f3={},Hr=le;Object.defineProperty(f3,"__esModule",{value:!0});var H2=f3.default=void 0,Nr=Hr(ce()),Wr=de,Ur=(0,Nr.default)((0,Wr.jsx)("path",{d:"M12 5.99 19.53 19H4.47L12 5.99M12 2 1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined");H2=f3.default=Ur;const qr=p(A)(({theme:e})=>({display:"flex",alignItems:"center",color:e.palette.success.dark,"& svg":{color:e.palette.success.main}})),M3=p(A)(({theme:e})=>({display:"flex",alignItems:"center",color:e.palette.warning.dark,"& svg":{color:e.palette.warning.main}})),Gr=p(F1)(({theme:e})=>({padding:e.spacing(4),marginBottom:e.spacing(2),borderRadius:e.shape.borderRadiusLarge,boxShadow:"none",display:"flex",justifyContent:"space-between",[e.breakpoints.down("md")]:{flexDirection:"column",gap:e.spacing(2)}})),I2=p("h2")(({theme:e})=>({fontSize:e.fontSizes.mainHeader,marginBottom:e.spacing(1)})),Kr=p("p")(({theme:e})=>({fontSize:"2rem",fontWeight:e.fontWeight.bold})),Jr=p("p")(({theme:e})=>({color:e.palette.text.secondary})),L3=p("ul")(({theme:e})=>({listStyleType:"none",margin:0,padding:0,"& svg":{marginRight:e.spacing(1)}})),z3=p("p")(({theme:e})=>({marginLeft:e.spacing(4)})),Yr=({healthReport:e})=>{const n=e.health<50?"error.main":e.health<75?"warning.main":"success.main",a=()=>s(qr,{children:[t(un,{}),s("span",{children:[e.activeCount," active toggles"]})]}),r=()=>s(M3,{children:[t(H2,{}),s("span",{children:[e.staleCount," stale toggles"]})]}),o=()=>s(M3,{children:[t(H2,{}),s("span",{children:[e.potentiallyStaleCount," potentially stale toggles"]})]});return s(Gr,{children:[s(A,{children:[t(I2,{children:"Health rating"}),t(C,{condition:e.health>-1,show:s(G,{children:[s(Kr,{sx:{color:n},children:[e.health,"%"]}),s(Jr,{children:["Last updated:"," ",t(n3,{date:e.updatedAt,live:!1})]})]})})]}),s(A,{children:[t(I2,{children:"Toggle report"}),s(L3,{children:[t("li",{children:t(C,{condition:Boolean(e.activeCount),show:a})}),t(C,{condition:Boolean(e.activeCount),show:t(z3,{children:"Also includes potentially stale toggles."})}),t("li",{children:t(C,{condition:Boolean(e.staleCount),show:r})})]})]}),s(A,{sx:{flexBasis:"40%"},children:[t(I2,{children:"Potential actions"}),t(L3,{children:t("li",{children:t(C,{condition:Boolean(e.potentiallyStaleCount),show:o})})}),t(C,{condition:Boolean(e.potentiallyStaleCount),show:t(z3,{children:"Review your feature toggles and delete unused toggles."}),elseShow:t("span",{children:"No action is required"})})]})]})},Qr=({row:e})=>{const n=h1();return e.original.expiredAt?t(h2,{value:e.original.expiredAt}):t(i1,{children:t(B,{variant:"body2",color:n.palette.text.secondary,children:"N/A"})})},Xr=p("span")(({theme:e})=>({display:"flex",gap:"1ch",alignItems:"center",color:e.palette.warning.dark,"& svg":{color:e.palette.warning.main}})),eo=p("span")(({theme:e})=>({display:"flex",gap:"1ch",alignItems:"center",color:e.palette.success.dark,"& svg":{color:e.palette.success.main}})),to=({row:e})=>e.original.status==="potentially-stale"?t(i1,{children:s(Xr,{children:[t(F4,{}),t("span",{children:"Potentially stale"})]})}):t(i1,{children:s(eo,{children:[t(Bt,{}),t("span",{children:"Healthy"})]})}),H3=40,no=7,a0={[mn]:H3,[gn]:H3,[fn]:no},r0=(e,n)=>Math.abs(hn(e,n)),o0=(e,n)=>e>=a0[n],ao=e=>{const{type:n,createdAt:a}=e,r=_t(a),o=new Date,i=r0(r,o);return o0(i,n)&&n!==Ft&&n!==Vt?"potentially-stale":"healthy"},ro=e=>{const{type:n,createdAt:a}=e;if(n===Ft||n===Vt)return;const r=_t(a),o=new Date,i=r0(r,o);if(o0(i,n)){const c=i-a0[n];return M4(o,c).toISOString()}},oo=({projectId:e,features:n})=>{const a=h1(),r=g1(a.breakpoints.down("sm")),o=g1(a.breakpoints.down("md")),i=g1(a.breakpoints.down("lg")),c=d.useMemo(()=>n.map(x=>({project:e,name:x.name,type:x.type,stale:x.stale,status:ao(x),lastSeenAt:x.lastSeenAt,createdAt:x.createdAt,expiredAt:ro(x)})),[e,n]),l=d.useMemo(()=>({hiddenColumns:[],sortBy:[{id:"createdAt"}]}),[]),{headerGroups:h,rows:u,prepareRow:g,state:{globalFilter:f},setGlobalFilter:m,setHiddenColumns:b}=r1.useTable({columns:N3,data:c,initialState:l,sortTypes:Pe,autoResetGlobalFilter:!1,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0},r1.useGlobalFilter,r1.useFlexLayout,r1.useSortBy);f2([{condition:r,columns:["stale"]},{condition:o,columns:["expiredAt","lastSeenAt"]},{condition:i,columns:["createdAt"]}],b,N3);const S=u.length<c.length?`Feature toggles (${u.length} of ${c.length})`:`Feature toggles (${c.length})`;return s(p1,{header:t(s1,{title:S,actions:t(x1,{initialValue:f,onChange:m})}),children:[t(se,{value:f,children:t(g2,{headerGroups:h,prepareRow:g,rows:u})}),t(C,{condition:u.length===0,show:t(C,{condition:(f==null?void 0:f.length)>0,show:s(y1,{children:["No feature toggles found matching “",f,"”"]}),elseShow:t(y1,{children:"No feature toggles available. Get started by adding a new feature toggle."})})})]})},N3=[{Header:"Seen",accessor:"lastSeenAt",sortType:"date",align:"center",Cell:Et,disableGlobalFilter:!0,maxWidth:85},{Header:"Type",accessor:"type",align:"center",Cell:Rt,disableGlobalFilter:!0,maxWidth:85},{Header:"Name",accessor:"name",sortType:"alphanumeric",Cell:vn,minWidth:120},{Header:"Created",accessor:"createdAt",sortType:"date",Cell:h2,disableGlobalFilter:!0,maxWidth:150},{Header:"Expired",accessor:"expiredAt",Cell:Qr,disableGlobalFilter:!0,maxWidth:150},{Header:"Status",id:"status",accessor:"status",Cell:to,disableGlobalFilter:!0,width:180},{Header:"State",accessor:"stale",sortType:"boolean",Cell:yn,disableGlobalFilter:!0,maxWidth:120}],io=()=>{const e=Q("projectId"),n=k1(e);T1(`Project health – ${n}`);const{healthReport:a,refetchHealthReport:r,error:o}=Lr(e,{refreshInterval:15*1e3});return a?s("div",{children:[t(C,{condition:Boolean(o),show:t(Ct,{"data-loading":!0,style:{maxWidth:"500px",marginTop:"1rem"},onClick:r,text:`Could not fetch health rating for ${e}`})}),t(Yr,{healthReport:a}),t(oo,{projectId:e,features:a.features})]}):null},so=p("div")(({theme:e})=>({borderRadius:"12.5px",backgroundColor:e.palette.background.paper,padding:"2rem"})),co=()=>{const e=Q("projectId");return t(so,{children:t(bn,{title:"Event Log",project:e,displayInline:!0})})},i0=(e,n)=>{const{data:a,error:r,mutate:o}=ie(q1(`api/admin/projects/${e}/change-requests/${n}`),lo,{refreshInterval:15e3});return{data:a,loading:!r&&!a,refetchChangeRequest:()=>o(),error:r}},lo=e=>fetch(e).then(G1("Request changes")).then(n=>n.json()),po=p(F1)(({theme:e})=>({padding:e.spacing(3,4),borderRadius:`${e.shape.borderRadiusLarge}px`})),uo=p(A)(({theme:e})=>({display:"flex",alignItems:"center",marginBottom:e.spacing(2)})),ho=p(A)(({theme:e})=>({display:"flex",alignItems:"center"})),mo=p(B)(({theme:e})=>({display:"flex",alignItems:"center",marginRight:e.spacing(1),fontSize:e.fontSizes.mainHeader})),go=p(Cn)(({theme:e})=>({padding:e.spacing(.75,1.5),backgroundColor:e.palette.background.elevation2})),s0=p(Ie)(({theme:e})=>({height:"24px",width:"24px"})),fo=({changeRequest:e})=>{var n,a;return s(po,{elevation:0,children:[s(uo,{children:[s(mo,{variant:"h1",sx:{mr:1.5},children:["Change request #",e.id]}),t(Mt,{state:e.state})]}),s(ho,{children:[s(B,{variant:"body2",sx:{margin:"auto 0"},children:["Created"," ",t(n3,{minPeriod:60,date:new Date(e.createdAt)})," ","by"]}),t(A,{sx:r=>({marginLeft:r.spacing(1)}),children:t(K1,{title:(n=e==null?void 0:e.createdBy)==null?void 0:n.username,children:t(s0,{src:(a=e==null?void 0:e.createdBy)==null?void 0:a.imageUrl})})}),t(A,{sx:r=>({marginLeft:r.spacing(1.5)}),children:t(go,{variant:"outlined",children:s(B,{variant:"body2",sx:{lineHeight:1},children:["Environment:"," ",t(B,{display:"inline",fontWeight:"bold",variant:"body2",component:"span",children:e==null?void 0:e.environment})," ",t(Sn,{})," Updates:"," ",s(B,{variant:"body2",display:"inline",fontWeight:"bold",component:"span",children:[e.features.length," ",e.features.length===1?"feature toggle":"feature toggles"]})]})})})]})]})};function o1(){return o1=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},o1.apply(this,arguments)}function ve(e,n){if(e==null)return{};var a={},r=Object.keys(e),o,i;for(i=0;i<r.length;i++)o=r[i],!(n.indexOf(o)>=0)&&(a[o]=e[o]);return a}const vo=d.createContext({}),Qe=vo;function yo(e){return pe("MuiTimeline",e)}J1("MuiTimeline",["root","positionLeft","positionRight","positionAlternate"]);const bo=["position","className"],Co=e=>{const{position:n,classes:a}=e,r={root:["root",n&&`position${Z1(n)}`]};return me(r,yo,a)},So=p("ul",{name:"MuiTimeline",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:a}=e;return[n.root,a.position&&n[`position${Z1(a.position)}`]]}})({display:"flex",flexDirection:"column",padding:"6px 16px",flexGrow:1}),wo=d.forwardRef(function(n,a){const r=ue({props:n,name:"MuiTimeline"}),{position:o="right",className:i}=r,c=ve(r,bo),l=o1({},r,{position:o}),h=Co(l),u=d.useMemo(()=>({position:o}),[o]);return t(Qe.Provider,{value:u,children:t(So,o1({className:he(h.root,i),ownerState:l,ref:a},c))})}),c0=wo;function xo(e){return pe("MuiTimelineContent",e)}const To=J1("MuiTimelineContent",["root","positionLeft","positionRight","positionAlternate"]),Ao=["className"],Eo=e=>{const{position:n,classes:a}=e,r={root:["root",`position${Z1(n)}`]};return me(r,xo,a)},Ro=p(B,{name:"MuiTimelineContent",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:a}=e;return[n.root,n[`position${Z1(a.position)}`]]}})(({ownerState:e})=>o1({flex:1,padding:"6px 16px",textAlign:"left"},e.position==="left"&&{textAlign:"right"})),ko=d.forwardRef(function(n,a){const r=ue({props:n,name:"MuiTimelineContent"}),{className:o}=r,i=ve(r,Ao),{position:c}=d.useContext(Qe),l=o1({},r,{position:c||"right"}),h=Eo(l);return t(Ro,o1({component:"div",className:he(h.root,o),ownerState:l,ref:a},i))}),l0=ko,Po=J1("MuiTimelineOppositeContent",["root","positionLeft","positionRight","positionAlternate"]),Io=Po;function Zo(e){return pe("MuiTimelineItem",e)}const jo=J1("MuiTimelineItem",["root","positionLeft","positionRight","positionAlternate","missingOppositeContent"]),d0=jo,Do=["position","className"],Oo=e=>{const{position:n,classes:a,hasOppositeContent:r}=e,o={root:["root",`position${Z1(n)}`,!r&&"missingOppositeContent"]};return me(o,Zo,a)},$o=p("li",{name:"MuiTimelineItem",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:a}=e;return[n.root,n[`position${Z1(a.position)}`]]}})(({ownerState:e})=>o1({listStyle:"none",display:"flex",position:"relative",minHeight:70},e.position==="left"&&{flexDirection:"row-reverse"},e.position==="alternate"&&{"&:nth-of-type(even)":{flexDirection:"row-reverse",[`& .${To.root}`]:{textAlign:"right"},[`& .${Io.root}`]:{textAlign:"left"}}},!e.hasOppositeContent&&{"&:before":{content:'""',flex:1,padding:"6px 16px"}})),Bo=d.forwardRef(function(n,a){const r=ue({props:n,name:"MuiTimelineItem"}),{position:o,className:i}=r,c=ve(r,Do),{position:l}=d.useContext(Qe);let h=!1;d.Children.forEach(r.children,m=>{wn(m,["TimelineOppositeContent"])&&(h=!0)});const u=o1({},r,{position:o||l||"right",hasOppositeContent:h}),g=Oo(u),f=d.useMemo(()=>({position:u.position}),[u.position]);return t(Qe.Provider,{value:f,children:t($o,o1({className:he(g.root,i),ownerState:u,ref:a},c))})}),Ue=Bo;function _o(e){return pe("MuiTimelineSeparator",e)}J1("MuiTimelineSeparator",["root"]);const Fo=["className"],Vo=e=>{const{classes:n}=e;return me({root:["root"]},_o,n)},Mo=p("div",{name:"MuiTimelineSeparator",slot:"Root",overridesResolver:(e,n)=>n.root})({display:"flex",flexDirection:"column",flex:0,alignItems:"center"}),Lo=d.forwardRef(function(n,a){const r=ue({props:n,name:"MuiTimelineSeparator"}),{className:o}=r,i=ve(r,Fo),c=r,l=Vo(c);return t(Mo,o1({className:he(l.root,o),ownerState:c,ref:a},i))}),qe=Lo;function zo(e){return pe("MuiTimelineDot",e)}J1("MuiTimelineDot",["root","filled","outlined","filledGrey","outlinedGrey","filledPrimary","outlinedPrimary","filledSecondary","outlinedSecondary"]);const Ho=["className","color","variant"],No=e=>{const{color:n,variant:a,classes:r}=e,o={root:["root",a,n!=="inherit"&&`${a}${Z1(n)}`]};return me(o,zo,r)},Wo=p("span",{name:"MuiTimelineDot",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:a}=e;return[n.root,n[a.color!=="inherit"&&`${a.variant}${Z1(a.color)}`],n[a.variant]]}})(({ownerState:e,theme:n})=>o1({display:"flex",alignSelf:"baseline",borderStyle:"solid",borderWidth:2,padding:4,borderRadius:"50%",boxShadow:(n.vars||n).shadows[1],margin:"11.5px 0"},e.variant==="filled"&&o1({borderColor:"transparent"},e.color!=="inherit"&&o1({},e.color==="grey"?{color:(n.vars||n).palette.grey[50],backgroundColor:(n.vars||n).palette.grey[400]}:{color:(n.vars||n).palette[e.color].contrastText,backgroundColor:(n.vars||n).palette[e.color].main})),e.variant==="outlined"&&o1({boxShadow:"none",backgroundColor:"transparent"},e.color!=="inherit"&&o1({},e.color==="grey"?{borderColor:(n.vars||n).palette.grey[400]}:{borderColor:(n.vars||n).palette[e.color].main})))),Uo=d.forwardRef(function(n,a){const r=ue({props:n,name:"MuiTimelineDot"}),{className:o,color:i="grey",variant:c="filled"}=r,l=ve(r,Ho),h=o1({},r,{color:i,variant:c}),u=No(h);return t(Wo,o1({className:he(u.root,o),ownerState:h,ref:a},l))}),p0=Uo;function qo(e){return pe("MuiTimelineConnector",e)}J1("MuiTimelineConnector",["root"]);const Go=["className"],Ko=e=>{const{classes:n}=e;return me({root:["root"]},qo,n)},Jo=p("span",{name:"MuiTimelineConnector",slot:"Root",overridesResolver:(e,n)=>n.root})(({theme:e})=>({width:2,backgroundColor:(e.vars||e).palette.grey[400],flexGrow:1})),Yo=d.forwardRef(function(n,a){const r=ue({props:n,name:"MuiTimelineConnector"}),{className:o}=r,i=ve(r,Go),c=r,l=Ko(c);return t(Jo,o1({className:he(l.root,o),ownerState:c,ref:a},i))}),v3=Yo,Qo=p(F1)(({theme:e})=>({marginTop:e.spacing(2),borderRadius:`${e.shape.borderRadiusLarge}px`})),Xo=p(A)(({theme:e})=>({padding:e.spacing(2),marginBottom:`-${e.spacing(4)}`})),e5=p(c0)(()=>({[`& .${d0.root}:before`]:{flex:0,padding:0}})),t5=({state:e})=>{const n=r=>["Draft","In review","Approved","Applied"].map(i=>({title:i,active:i===r}));return t(Qo,{elevation:0,children:t(Xo,{children:t(e5,{children:(()=>{const r=n(e),o=r.findIndex(c=>c.active),i=o!==-1?o:null;return e==="Cancelled"?a5(r):n5(r,i)})()})})})},n5=(e,n)=>e.map(({title:a},r)=>{const o=r<e.length-1,i=t(C,{condition:o,show:t(v3,{})});return n!==null&&n>=r?Ge("success",a,i):n!==null&&n+1===r?Ge("primary",a,i,{variant:"outlined"}):Ge("grey",a,i)}),a5=e=>e.map(({title:n},a)=>{const r=a<e.length-1;return Ge("grey",n,t(C,{condition:r,show:t(v3,{})}))}),Ge=(e,n,a,r={})=>s(Ue,{children:[s(qe,{children:[t(p0,{color:e,...r}),a]}),t(l0,{children:n})]},n),r5=p(A)(({theme:e})=>({marginBottom:e.spacing(2)})),o5=({actualApprovals:e,minApprovals:n})=>s(G,{children:["Reviewers"," ",s(B,{component:"span",color:"text.secondary",children:["(",e,"/",n," required)"]})]}),i5=({header:e,children:n})=>s(F1,{elevation:0,sx:a=>({marginTop:a.spacing(2),padding:a.spacing(4),borderRadius:r=>`${r.shape.borderRadiusLarge}px`}),children:[t(r5,{children:e}),t(B,{variant:"body1",color:"text.secondary",children:t(C,{condition:Ae.Children.count(n)>0,show:"Approved by",elseShow:"No approvals yet"})}),n]}),y3=()=>e=>e!=="color"&&e!=="sx"&&e!=="approved"&&e!=="border"&&e!=="bgColor"&&e!=="svgColor",re=p(A)(({theme:e})=>({display:"flex",alignItems:"center"})),s5=p(Lt)(({theme:e})=>({color:e.palette.error.main,height:"35px",width:"35px",marginRight:e.spacing(1)})),W3=p(Lt)(({theme:e})=>({color:e.palette.warning.main,height:"35px",width:"35px",marginRight:e.spacing(1)})),N2=p(zt)(({theme:e})=>({color:e.palette.success.main,height:"35px",width:"35px",marginRight:e.spacing(1)})),c5=p(A)(({theme:e})=>({display:"flex",marginTop:e.spacing(2)})),l5=p(A,{shouldForwardProp:y3()})(({theme:e,bgColor:n,svgColor:a})=>({borderRadius:`${e.shape.borderRadiusMedium}px`,backgroundColor:n,padding:e.spacing(1,2),marginRight:e.spacing(2),height:"45px",width:"45px",display:"flex",alignItems:"center",justifyContent:"center",svg:{color:a}})),u0=p(wt)(({theme:e})=>({margin:e.spacing(2.5,0)})),d5=p(A,{shouldForwardProp:y3()})(({theme:e,border:n})=>({borderRadius:`${e.shape.borderRadiusLarge}px`,border:n,padding:e.spacing(3),width:"100%"})),oe=p(B,{shouldForwardProp:y3()})(({theme:e,color:n})=>({fontWeight:"bold",color:n})),p5=(e,n)=>e==="Approved"?`2px solid ${n.palette.success.main}`:e==="Applied"?`2px solid ${n.palette.primary.main}`:`1px solid ${n.palette.divider}`,u5=(e,n)=>e==="Approved"?{bgColor:n.palette.success.main,svgColor:n.palette.background.paper}:e==="Applied"?{bgColor:n.palette.primary.main,svgColor:n.palette.background.paper}:{bgColor:n.palette.background.elevation2,svgColor:n.palette.neutral.main},h5=({changeRequest:e})=>{const n=h1();return s(c5,{children:[t(l5,{...u5(e.state,n),children:t(xn,{style:{transform:"scale(1.5)"}})}),t(d5,{sx:{backgroundColor:e.state==="In review"?n.palette.warning.light:"initial"},border:p5(e.state,n),children:t(m5,{changeRequest:e})})]})},m5=({changeRequest:e})=>{const{state:n}=e;return n?n==="Approved"?t(g5,{}):n==="Applied"?t(v5,{}):n==="Cancelled"?t(y5,{}):t(f5,{minApprovals:e.minApprovals}):null},g5=()=>{const e=h1();return s(G,{children:[s(re,{children:[t(N2,{}),s(A,{children:[t(oe,{color:e.palette.success.dark,children:"Changes approved"}),t(B,{children:"One approving review from requested approvers"})]})]}),t(u0,{}),s(re,{children:[t(N2,{}),t(A,{children:t(oe,{color:e.palette.success.dark,children:"Changes are ready to be applied"})})]})]})},f5=({minApprovals:e})=>{const n=h1();return s(G,{children:[s(re,{children:[t(W3,{}),s(A,{children:[t(oe,{color:n.palette.warning.dark,children:"Review required"}),s(B,{children:["At least ",e," approval(s) must be submitted before changes can be applied"]})]})]}),t(u0,{}),s(re,{children:[t(W3,{}),t(oe,{color:n.palette.warning.dark,children:"Apply changes is blocked"})]})]})},v5=()=>{const e=h1();return t(G,{children:s(re,{children:[t(N2,{sx:{color:e.palette.primary.main}}),t(A,{children:t(oe,{color:e.palette.primary.main,children:"Changes applied"})})]})})},y5=()=>{const e=h1();return t(G,{children:s(re,{children:[t(s5,{}),t(A,{children:t(oe,{color:e.palette.error.main,children:"Changes cancelled"})})]})})};var b3={},b5=le;Object.defineProperty(b3,"__esModule",{value:!0});var h0=b3.default=void 0,C5=b5(ce()),S5=de,w5=(0,C5.default)((0,S5.jsx)("path",{d:"m7 10 5 5 5-5z"}),"ArrowDropDown");h0=b3.default=w5;const x5=({disabled:e})=>{const{isAdmin:n}=d.useContext(ge),a=Q("projectId"),r=Q("id"),{user:o}=Ht(),{refetchChangeRequest:i,data:c}=i0(a,r),{refetch:l}=a3(a),{setToastApiError:h,setToastData:u}=u1(),{changeState:g}=r3(),[f,m]=Ae.useState(!1),b=Ae.useRef(null),S=async()=>{try{await g(a,Number(r),{state:"Approved"}),i(),l(),u({type:"success",title:"Success",text:"Changes approved"})}catch(v){h(f1(v))}},x=()=>{m(v=>!v)},Z=v=>{b.current&&b.current.contains(v.target)||m(!1)};return s(Ae.Fragment,{children:[t(o3,{variant:"contained",disabled:e||(c==null?void 0:c.createdBy.id)===(o==null?void 0:o.id)&&!n,"aria-controls":f?"review-options-menu":void 0,"aria-expanded":f?"true":void 0,"aria-label":"review changes","aria-haspopup":"menu",onClick:x,ref:b,endIcon:t(h0,{}),permission:Tn,projectId:a,environmentId:c==null?void 0:c.environment,children:"Review changes"}),t(Dt,{sx:{zIndex:1},open:f,anchorEl:b.current,role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:v,placement:j})=>t(An,{...v,style:{transformOrigin:j==="bottom"?"center top":"center bottom"},children:t(F1,{className:"dropdown-outline",children:t(Ot,{onClickAway:Z,children:t(d2,{id:"review-options-menu",autoFocusItem:!0,children:t(H1,{onClick:S,children:"Approve changes"})})})})})})]})},T5=p(A)(({theme:e})=>({display:"flex",alignItems:"center",flexWrap:"wrap",marginTop:e.spacing(1.5),gap:e.spacing(1)})),A5=p(zt)(({theme:e})=>({color:e.palette.success.main,marginLeft:"auto"})),E5=({name:e,imageUrl:n})=>s(T5,{children:[t(s0,{src:n}),t(B,{variant:"body1",color:"text.primary",sx:{maxWidth:"170px",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"},children:e}),t(A5,{})]}),m0=p(Ie)(({theme:e})=>({height:"32px",width:"32px",marginTop:e.spacing(1),marginRight:e.spacing(2)})),R5=p(A)(({theme:e})=>({display:"flex",marginTop:e.spacing(2)})),k5=p(F1)(({theme:e})=>({width:"100%",padding:e.spacing(1.5,3,2.5,3),backgroundColor:e.palette.neutral.light,borderRadius:e.shape.borderRadiusLarge,borderColor:e.palette.divider})),P5=p(A)(({theme:e})=>({display:"flex",borderBottom:"1px solid",borderColor:e.palette.divider,paddingBottom:e.spacing(1.5)})),I5=({comment:e})=>s(R5,{children:[t(K1,{title:e.createdBy.username,children:t(m0,{src:e.createdBy.imageUrl})}),s(k5,{variant:"outlined",children:[t(P5,{children:s(A,{children:[t("strong",{children:e.createdBy.username})," ",s(B,{color:"text.secondary",component:"span",children:["commented"," ",t(n3,{minPeriod:60,date:new Date(e.createdAt)})]})]})}),t(A,{sx:{paddingTop:2.5},children:e.text})]})]}),Z5=p(A)(({theme:e})=>({display:"flex",marginTop:e.spacing(2),marginBottom:e.spacing(1)})),j5=({user:e,commentText:n,onTypeComment:a,children:r})=>s(G,{children:[s(Z5,{children:[t(K1,{title:(e==null?void 0:e.name)||(e==null?void 0:e.username),children:t(m0,{src:(e==null?void 0:e.imageUrl)||""})}),t(Je,{variant:"outlined",placeholder:"Add your comment here",fullWidth:!0,multiline:!0,minRows:2,onChange:o=>a(o.target.value),value:n})]}),t(A,{sx:{display:"flex",justifyContent:"flex-end"},children:r})]}),D5=p(A)(({theme:e})=>({width:"30%",display:"flex",flexDirection:"column",[e.breakpoints.down("sm")]:{width:"100%"}})),O5=p(F1)(({theme:e})=>({marginTop:e.spacing(2),marginLeft:e.spacing(2),width:"70%",padding:e.spacing(1,2),borderRadius:e.shape.borderRadiusLarge,[e.breakpoints.down("sm")]:{marginLeft:0,width:"100%"}})),$5=p(A)(({theme:e})=>({marginTop:e.spacing(3),display:"flex",justifyContent:"flex-end"})),B5=p(A)(({theme:e})=>({padding:e.spacing(2)})),_5=p(A)(({theme:e})=>({display:"flex",[e.breakpoints.down("sm")]:{flexDirection:"column"}})),F5=()=>{var F,N;const e=Q("projectId"),[n,a]=d.useState(!1),{user:r}=Ht(),{isAdmin:o}=d.useContext(ge),[i,c]=d.useState(""),l=Q("id"),{data:h,refetchChangeRequest:u}=i0(e,l),{changeState:g,addComment:f,loading:m}=r3(),{refetch:b}=a3(e),{setToastData:S,setToastApiError:x}=u1(),{isChangeRequestConfigured:Z}=u2(e);if(!h)return null;const v=Z(h.environment),j=async()=>{try{await g(e,Number(l),{state:"Applied"}),u(),b(),S({type:"success",title:"Success",text:"Changes applied"})}catch(_){x(f1(_))}},H=async()=>{try{await f(e,l,i),c(""),u(),S({type:"success",title:"Success",text:"Comment added"})}catch(_){x(f1(_))}},z=async()=>{try{await g(e,Number(l),{state:"Cancelled"}),a(!1),u(),b(),S({type:"success",title:"Success",text:"Changes cancelled"})}catch(_){x(f1(_))}},U=()=>a(!0),w=()=>a(!1),D=(h==null?void 0:h.createdBy.id)===(r==null?void 0:r.id)&&h.state==="In review"&&!o,O=h.approvals.some(_=>_.createdBy.id===(r==null?void 0:r.id));return s(G,{children:[t(fo,{changeRequest:h}),s(_5,{children:[s(D5,{children:[t(t5,{state:h.state}),t(i5,{header:t(o5,{actualApprovals:h.approvals.length,minApprovals:h.minApprovals}),children:(F=h.approvals)==null?void 0:F.map(_=>t(E5,{name:_.createdBy.username||"Unknown user",imageUrl:_.createdBy.imageUrl},_.createdBy.username))})]}),t(O5,{elevation:0,children:s(B5,{children:["Requested Changes (",En(h),")",t(Rn,{changeRequest:h,onRefetch:u}),(N=h.comments)==null?void 0:N.map(_=>t(I5,{comment:_},_.id)),t(j5,{user:r,commentText:i,onTypeComment:c,children:t(v1,{variant:"outlined",onClick:H,disabled:!v||i.trim().length===0||i.trim().length>1e3,children:"Comment"})}),t(C,{condition:D,show:t(U1,{sx:_=>({marginTop:_.spacing(1.5)}),severity:"info",children:"You can not approve your own change request"})}),t(h5,{changeRequest:h}),s($5,{children:[t(C,{condition:h.state==="In review"&&!O,show:t(x5,{disabled:!v})}),t(C,{condition:h.state==="Approved",show:t(o3,{variant:"contained",onClick:j,projectId:e,permission:kn,environmentId:h.environment,disabled:!v||m,children:"Apply changes"})}),t(C,{condition:h.state!=="Applied"&&h.state!=="Cancelled"&&(h.createdBy.id===(r==null?void 0:r.id)||o),show:t(v1,{sx:{marginLeft:_=>_.spacing(2)},variant:"outlined",onClick:U,children:"Cancel changes"})})]})]})}),s(ke,{open:n,onClick:z,onClose:w,title:"Cancel change request",children:[t(B,{sx:{marginBottom:2},children:"You are about to cancel this change request"}),t(B,{variant:"body2",sx:_=>({color:_.palette.neutral.dark}),children:"The change request will be moved to closed, and it can't be applied anymore. Once cancelled, the change request can't be reopened."})]})]})]})},V5=({value:e})=>{const n=()=>e?t(Mt,{state:e}):null;return e?t(i1,{children:n()}):t(i1,{})},M5=({value:e})=>t(i1,{children:t(v2,{user:e,sx:{maxWidth:"30px",maxHeight:"30px",alignSelf:"left"}})}),L5=p("div")(({theme:e})=>({display:"flex",flexDirection:"row",margin:0})),z5=({value:e,row:{original:n}})=>{const a=Q("projectId"),{id:r,features:o}=n,i=Pn(),c=`/projects/${a}/change-requests/${r}`;return e?s(i1,{sx:{minWidth:"200px"},children:[t(L5,{children:s(B,{component:"span",variant:"body2",color:i.palette.text.secondary,children:[t(e3,{component:R1,underline:"hover",to:c,sx:l=>({paddingTop:l.spacing(.2),marginRight:l.spacing(1),"&:hover":{textDecoration:"underline"}}),children:"Change request"}),`#${r}`]})}),s("span",{children:[`${o==null?void 0:o.length}`," ",o.length<=1?"update":"updates"]})]}):t(i1,{})},H5=xt()(e=>({header:{padding:e.spacing(0,4)},bodyClass:{padding:e.spacing(4),overflowX:"auto"}})),N5={id:"createdAt"},W5=p("div")({paddingLeft:0,paddingBottom:0}),U5=p(Ke)(({theme:e})=>({textTransform:"none",width:"auto",fontSize:e.fontSizes.bodySize,[e.breakpoints.up("md")]:{minWidth:160}})),q5=({changeRequests:e=[],loading:n,projectId:a})=>{var Y,y;const{classes:r}=H5(),o=g1(In.breakpoints.down("md")),[i,c]=t3(),[l,h]=d.useState(i.get("search")||""),{value:u,setValue:g}=c2(`${a}:ProjectChangeRequest`,N5),[f,m]=d.useMemo(()=>{const T=e.filter(I=>I.state!=="Cancelled"&&I.state!=="Applied"),V=e.filter(I=>I.state==="Cancelled"||I.state==="Applied");return[T,V]},[e]),b=[{title:"Change requests",data:f},{title:"Closed",data:m}],[S,x]=d.useState(0),Z=d.useMemo(()=>[{id:"Title",Header:"Title",width:100,canSort:!0,accessor:"id",Cell:z5},{Header:"By",accessor:"createdBy",maxWidth:50,canSort:!1,Cell:M5,align:"center"},{Header:"Submitted",accessor:"createdAt",searchable:!0,maxWidth:100,Cell:Ye,sortType:"alphanumeric"},{Header:"Environment",accessor:"environment",searchable:!0,maxWidth:100,Cell:i1},{Header:"Status",accessor:"state",searchable:!0,minWidth:150,width:150,Cell:V5}],[a]),{data:v,getSearchText:j,getSearchContext:H}=m2(Z,l,(Y=b[S])==null?void 0:Y.data),z=d.useMemo(()=>n?Zn:v,[v,n]),[U]=d.useState(()=>({sortBy:[{id:i.get("sort")||u.id,desc:i.has("order")?i.get("order")==="desc":u.desc}],hiddenColumns:[]})),{headerGroups:w,rows:D,state:{sortBy:O},prepareRow:F,setHiddenColumns:N,getTableProps:_,getTableBodyProps:K}=r1.useTable({columns:Z,data:z,initialState:U,sortTypes:Pe,autoResetHiddenColumns:!1,disableSortRemove:!0,autoResetSortBy:!1,defaultColumn:{Cell:i1}},r1.useSortBy);return f2([{condition:o,columns:["createdBy"]}],N,Z),d.useEffect(()=>{if(n)return;const T={};T.sort=O[0].id,O[0].desc&&(T.order="desc"),l&&(T.search=l),c(T,{replace:!0}),g(V=>({...V,id:O[0].id,desc:O[0].desc||!1}))},[n,O,l,c]),s(p1,{isLoading:n,bodyClass:r.bodyClass,headerClass:r.header,header:t(s1,{titleElement:t(W5,{children:t(i3,{value:(y=b[S])==null?void 0:y.title,indicatorColor:"primary",textColor:"primary",variant:"scrollable",allowScrollButtonsMobile:!0,children:b.map((T,V)=>t(U5,{label:`${T.title} (${T.data.length})`,value:T.title,onClick:()=>x(V)},T.title))})}),actions:t(x1,{initialValue:l,onChange:h,hasFilters:!0,getSearchContext:H})}),children:[t(se,{value:j(l),children:s(n2,{..._(),children:[t(a2,{headerGroups:w}),t(r2,{...K(),children:D.map(T=>(F(T),t(o2,{hover:!0,...T.getRowProps(),children:T.cells.map(V=>t(i2,{...V.getCellProps(),padding:"none",children:V.render("Cell")}))})))})]})}),t(C,{condition:D.length===0,show:()=>t(C,{condition:(l==null?void 0:l.length)>0,show:s(y1,{children:["No changes found matching “",l,"”"]}),elseShow:t(y1,{children:"None of the changes were submitted yet."})})})]})},G5=()=>{const e=Q("projectId"),n=k1(e),{isOss:a,isPro:r}=l1();T1(`Change requests – ${n}`);const{changeRequests:o,loading:i}=n0(e);return a()||r()?t(p1,{sx:{justifyContent:"center"},children:t(y2,{feature:"change-requests"})}):t(q5,{changeRequests:o,projectId:e,loading:i})};var q=(e=>(e.USER="USERS",e.GROUP="GROUPS",e.SERVICE_ACCOUNT="SERVICE ACCOUNTS",e))(q||{});const ye=(e,n={})=>{const a=q1(`api/admin/projects/${e}/access`),r=()=>fetch(a,{method:"GET"}).then(G1("project access")).then(f=>f.json()),o=`api/admin/projects/${e}/users`,{data:i,error:c}=ie(o,r,n),[l,h]=d.useState(!c&&!i),u=()=>{$t(o)};return d.useEffect(()=>{h(!c&&!i)},[i,c]),{access:d.useMemo(()=>{if(i)return K5({roles:i.roles,users:i.users.filter(({accountType:f})=>!f||f==="User"),serviceAccounts:i.users.filter(({accountType:f})=>f==="Service Account"),groups:(i==null?void 0:i.groups.map(f=>({...f,users:y4(f.users??[])})))??[]})},[i]),error:c,loading:l,refetchProjectAccess:u}},K5=e=>{const n=e.users||[],a=e.serviceAccounts||[],r=e.groups||[];return{...e,rows:[...n.map(o=>({entity:o,type:"USERS"})),...a.map(o=>({entity:o,type:"SERVICE ACCOUNTS"})),...r.map(o=>({entity:o,type:"GROUPS"}))]}},J5=p(p1)(({theme:e})=>({height:"100vh",overflow:"auto",padding:e.spacing(7.5,6),[e.breakpoints.down("md")]:{padding:e.spacing(4,2)},"& .header":{padding:e.spacing(0,0,2,0)},"& .body":{padding:e.spacing(3,0,0,0)},borderRadius:`${e.spacing(1.5,0,0,1.5)} !important`})),Y5=p("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span":{color:e.palette.text.secondary,fontSize:e.fontSizes.bodySize}})),U3={id:"joinedAt"},Z2=[{Header:"Avatar",accessor:"imageUrl",Cell:({row:{original:e}})=>t(i1,{children:t(v2,{user:e})}),maxWidth:85,disableSortBy:!0},{id:"name",Header:"Name",accessor:e=>e.name||"",Cell:Ee,minWidth:100,searchable:!0},{id:"username",Header:"Username",accessor:e=>e.username||e.email,Cell:Ee,minWidth:100,searchable:!0},{id:"joined",Header:"Joined",accessor:"joinedAt",Cell:h2,sortType:"date",maxWidth:150},{id:"lastLogin",Header:"Last login",accessor:e=>e.seenAt||"",Cell:({row:{original:e}})=>t(Ye,{value:e.seenAt,emptyText:"Never",title:n=>`Last login: ${n}`}),sortType:"date",maxWidth:150}],Q5=["imageUrl","name","joined","lastLogin"],X5=({open:e,setOpen:n,group:a,projectId:r,subtitle:o,onEdit:i,onRemove:c})=>{const l=h1(),h=g1(l.breakpoints.down("md")),[u]=d.useState(()=>({sortBy:[{id:U3.id,desc:U3.desc}]})),[g,f]=d.useState(""),{data:m,getSearchText:b,getSearchContext:S}=m2(Z2,g,(a==null?void 0:a.users)??[]),{headerGroups:x,rows:Z,prepareRow:v,setHiddenColumns:j}=r1.useTable({columns:Z2,data:m,initialState:u,sortTypes:Pe,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},r1.useSortBy,r1.useFlexLayout);return f2([{condition:h,columns:Q5}],j,Z2),t(ne,{open:e,onClose:()=>{n(!1)},label:(a==null?void 0:a.name)||"Group",children:s(J5,{header:t(s1,{secondary:!0,titleElement:s(Y5,{children:[a==null?void 0:a.name," (",Z.length<m.length?`${Z.length} of ${m.length}`:m.length,")",t("span",{children:o})]}),actions:s(G,{children:[t(C,{condition:!h,show:s(G,{children:[t(x1,{initialValue:g,onChange:f,hasFilters:!0,getSearchContext:S}),t(s1.Divider,{})]})}),t(N1,{permission:E1,projectId:r,tooltipProps:{title:"Edit group access"},onClick:i,children:t(s3,{})}),t(N1,{permission:E1,projectId:r,tooltipProps:{title:"Remove group access"},onClick:c,children:t(c3,{})})]}),children:t(C,{condition:h,show:t(x1,{initialValue:g,onChange:f,hasFilters:!0,getSearchContext:S})})}),children:[t(se,{value:b(g),children:t(g2,{rows:Z,headerGroups:x,prepareRow:v})}),t(C,{condition:Z.length===0,show:t(C,{condition:(g==null?void 0:g.length)>0,show:s(y1,{children:["No users found matching “",g,"” in this group."]}),elseShow:t(y1,{children:"This group is empty. Get started by adding a user to the group."})})})]})})},ei=({permissions:e})=>t(G,{children:e==null?void 0:e.filter(n=>!n.environment).map(n=>n.displayName).sort().map(n=>t("p",{children:n},n))}),ti=({environment:e,permissions:n})=>t(G,{children:[...new Set(n.filter(a=>a.environment===e).map(a=>a.displayName))].sort().map(a=>t("p",{children:a},`${e}-${a}`))}),ni=p("div",{shouldForwardProp:e=>e!=="roleId"&&e!=="popover"&&e!=="sx"})(({theme:e,popover:n})=>({width:"100%",maxWidth:e.spacing(50),padding:e.spacing(3),backgroundColor:n?e.palette.background.paper:e.palette.neutral.light,color:e.palette.text.secondary,fontSize:e.fontSizes.smallBody,borderRadius:e.shape.borderRadiusMedium})),j2=p("div")(({theme:e})=>({"& p:last-child":{marginBottom:e.spacing(2)}})),q3=p("p")(({theme:e})=>({color:e.palette.text.primary,fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.bold,marginBottom:e.spacing(2)})),G3=p("p")(({theme:e})=>({color:e.palette.text.primary,fontSize:e.fontSizes.smallBody,marginBottom:e.spacing(1)})),g0=d.forwardRef(({roleId:e,projectId:n,className:a,sx:r,...o},i)=>{var f;const{role:c}=b4(e.toString()),{access:l}=ye(n),h=l==null?void 0:l.roles.find(m=>m.id===e),u=d.useMemo(()=>{var b;const m=new Set;return(b=c.permissions)==null||b.filter(S=>S.environment).forEach(S=>{m.add(S.environment)}),[...m].sort()},[c]),g=d.useMemo(()=>{var m;return(m=c.permissions)==null?void 0:m.filter(b=>!b.environment)},[c]);return t(ni,{className:a,sx:r,...o,ref:i,children:t(C,{condition:((f=c.permissions)==null?void 0:f.length)>0,show:s(G,{children:[t(C,{condition:Boolean(g==null?void 0:g.length),show:s(G,{children:[t(q3,{children:"Project permissions"}),t(j2,{children:t(ei,{permissions:c.permissions})})]})}),t(C,{condition:Boolean(u.length),show:s(G,{children:[t(q3,{children:"Environment permissions"}),u.map(m=>s("div",{children:[t(G3,{children:m}),t(j2,{children:t(ti,{environment:m,permissions:c.permissions})})]},m))]})})]}),elseShow:s(G,{children:[t(G3,{children:h==null?void 0:h.name}),t(j2,{children:h==null?void 0:h.description})]})})})}),ai=p("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),K3=p("p")(({theme:e})=>({color:e.palette.text.secondary,marginBottom:e.spacing(1)})),J3=p("div")(({theme:e})=>({"& > div:first-of-type":{width:"100%",maxWidth:e.spacing(50),marginBottom:e.spacing(2)}})),ri=p("div")(({theme:e})=>({marginTop:e.spacing(6),display:"flex",justifyContent:"flex-end"})),oi=p(v1)(({theme:e})=>({marginLeft:e.spacing(3)})),ii=p("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span:last-of-type":{color:e.palette.text.secondary}})),si=p("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span:first-of-type":{color:e.palette.text.secondary}})),ci=p("div")(({theme:e})=>({display:"flex",flexDirection:"column","& > span:last-of-type":{fontSize:e.fontSizes.smallerBody,color:e.palette.text.secondary}})),C3=({selected:e,accesses:n,users:a,serviceAccounts:r,groups:o,roles:i})=>{const{uiConfig:c}=l1(),{flags:l}=c,h=l.UG?"user / group":"user",u=Q("projectId"),{refetchProjectAccess:g}=ye(u),{addAccessToProject:f,changeUserRole:m,changeGroupRole:b,loading:S}=s2(),x=Boolean(e),{setToastData:Z,setToastApiError:v}=u1(),j=_1(),H=[...o.filter(y=>x||!n.some(({entity:{id:T},type:V})=>y.id===T&&V===q.GROUP)).map(y=>({id:y.id,entity:y,type:q.GROUP})),...a.filter(y=>x||!n.some(({entity:{id:T},type:V})=>y.id===T&&V===q.USER)).sort((y,T)=>{const V=y.name||y.username||"",I=T.name||T.username||"";return V.localeCompare(I)}).map(y=>({id:y.id,entity:y,type:q.USER})),...r.filter(y=>x||!n.some(({entity:{id:T},type:V})=>y.id===T&&V===q.SERVICE_ACCOUNT)).sort((y,T)=>{const V=y.name||y.username||"",I=T.name||T.username||"";return V.localeCompare(I)}).map(y=>({id:y.id,entity:y,type:q.SERVICE_ACCOUNT}))],[z,U]=d.useState(()=>H.filter(({id:y,type:T})=>y===(e==null?void 0:e.entity.id)&&T===(e==null?void 0:e.type))),[w,D]=d.useState(i.find(({id:y})=>y===(e==null?void 0:e.entity.roleId))??null),O={users:z==null?void 0:z.filter(({type:y})=>y===q.USER||y===q.SERVICE_ACCOUNT).map(({id:y})=>({id:y})),groups:z==null?void 0:z.filter(({type:y})=>y===q.GROUP).map(({id:y})=>({id:y}))},F=async y=>{if(y.preventDefault(),!!Y)try{x?(e==null?void 0:e.type)===q.USER||(e==null?void 0:e.type)===q.SERVICE_ACCOUNT?await m(u,w.id,e.entity.id):(e==null?void 0:e.type)===q.GROUP&&await b(u,w.id,e.entity.id):await f(u,w.id,O),g(),j($1),Z({title:`${z.length} ${z.length===1?"access":"accesses"} ${x?"edited":"assigned"} successfully`,type:"success"})}catch(T){v(f1(T))}},N=()=>x?`curl --location --request ${x?"PUT":"POST"} '${c.unleashUrl}/api/admin/projects/${u}/${(e==null?void 0:e.type)===q.USER||(e==null?void 0:e.type)===q.SERVICE_ACCOUNT?"users":"groups"}/${e==null?void 0:e.entity.id}/roles/${w==null?void 0:w.id}' \\
3
3
  --header 'Authorization: INSERT_API_KEY'`:`curl --location --request ${x?"PUT":"POST"} '${c.unleashUrl}/api/admin/projects/${u}/role/${w==null?void 0:w.id}/access' \\
4
4
  --header 'Authorization: INSERT_API_KEY' \\