unleash-server 7.2.1 → 7.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/{AdvancedPlayground-CUkOz1YF.js → AdvancedPlayground-D2Y0O_LK.js} +1 -1
- package/frontend/build/static/{BackendConnections-Bi1Fsohi.js → BackendConnections-C9HcQ9To.js} +1 -1
- package/frontend/build/static/{ChartItem-Ci-KFL7s.js → ChartItem-COMyVdgD.js} +1 -1
- package/frontend/build/static/{CreateProject-COHPsP3X.js → CreateProject-jRfRrbUO.js} +1 -1
- package/frontend/build/static/{FeatureMetricsChart-ClbKeGOa.js → FeatureMetricsChart-CQkGp91T.js} +1 -1
- package/frontend/build/static/{FeatureStaleDialog-DZvKjxPB.js → FeatureStaleDialog-DKeGFuL1.js} +1 -1
- package/frontend/build/static/{FeatureViewLazyExport-yCIrczZt.js → FeatureViewLazyExport-CgntSCvS.js} +2 -2
- package/frontend/build/static/{FlagMetricsChart-D0GI-ltv.js → FlagMetricsChart-oDTQTkxU.js} +1 -1
- package/frontend/build/static/{FrontendNetworkTrafficUsage-DlRkx8CV.js → FrontendNetworkTrafficUsage-E4pIeMFQ.js} +1 -1
- package/frontend/build/static/{ImpactMetricsPage-BYcbHNWC.js → ImpactMetricsPage-B3STis_H.js} +1 -1
- package/frontend/build/static/{LazyAdminExport-BjSYZTvt.js → LazyAdminExport-CsCsRIwk.js} +2 -2
- package/frontend/build/static/{LazyProjectExport-9mNkV9Jq.js → LazyProjectExport-DkN0UegC.js} +2 -2
- package/frontend/build/static/{LifecycleChartComponent-BigwXcU3.js → LifecycleChartComponent-Dz1wdYkW.js} +1 -1
- package/frontend/build/static/{LineChartComponent-CPcDsiNa.js → LineChartComponent-DG1LdcL_.js} +1 -1
- package/frontend/build/static/{MarkCompletedDialogue-CS-kM4vW.js → MarkCompletedDialogue-Bw9Iccid.js} +1 -1
- package/frontend/build/static/{NetworkConnectedEdges-C2nfTRKM.js → NetworkConnectedEdges-HU923-QZ.js} +1 -1
- package/frontend/build/static/{NetworkOverview-BKozpi8w.js → NetworkOverview-_igGCPCJ.js} +1 -1
- package/frontend/build/static/{NetworkPrometheusAPIWarning-wqCXwcem.js → NetworkPrometheusAPIWarning-BS9PGbzI.js} +1 -1
- package/frontend/build/static/{NetworkTraffic-Co7oakIE.js → NetworkTraffic-BpNEMFBl.js} +1 -1
- package/frontend/build/static/{NetworkTrafficUsage-DNDJZGXi.js → NetworkTrafficUsage-bSUVPjoc.js} +1 -1
- package/frontend/build/static/{ReactJSONEditor-BDMT4-_1.js → ReactJSONEditor-DZ9l5V9S.js} +1 -1
- package/frontend/build/static/{RoleCell-COtuTPWk.js → RoleCell-C-hJFmul.js} +1 -1
- package/frontend/build/static/{aggregateFeatureMetrics-ClblY5Ev.js → aggregateFeatureMetrics-Dli6i5No.js} +1 -1
- package/frontend/build/static/{formatTickValue-DojfJagm.js → formatTickValue-D3KZyzeb.js} +1 -1
- package/frontend/build/static/{index-CqYZiU1N.js → index-A5We7bvX.js} +9 -9
- package/frontend/build/static/{networkTrafficUsageHighlightPlugin-BMMmh5e_.js → networkTrafficUsageHighlightPlugin-DLE_BBMN.js} +1 -1
- package/frontend/build/static/{useApiTokens-B6vbGXUF.js → useApiTokens-DNIDLJlc.js} +1 -1
- package/package.json +1 -1
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
rel="stylesheet"
|
|
22
22
|
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0"
|
|
23
23
|
/>
|
|
24
|
-
<script type="module" crossorigin src="/static/index-
|
|
24
|
+
<script type="module" crossorigin src="/static/index-A5We7bvX.js"></script>
|
|
25
25
|
<link rel="stylesheet" crossorigin href="/static/style-BW9ZTER3.css">
|
|
26
26
|
</head>
|
|
27
27
|
<body>
|
package/frontend/build/static/{AdvancedPlayground-CUkOz1YF.js → AdvancedPlayground-D2Y0O_LK.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
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 Ge,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 _e,m as Dt,n as Wt,o as Ht,q as zt,t as Mt,v as Ut,w as Gt,x as _t,y as Ie,P as Vt,z as Pe,D as G,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-CqYZiU1N.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 Gn,r as _n,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-B6vbGXUF.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(Gn()),n.closeBrackets!==!1&&s.push(_n()),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 _=O.state.doc,q=_.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},_=w?ae.fromJSON(w.json,O,w.fields):ae.create(O);if(z(_),!C){var q=new U({state:_,parent:x,root:m});A(q),c&&c(q,_)}}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 Gr=e=>!e||e.length===0||e.length===1&&e[0]==="*"?"*":ct(e),_r=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}=Ge(),{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(_e,{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(_e,{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(Gt)(()=>({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}=_t(),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(G,{"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(G,{"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
|
|
1
|
+
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 Ge,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 _e,m as Dt,n as Wt,o as Ht,q as zt,t as Mt,v as Ut,w as Gt,x as _t,y as Ie,P as Vt,z as Pe,D as G,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-A5We7bvX.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 Gn,r as _n,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-DNIDLJlc.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(Gn()),n.closeBrackets!==!1&&s.push(_n()),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 _=O.state.doc,q=_.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},_=w?ae.fromJSON(w.json,O,w.fields):ae.create(O);if(z(_),!C){var q=new U({state:_,parent:x,root:m});A(q),c&&c(q,_)}}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 Gr=e=>!e||e.length===0||e.length===1&&e[0]==="*"?"*":ct(e),_r=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}=Ge(),{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(_e,{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(_e,{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(Gt)(()=>({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}=_t(),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(G,{"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(G,{"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
|
|
2
2
|
feature flag configuration`,bodyText:`You can also specify specific projects, or check
|
|
3
3
|
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(G,{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(G,{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(G,{"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(G,{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:Ga,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)})})]})]})},Ga=[{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})}],_a=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(_a,{children:[e,t.jsx(L,{condition:!!n&&n.length>0&&a,show:t.jsxs(t.Fragment,{children:[t.jsx(G,{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(G,{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}=Ge(),[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=_();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("projects");return H&&(S=H.split(","),b(S)),S},_=()=>{let S=m.get("context");return S&&(S=decodeURI(S),R(S)),S},q=()=>{let S=m.get("token");return S&&(S=decodeURI(S),I(S)),S},le=()=>{const S=m.get("changeRequest");S&&j(S)},we=async(S,H,ee,ce)=>{try{f(void 0);const M={appName:"playground",...JSON.parse(ee||"{}")},Et=x?await A(x,{context:M}):await C({environments:_r(S),projects:Gr(H),context:M});ce&&typeof ce=="function"&&ce(),F(Et)}catch(M){M instanceof Sn?f(M.message):M instanceof SyntaxError?y({type:"error",text:`Error parsing context: ${Z(M)}`}):y({type:"error",text:Z(M)})}},vt=()=>{let S="default";T&&T!==""?S="api_token":x&&(S="change_request"),s("playground",{props:{eventType:"try-configuration",mode:S}})},jt=async S=>{S.preventDefault(),V(!0),vt(),await we(o,h,v,()=>{St(),x||a({environments:o,projects:h,context:v})})},Ct=()=>{j(void 0)},St=()=>{m.set("context",encodeURI(v||"")),Array.isArray(o)&&o.length>0&&!(o.length===1&&o[0]==="*")?m.set("environments",o.join(",")):m.delete("projects"),Array.isArray(h)&&h.length>0&&!(h.length===1&&h[0]==="*")?m.set("projects",h.join(",")):m.delete("projects"),x?m.set("changeRequest",x):m.delete("changeRequest"),w(m)},kt=P&&!l?"35%":"auto",wt=Kr();return t.jsx(kn,{header:t.jsx(wn,{title:"Unleash playground",actions:t.jsx(ha,{})}),disableLoading:!0,bodyClass:"no-padding",children:t.jsxs(k,{sx:{display:"flex",flexDirection:"column"},children:[t.jsx(k,{sx:{background:d.palette.background.elevation2,borderBottomLeftRadius:d.shape.borderRadiusMedium,isolation:"isolate",zIndex:2},children:t.jsx(En,{elevation:0,sx:{px:4,py:3,background:d.palette.background.elevation2,transition:"width 0.4s ease",minWidth:"auto",width:kt,position:"sticky",top:0},children:t.jsx(e,{onSubmit:jt,context:v,setContext:R,availableEnvironments:c,projects:h,environments:o,token:T,setToken:I,setProjects:b,setEnvironments:p,changeRequest:x||void 0,onClearChangeRequest:Ct})})}),t.jsxs(k,{sx:S=>({width:wt,transition:"width 0.4s ease",padding:S.spacing(4,4),isolation:"isolate",zIndex:1}),children:[t.jsx(L,{condition:!!u,show:t.jsx(bt,{severity:"warning",children:u})}),t.jsx(L,{condition:D,show:t.jsx(Tn,{}),elseShow:t.jsxs(t.Fragment,{children:[t.jsx(L,{condition:!!P&&Object.values(z).length===0,show:t.jsxs(t.Fragment,{children:[t.jsx(os,{response:P}),t.jsx(ss,{loading:D,features:P==null?void 0:P.features,input:P==null?void 0:P.input})]})}),t.jsx(L,{condition:!P&&!J,show:t.jsx(ut,{})})]})})]})]})})};export{ds as AdvancedPlayground,ds as default};
|
package/frontend/build/static/{BackendConnections-Bi1Fsohi.js → BackendConnections-C9HcQ9To.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as l,B as n,cS as c,bc as d,j as e,C as p,V as t,T as g,y as h,hE as j,j6 as u,i$ as x,j0 as m,j1 as y,j2 as C,j3 as S,j4 as f,j5 as B}from"./index-
|
|
1
|
+
import{s as l,B as n,cS as c,bc as d,j as e,C as p,V as t,T as g,y as h,hE as j,j6 as u,i$ as x,j0 as m,j1 as y,j2 as C,j3 as S,j4 as f,j5 as B}from"./index-A5We7bvX.js";import{u as T,b,S as v,T as w,P,n as k,g as D}from"./networkTrafficUsageHighlightPlugin-DLE_BBMN.js";import{a as q}from"./formatTickValue-D3KZyzeb.js";import"./LazyAdminExport-CsCsRIwk.js";import"./RoleCell-C-hJFmul.js";import"./useApiTokens-DNIDLJlc.js";const E=l(n)(({theme:s})=>({display:"flex",alignItems:"center",gap:s.spacing(.5)})),F=()=>{c("Network - Backend Connections");const{isOss:s}=d(),{chartDataSelection:a,setChartDataSelection:i,options:o}=T(),{chartData:r}=b(a);return e.jsx(p,{condition:s(),show:e.jsx(t,{severity:"warning",children:"Not enabled."}),elseShow:e.jsx(e.Fragment,{children:e.jsxs(v,{children:[e.jsxs(w,{children:[e.jsx(n,{children:e.jsx(t,{severity:"info",icon:!1,children:e.jsxs(E,{children:[e.jsx(g,{children:"1 connection = 7200 backend SDK requests per day"}),e.jsx(h,{title:"1 connection involves polling every 15 seconds and sending metrics every 60 seconds. This translates to 5 requests per minute, 300 requests per hour, and 7200 requests per day.",children:e.jsx(j,{})})]})})}),e.jsx(P,{selectedPeriod:a,setPeriod:i})]}),e.jsx(u,{data:r,plugins:[k],options:o,"aria-label":D(a)})]})})})};x.register(q,m,y,C,S,f,B);export{F as BackendConnections,F as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fB as oe,fC as ce,iW as de,dC as N,b9 as I,dD as Z,j as t,A as G,r as j,B as h,T as y,ep as $,l as _,F as U,I as Y,S as J,M as f,dY as Q,m as X,s as v,t as V,V as R,b as K,iX as ie,fn as ue,iY as H,al as he,c4 as pe,hT as ge,c9 as xe,E as me,c5 as be,i as O,G as je,H as ve,aE as fe,D as z,b1 as ye,b3 as Se}from"./index-CqYZiU1N.js";function E(e){oe(1,arguments);var s=de(e);return ce(s*1e3)}const Xe=()=>{const e="api/admin/impact-metrics/metadata",{data:s,refetch:a,loading:l,error:r}=N(I(e),()=>Z(I(e),"Impact metrics metadata"));return{metadata:s,refetch:a,loading:l,error:r}},Me=({value:e,onChange:s,options:a,loading:l=!1})=>t.jsx(G,{options:a,getOptionLabel:r=>r.displayName,value:a.find(r=>r.name===e)||null,onChange:(r,c)=>s((c==null?void 0:c.name)||""),disabled:l,renderOption:(r,c,{inputValue:n})=>j.createElement(h,{component:"li",...r,key:c.name},t.jsxs(h,{sx:{display:"flex",flexDirection:"column"},children:[t.jsx(y,{variant:"body2",children:t.jsx($,{search:n,children:c.displayName})}),t.jsx(y,{variant:"caption",color:"text.secondary",children:t.jsx($,{search:n,children:c.help})})]})),renderInput:r=>t.jsx(_,{...r,label:"Data series",placeholder:"Search for a metric…",variant:"outlined",size:"small",required:!0}),noOptionsText:"No metrics available",sx:{minWidth:300}}),ke=({value:e,onChange:s})=>t.jsxs(U,{variant:"outlined",size:"small",sx:{minWidth:200},children:[t.jsx(Y,{id:"range-select-label",children:"Time"}),t.jsxs(J,{labelId:"range-select-label",value:e,onChange:a=>s(a.target.value),label:"Time Range",children:[t.jsx(f,{value:"hour",children:"Last hour"}),t.jsx(f,{value:"day",children:"Last 24 hours"}),t.jsx(f,{value:"week",children:"Last 7 days"}),t.jsx(f,{value:"month",children:"Last 30 days"})]})]}),we=({value:e,onChange:s,seriesType:a})=>a==="unknown"?null:t.jsxs(U,{variant:"outlined",size:"small",sx:{minWidth:200},children:[t.jsx(Y,{id:"mode-select-label",children:"Mode"}),t.jsx(J,{labelId:"mode-select-label",value:e,onChange:l=>s(l.target.value),label:"Mode",children:a==="counter"?[t.jsx(f,{value:"rps",children:"Rate per second"},"rps"),t.jsx(f,{value:"count",children:"Count"},"count")]:[t.jsx(f,{value:"avg",children:"Average"},"avg"),t.jsx(f,{value:"sum",children:"Sum"},"sum")]})]}),B=e=>{switch(e){case"hour":return"minute";case"day":return"hour";case"week":return"day";case"month":return"week";default:return"day"}},Ae=e=>{switch(e){case"hour":return"HH:mm";case"day":return"HH:mm";case"week":return"MMM dd";case"month":return"MMM dd";default:return"MMM dd"}},W=e=>{const{__name__:s,...a}=e,l=Object.entries(a).filter(([r,c])=>r!=="__name__"&&c).map(([r,c])=>`${r}=${c}`).join(", ");return!s&&!l?"Series":s?l?`${s} (${l})`:s:l},Le=e=>e>=1e6?`${(e/1e6).toFixed(0)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:e.toString(),L=e=>e.startsWith("unleash_counter_")?"counter":e.startsWith("unleash_gauge_")?"gauge":"unknown",Ie=({formData:e,actions:s,metricSeries:a,loading:l})=>t.jsxs(h,{children:[t.jsxs(h,{sx:r=>({display:"flex",flexDirection:"column",gap:r.spacing(3)}),children:[t.jsx(y,{variant:"body2",color:"text.secondary",children:"Select a custom metric to see its value over time. This can help you understand the impact of your feature rollout on key outcomes, such as system performance, usage patterns or error rates."}),t.jsx(Me,{value:e.selectedSeries,onChange:s.handleSeriesChange,options:a,loading:l}),e.selectedSeries?t.jsxs(t.Fragment,{children:[t.jsx(ke,{value:e.selectedRange,onChange:s.setSelectedRange}),t.jsx(we,{value:e.aggregationMode,onChange:s.setAggregationMode,seriesType:L(e.selectedSeries)})]}):null]}),e.selectedSeries?t.jsx(Q,{sx:r=>({margin:r.spacing(1.5,0)}),control:t.jsx(X,{checked:e.beginAtZero,onChange:r=>s.setBeginAtZero(r.target.checked)}),label:"Begin at zero"}):null]}),q=e=>{const s=!!(e!=null&&e.series&&(e!=null&&e.range)),l=(()=>{if(!e)return"";const o=new URLSearchParams({series:e.series,range:e.range});if(e.aggregationMode!==void 0&&o.append("aggregationMode",e.aggregationMode),e.labels&&Object.keys(e.labels).length>0){const d=Object.entries(e.labels).reduce((p,[m,g])=>(g.length>0&&(p[m]=g),p),{});Object.keys(d).length>0&&o.append("labels",JSON.stringify(d))}return`api/admin/impact-metrics/?${o.toString()}`})(),{data:r,refetch:c,loading:n,error:u}=N(s?I(l):null,s?()=>Z(I(l),"Impact metrics data"):()=>Promise.resolve([]),{refreshInterval:30*1e3,revalidateOnFocus:!0});return{data:r||{series:[],labels:{}},refetch:c,loading:s?n:!1,error:u}},Te=({open:e,initialConfig:s})=>{const[a,l]=j.useState((s==null?void 0:s.title)||""),[r,c]=j.useState((s==null?void 0:s.selectedSeries)||""),[n,u]=j.useState((s==null?void 0:s.selectedRange)||"day"),[o,d]=j.useState((s==null?void 0:s.beginAtZero)||!1),[p,m]=j.useState((s==null?void 0:s.selectedLabels)||{}),[g,i]=j.useState(((s==null?void 0:s.aggregationMode)||L(r))==="counter"?"count":"avg"),{data:{labels:x}}=q(r?{series:r,range:n,aggregationMode:g}:void 0);j.useEffect(()=>{e&&s?(l(s.title||""),c(s.selectedSeries),u(s.selectedRange),d(s.beginAtZero),m(s.selectedLabels),i(s.aggregationMode||(L(s.selectedSeries)==="counter"?"count":"avg"))):e&&!s&&(l(""),c(""),u("day"),d(!1),m({}),i("count"))},[e,s]);const S=M=>{c(M),m({});const w=L(M);w==="counter"?i("count"):w==="gauge"&&i("avg")},k=()=>({title:a||void 0,selectedSeries:r,selectedRange:n,beginAtZero:o,selectedLabels:p,aggregationMode:g}),T=r.length>0;return{formData:{title:a,selectedSeries:r,selectedRange:n,beginAtZero:o,aggregationMode:g,selectedLabels:p},actions:{setTitle:l,setSelectedSeries:c,setSelectedRange:u,setBeginAtZero:d,setAggregationMode:i,setSelectedLabels:m,handleSeriesChange:S,getConfigToSave:k},isValid:T,currentAvailableLabels:x}},De=v("span")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Ce=({labelKey:e,options:s,value:a,onChange:l})=>{const r=a.includes("*"),c=`autocomplete-${e}`,n=`select-all-${e}`,u=s.length>=1e3;return t.jsxs(t.Fragment,{children:[t.jsx(Q,{sx:o=>({marginLeft:o.spacing(0)}),control:t.jsx(X,{id:n,size:"small",checked:r,onChange:o=>l(o.target.checked?["*"]:[]),inputProps:{"aria-describedby":c,"aria-label":`Select all ${e} options`}}),label:t.jsx(De,{children:"Select all"})}),t.jsx(G,{multiple:!0,id:c,options:s,value:r?s:a,onChange:(o,d)=>{l(d)},disabled:r,renderTags:(o,d)=>{const m=o.slice(-5),g=o.length-5;return t.jsxs(t.Fragment,{children:[m.map((i,x)=>{const{key:S,...k}=d({index:x});return j.createElement(V,{...k,key:S,label:i,size:"small"})}),g>0?t.jsxs(y,{component:"span",sx:{color:"text.secondary"},children:[" ","(+",g,")"]}):null]})},renderInput:o=>t.jsxs(t.Fragment,{children:[t.jsx(_,{...o,label:e,placeholder:r?void 0:"Select values…",variant:"outlined",size:"small",inputProps:{...o.inputProps,"aria-describedby":r?`${n}-description`:void 0}}),u&&t.jsx(R,{severity:"warning",sx:d=>({padding:d.spacing(1,2),marginTop:d.spacing(1)}),children:"Maximum of 1000 values loaded due to performance."})]})})]})},Re=({selectedLabels:e,onChange:s,availableLabels:a})=>{const l=(n,u)=>{const o={...e};u.length===0?delete o[n]:o[n]=u,s(o)},r=(n,u)=>{const o={...e};u?o[n]=["*"]:delete o[n],s(o)},c=()=>{s({})};return!a||Object.keys(a).length===0?null:t.jsxs(h,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[t.jsxs(h,{sx:{display:"flex",alignItems:"center",gap:1,width:"100%"},children:[t.jsx(y,{variant:"subtitle2",children:"Filter by labels"}),Object.keys(e).length>0&&t.jsx(V,{label:"Clear all",size:"small",variant:"outlined",onClick:c})]}),t.jsx(h,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:2,flexGrow:1},children:Object.entries(a).sort().map(([n,u])=>{const o=e[n]||[];return t.jsx(h,{sx:{display:"flex",flexDirection:"column",flexGrow:1},children:t.jsx(Ce,{labelKey:n,options:u,value:o,onChange:d=>l(n,d),handleAllToggle:r})},n)})})]})},_e=(e,s)=>{if(!s||s.length===0||e<=0)return 0;let a=0;for(let l=0;l<s.length;l++){const r=s.charCodeAt(l);a=(a<<5)-a+r,a=a&a}return Math.abs(a)%e},Pe=(e,s)=>{const a=K(),l=a.palette.charts.series,r=_e(l.length,s);return j.useMemo(()=>{if(!e||e.length===0)return{labels:[],datasets:[{data:[],borderColor:a.palette.primary.main,backgroundColor:a.palette.primary.light}]};if(e.length===1){const c=e[0],n=c.data.map(([o])=>new Date(o*1e3)),u=c.data.map(([,o])=>o);return{labels:n,datasets:[{data:u,borderColor:a.palette.primary.main,backgroundColor:a.palette.primary.light,label:W(c.metric)}]}}else{const c=new Set;if(e.forEach(d=>{d.data.forEach(([p])=>{c.add(p)})}),c.size===0)return{labels:[],datasets:[]};const n=Array.from(c).sort((d,p)=>d-p),u=n.map(d=>new Date(d*1e3)),o=e.map((d,p)=>{const m=W(d.metric),g=l[(p+r)%l.length],i=new Map(d.data),x=n.map(S=>i.get(S)??null);return{label:m,data:x,borderColor:g,backgroundColor:g,fill:!1}});return{labels:u,datasets:o}}},[e,a])},ee=({selectedSeries:e,selectedRange:s,selectedLabels:a,beginAtZero:l,aggregationMode:r,aspectRatio:c,overrideOptions:n={},errorTitle:u="Failed to load impact metrics.",emptyDataDescription:o="Send impact metrics using Unleash SDK and select data series to view the chart.",noSeriesPlaceholder:d,isPreview:p})=>{const{data:{start:m,end:g,series:i,debug:x},loading:S,error:k}=q(e?{series:e,range:s,aggregationMode:r,labels:Object.keys(a).length>0?a:void 0}:void 0),T=ie({fill:!0,type:"constant"}),M=Pe(i,x==null?void 0:x.query),w=!!k,A=S,se=!e||A||w,F=j.useMemo(()=>!A&&(!i||i.length===0||!M.datasets.some(b=>b.data.length>1)),[M,A,i]),D=m?E(Number.parseInt(m,10)):void 0,C=g?E(Number.parseInt(g,10)):void 0,ae=e?t.jsx(H,{description:o}):d||t.jsx(H,{title:"Select a metric series to view the chart.",description:""}),re=Object.keys(a).length>0,ne=F?ae:A,le=se?n:{...n,scales:{x:{type:"time",min:D==null?void 0:D.getTime(),max:C==null?void 0:C.getTime(),time:{unit:B(s),displayFormats:{[B(s)]:Ae(s)},tooltipFormat:"PPpp"},ticks:{maxRotation:45,minRotation:45,maxTicksLimit:8}},y:{beginAtZero:l,title:{display:r==="rps",text:r==="rps"?"Rate per second":""},ticks:{precision:0,callback:b=>typeof b=="number"?`${Le(b)}${r==="rps"?"/s":""}`:b}}},plugins:{legend:{display:i&&(re||i.length>1),position:"bottom",labels:{usePointStyle:!0,boxWidth:8,padding:12}}},animations:{x:{duration:0},y:{duration:0}}};return t.jsxs(t.Fragment,{children:[t.jsx(h,{sx:p?{}:{height:"100%",width:"100%","& > div":{height:"100% !important",width:"100% !important"}},children:t.jsx(ue,{data:F||A?T:M,aspectRatio:c,overrideOptions:le,cover:w?t.jsx(R,{severity:"error",children:u}):ne})}),p&&(x!=null&&x.query)?t.jsx(h,{sx:b=>({margin:b.spacing(2),padding:b.spacing(2),background:b.palette.background.elevation1}),children:t.jsx(y,{variant:"caption",color:"text.secondary",sx:{wordBreak:"break-all"},children:t.jsx("code",{children:x.query})})}):null,p&&(x!=null&&x.isTruncated)?t.jsx(h,{sx:b=>({padding:b.spacing(0,2)}),children:t.jsxs(R,{severity:"warning",children:["Showing only ",i.length," series due to performance. Please change filters for more accurate results."]})}):null]})},Fe=v(h)(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(3),[e.breakpoints.down("lg")]:{flex:"none"},[e.breakpoints.up("lg")]:{flex:"0 0 400px"}})),$e=v(h)(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",gap:e.spacing(2),[e.breakpoints.down("lg")]:{minHeight:"300px"},[e.breakpoints.up("lg")]:{minHeight:"400px"}})),Ve=({open:e,onClose:s,onSave:a,initialConfig:l,metricSeries:r,loading:c=!1})=>{const{formData:n,actions:u,isValid:o,currentAvailableLabels:d}=Te({open:e,initialConfig:l}),p=K(),m=he(p.breakpoints.down("lg")),g=()=>{o&&(a(u.getConfigToSave()),s())};return t.jsxs(pe,{open:e,onClose:s,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:"600px",maxHeight:"90vh"}},children:[t.jsx(ge,{children:l?"Edit Chart":"Add New Chart"}),t.jsxs(xe,{children:[t.jsxs(h,{sx:i=>({display:"flex",flexDirection:{xs:"column",lg:"row"},gap:i.spacing(3),pt:i.spacing(1),height:"100%"}),children:[t.jsxs(Fe,{children:[t.jsx(_,{label:"Chart Title (optional)",value:n.title,onChange:i=>u.setTitle(i.target.value),fullWidth:!0,variant:"outlined",size:"small"}),t.jsx(Ie,{formData:n,actions:u,metricSeries:r,loading:c})]}),t.jsx($e,{children:t.jsx(h,{sx:i=>({padding:i.spacing(1)}),children:t.jsx(ee,{selectedSeries:n.selectedSeries,selectedRange:n.selectedRange,selectedLabels:n.selectedLabels,beginAtZero:n.beginAtZero,aggregationMode:n.aggregationMode,isPreview:!0},m?"small":"large")})})]}),d?t.jsx(Re,{selectedLabels:n.selectedLabels,onChange:u.setSelectedLabels,availableLabels:d}):null]}),t.jsx(me,{}),t.jsxs(be,{sx:i=>({margin:i.spacing(2,3,3)}),children:[t.jsx(O,{onClick:s,children:"Cancel"}),t.jsx(O,{onClick:g,variant:"contained",disabled:!o,children:l?"Update":"Add Chart"})]})]})};var P={},He=ve;Object.defineProperty(P,"__esModule",{value:!0});var te=P.default=void 0,Oe=He(je()),ze=t,Ee=(0,Oe.default)((0,ze.jsx)("path",{d:"M20 9H4v2h16V9zM4 15h16v-2H4v2z"}),"DragHandle");te=P.default=Ee;const Be=e=>{const s=[];e.displayName&&s.push(`${e.displayName}`),s.push(`last ${e.selectedRange}`),e.aggregationMode==="rps"?s.push("rate per second"):e.aggregationMode==="count"?s.push("count"):e.aggregationMode==="avg"?s.push("average"):e.aggregationMode==="sum"&&s.push("sum");const a=Object.keys(e.selectedLabels).length;return a>0&&s.push(`${a} filter${a>1?"s":""}`),s.join(" • ")},We=v(fe)(({theme:e})=>({borderRadius:`${e.shape.borderRadiusMedium}px`,boxShadow:"none",display:"flex",flexDirection:"column",height:"100%"})),Ne=v(h)({flex:1,display:"flex",flexDirection:"column",minHeight:0}),Ze=v(h)(({theme:e})=>({position:"relative",minWidth:0,flexGrow:1,height:"100%",display:"flex",flexDirection:"column",margin:"auto 0",padding:e.spacing(3)})),Ge=v(h)(({theme:e})=>({display:"flex",gap:e.spacing(2),alignItems:"center",padding:e.spacing(1.5,2),borderBottom:`1px solid ${e.palette.divider}`})),Ue=v(h)(({theme:e})=>({display:"flex",alignItems:"center",cursor:"move",padding:e.spacing(.5),borderRadius:e.shape.borderRadius,color:e.palette.text.secondary,"&:hover":{backgroundColor:e.palette.action.hover,color:e.palette.text.primary}})),Ye=v(h)(({theme:e})=>({display:"flex",flexDirection:"column",justifyContent:"flex-end",flexGrow:1,overflow:"hidden",textOverflow:"ellipsis"})),Je=v(h)(({theme:e})=>({marginLeft:"auto",display:"flex",alignItems:"center",gap:e.spacing(.5)})),Ke=({config:e,onEdit:s,onDelete:a})=>t.jsxs(We,{children:[t.jsxs(Ge,{children:[t.jsx(Ue,{className:"grid-item-drag-handle",children:t.jsx(te,{fontSize:"small"})}),t.jsxs(Ye,{children:[e.title&&t.jsx(y,{variant:"h6",children:e.title}),t.jsx(y,{variant:"body2",color:"text.secondary",children:Be(e)})]}),t.jsxs(Je,{children:[t.jsx(z,{onClick:()=>s(e),children:t.jsx(ye,{})}),t.jsx(z,{onClick:()=>a(e.id),children:t.jsx(Se,{})})]})]}),t.jsx(Ne,{children:t.jsx(Ze,{children:t.jsx(ee,{selectedSeries:e.selectedSeries,selectedRange:e.selectedRange,selectedLabels:e.selectedLabels,beginAtZero:e.beginAtZero,aggregationMode:e.aggregationMode,aspectRatio:1.5,overrideOptions:{maintainAspectRatio:!1},emptyDataDescription:"Send impact metrics using Unleash SDK for this series to view the chart."})})})]});export{Ke as C,Ve as a,Xe as u};
|
|
1
|
+
import{fB as oe,fC as ce,iW as de,dC as N,b9 as I,dD as Z,j as t,A as G,r as j,B as h,T as y,ep as $,l as _,F as U,I as Y,S as J,M as f,dY as Q,m as X,s as v,t as V,V as R,b as K,iX as ie,fn as ue,iY as H,al as he,c4 as pe,hT as ge,c9 as xe,E as me,c5 as be,i as O,G as je,H as ve,aE as fe,D as z,b1 as ye,b3 as Se}from"./index-A5We7bvX.js";function E(e){oe(1,arguments);var s=de(e);return ce(s*1e3)}const Xe=()=>{const e="api/admin/impact-metrics/metadata",{data:s,refetch:a,loading:l,error:r}=N(I(e),()=>Z(I(e),"Impact metrics metadata"));return{metadata:s,refetch:a,loading:l,error:r}},Me=({value:e,onChange:s,options:a,loading:l=!1})=>t.jsx(G,{options:a,getOptionLabel:r=>r.displayName,value:a.find(r=>r.name===e)||null,onChange:(r,c)=>s((c==null?void 0:c.name)||""),disabled:l,renderOption:(r,c,{inputValue:n})=>j.createElement(h,{component:"li",...r,key:c.name},t.jsxs(h,{sx:{display:"flex",flexDirection:"column"},children:[t.jsx(y,{variant:"body2",children:t.jsx($,{search:n,children:c.displayName})}),t.jsx(y,{variant:"caption",color:"text.secondary",children:t.jsx($,{search:n,children:c.help})})]})),renderInput:r=>t.jsx(_,{...r,label:"Data series",placeholder:"Search for a metric…",variant:"outlined",size:"small",required:!0}),noOptionsText:"No metrics available",sx:{minWidth:300}}),ke=({value:e,onChange:s})=>t.jsxs(U,{variant:"outlined",size:"small",sx:{minWidth:200},children:[t.jsx(Y,{id:"range-select-label",children:"Time"}),t.jsxs(J,{labelId:"range-select-label",value:e,onChange:a=>s(a.target.value),label:"Time Range",children:[t.jsx(f,{value:"hour",children:"Last hour"}),t.jsx(f,{value:"day",children:"Last 24 hours"}),t.jsx(f,{value:"week",children:"Last 7 days"}),t.jsx(f,{value:"month",children:"Last 30 days"})]})]}),we=({value:e,onChange:s,seriesType:a})=>a==="unknown"?null:t.jsxs(U,{variant:"outlined",size:"small",sx:{minWidth:200},children:[t.jsx(Y,{id:"mode-select-label",children:"Mode"}),t.jsx(J,{labelId:"mode-select-label",value:e,onChange:l=>s(l.target.value),label:"Mode",children:a==="counter"?[t.jsx(f,{value:"rps",children:"Rate per second"},"rps"),t.jsx(f,{value:"count",children:"Count"},"count")]:[t.jsx(f,{value:"avg",children:"Average"},"avg"),t.jsx(f,{value:"sum",children:"Sum"},"sum")]})]}),B=e=>{switch(e){case"hour":return"minute";case"day":return"hour";case"week":return"day";case"month":return"week";default:return"day"}},Ae=e=>{switch(e){case"hour":return"HH:mm";case"day":return"HH:mm";case"week":return"MMM dd";case"month":return"MMM dd";default:return"MMM dd"}},W=e=>{const{__name__:s,...a}=e,l=Object.entries(a).filter(([r,c])=>r!=="__name__"&&c).map(([r,c])=>`${r}=${c}`).join(", ");return!s&&!l?"Series":s?l?`${s} (${l})`:s:l},Le=e=>e>=1e6?`${(e/1e6).toFixed(0)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:e.toString(),L=e=>e.startsWith("unleash_counter_")?"counter":e.startsWith("unleash_gauge_")?"gauge":"unknown",Ie=({formData:e,actions:s,metricSeries:a,loading:l})=>t.jsxs(h,{children:[t.jsxs(h,{sx:r=>({display:"flex",flexDirection:"column",gap:r.spacing(3)}),children:[t.jsx(y,{variant:"body2",color:"text.secondary",children:"Select a custom metric to see its value over time. This can help you understand the impact of your feature rollout on key outcomes, such as system performance, usage patterns or error rates."}),t.jsx(Me,{value:e.selectedSeries,onChange:s.handleSeriesChange,options:a,loading:l}),e.selectedSeries?t.jsxs(t.Fragment,{children:[t.jsx(ke,{value:e.selectedRange,onChange:s.setSelectedRange}),t.jsx(we,{value:e.aggregationMode,onChange:s.setAggregationMode,seriesType:L(e.selectedSeries)})]}):null]}),e.selectedSeries?t.jsx(Q,{sx:r=>({margin:r.spacing(1.5,0)}),control:t.jsx(X,{checked:e.beginAtZero,onChange:r=>s.setBeginAtZero(r.target.checked)}),label:"Begin at zero"}):null]}),q=e=>{const s=!!(e!=null&&e.series&&(e!=null&&e.range)),l=(()=>{if(!e)return"";const o=new URLSearchParams({series:e.series,range:e.range});if(e.aggregationMode!==void 0&&o.append("aggregationMode",e.aggregationMode),e.labels&&Object.keys(e.labels).length>0){const d=Object.entries(e.labels).reduce((p,[m,g])=>(g.length>0&&(p[m]=g),p),{});Object.keys(d).length>0&&o.append("labels",JSON.stringify(d))}return`api/admin/impact-metrics/?${o.toString()}`})(),{data:r,refetch:c,loading:n,error:u}=N(s?I(l):null,s?()=>Z(I(l),"Impact metrics data"):()=>Promise.resolve([]),{refreshInterval:30*1e3,revalidateOnFocus:!0});return{data:r||{series:[],labels:{}},refetch:c,loading:s?n:!1,error:u}},Te=({open:e,initialConfig:s})=>{const[a,l]=j.useState((s==null?void 0:s.title)||""),[r,c]=j.useState((s==null?void 0:s.selectedSeries)||""),[n,u]=j.useState((s==null?void 0:s.selectedRange)||"day"),[o,d]=j.useState((s==null?void 0:s.beginAtZero)||!1),[p,m]=j.useState((s==null?void 0:s.selectedLabels)||{}),[g,i]=j.useState(((s==null?void 0:s.aggregationMode)||L(r))==="counter"?"count":"avg"),{data:{labels:x}}=q(r?{series:r,range:n,aggregationMode:g}:void 0);j.useEffect(()=>{e&&s?(l(s.title||""),c(s.selectedSeries),u(s.selectedRange),d(s.beginAtZero),m(s.selectedLabels),i(s.aggregationMode||(L(s.selectedSeries)==="counter"?"count":"avg"))):e&&!s&&(l(""),c(""),u("day"),d(!1),m({}),i("count"))},[e,s]);const S=M=>{c(M),m({});const w=L(M);w==="counter"?i("count"):w==="gauge"&&i("avg")},k=()=>({title:a||void 0,selectedSeries:r,selectedRange:n,beginAtZero:o,selectedLabels:p,aggregationMode:g}),T=r.length>0;return{formData:{title:a,selectedSeries:r,selectedRange:n,beginAtZero:o,aggregationMode:g,selectedLabels:p},actions:{setTitle:l,setSelectedSeries:c,setSelectedRange:u,setBeginAtZero:d,setAggregationMode:i,setSelectedLabels:m,handleSeriesChange:S,getConfigToSave:k},isValid:T,currentAvailableLabels:x}},De=v("span")(({theme:e})=>({fontSize:e.fontSizes.smallBody})),Ce=({labelKey:e,options:s,value:a,onChange:l})=>{const r=a.includes("*"),c=`autocomplete-${e}`,n=`select-all-${e}`,u=s.length>=1e3;return t.jsxs(t.Fragment,{children:[t.jsx(Q,{sx:o=>({marginLeft:o.spacing(0)}),control:t.jsx(X,{id:n,size:"small",checked:r,onChange:o=>l(o.target.checked?["*"]:[]),inputProps:{"aria-describedby":c,"aria-label":`Select all ${e} options`}}),label:t.jsx(De,{children:"Select all"})}),t.jsx(G,{multiple:!0,id:c,options:s,value:r?s:a,onChange:(o,d)=>{l(d)},disabled:r,renderTags:(o,d)=>{const m=o.slice(-5),g=o.length-5;return t.jsxs(t.Fragment,{children:[m.map((i,x)=>{const{key:S,...k}=d({index:x});return j.createElement(V,{...k,key:S,label:i,size:"small"})}),g>0?t.jsxs(y,{component:"span",sx:{color:"text.secondary"},children:[" ","(+",g,")"]}):null]})},renderInput:o=>t.jsxs(t.Fragment,{children:[t.jsx(_,{...o,label:e,placeholder:r?void 0:"Select values…",variant:"outlined",size:"small",inputProps:{...o.inputProps,"aria-describedby":r?`${n}-description`:void 0}}),u&&t.jsx(R,{severity:"warning",sx:d=>({padding:d.spacing(1,2),marginTop:d.spacing(1)}),children:"Maximum of 1000 values loaded due to performance."})]})})]})},Re=({selectedLabels:e,onChange:s,availableLabels:a})=>{const l=(n,u)=>{const o={...e};u.length===0?delete o[n]:o[n]=u,s(o)},r=(n,u)=>{const o={...e};u?o[n]=["*"]:delete o[n],s(o)},c=()=>{s({})};return!a||Object.keys(a).length===0?null:t.jsxs(h,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[t.jsxs(h,{sx:{display:"flex",alignItems:"center",gap:1,width:"100%"},children:[t.jsx(y,{variant:"subtitle2",children:"Filter by labels"}),Object.keys(e).length>0&&t.jsx(V,{label:"Clear all",size:"small",variant:"outlined",onClick:c})]}),t.jsx(h,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:2,flexGrow:1},children:Object.entries(a).sort().map(([n,u])=>{const o=e[n]||[];return t.jsx(h,{sx:{display:"flex",flexDirection:"column",flexGrow:1},children:t.jsx(Ce,{labelKey:n,options:u,value:o,onChange:d=>l(n,d),handleAllToggle:r})},n)})})]})},_e=(e,s)=>{if(!s||s.length===0||e<=0)return 0;let a=0;for(let l=0;l<s.length;l++){const r=s.charCodeAt(l);a=(a<<5)-a+r,a=a&a}return Math.abs(a)%e},Pe=(e,s)=>{const a=K(),l=a.palette.charts.series,r=_e(l.length,s);return j.useMemo(()=>{if(!e||e.length===0)return{labels:[],datasets:[{data:[],borderColor:a.palette.primary.main,backgroundColor:a.palette.primary.light}]};if(e.length===1){const c=e[0],n=c.data.map(([o])=>new Date(o*1e3)),u=c.data.map(([,o])=>o);return{labels:n,datasets:[{data:u,borderColor:a.palette.primary.main,backgroundColor:a.palette.primary.light,label:W(c.metric)}]}}else{const c=new Set;if(e.forEach(d=>{d.data.forEach(([p])=>{c.add(p)})}),c.size===0)return{labels:[],datasets:[]};const n=Array.from(c).sort((d,p)=>d-p),u=n.map(d=>new Date(d*1e3)),o=e.map((d,p)=>{const m=W(d.metric),g=l[(p+r)%l.length],i=new Map(d.data),x=n.map(S=>i.get(S)??null);return{label:m,data:x,borderColor:g,backgroundColor:g,fill:!1}});return{labels:u,datasets:o}}},[e,a])},ee=({selectedSeries:e,selectedRange:s,selectedLabels:a,beginAtZero:l,aggregationMode:r,aspectRatio:c,overrideOptions:n={},errorTitle:u="Failed to load impact metrics.",emptyDataDescription:o="Send impact metrics using Unleash SDK and select data series to view the chart.",noSeriesPlaceholder:d,isPreview:p})=>{const{data:{start:m,end:g,series:i,debug:x},loading:S,error:k}=q(e?{series:e,range:s,aggregationMode:r,labels:Object.keys(a).length>0?a:void 0}:void 0),T=ie({fill:!0,type:"constant"}),M=Pe(i,x==null?void 0:x.query),w=!!k,A=S,se=!e||A||w,F=j.useMemo(()=>!A&&(!i||i.length===0||!M.datasets.some(b=>b.data.length>1)),[M,A,i]),D=m?E(Number.parseInt(m,10)):void 0,C=g?E(Number.parseInt(g,10)):void 0,ae=e?t.jsx(H,{description:o}):d||t.jsx(H,{title:"Select a metric series to view the chart.",description:""}),re=Object.keys(a).length>0,ne=F?ae:A,le=se?n:{...n,scales:{x:{type:"time",min:D==null?void 0:D.getTime(),max:C==null?void 0:C.getTime(),time:{unit:B(s),displayFormats:{[B(s)]:Ae(s)},tooltipFormat:"PPpp"},ticks:{maxRotation:45,minRotation:45,maxTicksLimit:8}},y:{beginAtZero:l,title:{display:r==="rps",text:r==="rps"?"Rate per second":""},ticks:{precision:0,callback:b=>typeof b=="number"?`${Le(b)}${r==="rps"?"/s":""}`:b}}},plugins:{legend:{display:i&&(re||i.length>1),position:"bottom",labels:{usePointStyle:!0,boxWidth:8,padding:12}}},animations:{x:{duration:0},y:{duration:0}}};return t.jsxs(t.Fragment,{children:[t.jsx(h,{sx:p?{}:{height:"100%",width:"100%","& > div":{height:"100% !important",width:"100% !important"}},children:t.jsx(ue,{data:F||A?T:M,aspectRatio:c,overrideOptions:le,cover:w?t.jsx(R,{severity:"error",children:u}):ne})}),p&&(x!=null&&x.query)?t.jsx(h,{sx:b=>({margin:b.spacing(2),padding:b.spacing(2),background:b.palette.background.elevation1}),children:t.jsx(y,{variant:"caption",color:"text.secondary",sx:{wordBreak:"break-all"},children:t.jsx("code",{children:x.query})})}):null,p&&(x!=null&&x.isTruncated)?t.jsx(h,{sx:b=>({padding:b.spacing(0,2)}),children:t.jsxs(R,{severity:"warning",children:["Showing only ",i.length," series due to performance. Please change filters for more accurate results."]})}):null]})},Fe=v(h)(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(3),[e.breakpoints.down("lg")]:{flex:"none"},[e.breakpoints.up("lg")]:{flex:"0 0 400px"}})),$e=v(h)(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",gap:e.spacing(2),[e.breakpoints.down("lg")]:{minHeight:"300px"},[e.breakpoints.up("lg")]:{minHeight:"400px"}})),Ve=({open:e,onClose:s,onSave:a,initialConfig:l,metricSeries:r,loading:c=!1})=>{const{formData:n,actions:u,isValid:o,currentAvailableLabels:d}=Te({open:e,initialConfig:l}),p=K(),m=he(p.breakpoints.down("lg")),g=()=>{o&&(a(u.getConfigToSave()),s())};return t.jsxs(pe,{open:e,onClose:s,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:"600px",maxHeight:"90vh"}},children:[t.jsx(ge,{children:l?"Edit Chart":"Add New Chart"}),t.jsxs(xe,{children:[t.jsxs(h,{sx:i=>({display:"flex",flexDirection:{xs:"column",lg:"row"},gap:i.spacing(3),pt:i.spacing(1),height:"100%"}),children:[t.jsxs(Fe,{children:[t.jsx(_,{label:"Chart Title (optional)",value:n.title,onChange:i=>u.setTitle(i.target.value),fullWidth:!0,variant:"outlined",size:"small"}),t.jsx(Ie,{formData:n,actions:u,metricSeries:r,loading:c})]}),t.jsx($e,{children:t.jsx(h,{sx:i=>({padding:i.spacing(1)}),children:t.jsx(ee,{selectedSeries:n.selectedSeries,selectedRange:n.selectedRange,selectedLabels:n.selectedLabels,beginAtZero:n.beginAtZero,aggregationMode:n.aggregationMode,isPreview:!0},m?"small":"large")})})]}),d?t.jsx(Re,{selectedLabels:n.selectedLabels,onChange:u.setSelectedLabels,availableLabels:d}):null]}),t.jsx(me,{}),t.jsxs(be,{sx:i=>({margin:i.spacing(2,3,3)}),children:[t.jsx(O,{onClick:s,children:"Cancel"}),t.jsx(O,{onClick:g,variant:"contained",disabled:!o,children:l?"Update":"Add Chart"})]})]})};var P={},He=ve;Object.defineProperty(P,"__esModule",{value:!0});var te=P.default=void 0,Oe=He(je()),ze=t,Ee=(0,Oe.default)((0,ze.jsx)("path",{d:"M20 9H4v2h16V9zM4 15h16v-2H4v2z"}),"DragHandle");te=P.default=Ee;const Be=e=>{const s=[];e.displayName&&s.push(`${e.displayName}`),s.push(`last ${e.selectedRange}`),e.aggregationMode==="rps"?s.push("rate per second"):e.aggregationMode==="count"?s.push("count"):e.aggregationMode==="avg"?s.push("average"):e.aggregationMode==="sum"&&s.push("sum");const a=Object.keys(e.selectedLabels).length;return a>0&&s.push(`${a} filter${a>1?"s":""}`),s.join(" • ")},We=v(fe)(({theme:e})=>({borderRadius:`${e.shape.borderRadiusMedium}px`,boxShadow:"none",display:"flex",flexDirection:"column",height:"100%"})),Ne=v(h)({flex:1,display:"flex",flexDirection:"column",minHeight:0}),Ze=v(h)(({theme:e})=>({position:"relative",minWidth:0,flexGrow:1,height:"100%",display:"flex",flexDirection:"column",margin:"auto 0",padding:e.spacing(3)})),Ge=v(h)(({theme:e})=>({display:"flex",gap:e.spacing(2),alignItems:"center",padding:e.spacing(1.5,2),borderBottom:`1px solid ${e.palette.divider}`})),Ue=v(h)(({theme:e})=>({display:"flex",alignItems:"center",cursor:"move",padding:e.spacing(.5),borderRadius:e.shape.borderRadius,color:e.palette.text.secondary,"&:hover":{backgroundColor:e.palette.action.hover,color:e.palette.text.primary}})),Ye=v(h)(({theme:e})=>({display:"flex",flexDirection:"column",justifyContent:"flex-end",flexGrow:1,overflow:"hidden",textOverflow:"ellipsis"})),Je=v(h)(({theme:e})=>({marginLeft:"auto",display:"flex",alignItems:"center",gap:e.spacing(.5)})),Ke=({config:e,onEdit:s,onDelete:a})=>t.jsxs(We,{children:[t.jsxs(Ge,{children:[t.jsx(Ue,{className:"grid-item-drag-handle",children:t.jsx(te,{fontSize:"small"})}),t.jsxs(Ye,{children:[e.title&&t.jsx(y,{variant:"h6",children:e.title}),t.jsx(y,{variant:"body2",color:"text.secondary",children:Be(e)})]}),t.jsxs(Je,{children:[t.jsx(z,{onClick:()=>s(e),children:t.jsx(ye,{})}),t.jsx(z,{onClick:()=>a(e.id),children:t.jsx(Se,{})})]})]}),t.jsx(Ne,{children:t.jsx(Ze,{children:t.jsx(ee,{selectedSeries:e.selectedSeries,selectedRange:e.selectedRange,selectedLabels:e.selectedLabels,beginAtZero:e.beginAtZero,aggregationMode:e.aggregationMode,aspectRatio:1.5,overrideOptions:{maintainAspectRatio:!1},emptyDataDescription:"Send impact metrics using Unleash SDK for this series to view the chart."})})})]});export{Ke as C,Ve as a,Xe as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,e2 as t}from"./index-
|
|
1
|
+
import{j as e,e2 as t}from"./index-A5We7bvX.js";const a=()=>e.jsx(t,{to:"/projects?create=true",replace:!0});export{a as default};
|
package/frontend/build/static/{FeatureMetricsChart-ClbKeGOa.js → FeatureMetricsChart-CQkGp91T.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jc as c,dq as m,iZ as u,bv as x,b as g,bs as f,r as d,j as b,jq as C,i$ as j,j0 as v,j1 as q,ji as M,jv as S,jl as $,j5 as D,j4 as E,j3 as T}from"./index-
|
|
1
|
+
import{jc as c,dq as m,iZ as u,bv as x,b as g,bs as f,r as d,j as b,jq as C,i$ as j,j0 as v,j1 as q,ji as M,jv as S,jl as $,j5 as D,j4 as E,j3 as T}from"./index-A5We7bvX.js";import{d as L}from"./FeatureViewLazyExport-CgntSCvS.js";import"./MarkCompletedDialogue-Bw9Iccid.js";import"./aggregateFeatureMetrics-Dli6i5No.js";import"./FeatureStaleDialog-DKeGFuL1.js";import"./ChartItem-COMyVdgD.js";const h=(e,l,s)=>{const a={label:"Total requests",borderColor:e.palette.primary.main,backgroundColor:e.palette.primary.main,data:p(l,s,o=>o.yes+o.no),elements:{point:{radius:6,pointStyle:"circle"},line:{borderDash:[8,4]}}},t={label:"Exposed",borderColor:e.palette.success.main,backgroundColor:e.palette.success.main,data:p(l,s,o=>o.yes),elements:{point:{radius:6,pointStyle:"triangle"}}},r={label:"Not exposed",borderColor:e.palette.error.main,backgroundColor:e.palette.error.main,data:p(l,s,o=>o.no),elements:{point:{radius:6,pointStyle:"triangle",pointRotation:180}}};return{datasets:[t,r,a]}},p=(e,l,s)=>e.map(a=>({x:a.timestamp,y:s(a),variants:a.variants||{}})),k=(e,l)=>{if(l===0)return"";const[s,a]=e,t=Math.floor(Number(a)/l*100);return`${a} (${t}%) - ${s}`},O=(e,l,s,a)=>({locale:a.locale,responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},color:e.palette.text.secondary,plugins:{tooltip:{backgroundColor:e.palette.background.paper,bodyColor:e.palette.text.primary,titleColor:e.palette.text.secondary,borderColor:e.palette.primary.main,borderWidth:1,padding:10,boxPadding:5,usePointStyle:!0,itemSort:(t,r)=>{const o=["Total requests","Exposed","Not exposed"],n=o.indexOf(t.dataset.label),i=o.indexOf(r.dataset.label);return n-i},callbacks:{label:t=>`${t.formattedValue} - ${t.dataset.label}`,afterLabel:t=>{const r=t.dataset.data[t.dataIndex];if(t.dataset.label!=="Exposed"||r.variants===void 0)return"";const{disabled:o,...n}=r.variants;return Object.entries(n).map(i=>k(i,r.y)).join(`
|
|
2
2
|
`)},title:t=>`Time: ${s>48?m(t[0].parsed.x,a.locale,"UTC"):u(t[0].parsed.x,a.locale)}`}},legend:{position:"top",align:"end",labels:{boxWidth:10,boxHeight:10,usePointStyle:!0}},title:{text:P(s),position:"top",align:"start",display:!0,font:{size:16,weight:"400"},color:e.palette.text.primary}},scales:{y:{type:"linear",title:{display:!0,text:"Number of requests",color:e.palette.text.secondary},suggestedMin:0,ticks:{precision:0,color:e.palette.text.secondary},grid:{color:e.palette.divider,borderColor:e.palette.divider}},x:{type:"time",time:{unit:s>48?"day":"hour"},grid:{display:!1},ticks:{callback:(t,r,o)=>s>48?x(o[r].value,a.locale,"UTC"):u(o[r].value,a.locale),color:e.palette.text.secondary}}}}),P=e=>e===1?"Requests in the last hour":`Requests in the last ${L(e)}`;c.font={...c.font,family:"Sen",size:13,weight:"400"};const V=({metrics:e,hoursBack:l,statsSectionId:s})=>{const a=g(),{locationSettings:t}=f(),r=d.useMemo(()=>[...e].sort((i,y)=>i.timestamp.localeCompare(y.timestamp)),[e]),o=d.useMemo(()=>O(a,r,l,t),[a,r,l,t]),n=d.useMemo(()=>h(a,r,t),[a,r,t]);return b.jsx("div",{style:{height:400},children:b.jsx(C,{options:o,data:n,"aria-label":"A feature metrics line chart, with three lines: all requests, positive requests, and negative requests.","aria-describedby":s})})};j.register(v,q,M,S,$,D,E,T);export{V as FeatureMetricsChart,V as default};
|
package/frontend/build/static/{FeatureStaleDialog-DZvKjxPB.js → FeatureStaleDialog-DKeGFuL1.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{G as W,H as Y,j as t,A as J,l as K,C as I,bh as le,m as ce,o as de,iB as ue,n as pe,s as j,b as Q,T as C,u as he,ba as ge,r as b,b9 as me,bb as fe,bd as xe,as as X,d1 as z,c2 as be,c0 as ve,iC as ye,c$ as Se,d4 as H,b5 as V,iD as Te,d3 as je,d2 as Ee,iE as Ce,cs as Re,bE as Z,bt as ee,bc as te,iF as we,iG as Ae,iH as ke,iI as De,hP as Ie,hF as ae,iJ as Pe,i as Oe,iK as Fe,db as se,aQ as q,bB as _e,fN as Ve,e as $,bF as $e,bD as Be,bK as qe,b$ as Ne,hS as Le,iL as Ue,h as _,eR as ze,b8 as He,dv as Me,bp as Ge,aU as We,aV as ne,aY as N,V as Ye,d5 as Je,aR as Ke,bi as M,bf as re,iM as Qe,iN as Xe,B as Ze,aq as et,hD as tt,iO as at,cK as st,iP as nt,fL as rt}from"./index-
|
|
1
|
+
import{G as W,H as Y,j as t,A as J,l as K,C as I,bh as le,m as ce,o as de,iB as ue,n as pe,s as j,b as Q,T as C,u as he,ba as ge,r as b,b9 as me,bb as fe,bd as xe,as as X,d1 as z,c2 as be,c0 as ve,iC as ye,c$ as Se,d4 as H,b5 as V,iD as Te,d3 as je,d2 as Ee,iE as Ce,cs as Re,bE as Z,bt as ee,bc as te,iF as we,iG as Ae,iH as ke,iI as De,hP as Ie,hF as ae,iJ as Pe,i as Oe,iK as Fe,db as se,aQ as q,bB as _e,fN as Ve,e as $,bF as $e,bD as Be,bK as qe,b$ as Ne,hS as Le,iL as Ue,h as _,eR as ze,b8 as He,dv as Me,bp as Ge,aU as We,aV as ne,aY as N,V as Ye,d5 as Je,aR as Ke,bi as M,bf as re,iM as Qe,iN as Xe,B as Ze,aq as et,hD as tt,iO as at,cK as st,iP as nt,fL as rt}from"./index-A5We7bvX.js";var L={},ot=Y;Object.defineProperty(L,"__esModule",{value:!0});var oe=L.default=void 0,it=ot(W()),lt=t,ct=(0,it.default)((0,lt.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10H7v-2h10v2z"}),"IndeterminateCheckBox");oe=L.default=ct;const dt=ue(),Yt=({options:e,selectedOptions:n,indeterminateOptions:s,tagType:u,existingTags:o,disabled:l=!1,onChange:a})=>{const i=t.jsx(pe,{fontSize:"small"}),d=p=>p.inputValue?p.inputValue:p.title,m=({key:p,...h},r,{selected:g})=>{const y=(s==null?void 0:s.some(v=>v.title===r.title))??!1;return t.jsxs("li",{...h,children:[t.jsx(I,{condition:!!r.inputValue,show:t.jsx(le,{sx:{mr:v=>v.spacing(.5)}}),elseShow:t.jsx(ce,{icon:i,checkedIcon:t.jsx(de,{fontSize:"small"}),indeterminateIcon:t.jsx(oe,{fontSize:"small"}),sx:{mr:v=>v.spacing(.5)},checked:g&&!y,indeterminate:y})}),r.title]},p)},f=(p,h)=>{const r=h.inputValue.trim(),g=dt(p,{...h,inputValue:r}),y=p.some(v=>r===v.title);return r.length>=2&&!y&&g.push({inputValue:r,title:`Create new value "${r}"`}),g};return t.jsx(J,{multiple:!0,id:"checkboxes-tag",sx:{marginTop:p=>p.spacing(2),width:500},disableCloseOnSelect:!0,options:e,value:n,isOptionEqualToValue:(p,h)=>h.inputValue&&h.inputValue!==""?p.title===h.inputValue:p.title===h.title,getOptionLabel:d,renderOption:m,filterOptions:f,ListboxProps:{style:{maxHeight:200,overflow:"auto"}},onChange:a,renderInput:p=>t.jsx(K,{...p,label:"Select values",placeholder:"Select values"}),disabled:l})},ut=j("li")({flexDirection:"column"}),Jt=({options:e,value:n,disabled:s=!1,onChange:u})=>{const o=Q();return t.jsx(J,{disablePortal:!0,disabled:s,id:"tag-type-select",sx:{marginTop:l=>l.spacing(2),width:500},options:e,disableClearable:!0,value:n,getOptionLabel:l=>l.name,renderOption:({key:l,...a},i)=>t.jsxs(ut,{...a,style:{alignItems:"flex-start",gap:o.spacing(.5)},children:[t.jsx(C,{variant:"body1",children:i.name}),t.jsx(C,{variant:"caption",children:i.description})]},l),renderInput:l=>t.jsx(K,{...l,label:"Tag type",value:n}),onChange:u,ListboxProps:{style:{maxHeight:200,overflow:"auto"}}})},Kt=()=>{const{makeRequest:e,createRequest:n,errors:s,loading:u}=he({propagateErrors:!0});return{createTag:async a=>{const d=n("api/admin/tags",{method:"POST",body:JSON.stringify(a)});return e(d.caller,d.id)},bulkUpdateTags:async(a,i)=>{const d=`api/admin/projects/${i}/tags`,m=n(d,{method:"PUT",body:JSON.stringify(a)});return e(m.caller,m.id)},errors:s,loading:u}},Qt=(e,n={})=>{const s=async()=>{const m=me(`api/admin/tags/${e}`);return(await fetch(m,{method:"GET"}).then(fe("Tags"))).json()},u=`api/admin/tags/${e}`,{data:o,error:l}=ge(!!e,{tags:[]},u,s,n),[a,i]=b.useState(!l&&!o),d=()=>{xe(u)};return b.useEffect(()=>{i(!l&&!o)},[o,l]),{tags:(o==null?void 0:o.tags)||[],error:l,loading:a,refetch:d}},pt=j("div")({display:"flex",flexDirection:"column"}),ht=({strategy:e,setStrategy:n,projectId:s,environment:u,editable:o,permission:l=je})=>{const{trackEvent:a}=X(),[i,d]=b.useState([]),m=Q(),f=e!=null&&e.parameters&&"stickiness"in(e==null?void 0:e.parameters)?String(e.parameters.stickiness):"default";b.useEffect(()=>{d((e.variants||[]).map(r=>({...r,new:o||!1,isValid:!0,id:z(),overrides:[]})))},[]),b.useEffect(()=>{n(r=>({...r,variants:i.map(g=>({stickiness:f,name:g.name,weight:g.weight,payload:g.payload,weightType:g.weightType}))}))},[f,JSON.stringify(i)]);const p=(r,g)=>{d(y=>H(y.map(v=>v.id===g?r:v),1e3))},h=()=>{const r=z();d(g=>[...g,{name:"",weightType:Ee.VARIABLE,weight:0,stickiness:f,new:!0,isValid:!1,id:r}]),a("strategy-variants",{props:{eventType:"variant added"}})};return t.jsxs(t.Fragment,{children:[t.jsxs(C,{component:"h3",sx:{m:0,display:"flex",gap:"1ch"},variant:"h3",children:["Variants",t.jsx(be,{htmlTooltip:!0,tooltip:t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Variants allow to attach one or more values to this strategy. Variants at the strategy level override variants at the feature level."}),t.jsx(ve,{target:"_blank",href:"https://docs.getunleash.io/reference/strategy-variants",children:"Learn more"})]})})]}),t.jsxs(pt,{children:[t.jsx(ye,{}),i.map((r,g)=>t.jsx(Se,{disableOverrides:!0,variant:r,variants:i,updateVariant:y=>p(y,r.id),removeVariant:()=>d(y=>H(y.filter(v=>v.id!==r.id),1e3)),decorationColor:m.palette.variants[g%m.palette.variants.length]},r.id))]}),t.jsx(V,{onClick:h,variant:"outlined",permission:l,projectId:s,environmentId:u,"data-testid":"ADD_STRATEGY_VARIANT_BUTTON",children:"Add variant"}),t.jsx(Te,{variants:i})]})},gt=j("form")(({theme:e})=>({display:"grid",gap:e.spacing(2)})),G=j("hr")(({theme:e})=>({width:"100%",height:"1px",margin:e.spacing(2,0),border:"none",background:e.palette.background.elevation2})),mt=j("div")(({theme:e})=>({display:"flex",justifyContent:"end",gap:e.spacing(2),paddingBottom:e.spacing(10)})),ft=({projectId:e,environmentId:n,permission:s,onSubmit:u,onCancel:o,loading:l,strategy:a,setStrategy:i,segments:d,setSegments:m,errors:f})=>{const p=Ce(a.constraints),h=Re(s,e,n),{strategyDefinition:r}=Z(a==null?void 0:a.name),g=ee(),{uiConfig:y,error:v,loading:P}=te();if(v)throw v;if(P||!r)return null;const O=S=>r.parameters.find(E=>E.name===S),R=(S,E)=>{const w=O(S);if(S!=="groupId"){const D=Fe(w,E);return D?(f.setFormError(S,D),!1):(f.removeFormError(S),!0)}return!0},c=()=>r.parameters.map(S=>S.name).map(S=>{var E;return R(S,(E=a.parameters)==null?void 0:E[S])}).every(Boolean),k=()=>{g(`/projects/${e}/settings/default-strategy`)},F=async S=>{if(S.preventDefault(),c())u();else return};return t.jsxs(gt,{onSubmit:F,children:[t.jsx(we,{title:a.title||"",setTitle:S=>{i(E=>({...E,title:S}))}}),t.jsx(Ae,{segments:d,setSegments:m,projectId:e}),t.jsx(ke,{projectId:e,environmentId:n,strategy:a,setStrategy:i}),t.jsx(G,{}),t.jsx(De,{strategy:a,strategyDefinition:r,setStrategy:i,validateParameter:R,errors:f,hasAccess:h}),t.jsx(I,{condition:a.parameters!=null&&"stickiness"in a.parameters,show:t.jsx(ht,{strategy:a,setStrategy:i,environment:n,projectId:e,permission:[Ie,ae]})}),t.jsx(G,{}),t.jsxs(mt,{children:[t.jsx(V,{permission:s,projectId:e,environmentId:n,variant:"contained",color:"primary",type:"submit",disabled:l||!p||f.hasFormErrors(),"data-testid":Pe,children:"Save strategy"}),t.jsx(Oe,{type:"button",color:"primary",onClick:o||k,disabled:l,children:"Cancel"})]})]})},xt=(e,n)=>{var a,i;const{project:s,refetch:u}=se(e),o={name:"flexibleRollout",constraints:[],parameters:{rollout:"100",stickiness:s.defaultStickiness||"default",groupId:""}},l=(i=(a=s.environments)==null?void 0:a.find(d=>d.environment===n))==null?void 0:i.defaultStrategy;return{defaultStrategyFallback:o,strategy:l,refetch:u}},Xt=()=>{const e=q("projectId"),n=_e("environmentId"),{refetch:s}=se(e),{defaultStrategyFallback:u,strategy:o,refetch:l}=xt(e,n),[a,i]=b.useState(o||u),[d,m]=b.useState([]),{updateDefaultStrategy:f,loading:p}=Ve(),{strategyDefinition:h}=Z(a==null?void 0:a.name),{setToastData:r,setToastApiError:g}=$(),y=$e(),{uiConfig:v}=te(),{unleashUrl:P}=v,O=ee(),{trackEvent:R}=X(),{segments:c,refetchSegments:k}=Be();b.useEffect(()=>{if(c&&(o!=null&&o.segments)){const w=[];for(const D of o==null?void 0:o.segments)w.push(...c.filter(T=>T.id===D));m(w)}},[JSON.stringify(c),JSON.stringify(o==null?void 0:o.segments)]);const F=bt(a,d),S=async w=>{await f(e,n,w),R("default_strategy",{props:{action:"edit",hasTitle:!!w.title}}),k(),s(),r({text:"Default Strategy updated",type:"success"})},E=async()=>{const w=`/projects/${e}/settings/default-strategy`;try{await S(F),await l(),O(w)}catch(D){g(_(D))}};return!h||!a?null:t.jsx(qe,{modal:!0,title:Ne((a==null?void 0:a.name)??""),description:yt,documentationLink:St,documentationLinkLabel:Tt,formatApiCode:()=>vt(e,n,F,h,P),children:t.jsx(ft,{projectId:e,strategy:a,setStrategy:i,segments:d,setSegments:m,environmentId:n,onSubmit:E,loading:p,permission:[Le,ae],errors:y,isChangeRequest:!1})})},bt=(e,n)=>({name:e.name,title:e.title,constraints:e.constraints??[],parameters:e.parameters??{},variants:e.variants??[],segments:n.map(s=>s.id),disabled:e.disabled??!1}),vt=(e,n,s,u,o)=>{if(!o)return"";const l={...s,parameters:Ue(s.parameters??{},u)},a=`${o}/api/admin/projects/${e}/environments/${n}/default-strategy}`,i=JSON.stringify(l,void 0,2);return`curl --location --request PUT '${a}' \\
|
|
2
2
|
--header 'Authorization: INSERT_API_KEY' \\
|
|
3
3
|
--header 'Content-Type: application/json' \\
|
|
4
4
|
--data-raw '${i}'`},yt=`
|