unleash-server 4.22.0 → 4.23.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/lib/db/project-store.js +3 -5
  2. package/dist/lib/db/project-store.js.map +1 -1
  3. package/frontend/build/index.html +1 -1
  4. package/frontend/build/static/{CreateProject-79087949.js → CreateProject-fd48f8ba.js} +1 -1
  5. package/frontend/build/static/{Error-b8ec37c0.js → Error-57edb730.js} +1 -1
  6. package/frontend/build/static/{ExpandMore-4c20b51c.js → ExpandMore-755ec693.js} +1 -1
  7. package/frontend/build/static/{FeatureArchiveDialog-b81c4e16.js → FeatureArchiveDialog-bf1868f0.js} +1 -1
  8. package/frontend/build/static/FeatureMetricsChart-8054718f.js +1 -0
  9. package/frontend/build/static/{FeatureViewLazyExport-10ea877c.js → FeatureViewLazyExport-74c55767.js} +2 -2
  10. package/frontend/build/static/{LazyAdminExport-0f2734aa.js → LazyAdminExport-742c5337.js} +2 -2
  11. package/frontend/build/static/{LazyProjectExport-cb47b897.js → LazyProjectExport-cfec09be.js} +1 -1
  12. package/frontend/build/static/{NetworkOverview-8b64cc40.js → NetworkOverview-c2a8d0f8.js} +64 -64
  13. package/frontend/build/static/NetworkTraffic-1d06a0ff.js +1 -0
  14. package/frontend/build/static/{Playground-4e2c6704.js → Playground-02573199.js} +1 -1
  15. package/frontend/build/static/{StrategyItemContainer-d93244f3.js → StrategyItemContainer-905f3f96.js} +1 -1
  16. package/frontend/build/static/{chartjs-adapter-date-fns.esm-24250637.js → chartjs-adapter-date-fns.esm-42d2aa6d.js} +1 -1
  17. package/frontend/build/static/{index-32a0dc63.js → index-08eccda8.js} +1 -1
  18. package/frontend/build/static/{index-fe84ab30.js → index-4f0aab89.js} +1 -1
  19. package/frontend/build/static/{index-c4e310cb.js → index-b8a4d792.js} +70 -70
  20. package/frontend/build/static/logoBg-3fc9c711.svg +1 -0
  21. package/frontend/build/static/logoWhiteBg-dacde9ce.svg +1 -0
  22. package/frontend/build/static/{unknownify-8af014d5.js → unknownify-a5879289.js} +1 -1
  23. package/frontend/build/static/{useProjectRole-08992a4c.js → useProjectRole-4ce2a494.js} +1 -1
  24. package/package.json +1 -1
  25. package/frontend/build/static/FeatureMetricsChart-37e55387.js +0 -1
  26. package/frontend/build/static/NetworkTraffic-38cef6f4.js +0 -1
  27. package/frontend/build/static/logoBg-6e3a3ec3.svg +0 -1
  28. package/frontend/build/static/logoPlain-b10e04a3.svg +0 -6
  29. package/frontend/build/static/logoWhiteBg-41a11888.svg +0 -7
@@ -268,14 +268,12 @@ class ProjectStore {
268
268
  return members;
269
269
  }
