unleash-server 4.22.0-beta.63 → 4.22.0-beta.64
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.
- package/dist/lib/db/segment-store.js +1 -1
- package/dist/lib/db/segment-store.js.map +1 -1
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/{CreateProject-42e43ddc.js → CreateProject-4fd51b56.js} +1 -1
- package/frontend/build/static/{Error-87dc92a7.js → Error-2285a578.js} +1 -1
- package/frontend/build/static/{ExpandMore-c58be316.js → ExpandMore-6061c1d6.js} +1 -1
- package/frontend/build/static/{FeatureArchiveDialog-46cb7edd.js → FeatureArchiveDialog-70fce2b5.js} +1 -1
- package/frontend/build/static/{FeatureMetricsChart-06211c4e.js → FeatureMetricsChart-e14f79ef.js} +1 -1
- package/frontend/build/static/{FeatureViewLazyExport-6963c587.js → FeatureViewLazyExport-9e6ca388.js} +2 -2
- package/frontend/build/static/{LazyAdminExport-d0c79ee4.js → LazyAdminExport-8803079c.js} +2 -2
- package/frontend/build/static/{LazyProjectExport-7e597a7b.js → LazyProjectExport-eb91ebfd.js} +1 -1
- package/frontend/build/static/{NetworkOverview-3508ad26.js → NetworkOverview-48647516.js} +1 -1
- package/frontend/build/static/{NetworkTraffic-22ad00ab.js → NetworkTraffic-95815500.js} +1 -1
- package/frontend/build/static/{Playground-555fbd57.js → Playground-f9384a22.js} +1 -1
- package/frontend/build/static/{StrategyItemContainer-f58e6b57.js → StrategyItemContainer-4528608d.js} +1 -1
- package/frontend/build/static/{chartjs-adapter-date-fns.esm-ded0172d.js → chartjs-adapter-date-fns.esm-2bf68fdb.js} +1 -1
- package/frontend/build/static/{index-79b43ef1.js → index-7786a63b.js} +3 -3
- package/frontend/build/static/{index-989b5768.js → index-ad1d0a26.js} +1 -1
- package/frontend/build/static/{index-66f5d618.js → index-c36b9313.js} +1 -1
- package/frontend/build/static/{unknownify-70187dd8.js → unknownify-da135fce.js} +1 -1
- package/frontend/build/static/{useProjectRole-f56eaba9.js → useProjectRole-3302435e.js} +1 -1
- package/package.json +1 -1
|
@@ -133,7 +133,7 @@ class SegmentStore {
|
|
|
133
133
|
id: row.id,
|
|
134
134
|
name: row.name,
|
|
135
135
|
description: row.description,
|
|
136
|
-
project: row.segment_project_id,
|
|
136
|
+
project: row.segment_project_id || undefined,
|
|
137
137
|
constraints: row.constraints,
|
|
138
138
|
createdBy: row.created_by,
|
|
139
139
|
createdAt: row.created_at,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segment-store.js","sourceRoot":"","sources":["../../../src/lib/db/segment-store.ts"],"names":[],"mappings":"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
|
|
1
|
+
{"version":3,"file":"segment-store.js","sourceRoot":"","sources":["../../../src/lib/db/segment-store.ts"],"names":[],"mappings":"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"}
|
|
@@ -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-
|
|
19
|
+
<script type="module" crossorigin src="/static/index-7786a63b.js"></script>
|
|
20
20
|
<link rel="stylesheet" href="/static/index-1fa04e71.css">
|
|
21
21
|
</head>
|
|
22
22
|
<body>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a2 as N,aq as w,H as I,ar as D,as as U,at as x,au as O,j as t,av as _,aw as b,ax as F,ay as L,a4 as R,az as $}from"./index-
|
|
1
|
+
import{a2 as N,aq as w,H as I,ar as D,as as U,at as x,au as O,j as t,av as _,aw as b,ax as F,ay as L,a4 as R,az as $}from"./index-7786a63b.js";const K=()=>{const{setToastData:n,setToastApiError:i}=N(),{refetchUser:d}=w(),{uiConfig:l}=I(),a=D(),{projectId:e,projectName:u,projectDesc:j,setProjectId:p,setProjectName:m,setProjectDesc:P,getProjectPayload:o,clearErrors:s,validateProjectId:r,validateName:h,setProjectStickiness:f,projectStickiness:g,errors:C}=U(),{createProject:y,loading:S}=x(),{setDefaultProjectStickiness:v}=O(e);return t(_,{loading:S,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:t(b,{errors:C,handleSubmit:async A=>{A.preventDefault(),s();const T=h(),k=await r();if(T&&k){const c=o();try{await y(c),v(c.projectStickiness),d(),a(`/projects/${e}`),n({title:"Project created",text:"Now you can add toggles to this project",confetti:!0,type:"success"})}catch(E){i(R(E))}}},handleCancel:()=>{a($)},projectId:e,setProjectId:p,projectName:u,projectStickiness:g,setProjectStickiness:f,setProjectName:m,projectDesc:j,setProjectDesc:P,mode:"Create",clearErrors:s,validateProjectId:r,children:t(F,{name:"project",permission:L})})})};export{K as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as r,j as o}from"./index-
|
|
1
|
+
import{c as r,j as o}from"./index-7786a63b.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-
|
|
1
|
+
import{c as a,j as o}from"./index-7786a63b.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};
|
package/frontend/build/static/{FeatureArchiveDialog-46cb7edd.js → FeatureArchiveDialog-70fce2b5.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aH as R,b0 as w,f as p,aZ as C,j as o,C as E,A as M,T as b,c1 as J,ct as x,r as d,cu as Q,cv as Z,a_ as X,a$ as B,a2 as v,H as ee,ar as P,aI as D,aU as te,cw as ae,av as ne,ap as se,cx as re,cy as oe,cz as ie,cA as ce,b7 as $,cB as ue,b1 as le,a4 as S,cC as ge,s as j,aY as de,cD as he,cE as ye,F as fe,bA as N}from"./index-
|
|
1
|
+
import{aH as R,b0 as w,f as p,aZ as C,j as o,C as E,A as M,T as b,c1 as J,ct as x,r as d,cu as Q,cv as Z,a_ as X,a$ as B,a2 as v,H as ee,ar as P,aI as D,aU as te,cw as ae,av as ne,ap as se,cx as re,cy as oe,cz as ie,cA as ce,b7 as $,cB as ue,b1 as le,a4 as S,cC as ge,s as j,aY as de,cD as he,cE as ye,F as fe,bA as N}from"./index-7786a63b.js";const Ae=({isOpen:e,onConfirm:t,onClose:a,showBanner:n,environment:s,messageComponent:r})=>{const i=R("projectId"),{data:l}=w(i),{changeRequestInReviewOrApproved:u,alert:g}=J(l),c=u(s||"");return p(C,{open:e,primaryButtonText:c?"Add to existing change request":"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:t,onClose:a,title:"Request changes",fullWidth:!0,children:[o(E,{condition:c,show:g}),o(E,{condition:Boolean(n),show:p(M,{severity:"info",sx:{mb:2},children:["Change requests feature is enabled for ",s,". 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."]})}),o(b,{variant:"body2",color:"text.secondary",children:"Your suggestion:"}),r]})},pe=(e,t)=>{const a={};return t.parameters.forEach(n=>{a[n.name]=me(e,n)}),{name:t.name,constraints:[],parameters:a}},me=(e,t)=>t.name==="rollout"||t.name==="percentage"||t.type==="percentage"?"50":t.name==="stickiness"?"":t.name==="groupId"?e:t.type==="boolean"?"false":"",Re=()=>{const e=R("projectId"),t=R("featureId"),a=x("environmentId"),n=x("strategyName"),[s,r]=d.useState({}),[i,l]=d.useState([]),{strategyDefinition:u}=Q(n),g=Z(),{addStrategyToFeature:c,loading:h}=X(),{addChange:m}=B(),{setToastData:T,setToastApiError:O}=v(),{uiConfig:Y}=ee(),{unleashUrl:z}=Y,_=P(),{feature:y,refetchFeature:F}=D(e,t),q=d.useRef(y),{isChangeRequestConfigured:k}=te(e),{refetch:L}=w(e),{data:A,staleDataNotification:U,forceRefreshCache:W}=ae({unleashGetter:D,params:[e,t],dataKey:"feature",refetchFunctionKey:"refetchFeature",options:{}},y,{afterSubmitAction:F},ge);d.useEffect(()=>{q.current.name===""&&y.name&&(W(y),q.current=y)},[y]),d.useEffect(()=>{u&&r(pe(t,u))},[t,u]);const H=async f=>{await c(e,t,a,f),T({title:"Strategy created",type:"success",confetti:!0})},V=async f=>{await m(e,a,{action:"addStrategy",feature:t,payload:f}),T({title:"Strategy added to draft",type:"success",confetti:!0}),L()},G=async()=>{const f=ue(s,i);try{k(a)?await V(f):await H(f),F(),_(le(e,t))}catch(K){O(S(K))}};return!A||!A.project?null:p(ne,{modal:!0,title:se(n),description:re,documentationLink:oe,documentationLinkLabel:ie,formatApiCode:()=>be(e,t,a,s,z),children:[o(ce,{projectId:e,feature:A,strategy:s,setStrategy:r,segments:i,setSegments:l,environmentId:a,onSubmit:G,loading:h,permission:$,errors:g,isChangeRequest:k(a)}),U]})},Te=(e,t,a,n)=>{const s=new URLSearchParams({environmentId:a,strategyName:n});return`/projects/${e}/features/${t}/strategies/create?${s}`},be=(e,t,a,n,s)=>{if(!s)return"";const r=`${s}/api/admin/projects/${e}/features/${t}/environments/${a}/strategies`,i=JSON.stringify(n,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}'`},I=j("p")(({theme:e})=>({marginBottom:e.spacing(.5),fontSize:e.fontSizes.bodySize})),Ee=({open:e,environmentName:t,featureId:a,projectId:n,onClose:s})=>{const r=P(),i=Te(n,a,t,"default");return p(C,{open:e,maxWidth:"sm",onClose:()=>s(),title:"You need to add a strategy to your toggle",primaryButtonText:"Take me directly to add strategy",permissionButton:o(de,{type:"button",permission:$,projectId:n,environmentId:t,onClick:()=>{s(),r(i)},children:"Take me directly to add strategy"}),secondaryButtonText:"Cancel",children:[o(I,{children:"Before you can enable the toggle in the environment, you need to add an activation strategy."}),o(I,{children:"You can add the activation strategy by selecting the toggle, open the environment accordion and add the activation strategy."})]})},we="You can not enable the environment before it has strategies",Fe=e=>{const{setToastData:t,setToastApiError:a}=v(),{addChange:n}=B(),{refetch:s}=w(e),[r,i]=d.useState({isOpen:!1}),l=d.useCallback((c,h,m)=>{i({featureName:c,environment:h,enabled:m,isOpen:!0})},[]),u=d.useCallback(()=>{i(c=>({...c,isOpen:!1}))},[]),g=d.useCallback(async()=>{try{await n(e,r.environment,{feature:r.featureName,action:"updateEnabled",payload:{enabled:Boolean(r.enabled)}}),s(),i(c=>({...c,isOpen:!1})),t({type:"success",title:"Changes added to the draft!"})}catch(c){a(S(c)),i(h=>({...h,isOpen:!1}))}},[n]);return{onChangeRequestToggle:l,onChangeRequestToggleClose:u,onChangeRequestToggleConfirm:g,changeRequestDialogDetails:r}},qe=({enabled:e,featureName:t,environment:a})=>p(b,{"data-testid":"update-enabled-message",children:[o("strong",{children:e?"Enable":"Disable"})," feature toggle"," ",o("strong",{children:t})," in ",o("strong",{children:a})]}),Ce=j(he)(({theme:e})=>({color:e.palette.warning.main,fontSize:e.fontSizes.bodySize})),ke=()=>o(ye,{arrow:!0,title:p(fe,{children:["This environment has no variants enabled. If you check this feature's variants in this environment, you will get the"," ",o("a",{href:"https://docs.getunleash.io/reference/feature-toggle-variants#the-disabled-variant",target:"_blank",rel:"noreferrer",children:"disabled variant"}),"."]}),children:o(Ce,{})}),xe=({isStale:e,isOpen:t,projectId:a,featureId:n,onClose:s})=>{const{setToastData:r,setToastApiError:i}=v(),{patchFeatureToggle:l}=N(),u=o(b,{children:"Setting a toggle to stale marks it for cleanup"}),g=o(b,{children:"Setting a toggle to active marks it as in active use"}),c=e?"active":"stale",h=async m=>{m.stopPropagation();try{await l(a,n,[{op:"replace",path:"/stale",value:!e}]),s()}catch(T){i(S(T))}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 o(C,{open:t,secondaryButtonText:"Cancel",primaryButtonText:`Flip to ${c}`,title:`Set feature state to ${c}`,onClick:h,onClose:s,children:o(E,{condition:e,show:g,elseShow:u})})},De=({isOpen:e,onClose:t,onConfirm:a,projectId:n,featureId:s})=>{const{archiveFeatureToggle:r}=N(),{setToastData:i,setToastApiError:l}=v(),u=async()=>{try{await r(n,s),i({text:"Your feature toggle has been archived",type:"success",title:"Feature archived"}),a(),t()}catch(g){l(S(g)),t()}};return o(C,{onClick:()=>u(),open:e,onClose:t,primaryButtonText:"Archive toggle",secondaryButtonText:"Cancel",title:"Archive feature toggle",children:"Are you sure you want to archive this feature toggle?"})};export{Ae as C,we as E,Re as F,qe as U,ke as V,Ee as a,De as b,xe as c,Te as f,Fe as u};
|
package/frontend/build/static/{FeatureMetricsChart-06211c4e.js → FeatureMetricsChart-e14f79ef.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c9 as i,f3 as p,bv as y,r as l,j as u}from"./index-
|
|
1
|
+
import{c9 as i,f3 as p,bv as y,r as l,j as u}from"./index-7786a63b.js";import{d as c,L as g,C as h,a as C,b as f,P as x,c as S,T as q,p as v,e as M,f as k}from"./chartjs-adapter-date-fns.esm-2bf68fdb.js";import"./index-ad1d0a26.js";import"./index-c36b9313.js";const L=(t,s)=>{const o={label:"total requests",borderColor:i.palette.primary.main,backgroundColor:i.palette.primary.main,data:n(t,s,r=>r.yes+r.no),elements:{point:{radius:6,pointStyle:"circle"},line:{borderDash:[8,4]}}},e={label:"exposed",borderColor:i.palette.success.main,backgroundColor:i.palette.success.main,data:n(t,s,r=>r.yes),elements:{point:{radius:6,pointStyle:"triangle"}}},a={label:"not exposed",borderColor:i.palette.error.main,backgroundColor:i.palette.error.main,data:n(t,s,r=>r.no),elements:{point:{radius:6,pointStyle:"triangle",pointRotation:180}}};return{datasets:[e,a,o]}},n=(t,s,o)=>t.map(e=>({x:e.timestamp,y:o(e)})),P=(t,s,o)=>({locale:o.locale,responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},plugins:{tooltip:{backgroundColor:"white",bodyColor:i.palette.text.primary,titleColor:i.palette.action.active,borderColor:i.palette.primary.main,borderWidth:1,padding:10,boxPadding:5,usePointStyle:!0,callbacks:{title:e=>p(e[0].parsed.x,o.locale)},itemSort:(e,a)=>a.parsed.y-e.parsed.y},legend:{position:"top",align:"end",labels:{boxWidth:10,boxHeight:10,usePointStyle:!0}},title:{text:w(s),position:"top",align:"start",display:!0,font:{size:16,weight:"400"}}},scales:{y:{type:"linear",title:{display:!0,text:"Number of requests"},suggestedMin:0,ticks:{precision:0}},x:{type:"time",time:{unit:"hour"},grid:{display:!1},ticks:{callback:(e,a,r)=>p(r[a].value,o.locale)}}}}),w=t=>t===1?"Requests in the last hour":`Requests in the last ${t} hours`;c.font={...c.font,family:"Sen",size:13,weight:"400"};const j=({metrics:t,hoursBack:s,statsSectionId:o})=>{const{locationSettings:e}=y(),a=l.useMemo(()=>[...t].sort((m,b)=>m.timestamp.localeCompare(b.timestamp)),[t]),r=l.useMemo(()=>P(a,s,e),[a,s,e]),d=l.useMemo(()=>L(a,e),[a,e]);return u("div",{style:{height:400},children:u(g,{options:r,data:d,"aria-label":"A feature metrics line chart, with three lines: all requests, positive requests, and negative requests.","aria-describedby":o})})};h.register(C,f,x,S,q,v,M,k);export{j as FeatureMetricsChart,j as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aA as vn,aB as wn,s as d,r as m,aC as Tn,aD as xn,aE as pt,j as t,aF as An,aG as En,c as $e,aH as F,aI as j,aJ as In,f as l,aK as Rn,C as A,aL as K,aM as ie,aN as X,aO as ye,aP as Fn,aQ as et,aR as pe,aS as Ce,aT as Be,u as ve,aU as ae,F as O,aV as gt,aW as ht,aX as tt,aY as oe,aZ as le,T as M,a_ as we,a2 as U,ar as ge,a$ as nt,b0 as Te,A as he,b1 as _t,a4 as N,b2 as kn,b3 as Pn,b4 as $n,b5 as Bn,ap as xe,b6 as On,b7 as ce,b8 as Z,m as Oe,b9 as Dn,ba as Vn,bb as De,a8 as Ve,bc as jt,bd as Nt,be as at,bf as Ln,bg as Mn,bh as _n,a as q,p as jn,N as de,B as Se,bi as ot,a9 as re,bj as Nn,x as rt,an as Re,E as zn,bk as st,bl as Fe,P as Wn,bm as Hn,bn as ee,bo as qn,bp as Un,D as Gn,bq as Yn,br as Kn,bs as Xn,bt as zt,bu as Jn,bv as Qn,bw as Zn,bx as ea,by as ta,bz as na,bA as Ae,bB as aa,bC as oa,bD as ra,bE as Wt,ad as it,ac as Le,bF as Ht,bG as qt,bH as sa,bI as ia,bJ as la,bK as ca,Z as da,bL as Ut,bM as ua,w as Gt,af as ke,bN as pa,bO as Ke,bP as Yt,bQ as Kt,bR as ne,bS as Xe,bT as ga,bU as Xt,a3 as lt,bV as ha,bW as Jt,bX as ma,bY as fa,bZ as Qt,b_ as ya,H as ct,au as Sa,av as ba,b$ as me,c0 as mt,c1 as Ca,c2 as Zt,l as te,c3 as Je,c4 as en,R as va,b as wa,Q as Ta,d as fe,e as xa,U as tn,X as Aa,g as nn,S as an,h as on,i as rn,k as sn,W as Ea,c5 as Ia,ak as dt,al as Ra,V as ft,c6 as Fa,c7 as ka,c8 as Pa,c9 as ln,I as $a,ca as Ba,cb as Oa,cc as yt,cd as Da,ce as cn,cf as Va,ae as La,cg as St,ch as Ma,ci as _a,cj as ja,ck as Na,cl as za,cm as Wa,M as Ha,cn as qa,co as Ua,cp as Ga,cq as Ya,cr as Ka,cs as Xa}from"./index-79b43ef1.js";import{C as Me,f as Ja,u as Qa,U as Za,E as eo,V as to,a as no,F as ao,b as oo,c as ro}from"./FeatureArchiveDialog-46cb7edd.js";import{S as so}from"./StrategyItemContainer-f58e6b57.js";import{E as io}from"./ExpandMore-c58be316.js";import{v as Ne}from"./v4-a960c1f4.js";function lo(e){return vn("MuiCardContent",e)}wn("MuiCardContent",["root"]);const co=["className","component"],uo=e=>{const{classes:n}=e;return En({root:["root"]},lo,n)},po=d("div",{name:"MuiCardContent",slot:"Root",overridesResolver:(e,n)=>n.root})(()=>({padding:16,"&:last-child":{paddingBottom:24}})),go=m.forwardRef(function(n,a){const r=Tn({props:n,name:"MuiCardContent"}),{className:o,component:s="div"}=r,i=xn(r,co),c=pt({},r,{component:s}),u=uo(c);return t(po,pt({as:s,className:An(u.root,o),ownerState:c,ref:a},i))}),ho=go,mo=$e(t("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"),fo=$e(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"),yo=$e(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"),So=$e(t("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"),bo=d("div")(({theme:e})=>({borderRadius:e.spacing(1.5),backgroundColor:e.palette.background.paper,padding:e.spacing(4)})),Co=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n);return a.name?t(bo,{children:t(In,{title:"Event log",feature:n,displayInline:!0})}):null},vo=d("div")(({theme:e})=>({borderRadius:e.shape.borderRadiusLarge,color:e.palette.primary.contrastText,backgroundColor:e.palette.background.sidebar,display:"flex",flexDirection:"column",maxWidth:"350px",minWidth:"350px",marginRight:e.spacing(2),[e.breakpoints.down(1e3)]:{width:"100%",maxWidth:"none",minWidth:"auto"}})),wo=d("div")({padding:"1.5rem 1.5rem 0 1.5rem"}),To=d("div")({display:"flex",alignItems:"center"}),xo=d("h2")(({theme:e})=>({fontSize:e.fontSizes.bodySize,fontWeight:"normal",margin:0})),Ao=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})),Eo=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n),{project:r,description:o,type:s}=a,i=Fn(s);return t(vo,{children:l(wo,{children:[l(To,{"data-loading":!0,children:[t(i,{sx:c=>({marginRight:c.spacing(2),height:"40px",width:"40px",fill:c.palette.primary.contrastText})})," ",l(xo,{children:[Rn(s||"")," toggle"]})]}),l(Ao,{children:[l(bt,{"data-loading":!0,children:["Project: ",r]}),t(A,{condition:Boolean(o),show:l(bt,{"data-loading":!0,children:[t("div",{children:"Description:"}),l(Ct,{children:[t("p",{children:o}),t(K,{projectId:e,permission:ie,component:X,to:`/projects/${e}/features/${n}/settings`,tooltipProps:{title:"Edit description"},children:t(ye,{sx:c=>({color:c.palette.primary.contrastText})})})]})]}),elseShow:t("span",{"data-loading":!0,children:l(Ct,{children:["No description."," ",t(K,{projectId:e,permission:ie,component:X,to:`/projects/${e}/features/${n}/settings`,tooltipProps:{title:"Edit description"},children:t(ye,{sx:c=>({color:c.palette.primary.contrastText})})})]})})})]})]})})},vt={lastHourUsage:[],seenApplications:[]},Io=(e,n,a={})=>{const r=async()=>{const g=pe(`api/admin/client-metrics/features/${n}`),h=await fetch(g,{method:"GET"}).then(Ce("feature metrics"));return h.ok?h.json():vt},o=`${e}_${n}_metrics`,{data:s,error:i}=et(o,r,{...a}),[c,u]=m.useState(!i&&!s),p=()=>{Be(o)};return m.useEffect(()=>{u(!i&&!s)},[s,i]),{metrics:s||vt,error:i,loading:c,refetch:p,FEATURE_METRICS_CACHE_KEY:o}},Ro=e=>({yes:0,no:0,environment:e,timestamp:""}),Fo=(e,n)=>e.map(a=>n.lastHourUsage.find(o=>o.environment===a.name)||Ro(a.name)),ko=({enabled:e,className:n})=>{const a=ve(),r=e?"Environment enabled":"Environment disabled",o={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)};return t("div",{style:o,className:n,children:t(yo,{style:{fill:"#fff",width:"16px",height:"16px"},titleAccess:r})})},dn=()=>t(he,{severity:"error",children:"Removing the strategy will change which users receive access to the feature."}),Po=({onRemove:e,onClose:n,isOpen:a})=>t(le,{title:"Are you sure you want to delete this strategy?",open:a,primaryButtonText:"Remove strategy",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:t(dn,{})}),$o=d("div")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1)})),Bo=({onRemove:e,onClose:n,isOpen:a})=>l(le,{title:"Suggest changes",open:a,primaryButtonText:"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:[t(dn,{}),t($o,{children:t(M,{variant:"body2",color:"text.secondary",children:"Your suggestion:"})}),t(M,{fontWeight:"bold",children:"Remove strategy"})]}),Oo=({projectId:e,featureId:n,environmentId:a,strategyId:r})=>{const{deleteStrategyFromFeature:o}=we(),{setToastData:s,setToastApiError:i}=U(),c=ge(),{refetchFeature:u}=j(e,n);return async g=>{try{g.preventDefault(),await o(e,n,a,r),s({title:"Strategy deleted",type:"success"}),u(),c(_t(e,n))}catch(h){i(N(h))}}},Do=({projectId:e,featureId:n,environmentId:a,strategyId:r})=>{const{addChange:o}=nt(),{refetch:s}=Te(e),{setToastData:i,setToastApiError:c}=U();return async p=>{try{p.preventDefault(),await o(e,a,{action:"deleteStrategy",feature:n,payload:{id:r}}),i({title:"Changes added to the draft!",type:"success"}),await s()}catch(g){c(N(g))}}},Vo=({projectId:e,featureId:n,environmentId:a,strategyId:r,disabled:o,icon:s})=>{const[i,c]=m.useState(!1),{isChangeRequestConfigured:u}=ae(e),p=Oo({featureId:n,projectId:e,strategyId:r,environmentId:a}),g=Do({featureId:n,projectId:e,strategyId:r,environmentId:a});return l(O,{children:[t(A,{condition:Boolean(s),show:t(K,{onClick:()=>c(!0),projectId:e,environmentId:a,disabled:o,permission:gt,"data-testid":ht,tooltipProps:{title:"Remove strategy"},type:"button",children:t(tt,{})}),elseShow:t(oe,{onClick:()=>c(!0),projectId:e,environmentId:a,disabled:o,permission:gt,"data-testid":ht,color:"secondary",variant:"text",type:"button",children:"Remove strategy"})}),t(A,{condition:u(a),show:t(Bo,{isOpen:i,onClose:()=>c(!1),onRemove:async h=>{await g(h),c(!1)}}),elseShow:t(Po,{isOpen:i,onClose:()=>c(!1),onRemove:p})})]})},Lo=e=>(n,a,r)=>(r.revalidateOnFocus=!1,r.revalidateIfStale=!1,r.revalidateOnReconnect=!1,e(n,a,r));var Mo=kn(et,Lo);const un=(e,n)=>{const{refetchFeature:a}=j(e,n),r=Pn(e,n),{data:o,error:s,mutate:i}=Mo(["useFeatureImmutable",r],()=>$n(r)),c=m.useCallback(async()=>{await i(),await a()},[i,a]);return{feature:(o==null?void 0:o.body)||Bn,refetchFeature:c,loading:!s&&!o,status:o==null?void 0:o.status,error:s}},ut=(e,n,a)=>{const{setToastData:r,setToastApiError:o}=U(),{addChange:s}=nt(),{refetch:i}=Te(e),[c,u]=m.useState({isOpen:!1}),p=m.useCallback((v,T,f)=>{u({featureName:n,environment:v,fromEnvironment:f,strategy:T,isOpen:!0})},[]),g=m.useCallback((v,T,f)=>{u({featureName:n,environment:v,fromEnvironment:f,strategies:T,isOpen:!0})},[]),h=m.useCallback(()=>{u({isOpen:!1})},[]),b=m.useCallback(async()=>{try{await s(e,c.environment,{feature:c.featureName,action:a,payload:c.strategy}),i(),u({isOpen:!1}),r({type:"success",title:"Changes added to the draft!"})}catch(v){o(N(v)),u({isOpen:!1})}},[s]),S=m.useCallback(async()=>{try{await Promise.all(c.strategies.map(v=>s(e,c.environment,{feature:c.featureName,action:a,payload:v}))),i(),u({isOpen:!1}),r({type:"success",title:"Changes added to the draft!"})}catch(v){o(N(v)),u({isOpen:!1})}},[s]);return{onChangeRequestAddStrategy:p,onChangeRequestAddStrategies:g,onChangeRequestAddStrategyClose:h,onChangeRequestAddStrategyConfirm:b,onChangeRequestAddStrategiesConfirm:S,changeRequestDialogDetails:c}},_o=({payload:e,fromEnvironment:n,environment:a})=>l(M,{children:[l("strong",{children:["Copy ",xe((e==null?void 0:e.name)||"")," strategy"," "]})," ","from ",n," to ",a]}),jo=({environmentId:e,environments:n,strategy:a})=>{const r=F("projectId"),o=F("featureId"),[s,i]=m.useState(null),c=Boolean(s),{addStrategyToFeature:u}=we(),{setToastData:p,setToastApiError:g}=U(),{refetchFeature:h}=j(r,o),{refetchFeature:b}=un(r,o),S=()=>{i(null)},v=On(r),{isChangeRequestConfigured:T}=ae(r),{changeRequestDialogDetails:f,onChangeRequestAddStrategyClose:y,onChangeRequestAddStrategy:w,onChangeRequestAddStrategyConfirm:x}=ut(r,o,"addStrategy"),P=async $=>{const{id:B,...I}={...a,targetEnvironment:$};if(T($)){await w($,{id:B,...I},e);return}try{await u(r,o,$,a),h(),b(),p({title:"Strategy created",text:`Successfully copied a strategy to ${$}`,type:"success"})}catch(_){g(N(_))}S()},D=n.some($=>v(ce,$));return l("div",{children:[t(Me,{isOpen:f.isOpen,onClose:y,environment:f==null?void 0:f.environment,onConfirm:x,messageComponent:t(_o,{fromEnvironment:f.fromEnvironment,payload:f.strategy})}),t(Z,{title:`Copy to another environment${D?"":" (Access denied)"}`,children:t("div",{children:t(Oe,{size:"large",id:`copy-strategy-icon-menu-${a.id}`,"aria-controls":c?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":c?"true":void 0,onClick:$=>{i($.currentTarget)},"data-testid":Dn,disabled:!D,children:t(Vn,{})})})}),t(De,{id:"basic-menu",anchorEl:s,open:c,onClose:S,MenuListProps:{"aria-labelledby":`copy-strategy-icon-menu-${a.id}`},children:n.map($=>{const B=v(ce,$);return t(Z,{title:B?"":"You don't have access to add a strategy to this environment",children:t("div",{children:l(Ve,{onClick:()=>P($),disabled:!B,children:[t(A,{condition:!B,show:t(jt,{children:t(Nt,{fontSize:"small"})})}),l(at,{children:["Copy to ",$]})]})})},$)})})]})},No=({environmentId:e,strategy:n,onDragStart:a,onDragEnd:r,otherEnvironments:o,orderNumber:s,headerChildren:i})=>{const c=F("projectId"),u=F("featureId"),p=Ln(c,u,e,n.id);return t(so,{strategy:n,onDragStart:a,onDragEnd:r,orderNumber:s,actions:l(O,{children:[i,t(A,{condition:Boolean(o&&(o==null?void 0:o.length)>0),show:()=>t(jo,{environmentId:e,environments:o,strategy:n})}),t(K,{permission:Mn,environmentId:e,projectId:c,component:X,to:p,tooltipProps:{title:"Edit strategy"},children:t(ye,{})}),t(Vo,{projectId:c,featureId:u,environmentId:e,strategyId:n.id,icon:!0})]}),children:t(_n,{strategy:n})})},zo=(e,n,a,r)=>{const{data:o}=Te(e),s=o==null?void 0:o.find(u=>u.environment===a),i=s==null?void 0:s.features.find(u=>u.name===n);return i==null?void 0:i.changes.find(u=>u.action==="updateStrategy"||u.action==="deleteStrategy"?u.payload.id===r:!1)},Wo=({strategy:e,index:n,environmentName:a,otherEnvironments:r,isDragging:o,onDragStartRef:s,onDragOver:i,onDragEnd:c})=>{const u=F("projectId"),p=F("featureId"),g=m.useRef(null),h=zo(u,p,a,e.id);return l(q,{ref:g,onDragOver:i(g,n),sx:{opacity:o?"0.5":"1"},children:[t(A,{condition:n>0,show:t(jn,{text:"OR"})}),t(No,{strategy:e,environmentId:a,otherEnvironments:r,onDragStart:s(g,n),onDragEnd:c,orderNumber:n+1,headerChildren:t(Ho,{change:h})})]},e.id)},Ho=({change:e})=>{const n=ve();return de(n.breakpoints.down("sm"))?null:l(q,{sx:{mr:1.5},children:[t(A,{condition:(e==null?void 0:e.action)==="updateStrategy",show:t(Se,{color:"warning",children:"Modified in draft"})}),t(A,{condition:(e==null?void 0:e.action)==="deleteStrategy",show:t(Se,{color:"error",children:"Deleted in draft"})})]})},qo=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}})),Uo=d("span")(({theme:e})=>({fontSize:e.fontSizes.bodySize,textAlign:"center",padding:"0 1rem",background:e.palette.background.elevation2,position:"relative",maxWidth:"80%",color:e.palette.text.primary})),pn=({children:e})=>t(qo,{children:t(Uo,{children:e})}),Go=({environmentId:e,environments:n,onClick:a})=>{const r=F("projectId"),[o,s]=m.useState(null),i=Boolean(o),{hasAccess:c}=m.useContext(ot),u=n.some(p=>c(ce,r,p));return l("div",{children:[t(Z,{title:u?"":"(Access denied)",children:t("div",{children:t(re,{id:`copy-all-strategies-${e}`,"aria-controls":i?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":i?"true":void 0,onClick:p=>{s(p.currentTarget)},disabled:!u,variant:"outlined",children:"Copy from another environment"})})}),t(De,{id:"basic-menu",anchorEl:o,open:i,onClose:()=>{s(null)},MenuListProps:{"aria-labelledby":`copy-all-strategies-${e}`},children:n.map(p=>{const g=c(ce,r,p);return t(Z,{title:g?"":"You don't have access to add a strategy to this environment",children:t("div",{children:l(Ve,{onClick:()=>a(p),disabled:!g,children:[t(A,{condition:!g,show:t(jt,{children:t(Nt,{fontSize:"small"})})}),l(at,{children:["Copy from ",p]})]})})},p)})})]})},Yo=d("div")(({theme:e})=>({"&>*:nth-child(n)":{margin:e.spacing(1,0)}})),Ko=({payload:e,fromEnvironment:n,environment:a})=>l(Yo,{children:[t(M,{children:t("strong",{children:"Copy: "})}),e==null?void 0:e.map(r=>l(M,{children:[l("strong",{children:[xe((r==null?void 0:r.name)||"")," strategy"," "]})," "]})),l(M,{children:["from ",n," to ",a]})]}),Xo=({payload:e,environment:n})=>l(O,{children:[t(M,{component:"span",children:"Add "}),l("strong",{children:[xe((e==null?void 0:e.name)||"")," strategy"]})," to ",t("strong",{children:n})]}),Jo=d(Nn)(({theme:e})=>({display:"flex",flexDirection:"column",borderRadius:e.shape.borderRadiusMedium})),wt=({title:e,children:n,featureId:a,projectId:r,environmentId:o,strategy:s,Icon:i,onAfterAddStrategy:c})=>{const{addStrategyToFeature:u}=we(),{setToastApiError:p}=U(),{isChangeRequestConfigured:g}=ae(r),{changeRequestDialogDetails:h,onChangeRequestAddStrategy:b,onChangeRequestAddStrategyConfirm:S,onChangeRequestAddStrategyClose:v}=ut(r,a,"addStrategy");return l(O,{children:[t(Jo,{variant:"outlined",children:l(ho,{sx:{display:"flex",flexDirection:"column",flexGrow:1},children:[l(M,{variant:"body1",fontWeight:"medium",sx:{mb:.5,display:"flex",alignItems:"center"},children:[t(i,{color:"disabled",sx:{mr:1}})," ",e]}),t(M,{variant:"body2",color:"text.secondary",component:"p",children:n}),t(q,{sx:{ml:"auto",mt:"auto",pt:1,mr:{xs:"auto",sm:0}},children:t(oe,{permission:ce,projectId:r,environmentId:o,variant:"outlined",size:"small",onClick:async()=>{try{g(o)?b(o,s):(await u(r,a,o,s),c())}catch(f){p(N(f))}},children:"Use template"})})]})}),t(Me,{isOpen:h.isOpen,onClose:v,environment:h==null?void 0:h.environment,onConfirm:S,messageComponent:t(Xo,{environment:o,payload:h.strategy})})]})},Qo=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}})),Zo=d("div")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),er=d(rt)(({theme:e})=>({fontWeight:e.fontWeight.bold})),tr=d(X)(({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}})),nr=({projectId:e,featureId:n,environmentId:a,strategy:r})=>{const o=Re(r.name),s=xe(r.name),i=Ja(e,n,a,r.name);return l(tr,{to:i,children:[t(Qo,{children:t(o,{})}),l("div",{children:[t(er,{text:r.displayName||s,maxWidth:"200",maxLength:25}),t(Zo,{children:r.description})]})]})},ar=({projectId:e,featureId:n,environmentId:a})=>{const{strategies:r}=zn(),o=m.useMemo(()=>r.filter(s=>!s.deprecated),[r]);return t(st,{dense:!0,children:o.map(s=>t(Fe,{children:t(nr,{projectId:e,featureId:n,environmentId:a,strategy:s})},s.name))})},Qe=({label:e,projectId:n,featureId:a,environmentId:r,variant:o,matchWidth:s})=>{const[i,c]=m.useState(),u=Boolean(i),p=u?"FeatureStrategyMenuPopover":void 0,g=()=>{c(void 0)};return l("div",{onClick:b=>b.stopPropagation(),children:[t(oe,{permission:ce,projectId:n,environmentId:r,onClick:b=>{c(b.currentTarget)},"aria-labelledby":p,variant:o,sx:{minWidth:s?"282px":"auto"},children:e}),t(Wn,{id:p,open:u,anchorEl:i,onClose:g,onClick:g,children:t(ar,{projectId:n,featureId:a,environmentId:r})})]})},or=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingTop:e.spacing(2)})),rr=d("div")(({theme:e})=>({fontSize:e.fontSizes.bodySize,textAlign:"center",color:e.palette.text.primary,marginBottom:e.spacing(1)})),sr=d("p")(({theme:e})=>({color:e.palette.text.secondary,fontSize:e.fontSizes.smallBody,textAlign:"center",marginBottom:e.spacing(3)})),ir=({projectId:e,featureId:n,environmentId:a})=>{const{addStrategyToFeature:r}=we(),{setToastData:o,setToastApiError:s}=U(),{refetchFeature:i}=j(e,n),{refetchFeature:c}=un(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:g}=ae(e),{changeRequestDialogDetails:h,onChangeRequestAddStrategies:b,onChangeRequestAddStrategiesConfirm:S,onChangeRequestAddStrategyClose:v}=ut(e,n,"addStrategy"),T=(w=!1)=>{i(),c(),o({title:w?"Strategies created":"Strategy created",text:w?"Successfully copied from another environment":"Successfully created strategy",type:"success"})},f=async w=>{var P;const x=((P=p==null?void 0:p.find(D=>D.name===w))==null?void 0:P.strategies)||[];if(g(a)){await b(a,x,w);return}try{await Promise.all(x.map(D=>{const{id:$,...B}={...D,environment:a};return r(e,n,a,B)})),T(!0)}catch(D){s(N(D))}},y=p&&p.length>0;return l(O,{children:[t(Me,{isOpen:h.isOpen,onClose:v,environment:h==null?void 0:h.environment,onConfirm:S,messageComponent:t(Ko,{fromEnvironment:h.fromEnvironment,payload:h.strategies})}),l(or,{children:[t(rr,{children:"You have not defined any strategies yet."}),l(sr,{children:["Strategies added in this environment will only be executed if the SDK is using an"," ",t(X,{to:"/admin/api",children:"API key configured"})," for this environment."]}),l(q,{sx:{w:"100%",display:"flex",flexWrap:"wrap",gap:2,alignItems:"center",justifyContent:"center"},children:[t(Qe,{label:"Add your first strategy",projectId:e,featureId:n,environmentId:a,matchWidth:y}),t(A,{condition:y,show:t(Go,{environmentId:a,environments:p.map(w=>w.name),onClick:f})})]}),t(q,{sx:{width:"100%",mt:3},children:t(pn,{children:"Or use a strategy template"})}),l(q,{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:T,Icon:Re("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:T,Icon:Re("flexibleRollout"),strategy:{name:"flexibleRollout",parameters:{rollout:"50",stickiness:"default",groupId:u.name},constraints:[]},children:"Roll out to a percentage of your userbase."})]})]})]})},lr=d("div")(({theme:e})=>({width:"100%",position:"relative",paddingBottom:e.spacing(2)})),cr=d("div")(({theme:e})=>({[e.breakpoints.down(400)]:{padding:e.spacing(1)}})),dr=({featureEnvironment:e,isDisabled:n,otherEnvironments:a})=>{const r=F("projectId"),o=F("featureId"),{setStrategiesSortOrder:s}=we(),{setToastData:i,setToastApiError:c}=U(),{refetchFeature:u}=j(r,o),[p,g]=m.useState((e==null?void 0:e.strategies)||[]),[h,b]=m.useState(null);if(m.useEffect(()=>{g((e==null?void 0:e.strategies)||[])},[e==null?void 0:e.strategies]),!e)return null;const S=async y=>{try{await s(r,o,e.name,y),u(),i({title:"Order of strategies updated",type:"success"})}catch(w){c(N(w))}},v=(y,w)=>x=>{var P;b({id:p[w].id,index:w,height:((P=y.current)==null?void 0:P.offsetHeight)||0}),y!=null&&y.current&&(x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("text/html",y.current.outerHTML),x.dataTransfer.setDragImage(y.current,20,20))},T=y=>(w,x)=>P=>{if(h===null||w.current===null||h.index===x||y===h.id)return;const{top:D,bottom:$}=w.current.getBoundingClientRect(),B=P.clientY-D<h.height,I=$-P.clientY<h.height,_=h.index>x;if(B&&_||I&&!_){const W=[...p],L=W.splice(h.index,1)[0];W.splice(x,0,L),g(W),b({...h,index:x})}},f=()=>{b(null),S(p.map((y,w)=>({id:y.id,sortOrder:w})))};return t(lr,{children:l(cr,{children:[t(A,{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(A,{condition:p.length>0,show:t(O,{children:p.map((y,w)=>t(Wo,{strategy:y,index:w,environmentName:e.name,otherEnvironments:a,isDragging:(h==null?void 0:h.id)===y.id,onDragStartRef:v,onDragOver:T(y.id),onDragEnd:f},y.id))}),elseShow:t(ir,{projectId:r,featureId:o,environmentId:e.name})})]})})},gn=(e,n)=>e===0?0:Math.round(n/e*100);var _e={},je={};Object.defineProperty(je,"__esModule",{value:!0});je.defaultOptions=void 0;je.defaultOptions={decimalSeparator:".",lowercase:!1,precision:1,space:!1,units:["","K","M","B","T","P","E"]};var ue={};Object.defineProperty(ue,"__esModule",{value:!0});ue.roundTo=ue.parseValue=void 0;function ur(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}ue.parseValue=ur;function pr(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))}ue.roundTo=pr;Object.defineProperty(_e,"__esModule",{value:!0});_e.millify=void 0;const ze=je,Tt=ue,xt=1e3;function*At(e){let n=xt;for(;;){const a=e/n;if(a<1)return;yield a,n*=xt}}function hn(e,n){var a;const r=n?Object.assign(Object.assign({},ze.defaultOptions),n):ze.defaultOptions;if(!Array.isArray(r.units)||!r.units.length)throw new Error("Option `units` must be a non-empty array");let o;try{o=Tt.parseValue(e)}catch(S){return S instanceof Error&&console.warn(`WARN: ${S.message} (millify)`),String(e)}const s=o<0?"-":"";o=Math.abs(o);let i=0;for(const S of At(o))o=S,i+=1;if(i>=r.units.length)return e.toString();let u=Tt.roundTo(o,r.precision);for(const S of At(u))u=S,i+=1;const p=(a=r.units[i])!==null&&a!==void 0?a:"",g=r.lowercase?p.toLowerCase():p,h=r.space?" ":"",b=u.toString().replace(ze.defaultOptions.decimalSeparator,r.decimalSeparator);return`${s}${b}${h}${g}`}_e.millify=hn;var gr=_e.default=hn;const Pe=({value:e,threshold:n=1e6,precision:a=2})=>{let r,o=!1;e<n?r=e.toLocaleString():(r=gr(e,{precision:a}),o=!0);const s=t("span",{"data-testid":Hn,children:r});return t(A,{condition:o,show:t(Z,{title:e.toLocaleString(),arrow:!0,children:s}),elseShow:s})},We=d("article")(({theme:e})=>({padding:e.spacing(2),background:"transparent",borderRadius:e.spacing(2),textAlign:"center",[e.breakpoints.up("md")]:{padding:e.spacing(4)}})),He=d("h3")(({theme:e})=>({margin:0,fontSize:e.fontSizes.bodySize,fontWeight:e.fontWeight.thin})),qe=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})),mn=({totalYes:e,totalNo:n,hoursBack:a,statsSectionId:r,tableSectionId:o})=>{const s=a===1?"in the last hour":`in the last ${a} hours`;return l(ee,{container:!0,spacing:2,id:r,"aria-describedby":o,"aria-label":"Feature metrics summary",component:"section",children:[t(ee,{item:!0,xs:12,sm:4,children:l(We,{children:[t(He,{children:"Exposure"}),t(qe,{children:t(Pe,{value:e})}),l(Ue,{children:["Total exposure of the feature in the environment"," ",s,"."]})]})}),t(ee,{item:!0,xs:12,sm:4,children:l(We,{children:[t(He,{children:"Exposure %"}),l(qe,{children:[gn(e+n,e),"%"]}),l(Ue,{children:["% total exposure of the feature in the environment"," ",s,"."]})]})}),t(ee,{item:!0,xs:12,sm:4,children:l(We,{children:[t(He,{children:"Requests"}),t(qe,{children:t(Pe,{value:e+n})}),l(Ue,{children:["Total requests for the feature in the environment"," ",s,"."]})]})})]})},hr=({environmentMetric:e})=>e?l(O,{children:[t(pn,{children:"Feature toggle exposure"}),t("div",{children:t(mn,{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"}})),mr=d(qn)(({theme:e})=>({fill:e.palette.background.application,height:"75px",width:"75px",[e.breakpoints.down(500)]:{display:"none"}})),fr=d("div")(({theme:e})=>({margin:e.spacing(0,2),[e.breakpoints.down(500)]:{display:"none"}})),yr=({environmentMetric:e,disabled:n=!1})=>{const a=Un();if(!e)return null;const r=e.yes+e.no,o=gn(r,e==null?void 0:e.yes);return!e||e.yes===0&&e.no===0?l(Et,{children:[l(It,{children:[l(Rt,{style:{color:n?a.palette.text.secondary:void 0},"data-loading":!0,children:[o,"%"]}),l(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(mr,{style:{transform:"scale(1.1)"},"data-loading":!0})]}):l(Et,{children:[l(It,{children:[l(Rt,{children:[o,"%"]}),l(Ft,{children:["The feature has been requested"," ",l("b",{children:[t(Pe,{value:r})," times"]})," ","and exposed"," ",l("b",{children:[t(Pe,{value:e.yes})," ","times"]})," ","in the last hour"]})]}),t(fr,{"data-loading":!0,children:t(Gn,{percentage:o,size:"3rem"})})]})},Sr=({strategyName:e})=>{const n=Re(e);return t(Z,{title:xe(e),arrow:!0,children:t(br,{children:t(n,{})})})},br=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)}})),Cr=({strategies:e})=>e!=null&&e.length?t(vr,{"aria-label":"Feature strategies",children:e.map(n=>t(wr,{children:t(Sr,{strategyName:n.name})},n.id))}):null,vr=d("ul")(()=>({all:"unset",display:"flex",alignItems:"center",alignContent:"center"})),wr=d("li")(()=>({all:"unset",minWidth:30,textAlign:"center"})),Tr=d("div",{shouldForwardProp:e=>e!=="enabled"})(({theme:e,enabled:n})=>({borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2),backgroundColor:e.palette.background.paper,background:n?e.palette.background.paper:e.palette.neutral.light})),xr=d(Yn)({boxShadow:"none",background:"none"}),Ar=d(Kn)(({theme:e})=>({boxShadow:"none",padding:e.spacing(2,4),[e.breakpoints.down(400)]:{padding:e.spacing(1,2)}})),Er=d(Xn,{shouldForwardProp:e=>e!=="enabled"})(({theme:e,enabled:n})=>({padding:e.spacing(3),background:e.palette.background.elevation2,borderBottomLeftRadius:e.shape.borderRadiusLarge,borderBottomRightRadius:e.shape.borderRadiusLarge,borderBottom:`4px solid ${n?e.palette.primary.light:e.palette.neutral.border}`,[e.breakpoints.down("md")]:{padding:e.spacing(2,1)}})),Ir=d(dr)(({theme:e})=>({width:"100%",position:"relative",paddingBottom:e.spacing(2)})),Rr=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})),Fr=d("div")(({theme:e})=>({display:"flex",alignItems:"center",[e.breakpoints.down(560)]:{flexDirection:"column",textAlign:"center"}})),kr=d(ko)(({theme:e})=>({[e.breakpoints.down(560)]:{marginBottom:"0.5rem"}})),Pr=d(rt)(({theme:e})=>({fontSize:e.fontSizes.bodySize,fontWeight:e.typography.fontWeightMedium,[e.breakpoints.down(560)]:{textAlign:"center"}})),$r=d("div")(({theme:e})=>({display:"flex",alignItems:"center",marginLeft:"1.8rem",[e.breakpoints.down(560)]:{flexDirection:"column",marginLeft:"0"}})),Br=({env:e})=>{var p;const n=F("projectId"),a=F("featureId"),{metrics:r}=Io(n,a),{feature:o}=j(n,a),{value:s}=zt(),c=Fo(o==null?void 0:o.environments,r).find(g=>g.environment===e.name),u=o==null?void 0:o.environments.find(g=>g.name===e.name);return t(A,{condition:!Boolean(new Set(s.hiddenEnvironments).has(e.name)),show:t(Tr,{enabled:e.enabled,children:l(xr,{"data-testid":`${Jn}_${e.name}`,children:[l(Ar,{expandIcon:t(io,{titleAccess:"Toggle"}),children:[l(Rr,{"data-loading":!0,enabled:e.enabled,children:[l(Fr,{children:[t(kr,{enabled:e.enabled}),t("div",{children:t(Pr,{text:e.name,maxWidth:"100",maxLength:15})}),t(A,{condition:!e.enabled,show:t(Se,{color:"neutral",sx:{ml:1},children:"Disabled"})})]}),l($r,{children:[t(Qe,{label:"Add strategy",projectId:n,featureId:a,environmentId:e.name,variant:"text"}),t(Cr,{strategies:u==null?void 0:u.strategies})]})]}),t(yr,{environmentMetric:c,disabled:!e.enabled})]}),l(Er,{enabled:e.enabled,children:[t(Ir,{featureEnvironment:u,isDisabled:!e.enabled,otherEnvironments:o==null?void 0:o.environments.map(({name:g})=>g).filter(g=>g!==e.name)}),t(A,{condition:(((p=u==null?void 0:u.strategies)==null?void 0:p.length)||0)>0,show:l(O,{children:[t(q,{sx:{display:"flex",justifyContent:"center",py:1},children:t(Qe,{label:"Add strategy",projectId:n,featureId:a,environmentId:e.name})}),t(hr,{environmentMetric:c})]})})]})]})})})},Or=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n);if(!a)return null;const{environments:r}=a;return t(O,{children:r==null?void 0:r.map(o=>t(Br,{env:o},o.name))})},Dr=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(3),fontSize:e.fontSizes.smallBody})),Vr=d("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)})),Lr=({feature:e,header:n})=>{const{locationSettings:a}=Qn();return l(Dr,{children:[n,l("div",{"data-loading":!0,children:[t(Vr,{children:"Created at:"}),t("span",{children:Zn(ea(e.createdAt),a.locale)})]})]})},Mr=d(Oe,{shouldForwardProp:e=>e!=="visibilityOff"})(({theme:e,visibilityOff:n})=>({marginLeft:"auto",marginRight:e.spacing(-1),color:n?e.palette.neutral.main:e.palette.divider,"&:hover":{color:e.palette.neutral.main}})),_r=({environment:e,hiddenEnvironments:n,setHiddenEnvironments:a})=>t(Mr,{onClick:()=>{a(e.name)},visibilityOff:n.has(e.name),children:t(A,{condition:n.has(e.name),show:t(ta,{}),elseShow:t(na,{})})}),jr=d("div")(({theme:e})=>({marginLeft:e.spacing(-1.5),"&:not(:last-of-type)":{marginBottom:e.spacing(2)},display:"flex",alignItems:"center"})),Nr=d("label")(()=>({display:"inline-flex",alignItems:"center",cursor:"pointer"})),zr=({environment:e,callback:n,showInfoBox:a,children:r,hiddenEnvironments:o,setHiddenEnvironments:s})=>{const{name:i,enabled:c}=e,u=F("projectId"),p=F("featureId"),{toggleFeatureEnvironmentOn:g,toggleFeatureEnvironmentOff:h}=Ae(),{refetchFeature:b}=j(u,p),{setToastData:S,setToastApiError:v}=U(),{isChangeRequestConfigured:T}=ae(u),{onChangeRequestToggle:f,onChangeRequestToggleClose:y,onChangeRequestToggleConfirm:w,changeRequestDialogDetails:x}=Qa(u),P=async()=>{try{await g(u,p,i),S({type:"success",title:`Available in ${i}`,text:`${p} is now available in ${i} based on its defined strategies.`}),b(),n&&n()}catch(I){I instanceof Error&&I.message===eo?a():v(N(I))}},D=async()=>{try{await h(u,p,i),S({type:"success",title:`Unavailable in ${i}`,text:`${p} is unavailable in ${i} and its strategies will no longer have any effect.`}),b(),n&&n()}catch(I){v(N(I))}},$=async I=>{if(T(i)){I.preventDefault(),f(p,i,!c);return}if(c){await D();return}await P()},B=l(O,{children:[" ",l("span",{"data-loading":!0,children:[c?"enabled":"disabled"," in"]})," ",t(rt,{text:i,maxWidth:"120",maxLength:15})]});return l(jr,{children:[l(Nr,{children:[t(aa,{tooltip:c?`Disable feature in ${i}`:`Enable feature in ${i}`,permission:oa,projectId:u,checked:c,onChange:$,environmentId:i}),r??B]}),t(_r,{environment:e,hiddenEnvironments:o,setHiddenEnvironments:s}),t(Me,{isOpen:x.isOpen,onClose:y,environment:x==null?void 0:x.environment,onConfirm:w,messageComponent:t(Za,{enabled:x==null?void 0:x.enabled,featureName:x==null?void 0:x.featureName,environment:x.environment})})]})},Wr=d("div")(({theme:e})=>({padding:e.spacing(3)})),Hr=d("div")(()=>({display:"flex",flexDirection:"column"})),qr=d("p")(({theme:e})=>({fontSize:e.fontSizes.bodySize})),Ur=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:'"-"'}})),Gr=d(ra)(()=>({"&:hover, &:focus":{textDecoration:"underline"}})),Yr=({feature:e,header:n,hiddenEnvironments:a,setHiddenEnvironments:r})=>{const[o,s]=m.useState(!1),[i,c]=m.useState(""),u=e.environments.some(p=>{var g;return p.enabled&&((g=p.variants)==null?void 0:g.length)});return l(Wr,{"data-testid":"feature-toggle-status",children:[n,e.environments.map(p=>{const g=p.strategies.length===1?"1 strategy":`${p.strategies.length} strategies`,h=p.variants??[],b=h.length>0&&l(O,{children:[t(kt,{}),t(Z,{title:"View variants",arrow:!0,describeChild:!0,children:t(Gr,{component:X,to:`/projects/${e.project}/features/${e.name}/variants`,underline:"hover",children:h.length===1?"1 variant":`${h.length} variants`})})]}),S=p.enabled&&h.length===0&&u;return t(zr,{environment:p,hiddenEnvironments:a,setHiddenEnvironments:r,showInfoBox:()=>{c(p.name),s(!0)},children:l(Hr,{children:[t(qr,{children:p.name}),l(Ur,{children:[g,b,t(A,{condition:S,show:l(O,{children:[t(kt,{}),t(to,{})]})})]})]})},p.name)}),t(no,{open:o,onClose:()=>s(!1),projectId:e.project,featureId:e.name,environmentName:i})]})},fn=(e,n={})=>{const a=async()=>{const p=pe(`api/admin/features/${e}/tags`);return(await fetch(p,{method:"GET"}).then(Ce("Tags"))).json()},r=`api/admin/features/${e}/tags`,{data:o,error:s}=Wt(Boolean(e),{tags:[]},r,a,n),[i,c]=m.useState(!s&&!o),u=()=>{Be(r)};return m.useEffect(()=>{c(!s&&!o)},[o,s]),{tags:(o==null?void 0:o.tags)||[],error:s,loading:i,refetch:u}},Kr=sa(),Xr=({options:e,featureTags:n,tagType:a,onChange:r})=>{const o=t(ia,{fontSize:"small"}),s=t(la,{fontSize:"small"});return t(it,{multiple:!0,id:"checkboxes-tags-demo",sx:{marginTop:g=>g.spacing(2),width:500},disableCloseOnSelect:!0,placeholder:"Select Values",options:e,isOptionEqualToValue:(g,h)=>h.inputValue&&h.inputValue!==""?g.title===h.inputValue:g.title===h.title,getOptionDisabled:g=>n.some(h=>h.type===a&&h.value===g.title),getOptionLabel:g=>g.inputValue?g.inputValue:g.title,renderOption:(g,h,{selected:b})=>{const S=n.some(v=>v.type===a&&v.value===h.title);return l("li",{...g,children:[t(A,{condition:Boolean(h.inputValue),show:t(Ht,{sx:{mr:v=>v.spacing(.5)}}),elseShow:t(qt,{icon:o,checkedIcon:s,sx:{mr:v=>v.spacing(.5)},checked:b||S})}),h.title]})},filterOptions:(g,h)=>{const b=Kr(g,h),{inputValue:S}=h,v=g.some(T=>S===T.title);return S!==""&&!v&&b.push({inputValue:S,title:`Create new value "${S}"`}),b},ListboxProps:{style:{maxHeight:200,overflow:"auto"}},onChange:r,renderInput:g=>t(Le,{...g,label:"Select values",placeholder:"Select values"})})},Jr=d("li")({flexDirection:"column"}),Qr=({value:e,onChange:n})=>{const{tagTypes:a}=ca(),r=ve();return t(it,{disablePortal:!0,id:"tag-type-select",sx:{marginTop:o=>o.spacing(2),width:500},options:a,disableClearable:!0,value:e,getOptionLabel:o=>o.name,renderOption:(o,s)=>l(Jr,{...o,style:{alignItems:"flex-start",gap:r.spacing(.5)},children:[t(M,{variant:"body1",children:s.name}),t(M,{variant:"caption",children:s.description})]}),renderInput:o=>t(Le,{...o,label:"Tag type",value:e}),onChange:n,ListboxProps:{style:{maxHeight:200,overflow:"auto"}}})},Zr=()=>{const{makeRequest:e,createRequest:n,errors:a,loading:r}=da({propagateErrors:!0});return{createTag:async s=>{const c=n("api/admin/tags",{method:"POST",body:JSON.stringify(s)});try{return await e(c.caller,c.id)}catch(u){throw u}},errors:a,loading:r}},es=(e,n={})=>{const a=async()=>{const p=pe(`api/admin/tags/${e}`);return(await fetch(p,{method:"GET"}).then(Ce("Tags"))).json()},r=`api/admin/tags/${e}`,{data:o,error:s}=Wt(Boolean(e),{tags:[]},r,a,n),[i,c]=m.useState(!s&&!o),u=()=>{Be(r)};return m.useEffect(()=>{c(!s&&!o)},[o,s]),{tags:(o==null?void 0:o.tags)||[],error:s,loading:i,refetch:u}},ts=d("section")(({theme:e})=>({["& > *"]:{margin:e.spacing(1,0)}})),yn=({open:e,setOpen:n})=>{const a=F("featureId"),{createTag:r}=Zr(),{addTagToFeature:o,loading:s}=Ae(),{tags:i,refetch:c}=fn(a),{setToastData:u}=U(),[p,g]=m.useState({name:"simple",description:"Simple tag to get you started",icon:""}),{trackEvent:h}=Ut(),[b,S]=m.useState([]),{tags:v,refetch:T}=es(p.name),f=m.useMemo(()=>v.map(B=>({title:B.value})),[v]),y=()=>{n(!1),S([])},w=async B=>{B.preventDefault();let I=0;if(b.length!==0){for(const _ of b)if(!i.includes({type:p.name,value:_.title}))try{_.title.startsWith("Create")||(await o(a,{type:p.name,value:_.title}),I++,await c())}catch(W){const L=N(W);u({type:"error",title:"Failed to add tag",text:L,confetti:!1})}I>1&&h("suggest_tags",{props:{eventType:"multiple_tags_added"}}),I>0&&u({type:"success",title:`Added tag${I>1?"s":""} to toggle`,text:`We successfully added ${I} new tag${I>1?"s":""} to your toggle`,confetti:!0}),n(!1),S([])}},x=(B,I)=>{I!=null&&typeof I!="string"&&(B.preventDefault(),g(I))},P=(B,I,_)=>{if(_==="selectOption"){const W=ua(I);I.forEach((L,G)=>{if(typeof L!="string"&&L.inputValue&&L.inputValue!==""){const J={value:L.inputValue,type:p.name};r(J).then(()=>{h("suggest_tags",{props:{eventType:"tag_created"}}),T()}),L.title=L.inputValue,L.inputValue="",W[G]=L}}),S(W)}},D=b.length!==0,$="add-tag-form";return t(O,{children:t(le,{open:e,secondaryButtonText:"Cancel",primaryButtonText:`Add tag (${b.length})`,title:"Add tags to feature toggle",onClick:w,disabledPrimaryButton:s||!D,onClose:y,formId:$,children:l(O,{children:[t(M,{paragraph:!0,sx:{marginBottom:B=>B.spacing(2.5)},children:"Tags allow you to group features together"}),t("form",{id:$,onSubmit:w,children:l(ts,{children:[t(Qr,{autoFocus:!0,value:p,onChange:x}),t(Xr,{options:f,tagType:p.name,featureTags:i,onChange:P})]})})]})})})},ns=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(3)})),as=d("div")(({theme:e})=>({display:"flex",gap:e.spacing(1),flexWrap:"wrap"})),os=d(Gt)(({theme:e})=>({fontSize:e.fontSizes.smallBody})),rs=d(ke)(({theme:e})=>({margin:e.spacing(3),borderStyle:"dashed"})),ss=d(re)(({theme:e})=>({maxWidth:e.spacing(20),alignSelf:"center"})),is=({feature:e,header:n})=>{const{tags:a,refetch:r}=fn(e.name),{deleteTagFromFeature:o}=Ae(),[s,i]=m.useState(!1),[c,u]=m.useState(!1),[p,g]=m.useState(),{setToastData:h,setToastApiError:b}=U(),{hasAccess:S}=m.useContext(ot),v=S(ie,e.project),T=async()=>{if(p)try{await o(e.name,p.type,p.value),r(),h({type:"success",title:"Tag deleted",text:"Successfully deleted tag"})}catch(f){b(N(f))}};return l(ns,{children:[n,t(as,{children:a.map(f=>{const y=`${f.type}:${f.value}`;return t(os,{label:y,deleteIcon:t(pa,{titleAccess:"Remove"}),onDelete:v?()=>{u(!0),g(f)}:void 0},y)})}),t(A,{condition:v,show:l(O,{children:[t(A,{condition:a.length>0,show:t(rs,{})}),t(ss,{"data-loading":!0,variant:"outlined",startIcon:t(Ht,{}),onClick:()=>i(!0),children:"Add new tag"})]})}),t(yn,{open:s,setOpen:i}),l(le,{open:c,primaryButtonText:"Delete tag",secondaryButtonText:"Cancel",onClose:()=>{u(!1),g(void 0)},onClick:()=>{u(!1),T(),g(void 0)},title:"Delete tag?",children:["You are about to delete tag:"," ",l("strong",{children:[p==null?void 0:p.type,":",p==null?void 0:p.value]})]})]})},ls=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"}})),Ge=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}})),cs=({hiddenEnvironments:e,setHiddenEnvironments:n})=>{const a=F("projectId"),r=F("featureId"),{feature:o}=j(a,r);return l(ls,{children:[t(Yr,{header:l(Ge,{"data-loading":!0,children:["Enabled in environments (",o.environments.filter(({enabled:s})=>s).length,")",t(Ke,{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:o,hiddenEnvironments:e,setHiddenEnvironments:n}),t(ke,{}),t(Lr,{header:t(Ge,{"data-loading":!0,children:"Feature toggle details"}),feature:o}),t(ke,{}),t(is,{header:t(Ge,{"data-loading":!0,children:"Tags for this feature toggle"}),feature:o})]})},ds=()=>{const{trackEvent:e}=Ut(),{value:n,setValue:a}=zt(),[r,o]=m.useState(new Set(n.hiddenEnvironments));return{hiddenEnvironments:r,setHiddenEnvironments:i=>{a(c=>{const u=new Set(c.hiddenEnvironments);return u.has(i)?(u.delete(i),e("hidden_environment",{props:{eventType:"environment unhidden"}})):(u.add(i),e("hidden_environment",{props:{eventType:"environment hidden"}})),o(u),{...n,hiddenEnvironments:u}})}}},us=d("div")(({theme:e})=>({display:"flex",width:"100%",[e.breakpoints.down(1e3)]:{flexDirection:"column"}})),ps=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",width:"calc(100% - (350px + 1rem))",[e.breakpoints.down(1e3)]:{width:"100%"}})),gs=()=>{const e=ge(),n=F("projectId"),a=F("featureId"),r=_t(n,a),{hiddenEnvironments:o,setHiddenEnvironments:s}=ds(),i=()=>e(r);return Yt(a),l(us,{children:[l("div",{children:[t(Eo,{}),t(cs,{hiddenEnvironments:o,setHiddenEnvironments:s})]}),t(ps,{children:t(Or,{})}),l(Kt,{children:[t(ne,{path:"strategies/create",element:t(Xe,{label:"Create feature strategy",onClose:i,open:!0,children:t(ao,{})})}),t(ne,{path:"strategies/edit",element:t(Xe,{label:"Edit feature strategy",onClose:i,open:!0,children:t(ga,{})})})]})]})},hs=({values:e=[],updateValues:n,placeholder:a="",error:r,...o})=>{const s=c=>{const p=c.target.value.split(/,\s?/).map(g=>g.trim());n(p)},i=c=>{if(c.key==="Backspace"){const u=c.target.value;if(u.endsWith(", ")){c.preventDefault();const p=u.slice(0,-2);n(p.split(/,\s*/))}}};return t(Le,{...o,error:r,placeholder:a,value:e?e.join(", "):"",onKeyDown:i,onChange:s,style:{width:"100%"},variant:"outlined",size:"small"})},ms=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"}}})),fs=d(Xt)(({theme:e})=>({minWidth:e.spacing(20),marginRight:e.spacing(10)})),ys=d("div")(({theme:e})=>({width:"100%",gap:e.spacing(1.5),display:"flex"})),Ss=d(hs)(()=>({width:"100%"})),bs=d(Le)(()=>({width:"100%"})),Cs=({overrides:e,overridesDispatch:n})=>{const{context:a}=lt(),r=a.map(({name:i})=>({key:i,label:i})),o=i=>c=>{n({type:"UPDATE_VALUES_AT",payload:[i,c]})},s=i=>(c,u)=>{c==null||c.preventDefault(),n({type:"UPDATE_VALUES_AT",payload:[i,u||[]]})};return t(O,{children:e.map((i,c)=>{var h;const u=a.find(({name:b})=>b===i.contextName),p=((h=u==null?void 0:u.legalValues)==null?void 0:h.map(({value:b})=>b))||[],g=i.values.filter(b=>p.includes(b));return l(ms,{children:[t(fs,{id:"override-context-name",name:"contextName",label:"Context Field",value:i.contextName,options:r,onChange:b=>n({type:"UPDATE_TYPE_AT",payload:[c,b.target.value]})}),l(ys,{children:[t(A,{condition:Boolean(p&&p.length>0),show:t(it,{multiple:!0,id:`override-select-${c}`,isOptionEqualToValue:(b,S)=>b===S,options:p,onChange:s(c),getOptionLabel:b=>b,value:g,style:{width:"100%"},filterSelectedOptions:!0,size:"small",renderInput:b=>t(bs,{...b,variant:"outlined",label:"Legal values"})}),elseShow:t(Ss,{label:"Values (v1, v2, ...)",name:"values",placeholder:"",values:i.values,updateValues:o(c)})}),t(Z,{title:"Remove",arrow:!0,children:t(Oe,{onClick:b=>{b.preventDefault(),n({type:"REMOVE",payload:c})},children:t(tt,{})})})]})]},`override=${c}`)})})},vs=(e,n)=>{switch(n.type){case"SET":return n.payload;case"CLEAR":return[];case"ADD":return[...e,n.payload];case"REMOVE":return e.filter((i,c)=>c!==n.payload);case"UPDATE_VALUES_AT":const[a,r]=n.payload;return e.map((i,c)=>c===a?{...i,values:r}:i);case"UPDATE_TYPE_AT":const[o,s]=n.payload;return e.map((i,c)=>c===o?{...i,contextName:s}:i)}},ws=(e=[])=>m.useReducer(vs,e);var Y=(e=>(e.FIX="fix",e.VARIABLE="variable",e))(Y||{});const Ts=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})),xs=d(Z)(({theme:e})=>({position:"absolute",top:e.spacing(2),right:e.spacing(2)})),Sn=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Pt=d(Sn)(({theme:e})=>({display:"flex",color:e.palette.text.primary,marginTop:e.spacing(1),marginBottom:e.spacing(2)})),As=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(2)})),Es=d(ha)(({theme:e})=>({marginBottom:e.spacing(1),"& > span":{fontSize:e.fontSizes.smallBody},[e.breakpoints.down("sm")]:{marginTop:e.spacing(1),marginBottom:e.spacing(1.5)}})),$t=d(Jt)(()=>({width:"100%"})),Is=d("div")(({theme:e})=>({marginLeft:e.spacing(3)})),Rs=d(Jt)(({theme:e})=>({width:e.spacing(24),[e.breakpoints.down("sm")]:{width:"100%"}})),Fs=d("div")(({theme:e})=>({marginTop:e.spacing(3),flexGrow:1})),bn=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%"}}})),ks=d(bn)({alignItems:"end",justifyContent:"space-between"}),Ps=d(Xt)(({theme:e})=>({minWidth:e.spacing(20),marginRight:e.spacing(10)})),$s=d(re)(({theme:e})=>({width:e.spacing(20),maxWidth:"100%"})),Bs=[{key:"string",label:"string"},{key:"json",label:"json"},{key:"csv",label:"csv"}],Os={type:"string",value:""},Ds=({variant:e,variants:n,updateVariant:a,removeVariant:r,apiPayload:o})=>{const[s,i]=m.useState(e.name),[c,u]=m.useState(e.weightType===Y.FIX),[p,g]=m.useState(String(e.weight/10)),[h,b]=m.useState(e.payload||Os),[S,v]=ws(e.overrides||[]),{context:T}=lt(),[f,y]=m.useState({}),w=C=>{y(E=>({...E,[C]:void 0}))},x=(C,E)=>{y(V=>({...V,[C]:E}))};m.useEffect(()=>{var C;w("percentage"),(C=o.error)!=null&&C.includes("%")&&x("percentage","Total weight must equal 100%")},[o.error]);const P=!e.new,D=n.filter(({id:C,weightType:E})=>C!==e.id&&E===Y.VARIABLE).length>0,$=C=>{const E=C.weightType===Y.VARIABLE,V=n.some(Q=>Q.weightType===Y.FIX),H=n.filter(Q=>Q.weightType===Y.VARIABLE).length===1;return V&&H&&E},B=C=>{w("name"),G(C,e.id)||x("name","A variant with that name already exists for this environment."),i(C)},I=C=>{(C===""||J(C))&&g(C)},_=C=>{R(C)||x("payload","Invalid JSON.")},W=()=>{T.length>0&&v({type:"ADD",payload:{contextName:T[0].name,values:[]}})},L=C=>Boolean(C.length),G=(C,E)=>P||!n.some(V=>V.name===C&&V.id!==E),J=C=>{if(!c)return!0;if(C===""||C.match(/\.[0-9]{2,}$/))return!1;const E=Number(C);return E>=0&&E<=100},R=C=>{try{return C.type==="json"&&JSON.parse(C.value),!0}catch{return!1}};return m.useEffect(()=>{a({...e,name:s,weight:Number(c?p:100)*10,weightType:c?Y.FIX:Y.VARIABLE,stickiness:(n==null?void 0:n.length)>0?n[0].stickiness:"default",payload:h.value?h:void 0,overrides:S.map(C=>({contextName:C.contextName,values:C.values})).filter(C=>C.values&&C.values.length>0),isValid:L(s)&&G(s,e.id)&&J(p)&&R(h)&&!o.error})},[s,c,p,h,S]),m.useEffect(()=>{c||g(String(e.weight/10))},[e.weight]),l(Ts,{children:[t(xs,{arrow:!0,title:$(e)?"You need to have at least one variable variant":"Delete variant",children:t("div",{children:t(Oe,{"data-testid":`VARIANT_DELETE_BUTTON_${e.name}`,onClick:()=>r(e.id),disabled:$(e),children:t(tt,{})})})}),l(ks,{children:[l(Fs,{children:[t(Sn,{children:"Variant name"}),t(As,{children:"This will be used to identify the variant in your code"}),t($t,{"data-testid":"VARIANT_NAME_INPUT",autoFocus:!0,label:"Variant name",error:Boolean(f.name),errorText:f.name,value:s,onChange:C=>B(C.target.value),disabled:P,required:!0})]}),t(A,{condition:D,show:l(Is,{children:[t(Es,{label:"Custom percentage",control:t(ma,{"data-testid":"VARIANT_WEIGHT_CHECK",checked:c,onChange:C=>u(C.target.checked)})}),t(Rs,{"data-testid":"VARIANT_WEIGHT_INPUT",type:"number",label:"Variant weight",error:Boolean(f.percentage),errorText:f.percentage,value:p,onChange:C=>I(C.target.value),required:c,disabled:!c,"aria-valuemin":0,"aria-valuemax":100,InputProps:{endAdornment:t(fa,{position:"end",children:"%"})}})]})})]}),l(Pt,{children:["Payload",t(Ke,{tooltip:"Passed along with the the variant object."})]}),l(bn,{children:[t(Ps,{id:"variant-payload-type",name:"type",label:"Type",value:h.type,options:Bs,onChange:C=>{w("payload"),b(E=>({...E,type:C.target.value}))}}),t($t,{id:"variant-payload-value",name:"variant-payload-value",label:"Value",multiline:h.type!=="string",rows:h.type==="string"?1:4,value:h.value,onChange:C=>{w("payload"),b(E=>({...E,value:C.target.value}))},placeholder:h.type==="json"?'{ "hello": "world" }':"",onBlur:()=>_(h),error:Boolean(f.payload),errorText:f.payload})]}),l(Pt,{children:["Overrides",t(Ke,{tooltip:"Here you can specify which users should get this variant."})]}),t(Cs,{overrides:S,overridesDispatch:v}),t($s,{onClick:W,variant:"outlined",color:"primary",children:"Add override"})]})},Vs=d("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"},marginTop:e.spacing(-1.5),marginBottom:e.spacing(4)})),Ls=d(Qt,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.neutral.border:e.palette.primary.main})),Ms=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})),_s=d("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),js=d(he)(({theme:e})=>({marginBottom:e.spacing(2)})),Ns=d(he)(({theme:e})=>({marginTop:e.spacing(4)})),zs=d("div")({display:"flex",flexDirection:"column-reverse"}),Ws=d("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),Bt=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),Hs=d(ya)(({theme:e})=>({minWidth:e.spacing(20),width:"100%"})),qs=d("div")(({theme:e})=>({marginTop:"auto",paddingTop:e.spacing(4),display:"flex",justifyContent:"flex-end"})),Us=d(re)(({theme:e})=>({marginLeft:e.spacing(3)})),Gs=({environment:e,open:n,setOpen:a,getApiPayload:r,getCrPayload:o,onConfirm:s})=>{var Q;const i=F("projectId"),c=F("featureId"),{uiConfig:u}=ct(),{context:p}=lt(),{defaultStickiness:g}=Sa(i),{isChangeRequestConfigured:h}=ae(i),{data:b}=Te(i),{changeRequestInReviewOrApproved:S,alert:v}=Ca(b),T=(e==null?void 0:e.variants)||[],[f,y]=m.useState([]);m.useEffect(()=>{y(T.length?T.map(k=>({...k,isValid:!0,new:!1,id:Ne()})):[{name:"",weightType:Y.VARIABLE,weight:0,overrides:[],stickiness:(f==null?void 0:f.length)>0?f[0].stickiness:g,new:!0,isValid:!1,id:Ne()}])},[n]);const w=(k,z)=>{y(se=>mt(se.map(Ee=>Ee.id===z?k:Ee),1e3))},x=f.map(({new:k,isValid:z,id:se,...Ee})=>Ee),P=r(T,x),D=o(x),$=async k=>{k.preventDefault(),s(x)},B=()=>L?`curl --location --request POST '${u.unleashUrl}/api/admin/projects/${i}/environments/${e==null?void 0:e.name}/change-requests' \\
|
|
1
|
+
import{aA as vn,aB as wn,s as d,r as m,aC as Tn,aD as xn,aE as pt,j as t,aF as An,aG as En,c as $e,aH as F,aI as j,aJ as In,f as l,aK as Rn,C as A,aL as K,aM as ie,aN as X,aO as ye,aP as Fn,aQ as et,aR as pe,aS as Ce,aT as Be,u as ve,aU as ae,F as O,aV as gt,aW as ht,aX as tt,aY as oe,aZ as le,T as M,a_ as we,a2 as U,ar as ge,a$ as nt,b0 as Te,A as he,b1 as _t,a4 as N,b2 as kn,b3 as Pn,b4 as $n,b5 as Bn,ap as xe,b6 as On,b7 as ce,b8 as Z,m as Oe,b9 as Dn,ba as Vn,bb as De,a8 as Ve,bc as jt,bd as Nt,be as at,bf as Ln,bg as Mn,bh as _n,a as q,p as jn,N as de,B as Se,bi as ot,a9 as re,bj as Nn,x as rt,an as Re,E as zn,bk as st,bl as Fe,P as Wn,bm as Hn,bn as ee,bo as qn,bp as Un,D as Gn,bq as Yn,br as Kn,bs as Xn,bt as zt,bu as Jn,bv as Qn,bw as Zn,bx as ea,by as ta,bz as na,bA as Ae,bB as aa,bC as oa,bD as ra,bE as Wt,ad as it,ac as Le,bF as Ht,bG as qt,bH as sa,bI as ia,bJ as la,bK as ca,Z as da,bL as Ut,bM as ua,w as Gt,af as ke,bN as pa,bO as Ke,bP as Yt,bQ as Kt,bR as ne,bS as Xe,bT as ga,bU as Xt,a3 as lt,bV as ha,bW as Jt,bX as ma,bY as fa,bZ as Qt,b_ as ya,H as ct,au as Sa,av as ba,b$ as me,c0 as mt,c1 as Ca,c2 as Zt,l as te,c3 as Je,c4 as en,R as va,b as wa,Q as Ta,d as fe,e as xa,U as tn,X as Aa,g as nn,S as an,h as on,i as rn,k as sn,W as Ea,c5 as Ia,ak as dt,al as Ra,V as ft,c6 as Fa,c7 as ka,c8 as Pa,c9 as ln,I as $a,ca as Ba,cb as Oa,cc as yt,cd as Da,ce as cn,cf as Va,ae as La,cg as St,ch as Ma,ci as _a,cj as ja,ck as Na,cl as za,cm as Wa,M as Ha,cn as qa,co as Ua,cp as Ga,cq as Ya,cr as Ka,cs as Xa}from"./index-7786a63b.js";import{C as Me,f as Ja,u as Qa,U as Za,E as eo,V as to,a as no,F as ao,b as oo,c as ro}from"./FeatureArchiveDialog-70fce2b5.js";import{S as so}from"./StrategyItemContainer-4528608d.js";import{E as io}from"./ExpandMore-6061c1d6.js";import{v as Ne}from"./v4-a960c1f4.js";function lo(e){return vn("MuiCardContent",e)}wn("MuiCardContent",["root"]);const co=["className","component"],uo=e=>{const{classes:n}=e;return En({root:["root"]},lo,n)},po=d("div",{name:"MuiCardContent",slot:"Root",overridesResolver:(e,n)=>n.root})(()=>({padding:16,"&:last-child":{paddingBottom:24}})),go=m.forwardRef(function(n,a){const r=Tn({props:n,name:"MuiCardContent"}),{className:o,component:s="div"}=r,i=xn(r,co),c=pt({},r,{component:s}),u=uo(c);return t(po,pt({as:s,className:An(u.root,o),ownerState:c,ref:a},i))}),ho=go,mo=$e(t("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"),fo=$e(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"),yo=$e(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"),So=$e(t("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"),bo=d("div")(({theme:e})=>({borderRadius:e.spacing(1.5),backgroundColor:e.palette.background.paper,padding:e.spacing(4)})),Co=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n);return a.name?t(bo,{children:t(In,{title:"Event log",feature:n,displayInline:!0})}):null},vo=d("div")(({theme:e})=>({borderRadius:e.shape.borderRadiusLarge,color:e.palette.primary.contrastText,backgroundColor:e.palette.background.sidebar,display:"flex",flexDirection:"column",maxWidth:"350px",minWidth:"350px",marginRight:e.spacing(2),[e.breakpoints.down(1e3)]:{width:"100%",maxWidth:"none",minWidth:"auto"}})),wo=d("div")({padding:"1.5rem 1.5rem 0 1.5rem"}),To=d("div")({display:"flex",alignItems:"center"}),xo=d("h2")(({theme:e})=>({fontSize:e.fontSizes.bodySize,fontWeight:"normal",margin:0})),Ao=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})),Eo=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n),{project:r,description:o,type:s}=a,i=Fn(s);return t(vo,{children:l(wo,{children:[l(To,{"data-loading":!0,children:[t(i,{sx:c=>({marginRight:c.spacing(2),height:"40px",width:"40px",fill:c.palette.primary.contrastText})})," ",l(xo,{children:[Rn(s||"")," toggle"]})]}),l(Ao,{children:[l(bt,{"data-loading":!0,children:["Project: ",r]}),t(A,{condition:Boolean(o),show:l(bt,{"data-loading":!0,children:[t("div",{children:"Description:"}),l(Ct,{children:[t("p",{children:o}),t(K,{projectId:e,permission:ie,component:X,to:`/projects/${e}/features/${n}/settings`,tooltipProps:{title:"Edit description"},children:t(ye,{sx:c=>({color:c.palette.primary.contrastText})})})]})]}),elseShow:t("span",{"data-loading":!0,children:l(Ct,{children:["No description."," ",t(K,{projectId:e,permission:ie,component:X,to:`/projects/${e}/features/${n}/settings`,tooltipProps:{title:"Edit description"},children:t(ye,{sx:c=>({color:c.palette.primary.contrastText})})})]})})})]})]})})},vt={lastHourUsage:[],seenApplications:[]},Io=(e,n,a={})=>{const r=async()=>{const g=pe(`api/admin/client-metrics/features/${n}`),h=await fetch(g,{method:"GET"}).then(Ce("feature metrics"));return h.ok?h.json():vt},o=`${e}_${n}_metrics`,{data:s,error:i}=et(o,r,{...a}),[c,u]=m.useState(!i&&!s),p=()=>{Be(o)};return m.useEffect(()=>{u(!i&&!s)},[s,i]),{metrics:s||vt,error:i,loading:c,refetch:p,FEATURE_METRICS_CACHE_KEY:o}},Ro=e=>({yes:0,no:0,environment:e,timestamp:""}),Fo=(e,n)=>e.map(a=>n.lastHourUsage.find(o=>o.environment===a.name)||Ro(a.name)),ko=({enabled:e,className:n})=>{const a=ve(),r=e?"Environment enabled":"Environment disabled",o={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)};return t("div",{style:o,className:n,children:t(yo,{style:{fill:"#fff",width:"16px",height:"16px"},titleAccess:r})})},dn=()=>t(he,{severity:"error",children:"Removing the strategy will change which users receive access to the feature."}),Po=({onRemove:e,onClose:n,isOpen:a})=>t(le,{title:"Are you sure you want to delete this strategy?",open:a,primaryButtonText:"Remove strategy",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:t(dn,{})}),$o=d("div")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1)})),Bo=({onRemove:e,onClose:n,isOpen:a})=>l(le,{title:"Suggest changes",open:a,primaryButtonText:"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:e,onClose:n,children:[t(dn,{}),t($o,{children:t(M,{variant:"body2",color:"text.secondary",children:"Your suggestion:"})}),t(M,{fontWeight:"bold",children:"Remove strategy"})]}),Oo=({projectId:e,featureId:n,environmentId:a,strategyId:r})=>{const{deleteStrategyFromFeature:o}=we(),{setToastData:s,setToastApiError:i}=U(),c=ge(),{refetchFeature:u}=j(e,n);return async g=>{try{g.preventDefault(),await o(e,n,a,r),s({title:"Strategy deleted",type:"success"}),u(),c(_t(e,n))}catch(h){i(N(h))}}},Do=({projectId:e,featureId:n,environmentId:a,strategyId:r})=>{const{addChange:o}=nt(),{refetch:s}=Te(e),{setToastData:i,setToastApiError:c}=U();return async p=>{try{p.preventDefault(),await o(e,a,{action:"deleteStrategy",feature:n,payload:{id:r}}),i({title:"Changes added to the draft!",type:"success"}),await s()}catch(g){c(N(g))}}},Vo=({projectId:e,featureId:n,environmentId:a,strategyId:r,disabled:o,icon:s})=>{const[i,c]=m.useState(!1),{isChangeRequestConfigured:u}=ae(e),p=Oo({featureId:n,projectId:e,strategyId:r,environmentId:a}),g=Do({featureId:n,projectId:e,strategyId:r,environmentId:a});return l(O,{children:[t(A,{condition:Boolean(s),show:t(K,{onClick:()=>c(!0),projectId:e,environmentId:a,disabled:o,permission:gt,"data-testid":ht,tooltipProps:{title:"Remove strategy"},type:"button",children:t(tt,{})}),elseShow:t(oe,{onClick:()=>c(!0),projectId:e,environmentId:a,disabled:o,permission:gt,"data-testid":ht,color:"secondary",variant:"text",type:"button",children:"Remove strategy"})}),t(A,{condition:u(a),show:t(Bo,{isOpen:i,onClose:()=>c(!1),onRemove:async h=>{await g(h),c(!1)}}),elseShow:t(Po,{isOpen:i,onClose:()=>c(!1),onRemove:p})})]})},Lo=e=>(n,a,r)=>(r.revalidateOnFocus=!1,r.revalidateIfStale=!1,r.revalidateOnReconnect=!1,e(n,a,r));var Mo=kn(et,Lo);const un=(e,n)=>{const{refetchFeature:a}=j(e,n),r=Pn(e,n),{data:o,error:s,mutate:i}=Mo(["useFeatureImmutable",r],()=>$n(r)),c=m.useCallback(async()=>{await i(),await a()},[i,a]);return{feature:(o==null?void 0:o.body)||Bn,refetchFeature:c,loading:!s&&!o,status:o==null?void 0:o.status,error:s}},ut=(e,n,a)=>{const{setToastData:r,setToastApiError:o}=U(),{addChange:s}=nt(),{refetch:i}=Te(e),[c,u]=m.useState({isOpen:!1}),p=m.useCallback((v,T,f)=>{u({featureName:n,environment:v,fromEnvironment:f,strategy:T,isOpen:!0})},[]),g=m.useCallback((v,T,f)=>{u({featureName:n,environment:v,fromEnvironment:f,strategies:T,isOpen:!0})},[]),h=m.useCallback(()=>{u({isOpen:!1})},[]),b=m.useCallback(async()=>{try{await s(e,c.environment,{feature:c.featureName,action:a,payload:c.strategy}),i(),u({isOpen:!1}),r({type:"success",title:"Changes added to the draft!"})}catch(v){o(N(v)),u({isOpen:!1})}},[s]),S=m.useCallback(async()=>{try{await Promise.all(c.strategies.map(v=>s(e,c.environment,{feature:c.featureName,action:a,payload:v}))),i(),u({isOpen:!1}),r({type:"success",title:"Changes added to the draft!"})}catch(v){o(N(v)),u({isOpen:!1})}},[s]);return{onChangeRequestAddStrategy:p,onChangeRequestAddStrategies:g,onChangeRequestAddStrategyClose:h,onChangeRequestAddStrategyConfirm:b,onChangeRequestAddStrategiesConfirm:S,changeRequestDialogDetails:c}},_o=({payload:e,fromEnvironment:n,environment:a})=>l(M,{children:[l("strong",{children:["Copy ",xe((e==null?void 0:e.name)||"")," strategy"," "]})," ","from ",n," to ",a]}),jo=({environmentId:e,environments:n,strategy:a})=>{const r=F("projectId"),o=F("featureId"),[s,i]=m.useState(null),c=Boolean(s),{addStrategyToFeature:u}=we(),{setToastData:p,setToastApiError:g}=U(),{refetchFeature:h}=j(r,o),{refetchFeature:b}=un(r,o),S=()=>{i(null)},v=On(r),{isChangeRequestConfigured:T}=ae(r),{changeRequestDialogDetails:f,onChangeRequestAddStrategyClose:y,onChangeRequestAddStrategy:w,onChangeRequestAddStrategyConfirm:x}=ut(r,o,"addStrategy"),P=async $=>{const{id:B,...I}={...a,targetEnvironment:$};if(T($)){await w($,{id:B,...I},e);return}try{await u(r,o,$,a),h(),b(),p({title:"Strategy created",text:`Successfully copied a strategy to ${$}`,type:"success"})}catch(_){g(N(_))}S()},D=n.some($=>v(ce,$));return l("div",{children:[t(Me,{isOpen:f.isOpen,onClose:y,environment:f==null?void 0:f.environment,onConfirm:x,messageComponent:t(_o,{fromEnvironment:f.fromEnvironment,payload:f.strategy})}),t(Z,{title:`Copy to another environment${D?"":" (Access denied)"}`,children:t("div",{children:t(Oe,{size:"large",id:`copy-strategy-icon-menu-${a.id}`,"aria-controls":c?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":c?"true":void 0,onClick:$=>{i($.currentTarget)},"data-testid":Dn,disabled:!D,children:t(Vn,{})})})}),t(De,{id:"basic-menu",anchorEl:s,open:c,onClose:S,MenuListProps:{"aria-labelledby":`copy-strategy-icon-menu-${a.id}`},children:n.map($=>{const B=v(ce,$);return t(Z,{title:B?"":"You don't have access to add a strategy to this environment",children:t("div",{children:l(Ve,{onClick:()=>P($),disabled:!B,children:[t(A,{condition:!B,show:t(jt,{children:t(Nt,{fontSize:"small"})})}),l(at,{children:["Copy to ",$]})]})})},$)})})]})},No=({environmentId:e,strategy:n,onDragStart:a,onDragEnd:r,otherEnvironments:o,orderNumber:s,headerChildren:i})=>{const c=F("projectId"),u=F("featureId"),p=Ln(c,u,e,n.id);return t(so,{strategy:n,onDragStart:a,onDragEnd:r,orderNumber:s,actions:l(O,{children:[i,t(A,{condition:Boolean(o&&(o==null?void 0:o.length)>0),show:()=>t(jo,{environmentId:e,environments:o,strategy:n})}),t(K,{permission:Mn,environmentId:e,projectId:c,component:X,to:p,tooltipProps:{title:"Edit strategy"},children:t(ye,{})}),t(Vo,{projectId:c,featureId:u,environmentId:e,strategyId:n.id,icon:!0})]}),children:t(_n,{strategy:n})})},zo=(e,n,a,r)=>{const{data:o}=Te(e),s=o==null?void 0:o.find(u=>u.environment===a),i=s==null?void 0:s.features.find(u=>u.name===n);return i==null?void 0:i.changes.find(u=>u.action==="updateStrategy"||u.action==="deleteStrategy"?u.payload.id===r:!1)},Wo=({strategy:e,index:n,environmentName:a,otherEnvironments:r,isDragging:o,onDragStartRef:s,onDragOver:i,onDragEnd:c})=>{const u=F("projectId"),p=F("featureId"),g=m.useRef(null),h=zo(u,p,a,e.id);return l(q,{ref:g,onDragOver:i(g,n),sx:{opacity:o?"0.5":"1"},children:[t(A,{condition:n>0,show:t(jn,{text:"OR"})}),t(No,{strategy:e,environmentId:a,otherEnvironments:r,onDragStart:s(g,n),onDragEnd:c,orderNumber:n+1,headerChildren:t(Ho,{change:h})})]},e.id)},Ho=({change:e})=>{const n=ve();return de(n.breakpoints.down("sm"))?null:l(q,{sx:{mr:1.5},children:[t(A,{condition:(e==null?void 0:e.action)==="updateStrategy",show:t(Se,{color:"warning",children:"Modified in draft"})}),t(A,{condition:(e==null?void 0:e.action)==="deleteStrategy",show:t(Se,{color:"error",children:"Deleted in draft"})})]})},qo=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}})),Uo=d("span")(({theme:e})=>({fontSize:e.fontSizes.bodySize,textAlign:"center",padding:"0 1rem",background:e.palette.background.elevation2,position:"relative",maxWidth:"80%",color:e.palette.text.primary})),pn=({children:e})=>t(qo,{children:t(Uo,{children:e})}),Go=({environmentId:e,environments:n,onClick:a})=>{const r=F("projectId"),[o,s]=m.useState(null),i=Boolean(o),{hasAccess:c}=m.useContext(ot),u=n.some(p=>c(ce,r,p));return l("div",{children:[t(Z,{title:u?"":"(Access denied)",children:t("div",{children:t(re,{id:`copy-all-strategies-${e}`,"aria-controls":i?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":i?"true":void 0,onClick:p=>{s(p.currentTarget)},disabled:!u,variant:"outlined",children:"Copy from another environment"})})}),t(De,{id:"basic-menu",anchorEl:o,open:i,onClose:()=>{s(null)},MenuListProps:{"aria-labelledby":`copy-all-strategies-${e}`},children:n.map(p=>{const g=c(ce,r,p);return t(Z,{title:g?"":"You don't have access to add a strategy to this environment",children:t("div",{children:l(Ve,{onClick:()=>a(p),disabled:!g,children:[t(A,{condition:!g,show:t(jt,{children:t(Nt,{fontSize:"small"})})}),l(at,{children:["Copy from ",p]})]})})},p)})})]})},Yo=d("div")(({theme:e})=>({"&>*:nth-child(n)":{margin:e.spacing(1,0)}})),Ko=({payload:e,fromEnvironment:n,environment:a})=>l(Yo,{children:[t(M,{children:t("strong",{children:"Copy: "})}),e==null?void 0:e.map(r=>l(M,{children:[l("strong",{children:[xe((r==null?void 0:r.name)||"")," strategy"," "]})," "]})),l(M,{children:["from ",n," to ",a]})]}),Xo=({payload:e,environment:n})=>l(O,{children:[t(M,{component:"span",children:"Add "}),l("strong",{children:[xe((e==null?void 0:e.name)||"")," strategy"]})," to ",t("strong",{children:n})]}),Jo=d(Nn)(({theme:e})=>({display:"flex",flexDirection:"column",borderRadius:e.shape.borderRadiusMedium})),wt=({title:e,children:n,featureId:a,projectId:r,environmentId:o,strategy:s,Icon:i,onAfterAddStrategy:c})=>{const{addStrategyToFeature:u}=we(),{setToastApiError:p}=U(),{isChangeRequestConfigured:g}=ae(r),{changeRequestDialogDetails:h,onChangeRequestAddStrategy:b,onChangeRequestAddStrategyConfirm:S,onChangeRequestAddStrategyClose:v}=ut(r,a,"addStrategy");return l(O,{children:[t(Jo,{variant:"outlined",children:l(ho,{sx:{display:"flex",flexDirection:"column",flexGrow:1},children:[l(M,{variant:"body1",fontWeight:"medium",sx:{mb:.5,display:"flex",alignItems:"center"},children:[t(i,{color:"disabled",sx:{mr:1}})," ",e]}),t(M,{variant:"body2",color:"text.secondary",component:"p",children:n}),t(q,{sx:{ml:"auto",mt:"auto",pt:1,mr:{xs:"auto",sm:0}},children:t(oe,{permission:ce,projectId:r,environmentId:o,variant:"outlined",size:"small",onClick:async()=>{try{g(o)?b(o,s):(await u(r,a,o,s),c())}catch(f){p(N(f))}},children:"Use template"})})]})}),t(Me,{isOpen:h.isOpen,onClose:v,environment:h==null?void 0:h.environment,onConfirm:S,messageComponent:t(Xo,{environment:o,payload:h.strategy})})]})},Qo=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}})),Zo=d("div")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),er=d(rt)(({theme:e})=>({fontWeight:e.fontWeight.bold})),tr=d(X)(({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}})),nr=({projectId:e,featureId:n,environmentId:a,strategy:r})=>{const o=Re(r.name),s=xe(r.name),i=Ja(e,n,a,r.name);return l(tr,{to:i,children:[t(Qo,{children:t(o,{})}),l("div",{children:[t(er,{text:r.displayName||s,maxWidth:"200",maxLength:25}),t(Zo,{children:r.description})]})]})},ar=({projectId:e,featureId:n,environmentId:a})=>{const{strategies:r}=zn(),o=m.useMemo(()=>r.filter(s=>!s.deprecated),[r]);return t(st,{dense:!0,children:o.map(s=>t(Fe,{children:t(nr,{projectId:e,featureId:n,environmentId:a,strategy:s})},s.name))})},Qe=({label:e,projectId:n,featureId:a,environmentId:r,variant:o,matchWidth:s})=>{const[i,c]=m.useState(),u=Boolean(i),p=u?"FeatureStrategyMenuPopover":void 0,g=()=>{c(void 0)};return l("div",{onClick:b=>b.stopPropagation(),children:[t(oe,{permission:ce,projectId:n,environmentId:r,onClick:b=>{c(b.currentTarget)},"aria-labelledby":p,variant:o,sx:{minWidth:s?"282px":"auto"},children:e}),t(Wn,{id:p,open:u,anchorEl:i,onClose:g,onClick:g,children:t(ar,{projectId:n,featureId:a,environmentId:r})})]})},or=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingTop:e.spacing(2)})),rr=d("div")(({theme:e})=>({fontSize:e.fontSizes.bodySize,textAlign:"center",color:e.palette.text.primary,marginBottom:e.spacing(1)})),sr=d("p")(({theme:e})=>({color:e.palette.text.secondary,fontSize:e.fontSizes.smallBody,textAlign:"center",marginBottom:e.spacing(3)})),ir=({projectId:e,featureId:n,environmentId:a})=>{const{addStrategyToFeature:r}=we(),{setToastData:o,setToastApiError:s}=U(),{refetchFeature:i}=j(e,n),{refetchFeature:c}=un(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:g}=ae(e),{changeRequestDialogDetails:h,onChangeRequestAddStrategies:b,onChangeRequestAddStrategiesConfirm:S,onChangeRequestAddStrategyClose:v}=ut(e,n,"addStrategy"),T=(w=!1)=>{i(),c(),o({title:w?"Strategies created":"Strategy created",text:w?"Successfully copied from another environment":"Successfully created strategy",type:"success"})},f=async w=>{var P;const x=((P=p==null?void 0:p.find(D=>D.name===w))==null?void 0:P.strategies)||[];if(g(a)){await b(a,x,w);return}try{await Promise.all(x.map(D=>{const{id:$,...B}={...D,environment:a};return r(e,n,a,B)})),T(!0)}catch(D){s(N(D))}},y=p&&p.length>0;return l(O,{children:[t(Me,{isOpen:h.isOpen,onClose:v,environment:h==null?void 0:h.environment,onConfirm:S,messageComponent:t(Ko,{fromEnvironment:h.fromEnvironment,payload:h.strategies})}),l(or,{children:[t(rr,{children:"You have not defined any strategies yet."}),l(sr,{children:["Strategies added in this environment will only be executed if the SDK is using an"," ",t(X,{to:"/admin/api",children:"API key configured"})," for this environment."]}),l(q,{sx:{w:"100%",display:"flex",flexWrap:"wrap",gap:2,alignItems:"center",justifyContent:"center"},children:[t(Qe,{label:"Add your first strategy",projectId:e,featureId:n,environmentId:a,matchWidth:y}),t(A,{condition:y,show:t(Go,{environmentId:a,environments:p.map(w=>w.name),onClick:f})})]}),t(q,{sx:{width:"100%",mt:3},children:t(pn,{children:"Or use a strategy template"})}),l(q,{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:T,Icon:Re("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:T,Icon:Re("flexibleRollout"),strategy:{name:"flexibleRollout",parameters:{rollout:"50",stickiness:"default",groupId:u.name},constraints:[]},children:"Roll out to a percentage of your userbase."})]})]})]})},lr=d("div")(({theme:e})=>({width:"100%",position:"relative",paddingBottom:e.spacing(2)})),cr=d("div")(({theme:e})=>({[e.breakpoints.down(400)]:{padding:e.spacing(1)}})),dr=({featureEnvironment:e,isDisabled:n,otherEnvironments:a})=>{const r=F("projectId"),o=F("featureId"),{setStrategiesSortOrder:s}=we(),{setToastData:i,setToastApiError:c}=U(),{refetchFeature:u}=j(r,o),[p,g]=m.useState((e==null?void 0:e.strategies)||[]),[h,b]=m.useState(null);if(m.useEffect(()=>{g((e==null?void 0:e.strategies)||[])},[e==null?void 0:e.strategies]),!e)return null;const S=async y=>{try{await s(r,o,e.name,y),u(),i({title:"Order of strategies updated",type:"success"})}catch(w){c(N(w))}},v=(y,w)=>x=>{var P;b({id:p[w].id,index:w,height:((P=y.current)==null?void 0:P.offsetHeight)||0}),y!=null&&y.current&&(x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("text/html",y.current.outerHTML),x.dataTransfer.setDragImage(y.current,20,20))},T=y=>(w,x)=>P=>{if(h===null||w.current===null||h.index===x||y===h.id)return;const{top:D,bottom:$}=w.current.getBoundingClientRect(),B=P.clientY-D<h.height,I=$-P.clientY<h.height,_=h.index>x;if(B&&_||I&&!_){const W=[...p],L=W.splice(h.index,1)[0];W.splice(x,0,L),g(W),b({...h,index:x})}},f=()=>{b(null),S(p.map((y,w)=>({id:y.id,sortOrder:w})))};return t(lr,{children:l(cr,{children:[t(A,{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(A,{condition:p.length>0,show:t(O,{children:p.map((y,w)=>t(Wo,{strategy:y,index:w,environmentName:e.name,otherEnvironments:a,isDragging:(h==null?void 0:h.id)===y.id,onDragStartRef:v,onDragOver:T(y.id),onDragEnd:f},y.id))}),elseShow:t(ir,{projectId:r,featureId:o,environmentId:e.name})})]})})},gn=(e,n)=>e===0?0:Math.round(n/e*100);var _e={},je={};Object.defineProperty(je,"__esModule",{value:!0});je.defaultOptions=void 0;je.defaultOptions={decimalSeparator:".",lowercase:!1,precision:1,space:!1,units:["","K","M","B","T","P","E"]};var ue={};Object.defineProperty(ue,"__esModule",{value:!0});ue.roundTo=ue.parseValue=void 0;function ur(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}ue.parseValue=ur;function pr(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))}ue.roundTo=pr;Object.defineProperty(_e,"__esModule",{value:!0});_e.millify=void 0;const ze=je,Tt=ue,xt=1e3;function*At(e){let n=xt;for(;;){const a=e/n;if(a<1)return;yield a,n*=xt}}function hn(e,n){var a;const r=n?Object.assign(Object.assign({},ze.defaultOptions),n):ze.defaultOptions;if(!Array.isArray(r.units)||!r.units.length)throw new Error("Option `units` must be a non-empty array");let o;try{o=Tt.parseValue(e)}catch(S){return S instanceof Error&&console.warn(`WARN: ${S.message} (millify)`),String(e)}const s=o<0?"-":"";o=Math.abs(o);let i=0;for(const S of At(o))o=S,i+=1;if(i>=r.units.length)return e.toString();let u=Tt.roundTo(o,r.precision);for(const S of At(u))u=S,i+=1;const p=(a=r.units[i])!==null&&a!==void 0?a:"",g=r.lowercase?p.toLowerCase():p,h=r.space?" ":"",b=u.toString().replace(ze.defaultOptions.decimalSeparator,r.decimalSeparator);return`${s}${b}${h}${g}`}_e.millify=hn;var gr=_e.default=hn;const Pe=({value:e,threshold:n=1e6,precision:a=2})=>{let r,o=!1;e<n?r=e.toLocaleString():(r=gr(e,{precision:a}),o=!0);const s=t("span",{"data-testid":Hn,children:r});return t(A,{condition:o,show:t(Z,{title:e.toLocaleString(),arrow:!0,children:s}),elseShow:s})},We=d("article")(({theme:e})=>({padding:e.spacing(2),background:"transparent",borderRadius:e.spacing(2),textAlign:"center",[e.breakpoints.up("md")]:{padding:e.spacing(4)}})),He=d("h3")(({theme:e})=>({margin:0,fontSize:e.fontSizes.bodySize,fontWeight:e.fontWeight.thin})),qe=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})),mn=({totalYes:e,totalNo:n,hoursBack:a,statsSectionId:r,tableSectionId:o})=>{const s=a===1?"in the last hour":`in the last ${a} hours`;return l(ee,{container:!0,spacing:2,id:r,"aria-describedby":o,"aria-label":"Feature metrics summary",component:"section",children:[t(ee,{item:!0,xs:12,sm:4,children:l(We,{children:[t(He,{children:"Exposure"}),t(qe,{children:t(Pe,{value:e})}),l(Ue,{children:["Total exposure of the feature in the environment"," ",s,"."]})]})}),t(ee,{item:!0,xs:12,sm:4,children:l(We,{children:[t(He,{children:"Exposure %"}),l(qe,{children:[gn(e+n,e),"%"]}),l(Ue,{children:["% total exposure of the feature in the environment"," ",s,"."]})]})}),t(ee,{item:!0,xs:12,sm:4,children:l(We,{children:[t(He,{children:"Requests"}),t(qe,{children:t(Pe,{value:e+n})}),l(Ue,{children:["Total requests for the feature in the environment"," ",s,"."]})]})})]})},hr=({environmentMetric:e})=>e?l(O,{children:[t(pn,{children:"Feature toggle exposure"}),t("div",{children:t(mn,{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"}})),mr=d(qn)(({theme:e})=>({fill:e.palette.background.application,height:"75px",width:"75px",[e.breakpoints.down(500)]:{display:"none"}})),fr=d("div")(({theme:e})=>({margin:e.spacing(0,2),[e.breakpoints.down(500)]:{display:"none"}})),yr=({environmentMetric:e,disabled:n=!1})=>{const a=Un();if(!e)return null;const r=e.yes+e.no,o=gn(r,e==null?void 0:e.yes);return!e||e.yes===0&&e.no===0?l(Et,{children:[l(It,{children:[l(Rt,{style:{color:n?a.palette.text.secondary:void 0},"data-loading":!0,children:[o,"%"]}),l(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(mr,{style:{transform:"scale(1.1)"},"data-loading":!0})]}):l(Et,{children:[l(It,{children:[l(Rt,{children:[o,"%"]}),l(Ft,{children:["The feature has been requested"," ",l("b",{children:[t(Pe,{value:r})," times"]})," ","and exposed"," ",l("b",{children:[t(Pe,{value:e.yes})," ","times"]})," ","in the last hour"]})]}),t(fr,{"data-loading":!0,children:t(Gn,{percentage:o,size:"3rem"})})]})},Sr=({strategyName:e})=>{const n=Re(e);return t(Z,{title:xe(e),arrow:!0,children:t(br,{children:t(n,{})})})},br=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)}})),Cr=({strategies:e})=>e!=null&&e.length?t(vr,{"aria-label":"Feature strategies",children:e.map(n=>t(wr,{children:t(Sr,{strategyName:n.name})},n.id))}):null,vr=d("ul")(()=>({all:"unset",display:"flex",alignItems:"center",alignContent:"center"})),wr=d("li")(()=>({all:"unset",minWidth:30,textAlign:"center"})),Tr=d("div",{shouldForwardProp:e=>e!=="enabled"})(({theme:e,enabled:n})=>({borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2),backgroundColor:e.palette.background.paper,background:n?e.palette.background.paper:e.palette.neutral.light})),xr=d(Yn)({boxShadow:"none",background:"none"}),Ar=d(Kn)(({theme:e})=>({boxShadow:"none",padding:e.spacing(2,4),[e.breakpoints.down(400)]:{padding:e.spacing(1,2)}})),Er=d(Xn,{shouldForwardProp:e=>e!=="enabled"})(({theme:e,enabled:n})=>({padding:e.spacing(3),background:e.palette.background.elevation2,borderBottomLeftRadius:e.shape.borderRadiusLarge,borderBottomRightRadius:e.shape.borderRadiusLarge,borderBottom:`4px solid ${n?e.palette.primary.light:e.palette.neutral.border}`,[e.breakpoints.down("md")]:{padding:e.spacing(2,1)}})),Ir=d(dr)(({theme:e})=>({width:"100%",position:"relative",paddingBottom:e.spacing(2)})),Rr=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})),Fr=d("div")(({theme:e})=>({display:"flex",alignItems:"center",[e.breakpoints.down(560)]:{flexDirection:"column",textAlign:"center"}})),kr=d(ko)(({theme:e})=>({[e.breakpoints.down(560)]:{marginBottom:"0.5rem"}})),Pr=d(rt)(({theme:e})=>({fontSize:e.fontSizes.bodySize,fontWeight:e.typography.fontWeightMedium,[e.breakpoints.down(560)]:{textAlign:"center"}})),$r=d("div")(({theme:e})=>({display:"flex",alignItems:"center",marginLeft:"1.8rem",[e.breakpoints.down(560)]:{flexDirection:"column",marginLeft:"0"}})),Br=({env:e})=>{var p;const n=F("projectId"),a=F("featureId"),{metrics:r}=Io(n,a),{feature:o}=j(n,a),{value:s}=zt(),c=Fo(o==null?void 0:o.environments,r).find(g=>g.environment===e.name),u=o==null?void 0:o.environments.find(g=>g.name===e.name);return t(A,{condition:!Boolean(new Set(s.hiddenEnvironments).has(e.name)),show:t(Tr,{enabled:e.enabled,children:l(xr,{"data-testid":`${Jn}_${e.name}`,children:[l(Ar,{expandIcon:t(io,{titleAccess:"Toggle"}),children:[l(Rr,{"data-loading":!0,enabled:e.enabled,children:[l(Fr,{children:[t(kr,{enabled:e.enabled}),t("div",{children:t(Pr,{text:e.name,maxWidth:"100",maxLength:15})}),t(A,{condition:!e.enabled,show:t(Se,{color:"neutral",sx:{ml:1},children:"Disabled"})})]}),l($r,{children:[t(Qe,{label:"Add strategy",projectId:n,featureId:a,environmentId:e.name,variant:"text"}),t(Cr,{strategies:u==null?void 0:u.strategies})]})]}),t(yr,{environmentMetric:c,disabled:!e.enabled})]}),l(Er,{enabled:e.enabled,children:[t(Ir,{featureEnvironment:u,isDisabled:!e.enabled,otherEnvironments:o==null?void 0:o.environments.map(({name:g})=>g).filter(g=>g!==e.name)}),t(A,{condition:(((p=u==null?void 0:u.strategies)==null?void 0:p.length)||0)>0,show:l(O,{children:[t(q,{sx:{display:"flex",justifyContent:"center",py:1},children:t(Qe,{label:"Add strategy",projectId:n,featureId:a,environmentId:e.name})}),t(hr,{environmentMetric:c})]})})]})]})})})},Or=()=>{const e=F("projectId"),n=F("featureId"),{feature:a}=j(e,n);if(!a)return null;const{environments:r}=a;return t(O,{children:r==null?void 0:r.map(o=>t(Br,{env:o},o.name))})},Dr=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(3),fontSize:e.fontSizes.smallBody})),Vr=d("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)})),Lr=({feature:e,header:n})=>{const{locationSettings:a}=Qn();return l(Dr,{children:[n,l("div",{"data-loading":!0,children:[t(Vr,{children:"Created at:"}),t("span",{children:Zn(ea(e.createdAt),a.locale)})]})]})},Mr=d(Oe,{shouldForwardProp:e=>e!=="visibilityOff"})(({theme:e,visibilityOff:n})=>({marginLeft:"auto",marginRight:e.spacing(-1),color:n?e.palette.neutral.main:e.palette.divider,"&:hover":{color:e.palette.neutral.main}})),_r=({environment:e,hiddenEnvironments:n,setHiddenEnvironments:a})=>t(Mr,{onClick:()=>{a(e.name)},visibilityOff:n.has(e.name),children:t(A,{condition:n.has(e.name),show:t(ta,{}),elseShow:t(na,{})})}),jr=d("div")(({theme:e})=>({marginLeft:e.spacing(-1.5),"&:not(:last-of-type)":{marginBottom:e.spacing(2)},display:"flex",alignItems:"center"})),Nr=d("label")(()=>({display:"inline-flex",alignItems:"center",cursor:"pointer"})),zr=({environment:e,callback:n,showInfoBox:a,children:r,hiddenEnvironments:o,setHiddenEnvironments:s})=>{const{name:i,enabled:c}=e,u=F("projectId"),p=F("featureId"),{toggleFeatureEnvironmentOn:g,toggleFeatureEnvironmentOff:h}=Ae(),{refetchFeature:b}=j(u,p),{setToastData:S,setToastApiError:v}=U(),{isChangeRequestConfigured:T}=ae(u),{onChangeRequestToggle:f,onChangeRequestToggleClose:y,onChangeRequestToggleConfirm:w,changeRequestDialogDetails:x}=Qa(u),P=async()=>{try{await g(u,p,i),S({type:"success",title:`Available in ${i}`,text:`${p} is now available in ${i} based on its defined strategies.`}),b(),n&&n()}catch(I){I instanceof Error&&I.message===eo?a():v(N(I))}},D=async()=>{try{await h(u,p,i),S({type:"success",title:`Unavailable in ${i}`,text:`${p} is unavailable in ${i} and its strategies will no longer have any effect.`}),b(),n&&n()}catch(I){v(N(I))}},$=async I=>{if(T(i)){I.preventDefault(),f(p,i,!c);return}if(c){await D();return}await P()},B=l(O,{children:[" ",l("span",{"data-loading":!0,children:[c?"enabled":"disabled"," in"]})," ",t(rt,{text:i,maxWidth:"120",maxLength:15})]});return l(jr,{children:[l(Nr,{children:[t(aa,{tooltip:c?`Disable feature in ${i}`:`Enable feature in ${i}`,permission:oa,projectId:u,checked:c,onChange:$,environmentId:i}),r??B]}),t(_r,{environment:e,hiddenEnvironments:o,setHiddenEnvironments:s}),t(Me,{isOpen:x.isOpen,onClose:y,environment:x==null?void 0:x.environment,onConfirm:w,messageComponent:t(Za,{enabled:x==null?void 0:x.enabled,featureName:x==null?void 0:x.featureName,environment:x.environment})})]})},Wr=d("div")(({theme:e})=>({padding:e.spacing(3)})),Hr=d("div")(()=>({display:"flex",flexDirection:"column"})),qr=d("p")(({theme:e})=>({fontSize:e.fontSizes.bodySize})),Ur=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:'"-"'}})),Gr=d(ra)(()=>({"&:hover, &:focus":{textDecoration:"underline"}})),Yr=({feature:e,header:n,hiddenEnvironments:a,setHiddenEnvironments:r})=>{const[o,s]=m.useState(!1),[i,c]=m.useState(""),u=e.environments.some(p=>{var g;return p.enabled&&((g=p.variants)==null?void 0:g.length)});return l(Wr,{"data-testid":"feature-toggle-status",children:[n,e.environments.map(p=>{const g=p.strategies.length===1?"1 strategy":`${p.strategies.length} strategies`,h=p.variants??[],b=h.length>0&&l(O,{children:[t(kt,{}),t(Z,{title:"View variants",arrow:!0,describeChild:!0,children:t(Gr,{component:X,to:`/projects/${e.project}/features/${e.name}/variants`,underline:"hover",children:h.length===1?"1 variant":`${h.length} variants`})})]}),S=p.enabled&&h.length===0&&u;return t(zr,{environment:p,hiddenEnvironments:a,setHiddenEnvironments:r,showInfoBox:()=>{c(p.name),s(!0)},children:l(Hr,{children:[t(qr,{children:p.name}),l(Ur,{children:[g,b,t(A,{condition:S,show:l(O,{children:[t(kt,{}),t(to,{})]})})]})]})},p.name)}),t(no,{open:o,onClose:()=>s(!1),projectId:e.project,featureId:e.name,environmentName:i})]})},fn=(e,n={})=>{const a=async()=>{const p=pe(`api/admin/features/${e}/tags`);return(await fetch(p,{method:"GET"}).then(Ce("Tags"))).json()},r=`api/admin/features/${e}/tags`,{data:o,error:s}=Wt(Boolean(e),{tags:[]},r,a,n),[i,c]=m.useState(!s&&!o),u=()=>{Be(r)};return m.useEffect(()=>{c(!s&&!o)},[o,s]),{tags:(o==null?void 0:o.tags)||[],error:s,loading:i,refetch:u}},Kr=sa(),Xr=({options:e,featureTags:n,tagType:a,onChange:r})=>{const o=t(ia,{fontSize:"small"}),s=t(la,{fontSize:"small"});return t(it,{multiple:!0,id:"checkboxes-tags-demo",sx:{marginTop:g=>g.spacing(2),width:500},disableCloseOnSelect:!0,placeholder:"Select Values",options:e,isOptionEqualToValue:(g,h)=>h.inputValue&&h.inputValue!==""?g.title===h.inputValue:g.title===h.title,getOptionDisabled:g=>n.some(h=>h.type===a&&h.value===g.title),getOptionLabel:g=>g.inputValue?g.inputValue:g.title,renderOption:(g,h,{selected:b})=>{const S=n.some(v=>v.type===a&&v.value===h.title);return l("li",{...g,children:[t(A,{condition:Boolean(h.inputValue),show:t(Ht,{sx:{mr:v=>v.spacing(.5)}}),elseShow:t(qt,{icon:o,checkedIcon:s,sx:{mr:v=>v.spacing(.5)},checked:b||S})}),h.title]})},filterOptions:(g,h)=>{const b=Kr(g,h),{inputValue:S}=h,v=g.some(T=>S===T.title);return S!==""&&!v&&b.push({inputValue:S,title:`Create new value "${S}"`}),b},ListboxProps:{style:{maxHeight:200,overflow:"auto"}},onChange:r,renderInput:g=>t(Le,{...g,label:"Select values",placeholder:"Select values"})})},Jr=d("li")({flexDirection:"column"}),Qr=({value:e,onChange:n})=>{const{tagTypes:a}=ca(),r=ve();return t(it,{disablePortal:!0,id:"tag-type-select",sx:{marginTop:o=>o.spacing(2),width:500},options:a,disableClearable:!0,value:e,getOptionLabel:o=>o.name,renderOption:(o,s)=>l(Jr,{...o,style:{alignItems:"flex-start",gap:r.spacing(.5)},children:[t(M,{variant:"body1",children:s.name}),t(M,{variant:"caption",children:s.description})]}),renderInput:o=>t(Le,{...o,label:"Tag type",value:e}),onChange:n,ListboxProps:{style:{maxHeight:200,overflow:"auto"}}})},Zr=()=>{const{makeRequest:e,createRequest:n,errors:a,loading:r}=da({propagateErrors:!0});return{createTag:async s=>{const c=n("api/admin/tags",{method:"POST",body:JSON.stringify(s)});try{return await e(c.caller,c.id)}catch(u){throw u}},errors:a,loading:r}},es=(e,n={})=>{const a=async()=>{const p=pe(`api/admin/tags/${e}`);return(await fetch(p,{method:"GET"}).then(Ce("Tags"))).json()},r=`api/admin/tags/${e}`,{data:o,error:s}=Wt(Boolean(e),{tags:[]},r,a,n),[i,c]=m.useState(!s&&!o),u=()=>{Be(r)};return m.useEffect(()=>{c(!s&&!o)},[o,s]),{tags:(o==null?void 0:o.tags)||[],error:s,loading:i,refetch:u}},ts=d("section")(({theme:e})=>({["& > *"]:{margin:e.spacing(1,0)}})),yn=({open:e,setOpen:n})=>{const a=F("featureId"),{createTag:r}=Zr(),{addTagToFeature:o,loading:s}=Ae(),{tags:i,refetch:c}=fn(a),{setToastData:u}=U(),[p,g]=m.useState({name:"simple",description:"Simple tag to get you started",icon:""}),{trackEvent:h}=Ut(),[b,S]=m.useState([]),{tags:v,refetch:T}=es(p.name),f=m.useMemo(()=>v.map(B=>({title:B.value})),[v]),y=()=>{n(!1),S([])},w=async B=>{B.preventDefault();let I=0;if(b.length!==0){for(const _ of b)if(!i.includes({type:p.name,value:_.title}))try{_.title.startsWith("Create")||(await o(a,{type:p.name,value:_.title}),I++,await c())}catch(W){const L=N(W);u({type:"error",title:"Failed to add tag",text:L,confetti:!1})}I>1&&h("suggest_tags",{props:{eventType:"multiple_tags_added"}}),I>0&&u({type:"success",title:`Added tag${I>1?"s":""} to toggle`,text:`We successfully added ${I} new tag${I>1?"s":""} to your toggle`,confetti:!0}),n(!1),S([])}},x=(B,I)=>{I!=null&&typeof I!="string"&&(B.preventDefault(),g(I))},P=(B,I,_)=>{if(_==="selectOption"){const W=ua(I);I.forEach((L,G)=>{if(typeof L!="string"&&L.inputValue&&L.inputValue!==""){const J={value:L.inputValue,type:p.name};r(J).then(()=>{h("suggest_tags",{props:{eventType:"tag_created"}}),T()}),L.title=L.inputValue,L.inputValue="",W[G]=L}}),S(W)}},D=b.length!==0,$="add-tag-form";return t(O,{children:t(le,{open:e,secondaryButtonText:"Cancel",primaryButtonText:`Add tag (${b.length})`,title:"Add tags to feature toggle",onClick:w,disabledPrimaryButton:s||!D,onClose:y,formId:$,children:l(O,{children:[t(M,{paragraph:!0,sx:{marginBottom:B=>B.spacing(2.5)},children:"Tags allow you to group features together"}),t("form",{id:$,onSubmit:w,children:l(ts,{children:[t(Qr,{autoFocus:!0,value:p,onChange:x}),t(Xr,{options:f,tagType:p.name,featureTags:i,onChange:P})]})})]})})})},ns=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(3)})),as=d("div")(({theme:e})=>({display:"flex",gap:e.spacing(1),flexWrap:"wrap"})),os=d(Gt)(({theme:e})=>({fontSize:e.fontSizes.smallBody})),rs=d(ke)(({theme:e})=>({margin:e.spacing(3),borderStyle:"dashed"})),ss=d(re)(({theme:e})=>({maxWidth:e.spacing(20),alignSelf:"center"})),is=({feature:e,header:n})=>{const{tags:a,refetch:r}=fn(e.name),{deleteTagFromFeature:o}=Ae(),[s,i]=m.useState(!1),[c,u]=m.useState(!1),[p,g]=m.useState(),{setToastData:h,setToastApiError:b}=U(),{hasAccess:S}=m.useContext(ot),v=S(ie,e.project),T=async()=>{if(p)try{await o(e.name,p.type,p.value),r(),h({type:"success",title:"Tag deleted",text:"Successfully deleted tag"})}catch(f){b(N(f))}};return l(ns,{children:[n,t(as,{children:a.map(f=>{const y=`${f.type}:${f.value}`;return t(os,{label:y,deleteIcon:t(pa,{titleAccess:"Remove"}),onDelete:v?()=>{u(!0),g(f)}:void 0},y)})}),t(A,{condition:v,show:l(O,{children:[t(A,{condition:a.length>0,show:t(rs,{})}),t(ss,{"data-loading":!0,variant:"outlined",startIcon:t(Ht,{}),onClick:()=>i(!0),children:"Add new tag"})]})}),t(yn,{open:s,setOpen:i}),l(le,{open:c,primaryButtonText:"Delete tag",secondaryButtonText:"Cancel",onClose:()=>{u(!1),g(void 0)},onClick:()=>{u(!1),T(),g(void 0)},title:"Delete tag?",children:["You are about to delete tag:"," ",l("strong",{children:[p==null?void 0:p.type,":",p==null?void 0:p.value]})]})]})},ls=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"}})),Ge=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}})),cs=({hiddenEnvironments:e,setHiddenEnvironments:n})=>{const a=F("projectId"),r=F("featureId"),{feature:o}=j(a,r);return l(ls,{children:[t(Yr,{header:l(Ge,{"data-loading":!0,children:["Enabled in environments (",o.environments.filter(({enabled:s})=>s).length,")",t(Ke,{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:o,hiddenEnvironments:e,setHiddenEnvironments:n}),t(ke,{}),t(Lr,{header:t(Ge,{"data-loading":!0,children:"Feature toggle details"}),feature:o}),t(ke,{}),t(is,{header:t(Ge,{"data-loading":!0,children:"Tags for this feature toggle"}),feature:o})]})},ds=()=>{const{trackEvent:e}=Ut(),{value:n,setValue:a}=zt(),[r,o]=m.useState(new Set(n.hiddenEnvironments));return{hiddenEnvironments:r,setHiddenEnvironments:i=>{a(c=>{const u=new Set(c.hiddenEnvironments);return u.has(i)?(u.delete(i),e("hidden_environment",{props:{eventType:"environment unhidden"}})):(u.add(i),e("hidden_environment",{props:{eventType:"environment hidden"}})),o(u),{...n,hiddenEnvironments:u}})}}},us=d("div")(({theme:e})=>({display:"flex",width:"100%",[e.breakpoints.down(1e3)]:{flexDirection:"column"}})),ps=d("div")(({theme:e})=>({display:"flex",flexDirection:"column",width:"calc(100% - (350px + 1rem))",[e.breakpoints.down(1e3)]:{width:"100%"}})),gs=()=>{const e=ge(),n=F("projectId"),a=F("featureId"),r=_t(n,a),{hiddenEnvironments:o,setHiddenEnvironments:s}=ds(),i=()=>e(r);return Yt(a),l(us,{children:[l("div",{children:[t(Eo,{}),t(cs,{hiddenEnvironments:o,setHiddenEnvironments:s})]}),t(ps,{children:t(Or,{})}),l(Kt,{children:[t(ne,{path:"strategies/create",element:t(Xe,{label:"Create feature strategy",onClose:i,open:!0,children:t(ao,{})})}),t(ne,{path:"strategies/edit",element:t(Xe,{label:"Edit feature strategy",onClose:i,open:!0,children:t(ga,{})})})]})]})},hs=({values:e=[],updateValues:n,placeholder:a="",error:r,...o})=>{const s=c=>{const p=c.target.value.split(/,\s?/).map(g=>g.trim());n(p)},i=c=>{if(c.key==="Backspace"){const u=c.target.value;if(u.endsWith(", ")){c.preventDefault();const p=u.slice(0,-2);n(p.split(/,\s*/))}}};return t(Le,{...o,error:r,placeholder:a,value:e?e.join(", "):"",onKeyDown:i,onChange:s,style:{width:"100%"},variant:"outlined",size:"small"})},ms=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"}}})),fs=d(Xt)(({theme:e})=>({minWidth:e.spacing(20),marginRight:e.spacing(10)})),ys=d("div")(({theme:e})=>({width:"100%",gap:e.spacing(1.5),display:"flex"})),Ss=d(hs)(()=>({width:"100%"})),bs=d(Le)(()=>({width:"100%"})),Cs=({overrides:e,overridesDispatch:n})=>{const{context:a}=lt(),r=a.map(({name:i})=>({key:i,label:i})),o=i=>c=>{n({type:"UPDATE_VALUES_AT",payload:[i,c]})},s=i=>(c,u)=>{c==null||c.preventDefault(),n({type:"UPDATE_VALUES_AT",payload:[i,u||[]]})};return t(O,{children:e.map((i,c)=>{var h;const u=a.find(({name:b})=>b===i.contextName),p=((h=u==null?void 0:u.legalValues)==null?void 0:h.map(({value:b})=>b))||[],g=i.values.filter(b=>p.includes(b));return l(ms,{children:[t(fs,{id:"override-context-name",name:"contextName",label:"Context Field",value:i.contextName,options:r,onChange:b=>n({type:"UPDATE_TYPE_AT",payload:[c,b.target.value]})}),l(ys,{children:[t(A,{condition:Boolean(p&&p.length>0),show:t(it,{multiple:!0,id:`override-select-${c}`,isOptionEqualToValue:(b,S)=>b===S,options:p,onChange:s(c),getOptionLabel:b=>b,value:g,style:{width:"100%"},filterSelectedOptions:!0,size:"small",renderInput:b=>t(bs,{...b,variant:"outlined",label:"Legal values"})}),elseShow:t(Ss,{label:"Values (v1, v2, ...)",name:"values",placeholder:"",values:i.values,updateValues:o(c)})}),t(Z,{title:"Remove",arrow:!0,children:t(Oe,{onClick:b=>{b.preventDefault(),n({type:"REMOVE",payload:c})},children:t(tt,{})})})]})]},`override=${c}`)})})},vs=(e,n)=>{switch(n.type){case"SET":return n.payload;case"CLEAR":return[];case"ADD":return[...e,n.payload];case"REMOVE":return e.filter((i,c)=>c!==n.payload);case"UPDATE_VALUES_AT":const[a,r]=n.payload;return e.map((i,c)=>c===a?{...i,values:r}:i);case"UPDATE_TYPE_AT":const[o,s]=n.payload;return e.map((i,c)=>c===o?{...i,contextName:s}:i)}},ws=(e=[])=>m.useReducer(vs,e);var Y=(e=>(e.FIX="fix",e.VARIABLE="variable",e))(Y||{});const Ts=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})),xs=d(Z)(({theme:e})=>({position:"absolute",top:e.spacing(2),right:e.spacing(2)})),Sn=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Pt=d(Sn)(({theme:e})=>({display:"flex",color:e.palette.text.primary,marginTop:e.spacing(1),marginBottom:e.spacing(2)})),As=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(2)})),Es=d(ha)(({theme:e})=>({marginBottom:e.spacing(1),"& > span":{fontSize:e.fontSizes.smallBody},[e.breakpoints.down("sm")]:{marginTop:e.spacing(1),marginBottom:e.spacing(1.5)}})),$t=d(Jt)(()=>({width:"100%"})),Is=d("div")(({theme:e})=>({marginLeft:e.spacing(3)})),Rs=d(Jt)(({theme:e})=>({width:e.spacing(24),[e.breakpoints.down("sm")]:{width:"100%"}})),Fs=d("div")(({theme:e})=>({marginTop:e.spacing(3),flexGrow:1})),bn=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%"}}})),ks=d(bn)({alignItems:"end",justifyContent:"space-between"}),Ps=d(Xt)(({theme:e})=>({minWidth:e.spacing(20),marginRight:e.spacing(10)})),$s=d(re)(({theme:e})=>({width:e.spacing(20),maxWidth:"100%"})),Bs=[{key:"string",label:"string"},{key:"json",label:"json"},{key:"csv",label:"csv"}],Os={type:"string",value:""},Ds=({variant:e,variants:n,updateVariant:a,removeVariant:r,apiPayload:o})=>{const[s,i]=m.useState(e.name),[c,u]=m.useState(e.weightType===Y.FIX),[p,g]=m.useState(String(e.weight/10)),[h,b]=m.useState(e.payload||Os),[S,v]=ws(e.overrides||[]),{context:T}=lt(),[f,y]=m.useState({}),w=C=>{y(E=>({...E,[C]:void 0}))},x=(C,E)=>{y(V=>({...V,[C]:E}))};m.useEffect(()=>{var C;w("percentage"),(C=o.error)!=null&&C.includes("%")&&x("percentage","Total weight must equal 100%")},[o.error]);const P=!e.new,D=n.filter(({id:C,weightType:E})=>C!==e.id&&E===Y.VARIABLE).length>0,$=C=>{const E=C.weightType===Y.VARIABLE,V=n.some(Q=>Q.weightType===Y.FIX),H=n.filter(Q=>Q.weightType===Y.VARIABLE).length===1;return V&&H&&E},B=C=>{w("name"),G(C,e.id)||x("name","A variant with that name already exists for this environment."),i(C)},I=C=>{(C===""||J(C))&&g(C)},_=C=>{R(C)||x("payload","Invalid JSON.")},W=()=>{T.length>0&&v({type:"ADD",payload:{contextName:T[0].name,values:[]}})},L=C=>Boolean(C.length),G=(C,E)=>P||!n.some(V=>V.name===C&&V.id!==E),J=C=>{if(!c)return!0;if(C===""||C.match(/\.[0-9]{2,}$/))return!1;const E=Number(C);return E>=0&&E<=100},R=C=>{try{return C.type==="json"&&JSON.parse(C.value),!0}catch{return!1}};return m.useEffect(()=>{a({...e,name:s,weight:Number(c?p:100)*10,weightType:c?Y.FIX:Y.VARIABLE,stickiness:(n==null?void 0:n.length)>0?n[0].stickiness:"default",payload:h.value?h:void 0,overrides:S.map(C=>({contextName:C.contextName,values:C.values})).filter(C=>C.values&&C.values.length>0),isValid:L(s)&&G(s,e.id)&&J(p)&&R(h)&&!o.error})},[s,c,p,h,S]),m.useEffect(()=>{c||g(String(e.weight/10))},[e.weight]),l(Ts,{children:[t(xs,{arrow:!0,title:$(e)?"You need to have at least one variable variant":"Delete variant",children:t("div",{children:t(Oe,{"data-testid":`VARIANT_DELETE_BUTTON_${e.name}`,onClick:()=>r(e.id),disabled:$(e),children:t(tt,{})})})}),l(ks,{children:[l(Fs,{children:[t(Sn,{children:"Variant name"}),t(As,{children:"This will be used to identify the variant in your code"}),t($t,{"data-testid":"VARIANT_NAME_INPUT",autoFocus:!0,label:"Variant name",error:Boolean(f.name),errorText:f.name,value:s,onChange:C=>B(C.target.value),disabled:P,required:!0})]}),t(A,{condition:D,show:l(Is,{children:[t(Es,{label:"Custom percentage",control:t(ma,{"data-testid":"VARIANT_WEIGHT_CHECK",checked:c,onChange:C=>u(C.target.checked)})}),t(Rs,{"data-testid":"VARIANT_WEIGHT_INPUT",type:"number",label:"Variant weight",error:Boolean(f.percentage),errorText:f.percentage,value:p,onChange:C=>I(C.target.value),required:c,disabled:!c,"aria-valuemin":0,"aria-valuemax":100,InputProps:{endAdornment:t(fa,{position:"end",children:"%"})}})]})})]}),l(Pt,{children:["Payload",t(Ke,{tooltip:"Passed along with the the variant object."})]}),l(bn,{children:[t(Ps,{id:"variant-payload-type",name:"type",label:"Type",value:h.type,options:Bs,onChange:C=>{w("payload"),b(E=>({...E,type:C.target.value}))}}),t($t,{id:"variant-payload-value",name:"variant-payload-value",label:"Value",multiline:h.type!=="string",rows:h.type==="string"?1:4,value:h.value,onChange:C=>{w("payload"),b(E=>({...E,value:C.target.value}))},placeholder:h.type==="json"?'{ "hello": "world" }':"",onBlur:()=>_(h),error:Boolean(f.payload),errorText:f.payload})]}),l(Pt,{children:["Overrides",t(Ke,{tooltip:"Here you can specify which users should get this variant."})]}),t(Cs,{overrides:S,overridesDispatch:v}),t($s,{onClick:W,variant:"outlined",color:"primary",children:"Add override"})]})},Vs=d("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"},marginTop:e.spacing(-1.5),marginBottom:e.spacing(4)})),Ls=d(Qt,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.neutral.border:e.palette.primary.main})),Ms=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})),_s=d("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),js=d(he)(({theme:e})=>({marginBottom:e.spacing(2)})),Ns=d(he)(({theme:e})=>({marginTop:e.spacing(4)})),zs=d("div")({display:"flex",flexDirection:"column-reverse"}),Ws=d("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),Bt=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),Hs=d(ya)(({theme:e})=>({minWidth:e.spacing(20),width:"100%"})),qs=d("div")(({theme:e})=>({marginTop:"auto",paddingTop:e.spacing(4),display:"flex",justifyContent:"flex-end"})),Us=d(re)(({theme:e})=>({marginLeft:e.spacing(3)})),Gs=({environment:e,open:n,setOpen:a,getApiPayload:r,getCrPayload:o,onConfirm:s})=>{var Q;const i=F("projectId"),c=F("featureId"),{uiConfig:u}=ct(),{context:p}=lt(),{defaultStickiness:g}=Sa(i),{isChangeRequestConfigured:h}=ae(i),{data:b}=Te(i),{changeRequestInReviewOrApproved:S,alert:v}=Ca(b),T=(e==null?void 0:e.variants)||[],[f,y]=m.useState([]);m.useEffect(()=>{y(T.length?T.map(k=>({...k,isValid:!0,new:!1,id:Ne()})):[{name:"",weightType:Y.VARIABLE,weight:0,overrides:[],stickiness:(f==null?void 0:f.length)>0?f[0].stickiness:g,new:!0,isValid:!1,id:Ne()}])},[n]);const w=(k,z)=>{y(se=>mt(se.map(Ee=>Ee.id===z?k:Ee),1e3))},x=f.map(({new:k,isValid:z,id:se,...Ee})=>Ee),P=r(T,x),D=o(x),$=async k=>{k.preventDefault(),s(x)},B=()=>L?`curl --location --request POST '${u.unleashUrl}/api/admin/projects/${i}/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(D,void 0,2)}'`:`curl --location --request PATCH '${u.unleashUrl}/api/admin/projects/${i}/features/${c}/environments/${e==null?void 0:e.name}/variants' \\
|
|
@@ -6,4 +6,4 @@ import{aA as vn,aB as wn,s as d,r as m,aC as Tn,aD as xn,aE as pt,j as t,aF as A
|
|
|
6
6
|
--header 'Content-Type: application/json' \\
|
|
7
7
|
--data-raw '${JSON.stringify(P.patch,void 0,2)}'`,I=f.every(({isValid:k})=>k),_=S((e==null?void 0:e.name)||""),W=_?"Add to existing change request":"Add change to draft",L=h((e==null?void 0:e.name)||"")&&u.flags.crOnVariants,G=((Q=x[0])==null?void 0:Q.stickiness)||g,J=m.useMemo(()=>["default",...p.filter(k=>k.stickiness).map(k=>k.name)],[p]),R=J.map(k=>({key:k,label:k}));J.includes(G)||R.push({key:G,label:G});const C=async k=>{y(z=>z.map(se=>({...se,stickiness:k})))},E=k=>{C(k).catch(console.warn)},[V,H]=m.useState();return m.useEffect(()=>{H(void 0),P.error&&H(P.error)},[P.error]),t(Xe,{open:n,onClose:()=>{a(!1)},label:"",children:l(ba,{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:B,loading:!n,children:[l(Vs,{children:[l("div",{children:[t(Ls,{deprecated:!(e!=null&&e.enabled)}),t(Ms,{deprecated:!(e!=null&&e.enabled),children:e==null?void 0:e.name})]}),t(oe,{"data-testid":"MODAL_ADD_VARIANT_BUTTON",onClick:()=>y(k=>[...k,{name:"",weightType:Y.VARIABLE,weight:0,overrides:[],stickiness:(k==null?void 0:k.length)>0?k[0].stickiness:"default",new:!0,isValid:!1,id:Ne()}]),variant:"outlined",permission:me,projectId:i,environmentId:e==null?void 0:e.name,children:"Add variant"})]}),l(_s,{onSubmit:$,children:[t(A,{condition:_,show:v,elseShow:t(A,{condition:Boolean(L),show:l(js,{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(zs,{children:f.map(k=>t(Ds,{variant:k,variants:f,updateVariant:z=>w(z,k.id),removeVariant:()=>y(z=>mt(z.filter(se=>se.id!==k.id),1e3)),projectId:i,apiPayload:P},k.id))}),t(A,{condition:f.length>0,show:l(O,{children:[t(Ws,{children:t("p",{children:"Stickiness"})}),l(Bt,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t("a",{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]}),t("div",{children:t(Hs,{value:G,label:"",editable:!0,onChange:k=>E(k.target.value)})})]}),elseShow:t(Bt,{children:"This environment has no variants. Get started by adding a variant."})}),l(Ns,{severity:"error",hidden:!Boolean(V),children:[t("strong",{children:"Error: "}),V]}),l(qs,{children:[t(re,{"data-testid":"DIALOGUE_CONFIRM_ID",type:"submit",variant:"contained",color:"primary",disabled:!I,children:L?W:"Save variants"}),t(Us,{onClick:()=>{a(!1)},children:"Cancel"})]})]})]})})},Ys=d(M)(({theme:e})=>({fontSize:e.fontSizes.smallerBody,whiteSpace:"pre-wrap"})),Ks=({value:e})=>{const{searchQuery:n}=Zt();return e?e.type==="string"&&e.value.length<20?t(te,{children:t(Je,{search:n,children:e.value})}):t(te,{children:t(en,{tooltip:t(O,{children:t(Ys,{children:t(Je,{search:n,children:e.value})})}),highlighted:n.length>0&&e.value.toLowerCase().includes(n.toLowerCase()),children:e.type})}):t(te,{})},Xs=d(M)(({theme:e})=>({fontSize:e.fontSizes.smallerBody})),Js=({value:e})=>{const{searchQuery:n}=Zt();if(!e||e.length===0)return t(te,{});const a=r=>`${r.contextName}:${r.values.join()}`;return t(te,{children:t(en,{tooltip:t(O,{children:e.map((r,o)=>t(Xs,{children:t(Je,{search:n,children:a(r)})},r.contextName+o))}),highlighted:n.length>0&&(e==null?void 0:e.map(a).join(`
|
|
8
8
|
`).toLowerCase().includes(n.toLowerCase())),children:e.length===1?"1 override":`${e.length} overrides`})})},Qs=d("div")(({theme:e})=>({margin:e.spacing(3,0)})),Zs=({environment:e,searchValue:n})=>{const a=F("projectId"),r=ve(),o=de(r.breakpoints.down("md")),s=de(r.breakpoints.down("lg")),i=e.variants??[],c=m.useMemo(()=>[{Header:"Name",accessor:"name",Cell:va,sortType:"alphanumeric",minWidth:350,searchable:!0},{Header:"Payload",accessor:"payload",Cell:Ks,disableSortBy:!0,searchable:!0,filterParsing:y=>y==null?void 0:y.value},{Header:"Overrides",accessor:"overrides",Cell:Js,disableSortBy:!0,searchable:!0,filterParsing:y=>(y==null?void 0:y.map(({contextName:w,values:x})=>`${w}:${x.join()}`).join(`
|
|
9
|
-
`))||""},{Header:"Weight",accessor:"weight",Cell:({row:{original:{name:y,weight:w}}})=>l(te,{"data-testid":`VARIANT_WEIGHT_${y}`,children:[wa(w)," %"]}),sortType:"number"},{Header:"Type",accessor:y=>y.weightType==="fix"?"Fixed":"Variable",Cell:te,sortType:"alphanumeric"}],[a,i,e]),u=m.useMemo(()=>({sortBy:[{id:"name",desc:!1}]}),[]),{data:p,getSearchText:g}=Ta(c,n,i),{getTableProps:h,getTableBodyProps:b,headerGroups:S,rows:v,prepareRow:T,setHiddenColumns:f}=fe.useTable({columns:c,data:p,initialState:u,sortTypes:xa,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},fe.useSortBy);return tn([{condition:o,columns:["payload","overrides"]},{condition:s,columns:["weightType"]}],f,c),l(Qs,{children:[t(Aa,{value:g(n),children:l(nn,{...h(),children:[t(an,{headerGroups:S}),t(on,{...b(),children:v.map(y=>(T(y),t(rn,{hover:!0,...y.getRowProps(),children:y.cells.map(w=>t(sn,{...w.getCellProps(),children:w.render("Cell")}))})))})]})}),t(A,{condition:v.length===0,show:t(A,{condition:(n==null?void 0:n.length)>0,show:l(Ea,{children:["No variants found matching “",n,"”"]})})})]})},ei=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)}})),ti=d("div")({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"}}),ni=d(Qt,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.neutral.border:e.palette.primary.main})),ai=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})),oi=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),ri=d("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),si=({environment:e,searchValue:n,children:a})=>{var s;const r=e.variants??[],o=((s=r[0])==null?void 0:s.stickiness)||"default";return l(ei,{children:[l(ti,{children:[l("div",{children:[t(ni,{deprecated:!e.enabled}),t(ai,{deprecated:!e.enabled,children:e.name})]}),a]}),t(A,{condition:r.length>0,show:l(O,{children:[t(Zs,{environment:e,searchValue:n}),t(A,{condition:r.length>1,show:l(O,{children:[l(ri,{children:[t("p",{children:"Stickiness:"}),t(Se,{children:o})]}),l(oi,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t("a",{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]})]})})]})})]})},ii=d(at)(({theme:e})=>({"& span":{fontSize:e.fontSizes.smallBody}})),li=({environment:e,permission:n,projectId:a,environmentId:r,onCopyVariantsFrom:o,otherEnvsWithVariants:s})=>{const[i,c]=m.useState(null),u=Boolean(i),p=e.variants??[];return t(A,{condition:s.length>0&&p.length===0,show:l(O,{children:[t(oe,{onClick:g=>{c(g.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:r,children:"Copy variants from"}),t(De,{anchorEl:i,open:u,onClose:()=>c(null),MenuListProps:{"aria-labelledby":`copy-from-menu-${e.name}`},children:s.map(g=>t(Ve,{onClick:()=>o(g,e),children:t(ii,{children:`Copy from ${g.name}`})},g.name))})]})})},ci=({permission:e,projectId:n,environment:a,checked:r,onClick:o,...s})=>{const i=Ia(e,n,a);return l(Ve,{disabled:!i,onClick:o,...s,children:[t(qt,{checked:r}),a]})},di=d(De)(({theme:e})=>({"& > div > ul":{display:"flex",flexDirection:"column",justifyContent:"center","& > li":{padding:e.spacing(0,1)}}})),ui=d("div")(({theme:e})=>({margin:e.spacing(1,2)})),pi=d(re)(({theme:e})=>({marginTop:e.spacing(2)})),gi=({current:e,environments:n,permission:a,projectId:r,onSubmit:o})=>{var T;const[s,i]=m.useState(null),c=Boolean(s),[u,p]=m.useState([]),g=f=>{p(y=>[...y,f])},h=f=>{p(y=>y.filter(({name:w})=>w!==f.name))},b=f=>{u.includes(f)?h(f):g(f)},S=()=>{p([]),i(null)},v=((T=n.find(f=>f.name===e))==null?void 0:T.variants)??[];return t(A,{condition:v.length>0&&n.length>1,show:l(O,{children:[t(re,{onClick:f=>{i(f.currentTarget)},id:`push-to-menu-${e}`,"aria-controls":c?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":c?"true":void 0,variant:"outlined",children:"Push to environment"}),l(di,{anchorEl:s,open:c,onClose:()=>i(null),MenuListProps:{"aria-labelledby":`push-to-menu-${e}`},children:[n.filter(f=>f.name!==e).map(f=>t(ci,{projectId:r,permission:a,environment:f.name,checked:u.includes(f),onClick:()=>b(f)},f.name)),l(ui,{children:[t(ke,{}),l(pi,{variant:"outlined",onClick:()=>{o(u),S()},disabled:u.length===0,children:["Push to selected (",u.length,")"]})]})]})]})})},hi=d(he)(({theme:e})=>({marginBottom:e.spacing(4),"& code":{fontWeight:e.fontWeight.bold}})),mi=d("div")(({theme:e})=>({display:"flex",gap:e.spacing(1.5)})),fi=()=>{const{uiConfig:e}=ct(),{setToastData:n,setToastApiError:a}=U(),r=ve(),o=de(r.breakpoints.down("md")),s=F("projectId"),i=F("featureId"),{feature:c,refetchFeature:u,loading:p}=j(s,i),{patchFeatureEnvironmentVariants:g,overrideVariantsInEnvironments:h}=Ae(),{refetch:b}=Te(s),{addChange:S}=nt(),{isChangeRequestConfigured:v}=ae(s),[T,f]=m.useState(""),[y,w]=m.useState(),[x,P]=m.useState(!1),D=m.useMemo(()=>{var R;return((R=c==null?void 0:c.environments)==null?void 0:R.map(C=>({...C,crEnabled:e.flags.crOnVariants&&v(C.name)})))||[]},[c.environments,e.flags.crOnVariants]),$=(R,C)=>ka(R,C),B=(R,C)=>{try{const E=Fa(C,1e3);return{patch:$(R,E)}}catch(E){return{patch:[],error:N(E)}}},I=R=>({feature:i,action:"patchVariant",payload:{variants:R}}),_=async(R,C)=>{if(R.crEnabled)await S(s,R.name,I(C)),b();else{const E=R.variants??[],{patch:V,error:H}=B(E,C);if(V.length===0)return;if(H){n({type:"error",title:H});return}await g(s,i,R.name,V)}u()},W=async(R,C)=>{try{const E=C.filter(({crEnabled:z})=>z),V=C.filter(({crEnabled:z})=>!z);E.length&&await Promise.all(E.map(z=>S(s,z.name,I(R)))),V.length&&await h(s,i,R,V.map(({name:z})=>z)),b(),u();const H=V.length?`Variants pushed to ${V.length===1?V[0].name:`${V.length} environments`}`:"",Q=E.length?`Variants push added to ${E.length===1?`${E[0].name} draft`:`${E.length} drafts`}`:"",k=`${H}${H&&Q?". ":""}${Q}`;n({title:k,type:"success"})}catch(E){a(N(E))}},L=R=>{w(R),P(!0)},G=async R=>{if(y)try{await _(y,R),P(!1),n({title:y.crEnabled?"Variant changes added to draft":"Variants updated successfully",type:"success"})}catch(C){a(N(C))}},J=async(R,C)=>{try{const E=R.variants??[];await _(C,E),n({title:C.crEnabled?"Variants copy added to draft":"Variants copied successfully",type:"success"})}catch(E){a(N(E))}};return l(dt,{isLoading:p,header:t(Ra,{title:"Variants",actions:t(A,{condition:!o,show:t(O,{children:t(ft,{initialValue:T,onChange:f})})}),children:t(A,{condition:o,show:t(ft,{initialValue:T,onChange:f})})}),children:[l(hi,{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(R=>{var E;const C=D.filter(({name:V,variants:H})=>V!==R.name&&(H==null?void 0:H.length));return t(si,{environment:R,searchValue:T,children:l(mi,{children:[t(gi,{current:R.name,environments:D,permission:me,projectId:s,onSubmit:V=>W(R.variants??[],V)}),t(li,{environment:R,permission:me,projectId:s,environmentId:R.name,onCopyVariantsFrom:J,otherEnvsWithVariants:C}),t(A,{condition:Boolean((E=R.variants)==null?void 0:E.length),show:t(K,{"data-testid":"EDIT_VARIANTS_BUTTON",onClick:()=>L(R),permission:me,projectId:s,environmentId:R.name,tooltipProps:{title:"Edit variants"},children:t(ye,{})}),elseShow:t(oe,{"data-testid":"ADD_VARIANT_BUTTON",onClick:()=>L(R),variant:"outlined",permission:me,projectId:s,environmentId:R.name,children:"Add variant"})})]})},R.name)}),t(Gs,{environment:y,open:x,setOpen:P,getApiPayload:B,getCrPayload:I,onConfirm:G})]})},yi=pe("api/admin/client-metrics/features"),Cn=(e,n)=>{const a=pe(`api/admin/client-metrics/features/${e}/raw?hoursBack=${n}`),{data:r,error:o}=et(a,()=>Si(a)),s=m.useCallback(()=>{Be(yi).catch(console.warn)},[]);return{featureMetrics:r==null?void 0:r.data,loading:!o&&!r,refetchFeatureMetrics:s,error:o}},Si=e=>fetch(e).then(Ce("Features")).then(n=>n.json()).then(),be=48,bi=({hoursBack:e,setHoursBack:n})=>{const a=r=>{n(Ci(r))};return t(Pa,{label:"Period",name:"feature-metrics-period",id:"feature-metrics-period",options:vi,value:String(e),onChange:a,fullWidth:!0})},Ci=e=>{switch(e){case"1":return 1;case"24":return 24;default:return be}},vi=[{key:"1",label:"Last hour"},{key:"24",label:"Last 24 hours"},{key:`${be}`,label:`Last ${be} hours`}],wi=({metrics:e,tableSectionId:n})=>{const a=de(ln.breakpoints.down("md")),r=m.useMemo(()=>({sortBy:[{id:"timestamp"}]}),[]),{getTableProps:o,getTableBodyProps:s,headerGroups:i,rows:c,prepareRow:u,setHiddenColumns:p}=fe.useTable({initialState:r,columns:Ot,data:e,autoResetHiddenColumns:!1,disableSortRemove:!0,defaultColumn:{Cell:te}},fe.useGlobalFilter,fe.useSortBy);return tn([{condition:a,columns:["appName","environment"]}],p,Ot),e.length===0?null:l(nn,{...o(),rowHeight:"standard",id:n,children:[t(an,{headerGroups:i}),t(on,{...s(),children:c.map(g=>(u(g),t(rn,{hover:!0,...g.getRowProps(),children:g.cells.map(h=>t(sn,{...h.getCellProps(),children:h.render("Cell")}))})))})]})},Ot=[{id:"Icon",width:"1%",disableSortBy:!0,Cell:()=>t($a,{icon:t(fo,{color:"disabled"})})},{Header:"Time",accessor:"timestamp",Cell:e=>t(Ba,{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"}],Ti=({metrics:e,...n})=>{const a=m.useMemo(()=>e.reduce((o,s)=>o+s.yes,0),[e]),r=m.useMemo(()=>e.reduce((o,s)=>o+s.no,0),[e]);return t(mn,{...n,totalYes:a,totalNo:r})},xi=({metrics:e,hoursBack:n})=>{const a=yt(),r=yt();return e.length===0?l(q,{mt:6,children:[t(M,{variant:"body1",paragraph:!0,children:"We have yet to receive any metrics for this feature toggle in the selected time period."}),t(M,{variant:"body1",paragraph:!0,children:"Please note that, since the SDKs send metrics on an interval, it might take some time before metrics appear."})]}):l(m.Suspense,{fallback:null,children:[t(q,{borderTop:1,pt:2,mt:3,borderColor:ln.palette.divider,children:t(Ai,{metrics:e,hoursBack:n,statsSectionId:a})}),t(q,{mt:4,children:t(Ti,{metrics:e,hoursBack:n,statsSectionId:a,tableSectionId:r})}),t(q,{mt:4,children:t(wi,{metrics:e,tableSectionId:r})})]})},Ai=Oa.lazy(()=>import("./FeatureMetricsChart-06211c4e.js")),Ze=e=>{const{search:n}=window.location,a=ge(),r=m.useMemo(()=>new URLSearchParams(n),[n]),o=m.useCallback(s=>{const i=new URLSearchParams(n);i.set(e,s),a({search:i.toString()},{replace:!0})},[e,n,a]);return[r.get(e)||void 0,o]},Ei=e=>{const[n,a]=Ze(e),r=m.useCallback(o=>a(String(o)),[a]);return[Number.isFinite(Number(n))?Number(n):void 0,r]},Ii=d("h2")(({theme:e})=>({margin:0,marginBottom:e.spacing(1),fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.thin,color:e.palette.text.secondary})),Ri=d("ul")(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing(1),listStyleType:"none",padding:0,minHeight:"100%"})),Fi=d("li")(({theme:e})=>({"& > [aria-pressed=true]":{backgroundColor:e.palette.primary.main,color:e.palette.primary.contrastText},"& > [aria-pressed=true]:hover":{backgroundColor:e.palette.primary.light}})),Dt=({title:e,values:n,value:a,setValue:r})=>{const o=i=>()=>{n.has(i)&&r(i)},s=m.useMemo(()=>Array.from(n).sort((i,c)=>i.localeCompare(c)),[n]);return l("div",{children:[t(Ii,{children:e}),t(Ri,{children:s.map(i=>t(Fi,{children:t(Gt,{label:i,onClick:o(i),"aria-pressed":i===a,sx:Da})},i))})]})},ki=d("div")(({theme:e})=>({[e.breakpoints.down("md")]:{marginTop:e.spacing(2)}})),Pi=()=>{const e=F("projectId"),n=F("featureId"),a=$i(e,n),r=Bi(n);Yt("Metrics");const[o=be,s]=Ei("hoursBack"),{featureMetrics:i}=Cn(n,o),[c,u]=m.useState(i);m.useEffect(()=>{i&&u(i)},[i]);const p=Array.from(a)[0],g=Array.from(r)[0],[h=p,b]=Ze("environment"),[S=g,v]=Ze("application"),T=m.useMemo(()=>c==null?void 0:c.filter(f=>f.environment===h).filter(f=>f.appName===S),[c,h,S]);return T?l(dt,{children:[l(ee,{container:!0,component:"header",spacing:2,alignItems:"flex-end",children:[t(ee,{item:!0,xs:12,md:5,children:t(A,{condition:a.size>0,show:t(Dt,{title:"Environments",values:a,value:h,setValue:b})})}),t(ee,{item:!0,xs:12,md:5,children:t(A,{condition:r.size>0,show:t(Dt,{title:"Applications",values:r,value:S,setValue:v})})}),t(ee,{item:!0,xs:12,md:2,children:t(ki,{children:t(bi,{hoursBack:o,setHoursBack:s})})})]}),t(xi,{metrics:T,hoursBack:o})]}):null},$i=(e,n)=>{const{feature:a}=j(e,n),r=a.environments.map(o=>o.name);return new Set(r)},Bi=e=>{const{featureMetrics:n=[]}=Cn(e,be),a=n.map(r=>r.appName);return new Set(a)},Oi=(e,n)=>{const a=new Set(e),r=new Set(n);return a.size!==r.size?!1:[...a].every(o=>r.has(o))},Vt=d("div")(({theme:e})=>({display:"grid",gap:e.spacing(2)})),Lt=d(he)(({theme:e})=>({marginBottom:e.spacing(1)})),Di=d(st)({padding:0}),Vi=({projectId:e,open:n,onClose:a,onClick:r,feature:o,changeRequests:s})=>{const i=F("projectId"),{project:c}=cn(e),u=m.useMemo(()=>Oi(o.environments.map(g=>g.name),c.environments),[o,c]),p=s?s.length>0:!1;return t(A,{condition:u&&!p,show:t(le,{open:n,onClose:a,onClick:r,title:"Confirm change project",primaryButtonText:"Change project",secondaryButtonText:"Cancel",children:l(Vt,{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(le,{open:n,onClick:a,title:"Confirm change project",primaryButtonText:"OK",children:l(Vt,{children:[t(Lt,{severity:"warning",children:"Incompatible project environments"}),t("p",{children:"In order to move a feature toggle between two projects, both projects must have the exact same environments enabled."}),t(A,{condition:p,show:l(O,{children:[t("p",{children:"In addition the feature toggle must not have any pending change requests. This feature toggle is currently referenced in the following change requests:"}),t(Di,{children:s==null?void 0:s.map(g=>t(Fe,{children:l(X,{to:`/projects/${i}/change-requests/${g.id}`,children:["View change request"," ",g.id]})},g.id))})]})})]})})})},Li=e=>fetch(e).then(Ce("ChangeRequest")).then(n=>n.json()),Mi=(e,n)=>{const{data:a,error:r,mutate:o}=Va([],pe(`api/admin/projects/${e}/change-requests/pending/${n}`),Li);return{changeRequests:a,loading:!r&&!a,refetch:o,error:r}},_i=()=>{const{hasAccess:e}=m.useContext(ot),n=F("projectId"),a=F("featureId"),{feature:r,refetchFeature:o}=j(n,a),[s,i]=m.useState(!1),{changeFeatureProject:c}=Ae(),{setToastData:u,setToastApiError:p}=U(),[g,h]=m.useState(n),{projects:b}=La(),S=ge(),{changeRequests:v}=Mi(n,a),T=async()=>{try{g&&(await c(n,a,g),o(),u({title:"Project changed",type:"success"}),i(!1),S(`/projects/${g}/features/${a}/settings`,{replace:!0}))}catch(y){p(N(y))}},f=m.useMemo(()=>b.map(y=>y.id).filter(y=>e(St,y)),[b,e]);return f.length===0?null:l(O,{children:[t(Ma,{value:g,onChange:h,label:"Project",filter:y=>f.includes(y),enabled:!0}),t(oe,{permission:St,onClick:()=>i(!0),disabled:g===n,projectId:n,children:"Save"}),t(Vi,{changeRequests:v,projectId:g,open:s,feature:r,onClose:()=>i(!1),onClick:T})]})},ji=d("div")({display:"flex",alignItems:"center"}),Ni=d(M)(({theme:e})=>({fontSize:e.fontSizes.mainHeader})),zi=({projectId:e,featureId:n})=>{var s;const{feature:a}=j(e,n),r=ge();return l(O,{children:[l(ji,{children:[t(Ni,{children:"Feature information"}),t(K,{permission:ie,projectId:e,"data-loading":!0,onClick:()=>{r(`/projects/${e}/features/${n}/edit`)},tooltipProps:{title:"Edit"},children:t(ye,{})})]}),l(M,{children:["Name: ",t("strong",{children:a.name})]}),l(M,{children:["Description:"," ",t("strong",{children:(s=a.description)!=null&&s.length?a.description:"no description"})]}),l(M,{children:["Type: ",t("strong",{children:a.type})]}),l(M,{children:["Impression Data:"," ",t("strong",{children:a.impressionData?"enabled":"disabled"})]})]})},Ie="metadata",Ye="project",Wi=d("div")(({theme:e})=>({width:"20%",borderRight:`1px solid ${e.palette.divider}`,padding:e.spacing(2,0),[e.breakpoints.down("md")]:{width:"35%"}})),Hi=d("div")(({theme:e})=>({padding:e.spacing(4),display:"flex",flexDirection:"column",width:400,["& > *"]:{margin:e.spacing(1,0)}})),qi=()=>{const e=F("projectId"),n=F("featureId"),[a,r]=m.useState(Ie),{uiConfig:o}=ct();return t(dt,{header:"Settings",sx:{padding:0},children:l(q,{sx:{display:"flex"},children:[t(Wi,{children:l(st,{children:[t(Fe,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>r(Ie),selected:a===Ie,children:"Metadata"},0),t(Fe,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>r(Ye),selected:a===Ye,hidden:!o.flags.P,children:"Project"},1)]})}),l(Hi,{children:[t(A,{condition:a===Ie,show:t(zi,{projectId:e,featureId:n})}),t(A,{condition:a===Ye&&o.flags.P,show:t(_i,{})})]})]})})},Ui=({stale:e,showActive:n=!0})=>!e&&!n?null:t("div",{"data-loading":!0,style:{marginLeft:"8px"},children:t(Se,{color:e?"neutral":"secondary",title:e?"Feature toggle is deprecated.":"Feature toggle is active.",children:e?"Stale":"Active"})}),Mt=d("strong")({wordBreak:"break-all"}),Gi=()=>{const e=F("projectId"),n=F("featureId"),{archivedFeatures:a}=_a(),r=ja(e,{name:n});return a?a.some(s=>s.name===n)?l("p",{children:["The feature ",t(Mt,{children:n})," has been archived. You can find it on the"," ",t(X,{to:`/projects/${e}/archive`,children:"project archive page"}),"."]}):l("p",{children:["The feature ",t(Mt,{children:n})," does not exist. Would you like to"," ",t(X,{to:r,children:"create it"}),"?"]}):null},Yi=d("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),Ki=d("div")(({theme:e})=>({padding:e.spacing(2,4,2,2),display:"flex",justifyContent:"space-between",alignItems:"center",[e.breakpoints.down(500)]:{flexDirection:"column"}})),Xi=d("div")({display:"flex",alignItems:"center"}),Ji=d("h1")(({theme:e})=>({fontSize:e.fontSizes.mainHeader,fontWeight:"normal",display:"flex",alignItems:"center",wordBreak:"break-all"})),Qi=d("div")({flexShrink:0,display:"flex"}),Zi=d("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.background.elevation2,height:"1px"})),el=d("div")(({theme:e})=>({padding:e.spacing(0,4)})),tl=d(Na)(({theme:e})=>({textTransform:"none",width:"auto",fontSize:e.fontSizes.bodySize,padding:"0 !important",[e.breakpoints.up("md")]:{minWidth:160}})),il=()=>{const e=F("projectId"),n=F("featureId"),{refetch:a}=cn(e),{favorite:r,unfavorite:o}=za(),{refetchFeature:s}=j(e,n),[i,c]=m.useState(!1),[u,p]=m.useState(!1),[g,h]=m.useState(!1),b=de(`(max-width:${500}px)`),{feature:S,loading:v,error:T,status:f}=j(e,n),y=ge(),{pathname:w}=Wa(),x=Ha(v),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(I=>I.path===w)??D[0],B=async()=>{S!=null&&S.favorite?await o(e,S.name):await r(e,S.name),s()};return f===404?t(Gi,{}):T!==void 0?t("div",{ref:x}):l("div",{ref:x,children:[l(Yi,{children:[l(Ki,{children:[l(Xi,{children:[t(qa,{onClick:B,isFavorite:S==null?void 0:S.favorite}),l(Ji,{"data-loading":!0,children:[S.name," "]}),t(A,{condition:!b,show:t(Ui,{stale:S==null?void 0:S.stale})})]}),l(Qi,{children:[t(K,{permission:Ua,projectId:e,"data-loading":!0,component:X,to:`/projects/${e}/features/${n}/strategies/copy`,tooltipProps:{title:"Copy feature toggle"},children:t(Ga,{})}),t(K,{permission:Ya,projectId:e,tooltipProps:{title:"Archive feature toggle"},"data-loading":!0,onClick:()=>p(!0),children:t(mo,{})}),t(K,{onClick:()=>h(!0),permission:ie,projectId:e,tooltipProps:{title:"Toggle stale state"},"data-loading":!0,children:t(So,{})}),t(K,{onClick:()=>c(!0),permission:ie,projectId:e,tooltipProps:{title:"Add tag"},"data-loading":!0,children:t(Ka,{})})]})]}),t(Zi,{}),t(el,{children:t(Xa,{value:$.path,indicatorColor:"primary",textColor:"primary",children:D.map(I=>t(tl,{label:I.title,value:I.path,onClick:()=>y(I.path)},I.title))})})]}),l(Kt,{children:[t(ne,{path:"metrics",element:t(Pi,{})}),t(ne,{path:"logs",element:t(Co,{})}),t(ne,{path:"variants",element:t(fi,{})}),t(ne,{path:"settings",element:t(qi,{})}),t(ne,{path:"*",element:t(gs,{})})]}),t(oo,{isOpen:u,onConfirm:()=>{a(),y(`/projects/${e}`)},onClose:()=>p(!1),projectId:e,featureId:n}),t(ro,{isStale:S.stale,isOpen:g,onClose:()=>{h(!1),s()},featureId:n,projectId:e}),t(yn,{open:i,setOpen:c})]})};export{il as default};
|
|
9
|
+
`))||""},{Header:"Weight",accessor:"weight",Cell:({row:{original:{name:y,weight:w}}})=>l(te,{"data-testid":`VARIANT_WEIGHT_${y}`,children:[wa(w)," %"]}),sortType:"number"},{Header:"Type",accessor:y=>y.weightType==="fix"?"Fixed":"Variable",Cell:te,sortType:"alphanumeric"}],[a,i,e]),u=m.useMemo(()=>({sortBy:[{id:"name",desc:!1}]}),[]),{data:p,getSearchText:g}=Ta(c,n,i),{getTableProps:h,getTableBodyProps:b,headerGroups:S,rows:v,prepareRow:T,setHiddenColumns:f}=fe.useTable({columns:c,data:p,initialState:u,sortTypes:xa,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},fe.useSortBy);return tn([{condition:o,columns:["payload","overrides"]},{condition:s,columns:["weightType"]}],f,c),l(Qs,{children:[t(Aa,{value:g(n),children:l(nn,{...h(),children:[t(an,{headerGroups:S}),t(on,{...b(),children:v.map(y=>(T(y),t(rn,{hover:!0,...y.getRowProps(),children:y.cells.map(w=>t(sn,{...w.getCellProps(),children:w.render("Cell")}))})))})]})}),t(A,{condition:v.length===0,show:t(A,{condition:(n==null?void 0:n.length)>0,show:l(Ea,{children:["No variants found matching “",n,"”"]})})})]})},ei=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)}})),ti=d("div")({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"}}),ni=d(Qt,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:n})=>({color:n?e.palette.neutral.border:e.palette.primary.main})),ai=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})),oi=d("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),ri=d("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),si=({environment:e,searchValue:n,children:a})=>{var s;const r=e.variants??[],o=((s=r[0])==null?void 0:s.stickiness)||"default";return l(ei,{children:[l(ti,{children:[l("div",{children:[t(ni,{deprecated:!e.enabled}),t(ai,{deprecated:!e.enabled,children:e.name})]}),a]}),t(A,{condition:r.length>0,show:l(O,{children:[t(Zs,{environment:e,searchValue:n}),t(A,{condition:r.length>1,show:l(O,{children:[l(ri,{children:[t("p",{children:"Stickiness:"}),t(Se,{children:o})]}),l(oi,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t("a",{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]})]})})]})})]})},ii=d(at)(({theme:e})=>({"& span":{fontSize:e.fontSizes.smallBody}})),li=({environment:e,permission:n,projectId:a,environmentId:r,onCopyVariantsFrom:o,otherEnvsWithVariants:s})=>{const[i,c]=m.useState(null),u=Boolean(i),p=e.variants??[];return t(A,{condition:s.length>0&&p.length===0,show:l(O,{children:[t(oe,{onClick:g=>{c(g.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:r,children:"Copy variants from"}),t(De,{anchorEl:i,open:u,onClose:()=>c(null),MenuListProps:{"aria-labelledby":`copy-from-menu-${e.name}`},children:s.map(g=>t(Ve,{onClick:()=>o(g,e),children:t(ii,{children:`Copy from ${g.name}`})},g.name))})]})})},ci=({permission:e,projectId:n,environment:a,checked:r,onClick:o,...s})=>{const i=Ia(e,n,a);return l(Ve,{disabled:!i,onClick:o,...s,children:[t(qt,{checked:r}),a]})},di=d(De)(({theme:e})=>({"& > div > ul":{display:"flex",flexDirection:"column",justifyContent:"center","& > li":{padding:e.spacing(0,1)}}})),ui=d("div")(({theme:e})=>({margin:e.spacing(1,2)})),pi=d(re)(({theme:e})=>({marginTop:e.spacing(2)})),gi=({current:e,environments:n,permission:a,projectId:r,onSubmit:o})=>{var T;const[s,i]=m.useState(null),c=Boolean(s),[u,p]=m.useState([]),g=f=>{p(y=>[...y,f])},h=f=>{p(y=>y.filter(({name:w})=>w!==f.name))},b=f=>{u.includes(f)?h(f):g(f)},S=()=>{p([]),i(null)},v=((T=n.find(f=>f.name===e))==null?void 0:T.variants)??[];return t(A,{condition:v.length>0&&n.length>1,show:l(O,{children:[t(re,{onClick:f=>{i(f.currentTarget)},id:`push-to-menu-${e}`,"aria-controls":c?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":c?"true":void 0,variant:"outlined",children:"Push to environment"}),l(di,{anchorEl:s,open:c,onClose:()=>i(null),MenuListProps:{"aria-labelledby":`push-to-menu-${e}`},children:[n.filter(f=>f.name!==e).map(f=>t(ci,{projectId:r,permission:a,environment:f.name,checked:u.includes(f),onClick:()=>b(f)},f.name)),l(ui,{children:[t(ke,{}),l(pi,{variant:"outlined",onClick:()=>{o(u),S()},disabled:u.length===0,children:["Push to selected (",u.length,")"]})]})]})]})})},hi=d(he)(({theme:e})=>({marginBottom:e.spacing(4),"& code":{fontWeight:e.fontWeight.bold}})),mi=d("div")(({theme:e})=>({display:"flex",gap:e.spacing(1.5)})),fi=()=>{const{uiConfig:e}=ct(),{setToastData:n,setToastApiError:a}=U(),r=ve(),o=de(r.breakpoints.down("md")),s=F("projectId"),i=F("featureId"),{feature:c,refetchFeature:u,loading:p}=j(s,i),{patchFeatureEnvironmentVariants:g,overrideVariantsInEnvironments:h}=Ae(),{refetch:b}=Te(s),{addChange:S}=nt(),{isChangeRequestConfigured:v}=ae(s),[T,f]=m.useState(""),[y,w]=m.useState(),[x,P]=m.useState(!1),D=m.useMemo(()=>{var R;return((R=c==null?void 0:c.environments)==null?void 0:R.map(C=>({...C,crEnabled:e.flags.crOnVariants&&v(C.name)})))||[]},[c.environments,e.flags.crOnVariants]),$=(R,C)=>ka(R,C),B=(R,C)=>{try{const E=Fa(C,1e3);return{patch:$(R,E)}}catch(E){return{patch:[],error:N(E)}}},I=R=>({feature:i,action:"patchVariant",payload:{variants:R}}),_=async(R,C)=>{if(R.crEnabled)await S(s,R.name,I(C)),b();else{const E=R.variants??[],{patch:V,error:H}=B(E,C);if(V.length===0)return;if(H){n({type:"error",title:H});return}await g(s,i,R.name,V)}u()},W=async(R,C)=>{try{const E=C.filter(({crEnabled:z})=>z),V=C.filter(({crEnabled:z})=>!z);E.length&&await Promise.all(E.map(z=>S(s,z.name,I(R)))),V.length&&await h(s,i,R,V.map(({name:z})=>z)),b(),u();const H=V.length?`Variants pushed to ${V.length===1?V[0].name:`${V.length} environments`}`:"",Q=E.length?`Variants push added to ${E.length===1?`${E[0].name} draft`:`${E.length} drafts`}`:"",k=`${H}${H&&Q?". ":""}${Q}`;n({title:k,type:"success"})}catch(E){a(N(E))}},L=R=>{w(R),P(!0)},G=async R=>{if(y)try{await _(y,R),P(!1),n({title:y.crEnabled?"Variant changes added to draft":"Variants updated successfully",type:"success"})}catch(C){a(N(C))}},J=async(R,C)=>{try{const E=R.variants??[];await _(C,E),n({title:C.crEnabled?"Variants copy added to draft":"Variants copied successfully",type:"success"})}catch(E){a(N(E))}};return l(dt,{isLoading:p,header:t(Ra,{title:"Variants",actions:t(A,{condition:!o,show:t(O,{children:t(ft,{initialValue:T,onChange:f})})}),children:t(A,{condition:o,show:t(ft,{initialValue:T,onChange:f})})}),children:[l(hi,{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(R=>{var E;const C=D.filter(({name:V,variants:H})=>V!==R.name&&(H==null?void 0:H.length));return t(si,{environment:R,searchValue:T,children:l(mi,{children:[t(gi,{current:R.name,environments:D,permission:me,projectId:s,onSubmit:V=>W(R.variants??[],V)}),t(li,{environment:R,permission:me,projectId:s,environmentId:R.name,onCopyVariantsFrom:J,otherEnvsWithVariants:C}),t(A,{condition:Boolean((E=R.variants)==null?void 0:E.length),show:t(K,{"data-testid":"EDIT_VARIANTS_BUTTON",onClick:()=>L(R),permission:me,projectId:s,environmentId:R.name,tooltipProps:{title:"Edit variants"},children:t(ye,{})}),elseShow:t(oe,{"data-testid":"ADD_VARIANT_BUTTON",onClick:()=>L(R),variant:"outlined",permission:me,projectId:s,environmentId:R.name,children:"Add variant"})})]})},R.name)}),t(Gs,{environment:y,open:x,setOpen:P,getApiPayload:B,getCrPayload:I,onConfirm:G})]})},yi=pe("api/admin/client-metrics/features"),Cn=(e,n)=>{const a=pe(`api/admin/client-metrics/features/${e}/raw?hoursBack=${n}`),{data:r,error:o}=et(a,()=>Si(a)),s=m.useCallback(()=>{Be(yi).catch(console.warn)},[]);return{featureMetrics:r==null?void 0:r.data,loading:!o&&!r,refetchFeatureMetrics:s,error:o}},Si=e=>fetch(e).then(Ce("Features")).then(n=>n.json()).then(),be=48,bi=({hoursBack:e,setHoursBack:n})=>{const a=r=>{n(Ci(r))};return t(Pa,{label:"Period",name:"feature-metrics-period",id:"feature-metrics-period",options:vi,value:String(e),onChange:a,fullWidth:!0})},Ci=e=>{switch(e){case"1":return 1;case"24":return 24;default:return be}},vi=[{key:"1",label:"Last hour"},{key:"24",label:"Last 24 hours"},{key:`${be}`,label:`Last ${be} hours`}],wi=({metrics:e,tableSectionId:n})=>{const a=de(ln.breakpoints.down("md")),r=m.useMemo(()=>({sortBy:[{id:"timestamp"}]}),[]),{getTableProps:o,getTableBodyProps:s,headerGroups:i,rows:c,prepareRow:u,setHiddenColumns:p}=fe.useTable({initialState:r,columns:Ot,data:e,autoResetHiddenColumns:!1,disableSortRemove:!0,defaultColumn:{Cell:te}},fe.useGlobalFilter,fe.useSortBy);return tn([{condition:a,columns:["appName","environment"]}],p,Ot),e.length===0?null:l(nn,{...o(),rowHeight:"standard",id:n,children:[t(an,{headerGroups:i}),t(on,{...s(),children:c.map(g=>(u(g),t(rn,{hover:!0,...g.getRowProps(),children:g.cells.map(h=>t(sn,{...h.getCellProps(),children:h.render("Cell")}))})))})]})},Ot=[{id:"Icon",width:"1%",disableSortBy:!0,Cell:()=>t($a,{icon:t(fo,{color:"disabled"})})},{Header:"Time",accessor:"timestamp",Cell:e=>t(Ba,{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"}],Ti=({metrics:e,...n})=>{const a=m.useMemo(()=>e.reduce((o,s)=>o+s.yes,0),[e]),r=m.useMemo(()=>e.reduce((o,s)=>o+s.no,0),[e]);return t(mn,{...n,totalYes:a,totalNo:r})},xi=({metrics:e,hoursBack:n})=>{const a=yt(),r=yt();return e.length===0?l(q,{mt:6,children:[t(M,{variant:"body1",paragraph:!0,children:"We have yet to receive any metrics for this feature toggle in the selected time period."}),t(M,{variant:"body1",paragraph:!0,children:"Please note that, since the SDKs send metrics on an interval, it might take some time before metrics appear."})]}):l(m.Suspense,{fallback:null,children:[t(q,{borderTop:1,pt:2,mt:3,borderColor:ln.palette.divider,children:t(Ai,{metrics:e,hoursBack:n,statsSectionId:a})}),t(q,{mt:4,children:t(Ti,{metrics:e,hoursBack:n,statsSectionId:a,tableSectionId:r})}),t(q,{mt:4,children:t(wi,{metrics:e,tableSectionId:r})})]})},Ai=Oa.lazy(()=>import("./FeatureMetricsChart-e14f79ef.js")),Ze=e=>{const{search:n}=window.location,a=ge(),r=m.useMemo(()=>new URLSearchParams(n),[n]),o=m.useCallback(s=>{const i=new URLSearchParams(n);i.set(e,s),a({search:i.toString()},{replace:!0})},[e,n,a]);return[r.get(e)||void 0,o]},Ei=e=>{const[n,a]=Ze(e),r=m.useCallback(o=>a(String(o)),[a]);return[Number.isFinite(Number(n))?Number(n):void 0,r]},Ii=d("h2")(({theme:e})=>({margin:0,marginBottom:e.spacing(1),fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.thin,color:e.palette.text.secondary})),Ri=d("ul")(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing(1),listStyleType:"none",padding:0,minHeight:"100%"})),Fi=d("li")(({theme:e})=>({"& > [aria-pressed=true]":{backgroundColor:e.palette.primary.main,color:e.palette.primary.contrastText},"& > [aria-pressed=true]:hover":{backgroundColor:e.palette.primary.light}})),Dt=({title:e,values:n,value:a,setValue:r})=>{const o=i=>()=>{n.has(i)&&r(i)},s=m.useMemo(()=>Array.from(n).sort((i,c)=>i.localeCompare(c)),[n]);return l("div",{children:[t(Ii,{children:e}),t(Ri,{children:s.map(i=>t(Fi,{children:t(Gt,{label:i,onClick:o(i),"aria-pressed":i===a,sx:Da})},i))})]})},ki=d("div")(({theme:e})=>({[e.breakpoints.down("md")]:{marginTop:e.spacing(2)}})),Pi=()=>{const e=F("projectId"),n=F("featureId"),a=$i(e,n),r=Bi(n);Yt("Metrics");const[o=be,s]=Ei("hoursBack"),{featureMetrics:i}=Cn(n,o),[c,u]=m.useState(i);m.useEffect(()=>{i&&u(i)},[i]);const p=Array.from(a)[0],g=Array.from(r)[0],[h=p,b]=Ze("environment"),[S=g,v]=Ze("application"),T=m.useMemo(()=>c==null?void 0:c.filter(f=>f.environment===h).filter(f=>f.appName===S),[c,h,S]);return T?l(dt,{children:[l(ee,{container:!0,component:"header",spacing:2,alignItems:"flex-end",children:[t(ee,{item:!0,xs:12,md:5,children:t(A,{condition:a.size>0,show:t(Dt,{title:"Environments",values:a,value:h,setValue:b})})}),t(ee,{item:!0,xs:12,md:5,children:t(A,{condition:r.size>0,show:t(Dt,{title:"Applications",values:r,value:S,setValue:v})})}),t(ee,{item:!0,xs:12,md:2,children:t(ki,{children:t(bi,{hoursBack:o,setHoursBack:s})})})]}),t(xi,{metrics:T,hoursBack:o})]}):null},$i=(e,n)=>{const{feature:a}=j(e,n),r=a.environments.map(o=>o.name);return new Set(r)},Bi=e=>{const{featureMetrics:n=[]}=Cn(e,be),a=n.map(r=>r.appName);return new Set(a)},Oi=(e,n)=>{const a=new Set(e),r=new Set(n);return a.size!==r.size?!1:[...a].every(o=>r.has(o))},Vt=d("div")(({theme:e})=>({display:"grid",gap:e.spacing(2)})),Lt=d(he)(({theme:e})=>({marginBottom:e.spacing(1)})),Di=d(st)({padding:0}),Vi=({projectId:e,open:n,onClose:a,onClick:r,feature:o,changeRequests:s})=>{const i=F("projectId"),{project:c}=cn(e),u=m.useMemo(()=>Oi(o.environments.map(g=>g.name),c.environments),[o,c]),p=s?s.length>0:!1;return t(A,{condition:u&&!p,show:t(le,{open:n,onClose:a,onClick:r,title:"Confirm change project",primaryButtonText:"Change project",secondaryButtonText:"Cancel",children:l(Vt,{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(le,{open:n,onClick:a,title:"Confirm change project",primaryButtonText:"OK",children:l(Vt,{children:[t(Lt,{severity:"warning",children:"Incompatible project environments"}),t("p",{children:"In order to move a feature toggle between two projects, both projects must have the exact same environments enabled."}),t(A,{condition:p,show:l(O,{children:[t("p",{children:"In addition the feature toggle must not have any pending change requests. This feature toggle is currently referenced in the following change requests:"}),t(Di,{children:s==null?void 0:s.map(g=>t(Fe,{children:l(X,{to:`/projects/${i}/change-requests/${g.id}`,children:["View change request"," ",g.id]})},g.id))})]})})]})})})},Li=e=>fetch(e).then(Ce("ChangeRequest")).then(n=>n.json()),Mi=(e,n)=>{const{data:a,error:r,mutate:o}=Va([],pe(`api/admin/projects/${e}/change-requests/pending/${n}`),Li);return{changeRequests:a,loading:!r&&!a,refetch:o,error:r}},_i=()=>{const{hasAccess:e}=m.useContext(ot),n=F("projectId"),a=F("featureId"),{feature:r,refetchFeature:o}=j(n,a),[s,i]=m.useState(!1),{changeFeatureProject:c}=Ae(),{setToastData:u,setToastApiError:p}=U(),[g,h]=m.useState(n),{projects:b}=La(),S=ge(),{changeRequests:v}=Mi(n,a),T=async()=>{try{g&&(await c(n,a,g),o(),u({title:"Project changed",type:"success"}),i(!1),S(`/projects/${g}/features/${a}/settings`,{replace:!0}))}catch(y){p(N(y))}},f=m.useMemo(()=>b.map(y=>y.id).filter(y=>e(St,y)),[b,e]);return f.length===0?null:l(O,{children:[t(Ma,{value:g,onChange:h,label:"Project",filter:y=>f.includes(y),enabled:!0}),t(oe,{permission:St,onClick:()=>i(!0),disabled:g===n,projectId:n,children:"Save"}),t(Vi,{changeRequests:v,projectId:g,open:s,feature:r,onClose:()=>i(!1),onClick:T})]})},ji=d("div")({display:"flex",alignItems:"center"}),Ni=d(M)(({theme:e})=>({fontSize:e.fontSizes.mainHeader})),zi=({projectId:e,featureId:n})=>{var s;const{feature:a}=j(e,n),r=ge();return l(O,{children:[l(ji,{children:[t(Ni,{children:"Feature information"}),t(K,{permission:ie,projectId:e,"data-loading":!0,onClick:()=>{r(`/projects/${e}/features/${n}/edit`)},tooltipProps:{title:"Edit"},children:t(ye,{})})]}),l(M,{children:["Name: ",t("strong",{children:a.name})]}),l(M,{children:["Description:"," ",t("strong",{children:(s=a.description)!=null&&s.length?a.description:"no description"})]}),l(M,{children:["Type: ",t("strong",{children:a.type})]}),l(M,{children:["Impression Data:"," ",t("strong",{children:a.impressionData?"enabled":"disabled"})]})]})},Ie="metadata",Ye="project",Wi=d("div")(({theme:e})=>({width:"20%",borderRight:`1px solid ${e.palette.divider}`,padding:e.spacing(2,0),[e.breakpoints.down("md")]:{width:"35%"}})),Hi=d("div")(({theme:e})=>({padding:e.spacing(4),display:"flex",flexDirection:"column",width:400,["& > *"]:{margin:e.spacing(1,0)}})),qi=()=>{const e=F("projectId"),n=F("featureId"),[a,r]=m.useState(Ie),{uiConfig:o}=ct();return t(dt,{header:"Settings",sx:{padding:0},children:l(q,{sx:{display:"flex"},children:[t(Wi,{children:l(st,{children:[t(Fe,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>r(Ie),selected:a===Ie,children:"Metadata"},0),t(Fe,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>r(Ye),selected:a===Ye,hidden:!o.flags.P,children:"Project"},1)]})}),l(Hi,{children:[t(A,{condition:a===Ie,show:t(zi,{projectId:e,featureId:n})}),t(A,{condition:a===Ye&&o.flags.P,show:t(_i,{})})]})]})})},Ui=({stale:e,showActive:n=!0})=>!e&&!n?null:t("div",{"data-loading":!0,style:{marginLeft:"8px"},children:t(Se,{color:e?"neutral":"secondary",title:e?"Feature toggle is deprecated.":"Feature toggle is active.",children:e?"Stale":"Active"})}),Mt=d("strong")({wordBreak:"break-all"}),Gi=()=>{const e=F("projectId"),n=F("featureId"),{archivedFeatures:a}=_a(),r=ja(e,{name:n});return a?a.some(s=>s.name===n)?l("p",{children:["The feature ",t(Mt,{children:n})," has been archived. You can find it on the"," ",t(X,{to:`/projects/${e}/archive`,children:"project archive page"}),"."]}):l("p",{children:["The feature ",t(Mt,{children:n})," does not exist. Would you like to"," ",t(X,{to:r,children:"create it"}),"?"]}):null},Yi=d("div")(({theme:e})=>({backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadiusLarge,marginBottom:e.spacing(2)})),Ki=d("div")(({theme:e})=>({padding:e.spacing(2,4,2,2),display:"flex",justifyContent:"space-between",alignItems:"center",[e.breakpoints.down(500)]:{flexDirection:"column"}})),Xi=d("div")({display:"flex",alignItems:"center"}),Ji=d("h1")(({theme:e})=>({fontSize:e.fontSizes.mainHeader,fontWeight:"normal",display:"flex",alignItems:"center",wordBreak:"break-all"})),Qi=d("div")({flexShrink:0,display:"flex"}),Zi=d("div")(({theme:e})=>({width:"100%",backgroundColor:e.palette.background.elevation2,height:"1px"})),el=d("div")(({theme:e})=>({padding:e.spacing(0,4)})),tl=d(Na)(({theme:e})=>({textTransform:"none",width:"auto",fontSize:e.fontSizes.bodySize,padding:"0 !important",[e.breakpoints.up("md")]:{minWidth:160}})),il=()=>{const e=F("projectId"),n=F("featureId"),{refetch:a}=cn(e),{favorite:r,unfavorite:o}=za(),{refetchFeature:s}=j(e,n),[i,c]=m.useState(!1),[u,p]=m.useState(!1),[g,h]=m.useState(!1),b=de(`(max-width:${500}px)`),{feature:S,loading:v,error:T,status:f}=j(e,n),y=ge(),{pathname:w}=Wa(),x=Ha(v),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(I=>I.path===w)??D[0],B=async()=>{S!=null&&S.favorite?await o(e,S.name):await r(e,S.name),s()};return f===404?t(Gi,{}):T!==void 0?t("div",{ref:x}):l("div",{ref:x,children:[l(Yi,{children:[l(Ki,{children:[l(Xi,{children:[t(qa,{onClick:B,isFavorite:S==null?void 0:S.favorite}),l(Ji,{"data-loading":!0,children:[S.name," "]}),t(A,{condition:!b,show:t(Ui,{stale:S==null?void 0:S.stale})})]}),l(Qi,{children:[t(K,{permission:Ua,projectId:e,"data-loading":!0,component:X,to:`/projects/${e}/features/${n}/strategies/copy`,tooltipProps:{title:"Copy feature toggle"},children:t(Ga,{})}),t(K,{permission:Ya,projectId:e,tooltipProps:{title:"Archive feature toggle"},"data-loading":!0,onClick:()=>p(!0),children:t(mo,{})}),t(K,{onClick:()=>h(!0),permission:ie,projectId:e,tooltipProps:{title:"Toggle stale state"},"data-loading":!0,children:t(So,{})}),t(K,{onClick:()=>c(!0),permission:ie,projectId:e,tooltipProps:{title:"Add tag"},"data-loading":!0,children:t(Ka,{})})]})]}),t(Zi,{}),t(el,{children:t(Xa,{value:$.path,indicatorColor:"primary",textColor:"primary",children:D.map(I=>t(tl,{label:I.title,value:I.path,onClick:()=>y(I.path)},I.title))})})]}),l(Kt,{children:[t(ne,{path:"metrics",element:t(Pi,{})}),t(ne,{path:"logs",element:t(Co,{})}),t(ne,{path:"variants",element:t(fi,{})}),t(ne,{path:"settings",element:t(qi,{})}),t(ne,{path:"*",element:t(gs,{})})]}),t(oo,{isOpen:u,onConfirm:()=>{a(),y(`/projects/${e}`)},onClose:()=>p(!1),projectId:e,featureId:n}),t(ro,{isStale:S.stale,isOpen:g,onClose:()=>{h(!1),s()},featureId:n,projectId:e}),t(yn,{open:i,setOpen:c})]})};export{il as default};
|