unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
3 lines • 70.6 kB
JavaScript
import{u as rn,g as an,r as m,_ as on,j as t,a as Fe,s as f,U as ln,b as $,B as C,C as v,d as cn,c as dn,e as ct,f as un,h as re,T as R,F as hn,I as gn,S as xn,M as mn,i as xe,p as _e,k as Ge,l as le,A as dt,m as fn,n as pn,o as jn,q as bn,t as ut,v as yn,w as vn,x as Sn,y as qe,P as Cn,z as Ve,D as A,L as wn,E as kn,G as me,H as fe,J as ee,K as En,N as V,O as ae,Q as ht,R as gt,V as xt,W as U,X as Tn,Y as J,Z as mt,$ as Z,a0 as ft,a1 as Te,a2 as ce,a3 as Ie,a4 as In,a5 as pt,a6 as Pn,a7 as $e,a8 as Pe,a9 as Rn,aa as Fn,ab as $n,ac as jt,ad as On,ae as Bn,af as Dn,ag as Nn,ah as Ln,ai as An,aj as Wn,ak as zn,al as B,am as pe,an as Mn,ao as Un,ap as Hn,aq as _n,ar as Gn,as as qn,at as Ke,au as bt,av as Oe,aw as Be,ax as yt,ay as De,az as vt,aA as St,aB as Ct,aC as wt,aD as Vn,aE as Je,aF as Kn,aG as Jn,aH as ve,aI as Yn,aJ as Zn,aK as Qn,aL as Xn,aM as es,aN as ts,aO as ns}from"./index-DEkgmbaI.js";import{c as ss,d as rs,s as as,h as os,f as is,a as ls,l as cs,b as ds,e as us,g as hs,i as gs,j as xs,k as ms,m as fs,E as ue,n as ps,o as Ne,p as js,q as bs,r as ys,t as vs,u as Ss,v as Cs,w as ws,x as ks,y as Es,z as kt,A as q,H as Et,B as u,C as Ts,D as Is,S as Ps,F as Rs,G as Fs}from"./index-CKXZ0XnY.js";import{u as $s}from"./useApiTokens-DuYwQsyc.js";import{S as Os}from"./LegacyStrategyItemContainer-CqOcbhDa.js";const Bs=()=>{const{makeRequest:e,createRequest:n,errors:s,loading:r}=rn({propagateErrors:!0}),a="api/admin/playground";return{evaluateAdvancedPlayground:async c=>{const d=`${a}/advanced`,g=n(d,{method:"POST",body:JSON.stringify(c)});return(await e(g.caller,g.id)).json()},evaluateChangeRequestPlayground:async(c,d)=>{const g=`${a}/change-request/${c}`,l=n(g,{method:"POST",body:JSON.stringify(d)});return(await e(l.caller,l.id)).json()},errors:s,loading:r}};var Le={exports:{}};function Tt(e,n=100,s={}){if(typeof e!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof e}\`.`);if(n<0)throw new RangeError("`wait` must not be negative.");const{immediate:r}=typeof s=="boolean"?{immediate:s}:s;let a,o,i,c,d;function g(){const h=a,p=o;return a=void 0,o=void 0,d=e.apply(h,p),d}function l(){const h=Date.now()-c;h<n&&h>=0?i=setTimeout(l,n-h):(i=void 0,r||(d=g()))}const x=function(...h){if(a&&this!==a&&Object.getPrototypeOf(this)===Object.getPrototypeOf(a))throw new Error("Debounced method called with different contexts of the same prototype.");a=this,o=h,c=Date.now();const p=r&&!i;return i||(i=setTimeout(l,n)),p&&(d=g()),d};return Object.defineProperty(x,"isPending",{get(){return i!==void 0}}),x.clear=()=>{i&&(clearTimeout(i),i=void 0)},x.flush=()=>{i&&x.trigger()},x.trigger=()=>{d=g(),x.clear()},x}Le.exports.debounce=Tt;Le.exports=Tt;var Ds=Le.exports;const Ns=an(Ds);var Ye=function(n){n===void 0&&(n={});var{crosshairCursor:s=!1}=n,r=[];n.closeBracketsKeymap!==!1&&(r=r.concat(ss)),n.defaultKeymap!==!1&&(r=r.concat(rs)),n.searchKeymap!==!1&&(r=r.concat(as)),n.historyKeymap!==!1&&(r=r.concat(os)),n.foldKeymap!==!1&&(r=r.concat(is)),n.completionKeymap!==!1&&(r=r.concat(ls)),n.lintKeymap!==!1&&(r=r.concat(cs));var a=[];return n.lineNumbers!==!1&&a.push(ds()),n.highlightActiveLineGutter!==!1&&a.push(us()),n.highlightSpecialChars!==!1&&a.push(hs()),n.history!==!1&&a.push(gs()),n.foldGutter!==!1&&a.push(xs()),n.drawSelection!==!1&&a.push(ms()),n.dropCursor!==!1&&a.push(fs()),n.allowMultipleSelections!==!1&&a.push(ue.allowMultipleSelections.of(!0)),n.indentOnInput!==!1&&a.push(ps()),n.syntaxHighlighting!==!1&&a.push(Ne(js,{fallback:!0})),n.bracketMatching!==!1&&a.push(bs()),n.closeBrackets!==!1&&a.push(ys()),n.autocompletion!==!1&&a.push(vs()),n.rectangularSelection!==!1&&a.push(Ss()),s!==!1&&a.push(Cs()),n.highlightActiveLine!==!1&&a.push(ws()),n.highlightSelectionMatches!==!1&&a.push(ks()),n.tabSize&&typeof n.tabSize=="number"&&a.push(Es.of(" ".repeat(n.tabSize))),a.concat([kt.of(r.flat())]).filter(Boolean)};const Ls="#e5c07b",Ze="#e06c75",As="#56b6c2",Ws="#ffffff",de="#abb2bf",Re="#7d8799",zs="#61afef",Ms="#98c379",Qe="#d19a66",Us="#c678dd",Hs="#21252b",Xe="#2c313a",et="#282c34",Se="#353a42",_s="#3E4451",tt="#528bff",Gs=q.theme({"&":{color:de,backgroundColor:et},".cm-content":{caretColor:tt},".cm-cursor, .cm-dropCursor":{borderLeftColor:tt},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:_s},".cm-panels":{backgroundColor:Hs,color:de},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:et,color:Re,border:"none"},".cm-activeLineGutter":{backgroundColor:Xe},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Se},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Se,borderBottomColor:Se},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Xe,color:de}}},{dark:!0}),qs=Et.define([{tag:u.keyword,color:Us},{tag:[u.name,u.deleted,u.character,u.propertyName,u.macroName],color:Ze},{tag:[u.function(u.variableName),u.labelName],color:zs},{tag:[u.color,u.constant(u.name),u.standard(u.name)],color:Qe},{tag:[u.definition(u.name),u.separator],color:de},{tag:[u.typeName,u.className,u.number,u.changed,u.annotation,u.modifier,u.self,u.namespace],color:Ls},{tag:[u.operator,u.operatorKeyword,u.url,u.escape,u.regexp,u.link,u.special(u.string)],color:As},{tag:[u.meta,u.comment],color:Re},{tag:u.strong,fontWeight:"bold"},{tag:u.emphasis,fontStyle:"italic"},{tag:u.strikethrough,textDecoration:"line-through"},{tag:u.link,color:Re,textDecoration:"underline"},{tag:u.heading,fontWeight:"bold",color:Ze},{tag:[u.atom,u.bool,u.special(u.variableName)],color:Qe},{tag:[u.processingInstruction,u.string,u.inserted],color:Ms},{tag:u.invalid,color:Ws}]),Vs=[Gs,Ne(qs)];var Ks=q.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Js=function(n){n===void 0&&(n={});var{indentWithTab:s=!0,editable:r=!0,readOnly:a=!1,theme:o="light",placeholder:i="",basicSetup:c=!0}=n,d=[];switch(s&&d.unshift(kt.of([Ts])),c&&(typeof c=="boolean"?d.unshift(Ye()):d.unshift(Ye(c))),i&&d.unshift(Is(i)),o){case"light":d.push(Ks);break;case"dark":d.push(Vs);break;case"none":break;default:d.push(o);break}return r===!1&&d.push(q.editable.of(!1)),a&&d.push(ue.readOnly.of(!0)),[...d]},Ys=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(n=>e.state.sliceDoc(n.from,n.to)),selectedText:e.state.selection.ranges.some(n=>!n.empty)}),nt=Rs.define(),Zs=[];function Qs(e){var{value:n,selection:s,onChange:r,onStatistics:a,onCreateEditor:o,onUpdate:i,extensions:c=Zs,autoFocus:d,theme:g="light",height:l=null,minHeight:x=null,maxHeight:h=null,width:p=null,minWidth:S=null,maxWidth:T=null,placeholder:P="",editable:N=!0,readOnly:F=!1,indentWithTab:D=!0,basicSetup:y=!0,root:j,initialState:I}=e,[b,w]=m.useState(),[k,L]=m.useState(),[W,H]=m.useState(),te=q.theme({"&":{height:l,minHeight:x,maxHeight:h,width:p,minWidth:S,maxWidth:T},"& .cm-scroller":{height:"100% !important"}}),Q=q.updateListener.of(O=>{if(O.docChanged&&typeof r=="function"&&!O.transactions.some(be=>be.annotation(nt))){var Y=O.state.doc,X=Y.toString();r(X,O)}a&&a(Ys(O))}),ne=Js({theme:g,editable:N,readOnly:F,placeholder:P,indentWithTab:D,basicSetup:y}),z=[Q,te,...ne];return i&&typeof i=="function"&&z.push(q.updateListener.of(i)),z=z.concat(c),m.useLayoutEffect(()=>{if(b&&!W){var O={doc:n,selection:s,extensions:z},Y=I?ue.fromJSON(I.json,O,I.fields):ue.create(O);if(H(Y),!k){var X=new q({state:Y,parent:b,root:j});L(X),o&&o(X,Y)}}return()=>{k&&(H(void 0),L(void 0))}},[b,W]),m.useEffect(()=>{e.container&&w(e.container)},[e.container]),m.useEffect(()=>()=>{k&&(k.destroy(),L(void 0))},[k]),m.useEffect(()=>{d&&k&&k.focus()},[d,k]),m.useEffect(()=>{k&&k.dispatch({effects:Ps.reconfigure.of(z)})},[g,c,l,x,h,p,S,T,P,N,F,D,y,r,i]),m.useEffect(()=>{if(n!==void 0){var O=k?k.state.doc.toString():"";k&&n!==O&&k.dispatch({changes:{from:0,to:O.length,insert:n||""},annotations:[nt.of(!0)]})}},[n,k]),{state:W,setState:H,view:k,setView:L,container:b,setContainer:w}}var Xs=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],It=m.forwardRef((e,n)=>{var{className:s,value:r="",selection:a,extensions:o=[],onChange:i,onStatistics:c,onCreateEditor:d,onUpdate:g,autoFocus:l,theme:x="light",height:h,minHeight:p,maxHeight:S,width:T,minWidth:P,maxWidth:N,basicSetup:F,placeholder:D,indentWithTab:y,editable:j,readOnly:I,root:b,initialState:w}=e,k=on(e,Xs),L=m.useRef(null),{state:W,view:H,container:te,setContainer:Q}=Qs({root:b,value:r,autoFocus:l,theme:x,height:h,minHeight:p,maxHeight:S,width:T,minWidth:P,maxWidth:N,basicSetup:F,placeholder:D,indentWithTab:y,editable:j,readOnly:I,selection:a,onChange:i,onStatistics:c,onCreateEditor:d,onUpdate:g,extensions:o,initialState:w});m.useImperativeHandle(n,()=>({editor:L.current,state:W,view:H}),[L,te,W,H]);var ne=m.useCallback(O=>{L.current=O,Q(O)},[Q]);if(typeof r!="string")throw new Error("value must be typeof string but got "+typeof r);var z=typeof x=="string"?"cm-theme-"+x:"cm-theme";return t.jsx("div",Fe({ref:ne,className:""+z+(s?" "+s:"")},k))});It.displayName="CodeMirror";var Pt=e=>{var{theme:n,settings:s={},styles:r=[]}=e,a={".cm-gutters":{}},o={};s.background&&(o.backgroundColor=s.background),s.backgroundImage&&(o.backgroundImage=s.backgroundImage),s.foreground&&(o.color=s.foreground),s.fontSize&&(o.fontSize=s.fontSize),(s.background||s.foreground)&&(a["&"]=o),s.fontFamily&&(a["&.cm-editor .cm-scroller"]={fontFamily:s.fontFamily}),s.gutterBackground&&(a[".cm-gutters"].backgroundColor=s.gutterBackground),s.gutterForeground&&(a[".cm-gutters"].color=s.gutterForeground),s.gutterBorder&&(a[".cm-gutters"].borderRightColor=s.gutterBorder),s.caret&&(a[".cm-content"]={caretColor:s.caret},a[".cm-cursor, .cm-dropCursor"]={borderLeftColor:s.caret});var i={};s.gutterActiveForeground&&(i.color=s.gutterActiveForeground),s.lineHighlight&&(a[".cm-activeLine"]={backgroundColor:s.lineHighlight},i.backgroundColor=s.lineHighlight),a[".cm-activeLineGutter"]=i,s.selection&&(a["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:s.selection+" !important"}),s.selectionMatch&&(a["& .cm-selectionMatch"]={backgroundColor:s.selectionMatch});var c=q.theme(a,{dark:n==="dark"}),d=Et.define(r),g=[c,Ne(d)];return g},er={background:"#faf8f5",foreground:"#b29762",caret:"#93abdc",selection:"#e3dcce",selectionMatch:"#e3dcce",gutterBackground:"#faf8f5",gutterForeground:"#cdc4b1",gutterBorder:"transparent",lineHighlight:"#ddceb154"},tr=[{tag:[u.comment,u.bracket],color:"#b6ad9a"},{tag:[u.atom,u.number,u.keyword,u.link,u.attributeName,u.quote],color:"#063289"},{tag:[u.emphasis,u.heading,u.tagName,u.propertyName,u.variableName],color:"#2d2006"},{tag:[u.typeName,u.url,u.string],color:"#896724"},{tag:[u.operator,u.string],color:"#1659df"},{tag:[u.propertyName],color:"#b29762"},{tag:[u.unit,u.punctuation],color:"#063289"}],nr=e=>{var{theme:n="light",settings:s={},styles:r=[]}={};return Pt({theme:n,settings:Fe({},er,s),styles:[...tr,...r]})},sr=nr(),rr={background:"#2a2734",foreground:"#6c6783",caret:"#ffad5c",selection:"#91ff6c26",selectionMatch:"#91ff6c26",gutterBackground:"#2a2734",gutterForeground:"#545167",lineHighlight:"#36334280"},ar=[{tag:[u.comment,u.bracket],color:"#6c6783"},{tag:[u.atom,u.number,u.keyword,u.link,u.attributeName,u.quote],color:"#ffcc99"},{tag:[u.emphasis,u.heading,u.tagName,u.propertyName,u.className,u.variableName],color:"#eeebff"},{tag:[u.typeName,u.url],color:"#7a63ee"},{tag:u.operator,color:"#ffad5c"},{tag:u.string,color:"#ffb870"},{tag:[u.propertyName],color:"#9a86fd"},{tag:[u.unit,u.punctuation],color:"#e09142"}],or=e=>{var{theme:n="dark",settings:s={},styles:r=[]}={};return Pt({theme:n,settings:Fe({},rr,s),styles:[...ar,...r]})},ir=or();const lr=f("aside")(({theme:e})=>({height:"50px",backgroundColor:e.palette.background.paper,borderTopRightRadius:e.shape.borderRadiusMedium,borderTopLeftRadius:e.shape.borderRadiusMedium,padding:e.spacing(1,2),color:e.palette.text.primary,display:"flex",justifyContent:"space-between",alignItems:"center",border:`1px solid ${e.palette.divider}`})),Rt=f("div")(({theme:e,style:n})=>({width:e.spacing(3),height:e.spacing(3),display:"flex",alignItems:"center",color:e.palette.background.paper,justifyContent:"center",transition:"background-color 0.5s ease-in-out",borderRadius:"50%",...n})),cr=f("div")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.error.dark,marginRight:e.spacing(1)})),dr=()=>{const e=$();return t.jsx(Rt,{style:{backgroundColor:e.palette.success.main},children:t.jsx(cn,{sx:n=>({width:n.spacing(2),height:n.spacing(2)})})})},ur=()=>{const e=$();return t.jsx(Rt,{style:{backgroundColor:e.palette.error.main},children:t.jsx(dn,{})})},hr=({context:e,setContext:n,error:s})=>{const{themeMode:r}=m.useContext(ln),a=$(),o=m.useCallback(c=>{n(c)},[n]),i=`calc(6 * ${a.typography.body1.fontSize} * ${a.typography.body1.lineHeight}) + 8px`;return t.jsxs(C,{sx:{width:"100%"},children:[t.jsxs(lr,{children:["JSON",t.jsx(v,{condition:!!s,show:t.jsxs(C,{sx:c=>({display:"flex",alignItems:"center"}),children:[t.jsx(cr,{children:s}),t.jsx(ur,{})]}),elseShow:t.jsx(dr,{})})]}),t.jsx(It,{value:e,minHeight:i,theme:r==="dark"?ir:sr,extensions:[Fs()],onChange:o,style:{border:`1px solid ${a.palette.divider}`,borderTop:"none"},placeholder:JSON.stringify({currentTime:"2022-07-04T14:13:03.929Z",appName:"playground",userId:"test",remoteAddress:"127.0.0.1"},null,2)})]})};function Ft(e){return Array.isArray(e)?e:[e]}const gr=e=>!e||e.length===0||e.length===1&&e[0]==="*"?"*":Ft(e),xr=e=>Ft(e),mr=e=>{const n=fr(e);return n.length>0?n[0]:""},fr=e=>e.filter(({enabled:n})=>!!n).sort((n,s)=>n.sortOrder-s.sortOrder).map(({name:n})=>n),pr=(e,n)=>"100%",jr=e=>typeof e=="string"?!0:Array.isArray(e)?e.every(n=>typeof n=="string"):!1,br=e=>{const n=new Set(["appName","environment","userId","sessionId","remoteAddress","currentTime","properties"]),s={...e};let r=!1;for(const a in e)n.has(a)||(s.properties||(s.properties={}),s.properties[a]=e[a],delete s[a],r=!0);return!r&&!e.properties&&delete s.properties,s},yr=e=>{const[n]=e.split("."),[s,r]=n.split(":");if(!s||!r)throw new Error("Invalid token format");if(r==="*")throw new Error("Admin tokens are not supported in the playground")},vr=e=>{const[n]=e.split(".");return n.split(":")},Sr=({context:e,setContext:n})=>{const s=$(),{setToastData:r}=ct(),{context:a}=un(),o=a.sort((y,j)=>y.sortOrder-j.sortOrder).map(({name:y})=>y),[i,c]=m.useState(),[d,g]=m.useState(!1),[l,x]=m.useState(""),[h,p]=m.useState(""),S=m.useMemo(()=>Ns(y=>{var j;if(!y)return c(void 0);try{const I=JSON.parse(y);g(I[l]!==void 0||((j=I==null?void 0:I.properties)==null?void 0:j[l])!==void 0)}catch(I){return c(re(I))}return c(void 0)},250),[c,l,g]);m.useEffect(()=>{S(e)},[S,e]);const T=()=>{try{const y=JSON.parse(e||"{}");n(JSON.stringify(br({...y,[l]:h}),null,2));const j=a.find(I=>I.name===l);if(j!=null&&j.legalValues&&j.legalValues.length>0||l==="currentTime")return p("")}catch(y){r({type:"error",text:`Error parsing context: ${re(y)}`})}},P=(y,j)=>{if(jr(j)){if(Array.isArray(j)){const I=(j||[]).length>1?j.join(","):j[0];return p(I)}p(j)}},N=()=>{if(!h||h==="")return[];const y=a.find(I=>I.name===l),j=((y==null?void 0:y.legalValues)||[]).length>1;return h.includes(",")&&j?h.split(","):[h]},F=()=>{if(l==="currentTime"){const j=_e(h),b=j?Ge(j.toISOString()):Ge(new Date().toISOString());return t.jsx(le,{id:"date",label:"Date",size:"small",type:"datetime-local",value:b,sx:{width:200,maxWidth:"100%"},onChange:w=>{const k=_e(w.target.value),L=k==null?void 0:k.toISOString();L&&p(L)},InputLabelProps:{shrink:!0},required:!0})}const y=a.find(j=>j.name===l);if(y!=null&&y.legalValues&&y.legalValues.length>0){const j=y.legalValues.map(({value:I})=>I);return t.jsx(dt,{disablePortal:!0,limitTags:3,id:"context-legal-values",multiple:!0,options:j,disableCloseOnSelect:!0,size:"small",value:N(),onChange:P,getOptionLabel:I=>I,renderOption:(I,b,{selected:w})=>t.jsxs("li",{...I,children:[t.jsx(fn,{icon:t.jsx(pn,{fontSize:"small"}),checkedIcon:t.jsx(jn,{fontSize:"small"}),sx:k=>({marginRight:k.spacing(.5)}),checked:w}),b]}),sx:{width:370,maxWidth:"100%"},renderInput:I=>t.jsx(le,{...I,label:"Value"})})}return t.jsx(le,{label:"Value",id:"context-value",sx:{width:370,maxWidth:"100%"},placeholder:"value1,value2,value3",size:"small",value:h,onChange:j=>p(j.target.value||"")})},D=y=>{if(x(y.target.value||""),y.target.value==="currentTime")return p(new Date().toISOString());p("")};return t.jsxs(C,{children:[t.jsx(C,{sx:{display:"flex",alignItems:"center",mb:2},children:t.jsx(R,{variant:"body2",color:s.palette.text.primary,sx:{ml:1},children:"Unleash context"})}),t.jsxs(C,{sx:{display:"flex",gap:2,flexWrap:"wrap",mb:2},children:[t.jsxs(hn,{children:[t.jsx(gn,{id:"context-field-label",size:"small",children:"Context field"}),t.jsx(xn,{label:"Context field",labelId:"context-field-label",id:"context-field",value:l,onChange:D,variant:"outlined",size:"small",sx:{width:200,maxWidth:"100%"},children:o.map(y=>t.jsx(mn,{value:y,children:y},y))})]}),F(),t.jsx(xe,{variant:"outlined",disabled:!l||!!i,onClick:T,sx:{width:"95px",maxHeight:"40px"},children:`${d?"Replace":"Add"} `})]}),t.jsx(hr,{context:e,setContext:n,error:i})]})},Cr=({environments:e,setEnvironments:n,availableEnvironments:s,disabled:r})=>{const a=[...s.map(c=>({label:c,id:c}))],o=a.filter(({id:c})=>e.includes(c)),i=(c,d,g)=>{const l=d;return g==="clear"||l===null?n([]):Array.isArray(l)?l.length===0?n([]):n(l.map(({id:x})=>x)):n([l.id])};return t.jsx(dt,{disablePortal:!0,limitTags:3,id:"environment",multiple:!0,options:a,sx:{flex:1},renderInput:c=>t.jsx(le,{...c,label:"Environments"}),renderOption:bn,renderTags:(c,d)=>c.map((g,l)=>{const{key:x,...h}=d({index:l});return t.jsx(ut,{size:"small",...h,label:g.label},x)}),getOptionLabel:({label:c})=>c,disableCloseOnSelect:!1,size:"small",value:o,onChange:i,disabled:r,"data-testid":"PLAYGROUND_ENVIRONMENT_SELECT"})},Ce={label:"ALL",id:"*"},st=f(yn)({fontSize:"1.25rem"}),$t=f(vn)(()=>({width:"100%"})),wr=f(C)(({theme:e})=>({display:"grid",columnGap:e.spacing(2),rowGap:e.spacing(2),gridTemplateColumns:"1fr",[e.breakpoints.up("md")]:{gridTemplateColumns:"1fr 1fr"}})),kr=f($t)(({theme:e})=>({"& label":{WebkitTextFillColor:e.palette.text.secondary},"& input.Mui-disabled":{WebkitTextFillColor:e.palette.text.secondary}})),Er=({environments:e,projects:n,token:s,setProjects:r,setEnvironments:a,setToken:o,availableEnvironments:i,changeRequest:c,onClearChangeRequest:d})=>{const g=$(),{tokens:l}=$s(),[x,h]=m.useState(),{projects:p}=Sn(),S=[Ce,...p.map(({name:b,id:w})=>({label:b,id:w}))],T=async b=>{const w=b.target.value;if(o==null||o(w),w===""){j();return}try{yr(w),h(void 0),P(w)}catch(k){h(k.message)}},P=b=>{const[w,k]=vr(b);switch(a([k]),w){case"[]":F(b);break;case"*":D();break;default:y(w)}},N=b=>{!b.projects||b.projects==="*"?r([Ce.id]):typeof b.projects=="string"?r([b.projects]):Array.isArray(b.projects)&&r(b.projects)},F=b=>{const w=l.find(({secret:k})=>k===b);w?N(w):h("Invalid token. Ensure you use a valid token from this Unleash instance.")},D=()=>{r([Ce.id])},y=b=>{S.map(w=>w.id).includes(b)?r([b]):h(`Invalid token. Project ${b} does not exist.`)},j=()=>{h(void 0)},I=()=>{o==null||o(""),j()};return t.jsxs(C,{sx:{pb:2},children:[t.jsx(C,{sx:{display:"flex",alignItems:"center",mb:2},children:t.jsx(R,{variant:"body2",color:g.palette.text.primary,sx:{ml:1},children:"Access configuration"})}),t.jsxs(wr,{children:[t.jsx(C,{children:t.jsx(qe,{arrow:!0,title:s?"Environment is automatically selected because you are using a token":"Select environments to use in the playground",children:t.jsx(C,{children:t.jsx(Cr,{environments:e,setEnvironments:a,availableEnvironments:i,disabled:!!(s||c)})})})}),t.jsx(C,{children:t.jsx(qe,{arrow:!0,title:s?"Project is automatically selected because you are using a token":"Select projects to use in the playground",children:t.jsx(Cn,{selectedProjects:n,onChange:r,dataTestId:"PLAYGROUND_PROJECT_SELECT",disabled:!!(s||c),limitTags:3})})}),t.jsx(C,{children:t.jsx($t,{label:"API token",value:s||(c?" ":""),onChange:T,type:"text",error:!!x,errorText:x,placeholder:"Enter your API token","data-testid":"PLAYGROUND_TOKEN_INPUT",InputProps:{endAdornment:s?t.jsx(Ve,{position:"end","data-testid":"TOKEN_INPUT_CLEAR_BTN",children:t.jsx(A,{"aria-label":"clear API token",onClick:I,edge:"end",children:t.jsx(st,{})})}):null},disabled:!!c})}),t.jsx(v,{condition:!!c,show:t.jsxs(C,{sx:{display:"flex",gap:2},children:[t.jsx(C,{sx:{flex:1},children:t.jsx(kr,{label:"Change request",value:c?`Change request #${c}`:"",onChange:()=>{},type:"text",disabled:!0,InputProps:{endAdornment:t.jsx(Ve,{position:"end",children:t.jsx(A,{"aria-label":"clear Change request results",onClick:d,edge:"end",children:t.jsx(st,{})})})}})}),t.jsx(xe,{variant:"outlined",size:"small",to:`/projects/${n[0]}/change-requests/${c}`,component:wn,children:"View change request"})]})})]})]})},Tr=({availableEnvironments:e,environments:n,onSubmit:s,projects:r,token:a,setToken:o,setProjects:i,setEnvironments:c,context:d,setContext:g,changeRequest:l,onClearChangeRequest:x})=>t.jsxs(C,{component:"form",onSubmit:s,sx:{display:"flex",flexDirection:"column"},children:[t.jsx(Er,{environments:Array.isArray(n)?n:[n],projects:r,token:a,setToken:o,setEnvironments:c,setProjects:i,availableEnvironments:e.map(({name:h})=>h),changeRequest:l,onClearChangeRequest:x}),t.jsx(Sr,{context:d,setContext:g}),t.jsx(C,{sx:{mt:2,display:"flex",alignItems:"center",justifyContent:"space-between"},children:t.jsx(xe,{variant:"contained",size:"large",type:"submit",sx:{marginLeft:"auto"},children:"Try configuration"})})]}),Ir=f("div")(({style:e,theme:n})=>({width:"25px",height:"25px",borderRadius:"50%",color:n.palette.common.white,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"bold",...e})),Pr=({style:e,children:n,type:s})=>{const r=$(),a={backgroundColor:r.palette.background.alternative,color:r.palette.common.white};return s==="secondary"&&(a.backgroundColor=r.palette.background.paper,a.color=r.palette.text.secondary),t.jsx(Ir,{style:{...a,...e},children:n})},we=({headerText:e,bodyText:n,sectionNumber:s})=>t.jsx(C,{sx:{display:"flex",alignItems:"flex-start",mt:2,flexDirection:"column"},children:t.jsxs(C,{sx:{display:"flex"},children:[t.jsx(C,{children:t.jsx(Pr,{children:s})}),t.jsxs(C,{sx:{ml:2,display:"flex",flexDirection:"column"},children:[t.jsx(R,{variant:"body1",sx:{fontWeight:"bold"},children:e}),t.jsx(v,{condition:!!n,show:t.jsx(R,{variant:"body1",sx:{mt:1},children:n})})]})]})}),Ot=()=>t.jsxs(C,{sx:{ml:4},children:[t.jsx(R,{variant:"body1",children:"Unleash playground is for helping you to understand how Unleash works, how feature flags are evaluated and for you to easily debug your feature flags."}),t.jsx(kn,{sx:{mt:2,mb:2}}),t.jsx(R,{variant:"body1",sx:{mb:1},children:"What you need to do is:"}),t.jsx(we,{headerText:`Select in which environment you want to test your
feature flag configuration`,bodyText:`You can also specify specific projects, or check
flags in all projects.`,sectionNumber:"1"}),t.jsx(we,{headerText:"Select a context field that you'd like to check",bodyText:"You can configure as many context fields as you want. You can also leave the context empty to test against an empty context.",sectionNumber:"2"}),t.jsx(we,{headerText:"Submit the form to try the configuration",bodyText:"The results of evaluating your feature flags will appear after you submit the form. Then view the results.",sectionNumber:"3"})]});var Ae={},Rr=fe;Object.defineProperty(Ae,"__esModule",{value:!0});var Bt=Ae.default=void 0,Fr=Rr(me()),$r=t,Or=(0,Fr.default)((0,$r.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"}),"Help");Bt=Ae.default=Or;const Br=f(ee)(({theme:e})=>({"& .MuiPaper-root":{borderRadius:e.shape.borderRadiusExtraLarge,border:`1px solid ${e.palette.divider}`,padding:e.spacing(8,4),maxWidth:"500px"}})),Dr=()=>{const[e,n]=m.useState(null),s=o=>n(o.currentTarget),r=()=>n(null),a=!!e;return t.jsxs(C,{children:[t.jsx(A,{onClick:s,"aria-label":"Open Playground guidance",children:t.jsx(Bt,{})}),t.jsxs(Br,{open:a,anchorEl:e,onClose:r,anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},sx:o=>({zIndex:o.zIndex.tooltip,background:"none"}),children:[t.jsx(A,{onClick:r,sx:{position:"absolute",right:25,top:15},children:t.jsx(En,{})}),t.jsx(Ot,{})]})]})},Dt=e=>m.createElement("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},m.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.84818 0.184159C8.56367 -0.0789547 8.1234 -0.0575747 7.86482 0.231912C7.60623 0.521399 7.62724 0.96937 7.91175 1.23248C9.48292 2.68551 10.6076 4.74934 10.6076 7C10.6076 9.25066 9.48292 11.3145 7.91175 12.7675C7.62724 13.0306 7.60623 13.4786 7.86482 13.7681C8.1234 14.0576 8.56367 14.079 8.84818 13.8158C10.6396 12.1592 11.9998 9.73702 11.9998 7C11.9998 4.26298 10.6396 1.84083 8.84818 0.184159ZM6.04105 2.23302C6.29109 1.93586 6.73054 1.90121 7.02259 2.15563C8.33146 3.29586 9.35426 5.02309 9.35426 6.99995C9.35426 8.97682 8.33145 10.7039 7.02259 11.8441C6.73054 12.0986 6.29109 12.0639 6.04105 11.7668C5.79101 11.4696 5.82506 11.0225 6.11711 10.768C7.19425 9.82969 7.96199 8.46967 7.96199 6.99995C7.96199 5.53021 7.19423 4.17007 6.11711 3.23173C5.82506 2.97731 5.79101 2.53017 6.04105 2.23302ZM6.56908 7.00015C6.56908 8.56492 5.3224 9.83342 3.78454 9.83342C2.24668 9.83342 1 8.56492 1 7.00015C1 5.43539 2.24668 4.16689 3.78454 4.16689C5.3224 4.16689 6.56908 5.43539 6.56908 7.00015Z",fill:"currentColor"})),Nt=e=>m.createElement("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},m.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.84835 0.184159C8.56384 -0.0789547 8.12358 -0.0575747 7.86499 0.231912C7.6064 0.521399 7.62741 0.96937 7.91192 1.23248C9.4831 2.68551 10.6078 4.74934 10.6078 7C10.6078 7.40738 10.5709 7.80863 10.5012 8.20125L11.6597 9.35972C11.8783 8.60937 12 7.81877 12 7C12 4.26298 10.6397 1.84083 8.84835 0.184159ZM9.35443 6.99995L9.35418 7.0542L7.63252 5.33255C7.30901 4.52372 6.76993 3.80029 6.11728 3.23173C5.82523 2.97731 5.79118 2.53017 6.04122 2.23302C6.29127 1.93586 6.73072 1.90121 7.02276 2.15563C8.33164 3.29586 9.35443 5.02309 9.35443 6.99995ZM7.57827 8.79752L6.48307 7.70233C6.17606 8.92745 5.08437 9.83342 3.78471 9.83342C2.24685 9.83342 1.00017 8.56492 1.00017 7.00015C1.00017 5.69492 1.8676 4.59583 3.04789 4.26714L0.458225 1.67748C0.172794 1.39205 0.178843 0.923223 0.471736 0.63033C0.764629 0.337437 1.23345 0.331388 1.51889 0.616819L13.2132 12.3111C13.4986 12.5965 13.4926 13.0654 13.1997 13.3583C12.9068 13.6511 12.4379 13.6572 12.1525 13.3718L10.556 11.7753C10.0694 12.539 9.48623 13.2259 8.84835 13.8158C8.56384 14.079 8.12358 14.0576 7.86499 13.7681C7.6064 13.4786 7.62741 13.0306 7.91192 12.7675C8.54021 12.1865 9.0971 11.5078 9.53922 10.7585L8.62356 9.84281C8.20906 10.6195 7.64861 11.2989 7.02276 11.8441C6.73072 12.0986 6.29127 12.0639 6.04122 11.7668C5.79118 11.4696 5.82523 11.0225 6.11728 10.768C6.73471 10.2302 7.25048 9.55374 7.57827 8.79752Z",fill:"currentColor"}));var We={},Nr=fe;Object.defineProperty(We,"__esModule",{value:!0});var Lt=We.default=void 0,Lr=Nr(me()),Ar=t,Wr=(0,Lr.default)((0,Ar.jsx)("path",{d:"M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"}),"WarningOutlined");Lt=We.default=Wr;const zr=e=>e==="unknown"||e==="unevaluated"?[ae,"info"]:e===!0?[Dt,"success"]:[Nt,"error"],At=({enabled:e,label:n,showIcon:s=!0})=>{const[r,a]=zr(e);return t.jsx(V,{color:a,icon:s?t.jsx(r,{"aria-hidden":!0,color:a,strokeWidth:"0.25"}):void 0,children:n})},K=({enabled:e,label:n,showIcon:s=!0})=>{const r=$();if(ht("flagOverviewRedesign"))return t.jsx(At,{enabled:e,label:n,showIcon:s});const o=t.jsx(v,{condition:e==="unknown"||e==="unevaluated",show:t.jsx(Lt,{color:"warning",fontSize:"inherit"}),elseShow:t.jsx(v,{condition:typeof e=="boolean"&&!!e,show:t.jsx(Dt,{"aria-hidden":!0,color:r.palette.success.main,strokeWidth:"0.25"}),elseShow:t.jsx(Nt,{"aria-hidden":!0,color:r.palette.error.main,strokeWidth:"0.25"})})});return t.jsx(v,{condition:e==="unknown"||e==="unevaluated",show:t.jsx(V,{icon:s?o:void 0,color:"warning",children:n}),elseShow:t.jsx(v,{condition:typeof e=="boolean"&&!!e,show:t.jsx(V,{color:"success",icon:s?o:void 0,children:n}),elseShow:t.jsx(V,{color:"error",icon:s?o:void 0,children:n})})})},Mr=f(C)(({theme:e})=>({display:"flex",alignItems:"center",padding:e.spacing(1,0,1,2)})),Ur=f(C)(()=>({marginRight:"auto"})),Wt=({feature:e})=>{const[n,s]=(()=>{var r;return e!=null&&e.isEnabled?[!0,"True"]:((r=e==null?void 0:e.strategies)==null?void 0:r.result)==="unknown"?["unknown","Unknown"]:[!1,"False"]})();return t.jsx(Mr,{children:t.jsx(Ur,{"data-loading":!0,children:t.jsx(K,{enabled:n,label:s,showIcon:n!=="unknown"})})})};function ze(e){return e===void 0?!0:Object.values(e).every(n=>n&&typeof n=="object"?ze(n):n===null)}const he=e=>{var n,s;return(s=(n=e.strategies)==null?void 0:n.data)==null?void 0:s.find(r=>!gt.includes(r.name))},zt=e=>{var n,s,r,a;return((s=(n=e.strategies)==null?void 0:n.data)==null?void 0:s.length)>0&&!((a=(r=e.strategies)==null?void 0:r.data)!=null&&a.find(o=>gt.includes(o.name)))},Hr=f("div")({display:"flex",justifyContent:"space-between",width:"100%"}),_r=f("div")(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:e.spacing(1.5),marginTop:e.spacing(1.5)})),rt=f("div")(({theme:e})=>({margin:e.spacing(1,0)})),Gr=f("div")(({theme:e})=>({margin:e.spacing(1,.5)})),qr=f(R)(({theme:e})=>({fontWeight:600,padding:e.spacing(.5)})),Vr=f(A)({textAlign:"right"}),Kr=({feature:e,input:n,onClose:s})=>{var l;const r=$(),[a,o,i]=e.isEnabled?[`This feature flag is True in ${n==null?void 0:n.environment} because `,"at least one strategy is True",r.palette.success.main]:e.hasUnsatisfiedDependency&&!e.isEnabledInCurrentEnvironment?[`This feature flag is False in ${n==null?void 0:n.environment} because `,"parent dependency is not satisfied and the environment is disabled",r.palette.error.main]:e.isEnabledInCurrentEnvironment?zt(e)?[`This feature flag is Unknown in ${n==null?void 0:n.environment} because `,"no strategies could be fully evaluated",r.palette.warning.main]:he(e)?[`This feature flag is Unknown in ${n==null?void 0:n.environment} because `,"not all strategies could be fully evaluated",r.palette.warning.main]:e.hasUnsatisfiedDependency?[`This feature flag is False in ${n==null?void 0:n.environment} because `,"parent dependency is not satisfied",r.palette.error.main]:[`This feature flag is False in ${n==null?void 0:n.environment} because `,"all strategies are either False or could not be fully evaluated",r.palette.error.main]:[`This feature flag is False in ${n==null?void 0:n.environment} because `,"the environment is disabled",r.palette.error.main],c=ze(n==null?void 0:n.context)?"You did not provide a value for your context field in step 2 of the configuration":void 0,d=he(e)?"This feature uses custom strategies. Custom strategies can't be evaluated, so they will be marked accordingly.":void 0,g=s&&(x=>{x.stopPropagation(),s()});return t.jsxs(t.Fragment,{children:[t.jsxs(Hr,{children:[t.jsxs(_r,{children:[t.jsx(qr,{variant:"subtitle1",children:e.name}),t.jsx(v,{condition:((l=e==null?void 0:e.strategies)==null?void 0:l.result)!=="unknown",show:()=>t.jsx(K,{enabled:e.isEnabled,label:e.isEnabled?"True":"False"}),elseShow:()=>t.jsx(K,{enabled:"unknown",label:"Unknown",showIcon:!1})})]}),t.jsx(Vr,{onClick:g,children:t.jsx(xt,{})})]}),t.jsxs(Gr,{children:[t.jsx(R,{variant:"body1",component:"span",children:a}),t.jsx(R,{variant:"subtitle1",color:i,component:"span",children:o}),t.jsx(R,{variant:"body1",component:"span",children:"."})]}),t.jsx(v,{condition:!!c,show:t.jsx(rt,{children:t.jsx(U,{color:"info",children:c})})}),t.jsx(v,{condition:!!d,show:t.jsx(rt,{children:t.jsx(U,{severity:"warning",color:"info",children:d})})})]})};var Me={},Jr=fe;Object.defineProperty(Me,"__esModule",{value:!0});var oe=Me.default=void 0,Yr=Jr(me()),Zr=t,Qr=(0,Yr.default)((0,Zr.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 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 8zm3.59-13L12 10.59 8.41 7 7 8.41 10.59 12 7 15.59 8.41 17 12 13.41 15.59 17 17 15.59 13.41 12 17 8.41z"}),"CancelOutlined");oe=Me.default=Qr;const Xr=f("div")(({theme:e})=>({display:"flex",alignItems:"center",marginTop:e.spacing(1),color:e.palette.error.main})),ea=({constraint:e,input:n})=>{const s=()=>{const r=n==null?void 0:n.context[e.contextName];return r?`Constraint not met – the value in the context: { ${r} } is not ${e.operator} ${e.contextName}`:`Constraint not met – no value was specified for ${e.contextName}`};return t.jsxs(Xr,{children:[t.jsx(oe,{style:{marginRight:"0.25rem"}}),t.jsx(R,{variant:"body2",children:s()})]})},ta=f(Tn)(({theme:e})=>({color:e.palette.success.main})),na=f("div")(({theme:e})=>({display:"flex",alignItems:"center",marginTop:e.spacing(1),color:e.palette.success.main})),sa=()=>t.jsxs(na,{children:[t.jsx(ta,{style:{marginRight:"0.25rem"}}),t.jsx(R,{variant:"body2",children:"Constraint met by value in context"})]}),ra=f("div")(()=>({width:"100%",display:"flex",flexDirection:"column"})),Mt=({constraints:e,input:n})=>e?t.jsx(ra,{children:e==null?void 0:e.map((s,r)=>t.jsxs(m.Fragment,{children:[t.jsx(v,{condition:r>0,show:t.jsx(J,{text:"AND"})}),t.jsx(mt,{constraint:s,compact:!0,renderAfter:t.jsx(v,{condition:s.result,show:t.jsx(sa,{}),elseShow:t.jsx(ea,{input:n,constraint:s})})})]},Z(s)))}):null,aa=f("div")(({theme:e})=>({color:e.palette.error.main,display:"inline-flex",justifyContent:"center",marginLeft:"auto",gap:e.spacing(1)})),oa=({segments:e,input:n})=>e?t.jsx(t.Fragment,{children:e.map((s,r)=>t.jsxs(m.Fragment,{children:[t.jsx(ft,{segment:s,constraintList:t.jsx(Mt,{constraints:s.constraints,input:n}),headerContent:t.jsx(v,{condition:!s.result,show:t.jsxs(aa,{children:[t.jsx(R,{variant:"subtitle2",sx:{pt:.25},children:"segment is false"}),t.jsx("span",{children:t.jsx(oe,{})})]}),elseShow:void 0}),isExpanded:!0}),t.jsx(v,{condition:r>=0&&e.length>1&&r!==e.length-1,show:t.jsx(J,{text:"AND"})})]},s.id))}):null,ia=f("div",{shouldForwardProp:e=>e!=="showReason"})(({theme:e,showReason:n})=>({width:"100%",padding:e.spacing(2,3),borderRadius:e.shape.borderRadiusMedium,border:`1px solid ${e.palette.divider}`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:e.spacing(2),opacity:n?.9:1,backgroundColor:n?e.palette.background.paper:"inherit"})),la=f("div")(({theme:e})=>({flexDirection:"column"})),ca=f(ut)(({theme:e})=>({margin:e.spacing(.5)})),da=f("p",{shouldForwardProp:e=>e!=="disabled"})(({theme:e,disabled:n})=>({display:"inline",margin:e.spacing(.5,0),maxWidth:"95%",textAlign:"center",wordBreak:"break-word",color:n?e.palette.text.secondary:"inherit"})),ke=({value:e,text:n,input:s,showReason:r=!1,disabled:a=!1})=>{const o=$(),i=s==="no value"&&!a?"error":"neutral",c=`value does not match any ${n}`;return t.jsxs(ia,{showReason:r,children:[t.jsx(R,{variant:"subtitle1",color:o.palette[i].main,children:`${s}`}),t.jsxs(la,{children:[t.jsx(v,{condition:!!r,show:t.jsx(R,{variant:"subtitle1",color:a?o.palette.text.secondary:o.palette.error.main,children:c})}),t.jsx(v,{condition:e.length===0,show:t.jsxs("p",{children:["No ",n,"s added yet."]}),elseShow:t.jsxs("div",{children:[t.jsxs(da,{disabled:a,children:[e.length," ",e.length>1?`${n}s`:n," will get access."]}),e.map(d=>t.jsx(ca,{disabled:a,label:t.jsx(Te,{maxWidth:"300",text:d.toString(),maxLength:50})},d))]})})]}),t.jsx(v,{condition:!!r,show:t.jsx(oe,{color:a?"disabled":"error"}),elseShow:t.jsx("div",{})})]})},je=f(C)(({theme:e})=>({width:"auto",height:"auto",padding:e.spacing(2,3),borderRadius:e.shape.borderRadiusMedium,border:`1px solid ${e.palette.divider}`})),G=e=>{switch(e.toUpperCase()){case"USERIDS":return"userId";case"IPS":return"remoteAddress";default:return e}},ua=({percentage:e,size:n="4rem"})=>{const s=$(),r={display:"block",borderRadius:"100%",transform:"rotate(-90deg)",height:n,width:n,background:s.palette.background.elevation2},a=100/(2*Math.PI),o=2*a;return t.jsxs("svg",{viewBox:`0 0 ${o} ${o}`,style:r,"aria-hidden":!0,children:[t.jsxs("title",{children:["A circle progress bar with ",e,"% completion."]}),t.jsx("circle",{r:a,cx:a,cy:a,fill:"none",stroke:s.palette.neutral.border,strokeWidth:o,strokeDasharray:`${e} 100`})]})},ha=f("div",{shouldForwardProp:e=>e!=="disabled"})(({theme:e,disabled:n})=>({color:n?e.palette.text.secondary:e.palette.neutral.main})),Ut=({parameters:e,constraints:n,input:s,disabled:r=!1})=>{const a=e==null?void 0:e.stickiness,o=typeof a=="string"&&a!=="default";return t.jsx(t.Fragment,{children:Object.keys(e).map(i=>{var c,d,g,l,x,h,p,S;switch(i){case"rollout":case"Rollout":{const T=Ie(e[i]);return t.jsxs(je,{sx:{display:"flex",alignItems:"center"},children:[t.jsx(C,{sx:P=>({mr:"1rem",color:r?P.palette.neutral.border:P.palette.text.secondary}),children:t.jsx(v,{condition:r,show:t.jsx(ua,{percentage:T,size:"2rem"}),elseShow:t.jsx(In,{percentage:T,size:"2rem"})})}),t.jsxs(ha,{disabled:r,children:[t.jsxs(V,{color:r?"disabled":"success",children:[T,"%"]})," ","of your base"," ",t.jsxs("span",{children:[o?t.jsxs(t.Fragment,{children:["with"," ",t.jsx("strong",{children:a})]}):""," "]}),n.length>0?"who match constraints":""," ","is included."]})]},i)}case"userIds":case"UserIds":{const T=ce(e[i]);return t.jsx(ke,{value:T,text:"user",input:(c=s==null?void 0:s.context)!=null&&c[G(i)]?(d=s==null?void 0:s.context)==null?void 0:d[G(i)]:"no value",showReason:(g=s==null?void 0:s.context)!=null&&g[G(i)]?!T.includes((l=s==null?void 0:s.context)==null?void 0:l[G(i)]):void 0},i)}case"hostNames":case"HostNames":{const T=ce(e[i]);return t.jsx(ke,{value:T,text:"host",input:"no value",showReason:void 0,disabled:r},i)}case"IPs":{const T=ce(e[i]);return t.jsx(ke,{value:T,text:"IP",disabled:r,input:(x=s==null?void 0:s.context)!=null&&x[G(i)]?(h=s==null?void 0:s.context)==null?void 0:h[G(i)]:"no value",showReason:(p=s==null?void 0:s.context)!=null&&p[G(i)]?!T.includes((S=s==null?void 0:s.context)==null?void 0:S[G(i)]):void 0},i)}case"stickiness":case"groupId":return null;default:return null}})})},ga=f(C)(({theme:e})=>({width:"100%",padding:e.spacing(2,3),borderRadius:e.shape.borderRadiusMedium,border:`1px solid ${e.palette.divider}`,display:"flex",flexDirection:"row",alignItems:"center",gap:2})),se=({text:e,input:n=null,isRequired:s=!1})=>{const r=$(),a=n===null?"error":"neutral",o=s&&n===null;return t.jsxs(ga,{children:[t.jsx(R,{variant:"subtitle1",color:r.palette[a].main,sx:{minWidth:118},children:`${n===null?"no value":n}`}),t.jsx(C,{sx:{flexGrow:1,flexDirection:"column"},children:t.jsx(C,{sx:{flexGrow:1},children:t.jsx(v,{condition:!!o,show:t.jsxs(t.Fragment,{children:[t.jsx(R,{component:"span",color:r.palette.error.main,children:" required parameter "}),t.jsx(Te,{maxWidth:"300",text:e,maxLength:50}),t.jsx(R,{component:"span",color:r.palette.error.main,children:" is not set "})]}),elseShow:t.jsxs(t.Fragment,{children:[t.jsx(R,{component:"span",color:"text.disabled",children:" set on parameter "}),t.jsx(Te,{maxWidth:"300",text:e,maxLength:50})]})})})}),t.jsx(v,{condition:!!o,show:t.jsx(oe,{color:"error"}),elseShow:t.jsx("div",{})})]})},Ht=({strategyName:e,parameters:n})=>{const{strategies:s}=pt(),r=s.find(o=>o.name===e);if(!(r!=null&&r.editable))return null;const a=r==null?void 0:r.parameters.map(o=>{const i=n[o.name],c=o.required;switch(o==null?void 0:o.type){case"list":{const d=ce(i);return t.jsx(se,{isRequired:c,text:o.name,input:(d==null?void 0:d.length)>0?d.join(", "):null})}case"percentage":{const d=Ie(i),g=!(i===void 0||i===""||d<0||d>100);return t.jsx(se,{text:o.name,isRequired:c,input:g?`${d}%`:void 0})}case"boolean":{const d=["true","false"].includes(i)?i:void 0;return t.jsx(se,{isRequired:c,text:o.name,input:i!==void 0?d:void 0})}case"string":{const d=Pn(i);return t.jsx(se,{text:o.name,isRequired:c,input:d!==void 0?d:void 0})}case"number":{const d=!(i===void 0||i===""),g=Ie(i);return t.jsx(se,{text:o.name,isRequired:c,input:d?`${g}`:void 0})}case"default":return null}return null});return t.jsx(t.Fragment,{children:a.map((o,i)=>t.jsxs(m.Fragment,{children:[t.jsx(v,{condition:i>0,show:t.jsx(J,{text:"AND"})}),o]},i))})},xa=f("div")(({theme:e})=>({padding:e.spacing(0)})),ma=({strategyResult:e,input:n})=>{const{name:s,constraints:r,segments:a,parameters:o}=e,i=!!(a&&a.length>0),c=!!(r&&(r==null?void 0:r.length)>0),d=s!=="default"&&Object.keys($e).includes(s),g=Object.keys(o).length>0&&e.result.evaluationStatus==="incomplete";if(!o)return null;const l=[i&&t.jsx(oa,{segments:a,input:n}),c&&t.jsx(Mt,{constraints:r,input:n}),d&&t.jsx(Ut,{parameters:o,constraints:r,input:n}),g&&t.jsx(Ht,{strategyName:s,parameters:o}),s==="default"&&t.jsxs(je,{sx:{width:"100%"},children:["The standard strategy is ",t.jsx(V,{color:"success",children:"ON"})," for all users."]})].filter(Boolean);return t.jsx(xa,{children:l.map((x,h)=>t.jsxs(m.Fragment,{children:[t.jsx(v,{condition:h>0&&(e.name==="flexibleRollout"?h<l.length:h<l.length-1),show:t.jsx(J,{text:"AND"})}),x]},h))})},fa=f("div")(()=>({width:"100%",display:"flex",flexDirection:"column"})),_t=({constraints:e})=>e?t.jsx(fa,{children:e==null?void 0:e.map((n,s)=>t.jsxs(m.Fragment,{children:[t.jsx(v,{condition:s>0,show:t.jsx(J,{text:"AND"})}),t.jsx(mt,{constraint:n,compact:!0,disabled:!0})]},Z(n)))}):null,pa=({segments:e})=>e?t.jsx(t.Fragment,{children:e.map((n,s)=>t.jsxs(m.Fragment,{children:[t.jsx(ft,{segment:n,constraintList:t.jsx(_t,{constraints:n.constraints}),isExpanded:!0,disabled:!0}),t.jsx(v,{condition:s>=0&&e.length>1&&s!==e.length-1,show:t.jsx(J,{text:"AND"})})]},n.id))}):null,ja=f("div")(({theme:e})=>({padding:e.spacing(0)})),ba=({strategyResult:e,input:n,percentageFill:s})=>{const{name:r,constraints:a,segments:o,parameters:i}=e,c=!!(o&&o.length>0),d=!!(a&&(a==null?void 0:a.length)>0),g=r!=="default"&&Object.keys($e).includes(r),l=Object.keys(i).length>0&&e.result.evaluationStatus==="incomplete";if(!i)return null;const x=[c&&t.jsx(pa,{segments:o}),d&&t.jsx(_t,{constraints:a}),g&&t.jsx(Ut,{parameters:i,constraints:a,input:n,disabled:!0}),l&&t.jsx(Ht,{strategyName:r,parameters:i}),r==="default"&&t.jsxs(je,{sx:h=>({width:"100%",color:h.palette.text.secondary}),children:["The standard strategy is ",t.jsx(V,{color:"disabled",children:"ON"})," ","for all users."]})].filter(Boolean);return t.jsx(ja,{children:x.map((h,p)=>t.jsxs(m.Fragment,{children:[t.jsx(v,{condition:p>0&&(e.name==="flexibleRollout"?p<x.length:p<x.length-1),show:t.jsx(J,{text:"AND"})}),h]},p))})},ya=({strategy:e,input:n,index:s})=>{const{result:r}=e,a=$(),o=r.evaluationStatus==="incomplete"||r.evaluationStatus==="unevaluated"?"Unevaluated":r.enabled?"True":"False";return t.jsx(Os,{style:{borderColor:r.enabled&&r.evaluationStatus==="complete"?a.palette.success.main:"none"},strategy:{...e,id:`${Z(e)}`},orderNumber:s+1,actions:t.jsx(K,{showIcon:!1,enabled:r.enabled,label:o}),children:t.jsx(v,{condition:!!e.disabled,show:t.jsx(ba,{strategyResult:e,input:n}),elseShow:t.jsx(ma,{strategyResult:e,input:n,percentageFill:a.palette.background.elevation2})})})},va=f("div")(({theme:e})=>({display:"flex",padding:"0, 4px",flexDirection:"column",borderRadius:e.shape.borderRadiusMedium,border:`1px solid ${e.palette.warning.border}`})),at=f("div")(({theme:e})=>({padding:e.spacing(1,.5)})),Sa=f(U)(({theme:e})=>({border:"0!important",borderBottomLeftRadius:0,borderBottomRightRadius:0,borderBottom:`1px solid ${e.palette.warning.border}!important`})),ot=f(R)(({theme:e})=>({margin:e.spacing(2,1,2,0),color:"text.secondary"})),ge=({strategies:e,input:n,titlePrefix:s,infoText:r})=>t.jsx(v,{condition:e.length>0,show:t.jsxs(t.Fragment,{children:[t.jsx(ot,{variant:"subtitle1",children:`${s?s.concat(" strategies"):"Strategies"} (${e==null?void 0:e.length})`}),t.jsx(v,{condition:!!r,show:t.jsx(ot,{variant:"subtitle2",children:r})}),t.jsx(C,{sx:{width:"100%"},children:e==null?void 0:e.map((a,o)=>t.jsxs(m.Fragment,{children:[t.jsx(v,{condition:o>0,show:t.jsx(J,{text:"OR"})}),t.jsx(ya,{strategy:a,index:o,input:n},a.id)]},a.id))})]})}),Ca=e=>e.hasUnsatisfiedDependency&&!e.isEnabledInCurrentEnvironment?"If the environment was enabled and parent dependencies were satisfied":e.hasUnsatisfiedDependency?"If parent dependencies were satisfied":e.isEnabledInCurrentEnvironment?"":"If the environment was enabled",wa=({feature:e,input:n})=>{var o,i,c,d,g;const s=(i=(o=e.strategies)==null?void 0:o.data)==null?void 0:i.filter(l=>!l.disabled),r=(d=(c=e.strategies)==null?void 0:c.data)==null?void 0:d.filter(l=>l.disabled),a=(r==null?void 0:r.length)>0;return t.jsxs(va,{sx:{pb:1,mt:2},children:[t.jsxs(Sa,{severity:"info",color:"warning",children:[Ca(e),", then this feature flag would be"," ",(g=e.strategies)!=null&&g.result?"TRUE":"FALSE"," with strategies evaluated like this:"," "]}),t.jsx(at,{sx:{p:2.5},children:t.jsx(ge,{strategies:s||[],input:n,titlePrefix:a?"Enabled":""})}),t.jsx(v,{condition:a,show:t.jsx(at,{sx:{p:2.5},children:t.jsx(ge,{strategies:r,input:n,titlePrefix:"Disabled",infoText:"Disabled strategies are not evaluated for the overall result."})})})]})},ka=({feature:e,input:n})=>{var o,i,c,d,g,l,x;const s=(i=(o=e.strategies)==null?void 0:o.data)==null?void 0:i.filter(h=>!h.disabled),r=(d=(c=e.strategies)==null?void 0:c.data)==null?void 0:d.filter(h=>h.disabled),a=(r==null?void 0:r.length)>0;return t.jsxs(t.Fragment,{children:[t.jsx(v,{condition:((l=(g=e==null?void 0:e.strategies)==null?void 0:g.data)==null?void 0:l.length)===0,show:t.jsx(U,{severity:"warning",sx:{mt:2},children:"There are no strategies added to this feature flag in selected environment."})}),t.jsx(v,{condition:(e.hasUnsatisfiedDependency||!e.isEnabledInCurrentEnvironment)&&!!((x=e==null?void 0:e.strategies)!=null&&x.data),show:t.jsx(wa,{feature:e,input:n}),elseShow:t.jsxs(t.Fragment,{children:[t.jsx(ge,{strategies:s||[],input:n,titlePrefix:a?"Enabled":""}),t.jsx(v,{condition:a,show:t.jsx(ge,{strategies:r,input:n,titlePrefix:"Disabled",infoText:"Disabled strategies are not evaluated for the overall result."})})]})})]})},Ea=f("div")({display:"flex",justifyContent:"space-between",width:"100%"}),Ta=f("hgroup")(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:e.spacing(1.5)})),Ia=f("h3")(({theme:e})=>({fontWeight:"bold",fontSize:e.typography.subtitle1.fontSize,margin:0})),Pa=({feature:e,input:n,onClose:s})=>{var l;const r=$(),[a,o,i]=e.isEnabled?[`This feature flag is True in ${n==null?void 0:n.environment} because `,"at least one strategy is True",r.palette.success.contrastText]:e.hasUnsatisfiedDependency&&!e.isEnabledInCurrentEnvironment?[`This feature flag is False in ${n==null?void 0:n.environment} because `,"parent dependency is not satisfied and the environment is disabled",r.palette.error.contrastText]:e.isEnabledInCurrentEnvironment?zt(e)?[`This feature flag is Unknown in ${n==null?void 0:n.environment} because `,"no strategies could be fully evaluated",r.palette.warning.contrastText]:he(e)?[`This feature flag is Unknown in ${n==null?void 0:n.environment} because `,"not all strategies could be fully evaluated",r.palette.warning.contrastText]:e.hasUnsatisfiedDependency?[`This feature flag is False in ${n==null?void 0:n.environment} because `,"parent dependency is not satisfied",r.palette.error.contrastText]:[`This feature flag is False in ${n==null?void 0:n.environment} because `,"all strategies are either False or could not be fully evaluated",r.palette.error.contrastText]:[`This feature flag is False in ${n==null?void 0:n.environment} because `,"the environment is disabled",r.palette.error.contrastText],c=ze(n==null?void 0:n.context)?"You did not provide a value for your context field in step 2 of the configuration":void 0,d=he(e)?"This feature uses custom strategies. Custom strategies can't be evaluated, so they will be marked accordingly.":void 0,g=s&&(x=>{x.stopPropagation(),s()});return t.jsxs(t.Fragment,{children:[t.jsxs(Ea,{children:[t.jsxs(Ta,{children:[t.jsx(Ia,{children:e.name}),t.jsx("p",{children:((l=e==null?void 0:e.strategies)==null?void 0:l.result)!=="unknown"?t.jsx(K,{enabled:e.isEnabled,label:e.isEnabled?"True":"False"}):t.jsx(K,{enabled:"unknown",label:"Unknown",showIcon:!1})})]}),t.jsx(A,{"aria-label":"Close",onClick:g,children:t.jsx(xt,{})})]}),t.jsxs("p",{children:[a,t.jsx(R,{color:i,component:"span",children:o}),"."]}),c?t.jsx(U,{color:"info",children:c}):null,d?t.jsx(U,{severity:"warning",color:"info",children:d}):null]})},Gt=f("div",{shouldForwardProp:e