UNPKG

unleash-server

Version:

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

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