270
270
  async getProjectsByUser(userId) {
271
- const members = await this.db
271
+ const projects = await this.db
272
272
  .from((db) => {
273
273
  db.select('project')
274
274
  .from('role_user')
275
275
  .leftJoin('roles', 'role_user.role_id', 'roles.id')
276
- .where('type', 'root')
277
- .andWhere('name', 'Editor')
278
- .andWhere('user_id', userId)
276
+ .where('user_id', userId)
279
277
  .union((queryBuilder) => {
280
278
  queryBuilder
281
279
  .select('project')
@@ -286,7 +284,7 @@ class ProjectStore {
286
284
  .as('query');
287
285
  })
288
286
  .pluck('project');
289
- return members;
287
+ return projects;
290
288
  }
291
289
  async getMembersCountByProject(projectId) {
292
290
  const members = await this.db
@@ -1 +1 @@
1
- {"version":3,"file":"project-store.js","sourceRoot":"","sources":["../../../src/lib/db/project-store.ts"],"names":[],"mappings":";;;;;AAGA,6EAAoD;AAgBpD,kCAAsC;AACtC,4EAAmD;AACnD,oDAA2C;AAK3C,MAAM,OAAO,GAAG;IACZ,IAAI;IACJ,MAAM;IACN,aAAa;IACb,YAAY;IACZ,QAAQ;IACR,YAAY;CACf,CAAC;AACF,MAAM,KAAK,GAAG,UAAU,CAAC;AACzB,MAAM,gBAAgB,GAAG,CAAC,cAAc,CAAC,CAAC;AAC1C,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAY1C,MAAM,YAAY;IASd,YACI,EAAM,EAC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AAE,GAAG,CAAC,WAAW;YAC5B,SAAS,EAAE,GAAG,CAAC,UAAU;YACzB,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,GAAG;YACzB,SAAS,EAAE,GAAG,CAAC,UAAU,IAAI,IAAI,IAAI,EAAE;YACvC,IAAI,EAAE,GAAG,CAAC,YAAY,IAAI,MAAM;SACnC,CAAC;IACN,CAAC;CACJ;AAED,kBAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"project-store.js","sourceRoot":"","sources":["../../../src/lib/db/project-store.ts"],"names":[],"mappings":";;;;;AAGA,6EAAoD;AAgBpD,kCAAsC;AACtC,4EAAmD;AACnD,oDAA2C;AAK3C,MAAM,OAAO,GAAG;IACZ,IAAI;IACJ,MAAM;IACN,aAAa;IACb,YAAY;IACZ,QAAQ;IACR,YAAY;CACf,CAAC;AACF,MAAM,KAAK,GAAG,UAAU,CAAC;AACzB,MAAM,gBAAgB,GAAG,CAAC,cAAc,CAAC,CAAC;AAC1C,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAY1C,MAAM,YAAY;IASd,YACI,EAAM,EACN,QAAsB,EACtB,SAAsB,EACtB,YAA2B;QAE3B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,kBAAkB,CAAC,CAAC;QAC5C,IAAI,CAAC,KAAK,GAAG,CAAC,MAAM,EAAE,EAAE,CACpB,wBAAa,CAAC,SAAS,CAAC,QAAQ,EAAE,uBAAO,EAAE;YACvC,KAAK,EAAE,SAAS;YAChB,MAAM;SACT,CAAC,CAAC;QACP,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAED,6EAA6E;IAC7E,UAAU,CAAC,IAAI;QACX,OAAO;YACH,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;SAChC,CAAC;IACN,CAAC;IAED,OAAO,KAAU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AAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,cAAc,CAAC,GAAyB;QACpC,OAAO;YACH,iBAAiB,EAAE,GAAG,EAAE,kBAAkB,IAAI,SAAS;YACvD,IAAI,EAAE,GAAG,EAAE,YAAY,IAAI,MAAM;SACpC,CAAC;IACN,CAAC;IAED,6EAA6E;IAC7E,UAAU,CAAC,GAAG;QACV,OAAO;YACH,eAAe,EAAE,GAAG,CAAC,gBAAgB;YACrC,SAAS,EAAE,GAAG,CAAC,UAAU;SAC5B,CAAC;IACN,CAAC;IAED,6EAA6E;IAC7E,MAAM,CAAC,GAAG;QACN,IAAI,CAAC,GAAG,EAAE;YACN,MAAM,IAAI,wBAAa,CAAC,kBAAkB,CAAC,CAAC;SAC/C;QAED,OAAO;YACH,EAAE,EAAE,GAAG,CAAC,EAAE;YACV,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,SAAS,EAAE,GAAG,CAAC,UAAU;YACzB,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,GAAG;YACzB,SAAS,EAAE,GAAG,CAAC,UAAU,IAAI,IAAI,IAAI,EAAE;YACvC,IAAI,EAAE,GAAG,CAAC,YAAY,IAAI,MAAM;SACnC,CAAC;IACN,CAAC;CACJ;AAED,kBAAe,YAAY,CAAC"}
@@ -16,7 +16,7 @@
16
16
  href="https://fonts.googleapis.com/css2?family=Sen:wght@400;700;800&display=swap"
17
17
  rel="stylesheet"
18
18
  />
19
- <script type="module" crossorigin src="/static/index-c4e310cb.js"></script>
19
+ <script type="module" crossorigin src="/static/index-b8a4d792.js"></script>
20
20
  <link rel="stylesheet" href="/static/index-870c8122.css">
21
21
  </head>
22
22
  <body>
@@ -1,4 +1,4 @@
1
- import{a2 as k,aq as R,H as w,ar as O,as as U,at as D,au as J,j as e,av as b,aw as x,ax as B,ay as F,az as L,a4 as K,aA as $}from"./index-c4e310cb.js";const q="CREATE_PROJECT_BTN",Y=()=>{const{setToastData:n,setToastApiError:i}=k(),{refetchUser:d}=R(),{uiConfig:l}=w(),t=O(),{trackEvent:u}=U(),{projectId:a,projectName:j,projectMode:p,projectDesc:m,setProjectId:P,setProjectName:C,setProjectDesc:T,getProjectPayload:o,clearErrors:r,validateProjectId:s,validateName:h,setProjectStickiness:E,setProjectMode:f,projectStickiness:c,errors:g}=D(),{createProject:A,loading:_}=J();return e(b,{loading:_,title:"Create project",description:"Projects allows you to group feature toggles together in the management UI.",documentationLink:"https://docs.getunleash.io/reference/projects",documentationLinkLabel:"Projects documentation",formatApiCode:()=>`curl --location --request POST '${l.unleashUrl}/api/admin/projects' \\
1
+ import{a2 as k,aq as R,H as w,ar as O,as as U,at as D,au as J,j as e,av as b,aw as x,ax as B,ay as F,az as L,a4 as K,aA as $}from"./index-b8a4d792.js";const q="CREATE_PROJECT_BTN",Y=()=>{const{setToastData:n,setToastApiError:i}=k(),{refetchUser:d}=R(),{uiConfig:l}=w(),t=O(),{trackEvent:u}=U(),{projectId:a,projectName:j,projectMode:p,projectDesc:m,setProjectId:P,setProjectName:C,setProjectDesc:T,getProjectPayload:o,clearErrors:r,validateProjectId:s,validateName:h,setProjectStickiness:E,setProjectMode:f,projectStickiness:c,errors:g}=D(),{createProject:A,loading:_}=J();return e(b,{loading:_,title:"Create project",description:"Projects allows you to group feature toggles together in the management UI.",documentationLink:"https://docs.getunleash.io/reference/projects",documentationLinkLabel:"Projects documentation",formatApiCode:()=>`curl --location --request POST '${l.unleashUrl}/api/admin/projects' \\
2
2
  --header 'Authorization: INSERT_API_KEY' \\
3
3
  --header 'Content-Type: application/json' \\
4
4
  --data-raw '${JSON.stringify(o(),void 0,2)}'`,children:e(x,{errors:g,handleSubmit:async N=>{N.preventDefault(),r();const v=h(),y=await s();if(v&&y){const S=o();try{await A(S),d(),t(`/projects/${a}`),n({title:"Project created",text:"Now you can add toggles to this project",confetti:!0,type:"success"}),c!==L&&u("project_stickiness_set")}catch(I){i(K(I))}}},handleCancel:()=>{t($)},projectId:a,setProjectId:P,projectName:j,projectMode:p,projectStickiness:c,setProjectStickiness:E,setProjectMode:f,setProjectName:C,projectDesc:m,setProjectDesc:T,mode:"Create",clearErrors:r,validateProjectId:s,children:e(B,{name:"project",permission:F,"data-testid":q})})})};export{Y as default};
@@ -1 +1 @@
1
- import{c as r,j as o}from"./index-c4e310cb.js";const a=r(o("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}),"Error");export{a as E};
1
+ import{c as r,j as o}from"./index-b8a4d792.js";const a=r(o("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}),"Error");export{a as E};
@@ -1 +1 @@
1
- import{c as a,j as o}from"./index-c4e310cb.js";const e=a(o("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore");export{e as E};
1
+ import{c as a,j as o}from"./index-b8a4d792.js";const e=a(o("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore");export{e as E};
@@ -1,4 +1,4 @@
1
- import{c as _,j as n,aI as F,b1 as k,f as v,a_ as x,C as A,A as te,T as w,b_ as ae,cp as $,r as y,cq as ne,cr as se,a$ as re,b0 as j,a2 as E,H as oe,ar as N,aJ as z,aV as ce,cs as ie,av as le,ap as ue,ct as ge,cu as de,cv as he,cw as pe,b8 as H,cx as ye,b2 as me,a4 as R,cy as fe,s as P,aZ as ve,cz as Te,cA as be,F as U,cB as Se,cC as Ce,cD as Ae,ad as W,ac as Y,bJ as we,c1 as Re,cE as xe,w as Ee,cF as qe,cG as Fe,u as ke,Z as Pe,bF as Be,aU as De,aS as Oe,aT as Le,bB as I,au as $e}from"./index-c4e310cb.js";const Ke=_(n("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"),Ze=_(n("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"),Qe=({isOpen:e,onConfirm:t,onClose:s,showBanner:o,environment:a,messageComponent:r})=>{const i=F("projectId"),{data:h}=k(i),{changeRequestInReviewOrApproved:l,alert:u}=ae(h),d=l(a||"");return v(x,{open:e,primaryButtonText:d?"Add to existing change request":"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:t,onClose:s,title:"Request changes",fullWidth:!0,children:[n(A,{condition:d,show:u}),n(A,{condition:Boolean(o),show:v(te,{severity:"info",sx:{mb:2},children:["Change requests feature is enabled for ",a,". Your changes need to be approved before they will be live. All the changes you do now will be added into a draft that you can submit for review."]})}),n(w,{variant:"body2",color:"text.secondary",children:"Your suggestion:"}),r]})},ze=(e,t)=>{const s={};return t.parameters.forEach(o=>{s[o.name]=Ve(e,o)}),{name:t.name,constraints:[],parameters:s}},Ve=(e,t)=>t.name==="rollout"||t.name==="percentage"||t.type==="percentage"?"50":t.name==="stickiness"?"":t.name==="groupId"?e:t.type==="boolean"?"false":"",Xe=()=>{const e=F("projectId"),t=F("featureId"),s=$("environmentId"),o=$("strategyName"),[a,r]=y.useState({}),[i,h]=y.useState([]),{strategyDefinition:l}=ne(o),u=se(),{addStrategyToFeature:d,loading:m}=re(),{addChange:c}=j(),{setToastData:g,setToastApiError:T}=E(),{uiConfig:p}=oe(),{unleashUrl:f}=p,b=N(),{feature:S,refetchFeature:D}=z(e,t),O=y.useRef(S),{isChangeRequestConfigured:L}=ce(e),{refetch:G}=k(e),{data:q,staleDataNotification:J,forceRefreshCache:K}=ie({unleashGetter:z,params:[e,t],dataKey:"feature",refetchFunctionKey:"refetchFeature",options:{}},S,{afterSubmitAction:D},fe);y.useEffect(()=>{O.current.name===""&&S.name&&(K(S),O.current=S)},[S]),y.useEffect(()=>{l&&r(ze(t,l))},[t,l]);const Z=async C=>{await d(e,t,s,C),g({title:"Strategy created",type:"success",confetti:!0})},Q=async C=>{await c(e,s,{action:"addStrategy",feature:t,payload:C}),g({title:"Strategy added to draft",type:"success",confetti:!0}),G()},X=async()=>{const C=ye(a,i);try{L(s)?await Q(C):await Z(C),D(),b(me(e,t))}catch(ee){T(R(ee))}};return!q||!q.project?null:v(le,{modal:!0,title:ue(o),description:ge,documentationLink:de,documentationLinkLabel:he,formatApiCode:()=>je(e,t,s,a,f),children:[n(pe,{projectId:e,feature:q,strategy:a,setStrategy:r,segments:i,setSegments:h,environmentId:s,onSubmit:X,loading:m,permission:H,errors:u,isChangeRequest:L(s)}),J]})},_e=(e,t,s,o)=>{const a=new URLSearchParams({environmentId:s,strategyName:o});return`/projects/${e}/features/${t}/strategies/create?${a}`},je=(e,t,s,o,a)=>{if(!a)return"";const r=`${a}/api/admin/projects/${e}/features/${t}/environments/${s}/strategies`,i=JSON.stringify(o,void 0,2);return`curl --location --request POST '${r}' \\
1
+ import{c as _,j as n,aI as F,b1 as k,f as v,a_ as x,C as A,A as te,T as w,b_ as ae,cp as $,r as y,cq as ne,cr as se,a$ as re,b0 as j,a2 as E,H as oe,ar as N,aJ as z,aV as ce,cs as ie,av as le,ap as ue,ct as ge,cu as de,cv as he,cw as pe,b8 as H,cx as ye,b2 as me,a4 as R,cy as fe,s as P,aZ as ve,cz as Te,cA as be,F as U,cB as Se,cC as Ce,cD as Ae,ad as W,ac as Y,bJ as we,c1 as Re,cE as xe,w as Ee,cF as qe,cG as Fe,u as ke,Z as Pe,bF as Be,aU as De,aS as Oe,aT as Le,bB as I,au as $e}from"./index-b8a4d792.js";const Ke=_(n("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"),Ze=_(n("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"),Qe=({isOpen:e,onConfirm:t,onClose:s,showBanner:o,environment:a,messageComponent:r})=>{const i=F("projectId"),{data:h}=k(i),{changeRequestInReviewOrApproved:l,alert:u}=ae(h),d=l(a||"");return v(x,{open:e,primaryButtonText:d?"Add to existing change request":"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:t,onClose:s,title:"Request changes",fullWidth:!0,children:[n(A,{condition:d,show:u}),n(A,{condition:Boolean(o),show:v(te,{severity:"info",sx:{mb:2},children:["Change requests feature is enabled for ",a,". Your changes need to be approved before they will be live. All the changes you do now will be added into a draft that you can submit for review."]})}),n(w,{variant:"body2",color:"text.secondary",children:"Your suggestion:"}),r]})},ze=(e,t)=>{const s={};return t.parameters.forEach(o=>{s[o.name]=Ve(e,o)}),{name:t.name,constraints:[],parameters:s}},Ve=(e,t)=>t.name==="rollout"||t.name==="percentage"||t.type==="percentage"?"50":t.name==="stickiness"?"":t.name==="groupId"?e:t.type==="boolean"?"false":"",Xe=()=>{const e=F("projectId"),t=F("featureId"),s=$("environmentId"),o=$("strategyName"),[a,r]=y.useState({}),[i,h]=y.useState([]),{strategyDefinition:l}=ne(o),u=se(),{addStrategyToFeature:d,loading:m}=re(),{addChange:c}=j(),{setToastData:g,setToastApiError:T}=E(),{uiConfig:p}=oe(),{unleashUrl:f}=p,b=N(),{feature:S,refetchFeature:D}=z(e,t),O=y.useRef(S),{isChangeRequestConfigured:L}=ce(e),{refetch:G}=k(e),{data:q,staleDataNotification:J,forceRefreshCache:K}=ie({unleashGetter:z,params:[e,t],dataKey:"feature",refetchFunctionKey:"refetchFeature",options:{}},S,{afterSubmitAction:D},fe);y.useEffect(()=>{O.current.name===""&&S.name&&(K(S),O.current=S)},[S]),y.useEffect(()=>{l&&r(ze(t,l))},[t,l]);const Z=async C=>{await d(e,t,s,C),g({title:"Strategy created",type:"success",confetti:!0})},Q=async C=>{await c(e,s,{action:"addStrategy",feature:t,payload:C}),g({title:"Strategy added to draft",type:"success",confetti:!0}),G()},X=async()=>{const C=ye(a,i);try{L(s)?await Q(C):await Z(C),D(),b(me(e,t))}catch(ee){T(R(ee))}};return!q||!q.project?null:v(le,{modal:!0,title:ue(o),description:ge,documentationLink:de,documentationLinkLabel:he,formatApiCode:()=>je(e,t,s,a,f),children:[n(pe,{projectId:e,feature:q,strategy:a,setStrategy:r,segments:i,setSegments:h,environmentId:s,onSubmit:X,loading:m,permission:H,errors:u,isChangeRequest:L(s)}),J]})},_e=(e,t,s,o)=>{const a=new URLSearchParams({environmentId:s,strategyName:o});return`/projects/${e}/features/${t}/strategies/create?${a}`},je=(e,t,s,o,a)=>{if(!a)return"";const r=`${a}/api/admin/projects/${e}/features/${t}/environments/${s}/strategies`,i=JSON.stringify(o,void 0,2);return`curl --location --request POST '${r}' \\
2
2
  --header 'Authorization: INSERT_API_KEY' \\
3
3
  --header 'Content-Type: application/json' \\
4
4
  --data-raw '${i}'`},V=P("p")(({theme:e})=>({marginBottom:e.spacing(.5),fontSize:e.fontSizes.bodySize})),et=({open:e,environmentName:t,featureId:s,projectId:o,onClose:a})=>{const r=N(),i=_e(o,s,t,"default");return v(x,{open:e,maxWidth:"sm",onClose:()=>a(),title:"You need to add a strategy to your toggle",primaryButtonText:"Take me directly to add strategy",permissionButton:n(ve,{type:"button",permission:H,projectId:o,environmentId:t,onClick:()=>{a(),r(i)},children:"Take me directly to add strategy"}),secondaryButtonText:"Cancel",children:[n(V,{children:"Before you can enable the toggle in the environment, you need to add an activation strategy."}),n(V,{children:"You can add the activation strategy by selecting the toggle, open the environment accordion and add the activation strategy."})]})},tt="You can not enable the environment before it has strategies",at=e=>{const{setToastData:t,setToastApiError:s}=E(),{addChange:o}=j(),{refetch:a}=k(e),[r,i]=y.useState({isOpen:!1}),h=y.useCallback((d,m,c)=>{i({featureName:d,environment:m,enabled:c,isOpen:!0})},[]),l=y.useCallback(()=>{i(d=>({...d,isOpen:!1}))},[]),u=y.useCallback(async()=>{try{await o(e,r.environment,{feature:r.featureName,action:"updateEnabled",payload:{enabled:Boolean(r.enabled)}}),a(),i(d=>({...d,isOpen:!1})),t({type:"success",title:"Changes added to the draft!"})}catch(d){s(R(d)),i(m=>({...m,isOpen:!1}))}},[o]);return{onChangeRequestToggle:h,onChangeRequestToggleClose:l,onChangeRequestToggleConfirm:u,changeRequestDialogDetails:r}},nt=({enabled:e,featureName:t,environment:s})=>v(w,{"data-testid":"update-enabled-message",children:[n("strong",{children:e?"Enable":"Disable"})," feature toggle"," ",n("strong",{children:t})," in ",n("strong",{children:s})]}),Ne=P(Te)(({theme:e})=>({color:e.palette.warning.main,fontSize:e.fontSizes.bodySize})),st=()=>n(be,{arrow:!0,title:v(U,{children:["This environment has no variants enabled. If you check this feature's variants in this environment, you will get the"," ",n("a",{href:"https://docs.getunleash.io/reference/feature-toggle-variants#the-disabled-variant",target:"_blank",rel:"noreferrer",children:"disabled variant"}),"."]}),children:n(Ne,{})});var B={},He=Ce;Object.defineProperty(B,"__esModule",{value:!0});var M=B.default=void 0,Ue=He(Se()),We=Ae,Ye=(0,Ue.default)((0,We.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10H7v-2h10v2z"}),"IndeterminateCheckBox");M=B.default=Ye;const Ie=qe(),rt=({options:e,selectedOptions:t,indeterminateOptions:s,tagType:o,existingTags:a,disabled:r=!1,onChange:i})=>{const h=n(Fe,{fontSize:"small"});return n(W,{multiple:!0,id:"checkboxes-tag",sx:{marginTop:c=>c.spacing(2),width:500},disableCloseOnSelect:!0,placeholder:"Select Values",options:e,value:t,renderTags:(c,g)=>c.map((T,p)=>a.some(b=>b.value===T.title&&b.type===o.name)&&s===void 0?null:n(Ee,{...g({index:p}),label:T.title})),isOptionEqualToValue:(c,g)=>g.inputValue&&g.inputValue!==""?c.title===g.inputValue:c.title===g.title,getOptionLabel:c=>c.inputValue?c.inputValue:c.title,renderOption:(c,g,{selected:T})=>{const p=(s==null?void 0:s.some(f=>f.title===g.title))??!1;return v("li",{...c,children:[n(A,{condition:Boolean(g.inputValue),show:n(we,{sx:{mr:f=>f.spacing(.5)}}),elseShow:n(Re,{icon:h,checkedIcon:n(xe,{fontSize:"small"}),indeterminateIcon:n(M,{fontSize:"small"}),sx:{mr:f=>f.spacing(.5)},checked:T&&!p,indeterminate:p})}),g.title]})},filterOptions:(c,g)=>{const T=Ie(c,g),{inputValue:p}=g,f=c.some(b=>p===b.title);return p!==""&&!f&&T.push({inputValue:p,title:`Create new value "${p}"`}),T},ListboxProps:{style:{maxHeight:200,overflow:"auto"}},onChange:i,renderInput:c=>n(Y,{...c,label:"Select values",placeholder:"Select values"}),disabled:r})},Me=P("li")({flexDirection:"column"}),ot=({options:e,value:t,disabled:s=!1,onChange:o})=>{const a=ke();return n(W,{disablePortal:!0,disabled:s,id:"tag-type-select",sx:{marginTop:r=>r.spacing(2),width:500},options:e,disableClearable:!0,value:t,getOptionLabel:r=>r.name,renderOption:(r,i)=>v(Me,{...r,style:{alignItems:"flex-start",gap:a.spacing(.5)},children:[n(w,{variant:"body1",children:i.name}),n(w,{variant:"caption",children:i.description})]}),renderInput:r=>n(Y,{...r,label:"Tag type",value:t}),onChange:o,ListboxProps:{style:{maxHeight:200,overflow:"auto"}}})},ct=()=>{const{makeRequest:e,createRequest:t,errors:s,loading:o}=Pe({propagateErrors:!0});return{createTag:async i=>{const l=t("api/admin/tags",{method:"POST",body:JSON.stringify(i)});try{return await e(l.caller,l.id)}catch(u){throw u}},bulkUpdateTags:async i=>{const l=t("api/admin/tags/features",{method:"PUT",body:JSON.stringify(i)});try{return await e(l.caller,l.id)}catch(u){throw u}},errors:s,loading:o}},it=(e,t={})=>{const s=async()=>{const u=Oe(`api/admin/tags/${e}`);return(await fetch(u,{method:"GET"}).then(Le("Tags"))).json()},o=`api/admin/tags/${e}`,{data:a,error:r}=Be(Boolean(e),{tags:[]},o,s,t),[i,h]=y.useState(!r&&!a),l=()=>{De(o)};return y.useEffect(()=>{h(!r&&!a)},[a,r]),{tags:(a==null?void 0:a.tags)||[],error:r,loading:i,refetch:l}},lt=({isStale:e,isOpen:t,projectId:s,featureId:o,onClose:a})=>{const{setToastData:r,setToastApiError:i}=E(),{patchFeatureToggle:h}=I(),l=n(w,{children:"Setting a toggle to stale marks it for cleanup"}),u=n(w,{children:"Setting a toggle to active marks it as in active use"}),d=e?"active":"stale",m=async c=>{c.stopPropagation();try{await h(s,o,[{op:"replace",path:"/stale",value:!e}]),a()}catch(g){i(R(g))}r(e?{type:"success",title:"And we're back!",text:"The toggle is no longer marked as stale."}:{type:"success",title:"A job well done.",text:"The toggle has been marked as stale."})};return n(x,{open:t,secondaryButtonText:"Cancel",primaryButtonText:`Flip to ${d}`,title:`Set feature state to ${d}`,onClick:m,onClose:a,children:n(A,{condition:e,show:u,elseShow:l})})},ut=({isOpen:e,onClose:t,onConfirm:s,projectId:o,featureIds:a})=>{const{archiveFeatureToggle:r}=I(),{archiveFeatures:i}=$e(),{setToastData:h,setToastApiError:l}=E(),u=(a==null?void 0:a.length)>1;return n(x,{onClick:u?async()=>{try{await i(o,a),h({text:"Selected feature toggles have been archived",type:"success",title:"Feature toggles archived"}),s(),t()}catch(c){l(R(c)),t()}}:async()=>{try{await r(o,a[0]),h({text:"Your feature toggle has been archived",type:"success",title:"Feature archived"}),s(),t()}catch(c){l(R(c)),t()}},open:e,onClose:t,primaryButtonText:u?"Archive toggles":"Archive toggle",secondaryButtonText:"Cancel",title:u?"Archive feature toggles":"Archive feature toggle",children:n(A,{condition:u,show:v(U,{children:[v("p",{children:["Are you sure you want to archive"," ",n("strong",{children:a==null?void 0:a.length})," feature toggles?"]}),n(A,{condition:(a==null?void 0:a.length)<=5,show:n("ul",{children:a==null?void 0:a.map(c=>n("li",{children:c},c))})})]}),elseShow:n("p",{children:"Are you sure you want to archive these feature toggles?"})})})};export{Ke as A,Qe as C,tt as E,Xe as F,ot as T,nt as U,st as V,Ze as W,et as a,ct as b,it as c,rt as d,ut as e,_e as f,lt as g,at as u};
@@ -0,0 +1 @@
1
+ import{fa as p,u as m,bw as g,r as l,j as d}from"./index-b8a4d792.js";import{d as c,L as x,C,a as f,b as S,P as h,c as q,T as k,p as v,e as M,f as L}from"./chartjs-adapter-date-fns.esm-42d2aa6d.js";import"./index-08eccda8.js";import"./index-4f0aab89.js";const P=(e,i,s)=>{const t={label:"total requests",borderColor:e.palette.primary.main,backgroundColor:e.palette.primary.main,data:n(i,s,o=>o.yes+o.no),elements:{point:{radius:6,pointStyle:"circle"},line:{borderDash:[8,4]}}},a={label:"exposed",borderColor:e.palette.success.main,backgroundColor:e.palette.success.main,data:n(i,s,o=>o.yes),elements:{point:{radius:6,pointStyle:"triangle"}}},r={label:"not exposed",borderColor:e.palette.error.main,backgroundColor:e.palette.error.main,data:n(i,s,o=>o.no),elements:{point:{radius:6,pointStyle:"triangle",pointRotation:180}}};return{datasets:[a,r,t]}},n=(e,i,s)=>e.map(t=>({x:t.timestamp,y:s(t)})),w=(e,i,s,t)=>({locale:t.locale,responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},color:e.palette.text.secondary,plugins:{tooltip:{backgroundColor:e.palette.background.paper,bodyColor:e.palette.text.primary,titleColor:e.palette.text.secondary,borderColor:e.palette.primary.main,borderWidth:1,padding:10,boxPadding:5,usePointStyle:!0,callbacks:{title:a=>p(a[0].parsed.x,t.locale)},itemSort:(a,r)=>r.parsed.y-a.parsed.y},legend:{position:"top",align:"end",labels:{boxWidth:10,boxHeight:10,usePointStyle:!0}},title:{text:R(s),position:"top",align:"start",display:!0,font:{size:16,weight:"400"},color:e.palette.text.primary}},scales:{y:{type:"linear",title:{display:!0,text:"Number of requests",color:e.palette.text.secondary},suggestedMin:0,ticks:{precision:0,color:e.palette.text.secondary},grid:{color:e.palette.divider,borderColor:e.palette.divider}},x:{type:"time",time:{unit:"hour"},grid:{display:!1},ticks:{callback:(a,r,o)=>p(o[r].value,t.locale),color:e.palette.text.secondary}}}}),R=e=>e===1?"Requests in the last hour":`Requests in the last ${e} hours`;c.font={...c.font,family:"Sen",size:13,weight:"400"};const j=({metrics:e,hoursBack:i,statsSectionId:s})=>{const t=m(),{locationSettings:a}=g(),r=l.useMemo(()=>[...e].sort((y,b)=>y.timestamp.localeCompare(b.timestamp)),[e]),o=l.useMemo(()=>w(t,r,i,a),[t,r,i,a]),u=l.useMemo(()=>P(t,r,a),[t,r,a]);return d("div",{style:{height:400},children:d(x,{options:o,data:u,"aria-label":"A feature metrics line chart, with three lines: all requests, positive requests, and negative requests.","aria-describedby":s})})};C.register(f,S,h,q,k,v,M,L);export{j as FeatureMetricsChart,j as default};
@@ -1,7 +1,7 @@
1
- import{aB as gn,aC as hn,s as d,r as f,aD as mn,aE as fn,aF as pt,j as t,aG as yn,aH as Sn,c as jt,aI as F,aJ as j,aK as bn,f as c,aL as Cn,C as I,aM as Q,aN as le,aO as J,aP as me,aQ as vn,aR as Qe,aS as be,aT as ke,aU as Ze,u as et,aV as oe,F as M,aW as gt,aX as ht,aY as tt,aZ as ae,a_ as de,T as N,a$ as Ce,a2 as G,ar as ge,b0 as nt,b1 as ve,A as he,b2 as Nt,a4 as z,b3 as wn,b4 as Tn,b5 as xn,b6 as An,ap as we,b7 as En,b8 as ue,b9 as ee,m as $e,ba as In,bb as Rn,bc as Pe,a8 as Be,bd as zt,be as Wt,bf as at,bg as Fn,bh as kn,bi as $n,a as H,p as Pn,N as De,B as fe,bj as ot,a9 as re,bk as Bn,x as st,an as Ie,E as Dn,bl as rt,bm as Re,P as On,bn as Vn,bo as ne,bp as Mn,bq as Ln,D as _n,br as jn,bs as Nn,bt as zn,bu as Ut,bv as Wn,bw as Un,bx as qn,by as Hn,bz as Gn,bA as Yn,bB as Te,bC as Kn,bD as Jn,bE as it,bF as Xn,bG as Qn,as as qt,bH as Zn,w as Ht,af as ye,bI as ea,bJ as ta,bK as Ye,bL as Gt,bM as Yt,bN as se,bO as Ke,bP as na,ac as Kt,bQ as Jt,a3 as ct,ad as aa,bR as oa,bS as Xt,bT as sa,bU as ra,bV as Qt,bW as ia,H as lt,bX as ca,av as la,bY as ce,bZ as mt,b_ as da,b$ as ua,c0 as pa,c1 as ga,ak as dt,al as ha,V as ft,c2 as ma,c3 as fa,c4 as ya,c5 as Zt,d as Le,l as Sa,U as ba,g as Ca,S as va,h as wa,i as Ta,k as xa,I as Aa,c6 as Ea,c7 as Ia,c8 as yt,c9 as Ra,ca as en,cb as Fa,ae as ka,cc as St,cd as $a,ce as Pa,cf as Ba,cg as Da,ch as Oa,ci as Va,M as Ma,cj as La,ck as _a,cl as ja,cm as Na,cn as za,co as Wa}from"./index-c4e310cb.js";import{C as Oe,f as Ua,u as qa,U as Ha,E as Ga,V as Ya,a as Ka,b as Ja,c as Xa,T as Qa,d as Za,F as eo,A as to,W as no,e as ao,g as oo}from"./FeatureArchiveDialog-b81c4e16.js";import{S as so}from"./StrategyItemContainer-d93244f3.js";import{E as ro}from"./ExpandMore-4c20b51c.js";import{v as _e}from"./v4-a960c1f4.js";function io(e){return gn("MuiCardContent",e)}hn("MuiCardContent",["root"]);const co=["className","component"],lo=e=>{const{classes:n}=e;return Sn({root:["root"]},io,n)},uo=d("div",{name:"MuiCardContent",slot:"Root",overridesResolver:(e,n)=>n.root})(()=>({padding:16,"&:last-child":{paddingBottom:24}})),po=f.forwardRef(function(n,a){const o=mn({props:n,name:"MuiCardContent"}),{className:s,component:i="div"}=o,r=fn(o,co),l=pt({},o,{component:i}),u=lo(l);return t(uo,pt({as:i,className:yn(u.root,s),ownerState:l,ref:a},r))}),go=po,ho=jt(t("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z"}),"Assessment"),mo=jt(t("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z"}),"Cloud"),fo=d("div")(({theme:e})=>({borderRadius:e.spacing(1.5),backgroundColor:e.palette.background.paper,padding:e.spacing(4)})),yo=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n);return a.name?t(fo,{children:t(bn,{title:"Event log",feature:n,displayInline:!0})}):null},So=d("div")(({theme:e})=>({borderRadius:e.shape.borderRadiusLarge,color:e.palette.primary.contrastText,backgroundColor:e.palette.background.alternative,display:"flex",flexDirection:"column",maxWidth:"350px",minWidth:"350px",marginRight:e.spacing(2),[e.breakpoints.down(1e3)]:{width:"100%",maxWidth:"none",minWidth:"auto"}})),bo=d("div")({padding:"1.5rem 1.5rem 0 1.5rem"}),Co=d("div")({display:"flex",alignItems:"center"}),vo=d("h2")(({theme:e})=>({fontSize:e.fontSizes.bodySize,fontWeight:"normal",margin:0})),wo=d("div")(({theme:e})=>({margin:e.spacing(2,0),display:"flex",flexDirection:"column"})),bt=d("span")(({theme:e})=>({margin:e.spacing(1,0),fontSize:e.fontSizes.bodySize,wordBreak:"break-all"})),Ct=d("div")(({theme:e})=>({display:"flex",alignItems:"center",color:e.palette.primary.contrastText})),To=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n),{project:o,description:s,type:i}=a,r=vn(i);return t(So,{children:c(bo,{children:[c(Co,{"data-loading":!0,children:[t(r,{sx:l=>({marginRight:l.spacing(2),height:"40px",width:"40px",fill:l.palette.primary.contrastText})})," ",c(vo,{children:[Cn(i||"")," toggle"]})]}),c(wo,{children:[c(bt,{"data-loading":!0,children:["Project: ",o]}),t(I,{condition:Boolean(s),show:c(bt,{"data-loading":!0,children:[t("div",{children:"Description:"}),c(Ct,{children:[t("p",{children:s}),t(Q,{projectId:e,permission:le,component:J,to:`/projects/${e}/features/${n}/settings`,tooltipProps:{title:"Edit description"},children:t(me,{sx:l=>({color:l.palette.primary.contrastText})})})]})]}),elseShow:t("span",{"data-loading":!0,children:c(Ct,{children:["No description."," ",t(Q,{projectId:e,permission:le,component:J,to:`/projects/${e}/features/${n}/settings`,tooltipProps:{title:"Edit description"},children:t(me,{sx:l=>({color:l.palette.primary.contrastText})})})]})})})]})]})})},vt={lastHourUsage:[],seenApplications:[]},xo=(e,n,a={})=>{const o=async()=>{const m=be(`api/admin/client-metrics/features/${n}`),g=await fetch(m,{method:"GET"}).then(ke("feature metrics"));return g.ok?g.json():vt},s=`${e}_${n}_metrics`,{data:i,error:r}=Qe(s,o,{...a}),[l,u]=f.useState(!r&&!i),p=()=>{Ze(s)};return f.useEffect(()=>{u(!r&&!i)},[i,r]),{metrics:i||vt,error:r,loading:l,refetch:p,FEATURE_METRICS_CACHE_KEY:s}},Ao=e=>({yes:0,no:0,environment:e,timestamp:""}),Eo=(e,n)=>e.map(a=>n.lastHourUsage.find(s=>s.environment===a.name)||Ao(a.name)),Io=({enabled:e,className:n})=>{const a=et(),o=e?"Environment enabled":"Environment disabled",s={backgroundColor:e?a.palette.primary.light:a.palette.neutral.border,borderRadius:"50%",width:"28px",height:"28px",minWidth:"28px",display:"flex",alignItems:"center",justifyContent:"center",marginRight:a.spacing(1)},i={fill:a.palette.common.white,width:"16px",height:"16px"};return t("div",{style:s,className:n,children:t(mo,{style:i,titleAccess:o})})},tn=()=>t(he,{severity:"error",children:"Removing the strategy will change which users receive access to the feature."}),Ro=({onRemove:e,onClose:n,isOpen:a})=>t(de,{title:"Are you sure you want to delete this strategy?",open:a,primaryButtonText:"Remove strategy",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:t(tn,{})}),Fo=d("div")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1)})),ko=({onRemove:e,onClose:n,isOpen:a})=>c(de,{title:"Suggest changes",open:a,primaryButtonText:"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:[t(tn,{}),t(Fo,{children:t(N,{variant:"body2",color:"text.secondary",children:"Your suggestion:"})}),t(N,{fontWeight:"bold",children:"Remove strategy"})]}),$o=({projectId:e,featureId:n,environmentId:a,strategyId:o})=>{const{deleteStrategyFromFeature:s}=Ce(),{setToastData:i,setToastApiError:r}=G(),l=ge(),{refetchFeature:u}=j(e,n);return async m=>{try{m.preventDefault(),await s(e,n,a,o),i({title:"Strategy deleted",type:"success"}),u(),l(Nt(e,n))}catch(g){r(z(g))}}},Po=({projectId:e,featureId:n,environmentId:a,strategyId:o})=>{const{addChange:s}=nt(),{refetch:i}=ve(e),{setToastData:r,setToastApiError:l}=G();return async p=>{try{p.preventDefault(),await s(e,a,{action:"deleteStrategy",feature:n,payload:{id:o}}),r({title:"Changes added to the draft!",type:"success"}),await i()}catch(m){l(z(m))}}},Bo=({projectId:e,featureId:n,environmentId:a,strategyId:o,disabled:s,icon:i})=>{const[r,l]=f.useState(!1),{isChangeRequestConfigured:u}=oe(e),p=$o({featureId:n,projectId:e,strategyId:o,environmentId:a}),m=Po({featureId:n,projectId:e,strategyId:o,environmentId:a});return c(M,{children:[t(I,{condition:Boolean(i),show:t(Q,{onClick:()=>l(!0),projectId:e,environmentId:a,disabled:s,permission:gt,"data-testid":ht,tooltipProps:{title:"Remove strategy"},type:"button",children:t(tt,{})}),elseShow:t(ae,{onClick:()=>l(!0),projectId:e,environmentId:a,disabled:s,permission:gt,"data-testid":ht,color:"secondary",variant:"text",type:"button",children:"Remove strategy"})}),t(I,{condition:u(a),show:t(ko,{isOpen:r,onClose:()=>l(!1),onRemove:async g=>{await m(g),l(!1)}}),elseShow:t(Ro,{isOpen:r,onClose:()=>l(!1),onRemove:p})})]})},Do=e=>(n,a,o)=>(o.revalidateOnFocus=!1,o.revalidateIfStale=!1,o.revalidateOnReconnect=!1,e(n,a,o));var Oo=wn(Qe,Do);const nn=(e,n)=>{const{refetchFeature:a}=j(e,n),o=Tn(e,n),{data:s,error:i,mutate:r}=Oo(["useFeatureImmutable",o],()=>xn(o)),l=f.useCallback(async()=>{await r(),await a()},[r,a]);return{feature:(s==null?void 0:s.body)||An,refetchFeature:l,loading:!i&&!s,status:s==null?void 0:s.status,error:i}},ut=(e,n,a)=>{const{setToastData:o,setToastApiError:s}=G(),{addChange:i}=nt(),{refetch:r}=ve(e),[l,u]=f.useState({isOpen:!1}),p=f.useCallback((x,A,y)=>{u({featureName:n,environment:x,fromEnvironment:y,strategy:A,isOpen:!0})},[]),m=f.useCallback((x,A,y)=>{u({featureName:n,environment:x,fromEnvironment:y,strategies:A,isOpen:!0})},[]),g=f.useCallback(()=>{u({isOpen:!1})},[]),S=f.useCallback(async()=>{try{await i(e,l.environment,{feature:l.featureName,action:a,payload:l.strategy}),r(),u({isOpen:!1}),o({type:"success",title:"Changes added to the draft!"})}catch(x){s(z(x)),u({isOpen:!1})}},[i]),C=f.useCallback(async()=>{try{await Promise.all(l.strategies.map(x=>i(e,l.environment,{feature:l.featureName,action:a,payload:x}))),r(),u({isOpen:!1}),o({type:"success",title:"Changes added to the draft!"})}catch(x){s(z(x)),u({isOpen:!1})}},[i]);return{onChangeRequestAddStrategy:p,onChangeRequestAddStrategies:m,onChangeRequestAddStrategyClose:g,onChangeRequestAddStrategyConfirm:S,onChangeRequestAddStrategiesConfirm:C,changeRequestDialogDetails:l}},Vo=({payload:e,fromEnvironment:n,environment:a})=>c(N,{children:[c("strong",{children:["Copy ",we((e==null?void 0:e.name)||"")," strategy"," "]})," ","from ",n," to ",a]}),Mo=({environmentId:e,environments:n,strategy:a})=>{const o=F("projectId"),s=F("featureId"),[i,r]=f.useState(null),l=Boolean(i),{addStrategyToFeature:u}=Ce(),{setToastData:p,setToastApiError:m}=G(),{refetchFeature:g}=j(o,s),{refetchFeature:S}=nn(o,s),C=()=>{r(null)},x=En(o),{isChangeRequestConfigured:A}=oe(o),{changeRequestDialogDetails:y,onChangeRequestAddStrategyClose:v,onChangeRequestAddStrategy:w,onChangeRequestAddStrategyConfirm:R}=ut(o,s,"addStrategy"),P=async $=>{const{id:O,...B}={...a,targetEnvironment:$};if(A($)){await w($,{id:O,...B},e);return}try{await u(o,s,$,a),g(),S(),p({title:"Strategy created",text:`Successfully copied a strategy to ${$}`,type:"success"})}catch(U){m(z(U))}C()},D=n.some($=>x(ue,$));return c("div",{children:[t(Oe,{isOpen:y.isOpen,onClose:v,environment:y==null?void 0:y.environment,onConfirm:R,messageComponent:t(Vo,{fromEnvironment:y.fromEnvironment,payload:y.strategy})}),t(ee,{title:`Copy to another environment${D?"":" (Access denied)"}`,children:t("div",{children:t($e,{size:"large",id:`copy-strategy-icon-menu-${a.id}`,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,onClick:$=>{r($.currentTarget)},"data-testid":In,disabled:!D,children:t(Rn,{})})})}),t(Pe,{id:"basic-menu",anchorEl:i,open:l,onClose:C,MenuListProps:{"aria-labelledby":`copy-strategy-icon-menu-${a.id}`},children:n.map($=>{const O=x(ue,$);return t(ee,{title:O?"":"You don't have access to add a strategy to this environment",children:t("div",{children:c(Be,{onClick:()=>P($),disabled:!O,children:[t(I,{condition:!O,show:t(zt,{children:t(Wt,{fontSize:"small"})})}),c(at,{children:["Copy to ",$]})]})})},$)})})]})},Lo=({environmentId:e,strategy:n,onDragStart:a,onDragEnd:o,otherEnvironments:s,orderNumber:i,headerChildren:r})=>{const l=F("projectId"),u=F("featureId"),p=Fn(l,u,e,n.id);return t(so,{strategy:n,onDragStart:a,onDragEnd:o,orderNumber:i,actions:c(M,{children:[r,t(I,{condition:Boolean(s&&(s==null?void 0:s.length)>0),show:()=>t(Mo,{environmentId:e,environments:s,strategy:n})}),t(Q,{permission:kn,environmentId:e,projectId:l,component:J,to:p,tooltipProps:{title:"Edit strategy"},children:t(me,{})}),t(Bo,{projectId:l,featureId:u,environmentId:e,strategyId:n.id,icon:!0})]}),children:t($n,{strategy:n})})},_o=(e,n,a,o)=>{const{data:s}=ve(e),i=s==null?void 0:s.find(u=>u.environment===a),r=i==null?void 0:i.features.find(u=>u.name===n);return r==null?void 0:r.changes.find(u=>u.action==="updateStrategy"||u.action==="deleteStrategy"?u.payload.id===o:!1)},jo=({strategy:e,index:n,environmentName:a,otherEnvironments:o,isDragging:s,onDragStartRef:i,onDragOver:r,onDragEnd:l})=>{const u=F("projectId"),p=F("featureId"),m=f.useRef(null),g=_o(u,p,a,e.id);return c(H,{ref:m,onDragOver:r(m,n),sx:{opacity:s?"0.5":"1"},children:[t(I,{condition:n>0,show:t(Pn,{text:"OR"})}),t(Lo,{strategy:e,environmentId:a,otherEnvironments:o,onDragStart:i(m,n),onDragEnd:l,orderNumber:n+1,headerChildren:t(No,{change:g})})]},e.id)},No=({change:e})=>{const n=et();return De(n.breakpoints.down("sm"))?null:c(H,{sx:{mr:1.5},children:[t(I,{condition:(e==null?void 0:e.action)==="updateStrategy",show:t(fe,{color:"warning",children:"Modified in draft"})}),t(I,{condition:(e==null?void 0:e.action)==="deleteStrategy",show:t(fe,{color:"error",children:"Deleted in draft"})})]})},zo=d("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",margin:"1rem 0",position:"relative","&:before":{content:'""',position:"absolute",top:"50%",transform:"translateY(-50%)",height:2,width:"100%",backgroundColor:e.palette.divider}})),Wo=d("span")(({theme:e})=>({fontSize:e.fontSizes.bodySize,textAlign:"center",padding:"0 1rem",background:e.palette.envAccordion.expanded,position:"relative",maxWidth:"80%",color:e.palette.text.primary})),an=({children:e})=>t(zo,{children:t(Wo,{children:e})}),Uo=({environmentId:e,environments:n,onClick:a})=>{const o=F("projectId"),[s,i]=f.useState(null),r=Boolean(s),{hasAccess:l}=f.useContext(ot),u=n.some(p=>l(ue,o,p));return c("div",{children:[t(ee,{title:u?"":"(Access denied)",children:t("div",{children:t(re,{id:`copy-all-strategies-${e}`,"aria-controls":r?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":r?"true":void 0,onClick:p=>{i(p.currentTarget)},disabled:!u,variant:"outlined",children:"Copy from another environment"})})}),t(Pe,{id:"basic-menu",anchorEl:s,open:r,onClose:()=>{i(null)},MenuListProps:{"aria-labelledby":`copy-all-strategies-${e}`},children:n.map(p=>{const m=l(ue,o,p);return t(ee,{title:m?"":"You don't have access to add a strategy to this environment",children:t("div",{children:c(Be,{onClick:()=>a(p),disabled:!m,children:[t(I,{condition:!m,show:t(zt,{children:t(Wt,{fontSize:"small"})})}),c(at,{children:["Copy from ",p]})]})})},p)})})]})},qo=d("div")(({theme:e})=>({"&>*:nth-child(n)":{margin:e.spacing(1,0)}})),Ho=({payload:e,fromEnvironment:n,environment:a})=>c(qo,{children:[t(N,{children:t("strong",{children:"Copy: "})}),e==null?void 0:e.map(o=>c(N,{children:[c("strong",{children:[we((o==null?void 0:o.name)||"")," strategy"," "]})," "]})),c(N,{children:["from ",n," to ",a]})]}),Go=({payload:e,environment:n})=>c(M,{children:[t(N,{component:"span",children:"Add "}),c("strong",{children:[we((e==null?void 0:e.name)||"")," strategy"]})," to ",t("strong",{children:n})]}),Yo=d(Bn)(({theme:e})=>({display:"flex",flexDirection:"column",borderRadius:e.shape.borderRadiusMedium})),wt=({title:e,children:n,featureId:a,projectId:o,environmentId:s,strategy:i,Icon:r,onAfterAddStrategy:l})=>{const{addStrategyToFeature:u}=Ce(),{setToastApiError:p}=G(),{isChangeRequestConfigured:m}=oe(o),{changeRequestDialogDetails:g,onChangeRequestAddStrategy:S,onChangeRequestAddStrategyConfirm:C,onChangeRequestAddStrategyClose:x}=ut(o,a,"addStrategy");return c(M,{children:[t(Yo,{variant:"outlined",children:c(go,{sx:{display:"flex",flexDirection:"column",flexGrow:1},children:[c(N,{variant:"body1",fontWeight:"medium",sx:{mb:.5,display:"flex",alignItems:"center"},children:[t(r,{color:"disabled",sx:{mr:1}})," ",e]}),t(N,{variant:"body2",color:"text.secondary",component:"p",children:n}),t(H,{sx:{ml:"auto",mt:"auto",pt:1,mr:{xs:"auto",sm:0}},children:t(ae,{permission:ue,projectId:o,environmentId:s,variant:"outlined",size:"small",onClick:async()=>{try{m(s)?S(s,i):(await u(o,a,s,i),l())}catch(y){p(z(y))}},children:"Use template"})})]})}),t(Oe,{isOpen:g.isOpen,onClose:x,environment:g==null?void 0:g.environment,onConfirm:C,messageComponent:t(Go,{environment:s,payload:g.strategy})})]})},Ko=d("div")(({theme:e})=>({width:e.spacing(4),height:"auto","& > svg":{fill:e.palette.primary.main},"& > div":{height:e.spacing(2),marginLeft:"-.75rem",color:e.palette.primary.main}})),Jo=d("div")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Xo=d(st)(({theme:e})=>({fontWeight:e.fontWeight.bold})),Qo=d(J)(({theme:e})=>({display:"grid",gridTemplateColumns:"3rem 1fr",width:"20rem",padding:e.spacing(2),color:"inherit",textDecoration:"inherit",lineHeight:1.25,borderWidth:"1px",borderStyle:"solid",borderColor:e.palette.divider,borderRadius:e.spacing(1),"&:hover, &:focus":{borderColor:e.palette.primary.main}})),Zo=({projectId:e,featureId:n,environmentId:a,strategy:o})=>{const s=Ie(o.name),i=we(o.name),r=Ua(e,n,a,o.name);return c(Qo,{to:r,children:[t(Ko,{children:t(s,{})}),c("div",{children:[t(Xo,{text:o.displayName||i,maxWidth:"200",maxLength:25}),t(Jo,{children:o.description})]})]})},es=({projectId:e,featureId:n,environmentId:a})=>{const{strategies:o}=Dn(),s=f.useMemo(()=>o.filter(i=>!i.deprecated),[o]);return t(rt,{dense:!0,children:s.map(i=>t(Re,{children:t(Zo,{projectId:e,featureId:n,environmentId:a,strategy:i})},i.name))})},Je=({label:e,projectId:n,featureId:a,environmentId:o,variant:s,matchWidth:i})=>{const[r,l]=f.useState(),u=Boolean(r),p=u?"FeatureStrategyMenuPopover":void 0,m=()=>{l(void 0)};return c("div",{onClick:S=>S.stopPropagation(),children:[t(ae,{permission:ue,projectId:n,environmentId:o,onClick:S=>{l(S.currentTarget)},"aria-labelledby":p,variant:s,sx:{minWidth:i?"282px":"auto"},children:e}),t(On,{id:p,open:u,anchorEl:r,onClose:m,onClick:m,children:t(es,{projectId:n,featureId:a,environmentId:o})})]})},ts=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingTop:e.spacing(2)})),ns=d("div")(({theme:e})=>({fontSize:e.fontSizes.bodySize,textAlign:"center",color:e.palette.text.primary,marginBottom:e.spacing(1)})),as=d("p")(({theme:e})=>({color:e.palette.text.secondary,fontSize:e.fontSizes.smallBody,textAlign:"center",marginBottom:e.spacing(3),a:{color:e.palette.links}})),os=({projectId:e,featureId:n,environmentId:a})=>{const{addStrategyToFeature:o}=Ce(),{setToastData:s,setToastApiError:i}=G(),{refetchFeature:r}=j(e,n),{refetchFeature:l}=nn(e,n),{feature:u}=j(e,n),p=u==null?void 0:u.environments.filter(w=>w.name!==a&&w.strategies&&w.strategies.length>0),{isChangeRequestConfigured:m}=oe(e),{changeRequestDialogDetails:g,onChangeRequestAddStrategies:S,onChangeRequestAddStrategiesConfirm:C,onChangeRequestAddStrategyClose:x}=ut(e,n,"addStrategy"),A=(w=!1)=>{r(),l(),s({title:w?"Strategies created":"Strategy created",text:w?"Successfully copied from another environment":"Successfully created strategy",type:"success"})},y=async w=>{var P;const R=((P=p==null?void 0:p.find(D=>D.name===w))==null?void 0:P.strategies)||[];if(m(a)){await S(a,R,w);return}try{await Promise.all(R.map(D=>{const{id:$,...O}={...D,environment:a};return o(e,n,a,O)})),A(!0)}catch(D){i(z(D))}},v=p&&p.length>0;return c(M,{children:[t(Oe,{isOpen:g.isOpen,onClose:x,environment:g==null?void 0:g.environment,onConfirm:C,messageComponent:t(Ho,{fromEnvironment:g.fromEnvironment,payload:g.strategies})}),c(ts,{children:[t(ns,{children:"You have not defined any strategies yet."}),c(as,{children:["Strategies added in this environment will only be executed if the SDK is using an"," ",t(J,{to:"/admin/api",children:"API key configured"})," for this environment."]}),c(H,{sx:{w:"100%",display:"flex",flexWrap:"wrap",gap:2,alignItems:"center",justifyContent:"center"},children:[t(Je,{label:"Add your first strategy",projectId:e,featureId:n,environmentId:a,matchWidth:v}),t(I,{condition:v,show:t(Uo,{environmentId:a,environments:p.map(w=>w.name),onClick:y})})]}),t(H,{sx:{width:"100%",mt:3},children:t(an,{children:"Or use a strategy template"})}),c(H,{sx:{display:"grid",width:"100%",gap:2,gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"}},children:[t(wt,{title:"Standard strategy",projectId:e,featureId:n,environmentId:a,onAfterAddStrategy:A,Icon:Ie("default"),strategy:{name:"default",parameters:{},constraints:[]},children:"The standard strategy is strictly on/off for your entire userbase."}),t(wt,{title:"Gradual rollout",projectId:e,featureId:n,environmentId:a,onAfterAddStrategy:A,Icon:Ie("flexibleRollout"),strategy:{name:"flexibleRollout",parameters:{rollout:"50",stickiness:"default",groupId:u.name},constraints:[]},children:"Roll out to a percentage of your userbase."})]})]})]})},ss=d("div")(({theme:e})=>({width:"100%",position:"relative",paddingBottom:e.spacing(2)})),rs=d("div")(({theme:e})=>({[e.breakpoints.down(400)]:{padding:e.spacing(1)}})),is=({featureEnvironment:e,isDisabled:n,otherEnvironments:a})=>{const o=F("projectId"),s=F("featureId"),{setStrategiesSortOrder:i}=Ce(),{setToastData:r,setToastApiError:l}=G(),{refetchFeature:u}=j(o,s),[p,m]=f.useState((e==null?void 0:e.strategies)||[]),[g,S]=f.useState(null);if(f.useEffect(()=>{m((e==null?void 0:e.strategies)||[])},[e==null?void 0:e.strategies]),!e)return null;const C=async v=>{try{await i(o,s,e.name,v),u(),r({title:"Order of strategies updated",type:"success"})}catch(w){l(z(w))}},x=(v,w)=>R=>{var P;S({id:p[w].id,index:w,height:((P=v.current)==null?void 0:P.offsetHeight)||0}),v!=null&&v.current&&(R.dataTransfer.effectAllowed="move",R.dataTransfer.setData("text/html",v.current.outerHTML),R.dataTransfer.setDragImage(v.current,20,20))},A=v=>(w,R)=>P=>{if(g===null||w.current===null||g.index===R||v===g.id)return;const{top:D,bottom:$}=w.current.getBoundingClientRect(),O=P.clientY-D<g.height,B=$-P.clientY<g.height,U=g.index>R;if(O&&U||B&&!U){const Y=[...p],K=Y.splice(g.index,1)[0];Y.splice(R,0,K),m(Y),S({...g,index:R})}},y=()=>{S(null),C(p.map((v,w)=>({id:v.id,sortOrder:w})))};return t(ss,{children:c(rs,{children:[t(I,{condition:p.length>0&&n,show:()=>t(he,{severity:"warning",sx:{mb:2},children:"This environment is disabled, which means that none of your strategies are executing."})}),t(I,{condition:p.length>0,show:t(M,{children:p.map((v,w)=>t(jo,{strategy:v,index:w,environmentName:e.name,otherEnvironments:a,isDragging:(g==null?void 0:g.id)===v.id,onDragStartRef:x,onDragOver:A(v.id),onDragEnd:y},v.id))}),elseShow:t(os,{projectId:o,featureId:s,environmentId:e.name})})]})})},on=(e,n)=>e===0?0:Math.round(n/e*100);var Ve={},Me={};Object.defineProperty(Me,"__esModule",{value:!0});Me.defaultOptions=void 0;Me.defaultOptions={decimalSeparator:".",lowercase:!1,precision:1,space:!1,units:["","K","M","B","T","P","E"]};var pe={};Object.defineProperty(pe,"__esModule",{value:!0});pe.roundTo=pe.parseValue=void 0;function cs(e){const n=parseFloat(e==null?void 0:e.toString());if(isNaN(n))throw new Error("Input value is not a number");if(n>Number.MAX_SAFE_INTEGER||n<Number.MIN_SAFE_INTEGER)throw new RangeError("Input value is outside of safe integer range");return n}pe.parseValue=cs;function ls(e,n){if(!Number.isFinite(e))throw new Error("Input value is not a finite number");if(!Number.isInteger(n)||n<0)throw new Error("Precision is not a positive integer");return Number.isInteger(e)?e:parseFloat(e.toFixed(n))}pe.roundTo=ls;Object.defineProperty(Ve,"__esModule",{value:!0});Ve.millify=void 0;const je=Me,Tt=pe,xt=1e3;function*At(e){let n=xt;for(;;){const a=e/n;if(a<1)return;yield a,n*=xt}}function sn(e,n){var a;const o=n?Object.assign(Object.assign({},je.defaultOptions),n):je.defaultOptions;if(!Array.isArray(o.units)||!o.units.length)throw new Error("Option `units` must be a non-empty array");let s;try{s=Tt.parseValue(e)}catch(C){return C instanceof Error&&console.warn(`WARN: ${C.message} (millify)`),String(e)}const i=s<0?"-":"";s=Math.abs(s);let r=0;for(const C of At(s))s=C,r+=1;if(r>=o.units.length)return e.toString();let u=Tt.roundTo(s,o.precision);for(const C of At(u))u=C,r+=1;const p=(a=o.units[r])!==null&&a!==void 0?a:"",m=o.lowercase?p.toLowerCase():p,g=o.space?" ":"",S=u.toString().replace(je.defaultOptions.decimalSeparator,o.decimalSeparator);return`${i}${S}${g}${m}`}Ve.millify=sn;var ds=Ve.default=sn;const Fe=({value:e,threshold:n=1e6,precision:a=2})=>{let o,s=!1;e<n?o=e.toLocaleString():(o=ds(e,{precision:a}),s=!0);const i=t("span",{"data-testid":Vn,children:o});return t(I,{condition:s,show:t(ee,{title:e.toLocaleString(),arrow:!0,children:i}),elseShow:i})},Ne=d("article")(({theme:e})=>({padding:e.spacing(2),background:"transparent",borderRadius:e.spacing(2),textAlign:"center",[e.breakpoints.up("md")]:{padding:e.spacing(4)}})),ze=d("h3")(({theme:e})=>({margin:0,fontSize:e.fontSizes.bodySize,fontWeight:e.fontWeight.thin})),We=d("p")(({theme:e})=>({fontSize:"2.25rem",fontWeight:e.fontWeight.bold,color:e.palette.primary.main})),Ue=d("p")(({theme:e})=>({margin:e.spacing(1,0,0,0),padding:e.spacing(2,0,0,0),borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:e.palette.divider,fontSize:e.fontSizes.smallerBody,color:e.palette.text.secondary})),rn=({totalYes:e,totalNo:n,hoursBack:a,statsSectionId:o,tableSectionId:s})=>{const i=a===1?"in the last hour":`in the last ${a} hours`;return c(ne,{container:!0,spacing:2,id:o,"aria-describedby":s,"aria-label":"Feature metrics summary",component:"section",children:[t(ne,{item:!0,xs:12,sm:4,children:c(Ne,{children:[t(ze,{children:"Exposure"}),t(We,{children:t(Fe,{value:e})}),c(Ue,{children:["Total exposure of the feature in the environment"," ",i,"."]})]})}),t(ne,{item:!0,xs:12,sm:4,children:c(Ne,{children:[t(ze,{children:"Exposure %"}),c(We,{children:[on(e+n,e),"%"]}),c(Ue,{children:["% total exposure of the feature in the environment"," ",i,"."]})]})}),t(ne,{item:!0,xs:12,sm:4,children:c(Ne,{children:[t(ze,{children:"Requests"}),t(We,{children:t(Fe,{value:e+n})}),c(Ue,{children:["Total requests for the feature in the environment"," ",i,"."]})]})})]})},us=({environmentMetric:e})=>e?c(M,{children:[t(an,{children:"Feature toggle exposure"}),t("div",{children:t(rn,{totalYes:e.yes,totalNo:e.no,hoursBack:1})})]}):null,Et=d("div")({marginLeft:"auto",display:"flex",alignItems:"center"}),It=d("div")(({theme:e})=>({marginRight:e.spacing(1),display:"flex",flexDirection:"column"})),Rt=d("p")(({theme:e})=>({color:e.palette.primary.main,textAlign:"right",fontSize:e.fontSizes.bodySize})),Ft=d("p")(({theme:e})=>({maxWidth:"270px",marginTop:e.spacing(.5),fontSize:e.fontSizes.smallBody,textAlign:"right",[e.breakpoints.down(700)]:{display:"none"}})),ps=d(Mn)(({theme:e})=>({fill:e.palette.background.elevation2,height:"75px",width:"75px",[e.breakpoints.down(500)]:{display:"none"}})),gs=d("div")(({theme:e})=>({margin:e.spacing(0,2),[e.breakpoints.down(500)]:{display:"none"}})),hs=({environmentMetric:e,disabled:n=!1})=>{const a=Ln();if(!e)return null;const o=e.yes+e.no,s=on(o,e==null?void 0:e.yes);return!e||e.yes===0&&e.no===0?c(Et,{children:[c(It,{children:[c(Rt,{style:{color:n?a.palette.text.secondary:void 0},"data-loading":!0,children:[s,"%"]}),c(Ft,{style:{color:n?a.palette.text.secondary:a.palette.text.primary},"data-loading":!0,children:["The feature has been requested ",t("b",{children:"0 times"})," and exposed",t("b",{children:" 0 times"})," in the last hour"]})]}),t(ps,{style:{transform:"scale(1.1)"},"data-loading":!0})]}):c(Et,{children:[c(It,{children:[c(Rt,{children:[s,"%"]}),c(Ft,{children:["The feature has been requested"," ",c("b",{children:[t(Fe,{value:o})," times"]})," ","and exposed"," ",c("b",{children:[t(Fe,{value:e.yes})," ","times"]})," ","in the last hour"]})]}),t(gs,{"data-loading":!0,children:t(_n,{percentage:s,size:"3rem"})})]})},ms=({strategyName:e})=>{const n=Ie(e);return t(ee,{title:we(e),arrow:!0,children:t(fs,{children:t(n,{})})})},fs=d("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.palette.action.disabled,"& svg":{width:e.spacing(2.5),height:e.spacing(2.5)}})),ys=({strategies:e})=>e!=null&&e.length?t(Ss,{"aria-label":"Feature strategies",children:e.map(n=>t(bs,{children:t(ms,{strategyName:n.name})},n.id))}):null,Ss=d("ul")(()=>({all:"unset",display:"flex",alignItems:"center",alignContent:"center"})),bs=d("li")(()=>({all:"unset",minWidth:30,textAlign:"center"})),Cs=d("div",{shouldForwardProp:e=>e!=="enabled"})(({theme:e,enabled:n})=>({borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2),backgroundColor:n?e.palette.background.paper:e.palette.envAccordion.disabled})),vs=d(jn)({boxShadow:"none",background:"none"}),ws=d(Nn)(({theme:e})=>({boxShadow:"none",padding:e.spacing(2,4),[e.breakpoints.down(400)]:{padding:e.spacing(1,2)}})),Ts=d(zn,{shouldForwardProp:e=>e!=="enabled"})(({theme:e})=>({padding:e.spacing(3),background:e.palette.envAccordion.expanded,borderBottomLeftRadius:e.shape.borderRadiusLarge,borderBottomRightRadius:e.shape.borderRadiusLarge,boxShadow:"inset 0px 2px 4px rgba(32, 32, 33, 0.05)",[e.breakpoints.down("md")]:{padding:e.spacing(2,1)}})),xs=d(is)(({theme:e})=>({width:"100%",position:"relative",paddingBottom:e.spacing(2)})),As=d("div",{shouldForwardProp:e=>e!=="enabled"})(({theme:e,enabled:n})=>({display:"flex",justifyContent:"center",flexDirection:"column",color:n?e.palette.text.primary:e.palette.text.secondary})),Es=d("div")(({theme:e})=>({display:"flex",alignItems:"center",[e.breakpoints.down(560)]:{flexDirection:"column",textAlign:"center"}})),Is=d(Io)(({theme:e})=>({[e.breakpoints.down(560)]:{marginBottom:"0.5rem"}})),Rs=d(st)(({theme:e})=>({fontSize:e.fontSizes.bodySize,fontWeight:e.typography.fontWeightMedium,[e.breakpoints.down(560)]:{textAlign:"center"}})),Fs=d("div")(({theme:e})=>({display:"flex",alignItems:"center",marginLeft:"1.8rem",[e.breakpoints.down(560)]:{flexDirection:"column",marginLeft:"0"}})),ks=({env:e})=>{var p;const n=F("projectId"),a=F("featureId"),{metrics:o}=xo(n,a),{feature:s}=j(n,a),{value:i}=Ut(),l=Eo(s==null?void 0:s.environments,o).find(m=>m.environment===e.name),u=s==null?void 0:s.environments.find(m=>m.name===e.name);return t(I,{condition:!Boolean(new Set(i.hiddenEnvironments).has(e.name)),show:t(Cs,{enabled:e.enabled,children:c(vs,{"data-testid":`${Wn}_${e.name}`,className:`environment-accordion ${e.enabled?"":"accordion-disabled"}`,children:[c(ws,{expandIcon:t(ro,{titleAccess:"Toggle"}),children:[c(As,{"data-loading":!0,enabled:e.enabled,children:[c(Es,{children:[t(Is,{enabled:e.enabled}),t("div",{children:t(Rs,{text:e.name,maxWidth:"100",maxLength:15})}),t(I,{condition:!e.enabled,show:t(fe,{color:"neutral",sx:{ml:1},children:"Disabled"})})]}),c(Fs,{children:[t(Je,{label:"Add strategy",projectId:n,featureId:a,environmentId:e.name,variant:"text"}),t(ys,{strategies:u==null?void 0:u.strategies})]})]}),t(hs,{environmentMetric:l,disabled:!e.enabled})]}),c(Ts,{enabled:e.enabled,children:[t(xs,{featureEnvironment:u,isDisabled:!e.enabled,otherEnvironments:s==null?void 0:s.environments.map(({name:m})=>m).filter(m=>m!==e.name)}),t(I,{condition:(((p=u==null?void 0:u.strategies)==null?void 0:p.length)||0)>0,show:c(M,{children:[t(H,{sx:{display:"flex",justifyContent:"center",py:1},children:t(Je,{label:"Add strategy",projectId:n,featureId:a,environmentId:e.name})}),t(us,{environmentMetric:l})]})})]})]})})})},$s=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n);if(!a)return null;const{environments:o}=a;return t(M,{children:o==null?void 0:o.map(s=>t(ks,{env:s},s.name))})},Ps=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(3),fontSize:e.fontSizes.smallBody})),Bs=d("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)})),Ds=({feature:e,header:n})=>{const{locationSettings:a}=Un();return c(Ps,{children:[n,c("div",{"data-loading":!0,children:[t(Bs,{children:"Created at:"}),t("span",{children:qn(Hn(e.createdAt),a.locale)})]})]})},Os=d($e,{shouldForwardProp:e=>e!=="visibilityOff"})(({theme:e,visibilityOff:n})=>({marginLeft:"auto",marginRight:e.spacing(-1),color:n?e.palette.action.active:e.palette.action.focus,"&:hover":{color:e.palette.action.active}})),Vs=({environment:e,hiddenEnvironments:n,setHiddenEnvironments:a})=>t(Os,{onClick:()=>{a(e.name)},visibilityOff:n.has(e.name),children:t(I,{condition:n.has(e.name),show:t(Gn,{}),elseShow:t(Yn,{})})}),Ms=d("div")(({theme:e})=>({marginLeft:e.spacing(-1.5),"&:not(:last-of-type)":{marginBottom:e.spacing(2)},display:"flex",alignItems:"center"})),Ls=d("label")(()=>({display:"inline-flex",alignItems:"center",cursor:"pointer"})),_s=({environment:e,callback:n,showInfoBox:a,children:o,hiddenEnvironments:s,setHiddenEnvironments:i})=>{const{name:r,enabled:l}=e,u=F("projectId"),p=F("featureId"),{toggleFeatureEnvironmentOn:m,toggleFeatureEnvironmentOff:g}=Te(),{refetchFeature:S}=j(u,p),{setToastData:C,setToastApiError:x}=G(),{isChangeRequestConfigured:A}=oe(u),{onChangeRequestToggle:y,onChangeRequestToggleClose:v,onChangeRequestToggleConfirm:w,changeRequestDialogDetails:R}=qa(u),P=async()=>{try{await m(u,p,r),C({type:"success",title:`Available in ${r}`,text:`${p} is now available in ${r} based on its defined strategies.`}),S(),n&&n()}catch(B){B instanceof Error&&B.message===Ga?a():x(z(B))}},D=async()=>{try{await g(u,p,r),C({type:"success",title:`Unavailable in ${r}`,text:`${p} is unavailable in ${r} and its strategies will no longer have any effect.`}),S(),n&&n()}catch(B){x(z(B))}},$=async B=>{if(A(r)){B.preventDefault(),y(p,r,!l);return}if(l){await D();return}await P()},O=c(M,{children:[" ",c("span",{"data-loading":!0,children:[l?"enabled":"disabled"," in"]})," ",t(st,{text:r,maxWidth:"120",maxLength:15})]});return c(Ms,{children:[c(Ls,{children:[t(Kn,{tooltip:l?`Disable feature in ${r}`:`Enable feature in ${r}`,permission:Jn,projectId:u,checked:l,onChange:$,environmentId:r}),o??O]}),t(Vs,{environment:e,hiddenEnvironments:s,setHiddenEnvironments:i}),t(Oe,{isOpen:R.isOpen,onClose:v,environment:R==null?void 0:R.environment,onConfirm:w,messageComponent:t(Ha,{enabled:R==null?void 0:R.enabled,featureName:R==null?void 0:R.featureName,environment:R.environment})})]})},js=d("div")(({theme:e})=>({padding:e.spacing(3)})),Ns=d("div")(()=>({display:"flex",flexDirection:"column"})),zs=d("p")(({theme:e})=>({fontSize:e.fontSizes.bodySize})),Ws=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,display:"flex",alignItems:"center"})),kt=d("span")(({theme:e})=>({padding:e.spacing(0,.5),"::after":{content:'"-"'}})),Us=d(it)(()=>({"&:hover, &:focus":{textDecoration:"underline"}})),qs=({feature:e,header:n,hiddenEnvironments:a,setHiddenEnvironments:o})=>{const[s,i]=f.useState(!1),[r,l]=f.useState(""),u=e.environments.some(p=>{var m;return p.enabled&&((m=p.variants)==null?void 0:m.length)});return c(js,{"data-testid":"feature-toggle-status",children:[n,e.environments.map(p=>{const m=p.strategies.length===1?"1 strategy":`${p.strategies.length} strategies`,g=p.variants??[],S=g.length>0&&c(M,{children:[t(kt,{}),t(ee,{title:"View variants",arrow:!0,describeChild:!0,children:t(Us,{component:J,to:`/projects/${e.project}/features/${e.name}/variants`,underline:"hover",children:g.length===1?"1 variant":`${g.length} variants`})})]}),C=p.enabled&&g.length===0&&u;return t(_s,{environment:p,hiddenEnvironments:a,setHiddenEnvironments:o,showInfoBox:()=>{l(p.name),i(!0)},children:c(Ns,{children:[t(zs,{children:p.name}),c(Ws,{children:[m,S,t(I,{condition:C,show:c(M,{children:[t(kt,{}),t(Ya,{})]})})]})]})},p.name)}),t(Ka,{open:s,onClose:()=>i(!1),projectId:e.project,featureId:e.name,environmentName:r})]})},cn=(e,n={})=>{const a=async()=>{const p=be(`api/admin/features/${e}/tags`);return(await fetch(p,{method:"GET"}).then(ke("Tags"))).json()},o=`api/admin/features/${e}/tags`,{data:s,error:i}=Xn(Boolean(e),{tags:[]},o,a,n),[r,l]=f.useState(!i&&!s),u=()=>{Ze(o)};return f.useEffect(()=>{l(!i&&!s)},[s,i]),{tags:(s==null?void 0:s.tags)||[],error:i,loading:r,refetch:u}},Hs=d("section")(({theme:e})=>({["& > *"]:{margin:e.spacing(1,0)}})),qe=e=>e.map(n=>({title:n.value})),$t=(e,n)=>e.map(a=>({value:a.title,type:n})),ln=({open:e,setOpen:n})=>{const{tagTypes:a}=Qn(),o=F("featureId"),{createTag:s}=Ja(),{updateFeatureTags:i,loading:r}=Te(),{tags:l,refetch:u,loading:p}=cn(o),{setToastData:m}=G(),[g,S]=f.useState({name:"simple",description:"Simple tag to get you started",icon:""}),C=r||p,[x,A]=f.useState(0),{trackEvent:y}=qt(),[v,w]=f.useState(qe(l.filter(h=>h.type===g.name))),{tags:R,refetch:P}=Xa(g.name),D=f.useMemo(()=>qe(R),[R]);f.useEffect(()=>{l&&g&&w(qe(l.filter(h=>h.type===g.name)))},[JSON.stringify(l),g]);const $=()=>{n(!1),w([])};function O(h,b){const E=h.filter(L=>L.type===g.name).filter(L=>!b.find(_=>L.value===_.value&&L.type===_.type)),V=b.filter(L=>L.type===g.name).filter(L=>!h.find(_=>L.value===_.value&&L.type===_.type));return A(E.length+V.length),{added:E,removed:V}}const B=h=>h.filter(b=>!b.title.startsWith("Create")),U=async(h,b)=>{try{await i(o,{addedTags:h,removedTags:b}),await u()}catch(E){const V=z(E);m({type:"error",title:"Failed to add tag",text:V,confetti:!1})}},Y=(h,b)=>{let E="We successfully";return h>0&&(E=E.concat(` added ${h} new tag${h>1?"s":""}`)),h>0&&b>0&&(E=E.concat(" and ")),b>0&&(E=E.concat(` removed ${b} tag${b>1?"s":""}`)),E},K=async h=>{h.preventDefault();const b=$t(B(v),g.name),{added:E,removed:V}=O(b,l);x>0&&(await U(E,V),x>1&&y("suggest_tags",{props:{eventType:"multiple_tags_added"}}),x>0&&m({type:"success",title:`Updated tag${E.length>1?"s":""} to toggle`,text:Y(E.length,V.length),confetti:!0})),A(0),w([]),n(!1)},Z=(h,b)=>{b!=null&&typeof b!="string"&&(h.preventDefault(),S(b),w([]),A(0))},te=(h,b,E)=>{const V=Zn(b);E==="selectOption"&&b.forEach((_,q)=>{if(typeof _!="string"&&_.inputValue&&_.inputValue!==""){const xe={value:_.inputValue,type:g.name};s(xe).then(()=>{y("suggest_tags",{props:{eventType:"tag_created"}}),P()}),_.title=_.inputValue,_.inputValue="",V[q]=_}});const L=$t(B(V),g.name);O(L,l),w(V)},T="add-tag-form";return t(de,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update tags to feature toggle",onClick:K,disabledPrimaryButton:C||x===0,onClose:$,formId:T,children:c(M,{children:[t(N,{paragraph:!0,sx:{marginBottom:h=>h.spacing(2.5)},children:"Tags allow you to group features together"}),t("form",{id:T,onSubmit:K,children:c(Hs,{children:[t(Qa,{options:a,value:g,onChange:Z}),t(Za,{options:D,existingTags:l,tagType:g,selectedOptions:v,onChange:te})]})})]})})},Gs=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(3)})),Ys=d("div")(({theme:e})=>({display:"flex",gap:e.spacing(1),flexWrap:"wrap"})),Ks=d(Ht)(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Js=d(ye)(({theme:e})=>({margin:e.spacing(3),borderStyle:"dashed"})),Xs=d(re)(({theme:e})=>({maxWidth:e.spacing(20),alignSelf:"center"})),Qs=({feature:e,header:n})=>{const{tags:a,refetch:o}=cn(e.name),{deleteTagFromFeature:s}=Te(),[i,r]=f.useState(!1),[l,u]=f.useState(!1),[p,m]=f.useState(),{setToastData:g,setToastApiError:S}=G(),{hasAccess:C}=f.useContext(ot),x=C(le,e.project),A=async()=>{if(p)try{await s(e.name,p.type,p.value),o(),g({type:"success",title:"Tag deleted",text:"Successfully deleted tag"})}catch(y){S(z(y))}};return c(Gs,{children:[n,t(Ys,{children:a.map(y=>{const v=`${y.type}:${y.value}`;return t(Ks,{label:v,deleteIcon:t(ea,{titleAccess:"Remove"}),onDelete:x?()=>{u(!0),m(y)}:void 0},v)})}),t(I,{condition:x,show:c(M,{children:[t(I,{condition:a.length>0,show:t(Js,{})}),t(Xs,{"data-loading":!0,variant:"outlined",startIcon:t(ta,{}),onClick:()=>r(!0),children:"Add new tag"})]})}),t(ln,{open:i,setOpen:r}),c(de,{open:l,primaryButtonText:"Delete tag",secondaryButtonText:"Cancel",onClose:()=>{u(!1),m(void 0)},onClick:()=>{u(!1),A(),m(void 0)},title:"Delete tag?",children:["You are about to delete tag:"," ",c("strong",{children:[p==null?void 0:p.type,":",p==null?void 0:p.value]})]})]})},Zs=d("div")(({theme:e})=>({position:"sticky",top:e.spacing(2),borderRadius:e.shape.borderRadiusLarge,backgroundColor:e.palette.background.paper,display:"flex",flexDirection:"column",maxWidth:"350px",minWidth:"350px",marginRight:"1rem",marginTop:"1rem",[e.breakpoints.down(1e3)]:{marginBottom:"1rem",width:"100%",maxWidth:"none",minWidth:"auto"}})),He=d("h3")(({theme:e})=>({display:"flex",gap:e.spacing(1),alignItems:"center",fontSize:e.fontSizes.bodySize,margin:0,marginBottom:e.spacing(3),"& > :last-child":{position:"relative",top:1}})),er=({hiddenEnvironments:e,setHiddenEnvironments:n})=>{const a=F("projectId"),o=F("featureId"),{feature:s}=j(a,o);return c(Zs,{children:[t(qs,{header:c(He,{"data-loading":!0,children:["Enabled in environments (",s.environments.filter(({enabled:i})=>i).length,")",t(Ye,{tooltip:"When a feature is switched off in an environment, it will always return false. When switched on, it will return true or false depending on its strategies.",placement:"top"})]}),feature:s,hiddenEnvironments:e,setHiddenEnvironments:n}),t(ye,{}),t(Ds,{header:t(He,{"data-loading":!0,children:"Feature toggle details"}),feature:s}),t(ye,{}),t(Qs,{header:t(He,{"data-loading":!0,children:"Tags for this feature toggle"}),feature:s})]})},tr=()=>{const{trackEvent:e}=qt(),{value:n,setValue:a}=Ut(),[o,s]=f.useState(new Set(n.hiddenEnvironments));return{hiddenEnvironments:o,setHiddenEnvironments:r=>{a(l=>{const u=new Set(l.hiddenEnvironments);return u.has(r)?(u.delete(r),e("hidden_environment",{props:{eventType:"environment unhidden"}})):(u.add(r),e("hidden_environment",{props:{eventType:"environment hidden"}})),s(u),{...n,hiddenEnvironments:u}})}}},nr=d("div")(({theme:e})=>({display:"flex",width:"100%",[e.breakpoints.down(1e3)]:{flexDirection:"column"}})),ar=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",width:"calc(100% - (350px + 1rem))",[e.breakpoints.down(1e3)]:{width:"100%"}})),or=()=>{const e=ge(),n=F("projectId"),a=F("featureId"),o=Nt(n,a),{hiddenEnvironments:s,setHiddenEnvironments:i}=tr(),r=()=>e(o);return Gt(a),c(nr,{children:[c("div",{children:[t(To,{}),t(er,{hiddenEnvironments:s,setHiddenEnvironments:i})]}),t(ar,{children:t($s,{})}),c(Yt,{children:[t(se,{path:"strategies/create",element:t(Ke,{label:"Create feature strategy",onClose:r,open:!0,children:t(eo,{})})}),t(se,{path:"strategies/edit",element:t(Ke,{label:"Edit feature strategy",onClose:r,open:!0,children:t(na,{})})})]})]})},sr=({values:e=[],updateValues:n,placeholder:a="",error:o,...s})=>{const i=l=>{const p=l.target.value.split(/,\s?/).map(m=>m.trim());n(p)},r=l=>{if(l.key==="Backspace"){const u=l.target.value;if(u.endsWith(", ")){l.preventDefault();const p=u.slice(0,-2);n(p.split(/,\s*/))}}};return t(Kt,{...s,error:o,placeholder:a,value:e?e.join(", "):"",onKeyDown:r,onChange:i,style:{width:"100%"},variant:"outlined",size:"small"})},rr=d("div")(({theme:e})=>({display:"flex",alignItems:"center",rowGap:e.spacing(1.5),marginBottom:e.spacing(2),[e.breakpoints.down("sm")]:{flexDirection:"column","& > div, .MuiInputBase-root":{width:"100%",alignItems:"flex-start"}}})),ir=d(Jt)(({theme:e})=>({marginRight:e.spacing(10),[e.breakpoints.up("sm")]:{minWidth:e.spacing(20)}})),cr=d("div")(({theme:e})=>({width:"100%",gap:e.spacing(1.5),display:"flex"})),lr=d(sr)(()=>({width:"100%"})),dr=d(Kt)(()=>({width:"100%"})),ur=({overrides:e,overridesDispatch:n})=>{const{context:a}=ct(),o=a.map(({name:r})=>({key:r,label:r})),s=r=>l=>{n({type:"UPDATE_VALUES_AT",payload:[r,l]})},i=r=>(l,u)=>{l==null||l.preventDefault(),n({type:"UPDATE_VALUES_AT",payload:[r,u||[]]})};return t(M,{children:e.map((r,l)=>{var g;const u=a.find(({name:S})=>S===r.contextName),p=((g=u==null?void 0:u.legalValues)==null?void 0:g.map(({value:S})=>S))||[],m=r.values.filter(S=>p.includes(S));return c(rr,{children:[t(ir,{id:"override-context-name",name:"contextName",label:"Context Field",value:r.contextName,options:o,onChange:S=>n({type:"UPDATE_TYPE_AT",payload:[l,S.target.value]})}),c(cr,{children:[t(I,{condition:Boolean(p&&p.length>0),show:t(aa,{multiple:!0,id:`override-select-${l}`,isOptionEqualToValue:(S,C)=>S===C,options:p,onChange:i(l),getOptionLabel:S=>S,value:m,style:{width:"100%"},filterSelectedOptions:!0,size:"small",renderInput:S=>t(dr,{...S,variant:"outlined",label:"Legal values"})}),elseShow:t(lr,{label:"Values (v1, v2, ...)",name:"values",placeholder:"",values:r.values,updateValues:s(l)})}),t(ee,{title:"Remove",arrow:!0,children:t($e,{onClick:S=>{S.preventDefault(),n({type:"REMOVE",payload:l})},children:t(tt,{})})})]})]},`override=${l}`)})})},pr=(e,n)=>{switch(n.type){case"SET":return n.payload;case"CLEAR":return[];case"ADD":return[...e,n.payload];case"REMOVE":return e.filter((r,l)=>l!==n.payload);case"UPDATE_VALUES_AT":const[a,o]=n.payload;return e.map((r,l)=>l===a?{...r,values:o}:r);case"UPDATE_TYPE_AT":const[s,i]=n.payload;return e.map((r,l)=>l===s?{...r,contextName:i}:r)}},gr=(e=[])=>f.useReducer(pr,e);var X=(e=>(e.FIX="fix",e.VARIABLE="variable",e))(X||{});const hr=d("div")(({theme:e})=>({position:"relative",backgroundColor:e.palette.neutral.light,display:"flex",flexDirection:"column",padding:e.spacing(3),marginBottom:e.spacing(3),borderRadius:e.shape.borderRadiusLarge})),mr=d(ee)(({theme:e})=>({position:"absolute",top:e.spacing(2),right:e.spacing(2)})),dn=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Pt=d(dn)(({theme:e})=>({display:"flex",color:e.palette.text.primary,marginTop:e.spacing(1),marginBottom:e.spacing(2)})),fr=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(2)})),yr=d(oa)(({theme:e})=>({marginBottom:e.spacing(1),"& > span":{fontSize:e.fontSizes.smallBody},[e.breakpoints.down("sm")]:{marginTop:e.spacing(1),marginBottom:e.spacing(1.5)}})),Sr=d("div")(({theme:e})=>({width:"100%",gap:e.spacing(1.5),display:"flex","& > div":{width:"100%"}})),Bt=d(Xt)(()=>({width:"100%"})),br=d("div")(({theme:e})=>({marginLeft:e.spacing(3)})),Cr=d(Xt)(({theme:e})=>({width:e.spacing(24),[e.breakpoints.down("sm")]:{width:"100%"}})),vr=d("div")(({theme:e})=>({marginTop:e.spacing(3),flexGrow:1})),un=d("div")(({theme:e})=>({display:"flex",rowGap:e.spacing(1.5),marginBottom:e.spacing(2),[e.breakpoints.down("sm")]:{flexDirection:"column","& > div, .MuiInputBase-root":{width:"100%"}}})),wr=d(un)({alignItems:"end",justifyContent:"space-between"}),Tr=d(Jt)(({theme:e})=>({marginRight:e.spacing(10),[e.breakpoints.up("sm")]:{minWidth:e.spacing(20)}})),xr=d(re)(({theme:e})=>({marginTop:e.spacing(-1),marginLeft:e.spacing(-1)})),Ar=[{key:"string",label:"string"},{key:"json",label:"json"},{key:"csv",label:"csv"}],Er={type:"string",value:""},Ir=({variant:e,variants:n,updateVariant:a,removeVariant:o,apiPayload:s})=>{const[i,r]=f.useState(e.name),[l,u]=f.useState(e.weightType===X.FIX),[p,m]=f.useState(String(e.weight/10)),[g,S]=f.useState(e.payload||Er),[C,x]=gr(e.overrides||[]),{context:A}=ct(),[y,v]=f.useState({}),w=h=>{v(b=>({...b,[h]:void 0}))},R=(h,b)=>{v(E=>({...E,[h]:b}))};f.useEffect(()=>{var h;w("percentage"),(h=s.error)!=null&&h.includes("%")&&R("percentage","Total weight must equal 100%")},[s.error]);const P=!e.new,D=n.filter(({id:h,weightType:b})=>h!==e.id&&b===X.VARIABLE).length>0,$=h=>{const b=h.weightType===X.VARIABLE,E=n.some(L=>L.weightType===X.FIX),V=n.filter(L=>L.weightType===X.VARIABLE).length===1;return E&&V&&b},O=h=>{w("name"),Z(h,e.id)||R("name","A variant with that name already exists for this environment."),r(h)},B=h=>{(h===""||te(h))&&m(h)},U=h=>{T(h)||R("payload","Invalid JSON.")},Y=()=>{A.length>0&&x({type:"ADD",payload:{contextName:A[0].name,values:[]}})},K=h=>Boolean(h.length),Z=(h,b)=>P||!n.some(E=>E.name===h&&E.id!==b),te=h=>{if(!l)return!0;if(h===""||h.match(/\.[0-9]{2,}$/))return!1;const b=Number(h);return b>=0&&b<=100},T=h=>{try{return h.type==="json"&&JSON.parse(h.value),!0}catch{return!1}};return f.useEffect(()=>{a({...e,name:i,weight:Number(l?p:100)*10,weightType:l?X.FIX:X.VARIABLE,stickiness:(n==null?void 0:n.length)>0?n[0].stickiness:"default",payload:g.value?g:void 0,overrides:C.map(h=>({contextName:h.contextName,values:h.values})).filter(h=>h.values&&h.values.length>0),isValid:K(i)&&Z(i,e.id)&&te(p)&&T(g)&&!s.error})},[i,l,p,g,C]),f.useEffect(()=>{l||m(String(e.weight/10))},[e.weight]),c(hr,{children:[t(mr,{arrow:!0,title:$(e)?"You need to have at least one variable variant":"Delete variant",children:t("div",{children:t($e,{"data-testid":`VARIANT_DELETE_BUTTON_${e.name}`,onClick:()=>o(e.id),disabled:$(e),children:t(tt,{})})})}),c(wr,{children:[c(vr,{children:[t(dn,{children:"Variant name"}),t(fr,{children:"This will be used to identify the variant in your code"}),t(Bt,{id:`variant-name-input-${e.id}`,"data-testid":"VARIANT_NAME_INPUT",label:"Variant name",error:Boolean(y.name),errorText:y.name,value:i,onChange:h=>O(h.target.value),disabled:P,required:!0})]}),t(I,{condition:D,show:c(br,{children:[t(yr,{label:"Custom percentage",control:t(sa,{"data-testid":"VARIANT_WEIGHT_CHECK",checked:l,onChange:h=>u(h.target.checked)})}),t(Cr,{"data-testid":"VARIANT_WEIGHT_INPUT",type:"number",label:"Variant weight",error:Boolean(y.percentage),errorText:y.percentage,value:p,onChange:h=>B(h.target.value),required:l,disabled:!l,"aria-valuemin":0,"aria-valuemax":100,InputProps:{endAdornment:t(ra,{position:"end",children:"%"})}})]})})]}),c(Pt,{children:["Payload",t(Ye,{tooltip:"Passed along with the the variant object."})]}),c(un,{children:[t(Tr,{id:"variant-payload-type",name:"type",label:"Type",value:g.type,options:Ar,onChange:h=>{w("payload"),S(b=>({...b,type:h.target.value}))}}),t(Sr,{children:t(Bt,{id:"variant-payload-value",name:"variant-payload-value",label:"Value",multiline:g.type!=="string",rows:g.type==="string"?1:4,value:g.value,onChange:h=>{w("payload"),S(b=>({...b,value:h.target.value}))},placeholder:g.type==="json"?'{ "hello": "world" }':"",onBlur:()=>U(g),error:Boolean(y.payload),errorText:y.payload})})]}),c(Pt,{children:["Overrides",t(Ye,{tooltip:"Here you can specify which users should get this variant."})]}),t(ur,{overrides:C,overridesDispatch:x}),t("div",{children:t(xr,{onClick:Y,variant:"text",color:"primary",children:"Add override"})})]})},Rr=d("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"},marginTop:e.spacing(-3.5),marginBottom:e.spacing(2),backgroundColor:e.palette.background.default,paddingTop:e.spacing(2),paddingBottom:e.spacing(2),position:"sticky",top:0,zIndex:2})),Fr=d(Qt,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.neutral.border:e.palette.primary.main})),kr=d("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontSize:e.fontSizes.mainHeader,fontWeight:e.fontWeight.bold})),$r=d("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),Pr=d(he)(({theme:e})=>({marginBottom:e.spacing(2)})),Br=d(he)(({theme:e})=>({marginTop:e.spacing(4)})),Dr=d("div")({display:"flex",flexDirection:"column"}),Or=d("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),Dt=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),Vr=d(ye)(({theme:e})=>({margin:e.spacing(4,0)})),Mr=d(ia)(({theme:e})=>({minWidth:e.spacing(20),width:"100%"})),Lr=d("div")(({theme:e})=>({marginTop:"auto",paddingTop:e.spacing(4),display:"flex",justifyContent:"flex-end"})),_r=d(re)(({theme:e})=>({marginLeft:e.spacing(3)})),jr=({environment:e,open:n,setOpen:a,getApiPayload:o,getCrPayload:s,onConfirm:i})=>{var xe;const r=F("projectId"),l=F("featureId"),{uiConfig:u}=lt(),{context:p}=ct(),{defaultStickiness:m}=ca(r),{isChangeRequestConfigured:g}=oe(r),{data:S}=ve(r),{changeRequestInReviewOrApproved:C,alert:x}=da(S),A=(e==null?void 0:e.variants)||[],[y,v]=f.useState([]),[w,R]=f.useState();f.useEffect(()=>{v(A.length?A.map(k=>({...k,isValid:!0,new:!1,id:_e()})):[{name:"",weightType:X.VARIABLE,weight:0,overrides:[],stickiness:(y==null?void 0:y.length)>0?y[0].stickiness:m,new:!0,isValid:!1,id:_e()}])},[n]);const P=(k,W)=>{v(ie=>mt(ie.map(Ae=>Ae.id===W?k:Ae),1e3))},D=()=>{const k=_e();v(W=>[...W,{name:"",weightType:X.VARIABLE,weight:0,overrides:[],stickiness:(W==null?void 0:W.length)>0?W[0].stickiness:"default",new:!0,isValid:!1,id:k}]),R(k)};f.useEffect(()=>{if(w){const k=document.getElementById(`variant-name-input-${w}`);k==null||k.scrollIntoView({behavior:"smooth",block:"center"}),k==null||k.focus({preventScroll:!0}),R(void 0)}},[w]);const $=y.map(({new:k,isValid:W,id:ie,...Ae})=>Ae),O=o(A,$),B=s($),U=async k=>{k.preventDefault(),i($)},Y=()=>T?`curl --location --request POST '${u.unleashUrl}/api/admin/projects/${r}/environments/${e==null?void 0:e.name}/change-requests' \\
1
+ import{aB as pn,aC as gn,s as d,r as f,aD as hn,aE as mn,aF as pt,j as t,aG as fn,aH as yn,c as jt,aI as F,aJ as j,aK as Sn,f as c,aL as bn,C as I,aM as Q,aN as le,aO as J,aP as me,aQ as Cn,aR as Qe,aS as be,aT as ke,aU as Ze,u as et,aV as oe,F as M,aW as gt,aX as ht,aY as tt,aZ as ae,a_ as de,T as N,a$ as Ce,a2 as G,ar as ge,b0 as nt,b1 as ve,A as he,b2 as Nt,a4 as z,b3 as vn,b4 as wn,b5 as Tn,b6 as xn,ap as we,b7 as An,b8 as ue,b9 as ee,m as $e,ba as En,bb as In,bc as Pe,a8 as Be,bd as zt,be as Wt,bf as at,bg as Rn,bh as Fn,bi as kn,a as H,p as $n,N as De,B as fe,bj as ot,a9 as re,bk as Pn,x as st,an as Ie,E as Bn,bl as rt,bm as Re,P as Dn,bn as On,bo as ne,bp as Vn,bq as Mn,D as Ln,br as _n,bs as jn,bt as Nn,bu as Ut,bv as zn,bw as Wn,bx as Un,by as qn,bz as Hn,bA as Gn,bB as Te,bC as Yn,bD as Kn,bE as it,bF as Jn,bG as Xn,as as qt,bH as Qn,w as Ht,af as ye,bI as Zn,bJ as ea,bK as Ye,bL as Gt,bM as Yt,bN as se,bO as Ke,bP as ta,ac as Kt,bQ as Jt,a3 as ct,ad as na,bR as aa,bS as Xt,bT as oa,bU as sa,bV as Qt,bW as ra,H as lt,bX as ia,av as ca,bY as ce,bZ as mt,b_ as la,b$ as da,c0 as ua,c1 as pa,ak as dt,al as ga,V as ft,c2 as ha,c3 as ma,c4 as fa,c5 as ya,d as Le,l as Sa,U as ba,g as Ca,S as va,h as wa,i as Ta,k as xa,I as Aa,c6 as Ea,c7 as Ia,c8 as yt,c9 as Ra,ca as Zt,cb as Fa,ae as ka,cc as St,cd as $a,ce as Pa,cf as Ba,cg as Da,ch as Oa,ci as Va,M as Ma,cj as La,ck as _a,cl as ja,cm as Na,cn as za,co as Wa}from"./index-b8a4d792.js";import{C as Oe,f as Ua,u as qa,U as Ha,E as Ga,V as Ya,a as Ka,b as Ja,c as Xa,T as Qa,d as Za,F as eo,A as to,W as no,e as ao,g as oo}from"./FeatureArchiveDialog-bf1868f0.js";import{S as so}from"./StrategyItemContainer-905f3f96.js";import{E as ro}from"./ExpandMore-755ec693.js";import{v as _e}from"./v4-a960c1f4.js";function io(e){return pn("MuiCardContent",e)}gn("MuiCardContent",["root"]);const co=["className","component"],lo=e=>{const{classes:n}=e;return yn({root:["root"]},io,n)},uo=d("div",{name:"MuiCardContent",slot:"Root",overridesResolver:(e,n)=>n.root})(()=>({padding:16,"&:last-child":{paddingBottom:24}})),po=f.forwardRef(function(n,a){const o=hn({props:n,name:"MuiCardContent"}),{className:s,component:i="div"}=o,r=mn(o,co),l=pt({},o,{component:i}),u=lo(l);return t(uo,pt({as:i,className:fn(u.root,s),ownerState:l,ref:a},r))}),go=po,ho=jt(t("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z"}),"Assessment"),mo=jt(t("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z"}),"Cloud"),fo=d("div")(({theme:e})=>({borderRadius:e.spacing(1.5),backgroundColor:e.palette.background.paper,padding:e.spacing(4)})),yo=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n);return a.name?t(fo,{children:t(Sn,{title:"Event log",feature:n,displayInline:!0})}):null},So=d("div")(({theme:e})=>({borderRadius:e.shape.borderRadiusLarge,color:e.palette.primary.contrastText,backgroundColor:e.palette.background.alternative,display:"flex",flexDirection:"column",maxWidth:"350px",minWidth:"350px",marginRight:e.spacing(2),[e.breakpoints.down(1e3)]:{width:"100%",maxWidth:"none",minWidth:"auto"}})),bo=d("div")({padding:"1.5rem 1.5rem 0 1.5rem"}),Co=d("div")({display:"flex",alignItems:"center"}),vo=d("h2")(({theme:e})=>({fontSize:e.fontSizes.bodySize,fontWeight:"normal",margin:0})),wo=d("div")(({theme:e})=>({margin:e.spacing(2,0),display:"flex",flexDirection:"column"})),bt=d("span")(({theme:e})=>({margin:e.spacing(1,0),fontSize:e.fontSizes.bodySize,wordBreak:"break-all"})),Ct=d("div")(({theme:e})=>({display:"flex",alignItems:"center",color:e.palette.primary.contrastText})),To=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n),{project:o,description:s,type:i}=a,r=Cn(i);return t(So,{children:c(bo,{children:[c(Co,{"data-loading":!0,children:[t(r,{sx:l=>({marginRight:l.spacing(2),height:"40px",width:"40px",fill:l.palette.primary.contrastText})})," ",c(vo,{children:[bn(i||"")," toggle"]})]}),c(wo,{children:[c(bt,{"data-loading":!0,children:["Project: ",o]}),t(I,{condition:Boolean(s),show:c(bt,{"data-loading":!0,children:[t("div",{children:"Description:"}),c(Ct,{children:[t("p",{children:s}),t(Q,{projectId:e,permission:le,component:J,to:`/projects/${e}/features/${n}/settings`,tooltipProps:{title:"Edit description"},children:t(me,{sx:l=>({color:l.palette.primary.contrastText})})})]})]}),elseShow:t("span",{"data-loading":!0,children:c(Ct,{children:["No description."," ",t(Q,{projectId:e,permission:le,component:J,to:`/projects/${e}/features/${n}/settings`,tooltipProps:{title:"Edit description"},children:t(me,{sx:l=>({color:l.palette.primary.contrastText})})})]})})})]})]})})},vt={lastHourUsage:[],seenApplications:[]},xo=(e,n,a={})=>{const o=async()=>{const m=be(`api/admin/client-metrics/features/${n}`),g=await fetch(m,{method:"GET"}).then(ke("feature metrics"));return g.ok?g.json():vt},s=`${e}_${n}_metrics`,{data:i,error:r}=Qe(s,o,{...a}),[l,u]=f.useState(!r&&!i),p=()=>{Ze(s)};return f.useEffect(()=>{u(!r&&!i)},[i,r]),{metrics:i||vt,error:r,loading:l,refetch:p,FEATURE_METRICS_CACHE_KEY:s}},Ao=e=>({yes:0,no:0,environment:e,timestamp:""}),Eo=(e,n)=>e.map(a=>n.lastHourUsage.find(s=>s.environment===a.name)||Ao(a.name)),Io=({enabled:e,className:n})=>{const a=et(),o=e?"Environment enabled":"Environment disabled",s={backgroundColor:e?a.palette.primary.light:a.palette.neutral.border,borderRadius:"50%",width:"28px",height:"28px",minWidth:"28px",display:"flex",alignItems:"center",justifyContent:"center",marginRight:a.spacing(1)},i={fill:a.palette.common.white,width:"16px",height:"16px"};return t("div",{style:s,className:n,children:t(mo,{style:i,titleAccess:o})})},en=()=>t(he,{severity:"error",children:"Removing the strategy will change which users receive access to the feature."}),Ro=({onRemove:e,onClose:n,isOpen:a})=>t(de,{title:"Are you sure you want to delete this strategy?",open:a,primaryButtonText:"Remove strategy",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:t(en,{})}),Fo=d("div")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1)})),ko=({onRemove:e,onClose:n,isOpen:a})=>c(de,{title:"Suggest changes",open:a,primaryButtonText:"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:[t(en,{}),t(Fo,{children:t(N,{variant:"body2",color:"text.secondary",children:"Your suggestion:"})}),t(N,{fontWeight:"bold",children:"Remove strategy"})]}),$o=({projectId:e,featureId:n,environmentId:a,strategyId:o})=>{const{deleteStrategyFromFeature:s}=Ce(),{setToastData:i,setToastApiError:r}=G(),l=ge(),{refetchFeature:u}=j(e,n);return async m=>{try{m.preventDefault(),await s(e,n,a,o),i({title:"Strategy deleted",type:"success"}),u(),l(Nt(e,n))}catch(g){r(z(g))}}},Po=({projectId:e,featureId:n,environmentId:a,strategyId:o})=>{const{addChange:s}=nt(),{refetch:i}=ve(e),{setToastData:r,setToastApiError:l}=G();return async p=>{try{p.preventDefault(),await s(e,a,{action:"deleteStrategy",feature:n,payload:{id:o}}),r({title:"Changes added to the draft!",type:"success"}),await i()}catch(m){l(z(m))}}},Bo=({projectId:e,featureId:n,environmentId:a,strategyId:o,disabled:s,icon:i})=>{const[r,l]=f.useState(!1),{isChangeRequestConfigured:u}=oe(e),p=$o({featureId:n,projectId:e,strategyId:o,environmentId:a}),m=Po({featureId:n,projectId:e,strategyId:o,environmentId:a});return c(M,{children:[t(I,{condition:Boolean(i),show:t(Q,{onClick:()=>l(!0),projectId:e,environmentId:a,disabled:s,permission:gt,"data-testid":ht,tooltipProps:{title:"Remove strategy"},type:"button",children:t(tt,{})}),elseShow:t(ae,{onClick:()=>l(!0),projectId:e,environmentId:a,disabled:s,permission:gt,"data-testid":ht,color:"secondary",variant:"text",type:"button",children:"Remove strategy"})}),t(I,{condition:u(a),show:t(ko,{isOpen:r,onClose:()=>l(!1),onRemove:async g=>{await m(g),l(!1)}}),elseShow:t(Ro,{isOpen:r,onClose:()=>l(!1),onRemove:p})})]})},Do=e=>(n,a,o)=>(o.revalidateOnFocus=!1,o.revalidateIfStale=!1,o.revalidateOnReconnect=!1,e(n,a,o));var Oo=vn(Qe,Do);const tn=(e,n)=>{const{refetchFeature:a}=j(e,n),o=wn(e,n),{data:s,error:i,mutate:r}=Oo(["useFeatureImmutable",o],()=>Tn(o)),l=f.useCallback(async()=>{await r(),await a()},[r,a]);return{feature:(s==null?void 0:s.body)||xn,refetchFeature:l,loading:!i&&!s,status:s==null?void 0:s.status,error:i}},ut=(e,n,a)=>{const{setToastData:o,setToastApiError:s}=G(),{addChange:i}=nt(),{refetch:r}=ve(e),[l,u]=f.useState({isOpen:!1}),p=f.useCallback((x,A,y)=>{u({featureName:n,environment:x,fromEnvironment:y,strategy:A,isOpen:!0})},[]),m=f.useCallback((x,A,y)=>{u({featureName:n,environment:x,fromEnvironment:y,strategies:A,isOpen:!0})},[]),g=f.useCallback(()=>{u({isOpen:!1})},[]),S=f.useCallback(async()=>{try{await i(e,l.environment,{feature:l.featureName,action:a,payload:l.strategy}),r(),u({isOpen:!1}),o({type:"success",title:"Changes added to the draft!"})}catch(x){s(z(x)),u({isOpen:!1})}},[i]),C=f.useCallback(async()=>{try{await Promise.all(l.strategies.map(x=>i(e,l.environment,{feature:l.featureName,action:a,payload:x}))),r(),u({isOpen:!1}),o({type:"success",title:"Changes added to the draft!"})}catch(x){s(z(x)),u({isOpen:!1})}},[i]);return{onChangeRequestAddStrategy:p,onChangeRequestAddStrategies:m,onChangeRequestAddStrategyClose:g,onChangeRequestAddStrategyConfirm:S,onChangeRequestAddStrategiesConfirm:C,changeRequestDialogDetails:l}},Vo=({payload:e,fromEnvironment:n,environment:a})=>c(N,{children:[c("strong",{children:["Copy ",we((e==null?void 0:e.name)||"")," strategy"," "]})," ","from ",n," to ",a]}),Mo=({environmentId:e,environments:n,strategy:a})=>{const o=F("projectId"),s=F("featureId"),[i,r]=f.useState(null),l=Boolean(i),{addStrategyToFeature:u}=Ce(),{setToastData:p,setToastApiError:m}=G(),{refetchFeature:g}=j(o,s),{refetchFeature:S}=tn(o,s),C=()=>{r(null)},x=An(o),{isChangeRequestConfigured:A}=oe(o),{changeRequestDialogDetails:y,onChangeRequestAddStrategyClose:v,onChangeRequestAddStrategy:w,onChangeRequestAddStrategyConfirm:R}=ut(o,s,"addStrategy"),P=async $=>{const{id:O,...B}={...a,targetEnvironment:$};if(A($)){await w($,{id:O,...B},e);return}try{await u(o,s,$,a),g(),S(),p({title:"Strategy created",text:`Successfully copied a strategy to ${$}`,type:"success"})}catch(U){m(z(U))}C()},D=n.some($=>x(ue,$));return c("div",{children:[t(Oe,{isOpen:y.isOpen,onClose:v,environment:y==null?void 0:y.environment,onConfirm:R,messageComponent:t(Vo,{fromEnvironment:y.fromEnvironment,payload:y.strategy})}),t(ee,{title:`Copy to another environment${D?"":" (Access denied)"}`,children:t("div",{children:t($e,{size:"large",id:`copy-strategy-icon-menu-${a.id}`,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,onClick:$=>{r($.currentTarget)},"data-testid":En,disabled:!D,children:t(In,{})})})}),t(Pe,{id:"basic-menu",anchorEl:i,open:l,onClose:C,MenuListProps:{"aria-labelledby":`copy-strategy-icon-menu-${a.id}`},children:n.map($=>{const O=x(ue,$);return t(ee,{title:O?"":"You don't have access to add a strategy to this environment",children:t("div",{children:c(Be,{onClick:()=>P($),disabled:!O,children:[t(I,{condition:!O,show:t(zt,{children:t(Wt,{fontSize:"small"})})}),c(at,{children:["Copy to ",$]})]})})},$)})})]})},Lo=({environmentId:e,strategy:n,onDragStart:a,onDragEnd:o,otherEnvironments:s,orderNumber:i,headerChildren:r})=>{const l=F("projectId"),u=F("featureId"),p=Rn(l,u,e,n.id);return t(so,{strategy:n,onDragStart:a,onDragEnd:o,orderNumber:i,actions:c(M,{children:[r,t(I,{condition:Boolean(s&&(s==null?void 0:s.length)>0),show:()=>t(Mo,{environmentId:e,environments:s,strategy:n})}),t(Q,{permission:Fn,environmentId:e,projectId:l,component:J,to:p,tooltipProps:{title:"Edit strategy"},children:t(me,{})}),t(Bo,{projectId:l,featureId:u,environmentId:e,strategyId:n.id,icon:!0})]}),children:t(kn,{strategy:n})})},_o=(e,n,a,o)=>{const{data:s}=ve(e),i=s==null?void 0:s.find(u=>u.environment===a),r=i==null?void 0:i.features.find(u=>u.name===n);return r==null?void 0:r.changes.find(u=>u.action==="updateStrategy"||u.action==="deleteStrategy"?u.payload.id===o:!1)},jo=({strategy:e,index:n,environmentName:a,otherEnvironments:o,isDragging:s,onDragStartRef:i,onDragOver:r,onDragEnd:l})=>{const u=F("projectId"),p=F("featureId"),m=f.useRef(null),g=_o(u,p,a,e.id);return c(H,{ref:m,onDragOver:r(m,n),sx:{opacity:s?"0.5":"1"},children:[t(I,{condition:n>0,show:t($n,{text:"OR"})}),t(Lo,{strategy:e,environmentId:a,otherEnvironments:o,onDragStart:i(m,n),onDragEnd:l,orderNumber:n+1,headerChildren:t(No,{change:g})})]},e.id)},No=({change:e})=>{const n=et();return De(n.breakpoints.down("sm"))?null:c(H,{sx:{mr:1.5},children:[t(I,{condition:(e==null?void 0:e.action)==="updateStrategy",show:t(fe,{color:"warning",children:"Modified in draft"})}),t(I,{condition:(e==null?void 0:e.action)==="deleteStrategy",show:t(fe,{color:"error",children:"Deleted in draft"})})]})},zo=d("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",margin:"1rem 0",position:"relative","&:before":{content:'""',position:"absolute",top:"50%",transform:"translateY(-50%)",height:2,width:"100%",backgroundColor:e.palette.divider}})),Wo=d("span")(({theme:e})=>({fontSize:e.fontSizes.bodySize,textAlign:"center",padding:"0 1rem",background:e.palette.envAccordion.expanded,position:"relative",maxWidth:"80%",color:e.palette.text.primary})),nn=({children:e})=>t(zo,{children:t(Wo,{children:e})}),Uo=({environmentId:e,environments:n,onClick:a})=>{const o=F("projectId"),[s,i]=f.useState(null),r=Boolean(s),{hasAccess:l}=f.useContext(ot),u=n.some(p=>l(ue,o,p));return c("div",{children:[t(ee,{title:u?"":"(Access denied)",children:t("div",{children:t(re,{id:`copy-all-strategies-${e}`,"aria-controls":r?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":r?"true":void 0,onClick:p=>{i(p.currentTarget)},disabled:!u,variant:"outlined",children:"Copy from another environment"})})}),t(Pe,{id:"basic-menu",anchorEl:s,open:r,onClose:()=>{i(null)},MenuListProps:{"aria-labelledby":`copy-all-strategies-${e}`},children:n.map(p=>{const m=l(ue,o,p);return t(ee,{title:m?"":"You don't have access to add a strategy to this environment",children:t("div",{children:c(Be,{onClick:()=>a(p),disabled:!m,children:[t(I,{condition:!m,show:t(zt,{children:t(Wt,{fontSize:"small"})})}),c(at,{children:["Copy from ",p]})]})})},p)})})]})},qo=d("div")(({theme:e})=>({"&>*:nth-child(n)":{margin:e.spacing(1,0)}})),Ho=({payload:e,fromEnvironment:n,environment:a})=>c(qo,{children:[t(N,{children:t("strong",{children:"Copy: "})}),e==null?void 0:e.map(o=>c(N,{children:[c("strong",{children:[we((o==null?void 0:o.name)||"")," strategy"," "]})," "]})),c(N,{children:["from ",n," to ",a]})]}),Go=({payload:e,environment:n})=>c(M,{children:[t(N,{component:"span",children:"Add "}),c("strong",{children:[we((e==null?void 0:e.name)||"")," strategy"]})," to ",t("strong",{children:n})]}),Yo=d(Pn)(({theme:e})=>({display:"flex",flexDirection:"column",borderRadius:e.shape.borderRadiusMedium})),wt=({title:e,children:n,featureId:a,projectId:o,environmentId:s,strategy:i,Icon:r,onAfterAddStrategy:l})=>{const{addStrategyToFeature:u}=Ce(),{setToastApiError:p}=G(),{isChangeRequestConfigured:m}=oe(o),{changeRequestDialogDetails:g,onChangeRequestAddStrategy:S,onChangeRequestAddStrategyConfirm:C,onChangeRequestAddStrategyClose:x}=ut(o,a,"addStrategy");return c(M,{children:[t(Yo,{variant:"outlined",children:c(go,{sx:{display:"flex",flexDirection:"column",flexGrow:1},children:[c(N,{variant:"body1",fontWeight:"medium",sx:{mb:.5,display:"flex",alignItems:"center"},children:[t(r,{color:"disabled",sx:{mr:1}})," ",e]}),t(N,{variant:"body2",color:"text.secondary",component:"p",children:n}),t(H,{sx:{ml:"auto",mt:"auto",pt:1,mr:{xs:"auto",sm:0}},children:t(ae,{permission:ue,projectId:o,environmentId:s,variant:"outlined",size:"small",onClick:async()=>{try{m(s)?S(s,i):(await u(o,a,s,i),l())}catch(y){p(z(y))}},children:"Use template"})})]})}),t(Oe,{isOpen:g.isOpen,onClose:x,environment:g==null?void 0:g.environment,onConfirm:C,messageComponent:t(Go,{environment:s,payload:g.strategy})})]})},Ko=d("div")(({theme:e})=>({width:e.spacing(4),height:"auto","& > svg":{fill:e.palette.primary.main},"& > div":{height:e.spacing(2),marginLeft:"-.75rem",color:e.palette.primary.main}})),Jo=d("div")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Xo=d(st)(({theme:e})=>({fontWeight:e.fontWeight.bold})),Qo=d(J)(({theme:e})=>({display:"grid",gridTemplateColumns:"3rem 1fr",width:"20rem",padding:e.spacing(2),color:"inherit",textDecoration:"inherit",lineHeight:1.25,borderWidth:"1px",borderStyle:"solid",borderColor:e.palette.divider,borderRadius:e.spacing(1),"&:hover, &:focus":{borderColor:e.palette.primary.main}})),Zo=({projectId:e,featureId:n,environmentId:a,strategy:o})=>{const s=Ie(o.name),i=we(o.name),r=Ua(e,n,a,o.name);return c(Qo,{to:r,children:[t(Ko,{children:t(s,{})}),c("div",{children:[t(Xo,{text:o.displayName||i,maxWidth:"200",maxLength:25}),t(Jo,{children:o.description})]})]})},es=({projectId:e,featureId:n,environmentId:a})=>{const{strategies:o}=Bn(),s=f.useMemo(()=>o.filter(i=>!i.deprecated),[o]);return t(rt,{dense:!0,children:s.map(i=>t(Re,{children:t(Zo,{projectId:e,featureId:n,environmentId:a,strategy:i})},i.name))})},Je=({label:e,projectId:n,featureId:a,environmentId:o,variant:s,matchWidth:i})=>{const[r,l]=f.useState(),u=Boolean(r),p=u?"FeatureStrategyMenuPopover":void 0,m=()=>{l(void 0)};return c("div",{onClick:S=>S.stopPropagation(),children:[t(ae,{permission:ue,projectId:n,environmentId:o,onClick:S=>{l(S.currentTarget)},"aria-labelledby":p,variant:s,sx:{minWidth:i?"282px":"auto"},children:e}),t(Dn,{id:p,open:u,anchorEl:r,onClose:m,onClick:m,children:t(es,{projectId:n,featureId:a,environmentId:o})})]})},ts=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingTop:e.spacing(2)})),ns=d("div")(({theme:e})=>({fontSize:e.fontSizes.bodySize,textAlign:"center",color:e.palette.text.primary,marginBottom:e.spacing(1)})),as=d("p")(({theme:e})=>({color:e.palette.text.secondary,fontSize:e.fontSizes.smallBody,textAlign:"center",marginBottom:e.spacing(3),a:{color:e.palette.links}})),os=({projectId:e,featureId:n,environmentId:a})=>{const{addStrategyToFeature:o}=Ce(),{setToastData:s,setToastApiError:i}=G(),{refetchFeature:r}=j(e,n),{refetchFeature:l}=tn(e,n),{feature:u}=j(e,n),p=u==null?void 0:u.environments.filter(w=>w.name!==a&&w.strategies&&w.strategies.length>0),{isChangeRequestConfigured:m}=oe(e),{changeRequestDialogDetails:g,onChangeRequestAddStrategies:S,onChangeRequestAddStrategiesConfirm:C,onChangeRequestAddStrategyClose:x}=ut(e,n,"addStrategy"),A=(w=!1)=>{r(),l(),s({title:w?"Strategies created":"Strategy created",text:w?"Successfully copied from another environment":"Successfully created strategy",type:"success"})},y=async w=>{var P;const R=((P=p==null?void 0:p.find(D=>D.name===w))==null?void 0:P.strategies)||[];if(m(a)){await S(a,R,w);return}try{await Promise.all(R.map(D=>{const{id:$,...O}={...D,environment:a};return o(e,n,a,O)})),A(!0)}catch(D){i(z(D))}},v=p&&p.length>0;return c(M,{children:[t(Oe,{isOpen:g.isOpen,onClose:x,environment:g==null?void 0:g.environment,onConfirm:C,messageComponent:t(Ho,{fromEnvironment:g.fromEnvironment,payload:g.strategies})}),c(ts,{children:[t(ns,{children:"You have not defined any strategies yet."}),c(as,{children:["Strategies added in this environment will only be executed if the SDK is using an"," ",t(J,{to:"/admin/api",children:"API key configured"})," for this environment."]}),c(H,{sx:{w:"100%",display:"flex",flexWrap:"wrap",gap:2,alignItems:"center",justifyContent:"center"},children:[t(Je,{label:"Add your first strategy",projectId:e,featureId:n,environmentId:a,matchWidth:v}),t(I,{condition:v,show:t(Uo,{environmentId:a,environments:p.map(w=>w.name),onClick:y})})]}),t(H,{sx:{width:"100%",mt:3},children:t(nn,{children:"Or use a strategy template"})}),c(H,{sx:{display:"grid",width:"100%",gap:2,gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"}},children:[t(wt,{title:"Standard strategy",projectId:e,featureId:n,environmentId:a,onAfterAddStrategy:A,Icon:Ie("default"),strategy:{name:"default",parameters:{},constraints:[]},children:"The standard strategy is strictly on/off for your entire userbase."}),t(wt,{title:"Gradual rollout",projectId:e,featureId:n,environmentId:a,onAfterAddStrategy:A,Icon:Ie("flexibleRollout"),strategy:{name:"flexibleRollout",parameters:{rollout:"50",stickiness:"default",groupId:u.name},constraints:[]},children:"Roll out to a percentage of your userbase."})]})]})]})},ss=d("div")(({theme:e})=>({width:"100%",position:"relative",paddingBottom:e.spacing(2)})),rs=d("div")(({theme:e})=>({[e.breakpoints.down(400)]:{padding:e.spacing(1)}})),is=({featureEnvironment:e,isDisabled:n,otherEnvironments:a})=>{const o=F("projectId"),s=F("featureId"),{setStrategiesSortOrder:i}=Ce(),{setToastData:r,setToastApiError:l}=G(),{refetchFeature:u}=j(o,s),[p,m]=f.useState((e==null?void 0:e.strategies)||[]),[g,S]=f.useState(null);if(f.useEffect(()=>{m((e==null?void 0:e.strategies)||[])},[e==null?void 0:e.strategies]),!e)return null;const C=async v=>{try{await i(o,s,e.name,v),u(),r({title:"Order of strategies updated",type:"success"})}catch(w){l(z(w))}},x=(v,w)=>R=>{var P;S({id:p[w].id,index:w,height:((P=v.current)==null?void 0:P.offsetHeight)||0}),v!=null&&v.current&&(R.dataTransfer.effectAllowed="move",R.dataTransfer.setData("text/html",v.current.outerHTML),R.dataTransfer.setDragImage(v.current,20,20))},A=v=>(w,R)=>P=>{if(g===null||w.current===null||g.index===R||v===g.id)return;const{top:D,bottom:$}=w.current.getBoundingClientRect(),O=P.clientY-D<g.height,B=$-P.clientY<g.height,U=g.index>R;if(O&&U||B&&!U){const Y=[...p],K=Y.splice(g.index,1)[0];Y.splice(R,0,K),m(Y),S({...g,index:R})}},y=()=>{S(null),C(p.map((v,w)=>({id:v.id,sortOrder:w})))};return t(ss,{children:c(rs,{children:[t(I,{condition:p.length>0&&n,show:()=>t(he,{severity:"warning",sx:{mb:2},children:"This environment is disabled, which means that none of your strategies are executing."})}),t(I,{condition:p.length>0,show:t(M,{children:p.map((v,w)=>t(jo,{strategy:v,index:w,environmentName:e.name,otherEnvironments:a,isDragging:(g==null?void 0:g.id)===v.id,onDragStartRef:x,onDragOver:A(v.id),onDragEnd:y},v.id))}),elseShow:t(os,{projectId:o,featureId:s,environmentId:e.name})})]})})},an=(e,n)=>e===0?0:Math.round(n/e*100);var Ve={},Me={};Object.defineProperty(Me,"__esModule",{value:!0});Me.defaultOptions=void 0;Me.defaultOptions={decimalSeparator:".",lowercase:!1,precision:1,space:!1,units:["","K","M","B","T","P","E"]};var pe={};Object.defineProperty(pe,"__esModule",{value:!0});pe.roundTo=pe.parseValue=void 0;function cs(e){const n=parseFloat(e==null?void 0:e.toString());if(isNaN(n))throw new Error("Input value is not a number");if(n>Number.MAX_SAFE_INTEGER||n<Number.MIN_SAFE_INTEGER)throw new RangeError("Input value is outside of safe integer range");return n}pe.parseValue=cs;function ls(e,n){if(!Number.isFinite(e))throw new Error("Input value is not a finite number");if(!Number.isInteger(n)||n<0)throw new Error("Precision is not a positive integer");return Number.isInteger(e)?e:parseFloat(e.toFixed(n))}pe.roundTo=ls;Object.defineProperty(Ve,"__esModule",{value:!0});Ve.millify=void 0;const je=Me,Tt=pe,xt=1e3;function*At(e){let n=xt;for(;;){const a=e/n;if(a<1)return;yield a,n*=xt}}function on(e,n){var a;const o=n?Object.assign(Object.assign({},je.defaultOptions),n):je.defaultOptions;if(!Array.isArray(o.units)||!o.units.length)throw new Error("Option `units` must be a non-empty array");let s;try{s=Tt.parseValue(e)}catch(C){return C instanceof Error&&console.warn(`WARN: ${C.message} (millify)`),String(e)}const i=s<0?"-":"";s=Math.abs(s);let r=0;for(const C of At(s))s=C,r+=1;if(r>=o.units.length)return e.toString();let u=Tt.roundTo(s,o.precision);for(const C of At(u))u=C,r+=1;const p=(a=o.units[r])!==null&&a!==void 0?a:"",m=o.lowercase?p.toLowerCase():p,g=o.space?" ":"",S=u.toString().replace(je.defaultOptions.decimalSeparator,o.decimalSeparator);return`${i}${S}${g}${m}`}Ve.millify=on;var ds=Ve.default=on;const Fe=({value:e,threshold:n=1e6,precision:a=2})=>{let o,s=!1;e<n?o=e.toLocaleString():(o=ds(e,{precision:a}),s=!0);const i=t("span",{"data-testid":On,children:o});return t(I,{condition:s,show:t(ee,{title:e.toLocaleString(),arrow:!0,children:i}),elseShow:i})},Ne=d("article")(({theme:e})=>({padding:e.spacing(2),background:"transparent",borderRadius:e.spacing(2),textAlign:"center",[e.breakpoints.up("md")]:{padding:e.spacing(4)}})),ze=d("h3")(({theme:e})=>({margin:0,fontSize:e.fontSizes.bodySize,fontWeight:e.fontWeight.thin})),We=d("p")(({theme:e})=>({fontSize:"2.25rem",fontWeight:e.fontWeight.bold,color:e.palette.primary.main})),Ue=d("p")(({theme:e})=>({margin:e.spacing(1,0,0,0),padding:e.spacing(2,0,0,0),borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:e.palette.divider,fontSize:e.fontSizes.smallerBody,color:e.palette.text.secondary})),sn=({totalYes:e,totalNo:n,hoursBack:a,statsSectionId:o,tableSectionId:s})=>{const i=a===1?"in the last hour":`in the last ${a} hours`;return c(ne,{container:!0,spacing:2,id:o,"aria-describedby":s,"aria-label":"Feature metrics summary",component:"section",children:[t(ne,{item:!0,xs:12,sm:4,children:c(Ne,{children:[t(ze,{children:"Exposure"}),t(We,{children:t(Fe,{value:e})}),c(Ue,{children:["Total exposure of the feature in the environment"," ",i,"."]})]})}),t(ne,{item:!0,xs:12,sm:4,children:c(Ne,{children:[t(ze,{children:"Exposure %"}),c(We,{children:[an(e+n,e),"%"]}),c(Ue,{children:["% total exposure of the feature in the environment"," ",i,"."]})]})}),t(ne,{item:!0,xs:12,sm:4,children:c(Ne,{children:[t(ze,{children:"Requests"}),t(We,{children:t(Fe,{value:e+n})}),c(Ue,{children:["Total requests for the feature in the environment"," ",i,"."]})]})})]})},us=({environmentMetric:e})=>e?c(M,{children:[t(nn,{children:"Feature toggle exposure"}),t("div",{children:t(sn,{totalYes:e.yes,totalNo:e.no,hoursBack:1})})]}):null,Et=d("div")({marginLeft:"auto",display:"flex",alignItems:"center"}),It=d("div")(({theme:e})=>({marginRight:e.spacing(1),display:"flex",flexDirection:"column"})),Rt=d("p")(({theme:e})=>({color:e.palette.primary.main,textAlign:"right",fontSize:e.fontSizes.bodySize})),Ft=d("p")(({theme:e})=>({maxWidth:"270px",marginTop:e.spacing(.5),fontSize:e.fontSizes.smallBody,textAlign:"right",[e.breakpoints.down(700)]:{display:"none"}})),ps=d(Vn)(({theme:e})=>({fill:e.palette.background.elevation2,height:"75px",width:"75px",[e.breakpoints.down(500)]:{display:"none"}})),gs=d("div")(({theme:e})=>({margin:e.spacing(0,2),[e.breakpoints.down(500)]:{display:"none"}})),hs=({environmentMetric:e,disabled:n=!1})=>{const a=Mn();if(!e)return null;const o=e.yes+e.no,s=an(o,e==null?void 0:e.yes);return!e||e.yes===0&&e.no===0?c(Et,{children:[c(It,{children:[c(Rt,{style:{color:n?a.palette.text.secondary:void 0},"data-loading":!0,children:[s,"%"]}),c(Ft,{style:{color:n?a.palette.text.secondary:a.palette.text.primary},"data-loading":!0,children:["The feature has been requested ",t("b",{children:"0 times"})," and exposed",t("b",{children:" 0 times"})," in the last hour"]})]}),t(ps,{style:{transform:"scale(1.1)"},"data-loading":!0})]}):c(Et,{children:[c(It,{children:[c(Rt,{children:[s,"%"]}),c(Ft,{children:["The feature has been requested"," ",c("b",{children:[t(Fe,{value:o})," times"]})," ","and exposed"," ",c("b",{children:[t(Fe,{value:e.yes})," ","times"]})," ","in the last hour"]})]}),t(gs,{"data-loading":!0,children:t(Ln,{percentage:s,size:"3rem"})})]})},ms=({strategyName:e})=>{const n=Ie(e);return t(ee,{title:we(e),arrow:!0,children:t(fs,{children:t(n,{})})})},fs=d("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.palette.action.disabled,"& svg":{width:e.spacing(2.5),height:e.spacing(2.5)}})),ys=({strategies:e})=>e!=null&&e.length?t(Ss,{"aria-label":"Feature strategies",children:e.map(n=>t(bs,{children:t(ms,{strategyName:n.name})},n.id))}):null,Ss=d("ul")(()=>({all:"unset",display:"flex",alignItems:"center",alignContent:"center"})),bs=d("li")(()=>({all:"unset",minWidth:30,textAlign:"center"})),Cs=d("div",{shouldForwardProp:e=>e!=="enabled"})(({theme:e,enabled:n})=>({borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2),backgroundColor:n?e.palette.background.paper:e.palette.envAccordion.disabled})),vs=d(_n)({boxShadow:"none",background:"none"}),ws=d(jn)(({theme:e})=>({boxShadow:"none",padding:e.spacing(2,4),[e.breakpoints.down(400)]:{padding:e.spacing(1,2)}})),Ts=d(Nn,{shouldForwardProp:e=>e!=="enabled"})(({theme:e})=>({padding:e.spacing(3),background:e.palette.envAccordion.expanded,borderBottomLeftRadius:e.shape.borderRadiusLarge,borderBottomRightRadius:e.shape.borderRadiusLarge,boxShadow:"inset 0px 2px 4px rgba(32, 32, 33, 0.05)",[e.breakpoints.down("md")]:{padding:e.spacing(2,1)}})),xs=d(is)(({theme:e})=>({width:"100%",position:"relative",paddingBottom:e.spacing(2)})),As=d("div",{shouldForwardProp:e=>e!=="enabled"})(({theme:e,enabled:n})=>({display:"flex",justifyContent:"center",flexDirection:"column",color:n?e.palette.text.primary:e.palette.text.secondary})),Es=d("div")(({theme:e})=>({display:"flex",alignItems:"center",[e.breakpoints.down(560)]:{flexDirection:"column",textAlign:"center"}})),Is=d(Io)(({theme:e})=>({[e.breakpoints.down(560)]:{marginBottom:"0.5rem"}})),Rs=d(st)(({theme:e})=>({fontSize:e.fontSizes.bodySize,fontWeight:e.typography.fontWeightMedium,[e.breakpoints.down(560)]:{textAlign:"center"}})),Fs=d("div")(({theme:e})=>({display:"flex",alignItems:"center",marginLeft:"1.8rem",[e.breakpoints.down(560)]:{flexDirection:"column",marginLeft:"0"}})),ks=({env:e})=>{var p;const n=F("projectId"),a=F("featureId"),{metrics:o}=xo(n,a),{feature:s}=j(n,a),{value:i}=Ut(),l=Eo(s==null?void 0:s.environments,o).find(m=>m.environment===e.name),u=s==null?void 0:s.environments.find(m=>m.name===e.name);return t(I,{condition:!Boolean(new Set(i.hiddenEnvironments).has(e.name)),show:t(Cs,{enabled:e.enabled,children:c(vs,{"data-testid":`${zn}_${e.name}`,className:`environment-accordion ${e.enabled?"":"accordion-disabled"}`,children:[c(ws,{expandIcon:t(ro,{titleAccess:"Toggle"}),children:[c(As,{"data-loading":!0,enabled:e.enabled,children:[c(Es,{children:[t(Is,{enabled:e.enabled}),t("div",{children:t(Rs,{text:e.name,maxWidth:"100",maxLength:15})}),t(I,{condition:!e.enabled,show:t(fe,{color:"neutral",sx:{ml:1},children:"Disabled"})})]}),c(Fs,{children:[t(Je,{label:"Add strategy",projectId:n,featureId:a,environmentId:e.name,variant:"text"}),t(ys,{strategies:u==null?void 0:u.strategies})]})]}),t(hs,{environmentMetric:l,disabled:!e.enabled})]}),c(Ts,{enabled:e.enabled,children:[t(xs,{featureEnvironment:u,isDisabled:!e.enabled,otherEnvironments:s==null?void 0:s.environments.map(({name:m})=>m).filter(m=>m!==e.name)}),t(I,{condition:(((p=u==null?void 0:u.strategies)==null?void 0:p.length)||0)>0,show:c(M,{children:[t(H,{sx:{display:"flex",justifyContent:"center",py:1},children:t(Je,{label:"Add strategy",projectId:n,featureId:a,environmentId:e.name})}),t(us,{environmentMetric:l})]})})]})]})})})},$s=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n);if(!a)return null;const{environments:o}=a;return t(M,{children:o==null?void 0:o.map(s=>t(ks,{env:s},s.name))})},Ps=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(3),fontSize:e.fontSizes.smallBody})),Bs=d("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)})),Ds=({feature:e,header:n})=>{const{locationSettings:a}=Wn();return c(Ps,{children:[n,c("div",{"data-loading":!0,children:[t(Bs,{children:"Created at:"}),t("span",{children:Un(qn(e.createdAt),a.locale)})]})]})},Os=d($e,{shouldForwardProp:e=>e!=="visibilityOff"})(({theme:e,visibilityOff:n})=>({marginLeft:"auto",marginRight:e.spacing(-1),color:n?e.palette.action.active:e.palette.action.focus,"&:hover":{color:e.palette.action.active}})),Vs=({environment:e,hiddenEnvironments:n,setHiddenEnvironments:a})=>t(Os,{onClick:()=>{a(e.name)},visibilityOff:n.has(e.name),children:t(I,{condition:n.has(e.name),show:t(Hn,{}),elseShow:t(Gn,{})})}),Ms=d("div")(({theme:e})=>({marginLeft:e.spacing(-1.5),"&:not(:last-of-type)":{marginBottom:e.spacing(2)},display:"flex",alignItems:"center"})),Ls=d("label")(()=>({display:"inline-flex",alignItems:"center",cursor:"pointer"})),_s=({environment:e,callback:n,showInfoBox:a,children:o,hiddenEnvironments:s,setHiddenEnvironments:i})=>{const{name:r,enabled:l}=e,u=F("projectId"),p=F("featureId"),{toggleFeatureEnvironmentOn:m,toggleFeatureEnvironmentOff:g}=Te(),{refetchFeature:S}=j(u,p),{setToastData:C,setToastApiError:x}=G(),{isChangeRequestConfigured:A}=oe(u),{onChangeRequestToggle:y,onChangeRequestToggleClose:v,onChangeRequestToggleConfirm:w,changeRequestDialogDetails:R}=qa(u),P=async()=>{try{await m(u,p,r),C({type:"success",title:`Available in ${r}`,text:`${p} is now available in ${r} based on its defined strategies.`}),S(),n&&n()}catch(B){B instanceof Error&&B.message===Ga?a():x(z(B))}},D=async()=>{try{await g(u,p,r),C({type:"success",title:`Unavailable in ${r}`,text:`${p} is unavailable in ${r} and its strategies will no longer have any effect.`}),S(),n&&n()}catch(B){x(z(B))}},$=async B=>{if(A(r)){B.preventDefault(),y(p,r,!l);return}if(l){await D();return}await P()},O=c(M,{children:[" ",c("span",{"data-loading":!0,children:[l?"enabled":"disabled"," in"]})," ",t(st,{text:r,maxWidth:"120",maxLength:15})]});return c(Ms,{children:[c(Ls,{children:[t(Yn,{tooltip:l?`Disable feature in ${r}`:`Enable feature in ${r}`,permission:Kn,projectId:u,checked:l,onChange:$,environmentId:r}),o??O]}),t(Vs,{environment:e,hiddenEnvironments:s,setHiddenEnvironments:i}),t(Oe,{isOpen:R.isOpen,onClose:v,environment:R==null?void 0:R.environment,onConfirm:w,messageComponent:t(Ha,{enabled:R==null?void 0:R.enabled,featureName:R==null?void 0:R.featureName,environment:R.environment})})]})},js=d("div")(({theme:e})=>({padding:e.spacing(3)})),Ns=d("div")(()=>({display:"flex",flexDirection:"column"})),zs=d("p")(({theme:e})=>({fontSize:e.fontSizes.bodySize})),Ws=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,display:"flex",alignItems:"center"})),kt=d("span")(({theme:e})=>({padding:e.spacing(0,.5),"::after":{content:'"-"'}})),Us=d(it)(()=>({"&:hover, &:focus":{textDecoration:"underline"}})),qs=({feature:e,header:n,hiddenEnvironments:a,setHiddenEnvironments:o})=>{const[s,i]=f.useState(!1),[r,l]=f.useState(""),u=e.environments.some(p=>{var m;return p.enabled&&((m=p.variants)==null?void 0:m.length)});return c(js,{"data-testid":"feature-toggle-status",children:[n,e.environments.map(p=>{const m=p.strategies.length===1?"1 strategy":`${p.strategies.length} strategies`,g=p.variants??[],S=g.length>0&&c(M,{children:[t(kt,{}),t(ee,{title:"View variants",arrow:!0,describeChild:!0,children:t(Us,{component:J,to:`/projects/${e.project}/features/${e.name}/variants`,underline:"hover",children:g.length===1?"1 variant":`${g.length} variants`})})]}),C=p.enabled&&g.length===0&&u;return t(_s,{environment:p,hiddenEnvironments:a,setHiddenEnvironments:o,showInfoBox:()=>{l(p.name),i(!0)},children:c(Ns,{children:[t(zs,{children:p.name}),c(Ws,{children:[m,S,t(I,{condition:C,show:c(M,{children:[t(kt,{}),t(Ya,{})]})})]})]})},p.name)}),t(Ka,{open:s,onClose:()=>i(!1),projectId:e.project,featureId:e.name,environmentName:r})]})},rn=(e,n={})=>{const a=async()=>{const p=be(`api/admin/features/${e}/tags`);return(await fetch(p,{method:"GET"}).then(ke("Tags"))).json()},o=`api/admin/features/${e}/tags`,{data:s,error:i}=Jn(Boolean(e),{tags:[]},o,a,n),[r,l]=f.useState(!i&&!s),u=()=>{Ze(o)};return f.useEffect(()=>{l(!i&&!s)},[s,i]),{tags:(s==null?void 0:s.tags)||[],error:i,loading:r,refetch:u}},Hs=d("section")(({theme:e})=>({["& > *"]:{margin:e.spacing(1,0)}})),qe=e=>e.map(n=>({title:n.value})),$t=(e,n)=>e.map(a=>({value:a.title,type:n})),cn=({open:e,setOpen:n})=>{const{tagTypes:a}=Xn(),o=F("featureId"),{createTag:s}=Ja(),{updateFeatureTags:i,loading:r}=Te(),{tags:l,refetch:u,loading:p}=rn(o),{setToastData:m}=G(),[g,S]=f.useState({name:"simple",description:"Simple tag to get you started",icon:""}),C=r||p,[x,A]=f.useState(0),{trackEvent:y}=qt(),[v,w]=f.useState(qe(l.filter(h=>h.type===g.name))),{tags:R,refetch:P}=Xa(g.name),D=f.useMemo(()=>qe(R),[R]);f.useEffect(()=>{l&&g&&w(qe(l.filter(h=>h.type===g.name)))},[JSON.stringify(l),g]);const $=()=>{n(!1),w([])};function O(h,b){const E=h.filter(L=>L.type===g.name).filter(L=>!b.find(_=>L.value===_.value&&L.type===_.type)),V=b.filter(L=>L.type===g.name).filter(L=>!h.find(_=>L.value===_.value&&L.type===_.type));return A(E.length+V.length),{added:E,removed:V}}const B=h=>h.filter(b=>!b.title.startsWith("Create")),U=async(h,b)=>{try{await i(o,{addedTags:h,removedTags:b}),await u()}catch(E){const V=z(E);m({type:"error",title:"Failed to add tag",text:V,confetti:!1})}},Y=(h,b)=>{let E="We successfully";return h>0&&(E=E.concat(` added ${h} new tag${h>1?"s":""}`)),h>0&&b>0&&(E=E.concat(" and ")),b>0&&(E=E.concat(` removed ${b} tag${b>1?"s":""}`)),E},K=async h=>{h.preventDefault();const b=$t(B(v),g.name),{added:E,removed:V}=O(b,l);x>0&&(await U(E,V),x>1&&y("suggest_tags",{props:{eventType:"multiple_tags_added"}}),x>0&&m({type:"success",title:`Updated tag${E.length>1?"s":""} to toggle`,text:Y(E.length,V.length),confetti:!0})),A(0),w([]),n(!1)},Z=(h,b)=>{b!=null&&typeof b!="string"&&(h.preventDefault(),S(b),w([]),A(0))},te=(h,b,E)=>{const V=Qn(b);E==="selectOption"&&b.forEach((_,q)=>{if(typeof _!="string"&&_.inputValue&&_.inputValue!==""){const xe={value:_.inputValue,type:g.name};s(xe).then(()=>{y("suggest_tags",{props:{eventType:"tag_created"}}),P()}),_.title=_.inputValue,_.inputValue="",V[q]=_}});const L=$t(B(V),g.name);O(L,l),w(V)},T="add-tag-form";return t(de,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update tags to feature toggle",onClick:K,disabledPrimaryButton:C||x===0,onClose:$,formId:T,children:c(M,{children:[t(N,{paragraph:!0,sx:{marginBottom:h=>h.spacing(2.5)},children:"Tags allow you to group features together"}),t("form",{id:T,onSubmit:K,children:c(Hs,{children:[t(Qa,{options:a,value:g,onChange:Z}),t(Za,{options:D,existingTags:l,tagType:g,selectedOptions:v,onChange:te})]})})]})})},Gs=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(3)})),Ys=d("div")(({theme:e})=>({display:"flex",gap:e.spacing(1),flexWrap:"wrap"})),Ks=d(Ht)(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Js=d(ye)(({theme:e})=>({margin:e.spacing(3),borderStyle:"dashed"})),Xs=d(re)(({theme:e})=>({maxWidth:e.spacing(20),alignSelf:"center"})),Qs=({feature:e,header:n})=>{const{tags:a,refetch:o}=rn(e.name),{deleteTagFromFeature:s}=Te(),[i,r]=f.useState(!1),[l,u]=f.useState(!1),[p,m]=f.useState(),{setToastData:g,setToastApiError:S}=G(),{hasAccess:C}=f.useContext(ot),x=C(le,e.project),A=async()=>{if(p)try{await s(e.name,p.type,p.value),o(),g({type:"success",title:"Tag deleted",text:"Successfully deleted tag"})}catch(y){S(z(y))}};return c(Gs,{children:[n,t(Ys,{children:a.map(y=>{const v=`${y.type}:${y.value}`;return t(Ks,{label:v,deleteIcon:t(Zn,{titleAccess:"Remove"}),onDelete:x?()=>{u(!0),m(y)}:void 0},v)})}),t(I,{condition:x,show:c(M,{children:[t(I,{condition:a.length>0,show:t(Js,{})}),t(Xs,{"data-loading":!0,variant:"outlined",startIcon:t(ea,{}),onClick:()=>r(!0),children:"Add new tag"})]})}),t(cn,{open:i,setOpen:r}),c(de,{open:l,primaryButtonText:"Delete tag",secondaryButtonText:"Cancel",onClose:()=>{u(!1),m(void 0)},onClick:()=>{u(!1),A(),m(void 0)},title:"Delete tag?",children:["You are about to delete tag:"," ",c("strong",{children:[p==null?void 0:p.type,":",p==null?void 0:p.value]})]})]})},Zs=d("div")(({theme:e})=>({position:"sticky",top:e.spacing(2),borderRadius:e.shape.borderRadiusLarge,backgroundColor:e.palette.background.paper,display:"flex",flexDirection:"column",maxWidth:"350px",minWidth:"350px",marginRight:"1rem",marginTop:"1rem",[e.breakpoints.down(1e3)]:{marginBottom:"1rem",width:"100%",maxWidth:"none",minWidth:"auto"}})),He=d("h3")(({theme:e})=>({display:"flex",gap:e.spacing(1),alignItems:"center",fontSize:e.fontSizes.bodySize,margin:0,marginBottom:e.spacing(3),"& > :last-child":{position:"relative",top:1}})),er=({hiddenEnvironments:e,setHiddenEnvironments:n})=>{const a=F("projectId"),o=F("featureId"),{feature:s}=j(a,o);return c(Zs,{children:[t(qs,{header:c(He,{"data-loading":!0,children:["Enabled in environments (",s.environments.filter(({enabled:i})=>i).length,")",t(Ye,{tooltip:"When a feature is switched off in an environment, it will always return false. When switched on, it will return true or false depending on its strategies.",placement:"top"})]}),feature:s,hiddenEnvironments:e,setHiddenEnvironments:n}),t(ye,{}),t(Ds,{header:t(He,{"data-loading":!0,children:"Feature toggle details"}),feature:s}),t(ye,{}),t(Qs,{header:t(He,{"data-loading":!0,children:"Tags for this feature toggle"}),feature:s})]})},tr=()=>{const{trackEvent:e}=qt(),{value:n,setValue:a}=Ut(),[o,s]=f.useState(new Set(n.hiddenEnvironments));return{hiddenEnvironments:o,setHiddenEnvironments:r=>{a(l=>{const u=new Set(l.hiddenEnvironments);return u.has(r)?(u.delete(r),e("hidden_environment",{props:{eventType:"environment unhidden"}})):(u.add(r),e("hidden_environment",{props:{eventType:"environment hidden"}})),s(u),{...n,hiddenEnvironments:u}})}}},nr=d("div")(({theme:e})=>({display:"flex",width:"100%",[e.breakpoints.down(1e3)]:{flexDirection:"column"}})),ar=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",width:"calc(100% - (350px + 1rem))",[e.breakpoints.down(1e3)]:{width:"100%"}})),or=()=>{const e=ge(),n=F("projectId"),a=F("featureId"),o=Nt(n,a),{hiddenEnvironments:s,setHiddenEnvironments:i}=tr(),r=()=>e(o);return Gt(a),c(nr,{children:[c("div",{children:[t(To,{}),t(er,{hiddenEnvironments:s,setHiddenEnvironments:i})]}),t(ar,{children:t($s,{})}),c(Yt,{children:[t(se,{path:"strategies/create",element:t(Ke,{label:"Create feature strategy",onClose:r,open:!0,children:t(eo,{})})}),t(se,{path:"strategies/edit",element:t(Ke,{label:"Edit feature strategy",onClose:r,open:!0,children:t(ta,{})})})]})]})},sr=({values:e=[],updateValues:n,placeholder:a="",error:o,...s})=>{const i=l=>{const p=l.target.value.split(/,\s?/).map(m=>m.trim());n(p)},r=l=>{if(l.key==="Backspace"){const u=l.target.value;if(u.endsWith(", ")){l.preventDefault();const p=u.slice(0,-2);n(p.split(/,\s*/))}}};return t(Kt,{...s,error:o,placeholder:a,value:e?e.join(", "):"",onKeyDown:r,onChange:i,style:{width:"100%"},variant:"outlined",size:"small"})},rr=d("div")(({theme:e})=>({display:"flex",alignItems:"center",rowGap:e.spacing(1.5),marginBottom:e.spacing(2),[e.breakpoints.down("sm")]:{flexDirection:"column","& > div, .MuiInputBase-root":{width:"100%",alignItems:"flex-start"}}})),ir=d(Jt)(({theme:e})=>({marginRight:e.spacing(10),[e.breakpoints.up("sm")]:{minWidth:e.spacing(20)}})),cr=d("div")(({theme:e})=>({width:"100%",gap:e.spacing(1.5),display:"flex"})),lr=d(sr)(()=>({width:"100%"})),dr=d(Kt)(()=>({width:"100%"})),ur=({overrides:e,overridesDispatch:n})=>{const{context:a}=ct(),o=a.map(({name:r})=>({key:r,label:r})),s=r=>l=>{n({type:"UPDATE_VALUES_AT",payload:[r,l]})},i=r=>(l,u)=>{l==null||l.preventDefault(),n({type:"UPDATE_VALUES_AT",payload:[r,u||[]]})};return t(M,{children:e.map((r,l)=>{var g;const u=a.find(({name:S})=>S===r.contextName),p=((g=u==null?void 0:u.legalValues)==null?void 0:g.map(({value:S})=>S))||[],m=r.values.filter(S=>p.includes(S));return c(rr,{children:[t(ir,{id:"override-context-name",name:"contextName",label:"Context Field",value:r.contextName,options:o,onChange:S=>n({type:"UPDATE_TYPE_AT",payload:[l,S.target.value]})}),c(cr,{children:[t(I,{condition:Boolean(p&&p.length>0),show:t(na,{multiple:!0,id:`override-select-${l}`,isOptionEqualToValue:(S,C)=>S===C,options:p,onChange:i(l),getOptionLabel:S=>S,value:m,style:{width:"100%"},filterSelectedOptions:!0,size:"small",renderInput:S=>t(dr,{...S,variant:"outlined",label:"Legal values"})}),elseShow:t(lr,{label:"Values (v1, v2, ...)",name:"values",placeholder:"",values:r.values,updateValues:s(l)})}),t(ee,{title:"Remove",arrow:!0,children:t($e,{onClick:S=>{S.preventDefault(),n({type:"REMOVE",payload:l})},children:t(tt,{})})})]})]},`override=${l}`)})})},pr=(e,n)=>{switch(n.type){case"SET":return n.payload;case"CLEAR":return[];case"ADD":return[...e,n.payload];case"REMOVE":return e.filter((r,l)=>l!==n.payload);case"UPDATE_VALUES_AT":const[a,o]=n.payload;return e.map((r,l)=>l===a?{...r,values:o}:r);case"UPDATE_TYPE_AT":const[s,i]=n.payload;return e.map((r,l)=>l===s?{...r,contextName:i}:r)}},gr=(e=[])=>f.useReducer(pr,e);var X=(e=>(e.FIX="fix",e.VARIABLE="variable",e))(X||{});const hr=d("div")(({theme:e})=>({position:"relative",backgroundColor:e.palette.neutral.light,display:"flex",flexDirection:"column",padding:e.spacing(3),marginBottom:e.spacing(3),borderRadius:e.shape.borderRadiusLarge})),mr=d(ee)(({theme:e})=>({position:"absolute",top:e.spacing(2),right:e.spacing(2)})),ln=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Pt=d(ln)(({theme:e})=>({display:"flex",color:e.palette.text.primary,marginTop:e.spacing(1),marginBottom:e.spacing(2)})),fr=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(2)})),yr=d(aa)(({theme:e})=>({marginBottom:e.spacing(1),"& > span":{fontSize:e.fontSizes.smallBody},[e.breakpoints.down("sm")]:{marginTop:e.spacing(1),marginBottom:e.spacing(1.5)}})),Sr=d("div")(({theme:e})=>({width:"100%",gap:e.spacing(1.5),display:"flex","& > div":{width:"100%"}})),Bt=d(Xt)(()=>({width:"100%"})),br=d("div")(({theme:e})=>({marginLeft:e.spacing(3)})),Cr=d(Xt)(({theme:e})=>({width:e.spacing(24),[e.breakpoints.down("sm")]:{width:"100%"}})),vr=d("div")(({theme:e})=>({marginTop:e.spacing(3),flexGrow:1})),dn=d("div")(({theme:e})=>({display:"flex",rowGap:e.spacing(1.5),marginBottom:e.spacing(2),[e.breakpoints.down("sm")]:{flexDirection:"column","& > div, .MuiInputBase-root":{width:"100%"}}})),wr=d(dn)({alignItems:"end",justifyContent:"space-between"}),Tr=d(Jt)(({theme:e})=>({marginRight:e.spacing(10),[e.breakpoints.up("sm")]:{minWidth:e.spacing(20)}})),xr=d(re)(({theme:e})=>({marginTop:e.spacing(-1),marginLeft:e.spacing(-1)})),Ar=[{key:"string",label:"string"},{key:"json",label:"json"},{key:"csv",label:"csv"}],Er={type:"string",value:""},Ir=({variant:e,variants:n,updateVariant:a,removeVariant:o,apiPayload:s})=>{const[i,r]=f.useState(e.name),[l,u]=f.useState(e.weightType===X.FIX),[p,m]=f.useState(String(e.weight/10)),[g,S]=f.useState(e.payload||Er),[C,x]=gr(e.overrides||[]),{context:A}=ct(),[y,v]=f.useState({}),w=h=>{v(b=>({...b,[h]:void 0}))},R=(h,b)=>{v(E=>({...E,[h]:b}))};f.useEffect(()=>{var h;w("percentage"),(h=s.error)!=null&&h.includes("%")&&R("percentage","Total weight must equal 100%")},[s.error]);const P=!e.new,D=n.filter(({id:h,weightType:b})=>h!==e.id&&b===X.VARIABLE).length>0,$=h=>{const b=h.weightType===X.VARIABLE,E=n.some(L=>L.weightType===X.FIX),V=n.filter(L=>L.weightType===X.VARIABLE).length===1;return E&&V&&b},O=h=>{w("name"),Z(h,e.id)||R("name","A variant with that name already exists for this environment."),r(h)},B=h=>{(h===""||te(h))&&m(h)},U=h=>{T(h)||R("payload","Invalid JSON.")},Y=()=>{A.length>0&&x({type:"ADD",payload:{contextName:A[0].name,values:[]}})},K=h=>Boolean(h.length),Z=(h,b)=>P||!n.some(E=>E.name===h&&E.id!==b),te=h=>{if(!l)return!0;if(h===""||h.match(/\.[0-9]{2,}$/))return!1;const b=Number(h);return b>=0&&b<=100},T=h=>{try{return h.type==="json"&&JSON.parse(h.value),!0}catch{return!1}};return f.useEffect(()=>{a({...e,name:i,weight:Number(l?p:100)*10,weightType:l?X.FIX:X.VARIABLE,stickiness:(n==null?void 0:n.length)>0?n[0].stickiness:"default",payload:g.value?g:void 0,overrides:C.map(h=>({contextName:h.contextName,values:h.values})).filter(h=>h.values&&h.values.length>0),isValid:K(i)&&Z(i,e.id)&&te(p)&&T(g)&&!s.error})},[i,l,p,g,C]),f.useEffect(()=>{l||m(String(e.weight/10))},[e.weight]),c(hr,{children:[t(mr,{arrow:!0,title:$(e)?"You need to have at least one variable variant":"Delete variant",children:t("div",{children:t($e,{"data-testid":`VARIANT_DELETE_BUTTON_${e.name}`,onClick:()=>o(e.id),disabled:$(e),children:t(tt,{})})})}),c(wr,{children:[c(vr,{children:[t(ln,{children:"Variant name"}),t(fr,{children:"This will be used to identify the variant in your code"}),t(Bt,{id:`variant-name-input-${e.id}`,"data-testid":"VARIANT_NAME_INPUT",label:"Variant name",error:Boolean(y.name),errorText:y.name,value:i,onChange:h=>O(h.target.value),disabled:P,required:!0})]}),t(I,{condition:D,show:c(br,{children:[t(yr,{label:"Custom percentage",control:t(oa,{"data-testid":"VARIANT_WEIGHT_CHECK",checked:l,onChange:h=>u(h.target.checked)})}),t(Cr,{"data-testid":"VARIANT_WEIGHT_INPUT",type:"number",label:"Variant weight",error:Boolean(y.percentage),errorText:y.percentage,value:p,onChange:h=>B(h.target.value),required:l,disabled:!l,"aria-valuemin":0,"aria-valuemax":100,InputProps:{endAdornment:t(sa,{position:"end",children:"%"})}})]})})]}),c(Pt,{children:["Payload",t(Ye,{tooltip:"Passed along with the the variant object."})]}),c(dn,{children:[t(Tr,{id:"variant-payload-type",name:"type",label:"Type",value:g.type,options:Ar,onChange:h=>{w("payload"),S(b=>({...b,type:h.target.value}))}}),t(Sr,{children:t(Bt,{id:"variant-payload-value",name:"variant-payload-value",label:"Value",multiline:g.type!=="string",rows:g.type==="string"?1:4,value:g.value,onChange:h=>{w("payload"),S(b=>({...b,value:h.target.value}))},placeholder:g.type==="json"?'{ "hello": "world" }':"",onBlur:()=>U(g),error:Boolean(y.payload),errorText:y.payload})})]}),c(Pt,{children:["Overrides",t(Ye,{tooltip:"Here you can specify which users should get this variant."})]}),t(ur,{overrides:C,overridesDispatch:x}),t("div",{children:t(xr,{onClick:Y,variant:"text",color:"primary",children:"Add override"})})]})},Rr=d("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"},marginTop:e.spacing(-3.5),marginBottom:e.spacing(2),backgroundColor:e.palette.background.default,paddingTop:e.spacing(2),paddingBottom:e.spacing(2),position:"sticky",top:0,zIndex:2})),Fr=d(Qt,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.neutral.border:e.palette.primary.main})),kr=d("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontSize:e.fontSizes.mainHeader,fontWeight:e.fontWeight.bold})),$r=d("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),Pr=d(he)(({theme:e})=>({marginBottom:e.spacing(2)})),Br=d(he)(({theme:e})=>({marginTop:e.spacing(4)})),Dr=d("div")({display:"flex",flexDirection:"column"}),Or=d("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),Dt=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),Vr=d(ye)(({theme:e})=>({margin:e.spacing(4,0)})),Mr=d(ra)(({theme:e})=>({minWidth:e.spacing(20),width:"100%"})),Lr=d("div")(({theme:e})=>({marginTop:"auto",paddingTop:e.spacing(4),display:"flex",justifyContent:"flex-end"})),_r=d(re)(({theme:e})=>({marginLeft:e.spacing(3)})),jr=({environment:e,open:n,setOpen:a,getApiPayload:o,getCrPayload:s,onConfirm:i})=>{var xe;const r=F("projectId"),l=F("featureId"),{uiConfig:u}=lt(),{context:p}=ct(),{defaultStickiness:m}=ia(r),{isChangeRequestConfigured:g}=oe(r),{data:S}=ve(r),{changeRequestInReviewOrApproved:C,alert:x}=la(S),A=(e==null?void 0:e.variants)||[],[y,v]=f.useState([]),[w,R]=f.useState();f.useEffect(()=>{v(A.length?A.map(k=>({...k,isValid:!0,new:!1,id:_e()})):[{name:"",weightType:X.VARIABLE,weight:0,overrides:[],stickiness:(y==null?void 0:y.length)>0?y[0].stickiness:m,new:!0,isValid:!1,id:_e()}])},[n]);const P=(k,W)=>{v(ie=>mt(ie.map(Ae=>Ae.id===W?k:Ae),1e3))},D=()=>{const k=_e();v(W=>[...W,{name:"",weightType:X.VARIABLE,weight:0,overrides:[],stickiness:(W==null?void 0:W.length)>0?W[0].stickiness:"default",new:!0,isValid:!1,id:k}]),R(k)};f.useEffect(()=>{if(w){const k=document.getElementById(`variant-name-input-${w}`);k==null||k.scrollIntoView({behavior:"smooth",block:"center"}),k==null||k.focus({preventScroll:!0}),R(void 0)}},[w]);const $=y.map(({new:k,isValid:W,id:ie,...Ae})=>Ae),O=o(A,$),B=s($),U=async k=>{k.preventDefault(),i($)},Y=()=>T?`curl --location --request POST '${u.unleashUrl}/api/admin/projects/${r}/environments/${e==null?void 0:e.name}/change-requests' \\
2
2
  --header 'Authorization: INSERT_API_KEY' \\
3
3
  --header 'Content-Type: application/json' \\
4
4
  --data-raw '${JSON.stringify(B,void 0,2)}'`:`curl --location --request PATCH '${u.unleashUrl}/api/admin/projects/${r}/features/${l}/environments/${e==null?void 0:e.name}/variants' \\
5
5
  --header 'Authorization: INSERT_API_KEY' \\
6
6
  --header 'Content-Type: application/json' \\
7
- --data-raw '${JSON.stringify(O.patch,void 0,2)}'`,K=y.every(({isValid:k})=>k),Z=C((e==null?void 0:e.name)||""),te=Z?"Add to existing change request":"Add change to draft",T=g((e==null?void 0:e.name)||"")&&u.flags.crOnVariants,h=((xe=$[0])==null?void 0:xe.stickiness)||m,b=f.useMemo(()=>["default",...p.filter(k=>k.stickiness).map(k=>k.name)],[p]),E=b.map(k=>({key:k,label:k}));b.includes(h)||E.push({key:h,label:h});const V=async k=>{v(W=>W.map(ie=>({...ie,stickiness:k})))},L=k=>{V(k).catch(console.warn)},[_,q]=f.useState();return f.useEffect(()=>{q(void 0),O.error&&q(O.error)},[O.error]),t(Ke,{open:n,onClose:()=>{a(!1)},label:"",children:c(la,{modal:!0,title:"",description:"Variants allows you to return a variant object if the feature toggle is considered enabled for the current request.",documentationLink:"https://docs.getunleash.io/reference/feature-toggle-variants",documentationLinkLabel:"Feature toggle variants documentation",formatApiCode:Y,loading:!n,children:[c(Rr,{children:[c("div",{children:[t(Fr,{deprecated:!(e!=null&&e.enabled)}),t(kr,{deprecated:!(e!=null&&e.enabled),children:e==null?void 0:e.name})]}),t(ae,{"data-testid":"MODAL_ADD_VARIANT_BUTTON",onClick:D,variant:"outlined",permission:ce,projectId:r,environmentId:e==null?void 0:e.name,children:"Add variant"})]}),c($r,{onSubmit:U,children:[t(I,{condition:Z,show:x,elseShow:t(I,{condition:Boolean(T),show:c(Pr,{severity:"info",children:[t("strong",{children:"Change requests"})," are enabled",e?` for ${e.name}`:"",". Your changes need to be approved before they will be live. All the changes you do now will be added into a draft that you can submit for review."]})})}),t(Dr,{children:y.map(k=>t(Ir,{variant:k,variants:y,updateVariant:W=>P(W,k.id),removeVariant:()=>v(W=>mt(W.filter(ie=>ie.id!==k.id),1e3)),projectId:r,apiPayload:O},k.id))}),t(ae,{onClick:D,variant:"outlined",permission:ce,projectId:r,environmentId:e==null?void 0:e.name,children:"Add variant"}),t(Vr,{}),t(I,{condition:y.length>0,show:c(M,{children:[t(Or,{children:t("p",{children:"Stickiness"})}),c(Dt,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t(it,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]}),t("div",{children:t(Mr,{value:h,label:"",editable:!0,onChange:k=>L(k.target.value)})})]}),elseShow:t(Dt,{children:"This environment has no variants. Get started by adding a variant."})}),c(Br,{severity:"error",hidden:!Boolean(_),children:[t("strong",{children:"Error: "}),_]}),c(Lr,{children:[t(re,{"data-testid":"DIALOGUE_CONFIRM_ID",type:"submit",variant:"contained",color:"primary",disabled:!K,children:T?te:"Save variants"}),t(_r,{onClick:()=>{a(!1)},children:"Cancel"})]})]})]})})},Nr=d("div")(({theme:e})=>({padding:e.spacing(3),borderRadius:e.shape.borderRadiusLarge,border:`1px solid ${e.palette.divider}`,"&:not(:last-child)":{marginBottom:e.spacing(3)}})),zr=d("div")({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"}}),Wr=d(Qt,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.neutral.border:e.palette.primary.main})),Ur=d("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontWeight:e.fontWeight.bold})),qr=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),Hr=d("div")(({theme:e})=>({margin:e.spacing(3,0)})),Gr=d("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),Yr=({environment:e,searchValue:n,children:a})=>{var i;const o=e.variants??[],s=((i=o[0])==null?void 0:i.stickiness)||"default";return c(Nr,{children:[c(zr,{children:[c("div",{children:[t(Wr,{deprecated:!e.enabled}),t(Ur,{deprecated:!e.enabled,children:e.name})]}),a]}),t(I,{condition:o.length>0,show:c(M,{children:[t(Hr,{children:t(ua,{variants:o,searchValue:n})}),t(I,{condition:o.length>1,show:c(M,{children:[c(Gr,{children:[t("p",{children:"Stickiness:"}),t(fe,{children:s})]}),c(qr,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t(it,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]})]})})]})})]})},Kr=d(at)(({theme:e})=>({"& span":{fontSize:e.fontSizes.smallBody}})),Jr=({environment:e,permission:n,projectId:a,environmentId:o,onCopyVariantsFrom:s,otherEnvsWithVariants:i})=>{const[r,l]=f.useState(null),u=Boolean(r),p=e.variants??[];return t(I,{condition:i.length>0&&p.length===0,show:c(M,{children:[t(ae,{onClick:m=>{l(m.currentTarget)},id:`copy-from-menu-${e.name}`,"aria-controls":u?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":u?"true":void 0,variant:"outlined",permission:n,projectId:a,environmentId:o,children:"Copy variants from"}),t(Pe,{anchorEl:r,open:u,onClose:()=>l(null),MenuListProps:{"aria-labelledby":`copy-from-menu-${e.name}`},children:i.map(m=>t(Be,{onClick:()=>s(m,e),children:t(Kr,{children:`Copy from ${m.name}`})},m.name))})]})})},Xr=({permission:e,projectId:n,environment:a,checked:o,onClick:s,...i})=>{const r=pa(e,n,a);return c(Be,{disabled:!r,onClick:s,...i,children:[t(ga,{checked:o}),a]})},Qr=d(Pe)(({theme:e})=>({"& > div > ul":{display:"flex",flexDirection:"column",justifyContent:"center","& > li":{padding:e.spacing(0,1)}}})),Zr=d("div")(({theme:e})=>({margin:e.spacing(1,2)})),ei=d(re)(({theme:e})=>({marginTop:e.spacing(2)})),ti=({current:e,environments:n,permission:a,projectId:o,onSubmit:s})=>{var A;const[i,r]=f.useState(null),l=Boolean(i),[u,p]=f.useState([]),m=y=>{p(v=>[...v,y])},g=y=>{p(v=>v.filter(({name:w})=>w!==y.name))},S=y=>{u.includes(y)?g(y):m(y)},C=()=>{p([]),r(null)},x=((A=n.find(y=>y.name===e))==null?void 0:A.variants)??[];return t(I,{condition:x.length>0&&n.length>1,show:c(M,{children:[t(re,{onClick:y=>{r(y.currentTarget)},id:`push-to-menu-${e}`,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,variant:"outlined",children:"Push to environment"}),c(Qr,{anchorEl:i,open:l,onClose:()=>r(null),MenuListProps:{"aria-labelledby":`push-to-menu-${e}`},children:[n.filter(y=>y.name!==e).map(y=>t(Xr,{projectId:o,permission:a,environment:y.name,checked:u.includes(y),onClick:()=>S(y)},y.name)),c(Zr,{children:[t(ye,{}),c(ei,{variant:"outlined",onClick:()=>{s(u),C()},disabled:u.length===0,children:["Push to selected (",u.length,")"]})]})]})]})})},ni=d(he)(({theme:e})=>({marginBottom:e.spacing(4),"& code":{fontWeight:e.fontWeight.bold}})),ai=d("div")(({theme:e})=>({display:"flex",gap:e.spacing(1.5)})),oi=()=>{const{uiConfig:e}=lt(),{setToastData:n,setToastApiError:a}=G(),o=et(),s=De(o.breakpoints.down("md")),i=F("projectId"),r=F("featureId"),{feature:l,refetchFeature:u,loading:p}=j(i,r),{patchFeatureEnvironmentVariants:m,overrideVariantsInEnvironments:g}=Te(),{refetch:S}=ve(i),{addChange:C}=nt(),{isChangeRequestConfigured:x}=oe(i),[A,y]=f.useState(""),[v,w]=f.useState(),[R,P]=f.useState(!1),D=f.useMemo(()=>{var T;return((T=l==null?void 0:l.environments)==null?void 0:T.map(h=>({...h,crEnabled:e.flags.crOnVariants&&x(h.name)})))||[]},[l.environments,e.flags.crOnVariants]),$=(T,h)=>fa(T,h),O=(T,h)=>{try{const b=ma(h,1e3);return{patch:$(T,b)}}catch(b){return{patch:[],error:z(b)}}},B=T=>({feature:r,action:"patchVariant",payload:{variants:T}}),U=async(T,h)=>{if(T.crEnabled)await C(i,T.name,B(h)),S();else{const b=T.variants??[],{patch:E,error:V}=O(b,h);if(E.length===0)return;if(V){n({type:"error",title:V});return}await m(i,r,T.name,E)}u()},Y=async(T,h)=>{try{const b=h.filter(({crEnabled:q})=>q),E=h.filter(({crEnabled:q})=>!q);b.length&&await Promise.all(b.map(q=>C(i,q.name,B(T)))),E.length&&await g(i,r,T,E.map(({name:q})=>q)),S(),u();const V=E.length?`Variants pushed to ${E.length===1?E[0].name:`${E.length} environments`}`:"",L=b.length?`Variants push added to ${b.length===1?`${b[0].name} draft`:`${b.length} drafts`}`:"",_=`${V}${V&&L?". ":""}${L}`;n({title:_,type:"success"})}catch(b){a(z(b))}},K=T=>{w(T),P(!0)},Z=async T=>{if(v)try{await U(v,T),P(!1),n({title:v.crEnabled?"Variant changes added to draft":"Variants updated successfully",type:"success"})}catch(h){a(z(h))}},te=async(T,h)=>{try{const b=T.variants??[];await U(h,b),n({title:h.crEnabled?"Variants copy added to draft":"Variants copied successfully",type:"success"})}catch(b){a(z(b))}};return c(dt,{isLoading:p,header:t(ha,{title:"Variants",actions:t(I,{condition:!s,show:t(M,{children:t(ft,{initialValue:A,onChange:y})})}),children:t(I,{condition:s,show:t(ft,{initialValue:A,onChange:y})})}),children:[c(ni,{severity:"info",children:["Variants allows you to return a variant object if the feature toggle is considered enabled for the current request. When using variants you should use the ",t("code",{children:"getVariant()"})," method in the Client SDK."]}),D.map(T=>{var b;const h=D.filter(({name:E,variants:V})=>E!==T.name&&(V==null?void 0:V.length));return t(Yr,{environment:T,searchValue:A,children:c(ai,{children:[t(ti,{current:T.name,environments:D,permission:ce,projectId:i,onSubmit:E=>Y(T.variants??[],E)}),t(Jr,{environment:T,permission:ce,projectId:i,environmentId:T.name,onCopyVariantsFrom:te,otherEnvsWithVariants:h}),t(I,{condition:Boolean((b=T.variants)==null?void 0:b.length),show:t(Q,{"data-testid":"EDIT_VARIANTS_BUTTON",onClick:()=>K(T),permission:ce,projectId:i,environmentId:T.name,tooltipProps:{title:"Edit variants"},children:t(me,{})}),elseShow:t(ae,{"data-testid":"ADD_VARIANT_BUTTON",onClick:()=>K(T),variant:"outlined",permission:ce,projectId:i,environmentId:T.name,children:"Add variant"})})]})},T.name)}),t(jr,{environment:v,open:R,setOpen:P,getApiPayload:O,getCrPayload:B,onConfirm:Z})]})},si=be("api/admin/client-metrics/features"),pn=(e,n)=>{const a=be(`api/admin/client-metrics/features/${e}/raw?hoursBack=${n}`),{data:o,error:s}=Qe(a,()=>ri(a)),i=f.useCallback(()=>{Ze(si).catch(console.warn)},[]);return{featureMetrics:o==null?void 0:o.data,loading:!s&&!o,refetchFeatureMetrics:i,error:s}},ri=e=>fetch(e).then(ke("Features")).then(n=>n.json()).then(),Se=48,ii=({hoursBack:e,setHoursBack:n})=>{const a=o=>{n(ci(o))};return t(ya,{label:"Period",name:"feature-metrics-period",id:"feature-metrics-period",options:li,value:String(e),onChange:a,fullWidth:!0})},ci=e=>{switch(e){case"1":return 1;case"24":return 24;default:return Se}},li=[{key:"1",label:"Last hour"},{key:"24",label:"Last 24 hours"},{key:`${Se}`,label:`Last ${Se} hours`}],di=({metrics:e,tableSectionId:n})=>{const a=De(Zt.breakpoints.down("md")),o=f.useMemo(()=>({sortBy:[{id:"timestamp"}]}),[]),{getTableProps:s,getTableBodyProps:i,headerGroups:r,rows:l,prepareRow:u,setHiddenColumns:p}=Le.useTable({initialState:o,columns:Ot,data:e,autoResetHiddenColumns:!1,disableSortRemove:!0,defaultColumn:{Cell:Sa}},Le.useGlobalFilter,Le.useSortBy);return ba([{condition:a,columns:["appName","environment"]}],p,Ot),e.length===0?null:c(Ca,{...s(),rowHeight:"standard",id:n,children:[t(va,{headerGroups:r}),t(wa,{...i(),children:l.map(m=>(u(m),t(Ta,{hover:!0,...m.getRowProps(),children:m.cells.map(g=>t(xa,{...g.getCellProps(),children:g.render("Cell")}))})))})]})},Ot=[{id:"Icon",width:"1%",disableSortBy:!0,Cell:()=>t(Aa,{icon:t(ho,{color:"disabled"})})},{Header:"Time",accessor:"timestamp",Cell:e=>t(Ea,{value:e.row.original.timestamp})},{Header:"Application",accessor:"appName"},{Header:"Environment",accessor:"environment"},{id:"requested",Header:"Requested",accessor:e=>e.yes+e.no},{Header:"Exposed",accessor:"yes"}],ui=({metrics:e,...n})=>{const a=f.useMemo(()=>e.reduce((s,i)=>s+i.yes,0),[e]),o=f.useMemo(()=>e.reduce((s,i)=>s+i.no,0),[e]);return t(rn,{...n,totalYes:a,totalNo:o})},pi=({metrics:e,hoursBack:n})=>{const a=yt(),o=yt();return e.length===0?c(H,{mt:6,children:[t(N,{variant:"body1",paragraph:!0,children:"We have yet to receive any metrics for this feature toggle in the selected time period."}),t(N,{variant:"body1",paragraph:!0,children:"Please note that, since the SDKs send metrics on an interval, it might take some time before metrics appear."})]}):c(f.Suspense,{fallback:null,children:[t(H,{borderTop:1,pt:2,mt:3,borderColor:Zt.palette.divider,children:t(gi,{metrics:e,hoursBack:n,statsSectionId:a})}),t(H,{mt:4,children:t(ui,{metrics:e,hoursBack:n,statsSectionId:a,tableSectionId:o})}),t(H,{mt:4,children:t(di,{metrics:e,tableSectionId:o})})]})},gi=Ia.lazy(()=>import("./FeatureMetricsChart-37e55387.js")),Xe=e=>{const{search:n}=window.location,a=ge(),o=f.useMemo(()=>new URLSearchParams(n),[n]),s=f.useCallback(i=>{const r=new URLSearchParams(n);r.set(e,i),a({search:r.toString()},{replace:!0})},[e,n,a]);return[o.get(e)||void 0,s]},hi=e=>{const[n,a]=Xe(e),o=f.useCallback(s=>a(String(s)),[a]);return[Number.isFinite(Number(n))?Number(n):void 0,o]},mi=d("h2")(({theme:e})=>({margin:0,marginBottom:e.spacing(1),fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.thin,color:e.palette.text.secondary})),fi=d("ul")(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing(1),listStyleType:"none",padding:0,minHeight:"100%"})),yi=d("li")(({theme:e})=>({"& > [aria-pressed=true]":{backgroundColor:e.palette.background.alternative,color:e.palette.primary.contrastText},"& > [aria-pressed=true]:hover":{backgroundColor:e.palette.primary.light}})),Vt=({title:e,values:n,value:a,setValue:o})=>{const s=r=>()=>{n.has(r)&&o(r)},i=f.useMemo(()=>Array.from(n).sort((r,l)=>r.localeCompare(l)),[n]);return c("div",{children:[t(mi,{children:e}),t(fi,{children:i.map(r=>t(yi,{children:t(Ht,{label:r,onClick:s(r),"aria-pressed":r===a,sx:Ra})},r))})]})},Si=d("div")(({theme:e})=>({[e.breakpoints.down("md")]:{marginTop:e.spacing(2)}})),bi=()=>{const e=F("projectId"),n=F("featureId"),a=Ci(e,n),o=vi(n);Gt("Metrics");const[s=Se,i]=hi("hoursBack"),{featureMetrics:r}=pn(n,s),[l,u]=f.useState(r);f.useEffect(()=>{r&&u(r)},[r]);const p=Array.from(a)[0],m=Array.from(o)[0],[g=p,S]=Xe("environment"),[C=m,x]=Xe("application"),A=f.useMemo(()=>l==null?void 0:l.filter(y=>y.environment===g).filter(y=>y.appName===C),[l,g,C]);return A?c(dt,{children:[c(ne,{container:!0,component:"header",spacing:2,alignItems:"flex-end",children:[t(ne,{item:!0,xs:12,md:5,children:t(I,{condition:a.size>0,show:t(Vt,{title:"Environments",values:a,value:g,setValue:S})})}),t(ne,{item:!0,xs:12,md:5,children:t(I,{condition:o.size>0,show:t(Vt,{title:"Applications",values:o,value:C,setValue:x})})}),t(ne,{item:!0,xs:12,md:2,children:t(Si,{children:t(ii,{hoursBack:s,setHoursBack:i})})})]}),t(pi,{metrics:A,hoursBack:s})]}):null},Ci=(e,n)=>{const{feature:a}=j(e,n),o=a.environments.map(s=>s.name);return new Set(o)},vi=e=>{const{featureMetrics:n=[]}=pn(e,Se),a=n.map(o=>o.appName);return new Set(a)},wi=(e,n)=>{const a=new Set(e),o=new Set(n);return a.size!==o.size?!1:[...a].every(s=>o.has(s))},Mt=d("div")(({theme:e})=>({display:"grid",gap:e.spacing(2)})),Lt=d(he)(({theme:e})=>({marginBottom:e.spacing(1)})),Ti=d(rt)({padding:0}),xi=({projectId:e,open:n,onClose:a,onClick:o,feature:s,changeRequests:i})=>{const r=F("projectId"),{project:l}=en(e),{isChangeRequestConfiguredInAnyEnv:u}=oe(e),p=u(),m=f.useMemo(()=>wi(s.environments.map(S=>S.name),l.environments),[s,l]),g=i?i.length>0:!1;return t(I,{condition:m&&!g&&!p,show:t(de,{open:n,onClose:a,onClick:o,title:"Confirm change project",primaryButtonText:"Change project",secondaryButtonText:"Cancel",children:c(Mt,{children:[t(Lt,{severity:"success",children:"This feature toggle is compatible with the new project."}),t("p",{children:"Are you sure you want to change the project for this toggle?"})]})}),elseShow:t(de,{open:n,onClick:a,title:"Confirm change project",primaryButtonText:"Close",children:c(Mt,{children:[t(Lt,{severity:"warning",children:"Cannot proceed with the move"}),t(I,{condition:!m,show:t("p",{children:"In order to move a feature toggle between two projects, both projects must have the exact same environments enabled."})}),t(I,{condition:g,show:c(M,{children:[t("p",{children:"The feature toggle must not have any pending change requests. This feature toggle is currently referenced in the following change requests:"}),t(Ti,{children:i==null?void 0:i.map(S=>t(Re,{children:c(J,{to:`/projects/${r}/change-requests/${S.id}`,children:["View change request"," ",S.id]})},S.id))})]})}),t(I,{condition:p,show:c("p",{children:["You're not allowed to move the feature to project"," ",t(J,{to:`/projects/${e}/settings/change-requests`,children:e}),". This project has change requests enabled."]})})]})})})},Ai=e=>fetch(e).then(ke("ChangeRequest")).then(n=>n.json()),Ei=(e,n)=>{const{data:a,error:o,mutate:s}=Fa([],be(`api/admin/projects/${e}/change-requests/pending/${n}`),Ai);return{changeRequests:a,loading:!o&&!a,refetch:s,error:o}},Ii=()=>{const{hasAccess:e}=f.useContext(ot),n=F("projectId"),a=F("featureId"),{feature:o,refetchFeature:s}=j(n,a),[i,r]=f.useState(!1),{changeFeatureProject:l}=Te(),{setToastData:u,setToastApiError:p}=G(),[m,g]=f.useState(n),{projects:S}=ka(),C=ge(),{changeRequests:x}=Ei(n,a),A=async()=>{try{m&&(await l(n,a,m),s(),u({title:"Project changed",type:"success"}),r(!1),C(`/projects/${m}/features/${a}/settings`,{replace:!0}))}catch(v){p(z(v))}},y=f.useMemo(()=>S.map(v=>v.id).filter(v=>e(St,v)),[S,e]);return y.length===0?null:c(M,{children:[t($a,{value:m,onChange:g,label:"Project",filter:v=>y.includes(v),enabled:!0}),t(ae,{permission:St,onClick:()=>r(!0),disabled:m===n,projectId:n,children:"Save"}),t(xi,{changeRequests:x,projectId:m,open:i,feature:o,onClose:()=>r(!1),onClick:A})]})},Ri=d("div")({display:"flex",alignItems:"center"}),Fi=d(N)(({theme:e})=>({fontSize:e.fontSizes.mainHeader})),ki=({projectId:e,featureId:n})=>{var i;const{feature:a}=j(e,n),o=ge();return c(M,{children:[c(Ri,{children:[t(Fi,{children:"Feature information"}),t(Q,{permission:le,projectId:e,"data-loading":!0,onClick:()=>{o(`/projects/${e}/features/${n}/edit`)},tooltipProps:{title:"Edit"},children:t(me,{})})]}),c(N,{children:["Name: ",t("strong",{children:a.name})]}),c(N,{children:["Description:"," ",t("strong",{children:(i=a.description)!=null&&i.length?a.description:"no description"})]}),c(N,{children:["Type: ",t("strong",{children:a.type})]}),c(N,{children:["Impression Data:"," ",t("strong",{children:a.impressionData?"enabled":"disabled"})]})]})},Ee="metadata",Ge="project",$i=d("div")(({theme:e})=>({width:"20%",borderRight:`1px solid ${e.palette.divider}`,padding:e.spacing(2,0),[e.breakpoints.down("md")]:{width:"35%"}})),Pi=d("div")(({theme:e})=>({padding:e.spacing(4),display:"flex",flexDirection:"column",width:400,["& > *"]:{margin:e.spacing(1,0)}})),Bi=()=>{const e=F("projectId"),n=F("featureId"),[a,o]=f.useState(Ee),{uiConfig:s}=lt();return t(dt,{header:"Settings",sx:{padding:0},children:c(H,{sx:{display:"flex"},children:[t($i,{children:c(rt,{children:[t(Re,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>o(Ee),selected:a===Ee,children:"Metadata"},0),t(Re,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>o(Ge),selected:a===Ge,hidden:!s.flags.P,children:"Project"},1)]})}),c(Pi,{children:[t(I,{condition:a===Ee,show:t(ki,{projectId:e,featureId:n})}),t(I,{condition:a===Ge&&s.flags.P,show:t(Ii,{})})]})]})})},Di=({stale:e,showActive:n=!0})=>!e&&!n?null:t("div",{"data-loading":!0,style:{marginLeft:"8px"},children:t(fe,{color:e?"error":"success",title:e?"Feature toggle is deprecated.":"Feature toggle is active.",children:e?"Stale":"Active"})}),_t=d("strong")({wordBreak:"break-all"}),Oi=()=>{const e=F("projectId"),n=F("featureId"),{archivedFeatures:a}=Pa(),o=Ba(e,{name:n});return a?a.some(i=>i.name===n)?c("p",{children:["The feature ",t(_t,{children:n})," has been archived. You can find it on the"," ",t(J,{to:`/projects/${e}/archive`,children:"project archive page"}),"."]}):c("p",{children:["The feature ",t(_t,{children:n})," does not exist. Would you like to"," ",t(J,{to:o,children:"create it"}),"?"]}):null},Vi=d("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),Mi=d("div")(({theme:e})=>({padding:e.spacing(2,4,2,2),display:"flex",justifyContent:"space-between",alignItems:"center",[e.breakpoints.down(500)]:{flexDirection:"column"}})),Li=d("div")({display:"flex",alignItems:"center"}),_i=d("h1")(({theme:e})=>({fontSize:e.fontSizes.mainHeader,fontWeight:"normal",display:"flex",alignItems:"center",wordBreak:"break-all"})),ji=d("div")({flexShrink:0,display:"flex"}),Ni=d("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.divider,height:"1px"})),zi=d("div")(({theme:e})=>({padding:e.spacing(0,4)})),Wi=d(Da)(({theme:e})=>({textTransform:"none",width:"auto",fontSize:e.fontSizes.bodySize,padding:"0 !important",[e.breakpoints.up("md")]:{minWidth:160}})),Ki=()=>{const e=F("projectId"),n=F("featureId"),{refetch:a}=en(e),{favorite:o,unfavorite:s}=Oa(),{refetchFeature:i}=j(e,n),[r,l]=f.useState(!1),[u,p]=f.useState(!1),[m,g]=f.useState(!1),S=De(`(max-width:${500}px)`),{feature:C,loading:x,error:A,status:y}=j(e,n),v=ge(),{pathname:w}=Va(),R=Ma(x),P=`/projects/${e}/features/${n}`,D=[{title:"Overview",path:`${P}`,name:"overview"},{title:"Metrics",path:`${P}/metrics`,name:"Metrics"},{title:"Variants",path:`${P}/variants`,name:"Variants"},{title:"Settings",path:`${P}/settings`,name:"Settings"},{title:"Event log",path:`${P}/logs`,name:"Event log"}],$=D.find(B=>B.path===w)??D[0],O=async()=>{C!=null&&C.favorite?await s(e,C.name):await o(e,C.name),i()};return y===404?t(Oi,{}):A!==void 0?t("div",{ref:R}):c("div",{ref:R,children:[c(Vi,{children:[c(Mi,{children:[c(Li,{children:[t(La,{onClick:O,isFavorite:C==null?void 0:C.favorite}),c(_i,{"data-loading":!0,children:[C.name," "]}),t(I,{condition:!S,show:t(Di,{stale:C==null?void 0:C.stale})})]}),c(ji,{children:[t(Q,{permission:_a,projectId:e,"data-loading":!0,component:J,to:`/projects/${e}/features/${n}/strategies/copy`,tooltipProps:{title:"Copy feature toggle"},children:t(ja,{})}),t(Q,{permission:Na,projectId:e,tooltipProps:{title:"Archive feature toggle"},"data-loading":!0,onClick:()=>p(!0),children:t(to,{})}),t(Q,{onClick:()=>g(!0),permission:le,projectId:e,tooltipProps:{title:"Toggle stale state"},"data-loading":!0,children:t(no,{})}),t(Q,{onClick:()=>l(!0),permission:le,projectId:e,tooltipProps:{title:"Add tag"},"data-loading":!0,children:t(za,{})})]})]}),t(Ni,{}),t(zi,{children:t(Wa,{value:$.path,indicatorColor:"primary",textColor:"primary",children:D.map(B=>t(Wi,{label:B.title,value:B.path,onClick:()=>v(B.path)},B.title))})})]}),c(Yt,{children:[t(se,{path:"metrics",element:t(bi,{})}),t(se,{path:"logs",element:t(yo,{})}),t(se,{path:"variants",element:t(oi,{})}),t(se,{path:"settings",element:t(Bi,{})}),t(se,{path:"*",element:t(or,{})})]}),t(ao,{isOpen:u,onConfirm:()=>{a(),v(`/projects/${e}`)},onClose:()=>p(!1),projectId:e,featureIds:[n]}),t(oo,{isStale:C.stale,isOpen:m,onClose:()=>{g(!1),i()},featureId:n,projectId:e}),t(ln,{open:r,setOpen:l})]})};export{Ki as default};
7
+ --data-raw '${JSON.stringify(O.patch,void 0,2)}'`,K=y.every(({isValid:k})=>k),Z=C((e==null?void 0:e.name)||""),te=Z?"Add to existing change request":"Add change to draft",T=g((e==null?void 0:e.name)||"")&&u.flags.crOnVariants,h=((xe=$[0])==null?void 0:xe.stickiness)||m,b=f.useMemo(()=>["default",...p.filter(k=>k.stickiness).map(k=>k.name)],[p]),E=b.map(k=>({key:k,label:k}));b.includes(h)||E.push({key:h,label:h});const V=async k=>{v(W=>W.map(ie=>({...ie,stickiness:k})))},L=k=>{V(k).catch(console.warn)},[_,q]=f.useState();return f.useEffect(()=>{q(void 0),O.error&&q(O.error)},[O.error]),t(Ke,{open:n,onClose:()=>{a(!1)},label:"",children:c(ca,{modal:!0,title:"",description:"Variants allows you to return a variant object if the feature toggle is considered enabled for the current request.",documentationLink:"https://docs.getunleash.io/reference/feature-toggle-variants",documentationLinkLabel:"Feature toggle variants documentation",formatApiCode:Y,loading:!n,children:[c(Rr,{children:[c("div",{children:[t(Fr,{deprecated:!(e!=null&&e.enabled)}),t(kr,{deprecated:!(e!=null&&e.enabled),children:e==null?void 0:e.name})]}),t(ae,{"data-testid":"MODAL_ADD_VARIANT_BUTTON",onClick:D,variant:"outlined",permission:ce,projectId:r,environmentId:e==null?void 0:e.name,children:"Add variant"})]}),c($r,{onSubmit:U,children:[t(I,{condition:Z,show:x,elseShow:t(I,{condition:Boolean(T),show:c(Pr,{severity:"info",children:[t("strong",{children:"Change requests"})," are enabled",e?` for ${e.name}`:"",". Your changes need to be approved before they will be live. All the changes you do now will be added into a draft that you can submit for review."]})})}),t(Dr,{children:y.map(k=>t(Ir,{variant:k,variants:y,updateVariant:W=>P(W,k.id),removeVariant:()=>v(W=>mt(W.filter(ie=>ie.id!==k.id),1e3)),projectId:r,apiPayload:O},k.id))}),t(ae,{onClick:D,variant:"outlined",permission:ce,projectId:r,environmentId:e==null?void 0:e.name,children:"Add variant"}),t(Vr,{}),t(I,{condition:y.length>0,show:c(M,{children:[t(Or,{children:t("p",{children:"Stickiness"})}),c(Dt,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t(it,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]}),t("div",{children:t(Mr,{value:h,label:"",editable:!0,onChange:k=>L(k.target.value)})})]}),elseShow:t(Dt,{children:"This environment has no variants. Get started by adding a variant."})}),c(Br,{severity:"error",hidden:!Boolean(_),children:[t("strong",{children:"Error: "}),_]}),c(Lr,{children:[t(re,{"data-testid":"DIALOGUE_CONFIRM_ID",type:"submit",variant:"contained",color:"primary",disabled:!K,children:T?te:"Save variants"}),t(_r,{onClick:()=>{a(!1)},children:"Cancel"})]})]})]})})},Nr=d("div")(({theme:e})=>({padding:e.spacing(3),borderRadius:e.shape.borderRadiusLarge,border:`1px solid ${e.palette.divider}`,"&:not(:last-child)":{marginBottom:e.spacing(3)}})),zr=d("div")({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"}}),Wr=d(Qt,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.neutral.border:e.palette.primary.main})),Ur=d("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontWeight:e.fontWeight.bold})),qr=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),Hr=d("div")(({theme:e})=>({margin:e.spacing(3,0)})),Gr=d("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),Yr=({environment:e,searchValue:n,children:a})=>{var i;const o=e.variants??[],s=((i=o[0])==null?void 0:i.stickiness)||"default";return c(Nr,{children:[c(zr,{children:[c("div",{children:[t(Wr,{deprecated:!e.enabled}),t(Ur,{deprecated:!e.enabled,children:e.name})]}),a]}),t(I,{condition:o.length>0,show:c(M,{children:[t(Hr,{children:t(da,{variants:o,searchValue:n})}),t(I,{condition:o.length>1,show:c(M,{children:[c(Gr,{children:[t("p",{children:"Stickiness:"}),t(fe,{children:s})]}),c(qr,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t(it,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]})]})})]})})]})},Kr=d(at)(({theme:e})=>({"& span":{fontSize:e.fontSizes.smallBody}})),Jr=({environment:e,permission:n,projectId:a,environmentId:o,onCopyVariantsFrom:s,otherEnvsWithVariants:i})=>{const[r,l]=f.useState(null),u=Boolean(r),p=e.variants??[];return t(I,{condition:i.length>0&&p.length===0,show:c(M,{children:[t(ae,{onClick:m=>{l(m.currentTarget)},id:`copy-from-menu-${e.name}`,"aria-controls":u?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":u?"true":void 0,variant:"outlined",permission:n,projectId:a,environmentId:o,children:"Copy variants from"}),t(Pe,{anchorEl:r,open:u,onClose:()=>l(null),MenuListProps:{"aria-labelledby":`copy-from-menu-${e.name}`},children:i.map(m=>t(Be,{onClick:()=>s(m,e),children:t(Kr,{children:`Copy from ${m.name}`})},m.name))})]})})},Xr=({permission:e,projectId:n,environment:a,checked:o,onClick:s,...i})=>{const r=ua(e,n,a);return c(Be,{disabled:!r,onClick:s,...i,children:[t(pa,{checked:o}),a]})},Qr=d(Pe)(({theme:e})=>({"& > div > ul":{display:"flex",flexDirection:"column",justifyContent:"center","& > li":{padding:e.spacing(0,1)}}})),Zr=d("div")(({theme:e})=>({margin:e.spacing(1,2)})),ei=d(re)(({theme:e})=>({marginTop:e.spacing(2)})),ti=({current:e,environments:n,permission:a,projectId:o,onSubmit:s})=>{var A;const[i,r]=f.useState(null),l=Boolean(i),[u,p]=f.useState([]),m=y=>{p(v=>[...v,y])},g=y=>{p(v=>v.filter(({name:w})=>w!==y.name))},S=y=>{u.includes(y)?g(y):m(y)},C=()=>{p([]),r(null)},x=((A=n.find(y=>y.name===e))==null?void 0:A.variants)??[];return t(I,{condition:x.length>0&&n.length>1,show:c(M,{children:[t(re,{onClick:y=>{r(y.currentTarget)},id:`push-to-menu-${e}`,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,variant:"outlined",children:"Push to environment"}),c(Qr,{anchorEl:i,open:l,onClose:()=>r(null),MenuListProps:{"aria-labelledby":`push-to-menu-${e}`},children:[n.filter(y=>y.name!==e).map(y=>t(Xr,{projectId:o,permission:a,environment:y.name,checked:u.includes(y),onClick:()=>S(y)},y.name)),c(Zr,{children:[t(ye,{}),c(ei,{variant:"outlined",onClick:()=>{s(u),C()},disabled:u.length===0,children:["Push to selected (",u.length,")"]})]})]})]})})},ni=d(he)(({theme:e})=>({marginBottom:e.spacing(4),"& code":{fontWeight:e.fontWeight.bold}})),ai=d("div")(({theme:e})=>({display:"flex",gap:e.spacing(1.5)})),oi=()=>{const{uiConfig:e}=lt(),{setToastData:n,setToastApiError:a}=G(),o=et(),s=De(o.breakpoints.down("md")),i=F("projectId"),r=F("featureId"),{feature:l,refetchFeature:u,loading:p}=j(i,r),{patchFeatureEnvironmentVariants:m,overrideVariantsInEnvironments:g}=Te(),{refetch:S}=ve(i),{addChange:C}=nt(),{isChangeRequestConfigured:x}=oe(i),[A,y]=f.useState(""),[v,w]=f.useState(),[R,P]=f.useState(!1),D=f.useMemo(()=>{var T;return((T=l==null?void 0:l.environments)==null?void 0:T.map(h=>({...h,crEnabled:e.flags.crOnVariants&&x(h.name)})))||[]},[l.environments,e.flags.crOnVariants]),$=(T,h)=>ma(T,h),O=(T,h)=>{try{const b=ha(h,1e3);return{patch:$(T,b)}}catch(b){return{patch:[],error:z(b)}}},B=T=>({feature:r,action:"patchVariant",payload:{variants:T}}),U=async(T,h)=>{if(T.crEnabled)await C(i,T.name,B(h)),S();else{const b=T.variants??[],{patch:E,error:V}=O(b,h);if(E.length===0)return;if(V){n({type:"error",title:V});return}await m(i,r,T.name,E)}u()},Y=async(T,h)=>{try{const b=h.filter(({crEnabled:q})=>q),E=h.filter(({crEnabled:q})=>!q);b.length&&await Promise.all(b.map(q=>C(i,q.name,B(T)))),E.length&&await g(i,r,T,E.map(({name:q})=>q)),S(),u();const V=E.length?`Variants pushed to ${E.length===1?E[0].name:`${E.length} environments`}`:"",L=b.length?`Variants push added to ${b.length===1?`${b[0].name} draft`:`${b.length} drafts`}`:"",_=`${V}${V&&L?". ":""}${L}`;n({title:_,type:"success"})}catch(b){a(z(b))}},K=T=>{w(T),P(!0)},Z=async T=>{if(v)try{await U(v,T),P(!1),n({title:v.crEnabled?"Variant changes added to draft":"Variants updated successfully",type:"success"})}catch(h){a(z(h))}},te=async(T,h)=>{try{const b=T.variants??[];await U(h,b),n({title:h.crEnabled?"Variants copy added to draft":"Variants copied successfully",type:"success"})}catch(b){a(z(b))}};return c(dt,{isLoading:p,header:t(ga,{title:"Variants",actions:t(I,{condition:!s,show:t(M,{children:t(ft,{initialValue:A,onChange:y})})}),children:t(I,{condition:s,show:t(ft,{initialValue:A,onChange:y})})}),children:[c(ni,{severity:"info",children:["Variants allows you to return a variant object if the feature toggle is considered enabled for the current request. When using variants you should use the ",t("code",{children:"getVariant()"})," method in the Client SDK."]}),D.map(T=>{var b;const h=D.filter(({name:E,variants:V})=>E!==T.name&&(V==null?void 0:V.length));return t(Yr,{environment:T,searchValue:A,children:c(ai,{children:[t(ti,{current:T.name,environments:D,permission:ce,projectId:i,onSubmit:E=>Y(T.variants??[],E)}),t(Jr,{environment:T,permission:ce,projectId:i,environmentId:T.name,onCopyVariantsFrom:te,otherEnvsWithVariants:h}),t(I,{condition:Boolean((b=T.variants)==null?void 0:b.length),show:t(Q,{"data-testid":"EDIT_VARIANTS_BUTTON",onClick:()=>K(T),permission:ce,projectId:i,environmentId:T.name,tooltipProps:{title:"Edit variants"},children:t(me,{})}),elseShow:t(ae,{"data-testid":"ADD_VARIANT_BUTTON",onClick:()=>K(T),variant:"outlined",permission:ce,projectId:i,environmentId:T.name,children:"Add variant"})})]})},T.name)}),t(jr,{environment:v,open:R,setOpen:P,getApiPayload:O,getCrPayload:B,onConfirm:Z})]})},si=be("api/admin/client-metrics/features"),un=(e,n)=>{const a=be(`api/admin/client-metrics/features/${e}/raw?hoursBack=${n}`),{data:o,error:s}=Qe(a,()=>ri(a)),i=f.useCallback(()=>{Ze(si).catch(console.warn)},[]);return{featureMetrics:o==null?void 0:o.data,loading:!s&&!o,refetchFeatureMetrics:i,error:s}},ri=e=>fetch(e).then(ke("Features")).then(n=>n.json()).then(),ii=d("h2")(({theme:e})=>({margin:0,marginBottom:e.spacing(1),fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.thin,color:e.palette.text.secondary})),Se=48,ci=({hoursBack:e,setHoursBack:n})=>{const a=o=>{n(li(o))};return c("div",{children:[t(ii,{children:"Period"}),t(fa,{name:"feature-metrics-period",id:"feature-metrics-period",options:di,value:String(e),onChange:a,fullWidth:!0})]})},li=e=>{switch(e){case"1":return 1;case"24":return 24;default:return Se}},di=[{key:"1",label:"Last hour"},{key:"24",label:"Last 24 hours"},{key:`${Se}`,label:`Last ${Se} hours`}],ui=({metrics:e,tableSectionId:n})=>{const a=De(ya.breakpoints.down("md")),o=f.useMemo(()=>({sortBy:[{id:"timestamp"}]}),[]),{getTableProps:s,getTableBodyProps:i,headerGroups:r,rows:l,prepareRow:u,setHiddenColumns:p}=Le.useTable({initialState:o,columns:Ot,data:e,autoResetHiddenColumns:!1,disableSortRemove:!0,defaultColumn:{Cell:Sa}},Le.useGlobalFilter,Le.useSortBy);return ba([{condition:a,columns:["appName","environment"]}],p,Ot),e.length===0?null:c(Ca,{...s(),rowHeight:"standard",id:n,children:[t(va,{headerGroups:r}),t(wa,{...i(),children:l.map(m=>(u(m),t(Ta,{hover:!0,...m.getRowProps(),children:m.cells.map(g=>t(xa,{...g.getCellProps(),children:g.render("Cell")}))})))})]})},Ot=[{id:"Icon",width:"1%",disableSortBy:!0,Cell:()=>t(Aa,{icon:t(ho,{color:"disabled"})})},{Header:"Time",accessor:"timestamp",Cell:e=>t(Ea,{value:e.row.original.timestamp})},{Header:"Application",accessor:"appName"},{Header:"Environment",accessor:"environment"},{id:"requested",Header:"Requested",accessor:e=>e.yes+e.no},{Header:"Exposed",accessor:"yes"}],pi=({metrics:e,...n})=>{const a=f.useMemo(()=>e.reduce((s,i)=>s+i.yes,0),[e]),o=f.useMemo(()=>e.reduce((s,i)=>s+i.no,0),[e]);return t(sn,{...n,totalYes:a,totalNo:o})},gi=({metrics:e,hoursBack:n})=>{const a=yt(),o=yt();return e.length===0?c(H,{mt:6,children:[t(N,{variant:"body1",paragraph:!0,children:"We have yet to receive any metrics for this feature toggle in the selected time period."}),t(N,{variant:"body1",paragraph:!0,children:"Please note that, since the SDKs send metrics on an interval, it might take some time before metrics appear."})]}):c(f.Suspense,{fallback:null,children:[t(H,{borderTop:1,pt:2,mt:3,borderColor:"divider",children:t(hi,{metrics:e,hoursBack:n,statsSectionId:a})}),t(H,{mt:4,children:t(pi,{metrics:e,hoursBack:n,statsSectionId:a,tableSectionId:o})}),t(H,{mt:4,children:t(ui,{metrics:e,tableSectionId:o})})]})},hi=Ia.lazy(()=>import("./FeatureMetricsChart-8054718f.js")),Xe=e=>{const{search:n}=window.location,a=ge(),o=f.useMemo(()=>new URLSearchParams(n),[n]),s=f.useCallback(i=>{const r=new URLSearchParams(n);r.set(e,i),a({search:r.toString()},{replace:!0})},[e,n,a]);return[o.get(e)||void 0,s]},mi=e=>{const[n,a]=Xe(e),o=f.useCallback(s=>a(String(s)),[a]);return[Number.isFinite(Number(n))?Number(n):void 0,o]},fi=d("h2")(({theme:e})=>({margin:0,marginBottom:e.spacing(1.5),fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.thin,color:e.palette.text.secondary})),yi=d("ul")(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing(1),listStyleType:"none",padding:0,minHeight:"100%"})),Si=d("li")(({theme:e})=>({"& > [aria-pressed=true]":{backgroundColor:e.palette.background.alternative,color:e.palette.primary.contrastText},"& > [aria-pressed=true]:hover":{backgroundColor:e.palette.primary.light}})),Vt=({title:e,values:n,value:a,setValue:o})=>{const s=r=>()=>{n.has(r)&&o(r)},i=f.useMemo(()=>Array.from(n).sort((r,l)=>r.localeCompare(l)),[n]);return c("div",{children:[t(fi,{children:e}),t(yi,{children:i.map(r=>t(Si,{children:t(Ht,{label:r,onClick:s(r),"aria-pressed":r===a,sx:Ra})},r))})]})},bi=()=>{const e=F("projectId"),n=F("featureId"),a=Ci(e,n),o=vi(n);Gt("Metrics");const[s=Se,i]=mi("hoursBack"),{featureMetrics:r}=un(n,s),[l,u]=f.useState(r);f.useEffect(()=>{r&&u(r)},[r]);const p=Array.from(a)[0],m=Array.from(o)[0],[g=p,S]=Xe("environment"),[C=m,x]=Xe("application"),A=f.useMemo(()=>l==null?void 0:l.filter(y=>y.environment===g).filter(y=>y.appName===C),[l,g,C]);return A?c(dt,{children:[c(ne,{container:!0,component:"header",spacing:2,children:[t(ne,{item:!0,xs:12,md:5,children:t(I,{condition:a.size>0,show:t(Vt,{title:"Environments",values:a,value:g,setValue:S})})}),t(ne,{item:!0,xs:12,md:5,children:t(I,{condition:o.size>0,show:t(Vt,{title:"Applications",values:o,value:C,setValue:x})})}),t(ne,{item:!0,xs:12,md:2,children:t(ci,{hoursBack:s,setHoursBack:i})})]}),t(gi,{metrics:A,hoursBack:s})]}):null},Ci=(e,n)=>{const{feature:a}=j(e,n),o=a.environments.map(s=>s.name);return new Set(o)},vi=e=>{const{featureMetrics:n=[]}=un(e,Se),a=n.map(o=>o.appName);return new Set(a)},wi=(e,n)=>{const a=new Set(e),o=new Set(n);return a.size!==o.size?!1:[...a].every(s=>o.has(s))},Mt=d("div")(({theme:e})=>({display:"grid",gap:e.spacing(2)})),Lt=d(he)(({theme:e})=>({marginBottom:e.spacing(1)})),Ti=d(rt)({padding:0}),xi=({projectId:e,open:n,onClose:a,onClick:o,feature:s,changeRequests:i})=>{const r=F("projectId"),{project:l}=Zt(e),{isChangeRequestConfiguredInAnyEnv:u}=oe(e),p=u(),m=f.useMemo(()=>wi(s.environments.map(S=>S.name),l.environments),[s,l]),g=i?i.length>0:!1;return t(I,{condition:m&&!g&&!p,show:t(de,{open:n,onClose:a,onClick:o,title:"Confirm change project",primaryButtonText:"Change project",secondaryButtonText:"Cancel",children:c(Mt,{children:[t(Lt,{severity:"success",children:"This feature toggle is compatible with the new project."}),t("p",{children:"Are you sure you want to change the project for this toggle?"})]})}),elseShow:t(de,{open:n,onClick:a,title:"Confirm change project",primaryButtonText:"Close",children:c(Mt,{children:[t(Lt,{severity:"warning",children:"Cannot proceed with the move"}),t(I,{condition:!m,show:t("p",{children:"In order to move a feature toggle between two projects, both projects must have the exact same environments enabled."})}),t(I,{condition:g,show:c(M,{children:[t("p",{children:"The feature toggle must not have any pending change requests. This feature toggle is currently referenced in the following change requests:"}),t(Ti,{children:i==null?void 0:i.map(S=>t(Re,{children:c(J,{to:`/projects/${r}/change-requests/${S.id}`,children:["View change request"," ",S.id]})},S.id))})]})}),t(I,{condition:p,show:c("p",{children:["You're not allowed to move the feature to project"," ",t(J,{to:`/projects/${e}/settings/change-requests`,children:e}),". This project has change requests enabled."]})})]})})})},Ai=e=>fetch(e).then(ke("ChangeRequest")).then(n=>n.json()),Ei=(e,n)=>{const{data:a,error:o,mutate:s}=Fa([],be(`api/admin/projects/${e}/change-requests/pending/${n}`),Ai);return{changeRequests:a,loading:!o&&!a,refetch:s,error:o}},Ii=()=>{const{hasAccess:e}=f.useContext(ot),n=F("projectId"),a=F("featureId"),{feature:o,refetchFeature:s}=j(n,a),[i,r]=f.useState(!1),{changeFeatureProject:l}=Te(),{setToastData:u,setToastApiError:p}=G(),[m,g]=f.useState(n),{projects:S}=ka(),C=ge(),{changeRequests:x}=Ei(n,a),A=async()=>{try{m&&(await l(n,a,m),s(),u({title:"Project changed",type:"success"}),r(!1),C(`/projects/${m}/features/${a}/settings`,{replace:!0}))}catch(v){p(z(v))}},y=f.useMemo(()=>S.map(v=>v.id).filter(v=>e(St,v)),[S,e]);return y.length===0?null:c(M,{children:[t($a,{value:m,onChange:g,label:"Project",filter:v=>y.includes(v),enabled:!0}),t(ae,{permission:St,onClick:()=>r(!0),disabled:m===n,projectId:n,children:"Save"}),t(xi,{changeRequests:x,projectId:m,open:i,feature:o,onClose:()=>r(!1),onClick:A})]})},Ri=d("div")({display:"flex",alignItems:"center"}),Fi=d(N)(({theme:e})=>({fontSize:e.fontSizes.mainHeader})),ki=({projectId:e,featureId:n})=>{var i;const{feature:a}=j(e,n),o=ge();return c(M,{children:[c(Ri,{children:[t(Fi,{children:"Feature information"}),t(Q,{permission:le,projectId:e,"data-loading":!0,onClick:()=>{o(`/projects/${e}/features/${n}/edit`)},tooltipProps:{title:"Edit"},children:t(me,{})})]}),c(N,{children:["Name: ",t("strong",{children:a.name})]}),c(N,{children:["Description:"," ",t("strong",{children:(i=a.description)!=null&&i.length?a.description:"no description"})]}),c(N,{children:["Type: ",t("strong",{children:a.type})]}),c(N,{children:["Impression Data:"," ",t("strong",{children:a.impressionData?"enabled":"disabled"})]})]})},Ee="metadata",Ge="project",$i=d("div")(({theme:e})=>({width:"20%",borderRight:`1px solid ${e.palette.divider}`,padding:e.spacing(2,0),[e.breakpoints.down("md")]:{width:"35%"}})),Pi=d("div")(({theme:e})=>({padding:e.spacing(4),display:"flex",flexDirection:"column",width:400,["& > *"]:{margin:e.spacing(1,0)}})),Bi=()=>{const e=F("projectId"),n=F("featureId"),[a,o]=f.useState(Ee),{uiConfig:s}=lt();return t(dt,{header:"Settings",sx:{padding:0},children:c(H,{sx:{display:"flex"},children:[t($i,{children:c(rt,{children:[t(Re,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>o(Ee),selected:a===Ee,children:"Metadata"},0),t(Re,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>o(Ge),selected:a===Ge,hidden:!s.flags.P,children:"Project"},1)]})}),c(Pi,{children:[t(I,{condition:a===Ee,show:t(ki,{projectId:e,featureId:n})}),t(I,{condition:a===Ge&&s.flags.P,show:t(Ii,{})})]})]})})},Di=({stale:e,showActive:n=!0})=>!e&&!n?null:t("div",{"data-loading":!0,style:{marginLeft:"8px"},children:t(fe,{color:e?"error":"success",title:e?"Feature toggle is deprecated.":"Feature toggle is active.",children:e?"Stale":"Active"})}),_t=d("strong")({wordBreak:"break-all"}),Oi=()=>{const e=F("projectId"),n=F("featureId"),{archivedFeatures:a}=Pa(),o=Ba(e,{name:n});return a?a.some(i=>i.name===n)?c("p",{children:["The feature ",t(_t,{children:n})," has been archived. You can find it on the"," ",t(J,{to:`/projects/${e}/archive`,children:"project archive page"}),"."]}):c("p",{children:["The feature ",t(_t,{children:n})," does not exist. Would you like to"," ",t(J,{to:o,children:"create it"}),"?"]}):null},Vi=d("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),Mi=d("div")(({theme:e})=>({padding:e.spacing(2,4,2,2),display:"flex",justifyContent:"space-between",alignItems:"center",[e.breakpoints.down(500)]:{flexDirection:"column"}})),Li=d("div")({display:"flex",alignItems:"center"}),_i=d("h1")(({theme:e})=>({fontSize:e.fontSizes.mainHeader,fontWeight:"normal",display:"flex",alignItems:"center",wordBreak:"break-all"})),ji=d("div")({flexShrink:0,display:"flex"}),Ni=d("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.divider,height:"1px"})),zi=d("div")(({theme:e})=>({padding:e.spacing(0,4)})),Wi=d(Da)(({theme:e})=>({textTransform:"none",width:"auto",fontSize:e.fontSizes.bodySize,padding:"0 !important",[e.breakpoints.up("md")]:{minWidth:160}})),Ki=()=>{const e=F("projectId"),n=F("featureId"),{refetch:a}=Zt(e),{favorite:o,unfavorite:s}=Oa(),{refetchFeature:i}=j(e,n),[r,l]=f.useState(!1),[u,p]=f.useState(!1),[m,g]=f.useState(!1),S=De(`(max-width:${500}px)`),{feature:C,loading:x,error:A,status:y}=j(e,n),v=ge(),{pathname:w}=Va(),R=Ma(x),P=`/projects/${e}/features/${n}`,D=[{title:"Overview",path:`${P}`,name:"overview"},{title:"Metrics",path:`${P}/metrics`,name:"Metrics"},{title:"Variants",path:`${P}/variants`,name:"Variants"},{title:"Settings",path:`${P}/settings`,name:"Settings"},{title:"Event log",path:`${P}/logs`,name:"Event log"}],$=D.find(B=>B.path===w)??D[0],O=async()=>{C!=null&&C.favorite?await s(e,C.name):await o(e,C.name),i()};return y===404?t(Oi,{}):A!==void 0?t("div",{ref:R}):c("div",{ref:R,children:[c(Vi,{children:[c(Mi,{children:[c(Li,{children:[t(La,{onClick:O,isFavorite:C==null?void 0:C.favorite}),c(_i,{"data-loading":!0,children:[C.name," "]}),t(I,{condition:!S,show:t(Di,{stale:C==null?void 0:C.stale})})]}),c(ji,{children:[t(Q,{permission:_a,projectId:e,"data-loading":!0,component:J,to:`/projects/${e}/features/${n}/strategies/copy`,tooltipProps:{title:"Copy feature toggle"},children:t(ja,{})}),t(Q,{permission:Na,projectId:e,tooltipProps:{title:"Archive feature toggle"},"data-loading":!0,onClick:()=>p(!0),children:t(to,{})}),t(Q,{onClick:()=>g(!0),permission:le,projectId:e,tooltipProps:{title:"Toggle stale state"},"data-loading":!0,children:t(no,{})}),t(Q,{onClick:()=>l(!0),permission:le,projectId:e,tooltipProps:{title:"Add tag"},"data-loading":!0,children:t(za,{})})]})]}),t(Ni,{}),t(zi,{children:t(Wa,{value:$.path,indicatorColor:"primary",textColor:"primary",children:D.map(B=>t(Wi,{label:B.title,value:B.path,onClick:()=>v(B.path)},B.title))})})]}),c(Yt,{children:[t(se,{path:"metrics",element:t(bi,{})}),t(se,{path:"logs",element:t(yo,{})}),t(se,{path:"variants",element:t(oi,{})}),t(se,{path:"settings",element:t(Bi,{})}),t(se,{path:"*",element:t(or,{})})]}),t(ao,{isOpen:u,onConfirm:()=>{a(),v(`/projects/${e}`)},onClose:()=>p(!1),projectId:e,featureIds:[n]}),t(oo,{isStale:C.stale,isOpen:m,onClose:()=>{g(!1),i()},featureId:n,projectId:e}),t(cn,{open:r,setOpen:l})]})};export{Ki as default};