@deephaven/code-studio 0.38.1 → 0.39.1-beta.0
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/build/assets/AppRoot-1a29b8a5.js +42 -0
- package/build/assets/AppRoot-1a29b8a5.js.map +1 -0
- package/build/assets/AppRoot-44d1b9c4.css +1 -0
- package/build/assets/index-9a42370c.js +6 -0
- package/build/assets/index-9a42370c.js.map +1 -0
- package/build/assets/{index-565638f1.js → index-a8ae5175.js} +2 -2
- package/build/assets/index-a8ae5175.js.map +1 -0
- package/build/assets/useConnection-fb76a373.js +5 -0
- package/build/assets/useConnection-fb76a373.js.map +1 -0
- package/build/index.html +2 -2
- package/package.json +31 -31
- package/build/assets/AppRoot-86cdc34b.css +0 -1
- package/build/assets/AppRoot-fea00f9f.js +0 -42
- package/build/assets/AppRoot-fea00f9f.js.map +0 -1
- package/build/assets/index-565638f1.js.map +0 -1
- package/build/assets/index-8f7fbfbf.js +0 -6
- package/build/assets/index-8f7fbfbf.js.map +0 -1
- package/build/assets/useConnection-c96fd538.js +0 -5
- package/build/assets/useConnection-c96fd538.js.map +0 -1
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import{C as r,G as X,A as w,I as Yu,B,F as K,J as Ac,H as ae,K as he,L as Aa,M as Ts,N as Ge,O as Te,P as _c,Q as Je,S as er,T as qu,U as Xu,V as Zu,W as Qu,X as de,R as ll,Y as od,Z as ze,_ as tr,$ as Ju,a0 as em,a1 as Pc,a2 as Ae,a3 as _a,E as tm,D as $t,a4 as Al,a5 as jc,a6 as nr,a7 as nm,a8 as In,a9 as sm,aa as im,ab as om,ac as lm,ad as Pa,ae as am,af as rm,ag as dm,ah as ld,ai as cm,aj as ad,ak as hm,al as um,am as mm,an as gm,ao as pm,ap as fm,aq as gt,ar as Hc,as as Cm,at as Uc,au as Sm,av as Vc,aw as bm,ax as wm,ay as vm,az as Tm,aA as rd,aB as Em}from"./vendor-4a7e2c7c.js";import{P as ve,s as I,T as _l,B as _,a as N,S as Ve,M as Se,K as Ee,G as qn,b as en,C as se,c as nn,D as Wn,d as xi,e as Pl,f as tt,g as co,I as Ei,U as ym,h as pe,i as F,j as Zs,F as Gn,k as gn,u as sr,E as Fe,l as k,m as jn,n as Es,o as tl,p as lt,q as We,r as ot,t as jl,v as Rm,O as Vn,w as xm,x as hn,y as rn,z as Im,A as Dm,R as Hl,H as zn,J as Ul,L as Bc,N as $c,Q as Fm,V as Nm,W as dd,X as $e,Y as cd,Z as Wc,_ as ir,$ as hd,a0 as io,a1 as Gc,a2 as km,a3 as zc,a4 as Mm,a5 as sn,a6 as Lm,a7 as Om,a8 as Am,a9 as _m,aa as Pm,ab as jm,ac as Hm,ad as Um,ae as Vm,af as Bm,ag as $m,ah as Wm}from"./useConnection-c96fd538.js";import{e as Kn,l as xn,K as tn,a as ud,R as Gm,b as Cs,W as zm}from"./monaco-6eaf53f7.js";import{v as ja,d as Km,a as Kc,b as or,L as Nn,c as ho,e as $n,f as Yc,g as ee,h as md,i as Ym,j as qm,k as Xm,l as Zm,m as Wt,n as vs,o as qc,p as Yn,q as Vl,r as yi,s as Qm,t as Jm,u as gd,w as al,x as pd,y as Xc,z as eg,A as uo,B as Zc,C as tg,D as ng,T as Xe,E as lr,F as ar,G as rl,H as Ln,I as sg,J as ig,K as og,M as lg,N as ag,O as rr,P as ys,Q as fd,R as mo,S as dr,U as cr,V as Qc,W as rg,X as Bl,Y as dg,Z as dl,_ as cg,$ as hr,a0 as Jc,a1 as Gs,a2 as hg,a3 as ug,a4 as mg,a5 as gg,a6 as pg,a7 as fg,a8 as Cd,a9 as ma,aa as Cg,ab as Sg,ac as bg,ad as $l,ae as Wl,af as wg,ag as vg,ah as Gl,ai as eh,aj as Tg,ak as Eg,al as yg,am as th,an as Rg,ao as xg,ap as Ig,aq as Dg,ar as Fg,as as Ng,at as kg,au as Mg,av as Lg,aw as Og,ax as Ag,ay as _g,az as Pg,aA as nh,aB as jg,aC as Ha,aD as Ua,aE as Hg,aF as Ug,aG as Vg,aH as Bg,aI as $g,aJ as Wg,aK as Gg,aL as zg,aM as Kg,aN as Yg,aO as qg,aP as Xg,aQ as Zg,aR as Sd,aS as Qg,aT as Jg,aU as ep}from"./index-8f7fbfbf.js";import{P as cl,b as tp,h as np,p as sp,o as ip,s as op,t as lp,c as ga}from"./plotly-788bff8c.js";import"./helpers-042e6b4d.js";class ur{static isDark(e){const t=document.createElement("div");t.style.display="none",t.style.color=e;const n=getComputedStyle(document.body.appendChild(t)).color,s=n.match(/\d+/g);let i=[];if(s)i=s.map(l=>parseInt(l,10));else throw new Error(`Invalid color received. Got ${n}`);return document.body.removeChild(t),ur.getBrightness(i)<125}static getBrightness(e){return Math.round((e[0]*299+e[1]*587+e[2]*114)/1e3)}}const sh=ur,ap="table_",bd="column_",rp=new Set(["in","not","i","ii","k"]),dp=new Set(["abstract","continue","for","new","switch","assert","default","if","package","synchronized","boolean","do","goto","private","this","break","double","implements","protected","throw","byte","else","import","public","throws","case","enum","instanceof","return","transient","catch","extends","int","short","try","char","final","interface","static","void","class","finally","long","strictfp","volatile","const","float","native","super","while","null","true","false"]),cp=/[^a-zA-Z0-9_$+@-]/g,hp=/[^A-Za-z0-9_$]/g;class Hs{static legalize=(e,t,n,s,i)=>{let o=e.trim().replace(/[- ]/g,"_");return s&&(rp.has(o)||dp.has(o))&&(o=t+o),o=o.replace(n,""),o||(o=t+i),Number.isNaN(Number(o.charAt(0)))||(o=t+o),o};static legalizeTableName=e=>Hs.legalize(e,ap,cp,!1,0);static legalizeColumnNames=e=>{const t=[];return e.forEach((n,s)=>{let i=Hs.legalizeColumnName(n,s);t.includes(i)&&(i=bd+s),t.push(i)}),t};static legalizeColumnName=(e,t=0)=>Hs.legalize(e,bd,hp,!0,t);static isValidTableName=e=>Hs.legalizeTableName(e)===e;static isValidColumnName=e=>Hs.legalizeColumnName(e)===e}const Ii=Hs;function up(c,e){return c?c.closest(`.${e}`):null}const mp={getClosestByClassName:up};class gp{pending=[];resolved=[];add(e,t){const n=ve.makeCancelable(e,t);return this.pending.push(n),n.then(()=>{this.resolve(n)},()=>{this.resolve(n)}),n}remove(e){for(let t=0;t<this.pending.length;t+=1)if(this.pending[t]===e){this.pending.splice(t,1);return}}resolve(e){this.remove(e),this.resolved.push(e)}cancel(){const e=[...this.pending,...this.resolved];for(let t=0;t<e.length;t+=1)e[t].cancel();this.pending=[],this.resolved=[]}}const Xn=gp;class pp extends Error{isInvalid=!0}const wi=pp;function ih({type:c}){switch(c){case I.VariableType.TABLE:case I.VariableType.TABLEMAP:case I.VariableType.TREETABLE:case I.VariableType.HIERARCHICALTABLE:return r.jsx(X,{icon:or});case I.VariableType.FIGURE:return r.jsx(X,{icon:Kc});case I.VariableType.PANDAS:return r.jsx(X,{icon:Km});default:return r.jsx(X,{icon:ja})}}class fp extends w.Component{constructor(e){super(e),this.container=null}componentDidMount(){this.colorize()}container;colorize(){const{children:e}=this.props;this.container&&e!=null&&Kn.colorizeElement(this.container,{theme:"dh-dark"})}render(){const{children:e,language:t}=this.props;return r.jsx("div",{children:r.jsx("div",{"data-lang":t,ref:n=>{this.container=n},style:{pointerEvents:"none"},children:e})})}}const zl=fp;class Cp{static get LANGUAGE_MAP(){return new Map([["python","Python"],["groovy","Groovy"],["scala","Scala"]])}}const oh=Cp;class hl{static hasComment(e){return e.comment!==void 0}static hasPattern(e){return e.pattern!==void 0}static hasOp(e){return e.op!==void 0}static parseArguments(e){return e==null||!(typeof e=="string"||e instanceof String)?[]:Yu.parse(e).filter(t=>!this.hasComment(t)).map(t=>this.hasPattern(t)?t.pattern:this.hasOp(t)?t.op:`${t}`)}static formatTimestamp(e){if(e==null||!(e instanceof Date))return null;const t=`${e.getHours()}`.padStart(2,"0"),n=`${e.getMinutes()}`.padStart(2,"0"),s=`${e.getSeconds()}`.padStart(2,"0"),i=`${e.getMilliseconds()}`.padStart(3,"0");return`${t}:${n}:${s}.${i}`}static isTableType(e){return e===I.VariableType.TABLE||e===I.VariableType.TREETABLE||e===I.VariableType.HIERARCHICALTABLE}static isWidgetType(e){return e===I.VariableType.FIGURE||e===I.VariableType.OTHERWIDGET||e===I.VariableType.PANDAS}static isOpenableType(e){return hl.isTableType(e)||hl.isWidgetType(e)}static isFigureType(e){return e===I.VariableType.FIGURE}static isPandas(e){return e===I.VariableType.PANDAS}}const Va=hl;function lh({children:c}){return r.jsxs("div",{className:"console-history-item-result",children:[r.jsx("div",{className:"console-history-gutter",children:"-"}),r.jsx("div",{className:"console-history-content",children:c})]})}lh.propTypes={children:B.node.isRequired};class Sp extends w.Component{static defaultProps={disabled:!1};constructor(e){super(e),this.updateElapsed=this.updateElapsed.bind(this),this.startTime=Date.now(),this.state={elapsed:0}}componentDidMount(){this.timer=setInterval(this.updateElapsed,1e3)}componentWillUnmount(){this.timer&&clearInterval(this.timer),this.timer=void 0}timer;startTime;updateElapsed(){this.setState({elapsed:Math.round((Date.now()-this.startTime)/1e3)})}render(){const{disabled:e,onCancelClick:t}=this.props,{elapsed:n}=this.state;return r.jsx("div",{className:K("console-history-result-in-progress",{disabled:e}),children:r.jsxs("span",{className:"badge",children:[r.jsx(Nn,{})," Running... ",_l.formatElapsedTime(n)," ",r.jsx(_,{className:"console-history-result-in-progress-cancel",kind:"ghost",icon:ho,tooltip:"Cancel",onClick:t,disabled:e})]})})}}const bp=Sp;class ul extends w.PureComponent{static defaultProps={message:""};static mouseDragThreshold=5;constructor(e){super(e),this.handleKeyPress=this.handleKeyPress.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleToggleError=this.handleToggleError.bind(this),this.handleMouseEnter=this.handleMouseEnter.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.mouseX=null,this.mouseY=null,this.isClicking=!1,this.state={isExpanded:!1,isTriggerHovered:!1}}mouseX;mouseY;isClicking;handleKeyPress(e){switch(e.key){case"Enter":case" ":this.handleToggleError(),e.stopPropagation(),e.preventDefault();break}}handleMouseDown(e){this.mouseX=e.clientX,this.mouseY=e.clientY,this.isClicking=!0}handleMouseMove(e){this.mouseX!=null&&this.mouseY!=null?(Math.abs(e.clientX-this.mouseX)>=ul.mouseDragThreshold||Math.abs(e.clientY-this.mouseY)>=ul.mouseDragThreshold)&&(this.isClicking=!1):this.isClicking&&(this.isClicking=!1)}handleMouseUp(e){this.isClicking&&!e.shiftKey&&!e.metaKey&&!e.altKey&&this.handleToggleError(),this.mouseX=null,this.mouseY=null,this.isClicking=!1}handleToggleError(){this.setState(e=>({isExpanded:!e.isExpanded}))}handleMouseEnter(){this.setState({isTriggerHovered:!0})}handleMouseLeave(){this.setState({isTriggerHovered:!1})}render(){const{isExpanded:e,isTriggerHovered:t}=this.state,{message:n}=this.props;N(n);const s=n.indexOf(`
|
|
2
|
-
`),i=s>-1;let o=n;i&&(o=n.slice(0,s));const l=n.slice(s),a=t?"error-btn-link error-btn-link--active":"error-btn-link";return r.jsxs("div",{className:K("error-message",{expanded:e}),children:[i&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"error-gutter",children:r.jsx("button",{type:"button",onClick:this.handleToggleError,className:a,tabIndex:-1,children:r.jsx(X,{icon:e?$n:Yc,transform:"left-3"})})}),r.jsxs("div",{className:"error-content",children:[r.jsx("div",{className:"console-error-text-trigger",role:"button",tabIndex:0,onKeyPress:this.handleKeyPress,onMouseDown:this.handleMouseDown,onMouseMove:this.handleMouseMove,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,onMouseUp:this.handleMouseUp,children:o}),e?l:""]})]}),!i&&r.jsx("div",{className:"error-content",children:r.jsx("div",{className:"console-error-text",children:o})})]},"error")}}const wp=ul;const wd=ee.module("ConsoleHistoryItem");class vp extends w.PureComponent{static defaultProps={disabled:!1};constructor(e){super(e),this.handleCancelClick=this.handleCancelClick.bind(this),this.handleObjectClick=this.handleObjectClick.bind(this)}handleObjectClick(e){wd.debug("handleObjectClick",e);const{openObject:t}=this.props;t(e)}handleCancelClick(){const{item:e}=this.props;e!=null&&e.cancelResult&&(wd.debug(`Cancelling command: ${e.command}`),e.cancelResult())}render(){const{disabled:e,item:t,language:n}=this.props,{disabledObjects:s,result:i}=t;let o=null;t.command!=null&&t.command!==""&&(o=r.jsxs("div",{className:"console-history-item-command",children:[r.jsx("div",{className:"console-history-gutter",children:">"}),r.jsx("div",{className:"console-history-content",children:r.jsx(zl,{language:n,children:t.command})})]}));const l=[];let a=!1;if(i){const{error:h,message:u,changes:m}=i;if(m){const{created:g,updated:p}=m;[...g,...p].forEach(C=>{a=!0;const{title:f}=C,S=`${f}`,v=e===void 0||e||(s??[]).indexOf(S)>=0,b=r.jsx(_,{kind:"primary",onClick:()=>this.handleObjectClick(C),className:"btn-console-object",disabled:v,icon:r.jsx(ih,{type:C.type}),children:f},S);l.push(b)})}if(h!=null&&t.command==null){let g=`${h.message??h}`;g||(g=h);const p=r.jsx(wp,{message:g},"result-error");l.push(p)}if(u!==void 0&&u!==""){const g=r.jsx("div",{className:"log-message",children:u},"log-message");l.push(g)}}else{a=!0;const h=r.jsx(bp,{onCancelClick:this.handleCancelClick,disabled:e},"in_progress");l.push(h)}let d=null;return l.length>0&&(d=r.jsx(lh,{children:l})),r.jsxs("div",{className:K("console-command-result",{"console-result-buttons":a}),children:[o,d]})}}const Tp=vp;class mr extends w.Component{static defaultProps={disabled:!1};static itemKey(e,t){return`${e}.${t.command}.${t.result&&t.result.message}.${t.result&&t.result.error}`}render(){const{disabled:e,items:t,language:n,openObject:s}=this.props,i=[];for(let o=0;o<t.length;o+=1){const l=t[o],a=r.jsx(Tp,{disabled:e,item:l,openObject:s,language:n},mr.itemKey(o,l));i.push(a)}return r.jsx("div",{className:"container-fluid console-history",children:i})}}const Ep=mr,yp={name:"Console",CLEAR:Ve.createAndAdd({id:"CONSOLE.CLEAR",name:"Clear",shortcut:[Se.CTRL,Ee.L],macShortcut:[Se.CTRL,Ee.C]}),FOCUS_HISTORY:Ve.createAndAdd({id:"CONSOLE.FOCUS_HISTORY",name:"Focus History",shortcut:[Se.CTRL,Ee.H],macShortcut:[Se.CTRL,Se.OPTION,Ee.H]})},Rp={name:"Command History",FOCUS_HISTORY:Ve.createAndAdd({id:"COMMAND_HISTORY.FOCUS_HISTORY",name:"Focus History Search",shortcut:[Se.CTRL,Ee.H],macShortcut:[Se.CTRL,Se.OPTION,Ee.H]}),SEND_TO_CONSOLE:Ve.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_CONSOLE",name:"Send to Console",shortcut:[Ee.ENTER],macShortcut:[Ee.ENTER]}),SEND_TO_NOTEBOOK:Ve.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_NOTEBOOK",name:"Send to Notebook",shortcut:[Se.CTRL,Ee.ENTER],macShortcut:[Se.CMD,Ee.ENTER]}),RUN:Ve.createAndAdd({id:"COMMAND_HISTORY.RUN",name:"Run",shortcut:[Se.ALT,Ee.R],macShortcut:[Se.OPTION,Ee.R]})},xp={name:"Notebook",RUN:Ve.createAndAdd({id:"NOTEBOOK.RUN",name:"Run",shortcut:[Se.ALT,Ee.R],macShortcut:[Se.OPTION,Ee.R]}),RUN_SELECTED:Ve.createAndAdd({id:"NOTEBOOK.RUN_SELECTED",name:"Run Selected",shortcut:[Se.ALT,Se.SHIFT,Ee.R],macShortcut:[Se.OPTION,Se.SHIFT,Ee.R]}),FIND:Ve.createAndAdd({id:"NOTEBOOK.FIND",name:"Find",shortcut:[Se.CTRL,Ee.F],macShortcut:[Se.CMD,Ee.F],isEditable:!1}),MINIMAP:Ve.createAndAdd({id:"NOTEBOOK.MINIMAP",name:"Show Minimap",shortcut:[Se.ALT,Ee.M],macShortcut:[Se.OPTION,Ee.M]}),WORDWRAP:Ve.createAndAdd({id:"NOTEBOOK.WORDWRAP",name:"Word Wrap",shortcut:[Se.ALT,Ee.Z],macShortcut:[Se.OPTION,Ee.Z]})},Ip={CONSOLE:yp,COMMAND_HISTORY:Rp,NOTEBOOK:xp},It=Ip,ut=Object.freeze({FATAL:"FATAL",STDERR:"STDERR",ERROR:"ERROR",WARN:"WARN",STDOUT:"STDOUT",INFO:"INFO",DEBUG:"DEBUG",TRACE:"TRACE"}),Dp="#2d2a2e",Fp="#fcfcfa",Np="#fcd65b",kp="#b2b1b2",Mp="#9edc6f",Lp="#76d9e4",Op="#f95d84",Ap="#aa9af4",_p="#f95d84",Pp="#fcfcfa",jp="#7c7b7c",ue={"error-foreground":"#f95d84",background:Dp,foreground:Fp,"line-height":"19px",string:Np,"string-delim":"#929192",delimiter:kp,predefined:Mp,keyword:Lp,storage:Op,number:Ap,operator:_p,identifier:Pp,"namespace-identifier":"#f95d84","identifier-js":"#fcd65b",comment:jp,"input-option-active-border":"#929192","focus-border":"rgba(72, 120, 234, 0.85)","input-background":"#555356","input-foreground":"#f0f0ee","input-border":"#929192","editor-line-number-foreground":"#929192","editor-selection-background":"#676368","editor-line-highlight-bg":"#373438","context-menu-background":"#555356","context-menu-foreground":"#f0f0ee","menu-selection-background":"#4878ea","log-date":"#929192","log-error":"#f95d84","log-info":"#76d9e4","log-stdout":"#f0f0ee","log-warn":"#fcd65b","log-debug":"#aa9af4","log-trace":"#9edc6f","editor-find-match-background":"#3c5595","editor-find-match-highlight-background":"#343e5d","editor-widget-background":"#403e41","input-option-active-background":"#4878ea","input-option-active-foreground":"#f0f0ee","editor-suggest-widget-background":"#403e41","editor-suggest-widget-border":"#5b5a5c","editor-suggest-widget-foreground":"#f0f0ee","editor-suggest-widget-selected-background":"#41475a","editor-suggest-widget-highlightForeground":"#4878ea","list-hover-background":"#555356","text-link-foreground":"#929192","text-link-active-foreground":"#f0f0ee","editor-link-active-foreground":"#f0f0ee"},Hp="python",Up={comments:{lineComment:"#",blockComment:["'''","'''"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"',notIn:["string"]},{open:"'",close:"'",notIn:["string","comment"]}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],onEnterRules:[{beforeText:/^\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\s*$/,action:{indentAction:1}}],folding:{offSide:!0,markers:{start:/^\s*#region\b/,end:/^\s*#endregion\b/}}},Vp={keywords:["and","del","from","not","while","as","elif","global","or","with","assert","else","if","pass","yield","break","except","import","print","exec","in","raise","continue","finally","is","return","for","try",":","=","isinstance","__debug__"],storage:["class","def","async","lambda"],operators:["+","-","*","**","/","//","%","<<",">>","&","|","^","~","<",">","<=",">=","==","!=","<>","+=","-=","*=","/","//=","%=","&=","|=","^=",">>=","<<=","**="],brackets:[{open:"{",close:"}",token:"delimiter.curly"},{open:"[",close:"]",token:"delimiter.square"},{open:"(",close:")",token:"delimiter.parenthesis"}],symbols:/[=><!~&|+\-*/^%]+/,delimiters:/[;=.@:,`]/,escapes:/\\(?:[abfnrtv\\"'\n\r]|x[0-9A-Fa-f]{2}|[0-7]{3}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}|N\{\w+\})/,rawpre:/(?:[rR]|ur|Ur|uR|UR|br|Br|bR|BR)/,strpre:/(?:[buBU])/,tokenizer:{root:[[/@strpre?("""|''')/,{token:"string.delim",bracket:"@open",next:"@mstring.$1"}],[/@strpre?"([^"\\]|\\.)*$/,"string.invalid"],[/@strpre?'([^'\\]|\\.)*$/,"string.invalid"],[/@strpre?(["])/,{token:"string.delim",bracket:"@open",next:"@sstring.$1",nextEmbedded:"deephavenDb"}],[/@strpre?(["'])/,{token:"string.delim",bracket:"@open",next:"@string.$1"}],[/@rawpre("""|''')/,{token:"string.delim",bracket:"@open",next:"@mrawstring.$1"}],[/@rawpre"([^"\\]|\\.)*$/,"string.invalid"],[/@rawpre'([^'\\]|\\.)*$/,"string.invalid"],[/@rawpre(["'])/,{token:"string.delim",bracket:"@open",next:"@rawstring.$1"}],[/__[\w$]*/,"predefined"],[/[a-z_$][\w$]*/,{cases:{"@keywords":"keyword","@storage":"storage","@default":"identifier"}}],[/[A-Z][\w]*/,{cases:{"~[A-Z0-9_]+":"constructor.identifier","@default":"namespace.identifier"}}],{include:"@whitespace"},[/[{}()[\]]/,"@brackets"],[/@symbols/,{cases:{"@keywords":"keyword","@operators":"operator","@default":""}}],[/\d*\.\d+([eE][-+]?\d+)?/,"number.float"],[/0[xX][0-9a-fA-F]+[lL]?/,"number.hex"],[/0[bB][0-1]+[lL]?/,"number.binary"],[/(0[oO][0-7]+|0[0-7]+)[lL]?/,"number.octal"],[/(0|[1-9]\d*)[lL]?/,"number"],[":",{token:"keyword",bracket:"@open"}],[/@delimiters/,{cases:{"@keywords":"keyword","@default":"delimiter"}}]],comment:[[/[^/*]+/,"comment"],[/\/\*/,"comment","@push"],["\\*/","comment","@pop"],[/[/*]/,"comment"]],mstring:[{include:"@strcontent"},[/"""|'''/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/["']/,"string"],[/./,"string.invalid"]],sstring:[{include:"@strcontent"},[/["]/,{token:"string.delim",bracket:"@close",next:"@pop",nextEmbedded:"@pop"}],[/./,"string.invalid"]],string:[{include:"@strcontent"},[/[']/,{token:"string.delim",bracket:"@close",next:"@pop"}],[/./,"string.invalid"]],strcontent:[[/[^\\"']+/,"string"],[/\\$/,"string.escape"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"]],mrawstring:[{include:"@rawstrcontent"},[/"""|'''/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/["']/,"string"],[/./,"string.invalid"]],rawstring:[{include:"@rawstrcontent"},[/["']/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/./,"string.invalid"]],rawstrcontent:[[/[^\\"']+/,"string"],[/\\["']/,"string"],[/\\u[0-9A-Fa-f]{4}/,"string.escape"],[/\\/,"string"]],whitespace:[[/\s+/,"white"],[/(^#.*$)/,"comment"],[/'''/,"string","@endDocString"],[/"""/,"string","@endDblDocString"]],endDocString:[[/[^']+/,"string"],[/\\'/,"string"],[/'''/,"string","@popall"],[/'/,"string"]],endDblDocString:[[/[^"]+/,"string"],[/\\"/,"string"],[/"""/,"string","@popall"],[/"/,"string"]]}},Bp={id:Hp,conf:Up,language:Vp},$p=Bp,Wp="groovy",Gp={comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"',notIn:["string"]},{open:"'",close:"'",notIn:["string","comment"]}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],onEnterRules:[{beforeText:/^\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\s*$/,action:{indentAction:1}}],folding:{offSide:!0,markers:{start:/^\s*#region\b/,end:/^\s*#endregion\b/}}},zp={keywords:["and","del","from","not","while","as","elif","global","or","with","assert","else","if","pass","yield","break","except","import","print","println","class","exec","in","raise","continue","finally","is","return","def","for","lambda","try",":","=","isinstance","__debug__"],operators:["+","-","*","**","/","//","%","<<",">>","&","|","^","~","<",">","<=",">=","==","!=","<>","+=","-=","*=","/","//=","%=","&=","|=","^=",">>=","<<=","**="],brackets:[{open:"{",close:"}",token:"delimiter.curly"},{open:"[",close:"]",token:"delimiter.square"},{open:"(",close:")",token:"delimiter.parenthesis"}],symbols:/[=><!~&|+\-*/^%]+/,delimiters:/[;=.@:,`]/,escapes:/\\(?:[abfnrtv\\"'\n\r]|x[0-9A-Fa-f]{2}|[0-7]{3}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}|N\{\w+\})/,rawpre:/(?:[rR]|ur|Ur|uR|UR|br|Br|bR|BR)/,strpre:/(?:[buBU])/,tokenizer:{root:[[/@strpre?("""|''')/,{token:"string.delim",bracket:"@open",next:"@mstring.$1"}],[/@strpre?"([^"\\]|\\.)*$/,"string.invalid"],[/@strpre?'([^'\\]|\\.)*$/,"string.invalid"],[/@strpre?(["])/,{token:"string.delim",bracket:"@open",next:"@sstring.$1",nextEmbedded:"deephavenDb"}],[/@strpre?(["'])/,{token:"string.delim",bracket:"@open",next:"@string.$1"}],[/@rawpre("""|''')/,{token:"string.delim",bracket:"@open",next:"@mrawstring.$1"}],[/@rawpre"([^"\\]|\\.)*$/,"string.invalid"],[/@rawpre'([^'\\]|\\.)*$/,"string.invalid"],[/@rawpre(["'])/,{token:"string.delim",bracket:"@open",next:"@rawstring.$1"}],[/__[\w$]*/,"predefined"],[/[a-z_$][\w$]*/,{cases:{"@keywords":"keyword","@default":"identifier"}}],[/[A-Z][\w]*/,{cases:{"~[A-Z0-9_]+":"constructor.identifier","@default":"namespace.identifier"}}],{include:"@whitespace"},[/[{}()[\]]/,"@brackets"],[/@symbols/,{cases:{"@keywords":"keyword","@operators":"operator","@default":""}}],[/\d*\.\d+([eE][-+]?\d+)?/,"number.float"],[/0[xX][0-9a-fA-F]+[lL]?/,"number.hex"],[/0[bB][0-1]+[lL]?/,"number.binary"],[/(0[oO][0-7]+|0[0-7]+)[lL]?/,"number.octal"],[/(0|[1-9]\d*)[lL]?/,"number"],[":",{token:"keyword",bracket:"@open"}],[/@delimiters/,{cases:{"@keywords":"keyword","@default":"delimiter"}}]],mstring:[{include:"@strcontent"},[/"""|'''/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/["']/,"string"],[/./,"string.invalid"]],sstring:[{include:"@strcontent"},[/["]/,{token:"string.delim",bracket:"@close",next:"@pop",nextEmbedded:"@pop"}],[/./,"string.invalid"]],string:[{include:"@strcontent"},[/[']/,{token:"string.delim",bracket:"@close",next:"@pop"}],[/./,"string.invalid"]],strcontent:[[/[^\\"']+/,"string"],[/\\$/,"string.escape"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"]],mrawstring:[{include:"@rawstrcontent"},[/"""|'''/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/["']/,"string"],[/./,"string.invalid"]],rawstring:[{include:"@rawstrcontent"},[/["']/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/./,"string.invalid"]],rawstrcontent:[[/[^\\"']+/,"string"],[/\\["']/,"string"],[/\\u[0-9A-Fa-f]{4}/,"string.escape"],[/\\/,"string"]],whitespace:[[/[ \t\r\n]+/,""],[/\/\*\*(?!\/)/,"comment.doc","@doccomment"],[/\/\*/,"comment","@comment"],[/\/\/.*$/,"comment"]],comment:[[/[^/*]+/,"comment"],[/\*\//,"comment","@pop"],[/[/*]/,"comment"]],doccomment:[[/[^/*]+/,"comment.doc"],[/\*\//,"comment.doc","@pop"],[/[/*]/,"comment.doc"]]}},Kp={id:Wp,conf:Gp,language:zp},Yp=Kp,qp="scala",Xp={wordPattern:/(unary_[@~!#%^&*()\-=+\\|:<>/?]+)|([a-zA-Z_$][\w$]*?_=)|(`[^`]+`)|([a-zA-Z_$][\w$]*)/g,comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],folding:{markers:{start:/^\s*\/\/\s*(?:(?:#?region\b)|(?:<editor-fold\b))/,end:/^\s*\/\/\s*(?:(?:#?endregion\b)|(?:<\/editor-fold>))/}}},Zp={keywords:["asInstanceOf","catch","class","classOf","def","do","else","extends","finally","for","foreach","forSome","if","import","isInstanceOf","macro","match","new","object","package","return","throw","trait","try","type","until","val","var","while","with","yield","given","enum","then"],softKeywords:["as","export","extension","end","derives","on"],constants:["true","false","null","this","super"],modifiers:["abstract","final","implicit","lazy","override","private","protected","sealed"],softModifiers:["inline","opaque","open","transparent","using"],name:/(?:[a-z_$][\w$]*|`[^`]+`)/,type:/(?:[A-Z][\w$]*)/,symbols:/[=><!~?:&|+\-*/^\\%@#]+/,digits:/\d+(_+\d+)*/,hexdigits:/[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,escapes:/\\(?:[btnfr\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,fstring_conv:/[bBhHsScCdoxXeEfgGaAt]|[Tn](?:[HIklMSLNpzZsQ]|[BbhAaCYyjmde]|[RTrDFC])/,tokenizer:{root:[[/\braw"""/,{token:"string.quote",bracket:"@open",next:"@rawstringt"}],[/\braw"/,{token:"string.quote",bracket:"@open",next:"@rawstring"}],[/\bs"""/,{token:"string.quote",bracket:"@open",next:"@sstringt"}],[/\bs"/,{token:"string.quote",bracket:"@open",next:"@sstring"}],[/\bf""""/,{token:"string.quote",bracket:"@open",next:"@fstringt"}],[/\bf"/,{token:"string.quote",bracket:"@open",next:"@fstring"}],[/"""/,{token:"string.quote",bracket:"@open",next:"@stringt"}],[/"/,{token:"string.quote",bracket:"@open",next:"@string"}],[/(@digits)[eE]([-+]?(@digits))?[fFdD]?/,"number.float","@allowMethod"],[/(@digits)\.(@digits)([eE][-+]?(@digits))?[fFdD]?/,"number.float","@allowMethod"],[/0[xX](@hexdigits)[Ll]?/,"number.hex","@allowMethod"],[/(@digits)[fFdD]/,"number.float","@allowMethod"],[/(@digits)[lL]?/,"number","@allowMethod"],[/\b_\*/,"key"],[/\b(_)\b/,"keyword","@allowMethod"],[/\bimport\b/,"keyword","@import"],[/\b(case)([ \t]+)(class)\b/,["keyword.modifier","white","keyword"]],[/\bcase\b/,"keyword","@case"],[/\bva[lr]\b/,"keyword","@vardef"],[/\b(def)([ \t]+)((?:unary_)?@symbols|@name(?:_=)|@name)/,["keyword","white","identifier"]],[/@name(?=[ \t]*:(?!:))/,"variable"],[/(\.)(@name|@symbols)/,[{token:"operator"},{token:"@rematch",next:"@allowMethod"}]],[/([{(])(\s*)(@name(?=\s*=>))/,["@brackets","white","variable"]],[/@name/,{cases:{"@keywords":"keyword","@softKeywords":"keyword","@modifiers":"keyword.modifier","@softModifiers":"keyword.modifier","@constants":{token:"constant",next:"@allowMethod"},"@default":{token:"identifier",next:"@allowMethod"}}}],[/@type/,"type","@allowMethod"],{include:"@whitespace"},[/@[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*/,"annotation"],[/[{(]/,"@brackets"],[/[})]/,"@brackets","@allowMethod"],[/\[/,"operator.square"],[/](?!\s*(?:va[rl]|def|type)\b)/,"operator.square","@allowMethod"],[/]/,"operator.square"],[/([=-]>|<-|>:|<:|:>|<%)(?=[\s\w()[\]{},."'`])/,"keyword"],[/@symbols/,"operator"],[/[;,.]/,"delimiter"],[/'[a-zA-Z$][\w$]*(?!')/,"attribute.name"],[/'[^\\']'/,"string","@allowMethod"],[/(')(@escapes)(')/,[{token:"string"},{token:"string.escape"},{token:"string",next:"@allowMethod"}]],[/'/,"string.invalid"]],import:[[/;/,"delimiter","@pop"],[/^|$/,"","@pop"],[/[ \t]+/,"white"],[/[\n\r]+/,"white","@pop"],[/\/\*/,"comment","@comment"],[/@name|@type/,"type"],[/[(){}]/,"@brackets"],[/[[\]]/,"operator.square"],[/[.,]/,"delimiter"]],allowMethod:[[/^|$/,"","@pop"],[/[ \t]+/,"white"],[/[\n\r]+/,"white","@pop"],[/\/\*/,"comment","@comment"],[/(?==>[\s\w([{])/,"keyword","@pop"],[/(@name|@symbols)(?=[ \t]*[[({"'`]|[ \t]+(?:[+-]?\.?\d|\w))/,{cases:{"@keywords":{token:"keyword",next:"@pop"},"->|<-|>:|<:|<%":{token:"keyword",next:"@pop"},"@default":{token:"@rematch",next:"@pop"}}}],["","","@pop"]],comment:[[/[^/*]+/,"comment"],[/\/\*/,"comment","@push"],[/\*\//,"comment","@pop"],[/[/*]/,"comment"]],case:[[/\b_\*/,"key"],[/\b(_|true|false|null|this|super)\b/,"keyword","@allowMethod"],[/\bif\b|=>/,"keyword","@pop"],[/`[^`]+`/,"identifier","@allowMethod"],[/@name/,"variable","@allowMethod"],[/:::?|\||@(?![a-z_$])/,"keyword"],{include:"@root"}],vardef:[[/\b_\*/,"key"],[/\b(_|true|false|null|this|super)\b/,"keyword"],[/@name/,"variable"],[/:::?|\||@(?![a-z_$])/,"keyword"],[/=|:(?!:)/,"operator","@pop"],[/$/,"white","@pop"],{include:"@root"}],string:[[/[^\\"\n\r]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}]],stringt:[[/[^\\"\n\r]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"(?=""")/,"string"],[/"""/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/"/,"string"]],fstring:[[/@escapes/,"string.escape"],[/"/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/\$\$/,"string"],[/(\$)([a-z_]\w*)/,["operator","identifier"]],[/\$\{/,"operator","@interp"],[/%%/,"string"],[/(%)([-#+ 0,(])(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/,["metatag","keyword.modifier","number","metatag"]],[/(%)(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/,["metatag","number","metatag"]],[/(%)([-#+ 0,(])(@fstring_conv)/,["metatag","keyword.modifier","metatag"]],[/(%)(@fstring_conv)/,["metatag","metatag"]],[/./,"string"]],fstringt:[[/@escapes/,"string.escape"],[/"(?=""")/,"string"],[/"""/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/\$\$/,"string"],[/(\$)([a-z_]\w*)/,["operator","identifier"]],[/\$\{/,"operator","@interp"],[/%%/,"string"],[/(%)([-#+ 0,(])(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/,["metatag","keyword.modifier","number","metatag"]],[/(%)(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/,["metatag","number","metatag"]],[/(%)([-#+ 0,(])(@fstring_conv)/,["metatag","keyword.modifier","metatag"]],[/(%)(@fstring_conv)/,["metatag","metatag"]],[/./,"string"]],sstring:[[/@escapes/,"string.escape"],[/"/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/\$\$/,"string"],[/(\$)([a-z_]\w*)/,["operator","identifier"]],[/\$\{/,"operator","@interp"],[/./,"string"]],sstringt:[[/@escapes/,"string.escape"],[/"(?=""")/,"string"],[/"""/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/\$\$/,"string"],[/(\$)([a-z_]\w*)/,["operator","identifier"]],[/\$\{/,"operator","@interp"],[/./,"string"]],interp:[[/{/,"operator","@push"],[/}/,"operator","@pop"],{include:"@root"}],rawstring:[[/[^"]/,"string"],[/"/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}]],rawstringt:[[/[^"]/,"string"],[/"(?=""")/,"string"],[/"""/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/"/,"string"]],whitespace:[[/[ \t\r\n]+/,"white"],[/\/\*/,"comment","@comment"],[/\/\/.*$/,"comment"]]}},Qp={id:qp,conf:Xp,language:Zp},Jp=Qp,ef="deephavenDb",tf={comments:{lineComment:"#",blockComment:["'''","'''"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"',notIn:["string"]},{open:"'",close:"'",notIn:["string","comment"]}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],onEnterRules:[{beforeText:/^\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\s*$/,action:{indentAction:1}}],folding:{offSide:!0,markers:{start:/^\s*#region\b/,end:/^\s*#endregion\b/}}},nf={tokenPostfix:".js",keywords:["boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with"],builtins:["define","require","window","document","undefined"],operators:["=",">","<","!","~","?",":","==","<=",">=","!=","&&","||","++","--","+","-","*","/","&","|","^","%","<<",">>",">>>","+=","-=","*=","/=","&=","|=","^=","%=","<<=",">>=",">>>="],brackets:[{open:"{",close:"}",token:"delimiter.curly"},{open:"[",close:"]",token:"delimiter.bracket"},{open:"(",close:")",token:"delimiter.parenthesis"}],symbols:/[~!@#%\^&*-+=|\\:`<>.?\/]+/,escapes:/\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,exponent:/[eE][\-+]?[0-9]+/,regexpctl:/[(){}\[\]\$\^|\-*+?\.]/,regexpesc:/\\(?:[bBdDfnrstvwWn0\\\/]|@regexpctl|c[A-Z]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})/,tokenizer:{root:[[/([a-zA-Z_\$][\w\$]*)(\s*)(:?)/,{cases:{"$1@keywords":["keyword","white","delimiter"],$3:["key.identifier","white","delimiter"],"$1@builtins":["predefined.identifier","white","delimiter"],"@default":["identifier","white","delimiter"]}}],{include:"@whitespace"},[/\/(?=([^\\\/]|\\.)+\/)/,{token:"regexp.slash",bracket:"@open",next:"@regexp"}],[/[{}()\[\]]/,"@brackets"],[/[;,.]/,"delimiter"],[/@symbols/,{cases:{"@operators":"operator","@default":""}}],[/\d+\.\d*(@exponent)?/,"number.float"],[/\.\d+(@exponent)?/,"number.float"],[/\d+@exponent/,"number.float"],[/0[xX][\da-fA-F]+/,"number.hex"],[/0[0-7]+/,"number.octal"],[/\d+/,"number"],[/"([^"\\]|\\.)*$/,"string.invalid"],[/'([^'\\]|\\.)*$/,"string.invalid"],[/"/,"string",'@string."'],[/'/,"string","@string.'"]],whitespace:[[/[ \t\r\n]+/,"white"],[/\/\*/,"comment","@comment"],[/\/\/.*$/,"comment"]],comment:[[/[^\/*]+/,"comment"],[/\/\*/,"comment.invalid"],["\\*/","comment","@pop"],[/[\/*]/,"comment"]],string:[[/[^\\"']+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/["']/,{cases:{"$#==$S2":{token:"string",next:"@pop"},"@default":"string"}}]],regexp:[[/(\{)(\d+(?:,\d*)?)(\})/,["@brackets.regexp.escape.control","regexp.escape.control","@brackets.regexp.escape.control"]],[/(\[)(\^?)(?=(?:[^\]\\\/]|\\.)+)/,[{token:"@brackets.regexp.escape.control"},{token:"regexp.escape.control",next:"@regexrange"}]],[/(\()(\?:|\?=|\?!)/,["@brackets.regexp.escape.control","regexp.escape.control"]],[/[()]/,"@brackets.regexp.escape.control"],[/@regexpctl/,"regexp.escape.control"],[/[^\\\/]/,"regexp"],[/@regexpesc/,"regexp.escape"],[/\\\./,"regexp.invalid"],["/",{token:"regexp.slash",bracket:"@close"},"@pop"]],regexrange:[[/-/,"regexp.escape.control"],[/\^/,"regexp.invalid"],[/@regexpesc/,"regexp.escape"],[/[^\]]/,"regexp"],[/\]/,"@brackets.regexp.escape.control","@pop"]]}},sf={id:ef,conf:tf,language:nf},of=sf,lf="log",af={},rf={tokenizer:{root:[[/ FATAL[\s\S]*/,{token:"error",next:"@error"}],[/ ERROR[\s\S]*/,{token:"error",next:"@error"}],[/ STDERR[\s\S]*/,{token:"error",next:"@error"}],[/ STDOUT.*/,{token:"stdout",next:"@stdout"}],[/ INFO[\s\S]*/,{token:"info",next:"@info"}],[/ WARN.*/,{token:"warn",next:"@warn"}],[/ TRACE[\s\S]*/,{token:"trace",next:"@trace"}],[/ DEBUG[.\s\S]*/,{token:"debug",next:"@debug"}],[/^\d{2}:\d{2}:\d{2}.\d{3}/,"date"]],error:[{include:"@body"}],info:[{include:"@body"}],warn:[{include:"@body"}],stdout:[{include:"@body"}],trace:[{include:"@body"}],debug:[{include:"@body"}],body:[[/^\d{2}:\d{2}:\d{2}.\d{3}/,{token:"date",next:"@pop"}],[/[\s\S]*/,{token:"$S0"}]]}},df={id:lf,conf:af,language:rf},cf=df,bn=ee.module("MonacoUtils");class Tn{static init({getWorker:e}={}){bn.debug("Initializing Monaco..."),e!==void 0&&Tn.registerGetWorker(e);const{registerLanguages:t,removeHashtag:n}=Tn,s=[{token:"",foreground:n(ue.foreground)},{token:"string",foreground:n(ue.string)},{token:"string.delim",foreground:n(ue["string-delim"])},{token:"keyword",foreground:n(ue.keyword)},{token:"identifier.js",foreground:n(ue["identifier-js"])},{token:"delimiter",foreground:n(ue.delimiter)},{token:"comment",foreground:n(ue.comment)},{token:"number",foreground:n(ue.number)},{token:"storage",foreground:n(ue.storage)},{token:"identifier",foreground:n(ue.identifier)},{token:"namespace.identifier",foreground:n(ue["namespace-identifier"])},{token:"operator",foreground:n(ue.operator)},{token:"predefined",foreground:n(ue.predefined)},{token:"error.log",foreground:ue["log-error"].substring(1)},{token:"warn.log",foreground:n(ue["log-warn"])},{token:"info.log",foreground:n(ue["log-info"])},{token:"stdout.log",foreground:n(ue["log-stdout"])},{token:"trace.log",foreground:n(ue["log-trace"])},{token:"debug.log",foreground:n(ue["log-debug"])},{token:"date.log",foreground:n(ue["log-date"])}],i={errorForeground:ue["error-foreground"],"inputOption.activeBorder":ue["input-option-active-border"],"editor.background":ue.background,"editor.foreground":ue.foreground,"editor.lineHighlightBackground":ue["editor-line-highlight-bg"],"editorLineNumber.foreground":ue["editor-line-number-foreground"],"editor.selectionBackground":ue["editor-selection-background"],"editor.findMatchBackground":ue["editor-find-match-background"],"editor.findMatchHighlightBackground":ue["editor-find-match-highlight-background"],"editorSuggestWidget.background":ue["editor-suggest-widget-background"],"editorSuggestWidget.border":ue["editor-suggest-widget-border"],"editorSuggestWidget.foreground":ue["editor-suggest-widget-foreground"],"editorSuggestWidget.selectedBackground":ue["editor-suggest-widget-selected-background"],"editorSuggestWidget.highlightForeground":ue["editor-suggest-widget-highlightForeground"],"list.hoverBackground":ue["list-hover-background"],"dropdown.background":ue["context-menu-background"],"dropdown.foreground":ue["context-menu-foreground"],"menu.selectionBackground":ue["menu-selection-background"],"list.focusBackground":ue["menu-selection-background"],"editorWidget.background":ue["editor-widget-background"],"inputOption.activeBackground":ue["input-option-active-background"],"inputOption.activeForeground":ue["input-option-active-foreground"],focusBorder:ue["focus-border"],"input.background":ue["input-background"],"input.foreground":ue["input-foreground"],"input.border":ue["input-border"],"textLink.foreground":ue["text-link-foreground"],"textLink.activeForeground":ue["text-link-active-foreground"],"editorLink.activeForeground":ue["editor-link-active-foreground"]};Kn.defineTheme("dh-dark",{base:"vs-dark",inherit:!0,rules:s,colors:i}),bn.debug2("monaco theme: ",ue),Kn.setTheme("dh-dark"),t([of,$p,Yp,cf,Jp]),bn.debug("Monaco initialized.")}static registerGetWorker(e){window.MonacoEnvironment={...window.MonacoEnvironment,getWorker:e}}static removeHashtag(e){return e.substring(1)}static registerLanguages(e){const t=e.map(({id:n})=>n);xn.getLanguages().filter(({id:n})=>t.includes(n)).forEach(n=>{const s=n;bn.debug2("Overriding default language loader:",s.id)}),e.forEach(n=>{Tn.registerLanguage(n)})}static registerLanguage(e){bn.debug2("Registering language: ",e.id),xn.register(e),xn.onLanguage(e.id,()=>{xn.setLanguageConfiguration(e.id,e.conf),xn.setMonarchTokensProvider(e.id,e.language)})}static setEOL(e,t=Kn.EndOfLineSequence.LF){e.getModel()?.setEOL(t)}static openDocument(e,t){const n=e.getModel();N(n);const s={textDocument:{uri:`${n.uri}`,languageId:n.getLanguageId(),version:n.getVersionId(),text:n.getValue()}};return bn.debug2("didOpenDocumentParams: ",s),t.openDocument(s),e.onDidChangeModelContent(o=>{const{changes:l,versionId:a}=o,d=[];for(let h=0;h<l.length;h+=1){const u=l[h],{range:m,rangeLength:g,text:p}=u,C={range:{start:{line:m.startLineNumber-1,character:m.startColumn-1},end:{line:m.endLineNumber-1,character:m.endColumn-1}},rangeLength:g,text:p};d.push(C)}if(d.length>0){const h={textDocument:{version:a,uri:`${n.uri}`},contentChanges:d};bn.debug2("didChangeDocumentParams",h),t.changeDocument(h)}})}static closeDocument(e,t){const n=e.getModel();N(n);const s={textDocument:{uri:`${n.uri}`}};t.closeDocument(s)}static registerPasteHandler(e){e.onDidPaste(t=>{const n=/“|”/g,s=/\u200b/g,i=/\u00A0/g,o=e.getModel();N(o);const l=o.getValueInRange(t.range);(n.test(l)||s.test(l)||i.test(l))&&o.applyEdits([{range:t.range,text:l.replace(n,'"').replace(s,"").replace(i," ")}])})}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static removeConflictingKeybindings(e){const t=[{windows:"ctrl+D",mac:"meta+D"},{windows:"ctrl+H"}];try{t.forEach(n=>{Tn.isMacPlatform()&&n.mac===""||!Tn.isMacPlatform()&&n.windows===""||Tn.removeKeybinding(e,Tn.isMacPlatform()?n.mac:n.windows)})}catch(n){bn.error(n)}}static removeKeybinding(e,t){if(t===void 0)return;const n=e._standaloneKeybindingService._getResolver()._map.get(t);n!=null?n.forEach(s=>{bn.debug2(`Removing Monaco keybinding ${t} for ${s.command}`),e._standaloneKeybindingService.addDynamicKeybinding(`-${s.command}`,null,()=>{})}):bn.warn(`Did not find any keybindings to remove for ${t}`)}static getMonacoKeyCodeFromShortcut(e){const{keyState:t}=e,{keyValue:n}=t;return n===null?0:Tn.isMacPlatform()?(t.metaKey?tn.CtrlCmd:0)|(t.shiftKey?tn.Shift:0)|(t.altKey?tn.Alt:0)|(t.ctrlKey?tn.WinCtrl:0)|ud.fromString(n):(t.ctrlKey?tn.CtrlCmd:0)|(t.shiftKey?tn.Shift:0)|(t.altKey?tn.Alt:0)|(t.metaKey?tn.WinCtrl:0)|ud.fromString(n)}static provideLinks(e){const t=[];for(let n=1;n<=e.getLineCount();n+=1){const s=e.getLineContent(n);Ac(s).filter(l=>l.type==="url"?/^https?:\/\//.test(l.value):!0).forEach(l=>{t.push({url:l.href,range:new Gm(n,l.start+1,n,l.end+1)})})}return{links:t}}}const At=Tn,On=ee.module("MonacoCompletionProvider");class Us extends w.PureComponent{static lspToMonacoKind(e){const t=xn.CompletionItemKind;switch(e){case 1:return t.Text;case 2:return t.Method;case 3:return t.Function;case 4:return t.Constructor;case 5:return t.Field;case 6:return t.Variable;case 7:return t.Class;case 8:return t.Interface;case 9:return t.Module;case 10:return t.Property;case 11:return t.Unit;case 12:return t.Value;case 13:return t.Enum;case 14:return t.Keyword;case 15:return t.Snippet;case 16:return t.Color;case 17:return t.File;case 18:return t.Reference;case 19:return t.Folder;case 20:return t.EnumMember;case 21:return t.Constant;case 22:return t.Struct;case 23:return t.Event;case 24:return t.Operator;case 25:return t.TypeParameter;default:return t.Variable}}static lspToMonacoRange(e){const{start:t,end:n}=e;return{startLineNumber:t.line+1,startColumn:t.character+1,endLineNumber:n.line+1,endColumn:n.character+1}}static monacoToLspPosition(e){return{line:e.lineNumber-1,character:e.column-1}}constructor(e){super(e),this.handleCompletionRequest=this.handleCompletionRequest.bind(this),this.handleSignatureRequest=this.handleSignatureRequest.bind(this),this.handleHoverRequest=this.handleHoverRequest.bind(this)}componentDidMount(){const{language:e,session:t}=this.props;this.registeredCompletionProvider=xn.registerCompletionItemProvider(e,{provideCompletionItems:this.handleCompletionRequest,triggerCharacters:[".",'"',"'"]}),t.getSignatureHelp&&(this.registeredSignatureProvider=xn.registerSignatureHelpProvider(e,{provideSignatureHelp:this.handleSignatureRequest,signatureHelpTriggerCharacters:["(",","]})),t.getHover&&(this.registeredHoverProvider=xn.registerHoverProvider(e,{provideHover:this.handleHoverRequest}))}componentWillUnmount(){this.registeredCompletionProvider?.dispose(),this.registeredSignatureProvider?.dispose(),this.registeredHoverProvider?.dispose()}registeredCompletionProvider;registeredSignatureProvider;registeredHoverProvider;handleCompletionRequest(e,t,n){const{model:s,session:i}=this.props;if(e!==s)return null;const o={textDocument:{uri:`${e.uri}`,version:e.getVersionId()},position:Us.monacoToLspPosition(t),context:n},l=i.getCompletionItems(o);return On.debug("Requested completion items",o),l.then(d=>(On.debug("Completion items received: ",o,d),{incomplete:!0,suggestions:d.map(u=>{const{label:m,kind:g,detail:p,documentation:C,sortText:f,filterText:S,textEdit:v,insertTextFormat:b}=u;return{label:m,kind:Us.lspToMonacoKind(g),detail:p,documentation:C?.kind==="markdown"?C:C?.value,sortText:f,filterText:S,insertText:v.text,insertTextRules:b===2?4:b,range:Us.lspToMonacoRange(v.range)}})})).catch(d=>(On.error("There was an error retrieving completion items",d),{suggestions:[]}))}handleSignatureRequest(e,t,n,s){const i={value:{signatures:[],activeSignature:0,activeParameter:0},dispose:()=>{}},{model:o,session:l}=this.props;if(e!==o||!l.getSignatureHelp)return null;const a={textDocument:{uri:`${e.uri}`,version:e.getVersionId()},position:Us.monacoToLspPosition(t),context:s},d=l.getSignatureHelp(a);return On.debug("Requested signature help",a),d.then(u=>{On.debug("Signatures received: ",a,d);const m=u.map(p=>{const{label:C,documentation:f,parameters:S}=p;return{documentation:f?.kind==="markdown"?f:f?.value,label:C,parameters:S??[]}});if(m.length===0)return i;const g=0;return{value:{signatures:m,activeSignature:g,activeParameter:u[g].activeParameter},dispose:()=>{}}}).catch(u=>(On.error("There was an error retrieving completion items",u),i))}handleHoverRequest(e,t){const{model:n,session:s}=this.props;if(e!==n||!s.getHover)return null;const i={textDocument:{uri:`${e.uri}`,version:e.getVersionId()},position:Us.monacoToLspPosition(t)},o=s.getHover(i);return On.debug("Requested hover",i),o.then(a=>{On.debug("Hover received: ",i,a);const{contents:d}=a;return{contents:d?[d]:[]}}).catch(a=>(On.error("There was an error retrieving hover",a),{contents:[]}))}render(){return null}}const ah=Us;const pa=ee.module("ConsoleInput"),nl=parseInt(ue["line-height"],10),rh=6,ch=6,hf=nl+rh+ch,fa=100;class gr extends w.PureComponent{static defaultProps={maxHeight:nl*10,scope:null,disabled:!1};static INPUT_CLASS_NAME="console-input";constructor(e){super(e),this.handleWindowResize=this.handleWindowResize.bind(this),this.commandContainer=ae.createRef(),this.commandHistoryIndex=null,this.timestamp=Date.now(),this.bufferIndex=0,this.history=[],this.modifiedCommands=new Map,this.state={commandEditorHeight:nl,isFocused:!1,model:null}}componentDidMount(){this.initCommandEditor(),window.addEventListener("resize",this.handleWindowResize),this.loadMoreHistory()}componentDidUpdate(){this.layoutEditor()}componentWillUnmount(){window.removeEventListener("resize",this.handleWindowResize),this.loadingPromise!=null&&this.loadingPromise.cancel(),this.destroyCommandEditor()}cancelListener;commandContainer;commandEditor;commandHistoryIndex;commandSuggestionContainer;loadingPromise;timestamp;bufferIndex;history;modifiedCommands;setConsoleText(e,t=!0,n=!1){e&&(pa.debug("Command received: ",e),n||(this.commandHistoryIndex=null,this.commandEditor?.setValue(e)),t&&this.focusEnd(),this.updateDimensions(),n&&this.processCommand(e))}initCommandEditor(){const{language:e,session:t}=this.props,n={copyWithSyntaxHighlighting:!1,cursorStyle:"block",fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:e,lineHeight:nl,lineDecorationsWidth:3,lineNumbers:"off",minimap:{enabled:!1},renderLineHighlight:"none",scrollBeyondLastLine:!1,scrollbar:{arrowSize:0,horizontal:"hidden",horizontalScrollbarSize:0},padding:{top:rh,bottom:ch},tabCompletion:"on",value:"",wordWrap:"on"},s=this.commandContainer.current;N(s),this.commandEditor=Kn.create(s,n),At.setEOL(this.commandEditor),At.openDocument(this.commandEditor,t),this.commandEditor.onDidChangeModelContent(()=>{const i=this.commandEditor?.getValue();this.modifiedCommands.set(this.commandHistoryIndex,i??null),this.updateDimensions()}),this.commandEditor.onDidFocusEditorText(()=>{this.setState({isFocused:!0})}),this.commandEditor.onDidBlurEditorText(()=>{this.setState({isFocused:!1})}),this.commandEditor.onKeyDown(i=>{const{commandEditor:o,commandHistoryIndex:l}=this,a=o?.getPosition();N(a);const{lineNumber:d}=a,h=o?.getModel();if(i.code==="ArrowUp"&&!this.isSuggestionMenuPopulated()&&d===1){l!=null?this.loadCommand(l+1):this.loadCommand(0),this.focusStart(),i.stopPropagation(),i.preventDefault();return}if(i.code==="ArrowDown"&&!this.isSuggestionMenuPopulated()&&d===h?.getLineCount()){l!=null&&l>0?this.loadCommand(l-1):this.loadCommand(null),this.focusEnd(),i.stopPropagation(),i.preventDefault();return}if(!i.altKey&&!i.shiftKey&&!i.metaKey)if(i.keyCode===Cs.Enter){if(!this.isSuggestionMenuPopulated()){i.stopPropagation(),i.preventDefault();const u=this.commandEditor?.getValue().trim();u!==void 0&&(this.processCommand(u),this.commandEditor?.setValue(""))}}else i.keyCode===Cs.Tab&&(this.isSuggestionMenuActive()?this.isSuggestionMenuPopulated()||(i.stopPropagation(),i.preventDefault()):(i.stopPropagation(),i.preventDefault(),this.commandEditor?.trigger("Tab key trigger suggestions","editor.action.triggerSuggest",{})))}),this.commandEditor.addCommand(tn.CtrlCmd|Cs.KeyF,()=>{}),At.removeConflictingKeybindings(this.commandEditor),At.registerPasteHandler(this.commandEditor),this.commandEditor.focus(),this.updateDimensions(),this.setState({model:this.commandEditor.getModel()})}destroyCommandEditor(){const{session:e}=this.props;this.commandEditor&&(At.closeDocument(this.commandEditor,e),this.commandEditor.dispose(),this.commandEditor=void 0)}handleWindowResize(){this.updateDimensions()}isSuggestionMenuActive(){return this.commandSuggestionContainer||(this.commandSuggestionContainer=this.commandEditor?.getDomNode()?.querySelector(".suggest-widget")),(this.commandSuggestionContainer&&this.commandSuggestionContainer.classList.contains("visible"))??!1}isSuggestionMenuPopulated(){return this.isSuggestionMenuActive()&&(this.commandSuggestionContainer?.querySelector(".monaco-list-rows")?.childElementCount??0)>0}focus(){this.commandEditor?.focus()}focusStart(){const e=this.commandEditor?.getModel();N(e);const t=e.getLineLength(1)+1,n=this.commandEditor?.getTopForPosition(1,t);N(n),this.commandEditor?.setPosition({lineNumber:1,column:t}),this.commandEditor?.setScrollTop(n),this.commandEditor?.focus()}focusEnd(){const e=this.commandEditor?.getModel();N(e);const t=e.getLineCount(),n=e.getLineLength(t)+1,s=this.commandEditor?.getTopForPosition(t,n);N(s),this.commandEditor?.setPosition({lineNumber:t,column:n}),this.commandEditor?.setScrollTop(s),this.commandEditor?.focus()}clear(){this.commandEditor?.focus(),this.commandEditor?.getModel()?.setValue(""),this.commandHistoryIndex=null}layoutEditor(){this.commandEditor&&this.commandEditor.layout()}loadCommand(e){if(e!==null&&e>=this.history.length)return;const t=this.modifiedCommands.get(e),n=e===null?"":this.history[this.history.length-e-1];this.commandHistoryIndex=e,this.commandEditor?.getModel()?.setValue(t??n),e!==null&&e>this.history.length-fa&&this.loadMoreHistory()}async loadMoreHistory(){try{if(this.loadingPromise!=null||this.bufferIndex==null)return;const{commandHistoryStorage:e,language:t,scope:n}=this.props;this.loadingPromise=ve.makeCancelable(e.getTable(t,n??"",this.timestamp),o=>o.close());const s=await this.loadingPromise;s.setReversed(!0),s.setViewport({top:this.bufferIndex,bottom:this.bufferIndex+fa-1}),this.loadingPromise=ve.makeCancelable(s.getViewportData(),()=>s.close());const i=await this.loadingPromise;this.bufferIndex+=fa,this.bufferIndex>=s.size&&(this.bufferIndex=null),this.history=[...i.items.filter(({name:o},l,a)=>l===0||o!==a[l-1].name).map(({name:o})=>o).reverse(),...this.history],this.loadingPromise=void 0,s.close()}catch(e){if(this.loadingPromise=void 0,ve.isCanceled(e)){pa.debug2("Promise canceled, not loading history");return}pa.error("Error fetching history",e)}}processCommand(e){this.commandHistoryIndex=null,this.modifiedCommands.clear(),N(e),e!==""&&(this.history.length===0||e!==this.history[this.history.length-1])&&this.history.push(e),this.updateDimensions();const{onSubmit:t}=this.props;t(e)}updateDimensions(){if(!this.commandEditor)return;const{maxHeight:e}=this.props;N(e);const t=this.commandEditor.getContentHeight(),n=Math.max(Math.min(t,e),hf),i={overviewRulerLanes:t>n?void 0:0};this.setState({commandEditorHeight:n},()=>{this.commandEditor?.updateOptions(i),this.commandEditor?.layout()})}render(){const{disabled:e,language:t,session:n}=this.props,{commandEditorHeight:s,isFocused:i,model:o}=this.state;return r.jsx("div",{className:K("console-input-wrapper",{disabled:e}),children:r.jsxs("div",{className:K("console-input-inner-wrapper",{focus:i}),children:[r.jsx("div",{className:gr.INPUT_CLASS_NAME,ref:this.commandContainer,style:{height:s}}),o&&r.jsx(ah,{model:o,language:t,session:n})]})})}}const vd=gr;const Td="pasted values",uf=[/^audio.*/,/^font.*/,/^image.*/,/^video.*/],Ca=[".csv",".tsv",".tab",".psv",".dsv",".txt"],Ed=[".zip"];class Vs extends w.Component{static defaultProps={allowZip:!1,dragError:null};static MULTIPLE_FILE_ERROR="Please select only one file";static FILE_TYPE_ERROR="Filetype not supported.";static isValidDropItem(e){return e!=null&&e.kind==="file"&&!uf.find(t=>t.test(e.type))}static isValidExtension(e,t=!1){return Ca.some(n=>e.endsWith(n))||t&&Ed.some(n=>e.endsWith(n))}static handleDragOver(e){e.preventDefault(),e.stopPropagation()}static getIcon(e){return e===Td?md:e.endsWith(".csv")?Ym:e.endsWith(".zip")?qm:Xm}constructor(e){super(e),this.handleSelectFile=this.handleSelectFile.bind(this),this.handleFiles=this.handleFiles.bind(this),this.handleDrop=this.handleDrop.bind(this),this.unstageFile=this.unstageFile.bind(this),this.handleMenuPaste=this.handleMenuPaste.bind(this),this.handlePasteEvent=this.handlePasteEvent.bind(this),this.fileElem=ae.createRef(),this.divElem=ae.createRef(),this.state={selectedFileName:""}}componentDidMount(){this.divElem.current?.addEventListener("paste",this.handlePasteEvent),this.divElem.current?.focus()}componentWillUnmount(){this.divElem.current?.removeEventListener("paste",this.handlePasteEvent)}fileElem;divElem;handleSelectFile(){this.fileElem.current&&(this.fileElem.current.value="",this.fileElem.current?.click())}handleFiles(e){e.stopPropagation(),e.preventDefault();const{files:t}=e.target;t!=null&&this.handleFile(t[0])}handleDrop(e){const{allowZip:t,clearDragError:n,dragError:s}=this.props;if(e.preventDefault(),e.stopPropagation(),s!=null){n();return}if(e.dataTransfer==null||e.dataTransfer.items==null||e.dataTransfer.items.length===0)return;const i=e.dataTransfer.items[0].getAsFile();N(i),Vs.isValidExtension(i.name,t)?this.handleFile(i):this.setState({dropError:Vs.FILE_TYPE_ERROR})}unstageFile(e){const{onCancel:t}=this.props;e.stopPropagation(),e.preventDefault(),t(),this.setState({selectedFileName:"",dropError:void 0})}handleFile(e){const{onFileOpened:t}=this.props;t(e),this.setState({selectedFileName:e.name,dropError:void 0})}handleMenuPaste(){const{onPaste:e,onError:t,uploadInProgress:n}=this.props;n||navigator.clipboard.readText().then(s=>{e(s),this.setState({selectedFileName:Td,dropError:void 0})}).catch(s=>t(s))}handlePasteEvent(e){e.stopPropagation(),e.preventDefault(),this.handleMenuPaste()}makeContextMenuItems(){const{uploadInProgress:e}=this.props;return[{title:"Paste",icon:md,action:this.handleMenuPaste,shortcut:qn.PASTE,disabled:e}]}getValidExtensions=he(e=>e?[...Ca,...Ed]:[...Ca]);getAcceptString=he(e=>this.getValidExtensions(e).join(", "));getFileTypeErrorString=he(e=>en.join(this.getValidExtensions(e),"or"));render(){const{allowZip:e,dragError:t,uploadInProgress:n}=this.props,{selectedFileName:s,dropError:i}=this.state,o=t??i,l=this.makeContextMenuItems();return r.jsxs("div",{ref:this.divElem,className:"csv-overlay fill-parent-absolute",onDragOver:Vs.handleDragOver,onDrop:this.handleDrop,tabIndex:-1,children:[r.jsx(se,{actions:l}),r.jsx("input",{ref:this.fileElem,type:"file",id:"fileElem",accept:this.getAcceptString(e),style:{display:"none"},onChange:this.handleFiles,"data-testid":"fileElem"}),!s&&(o===void 0||o==="")&&r.jsxs("div",{className:"message-content",children:[r.jsx("div",{className:"message-icon",children:r.jsx(X,{icon:Zm})}),r.jsx("label",{children:"Drop file (or paste values) here to import"}),r.jsx("div",{className:"message-small",children:r.jsx("label",{children:"or"})}),r.jsx(_,{kind:"primary",onClick:this.handleSelectFile,children:"Select File..."})]}),s&&(o===void 0||o==="")&&r.jsxs("div",{className:"selected-content",children:[r.jsx("div",{className:"selected-icon",children:r.jsx(X,{icon:Vs.getIcon(s)})}),r.jsxs("div",{className:"selected-text",children:[r.jsx("label",{children:"Selected File"}),r.jsxs("label",{className:"selected-name",children:[s,!n&&r.jsx(_,{kind:"ghost",className:"ml-2",onClick:this.unstageFile,icon:Wt,tooltip:"Remove"})]})]})]}),Boolean(o)&&r.jsxs("div",{className:"message-content",children:[r.jsx("div",{className:"message-icon",children:r.jsx(X,{icon:vs})}),r.jsx("label",{children:o}),o===Vs.FILE_TYPE_ERROR&&r.jsx("div",{className:"message-small",children:r.jsx("label",{children:this.getFileTypeErrorString(e)})})]})]})}}const hi=Vs;class mf{static INTEGER="int";static LONG="long";static DOUBLE="double";static BOOLEAN="bool";static STRING="string";static DATE_TIME="datetime";static LOCAL_TIME="localtime"}const Le=mf,yd="unknown",gf=2147483647,pf=-2147483648,Rd=/^[0-9]{4}-[0-1][0-9]-[0-3][0-9][ T][0-2][0-9]:[0-5][0-9]:[0-6][0-9](?:\.[0-9]{1,9})?(?: [a-zA-Z]+)?$/,xd=/^([0-9]+T)?([0-9]+):([0-9]+)(:[0-9]+)?(?:\.[0-9]{1,9})?$/;class bt{static determineType(e,t,n){if(!e||e===n)return t;switch(t){case Le.STRING:return Le.STRING;case Le.INTEGER:return bt.checkInteger(e);case Le.LONG:return bt.checkLong(e);case Le.DOUBLE:return bt.checkDouble(e);case Le.BOOLEAN:return bt.checkBoolean(e);case Le.DATE_TIME:return bt.checkDateTime(e);case Le.LOCAL_TIME:return bt.checkLocalTime(e);default:return bt.getTypeFromUnknown(e)}}static isNotParsableNumber(e){return isNaN(e)||e==="Infinity"||e==="-Infinity"}static checkInteger(e){const t=e.replace(/,/g,"");return bt.isNotParsableNumber(t)?Le.STRING:bt.getNumberType(t)}static checkLong(e){const t=e.replace(/,/g,"");return bt.isNotParsableNumber(t)?Le.STRING:t.includes(".")?Le.DOUBLE:Le.LONG}static checkDouble(e){const t=e.replace(/,/g,"");return bt.isNotParsableNumber(t)?Le.STRING:Le.DOUBLE}static checkBoolean(e){const t=e.toLowerCase();return t==="true"||t==="false"?Le.BOOLEAN:Le.STRING}static checkDateTime(e){return Rd.test(e)?Le.DATE_TIME:Le.STRING}static checkLocalTime(e){return xd.test(e)?Le.LOCAL_TIME:Le.STRING}static getTypeFromUnknown(e){const t=e.replace(/,/g,"");if(bt.isNotParsableNumber(t)){const n=e.toLowerCase();return n==="true"||n==="false"?Le.BOOLEAN:Rd.test(e)&&e.includes(":")?Le.DATE_TIME:xd.test(e)?Le.LOCAL_TIME:Le.STRING}return bt.getNumberType(t)}static getNumberType(e){if(e.includes("."))return Le.DOUBLE;const t=e.startsWith("-")?11:10;if(e.length>t)return Le.LONG;const n=parseInt(e,10);return n>gf||n<pf?Le.LONG:Le.INTEGER}constructor(e,t,n,s,i,o,l,a,d,h){this.onFileCompleted=e,this.file=t,this.readHeaders=n,this.nullString=i,this.onProgress=o,this.onError=l,this.chunks=0,this.totalChunks=a,this.isZip=d,this.shouldTrim=h,this.zipProgress=0,this.handleChunk=this.handleChunk.bind(this),this.handleComplete=this.handleComplete.bind(this),this.handleError=this.handleError.bind(this),this.handleNodeUpdate=this.handleNodeUpdate.bind(this),this.config={...s,error:this.handleError,chunk:this.handleChunk,complete:this.handleComplete}}onFileCompleted;file;readHeaders;nullString;onProgress;onError;types;chunks;totalChunks;isZip;shouldTrim;zipProgress;config;parse(){const e=this.isZip?this.file.nodeStream("nodebuffer",this.handleNodeUpdate):this.file;Aa.parse(e,this.config)}handleChunk(e,t){let{data:n}=e;if(!this.types){if(n==null||n.length===0){t.abort(),this.onError("Error parsing CSV: no data in file.");return}this.types=new Array(n[0].length).fill(yd),this.readHeaders&&(n=n.slice(1))}N(this.types);const s=[...this.types];n.forEach(l=>{if(l.length>=s.length){for(let a=0;a<s.length;a+=1)s[a]=bt.determineType(this.shouldTrim?l[a].trim():l[a],s[a],this.nullString);this.types=s}else t.abort(),this.onError(`Error parsing CSV: Insufficient data in row.
|
|
3
|
-
Expected length ${s.length} but found ${l.length}.
|
|
4
|
-
Row = ${l}`)}),this.chunks+=1;let i=0;this.totalChunks>0?i=Math.round(this.chunks/this.totalChunks*50):i=Math.round(this.zipProgress/2),this.onProgress(i)&&t.abort()}handleComplete(e){const{types:t,onFileCompleted:n}=this;N(t),(e==null||!e.meta.aborted)&&n(t.map(s=>s===yd?Le.STRING:s))}handleError(e){const{onError:t}=this;t(e)}handleNodeUpdate(e){this.zipProgress=e.percent}}const ff=bt,_o=ee.module("CsvParser"),Cf=650;class Xi{static generateHeaders=e=>{const t=[];for(let n=0;n<e;n+=1)t.push(Xi.generateHeaderRecursive(n));return t};static generateHeaderRecursive(e){let t="",n=e;return e>=26&&(t=t.concat(Xi.generateHeaderRecursive(Math.floor(e/26)-1)),n=e%26),t.concat(String.fromCharCode(65+n))}constructor({onFileCompleted:e,session:t,file:n,type:s,readHeaders:i=!0,onProgress:o,onError:l,timeZone:a,isZip:d}){this.onFileCompleted=e,this.session=t,this.file=n,this.isZip=d,this.type=s,this.readHeaders=i,this.timeZone=a,this.onProgress=o,this.onError=l,this.tables=[],this.chunks=0,this.totalChunks=d?0:Math.ceil(n.size/Aa.LocalChunkSize),this.isComplete=!1,this.zipProgress=0,this.numConsolidated=0,this.isCancelled=!1,this.handleChunk=this.handleChunk.bind(this),this.handleError=this.handleError.bind(this),this.handleComplete=this.handleComplete.bind(this),this.handleNodeUpdate=this.handleNodeUpdate.bind(this),this.handleCreateTable=this.handleCreateTable.bind(this),this.config={delimiter:s.delimiter,newline:s.newline,escapeChar:s.escapeChar,dynamicTyping:!1,error:this.handleError,skipEmptyLines:s.skipEmptyLines,chunk:this.handleChunk,complete:this.handleComplete,fastMode:!1}}onFileCompleted;session;file;isZip;type;readHeaders;timeZone;onProgress;onError;tables;headers;types;chunks;totalChunks;isComplete;zipProgress;consolidatedChunks;numConsolidated;isCancelled;config;cancel(){this.isCancelled=!0}transpose(e,t){const n=t.length,s=new Array(e).fill(null).map(()=>new Array(n));for(let i=0;i<n;i+=1){const o=t[i];if(o.length<e)throw new Error(`Insufficient columns. Expected ${e} but found ${o.length}
|
|
5
|
-
${o}`);for(let l=0;l<e;l+=1){const a=this.type.shouldTrim?t[i][l].trim():t[i][l];s[l][i]=this.nullCheck(a)}}return s}nullCheck(e){return e===this.type.nullString?"":e}parse(){const e=n=>{const s=this.isZip?this.file.nodeStream("nodebuffer",this.handleNodeUpdate):this.file;this.types=n,Aa.parse(s,this.config)};new ff(e,this.file,this.readHeaders,this.config,this.type.nullString,this.onProgress,this.onError,this.totalChunks,this.isZip,this.type.shouldTrim).parse()}handleChunk(e,t){const{readHeaders:n,onError:s,handleCreateTable:i,isZip:o,tables:l}=this;if(this.isCancelled){_o.debug2("CSV parser cancelled."),t.abort(),l.forEach(h=>h.close());return}let{data:a}=e;this.headers||(n?(this.headers=Ii.legalizeColumnNames(a[0]),a=a.slice(1)):this.headers=Xi.generateHeaders(a[0].length));let d=[];try{if(d=this.transpose(this.headers.length,a),o)this.consolidateChunks(d,t);else{const h=this.chunks;this.chunks+=1,i(h,d,t)}}catch(h){s(h)}}consolidateChunks(e,t){if(!this.consolidatedChunks)this.consolidatedChunks=e.slice();else for(let n=0;n<e.length;n+=1)this.consolidatedChunks[n]=this.consolidatedChunks[n].concat(e[n]);this.numConsolidated+=1,(this.numConsolidated>=Cf||this.isComplete)&&this.uploadConsolidatedChunks(t)}uploadConsolidatedChunks(e){const{handleCreateTable:t}=this,n=this.chunks;this.chunks+=1;const s=this.consolidatedChunks?.slice();this.consolidatedChunks=void 0,this.numConsolidated=0,N(s),t(n,s,e)}handleCreateTable(e,t,n){const{session:s,tables:i,onFileCompleted:o,totalChunks:l,types:a,onProgress:d,onError:h}=this;n&&n.pause(),N(this.headers),N(a),s.newTable(this.headers,a,t,this.timeZone).then(u=>{if(this.isCancelled){_o.debug2("CSV parser cancelled."),n&&n.abort(),i.forEach(g=>g.close());return}n&&n.resume(),i[e]=u;let m=0;l>0?m=Math.round(i.length/l*50)+50:m=Math.round(50+this.zipProgress/2),_o.debug2(`CSV parser progress ${m}`),d(m),this.isComplete&&i.length===this.chunks&&(_o.debug2("CSV parser complete."),o(i))}).catch(u=>{!this.isComplete&&n&&n.abort(),h(u)})}handleComplete(e){(e==null||e.meta.aborted==null)&&(this.isComplete=!0,this.consolidatedChunks&&this.uploadConsolidatedChunks(null))}handleError(e){const{onError:t}=this;t(e)}handleNodeUpdate(e){this.zipProgress=e.percent}}const Sf=Xi;class bf{static DEFAULT_TYPE="DEFAULT_CSV";static AUTO="AUTODETECT";static fromExtension(e){return e.endsWith(".csv")?"DEFAULT_CSV":e.endsWith(".tsv")||e.endsWith(".tab")?"TSV":e.endsWith(".psv")?"PIPE_SV":"AUTODETECT"}static TYPES=Object.freeze({DEFAULT_CSV:{name:"Default csv (trimmed)",delimiter:",",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},TSV:{name:"Tab seperated (tsv)",delimiter:" ",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},APACHE_COMMON_CSV:{name:"Apache Common csv",delimiter:",",newline:`\r
|
|
6
|
-
`,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:null},EXCEL_CSV:{name:"Excel csv (strict)",delimiter:",",newline:`\r
|
|
7
|
-
`,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!1,nullString:null},MY_SQL_CSV:{name:"MySQL csv",delimiter:" ",newline:`
|
|
8
|
-
`,escapeChar:"\\",shouldTrim:!0,skipEmptyLines:!1,nullString:"\\N"},RFC4180_CSV:{name:"RFC4180 csv",delimiter:",",newline:`\r
|
|
9
|
-
`,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!1,nullString:null},COLON_SV:{name:": colon sv",delimiter:":",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},SEMI_COLON_SV:{name:"; semi-colon sv",delimiter:";",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},PIPE_SV:{name:"| pipe separated (psv)",delimiter:"|",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},SPACE_SV:{name:'" " space sv',delimiter:" ",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},AUTODETECT:{name:"autodetect",delimiter:void 0,newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"}})}const Ki=bf;const Id=ee.module("CsvInputBar"),wf=Object.entries(Ki.TYPES).map(([c,e])=>r.jsx("option",{value:c,children:e.name},c));class vf extends w.Component{static defaultProps={file:null,paste:null,unzip:null};constructor(e){super(e),this.handleUpload=this.handleUpload.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleError=this.handleError.bind(this),this.handleTableName=this.handleTableName.bind(this),this.toggleFirstRowHeaders=this.toggleFirstRowHeaders.bind(this),this.handleProgress=this.handleProgress.bind(this),this.handleCancelInProgress=this.handleCancelInProgress.bind(this),this.handleQueryTypeChange=this.handleQueryTypeChange.bind(this),this.inputRef=ae.createRef(),this.state={tableName:"",tableNameSet:!1,isFirstRowHeaders:!0,showProgress:!1,progressValue:0,type:Ki.DEFAULT_TYPE,parser:null}}componentDidUpdate(e){const{file:t,paste:n}=this.props,{tableName:s,tableNameSet:i}=this.state;if(!i&&t!=null&&!s){const o=t.name.lastIndexOf("."),l=Ii.legalizeTableName(t.name.substring(0,o));this.setState({tableName:l,tableNameSet:!0}),this.inputRef.current?.focus()}else(t==null&&e.file!=null||n==null&&e.paste!=null)&&this.setState({tableName:"",tableNameSet:!1});n!=null&&n!==""&&!s&&this.inputRef.current&&this.inputRef.current.focus(),t!=null&&t!==e.file?this.setState({type:Ki.fromExtension(t.name)}):n!=null&&n!==""&&(e.paste===void 0||e.paste==="")&&this.setState({type:Ki.AUTO})}componentWillUnmount(){const{parser:e}=this.state;e&&e.cancel()}inputRef;handleCancel(){const{onClose:e}=this.props;e()}handleError(e){const{onClose:t,onError:n}=this.props;Id.error(e),n(e),t()}handleTableName(e){this.setState({tableName:e.target.value,tableNameSet:!0})}toggleFirstRowHeaders(){const{isFirstRowHeaders:e}=this.state;this.setState({isFirstRowHeaders:!e})}handleUpload(e){e.stopPropagation(),e.preventDefault();const{file:t,paste:n}=this.props;t!=null?t.name.endsWith(".zip")?this.handleZipFile(t):this.handleFile(t):n!==void 0&&n!==""&&this.handleFile(new Blob([n],{type:"text/plain"}))}handleFile(e,t=!1){Id.info(`Starting CSV parser for ${e instanceof File?e.name:"pasted values"} ${t?"":e.size} bytes`);const{session:n,timeZone:s,onInProgress:i}=this.props,{tableName:o,isFirstRowHeaders:l,type:a}=this.state,d=u=>{u.length===1?n.bindTableToVariable(u[0],o).then(()=>this.openTable()).catch(m=>this.handleError(m)):n.mergeTables(u).then(m=>{n.bindTableToVariable(m,o).then(()=>this.openTable()).catch(g=>this.handleError(g)),u.forEach(g=>g.close())}).catch(m=>this.handleError(m))},h=new Sf({onFileCompleted:d,session:n,file:e,type:Ki.TYPES[a],readHeaders:l,onProgress:this.handleProgress,onError:this.handleError,timeZone:s,isZip:t});h.parse(),this.setState({showProgress:!0,parser:h}),i(!0)}handleZipFile(e){const{onUpdate:t,unzip:n}=this.props;if(n==null){this.handleError(new Error("No support for zip files available."));return}n(e).then(s=>{let i=!1;for(let o=0;o<s.length;o+=1){const l=s[o];if(hi.isValidExtension(l.name)){t(`Loading ${l.name} as csv from ${e.name}`),i=!0,this.handleFile(l,!0);break}}if(!i)throw new Error(`No csv file found in ${e.name}`)}).catch(s=>this.handleError(s))}handleProgress(e){const{showProgress:t}=this.state;return t&&this.setState({progressValue:e}),!t}handleCancelInProgress(){const{onInProgress:e}=this.props,{parser:t}=this.state;t&&t.cancel(),this.setState({showProgress:!1,progressValue:0}),e(!1)}openTable(){const{onOpenTable:e,onClose:t}=this.props,{tableName:n}=this.state;e(n),t()}handleQueryTypeChange(e){this.setState({type:e.target.value})}render(){const{file:e,paste:t}=this.props,{tableName:n,isFirstRowHeaders:s,showProgress:i,progressValue:o,type:l}=this.state,a=Boolean(t)&&!n;return r.jsxs("div",{className:"csv-input-bar",children:[!i&&r.jsxs("form",{onSubmit:this.handleUpload,className:"csv-input-bar-container form-inline",children:[r.jsxs("div",{className:"form-group",children:[r.jsx("label",{htmlFor:"tableNameInput",children:"Table name"}),r.jsx("input",{ref:this.inputRef,id:"tableNameInput",type:"text",className:K("form-control",{"is-invalid":a}),value:n,onChange:this.handleTableName})]}),r.jsxs("div",{className:"form-group",children:[r.jsx("label",{htmlFor:"formatSelect",children:"File format"}),r.jsx("select",{id:"formatSelect",className:"custom-select",value:l,onChange:this.handleQueryTypeChange,children:wf})]}),r.jsx(nn,{className:"firstRowHeaders",checked:s,onChange:this.toggleFirstRowHeaders,children:"First row is column headers"}),r.jsxs("div",{className:"csv-input-buttons form-group",children:[r.jsx(_,{kind:"secondary",onClick:this.handleCancel,children:"Cancel"}),r.jsx(_,{kind:"primary",type:"submit",disabled:!(e!==null||t!==void 0&&t!=="")||!n,children:"Upload"})]})]}),i&&r.jsxs("div",{className:"csv-progress-container",children:[r.jsx("label",{children:"Uploading Table"}),r.jsx("div",{className:"progress",children:r.jsx("div",{className:"progress-bar bg-primary",style:{width:`${o}%`},"aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100})}),r.jsxs("label",{children:[o,"%"]}),r.jsx(_,{kind:"primary",onClick:this.handleCancelInProgress,children:"Cancel"})]})]})}}const Tf=vf;const Dd=ee.module("ConsoleMenu");class ml extends w.PureComponent{static makeItemActions(e,t,n,s,i){if(e.length===0)return[];const o={menuElement:r.jsx(xi,{value:t,onChange:s,className:"console-menu",ref:n})};let l=e;t&&(l=l.filter(({title:d})=>d!=null&&d.toLowerCase().indexOf(t.toLowerCase())>=0));const a=l.map(d=>({title:d.title,action:()=>{i(d)}}));return[o,...a]}constructor(e){super(e),this.handleTableFilterChange=this.handleTableFilterChange.bind(this),this.handleTableMenuClosed=this.handleTableMenuClosed.bind(this),this.handleTableMenuOpened=this.handleTableMenuOpened.bind(this),this.handleWidgetFilterChange=this.handleWidgetFilterChange.bind(this),this.handleWidgetMenuClosed=this.handleWidgetMenuClosed.bind(this),this.handleWidgetMenuOpened=this.handleWidgetMenuOpened.bind(this),this.state={tableFilterText:"",widgetFilterText:""}}tableSearchField;widgetSearchField;makeTableActions=he((e,t,n)=>{const s=e.filter(i=>Va.isTableType(i.type));return ml.makeItemActions(s,t,i=>{this.tableSearchField=i},this.handleTableFilterChange,n)});makeWidgetActions=he((e,t,n)=>{const s=e.filter(i=>Va.isWidgetType(i.type));return ml.makeItemActions(s,t,i=>{this.widgetSearchField=i},this.handleWidgetFilterChange,n)});handleTableFilterChange(e){Dd.debug("filtering tables..."),this.setState({tableFilterText:e.target.value})}handleTableMenuClosed(){this.setState({tableFilterText:""})}handleTableMenuOpened(){this.tableSearchField?.focus()}handleWidgetFilterChange(e){Dd.debug("filtering widgets..."),this.setState({widgetFilterText:e.target.value})}handleWidgetMenuClosed(){this.setState({widgetFilterText:""})}handleWidgetMenuOpened(){this.widgetSearchField?.focus()}render(){const{overflowActions:e,objects:t,openObject:n}=this.props,{tableFilterText:s,widgetFilterText:i}=this.state,o=this.makeTableActions(t,s,n),l=this.makeWidgetActions(t,i,n),a={placement:"bottom-end"},d=o.length===0,h=l.length===0;return r.jsxs("div",{className:"console-pane-menu",children:[r.jsxs(_,{kind:"ghost",className:"btn-link-icon",disabled:d,onClick:()=>{},tooltip:d?"No tables available":"Tables",children:[r.jsxs("div",{className:"fa-md fa-layers",children:[r.jsx(X,{mask:or,icon:$n,transform:"right-5 down-5"}),r.jsx(X,{icon:$n,transform:"right-8 down-6"})]}),r.jsx(Wn,{actions:o,onMenuOpened:this.handleTableMenuOpened,onMenuClosed:this.handleTableMenuClosed,options:{initialKeyboardIndex:1},popperOptions:a},"table-actions ")]}),r.jsxs(_,{kind:"ghost",className:"btn-link-icon",disabled:l.length===0,onClick:()=>{},tooltip:h?"No widgets available":"Widgets",children:[r.jsxs("div",{className:"fa-md fa-layers",children:[r.jsx(X,{mask:Kc,icon:$n,transform:"right-5 down-5"}),r.jsx(X,{icon:$n,transform:"right-8 down-6"})]}),r.jsx(Wn,{actions:l,onMenuOpened:this.handleWidgetMenuOpened,onMenuClosed:this.handleWidgetMenuClosed,options:{initialKeyboardIndex:1},popperOptions:a},"table-actions")]}),r.jsx(_,{kind:"ghost",className:"btn-overflow btn-link-icon",icon:qc,tooltip:"More Actions...",onClick:()=>{},children:r.jsx(Wn,{actions:e,popperOptions:a})})]})}}const Ef=ml;class yf extends w.PureComponent{static defaultProps={children:null};constructor(e){super(e),this.handleCommandStarted=this.handleCommandStarted.bind(this),this.handleCommandCompleted=this.handleCommandCompleted.bind(this),this.pending=new Xn,this.state={isDisconnected:!1,isCommandRunning:!1}}componentDidMount(){this.startListening()}componentWillUnmount(){this.stopListening(),this.cancelPendingPromises()}pending;startListening(){const{session:e}=this.props;e.addEventListener(I.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted)}stopListening(){const{session:e}=this.props;e.removeEventListener(I.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted)}cancelPendingPromises(){this.pending.cancel()}handleCommandStarted(e){const{result:t}=e.detail;this.pending.add(t).then(()=>this.handleCommandCompleted(null)).catch(n=>this.handleCommandCompleted(n)),this.setState({isCommandRunning:!0})}handleCommandCompleted(e){e instanceof Pl||this.setState({isCommandRunning:this.pending.pending.length>0})}render(){const{children:e,openObject:t,overflowActions:n,objects:s}=this.props,{isDisconnected:i,isCommandRunning:o}=this.state;let l=null,a=null;return i?(l="console-status-icon-disconnected",a="Worker is disconnected"):o?(l="console-status-icon-pending",a="Worker is busy"):(l="console-status-icon-idle",a="Worker is idle"),r.jsxs("div",{className:"console-pane-status-bar",children:[r.jsxs("div",{children:[r.jsx("div",{className:K("console-status-icon",l)}),r.jsx(tt,{children:a})]}),e,r.jsx(Ef,{overflowActions:n,openObject:t,objects:s})]})}}const Rf=yf,An=ee.module("Console"),Fd={isAutoLaunchPanelsEnabled:!0,isPrintStdOutEnabled:!0,isClosePanelsOnDisconnectEnabled:!0};class ui extends w.PureComponent{static defaultProps={statusBarChildren:null,settings:{},onSettingsChange:()=>{},scope:null,actions:[],historyChildren:null,timeZone:"America/New_York",objectMap:new Map,disabled:!1,unzip:null};static LOG_THROTTLE=500;static isErrorLevel(e){return e===ut.STDERR||e===ut.ERROR||e===ut.FATAL}static isOutputLevel(e){return e===ut.STDOUT||ui.isErrorLevel(e)}constructor(e){super(e),this.handleCommandResult=this.handleCommandResult.bind(this),this.handleCommandStarted=this.handleCommandStarted.bind(this),this.handleCommandSubmit=this.handleCommandSubmit.bind(this),this.handleClearShortcut=this.handleClearShortcut.bind(this),this.handleFocusHistory=this.handleFocusHistory.bind(this),this.handleLogMessage=this.handleLogMessage.bind(this),this.handleOverflowActions=this.handleOverflowActions.bind(this),this.handleScrollPaneScroll=this.handleScrollPaneScroll.bind(this),this.handleToggleAutoLaunchPanels=this.handleToggleAutoLaunchPanels.bind(this),this.handleToggleClosePanelsOnDisconnect=this.handleToggleClosePanelsOnDisconnect.bind(this),this.handleTogglePrintStdout=this.handleTogglePrintStdout.bind(this),this.handleUploadCsv=this.handleUploadCsv.bind(this),this.handleHideCsv=this.handleHideCsv.bind(this),this.handleCsvFileCanceled=this.handleCsvFileCanceled.bind(this),this.handleCsvFileOpened=this.handleCsvFileOpened.bind(this),this.handleCsvPaste=this.handleCsvPaste.bind(this),this.handleDragEnter=this.handleDragEnter.bind(this),this.handleDragLeave=this.handleDragLeave.bind(this),this.handleClearDragError=this.handleClearDragError.bind(this),this.handleOpenCsvTable=this.handleOpenCsvTable.bind(this),this.handleCsvUpdate=this.handleCsvUpdate.bind(this),this.handleCsvError=this.handleCsvError.bind(this),this.handleCsvInProgress=this.handleCsvInProgress.bind(this),this.consolePane=ae.createRef(),this.consoleInput=ae.createRef(),this.consoleHistoryScrollPane=ae.createRef(),this.pending=new Xn,this.queuedLogMessages=[];const{objectMap:t,settings:n}=this.props;this.state={consoleHistory:[],consoleHeight:0,isScrollDecorationShown:!1,objectHistoryMap:new Map,objectMap:new Map(t),showCsvOverlay:!1,csvFile:null,csvPaste:null,dragError:null,csvUploadInProgress:!1,...Fd,...n}}componentDidMount(){this.initConsoleLogging();const{session:e}=this.props;e.addEventListener(I.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted),this.updateDimensions()}componentDidUpdate(e,t){const{props:n,state:s}=this;this.sendSettingsChange(t,s),n.objectMap!==e.objectMap&&this.updateObjectMap()}componentWillUnmount(){const{session:e}=this.props;e.removeEventListener(I.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted),this.pending.cancel(),this.processLogMessageQueue.cancel(),this.deinitConsoleLogging()}cancelListener;consolePane;consoleInput;consoleHistoryScrollPane;pending;queuedLogMessages;initConsoleLogging(){const{session:e}=this.props;this.cancelListener=e.onLogMessage(this.handleLogMessage)}deinitConsoleLogging(){this.cancelListener!=null&&(this.cancelListener(),this.cancelListener=void 0)}handleClearShortcut(e){e.preventDefault(),e.stopPropagation(),this.consoleInput.current?.clear()}handleCommandStarted(e){const{code:t,result:n}=e.detail,s=this.pending.add(n),i={command:t,disabledObjects:[],startTime:Date.now(),cancelResult:()=>{n.cancel()},wrappedResult:s},{commandHistoryStorage:o,language:l,scope:a}=this.props,d=o.addItem(l,a,t,{command:t,startTime:new Date().toJSON()});d.catch(h=>{An.debug("Error adding workspace item",h)}),this.setState(h=>({consoleHistory:h.consoleHistory.concat(i)}),()=>{this.scrollConsoleHistoryToBottom(!0)}),s.then(h=>{this.handleCommandResult(h,i,d)}).catch(h=>{this.handleCommandError(h,i,d)})}handleCommandResult(e,t,n){const s={...t,wrappedResult:void 0,cancelResult:void 0,result:e??t.result};this.setState(({consoleHistory:i})=>{const o=i.lastIndexOf(t);if(o<0)return An.error("historyItem not found in consoleHistory"),null;const l=i.concat();return l[o]=s,{consoleHistory:l}}),e&&(this.updateHistory(e,s),this.updateKnownObjects(s),this.updateWorkspaceHistoryItem({error:e.error},n),this.closeRemovedItems(e.changes),this.openUpdatedItems(e.changes))}handleCommandError(e,t,n){if(ve.isCanceled(e)){An.debug("Called handleCommandError on a cancelled promise result");return}this.updateWorkspaceHistoryItem({error:`${e}`},n),this.setState(s=>{const i=s.consoleHistory.concat(),o=i.lastIndexOf(t),l={...t};return l.wrappedResult=void 0,l.cancelResult=void 0,l.endTime=Date.now(),l.result={error:e},i[o]=l,{consoleHistory:i}})}handleFocusHistory(e){e.preventDefault(),e.stopPropagation();const{focusCommandHistory:t}=this.props;t()}handleLogMessage(e){const{isPrintStdOutEnabled:t}=this.state;t&&ui.isOutputLevel(e.logLevel)&&this.queueLogMessage(e.message,e.logLevel)}queueLogMessage(e,t){const n={};ui.isErrorLevel(t)?n.error=e:n.message=e;const s={command:void 0,result:n};this.queuedLogMessages.push(s),this.processLogMessageQueue()}processLogMessageQueue=Ts(()=>{this.scrollConsoleHistoryToBottom(),this.setState(e=>{An.debug2("processLogMessageQueue",this.queuedLogMessages.length," items");let{consoleHistory:t}=e;return t=t.concat(this.queuedLogMessages),this.queuedLogMessages=[],{consoleHistory:t}})},ui.LOG_THROTTLE);openUpdatedItems(e){const{isAutoLaunchPanelsEnabled:t}=this.state;if(e==null||!t)return;const{openObject:n}=this.props;[...e.created,...e.updated].forEach(s=>n(s))}closeRemovedItems(e){if(e==null||e.removed==null||e.removed.length===0)return;const{closeObject:t}=this.props,{removed:n}=e;n.forEach(s=>t(s))}updateHistory(e,t){const n=t;e==null||e.changes==null||n==null||(n.endTime=Date.now(),this.scrollConsoleHistoryToBottom(),this.setState(s=>({consoleHistory:s.consoleHistory.concat()})))}updateKnownObjects(e){let t;if(e.result&&(t=e.result.changes),!t||(t.created==null||t.created.length===0)&&(t.updated==null||t.updated.length===0)&&(t.removed==null||t.removed.length===0)){An.debug2("updateKnownObjects no changes");return}this.setState(n=>{let{consoleHistory:s}=n;const i=s.lastIndexOf(e);if(i<0)return An.error("historyItem not found in state.consoleHistory"),null;const o=new Map(n.objectHistoryMap),l=new Map(n.objectMap),a=(d,h=!1)=>{const{title:u}=d;N(u);const m=o.get(u);if(m!=null&&m>=0){s===n.consoleHistory&&(s=s.concat());const g={...s[m],disabledObjects:[...s[m].disabledObjects??[],u]};s[m]=g}o.set(u,i),h?l.delete(u):l.set(u,d)};return t?.updated.forEach(d=>a(d)),t?.removed.forEach(d=>a(d,!0)),t?.created.forEach(d=>{const{title:h}=d;N(h),o.set(h,i),l.set(h,d)}),{objectHistoryMap:o,objectMap:l,consoleHistory:s}})}updateObjectMap(){const{objectMap:e}=this.props;this.setState({objectMap:e})}updateWorkspaceHistoryItem(e,t){const n=this.pending.add(t),s=new Date().toJSON();n.then(i=>{const o={...i,data:{...i.data,endTime:s,result:e}},{commandHistoryStorage:l,language:a}=this.props;l.updateItem(a,o).catch(d=>{An.warn("Error updating command history storage",d)})}).catch(i=>{An.debug("Error updating workspace history item",i)})}scrollConsoleHistoryToBottom(e=!1){const t=this.consoleHistoryScrollPane.current;N(t),!(!e&&t.scrollTop<t.scrollHeight-t.offsetHeight)&&window.requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})}handleScrollPaneScroll(){const e=this.consoleHistoryScrollPane.current;N(e),e.scrollTop>0&&e.scrollHeight>e.clientHeight?this.setState({isScrollDecorationShown:!0}):this.setState({isScrollDecorationShown:!1})}handleToggleAutoLaunchPanels(){this.setState(e=>({isAutoLaunchPanelsEnabled:!e.isAutoLaunchPanelsEnabled}))}handleToggleClosePanelsOnDisconnect(){this.setState(e=>({isClosePanelsOnDisconnectEnabled:!e.isClosePanelsOnDisconnectEnabled}))}handleTogglePrintStdout(){this.setState(e=>({isPrintStdOutEnabled:!e.isPrintStdOutEnabled}))}handleUploadCsv(){this.setState({showCsvOverlay:!0,dragError:null,csvUploadInProgress:!1})}handleHideCsv(){this.setState({showCsvOverlay:!1,csvFile:null,csvPaste:null,dragError:null,csvUploadInProgress:!1})}handleCsvFileCanceled(){this.setState({csvFile:null,csvPaste:null})}handleCsvFileOpened(e){this.setState({csvFile:e,csvPaste:null})}handleCsvPaste(e){this.setState({csvFile:null,csvPaste:e})}handleDragEnter(e){if(e.dataTransfer==null||e.dataTransfer.items==null||e.dataTransfer.items.length===0||e.dataTransfer.items[0].kind==="string")return;e.preventDefault(),e.stopPropagation(),this.setState({showCsvOverlay:!0});const{items:t}=e.dataTransfer;if(t.length>1){this.setState({dragError:hi.MULTIPLE_FILE_ERROR});return}const n=t[0];hi.isValidDropItem(n)?this.setState({dragError:null}):this.setState({dragError:hi.FILE_TYPE_ERROR})}handleDragLeave(e){e.currentTarget==null||e.currentTarget instanceof Element&&e.relatedTarget instanceof Element&&e.currentTarget.contains(e.relatedTarget)||(e.preventDefault(),e.stopPropagation(),this.setState({showCsvOverlay:!1,dragError:null}))}handleClearDragError(){this.setState({dragError:null})}handleOpenCsvTable(e){const{openObject:t,commandHistoryStorage:n,language:s,scope:i}=this.props,{consoleHistory:o,objectMap:l}=this.state,a={name:e,title:e,type:I.VariableType.TABLE},d=l.has(e),h={startTime:Date.now(),endTime:Date.now(),disabledObjects:[],result:{changes:{created:[],updated:[],removed:[],[d?"updated":"created"]:[a]}}},u=o.concat(h);this.setState({consoleHistory:u}),this.scrollConsoleHistoryToBottom(!0),this.updateKnownObjects(h),t({name:e,title:e,type:I.VariableType.TABLE}),n.addItem(s,i,e,{command:e,startTime:new Date().toJSON(),endTime:new Date().toJSON()})}addConsoleHistoryMessage(e,t){const{consoleHistory:n}=this.state,s={command:"",startTime:Date.now(),endTime:Date.now(),result:{message:e,error:t}},i=n.concat(s);this.setState({consoleHistory:i})}handleCsvUpdate(e){this.addConsoleHistoryMessage(e)}handleCsvError(e){this.addConsoleHistoryMessage(void 0,e!=null?`${e}`:void 0)}handleCsvInProgress(e){this.setState({csvUploadInProgress:e})}handleOverflowActions(){const{isAutoLaunchPanelsEnabled:e,isClosePanelsOnDisconnectEnabled:t,isPrintStdOutEnabled:n}=this.state,{actions:s}=this.props;return[...s,{title:"Print Stdout",action:this.handleTogglePrintStdout,group:se.groups.high,icon:n?Yn:void 0,order:10},{title:"Auto Launch Panels",action:this.handleToggleAutoLaunchPanels,group:se.groups.high,icon:e?Yn:void 0,order:20},{title:"Close Panels on Disconnect",action:this.handleToggleClosePanelsOnDisconnect,group:se.groups.high,icon:t?Yn:void 0,order:30},{title:"Upload Table from File",action:this.handleUploadCsv,group:se.groups.high+10,order:40}]}handleCommandSubmit(e){if(e==="clear"||e==="cls")this.clearConsoleHistory();else if(e.length>0){const{session:t}=this.props;t.runCode(e).catch(n=>{An.error("There was an error initiating the command",n)})}else{const t={command:" ",result:{},startTime:Date.now(),endTime:Date.now()};this.scrollConsoleHistoryToBottom(!0),this.setState(n=>({consoleHistory:n.consoleHistory.concat(t)}))}}clearConsoleHistory(){this.pending.cancel(),this.setState(e=>{const t=new Map([...e.objectHistoryMap.keys()].map(n=>[n,-1]));return{consoleHistory:[],objectHistoryMap:t}})}getObjects=he(e=>[...e.values()]);getContextActions=he(e=>[...e,{action:this.handleClearShortcut,shortcut:It.CONSOLE.CLEAR},{action:this.handleFocusHistory,shortcut:It.CONSOLE.FOCUS_HISTORY}]);addCommand(e,t=!0,n=!1){this.consoleInput.current&&(this.consoleInput.current.setConsoleText(e,t,n),t&&this.scrollConsoleHistoryToBottom(!0))}focus(){this.consoleInput.current?.focus()}sendSettingsChange(e,t,n=!0){const s=Object.keys(Fd),i={};let o=!1;for(let a=0;a<s.length;a+=1){const d=s[a],{[d]:h}=t,{[d]:u}=e;h!==u&&(o=!0),i[d]=h}if(n&&!o)return;const{onSettingsChange:l}=this.props;l(i)}updateDimensions(){this.consolePane.current&&this.setState({consoleHeight:this.consolePane.current.clientHeight}),this.consoleInput.current&&this.consoleInput.current.updateDimensions()}render(){const{actions:e,historyChildren:t,language:n,statusBarChildren:s,openObject:i,session:o,scope:l,commandHistoryStorage:a,timeZone:d,disabled:h,unzip:u}=this.props,{consoleHeight:m,consoleHistory:g,isScrollDecorationShown:p,objectMap:C,showCsvOverlay:f,csvFile:S,csvPaste:v,dragError:b,csvUploadInProgress:T}=this.state,y=this.getObjects(C),E=Math.round(m*.7),R=this.getContextActions(e);return r.jsxs("div",{role:"presentation",className:K("iris-console","h-100","w-100",{disabled:h}),children:[r.jsxs("div",{className:"console-pane",ref:this.consolePane,children:[r.jsx(Rf,{session:o,overflowActions:this.handleOverflowActions,openObject:i,objects:y,children:s}),r.jsxs("div",{className:"console-csv-container",onDragOver:hi.handleDragOver,onDragEnter:this.handleDragEnter,onDragLeave:this.handleDragLeave,children:[f&&r.jsx(hi,{onCancel:this.handleCsvFileCanceled,onFileOpened:this.handleCsvFileOpened,onPaste:this.handleCsvPaste,clearDragError:this.handleClearDragError,dragError:b,onError:this.handleCsvError,uploadInProgress:T,allowZip:u!=null}),r.jsxs("div",{role:"presentation",className:K("scroll-pane no-scroll-x",{"scroll-decoration":p}),onScroll:this.handleScrollPaneScroll,ref:this.consoleHistoryScrollPane,children:[r.jsx(Ep,{items:g,openObject:i,language:n,disabled:h}),t]})]}),!f&&r.jsx(vd,{ref:this.consoleInput,session:o,language:n,scope:l,onSubmit:this.handleCommandSubmit,maxHeight:E,commandHistoryStorage:a}),f&&r.jsx(Tf,{session:o,onOpenTable:this.handleOpenCsvTable,onClose:this.handleHideCsv,onUpdate:this.handleCsvUpdate,onError:this.handleCsvError,file:S??void 0,paste:v??void 0,onInProgress:this.handleCsvInProgress,timeZone:d,unzip:u})]}),r.jsx(se,{actions:R,ignoreClassNames:[vd.INPUT_CLASS_NAME]})]})}}const xf=ui;class If extends w.Component{static defaultProps={className:"fill-parent-absolute",onEditorInitialized:()=>{},onEditorWillDestroy:()=>{},settings:{}};constructor(e){super(e),this.handleResize=this.handleResize.bind(this),this.container=null,this.state={}}componentDidMount(){this.initEditor(),window.addEventListener("resize",this.handleResize)}componentWillUnmount(){window.removeEventListener("resize",this.handleResize),this.destroyEditor()}container;editor;setLanguage(e){if(this.editor){const t=this.editor.getModel();N(t),Kn.setModelLanguage(t,e)}}handleResize(){this.updateDimensions()}toggleFind(){this.editor&&(this.editor.focus(),this.editor.trigger("toggleFind","actions.find",void 0))}updateDimensions(){this.editor?.layout()}initEditor(){const{onEditorInitialized:e}=this.props;let{settings:t}=this.props;t={copyWithSyntaxHighlighting:!1,fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"python",lineNumbersMinChars:3,minimap:{enabled:!1},scrollBeyondLastLine:!1,tabCompletion:"on",value:"",wordWrap:"off",links:!0,...t},N(this.container),this.editor=Kn.create(this.container,t),this.editor.addAction({id:"find",label:"Find",keybindings:[tn.CtrlCmd|Cs.KeyF],precondition:void 0,keybindingContext:void 0,contextMenuGroupId:"navigation",contextMenuOrder:1,run:()=>{this.toggleFind()}}),this.editor.layout(),At.removeConflictingKeybindings(this.editor),xn.registerLinkProvider("plaintext",{provideLinks:At.provideLinks}),e(this.editor)}destroyEditor(){const{onEditorWillDestroy:e}=this.props;N(this.editor),e(this.editor),this.editor.dispose(),this.editor=void 0}render(){const{className:e}=this.props;return r.jsx("div",{className:K("editor-container",e),ref:t=>{this.container=t}})}}const pr=If;const qt=ee.module("ScriptEditor");class Df extends w.Component{static defaultProps={error:null,isLoading:!1,isLoaded:!1,focusOnMount:!0,onChange:()=>{},onEditorInitialized:()=>{},onEditorWillDestroy:()=>{},session:null};constructor(e){super(e),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorWillDestroy=this.handleEditorWillDestroy.bind(this),this.handleRun=this.handleRun.bind(this),this.handleRunSelected=this.handleRunSelected.bind(this),this.updateShortcuts=this.updateShortcuts.bind(this),this.contextActionCleanups=[],this.editorComponent=ae.createRef(),this.state={model:null}}componentDidMount(){Ve.addEventListener("onUpdate",this.updateShortcuts)}componentDidUpdate(e){const{sessionLanguage:t,settings:n}=this.props,s=n?.language;s!==e.settings?.language&&(qt.debug("Set language",s),this.setLanguage(s));const o=t==null&&e.sessionLanguage!=null,l=s===t,a=e.settings?.language===e.sessionLanguage;(o||t!==void 0&&a&&!l)&&(qt.debug("De-init completion and context actions"),this.deInitContextActions(),this.deInitCodeCompletion()),(t!=null&&e.sessionLanguage==null&&l||t!==void 0&&!a&&l)&&(qt.debug("Init completion and context actions"),this.initContextActions(),this.initCodeCompletion())}componentWillUnmount(){Ve.removeEventListener("onUpdate",this.updateShortcuts)}contextActionCleanups;completionCleanup;editor;editorComponent;getValue(){return this.editor?this.editor.getValue():(qt.error("Editor not initialized"),null)}getSelectedCommand(){const e=this.editor?.getSelection();N(e);const t=this.editor?.getModel();N(t);const{startLineNumber:n,endColumn:s}=e;let{endLineNumber:i}=e;s===1&&i>n&&(i-=1);const o=t?.getLineMinColumn(n),l=t?.getLineMaxColumn(i),a=e.setStartPosition(n,o).setEndPosition(i,l);return t?.getValueInRange(a)}handleEditorInitialized(e){const{focusOnMount:t,onChange:n,onEditorInitialized:s,settings:i,session:o,sessionLanguage:l}=this.props;qt.debug("handleEditorInitialized",l,o,i),this.editor=e,this.setState({model:this.editor.getModel()}),At.setEOL(e),At.registerPasteHandler(e),o!=null&&i&&l===i.language&&(this.initContextActions(),this.initCodeCompletion()),e.onDidChangeModelContent(n),t!=null&&t&&e.focus(),s(this.editor)}handleEditorWillDestroy(e){qt.debug("handleEditorWillDestroy");const{onEditorWillDestroy:t}=this.props;t(e),this.deInitContextActions(),this.deInitCodeCompletion(),this.setState({model:null}),this.editor=void 0}handleRun(){const{onRunCommand:e}=this.props,t=this.getValue();t!=null&&e(t)}handleRunSelected(){const{onRunCommand:e}=this.props,t=this.getSelectedCommand();e(t)}initContextActions(){if(this.contextActionCleanups.length>0){qt.error("Context actions already initialized.");return}if(!this.editor)return;const e=[];e.push(this.editor.addAction({id:"run-code",label:"Run",keybindings:[At.getMonacoKeyCodeFromShortcut(It.NOTEBOOK.RUN)],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:()=>{this.handleRun()}})),e.push(this.editor.addAction({id:"run-selected-code",label:"Run Selected",keybindings:[At.getMonacoKeyCodeFromShortcut(It.NOTEBOOK.RUN_SELECTED)],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:()=>{this.handleRunSelected()}})),this.contextActionCleanups=e}deInitContextActions(){this.contextActionCleanups.length>0&&(this.contextActionCleanups.forEach(e=>e.dispose()),this.contextActionCleanups=[])}updateShortcuts(){this.deInitContextActions(),this.initContextActions()}initCodeCompletion(){if(this.completionCleanup!=null){qt.error("Code completion already initialized.");return}const{session:e}=this.props;qt.debug("initCodeCompletion",this.editor,e),this.editor&&e!=null&&(this.completionCleanup=At.openDocument(this.editor,e))}deInitCodeCompletion(){const{session:e}=this.props;qt.debug("deInitCodeCompletion",this.editor,e),this.completionCleanup&&(this.completionCleanup.dispose(),this.completionCleanup=void 0,this.editor&&e!=null&&At.closeDocument(this.editor,e))}append(e,t=!0){N(this.editor);const n=this.editor.getModel();N(n);const s=n.getValue();s?n.setValue(`${s}
|
|
10
|
-
${e}`):n.setValue(`${e}`);const i=n.getLineCount(),o=n.getLineLength(i)+1;this.editor.setPosition({lineNumber:i,column:o}),t&&this.editor.focus()}updateDimensions(){qt.debug("updateDimensions"),this.editor&&this.editor.layout()}focus(){qt.debug("focus"),this.editor&&this.editor.focus()}toggleFind(){this.editorComponent.current&&this.editorComponent.current.toggleFind()}setLanguage(e){this.editorComponent.current&&e!==void 0&&this.editorComponent.current.setLanguage(e)}render(){const{error:e,isLoaded:t,isLoading:n,session:s,sessionLanguage:i,settings:o}=this.props,{model:l}=this.state,a=e?`Unable to open document. ${e}`:null,d=o?o.language??null:null,h=l&&s&&d===i;return r.jsxs(r.Fragment,{children:[(e||n)&&r.jsx("div",{className:"h-100 w-100 position-relative",children:r.jsx(Vl,{errorMessage:a,isLoading:n,isLoaded:t})}),t&&r.jsx("div",{className:"h-100 w-100 script-editor",children:o&&r.jsxs(r.Fragment,{children:[r.jsx(pr,{ref:this.editorComponent,settings:o,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy}),h!=null&&h&&r.jsx(ah,{model:l,language:d,session:s})]})})]})}}const Ff=Df,Nf={groovy:"Groovy",python:"Python",scala:"Scala"};class kf{static normalizeScriptLanguage(e){return Nf[e]||null}static getDisabledRunTooltip(e,t,n,s){return e?t?null:`${n} doesn't match the session language – ${s} disabled`:`Console session not connected – ${s} disabled`}}const Nd=kf;const Mf=250,Lf=2500;class fr extends w.Component{static defaultProps={onUpdate:()=>{}};static getTimeString(e,t){if(e==null||t===""||t===0)return null;const n=Math.round((new Date(t).valueOf()-new Date(e).valueOf())/1e3);return n<1?"<1s":_l.formatElapsedTime(n)}constructor(e){super(e),this.handleUpdate=this.handleUpdate.bind(this),this.handleError=this.handleError.bind(this),this.handleTimeout=this.handleTimeout.bind(this),this.state={currentTime:Date.now()}}componentDidMount(){this.loadData()}componentDidUpdate(e,t){const{data:n}=this.state;this.timer==null&&!n?.result&&Boolean(n?.startTime)&&!(n==null||n.endTime===void 0)?this.startTimer():(n?.result&&!t.data?.result||Boolean(n?.endTime)&&!(t.data==null||t.data.endTime===void 0))&&this.stopTimer()}componentWillUnmount(){this.loadData.cancel(),this.cleanup!=null&&this.cleanup(),this.stopTimer()}timer;cleanup;loadData=Ge(()=>{const{commandHistoryStorage:e,item:t,language:n}=this.props,{id:s}=t;this.cleanup=e.listenItem(n,s,this.handleUpdate,this.handleError)},Mf);startTimer(){this.stopTimer(),this.timer=setInterval(this.handleTimeout,1e3)}stopTimer(){this.timer&&(clearInterval(this.timer),this.timer=void 0)}updateTime(){this.setState({currentTime:Date.now()})}handleError(e){this.setState({error:`${e}`})}handleUpdate(e){const{data:t}=e??{};this.setState({data:t});const{onUpdate:n}=this.props;n?.(t)}handleTimeout(){this.updateTime()}getPreviewText=Te(e=>e.split(`
|
|
11
|
-
`,Lf).join(`
|
|
12
|
-
`),{max:1});render(){const{item:{name:e},language:t}=this.props,{currentTime:n,data:s,error:i}=this.state,{result:o,startTime:l,endTime:a}=s??{},d=o?.error??i,h=fr.getTimeString(l,a??n),u=this.getPreviewText(e),m=Boolean(h);return r.jsxs("div",{className:"command-history-item-tooltip",children:[r.jsxs("div",{className:"scroll-container",children:[r.jsx(zl,{language:t,children:u}),u.length<e.length&&r.jsx("p",{children:"Preview Truncated..."})]}),r.jsxs("div",{className:"result-info",children:[r.jsxs("div",{className:"d-flex justify-content-between",children:[Boolean(d)&&r.jsxs("div",{className:"text-danger mr-1",children:[r.jsx(X,{icon:vs})," Executed with errors"]}),r.jsxs("div",{className:"time-wrapper",children:["Elapsed time:"," ",m?r.jsx("span",{className:"time-string",children:h}):r.jsx(Nn,{})]})]}),Boolean(d)&&r.jsx("div",{className:"error-message",children:d})]})]})}}const Of=fr,Af=512;function hh(c){const{item:e,language:t,isSelected:n,commandHistoryStorage:s}=c,i=e.name.substring(0,Af),o=w.useRef(null),l=w.useCallback(()=>{o.current?.update()},[o]);return r.jsxs("div",{className:K("command-history-item",{selected:n}),children:[i,r.jsx(tt,{ref:o,interactive:!0,options:{placement:"left",modifiers:{preventOverflow:{enabled:!0,boundariesElement:"viewport",order:825}}},popperClassName:"command-history-item-popper",children:r.jsx(Of,{item:e,language:t,onUpdate:l,commandHistoryStorage:s})})]})}hh.defaultProps={isSelected:!1};class gl extends w.Component{static itemKey(e,t){return`${t.title}`}static renderContent(e){return e.selectionRequired!==void 0&&e.selectionRequired?r.jsxs("div",{className:"fa-md fa-layers",children:[r.jsx(X,{icon:yi,mask:e.icon,transform:"right-5 down-5 shrink-4"}),r.jsx(X,{icon:Qm,transform:"shrink-3 right-7 down-6"})]}):r.jsx(X,{icon:e.icon})}render(){const{actions:e,hasSelection:t}=this.props;return r.jsx("div",{className:"command-history-actions",children:e.map((n,s)=>r.jsx(_,{kind:"inline",className:K(n.className),onClick:n.action,tooltip:n.description,disabled:n.selectionRequired!==void 0&&n.selectionRequired&&!t,icon:gl.renderContent(n)},gl.itemKey(s,n)))})}}const _f=gl;const Pf=150,jf=150,kd=3,Md=ee.module("CommandHistoryViewportUpdater");function Hf({table:c,columns:e,top:t=0,bottom:n=0,search:s,isReversed:i=!1,onUpdate:o}){const l=w.useMemo(()=>Ge(d=>{c.setSearch(d??"")},Pf),[c]),a=w.useMemo(()=>Ts(d=>{const h=d.bottom-d.top,u=Math.max(0,d.top-h*kd),m=d.bottom+h*kd;c.setViewport({top:u,bottom:m,columns:d.columns})},jf),[c]);return w.useEffect(function(){const h=c.onUpdate(u=>{o({items:u.items??[],offset:u.offset??0})});return()=>{Md.debug("onUpdate cleanup"),h()}},[c,o]),w.useEffect(function(){l(s)},[l,s]),w.useEffect(function(){a({top:t,bottom:n,columns:e})},[a,t,n,e,s,i]),w.useEffect(()=>()=>{Md.debug2("Cancel throttledUpdateViewport"),a.cancel()},[a]),null}const ns=ee.module("CommandHistory");class En extends w.Component{static ITEM_HEIGHT=29;static MAX_SELECTION_COUNT=1e4;static menuGroups={send:se.groups.medium+100};static getCommandsFromViewport(e,t,n){const s=[];for(let i=0;i<n.length;i+=1){const o=n[i];for(let l=o[0];l<=o[1];l+=1)if(l>=t&&l<t+e.length){const{name:a}=e[l-t];s.push(a)}}return s}static async getCommandsFromSnapshot(e,t){return[...(await e.getSnapshot(t)).values()].map(s=>s.name)}constructor(e){super(e),this.copySelectedCommands=this.copySelectedCommands.bind(this),this.createNotebook=this.createNotebook.bind(this),this.sendToConsole=this.sendToConsole.bind(this),this.renderItem=this.renderItem.bind(this),this.runInConsole=this.runInConsole.bind(this),this.sendToNotebook=this.sendToNotebook.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleSelectionChange=this.handleSelectionChange.bind(this),this.handleSearchChange=this.handleSearchChange.bind(this),this.handleViewportChange=this.handleViewportChange.bind(this),this.handleViewportUpdate=this.handleViewportUpdate.bind(this),this.itemActions=[{title:"Copy Selection",description:"Copy selected commands to clipboard",icon:Jm,shortcut:qn.COPY,action:this.copySelectedCommands,group:se.groups.edit},{title:"Send to Console",description:"Open selected commands in the console",icon:gd,shortcut:It.COMMAND_HISTORY.SEND_TO_CONSOLE,action:this.sendToConsole,group:En.menuGroups.send,order:10},{title:"Run in Console",description:"Run selected commands in the console",icon:al,shortcut:It.COMMAND_HISTORY.RUN,action:this.runInConsole,group:En.menuGroups.send,order:10},{title:"Send to Active Notebook",description:"Open selected commands in a notebook",icon:pd,shortcut:It.COMMAND_HISTORY.SEND_TO_NOTEBOOK,action:this.sendToNotebook,group:En.menuGroups.send,order:20},{title:"Send to New Notebook",description:"Open selected commands in a new notebook",icon:Xc,action:this.createNotebook,group:En.menuGroups.send,order:30}],this.historyActions=[{title:"Send to Console",icon:gd,selectionRequired:!0,description:"Open selected commands in the console",action:this.sendToConsole},{title:"Send to Notebook",icon:pd,selectionRequired:!0,description:"Open selected commands in a notebook",action:this.sendToNotebook}],this.pending=new Xn,this.searchInputRef=ae.createRef(),this.itemListRef=ae.createRef();const{table:t}=e;this.state={actions:[],historyActions:this.historyActions,top:0,bottom:0,itemCount:t.size,items:[],offset:0,selectedRanges:[],searchText:""}}componentWillUnmount(){this.pending.cancel()}itemActions;historyActions;pending;searchInputRef;itemListRef;async getSelectedCommands(){const{items:e,offset:t,selectedRanges:n}=this.state,s=n.slice().sort((o,l)=>o[0]-l[0]);if(s.length===0)return[];if(s[0][0]>=t&&s[s.length-1][1]<t+e.length)return En.getCommandsFromViewport(e,t,s);const{table:i}=this.props;return this.pending.add(En.getCommandsFromSnapshot(i,s))}getSelectedCommandText(){return this.getSelectedCommands().then(e=>e.join(`
|
|
13
|
-
`))}updateActions(){this.setState(e=>{const{selectedRanges:t}=e,n=t.reduce((s,i)=>s+i[1]-i[0]+1,0);return n>0&&n<En.MAX_SELECTION_COUNT?(ns.debug("Updating actions",this.itemActions),{actions:this.itemActions}):(ns.debug("Disabling actions",n),{actions:[]})})}copySelectedCommands(){this.getSelectedCommandText().then(co).catch(ns.error)}createNotebook(){this.getSelectedCommandText().then(e=>{const{language:t,sendToNotebook:n}=this.props;n({value:e,language:t},!0)}).catch(ns.error)}sendToNotebook(){this.getSelectedCommandText().then(e=>{const{language:t,sendToNotebook:n}=this.props;n({value:e,language:t})}).catch(ns.error)}sendToConsole(){const{sendToConsole:e}=this.props;this.getSelectedCommandText().then(e).catch(ns.error)}runInConsole(){this.getSelectedCommandText().then(e=>{const{sendToConsole:t}=this.props;t(e,!0,!0)}).catch(ns.error)}handleSelect(e){const{sendToConsole:t}=this.props,{items:n,offset:s}=this.state;if(e<s||e>=s+n.length){ns.error("Invalid index!",e);return}const{name:i}=n[e-s];t(i)}handleSelectionChange(e){this.setState({selectedRanges:e}),this.updateActions()}handleViewportChange(e,t){this.setState({top:e,bottom:t})}handleSearchChange(e){this.setState({searchText:e.target.value,selectedRanges:[]})}handleViewportUpdate({items:e,offset:t}){const{table:n}=this.props,s=n.size;this.setState({items:e,itemCount:s,offset:t})}renderItem({item:e,itemIndex:t,isSelected:n}){const{language:s,commandHistoryStorage:i}=this.props;return r.jsx(hh,{isSelected:n,item:e,language:s,commandHistoryStorage:i})}focus(){this.searchInputRef.current&&this.searchInputRef.current.focus()}restoreScrollPosition(){this.itemListRef.current?.restoreScrollPosition()}render(){const{language:e,table:t}=this.props,{actions:n,historyActions:s,searchText:i,top:o,bottom:l,items:a,itemCount:d,offset:h,selectedRanges:u}=this.state,m=oh.LANGUAGE_MAP.get(e)??"";return r.jsxs("div",{className:"command-history",children:[r.jsxs("div",{className:"command-history-search-bar",children:[r.jsx(xi,{ref:this.searchInputRef,value:i,placeholder:`${m} Command History`,onChange:this.handleSearchChange}),r.jsx(_f,{actions:s,hasSelection:u.length>0})]}),r.jsxs("div",{className:"command-history-list",children:[r.jsx(Ei,{ref:this.itemListRef,itemCount:d,items:a,offset:h,selectedRanges:u,onSelect:this.handleSelect,onSelectionChange:this.handleSelectionChange,onViewportChange:this.handleViewportChange,renderItem:this.renderItem,rowHeight:En.ITEM_HEIGHT,isDoubleClickSelect:!0,isMultiSelect:!0,isStickyBottom:!0}),r.jsx(Hf,{table:t,top:o,bottom:l,search:i,onUpdate:this.handleViewportUpdate}),r.jsx(se,{actions:n})]})]})}}const Uf=En;class Vf extends w.PureComponent{constructor(e){super(e),this.handleSwitchClick=this.handleSwitchClick.bind(this)}handleSwitchClick(){const{logLevel:e,onClick:t}=this.props;t(e)}render(){const{logLevel:e,on:t}=this.props;return r.jsxs("div",{className:K("log-level-menu-item",e),children:[r.jsx(ym,{on:t,onClick:this.handleSwitchClick}),e]})}}const Bf=Vf;class wt extends w.PureComponent{static DefaultLogLevels=[ut.STDOUT,ut.ERROR,ut.FATAL,ut.STDERR,ut.WARN];static AllLogLevels=[ut.INFO,ut.STDOUT,ut.ERROR,ut.FATAL,ut.STDERR,ut.WARN,ut.DEBUG,ut.TRACE];static bufferTimeout=16;static maxLogSize=131072;static truncateSize=65536;static getLogText(e){const t=new Date(e.micros/1e3);return`${Va.formatTimestamp(t)} ${e.logLevel} ${e.message}`}constructor(e){super(e),this.handleClearClick=this.handleClearClick.bind(this),this.handleFlushTimeout=this.handleFlushTimeout.bind(this),this.handleLogMessage=this.handleLogMessage.bind(this),this.handleMenuItemClick=this.handleMenuItemClick.bind(this),this.handleResetClick=this.handleResetClick.bind(this),this.handleResize=this.handleResize.bind(this),this.handleToggleAllClick=this.handleToggleAllClick.bind(this),this.logLevelMenuItems={},this.editorContainer=null,this.bufferedMessages=[],this.messages=[],this.state={shownLogLevels:{}}}componentDidMount(){this.resetLogLevels(),this.initMonaco(),this.startListening(),window.addEventListener("resize",this.handleResize)}componentDidUpdate(e,t){this.updateDimensions();const{shownLogLevels:n}=this.state;t.shownLogLevels!==n&&this.refreshLogText();const{session:s}=this.props;e.session!==s&&(this.stopListening(),this.startListening(),this.clearLogs())}componentWillUnmount(){this.stopFlushTimer(),this.stopListening(),this.destroyMonaco(),window.removeEventListener("resize",this.handleResize)}cancelListener;editor;editorContainer;logLevelMenuItems;flushTimer;bufferedMessages;messages;getMenuActions(e){const t=[];t.push({menuElement:r.jsx("div",{className:"log-level-menu-title",children:"Display Log Levels"}),group:1,order:10});for(let n=0;n<wt.AllLogLevels.length;n+=1){const s=wt.AllLogLevels[n],i=e[s]!=null?e[s]:!1;t.push({title:s,group:1,order:n+100,menuElement:r.jsx(Bf,{logLevel:s,on:i,onClick:this.handleMenuItemClick,ref:o=>{o!=null&&(this.logLevelMenuItems[s]=o)}})})}return t.push({group:1,order:1e3,menuElement:r.jsxs("div",{className:"log-level-menu-controls",children:[r.jsx(_,{kind:"ghost",className:"log-level-toggle-all",onClick:this.handleToggleAllClick,children:"Toggle All"}),r.jsx(_,{kind:"ghost",onClick:this.handleResetClick,children:"Reset"})]})}),t}resetLogLevels(){const e={};for(let t=0;t<wt.AllLogLevels.length;t+=1){const n=wt.AllLogLevels[t],s=wt.DefaultLogLevels.some(i=>i===n);e[n]=s}this.setState({shownLogLevels:e})}startListening(){const{session:e}=this.props;this.cancelListener=e.onLogMessage(this.handleLogMessage)}stopListening(){this.cancelListener!=null&&(this.cancelListener(),this.cancelListener=void 0)}initMonaco(){N(this.editorContainer),this.editor=Kn.create(this.editorContainer,{copyWithSyntaxHighlighting:!1,fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"log",lineDecorationsWidth:0,lineNumbers:"off",lineNumbersMinChars:0,minimap:{enabled:!1},readOnly:!0,renderLineHighlight:"none",scrollBeyondLastLine:!1,value:"",wordWrap:"on"}),this.editor.addCommand(Cs.Escape,()=>{}),this.editor.addCommand(tn.Shift|Cs.Escape,()=>{}),this.editor.addCommand(Cs.Escape,()=>{const e=this.editor?.getPosition();N(e),this.editor?.setPosition(e)},"findWidgetVisible && editorTextFocus"),this.editor.addCommand(tn.Shift|Cs.Escape,()=>{const e=this.editor?.getPosition();N(e),this.editor?.setPosition(e)},"findWidgetVisible && editorTextFocus")}destroyMonaco(){this.editor&&(this.editor.dispose(),this.editor=void 0)}triggerFindWidget(){this.editor?.focus(),this.editor?.trigger("keyboard","actions.find",void 0)}toggleAll(){const{shownLogLevels:e}=this.state;let t=!0;for(let n=0;n<wt.AllLogLevels.length;n+=1){const s=wt.AllLogLevels[n];if(!e[s]){t=!1;break}}if(t)this.setState({shownLogLevels:{}});else{const n={};for(let s=0;s<wt.AllLogLevels.length;s+=1){const i=wt.AllLogLevels[s];n[i]=!0}this.setState({shownLogLevels:n})}}toggleLogLevel(e){const{shownLogLevels:t}=this.state,n=t[e],s={};s[e]=!n,this.updateLogLevels(s)}updateLogLevels(e){let{shownLogLevels:t}=this.state;t={...t,...e},this.setState({shownLogLevels:t})}appendLogText(e){if(!this.editor)return;const t=this.editor.getModel();let n=t?.getLineCount();N(n);let s=t?.getLineLength(n);N(s);const i=this.isBottomVisible(),o=[];if(s>0&&(o.push({range:{startLineNumber:n,startColumn:s+1,endLineNumber:n,endColumn:s+1},text:`
|
|
14
|
-
`,forceMoveMarkers:!0}),n+=1,s=0),o.push({range:{startLineNumber:n,startColumn:s,endLineNumber:n,endColumn:s},text:e,forceMoveMarkers:!0}),t?.applyEdits(o),i){const l=t?.getLineCount();N(l),this.editor.revealLine(l,1)}}refreshLogText(){if(!this.editor)return;this.truncateLogIfNecessary();const{shownLogLevels:e}=this.state,t=this.isBottomVisible();let n="";for(let s=0;s<this.messages.length;s+=1){const i=this.messages[s];if(e[i.logLevel]){const o=wt.getLogText(i);o.length>0&&(n+=o,o.charAt(o.length-1)!==`
|
|
15
|
-
`&&(n+=`
|
|
16
|
-
`))}}if(n=n.trimRight(),this.editor.setValue(n),t){const s=this.editor.getModel()?.getLineCount();N(s),this.editor.revealLine(s,1)}this.stopFlushTimer(),this.bufferedMessages=[]}truncateLogIfNecessary(){this.messages.length>wt.maxLogSize&&(this.messages=this.messages.splice(this.messages.length-wt.truncateSize))}scrollToBottom(){if(!this.editor)return;const e=this.editor?.getModel?.()?.getLineCount();N(e),this.editor.revealLine(e,1)}isBottomVisible(){if(!this.editor)return!0;const t=this.editor.getModel()?.getLineCount();return N(t),this.isLineVisible(t)}isLineVisible(e){const t=this.editor?.getVisibleRanges();if(t==null||t.length===0)return!1;for(let n=0;n<t.length;n+=1){const s=t[n];if(s.startLineNumber<=e&&e<=s.endLineNumber)return!0}return!1}isLogItemVisible(e){const{shownLogLevels:t}=this.state;return t[e.logLevel]}flush(){let e="";for(let t=0;t<this.bufferedMessages.length;t+=1){const n=this.bufferedMessages[t],s=wt.getLogText(n);e+=s,s.charAt(s.length-1)!==`
|
|
17
|
-
`&&(e+=`
|
|
18
|
-
`)}this.bufferedMessages=[],this.appendLogText(e)}queue(e){this.bufferedMessages.push(e),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,wt.bufferTimeout))}stopFlushTimer(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0)}updateDimensions(){this.editor&&this.editor.layout()}handleClearClick(){this.clearLogs()}clearLogs(){this.messages=[],this.refreshLogText()}handleFlushTimeout(){this.stopFlushTimer(),this.flush()}handleLogMessage(e){this.messages.push(e),this.editor&&this.isLogItemVisible(e)&&this.queue(e)}handleMenuItemClick(e){this.toggleLogLevel(e)}handleResetClick(){this.resetLogLevels()}handleResize(){this.updateDimensions()}handleToggleAllClick(){this.toggleAll()}render(){const e={placement:"bottom-end"},{shownLogLevels:t}=this.state,n=this.getMenuActions(t);return r.jsxs("div",{className:"log-pane h-100 w-100",children:[r.jsxs("div",{className:"log-pane-menu",children:[r.jsx(_,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:eg,tooltip:"Clear log"}),r.jsx(_,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:uo,tooltip:"Log Settings",onClick:()=>{},children:r.jsx(Wn,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:e})})]}),r.jsx("div",{className:"log-pane-editor h-100 w-100",ref:s=>{this.editorContainer=s}})]})}}const $f=wt;function uh(c){switch(c){case pe.eq:return"is exactly";case pe.eqIgnoreCase:return"is exactly (ignore case)";case pe.notEq:return"is not exactly";case pe.notEqIgnoreCase:return"is not exactly (ignore case)";case pe.contains:return"contains";case pe.notContains:return"does not contain";case pe.startsWith:return"starts with";case pe.endsWith:return"ends with";default:throw new Error(`Unrecognized text filter type ${c}`)}}function mh(c){switch(c){case pe.eq:return"is equal to";case pe.notEq:return"is not equal to";case pe.greaterThan:return"greater than";case pe.greaterThanOrEqualTo:return"greater than or equal to";case pe.lessThan:return"less than";case pe.lessThanOrEqualTo:return"less than or equal to";default:throw new Error(`Unrecognized number filter type ${c}`)}}function gh(c){switch(c){case pe.eq:return"date is";case pe.notEq:return"date is not";case pe.notEqIgnoreCase:case pe.greaterThan:return"date is after";case pe.greaterThanOrEqualTo:return"date is after or equal";case pe.lessThan:return"date is before";case pe.lessThanOrEqualTo:return"date is before or equal";default:throw new Error(`Unrecognized date filter type ${c}`)}}function Wf(c){switch(c){case pe.isTrue:return"Is True";case pe.isFalse:return"Is False";case pe.isNull:return"Is Null";default:throw new Error(`Unrecognized boolean filter type ${c}`)}}cl.register([tp,np,sp,ip,op,lp]);const ph=typeof ga=="function"?ga(cl):ga.default(cl);class yn{static EVENT_UPDATED="ChartModel.EVENT_UPDATED";static EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";static EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";static EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";static EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";static EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";static EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";static EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";constructor(){this.listeners=[],this.isDownsamplingDisabled=!1}listeners;formatter;rect;isDownsamplingDisabled;title;getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(e){}close(){}setFormatter(e){this.formatter=e}setDownsamplingDisabled(e){this.isDownsamplingDisabled=e}setDimensions(e){this.rect=e}setTitle(e){this.title=e}subscribe(e){this.listeners.push(e)}unsubscribe(e){this.listeners=this.listeners.filter(t=>t!==e)}fireEvent(e){for(let t=0;t<this.listeners.length;t+=1)this.listeners[t](e)}fireUpdate(e){this.fireEvent(new CustomEvent(yn.EVENT_UPDATED,{detail:e}))}fireDisconnect(){this.fireEvent(new CustomEvent(yn.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(yn.EVENT_RECONNECT))}fireDownsampleStart(e){this.fireEvent(new CustomEvent(yn.EVENT_DOWNSAMPLESTARTED,{detail:e}))}fireDownsampleFinish(e){this.fireEvent(new CustomEvent(yn.EVENT_DOWNSAMPLEFINISHED,{detail:e}))}fireDownsampleFail(e){this.fireEvent(new CustomEvent(yn.EVENT_DOWNSAMPLEFAILED,{detail:e}))}fireDownsampleNeeded(e){this.fireEvent(new CustomEvent(yn.EVENT_DOWNSAMPLENEEDED,{detail:e}))}fireLoadFinished(){this.fireEvent(new CustomEvent(yn.EVENT_LOADFINISHED))}}const Pn=yn,Gf="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",zf="#403e41",Kf="#5b5a5c",Yf="#c0bfbf",qf="#4878ea",Xf="rgba(91, 90, 92, 0.7)",Ct={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:Gf,gridcolor:zf,linecolor:Kf,zerolinecolor:Yf,activecolor:qf,rangebgcolor:Xf,"area-color":"#76d9e4","trend-color":"#d5f0c1","line-color":"#9edc6f","error-band-line-color":"white","error-band-fill-color":"rgba(213, 240, 193, 0.1)","ohlc-increasing":"#9edc6f","ohlc-decreasing":"#f95d84"},Ot=Object.freeze({paper_bgcolor:Ct["paper-bgcolor"],plot_bgcolor:Ct["plot-bgcolor"],title_color:Ct["title-color"],colorway:Ct.colorway,gridcolor:Ct.gridcolor,linecolor:Ct.linecolor,zerolinecolor:Ct.zerolinecolor,activecolor:Ct.activecolor,rangebgcolor:Ct.rangebgcolor,area_color:Ct["area-color"],trend_color:Ct["trend-color"],line_color:Ct["line-color"],error_band_line_color:Ct["error-band-line-color"],error_band_fill_color:Ct["error-band-fill-color"],ohlc_increasing:Ct["ohlc-increasing"],ohlc_decreasing:Ct["ohlc-decreasing"]}),Pi=ee.module("ChartUtils"),ss=Object.freeze(I.calendar.DayOfWeek.values()),Ld="io.deephaven.time.DateTime",Zf=36e5,Qf=1e6;function Jf(c){return c.asDate!==void 0}function eC(c){return c.asNumber!==void 0}function Od(c){return c.dhTimeZone!==void 0}function tC(c){return c!=null&&c.range!=null&&(c.autorange===!1||c.autorange===void 0)}class te{static DEFAULT_AXIS_SIZE=.15;static MIN_AXIS_SIZE=.025;static MAX_AXIS_SIZE=.2;static AXIS_SIZE_PX=75;static LEGEND_WIDTH_PX=50;static MAX_LEGEND_SIZE=.25;static ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});static DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";static DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});static DEFAULT_TITLE_PADDING=Object.freeze({t:8});static SUBTITLE_LINE_HEIGHT=25;static DEFAULT_MARKER_SIZE=6;static MODE_MARKERS="markers";static MODE_LINES="lines";static getPlotlyChartType(e,t){switch(e){case I.plot.SeriesPlotStyle.SCATTER:return t?"scatter":"scattergl";case I.plot.SeriesPlotStyle.LINE:return"scatter";case I.plot.SeriesPlotStyle.BAR:case I.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case I.plot.SeriesPlotStyle.PIE:return"pie";case I.plot.SeriesPlotStyle.TREEMAP:return"treemap";case I.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case I.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(e,t,n){const s=new Set;switch(e){case I.plot.SeriesPlotStyle.SCATTER:(t??!1)&&s.add(te.MODE_LINES),(n??!0)&&s.add(te.MODE_MARKERS);break;case I.plot.SeriesPlotStyle.LINE:(t??!0)&&s.add(te.MODE_LINES),(n??!1)&&s.add(te.MODE_MARKERS);break}return s.size>0?[...s].join("+"):void 0}static getPlotlyProperty(e,t){switch(e){case I.plot.SeriesPlotStyle.PIE:switch(t){case I.plot.SourceType.X:return"labels";case I.plot.SourceType.Y:return"values"}break;case I.plot.SeriesPlotStyle.OHLC:switch(t){case I.plot.SourceType.TIME:return"x"}break;case I.plot.SeriesPlotStyle.TREEMAP:switch(t){case I.plot.SourceType.X:return"ids";case I.plot.SourceType.Y:return"values";case I.plot.SourceType.LABEL:return"labels";case I.plot.SourceType.PARENT:return"parents";case I.plot.SourceType.COLOR:return"marker.colors"}break}switch(t){case I.plot.SourceType.X:return"x";case I.plot.SourceType.Y:return"y";case I.plot.SourceType.Z:return"z";case I.plot.SourceType.X_LOW:return"xLow";case I.plot.SourceType.X_HIGH:return"xHigh";case I.plot.SourceType.Y_LOW:return"yLow";case I.plot.SourceType.Y_HIGH:return"yHigh";case I.plot.SourceType.TIME:return"time";case I.plot.SourceType.OPEN:return"open";case I.plot.SourceType.HIGH:return"high";case I.plot.SourceType.LOW:return"low";case I.plot.SourceType.CLOSE:return"close";case I.plot.SourceType.SHAPE:return"shape";case I.plot.SourceType.SIZE:return"size";case I.plot.SourceType.LABEL:return"label";case I.plot.SourceType.COLOR:return"color";case I.plot.SourceType.PARENT:return"parent";case I.plot.SourceType.HOVER_TEXT:return"hovertext";case I.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${t}`)}}static getPlotlySeriesOrientation(e){const{sources:t}=e;return t.length===2&&t[0]?.axis?.type===I.plot.AxisType.Y?te.ORIENTATION.HORIZONTAL:te.ORIENTATION.VERTICAL}static getPlotlyErrorBars(e,t,n){const s=n.map((o,l)=>o-e[l]),i=t.map((o,l)=>e[l]-o);return{type:"data",symmetric:!1,array:s,arrayminus:i}}static getPlotlyDateFormat(e,t,n){const s=n?.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let i;const o=e?.getColumnTypeFormatter(t);return o!=null&&Od(o)&&o.dhTimeZone!=null&&o.showTimeZone&&(i=I.i18n.DateTimeFormat.format(" z",new Date,o.dhTimeZone)),{tickformat:s,ticksuffix:i,automargin:!0}}static convertNumberPrefix(e){return e.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(e,t,n){if(!n)return null;const i=n.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);N(i);const[,o,l,a,,d,h,u,m,g]=i,p=a.replace(",","").length,f=l.indexOf(",")>=0||a.indexOf(",")>=0?",":"",S=u!=null&&u!==""?"e":"f",v=m!==""?m:S,b=d.length+h.length,y=`0${p}${f}.${b}${v}`,E=te.convertNumberPrefix(o),R=te.convertNumberPrefix(g);return{tickformat:y,tickprefix:E,ticksuffix:R,automargin:!0}}static getPlotlyAxisFormat(e,t=null){const{axis:n,columnType:s}=e,{formatPattern:i}=n;let o=null;return F.isDateType(s)?(o=te.getPlotlyDateFormat(t,s,i),o=te.addTickSpacing(o,n,!0)):F.isNumberType(s)&&(o=te.getPlotlyNumberFormat(t,s,i),o=te.addTickSpacing(o,n,!1)),n.formatType===I.plot.AxisFormatType.CATEGORY&&(o?o.type="category":o={type:"category",tickformat:void 0,ticksuffix:void 0}),o}static addTickSpacing(e,t,n){const{gapBetweenMajorTicks:s}=t;if(s>0){const i=e||{};let o=s;return n&&(o=s/Qf),t.log&&(o=Math.log(o)),i.tickmode="linear",i.dtick=o,i}return e}static getSourceForAxis(e,t){for(let n=0;n<e.series.length;n+=1){const s=e.series[n];for(let i=0;i<s.sources.length;i+=1){const o=s.sources[i];if(o.axis===t)return o}}return null}static getSeriesVisibility(e,t){return t!=null&&t.hiddenSeries!=null&&t.hiddenSeries.includes(e)?"legendonly":!0}static getHiddenLabels(e){return e?.hiddenSeries?[...e.hiddenSeries]:[]}static makeSeriesData(e,t,n,s,i=te.ORIENTATION.VERTICAL){return{type:e,mode:t,name:n,orientation:i,showlegend:s??void 0}}static makeSeriesDataFromSeries(e,t,n,s=null,i=Ot){const{name:o,isLinesVisible:l,isShapesVisible:a,plotStyle:d,lineColor:h,shapeColor:u,sources:m,shape:g,shapeSize:p}=e,C=m.some(T=>T.axis?.businessCalendar),f=te.getChartType(d,C),S=te.getPlotlyChartMode(d,l??void 0,a??void 0),v=te.getPlotlySeriesOrientation(e),b=te.makeSeriesData(f,S,o,s,v);return te.addSourcesToSeriesData(b,d,m,t),te.addStylingToSeriesData(b,d,i,h,u,g,p,n),b}static addSourcesToSeriesData(e,t,n,s){const i=e;for(let o=0;o<n.length;o+=1){const l=n[o],{axis:a,type:d}=l,h=te.getPlotlyProperty(t,d);_c(i,h,[]);const u=a!=null?te.getAxisPropertyName(a.type):null;if(u!=null){const m=s.get(a.type);if(m){const g=m.indexOf(a),p=g>0?`${g+1}`:"";i[`${u}axis`]=`${u}${p}`}}}}static addStylingToSeriesData(e,t,n=Ot,s=null,i=null,o=null,l=null,a=null){const d=e;if(d.marker={line:{}},d.line={width:1},t===I.plot.SeriesPlotStyle.AREA?d.fill="tozeroy":t===I.plot.SeriesPlotStyle.STACKED_AREA?d.stackgroup="stack":t===I.plot.SeriesPlotStyle.STEP?d.line.shape="hv":t===I.plot.SeriesPlotStyle.HISTOGRAM?(d.width=[],d.marker.line!==void 0&&Object.assign(d.marker.line,{color:n.paper_bgcolor,width:1})):t===I.plot.SeriesPlotStyle.OHLC?(d.increasing={line:{color:n.ohlc_increasing}},d.decreasing={line:{color:n.ohlc_decreasing}}):t===I.plot.SeriesPlotStyle.PIE?(d.textinfo="label+percent",d.outsidetextfont={color:n.title_color}):t===I.plot.SeriesPlotStyle.TREEMAP&&(d.hoverinfo="text",d.textinfo="label+text",d.tiling={packing:"squarify",pad:0},d.textposition="middle center",d.outsidetextfont={color:n.title_color}),s!=null&&(t===I.plot.SeriesPlotStyle.BAR?d.marker.color=s:d.line.color=s),i!=null&&(d.marker.color=i),o!=null&&o.length>0)try{d.marker.symbol=te.getMarkerSymbol(o)}catch(h){Pi.warn("Unable to handle shape",o,":",h)}l!=null&&(d.marker.size=l*te.DEFAULT_MARKER_SIZE),a!=null&&t!==I.plot.SeriesPlotStyle.PIE&&(d.visible=a)}static getMarkerSymbol(e){switch(e){case"SQUARE":return"square";case"CIRCLE":return"circle";case"DIAMOND":return"diamond";case"UP_TRIANGLE":return"triangle-up";case"DOWN_TRIANGLE":return"triangle-down";case"RIGHT_TRIANGLE":return"triangle-right";case"LEFT_TRIANGLE":return"triangle-left";case"ELLIPSE":case"HORIZONTAL_RECTANGLE":case"VERTICAL_RECTANGLE":default:throw new Error(`Unrecognized shape ${e}`)}}static getAxisFormats(e,t){const n=new Map,s={tickformat:null,ticksuffix:null},i=te.getAllAxes(e),o=te.groupArray(i,"type"),{charts:l}=e;for(let a=0;a<l.length;a+=1){const d=l[a];for(let h=0;h<d.series.length;h+=1){const u=d.series[h],{sources:m}=u,g=m.filter(p=>p.axis);for(let p=0;p<g.length;p+=1){const C=g[p],{axis:f}=C,{type:S}=f,v=o.get(S);N(v);const b=v.indexOf(f),T=te.getAxisPropertyName(S);if(T!=null){const y=te.getAxisLayoutProperty(T,b);if(n.has(y))Pi.debug(`${y} already added.`);else{Pi.debug(`Adding ${y} to axisFormats.`);const E=te.getPlotlyAxisFormat(C,t);if(E===null)n.set(y,s);else{n.set(y,E);const{businessCalendar:R}=f;if(R!=null){const x=[],{businessPeriods:D,businessDays:L,holidays:M,timeZone:j}=R,A=t?.getColumnTypeFormatter(Ld);let W;Od(A)&&(W=A.dhTimeZone);const H=W?(j.standardOffset-W.standardOffset)/60:0;M.length>0&&x.push(...te.createRangeBreakValuesFromHolidays(M,j,W)),D.forEach(U=>x.push({pattern:"hour",bounds:[te.periodToDecimal(U.close)+H,te.periodToDecimal(U.open)+H]})),L.length<ss.length&&te.createBoundsFromDays(L).forEach(U=>x.push({pattern:"day of week",bounds:U})),E.rangebreaks=x}if(n.size===d.axes.length)return n}}}}}}return n}static getChartType(e,t){switch(e){case I.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return te.getPlotlyChartType(e,t)}}static getAxisPropertyName(e){switch(e){case I.plot.AxisType.X:return"x";case I.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(e){switch(e){case I.plot.AxisPosition.BOTTOM:return"bottom";case I.plot.AxisPosition.TOP:return"top";case I.plot.AxisPosition.LEFT:return"left";case I.plot.AxisPosition.RIGHT:return"right";default:return}}static getAllAxes(e){return e.charts.reduce((t,n)=>[...t,...n.axes],[])}static getChartForSeries(e,t){const{charts:n}=e;for(let s=0;s<n.length;s+=1){const i=n[s];for(let o=0;o<i.series.length;o+=1)if(t===i.series[o])return i}return null}static getLayoutRanges(e){const t={},n=Object.keys(e).filter(s=>s.indexOf("axis")>=0);for(let s=0;s<n.length;s+=1){const i=n[s],o=e[i];tC(o)&&(t[i]=[...o.range])}return t}static updateFigureAxes(e,t,n,s=0,i=0,o=Ot){const l=e,a=te.getAllAxes(t);for(let d=0;d<t.charts.length;d+=1){const h=t.charts[d],u=n?.(h),m=te.getChartBounds(t,h,s,i);te.updateLayoutAxes(l,h.axes,a,s,i,m,u,o)}te.removeStaleAxes(l,a)}static getChartBounds(e,t,n,s){const{cols:i,rows:o}=e,{column:l,colspan:a,row:d,rowspan:h}=t,u=l+a,m=d+h,g=1/i,p=1/o,C=te.AXIS_SIZE_PX/n,f=te.AXIS_SIZE_PX/s,S={bottom:(o-m)*p+(m<o?f/2:0),top:(o-d)*p-(d>0?f/2:0),left:l*g+(l>0?C/2:0),right:u*g-(u<i?C/2:0)};return(te.groupArray(t.axes,"position").get(I.plot.AxisPosition.RIGHT)??[]).length>0&&(n>0?S.right-=(S.right-S.left)*Math.max(0,Math.min(te.LEGEND_WIDTH_PX/n,te.MAX_LEGEND_SIZE)):S.right-=(S.right-S.left)*te.DEFAULT_AXIS_SIZE),S}static updateLayoutAxes(e,t,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},l,a=Ot){const d=s>0?Math.max(te.MIN_AXIS_SIZE,Math.min(te.AXIS_SIZE_PX/i,te.MAX_AXIS_SIZE)):te.DEFAULT_AXIS_SIZE,h=i>0?Math.max(te.MIN_AXIS_SIZE,Math.min(te.AXIS_SIZE_PX/s,te.MAX_AXIS_SIZE)):te.DEFAULT_AXIS_SIZE,u=e,m=te.groupArray(t,"position"),g=te.groupArray(t,"type"),p=[...g.keys()],C=te.groupArray(n,"type");for(let f=0;f<p.length;f+=1){const S=p[f],v=te.getAxisPropertyName(S);if(v!=null){const b=g.get(S),T=C.get(S),E=S===I.plot.AxisType.Y?i:s;N(b),N(T);for(let R=0;R<b.length;R+=1){const x=b[R],D=T.indexOf(x),L=te.getAxisLayoutProperty(v,D);u[L]==null&&(u[L]=te.makeLayoutAxis(S,a));const M=u[L];if(M!=null){te.updateLayoutAxis(M,x,R,m,d,h,o);const{range:j,autorange:A}=M;if(l!=null&&j!==void 0&&(A===void 0||A===!1)){const W=l(x),[H,U]=W(j);Pi.debug("Setting downsample range",E,H,U),x.range(E,H,U)}else x.range(E)}}}}}static removeStaleAxes(e,t){const n=e,s=te.groupArray(t,"type"),i=[...s.keys()];for(let o=0;o<i.length;o+=1){const l=i[o],a=s.get(l);N(a);let d=a.length;const h=te.getAxisPropertyName(l);if(h!=null){let u=te.getAxisLayoutProperty(h,d);for(;n[u]!=null;)delete n[u],d+=1,u=te.getAxisLayoutProperty(h,d)}}}static getAxisLayoutProperty(e,t){const n=t>0?`${t+1}`:"";return`${e??""}axis${n}`}static updateLayoutAxis(e,t,n,s,i,o,l){const d=t.type===I.plot.AxisType.Y?o:i,h=e,u=t.label??"";if(h.title!==void 0&&typeof h.title!="string"?h.title.text=u:h.title={text:u},t.log&&(h.type="log"),h.side=te.getAxisSide(t.position),n>0){h.overlaying=te.getAxisPropertyName(t.type)??void 0;const m=s.get(t.position)??[],g=m.indexOf(t);g>0&&(h.anchor="free",t.position===I.plot.AxisPosition.RIGHT?h.position=l.right+(g-m.length+1)*d:t.position===I.plot.AxisPosition.TOP?h.position=l.top+(g-m.length+1)*d:t.position===I.plot.AxisPosition.BOTTOM?h.position=l.bottom+(m.length-g+1)*d:t.position===I.plot.AxisPosition.LEFT&&(h.position=l.left+(m.length-g+1)*d))}else if(t.type===I.plot.AxisType.X){const m=s.get(I.plot.AxisPosition.LEFT)||[],g=s.get(I.plot.AxisPosition.RIGHT)||[],p=Math.max(l.left,l.left+(m.length-1)*o),C=Math.min(l.right-(g.length-1)*o,l.right);h.domain=[p,C]}else if(t.type===I.plot.AxisType.Y){const m=s.get(I.plot.AxisPosition.BOTTOM)||[],g=s.get(I.plot.AxisPosition.TOP)||[],p=Math.max(l.bottom,l.bottom+(m.length-1)*i),C=Math.min(l.top-(g.length-1)*i,l.top);h.domain=[p,C]}}static periodToDecimal(e){const t=e.split(":");return Number(t[0])+Number(t[1])/60}static createBoundsFromDays(e){const t=e.map(o=>ss.indexOf(o)),n=ss.filter(o=>!e.includes(o)).map(o=>ss.indexOf(o)),s=new Set;n.forEach(o=>{for(let l=o+1;l<o+ss.length;l+=1){const a=l%ss.length;if(t.includes(a)){s.add(a);break}}});const i=[];return s.forEach(o=>{for(let l=o-1;l>o-ss.length;l-=1){const a=l<0?l+ss.length:l;if(t.includes(a)){const d=(a+1)%7;i.push([d,o]);break}}}),i}static createRangeBreakValuesFromHolidays(e,t,n){const s=[],i=[];return e.forEach(o=>{o.businessPeriods.length>0?i.push(...te.createPartialHoliday(o,t,n)):s.push(te.createFullHoliday(o,t,n))}),[{values:s},...i]}static createFullHoliday(e,t,n){return te.adjustDateForTimeZone(`${e.date.toString()} 00:00:00.000000`,t,n)}static createPartialHoliday(e,t,n){const s=e.date.toString(),i=["00:00"];e.businessPeriods.forEach(l=>{i.push(l.open),i.push(l.close)}),i.push("24:00");const o=[];for(let l=0;l<i.length;l+=2){const a=i[l],d=i[l+1];if(a!==d){const h=[te.adjustDateForTimeZone(`${s} ${a}:00.000000`,t,n)],u=Zf*(te.periodToDecimal(d)-te.periodToDecimal(a));o.push({values:h,dvalue:u})}}return o}static adjustDateForTimeZone(e,t,n){return n&&n.standardOffset!==t.standardOffset?te.unwrapValue(te.wrapValue(e,Ld,t),n):e}static groupArray(e,t){return e.reduce((n,s)=>{const i=s[t],o=n.get(i)??[];return o.push(s),n.set(i,o),n},new Map)}static unwrapValue(e,t){if(e!=null){if(Jf(e))return I.i18n.DateTimeFormat.format(te.DATE_FORMAT,e,t);if(eC(e))return e.asNumber()}return e}static wrapValue(e,t,n=null){if(F.isDateType(t)&&typeof e=="string"){const s=e,i=te.DATE_FORMAT.substr(0,e.length),o=I.i18n.DateTimeFormat.parse(i,s);if(!n)return o;const l=`${i} Z`,a=I.i18n.DateTimeFormat.format("Z",o,n),d=I.i18n.DateTimeFormat.parse(l,`${s} ${a}`),h=I.i18n.DateTimeFormat.format("Z",d,n);return I.i18n.DateTimeFormat.parse(l,`${s} ${h}`)}return e}static makeLayoutAxis(e,t=Ot){const n={automargin:!0,gridcolor:t.gridcolor,linecolor:t.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:t.paper_bgcolor,tickfont:{color:t.zerolinecolor},title:{font:{color:t.title_color}}};return e===I.plot.AxisType.X?Object.assign(n,{showgrid:!0}):e===I.plot.AxisType.Y&&Object.assign(n,{zerolinecolor:t.zerolinecolor,zerolinewidth:2}),n}static getColorwayFromTheme(e=Ot){let t=[];return e.colorway&&(Array.isArray(e.colorway)?t=e.colorway:typeof e.colorway=="string"?t=e.colorway.split(" "):Pi.warn(`Unable to handle colorway property: ${e.colorway}`)),t}static makeDefaultLayout(e=Ot){const t={...e,autosize:!0,colorway:te.getColorwayFromTheme(e),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:e.title_color},yanchor:"top",pad:{...te.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:e.title_color}},margin:{...te.DEFAULT_MARGIN},xaxis:te.makeLayoutAxis(I.plot.AxisType.X,e),yaxis:te.makeLayoutAxis(I.plot.AxisType.Y,e)};return t.datarevision=0,t}static hydrateSettings(e){return{...e,type:e.type!=null?I.plot.SeriesPlotStyle[e.type]:void 0}}static titleFromSettings(e){const{series:t,xAxis:n,title:s=`${(t??[]).join(", ")} by ${n}`}=e;return s}static makeFigureSettings(e,t){const{series:n,xAxis:s,type:i}=e,o=te.titleFromSettings(e),l={formatType:`${I.plot.AxisFormatType.NUMBER}`,type:`${I.plot.AxisType.X}`,position:`${I.plot.AxisPosition.BOTTOM}`},a={formatType:`${I.plot.AxisFormatType.NUMBER}`,type:`${I.plot.AxisType.Y}`,position:`${I.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${I.plot.ChartType.XY}`,axes:[l,a],series:(n??[]).map(d=>({plotStyle:`${i}`,name:d,dataSources:[{type:`${I.plot.SourceType.X}`,columnName:s??"",axis:l,table:t},{type:`${I.plot.SourceType.Y}`,columnName:d,axis:a,table:t}]}))}],title:o}}}const qe=te;const is=ee.module("Chart");class mi extends w.Component{static defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Zs.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};static convertIcon(e){const[t,,,,n]=e.icon,s=`${n}`;return{width:t,path:s,ascent:t,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(e,t){return e?"Downsampling in progress...":t?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(e,t){return e?"animation-spin":t?void 0:"fill-active"}constructor(e){super(e),this.handleAfterPlot=this.handleAfterPlot.bind(this),this.handleDownsampleClick=this.handleDownsampleClick.bind(this),this.handleModelEvent=this.handleModelEvent.bind(this),this.handlePlotUpdate=this.handlePlotUpdate.bind(this),this.handleRelayout=this.handleRelayout.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.plot=ae.createRef(),this.plotWrapper=ae.createRef(),this.columnFormats=[],this.dateTimeFormatterOptions={},this.decimalFormatOptions={},this.integerFormatOptions={},this.isSubscribed=!1,this.isLoadedFired=!1,this.currentSeries=0,this.state={data:null,downsamplingError:null,isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,layout:{datarevision:0},revision:0}}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:e}=this.props;e&&this.subscribe()}componentDidUpdate(e){const{isActive:t,settings:n}=this.props;this.updateFormatterSettings(n),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}currentSeries;plot;plotWrapper;columnFormats;dateTimeFormatterOptions;decimalFormatOptions;integerFormatOptions;rect;ranges;isSubscribed;isLoadedFired;getCachedConfig=he((e,t,n,s)=>{const i=[],o=Boolean(e);if(o&&i.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:mi.convertIcon(Zc),attr:"fill-warning"}),t||n||s||o){const l=mi.downsampleButtonTitle(n,s),a=mi.downsampleButtonAttr(n,s),d=n?tg:ng;i.push({name:l,icon:mi.convertIcon(d),click:this.handleDownsampleClick,attr:a})}return{displaylogo:!1,displayModeBar:n||o?!0:"hover",modeBarButtons:[i,["toImage"],["zoom2d","pan2d"],["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]]}});getPlotRect(){return this.plotWrapper.current?.getBoundingClientRect()??null}initData(){const{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:{...t,...e.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:e}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){is.debug2("Delaying subscription until model dimensions are set");return}e.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:e}=this.props;e.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:e})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!e}),()=>{const{model:e}=this.props,{isDownsamplingDisabled:t}=this.state;e.setDownsamplingDisabled(t)})}handleModelEvent(e){const{type:t,detail:n}=e;switch(is.debug2("Received data update",t,n),t){case Pn.EVENT_UPDATED:{this.currentSeries+=1,this.setState(i=>{const{layout:o,revision:l}=i;return typeof o.datarevision=="number"&&(o.datarevision+=1),{data:n,layout:o,revision:l+1}});const{onUpdate:s}=this.props;s({isLoading:!this.isLoadedFired});break}case Pn.EVENT_LOADFINISHED:{const{onUpdate:s}=this.props;this.isLoadedFired=!0,s({isLoading:!1});break}case Pn.EVENT_DISCONNECT:{const{onDisconnect:s}=this.props;s();break}case Pn.EVENT_RECONNECT:{const{onReconnect:s}=this.props;s();break}case Pn.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case Pn.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case Pn.EVENT_DOWNSAMPLENEEDED:case Pn.EVENT_DOWNSAMPLEFAILED:{const s=n.message??n;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:s});const{onError:i}=this.props;i(new Error(s));break}default:is.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,n=qe.getLayoutRanges(t);!Je(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(e){if(is.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,n=[...e.hiddenlabels];t({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([e,t]){if(is.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:n}=this.state,{onSettingsChanged:s}=this.props;if(n!=null){const i=n.reduce((o,{name:l,visible:a})=>l!=null&&a==="legendonly"?[...o,l]:o,[]);s({hiddenSeries:i})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){is.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==t.width||this.rect.height!==t.height||e){this.rect=t;const{isActive:s,model:i}=this.props;i.setDimensions(t),s&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=Gn.getColumnFormats(e),n=Gn.getDateTimeFormatterOptions(e),{decimalFormatOptions:s={},integerFormatOptions:i={}}=e;(!Je(this.columnFormats,t)||!Je(this.dateTimeFormatterOptions,n)||!Je(this.decimalFormatOptions,s)||!Je(this.integerFormatOptions,i))&&(this.columnFormats=Gn.getColumnFormats(e),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const e=new gn(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:t}=this.props;t.setFormatter(e)}updateDimensions(){const e=this.getPlotRect();this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&cl.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{is.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:n,isDownsampleInProgress:s,isDownsamplingDisabled:i,layout:o,revision:l}=this.state,a=this.getCachedConfig(t,n,s,i),d=e!=null;return r.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:d&&r.jsx(ph,{ref:this.plot,data:e,layout:o,revision:l,config:a,onAfterPlot:this.handleAfterPlot,onError:is.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}}const nC=mi,yt=ee.module("FigureChartModel");class Cr extends Pn{static ADD_SERIES_DEBOUNCE=50;constructor(e,t={},n=Ot){super(),this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.figure=e,this.settings=t,this.theme=n,this.data=[];const s={data:{},layout:qe.makeDefaultLayout(n)};this.layout={grid:{rows:e.rows,columns:e.cols,pattern:"independent"},template:s},this.seriesDataMap=new Map,this.pendingSeries=[],this.oneClicks=[],this.filterColumnMap=new Map,this.lastFilter=new Map,this.isConnected=!0,this.seriesToProcess=new Set,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure()}figure;settings;theme;data;layout;seriesDataMap;pendingSeries;oneClicks;filterColumnMap;lastFilter;isConnected;seriesToProcess;close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=qe.getAllAxes(this.figure),n=[];for(let o=0;o<e.length;o+=1){const l=e[o];for(let a=0;a<l.series.length;a+=1){const d=l.series[a];n.push(d.name),this.addSeries(d,t,l.showLegend)}}const i=[...this.seriesDataMap.keys()].filter(o=>n.indexOf(o)<0);for(let o=0;o<i.length;o+=1){const l=i[o];this.seriesDataMap.delete(l)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,n){const s=qe.groupArray(t,"type"),i=qe.makeSeriesDataFromSeries(e,s,qe.getSeriesVisibility(e.name,this.settings),n,this.theme);if(this.seriesDataMap.set(e.name,i),this.data=[...this.seriesDataMap.values()],e.plotStyle===I.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===I.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=qe.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===I.plot.SeriesPlotStyle.PIE?n??void 0:!1,e.oneClick!=null){const{oneClick:o}=e,{columns:l}=o;for(let a=0;a<l.length;a+=1)this.filterColumnMap.set(l[a].name,l[a]);this.oneClicks.push(o)}this.updateLayoutFormats()}addPendingSeries=Ge(()=>{const e=qe.getAllAxes(this.figure),{pendingSeries:t}=this;for(let n=0;n<t.length;n+=1){const s=t[n],i=this.figure.charts.find(o=>o.series.includes(s));this.addSeries(s,e,i?.showLegend??null),s.subscribe()}this.pendingSeries=[]},Cr.ADD_SERIES_DEBOUNCE);subscribe(e){super.subscribe(e),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(e){super.unsubscribe(e),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){yt.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?I.plot.DownsampleOptions.DISABLE:I.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(I.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(I.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(I.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(I.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(I.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(I.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(I.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(I.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(I.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(I.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(I.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(I.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(I.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(I.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(I.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(I.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(I.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(I.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}getTimeZone=Te((e,t)=>{if(t!=null){const n=t.getColumnTypeFormatter(e);if(n!=null)return n.dhTimeZone}});getValueTranslator=Te((e,t)=>{const n=this.getTimeZone(e,t);return s=>qe.unwrapValue(s,n)});getValueParser=Te((e,t)=>{const n=this.getTimeZone(e,t);return s=>qe.wrapValue(s,e,n)});getRangeParser=Te((e,t)=>n=>{let[s,i]=n;const o=this.getValueParser(e,t);return s=o(s),i=o(i),[s,i]});getAxisRangeParser=Te((e,t)=>n=>{const s=qe.getSourceForAxis(e,n);return s?this.getRangeParser(s.columnType,t):i=>i});handleDownsampleStart(e){yt.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){yt.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){yt.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){yt.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:n}=t;yt.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];yt.debug2("handleFigureUpdated updating series",o.name);const{sources:l}=o;for(let a=0;a<l.length;a+=1){const d=l[a],{columnType:h,type:u}=d,m=this.getValueTranslator(h,this.formatter),g=t.getArray(o,u,m);this.setDataArrayForSeries(o,u,g)}this.seriesToProcess.delete(o.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(o)}const{data:s}=this;this.fireUpdate(s)}handleRequestFailed(e){yt.error("Request failed",e)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(e){super.setFormatter(e),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(e){super.setDownsamplingDisabled(e),this.resubscribe()}handleFigureDisconnected(e){yt.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){yt.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;yt.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){super.setTitle(e);const t=(e??"").match(/<br>/g)?.length??0,n=qe.DEFAULT_MARGIN.t+t*qe.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=n:this.layout.margin={t:n},typeof this.layout.title=="string"?this.layout.title=e:(this.layout.title={...this.layout.title},this.layout.title.text=e,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=qe.DEFAULT_TITLE_PADDING.t+t*qe.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){return!this.rect||!this.rect.width?0:Math.max(this.rect.width-(this.layout.margin?.l??0)-(this.layout.margin?.r??0),0)}getPlotHeight(){return!this.rect||!this.rect.height?0:Math.max(this.rect.height-(this.layout.margin?.t??0)-(this.layout.margin?.b??0),0)}updateAxisPositions(){const e=this.getPlotWidth(),t=this.getPlotHeight();qe.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;qe.getAxisFormats(this.figure,this.formatter).forEach((t,n)=>{yt.debug(`Assigning ${n}`,this.layout[n],t);const s=this.layout[n];s!=null?Object.assign(s,t):yt.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(e,t,n){const{name:s,plotStyle:i}=e,o=this.seriesDataMap.get(s),l=qe.getPlotlyProperty(i,t);o&&_c(o,l,n)}cleanSeries(e){const{name:t,plotStyle:n}=e,s=this.seriesDataMap.get(t);if(s!=null){if(n===I.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:i,xHigh:o}=s;if(i&&o&&i.length===o.length){const l=[];for(let a=0;a<i.length;a+=1)l.push(o[a]-i[a]);s.width=l}}else if(n===I.plot.SeriesPlotStyle.LINE){const{x:i,xLow:o,xHigh:l,y:a,yLow:d,yHigh:h}=s;o&&l&&o!==i&&(s.error_x=qe.getPlotlyErrorBars(i,o,l)),d&&h&&d!==a&&(s.error_y=qe.getPlotlyErrorBars(a,d,h))}else if(n===I.plot.SeriesPlotStyle.TREEMAP){const{ids:i,labels:o}=s;i!==void 0&&o===void 0&&(s.labels=i)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){yt.warn("Trying to set a filter, but no one click!");return}yt.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const n=this.oneClicks[t],{columns:s}=n;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(o=>{const l=e.get(o);this.lastFilter.get(o)!==l&&s.find(a=>a.name===o)!=null&&n.setValueForColumn(o,l)})}this.lastFilter=new Map(e)}setFigure(e){this.close(),this.figure=e,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(e){this.settings=e}}const Ad=Cr;class Sr{static async makeModelFromSettings(e,t,n=Ot){const s=await Sr.makeFigureFromSettings(e,t);return new Ad(s,e,n)}static async makeFigureFromSettings(e,t){const n=await t.copy();return n.applyCustomColumns(t.customColumns),n.applyFilter(t.filter),n.applySort(t.sort),I.plot.Figure.create(qe.makeFigureSettings(e,n))}static async makeModel(e,t,n=Ot){return new Ad(t,e,n)}}const pl=Sr;function _d(c){return c.setFigure!==void 0}const sC=ee.module("HeapUsage");function iC({connection:c,defaultUpdateInterval:e,hoverUpdateInterval:t,bgMonitoring:n=!0,monitorDuration:s}){const[i,o]=w.useState({freeMemory:0,maximumHeapSize:999,totalHeapSize:0}),[l,a]=w.useState(!1),d=w.useRef({timestamps:[],usages:[]});w.useEffect(function(){const M=async()=>{try{const A=await c.getWorkerHeapInfo();if(o(A),n||l){const W=(A.totalHeapSize-A.freeMemory)/A.maximumHeapSize,H=Date.now(),{timestamps:U,usages:P}=d.current;for(;U.length!==0&&H-U[0]>s*1.5;)U.shift(),P.shift();U.push(H),P.push(W)}else d.current={timestamps:[],usages:[]}}catch(A){sC.warn("Unable to get heap usage",A)}};M();const j=setInterval(M,l?t:e);return()=>{clearInterval(j)}},[l,t,c,e,s,n]);const h=(L,M)=>Math.round(L*10**M)/10**M,u=2,m=1024**3,{freeMemory:g,totalHeapSize:p,maximumHeapSize:C}=i,f=h(g/m,u),S=h(p/m,u),v=h(C/m,u),b=S-f,T=(L,M,j=!1)=>r.jsxs("div",{className:K("heap-usage-info-row",{"heading-bottom-border":j}),children:[r.jsx("div",{className:"font-weight-bold",children:L}),r.jsx("div",{children:M})]}),{timestamps:y,usages:E}=d.current,R=y[y.length-1]??0,x=p/C,D=(p-g)/C;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"max-memory",children:[r.jsx("div",{className:"total-memory",style:{width:`calc(${x*100}% - ${x*2}px`}}),r.jsx("div",{className:K("used-memory",{"heap-overflow":(p-g)/C>.95}),style:{width:`calc(${D*100}% - ${D*2}px`}}),r.jsxs("div",{className:"memory-text",children:[v.toFixed(1)," GB"]})]}),r.jsx(tt,{onEntered:()=>a(!0),onExited:()=>a(!1),interactive:!0,children:r.jsxs("div",{className:"heap-tooltip",children:[T("In use:",`${b.toFixed(u)} of ${v.toFixed(u)} GB`,!0),T("Free:",`${f.toFixed(u)} GB`),T("Total:",`${S.toFixed(u)} GB`),T("Max:",`${v.toFixed(u)} GB`),r.jsx("div",{className:"heap-plot",children:r.jsx(ph,{data:[{x:[...y],y:[...E],type:"scatter",mode:"lines"}],config:{staticPlot:!0,responsive:!0},style:{width:"196px",height:"100px"},layout:{legend:!1,margin:{l:2,t:2,r:2,b:2},plot_bgcolor:"transparent",paper_bgcolor:"transparent",colorway:["#4878ea"],xaxis:{dtick:Math.round(s/6),gridcolor:Ot.linecolor,range:[R-s,R],linecolor:Ot.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:Ot.linecolor,range:[0,1],linecolor:Ot.linecolor,linewidth:2,mirror:!0}}})}),r.jsxs("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(s/1e3/60)," min."]})]})})]})}const br=Object.freeze({}),oC=new Map,fh=c=>c.user,wr=c=>c.storage,Ch=c=>wr(c).commandHistoryStorage,Sh=c=>wr(c).fileStorage,lC=c=>wr(c).workspaceStorage,Kl=c=>c.workspace,pt=c=>Kl(c).data.settings,bh=c=>pt(c).defaultDateTimeFormat,wh=c=>pt(c).defaultDecimalFormatOptions??br,vh=c=>pt(c).defaultIntegerFormatOptions??br,Th=c=>pt(c).formatter,go=c=>pt(c).timeZone,Eh=c=>pt(c).showTimeZone,yh=c=>pt(c).showTSeparator,Rh=c=>pt(c).truncateNumbersWithPound,aC=c=>pt(c).shortcutOverrides,rC=c=>pt(c).defaultNotebookSettings??br,Yl=c=>c.activeTool,dC=c=>c.plugins??oC,xh="SET_ACTIVE_TOOL",Ih="SET_COMMAND_HISTORY_STORAGE",Dh="SET_FILE_STORAGE",Fh="SET_PLUGINS",Nh="SET_USER",kh="SET_WORKSPACE",Mh="SET_WORKSPACE_STORAGE",Lh="SET_SERVER_CONFIG_VALUES",cC=c=>({type:Nh,payload:c}),Oh=c=>({type:kh,payload:c}),hC=c=>({type:Mh,payload:c}),uC=c=>({type:Ih,payload:c}),mC=c=>({type:Dh,payload:c}),gC=c=>(e,t)=>{e(Oh(c));const{storage:n}=t(),{workspaceStorage:s}=n;return s.save(c)},Ah=c=>(e,t)=>{const{workspace:n}=t(),{data:s}=n,i={...n,data:{...s,...c}};return e(gC(i))},ql=c=>e=>e(Ah({settings:c})),Xl=c=>({type:xh,payload:c}),pC=c=>({type:Fh,payload:c}),fC=c=>({type:Lh,payload:c});function _h(c,e){return(t=e,n)=>{switch(n.type){case c:{const s=n.payload;return s==null?null:t!=null?{...t,...s}:{...s}}default:return t}}}function CC(c,e={},t=!0){return(n=e,s)=>{switch(s.type){case c:{const{id:i,payload:o}=s;return t&&Je({payload:o},{payload:n[i]})?n:{...n,[i]:o}}default:return n}}}function Js(c,e){return(t=e,n)=>{switch(n.type){case c:return n.payload;default:return t}}}const SC=Js(xh,null),bC=Js(Fh,null),wC=Js(Ih,null),vC=Js(Dh,null),TC=Js(Mh,null),EC=er({commandHistoryStorage:wC,fileStorage:vC,workspaceStorage:TC}),yC=_h(Nh,null),RC=_h(kh,null),xC=Js(Lh,null),IC={activeTool:SC,plugins:bC,storage:EC,user:yC,workspace:RC,serverConfigValues:xC},DC=IC;class FC{reducers={};listener=null;register(e,t){this.reducers={...this.reducers,[e]:t},this.listener?.(this.reducers)}setListener(e){this.listener=e}}const NC=new FC,po=NC,Pd=ee.module("redux-logger"),kC=c=>e=>t=>{Pd.debug("dispatching",t);const n=e(t);return Pd.debug("next state",c.getState()),n},MC=kC,LC=ee.module("redux-crashReporter"),OC=c=>e=>t=>{try{return e(t)}catch(n){throw LC.error("Error executing",t," with state ",c.getState(),":",n),n}},AC=OC,_C=[MC,AC,qu];Object.entries(DC).map(([c,e])=>po.register(c,e));const PC=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__??Qu,Ph=Xu(er(po.reducers),PC(Zu(..._C)));po.setListener(c=>{Ph.replaceReducer(er(c))});const vr=Ph,jh=Object.freeze({openPopouts:[],settings:{hasHeaders:!0,constrainDragToContainer:!0,reorderEnabled:!0,selectionEnabled:!1,popoutWholeStack:!1,blockedPopoutsThrowError:!0,closePopoutsOnUnload:!0,showPopoutIcon:!0,showMaximiseIcon:!0,showCloseIcon:!0,responsiveMode:"onload",tabOverlapAllowance:0,tabControlOffset:10},dimensions:{borderWidth:5,borderGrabWidth:10,minItemHeight:10,minItemWidth:10,headerHeight:20,dragProxyWidth:300,dragProxyHeight:200},labels:{close:"Close",maximise:"Maximize",minimise:"Minimize",popout:"Open in new window",popin:"Pop in",tabDropdown:"Additional tabs",tabNextLabel:"Next",tabPreviousLabel:"Previous"},content:[]});function Hh(c){return c.componentName!==void 0}function jC(c){return c.component!==void 0}const Uh=Object.freeze({type:"default",isClosable:!0,isFocusOnShow:!0,reorderEnabled:!0,title:""}),HC=Object.freeze(Object.defineProperty({__proto__:null,defaultConfig:jh,isGLComponentConfig:Hh,isReactComponentConfig:jC,itemDefaultConfig:Uh},Symbol.toStringTag,{value:"Module"}));class fl{static ALL_EVENT="__all";_mSubscriptions;constructor(){this._mSubscriptions={},this._mSubscriptions[fl.ALL_EVENT]=[]}on(e,t,n){if(typeof t!="function")throw new Error("Tried to listen to event "+e+" with non-function callback "+t);this._mSubscriptions[e]||(this._mSubscriptions[e]=[]),this._mSubscriptions[e].push({fn:t,ctx:n})}emit(e,...t){const n=this._mSubscriptions[e];if(n)for(let i=0;i<n.length;i++){const o=n[i].ctx||{};n[i].fn.apply(o,t)}t.unshift(e);const s=this._mSubscriptions[fl.ALL_EVENT];for(let i=0;i<s.length;i++){const o=s[i].ctx||{};s[i].fn.apply(o,t)}}unbind(e,t,n){if(!this._mSubscriptions[e])throw new Error("No subscribtions to unsubscribe for event "+e);let s=!1;for(let i=0;i<this._mSubscriptions[e].length;i++)(!t||this._mSubscriptions[e][i].fn===t)&&(!n||n===this._mSubscriptions[e][i].ctx)&&(this._mSubscriptions[e].splice(i,1),s=!0);if(s===!1)throw new Error("Nothing to unbind for "+e)}off=this.unbind;trigger=this.emit}const pn=fl;class Ba extends pn{width;height;title;parent;layoutManager;tab;_config;isHidden=!1;beforeCloseHandler;_element=de(['<div class="lm_item_container">','<div class="lm_content" tabindex="-1"></div>',"</div>"].join(""));_contentElement;constructor(e,t,n){super(),this.title=Hh(e)?e.componentName:"",this.parent=t,this.layoutManager=n,this._config=e,this._contentElement=this._element.find(".lm_content"),this.beforeCloseHandler=null}getElement(){return this._contentElement}hide(){this.emit("hide"),this.isHidden=!0,this._element.hide()}show(){this.emit("show"),this.isHidden=!1,this._element.show(),(this.height!=0||this.width!=0)&&this.emit("shown")}setSize(e,t){let n=this.parent,s=null;for(;n&&!n.isColumn&&!n.isRow;)if(s=n,n=n.parent,n?.isRoot)return!1;if(!n||!s)return!1;const i=n.isColumn?"height":"width",o=i==="height"?t:e,l=(this[i]??0)*(1/((s.config[i]??0)/100)),a=o/l*100,d=((s.config[i]??0)-a)/(n.contentItems.length-1);for(let h=0;h<n.contentItems.length;h++)n.contentItems[h]===s?n.contentItems[h].config[i]=a:n.contentItems[h].config[i]=(n.contentItems[h].config[i]??0)+d;return n.callDownwards("setSize"),!0}close(e){this._config.isClosable&&(this.beforeCloseHandler?.(e)??!0)&&(this.emit("close"),this.parent.close())}beforeClose(e){this.beforeCloseHandler=e}getState(){return this._config.componentState}extendState(e){this.setState(de.extend(!0,this.getState(),e))}setState(e){this._config.componentState=e,this.parent.emitBubblingEvent("stateChanged")}setTitle(e){this.parent.setTitle(e)}_$setSize(e=0,t=0){if(e!==this.width||t!==this.height){this.width=e,this.height=t;var n=this._contentElement[0],s=n.offsetWidth-n.clientWidth,i=n.offsetHeight-n.clientHeight;this._contentElement.width(this.width-s).height(this.height-i),this.emit("resize")}}}const UC=Object.freeze(Object.defineProperty({__proto__:null,Container:Ba,ItemContainer:Ba},Symbol.toStringTag,{value:"Module"}));function Vh(c){var e=location.hash.match(new RegExp(c+"=([^&]*)"));return e?e[1]:null}function Bh(c){if(window.location.hash)return Vh(c);if(!window.location.search)return null;var e=window.location.search.substr(1).split("&"),t={},n,s;for(s=0;s<e.length;s++)n=e[s].split("="),t[n[0]]=n[1];return t[c]||null}function Zl(c){return window.requestAnimationFrame(c)}function VC(c,e){var t=e.indexOf(c);if(t===-1)throw new Error("Can't remove item from array. Item is not in the array");e.splice(t,1)}function Tr(){return(Math.random()*1e15).toString(36).replace(".","")}function BC(c,e){var t=c.replace(/javascript/gi,"javascript").replace(/expression/gi,"expression").replace(/onload/gi,"onload").replace(/script/gi,"script").replace(/onerror/gi,"onerror");return e===!0?t:t.replace(/>/g,">").replace(/</g,"<")}function Er(c){return de.trim(c.replace(/(<([^>]+)>)/gi,""))}class $C extends pn{_eElement;_oDocument;_eBody;_destroyAfterMouseUp;_nDelay=400;_timeout;timeout;_nDistance=10;_nX=0;_nY=0;_nOriginalX=0;_nOriginalY=0;_bDragging=!1;constructor(e,t=!1){super(),this._eElement=e,this._oDocument=de(document),this._eBody=de(document.body),this._destroyAfterMouseUp=t,this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this._startDrag=this._startDrag.bind(this),this._eElement?.on("mousedown",this.onMouseDown)}destroy(){this._eElement?.unbind("mousedown",this.onMouseDown),this._oDocument?.unbind("mouseup",this.onMouseUp),this._eElement=void 0,this._oDocument=void 0,this._eBody=void 0,clearTimeout(this._timeout),this._timeout=void 0}onMouseDown(e){if(e.preventDefault(),e.button===0){var t=this._getCoordinates(e);this._nOriginalX=t.x??0,this._nOriginalY=t.y??0,this._oDocument?.on("mousemove",this.onMouseMove),this._oDocument?.on("mouseup",this.onMouseUp),this._timeout=window.setTimeout(this._startDrag,this._nDelay)}}onMouseMove(e){if(this._timeout!=null){e.preventDefault();var t=this._getCoordinates(e);this._nX=(t.x??0)-this._nOriginalX,this._nY=(t.y??0)-this._nOriginalY,this._bDragging===!1&&(Math.abs(this._nX)>this._nDistance||Math.abs(this._nY)>this._nDistance)&&this._startDrag(),this._bDragging&&this.emit("drag",this._nX,this._nY,e)}}onMouseUp(e){this._timeout!=null&&(clearTimeout(this._timeout),this._oDocument?.unbind("mousemove",this.onMouseMove),this._oDocument?.unbind("mouseup",this.onMouseUp),this._oDocument?.find("iframe")?.css("pointer-events",""),this._bDragging===!0&&(this._bDragging=!1,this.emit("dragStop",e,this._nOriginalX+this._nX)),this._eBody?.removeClass("lm_dragging"),this._eElement instanceof Window||this._eElement?.removeClass("lm_dragging"),this._destroyAfterMouseUp&&this.destroy())}_startDrag(){window.clearTimeout(this._timeout),this._bDragging=!0,this._eBody?.addClass("lm_dragging"),this._eElement?.addClass("lm_dragging"),this._oDocument?.find("iframe")?.css("pointer-events","none"),this.emit("dragStart",this._nOriginalX,this._nOriginalY)}_getCoordinates(e){return{x:e.pageX??0,y:e.pageY??0}}}const fo=$C;class $h{_container;_reactComponent=null;_originalComponentWillUpdate=null;_initialState;_reactClass;constructor(e,t){this._reactComponent=null,this._originalComponentWillUpdate=null,this._container=e,this._initialState=t,this._reactClass=this._getReactClass(),this._container.on("open",this._render,this),this._container.on("destroy",this._destroy,this)}_render(){ll.render(this._getReactComponent(),this._container.getElement()[0])}_gotReactComponent(e){if(!e)return;this._reactComponent=e,this._originalComponentWillUpdate=this._reactComponent.componentWillUpdate||function(){},this._reactComponent.componentWillUpdate=this._onUpdate.bind(this);const t=this._container.getState();t&&this._reactComponent.setState(t)}_destroy(){ll.unmountComponentAtNode(this._container.getElement()[0]),this._container.off("open",this._render,this),this._container.off("destroy",this._destroy,this)}_onUpdate(e,t){this._container.setState(t),this._originalComponentWillUpdate?.call(this._reactComponent,e,t)}_getReactClass(){var e=this._container._config.component;if(!e)throw new Error("No react component name. type: react-component needs a field `component`");const t=this._container.layoutManager.getComponent(e)||this._container.layoutManager.getFallbackComponent();if(!t)throw new Error('React component "'+e+'" not found. Please register all components with GoldenLayout using `registerComponent(name, component)`');return t}_getReactComponent(){var e={glEventHub:this._container.layoutManager.eventHub,glContainer:this._container,ref:this._gotReactComponent.bind(this)},t=de.extend(e,this._container._config.props);return ae.createElement(this._reactClass,t)}}const Cl=["settings","hasHeaders","constrainDragToContainer","selectionEnabled","dimensions","borderWidth","minItemHeight","minItemWidth","headerHeight","dragProxyWidth","dragProxyHeight","labels","close","maximise","minimise","popout","content","componentName","componentState","id","width","type","height","isClosable","title","popoutWholeStack","openPopouts","parentId","activeItemIndex","reorderEnabled","borderGrabWidth"],WC=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"];function yr(c){if(Cl.length>36)throw new Error("Too many keys in config minifier map");const e={};return Rr(c,e,"_min"),e}function $a(c){if(Cl.length>36)throw new Error("Too many keys in config minifier map");const e={};return Rr(c,e,"_max"),e}function Rr(c,e,t){const n=t==="_min"?GC:zC;for(let s in c){if(!c.hasOwnProperty(s))continue;const i=Array.isArray(c)?c[Number.parseInt(s,10)]:c[s];if(typeof i=="object"&&i!=null){const o=i instanceof Array?[]:{};if(Array.isArray(e))e[Number.parseInt(s,10)]=o;else{const l=n(s,Cl);e[l]=o}Rr(i,o,t)}else{const o=n(i,WC);if(Array.isArray(e))e[Number.parseInt(s,10)]=o;else{const l=n(s,Cl);e[l]=o}}}}function GC(c,e){if(typeof c=="string"&&c.length===1)return"___"+c;var t=e.indexOf(c);return t===-1?c:t.toString(36)}function zC(c,e){return typeof c=="string"&&c.length===1?e[parseInt(c,36)]:typeof c=="string"&&c.substr(0,3)==="___"?c[3]:c}class Wa{name;origin;isPropagationStopped;constructor(e,t){this.name=e,this.origin=t,this.isPropagationStopped=!1}stopPropagation(){this.isPropagationStopped=!0}}let KC=class extends pn{_layoutManager;_dontPropagateToParent;_childEventSource;_boundOnEventFromChild;constructor(e){super(),this._layoutManager=e,this._dontPropagateToParent=null,this._childEventSource=null,this.on(pn.ALL_EVENT,this._onEventFromThis.bind(this)),this._boundOnEventFromChild=this._onEventFromChild.bind(this),de(window).on("gl_child_event",this._boundOnEventFromChild)}_onEventFromThis(...e){this._layoutManager.isSubWindow&&e[0]!==this._dontPropagateToParent&&this._propagateToParent(e),this._propagateToChildren(e),this._dontPropagateToParent=null,this._childEventSource=null}_$onEventFromParent(e){this._dontPropagateToParent=e[0],this.emit.apply(this,e)}_onEventFromChild(e){this._childEventSource=e.originalEvent.__gl,this.emit.apply(this,e.originalEvent.__glArgs)}_propagateToParent(e){const t="gl_child_event",n=window.opener?.document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),n.eventName=t,n.__glArgs=e,n.__gl=this._layoutManager,window.opener.dispatchEvent(n)}_propagateToChildren(e){for(let t=0;t<this._layoutManager.openPopouts.length;t++){const n=this._layoutManager.openPopouts[t].getGlInstance();n&&n!==this._childEventSource&&n.eventHub._$onEventFromParent(e)}}destroy(){de(window).off("gl_child_event",this._boundOnEventFromChild)}};const Wh=KC,YC=Object.freeze(Object.defineProperty({__proto__:null,BubblingEvent:Wa,DragListener:fo,EventEmitter:pn,EventHub:Wh,ReactComponentHandler:$h,animFrame:Zl,filterXss:BC,getHashValue:Vh,getQueryStringParam:Bh,getUniqueId:Tr,minifyConfig:yr,removeFromArray:VC,stripTags:Er,unminifyConfig:$a},Symbol.toStringTag,{value:"Module"}));class Gh extends pn{isInitialised=!1;_config;_dimensions;_parentId;_indexInParent;_layoutManager;_popoutWindow=null;_id=null;constructor(e,t,n,s,i){super(),this._config=e,this._dimensions=t,this._parentId=n,this._indexInParent=s,this._layoutManager=i,this._createWindow()}toConfig(){if(this.isInitialised===!1)throw new Error("Can't create config, layout not yet initialised");return{dimensions:{width:this.getGlInstance()?.width,height:this.getGlInstance()?.height,left:this._popoutWindow?.screenX??this._popoutWindow?.screenLeft??0,top:this._popoutWindow?.screenY??this._popoutWindow?.screenTop??0},content:this.getGlInstance()?.toConfig().content,parentId:this._parentId,indexInParent:this._indexInParent}}getGlInstance(){return this._popoutWindow?.__glInstance}getWindow(){return this._popoutWindow}close(){if(this.getGlInstance())this.getGlInstance()?._$closeWindow();else try{this.getWindow()?.close()}catch{}}popIn(){this._indexInParent;let e=null,t=null;this._parentId&&(e=de.extend(!0,{},this.getGlInstance()?.toConfig()).content[0],t=this._layoutManager.root.getItemsById(this._parentId)[0],t||((this._layoutManager.root.contentItems.length??0)>0?t=this._layoutManager.root.contentItems[0]:t=this._layoutManager.root)),e&&(t?.addChild(e,this._indexInParent),this.close())}_createWindow(){const e=this._createUrl(),t=Math.floor(Math.random()*1e6).toString(36),n=this._serializeWindowOptions({width:this._dimensions.width,height:this._dimensions.height,innerWidth:this._dimensions.width,innerHeight:this._dimensions.height,menubar:"no",toolbar:"no",location:"no",personalbar:"no",resizable:"yes",scrollbars:"no",status:"no"});if(this._popoutWindow=window.open(e,t,n),!this._popoutWindow)if(this._layoutManager.config.settings.blockedPopoutsThrowError===!0){const i=new Error("Popout blocked");throw i.type="popoutBlocked",i}else return;de(this._popoutWindow).on("load",this._positionWindow.bind(this)).on("unload beforeunload",this._onClose.bind(this));let s=window.setInterval(()=>{this._popoutWindow?.__glInstance&&this._popoutWindow.__glInstance.isInitialised&&(this._onInitialised(),window.clearInterval(s))},10)}_serializeWindowOptions(e){var t=[],n;for(n in e)t.push(n+"="+e[n]);return t.join(",")}_createUrl(){var e={content:this._config};const t="gl-window-config-"+Tr();e=yr(e);try{localStorage.setItem(t,JSON.stringify(e))}catch(s){throw new Error("Error while writing to localStorage "+s.toString())}const n=document.location.href.split("?");return n.length===1?n[0]+"?gl-window="+t:document.location.href+"&gl-window="+t}_positionWindow(){this._popoutWindow?.moveTo(this._dimensions.left,this._dimensions.top),this._popoutWindow?.focus()}_onInitialised(){this.isInitialised=!0,this.getGlInstance()?.on("popIn",this.popIn,this),this.emit("initialised")}_onClose(){setTimeout(this.emit.bind(this,"closed"),50)}}class Di extends pn{static _template='<div class="lm_dragProxy"><div class="lm_header"><ul class="lm_tabs"><li class="lm_tab lm_active"><i class="lm_left"></i><span class="lm_title"></span><i class="lm_right"></i></li></ul></div><div class="lm_content"></div></div>';_dragListener;_layoutManager;_contentItem;_originalParent;_area=null;_lastValidArea=null;_minX;_maxX;_minY;_maxY;_width;_height;_sided;element;childElementContainer;_proxyTab;constructor(e,t,n,s,i,o){super(),this._dragListener=n,this._layoutManager=s,this._contentItem=i,this._originalParent=o,this._dragListener.on("drag",this._onDrag,this),this._dragListener.on("dragStop",this._onDrop,this),this._contentItem.tab&&this._contentItem.tab.element&&(this._layoutManager.tabDropPlaceholder.width(this._contentItem.tab.element.outerWidth(!0)??0),this._layoutManager.tabDropPlaceholder.height(this._contentItem.tab.element.outerHeight(!0)??0)),this.element=de(Di._template),o&&o._side&&(this._sided=o._sided,this.element.addClass("lm_"+o._side),["right","bottom"].indexOf(o._side.toString())>=0&&this.element.find(".lm_content").after(this.element.find(".lm_header"))),this.element.css({left:e,top:t}),this._proxyTab=this.element.find(".lm_tab"),this._proxyTab.attr("title",Er(this._contentItem.config.title??"")),this.element.find(".lm_title").html(this._contentItem.config.title??""),this.childElementContainer=this.element.find(".lm_content"),this.childElementContainer.append(i.element),this._updateTree(),this._layoutManager._$calculateItemAreas(),de(document.body).append(this.element),this._setDimensions(),!this._contentItem.tab&&this._proxyTab.length&&(this._layoutManager.tabDropPlaceholder.width(this._proxyTab.outerWidth(!0)??0),this._layoutManager.tabDropPlaceholder.height(this._proxyTab.outerHeight(!0)??0));var l=this._layoutManager.container.offset();this._minX=l?.left??0,this._minY=l?.top??0,this._maxX=(this._layoutManager.container.width()??0)+this._minX,this._maxY=(this._layoutManager.container.height()??0)+this._minY,this._width=this.element.width()??0,this._height=this.element.height()??0,this._setDropPosition(e,t),this._layoutManager.emit("itemPickedUp",this._contentItem)}_onDrag(e,t,n){const s=n.pageX??0,i=n.pageY??0;!(s>this._minX&&s<this._maxX&&i>this._minY&&i<this._maxY)&&this._layoutManager.config.settings.constrainDragToContainer===!0||this._setDropPosition(s,i)}_setDropPosition(e,t){this.element.css({left:e,top:t}),this._area=this._layoutManager._$getArea(e,t),this._area!==null&&(this._lastValidArea=this._area,this._area.contentItem._$highlightDropZone(e,t,this._area))}_onDrop(){this._layoutManager.dropTargetIndicator?.hide(),this._area!==null?this._area.contentItem._$onDrop(this._contentItem,this._area):this._lastValidArea!==null?this._lastValidArea.contentItem._$onDrop(this._contentItem,this._lastValidArea):this._originalParent?this._originalParent.addChild(this._contentItem):this._contentItem._$destroy(),this._dragListener.off("drag",this._onDrag,this),this._dragListener.off("dragStop",this._onDrop,this),this.element.remove(),this._layoutManager.emit("itemDropped",this._contentItem)}_updateTree(){this._contentItem.parent&&this._contentItem.parent.removeChild(this._contentItem,!0),this._contentItem._$setParent(null)}_setDimensions(){const e=this._layoutManager.config.dimensions;let t=e.dragProxyWidth,n=e.dragProxyHeight;this.element.width(t),this.element.height(n),t-=this._sided?e.headerHeight:0,n-=this._sided?0:e.headerHeight,this.childElementContainer.width(t),this.childElementContainer.height(n),this._contentItem.element.width(t),this._contentItem.element.height(n),this._contentItem.callDownwards("_$show"),this._contentItem.callDownwards("setSize")}}class zh{_element;_itemConfig;_layoutManager;_dragListener;constructor(e,t,n){this._element=e,this._itemConfig=t,this._layoutManager=n,this._dragListener=this._createDragListener()}_createDragListener(){return this._dragListener=new fo(this._element,!0),this._dragListener.on("dragStart",this._onDragStart,this),this._dragListener.on("dragStop",this._createDragListener,this),this._dragListener}_onDragStart(e,t){let n=this._itemConfig;typeof n=="function"&&(n=n());const s=this._layoutManager._$normalizeContentItem(de.extend(!0,{},n)),i=new Di(e,t,this._dragListener,this._layoutManager,s,null);this._layoutManager.transitionIndicator?.transitionElements(this._element,i.element)}}class Kh{_element=de(window);_itemConfig;_layoutManager;_dragListener;constructor(e,t,n){this._itemConfig=e,this._layoutManager=t,this._createDragListener(n)}_createDragListener(e){this._dragListener&&this._dragListener.destroy(),this._element&&(this._dragListener=new fo(this._element,!0),this._dragListener.on("dragStart",this._onDragStart,this),this._dragListener.on("dragStop",this._destroy,this),this._dragListener.onMouseDown(e),this._dragListener._startDrag())}_destroy(){this._dragListener=void 0,this._element=void 0,this._itemConfig=void 0,this._layoutManager=void 0}_onDragStart(e,t){if(!(!this._dragListener||!this._layoutManager)){var n=this._itemConfig;typeof n=="function"&&(n=n());var s=this._layoutManager._$normalizeContentItem(de.extend(!0,{},n));new Di(e,t,this._dragListener,this._layoutManager,s,null)}}}class Ql{static _template='<div class="lm_dropTargetIndicator"><div class="lm_inner"></div></div>';element=de(Ql._template);constructor(){de(document.body).append(this.element)}destroy(){this.element.remove()}highlightArea(e){this.element.css({left:e.x1,top:e.y1,width:Math.floor(e.x2-e.x1),height:Math.floor(e.y2-e.y1)}).show()}hide(){this.element.hide()}}class Yi{element;_header;_action;constructor(e,t,n,s){this._header=e,this.element=de('<li class="'+n+'" title="'+t+'"></li>'),this._header.on("destroy",this._$destroy,this),this._action=s,this.element.on("click",this._action),this._header.controlsContainer.append(this.element)}_$destroy(){this.element.off(),this.element.remove()}}class qC extends Error{node;constructor(e,t){super(),this.name="Configuration Error",this.message=e,this.node=t}}const zs=qC,XC=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationError:zs},Symbol.toStringTag,{value:"Module"}));function oo(c){return c.isStack}function Lt(c){return c.isComponent}function Yh(c){return c.isRoot}class mt extends pn{config;type;contentItems;parent;layoutManager;element;childElementContainer;componentName;isInitialised=!1;isMaximised=!1;isRoot=!1;isRow=!1;isColumn=!1;isStack=!1;isComponent=!1;tab;_pendingEventPropagations;_throttledEvents;constructor(e,t,n,s){super(),this.element=s,this.config=this._extendItemNode(t),this.type=t.type,this.contentItems=[],this.parent=n,this.layoutManager=e,this._pendingEventPropagations={},this._throttledEvents=["stateChanged"],this.on(pn.ALL_EVENT,this._propagateEvent,this),t.content&&this._createContentItems(t)}callDownwards(e,t=[],n=!1,s=!1){n!==!0&&s!==!0&&this[e].apply(this,t);for(let i=0;i<this.contentItems.length;i++)this.contentItems[i].callDownwards(e,t,n);n===!0&&s!==!0&&this[e].apply(this,t)}removeChild(e,t=!1){const n=this.contentItems.indexOf(e);if(n===-1)throw new Error("Can't remove child item. Unknown content item");t!==!0&&this.contentItems[n]._$destroy(),this.contentItems.splice(n,1),this.config.content?.splice(n,1),this.contentItems.length>0?this.callDownwards("setSize"):this.type!=="root"&&this.config.isClosable&&this.parent?.removeChild(this)}addChild(e,t){e=this.layoutManager._$normalizeContentItem(e,this),t===void 0&&(t=this.contentItems.length),this.contentItems.splice(t,0,e),this.config.content===void 0&&(this.config.content=[]),this.config.content.splice(t,0,e.config),e.parent=this,e.parent.isInitialised===!0&&e.isInitialised===!1&&e._$init()}replaceChild(e,t,n=!1){t=this.layoutManager._$normalizeContentItem(t);const s=this.contentItems.indexOf(e),i=e.element[0].parentNode;if(s===-1)throw new Error("Can't replace child. oldChild is not child of this");i?.replaceChild(t.element[0],e.element[0]),n===!0&&(e.parent=null,e._$destroy()),this.contentItems[s]=t,t.parent=this,oo(this)&&(this.header.tabs[s].contentItem=t),t.parent.isInitialised===!0&&t.isInitialised===!1&&t._$init(),this.callDownwards("setSize")}remove(){this.parent?.removeChild(this)}popout(){var e=this.layoutManager.createPopout(this);return this.emitBubblingEvent("stateChanged"),e}toggleMaximise(e){e&&e.preventDefault(),this.isMaximised===!0?this.layoutManager._$minimiseItem(this):this.layoutManager._$maximiseItem(this),this.isMaximised=!this.isMaximised,this.emitBubblingEvent("stateChanged")}select(){this.layoutManager.selectedItem!==this&&(this.layoutManager.selectItem(this,!0),this.element.addClass("lm_selected"))}deselect(){this.layoutManager.selectedItem===this&&(this.layoutManager.selectedItem=null,this.element.removeClass("lm_selected"))}setTitle(e){this.config.title=e,this.emit("titleChanged",e),this.emitBubblingEvent("stateChanged")}hasId(e){if(this.config.id){if(typeof this.config.id=="string")return this.config.id===e;if(this.config.id instanceof Array)return this.config.id.indexOf(e)!==-1}else return!1}addId(e){this.hasId(e)||(this.config.id?typeof this.config.id=="string"?this.config.id=[this.config.id,e]:this.config.id instanceof Array&&this.config.id.push(e):this.config.id=e)}removeId(e){if(!this.hasId(e))throw new Error("Id not found");if(typeof this.config.id=="string")delete this.config.id;else if(this.config.id instanceof Array){var t=this.config.id.indexOf(e);this.config.id.splice(t,1)}}getItemsByFilter(e){const t=[],n=function(s){for(let i=0;i<s.contentItems.length;i++)e(s.contentItems[i])===!0&&t.push(s.contentItems[i]),n(s.contentItems[i])};return n(this),t}getItemsById(e){return this.getItemsByFilter(function(t){return t.config.id instanceof Array?t.config.id.indexOf(e)!==-1:t.config.id===e})}getItemsByType(e){return this._$getItemsByProperty("type",e)}getComponentsByName(e){const t=this._$getItemsByProperty("componentName",e),n=[];for(let s=0;s<t.length;s++)n.push(t[s].instance);return n}_$getItemsByProperty(e,t){return this.getItemsByFilter(function(n){return n[e]===t})}_$setParent(e){this.parent=e}_$highlightDropZone(e,t,n){this.layoutManager.dropTargetIndicator?.highlightArea(n)}_$onDrop(e,t){this.addChild(e)}_$hide(){this._callOnActiveComponents("hide"),this.element.hide(),this.layoutManager.updateSize()}_$show(){this._callOnActiveComponents("show"),this.element.show(),this.layoutManager.updateSize()}_callOnActiveComponents(e){const t=this.getItemsByType("stack");let n=null;for(let s=0;s<t.length;s++)n=t[s].getActiveContentItem(),n&&Lt(n)&&n.container[e]()}_$destroy(){this.emitBubblingEvent("beforeItemDestroyed"),this.callDownwards("_$destroy",[],!0,!0),this.element.remove(),this.emitBubblingEvent("itemDestroyed")}_$getArea(e){e=e||this.element;const t=e.offset()??{left:0,top:0},n=e.width()??0,s=e.height()??0;return{x1:t.left,y1:t.top,x2:t.left+n,y2:t.top+s,surface:n*s,contentItem:this,side:""}}_$init(){this.setSize();for(let e=0;e<this.contentItems.length;e++)this.childElementContainer?.append(this.contentItems[e].element);this.isInitialised=!0,this.emitBubblingEvent("itemCreated"),this.emitBubblingEvent(this.type+"Created")}emitBubblingEvent(e){var t=new Wa(e,this);this.emit(e,t)}_createContentItems(e){var t;if(!(e.content instanceof Array))throw new zs("content must be an Array",e);for(let n=0;n<e.content.length;n++)t=this.layoutManager.createContentItem(e.content[n],this),this.contentItems.push(t)}_extendItemNode(e){for(let[t,n]of Object.entries(Uh)){const s=t;e[s]===void 0&&(e[s]=n)}return e}_propagateEvent(e,t){t instanceof Wa&&t.isPropagationStopped===!1&&this.isInitialised===!0&&(this.isRoot===!1&&this.parent?this.parent.emit.apply(this.parent,[e,t]):this._scheduleEventPropagationToLayoutManager(e,t))}_scheduleEventPropagationToLayoutManager(e,t){this._throttledEvents.indexOf(e)===-1?this.layoutManager.emit(e,t.origin):this._pendingEventPropagations[e]!==!0&&(this._pendingEventPropagations[e]=!0,Zl(this._propagateEventToLayoutManager.bind(this,e,t)))}_propagateEventToLayoutManager(e,t){this._pendingEventPropagations[e]=!1,this.layoutManager.emit(e,t)}}class qh extends mt{config;componentName;container;parent;instance;constructor(e,t,n){super(e,t,n,de()),this.config=t,this.parent=n;const s=e.getComponent(this.config.componentName)||e.getFallbackComponent(),i=de.extend(!0,{},this.config.componentState||{});if(s==null)throw new zs('Unknown component "'+this.config.componentName+'"');i.componentName=this.config.componentName,this.componentName=this.config.componentName,this.config.title===""&&(this.config.title=this.config.componentName),this.isComponent=!0,this.container=new Ba(this.config,this,e),this.instance=new s(this.container,i),this.element=this.container._element}close(){this.parent.removeChild(this)}setSize(){this.element.is(":visible")&&this.container._$setSize(this.element.width(),this.element.height())}_$init(){mt.prototype._$init.call(this),this.container.emit("open")}_$hide(){this.container.hide(),mt.prototype._$hide.call(this)}_$show(){this.container.show(),this.container._config.isFocusOnShow&&this.container._contentElement[0].focus({preventScroll:!0}),mt.prototype._$show.call(this)}_$destroy(){this.container.emit("destroy",this),mt.prototype._$destroy.call(this)}_$getArea(){return null}}class Sl extends mt{isRow;isColumn;childElementContainer;parent;_splitter=[];_splitterSize;_splitterGrabSize;_isColumn;_dimension;_splitterPosition=null;_splitterMinPosition=null;_splitterMaxPosition=null;constructor(e,t,n,s){super(t,n,s,de('<div class="lm_item lm_'+(e?"column":"row")+'"></div>')),this.parent=s,this.isRow=!e,this.isColumn=e,this.childElementContainer=this.element,this._splitterSize=t.config.dimensions.borderWidth,this._splitterGrabSize=t.config.dimensions.borderGrabWidth,this._isColumn=e,this._dimension=e?"height":"width",this._splitterPosition=null,this._splitterMinPosition=null,this._splitterMaxPosition=null}addChild(e,t,n){var s,i,o,l;if(e=this.layoutManager._$normalizeContentItem(e,this),t===void 0&&(t=this.contentItems.length),this.contentItems.length>0?(l=this._createSplitter(Math.max(0,t-1)).element,t>0?(this.contentItems[t-1].element.after(l),l.after(e.element)):(this.contentItems[0].element.before(l),l.before(e.element))):this.childElementContainer.append(e.element),mt.prototype.addChild.call(this,e,t),s=1/this.contentItems.length*100,n===!0){this.emitBubblingEvent("stateChanged");return}for(o=0;o<this.contentItems.length;o++)this.contentItems[o]===e?e.config[this._dimension]=s:(i=(this.contentItems[o].config[this._dimension]??0)*(100-s)/100,this.contentItems[o].config[this._dimension]=i);this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}removeChild(e,t){var n=e.config[this._dimension]??0,s=this.contentItems.indexOf(e),i=Math.max(s-1,0),o,l;if(s===-1)throw new Error("Can't remove child. ContentItem is not child of this Row or Column");for(this._splitter[i]&&(this._splitter[i]._$destroy(),this._splitter.splice(i,1)),o=0;o<this.contentItems.length;o++)this.contentItems[o]!==e&&(this.contentItems[o].config[this._dimension]=(this.contentItems[o].config[this._dimension]??0)+n/(this.contentItems.length-1));mt.prototype.removeChild.call(this,e,t),this.contentItems.length===1&&this.config.isClosable===!0?(l=this.contentItems[0],this.contentItems=[],this.parent.replaceChild(this,l,!0)):(this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged"))}replaceChild(e,t){var n=e.config[this._dimension];super.replaceChild(e,t),t.config[this._dimension]=n,this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}setSize(){this.contentItems.length>0&&(this._calculateRelativeSizes(),this._setAbsoluteSizes()),this.emitBubblingEvent("stateChanged"),this.emit("resize")}_$init(){if(this.isInitialised!==!0){var e;for(mt.prototype._$init.call(this),e=0;e<this.contentItems.length-1;e++)this.contentItems[e].element.after(this._createSplitter(e).element)}}_setAbsoluteSizes(){var e,t=this._calculateAbsoluteSizes();for(e=0;e<this.contentItems.length;e++)t.additionalPixel-e>0&&t.itemSizes[e]++,this._isColumn?(this.contentItems[e].element.width(t.totalWidth),this.contentItems[e].element.height(t.itemSizes[e])):(this.contentItems[e].element.width(t.itemSizes[e]),this.contentItems[e].element.height(t.totalHeight))}_calculateAbsoluteSizes(){const e=(this.contentItems.length-1)*this._splitterSize;let t=this.element.width()??0,n=this.element.height()??0,s=0;const i=[];this._isColumn?n-=e:t-=e;for(let l=0;l<this.contentItems.length;l++){const a=this._isColumn?Math.floor(n*((this.contentItems[l].config.height??0)/100)):Math.floor(t*((this.contentItems[l].config.width??0)/100));s+=a,i.push(a)}const o=Math.floor((this._isColumn?n:t)-s);return{itemSizes:i,additionalPixel:o,totalWidth:t,totalHeight:n}}_calculateRelativeSizes(){let e=0;const t=[],n=this._isColumn?"height":"width";for(let s=0;s<this.contentItems.length;s++)this.contentItems[s].config[n]!==void 0?e+=this.contentItems[s].config[n]??0:t.push(this.contentItems[s]);if(Math.round(e)===100){this._respectMinItemWidth();return}if(Math.round(e)<100&&t.length>0){for(let s=0;s<t.length;s++)t[s].config[n]=(100-e)/t.length;this._respectMinItemWidth();return}if(Math.round(e)>100)for(let s=0;s<t.length;s++)t[s].config[n]=50,e+=50;for(let s=0;s<this.contentItems.length;s++)this.contentItems[s].config[n]=(this.contentItems[s].config[n]??0)/e*100;this._respectMinItemWidth()}_respectMinItemWidth(){const e=this.layoutManager.config.dimensions?this.layoutManager.config.dimensions.minItemWidth??0:0,t=[];let n=0,s=0,i=0;const o=[];let l;if(this._isColumn||!e||this.contentItems.length<=1)return;const a=this._calculateAbsoluteSizes();for(let h=0;h<this.contentItems.length;h++){this.contentItems[h];const u=a.itemSizes[h];u<e?(s+=e-u,l={width:e}):(n+=u-e,l={width:u},t.push(l)),o.push(l)}if(s===0||s>n)return;const d=s/n;i=s;for(let h=0;h<t.length;h++){l=t[h];const u=Math.round((l.width-e)*d);i-=u,l.width-=u}i!==0&&(o[o.length-1].width-=i);for(let h=0;h<this.contentItems.length;h++)this.contentItems[h].config.width=o[h].width/a.totalWidth*100}_createSplitter(e){var t;return t=new Xh(this._isColumn,this._splitterSize,this._splitterGrabSize),t.on("drag",this._onSplitterDrag.bind(this,t),this),t.on("dragStop",this._onSplitterDragStop.bind(this,t),this),t.on("dragStart",this._onSplitterDragStart.bind(this,t),this),this._splitter.splice(e,0,t),t}_getItemsForSplitter(e){const t=this._splitter.indexOf(e);if(t<0)throw new Error("Splitter not found in RowOrColumn");return{before:this.contentItems[t],after:this.contentItems[t+1]}}_getMinimumDimensions(e){for(var t=0,n=0,s=0;s<e.length;++s)t=Math.max(e[s].minWidth??0,t),n=Math.max(e[s].minHeight??0,n);return{horizontal:t,vertical:n}}_onSplitterDragStart(e){const t=this._getItemsForSplitter(e),n=this.layoutManager.config.dimensions[this._isColumn?"minItemHeight":"minItemWidth"];var s=this._getMinimumDimensions(t.before.config.content??[]),i=this._isColumn?s.vertical:s.horizontal,o=this._getMinimumDimensions(t.after.config.content??[]),l=this._isColumn?o.vertical:o.horizontal;this._splitterPosition=0,this._splitterMinPosition=-1*((t.before.element[this._dimension]()??0)-(i||n)),this._splitterMaxPosition=(t.after.element[this._dimension]()??0)-(l||n)}_onSplitterDrag(e,t,n){const s=this._isColumn?n:t;this._splitterMaxPosition==null||this._splitterMinPosition==null||s>this._splitterMinPosition&&s<this._splitterMaxPosition&&(this._splitterPosition=s,e.element.css(this._isColumn?"top":"left",s))}_onSplitterDragStop(e){const t=this._getItemsForSplitter(e),n=t.before.element[this._dimension]()??0,s=t.after.element[this._dimension]()??0,i=((this._splitterPosition??0)+n)/(n+s),o=(t.before.config[this._dimension]??0)+(t.after.config[this._dimension]??0);t.before.config[this._dimension]=i*o,t.after.config[this._dimension]=(1-i)*o,e.element.css({top:0,left:0}),Zl(this.callDownwards.bind(this,"setSize",void 0,void 0,void 0))}}class Ga extends mt{childElementContainer;_containerElement;constructor(e,t,n){super(e,{...t,type:"root"},null,de('<div class="lm_goldenlayout lm_item lm_root"></div>')),this.isRoot=!0,this.type="root",this.childElementContainer=this.element,this._containerElement=n,this._containerElement.append(this.element)}addChild(e,t){if(this.contentItems.length>0)throw new Error("Root node can only have a single child");e=this.layoutManager._$normalizeContentItem(e,this),this.childElementContainer.append(e.element),super.addChild(e,t),this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}setSize(e,t){e=typeof e>"u"?this._containerElement.width()??0:e,t=typeof t>"u"?this._containerElement.height()??0:t,this.element.width(e),this.element.height(t),this.contentItems[0]&&(this.contentItems[0].element.width(e),this.contentItems[0].element.height(t))}_$getArea(){const e=super._$getArea();if(e==null)throw new Error("Unable to get root area");return e}_$highlightDropZone(e,t,n){this.layoutManager.tabDropPlaceholder.remove(),super._$highlightDropZone(e,t,n)}_$onDrop(e,t){var n;if(Lt(e)&&(n=this.layoutManager.createContentItem({type:"stack",header:e.config.header||{}},this),n._$init(),n.addChild(e),e=n),!this.contentItems.length)this.addChild(e);else{const{side:s}=t,i=s==="left"||s==="right"?"row":"column",o=s==="left"||s==="right"?"width":"height",l=s==="left"||s==="top",a=this.contentItems[0];if(!(a instanceof Sl)||a.type!=i){const d=this.layoutManager.createContentItem({type:i},this);this.replaceChild(a,d),d.addChild(e,l?0:void 0,!0),d.addChild(a,l?void 0:0,!0),a.config[o]=50,e.config[o]=50,d.callDownwards("setSize")}else{const d=a.contentItems[l?0:a.contentItems.length-1];a.addChild(e,l?0:void 0,!0),d.config[o]=(d.config[o]??0)*.5,e.config[o]=d.config[o],a.callDownwards("setSize")}}}}class za extends mt{_activeContentItem=null;_header;childElementContainer=de('<div class="lm_items"></div>');header;parent;isStack=!0;_dropZones={};_dropSegment=null;_contentAreaDimensions=null;_dropIndex;_side;_sided=!1;config;constructor(e,t,n){super(e,t,n,de('<div class="lm_item lm_stack"></div>')),this.parent=n,this.config=t;const s=e.config;this._side=!1,this._header={show:s.settings?.hasHeaders&&t.hasHeaders!==!1,popout:s.settings?.showPopoutIcon?s.labels?.popout:void 0,maximise:s.settings?.showMaximiseIcon?s.labels?.maximise:void 0,close:s.settings?.showCloseIcon?s.labels?.close:void 0,minimise:s.labels?.minimise??void 0},s.header&&(this._header={...this._header,...s.header}),t.header&&(this._header={...this._header,...t.header}),t.content&&t.content[0]&&t.content[0].header&&(this._header={...this._header,...t.content[0].header}),this.header=new vi(e,this),this.element.append(this.header.element),this.element.append(this.childElementContainer),this._setupHeaderPosition(),this._$validateClosability()}setSize(){var e,t=this._header.show?this.layoutManager.config.dimensions?.headerHeight??0:0,n=(this.element.width()??0)-(this._sided?t:0),s=(this.element.height()??0)-(this._sided?0:t);for(this.childElementContainer.width(n),this.childElementContainer.height(s),e=0;e<this.contentItems.length;e++)this.contentItems[e].element.width(n).height(s);this.emit("resize"),this.emitBubblingEvent("stateChanged")}_$init(){if(this.isInitialised!==!0){this.header._attachWheelListener(),super._$init();for(let e=0;e<this.contentItems.length;e++)this.header.createTab(this.contentItems[e]),this.contentItems[e]._$hide();if(this.contentItems.length>0){const e=this.contentItems[this.config.activeItemIndex||0];if(!e)throw new Error("Configured activeItemIndex out of bounds");this.setActiveContentItem(e)}}}setActiveContentItem(e){if(this.contentItems.indexOf(e)===-1)throw new Error("contentItem is not a child of this stack");this._activeContentItem!==null&&this._activeContentItem._$hide(),this._activeContentItem=e,this.header.setActiveContentItem(e),e._$show(),this.emit("activeContentItemChanged",e),this.layoutManager.emit("activeContentItemChanged",e),this.emitBubblingEvent("stateChanged")}getActiveContentItem(){return this.header.activeContentItem}addChild(e,t){e=this.layoutManager._$normalizeContentItem(e,this),super.addChild(e,t),this.childElementContainer.append(e.element),this.header.createTab(e,t),this.setActiveContentItem(e),this.callDownwards("setSize"),this._$validateClosability(),this.emitBubblingEvent("stateChanged")}removeChild(e,t=!1){var n=this.contentItems.indexOf(e);super.removeChild(e,t),this.header.removeTab(e),this.header.activeContentItem===e&&(this.contentItems.length>0?this.setActiveContentItem(this.contentItems[Math.max(n-1,0)]):this._activeContentItem=null),this._$validateClosability(),this.emitBubblingEvent("stateChanged")}_$validateClosability(){let e=this.header._isClosable();for(let t=0,n=this.contentItems.length;t<n&&e;t++)e=this.contentItems[t].config.isClosable??!1;this.header._$setClosable(e)}_$destroy(){mt.prototype._$destroy.call(this),this.header._$destroy()}_$onDrop(e){if(this._dropSegment==="header"){this._resetHeaderDropZone(),this.addChild(e,this._dropIndex);return}if(this._dropSegment==="body"){this.addChild(e);return}const t=this._dropSegment==="top"||this._dropSegment==="bottom",n=this._dropSegment==="left"||this._dropSegment==="right",s=this._dropSegment==="top"||this._dropSegment==="left",i=t&&this.parent.isColumn||n&&this.parent.isRow,o=t?"column":"row",l=t?"height":"width";if(Lt(e)){const a=this.layoutManager.createContentItem({type:"stack",header:e.config.header||{}},this);a._$init(),a.addChild(e),e=a}if(i){const a=this.parent.contentItems.indexOf(this);this.parent.addChild(e,s?a:a+1,!0),this.config[l]=(this.config[l]??0)*.5,e.config[l]=this.config[l],this.parent.callDownwards("setSize")}else{const a=this.layoutManager.createContentItem({type:o},this);this.parent.replaceChild(this,a),a.addChild(e,s?0:void 0,!0),a.addChild(this,s?void 0:0,!0),this.config[l]=50,e.config[l]=50,a.callDownwards("setSize")}}_$highlightDropZone(e,t){if(this._contentAreaDimensions)for(let[n,s]of Object.entries(this._contentAreaDimensions)){const i=s.hoverArea;if(i.x1<e&&i.x2>e&&i.y1<t&&i.y2>t){n==="header"?(this._dropSegment="header",this._highlightHeaderDropZone(e)):(this._resetHeaderDropZone(),this._highlightBodyDropZone(n));return}}}_$getArea(){if(this.element.is(":visible")===!1)return null;const e=super._$getArea(this.header.element),t=super._$getArea(this.childElementContainer);if(e==null||t==null)return null;const n=t.x2-t.x1,s=t.y2-t.y1;return this._contentAreaDimensions={header:{hoverArea:{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2},highlightArea:{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2}}},this._activeContentItem&&this._activeContentItem.isComponent===!1?e:this.contentItems.length===0?(this._contentAreaDimensions.body={hoverArea:{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2},highlightArea:{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2}},super._$getArea(this.element)):(this._contentAreaDimensions.left={hoverArea:{x1:t.x1,y1:t.y1,x2:t.x1+n*.25,y2:t.y2},highlightArea:{x1:t.x1,y1:t.y1,x2:t.x1+n*.5,y2:t.y2}},this._contentAreaDimensions.top={hoverArea:{x1:t.x1+n*.25,y1:t.y1,x2:t.x1+n*.75,y2:t.y1+s*.5},highlightArea:{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y1+s*.5}},this._contentAreaDimensions.right={hoverArea:{x1:t.x1+n*.75,y1:t.y1,x2:t.x2,y2:t.y2},highlightArea:{x1:t.x1+n*.5,y1:t.y1,x2:t.x2,y2:t.y2}},this._contentAreaDimensions.bottom={hoverArea:{x1:t.x1+n*.25,y1:t.y1+s*.5,x2:t.x1+n*.75,y2:t.y2},highlightArea:{x1:t.x1,y1:t.y1+s*.5,x2:t.x2,y2:t.y2}},super._$getArea(this.element))}_highlightHeaderDropZone(e){const t=this.header.tabs.length;if(t===0){const u=this.header.element.offset();this.layoutManager.dropTargetIndicator?.highlightArea({x1:u?.left??0,x2:(u?.left??0)+100,y1:this.header.element.offset()?.top??0,y2:(this.header.element.offset()?.top??0)+(this.header.element.innerHeight()??0)});return}const s=this.header.tabsContainer.get(0)?.getBoundingClientRect(),i=this.layoutManager.tabDropPlaceholder.get(0)?.getBoundingClientRect();if(!s||!i)return;e<s.left?e=s.left+1:e>s.right&&(e=s.right-1);let o,l;if(!(i.left<e&&e<i.right)){for(var a=0;a<t;a++)if(o=this.header.tabs[a].element,l=o.get(0)?.getBoundingClientRect(),l&&l.left<e&&e<l.right){this._dropIndex=a;break}o&&l&&e<l.left+l.width*.5?o.before(this.layoutManager.tabDropPlaceholder):o&&(this._dropIndex=Math.min((this._dropIndex??0)+1,t),o.after(this.layoutManager.tabDropPlaceholder))}let d=this.layoutManager.tabDropPlaceholder.offset()?.left??0;d=Math.max(d,this.header.tabsContainer.offset()?.left??0);var h=d+(this.layoutManager.tabDropPlaceholder.width()??0);h=Math.min(h,(this.header.tabsContainer.offset()?.left??0)+(this.header.tabsContainer.innerWidth()??0)),this.layoutManager.dropTargetIndicator?.highlightArea({x1:d,x2:h,y1:this.header.element.offset()?.top??0,y2:(this.header.element.offset()?.top??0)+(this.header.element.innerHeight()??0)})}_resetHeaderDropZone(){this.layoutManager.tabDropPlaceholder.remove()}_setupHeaderPosition(){const e=["right","left","bottom"].some(t=>t===this._header.show)?this._header.show:void 0;if(this.header.element.toggle(!!this._header.show),!!e&&(this._side=e,this._sided=["right","left"].indexOf(this._side.toString())>=0,this.element.removeClass("lm_left lm_right lm_bottom"),this._side&&this.element.addClass("lm_"+this._side),this.element.find(".lm_header").length&&this.childElementContainer)){const t=["right","bottom"].indexOf(this._side.toString())>=0?"before":"after";this.header.element[t](this.childElementContainer),this.callDownwards("setSize")}}_highlightBodyDropZone(e){const t=this._contentAreaDimensions?.[e]?.highlightArea;t&&this.layoutManager.dropTargetIndicator?.highlightArea(t),this._dropSegment=e}}const ZC=Object.freeze(Object.defineProperty({__proto__:null,AbstractContentItem:mt,Component:qh,ContentItem:mt,Root:Ga,RowOrColumn:Sl,Stack:za,isComponent:Lt,isRoot:Yh,isStack:oo},Symbol.toStringTag,{value:"Module"}));class Jl{static _template=['<li class="lm_tab">','<span class="lm_title_before"></span>','<span class="lm_title"></span>','<div class="lm_close_tab"></div>',"</li>"].join("");header;contentItem;element=de(Jl._template);titleElement;closeElement;isActive=!1;_layoutManager;_dragListener;constructor(e,t){this.header=e,this.contentItem=t,this.titleElement=this.element.find(".lm_title"),this.closeElement=this.element.find(".lm_close_tab"),this.closeElement[t.config.isClosable?"show":"hide"](),this.setTitle(t.config.title),this.contentItem.on("titleChanged",this.setTitle,this),this._layoutManager=this.contentItem.layoutManager,this._layoutManager.config.settings?.reorderEnabled&&t.config.reorderEnabled&&(this._dragListener=new fo(this.element),this._dragListener.on("dragStart",this._onDragStart,this),this.contentItem.on("destroy",this._dragListener.destroy,this._dragListener)),this._onTabClick=this._onTabClick.bind(this),this._onCloseClick=this._onCloseClick.bind(this),this._onTabContentFocusIn=this._onTabContentFocusIn.bind(this),this._onTabContentFocusOut=this._onTabContentFocusOut.bind(this),this.element.on("click",this._onTabClick),this.element.on("auxclick",this._onTabClick),this.contentItem.config.isClosable?(this.closeElement.on("click",this._onCloseClick),this.closeElement.on("mousedown",this._onCloseMousedown)):this.closeElement.remove(),this.contentItem.tab=this,this.contentItem.emit("tab",this),this.contentItem.layoutManager.emit("tabCreated",this),Lt(this.contentItem)&&(this.contentItem.container._contentElement.on("focusin",this._onTabContentFocusIn).on("focusout",this._onTabContentFocusOut),this.contentItem.container._contentElement[0].addEventListener("click",this._onTabContentFocusIn,!0),this.contentItem.container.tab=this,this.contentItem.container.emit("tab",this))}setTitle(e=""){this.titleElement.html(e)}setActive(e){e!==this.isActive&&(this.isActive=e,e?this.element.addClass("lm_active"):this.element.removeClass("lm_active"))}_$destroy(){this.element.off("click",this._onTabClick),this.element.off("auxclick",this._onTabClick),this.closeElement.off("click",this._onCloseClick),Lt(this.contentItem)&&(this.contentItem.container._contentElement.off(),this.contentItem.container._contentElement[0].removeEventListener("click",this._onTabContentFocusIn,!0)),this._dragListener&&(this.contentItem.off("destroy",this._dragListener.destroy,this._dragListener),this._dragListener.off("dragStart",this._onDragStart),this._dragListener=void 0),this.element.remove()}_onDragStart(e,t){this.contentItem.parent?.isMaximised&&this.contentItem.parent.toggleMaximise(),this._dragListener&&new Di(e,t,this._dragListener,this._layoutManager,this.contentItem,this.header.parent)}_onTabContentFocusIn(){Lt(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.contentItem.container._contentElement[0].focus(),this.element.addClass("lm_focusin")}_onTabContentFocusOut(){Lt(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.element.removeClass("lm_focusin")}_onTabClick(e){if(!e||e.button===0){var t=this.header.parent.getActiveContentItem();this.contentItem!==t&&Lt(this.contentItem)?this.header.parent.setActiveContentItem(this.contentItem):Lt(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.contentItem.container._contentElement.focus(),Lt(this.contentItem)&&this.contentItem.container.emit("tabClicked",e),this.header._hideAdditionalTabsDropdown(),this.element.get(0)?.scrollIntoView({inline:"nearest"})}else e.button===1&&this.contentItem.config.isClosable&&this._onCloseClick(e)}_onCloseClick(e){e.stopPropagation(),Lt(this.contentItem)?this.contentItem.container.close():this.header.parent.removeChild(this.contentItem)}_onCloseMousedown(e){e.stopPropagation()}}class vi extends pn{static _template=['<div class="lm_header">','<ul class="lm_tabs"></ul>','<ul class="lm_controls"></ul>','<ul class="lm_tabdropdown_list">','<li class="lm_tabdropdown_search"><input type="text" placeholder="Find tab..."></li>',"</ul>","</div>"].join("");static _previousButtonTemplate=['<ul class="lm_controls">','<li class="lm_tabpreviousbutton"></li>',"</ul>"].join("");static _nextButtonTemplate=['<li class="lm_tabnextbutton"></li>'].join("");layoutManager;element=de(vi._template);tabsContainer;tabDropdownContainer;tabDropdownSearch;tabDropdownList=null;controlsContainer;parent;tabs=[];activeContentItem=null;closeButton=null;tabDropdownButton=null;tabNextButton=de(vi._nextButtonTemplate);tabPreviousButton=de(vi._previousButtonTemplate);holdTimer=null;rAF=null;CLICK_TIMEOUT=500;START_SPEED=.01;ACCELERATION=5e-4;SCROLL_LEFT="left";SCROLL_RIGHT="right";isDraggingTab=!1;isOverflowing=!1;isDropdownShown=!1;dropdownKeyIndex=0;_lastVisibleTabIndex=-1;_tabControlOffset;constructor(e,t){super(),this.layoutManager=e,this.layoutManager.config.settings?.selectionEnabled&&(this.element.addClass("lm_selectable"),this.element.on("click",this._onHeaderClick.bind(this))),this.tabsContainer=this.element.find(".lm_tabs"),this.tabDropdownContainer=this.element.find(".lm_tabdropdown_list"),this.tabDropdownContainer.hide(),this.tabDropdownSearch=this.element.find(".lm_tabdropdown_search input"),this._handleFilterInput=this._handleFilterInput.bind(this),this._handleFilterKeydown=this._handleFilterKeydown.bind(this),this.tabDropdownSearch.on("input",this._handleFilterInput),this.tabDropdownSearch.on("keydown",this._handleFilterKeydown),this.controlsContainer=this.element.find(".lm_controls"),this.parent=t,this.parent.on("resize",this._updateTabSizes,this),this._handleItemPickedUp=this._handleItemPickedUp.bind(this),this._handleItemDropped=this._handleItemDropped.bind(this),this._handleNextMouseEnter=this._handleNextMouseEnter.bind(this),this._handleNextMouseLeave=this._handleNextMouseLeave.bind(this),this._handlePreviousMouseEnter=this._handlePreviousMouseEnter.bind(this),this._handlePreviousMouseLeave=this._handlePreviousMouseLeave.bind(this),this._handleScrollRepeat=this._handleScrollRepeat.bind(this),this._handleNextButtonMouseDown=this._handleNextButtonMouseDown.bind(this),this._handlePreviousButtonMouseDown=this._handlePreviousButtonMouseDown.bind(this),this._handleScrollButtonMouseDown=this._handleScrollButtonMouseDown.bind(this),this._handleScrollButtonMouseUp=this._handleScrollButtonMouseUp.bind(this),this._handleScrollEvent=this._handleScrollEvent.bind(this),this.tabNextButton.on("mousedown",this._handleNextButtonMouseDown),this.tabPreviousButton.on("mousedown",this._handlePreviousButtonMouseDown),this.tabsContainer.on("scroll",this._handleScrollEvent),this.layoutManager.on("itemPickedUp",this._handleItemPickedUp),this.layoutManager.on("itemDropped",this._handleItemDropped),this.tabsContainer.before(this.tabPreviousButton),this.tabPreviousButton=this.tabPreviousButton.find(">:first-child"),this.tabPreviousButton.hide(),this._showAdditionalTabsDropdown=this._showAdditionalTabsDropdown.bind(this),this._hideAdditionalTabsDropdown=this._hideAdditionalTabsDropdown.bind(this),this._tabControlOffset=this.layoutManager.config.settings?.tabControlOffset,this._createControls()}createTab(e,t){for(let s=0;s<this.tabs.length;s++)if(this.tabs[s].contentItem===e)return;const n=new Jl(this,e);if(this.tabs.length===0){this.tabs.push(n),this.tabsContainer.append(n.element);return}t===void 0&&(t=this.tabs.length),t>0?this.tabs[t-1].element.after(n.element):this.tabs[0].element.before(n.element),this.tabs.splice(t,0,n),this._updateTabSizes()}removeTab(e){for(var t=0;t<this.tabs.length;t++)if(this.tabs[t].contentItem===e){this.tabs[t]._$destroy(),this.tabs.splice(t,1);return}throw new Error("contentItem is not controlled by this header")}setActiveContentItem(e){for(var t,n=0;n<this.tabs.length;n++)t=this.tabs[n].contentItem===e,this.tabs[n].setActive(t),t===!0&&(this.activeContentItem=e,this.parent.config.activeItemIndex=n);this.tabs[this.parent.config.activeItemIndex??0].element.get(0)?.scrollIntoView({inline:"nearest"}),this._hideAdditionalTabsDropdown(),this._updateTabSizes(),this.parent.emitBubblingEvent("stateChanged")}position(e){let t=this.parent._header.show;return t&&!this.parent._side&&(t="top"),e!==void 0&&this.parent._header.show!==e&&(this.parent._header.show=e,this.parent._setupHeaderPosition()),t}_attachWheelListener(){this.tabsContainer.get(0)?.addEventListener("wheel",this._handleWheelEvent,{passive:!0})}_detachWheelListener(){this.tabsContainer.get(0)?.removeEventListener("wheel",this._handleWheelEvent)}_handleWheelEvent(e){const t=e.currentTarget;if(!(t instanceof HTMLElement))return;let n=Math.abs(e.deltaY)>Math.abs(e.deltaX)?e.deltaY:e.deltaX;e.deltaMode===WheelEvent.DOM_DELTA_PAGE?n*=this.tabsContainer.innerWidth()??1:e.deltaMode===WheelEvent.DOM_DELTA_LINE&&(n*=100/3),t.scrollLeft+=Math.round(n)}_handleScrollEvent(){this._checkScrollArrows()}_handleItemPickedUp(){this.isDraggingTab=!0,this.controlsContainer.on("mouseenter",this._handleNextMouseEnter),this.tabPreviousButton.on("mouseenter",this._handlePreviousMouseEnter)}_handleItemDropped(){this.isDraggingTab=!1,window.cancelAnimationFrame(this.rAF??-1),this.rAF=null,this.controlsContainer.off("mouseenter",this._handleNextMouseEnter),this.controlsContainer.off("mouseleave",this._handleNextMouseLeave),this.tabPreviousButton.off("mouseenter",this._handlePreviousMouseEnter),this.tabPreviousButton.off("mouseleave",this._handlePreviousMouseLeave)}_handleNextMouseEnter(){this.controlsContainer.on("mouseleave",this._handleNextMouseLeave),this._handleScrollRepeat(this.SCROLL_RIGHT,this.tabsContainer.scrollLeft()??0)}_handlePreviousMouseEnter(){this.tabPreviousButton.on("mouseleave",this._handlePreviousMouseLeave),this._handleScrollRepeat(this.SCROLL_LEFT,this.tabsContainer.scrollLeft()??0)}_handleNextMouseLeave(){window.cancelAnimationFrame(this.rAF??-1),this.rAF=null,this.controlsContainer.off("mouseleave",this._handleNextMouseLeave)}_handlePreviousMouseLeave(){window.cancelAnimationFrame(this.rAF??-1),this.rAF=null,this.tabPreviousButton.off("mouseleave",this._handlePreviousMouseLeave)}_handleNextButtonMouseDown(){var e;for(let t=0;t<this.tabs.length;t+=1)if((this.tabs[t].element.get(0)?.offsetLeft??0)>(this.tabsContainer.get(0)?.offsetWidth??0)+(this.tabsContainer.scrollLeft()??0)){e=this.tabs[t].element.get(0);break}if(e)e.scrollIntoView({behavior:"smooth",inline:"nearest"}),this._handleScrollButtonMouseDown(this.SCROLL_RIGHT);else{const t=this.tabsContainer.get(0);t&&(t.scrollLeft=this.tabsContainer.get(0)?.scrollWidth??0)}}_handlePreviousButtonMouseDown(){for(var e,t=this.tabs.length-1;t>=0;t-=1)if((this.tabs[t].element.get(0)?.offsetLeft??0)<(this.tabsContainer.scrollLeft()??0)){e=this.tabs[t].element.get(0);break}if(e)e.scrollIntoView({behavior:"smooth",inline:"start"}),this._handleScrollButtonMouseDown(this.SCROLL_LEFT);else{const n=this.tabsContainer.get(0);n&&(n.scrollLeft=0)}}_handleScrollButtonMouseDown(e){this.holdTimer=window.setTimeout(()=>{this._handleScrollRepeat(e,this.tabsContainer.scrollLeft()??0,100)},this.CLICK_TIMEOUT),window.addEventListener("mouseup",this._handleScrollButtonMouseUp)}_handleScrollButtonMouseUp(){clearTimeout(this.holdTimer??-1),this.holdTimer=null,cancelAnimationFrame(this.rAF??-1),this.rAF=null,window.removeEventListener("mouseup",this._handleScrollButtonMouseUp)}_checkScrollArrows(){this.tabsContainer.scrollLeft()===0?this.tabPreviousButton.first().prop("disabled",!0):(this.tabsContainer.scrollLeft()??0)+(this.tabsContainer.innerWidth()??0)===this.tabsContainer.get(0)?.scrollWidth?this.tabNextButton.prop("disabled",!0):(this.tabNextButton.prop("disabled",!1),this.tabPreviousButton.first().prop("disabled",!1))}_handleScrollRepeat(e,t,n=0,s){const i=this.tabsContainer.get(0);if(!i)return;const o=i.getBoundingClientRect();if(e===this.SCROLL_LEFT){if(this.tabsContainer.scrollLeft(t-n),this.isDraggingTab&&this.parent._highlightHeaderDropZone(o.left-1),this.tabsContainer.scrollLeft()===0){this._checkScrollArrows();return}}else if(e===this.SCROLL_RIGHT&&(this.tabsContainer.scrollLeft(t+n),this.isDraggingTab&&this.parent._highlightHeaderDropZone(o.right+1),(this.tabsContainer.scrollLeft()??0)+(this.tabsContainer.innerWidth()??0)===i.scrollWidth)){this._checkScrollArrows();return}window.cancelAnimationFrame(this.rAF??-1),this.rAF=window.requestAnimationFrame(l=>{var a=s||l,d=l-a,h=this.START_SPEED*d+.5*this.ACCELERATION*(d*d);h=Math.min(h,this.tabsContainer.get(0)?.scrollWidth??1/0),this._handleScrollRepeat(e,t,h,a)})}_$setClosable(e){return this.closeButton&&this._isClosable()?(this.closeButton.element[e?"show":"hide"](),!0):!1}_$destroy(){this.emit("destroy",this);for(var e=0;e<this.tabs.length;e++)this.tabs[e]._$destroy();this._detachWheelListener(),this._handleItemDropped(),de(document).off("mouseup",this._hideAdditionalTabsDropdown),this.tabDropdownSearch.off("input",this._handleFilterInput),this.tabDropdownSearch.off("keydown",this._handleFilterKeydown),this.element.remove()}_getHeaderSetting(e){if(e in this.parent._header)return this.parent._header[e]}_createControls(){var e,t,n,s,i;if(i=this.layoutManager.config.labels.tabDropdown,this.layoutManager.config.labels.tabNextLabel,this.layoutManager.config.labels.tabPreviousLabel,this.tabDropdownButton=new Yi(this,i,"lm_tabdropdown",this._showAdditionalTabsDropdown),this.tabDropdownButton.element.hide(),this.controlsContainer.prepend(this.tabNextButton),this.tabNextButton.hide(),this._getHeaderSetting("popout")&&(t=this._onPopoutClick.bind(this),n=this._getHeaderSetting("popout"),new Yi(this,n,"lm_popout",t)),this._getHeaderSetting("maximise")){s=this.parent.toggleMaximise.bind(this.parent);const o=this._getHeaderSetting("maximise"),l=this._getHeaderSetting("minimise"),a=new Yi(this,o,"lm_maximise",s);this.parent.on("maximised",function(){a.element.attr("title",l??"")}),this.parent.on("minimised",function(){a.element.attr("title",o??"")})}this._isClosable()&&(e=this.parent.remove.bind(this.parent),n=this._getHeaderSetting("close"),this.closeButton=new Yi(this,n,"lm_close",e))}_showAdditionalTabsDropdown(){if(this.isDropdownShown){this._hideAdditionalTabsDropdown();return}this.tabDropdownList=this.tabsContainer.clone(!0).appendTo(this.tabDropdownContainer).children().removeClass("lm_active"),this.tabDropdownContainer.show(),this.isDropdownShown=!0,this.element.addClass("lm_dropdown_open"),this.tabDropdownSearch.val("").focus(),this.dropdownKeyIndex=0,this.tabDropdownList.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active"),de(document).on("mousedown",this._hideAdditionalTabsDropdown),this._updateAdditionalTabsDropdown()}_handleFilterKeydown(e){if(this.dropdownKeyIndex===-1)return;if(e.key==="Escape"){this._hideAdditionalTabsDropdown();return}if(e.key==="Enter"||e.key===" "){this._hideAdditionalTabsDropdown(),this.tabs[this.dropdownKeyIndex]._onTabClick();return}function t(n,s,i){if(i==null||i.length<2)return-1;for(var o=(n+s+i.length)%i.length;o!==n;){if(i.eq(o).css("display")!=="none")return o;o=(o+s+i.length)%i.length}return n}e.key==="ArrowDown"||e.key==="Tab"&&e.shiftKey===!1?(e.preventDefault(),this.tabDropdownList?.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=t(this.dropdownKeyIndex,1,this.tabDropdownList),this.tabDropdownList?.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active")):(e.key==="ArrowUp"||e.key==="Tab")&&(e.preventDefault(),this.tabDropdownList?.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=t(this.dropdownKeyIndex,-1,this.tabDropdownList),this.tabDropdownList?.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active"))}_handleFilterInput(e){if(this.tabDropdownList!=null){this.tabDropdownList.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=-1;for(var t=0;t<this.tabDropdownList.length;t++)(this.tabs[t].contentItem.config.title?.toLowerCase().indexOf(e.target.value.toLowerCase())??-1)!==-1?(this.tabDropdownList.eq(t).css("display",""),this.dropdownKeyIndex===-1&&(this.dropdownKeyIndex=t)):this.tabDropdownList.eq(t).css("display","none");this.dropdownKeyIndex!==-1&&this.tabDropdownList.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active")}}_hideAdditionalTabsDropdown(e){this.isDropdownShown&&(e&&this.tabDropdownContainer.get(0)?.contains(e.target)||e&&this.tabDropdownButton?.element.get(0)===e.target||(this.element.removeClass("lm_dropdown_open"),this.tabDropdownContainer.hide(),this.isDropdownShown=!1,this.tabDropdownContainer.find(".lm_tabs").remove(),de(document).off("mousedown",this._hideAdditionalTabsDropdown)))}_updateAdditionalTabsDropdown(){this.tabDropdownContainer.css("max-height","");const e=this.tabDropdownContainer[0].scrollHeight;if(e===0)return;const t=(this.tabDropdownContainer.offset()?.top??0)-(de(window).scrollTop()??0);t+e>(de(window).height()??0)&&this.tabDropdownContainer.css("max-height",(de(window).height()??0)-t-10)}_isClosable(){return Boolean(this.parent.config.isClosable&&this.layoutManager.config.settings.showCloseIcon)}_onPopoutClick(){this.layoutManager.config.settings.popoutWholeStack===!0?this.parent.popout():this.activeContentItem?.popout()}_onHeaderClick(e){e.target===this.element[0]&&this.parent.select()}_updateTabSizes(){if(this.tabs.length===0)return;const e=this.tabsContainer.get(0);e&&(!this.isOverflowing&&e.scrollWidth>e.clientWidth?(this.tabDropdownButton?.element.show(),this.tabNextButton.show(),this.tabPreviousButton.show(),this.isOverflowing=!0):this.isOverflowing&&e.scrollWidth<=e.clientWidth&&(this.tabDropdownButton?.element.hide(),this.tabNextButton.hide(),this.tabPreviousButton.hide(),this.isOverflowing=!1),this.isOverflowing&&this._checkScrollArrows())}}class Xh{_isVertical;_size;_grabSize;_dragListener;element;constructor(e,t,n){this._isVertical=e,this._size=t,this._grabSize=n<t?t:n,this.element=this._createElement(),this._dragListener=new fo(this.element)}on(e,t,n){this._dragListener?.on(e,t,n)}_$destroy(){this._dragListener?.destroy(),this._dragListener=null,this.element.remove()}_createElement(){var e=de('<div class="lm_drag_handle"></div>'),t=de('<div class="lm_splitter"></div>');t.append(e);var n=this._grabSize-this._size,s=n/2;return this._isVertical?(e.css("top",-s),e.css("height",this._size+n),t.addClass("lm_vertical"),t.height(this._size)):(e.css("left",-s),e.css("width",this._size+n),t.addClass("lm_horizontal"),t.width(this._size)),t}}class Zh{_element=de('<div class="lm_transition_indicator"></div>');_toElement=null;_fromDimensions={};_totalAnimationDuration=200;_animationStartTime=null;constructor(){de(document.body).append(this._element)}destroy(){this._element.remove()}transitionElements(e,t){}_nextAnimationFrame(){if(!this._toElement||this._animationStartTime==null)return;const e=this._measure(this._toElement),t=(Date.now()-this._animationStartTime)/this._totalAnimationDuration,n={};if(t>=1){this._element.hide();return}e.opacity=0;const s=Object.keys(this._fromDimensions);for(let i of s)n[i]=(this._fromDimensions[i]??0)+((e[i]??0)-(this._fromDimensions[i]??0))*t;this._element.css(n),Zl(this._nextAnimationFrame.bind(this))}_measure(e){const t=e.offset();return{left:t?.left,top:t?.top,width:e.outerWidth(),height:e.outerHeight()}}}const QC=Object.freeze(Object.defineProperty({__proto__:null,BrowserPopout:Gh,DragProxy:Di,DragSource:zh,DragSourceFromEvent:Kh,DropTargetIndicator:Ql,Header:vi,HeaderButton:Yi,Splitter:Xh,Tab:Jl,TransitionIndicator:Zh},Symbol.toStringTag,{value:"Module"})),JC={config:HC,container:UC,controls:QC,errors:XC,items:ZC,utils:YC},eS=JC;class Qh extends pn{static __lm=eS;static minifyConfig(e){return yr(e)}static unminifyConfig(e){return $a(e)}isInitialised=!1;_isFullPage=!1;_resizeTimeoutId;_components={"lm-react-component":$h};_fallbackComponent;_itemAreas=[];_maximisedItem=null;_maximisePlaceholder=de('<div class="lm_maximise_place"></div>');_creationTimeoutPassed=!1;_subWindowsCreated=!1;_dragSources=[];_updatingColumnsResponsive=!1;_firstLoad=!0;width=null;height=null;root;openPopouts=[];selectedItem=null;isSubWindow=!1;eventHub=new Wh(this);config;container;_originalContainer;dropTargetIndicator=null;transitionIndicator=null;tabDropPlaceholder=de('<div class="lm_drop_tab_placeholder"></div>');_typeToItem;constructor(e,t){super(),this._onResize=this._onResize.bind(this),this._onUnload=this._onUnload.bind(this),this._windowBlur=this._windowBlur.bind(this),this._windowFocus=this._windowFocus.bind(this),this.config=this._createConfig(e),this._originalContainer=t,this.container=this._getContainer(),this.isSubWindow&&de("body").css("visibility","hidden"),this._typeToItem={column:Sl.bind(this,!0),row:Sl.bind(this,!1),stack:za,component:qh}}registerComponent(e,t){if(typeof t!="function"&&(t==null||t.render==null||typeof t.render!="function"))throw new Error("Please register a constructor function");if(this._components[e]!==void 0)throw new Error("Component "+e+" is already registered");return this._components[e]=t,()=>{if(this._components[e]===void 0)throw new Error("Component "+e+" is not registered");delete this._components[e]}}setFallbackComponent(e){this._fallbackComponent=e}toConfig(e){if(this.isInitialised===!1)throw new Error("Can't create config, layout not yet initialised");if(e&&!(e instanceof mt))throw new Error("Root must be a ContentItem");const t={settings:{...this.config.settings},dimensions:{...this.config.dimensions},labels:{...this.config.labels},content:[]},n=function(s,i){for(let o in i.config)o!=="content"&&(s[o]=i.config[o]);if(s.componentName==="lm-react-component"&&(s.type="react-component"),i.contentItems.length){s.content=[];for(let o=0;o<i.contentItems.length;o++)s.content[o]={},n(s.content[o],i.contentItems[o])}};e?n(t,{contentItems:[e]}):n(t,this.root),this._$reconcilePopoutWindows(),t.openPopouts=[];for(let s=0;s<this.openPopouts.length;s++)t.openPopouts.push(this.openPopouts[s].toConfig());return t.maximisedItemId=this._maximisedItem?"__glMaximised":void 0,t}getComponent(e){return this._components[e]}getFallbackComponent(){return this._fallbackComponent}init(){if(this._subWindowsCreated===!1&&(this._createSubWindows(),this._subWindowsCreated=!0),document.readyState==="loading"||document.body===null){de(document).ready(this.init.bind(this));return}if(this.isSubWindow===!0&&this._creationTimeoutPassed===!1){setTimeout(this.init.bind(this),7),this._creationTimeoutPassed=!0;return}this.isSubWindow===!0&&this._adjustToWindowMode(),this._setContainer(),this.dropTargetIndicator=new Ql,this.transitionIndicator=new Zh,this.updateSize(),this._create(this.config),this._bindEvents(),this.isInitialised=!0,this._adjustColumnsResponsive(),this.emit("initialised")}updateSize(e,t){this.width=e??this.container.width()??0,this.height=t??this.container.height()??0,this.isInitialised===!0&&(this.root.callDownwards("setSize",[this.width,this.height]),this._maximisedItem&&(this._maximisedItem.element.width(this.container.width()??0),this._maximisedItem.element.height(this.container.height()??0),this._maximisedItem.callDownwards("setSize")),this._adjustColumnsResponsive())}destroy(){this.isInitialised===!1||!this.root||(this._onUnload(),de(window).off("resize",this._onResize),de(window).off("unload beforeunload",this._onUnload),de(window).off("blur.lm").off("focus.lm"),this.root.callDownwards("_$destroy",[],!0),this.root.contentItems=[],this.tabDropPlaceholder.remove(),this.dropTargetIndicator?.destroy(),this.transitionIndicator?.destroy(),this.eventHub.destroy(),this._dragSources.forEach(function(e){e._dragListener.destroy()}),this._dragSources=[])}createContentItem(e,t){var n,s;if(typeof e.type!="string")throw new zs("Missing parameter 'type'",e);if(e.type==="react-component"&&(e.type="component",e.componentName="lm-react-component"),!this._typeToItem[e.type])throw n="Unknown type '"+e.type+"'. Valid types are "+Object.keys(this._typeToItem).join(","),new zs(n);return e.type==="component"&&!(t instanceof za)&&t&&!(this.isSubWindow===!0&&t instanceof Ga)&&(e={type:"stack",width:e.width,height:e.height,content:[e]}),s=new this._typeToItem[e.type](this,e,t),s}createPopout(e,t,n,s){let i=[];const o=e instanceof mt,l=this;if(o){i=this.toConfig(e).content,n=Tr();let d=e.parent,h=e;for(;d?.contentItems.length===1&&!d.isRoot;)h=d,d=d.parent;d?.addId(n),(s==null||Number.isNaN(s))&&(s=d?.contentItems.indexOf(h))}else e instanceof Array?i=e:i=[e];if(!t&&o){const d=window.screenX||window.screenLeft,h=window.screenY||window.screenTop,u=e.element.offset()??{left:0,top:0};t={left:d+u.left,top:h+u.top,width:e.element.width()??0,height:e.element.height()??0}}if(!t&&!o&&(t={left:window.screenX||window.screenLeft+20,top:window.screenY||window.screenTop+20,width:500,height:309}),o&&e.remove(),!t||!n||s===void 0)return;const a=new Gh(i,t,n,s,this);return a.on("initialised",function(){l.emit("windowOpened",a)}),a.on("closed",function(){l._$reconcilePopoutWindows()}),this.openPopouts.push(a),a}createDragSource(e,t){this.config.settings.constrainDragToContainer=!1;var n=new zh(e,t,this);return this._dragSources.push(n),n}createDragSourceFromEvent(e,t){return this.config.settings.constrainDragToContainer=!1,new Kh(e,this,t)}selectItem(e,t){if(this.config.settings.selectionEnabled!==!0)throw new Error("Please set selectionEnabled to true to use this feature");e!==this.selectedItem&&(this.selectedItem!==null&&this.selectedItem.deselect(),e&&t!==!0&&e.select(),this.selectedItem=e,this.emit("selectionChanged",e))}_$maximiseItem(e){this._maximisedItem!==null&&this._$minimiseItem(this._maximisedItem),this._maximisedItem=e,this._maximisedItem.addId("__glMaximised"),e.element.addClass("lm_maximised"),e.element.after(this._maximisePlaceholder),this.root.element.prepend(e.element),e.element.width(this.container.width()??0),e.element.height(this.container.height()??0),e.callDownwards("setSize"),this._maximisedItem.emit("maximised"),this.emit("stateChanged")}_$minimiseItem(e){e.element.removeClass("lm_maximised"),e.removeId("__glMaximised"),this._maximisePlaceholder.after(e.element),this._maximisePlaceholder.remove(),e.parent?.callDownwards("setSize"),this._maximisedItem=null,e.emit("minimised"),this.emit("stateChanged")}_$closeWindow(){window.setTimeout(function(){window.close()},1)}_$getArea(e,t){let n=1/0,s=null;for(let i=0;i<this._itemAreas.length;i++){const o=this._itemAreas[i];e>o.x1&&e<o.x2&&t>o.y1&&t<o.y2&&n>o.surface&&(n=o.surface,s=o)}return s}_$createRootItemAreas(){const t={...this.root._$getArea()},n=[{...t,side:"left",x2:t.x1+50},{...t,side:"right",x1:t.x2-50},{...t,side:"top",y2:t.y1+50},{...t,side:"bottom",y1:t.y2-50}];n.forEach(s=>{s.surface=(s.x2-s.x1)*(s.y2-s.y1)}),this._itemAreas.push(...n)}_$calculateItemAreas(){const e=this._getAllContentItems();if(this._itemAreas=[],e.length===1){this._itemAreas.push(this.root._$getArea());return}this._$createRootItemAreas();for(let t=0;t<e.length;t++){const n=e[t];if(!oo(n))continue;const s=n._$getArea();if(s!==null)if(s instanceof Array)this._itemAreas=this._itemAreas.concat(s);else{this._itemAreas.push(s);let i={...s,...s.contentItem._contentAreaDimensions?.header.highlightArea};i.surface=(i.x2-i.x1)*(i.y2-i.y1),this._itemAreas.push(i)}}}_$normalizeContentItem(e,t){if(!e)throw new Error("No content item defined");if(typeof e=="function"&&(e=e()),e instanceof mt)return e;if(de.isPlainObject(e)&&e.type){var n=this.createContentItem(e,t);return n.callDownwards("_$init"),n}else throw new Error("Invalid contentItem")}_$reconcilePopoutWindows(){const e=[];for(let t=0;t<this.openPopouts.length;t++)this.openPopouts[t].getWindow()?.closed===!1?e.push(this.openPopouts[t]):this.emit("windowClosed",this.openPopouts[t]);this.openPopouts.length!==e.length&&(this.emit("stateChanged"),this.openPopouts=e)}_getAllContentItems(){const e=[],t=n=>{if(e.push(n),n.contentItems instanceof Array)for(let s=0;s<n.contentItems.length;s++)t(n.contentItems[s])};return t(this.root),e}_bindEvents(){this._isFullPage&&de(window).resize(this._onResize),de(window).on("unload beforeunload",this._onUnload).on("blur.lm",this._windowBlur).on("focus.lm",this._windowFocus)}_windowBlur(){this.root.element.addClass("lm_window_blur")}_windowFocus(){this.root.element.removeClass("lm_window_blur")}_onResize(){clearTimeout(this._resizeTimeoutId),this._resizeTimeoutId=window.setTimeout(this.updateSize.bind(this),100)}_createConfig(e){var t=Bh("gl-window");t&&(this.isSubWindow=!0,e=JSON.parse(localStorage.getItem(t)||"{}"),e=$a(e),localStorage.removeItem(t)),e=de.extend(!0,{},jh,e);var n=function(s){for(var i in s){const o=s[i];i!=="props"&&typeof o=="object"&&o!=null?n(o):i==="type"&&o==="react-component"&&(s.type="component",s.componentName="lm-react-component")}};return n(e),e.settings?.hasHeaders===!1&&(e.dimensions.headerHeight=0),e}_adjustToWindowMode(){var e=de('<div class="lm_popin" title="'+this.config.labels.popin+'"><div class="lm_icon"></div><div class="lm_bg"></div></div>');e.click(()=>{this.emit("popIn")}),document.title=Er(this.config.content[0].title??""),de("head").append(de("body link, body style, template, .gl_keep")),this.container=de("body").html("").css("visibility","visible").append(e),document.body.offsetHeight,window.__glInstance=this}_createSubWindows(){if(this.config.openPopouts)for(let e=0;e<this.config.openPopouts.length;e++){const t=this.config.openPopouts[e];this.createPopout(t.content,t.dimensions,t.parentId,t.indexInParent)}}_getContainer(){const e=this._originalContainer?de(this._originalContainer):de("body");if(e.length===0)throw new Error("GoldenLayout container not found");if(e.length>1)throw new Error("GoldenLayout more than one container element specified");return e}_setContainer(){const e=this._getContainer();e[0]===document.body&&(this._isFullPage=!0,de("html, body").css({height:"100%",margin:0,padding:0,overflow:"hidden"})),this.container=e}_create(e){var t;if(!(e.content instanceof Array))throw e.content===void 0?t="Missing setting 'content' on top level of configuration":t="Configuration parameter 'content' must be an array",new zs(t,e);if(e.content.length>1)throw t="Top level content can't contain more then one element.",new zs(t,e);this.root=new Ga(this,{content:e.content},this.container),this.root.callDownwards("_$init"),e.maximisedItemId==="__glMaximised"&&this.root.getItemsById(e.maximisedItemId)[0].toggleMaximise()}_onUnload(){if(this.config.settings.closePopoutsOnUnload===!0)for(var e=0;e<this.openPopouts.length;e++)this.openPopouts[e].close()}_adjustColumnsResponsive(){if(!this._useResponsiveLayout()||this._updatingColumnsResponsive||!this.config.dimensions||!this.config.dimensions.minItemWidth||this.root.contentItems.length===0||!this.root.contentItems[0].isRow){this._firstLoad=!1;return}this._firstLoad=!1;var e=this.root.contentItems[0].contentItems.length;if(!(e<=1)){var t=this.config.dimensions.minItemWidth,n=e*t;if(!(this.width==null||n<=this.width)){this._updatingColumnsResponsive=!0;for(var s=Math.max(Math.floor(this.width/t),1),i=e-s,o=this.root.contentItems[0],l=this._findAllStackContainers()[0],a=0;a<i;a++){var d=o.contentItems[o.contentItems.length-1];this._addChildContentItemsToContainer(l,d)}this._updatingColumnsResponsive=!1}}}_useResponsiveLayout(){return this.config.settings&&(this.config.settings.responsiveMode=="always"||this.config.settings.responsiveMode=="onload"&&this._firstLoad)}_addChildContentItemsToContainer(e,t){t.type==="stack"?t.contentItems.forEach(function(n){e.addChild(n),t.removeChild(n,!0)}):t.contentItems.forEach(n=>{this._addChildContentItemsToContainer(e,n)})}_findAllStackContainers(){const e=[];return this._findAllStackContainersRecursive(e,this.root),e}_findAllStackContainersRecursive(e,t){t.contentItems.forEach(n=>{oo(n)?e.push(n):n.isComponent||this._findAllStackContainersRecursive(e,n)})}}const tS="_lm_root_15d73_3",nS="_lm_row_15d73_7",sS="_lm_item_15d73_7",iS="_lm_content_15d73_11",oS="_lm_dragging_15d73_17",lS="_lm_maximised_15d73_23",aS="_lm_maximise_placeholder_15d73_30",rS="_lm_splitter_15d73_34",dS="_lm_vertical_15d73_41",cS="_lm_drag_handle_15d73_41",hS="_lm_horizontal_15d73_46",uS="_lm_header_15d73_56",mS="_lm_dropdown_open_15d73_63",gS="_lm_controls_15d73_69",pS="_lm_tabs_15d73_89",fS="_lm_tab_15d73_89",CS="_lm_title_15d73_104",SS="_lm_close_tab_15d73_111",bS="_lm_stack_15d73_120",wS="_lm_left_15d73_120",vS="_lm_right_15d73_121",TS="_lm_dragProxy_15d73_125",ES="_lm_items_15d73_148",yS="_lm_tabdropdown_list_15d73_165",RS="_lm_bottom_15d73_192",xS="_lm_drop_tab_placeholder_15d73_207",IS="_lm_tabdropdown_15d73_165",DS="_lm_dropTargetIndicator_15d73_258",FS="_lm_inner_15d73_264",NS="_lm_transition_indicator_15d73_272",kS="_lm_popin_15d73_282",MS="_lm_bg_15d73_297",LS="_lm_icon_15d73_300",OS="_lm_goldenlayout_15d73_304",AS="_lm_selectable_15d73_340",_S="_lm_active_15d73_370",PS="_lm_selected_15d73_388",jS="_lm_keyboard_active_15d73_397",HS="_lm_popout_15d73_416",US="_lm_maximise_15d73_23",VS="_lm_close_15d73_111",BS="_lm_tabnextbutton_15d73_425",$S="_lm_tabpreviousbutton_15d73_428",WS="_lm_title_before_15d73_544",GS="_lm_focusin_15d73_568",zS="_lm_window_blur_15d73_573",KS="_lm_tabdropdown_search_15d73_631",YS="_march_15d73_1",qS="_app_15d73_712",XS="_plotly_15d73_721",jd={"tab-height":"28px","drag-border-width":"5px",lm_root:tS,lm_row:nS,lm_item:sS,lm_content:iS,lm_dragging:oS,lm_maximised:lS,lm_maximise_placeholder:aS,lm_splitter:rS,lm_vertical:dS,lm_drag_handle:cS,lm_horizontal:hS,lm_header:uS,lm_dropdown_open:mS,lm_controls:gS,lm_tabs:pS,lm_tab:fS,lm_title:CS,lm_close_tab:SS,lm_stack:bS,lm_left:wS,lm_right:vS,lm_dragProxy:TS,lm_items:ES,lm_tabdropdown_list:yS,lm_bottom:RS,lm_drop_tab_placeholder:xS,lm_tabdropdown:IS,lm_dropTargetIndicator:DS,lm_inner:FS,lm_transition_indicator:NS,lm_popin:kS,lm_bg:MS,lm_icon:LS,lm_goldenlayout:OS,lm_selectable:AS,lm_active:_S,lm_selected:PS,lm_keyboard_active:jS,lm_popout:HS,lm_maximise:US,lm_close:VS,lm_tabnextbutton:BS,lm_tabpreviousbutton:$S,lm_title_before:WS,"editor-unsaved-indicator":"_editor-unsaved-indicator_15d73_548","is-unsaved":"_is-unsaved_15d73_556",lm_focusin:GS,lm_window_blur:zS,lm_tabdropdown_search:KS,march:YS,app:qS,"js-plotly-plot":"_js-plotly-plot_15d73_721",plotly:XS},Hd=Object.freeze({tabHeight:parseInt(jd["tab-height"],10),dragBorderWidth:parseInt(jd["drag-border-width"],10)}),os=ee.module("LayoutUtils");function Jh(c){return c.componentName!==void 0}function gi(c){const e=c;return(Jh(c)&&c.componentName==="lm-react-component"||c.type==="react-component")&&e.component!==void 0}function Po(c){return c.focus!==void 0}function Ud(c){return c.type==="stack"}class ${static DEFAULT_FOCUS_SELECTOR="input, select, textarea, button";static activateTab(e,t){const n=$.getStackForRoot(e,t,!1);if(!n){os.error("Could not find stack for config",t);return}const s=$.getContentItemInStack(n,t);s&&n.setActiveContentItem(s)}static isActiveTab(e,t){const n=$.getStackForRoot(e,t,!1);if(!n)return os.error("Could not find stack for config",t),!1;const s=$.getContentItemInStack(n,t);return n.getActiveContentItem()===s}static addStack(e,t=!0){const n=t?"column":"row";if(Yh(e)){(e.contentItems==null||e.contentItems.length===0)&&e.addChild({type:n});const o=e.contentItems[0];if(!(t?o.isColumn:o.isRow)){e.removeChild(o,!0),e.addChild({type:n});const a=document.activeElement;e.contentItems[0].addChild(o),a&&a.focus!=null&&a.focus()}return this.addStack(e.contentItems[0],t)}if(e.contentItems.length<2)return e.addChild({type:"stack"}),e.contentItems[e.contentItems.length-1];let s=e.contentItems[e.contentItems.length-1];return(t?s.isRow:s.isColumn)||(e.addChild({type:t?"row":"column"}),e.removeChild(s,!0),e.contentItems[e.contentItems.length-1].addChild(s),s=e.contentItems[e.contentItems.length-1]),this.addStack(s,!t)}static getStackForConfig(e,t={},n=!1){if(n&&oo(e)&&e.contentItems.length===0)return e;if(e.contentItems==null)return null;for(let s=0;s<e.contentItems.length;s+=1){const i=e.contentItems[s];if(i.isComponent&&i.config!=null&&od(i.config,t))return e;const o=this.getStackForConfig(i,t,n);if(o)return o}return null}static getStackForRoot(e,t,n=!0,s=!0,i=!0){let o=this.getStackForConfig(e,t);return!o&&s&&(o=this.getStackForConfig(e,{component:t.component},i)),!o&&n&&(o=this.addStack(e)),o}static getStackForComponentTypes(e,t,n=!0,s=!0,i=!0){for(let o=0;o<t.length;o+=1){const l=t[o],a=o===t.length-1,d=$.getStackForRoot(e,{component:l},n&&a,s,i);if(d)return d}return null}static getContentItemInStack(e,t){if(!e)return null;for(let n=0;n<e.contentItems.length;n+=1){const s=e.contentItems[n];if(s.isComponent&&s.config!=null&&od(s.config,t))return s}return null}static dehydrateLayoutConfig(e,t){if(e==null||!e.length)return[];const n=[];for(let s=0;s<e.length;s+=1){const i=e[s],{component:o,content:l}=i;if(o){const a=t(o,i);a!=null?n.push(a):os.debug2(`dehydrateLayoutConfig: skipping unmapped component "${o}"`)}else if(l){const a={...i,content:$.dehydrateLayoutConfig(l,t)};n.push(a)}else n.push(i)}return n}static getTabPoint(e){const{tab:t}=e;if(t==null)throw new Error(`Cannot get tab for panel container ${e}`);const n=t.element[0].getBoundingClientRect();return[n.left+n.width*.5,n.bottom-8]}static dropLayoutMinorChange(e){for(let t=0;t<e.length;t+=1){const n=e[t],{content:s}=n;s!==void 0?(Ud(n)&&delete n.activeItemIndex,$.dropLayoutMinorChange(s)):gi(n)&&n.component==="IrisGridPanel"&&n.props.panelState!=null&&(delete n.id,n.props.panelState.irisGridState.sorts=[],n.props.panelState.irisGridState.quickFilters=[])}}static isEqual(e,t,n=!1){if(n){const s=$.cloneLayout(e),i=$.cloneLayout(t);return $.dropLayoutMinorChange(s),$.dropLayoutMinorChange(i),Je(s,i)}return Je(e,t)}static cloneLayout(e){return JSON.parse(JSON.stringify(e))}static hydrateLayoutConfig(e,t){if(e==null||!e.length)return[];const n=[];for(let s=0;s<e.length;s+=1){const i=e[s];if(gi(i)){const{component:o,props:l={}}=i;n.push({...i,id:i?.id??ze(),props:t(o,l)})}else if(i.content!==void 0){const o=$.hydrateLayoutConfig(i.content,t);Ud(i)&&i.activeItemIndex!=null&&i.activeItemIndex>=o.length&&(os.warn("Fixing bad activeItemIndex!",i.activeItemIndex,i),i.activeItemIndex=0),n.push({...i,content:o})}else n.push(i)}return n}static openComponent({root:e,config:t,replaceExisting:n=!0,replaceConfig:s=void 0,createNewStack:i=!1,focusElement:o=void 0,dragEvent:l=void 0}={}){const a=document.activeElement,d={...t};if(d.id==null&&(d.id=ze.generate()),l){e?.layoutManager.createDragSourceFromEvent(d,l);return}const h=s||{id:d.id,component:d.component};N(e);const u=i?$.addStack(e):$.getStackForRoot(e,h);N(u);const m=$.getContentItemInStack(u,h);if(o!=null){const g=p=>{os.debug("Component created, focusing element",o),u.off("componentCreated",g);const{element:C}=p.origin;requestAnimationFrame(()=>{$.focusElement(C[0],o)})};u.on("componentCreated",g)}if(n&&m){const g=u.contentItems.indexOf(m);u.addChild(d,g+1),u.removeChild(m),u.setActiveContentItem(u.contentItems[g])}else u.addChild(d);o==null&&a&&Po(a)&&a.focus()}static openComponentInStack(e,t,n=!0){const s=document.activeElement,i={id:t.id},o=$.getContentItemInStack(e,i);if(n&&o&&e){const l=e?.contentItems.indexOf(o);e.addChild(t,l+1),e.removeChild(o),e.setActiveContentItem(e.contentItems[l])}else e?.addChild(t);s&&Po(s)&&s.focus()}static closeComponent(e,t,n){const s=$.getStackForRoot(e,t,!1,!1,!1);if(!s){os.warn("Cannot find stack for component, ignoring close",t);return}const i=$.getContentItemInStack(s,t),o=document.activeElement;i&&(Lt(i)?i.container.close(n):s.removeChild(i)),o&&document.contains(o)&&Po(o)&&o.focus()}static renameComponent(e,t,n){const s=$.getStackForRoot(e,t,!1);if(!s){os.error("Could not find stack for config",t);return}const i=$.getContentItemInStack(s,t);i&&i.setTitle(n)}static cloneComponent(e,t){const n=$.getStackForRoot(e,t,!1);if(!n)return os.error("Could not find stack for config",t),null;const{props:s={}}=t,i=$.getPanelComponentState(t),o={type:"react-component",component:t.component,props:{...s,panelState:i},title:`${t.title} Copy`,id:ze.generate()};return $.openComponentInStack(n,o),o}static getPanelComponentState(e){return Jh(e)?e.componentState?.panelState:gi(e)?e.props?.panelState:null}static makeDefaultLayout(){return{dimensions:{headerHeight:Hd.tabHeight,borderWidth:Hd.dragBorderWidth,borderGrabWidth:10},settings:{showPopoutIcon:!1,showCloseIcon:!1,constrainDragToContainer:!1}}}static getRootFromContainer(e){return e.layoutManager.root}static getComponentConfigFromContainer(e){return e?e.tab!=null&&e.tab.contentItem!=null?e.tab.contentItem.config:e._config:null}static getTitleFromContainer(e){return e!=null&&e.tab!=null&&e.tab.contentItem!=null?e.tab.contentItem.config.title:null}static getTitleFromTab(e){return e!=null&&e.contentItem!=null?e.contentItem.config.title:null}static getIdFromContainer(e){const t=$.getComponentConfigFromContainer(e);return t?t.id:null}static getIdFromPanel(e){const{glContainer:t}=e.props;return $.getIdFromContainer(t)}static getComponentNameFromPanel(e){const{glContainer:t}=e.props,n=$.getComponentConfigFromContainer(t);return n&&gi(n)?n.component??null:null}static getComponentName(e){const t=e.WrappedComponent?.displayName??e.displayName;if(t==null)throw new Error(`Component displayName not defined ${e}`);return t}static focusElement(e,t=$.DEFAULT_FOCUS_SELECTOR){if(e==null)return null;const n=e.querySelector(t);return n==null?null:(Po(n)&&n.focus(),n)}static onInitialized(e){return new Promise(t=>{if(e.isInitialised){t();return}const n=()=>{e.off("initialised",n),t()};e.on("initialised",n)})}}const eu=ae.forwardRef((c,e)=>{const t=$.getComponentNameFromPanel({props:c});return r.jsxs("div",{ref:e,className:"panel-placeholder",children:['Component "',t,'" is not registered.']})});eu.displayName="PanelPlaceholder";const we=Object.freeze({FOCUS:"PanelEvent.FOCUS",MOUNT:"PanelEvent.MOUNT",UNMOUNT:"PanelEvent.UNMOUNT",TITLE_CHANGED:"PanelEvent.TITLE_CHANGED",REOPEN:"PanelEvent.REOPEN",DELETE:"PanelEvent.DELETE",CLONED:"PanelEvent.CLONED",CLOSED:"PanelEvent.CLOSED",OPEN:"PanelEvent.OPEN",CLOSE:"PanelEvent.CLOSE",DRAGGING:"PanelEvent.DRAGGING",DROPPED:"PanelEvent.DROPPED"});function Vd(c){return c?.WrappedComponent!==void 0}function ZS(c){return typeof c.id=="string"&&c.layout instanceof Qh&&c.panelManager instanceof tu&&typeof c.registerComponent=="function"}function Rs(c){if(!ZS(c))throw new Error(`Expected dashboard plugin props, but instead received ${c}`)}const Xt=ee.module("PanelManager");class tu{static MAX_CLOSED_PANEL_COUNT=100;layout;hydrateComponent;dehydrateComponent;onPanelsUpdated;closed;openedMap;constructor(e,t=(l,a)=>a,n=(l,a)=>a,s=new Map,i=[],o=()=>{}){this.handleFocus=this.handleFocus.bind(this),this.handleMount=this.handleMount.bind(this),this.handleUnmount=this.handleUnmount.bind(this),this.handleReopen=this.handleReopen.bind(this),this.handleDeleted=this.handleDeleted.bind(this),this.handleClosed=this.handleClosed.bind(this),this.handleControlClose=this.handleControlClose.bind(this),this.layout=e,this.hydrateComponent=t,this.dehydrateComponent=n,this.onPanelsUpdated=o,this.openedMap=new Map(s),this.closed=[...i],this.startListening()}startListening(){const{eventHub:e}=this.layout;e.on(we.FOCUS,this.handleFocus),e.on(we.MOUNT,this.handleMount),e.on(we.UNMOUNT,this.handleUnmount),e.on(we.REOPEN,this.handleReopen),e.on(we.DELETE,this.handleDeleted),e.on(we.CLOSED,this.handleClosed),e.on(we.CLOSE,this.handleControlClose)}stopListening(){const{eventHub:e}=this.layout;e.off(we.FOCUS,this.handleFocus),e.off(we.MOUNT,this.handleMount),e.off(we.UNMOUNT,this.handleUnmount),e.off(we.REOPEN,this.handleReopen),e.off(we.DELETE,this.handleDeleted),e.off(we.CLOSED,this.handleClosed),e.off(we.CLOSE,this.handleControlClose)}getClosedPanelConfigsOfType(e){return this.closed.filter(t=>t.component===e)}getOpenedPanels(){return Array.from(this.openedMap.values())}getOpenedPanelConfigs(){return this.getOpenedPanels().map(e=>{const{glContainer:t}=e.props;return $.getComponentConfigFromContainer(t)})}getOpenedPanelConfigsOfType(e){return this.getOpenedPanelConfigs().filter(t=>t!=null&&gi(t)&&t.component===e)}getOpenedPanelById(e){return this.openedMap.get(e)}getContainerByPanelId(e){const t=$.getStackForConfig(this.layout.root,{id:e});return(t&&$.getContentItemInStack(t,{id:e}))??null}getLastUsedPanel(e){const t=this.getOpenedPanels();for(let n=t.length-1;n>=0;n-=1){const s=t[n];if(e==null||e(s))return s}}getLastUsedPanelOfType(e){return this.getLastUsedPanelOfTypes([e])}getLastUsedPanelOfTypes(e){return this.getLastUsedPanel(t=>e.some(n=>Vd(n)&&t instanceof n.WrappedComponent||!Vd(n)&&t instanceof n))}updatePanel(e){const t=$.getIdFromPanel(e);if(t==null){Xt.error("updatePanel Panel did not have an ID",e);return}Xt.debug2(`Updating panel ID ${t} in open panels map`),this.openedMap.delete(t),this.openedMap.set(t,e)}removePanel(e){const t=$.getIdFromPanel(e);if(t==null){Xt.error("removePanel Panel did not have an ID",e);return}if(!this.openedMap.has(t)){Xt.error(`Missing panel ID ${t} in open panels map`);return}if(this.openedMap.get(t)!==e){Xt.debug(`Panel argument doesn't match the open panels map entry for ${t}, removePanel ignored`);return}Xt.debug2(`Removing panel ID ${t} from open panels map`),this.openedMap.delete(t)}removeClosedPanelConfig(e){const t=this.closed.findIndex(n=>n===e||n.id!=null&&e.id!=null&&n.id===e.id);t>=0&&this.closed.splice(t,1)}handleFocus(e){Xt.debug2("Focus: ",e),this.updatePanel(e)}handleMount(e){Xt.debug2("Mount: ",e),this.updatePanel(e),this.sendUpdate()}handleUnmount(e){Xt.debug2("Unmount: ",e),this.removePanel(e),this.sendUpdate()}handleReopen(e,t){Xt.debug2("Reopen:",e,t),this.removeClosedPanelConfig(e);const{component:n}=e;let{props:s}=e;s=this.hydrateComponent(n,s);const i={...e,props:s},{root:o}=this.layout;$.openComponent({root:o,config:i,replaceConfig:t})}handleDeleted(e){Xt.debug2("Deleted:",e),this.removeClosedPanelConfig(e),this.sendUpdate()}handleClosed(e,t){Xt.debug2("Closed: ",e),this.addClosedPanel(t),this.sendUpdate()}handleControlClose(e){const t={id:e},{root:n}=this.layout;$.closeComponent(n,t)}addClosedPanel(e){const t=$.getComponentConfigFromContainer(e);if(t&&gi(t)){const n=this.dehydrateComponent(t.component,t);n!=null&&this.closed.push(n)}}sendUpdate(){const{closed:e,openedMap:t}=this;this.onPanelsUpdated({closed:[...e],openedMap:new Map(t)})}}const QS=ee.module("PanelErrorBoundary");class JS extends w.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}componentWillUnmount(){const{glContainer:e,glEventHub:t}=this.props,n=$.getIdFromContainer(e);QS.debug("componentWillUnmount",n),t.emit(we.CLOSED,n,e)}render(){const{children:e}=this.props,{error:t}=this.state;return t!=null?r.jsx("div",{className:"panel-error-boundary",children:r.jsx(Vl,{errorMessage:`${t}`,isLoading:!1,isLoaded:!1})}):e}}function xr(c){const{props:e,componentState:t}=c,{metadata:n}=e;let{panelState:s=null}=e;t&&({panelState:s}=t);const i={};return n!=null&&(i.metadata=n),s!=null&&(i.panelState=s),{...c,componentState:null,props:i,type:"react-component"}}function Ir(c,e=""){return{metadata:{},...c,localDashboardId:e}}const Ka={dehydrate:xr,hydrate:Ir},eb=B.shape({on:B.func,off:B.func,isHidden:B.bool,tab:B.shape({header:B.shape({tabs:B.arrayOf(B.shape({contentItem:B.shape({})}))})}),title:B.string,setTitle:B.func,close:B.func}),nu=B.shape({on:B.func,off:B.func,emit:B.func}),tb=B.shape({registerComponent:B.func,root:B.shape({addChild:B.func}),on:B.func,off:B.func,eventHub:nu}),Dr=Object.freeze({Container:eb,EventHub:nu,Layout:tb}),je=(c,e,t)=>w.useEffect(function(){return c.on(e,t),()=>{c.off(e,t)}},[c,e,t]),su="SET_DASHBOARD_DATA",nb=CC(su,{},!1),sb={dashboardData:nb},ib=new Map,ob=Object.freeze({}),lb=Object.freeze([]),ab=c=>c.dashboardData,Pt=(c,e)=>ab(c)[e]??ob,rb=(c,e)=>Pt(c,e).closed??lb,iu=(c,e)=>Pt(c,e).openedMap??ib,ou=(c,e)=>({type:su,id:c,payload:e}),kn=(c,e)=>(t,n)=>t(ou(c,{...Pt(n(),c),...e}));Object.entries(sb).map(([c,e])=>po.register(c,e));const jo=ee.module("DashboardLayout"),db=Object.freeze({}),cb=[],Bd=()=>{},$d=c=>c;function lu({id:c,children:e,emptyDashboard:t=r.jsx("div",{children:"Dashboard is empty."}),layout:n,layoutConfig:s=cb,onLayoutChange:i=Bd,onLayoutInitialized:o=Bd,hydrate:l=Ir,dehydrate:a=xr}){const d=tr(),h=Ju(U=>Pt(U,c))??db,[u,m]=w.useState(!1),[g,p]=w.useState(!1),[C,f]=w.useState(),[S]=w.useState(h?.closed??[]),[v,b]=w.useState(!1),T=w.useMemo(()=>new Map,[]),y=w.useMemo(()=>new Map,[]),E=em(),R=w.useCallback((U,P,Q=l,G=a)=>{jo.debug2("registerComponent",U,P,Q,G);function ne(Z,oe){const re=P,{glContainer:q,glEventHub:ie}=Z;return r.jsx(Pc,{store:E,children:r.jsx(JS,{glContainer:q,glEventHub:ie,children:r.jsx(re,{...Z,ref:oe})})})}const V=ae.forwardRef(ne),z=n.registerComponent(U,V);return T.set(U,Q),y.set(U,G),z},[l,a,T,y,n,E]),x=w.useCallback((U,P)=>(T.get(U)??$d)(P,c),[T,c]),D=w.useCallback((U,P)=>(y.get(U)??$d)(P,c),[y,c]),L=w.useMemo(()=>new tu(n,x,D,new Map,S,({closed:U,openedMap:P})=>{d(kn(c,{closed:U,openedMap:P}))}),[D,d,x,c,S,n]),M=w.useCallback(()=>{if(g)return;v||(o(),b(!0));const P=n.toConfig().content,Q=$.dehydrateLayoutConfig(P,D),G=C==null||!$.isEqual(C,Q);jo.debug("handleLayoutStateChanged",G,P,Q),G&&(m(n.root.contentItems.length===0),f(Q),i(Q))},[D,v,g,C,n,i,o]),j=w.useCallback(U=>{const P=$.getIdFromContainer(U);n.eventHub.emit(we.DRAGGING,P),p(!0)},[n.eventHub]),A=w.useCallback(U=>{const P=$.getIdFromContainer(U);n.eventHub.emit(we.DROPPED,P),p(!1)},[n.eventHub]),W=w.useCallback(U=>{if(jo.debug2("handleComponentCreated",U),U==null||U.config==null||U.config.component==null||U.element==null)return;const Q=`${U.config.component.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}-component`;U.element.addClass(Q)},[]);je(n,"stateChanged",M),je(n,"itemPickedUp",j),je(n,"itemDropped",A),je(n,"componentCreated",W),je(n.eventHub,we.TITLE_CHANGED,M);const H=sr(s);return w.useEffect(function(){if(H!==s&&s!==C){jo.debug("Setting new layout content...");const P=$.hydrateLayoutConfig(s,x);for(;n.root.contentItems.length>0;)n.root.contentItems[0].remove();for(let Q=0;Q<P.length;Q+=1)n.root.addChild(P[Q]);m(n.root.contentItems.length===0)}},[x,n,s,C,L,H]),r.jsxs(r.Fragment,{children:[u&&t,ae.Children.map(e,U=>U!=null?ae.cloneElement(U,{id:c,layout:n,panelManager:L,registerComponent:R}):null)]})}lu.propTypes={id:B.string.isRequired,children:B.node,data:B.shape({}),emptyDashboard:B.node,layout:Dr.Layout.isRequired,layoutConfig:B.arrayOf(B.shape({})),onLayoutChange:B.func,onLayoutInitialized:B.func};const hb=100,Sa=()=>{},ub=Object.freeze({});function mb({id:c="default",children:e,emptyDashboard:t,layoutConfig:n,layoutSettings:s=ub,onLayoutConfigChange:i=Sa,onGoldenLayoutChange:o=Sa,onLayoutInitialized:l=Sa,fallbackComponent:a=eu,hydrate:d,dehydrate:h}){const u=w.useRef(null),[m,g]=w.useState(!1),[p,C]=w.useState();w.useEffect(function(){if(!u.current){C(void 0);return}const v={...$.makeDefaultLayout()};v.settings===void 0&&(v.settings={}),Object.assign(v.settings,s),v.content=[];const b=new Qh(v,u.current),T=()=>{b.off("initialised",T),g(!0)};return b.on("initialised",T),a!=null&&b.setFallbackComponent(a),b.init(),C(b),o(b),()=>{b.destroy()}},[s,a,o,g,C]);const f=w.useMemo(()=>Ts(()=>{p!=null&&p.isInitialised&&p?.updateSize()},hb),[p]);return w.useEffect(function(){return window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}},[f]),r.jsxs("div",{className:"dashboard-container w-100 h-100",children:[r.jsx("div",{className:"w-100 h-100",ref:u}),m&&p&&r.jsx(lu,{emptyDashboard:t,id:c,layout:p,layoutConfig:n,onLayoutChange:i,onLayoutInitialized:l,hydrate:d,dehydrate:h,children:e})]})}const un="default";class gb extends Error{isAssertionFailed=!0}const au=gb;function Wd(c){if(c==null)throw new au(`Expected 'val' to be defined, but received ${c}`)}class pb extends Error{isPasteError=!0}const ba=pb;function Ke(c){return c?.isEditable!==void 0}function Gd(c){if(!Ke(c))throw new au(`Expected 'model' to be editable, but received ${c}`)}function He(c){return c?.hasExpandableRows!==void 0}var mn=(c=>(c.DOWN="DOWN",c.UP="UP",c.LEFT="LEFT",c.RIGHT="RIGHT",c))(mn||{});class J{startColumn;startRow;endColumn;endRow;static SELECTION_DIRECTION=mn;static normalize(e,t,n,s){let i=e,o=t,l=n,a=s;return i!=null&&l!=null&&l<i&&(i=l,l=e),o!=null&&a!=null&&a<o&&(o=a,a=t),[i,o,l,a]}static makeNormalized(e,t,n,s){return new J(...J.normalize(e,t,n,s))}static makeCell(e,t){return new J(e,t,e,t)}static makeColumn(e){return new J(e,null,e,null)}static makeRow(e){return new J(null,e,null,e)}static minOrNull(e,t){return e==null||t==null?null:Math.min(e,t)}static maxOrNull(e,t){return e==null||t==null?null:Math.max(e,t)}static consolidate(e){const t=e.slice();let n=!0;for(;n;){n=!1;for(let s=0;s<t.length&&!n;s+=1){const i=t[s];for(let o=t.length-1;o>s;o-=1){const l=t[o];if(i.contains(l))t.splice(o,1);else if(l.contains(i)){n=!0,t[s]=l,t.splice(o,1);break}else if(i.startRow===l.startRow&&i.endRow===l.endRow){if(i.touches(l)){const{startRow:a,endRow:d}=i,h=J.minOrNull(i.startColumn,l.startColumn),u=J.maxOrNull(i.endColumn,l.endColumn);n=!0,t[s]=new J(h,a,u,d),t.splice(o,1);break}}else if(i.startColumn===l.startColumn&&i.endColumn===l.endColumn&&i.touches(l)){const{startColumn:a,endColumn:d}=i,h=J.minOrNull(i.startRow,l.startRow),u=J.maxOrNull(i.endRow,l.endRow);n=!0,t[s]=new J(a,h,d,u),t.splice(o,1);break}}}}return t}static isAxisRangeTouching(e,t,n,s){return e==null?t==null||n==null?!0:n<=t+1:t==null?s==null?!0:s>=e-1:n==null?s==null?!0:e<=s+1:s==null?t>=n-1:n>=e-1?n<=t+1:s>=e-1}static rangeArraysEqual(e,t){if(e===t)return!0;if(e==null||t==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!e[n].equals(t[n]))return!1;return!0}static intersection(e,t){if(e.equals(t))return e;let{startColumn:n,startRow:s,endColumn:i,endRow:o}=e;return n=n!=null&&t.startColumn!=null?Math.max(n,t.startColumn):n??t.startColumn,i=i!=null&&t.endColumn!=null?Math.min(i,t.endColumn):i??t.endColumn,s=s!=null&&t.startRow!=null?Math.max(s,t.startRow):s??t.startRow,o=o!=null&&t.endRow!=null?Math.min(o,t.endRow):o??t.endRow,n!=null&&n>(i??-1)||s!=null&&s>(o??-1)?null:new J(n,s,i,o)}static subtractFromRange(e,t){const n=[],s=J.intersection(e,t);return s==null?[e]:(s.startRow!=null&&(e.startRow==null||e.startRow<s.startRow)&&n.push(new J(e.startColumn,e.startRow,e.endColumn,s.startRow-1)),s.startColumn!=null&&(e.startColumn==null||e.startColumn<s.startColumn)&&n.push(new J(e.startColumn,s.startRow,s.startColumn-1,s.endRow)),s.endColumn!=null&&(e.endColumn==null||e.endColumn>s.endColumn)&&n.push(new J(s.endColumn+1,s.startRow,e.endColumn,s.endRow)),s.endRow!=null&&(e.endRow==null||e.endRow>s.endRow)&&n.push(new J(e.startColumn,s.endRow+1,e.endColumn,e.endRow)),n)}static subtractFromRanges(e,t){const n=[];for(let s=0;s<e.length;s+=1)n.push(...J.subtractFromRange(e[s],t));return n}static subtractRangesFromRanges(e,t){let n=[...e];for(let s=0;s<t.length;s+=1)n=J.subtractFromRanges(n,t[s]);return n}static isBounded(e){return e.startRow!=null&&e.startColumn!=null&&e.endRow!=null&&e.endColumn!=null}static boundedRange(e,t,n){return J.isBounded(e)?e:new J(e.startColumn??0,e.startRow??0,e.endColumn??t-1,e.endRow??n-1)}static boundedRanges(e,t,n){return e.map(s=>J.boundedRange(s,t,n))}static offset(e,t,n){return new J(e.startColumn!=null?e.startColumn+t:null,e.startRow!=null?e.startRow+n:null,e.endColumn!=null?e.endColumn+t:null,e.endRow!=null?e.endRow+n:null)}static nextCell(e,t=null,n=null,s=J.SELECTION_DIRECTION.DOWN){if(e.length===0)return null;let i=-1;if(t!=null&&n!=null&&(i=e.findIndex(o=>o.containsCell(t,n)),i>=0)){const l=e[i].nextCell(t,n,s);if(l!=null)return l}switch(s){case J.SELECTION_DIRECTION.DOWN:case J.SELECTION_DIRECTION.RIGHT:{const o=i<e.length-1?i+1:0;return e[o].startCell(s)}case J.SELECTION_DIRECTION.LEFT:case J.SELECTION_DIRECTION.UP:{const o=i>0?i-1:e.length-1;return e[o].startCell(s)}default:throw new Error(`Invalid direction: ${s}`)}}static cellCount(e){return e.reduce((t,n)=>t+((n.endRow??NaN)-(n.startRow??NaN)+1)*((n.endColumn??NaN)-(n.startColumn??NaN)+1),0)}static rowCount(e){return e.reduce((t,n)=>t+(n.endRow??NaN)-(n.startRow??NaN)+1,0)}static columnCount(e){return e.reduce((t,n)=>t+(n.endColumn??NaN)-(n.startColumn??NaN)+1,0)}static containsCell(e,t,n){for(let s=0;s<e.length;s+=1)if(e[s].containsCell(t,n))return!0;return!1}static forEachCell(e,t,n=J.SELECTION_DIRECTION.RIGHT){for(let s=0;s<e.length;s+=1)e[s].forEach(t,n)}constructor(e,t,n,s){this.startColumn=e,this.startRow=t,this.endColumn=n,this.endRow=s}equals(e){return this.startColumn===e.startColumn&&this.startRow===e.startRow&&this.endColumn===e.endColumn&&this.endRow===e.endRow}contains(e){return(this.startColumn==null||e.startColumn!=null&&this.startColumn<=e.startColumn)&&(this.startRow==null||e.startRow!=null&&this.startRow<=e.startRow)&&(this.endColumn==null||e.endColumn!=null&&this.endColumn>=e.endColumn)&&(this.endRow==null||e.endRow!=null&&this.endRow>=e.endRow)}containsCell(e,t){return e==null||t==null?!1:(this.startColumn==null||this.startColumn<=e)&&(this.endColumn==null||this.endColumn>=e)&&(this.startRow==null||this.startRow<=t)&&(this.endRow==null||this.endRow>=t)}touches(e){return J.isAxisRangeTouching(this.startRow,this.endRow,e.startRow,e.endRow)&&J.isAxisRangeTouching(this.startColumn,this.endColumn,e.startColumn,e.endColumn)}subtract(e){return J.subtractFromRange(this,e)}startCell(e=J.SELECTION_DIRECTION.DOWN){if(!J.isBounded(this))throw new Error("Cannot get the startCell of an unbounded range");switch(e){case J.SELECTION_DIRECTION.DOWN:case J.SELECTION_DIRECTION.RIGHT:return{column:this.startColumn,row:this.startRow};case J.SELECTION_DIRECTION.LEFT:case J.SELECTION_DIRECTION.UP:return{column:this.endColumn,row:this.endRow};default:throw new Error(`Invalid direction: ${e}`)}}nextCell(e,t,n){if(!J.isBounded(this))throw new Error("Bounded range required");if(e==null||t==null)throw new Error("Require a non-null cursor");const{startColumn:s,endColumn:i,startRow:o,endRow:l}=this;switch(n){case J.SELECTION_DIRECTION.DOWN:if(t<l)return{column:e,row:Math.max(t+1,o)};if(e<i)return{column:Math.max(e+1,s),row:o};break;case J.SELECTION_DIRECTION.UP:if(t>o)return{column:e,row:Math.min(t-1,l)};if(e>s)return{column:Math.min(e-1,i),row:l};break;case J.SELECTION_DIRECTION.RIGHT:if(e<i)return{column:Math.max(e+1,s),row:t};if(t<l)return{column:s,row:Math.max(t+1,o)};break;case J.SELECTION_DIRECTION.LEFT:if(e>s)return{column:Math.min(e-1,i),row:t};if(t>o)return{column:i,row:Math.min(t-1,l)};break;default:throw new Error(`Invalid direction: ${n}`)}return null}forEach(e,t=J.SELECTION_DIRECTION.RIGHT){let n=0,{column:s,row:i}=this.startCell(t);for(;s!=null&&i!=null;)e(s,i,n),n+=1,{column:s,row:i}=this.nextCell(s,i,t)??{}}}const Ie=J;function fb(c){return Array.isArray(c)&&c.length===2&&(c[0]===null||typeof c[0]=="number")&&(c[1]===null||typeof c[1]=="number")}function Ho(c){return fb(c)&&c[0]!=null&&c[1]!=null}function bl(c){return c?.href!==void 0}class O{static PIXELS_PER_LINE=100/3;static getGridPointFromXY(e,t,n){const s=O.getColumnAtX(e,n),i=O.getRowAtY(t,n),o=O.getColumnHeaderDepthAtY(t,n);return{x:e,y:t,row:i,column:s,columnHeaderDepth:o}}static getCellInfoFromXY(e,t,n){const{row:s,column:i}=O.getGridPointFromXY(e,t,n),{allColumnWidths:o,allRowHeights:l,allColumnXs:a,allRowYs:d,modelColumns:h,modelRows:u}=n,m=s!==null?u.get(s):null,g=i!==null?h.get(i):null,p=i!==null?a.get(i):null,C=s!==null?d.get(s):null,f=i!==null?o.get(i):null,S=s!==null?l.get(s):null;return{row:s,column:i,modelRow:m??null,modelColumn:g??null,left:p??null,top:C??null,columnWidth:f??null,rowHeight:S??null}}static getColumnHeaderDepthAtY(e,t){const n=O.getRowAtY(e,t),{columnHeaderHeight:s,columnHeaderMaxDepth:i}=t;if(n===null&&e<=s*i)return Ae(i-Math.ceil(e/s),0,i-1)}static iterateFloatingStart(e,t,n){for(let s=0;s<e&&s<t;s+=1){const i=n(s);if(i!==void 0)return i}}static iterateFloatingEnd(e,t,n){for(let s=0;s<e&&t-(e-s)>=0;s+=1){const i=n(t-(e-s));if(i!==void 0)return i}}static iterateFloating(e,t,n,s){const i=O.iterateFloatingStart(e,n,s);return i!==void 0?i:O.iterateFloatingEnd(t,n,s)}static iterateAllItems(e,t,n,s,i,o){const l=Math.max(e,n),a=Math.min(t,i-s-1);let d=O.iterateFloating(n,s,i,o);if(d!==void 0)return d;for(let h=l;h<=a;h+=1)if(d=o(h),d!==void 0)return d}static isInItem(e,t,n,s){const i=t.get(e)??0,o=n.get(e)??0;return i<=s&&s<=i+o}static getItemAtOffset(e,t,n,s,i,o,l,a=!1){const d=a?void 0:O.iterateFloating(n,s,t,h=>{if(O.isInItem(h,o,l,e))return h});if(!a&&d!==void 0)return d;for(let h=0;h<i.length;h+=1){const u=i[h];if(O.isInItem(u,o,l,e))return u}return null}static getColumnAtX(e,t,n=!1){const{columnCount:s,floatingLeftColumnCount:i,floatingRightColumnCount:o,visibleColumns:l,allColumnXs:a,allColumnWidths:d,gridX:h}=t;return e<h?null:this.getItemAtOffset(e-h,s,i,o,l,a,d,n)}static getRowAtY(e,t){const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i,visibleRows:o,allRowYs:l,allRowHeights:a,gridY:d}=t;return e<d?null:this.getItemAtOffset(e-d,i,n,s,o,l,a)}static getNextShownItem(e,t,n,s){let i=n.findIndex(o=>o===e)||0;for(i-=1;i!=null&&i>=0;){const o=n[i],l=t.get(o);if(l!=null&&s.get(l)!==0)return o;i-=1}return null}static getNextShownColumn(e,t){const{modelColumns:n,visibleColumns:s,userColumnWidths:i}=t;return O.getNextShownItem(e,n,s,i)}static getNextShownRow(e,t){const{modelRows:n,visibleRows:s,userRowHeights:i}=t;return O.getNextShownItem(e,n,s,i)}static getColumnSeparatorIndex(e,t,n,s){const{rowHeaderWidth:i,columnHeaderHeight:o,floatingColumns:l,floatingLeftWidth:a,visibleColumns:d,allColumnXs:h,allColumnWidths:u,columnHeaderMaxDepth:m}=n,{allowColumnResize:g,headerSeparatorHandleSize:p}=s;if(m*o<t||!g||p<=0)return null;const C=e-i,f=p*.5;let S=!1;for(let v=l.length-1;v>=0;v-=1){const b=l[v],T=h.get(b)??0,y=u.get(b)??0,E=y===0;if(!S||!E){let R=T+y;E?R+=f:S&&(R-=f);const x=R-f,D=R+f;if(x<=C&&C<=D)return b;S=E}}S=!1;for(let v=d.length-1;v>=0;v-=1){const b=d[v],T=h.get(b)??0,y=u.get(b)??0,E=y===0;if(T<a-y)return null;if(!S||!E){let R=T+y;E?R+=f:S&&(R-=f);const x=R-f,D=R+f;if(x<=C&&C<=D)return b;S=E}}return null}static isItemHidden(e,t){return t.get(e)===0}static isColumnHidden(e,t){const{allColumnWidths:n}=t;return O.isItemHidden(e,n)}static isFloatingRow(e,t){if(e==null)return!1;const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i}=t;return e<n||e>=i-s}static isFloatingColumn(e,t){if(e==null)return!1;const{floatingLeftColumnCount:n,floatingRightColumnCount:s,columnCount:i}=t;return e<n||e>=i-s}static getHiddenItems(e,t,n){if(!O.isItemHidden(e,t))return[];const s=[e],i=n.findIndex(o=>o===e);for(let o=i-1;o>=0;o-=1){const l=n[o];if(!O.isItemHidden(l,t))break;s.push(l)}return s}static getHiddenColumns(e,t){const{visibleColumns:n,allColumnWidths:s}=t;return O.getHiddenItems(e,s,n)}static getRowSeparatorIndex(e,t,n,s){const{rowHeaderWidth:i,columnHeaderHeight:o,visibleRows:l,allRowYs:a,allRowHeights:d}=n,{allowRowResize:h,headerSeparatorHandleSize:u}=s;if(i<e||!h||u<=0)return null;const m=t-o,g=u*.5;let p=!1;for(let C=l.length-1;C>=0;C-=1){const f=l[C],S=a.get(f)??0,v=d.get(f)??0,b=v===0;if(!p||!b){let T=S+v;b?T+=g:p&&(T-=g);const y=T-g,E=T+g;if(y<=m&&m<=E)return f;p=b}}return null}static isRowHidden(e,t){const{allRowHeights:n}=t;return O.isItemHidden(e,n)}static getHiddenRows(e,t){const{visibleRows:n,allRowHeights:s}=t;return O.getHiddenItems(e,s,n)}static moveItem(e,t,n){if(e===t)return[...n];const s=[...n],i=s[s.length-1];return i!=null&&!Ho(i.from)&&i.to===e?i.from===t?s.pop():s[s.length-1]={...i,to:t}:s.push({from:e,to:t}),s}static moveRange(e,t,n,s=!1){if(e[0]===e[1])return O.moveItem(e[0],t,n);let i=t;if(s&&e[0]<t&&(i-=e[1]-e[0]),e[0]===i)return[...n];const o=[...n],l=o[o.length-1];l!=null&&Ho(l.from)&&l.from[1]-l.from[0]===e[1]-e[0]&&l.to===e[0]?o[o.length-1]={...l,to:i}:o.push({from:e,to:i});const a=o[o.length-1];return Ho(a.from)&&a.from[0]===a.to&&o.pop(),o}static moveItemOrRange(e,t,n,s=!1){return Array.isArray(e)?O.moveRange(e,t,n,s):O.moveItem(e,t,n)}static applyItemMoves(e,t,n,s=!1){let i=[[e,t]];for(let o=s?n.length-1:0;s?o>=0:o<n.length;s?o-=1:o+=1){const{from:l,to:a}=n[o];let d=1,h;Ho(l)?(d=l[1]-l[0]+1,[h]=l):h=l;const u=s?a:h,m=u+d-1,g=s?h:a,p=g-u,C=[];for(let f=0;f<i.length;f+=1){const S=i[f][0]??Number.NEGATIVE_INFINITY,v=i[f][1]??Number.POSITIVE_INFINITY;let b;const T=[[S,u-1],[u,m],[m+1,v]].map(([y,E])=>[Math.max(y,S),Math.min(E,v)]).filter(([y,E])=>y<=E).map(y=>{const[E,R]=y;return u<=E&&m>=R?(b=[E+p,R+p],b):m<E?[E-d,R-d]:y}).map(y=>{const[E,R]=y;return g>E&&g<=R?[[E,g-1],[g+d,R+d]]:y===b?[y]:g<=E?[[E+d,R+d]]:[y]}).flat();C.push(...T)}i=C.map(([f,S])=>[Number.isFinite(f)?f:null,Number.isFinite(S)?S:null])}return i}static translateRange(e,t,n,s){const i=O.applyItemMoves(e.startColumn,e.endColumn,t,s),o=O.applyItemMoves(e.startRow,e.endRow,n,s),l=[];for(let a=0;a<i.length;a+=1){const d=i[a];for(let h=0;h<o.length;h+=1){const u=o[h];l.push(new Ie(d[0],u[0],d[1],u[1]))}}return l}static getModelIndex(e,t){return O.applyItemMoves(e,e,t,!0)[0][0]}static getModelIndexes(e,t){return e.map(n=>O.getModelIndex(n,t))}static getModelRangeIndexes(e,t,n){return O.applyItemMoves(e,t,n,!0)}static getModelRange(e,t=Fe,n=Fe){return O.translateRange(e,t,n,!0)}static getModelRanges(e,t=Fe,n=Fe){const s=[];for(let i=0;i<e.length;i+=1)s.push(...O.getModelRange(e[i],t,n));return s}static getVisibleRangeIndexes(e,t,n){return O.applyItemMoves(e,t,n,!1)}static getVisibleRange(e,t=Fe,n=Fe){return this.translateRange(e,t,n,!1)}static getVisibleRanges(e,t=Fe,n=Fe){const s=[];for(let i=0;i<e.length;i+=1)s.push(...O.getVisibleRange(e[i],t,n));return s}static getVisibleIndex(e,t){return O.applyItemMoves(e,e,t)[0][0]}static getVisibleIndexes(e,t){return e.map(n=>O.getVisibleIndex(n,t))}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return O.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){const t=O.getModifierKey();return e[t]}static checkColumnHidden(e,t){return t.get(e)===0}static checkAllColumnsHidden(e,t){return t.size===0?!1:e.every(n=>t.get(n)===0)}static getScrollDragBounds(e,t,n){const{gridX:s,gridY:i,width:o,height:l,floatingTopRowCount:a,floatingBottomRowCount:d,floatingLeftColumnCount:h,floatingRightColumnCount:u,floatingLeftWidth:m,floatingRightWidth:g,floatingTopHeight:p,floatingBottomHeight:C,columnCount:f,rowCount:S}=e;let v=s,b=i,T=o,y=l;return n!=null&&(n>h&&(v+=m),n<f-u&&(T-=g)),t!=null&&(t>a&&(b+=p),t<S-d&&(y-=C)),{x1:v,y1:b,x2:T,y2:y}}static getScrollDelta(e,t=1024,n=768,s=20,i=20){let{deltaX:o,deltaY:l}=e;return!O.isMacPlatform()&&e.shiftKey&&e.deltaX===0&&e.deltaY!==0&&(o=e.deltaY,l=e.deltaX),e?.deltaMode===WheelEvent.DOM_DELTA_PAGE?(o*=t,l*=n):e?.deltaMode===WheelEvent.DOM_DELTA_LINE&&(O.isMacPlatform()?(o=Math.round(o*s),l=Math.round(l*i)):(o=Math.round(o*this.PIXELS_PER_LINE),l=Math.round(l*this.PIXELS_PER_LINE))),{deltaX:o,deltaY:l}}static compareRanges(e,t){return e[0]==null||e[1]==null||t[0]==null||t[1]==null?0:e[0]!==t[0]?e[0]-t[0]:e[1]-t[1]}static mergeSortedRanges(e){const t=[];for(let n=0;n<e.length;n+=1){const s=e[n],i=s[0],o=s[1];n===0?t.push([i,o]):i-1<=t[t.length-1][1]?t[t.length-1][1]=Math.max(t[t.length-1][1],o):t.push([i,o])}return t}static translateTokenBox(e,t){const{x1:n,y1:s,x2:i,y2:o}=e,{gridX:l,gridY:a,width:d,height:h,verticalBarWidth:u,horizontalBarHeight:m}=t,g=Ae(l+n,l,d-u),p=Ae(l+i,l,d-u),C=Ae(a+s,a,h-m),f=Ae(a+o,a,h-m);return{x1:g,y1:C,x2:p,y2:f,token:e.token}}static findTokensWithProtocolInText(e){return Ac(e).filter(n=>n.type==="url"?/^https?:\/\//.test(n.value):!0)}}function Uo(c,e=Co.CACHE_SIZE,t=Math.floor(e/2)){if(c.size>e){const n=c.keys();for(;c.size>t;)c.delete(n.next().value)}}function zd(c,e,t,n,s){const i=new Map;let o=0;for(let l=0;l<c&&l<t;l+=1)i.set(l,o),o+=k(s,l);o=n;for(let l=0;l<e&&t-l-1>=0;l+=1)o-=k(s,t-l-1),i.set(t-l-1,o);return i}class Co{static CACHE_SIZE=1e4;static MAX_COLUMN_WIDTH=.8;initialRowHeights;initialColumnWidths;userColumnWidths;userRowHeights;calculatedColumnWidths;calculatedRowHeights;fontWidths;modelRows;modelColumns;movedRows;movedColumns;constructor({userColumnWidths:e=new Map,userRowHeights:t=new Map,calculatedColumnWidths:n=new Map,calculatedRowHeights:s=new Map,fontWidths:i=new Map,modelRows:o=new Map,modelColumns:l=new Map,movedRows:a=[],movedColumns:d=[],initialRowHeights:h=new Map,initialColumnWidths:u=new Map}={}){this.userColumnWidths=e,this.userRowHeights=t,this.calculatedRowHeights=s,this.calculatedColumnWidths=n,this.fontWidths=i,this.modelRows=o,this.modelColumns=l,this.movedRows=a,this.movedColumns=d,this.initialRowHeights=h,this.initialColumnWidths=u}getMetrics(e){const{left:t,top:n,leftOffset:s,topOffset:i,width:o,height:l,theme:a,model:d,movedRows:h,movedColumns:u,draggingColumn:m}=e,{rowHeight:g,rowHeaderWidth:p,rowFooterWidth:C,columnWidth:f,columnHeaderHeight:S,minScrollHandleSize:v,scrollBarSize:b}=a;h!==this.movedRows&&(this.movedRows=h,this.modelRows.clear()),u!==this.movedColumns&&(this.movedColumns=u,this.modelColumns.clear());const{columnCount:T,rowCount:y,floatingTopRowCount:E,floatingBottomRowCount:R,floatingLeftColumnCount:x,floatingRightColumnCount:D,columnHeaderMaxDepth:L}=d,M=this.getFirstRow(e),j=this.getFirstColumn(e),A=this.getGridX(e),W=this.getGridY(e),H=He(d)&&d.hasExpandableRows?this.calculateTreePaddingX(e):0,U=0,P=this.getVisibleRowHeights(e),Q=this.getVisibleColumnWidths(e,j,H),G=Array.from(P.keys()),ne=Array.from(Q.keys()),V=new Map([...P,...this.getFloatingRowHeights(e)]),z=new Map([...Q,...this.getFloatingColumnWidths(e)]),Z=this.getVisibleColumnXs(z,ne,s),oe=this.getVisibleRowYs(V,G,i),re=G.length>0?G[G.length-1]:n,q=ne.length>0?ne[ne.length-1]:t,ie=this.getBottomViewport(e,G,oe,V),fe=this.getRightViewport(e,ne,Z,z),Re=this.getFloatingTopHeight(e,V),xe=this.getFloatingBottomHeight(e,V),vt=this.getFloatingLeftWidth(e,z),Tt=this.getFloatingRightWidth(e,z),Gt=Array.from(z.values()),fn=Array.from(V.values()),Dt=Gt.reduce((Me,Yt)=>Me+Yt,0)-s,ye=fn.reduce((Me,Yt)=>Me+Yt,0)-i,dt=s+Dt+C,nt=i+ye,ft=o-A,Ft=l-W,Cn=this.getLastLeft(e,null,ft-C),zt=this.getLastLeft(e,null,ft-C-b),So=this.getLastTop(e,null,Ft-xe),xs=this.getLastTop(e,null,Ft-xe-b);let Kt=zt,Qn=xs;Cn===0&&So===0&&(Kt=0,Qn=0);const ti=Kt>0,Ni=ti?b:0,ni=Qn>0,si=ni?b:0,bo=A,wo=L*S,Jn=o-bo-si,Is=l-wo-Ni,ia=T===1?Jn/dt:(T-Kt)/T,vo=y===1?Is/nt:(y-Qn)/y,ki=ti?Ae(Jn*ia,v,Jn-1):0,Mi=ni?Ae(Is*vo,v,Is-1):0,Li=k(z,t,0),To=k(V,n,0),oa=Li>0?s/Li:0,la=To>0?i/To:0,aa=T===1?s/(dt-ft):(t+oa)/Kt,ra=y===1?i/(nt-Ft):(n+la)/Qn,da=ti?aa*(Jn-ki):0,Ds=ni?ra*(Is-Mi):0,Eo=[...Array(E).keys(),...[...Array(R).keys()].map(Me=>y-Me-1)],ii=new Map([...oe,...this.getFloatingRowYs(e,V,Math.floor(l-W-Ni))]),yo=[...Array(x).keys(),...[...Array(D).keys()].map(Me=>T-Me-1)],Fs=new Map([...Z,...this.getFloatingColumnXs(e,z,Math.floor(o-A-si))]),Ro=[];if(m)for(let Me=m.range[0];Me<=m.range[1];Me+=1)Ro.push(Me),z.has(Me)||z.set(Me,this.getVisibleColumnWidth(Me,e)),Fs.has(Me)||Fs.set(Me,0);const Oi=G.concat(Eo),Ai=ne.concat(yo).concat(Ro),xo=this.getModelRows(Oi,e),Io=this.getModelColumns(Ai,e),Do=this.getVisibleRowTreeBoxes(V,xo,e),ca=this.getTopVisible(e,ii,V,G),Fo=this.getLeftVisible(e,Fs,z,ne),No=Qn>0?this.getBottomVisible(e,ii,V,G,W):re,ko=Kt>0?this.getRightVisible(e,Fs,z,ne,A):q,{fontWidths:Mo,userColumnWidths:Lo,userRowHeights:Oo,calculatedRowHeights:ha,calculatedColumnWidths:Be}=this;return{rowHeight:g,rowHeaderWidth:p,rowFooterWidth:C,rowCount:y,columnWidth:f,columnCount:T,columnHeaderHeight:S,floatingTopRowCount:E,floatingBottomRowCount:R,floatingLeftColumnCount:x,floatingRightColumnCount:D,gridX:A,gridY:W,firstRow:M,firstColumn:j,treePaddingX:H,treePaddingY:U,left:t,top:n,bottom:re,right:q,topOffset:i,leftOffset:s,topVisible:ca,leftVisible:Fo,bottomVisible:No,rightVisible:ko,bottomViewport:ie,rightViewport:fe,width:o,height:l,maxX:Dt,maxY:ye,lastLeft:Kt,lastTop:Qn,barHeight:Is,barTop:wo,barWidth:Jn,barLeft:bo,handleHeight:Mi,handleWidth:ki,hasHorizontalBar:ti,hasVerticalBar:ni,verticalBarWidth:si,horizontalBarHeight:Ni,scrollX:da,scrollY:Ds,scrollableContentWidth:dt,scrollableContentHeight:nt,scrollableViewportWidth:ft,scrollableViewportHeight:Ft,visibleRows:G,visibleColumns:ne,visibleRowHeights:P,visibleColumnWidths:Q,floatingRows:Eo,floatingColumns:yo,allRows:Oi,allColumns:Ai,allRowHeights:V,allColumnWidths:z,floatingTopHeight:Re,floatingBottomHeight:xe,floatingLeftWidth:vt,floatingRightWidth:Tt,visibleRowYs:oe,visibleColumnXs:Z,allRowYs:ii,allColumnXs:Fs,visibleRowTreeBoxes:Do,modelRows:xo,modelColumns:Io,movedRows:h,movedColumns:u,fontWidths:Mo,userColumnWidths:Lo,userRowHeights:Oo,calculatedRowHeights:ha,calculatedColumnWidths:Be,columnHeaderMaxDepth:L}}getGridX(e){const{theme:t}=e,{rowHeaderWidth:n}=t;return n}getGridY(e){const{theme:t,model:n}=e,{columnHeaderHeight:s}=t,{columnHeaderMaxDepth:i}=n;return i*s}getVisibleHeight(e,t=this.getFloatingRowHeights(e)){const{height:n,theme:s}=e,{scrollBarSize:i}=s,o=this.getGridY(e),l=this.getFloatingBottomHeight(e,t),a=this.getFloatingTopHeight(e,t);return n-l-a-o-i}getVisibleWidth(e,t=this.getFloatingColumnWidths(e)){const{width:n,theme:s}=e,{scrollBarSize:i,rowFooterWidth:o}=s,l=this.getGridX(e),a=this.getFloatingRightWidth(e,t),d=this.getFloatingLeftWidth(e,t);return n-d-a-l-i-o}getFirstIndex(e,t,n){const s=e.size+1;for(let i=0;i<s;i+=1){const o=t(i,n);if(e.get(o)!==0)return i}return 0}getFirstColumn(e){return this.getFirstIndex(this.userColumnWidths,this.getModelColumn.bind(this),e)}getFirstRow(e){return this.getFirstIndex(this.userRowHeights,this.getModelRow.bind(this),e)}getLastLeft(e,t,n){const{model:s}=e,{columnCount:i,floatingRightColumnCount:o}=s;let l=Math.max(0,i-o-1);t!=null&&(l=t);let a=0;for(;l>=0;){const d=this.getVisibleColumnWidth(l,e);if(a+=d,a>=n)return Ae(l+1,0,t??i-1);l-=1}return 0}getLastTop(e,t,n){const{model:s}=e,{rowCount:i,floatingBottomRowCount:o}=s;let l=Math.max(0,i-o-1);t!=null&&(l=t);let a=0;for(;l>=0;){const d=this.getVisibleRowHeight(l,e);if(a+=d,a>=n)return Ae(l+1,0,i-1);l-=1}return 0}getTopForTopVisible(e,t){const n=this.getFloatingTopHeight(e);let s=t,i=0;for(;s>0&&i<n;)s-=1,i+=this.getVisibleRowHeight(s,e);return s}getTopForBottomVisible(e,t){const{height:n}=e,s=this.getGridY(e),i=this.getFloatingBottomHeight(e),o=n-s-i;return this.getLastTop(e,t,o)}getLeftForLeftVisible(e,t){const n=this.getFloatingLeftWidth(e);let s=t,i=0;for(;s>0&&i<n;)s-=1,i+=this.getVisibleColumnWidth(s,e);return s}getLeftForRightVisible(e,t){const{width:n}=e,s=this.getGridX(e),i=this.getFloatingRightWidth(e),o=n-s-i;return this.getLastLeft(e,t,o)}getFloatingRowHeights(e){const{model:t}=e,{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i}=t,o=new Map;for(let l=0;l<n&&l<i;l+=1)o.set(l,this.getVisibleRowHeight(l,e));for(let l=0;l<s&&i-l-1>=0;l+=1){const a=i-l-1;o.set(a,this.getVisibleRowHeight(a,e))}return o}getVisibleRowHeights(e){const{top:t,topOffset:n,height:s,model:i}=e;let o=0,l=t;const a=new Map,{rowCount:d}=i;for(;o<s+n&&l<d;){const h=this.getVisibleRowHeight(l,e);a.set(l,h),o+=h,l+=1}return a}getFloatingColumnWidths(e,t=this.getFirstColumn(e),n=this.calculateTreePaddingX(e)){const{model:s}=e,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:l}=s,a=new Map;for(let d=0;d<o&&d<i;d+=1)a.set(d,this.getVisibleColumnWidth(d,e,t,n));for(let d=0;d<l&&i-d-1>=0;d+=1){const h=i-d-1;a.set(h,this.getVisibleColumnWidth(h,e,t,n))}return a}getVisibleColumnWidths(e,t=this.getFirstColumn(e),n=this.calculateTreePaddingX(e)){const{left:s,leftOffset:i,width:o,model:l}=e;let a=0,d=s;const h=new Map,{columnCount:u}=l;for(;a<o+i&&d<u;){const m=this.getVisibleColumnWidth(d,e,t,n);h.set(d,m),a+=m,d+=1}return h}getFloatingColumnXs(e,t,n){const{model:s}=e,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:l}=s;return zd(o,l,i,n,t)}getVisibleColumnXs(e,t,n){const s=new Map;let i=-n;for(let o=0;o<t.length;o+=1){const l=t[o],a=k(e,l);s.set(l,i),i+=a}return s}getFloatingRowYs(e,t,n){const{model:s}=e,{floatingTopRowCount:i,floatingBottomRowCount:o,rowCount:l}=s;return zd(i,o,l,n,t)}getVisibleRowYs(e,t,n){const s=new Map;let i=-n;for(let o=0;o<t.length;o+=1){const l=t[o],a=k(e,l);s.set(l,i),i+=a}return s}getVisibleRowTreeBoxes(e,t,n){const s=new Map,{model:i,theme:o}=n,{treeDepthIndent:l,treeHorizontalPadding:a}=o;return He(i)&&i.hasExpandableRows&&e.forEach((d,h)=>{const u=k(t,h);if(i.isRowExpandable(u)){const m=i.depthForRow(u),g=m*l+a,p=(m+1)*l+a,C=0,f=d;s.set(h,{x1:g,y1:C,x2:p,y2:f})}}),s}getFloatingLeftWidth(e,t=this.getFloatingColumnWidths(e)){const{model:n}=e,{floatingLeftColumnCount:s}=n;let i=0;for(let o=0;o<s;o+=1)i+=k(t,o);return i}getFloatingRightWidth(e,t=this.getFloatingColumnWidths(e)){const{model:n}=e,{floatingRightColumnCount:s,columnCount:i}=n;let o=0;for(let l=0;l<s;l+=1)o+=k(t,i-l-1);return o}getFloatingTopHeight(e,t=this.getFloatingRowHeights(e)){const{model:n}=e,{floatingTopRowCount:s}=n;let i=0;for(let o=0;o<s;o+=1)i+=k(t,o);return i}getFloatingBottomHeight(e,t=this.getFloatingRowHeights(e)){const{model:n}=e,{floatingBottomRowCount:s,rowCount:i}=n;let o=0;for(let l=0;l<s;l+=1)o+=k(t,i-l-1);return o}getTopVisible(e,t,n,s){const i=this.getFloatingTopHeight(e,n);for(let o=0;o<s.length;o+=1){const l=s[o];if(k(t,l)>=i)return l}return 0}getLeftVisible(e,t,n,s){const i=this.getFloatingLeftWidth(e,n);for(let o=0;o<s.length;o+=1){const l=s[o];if(k(t,l)>=i)return l}return 0}getBottomVisible(e,t,n,s,i){const{height:o,theme:l}=e,{scrollBarSize:a}=l,d=this.getFloatingBottomHeight(e,n),h=o-i-a-d;for(let u=s.length-1;u>=0;u-=1){const m=s[u],g=k(t,m),p=k(n,m);if(g+p<=h)return m}return 0}getRightVisible(e,t,n,s,i){const{width:o,theme:l}=e,{scrollBarSize:a}=l,d=this.getFloatingRightWidth(e,n),h=o-i-a-d;for(let u=s.length-1;u>=0;u-=1){const m=s[u],g=k(t,m),p=k(n,m);if(g+p<=h)return m}return 0}getBottomViewport(e,t,n,s){const{height:i,theme:o}=e,{rowHeight:l}=o;return this.getLastIndexViewport(t,n,s,i,l)}getRightViewport(e,t,n,s){const{width:i,theme:o}=e,{columnWidth:l}=o;return this.getLastIndexViewport(t,n,s,i,l)}getLastIndexViewport(e,t,n,s,i){let o=0,l=0;return e.length>0&&(o=e[e.length-1],l=k(t,o)+k(n,o)),l<s&&(o+=Math.ceil((s-l)/i)),o}getVisibleItemSize(e,t,n){return t.get(e)??n()}getVisibleRowHeight(e,t){const n=this.getModelRow(e,t),s=this.calculateRowHeight(e,n,t);return this.getVisibleItemSize(n,this.userRowHeights,()=>{const i=this.initialRowHeights.get(n);return i!==void 0?i:s})}getVisibleColumnWidth(e,t,n=this.getFirstColumn(t),s=this.calculateTreePaddingX(t)){const i=this.getModelColumn(e,t),o=this.calculateColumnWidth(e,i,t,n,s);return this.getVisibleItemSize(i,this.userColumnWidths,()=>{const l=this.initialColumnWidths.get(i);return l!==void 0?l:o})}getModelRows(e,t){const n=new Map;for(let s=0;s<e.length;s+=1){const i=e[s],o=this.getModelRow(i,t);n.set(i,o)}return n}getModelRow(e,t){if(this.modelRows.has(e))return k(this.modelRows,e);const{movedRows:n}=t,s=O.getModelIndex(e,n);return this.modelRows.set(e,s),s}getModelColumns(e,t){const n=new Map;for(let s=0;s<e.length;s+=1){const i=e[s],o=this.getModelColumn(i,t);n.set(i,o)}return n}getModelColumn(e,t){if(this.modelColumns.has(e))return k(this.modelColumns,e);const{movedColumns:s}=t,i=O.getModelIndex(e,s);return this.modelColumns.set(e,i),i}calculateRowHeight(e,t,n){const{theme:s}=n,{autoSizeRows:i,rowHeight:o}=s;if(!i)return o;const l=this.calculatedRowHeights.get(t);return l??(this.calculatedRowHeights.set(t,Math.ceil(o)),Uo(this.calculatedRowHeights),o)}calculateColumnWidth(e,t,n,s=this.getFirstColumn(n),i=this.calculateTreePaddingX(n)){const{theme:o}=n,{autoSizeColumns:l,minColumnWidth:a}=o;if(!l){const{columnWidth:g}=o;return g}const d=this.calculateColumnHeaderWidth(t,n),h=this.calculateColumnDataWidth(t,n),u=this.calculatedColumnWidths.get(t);let m=Math.ceil(Math.max(d,h));return m=Math.max(a,m),u!=null&&u>m?m=u:(this.calculatedColumnWidths.set(t,m),Uo(this.calculatedColumnWidths)),e===s&&(m+=i),m}calculateColumnHeaderWidth(e,t){const{model:n,theme:s}=t,{headerFont:i,headerHorizontalPadding:o}=s,l=n.textForColumnHeader(e,0);if(l!==void 0&&l!==""){const a=this.getWidthForFont(i,t);return l.length*a+o*2}return o*2}calculateColumnDataWidth(e,t){const{top:n,height:s,width:i,model:o,theme:l}=t,{floatingTopRowCount:a,floatingBottomRowCount:d,rowCount:h}=o,{font:u,cellHorizontalPadding:m,rowHeight:g,rowHeaderWidth:p,rowFooterWidth:C,scrollBarSize:f}=l;let S=0;const v=this.getWidthForFont(u,t),b=s/g,T=Math.ceil(n+b);return O.iterateAllItems(n,T,a,d,h,y=>{const E=this.getModelRow(y,t),R=o.textForCell(e,E);if(R){const x=m*2;S=Math.max(S,R.length*v+x)}}),S=Math.max(Math.min(S,(i-p-f-C)*Co.MAX_COLUMN_WIDTH),m*2),S}calculateTreePaddingX(e){const{top:t,height:n,model:s,theme:i}=e,{rowHeight:o,treeDepthIndent:l}=i;if(!He(s)||!s.hasExpandableRows)return 0;let a=0;const d=n/o,h=Math.ceil(t+d);for(let u=t;u<=h;u+=1){const m=this.getModelRow(u,e),g=s.depthForRow(m);a=Math.max(a,l*(g+1))}return a}getWidthForFont(e,t){if(this.fontWidths.has(e))return k(this.fontWidths,e);const{context:n}=t;n.font=e;const s=n.measureText("8"),{width:i}=s;return this.fontWidths.set(e,i),this.fontWidths.set(n.font,i),i}setColumnWidth(e,t){const n=new Map(this.userColumnWidths);n.set(e,Math.ceil(t)),Uo(n),this.userColumnWidths=n}resetColumnWidth(e){const t=new Map(this.userColumnWidths);t.delete(e),this.userColumnWidths=t}setRowHeight(e,t){const n=new Map(this.userRowHeights);n.set(e,Math.ceil(t)),Uo(n),this.userRowHeights=n}resetRowHeight(e){const t=new Map(this.userRowHeights);t.delete(e),this.userRowHeights=t,this.calculatedRowHeights.delete(e)}}const Cb=Co,Sb=Object.freeze({allowColumnResize:!0,allowRowResize:!0,autoSelectRow:!1,autoSelectColumn:!1,autoSizeColumns:!0,autoSizeRows:!0,backgroundColor:"#000000",black:"#000000",white:"#ffffff",cellHorizontalPadding:5,headerHorizontalPadding:5,font:"12px Arial, sans serif",gridColumnColor:"#8f8f8f66",gridRowColor:"#8f8f8f66",headerBackgroundColor:"#222222",headerSeparatorColor:"#000000",headerSeparatorHoverColor:"#888888",headerSeparatorHandleSize:5,headerHiddenSeparatorSize:5,headerHiddenSeparatorHoverColor:"#8888FF",headerColor:"#d5d5d5",headerFont:"10px Arial, sans serif",columnHoverBackgroundColor:"#444444",selectedColumnHoverBackgroundColor:"#494949",rowBackgroundColors:"#333333 #222222",rowHoverBackgroundColor:"#444444",selectedRowHoverBackgroundColor:"#494949",minScrollHandleSize:50,scrollBarBackgroundColor:"#111111",scrollBarHoverBackgroundColor:"#333333",scrollBarCasingColor:"#000000",scrollBarCornerColor:"#000000",scrollBarColor:"#555555",scrollBarHoverColor:"#888888",scrollBarActiveColor:"#AAAAAA",scrollBarSize:12,scrollBarHoverSize:16,scrollBarCasingWidth:1,scrollSnapToColumn:!1,scrollSnapToRow:!1,selectionColor:"#4286f433",selectionOutlineColor:"#4286f4",selectionOutlineCasingColor:"#222222",scrollBarSelectionTick:!0,scrollBarSelectionTickColor:"#4286f433",scrollBarActiveSelectionTickColor:"#4286f480",shadowBlur:8,shadowColor:"#000000",textColor:"#ffffff",hyperlinkColor:"#4878ea",maxDepth:6,treeDepthIndent:10,treeHorizontalPadding:5,treeLineColor:"#888888",treeMarkerColor:"#cccccc",treeMarkerHoverColor:"#ffffff",rowHeight:20,columnWidth:100,minRowHeight:20,minColumnWidth:55,columnHeaderHeight:20,rowHeaderWidth:30,rowFooterWidth:0,headerResizeSnapThreshold:10,headerResizeHiddenSnapThreshold:8,allowColumnReorder:!0,allowRowReorder:!0,reorderOffset:2,floatingGridColumnColor:"#8f8f8f66",floatingGridRowColor:"#8f8f8f66",floatingRowBackgroundColors:"#393939 #292929",floatingDividerOuterColor:"#000000",floatingDividerInnerColor:"#cccccc"}),bb=Sb,wb=(c,e)=>{let t=!1;const n=Te(c,{...e,dispose:()=>{t||(t=!0,n.clear(),t=!1)}});return n},Bn=wb;function vb(c,e,t=6){const n=_a.hex.lab.raw(c);return n[0]=Math.max(n[0]-n[0]/t*e,0),`#${_a.lab.hex(n)}`}function Tb(c,e){const[t,n,s]=_a.hex.rgb(c);return`rgba(${t}, ${n}, ${s}, ${e})`}const Kd={colorWithAlpha:Tb,darkenForDepth:vb};class at{order;constructor(e=5e3){this.order=e}cursor=null;onDown(e,t,n){return!1}onMove(e,t,n){return!1}onDrag(e,t,n){return!1}onLeave(e,t,n){return!1}onClick(e,t,n){return!1}onContextMenu(e,t,n){return!1}onDoubleClick(e,t,n){return!1}onUp(e,t,n){return!1}onWheel(e,t,n){return!1}}class Eb extends at{draggingIndex;resizingItems=[];hiddenItems=[];targetSizes=new Map;dragOffset=0;onDown(e,t){const{metrics:n}=t,{model:s}=t.props,i=t.getTheme();if(!n)throw new Error("metrics not set");const o=this.getSeparator(e,n,s,i);if(o!=null){const l=o.index;return this.dragOffset=0,this.draggingIndex=l,this.resizingItems=[l],this.hiddenItems=this.getHiddenItems(l,n).reverse(),this.targetSizes.clear(),this.addTargetSize(n,l),this.updateCursor(n,l),this.updateSeparator(t,o),!0}return!1}onMove(e,t){const{metrics:n}=t,{model:s}=t.props,i=t.getTheme();if(!n)throw new Error("metrics not set");const o=this.getSeparator(e,n,s,i);return o!=null?(this.updateCursor(n,o.index),!0):!1}onDrag(e,t){if(this.draggingIndex==null)return!1;const n=e[this.pointProperty],{metricCalculator:s,metrics:i}=t;if(!i)throw new Error("metrics not set");const o=t.getTheme(),l=i[this.visibleOffsetProperty],a=i[this.marginProperty],d=i[this.calculatedSizesProperty],h=i[this.modelIndexesProperty],u=i[this.firstIndexProperty],m=i[this.treePaddingProperty],g=new Map;let p=this.resizingItems[this.resizingItems.length-1];for(;p!=null;){const C=k(l,p),f=n-a-C-this.dragOffset,S=k(h,p),v=this.targetSizes.get(S),b=this.resizingItems.length>1,T=this.hiddenItems.indexOf(p);let y=k(d,S);p===u&&(y+=m);let E=f;Math.abs(f-y)<=o.headerResizeSnapThreshold?E=y:v!==void 0&&f>v&&(b&&T!==0||T>0)?E=v:f<=o.headerResizeHiddenSnapThreshold&&(E=0),g.set(S,E),f<-o.headerResizeSnapThreshold&&E===0?T>=0&&b?(this.resizingItems.pop(),this.removeTargetSize(i,p),p=this.resizingItems[this.resizingItems.length-1],this.dragOffset-=this.targetSizes.get(k(h,p))??0):(p=this.getNextShownItem(p,i),p!==null&&(this.resizingItems.push(p),this.addTargetSize(i,p))):v!==void 0&&f>v+o.headerResizeSnapThreshold&&E===v?T>0?(this.dragOffset+=E,p=this.hiddenItems[T-1],this.resizingItems.push(p),this.addTargetSize(i,p)):b?(this.resizingItems.pop(),this.removeTargetSize(i,p),p=this.resizingItems[this.resizingItems.length-1]):p=null:p=null}return g.forEach((C,f)=>{const S=s[this.initialSizesProperty].get(f)??d.get(f);C===S?this.resetSize(s,f):this.setSize(s,f,C)}),this.updateCursor(i,this.draggingIndex),!0}onUp(e,t){return this.draggingIndex!=null&&(this.draggingIndex=void 0,this.resizingItems=[],this.hiddenItems=[],this.targetSizes.clear(),this.updateSeparator(t,null)),!1}onDoubleClick(e,t){const{metrics:n,metricCalculator:s}=t,{model:i}=t.props,o=t.getTheme();if(!n)throw new Error("metrics not set");const l=this.getSeparator(e,n,i,o);if(l!=null){const a=n[this.modelIndexesProperty],d=k(a,l.index),h=k(n[this.calculatedSizesProperty],d),u=s[this.initialSizesProperty].get(d);return h===u?this.resetSize(s,d):this.setSize(s,d,h),t.forceUpdate(),!0}return!1}updateCursor(e,t){const n=e[this.visibleSizesProperty];k(n,t)===0?this.cursor=this.hiddenCursor:this.cursor=this.defaultCursor}addTargetSize(e,t){const n=e[this.modelIndexesProperty],s=e[this.userSizesProperty],i=e[this.calculatedSizesProperty],o=t===0?e[this.treePaddingProperty]:0,l=k(n,t);let a=s.get(l);(a==null||a===0)&&(a=k(i,l)+o),this.targetSizes.set(l,a)}removeTargetSize(e,t){const n=e[this.modelIndexesProperty],s=k(n,t);this.targetSizes.delete(s)}}const ru=Eb;class Fr extends ru{static getColumnSeparator(e,t,n,s){if(!s.allowColumnResize)return null;const{x:i,y:o,columnHeaderDepth:l}=e,{modelColumns:a}=t,d=O.getColumnSeparatorIndex(i,o,t,s);return d==null||l==null||l>0?null:a.get(d)!=null?{index:d,depth:0}:null}hiddenCursor="e-resize";defaultCursor="col-resize";pointProperty="x";userSizesProperty="userColumnWidths";visibleOffsetProperty="visibleColumnXs";visibleSizesProperty="visibleColumnWidths";marginProperty="rowHeaderWidth";calculatedSizesProperty="calculatedColumnWidths";initialSizesProperty="initialColumnWidths";modelIndexesProperty="modelColumns";firstIndexProperty="firstColumn";treePaddingProperty="treePaddingX";getHiddenItems=O.getHiddenColumns;getNextShownItem=O.getNextShownColumn;setSize(e,t,n){e.setColumnWidth(t,n)}resetSize(e,t){e.resetColumnWidth(t)}updateSeparator(e,t){e.setState({draggingColumnSeparator:t,isDragging:t!==null})}getSeparator=Fr.getColumnSeparator}const du=Fr;class Mt{static DEFAULT_FONT_WIDTH=10;static DEFAULT_EDGE_RADIUS=2;static ACTIVE_CELL_BORDER_WIDTH=2;static truncate(e,t){return t<e.length?e.substr(0,t)+"…":e}static binaryTruncateToWidth(e,t,n,s=0,i=t.length,o){if(i>=t.length&&e.measureText(t).width<=n)return t;if(o!==void 0){const h=e.measureText(o).width;return o.repeat(Math.max(1,Math.floor(n/h)))}let l=s,a=Math.min(t.length-1,i),d=t;for(;a>=l;){const h=Math.ceil((a+l)/2),u=Mt.truncate(t,h);if(e.measureText(u).width<=n){if(d=u,l===h)break;l=h}else if(h===0){d=u;break}else a=h-1}return d}static truncateToWidth(e,t,n,s=Mt.DEFAULT_FONT_WIDTH,i){if(n<=0||t.length<=0)return"";const o=Math.min(Math.max(0,Math.floor(n/s/2)-5),t.length),l=Math.min(Math.ceil(n/s*2),t.length);return Mt.binaryTruncateToWidth(e,t,n,o,l,i)}drawCanvas(e){const{context:t}=e;t.save(),this.configureContext(t,e),this.drawBackground(t,e),this.drawGrid(t,e),this.drawHeaders(t,e),this.drawFooters(t,e),this.drawDraggingColumn(t,e),this.drawDraggingRow(t,e),this.drawScrollBars(t,e),t.restore()}configureContext(e,t){const{theme:n}=t;e.font=n.font,e.textBaseline="middle",e.lineCap="butt"}drawBackground(e,t){const{theme:n,metrics:s}=t,{width:i,height:o}=s;e.fillStyle=n.backgroundColor,e.fillRect(0,0,i,o)}drawGrid(e,t){const{metrics:n,draggingRow:s,draggingColumn:i}=t,{gridX:o,gridY:l}=n;e.translate(o,l),this.drawGridBackground(e,t,s==null&&i==null),this.drawCellContents(e,t),this.drawFloatingRows(e,t),this.drawFloatingColumns(e,t),e.translate(-o,-l)}drawFloatingRows(e,t){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=t,{floatingTopRowCount:l,floatingBottomRowCount:a,floatingRows:d,rowCount:h,visibleColumns:u,allRowYs:m,allRowHeights:g}=i;if(d.length!==0){o.floatingRowBackgroundColors&&this.drawRowStripesForRows(e,t,d,o.floatingRowBackgroundColors),n==null&&s==null&&this.drawFloatingMouseRowHover(e,t),this.drawGridLinesForItems(e,t,u,d,o.floatingGridColumnColor,o.floatingGridRowColor),this.drawCellBackgroundsForItems(e,t,u,d),this.drawFloatingBorders(e,t),l>0&&this.drawSelectedRanges(e,t,{top:0,bottom:l-1,maxY:k(m,l-1)+k(g,l-1)-.5}),a>0&&this.drawSelectedRanges(e,t,{top:h-a-1,bottom:h-1,minY:k(m,h-a)+.5,maxY:k(m,h-1)+k(g,h-1)-.5});for(let p=0;p<u.length;p+=1){const C=u[p];for(let f=0;f<d.length;f+=1){const S=d[f];this.drawCellContent(e,t,C,S)}}}}drawFloatingColumns(e,t){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=t,{floatingLeftColumnCount:l,floatingRightColumnCount:a,floatingLeftWidth:d,floatingRightWidth:h,floatingColumns:u,gridX:m,maxX:g,columnCount:p,visibleRows:C,allColumnXs:f,allColumnWidths:S,width:v,height:b}=i;if(u.length!==0){o.floatingRowBackgroundColors&&(this.drawRowStripesForRows(e,t,C,o.floatingRowBackgroundColors,0,d),this.drawRowStripesForRows(e,t,C,o.floatingRowBackgroundColors,v-m-h,g)),n==null&&s==null&&this.drawFloatingMouseRowHover(e,t),e.save(),e.beginPath(),e.rect(0,0,d,b),e.clip(),this.drawGridLinesForItems(e,t,u,C,o.floatingGridColumnColor,o.floatingGridRowColor),e.restore(),this.drawCellBackgroundsForItems(e,t,u,C),this.drawFloatingBorders(e,t),l>0&&this.drawSelectedRanges(e,t,{left:0,maxX:k(f,l-1)+k(S,l-1)}),a>0&&this.drawSelectedRanges(e,t,{left:p-a,right:p-1,minX:k(f,p-a)+.5,maxX:k(f,p-1)+k(S,p-1)});for(let T=0;T<u.length;T+=1){const y=u[T];for(let E=0;E<C.length;E+=1){const R=C[E];this.drawCellContent(e,t,y,R)}}}}drawFloatingBorders(e,t){const{metrics:n,theme:s}=t,{floatingTopRowCount:i,floatingBottomRowCount:o,floatingLeftColumnCount:l,floatingRightColumnCount:a,rowCount:d,columnCount:h,allRowYs:u,allColumnXs:m,allRowHeights:g,allColumnWidths:p,maxX:C,maxY:f}=n,{floatingDividerOuterColor:S,floatingDividerInnerColor:v}=s;if(e.lineWidth=3,e.beginPath(),e.strokeStyle=S,i>0){const b=k(u,i-1)+k(g,i-1)+.5;e.moveTo(0,b),e.lineTo(C,b)}if(o>0){const b=k(u,d-o)-.5;e.moveTo(0,b),e.lineTo(C,b)}if(l>0){const b=k(m,l-1)+k(p,l-1)+.5;e.moveTo(b,0),e.lineTo(b,f)}if(a>0){const b=k(m,h-a)-.5;e.moveTo(b,0),e.lineTo(b,f)}if(e.stroke(),e.beginPath(),e.lineWidth=1,e.strokeStyle=v,i>0){const b=k(u,i-1)+k(g,i-1)+.5;e.moveTo(0,b),e.lineTo(C,b)}if(o>0){const b=k(u,d-o)-.5;e.moveTo(0,b),e.lineTo(C,b)}if(l>0){const b=k(m,l-1)+k(p,l-1)+.5;e.moveTo(b,0),e.lineTo(b,f)}if(a>0){const b=k(m,h-a)-.5;e.moveTo(b,0),e.lineTo(b,f)}e.stroke()}drawGridBackground(e,t,n=!1){this.drawRowStripes(e,t),n&&(this.drawMouseColumnHover(e,t),this.drawMouseRowHover(e,t)),this.drawGridLines(e,t),this.drawCellBackgrounds(e,t);const{metrics:s}=t,{bottom:i,right:o,floatingBottomRowCount:l,floatingLeftColumnCount:a,floatingRightColumnCount:d,floatingTopRowCount:h,columnCount:u,rowCount:m,allRowHeights:g,allRowYs:p,allColumnXs:C,allColumnWidths:f,width:S,height:v}=s;this.drawSelectedRanges(e,t,{bottom:Math.min(i,m-l-1),right:Math.min(o,u-d-1),minX:a>0&&C.has(a+1)?k(C,a+1):-10,minY:h>0&&p.has(h+1)?k(p,h+1):-10,maxX:d>0&&C.has(u-d-1)?k(C,u-d-1)+k(f,u-d-1)-.5:S+10,maxY:l>0&&p.has(m-l-1)?k(p,m-l-1)+k(g,m-l-1)-.5:v+10})}drawRowStripes(e,t){const{metrics:n,theme:s}=t,{visibleRows:i}=n,{rowBackgroundColors:o}=s;o&&this.drawRowStripesForRows(e,t,i,o)}drawRowStripesForRows(e,t,n,s,i=0,o=t.metrics.maxX){const{theme:l,metrics:a,model:d}=t,{maxDepth:h,shadowBlur:u,shadowColor:m}=l,g=this.getCachedBackgroundColors(s,h),{allRowYs:p,allRowHeights:C}=a,f=new Map,S=[],v=[],b=(T,y)=>{const E=He(d)?d.depthForRow(T):0,R=g[T%g.length],x=R[Math.min(E,R.length-1)];if(f.has(x)||f.set(x,[]),f.get(x).push(T),y!=null){const D=He(d)?d.depthForRow(y):0;D<E?S.push(T):D>E&&v.push(y)}};for(let T=0;T<n.length;T+=1){const y=n[T],E=T>0?n[T-1]:void 0;b(y,E)}if(f.forEach((T,y)=>{e.fillStyle=y,e.beginPath();for(let E=0;E<T.length;E+=1){const R=T[E],x=k(p,R),D=k(C,R);e.rect(i,x,o,D)}e.fill()}),S.length>0){e.save();const T=this.getCachedColorWithAlpha(m,.15),y=this.getCachedColorWithAlpha(m,0),E=e.createLinearGradient(0,0,0,u);E.addColorStop(0,T),E.addColorStop(1,y),e.fillStyle=E;for(let R=0;R<S.length;R+=1){const x=S[R],D=k(p,x);e.translate(0,D),e.fillRect(i,0,o,u),e.translate(0,-D)}e.restore()}if(v.length>0){e.save();const T=this.getCachedColorWithAlpha(m,0),y=this.getCachedColorWithAlpha(m,.15),E=e.createLinearGradient(0,0,0,u);E.addColorStop(0,T),E.addColorStop(1,y),e.fillStyle=E;for(let R=0;R<v.length;R+=1){const x=v[R],D=k(p,x),L=k(C,x),M=D+L-u;e.translate(0,M),e.fillRect(i,0,o,u),e.translate(0,-M)}e.restore()}}drawMouseColumnHover(e,t){const{mouseX:n,mouseY:s,theme:i,metrics:o}=t;if(n==null||s==null)return;const l=O.getColumnAtX(n,o);if(l==null||i.columnHoverBackgroundColor==null)return;const{allColumnWidths:a,allColumnXs:d,maxY:h}=o;if(s>h)return;const u=k(d,l),m=k(a,l);e.fillStyle=i.columnHoverBackgroundColor,e.fillRect(u,0,m,h)}drawMouseRowHover(e,t){const{mouseX:n,mouseY:s,theme:i,metrics:o}=t;if(n==null||s==null)return;const{maxX:l}=o;if(n>l||i.rowHoverBackgroundColor==null)return;const a=O.getRowAtY(s,o);a!=null&&this.drawMouseRowHoverForRow(e,t,a)}drawFloatingMouseRowHover(e,t){const{mouseX:n,mouseY:s,theme:i,metrics:o}=t,{maxX:l,floatingTopRowCount:a,floatingBottomRowCount:d,rowCount:h,rowFooterWidth:u}=o;if(n==null||s==null||n>l+u||i.rowHoverBackgroundColor==null)return;const m=O.getRowAtY(s,o);m!=null&&(m<a||h-d<=m)&&this.drawMouseRowHoverForRow(e,t,m)}drawMouseRowHoverForRow(e,t,n){const{metrics:s,selectedRanges:i,theme:o}=t,{allRowHeights:l,allRowYs:a,maxX:d}=s,h=k(a,n),u=k(l,n);o.rowHoverBackgroundColor!=null&&(e.fillStyle=o.rowHoverBackgroundColor);for(let m=0;m<i.length;m+=1){const{startRow:g,endRow:p}=i[m];if(g!=null&&p!=null&&g<=n&&p>=n){o.selectedRowHoverBackgroundColor!=null&&(e.fillStyle=o.selectedRowHoverBackgroundColor);break}}e.fillRect(0,h,d,u)}drawGridLines(e,t){const{metrics:n,theme:s}=t,{visibleColumns:i,visibleRows:o}=n;this.drawGridLinesForItems(e,t,i,o,s.gridColumnColor,s.gridRowColor)}drawGridLinesForItems(e,t,n,s,i,o){i==null&&o==null||(e.lineWidth=1,e.beginPath(),i!=null&&(e.strokeStyle=i,this.drawGridLinesForColumns(e,t,n)),o!=null&&(e.strokeStyle=o,this.drawGridLinesForRows(e,t,s)),e.stroke())}drawGridLinesForColumns(e,t,n){const{metrics:s}=t,{allColumnXs:i,maxY:o}=s;for(let l=0;l<n.length;l+=1){const a=n[l],d=k(i,a)+.5;e.moveTo(d,0),e.lineTo(d,o)}}drawGridLinesForRows(e,t,n){const{metrics:s}=t,{allRowYs:i,maxX:o}=s,l=o;for(let a=0;a<n.length;a+=1){const d=n[a],h=k(i,d)+.5;e.moveTo(.5,h),e.lineTo(l-.5,h)}}drawCellBackgrounds(e,t){const{metrics:n}=t,{visibleColumns:s,visibleRows:i}=n;this.drawCellBackgroundsForItems(e,t,s,i)}drawCellBackgroundsForItems(e,t,n,s){e.save();for(let i=0;i<n.length;i+=1){const o=n[i];for(let l=0;l<s.length;l+=1){const a=s[l],d=l+1<s.length?s[l+1]:void 0;this.drawCellBackground(e,t,o,a,d)}}e.restore()}drawCellBackground(e,t,n,s,i){const{metrics:o,model:l,theme:a}=t,{firstColumn:d,modelColumns:h,modelRows:u,allColumnXs:m,allColumnWidths:g,allRowYs:p,allRowHeights:C}=o,f=k(u,s),S=k(h,n),v=l.backgroundColorForCell(S,f,a),b=n===d,T=He(l)&&l.hasExpandableRows;if(v!=null){const y=k(m,n)+1,E=k(p,s)+1,R=k(g,n)-1,x=k(C,s)-1;e.fillStyle=v,e.fillRect(y,E,R,x)}b&&T&&this.drawCellRowTreeDepthLines(e,t,s,i)}drawCellContents(e,t){const{metrics:n}=t,{visibleColumns:s}=n;for(let i=0;i<s.length;i+=1){const o=s[i];this.drawColumnCellContents(e,t,o)}}drawColumnCellContents(e,t,n){const{metrics:s}=t,{allColumnXs:i,allColumnWidths:o,visibleRows:l,height:a}=s,d=k(i,n),h=k(o,n);e.save(),e.beginPath(),e.rect(d,0,h,a),e.clip();for(let u=0;u<l.length;u+=1){const m=l[u];this.drawCellContent(e,t,n,m)}e.restore()}getTextRenderMetrics(e,t,n){const{metrics:s,model:i,theme:o}=e,{firstColumn:l,allColumnXs:a,allColumnWidths:d,allRowYs:h,allRowHeights:u,modelRows:m,modelColumns:g}=s,{cellHorizontalPadding:p,treeDepthIndent:C,treeHorizontalPadding:f}=o,S=k(m,n),v=k(g,t),b=i.textAlignForCell(v,S),T=k(a,t),y=k(h,n),E=k(d,t),R=k(u,n),x=t===l;let D=0;He(i)&&i.hasExpandableRows&&x&&(D=C*(i.depthForRow(n)+1)+f);const L=E-D;let M=T+p;const j=y+R*.5;return b==="right"?M=T+L-p:b==="center"&&(M=T+L*.5),M+=D,{width:L-p*2,x:M,y:j}}drawCellContent(e,t,n,s,i){const{metrics:o,model:l,theme:a}=t,{firstColumn:d,fontWidths:h,modelColumns:u,modelRows:m,allRowHeights:g}=o,{textColor:p}=a,C=k(g,s),f=k(m,s),S=k(u,n),v=i??l.textForCell(S,f),b=l.truncationCharForCell(S,f),T=n===d;if(v&&C>0){const y=l.textAlignForCell(S,f)||"left";e.textAlign=y;const E=l.colorForCell(S,f,a)||p;e.fillStyle=E,e.save();const{width:R,x,y:D}=this.getTextRenderMetrics(t,n,s),L=h.get(e.font)??Mt.DEFAULT_FONT_WIDTH,M=this.getCachedTruncatedString(e,v,R,L,b),j=l.tokensForCell(S,f,M.length);if(M){let A=0,W=0,H=x;const{actualBoundingBoxDescent:U}=e.measureText(M);for(;W<M.length;){const P=j[A],Q=W===P?.start?P:null,G=Q?.end??P?.start??M.length,ne=M.substring(W,G),{width:V}=e.measureText(ne),z=ne.endsWith("…")?e.measureText(ne.substring(0,ne.length-1)).width:V;Q!=null?(e.fillStyle=a.hyperlinkColor,e.fillText(ne,H,D),e.fillRect(H,D+U,z,1)):(e.fillStyle=E,e.fillText(ne,H,D)),H+=V,W=G,Q!=null&&(A+=1)}}e.restore()}T&&He(l)&&l.hasExpandableRows&&this.drawCellRowTreeMarker(e,t,s)}drawCellRowTreeMarker(e,t,n){const{metrics:s,model:i,mouseX:o,mouseY:l,theme:a}=t,{firstColumn:d,gridX:h,gridY:u,allColumnXs:m,allColumnWidths:g,allRowYs:p,allRowHeights:C,visibleRowTreeBoxes:f}=s,{treeMarkerColor:S,treeMarkerHoverColor:v}=a,b=k(m,d),T=k(g,d),y=k(p,n),E=k(C,n);if(!He(i)||!i.isRowExpandable(n))return;const R=k(f,n),x=o!=null&&l!=null&&o>=h+b&&o<=h+b+T&&l>=u+y&&l<=u+y+E?v:S;this.drawTreeMarker(e,t,b,y,R,x,i.isRowExpanded(n))}drawTreeMarker(e,t,n,s,i,o,l){const{x1:a,y1:d,x2:h,y2:u}=i,m=l?"⊟":"⊞",g=n+(a+h)*.5+.5,p=s+(d+u)*.5+.5;e.fillStyle=o,e.textAlign="center",e.fillText(m,g,p)}drawCellRowTreeDepthLines(e,t,n,s){const{metrics:i,model:o,theme:l}=t;if(!He(o))return;const a=o.depthForRow(n);if(a===0)return;const{firstColumn:d,allColumnXs:h,allRowYs:u,allRowHeights:m}=i,{treeDepthIndent:g,treeHorizontalPadding:p,treeLineColor:C}=l,f=k(h,d),S=k(u,n),v=k(m,n),b=s!==void 0?o.depthForRow(s):0,T=a>b?a-b:0;if(e.strokeStyle=C,e.lineWidth=1,a-T>0){e.beginPath();for(let y=0;y<a-T;y+=1){const E=f+y*g+g*.5+p+.5;e.moveTo(E,S),e.lineTo(E,S+v)}e.stroke()}if(T>0){e.beginPath();for(let y=a-T;y<a;y+=1){const E=f+y*g+g*.5+p+.5;e.moveTo(E,S),e.lineTo(E,S+Math.ceil(v/2)),e.moveTo(E-.5,S+Math.ceil(v/2)+.5),e.lineTo(E+g-.5,S+Math.ceil(v/2)+.5)}e.stroke()}}getCachedTruncatedString=Bn((e,t,n,s,i)=>Mt.truncateToWidth(e,t,n,s,i),{max:1e4});getCachedBackgroundColors=Bn((e,t)=>e.split(" ").map(n=>{const s=[];for(let i=0;i<t;i+=1)s.push(Kd.darkenForDepth(n,i,t));return s}),{max:1e3});getCachedColorWithAlpha=Bn((e,t)=>Kd.colorWithAlpha(e,t),{max:1e3});getCachedColorIsDark=Bn(e=>sh.isDark(e),{max:1e3});drawHeaders(e,t){const{theme:n}=t;e.font=n.headerFont,this.drawColumnHeaders(e,t),this.drawRowHeaders(e,t)}drawFooters(e,t){const{theme:n}=t;e.font=n.headerFont,this.drawRowFooters(e,t)}drawColumnHeaders(e,t){const{mouseX:n,mouseY:s,theme:i,metrics:o,draggingColumnSeparator:l,isDragging:a,model:d}=t,{columnHeaderHeight:h,floatingColumns:u,gridX:m,width:g,visibleColumns:p,allColumnWidths:C,allColumnXs:f,floatingLeftColumnCount:S,floatingLeftWidth:v,floatingRightWidth:b,modelColumns:T,columnHeaderMaxDepth:y}=o;if(h<=0)return;const{headerHiddenSeparatorSize:E,headerHiddenSeparatorHoverColor:R,headerSeparatorColor:x,headerSeparatorHoverColor:D}=i,L=h*.5,M=h*(y-1)+h*.5-L*.5,j=S>0;if(e.save(),this.drawColumnHeadersForRange(e,t,[p[0],p[p.length-1]],{minX:m+v,maxX:g-b}),j&&this.drawColumnHeadersForRange(e,t,[u[0],u[u.length-1]],{minX:m,maxX:m+v}),x){e.strokeStyle=x;const A=[...C.entries()].filter(([W,H])=>H===0).map(([W])=>W);e.beginPath(),e.fillStyle=x;for(let W=0;W<A.length;W+=1){const H=A[W],U=k(f,H),P=k(C,H),Q=m+U+P+.5-E*.5;e.rect(Q,M,E,L)}e.fill()}if(D){let{index:A,depth:W}=l??{};if(A==null&&n!=null&&s!=null){const U=du.getColumnSeparator(O.getGridPointFromXY(n,s,o),o,d,i);A=U?.index,W=U?.depth}let H;if(A==null)H=!1;else{const U=T.get(A),P=T.get(A+1);U==null||P==null?H=!1:H=d.textForColumnHeader(U,W)!==d.textForColumnHeader(P,W)}if(H&&A!=null&&W!=null&&(!a||l!=null)){e.strokeStyle=D;const U=k(f,A),P=k(C,A),Q=m+U+P+.5,G=p.indexOf(A),ne=G<p.length-1?p[G+1]:null,V=ne!=null?C.get(ne):null,z=P===0,Z=V!=null&&V===0;z?(e.strokeStyle=R,e.fillStyle=R,e.fillRect(Q,M,E*.5,L)):Z&&(e.fillStyle=D,e.fillRect(Q-E*.5,M,E*.5,L)),e.beginPath(),e.moveTo(Q,(y-W-1)*h),e.lineTo(Q,(y-W)*h-1),e.stroke()}}e.restore()}drawColumnHeadersForRange(e,t,n,s){const{model:i}=t,{columnHeaderMaxDepth:o}=i;if(o!==0)for(let l=0;l<=o;l+=1)this.drawColumnHeadersAtDepth(e,t,n,s,l)}drawColumnHeadersAtDepth(e,t,n,s,i){const{metrics:o,model:l,theme:a}=t,{modelColumns:d,allColumnXs:h,gridX:u,userColumnWidths:m,allColumnWidths:g,movedColumns:p}=o,{columnHeaderHeight:C,columnWidth:f}=a,{columnHeaderMaxDepth:S}=l,{minX:v,maxX:b}=s,T=b-v;if(S===0)return;const y=n[0],E=n[1];if(e.save(),e.translate(0,(S-i-1)*C),i===0){this.drawColumnHeader(e,t,"",v,b);for(let R=y;R<=E;R+=1)this.drawColumnHeaderAtIndex(e,t,R,s)}if(i>0){let R=y;for(;R<=E;){const{columnCount:x}=o,D=k(d,R),L=l.textForColumnHeader(D,i),M=l.colorForColumnHeader(D,i);let j=k(h,R)+u,A=j+k(g,R);if(L!=null){let W=R-1;for(;W>=0&&(A-j<T||j>v);){const Q=d.get(W)??O.getModelIndex(W,p);if(Q==null||l.textForColumnHeader(Q,i)!==L)break;const G=m.get(Q)??g.get(W)??f;j-=G,W-=1}let H=R+1;for(;H<x&&(A-j<T||A<b);){const Q=d.get(H)??O.getModelIndex(H,p);if(l.textForColumnHeader(Q,i)!==L)break;const G=m.get(Q)??g.get(H)??f;A+=G,H+=1}R=H-1;const U=A-j>=T;let P=j;U&&(A<b?P=A-T:j<v&&(P=v)),this.drawColumnHeader(e,t,L,P,Math.min(A-j,T),{backgroundColor:M??void 0},s)}R+=1}}e.restore()}drawColumnHeaderAtIndex(e,t,n,s){const{metrics:i,model:o}=t,{modelColumns:l,allColumnWidths:a,allColumnXs:d,gridX:h}=i,u=k(a,n),m=k(d,n)+h,g=k(l,n),p=o.textForColumnHeader(g);p!=null&&this.drawColumnHeader(e,t,p,m,u,{backgroundColor:o.colorForColumnHeader(g)??void 0},s)}drawColumnHeader(e,t,n,s,i,o,l){if(i<=0)return;const{metrics:a,theme:d}=t,{headerHorizontalPadding:h,columnHeaderHeight:u,headerBackgroundColor:m,headerColor:g,headerSeparatorColor:p,black:C,white:f}=d,{fontWidths:S,width:v}=a,b=S.get(e.font)??Mt.DEFAULT_FONT_WIDTH,y=(i-h*2)/b,{backgroundColor:E=m,separatorColor:R=p}=o??{};let{textColor:x=g}=o??{};try{const z=this.getCachedColorIsDark(E),Z=this.getCachedColorIsDark(x);z&&Z?x=f:!z&&!Z&&(x=C)}catch{}let{minX:D=0,maxX:L=v}=l??{};e.save(),e.rect(D,0,L-D,u),e.clip(),E!=null&&(e.fillStyle=E,e.fillRect(s,0,i,u)),R!=null&&(e.strokeStyle=R,e.beginPath(),s>0&&(e.moveTo(s+.5,0),e.lineTo(s+.5,u)),e.moveTo(s+i+.5,0),e.lineTo(s+i+.5,u),e.moveTo(s,u-.5),e.lineTo(s+i,u-.5),e.stroke()),e.beginPath(),e.rect(s,0,i,u),e.clip(),e.fillStyle=x;let M=n;y<=0?M="":M.length>y&&(M=`${M.substring(0,y-1)}…`);const j=M.length*b;let A=s+i*.5;const W=u*.5;D+=h,L-=h;const H=s+h,U=Ae(H,D,L),P=s+i-h,G=Ae(P,D,L)-U,ne=A-j*.5<D,V=A+j*.5>L;ne?j<G?A=D+j*.5:A=P-j*.5:V&&(j<G?A=L-j*.5:A=H+j*.5),e.textAlign="center",e.fillText(M,A,W),e.restore()}drawRowHeaders(e,t){const{mouseX:n,mouseY:s,metrics:i,theme:o,draggingRowSeparator:l}=t,{gridY:a,rowHeaderWidth:d,height:h,visibleRows:u,allRowHeights:m,allRowYs:g}=i;if(d<=0)return;const{headerBackgroundColor:p,headerColor:C,headerHiddenSeparatorSize:f,headerHiddenSeparatorHoverColor:S,headerSeparatorColor:v,headerSeparatorHoverColor:b}=o,T=d*.5,y=d*.5-T*.5;if(e.save(),e.beginPath(),e.fillStyle=p,e.fillRect(0,0,d,h),v){e.strokeStyle=v,e.beginPath(),e.moveTo(0,a+.5),e.lineTo(d,a+.5);const E=[];let R=!1;for(let x=0;x<u.length;x+=1){const D=u[x],L=k(g,D),M=k(m,D);if(M>0){const j=a+L+M+.5;e.moveTo(0,j),e.lineTo(d,j),R=!1}else R||(R=!0,E.push(D))}e.moveTo(d-.5,0),e.lineTo(d-.5,h),e.stroke(),e.beginPath(),e.fillStyle=v;for(let x=0;x<E.length;x+=1){const D=E[x],L=k(g,D),M=k(m,D),j=a+L+M+.5-f*.5;e.rect(y,j,T,f)}e.fill()}if(b){let{index:E=null}=l??{};if(E==null&&n!=null&&s!=null&&(E=O.getRowSeparatorIndex(n,s,i,o)),E!=null){e.strokeStyle=b;const R=k(g,E),x=k(m,E),D=a+R+x+.5,L=u.indexOf(E),M=L<u.length-1?u[L+1]:null,j=M!=null?m.get(M):null,A=x===0,W=j!=null&&j===0;A?(e.strokeStyle=S,e.fillStyle=S,e.fillRect(y,D,T,f*.5)):W&&(e.fillStyle=b,e.fillRect(y,D-f*.5,T,f*.5)),e.beginPath(),e.moveTo(.5,D),e.lineTo(d+.5,D),e.stroke()}}e.beginPath(),e.rect(0,a,d,h),e.clip(),e.fillStyle=C,e.textAlign="right";for(let E=0;E<u.length;E+=1){const R=u[E],x=k(m,R),D=k(g,R)+a;this.drawRowHeader(e,t,R,D,x)}e.restore()}drawRowHeader(e,t,n,s,i){if(i<=0)return;const{metrics:o,model:l,theme:a}=t,{modelRows:d,rowHeaderWidth:h}=o,u=k(d,n),m=h-a.cellHorizontalPadding,g=s+i*.5;e.fillText(l.textForRowHeader(u),m,g)}drawRowFooters(e,t){const{mouseX:n,mouseY:s,metrics:i,model:o,theme:l,draggingRowSeparator:a}=t,{gridY:d,gridX:h,maxX:u,modelRows:m,rowFooterWidth:g,height:p,verticalBarWidth:C,visibleRows:f,allRowHeights:S,allRowYs:v,width:b}=i;if(g<=0)return;const{cellHorizontalPadding:T,headerBackgroundColor:y,headerColor:E,headerHiddenSeparatorSize:R,headerHiddenSeparatorHoverColor:x,headerSeparatorColor:D,headerSeparatorHoverColor:L}=l,M=g*.5,j=g*.5-M*.5,A=Math.min(h+u,b-g-C);if(e.save(),e.beginPath(),e.fillStyle=y,e.fillRect(A,d,g,p),D){e.strokeStyle=D,e.beginPath(),e.moveTo(A,d+.5),e.lineTo(g,d+.5);const H=[];let U=!1;for(let P=0;P<f.length;P+=1){const Q=f[P],G=k(v,Q),ne=k(S,Q);if(ne>0){const V=d+G+ne+.5;e.moveTo(A+.5,V),e.lineTo(A+g-.5,V),U=!1}else U||(U=!0,H.push(Q))}e.moveTo(A+.5,d),e.lineTo(A+.5,p),e.stroke(),e.beginPath(),e.fillStyle=D;for(let P=0;P<H.length;P+=1){const Q=H[P],G=k(v,Q),ne=k(S,Q),V=d+G+ne+.5-R*.5;e.rect(A+j,V,M,R)}e.fill()}if(L){let{index:H=null}=a??{};if(H==null&&n!=null&&s!=null&&(H=O.getRowSeparatorIndex(n,s,i,l)),H!=null){e.strokeStyle=L;const U=k(v,H),P=k(S,H),Q=d+U+P+.5,G=f.indexOf(H),ne=G<f.length-1?f[G+1]:null,V=ne!=null?S.get(ne):null,z=P===0,Z=V!=null&&V===0;z?(e.strokeStyle=x,e.fillStyle=x,e.fillRect(j,Q,M,R*.5)):Z&&(e.fillStyle=L,e.fillRect(j,Q-R*.5,M,R*.5)),e.beginPath(),e.moveTo(A+.5,Q),e.lineTo(A+g+.5,Q),e.stroke()}}e.beginPath(),e.rect(A,d,g,p),e.clip(),e.fillStyle=E,e.textAlign="left";const W=A+T;for(let H=0;H<f.length;H+=1){const U=f[H],P=k(S,U);if(P>0){const Q=k(v,U)+d,G=k(m,U),ne=Q+P*.5;e.fillText(o.textForRowFooter(G),W,ne)}}e.restore()}drawSelectedRanges(e,t,n={}){const{cursorColumn:s,cursorRow:i,draggingRow:o,draggingColumn:l,editingCell:a,metrics:d,model:h,selectedRanges:u,theme:m}=t,{allColumnWidths:g,allColumnXs:p,allRowHeights:C,allRowYs:f,width:S,height:v}=d,{left:b=d.left,top:T=d.top,right:y=d.right,bottom:E=d.bottom,minY:R=-10,maxY:x=v+10,minX:D=-10,maxX:L=S+10}=n;if(u.length===0)return;const M=Ke(h)&&h.isEditable&&a==null&&o==null&&l==null&&s!=null&&i!=null&&p.has(s)&&f.has(i);if(M){const j=k(p,s),A=k(f,i),W=k(g,s),H=k(C,i);e.save(),e.beginPath(),e.rect(0,0,S,v),e.rect(j,A,W,H),e.clip("evenodd")}e.beginPath();for(let j=0;j<u.length;j+=1){const A=u[j],W=A.startColumn!==null?A.startColumn:b,H=A.startRow!==null?A.startRow:T,U=A.endColumn!==null?A.endColumn:y,P=A.endRow!==null?A.endRow:E;if(P>=T&&E>=H&&U>=b&&y>=W){const Q=W>=b&&p.has(W)?Math.round(k(p,W))+.5:D,G=H>=T&&f.has(H)?Math.max(Math.round(k(f,H))+.5,.5):R,ne=U<=y&&p.has(U)?Math.round(k(p,U)+k(g,U))-.5:L,V=P<=E&&f.has(P)?Math.round(k(f,P)+k(C,P))-.5:x;e.rect(Q,G,ne-Q,V-G)}e.fillStyle=m.selectionColor,e.fill(),e.save(),e.clip(),e.strokeStyle=m.selectionOutlineCasingColor,e.lineWidth=3,e.stroke(),e.restore(),e.strokeStyle=m.selectionOutlineColor,e.lineWidth=1,e.stroke()}M&&s!=null&&i!=null&&(e.restore(),this.drawActiveCell(e,t,s,i))}drawActiveCell(e,t,n,s,i=Mt.ACTIVE_CELL_BORDER_WIDTH){const{metrics:o,theme:l}=t,{allColumnWidths:a,allColumnXs:d,allRowHeights:h,allRowYs:u}=o,m=k(d,n),g=k(u,s),p=k(a,n),C=k(h,s);let f=m-i*.5,S=g-i*.5,v=p+i,b=C+i;f<=0&&(v+=f-1,f=1),S<=0&&(b+=S-1,S=1);const{lineWidth:T}=e;e.beginPath(),e.lineWidth=i,e.strokeStyle=l.selectionOutlineColor,this.drawRoundedRect(e,f,S,v,b),e.stroke(),e.lineWidth=T}drawRoundedRect(e,t,n,s,i,o=Mt.DEFAULT_EDGE_RADIUS){e.beginPath(),e.moveTo(t+o,n),e.lineTo(t+s-o,n),e.quadraticCurveTo(t+s,n,t+s,n+o),e.lineTo(t+s,n+i-o),e.quadraticCurveTo(t+s,n+i,t+s-o,n+i),e.lineTo(t+o,n+i),e.quadraticCurveTo(t,n+i,t,n+i-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n),e.closePath()}drawDraggingColumn(e,t){const{draggingColumn:n,metrics:s,mouseX:i,theme:o,model:l}=t;if(n==null||i==null)return;const{range:a,depth:d}=n,{gridX:h,gridY:u,allColumnXs:m,allColumnWidths:g,height:p,width:C,columnHeaderMaxDepth:f,columnHeaderHeight:S,movedColumns:v,modelColumns:b,floatingLeftWidth:T}=s,y=b.get(a[0])??O.getModelIndex(a[0],v),E=l.getColumnHeaderGroup(y,d);if(d>0&&!E)return;const[R,x]=a,D=k(m,R),M=k(m,x)+k(g,x)-D,j=n.left,{backgroundColor:A,font:W,headerFont:H,reorderOffset:U,shadowBlur:P,shadowColor:Q}=o,G=(f-d-1)*S;e.save(),e.translate(h,0),e.save(),e.beginPath(),e.rect(T,0,C,p),e.clip(),e.fillStyle=A,e.fillRect(D,G,M,p),e.restore(),e.translate(0,U),e.save(),e.shadowColor=Q,e.shadowBlur=P,e.fillStyle=A,e.fillRect(n.left,G+U,n.width,p),e.restore(),e.beginPath(),e.rect(n.left,G,n.width+1,p),e.clip(),e.translate(j-D,0),e.font=H;const ne=[];for(let V=n.range[0];V<=n.range[1];V+=1)ne.push(V);this.drawColumnHeaders(e,t),this.drawColumnHeadersForRange(e,t,[ne[0],ne[ne.length-1]],{minX:D,maxX:C}),e.translate(0,u),e.font=W,this.drawGridBackground(e,t);for(let V=R;V<=x;V+=1)this.drawColumnCellContents(e,t,V);e.restore()}drawDraggingRow(e,t){const{draggingRow:n,draggingRowOffset:s,metrics:i,mouseY:o,theme:l}=t;if(n==null||o==null)return;const{gridX:a,gridY:d,allRowYs:h,allRowHeights:u,width:m}=i,g=k(h,n),p=k(u,n)+1,{backgroundColor:C,font:f,headerFont:S,reorderOffset:v,shadowBlur:b,shadowColor:T}=l;e.save(),e.translate(0,d),e.fillStyle=C,e.fillRect(0,g,m,p),e.translate(a+v,o-g-d-(s??0)),e.save(),e.shadowColor=T,e.shadowBlur=b,e.fillStyle=C,e.fillRect(-a,g,m,p),e.restore(),e.beginPath(),e.rect(-a,g,m,p),e.clip(),e.font=f,this.drawGridBackground(e,t),this.drawCellContents(e,t),e.translate(-a,-d),e.font=S,this.drawRowHeaders(e,t),e.restore()}drawScrollBars(e,t){const{isDraggingHorizontalScrollBar:n,isDraggingVerticalScrollBar:s,isDragging:i,metrics:o,mouseX:l,mouseY:a,theme:d}=t;if(d.scrollBarSize<=0)return;const{width:h,height:u,handleHeight:m,handleWidth:g,scrollX:p,scrollY:C,hasHorizontalBar:f,hasVerticalBar:S,barWidth:v,barHeight:b,barLeft:T,barTop:y}=o,{scrollBarBackgroundColor:E,scrollBarHoverBackgroundColor:R,scrollBarCasingColor:x,scrollBarCornerColor:D,scrollBarColor:L,scrollBarHoverColor:M,scrollBarActiveColor:j,scrollBarSize:A,scrollBarHoverSize:W,scrollBarCasingWidth:H,scrollBarSelectionTick:U,scrollBarSelectionTickColor:P,scrollBarActiveSelectionTickColor:Q,autoSelectRow:G,autoSelectColumn:ne}=d,V=l!=null&&a!=null&&l<=h&&a<=u,z=s||S&&!n&&!i&&l!=null&&a!=null&&l>=h-W&&a>=y&&V,Z=n||f&&!s&&!i&&!z&&l!=null&&a!=null&&a>=u-W&&l>=T&&V,oe=Z?W:A,re=z?W:A;if(e.translate(T,y),f&&S&&(e.fillStyle=x,e.fillRect(h-T-A,u-y-A,A,A),e.fillStyle=D,e.fillRect(h-T-A+H,u-y-A+H,A-H,A-H)),f){const q=p,ie=u-y-oe;if(e.fillStyle=x,e.fillRect(0,ie,v,oe-H),e.fillStyle=Z?R:E,e.fillRect(0,ie+H,v,oe-H),n?e.fillStyle=j:Z?e.fillStyle=M:e.fillStyle=L,e.fillRect(q,ie+H,g,oe-H),!G&&U&&P!=null&&Q!=null){e.fillStyle=P;const{selectedRanges:fe,cursorColumn:Re}=t,{lastLeft:xe,columnCount:vt}=o,Gt=[...fe].filter(ye=>ye.startColumn!=null&&ye.endColumn!=null).map(ye=>[ye.startColumn,ye.endColumn]).sort(O.compareRanges),fn=O.mergeSortedRanges(Gt),Dt=ye=>ye<=xe?ye/xe*(v-g):v-g+(ye-xe)/(vt-xe)*g;for(let ye=0;ye<fn.length;ye+=1){const dt=fn[ye],nt=dt[0],ft=dt[1];if(nt!=null&&ft!=null&&(nt!==Re||ft!==Re)){const Ft=Dt(nt),Cn=Math.max(1,Math.round(Dt(ft+1)-Ft)),zt=oe-H;e.fillRect(Ft,ie+H+Math.round(zt/3),Cn,Math.round(zt/3))}}if(Re!=null){const ye=Dt(Re),dt=2,nt=oe-H;e.fillStyle=Q,e.fillRect(ye,ie+H,dt,nt)}}}if(S){const q=h-T-re,ie=C;if(e.fillStyle=x,e.fillRect(q,0,re-H,b),e.fillStyle=z?R:E,e.fillRect(q+H,0,re-H,b),s?e.fillStyle=j:z?e.fillStyle=M:e.fillStyle=L,e.fillRect(q+H,ie,re-H,m),!ne&&U&&P!=null&&Q!=null){const{selectedRanges:fe,cursorRow:Re}=t,{lastTop:xe,rowCount:vt}=o,Tt=ye=>ye<=xe?ye/xe*(b-m):b-m+(ye-xe)/(vt-xe)*m;e.fillStyle=P;const fn=[...fe].filter(ye=>ye.startRow!=null&&ye.endRow!=null).map(ye=>[ye.startRow,ye.endRow]).sort(O.compareRanges),Dt=O.mergeSortedRanges(fn);for(let ye=0;ye<Dt.length;ye+=1){const dt=Dt[ye],nt=dt[0],ft=dt[1];if(nt!=null&&ft!=null&&(nt!==Re||ft!==Re)){const Ft=Tt(nt),Cn=re-H,zt=Math.max(1,Math.round(Tt(ft+1)-Ft));e.fillRect(q+H+Math.round(Cn/3),Ft,Math.round(Cn/3),zt)}}if(Re!=null){const ye=Math.round(Tt(Re)),dt=re-H,nt=2;e.fillStyle=Q,e.fillRect(q+H,ye,dt,nt)}}}e.translate(-T,-y)}getTokenBoxesForVisibleCell(e,t,n){const{metrics:s,context:i,model:o,theme:l}=n;if(i==null||s==null)return Fe;const{modelRows:a,modelColumns:d}=s,h=k(a,t),u=k(d,e),m=o.textForCell(u,h),{width:g,x:p,y:C}=this.getTextRenderMetrics(n,e,t),{fontWidths:f}=s;i.save(),this.configureContext(i,n);const S=f?.get(i.font)??Mt.DEFAULT_FONT_WIDTH,v=o.truncationCharForCell(u,h),b=this.getCachedTruncatedString(i,m,g,S,v),{actualBoundingBoxAscent:T,actualBoundingBoxDescent:y}=i.measureText(b),E=T+y,R=o.tokensForCell(u,h,b.length);if(R.length===0)return i.restore(),Fe;const x=this.getCachedTokenBoxesForVisibleCell(b,R,l.font,"middle",E,i).map(D=>({x1:D.x1+p,y1:D.y1+(C-T),x2:D.x2+p,y2:D.y2+(C-T),token:D.token}));return i.restore(),x}getCachedTokenBoxesForVisibleCell=Bn((e,t,n,s,i,o)=>{const a=i,d=[];let h=0,u=0;for(let m=0;m<t.length;m+=1){const g=t[m],{start:p,end:C}=g,f=C>e.length?e.substring(p):g.value;u+=o.measureText(e.substring(h,p)).width;const S=o.measureText(f).width,v=u,b=v+S,T={x1:v,y1:0,x2:b,y2:a,token:g};d.push(T),h=C,u+=S}return d},{max:1e4})}const yb=Mt,Yd=100;class Rb extends at{startPoint;hasExtendedFloating=!1;timer;lastTriggerTime;dragBounds;onDown(e,t,n){const{x:s,y:i,column:o,row:l}=e,{metrics:a}=t;if(!a)throw new Error("metrics not set");const{gridX:d,gridY:h,maxX:u,maxY:m}=a,g=s-d,p=i-h;if(g<0||p<0||o==null&&g>u||l==null&&p>m)return!1;const C=O.isModifierKeyDown(n),f=n.shiftKey;C||(f?t.trimSelectedRanges():t.clearSelectedRanges());const S=t.getTheme(),{autoSelectRow:v,autoSelectColumn:b}=S;return(o!==null||!b)&&(l!==null||!v)&&(t.focus(),t.moveCursorToPosition(o,l,f,!1,f&&C)),this.startPoint=e,this.hasExtendedFloating=!1,this.dragBounds=O.getScrollDragBounds(a,l,o),!0}onDrag(e,t){if(this.startPoint===void 0)return!1;this.stopTimer();const{row:n,column:s}=this.startPoint,{x:i,y:o}=e;let{row:l,column:a}=e;const{metrics:d}=t;if(!d)throw new Error("metrics not set");const{left:h,lastLeft:u,top:m,lastTop:g,columnWidth:p,rowHeight:C}=d,f=O.getScrollDragBounds(d,n,s);let S=0,v=0;if(h<u&&(i<f.x1?S=i-f.x1:i>f.x2&&(S=i-f.x2)),m<g&&(o<f.y1?v=o-f.y1:o>f.y2&&(v=o-f.y2)),S!==0||v!==0)this.startTimer(t,e,S>0?Math.ceil(S/p):Math.floor(S/p),v>0?Math.ceil(v/C):Math.floor(v/C));else if(l!=null&&a!=null){const{floatingTopRowCount:b,floatingBottomRowCount:T,floatingLeftColumnCount:y,floatingRightColumnCount:E,columnCount:R,rowCount:x,bottom:D,right:L,topVisible:M,bottomVisible:j,leftVisible:A,rightVisible:W}=d;this.hasExtendedFloating||(n!==null&&n<b&&l>=b?(l=b,this.hasExtendedFloating=!0):n!==null&&n>=x-T&&l<x-T&&(l=x-T-1,this.hasExtendedFloating=!0),s!==null&&s<y&&a>=y?(a=y,this.hasExtendedFloating=!0):s!==null&&s>=R-E&&a<R-E&&(a=R-E-1,this.hasExtendedFloating=!0)),n!==null&&!O.isFloatingRow(n,d)&&O.isFloatingRow(l,d)&&(n>l&&l<m?l=M-1:n<l&&l>D&&(l=j+1)),s!==null&&!O.isFloatingColumn(s,d)&&O.isFloatingColumn(a,d)&&(s>a&&a<h?a=A-1:s<a&&a>L&&(a=W+1)),t.moveCursorToPosition(a,l,!0,!0)}return!0}onUp(e,t){return this.startPoint!==void 0&&(this.startPoint=void 0,this.dragBounds=void 0,this.stopTimer(),t.commitSelection()),!1}moveSelection(e,t,n,s){const{row:i,column:o}=t,{metrics:l}=e;if(!l)throw new Error("metrics not set");const{selectionEndRow:a,selectionEndColumn:d}=e.state;if(a==null||d==null)throw new Error("selection not set");const{rowCount:h,columnCount:u}=l,m=n<0&&o!=null?o:0,g=n>0&&o!=null?o:u-1,p=s<0&&i!=null?i:0,C=s>0&&i!=null?i:h-1;e.moveCursorToPosition(Math.min(Math.max(m,d+n),g),Math.min(Math.max(p,a+s),C),!0),this.lastTriggerTime=Date.now()}startTimer(e,t,n,s){this.stopTimer();const i=this.lastTriggerTime!=null?Yd-Math.min(Yd,Date.now()-this.lastTriggerTime):0;this.timer=setTimeout(()=>{this.moveSelection(e,t,n,s),this.startTimer(e,t,n,s)},i)}stopTimer(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0)}}const xb=Rb,qd=5,Ib=1e3/60,Vo=10;function ls(c,e,t,n){const{modelColumns:s,movedColumns:i,allColumnXs:o,columnCount:l,allColumnWidths:a,userColumnWidths:d,calculatedColumnWidths:h,floatingLeftWidth:u,maxX:m}=t;if(e==null||c==null||c>l||c<0)return null;const g=s.get(c)??O.getModelIndex(c,i),p=n.getColumnHeaderGroup(g,e),C=p!=null;let f,S,v;if(p!=null){const[b,T]=p.getVisibleRange(i);f=o.get(b)??u,S=(o.get(T)??m)+(a.get(T)??0),v=[b,T]}else{const b=o.get(c);if(b==null)return null;f=b,S=f+(a.get(c)??d.get(g)??h.get(g)??0),v=[c,c]}return{visibleIndex:c,modelIndex:g,left:f,right:S,width:S-f,isColumnGroup:C,range:v,depth:e}}class Db extends at{cursor=null;draggingOffset;initialOffset;initialGridPoint;scrollingInterval;scrollingDirection;draggingColumn=null;setScrollInterval(e,t){this.scrollingInterval!=null&&t===this.scrollingDirection||(this.scrollingDirection=t,this.scrollingInterval=window.setInterval(()=>{const{metrics:n}=e;if(!n)return;const{left:s,lastLeft:i,leftOffset:o,userColumnWidths:l,calculatedColumnWidths:a,movedColumns:d,allColumnWidths:h}=n;let u=s,m=o;if(t==="left")for(m-=Vo;m<0;){u-=1;const C=O.getModelIndex(s-1,d),f=l.get(C)??a.get(C);f===void 0?m=0:m+=f,u<0&&(m=0,u=0)}else{m+=Vo;let C=h.get(s);for(;C!==void 0&&m>C;){u+=1,m-=C;const f=O.getModelIndex(s+1,d);C=l.get(f)??a.get(f),u>i&&(m=0,u=i)}}const{mouseX:g,mouseY:p}=e.state;n==null||g==null||p==null||(this.moveDraggingColumn(g,e,t==="left"?-Vo:Vo),e.setState({left:u,leftOffset:m}),(t==="left"&&u===0&&o===0||t==="right"&&u===i)&&this.clearScrollInterval())},Ib))}clearScrollInterval(){this.scrollingDirection=void 0,window.clearInterval(this.scrollingInterval),this.scrollingInterval=void 0}onLeave(){return this.clearScrollInterval(),!1}onDown(e,t){const{model:n}=t.props,{x:s,column:i,columnHeaderDepth:o}=e,{metrics:l}=t;if(!l)throw new Error("Metrics not set");const a=ls(i,o,l,n);if(i==null||a==null||o==null||o>0&&!a.isColumnGroup)return!1;const{rowHeaderWidth:d}=l;return this.initialGridPoint=e,this.draggingColumn=null,this.cursor=null,a.modelIndex!=null&&o!=null&&n.isColumnMovable(a.modelIndex,o)&&(this.draggingOffset=s-a.left-d,this.initialOffset=this.draggingOffset),!1}onDrag(e,t,n){if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0)return!1;const{x:s,y:i}=e,{columnHeaderDepth:o}=this.initialGridPoint,{model:l}=t.props;let{draggingColumn:a}=this;const{metrics:d}=t;if(!d)throw new Error("Metrics not set");if(!a&&Math.abs(this.initialGridPoint.x-s)<qd&&Math.abs(this.initialGridPoint.y-i)<qd)return!1;if(a==null){const h=ls(this.initialGridPoint.column,o,d,l);if(!h||o==null||!l.isColumnMovable(h.modelIndex)||o>0&&!h.isColumnGroup||h.range[0]==null)return!1;a={range:h.range,depth:o,left:h.left,width:h.width};const u=ls(a.range[0],0,d,l),m=ls(a.range[1],0,d,l);if(!u||!m)return!1;this.draggingColumn=a,t.setState({draggingColumn:a,isDragging:!0})}return this.cursor="move",this.moveDraggingColumn(e.x,t,n.movementX),!0}moveDraggingColumn(e,t,n){if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0||this.draggingColumn==null||n===0)return;if(this.initialOffset!==this.draggingOffset){this.draggingOffset<this.initialOffset&&this.initialOffset<this.draggingOffset+n||this.draggingOffset>this.initialOffset&&this.initialOffset>this.draggingOffset+n?this.draggingOffset=this.initialOffset:this.draggingOffset+=n,this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},t.setState({draggingColumn:this.draggingColumn});return}const{depth:s}=this.draggingColumn,{model:i}=t.props,{movedColumns:o}=t.state,{metrics:l}=t;if(!l)throw new Error("Metrics not set");const{floatingLeftWidth:a,width:d,columnHeaderMaxDepth:h,allColumnXs:u}=l,m=n<0,g=ls(this.draggingColumn.range[0],s,l,i);if(!g)return;const p=e-this.draggingOffset,C=p+g.width;this.draggingColumn={...this.draggingColumn,left:p},t.setState({draggingColumn:this.draggingColumn});const f=ls(O.getColumnAtX(Ae(m?p:C,a,d),l,!0),s,l,i),S=i.getColumnHeaderParentGroup(g.modelIndex,g.depth);if(!f)return;if(S!==void 0){const R=S.getVisibleRange(o);if(f.visibleIndex<R[0]){const x=this.moveColumn(g,R[0],o);this.draggingOffset=e-(u.get(R[0])??0),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),t.setState({draggingColumn:this.draggingColumn,movedColumns:x});return}if(f.visibleIndex>R[1]){const x=this.moveColumn(g,R[1]-(g.range[1]-g.range[0]),o),{right:D=0}=ls(R[1],0,l,i)??{};this.draggingOffset=e-(D-g.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),t.setState({draggingColumn:this.draggingColumn,movedColumns:x});return}}if(!i.isColumnMovable(f.modelIndex)){let R=f.visibleIndex;if(m)for(R+=1;R<g.visibleIndex&&!i.isColumnMovable(O.getModelIndex(R,o));)R+=1;else for(R-=1;R>g.visibleIndex&&!i.isColumnMovable(O.getModelIndex(R,o));)R-=1;if(R!==g.visibleIndex){m||(R-=g.range[1]-g.range[0]);const D=this.moveColumn(g,R,o);t.setState({movedColumns:D,draggingColumn:this.draggingColumn})}const x=ls(R,0,l,i);m?this.draggingOffset=e-(x?.left??0):this.draggingOffset=e-((x?.right??0)-g.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},t.setState({draggingColumn:this.draggingColumn});return}if(p<=a?this.setScrollInterval(t,"left"):C>d?this.setScrollInterval(t,"right"):this.clearScrollInterval(),f.visibleIndex===g.visibleIndex||m&&g.visibleIndex<f.visibleIndex||!m&&g.visibleIndex>f.visibleIndex)return;const v=f.left+f.width*.5,b=i.getColumnHeaderParentGroup(g.modelIndex,g.depth);let T,y=(b?.depth??h)-1;for(;y>=0&&T===void 0;)T=i.getColumnHeaderGroup(f.modelIndex,y),y-=1;let E;m&&p<v&&(!T||f.visibleIndex===T.getVisibleRange(o)[0])&&(E=this.moveColumn(g,f.range[0],o)),!m&&C>v&&(!T||f.visibleIndex===T.getVisibleRange(o)[1])&&(E=this.moveColumn(g,f.range[1]-(g.range[1]-g.range[0]),o)),E&&(this.draggingColumn={...this.draggingColumn,left:p},t.setState({movedColumns:E,draggingColumn:this.draggingColumn}))}moveColumn(e,t,n){const s=e.isColumnGroup?O.moveRange(e.range,t,n):O.moveItem(e.visibleIndex,t,n),i=t-e.range[0],o=[e.range[0]+i,e.range[1]+i];return this.draggingColumn&&(this.draggingColumn={...this.draggingColumn,range:o}),s}onUp(e,t){return this.cursor=null,this.clearScrollInterval(),this.draggingOffset!=null?(this.draggingOffset=void 0,t.setState({draggingColumn:null,isDragging:!1}),!0):!1}}const Fb=Db;class Nr extends at{static getLeftWithOffsetFromRawLeft(e,t){const n=e.getTheme(),{metrics:s,metricCalculator:i}=e;if(!s)throw new Error("metrics not set");if(n.scrollSnapToColumn)return{left:Math.round(t),leftOffset:0};const o=Math.floor(t),l=t-o;let a=s.allColumnWidths.get(o);if(a==null){const h=e.getMetricState();a=i.getVisibleColumnWidth(o,h)}const d=a*l;return{left:o,leftOffset:d}}dragOffset;cursor="default";isInScrollBar(e,t){const n=t.getTheme(),{scrollBarSize:s,scrollBarHoverSize:i}=n,{metrics:o}=t;if(!o)throw new Error("metrics not set");const{x:l,y:a}=e,{barLeft:d,barWidth:h,height:u,hasHorizontalBar:m}=o;return m&&s>0&&a>=u-i&&a<u&&l>d&&l<d+h}getLeftWithOffset(e,t){const{metrics:n}=t;if(!n)throw new Error("metrics not set");const{x:s}=e,{barWidth:i,handleWidth:o,lastLeft:l,barLeft:a,columnCount:d,scrollableContentWidth:h,scrollableViewportWidth:u}=n,m=s-a,g=Ae((m-(this.dragOffset??0))/(i-o),0,1);if(d===1)return{left:0,leftOffset:g*(h-u)};const p=g*l;return Nr.getLeftWithOffsetFromRawLeft(t,p)}onDown(e,t){const{metrics:n}=t;if(!n)throw new Error("metrics not set");const{x:s}=e,{handleWidth:i,barLeft:o,scrollX:l}=n;if(!this.isInScrollBar(e,t))return!1;const a=s-o;if(a>=l&&a<=l+i)this.dragOffset=a-l,t.setState({isDraggingHorizontalScrollBar:!0});else{this.dragOffset=0;const{left:d,leftOffset:h}=this.getLeftWithOffset(e,t);t.setViewState({left:d,leftOffset:h,isDraggingHorizontalScrollBar:!0,isDragging:!0})}return!0}onDrag(e,t){if(this.dragOffset!=null){const{left:n,leftOffset:s}=this.getLeftWithOffset(e,t);return t.setViewState({left:n,leftOffset:s,isDraggingHorizontalScrollBar:!0,isDragging:!0}),!0}return!1}onMove(e,t){return this.isInScrollBar(e,t)}onUp(e,t){return this.dragOffset!==void 0&&(this.dragOffset=void 0,t.setState({isDraggingHorizontalScrollBar:!1,isDragging:!1})),this.isInScrollBar(e,t)}onClick(e,t){return this.isInScrollBar(e,t)}}const Nb=Nr;class kb extends at{cursor="move";draggingOffset;onDown(e,t){const{model:n}=t.props,{x:s,y:i,row:o}=e,{metrics:l}=t;if(!l)throw new Error("metrics not set");const{columnHeaderHeight:a,rowHeaderWidth:d,allRowYs:h}=l;if(s<=d&&o!==null&&n.isRowMovable(o)){const u=k(h,o);this.draggingOffset=i-u-a,t.setState({draggingRowOffset:this.draggingOffset})}return!1}onDrag(e,t){if(this.draggingOffset==null)return!1;const{model:n}=t.props;let{draggingRow:s}=t.state;const{mouseX:i,mouseY:o}=t.state;if(i==null||o==null)return!1;if(s==null){const{row:E}=t.getGridPointFromXY(i,o);if(E!=null&&!n.isRowMovable(E)||(s=E,t.setState({draggingRow:s,isDragging:!0}),s==null))return!1}const{metrics:l}=t;if(!l)throw new Error("metrics not set");const{top:a,lastTop:d,bottom:h,bottomVisible:u,rowCount:m,columnHeaderHeight:g,allRowHeights:p,allRowYs:C,height:f}=l;let S=g;if(a<s){const E=s-1;S=k(C,E)+k(p,E)*.5+g}let v=f;if(s<h){const E=s+1;v=k(C,E)+k(p,E)*.5+g}let{movedRows:b}=t.state;o<S&&s>0&&n.isRowMovable(s-1)?(b=O.moveItem(s,s-1,b),s-=1):v<o&&s<m-1&&n.isRowMovable(s+1)&&(b=O.moveItem(s,s+1,b),s+=1),t.setState({movedRows:b,draggingRow:s});const T=g+k(p,a)*.5,y=g+k(C,u)+k(p,u)*.5;return o<T&&a>0?t.setState({top:a-1}):o>y&&a<d&&t.setState({top:a+1}),!0}onUp(e,t){return this.draggingOffset!==void 0?(this.draggingOffset=void 0,t.setState({draggingRowOffset:null,draggingRow:null,isDragging:!1}),!0):!1}}const Mb=kb;class kr extends ru{static getRowSeparator(e,t,n,s){if(!s.allowRowResize)return null;const{x:i,y:o}=e,l=O.getRowSeparatorIndex(i,o,t,s);return l!=null?{index:l,depth:0}:null}hiddenCursor="s-resize";defaultCursor="row-resize";pointProperty="y";userSizesProperty="userRowHeights";visibleOffsetProperty="visibleRowYs";visibleSizesProperty="visibleRowHeights";marginProperty="columnHeaderHeight";calculatedSizesProperty="calculatedRowHeights";initialSizesProperty="initialRowHeights";modelIndexesProperty="modelRows";firstIndexProperty="firstRow";treePaddingProperty="treePaddingY";getHiddenItems=O.getHiddenRows;getNextShownItem=O.getNextShownRow;setSize(e,t,n){e.setRowHeight(t,n)}resetSize(e,t){e.resetRowHeight(t)}updateSeparator(e,t){e.setState({draggingRowSeparator:t,isDragging:t!==null})}getSeparator=kr.getRowSeparator}const Lb=kr;class wl extends at{static isInTreeBox(e,t){const{column:n,row:s,x:i,y:o}=e,{metrics:l}=t;if(!l)throw new Error("metrics not set");const{gridX:a,gridY:d,firstColumn:h,allColumnXs:u,allColumnWidths:m,allRowHeights:g,allRowYs:p,visibleRowTreeBoxes:C}=l;if(n===h&&s!=null&&C.get(s)!=null&&i>a&&o>d){const f=k(u,n),S=k(m,n),v=k(p,s),b=k(g,s);if(i>=a+f&&i<=a+f+S&&o>=d+v&&o<=d+v+b)return!0}return!1}onDown(e,t){return wl.isInTreeBox(e,t)}onClick(e,t,n){if(wl.isInTreeBox(e,t)){const{row:s}=e;if(s!==null)return t.toggleRowExpanded(s,O.isModifierKeyDown(n)),!0}return!1}}const Ya=wl;class Ob extends at{isInCorner(e,t){const n=t.getTheme(),{scrollBarSize:s}=n,{metrics:i}=t;if(!i)throw new Error("metrics not set");const{x:o,y:l}=e,{width:a,height:d,hasVerticalBar:h,hasHorizontalBar:u}=i;return s>0&&h&&u&&o>=a-s&&l>=d-s&&o<=a&&l<=d}onDown(e,t){return this.isInCorner(e,t)}onUp(e,t){return this.isInCorner(e,t)}onClick(e,t){return this.isInCorner(e,t)}}const Ab=Ob;class Mr extends at{static getTopWithOffsetFromRawTop(e,t){const n=e.getTheme(),{metrics:s,metricCalculator:i}=e;if(!s)throw new Error("metrics not set");if(n.scrollSnapToRow)return{top:Math.round(t),topOffset:0};const o=Math.floor(t),l=t-o;let a=s.allRowHeights.get(o);if(a==null){const h=e.getMetricState();a=i.getVisibleRowHeight(o,h)}const d=a*l;return{top:o,topOffset:d}}dragOffset;cursor="default";isInScrollBar(e,t){const n=t.getTheme(),{scrollBarSize:s,scrollBarHoverSize:i}=n,{metrics:o}=t;if(!o)throw new Error("metrics not set");const{x:l,y:a}=e,{barTop:d,barHeight:h,width:u,hasVerticalBar:m}=o;return m&&s>0&&l>=u-i&&l<u&&a>d&&a<d+h}getTopWithOffset(e,t){const{metrics:n}=t;if(!n)throw new Error("metrics not set");const{y:s}=e,{barHeight:i,handleHeight:o,lastTop:l,barTop:a,rowCount:d,scrollableContentHeight:h,scrollableViewportHeight:u}=n,m=s-a,g=Ae((m-(this.dragOffset??0))/(i-o),0,1);if(d===1)return{top:0,topOffset:g*(h-u)};const p=g*l;return Mr.getTopWithOffsetFromRawTop(t,p)}onDown(e,t){const{metrics:n}=t;if(!n)throw new Error("metrics not set");const{y:s}=e,{handleHeight:i,barTop:o,scrollY:l}=n;if(!this.isInScrollBar(e,t))return!1;const a=s-o;if(a>=l&&a<=l+i)this.dragOffset=a-l,t.setState({isDraggingVerticalScrollBar:!0});else{this.dragOffset=0;const{top:d,topOffset:h}=this.getTopWithOffset(e,t);t.setViewState({top:d,topOffset:h,isDraggingVerticalScrollBar:!0,isDragging:!0})}return!0}onMove(e,t){return this.isInScrollBar(e,t)}onDrag(e,t){if(this.dragOffset!=null){const{top:n,topOffset:s}=this.getTopWithOffset(e,t);return t.setViewState({top:n,topOffset:s,isDraggingVerticalScrollBar:!0,isDragging:!0}),!0}return!1}onUp(e,t){return this.dragOffset!==void 0&&(this.dragOffset=void 0,t.setState({isDraggingVerticalScrollBar:!1,isDragging:!1})),this.isInScrollBar(e,t)}onClick(e,t){return this.isInScrollBar(e,t)}}const _b=Mr;class Pb extends at{onDoubleClick({column:e,row:t},n){const{model:s}=n.props;return Ke(s)&&e!=null&&t!=null&&s.isEditableRange(Ie.makeCell(e,t))?(n.startEditing(e,t),!0):!1}}const jb=Pb;class Lr extends at{timeoutId;isHold=!1;isDown=!1;currentLinkBox;static HOLD_LENGTH=1e3;isHoveringLink(e,t){const{column:n,row:s,x:i,y:o}=e,{renderer:l,metrics:a}=t;if(n==null||s==null||a==null)return this.currentLinkBox=void 0,!1;if(this.currentLinkBox!=null){const{x1:u,y1:m,x2:g,y2:p}=this.currentLinkBox;if(i>=u&&i<=g&&o>=m&&o<=p)return!0}const d=t.updateRenderState(),h=l.getTokenBoxesForVisibleCell(n,s,d);for(let u=0;u<h.length;u+=1)if(bl(h[u].token)){const m=O.translateTokenBox(h[u],a),{x1:g,x2:p,y1:C,y2:f}=m;if(i>=g&&i<=p&&o>=C&&o<=f)return this.currentLinkBox=m,!0}return this.currentLinkBox=void 0,!1}setCursor(e,t){return this.isHoveringLink(e,t)?this.cursor="pointer":this.cursor=null,!1}onMove(e,t){return this.setCursor(e,t)}onDown(e,t,n){const s=this.isHoveringLink(e,t);return O.isModifierKeyDown(n)||n.shiftKey||!s?!1:(this.isDown=!0,this.timeoutId!=null&&clearTimeout(this.timeoutId),this.isHold=!1,this.timeoutId=setTimeout(()=>{this.isHold=!0;const{column:i,row:o}=e,{model:l}=t.props;t.clearSelectedRanges(),t.focus(),t.moveCursorToPosition(i,o),Ke(l)&&i!=null&&o!=null&&l.isEditableRange(Ie.makeCell(i,o))&&t.startEditing(i,o)},Lr.HOLD_LENGTH),!0)}onClick(e,t){return!this.isHoveringLink(e,t)||!this.isDown||this.currentLinkBox==null?(this.isDown=!1,this.isHold=!1,!1):(this.isHold||(this.timeoutId!=null&&clearTimeout(this.timeoutId),this.timeoutId=void 0,t.props.onTokenClicked(this.currentLinkBox?.token)),this.isHold=!1,this.isDown=!1,!0)}}const Hb=Lr;class Ub{order;constructor(e=5e3){this.order=e}onDown(e,t){return!1}}const ei=Ub;class Vb extends ei{onDown(e,t){switch(e.key){case"a":if(O.isModifierKeyDown(e))return t.selectAll(),!0;break;case"ArrowUp":return this.handleArrowMove(0,-1,e,t);case"ArrowDown":return this.handleArrowMove(0,1,e,t);case"ArrowRight":return this.handleArrowMove(1,0,e,t);case"ArrowLeft":return this.handleArrowMove(-1,0,e,t);case"k":case"K":return O.isModifierKeyDown(e)?!1:this.handlePageUp(e,t);case"j":case"J":return O.isModifierKeyDown(e)?!1:this.handlePageDown(e,t);case"h":case"H":return O.isModifierKeyDown(e)?!1:(e.shiftKey||t.clearSelectedRanges(),t.moveCursorToPosition(0,t.state.cursorRow,e.shiftKey),!0);case"l":case"L":{if(O.isModifierKeyDown(e))return!1;const{model:n}=t.props,{columnCount:s}=n;return e.shiftKey||t.clearSelectedRanges(),t.moveCursorToPosition(s-1,t.state.cursorRow,e.shiftKey),!0}case"PageDown":return this.handlePageDown(e,t);case"PageUp":return this.handlePageUp(e,t);case"Home":return e.shiftKey||t.clearSelectedRanges(),t.moveCursorToPosition(O.isModifierKeyDown(e)?t.state.cursorColumn:0,O.isModifierKeyDown(e)?0:t.state.cursorRow,e.shiftKey,!0,!0),!0;case"End":{const{model:n}=t.props,{columnCount:s,rowCount:i}=n;return e.shiftKey||t.clearSelectedRanges(),t.moveCursorToPosition(O.isModifierKeyDown(e)?t.state.cursorColumn:s-1,O.isModifierKeyDown(e)?i-1:t.state.cursorRow,e.shiftKey,!0,!0),!0}case"Escape":return t.clearSelectedRanges(),{preventDefault:!1,stopPropagation:!1};case"Enter":if(t.state.selectedRanges.length>0)return t.moveCursorInDirection(e.shiftKey?Ie.SELECTION_DIRECTION.UP:Ie.SELECTION_DIRECTION.DOWN),!0;break;case"Tab":if(t.state.selectedRanges.length>0)return t.moveCursorInDirection(e.shiftKey?Ie.SELECTION_DIRECTION.LEFT:Ie.SELECTION_DIRECTION.RIGHT),!0;break}return!1}handleArrowMove(e,t,n,s){const i=n.shiftKey,o=O.isModifierKeyDown(n);i?s.trimSelectedRanges():s.clearSelectedRanges();const{cursorRow:l,cursorColumn:a,selectionEndColumn:d,selectionEndRow:h}=s.state,u=i?d:a,m=i?h:l;if(o){const{model:g}=s.props,{columnCount:p,rowCount:C}=g,f=o&&i;let S=null,v=null;e<0?(S=0,v=m):e>0?(S=p-1,v=m):t<0?(S=u,v=0):t>0&&(S=u,v=C-1),S!=null&&v!=null&&s.moveCursorToPosition(S,v,i,!0,f)}else{if(!s.metrics)throw new Error("grid.metrics are not set");const{theme:g}=s.props,{autoSelectRow:p=!1,autoSelectColumn:C=!1}=g;if(p&&e!==0){const{lastLeft:f}=s.metrics;let{left:S}=s.state;S=Ae(S+e,0,f),s.moveCursorToPosition(S,l,i,!1),s.setViewState({left:S})}else if(C&&t!==0){const{lastTop:f}=s.metrics;let{top:S}=s.state;S=Ae(S+t,0,f),s.moveCursorToPosition(S,a,i,!1),s.setViewState({top:S})}else s.moveCursor(e,t,i)}return!0}handlePageUp(e,t){const n=e.shiftKey;n?t.trimSelectedRanges():t.clearSelectedRanges();const{cursorColumn:s,selectionEndRow:i}=t.state,o=i,l=s;if(o==null)return!1;const a=t.getMetricState(),{metricCalculator:d}=t,{bottomVisible:h,topVisible:u,hasHorizontalBar:m}=d.getMetrics(a);let g=o-(h-u);g-=m?0:1,g=Math.max(g,0);const p=Math.max(g-(o-u),0);return t.moveCursorToPosition(l,g,n,!1),t.setViewState({top:p}),!0}handlePageDown(e,t){const n=e.shiftKey;n?t.trimSelectedRanges():t.clearSelectedRanges();const{selectionEndRow:s,cursorColumn:i}=t.state,o=s,l=i;if(o===null)return!1;const a=t.getMetricState(),{metricCalculator:d}=t,{bottomVisible:h,topVisible:u,hasHorizontalBar:m,rowCount:g,lastTop:p}=d.getMetrics(a),C=g-1;let f=h-u+o;f+=m?0:1,f=Math.min(f,C);const S=Math.min(p,f-(o-u));return t.moveCursorToPosition(l,f,n,!1),t.setViewState({top:S}),!0}}const Bb=Vb;class $b extends ei{onDown(e,t){switch(e.key){case"Enter":case" ":return this.handleExpandKey(e,t)}return!1}handleExpandKey(e,t){const{selectedRanges:n}=t.state;if(n.length===1){const s=n[0];if(s.startRow===s.endRow&&s.startColumn===s.endColumn){if(!t.metrics)throw new Error("grid.metrics not set");const{model:i}=t.props,{startRow:o,startColumn:l}=s;if(o!=null){const a=t.getModelRow(o);if((l===0||l==null)&&He(i)&&i.isRowExpandable(a))return t.toggleRowExpanded(o),!0}}}return!1}}const Wb=$b;class Gb extends ei{onDown(e,t){if(O.isModifierKeyDown(e))return!1;const{model:n}=t.props,{cursorColumn:s,cursorRow:i}=t.state;if(s==null||i==null||!Ke(n)||!n.isEditableRange(Ie.makeCell(s,i)))return!1;const o=s,l=i;return o==null||l==null?!1:e.key.length===1?(t.startEditing(o,l,!0,[1,1],e.key),!0):e.key==="F2"?(t.startEditing(o,l),!0):e.key==="Backspace"?(t.startEditing(o,l,!0,void 0,""),!0):e.key==="Delete"?(t.setValueForCell(o,l,""),!0):!1}}const zb=Gb;function Kb(c){const e=[],t=c.querySelectorAll("tr");for(let n=0;n<t.length;n+=1){const i=t[n].querySelectorAll("td"),o=[];for(let l=0;l<i.length;l+=1){const a=i[l];o.push(a.textContent?.trim()??"")}e.push(o)}return e}function Yb(c){const e=[];return c.forEach(t=>{const n=t.textContent??"";n.length>0&&e.push(n.split(/\t|\u00a0\u00a0 \u00a0/))}),e}function qb(c){const e=c.querySelector("table");if(e!=null)return Kb(e);const t=c.textContent?.trim()??"";if(t.length>0){const{childNodes:n}=c,s=t.includes(" "),i=t.includes(" ");return s&&n.length!==0&&(n.length===1||n.length>1&&(n[0].textContent==null||!n[0].textContent.includes(" ")))?t.split(`
|
|
19
|
-
`).map(o=>o.split(" ")):n.length>1||i?Yb(c.childNodes):t}return null}class Xb extends ei{onDown(e,t){switch(e.key){case"v":if(O.isModifierKeyDown(e)){const n=document.createElement("div");document.body.appendChild(n),n.setAttribute("contenteditable","true"),n.setAttribute("style",'clip-path: "inset(50%)"; height: 1px; width: 1px; margin: -1px; overflow: hidden; padding 0; position: absolute;');const s=()=>{n.removeEventListener("input",s),n.remove(),t.focus();const i=qb(n);i!=null&&t.pasteValue(i)};return n.addEventListener("input",s),n.focus(),{preventDefault:!1,stopPropagation:!0}}break}return!1}}const Zb=Xb;const Qb=c=>{switch(c){case"ArrowDown":return mn.DOWN;case"ArrowUp":return mn.UP;case"ArrowLeft":return mn.LEFT;case"ArrowRight":return mn.RIGHT;default:return}};function Or({selectionRange:c=void 0,className:e="",disabled:t=!1,value:n="",isQuickEdit:s=!0,onChange:i=()=>{},onCancel:o=()=>{},onDone:l=()=>{},onContextMenu:a=()=>{},style:d={}}){const h=w.useRef(null),u=w.useRef(!1),[m]=w.useState(n),[g,p]=w.useState(!1),[C,f]=w.useState(s),[S,v]=w.useState(n);w.useEffect(function(){const{current:j}=h;j!=null&&(j.focus(),c?j.setSelectionRange(c[0],c[1]):j.setSelectionRange(j.value.length,j.value.length))},[c]);const b=w.useCallback(M=>{i(M)},[i]),T=w.useCallback(M=>{const{value:j}=M.target;v(j),p(!0),b(j)},[b,v,p]),y=w.useCallback(()=>{u.current=!0,g&&b(m),p(!1),o()},[m,g,o,b]),E=w.useCallback(()=>{f(!1)},[f]),R=w.useCallback((M,j=!1)=>{l(S,{direction:M,fillRange:j})},[l,S]),x=w.useCallback(()=>{u.current||R(null)},[u,R]),D=w.useCallback(M=>{switch(M.stopPropagation(),M.key){case"Escape":M.preventDefault(),y();break;case"Enter":if(M.preventDefault(),O.isModifierKeyDown(M))R(void 0,!0);else if(M.altKey){const j=`${S}
|
|
20
|
-
`;v(j),p(!0),b(j)}else R(M.shiftKey?mn.UP:mn.DOWN);break;case"Tab":M.preventDefault(),R(M.shiftKey?mn.LEFT:mn.RIGHT);break;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":C&&(M.preventDefault(),R(Qb(M.key)));break}},[y,R,C,v,p,b,S]),L=w.useCallback(M=>{a(M)},[a]);return r.jsx("textarea",{ref:h,className:K("grid-cell-input-field",e),value:S,onBlur:x,onChange:T,onKeyDown:D,onContextMenu:L,onClick:E,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",disabled:t,style:d})}Or.propTypes={selectionRange:B.arrayOf(B.number),className:B.string,disabled:B.bool,isQuickEdit:B.bool,value:B.string,onChange:B.func,onCancel:B.func,onDone:B.func,onContextMenu:B.func,style:B.shape({})};Or.defaultProps={selectionRange:null,className:"",disabled:!1,value:"",isQuickEdit:!0,onChange:()=>{},onCancel:()=>{},onDone:()=>{},onContextMenu:()=>{},style:{}};const Jb=ae.createContext({}),ew=Jb;class ms extends w.PureComponent{static contextType=ew;static defaultProps={canvasOptions:{alpha:!1},isStickyBottom:!1,isStickyRight:!1,isStuckToBottom:!1,isStuckToRight:!1,keyHandlers:Fe,mouseHandlers:Fe,movedColumns:Fe,movedRows:Fe,onError:()=>{},onSelectionChanged:()=>{},onMovedColumnsChanged:e=>{},onMoveColumnComplete:()=>{},onMovedRowsChanged:()=>{},onMoveRowComplete:()=>{},onViewChanged:()=>{},onTokenClicked:e=>{bl(e)&&window.open(e.href,"_blank","noopener,noreferrer")},stateOverride:{},theme:{autoSelectColumn:!1,autoSelectRow:!1}};static pixelsPerLine=100/3;static dragTimeout=1e3;static getTheme=he((e,t)=>({...bb,...e,...t}));static getScale(e){const t=window.devicePixelRatio||1,n=e,s=n.webkitBackingStorePixelRatio??n.mozBackingStorePixelRatio??n.msBackingStorePixelRatio??n.oBackingStorePixelRatio??n.backingStorePixelRatio??1;return t/s}static getCursorClassName(e){return e!=null&&e!==""?`grid-cursor-${e}`:null}renderer;metricCalculator;canvas;canvasContext;animationFrame;prevMetrics;metrics;renderState;documentCursor;dragTimer;keyHandlers;mouseHandlers;constructor(e){super(e),this.handleClick=this.handleClick.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.handleEditCellCancel=this.handleEditCellCancel.bind(this),this.handleEditCellChange=this.handleEditCellChange.bind(this),this.handleEditCellCommit=this.handleEditCellCommit.bind(this),this.handleDoubleClick=this.handleDoubleClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseDrag=this.handleMouseDrag.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleResize=this.handleResize.bind(this),this.handleWheel=this.handleWheel.bind(this);const{isStuckToBottom:t,isStuckToRight:n,metricCalculator:s,movedColumns:i,movedRows:o,renderer:l}=e;this.renderer=l||new yb,this.metricCalculator=s||new Cb,this.canvas=null,this.canvasContext=null,this.animationFrame=null,this.prevMetrics=null,this.metrics=null,this.renderState={},this.documentCursor=null,this.dragTimer=null,this.keyHandlers=[new zb(400),new Zb(450),new Bb(500),new Wb(900)],this.mouseHandlers=[new Lb(100),new du(200),new Mb(300),new Fb(400),new jb(450),new _b(500),new Nb(600),new Ab(700),new Ya(800),new Hb(825),new xb(900)],this.state={top:0,left:0,topOffset:0,leftOffset:0,draggingColumn:null,draggingRow:null,draggingRowOffset:null,draggingColumnSeparator:null,draggingRowSeparator:null,isDraggingHorizontalScrollBar:!1,isDraggingVerticalScrollBar:!1,isDragging:!1,mouseX:null,mouseY:null,movedColumns:i,movedRows:o,cursorRow:null,cursorColumn:null,selectionStartRow:null,selectionStartColumn:null,selectionEndRow:null,selectionEndColumn:null,selectedRanges:Fe,lastSelectedRanges:Fe,cursor:null,editingCell:null,isStuckToBottom:t,isStuckToRight:n}}componentDidMount(){this.initContext(),this.canvas?.addEventListener("wheel",this.handleWheel,{passive:!1}),window.addEventListener("resize",this.handleResize),this.updateCanvas();const{isStuckToBottom:e,isStuckToRight:t}=this.props;e&&this.scrollToBottom(),t&&this.scrollToRight()}componentDidUpdate(e,t){const{isStickyBottom:n,isStickyRight:s,movedColumns:i,movedRows:o,onMovedColumnsChanged:l,onMoveColumnComplete:a,onMovedRowsChanged:d,onMoveRowComplete:h}=this.props,{isStickyBottom:u,isStickyRight:m,movedColumns:g,movedRows:p}=e,{movedColumns:C,movedRows:f}=t,{draggingColumn:S,draggingRow:v,movedColumns:b,movedRows:T}=this.state;g!==i&&this.setState({movedColumns:i}),p!==o&&this.setState({movedRows:o}),C!==b&&l(b),t.draggingColumn!=null&&S==null&&a(b),f!==T&&d(T),t.draggingRow!=null&&v==null&&h(T),n!==u&&this.setState({isStuckToBottom:!1}),s!==m&&this.setState({isStuckToRight:!1}),this.updateMetrics(),this.requestUpdateCanvas(),this.checkStickyScroll(),this.validateSelection()&&this.checkSelectionChange(t)}componentWillUnmount(){this.animationFrame!=null&&cancelAnimationFrame(this.animationFrame),this.canvas?.removeEventListener("wheel",this.handleWheel),window.removeEventListener("mousemove",this.handleMouseDrag,!0),window.removeEventListener("mouseup",this.handleMouseUp,!0),window.removeEventListener("resize",this.handleResize),this.stopDragTimer()}getTheme(){const{theme:e}=this.props;return ms.getTheme(this.context,e)}getGridPointFromEvent(e){Wd(this.canvas);const t=this.canvas.getBoundingClientRect(),n=e.clientX-t.left,s=e.clientY-t.top;return this.getGridPointFromXY(n,s)}getGridPointFromXY(e,t){if(!this.metrics)throw new Error("metrics must be set");return O.getGridPointFromXY(e,t,this.metrics)}getMetricState(e=this.state){const t=this.getTheme(),{model:n,stateOverride:s}=this.props;if(!this.canvasContext||!this.canvas)throw new Error("Canvas and context must be defined to get metrics");const i=this.canvasContext,o=this.canvas.clientWidth,l=this.canvas.clientHeight,{left:a,top:d,leftOffset:h,topOffset:u,movedColumns:m,movedRows:g,isDraggingHorizontalScrollBar:p,isDraggingVerticalScrollBar:C,draggingColumn:f}=e;return{left:a,top:d,leftOffset:h,topOffset:u,width:o,height:l,context:i,theme:t,model:n,movedColumns:m,movedRows:g,isDraggingHorizontalScrollBar:p,isDraggingVerticalScrollBar:C,draggingColumn:f,...s}}getCachedKeyHandlers=he(e=>[...e,...this.keyHandlers].sort((t,n)=>t.order-n.order));getKeyHandlers(){const{keyHandlers:e}=this.props;return this.getCachedKeyHandlers(e)}getCachedMouseHandlers=he(e=>[...e,...this.mouseHandlers].sort((t,n)=>t.order-n.order));getMouseHandlers(){const{mouseHandlers:e}=this.props;return this.getCachedMouseHandlers(e)}getModelColumn(e){const t=this.metrics?.modelColumns?.get(e);if(t===void 0)throw new Error(`Unable to get ModelIndex for column ${e}`);return t}getModelRow(e){const t=this.metrics?.modelRows?.get(e);if(t===void 0)throw new Error(`Unable to get ModelIndex for row ${e}`);return t}toggleRowExpanded(e,t=!1){const n=this.getModelRow(e),{model:s}=this.props;He(s)&&s.isRowExpandable(n)&&s.setRowExpanded(n,!s.isRowExpanded(n),t),this.clearSelectedRanges(),this.commitSelection(),this.moveCursorToPosition(0,e),this.commitSelection(),this.setState({isStuckToBottom:!1})}scrollToBottom(){if(!this.metrics)return;const{bottomVisible:e,rowCount:t,top:n,lastTop:s}=this.metrics;(e<t-1&&e>0||n>s)&&this.setState({top:s})}scrollToRight(){if(!this.metrics)return;const{rightVisible:e,columnCount:t,left:n,lastLeft:s}=this.metrics;(e<t-1&&e>0||n>s)&&this.setState({left:s})}setSelectedRanges(e){const{model:t}=this.props,{columnCount:n,rowCount:s}=t,{cursorRow:i,cursorColumn:o,selectedRanges:l}=this.state;if(this.setState({selectedRanges:e,lastSelectedRanges:l}),e.length>0){const a=Ie.boundedRange(e[0],n,s);let d=i,h=o;a.containsCell(o,i)||({row:d,column:h}=a.startCell()),this.setState({selectionStartColumn:a.startColumn,selectionStartRow:a.startRow,selectionEndColumn:a.endColumn,selectionEndRow:a.endRow,cursorColumn:h,cursorRow:d})}}initContext(){const{canvas:e}=this,{canvasOptions:t}=this.props;if(!e)throw new Error("Canvas not set");this.canvasContext=e.getContext("2d",t)}requestUpdateCanvas(){this.animationFrame==null&&(this.animationFrame=requestAnimationFrame(()=>{this.animationFrame=null,this.updateCanvas()}))}updateCanvas(){this.updateCanvasScale(),this.updateMetrics(),this.updateRenderState();const{canvasContext:e,metrics:t,renderState:n}=this;N(e),N(t),N(n),this.renderer.configureContext(e,n);const{onViewChanged:s}=this.props;s(t),this.drawCanvas(t)}updateCanvasScale(){const{canvas:e,canvasContext:t}=this;if(!e)throw new Error("canvas not set");if(!t)throw new Error("canvasContext not set");if(!e.parentElement)throw new Error("Canvas has no parent element");const n=ms.getScale(t),s=e.parentElement.getBoundingClientRect(),i=Math.floor(s.width),o=Math.floor(s.height);e.style.width=`${i}px`,e.style.height=`${o}px`,e.width=i*n,e.height=o*n,t.scale(n,n)}updateScrollBounds(){if(!this.metrics)throw new Error("metrics not set");const{left:e,top:t}=this.state,{lastLeft:n,lastTop:s}=this.metrics;e>n&&this.setState({left:n,leftOffset:0}),t>s&&this.setState({top:s,topOffset:0})}checkStickyScroll(){if(this.metrics){if(this.prevMetrics){const{rowCount:e,columnCount:t,height:n,width:s}=this.metrics,{rowCount:i,columnCount:o,height:l,width:a}=this.prevMetrics;if(i!==e||n!==l){const{isStuckToBottom:d}=this.state;d&&this.scrollToBottom()}if(o!==t||s!==a){const{isStuckToRight:d}=this.state;d&&this.scrollToRight()}}this.prevMetrics=this.metrics}}updateMetrics(e=this.state){this.prevMetrics=this.metrics;const{metricCalculator:t}=this,n=this.getMetricState(e);return this.metrics=t.getMetrics(n),this.updateScrollBounds(),this.metrics}checkSelectionChange(e){const{selectedRanges:t}=e,{selectedRanges:n}=this.state;if(n!==t){const{onSelectionChanged:s}=this.props;s(n)}}validateSelection(){const{model:e}=this.props,{selectedRanges:t}=this.state,{columnCount:n,rowCount:s}=e;for(let i=0;i<t.length;i+=1){const o=t[i];if(o.endColumn!=null&&o.endColumn>=n||o.endRow!=null&&o.endRow>=s)return this.setState({selectedRanges:[],lastSelectedRanges:[]}),!1}return!0}clearSelectedRanges(){const{selectedRanges:e}=this.state;this.setState({selectedRanges:[],lastSelectedRanges:e})}trimSelectedRanges(){const{selectedRanges:e}=this.state;e.length>0&&this.setState({selectedRanges:e.slice(e.length-1)})}beginSelection(e,t){this.setState({selectionStartColumn:e,selectionStartRow:t,selectionEndColumn:e,selectionEndRow:t,cursorColumn:e,cursorRow:t})}moveSelection(e,t,n=!1,s=!1){this.setState(i=>{const{selectedRanges:o,selectionStartRow:l,selectionStartColumn:a}=i,{theme:d}=this.props,{autoSelectRow:h,autoSelectColumn:u}=d;if(n&&o.length>0){const C=o[o.length-1];let f=null,S=null,v=null,b=null;s?(f=h!==void 0&&h?null:Math.min(e??0,C.startColumn??0),S=u!==void 0&&u?null:Math.min(t??0,C.startRow??0),v=h!==void 0&&h?null:Math.max(e??0,C.endColumn??0),b=u!==void 0&&u?null:Math.max(t??0,C.endRow??0)):(f=C.startColumn,S=C.startRow,(a!=null||l!=null)&&((h===void 0||!h)&&(f=a),(u===void 0||!u)&&(S=l)),v=h!==void 0&&h?null:e,b=u!==void 0&&u?null:t);const T=Ie.makeNormalized(f,S,v,b);if(C.equals(T))return null;const y=[...o];return y[y.length-1]=T,{selectedRanges:y,selectionEndColumn:e,selectionEndRow:t}}const m=[...o],g=h!==void 0&&h?null:e,p=u!==void 0&&u?null:t;return m.push(Ie.makeNormalized(g,p,g,p)),{selectedRanges:m,selectionEndColumn:e,selectionEndRow:t}})}commitSelection(){this.setState(e=>{const{theme:t}=this.props,{autoSelectRow:n}=t,{selectedRanges:s,lastSelectedRanges:i,cursorRow:o,cursorColumn:l}=e;if(s.length===1&&(n!==void 0&&n?Ie.rowCount(s)===1:Ie.cellCount(s)===1)&&Ie.rangeArraysEqual(s,i))return{selectedRanges:[],lastSelectedRanges:[],cursorColumn:null,cursorRow:null};let a=s.slice();if(a.length>1){const u=a[a.length-1];for(let m=0;m<a.length-1;m+=1){const g=a[m];if(g.contains(u)){const p=g.subtract(u);a.pop(),a.splice(m,1),a=a.concat(p);break}}a=Ie.consolidate(a)}let d=l,h=o;if(!Ie.containsCell(a,l,o)){const{model:u}=this.props,{columnCount:m,rowCount:g}=u,p=Ie.nextCell(Ie.boundedRanges(s,m,g));p!=null?{column:d,row:h}=p:(d=null,h=null)}return a.length===0&&(d=null,h=null),{cursorRow:h,cursorColumn:d,selectedRanges:a,lastSelectedRanges:s}})}setFocusRow(e){if(!this.metrics||!this.prevMetrics)return;const{gridY:t,height:n,lastTop:s,userRowHeights:i,rowHeight:o}=this.metrics,l=n-t,a=Math.round(l/2)+(i.get(e)??o),d=this.getMetricState(),h=this.metricCalculator.getLastTop(d,e+1,a);this.setState({top:Math.min(s,h),selectedRanges:[new Ie(null,e,null,e)],isStuckToBottom:!1});const{cursorColumn:u}=this.state;this.moveCursorToPosition(u,e,!1,!1)}selectAll(){const{model:e,theme:t}=this.props,{autoSelectRow:n,autoSelectColumn:s}=t,i=s!==void 0&&s?null:0,o=s!==void 0&&s?null:e.rowCount-1,l=n!==void 0&&n?null:0,a=n!==void 0&&n?null:e.columnCount-1;this.setSelectedRanges([new Ie(l,i,a,o)])}moveCursor(e,t,n){const{cursorRow:s,cursorColumn:i,selectionEndColumn:o,selectionEndRow:l}=this.state,a=n?o:i,d=n?l:s;if(d===null||a===null){const{left:h,top:u}=this.state;this.moveCursorToPosition(h,u,n)}else{const{model:h}=this.props,{columnCount:u,rowCount:m}=h,g=Ae(a+e,0,u-1),p=Ae(d+t,0,m-1);this.moveCursorToPosition(g,p,n)}}moveCursorInDirection(e=Ie.SELECTION_DIRECTION.DOWN){const{model:t}=this.props,{columnCount:n,rowCount:s}=t,{cursorRow:i,cursorColumn:o,selectedRanges:l}=this.state,a=l.length>0?l:[Ie.makeCell(o,i)];let d=null;if(a.length===1&&Ie.cellCount(a)===1){const h=new Ie(0,0,n-1,s-1);d=h.nextCell(o,i,e)??h.startCell(e)}else d=Ie.nextCell(Ie.boundedRanges(a,n,s),o,i,e);if(d!=null){const{column:h,row:u}=d;this.setState({cursorColumn:h,cursorRow:u}),Ie.containsCell(l,h,u)||this.setState({selectedRanges:[Ie.makeCell(h,u)],selectionStartColumn:h,selectionStartRow:u,selectionEndColumn:h,selectionEndRow:u}),this.moveViewToCell(d.column,d.row)}}moveCursorToPosition(e,t,n=!1,s=!0,i=!1){n||this.beginSelection(e,t),this.moveSelection(e,t,n,i),s&&this.moveViewToCell(e,t)}moveViewToCell(e,t){if(!this.metrics)throw new Error("metrics not set");const{metricCalculator:n}=this,{bottomVisible:s,rightVisible:i,topVisible:o,leftVisible:l}=this.metrics,a=this.getMetricState(this.state);let{top:d,left:h,topOffset:u,leftOffset:m}=this.state;t!=null&&!O.isFloatingRow(t,this.metrics)&&(t<o?(d=n.getTopForTopVisible(a,t),u=0):t>s&&(d=n.getTopForBottomVisible(a,t),u=0)),e!=null&&!O.isFloatingColumn(e,this.metrics)&&(e<l?(h=n.getLeftForLeftVisible(a,e),m=0):e>i&&(h=n.getLeftForRightVisible(a,e),m=0)),this.setViewState({top:d,left:h,topOffset:u,leftOffset:m})}setViewState(e,t=!1){if(!this.metrics)throw new Error("metrics not set");const{isStickyBottom:n,isStickyRight:s}=this.props,{top:i,left:o}=e,{lastTop:l,lastLeft:a}=this.metrics;i!=null&&this.setState({isStuckToBottom:n&&i>=l}),o!=null&&this.setState({isStuckToRight:s&&o>=a}),this.setState(e),t&&this.forceUpdate()}startEditing(e,t,n=!1,s,i){const{model:o}=this.props;if(!Ke(o))throw new Error("model is not editable");const l=this.getModelColumn(e),a=this.getModelRow(t),d={column:e,row:t,selectionRange:s,value:i!==void 0?i:o.editValueForCell(l,a),isQuickEdit:n};this.setState({editingCell:d,cursorColumn:e,cursorRow:t}),this.moveViewToCell(e,t)}isValidForCell(e,t,n){const{model:s}=this.props,i=this.getModelColumn(e),o=this.getModelRow(t);return Ke(s)&&s.isValidForCell(i,o,n)}async pasteValue(e){const{model:t}=this.props,{movedColumns:n,movedRows:s,selectedRanges:i}=this.state;try{if(Gd(t),!t.isEditable||!i.every(m=>t.isEditableRange(m)))throw new ba("Can't paste in to read-only area.");if(i.length<=0)throw new ba("Select an area to paste to.");if(typeof e=="string"){const m=[],g=O.getModelRanges(i,n,s);Ie.forEachCell(g,(p,C)=>{m.push({column:p,row:C,text:e})}),await t.setValues(m);return}const o=e.length,l=e[0].length,{columnCount:a,rowCount:d}=t;let h=i;if(h.every(m=>Ie.cellCount([m])===1&&(m.startColumn??0)+l<=a&&(m.startRow??0)+o<=d)&&(h=h.map(m=>new Ie(m.startColumn,m.startRow,(m.startColumn??0)+l-1,(m.startRow??0)+o-1)),this.setSelectedRanges(h)),!h.every(m=>Ie.rowCount([m])===o&&Ie.columnCount([m])===l))throw new ba("Copy and paste area are not same size.");const u=[];h.forEach(m=>{for(let g=0;g<l;g+=1)for(let p=0;p<o;p+=1)u.push({column:(m.startColumn??0)+g,row:(m.startRow??0)+p,text:e[p][g]})}),await t.setValues(u)}catch(o){const{onError:l}=this.props;l(o instanceof Error?o:new Error(`${o}`))}}setValueForCell(e,t,n){const{model:s}=this.props;Gd(s);const i=this.getModelColumn(e),o=this.getModelRow(t);return s.isValidForCell(i,o,n)?(s.setValueForCell(i,o,n),!0):!1}setValueForRanges(e,t){const{model:n}=this.props,{movedColumns:s,movedRows:i}=this.state,o=O.getModelRanges(e,s,i);Ke(n)&&n.setValueForRanges(o,t)}isSelected(e,t){const{selectedRanges:n}=this.state;for(let s=0;s<n.length;s+=1){const i=n[s],o=i.startRow===null||i.startRow<=e&&e<=(i.endRow??0),l=i.startColumn===null||i.startColumn<=t&&t<=(i.endColumn??0);if(o&&l)return!0}return!1}addDocumentCursor(e=null){this.documentCursor!==ms.getCursorClassName(e)&&(this.documentCursor!=null&&document.documentElement.classList.remove(this.documentCursor),this.documentCursor=ms.getCursorClassName(e),this.documentCursor!=null&&document.documentElement.classList.add(this.documentCursor),document.documentElement.classList.add("grid-block-events"))}removeDocumentCursor(){this.documentCursor!=null&&(document.documentElement.classList.remove(this.documentCursor),document.documentElement.classList.remove("grid-block-events"),this.documentCursor=null)}startDragTimer(e){this.stopDragTimer();const t=new MouseEvent("custom",e.nativeEvent);this.dragTimer=setTimeout(()=>{this.handleMouseDrag(t)},ms.dragTimeout)}stopDragTimer(){this.dragTimer&&(clearTimeout(this.dragTimer),this.dragTimer=null)}drawCanvas(e=this.updateMetrics()){if(!this.canvas)throw new Error("canvas is not set");if(!this.canvasContext)throw new Error("context not set");const{renderer:t,canvasContext:n,renderState:s}=this;n.save(),t.drawCanvas(s),n.restore()}focus(){this.canvas?.focus()}isFocused(){return document.activeElement===this.canvas}handleClick(e){const t=this.getGridPointFromEvent(e),n=this.getMouseHandlers();for(let s=0;s<n.length;s+=1)if(n[s].onClick(t,this,e)!==!1){e.stopPropagation(),e.preventDefault();break}this.canvas?.focus()}handleContextMenu(e){const t=this.getGridPointFromEvent(e),n=this.getMouseHandlers();for(let s=0;s<n.length;s+=1)if(n[s].onContextMenu(t,this,e)!==!1){e.stopPropagation(),e.preventDefault();break}}handleKeyDown(e){const t=this.getKeyHandlers();for(let n=0;n<t.length;n+=1){const i=t[n].onDown(e,this);if(i!==!1){const o=i;(o?.stopPropagation??!0)&&e.stopPropagation(),(o?.preventDefault??!0)&&e.preventDefault();break}}}notifyMouseHandlers(e,t,n=!0,s=!1){const i=this.getGridPointFromEvent(t),o=this.getMouseHandlers();let l=null;for(let a=0;a<o.length;a+=1){const d=o[a],h=d[e]!=null&&d[e](i,this,t);if(h!==!1){d.cursor!=null&&({cursor:l}=d,s&&this.addDocumentCursor(l));const u=h;(u?.stopPropagation??!0)&&t.stopPropagation(),(u?.preventDefault??!0)&&t.preventDefault();break}}if(this.setState({cursor:l}),n){const{x:a,y:d}=i;this.setState({mouseX:a,mouseY:d})}}handleMouseDown(e){window.addEventListener("mousemove",this.handleMouseDrag,!0),window.addEventListener("mouseup",this.handleMouseUp,!0),!(e.button!=null&&e.button!==0)&&(this.notifyMouseHandlers("onDown",e),this.startDragTimer(e))}handleDoubleClick(e){this.notifyMouseHandlers("onDoubleClick",e)}handleMouseMove(e){this.notifyMouseHandlers("onMove",e)}handleMouseLeave(e){this.notifyMouseHandlers("onLeave",e,!1),this.setState({mouseX:null,mouseY:null})}handleMouseDrag(e){this.setState({isDragging:!0}),this.notifyMouseHandlers("onDrag",e,!0,!0),this.stopDragTimer()}handleMouseUp(e){window.removeEventListener("mousemove",this.handleMouseDrag,!0),window.removeEventListener("mouseup",this.handleMouseUp,!0),!(e.button!=null&&e.button!==0)&&(this.notifyMouseHandlers("onUp",e,!1),this.stopDragTimer(),this.removeDocumentCursor())}handleResize(){if(this.updateCanvas(),!this.metrics)throw new Error("metrics not set");this.forceUpdate()}handleWheel(e){if(this.notifyMouseHandlers("onWheel",e),e.defaultPrevented)return;const{metricCalculator:t,metrics:n}=this,s=this.getMetricState();if(!n)throw new Error("metrics not set");const{lastTop:i,lastLeft:o,columnCount:l,rowCount:a,scrollableContentWidth:d,scrollableViewportWidth:h,scrollableContentHeight:u,scrollableViewportHeight:m,hasHorizontalBar:g,hasVerticalBar:p}=n;let{top:C,left:f,topOffset:S,leftOffset:v}=n;const b=this.getTheme();let{deltaX:T,deltaY:y}=O.getScrollDelta(e,n.barWidth,n.barHeight,n.rowHeight,n.rowHeight);for(;g&&T!==0;){if(v+=T,T=0,l>1){if(v>0&&f>=o||v<0&&f<=0){v=0;break}}else{if(v<=0){v=0;break}const E=d-h;if(v>=E){v=E;break}}if(v>0){const E=n.allColumnWidths.get(f)??t.getVisibleColumnWidth(f,s);v>=E?(T=v-E,v=0,f+=1):b.scrollSnapToColumn&&l>1&&(v=0,f+=1)}else if(v<0){const E=n.allColumnWidths.get(f-1)??t.getVisibleColumnWidth(f-1,s);Math.abs(v)<=E&&b.scrollSnapToColumn&&l>1?(v=0,f-=1):(T=v+E,v=0,f-=1)}}for(;p&&y!==0;){if(S+=y,y=0,a>1){if(S>0&&C>=i||S<0&&C<=0){S=0;break}}else{if(S<=0){S=0;break}const E=u-m;if(S>=E){S=E;break}}if(S>0){const E=n.allRowHeights.get(C)??t.getVisibleRowHeight(C,s);S>=E?(y=S-E,S=0,C+=1):b.scrollSnapToRow&&a>1&&(S=0,C+=1)}else if(S<0){const E=n.allRowHeights.get(C-1)??t.getVisibleRowHeight(C-1,s);Math.abs(S)<=E&&b.scrollSnapToRow&&a>1?(S=0,C-=1):(y=S+E,S=0,C-=1)}}this.setViewState({top:C,left:f,leftOffset:v,topOffset:S}),e.stopPropagation(),e.preventDefault()}handleEditCellCancel(){this.setState({editingCell:null}),this.focus()}handleEditCellChange(e){this.setState(({editingCell:t})=>{try{return Wd(t),{editingCell:{...t,value:e}}}catch(n){const{onError:s}=this.props;return s(n instanceof Error?n:new Error(`${n}`)),null}})}handleEditCellCommit(e,{direction:t=mn.DOWN,fillRange:n=!1}={}){const{editingCell:s,selectedRanges:i}=this.state;if(!s)throw new Error("editingCell not set");const{column:o,row:l}=s;if(!this.isValidForCell(o,l,e)){t===null&&this.setState({editingCell:null});return}n?this.setValueForRanges(i,e):this.setValueForCell(o,l,e),t!==null&&this.moveCursorInDirection(t),this.setState({editingCell:null}),this.focus()}renderInputField(){const{model:e}=this.props,{editingCell:t}=this.state,{metrics:n}=this;if(t==null||n==null||!Ke(e))return null;const{selectionRange:s,value:i,isQuickEdit:o}=t,{column:l,row:a}=t,{gridX:d,gridY:h,allColumnXs:u,allRowYs:m,allColumnWidths:g,allRowHeights:p}=n,C=u.get(l),f=m.get(a),S=g.get(l),v=p.get(a),b=C!=null&&f!=null&&S!=null&&v!=null?{position:"absolute",left:d+C,top:h+f,width:S,height:v}:{opacity:0},T=this.getModelColumn(l),y=this.getModelRow(a),E=T!=null&&y!=null?{textAlign:e.textAlignForCell(T,y)}:void 0,R=e.isValidForCell(T,y,i);return r.jsx("div",{style:b,children:r.jsx(Or,{selectionRange:s,className:K({error:!R}),onCancel:this.handleEditCellCancel,onChange:this.handleEditCellChange,onDone:this.handleEditCellCommit,isQuickEdit:o,style:E,value:i},`${l},${a}`)})}updateRenderState(){if(!this.canvas)throw new Error("canvas is not set");if(!this.canvasContext)throw new Error("context not set");const{cursorColumn:e,cursorRow:t,draggingColumn:n,draggingColumnSeparator:s,draggingRow:i,draggingRowOffset:o,draggingRowSeparator:l,editingCell:a,isDraggingHorizontalScrollBar:d,isDraggingVerticalScrollBar:h,isDragging:u,mouseX:m,mouseY:g,selectedRanges:p}=this.state,{model:C,stateOverride:f}=this.props,{metrics:S}=this,v=this.canvasContext,b=this.getTheme(),T=this.canvas.clientWidth,y=this.canvas.clientHeight;return N(S),this.renderState={width:T,height:y,context:v,theme:b,model:C,metrics:S,mouseX:m,mouseY:g,selectedRanges:p,draggingColumn:n,draggingColumnSeparator:s,draggingRow:i,draggingRowOffset:o,draggingRowSeparator:l,editingCell:a,isDraggingHorizontalScrollBar:d,isDraggingVerticalScrollBar:h,isDragging:u,cursorColumn:e,cursorRow:t,...f},this.renderState}render(){const{cursor:e}=this.state;return r.jsxs(r.Fragment,{children:[r.jsx("canvas",{className:K("grid-canvas",ms.getCursorClassName(e)),ref:t=>{this.canvas=t},onClick:this.handleClick,onContextMenu:this.handleContextMenu,onDoubleClick:this.handleDoubleClick,onKeyDown:this.handleKeyDown,onMouseDown:this.handleMouseDown,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,tabIndex:0,children:"Your browser does not support HTML canvas. Update your browser?"}),this.renderInputField()]})}}const tw=ms,wa=5e3;class nw extends tm{get floatingTopRowCount(){return 0}get floatingBottomRowCount(){return 0}get floatingLeftColumnCount(){return 0}get floatingRightColumnCount(){return 0}get columnHeaderMaxDepth(){return 1}truncationCharForCell(e,t){}textAlignForCell(e,t){return"left"}colorForCell(e,t,n){return n.textColor}backgroundColorForCell(e,t,n){return null}colorForColumnHeader(e,t=0){return null}textForRowHeader(e){return""}textForRowFooter(e){return""}isColumnMovable(e,t=0){return!0}isRowMovable(e){return!0}getColumnHeaderGroup(e,t){}getColumnHeaderParentGroup(e,t){}tokensForCell(e,t,n=wa){const s=this.textForCell(e,t);return this.getCachedTokensInText(s,n)}getCachedTokensInText=Bn((e,t)=>{if(t>=e.length)return O.findTokensWithProtocolInText(e);const n=e.slice(t-1,wa).search(/\s/);let s=t+n;n===-1&&(s=Math.min(wa,e.length));const i=e.substring(0,s);return O.findTokensWithProtocolInText(i)})}const sw=nw;function iw(c,e){const t=aw(c);return t===void 0?void 0:`${mw(c)} ? ${t} : ${e}`}function ow(c){return dh.Column.formatRowColor(c)}function lw(c,e){return c.formatColor(e)}const Zi=ee.module("ConditionalFormattingUtils");var Fn=(c=>(c.CONDITIONAL="conditional",c.ROWS="rows",c))(Fn||{}),Ue=(c=>(c.IS_EQUAL="is-equal",c.IS_NOT_EQUAL="is-not-equal",c.IS_BETWEEN="is-between",c.GREATER_THAN="greater-than",c.GREATER_THAN_OR_EQUAL="greater-than-or-equal",c.LESS_THAN="less-than",c.LESS_THAN_OR_EQUAL="less-than-or-equal",c.IS_NULL="is-null",c.IS_NOT_NULL="is-not-null",c))(Ue||{}),Ht=(c=>(c.IS_EXACTLY="is-exactly",c.IS_NOT_EXACTLY="is-not-exactly",c.CONTAINS="contains",c.DOES_NOT_CONTAIN="does-not-contain",c.STARTS_WITH="starts-with",c.ENDS_WITH="ends-with",c.IS_NULL="is-null",c.IS_NOT_NULL="is-not-null",c))(Ht||{}),xt=(c=>(c.IS_EXACTLY="is-exactly",c.IS_NOT_EXACTLY="is-not-exactly",c.IS_BEFORE="is-before",c.IS_BEFORE_OR_EQUAL="is-before-or-equal",c.IS_AFTER="is-after",c.IS_AFTER_OR_EQUAL="is-after-or-equal",c.IS_NULL="is-null",c.IS_NOT_NULL="is-not-null",c))(xt||{}),qi=(c=>(c.IS_TRUE="is-true",c.IS_FALSE="is-false",c.IS_NULL="is-null",c.IS_NOT_NULL="is-not-null",c))(qi||{}),Ks=(c=>(c.IS_EQUAL="is-equal",c.IS_NOT_EQUAL="is-not-equal",c.IS_NULL="is-null",c.IS_NOT_NULL="is-not-null",c))(Ks||{}),on=(c=>(c.NO_FORMATTING="no-formatting",c.POSITIVE="positive",c.NEGATIVE="negative",c.WARN="warn",c.NEUTRAL="neutral",c.ACCENT_1="accent-1",c.ACCENT_2="accent-2",c.CUSTOM="custom",c))(on||{});function Xd(c){switch(c){case"no-formatting":return"No formatting";case"positive":return"Positive";case"negative":return"Negative";case"warn":return"Warn";case"neutral":return"Neutral";case"accent-1":return"Accent 1";case"accent-2":return"Accent 2";case"custom":return"Custom..."}}function vl(c){const{type:e,customConfig:t}=c;switch(e){case"no-formatting":return;case"positive":return"#9fde6f";case"negative":return"#ff6087";case"warn":return"#f67f40";case"neutral":return"#ffd95c";case"accent-1":return"#78dce8";case"accent-2":return"#ab9bf5";case"custom":return t?.background;default:return}}function Tl(c){const{type:e,customConfig:t}=c;switch(e){case"no-formatting":return;case"positive":return"#526a3f";case"negative":return"#802f44";case"warn":return"#663318";case"neutral":return"#63562b";case"accent-1":return"#3f6469";case"accent-2":return"#554d72";case"custom":return t?.color;default:return}}function aw(c){const e=Tl(c.style),t=vl(c.style);if(!(e===void 0||t===void 0))return`bgfg(\`${t}\`, \`${e}\`)`}function rw(c){const{column:e,value:t,start:n,end:s}=c;return yw(e.name,c.condition,t,n,s)}function dw(c){const{column:e,value:t}=c;return Rw(e.name,c.condition,t)}function cw(c){const{column:e,value:t}=c;return xw(e.name,c.condition,t)}function hw(c){const{column:e}=c;return Iw(e.name,c.condition)}function uw(c){const{column:e,value:t}=c;return Dw(e.name,c.condition,t)}function mw(c){const{column:e}=c;if(F.isNumberType(e.type))return rw(c);if(F.isCharType(e.type))return uw(c);if(F.isStringType(e.type))return dw(c);if(F.isDateType(e.type))return cw(c);if(F.isBooleanType(e.type))return hw(c);throw new Error("Invalid column type")}function gw(c){switch(c){case"is-equal":return"is equal to";case"is-not-equal":return"is not equal to";case"is-between":return"is between";case"greater-than":return"greater than";case"greater-than-or-equal":return"greater than or equal to";case"less-than":return"less than";case"less-than-or-equal":return"less than or equal to";case"is-null":return"is null";case"is-not-null":return"is not null"}}function pw(c){switch(c){case"is-exactly":return"is exactly";case"is-not-exactly":return"is not exactly";case"contains":return"contains";case"does-not-contain":return"does not contain";case"starts-with":return"starts with";case"ends-with":return"ends with";case"is-null":return"is null";case"is-not-null":return"is not null"}}function fw(c){switch(c){case"is-exactly":return"is";case"is-not-exactly":return"is not";case"is-before":return"is before";case"is-before-or-equal":return"is before or equal";case"is-after":return"is after";case"is-after-or-equal":return"is after or equal";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Cw(c){switch(c){case"is-true":return"is true";case"is-false":return"is false";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Sw(c){switch(c){case"is-equal":return"is";case"is-not-equal":return"is not";case"is-null":return"is null";case"is-not-null":return"is not null"}}function cu(c){if(F.isNumberType(c)||F.isCharType(c))return"is-equal";if(F.isStringType(c)||F.isDateType(c))return"is-exactly";if(F.isBooleanType(c))return"is-true";throw new Error("Invalid column type")}function hu(c){if(F.isCharType(c)||F.isStringType(c))return""}function uu(c){const{condition:e,value:t,start:n,end:s}=c;return{condition:e,value:t,start:n,end:s}}function ea(c){return{condition:cu(c),value:hu(c),start:void 0,end:void 0}}function mu(){return{type:"no-formatting"}}function bw(c){switch(c){case"is-exactly":return"==";case"is-not-exactly":return"!=";case"contains":return"contains";case"does-not-contain":return"does not contain";case"starts-with":return"starts with";case"ends-with":return"ends with";case"is-null":return"is null";case"is-not-null":return"is not null"}}function ww(c){switch(c){case"is-exactly":return"==";case"is-not-exactly":return"!=";case"is-before":return"<";case"is-before-or-equal":return"<=";case"is-after":return">";case"is-after-or-equal":return">=";case"is-null":return"is null";case"is-not-null":return"is not null"}}function vw(c){switch(c){case"is-true":return"is true";case"is-false":return"is false";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Tw(c){switch(c){case"is-equal":return"==";case"is-not-equal":return"!=";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Ew(c){switch(c){case"is-equal":return"==";case"is-not-equal":return"!=";case"is-between":return"==";case"greater-than":return">";case"greater-than-or-equal":return">=";case"less-than":return"<";case"less-than-or-equal":return"<=";case"is-null":return"is null";case"is-not-null":return"is not null"}}function yw(c,e,t,n,s){switch(e){case"is-equal":return`${c} == ${t}`;case"is-not-equal":return`${c} != ${t}`;case"is-between":return`${c} > ${n} && ${c} < ${s}`;case"greater-than":return`${c} > ${t}`;case"greater-than-or-equal":return`${c} >= ${t}`;case"less-than":return`${c} < ${t}`;case"less-than-or-equal":return`${c} <= ${t}`;case"is-null":return`${c} == null`;case"is-not-null":return`${c} != null`}}function Rw(c,e,t){switch(e){case"is-exactly":return`${c} == "${t}"`;case"is-not-exactly":return`${c} != "${t}"`;case"contains":return`${c} != null && ${c}.contains("${t}")`;case"does-not-contain":return`${c} != null && !${c}.contains("${t}")`;case"starts-with":return`${c} != null && ${c}.startsWith("${t}")`;case"ends-with":return`${c} != null && ${c}.endsWith("${t}")`;case"is-null":return`${c} == null`;case"is-not-null":return`${c} != null`}}function xw(c,e,t){switch(e){case"is-exactly":return`${c} == convertDateTime("${t}")`;case"is-not-exactly":return`${c} != convertDateTime(\`${t}\`)`;case"is-before":return`${c} < convertDateTime(\`${t}\`)`;case"is-before-or-equal":return`${c} <= convertDateTime("${t}")`;case"is-after":return`${c} > convertDateTime(\`${t}\`)`;case"is-after-or-equal":return`${c} >= convertDateTime(\`${t}\`)`;case"is-null":return`${c} == null`;case"is-not-null":return`${c} != null`}}function Iw(c,e){switch(e){case"is-true":return`${c} == true`;case"is-false":return`${c} == false`;case"is-null":return`${c} == null`;case"is-not-null":return`${c} != null`}}function Dw(c,e,t){switch(e){case"is-equal":return`${c} == '${t}'`;case"is-not-equal":return`${c} != '${t}'`;case"is-null":return`isNull(${c})`;case"is-not-null":return`!isNull(${c})`}}function Fw(c,e){if(F.isNumberType(c))return Ew(e);if(F.isCharType(c))return Tw(e);if(F.isStringType(c))return bw(e);if(F.isDateType(c))return ww(e);if(F.isBooleanType(c))return vw(e);throw new Error("Invalid column type")}function Nw(c,e){if(e===void 0)return Zi.debug("no rules passed."),[];const t=[];let n;const s=new Map;return e.forEach(({config:i,type:o})=>{const{column:l}=i,a=c.find(({name:p,type:C})=>p===l.name&&C===l.type);if(a===void 0){Zi.debug(`Column ${l.name}:${l.type} not found. Ignoring format rule.`,i);return}const[d,h]=(o==="conditional"?s.get(a.name):n)??["null",void 0],u=iw(i,d);if(u===void 0){Zi.debug("Ignoring format rule.",i);return}const m=h===void 0?-1:t.indexOf(h);m>-1&&t.splice(m,1);const g=o==="conditional"?lw(a,u):ow(u);t.push(g),o==="conditional"?s.set(a.name,[u,g]):n=[u,g]}),t}function kw(c,e){switch(c){case"is-null":case"is-not-null":return!0;default:{const[t,...n]=(e??"").split(" "),s=n.join(" ");try{Zs.parseDateTimeString(t)}catch{return Zi.debug("Invalid datetime string",t),!1}try{dh.i18n.TimeZone.getTimeZone(s)}catch{return Zi.debug("Invalid timezone string",s),!1}return!0}}}function Mw({type:c}){return F.isNumberType(c)||F.isCharType(c)||F.isStringType(c)||F.isDateType(c)||F.isBooleanType(c)}function ta({animation:c="iris-grid-bottom-bar-slide-up",children:e,className:t,isShown:n,onClick:s,onEntering:i,onEntered:o,onExiting:l,onExited:a}){return r.jsx($t,{in:n,timeout:Xe.transitionMs,classNames:c,onEntering:i,onEntered:o,onExiting:l,onExited:a,mountOnEnter:!0,unmountOnExit:!0,children:r.jsx("div",{className:K("iris-grid-bottom-bar",t),role:"presentation",onClick:s,onKeyPress:s,children:e})})}const Lw=3e3,Ow=5;function Aw({isSaving:c=!1,onSave:e,onDiscard:t,discardTooltip:n,saveTooltip:s,error:i,pendingDataErrors:o,pendingDataMap:l,onEntering:a,onEntered:d,onExiting:h,onExited:u}){const[m,g]=w.useState(!1),[p,C]=w.useState(!1),f=w.useRef(),S=sr(c),v=w.useMemo(()=>o.size===0?i:o.size<=Ow?`Key can't be empty (on pending row${o.size>1?"s":""} ${Array.from(o.keys()).join(", ").trim()})`:`Key can't be empty (on ${o.size} rows)`,[i,o]);w.useEffect(function(){S!=null&&S&&!c&&v==null&&(g(!0),C(!0),f.current=setTimeout(()=>{g(!1)},Lw))},[v,c,S]),w.useEffect(function(){f.current&&l.size>0&&(clearTimeout(f.current),g(!1),C(!1))},[l]),w.useEffect(function(){return()=>f.current?clearTimeout(f.current):void 0},[]);const b=l.size;let T;return c?T=r.jsx(Nn,{}):p&&(T=lr),r.jsxs(ta,{className:"pending-data-bottom-bar",isShown:b>0||m||v!=null,onEntering:a,onEntered:d,onExiting:h,onExited:()=>{C(!1),u&&u()},children:[v!=null&&v!==""&&r.jsxs("div",{className:"error-message",children:[r.jsx(X,{icon:vs}),r.jsx("span",{children:`${v}`})]}),(v==null||v==="")&&r.jsx("div",{className:"status-message",children:b>0&&r.jsx("span",{children:`${b} row${b>1?"s":""} pending`})}),r.jsxs("div",{className:"buttons-container",children:[!c&&!p&&r.jsx(_,{kind:"secondary",onClick:t,tooltip:n,children:"Discard"}),r.jsxs(_,{kind:p?"success":"primary",onClick:e,icon:T,disabled:c||p||v!=null,tooltip:s,children:[c&&"Committing...",!c&&p&&"Success",!c&&!p&&"Commit"]})]})]})}var gu=(c=>(c.COUNT="Count",c.MIN="Min",c.MAX="Max",c.SUM="Sum",c.ABS_SUM="AbsSum",c.VAR="Var",c.AVG="Avg",c.STD="Std",c.FIRST="First",c.LAST="Last",c.SKIP="Skip",c.COUNT_DISTINCT="CountDistinct",c.DISTINCT="Distinct",c.UNIQUE="Unique",c))(gu||{});const ke=gu,_w=[ke.SUM,ke.ABS_SUM,ke.MIN,ke.MAX,ke.VAR,ke.AVG,ke.STD,ke.FIRST,ke.LAST,ke.COUNT_DISTINCT,ke.DISTINCT,ke.COUNT,ke.UNIQUE],Pw=c=>{switch(c){default:return!1}},jw=(c,e)=>{switch(c){case ke.COUNT:case ke.FIRST:case ke.LAST:case ke.COUNT_DISTINCT:case ke.DISTINCT:case ke.UNIQUE:return!0;case ke.MIN:case ke.MAX:return F.isNumberType(e)||F.isDateType(e)||F.isTextType(e);case ke.SUM:case ke.ABS_SUM:case ke.VAR:case ke.AVG:case ke.STD:return F.isNumberType(e);case ke.SKIP:return!1}},Ar=(c,e)=>c.filter(t=>jw(e,t.type)),Hw=(c,e,t,n)=>Ar(c,e).map(({name:s})=>s).filter(s=>t.includes(s)?!n:n),Ss={isRollupOperation:Pw,filterValidColumns:Ar,getOperationColumnNames:Hw};var pu=(c=>(c.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS="filter-control-change-clears-all-filters",c.LINK_CHANGE_CLEARS_ALL_FILTERS="link-change-clears-all-filters",c))(pu||{});const Ri=pu,Uw=Object.freeze([[Ri.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS,!1],[Ri.LINK_CHANGE_CLEARS_ALL_FILTERS,!1]]),fu={DEFAULTS:Uw},Vw=ee.module("ColumnHeaderGroup");function va(c){return c instanceof dn}class dn{static NEW_GROUP_PREFIX=":newGroup";name;children;depth;parent;color;childIndexes;constructor({name:e,children:t,color:n,depth:s,childIndexes:i,parent:o}){this.name=e,this.children=t,this.color=n,this.depth=s,this.childIndexes=i,this.parent=o}getVisibleRange=he(e=>{const t=this.childIndexes.flat(),n=O.getVisibleIndexes(t,e),s=Math.min(...n),i=Math.max(...n);return i-s!==t.length-1&&Vw.warn(`Column header group ${this.name} is not contiguous`),[s,i]});setParent(e){this.parent=e}addChildren(e){const t=new Set(this.children.concat(e));this.children=[...t]}removeChildren(e){const t=new Set(this.children);e.forEach(n=>t.delete(n)),this.children=[...t]}get isNew(){return this.name.startsWith(dn.NEW_GROUP_PREFIX)}}const ji=ee.module("IrisGridUtils");function as(c,e){return c>=0&&c<e.length}function Bw(c){return c.asDate!=null}class be{static dehydrateGridState(e,t){const{isStuckToBottom:n,isStuckToRight:s,movedColumns:i,movedRows:o}=t,{columns:l}=e;return{isStuckToBottom:n,isStuckToRight:s,movedColumns:[...i].filter(({to:a,from:d})=>as(a,l)&&(typeof d=="number"&&as(d,l)||Array.isArray(d)&&as(d[0],l)&&as(d[1],l))).map(({to:a,from:d})=>({to:l[a].name,from:Array.isArray(d)?[l[d[0]].name,l[d[1]].name]:l[d].name})),movedRows:[...o]}}static hydrateGridState(e,t,n=[]){const{isStuckToBottom:s,isStuckToRight:i,movedColumns:o,movedRows:l}=t,{columns:a}=e,d=be.parseCustomColumnNames(n),h=a.map(({name:u})=>u).concat(d);return{isStuckToBottom:s,isStuckToRight:i,movedColumns:[...o].map(({to:u,from:m})=>{const g=p=>typeof p=="string"?h.findIndex(C=>C===p):p;return{to:g(u),from:Array.isArray(m)?[g(m[0]),g(m[1])]:g(m)}}).filter(({to:u,from:m})=>as(u,h)&&(typeof m=="number"&&as(m,h)||Array.isArray(m)&&as(m[0],h)&&as(m[1],h))),movedRows:[...l]}}static dehydrateIrisGridState(e,t){const{aggregationSettings:n={aggregations:Fe,showOnTop:!1},advancedFilters:s,customColumnFormatMap:i,isFilterBarShown:o,metrics:l,quickFilters:a,customColumns:d,conditionalFormats:h=Fe,reverseType:u,rollupConfig:m=void 0,showSearchBar:g,searchValue:p,selectDistinctColumns:C=Fe,selectedSearchColumns:f,sorts:S,invertSearchColumns:v,pendingDataMap:b=jn,frozenColumns:T,columnHeaderGroups:y}=t;N(l);const{userColumnWidths:E,userRowHeights:R}=l,{columns:x}=e;return{advancedFilters:be.dehydrateAdvancedFilters(x,s),aggregationSettings:n,customColumnFormatMap:[...i],isFilterBarShown:o,quickFilters:be.dehydrateQuickFilters(a),sorts:be.dehydrateSort(S),userColumnWidths:[...E].filter(([D])=>D!=null&&D>=0&&D<x.length).map(([D,L])=>[x[D].name,L]),userRowHeights:[...R],customColumns:[...d],conditionalFormats:[...h],reverseType:u,rollupConfig:m,showSearchBar:g,searchValue:p,selectDistinctColumns:[...C],selectedSearchColumns:f,invertSearchColumns:v,pendingDataMap:be.dehydratePendingDataMap(x,b),frozenColumns:T,columnHeaderGroups:y?.map(D=>({name:D.name,children:D.children,color:D.color}))}}static hydrateIrisGridState(e,t){const{advancedFilters:n,aggregationSettings:s={aggregations:[],showOnTop:!1},customColumnFormatMap:i,isFilterBarShown:o,quickFilters:l,sorts:a,customColumns:d,conditionalFormats:h,userColumnWidths:u,userRowHeights:m,reverseType:g,rollupConfig:p=void 0,showSearchBar:C,searchValue:f,selectDistinctColumns:S,selectedSearchColumns:v,invertSearchColumns:b=!0,pendingDataMap:T=[],frozenColumns:y,columnHeaderGroups:E}=t,{columns:R,formatter:x}=e;return{advancedFilters:be.hydrateAdvancedFilters(R,n,x.timeZone),aggregationSettings:s,customColumnFormatMap:new Map(i),isFilterBarShown:o,quickFilters:be.hydrateQuickFilters(R,l,x.timeZone),sorts:be.hydrateSort(R,a),userColumnWidths:new Map(u.map(([D,L])=>typeof D=="string"||D instanceof String?[R.findIndex(({name:M})=>M===D),L]:[D,L]).filter(([D])=>D!=null&&D>=0&&D<R.length)),customColumns:d,conditionalFormats:h,userRowHeights:new Map(m),reverseType:g,rollupConfig:p,showSearchBar:C,searchValue:f,selectDistinctColumns:S,selectedSearchColumns:v,invertSearchColumns:b,pendingDataMap:be.hydratePendingDataMap(R,T),frozenColumns:y,columnHeaderGroups:be.parseColumnHeaderGroups(e,E??e.layoutHints?.columnGroups??[]).groups}}static dehydrateIrisGridPanelState(e,t){const{isSelectingPartition:n,partition:s,partitionColumn:i,advancedSettings:o}=t;return{isSelectingPartition:n,partition:s,partitionColumn:i?.name,advancedSettings:[...o]}}static hydrateIrisGridPanelState(e,t){const{isSelectingPartition:n,partition:s,partitionColumn:i,advancedSettings:o}=t,{columns:l}=e;return{isSelectingPartition:n,partition:s,partitionColumn:i!=null?be.getColumnByName(l,i):void 0,advancedSettings:new Map([...fu.DEFAULTS,...o])}}static dehydrateQuickFilters(e){return[...e].map(([t,n])=>{const{text:s}=n;return[t,{text:s}]})}static hydrateQuickFilters(e,t,n){const s=t.map(([i,o])=>{const{text:l}=o;let a=null;try{const d=be.getColumn(e,i);d!=null&&(a=F.makeQuickFilter(d,l,n))}catch(d){ji.error("hydrateQuickFilters error with",l,d)}return[i,{text:l,filter:a}]});return new Map(s)}static dehydrateAdvancedFilters(e,t){return[...t].map(([n,s])=>{const i=be.getColumn(e,n);N(i);const o=be.dehydrateAdvancedFilterOptions(i,s.options);return[n,{options:o}]})}static hydrateAdvancedFilters(e,t,n){const s=t.map(([i,o])=>{const l=be.getColumn(e,i);N(l);const a=be.hydrateAdvancedFilterOptions(l,o.options);let d=null;try{be.getColumn(e,i)!=null&&(d=F.makeAdvancedFilter(l,a,n))}catch(h){ji.error("hydrateAdvancedFilters error with",a,h)}return[i,{options:a,filter:d}]});return new Map(s)}static dehydrateAdvancedFilterOptions(e,t){const{selectedValues:n,...s}=t;return{selectedValues:n?.map(i=>be.dehydrateValue(i,e?.type)),...s}}static hydrateAdvancedFilterOptions(e,t){const{selectedValues:n,...s}=t;return{selectedValues:n?.map(i=>be.hydrateValue(i,e?.type)),...s}}static dehydratePendingDataMap(e,t){return[...t].map(([n,{data:s}])=>[n,{data:[...s].map(([i,o])=>[e[i].name,be.dehydrateValue(o,e[i].type)])}])}static hydratePendingDataMap(e,t){const n=new Map,s=i=>(n.has(i)||n.set(i,e.findIndex(({name:o})=>o===i)),n.get(i));return new Map(t.map(([i,{data:o}])=>[i,{data:new Map(o.map(([l,a])=>{const d=s(l);return N(d),[s(l)??null,be.hydrateValue(a,e[d].type)]}))}]))}static dehydrateValue(e,t){return F.isDateType(t)?be.dehydrateDateTime(e):F.isLongType(t)?be.dehydrateLong(e):e}static hydrateValue(e,t){return F.isDateType(t)?be.hydrateDateTime(e):F.isLongType(t)?be.hydrateLong(e):e}static dehydrateDateTime(e){return e!=null?I.i18n.DateTimeFormat.format(Zs.FULL_DATE_FORMAT,e):null}static hydrateDateTime(e){return e!=null?I.i18n.DateTimeFormat.parse(Zs.FULL_DATE_FORMAT,e):null}static dehydrateLong(e){return e!=null?`${e}`:null}static hydrateLong(e){return e!=null?I.LongWrapper.ofString(e):null}static dehydrateSort(e){return e.map(t=>{const{column:n,isAbs:s,direction:i}=t;return{column:n.name,isAbs:s,direction:i}})}static hydrateSort(e,t){return t.map(n=>{const{column:s,isAbs:i,direction:o}=n;if(o===F.sortDirection.reverse)return I.Table.reverse();const l=typeof s=="string"?be.getColumnByName(e,s):be.getColumn(e,s);if(l!=null){let a=l.sort();return i&&(a=a.abs()),o===F.sortDirection.descending?a=a.desc():a=a.asc(),a}return null}).filter(n=>n!=null&&n.direction!==F.sortDirection.reverse)}static extractTableSettings(e,t=[]){const{irisGridPanelState:n,irisGridState:s}=e,{partitionColumn:i,partition:o}=n,{advancedFilters:l,quickFilters:a,sorts:d}=s;return{advancedFilters:l,inputFilters:t,partition:o,partitionColumn:i,quickFilters:a,sorts:d}}static applyTableSettings(e,t,n){const{columns:s}=e;let i=[];t.quickFilters&&(i=be.getFiltersFromFilterMap(be.hydrateQuickFilters(s,t.quickFilters,n)));let o=[];t.advancedFilters&&(o=be.getFiltersFromFilterMap(be.hydrateAdvancedFilters(s,t.advancedFilters,n)));const l=be.getFiltersFromInputFilters(s,t.inputFilters,n);let a=[];t.sorts&&(a=be.hydrateSort(s,t.sorts));let d=[...i,...o];const{partition:h,partitionColumn:u}=t;if(h!=null&&u!=null){const m=be.getColumnByName(s,u);m&&(d=[m.filter().eq(I.FilterValue.ofString(h)),...d])}d=[...l,...d],e.applyFilter(d),e.applySort(a)}static getInputFiltersForColumns(e,t=[]){return t.filter(({name:n,type:s})=>e.find(({name:i,type:o})=>i===n&&o===s))}static getFiltersFromInputFilters(e,t=[],n){return t.map(({name:s,type:i,value:o})=>{const l=e.find(({name:a,type:d})=>a===s&&d===i);if(l)try{return F.makeQuickFilter(l,o,n)}catch(a){ji.debug("Unable to create input filter",a)}return null}).filter(s=>s!=null)}static getFiltersFromFilterMap(e){const t=[],n=Array.from(e.keys());for(let s=0;s<n.length;s+=1){const i=n[s],o=e.get(i);o?.filter!=null&&t.push(o.filter)}return t}static getHiddenColumns(e){return[...e.entries()].filter(([,t])=>t===0).map(([t])=>t)}static parseCustomColumnNames(e){return e.map(t=>t.split("=")[0])}static getRemovedCustomColumnNames(e,t){const n=be.parseCustomColumnNames(e),s=be.parseCustomColumnNames(t);return n.filter(i=>!s.includes(i))}static removeSortsInColumns(e,t){return e.filter(n=>!t.includes(n.column.name))}static removeFiltersInColumns(e,t,n){const s=e.map(({name:o})=>o),i=new Map(t);return n.forEach(o=>i.delete(s.indexOf(o))),i}static removeColumnFromMovedColumns(e,t,n){const s=e.map(({name:o})=>o);let i=[...t];for(let o=0;o<n.length;o+=1){const l=n[o];let a=s.findIndex(h=>h===l);const d=[];for(let h=0;h<i.length;h+=1){const u=i[h],m={...u};let[g,p]=Array.isArray(u.from)?u.from:[u.from,u.from];a<=u.to&&(m.to-=1),a<g&&(g-=1),a<=p&&(p-=1),g<=p&&g!==m.to&&(g===p?d.push({...m,from:g}):d.push({...m,from:[g,p]})),a=O.applyItemMoves(a,a,[u])[0][0]}i=d,s.splice(s.findIndex(h=>h===l),1)}return i}static removeColumnsFromSelectDistinctColumns(e,t){return e.filter(n=>!t.includes(n))}static getVisibleColumnsInRange(e,t,n,s,i){const o=[];for(let l=t;l<=n;l+=1){const a=O.getModelIndex(l,s);a>=0&&a<e.length&&!i.includes(a)&&o.push(e[a])}return o}static getPrevVisibleColumns(e,t,n,s,i){const o=[];let l=t;for(;l>=0&&o.length<n;){const a=O.getModelIndex(l,s);a>=0&&a<e.length&&!i.includes(a)&&o.unshift(e[a]),l-=1}return o}static getNextVisibleColumns(e,t,n,s,i){const o=[];let l=t;for(;l<e.length&&o.length<n;){const a=O.getModelIndex(l,s);a>=0&&a<e.length&&!i.includes(a)&&o.push(e[a]),l+=1}return o}static getColumnsToFetch(e,t,n){const s=[...t];return n.forEach(i=>{const o=e.find(({name:l})=>l===i);o!=null&&!t.includes(o)&&s.push(o)}),s}static getModelViewportColumns(e,t,n,s,i=[],o=[],l=0){if(t==null||n==null)return null;const a=be.getVisibleColumnsInRange(e,t,n,s,i),d=a.length*l,h=be.getPrevVisibleColumns(e,t-1,d,s,i),u=be.getNextVisibleColumns(e,n+1,d,s,i),m=[...h,...a,...u];return be.getColumnsToFetch(e,m,o)}static rangeSetFromRanges(e){const t=e.slice().sort((n,s)=>(N(n.startRow),N(s.startRow),n.startRow-s.startRow)).map(n=>{const{startRow:s,endRow:i}=n;return N(s),N(i),I.RangeSet.ofRange(s,i)});return I.RangeSet.ofRanges(t)}static isValidSnapshotRanges(e){if(e==null||e.length===0)return!1;const t=new Map;for(let i=0;i<e.length;i+=1){const o=e[i],l=`${o.startRow}:${o.endRow}`,a=`${o.startColumn}:${o.endColumn}`;t.has(l)||t.set(l,[]),t.get(l).push(a)}const n=[...t.keys()],s=t.get(n[0]).sort().join(",");for(let i=1;i<n.length;i+=1)if(t.get(n[i]).sort().join(",")!==s)return!1;return!0}static isValidIndex(e){return!Number.isInteger(e)||typeof e!="number"?!1:e>=0}static columnsFromRanges(e,t){if(e==null||e.length===0)return[];if(e[0].startColumn===null&&e[0].endColumn===null)return[...t];const n=new Set;for(let s=0;s<e.length;s+=1){const i=e[s];N(i.startColumn),N(i.endColumn);for(let o=i.startColumn??0;o<=(i.endColumn??t.length-1);o+=1)n.add(o)}return[...n].map(s=>t[s])}static snapshotDataToMatrix(e){const{columns:t,rows:n}=e,s=[];for(let i=0;i<n.length;i+=1){const o=n[i],l=[];for(let a=0;a<t.length;a+=1){const d=t[a],h=o.get(d);l.push(h)}s.push(l)}return s}static getModelRollupConfig(e,t,n){if((t?.columns?.length??0)===0)return null;const{columns:s=[],showConstituents:i=!0,showNonAggregatedColumns:o=!0,includeDescriptions:l=!0}=t??{},{aggregations:a=[]}=n??{},d=a.map(({operation:u,selected:m,invert:g})=>Ss.isRollupOperation(u)?[]:Ss.getOperationColumnNames(e,u,m,g)),h={};for(let u=0;u<a.length;u+=1)h[a[u].operation]=d[u];if(o){const u=new Set(e.map(m=>m.name).filter(m=>!s.includes(m)));if(d.forEach(m=>{m.forEach(g=>u.delete(g))}),u.size>0){const m=h[ke.FIRST]??[];h[ke.FIRST]=[...m,...u]}}return{groupingColumns:s,includeConstituents:i,includeDescriptions:l,aggregations:h}}static getPendingErrors(e){e.forEach((t,n)=>{if(!be.isValidIndex(n))throw new Error(`Invalid rowIndex ${n}`);const{data:s}=t;s.forEach((i,o)=>{if(!be.isValidIndex(o))throw new Error(`Invalid columnIndex ${o}`)})})}static getColumn(e,t){return t<e.length?e[t]:(ji.error("Unable to retrieve column",t,">=",e.length),null)}static getColumnByName(e,t){const n=e.find(({name:s})=>s===t);return n==null&&ji.error("Unable to retrieve column by name",t,e.map(({name:s})=>s)),n}static changeFilterColumnNamesToIndexes(e,t){return t.map(({name:n,filter:s})=>{const i=e.findIndex(o=>o.name===n);return i<0?null:[i,s]}).filter(n=>n!=null)}static combineFiltersFromList(e,t){t.sort((s,i)=>s.operator==="eq"&&i.operator!=="eq"?1:s.operator!=="eq"&&i.operator==="eq"?-1:s.startColumnIndex-i.startColumnIndex);let n="";for(let s=0;s<t.length;s+=1){const{text:i,value:o,operator:l}=t[s];if(o!==void 0){let a="";l!==void 0&&(o==null&&l==="eq"?a="=":l!=="eq"&&(l==="startsWith"||l==="endsWith"?a="*":a=F.getFilterOperatorString(l)));let d=`${a}${i}`;l==="startsWith"&&(d=`${i}${a}`),e!=null&&o!==null&&F.isCharType(e)&&(d=`${a}${String.fromCharCode(parseInt(i,10))}`),s!==0&&(n+=l==="eq"?" || ":" && "),n+=d}}return n}static parseColumnHeaderGroups(e,t){let n=1;const s=new Map,i=new Map,o=t?.filter(({children:u})=>u.length>0);if(o.length===0)return{groups:[],maxDepth:n,parentMap:s,groupMap:i};const l=new Map(o.map(u=>[u.name,u])),a=new Set,d=u=>{const{name:m}=u;if(e.getColumnIndexByName(m)!=null)throw new Error(`Column header group has same name as column: ${m}`);const g=i.get(m);if(g)return g;const p=[];let C=1;u.children.forEach(S=>{if(a.has(S))throw new Error(`Column group child ${S} specified in multiple groups`);a.add(S);const v=l.get(S),b=e.getColumnIndexByName(S);if(v){const T=d(v);p.push(...T.childIndexes),C=Math.max(C,T.depth+1)}else if(b!=null)p.push(b),C=Math.max(C,1);else throw new Error(`Unknown child ${S} in group ${m}`)});const f=new dn({...u,depth:C,childIndexes:p.flat()});return i.set(m,f),u.children.forEach(S=>s.set(S,f)),n=Math.max(n,f.depth+1),f},h=new Set;return o.forEach(u=>{const{name:m}=u;if(h.has(m))throw new Error(`Duplicate column group name: ${m}`);h.add(m),d(u)}),i.forEach(u=>{u.setParent(s.get(u.name)?.name)}),{groups:[...i.values()],maxDepth:n,groupMap:i,parentMap:s}}static convertValueToText(e,t){if(t!=null&&F.isCharType(t)&&e!=null&&typeof e=="number")return String.fromCharCode(e);if(F.isDateType(t)&&Bw(e)){const n=new Date(e.asDate()),s=n.getTimezoneOffset();return new Date(n.getTime()-s*60*1e3).toISOString().replace("T"," ").substring(0,23)}return e==null?"":`${e}`}}const Ce=be;const jt=ee.module("IrisGridCopyHandler");class Ne extends w.Component{static NO_PROMPT_THRESHOLD=1e4;static HIDE_TIMEOUT=3e3;static COPY_STATES={IDLE:"IDLE",CONFIRMATION_REQUIRED:"CONFIRMATION_REQUIRED",FETCH_IN_PROGRESS:"FETCH_IN_PROGRESS",FETCH_ERROR:"FETCH_ERROR",CLICK_REQUIRED:"CLICK_REQUIRED",DONE:"DONE"};static BUTTON_STATES={COPY:"COPY",FETCH_IN_PROGRESS:"FETCH_IN_PROGRESS",CLICK_TO_COPY:"CLICK_TO_COPY",RETRY:"RETRY"};static defaultProps={copyOperation:null,onEntering:()=>{},onEntered:()=>{},onExiting:()=>{},onExited:()=>{}};static getStatusMessageText(e,t){switch(e){case Ne.COPY_STATES.CONFIRMATION_REQUIRED:return`Are you sure you want to copy ${t.toLocaleString()} rows to your clipboard?`;case Ne.COPY_STATES.CLICK_REQUIRED:return`Fetched ${t.toLocaleString()} rows!`;case Ne.COPY_STATES.FETCH_ERROR:return"Unable to copy data.";case Ne.COPY_STATES.FETCH_IN_PROGRESS:return`Fetching ${t.toLocaleString()} rows for clipboard...`;case Ne.COPY_STATES.DONE:return"Copied to Clipboard!";default:return""}}static getCopyButtonText(e){switch(e){case Ne.BUTTON_STATES.FETCH_IN_PROGRESS:return"Fetching";case Ne.BUTTON_STATES.CLICK_TO_COPY:return"Click to Copy";case Ne.BUTTON_STATES.RETRY:return"Retry";default:return"Copy"}}constructor(e){super(e),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleCancelClick=this.handleCancelClick.bind(this),this.handleCopyClick=this.handleCopyClick.bind(this),this.handleHideTimeout=this.handleHideTimeout.bind(this),this.state={error:void 0,copyState:Ne.COPY_STATES.IDLE,buttonState:Ne.BUTTON_STATES.COPY,isShown:!1,rowCount:0}}componentDidMount(){const{copyOperation:e}=this.props;e!=null&&this.startCopy()}componentDidUpdate(e){const{copyOperation:t}=this.props;e.copyOperation!==t&&this.startCopy()}componentWillUnmount(){this.stopCopy()}textData;hideTimer;fetchPromise;startCopy(){jt.debug2("startCopy"),this.stopCopy();const{copyOperation:e}=this.props;if(e==null){jt.debug2("No copy operation set, cancelling out"),this.setState({isShown:!1});return}const{ranges:t,error:n}=e;if(n!=null){jt.debug("Showing copy error",n),this.setState({isShown:!0,copyState:Ne.COPY_STATES.DONE,error:n}),this.startHideTimer();return}const s=J.rowCount(t);this.setState({rowCount:s,isShown:!0,error:void 0}),s>Ne.NO_PROMPT_THRESHOLD?this.setState({buttonState:Ne.BUTTON_STATES.COPY,copyState:Ne.COPY_STATES.CONFIRMATION_REQUIRED}):this.startFetch()}stopCopy(){this.textData=void 0,this.stopFetch(),this.stopHideTimer()}handleBackgroundClick(){jt.debug2("handleBackgroundClick");const{copyState:e}=this.state;e===Ne.COPY_STATES.DONE&&this.setState({isShown:!1})}handleCancelClick(){jt.debug2("handleCancelClick"),this.stopFetch(),this.setState({isShown:!1})}handleCopyClick(){jt.debug2("handleCopyClick"),this.textData!=null?this.copyText(this.textData):this.startFetch()}handleHideTimeout(){jt.debug2("handleHideTimeout"),this.stopHideTimer(),this.setState({isShown:!1})}copyText(e){jt.debug2("copyText",e),this.textData=e,co(e).then(()=>{this.setState({copyState:Ne.COPY_STATES.DONE}),this.startHideTimer()},t=>{jt.error("copyText error",t),this.setState({buttonState:Ne.BUTTON_STATES.CLICK_TO_COPY,copyState:Ne.COPY_STATES.CLICK_REQUIRED})})}startFetch(){this.stopFetch(),this.setState({buttonState:Ne.BUTTON_STATES.FETCH_IN_PROGRESS,copyState:Ne.COPY_STATES.FETCH_IN_PROGRESS});const{model:e,copyOperation:t}=this.props,{ranges:n,includeHeaders:s,userColumnWidths:i,movedColumns:o,formatValues:l}=t;jt.debug("startFetch",n);const a=Ce.getHiddenColumns(i);let d=O.getModelRanges(n,o);if(a.length>0){const u=a.map(J.makeColumn);d=J.subtractRangesFromRanges(d,u)}const h=l!=null&&l?(u,m)=>e.displayString(u,m.type,m.name):u=>`${u}`;this.fetchPromise=ve.makeCancelable(e.textSnapshot(d,s,h)),this.fetchPromise.then(u=>{this.fetchPromise=void 0,this.copyText(u)}).catch(u=>{u instanceof Pl?jt.debug("User cancelled copy."):(jt.error("Error fetching contents",u),this.fetchPromise=void 0,this.setState({buttonState:Ne.BUTTON_STATES.RETRY,copyState:Ne.COPY_STATES.FETCH_ERROR}))})}stopFetch(){this.fetchPromise&&(jt.debug2("stopFetch"),this.fetchPromise.cancel(),this.fetchPromise=void 0)}startHideTimer(){this.stopHideTimer(),this.hideTimer=setTimeout(this.handleHideTimeout,Ne.HIDE_TIMEOUT)}stopHideTimer(){this.hideTimer!=null&&(clearTimeout(this.hideTimer),this.hideTimer=void 0)}render(){const{onEntering:e,onEntered:t,onExiting:n,onExited:s}=this.props,{buttonState:i,copyState:o,isShown:l,rowCount:a,error:d}=this.state,h=o===Ne.COPY_STATES.DONE?"fade":"copy-slide-up",u=Ne.getCopyButtonText(i),m=d??Ne.getStatusMessageText(o,a),g=o!==Ne.COPY_STATES.DONE,p=i===Ne.BUTTON_STATES.FETCH_IN_PROGRESS,C=o===Ne.COPY_STATES.DONE;return r.jsxs(ta,{animation:h,isShown:l,className:K("iris-grid-copy-handler",{"copy-done":C}),onClick:this.handleBackgroundClick,onEntering:e,onEntered:t,onExiting:n,onExited:s,children:[r.jsx("div",{className:"status-message",children:r.jsx("span",{children:m})}),r.jsx($t,{in:g,timeout:Xe.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:r.jsxs("div",{className:"buttons-container",children:[r.jsx("button",{type:"button",className:"btn btn-outline-secondary btn-cancel",onClick:this.handleCancelClick,children:"Cancel"}),r.jsxs(_,{kind:p?"tertiary":"primary",className:K("btn-copy",{"btn-spinner":p}),onClick:this.handleCopyClick,disabled:p,children:[p&&r.jsx(Nn,{}),u]})]})})]})}}const $w=Ne;class Ww extends w.PureComponent{static defaultProps={style:{},className:"",value:"",isAdvancedFilterSet:!1,onAdvancedFiltersTriggered:()=>{},onChange:()=>{},onDone:()=>{},onTab:()=>{},onContextMenu:()=>{},debounceMs:150};constructor(e){super(e);const{debounceMs:t}=e;this.debouncedSendUpdate=Ge(this.sendUpdate.bind(this),t),this.handleCancel=this.handleCancel.bind(this),this.handleChange=this.handleChange.bind(this),this.handleCommit=this.handleCommit.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.inputField=null;const{value:n}=e;this.initialValue=n,this.state={isChanged:!1,value:n}}componentDidMount(){this.inputField?.focus()}componentDidUpdate(e){const{debounceMs:t}=this.props;e.debounceMs!==t&&(this.debouncedSendUpdate.flush(),this.debouncedSendUpdate=Ge(this.sendUpdate.bind(this),t))}componentWillUnmount(){this.debouncedSendUpdate.cancel()}inputField;initialValue;debouncedSendUpdate;setValue(e){this.initialValue=e,this.setState({value:e})}focus(){this.inputField?.focus()}handleChange(e){const{value:t}=e.target;this.setState({value:t,isChanged:!0}),this.debouncedSendUpdate(t)}handleCancel(){this.debouncedSendUpdate.cancel();const{initialValue:e}=this,{isChanged:t}=this.state;t&&this.sendUpdate(e);const{onDone:n}=this.props;n()}handleCommit(e=!0,t=!0){this.debouncedSendUpdate.flush();const{onDone:n}=this.props;n(e,t)}handleFocus(){this.inputField?.select()}handleBlur(e){const{relatedTarget:t}=e;t!=null&&t.classList.contains("context-menu-container")?this.handleCommit(!1,!0):t!=null&&t.classList.contains("advanced-filter-button")?this.handleCommit(!1,!1):this.handleCommit(!0,!0)}handleTab(e=!1){this.debouncedSendUpdate.flush();const{onTab:t}=this.props;t(e)}handleKeyDown(e){switch(e.key){case"Escape":e.stopPropagation(),e.preventDefault(),this.handleCancel();break;case"Enter":e.stopPropagation(),e.preventDefault(),this.handleCommit();break;case"Tab":e.stopPropagation(),e.preventDefault(),this.handleTab(e.shiftKey);break}}handleContextMenu(e){const{onContextMenu:t}=this.props;t(e)}sendUpdate(e){const{onChange:t}=this.props;t(e)}render(){const{className:e,style:t,isAdvancedFilterSet:n,onAdvancedFiltersTriggered:s}=this.props,{value:i}=this.state;return r.jsxs("div",{style:t,className:"iris-grid-input-autosized-wrapper","data-value":i,children:[r.jsx("input",{ref:o=>{this.inputField=o},className:K("iris-grid-input-field",e),type:"text",value:i,onBlur:this.handleBlur,onFocus:this.handleFocus,onChange:this.handleChange,onKeyDown:this.handleKeyDown,onContextMenu:this.handleContextMenu,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false"}),r.jsx("div",{className:"advanced-filter-button-container",children:r.jsx(_,{kind:"ghost",className:K("btn-link-icon advanced-filter-button",{"filter-set":n}),onClick:s,onContextMenu:this.handleContextMenu,children:r.jsxs("div",{className:"fa-layers ",children:[r.jsx(X,{icon:ar,className:"filter-solid"}),r.jsx(X,{icon:rl,className:"filter-light"})]})})})]})}}const Gw=Ww;class zw extends ei{irisGrid;constructor(e){super(),this.irisGrid=e}onDown(e){const{selectedRanges:t}=this.irisGrid.state;return e.key==="c"&&Es.isModifierKeyDown(e)?(Ce.isValidSnapshotRanges(t)?this.irisGrid.copyRanges(t):this.irisGrid.copyRanges(t,!1,!1,"Invalid copy ranges"),!0):!1}}const Kw=zw,Yw={TOGGLE_QUICK_FILTER:Ve.createAndAdd({id:"TABLE.TOGGLE_QUICK_FILTER",name:"Toggle Quick Filter",shortcut:[Se.CTRL,Ee.F],macShortcut:[Se.CMD,Ee.F]}),CLEAR_ALL_FILTERS:Ve.createAndAdd({id:"TABLE.CLEAR_ALL_FILTERS",name:"Clear All Table Filters",shortcut:[Se.CTRL,Ee.E],macShortcut:[Se.CMD,Ee.E]}),CLEAR_FILTERS:Ve.createAndAdd({id:"TABLE.CLEAR_FILTERS",name:"Clear Active Table Filters",shortcut:[Se.CTRL,Se.SHIFT,Ee.E],macShortcut:[Se.CMD,Se.SHIFT,Ee.E]}),REVERSE:Ve.createAndAdd({id:"TABLE.REVERSE",name:"Reverse",shortcut:[Se.CTRL,Ee.I],macShortcut:[Se.CMD,Ee.I]}),TOGGLE_SEARCH:Ve.createAndAdd({id:"TABLE.TOGGLE_SEARCH",name:"Toggle Search",shortcut:[Se.CTRL,Se.SHIFT,Ee.F],macShortcut:[Se.CMD,Se.SHIFT,Ee.F]}),GOTO_ROW:Ve.createAndAdd({id:"TABLE.GOTO_ROW",name:"Go to Row",shortcut:[Se.CTRL,Ee.G],macShortcut:[Se.CMD,Ee.G]})},qw={COMMIT:Ve.createAndAdd({id:"INPUT_TABLE.COMMIT",name:"Commit",shortcut:[Se.CTRL,Ee.S],macShortcut:[Se.CMD,Ee.S]}),DISCARD:Ve.createAndAdd({id:"INPUT_TABLE.DISCARD",name:"Discard",shortcut:[Se.CTRL,Se.ALT,Ee.S],macShortcut:[Se.CMD,Se.OPTION,Ee.S]})},Xw={TABLE:Yw,INPUT_TABLE:qw},Ut=Xw;class Zw extends ei{irisGrid;constructor(e){super(),this.irisGrid=e}onDown(e){if(Ut.TABLE.REVERSE.matchesEvent(e)){if(!this.irisGrid.isReversible())return!1;const{reverseType:t}=this.irisGrid.state;return t===F.REVERSE_TYPE.NONE?this.irisGrid.reverse(F.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(F.REVERSE_TYPE.NONE),!0}return!1}}const Qw=Zw;class Jw extends ei{irisGrid;constructor(e){super(),this.irisGrid=e}onDown(e){return Ut.TABLE.CLEAR_FILTERS.matchesEvent(e)?(this.irisGrid.clearAllFilters(),!0):!1}}const ev=Jw;class tv extends at{irisGrid;constructor(e){super(850),this.irisGrid=e}destroyColumnTooltip(){this.irisGrid.setState({overflowButtonTooltipProps:null})}setCursor(e){return this.isHoveringOverflowButton(e)?(this.cursor="pointer",{stopPropagation:!1,preventDefault:!1}):(this.cursor=null,!1)}getButtonPosition({x:e,y:t,column:n,row:s}){if(n==null||s==null)return null;const{renderer:i,grid:o,state:l,props:a}=this.irisGrid;if(!o)return null;const{metrics:d}=l,{model:h}=a,{canvasContext:u}=o,m=o.getTheme(),g={context:u,mouseX:e,mouseY:t,metrics:d,model:h,theme:m},{left:p,top:C,width:f,height:S}=i.getCellOverflowButtonPosition(g);return p==null||f==null||C==null||S==null?null:{left:p,top:C,width:f,height:S}}isHoveringOverflowButton(e){const{x:t,y:n}=e,{left:s,top:i,width:o,height:l}=this.getButtonPosition(e)??{};if(s==null||o==null||i==null||l==null)return!1;const{renderer:a,grid:d,state:h,props:u}=this.irisGrid;if(!d)return!1;const{metrics:m}=h,{model:g}=u,{canvasContext:p}=d,C=d.getTheme(),f={context:p,mouseX:t,mouseY:n,metrics:m,model:g,theme:C};return a.shouldRenderOverflowButton(f)&&t>=s&&t<=s+o&&n>=i&&n<=i+l}onMove(e){if(this.isHoveringOverflowButton(e)){const{overflowButtonTooltipProps:t}=this.irisGrid.state,n=this.getButtonPosition(e);Je(t,n)||this.irisGrid.setState({overflowButtonTooltipProps:n})}else this.destroyColumnTooltip();return this.setCursor(e)}onWheel(e){return this.destroyColumnTooltip(),this.onMove(e)}onDown(e){this.destroyColumnTooltip();const{column:t,row:n}=e;return this.isHoveringOverflowButton(e)&&this.irisGrid.setState({showOverflowModal:!0,overflowText:this.irisGrid.getValueForCell(t,n)}),!1}onContextMenu(){return this.destroyColumnTooltip(),!1}onLeave(){return this.destroyColumnTooltip(),!1}}const nv=tv;class sv extends at{constructor(e){super(),this.irisGrid=e,this.cursor=null}irisGrid;isActive(){const{isSelectingColumn:e}=this.irisGrid.props;return e}isValidColumn(e){if(e==null)return!1;const{columnSelectionValidator:t}=this.irisGrid.props;return t!=null?t(e):!0}updateColumnSelectionStatus(){const{columnSelectionValidator:e}=this.irisGrid.props;e?.(null)}getTableColumn(e){if(e==null)return null;const{model:t}=this.irisGrid.props,n=this.irisGrid.getModelColumn(e);return n==null?null:t.columns[n]}onMove(e){if(!this.isActive())return!1;const{columnAllowedCursor:t,columnNotAllowedCursor:n}=this.irisGrid.props,{column:s}=e,i=this.getTableColumn(s);return this.isValidColumn(i)?(this.cursor=t,this.irisGrid.setState({hoverSelectColumn:s})):(this.cursor=n,this.irisGrid.setState({hoverSelectColumn:null})),!0}onWheel(e){if(!this.isActive())return!1;const{columnAllowedCursor:t,columnNotAllowedCursor:n}=this.irisGrid.props,{column:s}=e,i=this.getTableColumn(s);return this.isValidColumn(i)?(this.cursor=t,this.irisGrid.setState({hoverSelectColumn:s})):(this.cursor=n,this.irisGrid.setState({hoverSelectColumn:null})),{preventDefault:!1,stopPropagation:!1}}onLeave(){return this.isActive()&&this.irisGrid.setState({hoverSelectColumn:null}),this.updateColumnSelectionStatus(),!1}onDown(){return this.isActive()}onClick(e){if(!this.isActive())return!1;const{column:t}=e,n=this.getTableColumn(t);return n!=null&&this.isValidColumn(n)&&this.irisGrid.selectColumn(n),!0}}const iv=sv;class ov extends at{constructor(e){super(),this.irisGrid=e}irisGrid;hideColumnTooltip(){const{tooltip:e}=this.irisGrid;e&&(e.stopTimer(),e.hide())}onDown(){return this.hideColumnTooltip(),!1}onContextMenu(){return this.hideColumnTooltip(),!1}onWheel(){return this.hideColumnTooltip(),!1}onLeave(e,t,n){const{relatedTarget:s}=n instanceof MouseEvent?n:n.nativeEvent,{tooltip:i}=this.irisGrid;if(!i)return!1;const o=i.popper.current;return o&&s instanceof Element&&o.element.contains(s)||this.hideColumnTooltip(),!1}onMove(e){const{column:t,row:n,columnHeaderDepth:s}=e,{shownColumnTooltip:i}=this.irisGrid.state;let o=null;return t!==null&&n===null&&s===0&&(o=t),o!==i&&this.irisGrid.setState({shownColumnTooltip:o}),!1}}const lv=ov;class _r extends w.Component{static defaultProps={formatString:"",forwardedProps:{menuItem:{},closeMenu(e){},iconElement:null},placeholder:"",title:"",onChange(e){}};constructor(e=_r.defaultProps){super(e),this.handleInputChange=this.handleInputChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.inputRef=ae.createRef()}inputRef;handleInputChange(){const{onChange:e}=this.props;this.inputRef.current&&e(this.inputRef.current.value)}closeContextMenu(){const{forwardedProps:e}=this.props,{closeMenu:t}=e;t(!0)}revertToDefault(){const{onChange:e}=this.props;e(null)}returnFocusToContextMenu(){const e=mp.getClosestByClassName(this.inputRef.current,"context-menu-container");e instanceof HTMLElement&&e.focus()}handleKeyDown(e){switch(e.key){case"Enter":e.stopPropagation(),this.closeContextMenu();break;case"Escape":e.stopPropagation(),this.revertToDefault(),this.closeContextMenu();break;case"ArrowRight":case"ArrowLeft":e.stopPropagation();break;case"ArrowUp":case"ArrowDown":this.returnFocusToContextMenu();break;default:e.stopPropagation()}}render(){const{formatString:e,forwardedProps:t,placeholder:n,title:s}=this.props,{menuItem:{description:i},iconElement:o}=t;return r.jsxs("div",{className:"form-group flex-grow mb-0",children:[r.jsxs("div",{className:"custom-format-title",children:[r.jsx("span",{className:"icon",children:o}),r.jsxs("label",{className:"title mb-0",htmlFor:"custom-format-input",children:[s,i!=null&&r.jsx(tt,{children:i})]})]}),r.jsx("div",{className:"pl-2 pr-2 pb-2",children:r.jsx("input",{id:"custom-format-input",className:"form-control text-right mb-0",type:"text",defaultValue:e,ref:this.inputRef,placeholder:n,onKeyDown:this.handleKeyDown,onChange:this.handleInputChange,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false"})})]})}}const av=_r;class rv{static isDefaultSelected(e){return!e||![tl.TYPE_CONTEXT_CUSTOM,tl.TYPE_CONTEXT_PRESET].includes(e.type)}static isCustomSelected(e){return e!=null&&e.type===tl.TYPE_CONTEXT_CUSTOM}static makeOption(e,t,n,s){return{title:e,description:e,group:n,format:t,isSelected:s}}static makeCustomFormatOption(e,t,n,s,i){return{title:e.label,description:e.label,format:e,group:t,isSelected:s,menuElement:r.jsx(av,{formatString:e.formatString,title:e.label,placeholder:n,onChange:i})}}}const Vt=rv;class ln{static dateGroup=10;static timeGroup=20;static dateTimeGroup=30;static getOptions(e,t){const n=new Date,i=[{group:ln.dateGroup,formatString:"yyyy-MM-dd"},{group:ln.dateGroup,formatString:"MM-dd-yyyy"},{group:ln.timeGroup,formatString:"HH:mm:ss"},{group:ln.timeGroup,formatString:"HH:mm:ss.SSS"},{group:ln.timeGroup,formatString:"HH:mm:ss.SSSSSSSSS"},{group:ln.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss"},{group:ln.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSS"},{group:ln.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"}].map(l=>{const a=lt.makeFormat("",l.formatString,lt.TYPE_CONTEXT_PRESET),d=e.getFormattedString(n,F.dataType.DATETIME,"",a);return Vt.makeOption(d,a,l.group,lt.isSameFormat(a,t))});return[Vt.makeOption("Default",null,ln.dateGroup,Vt.isDefaultSelected(t)),...i]}}const dv=ln;class an{static defaultGroup=10;static presetGroup=20;static presetRoundGroup=30;static customGroup=40;static getOptions(e,t){const n=[{format:We.FORMAT_PERCENT,group:an.presetGroup},{format:We.FORMAT_BASIS_POINTS,group:an.presetGroup},{format:We.FORMAT_MILLIONS,group:an.presetGroup},{format:We.FORMAT_SCIENTIFIC_NOTATION,group:an.presetGroup},{format:We.FORMAT_ROUND,group:an.presetRoundGroup},{format:We.FORMAT_ROUND_TWO_DECIMALS,group:an.presetRoundGroup},{format:We.FORMAT_ROUND_FOUR_DECIMALS,group:an.presetRoundGroup}],s=Vt.makeOption("Default",null,an.defaultGroup,Vt.isDefaultSelected(e)),i=n.map(d=>Vt.makeOption(d.format.label,d.format,d.group,We.isSameFormat(d.format,e))),o=Vt.isCustomSelected(e),l=o?e:We.makeCustomFormat(),a=Vt.makeCustomFormatOption(l,an.customGroup,We.DEFAULT_FORMAT_STRING,o,d=>{if(d!=null){const h=We.makeCustomFormat(d);We.isValid(h)&&t(h)}else t(null)});return[s,...i,a]}}const cv=an;class pi{static defaultGroup=10;static presetGroup=20;static customGroup=30;static getOptions(e,t){const n=[{format:ot.FORMAT_MILLIONS,group:pi.presetGroup},{format:ot.FORMAT_SCIENTIFIC_NOTATION,group:pi.presetGroup}],s=Vt.makeOption("Default",null,pi.defaultGroup,Vt.isDefaultSelected(e)),i=n.map(d=>Vt.makeOption(d.format.label,d.format,d.group,ot.isSameFormat(d.format,e))),o=Vt.isCustomSelected(e),l=o?e:ot.makeCustomFormat(),a=Vt.makeCustomFormatOption(l,pi.customGroup,ot.DEFAULT_FORMAT_STRING,o,d=>{if(d!=null){const h=ot.makeCustomFormat(d);ot.isValid(h)&&t(h)}else t(null)});return[s,...i,a]}}const hv=pi;const Zd=ee.module("IrisGridContextMenuHandler"),uv=150,Qd="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";class Y extends at{static GROUP_EDIT=se.groups.high+10;static GROUP_HIDE_COLUMNS=se.groups.high+25;static GROUP_FILTER=se.groups.high+50;static GROUP_EXPAND_COLLAPSE=se.groups.high+55;static GROUP_GOTO=se.groups.high+60;static GROUP_SORT=se.groups.high+75;static GROUP_COPY=se.groups.high+100;static GROUP_FORMAT=se.groups.high+150;static COLUMN_SORT_DIRECTION={ascending:"ASC",descending:"DESC",none:null};static getQuickFilterCondition(e,t,n){return e&&n==="&&"?e.and(t):e&&n==="||"?e.or(t):t}static getQuickFilterText(e,t,n){return n&&e!=null?`${e} ${n} ${t}`:t}static getOperatorAsText(e){return e==="&&"?"And":"Or"}static getNumberValueEqualsFilter(e,t){const n=e.filter();if(t===Number.POSITIVE_INFINITY)return I.FilterCondition.invoke("isInf",n).and(n.greaterThan(I.FilterValue.ofNumber(0)));if(t===Number.NEGATIVE_INFINITY)return I.FilterCondition.invoke("isInf",n).and(n.lessThan(I.FilterValue.ofNumber(0)));if(Number.isNaN(t))return I.FilterCondition.invoke("isNaN",n);const s=Y.getFilterValueForNumberOrChar(e.type,t);return n.eq(s)}static getFilterValueForNumberOrChar(e,t){return F.isCharType(e)?I.FilterValue.ofString(String.fromCharCode(t)):I.FilterValue.ofNumber(t)}static getRowOptionFormatted(e,t,n=30){return`${e} "${Mt.truncate(t,n-e.length-3)}"`}irisGrid;debouncedUpdateCustomFormat;constructor(e){super(),this.debouncedUpdateCustomFormat=Ge(e.handleFormatSelection,uv),this.irisGrid=e}componentWillUnmount(){this.debouncedUpdateCustomFormat.flush()}getHeaderActions(e,t){const{irisGrid:n}=this,{column:s}=t;N(s);const{model:i}=n.props,{columns:o}=i,l=o[e],a=[],{metrics:d,reverseType:h,quickFilters:u,advancedFilters:m,searchFilter:g}=n.state,p=n.getTheme();N(d);const{filterIconColor:C,filterBarActiveColor:f,contextMenuSortIconColor:S,contextMenuReverseIconColor:v}=p,b=i.sort,T=F.getSortForColumn(b,l.name),y=h!==F.REVERSE_TYPE.NONE,{userColumnWidths:E}=d,R=[...E.values()].some(L=>L===0),x=i.getColumnHeaderParentGroup(e,0)===void 0&&!(He(i)&&i.hasExpandableRows),D=i.isColumnFrozen(e);return a.push({title:"Hide Column",group:Y.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.hideColumnByVisibleIndex(s)}}),a.push({title:D?"Unfreeze Column":"Freeze Column",group:Y.GROUP_HIDE_COLUMNS,disabled:!x,action:()=>{D?this.irisGrid.unFreezeColumnByColumnName(l.name):this.irisGrid.freezeColumnByColumnName(l.name)},order:10}),a.push({title:"Show All Columns",group:Y.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.showAllColumns()},disabled:!R}),a.push({title:"Quick Filters",icon:Ln,iconColor:f,shortcut:Ut.TABLE.TOGGLE_QUICK_FILTER,group:Y.GROUP_FILTER,order:10,action:()=>{this.irisGrid.toggleFilterBar(s)}}),a.push({title:"Advanced Filters",icon:m.get(e)?ar:rl,iconColor:C,group:Y.GROUP_FILTER,order:20,action:()=>{this.irisGrid.handleAdvancedMenuOpened(s)}}),a.push({title:"Clear Table Filters",group:Y.GROUP_FILTER,order:40,shortcut:Ut.TABLE.CLEAR_FILTERS,action:()=>{this.irisGrid.clearAllFilters()},disabled:!(u.size>0||m.size>0||g!=null)}),a.push({title:"Sort by",icon:Ln,iconColor:S,group:Y.GROUP_SORT,order:10,actions:this.sortByActions(l,e,T)}),a.push({title:"Add Additional Sort",disabled:T&&b.length===1||y&&b.length===1||T&&y&&b.length===2||b.length===0,group:Y.GROUP_SORT,order:20,actions:this.additionalSortActions(l,e)}),a.push({title:"Clear Table Sorting",disabled:b.length===0||y&&b.length===1,group:Y.GROUP_SORT,action:()=>{this.irisGrid.sortColumn(s,Y.COLUMN_SORT_DIRECTION.none)},order:30}),a.push({title:h===F.REVERSE_TYPE.NONE?"Reverse Table":"Clear Reverse Table",icon:Ln,iconColor:v,group:Y.GROUP_SORT,order:40,disabled:!i.isReversible,shortcut:Ut.TABLE.REVERSE,action:()=>{h===F.REVERSE_TYPE.NONE?this.irisGrid.reverse(F.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(F.REVERSE_TYPE.NONE)}}),a.push({title:"Copy Column Name",group:Y.GROUP_COPY,action:()=>{co(i.textForColumnHeader(e)??"").catch(L=>Zd.error("Unable to copy header",L))}}),F.isDateType(l.type)?a.push({title:"Date/Time Format",group:Y.GROUP_FORMAT,actions:this.dateFormatActions(l)}):F.isNumberType(l.type)&&a.push({title:"Number Format",group:Y.GROUP_FORMAT,actions:this.numberFormatActions(l)??void 0}),a}getCellActions(e,t,n){N(e);const{irisGrid:s}=this,{column:i,row:o}=n,{model:l,canCopy:a}=s.props,{columns:d}=l,h=s.getModelRow(o);N(h);const u=l.valueForCell(e,h),m=l.textForCell(e,h),g=d[e],p=[],{quickFilters:C}=s.state,f=s.getTheme(),{filterIconColor:S}=f,{settings:v}=s.props,b=new lt({timeZone:v?.timeZone,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:Qd}),T=new lt({timeZone:v?.timeZone,showTimeZone:v?.showTimeZone,showTSeparator:v?.showTSeparator,defaultDateTimeFormatString:Qd});if(g==null||o==null)return p;if(l.isFilterable(e)){const E={title:"Filter by Value",icon:Ln,iconColor:S,group:Y.GROUP_FILTER,order:10,actions:[]};if(u==null)C.get(e)&&E.actions.push({title:"And",actions:this.nullFilterActions(g,C.get(e),"&&"),order:2,group:se.groups.high}),E.actions.push(...this.nullFilterActions(g));else if(F.isBooleanType(g.type))C.get(e)&&E.actions.push({title:"Or",actions:this.booleanFilterActions(g,m,C.get(e),"||"),order:2,group:se.groups.high}),E.actions.push(...this.booleanFilterActions(g,m));else if(F.isNumberType(g.type)||F.isCharType(g.type)){N(e);const R=F.isCharType(g.type)?String.fromCharCode(u):`${u}`;C.get(e)&&E.actions.push({title:"And",actions:this.numberFilterActions(g,R,u,C.get(e),"&&"),order:2,group:se.groups.high}),E.actions.push(...this.numberFilterActions(g,R,u,C.get(e)))}else if(F.isDateType(g.type)){const R=b.format(u),x=T.format(u);C.get(e)&&E.actions.push({title:"And",actions:this.dateFilterActions(g,R,x,u,C.get(e),"&&"),order:2,group:se.groups.high}),E.actions.push(...this.dateFilterActions(g,R,x,u,C.get(e)))}else C.get(e)&&E.actions.push({title:"And",actions:this.stringFilterActions(g,m,u,C.get(e),"&&"),order:2,group:se.groups.high}),E.actions.push(...this.stringFilterActions(g,m,u));E.actions!=null&&E.actions.length>0&&p.push(E)}if(He(l)&&l.isRowExpandable(h)){const E=l.groupedColumns.length>0?l.depthForRow(h)-1:0,x=l.valueForCell(E,h)==null?"null":l.textForCell(E,h);p.push({title:Y.getRowOptionFormatted(l.isRowExpanded(h)?"Collapse":"Expand",x),group:Y.GROUP_EXPAND_COLLAPSE,order:10,action:()=>{l.setRowExpanded(h,!l.isRowExpanded(h))}}),l.isExpandAllAvailable===!0&&p.push({title:Y.getRowOptionFormatted("Expand All in",x),group:Y.GROUP_EXPAND_COLLAPSE,order:20,action:()=>{l.setRowExpanded(h,!0,!0)}})}He(l)&&l.hasExpandableRows&&l.isExpandAllAvailable===!0&&(p.push({title:"Expand Entire Table",group:Y.GROUP_EXPAND_COLLAPSE,order:30,action:()=>{l.expandAll()}}),p.push({title:"Collapse Entire Table",group:Y.GROUP_EXPAND_COLLAPSE,order:40,action:()=>{l.collapseAll()}}));const y={title:"Go to",iconColor:S,shortcut:Ut.TABLE.GOTO_ROW,group:Y.GROUP_GOTO,order:10,action:()=>this.irisGrid.toggleGotoRow(`${o+1}`,`${u}`,g.name)};return p.push(y),a&&(p.push({title:"Copy Cell",group:Y.GROUP_COPY,order:10,action:()=>{s.copyCell(i,o)}}),p.push({title:"Copy Cell Unformatted",group:Y.GROUP_COPY,order:20,action:()=>{s.copyCell(i,o,!0)}})),p}onContextMenu(e,t,n){const{irisGrid:s}=this,{y:i,column:o,row:l,columnHeaderDepth:a}=e,d=s.getModelColumn(o),h=s.getModelRow(l),{model:u,canCopy:m}=s.props,{columns:g}=u,{metrics:p,isFilterBarShown:C,quickFilters:f,advancedFilters:S,selectedRanges:v}=s.state;N(p);const{columnHeaderHeight:b,gridY:T,columnHeaderMaxDepth:y}=p,E=[];if(d!=null&&h!=null){const R=u.valueForCell(d,h),x=u.textForCell(d,h),D=g[d],{onContextMenu:L}=s.props;D!=null&&E.push(L({model:u,value:R,valueText:x,column:D,rowIndex:l,columnIndex:o,modelRow:h,modelColumn:d}))}return d!=null&&u.isFilterable(d)&&E.push({title:"Clear Column Filter",group:Y.GROUP_FILTER,order:30,action:()=>{this.irisGrid.removeColumnFilter(d)},disabled:!(f.has(d)||S.has(d))}),(C?i<=T:i<=b*y&&a===0)?d!=null&&E.push(...this.getHeaderActions(d,e)):(d!=null&&h!=null&&E.push(...this.getCellActions(d,t,e)),m&&v.length>0&&(E.push({title:"Copy Selection",shortcut:qn.COPY,group:Y.GROUP_COPY,order:30,action:()=>{s.copyRanges(v)}}),E.push({title:"Copy Selection w/ Headers",group:Y.GROUP_COPY,order:40,action:()=>{s.copyRanges(v,!0)}})),Ke(u)&&u.isEditable&&v.length>0&&E.push({title:"Delete Selected Rows",group:Y.GROUP_EDIT,order:50,action:()=>{this.irisGrid.deleteRanges(v)}})),E.length===0?!1:(N(s.gridWrapper),se.triggerMenu(s.gridWrapper,n.clientX,n.clientY,E),!0)}dateFormatActions(e){const{model:t}=this.irisGrid.props,{formatter:n}=t,s=n.getColumnFormat(e.type,e.name),i=dv.getOptions(n,s),o=[];for(let l=0;l<i.length;l+=1){const{description:a,format:d,group:h,isSelected:u,title:m}=i[l];o.push({title:m,description:a,icon:u?Yn:void 0,group:h,order:l,action:()=>{const g=t.getColumnIndexByName(e.name);N(g),this.irisGrid.handleFormatSelection(g,d)}})}return o}numberFormatActions(e){const{model:t}=this.irisGrid.props,{formatter:n}=t,s=n.getColumnFormat(e.type,e.name);let i;const o=t.getColumnIndexByName(e.name);if(F.isDecimalType(e.type))i=cv.getOptions(s,a=>{N(o),this.debouncedUpdateCustomFormat(o,a)});else if(F.isIntegerType(e.type))i=hv.getOptions(s,a=>{N(o),this.debouncedUpdateCustomFormat(o,a)});else return Zd.error("Invalid column type in numberFormatActions"),null;const l=[];for(let a=0;a<i.length;a+=1){const{format:d,isSelected:h}=i[a];l.push({...i[a],icon:h?Yn:void 0,order:a,action:()=>{o===void 0&&d&&d.type===tl.TYPE_CONTEXT_CUSTOM||(N(o),this.irisGrid.handleFormatSelection(o,d))}})}return l}stringFilterActions(e,t,n,s,i){const o=I.FilterValue.ofString(n);let l=s;l||(l={filter:null,text:null});const{filter:a,text:d}=l,h=[],{model:u}=this.irisGrid.props,m=u.getColumnIndexByName(e.name);return N(m),h.push({menuElement:r.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[i?Y.getOperatorAsText(i):""," ",'"',t,'"']}),order:1,group:se.groups.high}),h.push({title:"text is exactly",description:`Show only rows where ${e.name} is ${n} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(a,e.filter().eq(o),i),Y.getQuickFilterText(d,`=${t}`,i))},order:10,group:se.groups.low}),h.push({title:"text is not exactly",description:`Show only rows where ${e.name} is not ${t} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(a,e.filter().notEq(o),i),Y.getQuickFilterText(d,`!=${t}`,i))},order:20,group:se.groups.low}),h.push({title:"text contains",description:`Show only rows where ${e.name} contains ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(a,e.filter().contains(o),i),Y.getQuickFilterText(d,`~${t}`,i))},order:30,group:se.groups.low}),h.push({title:"text does not contain",description:`Show only rows where ${e.name} does not contain ${n}`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(a,e.filter().contains(o).not(),i),Y.getQuickFilterText(d,`!~${t}`,i))},order:40,group:se.groups.low}),h.push({title:"text starts with",description:`Show only rows where ${e.name} starts with ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(a,e.filter().invoke("startsWith",o),i),Y.getQuickFilterText(d,`${t}*`,i))},order:50,group:se.groups.low}),h.push({title:"text ends with",description:`Show only rows where ${e.name} ends with ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(a,e.filter().invoke("endsWith",o),i),Y.getQuickFilterText(d,`*${t}`,i))},order:60,group:se.groups.low}),h}numberFilterActions(e,t,n,s,i){const o=Y.getFilterValueForNumberOrChar(e.type,n);let l=null,a=null;s&&(l=s.filter,a=s.text);const d=[],h=n!==Number.POSITIVE_INFINITY&&n!==Number.NEGATIVE_INFINITY&&!Number.isNaN(n),{model:u}=this.irisGrid.props,m=u.getColumnIndexByName(e.name);return N(m),d.push({menuElement:r.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[i?Y.getOperatorAsText(i):""," ",'"',t,'"']}),order:1,group:se.groups.high}),d.push({title:"is equal to",description:`Show only rows where ${e.name} is ${t}`,action:()=>{const g=Y.getNumberValueEqualsFilter(e,n);this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(l,g,i),Y.getQuickFilterText(a,`=${t}`,i))},order:10,group:se.groups.low}),d.push({title:"is not equal to",description:`Show only rows where ${e.name} is not ${t}`,action:()=>{const g=Y.getNumberValueEqualsFilter(e,n).not();this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(l,g,i),Y.getQuickFilterText(a,`!=${t}`,i))},order:20,group:se.groups.low}),h&&!F.isCharType(e.type)&&(d.push({title:"greater than",description:`Show only rows where ${e.name} is greater than ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(l,e.filter().greaterThan(o),i),Y.getQuickFilterText(a,`>${t}`,i))},order:30,group:se.groups.low}),d.push({title:"greater than or equal to",description:`Show only rows where ${e.name} is greater than or equal to ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(l,e.filter().greaterThanOrEqualTo(o),i),Y.getQuickFilterText(a,`>=${t}`,i))},order:40,group:se.groups.low}),d.push({title:"less than",description:`Show only rows where ${e.name} is less than ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(l,e.filter().lessThan(o),i),Y.getQuickFilterText(a,`<${t}`,i))},order:50,group:se.groups.low}),d.push({title:"less than or equal to",description:`Show only rows where ${e.name} is less than or equal to ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(l,e.filter().lessThanOrEqualTo(o),i),Y.getQuickFilterText(a,`<=${t}`,i))},order:60,group:se.groups.low})),d}booleanFilterActions(e,t,n,s){const i=[],{model:o}=this.irisGrid.props,{filter:l,text:a}=n||{},d=o.getColumnIndexByName(e.name);return N(d),i.push({menuElement:r.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[s?Y.getOperatorAsText(s):""," ",'"',t??"null",'"']}),order:1,group:se.groups.high}),i.push({title:"true",description:`Show only rows where ${e.name} is true`,action:()=>{this.irisGrid.setQuickFilter(d,Y.getQuickFilterCondition(l,e.filter().isTrue(),s),Y.getQuickFilterText(a,"true",s))},order:10,group:se.groups.low}),i.push({title:"false",description:`Show only rows where ${e.name} is false`,action:()=>{this.irisGrid.setQuickFilter(d,Y.getQuickFilterCondition(l,e.filter().isFalse(),s),Y.getQuickFilterText(a,"false",s))},order:20,group:se.groups.low}),i.push({title:"is null",description:`Show only rows where ${e.name} is null`,action:()=>{this.irisGrid.setQuickFilter(d,Y.getQuickFilterCondition(l,e.filter().isNull(),s),Y.getQuickFilterText(a,"null",s))},order:30,group:se.groups.low}),i.push({title:"is not null",description:`Show only rows where ${e.name} is not null`,action:()=>{this.irisGrid.setQuickFilter(d,Y.getQuickFilterCondition(l,e.filter().isNull().not(),s),Y.getQuickFilterText(a,"!null",s))},order:40,group:se.groups.low}),i}dateFilterActions(e,t,n,s,i,o){const l=I.FilterValue.ofNumber(s);let a=null,d=null;i&&(a=i.filter,d=i.text);const{model:h}=this.irisGrid.props,u=h.getColumnIndexByName(e.name);N(u);const m=[];return m.push({menuElement:r.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[o?Y.getOperatorAsText(o):""," ",'"',n,'"']}),order:1,group:se.groups.high}),m.push({title:"date is",description:`Show only rows where ${e.name} is ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,Y.getQuickFilterCondition(a,e.filter().eq(l),o),Y.getQuickFilterText(d,`=${t}`,o))},order:10,group:se.groups.low}),m.push({title:"date is not",description:`Show only rows where ${e.name} is not ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,Y.getQuickFilterCondition(a,e.filter().notEq(l),o),Y.getQuickFilterText(d,`!=${t}`,o))},order:20,group:se.groups.low}),m.push({title:"date is before",description:`Show only rows where ${e.name} is before ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,Y.getQuickFilterCondition(a,e.filter().lessThan(l),o),Y.getQuickFilterText(d,`<${t}`,o))},order:30,group:se.groups.low}),m.push({title:"date is before or equal",description:`Show only rows where ${e.name} is before or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,Y.getQuickFilterCondition(a,e.filter().lessThanOrEqualTo(l),o),Y.getQuickFilterText(d,`<=${t}`,o))},order:40,group:se.groups.low}),m.push({title:"date is after",description:`Show only rows where ${e.name} is greater than ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,Y.getQuickFilterCondition(a,e.filter().greaterThan(l),o),Y.getQuickFilterText(d,`>${t}`,o))},order:50,group:se.groups.low}),m.push({title:"date is after or equal",description:`Show only rows where ${e.name} is after or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,Y.getQuickFilterCondition(a,e.filter().greaterThanOrEqualTo(l),o),Y.getQuickFilterText(d,`>=${t}`,o))},order:60,group:se.groups.low}),m}nullFilterActions(e,t,n){let s=null,i=null;t&&(s=t.filter,i=t.text);const o=[],{model:l}=this.irisGrid.props,a=l.getColumnIndexByName(e.name);return N(a),o.push({menuElement:r.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[n?Y.getOperatorAsText(n):""," ",'"null"']}),order:1,group:se.groups.high}),o.push({title:"is null",description:`Show only rows where ${e.name} is null`,action:()=>{this.irisGrid.setQuickFilter(a,Y.getQuickFilterCondition(s,e.filter().isNull(),n),Y.getQuickFilterText(i,"null",n))},order:10,group:se.groups.low}),o.push({title:"is not null",description:`Show only rows where ${e.name} is not null`,action:()=>{this.irisGrid.setQuickFilter(a,Y.getQuickFilterCondition(s,e.filter().isNull().not(),n),Y.getQuickFilterText(i,"!null",n))},order:20,group:se.groups.low}),o}sortByActions(e,t,n){const s=this.irisGrid.getTheme(),{contextMenuSortIconColor:i}=s,o=[{title:`${e.name} Ascending`,order:10,action:()=>{this.irisGrid.sortColumn(t,Y.COLUMN_SORT_DIRECTION.ascending)},icon:this.checkColumnSort(n,Y.COLUMN_SORT_DIRECTION.ascending)?Ln:void 0,iconColor:i},{title:`${e.name} Descending`,order:20,action:()=>{this.irisGrid.sortColumn(t,Y.COLUMN_SORT_DIRECTION.descending)},icon:this.checkColumnSort(n,Y.COLUMN_SORT_DIRECTION.descending)?Ln:void 0,iconColor:i},{title:"Remove Sort",order:50,action:()=>{this.irisGrid.sortColumn(t,Y.COLUMN_SORT_DIRECTION.none,!1,!0)},disabled:!n}];return F.isNumberType(e.type)&&(o.push({title:`ABS(${e.name}) Ascending`,order:30,action:()=>{this.irisGrid.sortColumn(t,Y.COLUMN_SORT_DIRECTION.ascending,!0)},icon:this.checkColumnSort(n,Y.COLUMN_SORT_DIRECTION.ascending,!0)?Ln:void 0,iconColor:i}),o.push({title:`ABS(${e.name}) Descending`,order:40,action:()=>{this.irisGrid.sortColumn(t,Y.COLUMN_SORT_DIRECTION.descending,!0)},icon:this.checkColumnSort(n,Y.COLUMN_SORT_DIRECTION.descending,!0)?Ln:void 0,iconColor:i})),o}additionalSortActions(e,t){const n=this.irisGrid.getTheme(),{contextMenuSortIconColor:s}=n,i=[{title:"Add Sort By",menuElement:r.jsxs("div",{className:"btn-context-menu menu-title",children:[r.jsx("span",{className:"icon",children:r.jsx(X,{icon:Ln,style:{color:s??void 0}})}),r.jsx("span",{className:"title",children:"Add Additional Sort"}),r.jsx("span",{className:"shortcut",children:Es.isMacPlatform()?"⌘Click":"Ctrl+Click"})]}),order:1},{title:`${e.name} Ascending`,order:10,action:()=>{this.irisGrid.sortColumn(t,Y.COLUMN_SORT_DIRECTION.ascending,!1,!0)}},{title:`${e.name} Descending`,order:20,action:()=>{this.irisGrid.sortColumn(t,Y.COLUMN_SORT_DIRECTION.descending,!1,!0)}}];return F.isNumberType(e.type)&&(i.push({title:`ABS(${e.name}) Ascending`,order:30,action:()=>{this.irisGrid.sortColumn(t,Y.COLUMN_SORT_DIRECTION.ascending,!0,!0)}}),i.push({title:`ABS(${e.name}) Descending`,order:40,action:()=>{this.irisGrid.sortColumn(t,Y.COLUMN_SORT_DIRECTION.descending,!0,!0)}})),i}checkColumnSort(e,t=null,n=!1){return e?e.direction===t&&e.isAbs===n:!1}}const mv=Y;class gv extends at{constructor(e){super(),this.irisGrid=e}irisGrid;onDoubleClick(e){const{column:t,row:n}=e;return n==null||t==null?!1:(this.irisGrid.selectData(t,n),!0)}}const pv=gv;class fv extends at{constructor(e){super(),this.irisGrid=e}irisGrid;onDown(e){const{y:t,column:n,row:s}=e;if(n!==null&&s===null){const{isFilterBarShown:i,metrics:o}=this.irisGrid.state;if(!o)throw new Error("Metrics not set");const{columnHeaderMaxDepth:l}=o,a=this.irisGrid.getTheme();if(i&&a.columnHeaderHeight!=null&&a.filterBarHeight!=null&&t>a.columnHeaderHeight*l&&t<=a.columnHeaderHeight*l+a.filterBarHeight)return this.irisGrid.focusFilterBar(n),!0}return!1}onMove(e){const{y:t,column:n}=e,{isFilterBarShown:s,hoverAdvancedFilter:i,metrics:o}=this.irisGrid.state;if(!o)throw new Error("Metrics not set");const{columnHeaderMaxDepth:l}=o,a=this.irisGrid.getTheme();let d=null;return s&&a.columnHeaderHeight!=null&&a.filterBarHeight!=null&&n!==null&&t>=a.columnHeaderHeight*l&&t<=a.columnHeaderHeight*l+a.filterBarHeight&&(d=n),d!==i&&this.irisGrid.setState({hoverAdvancedFilter:d}),!1}onLeave(e){const{column:t}=e,{hoverAdvancedFilter:n}=this.irisGrid.state;return n!==null&&t!==n&&this.irisGrid.setState({hoverAdvancedFilter:null}),!1}}const Cv=fv;class Sv extends at{irisGrid;constructor(e){super(750),this.irisGrid=e}destroyTooltip(){this.irisGrid.setState({expandCellTooltipProps:null})}setCursor(e,t){return Ya.isInTreeBox(e,t)?(this.cursor="pointer",{stopPropagation:!1,preventDefault:!1}):(this.cursor=null,!1)}getButtonPosition({x:e,y:t,column:n,row:s}){if(n==null||s==null)return null;const{renderer:i,grid:o,state:l,props:a}=this.irisGrid;if(!o)return null;const{metrics:d}=l,{model:h}=a,{canvasContext:u}=o,m=o.getTheme(),g={context:u,mouseX:e,mouseY:t,metrics:d,model:h,theme:m},p=He(h)?h.depthForRow(s):null,{left:C,top:f,width:S,height:v}=i.getExpandButtonPosition(g,p);return C==null||S==null||f==null||v==null?null:{left:C,top:f,width:S,height:v}}onMove(e,t){if(Ya.isInTreeBox(e,t)){const{expandCellTooltipProps:n}=this.irisGrid.state,{model:s}=this.irisGrid.props,i=this.getButtonPosition(e),{row:o}=e;N(o);const l=He(s)&&s.isRowExpanded(o);Je(n,i)||this.irisGrid.setState({expandCellTooltipProps:i,expandTooltipDisplayValue:l?"collapse":"expand"})}else this.destroyTooltip();return this.setCursor(e,t)}onDown(){return this.destroyTooltip(),!1}onContextMenu(){return this.destroyTooltip(),!1}onWheel(){return this.destroyTooltip(),!1}onLeave(){return this.destroyTooltip(),!1}}const bv=Sv;class wv extends at{constructor(e){super(),this.column=null,this.irisGrid=e}irisGrid;column;getColumnFromGridPoint(e){const{column:t,row:n,columnHeaderDepth:s}=e;return t!==null&&n===null&&s===0?t:null}onDown(e){return this.column=this.getColumnFromGridPoint(e),!1}onClick(e,t,n){const s=this.getColumnFromGridPoint(e);if(s!=null&&s===this.column){const i=Es.isModifierKeyDown(n);return this.irisGrid.toggleSort(s,i),!0}return!1}}const vv=wv;class Tv extends at{constructor(e){super(),this.irisGrid=e}onWheel(e,t,n){const{irisGrid:s}=this,{model:i}=s.props,{metrics:o,pendingRowCount:l}=s.state;N(o);const{bottom:a,rowCount:d,rowHeight:h}=o,{deltaY:u}=O.getScrollDelta(n);return Ke(i)&&i.isEditable&&a>=d-1&&u>0&&s.setState({pendingRowCount:l+Math.ceil(u/h)}),!1}}const Ev=Tv;class yv extends at{irisGrid;currentLinkBox;constructor(e){super(),this.irisGrid=e}destroyTooltip(){this.irisGrid.setState({linkHoverTooltipProps:null})}isHoveringLink(e,t){const{column:n,row:s,x:i,y:o}=e,{renderer:l,metrics:a}=t;if(n==null||s==null||a==null)return this.currentLinkBox=void 0,!1;if(this.currentLinkBox!=null){const{x1:u,y1:m,x2:g,y2:p}=this.currentLinkBox;if(i>=u&&i<=g&&o>=m&&o<=p)return!0}const d=t.updateRenderState(),h=l.getTokenBoxesForVisibleCell(n,s,d);for(let u=0;u<h.length;u+=1)if(bl(h[u].token)){const m=O.translateTokenBox(h[u],a),{x1:g,x2:p,y1:C,y2:f}=m;if(i>=g&&i<=p&&o>=C&&o<=f)return this.currentLinkBox=m,!0}return this.currentLinkBox=void 0,!1}setCursor(e,t){return this.isHoveringLink(e,t)?(this.cursor="pointer",{stopPropagation:!1,preventDefault:!1}):(this.cursor=null,!1)}onMove(e,t){if(this.isHoveringLink(e,t)&&this.currentLinkBox!=null&&bl(this.currentLinkBox.token)){const{linkHoverTooltipProps:s}=this.irisGrid.state;if(this.currentLinkBox==null)return!1;const{x1:i,y1:o,x2:l,y2:a}=this.currentLinkBox,{href:d}=this.currentLinkBox.token,h=l-i,u=a-o,m={left:i,top:o+1,width:h,height:u};Je(s,m)||this.irisGrid.setState({linkHoverTooltipProps:m,linkHoverDisplayValue:d})}else this.destroyTooltip();return this.setCursor(e,t)}onDown(){return this.destroyTooltip(),!1}onContextMenu(){return this.destroyTooltip(),!1}onWheel(){return this.destroyTooltip(),!1}onLeave(){return this.destroyTooltip(),!1}}const Rv=yv,xv=3e3;function Iv({children:c=null,onEntering:e,onEntered:t,onExiting:n,onExited:s}){const[i,o]=w.useState(!1),l=w.useRef(),a=sr(c),d=w.useCallback(()=>{o(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{o(!1)},xv)},[o,l]);return w.useEffect(()=>{a!==c&&c!=null&&d()},[c,a,o,d]),w.useEffect(()=>()=>l.current?clearTimeout(l.current):void 0,[]),r.jsx(ta,{className:"toast-bottom-bar",isShown:i,onEntering:e,onEntered:t,onExiting:n,onExited:s,children:c})}class Dv extends Co{getGridY(e){let t=super.getGridY(e);const{isFilterBarShown:n,theme:s,advancedFilters:i,quickFilters:o,sorts:l,reverseType:a}=e;return n?t+=s.filterBarHeight:(o!=null&&o.size>0||i!=null&&i.size>0)&&(t+=s.filterBarCollapsedHeight),a!==F.REVERSE_TYPE.NONE&&l!=null&&l.length>0&&(t+=s.reverseHeaderBarHeight),t}getUserColumnWidths(){return this.userColumnWidths}}const Fv=Dv,Nv=1,Cu=ae.memo(({model:c,modelColumns:e,top:t,bottom:n,left:s,right:i,filter:o,formatter:l,reverseType:a=F.REVERSE_TYPE.NONE,sorts:d,customColumns:h,movedColumns:u,hiddenColumns:m,alwaysFetchColumns:g,rollupConfig:p=null,totalsConfig:C=null,selectDistinctColumns:f=Fe,pendingRowCount:S=0,pendingDataMap:v=jn,frozenColumns:b,formatColumns:T,columnHeaderGroups:y})=>{const E=w.useMemo(()=>Ce.getModelViewportColumns(e,s,i,u,m,g,Nv),[e,s,i,u,m,g]);return w.useEffect(function(){c.filter=o},[c,o]),w.useEffect(function(){const x=[...d];a!==F.REVERSE_TYPE.NONE&&x.push(I.Table.reverse()),c.sort=x},[c,d,a]),w.useEffect(function(){c.formatter=l},[c,l]),w.useEffect(function(){c.isCustomColumnsAvailable&&(c.customColumns=h)},[c,h]),w.useEffect(function(){c.isFormatColumnsAvailable&&(c.formatColumns=T)},[c,T]),w.useEffect(function(){c.setViewport(t,n,E)},[c,t,n,E]),w.useEffect(function(){c.isRollupAvailable&&(c.rollupConfig=p)},[c,c.isRollupAvailable,p]),w.useEffect(function(){c.isSelectDistinctAvailable&&(c.selectDistinctColumns=f)},[c,f]),w.useEffect(function(){c.isTotalsAvailable&&(c.totalsConfig=C)},[c,c.isTotalsAvailable,C]),w.useEffect(function(){c.pendingRowCount=S},[c,S]),w.useEffect(function(){c.pendingDataMap=v},[c,v]),w.useEffect(function(){b&&c.updateFrozenColumns(b)},[c,b]),w.useEffect(function(){c.columnHeaderGroups=y},[c,y]),null});Cu.displayName="IrisGridModelUpdater";const kv=Cu,wn=Object.freeze({SORT_UP:"sortUp",SORT_DOWN:"sortDown",CARET_DOWN:"caretDown",CARET_RIGHT:"caretRight",CELL_OVERFLOW:"cellOverflow"}),Jd=10,Ta=16;class Qi extends Mt{static isFilterValid(e,t){const n=e==null||e.filter!=null,s=t==null||t.filter!=null;return n&&s}constructor(){super(),this.icons={},this.initIcons()}icons;initIcons(){this.setIcon(wn.SORT_UP,sg),this.setIcon(wn.SORT_DOWN,ig),this.setIcon(wn.CARET_DOWN,$n),this.setIcon(wn.CARET_RIGHT,Yc),this.setIcon(wn.CELL_OVERFLOW,og)}setIcon(e,t){const n=Array.isArray(t.icon[4])?t.icon[4][0]:t.icon[4],s=new Path2D(n),i=new Path2D,o={a:Ta/t.icon[0],d:Ta/t.icon[1]};i.addPath(s,o),this.icons[e]=i}getIcon(e){return this.icons[e]}getSortIcon(e){return e?e.direction===F.sortDirection.ascending?this.getIcon(wn.SORT_UP):e.direction===F.sortDirection.descending?this.getIcon(wn.SORT_DOWN):null:null}drawCanvas(e){super.drawCanvas(e),this.drawScrim(e)}drawGrid(e,t){super.drawGrid(e,t),this.drawCellOverflowButton(t)}drawGridLines(e,t){super.drawGridLines(e,t),this.drawGroupedColumnLine(e,t),this.drawPendingRowLine(e,t)}drawCellContent(e,t,n,s){const{metrics:i,model:o}=t,{modelColumns:l,modelRows:a}=i,d=k(a,s),h=l.get(n);if(h===void 0)return;const u=o.valueForCell(h,d);if(F.isTextType(o.columns[h]?.type)&&(u===null||u==="")){const m=e.font;e.font=`italic ${m}`;const g=u===null?"null":"empty";super.drawCellContent(e,t,n,s,g),e.font=m;return}super.drawCellContent(e,t,n,s)}drawGroupedColumnLine(e,t){const{metrics:n,model:s,theme:i}=t,{groupedColumns:o}=s,{maxY:l,allColumnWidths:a,allColumnXs:d}=n;if(o.length===0||i.groupedColumnDividerColor==null)return;const h=o.length-1,u=d.get(h),m=a.get(h);if(u==null||m==null)return;const g=u+m+.5;e.strokeStyle=i.groupedColumnDividerColor,e.lineWidth=1,e.beginPath(),e.moveTo(g,0),e.lineTo(g,l),e.stroke()}drawPendingRowLine(e,t){const{metrics:n,model:s,theme:i}=t,{allRowYs:o,maxX:l}=n,{pendingRowCount:a}=s;if(a<=0)return;const d=s.rowCount-s.pendingRowCount-s.floatingBottomRowCount;let h=o.get(d);h!=null&&(h-=.5,e.save(),e.setLineDash([4,2]),e.strokeStyle=i.pendingTextColor,e.lineWidth=1,e.beginPath(),e.moveTo(0,h),e.lineTo(l,h),e.stroke(),e.restore())}drawMouseColumnHover(e,t){const{theme:n,metrics:s,hoverSelectColumn:i}=t;if(i==null||n.linkerColumnHoverBackgroundColor==null)return;const{allColumnWidths:o,allColumnXs:l,maxY:a}=s,d=k(l,i),h=k(o,i);e.fillStyle=n.linkerColumnHoverBackgroundColor,e.fillRect(d,0,h,a)}drawMouseRowHover(e,t){const{isSelectingColumn:n}=t;n||super.drawMouseRowHover(e,t)}drawScrim(e){const{context:t,loadingScrimProgress:n,metrics:s,theme:i}=e;if(n==null)return;const{width:o,height:l,gridY:a}=s,{scrimBlurSize:d,scrimColor:h}=i;t.save(),t.globalCompositeOperation="color",t.filter=`blur(${d}px)`,h!=null&&(t.fillStyle=h),t.beginPath(),t.rect(0,a,o,l-a),t.clip(),t.fillRect(-d,-d+a,d*2+o,(d*2+(l-a))*n),t.globalCompositeOperation="overlay",t.filter=`blur(${d}px) opacity(15%)`,t.fillRect(-d,-d+a,d*2+o,(d*2+(l-a))*n),t.restore()}drawColumnHeaders(e,t){super.drawColumnHeaders(e,t);const{theme:n,metrics:s,model:i,reverseType:o}=t,{columnHeaderHeight:l}=s;if(this.drawFilterHeaders(e,t),l<=0)return;const{sort:a}=i;if(a.length===1){const d=o!==F.REVERSE_TYPE.NONE;let h;d?h=n.headerReverseBarColor:h=n.headerSortBarColor,this.drawHeaderBar(e,t,h,d?n.reverseHeaderBarHeight:n.sortHeaderBarHeight)}else a.length>1&&(o!==F.REVERSE_TYPE.NONE&&this.drawHeaderBar(e,t,n.headerReverseBarColor,n.reverseHeaderBarHeight,!1),this.drawHeaderBar(e,t,n.headerSortBarColor,n.sortHeaderBarHeight))}drawHeaderBar(e,t,n,s,i=!0){const{theme:o,metrics:l,model:a}=t,{columnHeaderHeight:d,width:h}=l;let u=0;i||(u=s),e.fillStyle=o.headerBarCasingColor,e.fillRect(0,a.columnHeaderMaxDepth*d-s-2+u,h,s+2),e.fillStyle=n,e.fillRect(0,a.columnHeaderMaxDepth*d-s-1+u,h,s)}drawColumnHeadersAtDepth(e,t,n,s,i){const{metrics:o,model:l,isMenuShown:a}=t,{columnHeaderMaxDepth:d}=l,{width:h}=o,u={...s,maxX:i===d-1&&s.maxX===h?h-(a?0:30):s.maxX};super.drawColumnHeadersAtDepth(e,t,n,u,i)}drawColumnHeaderAtIndex(e,t,n,s){super.drawColumnHeaderAtIndex(e,t,n,s);const{metrics:i,model:o,theme:l}=t,{modelColumns:a,allColumnWidths:d,allColumnXs:h,gridX:u,columnHeaderHeight:m,fontWidths:g}=i,{headerHorizontalPadding:p}=l,C=k(d,n,0),f=k(h,n)+u,S=a.get(n);if(S==null)return;const v=o.columns[S]?.name;if(v==null)return;const b=F.getSortForColumn(o.sort,v);if(!b)return;const T=this.getSortIcon(b);if(!T)return;const y=o.textForColumnHeader(S);if(y===void 0)return;const E=g.get(e.font)??Mt.DEFAULT_FONT_WIDTH;N(E);const R=y.length*E,x=u+f+R+p;let{maxX:D}=s;D-=p;const L=u+f+C-p-1,M=x>D?x+1:Math.min(D,L),j=b.direction===F.sortDirection.ascending?-6:-12,A=m*.5+j;e.save(),e.beginPath(),e.rect(f,0,C,m),e.clip(),e.fillStyle=l.headerSortBarColor,e.translate(M,A),e.fill(T),e.restore()}drawFilterHeaders(e,t){const{isFilterBarShown:n,quickFilters:s,advancedFilters:i}=t;n?this.drawExpandedFilterHeaders(e,t):(s!=null&&s.size>0||i!=null&&i.size>0)&&this.drawCollapsedFilterHeaders(e,t)}drawExpandedFilterHeaders(e,t){const{metrics:n,model:s,theme:i,quickFilters:o,advancedFilters:l}=t,{filterBarHeight:a}=i;if(a<=0)return;const{gridX:d,gridY:h,maxX:u,modelColumns:m,visibleColumns:g,allColumnWidths:p,allColumnXs:C}=n,f=h-a;e.save(),e.font=i.font,e.textAlign="left",o!=null&&o.size>0||l!=null&&l.size>0?e.fillStyle=i.filterBarExpandedActiveBackgroundColor:e.fillStyle=i.filterBarExpandedBackgroundColor,e.fillRect(d,f,u,a-1),e.fillStyle=i.headerBarCasingColor,e.fillRect(d,f+a-1,u,1);const S=f;e.strokeStyle=i.filterBarSeparatorColor,e.beginPath();for(let v=0;v<g.length;v+=1){const b=g[v],T=k(m,b),y=k(C,b),E=k(p,b);if(s.isFilterable(T)&&E>0){const R=d+(y??0);e.rect(R+.5,S+.5,E,a-2)}}e.stroke();for(let v=0;v<g.length;v+=1){const b=g[v],T=k(p,b),E=k(C,b)+d;this.drawExpandedFilterHeader(e,t,b,E,T)}e.restore()}drawExpandedFilterHeader(e,t,n,s,i){if(i<=0)return;const{metrics:o,theme:l,quickFilters:a,advancedFilters:d}=t,{modelColumns:h,gridY:u}=o,{filterBarHeight:m,filterBarExpandedActiveCellBackgroundColor:g,filterBarErrorColor:p,filterBarHorizontalPadding:C,headerColor:f}=l,S=u-m,v=h.get(n);if(v===void 0)return;const b=a.get(v),T=d.get(v);if(b==null&&T==null)return;let y=null;if(b!=null){const{text:R}=b;if(y=R,y||(y=F.getFilterText(b.filter)),y!=null){const{fontWidths:x}=o;let D=x.get(e.font);(D==null||D===0)&&(D=e.measureText("8").width,D||(D=10));const L=(i-C*2)/D;L<=0?y="":y.length>L&&(y=`${y.substring(0,L-1)}…`)}}if(e.save(),Qi.isFilterValid(T,b)&&g!=null)e.fillStyle=g,e.fillRect(s+1,S+1,i-1,m-3);else if(p!=null){e.fillStyle=p,e.lineWidth=2,e.strokeStyle=p;const R=s+2,x=S+2,D=i-3,L=m-5;e.strokeRect(R,x,D,L)}if(y!=null&&y!==""){const R=s+C,x=S+m*.5+1;e.fillStyle=f,e.fillText(y,R,x)}e.restore()}drawCollapsedFilterHeaders(e,t){const{metrics:n,theme:s}=t,{headerSeparatorColor:i,filterBarCollapsedHeight:o}=s;if(o<=0)return;const{gridX:l,gridY:a,maxX:d,visibleColumns:h,allColumnWidths:u,allColumnXs:m}=n,g=a-o;e.save(),e.fillStyle=i,e.fillRect(l,g,d,o);for(let p=0;p<h.length;p+=1){const C=h[p],f=u.get(C),S=m.get(C);if(S!=null&&f!=null){const v=S+l;this.drawCollapsedFilterHeader(e,t,C,v,f)}}e.restore()}drawCollapsedFilterHeader(e,t,n,s,i){if(i<=0)return;const{metrics:o,theme:l,quickFilters:a,advancedFilters:d}=t,{modelColumns:h,gridY:u}=o,m=h.get(n);if(m===void 0)return;const g=a.get(m),p=d.get(m),{filterBarCollapsedHeight:C,filterBarActiveColor:f,filterBarActiveBackgroundColor:S,filterBarErrorColor:v}=l;e.save();const b=Qi.isFilterValid(p,g);S!=null&&g==null&&p==null?e.fillStyle=S:f!=null&&b?e.fillStyle=f:v!=null&&(e.fillStyle=v);const T=s+1,y=u-C,E=i-1,R=C-1;e.fillRect(T,y,E,R),e.restore()}drawTreeMarker(e,t,n,s,i,o,l){e.save();const{x1:a,y1:d}=i,h=l?this.getIcon(wn.CARET_DOWN):this.getIcon(wn.CARET_RIGHT),u=n+a-2,m=s+d+2.5;e.fillStyle=o,e.textAlign="center",e.translate(u,m),e.fill(h),e.restore()}drawRowFooters(e,t){const{metrics:n,model:s,mouseX:i,mouseY:o,theme:l}=t,{gridY:a,gridX:d,maxX:h,modelRows:u,floatingTopHeight:m,floatingBottomHeight:g,floatingRows:p,rowFooterWidth:C,height:f,horizontalBarHeight:S,verticalBarWidth:v,allRowHeights:b,allRowYs:T,width:y}=n;if(C<=0||p.length===0)return;const{cellHorizontalPadding:E,floatingGridRowColor:R,floatingRowBackgroundColors:x,headerColor:D,rowHoverBackgroundColor:L}=l;e.translate(d,a),e.beginPath();const M=Math.min(h,y-C-v-d);e.fillStyle=x,m>0&&e.rect(M,0,C,m),g>0&&e.rect(M,f-a-S-g,C,g),e.fill();const j=i!=null&&o!=null&&i>=d&&i<=h+C?O.getRowAtY(o,n):null;if(L!=null&&j!==null&&p.includes(j)){e.fillStyle=L;const W=T.get(j),H=b.get(j);N(W),N(H),e.fillRect(M,W,C,H)}if(e.beginPath(),R!=null&&(e.strokeStyle=R),m>0&&(e.moveTo(M+.5,.5),e.lineTo(M+.5,m-.5)),g>0){const W=f-a-S-g;e.moveTo(M-.5,W+.5),e.lineTo(M-.5,W+g-.5)}e.stroke(),e.fillStyle=D,e.textAlign="left";const A=M+E;for(let W=0;W<p.length;W+=1){const H=p[W],U=b.get(H),P=T.get(H),Q=u.get(H);if(P!=null&&U!=null&&Q!=null){const G=P+U*.5;e.fillText(s.textForRowFooter(Q),A,G)}}e.translate(-d,-a)}getTextRenderMetrics(e,t,n){const s=super.getTextRenderMetrics(e,t,n),{mouseX:i,mouseY:o,metrics:l}=e;if(i==null||o==null)return s;const{column:a,row:d}=O.getGridPointFromXY(i,o,l);if(t===a&&n===d){const{left:h}=this.getCellOverflowButtonPosition(e);this.shouldRenderOverflowButton(e)&&h!=null&&(s.width=h-l.gridX-s.x)}return s}shouldRenderOverflowButton(e){const{context:t,mouseX:n,mouseY:s,metrics:i,model:o,theme:l}=e;if(n==null||s==null)return!1;const{row:a,column:d,modelRow:h,modelColumn:u}=O.getCellInfoFromXY(n,s,i);if(a==null||d==null||h==null||u==null||!F.isStringType(o.columns[u].type))return!1;const m=o.textForCell(u,h)??"",{width:g}=super.getTextRenderMetrics(e,d,a),p=i.fontWidths.get(l.font)??Qi.DEFAULT_FONT_WIDTH;t.save(),t.font=l.font;const C=this.getCachedTruncatedString(t,m,g,p,o.truncationCharForCell(u,h));return t.restore(),m!==""&&C!==m}getCellOverflowButtonPosition({mouseX:e,mouseY:t,metrics:n,theme:s}){const i={left:null,top:null,width:null,height:null};if(e==null||t==null||n==null)return i;const{rowHeight:o,columnWidth:l,left:a,top:d}=O.getCellInfoFromXY(e,t,n);if(a==null||l==null||d==null)return i;const{width:h,verticalBarWidth:u}=n,{cellHorizontalPadding:m}=s,g=Ta+2*m,p=o,f=Math.min(n.gridX+a+l,h-u)-g,S=n.gridY+d;return{left:f,top:S,width:g,height:p}}drawCellOverflowButton(e){const{context:t,mouseX:n,mouseY:s,theme:i}=e;if(n==null||s==null||!this.shouldRenderOverflowButton(e))return;const{left:o,top:l,width:a,height:d}=this.getCellOverflowButtonPosition(e),{cellHorizontalPadding:h,overflowButtonColor:u,overflowButtonHoverColor:m}=i;t.save(),m!=null&&o!=null&&a!=null&&l!=null&&d!=null&&n>=o&&n<=o+a&&s>=l&&s<=l+d?t.fillStyle=m:u!=null&&(t.fillStyle=u);const g=this.getIcon(wn.CELL_OVERFLOW);o!=null&&l!=null&&t.translate(o+h,l+2),t.fill(g),t.restore()}getExpandButtonPosition({mouseX:e,mouseY:t,metrics:n,theme:s},i){const o={left:null,top:null,width:null,height:null};if(e==null||t==null||i==null||!n)return o;const{rowHeight:l,left:a,top:d}=O.getCellInfoFromXY(e,t,n);N(a),N(l),N(d);const{cellHorizontalPadding:h}=s,u=Jd+2*h,m=Math.max(a+Jd*i,n.gridX),g=n.gridY+d;return{left:m,top:g,width:u,height:l}}}const Mv=Qi,Lv="12px Fira Sans, sans-serif",Ov="#f0f0ee",Av="#1a171a",le={"grid-bg":"#211f22",font:Lv,white:Ov,black:Av,"header-bg":"#2d2a2e","header-color":"#f0f0ee","header-height":"30px","header-separator-color":"#211f22","header-separator-hover-color":"#929192","header-hidden-separator-hover-color":"#4878ea","header-sort-bar-color":"#aa9af4","header-reverse-bar-color":"#548d29","header-bar-casing-color":"#211f22","header-font":"600 12px Fira Sans, sans-serif","row-height":"19px","row-background-colors":"#373438 #2d2a2e","selection-color":"rgba(118, 217, 228, 0.09)","selection-outline-color":"#76d9e4","selection-outline-casing-color":"#211f22","row-hover-bg":"#4b494c","selected-row-hover-bg":"rgba(118, 217, 228, 0.25)","scroll-bar-active-selection-tick-color":"rgba(118, 217, 228, 0.5)","scroll-bar-bg":"#322f33","scroll-bar-hover-bg":"#373438","scroll-bar-casing-color":"#555356","scroll-bar-corner-color":"#322f33","scroll-bar-color":"#5b5a5c","scroll-bar-hover-color":"#929192","scroll-bar-active-color":"#c0bfbf","text-color":"#f0f0ee","hyperlink-color":"#4878ea","positive-number-color":"#9edc6f","negative-number-color":"#f95d84","zero-number-color":"#fcd65b","date-color":"#fcd65b","pending-text-color":"#fde38d","error-text-color":"#f95d84","null-string-color":"#929192","filter-bar-active-bg":"#425175","filter-bar-active-color":"#4878ea","filter-bar-expanded-bg":"#373438","filter-bar-expanded-active-bg":"#313849","filter-bar-expanded-active-cell-bg":"#374d80","filter-bar-separator-color":"#929192","filter-bar-error-color":"#f95d84","filter-icon-color":"#4878ea","scrim-color":"#211f22","context-menu-sort-icon-color":"#aa9af4","context-menu-reverse-icon-color":"#548d29","linker-column-hover-bg":"rgba(118, 217, 228, 0.09)","tree-line-color":"#5b5a5c","tree-marker-color":"#c0bfbf","tree-marker-hover-color":"#fcfcfa","grouped-column-divider-color":"#1a171a","floating-grid-row-color":"#555356","floating-row-background-colors":"#403e41","floating-divider-inner-color":"#403e41","floating-divider-outer-color":"#211f22","overflow-button-color":"#c0bfbf","overflow-button-hover-color":"#fcfcfa"},_v=Object.freeze({backgroundColor:le["grid-bg"],white:le.white,black:le.black,font:le.font,headerBackgroundColor:le["header-bg"],headerColor:le["header-color"],headerSeparatorColor:le["header-separator-color"],headerSeparatorHoverColor:le["header-separator-hover-color"],headerHiddenSeparatorHoverColor:le["header-hidden-separator-hover-color"],headerSortBarColor:le["header-sort-bar-color"],headerReverseBarColor:le["header-reverse-bar-color"],headerBarCasingColor:le["header-bar-casing-color"],headerFont:le["header-font"],rowBackgroundColors:le["row-background-colors"],rowHoverBackgroundColor:le["row-hover-bg"],selectionColor:le["selection-color"],selectionOutlineColor:le["selection-outline-color"],selectionOutlineCasingColor:le["selection-outline-casing-color"],selectedRowHoverBackgroundColor:le["selected-row-hover-bg"],scrollBarBackgroundColor:le["scroll-bar-bg"],scrollBarHoverBackgroundColor:le["scroll-bar-hover-bg"],scrollBarCasingColor:le["scroll-bar-casing-color"],scrollBarCornerColor:le["scroll-bar-corner-color"],scrollBarColor:le["scroll-bar-color"],scrollBarHoverColor:le["scroll-bar-hover-color"],scrollBarActiveColor:le["scroll-bar-active-color"],scrollBarSelectionTickColor:le["selected-row-hover-bg"],scrollBarActiveSelectionTickColor:le["scroll-bar-active-selection-tick-color"],textColor:le["text-color"],hyperlinkColor:le["hyperlink-color"],positiveNumberColor:le["positive-number-color"],negativeNumberColor:le["negative-number-color"],zeroNumberColor:le["zero-number-color"],dateColor:le["date-color"],pendingTextColor:le["pending-text-color"],errorTextColor:le["error-text-color"],nullStringColor:le["null-string-color"],filterBarActiveBackgroundColor:le["filter-bar-active-bg"],filterBarExpandedBackgroundColor:le["filter-bar-expanded-bg"],filterBarExpandedActiveBackgroundColor:le["filter-bar-expanded-active-bg"],filterBarExpandedActiveCellBackgroundColor:le["filter-bar-expanded-active-cell-bg"],filterBarSeparatorColor:le["filter-bar-separator-color"],filterBarActiveColor:le["filter-bar-active-color"],filterBarErrorColor:le["filter-bar-error-color"],filterIconColor:le["filter-icon-color"],scrimColor:le["scrim-color"],contextMenuSortIconColor:le["context-menu-sort-icon-color"],contextMenuReverseIconColor:le["context-menu-reverse-icon-color"],allowRowResize:!1,autoSelectRow:!0,gridColumnColor:null,gridRowColor:null,groupedColumnDividerColor:le["grouped-column-divider-color"],columnHoverBackgroundColor:null,headerHorizontalPadding:12,scrollBarSize:13,scrollBarHoverSize:16,minScrollHandleSize:24,rowHeight:parseInt(le["row-height"],10)||19,columnWidth:100,rowHeaderWidth:0,rowFooterWidth:60,columnHeaderHeight:parseInt(le["header-height"],10)||30,filterBarHeight:30,filterBarCollapsedHeight:5,sortHeaderBarHeight:2,reverseHeaderBarHeight:4,filterBarHorizontalPadding:4,scrimBlurSize:25,minScrimTransitionTime:150,maxScrimTransitionTime:350,scrollSnapToRow:!0,linkerColumnHoverBackgroundColor:le["linker-column-hover-bg"],treeLineColor:le["tree-line-color"],treeMarkerColor:le["tree-marker-color"],treeMarkerHoverColor:le["tree-marker-hover-color"],floatingGridColumnColor:null,floatingGridRowColor:le["floating-grid-row-color"],floatingRowBackgroundColors:le["floating-row-background-colors"],floatingDividerInnerColor:le["floating-divider-inner-color"],floatingDividerOuterColor:le["floating-divider-outer-color"],overflowButtonColor:le["overflow-button-color"],overflowButtonHoverColor:le["overflow-button-hover-color"]}),ec=_v;const Ea=ee.module("ColumnStatistics"),Pv={SIZE:"Number of Rows"};class El extends w.Component{static AUTO_GENERATE_LIMIT=1e5;static getStatsLabel(e){return Pv[e]??e.split(" ").map(t=>t[0].toUpperCase()+t.substr(1).toLowerCase()).join(" ")}constructor(e){super(e),this.handleError=this.handleError.bind(this),this.handleGenerateStatistics=this.handleGenerateStatistics.bind(this),this.handleStatistics=this.handleStatistics.bind(this),this.cancelablePromise=null,this.state={error:null,loading:!1,statistics:null,numRows:0}}componentDidMount(){this.maybeGenerateStatistics()}componentWillUnmount(){this.cancelablePromise&&this.cancelablePromise.cancel()}cancelablePromise;maybeGenerateStatistics(){const{model:e}=this.props,t=e.rowCount-e.pendingRowCount;this.setState({numRows:t}),e.isColumnStatisticsAvailable?t<El.AUTO_GENERATE_LIMIT&&this.handleGenerateStatistics():this.setState({loading:!1})}handleGenerateStatistics(){this.setState({loading:!0});const{column:e,model:t}=this.props;this.cancelablePromise=ve.makeCancelable(t.columnStatistics(e)),this.cancelablePromise.then(this.handleStatistics).catch(this.handleError)}handleStatistics(e){Ea.debug("Received statistics",e);const{model:t,onStatistics:n}=this.props,s=[];e.statisticsMap.forEach((i,o)=>{s.push({operation:El.getStatsLabel(o),value:i,type:e.getType(o)})}),e.uniqueValues.forEach((i,o)=>{s.push({operation:o,className:"column-statistics-unique-value",value:i,type:"long"})}),this.setState({loading:!1,statistics:s,numRows:t.rowCount-t.pendingRowCount}),n()}handleError(e){if(e!=null&&ve.isCanceled(e)){Ea.debug("Called handleError on a cancelled promise result");return}Ea.error("Error generating statistics",e),this.setState({error:e,loading:!1,statistics:null})}render(){const{column:e,model:t}=this.props,{error:n,loading:s,statistics:i,numRows:o}=this.state,l=!s&&n==null&&i==null&&t.isColumnStatisticsAvailable,a=[],d=e.type.substring(e.type.lastIndexOf(".")+1),h=e.description===null?null:e.description;if(i!=null)for(let p=0;p<i.length;p+=1){const{operation:C,className:f,value:S,type:v}=i[p],b=v?t.displayString(S,v):t.displayString(S,e.type,e.name),T=r.jsxs(ae.Fragment,{children:[r.jsx("div",{className:K("column-statistic-operation",f),children:C}),r.jsx("div",{className:"column-statistic-value",children:b})]},C);a.push(T)}const u=He(t)&&t.hasExpandableRows?"Expanded Rows":"Number of Rows",m=t.displayString(o,"long"),g=t.getColumnIndexByName(e.name);return r.jsxs("div",{className:"column-statistics",children:[r.jsxs("div",{className:"column-statistics-title",children:[e.name,r.jsxs("span",{className:"column-statistics-type",children:[" (",d,")"]}),r.jsx(jl,{className:"column-statistics-copy",tooltip:"Copy column name",copy:e.name})]}),h!=null&&r.jsx("div",{className:"column-statistics-description",children:h}),g!=null&&!t.isColumnMovable(g)&&r.jsxs("div",{className:"column-statistics-status",children:[r.jsx(X,{icon:t.isColumnFrozen(g)?lg:ag,className:"mr-1"}),t.isColumnFrozen(g)?"Frozen":"Not movable"]}),r.jsxs("div",{className:"column-statistics-grid",children:[i==null&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"column-statistic-operation",children:u}),r.jsx("div",{className:"column-statistic-value",children:m})]}),a]}),l&&r.jsx(_,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,children:"Generate Stats"}),n!=null&&r.jsx("div",{className:"error-message",children:`${n}`}),i&&!s&&r.jsx(_,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,icon:r.jsx(X,{icon:rr,className:"mr-1"}),children:"Refresh"}),s&&r.jsxs("div",{className:"column-statistics-loading",children:[r.jsx(Nn,{className:"mr-2"}),"Calculating Stats..."]})]})}}const jv=El;const Bo=ee.module("AdvancedFilterCreatorFilterItem");class Pr extends w.PureComponent{static getLabelForFilter(e,t){try{if(F.isNumberType(e)||F.isCharType(e))return mh(t);if(F.isTextType(e))return uh(t);if(F.isDateType(e))return gh(t);if(F.isBooleanType(e))return Wf(t);throw new Error(`Unrecognized column type: ${e}`)}catch(n){return Bo.warn(n),""}}constructor(e){super(e),this.handleDelete=this.handleDelete.bind(this),this.handleTypeChange=this.handleTypeChange.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.typeDropdown=null;const{value:t="",filterTypes:n,selectedType:s=n[0]}=e;this.state={selectedType:s,value:t}}componentDidMount(){this.typeDropdown?.focus()}componentDidUpdate(e){const{value:t,selectedType:n}=this.props;n!==void 0&&e.selectedType!==n&&this.setState({selectedType:n}),t!==void 0&&e.value!==t&&this.setState({value:t})}typeDropdown;handleTypeChange(e){const t=e.target.value;Bo.debug2("typeChange",t),this.setState({selectedType:t});const{onChange:n}=this.props,{value:s}=this.state;s!=null&&s.length>0&&n(t,s)}handleValueChange(e){Bo.debug2("valueChange");const{value:t}=e.target;this.setState({value:t});const{onChange:n}=this.props,{selectedType:s}=this.state;s!=null&&n(s,t)}handleDelete(){Bo.debug("delete");const{onDelete:e}=this.props;e()}getCachedIsValid=he((e,t,n,s)=>{try{return!n||F.makeAdvancedValueFilter(e,t,n,s)!=null}catch{return!1}});render(){const{column:e,filterTypes:t,formatter:n}=this.props,{selectedType:s,value:i}=this.state,o=!F.isBooleanType(e.type),l=[],a=this.getCachedIsValid(e,s,i,n.timeZone);for(let d=0;d<t.length;d+=1){const h=t[d],u=Pr.getLabelForFilter(e.type,h),m=r.jsx("option",{value:h,children:u},h);l.push(m)}return r.jsx("div",{className:"advanced-filter-creator-filter-item",children:r.jsxs("div",{className:"form-row",children:[r.jsx("div",{className:"form-group col",children:r.jsx("select",{className:"form-control custom-select",value:s,onChange:this.handleTypeChange,ref:d=>{this.typeDropdown=d},children:l})}),o&&r.jsx("div",{className:"form-group col",children:r.jsx("div",{className:"input-group",children:r.jsx("input",{type:"text",className:K("form-control",{error:!a}),placeholder:"Enter value",value:i,onChange:this.handleValueChange})})}),r.jsx("div",{className:"form-group col-1 px-0",children:r.jsx(_,{kind:"ghost",className:"w-100 h-100 p-0 m-0",onClick:this.handleDelete,icon:Wt,tooltip:"Remove Filter"})})]})})}}const Hv=Pr,tc=ee.module("AdvancedFilterCreatorSelectValueList");class yl extends w.PureComponent{static defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{}};static indexOf(e,t){for(let n=0;n<t.length;n+=1){const s=t[n];if(s===e||s!=null&&s.valueOf!=null&&e!=null&&e.valueOf!=null&&s.valueOf()===e.valueOf())return n}return-1}constructor(e){super(e),this.handleSelect=this.handleSelect.bind(this),this.handleViewportChange=this.handleViewportChange.bind(this),this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.list=null;const{selectedValues:t}=this.props;this.state={itemCount:0,items:[],offset:0,selectedValues:t,isLoading:!0}}componentDidMount(){const{table:e}=this.props;e&&this.startListening(e)}componentDidUpdate(e){const{filters:t,invertSelection:n,selectedValues:s,table:i}=this.props;e.table!==i&&(e.table&&this.stopListening(e.table),i&&this.startListening(i),this.resetViewport()),e.invertSelection!==n&&this.setState({selectedValues:[]},this.handleSelectionUpdate),e.selectedValues!==s&&this.setState({selectedValues:s},this.handleSelectionUpdate),e.filters!==t&&(i?.applyFilter(t),this.resetViewport())}componentWillUnmount(){const{table:e}=this.props;e&&this.stopListening(e)}list;handleSelect(e,t){const{invertSelection:n}=this.props;let{selectedValues:s}=this.state;s=[...s];const i=yl.indexOf(t,s);i>=0?s.splice(i,1):s.push(t);let o=i<0;n&&(o=!o);const{offset:l}=this.state;let{items:a}=this.state;a=[...a];const d=e-l;d>=0&&d<a.length&&(a[d].isSelected=o),this.setState({items:a,selectedValues:s});const{onChange:h}=this.props;h(s,n)}handleViewportChange(e,t){this.updateViewport(e,t)}handleSelectionUpdate(){this.updateItemSelection()}handleTableUpdate(e){const{table:t,formatter:n}=this.props;if(!t)return;const s=e.detail,{offset:i}=s,o=[],l=t.columns[0];for(let d=0;d<s.rows.length;d+=1){const u=s.rows[d].get(l),m=n.getFormattedString(u,l.type,l.name),g=this.isValueSelected(u);o.push({displayValue:m,value:u,isSelected:g})}tc.debug2("Received table update:",i,o.length);const a=t.size;this.setState({itemCount:a,items:o,offset:i,isLoading:!1})}isValueSelected(e){const{invertSelection:t}=this.props,{selectedValues:n}=this.state,s=yl.indexOf(e,n);return t?s<0:s>=0}startListening(e){e.addEventListener(I.Table.EVENT_UPDATED,this.handleTableUpdate)}stopListening(e){e.removeEventListener(I.Table.EVENT_UPDATED,this.handleTableUpdate)}resetViewport(){this.list&&this.list.topRow!=null&&this.list.bottomRow!=null&&this.updateViewport(this.list.topRow,this.list.bottomRow,!0)}updateItemSelection(){let{items:e}=this.state;e=[...e];for(let t=0;t<e.length;t+=1){const n=e[t],{value:s}=n;n.isSelected=this.isValueSelected(s)}this.setState({items:e})}updateViewport(e,t,n=!1){const{table:s}=this.props;if(s==null)return;n&&this.setState({isLoading:!0});const i=t-e+1,o=Math.max(0,e-i*3),l=Math.max(o,t+i*3);tc.debug2("Setting viewport",o,",",l),s.setViewport(o,l)}render(){const{offset:e,isLoading:t,items:n,itemCount:s}=this.state;return r.jsxs("div",{className:"select-value-list-wrapper",children:[r.jsx(Rm,{itemCount:s,items:n,offset:e,onSelect:this.handleSelect,onViewportChange:this.handleViewportChange,ref:i=>{this.list=i}}),r.jsx($t,{in:t,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:r.jsx("div",{className:"loading-list",children:r.jsx(Nn,{className:"loading-spinner-large"})})})]})}}const Uv=yl;class jr extends w.PureComponent{static searchDebounceTime=250;static defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{},showSearch:!0};constructor(e){super(e),this.handleSelectAllClick=this.handleSelectAllClick.bind(this),this.handleClearAllClick=this.handleClearAllClick.bind(this),this.handleListChange=this.handleListChange.bind(this),this.handleSearchChange=this.handleSearchChange.bind(this),this.handleUpdateFilterTimeout=this.handleUpdateFilterTimeout.bind(this);const{invertSelection:t,selectedValues:n}=e;this.state={filters:[],invertSelection:t,selectedValues:n,searchText:""}}componentDidMount(){this.initSearchTable()}componentDidUpdate(e,t){const{invertSelection:n,selectedValues:s,table:i}=this.props;e.table!==i&&this.initSearchTable(),e.invertSelection!==n&&this.setState({invertSelection:n}),e.selectedValues!==s&&this.setState({selectedValues:s});const{table:o,searchText:l}=this.state;o!==t.table&&(t.table!=null&&t.table.close(),o!=null&&this.startUpdateFilterTimer()),l!==t.searchText&&this.startUpdateFilterTimer()}componentWillUnmount(){const{table:e}=this.state;e?.close(),this.searchTablePromise=void 0,this.stopUpdateFilterTimer()}searchTablePromise;updateFilterTimer;getColumnName(){const{table:e}=this.props;return e!=null?e.columns[0].name:""}getDisplayedValuesCount(){const{invertSelection:e,selectedValues:t,table:n}=this.state;return n==null?null:e?n.totalSize-t.length:t.length}getDisplayedValueText(){const e=this.getDisplayedValuesCount(),{table:t}=this.state,{formatter:n}=this.props;if(e!=null&&t!=null){const s=n.getFormattedString(e,"long"),i=n.getFormattedString(t.totalSize,"long");let o="";return e<1e6&&(o="Displaying "),`${o}${s} of ${i}`}return null}initSearchTable(){const{table:e}=this.props;if(e==null)return;const t=e.copy();this.searchTablePromise=t,this.searchTablePromise.then(n=>{this.searchTablePromise===t?(this.setState({table:n}),this.searchTablePromise=void 0):n.close()})}handleListChange(e,t){this.setState({selectedValues:e,invertSelection:t});const{onChange:n}=this.props;n(e,t)}handleSearchChange(e){const t=e.target.value;this.setState({searchText:t})}handleSelectAllClick(){this.resetSelection(!0)}handleClearAllClick(){this.resetSelection(!1)}handleUpdateFilterTimeout(){this.updateFilterTimer=void 0,this.updateTableFilter()}resetSelection(e){const t=[];this.setState({invertSelection:e,selectedValues:t});const{onChange:n}=this.props;n(t,e)}startUpdateFilterTimer(){this.stopUpdateFilterTimer(),this.updateFilterTimer=setTimeout(this.handleUpdateFilterTimeout,jr.searchDebounceTime)}stopUpdateFilterTimer(){this.updateFilterTimer!=null&&(clearTimeout(this.updateFilterTimer),this.updateFilterTimer=void 0)}updateTableFilter(){const{table:e,searchText:t}=this.state,{timeZone:n}=this.props,s=e?.columns[0],i=[];if(s==null)return;let o;if(t.length>0){let l=null;F.isCharType(s.type)?l=F.makeQuickFilter(s,t):F.isTextType(s.type)?l=F.makeQuickFilter(s,`~${t}`,n):l=F.makeQuickFilter(s,`>=${t}`,n),l!=null?i.push(l):o="Invalid search text"}this.setState({filters:i,error:o})}render(){const{error:e,filters:t,invertSelection:n,selectedValues:s,searchText:i,table:o}=this.state,{formatter:l,showSearch:a}=this.props,d=this.getColumnName(),h=this.getDisplayedValueText(),u=d?`Find ${d}...`:"";return r.jsxs("div",{className:"advanced-filter-creator-select-value",children:[r.jsxs("div",{className:a?"form-group":"",children:[r.jsx("label",{htmlFor:"advanced-filter-creator-select-value-input",children:"Select Values"}),a&&r.jsx("input",{type:"text",className:K("form-control",{"is-invalid":e!=null}),id:"advanced-filter-creator-select-value-input",placeholder:u,value:i,onChange:this.handleSearchChange})]}),r.jsx(Uv,{table:o,filters:t,invertSelection:n,selectedValues:s,formatter:l,onChange:this.handleListChange}),r.jsxs("div",{className:"advanced-filter-creator-select-meta-row",children:[r.jsxs("div",{children:[r.jsx(_,{kind:"ghost",onClick:this.handleSelectAllClick,children:"Select All"}),r.jsx(_,{kind:"ghost",onClick:this.handleClearAllClick,children:"Clear"})]}),r.jsx($t,{in:h!=null,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:r.jsx("div",{className:"row-count-info",children:h})})]})]})}}const Vv=jr;const Hi=ee.module("AdvancedFilterCreator");class gs extends w.PureComponent{static debounceFilterUpdate=250;static defaultProps={options:{filterItems:null,filterOperators:null,invertSelection:!0,selectedValues:[]},sortDirection:null};static makeFilterItem(){return{key:ze()}}constructor(e){super(e),this.handleAddAnd=this.handleAddAnd.bind(this),this.handleAddOr=this.handleAddOr.bind(this),this.handleChangeFilterOperator=this.handleChangeFilterOperator.bind(this),this.handleDone=this.handleDone.bind(this),this.handleFilterChange=this.handleFilterChange.bind(this),this.handleFilterDelete=this.handleFilterDelete.bind(this),this.handleSelectValueChange=this.handleSelectValueChange.bind(this),this.handleReset=this.handleReset.bind(this),this.handleSortDown=this.handleSortDown.bind(this),this.handleSortUp=this.handleSortUp.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleFocusTrapStart=this.handleFocusTrapStart.bind(this),this.handleFocusTrapEnd=this.handleFocusTrapEnd.bind(this),this.handleUpdateTimeout=this.handleUpdateTimeout.bind(this),this.focusTrapContainer=ae.createRef();const{options:t}=e;let{filterOperators:n,invertSelection:s,selectedValues:i}=t;const o=t.filterItems?.map(({selectedType:l,value:a})=>({selectedType:l,value:a,key:ze()}))??[];o.length===0&&o.push(gs.makeFilterItem()),n==null&&(n=[]),s==null&&(s=!0),i==null&&(i=[]),this.state={filterItems:o,filterOperators:n,invertSelection:s,selectedValues:i,valuesTableError:null,valuesTable:void 0}}componentDidMount(){this.initValuesTable()}componentWillUnmount(){this.debounceTimeout!=null&&(clearTimeout(this.debounceTimeout),this.sendUpdate()),this.valuesTablePromise!=null&&this.valuesTablePromise.cancel()}focusTrapContainer;debounceTimeout;valuesTablePromise;getFilterChangeHandler(e){return this.handleFilterChange.bind(this,e)}getFilterDeleteHandler(e){return this.handleFilterDelete.bind(this,e)}getFilterTypes=he(e=>F.getFilterTypes(e));initValuesTable(){const{model:e,column:t}=this.props;if(!e.isValuesTableAvailable){Hi.debug("No values table for this model, just ignore");return}this.valuesTablePromise=F.makeCancelableTablePromise(e.valuesTable(t)),this.valuesTablePromise.then(n=>{const s=n.columns[0].sort().asc();n.applySort([s]),this.setState({valuesTable:n})}).catch(n=>{ve.isCanceled(n)||(Hi.error("Unable to open values table",n),this.setState({valuesTableError:n}))})}handleFocusTrapEnd(){(this.focusTrapContainer?.current?.querySelector("button,select,input,textarea")).focus()}handleFocusTrapStart(){const e=this.focusTrapContainer?.current?.querySelectorAll("button,select,input,textarea");e&&e.length>0&&e[e.length-1].focus()}handleAddAnd(){let{filterItems:e,filterOperators:t}=this.state;e=e.concat(gs.makeFilterItem()),t=t.concat(Vn.and),this.setState({filterItems:e,filterOperators:t})}handleAddOr(){let{filterItems:e,filterOperators:t}=this.state;e=e.concat(gs.makeFilterItem()),t=t.concat(Vn.or),this.setState({filterItems:e,filterOperators:t})}handleChangeFilterOperator(e,t){let{filterOperators:n}=this.state;n=[...n],xm(t),n[e]=t,this.setState({filterOperators:n}),this.startUpdateTimer()}handleFilterChange(e,t,n){let{filterItems:s}=this.state;s=[...s];const{key:i}=s[e];s[e]={key:i,selectedType:t,value:n},this.setState({filterItems:s}),this.startUpdateTimer()}handleFilterDelete(e){let{filterItems:t,filterOperators:n}=this.state;t=[...t],n=[...n],e<t.length&&t.splice(e,1),e<n.length?n.splice(e,1):e===n.length&&n.splice(n.length-1,1),t.length===0&&t.push(gs.makeFilterItem()),this.setState({filterItems:t,filterOperators:n}),this.startUpdateTimer()}handleSelectValueChange(e,t){this.setState({selectedValues:e,invertSelection:t}),this.startUpdateTimer()}handleReset(){Hi.debug("Resetting Advanced Filter"),this.setState({filterItems:[gs.makeFilterItem()],filterOperators:[],selectedValues:[],invertSelection:!0}),this.startUpdateTimer()}handleSortDown(e){const t=Es.isModifierKeyDown(e);this.sortTable(F.sortDirection.descending,t)}handleSortUp(e){const t=Es.isModifierKeyDown(e);this.sortTable(F.sortDirection.ascending,t)}handleSubmit(e){Hi.debug("Submitting Advanced Filter"),this.stopUpdateTimer(),this.sendUpdate(),e.preventDefault()}handleDone(e){Hi.debug("Submitting and Closing Advanced Filter"),this.stopUpdateTimer(),this.sendUpdate();const{onDone:t}=this.props;t(),e.preventDefault()}handleUpdateTimeout(){this.debounceTimeout=void 0,this.sendUpdate()}shouldShowAddFilter(){const{filterItems:e}=this.state;if(e.length===0)return!1;const t=e[e.length-1],{selectedType:n,value:s}=t;return n!=null&&n.length>0&&s!=null&&s.length>0}sortTable(e,t=!1){const{column:n,onSortChange:s}=this.props;s(n,e,t)}startUpdateTimer(){this.stopUpdateTimer(),this.debounceTimeout=setTimeout(this.handleUpdateTimeout,gs.debounceFilterUpdate)}stopUpdateTimer(){this.debounceTimeout!==void 0&&(clearTimeout(this.debounceTimeout),this.debounceTimeout=void 0)}sendUpdate(){const{filterItems:e,filterOperators:t,invertSelection:n,selectedValues:s}=this.state,{column:i,onFilterChange:o,model:l}=this.props,{formatter:a}=l,d=e.filter(({selectedType:g,value:p})=>g!=null&&p!=null&&p!==""),h=t.filter((g,p)=>g!=null&&e[p].selectedType!=null&&e[p].value!=null&&e[p].value!=="").slice(0,d.length-1),u={filterItems:d,filterOperators:h,invertSelection:n,selectedValues:s},m=F.makeAdvancedFilter(i,u,a.timeZone);o(i,m,u)}render(){const{column:e,model:t,sortDirection:n,formatter:s}=this.props,{filterItems:i,filterOperators:o,invertSelection:l,selectedValues:a,valuesTable:d,valuesTableError:h}=this.state,{isValuesTableAvailable:u}=t,m=F.isBooleanType(e.type),g=F.isDateType(e.type),p=this.getFilterTypes(e.type),C=e.type.substring(e.type.lastIndexOf(".")+1),f=[];if(!m&&p.length)for(let b=0;b<i.length;b+=1){const T=i[b],{key:y,selectedType:E,value:R}=T,x=r.jsx(Hv,{column:e,filterTypes:p,onChange:this.getFilterChangeHandler(b),onDelete:this.getFilterDeleteHandler(b),selectedType:E,value:R,formatter:s},y);if(f.push(x),b<o.length){const L=o[b]===Vn.and,M=r.jsxs("div",{className:"form-row justify-content-end advanced-filter-creator-filter-operator",children:[r.jsx(_,{kind:"ghost",className:K("filter-operator",{active:L}),onClick:()=>this.handleChangeFilterOperator(b,Vn.and),children:"AND"}),r.jsx(_,{kind:"ghost",className:K("filter-operator",{active:!L}),onClick:()=>this.handleChangeFilterOperator(b,Vn.or),children:"OR"})]},`filterOperator${y}`);f.push(M)}}const S=this.shouldShowAddFilter(),v=r.jsxs("div",{className:K("form-row justify-content-end add-filter-item",{hidden:!S}),children:[r.jsx("span",{className:"text-muted",children:r.jsx(X,{icon:ys})}),r.jsx(_,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddAnd,disabled:!S,tooltip:"Add filter with AND",children:"AND"}),r.jsx(_,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddOr,disabled:!S,tooltip:"Add filter with OR",children:"OR"})]},"addFilterItem");return f.push(v),r.jsxs("div",{className:"advanced-filter-creator",role:"presentation",children:[r.jsx("div",{tabIndex:0,onFocus:this.handleFocusTrapStart}),r.jsxs("form",{onSubmit:this.handleSubmit,ref:this.focusTrapContainer,children:[r.jsxs("div",{className:"title-bar",children:[r.jsx("h6",{className:"advanced-filter-title",children:"Advanced Filters"}),r.jsxs("div",{className:"advanced-filter-menu-buttons",children:[r.jsx(_,{kind:"ghost",className:K("sort-operator",{active:n===F.sortDirection.descending}),onClick:this.handleSortDown,icon:fd,tooltip:`Sort ${e.name} Descending`}),r.jsx(_,{kind:"ghost",className:K("sort-operator",{active:n===F.sortDirection.ascending}),onClick:this.handleSortUp,icon:r.jsx(X,{icon:fd,rotation:180}),tooltip:`Sort ${e.name} Ascending`})]})]}),r.jsx("hr",{}),r.jsxs("div",{className:"advanced-filter-column-name",children:[e.name," ",r.jsxs("span",{className:"column-type",children:["(",C,")"]})]}),f,u&&h==null&&r.jsxs(r.Fragment,{children:[!m&&r.jsx("hr",{}),r.jsx("div",{className:"form-group",children:r.jsx(Vv,{table:d,onChange:this.handleSelectValueChange,invertSelection:l,selectedValues:a,formatter:s,showSearch:!g,timeZone:s.timeZone})})]}),r.jsxs("div",{className:"form-row justify-content-end",children:[r.jsx(_,{kind:"secondary",className:"mr-2",onClick:this.handleReset,children:"Reset"}),r.jsx(_,{kind:"primary",onClick:this.handleDone,children:"Done"})]})]}),r.jsx("div",{tabIndex:0,onFocus:this.handleFocusTrapEnd})]})}}const Bv=gs;const nc=ee.module("Aggregations");function $v({isRollup:c,settings:e,onChange:t,onEdit:n}){const{aggregations:s,showOnTop:i}=e,o=w.useMemo(()=>_w.filter(D=>!s.some(L=>L.operation===D)),[s]),[l,a]=w.useState(o[0]),[d,h]=w.useState([]),u=w.useCallback(D=>{t({...e,...D})},[t,e]),m=w.useCallback(D=>{u({aggregations:D})},[u]),g=w.useCallback(D=>{u({showOnTop:D})},[u]),p=w.useCallback(()=>{nc.debug("handleDragStart"),hn.startDragging()},[]),C=w.useCallback(({destination:D,source:L})=>{if(nc.debug("handleDragEnd",D,L),hn.stopDragging(),D===null)return;let M=D.index;L.index<D.index&&(M+=1);const j=[...s],A=hn.reorder(j,d,j,M),W=hn.adjustDestinationIndex(M,d),H=[[W,W+A.length-1]];m(j),h(H)},[m,s,d,h]),f=w.useCallback(D=>{a(D)},[a]),S=w.useCallback(()=>{m([...s,{operation:l,selected:[],invert:!0}])},[s,l,m]),v=w.useCallback(D=>{m(s.filter((L,M)=>M!==D))},[s,m]),b=w.useCallback(D=>{h(D)},[h]),T=w.useCallback(D=>{const L=s[D];Ss.isRollupOperation(L.operation)||n(L)},[s,n]),y=w.useCallback(D=>{g(D.target.value==="true")},[g]);w.useEffect(function(){o.length>0&&!o.includes(l)&&a(o[0])},[o,l]);const E=w.useCallback(({item:D,itemIndex:L,isClone:M=!1,selectedCount:j})=>{const A=D.operation,W=M?`${j}`:void 0,H=M?"item-list-item-clone":void 0,U=Ss.isRollupOperation(D.operation),P=!M&&!U;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:K("item-list-item-content","draggable-item-list-item-content",H),children:[r.jsxs("span",{className:"title",children:[A,!c&&U&&r.jsxs("span",{className:"small text-warning",children:[r.jsx(X,{icon:Zc})," Requires rollup"]})]}),rn.renderBadge({text:W}),rn.renderHandle()]}),!M&&r.jsxs(r.Fragment,{children:[r.jsx(_,{kind:"ghost",className:"btn-edit",icon:mo,tooltip:"Edit Columns",onClick:()=>n(D),disabled:!P}),r.jsx(_,{kind:"ghost",className:"btn-delete",icon:Wt,tooltip:"Delete Aggregation",onClick:()=>v(L)})]})]})},[v,n,c]),R=o.length>0,x=s.length>0;return r.jsxs("div",{className:"aggregations",children:[R&&r.jsxs("div",{className:"form-inline",children:[r.jsx(Im,{onChange:f,value:l,children:o.map(D=>r.jsx(Dm,{value:D,children:D},D))}),r.jsxs("button",{type:"button",className:"btn btn-link btn-add",onClick:S,children:[r.jsx(X,{icon:ys}),"Add Aggregation"]})]}),R&&x&&r.jsx("hr",{}),x&&r.jsxs(r.Fragment,{children:[!c&&r.jsxs("div",{className:"form-inline",children:[r.jsx("label",{children:"Placement: "}),r.jsxs(Hl,{onChange:y,value:`${i}`,children:[r.jsx(zn,{value:"true",children:"Top"}),r.jsx(zn,{value:"false",children:"Bottom"})]})]}),r.jsx(Al,{onDragStart:p,onDragEnd:C,children:r.jsx(rn,{className:"selected-aggregations",itemCount:s.length,items:s,renderItem:E,offset:0,onSelectionChange:b,onSelect:T,selectedRanges:d,isMultiSelect:!0})})]})]})}const Wv=30;function Gv({aggregation:c,columns:e,onChange:t}){const[n,s]=w.useState(-1),[i,o]=w.useState(-1),[l,a]=w.useState(0),{invert:d,selected:h}=c,u=w.useRef(null),m=w.useCallback(y=>h.includes(y)?!d:d,[d,h]),g=w.useMemo(()=>{let y=Ar(e,c.operation);return l!==0&&(y=F.sortColumns(y,l===1)),y},[e,c.operation,l]),p=w.useMemo(()=>n>=0?g.slice(n,i+1).map(y=>({value:y.name,displayValue:y.name,isSelected:m(y.name)})):[],[g,m,i,n]),C=w.useCallback(y=>{const{name:E}=g[y],R=h.indexOf(E);let x=[...h],D=d;R>=0?x.splice(R,1):(x.push(E),x.length===g.length&&(x=[],D=!d)),t({...c,selected:x,invert:D})},[c,d,g,h,t]),f=w.useCallback(()=>{a(0),t({...c,selected:[],invert:!0})},[c,t]),S=w.useCallback((y,E)=>{s(y),o(E)},[s,o]),v=w.useCallback(()=>{h.length===0?t({...c,invert:!d}):t({...c,selected:[],invert:!0})},[c,d,t,h]),b=h.length===0?d:null,T=h.length!==0||!d||l!==0;return r.jsxs("div",{role:"menu",className:"aggregation-edit",children:[r.jsx("div",{className:"top-menu",children:r.jsxs("div",{className:"form-inline",children:[r.jsx(nn,{checked:b,onChange:v,children:"Toggle All"}),r.jsx("div",{className:"spacer"}),r.jsx($t,{in:T,timeout:Xe.transitionSlowMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:r.jsx(_,{kind:"ghost",className:"btn-reset",onClick:f,children:"Reset"})}),r.jsx(_,{kind:"ghost",className:K({active:l===1}),icon:dr,tooltip:"Sort ascending",onClick:()=>a(1)}),r.jsx(_,{kind:"ghost",className:K({active:l===2}),icon:cr,tooltip:"Sort descending",onClick:()=>a(2)})]})}),r.jsx("div",{className:"aggregation-edit-item-list",children:r.jsx(Ei,{itemCount:g.length,items:p,offset:n,renderItem:({item:y})=>r.jsx(nn,{checked:m(y.value),children:y.displayValue}),onSelect:C,onViewportChange:S,rowHeight:Wv,focusSelector:"input",ref:u})})]})}function zv(c){return r.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...c,children:r.jsxs("g",{fill:"none",fillRule:"evenodd",children:[r.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),r.jsx("path",{fill:"#7DA4FF",d:"M8 26h4v15H8zM15 17h4v24h-4zM22 21h4v20h-4zM29 17h4v24h-4zM36 11h4v30h-4z"})]})})}function Kv(c){return r.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...c,children:r.jsxs("g",{fill:"none",fillRule:"evenodd",children:[r.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),r.jsx("path",{fill:"#7DA4FF",d:"M7 34h4v8H7zM12 31h4v11h-4zM17 27h4v15h-4zM22 22h4v20h-4zM27 27h4v15h-4zM32 29h4v13h-4zM37 31h4v11h-4z"})]})})}function Yv(c){return r.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...c,children:r.jsxs("g",{fill:"none",fillRule:"evenodd",children:[r.jsx("path",{fill:"#C1C0C0",d:"M4 4h1v40H4zM44 43v1H5v-1z"}),r.jsx("path",{stroke:"#7DA4FF",d:"M7.984 32.44l7.982-11.378 5.273 3.739 9.952-10.838 2.826 1.894 7.45-5.802"}),r.jsx("path",{stroke:"#BECDEF",d:"M8.244 37.926L17 33.496l5 .87 10.637-10.35 10.615-1.381"})]})})}function qv(c){return r.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...c,children:r.jsxs("g",{fill:"none",fillRule:"evenodd",children:[r.jsx("path",{d:"M24 10c7.732 0 14 6.268 14 14s-6.268 14-14 14-14-6.268-14-14h14V10z",fill:"#80A6FF"}),r.jsx("path",{d:"M10 24c0-7.732 6.268-14 14-14v14H10z",fill:"#C1C0C0"})]})})}function Xv(c){return r.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...c,children:r.jsxs("g",{fill:"none",fillRule:"evenodd",children:[r.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),r.jsx("path",{fill:"#939293",d:"M44 34v1H4v-1zM44 25v1H4v-1zM44 16v1H4v-1z"}),r.jsx("circle",{fill:"#7DA4FF",cx:9.5,cy:37.5,r:1.5}),r.jsx("circle",{fill:"#7DA4FF",cx:16.5,cy:30.5,r:1.5}),r.jsx("circle",{fill:"#7DA4FF",cx:22.5,cy:36.5,r:1.5}),r.jsx("circle",{fill:"#7DA4FF",cx:28.5,cy:30.5,r:1.5}),r.jsx("circle",{fill:"#7DA4FF",cx:15.5,cy:38.5,r:1.5}),r.jsx("circle",{fill:"#7DA4FF",cx:23.5,cy:25.5,r:1.5}),r.jsx("circle",{fill:"#7DA4FF",cx:19.5,cy:19.5,r:1.5}),r.jsx("circle",{fill:"#7DA4FF",cx:29.5,cy:19.5,r:1.5}),r.jsx("circle",{fill:"#7DA4FF",cx:32.5,cy:26.5,r:1.5}),r.jsx("circle",{fill:"#7DA4FF",cx:36.5,cy:13.5,r:1.5})]})})}function Zv(c){return r.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...c,children:[r.jsx("rect",{width:"48",height:"48",fill:"none"}),r.jsx("rect",{x:"26",y:"10",width:"15",height:"4",fill:"#9FDE70"}),r.jsx("rect",{x:"26",y:"22",width:"15",height:"4",fill:"#9FDE70"}),r.jsx("rect",{x:"26",y:"28",width:"15",height:"4",fill:"#FFD95C"}),r.jsx("rect",{x:"26",y:"34",width:"15",height:"4",fill:"#9FDE70"})]})}function Qv(c){return r.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...c,children:[r.jsx("rect",{width:"48",height:"48",fill:"none"}),r.jsx("rect",{x:"4",y:"16",width:"40",height:"4",fill:"#FFD95C"}),r.jsx("rect",{x:"4",y:"10",width:"40",height:"4",fill:"#78DCE8"}),r.jsx("rect",{x:"4",y:"34",width:"40",height:"4",fill:"#78DCE8"})]})}const sc=ee.module("ChartBuilder");class rt extends w.PureComponent{static types=[I.plot.SeriesPlotStyle.LINE,I.plot.SeriesPlotStyle.BAR,I.plot.SeriesPlotStyle.SCATTER,I.plot.SeriesPlotStyle.PIE];static getTypeName(e){switch(e){case I.plot.SeriesPlotStyle.LINE:return"Line";case I.plot.SeriesPlotStyle.BAR:return"Bar";case I.plot.SeriesPlotStyle.SCATTER:return"Scatter";case I.plot.SeriesPlotStyle.PIE:return"Pie";case I.plot.SeriesPlotStyle.HISTOGRAM:return"Histogram";default:return e}}static getTypeIcon(e){switch(e){case I.plot.SeriesPlotStyle.LINE:return r.jsx(Yv,{});case I.plot.SeriesPlotStyle.BAR:return r.jsx(zv,{});case I.plot.SeriesPlotStyle.SCATTER:return r.jsx(Xv,{});case I.plot.SeriesPlotStyle.PIE:return r.jsx(qv,{});case I.plot.SeriesPlotStyle.HISTOGRAM:return r.jsx(Kv,{});default:return null}}static getMaxSeriesCount(e){switch(e){case I.plot.SeriesPlotStyle.PIE:return 1;case I.plot.SeriesPlotStyle.HISTOGRAM:return 0;default:return 100}}static getXAxisLabel(e){switch(e){case I.plot.SeriesPlotStyle.PIE:return"Labels";case I.plot.SeriesPlotStyle.HISTOGRAM:return"Data";default:return"X-Axis"}}static getSeriesLabel(e){switch(e){case I.plot.SeriesPlotStyle.PIE:return"Values";default:return"Series"}}static makeSeriesItem(e){return{id:ze.generate(),value:e}}static makeDefaultSeriesItems(e,t){if(rt.getMaxSeriesCount(e)===0||t==null||t.length===0)return[];const s=t.length>1?t[1].name:t[0].name;return[rt.makeSeriesItem(s)]}static getDefaultXAxis(e,t){return t!=null&&t.length>0?t[0].name:null}constructor(e){super(e),this.handleAddSeries=this.handleAddSeries.bind(this),this.handleLinkStateChange=this.handleLinkStateChange.bind(this),this.handleReset=this.handleReset.bind(this),this.handleSeriesChange=this.handleSeriesChange.bind(this),this.handleSeriesDeleteClick=this.handleSeriesDeleteClick.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleTypeClick=this.handleTypeClick.bind(this),this.handleXAxisChange=this.handleXAxisChange.bind(this),this.sendChange=this.sendChange.bind(this);const{model:t}=e,{columns:n}=t,s=rt.types[0],i=rt.getDefaultXAxis(s,n),o=rt.makeDefaultSeriesItems(s,n);this.state={type:s,seriesItems:o,xAxis:i,isLinked:!0}}handleAddSeries(){this.setState(e=>{const{seriesItems:t}=e,n=[...t],{model:s}=this.props,{columns:i}=s;return n.push({id:ze.generate(),value:i[0].name}),{seriesItems:n}},this.sendChange)}handleLinkStateChange(e){this.setState({isLinked:e.target.value==="true"},this.sendChange)}handleReset(){const{model:e}=this.props,{columns:t}=e,n=rt.types[0],s=rt.getDefaultXAxis(n,t),i=rt.makeDefaultSeriesItems(n,t),o=!0;this.setState({type:n,seriesItems:i,xAxis:s,isLinked:o},this.sendChange)}handleSeriesChange(e){const{value:t}=e.target,n=e.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(i=>{let{seriesItems:o}=i;return o=[...o],o[s].value=t,{seriesItems:o}},this.sendChange)}handleSeriesDeleteClick(e){const n=e.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(i=>{const{seriesItems:o}=i,l=[...o];return l.splice(s,1),{seriesItems:l}},this.sendChange)}handleSubmit(e){e.preventDefault();const{onSubmit:t}=this.props,{type:n,seriesItems:s,xAxis:i,isLinked:o}=this.state,l=s.map(a=>a.value);t({type:`${n}`,series:l,xAxis:i,isLinked:o})}handleTypeClick(e){const n=e.target.getAttribute("data-index"),s=parseInt(n,10),i=rt.types[s];sc.debug2("handleTypeSelect",i),this.setState(o=>{const l=rt.getMaxSeriesCount(i);let{seriesItems:a}=o;if(a=a.slice(0,l),a.length===0&&l>0){const{model:d}=this.props,{columns:h}=d;a=rt.makeDefaultSeriesItems(i,h)}return{type:i,seriesItems:a}},this.sendChange)}handleXAxisChange(e){const t=e.target.value;sc.debug2("x-axis change",t),this.setState({xAxis:t},this.sendChange)}sendChange(){const{onChange:e}=this.props,{isLinked:t,type:n,seriesItems:s,xAxis:i}=this.state,o=s.map(l=>l.value);e({type:n,series:o,xAxis:i,isLinked:t})}render(){const{model:e}=this.props,{columns:t}=e,{seriesItems:n,type:s,xAxis:i,isLinked:o}=this.state,l=rt.getMaxSeriesCount(s),a=rt.getXAxisLabel(s),d=rt.getSeriesLabel(s),h=n.length>0,u=n.length<l;return r.jsx("div",{className:"chart-builder",children:r.jsxs("form",{onSubmit:this.handleSubmit,children:[r.jsxs("div",{className:"form-row",children:[r.jsx("label",{children:"Select Chart Type"}),r.jsx("div",{className:"form-row",children:rt.types.map((m,g)=>{const p=m;return r.jsx("div",{className:"col col-chart-type",children:r.jsxs("button",{type:"button",className:K("btn","btn-icon","btn-chart-type",{active:m===s}),"data-index":g,onClick:this.handleTypeClick,children:[rt.getTypeIcon(m),rt.getTypeName(m)]})},p)})})]}),r.jsx("hr",{}),r.jsxs("div",{className:"form-row form-inline",children:[r.jsx("label",{className:"col-2 label-left",children:a}),r.jsx("select",{className:"form-control custom-select select-x-axis col",value:i,onChange:this.handleXAxisChange,children:t.map(m=>r.jsx("option",{value:m.name,children:m.name},m.name))})]}),h&&r.jsx("hr",{}),n.map((m,g)=>r.jsxs("div",{className:"form-row form-inline form-series-item","data-testid":`form-series-item-${g}`,children:[r.jsx("label",{className:"col-2 label-left",children:g===0?d:""}),r.jsx("select",{className:"form-control custom-select select-series col",value:m.value,onChange:this.handleSeriesChange,"data-testid":`select-series-item-${g}`,"data-index":g,children:t.map(p=>r.jsx("option",{value:p.name,"data-index":g,children:p.name},p.name))}),n.length>1&&r.jsx(_,{kind:"ghost",className:"btn-delete-series ml-2 px-2","data-index":g,"data-testid":`delete-series-${g}`,onClick:this.handleSeriesDeleteClick,icon:Wt,tooltip:"Delete"})]},m.id)),u&&r.jsxs("div",{className:"form-row",children:[r.jsx("div",{className:"col-2"}),r.jsx(_,{kind:"ghost",className:"btn-add-series mt-1",onClick:this.handleAddSeries,icon:ys,children:"Add Series"})]}),r.jsxs("div",{className:"form-row chart-builder-link",children:[r.jsx("label",{className:"col-2 label-right",children:r.jsxs("div",{className:"fa-md fa-layers",children:[r.jsx(X,{mask:or,icon:yi,transform:"right-5 down-5"}),r.jsx(X,{icon:o?Qc:rg,transform:"grow-2 right-8 down-6"})]})}),r.jsxs(Hl,{onChange:this.handleLinkStateChange,value:`${o}`,children:[r.jsx(zn,{value:"true",children:"Sync State"}),r.jsx(zn,{value:"false",children:"Freeze State"})]})]}),r.jsxs("div",{className:"form-row",children:[r.jsx("div",{className:"col-2 label-right"}),r.jsx("div",{className:"col chart-builder-link-info",children:o?"Charts with synced state will update to match any filters or user modifications applied to the parent table.":"Freeze State disconnects the chart state from the parent table. New filters or user modifications on the parent table will not be applied."})]}),r.jsxs("div",{className:K("form-row","justify-content-end","my-3"),children:[r.jsx(_,{kind:"secondary",className:"btn-reset",onClick:this.handleReset,children:"Reset"}),r.jsx(_,{kind:"primary",type:"submit",className:"btn-submit",children:"Create"})]})]})})}}const Jv=rt;class eT extends w.Component{static defaultProps={value:"",onContentChanged:()=>{},editorSettings:{},editorIndex:0,onTab:()=>{},invalid:!1};constructor(e){super(e),this.handleContentChanged=this.handleContentChanged.bind(this),this.handleEditorFocus=this.handleEditorFocus.bind(this),this.handleEditorBlur=this.handleEditorBlur.bind(this),this.handleContainerClick=this.handleContainerClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.state={isEditorFocused:!1,isEditorEmpty:!0},this.editorContainer=null}componentDidMount(){this.initEditor()}componentWillUnmount(){this.destroyEditor()}editorContainer;editor;initEditor(){const{value:e,editorSettings:t}=this.props,n={copyWithSyntaxHighlighting:"false",fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"groovyDB",lineDecorationsWidth:8,lineNumbers:"off",minimap:{enabled:!1},renderLineHighlight:"none",scrollbar:{arrowSize:0,horizontal:"hidden",horizontalScrollbarSize:0},scrollBeyondLastLine:!1,padding:{top:6,bottom:6},tabCompletion:"off",useTabStops:!0,value:e,wordWrap:"on",automaticLayout:!0,...t};if(!this.editorContainer)throw new Error("editorContainer is null");this.editor=Kn.create(this.editorContainer,n),this.editor.layout(),this.editor.getModel()?.updateOptions({tabSize:0}),this.editor.onKeyDown(this.handleKeyDown),this.editor.onDidChangeModelContent(this.handleContentChanged),this.editor.onDidFocusEditorText(this.handleEditorFocus),this.editor.onDidBlurEditorText(this.handleEditorBlur)}destroyEditor(){this.editor?.dispose(),this.editor=void 0}handleContentChanged(){const{onContentChanged:e}=this.props,t=this.editor?.getModel()?.getValue();t!==void 0&&this.setState({isEditorEmpty:t.length===0}),e(t)}handleEditorFocus(){this.setState({isEditorFocused:!0})}handleEditorBlur(){const e=this.editor?.getModel()?.getValue()??"";this.setState({isEditorEmpty:e.length===0,isEditorFocused:!1})}handleContainerClick(){const{isEditorFocused:e}=this.state;e||this.editor?.focus()}handleKeyDown(e){const{onTab:t,editorIndex:n}=this.props;e.code==="Tab"&&(e.stopPropagation(),e.preventDefault(),t(n,e.shiftKey))}render(){const{value:e,invalid:t}=this.props,{isEditorFocused:n,isEditorEmpty:s}=this.state;return r.jsxs("div",{className:K("input-editor-wrapper",{focused:n,invalid:t}),role:"presentation",onClick:this.handleContainerClick,children:[r.jsx("div",{className:"editor-container",ref:i=>{this.editorContainer=i}}),s&&!e&&r.jsx("div",{className:"editor-placeholder text-muted",children:"Column Formula"})]})}}const ic=Object.freeze({NAME:"name",FORMULA:"formula"}),tT=()=>{};function nT({eventKey:c,name:e,inputIndex:t,formula:n,onChange:s,onDeleteColumn:i,onTabInEditor:o,invalid:l,isDuplicate:a}){const d=e===""||Ii.isValidColumnName(e),h=w.useCallback(u=>{u!==void 0&&(u.replace(/(\r\n|\n|\r)/gm,""),s(c,ic.FORMULA,u))},[s,c]);return r.jsx(jc,{draggableId:c,index:t,disableInteractiveElementBlocking:!0,children:(u,m)=>r.jsxs("div",{className:K("draggable-container",{dragging:m.isDragging}),ref:u.innerRef,...u.draggableProps,children:[r.jsxs("div",{className:"custom-column-input-container",children:[r.jsxs("div",{className:"pb-3",children:[r.jsxs("div",{className:"d-flex flex-row custom-column-name",children:[r.jsx("input",{className:K("form-control custom-column-input",{"is-invalid":l||!d||a}),placeholder:"Column Name",value:e,onChange:g=>{s(c,ic.NAME,g.target.value)}}),r.jsx(_,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{i(c)},icon:Wt,tooltip:"Delete custom column"}),r.jsx(_,{kind:"ghost",className:"btn-drag-handle",onClick:tT,...u.dragHandleProps,icon:Bl,tooltip:"Drag column to re-order"})]}),(!d||a)&&r.jsx("p",{className:"validate-label-error text-danger mb-0 mt-2 pl-1",children:d?"Duplicate name":"Invalid name"})]}),r.jsx(eT,{editorSettings:{language:"deephavenDb"},editorIndex:t,value:n,onContentChanged:h,onTab:o,invalid:l})]}),r.jsx("hr",{})]})})}const ya=[];class sT extends sw{static EVENT=Object.freeze({UPDATED:"UPDATED",FORMATTER_UPDATED:"FORMATTER_UPDATED",REQUEST_FAILED:"REQUEST_FAILED",COLUMNS_CHANGED:"COLUMNS_CHANGED",TABLE_CHANGED:"TABLE_CHANGED",FILTERS_CHANGED:"FILTERS_CHANGED",SORTS_CHANGED:"SORTS_CHANGED",DISCONNECT:"DISCONNECT",RECONNECT:"RECONNECT",TOTALS_UPDATED:"TOTALS_UPDATED",PENDING_DATA_UPDATED:"PENDING_DATA_UPDATED"});constructor(){super(),this.listenerCount=0}listenerCount;addEventListener(e,t,n){super.addEventListener(e,t,n),this.listenerCount+=1,this.listenerCount===1&&this.startListening()}removeEventListener(e,t,n){super.removeEventListener(e,t,n),this.listenerCount-=1,this.listenerCount===0&&this.stopListening()}startListening(){}stopListening(){}get originalColumns(){return this.columns}get layoutHints(){return null}get frontColumns(){return ya}get backColumns(){return ya}get frozenColumns(){return ya}isColumnFrozen(e){return!1}get isFilterRequired(){return!1}get isReversible(){return!0}get isColumnStatisticsAvailable(){return!1}get description(){return""}get isCustomColumnsAvailable(){return!1}get isFormatColumnsAvailable(){return!1}get isExportAvailable(){return!1}get isValuesTableAvailable(){return!1}get isChartBuilderAvailable(){return!1}get isRollupAvailable(){return!1}get isSelectDistinctAvailable(){return!1}get isTotalsAvailable(){return!1}isFilterable(e){return!1}close(){}isRowMovable(){return!1}get isSeekRowAvailable(){return!1}}const ge=sT;class Bs extends w.Component{static SUCCESS_SHOW_DURATION=750;static makeCustomColumnInputEventKey(){return ze.generate()}static createCustomColumnInput(){return{eventKey:ze.generate(),name:"",formula:""}}constructor(e){super(e),this.handleAddColumnClick=this.handleAddColumnClick.bind(this),this.handleSaveClick=this.handleSaveClick.bind(this),this.handleInputChange=this.handleInputChange.bind(this),this.handleDeleteColumn=this.handleDeleteColumn.bind(this),this.handleCustomColumnUpdated=this.handleCustomColumnUpdated.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.resetRequestFailed=this.resetRequestFailed.bind(this),this.handleEditorTabNavigation=this.handleEditorTabNavigation.bind(this),this.state={inputs:[],isCustomColumnApplying:!1,errorMessage:null,hasRequestFailed:!1,isSuccessShowing:!1},this.container=null,this.successButtonTimer=null}componentDidMount(){const{customColumns:e}=this.props;this.parseCustomColumns(e),this.startListening()}componentWillUnmount(){this.stopListening(),this.successButtonTimer&&clearTimeout(this.successButtonTimer)}container;successButtonTimer;getInput=he((e,t)=>e.find(n=>n.eventKey===t));getInputIndex=he((e,t)=>e.findIndex(n=>n.eventKey===t));resetErrorMessage(){this.setState({errorMessage:null})}startListening(){const{model:e}=this.props;e.addEventListener(ge.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),e.addEventListener(ge.EVENT.UPDATED,this.handleCustomColumnUpdated),e.addEventListener(ge.EVENT.REQUEST_FAILED,this.handleRequestFailed)}stopListening(){const{model:e}=this.props;e.removeEventListener(ge.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),e.removeEventListener(ge.EVENT.UPDATED,this.handleCustomColumnUpdated),e.removeEventListener(ge.EVENT.REQUEST_FAILED,this.handleRequestFailed)}parseCustomColumns(e){if(e.length>0){const t=e.map(n=>{const s=n.split(/=(.+)/,2);return{eventKey:Bs.makeCustomColumnInputEventKey(),name:s[0],formula:s[1]}});this.setState({inputs:t})}else this.setState({inputs:[Bs.createCustomColumnInput()]})}handleAddColumnClick(){const{inputs:e}=this.state,t=[...e];t.push(Bs.createCustomColumnInput()),this.setState({inputs:t})}handleDeleteColumn(e){const{inputs:t}=this.state,n=this.getInputIndex(t,e),s=[...t];s.splice(n,1),s.length===0&&s.push(Bs.createCustomColumnInput()),this.setState({inputs:s})}handleInputChange(e,t,n){const{inputs:s}=this.state,i=this.getInputIndex(s,e),l={...this.getInput(s,e)};l[t]=n;const a=[...s];a.splice(i,1,l),this.setState({inputs:a})}handleCustomColumnUpdated(){const{isCustomColumnApplying:e}=this.state;e&&this.setState({isCustomColumnApplying:!1,isSuccessShowing:!0},()=>{this.successButtonTimer=setTimeout(()=>this.setState({isSuccessShowing:!1}),Bs.SUCCESS_SHOW_DURATION)})}handleRequestFailed(e){const t=e,{isCustomColumnApplying:n}=this.state;n&&this.setState({isCustomColumnApplying:!1,errorMessage:r.jsxs(r.Fragment,{children:[r.jsxs("p",{children:[r.jsx(X,{icon:vs})," Failed to apply custom columns."]}),r.jsxs("div",{className:"error-box",children:[t.detail.errorMessage,r.jsx("br",{}),"Table configuration:"," ",JSON.stringify(t.detail.configuration)]})]}),hasRequestFailed:!0})}handleDragEnd(e){if(hn.stopDragging(),!e.destination)return;const{inputs:t}=this.state,n=e.source.index,s=e.destination.index,i=[...t],o=t[n];i.splice(n,1),i.splice(s,0,o),this.setState({inputs:i})}handleEditorTabNavigation(e,t){const{inputs:n}=this.state;if(t){(this.container?.querySelectorAll(".btn-drag-handle")[e]).focus();return}if(e===n.length-1)this.container?.querySelector(".btn-add-column")?.focus();else{const s=e+1;(this.container?.querySelectorAll(".custom-column-input")[s]).focus()}}handleSaveClick(){const{onSave:e,customColumns:t}=this.props,{inputs:n,isCustomColumnApplying:s}=this.state;if(s)return;const i=[];n.forEach(o=>{const{name:l,formula:a}=o;l&&a&&i.push(`${l}=${a}`)}),this.resetErrorMessage(),this.setState({isCustomColumnApplying:i.length>0||t.length>0}),e(i)}resetRequestFailed(){this.setState(({hasRequestFailed:e})=>e?{hasRequestFailed:!1}:null)}renderInputs(){const{inputs:e,hasRequestFailed:t}=this.state,n=new Map;return e.forEach(({name:s})=>n.set(s,(n.get(s)??0)+1)),e.map((s,i)=>{const{eventKey:o,name:l,formula:a}=s,d=(n.get(l)??0)>1;return r.jsx(nT,{inputIndex:i,eventKey:o,name:l,formula:a,onChange:this.handleInputChange,onDeleteColumn:this.handleDeleteColumn,onTabInEditor:this.handleEditorTabNavigation,invalid:t,isDuplicate:d},o)})}renderSaveButton(){const{inputs:e,isCustomColumnApplying:t,isSuccessShowing:n}=this.state,s=e.length>1?"Save Columns":"Save Column",i=e.every(({name:a})=>a===""||Ii.isValidColumnName(a)),o=e.filter(({name:a})=>a!=="").map(({name:a})=>a),l=new Set(o).size===o.length;return r.jsxs(_,{kind:n?"success":"primary",className:K("btn-apply",{"btn-spinner":t}),disabled:n||t||!i||!l,onClick:this.handleSaveClick,children:[t&&r.jsxs("span",{children:[r.jsx(Nn,{}),r.jsx("span",{className:"btn-normal-content",children:"Applying"})]}),!n&&!t&&s,n&&r.jsxs(r.Fragment,{children:[r.jsx(X,{icon:lr})," Success"]})]})}render(){const{onCancel:e}=this.props,{errorMessage:t}=this.state;return r.jsxs("div",{role:"presentation",className:"custom-column-builder-container",ref:n=>{this.container=n},onClick:this.resetRequestFailed,onFocus:this.resetRequestFailed,children:[r.jsx("hr",{}),r.jsx(Al,{onDragStart:hn.startDragging,onDragEnd:this.handleDragEnd,children:r.jsx(nr,{droppableId:"droppable-custom-columns",children:(n,s)=>r.jsxs("div",{ref:n.innerRef,...n.droppableProps,className:K("droppable-container",{dragging:s.draggingFromThisWith}),children:[this.renderInputs(),n.placeholder]})})}),r.jsx("div",{className:"pt-1 px-3",children:r.jsx(_,{kind:"ghost",className:"btn-add-column",onClick:this.handleAddColumnClick,icon:ys,children:"Add Another Column"})}),r.jsxs("div",{className:"custom-column-builder-footer",children:[t&&r.jsx("div",{className:"error-message",children:t}),r.jsxs("div",{className:"d-flex justify-content-end",children:[r.jsx(_,{kind:"secondary",className:"mr-2",onClick:e,children:"Cancel"}),this.renderSaveButton()]})]})]})}}const iT=Bs;var Su=(c=>(c.ADVANCED_SETTINGS="ADVANCED_SETTINGS",c.AGGREGATIONS="AGGREGATIONS",c.AGGREGATION_EDIT="AGGREGATIONS_EDIT",c.CHART_BUILDER="CHART_BUILDER",c.CUSTOM_COLUMN_BUILDER="CUSTOM_COLUMN_BUILDER",c.QUICK_FILTERS="QUICK_FILTERS",c.ROLLUP_ROWS="ROLLUP_ROWS",c.SEARCH_BAR="SEARCH_BAR",c.SELECT_DISTINCT="SELECT_DISTINCT",c.TABLE_EXPORTER="TABLE_EXPORTER",c.VISIBILITY_ORDERING_BUILDER="VISIBILITY_ORDERING_BUILDER",c.CONDITIONAL_FORMATTING="CONDITIONAL_FORMATTING",c.CONDITIONAL_FORMATTING_EDIT="CONDITIONAL_FORMATTING_EDIT",c.GOTO="GOTO",c))(Su||{});const De=Su;const Ui=ee.module("RollupRows"),oT=150,$o="grouped-rollup-rows",Wo="ungrouped-rollup-rows";class Qt extends w.Component{static SORT=Object.freeze({ASCENDING:"ASC",DESCENDING:"DESC"});static defaultProps={config:null,onChange:()=>{}};static renderColumn({item:e,isClone:t,selectedCount:n}){const s=e?.name,i=t!==void 0&&t?`${n}`:void 0,o=t!==void 0&&t?"item-list-item-clone":"";return rn.renderTextItem({text:s,badgeText:i,className:o})}static addGroupings(e,t,n=e.length){if(t==null||t.length===0)return e;let s=n;const i=e.filter((o,l)=>t.includes(o)?(l<s&&(s-=1),!1):!0);return i.splice(s,0,...t),i}static isGroupable(e){return!F.isDecimalType(e.type)}constructor(e){super(e),this.handleDeleteClicked=this.handleDeleteClicked.bind(this),this.handleSearchChange=this.handleSearchChange.bind(this),this.handleUngroupedSelect=this.handleUngroupedSelect.bind(this),this.handleUngroupedSelectionChange=this.handleUngroupedSelectionChange.bind(this),this.handleDragStart=this.handleDragStart.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleGroupedSelectionChange=this.handleGroupedSelectionChange.bind(this),this.handleShowConstituentsChange=this.handleShowConstituentsChange.bind(this),this.handleShowNonAggregatedColumnsChange=this.handleShowNonAggregatedColumnsChange.bind(this),this.handleSortAscending=this.handleSortAscending.bind(this),this.handleSortDescending=this.handleSortDescending.bind(this),this.renderGroupedItem=this.renderGroupedItem.bind(this),this.ungroupedList=ae.createRef(),this.groupedList=ae.createRef();const{config:t}=e,{columns:n=[],showConstituents:s=!0,showNonAggregatedColumns:i=!0}=t??{};this.state={ungroupedSelectedRanges:[],columns:n,groupedSelectedRanges:[],searchFilter:"",showConstituents:s,showNonAggregatedColumns:i,dragSource:null,sort:null}}componentDidUpdate(e,t){const{config:n}=this.props,{columns:s,showConstituents:i,showNonAggregatedColumns:o}=this.state;n!==e.config?this.updateFromConfig():(s!==t.columns||i!==t.showConstituents||o!==t.showNonAggregatedColumns)&&(n==null||s!==n.columns||i!==n.showConstituents||o!==n.showNonAggregatedColumns)&&this.sendChange()}componentWillUnmount(){this.search.cancel()}ungroupedList;groupedList;handleSearchChange(e){const t=e.target.value;if(this.setState({searchFilter:t}),!t){this.search.cancel(),this.resetSelection();return}this.search(t)}handleSortAscending(){this.setState(({sort:e})=>({sort:e===Qt.SORT.ASCENDING?null:Qt.SORT.ASCENDING}))}handleSortDescending(){this.setState(({sort:e})=>({sort:e===Qt.SORT.DESCENDING?null:Qt.SORT.DESCENDING}))}resetSelection(){this.setState({ungroupedSelectedRanges:[],groupedSelectedRanges:[]})}search=Ge(e=>{const t=this.getSortedUngroupedColumns(),n=[];let s=null;for(let i=0;i<t.length;i+=1)t[i].name.toLowerCase().includes(e.toLowerCase())&&(s==null&&(s=i),n.push([i,i]));N(s),this.setState({ungroupedSelectedRanges:n}),n.length>0&&this.ungroupedList.current&&this.ungroupedList.current.scrollToItem(s)},oT);handleDragStart(e){Ui.debug("handleDragStart",e),document.documentElement.classList.add("drag-pointer-events-none"),this.setState({dragSource:e.source})}handleDragEnd(e){Ui.debug("handleDragEnd",e),document.documentElement.classList.remove("drag-pointer-events-none"),this.setState({dragSource:null});const{destination:t,source:n}=e;if(t==null||n==null)return;if(t.droppableId===Wo){this.setState(({groupedSelectedRanges:o,columns:l})=>{const a=[...l];return hn.reorder(a,o,[],0),{columns:a,ungroupedSelectedRanges:[],groupedSelectedRanges:[]}});return}const s=n.droppableId===$o;let i=t.index;s&&n.index<t.index&&(i+=1),this.setState(({columns:o,ungroupedSelectedRanges:l,groupedSelectedRanges:a})=>{const d=[...o],h=s?d:this.getSortedUngroupedColumns().map(C=>C.name),u=s?a:l,m=hn.reorder(h,u,d,i),g=s?hn.adjustDestinationIndex(i,a):i,p=[[g,g+m.length-1]];return{columns:d,ungroupedSelectedRanges:[],groupedSelectedRanges:p}}),this.resetSelection()}handleUngroupedSelect(e){Ui.debug("handleUngroupedSelect"),this.setState(({columns:t})=>({columns:Qt.addGroupings(t,[this.getSortedUngroupedColumns()[e].name]),ungroupedSelectedRanges:[],groupedSelectedRanges:[]}))}handleUngroupedSelectionChange(e){Ui.debug2("handleUngroupedSelectionChange",e),this.setState(({ungroupedSelectedRanges:t})=>e===t?null:{ungroupedSelectedRanges:e,groupedSelectedRanges:[]})}handleGroupedSelectionChange(e){Ui.debug2("handleGroupedSelectedRanges",e),this.setState(({groupedSelectedRanges:t})=>e===t?null:{groupedSelectedRanges:e,ungroupedSelectedRanges:[]})}handleDeleteClicked(e){this.setState(({columns:t})=>{const n=t.slice();return n.splice(e,1),{columns:n}})}handleShowConstituentsChange(){this.setState(({showConstituents:e})=>({showConstituents:!e}))}handleShowNonAggregatedColumnsChange(){this.setState(({showNonAggregatedColumns:e})=>({showNonAggregatedColumns:!e}))}updateFromConfig(){const{config:e}=this.props,{columns:t=[],showConstituents:n=!0,showNonAggregatedColumns:s=!0}=e??{};this.setState({columns:t,showConstituents:n,showNonAggregatedColumns:s})}sendChange(){const{onChange:e}=this.props,{columns:t,showConstituents:n,showNonAggregatedColumns:s}=this.state;e({columns:t,showConstituents:n,showNonAggregatedColumns:s})}getCachedUngroupedColumns=Te((e,t)=>e.filter(n=>Qt.isGroupable(n)&&t.find(s=>s===n.name)==null));getCachedSortedColumns=Te((e,t)=>t==null?[...e]:F.sortColumns(e,t===Qt.SORT.ASCENDING));getUngroupedColumns(){const{model:e}=this.props,{columns:t}=this.state,{originalColumns:n}=e;return this.getCachedUngroupedColumns(n,t)}getSortedUngroupedColumns(){const{sort:e}=this.state,t=this.getUngroupedColumns();return this.getCachedSortedColumns(t,e)}renderGroupedItem({item:e,itemIndex:t,isClone:n,selectedCount:s}){const o=`${n!==void 0&&n?"":" ".repeat(t)}${e}`,l=n!==void 0&&n?`${s}`:void 0,a=n!==void 0&&n?"item-list-item-clone":"";return r.jsxs(r.Fragment,{children:[rn.renderTextItem({text:o,badgeText:l,className:a}),(n===void 0||!n)&&r.jsx(_,{kind:"ghost",className:"btn btn-link btn-link-icon btn-delete-grouping float-right",onClick:()=>this.handleDeleteClicked(t),children:r.jsx(X,{icon:Wt})})]})}render(){const{columns:e,dragSource:t,searchFilter:n,groupedSelectedRanges:s,ungroupedSelectedRanges:i,showConstituents:o,showNonAggregatedColumns:l,sort:a}=this.state,d=this.getSortedUngroupedColumns();let h=e.length*rn.DEFAULT_ROW_HEIGHT;t?.droppableId===Wo&&(h+=rn.DEFAULT_ROW_HEIGHT);const u=d.length*rn.DEFAULT_ROW_HEIGHT+10,m=Math.min(3*rn.DEFAULT_ROW_HEIGHT,u);return r.jsx("div",{role:"menu",className:K("rollup-rows",{"is-dragging":t!=null}),tabIndex:0,children:r.jsxs(Al,{onDragEnd:this.handleDragEnd,onDragStart:this.handleDragStart,children:[r.jsxs("div",{className:"rollup-rows-group-by",children:[r.jsx("div",{className:"section-title",children:"Group By"}),e.length===0&&r.jsx(nr,{droppableId:"placeholder",children:(g,p)=>r.jsx("div",{className:K("placeholder","text-muted",{"is-dragging-from-this":p.draggingFromThisWith,"is-dragging-over":p.isDraggingOver,"is-dropping":p.draggingOverWith}),ref:g.innerRef,...g.droppableProps,children:"To create a rollup, drag columns from the list below and drop them into this area."})}),e.length>0&&r.jsx(rn,{draggingItemClassName:"rollup-rows-dragging-grouped-item",draggablePrefix:$o,droppableId:$o,itemCount:e.length,items:e,offset:0,onSelectionChange:this.handleGroupedSelectionChange,ref:this.groupedList,renderItem:this.renderGroupedItem,selectedRanges:s,style:{height:h},isMultiSelect:!0})]}),r.jsxs("div",{className:"rollup-rows-available-columns",children:[r.jsx("div",{className:"section-title",children:"Available Grouping Columns"}),r.jsxs("div",{className:"top-menu",children:[r.jsx(xi,{className:"w-100",value:n,matchCount:n?i.length:void 0,placeholder:"Find column...",onChange:this.handleSearchChange}),r.jsxs(_,{kind:"ghost",className:K("btn-link btn-link-icon",{active:a===Qt.SORT.ASCENDING}),onClick:this.handleSortAscending,children:[r.jsx(X,{icon:dr}),r.jsx(tt,{children:"Sort ascending"})]}),r.jsxs(_,{kind:"ghost",className:K("btn-link btn-link-icon",{active:a===Qt.SORT.DESCENDING}),onClick:this.handleSortDescending,children:[r.jsx(X,{icon:cr}),r.jsx(tt,{children:"Sort descending"})]})]}),r.jsx(rn,{className:"rollup-available-grouping-columns",draggablePrefix:Wo,droppableId:Wo,itemCount:d.length,items:d,renderItem:Qt.renderColumn,offset:0,onSelect:this.handleUngroupedSelect,onSelectionChange:this.handleUngroupedSelectionChange,ref:this.ungroupedList,selectedRanges:i,style:{maxHeight:u,minHeight:m},isDropDisabled:t?.droppableId!==$o,isMultiSelect:!0}),r.jsxs("div",{className:"bottom-menu",children:[r.jsx("div",{className:"label",children:"Show:"}),r.jsx(nn,{checked:o,onChange:this.handleShowConstituentsChange,children:"Constituents"}),r.jsx(nn,{checked:l,onChange:this.handleShowNonAggregatedColumnsChange,children:"Non-Aggregated Columns"})]})]})]})})}}const lT=Qt;const aT=ee.module("TableCsvExporter");class _e extends w.Component{static FILENAME_DATE_FORMAT="yyyy-MM-dd-HHmmss";static DOWNLOAD_STATUS={INITIATING:"INITIATING",DOWNLOADING:"DOWNLOADING",FINISHED:"FINISHED",CANCELED:"CANCELED"};static DOWNLOAD_ROW_OPTIONS={ALL_ROWS:"ALL_ROWS",SELECTED_ROWS:"SELECTED_ROWS",CUSTOMIZED_ROWS:"CUSTOMIZED_ROWS"};static CUSTOMIZED_ROWS_OPTIONS={FIRST:"FIRST",LAST:"LAST"};static DEFAULT_DOWNLOAD_ROWS=100;static defaultProps={onDownloadStart:()=>{},isDownloading:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:null,selectedRanges:[]};static getDateString(){return I.i18n.DateTimeFormat.format(_e.FILENAME_DATE_FORMAT,new Date)}constructor(e){super(e),this.handleDownloadClick=this.handleDownloadClick.bind(this),this.handleDownloadRowOptionChanged=this.handleDownloadRowOptionChanged.bind(this),this.handleCustomizedDownloadRowOptionChanged=this.handleCustomizedDownloadRowOptionChanged.bind(this),this.handleCustomizedDownloadRowsChanged=this.handleCustomizedDownloadRowsChanged.bind(this),this.handleIncludeColumnHeadersChanged=this.handleIncludeColumnHeadersChanged.bind(this),this.handleIncludeHiddenColumnsChanged=this.handleIncludeHiddenColumnsChanged.bind(this),this.handleUseUnformattedValuesChanged=this.handleUseUnformattedValuesChanged.bind(this);const{name:t}=e;this.state={fileName:`${t}-${_e.getDateString()}.csv`,downloadRowOption:_e.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,customizedDownloadRowOption:_e.CUSTOMIZED_ROWS_OPTIONS.FIRST,customizedDownloadRows:_e.DEFAULT_DOWNLOAD_ROWS,includeColumnHeaders:!0,includeHiddenColumns:!1,useUnformattedValues:!1,errorMessage:null,id:ze.generate()}}getSnapshotRanges(){const{model:e,selectedRanges:t}=this.props,{downloadRowOption:n,customizedDownloadRowOption:s,customizedDownloadRows:i}=this.state,{rowCount:o,columnCount:l}=e;let a=[];switch(n){case _e.DOWNLOAD_ROW_OPTIONS.ALL_ROWS:a.push(new J(0,0,l-1,o-1));break;case _e.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS:a=t.map(d=>({...d,startColumn:0,endColumn:l-1})).sort((d,h)=>d.startRow!=null&&h.startRow!=null?d.startRow-h.startRow:0);break;case _e.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS:switch(s){case _e.CUSTOMIZED_ROWS_OPTIONS.FIRST:a.push(new J(0,0,l-1,Math.min(i-1,o-1)));break;case _e.CUSTOMIZED_ROWS_OPTIONS.LAST:a.push(new J(0,Math.max(0,o-i),l-1,o-1));break}break}return a}getModelRanges(e){const{userColumnWidths:t,movedColumns:n}=this.props,{includeHiddenColumns:s}=this.state,i=Ce.getHiddenColumns(t);let o=O.getModelRanges(e,n);if(!s&&i.length>0){const l=i.map(J.makeColumn);o=J.subtractRangesFromRanges(o,l)}return o}resetDownloadState(){this.setState({errorMessage:null})}async handleDownloadClick(){const{model:e,isDownloading:t,onDownloadStart:n,onDownload:s,onCancel:i}=this.props,{fileName:o,includeColumnHeaders:l,useUnformattedValues:a}=this.state;if(t){i();return}this.resetDownloadState();const d=this.getSnapshotRanges(),h=this.getModelRanges(d);if(this.validateOptionInput()){n();try{const u=await e.export(),m=u.setViewport(0,0);await m.getViewportData(),s(o,u,m,d,h,l,a)}catch(u){aT.error("CSV download failed",u),this.setState({errorMessage:r.jsxs("p",{children:[r.jsx(X,{icon:vs})," ",`${u}`]})}),i()}}}handleDownloadRowOptionChanged(e){this.setState({downloadRowOption:e.target.value})}handleCustomizedDownloadRowOptionChanged(e){this.setState({customizedDownloadRowOption:e.target.value})}handleCustomizedDownloadRowsChanged(e){this.setState({customizedDownloadRows:parseInt(e.target.value,10)})}handleIncludeColumnHeadersChanged(){this.setState(({includeColumnHeaders:e})=>({includeColumnHeaders:!e}))}handleIncludeHiddenColumnsChanged(){this.setState(({includeHiddenColumns:e})=>({includeHiddenColumns:!e}))}handleUseUnformattedValuesChanged(){this.setState(({useUnformattedValues:e})=>({useUnformattedValues:!e}))}validateOptionInput(){const{selectedRanges:e}=this.props,{downloadRowOption:t,customizedDownloadRows:n}=this.state;return t===_e.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS&&e.length===0?(this.setState({errorMessage:r.jsxs("p",{children:[r.jsx(X,{icon:vs})," No rows selected. Please select some rows in the table."]})}),!1):t===_e.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS&&n<=0?(this.setState({errorMessage:r.jsxs("p",{children:[r.jsx(X,{icon:vs})," Number of rows to output must be greater than 0"]})}),!1):!0}render(){const{model:e,isDownloading:t,tableDownloadProgress:n,tableDownloadEstimatedTime:s,selectedRanges:i,tableDownloadStatus:o}=this.props,{fileName:l,downloadRowOption:a,customizedDownloadRowOption:d,customizedDownloadRows:h,includeColumnHeaders:u,includeHiddenColumns:m,useUnformattedValues:g,errorMessage:p,id:C}=this.state,{rowCount:f}=e;return r.jsxs("div",{className:"table-csv-exporter",children:[r.jsx("div",{className:"section-title",children:"Download Rows"}),r.jsx("div",{className:"form-group",children:r.jsxs(Hl,{onChange:this.handleDownloadRowOptionChanged,value:a,disabled:t,children:[r.jsxs(zn,{value:_e.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,"data-testid":"radio-csv-exporter-download-all",children:["All Rows",r.jsx("span",{className:"text-muted ml-2",children:`(${f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`})]}),r.jsxs(zn,{value:_e.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS,"data-testid":"radio-csv-exporter-only-selected",children:["Only Selected Rows",r.jsx("span",{className:"text-muted ml-2",children:i.length>0?`(${J.rowCount(i).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`:null})]}),r.jsx(zn,{value:_e.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS,"data-testid":"radio-csv-exporter-customized-rows",children:r.jsxs("div",{className:"radio-input-row",role:"presentation",onClick:()=>{this.setState({downloadRowOption:_e.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS})},children:[r.jsxs("select",{value:d,"data-testid":"select-csv-exporter-customized-rows",className:"custom-select",disabled:t,onChange:this.handleCustomizedDownloadRowOptionChanged,children:[r.jsx("option",{value:"FIRST",children:"First"}),r.jsx("option",{value:"LAST",children:"Last"})]}),r.jsx("input",{type:"number",className:"form-control",id:`customizedRows-${C}`,"data-testid":"input-csv-exporter-customized-rows",name:`customizedRows-${C}`,placeholder:"100",value:h,disabled:t,onChange:this.handleCustomizedDownloadRowsChanged}),r.jsx("div",{children:"Rows"})]})})]})}),r.jsxs("div",{className:"form-group",children:[r.jsx("label",{htmlFor:`customizedRows-${C}`,children:"File Name"}),r.jsx("input",{type:"text",className:"form-control",id:`filename-${C}`,"data-testid":"input-csv-exporter-file-name",name:`filename-${C}`,value:l,onChange:S=>{this.setState({fileName:S.target.value})},disabled:t})]}),r.jsxs("div",{className:"checkbox-options",children:[r.jsx(nn,{checked:u,onChange:this.handleIncludeColumnHeadersChanged,children:"Include column headers"}),r.jsx(nn,{checked:m,onChange:this.handleIncludeHiddenColumnsChanged,children:"Include hidden columns"}),r.jsx(nn,{checked:g,onChange:this.handleUseUnformattedValuesChanged,children:"Use unformatted values"})]}),r.jsxs("div",{className:"section-footer flex-column",children:[p!=null&&r.jsx("div",{className:"error-message",children:p}),o&&r.jsxs("div",{className:"download-status",children:[(o===_e.DOWNLOAD_STATUS.DOWNLOADING||o===_e.DOWNLOAD_STATUS.INITIATING)&&r.jsxs(r.Fragment,{children:[o===_e.DOWNLOAD_STATUS.INITIATING&&r.jsx("div",{className:"text-muted",children:"Starting Download..."}),o===_e.DOWNLOAD_STATUS.DOWNLOADING&&r.jsxs("div",{className:"text-muted d-flex justify-content-between",children:[r.jsx("span",{children:s||s===0?`Estimated time: ${_l.formatElapsedTime(s)}`:null}),r.jsx("span",{children:`${n}%`})]})]}),o===_e.DOWNLOAD_STATUS.FINISHED&&r.jsx("div",{className:"text-muted text-right",children:"Download Completed"}),o===_e.DOWNLOAD_STATUS.CANCELED&&r.jsx("div",{className:"text-muted",children:"Download Canceled"}),(o===_e.DOWNLOAD_STATUS.DOWNLOADING||o===_e.DOWNLOAD_STATUS.INITIATING)&&r.jsx("div",{className:"progress",children:r.jsx("div",{className:"progress-bar progress-bar-striped progress-bar-animated",style:{width:`${n}%`}})}),o===_e.DOWNLOAD_STATUS.FINISHED&&r.jsx("div",{className:"progress",children:r.jsx("div",{className:"progress-bar bg-success",style:{width:`${n}%`}})})]}),r.jsxs(_,{kind:"primary","data-testid":"btn-csv-exporter-download",className:K("btn-downloading",{"btn-spinner btn-cancelable":t}),onClick:this.handleDownloadClick,children:[t&&r.jsxs("span",{children:[r.jsx(Nn,{}),r.jsx("span",{className:"btn-normal-content",children:"Downloading"}),r.jsx("span",{className:"btn-hover-content",children:"Cancel"})]}),!t&&"Download"]})]})]})}}const Os=_e,_n=ee.module("TableSaver"),rT="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function dT(c){return c.added!==void 0}function cT(c){if(!dT(c))throw new Error("event is not UpdateEventData")}class Hn extends w.PureComponent{static DOWNLOAD_CELL_CHUNK=6e3;static SNAPSHOT_BUFFER_SIZE=5;static STREAM_TIMEOUT=8e3;static SNAPSHOT_HANDLER_TIMEOUT=5;static defaultProps={getDownloadWorker:()=>Promise.reject(new Error("Download worker not provided")),isDownloading:!1,onDownloadCompleted:()=>{},onDownloadCanceled:()=>{},onDownloadProgressUpdate:()=>{}};static csvEscapeString(e){return`"${e.replace(/"/g,'""')}"`}constructor(e){super(e),this.handlePortMessage=this.handlePortMessage.bind(this),this.handleSnapshotResolved=this.handleSnapshotResolved.bind(this),this.handleDownloadTimeout=this.handleDownloadTimeout.bind(this),this.state={},this.gridRanges=[],this.gridRangeCounter=0,this.rangedSnapshotsTotal=[],this.rangedSnapshotCounter=0,this.includeColumnHeaders=!0,this.useUnformattedValues=!1,this.snapshotsTotal=0,this.snapshotCounter=0,this.snapshotsBuffer=new Map,this.currentSnapshotIndex=0,this.snapshotPending=0,this.cancelableSnapshots=[],this.iframes=[],this.useBlobFallback=!1}componentDidMount(){const{getDownloadWorker:e}=this.props;e().then(t=>{_n.info("found active service worker"),this.sw=t,this.sw.postMessage("ping")}).catch(t=>{_n.warn("Download csv is not optimized.",t),this.useBlobFallback=!0})}componentWillUnmount(){this.iframes.length>0&&this.iframes.forEach(e=>{e.remove()}),this.streamTimeout&&clearTimeout(this.streamTimeout),this.snapshotHandlerTimeout&&clearTimeout(this.snapshotHandlerTimeout)}sw;port;fileWriter;table;tableSubscription;columns;fileName;includeColumnHeaders;useUnformattedValues;chunkRows;gridRanges;gridRangeCounter;rangedSnapshotsTotal;rangedSnapshotCounter;snapshotsTotal;snapshotCounter;snapshotsBuffer;currentSnapshotIndex;snapshotPending;cancelableSnapshots;streamTimeout;snapshotHandlerTimeout;downloadStartTime;iframes;useBlobFallback;getCachedCustomColumnFormatFlag=Bn(Gn.isCustomColumnFormatDefined,{max:1e4});createWriterStream(e){const t=this.useBlobFallback,n=[];let s=null;t&&(s=TextEncoder.prototype.encode.bind(new TextEncoder));const{fileName:i}=this,o={};return t?(o.write=l=>{N(s),l.header!==void 0&&n.push(s(l.header)),l.rows!==void 0&&n.push(s(l.rows))},o.close=()=>{N(i);const l=new Blob(n,{type:"application/octet-stream; charset=utf-8"}),a=document.createElement("a");a.href=URL.createObjectURL(l),a.download=i,a.click()},o.abort=()=>{e.postMessage({cancel:!0}),e.close()}):(o.write=l=>{e.postMessage(l)},o.close=()=>{e.postMessage({end:!0}),e.close()},o.abort=()=>{e.postMessage({cancel:!0}),e.close()}),new WritableStream(o)}startDownload(e,t,n,s,i,o,l){const{isDownloading:a}=this.props;if(a)return;this.downloadStartTime=Date.now(),_n.info(`start downloading ${e}`),this.table=t,this.columns=Ce.columnsFromRanges(i,t.columns),this.tableSubscription=n,this.gridRanges=s,this.includeColumnHeaders=o,this.useUnformattedValues=l;const d=encodeURIComponent(e.replace(/\//g,":")).replace(/['()]/g,escape).replace(/\*/g,"%2A"),h=new MessageChannel;if(this.port=h.port1,this.fileName=e,this.fileWriter=this.createWriterStream(this.port).getWriter(),this.useBlobFallback){this.writeCsvTable(o);return}this.sw&&this.sw.postMessage({encodedFileName:d},[h.port2]),this.port.onmessage=this.handlePortMessage}finishDownload(){this.table&&this.table.close(),this.tableSubscription&&this.tableSubscription.close(),this.fileWriter&&this.fileWriter.close();const{onDownloadCompleted:e}=this.props;e(),this.resetTableSaver(),this.downloadStartTime!==void 0&&_n.info(`download finished, total elapsed time ${(Date.now()-this.downloadStartTime)/1e3} seconds`)}cancelDownload(){this.table&&this.table.close(),this.tableSubscription&&this.tableSubscription.close(),this.fileWriter&&this.fileWriter.abort(),this.cancelableSnapshots.forEach(t=>{t&&(t.catch(()=>null),t.cancel())});const{onDownloadCanceled:e}=this.props;e(),this.resetTableSaver()}resetTableSaver(){this.table=void 0,this.tableSubscription=void 0,this.columns=void 0,this.chunkRows=void 0,this.gridRanges=[],this.gridRangeCounter=0,this.rangedSnapshotsTotal=[],this.rangedSnapshotCounter=0,this.includeColumnHeaders=!0,this.useUnformattedValues=!1,this.snapshotsTotal=0,this.snapshotCounter=0,this.snapshotsBuffer=new Map,this.currentSnapshotIndex=0,this.snapshotPending=0,this.cancelableSnapshots=[],this.streamTimeout!=null&&clearTimeout(this.streamTimeout),this.snapshotHandlerTimeout!=null&&clearTimeout(this.snapshotHandlerTimeout),this.streamTimeout=void 0,this.snapshotHandlerTimeout=void 0}handleDownloadTimeout(){_n.info("download canceled"),this.cancelDownload()}writeTableHeader(){let e="";if(this.columns)for(let t=0;t<this.columns.length;t+=1)e+=this.columns[t].name,e+=t===this.columns.length-1?`
|
|
21
|
-
`:",";this.fileWriter?.write({header:e}).then(()=>null)}startWriteTableBody(){this.columns&&this.gridRanges!=null&&(this.chunkRows=Math.floor(Hn.DOWNLOAD_CELL_CHUNK/this.columns.length),this.rangedSnapshotsTotal=this.gridRanges.map(e=>(N(e.endRow),N(e.startRow),N(this.chunkRows),Math.ceil((e.endRow-e.startRow+1)/this.chunkRows))),this.snapshotsTotal=this.rangedSnapshotsTotal.reduce((e,t)=>e+t),_n.info("start writing table, total snapshots: ",this.snapshotsTotal),this.makeSnapshot(Math.min(Hn.SNAPSHOT_BUFFER_SIZE,this.snapshotsTotal)))}writeCsvTable(e){e&&this.writeTableHeader(),this.startWriteTableBody()}writeSnapshot(e,t,n){if(this.currentSnapshotIndex===e&&this.fileWriter){for(;this.snapshotsBuffer.has(this.currentSnapshotIndex);){const s=this.snapshotsBuffer.get(this.currentSnapshotIndex);N(s),this.fileWriter.write({rows:this.convertSnapshotIntoCsv(s)}),this.snapshotsBuffer.delete(this.currentSnapshotIndex),this.currentSnapshotIndex+=1,this.updateDownloadProgress(e)}if(this.snapshotsTotal&&this.currentSnapshotIndex>=this.snapshotsTotal){this.finishDownload();return}}this.snapshotCounter&&this.snapshotsTotal&&this.snapshotCounter<this.snapshotsTotal&&(_n.debug2(`
|
|
22
|
-
current range index: ${this.gridRangeCounter},
|
|
23
|
-
snapshotIndexCounter: ${this.snapshotCounter},
|
|
24
|
-
currentRangedSnapshotIndex : ${this.rangedSnapshotCounter},
|
|
25
|
-
snapshotpending: ${this.snapshotPending},
|
|
26
|
-
buffered ${this.snapshotsBuffer.size}
|
|
27
|
-
making ${Math.min(Hn.SNAPSHOT_BUFFER_SIZE-this.snapshotsBuffer.size-this.snapshotPending,this.snapshotsTotal-this.snapshotCounter)} more snapshots
|
|
28
|
-
`),this.makeSnapshot(Math.min(Hn.SNAPSHOT_BUFFER_SIZE-this.snapshotsBuffer.size-this.snapshotPending,this.snapshotsTotal-this.snapshotCounter)))}updateDownloadProgress(e){if(e!=null&&this.snapshotsTotal!=null&&this.downloadStartTime!=null){const{onDownloadProgressUpdate:t}=this.props,n=Math.floor(e*100/this.snapshotsTotal),s=e>1?Math.floor((Date.now()-this.downloadStartTime)*(this.snapshotsTotal-e)/e/1e3):null;t(n,s)}}convertSnapshotIntoCsv(e){let t="";const n=e.added.iterator(),{formatter:s}=this.props,i=[];for(;n.hasNext();)i.push(n.next().value);N(this.columns);const{useUnformattedValues:o}=this;for(let l=0;l<i.length;l+=1){const a=i[l];for(let d=0;d<this.columns.length;d+=1){const{type:h,name:u}=this.columns[d];let m=null;if(o){let g=e.getData(a,this.columns[d])??"";g!==""&&F.isDateType(h)&&(g=I.i18n.DateTimeFormat.format(rT,g,I.i18n.TimeZone.getTimeZone(s.timeZone))),m=g.toString()}else{const g=this.getCachedCustomColumnFormatFlag(s,u,h);let p=null;if(!g){const C=e.getFormat(a,this.columns[d]);p=C?.formatString!=null?C:null}p?m=s.getFormattedString(e.getData(a,this.columns[d]),h,u,p):m=s.getFormattedString(e.getData(a,this.columns[d]),h,u)}t+=Hn.csvEscapeString(m),t+=d===this.columns.length-1?`
|
|
29
|
-
`:","}}return t}makeSnapshot(e){if(e<=0)return;N(this.gridRangeCounter);let t=0,n=this.gridRanges[this.gridRangeCounter];for(N(this.tableSubscription),N(this.columns);t<e;){N(n),N(n.startRow),N(n.endRow),N(this.rangedSnapshotCounter),N(this.chunkRows);const s=n.startRow+this.rangedSnapshotCounter*this.chunkRows,i=Math.min(s+this.chunkRows-1,n.endRow),o=this.snapshotCounter;this.cancelableSnapshots.push(ve.makeCancelable(this.tableSubscription.snapshot(I.RangeSet.ofRange(s,i),this.columns).then(l=>(cT(l),this.handleSnapshotResolved(l,o,s,i),o)).catch(l=>{_n.error(l)}),l=>{_n.info(`snapshot ${l} has been canceled`)})),this.rangedSnapshotCounter+=1,this.snapshotCounter+=1,this.snapshotPending+=1,this.rangedSnapshotCounter>=this.rangedSnapshotsTotal[this.gridRangeCounter]&&(this.gridRangeCounter+=1,this.rangedSnapshotCounter=0,n=this.gridRanges[this.gridRangeCounter]),t+=1}}handlePortMessage({data:e}){const{download:t,readableStreamPulling:n}=e;if(!this.useBlobFallback){if(t!=null){const{includeColumnHeaders:s}=this;this.makeIframe(`${t}`),this.writeCsvTable(s)}n!=null&&(this.useBlobFallback||(this.streamTimeout!=null&&clearTimeout(this.streamTimeout),this.streamTimeout=setTimeout(this.handleDownloadTimeout,Hn.STREAM_TIMEOUT)))}}handleSnapshotResolved(e,t,n,s){this.snapshotHandlerTimeout=setTimeout(()=>{this.snapshotsBuffer.set(t,e),this.snapshotPending-=1,this.writeSnapshot(t,n,s),this.cancelableSnapshots[t]=null},Hn.SNAPSHOT_HANDLER_TIMEOUT)}makeIframe(e){const t=document.createElement("iframe");t.hidden=!0,t.src=`download/${e}`,t.name="iframe",document.body.appendChild(t),this.iframes.push(t)}render(){return null}}function hT(c){const{group:e,onDelete:t,onColorChange:n,onNameChange:s,validateName:i}=c,{isNew:o}=e,l=w.useRef(e),a=w.useRef(null),d=w.useRef(null),[h,u]=w.useState(!1),[m,g]=w.useState(o?"":e.name),[p,C]=w.useState(o),[f,S]=w.useState(!1),v=m!==e.name?i(m):"",b=o&&!f||v==="",T=w.useCallback(()=>{u(!1)},[]);w.useEffect(function(){p&&a.current&&(a.current.focus(),a.current.select())},[p]),w.useEffect(function(){return()=>{l.current.isNew&&t(l.current)}},[t]),w.useEffect(function(){return h&&(d.current?.click(),d.current?.focus(),window.addEventListener("click",T,!0)),()=>window.removeEventListener("click",T,!0)},[h,T]);const y=()=>{b&&(s(e,m),C(!1))},E=()=>{if(o){t(e);return}g(e.name),C(!1)},R=x=>{S(!0),x.key==="Enter"&&(x.stopPropagation(),y()),x.key===" "&&x.stopPropagation(),x.key==="Escape"&&E()};return p?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"editing-container",children:[r.jsx("input",{ref:a,className:K("form-control",{"is-invalid":!b}),value:m,placeholder:"Group Name",onChange:x=>g(x.target.value),onKeyDown:R,onBlur:()=>S(!0)}),r.jsx(_,{kind:"ghost",icon:Yn,tooltip:"Confirm",onClick:y}),r.jsx(_,{kind:"ghost",icon:dg,tooltip:"Cancel",onClick:E})]}),!b&&r.jsx("p",{className:"mb-0 validate-label-error text-danger",children:v})]}):r.jsxs("div",{className:"group-name-wrapper",children:[r.jsx("span",{className:"column-name",children:m}),r.jsx(_,{className:"p-1 mx-1",kind:"ghost",icon:mo,tooltip:"Edit",onClick:()=>{C(!0)}}),r.jsxs("span",{className:"right-buttons",children:[r.jsx(_,{kind:"ghost",icon:Wt,tooltip:"Delete group",onClick:()=>t(e)}),r.jsx(_,{kind:"ghost",className:"color-swatch mr-1",icon:e.color!==void 0?r.jsxs("span",{className:"fa-layers",children:[r.jsx(X,{className:"color-swatch",icon:dl,color:Xe.white,transform:"down-1"}),r.jsx(X,{className:"color-swatch",icon:dl,color:e.color,transform:"shrink-2 down-1"})]}):cg,tooltip:"Set color",onClick:()=>u(x=>!x)}),h&&r.jsxs(r.Fragment,{children:[r.jsx("input",{"aria-label":"Color input",ref:d,type:"color",list:"presetColors",value:e.color??Xe["content-bg"],style:{visibility:"hidden",width:0,height:0,padding:0,border:0},onChange:x=>{e.color=x.target.value,n(e,x.target.value)}}),r.jsxs("datalist",{id:"presetColors",children:[r.jsx("option",{children:Xe["content-bg"]}),r.jsx("option",{children:Xe.primary}),r.jsx("option",{children:Xe.foreground}),r.jsx("option",{children:Xe.green}),r.jsx("option",{children:Xe.yellow}),r.jsx("option",{children:Xe.orange}),r.jsx("option",{children:Xe.red}),r.jsx("option",{children:Xe.purple}),r.jsx("option",{children:Xe.blue}),r.jsx("option",{children:Xe["gray-400"]})]})]})]})]})}function uT(){}const mT=w.forwardRef(function(e,t){const{value:n,clone:s,childCount:i,item:o,onVisibilityChange:l,onClick:a,onGroupDelete:d,onGroupColorChange:h,onGroupNameChange:u,validateGroupName:m,handleProps:g}=e,{group:p,modelIndex:C,isVisible:f}=o.data,S=w.useRef(null),v=w.useCallback(T=>{T.buttons===1&&(l([C].flat(),!f),S.current?.focus())},[l,C,f]),b=w.useCallback(T=>{a(n,T)},[a,n]);return r.jsxs("div",{ref:t,className:K("tree-item",{isSelected:o.selected,"two-dragged":i===2,"multiple-dragged":i>2}),onClick:b,...g,children:[r.jsx(_,{ref:S,kind:"ghost",className:"px-1",onClick:uT,onMouseDown:v,onMouseEnter:v,icon:f?hr:Jc,tooltip:"Toggle visibility"}),r.jsx("span",{className:K("column-name",p&&"column-group"),children:p&&!s?r.jsx(hT,{group:p,onDelete:d,onColorChange:h,onNameChange:u,validateName:m}):n}),r.jsxs("div",{children:[s&&i>1&&r.jsx("span",{className:"item-count",children:i}),r.jsx(tt,{children:"Drag to re-order"}),r.jsx(X,{icon:Bl})]})]})}),gT=mT;function pT(c){return c.parentId!==void 0}function fT(c,e){return Math.round(c/e)}function bu(c,e,t,n,s,i){const o=c.findIndex(l=>l.name===n);if(o===-1){const l=t.get(n);if(l==null)throw new Error(`Column or header group not found: ${n}`);const a=l.childIndexes.flat();return{id:n,selected:i.has(n),children:l.children.map(d=>bu(c,e,t,d,s,i)).sort((d,h)=>{const u=Array.isArray(d.data.visibleIndex)?d.data.visibleIndex[0]:d.data.visibleIndex,m=Array.isArray(h.data.visibleIndex)?h.data.visibleIndex[0]:h.data.visibleIndex;return u-m}),data:{modelIndex:a,visibleIndex:l.getVisibleRange(e),group:l,isVisible:a.some(d=>!s.has(d))}}}return{id:n,children:[],selected:i.has(n),data:{modelIndex:o,visibleIndex:O.getVisibleIndex(o,e),isVisible:!s.has(o)}}}function CT(c,e,t,n,s){const i=[],o=new Set(s),l=new Map(t.map(h=>[h.name,h])),a=new Set(n);let d=0;for(;d<c.length;){const h=O.getModelIndex(d,e),u=c[h].name;let m=t.find(({children:p})=>p.includes(u));for(;m!==void 0&&m.parent!==void 0;)m=l.get(m.parent);const g=bu(c,e,l,m?m.name:u,a,o);i.push(g),Array.isArray(g.data.visibleIndex)?d+=g.data.visibleIndex[1]-g.data.visibleIndex[0]+1:d+=1}return i}function Rl(c,e,t,n,s){const i=c.findIndex(({id:S})=>S===t),o=c.findIndex(({id:S})=>S===e),l=c[o],a=nm(c,o,i),d=a[i-1],h=a[i+1],u=fT(n,s),m=l.depth+u,g=ST({previousItem:d,nextItem:h}),p=bT({nextItem:h});let C=m;return m>=g?C=g:m<p&&(C=p),{depth:C,maxDepth:g,minDepth:p,parentId:f()};function f(){return C===0||!d?null:C===d.depth?d.parentId:C>d.depth?d.id:a.slice(0,i).reverse().find(v=>v.depth===C)?.parentId??null}}function ST({previousItem:c,nextItem:e}){return Math.max(c?.depth??0,e?.depth??0)}function bT({nextItem:c}){return c?c.depth:0}function wu(c,e=null,t=0){return c.reduce((n,s,i)=>[...n,{...s,parentId:e,depth:t,index:i},...wu(s.children,s.id,t+1)],[])}function Jt(c){return c.every(pT)?[...c]:wu(c)}function vu(c,e){for(let t=0;t<c.length;t+=1){const n=c[t],{id:s,children:i}=n;if(s===e)return n;if(i.length){const o=vu(i,e);if(o)return o}}}function Tu(c,e=0){return c.reduce((t,{children:n})=>n.length?Tu(n,t+1):t+1,e)}function wT(c,e){const t=vu(c,e);return t?Tu(t.children):0}const vT=[In.Down,In.Right,In.Up,In.Left],TT=[In.Left,In.Right];function ET(c,e,t){return(n,{currentCoordinates:s,context:{active:i,over:o,collisionRect:l,droppableRects:a,droppableContainers:d}})=>{if(vT.includes(n.code)){if(!i||!l)return;n.preventDefault();const{current:{items:h,offset:u}}=c;if(TT.includes(n.code)&&o?.id!=null){const{depth:C,maxDepth:f,minDepth:S}=Rl(h,i.id,o.id,u,t);switch(n.code){case In.Left:if(C>S)return{...s,x:s.x-t};break;case In.Right:if(C<f)return{...s,x:s.x+t};break}return}const m=[];d.forEach(C=>{if(C?.disabled||C.id===o?.id)return;const f=a.get(C.id);if(f)switch(n.code){case In.Down:l.top<f.top&&m.push(C);break;case In.Up:l.top>f.top&&m.push(C);break}});const g=sm({active:i,collisionRect:l,pointerCoordinates:null,droppableRects:a,droppableContainers:m});let p=im(g,"id");if(p===o?.id&&g.length>1&&(p=g[1].id),p!=null&&o?.id!=null){const C=a.get(i.id),f=a.get(p),S=d.get(p);if(C&&f&&S){const v=h.findIndex(({id:E})=>E===p),b=h[v],T=h.findIndex(({id:E})=>E===i.id),y=h[T];if(b!=null&&y!=null){const{depth:E}=Rl(h,i.id,p,(b.depth-y.depth)*t,t),x=v>T?1:-1,D=e?(l.height-C.height)/2:0;return{x:f.left+E*t,y:f.top+x*D}}}}}}}class yT extends om{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:e})=>!(!e.isPrimary||e.button!==0||xT(e.target))}]}const RT=["button","input","textarea","select","option"];function xT(c){return!!(c?.tagName!=null&&RT.includes(c.tagName.toLowerCase()))}function Eu(c){const{clone:e=!1,depth:t,disableInteraction:n=!1,ghost:s=!1,handleProps:i,value:o,dragRef:l=null,wrapperRef:a=null,renderItem:d,item:h,childCount:u}=c,m=w.useMemo(()=>Array(t).fill(0).map((p,C)=>r.jsx("span",{className:"depth-line"},`depth-line-${C}`)),[t]),g=w.useMemo(()=>({ref:l,clone:e,value:o,item:h,childCount:u,handleProps:i}),[l,e,o,h,u,i]);return r.jsxs("li",{className:K("item-wrapper",{clone:e,ghost:s,disableInteraction:n}),ref:a,children:[!e&&m,d(g)]},o)}Eu.displayName="TreeItem";const IT=({isSorting:c,wasDragging:e})=>!(c||e);function oc({id:c,depth:e,...t}){const{attributes:n,isDragging:s,isSorting:i,listeners:o,setDraggableNodeRef:l,setDroppableNodeRef:a,transform:d,transition:h}=lm({id:c,animateLayoutChanges:IT}),u=Pa.Translate.toString(d),m=w.useMemo(()=>({transform:u,transition:h}),[u,h]),g=w.useMemo(()=>({...n,...o,style:m}),[n,o,m]);return r.jsx(Eu,{dragRef:l,wrapperRef:a,depth:e,ghost:s,disableInteraction:i,handleProps:g,...t})}const DT={keyframes({transform:c}){return[{opacity:1,transform:Pa.Transform.toString(c.initial)},{opacity:0,transform:Pa.Transform.toString({...c.final,x:c.final.x+5,y:c.final.y+5})}]},easing:"ease-out",sideEffects({active:c}){c.node.animate([{opacity:0},{opacity:1}],{duration:ld.duration,easing:ld.easing})}};let Go=null;function FT(c){return Go==null&&c.activeNodeRect&&c.activatorEvent instanceof PointerEvent&&(Go=Math.floor((c.activatorEvent.clientY-c.activeNodeRect.top)/c.activeNodeRect.height)*c.activeNodeRect.height),c.activeNodeRect||(Go=null),{...c.transform,y:c.transform.y+(Go??0)}}function NT({items:c,renderItem:e,indentationWidth:t=30,indicator:n=!1,activeId:s,overId:i,offsetLeft:o}){const l=am(),a=w.useRef(l);w.useEffect(function(){a.current=l},[l]),w.useEffect(function(){a.current.measureDroppableContainers(c.map(({id:g})=>g))},[c]);const d=s!=null&&i!=null?Rl(c,s,i,o,t):null,h=w.useRef({items:c,offset:o}),u=s!=null?c.find(({id:m})=>m===s):null;return w.useEffect(()=>{h.current={items:c,offset:o}},[c,o]),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:K("tree-container",s!=null&&"marching-ants"),children:c.map(m=>{const{id:g,depth:p}=m;return r.jsx(oc,{id:g,value:g,depth:g===s&&d?d.depth:p,item:m,renderItem:e},g)})}),rm.createPortal(r.jsx(dm,{dropAnimation:DT,modifiers:[FT],className:"visibility-ordering-list",children:s!=null&&u?r.jsx(oc,{id:s,depth:u.depth,clone:!0,childCount:wT(c,s)+1,value:s.toString(),renderItem:e,item:u}):null}),document.body)]})}const kT={droppable:{strategy:pm.Always}},MT={activationConstraint:{distance:5}};function LT({items:c,indicator:e=!1,indentationWidth:t=30,onDragStart:n,onDragEnd:s,renderItem:i}){const[o,l]=w.useState(null),[a,d]=w.useState(null),[h,u]=w.useState(0),m=w.useMemo(()=>{const x=Jt(c);return o!=null?x.filter(({id:D,selected:L})=>D===o||!L):x},[o,c]),g=o!=null&&a!=null?Rl(m,o,a,h,t):null,p=w.useRef({items:m,offset:h}),C=w.useMemo(()=>({coordinateGetter:ET(p,e,t)}),[t,e]),f=cm(ad(yT,MT),ad(fm,C)),S=w.useMemo(()=>m.map(({id:x})=>x),[m]);w.useEffect(()=>{p.current={items:m,offset:h}},[m,h]);const v=w.useCallback(({active:{id:x}})=>{l(x),d(x),n?.(x),document.body.style.setProperty("cursor","grabbing")},[n]),b=w.useCallback(({delta:x})=>{u(x.x)},[]),T=w.useCallback(({over:x})=>{d(x?.id??null)},[]),y=w.useCallback(()=>{d(null),l(null),u(0),document.body.style.setProperty("cursor","")},[]),E=w.useCallback(({active:x,over:D})=>{if(y(),g&&D){const{depth:L,parentId:M}=g,j=JSON.parse(JSON.stringify(Jt(c))),A=j.findIndex(({id:U})=>U===D.id),W=j.findIndex(({id:U})=>U===x.id),H=j[W];j[W]={...H,depth:L,parentId:M},s?.(H,{...j[A],parentId:g.parentId})}},[c,s,g,y]),R=w.useCallback(()=>{y()},[y]);return r.jsx(hm,{sensors:f,collisionDetection:um,measuring:kT,onDragStart:v,onDragMove:b,onDragOver:T,onDragEnd:E,onDragCancel:R,children:r.jsx(mm,{items:S,strategy:gm,children:r.jsx(NT,{items:m,renderItem:i,indicator:e,indentationWidth:t,activeId:o,overId:a,offsetLeft:h})})})}function OT(c,e,t,n,s,i,o,l){const a=s.map((v,b)=>({...v,index:b}));let d=[],h=n;const u=i[0].data.visibleIndex,m=a.findIndex(({id:v})=>v===c.id),g=a.findIndex(({id:v})=>v===e.id);let p=Array.isArray(u)?u[1]+1:u+1;h=ps(i[0],e.parentId,h);for(let v=1;v<i.length;v+=1){const{data:{visibleIndex:b}}=i[v];d=O.moveItemOrRange(b,p,d,!0),p+=Array.isArray(b)?b[1]-b[0]+1:1,h=ps(i[v],e.parentId,h)}const C=[Array.isArray(u)?u[0]:u,p-1],f=Array.isArray(e.data.visibleIndex)?e.data.visibleIndex[0]:e.data.visibleIndex;let S=O.getVisibleIndex(f,d);return m>g&&S>f&&(S-=1),e.children.length>0&&(Array.isArray(u)?u[0]:u)<S&&(S-=1),C[0]<S&&(S-=C[1]-C[0]),d=O.moveItemOrRange(C,Ae(S,o,l),d),{groups:h,movedColumns:t.concat(d)}}function ps(c,e,t){if(c.parentId===e)return[...t];let n=t.map(a=>new dn(a));const s=new Map(n.map(a=>[a.name,a])),i=n.find(a=>a.name===c.parentId),o=n.find(a=>a.name===e),l=n.find(a=>a.name===c.id);if(i!=null&&(i.children=i.children.filter(a=>a!==c.id),i.children.length===0)){const a=new Set([i.name]),{parent:d=""}=i;let h=s.get(d);for(h?.removeChildren([i.name]);h&&h.children.length===0;){a.add(h.name);const u=h?.parent??"",m=s.get(u);m?.removeChildren([h.name]),h=m}n=n.filter(({name:u})=>!a.has(u))}return o?.addChildren([c.id]),l?.setParent(e??void 0),n}const AT=150;class ct extends w.Component{static SORTING_OPTIONS={DSC:"DSC",ASC:"ASC"};static MOVE_OPTIONS={TOP:"TOP",BOTTOM:"BOTTOM",UP:"UP",DOWN:"DOWN"};constructor(e){super(e),this.handleSearchInputChange=this.handleSearchInputChange.bind(this),this.searchColumns=this.searchColumns.bind(this),this.handleItemClick=this.handleItemClick.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleGroupDelete=this.handleGroupDelete.bind(this),this.handleGroupNameChange=this.handleGroupNameChange.bind(this),this.handleGroupCreate=this.handleGroupCreate.bind(this),this.validateGroupName=this.validateGroupName.bind(this),this.addColumnToSelected=this.addColumnToSelected.bind(this),this.handleDragStart=this.handleDragStart.bind(this),this.state={selectedColumns:new Set,lastSelectedColumn:"",searchFilter:""},this.list=null}componentWillUnmount(){this.debouncedSearchColumns.cancel()}list;debouncedSearchColumns=Ge(this.searchColumns,AT);resetVisibilityOrdering(){const{model:e,onReset:t,onMovedColumnsChanged:n,onColumnHeaderGroupChanged:s}=this.props;this.setState({selectedColumns:new Set,lastSelectedColumn:"",searchFilter:""}),t(),s(e.initialColumnHeaderGroups),n(e.initialMovedColumns)}resetSelection(){this.setState({selectedColumns:new Set,lastSelectedColumn:""})}handleSearchInputChange(e){const t=e.target.value;if(this.setState({searchFilter:t}),!t){this.debouncedSearchColumns.cancel(),this.resetSelection();return}this.debouncedSearchColumns(t)}searchColumns(e){const t=Jt(this.getTreeItems()),s=t.filter(({id:o,data:l})=>!(l.group?.isNew??!1)&&o.toLowerCase().includes(e.toLowerCase())).map(({id:o})=>o),i=t.findIndex(({id:o})=>o.toLowerCase().includes(e.toLowerCase()));this.addColumnToSelected(s,!1),s.length>0&&this.list?.querySelectorAll(".item-wrapper")[i]?.scrollIntoView({block:"center"})}moveSelectedColumns(e){const{columnHeaderGroups:t}=this.props,{selectedColumns:n}=this.state,s=Jt(this.getTreeItems());let i=this.getFirstMovableIndex(),o=this.getLastMovableIndex();N(i),N(o);const l=this.getSelectedParentItems();e===ct.MOVE_OPTIONS.UP||e===ct.MOVE_OPTIONS.TOP||l.reverse();let d=[],h=t;for(let u=0;u<l.length;u+=1){const{id:m,parentId:g,depth:p,data:{visibleIndex:C}}=l[u];switch(e){case ct.MOVE_OPTIONS.TOP:{d=O.moveItemOrRange(C,i,d,!0);const f=Array.isArray(C)?C[1]-C[0]+1:1;i+=f,h=ps(l[u],null,h);break}case ct.MOVE_OPTIONS.BOTTOM:{d=O.moveItemOrRange(C,o,d,!0);const f=Array.isArray(C)?C[1]-C[0]+1:1;o-=f,h=ps(l[u],null,h);break}case ct.MOVE_OPTIONS.UP:{const f=s.findIndex(b=>b.id===m),S=s.map((b,T)=>T<f&&!n.has(b.id)).lastIndexOf(!0),v=s[S];if(v!=null&&v.parentId!==g)if(Math.abs(v.depth-p)>1){const b=s.map((y,E)=>E<S&&y.depth===p).lastIndexOf(!0),T=s[b];h=ps(l[u],T.id,h)}else h=ps(l[u],v.parentId,h);else{const b=Ae(Array.isArray(C)?C[0]-1:C-1,i,o);d=O.moveItemOrRange(C,b,d,!1);const T=Array.isArray(C)?C[1]-C[0]+1:1;i+=T}break}case ct.MOVE_OPTIONS.DOWN:{const f=s.findIndex(T=>T.id===m),S=s.find((T,y)=>y>f&&!n.has(T.id));if(S?.parentId!==g){const T=s.find(y=>y.id===g);h=ps(l[u],T?.parentId??null,h);break}else if(S?.children.length>0){h=ps(l[u],S.id,h);break}const v=Ae(Array.isArray(C)?C[0]+1:C+1,i,o);d=O.moveItemOrRange(C,v,d,!1);const b=Array.isArray(C)?C[1]-C[0]+1:1;o-=b;break}}}return{newMoves:d,groups:h}}handleMoveColumns(e){const{onMovedColumnsChanged:t,movedColumns:n,onColumnHeaderGroupChanged:s}=this.props,{newMoves:i,groups:o}=this.moveSelectedColumns(e);let l;e===ct.MOVE_OPTIONS.TOP&&(l=()=>{this.list?.parentElement?.scroll({top:0})}),e===ct.MOVE_OPTIONS.BOTTOM&&(l=()=>{this.list?.parentElement?.scroll({top:this.list.parentElement.scrollHeight})}),s(o),i.length>0&&t(n.concat(i),l)}getSortMoves(e,t,n){const s=[...e],i=t===ct.SORTING_OPTIONS.ASC;s.sort((a,d)=>{const h=a.id.toUpperCase(),u=d.id.toUpperCase();return en.sort(h,u,i)});let o=[...n],l=Math.min(...s.flatMap(a=>{const{modelIndex:d}=a.data;return Array.isArray(d)?O.getVisibleIndexes(d,o):O.getVisibleIndex(d,o)}));for(let a=0;a<s.length;a+=1){const d=s[a],{modelIndex:h}=d.data,u=Array.isArray(h)?O.getVisibleIndexes(h,o):O.getVisibleIndex(h,o);o=Array.isArray(u)?O.moveRange([Math.min(...u),Math.max(...u)],l,o,!0):O.moveItem(u,l,o),Array.isArray(u)&&(o=this.getSortMoves(d.children,t,o)),l+=Array.isArray(h)?h.length:1}return o}handleSortColumns(e){const{model:t,onMovedColumnsChanged:n}=this.props,s=this.getSortMoves(this.getTreeItems(),e,t.initialMovedColumns);n(s)}handleItemClick(e,t){if(t.stopPropagation(),t.target instanceof HTMLElement&&(t.target.tagName==="BUTTON"||t.target.tagName==="INPUT"))return;t.currentTarget.focus();const{selectedColumns:n,lastSelectedColumn:s}=this.state,i=O.isModifierKeyDown(t),o=t.shiftKey,l=n.has(e),a=[e];if(l&&i){this.removeColumnFromSelected(e);return}const d=Jt(this.getTreeItems());if(l&&!o&&s===e){const h=d.find(({id:m})=>m===e);if(N(h),Jt(h.children).length+1===n.size){this.resetSelection();return}}if(o){const h=d.findIndex(m=>m.id===e),u=d.findIndex(m=>m.id===s);a.push(...d.slice(Math.min(u,h),Math.max(u,h)+1).map(m=>m.id))}this.addColumnToSelected(a,i||o),this.setState({lastSelectedColumn:e})}addColumnToSelected(e,t){const{selectedColumns:n}=this.state,s=new Set(t?[...n.values()].concat(e):e);Jt(this.getTreeItems()).forEach(({id:o,children:l})=>{s.has(o)&&l.forEach(a=>s.add(a.id))}),this.setState({selectedColumns:s})}removeColumnFromSelected(e){const{selectedColumns:t}=this.state,n=Jt(this.getTreeItems()),s=n.find(({id:o})=>o===e);N(s);let i=n.find(({id:o})=>o===s.parentId);for(Jt(s?.children).forEach(o=>t.delete(o.id));i!=null;){t.delete(i.id);const o=i.parentId;i=n.find(({id:l})=>l===o)}t.delete(e),this.setState({selectedColumns:new Set(t)})}handleDragStart(e){const{selectedColumns:t}=this.state;t.has(e)||this.addColumnToSelected([e],!1)}handleDragEnd(e,t){const{movedColumns:n,onMovedColumnsChanged:s,columnHeaderGroups:i,onColumnHeaderGroupChanged:o}=this.props,l=this.getSelectedParentItems(),a=Jt(this.getTreeItems()).map((g,p)=>({...g,index:p})),d=this.getFirstMovableIndex(),h=this.getLastMovableIndex();N(d),N(h);const{groups:u,movedColumns:m}=OT(e,t,n,i,a,l,d,h);o(u),s(m)}handleGroupNameChange(e,t){const{columnHeaderGroups:n,onColumnHeaderGroupChanged:s}=this.props,i=[...n],o=e.name,l=i.findIndex(({name:u})=>u===o),a=i[l];N(a);const d=new dn(a);d.name=t,i.splice(l,1,d);const h=i.findIndex(({name:u})=>u===d.parent);if(h>=0){const u=new dn(i[h]);u.removeChildren([o]),u.addChildren([t]),i.splice(h,1,u)}s(i)}handleGroupColorChange=Ts((e,t)=>{const{columnHeaderGroups:n,onColumnHeaderGroupChanged:s}=this.props,i=[...n],o=new dn({...e,color:t});i.splice(i.findIndex(({name:l})=>l===e.name),1,o),s(i)},250);handleGroupDelete(e){const{columnHeaderGroups:t,onColumnHeaderGroupChanged:n}=this.props,s=t.filter(o=>o.name!==e.name),i=s.findIndex(o=>o.name===e.parent);if(i>=0){const o=new dn(s[i]);o.addChildren(e.children),o.removeChildren([e.name]),s.splice(i,1,o)}n(s)}handleGroupCreate(){const{movedColumns:e,onMovedColumnsChanged:t,onColumnHeaderGroupChanged:n}=this.props,{newMoves:s,groups:i}=this.moveSelectedColumns(ct.MOVE_OPTIONS.TOP),o=i.filter(u=>!u.isNew),l=this.getSelectedParentItems(),a=l.map(u=>u.data.modelIndex).flat().filter(u=>u>=0),d=`${dn.NEW_GROUP_PREFIX}-${Date.now()}`,h=new dn({name:d,children:l.map(({id:u})=>u),depth:0,childIndexes:[...new Set(a)]});t(e.concat(s),()=>{this.list?.parentElement?.scroll({top:0})}),n(o.concat([h])),this.resetSelection()}validateGroupName(e){const{model:t,columnHeaderGroups:n}=this.props,{columns:s}=t;return Ii.isValidColumnName(e)?s.some(({name:i})=>i===e)||n.some(({name:i})=>i===e)?"Duplicate name":"":"Invalid name"}renderItem=Te(({value:e,clone:t,item:n,ref:s,handleProps:i})=>{const{onColumnVisibilityChanged:o}=this.props,{selectedColumns:l}=this.state;let a=e;return t&&(a=this.getSelectedParentItems().map(({id:h})=>h).join(", ")),r.jsx(gT,{ref:s,value:a,clone:t,item:n,childCount:l.size,onVisibilityChange:o,onClick:this.handleItemClick,onGroupDelete:this.handleGroupDelete,onGroupColorChange:this.handleGroupColorChange,onGroupNameChange:this.handleGroupNameChange,validateGroupName:this.validateGroupName,handleProps:i})});getMemoizedFirstMovableIndex=Te((e,t,n)=>{for(let s=0;s<t.length;s+=1){const i=O.getModelIndex(s,n);if(e.isColumnMovable(i))return s}return null});getFirstMovableIndex(){const{model:e,movedColumns:t}=this.props;return this.getMemoizedFirstMovableIndex(e,e.columns,t)}getMemoizedLastMovableIndex=Te((e,t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=O.getModelIndex(s,n);if(e.isColumnMovable(i))return s}return null});getLastMovableIndex(){const{model:e,movedColumns:t}=this.props;return this.getMemoizedLastMovableIndex(e,e.columns,t)}memoizedGetTreeItems=Te((e,t,n,s,i)=>CT(e,t,n,s,[...i.values()]));getTreeItems(){const{model:e,movedColumns:t,hiddenColumns:n,columnHeaderGroups:s}=this.props,{selectedColumns:i}=this.state;return this.memoizedGetTreeItems(e.columns,t,s,n,i)}getSelectedParentItems(){const{selectedColumns:e}=this.state;return Jt(this.getTreeItems()).filter(({id:n,parentId:s})=>e.has(n)&&!e.has(s??""))}makeVisibilityOrderingList=Te((e,t)=>{const{movedColumns:n}=this.props,s=[],i=this.getFirstMovableIndex(),o=this.getLastMovableIndex(),l=t.findIndex(({data:h})=>Array.isArray(h.visibleIndex)?h.visibleIndex[0]===i:h.visibleIndex===i),a=t.findIndex(({data:h})=>Array.isArray(h.visibleIndex)?h.visibleIndex[1]===o:h.visibleIndex===o),d=t.slice(l,a+1);if(i==null||o===null){for(let h=0;h<e.length;h+=1){const u=O.getModelIndex(h,n),m=e[u];s.push(this.renderImmovableItem(m.name))}return s}for(let h=0;h<i;h+=1){const u=O.getModelIndex(h,n),m=e[u];s.push(this.renderImmovableItem(m.name))}i!==null&&i>0&&s.push(r.jsx("hr",{},"top-horizontal-divider")),s.push(r.jsx(LT,{items:d,renderItem:this.renderItem,onDragStart:this.handleDragStart,onDragEnd:this.handleDragEnd},"movable-items")),o!=null&&o<e.length-1&&s.push(r.jsx("hr",{},"bottom-horizontal-divider"));for(let h=o+1;h<e.length;h+=1){const u=O.getModelIndex(h,n),m=e[u];s.push(this.renderImmovableItem(m.name))}return s});renderImmovableItem=Te(e=>r.jsx("div",{className:"visibility-ordering-list-item immovable",children:r.jsx("div",{className:"column-item",children:r.jsx("span",{className:"column-name",children:e})})},e));render(){const{model:e,hiddenColumns:t,onColumnVisibilityChanged:n}=this.props,{selectedColumns:s,searchFilter:i}=this.state,o=s.size>0,l=this.getTreeItems(),a=new Map(Jt(l).map(C=>[C.id,C.data.modelIndex])),d=new Set(t),h=[...new Set(o?[...s.values()].map(C=>a.get(C)).filter(C=>C!=null).flat():l.map(C=>C.data.modelIndex).flat())],u=h.some(C=>!d.has(C)),m=u?"Hide All":"Show All",g=u?"Hide Selected":"Show Selected",p=this.makeVisibilityOrderingList(e.columns,l);return r.jsxs("div",{role:"menu",className:"visibility-ordering-builder",tabIndex:0,children:[r.jsxs("div",{className:"top-menu",children:[r.jsx(_,{kind:"ghost",className:"toggle-visibility-btn",onClick:()=>{n(h,!u)},icon:u?hr:Jc,tooltip:"Toggle column visibility",children:o?g:m}),r.jsx(xi,{className:"visibility-search",value:i,matchCount:i?s.size:void 0,onChange:this.handleSearchInputChange})]}),r.jsxs("div",{className:"top-menu",children:[r.jsx(_,{kind:"ghost",icon:Gs,tooltip:"Reset to default",onClick:()=>{this.resetVisibilityOrdering()},children:"Reset"}),r.jsx("span",{className:"vertical-divider"}),r.jsx(_,{kind:"ghost",icon:dr,tooltip:"Sort ascending",onClick:()=>{this.handleSortColumns(ct.SORTING_OPTIONS.ASC)}}),r.jsx(_,{kind:"ghost",icon:cr,tooltip:"Sort descending",onClick:()=>{this.handleSortColumns(ct.SORTING_OPTIONS.DSC)}}),r.jsx("span",{className:"vertical-divider"}),r.jsxs(_,{kind:"ghost",tooltip:"Create group from selection",disabled:!o,onClick:this.handleGroupCreate,children:[r.jsxs("span",{className:"fa-layers",style:{marginRight:"0.75rem"},children:[r.jsx(X,{mask:hg,icon:yi,transform:"right-7 down-5 shrink-6"}),r.jsx(X,{icon:ug,transform:"right-8 down-6 shrink-8"})]}),"Group"]}),r.jsx("span",{className:"vertical-divider"}),r.jsx(_,{kind:"ghost",icon:mg,tooltip:"Move selection up",onClick:()=>{this.handleMoveColumns(ct.MOVE_OPTIONS.UP)},disabled:!o}),r.jsx(_,{kind:"ghost",icon:gg,tooltip:"Move selection down",onClick:()=>{this.handleMoveColumns(ct.MOVE_OPTIONS.DOWN)},disabled:!o}),r.jsx(_,{kind:"ghost",icon:pg,tooltip:"Move selection to top",onClick:()=>{this.handleMoveColumns(ct.MOVE_OPTIONS.TOP)},disabled:!o}),r.jsx(_,{kind:"ghost",icon:fg,tooltip:"Move selection to bottom",onClick:()=>{this.handleMoveColumns(ct.MOVE_OPTIONS.BOTTOM)},disabled:!o})]}),r.jsx("div",{role:"menu",className:K("visibility-ordering-list"),children:r.jsx("div",{className:"column-list",ref:C=>{this.list=C},children:p})})]})}}const _T=ct;class PT extends w.PureComponent{static createSearchFilter(e,t,n,s){const i=s?n.filter(o=>!t.includes(o.name)).map(o=>o.name):t;if(e&&i.length>0){const o=I.FilterValue.ofString(e);return i.length===n.length?I.FilterCondition.search(o):I.FilterCondition.search(o,n.filter(a=>i.includes(a.name)).map(a=>a.filter()))}}constructor(e){super(e),this.handleSearchValueChange=this.handleSearchValueChange.bind(this),this.toggleColumn=this.toggleColumn.bind(this),this.selectAll=this.selectAll.bind(this),this.clear=this.clear.bind(this),this.selectNumbers=this.selectNumbers.bind(this),this.searchField=ae.createRef(),this.state={isConfigureColumnsShown:!1}}searchField;focus(){this.searchField.current?.focus()}handleSearchValueChange(e){const{onChange:t,selectedColumns:n,invertSelection:s}=this.props;t(e.target.value,n,s)}sendColumnChange(e,t){const{onChange:n,value:s}=this.props;n(s,e,t)}setInvertSelection(e){const{onChange:t,value:n}=this.props;t(n,[],e)}toggleColumn(e){const{selectedColumns:t,invertSelection:n}=this.props;if(t.includes(e))this.sendColumnChange(t.filter(s=>s!==e),n);else{const s=t.slice();s.push(e),this.sendColumnChange(s,n)}}selectAll(){this.setInvertSelection(!0)}clear(){this.setInvertSelection(!1)}selectNumbers(){const{columns:e}=this.props;this.sendColumnChange(e.filter(t=>F.isNumberType(t.type)).map(t=>t.name),!1)}render(){const{value:e,selectedColumns:t,invertSelection:n,columns:s}=this.props,{isConfigureColumnsShown:i}=this.state,o=t.length===0&&n===!0||t.length===s.length&&n===!1,l=t.length===0&&n===!1||t.length===s.length&&n===!0;let a;return o?a=r.jsxs(r.Fragment,{children:[r.jsx(X,{icon:dl,mask:ma,transform:"shrink-2 down-5 right-7"}),r.jsx(X,{icon:Cg,className:"text-primary",transform:"shrink-4 down-5 right-7"})]}):l?a=r.jsxs(r.Fragment,{children:[r.jsx(X,{icon:yi,mask:ma,transform:"shrink-1 down-5 right-7"}),r.jsx(X,{icon:Cd,className:"text-danger",transform:"shrink-4 down-5 right-7"})]}):a=r.jsxs(r.Fragment,{children:[r.jsx(X,{icon:dl,mask:ma,transform:"shrink-2 down-5 right-7"}),r.jsx(X,{icon:Sg,className:"text-primary",transform:"shrink-4 down-5 right-7"})]}),r.jsxs("div",{className:"cross-column-container",children:[r.jsx(xi,{className:"cross-column-search",placeholder:"Search Data...",value:e,onChange:this.handleSearchValueChange,ref:this.searchField}),r.jsxs("button",{type:"button",className:"btn btn-link btn-link-icon px-2",onClick:()=>{i?this.setState({isConfigureColumnsShown:!1}):this.setState({isConfigureColumnsShown:!0})},children:[r.jsx("div",{className:"fa-layers",children:a}),r.jsx(tt,{children:"Configure Columns"}),r.jsx(Ul,{isShown:i,className:"cross-column-popper",onExited:()=>{this.setState({isConfigureColumnsShown:!1})},closeOnBlur:!0,interactive:!0,children:r.jsxs("div",{className:"cross-column-popup",children:["Searched Columns",r.jsx("div",{className:"cross-column-scroll",children:s.map(d=>r.jsxs(ae.Fragment,{children:[r.jsx(nn,{className:"cross-column-checkbox",checked:n?!t.includes(d.name):t.includes(d.name),onChange:()=>this.toggleColumn(d.name),children:d.name}),d.type.substring(d.type.lastIndexOf(".")+1)]},d.name))}),r.jsxs("div",{className:"cross-column-button-bar",children:[r.jsx("button",{type:"button",className:"btn btn-link",onClick:this.selectAll,children:"Select All"}),r.jsx("button",{type:"button",className:"btn btn-link",onClick:this.clear,children:"Clear"}),r.jsx("button",{type:"button",className:"btn btn-link",onClick:this.selectNumbers,children:"Numbers Only"})]}),l&&r.jsxs("p",{className:"text-danger",children:[r.jsx(X,{icon:Cd})," Select at least one column to search."]})]})})]})]})}}const zo=PT;const rs=ee.module("PartitionSelectorSearch"),jT=150;class Hr extends w.Component{static MAX_VISIBLE_ITEMS=12;static defaultProps={initialPageSize:100,onSelect:()=>{},onListResized:()=>{}};static propTypes={getFormattedString:B.func.isRequired,table:B.shape({addEventListener:B.func.isRequired,removeEventListener:B.func.isRequired,columns:B.arrayOf(B.shape({name:B.string.isRequired,type:B.string.isRequired,filter:B.func.isRequired})),size:B.number.isRequired,applyFilter:B.func.isRequired,setViewport:B.func.isRequired}).isRequired,initialPageSize:B.number,onSelect:B.func,onListResized:B.func};static handleError(e){e instanceof Pl||rs.error(e)}constructor(e){super(e),this.handleFilterChange=this.handleFilterChange.bind(this),this.handleInputFocus=this.handleInputFocus.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleListKeydown=this.handleListKeydown.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.handleTextChange=this.handleTextChange.bind(this),this.handleViewportChange=this.handleViewportChange.bind(this),this.itemList=null,this.searchInput=null,this.timer=null,this.state={offset:0,itemCount:0,items:[],text:"",isLoading:!0}}componentDidMount(){this.startListening()}componentDidUpdate(e,t){const{isLoading:n,itemCount:s}=this.state,{onListResized:i}=this.props;(s!==t.itemCount||n!==t.isLoading)&&i()}componentWillUnmount(){this.debounceUpdateFilter.cancel(),this.stopListening()}itemList;searchInput;timer;handleKeyDown(e){if(this.itemList==null)return!1;const{items:t,itemCount:n}=this.state;switch(e.key){case"Enter":{let s=null;if(t.length>0)s=t[0].value;else{const{text:i}=this.state;s=i.trim()}if(s.length>0){const{onSelect:i}=this.props;i(s)}return e.stopPropagation(),e.preventDefault(),!0}case"ArrowDown":return n>0&&this.itemList.focusItem(1),e.stopPropagation(),e.preventDefault(),!0;default:return!1}}handleListKeydown(e){switch(e.key){case"Escape":break;default:this.focus();break}}handleFilterChange(){rs.debug2("handleFilterChange");const{table:e}=this.props,t=e.size;this.setState({itemCount:t,isLoading:!0})}handleInputFocus(){this.itemList&&this.itemList.focusItem(0)}handleSelect(e){rs.debug2("handleSelect",e);const{onSelect:t}=this.props,{offset:n,items:s}=this.state,i=e-n;if(i<0||s.length<=i){rs.error("No data for item",e);return}const{value:o}=s[i];t(o)}handleTableUpdate(e){const t=e.detail,{offset:n}=t,s=[],{getFormattedString:i,table:o}=this.props,l=o.columns[0];for(let d=0;d<t.rows.length;d+=1){const u=t.rows[d].get(l),m=i(u,l.type,l.name);s.push({displayValue:m,value:u})}const a=o.size;rs.debug2("handleTableUpdate",a,n,s.length),this.setState({itemCount:a,items:s,offset:n,isLoading:!1})}handleTextChange(e){rs.debug2("handleTextChange");const{value:t}=e.target;this.setState({text:t}),this.debounceUpdateFilter()}handleViewportChange(e,t){rs.debug2("handleViewportChange",e,t);const n=Math.max(1,t-e),s=Math.max(0,e-n),i=t+n,{table:o}=this.props;o.setViewport(s,i)}debounceUpdateFilter=Ge(()=>{this.updateFilter()},jT);focus(){this.searchInput&&this.searchInput.focus()}startListening(){const{initialPageSize:e,table:t}=this.props;t.addEventListener(I.Table.EVENT_UPDATED,this.handleTableUpdate),t.addEventListener(I.Table.EVENT_FILTERCHANGED,this.handleFilterChange),t.setViewport(0,e)}stopListening(){const{table:e}=this.props;e.removeEventListener(I.Table.EVENT_UPDATED,this.handleTableUpdate),e.removeEventListener(I.Table.EVENT_FILTERCHANGED,this.handleFilterChange)}updateFilter(){const{initialPageSize:e,table:t}=this.props,{text:n}=this.state,s=n.trim(),i=[];if(s.length>0){const l=t.columns[0].filter().invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${s}\\E.*`));i.push(l)}rs.debug2("updateFilter",i),t.applyFilter(i),t.setViewport(0,e)}render(){const{isLoading:e,itemCount:t,items:n,offset:s,text:i}=this.state,o=Math.min(t,Hr.MAX_VISIBLE_ITEMS)*Ei.DEFAULT_ROW_HEIGHT+11;return r.jsxs("div",{className:"iris-grid-partition-selector-search",children:[r.jsx("div",{className:"search-container",children:r.jsx("input",{type:"text",ref:l=>{this.searchInput=l},value:i,placeholder:"Available Partitions",onChange:this.handleTextChange,onFocus:this.handleInputFocus,onKeyDown:this.handleKeyDown,className:"form-control input-partition"})}),!e&&t>0&&r.jsx("div",{className:"iris-grid-partition-selector-search-list",onKeyDown:this.handleListKeydown,role:"presentation",style:{height:o},children:r.jsx(Ei,{ref:l=>{this.itemList=l},itemCount:t,items:n,offset:s,onSelect:this.handleSelect,onViewportChange:this.handleViewportChange})}),!e&&t===0&&r.jsx("div",{className:"iris-grid-partition-selector-search-empty",children:"No results"}),e&&r.jsxs("div",{className:"iris-grid-partition-selector-loading",children:[r.jsx(Nn,{})," Loading..."]})]})}}const HT=Hr;const ri=ee.module("IrisGridPartitionSelector"),UT=250;class VT extends w.Component{static defaultProps={onAppend:()=>{},onChange:()=>{},onFetchAll:()=>{},onDone:()=>{},partition:""};constructor(e){super(e),this.handleAppendClick=this.handleAppendClick.bind(this),this.handleCloseClick=this.handleCloseClick.bind(this),this.handleIgnoreClick=this.handleIgnoreClick.bind(this),this.handlePartitionChange=this.handlePartitionChange.bind(this),this.handlePartitionSelect=this.handlePartitionSelect.bind(this),this.handlePartitionListResized=this.handlePartitionListResized.bind(this),this.handleSearchOpened=this.handleSearchOpened.bind(this),this.handleSearchClosed=this.handleSearchClosed.bind(this),this.searchMenu=null,this.selectorSearch=null;const{partition:t}=e;this.state={partition:t}}componentWillUnmount(){this.debounceUpdate.cancel()}searchMenu;selectorSearch;handleAppendClick(){ri.debug2("handleAppendClick");const{onAppend:e}=this.props,{partition:t}=this.state;e(t)}handleCloseClick(){ri.debug2("handleCloseClick"),this.sendDone()}handleIgnoreClick(){ri.debug2("handleIgnoreClick"),this.sendFetchAll()}handlePartitionChange(e){ri.debug2("handlePartitionChange");const{value:t}=e.target;this.setState({partition:t}),this.debounceUpdate()}handlePartitionSelect(e){this.searchMenu&&this.searchMenu.closeMenu(),this.setState({partition:e},()=>{this.sendUpdate()})}handlePartitionListResized(){this.searchMenu&&this.searchMenu.scheduleUpdate()}handleSearchClosed(){const{table:e}=this.props;e.applyFilter([])}handleSearchOpened(){this.selectorSearch&&this.selectorSearch.focus()}debounceUpdate=Ge(()=>{this.sendUpdate()},UT);sendDone(){this.debounceUpdate.flush();const{onDone:e}=this.props;e()}sendUpdate(){ri.debug2("sendUpdate");const{onChange:e}=this.props,{partition:t}=this.state;e(t)}sendFetchAll(){ri.debug2("sendFetchAll"),this.debounceUpdate.cancel();const{onFetchAll:e}=this.props;e()}render(){const{columnName:e,getFormattedString:t,onDone:n,table:s}=this.props,{partition:i}=this.state,o=r.jsx(HT,{getFormattedString:t,table:s,onSelect:this.handlePartitionSelect,onListResized:this.handlePartitionListResized,ref:l=>{this.selectorSearch=l}},"search");return r.jsxs("div",{className:"iris-grid-partition-selector",children:[r.jsx("div",{className:"status-message",children:r.jsxs("span",{children:['Filtering "',e,'" partition to']})}),r.jsxs("div",{className:"input-group",children:[r.jsx("input",{type:"text",value:i,onChange:this.handlePartitionChange,className:"form-control input-partition"}),r.jsx("div",{className:"input-group-append",children:r.jsxs("button",{type:"button",className:"btn btn-outline-primary",children:[r.jsx(X,{icon:$n}),r.jsx(tt,{children:"Partitions"}),r.jsx(Wn,{ref:l=>{this.searchMenu=l},actions:[{menuElement:o}],onMenuOpened:this.handleSearchOpened,onMenuClosed:this.handleSearchClosed})]})})]}),r.jsx("div",{className:"iris-grid-partition-selector-spacer"}),r.jsx("button",{type:"button",className:"btn btn-outline-primary btn-ignore",onClick:this.handleIgnoreClick,children:"Ignore & Fetch All"}),r.jsx("button",{type:"button",className:"btn btn-outline-primary btn-append",onClick:this.handleAppendClick,children:"Append Command"}),r.jsx("button",{type:"button",className:"btn btn-link btn-link-icon btn-close",onClick:n,children:r.jsx(X,{icon:ho})})]})}}const BT=VT;const $T=ee.module("SelectDistinctBuilder");class WT extends w.Component{static defaultProps={selectDistinctColumns:[],onChange:()=>{}};constructor(e){super(e),this.handleAddColumnClick=this.handleAddColumnClick.bind(this),this.handleDeleteColumn=this.handleDeleteColumn.bind(this),this.handleDropdownChanged=this.handleDropdownChanged.bind(this);const{model:t,selectDistinctColumns:n}=this.props;this.state={inputs:n.length>0?[...n]:[""],columns:t.originalColumns}}componentDidUpdate(e,t){const{inputs:n}=this.state,{onChange:s}=this.props;if(t.inputs!==n){const i=n.filter(o=>o!=="");Je(t.inputs.filter(o=>o!==""),i)||s(i)}}handleAddColumnClick(){this.setState(({inputs:e})=>({inputs:[...e,""]}))}handleDeleteColumn(e){this.setState(({inputs:t})=>({inputs:t.length===1&&e===0?[""]:t.filter((n,s)=>e!==s)}))}handleDropdownChanged(e,t){$T.debug("handleDropdownChanged",e,t);const{value:n}=t.target;this.setState(({inputs:s})=>{const i=[...s];return i[e]=n,{inputs:i}})}renderInputs(){const{columns:e,inputs:t}=this.state;return t.map((n,s)=>{const i=e.filter(({name:o})=>o===n||!t.includes(o)).map(({name:o})=>r.jsx("option",{value:o,children:o},o));return r.jsxs("div",{className:"form-inline px-3 pb-3",children:[r.jsxs("select",{className:"form-control custom-select col",value:n,onChange:o=>this.handleDropdownChanged(s,o),children:[r.jsx("option",{value:"",children:"Select a column"}),i]}),(t.length>1||n!=="")&&r.jsx(_,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{this.handleDeleteColumn(s)},icon:r.jsx(X,{icon:Wt,transform:"grow-3"}),tooltip:"Delete column"})]},s)})}render(){const{columns:e,inputs:t}=this.state,n=t.length>=e.length;return r.jsxs("div",{role:"presentation",className:"select-distinct-builder-container h-100",children:[r.jsx("div",{className:"select-distinct-title",children:"Display Unique Values From"}),this.renderInputs(),r.jsx("hr",{}),r.jsx("div",{className:"pt-1 px-3",children:r.jsx(_,{kind:"ghost",className:"btn-add-column",onClick:this.handleAddColumnClick,disabled:n,icon:ys,children:"Add Additional Column"})}),r.jsx("div",{className:"select-distinct-builder-footer",children:r.jsx("div",{className:"select-distinct-builder-hint",children:"Display only unique values from the selected table columns. Note that this will reset any filters and display only the selected columns."})})]})}}const GT=WT;function Ur({items:c,onChange:e=()=>{}}){return r.jsx(Bc,{items:Array.from(c.entries()).map(([t,n])=>({title:Ur.getAdvancedSettingsTitleForKey(t),isOn:n,onChange:s=>e(t,s)}))})}Ur.getAdvancedSettingsTitleForKey=c=>{switch(c){case Ri.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS:return"Clear current table filters before applying new filters from a control";case Ri.LINK_CHANGE_CLEARS_ALL_FILTERS:return"Clear current table filters before applying new filters from an incoming link filter"}};const lc=ee.module("ConditionalFormattingMenu"),Ra=()=>{};function zT(c){const{column:{type:e}}=c;if(F.isNumberType(e))return c.condition===Ue.IS_NULL||c.condition===Ue.IS_NOT_NULL?"":`${c.value}`;if(F.isCharType(e))return c.condition===xt.IS_NULL||c.condition===xt.IS_NOT_NULL?"":`${c.value}`;if(F.isStringType(e))return c.condition===Ht.IS_NULL||c.condition===Ht.IS_NOT_NULL?"":`"${c.value}"`;if(F.isDateType(e))return c.condition===xt.IS_NULL||c.condition===xt.IS_NOT_NULL?"":`${c.value}`;if(F.isBooleanType(e))return"";throw new Error(`Invalid column type ${e} in getRuleValue`)}function KT(c){return F.isNumberType(c.column.type)&&c.condition===Ue.IS_BETWEEN?`${c.start} < ${c.column.name} < ${c.end}`:`${c.column.name} ${Fw(c.column.type,c.condition)}
|
|
30
|
-
${zT(c)}`}function YT(c){const{rules:e=[],onChange:t=Ra,onCreate:n=Ra,onSelect:s=Ra}=c,i=w.useCallback((d,h,u)=>{d.stopPropagation(),lc.debug("Rule clicked",h,u),s(u)},[s]),o=w.useCallback((d,h,u)=>{d.stopPropagation(),lc.debug("Delete button clicked",h,u);const m=[...e];m.splice(u,1),t(m)},[t,e]),l=w.useCallback(d=>{d.stopPropagation()},[]),a=w.useCallback(d=>{if(hn.stopDragging(),d.destination==null)return;const h=d.source.index,u=d.destination.index,m=[...e],g=e[h];m.splice(h,1),m.splice(u,0,g),t(m)},[t,e]);return r.jsxs("div",{className:"conditional-formatting-rules",children:[r.jsx(Al,{onDragStart:hn.startDragging,onDragEnd:a,children:r.jsx(nr,{droppableId:"droppable-custom-columns",children:(d,h)=>r.jsxs("div",{ref:d.innerRef,...d.droppableProps,className:K("droppable-container",{dragging:h.draggingFromThisWith}),children:[e.length===0&&r.jsx("div",{className:"text-muted pl-2",children:"No formats defined"}),e.map((u,m)=>r.jsx(jc,{draggableId:`${m}-${u.type}`,index:m,disableInteractiveElementBlocking:!0,children:(g,p)=>r.jsx("div",{role:"menuitem",tabIndex:0,onClick:C=>i(C,u,m),className:K("draggable-container",{dragging:p.isDragging}),ref:g.innerRef,...g.draggableProps,children:r.jsx("div",{className:"conditional-formatting-list-item",children:r.jsxs("div",{className:"formatting-item",children:[r.jsx("div",{className:"rule-icon",children:r.jsx("span",{className:"rule-icon-bg",style:{backgroundColor:vl(u.config.style),color:Tl(u.config.style)},children:u.type===Fn.ROWS?"row":"col"})}),r.jsx("div",{className:"rule-title",children:KT(u.config)}),r.jsx(_,{kind:"ghost",className:"ml-1 px-2",onClick:C=>o(C,u,m),icon:Wt,tooltip:"Delete rule"}),r.jsxs("button",{type:"button",className:"btn btn-link btn-link-icon px-2 btn-drag-handle",onClick:l,...g.dragHandleProps,children:[r.jsx(tt,{children:"Drag to re-order"}),r.jsx(X,{icon:Bl})]})]})})})},`${m}-${u.type}`)),d.placeholder]})})}),r.jsx("hr",{}),r.jsx(_,{kind:"ghost",onClick:n,icon:ys,children:"Add New Rule"})]})}const As=ee.module("ConditionEditor"),qT=()=>{},XT=[Ue.IS_EQUAL,Ue.IS_NOT_EQUAL,Ue.IS_BETWEEN,Ue.GREATER_THAN,Ue.GREATER_THAN_OR_EQUAL,Ue.LESS_THAN,Ue.LESS_THAN_OR_EQUAL,Ue.IS_NULL,Ue.IS_NOT_NULL].map(c=>r.jsx("option",{value:c,children:gw(c)},c)),ZT=[Ht.IS_EXACTLY,Ht.IS_NOT_EXACTLY,Ht.CONTAINS,Ht.DOES_NOT_CONTAIN,Ht.STARTS_WITH,Ht.ENDS_WITH,Ht.IS_NULL,Ht.IS_NOT_NULL].map(c=>r.jsx("option",{value:c,children:pw(c)},c)),QT=[xt.IS_EXACTLY,xt.IS_NOT_EXACTLY,xt.IS_BEFORE,xt.IS_BEFORE_OR_EQUAL,xt.IS_AFTER,xt.IS_AFTER_OR_EQUAL,xt.IS_NULL,xt.IS_NOT_NULL].map(c=>r.jsx("option",{value:c,children:fw(c)},c)),JT=[qi.IS_TRUE,qi.IS_FALSE,qi.IS_NULL,qi.IS_NOT_NULL].map(c=>r.jsx("option",{value:c,children:Cw(c)},c)),eE=[Ks.IS_EQUAL,Ks.IS_NOT_EQUAL,Ks.IS_NULL,Ks.IS_NOT_NULL].map(c=>r.jsx("option",{value:c,children:Sw(c)},c));function tE(c,e,t,n){return c===Ue.IS_NULL||c===Ue.IS_NOT_NULL||c===Ue.IS_BETWEEN&&t!=null&&t!==""&&!Number.isNaN(Number.parseFloat(t))&&n!=null&&n!==""&&!Number.isNaN(Number.parseFloat(n))||c!==Ue.IS_BETWEEN&&e!==void 0&&e!==""&&!Number.isNaN(Number.parseFloat(e))}function nE(c,e,t,n,s,i,o){switch(c){case Ue.IS_EQUAL:case Ue.IS_NOT_EQUAL:case Ue.GREATER_THAN:case Ue.GREATER_THAN_OR_EQUAL:case Ue.LESS_THAN:case Ue.LESS_THAN_OR_EQUAL:return r.jsx("input",{type:"number",className:"form-control",placeholder:"Enter value",value:s??"",onChange:e});case Ue.IS_BETWEEN:return r.jsxs("div",{className:"d-flex flex-row",children:[r.jsx("input",{type:"number",className:"form-control d-flex mr-2",placeholder:"Start value",value:i??"",onChange:t}),r.jsx("input",{type:"number",className:"form-control d-flex",placeholder:"End value",value:o??"",onChange:n})]});case Ue.IS_NULL:case Ue.IS_NOT_NULL:return null}}function sE(c,e,t){switch(c){case Ht.IS_NULL:case Ht.IS_NOT_NULL:return null;default:return r.jsx("input",{type:"text",className:"form-control",placeholder:"Enter value",value:t??"",onChange:e})}}function iE(c,e,t){switch(c){case xt.IS_NULL:case xt.IS_NOT_NULL:return null;default:return r.jsx("input",{type:"text",className:"form-control",placeholder:"Enter value",value:t??"",onChange:e})}}function oE(){return null}function lE(c,e,t){switch(c){case Ks.IS_NULL:case Ks.IS_NOT_NULL:return null;default:return r.jsx("input",{type:"text",className:"form-control",maxLength:1,placeholder:"Enter value",value:t??"",onChange:e})}}function yu(c){const{column:e,config:t,onChange:n=qT}=c,s=e.type,[i,o]=w.useState(s),[l,a]=w.useState(t.condition),[d,h]=w.useState(t.value),[u,m]=w.useState(t.start),[g,p]=w.useState(t.end);s!==i&&(a(cu(s)),h(hu(s)),m(void 0),p(void 0),o(s));const C=w.useMemo(()=>{if(s===void 0)return[];if(F.isNumberType(s))return XT;if(F.isCharType(s))return eE;if(F.isStringType(s))return ZT;if(F.isDateType(s))return QT;if(F.isBooleanType(s))return JT},[s]),f=w.useCallback(y=>{const{value:E}=y.target;As.debug("handleConditionChange",E),a(E)},[]),S=w.useCallback(y=>{const{value:E}=y.target;As.debug("handleValueChange",E),h(E)},[]),v=w.useCallback(y=>{const{value:E}=y.target;As.debug("handleStartValueChange",E),m(E)},[]),b=w.useCallback(y=>{const{value:E}=y.target;As.debug("handleEndValueChange",E),p(E)},[]);w.useEffect(function(){let E=!0;l===void 0?(As.debug("Unable to create formatting rule. Condition is not selected."),E=!1):F.isNumberType(e.type)&&!tE(l,d,u,g)?(As.debug("Unable to create formatting rule. Invalid value",d),E=!1):F.isDateType(e.type)&&!kw(l,d)&&(As.debug("Unable to create formatting rule. Invalid date condition",d),E=!1),n({condition:l,value:d,start:u,end:g},E)},[n,e.type,l,d,u,g]);const T=w.useMemo(()=>{if(s===void 0)return null;if(F.isNumberType(s))return nE(l,S,v,b,d,u,g);if(F.isCharType(s))return lE(l,S,d);if(F.isStringType(s))return sE(l,S,d);if(F.isDateType(s))return iE(l,S,d);if(F.isBooleanType(s))return oE()},[s,l,d,u,g,S,v,b]);return r.jsxs("div",{className:"condition-editor mb-2",children:[r.jsx("select",{value:l,id:"condition-select",className:"custom-select mb-2",onChange:f,children:C}),T]})}const aE=ee.module("StyleEditor"),rE="#fcfcfa",dE="#f0f0ee",cE="#1a171a",hE=200,uE=()=>{};function Ru(c){const{config:e,onChange:t=uE}=c,[n,s]=w.useState(e.type),[i,o]=w.useState(e.customConfig?.background??rE),[l,a]=w.useState(!1),[d,h]=w.useState(hE),u=w.useRef(null),m=w.useCallback(b=>{const{value:T}=b.target;aE.debug("handleBackgroundChange",T),o(T)},[]),g=w.useCallback(()=>{l&&a(!1)},[l]),p=w.useCallback(()=>{l||f(),a(!l)},[l]),C=w.useMemo(()=>[on.NO_FORMATTING,on.POSITIVE,on.NEGATIVE,on.WARN,on.NEUTRAL,on.ACCENT_1,on.ACCENT_2,on.CUSTOM],[]);function f(){u.current&&h(u.current.getBoundingClientRect().width)}w.useEffect(function(){t({type:n,customConfig:{color:sh.isDark(i)?dE:cE,background:i}})},[t,n,i]);const S=w.useCallback(()=>{const b=[];for(let T=0;T<C.length;T+=1){const y=C[T],E=`option-${T}-${y}`;b.push(r.jsxs(_,{kind:"inline",className:"style-option-btn",onClick:()=>{s(y),a(!1)},style:{color:Tl({type:y}),background:vl({type:y})},children:[y===n&&r.jsx(X,{icon:Yn,className:"mr-2"}),y!==n&&r.jsx("span",{className:"mr-4"}),Xd(y)]},E))}return b},[C,n]),v=w.useCallback(()=>r.jsx("div",{className:"style-menu-container",role:"presentation",style:{width:d},children:r.jsx("div",{className:"style-options",children:S()})}),[d,S]);return r.jsxs("div",{className:"style-editor",children:[r.jsxs("div",{className:"mb-2",ref:u,children:[r.jsx("label",{className:"mb-0",children:"Style"}),r.jsxs(_,{kind:"inline",className:"cs-dropdown",style:{color:Tl({type:n}),background:vl({type:n})},onClick:p,children:[Xd(n),r.jsx("span",{children:r.jsx(X,{icon:bg,className:"cs-caret"})}),r.jsx(Wn,{isShown:l,actions:{menuElement:v()},popperOptions:{placement:"bottom-start"},popperClassName:"style-dropdown-menu",onMenuClosed:g,menuStyle:{maxWidth:"100rem"}})]})]}),n===on.CUSTOM&&r.jsxs("div",{className:"mb-2",children:[r.jsx("label",{className:"mb-0",children:"Background"}),r.jsx("input",{type:"color",value:i,className:"custom-select color-select",onChange:m})]})]})}const Vi=ee.module("ColumnFormatEditor"),mE=()=>{};function gE(c){const{type:e,name:t}=c[0];return{column:{type:e,name:t},style:mu(),...ea(e)}}function pE(c){const{columns:e,config:t=gE(e),onChange:n=mE}=c,[s,i]=w.useState(e.find(f=>f.name===t.column.name&&f.type===t.column.type)??e[0]),[o,l]=w.useState(uu(t)),[a,d]=w.useState(!1),[h,u]=w.useState(t.style),m=w.useCallback(f=>{const S=e.find(({name:v})=>v===f);S!==void 0?(i(S),s.type!==S.type&&(l(ea(S.type)),d(!1))):Vi.error(`Column ${f} not found.`)},[e,s]),g=w.useCallback((f,S)=>{Vi.debug("handleConditionChange",f,S),l(f),d(S)},[]),p=w.useCallback(f=>{Vi.debug("handleStyleChange",f),u(f)},[]);w.useEffect(function(){let S=a;s===void 0&&(Vi.debug("Column is not selected, invalidating update."),S=!1),(h===void 0||h.type===on.NO_FORMATTING)&&(Vi.debug("Style is not selected, invalidating update."),S=!1);const{type:v,name:b}=s;n({column:{type:v,name:b},style:h,...o},S)},[n,s,h,o,a]);const C=e.map(({name:f})=>({title:f,value:f}));return r.jsxs("div",{className:"conditional-rule-editor form",children:[r.jsxs("div",{className:"mb-2",children:[r.jsx("label",{className:"mb-0",children:"Format Cell If"}),r.jsx($c,{defaultValue:s?.name,options:C,inputPlaceholder:"Select a column",spellCheck:!1,onChange:m,searchPlaceholder:"Filter columns"})]}),s!==void 0&&r.jsxs(r.Fragment,{children:[r.jsx(yu,{column:s,config:o,onChange:g}),r.jsx(Ru,{config:h,onChange:p})]})]})}const Bi=ee.module("RowFormatEditor"),fE=()=>{};function CE(c){const{type:e,name:t}=c[0];return{column:{type:e,name:t},style:mu(),...ea(e)}}function SE(c){const{columns:e,config:t=CE(e),onChange:n=fE}=c,[s,i]=w.useState(e.find(f=>f.name===t.column.name&&f.type===t.column.type)??e[0]),[o,l]=w.useState(uu(t)),[a,d]=w.useState(!1),[h,u]=w.useState(t.style),m=w.useCallback(f=>{const S=e.find(({name:v})=>v===f);S!==void 0?(i(S),s.type!==S.type&&(l(ea(S.type)),d(!1))):Bi.error(`Column ${f} not found.`)},[e,s]),g=w.useCallback((f,S)=>{Bi.debug("handleConditionChange",f,S),l(f),d(S)},[]),p=w.useCallback(f=>{Bi.debug("handleStyleChange",f),u(f)},[]);w.useEffect(function(){if(s===void 0){Bi.debug("Column is not selected, skip update.");return}if(h===void 0){Bi.debug("Style is not selected, skip update.");return}const{type:S,name:v}=s;n({column:{type:S,name:v},style:h,...o},a)},[n,s,h,o,a]);const C=e.map(({name:f})=>({title:f,value:f}));return r.jsxs("div",{className:"conditional-rule-editor form",children:[r.jsxs("div",{className:"mb-2",children:[r.jsx("label",{className:"mb-0",children:"Format Row If"}),r.jsx($c,{defaultValue:s?.name,options:C,inputPlaceholder:"Select a column",spellCheck:!1,onChange:m,searchPlaceholder:"Filter columns"})]}),s!==void 0&&r.jsxs(r.Fragment,{children:[r.jsx(yu,{column:s,config:o,onChange:g}),r.jsx(Ru,{config:h,onChange:p})]})]})}const xa=ee.module("ConditionalFormatEditor"),Ia=()=>{};function bE(c){switch(c){case Fn.CONDITIONAL:return r.jsx(Zv,{});case Fn.ROWS:return r.jsx(Qv,{})}}function wE(c){switch(c){case Fn.CONDITIONAL:return"Conditional";case Fn.ROWS:return"Rows"}}const ac=[Fn.CONDITIONAL,Fn.ROWS];function vE(c){const{columns:e,onSave:t=Ia,onUpdate:n=Ia,onCancel:s=Ia,rule:i}=c,o=e.filter(Mw),[l,a]=w.useState(i?.type??ac[0]),[d,h]=w.useState(i),[u,m]=w.useState(!1),g=w.useCallback(()=>{s()},[s]),p=w.useCallback(()=>{if(d===void 0){xa.error("Rule is not defined.");return}t(d)},[t,d]),C=w.useCallback(S=>{xa.debug("handleFormatterChange",S),a(S)},[]),f=w.useCallback((S,v)=>{xa.debug("handleRuleChange",S,v,l);const b={type:l,config:S};h(b),m(v),n(v?b:void 0)},[n,l]);return r.jsxs("div",{className:"conditional-format-editor form",children:[r.jsxs("div",{className:"mb-2",children:[r.jsx("label",{className:"mb-0",htmlFor:"formatter-select",children:"Select Formatter"}),r.jsx("div",{className:"formatter-list",children:ac.map((S,v)=>r.jsx("div",{className:"formatter-type",children:r.jsxs("button",{type:"button",className:K("btn","btn-icon","btn-formatter-type",{active:S===l}),"data-index":v,onClick:()=>C(S),children:[bE(S),wE(S)]})},S))})]}),l===Fn.CONDITIONAL&&r.jsx(pE,{columns:o,config:d?.config,onChange:f}),l===Fn.ROWS&&r.jsx(SE,{columns:o,config:d?.config,onChange:f}),r.jsx("hr",{}),r.jsxs("div",{className:"d-flex justify-content-end my-3",children:[r.jsx(_,{kind:"secondary",onClick:g,className:"mr-2",children:"Cancel"}),r.jsx(_,{kind:"primary",onClick:p,disabled:d===void 0||!u,children:"Done"})]})]})}function TE({text:c,isOpen:e,onClose:t}){const[n,s]=w.useState(!1),[i,o]=w.useState(0),[l,a]=w.useState(!1),[d,h]=w.useState(!1),[u,m]=w.useState(!1),g=w.useRef();w.useEffect(function(){if(e){try{JSON.parse(c),m(!0)}catch{m(!1)}h(!1)}},[e,c]),w.useEffect(function(){g.current&&g.current.layout()},[i]),w.useEffect(function(){g.current&&g.current.updateOptions({lineNumbers:l?"on":"off"})},[l]);function p(){a(!l)}function C(){const b=g.current?.getModel();!u||!b||(d?(b.setValue(c),h(!1)):(b.setValue(JSON.stringify(JSON.parse(c),void 0,2)),h(!0)),f())}function f(){const b=g.current;b&&a((b.getModel()?.getLineCount()??0)>1)}function S(){n&&(g.current=void 0,t())}function v(b){g.current=b,o(b.getContentHeight()),b.onDidContentSizeChange(({contentHeight:T})=>o(T)),f()}return!e&&!n?null:r.jsxs($l,{isOpen:e,centered:!0,keyboard:!0,toggle:S,onOpened:()=>s(!0),onClosed:()=>{s(!1),o(0)},className:"theme-bg-dark cell-overflow-modal",size:"xl",children:[r.jsxs(Wl,{toggle:t,children:[r.jsx("h5",{className:"overflow-modal-title",children:"Cell Contents"}),r.jsx(jl,{kind:"inline",tooltip:"Copy cell contents",copy:g.current?.getValue()??c}),r.jsx(_,{kind:"inline",active:l,icon:wg,tooltip:"Toggle line numbers",onClick:p}),u&&r.jsx(_,{kind:"inline",icon:vg,active:d,tooltip:"Format as JSON",onClick:C})]}),r.jsx(Gl,{style:{height:i},children:r.jsx(pr,{onEditorInitialized:v,settings:{value:c,readOnly:!0,wordWrap:"on",language:u?"typescript":"plaintext",folding:u,padding:{bottom:16},lineNumbers:l?"on":"off",overviewRulerLanes:0,renderLineHighlight:"none",find:{seedSearchStringFromSelection:"never"}}})})]})}function EE(c){return c.model!==void 0}const yE="###,##0";function RE({gotoRow:c,gotoRowError:e,gotoValueError:t,onGotoRowSubmit:n,isShown:s,onEntering:i,onEntered:o,onExiting:l,onExited:a,model:d,onGotoRowNumberChanged:h,onClose:u,gotoValueSelectedColumnName:m,gotoValue:g,gotoValueFilter:p,onGotoValueSelectedColumnNameChanged:C,onGotoValueSelectedFilterChanged:f,onGotoValueChanged:S,onGotoValueSubmit:v}){const b=w.useRef(null),T=w.useRef(null),[y,E]=w.useState(!1);let R=[];EE(d)&&d.table!==void 0&&({columns:R}=d.table);const x="Row number",{rowCount:D}=d,L=G=>{G.key==="Enter"?(G.stopPropagation(),G.preventDefault(),v()):(G.key==="Backspace"||G.key==="Delete")&&(g===`${Number.POSITIVE_INFINITY}`||g===`${Number.NEGATIVE_INFINITY}`)&&U("")},M=G=>{G.key==="Enter"&&(G.stopPropagation(),G.preventDefault(),v(G.shiftKey))},j=d.getColumnIndexByName(m),W=R[j??0]?.type,H=F.getNormalizedType(W),U=G=>{S(G??"")},P=()=>{y&&document.activeElement!==b.current?b.current?.select():!y&&document.activeElement!==T.current&&T.current?.select()};w.useEffect(P,[y,c,g]);const Q=()=>{switch(H){case F.dataType.DECIMAL:case F.dataType.INT:return r.jsx("div",{className:"goto-row-input",children:r.jsx("input",{ref:T,className:K("form-control",{"is-invalid":t!==""}),onKeyDown:L,placeholder:"value",onChange:G=>{const ne=G.target.value.toLowerCase();/^-?[0-9]*\.?[0-9]*$/.test(G.target.value)?U(G.target.value):ne==="-i"||ne==="-infinity"?U(`${Number.NEGATIVE_INFINITY}`):(ne==="i"||ne==="infinity")&&U(`${Number.POSITIVE_INFINITY}`)},value:g})});case F.dataType.DATETIME:return r.jsx("div",{className:"goto-value-date-time-input",children:r.jsx(Fm,{ref:T,className:K("form-control","goto-value-date-time-input",{"is-invalid":t!==""}),defaultValue:g,onChange:U,onSubmit:M})});case F.dataType.STRING:return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"goto-row-input",children:r.jsxs("select",{className:"custom-select",onChange:G=>{f(G.target.value)},value:p,children:[r.jsx("option",{value:pe.eq,children:"Equals"},pe.eq),r.jsx("option",{value:pe.contains,children:"Contains"},pe.contains),r.jsx("option",{value:pe.eqIgnoreCase,children:"EqIgnoreCase"},pe.eqIgnoreCase)]})}),r.jsx("div",{className:"goto-row-input",children:r.jsx("input",{ref:T,className:K("form-control",{"is-invalid":t!==""}),onKeyDown:M,placeholder:"value",onChange:G=>U(G.target.value),value:g})})]});case F.dataType.BOOLEAN:return r.jsx("div",{className:"goto-row-input",children:r.jsxs("select",{className:"custom-select",onChange:G=>{U(G.target.value)},value:g,children:[r.jsx("option",{"aria-label":"null value",value:""},"null"),r.jsx("option",{value:"true",children:"true"},"true"),r.jsx("option",{value:"false",children:"false"},"false")]})});default:return r.jsx("div",{className:"goto-row-input",children:r.jsx("input",{ref:T,className:"form-control",onKeyDown:M,placeholder:"value",onChange:G=>U(G.target.value),value:g})})}};return r.jsx(ta,{isShown:s,className:K("goto-row"),onEntering:i,onEntered:()=>{o(),P()},onExiting:l,onExited:a,children:r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"goto-row-row",children:[r.jsxs("div",{className:K("goto-row-wrapper",{"is-inactive":!y}),onClick:()=>E(!0),onFocus:()=>E(!0),role:"group",children:[r.jsx("div",{className:"goto-row-text",children:"Go to row"}),r.jsx("div",{className:"goto-row-input",children:r.jsx("input",{ref:b,type:"number",onKeyDown:G=>{G.key==="Enter"&&(G.stopPropagation(),G.preventDefault(),n())},className:K("form-control",{"is-invalid":e!==""}),placeholder:x,onChange:G=>{h(G)},value:c})}),r.jsxs("div",{className:"goto-row-text",children:["of ",dh.i18n.NumberFormat.format(yE,D)]}),e&&r.jsx("div",{className:"text-danger",children:e})]}),r.jsx("div",{className:"goto-row-close",children:r.jsx(_,{kind:"ghost",onClick:u,children:r.jsx(X,{icon:ho,style:{marginRight:"0"}})})})]}),d.isSeekRowAvailable&&r.jsx("div",{className:"goto-row-row",children:r.jsxs("div",{className:K("goto-row-wrapper",{"is-inactive":y}),onClick:()=>E(!1),onFocus:()=>E(!1),role:"group",children:[r.jsx("div",{className:"goto-row-text",children:"Go to value"}),r.jsx("div",{className:"goto-row-input",children:r.jsx("select",{className:"custom-select",onChange:G=>{const ne=G.target.value;C(ne)},value:m,children:R.map(G=>r.jsx("option",{value:G.name,children:G.name},G.name))})}),Q(),r.jsxs("div",{children:[r.jsx(_,{kind:"ghost",disabled:g==="",onClick:()=>{v(!0)},children:r.jsx(X,{icon:eh})}),r.jsx(_,{kind:"ghost",disabled:g==="",onClick:()=>{v(!1)},children:r.jsx(X,{icon:Tg})})]}),t&&r.jsx("div",{className:"text-danger",children:t})]})})]})})}const ce=ee.module("IrisGrid"),xE=500,IE=250,DE=250,FE=250,rc=Object.freeze({aggregations:Fe,showOnTop:!1}),NE="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function dc({advancedFilters:c,aggregationSettings:e,customColumns:t,quickFilters:n,reverseType:s,rollupConfig:i,searchFilter:o,selectDistinctColumns:l,sorts:a}){return c.size===0&&e.aggregations.length===0&&t.length===0&&n.size===0&&s===F.REVERSE_TYPE.NONE&&i==null&&o==null&&l.length===0&&a.length===0}class Un extends w.Component{static minDebounce=150;static maxDebounce=500;static loadingSpinnerDelay=800;static defaultProps={children:null,advancedFilters:jn,advancedSettings:jn,alwaysFetchColumns:Fe,conditionalFormats:Fe,customColumnFormatMap:jn,isFilterBarShown:!1,applyInputFiltersOnInit:!1,movedColumns:Fe,movedRows:Fe,inputFilters:Fe,customFilters:Fe,onCreateChart:void 0,onColumnSelected:()=>{},onDataSelected:()=>{},onError:()=>{},onStateChange:()=>{},onPartitionAppend:()=>{},onAdvancedSettingsChange:()=>{},partition:null,partitionColumn:null,quickFilters:jn,selectDistinctColumns:Fe,sorts:Fe,reverseType:F.REVERSE_TYPE.NONE,customColumns:Fe,aggregationSettings:rc,rollupConfig:void 0,userColumnWidths:jn,userRowHeights:jn,onSelectionChanged:()=>{},isSelectingColumn:!1,isSelectingPartition:!1,isStuckToBottom:!1,isStuckToRight:!1,columnSelectionValidator:null,columnAllowedCursor:null,columnNotAllowedCursor:null,name:"table",onlyFetchVisibleColumns:!0,showSearchBar:!1,searchValue:"",selectedSearchColumns:null,invertSearchColumns:!0,onContextMenu:()=>{},pendingDataMap:jn,getDownloadWorker:void 0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Zs.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,truncateNumbersWithPound:!1,formatter:Fe,decimalFormatOptions:B.shape({defaultFormatString:B.string}),integerFormatOptions:B.shape({defaultFormatString:B.string})},canCopy:!0,canDownloadCsv:!0,frozenColumns:null,theme:ec,canToggleSearch:!0};static makeQuickFilter(e,t,n){try{return F.makeQuickFilter(e,t,n)}catch(s){ce.error("Error creating quick filter",s)}return null}constructor(e){super(e),this.handleAdvancedFilterChange=this.handleAdvancedFilterChange.bind(this),this.handleAdvancedFilterSortChange=this.handleAdvancedFilterSortChange.bind(this),this.handleAdvancedFilterDone=this.handleAdvancedFilterDone.bind(this),this.handleAdvancedMenuOpened=this.handleAdvancedMenuOpened.bind(this),this.handleGotoRowOpened=this.handleGotoRowOpened.bind(this),this.handleGotoRowClosed=this.handleGotoRowClosed.bind(this),this.handleAdvancedMenuClosed=this.handleAdvancedMenuClosed.bind(this),this.handleAggregationChange=this.handleAggregationChange.bind(this),this.handleAggregationsChange=this.handleAggregationsChange.bind(this),this.handleAggregationEdit=this.handleAggregationEdit.bind(this),this.handleAnimationLoop=this.handleAnimationLoop.bind(this),this.handleAnimationStart=this.handleAnimationStart.bind(this),this.handleAnimationEnd=this.handleAnimationEnd.bind(this),this.handleChartChange=this.handleChartChange.bind(this),this.handleChartCreate=this.handleChartCreate.bind(this),this.handleGridError=this.handleGridError.bind(this),this.handleFilterBarChange=this.handleFilterBarChange.bind(this),this.handleFilterBarDone=this.handleFilterBarDone.bind(this),this.handleFilterBarTab=this.handleFilterBarTab.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleMenu=this.handleMenu.bind(this),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleMenuSelect=this.handleMenuSelect.bind(this),this.handleMenuBack=this.handleMenuBack.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleSelectionChanged=this.handleSelectionChanged.bind(this),this.handleMovedColumnsChanged=this.handleMovedColumnsChanged.bind(this),this.handleHeaderGroupsChanged=this.handleHeaderGroupsChanged.bind(this),this.handleUpdate=this.handleUpdate.bind(this),this.handleTooltipRef=this.handleTooltipRef.bind(this),this.handleViewChanged=this.handleViewChanged.bind(this),this.handleFormatSelection=this.handleFormatSelection.bind(this),this.handleConditionalFormatCreate=this.handleConditionalFormatCreate.bind(this),this.handleConditionalFormatEdit=this.handleConditionalFormatEdit.bind(this),this.handleConditionalFormatsChange=this.handleConditionalFormatsChange.bind(this),this.handleConditionalFormatEditorSave=this.handleConditionalFormatEditorSave.bind(this),this.handleConditionalFormatEditorCancel=this.handleConditionalFormatEditorCancel.bind(this),this.handleUpdateCustomColumns=this.handleUpdateCustomColumns.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.handleSelectDistinctChanged=this.handleSelectDistinctChanged.bind(this),this.handlePendingDataUpdated=this.handlePendingDataUpdated.bind(this),this.handlePendingCommitClicked=this.handlePendingCommitClicked.bind(this),this.handlePendingDiscardClicked=this.handlePendingDiscardClicked.bind(this),this.handleGotoRowSelectedRowNumberSubmit=this.handleGotoRowSelectedRowNumberSubmit.bind(this),this.focusRowInGrid=this.focusRowInGrid.bind(this),this.handleDownloadTable=this.handleDownloadTable.bind(this),this.handleDownloadTableStart=this.handleDownloadTableStart.bind(this),this.handleCancelDownloadTable=this.handleCancelDownloadTable.bind(this),this.handleDownloadCanceled=this.handleDownloadCanceled.bind(this),this.handleDownloadCompleted=this.handleDownloadCompleted.bind(this),this.handlePartitionAppend=this.handlePartitionAppend.bind(this),this.handlePartitionChange=this.handlePartitionChange.bind(this),this.handlePartitionFetchAll=this.handlePartitionFetchAll.bind(this),this.handlePartitionDone=this.handlePartitionDone.bind(this),this.handleColumnVisibilityChanged=this.handleColumnVisibilityChanged.bind(this),this.handleColumnVisibilityReset=this.handleColumnVisibilityReset.bind(this),this.handleCrossColumnSearch=this.handleCrossColumnSearch.bind(this),this.handleRollupChange=this.handleRollupChange.bind(this),this.handleOverflowClose=this.handleOverflowClose.bind(this),this.getColumnBoundingRect=this.getColumnBoundingRect.bind(this),this.handleGotoRowSelectedRowNumberChanged=this.handleGotoRowSelectedRowNumberChanged.bind(this),this.handleGotoValueSelectedColumnNameChanged=this.handleGotoValueSelectedColumnNameChanged.bind(this),this.handleGotoValueSelectedFilterChanged=this.handleGotoValueSelectedFilterChanged.bind(this),this.handleGotoValueChanged=this.handleGotoValueChanged.bind(this),this.handleGotoValueSubmitted=this.handleGotoValueSubmitted.bind(this),this.grid=null,this.gridWrapper=null,this.lastLoadedConfig=null,this.pending=new Xn,this.globalColumnFormats=Fe,this.decimalFormatOptions={},this.integerFormatOptions={},this.truncateNumbersWithPound=!1,this.renderer=new Mv,this.tableSaver=null,this.crossColumnRef=ae.createRef(),this.isAnimating=!1,this.filterInputRef=ae.createRef(),this.toggleFilterBarAction={action:()=>this.toggleFilterBar(),shortcut:Ut.TABLE.TOGGLE_QUICK_FILTER},this.toggleSearchBarAction={action:()=>this.toggleSearchBar(),shortcut:Ut.TABLE.TOGGLE_SEARCH},this.toggleGotoRowAction={action:()=>this.toggleGotoRow(),shortcut:Ut.TABLE.GOTO_ROW},this.discardAction={action:()=>{const{model:P}=this.props;Ke(P)&&P.isEditable&&P.pendingDataMap.size>0&&this.discardPending().catch(ce.error)},shortcut:Ut.INPUT_TABLE.DISCARD},this.commitAction={action:()=>{const{model:P}=this.props;Ke(P)&&P.isEditable&&P.pendingDataMap.size>0&&P.pendingDataErrors.size===0&&this.commitPending().catch(ce.error)},shortcut:Ut.INPUT_TABLE.COMMIT},this.contextActions=[this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,this.discardAction,this.commitAction];const{aggregationSettings:t,conditionalFormats:n,customColumnFormatMap:s,isFilterBarShown:i,isSelectingPartition:o,model:l,movedColumns:a,movedRows:d,partition:h,partitionColumn:u,rollupConfig:m,userColumnWidths:g,userRowHeights:p,showSearchBar:C,searchValue:f,selectedSearchColumns:S,invertSearchColumns:v,advancedFilters:b,quickFilters:T,selectDistinctColumns:y,pendingDataMap:E,canCopy:R,frozenColumns:x,columnHeaderGroups:D}=e,L=[new Qw(this),new ev(this)];R&&L.push(new Kw(this));const M=[new nv(this),new bv(this),new Rv(this),new iv(this),new lv(this),new vv(this),new Cv(this),new mv(this),new pv(this),new Ev(this)],j=a.length>0?a:l.initialMovedColumns,A=d.length>0?d:l.initialMovedRows,W=new Fv({userColumnWidths:new Map(g),userRowHeights:new Map(p),movedColumns:j,initialColumnWidths:new Map(l?.layoutHints?.hiddenColumns?.map(P=>[l.getColumnIndexByName(P),0]))}),H=S??[],U=zo.createSearchFilter(f,H,l.columns,v);this.state={isFilterBarShown:i,isSelectingPartition:o,focusedFilterBarColumn:null,metricCalculator:W,metrics:void 0,keyHandlers:L,mouseHandlers:M,partition:h,partitionColumn:u,partitionTable:null,partitionFilters:[],quickFilters:T?new Map(T):new Map,advancedFilters:new Map(b),shownAdvancedFilter:null,hoverAdvancedFilter:null,sorts:[],reverseType:F.REVERSE_TYPE.NONE,customColumns:[],selectDistinctColumns:y,selectedRanges:[],copyOperation:null,loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1,movedColumns:j,movedRows:A,shownColumnTooltip:null,formatter:new gn,isMenuShown:!1,customColumnFormatMap:new Map(s),conditionalFormats:n,conditionalFormatEditIndex:null,conditionalFormatPreview:void 0,hoverSelectColumn:null,isTableDownloading:!1,isReady:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:0,showSearchBar:C,searchFilter:U,searchValue:f,selectedSearchColumns:H,invertSearchColumns:v,rollupConfig:m,rollupSelectedColumns:[],aggregationSettings:t,selectedAggregation:null,openOptions:[],pendingRowCount:0,pendingDataMap:E??new Map,pendingDataErrors:new Map,pendingSavePromise:null,pendingSaveError:null,toastMessage:null,frozenColumns:x,showOverflowModal:!1,overflowText:"",overflowButtonTooltipProps:null,expandCellTooltipProps:null,expandTooltipDisplayValue:"expand",linkHoverTooltipProps:null,linkHoverDisplayValue:"",isGotoShown:!1,gotoRow:"",gotoRowError:"",gotoValueError:"",gotoValueSelectedColumnName:l.columns[0]?.name??"",gotoValueSelectedFilter:pe.eq,gotoValue:"",columnHeaderGroups:D??l.initialColumnHeaderGroups}}componentDidMount(){const{partitionColumn:e,model:t}=this.props,n=e??t.columns.find(s=>s.isPartitionColumn);t.isFilterRequired&&t.isValuesTableAvailable&&n!=null?this.loadPartitionsTable(n):this.initState(),this.startListening(t)}componentDidUpdate(e){const{inputFilters:t,isSelectingColumn:n,settings:s,model:i,customFilters:o,sorts:l}=this.props;i!==e.model&&(this.stopListening(e.model),this.startListening(i));const a=t!==e.inputFilters?t.filter(u=>!e.inputFilters.includes(u)):[];if(a.length>0){const{advancedSettings:u}=this.props,m=u.get(Ri.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS)??!1;m&&(this.clearGridInputField(),this.clearCrossColumSearch()),this.startLoading("Filtering...",!0),this.applyInputFilters(a,m)}n!==e.isSelectingColumn&&this.resetColumnSelection(),s!==e.settings&&this.updateFormatterSettings(s),o!==e.customFilters&&this.startLoading("Filtering...",!0),l!==e.sorts&&this.updateSorts(l);const{loadingScrimStartTime:d,loadingScrimFinishTime:h}=this;d!=null&&h!=null&&window.requestAnimationFrame(()=>{const u=Date.now(),m=u-d,g=h-d,p=Math.min(m/g,1);h<u&&(this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0),this.setState(C=>C.loadingScrimProgress==null?(ce.debug2("Ignoring scrim update because loading cancelled."),null):{loadingScrimProgress:p})}),this.sendStateChange()}componentWillUnmount(){const{model:e}=this.props;this.stopListening(e),this.pending.cancel(),this.updateSearchFilter.cancel(),this.loadingTimer&&clearTimeout(this.loadingTimer),this.handleDownloadProgressUpdate.cancel(),this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame)}grid;gridWrapper;lastFocusedFilterBarColumn;lastLoadedConfig;tooltip;pending;globalColumnFormats;dateTimeFormatterOptions;decimalFormatOptions;integerFormatOptions;truncateNumbersWithPound;loadingScrimStartTime;loadingScrimFinishTime;animationFrame;loadingTimer;renderer;tableSaver;crossColumnRef;isAnimating;filterInputRef;toggleFilterBarAction;toggleSearchBarAction;toggleGotoRowAction;discardAction;commitAction;contextActions;getAdvancedMenuOpenedHandler=Te(e=>this.handleAdvancedMenuOpened.bind(this,e),{max:100});getCachedAdvancedFilterMenuActions=Te((e,t,n,s,i)=>r.jsx(Bv,{model:e,column:t,onFilterChange:this.handleAdvancedFilterChange,onSortChange:this.handleAdvancedFilterSortChange,onDone:this.handleAdvancedFilterDone,options:n,sortDirection:s,formatter:i}),{max:50});getCachedOptionItems=Te((e,t,n,s,i,o,l,a,d,h,u,m,g,p,C,f)=>{const S=[];return e&&S.push({type:De.CHART_BUILDER,title:"Chart Builder",icon:Eg}),S.push({type:De.VISIBILITY_ORDERING_BUILDER,title:"Organize Columns",icon:hr}),n&&S.push({type:De.CONDITIONAL_FORMATTING,title:"Conditional Formatting",icon:mo}),t&&S.push({type:De.CUSTOM_COLUMN_BUILDER,title:"Custom Columns",icon:yg}),s&&S.push({type:De.ROLLUP_ROWS,title:"Rollup Rows",icon:th}),i&&S.push({type:De.AGGREGATIONS,title:"Aggregate Columns",icon:Rg}),o&&S.push({type:De.SELECT_DISTINCT,title:"Select Distinct Values",icon:xg}),l&&g&&S.push({type:De.TABLE_EXPORTER,title:"Download CSV",icon:Ig}),f&&S.push({type:De.ADVANCED_SETTINGS,title:"Advanced Settings",icon:Dg}),S.push({type:De.QUICK_FILTERS,title:"Quick Filters",subtitle:a.shortcut.getDisplayText(),icon:rl,isOn:u,onChange:a.action}),p&&S.push({type:De.SEARCH_BAR,title:"Search Bar",subtitle:d.shortcut.getDisplayText(),icon:Fg,isOn:m,onChange:d.action}),S.push({type:De.GOTO,title:"Go to",subtitle:h.shortcut.getDisplayText(),icon:Ng,isOn:C,onChange:h.action}),Object.freeze(S)},{max:1});getCachedHiddenColumns=Te((e,t)=>Ce.getHiddenColumns(new Map([...e.initialColumnWidths,...t])),{max:1});getAggregationMap=Te((e,t)=>{const n={};return t.forEach(({operation:s,selected:i,invert:o})=>{n[s]=Ss.getOperationColumnNames(e,s,i,o)}),n});getOperationMap=Te((e,t)=>{const n={};return t.filter(s=>!Ss.isRollupOperation(s.operation)).forEach(({operation:s,selected:i,invert:o})=>{Ss.getOperationColumnNames(e,s,i,o).forEach(l=>{const a=[...n[l]??[],s];n[l]=Object.freeze(a)})}),n});getOperationOrder=Te(e=>e.map(t=>t.operation).filter(t=>!Ss.isRollupOperation(t)));getCachedFormatColumns=Te((e,t)=>Nw(e,t));getCachedPreviewFormatColumns=Te((e,t,n,s)=>{if(ce.debug("getCachedPreviewFormatColumns",t,n,s),n!==void 0&&s!==void 0){const i=[...t];return i[s]=n,this.getCachedFormatColumns(e,i)}return this.getCachedFormatColumns(e,t)});getModelRollupConfig=Te((e,t,n)=>Ce.getModelRollupConfig(e,t,n));getModelTotalsConfig=Te((e,t,n)=>{const{aggregations:s,showOnTop:i}=n;if((t?.columns?.length??0)>0||(s?.length??0)===0)return null;const o=this.getOperationMap(e,s),l=this.getOperationOrder(s);return{operationMap:o,operationOrder:l,showOnTop:i}});getCachedStateOverride=Te((e,t,n,s,i,o,l,a,d,h)=>({hoverSelectColumn:e,isFilterBarShown:t,isSelectingColumn:n,loadingScrimProgress:s,quickFilters:i,advancedFilters:o,sorts:l,reverseType:a,rollupConfig:d,isMenuShown:h}),{max:1});getCachedFilter=Te((e,t,n,s,i)=>[...e??[],...s??[],...Ce.getFiltersFromFilterMap(t),...Ce.getFiltersFromFilterMap(n),...i!==void 0?[i]:[]],{max:1});getCachedTheme=Te((e,t,n)=>({...ec,...e,autoSelectRow:!t,rowFooterWidth:n>0?e.rowFooterWidth:0}),{max:1});getValueForCell(e,t,n=!1){const{model:s}=this.props,i=this.getModelColumn(e),o=this.getModelRow(t);if(n&&i!=null&&o!=null){const l=s.valueForCell(i,o);if(F.isDateType(s.columns[i].type)){const{formatter:a}=s;return I.i18n.DateTimeFormat.format(NE,l,I.i18n.TimeZone.getTimeZone(a.timeZone))}return l}return n?null:i!=null&&o!=null?s.textForCell(i,o):""}getModelColumn(e){const{metrics:t}=this.state;N(t);const{modelColumns:n}=t;return n==null?null:e!=null?n.get(e):null}getModelRow(e){const{metrics:t}=this.state;N(t);const{modelRows:n}=t;return n==null?null:e!=null?n.get(e):null}getTheme(){const{model:e,theme:t}=this.props;return this.getCachedTheme(t,(Ke(e)&&e.isEditable)??!1,e.floatingTopRowCount+e.floatingBottomRowCount)}getVisibleColumn(e){const{movedColumns:t}=this.state;return O.getVisibleIndex(e,t)}applyInputFilters(e,t=!1){const{model:n}=this.props,{advancedFilters:s,quickFilters:i}=this.state,o=t?new Map:new Map(s),l=t?new Map:new Map(i);let a=t&&s.size>0;e.forEach(({name:d,type:h,value:u})=>{const m=n.columns.findIndex(({name:g,type:p})=>g===d&&p===h);m>=0?(a=o.delete(m)||a,a=this.applyQuickFilter(m,u,l)||a):ce.error("Unable to find column for inputFilter",d,h,u)}),a&&this.setState({quickFilters:l,advancedFilters:o})}applyQuickFilter(e,t,n){const{model:s}=this.props,{formatter:i}=s,o=s.columns[e];if(t!=null&&`${t}`.trim().length>0){const l=n.get(e);if(l!=null){const{text:a}=l;if(a===t)return ce.debug2("Ignoring change to existing filter"),!1}return n.set(e,{text:t,filter:Un.makeQuickFilter(o,t,i.timeZone)}),!0}return n.delete(e)}setAdvancedFilterMap(e){this.setState({advancedFilters:e})}setAdvancedFilter(e,t,n){ce.debug("Setting advanced filter",e,t),this.startLoading("Filtering...",!0),this.setState(({advancedFilters:s})=>{const i=new Map(s);return t==null?i.delete(e):i.set(e,{filter:t,options:n}),{advancedFilters:i}})}setQuickFilter(e,t,n){ce.debug("Setting quick filter",e,t,n),this.startLoading("Filtering...",!0),this.setState(({quickFilters:s})=>{const i=new Map(s);return i.set(e,{filter:t,text:n}),{quickFilters:i}})}setFilterMap(e){ce.debug("setFilterMap",e);const{advancedSettings:t}=this.props;(t.get(Ri.LINK_CHANGE_CLEARS_ALL_FILTERS)??!1)&&this.clearAllFilters();const{model:s}=this.props;e.forEach(({columnType:i,filterList:o},l)=>{const a=s.columns.find(u=>u.name===l&&u.type===i);if(a==null)return;const d=s.getColumnIndexByName(a.name);N(d);const h=Ce.combineFiltersFromList(i,o);if(h.length===0)this.removeQuickFilter(d);else{const{formatter:u}=s;this.setQuickFilter(d,Un.makeQuickFilter(a,h,u.timeZone),`${h}`)}})}removeColumnFilter(e){this.startLoading("Filtering...",!0),this.setState(({advancedFilters:t,quickFilters:n})=>{const s=t?new Map(t):new Map,i=n?new Map(n):new Map;return i.delete(e),s.delete(e),{quickFilters:i,advancedFilters:s}})}removeQuickFilter(e){this.startLoading("Clearing Filter...",!0),this.setState(({quickFilters:t})=>{const n=new Map(t);return n.delete(e),{quickFilters:n}})}clearAllFilters(){ce.debug("Clearing all filters");const{advancedFilters:e,quickFilters:t,searchFilter:n}=this.state;t.size===0&&e.size===0&&n===null||(this.clearGridInputField(),this.startLoading("Clearing Filters...",!0),this.setState({quickFilters:new Map,advancedFilters:new Map,searchValue:"",searchFilter:void 0}))}clearCrossColumSearch(){ce.debug("Clearing cross-column search"),this.setState({searchValue:"",searchFilter:void 0})}clearGridInputField(){this.filterInputRef.current!=null&&this.filterInputRef.current.setValue("")}rebuildFilters(){ce.debug("Rebuilding filters");const{model:e}=this.props,{advancedFilters:t,quickFilters:n}=this.state,{columns:s,formatter:i}=e,o=new Map,l=new Map;t.forEach((a,d)=>{const{options:h}=a,u=s[d],m=F.makeAdvancedFilter(u,h,i.timeZone);o.set(d,{options:h,filter:m})}),n.forEach((a,d)=>{const{text:h}=a,u=s[d];l.set(d,{text:h,filter:Un.makeQuickFilter(u,h,i.timeZone)})}),this.startLoading("Rebuilding filters...",!0),this.setState({quickFilters:l,advancedFilters:o})}setFilters({quickFilters:e,advancedFilters:t}){this.setState({quickFilters:e,advancedFilters:t})}updateFormatterSettings(e,t=!0){const n=Gn.getColumnFormats(e),s=Gn.getDateTimeFormatterOptions(e),i=e?.defaultDecimalFormatOptions??{},o=e?.defaultIntegerFormatOptions??{},l=e?.truncateNumbersWithPound??!1,a=!Je(this.globalColumnFormats,n),d=!Je(this.dateTimeFormatterOptions,s),h=!Je(this.decimalFormatOptions,e?.defaultDecimalFormatOptions),u=!Je(this.integerFormatOptions,o),m=this.truncateNumbersWithPound!==l;(a||d||h||u||m)&&(this.globalColumnFormats=n,this.dateTimeFormatterOptions=s,this.decimalFormatOptions=i,this.integerFormatOptions=o,this.truncateNumbersWithPound=l,this.updateFormatter({},t),d&&t&&this.rebuildFilters())}getAlwaysFetchColumns=Te((e,t,n,s,i,o)=>{const l=[];for(let d=0;d<s;d+=1)l.push(t[O.getModelIndex(d,n)].name);for(let d=0;d<i;d+=1)l.push(t[O.getModelIndex(t.length-1-d,n)].name);if(o)for(let d=o[0];d<=o[1];d+=1)l.push(t[O.getModelIndex(d,n)].name);const a=new Set([...e,...l]);return Object.freeze([...a])});updateFormatter(e,t=!0){const{customColumnFormatMap:n}=this.state,s={customColumnFormatMap:n,...e},i=[...this.globalColumnFormats??[],...s.customColumnFormatMap.values()],o=new gn(i,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions,this.truncateNumbersWithPound);ce.debug("updateFormatter",this.globalColumnFormats,i),this.setState({...s,formatter:o},()=>{t&&this.grid&&this.grid.forceUpdate()})}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}initState(){const{applyInputFiltersOnInit:e,inputFilters:t,sorts:n,model:s,reverseType:i,customColumns:o,searchValue:l,selectedSearchColumns:a,invertSearchColumns:d}=this.props,h=a??[],u=zo.createSearchFilter(l,h,s.columns,d);if(e){const m=t.filter(g=>g.value!=null);this.applyInputFilters(m)}this.setState({sorts:n,reverseType:i,customColumns:o,isReady:!0,searchFilter:u}),this.initFormatter()}async loadPartitionsTable(e){const{model:t}=this.props;this.setState({isSelectingPartition:!0});try{const n=await this.pending.add(t.valuesTable(e),l=>l.close()),s=n.columns[0],i=s.sort().desc();n.applySort([i]),n.setViewport(0,0,[s]);const o=await this.pending.add(n.getViewportData());if(o.rows.length>0){const a=o.rows[0].get(s);this.updatePartition(a,e),this.setState({isSelectingPartition:!0})}else ce.info("Table does not have any data, just fetching all"),this.setState({isSelectingPartition:!1}),this.handlePartitionFetchAll();this.setState({partitionTable:n,partitionColumn:e},()=>{this.initState()})}catch(n){this.handleTableLoadError(n)}}updatePartition(e,t){const s=[t.filter().eq(I.FilterValue.ofString(e))];this.setState({partition:e,partitionFilters:s})}copyCell(e,t,n=!1){const{canCopy:s}=this.props;if(s){const i=String(this.getValueForCell(e,t,n));co(i).catch(o=>ce.error("Unable to copy cell",o))}else ce.error("Attempted to copyCell for user without copy permission.")}copyRanges(e,t=!1,n=!0,s){const{model:i,canCopy:o}=this.props,{metricCalculator:l,movedColumns:a}=this.state,d=l.getUserColumnWidths();if(o){const h={ranges:J.boundedRanges(e,i.columnCount,i.rowCount),includeHeaders:t,formatValues:n,movedColumns:a,userColumnWidths:d,error:s};this.setState({copyOperation:h})}else ce.error("Attempted copyRanges for user without copy permission.")}startLoading(e,t=!1){this.setState({loadingText:e});const n=this.getTheme();if(t&&this.grid&&(this.grid.clearSelectedRanges(),this.grid.setViewState({top:0},!0)),this.loadingScrimStartTime==null){const{minScrimTransitionTime:s,maxScrimTransitionTime:i}=n;N(s),N(i);const o=this.gridWrapper?.getBoundingClientRect().height??0,l=Math.max(s,Math.min(o/2,i));this.loadingScrimStartTime=Date.now(),this.loadingScrimFinishTime=this.loadingScrimStartTime+l,this.setState({loadingScrimProgress:0}),this.loadingTimer=setTimeout(()=>{this.setState({loadingSpinnerShown:!0})},Un.loadingSpinnerDelay)}}stopLoading(){this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0,this.setState({loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1}),this.loadingTimer!=null&&(clearTimeout(this.loadingTimer),this.loadingTimer=void 0)}rollback(){if(this.lastLoadedConfig){ce.debug("loading last loading config",this.lastLoadedConfig);const{advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:l,selectDistinctColumns:a,sorts:d}=this.lastLoadedConfig;this.lastLoadedConfig=null,this.setState({advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:l,selectDistinctColumns:a,sorts:d})}else ce.debug("remove all sorts, filters, and custom columns"),this.setState({advancedFilters:new Map,aggregationSettings:rc,customColumns:[],quickFilters:new Map,reverseType:F.REVERSE_TYPE.NONE,rollupConfig:void 0,selectDistinctColumns:[],sorts:[]})}canRollback(){return this.lastLoadedConfig!=null||!dc(this.state)}startListening(e){e.addEventListener(ge.EVENT.UPDATED,this.handleUpdate),e.addEventListener(ge.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.addEventListener(ge.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.addEventListener(ge.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}stopListening(e){e.removeEventListener(ge.EVENT.UPDATED,this.handleUpdate),e.removeEventListener(ge.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.removeEventListener(ge.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.removeEventListener(ge.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}focus(){this.grid?.focus()}focusFilterBar(e){const{movedColumns:t}=this.state,{model:n}=this.props,{columnCount:s}=n,i=O.getModelIndex(e,t);if(e==null||e<0||s<=e||!n.isFilterable(i)){this.setState({focusedFilterBarColumn:null});return}const{metricCalculator:o,metrics:l}=this.state;N(l);const{left:a,rightVisible:d,lastLeft:h}=l;if(e<a)this.grid?.setViewState({left:e},!0);else if(d<e){const u=this.grid?.getMetricState();N(u);const m=o.getLastLeft(u,e,o.getVisibleWidth(u));this.grid?.setViewState({left:Math.min(m,h),leftOffset:0},!0)}this.lastFocusedFilterBarColumn=e,this.setState({focusedFilterBarColumn:e,isFilterBarShown:!0})}hideColumnByVisibleIndex(e){const{metricCalculator:t,movedColumns:n}=this.state;t.setColumnWidth(O.getModelIndex(e,n),0),this.grid?.forceUpdate()}freezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;ce.debug2("freezing column",e);const i=t==null?new Set(s.frozenColumns):new Set(t);i.add(e);const o=s.getColumnIndexByName(e);N(o);const l=O.getVisibleIndex(o,n),a=O.moveItem(l,i.size-1,n);this.setState({frozenColumns:[...i],movedColumns:a})}unFreezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;ce.debug2("unfreezing column",e);const i=t==null?new Set(s.frozenColumns):new Set(t);i.delete(e);const o=s.getColumnIndexByName(e);N(o);const l=O.getVisibleIndex(o,n),a=O.moveItem(l,i.size+s.frontColumns.length,n);this.setState({frozenColumns:[...i],movedColumns:a})}handleColumnVisibilityChanged(e,t){const{metricCalculator:n,metrics:s}=this.state;N(s),t?e.forEach(i=>{const o=n.initialColumnWidths.get(i),l=k(s.calculatedColumnWidths,i);o!==l?n.setColumnWidth(i,l):n.resetColumnWidth(i)}):e.forEach(i=>{n.setColumnWidth(i,0)}),this.grid?.forceUpdate()}handleColumnVisibilityReset(){const{metricCalculator:e,metrics:t}=this.state,{model:n}=this.props;N(t);for(let s=0;s<t.columnCount;s+=1)e.resetColumnWidth(s);this.handleMovedColumnsChanged(n.initialMovedColumns),this.handleHeaderGroupsChanged(n.initialColumnHeaderGroups),this.setState({frozenColumns:n.layoutHints?.frozenColumns??[]})}handleCrossColumnSearch(e,t,n){const{model:s}=this.props;this.updateSearchFilter(e,t,s.columns,n),this.setState({searchValue:e,selectedSearchColumns:t,invertSearchColumns:n})}updateSearchFilter=Ge((e,t,n,s)=>{const i=zo.createSearchFilter(e,t,n,s);this.setState({searchFilter:i})},IE);handleAnimationLoop(){this.grid?.updateCanvas(),this.isAnimating&&(this.animationFrame=requestAnimationFrame(this.handleAnimationLoop))}handleAnimationStart(){ce.debug2("handleAnimationStart"),this.isAnimating=!0,this.animationFrame=requestAnimationFrame(this.handleAnimationLoop)}handleAnimationEnd(){ce.debug2("handleAnimationEnd"),this.isAnimating=!1}handlePartitionAppend(e){const{onPartitionAppend:t}=this.props,{partitionColumn:n}=this.state;n!=null&&t(n,e)}handlePartitionChange(e){const{partitionColumn:t}=this.state;t!=null&&this.updatePartition(e,t)}handlePartitionFetchAll(){this.setState({partitionFilters:[],isSelectingPartition:!1})}handlePartitionDone(){this.setState({isSelectingPartition:!1})}handleTableLoadError(e){if(ve.isCanceled(e))return;ce.error(e);const{onError:t}=this.props;t(e)}showAllColumns(){const{metricCalculator:e}=this.state,n=[...e.getUserColumnWidths().entries()];for(let s=0;s<n.length;s+=1){const[i,o]=n[s];o===0&&e.resetColumnWidth(i)}this.grid?.forceUpdate()}toggleSort(e,t){ce.info("Toggling sort for column",e);const{model:n}=this.props,{sorts:s}=this.state,i=this.getModelColumn(e);N(i);const o=F.toggleSortForColumn(s,n.columns,i,t);this.updateSorts(o)}updateSorts(e){this.startLoading("Sorting..."),this.setState({sorts:e}),this.grid?.forceUpdate()}sortColumn(e,t=F.sortDirection.none,n=!1,s=!1){N(e);const{model:i}=this.props,o=F.sortColumn(i.sort,i.columns,e,t,n,s);this.startLoading("Sorting..."),this.setState({sorts:o}),this.grid?.forceUpdate()}reverse(e){this.startLoading("Reversing..."),this.setState({reverseType:e}),this.grid?.forceUpdate()}isReversible(){const{model:e}=this.props;return e.isReversible}toggleFilterBar(e=this.lastFocusedFilterBarColumn){let{isFilterBarShown:t}=this.state;if(t=!t,this.setState({isFilterBarShown:t}),t)if(e!=null)this.focusFilterBar(e);else{let n=0;const{model:s}=this.props,{columnCount:i}=s;for(let o=0;o<i;o+=1){const l=this.getModelColumn(o);if(l!=null){const a=s.columns[l];if(a!=null&&F.isTextType(a.type)){n=o;break}}}this.focusFilterBar(n)}else this.grid?.focus()}isTableSearchAvailable(){const{model:e,canToggleSearch:t}=this.props,n=e?.layoutHints?.searchDisplayMode;return n===I.SearchDisplayMode?.SEARCH_DISPLAY_HIDE?!1:n===I.SearchDisplayMode?.SEARCH_DISPLAY_SHOW?!0:t}toggleSearchBar(){const{showSearchBar:e}=this.state;if(!this.isTableSearchAvailable())return;const t=!e;this.setState({showSearchBar:t},()=>{t&&this.crossColumnRef?.current?this.crossColumnRef?.current.focus():this.grid?.focus()})}toggleGotoRow(e="",t="",n=""){const{isGotoShown:s}=this.state;if(e||t){this.setState({isGotoShown:!0,gotoRow:e,gotoValue:t,gotoValueSelectedColumnName:n,gotoRowError:"",gotoValueError:""}),this.focusRowInGrid(e);return}const i=this.grid?.state.cursorRow,o=this.grid?.state.cursorColumn;if(i==null||o==null){this.setState({isGotoShown:!s,gotoRow:"",gotoValue:"",gotoRowError:"",gotoValueError:""});return}const{model:l}=this.props,{name:a,type:d}=l.columns[o],h=l.valueForCell(o,i),u=Ce.convertValueToText(h,d);this.setState({isGotoShown:!s,gotoRow:`${i}`,gotoValue:u,gotoValueSelectedColumnName:a,gotoRowError:"",gotoValueError:""})}async commitPending(){const{model:e}=this.props;if(!Ke(e)||!e.isEditable)throw new Error("Cannot save, table is not editable");const{pendingSavePromise:t}=this.state;if(t!=null)throw new Error("Save already in progress");const n=document?.activeElement?.classList.contains("grid-cell-input-field");if(n!=null&&n){if(document.activeElement!=null&&document.activeElement.classList.contains("error"))throw new wi("Current input is invalid");this.grid?.focus()}const s=this.pending.add(e.commitPending()).then(()=>{this.setState({pendingSaveError:null,pendingSavePromise:null})}).catch(i=>{ve.isCanceled(i)||this.setState({pendingSaveError:i,pendingSavePromise:null})});return this.setState({pendingSavePromise:s}),s}async discardPending(){const{pendingSavePromise:e}=this.state;if(e!=null)throw new Error("Cannot cancel a save in progress");this.setState({pendingSavePromise:null,pendingSaveError:null,pendingDataMap:new Map,pendingDataErrors:new Map})}selectColumn(e){const{onColumnSelected:t}=this.props;t(e)}selectData(e,t){const{model:n}=this.props,{columns:s,groupedColumns:i}=n,o={};for(let a=0;a<s.length;a+=1){const d=s[a],{name:h,type:u}=d,m=n.valueForCell(a,t),g=n.textForCell(a,t),p=this.getVisibleColumn(a),C=He(n)&&n.isRowExpandable(t),f=i.find(S=>S.name===h)!=null;o[h]={value:m,text:g,type:u,isGrouped:f,isExpandable:C,visibleIndex:p}}const{onDataSelected:l}=this.props;l(t,o)}handleAdvancedFilterChange(e,t,n){const{model:s}=this.props,i=s.getColumnIndexByName(e.name);N(i),this.setAdvancedFilter(i,t,n)}handleAdvancedFilterSortChange(e,t,n=!1){const{model:s}=this.props,i=s.getColumnIndexByName(e.name);N(i);const o=s.columns[i].name,l=F.getSortForColumn(s.sort,o);let a=null;(l==null||l.direction!==t)&&(t===F.sortDirection.descending?a=e.sort().desc():a=e.sort().asc());const d=F.setSortForColumn(s.sort,o,a,n);ce.info("Setting table sorts",d),this.startLoading("Sorting..."),this.setState({sorts:d}),this.grid?.forceUpdate()}handleAdvancedFilterDone(){this.grid?.focus()}handleAdvancedMenuOpened(e){this.setState({shownAdvancedFilter:e})}handleGotoRowOpened(){this.setState({isGotoShown:!0})}handleGotoRowClosed(){this.setState({isGotoShown:!1})}handleAdvancedMenuClosed(e){const{focusedFilterBarColumn:t,isFilterBarShown:n}=this.state;n&&t===e&&this.filterInputRef?.current!==null?(this.filterInputRef?.current.focus(),this.setState({shownAdvancedFilter:null})):this.setState({focusedFilterBarColumn:null,shownAdvancedFilter:null})}handleCancel(){this.rollback()}handleChartChange(){}handleChartCreate(e){const{model:t,onCreateChart:n}=this.props;n(e,t)}handleGridError(e){ce.warn("Grid Error",e),this.setState({toastMessage:r.jsx("div",{className:"error-message",children:`${e}`})})}handleFilterBarChange(e){this.startLoading("Filtering...",!0),this.setState(({focusedFilterBarColumn:t,quickFilters:n})=>{const s=new Map(n);if(t!=null){const i=this.getModelColumn(t);N(i),this.applyQuickFilter(i,e,s)}return{quickFilters:s}})}handleFilterBarDone(e=!0,t=!0){e&&this.grid?.focus(),t&&this.setState({focusedFilterBarColumn:null})}handleFilterBarTab(e){const{focusedFilterBarColumn:t}=this.state;N(t),e?this.focusFilterBar(t-1):this.focusFilterBar(t+1)}handleFormatSelection(e,t){const{model:n}=this.props,s=n.columns[e],{customColumnFormatMap:i}=this.state,o=new Map(i);if(t!=null){const l=F.getNormalizedType(s.type);N(l);const a=gn.makeColumnFormattingRule(l,s.name,t);o.set(s.name,a)}else o.delete(s.name);this.updateFormatter({customColumnFormatMap:o})}handleMenu(e){e.stopPropagation(),this.setState({isMenuShown:!0})}handleMenuClose(){this.setState({isMenuShown:!1,openOptions:[]})}handleMenuBack(){this.setState(({openOptions:e})=>{const t=[...e];return t.pop(),{openOptions:t}})}handleMenuSelect(e){this.setState(({openOptions:t})=>({openOptions:[...t,e]}))}handleRequestFailed(e){const t=e;if(ce.error("request failed:",t.detail),this.stopLoading(),this.canRollback())this.startLoading("Rolling back changes...",!0),this.rollback();else{ce.error("Table failed and unable to rollback");const{onError:n}=this.props;n(new Error(`Error displaying table: ${t.detail}`))}}handleUpdate(){this.stopLoading(),ce.debug2("Received model update");const{advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:l,selectDistinctColumns:a,sorts:d}=this.state,h={advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:l,selectDistinctColumns:a,sorts:d};dc(h)?this.lastLoadedConfig=null:this.lastLoadedConfig=h,this.grid?.forceUpdate()}handleViewChanged(e){const{model:t}=this.props,{selectionEndRow:n=0}=this.grid?.state??{};let s=0;if(Ke(t)&&t.isEditable){N(e);const{bottomViewport:i}=e,o=t.rowCount-t.floatingBottomRowCount;n===o-1?s=t.pendingRowCount+1:n===o-2?s=t.pendingRowCount:s=Math.max(0,i-(t.rowCount-t.pendingRowCount)-t.floatingTopRowCount-t.floatingBottomRowCount-1)}this.setState({metrics:e,pendingRowCount:s})}handleSelectionChanged(e){N(e);const{onSelectionChanged:t}=this.props,{copyOperation:n}=this.state;this.setState({selectedRanges:e}),n!=null&&this.setState({copyOperation:null}),t(e)}handleMovedColumnsChanged(e,t){this.setState({movedColumns:e},t)}handleHeaderGroupsChanged(e){const{model:t}=this.props;this.setState({columnHeaderGroups:Ce.parseColumnHeaderGroups(t,e).groups},()=>this.grid?.forceUpdate())}handleTooltipRef(e){e?.startTimer(),this.tooltip=e}handleConditionalFormatsChange(e){ce.debug("Updated conditional formats",e),this.setState({conditionalFormats:e})}handleConditionalFormatCreate(){ce.debug("Create new conditional format");const{openOptions:e,conditionalFormats:t}=this.state;this.setState({openOptions:[...e,{type:De.CONDITIONAL_FORMATTING_EDIT,title:"Create Formatting Rule"}],conditionalFormatEditIndex:t.length,conditionalFormatPreview:void 0})}handleConditionalFormatEdit(e){ce.debug("Edit conditional format",e);const{openOptions:t,conditionalFormats:n}=this.state;this.setState({openOptions:[...t,{type:De.CONDITIONAL_FORMATTING_EDIT,title:"Edit Formatting Rule"}],conditionalFormatEditIndex:e,conditionalFormatPreview:{...n[e]}})}handleConditionalFormatEditorUpdate=Ge(e=>{this.setState({conditionalFormatPreview:e})},FE);handleConditionalFormatEditorSave(e){ce.debug("Save conditional format changes",e),this.setState(t=>{if(t.conditionalFormatEditIndex===null)return ce.debug("Invalid format index"),null;const n=[...t.conditionalFormats];return n[t.conditionalFormatEditIndex]=e,{conditionalFormats:n}},()=>{this.handleMenuBack()})}handleConditionalFormatEditorCancel(){this.handleMenuBack(),this.setState({conditionalFormatEditIndex:null})}handleUpdateCustomColumns(e){ce.info("handleUpdateCustomColumns:",e);const{model:t}=this.props,{movedColumns:n,sorts:s,quickFilters:i,advancedFilters:o,selectDistinctColumns:l}=this.state,{columns:a}=t,d=t.customColumns.map(u=>`${u}`),h=Ce.getRemovedCustomColumnNames(d,e);if(h.length>0){const u=Ce.removeSortsInColumns(s,h),m=Ce.removeFiltersInColumns(a,i,h),g=Ce.removeFiltersInColumns(a,o,h),p=Ce.removeColumnFromMovedColumns(a,n,h),C=Ce.removeColumnsFromSelectDistinctColumns(l,h);u.length!==s.length&&(ce.debug("removing sorts from removed custom columns..."),this.setState({sorts:u})),(m.size!==i.size||g.size!==o.size)&&(ce.debug("removing filters from removed custom columns..."),this.setState({quickFilters:m,advancedFilters:g})),Je(n,p)||(ce.debug("change moved columns for removed custom columns",p),this.setState({movedColumns:p})),Je(l,C)||(ce.debug("change selectDistinct columns for removed custom columns",p),this.setState({selectDistinctColumns:C}))}this.setState({customColumns:e}),e.length>0&&this.startLoading("Applying custom columns...")}handleCustomColumnsChanged(){ce.debug("custom columns changed");const{isReady:e}=this.state;e?(this.stopLoading(),this.grid?.forceUpdate()):this.initState()}handlePendingCommitClicked(){return this.commitPending()}handlePendingDiscardClicked(){return this.discardPending()}handlePendingDataUpdated(){ce.debug("pending data updated");const{model:e}=this.props,{pendingDataMap:t,pendingDataErrors:n}=e;this.setState({pendingDataMap:t,pendingDataErrors:n,pendingSaveError:null}),this.grid?.forceUpdate()}handleAggregationsChange(e){ce.debug("handleAggregationsChange",e),this.startLoading(`Aggregating ${e.aggregations.map(t=>t.operation).join(", ")}...`),this.setState({aggregationSettings:e})}handleAggregationChange(e){ce.debug("handleAggregationChange",e),this.startLoading(`Aggregating ${e.operation}...`),this.setState(({aggregationSettings:t})=>({selectedAggregation:e,aggregationSettings:{...t,aggregations:t.aggregations.map(n=>n.operation===e.operation?e:n)}}))}handleAggregationEdit(e){ce.debug("handleAggregationEdit",e);const{openOptions:t}=this.state;this.setState({openOptions:[...t,{type:De.AGGREGATION_EDIT,title:`Edit Columns to ${e.operation}`}],selectedAggregation:e})}handleRollupChange(e){ce.info("Rollup change",e),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Grouping by columns ${e?.columns?.join(", ")??""}...`),this.setState({rollupConfig:e,movedColumns:[],frozenColumns:[],sorts:[],reverseType:F.REVERSE_TYPE.NONE,selectDistinctColumns:[]})}handleSelectDistinctChanged(e){ce.debug("SelectDistinct change",e),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Selecting distinct values in ${e.length>0?e.join(", "):""}...`),this.setState({selectDistinctColumns:e,movedColumns:[],sorts:[],reverseType:F.REVERSE_TYPE.NONE})}handleDownloadTableStart(){const{canDownloadCsv:e}=this.props;e?this.setState({isTableDownloading:!0,tableDownloadProgress:0,tableDownloadEstimatedTime:null,tableDownloadStatus:Os.DOWNLOAD_STATUS.INITIATING}):ce.error("Attempted to handleDownloadTableStart for user without download CSV permission.")}handleDownloadTable(e,t,n,s,i,o,l){const{canDownloadCsv:a}=this.props;a?(ce.info("start table downloading",e,t,n,s,i,o,l),this.setState(()=>(this.tableSaver&&this.tableSaver.startDownload(e,t,n,s,i,o,l),{tableDownloadStatus:Os.DOWNLOAD_STATUS.DOWNLOADING}))):ce.error("Attempted to handleDownloadTable for user without download CSV permission.")}async seekRow(e,t=!1){const{gotoValueSelectedColumnName:n,gotoValueSelectedFilter:s}=this.state,{model:i}=this.props;if(!i.isSeekRowAvailable||e==="")return;const o=Ce.getColumnByName(i.columns,n);if(o===void 0)return;let l=this.grid?.state.cursorRow;l==null&&(l=0);const a=s===pe.contains,d=s===pe.eq||s===pe.eqIgnoreCase;try{const{formatter:h}=i,u=F.getNormalizedType(o.type);let m;switch(u){case F.dataType.CHAR:case F.dataType.STRING:{m=await i.seekRow(l,o,I.ValueType.STRING,e,d,a,t??!1);break}case F.dataType.DATETIME:{const[g]=Zs.parseDateRange(e,h.timeZone);m=await i.seekRow(l,o,I.ValueType.DATETIME,g,void 0,void 0,t??!1);break}case F.dataType.DECIMAL:case F.dataType.INT:{if(!F.isBigDecimalType(o.type)&&!F.isBigIntegerType(o.type)){let g=parseInt(e,10);e==="-Infinity"?g=Number.NEGATIVE_INFINITY:e==="Infinity"&&(g=Number.POSITIVE_INFINITY),m=await i.seekRow(l,o,I.ValueType.NUMBER,g,void 0,void 0,t??!1)}else m=await i.seekRow(l,o,I.ValueType.STRING,e,void 0,void 0,t??!1);break}default:m=await i.seekRow(l,o,I.ValueType.STRING,F.makeValue(o.type,e,h.timeZone),void 0,void 0,t??!1)}this.grid?.setFocusRow(m),this.setState({gotoValueError:""})}catch{this.setState({gotoValueError:"invalid input"})}}handleCancelDownloadTable(){this.tableSaver?.cancelDownload(),this.setState({isTableDownloading:!1})}handleDownloadProgressUpdate=Ts((e,t)=>{const{tableDownloadStatus:n}=this.state;n===Os.DOWNLOAD_STATUS.DOWNLOADING&&this.setState({tableDownloadProgress:e,tableDownloadEstimatedTime:t})},xE);handleDownloadCompleted(){this.setState({isTableDownloading:!1,tableDownloadProgress:100,tableDownloadStatus:Os.DOWNLOAD_STATUS.FINISHED})}handleDownloadCanceled(){this.setState({isTableDownloading:!1,tableDownloadProgress:0,tableDownloadStatus:Os.DOWNLOAD_STATUS.CANCELED})}deleteRanges(e){const{model:t}=this.props;this.pending.add(t.delete(e)).catch(n=>{ve.isCanceled(n)||ce.error("Unable to delete ranges",e,n)})}resetColumnSelection(){if(this.grid==null)return;const{isSelectingColumn:e}=this.props;if(e){const{columnAllowedCursor:t}=this.props;this.grid.setState({cursor:t})}else this.grid.setState({cursor:null}),this.setState({hoverSelectColumn:null})}resetGridViewState(e=!0){this.grid&&(this.grid.clearSelectedRanges(),this.grid.setViewState({left:0,top:0,topOffset:0,leftOffset:0},e))}sendStateChange(){if(!this.grid)return;const{state:e}=this,{state:t}=this.grid,{onStateChange:n}=this.props;n(e,t)}handleOverflowClose(){this.setState({showOverflowModal:!1})}getColumnBoundingRect(){const{metrics:e,shownColumnTooltip:t}=this.state;N(e),N(t);const n=this.gridWrapper?.getBoundingClientRect(),s=20;N(n);const{columnHeaderHeight:i,allColumnXs:o,allColumnWidths:l,width:a,columnHeaderMaxDepth:d}=e,h=o.get(t),u=l.get(t);N(h),N(u);const m=n.left+Ae(h+u/2,s,a-s);return{top:n.top+(d-1)*i,left:n.left+Ae(h+u/2,s,a-s),bottom:n.top+d*i,right:n.left+Ae(h+u/2,s,a-s)+1,width:1,height:i,x:m,y:n.top,toJSON:()=>{throw new Error("not implemented")}}}getOverflowButtonTooltip=Te(e=>{if(e==null)return null;const t={position:"absolute",...e,pointerEvents:"none"},n={placement:"left",modifiers:{flip:{behavior:["left","right"]}}};return r.jsx("div",{style:t,children:r.jsx(tt,{options:n,ref:this.handleTooltipRef,children:"View full contents"},Date.now())})});getExpandCellTooltip=Te(e=>{if(e==null)return null;const{expandTooltipDisplayValue:t}=this.state,n={position:"absolute",...e,pointerEvents:"none"},s={placement:"bottom-start"};return r.jsx("div",{style:n,children:r.jsx(tt,{options:s,ref:this.handleTooltipRef,children:r.jsxs("div",{style:{textAlign:"left"},children:["Click to ",t," row",r.jsx("br",{}),Es.isMacPlatform()?"⌘":"Ctrl+","Click to expand row and all children"]})},Date.now())})});getLinkHoverTooltip=Te(e=>{if(e==null)return null;const{linkHoverDisplayValue:t}=this.state,n={position:"absolute",...e,pointerEvents:"none"},s={placement:"bottom"};return r.jsx("div",{style:n,children:r.jsx(tt,{options:s,ref:this.handleTooltipRef,children:r.jsxs("div",{className:"link-hover-tooltip",children:[t," - Click once to follow.",r.jsx("br",{}),"Click and hold to select this cell."]})})})});handleGotoRowSelectedRowNumberSubmit(){const{gotoRow:e}=this.state;this.focusRowInGrid(e)}focusRowInGrid(e){const{model:t}=this.props,{rowCount:n}=t;if(this.setState({gotoRow:e}),e===""){this.setState({gotoRowError:"",gotoValueError:""});return}const s=parseInt(e,10);s>n||s<-n?this.setState({gotoRowError:"Invalid row index"}):s===0?(this.setState({gotoRowError:"",gotoValueError:""}),this.grid?.setFocusRow(0)):s<0?(this.setState({gotoRowError:"",gotoValueError:""}),this.grid?.setFocusRow(s+n)):(this.grid?.setFocusRow(s-1),this.setState({gotoRowError:"",gotoValueError:""}))}handleGotoRowSelectedRowNumberChanged(e){const t=e.target.value;this.focusRowInGrid(t)}getColumnTooltip(e,t,n){const{columnHeaderHeight:s,columnHeaderMaxDepth:i,allColumnXs:o,allColumnWidths:l,width:a}=t,d=o.get(e),h=l.get(e);if(d==null||h==null)return null;const u=Math.max(0,d);let m=h;d+h>a?m=a-d:d<0&&(m=h-Math.abs(d));const g={position:"absolute",top:(i-1)*s,left:u,width:m,height:s,pointerEvents:"none"},p={clientWidth:1,clientHeight:s,getBoundingClientRect:this.getColumnBoundingRect},C={placement:"bottom",modifiers:{flip:{behavior:["bottom","top"]}}},f=this.getModelColumn(e);if(f==null)return null;const S=n.columns[f];return S==null?null:r.jsx("div",{style:g,children:r.jsx(tt,{timeout:400,interactive:!0,options:C,ref:this.handleTooltipRef,referenceObject:p,onExited:()=>{this.setState({shownColumnTooltip:null})},children:r.jsx(jv,{model:n,column:S,onStatistics:()=>{this.tooltip?.update()}})},S.name)})}handleGotoValueSelectedColumnNameChanged(e){const{model:t}=this.props,n=this.grid?.state.cursorRow;if(n!=null){const s=t.getColumnIndexByName(e),i=Ce.getColumnByName(t.columns,e);if(s==null||i==null)return;const o=t.valueForCell(s,n),l=Ce.convertValueToText(o,i.type);this.setState({gotoValueSelectedColumnName:e,gotoValue:l,gotoValueError:""})}this.setState({gotoValueSelectedColumnName:e,gotoValueError:""})}handleGotoValueSelectedFilterChanged(e){this.setState({gotoValueSelectedFilter:e,gotoValueError:""})}handleGotoValueChanged=e=>{this.setState({gotoValue:e}),this.debouncedSeekRow(e)};debouncedSeekRow=Ge(e=>{this.seekRow(e)},DE);handleGotoValueSubmitted(e){const{gotoValue:t}=this.state;this.seekRow(t,e)}render(){const{children:e,customFilters:t,getDownloadWorker:n,isSelectingColumn:s,isStuckToBottom:i,isStuckToRight:o,model:l,name:a,onlyFetchVisibleColumns:d,alwaysFetchColumns:h,advancedSettings:u,onAdvancedSettingsChange:m,canDownloadCsv:g,onCreateChart:p}=this.props,{metricCalculator:C,metrics:f,isFilterBarShown:S,isSelectingPartition:v,isMenuShown:b,isReady:T,copyOperation:y,focusedFilterBarColumn:E,loadingText:R,loadingScrimProgress:x,loadingSpinnerShown:D,keyHandlers:L,mouseHandlers:M,shownColumnTooltip:j,hoverAdvancedFilter:A,shownAdvancedFilter:W,hoverSelectColumn:H,quickFilters:U,advancedFilters:P,partition:Q,partitionFilters:G,partitionTable:ne,partitionColumn:V,searchFilter:z,selectDistinctColumns:Z,movedColumns:oe,movedRows:re,formatter:q,conditionalFormats:ie,conditionalFormatPreview:fe,conditionalFormatEditIndex:Re,sorts:xe,reverseType:vt,customColumns:Tt,selectedRanges:Gt,isTableDownloading:fn,tableDownloadStatus:Dt,tableDownloadProgress:ye,tableDownloadEstimatedTime:dt,showSearchBar:nt,searchValue:ft,selectedSearchColumns:Ft,invertSearchColumns:Cn,aggregationSettings:zt,selectedAggregation:So,rollupConfig:xs,openOptions:Kt,pendingSavePromise:Qn,pendingSaveError:ti,pendingRowCount:Ni,pendingDataErrors:ni,pendingDataMap:si,toastMessage:bo,frozenColumns:wo,columnHeaderGroups:Jn,showOverflowModal:Is,overflowText:ia,overflowButtonTooltipProps:vo,expandCellTooltipProps:ki,linkHoverTooltipProps:Mi,isGotoShown:Li,gotoRow:To,gotoRowError:oa,gotoValueError:la,gotoValueSelectedColumnName:aa,gotoValue:ra,gotoValueSelectedFilter:da}=this.state;if(!T)return null;const Ds=this.getTheme(),Eo=this.getCachedFilter(t,U,P,G,z),ii=C.getUserColumnWidths(),yo=this.getCachedStateOverride(H,S,s,x,U,P,xe,vt,xs,b),Fs=f?f.top:0,Ro=f?f.bottomViewport:0;let Oi=null,Ai=null;d&&(Oi=f?f.left:0,Ai=f?f.right:0);const xo=f!=null&&f.width>0&&f.height>0,Io=(xs?.columns?.length??0)>0;let Do=null;const ca=f?Math.min(Math.max(Un.minDebounce,Math.round(f.rowCount/200)),Un.maxDebounce):Un.maxDebounce;if(S&&E!=null&&f!=null){const{gridX:Be,gridY:Me,allColumnXs:Yt,allColumnWidths:_i,width:oi}=f,es=Yt.get(E),Nt=_i.get(E);if(es!=null&&Nt!=null){const Et=Be+es,Mn=Me-(Ds.filterBarHeight??0),Ns=Nt+1,ks=(Ds.filterBarHeight??0)-1,Ao={top:Mn,left:Et,minWidth:Math.min(Ns,oi-Et),height:ks};let Sn="",Ms=!0;const Ls=this.getModelColumn(E);N(Ls);const li=U.get(Ls),ts=P.get(Ls);li!=null&&(Sn=li.text,Ms=li.filter!=null);const ai=U.size!==0||P.size!==0;Do=r.jsx(Gw,{ref:this.filterInputRef,style:Ao,className:K({error:!Ms,active:Sn!==""||ts!=null,"iris-grid-has-filter":ai}),isAdvancedFilterSet:ts!=null,onAdvancedFiltersTriggered:()=>{this.setState({shownAdvancedFilter:E})},onChange:this.handleFilterBarChange,onDone:this.handleFilterBarDone,onTab:this.handleFilterBarTab,onContextMenu:this.grid?.handleContextMenu,debounceMs:ca,value:Sn},E)}}let Fo=null;if(R!=null){const Be=r.jsxs("div",{className:"iris-grid-loading-status",children:[r.jsx("div",{className:K("iris-grid-loading-status-bar",{show:D}),children:R}),r.jsxs("button",{type:"button",onClick:this.handleCancel,className:K("iris-grid-btn-cancel",{show:D}),children:[r.jsx(X,{icon:ho,transform:"down-1"}),"Cancel"]})]}),Me=f?f.gridY:0;Fo=r.jsx("div",{className:"iris-grid-loading",style:{top:Me},children:Be})}let No=null;j!=null&&f&&(No=this.getColumnTooltip(j,f,l),this.tooltip?.update());const ko=[];if(f&&S){const{gridX:Be,gridY:Me,visibleColumns:Yt,allColumnXs:_i,allColumnWidths:oi}=f,{filterBarHeight:es}=Ds;for(let Nt=0;Nt<Yt.length;Nt+=1){const Et=Yt[Nt],Mn=_i.get(Et),Ns=oi.get(Et),ks=this.getModelColumn(Et);if(ks!=null&&l.isFilterable(ks)&&Mn!=null&&Ns!=null&&Ns>0){const Sn=Be+Mn+Ns-24,Ls={position:"absolute",top:Me-(es??0)+2,left:Sn},ts=P.get(ks)!=null,ai=Et===A||Et===E||ts,ua=r.jsx("div",{className:K("advanced-filter-button-container",{hidden:!ai}),style:Ls,children:ai&&r.jsx(_,{kind:"ghost",className:K("btn-link-icon advanced-filter-button",{"filter-set":ts}),onClick:()=>{this.setState({shownAdvancedFilter:Et})},onContextMenu:Ku=>{this.grid?.handleContextMenu(Ku)},onMouseEnter:()=>{this.setState({hoverAdvancedFilter:Et})},onMouseLeave:()=>{this.setState({hoverAdvancedFilter:null})},children:r.jsxs("div",{className:"fa-layers",children:[r.jsx(X,{icon:ar,className:"filter-solid"}),r.jsx(X,{icon:rl,className:"filter-light"})]})})},Et);ko.push(ua)}}}const Mo=[];if(f){const{gridX:Be,visibleColumns:Me,allColumnXs:Yt,allColumnWidths:_i,columnHeaderHeight:oi}=f;for(let es=0;es<Me.length;es+=1){const Nt=Me[es],Et=Yt.get(Nt),Mn=_i.get(Nt);if(Et!=null&&Mn!=null&&Mn>0){const Ns=Be+Et,ks=Be+Et+Mn-20,Ao=S?{position:"absolute",top:oi,left:ks,width:20,height:Ds.filterBarHeight}:{position:"absolute",top:0,left:Ns,width:Mn,height:oi},Sn=this.getModelColumn(Nt);if(Sn!=null){const Ms=l.columns[Sn];if(Ms==null){ce.warn(`Column does not exist at index ${Sn} for column array of length ${l.columns.length}`);continue}const Ls=P.get(Sn),{options:li}=Ls||{},ts=F.getSortForColumn(l.sort,Ms.name),ai=ts?ts.direction:null,ua=r.jsx("div",{className:"advanced-filter-menu-container",style:Ao,children:r.jsx(Ul,{className:"advanced-filter-menu-popper",onEntered:this.getAdvancedMenuOpenedHandler(Nt),onExited:()=>{this.handleAdvancedMenuClosed(Nt)},isShown:W===Nt,interactive:!0,closeOnBlur:!0,options:{positionFixed:!0},children:this.getCachedAdvancedFilterMenuActions(l,Ms,li,ai,q)})},Nt);Mo.push(ua)}}}}const Lo=this.getCachedOptionItems(p!==void 0&&l.isChartBuilderAvailable,l.isCustomColumnsAvailable,l.isFormatColumnsAvailable,l.isRollupAvailable,l.isTotalsAvailable||Io,l.isSelectDistinctAvailable,l.isExportAvailable,this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,S,nt,g,this.isTableSearchAvailable(),Li,u.size>0),Oo=this.getCachedHiddenColumns(C,ii),ha=Kt.map(Be=>{switch(Be.type){case De.CHART_BUILDER:return r.jsx(Jv,{model:l,onChange:this.handleChartChange,onSubmit:this.handleChartCreate},De.CHART_BUILDER);case De.VISIBILITY_ORDERING_BUILDER:return r.jsx(_T,{model:l,movedColumns:oe,hiddenColumns:Oo,columnHeaderGroups:Jn,onColumnVisibilityChanged:this.handleColumnVisibilityChanged,onReset:this.handleColumnVisibilityReset,onMovedColumnsChanged:this.handleMovedColumnsChanged,onColumnHeaderGroupChanged:this.handleHeaderGroupsChanged},De.VISIBILITY_ORDERING_BUILDER);case De.CONDITIONAL_FORMATTING:return r.jsx(YT,{rules:ie,onChange:this.handleConditionalFormatsChange,onCreate:this.handleConditionalFormatCreate,onSelect:this.handleConditionalFormatEdit});case De.CONDITIONAL_FORMATTING_EDIT:return N(l.columns),N(this.handleConditionalFormatEditorUpdate),r.jsx(vE,{columns:l.columns,rule:fe,onUpdate:this.handleConditionalFormatEditorUpdate,onSave:this.handleConditionalFormatEditorSave,onCancel:this.handleConditionalFormatEditorCancel});case De.CUSTOM_COLUMN_BUILDER:return r.jsx(iT,{model:l,customColumns:Tt,onSave:this.handleUpdateCustomColumns,onCancel:this.handleMenuBack},De.CUSTOM_COLUMN_BUILDER);case De.ROLLUP_ROWS:return r.jsx(lT,{model:l,onChange:this.handleRollupChange,config:xs},De.ROLLUP_ROWS);case De.AGGREGATIONS:return r.jsx($v,{settings:zt,isRollup:Io,onChange:this.handleAggregationsChange,onEdit:this.handleAggregationEdit});case De.AGGREGATION_EDIT:return So&&r.jsx(Gv,{aggregation:So,columns:l.originalColumns,onChange:this.handleAggregationChange});case De.TABLE_EXPORTER:return r.jsx(Os,{model:l,name:a,userColumnWidths:ii,movedColumns:oe,isDownloading:fn,tableDownloadStatus:Dt,tableDownloadProgress:ye,tableDownloadEstimatedTime:dt??void 0,onDownload:this.handleDownloadTable,onDownloadStart:this.handleDownloadTableStart,onCancel:this.handleCancelDownloadTable,selectedRanges:Gt},De.TABLE_EXPORTER);case De.SELECT_DISTINCT:return r.jsx(GT,{model:l,selectDistinctColumns:Z,onChange:this.handleSelectDistinctChanged});case De.ADVANCED_SETTINGS:return r.jsx(Ur,{items:u,onChange:m});default:throw Error(`Unexpected option type ${Be.type}`)}});return r.jsxs("div",{className:"iris-grid",role:"presentation",children:[r.jsxs("div",{className:"iris-grid-column",children:[e!=null&&r.jsx("div",{className:"iris-grid-bar",children:e}),r.jsx($t,{in:v,timeout:Xe.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:r.jsx("div",{className:"iris-grid-partition-selector-wrapper iris-grid-bar iris-grid-bar-primary",children:ne&&V&&Q!=null&&r.jsx(BT,{table:ne,getFormattedString:(Be,Me,Yt)=>l.displayString(Be,Me,Yt),columnName:V.name,partition:Q,onChange:this.handlePartitionChange,onFetchAll:this.handlePartitionFetchAll,onAppend:this.handlePartitionAppend,onDone:this.handlePartitionDone})})}),r.jsx($t,{in:nt,timeout:Xe.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:r.jsx("div",{className:"iris-grid-bar",children:r.jsx(zo,{value:ft,selectedColumns:Ft,invertSelection:Cn,onChange:this.handleCrossColumnSearch,columns:l.columns,ref:this.crossColumnRef})})}),r.jsxs("div",{className:"grid-wrapper",ref:Be=>{this.gridWrapper=Be},children:[r.jsx(tw,{ref:Be=>{this.grid=Be},isStickyBottom:!Ke(l)||!l.isEditable,isStuckToBottom:i,isStuckToRight:o,metricCalculator:C,model:l,keyHandlers:L,mouseHandlers:M,movedColumns:oe,movedRows:re,onError:this.handleGridError,onViewChanged:this.handleViewChanged,onSelectionChanged:this.handleSelectionChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged,renderer:this.renderer,stateOverride:yo,theme:Ds}),r.jsx(TE,{isOpen:Is,text:ia,onClose:this.handleOverflowClose}),xo&&r.jsx(kv,{model:l,modelColumns:l.columns,top:Fs,bottom:Ro,left:Oi,right:Ai,filter:Eo,formatter:q,sorts:xe,reverseType:vt,movedColumns:oe,customColumns:Tt,hiddenColumns:Oo,alwaysFetchColumns:this.getAlwaysFetchColumns(h,l.columns,oe,l.floatingLeftColumnCount,l.floatingRightColumnCount,this.grid?.state.draggingColumn?.range),formatColumns:this.getCachedPreviewFormatColumns(l.columns,ie,fe,Kt[Kt.length-1]?.type===De.CONDITIONAL_FORMATTING_EDIT?Re??void 0:void 0),rollupConfig:this.getModelRollupConfig(l.originalColumns,xs,zt),totalsConfig:this.getModelTotalsConfig(l.columns,xs,zt),selectDistinctColumns:Z,pendingRowCount:Ni,pendingDataMap:si,frozenColumns:wo,columnHeaderGroups:Jn}),!b&&r.jsx("div",{className:"grid-settings-button",children:r.jsx(_,{kind:"ghost","data-testid":`btn-iris-grid-settings-button-${a}`,onClick:this.handleMenu,icon:r.jsx(X,{icon:kg,transform:"up-1"}),tooltip:"Table Options"})}),Do,Fo,ko,No,Mo,vo&&this.getOverflowButtonTooltip(vo),ki&&this.getExpandCellTooltip(ki),Mi&&this.getLinkHoverTooltip(Mi)]}),r.jsx(RE,{model:l,isShown:Li,gotoRow:To,gotoRowError:oa,gotoValueError:la,onGotoRowSubmit:this.handleGotoRowSelectedRowNumberSubmit,onGotoRowNumberChanged:this.handleGotoRowSelectedRowNumberChanged,onClose:this.handleGotoRowClosed,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:()=>{this.handleAnimationStart(),this.focus()},onExited:this.handleAnimationEnd,gotoValueSelectedColumnName:aa,gotoValue:ra,gotoValueFilter:da,onGotoValueSelectedColumnNameChanged:this.handleGotoValueSelectedColumnNameChanged,onGotoValueSelectedFilterChanged:this.handleGotoValueSelectedFilterChanged,onGotoValueChanged:this.handleGotoValueChanged,onGotoValueSubmit:this.handleGotoValueSubmitted}),r.jsx(Aw,{error:ti,isSaving:Qn!=null,saveTooltip:`Commit (${this.commitAction.shortcut.getDisplayText()})`,discardTooltip:`Discard (${this.discardAction.shortcut.getDisplayText()})`,pendingDataErrors:ni,pendingDataMap:si,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,onSave:this.handlePendingCommitClicked,onDiscard:this.handlePendingDiscardClicked}),r.jsx(Iv,{children:bo}),r.jsx($w,{model:l,copyOperation:y??void 0,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd}),r.jsx(Hn,{ref:Be=>{this.tableSaver=Be},getDownloadWorker:n,onDownloadCompleted:this.handleDownloadCompleted,onDownloadCanceled:this.handleDownloadCanceled,onDownloadProgressUpdate:this.handleDownloadProgressUpdate,isDownloading:Dt===Os.DOWNLOAD_STATUS.DOWNLOADING,formatter:q})]}),r.jsx($t,{in:b,timeout:Xe.transitionMidMs,classNames:"slide-left",onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:r.jsx("div",{className:"table-sidebar",children:r.jsxs(Nm,{children:[r.jsx(dd,{title:"Table Options",onClose:this.handleMenuClose,children:r.jsx(Bc,{onSelect:Be=>this.handleMenuSelect(Lo[Be]),items:Lo})}),ha.map((Be,Me)=>r.jsx(dd,{title:Kt[Me].title,onBack:this.handleMenuBack,onClose:this.handleMenuClose,children:Be},Kt[Me].type))]})})}),r.jsx(se,{actions:this.contextActions})]})}}const xu=Un;class kE extends Error{isMissingKey=!0;rowIndex;columnName;constructor(e,t){super(`${t} can't be empty (on pending row ${e+1})`),this.rowIndex=e,this.columnName=t}}const ME=kE,Ze=ee.module("IrisGridTableModel"),LE=150,OE=0,AE=[];function Ys(c){return c.table!==void 0}class lo extends ge{static ROW_BUFFER_PAGES=1;seekRow(e,t,n,s,i,o,l){throw new Error("Method not implemented.")}export(){throw new Error("Method not implemented.")}columnStatistics(e){throw new Error("Method not implemented.")}get customColumns(){return[]}set customColumns(e){throw new Error("Method not implemented.")}get formatColumns(){return[]}set formatColumns(e){throw new Error("Method not implemented.")}updateFrozenColumns(e){throw new Error("Method not implemented.")}get rollupConfig(){throw new Error("Method not implemented.")}set rollupConfig(e){throw new Error("Method not implemented.")}get selectDistinctColumns(){throw new Error("Method not implemented.")}set selectDistinctColumns(e){throw new Error("Method not implemented.")}get columns(){return this.table.columns}irisFormatter;inputTable;subscription;table;viewport;viewportData;formattedStringData;pendingStringData;isSaveInProgress;totalsTable;totalsTablePromise;totals;totalsDataMap;pendingNewDataMap;pendingNewRowCount=0;_columnHeaderGroupMap=new Map;columnHeaderParentMap=new Map;_columnHeaderMaxDepth=null;_columnHeaderGroups=[];_movedColumns=null;constructor(e,t=new gn,n=null){super(),this.handleTableDisconnect=this.handleTableDisconnect.bind(this),this.handleTableReconnect=this.handleTableReconnect.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.handleTotalsUpdate=this.handleTotalsUpdate.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.irisFormatter=t,this.inputTable=n,this.subscription=null,this.table=e,this.viewport=null,this.viewportData=null,this.formattedStringData=[],this.pendingStringData=[],this.isSaveInProgress=!1,this.totalsTable=null,this.totalsTablePromise=null,this.totals=null,this.totalsDataMap=null,this.pendingNewDataMap=new Map,this.pendingNewRowCount=0,this.columnHeaderGroups=Ce.parseColumnHeaderGroups(this,this.layoutHints?.columnGroups??[]).groups}close(){this.table.close(),this.totalsTable!==null&&this.totalsTable.close(),this.totalsTablePromise!==null&&this.totalsTablePromise.cancel()}startListening(){super.startListening(),this.table.addEventListener(I.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.addEventListener(I.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.addEventListener(I.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.addEventListener(I.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.addEventListener(I.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable),this.applyViewport()}stopListening(){super.stopListening(),this.table.removeEventListener(I.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.removeEventListener(I.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.removeEventListener(I.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.removeEventListener(I.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.removeEventListener(I.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.removeTotalsListeners(this.totalsTable),this.closeSubscription()}addTotalsListeners(e){e.addEventListener(I.Table.EVENT_UPDATED,this.handleTotalsUpdate),e.setViewport(0,0)}removeTotalsListeners(e){e.removeEventListener(I.Table.EVENT_UPDATED,this.handleTotalsUpdate)}handleTableDisconnect(){this.dispatchEvent(new $e(ge.EVENT.DISCONNECT))}handleTableReconnect(){this.dispatchEvent(new $e(ge.EVENT.RECONNECT))}handleTableUpdate(e){this.copyViewportData(e.detail),this.dispatchEvent(new $e(ge.EVENT.UPDATED))}handleTotalsUpdate(e){this.copyTotalsData(e.detail),this.dispatchEvent(new $e(ge.EVENT.UPDATED))}handleRequestFailed(e){this.dispatchEvent(new $e(ge.EVENT.REQUEST_FAILED,e))}handleCustomColumnsChanged(){this.dispatchEvent(new $e(ge.EVENT.COLUMNS_CHANGED,{detail:this.columns}))}get rowCount(){return this.table.size+this.pendingNewRowCount+(this.totals?.operationOrder?.length??0)}get pendingDataErrors(){return this.getCachedPendingErrors(this.pendingNewDataMap,this.columns,this.inputTable?.keyColumns.length??0)}get pendingDataMap(){return this.pendingNewDataMap}set pendingDataMap(e){e!==this.pendingNewDataMap&&(e.forEach((t,n)=>{if(!Ce.isValidIndex(n))throw new Error(`Invalid rowIndex ${n}`);const{data:s}=t;s.forEach((i,o)=>{if(!Ce.isValidIndex(o))throw new Error(`Invalid columnIndex ${o}`)})}),this.pendingNewDataMap=e,this.pendingNewRowCount=Math.max(this.pendingNewRowCount,this.maxPendingDataRow),this.formattedStringData=[],this.dispatchEvent(new $e(ge.EVENT.PENDING_DATA_UPDATED)))}get pendingRowCount(){return this.pendingNewRowCount}set pendingRowCount(e){e!==this.pendingNewRowCount&&(this.pendingNewRowCount=Math.max(0,e,this.maxPendingDataRow),this.dispatchEvent(new $e(ge.EVENT.UPDATED)))}get maxPendingDataRow(){return this.pendingNewDataMap.size>0?Math.max(...this.pendingNewDataMap.keys())+1:0}get columnCount(){return this.columns.length}get floatingBottomRowCount(){return this.totals!=null&&this.totals.showOnTop?0:this.totals?.operationOrder?.length??0}get floatingTopRowCount(){return this.totals!=null&&this.totals.showOnTop?this.totals?.operationOrder?.length??0:0}get isChartBuilderAvailable(){return!0}get isTotalsAvailable(){return this.table.getTotalsTable!=null}get isEditable(){return!this.isSaveInProgress&&this.inputTable!=null}cacheFormattedValue(e,t,n){this.formattedStringData[e]==null&&(this.formattedStringData[e]=[]),this.formattedStringData[e][t]=n}cachePendingValue(e,t,n){this.pendingStringData[e]==null&&(this.pendingStringData[e]=[]),this.pendingStringData[e][t]=n}clearPendingValue(e,t){const n=this.pendingStringData[e];n!=null&&delete n[t]}textValueForCell(e,t){if(this.pendingStringData[e]?.[t]!==void 0)return this.pendingStringData[e][t];if(this.formattedStringData[e]?.[t]===void 0){const n=this.valueForCell(e,t);if(n==null)return null;const s=this.totalsColumn(e,t)??this.columns[e],i=this.getCachedCustomColumnFormatFlag(this.formatter,s.name,s.type);let o;if(!i){const a=this.formatForCell(e,t);a?.formatString!=null&&(o=a)}const l=this.displayString(n,s.type,s.name,o);this.cacheFormattedValue(e,t,l)}return this.formattedStringData[e][t]}textForCell(e,t){const n=this.textValueForCell(e,t);if(n==null&&this.isKeyColumn(e)){const s=this.pendingRow(t);if(s!=null&&this.pendingDataMap.has(s))return"*"}return n??""}truncationCharForCell(e){const t=this.columns[e],{type:n}=t;if(F.isNumberType(n)&&this.formatter.truncateNumbersWithPound)return"#"}colorForCell(e,t,n){const s=this.dataForCell(e,t);if(s){const{format:i,value:o}=s;if(o==null||o==="")return N(n.nullStringColor),n.nullStringColor;if(i&&i.color)return i.color;if(this.isPendingRow(t))return N(n.pendingTextColor),n.pendingTextColor;if(o!=null){const l=this.totalsColumn(e,t)??this.columns[e];if(F.isDateType(l.type)||l.name==="Date")return N(n.dateColor),n.dateColor;if(F.isNumberType(l.type))return o>0?(N(n.positiveNumberColor),n.positiveNumberColor):o<0?(N(n.negativeNumberColor),n.negativeNumberColor):(N(n.zeroNumberColor),n.zeroNumberColor)}}else if(this.isPendingRow(t)&&this.isKeyColumn(e))return N(n.errorTextColor),n.errorTextColor;return n.textColor}backgroundColorForCell(e,t){return this.formatForCell(e,t)?.backgroundColor??null}textAlignForCell(e){const t=this.columns[e],{type:n}=t;return F.isNumberType(n)?"right":F.isDateType(n)||t.name==="Date"?"center":"left"}textForColumnHeader(e,t=0){const n=this.columnAtDepth(e,t);return va(n)?n.isNew?"":n.name:n?.name}colorForColumnHeader(e,t=0){const n=this.columnAtDepth(e,t);return va(n)?n.color??null:null}getColumnHeaderGroup(e,t){const n=this.columnAtDepth(e,t);if(va(n))return n}getColumnHeaderParentGroup(e,t){return this.columnHeaderParentMap.get(this.columnAtDepth(e,t)?.name??"")}columnAtDepth(e,t=0){if(t===0)return this.columns[e];const n=this.columns[e]?.name;let s=this.columnHeaderParentMap.get(n);if(!s)return;let i=s.depth;for(;i<t;){if(s=this.columnHeaderParentMap.get(s.name),!s)return;i=s.depth}if(s.depth===t)return s}textForRowFooter(e){const t=this.totalsRow(e);return t!=null&&this.totals?this.totals.operationOrder[t]:""}getMemoizedInitialMovedColumns=he(e=>{if(!e)return[];let t=[];const{groupMap:n}=Ce.parseColumnHeaderGroups(this,e?.columnGroups??[]),s=(h,u)=>{const m=this.getColumnIndexByName(h);if(m==null)throw new Error(`Unknown layout hint column: ${h}`);const g=O.getVisibleIndex(m,t);t=O.moveItem(g,u,t)},i=(h,u)=>{const m=n.get(h);if(m==null)throw new Error(`Unknown layout hint group: ${h}`);const g=m.getVisibleRange(t);t=O.moveRange(g,u,t)},{frontColumns:o=[],backColumns:l=[],frozenColumns:a=[]}=e;if(o.length||l.length||a.length){const h=new Set;let u=0;a.forEach(g=>{if(h.has(g))throw new Error(`Column specified in multiple layout hints: ${g}`);s(g,u),u+=1}),o.forEach(g=>{if(h.has(g))throw new Error(`Column specified in multiple layout hints: ${g}`);s(g,u),u+=1});let m=this.columnMap.size-1;l.forEach(g=>{if(h.has(g))throw new Error(`Column specified in multiple layout hints: ${g}`);s(g,m),m-=1})}if(e?.columnGroups){const h=[...n.values()];h.sort((u,m)=>u.depth-m.depth),h.forEach(u=>{const m=u.children[0],g=this.getColumnIndexByName(m);let p;if(g!=null)p=O.getVisibleIndex(g,t);else{const C=n.get(m);if(!C)throw new Error(`Unknown column ${m} in group ${u.name}`);[,p]=C.getVisibleRange(t)}for(let C=1;C<u.children.length;C+=1){const f=u.children[C],S=n.get(f),v=this.getColumnIndexByName(f);if(S){const T=S.getVisibleRange(t)[0]<p?p-S.childIndexes.length+1:p+1;i(f,T),p=T+S.childIndexes.length-1}else if(v!=null){const T=O.getVisibleIndex(v,t)<p?p:p+1;s(f,T),p=T}}})}return this._movedColumns=t,t});get initialMovedColumns(){return this.getMemoizedInitialMovedColumns(this.layoutHints??void 0)}get initialMovedRows(){return AE}getMemoizedInitialColumnHeaderGroups=he(e=>Ce.parseColumnHeaderGroups(this,e?.columnGroups??[]).groups);get initialColumnHeaderGroups(){return this.getMemoizedInitialColumnHeaderGroups(this.layoutHints??void 0)}getMemoizedColumnMap=he(e=>{const t=new Map;return e.forEach(n=>t.set(n.name,n)),t});get columnMap(){return this.getMemoizedColumnMap(this.table.columns)}get columnHeaderMaxDepth(){return this._columnHeaderMaxDepth??1}set columnHeaderMaxDepth(e){this._columnHeaderMaxDepth=e}get columnHeaderGroupMap(){return this._columnHeaderGroupMap}get columnHeaderGroups(){return this._columnHeaderGroups}set columnHeaderGroups(e){if(e===this._columnHeaderGroups)return;const{groups:t,maxDepth:n,parentMap:s,groupMap:i}=Ce.parseColumnHeaderGroups(this,e??this.initialColumnHeaderGroups);this._columnHeaderGroups=t,this.columnHeaderMaxDepth=n,this.columnHeaderParentMap=s,this._columnHeaderGroupMap=i}get groupedColumns(){return[]}row(e){const t=this.totals?.operationOrder?.length??0,n=this.totals?.showOnTop??!1,s=this.totalsRow(e);if(s!=null){const a=this.totals?.operationOrder[s];return N(a),this.totalsDataMap?.get(a)??null}const i=this.pendingRow(e);if(i!=null)return this.pendingNewDataMap.get(i)??null;const o=this.viewportData?.offset??0,l=(n?e-t:e)-o;return this.viewportData?.rows?.[l]??null}totalsColumn(e,t){const n=this.totalsRow(t);if(n==null)return null;const s=this.totals?.operationOrder[n],i=this.totals?.defaultOperation??ke.SUM,o=this.columns[e];return this.totalsTable?.columns.find(l=>l.name===`${o.name}__${s}`||(s===i||this.totals?.operationOrder.length===1)&&l.name===o.name)}totalsRow(e){const t=this.totals?.operationOrder?.length??0,s=this.totals?.showOnTop??!1?e:e-this.table.size;return s>=0&&s<t?s:null}pendingRow(e){const t=e-this.floatingTopRowCount-this.table.size;return t>=0&&t<this.pendingNewRowCount?t:null}isTotalsRow(e){return this.totalsRow(e)!=null}isPendingRow(e){return this.pendingRow(e)!=null}dataForCell(e,t){return this.row(t)?.data.get(e)}formatForCell(e,t){return this.dataForCell(e,t)?.format}valueForCell(e,t){const n=this.dataForCell(e,t);if(n)return n.value??null}copyViewportData(e){if(e==null){Ze.warn("invalid data!");return}this.viewportData=this.extractViewportData(e),this.formattedStringData=[]}copyTotalsData(e){if(e==null){Ze.warn("invalid data!");return}const{columns:t,rows:n}=e;if(n.length!==1){Ze.error("Unexpected number of rows received for totals table, ignoring update");return}const s=new Map,i=n[0],o=this.totals?.defaultOperation??ke.SUM,l=this.totals?.operationMap;for(let a=0;a<t.length;a+=1){const d=t[a],[h,u=l?.[h]?.[0]??o]=d.name.split("__");s.has(u)||s.set(u,{data:new Map});const{data:m}=s.get(u),g=this.columns.findIndex(p=>p.name===h);m.set(g,{value:i.get(d),format:i.getFormat(d)})}Ze.debug2("copyTotalsData",s),this.totalsDataMap=s,this.formattedStringData=[]}getColumnIndexByName(e){return this.getColumnIndicesByNameMap(this.columns).get(e)}getColumnIndicesByNameMap=he(e=>{const t=new Map;return e.forEach(({name:n},s)=>t.set(n,s)),t});extractViewportData(e){const t={offset:e.offset,rows:[]},{columns:n}=e;for(let s=0;s<e.rows.length;s+=1){const i=e.rows[s],o=this.extractViewportRow(i,n);t.rows.push(o)}return t}extractViewportRow(e,t){const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],o=this.getColumnIndexByName(i.name);N(o),n.set(o,{value:e.get(i),format:e.getFormat(i)})}return{data:n}}closeSubscription(){Ze.debug2("closeSubscription",this.subscription),this.subscription&&(this.subscription.close(),this.subscription=null),this.setViewport.cancel(),this.applyViewport.cancel()}get filter(){return this.table.filter}set filter(e){this.closeSubscription(),this.table.applyFilter(e),this.applyViewport()}get formatter(){return this.irisFormatter}set formatter(e){this.irisFormatter=e,this.formattedStringData=[],this.dispatchEvent(new $e(ge.EVENT.FORMATTER_UPDATED))}displayString(e,t,n="",s){return this.getCachedFormattedString(this.formatter,e,t,n,s)}get sort(){return this.table.sort}set sort(e){this.closeSubscription(),this.table.applySort(e),this.applyViewport()}set totalsConfig(e){if(Ze.debug("set totalsConfig",e),e!==this.totals){if(this.totals=e,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),e==null){this.dispatchEvent(new $e(ge.EVENT.UPDATED));return}this.totalsTablePromise=ve.makeCancelable(this.table.getTotalsTable(e),t=>t.close()),this.totalsTablePromise.then(t=>{this.totalsTablePromise=null,this.setTotalsTable(t)}).catch(t=>{ve.isCanceled(t)||(Ze.error("Unable to set next totalsTable",t),this.totalsTablePromise=null,this.dispatchEvent(new $e(ge.EVENT.REQUEST_FAILED,{detail:t})))})}}setTotalsTable(e){Ze.debug("setTotalsTable",e),this.totalsTable!==null&&(this.listenerCount>0&&this.removeTotalsListeners(this.totalsTable),this.totalsTable.close()),this.totalsTable=e,this.totalsDataMap=null,this.listenerCount>0&&this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable)}setViewport=Ts((e,t,n)=>{if(t<e){Ze.error("Invalid viewport",e,t);return}const{viewport:s}=this;if(s!=null&&s.top===e&&s.bottom===t&&s.columns===n){Ze.debug2("Ignoring duplicate viewport",s);return}this.viewport={top:e,bottom:t,columns:n},Ze.debug2("setViewport",this.viewport),this.applyViewport()},LE);applyViewport=Ts(()=>{if(!this.viewport)return;Ze.debug2("applyViewport",this.viewport);const{top:e,bottom:t,columns:n}=this.viewport,[s,i]=this.getCachedViewportRowRange(e,t);this.applyBufferedViewport(s,i,n)},OE,{leading:!1});applyBufferedViewport(e,t,n){Ze.debug2("applyBufferedViewport",e,t,n),this.subscription==null?(Ze.debug2("applyBufferedViewport creating new subscription"),this.subscription=this.table.setViewport(e,t,n)):(Ze.debug2("applyBufferedViewport using existing subscription"),this.subscription.setViewport(e,t,n))}async snapshot(e,t=!1,n=i=>i,s=!0){if(this.subscription==null)throw new Error("No subscription available");const i=s?J.consolidate(e):e;if(!Ce.isValidSnapshotRanges(i))throw new Error(`Invalid snapshot ranges ${e}`);const o=new Set,l=[],a=new Set;for(let g=0;g<i.length;g+=1){const p=i[g];N(p.endRow),N(p.startRow);for(let C=p.startRow;C<=p.endRow&&C<this.floatingTopRowCount;C+=1)o.add(C);p.endRow>=this.floatingTopRowCount&&p.startRow<=this.floatingTopRowCount+this.table.size&&l.push(new J(p.startColumn,Math.min(Math.max(0,p.startRow-this.floatingTopRowCount)),p.endColumn,Math.min(Math.max(0,p.endRow-this.floatingTopRowCount),this.table.size-this.floatingTopRowCount)));for(let C=Math.max(p.startRow,this.floatingTopRowCount+this.table.size);C<=p.endRow&&C<this.floatingTopRowCount+this.table.size+this.floatingBottomRowCount;C+=1)a.add(C)}const d=Ce.columnsFromRanges(i,this.columns),h=[];t&&h.push(d.map(g=>g.name));const u=[...o].sort();for(let g=0;g<u.length;g+=1){const p=u[g],C=d.map(f=>{const S=this.getColumnIndexByName(f.name);return N(S),n(this.valueForCell(S,p),f)});t&&C.push(this.textForRowFooter(p)),h.push(C)}if(l.length>0){const g=Ce.rangeSetFromRanges(l),p=await this.subscription.snapshot(g,d);h.push(...p.rows.map(C=>d.map(f=>n(C.get(f),f))))}const m=[...a].sort();for(let g=0;g<m.length;g+=1){const p=m[g],C=d.map(f=>{const S=this.getColumnIndexByName(f.name);return N(S),n(this.valueForCell(S,p),f)});t&&C.push(this.textForRowFooter(p)),h.push(C)}return h}async textSnapshot(e,t=!1,n=s=>`${s}`){return Ze.debug2("textSnapshot",e,t),(await this.snapshot(e,t,n,!1)).map(i=>i.join(" ")).join(`
|
|
31
|
-
`)}async valuesTable(e){let t=null;try{return t=await this.table.copy(),t.applyFilter([]),t.applySort([]),t.selectDistinct([e])}finally{t?.close()}}getCachedFormattedString=Bn((e,t,n,s,i)=>e.getFormattedString(t,n,s,i),{max:1e4});getCachedCustomColumnFormatFlag=Bn(Gn.isCustomColumnFormatDefined,{max:1e4});getCachedViewportRowRange=he((e,t)=>{const n=t-e,s=Math.max(0,e-n*lo.ROW_BUFFER_PAGES),i=t+n*lo.ROW_BUFFER_PAGES;return[s,i]});getCachedPendingErrors=he((e,t,n)=>{const s=new Map;return e.forEach((i,o)=>{const{data:l}=i;for(let a=0;a<n;a+=1)l.has(a)||(s.has(o)||s.set(o,[]),s.get(o)?.push(new ME(o,t[a].name)))}),s});isColumnMovable(e,t){if(e<0||e>=this.columnCount)return!1;if(t>0)return!0;const n=this.columns[e].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)||!n?!1:!this.isKeyColumn(e)}isKeyColumn(e){return e<(this.inputTable?.keyColumns.length??0)}isRowMovable(){return!1}isEditableRange(e){return!(this.inputTable==null||!J.isBounded(e)||!(this.isPendingRow(e.startRow)&&this.isPendingRow(e.endRow)||this.inputTable.keyColumns.length!==0&&e.startColumn>=this.inputTable.keyColumns.length&&e.endColumn>=this.inputTable.keyColumns.length)||e.startRow<this.floatingTopRowCount||e.startRow>=this.floatingTopRowCount+this.table.size+this.pendingRowCount||e.endRow>=this.floatingTopRowCount+this.table.size+this.pendingRowCount)}isDeletableRange(e){return this.inputTable!=null&&e.startRow!=null&&e.endRow!=null&&e.startRow>=this.floatingTopRowCount&&e.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&e.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isEditableRanges(e){return e.every(t=>this.isEditableRange(t))}isDeletableRanges(e){return e.every(t=>this.isDeletableRange(t))}getTableAreaRange(){return new J(null,this.floatingTopRowCount,null,this.floatingTopRowCount+this.table.size-1)}getPendingAreaRange(){return new J(null,this.floatingTopRowCount+this.table.size,null,this.floatingTopRowCount+this.table.size+this.pendingNewRowCount-1)}async setValueForCell(e,t,n){return this.setValueForRanges([new J(e,t,e,t)],n)}async setValueForRanges(e,t){if(!this.isEditableRanges(e))throw new Error(`Uneditable ranges ${e}`);try{const n=new Set,s=[];J.forEachCell(e,(d,h)=>{const u=this.columns[d];if(n.add(u),s[d]===void 0){const m=F.makeValue(u.type,t,this.formatter.timeZone);s[d]=m!=null?this.displayString(m,u.type,u.name):null}this.cachePendingValue(d,h,s[d])});const i=this.getPendingAreaRange(),o=e.map(d=>J.intersection(i,d)).filter(d=>d!=null).map(d=>(N(d),J.offset(d,0,-(this.floatingTopRowCount+this.table.size))));if(o.length>0){const d=new Map(this.pendingNewDataMap);J.forEachCell(o,(h,u)=>{d.has(u)||d.set(u,{data:new Map});const m=this.columns[h],g=d.get(u);N(g);const{data:p}=g,C=new Map(p),f=F.makeValue(m.type,t,this.formatter.timeZone);f!=null?C.set(h,{value:f}):C.delete(h),C.size>0?d.set(u,{...g,data:C}):d.delete(u)}),this.pendingDataMap=d}this.dispatchEvent(new $e(ge.EVENT.UPDATED));const l=this.getTableAreaRange(),a=e.map(d=>J.intersection(l,d)).filter(d=>d!=null);if(a.length>0){const h=(await this.snapshot(a.map(m=>new J(null,m?.startRow??null,null,m?.endRow??null)))).map(m=>{const g={};for(let p=0;p<this.columns.length;p+=1)g[this.columns[p].name]=m[p];return n.forEach(p=>{g[p.name]=F.makeValue(p.type,t,this.formatter.timeZone)}),g}),u=await this.inputTable?.addRows(h);Ze.debug("setValueForRanges(",e,",",t,") set tableRanges",a,"result",u)}J.forEachCell(e,(d,h)=>{const u=s[d];N(u),this.cacheFormattedValue(d,h,u)})}catch(n){Ze.error("Unable to set ranges",e,t,n)}finally{J.forEachCell(e,(n,s)=>{this.clearPendingValue(n,s)})}}async setValues(e=[]){if(Ze.debug("setValues(",e,")"),!e.every(t=>this.isEditableRange(J.makeCell(t.column??t.x,t.row??t.y))))throw new Error(`Uneditable ranges ${e}`);try{const t=new Map(this.pendingNewDataMap);e.forEach(l=>{const{text:a}=l,d=l.column??l.x,h=l.row??l.y,u=this.columns[d],m=F.makeValue(u.type,a,this.formatter.timeZone),g=m!=null?this.displayString(m,u.type,u.name):null;this.cachePendingValue(d,h,g);const p=this.pendingRow(h);if(p!=null){t.has(p)||t.set(p,{data:new Map});const C=t.get(p);N(C);const{data:f}=C,S=new Map(f);m!=null?S.set(d,{value:m}):S.delete(d),S.size>0?t.set(p,{...C,data:S}):t.delete(p)}}),this.pendingDataMap=t,this.dispatchEvent(new $e(ge.EVENT.UPDATED));const n=e.reduce((l,a)=>{const d=a.row??a.y;return l.has(d)||l.set(d,[]),l.get(d)?.push(a),l},new Map),s=J.consolidate(e.map(l=>J.makeCell(l.column??l.x,l.row??l.y))),i=this.getTableAreaRange(),o=s.map(l=>J.intersection(i,l)).filter(l=>l!=null);if(o.length>0){const a=(await this.snapshot(o.map(h=>(N(h),new J(null,h.startRow,null,h.endRow))))).map((h,u)=>{let m=null,g=u;for(let f=0;f<o.length;f+=1){const S=o[f];N(S);const v=J.rowCount([S]);if(g<v){N(S.startRow),m=S.startRow+g;break}g-=v}const p={};for(let f=0;f<this.columns.length;f+=1)p[this.columns[f].name]=h[f];N(m);const C=n.get(m);return C?.forEach(f=>{const S=this.columns[f.column??f.x];p[S.name]=F.makeValue(S.type,f.text,this.formatter.timeZone)}),p});Ze.info("setValues setting tableRanges",o);const d=await this.inputTable?.addRows(a);Ze.info("setValues set tableRanges",o,"SUCCESS",d)}e.forEach(l=>{const{text:a}=l,d=l.column??l.x,h=l.row??l.y,u=this.columns[d],m=F.makeValue(u.type,a,this.formatter.timeZone),g=m!=null?this.displayString(m,u.type,u.name):null;this.cacheFormattedValue(d,h,g)})}finally{e.forEach(t=>{this.clearPendingValue(t.column,t.row)})}}async commitPending(){if(this.pendingNewDataMap.size<=0)throw new Error("No pending changes to commit");try{this.isSaveInProgress=!0;const e=[];this.pendingNewDataMap.forEach(n=>{const s={};n.data.forEach(({value:i},o)=>{const l=this.columns[o];s[l.name]=i}),e.push(s)});const t=await this.inputTable?.addRows(e);Ze.debug("commitPending()",this.pendingNewDataMap,"result",t),this.pendingNewDataMap=new Map,this.pendingNewRowCount=Math.max(0,(this.viewport?.bottom??0)-this.table.size),this.formattedStringData=[],this.dispatchEvent(new $e(ge.EVENT.PENDING_DATA_UPDATED))}finally{this.isSaveInProgress=!1}}editValueForCell(e,t){return this.textValueForCell(e,t)}async delete(e){if(!this.isDeletableRanges(e))throw new Error(`Undeletable ranges ${e}`);N(this.inputTable);const{keyColumns:t}=this.inputTable;if(t.length===0)throw new Error("No key columns to allow deletion");const n=this.getPendingAreaRange(),s=e.map(u=>J.intersection(n,u)).filter(u=>u!=null).map(u=>(N(u),J.offset(u,0,-(this.floatingTopRowCount+this.table.size))));if(s.length>0){const u=new Map(this.pendingNewDataMap);for(let m=0;m<s.length;m+=1){const g=s[m];N(g.startRow),N(g.endRow);for(let p=g.startRow;p<=g.endRow;p+=1)u.delete(p)}this.pendingNewDataMap=u,this.formattedStringData=[],this.dispatchEvent(new $e(ge.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new $e(ge.EVENT.UPDATED))}const i=this.getTableAreaRange(),o=e.map(u=>J.intersection(i,u)).filter(u=>u!=null);if(o.length<=0)return;const[l,a]=await Promise.all([this.snapshot(o.map(u=>(N(u),new J(0,u.startRow,t.length-1,u.endRow)))),this.table.copy()]),h=l.map(u=>{const m=[];for(let g=0;g<t.length;g+=1){const p=t[g],C=u[g],f=F.makeFilterRawValue(p.type,C),S=p.filter().eq(f);m.push(S)}return m.reduce((g,p)=>g?.and(p)??p)}).reduce((u,m)=>u?.or(m)??m);a.applyFilter([h]),a.close()}isValidForCell(e,t,n){try{const s=this.columns[e];return F.makeValue(s.type,n,this.formatter.timeZone),!0}catch{return!1}}}const ds=ee.module("IrisGridTableModel");class _E extends lo{userFrozenColumns;customColumnList;formatColumnList;constructor(e,t=new gn,n=null){super(e,t,n),this.customColumnList=[],this.formatColumnList=[]}get isExportAvailable(){return this.table.freeze!=null}get isColumnStatisticsAvailable(){return this.table.getColumnStatistics!=null}get isValuesTableAvailable(){return this.table.selectDistinct!=null&&this.table.copy!=null}get isRollupAvailable(){return this.table.rollup!=null}get isSelectDistinctAvailable(){return this.table.selectDistinct!=null}get isCustomColumnsAvailable(){return this.table.applyCustomColumns!=null}get isFormatColumnsAvailable(){return this.table.applyCustomColumns!=null}getMemoizedFrontColumns=he(e=>e??[]);get frontColumns(){return this.getMemoizedFrontColumns(this.layoutHints?.frontColumns)}getMemoizedBackColumns=he(e=>e??[]);get backColumns(){return this.getMemoizedBackColumns(this.layoutHints?.backColumns)}getMemoizedFrozenColumns=he((e,t)=>t??e??[]);get frozenColumns(){return this.getMemoizedFrozenColumns(this.layoutHints?.frozenColumns,this.userFrozenColumns)}get layoutHints(){return this.table.layoutHints}get floatingLeftColumnCount(){return this.frozenColumns.length}get description(){return this.table.description}get customColumns(){return this.customColumnList}set customColumns(e){if(ds.debug2("set customColumns",e,this.customColumnList,e===this.customColumnList),this.customColumnList.length===0&&e.length===0){ds.debug("Ignore empty initial customColumns"),this.customColumnList=e;return}if(this.customColumnList===e){ds.debug("Ignore same customColumns");return}this.closeSubscription(),this.customColumnList=e,this.table.applyCustomColumns([...e,...this.formatColumns]),this.applyViewport()}get formatColumns(){return this.formatColumnList}set formatColumns(e){if(ds.debug2("set formatColumns",e,this.formatColumnList,e===this.formatColumnList),this.formatColumnList.length===0&&e.length===0){ds.debug("Ignore empty initial formatColumns"),this.formatColumnList=e;return}if(this.formatColumnList===e){ds.debug("Ignore same formatColumns");return}this.closeSubscription(),this.formatColumnList=e,this.table.applyCustomColumns([...this.customColumns,...e]),this.applyViewport()}updateFrozenColumns(e){this.userFrozenColumns=e,this.dispatchEvent(new $e(ge.EVENT.TABLE_CHANGED,{detail:this.table}))}set totalsConfig(e){if(ds.debug("set totalsConfig",e),e!==this.totals){if(this.totals=e,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),e==null){this.dispatchEvent(new $e(ge.EVENT.UPDATED));return}this.totalsTablePromise=ve.makeCancelable(this.table.getTotalsTable(e),t=>t.close()),this.totalsTablePromise.then(t=>{this.totalsTablePromise=null,this.setTotalsTable(t)}).catch(t=>{ve.isCanceled(t)||(ds.error("Unable to set next totalsTable",t),this.totalsTablePromise=null,this.dispatchEvent(new $e(ge.EVENT.REQUEST_FAILED,{detail:t})))})}}get isFilterRequired(){return this.table.isUncoalesced}isFilterable(e){return this.getCachedFilterableColumnSet(this.columns).has(e)}async export(){return this.table.freeze()}columnStatistics(e){return this.table.getColumnStatistics(e)}getCachedFilterableColumnSet=he(e=>new Set(e.map((t,n)=>n)));isColumnMovable(e){const t=this.columns[e].name;return this.frontColumns.includes(t)||this.backColumns.includes(t)||this.frozenColumns.includes(t)?!1:!this.isKeyColumn(e)}isColumnFrozen(e){return this.frozenColumns.includes(this.columns[e].name)}async delete(e){if(!this.isDeletableRanges(e))throw new Error(`Undeletable ranges ${e}`);N(this.inputTable);const{keyColumns:t}=this.inputTable;if(t.length===0)throw new Error("No key columns to allow deletion");const n=this.getPendingAreaRange(),s=e.map(u=>J.intersection(n,u)).filter(u=>u!=null).map(u=>(N(u),J.offset(u,0,-(this.floatingTopRowCount+this.table.size))));if(s.length>0){const u=new Map(super.pendingDataMap);for(let m=0;m<s.length;m+=1){const g=s[m];N(g.startRow),N(g.endRow);for(let p=g.startRow;p<=g.endRow;p+=1)u.delete(p)}super.pendingDataMap=u,this.formattedStringData=[],this.dispatchEvent(new $e(ge.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new $e(ge.EVENT.UPDATED))}const i=this.getTableAreaRange(),o=e.map(u=>J.intersection(i,u)).filter(u=>u!=null);if(o.length<=0)return;const[l,a]=await Promise.all([this.snapshot(o.map(u=>(N(u),new J(0,u.startRow,t.length-1,u.endRow)))),this.table.copy()]),h=l.map(u=>{const m=[];for(let g=0;g<t.length;g+=1){const p=t[g],C=u[g],f=F.makeFilterRawValue(p.type,C),S=p.filter().eq(f);m.push(S)}return m.reduce((g,p)=>g?.and(p)??p)}).reduce((u,m)=>u?.or(m)??m);a.applyFilter([h]),await this.inputTable?.deleteTable(a),a.close()}async seekRow(e,t,n,s,i,o,l){return this.table.seekRow(e,t,n,s,i,o,l)}get isSeekRowAvailable(){return this.table.seekRow!=null}}const Iu=_E;class PE extends lo{applyBufferedViewport(e,t,n){this.table.setViewport(e,t,n)}textForCell(e,t){const n=this.columns[e],s=this.row(t);if(s!=null&&n!=null&&!s.hasChildren&&n.constituentType!=null){const i=this.valueForCell(e,t);return this.displayString(i,n.constituentType,n.name)}return super.textForCell(e,t)}extractViewportRow(e,t){const{isExpanded:n,hasChildren:s,depth:i}=e;return{...super.extractViewportRow(e,t),isExpanded:n,hasChildren:s,depth:i}}async snapshot(e,t,n){N(this.viewport),N(this.viewportData);const{columns:s}=this.viewport,i=[];t!=null&&t&&i.push(s.map(l=>l.name));const o=new J(0,this.viewportData?.offset,s.length,this.viewportData.offset+this.viewportData.rows.length);for(let l=0;l<e.length;l+=1){const a=J.intersection(o,e[l]);N(a),N(a.startRow),N(a.endRow);for(let d=a.startRow;d<=a.endRow;d+=1){const h=[],u=this.viewportData.rows[d-this.viewportData.offset];N(a.startColumn),N(a.endColumn);for(let m=a.startColumn;m<=a.endColumn;m+=1)N(n),h.push(n(u.data.get(m)?.value,this.columns[m]));i.push(h)}}return i}get groupedColumns(){return this.table.groupedColumns}get hasExpandableRows(){return!0}get isExpandAllAvailable(){return this.table.expandAll!==void 0}get isChartBuilderAvailable(){return!1}get isSelectDistinctAvailable(){return!1}get isReversible(){return!1}isFilterable(e){return this.getCachedFilterableColumnSet(this.columns,this.groupedColumns).has(e)}isColumnMovable(e){return e>=this.groupedColumns.length}isRowExpandable(e){return this.row(e)?.hasChildren??!1}isRowExpanded(e){return this.row(e)?.isExpanded??!1}setRowExpanded(e,t,n=!1){this.isExpandAllAvailable?this.table.setExpanded(e,t,n):this.table.setExpanded(e,t)}expandAll(){this.table.expandAll&&this.table.expandAll()}collapseAll(){this.table.collapseAll&&this.table.collapseAll()}depthForRow(e){return(this.row(e)?.depth??1)-1}getCachedFilterableColumnSet=he((e,t)=>new Set((t?.length>0?t:e).map(n=>e.findIndex(s=>n.name===s.name))));updateFrozenColumns(e){if(e.length>0)throw new Error("Cannot freeze columns on a tree table")}}const jE=PE,cs=ee.module("IrisGridProxyModel");function Da(c,e,t){return F.isTreeTable(c)?new jE(c,e):new Iu(c,e,t)}class HE extends ge{originalModel;model;modelPromise;rollup;selectDistinct;constructor(e,t=new gn,n=null){super(),this.handleModelEvent=this.handleModelEvent.bind(this);const s=Da(e,t,n);this.originalModel=s,this.model=s,this.modelPromise=null,this.rollup=null,this.selectDistinct=[]}close(){this.originalModel.close(),this.model!==this.originalModel&&this.model.close(),this.modelPromise!=null&&this.modelPromise.cancel()}handleModelEvent(e){cs.debug2("handleModelEvent",e);const{detail:t,type:n}=e;this.dispatchEvent(new $e(n,{detail:t}))}setModel(e){cs.debug("setModel",e);const t=this.model;t!==this.originalModel&&t.close(),this.model=e,this.listenerCount>0&&this.addListeners(e),this.dispatchEvent(new $e(ge.EVENT.COLUMNS_CHANGED,{detail:e.columns})),Ys(e)&&this.dispatchEvent(new $e(ge.EVENT.TABLE_CHANGED,{detail:e.table}))}setNextModel(e){cs.debug2("setNextModel"),this.modelPromise&&this.modelPromise.cancel(),this.listenerCount>0&&this.removeListeners(this.model),this.modelPromise=ve.makeCancelable(e,t=>t.close()),this.modelPromise.then(t=>{this.modelPromise=null,this.setModel(t)}).catch(t=>{if(ve.isCanceled(t)){cs.debug2("setNextModel cancelled");return}cs.error("Unable to set next model",t),this.modelPromise=null,this.dispatchEvent(new $e(ge.EVENT.REQUEST_FAILED,{detail:t}))})}startListening(){super.startListening(),this.addListeners(this.model)}stopListening(){super.stopListening(),this.removeListeners(this.model)}addListeners(e){const t=Object.keys(ge.EVENT);for(let n=0;n<t.length;n+=1)e.addEventListener(t[n],this.handleModelEvent)}removeListeners(e){const t=Object.keys(ge.EVENT);for(let n=0;n<t.length;n+=1)e.removeEventListener(t[n],this.handleModelEvent)}get rowCount(){return this.model.rowCount}get columnCount(){return this.model.columnCount}get floatingTopRowCount(){return this.model.floatingTopRowCount}get floatingBottomRowCount(){return this.model.floatingBottomRowCount}get floatingLeftColumnCount(){return this.model.floatingLeftColumnCount}get floatingRightColumnCount(){return this.model.floatingRightColumnCount}textForCell=(...e)=>this.model.textForCell(...e);truncationCharForCell=(...e)=>this.model.truncationCharForCell(...e);textAlignForCell=(...e)=>this.model.textAlignForCell(...e);colorForCell=(...e)=>this.model.colorForCell(...e);backgroundColorForCell=(...e)=>this.model.backgroundColorForCell(...e);textForColumnHeader=(...e)=>this.model.textForColumnHeader(...e);colorForColumnHeader=(...e)=>this.model.colorForColumnHeader(...e);textForRowHeader=(...e)=>this.model.textForRowHeader(...e);textForRowFooter=(...e)=>this.model.textForRowFooter(...e);isRowMovable=(...e)=>this.model.isRowMovable(...e);isColumnMovable=(...e)=>this.model.isColumnMovable(...e);isColumnFrozen(e){return this.model.isColumnFrozen(e)}get hasExpandableRows(){return He(this.model)?this.model.hasExpandableRows:!1}get isExpandAllAvailable(){return He(this.model)?this.model.isExpandAllAvailable??!1:!1}isRowExpandable=(...e)=>He(this.model)?this.model.isRowExpandable(...e):!1;isRowExpanded=(...e)=>He(this.model)?this.model.isRowExpanded(...e):!1;setRowExpanded=(...e)=>{if(He(this.model))return this.model.setRowExpanded(...e);throw Error("Function setRowExpanded does not exist on IrisGridTableModel")};expandAll=()=>{if(He(this.model))return this.model.expandAll();throw Error("Function expandAll does not exist on IrisGridTableModel")};collapseAll=()=>{if(He(this.model))return this.model.collapseAll();throw Error("Function collapseAll does not exist on IrisGridTableModel")};depthForRow=(...e)=>He(this.model)?this.model.depthForRow(...e):0;get isExportAvailable(){return this.model.isExportAvailable}get isColumnStatisticsAvailable(){return this.model.isColumnStatisticsAvailable}get isValuesTableAvailable(){return this.model.isValuesTableAvailable}get isCustomColumnsAvailable(){return this.model.isCustomColumnsAvailable&&!(this.isSelectDistinctAvailable&&this.selectDistinctColumns.length>0)}get isFormatColumnsAvailable(){return this.model.isFormatColumnsAvailable}get isChartBuilderAvailable(){return this.model.isChartBuilderAvailable}get isRollupAvailable(){return(this.originalModel.isRollupAvailable||this.rollup!=null)&&this.selectDistinct.length===0}get isSelectDistinctAvailable(){return(this.originalModel.isSelectDistinctAvailable||this.selectDistinct.length>0)&&this.rollup==null}get isTotalsAvailable(){return this.model.isTotalsAvailable}get isReversible(){return this.model.isReversible}get columns(){return this.model.columns}get initialMovedColumns(){return this.model.initialMovedColumns}get initialMovedRows(){return this.model.initialMovedRows}get layoutHints(){return this.model.layoutHints}get frontColumns(){return this.model.frontColumns}get backColumns(){return this.model.backColumns}get frozenColumns(){return this.model.frozenColumns}getColumnHeaderGroup=(...e)=>this.model.getColumnHeaderGroup(...e);get columnHeaderGroups(){return this.model.columnHeaderGroups}set columnHeaderGroups(e){this.model.columnHeaderGroups=e}get initialColumnHeaderGroups(){return this.model.initialColumnHeaderGroups}getColumnHeaderParentGroup=(...e)=>this.model.getColumnHeaderParentGroup(...e);get columnHeaderGroupMap(){return this.model.columnHeaderGroupMap}get columnHeaderMaxDepth(){return this.model.columnHeaderMaxDepth}updateFrozenColumns(e){return this.model.updateFrozenColumns(e)}get originalColumns(){return this.originalModel.columns}get groupedColumns(){return this.model.groupedColumns}get description(){return this.model.description}formatForCell=(...e)=>this.model.formatForCell(...e);valueForCell=(...e)=>this.model.valueForCell(...e);get filter(){return this.model.filter}set filter(e){this.model.filter=e}get formatter(){return this.model.formatter}set formatter(e){this.model.formatter=e}displayString=(...e)=>this.model.displayString(...e);get sort(){return this.model.sort}set sort(e){this.model.sort=e}get customColumns(){return this.model.customColumns}set customColumns(e){this.model.customColumns=e}get formatColumns(){return this.model.formatColumns}set formatColumns(e){this.model.formatColumns=e}get rollupConfig(){return this.rollup}set rollupConfig(e){if(cs.debug("set rollupConfig",e),!this.isRollupAvailable)throw new Error("Rollup Rows are not available");if(Je(e,this.rollup))return;this.rollup=e;let t=Promise.resolve(this.originalModel);Ys(this.originalModel)&&e!=null&&(t=this.originalModel.table.rollup(e).then(n=>Da(n,this.formatter))),this.setNextModel(t)}get selectDistinctColumns(){return this.selectDistinct}set selectDistinctColumns(e){if(cs.debug("set selectDistinctColumns",e),!this.isSelectDistinctAvailable)throw new Error("Select distinct is not available");if(e===this.selectDistinctColumns||e.length===0&&this.selectDistinctColumns.length===0){cs.debug("Ignore same selectDistinctColumns",e);return}this.selectDistinct=e;const t=e.map(s=>this.originalColumns.find(i=>i.name===s)).filter(s=>s!=null);let n=Promise.resolve(this.originalModel);Ys(this.originalModel)&&t.length>0&&(n=this.originalModel.table.selectDistinct(t).then(s=>Da(s,this.formatter))),this.setNextModel(n)}get table(){if(Ys(this.model))return this.model.table}get totalsConfig(){return this.model.totalsConfig}set totalsConfig(e){this.model.totalsConfig=e}get isFilterRequired(){return this.model.isFilterRequired}get isEditable(){return Ke(this.model)&&this.model.isEditable}isEditableRange=(...e)=>Ke(this.model)?this.model.isEditableRange(...e):!1;isFilterable=(...e)=>this.model.isFilterable(...e);setViewport=(e,t,n)=>this.model.setViewport(e,t,n);snapshot=(...e)=>this.model.snapshot(...e);textSnapshot=(...e)=>this.model.textSnapshot(...e);export(){if(F.isTreeTable(this.model))throw new Error("TreeTable has no 'export' property");return this.model.export()}valuesTable=(...e)=>this.model.valuesTable(...e);columnStatistics(e){if(F.isTreeTable(this.model))throw new Error("TreeTable has no 'columnStatistics' function");return this.model.columnStatistics(e)}editValueForCell=(...e)=>Ke(this.model)?this.model.editValueForCell(...e):"";setValueForCell=(...e)=>Ke(this.model)?this.model.setValueForCell(...e):Promise.reject(new Error("Model is not editable"));setValueForRanges=(...e)=>Ke(this.model)?this.model.setValueForRanges(...e):Promise.reject(new Error("Model is not editable"));setValues=(...e)=>Ke(this.model)?this.model.setValues(...e):Promise.resolve();isValidForCell=(...e)=>Ke(this.model)?this.model.isValidForCell(...e):!1;delete=(...e)=>this.model.delete(...e);get pendingDataMap(){return this.model.pendingDataMap}set pendingDataMap(e){this.model.pendingDataMap=e}get pendingRowCount(){return this.model.pendingRowCount}set pendingRowCount(e){this.model.pendingRowCount=e}get pendingDataErrors(){return this.model.pendingDataErrors}commitPending=(...e)=>this.model.commitPending(...e);getColumnIndexByName(e){return this.model.getColumnIndexByName(e)}async seekRow(e,t,n,s,i,o,l){return this.model.seekRow(e,t,n,s,i,o,l)}get isSeekRowAvailable(){return this.model.isSeekRowAvailable}}const UE=HE;class VE{static async makeModel(e,t=new gn){let n=null;return!F.isTreeTable(e)&&e.hasInputTable&&(n=await e.inputTable()),new UE(e,t,n)}}const Vr=VE;class BE{static OPEN="ChartEvent.OPEN";static CLOSE="ChartEvent.CLOSE";static COLUMN_SELECTED="ChartEvent.COLUMN_SELECTED"}const qa=BE;class $E{static SESSION_OPENED="ConsoleEvent.SESSION_OPENED";static SESSION_CLOSED="ConsoleEvent.SESSION_CLOSED";static FOCUS_HISTORY="ConsoleEvent.FOCUS_HISTORY";static SEND_COMMAND="ConsoleEvent.SEND_COMMAND";static SETTINGS_CHANGED="ConsoleEvent.SETTINGS_CHANGED"}const Bt=$E;class WE{static TABLE_CHANGED="InputFilterEvent.TABLE_CHANGED";static COLUMNS_CHANGED="InputFilterEvent.COLUMNS_CHANGED";static FILTERS_CHANGED="InputFilterEvent.FILTERS_CHANGED";static CLEAR_ALL_FILTERS="InputFilterEvent.CLEAR_ALL_FILTERS";static COLUMN_SELECTED="InputFilterEvent.COLUMN_SELECTED";static OPEN_DROPDOWN="InputFilterEvent.OPEN_DROPDOWN";static OPEN_INPUT="InputFilterEvent.OPEN_INPUT";static OPEN_FILTER_SET_MANAGER="InputFilterEvent.OPEN_FILTER_SET_MANAGER"}const Ye=WE;class GE{static OPEN_GRID="IrisGridEvent.OPEN_GRID";static CLOSE_GRID="IrisGridEvent.CLOSE_GRID";static DATA_SELECTED="IrisGridEvent.DATA_SELECTED";static COLUMN_SELECTED="IrisGridEvent.COLUMN_SELECTED";static STATE_CHANGED="IrisGridEvent.STATE_CHANGED";static CREATE_CHART="IrisGridevent.CREATE_CHART"}const cn=GE,Du=Object.freeze({OPEN:"MarkdownEvent.OPEN"});class zE{static CREATE_NOTEBOOK="NotebookEvent.createNotebook";static SELECT_NOTEBOOK="NotebookEvent.selectNotebook";static CLOSE_FILE="NotebookEvent.closeFile";static RENAME="NotebookEvent.rename";static RENAME_FILE="NotebookEvent.renameFile";static REGISTER_FILE="NotebookEvent.registerFile";static SEND_TO_NOTEBOOK="NotebookEvent.sendToNotebook";static UNREGISTER_FILE="NotebookEvent.unregisterFile";static PROMOTE_FROM_PREVIEW="NotebookEvent.promoteFromPreview"}const Pe=zE;class KE{static focus="TabEvent.focus";static blur="TabEvent.blur";static openPQObject="TabEvent.openPQObject";static openControl="TabEvent.openControl";static reload="TabEvent.reload";static clearAllFilters="TabEvent.clearAllFilters"}const Ko=KE;class YE extends w.PureComponent{static defaultProps={additionalActions:[]};constructor(e){super(e),this.handleCloseTab=this.handleCloseTab.bind(this),this.handleCloseTabsRight=this.handleCloseTabsRight.bind(this),this.handleCloseTabsAll=this.handleCloseTabsAll.bind(this)}getAllTabs(){const{glContainer:e}=this.props;return[...e?.tab?.header?.tabs??[]]}handleCloseTab(){const{glContainer:e}=this.props;e.close()}handleCloseTabsAll(){this.getAllTabs().forEach(t=>(t?.contentItem).container?.close())}handleCloseTabsRight(){const{glContainer:e}=this.props,t=this.getAllTabs();for(let n=t.length-1;n>0&&t[n].contentItem?.config?.id!==e.tab?.contentItem?.config?.id;n-=1)(t[n]?.contentItem).container?.close()}canCloseTabsRight(){const{glContainer:e}=this.props,t=this.getAllTabs();let n=!0;for(let s=t.length-1;s>0&&t[s].contentItem?.config?.id!==e.tab?.contentItem?.config?.id;s-=1)if(Boolean(t[s]?.contentItem?.config?.isClosable)){n=!1;break}return n}canCloseAny(){const e=this.getAllTabs();let t=!0;for(let n=e.length-1;n>0;n-=1)if(Boolean(e[n]?.contentItem?.config?.isClosable)){t=!1;break}return t}render(){const{additionalActions:e,glContainer:t}=this.props,n=[...e],s=t.tab?.contentItem?.config?.isClosable;return n.push({title:"Close",order:10,group:se.groups.low,action:this.handleCloseTab,disabled:s===void 0||!s}),n.push(()=>({title:"Close Tabs to Right",order:20,group:se.groups.low,action:this.handleCloseTabsRight,disabled:this.canCloseTabsRight()})),n.push(()=>({title:"Close All",order:30,group:se.groups.low,action:this.handleCloseTabsAll,disabled:this.canCloseAny()})),r.jsx(se,{actions:n})}}const qE=YE;class XE extends w.PureComponent{static defaultProps={isShared:!1,isOwner:!0,itemType:"Item",value:""};constructor(e){super(e),this.handleRenameDialogOpened=this.handleRenameDialogOpened.bind(this),this.handleRenameInputChange=this.handleRenameInputChange.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRenameSubmit=this.handleRenameSubmit.bind(this),this.renameInputRef=ae.createRef();const{value:t}=e;this.state={value:t,valueWasValidated:!1}}componentDidUpdate(e){const{isShown:t}=e,{isShown:n}=this.props;n&&!t&&this.resetState()}renameInputRef;resetState(){const{value:e}=this.props;this.setState({value:e,valueWasValidated:!1})}handleRenameDialogOpened(){this.renameInputRef?.current?.focus()}handleRenameInputChange(e){this.setState({value:e.target.value})}handleRenameCancel(){const{onCancel:e}=this.props;e()}handleRenameSubmit(e){e.stopPropagation(),e.preventDefault();const{value:t}=this.state,n=t?.trim();if(n!==void 0&&n!==""){const{onSubmit:s}=this.props;s(n)}else this.setState({value:n,valueWasValidated:!0})}renderRenameDialog(){const{isShared:e,isOwner:t,itemType:n}=this.props,{value:s,valueWasValidated:i}=this.state;return r.jsxs("form",{className:K("p-3",{"was-validated":i}),onSubmit:this.handleRenameSubmit,noValidate:!0,role:"presentation",onMouseDown:o=>{o.stopPropagation()},onMouseUp:o=>{o.stopPropagation()},children:[r.jsxs("div",{className:"form-group",children:[r.jsxs("label",{htmlFor:`rename-dialog-${n}-input`,children:["Rename ",n]}),r.jsx("input",{type:"text",className:"form-control",id:`rename-dialog-${n}-input`,value:s??void 0,ref:this.renameInputRef,onChange:this.handleRenameInputChange,required:!0}),r.jsxs("div",{className:"invalid-feedback",children:[n," name cannot be empty"]}),(e||!t)&&r.jsxs("div",{className:"pt-2",children:["Renaming this ",n," will rename for all users."]})]}),r.jsxs("div",{className:"text-right",children:[r.jsx(_,{kind:"secondary",className:"mr-2",onClick:this.handleRenameCancel,children:"Cancel"}),r.jsx(_,{kind:"primary",type:"submit",children:"Rename"})]})]})}render(){const{isShown:e,onCancel:t}=this.props;return r.jsx(Ul,{isShown:e,onEntered:this.handleRenameDialogOpened,onExited:t,options:{placement:"bottom"},interactive:!0,closeOnBlur:!0,children:this.renderRenameDialog()})}}const ZE=ee.module("Panel");class QE extends w.PureComponent{static defaultProps={className:"",onTab:()=>{},onTabClicked:()=>{},onClearAllFilters:()=>{},onFocus:()=>{},onBlur:()=>{},onHide:()=>{},onResize:()=>{},onSessionClose:()=>{},onSessionOpen:()=>{},onBeforeShow:()=>{},onShow:()=>{},onTabBlur:()=>{},onTabFocus:()=>{},renderTabTooltip:null,additionalActions:[],errorMessage:null,isLoading:!1,isLoaded:!0,isClonable:!1,isRenamable:!1};constructor(e){super(e),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.handleCopyPanel=this.handleCopyPanel.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleHide=this.handleHide.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleBeforeShow=this.handleBeforeShow.bind(this),this.handleShow=this.handleShow.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRenameSubmit=this.handleRenameSubmit.bind(this),this.handleShowRenameDialog=this.handleShowRenameDialog.bind(this),this.handleTabClicked=this.handleTabClicked.bind(this),this.handleTab=this.handleTab.bind(this);const{glContainer:t}=this.props;this.state={title:$.getTitleFromContainer(t),showRenameDialog:!1}}componentDidMount(){const{componentPanel:e,glContainer:t,glEventHub:n}=this.props;t.on("resize",this.handleResize),t.on("show",this.handleBeforeShow),t.on("shown",this.handleShow),t.on("hide",this.handleHide),t.on("tab",this.handleTab),t.on("tabClicked",this.handleTabClicked),n.on(Bt.SESSION_CLOSED,this.handleSessionClosed),n.on(Bt.SESSION_OPENED,this.handleSessionOpened),n.on(Ko.focus,this.handleTabFocus),n.on(Ko.blur,this.handleTabBlur),n.on(Ye.CLEAR_ALL_FILTERS,this.handleClearAllFilters),n.emit(we.MOUNT,e)}componentWillUnmount(){const{componentPanel:e,glContainer:t,glEventHub:n}=this.props;t.off("resize",this.handleResize),t.off("show",this.handleBeforeShow),t.off("shown",this.handleShow),t.off("hide",this.handleHide),t.off("tab",this.handleTab),t.off("tabClicked",this.handleTabClicked),n.off(Bt.SESSION_CLOSED,this.handleSessionClosed),n.off(Bt.SESSION_OPENED,this.handleSessionOpened),n.off(Ko.focus,this.handleTabFocus),n.off(Ko.blur,this.handleTabBlur),n.off(Ye.CLEAR_ALL_FILTERS,this.handleClearAllFilters),n.emit(we.UNMOUNT,e)}handleTab(e){e!=null&&this.setState({title:$.getTitleFromTab(e)}),this.forceUpdate();const{onTab:t}=this.props;t(e)}handleTabClicked(e){const{onTabClicked:t}=this.props;t(e)}handleClearAllFilters(...e){const{onClearAllFilters:t}=this.props;t(...e)}handleFocus(e){const{componentPanel:t,glEventHub:n}=this.props;n.emit(we.FOCUS,t);const{onFocus:s}=this.props;s(e)}handleBlur(e){const{onBlur:t}=this.props;t(e)}handleHide(...e){const{onHide:t}=this.props;t(...e)}handleResize(...e){const{onResize:t}=this.props;t(...e)}handleSessionClosed(e){const{onSessionClose:t}=this.props;t(e)}handleSessionOpened(e,t){const{onSessionOpen:n}=this.props;n(e,t)}handleBeforeShow(...e){const{onBeforeShow:t}=this.props;t(...e)}handleShow(...e){const{onShow:t}=this.props;t(...e)}handleTabBlur(...e){const{onTabBlur:t}=this.props;t(...e)}handleTabFocus(...e){const{onTabFocus:t}=this.props;t(...e)}handleRenameCancel(){this.setState({showRenameDialog:!1})}handleShowRenameDialog(){this.setState({showRenameDialog:!0})}handleRenameSubmit(e){const{glContainer:t}=this.props;this.setState({showRenameDialog:!1,title:e});const n=$.getRootFromContainer(t),s=$.getComponentConfigFromContainer(t);N(s),$.renameComponent(n,s,e)}handleCopyPanel(){const{glContainer:e,glEventHub:t}=this.props,n=$.getRootFromContainer(e),s=$.getComponentConfigFromContainer(e);if(s==null){ZE.error("Could not get component config from container",e);return}const i=$.cloneComponent(n,s);i!==null&&t.emit(we.CLONED,this,i)}getCloneAction(){return{title:"Copy Panel",order:10,group:se.groups.high,action:this.handleCopyPanel}}getRenameAction(){return{title:"Rename",order:10,group:se.groups.medium,action:this.handleShowRenameDialog}}getAdditionActions=he((e,t,n)=>{const s=[];return t&&s.push(this.getCloneAction()),n&&s.push(this.getRenameAction()),[...s,...e]});render(){const{children:e,className:t,renderTabTooltip:n,glContainer:s,additionalActions:i,errorMessage:o,isLoaded:l,isLoading:a,isClonable:d,isRenamable:h}=this.props,{tab:u}=s,{showRenameDialog:m,title:g}=this.state;return r.jsxs("div",{className:K("h-100 w-100 iris-panel",t),onFocusCapture:this.handleFocus,onBlurCapture:this.handleBlur,children:[e,r.jsx(Vl,{errorMessage:o,isLoaded:l,isLoading:a}),u!=null&&ll.createPortal(r.jsxs(r.Fragment,{children:[r.jsx(qE,{glContainer:s,additionalActions:this.getAdditionActions(i,d,h)}),h&&r.jsx(XE,{isShown:m,value:g,itemType:"Panel",onCancel:this.handleRenameCancel,onSubmit:this.handleRenameSubmit}),n!=null&&r.jsx(tt,{interactive:!0,options:{placement:"bottom"},popperClassName:"panel-tab-popper",children:n()})]}),u.element[0])]})}}const Zn=QE;function na(c){const{widgetType:e,widgetName:t,glContainer:n,description:s,children:i}=c,o=$.getTitleFromContainer(n);return r.jsxs("div",{className:"tab-tooltip-container",children:[r.jsxs("div",{className:"row flex-nowrap align-items-start",children:[r.jsx("span",{className:"tab-tooltip-title",children:r.jsxs("b",{children:[e," Name "]})}),r.jsx("span",{className:"tab-tooltip-name",children:t}),r.jsx(jl,{className:"tab-tooltip-copy",tooltip:"Copy name",copy:t})]}),t!==o&&r.jsxs("div",{className:"row",children:[r.jsx("span",{className:"tab-tooltip-title",children:r.jsx("b",{children:"Display Name"})}),r.jsx("span",{className:"tab-tooltip-name",children:o})]}),s&&r.jsx("div",{className:"row",children:r.jsx("span",{className:"tab-tooltip-description",children:s})}),i]})}na.propTypes={glContainer:Dr.Container.isRequired,widgetType:B.string,widgetName:B.string,description:B.string,children:B.node};na.defaultProps={widgetType:"",widgetName:"",description:null,children:null};class JE extends w.PureComponent{static defaultProps={className:"",errorMessage:null,isClonable:!0,isDisconnected:!1,isLoading:!1,isLoaded:!0,isRenamable:!0,showTabTooltip:!0,widgetName:"Widget",widgetType:"Widget",renderTabTooltip:null,description:"",onFocus:()=>{},onBlur:()=>{},onHide:()=>{},onClearAllFilters:()=>{},onResize:()=>{},onSessionClose:()=>{},onSessionOpen:()=>{},onShow:()=>{},onTabBlur:()=>{},onTabFocus:()=>{},onTabClicked:()=>{}};constructor(e){super(e),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleCopyName=this.handleCopyName.bind(this),this.state={isClientDisconnected:!1,isPanelDisconnected:!1,isWidgetDisconnected:!1,isWaitingForReconnect:!1,isPanelInactive:!1}}handleCopyName(){const{widgetName:e}=this.props;co(e)}getErrorMessage(){const{errorMessage:e}=this.props,{isClientDisconnected:t,isPanelDisconnected:n,isWidgetDisconnected:s,isWaitingForReconnect:i}=this.state;if(e)return`${e}`;if(t&&n&&i)return`Disconnected from server.
|
|
32
|
-
Check your internet connection.`;if(t&&n)return"Disconnected from server.";if(n){const{widgetName:o,widgetType:l}=this.props;return`Variable "${o}" not set.
|
|
33
|
-
${l} does not exist yet.`}if(s){const{widgetName:o}=this.props;return`${o} is unavailable.`}}getCachedRenderTabTooltip=he((e,t,n,s,i)=>e?()=>r.jsx(na,{glContainer:t,widgetType:n,widgetName:s,description:i}):null);handleSessionClosed(...e){const{onSessionClose:t}=this.props;this.setState({isPanelDisconnected:!0,isWaitingForReconnect:!1}),t(...e)}handleSessionOpened(...e){const{onSessionOpen:t}=this.props;t(...e)}render(){const{children:e,className:t,componentPanel:n,isLoaded:s,isLoading:i,glContainer:o,glEventHub:l,isDisconnected:a,isClonable:d,isRenamable:h,showTabTooltip:u,renderTabTooltip:m,widgetType:g,widgetName:p,description:C,onClearAllFilters:f,onHide:S,onFocus:v,onBlur:b,onResize:T,onShow:y,onTabBlur:E,onTabFocus:R,onTabClicked:x}=this.props,{isPanelDisconnected:D,isWidgetDisconnected:L,isPanelInactive:M}=this.state,j=this.getErrorMessage(),A=m??this.getCachedRenderTabTooltip(u,o,g,p,C),W=[{title:`Copy ${g} Name`,group:se.groups.medium,order:20,action:this.handleCopyName}];return r.jsxs(Zn,{className:K(t,{disconnected:D||L||a,inactive:M}),componentPanel:n,glContainer:o,glEventHub:l,onClearAllFilters:f,onHide:S,onFocus:v,onBlur:b,onResize:T,onShow:y,onSessionClose:this.handleSessionClosed,onSessionOpen:this.handleSessionOpened,onTabBlur:E,onTabFocus:R,onTabClicked:x,renderTabTooltip:A,errorMessage:j,isLoaded:s,isLoading:i,isClonable:d,isRenamable:h,additionalActions:W,children:[e,M&&r.jsx("div",{className:"fill-parent-absolute"})]})}}const Br=JE,_t=Object.freeze({DEFAULT:"DEFAULT",LINKER:"LINKER"}),ey=new Map,sa=Object.freeze([]),Fu=(c,e)=>Pt(c,e).columns??sa,ty=(c,e)=>Pt(c,e).filterSets??sa,$r=(c,e)=>Pt(c,e).filters??sa,Wr=(c,e)=>Pt(c,e).tableMap??ey,Gr=(c,e)=>Pt(c,e).isolatedLinkerPanelId,Fi=(c,e)=>Pt(c,e).links??sa,zr=(c,e)=>Pt(c,e).columnSelectionValidator,ny=(c,e)=>Pt(c,e).connection,Qs=(c,e)=>Pt(c,e).sessionWrapper,sy=(c,e)=>t=>t(kn(c,{connection:e})),iy=(c,e)=>t=>t(kn(c,{sessionWrapper:e})),Kr=(c,e)=>t=>t(kn(c,{links:e})),oy=(c,e)=>(t,n)=>{const s=Fi(n(),c),i=e.filter(o=>s.findIndex(l=>Je(l.start,o.start)&&Je(l.end,o.end))<0);return t(Kr(c,s.concat(i)))},ly=(c,e)=>(t,n)=>{const i=Fi(n(),c).filter(o=>!e.includes(o.id));return t(Kr(c,i))},Nu=(c,e)=>t=>t(kn(c,{isolatedLinkerPanelId:e})),ay=(c,e)=>t=>t(kn(c,{columnSelectionValidator:e})),ry=(c,e)=>t=>t(kn(c,{consoleSettings:e})),dy=(c,e)=>t=>t(kn(c,{filterSets:e}));function ku({columnMap:c,inputFilterMap:e,linkedColumnMap:t,onAdd:n,onOpenLinker:s,waitingFilterMap:i,waitingInputMap:o}){const l=w.useMemo(()=>{const g=Array.from(o.keys()),p=g.find(S=>e.get(S)!=null),C=g.find(S=>t.get(S)!=null),f=en.join(g.map(S=>`"${S}"`));return p!=null&&p&&C!=null&&C?`Use a filter control or linked table to set a value for ${f}`:p!=null&&p?`Set a filter control value for ${f}`:`Double click a row in a linked table to set a value for ${f}`},[e,t,o]),a=w.useMemo(()=>Array.from(c.values()),[c]),d=w.useCallback(g=>{g.stopPropagation(),g.preventDefault(),n(Array.from(i.values()))},[n,i]),h=w.useCallback(g=>{g.stopPropagation(),g.preventDefault(),s()},[s]),u=i.size>0,m=!u&&o.size>0;return r.jsx("div",{className:"chart-panel-overlay chart-filter-overlay",children:r.jsxs("div",{className:K("chart-panel-overlay-content chart-filter-overlay-content",{"chart-filter-waiting-filter":u},{"chart-filter-waiting-input":m}),children:[u&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"info-message",children:"This plot requires a filter control to be added to the layout or a table link to be created on the following columns:"}),r.jsx("div",{className:"waiting-filter-list",children:a.map(g=>{const p=i.has(g.name),C=p?vs:lr;return r.jsxs("div",{className:K("waiting-filter-item",{"is-invalid":p}),children:[r.jsx(X,{icon:C}),g.name]},g.name)})}),r.jsxs("div",{children:[r.jsx(cd,{onClick:d,className:"btn-primary",children:"Add Input Filters"}),r.jsx(cd,{onClick:h,className:"btn-primary",children:"Open Linker Tool"})]})]}),m&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"info-message",children:"Waiting for User Input"}),r.jsx("div",{className:"",children:l})]})]})})}ku.propTypes={columnMap:B.instanceOf(Map).isRequired,inputFilterMap:B.instanceOf(Map).isRequired,linkedColumnMap:B.instanceOf(Map).isRequired,onAdd:B.func.isRequired,onOpenLinker:B.func.isRequired,waitingFilterMap:B.instanceOf(Map).isRequired,waitingInputMap:B.instanceOf(Map).isRequired};function ao({columns:c,onColumnSelected:e,onMouseEnter:t,onMouseLeave:n}){return r.jsx("div",{className:"chart-panel-overlay chart-column-selector-overlay",children:r.jsxs("div",{className:K("chart-panel-overlay-content"),children:[r.jsx("div",{className:"info-message",children:"This plot requires a filter control to be added to the layout or a table link to be created on the following columns:"}),r.jsx("div",{className:"waiting-column-select-list",children:c.map(s=>r.jsx(Wc,{className:K("btn-chart-column-selector",ao.makeButtonClassName(s.name)),onClick:()=>e(s.name),onMouseEnter:()=>{t&&t(s)},onMouseLeave:n,disabled:!s.isValid,isLinked:s.isActive,children:s.name},s.name))})]})})}ao.makeButtonClassName=c=>`btn-chart-column-selector-${c}`;ao.defaultProps={onMouseEnter:()=>{},onMouseLeave:()=>{}};function sl(c){return c.settings!==void 0}const kt=ee.module("ChartPanel"),cy=150;function hy(c){return c.inputFilters!=null}function uy(c){return c.panelState!=null}class my extends w.Component{static defaultProps={columnSelectionValidator:null,isLinkerActive:!1,source:null,sourcePanel:null,panelState:null,settings:{}};static displayName="ChartPanel";static COMPONENT="ChartPanel";constructor(e){super(e),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleColumnMouseEnter=this.handleColumnMouseEnter.bind(this),this.handleColumnMouseLeave=this.handleColumnMouseLeave.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleFilterAdd=this.handleFilterAdd.bind(this),this.handleHide=this.handleHide.bind(this),this.handleError=this.handleError.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSettingsChanged=this.handleSettingsChanged.bind(this),this.handleOpenLinker=this.handleOpenLinker.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSourceColumnChange=this.handleSourceColumnChange.bind(this),this.handleSourceFilterChange=this.handleSourceFilterChange.bind(this),this.handleSourceSortChange=this.handleSourceSortChange.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleUpdate=this.handleUpdate.bind(this),this.updateModelFromSource=Ge(this.updateModelFromSource.bind(this),cy),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.panelContainer=ae.createRef(),this.chart=ae.createRef(),this.pending=new Xn;const{metadata:t,panelState:n}=e,{filterValueMap:s=[],settings:i={}}=n??{};this.state={settings:i,error:void 0,isActive:!1,isDisconnected:!1,isLoading:!1,isLoaded:!1,isLinked:t!=null&&sl(t)&&t.settings.isLinked,filterMap:new Map(s),filterValueMap:new Map(s),model:void 0,columnMap:new Map,panelState:n}}componentDidMount(){this.isHidden()||(this.setState({isActive:!0}),this.initModel())}componentDidUpdate(e,t){const{inputFilters:n,source:s}=this.props,{columnMap:i,model:o,filterMap:l,filterValueMap:a,isLinked:d,settings:h}=this.state;o&&(i!==t.columnMap&&this.pruneFilterMaps(),n!==e.inputFilters&&this.updateChangedInputFilters(n,e.inputFilters),l!==t.filterMap?this.updateFilters():a!==t.filterValueMap&&this.updatePanelState(),h!==t.settings&&_d(o)&&(o.updateSettings(h),this.updatePanelState()),d!==t.isLinked?s&&(d?(this.startListeningToSource(s),this.updateModelFromSource()):this.stopListeningToSource(s)):d&&s!==e.source&&(e.source&&this.stopListeningToSource(e.source),s&&(this.startListeningToSource(s),this.updateModelFromSource())))}componentWillUnmount(){this.pending.cancel();const{source:e}=this.props;e&&this.stopListeningToSource(e)}panelContainer;chart;pending;initModel(){this.setState({isLoading:!0,isLoaded:!1,error:void 0});const{makeModel:e}=this.props;this.pending.add(e(),t=>{t.close()}).then(this.handleLoadSuccess,this.handleLoadError)}getWaitingInputMap=he((e,t,n)=>{if(!e)return new Map;const s=new Map(t);return n.forEach((i,o)=>{s.delete(o)}),s});getWaitingFilterMap=he((e,t,n,s,i)=>{if(!e)return new Map;const o=new Map(t);return n.forEach((l,a)=>{o.delete(a)}),i.forEach((l,a)=>{o.delete(a)}),s.forEach((l,a)=>{o.delete(a)}),o});getInputFilterColumnMap=he((e,t)=>{const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],{name:o,type:l}=i,a=e.get(o);a!=null&&a.type===l&&n.set(o,i)}return n});getLinkedColumnMap=he((e,t)=>{const n=new Map,s=$.getIdFromPanel(this);for(let i=0;i<t.length;i+=1){const o=t[i];let l=null;if(o.start!=null&&o.start.panelId===s&&e.has(o.start.columnName)?l=o.start.columnName:o.end&&o.end.panelId===s&&e.has(o.end.columnName)&&(l=o.end.columnName),l!=null&&e.has(l)){const a=e.get(l);N(a),n.set(l,a)}}return n});getSelectorColumns=he((e,t,n)=>Array.from(e.values()).map(s=>({name:s.name,type:s.type,isValid:n?n(this,s):!1,isActive:t.has(s.name)})));startListeningToSource(e){kt.debug("startListeningToSource",e),e.addEventListener(I.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.addEventListener(I.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.addEventListener(I.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}stopListeningToSource(e){kt.debug("stopListeningToSource",e),e.removeEventListener(I.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.removeEventListener(I.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.removeEventListener(I.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}loadModelIfNecessary(){const{isActive:e,isLoaded:t,isLoading:n}=this.state;e&&!t&&!n&&this.initModel()}isHidden(){const{glContainer:e}=this.props,{isHidden:t}=e;return t}handleColumnSelected(e){const{glEventHub:t}=this.props,{columnMap:n}=this.state;t.emit(qa.COLUMN_SELECTED,this,n.get(e))}handleColumnMouseEnter({type:e,name:t}){const{columnSelectionValidator:n}=this.props;kt.debug("handleColumnMouseEnter",n,e,t),n&&n(this,{type:e,name:t})}handleColumnMouseLeave(){const{columnSelectionValidator:e}=this.props;kt.debug("handleColumnMouseLeave",e),e&&e(this,void 0)}handleDisconnect(){this.setState({error:new Error("Figure disconnected"),isDisconnected:!0})}handleFilterAdd(e){for(let t=0;t<e.length;t+=1)this.openInputFilter(e[t])}handleOpenLinker(){const{localDashboardId:e,setActiveTool:t,setDashboardIsolatedLinkerPanelId:n}=this.props;n(e,void 0),t(_t.LINKER)}handleReconnect(){this.setState({isDisconnected:!1,error:void 0}),this.sendColumnChange(),this.updateColumnFilters()}handleLoadSuccess(e){kt.debug("handleLoadSuccess");const{model:t}=this.state;this.setState({model:e,isLoaded:!0},()=>{const{inputFilters:n,source:s}=this.props,{filterMap:i,isLinked:o}=this.state;e!==t&&(this.sendColumnChange(),this.updateColumnFilters(),this.updateInputFilters(n,i.size>0||e.isFilterRequired()),s&&o&&(this.startListeningToSource(s),this.updateModelFromSource()))})}handleLoadError(e){ve.isCanceled(e)||(kt.error("handleLoadError",e),this.setState({error:e,isLoading:!1}))}handleSourceColumnChange(){this.updateModelFromSource()}handleSourceFilterChange(){this.updateModelFromSource()}handleSourceSortChange(){this.updateModelFromSource()}updateModelFromSource(){const{metadata:e,source:t}=this.props,{isLinked:n,model:s}=this.state;if(!n||!s||!t){kt.debug2("updateModelFromSource ignoring",n,s,t);return}if(this.pending.cancel(),sl(e)){const{settings:i}=e;this.pending.add(I.plot.Figure.create(qe.makeFigureSettings(i,t))).then(o=>{_d(s)&&s.setFigure(o)}).catch(this.handleLoadError)}this.updatePanelState()}updatePanelState(){const{sourcePanel:e}=this.props,{panelState:t,filterValueMap:n,settings:s}=this.state;let{tableSettings:i}=t??{};if(e&&hy(e.props)&&uy(e.state)){const{inputFilters:o}=e.props,{panelState:l}=e.state;l!=null&&(i=Ce.extractTableSettings(l,o))}this.setState({panelState:{settings:s,tableSettings:i,filterValueMap:Array.from(n)}})}handleError(){this.setState({isLoading:!1})}handleResize(){this.updateChart()}handleSettingsChanged(e){this.setState(({settings:t})=>{const n={...t,...e};return kt.debug("Updated settings",n),{settings:n}})}handleHide(){this.setActive(!1)}handleShow(){this.setActive(!0)}handleTabBlur(){this.setActive(!1)}handleTabFocus(){const e=this.isHidden();this.setActive(!e)}handleUpdate(){this.setState({isLoading:!1})}handleClearAllFilters(){this.setState({filterValueMap:new Map,filterMap:new Map}),this.updatePanelState()}openInputFilter(e){const{glEventHub:t}=this.props,{name:n,type:s}=e;t.emit(Ye.OPEN_INPUT,{title:`${n} Filter`,panelState:{name:n,type:s,isValueShown:!0},createNewStack:!0,focusElement:"input"})}setActive(e){this.setState({isActive:e},()=>{e&&(this.loadModelIfNecessary(),this.updateChart())})}sendColumnChange(){const{model:e}=this.state;if(!e)return;const{glEventHub:t}=this.props;t.emit(Ye.COLUMNS_CHANGED,this,Array.from(e.getFilterColumnMap().values()))}getCoordinateForColumn(e){const t=ao.makeButtonClassName(e);if(!this.panelContainer.current)return null;const s=this.panelContainer.current.querySelector(`.${t}`)?.getBoundingClientRect()??null;if(s==null||s.width<=0||s.height<=0)return null;const i=s.left+s.width/2,o=s.bottom;return[i,o]}setFilterMap(e){kt.debug("setFilterMap",e),this.setState(t=>{const{columnMap:n,filterMap:s}=t;let i=null;const o=new Map(t.filterValueMap);return e.forEach(({columnType:l,filterList:a},d)=>{const h=n.get(d);if(h==null||h.type!==l)return;if(a.length<1){kt.debug("Ignoring empty filterList for column",d);return}const{value:u}=a[0];o.set(d,u),s.get(d)!==u&&(i===null&&(i=new Map(s)),i.set(d,u))}),{filterValueMap:o,filterMap:i??s}})}unsetFilterValue(e){this.setState(t=>{const{inputFilters:n}=this.props,{columnMap:s}=t;let{filterMap:i,filterValueMap:o}=t;if(!o.has(e))return null;o=new Map(t.filterValueMap),o.delete(e);const l=this.getInputFilterColumnMap(s,n);if(l.has(e)){const a=i.get(e),d=l.get(e)?.value;d!=null&&a!==d&&(i=new Map(t.filterMap),d.length>0?i.set(e,d):i.delete(e))}else i=new Map(t.filterMap),i.delete(e);return{filterMap:i,filterValueMap:o}})}updateChangedInputFilters(e,t){const n=t.filter(i=>e.find(o=>o.name===i.name&&o.type===i.type)===void 0);n.length>0&&this.deleteInputFilters(n);const s=e.filter(i=>!t.includes(i));s.length>0&&this.updateInputFilters(s)}updateInputFilters(e,t=!1){this.setState(n=>{const{columnMap:s}=n,i=new Map(n.filterValueMap),o=new Map(n.filterMap),l=t?{filterMap:o,filterValueMap:i}:{};for(let a=0;a<e.length;a+=1){const{name:d,type:h,value:u}=e[a],m=s.get(d);m!=null&&m.type===h&&(u!=null&&o.get(d)!==u&&(u===""?o.delete(d):o.set(d,u),l.filterMap=o),i.has(d)&&(i.delete(d),l.filterValueMap=i))}return kt.debug("updateInputFilters",l),l})}deleteInputFilters(e,t=!1){this.setState(n=>{const{columnMap:s,filterValueMap:i}=n,o=new Map(n.filterMap);let l=t;for(let a=0;a<e.length;a+=1){const{name:d,type:h}=e[a],u=s.get(d);if(u!=null&&u.type===h&&o.has(d)){const m=o.get(d);if(i.has(d)){const g=i.get(d);g!==m&&g!=null&&(l=!0,o.set(d,g))}else l=!0,o.delete(d)}}return kt.debug("deleteInputFilters",l),l?{filterMap:o}:null})}updateColumnFilters(){this.setState(({model:e})=>e?{columnMap:e.getFilterColumnMap()}:null)}updateFilters(){const{columnMap:e,filterMap:t,model:n}=this.state;N(n);const s=this.getWaitingInputMap(n.isFilterRequired(),e,t);if(n.setFilter(t),t.size>0&&s.size===0){const i=n.getDefaultTitle(),o=en.join(Array.from(t.entries()).map(([l,a])=>`${l}: ${a}`));i?n.setTitle(`${i}<br><span style="font-size: smaller">${o}</span>`):n.setTitle(o),kt.debug2("updateFilters filters set",t),this.setState({isLoading:!0})}else kt.debug2("updateFilters waiting on inputs",s),n.setTitle(n.getDefaultTitle()),this.setState({isLoading:!1});this.updatePanelState()}pruneFilterMaps(){this.setState(e=>{const{columnMap:t}=e,n=new Map(e.filterMap),s=new Map(e.filterValueMap),i={};return e.filterValueMap.forEach((o,l)=>{t.has(l)||(s.delete(l),i.filterValueMap=s)}),e.filterMap.forEach((o,l)=>{t.has(l)||(n.delete(l),i.filterMap=n)}),i})}updateChart(){this.chart.current&&this.chart.current.updateDimensions()}render(){const{columnSelectionValidator:e,glContainer:t,glEventHub:n,inputFilters:s,isLinkerActive:i,links:o,metadata:l,settings:a}=this.props,{columnMap:d,filterMap:h,error:u,model:m,isActive:g,isDisconnected:p,isLoaded:C,isLoading:f}=this.state;let S;sl(l)?S=l.table:S=l.figure;const v=this.getInputFilterColumnMap(d,s),b=this.getLinkedColumnMap(d,o),T=m!=null?this.getWaitingInputMap(m.isFilterRequired(),d,h):new Map,y=m!=null?this.getWaitingFilterMap(m.isFilterRequired(),d,h,b,v):new Map,E=u!=null?`Unable to open chart. ${u}`:void 0,R=T.size>0,x=d.size>0&&i;return r.jsx(Br,{className:K("iris-chart-panel",{"input-required":R}),componentPanel:this,glContainer:t,glEventHub:n,onHide:this.handleHide,onClearAllFilters:this.handleClearAllFilters,onResize:this.handleResize,onShow:this.handleShow,onTabBlur:this.handleTabBlur,onTabFocus:this.handleTabFocus,errorMessage:E,isDisconnected:p,isLoading:f,isLoaded:C,widgetName:S,widgetType:"Chart",children:r.jsxs("div",{ref:this.panelContainer,className:"chart-panel-container h-100 w-100",children:[r.jsx("div",{className:"chart-container h-100 w-100",children:C&&m&&r.jsx(nC,{isActive:g,model:m,settings:a,ref:this.chart,onDisconnect:this.handleDisconnect,onReconnect:this.handleReconnect,onUpdate:this.handleUpdate,onError:this.handleError,onSettingsChanged:this.handleSettingsChanged})}),r.jsx($t,{in:R&&!x&&!f,timeout:Xe.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:r.jsx(ku,{inputFilterMap:v,linkedColumnMap:b,onAdd:this.handleFilterAdd,onOpenLinker:this.handleOpenLinker,columnMap:d,waitingFilterMap:y,waitingInputMap:T})}),r.jsx($t,{in:x,timeout:Xe.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:r.jsx(ao,{columns:this.getSelectorColumns(d,b,e),onColumnSelected:this.handleColumnSelected,onMouseEnter:this.handleColumnMouseEnter,onMouseLeave:this.handleColumnMouseLeave})})]})})}}const gy=(c,e)=>{const{localDashboardId:t,metadata:n}=e;let s;n!=null&&(s=n.sourcePanelId);const i=Wr(c,t),o=iu(c,t),l=Yl(c),a=Gr(c,t),d=l===_t.LINKER&&a===void 0;return{columnSelectionValidator:zr(c,t),isLinkerActive:d,inputFilters:$r(c,t),links:Fi(c,t),source:s!=null?i.get(s):void 0,sourcePanel:s!=null?o.get(s):void 0,settings:pt(c)}},py=gt(gy,{setActiveTool:Xl,setDashboardIsolatedLinkerPanelId:Nu},null,{forwardRef:!0})(my),Ti=py;const Yo=ee.module("CommandHistoryPanel");class Yr extends w.Component{static COMPONENT="CommandHistoryPanel";static TITLE="Command History";static handleError(e){Yo.error(e)}constructor(e){super(e),this.handleFocusHistory=this.handleFocusHistory.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSendToConsole=this.handleSendToConsole.bind(this),this.handleSendToNotebook=this.handleSendToNotebook.bind(this),this.container=ae.createRef(),this.pending=new Xn;const{session:t,sessionId:n,language:s}=e;this.state={panelState:{},session:t,sessionId:n,language:s,contextActions:[{action:this.handleFocusHistory,shortcut:It.COMMAND_HISTORY.FOCUS_HISTORY}]}}componentDidMount(){const{glEventHub:e,session:t}=this.props;e.on(Bt.FOCUS_HISTORY,this.handleFocusHistory),t!=null&&this.loadTable()}componentWillUnmount(){const{glEventHub:e}=this.props;e.off(Bt.FOCUS_HISTORY,this.handleFocusHistory),this.pending.cancel()}container;pending;handleFocusHistory(){this.container.current&&this.container.current.focus()}handleShow(){this.container.current?.restoreScrollPosition()}handleSessionOpened(e,{language:t,sessionId:n}){this.setState({session:e,sessionId:n,language:t},()=>{this.loadTable()})}handleSessionClosed(){this.pending.cancel(),this.setState({session:void 0,language:void 0,table:void 0})}handleSendToNotebook(e,t=!1){const{session:n,language:s}=this.state;if(Yo.debug("handleSendToNotebook",n,e),!n){Yo.error("Session is not connected.");return}const{glEventHub:i}=this.props;i.emit(t?Pe.CREATE_NOTEBOOK:Pe.SEND_TO_NOTEBOOK,n,s,e)}handleSendToConsole(e,t=!0,n=!1){Yo.debug("handleSendToConsole",e);const{glEventHub:s}=this.props;s.emit(Bt.SEND_COMMAND,e,t,n)}loadTable(){const{commandHistoryStorage:e}=this.props,{language:t,sessionId:n}=this.state;N(t),N(n),this.pending.add(e.getTable(t,n,Date.now()),s=>s.close()).then(s=>{this.setState({table:s})}).catch(Yr.handleError)}render(){const{glContainer:e,glEventHub:t,commandHistoryStorage:n}=this.props,{language:s,contextActions:i,table:o}=this.state;return r.jsxs(Zn,{className:"command-history-pane",componentPanel:this,glContainer:e,glEventHub:t,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[!o&&r.jsx("div",{className:"command-history-disconnected-message",children:"Waiting for console connection"}),o&&s!=null&&r.jsxs(r.Fragment,{children:[r.jsx(Uf,{ref:this.container,language:s,sendToNotebook:this.handleSendToNotebook,sendToConsole:this.handleSendToConsole,table:o,commandHistoryStorage:n}),r.jsx(se,{actions:i})]})]})}}const fy=(c,e)=>{const t=Ch(c),n=Qs(c,e.localDashboardId),{session:s,config:i}=n??{},{type:o,id:l}=i??{};return{commandHistoryStorage:t,language:o,session:s,sessionId:l}},Cy=gt(fy,null,null,{forwardRef:!0})(Yr),xl=Cy;const qo=ee.module("ConsolePanel"),Sy=500,by=Object.freeze({consoleSettings:{},itemIds:[]});class wy extends w.PureComponent{static COMPONENT="ConsolePanel";static TITLE="Console";constructor(e){super(e),this.handleFocusCommandHistory=this.handleFocusCommandHistory.bind(this),this.handleOpenObject=this.handleOpenObject.bind(this),this.handleCloseObject=this.handleCloseObject.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSettingsChange=this.handleSettingsChange.bind(this),this.handleShow=this.handleShow.bind(this),this.handlePanelMount=this.handlePanelMount.bind(this),this.consoleRef=ae.createRef();const{panelState:t}=e,n={...by,...t||{}},{consoleSettings:s,itemIds:i}=n;this.state={consoleSettings:s,itemIds:new Map(i),objectMap:new Map,error:void 0,panelState:n}}componentDidMount(){const{glEventHub:e}=this.props;this.closeDisconnectedPanels(),e.on(we.MOUNT,this.handlePanelMount),this.subscribeToFieldUpdates()}componentDidUpdate(e,t){const{consoleSettings:n,itemIds:s}=this.state;(t.consoleSettings!==n||t.itemIds!==s)&&this.savePanelState()}componentWillUnmount(){const{glEventHub:e}=this.props;this.savePanelState.flush(),e.off(we.MOUNT,this.handlePanelMount),this.objectSubscriptionCleanup?.()}consoleRef;objectSubscriptionCleanup;subscribeToFieldUpdates(){const{sessionWrapper:e}=this.props,{session:t}=e;this.objectSubscriptionCleanup=t.subscribeToFieldUpdates(n=>{qo.debug("Got updates",n),this.setState(({objectMap:s})=>{const{updated:i,created:o,removed:l}=n,a=[...i,...l],d=new Map(s);return a.forEach(u=>{const{title:m}=u;m!==void 0&&d.delete(m)}),[...i,...o].forEach(u=>{u.title!==void 0&&d.set(u.title,u)}),{objectMap:d}})})}setItemId(e,t){this.setState(({itemIds:n})=>{const s=new Map(n);return s.set(e,t),{itemIds:s}})}getItemId(e,t=!0){const{itemIds:n}=this.state;let s=n.get(e);return s==null&&t&&(s=ze.generate(),this.setItemId(e,s)),s}handleTabFocus(){this.consoleRef.current?.focus()}handlePanelMount(e){const{itemIds:t}=this.state,n=e?.props?.id,s=e?.props?.metadata?.sourcePanelId;n&&s&&new Set(t.values()).has(s)&&this.setItemId(n,n)}handleFocusCommandHistory(){const{glEventHub:e}=this.props;e.emit(Bt.FOCUS_HISTORY)}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions()}handleOpenObject(e){const{sessionWrapper:t}=this.props,{session:n}=t;this.openWidget(e,n)}handleCloseObject(e){const{title:t}=e;if(t!==void 0){const n=this.getItemId(t,!1),{glEventHub:s}=this.props;s.emit(we.CLOSE,n)}}handleSettingsChange(e){const{glEventHub:t}=this.props;qo.debug("handleSettingsChange",e),this.setState({consoleSettings:e}),t.emit(Bt.SETTINGS_CHANGED,e)}openWidget(e,t){const{glEventHub:n}=this.props,{title:s}=e;N(s);const i=this.getItemId(s),o={fetch:()=>t.getObject(e),panelId:i,widget:e};qo.debug("openWidget",o),n.emit(we.OPEN,o)}addCommand(e,t=!0,n=!1){this.consoleRef.current?.addCommand(e,t,n)}closeDisconnectedPanels(e=!1){const{consoleSettings:t,itemIds:n}=this.state,{isClosePanelsOnDisconnectEnabled:s=!0}=t;if(!s&&!e)return;const i=[...n.values()],{glEventHub:o}=this.props;i.forEach(l=>{o.emit(we.CLOSE,l)}),this.setState({itemIds:new Map})}savePanelState=Ge(()=>{const{consoleSettings:e,itemIds:t}=this.state,n={consoleSettings:e,itemIds:[...t]};qo.debug("Saving panel state",n),this.setState({panelState:n})},Sy);updateDimensions(){this.consoleRef.current?.updateDimensions()}render(){const{commandHistoryStorage:e,glContainer:t,glEventHub:n,sessionWrapper:s,timeZone:i,unzip:o}=this.props,{consoleSettings:l,error:a,objectMap:d}=this.state,{config:h,session:u,connection:m,details:g={}}=s,{workerName:p,processInfoId:C}=g,{id:f,type:S}=h;return r.jsx(Zn,{className:"iris-panel-console",componentPanel:this,glContainer:t,glEventHub:n,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,errorMessage:a!=null?`${a}`:void 0,children:u!=null&&r.jsx(xf,{ref:this.consoleRef,settings:l,session:u,focusCommandHistory:this.handleFocusCommandHistory,openObject:this.handleOpenObject,closeObject:this.handleCloseObject,commandHistoryStorage:e,onSettingsChange:this.handleSettingsChange,language:S,statusBarChildren:r.jsxs(r.Fragment,{children:[r.jsx("div",{children:" "}),r.jsx("div",{children:oh.LANGUAGE_MAP.get(S)}),p!=null&&r.jsxs(r.Fragment,{children:[r.jsx("div",{children:" • "}),p]}),C!=null&&r.jsxs(r.Fragment,{children:[r.jsx("div",{children:" • "}),C,r.jsx("div",{children:" •"})]}),r.jsx("div",{children:" "}),r.jsx("div",{children:r.jsx(iC,{connection:m,defaultUpdateInterval:10*1e3,hoverUpdateInterval:3*1e3,monitorDuration:10*60*1e3})}),r.jsx("div",{children:" "})]}),scope:f,timeZone:i,objectMap:d,unzip:o})})}}const vy=(c,e)=>({commandHistoryStorage:Ch(c),sessionWrapper:Qs(c,e.localDashboardId),timeZone:go(c)}),Ty=gt(vy,null,null,{forwardRef:!0})(wy),fi=Ty;const Xo=ee.module("DropdownFilter"),Ey=150;class Ji extends w.Component{static defaultProps={column:null,disableLinking:!1,isLinkerActive:!1,isLoaded:!1,isValueShown:!1,settingsError:null,source:null,value:"",values:[],onColumnSelected:()=>{},onSourceMouseEnter:()=>{},onSourceMouseLeave:()=>{}};static PLACEHOLDER="Select a value...";static SOURCE_BUTTON_CLASS_NAME="btn-dropdown-filter-selector";static SOURCE_BUTTON_PLACEHOLDER="Select a column";constructor(e){super(e),this.handleColumnChange=this.handleColumnChange.bind(this),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleDropdownKeyPress=this.handleDropdownKeyPress.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.dropdownRef=ae.createRef();const{column:t,isValueShown:n,value:s}=e;this.state={column:t,id:ze(),selectedColumn:t,disableCancel:!n,isValueShown:n,value:s}}componentDidUpdate(e,t){const{source:n,values:s,isLoaded:i}=this.props,{column:o,value:l,isValueShown:a}=this.state;i&&(n!==e.source&&this.sourceUpdated(),s!==e.values&&l!==""&&!s.includes(l)&&this.resetValue(),a!==t.isValueShown&&a&&this.focusInput(),(o!==t.column||l!==t.value||a!==t.isValueShown)&&this.sendUpdate())}componentWillUnmount(){this.sendUpdate.flush()}dropdownRef;getCompatibleColumns=he((e,t)=>e!=null?t.filter(({type:n})=>n!==void 0&&F.isCompatibleType(n,e.columnType)):[]);getColumnOptions=he((e,t)=>{let n=-1;const s=[];return s.push(r.jsx("option",{value:"-1",children:"Select a column"},"placeholder")),e.forEach((i,o)=>{s.push(r.jsx("option",{value:o,children:this.getItemLabel(e,o)},`${i.name}/${i.type}`)),t!==null&&i.name===t.name&&i.type===t.type&&(n=o)}),[s,n]});getSelectedOptionIndex=he((e,t)=>e.indexOf(t));getValueOptions=he(e=>[r.jsx("option",{value:"-1",children:Ji.PLACEHOLDER},"-1"),...e.map((t,n)=>r.jsx("option",{value:n,children:t??"(null)"},`${n}/${t}`))]);getItemLabel=Te((e,t)=>{const{name:n,type:s}=e[t];if(t>0&&e[t-1].name===n||t<e.length-1&&e[t+1].name===n){const i=s.substring(s.lastIndexOf(".")+1);return`${n} (${i})`}return n});handleColumnChange(e){const{value:t}=e.target;if(Xo.debug2("handleColumnChange",t),t!=null&&parseInt(t,10)<0){this.setState({selectedColumn:null});return}const{columns:n,source:s}=this.props,i=this.getCompatibleColumns(s,n);this.setState({selectedColumn:i[parseInt(t,10)]})}handleDropdownKeyPress(e){e.key==="Enter"&&(e.preventDefault(),e.stopPropagation(),Xo.debug2("handleDropdownKeyPress"),this.sendUpdate(),this.sendUpdate.flush())}handleValueChange(e){const{value:t}=e.target,n=parseInt(t,10);let s="";const{values:i}=this.props;n>=0&&n<i.length?s=i[n]:Xo.debug2("Selected default item"),Xo.debug2("handleValueChange",s),this.setState({value:s})}handleSettingsCancel(){this.setState(({column:e})=>({selectedColumn:e,isValueShown:!0}))}handleSettingsSave(){this.setState(({column:e,selectedColumn:t,value:n})=>({column:t,value:e===t?n:"",isValueShown:!0,disableCancel:!1}))}handleSettingsClick(e){e.stopPropagation(),this.showSettings()}handleBackgroundClick(e){e.target!==this.dropdownRef.current&&this.focusInput()}sourceUpdated(){this.setState({column:null,selectedColumn:null,isValueShown:!1,disableCancel:!0,value:""})}showSettings(){const{column:e}=this.state;this.setState({selectedColumn:e,isValueShown:!1})}focusInput(){this.dropdownRef.current?.focus()}resetValue(){this.setState({value:""})}clearFilter(){this.resetValue()}setFilterState({name:e,type:t,value:n,isValueShown:s}){const i=e!=null&&t!=null?{name:e,type:t}:null;this.setState(({value:o,isValueShown:l})=>({column:i,value:n??o,isValueShown:s??l}))}sendUpdate=Ge(()=>{const{onChange:e}=this.props,{column:t,value:n,isValueShown:s}=this.state;e({column:t,isValueShown:s,value:n??void 0})},Ey);render(){const{columns:e,disableLinking:t,isLinkerActive:n,isLoaded:s,source:i,onColumnSelected:o,onSourceMouseEnter:l,onSourceMouseLeave:a,values:d,settingsError:h}=this.props,{column:u,disableCancel:m,id:g,isValueShown:p,selectedColumn:C,value:f}=this.state,S=i===null,v=this.getCompatibleColumns(i,e),b=i!=null,T=i?.columnName??Ji.SOURCE_BUTTON_PLACEHOLDER,y=u!=null?`${u.name} Filter`:null,[E,R]=this.getColumnOptions(v,C),x=this.getValueOptions(d),D=this.getSelectedOptionIndex(d,f),L=!b||C==null,M=p&&!n,j=`source-column-btn-${g}`,A=`filter-column-select-${g}`;return r.jsxs(ir,{className:"dropdown-filter fill-parent-absolute",isFlipped:M,children:[r.jsx("div",{className:"dropdown-filter-settings-card",children:r.jsxs("div",{className:"dropdown-filter-card-content",children:[r.jsxs("div",{className:"dropdown-filter-settings-grid",children:[r.jsx("label",{htmlFor:j,children:"Source Column"}),r.jsx(Wc,{id:j,isLinked:b,onClick:o,onMouseEnter:l,onMouseLeave:a,className:Ji.SOURCE_BUTTON_CLASS_NAME,disabled:t,children:T}),r.jsx("div",{className:"text-muted small",children:"Select a source column for the list by linking to a table."}),r.jsx("label",{htmlFor:A,children:"Filter Column"}),r.jsx("select",{id:A,value:R,className:"custom-select",onChange:this.handleColumnChange,disabled:S,children:E}),r.jsx("div",{className:"text-muted small",children:"Dropdown filter control will apply its filter to all columns matching this name in this dashboard."})]}),h&&r.jsx("div",{className:"error-message text-center",children:h}),b&&r.jsxs("div",{className:"dropdown-filter-settings-buttons",children:[r.jsx(_,{kind:"secondary",type:"button",onClick:this.handleSettingsCancel,disabled:m||p||n,tooltip:n?"Cancel disabled while linker open":void 0,children:"Cancel"}),r.jsx(_,{kind:"primary",type:"button",className:"ml-2",onClick:this.handleSettingsSave,disabled:L||p||n,tooltip:n?"Save disabled while linker open":void 0,children:"Save"})]})]})}),r.jsx("div",{className:"dropdown-filter-value-card",onClick:this.handleBackgroundClick,"data-testid":"dropdown-filter-value-background",children:s&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"dropdown-filter-column",children:r.jsx("div",{className:"dropdown-filter-column-title",children:y})}),r.jsxs("div",{className:"dropdown-filter-card-content",children:[r.jsx("div",{className:"dropdown-filter-value-input d-flex flex-column justify-content-center",children:r.jsx("select",{className:"custom-select",value:D,ref:this.dropdownRef,onChange:this.handleValueChange,onKeyPress:this.handleDropdownKeyPress,title:"Select Value",children:x})}),h&&r.jsx("div",{className:"error-message mt-3 text-center",children:h})]}),r.jsx("div",{className:"dropdown-filter-menu",children:r.jsx(_,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:r.jsx(X,{icon:uo,transform:"grow-4"}),tooltip:"Dropdown Filter Settings"})})]})})]})}}const cc=Ji;const Qe=ee.module("DropdownFilterPanel"),yy=250,Ry=(c,e)=>{const{localDashboardId:t}=e,n=$.getIdFromPanel({props:e}),s=Wr(c,t),i=Fi(c,t),o=Yl(c),l=Gr(c,t),a=o===_t.LINKER&&(l===void 0||l===n),d=o===_t.LINKER&&l!==void 0&&l!==n;return{columns:Fu(c,t),columnSelectionValidator:zr(c,t),isLinkerActive:a,disableLinking:d,settings:pt(c),panelTableMap:s,dashboardLinks:i}},xy=gt(Ry,null,null,{forwardRef:!0});class fs extends w.Component{static displayName="DropdownFilterPanel";static COMPONENT="DropdownFilterPanel";static MAX_TABLE_SIZE=256;static DATETIME_FORMATTER=new lt({showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"});static SOURCE_COLUMN=Object.freeze({name:"FilterSource",type:null});constructor(e){super(e),this.handleChange=Ge(this.handleChange.bind(this),yy),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleSourceFilterChange=this.handleSourceFilterChange.bind(this),this.handleSourceSortChange=this.handleSourceSortChange.bind(this),this.handleSourceSizeChange=this.handleSourceSizeChange.bind(this),this.handleSourceMouseEnter=this.handleSourceMouseEnter.bind(this),this.handleSourceMouseLeave=this.handleSourceMouseLeave.bind(this),this.handleValuesTableUpdate=this.handleValuesTableUpdate.bind(this),this.dropdownFilterRef=ae.createRef(),this.panelContainer=ae.createRef(),this.pending=new Xn;const{panelState:t,settings:n}=e;this.columnFormats=Gn.getColumnFormats(n);const{value:s="",isValueShown:i=!1,name:o,type:l,timestamp:a}=t??{},d=o!=null&&l!=null?{name:o,type:l}:void 0;this.state={column:d,formatter:new gn(this.columnFormats),valuesTable:void 0,valuesColumn:void 0,sourceSize:0,value:s,timestamp:a,values:[],isValueShown:i,wasFlipped:!1,skipUpdate:!1,panelState:t,isDisconnected:!1,isLoading:!1,isLoaded:!1,error:null}}componentDidMount(){this.updateValuesTable();const{dashboardLinks:e,panelTableMap:t}=this.props,{column:n,value:s,timestamp:i}=this.state,o=this.getSourceTable(t,e);if(o!==null&&this.startListeningToSource(o),n!=null){const{name:l,type:a}=n;this.sendUpdate(l,a,s,i)}}componentDidUpdate(e,t){const{dashboardLinks:n,panelTableMap:s,settings:i}=this.props,{valuesTable:o}=this.state,l=this.getSource(n),a=this.getSourceTable(s,n),d=this.getSource(e.dashboardLinks),h=this.getSourceTable(e.panelTableMap,e.dashboardLinks);i!==e.settings&&i!==void 0&&this.updateFormatterSettings(i),o!==t.valuesTable&&t.valuesTable!=null&&(Qe.debug("Table in state modified, closing the old table."),t.valuesTable.close()),(a!==h||l!==d)&&this.updateValuesTable(),a!==h&&(h!==null&&this.stopListeningToSource(h),a!==null&&this.startListeningToSource(a))}componentWillUnmount(){const{dashboardLinks:e,panelTableMap:t}=this.props,{valuesTable:n}=this.state,s=this.getSourceTable(t,e);this.pending.cancel(),s!==null&&this.stopListeningToSource(s),this.cleanup&&this.cleanup(),n?.close()}dropdownFilterRef;panelContainer;pending;cleanup;columnFormats;getCachedValues=Te((e,{type:t,name:n},s)=>t!==void 0&&F.isDateType(t)?e.map(i=>fs.DATETIME_FORMATTER.format(i)):e.map(i=>i!=null&&t!=null?s.getFormattedString(i,t,n):null));getCoordinateForColumn(){if(this.panelContainer.current==null)return null;const t=this.panelContainer.current.querySelector(`.${cc.SOURCE_BUTTON_CLASS_NAME}`)?.getBoundingClientRect()??null;if(t==null||t.width<=0||t.height<=0)return null;const n=t.left+t.width/2,s=t.bottom;return[n,s]}getSettingsErrorMessage(){const{sourceSize:e}=this.state;if(e>fs.MAX_TABLE_SIZE)return`Table too large, must have fewer than ${fs.MAX_TABLE_SIZE} options.`}getPanelErrorMessage(){const{error:e}=this.state;return e!=null?`${e}`:void 0}getCachedPanelLinks=Te((e,t)=>{const n=$.getIdFromPanel(t);return Qe.debug("getCachedPanelLinks",e,n),e.filter(s=>s.end?.panelId===n)});getCachedSource=Te(e=>{Qe.debug("getCachedSource",e);let t;if(e.length>0){const[n]=e;t=n.start,e.length>1&&Qe.error("Filter has more that one link",e)}return t});getCachedSourceTable=Te((e,t)=>{if(Qe.debug("getCachedSourceTable",e,t),t==null)return null;const{panelId:n}=t;return e.get(n)??null});getCachedSourceColumn=Te((e,t)=>(Qe.debug("getCachedSourceColumn",e,t),e==null||t==null?null:e.columns.find(({name:n,type:s})=>n===t.columnName&&s===t.columnType)??null));getSource(e){const t=this.getCachedPanelLinks(e,this);return this.getCachedSource(t)}getSourceTable(e,t){const n=this.getSource(t);return this.getCachedSourceTable(e,n)}getValuesColumn(e,t){const n=this.getSource(t);return this.getCachedSourceColumn(e,n)}startListeningToSource(e){Qe.debug("startListeningToSource"),e.addEventListener(I.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.addEventListener(I.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),e.addEventListener(I.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),e.addEventListener(I.Table.EVENT_DISCONNECT,this.handleDisconnect),e.addEventListener(I.Table.EVENT_RECONNECT,this.handleReconnect)}stopListeningToSource(e){Qe.debug("stopListeningToSource"),e.removeEventListener(I.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.removeEventListener(I.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),e.removeEventListener(I.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),e.removeEventListener(I.Table.EVENT_DISCONNECT,this.handleDisconnect),e.removeEventListener(I.Table.EVENT_RECONNECT,this.handleReconnect)}handleChange({column:e,isValueShown:t=!1,value:n}){const{name:s=void 0,type:i=void 0}=e??{};let o=!0,l=Date.now();this.setState(({panelState:a,timestamp:d,wasFlipped:h,skipUpdate:u})=>{const m=a!=null&&t!==a.isValueShown&&s===a.name&&i===a.type&&n===a.value;return o=(!u&&t&&(!m||!h))??!1,o||(l=d),{panelState:{isValueShown:t,name:s,type:i,value:n,timestamp:l??void 0},timestamp:l,wasFlipped:m,skipUpdate:!1}},()=>{o&&this.sendUpdate(s??null,i,n,l)})}handleDisconnect(){this.setState({error:new Error("Table disconnected"),isDisconnected:!0,isLoading:!1})}handleReconnect(){this.setState({isDisconnected:!1,error:null})}handleSourceFilterChange(){this.applySourceFilters()}handleSourceSortChange(){this.applySourceSorts()}handleSourceSizeChange({detail:e}){this.setState({sourceSize:e})}handleColumnSelected(){Qe.debug("handleColumnSelected");const{glEventHub:e}=this.props;e.emit(Ye.COLUMN_SELECTED,this,fs.SOURCE_COLUMN)}handleClearAllFilters(){this.dropdownFilterRef?.current?.clearFilter()}setPanelState(e,t=!1){const{dashboardLinks:n}=this.props;if(this.getSource(n)==null){Qe.debug("Ignore state update for unlinked filter",e);return}this.setState({skipUpdate:!t}),this.dropdownFilterRef?.current?.setFilterState(e)}sendUpdate(e,t,n,s){const{dashboardLinks:i,glEventHub:o}=this.props,l=this.getSource(i)?.panelId,a=l===null?[]:[l];Qe.debug("sendUpdate",{name:e,type:t,value:n,timestamp:s,excludePanelIds:a}),o.emit(Ye.FILTERS_CHANGED,this,{name:e,type:t,value:n??"=null",timestamp:s,excludePanelIds:a})}updateValuesTable(){const{dashboardLinks:e,panelTableMap:t}=this.props,n=this.getSource(e),s=this.getSourceTable(t,e);if(Qe.debug("updateValuesTable",n,s),this.setState({values:[],valuesTable:void 0,error:null}),n==null){Qe.debug("Filter unlinked."),this.setState({isLoading:!1,isLoaded:!0,isValueShown:!1,sourceSize:0});return}this.setState({isLoading:!0}),s!=null&&(this.setState({isLoaded:!1,sourceSize:s.size}),this.pending.add(s.copy(),i=>i.close()).then(i=>{this.updateViewportListener(i),this.setState({valuesTable:i})}).catch(i=>{ve.isCanceled(i)||(Qe.error(i),this.setState({isLoading:!1,error:i}))}))}applySourceSorts(){const{dashboardLinks:e,panelTableMap:t}=this.props,{valuesTable:n}=this.state,s=this.getSourceTable(t,e);if(Qe.debug("applySourceSorts",s?.sort),n==null||s==null){Qe.debug("Table not initialized");return}const i=[...s.sort];n.applySort(i),this.setViewport(n)}applySourceFilters(){const{dashboardLinks:e,panelTableMap:t}=this.props,{valuesTable:n}=this.state,s=this.getSourceTable(t,e);if(Qe.debug("applySourceFilters",s?.filter),n==null||s==null){Qe.debug("Table not initialized");return}const i=[...s.filter];n.applyFilter(i),this.setViewport(n)}updateViewportListener(e){if(Qe.debug("updateViewportListener",e?.size),this.cleanup&&this.cleanup(),e==null){this.cleanup=void 0;return}this.cleanup=e.addEventListener(I.Table.EVENT_UPDATED,this.handleValuesTableUpdate),this.setViewport(e)}setViewport(e){const{dashboardLinks:t}=this.props,n=this.getValuesColumn(e,t);if(!n){Qe.error("values column is null");return}e.setViewport(0,fs.MAX_TABLE_SIZE-1,[n])}updateFormatterSettings(e){const t=Gn.getColumnFormats(e);Je(this.columnFormats,t)||(this.columnFormats=t,this.setState({formatter:new gn(t)}))}handleValuesTableUpdate({detail:e}){const{rows:t}=e,{dashboardLinks:n}=this.props,{valuesTable:s}=this.state;if(!s){Qe.error("valuesTable is null");return}const i=this.getValuesColumn(s,n);if(!i){Qe.error("Values column not found");return}const o=t.map(l=>l.get(i));this.setState({values:o,isLoading:!1,isLoaded:!0,valuesColumn:i})}handleSourceMouseEnter(){const{columnSelectionValidator:e}=this.props;e&&e(this,fs.SOURCE_COLUMN)}handleSourceMouseLeave(){const{columnSelectionValidator:e}=this.props;e&&e(this,void 0)}render(){const{columns:e,dashboardLinks:t,disableLinking:n,glContainer:s,glEventHub:i,isLinkerActive:o}=this.props,{column:l,formatter:a,isDisconnected:d,isValueShown:h,value:u,values:m,valuesColumn:g,isLoading:p,isLoaded:C}=this.state,f=this.getSource(t),S=this.getSettingsErrorMessage(),v=this.getPanelErrorMessage(),b=C&&g!=null?this.getCachedValues(m,g,a):[];return r.jsx(Br,{errorMessage:v,isLoading:p,isLoaded:C,isDisconnected:d,className:"iris-dropdown-filter-panel",componentPanel:this,glContainer:s,glEventHub:i,onClearAllFilters:this.handleClearAllFilters,widgetName:"Dropdown Filter",widgetType:"DropdownFilter",children:r.jsx("div",{ref:this.panelContainer,className:"dropdown-filter-container h-100 w-100 container",children:r.jsx(cc,{ref:this.dropdownFilterRef,column:l,columns:e,isValueShown:h,isLinkerActive:o,disableLinking:n,isLoaded:C,settingsError:S,source:f,value:u,values:b,onChange:this.handleChange,onColumnSelected:this.handleColumnSelected,onSourceMouseEnter:this.handleSourceMouseEnter,onSourceMouseLeave:this.handleSourceMouseLeave})})})}}const Iy=xy(fs),qs=Iy;function Dn(c){return c.type==="directory"}var Mu=(c=>(c.GROOVY="text/x-groovy",c.PLAIN_TEXT="text/plain",c.PYTHON="text/x-python",c.PYTHON_COMPILED="application/x-python-code",c.SCALA="text/x-scala",c.UNKNOWN="",c))(Mu||{});class $s{static fileExtensionToString(e=""){return e.length===0?"":`.${e}`}static getDepth(e){if(!$s.hasPath(e))throw new Error(`Invalid path provided: ${e}`);return(e.match(/\//g)??[]).length-1}static getExtension(e){const t=this.getBaseName(e).split(".");return t.length>1?t.pop()??"":""}static getBaseName(e){return e.split("/").pop()??""}static getCopyFileName(e){const t=e.lastIndexOf(".");let n=null,s=null;t<0?s=e:(s=e.substring(0,t),n=e.substring(t+1));const i=s?`${s}-copy`:"Copy";return n!==null?`${i}.${n}`:i}static getMimeType(e){switch(this.getExtension(e).toLowerCase()){case"groovy":return"text/x-groovy";case"py":return"text/x-python";case"pyc":return"application/x-python-code";case"scala":return"text/x-scala";case"txt":return"text/plain";default:return""}}static getParent(e){if(!$s.hasPath(e))throw new Error(`Invalid name provided: ${e}`);const t=e.split("/");for(;t.pop()==="";);if(t.length===0)throw new Error(`No parent for path provided: ${e}`);return`${t.join("/")}/`}static getPath(e){if(!$s.hasPath(e))throw new Error(`Invalid filename provided: ${e}`);const t=e.split("/");return t.pop(),`${t.join("/")}/`}static hasPath(e){return e.startsWith("/")}static isPath(e){return e.startsWith("/")&&e.endsWith("/")}static makePath(e){return e.endsWith("/")?e:`${e}/`}static replaceExtension(e,t=""){const n=e.lastIndexOf("."),s=n>-1?e.substring(0,n):e,i=$s.fileExtensionToString(t);return`${s}${i}`}static validateName(e){const t=[".",".."],n=/[\\/\0]/g,s=new Map([["\0","null"]]);if(!e)throw new wi("Name cannot be empty");if(t.includes(e))throw new wi(`"${e}" is a reserved name`);if(n.test(e))throw new wi(`Invalid characters in name: "${e.match(n)?.reduce((i,o)=>i.includes(o)?i:[...i,o],[]).map(i=>s.has(i)?s.get(i):i).join('", "')??""}"`)}static reducePaths(e){const t=e.filter(n=>$s.isPath(n));return e.filter(n=>!t.some(s=>n!==s&&n.startsWith(s)))}static removeRoot(e,t){if(e.length===0)return t;if(!t.startsWith(e))throw new Error(`Filename ${t} does not start with expected root ${e}`);return t.substring(e.length)}static addRoot(e,t){return`${e}${t}`}}const me=$s,qr=26;function Xa(c){return Dn(c)?me.makePath(c.filename):me.getPath(c.filename)}function hc(c,e){if(c.length===0||e==null)throw new Error("No items to move");const t=Xa(e);if(c.some(({filename:n})=>me.getPath(n)===t))throw new Error("File already in the destination folder");if(c.some(n=>Dn(n)&&t.startsWith(me.makePath(n.filename))))throw new Error("Destination folder cannot be a child of a dragged folder");return{files:c,targetPath:t}}function Dy(c){if(Dn(c))return c.isExpanded?Mg:Lg;switch(me.getMimeType(c.basename)){case Mu.PYTHON:return Ag;default:return Og}}function Za(c){const{children:e,draggedItems:t,isDragInProgress:n,isDropTargetValid:s,isSelected:i,item:o,itemIndex:l,dropTargetItem:a,onDragStart:d,onDragOver:h,onDragEnd:u,onDrop:m}=c,g=t?.some(E=>E.id===o.id)??!1,p=Xa(o),C=n&&a?Xa(a):null,f=n&&s&&Dn(o)&&C===p,S=n&&s&&C===p,v=n&&!s&&C===p,b=Dy(o),T=me.getDepth(o.filename),y=Array(T).fill(null).map((E,R)=>r.jsx("span",{className:"file-list-depth-line"},R));return r.jsxs("div",{className:K("d-flex w-100 align-items-center","file-list-item",{"is-dragged":g,"is-exact-drop-target":f,"is-in-drop-target":S,"is-invalid-drop-target":v,"is-selected":i}),onDragStart:E=>d(l,E),onDragOver:E=>h(l,E),onDragEnd:E=>u(l,E),onDrop:E=>m(l,E),draggable:!0,role:"presentation","aria-label":o.basename,children:[y," ",r.jsx(X,{icon:b,className:"item-icon",fixedWidth:!0})," ",r.jsxs("span",{className:"truncation-wrapper",children:[e??o.basename,r.jsx(tt,{options:{placement:"left"},children:e??o.basename})]})]})}const Rt=ee.module("FileList"),Fy=500,uc="item-list-scroll-pane";function Ny(c){const{isMultiSelect:e=!1,table:t,onFocusChange:n=()=>{},onMove:s,onSelect:i,onSelectionChange:o=()=>{},renderItem:l=Za,rowHeight:a=qr,overscanCount:d=Ei.DEFAULT_OVERSCAN}=c,[h,u]=w.useState(()=>({items:[],offset:0,itemCount:0})),[m,g]=w.useState({top:0,bottom:0}),[p,C]=w.useState(),[f,S]=w.useState(),[v,b]=w.useState(),[T,y]=w.useState([]),E=w.useRef(null),R=w.useRef(null),x=w.useCallback(q=>{if(q.length===0||h==null)return[];const ie=[];for(let fe=0;fe<q.length;fe+=1){const Re=q[fe];for(let xe=Re[0];xe<=Re[1];xe+=1)xe>=h.offset&&xe<h.offset+h.items.length&&ie.push(h.items[xe-h.offset])}return ie},[h]),D=w.useCallback(q=>{const ie=x([[q,q]]);if(ie.length>0)return ie[0]},[x]),L=w.useCallback(()=>{const q=hd.count(T);if(q===0)return null;if(q===1){const ie=T[0][0],fe=D(ie);if(fe!=null)return fe.filename}return`${q} items`},[D,T]),M=w.useCallback(q=>{if(!(!f||!p)){Rt.debug("dropItems",f,"to",q);try{const{files:ie,targetPath:fe}=hc(f,p);s?.(ie,fe),q!=null&&(y([[q,q]]),E.current?.focusItem(q))}catch(ie){Rt.error("Unable to complete move",ie)}}},[f,p,s]),j=w.useCallback((q,ie)=>{const fe=h.items[q-h.offset];fe!==void 0&&(Rt.debug("handleItemClick",fe),i(fe,ie),Dn(fe)&&t?.setExpanded(fe.filename,!fe.isExpanded))},[h,i,t]),A=w.useCallback((q,ie)=>{Rt.debug2("handleItemDragStart",q,T);let fe=T;hd.isSelected(T,q)||(fe=[[q,q]],y(fe)),S(x(fe)),E.current?.resetMouseState();const Re=document.createElement("div");Re.innerHTML=`<div class="dnd-placeholder-content">${L()}</div>`,Re.className="file-list-dnd-placeholder",document.body.appendChild(Re),ie.dataTransfer.setDragImage(Re,0,0),ie.dataTransfer.effectAllowed="move",b(Re)},[L,x,T]),W=w.useCallback((q,ie)=>{ie.preventDefault(),Rt.debug2("handleItemDragOver",ie),C(D(q))},[D]),H=w.useCallback((q,ie)=>{Rt.debug("handleItemDragEnd",q),v?.remove(),S(void 0),C(void 0),b(void 0)},[v]),U=w.useCallback((q,ie)=>{M(q)},[M]),P=w.useCallback(()=>{Rt.debug2("handleItemDragExit"),C(void 0)},[]),Q=w.useCallback(q=>{q.target instanceof Element&&q.target.classList.contains(uc)&&(q.preventDefault(),Rt.debug2("handleListDragOver",q),C({type:"directory",filename:"/",basename:"/",id:"/"}))},[]),G=w.useCallback(q=>{q.target instanceof Element&&q.target.classList.contains(uc)&&(Rt.debug("handleListDrop"),M())},[M]),ne=w.useCallback(q=>{if(Rt.debug2("handleSelectionChange",q),q!==T){y(q);const ie=x(q);o(ie)}},[x,o,T]),V=w.useCallback(q=>{if(Rt.debug2("handleFocusChange",q),q!=null){const[ie]=x([[q,q]]);n(ie)}else n()},[x,n]),z=w.useCallback((q,ie)=>{Rt.debug("handleViewportChange",q,ie),(q!==m.top||ie!==m.bottom)&&g({top:q,bottom:ie})},[m]),Z=w.useMemo(()=>{if(!f||!p)return!1;try{return hc(f,p),Rt.debug("handleValidateDropTarget true"),!0}catch{return Rt.debug("handleValidateDropTarget false"),!1}},[f,p]),{focusedPath:oe}=c;w.useEffect(()=>{oe!==void 0&&(oe==="/"?t.collapseAll():(t.setExpanded(oe,!1),t.setExpanded(oe,!0)))},[t,oe]),w.useEffect(function(){Rt.debug("updating table viewport",m),t?.setViewport({top:Math.max(0,m.top-d),bottom:m.bottom+d})},[d,t,m]),w.useEffect(function(){const ie=t.onUpdate(fe=>{u({items:fe.items.map(Re=>({...Re,itemName:Re.basename})),offset:fe.offset,itemCount:t.size})});return()=>{ie()}},[t]),w.useEffect(function(){if(p!=null&&Dn(p)&&p.filename!=="/"){const ie=setTimeout(()=>{p.isExpanded||t?.setExpanded(p.filename,!0)},Fy);return()=>clearTimeout(ie)}},[p,t]);const re=w.useCallback(q=>l({...q,isDragInProgress:f!=null,dropTargetItem:p,draggedItems:f,isDropTargetValid:Z,onDragStart:A,onDragEnd:H,onDragOver:W,onDragExit:P,onDrop:U}),[H,P,W,A,U,f,p,Z,l]);return r.jsx("div",{ref:R,className:K("file-list",{"is-dragging":f!=null}),onDragOver:Q,onDrop:G,children:r.jsx(Ei,{ref:E,items:h.items,itemCount:h.itemCount,offset:h.offset,onFocusChange:V,onSelect:j,onSelectionChange:ne,onViewportChange:z,selectedRanges:T,renderItem:re,rowHeight:a,isMultiSelect:e,isDragSelect:!1,isDeselectOnClick:!1})})}const ky={name:"File Explorer",DELETE:Ve.createAndAdd({id:"FILE_EXPLORER.DELETE",name:"Delete",shortcut:[Ee.DELETE],macShortcut:[Se.CMD,Ee.BACKSPACE]}),RENAME:Ve.createAndAdd({id:"FILE_EXPLORER.RENAME",name:"Rename",shortcut:[Ee.ENTER],macShortcut:[Ee.ENTER]})},mc={FILE_EXPLORER:ky};const gc=ee.module("FileListItemEditor"),My=()=>Promise.resolve();function Ly({item:c,onCancel:e,onSubmit:t,validate:n=My}){const s=w.useRef(null),[i,o]=w.useState(c.basename),[l,a]=w.useState(),[d,h]=w.useState(Promise.resolve()),u=w.useCallback(()=>{s.current?.focus()},[s]),m=w.useCallback(S=>S.stopPropagation(),[]),g=w.useCallback(()=>{d.then(()=>{t(i)}).catch(S=>gc.info("Unable to validate name",S))},[t,i,d]);w.useEffect(function(){const v=ve.makeCancelable(n(i));return v.then(()=>a(void 0)).catch(b=>{ve.isCanceled(b)||a(b)}),h(v),()=>v.cancel()},[n,i]),w.useEffect(function(){u()},[u]);const p=w.useCallback(()=>{gc.debug2("handleBlur"),g()},[g]),C=w.useCallback(S=>{const{value:v}=S.target;o(v)},[]),f=w.useCallback(S=>{S.stopPropagation();const{key:v}=S;switch(v){case"Enter":{g();break}case"Escape":{e();break}}},[e,g]);return r.jsxs("div",{className:"file-list-item-editor",children:[r.jsx("input",{type:"text",className:K("form-control file-list-item-editor-input",{"is-invalid":l}),value:i,ref:s,onBlur:p,onKeyDown:f,onChange:C,onClick:m,onDoubleClick:m,onMouseDown:m}),l&&r.jsx("div",{className:"invalid-feedback",children:`${l}`})]})}function Lu(c){const{isMultiSelect:e=!1,focusedPath:t,showContextMenu:n=!1,onCreateFile:s,onCreateFolder:i,onCopy:o,onDelete:l,onMove:a,onRename:d,onSelect:h,onSelectionChange:u,table:m,rowHeight:g=qr,validateRename:p=()=>Promise.resolve()}=c,[C,f]=w.useState(),[S,v]=w.useState([]),[b,T]=w.useState(),y=w.useCallback(P=>{v(P),u?.(P)},[u]),E=w.useCallback(P=>{T(P)},[]),R=w.useCallback(()=>{b&&o?.(b)},[b,o]),x=w.useCallback(()=>{S.length>0&&l?.(S)},[l,S]),D=w.useCallback(()=>{s?.()},[s]),L=w.useCallback(()=>{b&&i?.(me.getPath(b.filename))},[b,i]),M=w.useCallback(()=>{b&&f(b)},[b]),j=w.useCallback(()=>{f(void 0)},[]),A=w.useCallback(P=>{C&&(d?.(C,P),f(void 0))},[d,C]),W=w.useMemo(()=>{if(C)return[];const P=[];return s&&P.push({title:"New File",description:"Create new file",action:D,group:se.groups.medium}),i&&P.push({title:"New Folder",description:"Create new folder",action:L,group:se.groups.medium}),o&&P.push({title:"Copy",description:"Copy",action:R,group:se.groups.low,disabled:b==null||Dn(b)}),l&&S.length>0&&P.push({title:"Delete",description:"Delete",shortcut:mc.FILE_EXPLORER.DELETE,action:x,group:se.groups.low}),d&&P.push({title:"Rename",description:"Rename",shortcut:mc.FILE_EXPLORER.RENAME,action:M,group:se.groups.low,disabled:b==null}),P},[R,x,D,L,M,b,o,s,i,l,d,S,C]),H=w.useCallback(P=>(N(C),p(C,P)),[C,p]),U=w.useCallback(P=>{const{item:Q}=P;return C&&C.filename===Q.filename?r.jsx(Za,{...P,children:r.jsx(Ly,{item:Q,validate:H,onSubmit:A,onCancel:j})}):r.jsx(Za,{...P})},[j,A,C,H]);return r.jsxs("div",{className:"file-list-container",children:[m!=null&&r.jsx(Ny,{onMove:a,onSelect:h,onSelectionChange:y,onFocusChange:E,renderItem:U,rowHeight:g,table:m,isMultiSelect:e,focusedPath:t}),n&&r.jsx(se,{actions:W})]})}Lu.displayName="FileListContainer";class Oy extends wi{isExistingFile=!0;info;constructor(e){super("Name already exists"),this.info=e}}const il=Oy;class Ay extends Error{constructor(){super("No file exists at the path specified")}isFileNotFound=!0}const Xr=Ay,_s=ee.module("FileExplorer");function Zr(c){const{storage:e,isMultiSelect:t=!1,focusedPath:n,onDelete:s=()=>{},onRename:i=()=>{},onSelect:o,onSelectionChange:l,rowHeight:a=qr}=c,[d,h]=w.useState([]),[u,m]=w.useState();w.useEffect(function(){let R;async function x(){_s.debug("initTable"),R=ve.makeCancelable(e.getTable(),D=>D.close());try{m(await R)}catch(D){ve.isCanceled(D)||_s.error("Unable to initialize table",D)}}return x(),()=>{R.cancel()}},[e]);const g=w.useCallback(E=>{ve.isCanceled(E)||_s.error(E)},[]),p=w.useCallback(E=>{_s.debug("handleDelete, pending confirmation",E),h(E)},[]),C=w.useCallback(()=>{_s.debug("handleDeleteConfirm",d),d.forEach(E=>e.deleteFile(Dn(E)?me.makePath(E.filename):E.filename)),s(d),h([])},[d,s,e]),f=w.useCallback(()=>{_s.debug("handleDeleteCancel"),h([])},[]),S=w.useCallback((E,R)=>{me.reducePaths(E.map(D=>Dn(D)?me.makePath(D.filename):D.filename)).forEach(D=>{const L=me.isPath(D)?`${R}${me.getBaseName(D.substring(0,D.length-1))}/`:`${R}${me.getBaseName(D)}`;e.moveFile(D,L).then(()=>{i(D,L)}).catch(g)})},[g,i,e]),v=w.useCallback((E,R)=>{let x=E.filename;const D=Dn(E);D&&!x.endsWith("/")&&(x=`${x}/`);let L=`${me.getParent(x)}${R}`;D&&!L.endsWith("/")&&(L=`${L}/`),_s.debug2("handleRename",x,L),e.moveFile(x,L).catch(g),i(x,L)},[g,i,e]),b=w.useCallback(async(E,R)=>{if(R===E.basename)return;me.validateName(R);const x=`${me.getPath(E.filename)}${R}`;try{const D=await e.info(x);throw new il(D)}catch(D){if(!(D instanceof Xr))throw D}},[e]),T=d.length>0,y=w.useMemo(()=>d.length===1?`Are you sure you want to delete "${d[0].filename}"?`:"Are you sure you want to delete the selected files?",[d]);return r.jsxs("div",{className:"file-explorer",children:[u&&r.jsx(Lu,{isMultiSelect:t,focusedPath:n,showContextMenu:!0,onMove:S,onDelete:p,onRename:v,onSelect:o,onSelectionChange:l,rowHeight:a,table:u,validateRename:b}),r.jsx(io,{isOpen:T,headerText:y,bodyText:"You cannot undo this action.",onCancel:f,onConfirm:C,confirmButtonText:"Delete"})]})}Zr.displayName="FileExplorer";const Ps=ee.module("NewItemModal");class eo extends w.PureComponent{static propTypes={isOpen:B.bool,title:B.string.isRequired,defaultValue:B.string,type:B.oneOf(["file","directory"]).isRequired,onSubmit:B.func,onCancel:B.func,placeholder:B.string,storage:B.shape({}).isRequired,notifyOnExtensionChange:B.bool};static defaultProps={isOpen:!1,defaultValue:"/",notifyOnExtensionChange:!1,placeholder:"",onSubmit:(e,t)=>{},onCancel:()=>{}};static getValidationMessage(e){return e instanceof il&&e.info.type==="directory"?"Error: Cannot overwrite existing directory":`${e}`}static handleError(e){ve.isCanceled(e)||Ps.error(e)}constructor(e){super(e),this.handleModalSubmit=this.handleModalSubmit.bind(this),this.handleModalOpened=this.handleModalOpened.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleChange=this.handleChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleValidationError=this.handleValidationError.bind(this),this.handleOverwriteCancel=this.handleOverwriteCancel.bind(this),this.handleOverwriteConfirm=this.handleOverwriteConfirm.bind(this),this.handleExtensionChangeCancel=this.handleExtensionChangeCancel.bind(this),this.handleExtensionChangeConfirm=this.handleExtensionChangeConfirm.bind(this),this.handleBreadcrumbSelect=this.handleBreadcrumbSelect.bind(this);const{defaultValue:t}=e,n=me.hasPath(t)?me.getPath(t):"/";this.state={isSubmitting:!1,path:n,prevExtension:me.getExtension(t),showExtensionChangeModal:!1,showOverwriteModal:!1,value:me.getBaseName(t)}}componentDidUpdate(e,t){const{isOpen:n}=this.props,{isOpen:s}=e,{value:i,path:o}=this.state;!s&&n&&(this.resetValue(),this.isInitialLoad=!0),s&&n&&(!this.isInitialLoad&&(o!==t.path||i!==t.value)&&this.updateValidationStatus(o,i),this.isInitialLoad=!1)}componentWillUnmount(){this.pending.cancel(),this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableExistingItemPromise&&this.cancelableExistingItemPromise.cancel()}inputRef=ae.createRef();cancelableValidatePromise;cancelableExistingItemPromise;pending=new Xn;pathMap=new Map;isInitialLoad=!0;resetValue(){const{defaultValue:e}=this.props,t=me.hasPath(e)?me.getPath(e):"/";this.setState({path:t,value:me.getBaseName(e),validationError:void 0,prevExtension:me.getExtension(e),isSubmitting:!1})}getValidationPromise(e,t,n=!1){return this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableValidatePromise=ve.makeCancelable(this.validateName(e,t,n)),this.cancelableValidatePromise}async validateName(e,t,n){me.validateName(t);const{defaultValue:s,storage:i}=this.props;if(n){const o=`${e}${t}`;if(o!==s)try{const l=await i.info(o);throw new il(l)}catch(l){if(!(l instanceof Xr))throw l}}return t}updateValidationStatus(e,t){this.getValidationPromise(e,t).then(()=>{this.setState({validationError:void 0})}).catch(this.handleValidationError).catch(eo.handleError)}handleModalOpened(){this.focusRenameInput()}handleModalSubmit(){this.submitModal()}handleChange(e){const{value:t}=e.target;this.setState({value:t})}handleSelect(e){if(Ps.debug("handleSelect",e),e.type==="directory")this.setState({path:me.makePath(e.filename)});else{const t=e.basename,n=me.getPath(e.filename);this.setState({value:t,path:n},()=>{this.focusRenameInput()})}}handleKeyDown(e){const{key:t}=e;switch(e.stopPropagation(),t){case"Enter":{e.preventDefault(),this.submitModal();break}case"Escape":{e.preventDefault();const{onCancel:n}=this.props;n();break}}}handleValidationError(e){if(!(e instanceof wi))throw e;Ps.debug("Validation error",e),this.setState({validationError:e})}handleOverwriteCancel(){this.setState({showOverwriteModal:!1,isSubmitting:!1})}handleOverwriteConfirm(){this.setState({showOverwriteModal:!1});const{onSubmit:e}=this.props,{path:t,value:n}=this.state;Ps.debug("handleOverwriteConfirm",t,n),e(`${t}${n}`,!0)}handleExtensionChangeCancel(){Ps.debug("handleExtensionChangeCancel"),this.setState(({value:e,prevExtension:t})=>({showExtensionChangeModal:!1,value:me.replaceExtension(e,t)})),this.submitModal(!0)}handleExtensionChangeConfirm(){Ps.debug("handleExtensionChangeConfirm"),this.setState({showExtensionChangeModal:!1}),this.submitModal(!0)}focusRenameInput(){const e=this.inputRef.current;if(e){const{type:t}=this.props,{value:n}=e,s=t==="directory"?n.length:n.lastIndexOf(".");e.focus(),e.setSelectionRange(0,s>0?s:n.length)}}submitModal(e=!1){this.setState(({prevExtension:t,value:n,path:s})=>{const{notifyOnExtensionChange:i,type:o}=this.props;Ps.debug("submitModal",t,n);const l=me.getExtension(n);return i&&!e&&t!==null&&t!==l?{isSubmitting:!1,showExtensionChangeModal:!0,newExtension:l}:(this.getValidationPromise(s,n,!0).then(a=>{const{onSubmit:d}=this.props;d(`${s}${n}`)}).catch(a=>{if(a instanceof il&&o!=="directory"&&a.info.type!=="directory"){this.setState({showOverwriteModal:!0});return}throw a}).catch(a=>{throw ve.isCanceled(a)&&this.setState({isSubmitting:!1}),a}).catch(this.handleValidationError).catch(eo.handleError),{isSubmitting:!0,showExtensionChangeModal:!1,newExtension:void 0})})}handleBreadcrumbSelect(e){this.setState({path:e})}renderPathButtons(e){const t=e.split("/");return t.pop(),t.map((n,s)=>{let i="";for(let o=0;o<s;o+=1)i+=`${t[o]}/`;return i+=`${n}/`,r.jsxs(ae.Fragment,{children:[r.jsx(_,{kind:"ghost",className:"directory-breadcrumbs",onClick:()=>this.handleBreadcrumbSelect(i),"aria-label":s===0?"Home":void 0,icon:s===0?r.jsx(X,{icon:_g,transform:"right-1.6"}):void 0,tooltip:s===0?"Home":void 0,children:n}),"/"]},i)})}render(){const{storage:e,isOpen:t,onCancel:n,placeholder:s,title:i,type:o}=this.props,{isSubmitting:l,path:a,showExtensionChangeModal:d,showOverwriteModal:h,validationError:u,value:m,prevExtension:g,newExtension:p}=this.state,C=o==="directory",f=me.fileExtensionToString(g),S=me.fileExtensionToString(p),v=C?"Create":"Save",b=C?"New folder name":"Save file as";return r.jsxs(r.Fragment,{children:[r.jsxs($l,{isOpen:t,toggle:n,onOpened:this.handleModalOpened,className:"modal-dialog-centered new-file-modal theme-bg-dark",children:[r.jsx(Wl,{toggle:n,children:i}),r.jsx(Gl,{children:r.jsx("form",{children:r.jsxs("div",{className:"d-flex flex-column new-file-modal-content",children:[r.jsxs("div",{className:"flex-grow-0 mb-4",children:[r.jsx("label",{htmlFor:"file-name-input",children:b}),r.jsx("input",{id:"file-name-input",type:"text",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:"false",className:K("form-control",{"is-invalid":u}),value:m,placeholder:s,ref:this.inputRef,onKeyDown:this.handleKeyDown,onChange:this.handleChange}),u&&r.jsx("div",{className:"invalid-feedback",children:eo.getValidationMessage(u)})]}),r.jsxs("div",{className:"flex-grow-0",children:[r.jsx("label",{children:"Directory: /"}),this.renderPathButtons(a)]}),r.jsx("div",{className:"flex-grow-1 file-explorer-container",children:r.jsx(Zr,{onSelect:this.handleSelect,storage:e,focusedPath:a})})]})})}),r.jsxs(Gc,{children:[r.jsx(_,{kind:"secondary",onClick:n,children:"Cancel"}),r.jsx(_,{kind:"primary",disabled:l,onClick:this.handleModalSubmit,children:v})]})]}),r.jsx(io,{isOpen:h,headerText:"Confirm overwrite",bodyText:"File with this name already exists, are you sure you want to overwrite it?",onCancel:this.handleOverwriteCancel,onConfirm:this.handleOverwriteConfirm,cancelButtonText:"Cancel",confirmButtonText:"Overwrite"}),r.jsx(io,{isOpen:d,headerText:"Confirm extension change",bodyText:`Are you sure you want to change extension from "${f}" to "${S}"?`,onCancel:this.handleExtensionChangeCancel,onConfirm:this.handleExtensionChangeConfirm,cancelButtonText:`Keep "${f}"`,confirmButtonText:`Use "${S}"`})]})}}const Ou=eo;function _y({createFile:c,createFolder:e,onSearchChange:t,defaultSearchText:n=""}){return r.jsxs("div",{className:"file-explorer-toolbar",children:[r.jsxs("div",{className:"file-explorer-toolbar-buttons",children:[r.jsx(_,{kind:"ghost",icon:Xc,tooltip:"New notebook",onClick:c,"aria-label":"New notebook"}),r.jsx(_,{kind:"ghost",icon:Pg,tooltip:"New folder",onClick:e,"aria-label":"New folder"})]}),t&&r.jsx("div",{className:"file-explorer-toolbar-search",children:r.jsx(km,{value:n,onChange:t,placeholder:"Search by name"})})]})}const di=ee.module("FileExplorerPanel"),Py=(c,e)=>{const t=Sh(c),n=Qs(c,e.localDashboardId),{session:s,config:i}=n??{},o=i?.type;return{fileStorage:t,language:o,session:s}},jy=gt(Py,null,null,{forwardRef:!0});function Hy(c){const e=c;return e!=null&&typeof e.button=="number"}class Il extends ae.Component{static COMPONENT="FileExplorerPanel";static TITLE="File Explorer";static handleError(e){di.error(e)}static isFocusEvent(e){return Hy(e)?e.detail>=2:!0}constructor(e){super(e),this.handleFileSelect=this.handleFileSelect.bind(this),this.handleCreateFile=this.handleCreateFile.bind(this),this.handleCreateDirectory=this.handleCreateDirectory.bind(this),this.handleCreateDirectoryCancel=this.handleCreateDirectoryCancel.bind(this),this.handleCreateDirectorySubmit=this.handleCreateDirectorySubmit.bind(this),this.handleDelete=this.handleDelete.bind(this),this.handleRename=this.handleRename.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSelectionChange=this.handleSelectionChange.bind(this);const{session:t,language:n}=e;this.state={isShown:!1,language:n,session:t,showCreateFolder:!1,focusedFilePath:"/"}}componentDidMount(){this.isHidden()||this.setState({isShown:!0})}handleCreateFile(){const{glEventHub:e}=this.props,{session:t,language:n}=this.state,s={language:n,value:""};di.debug("handleCreateFile",t,n,s),e.emit(Pe.CREATE_NOTEBOOK,t,n,s)}handleCreateDirectory(e){this.setState({showCreateFolder:!0})}handleCreateDirectoryCancel(){di.debug("handleCreateDirectoryCancel"),this.setState({showCreateFolder:!1})}handleCreateDirectorySubmit(e){di.debug("handleCreateDirectorySubmit",e),this.setState({showCreateFolder:!1});const{fileStorage:t}=this.props;t.createDirectory(e).catch(Il.handleError)}handleDelete(e){const{glEventHub:t}=this.props;e.forEach(n=>{t.emit(Pe.CLOSE_FILE,{id:n.filename,itemName:n.filename})})}handleSelectionChange(e){let t="/";e.length===1&&(e[0].type==="directory"?t=me.makePath(e[0].filename):t=me.getPath(e[0].filename)),this.setState({focusedFilePath:t})}handleFileSelect(e,t){if(di.debug("fileSelect",e),e.type==="directory")return;const n=Il.isFocusEvent(t),s={id:e.filename,itemName:e.filename},{glEventHub:i}=this.props,{session:o,language:l}=this.state,a={value:null,language:l};i.emit(Pe.SELECT_NOTEBOOK,o,l,a,s,n)}handleRename(e,t){const{glEventHub:n}=this.props;di.debug("handleRename",e,t),n.emit(Pe.RENAME_FILE,e,t)}handleSessionOpened(e,{language:t}){this.setState({session:e,language:t})}handleSessionClosed(){this.setState({session:void 0,language:void 0})}handleShow(){this.setState({isShown:!0})}isHidden(){const{glContainer:e}=this.props,{isHidden:t}=e;return t}render(){const{fileStorage:e,glContainer:t,glEventHub:n}=this.props,{isShown:s,showCreateFolder:i,focusedFilePath:o}=this.state;return r.jsxs(Zn,{className:"file-explorer-panel",componentPanel:this,glContainer:t,glEventHub:n,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[r.jsx(_y,{createFile:this.handleCreateFile,createFolder:this.handleCreateDirectory}),s&&r.jsx(Zr,{isMultiSelect:!0,storage:e,onDelete:this.handleDelete,onRename:this.handleRename,onSelect:this.handleFileSelect,onSelectionChange:this.handleSelectionChange}),r.jsx(Ou,{isOpen:i,type:"directory",title:"Create New Folder",storage:e,onSubmit:this.handleCreateDirectorySubmit,onCancel:this.handleCreateDirectoryCancel,defaultValue:o})]})}}const Uy=jy(Il),Dl=Uy;const et=ee.module("FilterSetManager"),Vy="Enter name...",pc="No Available Filter Sets";class Fl extends w.Component{static animateScreenFlash(){const e=document.createElement("div");e.classList.add("screen-flash-overlay"),e.addEventListener("animationend",()=>{e.remove()}),document.querySelector("body")?.appendChild(e)}constructor(e){super(e),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleEditDropdownChange=this.handleEditDropdownChange.bind(this),this.handleFilterChange=this.handleFilterChange.bind(this),this.handleFilterApply=this.handleFilterApply.bind(this),this.handleCaptureNewSet=this.handleCaptureNewSet.bind(this),this.handleNameInputChange=this.handleNameInputChange.bind(this),this.handleNameInputKeyPress=this.handleNameInputKeyPress.bind(this),this.handleRenameConfirm=this.handleRenameConfirm.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRestoreFullStateChange=this.handleRestoreFullStateChange.bind(this),this.handleSetDelete=this.handleSetDelete.bind(this),this.handleSetEdit=this.handleSetEdit.bind(this),this.handleSetUpdate=this.handleSetUpdate.bind(this),this.state={editId:void 0,renameSet:void 0,nameInputValue:"",nameInputError:void 0,modifiedFilterSets:[],restoreFullState:!1}}componentDidMount(){const{isValueShown:e}=this.props;e?this.updateSelectedId():this.initSettingsScreen()}componentDidUpdate(e,t){const{isValueShown:n,filterSets:s}=this.props,{modifiedFilterSets:i}=this.state;if(e.isValueShown&&!n&&this.initSettingsScreen(),this.isNameInputScreen()&&!this.isNameInputScreen(t)&&this.focusRenameInput(),s!==e.filterSets)if(!n&&s.length>0&&e.filterSets.length===0&&i.length===0){const{onChange:o}=this.props;o({isValueShown:!0,selectedId:s[0].id})}else this.updateSelectedId()}renameInputRef=ae.createRef();dropdownRef=ae.createRef();editDropdownRef=ae.createRef();initSettingsScreen(){const{filterSets:e,selectedId:t}=this.props;et.debug("initSettingsScreen",e,t),this.setState({modifiedFilterSets:[...e],editId:t})}updateSelectedId(){const{isValueShown:e,filterSets:t,selectedId:n,onChange:s}=this.props;if(et.debug("updateSelectedId",t,n),!!e&&!t.some(({id:i})=>i===n)){const i=t.length===0;s({isValueShown:!i,selectedId:i?void 0:t[0].id})}}handleEditDropdownChange(e){const{value:t}=e.target;this.setState({editId:t})}handleFilterChange(e){const{value:t}=e.target,{isValueShown:n,onChange:s}=this.props;this.applyFilterSet(t),s({isValueShown:n,selectedId:t})}handleFilterApply(){const{selectedId:e}=this.props;this.applyFilterSet(e)}handleSettingsCancel(){const{onChange:e,selectedId:t,filterSets:n}=this.props;this.setState({modifiedFilterSets:[]}),n.length>0&&e({isValueShown:!0,selectedId:t})}handleSettingsSave(){const{onChange:e,onUpdateSets:t}=this.props,{modifiedFilterSets:n,editId:s}=this.state;this.setState({modifiedFilterSets:[]}),et.debug("Update sets",n,s),t(n),n.length>0&&e({isValueShown:!0,selectedId:s})}handleCaptureNewSet(){const{getFilterState:e}=this.props;Fl.animateScreenFlash();const t=ze(),n=e(),s={id:t,title:"",panels:n};et.debug("handleSetCreate",s),this.setState({nameInputValue:"",nameInputError:void 0,renameSet:s})}handleRenameCancel(){this.setState({renameSet:void 0})}handleRestoreFullStateChange(e){this.setState({restoreFullState:e.target.value==="true"})}getNameError(e){const{renameSet:t,modifiedFilterSets:n}=this.state,s=e?.trim()??"";if(s.length===0)return et.debug("Name cannot be empty",s),"Name cannot be empty";if(t!==void 0&&n.some(({title:i,id:o})=>i===s&&o!==t.id))return et.debug("Set with this name already exists",s),"Set with this name already exists"}handleRenameConfirm(){const{nameInputValue:e,renameSet:t,modifiedFilterSets:n,restoreFullState:s}=this.state;if(t===void 0){et.error("Renamed set undefined.");return}const i=this.getNameError(e);if(et.debug("handleRenameConfirm",e,i),i!==void 0){this.setState({nameInputError:i});return}const o=e?.trim()??"",l={...t,title:o,restoreFullState:s},a=n.findIndex(({id:h})=>h===t.id),d=[...n];a>=0?(d[a]=l,et.debug("Renamed existing set",d)):(d.push(l),et.debug("Added new set to modified sets",d)),this.setState({editId:l.id,modifiedFilterSets:d,renameSet:void 0})}handleSetDelete(){this.setState(e=>{const{editId:t,modifiedFilterSets:n}=e,s=n.findIndex(({id:a})=>a===t);if(s<0)return et.error("Unable to find selected filterSet index",n,t),null;const i=n.filter(({id:a})=>a!==t),o=Math.max(0,Math.min(i.length-1,s-1)),l=i.length>0?i[o].id:void 0;return et.debug("Deleted selected set",t,n,i),et.debug("New selection",o,l),{modifiedFilterSets:i,editId:l}})}handleSetUpdate(){const{getFilterState:e}=this.props;Fl.animateScreenFlash();const t=e();this.setState(({modifiedFilterSets:n,editId:s})=>{if(s===void 0)return et.error("Filter for update not selected."),null;const i=[...n],o=i.findIndex(({id:l})=>l===s);return o<0?(et.error("Selected set for update not found."),null):(i[o]={...i[o],panels:t},et.debug("Update set",i,t),{modifiedFilterSets:i})})}handleSetEdit(){this.setState(({editId:e,modifiedFilterSets:t})=>{const n=t.find(({id:o})=>o===e);if(n===void 0)return et.error("Could not find selected set",e,t),null;const{title:s,restoreFullState:i=!1}=n;return{nameInputValue:s,nameInputError:void 0,renameSet:n,restoreFullState:i}})}handleSettingsClick(e){e.stopPropagation();const{onChange:t,selectedId:n}=this.props;t({isValueShown:!1,selectedId:n})}handleBackgroundClick(e){et.debug("handleBackgroundClick"),e.target!==this.dropdownRef.current&&this.focusInput()}handleNameInputChange(e){const{value:t}=e.target,n=this.getNameError(t);this.setState({nameInputValue:t,nameInputError:n})}handleNameInputKeyPress(e){const{key:t}=e;t==="Enter"&&(e.preventDefault(),this.handleRenameConfirm())}isNameInputScreen(e=this.state){const{renameSet:t}=e;return t!==void 0}isRenamingExistingSet=he((e,t)=>t!==void 0&&e.some(({id:n})=>n===t.id));applyFilterSet(e){const{onApply:t,filterSets:n}=this.props;if(e===void 0){et.debug("No filter selected");return}const s=n.find(({id:i})=>i===e);if(s===void 0){et.debug("Selected id not found in filterSets",e,n);return}et.debug("Apply filterSet",s),t(s)}focusInput(){this.dropdownRef.current?.focus()}focusRenameInput(){this.renameInputRef.current?.focus()}render(){const{nameInputValue:e,nameInputError:t,editId:n,renameSet:s,modifiedFilterSets:i,restoreFullState:o}=this.state,{isValueShown:l,filterSets:a,selectedId:d}=this.props,h=this.isNameInputScreen(),u=this.isRenamingExistingSet(i,s),m=i.length===0,g=!h&&m&&a.length===0,p=!h&&!g,C=r.jsxs("div",{className:"fa-layers mr-3",children:[r.jsx(X,{icon:yi,mask:Ha,transform:"shrink-1 down-5 right-7"}),r.jsx(X,{icon:ys,className:"text-primary",transform:"shrink-6 down-5 right-7"})]}),f=r.jsxs("div",{className:"fa-layers",children:[r.jsx(X,{icon:yi,mask:Ha,transform:"shrink-1 down-5 right-7"}),r.jsx(X,{icon:Ua,transform:"shrink-1 down-5 right-7"})]});return r.jsx("div",{className:"filter-set-manager fill-parent-absolute",children:r.jsxs(ir,{className:"w-100 h-100",isFlipped:l,children:[r.jsx("div",{className:"filter-set-manager-settings-card fill-parent-absolute",children:r.jsxs("div",{className:"filter-set-manager-card-content",children:[g&&r.jsxs("div",{children:[r.jsx(_,{kind:"ghost",className:"btn btn-link no-underline",onClick:this.handleCaptureNewSet,icon:C,children:"Capture filter set"}),r.jsx("div",{className:"py-3 text-muted small",children:"Takes a snapshot of the currently applied filters on all panels, allowing you to restore saved filter sets later."})]}),h&&r.jsxs("div",{className:"d-flex flex-column justify-content-center","data-testid":"edit-filter-set-container",children:[r.jsxs("div",{className:"form-group",children:[r.jsx("label",{children:u?"Edit set":"Name captured set"}),r.jsxs("div",{className:"name-input-container",children:[r.jsx("input",{type:"text",className:"input-set-name form-control",placeholder:Vy,value:e,ref:this.renameInputRef,onChange:this.handleNameInputChange,onKeyPress:this.handleNameInputKeyPress,spellCheck:"false"}),r.jsx(_,{"data-testid":"rename-confirm-button",kind:"ghost",className:"btn btn-link no-underline pt-2 pb-2",onClick:this.handleRenameConfirm,tooltip:"Save","test-id":"button-save",icon:nh}),r.jsx(_,{"data-testid":"rename-cancel-button",kind:"ghost",className:"btn btn-link no-underline pt-2 pb-2",onClick:this.handleRenameCancel,tooltip:"Cancel",icon:jg})]}),t!==void 0&&r.jsx("div",{className:"error-message",children:t})]}),r.jsx("div",{className:"form-group",children:r.jsxs(Hl,{onChange:this.handleRestoreFullStateChange,value:`${o}`,children:[r.jsx(zn,{value:"false",children:"Restore only filters"}),r.jsx(zn,{value:"true",children:"Restore full table state"})]})})]}),p&&r.jsxs("div",{className:"filter-set-manager-settings-grid-1",children:[r.jsxs("div",{className:"form-group",children:[r.jsx("label",{children:"Edit filter sets"}),r.jsxs("div",{className:"filter-select-container",children:[r.jsxs("select",{"data-testid":"settings-card-filter-select",ref:this.editDropdownRef,value:n??"-1",className:"custom-select filter-value-select",onChange:this.handleEditDropdownChange,disabled:m,children:[m&&r.jsx("option",{value:"-1",disabled:!0,children:pc}),i.map(({id:S,title:v})=>r.jsx("option",{value:S,children:v},S))]}),r.jsx(_,{kind:"ghost",onClick:this.handleSetUpdate,disabled:m,icon:f,tooltip:"Update"}),r.jsx(_,{kind:"ghost",onClick:this.handleSetEdit,disabled:m,icon:mo,tooltip:"Edit"}),r.jsx(_,{kind:"ghost",onClick:this.handleSetDelete,disabled:m,icon:Wt,tooltip:"Delete"})]})]}),r.jsx("div",{children:r.jsx(_,{kind:"ghost",className:"btn btn-link no-underline",onClick:this.handleCaptureNewSet,icon:C,children:"Capture new filter set"})}),r.jsxs("div",{className:"py-3 text-right",children:[r.jsx(_,{kind:"secondary",onClick:this.handleSettingsCancel,children:"Cancel"})," ",r.jsx(_,{kind:"primary",onClick:this.handleSettingsSave,children:"Save"})]})]})]})},"front"),r.jsxs("div",{className:"filter-set-manager-value-card fill-parent-absolute",onClick:this.handleBackgroundClick,children:[r.jsx("div",{className:"filter-set-manager-column",children:r.jsx("div",{className:"filter-set-manager-column-title",children:"Filter sets"})}),r.jsx("div",{className:"filter-set-manager-card-content",children:r.jsx("div",{className:"filter-set-manager-value-input",children:r.jsxs("div",{className:"filter-select-container",children:[r.jsxs("select",{"data-testid":"value-card-filter-select",ref:this.dropdownRef,value:d,className:"custom-select filter-value-select",onChange:this.handleFilterChange,children:[a.length===0&&r.jsx("option",{value:"-1",disabled:!0,children:pc}),a.map(({id:S,title:v})=>r.jsx("option",{value:S,children:v},S))]}),r.jsx(_,{"data-testid":"filter-apply-button",kind:"ghost",onClick:this.handleFilterApply,icon:rr,tooltip:"Apply Filter Set"})]})})}),r.jsx("div",{className:"filter-set-manager-menu",children:r.jsx(_,{kind:"ghost",className:"btn btn-link btn-link-icon m-2 px-2",onClick:this.handleSettingsClick,tooltip:"Settings",icon:r.jsx(X,{icon:uo,transform:"grow-4"})})})]},"back")]})})}}const By=Fl;function Qr(c){const{model:e,widgetName:t,glContainer:n,description:s}=c,i=(e?.rowCount??0)-(e?.pendingRowCount??0),o=e?.displayString(i,"long");return r.jsx(na,{widgetType:"Table",widgetName:t,glContainer:n,description:s,children:r.jsxs("div",{className:"column-statistics-grid",children:[r.jsx("span",{className:"column-statistic-operation",children:"Number of Rows"}),r.jsx("span",{className:"column-statistic-value",children:o})]})})}Qr.propTypes={glContainer:Dr.Container.isRequired,widgetName:B.string.isRequired,description:B.string};Qr.defaultProps={description:null};const vn=ee.module("IrisGridPanel"),$y=500,Wy={IrisGrid:xu,IrisGridTableModel:Iu,ContextMenuRoot:zc};class Qa extends w.PureComponent{static defaultProps={onStateChange:()=>{},onPanelStateUpdate:()=>{}};static displayName="IrisGridPanel";static COMPONENT="IrisGridPanel";constructor(e){super(e),this.handleAdvancedSettingsChange=this.handleAdvancedSettingsChange.bind(this),this.handleColumnsChanged=this.handleColumnsChanged.bind(this),this.handleTableChanged=this.handleTableChanged.bind(this),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleDataSelected=this.handleDataSelected.bind(this),this.handleError=this.handleError.bind(this),this.handleGridStateChange=this.handleGridStateChange.bind(this),this.handlePluginStateChange=this.handlePluginStateChange.bind(this),this.handlePartitionAppend=this.handlePartitionAppend.bind(this),this.handleCreateChart=this.handleCreateChart.bind(this),this.handleResize=this.handleResize.bind(this),this.handleShow=this.handleShow.bind(this),this.handleTabClicked=this.handleTabClicked.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.isColumnSelectionValid=this.isColumnSelectionValid.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.handlePluginFilter=this.handlePluginFilter.bind(this),this.handlePluginFetchColumns=this.handlePluginFetchColumns.bind(this),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.irisGrid=ae.createRef(),this.pluginRef=ae.createRef();const{panelState:t}=e;this.pluginState=null,this.state={error:null,isDisconnected:!1,isLoaded:!1,isLoading:!0,isModelReady:!1,model:void 0,advancedFilters:new Map,aggregationSettings:{aggregations:[],showOnTop:!1},advancedSettings:new Map(fu.DEFAULTS),customColumns:[],customColumnFormatMap:new Map,isFilterBarShown:!1,quickFilters:new Map,sorts:[],userColumnWidths:new Map,userRowHeights:new Map,reverseType:F.REVERSE_TYPE.NONE,movedColumns:[],movedRows:[],isSelectingPartition:!1,partition:void 0,partitionColumn:void 0,rollupConfig:void 0,showSearchBar:!1,searchValue:"",selectedSearchColumns:void 0,invertSearchColumns:!0,Plugin:void 0,pluginFilters:[],pluginFetchColumns:[],modelQueue:[],pendingDataMap:new Map,frozenColumns:void 0,panelState:t,irisGridStateOverrides:{},gridStateOverrides:{},isStuckToBottom:!1,isStuckToRight:!1,conditionalFormats:[],selectDistinctColumns:[]}}componentDidMount(){this.initModel()}componentDidUpdate(e,t){const{model:n}=this.state;n!==t.model&&(t.model!=null&&(this.stopModelListening(t.model),t.model.close()),n!=null&&this.startModelListening(n))}componentWillUnmount(){this.savePanelState.cancel(),this.modelPromise!=null&&(this.modelPromise.cancel(),this.modelPromise=void 0);const{model:e}=this.state;e&&(this.stopModelListening(e),e.close())}irisGrid;pluginRef;modelPromise;irisGridState;gridState;pluginState;getTableName(){const{metadata:e}=this.props;return e.table}getGridInputFilters=he((e,t)=>Ce.getInputFiltersForColumns(e,t.filter(({value:n,excludePanelIds:s})=>{const i=$.getIdFromPanel(this);return n!=null&&(s==null||i!=null&&!s.includes(i))})));getAlwaysFetchColumns=he((e,t)=>{const n=$.getIdFromPanel(this),s=new Set(t);for(let i=0;i<e.length;i+=1){const{start:o}=e[i];o!=null&&o.panelId===n&&s.add(o.columnName)}return[...s]});getPluginContent=he((e,t,n,s,i)=>!t||!Ys(t)||e==null||t.table==null?null:r.jsx("div",{className:"iris-grid-plugin",children:r.jsx(e,{ref:this.pluginRef,filter:this.handlePluginFilter,onFilter:this.handlePluginFilter,fetchColumns:this.handlePluginFetchColumns,onFetchColumns:this.handlePluginFetchColumns,table:t.table,user:n,panel:this,workspace:s,components:Wy,onStateChange:this.handlePluginStateChange,pluginState:i})}));getDehydratedIrisGridPanelState=he((e,t,n,s,i)=>Ce.dehydrateIrisGridPanelState(e,{isSelectingPartition:t,partition:n,partitionColumn:s,advancedSettings:i}));getDehydratedIrisGridState=he((e,t,n,s,i,o,l,a,d,h,u,m,g,p,C,f,S,v,b,T,y)=>Ce.dehydrateIrisGridState(e,{advancedFilters:n,aggregationSettings:S,customColumnFormatMap:s,isFilterBarShown:i,metrics:{userColumnWidths:C,userRowHeights:f},quickFilters:o,customColumns:l,reverseType:a,rollupConfig:d,showSearchBar:h,searchValue:u,selectDistinctColumns:m,selectedSearchColumns:g,sorts:t,invertSearchColumns:p,pendingDataMap:v,frozenColumns:b,conditionalFormats:T,columnHeaderGroups:y}));getDehydratedGridState=he((e,t,n,s,i)=>Ce.dehydrateGridState(e,{isStuckToBottom:s,isStuckToRight:i,movedColumns:t,movedRows:n}));getCachedPanelState=he((e,t,n,s)=>({irisGridPanelState:e,irisGridState:t,gridState:n,pluginState:s}));initModel(){this.setState({isModelReady:!1,isLoading:!0,error:null});const{makeModel:e}=this.props;this.modelPromise!=null&&this.modelPromise.cancel(),this.modelPromise=ve.makeCancelable(e(),t=>t.close()),this.modelPromise.then(this.handleLoadSuccess).catch(this.handleLoadError)}handleLoadSuccess(e){const t=e,{panelState:n,irisGridStateOverrides:s}=this.state,i=[];if(n!=null){const{irisGridState:o}=n,{aggregationSettings:l,customColumns:a,selectDistinctColumns:d=[],rollupConfig:h}={...o,...s};a.length>0&&i.push(u=>{u.customColumns=a}),h!=null&&h.columns.length>0&&i.push(u=>{u.rollupConfig=Ce.getModelRollupConfig(u.originalColumns,h,l)}),d.length>0&&i.push(u=>{u.selectDistinctColumns=d})}this.setState({model:t,modelQueue:i}),this.initModelQueue(t,i)}initModelQueue(e,t){const n=e;if(t.length===0){this.modelInitialized(n);return}const s=t.shift();vn.debug("initModelQueue",s),s&&s(n),this.setState({modelQueue:t})}handleAdvancedSettingsChange(e,t){vn.debug("handleAdvancedSettingsChange",e,t),this.setState(({advancedSettings:n})=>n.get(e)===t?null:{advancedSettings:new Map(n).set(e,t)})}handlePluginFilter(e){const{model:t}=this.state;N(t);const{columns:n,formatter:s}=t,i=Ce.getFiltersFromInputFilters(n,e,s.timeZone);this.setState({pluginFilters:i})}handlePluginFetchColumns(e){this.setState({pluginFetchColumns:e})}handleContextMenu(e){return this.pluginRef.current?.getMenu?.(e)??[]}isColumnSelectionValid(e){const{columnSelectionValidator:t}=this.props;return t&&e?t(this,e):!1}handleGridStateChange(e,t){this.irisGridState=e,this.gridState=t,this.setState({isLoaded:!0,isLoading:!1}),this.savePanelState();const{glEventHub:n,onStateChange:s}=this.props;n.emit(cn.STATE_CHANGED,this),s?.(e,t)}handlePluginStateChange(e){const{irisGridState:t,gridState:n}=this;this.pluginState=e,t!==null&&n!==null&&this.savePanelState()}handleColumnsChanged(e){const{isModelReady:t,model:n,modelQueue:s}=this.state;t?this.sendColumnsChange(e.detail):(N(n),this.initModelQueue(n,s))}handleTableChanged(e){vn.debug("handleTableChanged",e);const{glEventHub:t}=this.props,{detail:n}=e;t.emit(Ye.TABLE_CHANGED,this,n)}handlePartitionAppend(e,t){const{glEventHub:n}=this.props,{name:s}=e,i=this.getTableName(),o=`${i} = ${i}.where("${s}=\`${t}\`")`;n.emit(Bt.SEND_COMMAND,o,!1,!0)}handleCreateChart(e,t){this.savePanelState.flush(),this.setState(()=>null,()=>{const{glEventHub:n,inputFilters:s,metadata:i}=this.props,{table:o}=i,{panelState:l}=this.state,a=$.getIdFromPanel(this);let d;l&&(d=Ce.extractTableSettings(l,s)),n.emit(cn.CREATE_CHART,{metadata:{settings:e,sourcePanelId:a,table:o,tableSettings:d},table:Ys(t)?t.table:void 0})})}handleColumnSelected(e){const{glEventHub:t}=this.props;t.emit(cn.COLUMN_SELECTED,this,e)}handleDataSelected(e,t){const{glEventHub:n}=this.props;n.emit(cn.DATA_SELECTED,this,t)}handleResize(){this.updateGrid()}handleShow(){this.updateGrid()}handleTabClicked(){this.irisGrid.current&&this.irisGrid.current.focus()}handleError(e){vn.error(e),this.setState({error:e,isLoading:!1})}handleDisconnect(){this.setState({error:new Error("Table disconnected"),isDisconnected:!0,isLoading:!1})}handleReconnect(){this.setState({isDisconnected:!1,error:null})}handleLoadError(e){ve.isCanceled(e)||this.handleError(e)}modelInitialized(e){const{glEventHub:t,loadPlugin:n}=this.props;if(this.modelPromise=void 0,this.loadPanelState(e),this.setState({isModelReady:!0}),Ys(e)){const{table:s}=e,{pluginName:i}=s;if(i!==""&&n!=null&&i!=null){const o=n(i);this.setState({Plugin:o})}t.emit(Ye.TABLE_CHANGED,this,s)}this.sendColumnsChange(e.columns)}handleClearAllFilters(){const e=this.irisGrid.current,{isDisconnected:t}=this.state;e!=null&&!t&&e.clearAllFilters()}sendColumnsChange(e){vn.debug2("sendColumnsChange",e);const{glEventHub:t}=this.props;t.emit(Ye.COLUMNS_CHANGED,this,e)}startModelListening(e){e.addEventListener(ge.EVENT.DISCONNECT,this.handleDisconnect),e.addEventListener(ge.EVENT.RECONNECT,this.handleReconnect),e.addEventListener(ge.EVENT.COLUMNS_CHANGED,this.handleColumnsChanged),e.addEventListener(ge.EVENT.TABLE_CHANGED,this.handleTableChanged)}stopModelListening(e){e.removeEventListener(ge.EVENT.DISCONNECT,this.handleDisconnect),e.removeEventListener(ge.EVENT.RECONNECT,this.handleReconnect),e.removeEventListener(ge.EVENT.COLUMNS_CHANGED,this.handleColumnsChanged),e.removeEventListener(ge.EVENT.TABLE_CHANGED,this.handleTableChanged)}getCoordinateForColumn(e){const{model:t}=this.state;if(!t)return null;const n=this.irisGrid.current,{gridWrapper:s}=n||{},i=s?.getBoundingClientRect()??null;if(i==null||i.width<=0||i.height<=0)return null;N(n);const{metrics:o}=n.state;N(o);const{columnHeaderHeight:l,allColumnXs:a,allColumnWidths:d,right:h,columnHeaderMaxDepth:u}=o,m=t.getColumnIndexByName(e);N(m);const g=n.getVisibleColumn(m),p=a.get(g)??0,C=d.get(g)??0,f=Math.max(i.left,Math.min(g>h?i.right:i.left+p+C*.5,i.right)),S=i.top+l*u;return[f,S]}setFilterMap(e){const t=this.irisGrid.current;t?.setFilterMap(e)}setAdvancedFilterMap(e){const t=this.irisGrid.current;t?.setAdvancedFilterMap(e)}setFilters({quickFilters:e,advancedFilters:t}){vn.debug("setFilters",e,t);const{model:n,isDisconnected:s}=this.state,i=this.irisGrid.current;if(i==null||s){vn.debug("Ignore setFilters, model disconnected");return}N(n);const{columns:o,formatter:l}=n,a=Ce.changeFilterColumnNamesToIndexes(n.columns,e).filter(([h])=>n.isFilterable(h)),d=Ce.changeFilterColumnNamesToIndexes(n.columns,t).filter(([h])=>n.isFilterable(h));i.clearAllFilters(),i.setFilters({quickFilters:Ce.hydrateQuickFilters(o,a,l.timeZone),advancedFilters:Ce.hydrateAdvancedFilters(o,d,l.timeZone)})}setStateOverrides(e){vn.debug("setStateOverrides",e);const{irisGridState:t,gridState:n}=e;this.setState({irisGridStateOverrides:t,gridStateOverrides:n},()=>{this.initModel()})}unsetFilterValue(){}loadPanelState(e){const{panelState:t,irisGridStateOverrides:n,gridStateOverrides:s}=this.state;if(t!=null)try{const{gridState:i,irisGridState:o,irisGridPanelState:l}=t,a={...n},{quickFilters:d,advancedFilters:h}=a;d&&(a.quickFilters=Ce.changeFilterColumnNamesToIndexes(e.columns,d)),h&&(a.advancedFilters=Ce.changeFilterColumnNamesToIndexes(e.columns,h));const{isSelectingPartition:u,partition:m,partitionColumn:g,advancedSettings:p}=Ce.hydrateIrisGridPanelState(e,l),{advancedFilters:C,customColumns:f,customColumnFormatMap:S,isFilterBarShown:v,quickFilters:b,reverseType:T,rollupConfig:y,aggregationSettings:E,sorts:R,userColumnWidths:x,userRowHeights:D,showSearchBar:L,searchValue:M,selectDistinctColumns:j,selectedSearchColumns:A,invertSearchColumns:W,pendingDataMap:H,frozenColumns:U,conditionalFormats:P,columnHeaderGroups:Q}=Ce.hydrateIrisGridState(e,{...o,...a}),{isStuckToBottom:G,isStuckToRight:ne,movedColumns:V,movedRows:z}=Ce.hydrateGridState(e,{...i,...s},o.customColumns);this.setState({advancedFilters:C,advancedSettings:p,conditionalFormats:P,customColumns:f,customColumnFormatMap:S,isFilterBarShown:v,isSelectingPartition:u,movedColumns:V,movedRows:z,partition:m,partitionColumn:g,quickFilters:b,reverseType:T,rollupConfig:y,aggregationSettings:E,sorts:R,userColumnWidths:x,userRowHeights:D,showSearchBar:L,searchValue:M,selectDistinctColumns:j,selectedSearchColumns:A,invertSearchColumns:W,pendingDataMap:H,frozenColumns:U,isStuckToBottom:G,isStuckToRight:ne,columnHeaderGroups:Q})}catch(i){vn.error("loadPanelState failed to load panelState",t,i)}}savePanelState=Ge(()=>{const{irisGridState:e,gridState:t,pluginState:n}=this;N(e);const{onPanelStateUpdate:s}=this.props,{model:i,panelState:o,isSelectingPartition:l,partition:a,partitionColumn:d,advancedSettings:h}=this.state,{advancedFilters:u,aggregationSettings:m,customColumnFormatMap:g,isFilterBarShown:p,quickFilters:C,customColumns:f,reverseType:S,rollupConfig:v,showSearchBar:b,searchValue:T,selectDistinctColumns:y,selectedSearchColumns:E,sorts:R,invertSearchColumns:x,metrics:D,pendingDataMap:L,frozenColumns:M,conditionalFormats:j,columnHeaderGroups:A}=e;N(i),N(D);const{userColumnWidths:W,userRowHeights:H}=D;N(t);const{isStuckToBottom:U,isStuckToRight:P,movedColumns:Q,movedRows:G}=t,ne=this.getCachedPanelState(this.getDehydratedIrisGridPanelState(i,l,a,d,h),this.getDehydratedIrisGridState(i,R,u,g,p,C,f,S,v,b,T,y,E,x,W,H,m,L,M,j,A),this.getDehydratedGridState(i,Q,G,U,P),n);ne!==o&&(vn.debug("Saving panel state",this,ne),this.setState({panelState:ne}),s?.(ne))},$y);updateGrid(){const e=this.irisGrid.current?.grid??null;e&&e.handleResize()}render(){const{children:e,glContainer:t,glEventHub:n,columnSelectionValidator:s,getDownloadWorker:i,inputFilters:o,links:l,metadata:a,panelState:d,user:h,workspace:u,settings:m,theme:g}=this.props,{advancedFilters:p,aggregationSettings:C,advancedSettings:f,conditionalFormats:S,customColumns:v,customColumnFormatMap:b,error:T,isDisconnected:y,isFilterBarShown:E,isSelectingPartition:R,isStuckToBottom:x,isStuckToRight:D,isLoaded:L,isLoading:M,isModelReady:j,model:A,movedColumns:W,movedRows:H,partition:U,partitionColumn:P,quickFilters:Q,reverseType:G,rollupConfig:ne,sorts:V,userColumnWidths:z,userRowHeights:Z,showSearchBar:oe,searchValue:re,selectDistinctColumns:q,selectedSearchColumns:ie,invertSearchColumns:fe,Plugin:Re,pluginFilters:xe,pluginFetchColumns:vt,pendingDataMap:Tt,frozenColumns:Gt,columnHeaderGroups:fn}=this.state,Dt=T!=null?`Unable to open table. ${T}`:void 0,{table:ye}=a,dt=A?.description??void 0,nt=d?.pluginState??null,ft=e??this.getPluginContent(Re,A,h,u,nt),{permissions:Ft}=h,{canCopy:Cn,canDownloadCsv:zt}=Ft;return r.jsx(Br,{errorMessage:Dt,isDisconnected:y,isLoading:M,isLoaded:L,className:"iris-grid-panel",glContainer:t,glEventHub:n,onClearAllFilters:this.handleClearAllFilters,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleShow,onTabClicked:this.handleTabClicked,widgetName:ye,widgetType:"Table",description:dt,componentPanel:this,renderTabTooltip:()=>r.jsx(Qr,{model:A,widgetName:ye,glContainer:t,description:dt}),children:j&&A&&r.jsx(xu,{advancedFilters:p,aggregationSettings:C,advancedSettings:f,alwaysFetchColumns:this.getAlwaysFetchColumns(l,vt),columnAllowedCursor:"linker",columnNotAllowedCursor:"linker-not-allowed",customColumns:v,customColumnFormatMap:b,columnSelectionValidator:this.isColumnSelectionValid,conditionalFormats:S,inputFilters:this.getGridInputFilters(A.columns,o),applyInputFiltersOnInit:d==null,isFilterBarShown:E,isSelectingColumn:s!=null,isSelectingPartition:R,isStuckToBottom:x,isStuckToRight:D,movedColumns:W,movedRows:H,partition:U,partitionColumn:P,quickFilters:Q,reverseType:G,rollupConfig:ne,settings:m,sorts:V,userColumnWidths:z,userRowHeights:Z,model:A,showSearchBar:oe,searchValue:re,selectedSearchColumns:ie,selectDistinctColumns:q,invertSearchColumns:fe,onColumnSelected:this.handleColumnSelected,onCreateChart:this.handleCreateChart,onDataSelected:this.handleDataSelected,onError:this.handleError,onPartitionAppend:this.handlePartitionAppend,onStateChange:this.handleGridStateChange,onContextMenu:this.handleContextMenu,onAdvancedSettingsChange:this.handleAdvancedSettingsChange,customFilters:xe,pendingDataMap:Tt,canCopy:Cn,canDownloadCsv:zt,ref:this.irisGrid,getDownloadWorker:i,frozenColumns:Gt,theme:g,columnHeaderGroups:fn,children:ft})})}}const Gy=(c,{localDashboardId:e=un})=>({inputFilters:$r(c,e),links:Fi(c,e),columnSelectionValidator:zr(c,e),user:fh(c),workspace:Kl(c),settings:pt(c)}),zy=gt(Gy,null,null,{forwardRef:!0})(Qa),Xs=zy;const fc=ee.module("InputFilter"),Ky=150;class Nl extends w.Component{static PLACEHOLDER="Enter value...";static defaultProps={column:null,isValueShown:!1,value:null};constructor(e){super(e),this.handleColumnChange=this.handleColumnChange.bind(this),this.handleInputKeyPress=this.handleInputKeyPress.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.inputRef=ae.createRef();const{column:t,isValueShown:n,value:s}=e;this.state={column:t,selectedColumn:t,value:s,isValueShown:n}}componentDidUpdate(e,t){const{column:n}=this.props,{column:s,value:i,isValueShown:o}=this.state;n!==e.column&&this.setState({column:n,selectedColumn:n}),o!==void 0&&o&&o!==t.isValueShown&&this.focusInput(),(s!==t.column||i!==t.value||o!==t.isValueShown)&&this.sendUpdate()}componentWillUnmount(){this.sendUpdate.flush()}inputRef;getItemLabel=Te((e,t)=>{const{name:n,type:s}=e[t];if(t>0&&e[t-1].name===n||t<e.length-1&&e[t+1].name===n){const i=s.substring(s.lastIndexOf(".")+1);return`${n} (${i})`}return n});handleColumnChange(e){const{columns:t}=this.props,{value:n}=e.target,s=t[parseInt(n,10)];fc.debug2("handleColumnChange",s),this.setState({selectedColumn:s,value:void 0})}handleInputKeyPress(e){e.key==="Enter"&&(e.preventDefault(),e.stopPropagation(),this.setState(({value:t})=>t==null?{value:""}:null,()=>{this.sendUpdate(),this.sendUpdate.flush()}))}handleValueChange(e){const{value:t}=e.target;fc.debug2("handleValueChange",t),this.setState({value:t})}handleSettingsCancel(){const{column:e}=this.state;this.setState({selectedColumn:e,isValueShown:!0})}handleSettingsSave(){const{selectedColumn:e}=this.state;this.setState({column:e,isValueShown:!0})}handleSettingsClick(e){const{column:t}=this.state;this.setState({selectedColumn:t,isValueShown:!1}),e.stopPropagation()}handleBackgroundClick(e){e.target!==this.inputRef.current&&this.focusInput()}focusInput(){this.inputRef.current!==null&&(this.inputRef.current.select(),this.inputRef.current.focus())}clearFilter(){this.setState({value:""})}setFilterState({name:e,type:t,value:n,isValueShown:s}){const i=e!=null&&t!=null?{name:e,type:t}:void 0,o=s===void 0?{column:i,value:n}:{column:i,value:n,isValueShown:s};this.setState(o)}sendUpdate=Ge(()=>{const{onChange:e}=this.props,{column:t,value:n,isValueShown:s}=this.state;e({column:t,isValueShown:s,value:n})},Ky);render(){const{columns:e}=this.props,{column:t,isValueShown:n,selectedColumn:s,value:i}=this.state,o=i==null||i.length===0?Nl.PLACEHOLDER.length:i.length;let l=null;if(t!=null){const a=e.findIndex(d=>d.name===t.name&&d.type===t.type);l=a>=0?this.getItemLabel(e,a):t.name}return r.jsxs(ir,{className:"input-filter fill-parent-absolute",isFlipped:n??!1,children:[r.jsx("div",{className:"input-filter-settings-card",children:r.jsxs("div",{className:"input-filter-settings-content",children:[r.jsxs("div",{className:"input-filter-settings-grid",children:[r.jsx("label",{children:"Filter Column"}),r.jsxs("select",{value:e.findIndex(a=>a.name===s?.name&&a.type===s?.type),className:"custom-select",onChange:this.handleColumnChange,children:[e.map((a,d)=>r.jsx("option",{value:d,children:this.getItemLabel(e,d)},`${a.name}/${a.type}`)),e.length===0&&r.jsx("option",{value:"-1",disabled:!0,children:"No Available Columns"})]}),r.jsx("div",{className:"text-muted small",children:"Input filter control will apply its filter to all columns matching this name in this dashboard."})]}),r.jsxs("div",{className:"input-filter-settings-buttons",children:[r.jsx(_,{kind:"secondary",onClick:this.handleSettingsCancel,disabled:t==null,children:"Cancel"}),r.jsx(_,{kind:"primary",className:"ml-2",onClick:this.handleSettingsSave,disabled:s==null,children:"Save"})]})]})}),r.jsxs("div",{className:"input-filter-value-card",onClick:this.handleBackgroundClick,children:[r.jsx("div",{className:"input-filter-column",children:r.jsxs("div",{className:"input-filter-column-title",children:[l," Filter"]})}),r.jsx("div",{className:"d-flex justify-content-center align-items-center h-100 w-100",children:r.jsx("div",{className:"input-filter-value-input d-flex flex-column justify-content-center",children:r.jsx("input",{type:"text",ref:this.inputRef,placeholder:Nl.PLACEHOLDER,value:i??"",onChange:this.handleValueChange,onKeyPress:this.handleInputKeyPress,style:{width:`${o+3}ch`},spellCheck:"false"})})}),r.jsx("div",{className:"input-filter-menu",children:r.jsx(_,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:r.jsx(X,{icon:uo,transform:"grow-4"}),tooltip:"Input Filter Settings"})})]})]})}}const Yy=Nl,qy=250;class Xy extends w.Component{static defaultProps={panelState:null};static COMPONENT="InputFilterPanel";static displayName="InputFilterPanel";constructor(e){super(e),this.handleChange=Ge(this.handleChange.bind(this),qy),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.inputFilterRef=ae.createRef();const{panelState:t}=e,{value:n,isValueShown:s=!1,name:i,type:o,timestamp:l}=t??{};this.state={columns:[],column:i!=null&&o!=null?{name:i,type:o}:void 0,value:n,timestamp:l,isValueShown:s,wasFlipped:!1,skipUpdate:!1,panelState:t}}componentDidMount(){this.updateColumns();const{column:e,value:t,timestamp:n}=this.state;if(e!=null){const{name:s,type:i}=e;this.sendUpdate(s,i,t,n)}}componentDidUpdate(e){const{columns:t}=this.props;t!==e.columns&&this.updateColumns()}inputFilterRef;handleChange({column:e,isValueShown:t=!1,value:n}){let s,i;e!=null&&({name:s,type:i}=e);let o=!0,l=Date.now();this.setState(({panelState:a,timestamp:d,wasFlipped:h,skipUpdate:u})=>{const m=a!=null&&t!==a.isValueShown&&s===a.name&&i===a.type&&n===a.value;return o=(!u&&t&&(!m||!h))??!1,o||(l=d),{panelState:{isValueShown:t,name:s,type:i,value:n,timestamp:l},timestamp:l,wasFlipped:m,skipUpdate:!1}},()=>{o&&this.sendUpdate(s,i,n,l)})}handleClearAllFilters(){this.inputFilterRef.current?.clearFilter()}sendUpdate(e,t,n,s){const{glEventHub:i}=this.props;i.emit(Ye.FILTERS_CHANGED,this,{name:e,type:t,value:n,timestamp:s})}setPanelState(e,t=!1){this.setState({skipUpdate:!t}),this.inputFilterRef.current?.setFilterState(e)}updateColumns(){const{columns:e}=this.props;e!=null&&this.setState(t=>{const{column:n}=t;return n==null&&e.length>0?{columns:[...e],column:e[0]}:n!=null&&!e.find(({name:s,type:i})=>n.name===s&&n.type===i)?{columns:[...e,n]}:{columns:[...e]}})}render(){const{glContainer:e,glEventHub:t}=this.props,{column:n,columns:s,isValueShown:i,value:o}=this.state;return r.jsx(Zn,{className:"iris-input-filter-panel",componentPanel:this,glContainer:e,glEventHub:t,onClearAllFilters:this.handleClearAllFilters,isClonable:!0,isRenamable:!0,children:r.jsx(Yy,{ref:this.inputFilterRef,column:n,columns:s,onChange:this.handleChange,isValueShown:i,value:o})})}}const Zy=(c,e)=>{const{localDashboardId:t}=e;return{columns:Fu(c,t)}},Qy=gt(Zy,null,null,{forwardRef:!0})(Xy),to=Qy;const St=ee.module("FilterSetManagerPanel");function Jy(c){return c.setPanelState!=null}class kl extends w.Component{static defaultProps={panelState:null};static COMPONENT="FilterSetManagerPanel";static changeFilterIndexesToColumnNames(e,t){return t.map(([n,s])=>{if(n>=e.columns.length)return null;const{name:i}=e.columns[n];return{name:i,filter:s}}).filter(n=>n!=null)}constructor(e){super(e),this.handleChange=this.handleChange.bind(this),this.handleFilterApply=this.handleFilterApply.bind(this),this.handleSetsUpdate=this.handleSetsUpdate.bind(this),this.handleGetFilterState=this.handleGetFilterState.bind(this);const{panelState:t,filterSets:n}=e,{selectedId:s=n.length>0?n[0].id:void 0,isValueShown:i=!1}=t??{};this.state={selectedId:s,isValueShown:i,panelState:t}}getFilterState(){const{dashboardOpenedPanelMap:e}=this.props,t=[];return[...e.keys()].forEach(n=>{const s=e.get(n);if(s===void 0){St.error("Could not get panel",s);return}const i=$.getComponentNameFromPanel(s),o=$.getIdFromPanel(s);St.debug("Panel:",s,i);const{glContainer:l=null}=s.props;if(l==null){St.error("Could not get panel container",s);return}const a=$.getComponentConfigFromContainer(l);if(a==null){St.error("Could not get component config from container",l);return}const d=$.getPanelComponentState(a);if(d==null){St.debug(`Panel state is null ${o}`);return}switch(i){case $.getComponentName(Qa):{let h;o!=null&&(h=this.getIrisGridPanelFilters(o,d)),h!=null&&t.push({panelId:o,type:i,state:h});break}case $.getComponentName(to):case $.getComponentName(qs):{const{isValueShown:h,name:u,type:m,value:g}=d;t.push({panelId:o,type:i,state:{isValueShown:h,name:u,type:m,value:g}});break}}}),t}getIrisGridPanelFilters(e,t){const{panelTableMap:n}=this.props,s=n.get(e);if(s==null)return St.error(`Unable to get table for panel ${e}.`),null;const{irisGridState:i={advancedFilters:void 0,quickFilters:void 0},gridState:o={}}=t,{advancedFilters:l,quickFilters:a}=i;let d;l&&(d=kl.changeFilterIndexesToColumnNames(s,l));let h;return a&&(h=kl.changeFilterIndexesToColumnNames(s,a)),{irisGridState:{...i,advancedFilters:d,quickFilters:h},gridState:{...o}}}handleGetFilterState(){return this.getFilterState()}handleChange({isValueShown:e,selectedId:t}){St.debug("handleChange",e,t),this.setState({isValueShown:e,selectedId:t}),this.updatePanelState()}handleFilterApply(e){const{dashboardOpenedPanelMap:t}=this.props,{panels:n,restoreFullState:s=!1}=e;St.debug("Apply filters from filter set",e),n.forEach(({panelId:i,type:o,state:l})=>{if(i==null){St.debug("panel is null",i);return}if(!t.has(i)){St.debug("Ignore closed panel",i);return}St.debug("Apply panel filters",i,o,l);const a=t.get(i);switch(o){case $.getComponentName(Qa):this.restoreIrisGridFilters(a,l,s);break;case $.getComponentName(to):case $.getComponentName(qs):this.restoreInputFilterState(a,l);break}})}handleSetsUpdate(e){const{setDashboardFilterSets:t,localDashboardId:n}=this.props;St.debug("Saving updated sets",e),t(n,[...e])}updatePanelState(){this.setState(({selectedId:e,isValueShown:t})=>({panelState:{selectedId:e,isValueShown:t}}))}restoreIrisGridFilters(e,t,n){const{irisGridState:s={},advancedFilters:i=[],quickFilters:o=[]}=t,{advancedFilters:l=i,quickFilters:a=o}=s,{panelTableMap:d}=this.props,h=$.getIdFromPanel(e);if(h==null){St.error("Panel Id is null.");return}if(d.get(h)==null){St.error(`Unable to get table for panel ${h}.`);return}St.debug("restoreIrisGridFilters",h,t,n),n?e.setStateOverrides(t):e.setFilters({quickFilters:a,advancedFilters:l})}restoreInputFilterState(e,t){const n={...t};delete n.isValueShown,St.debug("restoreInputFilterState",e,n),e&&Jy(e)&&e.setPanelState(n)}render(){const{glContainer:e,glEventHub:t,filterSets:n}=this.props,{isValueShown:s,selectedId:i}=this.state;return r.jsx(Zn,{className:"filter-set-manager-panel",componentPanel:this,glContainer:e,glEventHub:t,isClonable:!0,isRenamable:!0,children:r.jsx("div",{className:"input-filter-container h-100 w-100 container",children:r.jsx(By,{onChange:this.handleChange,onApply:this.handleFilterApply,onUpdateSets:this.handleSetsUpdate,isValueShown:s,filterSets:n,selectedId:i,getFilterState:this.handleGetFilterState})})})}}const eR=(c,e)=>{const{localDashboardId:t}=e;return{filterSets:ty(c,t),dashboardOpenedPanelMap:iu(c,t),dashboardInputFilters:$r(c,t),panelTableMap:Wr(c,t)}},tR=gt(eR,{setDashboardFilterSets:dy},null,{forwardRef:!0})(kl),Fa=tR;const Cc=ee.module("LogPanel");class nR extends w.PureComponent{static defaultProps={session:null};static COMPONENT="LogPanel";static TITLE="Log";constructor(e){super(e),this.handleResize=this.handleResize.bind(this),this.handleShow=this.handleShow.bind(this),this.handleHide=this.handleHide.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.isBottomVisible=!0,this.logView=null;const{session:t}=this.props;this.state={session:t}}isBottomVisible;logView;handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions(),this.logView&&(this.logView.triggerFindWidget(),this.isBottomVisible&&this.logView.scrollToBottom())}handleHide(){this.logView&&(this.isBottomVisible=this.logView.isBottomVisible())}handleSessionOpened(e){Cc.debug("Session opened",[e]),this.setState({session:e})}handleSessionClosed(e){Cc.debug("Session closed",e)}updateDimensions(){this.logView&&this.logView.updateDimensions()}render(){const{glContainer:e,glEventHub:t}=this.props,{session:n}=this.state;return r.jsxs(Zn,{componentPanel:this,glContainer:e,glEventHub:t,onResize:this.handleResize,onHide:this.handleHide,onShow:this.handleShow,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,children:[n==null&&r.jsx("div",{className:"log-panel-disconnected-message",children:"Waiting for session connection"}),n!=null&&r.jsx($f,{session:n,ref:s=>{this.logView=s}})]})}}const sR=(c,e)=>({session:Qs(c,e.localDashboardId)?.session}),iR=gt(sR,null,null,{forwardRef:!0})(nR),Ml=iR;class oR extends w.PureComponent{static defaultProps={isEditing:!1};render(){const{isEditing:e,children:t,onDoubleClick:n}=this.props;return r.jsxs("div",{className:"markdown-editor-container h-100 w-100",onDoubleClick:n,children:[r.jsx("div",{className:K("text-muted","edit-hint",{viewing:e===void 0||!e}),children:r.jsxs("span",{children:["double-click to edit ",r.jsx(X,{icon:mo})]})}),t]})}}const lR=ee.module("MarkdownStartPage");class aR extends w.PureComponent{static defaultProps={closedMarkdowns:[],onOpen:()=>{},onCreate:()=>{},onDelete:()=>{}};constructor(e){super(e),this.handleDeleteButtonClick=this.handleDeleteButtonClick.bind(this),this.handleDeleteModalClose=this.handleDeleteModalClose.bind(this),this.state={isDeleteModalShown:!1}}handleDeleteButtonClick(e){this.setState({isDeleteModalShown:!0,toBeDeleted:e})}handleDeleteModalClose(){this.setState({isDeleteModalShown:!1,toBeDeleted:void 0})}handleDeleteMarkdown(e){if(lR.debug("delete markdown: ",e),e!==void 0){const{onDelete:t}=this.props;t(e)}this.setState({isDeleteModalShown:!1,toBeDeleted:void 0})}render(){const{closedMarkdowns:e,onOpen:t,onCreate:n}=this.props,{isDeleteModalShown:s,toBeDeleted:i}=this.state;return r.jsx("div",{className:"markdown-panel-start-page h-100 w-100",children:r.jsxs("div",{className:"markdown-panel-start-page-container",children:[r.jsxs("div",{className:"markdown-panel-start-list",children:[r.jsx("h3",{className:"list-title",children:"Start"}),r.jsx("div",{className:"list-item",children:r.jsx(_,{kind:"ghost",className:"title",onClick:n,children:"New Markdown Note"})})]}),r.jsxs("div",{className:"markdown-panel-start-list",children:[r.jsx("h3",{className:"list-title",children:"Recently Closed from Dashboard"}),e.map(o=>r.jsxs("div",{className:"list-item",children:[r.jsx(_,{kind:"ghost",className:"title",onClick:()=>t(o),children:o.title}),r.jsx("button",{className:"btn-link icon",type:"button",onClick:()=>{this.handleDeleteButtonClick(o)},children:r.jsx(X,{icon:Wt})})]},o.id)),r.jsxs($l,{isOpen:s,toggle:this.handleDeleteModalClose,className:"modal-dialog-centered markdown-delete-modal theme-bg-light",children:[r.jsx(Wl,{children:"Are you sure you want to permanently delete this note?"}),r.jsx(Gl,{children:"You can't undo this action."}),r.jsxs(Gc,{children:[r.jsx(_,{kind:"secondary",onClick:this.handleDeleteModalClose,children:"Cancel"}),r.jsx(_,{kind:"danger",onClick:()=>{this.handleDeleteMarkdown(i)},children:"Delete"})]})]})]})]})})}}const rR=aR,dR=c=>{const{children:e,className:t}=c,n=t!==void 0&&t?.startsWith("language-")?t.substring(9):"plaintext";return r.jsx("pre",{children:r.jsx("code",{children:r.jsx(zl,{language:n,children:ae.Children.map(e,s=>typeof s=="string"?s.trim():s)})})})};class cR extends w.PureComponent{static defaultProps={isEditing:!1,content:""};constructor(e){super(e),this.container=null}container;render(){const{isEditing:e,content:t,onEditorInitialized:n}=this.props;return r.jsx("div",{className:"markdown-editor-container",ref:s=>{this.container=s},children:e?r.jsx(pr,{settings:{language:"markdown",value:t,lineNumbers:"off"},onEditorInitialized:n}):r.jsx(Hc,{components:{code:dR},children:t})})}}const Zo=ee.module("MarkdownPanel");class hR extends w.Component{static defaultProps={panelState:null};static COMPONENT="MarkdownPanel";constructor(e){super(e),this.handleContainerDoubleClick=this.handleContainerDoubleClick.bind(this),this.handleCreateMarkdown=this.handleCreateMarkdown.bind(this),this.handleDeleteMarkdown=this.handleDeleteMarkdown.bind(this),this.handleOpenMarkdown=this.handleOpenMarkdown.bind(this),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorBlur=this.handleEditorBlur.bind(this),this.handleEditorResize=this.handleEditorResize.bind(this);const{panelState:t}=e;let n=null;t!=null&&t.content!=null&&({content:n}=t),this.state={isStartPageShown:n==null,isEditing:!1,content:n,panelState:t},this.markdownEditor=null}markdownEditor;editor;setEditorPosition(e){N(this.markdownEditor);const{container:t}=this.markdownEditor;if(this.editor&&t){const n=t.getBoundingClientRect().top,s=t.scrollTop,i=t.scrollHeight,o=this.editor.getModel()?.getLineCount()??0;let l=Math.round((s+e-n)/i*o);l>o&&(l=o),this.editor.revealLine(l),this.editor.setPosition({lineNumber:l,column:1}),this.editor.focus()}}getClosedMarkdowns=he(e=>e.filter(t=>t.component==="MarkdownPanel").reverse());handleContainerDoubleClick(e){const{isEditing:t}=this.state,n=e.clientY;t||this.setState({isEditing:!0},()=>{this.setEditorPosition(n)})}handleEditorInitialized(e){Zo.debug("Markdown Editor Initialized..."),this.editor=e}handleCreateMarkdown(){Zo.debug("create markdown..."),this.setState({isStartPageShown:!1,content:"",isEditing:!0,panelState:{content:""}},()=>{this.editor!=null&&this.editor.focus!=null&&this.editor.focus()})}handleOpenMarkdown(e){Zo.debug("open markdown...",e);const{glContainer:t,glEventHub:n}=this.props,s=$.getComponentConfigFromContainer(t);n.emit(we.REOPEN,e,s)}handleDeleteMarkdown(e){const{glEventHub:t}=this.props;t.emit(we.DELETE,e)}handleEditorBlur(e){Zo.debug("markdown content changed, saving...");const{isEditing:t}=this.state;if(!t||this.markdownEditor!=null&&this.markdownEditor.container!=null&&this.markdownEditor.container.contains(e.relatedTarget))return;const n=this.editor?.getValue();this.setState({content:n,isEditing:!1,panelState:{content:n}})}handleEditorResize(){const{isEditing:e}=this.state;e&&this.editor&&this.editor.layout()}render(){const{glContainer:e,glEventHub:t,closedPanels:n}=this.props,{isEditing:s,isStartPageShown:i,content:o}=this.state,l=this.getClosedMarkdowns(n);return r.jsx(Zn,{glContainer:e,glEventHub:t,className:"markdown-panel",componentPanel:this,onResize:this.handleEditorResize,onBlur:this.handleEditorBlur,isClonable:!0,isRenamable:!0,children:i?r.jsx(rR,{closedMarkdowns:l,onCreate:this.handleCreateMarkdown,onOpen:this.handleOpenMarkdown,onDelete:this.handleDeleteMarkdown}):r.jsx(oR,{isEditing:s,onDoubleClick:this.handleContainerDoubleClick,children:r.jsx(cR,{ref:a=>{this.markdownEditor=a},isEditing:s,content:o??void 0,onEditorInitialized:this.handleEditorInitialized})})})}}const uR=(c,e)=>{const{localDashboardId:t}=e;return{closedPanels:rb(c,t)}},mR=gt(uR,null,null,{forwardRef:!0})(hR),$i=mR;class gR extends w.PureComponent{static defaultProps={onRunCode:()=>{}};constructor(e){super(e),this.handleRunSelected=this.handleRunSelected.bind(this),this.renderCodeBlock=this.renderCodeBlock.bind(this),this.renderLink=this.renderLink.bind(this),this.commands=new Map,this.codeElements=new Map,this.editorScrollView=ae.createRef(),this.state={hasCode:!1,hasRunCode:!1,nextStartLine:null}}componentDidMount(){this.updateHasCode()}componentDidUpdate(){this.updateHasCode()}commands;codeElements;editorScrollView;updateHasCode(){const{hasCode:e}=this.state;this.commands.size===0&&e?this.setState({hasCode:!1}):this.commands.size>0&&!e&&this.setState({hasCode:!0})}getNextStartLine(e){const t=[...this.commands.keys()],n=t.findIndex(s=>s===e)+1;return n>=t.length?null:t[n]}handleRunSelected(e){e.preventDefault(),e.stopPropagation();const{nextStartLine:t}=this.state,n=[...this.commands.keys()],s=n.findIndex(h=>h===t||t==null);if(s<0)return;const i=n[s],o=this.commands.get(i),l=this.getNextStartLine(i),d=this.codeElements.get(i)?.current?.parentElement?.nextElementSibling;if(d!=null){const{offsetTop:h}=d,u=h;this.editorScrollView.current?.scroll({top:u,left:0})}this.runCode(o),this.setState({nextStartLine:l})}runCode(e){const{onRunCode:t}=this.props;t(e),this.setState({hasRunCode:!0})}renderCodeBlock(e){const{children:t,className:n,inline:s,node:i}=e,{hasRunCode:o,nextStartLine:l}=this.state,{children:a,position:d}=i;N(d);const{start:h}=d,{line:u}=h,m=a[0].value,g=ae.createRef(),p=this.commands.size===0,C=l===u||p&&l==null&&!o,f=n!==void 0&&n.startsWith("language-")?n.substring(9):"plaintext";return s!=null&&s?r.jsx("code",{className:n,children:t}):(this.commands.set(u,m),this.codeElements.set(u,g),r.jsxs("div",{className:K("markdown-notebook-code-block",{"is-selected":C}),ref:g,onClick:()=>{this.setState({nextStartLine:u})},role:"presentation",children:[r.jsx(_,{kind:"ghost",icon:al,className:"btn-play-block",onClick:S=>{S.stopPropagation(),S.preventDefault(),this.runCode(m),this.setState({nextStartLine:u})},tooltip:"Run code"}),r.jsx("code",{children:r.jsx(zl,{language:f,children:ae.Children.map(t,S=>typeof S=="string"?S.trim():S)})})]}))}renderLink(e){const{onLinkClick:t}=this.props,{href:n,children:s,target:i}=e;return r.jsx("a",{href:n,onClick:t,target:i,children:s})}render(){const{content:e,transformImageUri:t,transformLinkUri:n}=this.props,{hasCode:s,hasRunCode:i,nextStartLine:o}=this.state;return r.jsxs("div",{className:"markdown-notebook",children:[r.jsx("div",{className:"markdown-notebook-toolbar",children:r.jsx(_,{className:K("btn-play-selected-cell",{flashing:s&&!i}),kind:"ghost",icon:al,onClick:this.handleRunSelected,tooltip:"Run code and select next",disabled:i&&o==null||!s,children:"Run Selected Code"})}),r.jsx("div",{className:"markdown-notebook-content",ref:this.editorScrollView,children:r.jsx(Hc,{components:{code:this.renderCodeBlock,a:this.renderLink},linkTarget:"_blank",remarkPlugins:[Cm],transformLinkUri:n,transformImageUri:t,includeElementIndex:!0,children:e})})]})}}const pR=gR;const Oe=ee.module("NotebookPanel"),Sc=400;class Ws extends w.Component{static COMPONENT="NotebookPanel";static POPPER_OPTIONS={placement:"bottom-end"};static DEFAULT_NAME="Untitled";static handleError(e){ve.isCanceled(e)||Oe.error(e)}static defaultProps={isDashboardActive:!0,isPreview:!1,session:null,sessionLanguage:null,defaultNotebookSettings:null};static languageFromFileName(e){switch(me.getExtension(e).toLowerCase()){case"py":case"python":return"python";case"groovy":return"groovy";case"scala":return"scala";default:return null}}constructor(e){super(e),this.handleBlur=this.handleBlur.bind(this),this.handleCloseCancel=this.handleCloseCancel.bind(this),this.handleCloseDiscard=this.handleCloseDiscard.bind(this),this.handleCloseSave=this.handleCloseSave.bind(this),this.handleCopy=this.handleCopy.bind(this),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorWillDestroy=this.handleEditorWillDestroy.bind(this),this.handleEditorChange=this.handleEditorChange.bind(this),this.handleFind=this.handleFind.bind(this),this.handleMinimapChange=this.handleMinimapChange.bind(this),this.handleWordWrapChange=this.handleWordWrapChange.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleLinkClick=this.handleLinkClick.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.handleTabClick=this.handleTabClick.bind(this),this.handleRenameFile=this.handleRenameFile.bind(this),this.handleResize=this.handleResize.bind(this),this.handleRunCommand=this.handleRunCommand.bind(this),this.handleRunAll=this.handleRunAll.bind(this),this.handleRunSelected=this.handleRunSelected.bind(this),this.handleSave=this.handleSave.bind(this),this.handleSaveAsCancel=this.handleSaveAsCancel.bind(this),this.handleSaveAsSubmit=this.handleSaveAsSubmit.bind(this),this.handleSaveError=this.handleSaveError.bind(this),this.handleSaveSuccess=this.handleSaveSuccess.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleShowRename=this.handleShowRename.bind(this),this.handleTab=this.handleTab.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTransformLinkUri=this.handleTransformLinkUri.bind(this),this.handleOverwrite=this.handleOverwrite.bind(this),this.handlePreviewPromotion=this.handlePreviewPromotion.bind(this),this.getDropdownOverflowActions=this.getDropdownOverflowActions.bind(this),this.pending=new Xn,this.debouncedSavePanelState=Ge(this.savePanelState.bind(this),Sc),this.debouncedLoad=Ge(this.load.bind(this),Sc),this.notebook=null,this.tabTitleElement=null,this.tabInitOnce=!1;const{isDashboardActive:t,session:n,sessionLanguage:s,panelState:i}=e;let o={value:"",language:"",wordWrap:"off"},l=null,{isPreview:a}=e;i!=null&&({fileMetadata:l=l,isPreview:a=a,settings:o=o}=i);const d=l!=null&&me.hasPath(l.itemName),u=d===!0&&o.value!=null||!d&&o.value!=null&&o.value.length>0?1:0;this.state={error:void 0,isDashboardActive:t,isFocused:!1,isLoading:!0,isLoaded:!1,isPreview:a,savedChangeCount:0,changeCount:u,fileMetadata:l,settings:o,session:n,sessionLanguage:s,panelState:{fileMetadata:l,settings:o},showCloseModal:!1,showSaveAsModal:!1,scriptCode:""},Oe.debug("constructor",e,this.state)}componentDidMount(){const{glContainer:e,glEventHub:t}=this.props,{tab:n}=e;n!=null&&this.initTab(n),this.initNotebookContent(),t.on(Pe.RENAME_FILE,this.handleRenameFile),e.on(Pe.PROMOTE_FROM_PREVIEW,this.handlePreviewPromotion)}componentDidUpdate(e,t){const{isPreview:n,settings:s}=this.state,{wordWrap:i}=s,{defaultNotebookSettings:o}=this.props;n!==t.isPreview&&this.setPreviewStatus(),i!==t.settings.wordWrap&&(this.updateEditorWordWrap(),this.debouncedSavePanelState()),o.isMinimapEnabled!==e.defaultNotebookSettings.isMinimapEnabled&&this.updateEditorMinimap()}componentWillUnmount(){this.debouncedSavePanelState.flush(),this.pending.cancel();const{glEventHub:e,glContainer:t}=this.props,{fileMetadata:n,isPreview:s}=this.state;e.off(Pe.RENAME_FILE,this.handleRenameFile),t.off(Pe.PROMOTE_FROM_PREVIEW,this.handlePreviewPromotion),e.emit(Pe.UNREGISTER_FILE,n,s)}pending;debouncedSavePanelState;debouncedLoad;notebook;tabTitleElement;tabInitOnce;editor;initTab(e){this.tabInitOnce||(this.tabInitOnce=!0,this.initTabCloseOverride()),this.initTabClasses(e)}initTabCloseOverride(){const{glContainer:e}=this.props;e.beforeClose(t=>{if(t?.force===!0)return!0;const{changeCount:n,savedChangeCount:s}=this.state;return n!==s?(this.setState({showCloseModal:!0}),!1):!0})}initTabClasses(e){const t=e.element.get(0);N(t);const n=t.querySelector(".lm_title");this.tabTitleElement=n,n?.classList.add("notebook-title"),this.setPreviewStatus()}getNotebookValue(){const{changeCount:e,savedChangeCount:t,settings:n}=this.state,{value:s}=n;if(e!==t&&this.notebook){const i=this.notebook.getValue();return i??s}return s}initNotebookContent(){const{fileMetadata:e,settings:t,isPreview:n}=this.state;if(e&&e.id){Oe.debug("Init content from file"),this.registerFileMetadata(e,n),this.load();return}if(t.value!=null){Oe.debug("Use content passed in the settings prop"),this.handleLoadSuccess();return}this.handleLoadError(new Error("Missing file metadata"))}closeFileTabById(e){const{glEventHub:t}=this.props;t.emit(Pe.CLOSE_FILE,{id:e})}registerFileMetadata(e,t){const{glEventHub:n,metadata:s}=this.props,{id:i}=s;n.emit(Pe.REGISTER_FILE,i,e,t)}renameTab(e,t){const{glEventHub:n}=this.props;n.emit(Pe.RENAME,e,t)}load(){const{fileMetadata:e,settings:t}=this.state;N(e);const{id:n}=e,{fileStorage:s}=this.props;this.pending.add(s.loadFile(n)).then(i=>{Oe.debug("Loaded file",i);const{filename:o}=i,{itemName:l}=this.state;if(o!==l){const{metadata:d}=this.props,{id:h}=d;this.renameTab(h,me.getBaseName(o))}const a={...t,language:Ws.languageFromFileName(o)??""};t.value==null&&(a.value=i.content),t.wordWrap===void 0&&(t.wordWrap="off"),this.setState({fileMetadata:{id:o,itemName:o},settings:a}),this.debouncedSavePanelState()}).then(this.handleLoadSuccess).catch(this.handleLoadError)}save(){const{fileMetadata:e}=this.state;if(e&&me.hasPath(e.itemName)){const t=this.getNotebookValue();return t!==void 0?(this.saveContent(e.itemName,t),!0):!1}return this.setState({showSaveAsModal:!0}),!1}saveContent(e,t){Oe.debug("saveContent",e,t),this.updateSavedChangeCount();const{fileStorage:n}=this.props;this.pending.add(n.saveFile({filename:e,content:t,basename:e})).then(this.handleSaveSuccess).catch(this.handleSaveError)}updateSavedChangeCount(){this.setState(({changeCount:e})=>({savedChangeCount:e}))}setPreviewStatus(){if(!this.tabTitleElement)return;const{isPreview:e}=this.state;Oe.debug("setPreviewStatus",this.tabTitleElement,e),e?this.tabTitleElement.classList.add("is-preview"):this.tabTitleElement.classList.remove("is-preview")}handlePreviewPromotion(){this.removePreviewStatus()}getSettings=he((e,t)=>({...e,minimap:{enabled:t}}));getOverflowActions=he((e,t)=>[{title:"Find",icon:Hg,action:this.handleFind,group:se.groups.high,shortcut:It.NOTEBOOK.FIND,order:10},{title:"Show Minimap",icon:e?Yn:void 0,action:this.handleMinimapChange,group:se.groups.medium,shortcut:It.NOTEBOOK.MINIMAP,order:20},{title:"Word Wrap",icon:t?Yn:void 0,action:this.handleWordWrapChange,group:se.groups.medium,shortcut:It.NOTEBOOK.WORDWRAP,order:30}]);savePanelState(){this.setState(e=>{const{changeCount:t,savedChangeCount:n,fileMetadata:s,isPreview:i,settings:o}=e,l=this.getNotebookValue(),a=t!==n?l:void 0,d={...o,value:l},u={settings:{...o,value:a},fileMetadata:s,isPreview:i};return Oe.debug("Saving panel state",u),{settings:d,panelState:u}})}handleCloseDiscard(){this.setState({showCloseModal:!1});const{glContainer:e}=this.props;e.close({force:!0})}handleCloseSave(){if(this.setState({showCloseModal:!1}),this.save()){const{glContainer:e}=this.props;e.close({force:!0})}}handleCloseCancel(){this.setState({showCloseModal:!1})}handleOverwrite(e){const{glEventHub:t}=this.props;t.emit(Pe.CLOSE_FILE,{id:e,itemName:e},{force:!0}),this.focus()}handleCopy(){const{fileMetadata:e,settings:t}=this.state;N(e);const n=this.getNotebookValue(),{language:s}=t,{itemName:i}=e,o=me.getCopyFileName(i);Oe.debug("handleCopy",e,i,o),this.createNotebook(o,s,n)}handleEditorInitialized(e){this.editor=e}handleEditorWillDestroy(){this.editor=void 0}handleEditorChange(e){Oe.debug2("handleEditorChanged",e),this.removePreviewStatus(),this.setState(t=>{const{changeCount:n,savedChangeCount:s}=t,{isUndoing:i,isRedoing:o}=e;return i?{changeCount:n-1,savedChangeCount:s}:!o&&n<s?{changeCount:n+1,savedChangeCount:0}:{changeCount:n+1,savedChangeCount:s}}),this.debouncedSavePanelState()}handleFind(){this.notebook&&this.notebook.toggleFind()}updateEditorMinimap(){if(this.editor){const{defaultNotebookSettings:e}=this.props;this.editor.updateOptions({minimap:{enabled:e.isMinimapEnabled}})}}handleMinimapChange(){const{settings:e,defaultNotebookSettings:t,saveSettings:n}=this.props,s={...e,defaultNotebookSettings:{isMinimapEnabled:!t.isMinimapEnabled}};n(s)}updateEditorWordWrap(){if(this.editor){const{settings:e}=this.state,{wordWrap:t}=e;this.editor.updateOptions({wordWrap:t})}}handleWordWrapChange(){this.editor&&this.setState(e=>{const{settings:t}=e,n=t.wordWrap==="on"?"off":"on";return{settings:{...t,wordWrap:n}}})}handleBlur(){Oe.debug("handleBlur"),this.setState({isFocused:!1})}handleFocus(){Oe.debug("handleFocus"),this.setState({isFocused:!0})}handleLinkClick(e){const{notebooksUrl:t,session:n,sessionLanguage:s}=this.props,{href:i}=e.currentTarget;if(!i||!i.startsWith(t))return;e.stopPropagation(),e.preventDefault();const o=`/${i.substring(t.length)}`.replace(/%20/g," ");if(o==="/"){Oe.debug("Ignoring invalid notebook link",o);return}Oe.debug("Notebook link clicked, opening",o);const{glEventHub:l}=this.props,a={value:null,language:s},d={id:o,itemName:o};l.emit(Pe.SELECT_NOTEBOOK,n,s,a,d)}handleLoadSuccess(){this.setState({error:void 0,isLoaded:!0,isLoading:!1})}handleLoadError(e){let t=e;ve.isCanceled(t)||(ve.isTimedOut(t)&&(t=new Error("File not found.")),Oe.error(t),this.setState({error:t,isLoading:!1}))}handleSave(){Oe.debug("handleSave"),this.save()}handleSaveSuccess(e){const{fileStorage:t}=this.props,n={id:e.filename,itemName:e.filename},s=Ws.languageFromFileName(e.filename)??"";this.setState(i=>{const{fileMetadata:o}=i,l={...i.settings,language:s};return Oe.debug("handleSaveSuccess",n,o,l),o&&me.hasPath(o.itemName)&&o.itemName!==n.itemName&&(Oe.debug("handleSaveSuccess deleting old file",o.itemName),t.deleteFile(o.itemName).catch(Ws.handleError)),{fileMetadata:n,settings:l,isPreview:!1}}),this.debouncedSavePanelState(),this.registerFileMetadata(n,!1)}handleSaveError(e){ve.isCanceled(e)||(this.setState({savedChangeCount:0}),Oe.error(e))}handleSaveAsCancel(){this.setState({showSaveAsModal:!1})}handleSaveAsSubmit(e,t=!1){t&&this.handleOverwrite(e),Oe.debug("handleSaveAsSubmit",e);const{fileMetadata:n}=this.state;if(!n)return;const{itemName:s}=n,i=this.getNotebookValue()??"";if(this.setState({showSaveAsModal:!1}),me.getBaseName(s)!==me.getBaseName(e)){const{metadata:o}=this.props,{id:l}=o;this.renameTab(l,me.getBaseName(e))}this.saveContent(e,i)}handleRenameFile(e,t,n){const{fileMetadata:s,panelState:i}=this.state,{glContainer:o}=this.props;if(s?.itemName===`/${t}`&&n&&JSON.stringify(i)!==JSON.stringify(n)){o.close();return}s&&s.id===e&&(this.setState({fileMetadata:{id:t,itemName:t}}),this.debouncedSavePanelState())}handleResize(){this.notebook?.updateDimensions()}handleRunCommand(e){this.runCommand(e)}handleRunAll(){if(!this.notebook){Oe.error("Editor is not initialized.");return}this.runCommand(this.notebook.getValue()??void 0)}handleRunSelected(){if(!this.notebook){Oe.error("Editor is not initialized.");return}this.runCommand(this.notebook.getSelectedCommand())}handleSessionOpened(e,{language:t}){this.setState({session:e,sessionLanguage:t})}handleSessionClosed(){this.setState({session:void 0,sessionLanguage:void 0})}handleShow(){Oe.debug("handleShow"),this.notebook?.updateDimensions()}handleShowRename(){this.setState({showSaveAsModal:!0})}handleTab(e){Oe.debug("NotebookPanel tab event",e),this.initTab(e)}handleTabFocus(...e){Oe.debug("handleTabFocus",...e);const{glContainer:t}=this.props;this.setState({isDashboardActive:!0}),this.notebook&&!t.isHidden&&this.notebook.updateDimensions()}handleTabBlur(){Oe.debug("handleTabBlur"),this.setState({isDashboardActive:!1})}handleTabClick(e){Oe.debug("handle NotebookPanel tab click"),this.focus(),e.detail===2&&this.removePreviewStatus()}handleTransformLinkUri(e){const{notebooksUrl:t}=this.props,{fileMetadata:n}=this.state;if(e.endsWith("/"))return e;if(e.startsWith("/"))return`${t}${e.substring(1)}`;let s=n?.itemName;if(s===void 0)return e;s.charAt(0)==="/"&&(s=s.substring(1));const i=new URL(s,t);return new URL(e,i).href}focus(){requestAnimationFrame(()=>{this.notebook&&this.notebook.focus()})}createNotebook(e,t,n=""){const{glEventHub:s}=this.props,{session:i,sessionLanguage:o,settings:l}=this.state,a={...l,language:t,value:n},d={id:null,itemName:e};Oe.debug("handleCreateNotebook",i,o,a,d),s.emit(Pe.CREATE_NOTEBOOK,i,o,a,d)}runCommand(e){if(e===void 0||e===""){Oe.debug("Ignoring empty command.");return}this.removePreviewStatus();const{glEventHub:t}=this.props;t.emit(Bt.SEND_COMMAND,e,!1,!0)}removePreviewStatus(){this.setState(({isPreview:e})=>{if(e){const{fileMetadata:t}=this.state;return t&&this.registerFileMetadata(t,!1),{isPreview:!1}}return null})}getDropdownOverflowActions(){const{defaultNotebookSettings:e}=this.props,{settings:t}=this.state;return this.getOverflowActions(e.isMinimapEnabled,this.getSettings(t,e.isMinimapEnabled).wordWrap==="on")}render(){const{fileStorage:e,glContainer:t,glContainer:{tab:n},glEventHub:s,defaultNotebookSettings:i}=this.props,{changeCount:o,savedChangeCount:l,error:a,isDashboardActive:d,isLoaded:h,isLoading:u,isPreview:m,fileMetadata:g,session:p,sessionLanguage:C,settings:f,showCloseModal:S,showSaveAsModal:v}=this.state,b=d&&!t.isHidden&&!m,T=g?.itemName??Ws.DEFAULT_NAME,y=T.endsWith(".md"),E=g?.id!=null,R=this.getSettings(f,i.isMinimapEnabled),x=p!=null,D=C===R.language,L=!h||!x||!D,M=!h,j=[{action:this.handleSave,shortcut:qn.SAVE},{action:this.handleMinimapChange,shortcut:It.NOTEBOOK.MINIMAP},{action:this.handleWordWrapChange,shortcut:It.NOTEBOOK.WORDWRAP}],A=Nd.getDisabledRunTooltip(x,D,"Notebook extension","Run"),W=Nd.getDisabledRunTooltip(x,D,"Notebook extension","Run Selected"),H=[{title:E?"Rename":"Save As…",order:10,group:se.groups.high,action:this.handleShowRename},{title:"Copy File",action:this.handleCopy,group:se.groups.high,order:20}],U=n?.element.find(".lm_title_before").get(0);return r.jsxs(r.Fragment,{children:[U&&ll.createPortal(r.jsx("span",{className:K("editor-unsaved-indicator",{"is-unsaved":o!==l})}),U),r.jsxs(Zn,{className:"notebook-container",componentPanel:this,glContainer:t,glEventHub:s,onTab:this.handleTab,onResize:this.handleResize,onShow:this.handleShow,onTabClicked:this.handleTabClick,onTabFocus:this.handleTabFocus,onTabBlur:this.handleTabBlur,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onFocus:this.handleFocus,onBlur:this.handleBlur,additionalActions:H,renderTabTooltip:()=>T,children:[!y&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"notebook-toolbar",children:[r.jsxs("span",{children:[r.jsx(_,{kind:"ghost",className:"btn-play",onClick:this.handleRunAll,disabled:L,icon:r.jsx(X,{icon:al,transform:"grow-4"}),tooltip:`Run ${It.NOTEBOOK.RUN.getDisplayText()}`,"aria-label":"Run"}),A!=null&&r.jsx(tt,{children:A})]}),r.jsxs("span",{children:[r.jsx(_,{kind:"ghost",className:"btn-play",onClick:this.handleRunSelected,disabled:L,icon:r.jsx(X,{icon:Ug,transform:"grow-4"}),tooltip:`Run Selected ${It.NOTEBOOK.RUN_SELECTED.getDisplayText()}`,"aria-label":"Run Selected"}),W!=null&&r.jsx(tt,{children:W})]}),r.jsx(_,{kind:"ghost",className:"mr-auto",disabled:M,onClick:this.handleSave,icon:nh,tooltip:`Save ${qn.SAVE.getDisplayText()}`,"aria-label":"Save"}),r.jsx(_,{kind:"ghost",className:"btn-overflow btn-link-icon",disabled:M,icon:qc,tooltip:"More Actions...",onClick:()=>{},children:r.jsx(Wn,{actions:this.getDropdownOverflowActions,popperOptions:Ws.POPPER_OPTIONS})})]}),r.jsx(Ff,{isLoaded:h,isLoading:u,error:a,onChange:this.handleEditorChange,onRunCommand:this.handleRunCommand,session:p,sessionLanguage:C,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy,settings:R,focusOnMount:b,ref:P=>{this.notebook=P}})]}),y&&r.jsx(pR,{content:R.value??"",onLinkClick:this.handleLinkClick,onRunCode:this.handleRunCommand,transformImageUri:this.handleTransformLinkUri,transformLinkUri:this.handleTransformLinkUri}),r.jsx(Ou,{isOpen:v,type:"file",defaultValue:T,title:E?"Rename":"Save file as",onSubmit:this.handleSaveAsSubmit,onCancel:this.handleSaveAsCancel,notifyOnExtensionChange:!0,storage:e}),r.jsx(io,{isOpen:S,headerText:`Do you want to save the changes you made to ${T}?`,bodyText:"Your changes will be lost if you don't save them.",onCancel:this.handleCloseCancel,onDiscard:this.handleCloseDiscard,onConfirm:this.handleCloseSave,discardButtonText:"Discard Changes",confirmButtonText:"Save"}),r.jsx(se,{actions:j})]})]})}}const fR=(c,e)=>{const t=Sh(c),n=pt(c),s=rC(c),i=Qs(c,e.localDashboardId),{session:o,config:l}=i??{},{type:a}=l??{};return{fileStorage:t,settings:n,defaultNotebookSettings:s,session:o,sessionLanguage:a}},CR=gt(fR,{saveSettings:ql},null,{forwardRef:!0})(Ws),hs=CR;class SR extends w.Component{static defaultProps={panelState:null};static COMPONENT="PandasPanel";constructor(e){super(e),this.irisGridRef=ae.createRef(),this.buttonRef=ae.createRef(),this.handleReload=this.handleReload.bind(this),this.handleGridStateChange=this.handleGridStateChange.bind(this),this.handlePanelStateUpdate=this.handlePanelStateUpdate.bind(this);const{panelState:t}=e;this.state={shouldFocusGrid:!1,panelState:t}}buttonRef;irisGridRef;handleReload(){this.irisGridRef.current?.initModel(),this.buttonRef.current?.blur(),this.setState({shouldFocusGrid:!0})}handleGridStateChange(){const{shouldFocusGrid:e}=this.state;e&&this.irisGridRef.current?.irisGrid?.current?.grid&&(this.irisGridRef.current.irisGrid.current.grid.focus(),this.setState({shouldFocusGrid:!1}))}handlePanelStateUpdate(e){this.setState({panelState:e})}render(){const{...e}=this.props;return r.jsx(Xs,{ref:this.irisGridRef,onStateChange:this.handleGridStateChange,onPanelStateUpdate:this.handlePanelStateUpdate,...e,children:r.jsxs(_,{ref:this.buttonRef,kind:"primary",className:"btn-pandas",onClick:this.handleReload,tooltip:"Click to refresh pandas dataframe, updates do not occur automatically.",children:["pandas dataframe",r.jsxs("span",{children:[r.jsx(X,{icon:rr,transform:"shrink-1",className:"mr-1"}),"Reload"]})]})})}}const Na=SR;function bR(c){Rs(c);const{id:e,layout:t,registerComponent:n,hydrate:s}=c,i=w.useCallback(({dragEvent:o,fetch:l,panelId:a=ze.generate(),widget:d})=>{const{name:h,type:u}=d;if(u!==dh.VariableType.FIGURE)return;const m={name:h,figure:h},g=()=>l().then(f=>pl.makeModel(void 0,f)),p={type:"react-component",component:Ti.COMPONENT,props:{localDashboardId:e,id:a,metadata:m,makeModel:g},title:h,id:a},{root:C}=t;$.openComponent({root:C,config:p,dragEvent:o})},[e,t]);return w.useEffect(function(){const l=[n(Ti.COMPONENT,Ti,s)];return()=>{l.forEach(a=>a())}},[s,n]),je(t.eventHub,we.OPEN,i),null}function wR(c){Rs(c);const{id:e,layout:t}=c,n=w.useCallback(({metadata:s,panelId:i=ze.generate(),table:o})=>{const{settings:l}=s,a=()=>pl.makeModelFromSettings(l,o),d=qe.titleFromSettings(l),h={type:"react-component",component:Ti.COMPONENT,props:{localDashboardId:e,id:i,metadata:s,makeModel:a},title:d,id:i},{root:u}=t;$.openComponent({root:u,config:h})},[e,t]);return je(t.eventHub,cn.CREATE_CHART,n),null}const st=ee.module("ConsolePlugin");function bc(c){return c.notebook!==void 0}function vR(c){Rs(c)}function TR(c){vR(c);const{id:e,hydrateConsole:t,layout:n,panelManager:s,registerComponent:i,notebooksUrl:o}=c,l=w.useRef(0),[a,d]=w.useState(new Map),[h,u]=w.useState(new Map),m=tr(),g=w.useCallback(()=>s.getLastUsedPanelOfType(fi),[s]),p=w.useCallback((V,z)=>{d(Z=>new Map(Z.set(V,z)))},[d]),C=w.useCallback(V=>{d(z=>(z.delete(V),new Map(z)))},[d]),f=w.useCallback((V,z)=>{u(Z=>new Map(Z.set(V,z)))},[u]),S=w.useCallback(V=>{u(z=>(z.delete(V),new Map(z)))},[u]),v=w.useCallback((V,z=!0,Z=!0)=>{if(!(V&&V.trim()))st.info("Ignoring empty code");else{const re=g();if(!re||!(re instanceof fi.WrappedComponent)){st.error("Console panel not found");return}st.debug("Send command: ",V,z,Z),re.addCommand(V,z,Z)}},[g]),b=w.useCallback(V=>{m(ry(e,V))},[m,e]),T=w.useCallback(({language:V})=>{const z=V==="python"?"py":V;let Z=null;return z==null?(st.debug("No extension for language",V),Z=`Untitled-${l.current}`):Z=`Untitled-${l.current}.${z}`,l.current+=1,Z},[]),y=w.useCallback((V,z=!0)=>{const{id:Z}=V;if(Z!=null&&a.has(Z))return a.get(Z);if(Z!=null&&h.has(Z))return h.get(Z);if(z)return ze.generate()},[a,h]),E=w.useCallback((V,z)=>{$.renameComponent(n.root,{id:V},z)},[n.root]),R=w.useCallback((V,z)=>{st.debug("Rename file panel",V,z);let Z;if(a.has(V)&&(Z=a.get(V),C(V),Z!=null&&p(z,Z)),h.has(V)&&(Z=h.get(V),S(V),Z!=null&&f(z,Z)),Z===void 0){st.debug2(`File ${V} isn't open, no need to rename the tab`);return}E(Z,me.getBaseName(z))},[a,h,E,p,f,C,S]),x=w.useCallback(V=>{const z=y(V,!1);if(z==null){st.error("Could not find panel id for file metadata",V);return}$.activateTab(n.root,{id:z})},[y,n.root]),D=w.useCallback((V,z,Z)=>{if(st.debug("registerFilePanel",V,z,Z),z==null||z.id==null){st.debug("Ignore empty file id",z);return}const{id:oe}=z;if(Z){f(oe,V);return}if(a.has(oe)){const re=a.get(oe);if(V===re){st.debug(`Update tab title for file ${oe}`);const{itemName:q}=z;R(oe,q)}else st.error(`File ${oe} already associated with a different tab ${re}`);return}p(oe,V),h.has(oe)&&S(oe)},[a,h,R,p,f,S]),L=w.useCallback((V,z)=>{if(st.debug("unregisterFileTab",V,z),V==null||V.id==null){st.debug("Ignore empty file id",V);return}const{id:Z}=V;if(z){S(Z);return}C(Z)},[C,S]),M=w.useCallback((V,z)=>{st.debug("closeFilePanel",V);const{id:Z}=V;let oe=null,re=!1;if(a.has(Z))oe=a.get(Z);else if(h.has(Z))oe=h.get(Z),re=!0;else{st.debug(`File ${Z} isn't open, ignore close event`);return}L(V,re),$.closeComponent(n.root,{id:oe},z)},[n.root,a,h,L]),j=w.useCallback(V=>{const{itemName:z}=V;return me.getBaseName(z)},[]),A=w.useCallback(V=>{const{id:z}=V;return st.debug("fileIsOpen",V,z,a),z!=null&&a.has(z)},[a]),W=w.useCallback(V=>{const{id:z}=V;return st.debug("fileIsOpenAsPreview",V,z,h),z!=null&&h.has(z)},[h]),H=w.useCallback(V=>{if(V==null)return;const z=s.getOpenedPanelById(V);z&&bc(z)&&z.focus()},[s]),U=w.useCallback(({id:V,settings:z,fileMetadata:Z,session:oe,sessionLanguage:re,isPreview:q=!1})=>{const ie={settings:z,fileMetadata:Z},fe=j(Z);return{type:"react-component",component:hs.COMPONENT,isFocusOnShow:!1,props:{localDashboardId:e,metadata:{id:V},session:oe,sessionLanguage:re,panelState:ie,isPreview:q,notebooksUrl:o},title:fe,id:V}},[j,e,o]),P=w.useCallback((V,z,Z,oe={id:null,itemName:T(Z)})=>{const re=y(oe);if(A(oe)&&re!=null){st.debug("File is already open, focus panel"),x(oe),H(re);return}const q=$.getStackForComponentTypes(n.root,[hs.COMPONENT]),ie=U({id:re,settings:Z,fileMetadata:oe,session:V,sessionLanguage:z});st.debug("createNotebook",ie,a),$.openComponentInStack(q,ie)},[A,H,T,y,n.root,U,a,x]),Q=w.useCallback((V,z,Z,oe,re=!1)=>{st.debug("selectNotebook",oe,re);const q=A(oe),ie=W(oe),[fe]=[...h.values()],Re=!re,xe=Re&&fe?fe:y(oe);if(xe==null||xe==="")throw new Error("Unable to retrieve or create panelId for metadata",oe);if(q||ie)x(oe);else{const vt=$.getStackForComponentTypes(n.root,[hs.COMPONENT]),Tt=U({id:xe,settings:Z,fileMetadata:oe,session:V,sessionLanguage:z,isPreview:Re});$.openComponentInStack(vt,Tt)}if(ie&&re){const vt=oe.id,Tt=$.getStackForConfig(n.root,{component:hs.COMPONENT,id:xe}),Gt=$.getContentItemInStack(Tt,{component:hs.COMPONENT,id:xe});Gt&&Lt(Gt)&&(Gt.container.emit(Pe.PROMOTE_FROM_PREVIEW),S(vt),p(vt,xe))}re&&H(xe)},[x,A,W,H,y,n.root,U,h,S,p]),G=w.useCallback((V,z,Z={},oe=!0)=>{const re=s.getLastUsedPanelOfType(hs);re&&bc(re)?Z!=null&&Z.value!=null&&re.notebook!=null&&re.notebook.append(Z.value):oe&&P(V,z,Z)},[P,s]),ne=w.useCallback((V,z)=>Ka.hydrate({...V,notebooksUrl:o},z),[o]);return w.useEffect(function(){const z=[i(fi.COMPONENT,fi,t),i(xl.COMPONENT,xl),i(Dl.COMPONENT,Dl),i(Ml.COMPONENT,Ml),i(hs.COMPONENT,hs,ne)];return()=>{z.forEach(Z=>Z())}},[i,t,ne]),je(n.eventHub,Bt.SEND_COMMAND,v),je(n.eventHub,Bt.SETTINGS_CHANGED,b),je(n.eventHub,Pe.CLOSE_FILE,M),je(n.eventHub,Pe.CREATE_NOTEBOOK,P),je(n.eventHub,Pe.SELECT_NOTEBOOK,Q),je(n.eventHub,Pe.RENAME,E),je(n.eventHub,Pe.RENAME_FILE,R),je(n.eventHub,Pe.SEND_TO_NOTEBOOK,G),je(n.eventHub,Pe.REGISTER_FILE,D),je(n.eventHub,Pe.UNREGISTER_FILE,L),null}const Wi=ee.module("FilterPlugin");function wc(c,e){return c.concat(e)}function ER(c){Rs(c);const{id:e,layout:t,registerComponent:n}=c,s=tr(),[i]=w.useState(()=>new Map),[o]=w.useState(()=>new Map),[l]=w.useState(()=>new Map),a=w.useCallback(()=>{const f=Array.from(i.values()).reduce(wc,[]).sort((b,T)=>{const y=en.toLower(b.name),E=en.toLower(T.name);if(y!==E)return y>E?1:-1;const R=en.toLower(b.type),x=en.toLower(T.type);return R!==x?R>x?1:-1:0}).reduce((b,T)=>((b.length===0||en.toLower(b[b.length-1].name)!==en.toLower(T.name)||en.toLower(b[b.length-1].type)!==en.toLower(T.type))&&b.push(T),b),[]),S=Array.from(o.values()).reduce(wc,[]).sort((b,T)=>b.timestamp-T.timestamp),v=new Map(l);Wi.debug("sendUpdate",{columns:f,filters:S,tableMap:v}),s(kn(e,{columns:f,filters:S,tableMap:v}))},[s,e,i,o,l]),d=w.useCallback((f,S)=>{Wi.debug2("handleColumnsChanged",f,S),i.set(f,[].concat(S)),a()},[i,a]),h=w.useCallback((f,S)=>{Wi.debug2("handleFiltersChanged",f,S),o.set(f,[].concat(S)),a()},[o,a]),u=w.useCallback((f,S)=>{Wi.debug2("handleTableChanged",f,S),l.set($.getIdFromPanel(f),S),a()},[l,a]),m=w.useCallback(f=>{Wi.debug2("handlePanelUnmount",f),i.delete(f),o.delete(f),l.delete($.getIdFromPanel(f)),a()},[i,o,l,a]),g=w.useCallback(({title:f="DropdownFilter",metadata:S={},panelState:v=null,id:b=ze.generate(),focusElement:T=$.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:E=null})=>{const R={type:"react-component",component:qs.COMPONENT,props:{id:b,metadata:S,panelState:v,localDashboardId:e},title:f,id:b},{root:x}=t;$.openComponent({root:x,config:R,focusElement:T,createNewStack:y,dragEvent:E})},[t,e]),p=w.useCallback(({title:f="InputFilter",metadata:S={},panelState:v=null,id:b=ze.generate(),focusElement:T=$.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:E=null})=>{const R={type:"react-component",component:to.COMPONENT,props:{id:b,metadata:S,panelState:v,localDashboardId:e},title:f,id:b},{root:x}=t;$.openComponent({root:x,config:R,focusElement:T,createNewStack:y,dragEvent:E})},[t,e]),C=w.useCallback(({title:f="FilterSets",metadata:S={},panelState:v=null,id:b=ze.generate(),focusElement:T=$.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:E=null})=>{const R={type:"react-component",component:Fa.COMPONENT,props:{id:b,metadata:S,panelState:v,localDashboardId:e},title:f,id:b},{root:x}=t;$.openComponent({root:x,config:R,focusElement:T,createNewStack:y,dragEvent:E})},[t,e]);return w.useEffect(function(){const S=[n(qs.COMPONENT,qs),n(to.COMPONENT,to),n(Fa.COMPONENT,Fa)];return()=>{S.forEach(v=>v())}},[n]),je(t.eventHub,Ye.COLUMNS_CHANGED,d),je(t.eventHub,Ye.FILTERS_CHANGED,h),je(t.eventHub,Ye.TABLE_CHANGED,u),je(t.eventHub,Ye.OPEN_DROPDOWN,g),je(t.eventHub,Ye.OPEN_INPUT,p),je(t.eventHub,Ye.OPEN_FILTER_SET_MANAGER,C),je(t.eventHub,we.UNMOUNT,m),null}const yR=[dh.VariableType.TABLE,dh.VariableType.TREETABLE,dh.VariableType.HIERARCHICALTABLE];function RR(c){Rs(c);const{getDownloadWorker:e,loadPlugin:t,id:n,layout:s,registerComponent:i,hydrate:o,theme:l}=c,a=w.useCallback(({dragEvent:d,fetch:h,panelId:u=ze.generate(),widget:m})=>{const{name:g,type:p}=m;if(!yR.includes(p))return;const C={name:g,table:g,type:m.type},f=()=>h().then(b=>Vr.makeModel(b)),S={type:"react-component",component:Xs.COMPONENT,props:{getDownloadWorker:e,loadPlugin:t,localDashboardId:n,id:u,metadata:C,makeModel:f,theme:l},title:g,id:u},{root:v}=s;$.openComponent({root:v,config:S,dragEvent:d})},[e,n,s,t,l]);return w.useEffect(function(){const h=[i(Xs.COMPONENT,Xs,o)];return()=>{h.forEach(u=>u())}},[o,i]),je(s.eventHub,we.OPEN,a),null}function Au(c){return typeof c.getCoordinateForColumn=="function"}function vc(c){const e=c;return Au(c)&&typeof e.setFilterMap=="function"&&typeof e.unsetFilterValue=="function"}function Tc(c){return c.description===void 0||!c.description?.startsWith("Preview of type: ")}const Gi=ee.module("LinkerUtils");class Jr{static ALLOWED_LINKS=new Map([[$.getComponentName(Xs),[$.getComponentName(Xs),$.getComponentName(Ti),$.getComponentName(qs)]]]);static getLinkType(e,t,n){if(e?.panelId==null||t?.panelId==null||e.panelId===t.panelId||n!=null&&n!==e.panelId&&n!==t.panelId)return Gi.debug2("Incompatible panel ids",e,t,n),"invalid";if(e.panelComponent==null||t.panelComponent==null)return Gi.error("PanelComponent should not be null",e,t),"invalid";const s=Jr.ALLOWED_LINKS.get(e.panelComponent)?.includes(t.panelComponent);if(s===void 0||!s)return Gi.debug2("Incompatible panel components",e,t),"invalid";const{columnType:i}=e,{columnType:o}=t;if(!(o===null||F.isCompatibleType(i,o)))return Gi.debug2("Incompatible type",i,o),"invalid";switch(t.panelComponent){case $.getComponentName(Ti):return"chartLink";case $.getComponentName(Xs):return"tableLink";case $.getComponentName(qs):return"filterSource"}return Gi.debug2("Incompatible target panel component",t.panelComponent),"invalid"}static findColumn(e,{columnName:t,columnType:n}){return e.find(({name:s,type:i})=>s===t&&i===n)}static cloneLinksForPanel(e,t,n){const s=[];return e.forEach(i=>{i.start.panelId===t&&i.type!=="filterSource"?s.push({...i,id:ze.generate(),start:{...i.start,panelId:n}}):i.end?.panelId===t&&s.push({...i,id:ze.generate(),end:{...i.end,panelId:n}})}),s}}const ci=Jr;const xR=ee.module("LinkerLink"),Ec=.015,yc=1.5,_u=12,Pu=12,Rc=2,Qo=Math.sqrt((Pu*.5)**2+_u**2),xc=Math.asin(Pu*.5/_u),Ic=15,us=Math.PI*.5;class no extends w.Component{static defaultProps={className:"",isSelected:!1,onClick(){},onDelete(){}};static makeCirclePath(e,t,n){return`M ${e} ${t} m -${n},0 a ${n},${n} 0 1,0 ${n*2},0 a ${n},${n} 0 1,0 -${n*2},0 z`}static getLabelForLinkFilter(e,t){try{if(F.isNumberType(e)||F.isCharType(e))return mh(t);if(F.isTextType(e))return uh(t);if(F.isDateType(e))return gh(t);if(F.isBooleanType(e)){if(t===pe.eq)return"is equal to";if(t===pe.notEq)return"is not equal to"}throw new Error(`Unrecognized column type: ${e}`)}catch(n){return xR.warn(n),""}}constructor(e){super(e),this.handleClick=this.handleClick.bind(this),this.handleMouseEnter=this.handleMouseEnter.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleDelete=this.handleDelete.bind(this),this.getDropdownActions=this.getDropdownActions.bind(this),this.state={isHovering:void 0}}getOperators=he((e,t)=>{const{onOperatorChanged:n}=this.props;let s=F.getFilterTypes(t);return F.isBooleanType(t)&&(s=[pe.eq,pe.notEq]),s.flatMap((i,o)=>{if(i==="eqIgnoreCase"||i==="notEqIgnoreCase")return[];let l="";return i==="startsWith"?l="a*":i==="endsWith"?l="*z":l=F.getFilterOperatorString(i),[{title:no.getLabelForLinkFilter(t,i),icon:r.jsx("b",{children:l}),action:()=>n(e,i),order:o}]})});handleClick(e){e.stopPropagation(),e.preventDefault();const{id:t,onClick:n,onDelete:s}=this.props;e.altKey?s(t):n(t)}handleMouseEnter(){this.setState({isHovering:!0})}handleMouseLeave(){this.setState({isHovering:!1})}handleDelete(){const{id:e,onDelete:t}=this.props;t(e)}getDropdownActions(){const{id:e,startColumnType:t}=this.props;return t!=null?this.getOperators(e,t):[]}render(){const{className:e,operator:t,isSelected:n,x1:s,y1:i,x2:o,y2:l,id:a,startColumnType:d,type:h}=this.props,{isHovering:u}=this.state,m=Math.sqrt((s-o)**2+(i-l)**2),g=Math.atan2(l-i,o-s),p=Math.sin(g),C=Math.cos(g)+2,f=window.innerWidth,S=window.innerHeight,v=0,b=0,T=Math.max(v,Math.min(s+(o-s)/2+p*(m*Ec)**yc,f)),y=Math.max(b,Math.min(i+(l-i)/2+C*(m*Ec)**yc,S)),E=`M ${s} ${i} Q ${T} ${y} ${o} ${l}`,R=`M ${v} ${b} L ${v} ${S} L ${f} ${S} L ${f} ${b} z
|
|
34
|
-
${no.makeCirclePath(s,i,Ic)}
|
|
35
|
-
${no.makeCirclePath(o,l,Ic)}`,x=`link-select-clip-${a}`,D=Math.atan2(l-y,o-T),L=D-xc+Math.PI,M=D+xc+Math.PI,j=o+Math.cos(D)*Rc,A=l+Math.sin(D)*Rc,W=j+Math.cos(L)*Qo,H=A+Math.sin(L)*Qo,U=j+Math.cos(M)*Qo,P=A+Math.sin(M)*Qo,Q=`${j},${A} ${W},${H} ${U},${P}`,G=.25*s+.5*T+.25*o,ne=.25*i+.5*y+.25*l,V=T-s+(o-T),Z=(y-i+(l-y))/V;let re=20/Math.sqrt(1+Z**2),q=re*Z,ie=re*-1,fe=q*-1;Number.isFinite(Z)?Z>0?(re*=-1,q*=-1,ie*=-1,fe*=-1,ie-=50-10*(Math.abs(g)%us),fe+=10*(Math.abs(g)%us),re-=50-10*(Math.abs(g)%us),q+=10*(Math.abs(g)%us)):Z<0?(ie+=10*(Math.abs(g)%us),fe+=10*(Math.abs(g)%us),re+=10*(Math.abs(g)%us),q+=10*(Math.abs(g)%us)):(ie=15,fe=10,re=-25,q=10):(ie=10,fe=5,re=10,q=-35);let Re="";t!==void 0&&(t==="startsWith"?Re="a*":t==="endsWith"?Re="*z":Re=F.getFilterOperatorString(t));const xe=h!=="chartLink"&&h!=="filterSource";return r.jsxs(r.Fragment,{children:[r.jsxs("svg",{className:K(e,{hovering:u}),children:[r.jsx("clipPath",{id:x,children:r.jsx("path",{d:R,clipRule:"evenodd"})}),r.jsx("path",{className:"link-select",d:E,onClick:this.handleClick,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,clipPath:`url(#${x})`,"data-testid":"link-select"}),r.jsx("path",{className:"link-background",d:E}),r.jsx("path",{className:"link-foreground",d:E}),r.jsx("circle",{className:"link-dot",cx:s,cy:i,r:"5"}),r.jsx("polygon",{className:"link-triangle",points:Q})]}),d!=null&&n&&r.jsxs(r.Fragment,{children:[xe&&r.jsx(_,{kind:"primary",className:"btn-fab btn-operator",style:{top:ne+(Z>=0?q:fe),left:G+(Z>=0?re:ie)},onClick:()=>{},icon:r.jsxs("div",{className:"fa-md fa-layers",children:[r.jsx("b",{children:Re}),r.jsx(X,{icon:$n,transform:"right-8 down-9 shrink-5"})]}),tooltip:"Change comparison operator",children:r.jsx(Wn,{actions:this.getDropdownActions,popperOptions:{placement:"bottom-start"}})}),r.jsx(_,{kind:"primary",className:"btn-fab btn-delete",style:{top:ne+(Z<0?q:fe),left:G+(Z<0?re:ie)},onClick:this.handleDelete,icon:Wt,tooltip:"Delete"})]})]})}}const IR=no;const ka=ee.module("LinkerOverlayContent");class DR extends w.Component{static defaultProps={disabled:"false"};constructor(e){super(e),this.handleBlur=this.handleBlur.bind(this),this.handleResize=this.handleResize.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleKeyUp=this.handleKeyUp.bind(this),this.handleEscapePressed=this.handleEscapePressed.bind(this),this.handleOperatorChanged=this.handleOperatorChanged.bind(this),this.dialogRef=ae.createRef(),this.state={mouse:void 0,dialog:void 0,offset:{x:0,y:0},isDragging:!1,mode:"select"}}componentDidMount(){window.addEventListener("blur",this.handleBlur,!0),window.addEventListener("mousemove",this.handleMouseMove,!0),window.addEventListener("mouseup",this.handleMouseUp,!0),window.addEventListener("keydown",this.handleKeyDown,!0),window.addEventListener("keyup",this.handleKeyUp,!0),window.addEventListener("resize",this.handleResize,!0)}componentDidCatch(e,t){ka.error("componentDidCatch",e,t)}componentWillUnmount(){window.removeEventListener("blur",this.handleBlur,!0),window.removeEventListener("mousemove",this.handleMouseMove,!0),window.removeEventListener("mouseup",this.handleMouseUp,!0),window.removeEventListener("keydown",this.handleKeyDown,!0),window.removeEventListener("keyup",this.handleKeyUp,!0),window.removeEventListener("resize",this.handleResize,!0)}dialogRef;getPointFromLinkPoint(e){const{panelManager:t}=this.props,{panelId:n,columnName:s}=e,i=t.getOpenedPanelById(n);if(i!=null){if(!Au(i))throw new Error(`Panel does not have getCoordinateForColumn method: ${n}`);try{const l=i.getCoordinateForColumn(s);if(l!=null)return l}catch{ka.error("Could not get coordinate for column",s,i)}}const o=t.getContainerByPanelId(n);if(o==null)throw new Error(`Unable to find panel container for id: ${n}`);return $.getTabPoint(o)}handleOperatorChanged(e,t){const{links:n,onLinksUpdated:s}=this.props,i=n.map(o=>o.id===e?{...o,operator:t}:o);s(i)}handleBlur(){this.setState({mode:"select"})}handleResize(){const{dialog:e}=this.state;if(e&&this.dialogRef.current){const t=this.dialogRef.current.getBoundingClientRect(),n=Ae(e.x,0,window.innerWidth-t.width),s=Ae(e.y,0,window.innerHeight-t.height);this.setState({dialog:{x:n,y:s}})}}handleMouseMove(e){const{offset:t,isDragging:n}=this.state;if(this.setState({mouse:{x:e.clientX,y:e.clientY}}),n&&this.dialogRef.current){const s=this.dialogRef.current.getBoundingClientRect(),i=Ae(window.innerWidth-(e.clientX+s.width+t.x),0,window.innerWidth-s.width),o=Ae(window.innerHeight-(e.clientY+s.height+t.y),0,window.innerHeight-s.height);this.setState({dialog:{x:i,y:o}})}}handleMouseDown(e){const t={x:0,y:0};if(this.dialogRef.current){const n=this.dialogRef.current.getBoundingClientRect();t.x=n.right-(n.width+e.clientX),t.y=n.bottom-(n.height+e.clientY)}this.setState({isDragging:!0,offset:t})}handleMouseUp(){this.setState({isDragging:!1})}handleKeyDown(e){if(e.key==="Alt")e.preventDefault(),this.setState({mode:"delete"});else if(e.key==="Delete"||e.key==="Backspace"){const{selectedIds:t,onLinkDeleted:n}=this.props;e.preventDefault(),t.forEach(s=>n(s))}}handleKeyUp(e){e.key==="Alt"&&(e.preventDefault(),this.setState({mode:"select"}))}handleEscapePressed(){const{onCancel:e}=this.props;e()}render(){const{disabled:e,links:t,selectedIds:n,messageText:s,onLinkSelected:i,onLinkDeleted:o,onAllLinksDeleted:l,onDone:a}=this.props,{mouse:d,dialog:h,isDragging:u,mode:m}=this.state,g=t.map(p=>{try{const{id:C,type:f,isReversed:S,start:v,end:b,operator:T}=p,y=v.columnType;let[E,R]=this.getPointFromLinkPoint(v),x=d?.x??E,D=d?.y??R;if(b!=null&&([x,D]=this.getPointFromLinkPoint(b)),S!=null&&S){const[M,j]=[E,R];[E,R]=[x,D],[x,D]=[M,j]}const L=K("linker-link",{disabled:e},{"link-filter-source":f==="filterSource"},{"link-invalid":f==="invalid"},{interactive:p.end==null},{"link-is-selected":n.has(C)},{"danger-delete":m==="delete"});return{x1:E,y1:R,x2:x,y2:D,id:C,className:L,operator:T,startColumnType:y,type:f}}catch(C){return ka.warn("Unable to get point for link",p,C),null}}).filter(p=>p!=null);return r.jsxs("div",{className:K("linker-overlay",{"danger-delete":m==="delete"}),children:[g.map(({x1:p,y1:C,x2:f,y2:S,id:v,className:b,operator:T,startColumnType:y,type:E})=>r.jsx(IR,{className:b,id:v,x1:p,y1:C,x2:f,y2:S,onClick:i,onDelete:o,isSelected:n.has(v),operator:T,startColumnType:y,type:E,onOperatorChanged:this.handleOperatorChanged},v)),r.jsxs("div",{className:K("linker-toast-dialog",{dragging:u}),ref:this.dialogRef,style:{bottom:h?.y,right:h?.x},"data-testid":"linker-toast-dialog",children:[r.jsx(_,{draggable:!0,kind:"inline",className:"btn-drag-handle",icon:Bl,onClick:()=>{},onMouseDown:this.handleMouseDown,children:!u&&r.jsx(tt,{children:"Drag to reposition"})}),r.jsx("div",{className:"toast-body",children:s}),r.jsxs("div",{className:"toast-footer",children:[r.jsx(_,{kind:"secondary",onClick:l,children:"Clear All"}),r.jsx(_,{kind:"primary",onClick:a,children:"Done"})]})]}),r.jsx(se,{actions:[{action:this.handleEscapePressed,shortcut:qn.LINKER_CLOSE,isGlobal:!0}]})]})}}const FR=DR,ht=ee.module("Linker"),NR=(c,e)=>({activeTool:Yl(c),isolatedLinkerPanelId:Gr(c,e.localDashboardId),links:Fi(c,e.localDashboardId),timeZone:go(c)}),kR=gt(NR,{setActiveTool:Xl,setDashboardLinks:Kr,addDashboardLinks:oy,deleteDashboardLinks:ly,setDashboardIsolatedLinkerPanelId:Nu,setDashboardColumnSelectionValidator:ay});class MR extends w.Component{constructor(e){super(e),this.handleCancel=this.handleCancel.bind(this),this.handleDone=this.handleDone.bind(this),this.handlePanelCloned=this.handlePanelCloned.bind(this),this.handleFilterColumnSelect=this.handleFilterColumnSelect.bind(this),this.handleColumnsChanged=this.handleColumnsChanged.bind(this),this.handlePanelClosed=this.handlePanelClosed.bind(this),this.handleLayoutStateChanged=this.handleLayoutStateChanged.bind(this),this.handleAllLinksDeleted=this.handleAllLinksDeleted.bind(this),this.handleLinkDeleted=this.handleLinkDeleted.bind(this),this.handleLinksUpdated=this.handleLinksUpdated.bind(this),this.handleChartColumnSelect=this.handleChartColumnSelect.bind(this),this.handleGridColumnSelect=this.handleGridColumnSelect.bind(this),this.handleUpdateValues=this.handleUpdateValues.bind(this),this.handleStateChange=this.handleStateChange.bind(this),this.handleExited=this.handleExited.bind(this),this.handleLinkSelected=this.handleLinkSelected.bind(this),this.handlePanelDragging=this.handlePanelDragging.bind(this),this.handlePanelDropped=this.handlePanelDropped.bind(this),this.isColumnSelectionValid=this.isColumnSelectionValid.bind(this),this.state={linkInProgress:void 0,selectedIds:new Set,isDraggingPanel:!1}}componentDidMount(){const{layout:e}=this.props;this.startListening(e),this.updateSelectionValidators()}componentDidUpdate(e){const{activeTool:t,layout:n}=this.props;n!==e.layout&&(this.stopListening(e.layout),this.startListening(n)),t!==e.activeTool&&(this.updateSelectionValidators(),t===_t.DEFAULT&&this.reset())}componentDidCatch(e,t){ht.error("componentDidCatch",e,t)}componentWillUnmount(){const{layout:e}=this.props;this.stopListening(e)}startListening(e){e.on("stateChanged",this.handleLayoutStateChanged);const{eventHub:t}=e;t.on(cn.COLUMN_SELECTED,this.handleGridColumnSelect),t.on(cn.DATA_SELECTED,this.handleUpdateValues),t.on(cn.STATE_CHANGED,this.handleStateChange),t.on(qa.COLUMN_SELECTED,this.handleChartColumnSelect),t.on(we.CLONED,this.handlePanelCloned),t.on(Ye.COLUMN_SELECTED,this.handleFilterColumnSelect),t.on(Ye.COLUMNS_CHANGED,this.handleColumnsChanged),t.on(we.CLOSE,this.handlePanelClosed),t.on(we.CLOSED,this.handlePanelClosed),t.on(we.DRAGGING,this.handlePanelDragging),t.on(we.DROPPED,this.handlePanelDropped)}stopListening(e){e.off("stateChanged",this.handleLayoutStateChanged);const{eventHub:t}=e;t.off(cn.COLUMN_SELECTED,this.handleGridColumnSelect),t.off(cn.DATA_SELECTED,this.handleUpdateValues),t.off(cn.STATE_CHANGED,this.handleStateChange),t.off(qa.COLUMN_SELECTED,this.handleChartColumnSelect),t.off(we.CLONED,this.handlePanelCloned),t.off(Ye.COLUMN_SELECTED,this.handleFilterColumnSelect),t.off(Ye.COLUMNS_CHANGED,this.handleColumnsChanged),t.off(we.CLOSE,this.handlePanelClosed),t.off(we.CLOSED,this.handlePanelClosed),t.off(we.DRAGGING,this.handlePanelDragging),t.off(we.DROPPED,this.handlePanelDropped)}reset(){this.setState({linkInProgress:void 0,selectedIds:new Set})}handleCancel(){const{linkInProgress:e}=this.state;if(e==null){const{setActiveTool:t}=this.props;t(_t.DEFAULT)}this.setState({linkInProgress:void 0})}handleDone(){const{setActiveTool:e}=this.props;e(_t.DEFAULT)}handleChartColumnSelect(e,t){this.columnSelected(e,t,!0)}handleFilterColumnSelect(e,t){ht.debug("handleFilterColumnSelect",this.isOverlayShown());const{links:n,localDashboardId:s,setActiveTool:i,setDashboardIsolatedLinkerPanelId:o}=this.props,l=$.getIdFromPanel(e),a=n.filter(d=>d.start?.panelId===l||d.end?.panelId===l);if(!this.isOverlayShown()&&l!=null){i(_t.LINKER),o(s,l),a.length===0&&this.columnSelected(e,t,!0,l);return}this.columnSelected(e,t,!0)}handleColumnsChanged(e,t){ht.debug("handleColumnsChanged",e,t);const{links:n}=this.props,s=$.getIdFromPanel(e);if(s==null){ht.error("Invalid panelId",e);return}const i=n.filter(({start:o,end:l})=>o.panelId===s&&ci.findColumn(t,o)==null||l!=null&&l.panelId===s&&ci.findColumn(t,l)==null);this.deleteLinks(i)}handleGridColumnSelect(e,t){if(!Tc(t)){ht.debug2("Column is not filterable");return}this.columnSelected(e,t)}columnSelected(e,t,n=!1,s){if(s===void 0&&!this.isOverlayShown())return;const{isolatedLinkerPanelId:i}=this.props,{linkInProgress:o}=this.state,l=$.getIdFromPanel(e);if(l==null)return;const a=$.getComponentNameFromPanel(e),{name:d,type:h}=t;if(o==null||o.start==null){const u={id:ze.generate(),start:{panelId:l,panelComponent:a,columnName:d,columnType:h},type:"invalid",isReversed:n};ht.debug("starting link",u),this.setState({linkInProgress:u})}else{const{links:u}=this.props,{start:m,id:g,isReversed:p}=o,C={panelId:l,panelComponent:a,columnName:d,columnType:h},f=ci.getLinkType(p!==void 0&&p?C:m,p!==void 0&&p?m:C,s??i);switch(f){case"invalid":ht.debug("Ignore invalid link connection",o,C);return;case"filterSource":{const v=p!==void 0&&p?m.panelId:C.panelId,b=u.filter(({end:T})=>T?.panelId===v);this.deleteLinks(b);break}case"chartLink":{const v=p===!0?m:C,b=p===!0?C:m;ht.debug("creating chartlink",{existingLinkEnd:v,start:m,end:C});const T=u.filter(({end:y,start:E})=>E?.panelId===b.panelId&&y?.panelId===v.panelId&&y?.columnName===v.columnName&&y?.columnType===v.columnType);this.deleteLinks(T);break}}const S={start:p!==void 0&&p?C:m,end:p!==void 0&&p?m:C,id:g,type:f,operator:pe.eq};ht.info("creating link",S),this.setState({linkInProgress:void 0,selectedIds:new Set([g])},()=>{this.addLinks([S])})}}unsetFilterValueForLink(e){const{panelManager:t}=this.props;if(e.end){const{end:n}=e,{panelId:s,columnName:i,columnType:o}=n,l=t.getOpenedPanelById(s);l?vc(l)?l.unsetFilterValue(i,o):ht.debug("endPanel.unsetFilterValue not implemented",l):ht.debug("endPanel no longer exists, ignoring unsetFilterValue",s)}}setPanelFilterMap(e,t){ht.debug("Set filter data for panel:",e,t);const{panelManager:n}=this.props,s=n.getOpenedPanelById(e);s?vc(s)?s.setFilterMap(t):ht.debug("panel.setFilterMap not implemented",e,s):ht.debug("panel no longer exists, ignoring setFilterMap",e)}addLinks(e){const{addDashboardLinks:t,localDashboardId:n}=this.props;t(n,e)}deleteLinks(e,t=!1){const{localDashboardId:n}=this.props;if(e.forEach(s=>this.unsetFilterValueForLink(s)),t){const{setDashboardLinks:s}=this.props;s(n,[])}else if(e.length>0){const{deleteDashboardLinks:s}=this.props;s(n,e.map(({id:i})=>i))}}handleAllLinksDeleted(){const{links:e,isolatedLinkerPanelId:t}=this.props;if(t===void 0)this.deleteLinks(e,!0);else{const n=e.filter(s=>s?.start?.panelId===t||s?.end?.panelId===t);this.deleteLinks(n)}this.reset()}handleLinkDeleted(e){const{links:t}=this.props,n=t.find(s=>s.id===e);n?this.deleteLinks([n]):ht.error("Unable to find link to delete",e)}handleUpdateValues(e,t){const n=$.getIdFromPanel(e),{links:s,timeZone:i}=this.props,o=new Map;for(let l=0;l<s.length;l+=1){const{start:a,end:d,operator:h}=s[l];if(a.panelId===n&&d!=null){const{panelId:u,columnName:m,columnType:g}=d,p=o.has(u)?o.get(u):new Map,C=p.has(m)===!0?p.get(m).filterList:[],{visibleIndex:f,isExpandable:S,isGrouped:v}=t[a.columnName];let{value:b}=t[a.columnName],T=`${b}`;b===null&&S&&v&&(b=void 0),g!=null&&F.isDateType(g)&&(T=new lt({timeZone:i,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:Zs.FULL_DATE_FORMAT}).format(b));const y={operator:h,text:T,value:b,startColumnIndex:f};C.push(y),p.set(m,{columnType:g,filterList:C}),o.set(u,p)}}o.forEach((l,a)=>{this.setPanelFilterMap(a,l)})}handlePanelCloned(e,t){const{links:n}=this.props,s=$.getIdFromPanel(e),i=t.id;if(s!=null){const o=ci.cloneLinksForPanel(n,s,i);this.addLinks(o)}}handlePanelDragging(e){const{links:t}=this.props;for(let n=0;n<t.length;n+=1){const s=t[n],{start:i,end:o}=s;if(i.panelId===e||o?.panelId===e){this.setState({isDraggingPanel:!0});return}}}handlePanelDropped(){this.setState({isDraggingPanel:!1})}handlePanelClosed(e){ht.debug(`Panel ${e} closed, deleting links.`),this.deleteLinksForPanelId(e)}handleLinkSelected(e){this.setState({selectedIds:new Set([e])})}handleLinksUpdated(e){const{localDashboardId:t,setDashboardLinks:n}=this.props;n(t,e)}handleLayoutStateChanged(){this.forceUpdate()}handleStateChange(){this.forceUpdate()}handleExited(){const{localDashboardId:e,setDashboardIsolatedLinkerPanelId:t}=this.props;t(e,void 0)}deleteLinksForPanelId(e){const{links:t}=this.props;for(let n=0;n<t.length;n+=1){const s=t[n],{start:i,end:o,id:l}=s;(i.panelId===e||o?.panelId===e)&&this.handleLinkDeleted(l)}}getCachedLinks=he((e,t,n)=>{const s=[...e];return t!=null&&t.start!=null&&s.push(t),n!==void 0?s.filter(i=>i?.start?.panelId===n||i?.end?.panelId===n||i?.end==null):s});isOverlayShown(){const{activeTool:e}=this.props;return e===_t.LINKER}updateSelectionValidators(){const{activeTool:e,setDashboardColumnSelectionValidator:t,localDashboardId:n}=this.props;switch(e){case _t.LINKER:t(n,this.isColumnSelectionValid);break;default:t(n,void 0);break}}updateLinkInProgressType(e="invalid"){this.setState(({linkInProgress:t})=>t!==void 0?{linkInProgress:{...t,type:e}}:null)}isColumnSelectionValid(e,t){const{linkInProgress:n}=this.state,{isolatedLinkerPanelId:s}=this.props;if(t==null)return n?.start!=null&&this.updateLinkInProgressType(),!1;if(!Tc(t))return ht.debug2("Column is not filterable",t.description),n?.start!=null&&this.updateLinkInProgressType("invalid"),!1;if(n?.start==null)return!0;const{isReversed:i,start:o}=n,l=$.getIdFromPanel(e);if(l==null)return!1;const a={panelId:l,panelComponent:$.getComponentNameFromPanel(e),columnName:t.name,columnType:t.type},d=i!==void 0&&i?ci.getLinkType(a,o,s):ci.getLinkType(o,a,s);return this.updateLinkInProgressType(d),d!=="invalid"}render(){const{links:e,isolatedLinkerPanelId:t,panelManager:n}=this.props,{linkInProgress:s,selectedIds:i,isDraggingPanel:o}=this.state,l=this.isOverlayShown(),a=s!=null&&s.start!=null,d=t===void 0?"Click a column source, then click a column target to create a filter link. The filter comparison operator used by a selected link can be changed. Delete a filter link by clicking the delete button or with alt+click. Click done when finished.":"Create a link between the source column button and a table column by clicking on one, then the other. Delete a filter link by clicking the delete button or with alt+click. Click done when finished.";return o?null:r.jsx($t,{in:l,timeout:Xe.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,onExited:this.handleExited,children:r.jsx(FR,{disabled:a,panelManager:n,links:this.getCachedLinks(e,s,t),selectedIds:i,messageText:d,onLinkSelected:this.handleLinkSelected,onLinkDeleted:this.handleLinkDeleted,onAllLinksDeleted:this.handleAllLinksDeleted,onLinksUpdated:this.handleLinksUpdated,onDone:this.handleDone,onCancel:this.handleCancel})})}}const LR=kR(MR),OR=LR;function AR(c){Rs(c);const{id:e,layout:t,panelManager:n}=c;return r.jsx(OR,{layout:t,localDashboardId:e,panelManager:n})}class Ll{static DEFAULT_TITLE="Note";static DEFAULT_CONTENT=`# Markdown Note
|
|
36
|
-
|
|
37
|
-
This note can be edited using **markdown** for styling.`;static getNewMarkdownTitle(e){let t=`${Ll.DEFAULT_TITLE}`,n=0;for(;e.indexOf(t)>=0;)n+=1,t=`${Ll.DEFAULT_TITLE}-${n}`;return t}}const Ma=Ll;function _R(c){Rs(c);const{id:e,layout:t,panelManager:n,registerComponent:s}=c,i=w.useCallback(l=>{const{title:a,componentState:d,props:h}=l;let{panelState:u=null}=h;return d!=null&&({panelState:u=null}=d),a==null||u==null||u.content==null||u.content.length===0||u.content===Ma.DEFAULT_CONTENT?null:xr(l)},[]),o=w.useCallback(({title:l="",metadata:a={},id:d=ze.generate(),focusElement:h=$.DEFAULT_FOCUS_SELECTOR,createNewStack:u=!1,dragEvent:m=null}={})=>{const g=n.getOpenedPanelConfigsOfType($i.COMPONENT),p=n.getClosedPanelConfigsOfType($i.COMPONENT),C=g.map(T=>T.title??""),f=l!=null&&l!==""?l:Ma.getNewMarkdownTitle(C),S=p.length>0?null:Ma.DEFAULT_CONTENT,v={type:"react-component",component:$i.COMPONENT,props:{id:d,metadata:a,panelState:{content:S},localDashboardId:e},title:f,id:d},{root:b}=t;$.openComponent({root:b,config:v,focusElement:h,createNewStack:u,dragEvent:m})},[e,t,n]);return w.useEffect(function(){const a=[s($i.COMPONENT,$i,Ir,i)];return()=>{a.forEach(d=>d())}},[i,s]),je(t.eventHub,Du.OPEN,o),null}function PR(c){Rs(c);const{hydrate:e,id:t,layout:n,registerComponent:s}=c,i=w.useCallback(({dragEvent:o,fetch:l,panelId:a=ze.generate(),widget:d})=>{const{name:h,type:u}=d;if(u!==dh.VariableType.PANDAS)return;const m={name:h,table:h},g=()=>l().then(f=>Vr.makeModel(f)),p={type:"react-component",component:Na.COMPONENT,props:{localDashboardId:t,id:a,metadata:m,makeModel:g},title:h,id:a},{root:C}=n;$.openComponent({root:C,config:p,dragEvent:o})},[t,n]);return w.useEffect(function(){const l=[s(Na.COMPONENT,Na,e)];return()=>{l.forEach(a=>a())}},[e,s]),je(n.eventHub,we.OPEN,i),null}class jR{static DROPDOWN_FILTER="ControlType.DROPDOWN_FILTER";static INPUT_FILTER="ControlType.INPUT_FILTER";static MARKDOWN="ControlType.MARKDOWN";static FILTER_SET_MANAGER="ControlType.FILTER_SET_MANAGER"}const bs=jR;class Dc{static makeSortConfig(e,t){return{column:e,direction:t}}static makeFilterConfig(e){const t=[],n=[];return e.forEach((s,i)=>{t.push(s),i>0&&n.push(Vn.and)}),{filterItems:t,filterOperators:n}}static combineFilterConfigs(e,t,n=Vn.and){return{filterItems:[...e.filterItems,...t.filterItems],filterOperators:[...e.filterOperators,n,...t.filterOperators]}}static makeFilterItem(e,t,n){return{columnName:e,type:t,value:n}}}function HR(c,e,t){if(c.length>e){const n=c.length-t;return{toKeep:c.slice(n),toPrune:c.slice(0,n)}}return{toKeep:c,toPrune:[]}}const La=ee.module("PouchStorageTable"),UR="Deephaven.";Uc.plugin(Sm);function VR(c,e){switch(c){case pe.in:case pe.contains:return{$regex:new RegExp(`${e}`)};case pe.inIgnoreCase:return{$regex:new RegExp(`${e}`,"i")};case pe.eq:return{$eq:e};case pe.notEq:return{$neq:e};case pe.greaterThan:return{$gt:e};case pe.greaterThanOrEqualTo:return{$gte:e};case pe.lessThan:return{$lt:e};case pe.lessThanOrEqualTo:return{$lte:e};case pe.startsWith:return{$regex:new RegExp(`^(?${e}).*`)};default:throw new Error(`Unsupported type: ${c}`)}}function BR(c){const{filterItems:e,filterOperators:t}=c;let n=null;for(let s=0;s<e.length;s+=1){const i=e[s],{columnName:o,type:l,value:a}=i,d={[o]:VR(l,a)};if(s===0)n=d;else if(n!==null&&s-1<t.length){const h=t[s-1];if(h===Vn.and)n={$and:[n,d]};else if(h===Vn.or)n={$or:[n,d]};else throw new Error(`Unexpected filter operator ${h}, ${d}`)}}if(n==null)throw new Error(`Invalid filter config ${c}`);return n}function Oa(c=[]){return{$and:[...c.map(e=>BR(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function $R(c,e=!1){return[{id:e?"desc":"asc"},...c?.map(t=>({[t.column]:t.direction}))??[]]}class WR{db;changes;listeners=[];itemListeners=new Map;currentSize=0;currentViewport;currentReverse=!1;currentFilter=null;currentSort=null;infoUpdatePromise;viewportUpdatePromise;currentViewportData;constructor(e,t){this.db=new Uc(`${UR}${e}`,t),this.db._remote=!1,this.listenForChanges(),this.db.createIndex({index:{fields:["id","name"]}}),this.refreshInfo()}listenForChanges(){this.changes=this.db.changes({live:!0,since:"now",include_docs:!0}).on("change",this.dbUpdate.bind(this))}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(t=>t!==e)}}onItemUpdate(e,t){return this.itemListeners.has(e)||this.itemListeners.set(e,[]),this.itemListeners.set(e,[...this.itemListeners.get(e),t]),this.refreshItem(e),()=>{this.itemListeners.set(e,this.itemListeners.get(e).filter(n=>n!==t))}}close(){this.listeners=[]}get size(){return this.currentSize}get viewport(){return this.currentViewport}setReversed(e){this.currentReverse=e,this.currentViewportData=void 0,this.refreshData()}setViewport(e){this.currentViewport=e,this.refreshInfo(),this.refreshData()}setSorts(e){this.currentSort=e,this.currentViewportData=void 0,this.refreshData()}setFilters(e){this.currentFilter=e,this.currentViewportData=void 0,this.refreshInfo(),this.refreshData()}get data(){return this.currentViewportData}async getViewportData(){return this.viewportUpdatePromise||this.refreshData(),this.viewportUpdatePromise??Promise.resolve({items:[],offset:0})}async put(e){const t={...e,_id:e.id};return await this.db.put(t),t}sendUpdate(){const{listeners:e}=this,t=this.currentViewportData??{items:[],offset:0};for(let n=0;n<e.length;n+=1)e[n](t)}sendItemUpdate(e){const t=this.itemListeners.get(e.id);if(t!==void 0)for(let n=0;n<t.length;n+=1)t[n](e)}dbUpdate(e){La.debug("Update received",e),this.refreshInfo(),e.doc!==void 0&&this.sendItemUpdate(e.doc),this.refreshData()}async fetchInfo(e){return this.db.find({selector:e,fields:[]})}async refreshInfo(){try{this.infoUpdatePromise?.cancel(),this.infoUpdatePromise=ve.makeCancelable(this.fetchInfo(Oa(this.currentFilter??[])));const e=await this.infoUpdatePromise;this.currentSize=e.docs.length,this.sendUpdate()}catch(e){if(!ve.isCanceled(e))throw La.error("Unable to refreshInfo",e),e}}async fetchViewportData(e,t,n){return this.db.find({selector:t,skip:e.top,limit:e.bottom-e.top+1,sort:n,fields:["id","name"]}).then(s=>({items:s.docs,offset:e.top}))}async refreshData(){if(this.currentViewport)try{const e=Oa(this.currentFilter??[]),t=$R(this.currentSort,this.currentReverse);this.viewportUpdatePromise?.cancel(),this.viewportUpdatePromise=ve.makeCancelable(this.fetchViewportData(this.currentViewport,e,t));const n=await this.viewportUpdatePromise;return this.currentViewportData=n,this.sendUpdate(),n}catch(e){if(!ve.isCanceled(e))throw La.error("Unable to refreshData",e),e}}async refreshItem(e){const n=(await this.db.find({selector:{id:e},limit:1})).docs[0];return n!==void 0&&this.sendItemUpdate(n),n}async getSnapshot(e){const t=new Map,n=[{id:this.currentReverse?"desc":"asc"}];return await Promise.all(e.map(async([s,i])=>{const o=i-s+1;return this.db.find({selector:Oa(this.currentFilter??[]),skip:s,limit:o,sort:n,fields:["id","name"]}).then(l=>{for(let a=0;a<o;a+=1){const d=s+a;t.set(d,l.docs[a])}})})),t}}const GR=WR,zR=2500,KR=2e3,Zt=ee.module("PouchCommandHistoryTable");class YR extends GR{constructor(e,t){super(`CommandHistoryStorage.${e}`,{auto_compaction:!0,revs_limit:1}),this.cache=t,this.cache.tableRegistry.has(this.cacheKey)||this.cache.tableRegistry.set(this.cacheKey,new Set),Zt.debug("Adding table to registry",this.cacheKey),this.cache.tableRegistry.get(this.cacheKey)?.add(this)}searchText;get cacheKey(){return this.db.name}setSearch(e){Zt.debug("Setting search filters",e),this.searchText=e.trim().toLowerCase(),this.setFilters(e?[Dc.makeFilterConfig([Dc.makeFilterItem("name",pe.contains,e)])]:[])}dbUpdate(e){Zt.debug("Clearing cache and refreshing data",e),this.cache.response.delete(this.cacheKey),super.dbUpdate(e)}async fetchData(e){return ve.withTimeout(0,async()=>{this.cache.response.has(this.cacheKey)?Zt.debug("Fetching from cache",this.searchText,this.viewport):(Zt.debug("Fetching from PouchDB",this.searchText,this.viewport),this.cache.response.set(this.cacheKey,this.db.allDocs({include_docs:!0}).then(n=>{const s=n.rows.map(l=>l.doc).filter(({name:l})=>l);Zt.debug(`Fetched ${s.length} command history items`);const{toKeep:i,toPrune:o}=HR(s,zR,KR);return o.length&&this.pruneItems(o),{docs:i}})));const t=this.cache.response.get(this.cacheKey);return this.searchText==null||this.searchText===""?t:{...t,docs:(await t).docs.filter(({name:n})=>n.toLowerCase().includes(this.searchText))}})}async fetchInfo(e){return this.fetchData(e)}async fetchViewportData(e,t,n){const s=await this.fetchData(t);return Zt.debug("Fetching viewport data",e.top,e.bottom+1,n,s),{items:(typeof n[0]=="object"&&n[0].id==="desc"?s.docs.slice(0).reverse():s.docs).slice(e.top,e.bottom+1),offset:e.top}}async pruneItems(e){if(this.cache.isPruning.get(this.cacheKey)===!0){Zt.debug("Pruning already in progress. Skipping.");return}try{Zt.debug(`Pruning ${e.length} command history items`);const t=this.cache.pauseChangeListeners(this.cacheKey);this.cache.isPruning.set(this.cacheKey,!0),await this.db.bulkDocs(e.map(n=>({...n,_deleted:!0}))),this.cache.isPruning.set(this.cacheKey,!1),t(),Zt.debug("Finished pruning command history items")}catch(t){Zt.error("An error occurred while pruning db",t)}}close(){Zt.debug("Closing table",this,this.cache.tableRegistry.get(this.cacheKey)?.size),this.cache.tableRegistry.get(this.cacheKey)?.delete(this),this.changes?.cancel(),super.close()}}const Fc=YR,Nc=ee.module("PouchCommandHistoryCache");class qR{constructor(){this.isPruning=new Map,this.response=new Map,this.tableRegistry=new Map}isPruning;response;tableRegistry;pauseChangeListeners(e){const t=[];return this.tableRegistry.get(e)?.forEach(n=>{n.changes&&(Nc.debug(`Pausing event listeners on '${e}' table`,n),n.changes.cancel(),t.push(n))}),()=>{t.forEach(n=>{(this.tableRegistry.get(e)?.has(n)??!1)&&(Nc.debug(`Resuming event listeners on '${e}' table`,n),n.listenForChanges())})}}}const XR=qR,kc=ee.module("PouchCommandHistoryStorage");class ZR{cache=new XR;updateTableMap=new Map;getUpdateTable(e){return this.updateTableMap.has(e)||this.updateTableMap.set(e,new Fc(e,this.cache)),this.updateTableMap.get(e)}async getTable(e){return new Fc(e,this.cache)}async addItem(e,t,n,s){return this.updateItem(e,{id:`${new Date().getTime()}`,name:n,data:s})}async updateItem(e,t){const n=this.getUpdateTable(e),i={...await n.refreshItem(t.id)??{},...t};return kc.debug("Updating item",i),await n.put(i),kc.debug("Update saved"),t}listenItem(e,t,n){return this.getUpdateTable(e).onItemUpdate(t,n)}}const ju="SET_LAYOUT_STORAGE",QR=c=>({type:ju,payload:c}),Hu=""+new URL("community-wordmark-app-d2c5c1eb.svg",import.meta.url).href;const JR=ee.module("FormattingSectionContent");function ex(c){return c.formatString!=null}function Ja(c){const e=c?.querySelector("input, select, textarea");e&&e.focus()}function Uu(c,e){return c.defaultFormatString===e.defaultFormatString}function tx(c,e){return Uu(c,e)}function nx(c,e){return Uu(c,e)}function Vu(c){return c!==""&&Ii.isValidColumnName(c)}function ws(c,e){if(!c||e.formatString==null||!ex(e))return!1;switch(c){case"datetime":return lt.isValid(e);case"decimal":return We.isValid(e);case"int":return ot.isValid(e);default:return JR.warn("Trying to validate format of unknown type"),!0}}function Bu(c){const{id:e,isNewRule:t,...n}=c;return n}function $u(c){return Vu(c.columnName)&&ws(c.columnType,c.format)}function Wu(c){const{timestamp:e,timeZone:t,showTimeZone:n,showTSeparator:s,isGlobalOptions:i,legacyGlobalFormat:o}=c,l=new gn([],{timeZone:t,showTimeZone:n,showTSeparator:s}),a=i?lt.getGlobalFormats(n,s):lt.getFormats(n,s);return o!=null&&!a.includes(o)&&a.unshift(o),r.jsx(r.Fragment,{children:a.map(d=>{const h=lt.makeFormat("",d,lt.TYPE_GLOBAL);return r.jsx("option",{value:d,"data-testid":"time-format",children:l.getFormattedString(e,F.dataType.DATETIME,"",h)},d)})})}function sx(){return r.jsx(r.Fragment,{children:_l.TIME_ZONES.map(c=>{const{label:e,value:t}=c;return r.jsx("option",{value:t,children:e},t)})})}const js=ee.module("FormattingSectionContent");class ed extends w.PureComponent{static defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:lt.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:We.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:ot.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:lt.DEFAULT_TIME_ZONE_ID}};static inputDebounceTime=250;constructor(e){super(e),this.debouncedCommitChanges=Ge(this.commitChanges.bind(this),ed.inputDebounceTime),this.handleDefaultDateTimeFormatChange=this.handleDefaultDateTimeFormatChange.bind(this),this.handleDefaultDecimalFormatChange=this.handleDefaultDecimalFormatChange.bind(this),this.handleDefaultIntegerFormatChange=this.handleDefaultIntegerFormatChange.bind(this),this.handleShowTimeZoneChange=this.handleShowTimeZoneChange.bind(this),this.handleShowTSeparatorChange=this.handleShowTSeparatorChange.bind(this),this.handleTimeZoneChange=this.handleTimeZoneChange.bind(this),this.handleResetDateTimeFormat=this.handleResetDateTimeFormat.bind(this),this.handleResetDecimalFormat=this.handleResetDecimalFormat.bind(this),this.handleResetIntegerFormat=this.handleResetIntegerFormat.bind(this),this.handleResetTimeZone=this.handleResetTimeZone.bind(this),this.handleTruncateNumbersWithPoundChange=this.handleTruncateNumbersWithPoundChange.bind(this);const{formatter:t,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:l,timeZone:a,truncateNumbersWithPound:d}=e,h=t.map((u,m)=>({...u,id:m}));this.containerRef=ae.createRef(),this.state={formatSettings:h,showTimeZone:o,showTSeparator:l,timeZone:a,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:d,timestampAtMenuOpen:new Date}}componentDidMount(){Ja(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}debouncedCommitChanges;containerRef;getCachedDateTimeFormatOptions=Te((e,t,n,s=!1,i)=>{const{timestampAtMenuOpen:o}=this.state;return r.jsx(Wu,{timestamp:o,timeZone:e,showTimeZone:t,showTSeparator:n,isGlobalOptions:s,legacyGlobalFormat:i})});handleDefaultDateTimeFormatChange(e){js.debug("handleDefaultDateTimeFormatChange",e.target.value),this.setState({defaultDateTimeFormat:e.target.value},()=>{this.debouncedCommitChanges()})}handleDefaultDecimalFormatChange(e){js.debug("handleDefaultDecimalFormatChange",e.target.value),this.setState({defaultDecimalFormatOptions:{defaultFormatString:e.target.value}},()=>{this.debouncedCommitChanges()})}handleDefaultIntegerFormatChange(e){js.debug("handleDefaultIntegerFormatChange",e.target.value),this.setState({defaultIntegerFormatOptions:{defaultFormatString:e.target.value}},()=>{this.debouncedCommitChanges()})}handleShowTimeZoneChange(){this.setState(e=>({showTimeZone:!e.showTimeZone}),()=>{this.debouncedCommitChanges()})}handleShowTSeparatorChange(){this.setState(e=>({showTSeparator:!e.showTSeparator}),()=>{this.debouncedCommitChanges()})}handleTimeZoneChange(e){this.setState({timeZone:e.target.value},()=>{this.debouncedCommitChanges()})}handleResetDateTimeFormat(){const{defaults:e}=this.props,{defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s}=e;js.debug("handleResetDateTimeFormat"),this.setState({defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s},()=>{this.debouncedCommitChanges()})}handleResetTimeZone(){const{defaults:e}=this.props,{timeZone:t}=e;js.debug("handleResetTimeZone"),this.setState({timeZone:t},()=>{this.debouncedCommitChanges()})}handleResetDecimalFormat(){const{defaults:e}=this.props,{defaultDecimalFormatOptions:t}=e;js.debug("handleResetDecimalFormat"),this.setState({defaultDecimalFormatOptions:t},()=>{this.debouncedCommitChanges()})}handleResetIntegerFormat(){const{defaults:e}=this.props,{defaultIntegerFormatOptions:t}=e;js.debug("handleResetIntegerFormat"),this.setState({defaultIntegerFormatOptions:t},()=>{this.debouncedCommitChanges()})}handleTruncateNumbersWithPoundChange(){this.setState(e=>({truncateNumbersWithPound:!e.truncateNumbersWithPound}),()=>{this.debouncedCommitChanges()})}commitChanges(){const{formatSettings:e,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:l,truncateNumbersWithPound:a}=this.state,d=e.filter($u).map(Bu)??[],{settings:h,saveSettings:u}=this.props,m={...h,formatter:d,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:a};ws(F.dataType.DECIMAL,We.makeCustomFormat(o.defaultFormatString))&&(m.defaultDecimalFormatOptions=o),ws(F.dataType.INT,ot.makeCustomFormat(l.defaultFormatString))&&(m.defaultIntegerFormatOptions=l),u(m)}render(){const{defaults:e}=this.props,{defaultDateTimeFormat:t,defaultDecimalFormatOptions:n,defaultIntegerFormatOptions:s,timeZone:i,showTimeZone:o,showTSeparator:l,truncateNumbersWithPound:a}=this.state,{defaultFormatString:d=We.DEFAULT_FORMAT_STRING}=n??{},{defaultFormatString:h=ot.DEFAULT_FORMAT_STRING}=s??{},u=i===e.timeZone,m=l===e.showTSeparator&&o===e.showTimeZone&&t===e.defaultDateTimeFormat,g=tx(n,e.defaultDecimalFormatOptions),p=nx(s,e.defaultIntegerFormatOptions);return r.jsx("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:r.jsxs("div",{className:"container-fluid p-0",children:[r.jsx("div",{className:"app-settings-menu-description mb-3",children:"Choose the default formatting rule to apply to all table columns based on their type."}),r.jsxs("div",{className:"form-row mb-2",children:[r.jsx("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),r.jsx("div",{className:"col pr-0",children:r.jsx("select",{className:"custom-select",value:i,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:r.jsx(sx,{})})}),r.jsx("div",{className:"col-1 btn-col",children:r.jsx(_,{kind:"ghost",icon:Gs,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:K("btn-reset","btn-reset-time-zone",{hidden:u})})})]}),r.jsxs("div",{className:"form-row mb-2",children:[r.jsx("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),r.jsx("div",{className:"col pr-0",children:r.jsx("select",{className:"custom-select",value:t,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(i,o,l,!0,t)})}),r.jsx("div",{className:"col-1 btn-col",children:r.jsx(_,{kind:"ghost",icon:Gs,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:K("btn-reset","btn-reset-date-time",{hidden:m})})})]}),r.jsx("div",{className:"form-row",children:r.jsx("div",{className:"offset-3 col-9",children:r.jsx(nn,{checked:o??null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),r.jsx("div",{className:"form-row mb-3",children:r.jsx("div",{className:"offset-3 col-9",children:r.jsx(nn,{checked:l??null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),r.jsxs("div",{className:"form-row mb-2",children:[r.jsx("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),r.jsx("div",{className:"col pr-0",children:r.jsx("input",{className:K("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!ws(F.dataType.DECIMAL,We.makeCustomFormat(d))}),"data-lpignore":!0,placeholder:We.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:d,onChange:this.handleDefaultDecimalFormatChange})}),r.jsx("div",{className:"col-1 btn-col",children:r.jsx(_,{kind:"ghost",icon:Gs,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:K("btn-reset","btn-reset-decimal",{hidden:g}),"data-testid":"btn-reset-decimal"})})]}),r.jsxs("div",{className:"form-row mb-2",children:[r.jsx("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),r.jsx("div",{className:"col pr-0",children:r.jsx("input",{className:K("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!ws(F.dataType.INT,ot.makeCustomFormat(h))}),"data-lpignore":!0,placeholder:ot.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:h,onChange:this.handleDefaultIntegerFormatChange})}),r.jsx("div",{className:"col-1 btn-col",children:r.jsx(_,{kind:"ghost",icon:Gs,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:K("btn-reset","btn-reset-integer",{hidden:p}),"data-testid":"btn-reset-integer"})})]}),r.jsx("div",{className:"form-row mb-3",children:r.jsx("div",{className:"offset-3 col-9",children:r.jsx(nn,{checked:a??null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Truncate numbers with #"})})})]})})}}const ix=c=>({formatter:Th(c),defaultDateTimeFormat:bh(c),defaultDecimalFormatOptions:wh(c),defaultIntegerFormatOptions:vh(c),showTimeZone:Eh(c),showTSeparator:yh(c),truncateNumbersWithPound:Rh(c),timeZone:go(c),settings:pt(c)}),ox=gt(ix,{saveSettings:ql})(ed);function lx(){const[c,e]=w.useState(!1),t=()=>{e(!c)};return r.jsxs(_,{kind:"ghost",onClick:t,icon:Vg,children:["Legal Notices",r.jsxs($l,{isOpen:c,toggle:t,className:"theme-bg-light",children:[r.jsx(Wl,{toggle:t,children:"Legal Notice"}),r.jsxs(Gl,{children:[r.jsx("p",{children:"Deephaven software is protected by U.S. Patent Nos. 9,612,959; 9,613,018; 9,613,109; 9,619,210; 9,633,060; 9,639,570; 9,672,238; 9,679,006; 9,690,821; 9,710,511; 9,760,591; 9,805,084; 9,836,495; 9,836,494; 9,886,469; 9,898,496; 9,934,266; 10,002,153; 10,002,154; 10,002,155; 10,003,673; 10,019,138; 10,069,943; 10,176,211; 10,198,465; 10,198,466; 10,198,469; 10,212,257; 10,241,960; 10,241,965; 10,242,040; 10,242,041; 10,353,893; 10,346,394; 10,452,649; 10,496,639; 10,540,351; 10,552,412; 10,565,194; 10,565,206; 10,572,474; 10,621,168; 10,642,829; 10,657,184; 10,678,787; 10,691,686; and 10,783,191. Other patents pending."}),r.jsxs("p",{children:["© 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})}function so(c){const{children:e,isExpanded:t,sectionKey:n,title:s,onToggle:i}=c;return r.jsxs(r.Fragment,{children:[r.jsx("div",{children:r.jsxs(_,{kind:"ghost",className:"btn-collapse-trigger",onClick:()=>i(n),children:[r.jsx("div",{className:"flex-grow-1",children:s}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx(X,{transform:t?"flip-v":"",icon:$n})})]})}),r.jsx(Mm,{in:t,autoFocusOnShow:!0,children:e})]})}so.propTypes={children:B.node,isExpanded:B.bool.isRequired,sectionKey:B.string.isRequired,title:B.node.isRequired,onToggle:B.func};so.defaultProps={children:null,onToggle:()=>{}};function ax({shortcut:c,displayText:e,categoryName:t,onChange:n}){const[s,i]=w.useState(e),[o,l]=w.useState(c.getKeyState()),[a,d]=w.useState(!1),[h,u]=w.useState("");w.useEffect(function(){i(e),l(c.getKeyState())},[e,c]),w.useEffect(function(){i(sn.getDisplayText(o)),c.matchesKeyState(o)&&d(!1)},[o,c]),w.useEffect(function(){if(a){if(!sn.isValidKeyState(o)){sn.isAllowedKey(o.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const T=Ve.getConflictingShortcuts(o).filter(y=>y.id.startsWith(t)&&y!==c).map(y=>y.name);if(T.length){u(`Conflicts with ${T.join(", ")}`);return}u("")}else u("")},[a,o,t,c]);function m(b){if(b.stopPropagation(),b.preventDefault(),c.isEditable&&!b.repeat){const T=sn.getKeyStateFromEvent(b),y=sn.createKeyState([Ee.BACKSPACE]);sn.doKeyStatesMatch(T,y)?l(sn.NULL_KEY_STATE):l(T)}}function g(b){b.stopPropagation(),b.preventDefault(),c.matchesKeyState(o)||d(!0)}function p(){Es.disableAllActions()}function C(){Es.enableAllActions()}function f(){c.setKeyState(o),d(!1),n(c)}function S(){const b=c.getKeyState();l(b),d(!1)}function v(){d(!0),l(c.getDefaultKeyState())}return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"shortcut-item-container",children:[r.jsxs("label",{className:"shortcut-item-name",children:[c.name,c.tooltip!==void 0&&r.jsx(tt,{children:c.tooltip})]}),r.jsxs("div",{className:"shortcut-item-input-container",children:[r.jsx("input",{className:K("form-control",{"is-invalid":h}),onKeyDown:m,onKeyUp:g,onFocus:p,onBlur:C,disabled:!c.isEditable,value:s,readOnly:!0}),!sn.doKeyStatesMatch(o,c.getDefaultKeyState())&&!h&&r.jsx(_,{className:"reset-to-default-button",kind:"ghost",icon:r.jsx(X,{icon:Gs,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:v})]})]}),a&&r.jsxs("div",{className:K("shortcut-item-message-container",{"is-invalid":h}),children:[r.jsx("div",{className:"shortcut-item-message",children:h}),r.jsxs("div",{className:"shortcut-item-message-buttons",children:[sn.isValidKeyState(o)&&r.jsx(_,{kind:"ghost",onClick:f,children:"Confirm"}),r.jsx(_,{kind:"ghost",onClick:S,children:"Undo"})]})]})]})}function rx({shortcutOverrides:c={},settings:e,saveSettings:t}){const n=w.useCallback(l=>{const a=sn.isMacPlatform,d={mac:{...c.mac},windows:{...c.windows}},h=a?d.mac:d.windows;l.forEach(u=>{u.isDefault()?delete h[u.id]:h[u.id]=u.getKeyState()}),t({...e,shortcutOverrides:d})},[e,t,c]);let s=Array.from(Ve.shortcutsByCategory.entries()).map(([l,a])=>({name:l,shortcuts:a}));const i=s.findIndex(l=>l.name.toUpperCase()==="GLOBAL"),o=s.splice(i,1);return s=s.concat(o),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. To prevent unexpected results, avoid conflicting shortcuts with the browser or IDE editor."}),s.map(l=>r.jsx(dx,{name:l.name,shortcuts:l.shortcuts,saveShortcutOverrides:n},l.name))]})}function dx({name:c,shortcuts:e,saveShortcutOverrides:t}){function n(a){return a.split("_").map(d=>`${d[0].toUpperCase()}${d.slice(1).toLowerCase()}`).join(" ")}const[s,i]=w.useState(e);function o(a){const d=s.filter(u=>u!==a&&!u.isNull()&&u.matchesKeyState(a.getKeyState()));d.forEach(u=>u.setToNull());const h=[a,...d];t(h),i(u=>[...u])}const l=w.useMemo(()=>s.map(a=>a.getDisplayText()),[s]);return r.jsxs("div",{className:"mt-3",children:[r.jsx("div",{className:"font-weight-bold",children:n(c)}),s.map((a,d)=>r.jsx(ax,{shortcut:a,displayText:l[d],categoryName:c,onChange:o},a.id))]})}const cx=c=>({settings:pt(c),shortcutOverrides:aC(c)}),hx={saveSettings:ql},ux=gt(cx,hx)(rx),mx="yyyy-MM-dd-HHmmss";function Gu(c,e="root",t=new Map([[c,""]])){const n={};return Object.entries(c).forEach(([s,i])=>{try{JSON.stringify(i),n[s]=i}catch{const l=i;if(typeof i=="bigint")n[s]=i.toString();else if(t.has(l))n[s]=`Circular ref to ${t.get(l)}`;else{const a=`${e}.${s}`;t.set(l,a),n[s]=Gu(i,a,t)}}}),n}function gx(){const c=vr.getState();return JSON.stringify(Gu(c),null,2)}function px(c){const e={uiVersion:"0.38.1",userAgent:navigator.userAgent,...c};return JSON.stringify(e,null,2)}async function fx(c=`${I.i18n.DateTimeFormat.format(mx,new Date)}_support_logs`,e){const t=new Vc,n=t.folder(c);n.file("console.txt",Bg.getFormattedHistory()),n.file("redux.json",gx()),n.file("metadata.json",px(e));const s=await t.generateAsync({type:"blob"}),i=document.createElement("a");i.href=URL.createObjectURL(s),i.download=`${c}.zip`,i.click()}const Cx=[{value:F.dataType.DATETIME,label:"DateTime"},{value:F.dataType.DECIMAL,label:"Decimal"},{value:F.dataType.INT,label:"Integer"}];function Sx(){const c=Cx.map(e=>r.jsx("option",{value:e.value,children:e.label},`key-columnType-${e.value}`));return r.jsxs(r.Fragment,{children:[r.jsx("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),c]})}class td extends w.PureComponent{static defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:lt.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:We.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:ot.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:lt.DEFAULT_TIME_ZONE_ID}};static inputDebounceTime=250;constructor(e){super(e),this.debouncedCommitChanges=Ge(this.commitChanges.bind(this),td.inputDebounceTime),this.handleFormatRuleEntered=this.handleFormatRuleEntered.bind(this),this.handleFormatRuleChange=this.handleFormatRuleChange.bind(this),this.handleFormatRuleCreate=this.handleFormatRuleCreate.bind(this),this.handleFormatRuleDelete=this.handleFormatRuleDelete.bind(this);const{formatter:t,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:l,timeZone:a,truncateNumbersWithPound:d}=e,h=t.map((u,m)=>({...u,id:m}));this.containerRef=ae.createRef(),this.addFormatRuleButtonRef=ae.createRef(),this.lastFormatRuleIndex=h.length,this.state={formatSettings:h,formatRulesChanged:!1,showTimeZone:o,showTSeparator:l,timeZone:a,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:d,timestampAtMenuOpen:new Date}}componentDidMount(){Ja(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}debouncedCommitChanges;containerRef;addFormatRuleButtonRef;lastFormatRuleIndex;isDuplicateRule(e){const{formatSettings:t}=this.state;return t.some(n=>n.id!==e.id&&n.columnName===e.columnName&&n.columnType===e.columnType)??!1}getAutoIncrementFormatRuleIndex(){const{lastFormatRuleIndex:e}=this;return this.lastFormatRuleIndex+=1,e}getCachedColumnTypeOptions=Te(()=>r.jsx(Sx,{}));getCachedDateTimeFormatOptions=Te((e,t,n,s=!1,i)=>{const{timestampAtMenuOpen:o}=this.state;return r.jsx(Wu,{timestamp:o,timeZone:e,showTimeZone:t,showTSeparator:n,isGlobalOptions:s,legacyGlobalFormat:i})});handleFormatRuleChange(e,t,n){this.setState(s=>{const{formatSettings:i}=s;N(i);const o=[...i];let l={};t==="columnType"&&(l={format:""});const a={...o[e],...l,[t]:n};return o[e]=a,{formatSettings:o}},()=>{this.debouncedCommitChanges()})}handleFormatRuleCreate(){this.setState(e=>{const{formatSettings:t}=e,n={columnType:F.dataType.DATETIME,columnName:"",format:{},id:this.getAutoIncrementFormatRuleIndex(),isNewRule:!0};return{formatSettings:[...t,n],formatRulesChanged:!0}})}handleFormatRuleDelete(e){this.setState(t=>{const{formatSettings:n}=t;return{formatSettings:n.filter((i,o)=>o!==e),formatRulesChanged:!0}},()=>{this.debouncedCommitChanges()})}handleFormatRuleEntered(e){this.scrollToFormatBlockBottom(),Ja(e)}commitChanges(){const{formatSettings:e,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:l,truncateNumbersWithPound:a}=this.state,d=e.filter($u).map(Bu)??[],{settings:h,saveSettings:u}=this.props,m={...h,formatter:d,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:a};ws(F.dataType.DECIMAL,We.makeCustomFormat(o.defaultFormatString))&&(m.defaultDecimalFormatOptions=o),ws(F.dataType.INT,ot.makeCustomFormat(l.defaultFormatString))&&(m.defaultIntegerFormatOptions=l),u(m)}scrollToFormatBlockBottom(){const{scrollTo:e}=this.props;e(0,(this.addFormatRuleButtonRef.current?.offsetHeight??0)+(this.addFormatRuleButtonRef.current?.offsetTop??0))}getRuleError(e){const t={hasColumnNameError:!1,hasFormatError:!1,message:""},n=[];return e.isNewRule!==void 0&&e.isNewRule||(this.isDuplicateRule(e)&&(t.hasColumnNameError=!0,n.push("Duplicate column name/type combo.")),Vu(e.columnName)||(t.hasColumnNameError=!0,n.push("Column names must start with a letter or underscore and contain only alphanumeric characters or underscores.")),e.format.formatString!==void 0&&e.format.formatString.length===0?(t.hasFormatError=!0,n.push("Empty formatting rule.")):ws(e.columnType,e.format)||(t.hasFormatError=!0,n.push("Invalid formatting rule.")),t.message=n.join(`
|
|
38
|
-
`)),t}renderFormatRule(e,t){const n=`input-${e}-columnName`,s=`input-${e}-columnType`,i=`input-${e}-format`,o=this.getCachedColumnTypeOptions(),l=u=>this.handleFormatRuleChange(e,"columnName",u.target.value),a=()=>this.handleFormatRuleChange(e,"isNewRule",!1),d=u=>this.handleFormatRuleChange(e,"columnType",u.target.value),h=this.getRuleError(t);return r.jsxs("fieldset",{className:"container-fluid format-rule-container",children:[r.jsxs("div",{className:"form-row",children:[r.jsxs("div",{className:"form-group col-7 mb-2",children:[r.jsx("label",{htmlFor:n,children:"Column Name"}),r.jsx("input",{id:n,className:K("form-control",{"is-invalid":h.hasColumnNameError}),"data-lpignore":!0,type:"text",value:t.columnName,onChange:l,onBlur:a})]}),r.jsxs("div",{className:"form-group col mb-2",children:[r.jsx(_,{kind:"ghost",className:"btn-delete-format-rule float-right",tabIndex:-1,onClick:()=>this.handleFormatRuleDelete(e),icon:Wt,tooltip:"Delete","aria-label":"Delete Format Rule"}),r.jsx("label",{htmlFor:s,children:"Column Type"}),r.jsx("select",{id:s,className:"custom-select",value:t.columnType,onChange:d,children:o})]})]}),r.jsx("div",{className:"form-row",children:r.jsxs("div",{className:"form-group col-12 d-flex mb-2",children:[r.jsx("label",{className:"flex-shrink-0 col-form-label mr-3",htmlFor:i,children:"Formatting Rule"}),this.renderFormatRuleInput(e,t.columnType,i,t.format,h.hasFormatError)]})}),r.jsx("div",{className:"form-row",children:r.jsx("div",{className:"form-group col-12 d-flex mb-2",children:h.message&&r.jsx("p",{className:"text-danger",children:h.message})})})]},e)}renderFormatRuleInput(e,t,n,s,i){switch(F.getNormalizedType(t)){case F.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(e,n,s,i);case F.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(e,n,s,i);case F.dataType.INT:return this.renderIntegerFormatRuleInput(e,n,s,i);default:throw new Error(`Unrecognized column type: ${t}`)}}renderDateTimeFormatRuleInput(e,t,n,s){const{showTimeZone:i,showTSeparator:o,timeZone:l}=this.state,a=n.formatString??"";return r.jsxs("select",{className:K("custom-select",{"is-invalid":s}),value:a,id:t,onChange:d=>{const h=lt.makeFormat("",d.target.value,lt.TYPE_GLOBAL);this.handleFormatRuleChange(e,"format",h)},children:[r.jsx("option",{value:"",disabled:!0,children:"Select format"},"default"),this.getCachedDateTimeFormatOptions(l,i,o)]})}renderIntegerFormatRuleInput(e,t,n,s){const i=n.formatString??"";return r.jsx("input",{className:K("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:t,placeholder:ot.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const l=ot.makeFormat("",o.target.value,ot.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(e,"format",l)}})}renderDecimalFormatRuleInput(e,t,n,s){const i=n.formatString??"";return r.jsx("input",{className:K("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:t,placeholder:We.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const l=We.makeFormat("",o.target.value,We.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(e,"format",l)}})}render(){const{formatRulesChanged:e,formatSettings:t}=this.state,n=t.map((i,o)=>r.jsx($t,{classNames:"fade",timeout:Xe.transitionMs,onEnter:this.handleFormatRuleEntered,children:this.renderFormatRule(o,i)},i.id)),s=r.jsx(_,{kind:"ghost",className:"mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,icon:ys,children:"Add New Rule"});return r.jsxs("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[r.jsx("div",{className:"app-settings-menu-description mb-3",children:"Customize the formatting of table columns by applying rules based on matching both a column name and column type."}),r.jsx(bm,{appear:e,enter:e,exit:e,children:n}),s]})}}const bx=c=>({formatter:Th(c),defaultDateTimeFormat:bh(c),defaultDecimalFormatOptions:wh(c),defaultIntegerFormatOptions:vh(c),showTimeZone:Eh(c),showTSeparator:yh(c),truncateNumbersWithPound:Rh(c),timeZone:go(c),settings:pt(c)}),wx=gt(bx,{saveSettings:ql})(td);class Rn extends w.Component{static defaultProps={onDone:()=>{}};static FORMATTING_SECTION_KEY="SettingsMenu.formatting";static COLUMN_SPECIFIC_SECTION_KEY="SettingsMenu.columnFormatting";static APPLICATION_SECTION_KEY="ApplicationMenu.settings";static SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";static focusFirstInputInContainer(e){const t=e?.querySelector("input, select, textarea");t&&t.focus()}constructor(e){super(e),this.handleClose=this.handleClose.bind(this),this.handleScrollTo=this.handleScrollTo.bind(this),this.handleSectionToggle=this.handleSectionToggle.bind(this),this.handleExportSupportLogs=this.handleExportSupportLogs.bind(this),this.handleLogout=this.handleLogout.bind(this),this.menuContentRef=ae.createRef(),this.broadcastChannel=new BroadcastChannel(Lm),this.state={expandedSectionKey:Rn.FORMATTING_SECTION_KEY}}componentDidMount(){Rn.focusFirstInputInContainer(this.menuContentRef.current)}componentWillUnmount(){this.broadcastChannel.close()}menuContentRef;broadcastChannel;isSectionExpanded(e){const{expandedSectionKey:t}=this.state;return t===e}handleLogout(){this.broadcastChannel.postMessage(Om(Am))}handleScrollTo(e,t){this.menuContentRef.current?.scrollTo(e,t)}handleSectionToggle(e){this.setState(t=>({expandedSectionKey:t.expandedSectionKey===e?void 0:e}))}handleClose(){const{onDone:e}=this.props;e()}handleExportSupportLogs(){const{serverConfigValues:e}=this.props;fx(void 0,Object.fromEntries(e))}render(){const e="0.38.1",t="https://github.com/deephaven/web-client-ui/",n="https://deephaven.io/core/docs/",{serverConfigValues:s,user:i}=this.props,o=s.get("barrage.version"),l=s.get("java.version"),a=s.get("deephaven.version"),d=(g,p)=>r.jsxs(r.Fragment,{children:[r.jsx("div",{children:g}),r.jsx("div",{children:p})]}),h=i.displayName??i.name,u=i.image!=null&&i.image!=="",m=h!=="";return r.jsxs("div",{className:"app-settings-menu",children:[r.jsxs("header",{className:"app-settings-menu-header",children:[r.jsxs("div",{className:"user-info",children:[r.jsxs("div",{className:"user-image",children:[!u&&r.jsx(X,{icon:$g,transform:"grow-8"}),u&&r.jsx("img",{src:i.image,alt:h})]}),r.jsxs("div",{className:"user-details",children:[m&&r.jsxs("div",{className:"user-name",children:[h,i.operateAs!=null&&i.name!==i.operateAs&&r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"font-weight-light font-italic",children:[" ","as"," "]}),r.jsxs("span",{className:"operating-as-user",children:[r.jsx(X,{icon:Wg,className:"mr-1"}),i.operateAs]})]})]}),i.permissions.canLogout&&r.jsx("button",{type:"button",className:"btn btn-link",onClick:this.handleLogout,children:"logout"})]})]}),r.jsx(_,{kind:"ghost",className:"btn-close-settings-menu",onClick:this.handleClose,icon:r.jsx(X,{icon:ho,transform:"grow-4"}),tooltip:"Close"})]}),r.jsxs("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[r.jsx("h5",{children:"Settings"}),r.jsx("hr",{className:"my-0"}),r.jsx(so,{sectionKey:Rn.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(Rn.FORMATTING_SECTION_KEY),title:r.jsxs(r.Fragment,{children:[r.jsx(X,{icon:Gg,transform:"grow-4",className:"mr-2"}),"Default Format & Time zone"]}),onToggle:this.handleSectionToggle,children:r.jsx(ox,{})}),r.jsx(so,{sectionKey:Rn.COLUMN_SPECIFIC_SECTION_KEY,isExpanded:this.isSectionExpanded(Rn.COLUMN_SPECIFIC_SECTION_KEY),title:r.jsxs(r.Fragment,{children:[r.jsx(X,{icon:zg,transform:"grow-4",className:"mr-2"}),"Format by Column Name & Type"]}),onToggle:this.handleSectionToggle,children:r.jsx(wx,{scrollTo:this.handleScrollTo})}),r.jsx(so,{sectionKey:Rn.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(Rn.SHORTCUT_SECTION_KEY),title:r.jsxs(r.Fragment,{children:[r.jsx(X,{icon:Kg,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:r.jsx(ux,{})}),r.jsxs("div",{className:"app-settings-footer",children:[r.jsxs("div",{className:"app-settings-footer-section",children:[r.jsxs("div",{className:"app-settings-footer-item",children:[r.jsx("div",{className:"font-weight-bold",children:"Support"}),r.jsxs("div",{children:["GitHub: ",r.jsx("a",{href:t,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:t})]}),r.jsx(_,{kind:"tertiary",className:"mt-2 py-2",onClick:this.handleExportSupportLogs,children:"Export Logs"})]}),r.jsxs("div",{className:"app-settings-footer-item",children:[r.jsx("div",{className:"font-weight-bold",children:"Documentation"}),r.jsx("a",{target:"_blank",rel:"noreferrer noopener",href:n,className:"custom-link",children:n})]}),r.jsxs("div",{className:"app-settings-footer-item",children:[r.jsx("div",{className:"font-weight-bold",children:"Version"}),r.jsxs("span",{className:"d-inline-block text-muted",children:[a," ",r.jsx(X,{icon:Yg}),r.jsxs(tt,{interactive:!0,children:[r.jsxs("div",{className:"detailed-server-config",children:[d("Engine Version",a),d("Web UI Version",e),d("Java Version",l),d("Barrage Version",o)]}),r.jsx(jl,{tooltip:"Copy version numbers",copy:`Engine Version: ${a}
|
|
39
|
-
Web UI Version: ${e}
|
|
40
|
-
Java Version: ${l}
|
|
41
|
-
Barrage Version: ${o}`,children:"Copy Versions"})]})]})]}),r.jsx("div",{className:"app-settings-footer-item",children:r.jsx(lx,{})})]}),r.jsx("div",{className:"app-settings-footer-section",children:r.jsx("div",{className:"logo",children:r.jsx("a",{target:"_blank",rel:"noreferrer noopener",href:"https://deephaven.io",className:"d-inline-block custom-link p-1",children:r.jsx("img",{src:Hu,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}}const Mc=10;function Ci(c){const{forwardedProps:{menuItem:{action:e,title:t,disabled:n},iconElement:s,displayShortcut:i,isMouseSelected:o,isKeyboardSelected:l,closeMenu:a}}=c,d=w.useRef(),h=w.useRef(),u=w.useRef(null),[m,g]=w.useState(!1),p=w.useCallback(S=>{d.current!=null&&h.current!=null&&u.current&&(Math.abs(d.current-S.clientX)>=Mc||Math.abs(h.current-S.clientY)>=Mc)&&(g(!0),window.removeEventListener("mousemove",p),a(),e(S),u.current=null)},[e,a]);function C(S){d.current=S.clientX,h.current=S.clientY,u.current=S.target,window.addEventListener("mousemove",p)}function f(S){u.current===S.target&&(g(!0),a(),e(),window.removeEventListener("mousemove",p)),u.current=null}return w.useEffect(function(){return function(){return window.removeEventListener("mousemove",p)}},[p]),r.jsxs("button",{type:"button",className:K("btn-context-menu",{disabled:n},{active:o&&!n},{"keyboard-active":l&&!n}),onMouseDown:C,onMouseUp:f,disabled:m,children:[r.jsx("span",{className:K("icon"),children:s}),r.jsx("span",{className:"title",children:t}),r.jsx("span",{className:"shortcut",children:i})]})}function nd(c){const{handleControlSelect:e,handleToolSelect:t,onClearFilter:n}=c,s=w.useMemo(()=>[{title:"Input Filter",icon:qg,menuElement:r.jsx(Ci,{}),action:i=>{e(bs.INPUT_FILTER,i)},order:10},{title:"Dropdown Filter",icon:th,menuElement:r.jsx(Ci,{}),action:i=>{e(bs.DROPDOWN_FILTER,i)},order:15},{title:"Markdown Widget",icon:Xg,menuElement:r.jsx(Ci,{}),action:i=>{e(bs.MARKDOWN,i)},order:20},{title:"Filter Sets",icon:Ha,menuElement:r.jsx(Ci,{}),action:i=>{e(bs.FILTER_SET_MANAGER,i)},order:25},{disabled:!0,menuElement:r.jsx("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:Qc,action:()=>{t(_t.LINKER)},order:40,shortcut:qn.LINKER},{disabled:!0,menuElement:r.jsx("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:Zg,action:()=>{n()},order:60,shortcut:Ut.TABLE.CLEAR_ALL_FILTERS}],[e,t,n]);return r.jsx(Wn,{popperClassName:"controls-menu-popper",actions:s})}nd.propTypes={handleControlSelect:B.func,handleToolSelect:B.func,onClearFilter:B.func};nd.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};Ci.propTypes={forwardedProps:B.shape({iconElement:B.node,displayShortcut:B.string,isMouseSelected:B.bool.isRequired,isKeyboardSelected:B.bool.isRequired,closeMenu:B.func.isRequired,menuItem:B.shape({action:B.func,title:B.string,disabled:B.bool}).isRequired})};Ci.defaultProps={forwardedProps:null};const vx=Js(ju,null),Tx={layoutStorage:vx},Ex=c=>c.layoutStorage,yx=c=>c.serverConfigValues;Object.entries(Tx).map(([c,e])=>po.register(c,e));const Lc=10;function Rx(c){const{onExportLayout:e,onImportLayout:t,onResetLayout:n,onSelect:s,widgets:i=[]}=c,[o,l]=w.useState(!1),[a,d]=w.useState(""),h=w.useRef(null),u=w.useRef(),m=w.useCallback((T,y)=>{T!=null&&s(T,y)},[s]),g=w.useCallback(T=>{d(T.target.value)},[]),p=w.useCallback(T=>{u.current!=null&&(Math.abs(u.current.x-T.clientX)>=Lc||Math.abs(u.current.y-T.clientY)>=Lc)&&(l(!0),window.removeEventListener("mousemove",p),m(u.current.widget,T),u.current=void 0)},[u,m]),C=w.useCallback((T,y)=>{u.current={x:T.clientX,y:T.clientY,widget:y},window.addEventListener("mousemove",p)},[p]),f=w.useCallback((T,y)=>{window.removeEventListener("mousemove",p),u.current?.widget===y&&(l(!0),m(y)),u.current=void 0},[p,u,m]),S=w.useMemo(()=>i.filter(T=>a?T.name?.toLowerCase().includes(a.toLowerCase()):!0),[a,i]).sort((T,y)=>T.name?.localeCompare(y.name??"")??0),v=w.useMemo(()=>S.map(T=>r.jsx("li",{children:r.jsxs(_,{kind:"ghost","data-testid":`panel-list-item-${T.name??""}-button`,onMouseDown:y=>{C(y,T)},onMouseUp:y=>{f(y,T)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&m(T)},disabled:o,onClick:()=>{},children:[r.jsx(ih,{type:T.type})," ",T.name??""]})},T.name)),[S,o,C,f,m]),b=w.useMemo(()=>v.length===0?r.jsx("span",{children:"No bound variables found."}):null,[v]);return r.jsxs("div",{className:"widget-list-container d-flex flex-column",children:[r.jsx("div",{className:"widget-list-header",children:r.jsx(xi,{value:a,placeholder:"Find Table, Plot or Widget",onChange:g,ref:h})}),r.jsxs("ul",{className:"widget-list flex-grow-1",children:[b&&r.jsx("li",{className:"widget-list-message",children:b}),!b&&v]}),r.jsx("div",{children:r.jsx("hr",{})}),r.jsxs("div",{className:"widget-list-footer",children:[r.jsxs(_,{kind:"ghost",onClick:e,children:[r.jsxs("div",{className:"fa-md fa-layers",children:[r.jsx(X,{mask:ja,icon:Sd,transform:"right-5 down-5"}),r.jsx(X,{icon:Sd,transform:"right-8 down-6"})]}),"Export Layout"]}),r.jsxs(_,{kind:"ghost",onClick:t,children:[r.jsxs("div",{className:"fa-md fa-layers",children:[r.jsx(X,{mask:ja,icon:Ua,transform:"right-5 down-5"}),r.jsx(X,{icon:Ua,transform:"right-8 down-6"})]}),"Import Layout"]}),r.jsx(_,{kind:"ghost",icon:Gs,onClick:n,tooltip:"Reset Layout"})]})]})}const xx=async(c,e,t)=>{let n,s,i,o;if(sl(e)?(n=e.settings,s=e.table,i=void 0,o=e.tableSettings):(n={},s="",i=e.figure,o={}),t!==void 0&&(t.tableSettings!=null&&(o=t.tableSettings),t.table!=null&&(s=t.table),t.figure!=null&&(i=t.figure),t.settings!=null&&(n={...n,...t.settings})),i!==void 0){const d={title:i,name:i,type:I.VariableType.FIGURE},h=await c.getObject(d);return pl.makeModel(n,h)}const l={title:i,name:s,type:I.VariableType.TABLE},a=await c.getObject(l);return Ce.applyTableSettings(a,o,go(vr.getState())),pl.makeModelFromSettings(n,a)},Ix=async(c,e,t=I.VariableType.TABLE)=>{const{table:n}=e,s={title:n,name:n,type:t},i=await c.getObject(s);return Vr.makeModel(i)};function Dx({onAutoFillClick:c=()=>{}}){return r.jsxs("div",{className:"empty-dashboard-container",children:[r.jsxs("div",{className:"hint-container",children:[r.jsx(X,{icon:eh})," ",r.jsx("br",{}),"Use the panel list to add objects from a query."]}),r.jsxs("div",{className:"empty-dashboard",children:[r.jsx("div",{className:"add-panels-hint",children:"Drag Panels Here"}),r.jsx(_,{kind:"tertiary",onClick:c,children:"Auto fill objects"})]})]})}function Fx(c){return c.version===2}function Nx(c){return Array.isArray(c)}const Jo=ee.module("UserLayoutUtils"),kx={layoutConfig:[{type:"column",content:[{type:"row",height:40,content:[{type:"stack",content:[{type:"react-component",component:fi.COMPONENT,title:fi.TITLE,isClosable:!1},{type:"react-component",component:Ml.COMPONENT,title:Ml.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:xl.COMPONENT,title:xl.TITLE,isClosable:!1},{type:"react-component",component:Dl.COMPONENT,title:Dl.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},Mx={layoutConfig:[],links:[],filterSets:[],version:2};function zu(c){if(Fx(c))return c;if(Nx(c))return{layoutConfig:c,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${c}`)}async function Lx(c,e=!0){try{const t=await c.getLayouts();if(t.length>0)try{const n=await c.getLayout(t[0]);return zu(n)}catch(n){Jo.error("Unable to load layout",t[0],":",n),Jo.warn("No valid layouts found, falling back to default layout")}}catch(t){Jo.error("Unable to fetch layout list",t),Jo.warn("Falling back to default layout")}return e?kx:Mx}function Ox(c){const{filterSets:e,layoutConfig:t,links:n}=c;return{filterSets:e,layoutConfig:t,links:n,version:2}}const ol={exportLayout:Ox,getDefaultLayout:Lx,normalizeLayout:zu},el=ee.module("DownloadServiceWorkerUtils");class ro{static DOWNLOAD_PATH="/download/";static registerOnLoaded(){new URL("./",window.location.href).origin===window.location.origin&&("serviceWorker"in navigator?window.addEventListener("load",()=>{const t=new URL("./download/serviceWorker.js",window.location.href);navigator.serviceWorker.register(t).then(n=>{n.update(),el.info("Registering service worker on ",t,n)}).catch(n=>{el.error("Failed to register service worker",n)})}):el.info("Service worker is not supported."))}static async getServiceWorker(){if("serviceWorker"in navigator){const t=(await navigator.serviceWorker.getRegistrations()).find(n=>n.scope.endsWith(ro.DOWNLOAD_PATH));if(t&&t.active)return el.info("Download service worker is active."),t.active;throw new Error("Can not find download service worker.")}throw new Error("Download service worker is not available.")}static unregisterSW(){}}const it=ee.module("AppMainContainer");class Si extends w.Component{static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,t){return Ka.hydrate({...e,unzip:n=>Vc.loadAsync(n).then(s=>Object.values(s.files))},t)}static handleRefresh(){it.info("Refreshing application"),window.location.reload()}constructor(e){super(e),this.handleSettingsMenuHide=this.handleSettingsMenuHide.bind(this),this.handleSettingsMenuShow=this.handleSettingsMenuShow.bind(this),this.handleError=this.handleError.bind(this),this.handleControlSelect=this.handleControlSelect.bind(this),this.handleToolSelect=this.handleToolSelect.bind(this),this.handleClearFilter=this.handleClearFilter.bind(this),this.handleDataChange=this.handleDataChange.bind(this),this.handleAutoFillClick=this.handleAutoFillClick.bind(this),this.handleGoldenLayoutChange=this.handleGoldenLayoutChange.bind(this),this.handleLayoutConfigChange=this.handleLayoutConfigChange.bind(this),this.handleExportLayoutClick=this.handleExportLayoutClick.bind(this),this.handleImportLayoutClick=this.handleImportLayoutClick.bind(this),this.handleImportLayoutFiles=this.handleImportLayoutFiles.bind(this),this.handleLoadTablePlugin=this.handleLoadTablePlugin.bind(this),this.handleResetLayoutClick=this.handleResetLayoutClick.bind(this),this.handleWidgetMenuClick=this.handleWidgetMenuClick.bind(this),this.handleWidgetsMenuClose=this.handleWidgetsMenuClose.bind(this),this.handleWidgetSelect=this.handleWidgetSelect.bind(this),this.handlePaste=this.handlePaste.bind(this),this.hydrateChart=this.hydrateChart.bind(this),this.hydrateGrid=this.hydrateGrid.bind(this),this.hydratePandas=this.hydratePandas.bind(this),this.hydrateDefault=this.hydrateDefault.bind(this),this.openNotebookFromURL=this.openNotebookFromURL.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleReconnectAuthFailed=this.handleReconnectAuthFailed.bind(this),this.importElement=ae.createRef(),this.state={contextActions:[{action:()=>{this.handleToolSelect(_t.LINKER)},shortcut:qn.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:Ut.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{it.debug("Consume unhandled save shortcut")},shortcut:qn.SAVE,isGlobal:!0}],isAuthFailed:!1,isDisconnected:!1,isPanelsMenuShown:!1,isSettingsMenuShown:!1,widgets:[]}}componentDidMount(){this.initWidgets(),this.startListeningForDisconnect(),window.addEventListener("beforeunload",Si.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:t}=this.props;e.dashboardData!==t&&this.handleDataChange(t)}componentWillUnmount(){this.deinitWidgets(),this.stopListeningForDisconnect(),window.removeEventListener("beforeunload",Si.handleWindowBeforeUnload)}goldenLayout;importElement;widgetListenerRemover;initWidgets(){const{connection:e}=this.props;if(e.subscribeToFieldUpdates==null){it.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(t=>{it.debug("Got updates",t),this.setState(({widgets:n})=>{const{updated:s,created:i,removed:o}=t,l=[...s,...o],a=n.filter(h=>!l.some(u=>u.name===h.name));return[...s,...i].forEach(h=>{h.name!=null&&h.name!==""&&a.push(h)}),{widgets:a}})})}deinitWidgets(){this.widgetListenerRemover?.()}openNotebookFromURL(){const{match:e}=this.props,{notebookPath:t}=e.params;if(t){const{session:n,sessionConfig:s}=this.props;if(n==null||s==null){it.error("No session available to open notebook URL",t);return}const i={id:`/${t}`,itemName:`/${t}`},o=s.type,l={value:null,language:o};this.emitLayoutEvent(Pe.SELECT_NOTEBOOK,n,o,l,i,!0)}}sendClearFilter(){this.emitLayoutEvent(Ye.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...t){this.goldenLayout?.eventHub.emit(e,...t)}handleError(e){ve.isCanceled(e)||it.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,t=null){switch(it.debug("handleControlSelect",e),e){case bs.DROPDOWN_FILTER:this.emitLayoutEvent(Ye.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:t});break;case bs.INPUT_FILTER:this.emitLayoutEvent(Ye.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:t});break;case bs.MARKDOWN:this.emitLayoutEvent(Du.OPEN,{title:"Markdown",type:e,dragEvent:t});break;case bs.FILTER_SET_MANAGER:this.emitLayoutEvent(Ye.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:t});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){it.debug("handleToolSelect",e);const{activeTool:t,setActiveTool:n}=this.props;n(t===e?_t.DEFAULT:e)}handleClearFilter(){this.sendClearFilter()}handleDataChange(e){const{updateWorkspaceData:t}=this.props,{closed:n,filterSets:s,links:i}=e;t({closed:n,filterSets:s,links:i})}handleGoldenLayoutChange(e){this.goldenLayout=e}handleLayoutConfigChange(e){const{updateWorkspaceData:t}=this.props;t({layoutConfig:e})}handleWidgetMenuClick(){this.setState(({isPanelsMenuShown:e})=>({isPanelsMenuShown:!e}))}handleWidgetSelect(e,t){this.setState({isPanelsMenuShown:!1}),it.debug("handleWidgetSelect",e,t),this.openWidget(e,t)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;it.debug("handleAutoFillClick",e);const t=e.sort((n,s)=>n.title!=null&&s.title!=null?n.title.localeCompare(s.title):0);for(let n=0;n<t.length;n+=1)this.openWidget(t[n])}handleExportLayoutClick(){it.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:t}=e,n=ol.exportLayout(t);it.info("handleExportLayoutClick exportedConfig",n);const s=new Blob([JSON.stringify(n)],{type:"application/json"}),i=I.i18n.DateTimeFormat.format("yyyy-MM-dd-HHmmss",new Date),o=document.createElement("a");o.href=URL.createObjectURL(s),o.download=`deephaven-app-layout-${i}.json`,o.click()}catch(e){it.error("Unable to export layout",e)}}handleImportLayoutClick(){it.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){it.info("handleResetLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.resetLayout()}handleImportLayoutFiles(e){e.stopPropagation(),e.preventDefault(),e.target.files!=null&&this.importLayoutFile(e.target.files?.[0])}handleDisconnect(){it.info("Disconnected from server"),this.setState({isDisconnected:!0})}handleReconnect(){it.info("Reconnected to server"),this.setState({isDisconnected:!1})}handleReconnectAuthFailed(){it.warn("Reconnect authentication failed"),this.setState({isAuthFailed:!0})}async importLayoutFile(e){try{const{updateDashboardData:t,updateWorkspaceData:n}=this.props,s=await e.text(),i=JSON.parse(s),{filterSets:o,layoutConfig:l,links:a}=ol.normalizeLayout(i);n({layoutConfig:l}),t(un,{filterSets:o,links:a})}catch(t){it.error("Unable to import layout",t)}}async resetLayout(){const{layoutStorage:e,session:t}=this.props,{filterSets:n,layoutConfig:s,links:i}=await ol.getDefaultLayout(e,t!==void 0),{updateDashboardData:o,updateWorkspaceData:l}=this.props;l({layoutConfig:s}),o(un,{filterSets:n,links:i})}handlePaste(e){if(e.target instanceof HTMLElement&&e.target.closest(".monaco-editor"))return;const{clipboardData:t}=e,n=t.getData("Text"),s=/“|”/g;s.test(n)&&(e.preventDefault(),e.stopPropagation(),document.execCommand("insertText",!1,n.replace(s,'"')))}handleLoadTablePlugin(e){const{plugins:t}=this.props,n=t.get(e);if(n!=null&&n.TablePlugin!=null)return n.TablePlugin;const s=`Unable to find table plugin ${e}.`;return it.error(s),r.jsx("div",{className:"error-message",children:`${s}`})}startListeningForDisconnect(){const{connection:e}=this.props;e.addEventListener(I.IdeConnection.EVENT_DISCONNECT,this.handleDisconnect),e.addEventListener(I.IdeConnection.EVENT_RECONNECT,this.handleReconnect),e.addEventListener(I.CoreClient.EVENT_RECONNECT_AUTH_FAILED,this.handleReconnectAuthFailed)}stopListeningForDisconnect(){const{connection:e}=this.props;e.removeEventListener(I.IdeConnection.EVENT_DISCONNECT,this.handleDisconnect),e.removeEventListener(I.IdeConnection.EVENT_RECONNECT,this.handleReconnect),e.removeEventListener(I.CoreClient.EVENT_RECONNECT_AUTH_FAILED,this.handleReconnectAuthFailed)}hydrateDefault(e,t){const{connection:n}=this.props,{metadata:s}=e;if(s?.type!=null&&(s?.id!=null||s?.name!=null)){const i=s.id!=null?{type:s.type,id:s.id}:{type:s.type,name:s.name,title:s.name};return{fetch:()=>n.getObject(i),localDashboardId:t,...e}}return Ka.hydrate(e,t)}hydrateGrid(e,t){return this.hydrateTable(e,t,e.metadata.type??I.VariableType.TABLE)}hydratePandas(e,t){return this.hydrateTable(e,t,I.VariableType.PANDAS)}hydrateTable(e,t,n=I.VariableType.TABLE){const{connection:s}=this.props;return{...e,getDownloadWorker:ro.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:t,makeModel:()=>Ix(s,e.metadata,n)}}hydrateChart(e,t){const{connection:n}=this.props;return{...e,localDashboardId:t,makeModel:()=>{const{metadata:s,panelState:i}=e;return xx(n,s,i)}}}openWidget(e,t){const{connection:n}=this.props;this.emitLayoutEvent(we.OPEN,{dragEvent:t,fetch:()=>n.getObject(e),widget:e})}getDashboardPlugins=he(e=>[...e.entries()].filter(([,t])=>t.DashboardPlugin!=null).map(([t,{DashboardPlugin:n}])=>r.jsx(n,{},t)));render(){const{activeTool:e,plugins:t,user:n,workspace:s,serverConfigValues:i}=this.props,{data:o}=s,{layoutConfig:l}=o,{permissions:a}=n,{canUsePanels:d}=a,{contextActions:h,isAuthFailed:u,isDisconnected:m,isPanelsMenuShown:g,isSettingsMenuShown:p,widgets:C}=this.state,f=this.getDashboardPlugins(t);return r.jsxs("div",{className:K("app-main-tabs","w-100","h-100","d-flex","flex-column",e?`active-tool-${e.toLowerCase()}`:""),onPaste:this.handlePaste,tabIndex:-1,children:[r.jsx("nav",{className:"nav-container",children:r.jsxs("div",{className:"app-main-top-nav-menus",children:[r.jsx("img",{src:Hu,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),r.jsxs("div",{children:[r.jsxs(_,{kind:"ghost",className:"btn-panels-menu",icon:Qg,onClick:()=>{},children:["Controls",r.jsx(nd,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),d&&r.jsxs(_,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:Jg,children:["Panels",r.jsx(Ul,{isShown:g,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:r.jsx(Rx,{widgets:C,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),r.jsx(_,{kind:"ghost",className:K("btn-settings-menu",{"text-warning":n.operateAs!=null&&n.operateAs!==n.name}),onClick:this.handleSettingsMenuShow,icon:r.jsx(X,{icon:uo,transform:"grow-3 right-1 down-1"}),tooltip:"User Settings"})]})]})}),r.jsxs(mb,{emptyDashboard:r.jsx(Dx,{onAutoFillClick:this.handleAutoFillClick}),id:un,layoutConfig:l,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[r.jsx(RR,{hydrate:this.hydrateGrid,getDownloadWorker:ro.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),r.jsx(bR,{hydrate:this.hydrateChart}),r.jsx(wR,{}),r.jsx(TR,{hydrateConsole:Si.hydrateConsole,notebooksUrl:new URL("notebooks/",document.baseURI).href}),r.jsx(ER,{}),r.jsx(PR,{hydrate:this.hydratePandas}),r.jsx(_R,{}),r.jsx(AR,{}),f]}),r.jsx($t,{in:p,timeout:Xe.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:r.jsx(Rn,{serverConfigValues:i,onDone:this.handleSettingsMenuHide,user:n})}),r.jsx(se,{actions:h}),r.jsx("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles}),r.jsx(_m,{isOpen:m&&!u,debounceMs:250,children:r.jsx(Pm,{icon:ep,title:r.jsxs(r.Fragment,{children:[r.jsx(Nn,{})," Attempting to reconnect..."]}),subtitle:"Please check your network connection."})}),r.jsx(io,{confirmButtonText:"Refresh",onConfirm:Si.handleRefresh,isOpen:u,headerText:"Authentication failed",bodyText:"Credentials are invalid. Please refresh your browser to try and reconnect."})]})}}const Ax=c=>({activeTool:Yl(c),dashboardData:Pt(c,un),layoutStorage:Ex(c),plugins:dC(c),connection:ny(c,un),session:Qs(c,un)?.session,sessionConfig:Qs(c,un)?.config,user:fh(c),workspace:Kl(c),serverConfigValues:yx(c)}),_x=gt(Ax,{setActiveTool:Xl,updateDashboardData:kn,updateWorkspaceData:Ah})(wm(Si));function Px(){return r.jsxs("div",{className:"app",children:[r.jsx(_x,{}),r.jsx(zc,{})]})}const jx=ee.module("LocalWorkspaceStorage");class bi{static STORAGE_KEY="deephaven.WorkspaceStorage";static async makeDefaultWorkspaceData(e,t){const{filterSets:n,links:s,layoutConfig:i}=await ol.getDefaultLayout(e,t?.isConsoleAvailable);return{settings:{defaultDateTimeFormat:lt.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:lt.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:We.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:ot.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1,defaultNotebookSettings:{isMinimapEnabled:!1}},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(e,t){return{data:await bi.makeDefaultWorkspaceData(e,t)}}layoutStorage;constructor(e){this.layoutStorage=e}async load(e){try{return JSON.parse(localStorage.getItem(bi.STORAGE_KEY)??"")}catch{return jx.info("Unable to load workspace data, initializing to default data"),bi.makeDefaultWorkspace(this.layoutStorage,e)}}async save(e){return localStorage.setItem(bi.STORAGE_KEY,JSON.stringify(e)),e}}class Hx{storageService;root;constructor(e,t=""){this.storageService=e,this.root=t}async getLayouts(){return(await this.storageService.listItems(this.root,"*.json")).map(t=>t.basename)}async getLayout(e){const n=await(await this.storageService.loadFile(`${this.root}/${e}`)).text();return JSON.parse(n)}}const zi=ee.module("GrpcFileStorageTable");class Ol{static REFRESH_DEBOUNCE=50;storageService;baseRoot;root;currentSize=0;currentViewport;listeners=[];viewportUpdatePromise;currentViewportData;childTables=new Map;constructor(e,t="",n=t){this.storageService=e,this.baseRoot=t,this.root=n,n===t&&(this.doRefresh=Ge(this.doRefresh.bind(this),Ol.REFRESH_DEBOUNCE))}removeBaseRoot(e){return me.removeRoot(this.baseRoot,e)}getViewportData(){return this.viewportUpdatePromise||this.refreshInternal(),this.viewportUpdatePromise??Promise.resolve({items:[],offset:0})}getSnapshot(e){throw new Error("Method not implemented.")}get size(){return this.currentSize}setExpanded(e,t){const n=e.split("/");let s=n.shift();if((s===void 0||s==="")&&(s=n.shift()),s===void 0||s==="")throw new Error(`Invalid path: ${e}`);const i=n.join("/");if(t){if(!this.childTables.has(s)){const o=new Ol(this.storageService,this.baseRoot,`${this.root}/${s}`);this.childTables.set(s,o)}i&&this.childTables.get(s)?.setExpanded(i,t)}else this.childTables.has(s)&&(i?this.childTables.get(s)?.setExpanded(i,t):this.childTables.delete(s));this.currentViewport&&this.refreshInternal()}collapseAll(){this.childTables.clear(),this.currentViewport&&this.refreshInternal()}setSearch(e){throw new Error("Method not implemented.")}setViewport(e){this.currentViewport=e,this.refreshInternal()}setFilters(){throw new Error("Method not implemented.")}setSorts(){throw new Error("Method not implemented.")}setReversed(){throw new Error("Method not implemented.")}close(){this.listeners=[]}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(t=>t!==e)}}doRefresh(e){zi.debug2("doRefresh",this.root),e(this.fetchData())}refresh(){zi.debug2("refresh",this.root),this.viewportUpdatePromise?.cancel();const e=new Promise(n=>{this.doRefresh(n)}),t=ve.makeCancelable(e.then(n=>{if(this.viewportUpdatePromise!==t)throw new Pl;return this.currentViewportData=n,this.sendUpdate(),n}));t.catch(n=>{ve.isCanceled(n)||zi.error("Error updating viewport",n)}),this.viewportUpdatePromise=t}refreshInternal(){try{this.refresh()}catch(e){ve.isCanceled(e)||zi.error("Unable to refresh data",e)}}async fetchData(){const{currentViewport:e}=this;if(!e)throw new Error("No viewport set");let n=(await this.storageService.listItems(this.root)).map(s=>({type:s.type,filename:this.removeBaseRoot(s.filename),basename:s.basename,id:this.removeBaseRoot(s.filename),isExpanded:s.type==="directory"?this.childTables.has(s.basename):void 0})).sort((s,i)=>s.type!==i.type?s.type==="directory"?-1:1:s.basename.localeCompare(i.basename));for(let s=0;s<n.length;s+=1){const i=n[s],{basename:o,filename:l}=i;if(l===this.removeBaseRoot(`${this.root}/${o}`)&&i.type==="directory"){const a=this.childTables.get(o);if(a!=null){a.setViewport({top:0,bottom:e.bottom-s});const d=await a.getViewportData();n.splice(s+1,0,...d.items)}}}return this.currentSize=n.length,zi.debug2(this.root,"items",n,e),n=n.slice(e.top,e.bottom),{items:n,offset:e.top}}sendUpdate(){const{listeners:e}=this,t=this.currentViewportData??{items:[],offset:0};for(let n=0;n<e.length;n+=1)e[n](t)}}const Ux=ee.module("GrpcFileStorage");class sd{static REFRESH_THROTTLE=150;storageService;tables=[];root;constructor(e,t=""){this.storageService=e,this.root=t}removeRoot(e){return me.removeRoot(this.root,e)}addRoot(e){return me.addRoot(this.root,e)}async createDirectory(e){return await this.storageService.createDirectory(this.addRoot(e)),this.refreshTables(),{type:"directory",id:e,filename:e,basename:me.getBaseName(e)}}async getTable(){const e=new Ol(this.storageService,this.root);return this.tables.push(e),e}async saveFile(e){const t=dh.storage.FileContents.text(e.content);return await this.storageService.saveFile(this.addRoot(e.filename),t,!0),this.refreshTables(),e}async loadFile(e){const n=await(await this.storageService.loadFile(this.addRoot(e))).text();return{filename:e,basename:me.getBaseName(e),content:n}}async deleteFile(e){await this.storageService.deleteItem(this.addRoot(e)),this.refreshTables()}async moveFile(e,t){await this.storageService.moveItem(this.addRoot(e),this.addRoot(t)),this.refreshTables()}async info(e){const t=await this.storageService.listItems(this.addRoot(me.getPath(e)),me.getBaseName(e));if(t.length===0)throw new Xr;if(t.length>1)throw Ux.error("More than one matching file found, should never happen.",t),new Error("More than one matching file found");const n=t[0];return{filename:this.removeRoot(n.filename),basename:n.basename,id:this.removeRoot(n.filename),type:n.type}}refreshTables=Ts(()=>{this.tables.forEach(e=>e.refresh())},sd.REFRESH_THROTTLE)}const Vx=ee.module("AppInit");function id(c){const{workspace:e,setActiveTool:t,setCommandHistoryStorage:n,setDashboardData:s,setFileStorage:i,setLayoutStorage:o,setDashboardConnection:l,setDashboardSessionWrapper:a,setPlugins:d,setUser:h,setWorkspace:u,setWorkspaceStorage:m,setServerConfigValues:g}=c,p=jm(),C=Hm(),f=Um(),S=w.useContext(Vm),v=w.useContext(Bm),[b,T]=w.useState();w.useEffect(function(){d(f)},[f,d]),w.useEffect(function(){async function D(){try{const L=await $m(),M=await Wm(C,L),j=p.getStorageService(),A=new Hx(j,"/layouts"),W=new sd(j,"/notebooks"),H=new bi(A),U=new ZR,[P,Q]=await Promise.all([p.getServerConfigValues(),H.load({isConsoleAvailable:M!==void 0})]),{data:G}=Q,{settings:ne}=G;ne.defaultDecimalFormatOptions===void 0&&(ne.defaultDecimalFormatOptions={defaultFormatString:We.DEFAULT_FORMAT_STRING}),ne.defaultIntegerFormatOptions===void 0&&(ne.defaultIntegerFormatOptions={defaultFormatString:ot.DEFAULT_FORMAT_STRING}),ne.truncateNumbersWithPound===void 0&&(ne.truncateNumbersWithPound=!1);const{shortcutOverrides:V={}}=ne,Z=sn.isMacPlatform?V.mac??{}:V.windows??{};Object.entries(Z).forEach(([fe,Re])=>{Ve.get(fe)?.setKeyState(Re)});const oe={filterSets:G.filterSets,links:G.links},re=new Map(P),q="",ie={name:q,operateAs:q,groups:[],...S,permissions:{isACLEditor:!1,isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:re.get("internal.webClient.appInit.canCopy")!=="false",canDownloadCsv:re.get("internal.webClient.appInit.canDownloadCsv")!=="false",canLogout:!0,...v}};t(_t.DEFAULT),g(re),n(U),s(un,oe),i(W),o(A),l(un,C),M!==void 0&&a(un,M),h(ie),m(H),u(Q)}catch(L){Vx.error(L),T(L)}}D()},[p,C,t,n,s,i,o,l,a,h,u,m,g,S,v]);const y=e==null&&b==null,E=!y&&b==null,R=b!=null?`${b}`:null;return r.jsxs(r.Fragment,{children:[E&&r.jsx(Px,{}),r.jsx(Vl,{isLoading:y&&R==null,isLoaded:E,errorMessage:R})]})}id.propTypes={workspace:B.shape({}),workspaceStorage:B.shape({close:B.func}),setActiveTool:B.func.isRequired,setCommandHistoryStorage:B.func.isRequired,setDashboardData:B.func.isRequired,setFileStorage:B.func.isRequired,setLayoutStorage:B.func.isRequired,setDashboardConnection:B.func.isRequired,setDashboardSessionWrapper:B.func.isRequired,setPlugins:B.func.isRequired,setUser:B.func.isRequired,setWorkspace:B.func.isRequired,setWorkspaceStorage:B.func.isRequired};id.defaultProps={workspace:null,workspaceStorage:null};const Bx=c=>({workspace:Kl(c),workspaceStorage:lC(c)}),Oc=gt(Bx,{setActiveTool:Xl,setCommandHistoryStorage:uC,setDashboardData:ou,setFileStorage:mC,setLayoutStorage:QR,setDashboardConnection:sy,setDashboardSessionWrapper:iy,setPlugins:pC,setUser:cC,setWorkspace:Oh,setWorkspaceStorage:hC,setServerConfigValues:fC})(id),$x=document.location.pathname;function Wx(){return r.jsx(vm,{basename:$x,children:r.jsxs(Tm,{children:[r.jsx(rd,{exact:!0,path:"/",component:Oc}),r.jsx(rd,{path:"/notebooks/:notebookPath+",component:Oc}),r.jsx(Em,{from:"*",to:"/"})]})})}function Qx(){return ro.registerOnLoaded(),At.init({getWorker:()=>new zm}),window["__react-beautiful-dnd-disable-dev-warnings"]=!0,r.jsx(Pc,{store:vr,children:r.jsx(Wx,{})})}export{Qx as AppRoot,Qx as default};
|
|
42
|
-
//# sourceMappingURL=AppRoot-fea00f9f.js.map
|