UNPKG

unleash-server

Version:

Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.

4 lines 110 kB
import{aG as fs,aH as ys,_ as bt,aI as bn,a as J,aJ as qe,j as t,s as g,aK as vn,aL as we,r as x,aM as ms,b as Pe,aN as gt,aO as $e,aP as js,aQ as A,aR as W,aS as Sn,V as Z,A as Cn,m as bs,l as vs,n as Tn,o as wn,aT as Ss,u as Cs,h as q,as as ie,aU as pe,aV as ce,e as H,aW as vt,aX as te,aY as ue,B,T as z,C as L,aZ as kn,L as ae,D as xe,J as Rn,y as ee,a_ as St,a$ as Dn,M as Se,b0 as De,b1 as We,b2 as Ce,b3 as Ts,b4 as He,b5 as K,b6 as ws,b7 as zt,b8 as Ue,b9 as Fe,ba as ks,bb as Oe,bc as fe,bd as Rs,be as An,bf as Ge,bg as En,bh as Ds,bi as Te,t as As,bj as Es,bk as Is,bl as In,v as $n,bm as Pn,bn as Fn,i as ne,bo as On,bp as _n,bq as Bn,br as zn,bs as $s,bt as le,am as Ln,bu as Mn,bv as Vn,bw as Ct,bx as Tt,by as Me,bz as Nn,bA as qn,N as Ae,bB as Lt,bC as Wn,bD as Hn,bE as Un,bF as Gn,bG as _e,bH as Yn,bI as Jn,bJ as Kn,bK as Ps,bL as Qn,bM as Xn,bN as Zn,bO as ea,bP as ve,bQ as ta,bR as sa,bS as na,bT as wt,bU as aa,bV as oa,bW as ra,bX as ia,bY as ca,bZ as Fs,b_ as Os,b$ as _s,O as la,c0 as Ye,c1 as Je,a3 as da,c2 as ua,K as kt,c3 as pa,c4 as Bs,c5 as ga,c6 as ha,c7 as Ke,c8 as xa,c9 as fa,ca as zs,cb as ya,cc as ma,cd as Ve,ce as Ls,cf as ja,al as Qe,cg as ba,ch as Ms,ci as va,cj as Sa,ck as Ca,cl as Ta,cm as wa,cn as Xe,co as ka,cp as Vs,cq as Ra,cr as ht,cs as Ns,ct as Da,cu as Aa,cv as Ea,cw as Ia,cx as $a,cy as Pa,cz as Fa,cA as Oa,cB as Re,cC as _a,cD as Ba,a8 as za,a9 as Ze,aa as Mt,cE as La,cF as Ma,cG as Va,cH as Na,cI as qa,cJ as qs,cK as Wa,G as Ee,H as Ie,cL as Ha,cM as Ua,cN as Ga,cO as Ya,cP as Ja,cQ as Ka,cR as Ws,cS as Qa,cT as Hs,cU as Xa,cV as Za,cW as Us,cX as be,cY as xt,cZ as eo,c_ as Gs,E as Ys,c$ as to,d0 as so,f as no,d1 as ao,d2 as et,d3 as Vt,aF as oo,d4 as ke,d5 as Nt,d6 as ro,d7 as io,d8 as co,aC as Rt,aD as lo,ax as qt,d9 as uo,da as po,db as go,dc as Wt,ak as Ne,dd as ho,ac as tt,ao as xo,ae as fo,af as yo,ag as mo,ah as jo,ai as bo,aj as vo,de as he,df as So,dg as Co,dh as Ht,di as To,dj as wo,dk as st,dl as ko,dm as Ro,dn as Do,x as Js,dp as Ao,dq as Ut,dr as Eo,ds as Io,dt as $o,d as Po,du as Fo,dv as Oo,dw as _o,dx as Bo,dy as zo,dz as Lo,dA as Mo,dB as Vo,dC as No,au as qo}from"./index-CBxzHo9v.js";import{u as Wo,a as Ho,F as Dt,M as Ks}from"./MarkCompletedDialogue-BxpNwvZk.js";import{F as At,a as ft,u as Qs,b as Uo,c as Go}from"./aggregateFeatureMetrics-B9YGjDrl.js";import{u as Yo,a as Jo,T as Ko,b as Qo,c as Xo,d as Zo,F as er,C as tr,e as sr,E as nr,f as ar}from"./FeatureStaleDialog-DOiJpKNC.js";function or(e){return ys("MuiPagination",e)}fs("MuiPagination",["root","ul","outlined","text"]);const rr=["boundaryCount","componentName","count","defaultPage","disabled","hideNextButton","hidePrevButton","onChange","page","showFirstButton","showLastButton","siblingCount"];function ir(e={}){const{boundaryCount:s=1,componentName:n="usePagination",count:a=1,defaultPage:o=1,disabled:r=!1,hideNextButton:i=!1,hidePrevButton:l=!1,onChange:c,page:p,showFirstButton:u=!1,showLastButton:d=!1,siblingCount:m=1}=e,j=bt(e,rr),[y,b]=bn({controlled:p,default:o,name:n,state:"page"}),h=(R,M)=>{p||b(M),c&&c(R,M)},f=(R,M)=>{const G=M-R+1;return Array.from({length:G},(Q,C)=>R+C)},w=f(1,Math.min(s,a)),E=f(Math.max(a-s+1,s+1),a),O=Math.max(Math.min(y-m,a-s-m*2-1),s+2),_=Math.min(Math.max(y+m,s+m*2+2),E.length>0?E[0]-2:a-1),$=[...u?["first"]:[],...l?[]:["previous"],...w,...O>s+2?["start-ellipsis"]:s+1<a-s?[s+1]:[],...f(O,_),..._<a-s-1?["end-ellipsis"]:a-s>s?[a-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 a;default:return null}},I=$.map(R=>typeof R=="number"?{onClick:M=>{h(M,R)},type:"page",page:R,selected:R===y,disabled:r,"aria-current":R===y?"true":void 0}:{onClick:M=>{h(M,D(R))},type:R,page:D(R),selected:!1,disabled:r||R.indexOf("ellipsis")===-1&&(R==="next"||R==="last"?y>=a:y<=1)});return J({items:I},j)}function cr(e){return ys("MuiPaginationItem",e)}const se=fs("MuiPaginationItem",["root","page","sizeSmall","sizeLarge","text","textPrimary","textSecondary","outlined","outlinedPrimary","outlinedSecondary","rounded","ellipsis","firstLast","previousNext","focusVisible","disabled","selected","icon"]),Gt=qe(t.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"}),"FirstPage"),Yt=qe(t.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"}),"LastPage"),Jt=qe(t.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"}),"NavigateBefore"),Kt=qe(t.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}),"NavigateNext"),lr=["className","color","component","components","disabled","page","selected","shape","size","slots","type","variant"],Xs=(e,s)=>{const{ownerState:n}=e;return[s.root,s[n.variant],s[`size${$e(n.size)}`],n.variant==="text"&&s[`text${$e(n.color)}`],n.variant==="outlined"&&s[`outlined${$e(n.color)}`],n.shape==="rounded"&&s.rounded,n.type==="page"&&s.page,(n.type==="start-ellipsis"||n.type==="end-ellipsis")&&s.ellipsis,(n.type==="previous"||n.type==="next")&&s.previousNext,(n.type==="first"||n.type==="last")&&s.firstLast]},dr=e=>{const{classes:s,color:n,disabled:a,selected:o,size:r,shape:i,type:l,variant:c}=e,p={root:["root",`size${$e(r)}`,c,i,n!=="standard"&&`${c}${$e(n)}`,a&&"disabled",o&&"selected",{page:"page",first:"firstLast",last:"firstLast","start-ellipsis":"ellipsis","end-ellipsis":"ellipsis",previous:"previousNext",next:"previousNext"}[l]],icon:["icon"]};return js(p,cr,s)},ur=g("div",{name:"MuiPaginationItem",slot:"Root",overridesResolver:Xs})(({theme:e,ownerState:s})=>J({},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)})),pr=g(vn,{name:"MuiPaginationItem",slot:"Root",overridesResolver:Xs})(({theme:e,ownerState:s})=>J({},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}))`:we(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}))`:we(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})=>J({},s.variant==="text"&&{[`&.${se.selected}`]:J({},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}`]:J({},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)`:we(e.palette[s.color].main,.5)}`,backgroundColor:e.vars?`rgba(${e.vars.palette[s.color].mainChannel} / ${e.vars.palette.action.activatedOpacity})`:we(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}))`:we(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}))`:we(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}})})),gr=g("div",{name:"MuiPaginationItem",slot:"Icon",overridesResolver:(e,s)=>s.icon})(({theme:e,ownerState:s})=>J({fontSize:e.typography.pxToRem(20),margin:"0 -8px"},s.size==="small"&&{fontSize:e.typography.pxToRem(18)},s.size==="large"&&{fontSize:e.typography.pxToRem(22)})),hr=x.forwardRef(function(s,n){const a=ms({props:s,name:"MuiPaginationItem"}),{className:o,color:r="standard",component:i,components:l={},disabled:c=!1,page:p,selected:u=!1,shape:d="circular",size:m="medium",slots:j={},type:y="page",variant:b="text"}=a,h=bt(a,lr),f=J({},a,{color:r,disabled:c,selected:u,shape:d,size:m,type:y,variant:b}),w=Pe(),E=dr(f),_=(w.direction==="rtl"?{previous:j.next||l.next||Kt,next:j.previous||l.previous||Jt,last:j.first||l.first||Gt,first:j.last||l.last||Yt}:{previous:j.previous||l.previous||Jt,next:j.next||l.next||Kt,first:j.first||l.first||Gt,last:j.last||l.last||Yt})[y];return y==="start-ellipsis"||y==="end-ellipsis"?t.jsx(ur,{ref:n,ownerState:f,className:gt(E.root,o),children:"…"}):t.jsxs(pr,J({ref:n,ownerState:f,component:i,disabled:c,className:gt(E.root,o)},h,{children:[y==="page"&&p,_?t.jsx(gr,{as:_,ownerState:f,className:E.icon}):null]}))}),xr=["boundaryCount","className","color","count","defaultPage","disabled","getItemAriaLabel","hideNextButton","hidePrevButton","onChange","page","renderItem","shape","showFirstButton","showLastButton","siblingCount","size","variant"],fr=e=>{const{classes:s,variant:n}=e;return js({root:["root",n],ul:["ul"]},or,s)},yr=g("nav",{name:"MuiPagination",slot:"Root",overridesResolver:(e,s)=>{const{ownerState:n}=e;return[s.root,s[n.variant]]}})({}),mr=g("ul",{name:"MuiPagination",slot:"Ul",overridesResolver:(e,s)=>s.ul})({display:"flex",flexWrap:"wrap",alignItems:"center",padding:0,margin:0,listStyle:"none"});function jr(e,s,n){return e==="page"?`${n?"":"Go to "}page ${s}`:`Go to ${e} page`}const br=x.forwardRef(function(s,n){const a=ms({props:s,name:"MuiPagination"}),{boundaryCount:o=1,className:r,color:i="standard",count:l=1,defaultPage:c=1,disabled:p=!1,getItemAriaLabel:u=jr,hideNextButton:d=!1,hidePrevButton:m=!1,renderItem:j=I=>t.jsx(hr,J({},I)),shape:y="circular",showFirstButton:b=!1,showLastButton:h=!1,siblingCount:f=1,size:w="medium",variant:E="text"}=a,O=bt(a,xr),{items:_}=ir(J({},a,{componentName:"Pagination"})),$=J({},a,{boundaryCount:o,color:i,count:l,defaultPage:c,disabled:p,getItemAriaLabel:u,hideNextButton:d,hidePrevButton:m,renderItem:j,shape:y,showFirstButton:b,showLastButton:h,siblingCount:f,size:w,variant:E}),D=fr($);return t.jsx(yr,J({"aria-label":"pagination navigation",className:gt(D.root,r),ownerState:$,ref:n},O,{children:t.jsx(mr,{className:D.ul,ownerState:$,children:_.map((I,R)=>t.jsx("li",{children:j(J({},I,{color:i,"aria-label":u(I.type,I.page,I.selected),shape:y,size:w,variant:E}))},R))})}))}),vr=()=>{const e=A("projectId"),s=A("featureId"),{feature:n}=W(e,s);return n.name?t.jsx(Sn,{title:"Event log",feature:s}):null},Sr=()=>t.jsxs(Z,{severity:"warning",children:["Remember to update your Unleash client! Feature dependencies require new SDK versions. Read more about ",t.jsx(Cr,{}),"."]}),Cr=()=>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"}),Tr=g(Cn)(({theme:e})=>({marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),wr=({project:e,parent:s,onSelect:n,selectedValues:a})=>{const{parentVariantOptions:o}=Wo(e,s),r=t.jsx(Tn,{fontSize:"small"}),i=t.jsx(wn,{fontSize:"small"});return t.jsx(Tr,{multiple:!0,id:"parent-variant-options",options:o,disableCloseOnSelect:!0,renderOption:(l,c,{selected:p})=>t.jsxs("li",{...l,children:[t.jsx(bs,{icon:r,checkedIcon:i,style:{marginRight:8},checked:p}),c]}),renderInput:l=>t.jsx(vs,{...l,placeholder:"Select values"}),fullWidth:!0,value:a,onChange:(l,c)=>{n(c)}})},de={key:"none (remove dependency)",label:"none (remove dependency)"},Zs=g(Ss)(({theme:e})=>({marginTop:e.spacing(2),marginBottom:e.spacing(1.5)})),kr=({onSelect:e,parentValue:s})=>t.jsx(Zs,{fullWidth:!0,options:[{key:"enabled",label:"enabled"},{key:"enabled_with_variants",label:"enabled with variants"},{key:"disabled",label:"disabled"}],value:s.status,onChange:e}),en=e=>{const{makeRequest:s,createRequest:n,errors:a,loading:o}=Cs({propagateErrors:!0}),r=async(p,u)=>{const d=n(`/api/admin/projects/${e}/features/${p}/dependencies`,{method:"POST",body:JSON.stringify(u)});await s(d.caller,d.id)},i=async(p,u)=>{const d=n(`/api/admin/projects/${e}/features/${p}/dependencies/${u}`,{method:"DELETE"});await s(d.caller,d.id)},l=async p=>{const u=n(`/api/admin/projects/${e}/features/${p}/dependencies`,{method:"DELETE"});await s(u.caller,u.id)},c=[n,s,q,e];return{addDependency:x.useCallback(r,c),removeDependency:x.useCallback(i,c),removeDependencies:x.useCallback(l,c),errors:a,loading:o}},Rr=(e,s,n,a,o)=>{const{trackEvent:r}=ie(),{addChange:i}=pe(),{refetch:l}=ce(e),{setToastData:c,setToastApiError:p}=H(),{refetchFeature:u}=W(e,s),d=vt(e)(),{isChangeRequestConfiguredInAnyEnv:m}=te(e),{addDependency:j,removeDependencies:y}=en(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:n,enabled:a.status!=="disabled",variants:a.status==="enabled_with_variants"?a.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=n===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 n===de.key?(await y(s),r("dependent_features",{props:{eventType:"dependency removed"}}),c({text:"Dependency removed",type:"success"})):(await j(s,{feature:n,enabled:a.status!=="disabled",variants:a.status==="enabled_with_variants"?a.variants:[]}),r("dependent_features",{props:{eventType:"dependency added"}}),c({text:"Dependency added",type:"success"}))}catch(h){p(q(h))}u(),o()}},Dr=({project:e,featureId:s,parent:n,onSelect:a})=>{const{parentOptions:o}=Ho(e,s),r=o?[de,...o.map(i=>({key:i,label:i}))]:[de];return t.jsx(Zs,{fullWidth:!0,options:r,value:n,onChange:a})},Ar=({project:e,featureId:s,parentDependency:n,showDependencyDialogue:a,onClose:o})=>{const[r,i]=x.useState((n==null?void 0:n.feature)||de.key),l=()=>{var f;return n?(f=n.variants)!=null&&f.length?{status:"enabled_with_variants",variants:n.variants}:n.enabled===!1?{status:"disabled"}:{status:"enabled"}:{status:"enabled"}},[c,p]=x.useState(l),u=()=>{i((n==null?void 0:n.feature)||de.key),p(l())};x.useEffect(()=>{u()},[JSON.stringify(n)]);const d=Rr(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")&&p({status:f}),f==="enabled_with_variants"&&p({status:f,variants:[]})},h=f=>{p({status:"enabled_with_variants",variants:f})};return t.jsx(ue,{open:a,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(Sr,{}),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(z,{children:["What ",t.jsx("b",{children:"feature"})," do you want to depend on?"]}),t.jsx(L,{condition:a,show:t.jsx(Dr,{project:e,featureId:s,parent:r,onSelect:f=>{p({status:"enabled"}),i(f)}})}),t.jsx(L,{condition:j,show:t.jsxs(B,{sx:{mt:2},children:[t.jsxs(z,{children:["What ",t.jsx("b",{children:"feature status"})," do you want to depend on?"]}),t.jsx(kr,{parentValue:c,onSelect:b})]})}),t.jsx(L,{condition:y,show:c.status==="enabled_with_variants"&&t.jsxs(B,{sx:{mt:2},children:[t.jsxs(z,{children:["What ",t.jsx("b",{children:"variant"})," do you want to depend on?"]}),t.jsx(wr,{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),...kn}));g("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)}));const Et=g(ae)(({theme:e})=>({maxWidth:"100%",textDecoration:"none","&:hover, &:focus":{textDecoration:"underline"}})),Er=g(xe)(({theme:e})=>({height:e.spacing(3.5),width:e.spacing(3.5)})),Ir=g(Rn)(({theme:e})=>({borderRadius:e.shape.borderRadiusLarge,padding:e.spacing(1,1.5)})),tn=({capabilityId:e,feature:s,onEdit:n,onDelete:a})=>{const o=`${e}-${s}-actions`,r=`${o}-menu`,[i,l]=x.useState(null),c=!!i,p=d=>{l(d.currentTarget)},u=()=>{l(null)};return t.jsxs(B,{children:[t.jsx(ee,{title:"Dependency actions",arrow:!0,describeChild:!0,children:t.jsx(Er,{id:o,"aria-controls":c?r:void 0,"aria-haspopup":"true","aria-expanded":c?"true":void 0,onClick:p,type:"button",children:t.jsx(St,{})})}),t.jsx(Ir,{id:r,anchorEl:i,open:c,onClose:u,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,children:t.jsxs(Dn,{"aria-labelledby":o,children:[t.jsxs(Se,{onClick:()=>{n(),u()},children:[t.jsx(De,{children:t.jsx(We,{})}),t.jsx(Ce,{children:t.jsx(z,{variant:"body2",children:"Edit"})})]}),t.jsxs(Se,{onClick:()=>{a(),u()},children:[t.jsx(De,{children:t.jsx(Ts,{})}),t.jsx(Ce,{children:t.jsx(z,{variant:"body2",children:"Delete"})})]})]})})]})},$r=({childFeatures:e,project:s})=>t.jsx(He,{tooltip:t.jsx(t.Fragment,{children:e.map(n=>t.jsx(Et,{to:`/projects/${s}/features/${n}`,children:t.jsx("div",{children:n})},`${s}-${n}`))}),children:e.length===1?"1 feature":`${e.length} features`}),Pr=({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,n)=>t.jsx("div",{children:s},n))}),children:e.length===1?"1 variant":`${e.length} variants`}),Fr=g(K)(({theme:e})=>({fontSize:e.fontSizes.smallBody,lineHeight:e.typography.body1.lineHeight})),Or=(e,s)=>{const{trackEvent:n}=ie(),{addChange:a}=pe(),{refetch:o}=ce(e),{setToastData:r,setToastApiError:i}=H(),{refetchFeature:l}=W(e,s),c=vt(e)(),{isChangeRequestConfiguredInAnyEnv:p}=te(e),{removeDependencies:u}=en(e),d=async()=>{if(!c){console.error("No change request environment");return}await a(e,c,[{action:"deleteDependency",feature:s,payload:void 0}])};return async()=>{try{p()?(await d(),n("dependent_features",{props:{eventType:"delete dependency added to change request"}}),r({type:"success",text:"Change added to draft"}),await o()):(await u(s),n("dependent_features",{props:{eventType:"dependency removed"}}),r({text:"Dependency removed",type:"success"}),await l())}catch(j){i(q(j))}}},_r=({feature:e})=>{var p,u,d,m,j,y,b;const[s,n]=x.useState(!1),a=!!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=vt(e.project)(),l=ws(e.project),c=Or(e.project,e.name);return t.jsxs(t.Fragment,{children:[a?t.jsxs(X,{children:[t.jsx(re,{children:"Dependency:"}),t.jsx("div",{children:t.jsx(Fr,{size:"small",permission:zt,projectId:e.project,variant:"text",onClick:()=>{n(!0)},children:"Add parent flag"})})]}):null,o?t.jsxs(X,{children:[t.jsx(re,{children:"Dependency:"}),t.jsxs(mt,{children:[t.jsx(Et,{to:`/projects/${e.project}/features/${(p=e.dependencies[0])==null?void 0:p.feature}`,children:t.jsx(Ue,{title:(u=e.dependencies[0])==null?void 0:u.feature,children:(d=e.dependencies[0])==null?void 0:d.feature})}),l(zt,i)?t.jsx(tn,{capabilityId:"dependency",feature:e.name,onEdit:()=>n(!0),onDelete:c}):null]})]}):null,o&&!((m=e.dependencies[0])!=null&&m.enabled)?t.jsxs(X,{children:[t.jsx(re,{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(re,{children:"Dependency value:"}),t.jsx(Pr,{variants:((b=e.dependencies[0])==null?void 0:b.variants)||[]})]}):null,r?t.jsxs(X,{children:[t.jsx(re,{children:"Children:"}),t.jsx($r,{childFeatures:e.children,project:e.project})]}):null,e.project?t.jsx(Ar,{project:e.project,featureId:e.name,parentDependency:e.dependencies[0],onClose:()=>n(!1),showDependencyDialogue:s}):null]})},Br=(e,s={})=>{const n=Fe(`/api/admin/projects/${e}/dependencies`),{data:a,error:o}=ks(e,!1,n,zr,s);return{dependenciesExist:a,error:o,loading:!o&&!a}},zr=async e=>await(await fetch(e).then(Oe("Dependencies exist check"))).json(),Lr=e=>{const{dependenciesExist:s}=Br(e),{isOss:n}=fe();return!!e&&!!(!n()||s)},sn=(e,s={})=>{const n=async()=>{const p=Fe(`api/admin/features/${e}/tags`);return(await fetch(p,{method:"GET"}).then(Oe("Tags"))).json()},a=`api/admin/features/${e}/tags`,{data:o,error:r}=ks(!!e,{tags:[]},a,n,s),[i,l]=x.useState(!r&&!o),c=()=>{Rs(a)};return x.useEffect(()=>{l(!r&&!o)},[o,r]),{tags:(o==null?void 0:o.tags)||[],error:r,loading:i,refetch:c}},Mr=g("section")(({theme:e})=>({"& > *":{margin:e.spacing(1,0)}})),nt=e=>e.map(s=>({title:s.value})),Qt=(e,s)=>e.map(n=>({value:n.title,type:s})),nn=({open:e,setOpen:s})=>{const{tagTypes:n}=An(),a=A("featureId"),{createTag:o}=Yo(),{updateFeatureTags:r,loading:i}=Ge(),{tags:l,refetch:c,loading:p}=sn(a),{setToastData:u}=H(),d=n&&n.length>0?n[0]:{name:"simple",description:"Simple tag to get you started",icon:""},[m,j]=x.useState(d),y=i||p,[b,h]=x.useState(0),{trackEvent:f}=ie(),[w,E]=x.useState(nt(l.filter(v=>v.type===m.name))),{tags:O,refetch:_}=Jo(m.name),$=x.useMemo(()=>nt(O),[O]);x.useEffect(()=>{l&&m&&E(nt(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")),M=async(v,S)=>{try{await r(a,{addedTags:v,removedTags:S}),await c()}catch{u({type:"error",text:"Failed to add tag"})}},G=async v=>{v.preventDefault();const S=Qt(R(w),m.name),{added:F,removed:V}=I(S,l);b>0&&(await M(F,V),b>1&&f("suggest_tags",{props:{eventType:"multiple_tags_added"}}),b>0&&u({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=En(S);F==="selectOption"&&S.forEach((k,oe)=>{if(typeof k!="string"&&k.inputValue&&k.inputValue!==""){const ge={value:k.inputValue,type:m.name};o(ge).then(()=>{f("suggest_tags",{props:{eventType:"tag_created"}}),_()}),k.title=k.inputValue,k.inputValue="",V[oe]=k}});const N=Qt(R(V),m.name);I(N,l),E(V)},P="add-tag-form";return t.jsx(ue,{open:e,secondaryButtonText:"Cancel",primaryButtonText:"Save tags",title:"Update feature flag tags",onClick:G,disabledPrimaryButton:y||b===0,onClose:D,formId:P,children:t.jsxs(t.Fragment,{children:[t.jsx(z,{paragraph:!0,sx:{marginBottom:v=>v.spacing(2.5)},children:"Tags allow you to group features together"}),t.jsx("form",{id:P,onSubmit:G,children:t.jsxs(Mr,{children:[t.jsx(Ko,{options:n,value:m,onChange:Q}),t.jsx(Qo,{options:$,existingTags:l,tagType:m,selectedOptions:w,onChange:C})]})})]})})},Vr=g(K)(({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)})),Nr=g(Ds)(({theme:e})=>({fontSize:e.typography.body2.fontSize})),Xt=({project:e,onClick:s})=>t.jsx(Vr,{size:"small",permission:Te,projectId:e,variant:"text",onClick:s,startIcon:t.jsx(Nr,{}),"data-loading":!0,children:"Add tag"}),Zt=g("span")(({theme:e})=>({marginTop:e.spacing(1),color:e.palette.text.secondary,marginRight:e.spacing(1)})),qr=g("div")(({theme:e})=>({display:"flex",justifyContent:"space-between",flexWrap:"wrap",minHeight:e.spacing(4.5),fontSize:e.fontSizes.smallBody})),es=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 Wr=({feature:e})=>{const{tags:s,refetch:n}=sn(e.name),{deleteTagFromFeature:a}=Ge(),[o,r]=x.useState(!1),[i,l]=x.useState(!1),[c,p]=x.useState(),{setToastData:u,setToastApiError:d}=H(),{hasAccess:m}=x.useContext(Es),j=m(Te,e.project),y=()=>{r(!0)},b=async()=>{if(c)try{await a(e.name,c.type,c.value),n(),u({type:"success",text:"Tag removed"})}catch(h){d(q(h))}};return t.jsxs(t.Fragment,{children:[s.length?t.jsxs(qr,{children:[t.jsx(Zt,{children:"Tags:"}),t.jsxs(es,{children:[s.map(h=>t.jsx(Hr,{tag:h,canUpdateTags:j,onTagRemove:f=>{l(!0),p(f)}},Is(h))),j?t.jsx(Xt,{project:e.project,onClick:y}):null]})]}):t.jsxs(X,{children:[t.jsx(Zt,{children:"Tags:"}),t.jsx(es,{children:t.jsx(Xt,{project:e.project,onClick:y})})]}),t.jsx(nn,{open:o,setOpen:r}),t.jsxs(ue,{open:i,primaryButtonText:"Remove tag",secondaryButtonText:"Cancel",onClose:()=>{l(!1),p(void 0),n()},onClick:()=>{l(!1),b(),p(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]})]})]})},Hr=({tag:e,canUpdateTags:s,onTagRemove:n})=>{const a=Is(e),o=a.length>25,r=s?()=>n(e):void 0,i=t.jsx(ee,{title:"Remove tag",arrow:!0,children:t.jsx($n,{sx:{height:"20px",width:"20px"}})});return t.jsx(ee,{title:o?a:"",arrow:!0,children:t.jsx("span",{children:t.jsx(In,{tag:e,onDelete:r,deleteIcon:i})})},a)},Ur=g(Pn)(({theme:e})=>({width:e.spacing(2.5),height:e.spacing(2.5)})),Gr=g(Fn)({flexWrap:"nowrap"}),Yr=({collaborators:e})=>!e||e.length===0?null:t.jsx(Gr,{users:e,avatarLimit:9,AvatarComponent:Ur}),Jr="environment-visibility-button",ts="environment-visibility-menu",Kr=g("div")(({theme:e})=>({display:"flex",justifyContent:"center",paddingTop:e.spacing(4)})),Qr=({environments:e,hiddenEnvironments:s,onChange:n})=>{const[a,o]=x.useState(null),r=!!a,i=d=>{o(d.currentTarget)},l=()=>{o(null)},c=e.map(d=>d.name),p=new Set(c.filter(d=>!s.includes(d))),u=d=>{n(d)};return t.jsxs(Kr,{children:[t.jsx(ne,{onClick:i,endIcon:r?t.jsx(On,{}):t.jsx(_n,{}),variant:"outlined",id:Jr,"aria-controls":ts,"aria-haspopup":"true","aria-expanded":r?"true":void 0,"data-loading":!0,children:"Hide/show environments"}),t.jsx(Bn,{id:ts,open:!!a,anchorEl:a,onClose:l,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:t.jsx(zn,{multiselect:{selectedOptions:p},onChange:u,options:c.map(d=>({label:d,value:d})),search:{label:"Filter environments",placeholder:"Filter environments"}})})]})},an=(e,s)=>{const{makeRequest:n,createRequest:a,errors:o,loading:r}=Cs({propagateErrors:!0}),i=async u=>{const d=a(`/api/admin/projects/${e}/features/${s}/link`,{method:"POST",body:JSON.stringify(u)});await n(d.caller,d.id)},l=async(u,d)=>{const m=a(`/api/admin/projects/${e}/features/${s}/link/${u}`,{method:"PUT",body:JSON.stringify(d)});await n(m.caller,m.id)},c=async u=>{const d=a(`/api/admin/projects/${e}/features/${s}/link/${u}`,{method:"DELETE"});await n(d.caller,d.id)},p=[a,n,q,e];return{addLink:x.useCallback(i,p),editLink:x.useCallback(l,p),deleteLink:x.useCallback(c,p),errors:o,loading:r}},ss=g(vs)(({theme:e})=>({width:"100%",marginTop:e.spacing(1),marginBottom:e.spacing(1)})),on=({showDialogue:e,onClose:s,project:n,featureId:a,mode:o,link:r})=>{const[i,l]=x.useState(""),[c,p]=x.useState(""),[u,d]=x.useState(""),{addLink:m,editLink:j,loading:y}=an(n,a),{refetchFeature:b}=W(n,a),{setToastData:h,setToastApiError:f}=H(),w=o==="edit",E=w?"Edit link":"Add link",O=w?"Link updated":"Link added",{trackEvent:_}=ie();x.useEffect(()=>{w&&r?(l(r.url||""),p(r.title||""),d(r.id||"")):w||(l(""),p(""),d(""))},[w,r]);const $=async()=>{try{w?(await j(u,{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(),p(""),l("")}catch(I){f(q(I))}},D=w?r!==null:e;return t.jsx(ue,{open:D,title:E,onClose:s,disabledPrimaryButton:i.trim()===""||y,onClick:$,primaryButtonText:"Save",secondaryButtonText:"Cancel",children:t.jsxs(B,{children:[t.jsx(ss,{label:"Link",variant:"outlined",value:i,onChange:I=>l(I.target.value)}),t.jsx(ss,{label:"Title (optional)",variant:"outlined",value:c,onChange:I=>p(I.target.value)})]})})},Xr=e=>t.jsx(on,{...e,mode:"add",link:null}),Zr=e=>t.jsx(on,{...e,mode:"edit",showDialogue:e.link!==null}),rn=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)})),yt=g("h2")(({theme:e})=>({fontSize:e.typography.body1.fontSize,fontWeight:e.typography.fontWeightBold,marginBottom:e.spacing(.5)})),ei=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})),re=g("span")(({theme:e})=>({color:e.palette.text.secondary,marginRight:e.spacing(1)})),Be=g("span")({overflowWrap:"anywhere"}),mt=g("div")(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1)})),ti=g(De)(({theme:e})=>({minWidth:e.spacing(5)})),si=({links:e,project:s,feature:n})=>{const[a,o]=x.useState(!1),[r,i]=x.useState(null),{deleteLink:l,loading:c}=an(s,n),{setToastData:p,setToastApiError:u}=H(),{refetchFeature:d}=W(s,n),m=t.jsx(K,{size:"small",startIcon:t.jsx(Ds,{}),permission:Te,disabled:e.length>=10,projectId:s,variant:"text",onClick:()=>o(!0),children:"Add link"}),j=()=>t.jsx(Tt,{children:e.map(h=>t.jsx(Me,{secondaryAction:t.jsx(tn,{capabilityId:"link",feature:n,onEdit:()=>{i(h)},onDelete:async()=>{try{await l(h.id),p({text:"Link removed",type:"success"}),d()}catch(f){u(q(f))}}}),disablePadding:!0,dense:!0,children:t.jsxs(Nn,{component:"a",href:h.url,target:"_blank",rel:"noopener noreferrer",disableGutters:!0,children:[t.jsx(ti,{children:t.jsx(qn,{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(yt,{children:["You can now add links"," ",t.jsx(Ae,{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(yt,{children:"Resources"}),j(),t.jsx("div",{children:m})]});return t.jsxs(t.Fragment,{children:[t.jsx(rn,{children:e.length===0?y:b}),t.jsx(Xr,{project:s,featureId:n,showDialogue:a,onClose:()=>o(!1)}),t.jsx(Zr,{project:s,featureId:n,link:r,onClose:()=>i(null)})]})},ni=({hiddenEnvironments:e,onEnvironmentVisibilityChange:s,feature:n,onChange:a})=>{var y,b,h,f;const{locationSettings:o}=$s(),r=le(),[i,l]=x.useState(!1),[c,p]=x.useState(!1),{project:u,description:d,type:m}=n,j=Lr(u);return t.jsxs(t.Fragment,{children:[t.jsx(si,{links:n.links||[],project:n.project,feature:n.name}),t.jsxs(rn,{children:[t.jsxs("div",{children:[t.jsx(yt,{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(ei,{children:[t.jsxs(X,{children:[t.jsx(re,{children:"Flag type:"}),t.jsxs(Be,{"data-loading":!0,children:[Ln(m||" ")," flag"]})]}),n.lifecycle?t.jsxs(X,{"data-loading":!0,children:[t.jsx(re,{children:"Lifecycle:"}),t.jsx(Mn,{feature:n,onArchive:()=>l(!0),onComplete:()=>p(!0),onUncomplete:a})]}):null,t.jsxs(X,{children:[t.jsx(re,{children:"Created:"}),t.jsx(Be,{"data-loading":!0,children:Vn(Ct(n.createdAt),o.locale)})]}),n.createdBy?t.jsxs(X,{children:[t.jsx(re,{children:"Created by:"}),t.jsx(mt,{children:t.jsx(Be,{"data-loading":!0,children:(y=n.createdBy)==null?void 0:y.name})})]}):null,(b=n.collaborators)!=null&&b.users&&((h=n.collaborators)==null?void 0:h.users.length)>0?t.jsxs(X,{children:[t.jsx(re,{children:"Collaborators:"}),t.jsx(mt,{children:t.jsx(Yr,{collaborators:(f=n.collaborators)==null?void 0:f.users})})]}):null,j?t.jsx(_r,{feature:n}):null,t.jsx(Wr,{feature:n}),s?t.jsx(Qr,{environments:n.environments||[],hiddenEnvironments:e||[],onChange:s}):null]})]}),n.children.length>0?t.jsx(At,{features:n.children,project:n.project,isOpen:i,onClose:()=>l(!1)}):t.jsx(Dt,{isOpen:i,onConfirm:()=>{r(`/projects/${n.project}`)},onClose:()=>l(!1),projectId:n.project,featureIds:[n.name]}),n.project?t.jsx(Ks,{isOpen:c,setIsOpen:p,projectId:n.project,featureId:n.name,onComplete:a}):null]})},ai=e=>{var o;const{uiConfig:s}=fe(),n=((o=s.resourceLimits)==null?void 0:o.featureEnvironmentStrategies)||100,a=e>=n;return{limit:n,limitReached:a}},oi=()=>{const[e,s]=x.useState(0),n=A("projectId"),a=A("featureId"),o=Lt("environmentId"),r=Lt("strategyName"),{strategy:i,defaultStrategyFallback:l}=Xo(n,o),c=JSON.parse(Wn().get("defaultStrategy")||"false"),{segments:p}=Hn(),u=(p||[]).filter(Y=>{var je;return(je=i==null?void 0:i.segments)==null?void 0:je.includes(Y.id)}),[d,m]=x.useState({}),[j,y]=x.useState(c?u:[]),{strategyDefinition:b}=Un(r),h=Gn(),{addStrategyToFeature:f,loading:w}=_e(),{addChange:E}=pe(),{setToastData:O,setToastApiError:_}=H(),{uiConfig:$}=fe(),{unleashUrl:D}=$,I=le(),{feature:R,refetchFeature:M}=W(n,a),G=R==null?void 0:R.environments.find(Y=>Y.name===o),Q=(G==null?void 0:G.strategies.length)||0,{limit:C,limitReached:P}=ai(Q),v=x.useRef(R),{isChangeRequestConfigured:S}=te(n),{refetch:F}=ce(n),{trackEvent:V}=ie(),{data:N,staleDataNotification:k,forceRefreshCache:oe}=Yn({unleashGetter:W,params:[n,a],dataKey:"feature",refetchFunctionKey:"refetchFeature",options:{}},R,{afterSubmitAction:M},aa);x.useEffect(()=>{v.current.name===""&&R.name&&(oe(R),v.current=R)},[R.name]),x.useEffect(()=>{var Y;if(c){const je=i||l;((Y=je.parameters)==null?void 0:Y.groupId)===""&&a?m({...je,parameters:{...je.parameters,groupId:a}}):m(je)}else b&&m(Jn(a,b))},[a,JSON.stringify(b),JSON.stringify(i),c]);const ge=async Y=>{await f(n,a,o,Y),O({text:"Strategy created",type:"success"})},ye=async Y=>{await E(n,o,{action:"addStrategy",feature:a,payload:Y}),O({text:"Strategy added to draft",type:"success"}),F()},T=Kn(d,j),U=async()=>{V("strategyTitle",{props:{hasTitle:!!d.title,on:"create"}});try{S(o)?await ye(T):await ge(T),M(),I(wt(n,a))}catch(Y){_(q(Y))}};return!N||!N.project?null:t.jsxs(Ps,{modal:!0,description:Qn,documentationLink:Xn,documentationLinkLabel:Zn,disablePadding:!0,formatApiCode:()=>ri(n,a,o,T,D),children:[t.jsx(ea,{projectId:n,feature:N,strategy:d,setStrategy:m,segments:j,setSegments:y,environmentId:o,onSubmit:U,loading:w,permission:ve,errors:h,isChangeRequest:S(o),tab:e,setTab:s,StrategyVariants:t.jsx(ta,{strategy:d,setStrategy:m,environment:o,projectId:n,editable:!0}),Limit:t.jsx(sa,{name:"strategies in this environment",shortName:"strategies",currentValue:Q,limit:C}),disabled:P}),k]})},cn=(e,s,n,a,o=!1)=>{const r=new URLSearchParams({environmentId:n,strategyName:a,defaultStrategy:String(o)});return`/projects/${e}/features/${s}/strategies/create?${r}`},ri=(e,s,n,a,o)=>{if(!o)return"";const r=`${o}/api/admin/projects/${e}/features/${s}/environments/${n}/strategies`,i=JSON.stringify(a,na,2);return`curl --location --request POST '${r}' \\ --header 'Authorization: INSERT_API_KEY' \\ --header 'Content-Type: application/json' \\ --data-raw '${i}'`},ns=3,ln=e=>Array.isArray(e)?e.filter(s=>s.featureId&&s.projectId):[],as=e=>ln(ia(e)||[]),ii=()=>{const e=`${ca}:unleash-lastViewedFlags`,[s,n]=x.useState(()=>as(e)),{emitEvent:a}=oa("lastViewedFlagsUpdated",x.useCallback(()=>{n(as(e))},[e]));x.useEffect(()=>{s&&(ra(e,s),a())},[JSON.stringify(s),e,a]);const o=x.useCallback(r=>{if(!r.featureId||!r.projectId||s.find(l=>l.featureId===r.featureId))return;const i=ln([...s,r]);n(i.length>ns?i.slice(-ns):i)},[JSON.stringify(s)]);return{lastViewed:s,setLastViewed:o}},ci=g("div")(({theme:e})=>({width:e.spacing(3),"& > svg":{width:e.spacing(2.25),height:e.spacing(2.25),fill:e.palette.primary.main}})),li=g(Fs)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,fontSize:e.typography.caption.fontSize,display:"block",marginBottom:e.spacing(.5)})),di=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}})),ui=g("div")(({theme:e})=>({display:"flex",flexDirection:"row",alignItems:"center",width:"100%"})),at=({projectId:e,featureId:s,environmentId:n,strategy:a,defaultStrategy:o,onClose:r})=>{const i=Os(a.name),l=_s(a.name),{trackEvent:c}=ie(),p=cn(e,s,n,a.name,o),u=()=>{c("strategy-add",{props:{buttonTitle:a.displayName||l}}),r()};return t.jsxs(di,{to:p,onClick:u,children:[t.jsxs(ui,{children:[t.jsx(ci,{children:t.jsx(i,{})}),t.jsx(li,{text:a.displayName||l,maxWidth:"200",maxLength:25})]}),t.jsx(Ue,{lines:1,title:a.description,arrow:!0,sx:{fontSize:d=>d.typography.caption.fontSize,width:"100%"},children:a.description})]})},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}})),gi=g(Fs)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,fontSize:e.typography.caption.fontSize,display:"block",marginBottom:e.spacing(.5)})),hi=g("div")(({theme:e})=>({width:"100%",transition:"opacity 0.2s ease-in-out"})),xi=g("div")(({theme:e})=>({position:"absolute",right:e.spacing(2),display:"flex",gap:e.spacing(1),opacity:0,transition:"opacity 0.1s ease-in-out"})),fi=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}})),yi=g("div")(({theme:e})=>({display:"flex",flexDirection:"row",alignItems:"center",width:"100%"})),mi=({template:{name:e,description:s},onClick:n,onPreviewClick:a})=>{const o=Os("releasePlanTemplate"),r=l=>{l.stopPropagation(),n()},i=l=>{l.stopPropagation(),a(l)};return t.jsxs(fi,{children:[t.jsxs(hi,{className:"cardContent",children:[t.jsxs(yi,{children:[t.jsx(pi,{children:t.jsx(o,{})}),t.jsx(gi,{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(xi,{className:"buttonContainer",children:[t.jsx(ne,{variant:"contained",size:"small",onClick:r,tabIndex:0,children:"Use"}),t.jsx(ne,{variant:"outlined",size:"small",onClick:i,children:"Preview"})]})]})},ji=g(B)(()=>({width:"100%",display:"flex",flexDirection:"column"})),bi=g(B)(({theme:e})=>({width:"100%",maxHeight:"70vh",overflowY:"auto",padding:e.spacing(4),paddingTop:0,display:"flex",flexDirection:"column",gap:e.spacing(3)})),ot=g(B)(({theme:e})=>({display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:e.spacing(1.5),width:"100%"})),ze=g(B)(()=>({width:"100%",minWidth:0})),vi=g(B)(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",padding:e.spacing(4,4,2,4)})),Si=g(z)(({theme:e})=>({fontSize:e.typography.body1.fontSize,fontWeight:e.typography.fontWeightBold,margin:0})),rt=g(B)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(.5),marginBottom:e.spacing(1),width:"100%"})),it=g(la)(({theme:e})=>({fontSize:e.typography.body2.fontSize,color:e.palette.text.secondary})),Ci=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"})),Ti=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"})),wi=g(z)(({theme:e})=>({fontSize:e.typography.caption.fontSize,fontWeight:e.typography.fontWeightBold,marginBottom:e.spacing(1),display:"flex",alignItems:"center"})),ki=g(z)(({theme:e})=>({fontSize:e.typography.caption.fontSize,color:e.palette.text.secondary})),Ri=g(Ye)(({theme:e})=>({fontWeight:e.typography.fontWeightBold,cursor:"pointer","&:hover":{textDecoration:"underline"}})),Di=({projectId:e,featureId:s,environmentId:n,onlyReleasePlans:a,onAddReleasePlan:o,onReviewReleasePlan:r,onClose:i})=>{const{isEnterprise:l}=fe(),c=Je("releasePlans"),{strategies:p}=da(),{templates:u}=ua(),d=le(),m=p.filter(h=>!h.deprecated&&!h.editable),j=p.filter(h=>!h.deprecated&&h.editable),y={name:"flexibleRollout",displayName:"Default strategy",description:"This is the default strategy defined for this environment in the project"},b=()=>!l()||!c?null:u.length?t.jsxs(B,{children:[t.jsxs(rt,{children:[t.jsx(z,{color:"inherit",variant:"body2",children:"Apply a release template"}),t.jsx(ee,{title:"Use a predefined template to roll out features to users",arrow:!0,children:t.jsx(it,{})})]}),t.jsx(ot,{children:u.map(h=>t.jsx(ze,{children:t.jsx(mi,{template:h,onClick:()=>o(h),onPreviewClick:()=>r(h)})},h.id))})]}):t.jsxs(Ti,{children:[t.jsxs(wi,{children:[t.jsx(Ci,{children:t.jsx(pa,{})}),"Create your own release templates"]}),t.jsxs(ki,{children:["Standardize your rollouts and save time by reusing predefined strategies. Find release templates in the side menu under"," ",t.jsx(Ri,{onClick:()=>d("/release-templates"),children:"Configure > Release templates"})]})]});return t.jsxs(ji,{children:[t.jsxs(vi,{children:[t.jsx(Si,{variant:"h2",children:a?"Select template":"Select strategy"}),t.jsx(xe,{size:"small",onClick:i,edge:"end","aria-label":"close",children:t.jsx(kt,{fontSize:"small"})})]}),t.jsx(bi,{children:a?b():t.jsxs(t.Fragment,{children:[t.jsxs(B,{children:[t.jsxs(rt,{children:[t.jsx(z,{color:"inherit",variant:"body2",children:"Pre-defined strategy types"}),t.jsx(ee,{title:"Select a starting setup, and customize the strategy to your need with targeting and variants",arrow:!0,children:t.jsx(it,{})})]}),t.jsxs(ot,{children:[t.jsx(ze,{children:t.jsx(at,{projectId:e,featureId:s,environmentId:n,strategy:y,defaultStrategy:!0,onClose:i})},y.name),m.map(h=>t.jsx(ze,{children:t.jsx(at,{projectId:e,featureId:s,environmentId:n,strategy:h,onClose:i})},h.name))]})]}),b(),j.length>0&&t.jsxs(B,{children:[t.jsxs(rt,{children:[t.jsx(z,{color:"inherit",variant:"body2",children:"Custom strategies"}),t.jsx(ee,{title:"Custom strategies you have defined in Unleash",arrow:!0,children:t.jsx(it,{})})]}),t.jsx(ot,{children:j.map(h=>t.jsx(ze,{children:t.jsx(at,{projectId:e,featureId:s,environmentId:n,strategy:h,onClose:i})},h.name))})]})]})})]})},Ai=g(Bs)(({theme:e})=>({"& .MuiDialog-paper":{borderRadius:e.shape.borderRadiusLarge,maxWidth:e.spacing(85)}})),Ei=g(ga)(({theme:e})=>({padding:e.spacing(2,4,4)})),Ii=g(B)(({theme:e})=>({display:"flex",justifyContent:"space-between",marginBottom:e.spacing(2)})),$i=g(B)(({theme:e})=>({display:"flex",alignItems:"center",cursor:"pointer"})),Pi=g(ha)(({theme:e})=>({marginRight:e.spacing(1),color:e.palette.primary.main,display:"flex",alignSelf:"center"})),Fi=g(z)(({theme:e})=>({fontWeight:e.typography.fontWeightMedium,display:"flex",alignItems:"center",lineHeight:1})),Oi=({open:e,setOpen:s,onConfirm:n,template:a,projectId:o,featureName:r,environment:i,crProtected:l})=>{const{feature:c}=W(o,r),{releasePlans:p}=Ke(o,r,i),u=p[0],d=c==null?void 0:c.environments.find(({name:b})=>b===i),m=d==null?void 0:d.enabled,j=xa(a.id,r,i),y=()=>s(!1);return t.jsxs(Ai,{open:e,onClose:y,fullWidth:!0,maxWidth:"md",children:[t.jsxs(fa,{children:[t.jsxs(Ii,{children:[t.jsxs($i,{onClick:y,children:[t.jsx(Pi,{}),t.jsx(Fi,{variant:"body2",color:"primary",children:"Go back"})]}),t.jsx(xe,{size:"small",onClick:y,edge:"end","aria-label":"close",children:t.jsx(kt,{fontSize:"small"})})]}),u&&t.jsxs(Z,{severity:"error",sx:{mb:1},children:["This feature environment currently has"," ",t.jsx("strong",{children:u.name})," -"," ",t.jsx("strong",{children:u.milestones[0].name}),m?" running":" paused",". Adding a new release plan will replace the existing release plan."]}),t.jsx("div",{children:t.jsx(zs,{plan:j,readonly:!0})}),l&&t.jsxs(z,{sx:{mt:4},children:[t.jsx("strong",{children:"Adding"})," release template"," ",t.jsx("strong",{children:a==null?void 0:a.name})," to"," ",t.jsx("strong",{children:r})," in"," ",t.jsx("strong",{children:i}),"."]})]}),t.jsx(Ei,{children:t.jsx(ne,{variant:"contained",color:"primary",onClick:n,children:l?"Add suggestion to draft":"Use template"})})]})},_i=g("div")(({theme:e})=>({display:"flex",flexFlow:"row",justifyContent:"flex-end",gap:e.spacing(1)})),Bi=g(K)(({theme:e})=>({minWidth:0,width:e.spacing(4.5),alignSelf:"stretch",paddingBlock:0})),os=({label:e,projectId:s,featureId:n,environmentId:a,variant:o,size:r,matchWidth:i,disableReason:l})=>{const[c,p]=x.useState(!1),[u,d]=x.useState(!1),m=le(),{trackEvent:j}=ie(),[y,b]=x.useState(),[h,f]=x.useState(!1),w=c?"FeatureStrategyMenuDialog":void 0,{setToastApiError:E,setToastData:O}=H(),{isChangeRequestConfigured:_}=te(s),{addChange:$}=pe(),{refetch:D}=ce(s),{refetch:I}=Ke(s,n,a),{addReleasePlanToFeature:R}=ya(),{isOss:M}=fe(),G=Je("releasePlans"),Q=!M()&&G,C=G&&_(a),P=()=>{p(!1)},v=k=>{j("strategy-add",{props:{buttonTitle:e}}),m(N)},S=k=>{d(!1),p(!0)},F=k=>{d(!0),p(!0)},V=async k=>{try{C?(await $(s,a,{feature:n,action:"addReleasePlan",payload:{templateId:k.id}}),O({type:"success",text:"Added to draft"}),D()):(await R(n,k.id,s,a),O({type:"success",text:"Release plan added"}),I()),j("release-management",{props:{eventType:"add-plan",plan:k.name}})}catch(oe){E(q(oe))}finally{f(!1),b(void 0),P()}},N=cn(s,n,a,"flexibleRollout",!0);return t.jsxs(_i,{onClick:k=>k.stopPropagation(),children:[Q?t.jsx(K,{"data-testid":"ADD_TEMPLATE_BUTTON",permission:ve,projectId:s,environmentId:a,onClick:F,"aria-labelledby":w,variant:"outlined",sx:{minWidth:i?"282px":"auto"},disabled:!!l,tooltipProps:{title:l||void 0},children:"Use template"}):null,t.jsx(K,{"data-testid":"ADD_STRATEGY_BUTTON",permission:ve,projectId:s,environmentId:a,onClick:v,"aria-labelledby":w,variant:o,sx:{minWidth:i?"282px":"auto"},disabled:!!l,tooltipProps:{title:l||void 0},children:e}),t.jsx(Bi,{permission:ve,projectId:s,environmentId:a,onClick:S,variant:"outlined",hideLockIcon:!0,disabled:!!l,tooltipProps:{title:l||"More strategies"},children:t.jsx(St,{})}),t.jsx(Bs,{open:c,onClose:P,maxWidth:"md",PaperProps:{sx:{borderRadius:"12px"}},children:t.jsx(Di,{projectId:s,featureId:n,environmentId:a,onlyReleasePlans:u,onAddReleasePlan:k=>{b(k),V(k)},onReviewReleasePlan:k=>{b(k),f(!0),P()},onClose:P})}),y&&t.jsx(Oi,{open:h,setOpen:k=>{f(k),k||p(!0)},onConfirm:()=>{V(y)},template:y,projectId:s,featureName:n,environment:a,crProtected:C})]})},dn=(e,s)=>e===0?0:Math.round(s/e*100),zi=g("div")(()=>({display:"flex",alignItems:"center",justifyContent:"center",position:"relative",margin:0})),Li=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})),Mi=({percentage:e,size:s="4rem",disabled:n=!1,children:a})=>{const o=Pe(),r={display:"block",borderRadius:"100%",transform:"rotate(-90deg)",height:s,width:s},i=100/(2*Math.PI),l=2*i,c=l*.2,p=n?o.palette.neutral.border:o.palette.primary.light;return t.jsxs(zi,{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:p,strokeWidth:c,strokeDasharray:`${e} 100`})]}),t.jsx(Li,{color:p,children:a})]})},Vi=g("figure")(({theme:e})=>({display:"flex",alignItems:"ce