unleash-server 7.2.1 → 7.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/frontend/build/index.html +1 -1
  2. package/frontend/build/static/{AdvancedPlayground-CUkOz1YF.js → AdvancedPlayground-D2Y0O_LK.js} +1 -1
  3. package/frontend/build/static/{BackendConnections-Bi1Fsohi.js → BackendConnections-C9HcQ9To.js} +1 -1
  4. package/frontend/build/static/{ChartItem-Ci-KFL7s.js → ChartItem-COMyVdgD.js} +1 -1
  5. package/frontend/build/static/{CreateProject-COHPsP3X.js → CreateProject-jRfRrbUO.js} +1 -1
  6. package/frontend/build/static/{FeatureMetricsChart-ClbKeGOa.js → FeatureMetricsChart-CQkGp91T.js} +1 -1
  7. package/frontend/build/static/{FeatureStaleDialog-DZvKjxPB.js → FeatureStaleDialog-DKeGFuL1.js} +1 -1
  8. package/frontend/build/static/{FeatureViewLazyExport-yCIrczZt.js → FeatureViewLazyExport-CgntSCvS.js} +2 -2
  9. package/frontend/build/static/{FlagMetricsChart-D0GI-ltv.js → FlagMetricsChart-oDTQTkxU.js} +1 -1
  10. package/frontend/build/static/{FrontendNetworkTrafficUsage-DlRkx8CV.js → FrontendNetworkTrafficUsage-E4pIeMFQ.js} +1 -1
  11. package/frontend/build/static/{ImpactMetricsPage-BYcbHNWC.js → ImpactMetricsPage-B3STis_H.js} +1 -1
  12. package/frontend/build/static/{LazyAdminExport-BjSYZTvt.js → LazyAdminExport-CsCsRIwk.js} +2 -2
  13. package/frontend/build/static/{LazyProjectExport-9mNkV9Jq.js → LazyProjectExport-DkN0UegC.js} +2 -2
  14. package/frontend/build/static/{LifecycleChartComponent-BigwXcU3.js → LifecycleChartComponent-Dz1wdYkW.js} +1 -1
  15. package/frontend/build/static/{LineChartComponent-CPcDsiNa.js → LineChartComponent-DG1LdcL_.js} +1 -1
  16. package/frontend/build/static/{MarkCompletedDialogue-CS-kM4vW.js → MarkCompletedDialogue-Bw9Iccid.js} +1 -1
  17. package/frontend/build/static/{NetworkConnectedEdges-C2nfTRKM.js → NetworkConnectedEdges-HU923-QZ.js} +1 -1
  18. package/frontend/build/static/{NetworkOverview-BKozpi8w.js → NetworkOverview-_igGCPCJ.js} +1 -1
  19. package/frontend/build/static/{NetworkPrometheusAPIWarning-wqCXwcem.js → NetworkPrometheusAPIWarning-BS9PGbzI.js} +1 -1
  20. package/frontend/build/static/{NetworkTraffic-Co7oakIE.js → NetworkTraffic-BpNEMFBl.js} +1 -1
  21. package/frontend/build/static/{NetworkTrafficUsage-DNDJZGXi.js → NetworkTrafficUsage-bSUVPjoc.js} +1 -1
  22. package/frontend/build/static/{ReactJSONEditor-BDMT4-_1.js → ReactJSONEditor-DZ9l5V9S.js} +1 -1
  23. package/frontend/build/static/{RoleCell-COtuTPWk.js → RoleCell-C-hJFmul.js} +1 -1
  24. package/frontend/build/static/{aggregateFeatureMetrics-ClblY5Ev.js → aggregateFeatureMetrics-Dli6i5No.js} +1 -1
  25. package/frontend/build/static/{formatTickValue-DojfJagm.js → formatTickValue-D3KZyzeb.js} +1 -1
  26. package/frontend/build/static/{index-CqYZiU1N.js → index-A5We7bvX.js} +9 -9
  27. package/frontend/build/static/{networkTrafficUsageHighlightPlugin-BMMmh5e_.js → networkTrafficUsageHighlightPlugin-DLE_BBMN.js} +1 -1
  28. package/frontend/build/static/{useApiTokens-B6vbGXUF.js → useApiTokens-DNIDLJlc.js} +1 -1
  29. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{aG as ms,aH as js,_ as bt,aI as ma,a as K,aJ as qe,j as t,s as g,aK as ja,aL as ke,r as x,aM as bs,b as $e,aN as ht,aO as Ie,aP as vs,aQ as A,aR as W,aS as ba,V as Z,A as va,m as Ss,l as Cs,n as Sa,o as Ca,aT as Ts,u as vt,h as q,as as ie,aU as ue,aV as ce,e as H,aW as St,aX as te,aY as pe,B,T as M,C as L,aZ as Ta,L as ae,D as ye,J as wa,y as re,a_ as Ct,a$ as ka,M as Se,b0 as Ae,b1 as We,b2 as Ce,b3 as ws,b4 as He,b5 as J,b6 as ks,b7 as Lt,b8 as Ue,b9 as Te,ba as Rs,bb as Pe,bc as ge,bd as Ds,be as Ra,bf as Ge,bg as Da,bh as Tt,bi as we,t as As,bj as Es,bk as Is,bl as Aa,v as Ea,bm as Ia,bn as $a,i as ee,bo as Pa,bp as Fa,bq as Oa,br as _a,bs as $s,bt as le,am as Ba,bu as Ma,bv as La,bw as wt,bx as kt,by as ze,bz as za,bA as Va,N as Ee,bB as zt,bC as Na,bD as qa,bE as Wa,bF as Ha,bG as Fe,bH as Ua,bI as Ga,bJ as Ya,bK as Ps,bL as Ja,bM as Ka,bN as Qa,bO as Xa,bP as xe,bQ as Za,bR as en,bS as tn,bT as Rt,bU as sn,bV as an,bW as nn,bX as on,bY as rn,bZ as Fs,b_ as Os,b$ as _s,c0 as Ye,a3 as cn,c1 as ln,K as Dt,c2 as et,c3 as dn,c4 as Bs,c5 as pn,c6 as un,c7 as Je,c8 as gn,c9 as hn,ca as Ms,cb as xn,cc as Ke,cd as fn,ce as Ve,cf as Ls,cg as yn,al as Qe,ch as mn,ci as zs,cj as jn,ck as bn,cl as vn,cm as Sn,cn as Cn,co as Xe,cp as Tn,cq as Vs,cr as wn,cs as xt,ct as Ns,cu as kn,cv as Rn,cw as Dn,cx as An,cy as En,cz as In,cA as $n,cB as Pn,cC as De,cD as Fn,cE as On,a8 as _n,a9 as tt,aa as Vt,cF as Bn,cG as Mn,cH as Ln,cI as zn,cJ as Vn,cK as Nn,cL as qn,cM as Wn,cN as Hn,cO as Un,cP as Gn,cQ as qs,cR as Yn,cS as Ws,cT as Jn,cU as Kn,cV as Hs,cW as ve,cX as ft,cY as Qn,cZ as Us,E as Gs,c_ as Xn,c$ as Zn,f as eo,d0 as to,d1 as st,d2 as Nt,aF as so,d3 as Re,d4 as qt,d5 as ao,d6 as no,d7 as oo,aC as Ze,aD as At,ax as Wt,d8 as ro,d9 as io,da as co,x as Ys,db as lo,dc as Ht,dd as po,de as uo,G as Oe,H as _e,df as go,d as ho,dg as xo,dh as fo,di as yo,dj as mo,dk as jo,dl as bo,dm as vo,dn as So,dp as Co,dq as Ut,ak as Ne,dr as To,ac as at,ao as wo,ae as ko,af as Ro,ag as Do,ah as Ao,ai as Eo,aj as Io,ds as fe,dt as $o,du as Po,dv as Gt,dw as Fo,dx as Oo,dy as nt,dz as _o,dA as Bo,dB as Mo,dC as Lo,dD as zo,dE as Vo,au as No}from"./index-CqYZiU1N.js";import{u as qo,a as Wo,F as Et,M as Js}from"./MarkCompletedDialogue-CS-kM4vW.js";import{F as It,a as yt,u as Ks,b as Ho,c as Uo}from"./aggregateFeatureMetrics-ClblY5Ev.js";import{u as Go,a as Yo,T as Jo,b as Ko,c as Qo,d as Xo,F as Zo,C as er,e as tr,E as sr,f as ar,g as Yt,h as nr}from"./FeatureStaleDialog-DZvKjxPB.js";import{u as or,C as rr,a as ir}from"./ChartItem-Ci-KFL7s.js";function cr(e){return js("MuiPagination",e)}ms("MuiPagination",["root","ul","outlined","text"]);const lr=["boundaryCount","componentName","count","defaultPage","disabled","hideNextButton","hidePrevButton","onChange","page","showFirstButton","showLastButton","siblingCount"];function dr(e={}){const{boundaryCount:s=1,componentName:a="usePagination",count:n=1,defaultPage:o=1,disabled:r=!1,hideNextButton:i=!1,hidePrevButton:l=!1,onChange:c,page:u,showFirstButton:p=!1,showLastButton:d=!1,siblingCount:m=1}=e,j=bt(e,lr),[y,b]=ma({controlled:u,default:o,name:a,state:"page"}),h=(R,z)=>{u||b(z),c&&c(R,z)},f=(R,z)=>{const Y=z-R+1;return Array.from({length:Y},(Q,C)=>R+C)},T=f(1,Math.min(s,n)),E=f(Math.max(n-s+1,s+1),n),O=Math.max(Math.min(y-m,n-s-m*2-1),s+2),_=Math.min(Math.max(y+m,s+m*2+2),E.length>0?E[0]-2:n-1),$=[...p?["first"]:[],...l?[]:["previous"],...T,...O>s+2?["start-ellipsis"]:s+1<n-s?[s+1]:[],...f(O,_),..._<n-s-1?["end-ellipsis"]:n-s>s?[n-s]:[],...E,...i?[]:["next"],...d?["last"]:[]],D=R=>{switch(R){case"first":return 1;case"previous":return y-1;case"next":return y+1;case"last":return n;default:return null}},I=$.map(R=>typeof R=="number"?{onClick:z=>{h(z,R)},type:"page",page:R,selected:R===y,disabled:r,"aria-current":R===y?"true":void 0}:{onClick:z=>{h(z,D(R))},type:R,page:D(R),selected:!1,disabled:r||R.indexOf("ellipsis")===-1&&(R==="next"||R==="last"?y>=n:y<=1)});return K({items:I},j)}function pr(e){return js("MuiPaginationItem",e)}const se=ms("MuiPaginationItem",["root","page","sizeSmall","sizeLarge","text","textPrimary","textSecondary","outlined","outlinedPrimary","outlinedSecondary","rounded","ellipsis","firstLast","previousNext","focusVisible","disabled","selected","icon"]),Jt=qe(t.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"}),"FirstPage"),Kt=qe(t.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"}),"LastPage"),Qt=qe(t.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"}),"NavigateBefore"),Xt=qe(t.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}),"NavigateNext"),ur=["className","color","component","components","disabled","page","selected","shape","size","slots","type","variant"],Qs=(e,s)=>{const{ownerState:a}=e;return[s.root,s[a.variant],s[`size${Ie(a.size)}`],a.variant==="text"&&s[`text${Ie(a.color)}`],a.variant==="outlined"&&s[`outlined${Ie(a.color)}`],a.shape==="rounded"&&s.rounded,a.type==="page"&&s.page,(a.type==="start-ellipsis"||a.type==="end-ellipsis")&&s.ellipsis,(a.type==="previous"||a.type==="next")&&s.previousNext,(a.type==="first"||a.type==="last")&&s.firstLast]},gr=e=>{const{classes:s,color:a,disabled:n,selected:o,size:r,shape:i,type:l,variant:c}=e,u={root:["root",`size${Ie(r)}`,c,i,a!=="standard"&&`${c}${Ie(a)}`,n&&"disabled",o&&"selected",{page:"page",first:"firstLast",last:"firstLast","start-ellipsis":"ellipsis","end-ellipsis":"ellipsis",previous:"previousNext",next:"previousNext"}[l]],icon:["icon"]};return vs(u,pr,s)},hr=g("div",{name:"MuiPaginationItem",slot:"Root",overridesResolver:Qs})(({theme:e,ownerState:s})=>K({},e.typography.body2,{borderRadius:32/2,textAlign:"center",boxSizing:"border-box",minWidth:32,padding:"0 6px",margin:"0 3px",color:(e.vars||e).palette.text.primary,height:"auto",[`&.${se.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity}},s.size==="small"&&{minWidth:26,borderRadius:26/2,margin:"0 1px",padding:"0 4px"},s.size==="large"&&{minWidth:40,borderRadius:40/2,padding:"0 10px",fontSize:e.typography.pxToRem(15)})),xr=g(ja,{name:"MuiPaginationItem",slot:"Root",overridesResolver:Qs})(({theme:e,ownerState:s})=>K({},e.typography.body2,{borderRadius:32/2,textAlign:"center",boxSizing:"border-box",minWidth:32,height:32,padding:"0 6px",margin:"0 3px",color:(e.vars||e).palette.text.primary,[`&.${se.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${se.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},transition:e.transitions.create(["color","background-color"],{duration:e.transitions.duration.short}),"&:hover":{backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${se.selected}`]:{backgroundColor:(e.vars||e).palette.action.selected,"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette.action.selectedChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.hoverOpacity}))`:ke(e.palette.action.selected,e.palette.action.selectedOpacity+e.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:(e.vars||e).palette.action.selected}},[`&.${se.focusVisible}`]:{backgroundColor:e.vars?`rgba(${e.vars.palette.action.selectedChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.focusOpacity}))`:ke(e.palette.action.selected,e.palette.action.selectedOpacity+e.palette.action.focusOpacity)},[`&.${se.disabled}`]:{opacity:1,color:(e.vars||e).palette.action.disabled,backgroundColor:(e.vars||e).palette.action.selected}}},s.size==="small"&&{minWidth:26,height:26,borderRadius:26/2,margin:"0 1px",padding:"0 4px"},s.size==="large"&&{minWidth:40,height:40,borderRadius:40/2,padding:"0 10px",fontSize:e.typography.pxToRem(15)},s.shape==="rounded"&&{borderRadius:(e.vars||e).shape.borderRadius}),({theme:e,ownerState:s})=>K({},s.variant==="text"&&{[`&.${se.selected}`]:K({},s.color!=="standard"&&{color:(e.vars||e).palette[s.color].contrastText,backgroundColor:(e.vars||e).palette[s.color].main,"&:hover":{backgroundColor:(e.vars||e).palette[s.color].dark,"@media (hover: none)":{backgroundColor:(e.vars||e).palette[s.color].main}},[`&.${se.focusVisible}`]:{backgroundColor:(e.vars||e).palette[s.color].dark}},{[`&.${se.disabled}`]:{color:(e.vars||e).palette.action.disabled}})},s.variant==="outlined"&&{border:e.vars?`1px solid rgba(${e.vars.palette.common.onBackgroundChannel} / 0.23)`:`1px solid ${e.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)"}`,[`&.${se.selected}`]:K({},s.color!=="standard"&&{color:(e.vars||e).palette[s.color].main,border:`1px solid ${e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / 0.5)`:ke(e.palette[s.color].main,.5)}`,backgroundColor:e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / ${e.vars.palette.action.activatedOpacity})`:ke(e.palette[s.color].main,e.palette.action.activatedOpacity),"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / calc(${e.vars.palette.action.activatedOpacity} + ${e.vars.palette.action.focusOpacity}))`:ke(e.palette[s.color].main,e.palette.action.activatedOpacity+e.palette.action.focusOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${se.focusVisible}`]:{backgroundColor:e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / calc(${e.vars.palette.action.activatedOpacity} + ${e.vars.palette.action.focusOpacity}))`:ke(e.palette[s.color].main,e.palette.action.activatedOpacity+e.palette.action.focusOpacity)}},{[`&.${se.disabled}`]:{borderColor:(e.vars||e).palette.action.disabledBackground,color:(e.vars||e).palette.action.disabled}})})),fr=g("div",{name:"MuiPaginationItem",slot:"Icon",overridesResolver:(e,s)=>s.icon})(({theme:e,ownerState:s})=>K({fontSize:e.typography.pxToRem(20),margin:"0 -8px"},s.size==="small"&&{fontSize:e.typography.pxToRem(18)},s.size==="large"&&{fontSize:e.typography.pxToRem(22)})),yr=x.forwardRef(function(s,a){const n=bs({props:s,name:"MuiPaginationItem"}),{className:o,color:r="standard",component:i,components:l={},disabled:c=!1,page:u,selected:p=!1,shape:d="circular",size:m="medium",slots:j={},type:y="page",variant:b="text"}=n,h=bt(n,ur),f=K({},n,{color:r,disabled:c,selected:p,shape:d,size:m,type:y,variant:b}),T=$e(),E=gr(f),_=(T.direction==="rtl"?{previous:j.next||l.next||Xt,next:j.previous||l.previous||Qt,last:j.first||l.first||Jt,first:j.last||l.last||Kt}:{previous:j.previous||l.previous||Qt,next:j.next||l.next||Xt,first:j.first||l.first||Jt,last:j.last||l.last||Kt})[y];return y==="start-ellipsis"||y==="end-ellipsis"?t.jsx(hr,{ref:a,ownerState:f,className:ht(E.root,o),children:"…"}):t.jsxs(xr,K({ref:a,ownerState:f,component:i,disabled:c,className:ht(E.root,o)},h,{children:[y==="page"&&u,_?t.jsx(fr,{as:_,ownerState:f,className:E.icon}):null]}))}),mr=["boundaryCount","className","color","count","defaultPage","disabled","getItemAriaLabel","hideNextButton","hidePrevButton","onChange","page","renderItem","shape","showFirstButton","showLastButton","siblingCount","size","variant"],jr=e=>{const{classes:s,variant:a}=e;return vs({root:["root",a],ul:["ul"]},cr,s)},br=g("nav",{name:"MuiPagination",slot:"Root",overridesResolver:(e,s)=>{const{ownerState:a}=e;return[s.root,s[a.variant]]}})({}),vr=g("ul",{name:"MuiPagination",slot:"Ul",overridesResolver:(e,s)=>s.ul})({display:"flex",flexWrap:"wrap",alignItems:"center",padding:0,margin:0,listStyle:"none"});function Sr(e,s,a){return e==="page"?`${a?"":"Go to "}page ${s}`:`Go to ${e} page`}const Cr=x.forwardRef(function(s,a){const n=bs({props:s,name:"MuiPagination"}),{boundaryCount:o=1,className:r,color:i="standard",count:l=1,defaultPage:c=1,disabled:u=!1,getItemAriaLabel:p=Sr,hideNextButton:d=!1,hidePrevButton:m=!1,renderItem:j=I=>t.jsx(yr,K({},I)),shape:y="circular",showFirstButton:b=!1,showLastButton:h=!1,siblingCount:f=1,size:T="medium",variant:E="text"}=n,O=bt(n,mr),{items:_}=dr(K({},n,{componentName:"Pagination"})),$=K({},n,{boundaryCount:o,color:i,count:l,defaultPage:c,disabled:u,getItemAriaLabel:p,hideNextButton:d,hidePrevButton:m,renderItem:j,shape:y,showFirstButton:b,showLastButton:h,siblingCount:f,size:T,variant:E}),D=jr($);return t.jsx(br,K({"aria-label":"pagination navigation",className:ht(D.root,r),ownerState:$,ref:a},O,{children:t.jsx(vr,{className:D.ul,ownerState:$,children:_.map((I,R)=>t.jsx("li",{children:j(K({},I,{color:i,"aria-label":p(I.type,I.page,I.selected),shape:y,size:T,variant:E}))},R))})}))}),Tr=()=>{const e=A("projectId"),s=A("featureId"),{feature:a}=W(e,s);return a.name?t.jsx(ba,{title:"Event log",feature:s}):null},wr=()=>t.jsxs(Z,{severity:"warning",children:["Remember to update your Unleash client! Feature dependencies require new SDK versions. Read more about ",t.jsx(kr,{}),"."]}),kr=()=>t.jsx("a",{href:"https://docs.getunleash.io/reference/feature-toggles#feature-flag-dependencies",target:"_blank",rel:"noreferrer",children:"Client SDK support for feature dependencies"}),Rr=g(va)(({theme:e})=>({marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),Dr=({project:e,parent:s,onSelect:a,selectedValues:n})=>{const{parentVariantOptions:o}=qo(e,s),r=t.jsx(Sa,{fontSize:"small"}),i=t.jsx(Ca,{fontSize:"small"});return t.jsx(Rr,{multiple:!0,id:"parent-variant-options",options:o,disableCloseOnSelect:!0,renderOption:(l,c,{selected:u})=>t.jsxs("li",{...l,children:[t.jsx(Ss,{icon:r,checkedIcon:i,style:{marginRight:8},checked:u}),c]}),renderInput:l=>t.jsx(Cs,{...l,placeholder:"Select values"}),fullWidth:!0,value:n,onChange:(l,c)=>{a(c)}})},de={key:"none (remove dependency)",label:"none (remove dependency)"},Xs=g(Ts)(({theme:e})=>({marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),Ar=({onSelect:e,parentValue:s})=>t.jsx(Xs,{fullWidth:!0,options:[{key:"enabled",label:"enabled"},{key:"enabled_with_variants",label:"enabled with variants"},{key:"disabled",label:"disabled"}],value:s.status,onChange:e}),Zs=e=>{const{makeRequest:s,createRequest:a,errors:n,loading:o}=vt({propagateErrors:!0}),r=async(u,p)=>{const d=a(`/api/admin/projects/${e}/features/${u}/dependencies`,{method:"POST",body:JSON.stringify(p)});await s(d.caller,d.id)},i=async(u,p)=>{const d=a(`/api/admin/projects/${e}/features/${u}/dependencies/${p}`,{method:"DELETE"});await s(d.caller,d.id)},l=async u=>{const p=a(`/api/admin/projects/${e}/features/${u}/dependencies`,{method:"DELETE"});await s(p.caller,p.id)},c=[a,s,q,e];return{addDependency:x.useCallback(r,c),removeDependency:x.useCallback(i,c),removeDependencies:x.useCallback(l,c),errors:n,loading:o}},Er=(e,s,a,n,o)=>{const{trackEvent:r}=ie(),{addChange:i}=ue(),{refetch:l}=ce(e),{setToastData:c,setToastApiError:u}=H(),{refetchFeature:p}=W(e,s),d=St(e)(),{isChangeRequestConfiguredInAnyEnv:m}=te(e),{addDependency:j,removeDependencies:y}=Zs(e),b=async h=>{if(!d){console.error("No change request environment");return}h==="addDependency"&&(await i(e,d,[{action:h,feature:s,payload:{feature:a,enabled:n.status!=="disabled",variants:n.status==="enabled_with_variants"?n.variants:[]}}]),r("dependent_features",{props:{eventType:"dependency added"}})),h==="deleteDependency"&&await i(e,d,[{action:h,feature:s,payload:void 0}]),l(),c({type:"success",text:"Change added to draft"})};return async()=>{try{if(m()){const h=a===de.key?"deleteDependency":"addDependency";await b(h),r("dependent_features",{props:{eventType:h==="addDependency"?"add dependency added to change request":"delete dependency added to change request"}})}else a===de.key?(await y(s),r("dependent_features",{props:{eventType:"dependency removed"}}),c({text:"Dependency removed",type:"success"})):(await j(s,{feature:a,enabled:n.status!=="disabled",variants:n.status==="enabled_with_variants"?n.variants:[]}),r("dependent_features",{props:{eventType:"dependency added"}}),c({text:"Dependency added",type:"success"}))}catch(h){u(q(h))}p(),o()}},Ir=({project:e,featureId:s,parent:a,onSelect:n})=>{const{parentOptions:o}=Wo(e,s),r=o?[de,...o.map(i=>({key:i,label:i}))]:[de];return t.jsx(Xs,{fullWidth:!0,options:r,value:a,onChange:n})},$r=({project:e,featureId:s,parentDependency:a,showDependencyDialogue:n,onClose:o})=>{const[r,i]=x.useState((a==null?void 0:a.feature)||de.key),l=()=>{var f;return a?(f=a.variants)!=null&&f.length?{status:"enabled_with_variants",variants:a.variants}:a.enabled===!1?{status:"disabled"}:{status:"enabled"}:{status:"enabled"}},[c,u]=x.useState(l),p=()=>{i((a==null?void 0:a.feature)||de.key),u(l())};x.useEffect(()=>{p()},[JSON.stringify(a)]);const d=Er(e,s,r,c,o),{isChangeRequestConfiguredInAnyEnv:m}=te(e),j=r!==de.key,y=r!==de.key&&c.status==="enabled_with_variants",b=f=>{(f==="enabled"||f==="disabled")&&u({status:f}),f==="enabled_with_variants"&&u({status:f,variants:[]})},h=f=>{u({status:"enabled_with_variants",variants:f})};return t.jsx(pe,{open:n,title:"Add parent flag dependency",onClose:o,onClick:d,primaryButtonText:m()?"Add change to draft":r===de.key?"Remove":"Add",secondaryButtonText:"Cancel",children:t.jsxs(B,{children:[t.jsx(wr,{}),t.jsxs(B,{sx:{mt:2,mb:4},children:["Your feature will be evaluated only when the selected parent feature is"," ",t.jsx("b",{children:c.status==="disabled"?"disabled":"enabled"})," ","in the same environment."]}),t.jsxs(M,{children:["What ",t.jsx("b",{children:"feature"})," do you want to depend on?"]}),t.jsx(L,{condition:n,show:t.jsx(Ir,{project:e,featureId:s,parent:r,onSelect:f=>{u({status:"enabled"}),i(f)}})}),t.jsx(L,{condition:j,show:t.jsxs(B,{sx:{mt:2},children:[t.jsxs(M,{children:["What ",t.jsx("b",{children:"feature status"})," do you want to depend on?"]}),t.jsx(Ar,{parentValue:c,onSelect:b})]})}),t.jsx(L,{condition:y,show:c.status==="enabled_with_variants"&&t.jsxs(B,{sx:{mt:2},children:[t.jsxs(M,{children:["What ",t.jsx("b",{children:"variant"})," do you want to depend on?"]}),t.jsx(Dr,{parent:r,project:e,selectedValues:c.variants,onSelect:h})]})})]})})};g("div")({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"});g("div")(({theme:e})=>({justifyContent:"center",paddingTop:e.spacing(.75),...Ta}));g("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)}));const $t=g(ae)(({theme:e})=>({maxWidth:"100%",textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}})),Pr=g(ye)(({theme:e})=>({height:e.spacing(3.5),width:e.spacing(3.5)})),Fr=g(wa)(({theme:e})=>({borderRadius:e.shape.borderRadiusLarge,padding:e.spacing(1,1.5)})),ea=({capabilityId:e,feature:s,onEdit:a,onDelete:n})=>{const o=`${e}-${s}-actions`,r=`${o}-menu`,[i,l]=x.useState(null),c=!!i,u=d=>{l(d.currentTarget)},p=()=>{l(null)};return t.jsxs(B,{children:[t.jsx(re,{title:"Dependency actions",arrow:!0,describeChild:!0,children:t.jsx(Pr,{id:o,"aria-controls":c?r:void 0,"aria-haspopup":"true","aria-expanded":c?"true":void 0,onClick:u,type:"button",children:t.jsx(Ct,{})})}),t.jsx(Fr,{id:r,anchorEl:i,open:c,onClose:p,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,children:t.jsxs(ka,{"aria-labelledby":o,children:[t.jsxs(Se,{onClick:()=>{a(),p()},children:[t.jsx(Ae,{children:t.jsx(We,{})}),t.jsx(Ce,{children:t.jsx(M,{variant:"body2",children:"Edit"})})]}),t.jsxs(Se,{onClick:()=>{n(),p()},children:[t.jsx(Ae,{children:t.jsx(ws,{})}),t.jsx(Ce,{children:t.jsx(M,{variant:"body2",children:"Delete"})})]})]})})]})},Or=({childFeatures:e,project:s})=>t.jsx(He,{tooltip:t.jsx(t.Fragment,{children:e.map(a=>t.jsx($t,{to:`/projects/${s}/features/${a}`,children:t.jsx("div",{children:a})},`${s}-${a}`))}),children:e.length===1?"1 feature":`${e.length} features`}),_r=({variants:e})=>e.length===1&&e[0].length<20?t.jsx("span",{children:e[0]}):t.jsx(He,{tooltip:t.jsx(t.Fragment,{children:e.map((s,a)=>t.jsx("div",{children:s},a))}),children:e.length===1?"1 variant":`${e.length} variants`}),Br=g(J)(({theme:e})=>({fontSize:e.fontSizes.smallBody,lineHeight:e.typography.body1.lineHeight})),Mr=(e,s)=>{const{trackEvent:a}=ie(),{addChange:n}=ue(),{refetch:o}=ce(e),{setToastData:r,setToastApiError:i}=H(),{refetchFeature:l}=W(e,s),c=St(e)(),{isChangeRequestConfiguredInAnyEnv:u}=te(e),{removeDependencies:p}=Zs(e),d=async()=>{if(!c){console.error("No change request environment");return}await n(e,c,[{action:"deleteDependency",feature:s,payload:void 0}])};return async()=>{try{u()?(await d(),a("dependent_features",{props:{eventType:"delete dependency added to change request"}}),r({type:"success",text:"Change added to draft"}),await o()):(await p(s),a("dependent_features",{props:{eventType:"dependency removed"}}),r({text:"Dependency removed",type:"success"}),await l())}catch(j){i(q(j))}}},Lr=({feature:e})=>{var u,p,d,m,j,y,b;const[s,a]=x.useState(!1),n=!!e.project&&e.dependencies.length===0&&e.children.length===0,o=!!e.project&&e.dependencies.length>0,r=!!e.project&&e.children.length>0,i=St(e.project)(),l=ks(e.project),c=Mr(e.project,e.name);return t.jsxs(t.Fragment,{children:[n?t.jsxs(X,{children:[t.jsx(oe,{children:"Dependency:"}),t.jsx("div",{children:t.jsx(Br,{size:"small",permission:Lt,projectId:e.project,variant:"text",onClick:()=>{a(!0)},children:"Add parent flag"})})]}):null,o?t.jsxs(X,{children:[t.jsx(oe,{children:"Dependency:"}),t.jsxs(jt,{children:[t.jsx($t,{to:`/projects/${e.project}/features/${(u=e.dependencies[0])==null?void 0:u.feature}`,children:t.jsx(Ue,{title:(p=e.dependencies[0])==null?void 0:p.feature,children:(d=e.dependencies[0])==null?void 0:d.feature})}),l(Lt,i)?t.jsx(ea,{capabilityId:"dependency",feature:e.name,onEdit:()=>a(!0),onDelete:c}):null]})]}):null,o&&!((m=e.dependencies[0])!=null&&m.enabled)?t.jsxs(X,{children:[t.jsx(oe,{children:"Dependency value:"}),t.jsx("span",{children:"disabled"})]}):null,o&&((y=(j=e.dependencies[0])==null?void 0:j.variants)!=null&&y.length)?t.jsxs(X,{children:[t.jsx(oe,{children:"Dependency value:"}),t.jsx(_r,{variants:((b=e.dependencies[0])==null?void 0:b.variants)||[]})]}):null,r?t.jsxs(X,{children:[t.jsx(oe,{children:"Children:"}),t.jsx(Or,{childFeatures:e.children,project:e.project})]}):null,e.project?t.jsx($r,{project:e.project,featureId:e.name,parentDependency:e.dependencies[0],onClose:()=>a(!1),showDependencyDialogue:s}):null]})},zr=(e,s={})=>{const a=Te(`/api/admin/projects/${e}/dependencies`),{data:n,error:o}=Rs(e,!1,a,Vr,s);return{dependenciesExist:n,error:o,loading:!o&&!n}},Vr=async e=>await(await fetch(e).then(Pe("Dependencies exist check"))).json(),Nr=e=>{const{dependenciesExist:s}=zr(e),{isOss:a}=ge();return!!e&&!!(!a()||s)},ta=(e,s={})=>{const a=async()=>{const u=Te(`api/admin/features/${e}/tags`);return(await fetch(u,{method:"GET"}).then(Pe("Tags"))).json()},n=`api/admin/features/${e}/tags`,{data:o,error:r}=Rs(!!e,{tags:[]},n,a,s),[i,l]=x.useState(!r&&!o),c=()=>{Ds(n)};return x.useEffect(()=>{l(!r&&!o)},[o,r]),{tags:(o==null?void 0:o.tags)||[],error:r,loading:i,refetch:c}},qr=g("section")(({theme:e})=>({"& > *":{margin:e.spacing(1,0)}})),ot=e=>e.map(s=>({title:s.value})),Zt=(e,s)=>e.map(a=>({value:a.title,type:s})),sa=({open:e,setOpen:s})=>{const{tagTypes:a}=Ra(),n=A("featureId"),{createTag:o}=Go(),{updateFeatureTags:r,loading:i}=Ge(),{tags:l,refetch:c,loading:u}=ta(n),{setToastData:p}=H(),d=a&&a.length>0?a[0]:{name:"simple",description:"Simple tag to get you started",icon:""},[m,j]=x.useState(d),y=i||u,[b,h]=x.useState(0),{trackEvent:f}=ie(),[T,E]=x.useState(ot(l.filter(v=>v.type===m.name))),{tags:O,refetch:_}=Yo(m.name),$=x.useMemo(()=>ot(O),[O]);x.useEffect(()=>{l&&m&&E(ot(l.filter(v=>v.type===m.name)))},[JSON.stringify(l),m,e]);const D=()=>{s(!1),E([])};function I(v,S){const F=v.filter(N=>N.type===m.name).filter(N=>!S.find(k=>N.value===k.value&&N.type===k.type)),V=S.filter(N=>N.type===m.name).filter(N=>!v.find(k=>N.value===k.value&&N.type===k.type));return h(F.length+V.length),{added:F,removed:V}}const R=v=>v.filter(S=>!S.title.startsWith("Create")),z=async(v,S)=>{try{await r(n,{addedTags:v,removedTags:S}),await c()}catch{p({type:"error",text:"Failed to add tag"})}},Y=async v=>{v.preventDefault();const S=Zt(R(T),m.name),{added:F,removed:V}=I(S,l);b>0&&(await z(F,V),b>1&&f("suggest_tags",{props:{eventType:"multiple_tags_added"}}),b>0&&p({type:"success",text:`Updated tag${F.length>1?"s":""} to flag`})),h(0),E([]),s(!1)},Q=(v,S)=>{S!=null&&typeof S!="string"&&(v.preventDefault(),j(S),E([]),h(0))},C=(v,S,F)=>{const V=Da(S);F==="selectOption"&&S.forEach((k,ne)=>{if(typeof k!="string"&&k.inputValue&&k.inputValue!==""){const he={value:k.inputValue,type:m.name};o(he).then(()=>{f("suggest_tags",{props:{eventType:"tag_created"}}),_()}),k.title=k.inputValue,k.inputValue="",V[ne]=k}});const N=Zt(R(V),m.name);I(N,l),E(V)},P="add-tag-form";return t.jsx(pe,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update feature flag tags",onClick:Y,disabledPrimaryButton:y||b===0,onClose:D,formId:P,children:t.jsxs(t.Fragment,{children:[t.jsx(M,{paragraph:!0,sx:{marginBottom:v=>v.spacing(2.5)},children:"Tags allow you to group features together"}),t.jsx("form",{id:P,onSubmit:Y,children:t.jsxs(qr,{children:[t.jsx(Jo,{options:a,value:m,onChange:Q}),t.jsx(Ko,{options:$,existingTags:l,tagType:m,selectedOptions:T,onChange:C})]})})]})})},Wr=g(J)(({theme:e})=>({lineHeight:e.typography.body1.lineHeight,borderRadius:e.shape.borderRadiusExtraLarge,background:e.palette.secondary.light,padding:e.spacing(.5,1),height:e.spacing(3.5)})),Hr=g(Tt)(({theme:e})=>({fontSize:e.typography.body2.fontSize})),es=({project:e,onClick:s})=>t.jsx(Wr,{size:"small",permission:we,projectId:e,variant:"text",onClick:s,startIcon:t.jsx(Hr,{}),"data-loading":!0,children:"Add tag"}),ts=g("span")(({theme:e})=>({marginTop:e.spacing(1),color:e.palette.text.secondary,marginRight:e.spacing(1)})),Ur=g("div")(({theme:e})=>({display:"flex",justifyContent:"space-between",flexWrap:"wrap",minHeight:e.spacing(4.5),fontSize:e.fontSizes.smallBody})),ss=g("div")(({theme:e})=>({display:"flex",overflow:"hidden",gap:e.spacing(1),flexWrap:"wrap",marginTop:e.spacing(.75)}));g(As)(({theme:e})=>({overflowWrap:"anywhere",lineHeight:e.typography.body1.lineHeight,backgroundColor:e.palette.neutral.light,color:e.palette.text.primary,padding:e.spacing(.25),height:e.spacing(3.5)}));g("span")(({theme:e})=>({color:e.palette.text.secondary}));const Gr=({feature:e})=>{const{tags:s,refetch:a}=ta(e.name),{deleteTagFromFeature:n}=Ge(),[o,r]=x.useState(!1),[i,l]=x.useState(!1),[c,u]=x.useState(),{setToastData:p,setToastApiError:d}=H(),{hasAccess:m}=x.useContext(Es),j=m(we,e.project),y=()=>{r(!0)},b=async()=>{if(c)try{await n(e.name,c.type,c.value),a(),p({type:"success",text:"Tag removed"})}catch(h){d(q(h))}};return t.jsxs(t.Fragment,{children:[s.length?t.jsxs(Ur,{children:[t.jsx(ts,{children:"Tags:"}),t.jsxs(ss,{children:[s.map(h=>t.jsx(Yr,{tag:h,canUpdateTags:j,onTagRemove:f=>{l(!0),u(f)}},Is(h))),j?t.jsx(es,{project:e.project,onClick:y}):null]})]}):t.jsxs(X,{children:[t.jsx(ts,{children:"Tags:"}),t.jsx(ss,{children:t.jsx(es,{project:e.project,onClick:y})})]}),t.jsx(sa,{open:o,setOpen:r}),t.jsxs(pe,{open:i,primaryButtonText:"Remove tag",secondaryButtonText:"Cancel",onClose:()=>{l(!1),u(void 0),a()},onClick:()=>{l(!1),b(),u(void 0)},title:"Remove tag",children:["You are about to remove tag:"," ",t.jsxs("strong",{children:[c==null?void 0:c.type,":",c==null?void 0:c.value]})]})]})},Yr=({tag:e,canUpdateTags:s,onTagRemove:a})=>{const n=Is(e),o=n.length>25,r=s?()=>a(e):void 0,i=t.jsx(re,{title:"Remove tag",arrow:!0,children:t.jsx(Ea,{sx:{height:"20px",width:"20px"}})});return t.jsx(re,{title:o?n:"",arrow:!0,children:t.jsx("span",{children:t.jsx(Aa,{tag:e,onDelete:r,deleteIcon:i})})},n)},Jr=g(Ia)(({theme:e})=>({width:e.spacing(2.5),height:e.spacing(2.5)})),Kr=g($a)({flexWrap:"nowrap"}),Qr=({collaborators:e})=>!e||e.length===0?null:t.jsx(Kr,{users:e,avatarLimit:9,AvatarComponent:Jr}),Xr="environment-visibility-button",as="environment-visibility-menu",Zr=g("div")(({theme:e})=>({display:"flex",justifyContent:"center",paddingTop:e.spacing(4)})),ei=({environments:e,hiddenEnvironments:s,onChange:a})=>{const[n,o]=x.useState(null),r=!!n,i=d=>{o(d.currentTarget)},l=()=>{o(null)},c=e.map(d=>d.name),u=new Set(c.filter(d=>!s.includes(d))),p=d=>{a(d)};return t.jsxs(Zr,{children:[t.jsx(ee,{onClick:i,endIcon:r?t.jsx(Pa,{}):t.jsx(Fa,{}),variant:"outlined",id:Xr,"aria-controls":as,"aria-haspopup":"true","aria-expanded":r?"true":void 0,"data-loading":!0,children:"Hide/show environments"}),t.jsx(Oa,{id:as,open:!!n,anchorEl:n,onClose:l,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:t.jsx(_a,{multiselect:{selectedOptions:u},onChange:p,options:c.map(d=>({label:d,value:d})),search:{label:"Filter environments",placeholder:"Filter environments"}})})]})},aa=(e,s)=>{const{makeRequest:a,createRequest:n,errors:o,loading:r}=vt({propagateErrors:!0}),i=async p=>{const d=n(`/api/admin/projects/${e}/features/${s}/link`,{method:"POST",body:JSON.stringify(p)});await a(d.caller,d.id)},l=async(p,d)=>{const m=n(`/api/admin/projects/${e}/features/${s}/link/${p}`,{method:"PUT",body:JSON.stringify(d)});await a(m.caller,m.id)},c=async p=>{const d=n(`/api/admin/projects/${e}/features/${s}/link/${p}`,{method:"DELETE"});await a(d.caller,d.id)},u=[n,a,q,e];return{addLink:x.useCallback(i,u),editLink:x.useCallback(l,u),deleteLink:x.useCallback(c,u),errors:o,loading:r}},ns=g(Cs)(({theme:e})=>({width:"100%",marginTop:e.spacing(1),marginBottom:e.spacing(1)})),na=({showDialogue:e,onClose:s,project:a,featureId:n,mode:o,link:r})=>{const[i,l]=x.useState(""),[c,u]=x.useState(""),[p,d]=x.useState(""),{addLink:m,editLink:j,loading:y}=aa(a,n),{refetchFeature:b}=W(a,n),{setToastData:h,setToastApiError:f}=H(),T=o==="edit",E=T?"Edit link":"Add link",O=T?"Link updated":"Link added",{trackEvent:_}=ie();x.useEffect(()=>{T&&r?(l(r.url||""),u(r.title||""),d(r.id||"")):T||(l(""),u(""),d(""))},[T,r]);const $=async()=>{try{T?(await j(p,{url:i,title:c||null}),_("feature-links",{props:{eventType:"edit-link"}})):(await m({url:i,title:c||null}),_("feature-links",{props:{eventType:"add-link"}})),h({text:O,type:"success"}),s(),b(),u(""),l("")}catch(I){f(q(I))}},D=T?r!==null:e;return t.jsx(pe,{open:D,title:E,onClose:s,disabledPrimaryButton:i.trim()===""||y,onClick:$,primaryButtonText:"Save",secondaryButtonText:"Cancel",children:t.jsxs(B,{children:[t.jsx(ns,{label:"Link",placeholder:"https://",variant:"outlined",value:i,onChange:I=>l(I.target.value)}),t.jsx(ns,{label:"Title (optional)",variant:"outlined",value:c,onChange:I=>u(I.target.value)})]})})},ti=e=>t.jsx(na,{...e,mode:"add",link:null}),si=e=>t.jsx(na,{...e,mode:"edit",showDialogue:e.link!==null}),oa=g("div")(({theme:e})=>({padding:e.spacing(3),borderRadius:e.shape.borderRadiusLarge,backgroundColor:e.palette.background.paper,display:"flex",flexDirection:"column",gap:e.spacing(2),width:"350px",border:`1px solid ${e.palette.divider}`,[e.breakpoints.down("md")]:{width:"100%"},marginBottom:e.spacing(2)})),mt=g("h2")(({theme:e})=>({fontSize:e.typography.body1.fontSize,fontWeight:e.typography.fontWeightBold,marginBottom:e.spacing(.5)})),ai=g("div")({display:"flex",flexDirection:"column"}),X=g("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",minHeight:e.spacing(4.5),fontSize:e.fontSizes.smallBody})),oe=g("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)})),Be=g("span")({overflowWrap:"anywhere"}),jt=g("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1)})),ni=g(Ae)(({theme:e})=>({minWidth:e.spacing(5)})),oi=({links:e,project:s,feature:a})=>{const[n,o]=x.useState(!1),[r,i]=x.useState(null),{deleteLink:l,loading:c}=aa(s,a),{setToastData:u,setToastApiError:p}=H(),{refetchFeature:d}=W(s,a),m=t.jsx(J,{size:"small",startIcon:t.jsx(Tt,{}),permission:we,disabled:e.length>=10,projectId:s,variant:"text",onClick:()=>o(!0),children:"Add link"}),j=()=>t.jsx(kt,{children:e.map(h=>t.jsx(ze,{secondaryAction:t.jsx(ea,{capabilityId:"link",feature:a,onEdit:()=>{i(h)},onDelete:async()=>{try{await l(h.id),u({text:"Link removed",type:"success"}),d()}catch(f){p(q(f))}}}),disablePadding:!0,dense:!0,children:t.jsxs(za,{component:"a",href:h.url,target:"_blank",rel:"noopener noreferrer",disableGutters:!0,children:[t.jsx(ni,{children:t.jsx(Va,{color:"primary"})}),t.jsx(Ce,{primary:h.title,secondary:h.url,secondaryTypographyProps:{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block"}}})]})},h.id))}),y=t.jsxs(t.Fragment,{children:[t.jsxs(mt,{children:["You can now add links"," ",t.jsx(Ee,{color:"success",sx:{ml:1},children:"New"})]}),t.jsx(X,{children:"Gather relevant links for external resources such as issue trackers, code repositories or analytics tooling"}),t.jsx("div",{children:m})]}),b=t.jsxs(t.Fragment,{children:[t.jsx(mt,{children:"Resources"}),j(),t.jsx("div",{children:m})]});return t.jsxs(t.Fragment,{children:[t.jsx(oa,{children:e.length===0?y:b}),t.jsx(ti,{project:s,featureId:a,showDialogue:n,onClose:()=>o(!1)}),t.jsx(si,{project:s,featureId:a,link:r,onClose:()=>i(null)})]})},ri=({hiddenEnvironments:e,onEnvironmentVisibilityChange:s,feature:a,onChange:n})=>{var y,b,h,f;const{locationSettings:o}=$s(),r=le(),[i,l]=x.useState(!1),[c,u]=x.useState(!1),{project:p,description:d,type:m}=a,j=Nr(p);return t.jsxs(t.Fragment,{children:[t.jsx(oi,{links:a.links||[],project:a.project,feature:a.name}),t.jsxs(oa,{children:[t.jsxs("div",{children:[t.jsx(mt,{children:"Flag details"}),d?t.jsx(X,{"data-loading":!0,children:t.jsx(Be,{children:t.jsx(Ue,{arrow:!0,lines:5,title:d,children:d})})}):null]}),t.jsxs(ai,{children:[t.jsxs(X,{children:[t.jsx(oe,{children:"Flag type:"}),t.jsxs(Be,{"data-loading":!0,children:[Ba(m||" ")," flag"]})]}),a.lifecycle?t.jsxs(X,{"data-loading":!0,children:[t.jsx(oe,{children:"Lifecycle:"}),t.jsx(Ma,{feature:a,onArchive:()=>l(!0),onComplete:()=>u(!0),onUncomplete:n})]}):null,t.jsxs(X,{children:[t.jsx(oe,{children:"Created:"}),t.jsx(Be,{"data-loading":!0,children:La(wt(a.createdAt),o.locale)})]}),a.createdBy?t.jsxs(X,{children:[t.jsx(oe,{children:"Created by:"}),t.jsx(jt,{children:t.jsx(Be,{"data-loading":!0,children:(y=a.createdBy)==null?void 0:y.name})})]}):null,(b=a.collaborators)!=null&&b.users&&((h=a.collaborators)==null?void 0:h.users.length)>0?t.jsxs(X,{children:[t.jsx(oe,{children:"Collaborators:"}),t.jsx(jt,{children:t.jsx(Qr,{collaborators:(f=a.collaborators)==null?void 0:f.users})})]}):null,j?t.jsx(Lr,{feature:a}):null,t.jsx(Gr,{feature:a}),s?t.jsx(ei,{environments:a.environments||[],hiddenEnvironments:e||[],onChange:s}):null]})]}),a.children.length>0?t.jsx(It,{features:a.children,project:a.project,isOpen:i,onClose:()=>l(!1)}):t.jsx(Et,{isOpen:i,onConfirm:()=>{r(`/projects/${a.project}`)},onClose:()=>l(!1),projectId:a.project,featureIds:[a.name]}),a.project?t.jsx(Js,{isOpen:c,setIsOpen:u,projectId:a.project,featureId:a.name,onComplete:n}):null]})},ii=e=>{var o;const{uiConfig:s}=ge(),a=((o=s.resourceLimits)==null?void 0:o.featureEnvironmentStrategies)||100,n=e>=a;return{limit:a,limitReached:n}},ci=()=>{const[e,s]=x.useState(0),a=A("projectId"),n=A("featureId"),o=zt("environmentId"),r=zt("strategyName"),{strategy:i,defaultStrategyFallback:l}=Qo(a,o),c=JSON.parse(Na().get("defaultStrategy")||"false"),{segments:u}=qa(),p=(u||[]).filter(G=>{var be;return(be=i==null?void 0:i.segments)==null?void 0:be.includes(G.id)}),[d,m]=x.useState({}),[j,y]=x.useState(c?p:[]),{strategyDefinition:b}=Wa(r),h=Ha(),{addStrategyToFeature:f,loading:T}=Fe(),{addChange:E}=ue(),{setToastData:O,setToastApiError:_}=H(),{uiConfig:$}=ge(),{unleashUrl:D}=$,I=le(),{feature:R,refetchFeature:z}=W(a,n),Y=R==null?void 0:R.environments.find(G=>G.name===o),Q=(Y==null?void 0:Y.strategies.length)||0,{limit:C,limitReached:P}=ii(Q),v=x.useRef(R),{isChangeRequestConfigured:S}=te(a),{refetch:F}=ce(a),{trackEvent:V}=ie(),{data:N,staleDataNotification:k,forceRefreshCache:ne}=Ua({unleashGetter:W,params:[a,n],dataKey:"feature",refetchFunctionKey:"refetchFeature",options:{}},R,{afterSubmitAction:z},sn);x.useEffect(()=>{v.current.name===""&&R.name&&(ne(R),v.current=R)},[R.name]),x.useEffect(()=>{var G;if(c){const be=i||l;((G=be.parameters)==null?void 0:G.groupId)===""&&n?m({...be,parameters:{...be.parameters,groupId:n}}):m(be)}else b&&m(Ga(n,b))},[n,JSON.stringify(b),JSON.stringify(i),c]);const he=async G=>{await f(a,n,o,G),O({text:"Strategy created",type:"success"})},me=async G=>{await E(a,o,{action:"addStrategy",feature:n,payload:G}),O({text:"Strategy added to draft",type:"success"}),F()},w=Ya(d,j),U=async()=>{V("strategyTitle",{props:{hasTitle:!!d.title,on:"create"}});try{S(o)?await me(w):await he(w),z(),I(Rt(a,n))}catch(G){_(q(G))}};return!N||!N.project?null:t.jsxs(Ps,{modal:!0,description:Ja,documentationLink:Ka,documentationLinkLabel:Qa,disablePadding:!0,formatApiCode:()=>li(a,n,o,w,D),children:[t.jsx(Xa,{projectId:a,feature:N,strategy:d,setStrategy:m,segments:j,setSegments:y,environmentId:o,onSubmit:U,loading:T,permission:xe,errors:h,isChangeRequest:S(o),tab:e,setTab:s,StrategyVariants:t.jsx(Za,{strategy:d,setStrategy:m,environment:o,projectId:a,editable:!0}),Limit:t.jsx(en,{name:"strategies in this environment",shortName:"strategies",currentValue:Q,limit:C}),disabled:P}),k]})},ra=(e,s,a,n,o=!1)=>{const r=new URLSearchParams({environmentId:a,strategyName:n,defaultStrategy:String(o)});return`/projects/${e}/features/${s}/strategies/create?${r}`},li=(e,s,a,n,o)=>{if(!o)return"";const r=`${o}/api/admin/projects/${e}/features/${s}/environments/${a}/strategies`,i=JSON.stringify(n,tn,2);return`curl --location --request POST '${r}' \\
