unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
3 lines • 54 kB
JavaScript
import{u as Tt,g as It,r as m,_ as Pt,j as t,a as ve,U as Rt,b as N,B as w,C as F,s as E,d as Ot,c as Lt,e as Bt,f as Ve,h as ee,T as D,G as Ft,i as le,p as Ie,k as Pe,l as ae,A as qe,m as Nt,n as At,o as $t,q as Dt,t as Mt,v as Ht,w as Re,P as Wt,I as Oe,x as q,L as zt,y as Ut,z as _t,D as Gt,E as Ke,F as Je,H as Vt,J as ne,K as Ye,M as ce,N as Ze,O as qt,Q as te,R as be,S as Kt,V as Jt,W as Yt,X as Qe,Y as oe,Z as Zt,$ as Qt,a0 as Xt,a1 as en,a2 as tn,a3 as nn,a4 as rn,a5 as an,a6 as sn,a7 as on,a8 as ln,a9 as O,aa as de,ab as cn,ac as dn,ad as un,ae as hn,af as gn,ag as fn,ah as Le,ai as Xe,aj as je,ak as Ce,al as et,am as Se,an as tt,ao as nt,ap as rt,aq as mn,ar as Be,as as pn,at as xn,au as bn,av as he,aw as at,ax as yn,ay as vn,az as jn,aA as Cn,aB as Sn,aC as kn}from"./index-Cikp5fMR.js";import{c as wn,d as En,s as Tn,h as In,f as Pn,a as Rn,l as On,b as Ln,e as Bn,g as Fn,i as Nn,j as An,k as $n,m as Dn,E as ie,n as Mn,o as ke,p as Hn,q as Wn,r as zn,t as Un,u as _n,v as Gn,w as Vn,x as qn,y as st,z as Kn,A as V,H as ot,B as o,C as Jn,D as Yn,S as Zn,F as Qn,G as Xn}from"./index-B87DWXbl.js";import{u as er}from"./useApiTokens-BHKIbW5c.js";const tr=()=>{const{makeRequest:e,createRequest:n,errors:r,loading:a}=Tt({propagateErrors:!0}),s="api/admin/playground";return{evaluateAdvancedPlayground:async i=>{const h=`${s}/advanced`,u=n(h,{method:"POST",body:JSON.stringify(i)});return(await e(u.caller,u.id)).json()},evaluateChangeRequestPlayground:async(i,h)=>{const u=`${s}/change-request/${i}`,c=n(u,{method:"POST",body:JSON.stringify(h)});return(await e(c.caller,c.id)).json()},errors:r,loading:a}};var we={exports:{}};function it(e,n=100,r={}){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:a}=typeof r=="boolean"?{immediate:r}:r;let s,l,d,i,h;function u(){const f=s,b=l;return s=void 0,l=void 0,h=e.apply(f,b),h}function c(){const f=Date.now()-i;f<n&&f>=0?d=setTimeout(c,n-f):(d=void 0,a||(h=u()))}const g=function(...f){if(s&&this!==s&&Object.getPrototypeOf(this)===Object.getPrototypeOf(s))throw new Error("Debounced method called with different contexts of the same prototype.");s=this,l=f,i=Date.now();const b=a&&!d;return d||(d=setTimeout(c,n)),b&&(h=u()),h};return Object.defineProperty(g,"isPending",{get(){return d!==void 0}}),g.clear=()=>{d&&(clearTimeout(d),d=void 0)},g.flush=()=>{d&&g.trigger()},g.trigger=()=>{h=u(),g.clear()},g}we.exports.debounce=it;we.exports=it;var nr=we.exports;const rr=It(nr);var Fe=function(n){n===void 0&&(n={});var{crosshairCursor:r=!1}=n,a=[];n.closeBracketsKeymap!==!1&&(a=a.concat(wn)),n.defaultKeymap!==!1&&(a=a.concat(En)),n.searchKeymap!==!1&&(a=a.concat(Tn)),n.historyKeymap!==!1&&(a=a.concat(In)),n.foldKeymap!==!1&&(a=a.concat(Pn)),n.completionKeymap!==!1&&(a=a.concat(Rn)),n.lintKeymap!==!1&&(a=a.concat(On));var s=[];return n.lineNumbers!==!1&&s.push(Ln()),n.highlightActiveLineGutter!==!1&&s.push(Bn()),n.highlightSpecialChars!==!1&&s.push(Fn()),n.history!==!1&&s.push(Nn()),n.foldGutter!==!1&&s.push(An()),n.drawSelection!==!1&&s.push($n()),n.dropCursor!==!1&&s.push(Dn()),n.allowMultipleSelections!==!1&&s.push(ie.allowMultipleSelections.of(!0)),n.indentOnInput!==!1&&s.push(Mn()),n.syntaxHighlighting!==!1&&s.push(ke(Kn,{fallback:!0})),n.bracketMatching!==!1&&s.push(Hn()),n.closeBrackets!==!1&&s.push(Wn()),n.autocompletion!==!1&&s.push(zn()),n.rectangularSelection!==!1&&s.push(Un()),r!==!1&&s.push(_n()),n.highlightActiveLine!==!1&&s.push(Gn()),n.highlightSelectionMatches!==!1&&s.push(Vn()),n.tabSize&&typeof n.tabSize=="number"&&s.push(qn.of(" ".repeat(n.tabSize))),s.concat([st.of(a.flat())]).filter(Boolean)};const ar="#e5c07b",Ne="#e06c75",sr="#56b6c2",or="#ffffff",se="#abb2bf",ye="#7d8799",ir="#61afef",lr="#98c379",Ae="#d19a66",cr="#c678dd",dr="#21252b",$e="#2c313a",De="#282c34",ge="#353a42",ur="#3E4451",Me="#528bff",hr=V.theme({"&":{color:se,backgroundColor:De},".cm-content":{caretColor:Me},".cm-cursor, .cm-dropCursor":{borderLeftColor:Me},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ur},".cm-panels":{backgroundColor:dr,color:se},".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:De,color:ye,border:"none"},".cm-activeLineGutter":{backgroundColor:$e},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:ge},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:ge,borderBottomColor:ge},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:$e,color:se}}},{dark:!0}),gr=ot.define([{tag:o.keyword,color:cr},{tag:[o.name,o.deleted,o.character,o.propertyName,o.macroName],color:Ne},{tag:[o.function(o.variableName),o.labelName],color:ir},{tag:[o.color,o.constant(o.name),o.standard(o.name)],color:Ae},{tag:[o.definition(o.name),o.separator],color:se},{tag:[o.typeName,o.className,o.number,o.changed,o.annotation,o.modifier,o.self,o.namespace],color:ar},{tag:[o.operator,o.operatorKeyword,o.url,o.escape,o.regexp,o.link,o.special(o.string)],color:sr},{tag:[o.meta,o.comment],color:ye},{tag:o.strong,fontWeight:"bold"},{tag:o.emphasis,fontStyle:"italic"},{tag:o.strikethrough,textDecoration:"line-through"},{tag:o.link,color:ye,textDecoration:"underline"},{tag:o.heading,fontWeight:"bold",color:Ne},{tag:[o.atom,o.bool,o.special(o.variableName)],color:Ae},{tag:[o.processingInstruction,o.string,o.inserted],color:lr},{tag:o.invalid,color:or}]),fr=[hr,ke(gr)];var mr=V.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),pr=function(n){n===void 0&&(n={});var{indentWithTab:r=!0,editable:a=!0,readOnly:s=!1,theme:l="light",placeholder:d="",basicSetup:i=!0}=n,h=[];switch(r&&h.unshift(st.of([Jn])),i&&(typeof i=="boolean"?h.unshift(Fe()):h.unshift(Fe(i))),d&&h.unshift(Yn(d)),l){case"light":h.push(mr);break;case"dark":h.push(fr);break;case"none":break;default:h.push(l);break}return a===!1&&h.push(V.editable.of(!1)),s&&h.push(ie.readOnly.of(!0)),[...h]},xr=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)});class br{constructor(n,r){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=r,this.timeoutMS=r,this.callbacks.push(n)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var n=this.callbacks.slice();this.callbacks.length=0,n.forEach(r=>{try{r()}catch(a){console.error("TimeoutLatch callback error:",a)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class He{constructor(){this.interval=null,this.latches=new Set}add(n){this.latches.add(n),this.start()}remove(n){this.latches.delete(n),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(n=>{n.tick(),n.isDone&&this.remove(n)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var fe=null,yr=()=>typeof window>"u"?new He:(fe||(fe=new He),fe),We=Qn.define(),vr=200,jr=[];function Cr(e){var{value:n,selection:r,onChange:a,onStatistics:s,onCreateEditor:l,onUpdate:d,extensions:i=jr,autoFocus:h,theme:u="light",height:c=null,minHeight:g=null,maxHeight:f=null,width:b=null,minWidth:T=null,maxWidth:I=null,placeholder:S="",editable:P=!0,readOnly:A=!1,indentWithTab:R=!0,basicSetup:p=!0,root:k,initialState:v}=e,[x,j]=m.useState(),[y,L]=m.useState(),[U,_]=m.useState(),B=m.useState(()=>({current:null}))[0],H=m.useState(()=>({current:null}))[0],Z=V.theme({"&":{height:c,minHeight:g,maxHeight:f,width:b,minWidth:T,maxWidth:I},"& .cm-scroller":{height:"100% !important"}}),Q=V.updateListener.of($=>{if($.docChanged&&typeof a=="function"&&!$.transactions.some(X=>X.annotation(We))){B.current?B.current.reset():(B.current=new br(()=>{if(H.current){var X=H.current;H.current=null,X()}B.current=null},vr),yr().add(B.current));var M=$.state.doc,W=M.toString();a(W,$)}s&&s(xr($))}),J=pr({theme:u,editable:P,readOnly:A,placeholder:S,indentWithTab:R,basicSetup:p}),K=[Q,Z,...J];return d&&typeof d=="function"&&K.push(V.updateListener.of(d)),K=K.concat(i),m.useLayoutEffect(()=>{if(x&&!U){var $={doc:n,selection:r,extensions:K},M=v?ie.fromJSON(v.json,$,v.fields):ie.create($);if(_(M),!y){var W=new V({state:M,parent:x,root:k});L(W),l&&l(W,M)}}return()=>{y&&(_(void 0),L(void 0))}},[x,U]),m.useEffect(()=>{e.container&&j(e.container)},[e.container]),m.useEffect(()=>()=>{y&&(y.destroy(),L(void 0)),B.current&&(B.current.cancel(),B.current=null)},[y]),m.useEffect(()=>{h&&y&&y.focus()},[h,y]),m.useEffect(()=>{y&&y.dispatch({effects:Zn.reconfigure.of(K)})},[u,i,c,g,f,b,T,I,S,P,A,R,p,a,d]),m.useEffect(()=>{if(n!==void 0){var $=y?y.state.doc.toString():"";if(y&&n!==$){var M=B.current&&!B.current.isDone,W=()=>{y&&n!==y.state.doc.toString()&&y.dispatch({changes:{from:0,to:y.state.doc.toString().length,insert:n||""},annotations:[We.of(!0)]})};M?H.current=W:W()}}},[n,y]),{state:U,setState:_,view:y,setView:L,container:x,setContainer:j}}var Sr=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],lt=m.forwardRef((e,n)=>{var{className:r,value:a="",selection:s,extensions:l=[],onChange:d,onStatistics:i,onCreateEditor:h,onUpdate:u,autoFocus:c,theme:g="light",height:f,minHeight:b,maxHeight:T,width:I,minWidth:S,maxWidth:P,basicSetup:A,placeholder:R,indentWithTab:p,editable:k,readOnly:v,root:x,initialState:j}=e,y=Pt(e,Sr),L=m.useRef(null),{state:U,view:_,container:B,setContainer:H}=Cr({root:x,value:a,autoFocus:c,theme:g,height:f,minHeight:b,maxHeight:T,width:I,minWidth:S,maxWidth:P,basicSetup:A,placeholder:R,indentWithTab:p,editable:k,readOnly:v,selection:s,onChange:d,onStatistics:i,onCreateEditor:h,onUpdate:u,extensions:l,initialState:j});m.useImperativeHandle(n,()=>({editor:L.current,state:U,view:_}),[L,B,U,_]);var Z=m.useCallback(J=>{L.current=J,H(J)},[H]);if(typeof a!="string")throw new Error("value must be typeof string but got "+typeof a);var Q=typeof g=="string"?"cm-theme-"+g:"cm-theme";return t.jsx("div",ve({ref:Z,className:""+Q+(r?" "+r:"")},y))});lt.displayName="CodeMirror";var ct=e=>{var{theme:n,settings:r={},styles:a=[]}=e,s={".cm-gutters":{}},l={};r.background&&(l.backgroundColor=r.background),r.backgroundImage&&(l.backgroundImage=r.backgroundImage),r.foreground&&(l.color=r.foreground),r.fontSize&&(l.fontSize=r.fontSize),(r.background||r.foreground)&&(s["&"]=l),r.fontFamily&&(s["&.cm-editor .cm-scroller"]={fontFamily:r.fontFamily}),r.gutterBackground&&(s[".cm-gutters"].backgroundColor=r.gutterBackground),r.gutterForeground&&(s[".cm-gutters"].color=r.gutterForeground),r.gutterBorder&&(s[".cm-gutters"].borderRightColor=r.gutterBorder),r.caret&&(s[".cm-content"]={caretColor:r.caret},s[".cm-cursor, .cm-dropCursor"]={borderLeftColor:r.caret});var d={};r.gutterActiveForeground&&(d.color=r.gutterActiveForeground),r.lineHighlight&&(s[".cm-activeLine"]={backgroundColor:r.lineHighlight},d.backgroundColor=r.lineHighlight),s[".cm-activeLineGutter"]=d,r.selection&&(s["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:r.selection+" !important"}),r.selectionMatch&&(s["& .cm-selectionMatch"]={backgroundColor:r.selectionMatch});var i=V.theme(s,{dark:n==="dark"}),h=ot.define(a),u=[i,ke(h)];return u},kr={background:"#faf8f5",foreground:"#b29762",caret:"#93abdc",selection:"#e3dcce",selectionMatch:"#e3dcce",gutterBackground:"#faf8f5",gutterForeground:"#cdc4b1",gutterBorder:"transparent",lineHighlight:"#ddceb154"},wr=[{tag:[o.comment,o.bracket],color:"#b6ad9a"},{tag:[o.atom,o.number,o.keyword,o.link,o.attributeName,o.quote],color:"#063289"},{tag:[o.emphasis,o.heading,o.tagName,o.propertyName,o.variableName],color:"#2d2006"},{tag:[o.typeName,o.url,o.string],color:"#896724"},{tag:[o.operator,o.string],color:"#1659df"},{tag:[o.propertyName],color:"#b29762"},{tag:[o.unit,o.punctuation],color:"#063289"}],Er=e=>{var{theme:n="light",settings:r={},styles:a=[]}={};return ct({theme:n,settings:ve({},kr,r),styles:[...wr,...a]})},Tr=Er(),Ir={background:"#2a2734",foreground:"#6c6783",caret:"#ffad5c",selection:"#91ff6c26",selectionMatch:"#91ff6c26",gutterBackground:"#2a2734",gutterForeground:"#545167",lineHighlight:"#36334280"},Pr=[{tag:[o.comment,o.bracket],color:"#6c6783"},{tag:[o.atom,o.number,o.keyword,o.link,o.attributeName,o.quote],color:"#ffcc99"},{tag:[o.emphasis,o.heading,o.tagName,o.propertyName,o.className,o.variableName],color:"#eeebff"},{tag:[o.typeName,o.url],color:"#7a63ee"},{tag:o.operator,color:"#ffad5c"},{tag:o.string,color:"#ffb870"},{tag:[o.propertyName],color:"#9a86fd"},{tag:[o.unit,o.punctuation],color:"#e09142"}],Rr=e=>{var{theme:n="dark",settings:r={},styles:a=[]}={};return ct({theme:n,settings:ve({},Ir,r),styles:[...Pr,...a]})},Or=Rr();const Lr=E("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}`})),dt=E("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})),Br=E("div")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.error.dark,marginRight:e.spacing(1)})),Fr=()=>{const e=N();return t.jsx(dt,{style:{backgroundColor:e.palette.success.main},children:t.jsx(Ot,{sx:n=>({width:n.spacing(2),height:n.spacing(2)})})})},Nr=()=>{const e=N();return t.jsx(dt,{style:{backgroundColor:e.palette.error.main},children:t.jsx(Lt,{})})},Ar=({context:e,setContext:n,error:r})=>{const{themeMode:a}=m.useContext(Rt),s=N(),l=m.useCallback(i=>{n(i)},[n]),d=`calc(6 * ${s.typography.body1.fontSize} * ${s.typography.body1.lineHeight}) + 8px`;return t.jsxs(w,{sx:{width:"100%"},children:[t.jsxs(Lr,{children:["JSON",t.jsx(F,{condition:!!r,show:t.jsxs(w,{sx:i=>({display:"flex",alignItems:"center"}),children:[t.jsx(Br,{children:r}),t.jsx(Nr,{})]}),elseShow:t.jsx(Fr,{})})]}),t.jsx(lt,{value:e,minHeight:d,theme:a==="dark"?Or:Tr,extensions:[Xn()],onChange:l,style:{border:`1px solid ${s.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 ut(e){return Array.isArray(e)?e:[e]}const $r=e=>!e||e.length===0||e.length===1&&e[0]==="*"?"*":ut(e),Dr=e=>ut(e),Mr=e=>{const n=Hr(e);return n.length>0?n[0]:""},Hr=e=>e.filter(({enabled:n})=>!!n).sort((n,r)=>n.sortOrder-r.sortOrder).map(({name:n})=>n),Wr=(e,n)=>"100%",zr=e=>typeof e=="string"?!0:Array.isArray(e)?e.every(n=>typeof n=="string"):!1,Ur=e=>{const n=new Set(["appName","environment","userId","sessionId","remoteAddress","currentTime","properties"]),r={...e};let a=!1;for(const s in e)n.has(s)||(r.properties||(r.properties={}),r.properties[s]=e[s],delete r[s],a=!0);return!a&&!e.properties&&delete r.properties,r},_r=e=>{const[n]=e.split("."),[r,a]=n.split(":");if(!r||!a)throw new Error("Invalid token format");if(a==="*")throw new Error("Admin tokens are not supported in the playground")},Gr=e=>{const[n]=e.split(".");return n.split(":")},Vr=e=>Bt({mode:"all"},e),qr=e=>{const n=s=>s.toSorted((l,d)=>l.sortOrder-d.sortOrder).map(l=>({key:l.name,label:l.name})),r=e.reduce(({project:s,global:l},d)=>(d.project?s.push(d):l.push(d),{project:s,global:l}),{project:[],global:[]}),a=[];return r.project.length&&a.push({groupHeader:"Project context fields",options:n(r.project)}),r.global.length&&a.push({groupHeader:"Global context fields",options:n(r.global)}),a},Kr=({context:e,setContext:n})=>{const r=N(),{setToastData:a}=Ve(),{context:s}=Vr(),l=qr(s),[d,i]=m.useState(),[h,u]=m.useState(!1),[c,g]=m.useState(""),[f,b]=m.useState(""),T=m.useMemo(()=>rr(p=>{var k;if(!p)return i(void 0);try{const v=JSON.parse(p);u(v[c]!==void 0||((k=v==null?void 0:v.properties)==null?void 0:k[c])!==void 0)}catch(v){return i(ee(v))}return i(void 0)},250),[i,c,u]);m.useEffect(()=>{T(e)},[T,e]);const I=()=>{try{const p=JSON.parse(e||"{}");n(JSON.stringify(Ur({...p,[c]:f}),null,2));const k=s.find(v=>v.name===c);if(k!=null&&k.legalValues&&k.legalValues.length>0||c==="currentTime")return b("")}catch(p){a({type:"error",text:`Error parsing context: ${ee(p)}`})}},S=(p,k)=>{if(zr(k)){if(Array.isArray(k)){const v=(k||[]).length>1?k.join(","):k[0];return b(v)}b(k)}},P=()=>{if(!f||f==="")return[];const p=s.find(v=>v.name===c),k=((p==null?void 0:p.legalValues)||[]).length>1;return f.includes(",")&&k?f.split(","):[f]},A=()=>{if(c==="currentTime"){const k=Ie(f),x=k?Pe(k.toISOString()):Pe(new Date().toISOString());return t.jsx(ae,{id:"date",label:"Date",size:"small",type:"datetime-local",value:x,sx:{width:200,maxWidth:"100%"},onChange:j=>{const y=Ie(j.target.value),L=y==null?void 0:y.toISOString();L&&b(L)},InputLabelProps:{shrink:!0},required:!0})}const p=s.find(k=>k.name===c);if(p!=null&&p.legalValues&&p.legalValues.length>0){const k=p.legalValues.map(({value:v})=>v);return t.jsx(qe,{disablePortal:!0,limitTags:3,id:"context-legal-values",multiple:!0,options:k,disableCloseOnSelect:!0,size:"small",value:P(),onChange:S,getOptionLabel:v=>v,renderOption:(v,x,{selected:j})=>t.jsxs("li",{...v,children:[t.jsx(Nt,{icon:t.jsx($t,{fontSize:"small"}),checkedIcon:t.jsx(At,{fontSize:"small"}),sx:y=>({marginRight:y.spacing(.5)}),checked:j}),x]}),sx:{width:370,maxWidth:"100%"},renderInput:v=>t.jsx(ae,{...v,label:"Value"})})}return t.jsx(ae,{label:"Value",id:"context-value",sx:{width:370,maxWidth:"100%"},placeholder:"value1,value2,value3",size:"small",value:f,onChange:k=>b(k.target.value||"")})},R=p=>{if(g(p||""),p==="currentTime")return b(new Date().toISOString());b("")};return t.jsxs(w,{children:[t.jsx(w,{sx:{display:"flex",alignItems:"center",mb:2},children:t.jsx(D,{variant:"body2",color:r.palette.text.primary,sx:{ml:1},children:"Unleash context"})}),t.jsxs(w,{sx:{display:"flex",gap:2,flexWrap:"wrap",mb:2},children:[t.jsx(Ft,{label:"Context field",labelId:"context-field-label",id:"context-field",value:c,onChange:R,variant:"outlined",size:"small",sx:{width:200,maxWidth:"100%"},options:l}),A(),t.jsx(le,{variant:"outlined",disabled:!c||!!d,onClick:I,sx:{width:"95px",maxHeight:"40px"},children:`${h?"Replace":"Add"} `})]}),t.jsx(Ar,{context:e,setContext:n,error:d})]})},Jr=({environments:e,setEnvironments:n,availableEnvironments:r,disabled:a})=>{const s=[...r.map(i=>({label:i,id:i}))],l=s.filter(({id:i})=>e.includes(i)),d=(i,h,u)=>{const c=h;return u==="clear"||c===null?n([]):Array.isArray(c)?c.length===0?n([]):n(c.map(({id:g})=>g)):n([c.id])};return t.jsx(qe,{disablePortal:!0,limitTags:3,id:"environment",multiple:!0,options:s,sx:{flex:1},renderInput:i=>t.jsx(ae,{...i,label:"Environments"}),renderOption:Dt,renderTags:(i,h)=>i.map((u,c)=>{const{key:g,...f}=h({index:c});return t.jsx(Mt,{size:"small",...f,label:u.label},g)}),getOptionLabel:({label:i})=>i,disableCloseOnSelect:!1,size:"small",value:l,onChange:d,disabled:a,"data-testid":"PLAYGROUND_ENVIRONMENT_SELECT"})},me={label:"ALL",id:"*"},ze=E(_t)({fontSize:"1.25rem"}),ht=E(Ut)(()=>({width:"100%"})),Yr=E(w)(({theme:e})=>({display:"grid",columnGap:e.spacing(2),rowGap:e.spacing(2),gridTemplateColumns:"1fr",[e.breakpoints.up("md")]:{gridTemplateColumns:"1fr 1fr"}})),Zr=E(ht)(({theme:e})=>({"& label":{WebkitTextFillColor:e.palette.text.secondary},"& input.Mui-disabled":{WebkitTextFillColor:e.palette.text.secondary}})),Qr=({environments:e,projects:n,token:r,setProjects:a,setEnvironments:s,setToken:l,availableEnvironments:d,changeRequest:i,onClearChangeRequest:h})=>{const u=N(),{tokens:c}=er(),[g,f]=m.useState(),{projects:b}=Ht(),T=[me,...b.map(({name:x,id:j})=>({label:x,id:j}))],I=async x=>{const j=x.target.value;if(l==null||l(j),j===""){k();return}try{_r(j),f(void 0),S(j)}catch(y){f(y.message)}},S=x=>{const[j,y]=Gr(x);switch(s([y]),j){case"[]":A(x);break;case"*":R();break;default:p(j)}},P=x=>{!x.projects||x.projects==="*"?a([me.id]):typeof x.projects=="string"?a([x.projects]):Array.isArray(x.projects)&&a(x.projects)},A=x=>{const j=c.find(({secret:y})=>y===x);j?P(j):f("Invalid token. Ensure you use a valid token from this Unleash instance.")},R=()=>{a([me.id])},p=x=>{T.map(j=>j.id).includes(x)?a([x]):f(`Invalid token. Project ${x} does not exist.`)},k=()=>{f(void 0)},v=()=>{l==null||l(""),k()};return t.jsxs(w,{sx:{pb:2},children:[t.jsx(w,{sx:{display:"flex",alignItems:"center",mb:2},children:t.jsx(D,{variant:"body2",color:u.palette.text.primary,sx:{ml:1},children:"Access configuration"})}),t.jsxs(Yr,{children:[t.jsx(w,{children:t.jsx(Re,{arrow:!0,title:r?"Environment is automatically selected because you are using a token":"Select environments to use in the playground",children:t.jsx(w,{children:t.jsx(Jr,{environments:e,setEnvironments:s,availableEnvironments:d,disabled:!!(r||i)})})})}),t.jsx(w,{children:t.jsx(Re,{arrow:!0,title:r?"Project is automatically selected because you are using a token":"Select projects to use in the playground",children:t.jsx(Wt,{selectedProjects:n,onChange:a,dataTestId:"PLAYGROUND_PROJECT_SELECT",disabled:!!(r||i),limitTags:3})})}),t.jsx(w,{children:t.jsx(ht,{label:"API token",value:r||(i?" ":""),onChange:I,type:"text",error:!!g,errorText:g,placeholder:"Enter your API token","data-testid":"PLAYGROUND_TOKEN_INPUT",InputProps:{endAdornment:r?t.jsx(Oe,{position:"end","data-testid":"TOKEN_INPUT_CLEAR_BTN",children:t.jsx(q,{"aria-label":"clear API token",onClick:v,edge:"end",children:t.jsx(ze,{})})}):null},disabled:!!i})}),t.jsx(F,{condition:!!i,show:t.jsxs(w,{sx:{display:"flex",gap:2},children:[t.jsx(w,{sx:{flex:1},children:t.jsx(Zr,{label:"Change request",value:i?`Change request #${i}`:"",onChange:()=>{},type:"text",disabled:!0,InputProps:{endAdornment:t.jsx(Oe,{position:"end",children:t.jsx(q,{"aria-label":"clear Change request results",onClick:h,edge:"end",children:t.jsx(ze,{})})})}})}),t.jsx(le,{variant:"outlined",size:"small",to:`/projects/${n[0]}/change-requests/${i}`,component:zt,children:"View change request"})]})})]})]})},Xr=({availableEnvironments:e,environments:n,onSubmit:r,projects:a,token:s,setToken:l,setProjects:d,setEnvironments:i,context:h,setContext:u,changeRequest:c,onClearChangeRequest:g})=>t.jsxs(w,{component:"form",onSubmit:r,sx:{display:"flex",flexDirection:"column"},children:[t.jsx(Qr,{environments:Array.isArray(n)?n:[n],projects:a,token:s,setToken:l,setEnvironments:i,setProjects:d,availableEnvironments:e.map(({name:f})=>f),changeRequest:c,onClearChangeRequest:g}),t.jsx(Kr,{context:h,setContext:u}),t.jsx(w,{sx:{mt:2,display:"flex",alignItems:"center",justifyContent:"space-between"},children:t.jsx(le,{variant:"contained",size:"large",type:"submit",sx:{marginLeft:"auto"},children:"Try configuration"})})]}),ea=E("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})),ta=({style:e,children:n,type:r})=>{const a=N(),s={backgroundColor:a.palette.background.alternative,color:a.palette.common.white};return r==="secondary"&&(s.backgroundColor=a.palette.background.paper,s.color=a.palette.text.secondary),t.jsx(ea,{style:{...s,...e},children:n})},pe=({headerText:e,bodyText:n,sectionNumber:r})=>t.jsx(w,{sx:{display:"flex",alignItems:"flex-start",mt:2,flexDirection:"column"},children:t.jsxs(w,{sx:{display:"flex"},children:[t.jsx(w,{children:t.jsx(ta,{children:r})}),t.jsxs(w,{sx:{ml:2,display:"flex",flexDirection:"column"},children:[t.jsx(D,{variant:"body1",sx:{fontWeight:"bold"},children:e}),t.jsx(F,{condition:!!n,show:t.jsx(D,{variant:"body1",sx:{mt:1},children:n})})]})]})}),gt=()=>t.jsxs(w,{sx:{ml:4},children:[t.jsx(D,{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(Gt,{sx:{mt:2,mb:2}}),t.jsx(D,{variant:"body1",sx:{mb:1},children:"What you need to do is:"}),t.jsx(pe,{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(pe,{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(pe,{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 Ee={},na=Je;Object.defineProperty(Ee,"__esModule",{value:!0});var ft=Ee.default=void 0,ra=na(Ke()),aa=t,sa=(0,ra.default)((0,aa.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");ft=Ee.default=sa;const oa=E(ne)(({theme:e})=>({"& .MuiPaper-root":{borderRadius:e.shape.borderRadiusExtraLarge,border:`1px solid ${e.palette.divider}`,padding:e.spacing(8,4),maxWidth:"500px"}})),ia=()=>{const[e,n]=m.useState(null),r=l=>n(l.currentTarget),a=()=>n(null),s=!!e;return t.jsxs(w,{children:[t.jsx(q,{onClick:r,"aria-label":"Open Playground guidance",children:t.jsx(ft,{})}),t.jsxs(oa,{open:s,anchorEl:e,onClose:a,anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},sx:l=>({zIndex:l.zIndex.tooltip,background:"none"}),children:[t.jsx(q,{onClick:a,sx:{position:"absolute",right:25,top:15},children:t.jsx(Vt,{})}),t.jsx(gt,{})]})]})},la=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"})),ca=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"})),da=e=>e==="unknown"||e==="unevaluated"?[ce,"info"]:e===!0?[la,"success"]:[ca,"error"],Y=({enabled:e,label:n,showIcon:r=!0})=>{const[a,s]=da(e);return t.jsx(Ye,{color:s,icon:r?t.jsx(a,{"aria-hidden":!0,color:s,strokeWidth:"0.25"}):void 0,children:n})},ua=E(w)(({theme:e})=>({display:"flex",alignItems:"center",padding:e.spacing(1,0,1,2)})),ha=E(w)(()=>({marginRight:"auto"})),mt=({feature:e})=>{const[n,r]=(()=>{var a;return e!=null&&e.isEnabled?[!0,"True"]:((a=e==null?void 0:e.strategies)==null?void 0:a.result)==="unknown"?["unknown","Unknown"]:[!1,"False"]})();return t.jsx(ua,{children:t.jsx(ha,{"data-loading":!0,children:t.jsx(Y,{enabled:n,label:r,showIcon:n!=="unknown"})})})};function pt(e){return e===void 0?!0:Object.values(e).every(n=>n&&typeof n=="object"?pt(n):n===null)}const Ue=e=>{var n,r;return(r=(n=e.strategies)==null?void 0:n.data)==null?void 0:r.find(a=>!Ze.includes(a.name))},ga=e=>{var n,r,a,s;return((r=(n=e.strategies)==null?void 0:n.data)==null?void 0:r.length)>0&&!((s=(a=e.strategies)==null?void 0:a.data)!=null&&s.find(l=>Ze.includes(l.name)))},fa=E("div")({display:"flex",justifyContent:"space-between",width:"100%"}),ma=E("hgroup")(({theme:e})=>({display:"inline-flex",alignItems:"center",gap:e.spacing(1.5)})),pa=E("h3")(({theme:e})=>({fontWeight:"bold",fontSize:e.typography.subtitle1.fontSize,margin:0})),xa=({feature:e,input:n,onClose:r})=>{var c;const a=N(),[s,l,d]=e.isEnabled?[`This feature flag is True in ${n==null?void 0:n.environment} because `,"at least one strategy is True",a.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",a.palette.error.contrastText]:e.isEnabledInCurrentEnvironment?ga(e)?[`This feature flag is Unknown in ${n==null?void 0:n.environment} because `,"no strategies could be fully evaluated",a.palette.warning.contrastText]:Ue(e)?[`This feature flag is Unknown in ${n==null?void 0:n.environment} because `,"not all strategies could be fully evaluated",a.palette.warning.contrastText]:e.hasUnsatisfiedDependency?[`This feature flag is False in ${n==null?void 0:n.environment} because `,"parent dependency is not satisfied",a.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",a.palette.error.contrastText]:[`This feature flag is False in ${n==null?void 0:n.environment} because `,"the environment is disabled",a.palette.error.contrastText],i=pt(n==null?void 0:n.context)?"You did not provide a value for your context field in step 2 of the configuration":void 0,h=Ue(e)?"This feature uses custom strategies. Custom strategies can't be evaluated, so they will be marked accordingly.":void 0,u=r&&(g=>{g.stopPropagation(),r()});return t.jsxs(t.Fragment,{children:[t.jsxs(fa,{children:[t.jsxs(ma,{children:[t.jsx(pa,{children:e.name}),t.jsx("p",{children:((c=e==null?void 0:e.strategies)==null?void 0:c.result)!=="unknown"?t.jsx(Y,{enabled:e.isEnabled,label:e.isEnabled?"True":"False"}):t.jsx(Y,{enabled:"unknown",label:"Unknown",showIcon:!1})})]}),t.jsx(q,{"aria-label":"Close",onClick:u,children:t.jsx(qt,{})})]}),t.jsxs("p",{children:[s,t.jsx(D,{color:d,component:"span",children:l}),"."]}),i?t.jsx(te,{color:"info",children:i}):null,h?t.jsx(te,{severity:"warning",color:"info",children:h}):null]})},xt=E("div",{shouldForwardProp:e=>e!=="variant"})(({theme:e,variant:n})=>({"--font-size":e.typography.body2.fontSize,display:"flex",alignItems:"center",gap:e.spacing(1),padding:e.spacing(.5,.25),color:n==="ok"?e.palette.success.dark:e.palette.error.dark,fontSize:"var(--font-size)",svg:{fontSize:"calc(var(--font-size) * 1.25)"}})),ba=()=>t.jsxs(xt,{variant:"ok",children:[t.jsx(Jt,{"aria-hidden":"true"}),t.jsx("p",{children:"Constraint met by value in context"})]}),ya=({text:e})=>t.jsxs(xt,{variant:"error",children:[t.jsx(Yt,{"aria-hidden":"true"}),t.jsx("p",{children:e})]}),bt=({constraint:e,input:n})=>{if(!e)return null;const r=()=>{const a=n==null?void 0:n.context[e.contextName];return e.operator==="REGEX"&&a&&e.value?`Constraint not met – the value in the context ${e.contextName}: { ${a} } is not matching ${e.operator} ${e.value}`:a?`Constraint not met – the value in the context: { ${a} } is not ${e.operator} ${e.contextName}`:`Constraint not met – no value was specified for ${e.contextName}`};return t.jsx(be,{children:t.jsxs("div",{children:[t.jsx(Kt,{...e}),e.result?t.jsx(ba,{}):t.jsx(ya,{text:r()})]})})},va=E(w)(({theme:e})=>({width:"auto",height:"auto",padding:e.spacing(2,3),borderRadius:e.shape.borderRadiusMedium,border:`1px solid ${e.palette.divider}`})),ja=({segment:e,input:n})=>{const r=e.constraints.length>0?t.jsx(Qe,{children:e.constraints.map(a=>t.jsx(bt,{constraint:a,input:n},oe(a)))}):void 0;return t.jsx(Zt,{segment:e,constraintList:r,isExpanded:!0})},Ca=({strategyResult:e,input:n})=>{const{name:r,constraints:a,segments:s,parameters:l}=e,d=Qt(e),{strategies:i}=Xt(),{isCustomStrategy:h,customStrategyParameters:u}=en(e,i),c=!!(s&&s.length>0),g=!!(a&&(a==null?void 0:a.length)>0),f=r!=="default"&&Object.keys(tn).includes(r);if(!l)return null;const b=[...c?s.map(S=>t.jsx(ja,{segment:S,input:n},oe(S))):[],...g?a.map(S=>t.jsx(bt,{constraint:S,input:n},oe(S))):[],f&&d.map((S,P)=>t.jsx(be,{children:S},P)),h&&u.map((S,P)=>t.jsx(be,{children:S},P)),r==="default"&&t.jsxs(va,{sx:{width:"100%"},children:["The standard strategy is ",t.jsx(Ye,{color:"success",children:"ON"})," for all users."]},"default-on")].filter(Boolean),{variant:T,variants:I}=e.result;return t.jsxs(t.Fragment,{children:[t.jsx(Qe,{children:b}),I!=null&&I.length?t.jsx(nn,{variants:I,selected:T==null?void 0:T.name}):null]})},Sa=({strategy:e,input:n,className:r})=>{const{result:a}=e,s=a.evaluationStatus==="incomplete"||a.evaluationStatus==="unevaluated"?"Not evaluated":a.enabled?"True":"False";return t.jsx(rn,{strategy:{...e,id:`${oe(e)}`},strategyHeaderLevel:4,className:r,headerItemsLeft:e.disabled?null:t.jsx(Y,{showIcon:!1,enabled:a.enabled,label:s}),children:t.jsx(Ca,{strategyResult:e,input:n})})},ka=E("hgroup")(({theme:e})=>({paddingBottom:e.spacing(2)})),wa=E("h4")(({theme:e})=>({fontWeight:"normal",fontSize:e.typography.body1.fontSize,margin:0})),Ea=E("p")(({theme:e})=>({fontWeight:"bold",fontSize:e.typography.body2.fontSize})),Ta=E(on)(({theme:e})=>({marginInline:"calc(var(--popover-inline-padding) * -1)",borderTop:`1px solid ${e.palette.divider}`,"> li:last-of-type":{paddingBottom:0}})),_e=({strategies:e,input:n,titlePrefix:r,infoText:a})=>e.length===0?null:t.jsxs("div",{children:[t.jsxs(ka,{children:[t.jsx(wa,{children:`${r?r.concat(" strategies"):"Strategies"} (${e==null?void 0:e.length})`}),a?t.jsx(Ea,{children:a}):null]}),t.jsx(Ta,{children:e==null?void 0:e.map((s,l)=>t.jsxs(an,{children:[l>0?t.jsx(sn,{}):"",t.jsx(Sa,{strategy:s,input:n})]},s.id))})]}),Ia=({feature:e})=>{var r,a;if(!((r=e==null?void 0:e.strategies)!=null&&r.data))return null;let n;if(e.hasUnsatisfiedDependency&&!e.isEnabledInCurrentEnvironment)n="If the environment was enabled and parent dependencies were satisfied";else if(e.hasUnsatisfiedDependency)n="If parent dependencies were satisfied";else if(!e.isEnabledInCurrentEnvironment)n="If the environment was enabled";else return;return t.jsxs(te,{severity:"info",color:"info",children:[n,", then this feature flag would be"," ",(a=e.strategies)!=null&&a.result?"TRUE":"FALSE"," with strategies evaluated like this:"]})},Pa=({feature:e,input:n})=>{var l,d,i,h,u;const r=(d=(l=e.strategies)==null?void 0:l.data)==null?void 0:d.filter(c=>!c.disabled),a=(h=(i=e.strategies)==null?void 0:i.data)==null?void 0:h.filter(c=>c.disabled),s=(a==null?void 0:a.length)>0;return(((u=e==null?void 0:e.strategies)==null?void 0:u.data.length)??0)===0?t.jsx(te,{severity:"info",children:"There are no strategies added to this feature flag in the selected environment."}):t.jsxs(t.Fragment,{children:[t.jsx(Ia,{feature:e}),t.jsx(_e,{strategies:r||[],input:n,titlePrefix:s?"Enabled":void 0}),s?t.jsx(_e,{strategies:a,input:n,titlePrefix:"Disabled",infoText:"Disabled strategies are not evaluated for the overall result."}):null]})},Ra=E("div")(({theme:e})=>({alignItems:"flex-end",color:e.palette.divider})),Oa=({feature:e,input:n})=>{const[r,a]=m.useState(!1),s=m.useRef(null),l=()=>{a(!r)};return t.jsxs(Ra,{children:[t.jsx(q,{onClick:l,children:t.jsx(ce,{ref:s})}),t.jsxs(ne,{open:r,onClose:()=>a(!1),anchorEl:s.current,PaperProps:{sx:d=>({"--popover-inline-padding":d.spacing(4),paddingInline:"var(--popover-inline-padding)",paddingBlock:d.spacing(3),display:"flex",flexDirection:"column",width:728,maxWidth:"100%",height:"auto",gap:d.spacing(3),overflowY:"auto",backgroundColor:d.palette.background.elevation1,borderRadius:d.shape.borderRadius})},anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:[t.jsx(xa,{feature:e,input:n,onClose:()=>a(!1)}),t.jsx(Pa,{feature:e,input:n})]})]})},yt=e=>e.feature?t.jsx(Oa,{...e}):null;var Te={},La=Je;Object.defineProperty(Te,"__esModule",{value:!0});var vt=Te.default=void 0,Ba=La(Ke()),Fa=t,Na=(0,Ba.default)((0,Fa.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 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 8zm4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"}),"CheckCircleOutlined");vt=Te.default=Na;const Aa=E("div")(({theme:e})=>({padding:e.spacing(4),maxWidth:"400px"})),xe=E(D)(({theme:e})=>({marginBottom:e.spacing(2)})),$a=E(vt)(({theme:e})=>({color:e.palette.success.main})),Da=({variants:e,selectedVariant:n})=>{const r=N(),a=m.useMemo(()=>e.map(c=>({name:c.name,weight:`${ln(c.weight)}%`,selected:c.name===n})),[e,n]),s=m.useMemo(()=>({sortBy:[{id:"name",desc:!1}]}),[]),{getTableProps:l,getTableBodyProps:d,headerGroups:i,rows:h,prepareRow:u}=O.useTable({initialState:s,columns:Ma,data:a,sortTypes:de,autoResetGlobalFilter:!1,autoResetSortBy:!1,disableSortRemove:!0},O.useGlobalFilter,O.useSortBy);return t.jsxs(Aa,{children:[t.jsx(xe,{variant:"subtitle2",children:"Variant Information"}),t.jsx(xe,{variant:"body2",children:"The following table shows the variants defined on this feature toggle and the variant result based on your context configuration."}),t.jsx(xe,{variant:"body2",children:'If you include "userId" or "sessionId" in your context, the variant will be the same every time because unleash uses these properties to ensure that the user receives the same experience.'}),t.jsxs(cn,{...l(),rowHeight:"dense",children:[t.jsx(dn,{headerGroups:i}),t.jsx(un,{...d(),children:h.map(c=>{const g={};c.original.selected||(g.color=r.palette.text.secondary),u(c);const{key:f,...b}=c.getRowProps();return t.jsx(hn,{hover:!0,...b,children:c.cells.map(T=>{const{key:I,...S}=T.getCellProps();return t.jsx(gn,{...S,style:g,children:T.render("Cell")},I)})},f)})})]})]})},Ma=[{id:"Icon",Cell:({row:{original:{selected:e}}})=>t.jsx(t.Fragment,{children:t.jsx(F,{condition:e,show:t.jsx(fn,{icon:t.jsx($a,{})})})}),maxWidth:25,disableGlobalFilter:!0},{Header:"Name",accessor:"name",searchable:!0,Cell:({row:{original:{name:e}}})=>t.jsx(Le,{children:e}),maxWidth:175,width:175},{Header:"Weight",accessor:"weight",sortType:"alphanumeric",searchable:!0,maxWidth:75,Cell:({row:{original:{weight:e}}})=>t.jsx(Le,{children:e})}],Ha=E("div")(()=>({maxWidth:"100%",display:"flex",alignItems:"center",wordBreak:"break-all"})),Wa=({variant:e,variants:n,feature:r,isEnabled:a})=>{const s=N(),[l,d]=m.useState(null),i=c=>d(c.currentTarget),h=()=>d(null),u=!!l;return t.jsxs(Ha,{children:[e,t.jsx(F,{condition:!!n&&n.length>0&&a,show:t.jsxs(t.Fragment,{children:[t.jsx(q,{onClick:i,children:t.jsx(ce,{})}),t.jsx(ne,{open:u,id:`${r}-result-variants`,PaperProps:{sx:{borderRadius:`${s.shape.borderRadiusLarge}px`}},onClose:h,anchorEl:l,anchorOrigin:{vertical:"bottom",horizontal:-320},children:t.jsx(Da,{variants:n,selectedVariant:e})})]})})]})},za=({features:e})=>{const n=N(),r=Xe(n.breakpoints.down("sm")),a=Object.keys(e[0].context).map(c=>({Header:Ce(c),accessor:g=>g.context[c],minWidth:160,Cell:je})),s=m.useMemo(()=>[...a,{Header:"Variant",id:"variant",accessor:"variant.name",sortType:"alphanumeric",filterName:"variant",maxWidth:200,Cell:({value:c,row:{original:{variant:g,feature:f,variants:b,isEnabled:T}}})=>t.jsx(Wa,{variant:g!=null&&g.enabled?c:"",variants:b,feature:f,isEnabled:T})},{id:"isEnabled",Header:"isEnabled",filterName:"isEnabled",accessor:c=>{var g;return c!=null&&c.isEnabled?"true":((g=c==null?void 0:c.strategies)==null?void 0:g.result)==="unknown"?"unknown":"false"},Cell:({row:c})=>t.jsx(mt,{feature:c.original}),sortType:"playgroundResultState",maxWidth:120,sortInverted:!0},{Header:"",maxWidth:70,id:"info",Cell:({row:c})=>t.jsx(yt,{feature:c.original,input:{environment:c.original.environment,context:c.original.context}})}],[]),{headerGroups:l,rows:d,prepareRow:i,setHiddenColumns:h}=O.useTable({columns:s,data:e,sortTypes:de,autoResetGlobalFilter:!1,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},O.useGlobalFilter,O.useFlexLayout,O.useSortBy);et([{condition:r,columns:["variant"]}],h,s);const u=m.useRef(null);return t.jsx(w,{ref:u,sx:{overflow:"auto",maxHeight:"800px"},children:t.jsx(Se,{parentRef:u,rows:d,headerGroups:l,prepareRow:i})})},Ua=E("div",{})(({theme:e})=>({flexGrow:0,...tt,justifyContent:"flex-start",margin:e.spacing(0,1.5)})),_a=E(w)(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing(1)})),Ga=({value:e})=>{const n=N(),[r,a]=m.useState(null),s=u=>a(u.currentTarget),l=()=>a(null),d=!!r,i=(e||[]).filter(u=>u.isEnabled),h=(e||[]).filter(u=>!u.isEnabled);return t.jsxs(Ua,{children:[t.jsxs(_a,{children:[t.jsx(F,{condition:i.length>0,show:t.jsx(Y,{enabled:!0,label:`${i.length}`,showIcon:!0})}),t.jsx(F,{condition:h.length>0,show:t.jsx(Y,{enabled:!1,label:`${h.length}`,showIcon:!0})})]}),t.jsxs(t.Fragment,{children:[t.jsx(q,{onClick:s,children:t.jsx(ce,{})}),t.jsxs(ne,{open:d,id:`${e}-result-details`,PaperProps:{sx:{borderRadius:`${n.shape.borderRadiusLarge}px`,padding:n.spacing(3)}},onClose:l,anchorEl:r,anchorOrigin:{vertical:"bottom",horizontal:-320},children:[t.jsx(D,{variant:"subtitle2",sx:{mb:3},children:e[0].environment}),t.jsx(za,{features:e})]})]})]})},Va=({features:e})=>{const n=Object.keys(e),r=e[n[0]],a=r[0].context,s=m.useMemo(()=>r.map((f,b)=>({...Object.fromEntries(n.map(T=>[T,e[T][b]]))})),[JSON.stringify(e)]),l=Object.keys(a).map(f=>({Header:Ce(f),accessor:b=>b[n[0]].context[f],minWidth:160,Cell:je})),d=n.map(f=>({Header:f,accessor:b=>{var T,I,S;return(T=b[f])!=null&&T.isEnabled?"true":((S=(I=b[f])==null?void 0:I.strategies)==null?void 0:S.result)==="unknown"?"unknown":"false"},Cell:({row:b})=>t.jsxs(w,{sx:{display:"flex"},children:[t.jsx(mt,{feature:b.original[f]}),t.jsx(yt,{feature:b.original[f],input:{environment:b.original[f].environment,context:b.original[f].context}})]}),sortType:"playgroundResultState",maxWidth:140})),i=m.useMemo(()=>[...l,...d],[]),{headerGroups:h,rows:u,prepareRow:c}=O.useTable({columns:i,data:s,sortTypes:de,autoResetGlobalFilter:!1,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},O.useGlobalFilter,O.useFlexLayout,O.useSortBy),g=m.useRef(null);return t.jsx(w,{ref:g,sx:{overflow:"auto",maxHeight:"800px"},children:t.jsx(Se,{parentRef:g,rows:u,headerGroups:h,prepareRow:c})})},qa=E("div",{})(({theme:e})=>({flexGrow:0,...tt,justifyContent:"flex-start",margin:e.spacing(0,1.5)})),Ka=E(le)(({theme:e})=>({textAlign:"left",textDecorationStyle:"dotted",textDecorationLine:"underline",textUnderlineOffset:e.spacing(.75),color:e.palette.neutral.dark,padding:0,fontWeight:"normal"})),Ja=({value:e})=>{const n=N(),[r,a]=m.useState(null),s=i=>a(i.currentTarget),l=()=>a(null),d=!!r;return t.jsx(qa,{children:t.jsxs(t.Fragment,{children:[t.jsx(Ka,{variant:"text",onClick:s,children:"View diff"}),t.jsxs(ne,{open:d,id:`${e}-result-details`,PaperProps:{sx:{borderRadius:`${n.shape.borderRadiusLarge}px`,padding:n.spacing(3)}},onClose:l,anchorEl:r,anchorOrigin:{vertical:"bottom",horizontal:-320},children:[t.jsx(D,{variant:"subtitle2",sx:{mb:3},children:"Environments diff"}),t.jsx(Va,{features:e})]})]})})},Ya=e=>e.reduce((n,r)=>n+Object.values(r.environments).flatMap(a=>Object.keys(a)).length,0),Za=e=>e<0?"invalid bucket":e>=2e4?"20000+":e>=1e4?"10000-20000":e>=1e3?"1000-10000":e>=100?"100-1000":"0-100",Qa={id:"name"},{value:Ge,setValue:Xa}=at("AdvancedPlaygroundResultsTable:v1",Qa),es=({features:e,input:n,loading:r})=>{const{trackEvent:a}=nt();e&&a("playground",{props:{eventType:"number-of-combinations",count:Za(Ya(e))}});const[s,l]=rt(),d=mn(r),[i,h]=m.useState(s.get("search")||""),u=N(),c=Xe(u.breakpoints.down("md")),g=e&&e.length>0?Object.keys(e[0].environments).length:0,f=m.useMemo(()=>{var x;return[{Header:"Name",accessor:"name",searchable:!0,minWidth:160,Cell:({value:j,row:{original:y}})=>t.jsx(Be,{title:j,to:`/projects/${y==null?void 0:y.projectId}/features/${j}`})},{Header:"Project ID",accessor:"projectId",sortType:"alphanumeric",filterName:"projectId",searchable:!0,minWidth:150,Cell:({value:j})=>t.jsx(Be,{title:j,to:`/projects/${j}`})},...((x=n==null?void 0:n.environments)==null?void 0:x.map(j=>({Header:r?()=>"":Ce(j),maxWidth:150,id:`environments.${j}`,align:"flex-start",Cell:({row:y})=>t.jsx(Ga,{value:y.original.environments[j]})})))||[],...g>1?[{Header:"Diff",minWidth:150,id:"diff",align:"left",Cell:({row:j})=>t.jsx(Ja,{value:j.original.environments})}]:[]]},[n]),{data:b,getSearchText:T,getSearchContext:I}=pn(f,i,e||[]),S=m.useMemo(()=>r?Array(5).fill({name:"Feature name",projectId:"Feature Project",environments:{name:"Feature Environments",variants:[]},enabled:!0}):b,[b,r]),[P]=m.useState(()=>({sortBy:[{id:s.get("sort")||Ge.id,desc:s.has("order")?s.get("order")==="desc":Ge.desc}]})),{headerGroups:A,rows:R,state:{sortBy:p},prepareRow:k,setHiddenColumns:v}=O.useTable({initialState:P,columns:f,data:S,sortTypes:de,autoResetGlobalFilter:!1,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0,defaultColumn:{Cell:je}},O.useGlobalFilter,O.useFlexLayout,O.useSortBy);return et([{condition:c,columns:["projectId"]}],v,f),m.useEffect(()=>{if(r)return;const x=Object.fromEntries(s);x.sort=p[0].id,p[0].desc?x.order="desc":x.order&&delete x.order,i?x.search=i:delete x.search,l(x,{replace:!0}),Xa({id:p[0].id,desc:p[0].desc||!1})},[r,p,i]),t.jsxs(t.Fragment,{children:[t.jsxs(w,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:[t.jsx(D,{variant:"subtitle1",sx:{ml:1},children:e!==void 0&&!r?`Results (${R.length<S.length?`${R.length} of ${S.length}`:S.length})`:"Results"}),t.jsx(xn,{initialValue:i,onChange:h,hasFilters:!0,getSearchContext:I,disabled:r,containerStyles:{marginLeft:"1rem",maxWidth:"400px"}})]}),t.jsx(F,{condition:!r&&!S,show:()=>t.jsx(he,{children:S===void 0?"None of the feature flags were evaluated yet.":"No results found."}),elseShow:()=>t.jsxs(w,{ref:d,sx:{overflow:"auto"},children:[t.jsx(bn,{value:T(i),children:t.jsx(Se,{rows:R,headerGroups:A,prepareRow:k})}),t.jsx(F,{condition:S.length===0&&(i==null?void 0:i.length)>0,show:t.jsxs(he,{children:["No feature flags found matching “",i,"”"]})}),t.jsx(F,{condition:S&&S.length===0&&!i,show:t.jsx(he,{children:"No features flags to display"})})]})})]})},jt=E(te)(({theme:e})=>({marginBottom:e.spacing(3)})),ts=({response:e})=>{var r;const n=(r=e==null?void 0:e.warnings)==null?void 0:r.invalidContextProperties;if(n&&n.length>0){n.sort();const a="Some context properties were not taken into account during evaluation",s=E("details")(({theme:l})=>({"* + *":{marginBlockStart:l.spacing(1)}}));return t.jsx(jt,{severity:"warning",children:t.jsxs(s,{children:[t.jsx("summary",{children:a}),t.jsx("p",{children:"The context you provided for this query contained top-level properties with