1
+ import{aG as ms,aH as js,_ as bt,aI as ma,a as K,aJ as qe,j as t,s as g,aK as ja,aL as ke,r as x,aM as bs,b as $e,aN as ht,aO as Ie,aP as vs,aQ as A,aR as W,aS as ba,V as Z,A as va,m as Ss,l as Cs,n as Sa,o as Ca,aT as Ts,u as vt,h as q,as as ie,aU as ue,aV as ce,e as H,aW as St,aX as te,aY as pe,B,T as M,C as L,aZ as Ta,L as ae,D as ye,J as wa,y as re,a_ as Ct,a$ as ka,M as Se,b0 as Ae,b1 as We,b2 as Ce,b3 as ws,b4 as He,b5 as J,b6 as ks,b7 as Lt,b8 as Ue,b9 as Te,ba as Rs,bb as Pe,bc as ge,bd as Ds,be as Ra,bf as Ge,bg as Da,bh as Tt,bi as we,t as As,bj as Es,bk as Is,bl as Aa,v as Ea,bm as Ia,bn as $a,i as ee,bo as Pa,bp as Fa,bq as Oa,br as _a,bs as $s,bt as le,am as Ba,bu as Ma,bv as La,bw as wt,bx as kt,by as ze,bz as za,bA as Va,N as Ee,bB as zt,bC as Na,bD as qa,bE as Wa,bF as Ha,bG as Fe,bH as Ua,bI as Ga,bJ as Ya,bK as Ps,bL as Ja,bM as Ka,bN as Qa,bO as Xa,bP as xe,bQ as Za,bR as en,bS as tn,bT as Rt,bU as sn,bV as an,bW as nn,bX as on,bY as rn,bZ as Fs,b_ as Os,b$ as _s,c0 as Ye,a3 as cn,c1 as ln,K as Dt,c2 as et,c3 as dn,c4 as Bs,c5 as pn,c6 as un,c7 as Je,c8 as gn,c9 as hn,ca as Ms,cb as xn,cc as Ke,cd as fn,ce as Ve,cf as Ls,cg as yn,al as Qe,ch as mn,ci as zs,cj as jn,ck as bn,cl as vn,cm as Sn,cn as Cn,co as Xe,cp as Tn,cq as Vs,cr as wn,cs as xt,ct as Ns,cu as kn,cv as Rn,cw as Dn,cx as An,cy as En,cz as In,cA as $n,cB as Pn,cC as De,cD as Fn,cE as On,a8 as _n,a9 as tt,aa as Vt,cF as Bn,cG as Mn,cH as Ln,cI as zn,cJ as Vn,cK as Nn,cL as qn,cM as Wn,cN as Hn,cO as Un,cP as Gn,cQ as qs,cR as Yn,cS as Ws,cT as Jn,cU as Kn,cV as Hs,cW as ve,cX as ft,cY as Qn,cZ as Us,E as Gs,c_ as Xn,c$ as Zn,f as eo,d0 as to,d1 as st,d2 as Nt,aF as so,d3 as Re,d4 as qt,d5 as ao,d6 as no,d7 as oo,aC as Ze,aD as At,ax as Wt,d8 as ro,d9 as io,da as co,x as Ys,db as lo,dc as Ht,dd as po,de as uo,G as Oe,H as _e,df as go,d as ho,dg as xo,dh as fo,di as yo,dj as mo,dk as jo,dl as bo,dm as vo,dn as So,dp as Co,dq as Ut,ak as Ne,dr as To,ac as at,ao as wo,ae as ko,af as Ro,ag as Do,ah as Ao,ai as Eo,aj as Io,ds as fe,dt as $o,du as Po,dv as Gt,dw as Fo,dx as Oo,dy as nt,dz as _o,dA as Bo,dB as Mo,dC as Lo,dD as zo,dE as Vo,au as No}from"./index-A5We7bvX.js";import{u as qo,a as Wo,F as Et,M as Js}from"./MarkCompletedDialogue-Bw9Iccid.js";import{F as It,a as yt,u as Ks,b as Ho,c as Uo}from"./aggregateFeatureMetrics-Dli6i5No.js";import{u as Go,a as Yo,T as Jo,b as Ko,c as Qo,d as Xo,F as Zo,C as er,e as tr,E as sr,f as ar,g as Yt,h as nr}from"./FeatureStaleDialog-DKeGFuL1.js";import{u as or,C as rr,a as ir}from"./ChartItem-COMyVdgD.js";function cr(e){return js("MuiPagination",e)}ms("MuiPagination",["root","ul","outlined","text"]);const lr=["boundaryCount","componentName","count","defaultPage","disabled","hideNextButton","hidePrevButton","onChange","page","showFirstButton","showLastButton","siblingCount"];function dr(e={}){const{boundaryCount:s=1,componentName:a="usePagination",count:n=1,defaultPage:o=1,disabled:r=!1,hideNextButton:i=!1,hidePrevButton:l=!1,onChange:c,page:u,showFirstButton:p=!1,showLastButton:d=!1,siblingCount:m=1}=e,j=bt(e,lr),[y,b]=ma({controlled:u,default:o,name:a,state:"page"}),h=(R,z)=>{u||b(z),c&&c(R,z)},f=(R,z)=>{const Y=z-R+1;return Array.from({length:Y},(Q,C)=>R+C)},T=f(1,Math.min(s,n)),E=f(Math.max(n-s+1,s+1),n),O=Math.max(Math.min(y-m,n-s-m*2-1),s+2),_=Math.min(Math.max(y+m,s+m*2+2),E.length>0?E[0]-2:n-1),$=[...p?["first"]:[],...l?[]:["previous"],...T,...O>s+2?["start-ellipsis"]:s+1<n-s?[s+1]:[],...f(O,_),..._<n-s-1?["end-ellipsis"]:n-s>s?[n-s]:[],...E,...i?[]:["next"],...d?["last"]:[]],D=R=>{switch(R){case"first":return 1;case"previous":return y-1;case"next":return y+1;case"last":return n;default:return null}},I=$.map(R=>typeof R=="number"?{onClick:z=>{h(z,R)},type:"page",page:R,selected:R===y,disabled:r,"aria-current":R===y?"true":void 0}:{onClick:z=>{h(z,D(R))},type:R,page:D(R),selected:!1,disabled:r||R.indexOf("ellipsis")===-1&&(R==="next"||R==="last"?y>=n:y<=1)});return K({items:I},j)}function pr(e){return js("MuiPaginationItem",e)}const se=ms("MuiPaginationItem",["root","page","sizeSmall","sizeLarge","text","textPrimary","textSecondary","outlined","outlinedPrimary","outlinedSecondary","rounded","ellipsis","firstLast","previousNext","focusVisible","disabled","selected","icon"]),Jt=qe(t.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"}),"FirstPage"),Kt=qe(t.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"}),"LastPage"),Qt=qe(t.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"}),"NavigateBefore"),Xt=qe(t.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}),"NavigateNext"),ur=["className","color","component","components","disabled","page","selected","shape","size","slots","type","variant"],Qs=(e,s)=>{const{ownerState:a}=e;return[s.root,s[a.variant],s[`size${Ie(a.size)}`],a.variant==="text"&&s[`text${Ie(a.color)}`],a.variant==="outlined"&&s[`outlined${Ie(a.color)}`],a.shape==="rounded"&&s.rounded,a.type==="page"&&s.page,(a.type==="start-ellipsis"||a.type==="end-ellipsis")&&s.ellipsis,(a.type==="previous"||a.type==="next")&&s.previousNext,(a.type==="first"||a.type==="last")&&s.firstLast]},gr=e=>{const{classes:s,color:a,disabled:n,selected:o,size:r,shape:i,type:l,variant:c}=e,u={root:["root",`size${Ie(r)}`,c,i,a!=="standard"&&`${c}${Ie(a)}`,n&&"disabled",o&&"selected",{page:"page",first:"firstLast",last:"firstLast","start-ellipsis":"ellipsis","end-ellipsis":"ellipsis",previous:"previousNext",next:"previousNext"}[l]],icon:["icon"]};return vs(u,pr,s)},hr=g("div",{name:"MuiPaginationItem",slot:"Root",overridesResolver:Qs})(({theme:e,ownerState:s})=>K({},e.typography.body2,{borderRadius:32/2,textAlign:"center",boxSizing:"border-box",minWidth:32,padding:"0 6px",margin:"0 3px",color:(e.vars||e).palette.text.primary,height:"auto",[`&.${se.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity}},s.size==="small"&&{minWidth:26,borderRadius:26/2,margin:"0 1px",padding:"0 4px"},s.size==="large"&&{minWidth:40,borderRadius:40/2,padding:"0 10px",fontSize:e.typography.pxToRem(15)})),xr=g(ja,{name:"MuiPaginationItem",slot:"Root",overridesResolver:Qs})(({theme:e,ownerState:s})=>K({},e.typography.body2,{borderRadius:32/2,textAlign:"center",boxSizing:"border-box",minWidth:32,height:32,padding:"0 6px",margin:"0 3px",color:(e.vars||e).palette.text.primary,[`&.${se.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${se.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},transition:e.transitions.create(["color","background-color"],{duration:e.transitions.duration.short}),"&:hover":{backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${se.selected}`]:{backgroundColor:(e.vars||e).palette.action.selected,"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette.action.selectedChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.hoverOpacity}))`:ke(e.palette.action.selected,e.palette.action.selectedOpacity+e.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:(e.vars||e).palette.action.selected}},[`&.${se.focusVisible}`]:{backgroundColor:e.vars?`rgba(${e.vars.palette.action.selectedChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.focusOpacity}))`:ke(e.palette.action.selected,e.palette.action.selectedOpacity+e.palette.action.focusOpacity)},[`&.${se.disabled}`]:{opacity:1,color:(e.vars||e).palette.action.disabled,backgroundColor:(e.vars||e).palette.action.selected}}},s.size==="small"&&{minWidth:26,height:26,borderRadius:26/2,margin:"0 1px",padding:"0 4px"},s.size==="large"&&{minWidth:40,height:40,borderRadius:40/2,padding:"0 10px",fontSize:e.typography.pxToRem(15)},s.shape==="rounded"&&{borderRadius:(e.vars||e).shape.borderRadius}),({theme:e,ownerState:s})=>K({},s.variant==="text"&&{[`&.${se.selected}`]:K({},s.color!=="standard"&&{color:(e.vars||e).palette[s.color].contrastText,backgroundColor:(e.vars||e).palette[s.color].main,"&:hover":{backgroundColor:(e.vars||e).palette[s.color].dark,"@media (hover: none)":{backgroundColor:(e.vars||e).palette[s.color].main}},[`&.${se.focusVisible}`]:{backgroundColor:(e.vars||e).palette[s.color].dark}},{[`&.${se.disabled}`]:{color:(e.vars||e).palette.action.disabled}})},s.variant==="outlined"&&{border:e.vars?`1px solid rgba(${e.vars.palette.common.onBackgroundChannel} / 0.23)`:`1px solid ${e.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)"}`,[`&.${se.selected}`]:K({},s.color!=="standard"&&{color:(e.vars||e).palette[s.color].main,border:`1px solid ${e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / 0.5)`:ke(e.palette[s.color].main,.5)}`,backgroundColor:e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / ${e.vars.palette.action.activatedOpacity})`:ke(e.palette[s.color].main,e.palette.action.activatedOpacity),"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / calc(${e.vars.palette.action.activatedOpacity} + ${e.vars.palette.action.focusOpacity}))`:ke(e.palette[s.color].main,e.palette.action.activatedOpacity+e.palette.action.focusOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${se.focusVisible}`]:{backgroundColor:e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / calc(${e.vars.palette.action.activatedOpacity} + ${e.vars.palette.action.focusOpacity}))`:ke(e.palette[s.color].main,e.palette.action.activatedOpacity+e.palette.action.focusOpacity)}},{[`&.${se.disabled}`]:{borderColor:(e.vars||e).palette.action.disabledBackground,color:(e.vars||e).palette.action.disabled}})})),fr=g("div",{name:"MuiPaginationItem",slot:"Icon",overridesResolver:(e,s)=>s.icon})(({theme:e,ownerState:s})=>K({fontSize:e.typography.pxToRem(20),margin:"0 -8px"},s.size==="small"&&{fontSize:e.typography.pxToRem(18)},s.size==="large"&&{fontSize:e.typography.pxToRem(22)})),yr=x.forwardRef(function(s,a){const n=bs({props:s,name:"MuiPaginationItem"}),{className:o,color:r="standard",component:i,components:l={},disabled:c=!1,page:u,selected:p=!1,shape:d="circular",size:m="medium",slots:j={},type:y="page",variant:b="text"}=n,h=bt(n,ur),f=K({},n,{color:r,disabled:c,selected:p,shape:d,size:m,type:y,variant:b}),T=$e(),E=gr(f),_=(T.direction==="rtl"?{previous:j.next||l.next||Xt,next:j.previous||l.previous||Qt,last:j.first||l.first||Jt,first:j.last||l.last||Kt}:{previous:j.previous||l.previous||Qt,next:j.next||l.next||Xt,first:j.first||l.first||Jt,last:j.last||l.last||Kt})[y];return y==="start-ellipsis"||y==="end-ellipsis"?t.jsx(hr,{ref:a,ownerState:f,className:ht(E.root,o),children:"…"}):t.jsxs(xr,K({ref:a,ownerState:f,component:i,disabled:c,className:ht(E.root,o)},h,{children:[y==="page"&&u,_?t.jsx(fr,{as:_,ownerState:f,className:E.icon}):null]}))}),mr=["boundaryCount","className","color","count","defaultPage","disabled","getItemAriaLabel","hideNextButton","hidePrevButton","onChange","page","renderItem","shape","showFirstButton","showLastButton","siblingCount","size","variant"],jr=e=>{const{classes:s,variant:a}=e;return vs({root:["root",a],ul:["ul"]},cr,s)},br=g("nav",{name:"MuiPagination",slot:"Root",overridesResolver:(e,s)=>{const{ownerState:a}=e;return[s.root,s[a.variant]]}})({}),vr=g("ul",{name:"MuiPagination",slot:"Ul",overridesResolver:(e,s)=>s.ul})({display:"flex",flexWrap:"wrap",alignItems:"center",padding:0,margin:0,listStyle:"none"});function Sr(e,s,a){return e==="page"?`${a?"":"Go to "}page ${s}`:`Go to ${e} page`}const Cr=x.forwardRef(function(s,a){const n=bs({props:s,name:"MuiPagination"}),{boundaryCount:o=1,className:r,color:i="standard",count:l=1,defaultPage:c=1,disabled:u=!1,getItemAriaLabel:p=Sr,hideNextButton:d=!1,hidePrevButton:m=!1,renderItem:j=I=>t.jsx(yr,K({},I)),shape:y="circular",showFirstButton:b=!1,showLastButton:h=!1,siblingCount:f=1,size:T="medium",variant:E="text"}=n,O=bt(n,mr),{items:_}=dr(K({},n,{componentName:"Pagination"})),$=K({},n,{boundaryCount:o,color:i,count:l,defaultPage:c,disabled:u,getItemAriaLabel:p,hideNextButton:d,hidePrevButton:m,renderItem:j,shape:y,showFirstButton:b,showLastButton:h,siblingCount:f,size:T,variant:E}),D=jr($);return t.jsx(br,K({"aria-label":"pagination navigation",className:ht(D.root,r),ownerState:$,ref:a},O,{children:t.jsx(vr,{className:D.ul,ownerState:$,children:_.map((I,R)=>t.jsx("li",{children:j(K({},I,{color:i,"aria-label":p(I.type,I.page,I.selected),shape:y,size:T,variant:E}))},R))})}))}),Tr=()=>{const e=A("projectId"),s=A("featureId"),{feature:a}=W(e,s);return a.name?t.jsx(ba,{title:"Event log",feature:s}):null},wr=()=>t.jsxs(Z,{severity:"warning",children:["Remember to update your Unleash client! Feature dependencies require new SDK versions. Read more about ",t.jsx(kr,{}),"."]}),kr=()=>t.jsx("a",{href:"https://docs.getunleash.io/reference/feature-toggles#feature-flag-dependencies",target:"_blank",rel:"noreferrer",children:"Client SDK support for feature dependencies"}),Rr=g(va)(({theme:e})=>({marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),Dr=({project:e,parent:s,onSelect:a,selectedValues:n})=>{const{parentVariantOptions:o}=qo(e,s),r=t.jsx(Sa,{fontSize:"small"}),i=t.jsx(Ca,{fontSize:"small"});return t.jsx(Rr,{multiple:!0,id:"parent-variant-options",options:o,disableCloseOnSelect:!0,renderOption:(l,c,{selected:u})=>t.jsxs("li",{...l,children:[t.jsx(Ss,{icon:r,checkedIcon:i,style:{marginRight:8},checked:u}),c]}),renderInput:l=>t.jsx(Cs,{...l,placeholder:"Select values"}),fullWidth:!0,value:n,onChange:(l,c)=>{a(c)}})},de={key:"none (remove dependency)",label:"none (remove dependency)"},Xs=g(Ts)(({theme:e})=>({marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),Ar=({onSelect:e,parentValue:s})=>t.jsx(Xs,{fullWidth:!0,options:[{key:"enabled",label:"enabled"},{key:"enabled_with_variants",label:"enabled with variants"},{key:"disabled",label:"disabled"}],value:s.status,onChange:e}),Zs=e=>{const{makeRequest:s,createRequest:a,errors:n,loading:o}=vt({propagateErrors:!0}),r=async(u,p)=>{const d=a(`/api/admin/projects/${e}/features/${u}/dependencies`,{method:"POST",body:JSON.stringify(p)});await s(d.caller,d.id)},i=async(u,p)=>{const d=a(`/api/admin/projects/${e}/features/${u}/dependencies/${p}`,{method:"DELETE"});await s(d.caller,d.id)},l=async u=>{const p=a(`/api/admin/projects/${e}/features/${u}/dependencies`,{method:"DELETE"});await s(p.caller,p.id)},c=[a,s,q,e];return{addDependency:x.useCallback(r,c),removeDependency:x.useCallback(i,c),removeDependencies:x.useCallback(l,c),errors:n,loading:o}},Er=(e,s,a,n,o)=>{const{trackEvent:r}=ie(),{addChange:i}=ue(),{refetch:l}=ce(e),{setToastData:c,setToastApiError:u}=H(),{refetchFeature:p}=W(e,s),d=St(e)(),{isChangeRequestConfiguredInAnyEnv:m}=te(e),{addDependency:j,removeDependencies:y}=Zs(e),b=async h=>{if(!d){console.error("No change request environment");return}h==="addDependency"&&(await i(e,d,[{action:h,feature:s,payload:{feature:a,enabled:n.status!=="disabled",variants:n.status==="enabled_with_variants"?n.variants:[]}}]),r("dependent_features",{props:{eventType:"dependency added"}})),h==="deleteDependency"&&await i(e,d,[{action:h,feature:s,payload:void 0}]),l(),c({type:"success",text:"Change added to draft"})};return async()=>{try{if(m()){const h=a===de.key?"deleteDependency":"addDependency";await b(h),r("dependent_features",{props:{eventType:h==="addDependency"?"add dependency added to change request":"delete dependency added to change request"}})}else a===de.key?(await y(s),r("dependent_features",{props:{eventType:"dependency removed"}}),c({text:"Dependency removed",type:"success"})):(await j(s,{feature:a,enabled:n.status!=="disabled",variants:n.status==="enabled_with_variants"?n.variants:[]}),r("dependent_features",{props:{eventType:"dependency added"}}),c({text:"Dependency added",type:"success"}))}catch(h){u(q(h))}p(),o()}},Ir=({project:e,featureId:s,parent:a,onSelect:n})=>{const{parentOptions:o}=Wo(e,s),r=o?[de,...o.map(i=>({key:i,label:i}))]:[de];return t.jsx(Xs,{fullWidth:!0,options:r,value:a,onChange:n})},$r=({project:e,featureId:s,parentDependency:a,showDependencyDialogue:n,onClose:o})=>{const[r,i]=x.useState((a==null?void 0:a.feature)||de.key),l=()=>{var f;return a?(f=a.variants)!=null&&f.length?{status:"enabled_with_variants",variants:a.variants}:a.enabled===!1?{status:"disabled"}:{status:"enabled"}:{status:"enabled"}},[c,u]=x.useState(l),p=()=>{i((a==null?void 0:a.feature)||de.key),u(l())};x.useEffect(()=>{p()},[JSON.stringify(a)]);const d=Er(e,s,r,c,o),{isChangeRequestConfiguredInAnyEnv:m}=te(e),j=r!==de.key,y=r!==de.key&&c.status==="enabled_with_variants",b=f=>{(f==="enabled"||f==="disabled")&&u({status:f}),f==="enabled_with_variants"&&u({status:f,variants:[]})},h=f=>{u({status:"enabled_with_variants",variants:f})};return t.jsx(pe,{open:n,title:"Add parent flag dependency",onClose:o,onClick:d,primaryButtonText:m()?"Add change to draft":r===de.key?"Remove":"Add",secondaryButtonText:"Cancel",children:t.jsxs(B,{children:[t.jsx(wr,{}),t.jsxs(B,{sx:{mt:2,mb:4},children:["Your feature will be evaluated only when the selected parent feature is"," ",t.jsx("b",{children:c.status==="disabled"?"disabled":"enabled"})," ","in the same environment."]}),t.jsxs(M,{children:["What ",t.jsx("b",{children:"feature"})," do you want to depend on?"]}),t.jsx(L,{condition:n,show:t.jsx(Ir,{project:e,featureId:s,parent:r,onSelect:f=>{u({status:"enabled"}),i(f)}})}),t.jsx(L,{condition:j,show:t.jsxs(B,{sx:{mt:2},children:[t.jsxs(M,{children:["What ",t.jsx("b",{children:"feature status"})," do you want to depend on?"]}),t.jsx(Ar,{parentValue:c,onSelect:b})]})}),t.jsx(L,{condition:y,show:c.status==="enabled_with_variants"&&t.jsxs(B,{sx:{mt:2},children:[t.jsxs(M,{children:["What ",t.jsx("b",{children:"variant"})," do you want to depend on?"]}),t.jsx(Dr,{parent:r,project:e,selectedValues:c.variants,onSelect:h})]})})]})})};g("div")({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"});g("div")(({theme:e})=>({justifyContent:"center",paddingTop:e.spacing(.75),...Ta}));g("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)}));const $t=g(ae)(({theme:e})=>({maxWidth:"100%",textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}})),Pr=g(ye)(({theme:e})=>({height:e.spacing(3.5),width:e.spacing(3.5)})),Fr=g(wa)(({theme:e})=>({borderRadius:e.shape.borderRadiusLarge,padding:e.spacing(1,1.5)})),ea=({capabilityId:e,feature:s,onEdit:a,onDelete:n})=>{const o=`${e}-${s}-actions`,r=`${o}-menu`,[i,l]=x.useState(null),c=!!i,u=d=>{l(d.currentTarget)},p=()=>{l(null)};return t.jsxs(B,{children:[t.jsx(re,{title:"Dependency actions",arrow:!0,describeChild:!0,children:t.jsx(Pr,{id:o,"aria-controls":c?r:void 0,"aria-haspopup":"true","aria-expanded":c?"true":void 0,onClick:u,type:"button",children:t.jsx(Ct,{})})}),t.jsx(Fr,{id:r,anchorEl:i,open:c,onClose:p,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,children:t.jsxs(ka,{"aria-labelledby":o,children:[t.jsxs(Se,{onClick:()=>{a(),p()},children:[t.jsx(Ae,{children:t.jsx(We,{})}),t.jsx(Ce,{children:t.jsx(M,{variant:"body2",children:"Edit"})})]}),t.jsxs(Se,{onClick:()=>{n(),p()},children:[t.jsx(Ae,{children:t.jsx(ws,{})}),t.jsx(Ce,{children:t.jsx(M,{variant:"body2",children:"Delete"})})]})]})})]})},Or=({childFeatures:e,project:s})=>t.jsx(He,{tooltip:t.jsx(t.Fragment,{children:e.map(a=>t.jsx($t,{to:`/projects/${s}/features/${a}`,children:t.jsx("div",{children:a})},`${s}-${a}`))}),children:e.length===1?"1 feature":`${e.length} features`}),_r=({variants:e})=>e.length===1&&e[0].length<20?t.jsx("span",{children:e[0]}):t.jsx(He,{tooltip:t.jsx(t.Fragment,{children:e.map((s,a)=>t.jsx("div",{children:s},a))}),children:e.length===1?"1 variant":`${e.length} variants`}),Br=g(J)(({theme:e})=>({fontSize:e.fontSizes.smallBody,lineHeight:e.typography.body1.lineHeight})),Mr=(e,s)=>{const{trackEvent:a}=ie(),{addChange:n}=ue(),{refetch:o}=ce(e),{setToastData:r,setToastApiError:i}=H(),{refetchFeature:l}=W(e,s),c=St(e)(),{isChangeRequestConfiguredInAnyEnv:u}=te(e),{removeDependencies:p}=Zs(e),d=async()=>{if(!c){console.error("No change request environment");return}await n(e,c,[{action:"deleteDependency",feature:s,payload:void 0}])};return async()=>{try{u()?(await d(),a("dependent_features",{props:{eventType:"delete dependency added to change request"}}),r({type:"success",text:"Change added to draft"}),await o()):(await p(s),a("dependent_features",{props:{eventType:"dependency removed"}}),r({text:"Dependency removed",type:"success"}),await l())}catch(j){i(q(j))}}},Lr=({feature:e})=>{var u,p,d,m,j,y,b;const[s,a]=x.useState(!1),n=!!e.project&&e.dependencies.length===0&&e.children.length===0,o=!!e.project&&e.dependencies.length>0,r=!!e.project&&e.children.length>0,i=St(e.project)(),l=ks(e.project),c=Mr(e.project,e.name);return t.jsxs(t.Fragment,{children:[n?t.jsxs(X,{children:[t.jsx(oe,{children:"Dependency:"}),t.jsx("div",{children:t.jsx(Br,{size:"small",permission:Lt,projectId:e.project,variant:"text",onClick:()=>{a(!0)},children:"Add parent flag"})})]}):null,o?t.jsxs(X,{children:[t.jsx(oe,{children:"Dependency:"}),t.jsxs(jt,{children:[t.jsx($t,{to:`/projects/${e.project}/features/${(u=e.dependencies[0])==null?void 0:u.feature}`,children:t.jsx(Ue,{title:(p=e.dependencies[0])==null?void 0:p.feature,children:(d=e.dependencies[0])==null?void 0:d.feature})}),l(Lt,i)?t.jsx(ea,{capabilityId:"dependency",feature:e.name,onEdit:()=>a(!0),onDelete:c}):null]})]}):null,o&&!((m=e.dependencies[0])!=null&&m.enabled)?t.jsxs(X,{children:[t.jsx(oe,{children:"Dependency value:"}),t.jsx("span",{children:"disabled"})]}):null,o&&((y=(j=e.dependencies[0])==null?void 0:j.variants)!=null&&y.length)?t.jsxs(X,{children:[t.jsx(oe,{children:"Dependency value:"}),t.jsx(_r,{variants:((b=e.dependencies[0])==null?void 0:b.variants)||[]})]}):null,r?t.jsxs(X,{children:[t.jsx(oe,{children:"Children:"}),t.jsx(Or,{childFeatures:e.children,project:e.project})]}):null,e.project?t.jsx($r,{project:e.project,featureId:e.name,parentDependency:e.dependencies[0],onClose:()=>a(!1),showDependencyDialogue:s}):null]})},zr=(e,s={})=>{const a=Te(`/api/admin/projects/${e}/dependencies`),{data:n,error:o}=Rs(e,!1,a,Vr,s);return{dependenciesExist:n,error:o,loading:!o&&!n}},Vr=async e=>await(await fetch(e).then(Pe("Dependencies exist check"))).json(),Nr=e=>{const{dependenciesExist:s}=zr(e),{isOss:a}=ge();return!!e&&!!(!a()||s)},ta=(e,s={})=>{const a=async()=>{const u=Te(`api/admin/features/${e}/tags`);return(await fetch(u,{method:"GET"}).then(Pe("Tags"))).json()},n=`api/admin/features/${e}/tags`,{data:o,error:r}=Rs(!!e,{tags:[]},n,a,s),[i,l]=x.useState(!r&&!o),c=()=>{Ds(n)};return x.useEffect(()=>{l(!r&&!o)},[o,r]),{tags:(o==null?void 0:o.tags)||[],error:r,loading:i,refetch:c}},qr=g("section")(({theme:e})=>({"& > *":{margin:e.spacing(1,0)}})),ot=e=>e.map(s=>({title:s.value})),Zt=(e,s)=>e.map(a=>({value:a.title,type:s})),sa=({open:e,setOpen:s})=>{const{tagTypes:a}=Ra(),n=A("featureId"),{createTag:o}=Go(),{updateFeatureTags:r,loading:i}=Ge(),{tags:l,refetch:c,loading:u}=ta(n),{setToastData:p}=H(),d=a&&a.length>0?a[0]:{name:"simple",description:"Simple tag to get you started",icon:""},[m,j]=x.useState(d),y=i||u,[b,h]=x.useState(0),{trackEvent:f}=ie(),[T,E]=x.useState(ot(l.filter(v=>v.type===m.name))),{tags:O,refetch:_}=Yo(m.name),$=x.useMemo(()=>ot(O),[O]);x.useEffect(()=>{l&&m&&E(ot(l.filter(v=>v.type===m.name)))},[JSON.stringify(l),m,e]);const D=()=>{s(!1),E([])};function I(v,S){const F=v.filter(N=>N.type===m.name).filter(N=>!S.find(k=>N.value===k.value&&N.type===k.type)),V=S.filter(N=>N.type===m.name).filter(N=>!v.find(k=>N.value===k.value&&N.type===k.type));return h(F.length+V.length),{added:F,removed:V}}const R=v=>v.filter(S=>!S.title.startsWith("Create")),z=async(v,S)=>{try{await r(n,{addedTags:v,removedTags:S}),await c()}catch{p({type:"error",text:"Failed to add tag"})}},Y=async v=>{v.preventDefault();const S=Zt(R(T),m.name),{added:F,removed:V}=I(S,l);b>0&&(await z(F,V),b>1&&f("suggest_tags",{props:{eventType:"multiple_tags_added"}}),b>0&&p({type:"success",text:`Updated tag${F.length>1?"s":""} to flag`})),h(0),E([]),s(!1)},Q=(v,S)=>{S!=null&&typeof S!="string"&&(v.preventDefault(),j(S),E([]),h(0))},C=(v,S,F)=>{const V=Da(S);F==="selectOption"&&S.forEach((k,ne)=>{if(typeof k!="string"&&k.inputValue&&k.inputValue!==""){const he={value:k.inputValue,type:m.name};o(he).then(()=>{f("suggest_tags",{props:{eventType:"tag_created"}}),_()}),k.title=k.inputValue,k.inputValue="",V[ne]=k}});const N=Zt(R(V),m.name);I(N,l),E(V)},P="add-tag-form";return t.jsx(pe,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update feature flag tags",onClick:Y,disabledPrimaryButton:y||b===0,onClose:D,formId:P,children:t.jsxs(t.Fragment,{children:[t.jsx(M,{paragraph:!0,sx:{marginBottom:v=>v.spacing(2.5)},children:"Tags allow you to group features together"}),t.jsx("form",{id:P,onSubmit:Y,children:t.jsxs(qr,{children:[t.jsx(Jo,{options:a,value:m,onChange:Q}),t.jsx(Ko,{options:$,existingTags:l,tagType:m,selectedOptions:T,onChange:C})]})})]})})},Wr=g(J)(({theme:e})=>({lineHeight:e.typography.body1.lineHeight,borderRadius:e.shape.borderRadiusExtraLarge,background:e.palette.secondary.light,padding:e.spacing(.5,1),height:e.spacing(3.5)})),Hr=g(Tt)(({theme:e})=>({fontSize:e.typography.body2.fontSize})),es=({project:e,onClick:s})=>t.jsx(Wr,{size:"small",permission:we,projectId:e,variant:"text",onClick:s,startIcon:t.jsx(Hr,{}),"data-loading":!0,children:"Add tag"}),ts=g("span")(({theme:e})=>({marginTop:e.spacing(1),color:e.palette.text.secondary,marginRight:e.spacing(1)})),Ur=g("div")(({theme:e})=>({display:"flex",justifyContent:"space-between",flexWrap:"wrap",minHeight:e.spacing(4.5),fontSize:e.fontSizes.smallBody})),ss=g("div")(({theme:e})=>({display:"flex",overflow:"hidden",gap:e.spacing(1),flexWrap:"wrap",marginTop:e.spacing(.75)}));g(As)(({theme:e})=>({overflowWrap:"anywhere",lineHeight:e.typography.body1.lineHeight,backgroundColor:e.palette.neutral.light,color:e.palette.text.primary,padding:e.spacing(.25),height:e.spacing(3.5)}));g("span")(({theme:e})=>({color:e.palette.text.secondary}));const Gr=({feature:e})=>{const{tags:s,refetch:a}=ta(e.name),{deleteTagFromFeature:n}=Ge(),[o,r]=x.useState(!1),[i,l]=x.useState(!1),[c,u]=x.useState(),{setToastData:p,setToastApiError:d}=H(),{hasAccess:m}=x.useContext(Es),j=m(we,e.project),y=()=>{r(!0)},b=async()=>{if(c)try{await n(e.name,c.type,c.value),a(),p({type:"success",text:"Tag removed"})}catch(h){d(q(h))}};return t.jsxs(t.Fragment,{children:[s.length?t.jsxs(Ur,{children:[t.jsx(ts,{children:"Tags:"}),t.jsxs(ss,{children:[s.map(h=>t.jsx(Yr,{tag:h,canUpdateTags:j,onTagRemove:f=>{l(!0),u(f)}},Is(h))),j?t.jsx(es,{project:e.project,onClick:y}):null]})]}):t.jsxs(X,{children:[t.jsx(ts,{children:"Tags:"}),t.jsx(ss,{children:t.jsx(es,{project:e.project,onClick:y})})]}),t.jsx(sa,{open:o,setOpen:r}),t.jsxs(pe,{open:i,primaryButtonText:"Remove tag",secondaryButtonText:"Cancel",onClose:()=>{l(!1),u(void 0),a()},onClick:()=>{l(!1),b(),u(void 0)},title:"Remove tag",children:["You are about to remove tag:"," ",t.jsxs("strong",{children:[c==null?void 0:c.type,":",c==null?void 0:c.value]})]})]})},Yr=({tag:e,canUpdateTags:s,onTagRemove:a})=>{const n=Is(e),o=n.length>25,r=s?()=>a(e):void 0,i=t.jsx(re,{title:"Remove tag",arrow:!0,children:t.jsx(Ea,{sx:{height:"20px",width:"20px"}})});return t.jsx(re,{title:o?n:"",arrow:!0,children:t.jsx("span",{children:t.jsx(Aa,{tag:e,onDelete:r,deleteIcon:i})})},n)},Jr=g(Ia)(({theme:e})=>({width:e.spacing(2.5),height:e.spacing(2.5)})),Kr=g($a)({flexWrap:"nowrap"}),Qr=({collaborators:e})=>!e||e.length===0?null:t.jsx(Kr,{users:e,avatarLimit:9,AvatarComponent:Jr}),Xr="environment-visibility-button",as="environment-visibility-menu",Zr=g("div")(({theme:e})=>({display:"flex",justifyContent:"center",paddingTop:e.spacing(4)})),ei=({environments:e,hiddenEnvironments:s,onChange:a})=>{const[n,o]=x.useState(null),r=!!n,i=d=>{o(d.currentTarget)},l=()=>{o(null)},c=e.map(d=>d.name),u=new Set(c.filter(d=>!s.includes(d))),p=d=>{a(d)};return t.jsxs(Zr,{children:[t.jsx(ee,{onClick:i,endIcon:r?t.jsx(Pa,{}):t.jsx(Fa,{}),variant:"outlined",id:Xr,"aria-controls":as,"aria-haspopup":"true","aria-expanded":r?"true":void 0,"data-loading":!0,children:"Hide/show environments"}),t.jsx(Oa,{id:as,open:!!n,anchorEl:n,onClose:l,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:t.jsx(_a,{multiselect:{selectedOptions:u},onChange:p,options:c.map(d=>({label:d,value:d})),search:{label:"Filter environments",placeholder:"Filter environments"}})})]})},aa=(e,s)=>{const{makeRequest:a,createRequest:n,errors:o,loading:r}=vt({propagateErrors:!0}),i=async p=>{const d=n(`/api/admin/projects/${e}/features/${s}/link`,{method:"POST",body:JSON.stringify(p)});await a(d.caller,d.id)},l=async(p,d)=>{const m=n(`/api/admin/projects/${e}/features/${s}/link/${p}`,{method:"PUT",body:JSON.stringify(d)});await a(m.caller,m.id)},c=async p=>{const d=n(`/api/admin/projects/${e}/features/${s}/link/${p}`,{method:"DELETE"});await a(d.caller,d.id)},u=[n,a,q,e];return{addLink:x.useCallback(i,u),editLink:x.useCallback(l,u),deleteLink:x.useCallback(c,u),errors:o,loading:r}},ns=g(Cs)(({theme:e})=>({width:"100%",marginTop:e.spacing(1),marginBottom:e.spacing(1)})),na=({showDialogue:e,onClose:s,project:a,featureId:n,mode:o,link:r})=>{const[i,l]=x.useState(""),[c,u]=x.useState(""),[p,d]=x.useState(""),{addLink:m,editLink:j,loading:y}=aa(a,n),{refetchFeature:b}=W(a,n),{setToastData:h,setToastApiError:f}=H(),T=o==="edit",E=T?"Edit link":"Add link",O=T?"Link updated":"Link added",{trackEvent:_}=ie();x.useEffect(()=>{T&&r?(l(r.url||""),u(r.title||""),d(r.id||"")):T||(l(""),u(""),d(""))},[T,r]);const $=async()=>{try{T?(await j(p,{url:i,title:c||null}),_("feature-links",{props:{eventType:"edit-link"}})):(await m({url:i,title:c||null}),_("feature-links",{props:{eventType:"add-link"}})),h({text:O,type:"success"}),s(),b(),u(""),l("")}catch(I){f(q(I))}},D=T?r!==null:e;return t.jsx(pe,{open:D,title:E,onClose:s,disabledPrimaryButton:i.trim()===""||y,onClick:$,primaryButtonText:"Save",secondaryButtonText:"Cancel",children:t.jsxs(B,{children:[t.jsx(ns,{label:"Link",placeholder:"https://",variant:"outlined",value:i,onChange:I=>l(I.target.value)}),t.jsx(ns,{label:"Title (optional)",variant:"outlined",value:c,onChange:I=>u(I.target.value)})]})})},ti=e=>t.jsx(na,{...e,mode:"add",link:null}),si=e=>t.jsx(na,{...e,mode:"edit",showDialogue:e.link!==null}),oa=g("div")(({theme:e})=>({padding:e.spacing(3),borderRadius:e.shape.borderRadiusLarge,backgroundColor:e.palette.background.paper,display:"flex",flexDirection:"column",gap:e.spacing(2),width:"350px",border:`1px solid ${e.palette.divider}`,[e.breakpoints.down("md")]:{width:"100%"},marginBottom:e.spacing(2)})),mt=g("h2")(({theme:e})=>({fontSize:e.typography.body1.fontSize,fontWeight:e.typography.fontWeightBold,marginBottom:e.spacing(.5)})),ai=g("div")({display:"flex",flexDirection:"column"}),X=g("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",minHeight:e.spacing(4.5),fontSize:e.fontSizes.smallBody})),oe=g("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)})),Be=g("span")({overflowWrap:"anywhere"}),jt=g("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1)})),ni=g(Ae)(({theme:e})=>({minWidth:e.spacing(5)})),oi=({links:e,project:s,feature:a})=>{const[n,o]=x.useState(!1),[r,i]=x.useState(null),{deleteLink:l,loading:c}=aa(s,a),{setToastData:u,setToastApiError:p}=H(),{refetchFeature:d}=W(s,a),m=t.jsx(J,{size:"small",startIcon:t.jsx(Tt,{}),permission:we,disabled:e.length>=10,projectId:s,variant:"text",onClick:()=>o(!0),children:"Add link"}),j=()=>t.jsx(kt,{children:e.map(h=>t.jsx(ze,{secondaryAction:t.jsx(ea,{capabilityId:"link",feature:a,onEdit:()=>{i(h)},onDelete:async()=>{try{await l(h.id),u({text:"Link removed",type:"success"}),d()}catch(f){p(q(f))}}}),disablePadding:!0,dense:!0,children:t.jsxs(za,{component:"a",href:h.url,target:"_blank",rel:"noopener noreferrer",disableGutters:!0,children:[t.jsx(ni,{children:t.jsx(Va,{color:"primary"})}),t.jsx(Ce,{primary:h.title,secondary:h.url,secondaryTypographyProps:{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block"}}})]})},h.id))}),y=t.jsxs(t.Fragment,{children:[t.jsxs(mt,{children:["You can now add links"," ",t.jsx(Ee,{color:"success",sx:{ml:1},children:"New"})]}),t.jsx(X,{children:"Gather relevant links for external resources such as issue trackers, code repositories or analytics tooling"}),t.jsx("div",{children:m})]}),b=t.jsxs(t.Fragment,{children:[t.jsx(mt,{children:"Resources"}),j(),t.jsx("div",{children:m})]});return t.jsxs(t.Fragment,{children:[t.jsx(oa,{children:e.length===0?y:b}),t.jsx(ti,{project:s,featureId:a,showDialogue:n,onClose:()=>o(!1)}),t.jsx(si,{project:s,featureId:a,link:r,onClose:()=>i(null)})]})},ri=({hiddenEnvironments:e,onEnvironmentVisibilityChange:s,feature:a,onChange:n})=>{var y,b,h,f;const{locationSettings:o}=$s(),r=le(),[i,l]=x.useState(!1),[c,u]=x.useState(!1),{project:p,description:d,type:m}=a,j=Nr(p);return t.jsxs(t.Fragment,{children:[t.jsx(oi,{links:a.links||[],project:a.project,feature:a.name}),t.jsxs(oa,{children:[t.jsxs("div",{children:[t.jsx(mt,{children:"Flag details"}),d?t.jsx(X,{"data-loading":!0,children:t.jsx(Be,{children:t.jsx(Ue,{arrow:!0,lines:5,title:d,children:d})})}):null]}),t.jsxs(ai,{children:[t.jsxs(X,{children:[t.jsx(oe,{children:"Flag type:"}),t.jsxs(Be,{"data-loading":!0,children:[Ba(m||" ")," flag"]})]}),a.lifecycle?t.jsxs(X,{"data-loading":!0,children:[t.jsx(oe,{children:"Lifecycle:"}),t.jsx(Ma,{feature:a,onArchive:()=>l(!0),onComplete:()=>u(!0),onUncomplete:n})]}):null,t.jsxs(X,{children:[t.jsx(oe,{children:"Created:"}),t.jsx(Be,{"data-loading":!0,children:La(wt(a.createdAt),o.locale)})]}),a.createdBy?t.jsxs(X,{children:[t.jsx(oe,{children:"Created by:"}),t.jsx(jt,{children:t.jsx(Be,{"data-loading":!0,children:(y=a.createdBy)==null?void 0:y.name})})]}):null,(b=a.collaborators)!=null&&b.users&&((h=a.collaborators)==null?void 0:h.users.length)>0?t.jsxs(X,{children:[t.jsx(oe,{children:"Collaborators:"}),t.jsx(jt,{children:t.jsx(Qr,{collaborators:(f=a.collaborators)==null?void 0:f.users})})]}):null,j?t.jsx(Lr,{feature:a}):null,t.jsx(Gr,{feature:a}),s?t.jsx(ei,{environments:a.environments||[],hiddenEnvironments:e||[],onChange:s}):null]})]}),a.children.length>0?t.jsx(It,{features:a.children,project:a.project,isOpen:i,onClose:()=>l(!1)}):t.jsx(Et,{isOpen:i,onConfirm:()=>{r(`/projects/${a.project}`)},onClose:()=>l(!1),projectId:a.project,featureIds:[a.name]}),a.project?t.jsx(Js,{isOpen:c,setIsOpen:u,projectId:a.project,featureId:a.name,onComplete:n}):null]})},ii=e=>{var o;const{uiConfig:s}=ge(),a=((o=s.resourceLimits)==null?void 0:o.featureEnvironmentStrategies)||100,n=e>=a;return{limit:a,limitReached:n}},ci=()=>{const[e,s]=x.useState(0),a=A("projectId"),n=A("featureId"),o=zt("environmentId"),r=zt("strategyName"),{strategy:i,defaultStrategyFallback:l}=Qo(a,o),c=JSON.parse(Na().get("defaultStrategy")||"false"),{segments:u}=qa(),p=(u||[]).filter(G=>{var be;return(be=i==null?void 0:i.segments)==null?void 0:be.includes(G.id)}),[d,m]=x.useState({}),[j,y]=x.useState(c?p:[]),{strategyDefinition:b}=Wa(r),h=Ha(),{addStrategyToFeature:f,loading:T}=Fe(),{addChange:E}=ue(),{setToastData:O,setToastApiError:_}=H(),{uiConfig:$}=ge(),{unleashUrl:D}=$,I=le(),{feature:R,refetchFeature:z}=W(a,n),Y=R==null?void 0:R.environments.find(G=>G.name===o),Q=(Y==null?void 0:Y.strategies.length)||0,{limit:C,limitReached:P}=ii(Q),v=x.useRef(R),{isChangeRequestConfigured:S}=te(a),{refetch:F}=ce(a),{trackEvent:V}=ie(),{data:N,staleDataNotification:k,forceRefreshCache:ne}=Ua({unleashGetter:W,params:[a,n],dataKey:"feature",refetchFunctionKey:"refetchFeature",options:{}},R,{afterSubmitAction:z},sn);x.useEffect(()=>{v.current.name===""&&R.name&&(ne(R),v.current=R)},[R.name]),x.useEffect(()=>{var G;if(c){const be=i||l;((G=be.parameters)==null?void 0:G.groupId)===""&&n?m({...be,parameters:{...be.parameters,groupId:n}}):m(be)}else b&&m(Ga(n,b))},[n,JSON.stringify(b),JSON.stringify(i),c]);const he=async G=>{await f(a,n,o,G),O({text:"Strategy created",type:"success"})},me=async G=>{await E(a,o,{action:"addStrategy",feature:n,payload:G}),O({text:"Strategy added to draft",type:"success"}),F()},w=Ya(d,j),U=async()=>{V("strategyTitle",{props:{hasTitle:!!d.title,on:"create"}});try{S(o)?await me(w):await he(w),z(),I(Rt(a,n))}catch(G){_(q(G))}};return!N||!N.project?null:t.jsxs(Ps,{modal:!0,description:Ja,documentationLink:Ka,documentationLinkLabel:Qa,disablePadding:!0,formatApiCode:()=>li(a,n,o,w,D),children:[t.jsx(Xa,{projectId:a,feature:N,strategy:d,setStrategy:m,segments:j,setSegments:y,environmentId:o,onSubmit:U,loading:T,permission:xe,errors:h,isChangeRequest:S(o),tab:e,setTab:s,StrategyVariants:t.jsx(Za,{strategy:d,setStrategy:m,environment:o,projectId:a,editable:!0}),Limit:t.jsx(en,{name:"strategies in this environment",shortName:"strategies",currentValue:Q,limit:C}),disabled:P}),k]})},ra=(e,s,a,n,o=!1)=>{const r=new URLSearchParams({environmentId:a,strategyName:n,defaultStrategy:String(o)});return`/projects/${e}/features/${s}/strategies/create?${r}`},li=(e,s,a,n,o)=>{if(!o)return"";const r=`${o}/api/admin/projects/${e}/features/${s}/environments/${a}/strategies`,i=JSON.stringify(n,tn,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}'`},os=3,ia=e=>Array.isArray(e)?e.filter(s=>s.featureId&&s.projectId):[],rs=e=>ia(on(e)||[]),di=()=>{const e=`${rn}:unleash-lastViewedFlags`,[s,a]=x.useState(()=>rs(e)),{emitEvent:n}=an("lastViewedFlagsUpdated",x.useCallback(()=>{a(rs(e))},[e]));x.useEffect(()=>{s&&(nn(e,s),n())},[JSON.stringify(s),e,n]);const o=x.useCallback(r=>{if(!r.featureId||!r.projectId||s.find(l=>l.featureId===r.featureId))return;const i=ia([...s,r]);a(i.length>os?i.slice(-os):i)},[JSON.stringify(s)]);return{lastViewed:s,setLastViewed:o}},pi=g("div")(({theme:e})=>({width:e.spacing(3),"& > svg":{width:e.spacing(2.25),height:e.spacing(2.25),fill:e.palette.primary.main}})),ui=g(Fs)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,fontSize:e.typography.caption.fontSize,display:"block",marginBottom:e.spacing(.5)})),gi=g(ae)(({theme:e})=>({display:"flex",flexDirection:"column",width:"100%",maxWidth:"30rem",padding:e.spacing(1.5,2),color:"inherit",textDecoration:"inherit",lineHeight:1.25,borderWidth:"1px",borderStyle:"solid",borderColor:e.palette.divider,borderRadius:e.spacing(1),overflow:"hidden","&:hover, &:focus":{borderColor:e.palette.primary.main}})),hi=g("div")(({theme:e})=>({display:"flex",flexDirection:"row",alignItems:"center",width:"100%"})),rt=({projectId:e,featureId:s,environmentId:a,strategy:n,defaultStrategy:o,onClose:r})=>{const i=Os(n.name),l=_s(n.name),{trackEvent:c}=ie(),u=ra(e,s,a,n.name,o),p=()=>{c("strategy-add",{props:{buttonTitle:n.displayName||l}}),r()};return t.jsxs(gi,{to:u,onClick:p,children:[t.jsxs(hi,{children:[t.jsx(pi,{children:t.jsx(i,{})}),t.jsx(ui,{text:n.displayName||l,maxWidth:"200",maxLength:25})]}),t.jsx(Ue,{lines:1,title:n.description,arrow:!0,sx:{fontSize:d=>d.typography.caption.fontSize,width:"100%"},children:n.description})]})},xi=g("div")(({theme:e})=>({width:e.spacing(3),"& > svg":{width:e.spacing(2.25),height:e.spacing(2.25),fill:e.palette.primary.main}})),fi=g(Fs)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,fontSize:e.typography.caption.fontSize,display:"block",marginBottom:e.spacing(.5)})),yi=g("div")(({theme:e})=>({width:"100%",transition:"opacity 0.2s ease-in-out"})),mi=g("div")(({theme:e})=>({position:"absolute",background:e.palette.background.paper,padding:e.spacing(1),top:e.spacing(1),right:e.spacing(1),display:"flex",gap:e.spacing(1),opacity:0,transition:"opacity 0.1s ease-in-out"})),ji=g("div")(({theme:e})=>({display:"flex",flexDirection:"column",width:"100%",height:"100%",maxWidth:"30rem",padding:e.spacing(1.5,2),color:"inherit",textDecoration:"inherit",lineHeight:1.25,borderWidth:"1px",borderStyle:"solid",borderColor:e.palette.divider,borderRadius:e.spacing(1),textAlign:"left",overflow:"hidden",position:"relative","&:hover .cardContent, &:focus-within .cardContent":{opacity:.5},"&:hover .buttonContainer, &:focus-within .buttonContainer":{opacity:1}})),bi=g("div")(({theme:e})=>({display:"flex",flexDirection:"row",alignItems:"center",width:"100%"})),vi=({template:{name:e,description:s},onClick:a,onPreviewClick:n})=>{const o=Os("releasePlanTemplate"),r=l=>{l.stopPropagation(),a()},i=l=>{l.stopPropagation(),n(l)};return t.jsxs(ji,{children:[t.jsxs(yi,{className:"cardContent",children:[t.jsxs(bi,{children:[t.jsx(xi,{children:t.jsx(o,{})}),t.jsx(fi,{text:e,maxWidth:"200",maxLength:25})]}),t.jsx(Ue,{lines:1,title:s,arrow:!0,sx:{fontSize:l=>l.typography.caption.fontSize,fontWeight:l=>l.typography.fontWeightRegular,width:"100%"},children:s})]}),t.jsxs(mi,{className:"buttonContainer",children:[t.jsx(ee,{variant:"contained",size:"small",onClick:r,tabIndex:0,children:"Use"}),t.jsx(ee,{variant:"outlined",size:"small",onClick:i,children:"Preview"})]})]})},Si=g(B)(()=>({width:"100%",display:"flex",flexDirection:"column"})),Ci=g(B)(({theme:e})=>({width:"100%",maxHeight:"70vh",overflowY:"auto",padding:e.spacing(4),paddingTop:0,display:"flex",flexDirection:"column",gap:e.spacing(3)})),it=g(B)(({theme:e})=>({display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:e.spacing(1.5),width:"100%"})),Me=g(B)(()=>({width:"100%",minWidth:0})),Ti=g(B)(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",padding:e.spacing(4,4,2,4)})),wi=g(M)(({theme:e})=>({fontSize:e.typography.body1.fontSize,fontWeight:e.typography.fontWeightBold,margin:0})),ct=g(B)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(.5),marginBottom:e.spacing(1),width:"100%"})),ki=g("span")(({theme:e})=>({width:e.spacing(3),"& > svg":{fill:e.palette.primary.main,width:e.spacing(2.25),height:e.spacing(2.25)},display:"flex",alignItems:"center"})),Ri=g(B)(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",backgroundColor:e.palette.neutral.light,borderRadius:e.shape.borderRadiusMedium,padding:e.spacing(3),width:"auto"})),Di=g(M)(({theme:e})=>({fontSize:e.typography.caption.fontSize,fontWeight:e.typography.fontWeightBold,marginBottom:e.spacing(1),display:"flex",alignItems:"center"})),Ai=g(M)(({theme:e})=>({fontSize:e.typography.caption.fontSize,color:e.palette.text.secondary})),Ei=g(Ye)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,cursor:"pointer","&:hover":{textDecoration:"underline"}})),Ii=({projectId:e,featureId:s,environmentId:a,onlyReleasePlans:n,onAddReleasePlan:o,onReviewReleasePlan:r,onClose:i})=>{const{isEnterprise:l}=ge(),{strategies:c}=cn(),{templates:u}=ln(),p=le(),d=c.filter(h=>!h.deprecated),m=d.filter(h=>!h.advanced&&!h.editable),j=d.filter(h=>h.editable||h.advanced),y={name:"flexibleRollout",displayName:"Default strategy",description:"This is the default strategy defined for this environment in the project"},b=()=>l()?t.jsxs(B,{children:[t.jsxs(ct,{children:[t.jsx(M,{color:"inherit",variant:"body2",children:"Release templates"}),t.jsx(et,{tooltip:"Use a predefined template to roll out features to users",size:"16px"})]}),u.length?t.jsx(it,{children:u.map(h=>t.jsx(Me,{children:t.jsx(vi,{template:h,onClick:()=>o(h),onPreviewClick:()=>r(h)})},h.id))}):t.jsxs(Ri,{children:[t.jsxs(Di,{children:[t.jsx(ki,{children:t.jsx(dn,{})}),"Create your own release templates"]}),t.jsxs(Ai,{children:["Standardize your rollouts and save time by reusing predefined strategies. Find release templates in the side menu under"," ",t.jsx(Ei,{onClick:()=>p("/release-templates"),children:"Configure > Release templates"})]})]})]}):null;return t.jsxs(Si,{children:[t.jsxs(Ti,{children:[t.jsx(wi,{variant:"h2",children:n?"Select template":"Add configuration"}),t.jsx(ye,{size:"small",onClick:i,edge:"end","aria-label":"close",children:t.jsx(Dt,{fontSize:"small"})})]}),t.jsx(Ci,{children:n?b():t.jsxs(t.Fragment,{children:[t.jsxs(B,{children:[t.jsxs(ct,{children:[t.jsx(M,{color:"inherit",variant:"body2",children:"Standard strategies"}),t.jsx(et,{tooltip:"Standard strategies let you enable a feature only for a specified audience. Select a starting setup, then customize your strategy with targeting and variants.",size:"16px"})]}),t.jsxs(it,{children:[t.jsx(Me,{children:t.jsx(rt,{projectId:e,featureId:s,environmentId:a,strategy:y,defaultStrategy:!0,onClose:i})},y.name),m.map(h=>t.jsx(Me,{children:t.jsx(rt,{projectId:e,featureId:s,environmentId:a,strategy:h,onClose:i})},h.name))]})]}),b(),j.length>0&&t.jsxs(B,{children:[t.jsxs(ct,{children:[t.jsx(M,{color:"inherit",variant:"body2",children:"Custom and advanced strategies"}),t.jsx(et,{tooltip:"Advanced strategies let you target based on specific properties. Custom activation strategies let you define your own activation strategies to use with Unleash.",size:"16px"})]}),t.jsx(it,{children:j.map(h=>t.jsx(Me,{children:t.jsx(rt,{projectId:e,featureId:s,environmentId:a,strategy:h,onClose:i})},h.name))})]})]})})]})},$i=g(Bs)(({theme:e})=>({"& .MuiDialog-paper":{borderRadius:e.shape.borderRadiusLarge,maxWidth:e.spacing(85)}})),Pi=g(pn)(({theme:e})=>({padding:e.spacing(2,4,4)})),Fi=g(B)(({theme:e})=>({display:"flex",justifyContent:"space-between",marginBottom:e.spacing(2)})),Oi=g(B)(({theme:e})=>({display:"flex",alignItems:"center",cursor:"pointer"})),_i=g(un)(({theme:e})=>({marginRight:e.spacing(1),color:e.palette.primary.main,display:"flex",alignSelf:"center"})),Bi=g(M)(({theme:e})=>({fontWeight:e.typography.fontWeightMedium,display:"flex",alignItems:"center",lineHeight:1})),Mi=({open:e,setOpen:s,onConfirm:a,template:n,projectId:o,featureName:r,environment:i,crProtected:l})=>{const{feature:c}=W(o,r),{releasePlans:u}=Je(o,r,i),p=u[0],d=c==null?void 0:c.environments.find(({name:b})=>b===i),m=d==null?void 0:d.enabled,j=gn(n.id,r,i),y=()=>s(!1);return t.jsxs($i,{open:e,onClose:y,fullWidth:!0,maxWidth:"md",children:[t.jsxs(hn,{children:[t.jsxs(Fi,{children:[t.jsxs(Oi,{onClick:y,children:[t.jsx(_i,{}),t.jsx(Bi,{variant:"body2",color:"primary",children:"Go back"})]}),t.jsx(ye,{size:"small",onClick:y,edge:"end","aria-label":"close",children:t.jsx(Dt,{fontSize:"small"})})]}),p&&t.jsxs(Z,{severity:"error",sx:{mb:1},children:["This feature environment currently has"," ",t.jsx("strong",{children:p.name})," -"," ",t.jsx("strong",{children:p.milestones[0].name}),m?" running":" paused",". Adding a new release plan will replace the existing release plan."]}),t.jsx("div",{children:t.jsx(Ms,{plan:j,readonly:!0})}),l&&t.jsxs(M,{sx:{mt:4},children:[t.jsx("strong",{children:"Adding"})," release template"," ",t.jsx("strong",{children:n==null?void 0:n.name})," to"," ",t.jsx("strong",{children:r})," in"," ",t.jsx("strong",{children:i}),"."]})]}),t.jsx(Pi,{children:t.jsx(ee,{variant:"contained",color:"primary",onClick:a,children:l?"Add suggestion to draft":"Use template"})})]})},Li=g("div")(({theme:e})=>({display:"flex",flexFlow:"row",justifyContent:"flex-end",gap:e.spacing(1)})),zi=g(J)(({theme:e})=>({minWidth:0,width:e.spacing(4.5),alignSelf:"stretch",paddingBlock:0})),is=({label:e,projectId:s,featureId:a,environmentId:n,variant:o,size:r,matchWidth:i,disableReason:l})=>{const[c,u]=x.useState(!1),[p,d]=x.useState(!1),m=le(),{trackEvent:j}=ie(),[y,b]=x.useState(),[h,f]=x.useState(!1),T=c?"FeatureStrategyMenuDialog":void 0,{setToastApiError:E,setToastData:O}=H(),{isChangeRequestConfigured:_}=te(s),{addChange:$}=ue(),{refetch:D}=ce(s),{refetch:I}=Je(s,a,n),{addReleasePlanToFeature:R}=xn(),{isEnterprise:z}=ge(),Y=Ke("addConfiguration"),Q=z(),C=_(n),P=()=>{u(!1)},v=k=>{j("strategy-add",{props:{buttonTitle:e}}),m(N)},S=k=>{d(!1),u(!0)},F=k=>{d(!0),u(!0)},V=async k=>{try{C?(await $(s,n,{feature:a,action:"addReleasePlan",payload:{templateId:k.id}}),O({type:"success",text:"Added to draft"}),D()):(await R(a,k.id,s,n),O({type:"success",text:"Release plan added"}),I()),j("release-management",{props:{eventType:"add-plan",plan:k.name}})}catch(ne){E(q(ne))}finally{f(!1),b(void 0),P()}},N=ra(s,a,n,"flexibleRollout",!0);return t.jsxs(Li,{onClick:k=>k.stopPropagation(),children:[Y?t.jsx(J,{"data-testid":"ADD_STRATEGY_BUTTON",permission:xe,projectId:s,environmentId:n,onClick:S,"aria-labelledby":T,variant:o,sx:{minWidth:i?"282px":"auto"},disabled:!!l,tooltipProps:{title:l||void 0},children:"Add configuration"}):t.jsxs(t.Fragment,{children:[Q?t.jsx(J,{"data-testid":"ADD_TEMPLATE_BUTTON",permission:xe,projectId:s,environmentId:n,onClick:F,"aria-labelledby":T,variant:"outlined",sx:{minWidth:i?"282px":"auto"},disabled:!!l,tooltipProps:{title:l||void 0},children:"Use template"}):null,t.jsx(J,{"data-testid":"ADD_STRATEGY_BUTTON",permission:xe,projectId:s,environmentId:n,onClick:v,"aria-labelledby":T,variant:o,sx:{minWidth:i?"282px":"auto"},disabled:!!l,tooltipProps:{title:l||void 0},children:e}),t.jsx(zi,{permission:xe,projectId:s,environmentId:n,onClick:S,variant:"outlined",hideLockIcon:!0,disabled:!!l,tooltipProps:{title:l||"More strategies"},children:t.jsx(Ct,{})})]}),t.jsx(Bs,{open:c,onClose:P,maxWidth:"md",PaperProps:{sx:{borderRadius:"12px"}},children:t.jsx(Ii,{projectId:s,featureId:a,environmentId:n,onlyReleasePlans:p,onAddReleasePlan:k=>{b(k),V(k)},onReviewReleasePlan:k=>{b(k),f(!0),P()},onClose:P})}),y&&t.jsx(Mi,{open:h,setOpen:k=>{f(k),k||u(!0)},onConfirm:()=>{V(y)},template:y,projectId:s,featureName:a,environment:n,crProtected:C})]})},ca=(e,s)=>e===0?0:Math.round(s/e*100),Vi=g("div")(()=>({display:"flex",alignItems:"center",justifyContent:"center",position:"relative",margin:0})),Ni=g("div",{shouldForwardProp:e=>e!=="color"})(({theme:e,color:s})=>({position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:s,fontSize:e.fontSizes.smallerBody,margin:0})),qi=({percentage:e,size:s="4rem",disabled:a=!1,children:n})=>{const o=$e(),r={display:"block",borderRadius:"100%",transform:"rotate(-90deg)",height:s,width:s},i=100/(2*Math.PI),l=2*i,c=l*.2,u=a?o.palette.neutral.border:o.palette.primary.light;return t.jsxs(Vi,{children:[t.jsxs("svg",{viewBox:`0 0 ${l} ${l}`,style:r,"aria-hidden":!0,children:[t.jsx("circle",{r:i,cx:i,cy:i,fill:"none",stroke:o.palette.background.elevation2,strokeWidth:c}),t.jsx("circle",{r:i,cx:i,cy:i,fill:"none",stroke:u,strokeWidth:c,strokeDasharray:`${e} 100`})]}),t.jsx(Ni,{color:u,children:n})]})},Wi=g("figure")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"flex-end",margin:0,padding:0})),Hi=g("figcaption")(({theme:e})=>({fontSize:e.typography.body2.fontSize,textAlign:"right",[e.breakpoints.down("xl")]:{display:"none"},display:"flex",flexDirection:"column",flexGrow:1,margin:0,padding:0,span:{textWrap:"nowrap"}})),Ui=g("div")(({theme:e})=>({marginRight:e.spacing(1),marginLeft:e.spacing(1.5),[e.breakpoints.down(500)]:{display:"none"}})),Gi=g(({className:e,...s})=>t.jsx(re,{...s,classes:{popper:e}}))({[`& .${fn.tooltip}`]:{maxWidth:200}}),Yi=({environmentMetric:e,collapsed:s})=>{if(!e)return null;const a=e.yes+e.no,n=ca(a,e==null?void 0:e.yes),o=!e||e.yes===0&&e.no===0,r=o?t.jsxs(t.Fragment,{children:["No evaluation metrics",t.jsx("br",{}),"received in the last hour"]}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:["The flag has been evaluated"," ",t.jsxs("b",{children:[t.jsx(Ve,{value:a})," times"]})]})," ",t.jsxs("span",{children:["and enabled"," ",t.jsxs("b",{children:[t.jsx(Ve,{value:e.yes})," times"]})," ","in the last hour"]})]});return t.jsxs(Wi,{children:[s?null:t.jsx(Hi,{children:r}),t.jsx(Gi,{title:s?r:"",arrow:!0,children:t.jsx(Ui,{"data-loading":!0,children:t.jsx(qi,{percentage:n,size:"3rem",children:o?null:`${n}%`})})})]})},Ji=g("div")(({theme:e})=>({order:-1,flex:0})),Ki=({environment:{name:e,type:s,strategies:a,enabled:n}})=>{const o=A("projectId"),r=A("featureId"),{refetchFeature:i}=W(o,r),{isChangeRequestConfigured:l}=te(o),{onToggle:c,modals:u}=Xo(o),p=(d,m)=>c(d,{projectId:o,featureId:r,environmentName:e,environmentType:s,hasStrategies:a.length>0,hasEnabledStrategies:a.some(j=>!j.disabled),isChangeRequestEnabled:l(e),onRollback:m,onSuccess:i});return t.jsxs(Ji,{onClick:d=>d.stopPropagation(),children:[t.jsx(Zo,{projectId:o,value:n,featureId:r,environmentName:e,onToggle:p}),u]})},Qi=(e,s)=>{const a=[];let n=0;if(e.length<=n)return e;for(;n<e.length;)if(n===0){n+=s;const o=e.slice(0,n);a.push(o)}else{const o=e.slice(n,n+s);n+=s,a.push(o)}return a},Xi=(e,s,a)=>{const[n,o]=x.useState([[]]),[r,i]=x.useState(0);x.useEffect(()=>{const m=Qi(e,s);o(m)},[JSON.stringify(e),s]);const l=()=>{r<n.length-1&&i(d=>d+1)},c=()=>{r>0&&i(d=>d-1)},u=()=>{i(n.length-1)},p=()=>{i(0)};return{page:n[r]||[],pages:n,nextPage:l,prevPage:c,lastPage:u,firstPage:p,setPageIndex:i,pageIndex:r}},Zi=e=>fetch(e).then(Pe("ChangeRequest")).then(s=>s.json()),la=(e,s)=>{const{data:a,error:n,mutate:o}=Ls([],Te(`api/admin/projects/${e}/change-requests/pending/${s}`),Zi);return{changeRequests:a,loading:!n&&!a,refetch:o,error:n}},ec=(e,s,a,n)=>{const{user:o}=yn(),{changeRequests:r}=la(e,s),i=[],l=r==null?void 0:r.filter(c=>c.environment===a);return l==null||l.forEach(c=>{const u=c==null?void 0:c.features.find(d=>d.name===s),p=u==null?void 0:u.changes.find(d=>d.action==="updateStrategy"||d.action==="deleteStrategy"?d.payload.id===n:!1);if(p){const d=c.state==="Scheduled",m=!d&&c.createdBy.id===(o==null?void 0:o.id);d&&i.push({changeRequestId:c.id,change:p,isScheduledChange:d}),m&&i.push({changeRequestId:c.id,change:p,isScheduledChange:d})}}),i},da=({scheduledChangeRequestIds:e})=>{const s=$e(),a=Qe(s.breakpoints.down("sm")),n=A("projectId");return a?null:t.jsx(B,{sx:{mr:1.5},children:t.jsx(He,{tooltip:t.jsx(t.Fragment,{children:e==null?void 0:e.map((o,r)=>t.jsxs($t,{to:`/projects/${n}/change-requests/${o}`,children:["Change request #",o]},`${n}-${r}`))}),children:t.jsx(Ee,{color:"warning",children:"Changes Scheduled"})})})},tc=({changeAction:e,sx:s})=>{switch(e){case"updateStrategy":return t.jsx(Ee,{color:"warning",sx:s,children:"Modified in draft"});case"deleteStrategy":return t.jsx(Ee,{color:"error",sx:s,children:"Deleted in draft"});default:return null}},sc=e=>(s,a,n)=>(n.revalidateOnFocus=!1,n.revalidateIfStale=!1,n.revalidateOnReconnect=!1,e(s,a,n)),ac=mn(zs,sc),nc=(e,s)=>{const{refetchFeature:a}=W(e,s),n=jn(e,s),{data:o,error:r,mutate:i}=ac(["useFeatureImmutable",n],()=>bn(n)),l=x.useCallback(async()=>{await i(),await a()},[i,a]);return{feature:(o==null?void 0:o.body)||vn,refetchFeature:l,loading:!r&&!o,status:o==null?void 0:o.status,error:r}},oc=(e,s,a)=>{const{setToastData:n,setToastApiError:o}=H(),{addChange:r}=ue(),{refetch:i}=ce(e),[l,c]=x.useState({isOpen:!1}),u=x.useCallback((y,b,h)=>{c({featureName:s,environment:y,fromEnvironment:h,strategy:b,isOpen:!0})},[]),p=x.useCallback((y,b,h)=>{c({featureName:s,environment:y,fromEnvironment:h,strategies:b,isOpen:!0})},[]),d=x.useCallback(()=>{c({isOpen:!1})},[]),m=x.useCallback(async()=>{try{await r(e,l.environment,{feature:l.featureName,action:a,payload:l.strategy}),i(),c({isOpen:!1}),n({type:"success",text:"Changes added to draft"})}catch(y){o(q(y)),c({isOpen:!1})}},[r]),j=x.useCallback(async()=>{try{await Promise.all(l.strategies.map(y=>r(e,l.environment,{feature:l.featureName,action:a,payload:y}))),i(),c({isOpen:!1}),n({type:"success",text:"Changes added to draft"})}catch(y){o(q(y)),c({isOpen:!1})}},[r]);return{onChangeRequestAddStrategy:u,onChangeRequestAddStrategies:p,onChangeRequestAddStrategyClose:d,onChangeRequestAddStrategyConfirm:m,onChangeRequestAddStrategiesConfirm:j,changeRequestDialogDetails:l}},rc=({payload:e,fromEnvironment:s,environment:a})=>t.jsxs(M,{children:[t.jsxs("strong",{children:["Copy ",_s((e==null?void 0:e.name)||"")," strategy"," "]})," ","from ",s," to ",a]}),ic=({environmentId:e,environments:s,strategy:a})=>{const n=A("projectId"),o=A("featureId"),[r,i]=x.useState(null),l=!!r,{addStrategyToFeature:c}=Fe(),{setToastData:u,setToastApiError:p}=H(),{refetchFeature:d}=W(n,o),{refetchFeature:m}=nc(n,o),j=()=>{i(null)},y=ks(n),{isChangeRequestConfigured:b}=te(n),{changeRequestDialogDetails:h,onChangeRequestAddStrategyClose:f,onChangeRequestAddStrategy:T,onChangeRequestAddStrategyConfirm:E}=oc(n,o,"addStrategy"),O=async D=>{const{id:I,...R}={...a,targetEnvironment:D};if(b(D)){await T(D,R,e);return}try{await c(n,o,D,a),d(),m(),u({text:`Strategy copied to ${D}`,type:"success"})}catch(z){p(q(z))}j()},_=[...s,e].some(D=>y(xe,D)),$=`Copy to environment${_?"":` (Access denied, missing ${xe} permission)`}`;return t.jsxs("div",{children:[t.jsx(er,{isOpen:h.isOpen,onClose:f,environment:h==null?void 0:h.environment,onConfirm:E,messageComponent:t.jsx(rc,{fromEnvironment:h.fromEnvironment,payload:h.strategy})}),t.jsx(re,{title:$,children:t.jsx("div",{children:t.jsx(ye,{size:"large",id:`copy-strategy-icon-menu-${a.id}`,"aria-label":$,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,onClick:D=>{i(D.currentTarget)},"data-testid":Sn,disabled:!_,children:t.jsx(Cn,{})})})}),t.jsx(Xe,{id:"basic-menu",anchorEl:r,open:l,onClose:j,MenuListProps:{"aria-labelledby":`copy-strategy-icon-menu-${a.id}`},children:[...s,e].map(D=>{const I=y(xe,D);return t.jsx(re,{title:I?"":"You don't have access to add a strategy to this environment",children:t.jsx("div",{children:t.jsxs(Se,{onClick:()=>O(D),disabled:!I,children:[t.jsx(L,{condition:!I,show:t.jsx(Ae,{children:t.jsx(Tn,{fontSize:"small"})})}),t.jsx(Ce,{children:D===e?"Duplicate in current":`Copy to ${D}`})]})})},D)})})]})},cc=()=>t.jsx(Z,{severity:"error",children:"Removing the strategy will change which users receive access to the feature."}),lc=g("div")(({theme:e})=>({"> * + *":{marginTop:e.spacing(1)}})),dc=({changeRequests:e,projectId:s})=>e&&e.length>0?t.jsxs(Z,{severity:"warning",children:[t.jsx("p",{children:"This strategy is in use by at least one scheduled change request. If you remove it, those change requests can no longer be applied."}),t.jsx("p",{children:"The following scheduled change requests use this strategy:"}),t.jsx("ul",{children:e.map(({id:a,title:n})=>{const o=n?`#${a} (${n})`:`#${a}`;return t.jsx("li",{children:t.jsx(ae,{to:`/projects/${s}/change-requests/${a}`,target:"_blank",rel:"noopener noreferrer",title:`Change request ${a}`,children:o})},a)})})]}):e===void 0?t.jsx(Z,{severity:"warning",children:t.jsx("p",{children:"This strategy may be in use by one or more scheduled change requests. If you remove it, those change requests can no longer be applied."})}):null,pa=({scheduledChangeRequestsForStrategy:e})=>t.jsxs(lc,{children:[t.jsx(cc,{}),t.jsx(dc,{projectId:e.projectId,changeRequests:e.changeRequests})]}),pc=({onRemove:e,onClose:s,isOpen:a,scheduledChangeRequestsForStrategy:n})=>t.jsx(pe,{title:"Are you sure you want to delete this strategy?",open:a,primaryButtonText:"Remove strategy",secondaryButtonText:"Cancel",onClick:e,onClose:s,children:t.jsx(pa,{scheduledChangeRequestsForStrategy:n})}),uc=g("div")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1)})),gc=({onRemove:e,onClose:s,isOpen:a,scheduledChangeRequestsForStrategy:n})=>t.jsxs(pe,{title:"Suggest changes",open:a,primaryButtonText:"Add suggestion to draft",secondaryButtonText:"Cancel",onClick:e,onClose:s,children:[t.jsx(pa,{scheduledChangeRequestsForStrategy:n}),t.jsx(uc,{children:t.jsx(M,{variant:"body2",color:"text.secondary",children:"Your suggestion:"})}),t.jsx(M,{fontWeight:"bold",children:"Remove strategy"})]}),hc=({projectId:e,featureId:s,environmentId:a,strategyId:n})=>{const{deleteStrategyFromFeature:o}=Fe(),{setToastData:r,setToastApiError:i}=H(),l=le(),{refetchFeature:c}=W(e,s);return async p=>{try{p.preventDefault(),await o(e,s,a,n),r({text:"Strategy deleted",type:"success"}),c(),l(Rt(e,s))}catch(d){i(q(d))}}},xc=({projectId:e,featureId:s,environmentId:a,strategyId:n})=>{const{addChange:o}=ue(),{refetch:r}=ce(e),{setToastData:i,setToastApiError:l}=H();return async u=>{try{u.preventDefault(),await o(e,a,{action:"deleteStrategy",feature:s,payload:{id:n}}),i({text:"Changes added to draft",type:"success"}),await r()}catch(p){l(q(p))}}},fc=({projectId:e,featureId:s,environmentId:a,strategyId:n,isOpen:o,onClose:r})=>{const{isChangeRequestConfigured:i}=te(e),{changeRequests:l}=Vs(e,n),c={changeRequests:l,projectId:e},u=hc({featureId:s,projectId:e,strategyId:n,environmentId:a}),p=xc({featureId:s,projectId:e,strategyId:n,environmentId:a});return i(a)?t.jsx(gc,{isOpen:o,onClose:()=>r(),onRemove:async d=>{await p(d),r()},scheduledChangeRequestsForStrategy:c}):t.jsx(pc,{isOpen:o,onClose:()=>r(),onRemove:u,scheduledChangeRequestsForStrategy:c})},yc=({projectId:e,environmentId:s,featureId:a,strategy:n})=>{const{refetchFeature:o}=W(e,a),{setStrategyDisabledState:r}=Fe(),{setToastData:i,setToastApiError:l}=H(),c=u=>async()=>{try{await r(e,a,s,n.id,!u),i({text:`Strategy ${u?"enabled":"disabled"}`,type:"success"}),o()}catch(p){l(q(p))}};return{onDisable:c(!1),onEnable:c(!0)}},mc=({projectId:e,environmentId:s,featureId:a,strategy:n})=>{const{addChange:o}=ue(),{refetch:r}=ce(e),{setToastData:i,setToastApiError:l}=H(),c=u=>async()=>{try{await o(e,s,{action:"updateStrategy",feature:a,payload:{...n,disabled:!u}}),i({text:"Changes added to draft",type:"success"}),await r()}catch(p){l(q(p))}};return{onSuggestDisable:c(!1),onSuggestEnable:c(!0)}},jc=({isOpen:e,onClose:s,...a})=>{var j;const{projectId:n,environmentId:o}=a,{isChangeRequestConfigured:r}=te(n),i=r(o),{onSuggestEnable:l,onSuggestDisable:c}=mc({...a}),{onEnable:u,onDisable:p}=yc({...a}),d=!!((j=a.strategy)!=null&&j.disabled),m=y=>{y.preventDefault(),i?d?l():c():d?u():p(),s()};return t.jsx(pe,{title:i?`Add ${d?"enable":"disable"} strategy to change request?`:`Are you sure you want to ${d?"enable":"disable"} this strategy?`,open:e,primaryButtonText:i?"Add to draft":`${d?"Enable":"Disable"} strategy`,secondaryButtonText:"Cancel",onClick:m,onClose:()=>s(),children:t.jsx(L,{condition:i,show:t.jsx(wn,{environment:o}),elseShow:t.jsxs(Z,{severity:"error",children:[d?"Enabling":"Disabling"," the strategy will change which users receive access to the feature."]})})})},bc=({projectId:e,strategy:s,featureId:a,environmentId:n})=>{const[o,r]=x.useState(null),[i,l]=x.useState(!1),[c,u]=x.useState(!1),p=!!o,d=b=>{r(b.currentTarget)},m=b=>{r(null),b.stopPropagation()},j=xt(Ns,e,n),y=xt(kn,e,n);return t.jsxs(t.Fragment,{children:[t.jsx(B,{sx:{display:"flex",alignItems:"center",textAlign:"center"},children:t.jsx(re,{title:"More actions",children:t.jsx(ye,{onClick:d,size:"small","aria-controls":p?"actions-menu":void 0,"aria-haspopup":"true","aria-expanded":p?"true":void 0,"data-testid":Rn,children:t.jsx(Ct,{sx:{width:32,height:32}})})})}),t.jsxs(Xe,{anchorEl:o,id:"actions-menu",open:p,onClose:m,onClick:m,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},"data-testid":Dn,children:[t.jsx(re,{title:s.disabled?"Enable strategy":"Disable strategy",arrow:!0,placement:"left",children:t.jsxs(Se,{disabled:!j,onClick:()=>l(!0),children:[t.jsx(Ae,{children:s.disabled?t.jsx(An,{}):t.jsx(En,{})}),t.jsx(Ce,{children:s.disabled?"Enable":"Disable"})]})}),t.jsx(re,{title:"Remove strategy",arrow:!0,placement:"left",children:t.jsxs(Se,{disabled:!y,onClick:()=>u(!0),"data-testid":In,children:[t.jsx(Ae,{children:t.jsx(ws,{})}),t.jsx(Ce,{children:"Remove"})]})})]}),t.jsx(jc,{isOpen:i,onClose:()=>l(!1),projectId:e,featureId:a,environmentId:n,strategy:s}),t.jsx(fc,{isOpen:c,onClose:()=>u(!1),projectId:e,featureId:a,environmentId:n,strategyId:s.id})]})},cs=({strategy:e,index:s,environmentName:a,otherEnvironments:n,isDragging:o,onDragStartRef:r,onDragOver:i,onDragEnd:l})=>{const c=A("projectId"),u=A("featureId");x.useRef(null);const p=ec(c,u,a,e.id),{changeRequests:d}=Vs(c,e.id),m=$n(c,u,a,e.id),j=p==null?void 0:p.find(({isScheduledChange:h})=>!h),y=$e(),b=Qe(y.breakpoints.down("sm"));return t.jsx(Pn,{strategy:e,onDragEnd:l,onDragStartRef:r,onDragOver:i,index:s,isDragging:o,headerItemsRight:t.jsxs(t.Fragment,{children:[j&&!b?t.jsx(tc,{sx:{mr:1.5},changeAction:j.change.action}):null,d&&d.length>0&&!b?t.jsx(da,{scheduledChangeRequestIds:(d??[]).map(h=>h.id)}):null,n&&(n==null?void 0:n.length)>0?t.jsx(ic,{environmentId:a,environments:n,strategy:e}):null,t.jsx(De,{permission:Ns,environmentId:a,projectId:c,component:ae,to:m,tooltipProps:{title:"Edit strategy"},"data-testid":`STRATEGY_EDIT-${e.name}`,children:t.jsx(We,{})}),t.jsx(bc,{projectId:c,featureId:u,environmentId:a,strategy:e})]})})},vc=g("div")(({theme:e})=>({borderBottom:`1px solid ${e.palette.divider}`})),Sc=g("div")(({theme:e})=>({padding:e.spacing(2),paddingBottom:e.spacing(0),backgroundColor:Fn(e),':has(+ ol>li[data-type="release-plan"])':{backgroundColor:On(e)}})),Cc=({featureEnvironment:e,isDisabled:s,otherEnvironments:a})=>{const n=A("projectId"),o=A("featureId"),{setStrategiesSortOrder:r}=Fe(),{addChange:i}=ue(),{isChangeRequestConfigured:l}=te(n),{refetch:c}=ce(n),{setToastData:u,setToastApiError:p}=H(),{refetchFeature:d}=W(n,o),m=Ke("manyStrategiesPagination"),[j,y]=x.useState((e==null?void 0:e.strategies)||[]),{releasePlans:b}=Je(n,o,e==null?void 0:e.name),{trackEvent:h}=ie(),[f,T]=x.useState(null);x.useEffect(()=>{y((e==null?void 0:e.strategies)||[])},[e==null?void 0:e.strategies]),x.useEffect(()=>{j.length>50&&h("many-strategies")},[]);const E=20,{page:O,pages:_,setPageIndex:$,pageIndex:D}=Xi(j,E);if(!e)return null;const I=async v=>{try{await r(n,o,e.name,v),d(),u({text:"Order of strategies updated",type:"success"})}catch(S){p(q(S))}},R=async v=>{await i(n,e.name,{action:"reorderStrategy",feature:o,payload:v}),u({text:"Strategy execution order added to draft",type:"success"}),c()},z=async v=>{try{l(e.name)?await R(v):await I(v)}catch(S){p(q(S))}},Y=(v,S)=>F=>{var V;T({id:j[S].id,index:S,height:((V=v.current)==null?void 0:V.offsetHeight)||0}),v!=null&&v.current&&(F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/html",v.current.outerHTML),F.dataTransfer.setDragImage(v.current,20,20))},Q=v=>(S,F)=>V=>{if(f===null||S.current===null||f.index===F||v===f.id)return;const{top:N,bottom:k}=S.current.getBoundingClientRect(),ne=V.clientY-N<f.height,he=k-V.clientY<f.height,me=f.index>F;if(ne&&me||he&&!me){const w=[...j],U=w.splice(f.index,1)[0];w.splice(F,0,U),y(w),T({...f,index:F})}},C=()=>{T(null),z(j.map((v,S)=>({id:v.id,sortOrder:S})))},P=j.length>=50&&m;return t.jsxs(vc,{children:[P?t.jsx(Sc,{children:t.jsx(Z,{severity:"warning",children:"We noticed you're using a high number of activation strategies. To ensure a more targeted approach, consider leveraging constraints or segments."})}):null,t.jsxs(_n,{children:[b.map(v=>t.jsx(tt,{"data-type":"release-plan",children:t.jsx(Ms,{plan:v,environmentIsDisabled:s})},v.id)),P?t.jsx(t.Fragment,{children:O.map((v,S)=>t.jsxs(tt,{children:[S>0||b.length>0?t.jsx(Vt,{}):null,t.jsx(cs,{strategy:v,index:S+D*E,environmentName:e.name,otherEnvironments:a})]},v.id))}):t.jsx(t.Fragment,{children:j.map((v,S)=>t.jsxs(tt,{children:[S>0||b.length>0?t.jsx(Vt,{}):null,t.jsx(cs,{strategy:v,index:S,environmentName:e.name,otherEnvironments:a,isDragging:(f==null?void 0:f.id)===v.id,onDragStartRef:Y,onDragOver:Q(v.id),onDragEnd:C})]},v.id))})]}),P?t.jsx(Cr,{count:_.length,shape:"rounded",page:D+1,onChange:(v,S)=>$(S-1)}):null]})},Tc=g(Ye)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),color:e.palette.links,fontWeight:e.typography.fontWeightMedium,textDecoration:"none",marginRight:"auto"})),wc=()=>{const{isEnterprise:e}=ge();return e()?t.jsx(Tc,{component:"a",href:Bn,underline:"hover",rel:"noopener noreferrer",target:"_blank",children:"Give feedback to release templates"}):null},kc=g("div")(({theme:e})=>({borderRadius:e.shape.borderRadiusLarge,backgroundColor:e.palette.background.paper,border:`1px solid ${e.palette.divider}`})),Rc=g(Mn)(({theme:e})=>({boxShadow:"none",background:"none",[`&:has(.${tr}:focus-visible)`]:{background:e.palette.table.headerHover}})),Dc=g(Ln)(({theme:e})=>({padding:0,background:e.palette.background.elevation1,borderBottomLeftRadius:e.shape.borderRadiusLarge,borderBottomRightRadius:e.shape.borderRadiusLarge,boxShadow:e.boxShadows.accordionFooter})),Ac=g("footer")(({theme:e})=>({padding:e.spacing(2,3,3),display:"flex",flexDirection:"column",gap:e.spacing(2)})),Ec=g("div")(({theme:e})=>({width:"100%",position:"relative"})),Ic=({environment:e,metrics:s={yes:0,no:0},otherEnvironments:a=[],onToggleEnvOpen:n=()=>{}})=>{var p,d;const[o,r]=x.useState(!1),i=A("projectId"),l=A("featureId"),{isOss:c}=ge(),u=!!(e!=null&&e.enabled||e!=null&&e.strategies&&(e==null?void 0:e.strategies.length)>0||e!=null&&e.releasePlans&&(e==null?void 0:e.releasePlans.length)>0);return t.jsx(kc,{children:t.jsxs(Rc,{TransitionProps:{mountOnEnter:!0,unmountOnExit:!0},"data-testid":`${zn}_${e.name}`,expanded:o&&u,onChange:()=>{const m=o?!o:u;n(m),r(m)},children:[t.jsxs(sr,{environmentMetadata:{strategyCount:((p=e.strategies)==null?void 0:p.length)??0,releasePlanCount:((d=e.releasePlans)==null?void 0:d.length)??0},environmentId:e.name,expandable:u,children:[t.jsx(Ki,{environment:e}),u?t.jsx(Yi,{environmentMetric:s}):t.jsx(is,{label:"Add strategy",projectId:i,featureId:l,environmentId:e.name,variant:"outlined",size:"small"})]}),t.jsxs(Dc,{children:[t.jsx(Ec,{children:t.jsx(Cc,{featureEnvironment:e,isDisabled:!e.enabled,otherEnvironments:a})}),t.jsxs(Ac,{children:[t.jsxs(B,{sx:{display:"flex",flexDirection:"row"},children:[t.jsx(wc,{}),t.jsx(B,{ml:"auto",children:t.jsx(is,{label:"Add strategy",projectId:i,featureId:l,environmentId:e.name})})]}),c()&&(e==null?void 0:e.type)==="production"?t.jsx(Vn,{}):null]})]})]})})},ls={lastHourUsage:[],seenApplications:[]},$c=(e,s,a={})=>{const n=async()=>{const p=Te(`api/admin/client-metrics/features/${s}`),d=await fetch(p,{method:"GET"}).then(Pe("feature metrics"));return d.ok?d.json():ls},o=`${e}_${s}_metrics`,{data:r,error:i}=zs(o,n,{...a}),[l,c]=x.useState(!i&&!r),u=()=>{Ds(o)};return x.useEffect(()=>{c(!i&&!r)},[r,i]),{metrics:r||ls,error:i,loading:l,refetch:u,FEATURE_METRICS_CACHE_KEY:o}},Pc=e=>({yes:0,no:0,environment:e,timestamp:""}),Fc=(e,s)=>e.map(a=>s.lastHourUsage.find(o=>o.environment===a.name)||Pc(a.name)),Oc=({environment:e,...s})=>{const a=A("projectId"),n=A("featureId"),{releasePlans:o}=Je(a,n,e==null?void 0:e.name);return t.jsx(Ic,{...s,environment:{...e,releasePlans:o}})},_c=({hiddenEnvironments:e=[],onToggleEnvOpen:s})=>{var l;const a=A("projectId"),n=A("featureId"),{feature:o}=W(a,n),{metrics:r}=$c(a,n),i=Fc(o==null?void 0:o.environments,r);return o?(l=o.environments)==null?void 0:l.filter(c=>!e.includes(c.name)).map(c=>{var u;return t.jsx(Oc,{onToggleEnvOpen:s,environment:c,metrics:i.find(p=>p.environment===(c==null?void 0:c.name)),otherEnvironments:((u=o.environments)==null?void 0:u.map(p=>p.name).filter(p=>p!==c.name&&!e.includes(p)))||[]},c.name)}):null},Bc=()=>{const[e,s]=Nn("environment-visibiilty",[]),{trackEvent:a}=ie();return{hiddenEnvironments:e,onEnvironmentVisibilityChange:o=>{e.includes(o)?(s(e.filter(r=>r!==o)),a("hidden_environment",{props:{eventType:"environment unhidden"}})):(s([...e,o]),a("hidden_environment",{props:{eventType:"environment hidden"}}))}}},Mc=g(B)(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(1),maxWidth:"300px",background:"#201e42",borderRadius:e.shape.borderRadiusMedium,color:e.palette.common.white,padding:e.spacing(2),paddingRight:e.spacing(1),fontSize:e.typography.body2.fontSize})),Lc=g(ee)(({theme:e})=>({color:e.palette.secondary.border,alignSelf:"start",marginLeft:e.spacing(-1)})),zc=g(ye)(({theme:e})=>({color:e.palette.common.white,background:"none",border:"none",position:"absolute",top:e.spacing(1),right:e.spacing(1),svg:{width:e.spacing(2),height:e.spacing(2)}})),Vc=g("p")(({theme:e})=>({fontSize:e.typography.body1.fontSize,fontWeight:"bold"})),Nc=({closeProps:e})=>t.jsxs(Mc,{component:"article",children:[t.jsx(zc,{type:"button",...e,children:t.jsx(Dt,{})}),t.jsx(Vc,{children:"Decide the order evaluation"}),t.jsx("p",{children:"Strategies are evaluated in the order presented here. Drag and rearrange the strategies to get the order you prefer."}),t.jsx(Lc,{type:"button","data-action":e["data-action"],onClick:e.onClick,children:"Ok, got it!"})]}),qc=({show:e,onClose:s})=>t.jsx(qn,{callback:({action:a})=>{a==="close"&&s()},floaterProps:{styles:{arrow:{color:"#201e42",spread:16,length:10}}},run:e,disableOverlay:!0,disableScrolling:!0,tooltipComponent:Nc,steps:[{disableBeacon:!0,offset:0,target:".strategy-drag-handle",content:t.jsx(t.Fragment,{})}]}),Wc=g(B)(({theme:e})=>({marginBottom:e.spacing(2)})),ds=g(B)(({theme:e})=>({display:"flex",gap:e.spacing(1),alignItems:"center"})),Hc=30,Uc=3,Gc=({feature:e,onChange:s})=>{const a=le(),{trackEvent:n}=ie(),[o,r]=x.useState(!1),[i,l]=x.useState(!1),{onUncompleteHandler:c,loading:u}=Wn({feature:e.name,project:e.project,onChange:s}),p=Hn(e),d=e.type==="release"||e.type==="experiment",m=p==null?void 0:p.enteredStageAt,j=m?Un(new Date,wt(m)):0,{shouldShowReminder:y,snoozeReminder:b}=ar(),f=(()=>{if(!p||!d)return null;if(p.name==="live"&&j>Hc)return"complete";if(p.name==="completed"&&y(e.name)){if(Yn(p.environments))return"archive";if(j>Uc)return"removeCode"}return null})();return f?t.jsxs(Wc,{children:[f==="complete"&&t.jsxs(t.Fragment,{children:[t.jsxs(Z,{severity:"info",icon:t.jsx(Gn,{}),action:t.jsx(J,{variant:"contained",permission:we,size:"medium",onClick:()=>r(!0),projectId:e.project,children:"Mark completed"}),children:[t.jsx("b",{children:"Is this flag ready to be completed?"}),t.jsxs("p",{children:["This flag has been in production for"," ",t.jsxs("b",{children:[j," days"]}),". Can it be removed from the code?"]})]}),t.jsx(Js,{isOpen:o,setIsOpen:r,projectId:e.project,featureId:e.name,onComplete:s})]}),f==="archive"&&t.jsxs(t.Fragment,{children:[t.jsxs(Z,{severity:"warning",icon:t.jsx(Yt,{}),action:t.jsxs(ds,{children:[t.jsx(ee,{size:"medium",onClick:()=>{b(e.name),n("feature-lifecycle",{props:{eventType:"snoozeReminder"}})},children:"Remind me later"}),t.jsx(J,{variant:"contained",permission:qs,size:"medium",onClick:()=>l(!0),projectId:e.project,children:"Archive flag"})]}),children:[t.jsx("b",{children:"Time to clean up technical debt?"}),t.jsx("p",{children:"We haven't observed any metrics for this flag lately. Can it be archived?"})]}),e.children.length>0?t.jsx(It,{features:e.children,project:e.project,isOpen:i,onClose:()=>l(!1)}):t.jsx(Et,{isOpen:i,onConfirm:()=>{a(`/projects/${e.project}`)},onClose:()=>l(!1),projectId:e.project,featureIds:[e.name]})]}),f==="removeCode"&&t.jsxs(Z,{severity:"warning",icon:t.jsx(Yt,{}),action:t.jsxs(ds,{children:[t.jsx(ee,{size:"medium",onClick:()=>{b(e.name),n("feature-lifecycle",{props:{eventType:"snoozeReminder"}})},children:"Remind me later"}),t.jsx(J,{variant:"outlined",permission:we,size:"medium",onClick:c,disabled:u,projectId:e.project,children:"Revert to previous stage"})]}),children:[t.jsx("b",{children:"Time to remove flag from code?"}),t.jsx("p",{children:"This flag was marked as complete and ready for cleanup. We're still seeing it being used within the last 2 days. Have you removed the flag from your code?"})]})]}):null},Yc=g("div")(({theme:e})=>({display:"flex",width:"100%",gap:e.spacing(2),[e.breakpoints.down("md")]:{flexDirection:"column"}})),Jc=g("div")(({theme:e})=>({display:"flex",flexDirection:"column",flexGrow:1,gap:e.spacing(2)})),Kc=()=>{const e=le(),s=A("projectId"),a=A("featureId"),n=Rt(s,a),{hiddenEnvironments:o,onEnvironmentVisibilityChange:r}=Bc(),i=()=>e(n);Ws(a);const{setLastViewed:l}=di();x.useEffect(()=>{l({featureId:a,projectId:s})},[a]);const{setSplashSeen:c}=Jn(),{splash:u}=Kn(),[p,d]=x.useState(!1),[m,j]=x.useState(!1),{feature:y,refetchFeature:b,loading:h}=W(s,a),f="strategy-drag-tooltip",T=!(u!=null&&u[f]),E=_=>{d(!m&&T&&_)},O=()=>{j(!0),c(f)};return t.jsxs("div",{children:[t.jsx(Gc,{feature:y,onChange:b}),t.jsxs(Yc,{children:[t.jsx("div",{children:h?null:t.jsx(ri,{hiddenEnvironments:o,onEnvironmentVisibilityChange:r,feature:y,onChange:b})}),t.jsx(Jc,{children:t.jsx(_c,{onToggleEnvOpen:E,hiddenEnvironments:o})}),t.jsxs(Hs,{children:[t.jsx(ve,{path:"strategies/create",element:t.jsx(ft,{label:"Create feature strategy",onClose:i,open:!0,children:t.jsx(ci,{})})}),t.jsx(ve,{path:"strategies/edit",element:t.jsx(ft,{label:"Edit feature strategy",onClose:i,open:!0,children:t.jsx(Qn,{})})})]})]}),t.jsx(qc,{show:p,onClose:O})]})},Qc=g("div")(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"},marginTop:e.spacing(-3.5),marginBottom:e.spacing(2),backgroundColor:e.palette.background.default,paddingTop:e.spacing(2),paddingBottom:e.spacing(2),position:"sticky",top:0,zIndex:2})),Xc=g(Us,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:s})=>({color:s?e.palette.neutral.border:e.palette.primary.main})),Zc=g("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:s})=>({color:s?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontSize:e.fontSizes.mainHeader,fontWeight:e.fontWeight.bold})),el=g("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),tl=g(Z)(({theme:e})=>({marginBottom:e.spacing(2)})),sl=g(Z)(({theme:e})=>({marginTop:e.spacing(4)})),al=g("div")({display:"flex",flexDirection:"column"}),nl=g("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),ps=g("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),ol=g(Gs)(({theme:e})=>({margin:e.spacing(4,0)})),rl=g(Xn)(({theme:e})=>({minWidth:e.spacing(20),width:"100%"})),il=g("div")(({theme:e})=>({marginTop:"auto",paddingTop:e.spacing(4),display:"flex",justifyContent:"flex-end"})),cl=g(ee)(({theme:e})=>({marginLeft:e.spacing(3)})),ll=x.memo(Zn),dl=({environment:e,open:s,setOpen:a,getApiPayload:n,getCrPayload:o,onConfirm:r})=>{const i=A("projectId"),l=A("featureId"),{uiConfig:c}=ge(),{context:u}=eo(),{defaultStickiness:p,loading:d}=to(i),{isChangeRequestConfigured:m}=te(i),{data:j}=ce(i),{changeRequestInReviewOrApproved:y,alert:b}=ao(j),h=(e==null?void 0:e.variants)||[],[f,T]=x.useState([]),[E,O]=x.useState();x.useEffect(()=>{d||T(h.length?h.map(w=>({...w,isValid:!0,new:!1,id:st()})):[{name:"",weightType:Nt.VARIABLE,weight:0,overrides:[],stickiness:(f==null?void 0:f.length)>0?f[0].stickiness:p,new:!0,isValid:!1,id:st()}])},[s,d]);const _=(w,U)=>{T(je=>qt(je.map(G=>G.id===U?w:G),1e3))},$=()=>{const w=st();T(U=>[...U,{name:"",weightType:Nt.VARIABLE,weight:0,overrides:[],stickiness:(U==null?void 0:U.length)>0?U[0].stickiness:p,new:!0,isValid:!1,id:w}]),O(w)};x.useEffect(()=>{if(E){const w=document.getElementById(`variant-name-input-${E}`);w==null||w.scrollIntoView({behavior:"smooth",block:"center"}),w==null||w.focus({preventScroll:!0}),O(void 0)}},[E]);const D=f.map(({new:w,isValid:U,id:je,...G})=>G),I=n(h,D),R=o(D),z=async w=>{w.preventDefault(),r(D)},Y=()=>v?`curl --location --request POST '${c.unleashUrl}/api/admin/projects/${i}/environments/${e==null?void 0:e.name}/change-requests' \\
@@ -7,4 +7,4 @@ import{aG as ms,aH as js,_ as bt,aI as ma,a as K,aJ as qe,j as t,s as g,aK as ja
7
7
  --data-raw '${JSON.stringify(R,void 0,2)}'`:`curl --location --request PATCH '${c.unleashUrl}/api/admin/projects/${i}/features/${l}/environments/${e==null?void 0:e.name}/variants' \\
8
8
  --header 'Authorization: INSERT_API_KEY' \\
9
9
  --header 'Content-Type: application/json' \\
10
- --data-raw '${JSON.stringify(I.patch,void 0,2)}'`,Q=f.every(({isValid:w})=>w),C=y((e==null?void 0:e.name)||""),P=C?"Add to existing change request":"Add change to draft",v=m((e==null?void 0:e.name)||""),S=x.useMemo(()=>{var w;return d?"":((w=D[0])==null?void 0:w.stickiness)||p},[d,p,JSON.stringify(D[0]??{})]),F=x.useMemo(()=>["default",...u.filter(w=>w.stickiness).map(w=>w.name)],[u]),V=F.map(w=>({key:w,label:w}));F.includes(S)||V.push({key:S,label:S});const N=async w=>{T(U=>U.map(je=>({...je,stickiness:w})))},k=w=>{N(w)},[ne,he]=x.useState();x.useEffect(()=>{he(void 0),I.error&&he(I.error)},[I.error]);const me=()=>{N(p),a(!1)};return d||S===""?t.jsx(so,{}):t.jsx(ft,{open:s,onClose:me,label:"",children:t.jsxs(Ps,{modal:!0,title:"",description:"Variants allow you to return a variant object if the feature flag is considered enabled for the current request.",documentationLink:"https://docs.getunleash.io/reference/feature-toggle-variants",documentationLinkLabel:"Feature flag variants documentation",formatApiCode:Y,loading:!s,children:[t.jsxs(Qc,{children:[t.jsxs("div",{children:[t.jsx(Xc,{deprecated:!(e!=null&&e.enabled)}),t.jsx(Zc,{deprecated:!(e!=null&&e.enabled),children:e==null?void 0:e.name})]}),t.jsx(J,{"data-testid":"MODAL_ADD_VARIANT_BUTTON",onClick:$,variant:"outlined",permission:Re,projectId:i,environmentId:e==null?void 0:e.name,children:"Add variant"})]}),t.jsxs(el,{onSubmit:z,children:[t.jsx(L,{condition:C,show:b,elseShow:t.jsx(L,{condition:!!v,show:t.jsxs(tl,{severity:"info",children:[t.jsx("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.jsx(al,{children:f.map(w=>t.jsx(ll,{variant:w,variants:f,updateVariant:U=>_(U,w.id),removeVariant:()=>T(U=>qt(U.filter(je=>je.id!==w.id),1e3)),error:I.error},w.id))}),t.jsx(J,{onClick:$,variant:"outlined",permission:Re,projectId:i,environmentId:e==null?void 0:e.name,children:"Add variant"}),t.jsx(ol,{}),t.jsx(L,{condition:f.length>0,show:t.jsxs(t.Fragment,{children:[t.jsx(nl,{children:t.jsx("p",{children:"Stickiness"})}),t.jsxs(ps,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t.jsx(Ye,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]}),t.jsx("div",{children:t.jsx(rl,{value:S,label:"",editable:!0,onChange:w=>k(w.target.value)})})]}),elseShow:t.jsx(ps,{children:"This environment has no variants. Get started by adding a variant."})}),t.jsxs(sl,{severity:"error",hidden:!ne,children:[t.jsx("strong",{children:"Error: "}),ne]}),t.jsxs(il,{children:[t.jsx(ee,{"data-testid":"DIALOGUE_CONFIRM_ID",type:"submit",variant:"contained",color:"primary",disabled:!Q,children:v?P:"Save variants"}),t.jsx(cl,{onClick:me,children:"Cancel"})]})]})]})})},pl=e=>fetch(e).then(Pe("ChangeRequest")).then(s=>s.json()),ul=(e,s)=>{const{data:a,error:n,mutate:o}=Ls([],Te(`api/admin/projects/${e}/change-requests/scheduled?variantForFlag=${s}`),pl);return{changeRequests:a,loading:!n&&!a,refetch:o,error:n}},gl=(e,s,a)=>{const{changeRequests:n}=ul(e,s),o=n==null?void 0:n.filter(r=>r.environment===a);return o?o.map(r=>r.id):[]},hl=g("div")(({theme:e})=>({padding:e.spacing(3),borderRadius:e.shape.borderRadiusLarge,border:`1px solid ${e.palette.divider}`,"&:not(:last-child)":{marginBottom:e.spacing(3)}})),xl=g("div")({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"}}),fl=g(Us,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:s})=>({color:s?e.palette.neutral.border:e.palette.primary.main})),yl=g("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:s})=>({color:s?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontWeight:e.fontWeight.bold})),ml=g("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),jl=g("div")(({theme:e})=>({margin:e.spacing(3,0)})),bl=g("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),vl=({environment:e,searchValue:s,children:a})=>{var c;const n=A("projectId"),o=A("featureId"),r=gl(n,o,e.name),i=e.variants??[],l=((c=i[0])==null?void 0:c.stickiness)||"default";return t.jsxs(hl,{children:[t.jsxs(xl,{children:[t.jsxs("div",{children:[t.jsx(fl,{deprecated:!e.enabled}),t.jsx(yl,{deprecated:!e.enabled,children:e.name}),t.jsx(L,{condition:r.length>0,show:t.jsx(no,{sx:{ml:2},children:t.jsx(da,{scheduledChangeRequestIds:r})})})]}),a]}),t.jsx(L,{condition:i.length>0,show:t.jsxs(t.Fragment,{children:[t.jsx(jl,{children:t.jsx(oo,{variants:i,searchValue:s})}),t.jsx(L,{condition:i.length>1,show:t.jsxs(t.Fragment,{children:[t.jsxs(bl,{children:[t.jsx("p",{children:"Stickiness:"}),t.jsx(Ee,{children:l})]}),t.jsxs(ml,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t.jsx(Ye,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]})]})})]})})]})},Sl=g(Ce)(({theme:e})=>({"& span":{fontSize:e.fontSizes.smallBody}})),Cl=({environment:e,permission:s,projectId:a,environmentId:n,onCopyVariantsFrom:o,otherEnvsWithVariants:r})=>{const[i,l]=x.useState(null),c=!!i,u=e.variants??[];return t.jsx(L,{condition:r.length>0&&u.length===0,show:t.jsxs(t.Fragment,{children:[t.jsx(J,{onClick:p=>{l(p.currentTarget)},id:`copy-from-menu-${e.name}`,"aria-controls":c?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":c?"true":void 0,variant:"outlined",permission:s,projectId:a,environmentId:n,children:"Copy variants from"}),t.jsx(Xe,{anchorEl:i,open:c,onClose:()=>l(null),MenuListProps:{"aria-labelledby":`copy-from-menu-${e.name}`},children:r.map(p=>t.jsx(Se,{onClick:()=>o(p,e),children:t.jsx(Sl,{children:`Copy from ${p.name}`})},p.name))})]})})},Tl=({permission:e,projectId:s,environment:a,checked:n,onClick:o,...r})=>{const i=xt(e,s,a);return t.jsxs(Se,{disabled:!i,onClick:o,...r,children:[t.jsx(Ss,{checked:n}),a]})},wl=g(Xe)(({theme:e})=>({"& > div > ul":{display:"flex",flexDirection:"column",justifyContent:"center","& > li":{padding:e.spacing(0,1)}}})),kl=g("div")(({theme:e})=>({margin:e.spacing(1,2)})),Rl=g(ee)(({theme:e})=>({marginTop:e.spacing(2)})),Dl=({current:e,environments:s,permission:a,projectId:n,onSubmit:o})=>{var b;const[r,i]=x.useState(null),l=!!r,[c,u]=x.useState([]),p=h=>{u(f=>[...f,h])},d=h=>{u(f=>f.filter(({name:T})=>T!==h.name))},m=h=>{c.includes(h)?d(h):p(h)},j=()=>{u([]),i(null)},y=((b=s.find(h=>h.name===e))==null?void 0:b.variants)??[];return t.jsx(L,{condition:y.length>0&&s.length>1,show:t.jsxs(t.Fragment,{children:[t.jsx(ee,{onClick:h=>{i(h.currentTarget)},id:`push-to-menu-${e}`,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,variant:"outlined",children:"Copy to environment"}),t.jsxs(wl,{anchorEl:r,open:l,onClose:()=>i(null),MenuListProps:{"aria-labelledby":`push-to-menu-${e}`},children:[s.filter(h=>h.name!==e).map(h=>t.jsx(Tl,{projectId:n,permission:a,environment:h.name,checked:c.includes(h),onClick:()=>m(h)},h.name)),t.jsxs(kl,{children:[t.jsx(Gs,{}),t.jsxs(Rl,{variant:"outlined",onClick:()=>{o(c),j()},disabled:c.length===0,children:["Push to selected (",c.length,")"]})]})]})]})})},Al=g("div")(({theme:e})=>({display:"flex",gap:e.spacing(1.5)})),El=()=>{const{setToastData:e,setToastApiError:s}=H(),a=$e(),n=Qe(a.breakpoints.down("md")),o=A("projectId"),r=A("featureId"),{feature:i,refetchFeature:l,loading:c}=W(o,r),{patchFeatureEnvironmentVariants:u,overrideVariantsInEnvironments:p}=Ge(),{refetch:d}=ce(o),{addChange:m}=ue(),{isChangeRequestConfigured:j}=te(o),[y,b]=x.useState(""),[h,f]=x.useState(),[T,E]=x.useState(!1),O=x.useMemo(()=>{var C;return((C=i==null?void 0:i.environments)==null?void 0:C.map(P=>({...P,crEnabled:j(P.name)})))||[]},[i.environments]),_=(C,P)=>co(C,P),$=(C,P)=>{try{const v=io(P,1e3);return{patch:_(C,v)}}catch(v){return{patch:[],error:q(v)}}},D=C=>({feature:r,action:"patchVariant",payload:{variants:C}}),I=async(C,P)=>{if(C.crEnabled)await m(o,C.name,D(P)),d();else{const v=C.variants??[],{patch:S,error:F}=$(v,P);if(S.length===0)return;if(F){e({type:"error",text:F});return}await u(o,r,C.name,S)}l()},R=async(C,P)=>{try{const v=P.filter(({crEnabled:k})=>k),S=P.filter(({crEnabled:k})=>!k);v.length&&await Promise.all(v.map(k=>m(o,k.name,D(C)))),S.length&&await p(o,r,C,S.map(({name:k})=>k)),d(),l();const F=S.length?`Variants pushed to ${S.length===1?S[0].name:`${S.length} environments`}`:"",V=v.length?`Variants push added to ${v.length===1?`${v[0].name} draft`:`${v.length} drafts`}`:"",N=`${F}${F&&V?". ":""}${V}`;e({text:N,type:"success"})}catch(v){s(q(v))}},z=C=>{f(C),E(!0)},Y=async C=>{if(h)try{await I(h,C),E(!1),e({text:h.crEnabled?"Variant changes added to draft":"Variants updated successfully",type:"success"})}catch(P){s(q(P))}},Q=async(C,P)=>{try{const v=C.variants??[];await I(P,v),e({text:P.crEnabled?"Variants copy added to draft":"Variants copied successfully",type:"success"})}catch(v){s(q(v))}};return t.jsxs(Ze,{isLoading:c,header:t.jsx(At,{title:"Variants",actions:t.jsx(L,{condition:!n,show:t.jsx(t.Fragment,{children:t.jsx(Wt,{initialValue:y,onChange:b})})}),children:t.jsx(L,{condition:n,show:t.jsx(Wt,{initialValue:y,onChange:b})})}),children:[t.jsx(ro,{}),O.map(C=>{var v;const P=O.filter(({name:S,variants:F})=>S!==C.name&&(F==null?void 0:F.length));return t.jsx(vl,{environment:C,searchValue:y,children:t.jsxs(Al,{children:[t.jsx(Dl,{current:C.name,environments:O,permission:Re,projectId:o,onSubmit:S=>R(C.variants??[],S)}),t.jsx(Cl,{environment:C,permission:Re,projectId:o,environmentId:C.name,onCopyVariantsFrom:Q,otherEnvsWithVariants:P}),t.jsx(L,{condition:!!((v=C.variants)!=null&&v.length),show:t.jsx(De,{"data-testid":"EDIT_VARIANTS_BUTTON",onClick:()=>z(C),permission:Re,projectId:o,environmentId:C.name,tooltipProps:{title:"Edit variants"},children:t.jsx(We,{})}),elseShow:t.jsx(J,{"data-testid":"ADD_VARIANT_BUTTON",onClick:()=>z(C),variant:"outlined",permission:Re,projectId:o,environmentId:C.name,children:"Add variant"})})]})},C.name)}),t.jsx(dl,{environment:h,open:T,setOpen:E,getApiPayload:$,getCrPayload:D,onConfirm:Y})]})},Il=({enabled:e,value:s,onChange:a,filter:n,...o})=>{const{projects:r}=Ys();if(!e)return null;const i=c=>({key:c.id,label:c.name,title:c.description||"",sx:{whiteSpace:"pre-line"}});let l;return n?l=r.filter(c=>n(c.id)).map(i):l=r.map(i),s&&!l.find(c=>c.key===s)&&l.push({key:s,label:s}),t.jsx(Ts,{label:"Project",options:l,value:s,onChange:a,...o})},$l=(e,s)=>{const a=new Set(e),n=new Set(s);return a.size!==n.size?!1:[...a].every(o=>n.has(o))},us=g("div")(({theme:e})=>({display:"grid",gap:e.spacing(2)})),gs=g(Z)(({theme:e})=>({marginBottom:e.spacing(1)})),Pl=g(kt)({padding:0}),Fl=({projectId:e,open:s,onClose:a,onClick:n,feature:o,changeRequests:r})=>{const i=A("projectId"),{project:l}=lo(e),{isChangeRequestConfiguredInAnyEnv:c}=te(e),u=c(),p=x.useMemo(()=>{var j;return $l(o.environments.map(y=>y.name),((j=l.environments)==null?void 0:j.map(y=>y.environment))||[])},[o,l]),d=r?r.length>0:!1,m=o.dependencies.length>0||o.children.length>0;return t.jsx(L,{condition:p&&!m&&!d&&!u,show:t.jsx(pe,{open:s,onClose:a,onClick:n,title:"Confirm change project",primaryButtonText:"Change project",secondaryButtonText:"Cancel",children:t.jsxs(us,{children:[t.jsx(gs,{severity:"success",children:"This feature flag is compatible with the new project."}),t.jsx("p",{children:"Are you sure you want to change the project for this flag?"})]})}),elseShow:t.jsx(pe,{open:s,onClick:a,title:"Confirm change project",primaryButtonText:"Close",children:t.jsxs(us,{children:[t.jsx(gs,{severity:"warning",children:"Cannot proceed with the move"}),t.jsx(L,{condition:m,show:t.jsxs("p",{children:[t.jsx("span",{children:"The feature flag must not have any dependencies."})," ",t.jsx("br",{}),t.jsx("span",{children:"Please remove feature dependencies first."})]})}),t.jsx(L,{condition:!p,show:t.jsx("p",{children:"In order to move a feature flag between two projects, both projects must have the exact same environments enabled."})}),t.jsx(L,{condition:d,show:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"The feature flag must not have any pending change requests. This feature flag is currently referenced in the following change requests:"}),t.jsx(Pl,{children:r==null?void 0:r.map(j=>t.jsx(ze,{children:t.jsxs(ae,{to:`/projects/${i}/change-requests/${j.id}`,children:["View change request"," ",j.id]})},j.id))})]})}),t.jsx(L,{condition:u,show:t.jsxs("p",{children:["You're not allowed to move the feature to project"," ",t.jsx(ae,{to:`/projects/${e}/settings/change-requests`,children:e}),". This project has change requests enabled."]})})]})})})},Ol=()=>{const{hasAccess:e}=x.useContext(Es),s=A("projectId"),a=A("featureId"),{feature:n,refetchFeature:o}=W(s,a),[r,i]=x.useState(!1),{changeFeatureProject:l}=Ge(),{setToastData:c,setToastApiError:u}=H(),[p,d]=x.useState(s),{projects:m}=Ys(),j=le(),{changeRequests:y}=la(s,a),b=async()=>{try{p&&(await l(s,a,p),o(),c({text:"Project changed",type:"success"}),i(!1),j(`/projects/${p}/features/${a}/settings`,{replace:!0}))}catch(f){u(q(f))}},h=x.useMemo(()=>m.map(f=>f.id).filter(f=>e(Ht,f)),[m,e]);return h.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx(Il,{value:p,onChange:d,label:"Project",filter:f=>h.includes(f),enabled:!0}),t.jsx(J,{permission:Ht,onClick:()=>i(!0),disabled:p===s,projectId:s,children:"Save"}),t.jsx(Fl,{changeRequests:y,projectId:p,open:r,feature:n,onClose:()=>i(!1),onClick:b})]})},_l=g("div")({display:"flex",alignItems:"center"}),Bl=g(M)(({theme:e})=>({fontSize:e.fontSizes.mainHeader})),Ml=({projectId:e,featureId:s})=>{var r;const{feature:a}=W(e,s),n=le(),o=()=>{n(`/projects/${e}/features/${s}/edit`)};return t.jsxs(t.Fragment,{children:[t.jsxs(_l,{children:[t.jsx(Bl,{children:"Feature information"}),t.jsx(De,{permission:we,projectId:e,"data-loading":!0,onClick:o,tooltipProps:{title:"Edit"},children:t.jsx(We,{})})]}),t.jsxs(M,{children:["Name: ",t.jsx("strong",{children:a.name})]}),t.jsxs(M,{children:["Description:"," ",t.jsx("strong",{children:(r=a.description)!=null&&r.length?a.description:"no description"})]}),t.jsxs(M,{children:["Type: ",t.jsx("strong",{children:a.type})]}),t.jsxs(M,{children:["Impression Data:"," ",t.jsx("strong",{children:a.impressionData?"enabled":"disabled"})]})]})},Le="metadata",lt="project",Ll=g("div")(({theme:e})=>({width:"20%",borderRight:`1px solid ${e.palette.divider}`,padding:e.spacing(2,0),[e.breakpoints.down("md")]:{width:"35%"}})),zl=g("div")(({theme:e})=>({padding:e.spacing(4),display:"flex",flexDirection:"column",width:400,"& > *":{margin:e.spacing(1,0)}})),Vl=()=>{const e=A("projectId"),s=A("featureId"),[a,n]=x.useState(Le),{uiConfig:o}=ge();return t.jsx(Ze,{header:"Settings",sx:{padding:0},children:t.jsxs(B,{sx:{display:"flex"},children:[t.jsx(Ll,{children:t.jsxs(kt,{children:[t.jsx(ze,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>n(Le),selected:a===Le,children:"Metadata"},0),t.jsx(ze,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>n(lt),selected:a===lt,hidden:!o.flags.P,children:"Project"},1)]})}),t.jsxs(zl,{children:[t.jsx(L,{condition:a===Le,show:t.jsx(Ml,{projectId:e,featureId:s})}),t.jsx(L,{condition:a===lt&&o.flags.P,show:t.jsx(Ol,{})})]})]})})},hs=g("strong")({wordBreak:"break-all"}),Nl=()=>{const e=A("projectId"),s=A("featureId"),{features:a}=po({project:`IS:${e}`,archived:"IS:true"}),n=uo(e,{name:s});return a?a.some(r=>r.name===s)?t.jsxs("p",{children:["The feature ",t.jsx(hs,{children:s})," has been archived. You can find it on the"," ",t.jsx(ae,{to:`/projects/${e}?archived=IS%3Atrue`,children:"project overview with archived flags filter"}),"."]}):t.jsxs("p",{children:["The feature ",t.jsx(hs,{children:s})," does not exist. Would you like to"," ",t.jsx(ae,{to:n,children:"create it"}),"?"]}):null};var Pt={},ql=_e;Object.defineProperty(Pt,"__esModule",{value:!0});var ua=Pt.default=void 0,Wl=ql(Oe()),Hl=t,Ul=(0,Wl.default)((0,Hl.jsx)("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM6.24 5h11.52l.81.97H5.44l.8-.97zM5 19V8h14v11H5zm8.45-9h-2.9v3H8l4 4 4-4h-2.55z"}),"ArchiveOutlined");ua=Pt.default=Ul;var Ft={},Gl=_e;Object.defineProperty(Ft,"__esModule",{value:!0});var ga=Ft.default=void 0,Yl=Gl(Oe()),Jl=t,Kl=(0,Yl.default)((0,Jl.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm.5-13H11v6l5.2 3.2.8-1.3-4.5-2.7V7z"}),"WatchLaterOutlined");ga=Ft.default=Kl;var Ot={},Ql=_e;Object.defineProperty(Ot,"__esModule",{value:!0});var ha=Ot.default=void 0,Xl=Ql(Oe()),Zl=t,ed=(0,Xl.default)((0,Zl.jsx)("path",{d:"M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H8V4h12v12zm-7-2h2v-3h3V9h-3V6h-2v3h-3v2h3z"}),"LibraryAddOutlined");ha=Ot.default=ed;const td=({stale:e,showActive:s=!0})=>{if(!e&&!s)return null;const a=e?"Feature flag is deprecated.":"Feature flag is active.",n=e?"Stale":"Active";return t.jsx("div",{"data-loading":!0,children:t.jsx(Ee,{color:e?"error":"success",title:a,children:n})})},sd=e=>go({key:"c",modifiers:["ctrl"],preventDefault:!1},()=>{var a;const s=(a=window.getSelection)==null?void 0:a.call(window);s&&(s.type==="None"||s.type==="Caret")&&e()});var _t={},ad=_e;Object.defineProperty(_t,"__esModule",{value:!0});var xa=_t.default=void 0,nd=ad(Oe()),od=t,rd=(0,nd.default)((0,od.jsx)("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4H8c-1.1 0-1.99.9-1.99 2L6 21c0 1.1.89 2 1.99 2H19c1.1 0 2-.9 2-2V11l-6-6zM8 21V7h6v5h5v9H8z"}),"FileCopyOutlined");xa=_t.default=rd;const xs=18/8,id=({name:e})=>{const[s,a]=x.useState(!1),{setToastData:n}=H(),o=()=>{try{xo(e),a(!0);const i=setTimeout(()=>{a(!1)},3e3);return()=>{clearTimeout(i)}}catch{n({type:"error",text:"Could not copy feature name"})}},r=sd(o);return t.jsx(re,{title:s?"Copied!":`Copy name (${r})`,arrow:!0,children:t.jsx(ye,{onClick:o,children:s?t.jsx(ho,{sx:i=>({fontSize:i.spacing(xs),color:i.palette.success.main})}):t.jsx(xa,{sx:i=>({fontSize:i.spacing(xs)})})})})},cd=g("div")(({theme:e})=>({backgroundColor:"none",marginBottom:e.spacing(2),borderBottom:`1px solid ${e.palette.divider}`,containerType:"inline-size"})),Bt=(e,s)=>({"@container (min-width: 650px)":s,"@supports not (container-type: inline-size)":{[e.breakpoints.up("md")]:s}}),fa=g("div")(({theme:e})=>({display:"flex",flexFlow:"row wrap",alignItems:"center",columnGap:e.spacing(1.5)})),ld=g("div")(({theme:e})=>({display:"flex",alignItems:"center",columnGap:e.spacing(.5)})),dd=g(fa)(({theme:e})=>({justifyContent:"space-between",columnGap:0,flexFlow:"column nowrap",alignItems:"flex-start",...Bt(e,{alignItems:"center",flexFlow:"row nowrap"})})),pd=g("div",{shouldForwardProp:e=>e!=="showOnNarrowScreens"})(({theme:e,showOnNarrowScreens:s})=>({display:s?"flex":"none",flexFlow:"row nowrap",alignItems:"center",...Bt(e,{display:s?"none":"flex"})})),ud=({children:e,label:s,onClick:a})=>t.jsx(Co,{title:s,arrow:!0,onClick:n=>n.preventDefault(),children:t.jsx(ye,{"aria-label":s,onClick:a,children:e})}),gd=g(fo)({minWidth:0,maxWidth:"100%","& .MuiTabs-flexContainer":{minHeight:"unset"}}),hd=g(yo)(({theme:e})=>({textTransform:"none",width:"auto",fontSize:e.fontSizes.bodySize,padding:"0 !important",...Bt(e,{minWidth:100})}));g(ae)(()=>({maxWidth:"100%",textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}}));const xd=e=>{const s=Ke("enableLegacyVariants"),a=e.some(n=>{var o;return(o=n.variants)==null?void 0:o.length});return s||a},fd=({showOnNarrowScreens:e,feature:s,onFavorite:a,openStaleDialog:n,openDeleteDialog:o})=>t.jsxs(pd,{showOnNarrowScreens:e,children:[t.jsx(ud,{label:"Favorite this feature flag",onClick:a,"data-loading":!0,children:s.favorite?t.jsx(bo,{}):t.jsx(vo,{})}),t.jsx(De,{permission:So,projectId:s.project,"data-loading":!0,component:ae,to:`/projects/${s.project}/features/${s.name}/copy`,tooltipProps:{title:"Clone"},children:t.jsx(ha,{})}),t.jsx(De,{permission:qs,projectId:s.project,tooltipProps:{title:"Archive feature flag"},"data-loading":!0,onClick:o,children:t.jsx(ua,{})}),t.jsx(De,{onClick:n,permission:we,projectId:s.project,tooltipProps:{title:"Toggle stale state"},"data-loading":!0,children:t.jsx(ga,{})})]}),yd=({feature:e})=>{const s=A("projectId"),a=A("featureId"),{favorite:n,unfavorite:o}=mo(),{refetchFeature:r}=W(s,a),{setToastData:i,setToastApiError:l}=H(),[c,u]=x.useState(!1),[p,d]=x.useState(!1),[m,j]=x.useState(!1),y=le(),{pathname:b}=jo(),h=`/projects/${s}/features/${a}`,f=xd(e.environments),T=[{title:"Overview",path:`${h}`,name:"overview"},{title:"Metrics",path:`${h}/metrics`,name:"Metrics"},...f?[{title:"Variants",path:`${h}/variants`,name:"Variants"}]:[],{title:"Settings",path:`${h}/settings`,name:"Settings"},{title:"Event log",path:`${h}/logs`,name:"Event log"}],E=T.find($=>$.path===b)??T[0],O=async()=>{try{e.favorite?await o(s,e.name):await n(s,e.name),r()}catch{l("Something went wrong, could not update favorite")}},_=({showOnNarrowScreens:$})=>t.jsx(fd,{showOnNarrowScreens:$,feature:e,onFavorite:O,openStaleDialog:()=>j(!0),openDeleteDialog:()=>d(!0)});return t.jsxs(t.Fragment,{children:[t.jsxs(cd,{children:[t.jsxs(fa,{children:[t.jsxs(ld,{children:[t.jsx(M,{variant:"h1",children:e.name}),t.jsx(id,{name:e.name})]}),e.stale?t.jsx(td,{stale:!0}):null]}),t.jsxs(dd,{children:[t.jsx(_,{showOnNarrowScreens:!0}),t.jsx(gd,{value:E.path,indicatorColor:"primary",textColor:"primary","aria-label":"Feature flag tabs",variant:"scrollable",children:T.map($=>t.jsx(hd,{label:$.title,value:$.path,onClick:()=>y($.path),"data-testid":`TAB-${$.title}`},$.title))}),t.jsx(_,{})]})]}),e.children.length>0?t.jsx(It,{features:e.children,project:s,isOpen:p,onClose:()=>d(!1)}):t.jsx(Et,{isOpen:p,onConfirm:()=>{y(`/projects/${s}`)},onClose:()=>d(!1),projectId:s,featureIds:[a]}),t.jsx(nr,{isStale:e.stale,isOpen:m,onClose:()=>{j(!1),r()},featureId:a,projectId:s}),t.jsx(sa,{open:c,setOpen:u})]})},md=({value:e,timeZone:s})=>{const{locationSettings:a}=$s(),n=e?e instanceof Date?Ut(e,a.locale,s):Ut(wt(e),a.locale,s):void 0;return t.jsx(Ne,{lineClamp:1,children:n})};var Mt={},jd=_e;Object.defineProperty(Mt,"__esModule",{value:!0});var ya=Mt.default=void 0,bd=jd(Oe()),vd=t,Sd=(0,bd.default)((0,vd.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z"}),"Assessment");ya=Mt.default=Sd;const Cd=g(M)(({theme:e})=>({fontSize:e.fontSizes.smallerBody})),Td=({row:e})=>e.original.selectedApplications&&e.original.selectedApplications.length>1?t.jsx(Ne,{children:t.jsx(He,{tooltip:t.jsx(t.Fragment,{children:e.original.selectedApplications.map(s=>t.jsx(Cd,{children:s},s))}),children:e.original.appName})}):t.jsx(Ne,{children:e.original.appName}),wd=({metrics:e,tableSectionId:s})=>{const a=Qe(To.breakpoints.down("md")),n=x.useMemo(()=>({sortBy:[{id:"timestamp"}]}),[]),{getTableProps:o,getTableBodyProps:r,headerGroups:i,rows:l,prepareRow:c,setHiddenColumns:u}=at.useTable({initialState:n,columns:fs,data:e,autoResetHiddenColumns:!1,disableSortRemove:!0,defaultColumn:{Cell:Ne}},at.useGlobalFilter,at.useSortBy);return wo([{condition:a,columns:["appName","environment"]}],u,fs),e.length===0?null:t.jsxs(ko,{...o(),rowHeight:"standard",id:s,children:[t.jsx(Ro,{headerGroups:i}),t.jsx(Do,{...r(),children:l.map(p=>{c(p);const{key:d,...m}=p.getRowProps();return t.jsx(Ao,{hover:!0,...m,children:p.cells.map(j=>{const{key:y,...b}=j.getCellProps();return t.jsx(Eo,{...b,children:j.render("Cell")},y)})},d)})})]})},fs=[{id:"Icon",width:"1%",disableSortBy:!0,Cell:()=>t.jsx(Io,{icon:t.jsx(ya,{color:"disabled"})})},{Header:"Time",accessor:"timestamp",Cell:e=>t.jsx(md,{value:e.row.original.timestamp,timeZone:e.row.original.timestamp.includes("23:59")?"UTC":void 0})},{Header:"Application",accessor:"appName",Cell:Td},{Header:"Environment",accessor:"environment"},{id:"requested",Header:"Requested",accessor:e=>e.yes+e.no},{Header:"Exposed",accessor:"yes"}],kd=e=>e>48?`${Math.floor(e/24)} days (UTC)`:`${e} hours (local time)`,dt=g("article")(({theme:e})=>({padding:e.spacing(2),background:"transparent",borderRadius:e.spacing(2),textAlign:"center",[e.breakpoints.up("md")]:{padding:e.spacing(4)}})),pt=g("h3")(({theme:e})=>({margin:0,fontSize:e.fontSizes.bodySize,fontWeight:e.fontWeight.thin})),ut=g("p")(({theme:e})=>({fontSize:"2.25rem",fontWeight:e.fontWeight.bold,color:e.palette.primary.main})),gt=g("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})),Rd=({totalYes:e,totalNo:s,hoursBack:a,statsSectionId:n,tableSectionId:o})=>{const r=a===1?"in the last hour":`in the last ${kd(a)}`;return t.jsxs(fe,{container:!0,spacing:2,id:n,"aria-describedby":o,"aria-label":"Feature metrics summary",component:"section",children:[t.jsx(fe,{item:!0,xs:12,sm:4,children:t.jsxs(dt,{children:[t.jsx(pt,{children:"Exposure"}),t.jsx(ut,{children:t.jsx(Ve,{value:e})}),t.jsxs(gt,{children:["Total exposure of the feature in the environment"," ",r,"."]})]})}),t.jsx(fe,{item:!0,xs:12,sm:4,children:t.jsxs(dt,{children:[t.jsx(pt,{children:"Exposure %"}),t.jsxs(ut,{children:[ca(e+s,e),"%"]}),t.jsxs(gt,{children:["% total exposure of the feature in the environment"," ",r,"."]})]})}),t.jsx(fe,{item:!0,xs:12,sm:4,children:t.jsxs(dt,{children:[t.jsx(pt,{children:"Requests"}),t.jsx(ut,{children:t.jsx(Ve,{value:e+s})}),t.jsxs(gt,{children:["Total requests for the feature in the environment"," ",r,"."]})]})})]})},Dd=({metrics:e,...s})=>{const a=x.useMemo(()=>e.reduce((o,r)=>o+r.yes,0),[e]),n=x.useMemo(()=>e.reduce((o,r)=>o+r.no,0),[e]);return t.jsx(Rd,{...s,totalYes:a,totalNo:n})},Ad=({metrics:e,hoursBack:s})=>{const a=Gt(),n=Gt();return e.length===0?t.jsxs(B,{mt:6,children:[t.jsx(M,{variant:"body1",paragraph:!0,children:"We have yet to receive any metrics for this feature flag in the selected time period."}),t.jsx(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."})]}):t.jsxs(x.Suspense,{fallback:null,children:[t.jsx(B,{borderTop:1,pt:2,mt:3,borderColor:"divider",children:t.jsx(Ed,{metrics:e,hoursBack:s,statsSectionId:a})}),t.jsx(B,{mt:4,children:t.jsx(Dd,{metrics:e,hoursBack:s,statsSectionId:a,tableSectionId:n})}),t.jsx(B,{mt:4,children:t.jsx(wd,{metrics:e,tableSectionId:n})})]})},Ed=$o.lazy(()=>Po(()=>import("./FeatureMetricsChart-ClbKeGOa.js"),[])),Id=g("h2")(({theme:e})=>({margin:0,marginBottom:e.spacing(1.5),fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.thin,color:e.palette.text.secondary})),$d=g("ul")(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing(1),listStyleType:"none",padding:0,minHeight:"100%",alignItems:"center",maxHeight:"200px",overflowY:"auto"})),Pd=g("li")(({theme:e})=>({"& > [aria-pressed=true]":{backgroundColor:e.palette.background.alternative,color:e.palette.primary.contrastText},"& > [aria-pressed=true]:hover":{backgroundColor:e.palette.primary.light}})),ys=({title:e,values:s,selectedValues:a,toggleValue:n,toggleValues:o})=>{const r=c=>()=>{n(c)},i=[...s].every(c=>a.includes(c)),l=x.useMemo(()=>Array.from(s).sort((c,u)=>c.localeCompare(u)),[s]);return t.jsxs("div",{children:[t.jsx(Id,{children:e}),t.jsxs($d,{children:[o&&s.size>1&&t.jsx(ee,{size:"small",onClick:o,"aria-pressed":i,children:i?"Unselect":"Select all"}),l.map(c=>t.jsx(Pd,{children:t.jsx(As,{label:c,onClick:r(c),"aria-pressed":a==null?void 0:a.includes(c),sx:Fo})},c))]})]})},Fd=()=>{const e=A("projectId"),s=A("featureId"),a=Od(e,s);Ws("Metrics");const n=Array.from(a)[0],[o,r]=Oo({environment:nt(_o,n),applications:nt(Bo,[]),hoursBack:nt(Mo,yt)}),i=_d(s,o.hoursBack||yt),l=Array.from(i),c=l[0],{environment:u,hoursBack:p}=o,d=o.applications.filter(f=>f!==null);x.useEffect(()=>{o.applications&&o.applications.length===0&&r({applications:l})},[JSON.stringify(l)]);const m=[...i].every(f=>d.includes(f)),{featureMetrics:j}=Ks(s,p),[y,b]=x.useState(j);x.useEffect(()=>{j&&b(j)},[j]);const h=x.useMemo(()=>Ho((y==null?void 0:y.filter(f=>u===f.environment).filter(f=>d.includes(f.appName)))||[]).map(f=>({...f,appName:d.length>1?"all selected":f.appName,selectedApplications:d})),[y,u,JSON.stringify(d)]);return h?t.jsxs(Ze,{header:t.jsx(At,{title:"Exposure metrics"}),children:[t.jsxs(fe,{container:!0,component:"header",spacing:2,children:[t.jsx(fe,{item:!0,xs:12,md:4,children:t.jsx(L,{condition:a.size>0,show:t.jsx(ys,{title:"Environments",values:a,selectedValues:[u],toggleValue:f=>{r({environment:f})}})})}),t.jsx(fe,{item:!0,xs:12,md:6,children:t.jsx(L,{condition:i.size>0,show:t.jsx(ys,{title:"Applications",values:i,selectedValues:d,toggleValues:()=>{r(m?{applications:[c]}:{applications:[...i]})},toggleValue:f=>{d.includes(f)?r({applications:d.filter(T=>T!==f)}):r({applications:[...d,f]})}})})}),t.jsx(fe,{item:!0,xs:12,md:2,children:t.jsx(Uo,{hoursBack:p,setHoursBack:f=>r({hoursBack:f})})})]}),t.jsx(Ad,{metrics:h,hoursBack:p})]}):null},Od=(e,s)=>{const{feature:a}=W(e,s),n=a.environments.map(o=>o.name);return new Set(n)},_d=(e,s=yt)=>{const{featureMetrics:a=[]}=Ks(e,s),n=a.map(o=>o.appName);return new Set(n)},Bd=()=>{const{makeRequest:e,createRequest:s,errors:a,loading:n}=vt({propagateErrors:!0});return{createImpactMetric:x.useCallback(async r=>{const l=s("api/admin/impact-metrics/config",{method:"POST",body:JSON.stringify(r)},"updateImpactMetric");return e(l.caller,l.id)},[e,s]),errors:a,loading:n}},Md=e=>{const s=`api/admin/impact-metrics/config/${e}`,{data:a,refetch:n,loading:o,error:r}=Lo(Te(s),()=>zo(Te(s),"Feature Impact Metrics"));return{impactMetrics:a||{configs:[]},refetch:n,loading:o,error:r}},Ld=g(M)(({theme:e})=>({fontSize:e.fontSizes.mainHeader,fontWeight:"normal",lineHeight:e.spacing(5)})),zd=()=>{const e=A("featureId"),[s,a]=x.useState(!1),{createImpactMetric:n}=Bd(),{impactMetrics:o}=Md(e),{metadata:r,loading:i,error:l}=or(),c=()=>{a(!0)},u=x.useMemo(()=>r!=null&&r.series?Object.entries(r.series).map(([p,d])=>({name:p,...d})):[],[r]);return t.jsxs(Ze,{children:[t.jsx(At,{titleElement:t.jsx(Ld,{children:"Impact Metrics"}),actions:t.jsx(ee,{variant:"contained",startIcon:t.jsx(Tt,{}),onClick:c,disabled:i||!!l,children:"Add Chart"})}),t.jsx(t.Fragment,{children:o.configs.map(p=>t.jsx(rr,{config:p,onEdit:()=>{},onDelete:()=>{}}))}),t.jsx(ir,{open:s,onClose:()=>a(!1),onSave:p=>n({...p,feature:e}),initialConfig:void 0,metricSeries:u,loading:i})]})},Vd=()=>{const e=Ke("impactMetrics");return t.jsxs(Vo,{spacing:2,children:[e?t.jsx(zd,{}):null,t.jsx(Fd,{})]})};g(ae)(()=>({maxWidth:"100%",textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}}));const Nd=()=>{const e=A("projectId"),s=A("featureId"),{feature:a,loading:n,error:o,status:r}=W(e,s),i=No(n);return r===404?t.jsx(Nl,{}):o!==void 0?t.jsx("div",{ref:i}):t.jsxs("div",{ref:i,children:[t.jsx(yd,{feature:a}),t.jsxs(Hs,{children:[t.jsx(ve,{path:"metrics",element:t.jsx(Vd,{})}),t.jsx(ve,{path:"logs",element:t.jsx(Tr,{})}),t.jsx(ve,{path:"variants",element:t.jsx(El,{})}),t.jsx(ve,{path:"settings",element:t.jsx(Vl,{})}),t.jsx(ve,{path:"*",element:t.jsx(Kc,{})})]})]})},Yd=Object.freeze(Object.defineProperty({__proto__:null,default:Nd},Symbol.toStringTag,{value:"Module"}));export{Yd as F,kd as d};
10
+ --data-raw '${JSON.stringify(I.patch,void 0,2)}'`,Q=f.every(({isValid:w})=>w),C=y((e==null?void 0:e.name)||""),P=C?"Add to existing change request":"Add change to draft",v=m((e==null?void 0:e.name)||""),S=x.useMemo(()=>{var w;return d?"":((w=D[0])==null?void 0:w.stickiness)||p},[d,p,JSON.stringify(D[0]??{})]),F=x.useMemo(()=>["default",...u.filter(w=>w.stickiness).map(w=>w.name)],[u]),V=F.map(w=>({key:w,label:w}));F.includes(S)||V.push({key:S,label:S});const N=async w=>{T(U=>U.map(je=>({...je,stickiness:w})))},k=w=>{N(w)},[ne,he]=x.useState();x.useEffect(()=>{he(void 0),I.error&&he(I.error)},[I.error]);const me=()=>{N(p),a(!1)};return d||S===""?t.jsx(so,{}):t.jsx(ft,{open:s,onClose:me,label:"",children:t.jsxs(Ps,{modal:!0,title:"",description:"Variants allow you to return a variant object if the feature flag is considered enabled for the current request.",documentationLink:"https://docs.getunleash.io/reference/feature-toggle-variants",documentationLinkLabel:"Feature flag variants documentation",formatApiCode:Y,loading:!s,children:[t.jsxs(Qc,{children:[t.jsxs("div",{children:[t.jsx(Xc,{deprecated:!(e!=null&&e.enabled)}),t.jsx(Zc,{deprecated:!(e!=null&&e.enabled),children:e==null?void 0:e.name})]}),t.jsx(J,{"data-testid":"MODAL_ADD_VARIANT_BUTTON",onClick:$,variant:"outlined",permission:Re,projectId:i,environmentId:e==null?void 0:e.name,children:"Add variant"})]}),t.jsxs(el,{onSubmit:z,children:[t.jsx(L,{condition:C,show:b,elseShow:t.jsx(L,{condition:!!v,show:t.jsxs(tl,{severity:"info",children:[t.jsx("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.jsx(al,{children:f.map(w=>t.jsx(ll,{variant:w,variants:f,updateVariant:U=>_(U,w.id),removeVariant:()=>T(U=>qt(U.filter(je=>je.id!==w.id),1e3)),error:I.error},w.id))}),t.jsx(J,{onClick:$,variant:"outlined",permission:Re,projectId:i,environmentId:e==null?void 0:e.name,children:"Add variant"}),t.jsx(ol,{}),t.jsx(L,{condition:f.length>0,show:t.jsxs(t.Fragment,{children:[t.jsx(nl,{children:t.jsx("p",{children:"Stickiness"})}),t.jsxs(ps,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t.jsx(Ye,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]}),t.jsx("div",{children:t.jsx(rl,{value:S,label:"",editable:!0,onChange:w=>k(w.target.value)})})]}),elseShow:t.jsx(ps,{children:"This environment has no variants. Get started by adding a variant."})}),t.jsxs(sl,{severity:"error",hidden:!ne,children:[t.jsx("strong",{children:"Error: "}),ne]}),t.jsxs(il,{children:[t.jsx(ee,{"data-testid":"DIALOGUE_CONFIRM_ID",type:"submit",variant:"contained",color:"primary",disabled:!Q,children:v?P:"Save variants"}),t.jsx(cl,{onClick:me,children:"Cancel"})]})]})]})})},pl=e=>fetch(e).then(Pe("ChangeRequest")).then(s=>s.json()),ul=(e,s)=>{const{data:a,error:n,mutate:o}=Ls([],Te(`api/admin/projects/${e}/change-requests/scheduled?variantForFlag=${s}`),pl);return{changeRequests:a,loading:!n&&!a,refetch:o,error:n}},gl=(e,s,a)=>{const{changeRequests:n}=ul(e,s),o=n==null?void 0:n.filter(r=>r.environment===a);return o?o.map(r=>r.id):[]},hl=g("div")(({theme:e})=>({padding:e.spacing(3),borderRadius:e.shape.borderRadiusLarge,border:`1px solid ${e.palette.divider}`,"&:not(:last-child)":{marginBottom:e.spacing(3)}})),xl=g("div")({display:"flex",alignItems:"center",justifyContent:"space-between","& > div":{display:"flex",alignItems:"center"}}),fl=g(Us,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:s})=>({color:s?e.palette.neutral.border:e.palette.primary.main})),yl=g("span",{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:s})=>({color:s?e.palette.text.secondary:e.palette.text.primary,marginLeft:e.spacing(1.25),fontWeight:e.fontWeight.bold})),ml=g("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,marginBottom:e.spacing(1.5)})),jl=g("div")(({theme:e})=>({margin:e.spacing(3,0)})),bl=g("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1.5),marginBottom:e.spacing(.5)})),vl=({environment:e,searchValue:s,children:a})=>{var c;const n=A("projectId"),o=A("featureId"),r=gl(n,o,e.name),i=e.variants??[],l=((c=i[0])==null?void 0:c.stickiness)||"default";return t.jsxs(hl,{children:[t.jsxs(xl,{children:[t.jsxs("div",{children:[t.jsx(fl,{deprecated:!e.enabled}),t.jsx(yl,{deprecated:!e.enabled,children:e.name}),t.jsx(L,{condition:r.length>0,show:t.jsx(no,{sx:{ml:2},children:t.jsx(da,{scheduledChangeRequestIds:r})})})]}),a]}),t.jsx(L,{condition:i.length>0,show:t.jsxs(t.Fragment,{children:[t.jsx(jl,{children:t.jsx(oo,{variants:i,searchValue:s})}),t.jsx(L,{condition:i.length>1,show:t.jsxs(t.Fragment,{children:[t.jsxs(bl,{children:[t.jsx("p",{children:"Stickiness:"}),t.jsx(Ee,{children:l})]}),t.jsxs(ml,{children:["By overriding the stickiness you can control which parameter is used to ensure consistent traffic allocation across variants."," ",t.jsx(Ye,{href:"https://docs.getunleash.io/reference/feature-toggle-variants",target:"_blank",rel:"noreferrer",children:"Read more"})]})]})})]})})]})},Sl=g(Ce)(({theme:e})=>({"& span":{fontSize:e.fontSizes.smallBody}})),Cl=({environment:e,permission:s,projectId:a,environmentId:n,onCopyVariantsFrom:o,otherEnvsWithVariants:r})=>{const[i,l]=x.useState(null),c=!!i,u=e.variants??[];return t.jsx(L,{condition:r.length>0&&u.length===0,show:t.jsxs(t.Fragment,{children:[t.jsx(J,{onClick:p=>{l(p.currentTarget)},id:`copy-from-menu-${e.name}`,"aria-controls":c?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":c?"true":void 0,variant:"outlined",permission:s,projectId:a,environmentId:n,children:"Copy variants from"}),t.jsx(Xe,{anchorEl:i,open:c,onClose:()=>l(null),MenuListProps:{"aria-labelledby":`copy-from-menu-${e.name}`},children:r.map(p=>t.jsx(Se,{onClick:()=>o(p,e),children:t.jsx(Sl,{children:`Copy from ${p.name}`})},p.name))})]})})},Tl=({permission:e,projectId:s,environment:a,checked:n,onClick:o,...r})=>{const i=xt(e,s,a);return t.jsxs(Se,{disabled:!i,onClick:o,...r,children:[t.jsx(Ss,{checked:n}),a]})},wl=g(Xe)(({theme:e})=>({"& > div > ul":{display:"flex",flexDirection:"column",justifyContent:"center","& > li":{padding:e.spacing(0,1)}}})),kl=g("div")(({theme:e})=>({margin:e.spacing(1,2)})),Rl=g(ee)(({theme:e})=>({marginTop:e.spacing(2)})),Dl=({current:e,environments:s,permission:a,projectId:n,onSubmit:o})=>{var b;const[r,i]=x.useState(null),l=!!r,[c,u]=x.useState([]),p=h=>{u(f=>[...f,h])},d=h=>{u(f=>f.filter(({name:T})=>T!==h.name))},m=h=>{c.includes(h)?d(h):p(h)},j=()=>{u([]),i(null)},y=((b=s.find(h=>h.name===e))==null?void 0:b.variants)??[];return t.jsx(L,{condition:y.length>0&&s.length>1,show:t.jsxs(t.Fragment,{children:[t.jsx(ee,{onClick:h=>{i(h.currentTarget)},id:`push-to-menu-${e}`,"aria-controls":l?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":l?"true":void 0,variant:"outlined",children:"Copy to environment"}),t.jsxs(wl,{anchorEl:r,open:l,onClose:()=>i(null),MenuListProps:{"aria-labelledby":`push-to-menu-${e}`},children:[s.filter(h=>h.name!==e).map(h=>t.jsx(Tl,{projectId:n,permission:a,environment:h.name,checked:c.includes(h),onClick:()=>m(h)},h.name)),t.jsxs(kl,{children:[t.jsx(Gs,{}),t.jsxs(Rl,{variant:"outlined",onClick:()=>{o(c),j()},disabled:c.length===0,children:["Push to selected (",c.length,")"]})]})]})]})})},Al=g("div")(({theme:e})=>({display:"flex",gap:e.spacing(1.5)})),El=()=>{const{setToastData:e,setToastApiError:s}=H(),a=$e(),n=Qe(a.breakpoints.down("md")),o=A("projectId"),r=A("featureId"),{feature:i,refetchFeature:l,loading:c}=W(o,r),{patchFeatureEnvironmentVariants:u,overrideVariantsInEnvironments:p}=Ge(),{refetch:d}=ce(o),{addChange:m}=ue(),{isChangeRequestConfigured:j}=te(o),[y,b]=x.useState(""),[h,f]=x.useState(),[T,E]=x.useState(!1),O=x.useMemo(()=>{var C;return((C=i==null?void 0:i.environments)==null?void 0:C.map(P=>({...P,crEnabled:j(P.name)})))||[]},[i.environments]),_=(C,P)=>co(C,P),$=(C,P)=>{try{const v=io(P,1e3);return{patch:_(C,v)}}catch(v){return{patch:[],error:q(v)}}},D=C=>({feature:r,action:"patchVariant",payload:{variants:C}}),I=async(C,P)=>{if(C.crEnabled)await m(o,C.name,D(P)),d();else{const v=C.variants??[],{patch:S,error:F}=$(v,P);if(S.length===0)return;if(F){e({type:"error",text:F});return}await u(o,r,C.name,S)}l()},R=async(C,P)=>{try{const v=P.filter(({crEnabled:k})=>k),S=P.filter(({crEnabled:k})=>!k);v.length&&await Promise.all(v.map(k=>m(o,k.name,D(C)))),S.length&&await p(o,r,C,S.map(({name:k})=>k)),d(),l();const F=S.length?`Variants pushed to ${S.length===1?S[0].name:`${S.length} environments`}`:"",V=v.length?`Variants push added to ${v.length===1?`${v[0].name} draft`:`${v.length} drafts`}`:"",N=`${F}${F&&V?". ":""}${V}`;e({text:N,type:"success"})}catch(v){s(q(v))}},z=C=>{f(C),E(!0)},Y=async C=>{if(h)try{await I(h,C),E(!1),e({text:h.crEnabled?"Variant changes added to draft":"Variants updated successfully",type:"success"})}catch(P){s(q(P))}},Q=async(C,P)=>{try{const v=C.variants??[];await I(P,v),e({text:P.crEnabled?"Variants copy added to draft":"Variants copied successfully",type:"success"})}catch(v){s(q(v))}};return t.jsxs(Ze,{isLoading:c,header:t.jsx(At,{title:"Variants",actions:t.jsx(L,{condition:!n,show:t.jsx(t.Fragment,{children:t.jsx(Wt,{initialValue:y,onChange:b})})}),children:t.jsx(L,{condition:n,show:t.jsx(Wt,{initialValue:y,onChange:b})})}),children:[t.jsx(ro,{}),O.map(C=>{var v;const P=O.filter(({name:S,variants:F})=>S!==C.name&&(F==null?void 0:F.length));return t.jsx(vl,{environment:C,searchValue:y,children:t.jsxs(Al,{children:[t.jsx(Dl,{current:C.name,environments:O,permission:Re,projectId:o,onSubmit:S=>R(C.variants??[],S)}),t.jsx(Cl,{environment:C,permission:Re,projectId:o,environmentId:C.name,onCopyVariantsFrom:Q,otherEnvsWithVariants:P}),t.jsx(L,{condition:!!((v=C.variants)!=null&&v.length),show:t.jsx(De,{"data-testid":"EDIT_VARIANTS_BUTTON",onClick:()=>z(C),permission:Re,projectId:o,environmentId:C.name,tooltipProps:{title:"Edit variants"},children:t.jsx(We,{})}),elseShow:t.jsx(J,{"data-testid":"ADD_VARIANT_BUTTON",onClick:()=>z(C),variant:"outlined",permission:Re,projectId:o,environmentId:C.name,children:"Add variant"})})]})},C.name)}),t.jsx(dl,{environment:h,open:T,setOpen:E,getApiPayload:$,getCrPayload:D,onConfirm:Y})]})},Il=({enabled:e,value:s,onChange:a,filter:n,...o})=>{const{projects:r}=Ys();if(!e)return null;const i=c=>({key:c.id,label:c.name,title:c.description||"",sx:{whiteSpace:"pre-line"}});let l;return n?l=r.filter(c=>n(c.id)).map(i):l=r.map(i),s&&!l.find(c=>c.key===s)&&l.push({key:s,label:s}),t.jsx(Ts,{label:"Project",options:l,value:s,onChange:a,...o})},$l=(e,s)=>{const a=new Set(e),n=new Set(s);return a.size!==n.size?!1:[...a].every(o=>n.has(o))},us=g("div")(({theme:e})=>({display:"grid",gap:e.spacing(2)})),gs=g(Z)(({theme:e})=>({marginBottom:e.spacing(1)})),Pl=g(kt)({padding:0}),Fl=({projectId:e,open:s,onClose:a,onClick:n,feature:o,changeRequests:r})=>{const i=A("projectId"),{project:l}=lo(e),{isChangeRequestConfiguredInAnyEnv:c}=te(e),u=c(),p=x.useMemo(()=>{var j;return $l(o.environments.map(y=>y.name),((j=l.environments)==null?void 0:j.map(y=>y.environment))||[])},[o,l]),d=r?r.length>0:!1,m=o.dependencies.length>0||o.children.length>0;return t.jsx(L,{condition:p&&!m&&!d&&!u,show:t.jsx(pe,{open:s,onClose:a,onClick:n,title:"Confirm change project",primaryButtonText:"Change project",secondaryButtonText:"Cancel",children:t.jsxs(us,{children:[t.jsx(gs,{severity:"success",children:"This feature flag is compatible with the new project."}),t.jsx("p",{children:"Are you sure you want to change the project for this flag?"})]})}),elseShow:t.jsx(pe,{open:s,onClick:a,title:"Confirm change project",primaryButtonText:"Close",children:t.jsxs(us,{children:[t.jsx(gs,{severity:"warning",children:"Cannot proceed with the move"}),t.jsx(L,{condition:m,show:t.jsxs("p",{children:[t.jsx("span",{children:"The feature flag must not have any dependencies."})," ",t.jsx("br",{}),t.jsx("span",{children:"Please remove feature dependencies first."})]})}),t.jsx(L,{condition:!p,show:t.jsx("p",{children:"In order to move a feature flag between two projects, both projects must have the exact same environments enabled."})}),t.jsx(L,{condition:d,show:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"The feature flag must not have any pending change requests. This feature flag is currently referenced in the following change requests:"}),t.jsx(Pl,{children:r==null?void 0:r.map(j=>t.jsx(ze,{children:t.jsxs(ae,{to:`/projects/${i}/change-requests/${j.id}`,children:["View change request"," ",j.id]})},j.id))})]})}),t.jsx(L,{condition:u,show:t.jsxs("p",{children:["You're not allowed to move the feature to project"," ",t.jsx(ae,{to:`/projects/${e}/settings/change-requests`,children:e}),". This project has change requests enabled."]})})]})})})},Ol=()=>{const{hasAccess:e}=x.useContext(Es),s=A("projectId"),a=A("featureId"),{feature:n,refetchFeature:o}=W(s,a),[r,i]=x.useState(!1),{changeFeatureProject:l}=Ge(),{setToastData:c,setToastApiError:u}=H(),[p,d]=x.useState(s),{projects:m}=Ys(),j=le(),{changeRequests:y}=la(s,a),b=async()=>{try{p&&(await l(s,a,p),o(),c({text:"Project changed",type:"success"}),i(!1),j(`/projects/${p}/features/${a}/settings`,{replace:!0}))}catch(f){u(q(f))}},h=x.useMemo(()=>m.map(f=>f.id).filter(f=>e(Ht,f)),[m,e]);return h.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx(Il,{value:p,onChange:d,label:"Project",filter:f=>h.includes(f),enabled:!0}),t.jsx(J,{permission:Ht,onClick:()=>i(!0),disabled:p===s,projectId:s,children:"Save"}),t.jsx(Fl,{changeRequests:y,projectId:p,open:r,feature:n,onClose:()=>i(!1),onClick:b})]})},_l=g("div")({display:"flex",alignItems:"center"}),Bl=g(M)(({theme:e})=>({fontSize:e.fontSizes.mainHeader})),Ml=({projectId:e,featureId:s})=>{var r;const{feature:a}=W(e,s),n=le(),o=()=>{n(`/projects/${e}/features/${s}/edit`)};return t.jsxs(t.Fragment,{children:[t.jsxs(_l,{children:[t.jsx(Bl,{children:"Feature information"}),t.jsx(De,{permission:we,projectId:e,"data-loading":!0,onClick:o,tooltipProps:{title:"Edit"},children:t.jsx(We,{})})]}),t.jsxs(M,{children:["Name: ",t.jsx("strong",{children:a.name})]}),t.jsxs(M,{children:["Description:"," ",t.jsx("strong",{children:(r=a.description)!=null&&r.length?a.description:"no description"})]}),t.jsxs(M,{children:["Type: ",t.jsx("strong",{children:a.type})]}),t.jsxs(M,{children:["Impression Data:"," ",t.jsx("strong",{children:a.impressionData?"enabled":"disabled"})]})]})},Le="metadata",lt="project",Ll=g("div")(({theme:e})=>({width:"20%",borderRight:`1px solid ${e.palette.divider}`,padding:e.spacing(2,0),[e.breakpoints.down("md")]:{width:"35%"}})),zl=g("div")(({theme:e})=>({padding:e.spacing(4),display:"flex",flexDirection:"column",width:400,"& > *":{margin:e.spacing(1,0)}})),Vl=()=>{const e=A("projectId"),s=A("featureId"),[a,n]=x.useState(Le),{uiConfig:o}=ge();return t.jsx(Ze,{header:"Settings",sx:{padding:0},children:t.jsxs(B,{sx:{display:"flex"},children:[t.jsx(Ll,{children:t.jsxs(kt,{children:[t.jsx(ze,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>n(Le),selected:a===Le,children:"Metadata"},0),t.jsx(ze,{sx:{padding:"0.75rem 2rem"},button:!0,onClick:()=>n(lt),selected:a===lt,hidden:!o.flags.P,children:"Project"},1)]})}),t.jsxs(zl,{children:[t.jsx(L,{condition:a===Le,show:t.jsx(Ml,{projectId:e,featureId:s})}),t.jsx(L,{condition:a===lt&&o.flags.P,show:t.jsx(Ol,{})})]})]})})},hs=g("strong")({wordBreak:"break-all"}),Nl=()=>{const e=A("projectId"),s=A("featureId"),{features:a}=po({project:`IS:${e}`,archived:"IS:true"}),n=uo(e,{name:s});return a?a.some(r=>r.name===s)?t.jsxs("p",{children:["The feature ",t.jsx(hs,{children:s})," has been archived. You can find it on the"," ",t.jsx(ae,{to:`/projects/${e}?archived=IS%3Atrue`,children:"project overview with archived flags filter"}),"."]}):t.jsxs("p",{children:["The feature ",t.jsx(hs,{children:s})," does not exist. Would you like to"," ",t.jsx(ae,{to:n,children:"create it"}),"?"]}):null};var Pt={},ql=_e;Object.defineProperty(Pt,"__esModule",{value:!0});var ua=Pt.default=void 0,Wl=ql(Oe()),Hl=t,Ul=(0,Wl.default)((0,Hl.jsx)("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM6.24 5h11.52l.81.97H5.44l.8-.97zM5 19V8h14v11H5zm8.45-9h-2.9v3H8l4 4 4-4h-2.55z"}),"ArchiveOutlined");ua=Pt.default=Ul;var Ft={},Gl=_e;Object.defineProperty(Ft,"__esModule",{value:!0});var ga=Ft.default=void 0,Yl=Gl(Oe()),Jl=t,Kl=(0,Yl.default)((0,Jl.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm.5-13H11v6l5.2 3.2.8-1.3-4.5-2.7V7z"}),"WatchLaterOutlined");ga=Ft.default=Kl;var Ot={},Ql=_e;Object.defineProperty(Ot,"__esModule",{value:!0});var ha=Ot.default=void 0,Xl=Ql(Oe()),Zl=t,ed=(0,Xl.default)((0,Zl.jsx)("path",{d:"M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H8V4h12v12zm-7-2h2v-3h3V9h-3V6h-2v3h-3v2h3z"}),"LibraryAddOutlined");ha=Ot.default=ed;const td=({stale:e,showActive:s=!0})=>{if(!e&&!s)return null;const a=e?"Feature flag is deprecated.":"Feature flag is active.",n=e?"Stale":"Active";return t.jsx("div",{"data-loading":!0,children:t.jsx(Ee,{color:e?"error":"success",title:a,children:n})})},sd=e=>go({key:"c",modifiers:["ctrl"],preventDefault:!1},()=>{var a;const s=(a=window.getSelection)==null?void 0:a.call(window);s&&(s.type==="None"||s.type==="Caret")&&e()});var _t={},ad=_e;Object.defineProperty(_t,"__esModule",{value:!0});var xa=_t.default=void 0,nd=ad(Oe()),od=t,rd=(0,nd.default)((0,od.jsx)("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4H8c-1.1 0-1.99.9-1.99 2L6 21c0 1.1.89 2 1.99 2H19c1.1 0 2-.9 2-2V11l-6-6zM8 21V7h6v5h5v9H8z"}),"FileCopyOutlined");xa=_t.default=rd;const xs=18/8,id=({name:e})=>{const[s,a]=x.useState(!1),{setToastData:n}=H(),o=()=>{try{xo(e),a(!0);const i=setTimeout(()=>{a(!1)},3e3);return()=>{clearTimeout(i)}}catch{n({type:"error",text:"Could not copy feature name"})}},r=sd(o);return t.jsx(re,{title:s?"Copied!":`Copy name (${r})`,arrow:!0,children:t.jsx(ye,{onClick:o,children:s?t.jsx(ho,{sx:i=>({fontSize:i.spacing(xs),color:i.palette.success.main})}):t.jsx(xa,{sx:i=>({fontSize:i.spacing(xs)})})})})},cd=g("div")(({theme:e})=>({backgroundColor:"none",marginBottom:e.spacing(2),borderBottom:`1px solid ${e.palette.divider}`,containerType:"inline-size"})),Bt=(e,s)=>({"@container (min-width: 650px)":s,"@supports not (container-type: inline-size)":{[e.breakpoints.up("md")]:s}}),fa=g("div")(({theme:e})=>({display:"flex",flexFlow:"row wrap",alignItems:"center",columnGap:e.spacing(1.5)})),ld=g("div")(({theme:e})=>({display:"flex",alignItems:"center",columnGap:e.spacing(.5)})),dd=g(fa)(({theme:e})=>({justifyContent:"space-between",columnGap:0,flexFlow:"column nowrap",alignItems:"flex-start",...Bt(e,{alignItems:"center",flexFlow:"row nowrap"})})),pd=g("div",{shouldForwardProp:e=>e!=="showOnNarrowScreens"})(({theme:e,showOnNarrowScreens:s})=>({display:s?"flex":"none",flexFlow:"row nowrap",alignItems:"center",...Bt(e,{display:s?"none":"flex"})})),ud=({children:e,label:s,onClick:a})=>t.jsx(Co,{title:s,arrow:!0,onClick:n=>n.preventDefault(),children:t.jsx(ye,{"aria-label":s,onClick:a,children:e})}),gd=g(fo)({minWidth:0,maxWidth:"100%","& .MuiTabs-flexContainer":{minHeight:"unset"}}),hd=g(yo)(({theme:e})=>({textTransform:"none",width:"auto",fontSize:e.fontSizes.bodySize,padding:"0 !important",...Bt(e,{minWidth:100})}));g(ae)(()=>({maxWidth:"100%",textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}}));const xd=e=>{const s=Ke("enableLegacyVariants"),a=e.some(n=>{var o;return(o=n.variants)==null?void 0:o.length});return s||a},fd=({showOnNarrowScreens:e,feature:s,onFavorite:a,openStaleDialog:n,openDeleteDialog:o})=>t.jsxs(pd,{showOnNarrowScreens:e,children:[t.jsx(ud,{label:"Favorite this feature flag",onClick:a,"data-loading":!0,children:s.favorite?t.jsx(bo,{}):t.jsx(vo,{})}),t.jsx(De,{permission:So,projectId:s.project,"data-loading":!0,component:ae,to:`/projects/${s.project}/features/${s.name}/copy`,tooltipProps:{title:"Clone"},children:t.jsx(ha,{})}),t.jsx(De,{permission:qs,projectId:s.project,tooltipProps:{title:"Archive feature flag"},"data-loading":!0,onClick:o,children:t.jsx(ua,{})}),t.jsx(De,{onClick:n,permission:we,projectId:s.project,tooltipProps:{title:"Toggle stale state"},"data-loading":!0,children:t.jsx(ga,{})})]}),yd=({feature:e})=>{const s=A("projectId"),a=A("featureId"),{favorite:n,unfavorite:o}=mo(),{refetchFeature:r}=W(s,a),{setToastData:i,setToastApiError:l}=H(),[c,u]=x.useState(!1),[p,d]=x.useState(!1),[m,j]=x.useState(!1),y=le(),{pathname:b}=jo(),h=`/projects/${s}/features/${a}`,f=xd(e.environments),T=[{title:"Overview",path:`${h}`,name:"overview"},{title:"Metrics",path:`${h}/metrics`,name:"Metrics"},...f?[{title:"Variants",path:`${h}/variants`,name:"Variants"}]:[],{title:"Settings",path:`${h}/settings`,name:"Settings"},{title:"Event log",path:`${h}/logs`,name:"Event log"}],E=T.find($=>$.path===b)??T[0],O=async()=>{try{e.favorite?await o(s,e.name):await n(s,e.name),r()}catch{l("Something went wrong, could not update favorite")}},_=({showOnNarrowScreens:$})=>t.jsx(fd,{showOnNarrowScreens:$,feature:e,onFavorite:O,openStaleDialog:()=>j(!0),openDeleteDialog:()=>d(!0)});return t.jsxs(t.Fragment,{children:[t.jsxs(cd,{children:[t.jsxs(fa,{children:[t.jsxs(ld,{children:[t.jsx(M,{variant:"h1",children:e.name}),t.jsx(id,{name:e.name})]}),e.stale?t.jsx(td,{stale:!0}):null]}),t.jsxs(dd,{children:[t.jsx(_,{showOnNarrowScreens:!0}),t.jsx(gd,{value:E.path,indicatorColor:"primary",textColor:"primary","aria-label":"Feature flag tabs",variant:"scrollable",children:T.map($=>t.jsx(hd,{label:$.title,value:$.path,onClick:()=>y($.path),"data-testid":`TAB-${$.title}`},$.title))}),t.jsx(_,{})]})]}),e.children.length>0?t.jsx(It,{features:e.children,project:s,isOpen:p,onClose:()=>d(!1)}):t.jsx(Et,{isOpen:p,onConfirm:()=>{y(`/projects/${s}`)},onClose:()=>d(!1),projectId:s,featureIds:[a]}),t.jsx(nr,{isStale:e.stale,isOpen:m,onClose:()=>{j(!1),r()},featureId:a,projectId:s}),t.jsx(sa,{open:c,setOpen:u})]})},md=({value:e,timeZone:s})=>{const{locationSettings:a}=$s(),n=e?e instanceof Date?Ut(e,a.locale,s):Ut(wt(e),a.locale,s):void 0;return t.jsx(Ne,{lineClamp:1,children:n})};var Mt={},jd=_e;Object.defineProperty(Mt,"__esModule",{value:!0});var ya=Mt.default=void 0,bd=jd(Oe()),vd=t,Sd=(0,bd.default)((0,vd.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z"}),"Assessment");ya=Mt.default=Sd;const Cd=g(M)(({theme:e})=>({fontSize:e.fontSizes.smallerBody})),Td=({row:e})=>e.original.selectedApplications&&e.original.selectedApplications.length>1?t.jsx(Ne,{children:t.jsx(He,{tooltip:t.jsx(t.Fragment,{children:e.original.selectedApplications.map(s=>t.jsx(Cd,{children:s},s))}),children:e.original.appName})}):t.jsx(Ne,{children:e.original.appName}),wd=({metrics:e,tableSectionId:s})=>{const a=Qe(To.breakpoints.down("md")),n=x.useMemo(()=>({sortBy:[{id:"timestamp"}]}),[]),{getTableProps:o,getTableBodyProps:r,headerGroups:i,rows:l,prepareRow:c,setHiddenColumns:u}=at.useTable({initialState:n,columns:fs,data:e,autoResetHiddenColumns:!1,disableSortRemove:!0,defaultColumn:{Cell:Ne}},at.useGlobalFilter,at.useSortBy);return wo([{condition:a,columns:["appName","environment"]}],u,fs),e.length===0?null:t.jsxs(ko,{...o(),rowHeight:"standard",id:s,children:[t.jsx(Ro,{headerGroups:i}),t.jsx(Do,{...r(),children:l.map(p=>{c(p);const{key:d,...m}=p.getRowProps();return t.jsx(Ao,{hover:!0,...m,children:p.cells.map(j=>{const{key:y,...b}=j.getCellProps();return t.jsx(Eo,{...b,children:j.render("Cell")},y)})},d)})})]})},fs=[{id:"Icon",width:"1%",disableSortBy:!0,Cell:()=>t.jsx(Io,{icon:t.jsx(ya,{color:"disabled"})})},{Header:"Time",accessor:"timestamp",Cell:e=>t.jsx(md,{value:e.row.original.timestamp,timeZone:e.row.original.timestamp.includes("23:59")?"UTC":void 0})},{Header:"Application",accessor:"appName",Cell:Td},{Header:"Environment",accessor:"environment"},{id:"requested",Header:"Requested",accessor:e=>e.yes+e.no},{Header:"Exposed",accessor:"yes"}],kd=e=>e>48?`${Math.floor(e/24)} days (UTC)`:`${e} hours (local time)`,dt=g("article")(({theme:e})=>({padding:e.spacing(2),background:"transparent",borderRadius:e.spacing(2),textAlign:"center",[e.breakpoints.up("md")]:{padding:e.spacing(4)}})),pt=g("h3")(({theme:e})=>({margin:0,fontSize:e.fontSizes.bodySize,fontWeight:e.fontWeight.thin})),ut=g("p")(({theme:e})=>({fontSize:"2.25rem",fontWeight:e.fontWeight.bold,color:e.palette.primary.main})),gt=g("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})),Rd=({totalYes:e,totalNo:s,hoursBack:a,statsSectionId:n,tableSectionId:o})=>{const r=a===1?"in the last hour":`in the last ${kd(a)}`;return t.jsxs(fe,{container:!0,spacing:2,id:n,"aria-describedby":o,"aria-label":"Feature metrics summary",component:"section",children:[t.jsx(fe,{item:!0,xs:12,sm:4,children:t.jsxs(dt,{children:[t.jsx(pt,{children:"Exposure"}),t.jsx(ut,{children:t.jsx(Ve,{value:e})}),t.jsxs(gt,{children:["Total exposure of the feature in the environment"," ",r,"."]})]})}),t.jsx(fe,{item:!0,xs:12,sm:4,children:t.jsxs(dt,{children:[t.jsx(pt,{children:"Exposure %"}),t.jsxs(ut,{children:[ca(e+s,e),"%"]}),t.jsxs(gt,{children:["% total exposure of the feature in the environment"," ",r,"."]})]})}),t.jsx(fe,{item:!0,xs:12,sm:4,children:t.jsxs(dt,{children:[t.jsx(pt,{children:"Requests"}),t.jsx(ut,{children:t.jsx(Ve,{value:e+s})}),t.jsxs(gt,{children:["Total requests for the feature in the environment"," ",r,"."]})]})})]})},Dd=({metrics:e,...s})=>{const a=x.useMemo(()=>e.reduce((o,r)=>o+r.yes,0),[e]),n=x.useMemo(()=>e.reduce((o,r)=>o+r.no,0),[e]);return t.jsx(Rd,{...s,totalYes:a,totalNo:n})},Ad=({metrics:e,hoursBack:s})=>{const a=Gt(),n=Gt();return e.length===0?t.jsxs(B,{mt:6,children:[t.jsx(M,{variant:"body1",paragraph:!0,children:"We have yet to receive any metrics for this feature flag in the selected time period."}),t.jsx(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."})]}):t.jsxs(x.Suspense,{fallback:null,children:[t.jsx(B,{borderTop:1,pt:2,mt:3,borderColor:"divider",children:t.jsx(Ed,{metrics:e,hoursBack:s,statsSectionId:a})}),t.jsx(B,{mt:4,children:t.jsx(Dd,{metrics:e,hoursBack:s,statsSectionId:a,tableSectionId:n})}),t.jsx(B,{mt:4,children:t.jsx(wd,{metrics:e,tableSectionId:n})})]})},Ed=$o.lazy(()=>Po(()=>import("./FeatureMetricsChart-CQkGp91T.js"),[])),Id=g("h2")(({theme:e})=>({margin:0,marginBottom:e.spacing(1.5),fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.thin,color:e.palette.text.secondary})),$d=g("ul")(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing(1),listStyleType:"none",padding:0,minHeight:"100%",alignItems:"center",maxHeight:"200px",overflowY:"auto"})),Pd=g("li")(({theme:e})=>({"& > [aria-pressed=true]":{backgroundColor:e.palette.background.alternative,color:e.palette.primary.contrastText},"& > [aria-pressed=true]:hover":{backgroundColor:e.palette.primary.light}})),ys=({title:e,values:s,selectedValues:a,toggleValue:n,toggleValues:o})=>{const r=c=>()=>{n(c)},i=[...s].every(c=>a.includes(c)),l=x.useMemo(()=>Array.from(s).sort((c,u)=>c.localeCompare(u)),[s]);return t.jsxs("div",{children:[t.jsx(Id,{children:e}),t.jsxs($d,{children:[o&&s.size>1&&t.jsx(ee,{size:"small",onClick:o,"aria-pressed":i,children:i?"Unselect":"Select all"}),l.map(c=>t.jsx(Pd,{children:t.jsx(As,{label:c,onClick:r(c),"aria-pressed":a==null?void 0:a.includes(c),sx:Fo})},c))]})]})},Fd=()=>{const e=A("projectId"),s=A("featureId"),a=Od(e,s);Ws("Metrics");const n=Array.from(a)[0],[o,r]=Oo({environment:nt(_o,n),applications:nt(Bo,[]),hoursBack:nt(Mo,yt)}),i=_d(s,o.hoursBack||yt),l=Array.from(i),c=l[0],{environment:u,hoursBack:p}=o,d=o.applications.filter(f=>f!==null);x.useEffect(()=>{o.applications&&o.applications.length===0&&r({applications:l})},[JSON.stringify(l)]);const m=[...i].every(f=>d.includes(f)),{featureMetrics:j}=Ks(s,p),[y,b]=x.useState(j);x.useEffect(()=>{j&&b(j)},[j]);const h=x.useMemo(()=>Ho((y==null?void 0:y.filter(f=>u===f.environment).filter(f=>d.includes(f.appName)))||[]).map(f=>({...f,appName:d.length>1?"all selected":f.appName,selectedApplications:d})),[y,u,JSON.stringify(d)]);return h?t.jsxs(Ze,{header:t.jsx(At,{title:"Exposure metrics"}),children:[t.jsxs(fe,{container:!0,component:"header",spacing:2,children:[t.jsx(fe,{item:!0,xs:12,md:4,children:t.jsx(L,{condition:a.size>0,show:t.jsx(ys,{title:"Environments",values:a,selectedValues:[u],toggleValue:f=>{r({environment:f})}})})}),t.jsx(fe,{item:!0,xs:12,md:6,children:t.jsx(L,{condition:i.size>0,show:t.jsx(ys,{title:"Applications",values:i,selectedValues:d,toggleValues:()=>{r(m?{applications:[c]}:{applications:[...i]})},toggleValue:f=>{d.includes(f)?r({applications:d.filter(T=>T!==f)}):r({applications:[...d,f]})}})})}),t.jsx(fe,{item:!0,xs:12,md:2,children:t.jsx(Uo,{hoursBack:p,setHoursBack:f=>r({hoursBack:f})})})]}),t.jsx(Ad,{metrics:h,hoursBack:p})]}):null},Od=(e,s)=>{const{feature:a}=W(e,s),n=a.environments.map(o=>o.name);return new Set(n)},_d=(e,s=yt)=>{const{featureMetrics:a=[]}=Ks(e,s),n=a.map(o=>o.appName);return new Set(n)},Bd=()=>{const{makeRequest:e,createRequest:s,errors:a,loading:n}=vt({propagateErrors:!0});return{createImpactMetric:x.useCallback(async r=>{const l=s("api/admin/impact-metrics/config",{method:"POST",body:JSON.stringify(r)},"updateImpactMetric");return e(l.caller,l.id)},[e,s]),errors:a,loading:n}},Md=e=>{const s=`api/admin/impact-metrics/config/${e}`,{data:a,refetch:n,loading:o,error:r}=Lo(Te(s),()=>zo(Te(s),"Feature Impact Metrics"));return{impactMetrics:a||{configs:[]},refetch:n,loading:o,error:r}},Ld=g(M)(({theme:e})=>({fontSize:e.fontSizes.mainHeader,fontWeight:"normal",lineHeight:e.spacing(5)})),zd=()=>{const e=A("featureId"),[s,a]=x.useState(!1),{createImpactMetric:n}=Bd(),{impactMetrics:o}=Md(e),{metadata:r,loading:i,error:l}=or(),c=()=>{a(!0)},u=x.useMemo(()=>r!=null&&r.series?Object.entries(r.series).map(([p,d])=>({name:p,...d})):[],[r]);return t.jsxs(Ze,{children:[t.jsx(At,{titleElement:t.jsx(Ld,{children:"Impact Metrics"}),actions:t.jsx(ee,{variant:"contained",startIcon:t.jsx(Tt,{}),onClick:c,disabled:i||!!l,children:"Add Chart"})}),t.jsx(t.Fragment,{children:o.configs.map(p=>t.jsx(rr,{config:p,onEdit:()=>{},onDelete:()=>{}}))}),t.jsx(ir,{open:s,onClose:()=>a(!1),onSave:p=>n({...p,feature:e}),initialConfig:void 0,metricSeries:u,loading:i})]})},Vd=()=>{const e=Ke("impactMetrics");return t.jsxs(Vo,{spacing:2,children:[e?t.jsx(zd,{}):null,t.jsx(Fd,{})]})};g(ae)(()=>({maxWidth:"100%",textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}}));const Nd=()=>{const e=A("projectId"),s=A("featureId"),{feature:a,loading:n,error:o,status:r}=W(e,s),i=No(n);return r===404?t.jsx(Nl,{}):o!==void 0?t.jsx("div",{ref:i}):t.jsxs("div",{ref:i,children:[t.jsx(yd,{feature:a}),t.jsxs(Hs,{children:[t.jsx(ve,{path:"metrics",element:t.jsx(Vd,{})}),t.jsx(ve,{path:"logs",element:t.jsx(Tr,{})}),t.jsx(ve,{path:"variants",element:t.jsx(El,{})}),t.jsx(ve,{path:"settings",element:t.jsx(Vl,{})}),t.jsx(ve,{path:"*",element:t.jsx(Kc,{})})]})]})},Yd=Object.freeze(Object.defineProperty({__proto__:null,default:Nd},Symbol.toStringTag,{value:"Module"}));export{Yd as F,kd as d};
@@ -1,2 +1,2 @@
1
- import{dq as w,iZ as F,bv as E,aR as S,r as p,j as r,B as k,i_ as D,bu as A,s as g,i$ as P,j0 as I,j1 as T,j2 as B,j3 as R,j4 as L,j5 as N,b as y,T as O,j6 as j,bs as $,aT as H}from"./index-CqYZiU1N.js";import{f as V,a as W}from"./formatTickValue-DojfJagm.js";import{F as _,c as U,u as Y,b as G}from"./aggregateFeatureMetrics-ClblY5Ev.js";import{F as q,M as z}from"./MarkCompletedDialogue-CS-kM4vW.js";const J=e=>{const t={label:"Exposed",hoverBackgroundColor:"#A39EFF",backgroundColor:"#A39EFF",data:M(e,n=>n.yes)},a={label:"Not exposed",hoverBackgroundColor:"#D8D6FF",backgroundColor:"#D8D6FF",data:M(e,n=>n.no)};return{datasets:[t,a]}},M=(e,t)=>e.map(a=>({x:a.timestamp,y:t(a),variants:a.variants||{}})),Z=(e,t)=>{if(t===0)return"";const[a,n]=e,s=Math.floor(Number(n)/t*100);return`${n} (${s}%) - ${a}`},C=e=>({plugins:{legend:{position:"top",labels:{color:e.palette.text.primary,usePointStyle:!0,pointStyle:"none",boxHeight:0,padding:15,boxPadding:5}},tooltip:{enabled:!1}},responsive:!0,maintainAspectRatio:!1,scales:{x:{stacked:!0,ticks:{display:!1},grid:{display:!1}},y:{stacked:!0,ticks:{maxTicksLimit:5,display:!1},grid:{drawBorder:!1,color:e.palette.divider}}},elements:{bar:{borderRadius:5}},interaction:{mode:"index",intersect:!1}}),K=(e,t,a)=>{var m;const{responsive:n,elements:s,interaction:c,scales:o,maintainAspectRatio:i}=C(e);return{plugins:{legend:{position:"bottom",labels:{color:e.palette.text.primary,pointStyle:"circle",usePointStyle:!0,boxHeight:6,padding:15,boxPadding:5}},annotation:{clip:!1,annotations:{}},tooltip:{backgroundColor:e.palette.background.paper,titleColor:e.palette.text.primary,bodyColor:e.palette.text.primary,bodySpacing:6,padding:{top:20,bottom:20,left:30,right:30},borderColor:"rgba(0, 0, 0, 0.05)",borderWidth:3,usePointStyle:!0,caretSize:0,boxPadding:10,callbacks:{label:l=>`${l.formattedValue} - ${l.dataset.label}`,afterLabel:l=>{const d=l.dataset.data[l.dataIndex];if(l.dataset.label!=="Exposed"||d.variants===void 0)return"";const{disabled:f,...u}=d.variants;return Object.entries(u).map(b=>Z(b,d.y)).join(`
1
+ import{dq as w,iZ as F,bv as E,aR as S,r as p,j as r,B as k,i_ as D,bu as A,s as g,i$ as P,j0 as I,j1 as T,j2 as B,j3 as R,j4 as L,j5 as N,b as y,T as O,j6 as j,bs as $,aT as H}from"./index-A5We7bvX.js";import{f as V,a as W}from"./formatTickValue-D3KZyzeb.js";import{F as _,c as U,u as Y,b as G}from"./aggregateFeatureMetrics-Dli6i5No.js";import{F as q,M as z}from"./MarkCompletedDialogue-Bw9Iccid.js";const J=e=>{const t={label:"Exposed",hoverBackgroundColor:"#A39EFF",backgroundColor:"#A39EFF",data:M(e,n=>n.yes)},a={label:"Not exposed",hoverBackgroundColor:"#D8D6FF",backgroundColor:"#D8D6FF",data:M(e,n=>n.no)};return{datasets:[t,a]}},M=(e,t)=>e.map(a=>({x:a.timestamp,y:t(a),variants:a.variants||{}})),Z=(e,t)=>{if(t===0)return"";const[a,n]=e,s=Math.floor(Number(n)/t*100);return`${n} (${s}%) - ${a}`},C=e=>({plugins:{legend:{position:"top",labels:{color:e.palette.text.primary,usePointStyle:!0,pointStyle:"none",boxHeight:0,padding:15,boxPadding:5}},tooltip:{enabled:!1}},responsive:!0,maintainAspectRatio:!1,scales:{x:{stacked:!0,ticks:{display:!1},grid:{display:!1}},y:{stacked:!0,ticks:{maxTicksLimit:5,display:!1},grid:{drawBorder:!1,color:e.palette.divider}}},elements:{bar:{borderRadius:5}},interaction:{mode:"index",intersect:!1}}),K=(e,t,a)=>{var m;const{responsive:n,elements:s,interaction:c,scales:o,maintainAspectRatio:i}=C(e);return{plugins:{legend:{position:"bottom",labels:{color:e.palette.text.primary,pointStyle:"circle",usePointStyle:!0,boxHeight:6,padding:15,boxPadding:5}},annotation:{clip:!1,annotations:{}},tooltip:{backgroundColor:e.palette.background.paper,titleColor:e.palette.text.primary,bodyColor:e.palette.text.primary,bodySpacing:6,padding:{top:20,bottom:20,left:30,right:30},borderColor:"rgba(0, 0, 0, 0.05)",borderWidth:3,usePointStyle:!0,caretSize:0,boxPadding:10,callbacks:{label:l=>`${l.formattedValue} - ${l.dataset.label}`,afterLabel:l=>{const d=l.dataset.data[l.dataIndex];if(l.dataset.label!=="Exposed"||d.variants===void 0)return"";const{disabled:f,...u}=d.variants;return Object.entries(u).map(b=>Z(b,d.y)).join(`
2
2
  `)},title:l=>`Time: ${t>48?w(l[0].label,a.locale,"UTC"):F(l[0].label,a.locale)}`}}},responsive:n,maintainAspectRatio:i,scales:{x:{...o?o.x:{},ticks:{color:e.palette.text.secondary,callback(l){const d=this.getLabelForValue(Number(l));return t>48?E(d,a.locale,"UTC"):F(d,a.locale)}}},y:{...(o==null?void 0:o.y)??{},ticks:{...((m=o==null?void 0:o.y)==null?void 0:m.ticks)??{},color:e.palette.text.secondary,callback:V,display:!0}}},elements:s,interaction:c}},Q=({project:e,flagName:t,onArchive:a,className:n})=>{var f;const{feature:s,refetchFeature:c}=S(e,t),o=(f=s.environments)==null?void 0:f.map(u=>({name:u.name,lastSeenAt:u.lastSeenAt,enabled:u.enabled,yes:u.yes,no:u.no})),[i,m]=p.useState(!1),[l,d]=p.useState(!1);return r.jsxs(k,{sx:{display:"flex"},className:n,children:[r.jsx(D,{sx:{pt:0,pb:0},featureLastSeen:s.lastSeenAt,environments:o}),r.jsx(A,{feature:s,onArchive:()=>m(!0),onComplete:()=>d(!0),onUncomplete:c}),s.children.length>0?r.jsx(_,{features:s.children,project:e,isOpen:i,onClose:()=>m(!1)}):r.jsx(q,{isOpen:i,onConfirm:a,onClose:()=>m(!1),projectId:e,featureIds:[t]}),s.project?r.jsx(z,{isOpen:l,setIsOpen:d,projectId:s.project,featureId:s.name,onComplete:c}):null]})},X=[0,14,28,21,33,31,31,22,26,37,31,14,21,14,0],ee=e=>({labels:Array.from({length:15},(t,a)=>a+1),datasets:[{data:X,backgroundColor:e.palette.divider,hoverBackgroundColor:e.palette.divider,label:""}]}),v=g("div")({width:"100%",flexGrow:1}),x=({label:e})=>{const t=y(),a=p.useMemo(()=>C(t),[t]),n=p.useMemo(()=>ee(t),[t]),s="placeholder-chart-label";return r.jsxs(r.Fragment,{children:[r.jsx(O,{id:s,children:e}),r.jsx(v,{children:r.jsx(j,{data:n,options:a,"aria-describedby":s})})]})},te=()=>{const e=y(),t=p.useMemo(()=>C(e),[e]),a=p.useMemo(()=>({labels:[],datasets:[]}),[e]);return r.jsx(v,{children:r.jsx(j,{data:a,options:t,"aria-label":"A placeholder bar chart with a single feature flag exposure metrics"})})},ae=(e,t)=>{const[a,n]=p.useState(null),{feature:s}=S(e,t),c=((s==null?void 0:s.environments)??[]).map(i=>({name:i.name,type:i.type})),o=c.find(i=>i.type==="production");return p.useEffect(()=>{o?n(o.name):c.length>0&&n(c[0].name)},[t,JSON.stringify(c)]),{environment:a,setEnvironment:n,activeEnvironments:c}},re=(e,t,a)=>{const{featureMetrics:n=[],loading:s,error:c}=Y(e,a),o=p.useMemo(()=>[...n].sort((u,b)=>u.timestamp.localeCompare(b.timestamp)),[n]),i=p.useMemo(()=>G(o==null?void 0:o.filter(u=>t===u.environment)).map(u=>({...u,appName:"all selected"})),[o,t]),m=p.useMemo(()=>J(i),[i]),l=y(),{locationSettings:d}=$(),f=p.useMemo(()=>K(l,a,d),[l,a,d]);return{data:m,options:f,loading:s,error:c}},se=({activeEnvironments:e,environment:t,setEnvironment:a})=>r.jsx(H,{name:"feature-environments",label:"Environment",id:"feature-environments",options:e.map(n=>({key:n.name,label:n.name})),value:String(t),onChange:a}),ne=g(k)(({theme:e})=>({display:"flex",justifyContent:"flex-start",flexFlow:"row wrap",gap:e.spacing(2)})),h=g("div")(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(3),alignItems:"center",height:"100%",justifyContent:"space-between"})),oe=g(Q)({alignItems:"center",justifySelf:"start"}),le=g("div")(({theme:e})=>({display:"flex",justifyContent:"space-between",flexFlow:"row wrap",width:"100%",gap:e.spacing(4)})),me=e=>r.jsx(h,{children:r.jsx(x,{...e})}),ie=({flag:e,onArchive:t})=>{const[a,n]=p.useState(48),{environment:s,setEnvironment:c,activeEnvironments:o}=ae(e.project,e.name),{data:i,options:m,loading:l,error:d}=re(e.name,s,a);if(d)return r.jsx(h,{children:r.jsx(x,{label:"Couldn't fetch metrics for the current flag right now. Please try again. Report this if it doesn't resolve itself."})});const f=i.datasets[0].data.length===0;return r.jsxs(h,{children:[r.jsxs(le,{children:[r.jsx(oe,{project:e.project,flagName:e.name,onArchive:t}),r.jsxs(ne,{children:[s?r.jsx(se,{environment:s,setEnvironment:c,activeEnvironments:o}):null,r.jsx(U,{hoursBack:a,setHoursBack:n})]})]}),l?r.jsx(te,{}):f?r.jsx(x,{label:"No metrics for this feature flag in the selected environment and time period"}):r.jsx(v,{children:r.jsx(j,{data:i,options:m,"aria-label":"A bar chart with a single feature flag exposure metrics"})})]})},fe=e=>[".",".."].includes(e.flag.name)?r.jsx(h,{children:r.jsx(x,{label:`The current flag name ('${e.flag.name}') is known to cause issues due how it affects URLs. We cannot show you a chart for it.`})}):r.jsx(ie,{...e});P.register(W,I,T,B,R,L,N);export{fe as FlagMetricsChart,me as PlaceholderFlagMetricsChartWithWrapper};
@@ -1 +1 @@
1
- import{cS as n,bc as l,j as e,C as c,V as a,B as d,j6 as g,i$ as h,j0 as j,j1 as f,j2 as p,j3 as u,j4 as x,j5 as m}from"./index-CqYZiU1N.js";import{a as S}from"./formatTickValue-DojfJagm.js";import{u as C,c as w,S as P,T as y,P as T,n as b,g as B}from"./networkTrafficUsageHighlightPlugin-BMMmh5e_.js";import"./LazyAdminExport-BjSYZTvt.js";import"./RoleCell-COtuTPWk.js";import"./useApiTokens-B6vbGXUF.js";const _=()=>{n("Network - Frontend Traffic Usage");const{isOss:s}=l(),{chartDataSelection:t,setChartDataSelection:r,options:i}=C(),{chartData:o}=w(t);return e.jsx(c,{condition:s(),show:e.jsx(a,{severity:"warning",children:"Not enabled."}),elseShow:e.jsx(e.Fragment,{children:e.jsxs(P,{children:[e.jsxs(y,{children:[e.jsx(d,{children:e.jsx(a,{severity:"info",icon:!1,children:"Frontend traffic is determined by the total SDK requests to the Frontend API"})}),e.jsx(T,{selectedPeriod:t,setPeriod:r})]}),e.jsx(g,{data:o,plugins:[b],options:i,"aria-label":B(t)})]})})})};h.register(S,j,f,p,u,x,m);export{_ as default};
1
+ import{cS as n,bc as l,j as e,C as c,V as a,B as d,j6 as g,i$ as h,j0 as j,j1 as f,j2 as p,j3 as u,j4 as x,j5 as m}from"./index-A5We7bvX.js";import{a as S}from"./formatTickValue-D3KZyzeb.js";import{u as C,c as w,S as P,T as y,P as T,n as b,g as B}from"./networkTrafficUsageHighlightPlugin-DLE_BBMN.js";import"./LazyAdminExport-CsCsRIwk.js";import"./RoleCell-C-hJFmul.js";import"./useApiTokens-DNIDLJlc.js";const _=()=>{n("Network - Frontend Traffic Usage");const{isOss:s}=l(),{chartDataSelection:t,setChartDataSelection:r,options:i}=C(),{chartData:o}=w(t);return e.jsx(c,{condition:s(),show:e.jsx(a,{severity:"warning",children:"Not enabled."}),elseShow:e.jsx(e.Fragment,{children:e.jsxs(P,{children:[e.jsxs(y,{children:[e.jsx(d,{children:e.jsx(a,{severity:"info",icon:!1,children:"Frontend traffic is determined by the total SDK requests to the Frontend API"})}),e.jsx(T,{selectedPeriod:t,setPeriod:r})]}),e.jsx(g,{data:o,plugins:[b],options:i,"aria-label":B(t)})]})})})};h.register(S,j,f,p,u,x,m);export{_ as default};