@deephaven/code-studio 0.39.1-chart-refactor.13 → 0.39.1-chart-refactor.14
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-e91e1a27.js → AppRoot-f1671cf4.js} +3 -3
- package/build/assets/AppRoot-f1671cf4.js.map +1 -0
- package/build/assets/{index-9a796860.js → index-0473d449.js} +2 -2
- package/build/assets/{index-9a796860.js.map → index-0473d449.js.map} +1 -1
- package/build/assets/{index-743a977a.js → index-f0607d3d.js} +2 -2
- package/build/assets/{index-743a977a.js.map → index-f0607d3d.js.map} +1 -1
- package/build/assets/{useConnection-2aa43b25.js → useConnection-063998ee.js} +2 -2
- package/build/assets/{useConnection-2aa43b25.js.map → useConnection-063998ee.js.map} +1 -1
- package/build/index.html +1 -1
- package/package.json +31 -31
- package/build/assets/AppRoot-e91e1a27.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as r,G as X,r as v,I as qu,p as U,F as z,J as Lc,H as oe,K as ce,L as Oa,M as bs,N as We,O as we,P as _c,Q as Ze,S as Ja,T as Xu,U as Zu,V as Qu,W as Ju,X as le,R as ll,Y as od,Z as Ge,_ as er,$ as em,a0 as tm,a1 as Pc,a2 as Ae,a3 as La,E as nm,D as Vt,a4 as Ol,a5 as jc,a6 as tr,a7 as sm,a8 as In,a9 as im,aa as om,ab as lm,ac as am,ad as _a,ae as rm,af as dm,ag as cm,ah as ld,ai as hm,aj as ad,ak as um,al as mm,am as gm,an as pm,ao as fm,ap as Cm,aq as mt,ar as Hc,as as Sm,at as Uc,au as bm,av as Bc,aw as wm,ax as vm,ay as Tm,az as Em,aA as rd,aB as ym}from"./vendor-d3621ab4.js";import{P as be,u as vs,T as Ll,B as P,a as D,S as He,M as fe,K as ve,G as Yn,b as Jt,C as te,c as tn,D as $n,d as xi,e as _l,f as Je,g as co,I as Ei,U as Rm,h as pe,i as F,j as Zs,F as Wn,k as gn,l as nr,E as Ie,m as N,n as jn,o as ws,p as tl,q as it,r as $e,s as st,t as Pl,v as xm,O as Un,w as Im,x as hn,y as rn,z as Dm,A as Fm,R as jl,H as Gn,J as Hl,L as Vc,N as $c,Q as Nm,V as km,W as dd,X as Ve,Y as cd,Z as Wc,_ as sr,$ as hd,a0 as io,a1 as Gc,a2 as Mm,a3 as zc,a4 as Am,a5 as nn,a6 as Om,a7 as Lm,a8 as _m,a9 as Pm,aa as jm,ab as Hm,ac as Um,ad as Bm,ae as Vm,af as $m,ag as Wm,ah as Gm}from"./useConnection-
|
|
1
|
+
import{C as r,G as X,r as v,I as qu,p as U,F as z,J as Lc,H as oe,K as ce,L as Oa,M as bs,N as We,O as we,P as _c,Q as Ze,S as Ja,T as Xu,U as Zu,V as Qu,W as Ju,X as le,R as ll,Y as od,Z as Ge,_ as er,$ as em,a0 as tm,a1 as Pc,a2 as Ae,a3 as La,E as nm,D as Vt,a4 as Ol,a5 as jc,a6 as tr,a7 as sm,a8 as In,a9 as im,aa as om,ab as lm,ac as am,ad as _a,ae as rm,af as dm,ag as cm,ah as ld,ai as hm,aj as ad,ak as um,al as mm,am as gm,an as pm,ao as fm,ap as Cm,aq as mt,ar as Hc,as as Sm,at as Uc,au as bm,av as Bc,aw as wm,ax as vm,ay as Tm,az as Em,aA as rd,aB as ym}from"./vendor-d3621ab4.js";import{P as be,u as vs,T as Ll,B as P,a as D,S as He,M as fe,K as ve,G as Yn,b as Jt,C as te,c as tn,D as $n,d as xi,e as _l,f as Je,g as co,I as Ei,U as Rm,h as pe,i as F,j as Zs,F as Wn,k as gn,l as nr,E as Ie,m as N,n as jn,o as ws,p as tl,q as it,r as $e,s as st,t as Pl,v as xm,O as Un,w as Im,x as hn,y as rn,z as Dm,A as Fm,R as jl,H as Gn,J as Hl,L as Vc,N as $c,Q as Nm,V as km,W as dd,X as Ve,Y as cd,Z as Wc,_ as sr,$ as hd,a0 as io,a1 as Gc,a2 as Mm,a3 as zc,a4 as Am,a5 as nn,a6 as Om,a7 as Lm,a8 as _m,a9 as Pm,aa as jm,ab as Hm,ac as Um,ad as Bm,ae as Vm,af as $m,ag as Wm,ah as Gm}from"./useConnection-063998ee.js";import{e as zn,l as xn,K as en,a as ud,R as zm,b as gs,W as Km}from"./monaco-6eaf53f7.js";import{v as Pa,d as Ym,a as Kc,b as ir,L as Nn,c as ho,e as Vn,f as Yc,g as J,h as md,i as qm,j as Xm,k as Zm,l as Qm,m as $t,n as Ss,o as qc,p as Kn,q as Ul,r as yi,s as Jm,t as eg,u as gd,w as al,x as pd,y as Xc,z as tg,A as uo,B as Zc,C as ng,D as sg,E as ig,T as Ye,F as or,G as lr,H as rl,I as An,J as og,K as lg,M as ag,N as rg,O as dg,P as ar,Q as Ts,R as fd,S as mo,U as rr,V as dr,W as Qc,X as cg,Y as Bl,Z as hg,_ as dl,$ as ug,a0 as cr,a1 as Jc,a2 as Gs,a3 as mg,a4 as gg,a5 as pg,a6 as fg,a7 as Cg,a8 as Sg,a9 as Cd,aa as ma,ab as bg,ac as wg,ad as vg,ae as Vl,af as $l,ag as Tg,ah as Eg,ai as Wl,aj as eh,ak as yg,al as Rg,am as xg,an as th,ao as Ig,ap as Dg,aq as Fg,ar as Ng,as as kg,at as Mg,au as Ag,av as Og,aw as Lg,ax as _g,ay as Pg,az as jg,aA as Hg,aB as nh,aC as Ug,aD as ja,aE as Ha,aF as Bg,aG as Vg,aH as $g,aI as Wg,aJ as Gg,aK as zg,aL as Kg,aM as Yg,aN as qg,aO as Xg,aP as Zg,aQ as Qg,aR as Jg,aS as Sd,aT as ep,aU as tp,aV as np}from"./index-f0607d3d.js";import{P as hr,b as sp,h as ip,p as op,o as lp,s as ap,t as rp,c as sh}from"./plotly-5dd1e817.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 ih=ur,dp="table_",bd="column_",cp=new Set(["in","not","i","ii","k"]),hp=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"]),up=/[^a-zA-Z0-9_$+@-]/g,mp=/[^A-Za-z0-9_$]/g;class js{static legalize=(e,t,n,s,i)=>{let o=e.trim().replace(/[- ]/g,"_");return s&&(cp.has(o)||hp.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=>js.legalize(e,dp,up,!1,0);static legalizeColumnNames=e=>{const t=[];return e.forEach((n,s)=>{let i=js.legalizeColumnName(n,s);t.includes(i)&&(i=bd+s),t.push(i)}),t};static legalizeColumnName=(e,t=0)=>js.legalize(e,bd,mp,!0,t);static isValidTableName=e=>js.legalizeTableName(e)===e;static isValidColumnName=e=>js.legalizeColumnName(e)===e}const Ii=js;function gp(c,e){return c?c.closest(`.${e}`):null}const pp={getClosestByClassName:gp};class fp{pending=[];resolved=[];add(e,t){const n=be.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 qn=fp;class Cp extends Error{isInvalid=!0}const wi=Cp;function oh({type:c}){const e=vs();switch(c){case e.VariableType.TABLE:case e.VariableType.TABLEMAP:case e.VariableType.TREETABLE:case e.VariableType.HIERARCHICALTABLE:return r.jsx(X,{icon:ir});case e.VariableType.FIGURE:return r.jsx(X,{icon:Kc});case e.VariableType.PANDAS:return r.jsx(X,{icon:Ym});default:return r.jsx(X,{icon:Pa})}}class Sp extends v.Component{constructor(e){super(e),this.container=null}componentDidMount(){this.colorize()}container;colorize(){const{children:e}=this.props;this.container&&e!=null&&zn.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 Gl=Sp;class bp{static get LANGUAGE_MAP(){return new Map([["python","Python"],["groovy","Groovy"],["scala","Scala"]])}}const lh=bp;class cl{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)?[]:qu.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,t){return t===e.VariableType.TABLE||t===e.VariableType.TREETABLE||t===e.VariableType.HIERARCHICALTABLE}static isWidgetType(e,t){return t===e.VariableType.FIGURE||t===e.VariableType.OTHERWIDGET||t===e.VariableType.PANDAS}static isOpenableType(e,t){return cl.isTableType(e,t)||cl.isWidgetType(e,t)}static isFigureType(e,t){return t===e.VariableType.FIGURE}static isPandas(e,t){return t===e.VariableType.PANDAS}}const Ua=cl;function ah({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})]})}ah.propTypes={children:U.node.isRequired};class wp extends v.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:z("console-history-result-in-progress",{disabled:e}),children:r.jsxs("span",{className:"badge",children:[r.jsx(Nn,{})," Running... ",Ll.formatElapsedTime(n)," ",r.jsx(P,{className:"console-history-result-in-progress-cancel",kind:"ghost",icon:ho,tooltip:"Cancel",onClick:t,disabled:e})]})})}}const vp=wp;class hl extends v.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)>=hl.mouseDragThreshold||Math.abs(e.clientY-this.mouseY)>=hl.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;D(n);const s=n.indexOf(`
|
|
2
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:z("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?Vn: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 Tp=hl;const wd=J.module("ConsoleHistoryItem");class Ep extends v.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(Gl,{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(f=>{a=!0;const{title:C}=f,S=`${C}`,b=e===void 0||e||(s??[]).indexOf(S)>=0,w=r.jsx(P,{kind:"primary",onClick:()=>this.handleObjectClick(f),className:"btn-console-object",disabled:b,icon:r.jsx(oh,{type:f.type}),children:C},S);l.push(w)})}if(h!=null&&t.command==null){let g=`${h.message??h}`;g||(g=h);const p=r.jsx(Tp,{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(vp,{onCancelClick:this.handleCancelClick,disabled:e},"in_progress");l.push(h)}let d=null;return l.length>0&&(d=r.jsx(ah,{children:l})),r.jsxs("div",{className:z("console-command-result",{"console-result-buttons":a}),children:[o,d]})}}const yp=Ep;class mr extends v.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(yp,{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 Rp=mr,xp={name:"Console",CLEAR:He.createAndAdd({id:"CONSOLE.CLEAR",name:"Clear",shortcut:[fe.CTRL,ve.L],macShortcut:[fe.CTRL,ve.C]}),FOCUS_HISTORY:He.createAndAdd({id:"CONSOLE.FOCUS_HISTORY",name:"Focus History",shortcut:[fe.CTRL,ve.H],macShortcut:[fe.CTRL,fe.OPTION,ve.H]})},Ip={name:"Command History",FOCUS_HISTORY:He.createAndAdd({id:"COMMAND_HISTORY.FOCUS_HISTORY",name:"Focus History Search",shortcut:[fe.CTRL,ve.H],macShortcut:[fe.CTRL,fe.OPTION,ve.H]}),SEND_TO_CONSOLE:He.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_CONSOLE",name:"Send to Console",shortcut:[ve.ENTER],macShortcut:[ve.ENTER]}),SEND_TO_NOTEBOOK:He.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_NOTEBOOK",name:"Send to Notebook",shortcut:[fe.CTRL,ve.ENTER],macShortcut:[fe.CMD,ve.ENTER]}),RUN:He.createAndAdd({id:"COMMAND_HISTORY.RUN",name:"Run",shortcut:[fe.ALT,ve.R],macShortcut:[fe.OPTION,ve.R]})},Dp={name:"Notebook",RUN:He.createAndAdd({id:"NOTEBOOK.RUN",name:"Run",shortcut:[fe.ALT,ve.R],macShortcut:[fe.OPTION,ve.R]}),RUN_SELECTED:He.createAndAdd({id:"NOTEBOOK.RUN_SELECTED",name:"Run Selected",shortcut:[fe.ALT,fe.SHIFT,ve.R],macShortcut:[fe.OPTION,fe.SHIFT,ve.R]}),FIND:He.createAndAdd({id:"NOTEBOOK.FIND",name:"Find",shortcut:[fe.CTRL,ve.F],macShortcut:[fe.CMD,ve.F],isEditable:!1}),MINIMAP:He.createAndAdd({id:"NOTEBOOK.MINIMAP",name:"Show Minimap",shortcut:[fe.ALT,ve.M],macShortcut:[fe.OPTION,ve.M]}),WORDWRAP:He.createAndAdd({id:"NOTEBOOK.WORDWRAP",name:"Word Wrap",shortcut:[fe.ALT,ve.Z],macShortcut:[fe.OPTION,ve.Z]})},Fp={CONSOLE:xp,COMMAND_HISTORY:Ip,NOTEBOOK:Dp},Rt=Fp,ct=Object.freeze({FATAL:"FATAL",STDERR:"STDERR",ERROR:"ERROR",WARN:"WARN",STDOUT:"STDOUT",INFO:"INFO",DEBUG:"DEBUG",TRACE:"TRACE"}),Np="#2d2a2e",kp="#fcfcfa",Mp="#fcd65b",Ap="#b2b1b2",Op="#9edc6f",Lp="#76d9e4",_p="#f95d84",Pp="#aa9af4",jp="#f95d84",Hp="#fcfcfa",Up="#7c7b7c",ue={"error-foreground":"#f95d84",background:Np,foreground:kp,"line-height":"19px",string:Mp,"string-delim":"#929192",delimiter:Ap,predefined:Op,keyword:Lp,storage:_p,number:Pp,operator:jp,identifier:Hp,"namespace-identifier":"#f95d84","identifier-js":"#fcd65b",comment:Up,"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"},Bp="python",Vp={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/}}},$p={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"]]}},Wp={id:Bp,conf:Vp,language:$p},Gp=Wp,zp="groovy",Kp={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/}}},Yp={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"]]}},qp={id:zp,conf:Kp,language:Yp},Xp=qp,Zp="scala",Qp={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>))/}}},Jp={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"]]}},ef={id:Zp,conf:Qp,language:Jp},tf=ef,nf="deephavenDb",sf={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/}}},of={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"]]}},lf={id:nf,conf:sf,language:of},af=lf,rf="log",df={},cf={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"}]]}},hf={id:rf,conf:df,language:cf},uf=hf,bn=J.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"]};zn.defineTheme("dh-dark",{base:"vs-dark",inherit:!0,rules:s,colors:i}),bn.debug2("monaco theme: ",ue),zn.setTheme("dh-dark"),t([af,Gp,Xp,uf,tf]),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=zn.EndOfLineSequence.LF){e.getModel()?.setEOL(t)}static openDocument(e,t){const n=e.getModel();D(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,f={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(f)}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();D(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();D(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?en.CtrlCmd:0)|(t.shiftKey?en.Shift:0)|(t.altKey?en.Alt:0)|(t.ctrlKey?en.WinCtrl:0)|ud.fromString(n):(t.ctrlKey?en.CtrlCmd:0)|(t.shiftKey?en.Shift:0)|(t.altKey?en.Alt:0)|(t.metaKey?en.WinCtrl:0)|ud.fromString(n)}static provideLinks(e){const t=[];for(let n=1;n<=e.getLineCount();n+=1){const s=e.getLineContent(n);Lc(s).filter(l=>l.type==="url"?/^https?:\/\//.test(l.value):!0).forEach(l=>{t.push({url:l.href,range:new zm(n,l.start+1,n,l.end+1)})})}return{links:t}}}const Mt=Tn,On=J.module("MonacoCompletionProvider");class Hs extends v.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:Hs.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:f,sortText:C,filterText:S,textEdit:b,insertTextFormat:w}=u;return{label:m,kind:Hs.lspToMonacoKind(g),detail:p,documentation:f?.kind==="markdown"?f:f?.value,sortText:C,filterText:S,insertText:b.text,insertTextRules:w===2?4:w,range:Hs.lspToMonacoRange(b.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:Hs.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:f,documentation:C,parameters:S}=p;return{documentation:C?.kind==="markdown"?C:C?.value,label:f,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:Hs.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 rh=Hs;const ga=J.module("ConsoleInput"),nl=parseInt(ue["line-height"],10),ch=6,hh=6,mf=nl+ch+hh,pa=100;class gr extends v.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=oe.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&&(ga.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:ch,bottom:hh},tabCompletion:"on",value:"",wordWrap:"on"},s=this.commandContainer.current;D(s),this.commandEditor=zn.create(s,n),Mt.setEOL(this.commandEditor),Mt.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();D(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===gs.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===gs.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(en.CtrlCmd|gs.KeyF,()=>{}),Mt.removeConflictingKeybindings(this.commandEditor),Mt.registerPasteHandler(this.commandEditor),this.commandEditor.focus(),this.updateDimensions(),this.setState({model:this.commandEditor.getModel()})}destroyCommandEditor(){const{session:e}=this.props;this.commandEditor&&(Mt.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();D(e);const t=e.getLineLength(1)+1,n=this.commandEditor?.getTopForPosition(1,t);D(n),this.commandEditor?.setPosition({lineNumber:1,column:t}),this.commandEditor?.setScrollTop(n),this.commandEditor?.focus()}focusEnd(){const e=this.commandEditor?.getModel();D(e);const t=e.getLineCount(),n=e.getLineLength(t)+1,s=this.commandEditor?.getTopForPosition(t,n);D(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-pa&&this.loadMoreHistory()}async loadMoreHistory(){try{if(this.loadingPromise!=null||this.bufferIndex==null)return;const{commandHistoryStorage:e,language:t,scope:n}=this.props;this.loadingPromise=be.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+pa-1}),this.loadingPromise=be.makeCancelable(s.getViewportData(),()=>s.close());const i=await this.loadingPromise;this.bufferIndex+=pa,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,be.isCanceled(e)){ga.debug2("Promise canceled, not loading history");return}ga.error("Error fetching history",e)}}processCommand(e){this.commandHistoryIndex=null,this.modifiedCommands.clear(),D(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;D(e);const t=this.commandEditor.getContentHeight(),n=Math.max(Math.min(t,e),mf),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:z("console-input-wrapper",{disabled:e}),children:r.jsxs("div",{className:z("console-input-inner-wrapper",{focus:i}),children:[r.jsx("div",{className:gr.INPUT_CLASS_NAME,ref:this.commandContainer,style:{height:s}}),o&&r.jsx(rh,{model:o,language:t,session:n})]})})}}const vd=gr;const Td="pasted values",gf=[/^audio.*/,/^font.*/,/^image.*/,/^video.*/],fa=[".csv",".tsv",".tab",".psv",".dsv",".txt"],Ed=[".zip"];class Us extends v.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"&&!gf.find(t=>t.test(e.type))}static isValidExtension(e,t=!1){return fa.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")?qm:e.endsWith(".zip")?Xm:Zm}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=oe.createRef(),this.divElem=oe.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();D(i),Us.isValidExtension(i.name,t)?this.handleFile(i):this.setState({dropError:Us.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:Yn.PASTE,disabled:e}]}getValidExtensions=ce(e=>e?[...fa,...Ed]:[...fa]);getAcceptString=ce(e=>this.getValidExtensions(e).join(", "));getFileTypeErrorString=ce(e=>Jt.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:Us.handleDragOver,onDrop:this.handleDrop,tabIndex:-1,children:[r.jsx(te,{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:Qm})}),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(P,{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:Us.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(P,{kind:"ghost",className:"ml-2",onClick:this.unstageFile,icon:$t,tooltip:"Remove"})]})]})]}),Boolean(o)&&r.jsxs("div",{className:"message-content",children:[r.jsx("div",{className:"message-icon",children:r.jsx(X,{icon:Ss})}),r.jsx("label",{children:o}),o===Us.FILE_TYPE_ERROR&&r.jsx("div",{className:"message-small",children:r.jsx("label",{children:this.getFileTypeErrorString(e)})})]})]})}}const ci=Us;class pf{static INTEGER="int";static LONG="long";static DOUBLE="double";static BOOLEAN="bool";static STRING="string";static DATE_TIME="datetime";static LOCAL_TIME="localtime"}const ke=pf,yd="unknown",ff=2147483647,Cf=-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 St{static determineType(e,t,n){if(!e||e===n)return t;switch(t){case ke.STRING:return ke.STRING;case ke.INTEGER:return St.checkInteger(e);case ke.LONG:return St.checkLong(e);case ke.DOUBLE:return St.checkDouble(e);case ke.BOOLEAN:return St.checkBoolean(e);case ke.DATE_TIME:return St.checkDateTime(e);case ke.LOCAL_TIME:return St.checkLocalTime(e);default:return St.getTypeFromUnknown(e)}}static isNotParsableNumber(e){return isNaN(e)||e==="Infinity"||e==="-Infinity"}static checkInteger(e){const t=e.replace(/,/g,"");return St.isNotParsableNumber(t)?ke.STRING:St.getNumberType(t)}static checkLong(e){const t=e.replace(/,/g,"");return St.isNotParsableNumber(t)?ke.STRING:t.includes(".")?ke.DOUBLE:ke.LONG}static checkDouble(e){const t=e.replace(/,/g,"");return St.isNotParsableNumber(t)?ke.STRING:ke.DOUBLE}static checkBoolean(e){const t=e.toLowerCase();return t==="true"||t==="false"?ke.BOOLEAN:ke.STRING}static checkDateTime(e){return Rd.test(e)?ke.DATE_TIME:ke.STRING}static checkLocalTime(e){return xd.test(e)?ke.LOCAL_TIME:ke.STRING}static getTypeFromUnknown(e){const t=e.replace(/,/g,"");if(St.isNotParsableNumber(t)){const n=e.toLowerCase();return n==="true"||n==="false"?ke.BOOLEAN:Rd.test(e)&&e.includes(":")?ke.DATE_TIME:xd.test(e)?ke.LOCAL_TIME:ke.STRING}return St.getNumberType(t)}static getNumberType(e){if(e.includes("."))return ke.DOUBLE;const t=e.startsWith("-")?11:10;if(e.length>t)return ke.LONG;const n=parseInt(e,10);return n>ff||n<Cf?ke.LONG:ke.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;Oa.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))}D(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]=St.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
3
|
Expected length ${s.length} but found ${l.length}.
|
|
4
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;D(t),(e==null||!e.meta.aborted)&&n(t.map(s=>s===yd?ke.STRING:s))}handleError(e){const{onError:t}=this;t(e)}handleNodeUpdate(e){this.zipProgress=e.percent}}const Sf=St,_o=J.module("CsvParser"),bf=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/Oa.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}
|
|
@@ -15,7 +15,7 @@ ${e}`):n.setValue(`${e}`);const i=n.getLineCount(),o=n.getLineLength(i)+1;this.e
|
|
|
15
15
|
`&&(n+=`
|
|
16
16
|
`))}}if(n=n.trimRight(),this.editor.setValue(n),t){const s=this.editor.getModel()?.getLineCount();D(s),this.editor.revealLine(s,1)}this.stopFlushTimer(),this.bufferedMessages=[]}truncateLogIfNecessary(){this.messages.length>bt.maxLogSize&&(this.messages=this.messages.splice(this.messages.length-bt.truncateSize))}scrollToBottom(){if(!this.editor)return;const e=this.editor?.getModel?.()?.getLineCount();D(e),this.editor.revealLine(e,1)}isBottomVisible(){if(!this.editor)return!0;const t=this.editor.getModel()?.getLineCount();return D(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=bt.getLogText(n);e+=s,s.charAt(s.length-1)!==`
|
|
17
17
|
`&&(e+=`
|
|
18
|
-
`)}this.bufferedMessages=[],this.appendLogText(e)}queue(e){this.bufferedMessages.push(e),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,bt.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(P,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:tg,tooltip:"Clear log"}),r.jsx(P,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:uo,tooltip:"Log Settings",onClick:()=>{},children:r.jsx($n,{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 Gf=bt;function mh(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 gh(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 ph(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 zf(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}`)}}hr.register([sp,ip,op,lp,ap,rp]);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(e){this.dh=e,this.listeners=[],this.isDownsamplingDisabled=!1}dh;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,Kf="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",Yf="#403e41",qf="#5b5a5c",Xf="#c0bfbf",Zf="#4878ea",Qf="rgba(91, 90, 92, 0.7)",ft={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:Kf,gridcolor:Yf,linecolor:qf,zerolinecolor:Xf,activecolor:Zf,rangebgcolor:Qf,"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"},kt=Object.freeze({paper_bgcolor:ft["paper-bgcolor"],plot_bgcolor:ft["plot-bgcolor"],title_color:ft["title-color"],colorway:ft.colorway,gridcolor:ft.gridcolor,linecolor:ft.linecolor,zerolinecolor:ft.zerolinecolor,activecolor:ft.activecolor,rangebgcolor:ft.rangebgcolor,area_color:ft["area-color"],trend_color:ft["trend-color"],line_color:ft["line-color"],error_band_line_color:ft["error-band-line-color"],error_band_fill_color:ft["error-band-fill-color"],ohlc_increasing:ft["ohlc-increasing"],ohlc_decreasing:ft["ohlc-decreasing"]}),Pi=J.module("ChartUtils"),Ad="io.deephaven.time.DateTime",Jf=36e5,eC=1e6;function tC(c){return c.asDate!==void 0}function nC(c){return c.asNumber!==void 0}function Od(c){return c.dhTimeZone!==void 0}function sC(c){return c!=null&&c.range!=null&&(c.autorange===!1||c.autorange===void 0)}class de{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 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 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*)(%?)(.*)/);D(i);const[,o,l,a,,d,h,u,m,g]=i,p=a.replace(",","").length,C=l.indexOf(",")>=0||a.indexOf(",")>=0?",":"",S=u!=null&&u!==""?"e":"f",b=m!==""?m:S,w=d.length+h.length,E=`0${p}${C}.${w}${b}`,y=de.convertNumberPrefix(o),R=de.convertNumberPrefix(g);return{tickformat:E,tickprefix:y,ticksuffix:R,automargin:!0}}static addTickSpacing(e,t,n){const{gapBetweenMajorTicks:s}=t;if(s>0){const i=e||{};let o=s;return n&&(o=s/eC),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=de.ORIENTATION.VERTICAL){return{type:e,mode:t,name:n,orientation:i,showlegend:s??void 0}}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 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];sC(o)&&(t[i]=[...o.range])}return t}static getAxisLayoutProperty(e,t){const n=t>0?`${t+1}`:"";return`${e??""}axis${n}`}static periodToDecimal(e){const t=e.split(":");return Number(t[0])+Number(t[1])/60}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 getColorwayFromTheme(e=kt){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 titleFromSettings(e){const{series:t,xAxis:n,title:s=`${(t??[]).join(", ")} by ${n}`}=e;return s}dh;daysOfWeek;constructor(e){this.dh=e,this.daysOfWeek=Object.freeze(e.calendar.DayOfWeek.values())}getAxisFormats(e,t){const n=new Map,s={tickformat:null,ticksuffix:null},i=de.getAllAxes(e),o=de.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 f=g[p],{axis:C}=f,{type:S}=C,b=o.get(S);D(b);const w=b.indexOf(C),T=this.getAxisPropertyName(S);if(T!=null){const E=de.getAxisLayoutProperty(T,w);if(n.has(E))Pi.debug(`${E} already added.`);else{Pi.debug(`Adding ${E} to axisFormats.`);const y=this.getPlotlyAxisFormat(f,t);if(y===null)n.set(E,s);else{n.set(E,y);const{businessCalendar:R}=C;if(R!=null){const I=[],{businessPeriods:x,businessDays:O,holidays:k,timeZone:_}=R,M=t?.getColumnTypeFormatter(Ad);let $;Od(M)&&($=M.dhTimeZone);const H=$?(_.standardOffset-$.standardOffset)/60:0;k.length>0&&I.push(...this.createRangeBreakValuesFromHolidays(k,_,$)),x.forEach(K=>I.push({pattern:"hour",bounds:[de.periodToDecimal(K.close)+H,de.periodToDecimal(K.open)+H]})),O.length<this.daysOfWeek.length&&this.createBoundsFromDays(O).forEach(K=>I.push({pattern:"day of week",bounds:K})),y.rangebreaks=I}if(n.size===d.axes.length)return n}}}}}}return n}getPlotlyChartType(e,t){const{dh:n}=this;switch(e){case n.plot.SeriesPlotStyle.SCATTER:return t?"scatter":"scattergl";case n.plot.SeriesPlotStyle.LINE:return"scatter";case n.plot.SeriesPlotStyle.BAR:case n.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case n.plot.SeriesPlotStyle.PIE:return"pie";case n.plot.SeriesPlotStyle.TREEMAP:return"treemap";case n.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case n.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}getPlotlyChartMode(e,t,n){const{dh:s}=this,i=new Set;switch(e){case s.plot.SeriesPlotStyle.SCATTER:(t??!1)&&i.add(de.MODE_LINES),(n??!0)&&i.add(de.MODE_MARKERS);break;case s.plot.SeriesPlotStyle.LINE:(t??!0)&&i.add(de.MODE_LINES),(n??!1)&&i.add(de.MODE_MARKERS);break}return i.size>0?[...i].join("+"):void 0}getPlotlyProperty(e,t){const{dh:n}=this;switch(e){case n.plot.SeriesPlotStyle.PIE:switch(t){case n.plot.SourceType.X:return"labels";case n.plot.SourceType.Y:return"values"}break;case n.plot.SeriesPlotStyle.OHLC:switch(t){case n.plot.SourceType.TIME:return"x"}break;case n.plot.SeriesPlotStyle.TREEMAP:switch(t){case n.plot.SourceType.X:return"ids";case n.plot.SourceType.Y:return"values";case n.plot.SourceType.LABEL:return"labels";case n.plot.SourceType.PARENT:return"parents";case n.plot.SourceType.COLOR:return"marker.colors"}break}switch(t){case n.plot.SourceType.X:return"x";case n.plot.SourceType.Y:return"y";case n.plot.SourceType.Z:return"z";case n.plot.SourceType.X_LOW:return"xLow";case n.plot.SourceType.X_HIGH:return"xHigh";case n.plot.SourceType.Y_LOW:return"yLow";case n.plot.SourceType.Y_HIGH:return"yHigh";case n.plot.SourceType.TIME:return"time";case n.plot.SourceType.OPEN:return"open";case n.plot.SourceType.HIGH:return"high";case n.plot.SourceType.LOW:return"low";case n.plot.SourceType.CLOSE:return"close";case n.plot.SourceType.SHAPE:return"shape";case n.plot.SourceType.SIZE:return"size";case n.plot.SourceType.LABEL:return"label";case n.plot.SourceType.COLOR:return"color";case n.plot.SourceType.PARENT:return"parent";case n.plot.SourceType.HOVER_TEXT:return"hovertext";case n.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${t}`)}}getPlotlySeriesOrientation(e){const{dh:t}=this,{sources:n}=e;return n.length===2&&n[0]?.axis?.type===t.plot.AxisType.Y?de.ORIENTATION.HORIZONTAL:de.ORIENTATION.VERTICAL}makeSeriesDataFromSeries(e,t,n,s=null,i=kt){const{name:o,isLinesVisible:l,isShapesVisible:a,plotStyle:d,lineColor:h,shapeColor:u,sources:m,shape:g,shapeSize:p}=e,f=m.some(T=>T.axis?.businessCalendar),C=this.getChartType(d,f),S=this.getPlotlyChartMode(d,l??void 0,a??void 0),b=this.getPlotlySeriesOrientation(e),w=de.makeSeriesData(C,S,o,s,b);return this.addSourcesToSeriesData(w,d,m,t),this.addStylingToSeriesData(w,d,i,h,u,g,p,n),w}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=this.getPlotlyProperty(t,d);_c(i,h,[]);const u=a!=null?this.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}`}}}}addStylingToSeriesData(e,t,n=kt,s=null,i=null,o=null,l=null,a=null){const{dh:d}=this,h=e;if(h.marker={line:{}},h.line={width:1},t===d.plot.SeriesPlotStyle.AREA?h.fill="tozeroy":t===d.plot.SeriesPlotStyle.STACKED_AREA?h.stackgroup="stack":t===d.plot.SeriesPlotStyle.STEP?h.line.shape="hv":t===d.plot.SeriesPlotStyle.HISTOGRAM?(h.width=[],h.marker.line!==void 0&&Object.assign(h.marker.line,{color:n.paper_bgcolor,width:1})):t===d.plot.SeriesPlotStyle.OHLC?(h.increasing={line:{color:n.ohlc_increasing}},h.decreasing={line:{color:n.ohlc_decreasing}}):t===d.plot.SeriesPlotStyle.PIE?(h.textinfo="label+percent",h.outsidetextfont={color:n.title_color}):t===d.plot.SeriesPlotStyle.TREEMAP&&(h.hoverinfo="text",h.textinfo="label+text",h.tiling={packing:"squarify",pad:0},h.textposition="middle center",h.outsidetextfont={color:n.title_color}),s!=null&&(t===d.plot.SeriesPlotStyle.BAR?h.marker.color=s:h.line.color=s),i!=null&&(h.marker.color=i),o!=null&&o.length>0)try{h.marker.symbol=de.getMarkerSymbol(o)}catch(u){Pi.warn("Unable to handle shape",o,":",u)}l!=null&&(h.marker.size=l*de.DEFAULT_MARKER_SIZE),a!=null&&t!==d.plot.SeriesPlotStyle.PIE&&(h.visible=a)}getChartType(e,t){const{dh:n}=this;switch(e){case n.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return this.getPlotlyChartType(e,t)}}getAxisPropertyName(e){const{dh:t}=this;switch(e){case t.plot.AxisType.X:return"x";case t.plot.AxisType.Y:return"y";default:return null}}getAxisSide(e){const{dh:t}=this;switch(e){case t.plot.AxisPosition.BOTTOM:return"bottom";case t.plot.AxisPosition.TOP:return"top";case t.plot.AxisPosition.LEFT:return"left";case t.plot.AxisPosition.RIGHT:return"right";default:return}}updateFigureAxes(e,t,n,s=0,i=0,o=kt){const l=e,a=de.getAllAxes(t);for(let d=0;d<t.charts.length;d+=1){const h=t.charts[d],u=n?.(h),m=this.getChartBounds(t,h,s,i);this.updateLayoutAxes(l,h.axes,a,s,i,m,u,o)}this.removeStaleAxes(l,a)}getChartBounds(e,t,n,s){const{dh:i}=this,{cols:o,rows:l}=e,{column:a,colspan:d,row:h,rowspan:u}=t,m=a+d,g=h+u,p=1/o,f=1/l,C=de.AXIS_SIZE_PX/n,S=de.AXIS_SIZE_PX/s,b={bottom:(l-g)*f+(g<l?S/2:0),top:(l-h)*f-(h>0?S/2:0),left:a*p+(a>0?C/2:0),right:m*p-(m<o?C/2:0)};return(de.groupArray(t.axes,"position").get(i.plot.AxisPosition.RIGHT)??[]).length>0&&(n>0?b.right-=(b.right-b.left)*Math.max(0,Math.min(de.LEGEND_WIDTH_PX/n,de.MAX_LEGEND_SIZE)):b.right-=(b.right-b.left)*de.DEFAULT_AXIS_SIZE),b}getPlotlyDateFormat(e,t,n){const{dh:s}=this,i=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 o;const l=e?.getColumnTypeFormatter(t);return l!=null&&Od(l)&&l.dhTimeZone!=null&&l.showTimeZone&&(o=s.i18n.DateTimeFormat.format(" z",new Date,l.dhTimeZone)),{tickformat:i,ticksuffix:o,automargin:!0}}getPlotlyAxisFormat(e,t=null){const{dh:n}=this,{axis:s,columnType:i}=e,{formatPattern:o}=s;let l=null;return F.isDateType(i)?(l=this.getPlotlyDateFormat(t,i,o),l=de.addTickSpacing(l,s,!0)):F.isNumberType(i)&&(l=de.getPlotlyNumberFormat(t,i,o),l=de.addTickSpacing(l,s,!1)),s.formatType===n.plot.AxisFormatType.CATEGORY&&(l?l.type="category":l={type:"category",tickformat:void 0,ticksuffix:void 0}),l}updateLayoutAxes(e,t,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},l,a=kt){const{dh:d}=this,h=s>0?Math.max(de.MIN_AXIS_SIZE,Math.min(de.AXIS_SIZE_PX/i,de.MAX_AXIS_SIZE)):de.DEFAULT_AXIS_SIZE,u=i>0?Math.max(de.MIN_AXIS_SIZE,Math.min(de.AXIS_SIZE_PX/s,de.MAX_AXIS_SIZE)):de.DEFAULT_AXIS_SIZE,m=e,g=de.groupArray(t,"position"),p=de.groupArray(t,"type"),f=[...p.keys()],C=de.groupArray(n,"type");for(let S=0;S<f.length;S+=1){const b=f[S],w=this.getAxisPropertyName(b);if(w!=null){const T=p.get(b),E=C.get(b),R=b===d.plot.AxisType.Y?i:s;D(T),D(E);for(let I=0;I<T.length;I+=1){const x=T[I],O=E.indexOf(x),k=de.getAxisLayoutProperty(w,O);m[k]==null&&(m[k]=this.makeLayoutAxis(b,a));const _=m[k];if(_!=null){this.updateLayoutAxis(_,x,I,g,h,u,o);const{range:M,autorange:$}=_;if(l!=null&&M!==void 0&&($===void 0||$===!1)){const H=l(x),[K,L]=H(M);Pi.debug("Setting downsample range",R,K,L),x.range(R,K,L)}else x.range(R)}}}}}removeStaleAxes(e,t){const n=e,s=de.groupArray(t,"type"),i=[...s.keys()];for(let o=0;o<i.length;o+=1){const l=i[o],a=s.get(l);D(a);let d=a.length;const h=this.getAxisPropertyName(l);if(h!=null){let u=de.getAxisLayoutProperty(h,d);for(;n[u]!=null;)delete n[u],d+=1,u=de.getAxisLayoutProperty(h,d)}}}updateLayoutAxis(e,t,n,s,i,o,l){const{dh:a}=this,h=t.type===a.plot.AxisType.Y?o:i,u=e,m=t.label??"";if(u.title!==void 0&&typeof u.title!="string"?u.title.text=m:u.title={text:m},t.log&&(u.type="log"),u.side=this.getAxisSide(t.position),n>0){u.overlaying=this.getAxisPropertyName(t.type)??void 0;const g=s.get(t.position)??[],p=g.indexOf(t);p>0&&(u.anchor="free",t.position===a.plot.AxisPosition.RIGHT?u.position=l.right+(p-g.length+1)*h:t.position===a.plot.AxisPosition.TOP?u.position=l.top+(p-g.length+1)*h:t.position===a.plot.AxisPosition.BOTTOM?u.position=l.bottom+(g.length-p+1)*h:t.position===a.plot.AxisPosition.LEFT&&(u.position=l.left+(g.length-p+1)*h))}else if(t.type===a.plot.AxisType.X){const g=s.get(a.plot.AxisPosition.LEFT)||[],p=s.get(a.plot.AxisPosition.RIGHT)||[],f=Math.max(l.left,l.left+(g.length-1)*o),C=Math.min(l.right-(p.length-1)*o,l.right);u.domain=[f,C]}else if(t.type===a.plot.AxisType.Y){const g=s.get(a.plot.AxisPosition.BOTTOM)||[],p=s.get(a.plot.AxisPosition.TOP)||[],f=Math.max(l.bottom,l.bottom+(g.length-1)*i),C=Math.min(l.top-(p.length-1)*i,l.top);u.domain=[f,C]}}createBoundsFromDays(e){const t=e.map(o=>this.daysOfWeek.indexOf(o)),n=this.daysOfWeek.filter(o=>!e.includes(o)).map(o=>this.daysOfWeek.indexOf(o)),s=new Set;n.forEach(o=>{for(let l=o+1;l<o+this.daysOfWeek.length;l+=1){const a=l%this.daysOfWeek.length;if(t.includes(a)){s.add(a);break}}});const i=[];return s.forEach(o=>{for(let l=o-1;l>o-this.daysOfWeek.length;l-=1){const a=l<0?l+this.daysOfWeek.length:l;if(t.includes(a)){const d=(a+1)%7;i.push([d,o]);break}}}),i}createRangeBreakValuesFromHolidays(e,t,n){const s=[],i=[];return e.forEach(o=>{o.businessPeriods.length>0?i.push(...this.createPartialHoliday(o,t,n)):s.push(this.createFullHoliday(o,t,n))}),[{values:s},...i]}createFullHoliday(e,t,n){return this.adjustDateForTimeZone(`${e.date.toString()} 00:00:00.000000`,t,n)}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=[this.adjustDateForTimeZone(`${s} ${a}:00.000000`,t,n)],u=Jf*(de.periodToDecimal(d)-de.periodToDecimal(a));o.push({values:h,dvalue:u})}}return o}adjustDateForTimeZone(e,t,n){return n&&n.standardOffset!==t.standardOffset?this.unwrapValue(this.wrapValue(e,Ad,t),n):e}makeFigureSettings(e,t){const{dh:n}=this,{series:s,xAxis:i,type:o}=e,l=de.titleFromSettings(e),a={formatType:`${n.plot.AxisFormatType.NUMBER}`,type:`${n.plot.AxisType.X}`,position:`${n.plot.AxisPosition.BOTTOM}`},d={formatType:`${n.plot.AxisFormatType.NUMBER}`,type:`${n.plot.AxisType.Y}`,position:`${n.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${n.plot.ChartType.XY}`,axes:[a,d],series:(s??[]).map(h=>({plotStyle:`${o}`,name:h,dataSources:[{type:`${n.plot.SourceType.X}`,columnName:i??"",axis:a,table:t},{type:`${n.plot.SourceType.Y}`,columnName:h,axis:d,table:t}]}))}],title:l}}unwrapValue(e,t){const{dh:n}=this;if(e!=null){if(tC(e))return n.i18n.DateTimeFormat.format(de.DATE_FORMAT,e,t);if(nC(e))return e.asNumber()}return e}wrapValue(e,t,n=null){const{dh:s}=this;if(F.isDateType(t)&&typeof e=="string"){const i=e,o=de.DATE_FORMAT.substr(0,e.length),l=s.i18n.DateTimeFormat.parse(o,i);if(!n)return l;const a=`${o} Z`,d=s.i18n.DateTimeFormat.format("Z",l,n),h=s.i18n.DateTimeFormat.parse(a,`${i} ${d}`),u=s.i18n.DateTimeFormat.format("Z",h,n);return s.i18n.DateTimeFormat.parse(a,`${i} ${u}`)}return e}makeLayoutAxis(e,t=kt){const{dh:n}=this,s={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===n.plot.AxisType.X?Object.assign(s,{showgrid:!0}):e===n.plot.AxisType.Y&&Object.assign(s,{zerolinecolor:t.zerolinecolor,zerolinewidth:2}),s}makeDefaultLayout(e=kt){const{dh:t}=this,n={...e,autosize:!0,colorway:de.getColorwayFromTheme(e),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:e.title_color},yanchor:"top",pad:{...de.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:e.title_color}},margin:{...de.DEFAULT_MARGIN},xaxis:this.makeLayoutAxis(t.plot.AxisType.X,e),yaxis:this.makeLayoutAxis(t.plot.AxisType.Y,e),polar:{angularaxis:this.makeLayoutAxis(t.plot.AxisType.SHAPE,e),radialaxis:this.makeLayoutAxis(t.plot.AxisType.SHAPE,e),bgcolor:e.plot_bgcolor},scene:{xaxis:this.makeLayoutAxis(t.plot.AxisType.X,e),yaxis:this.makeLayoutAxis(t.plot.AxisType.Y,e),zaxis:this.makeLayoutAxis(t.plot.AxisType.Z,e)}};return n.datarevision=0,n}hydrateSettings(e){const{dh:t}=this;return{...e,type:e.type!=null?t.plot.SeriesPlotStyle[e.type]:void 0}}}const ht=de;const ns=J.module("Chart");class ui extends v.Component{static defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Zs.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},Plotly:hr,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.PlotComponent=sh(e.Plotly),this.plot=oe.createRef(),this.plotWrapper=oe.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;PlotComponent;plot;plotWrapper;columnFormats;dateTimeFormatterOptions;decimalFormatOptions;integerFormatOptions;rect;ranges;isSubscribed;isLoadedFired;getCachedConfig=ce((e,t,n,s,i)=>{const o=[],l=Boolean(e);if(l&&o.push({name:`Downsampling failed: ${e}`,title:"Downsampling failed",click:()=>{},icon:ui.convertIcon(Zc),attr:"fill-warning"}),t||n||s||l){const a=ui.downsampleButtonTitle(n,s),d=ui.downsampleButtonAttr(n,s),h=n?ng:sg;o.push({name:a,title:"Downsampling status",icon:ui.convertIcon(h),click:this.handleDownsampleClick,attr:d})}return{displaylogo:!1,displayModeBar:n||l?!0:"hover",modeBarButtons:[o,["toImage"],i?["zoom3d","pan3d"]:["zoom2d","pan2d"],i?["orbitRotation","tableRotation","resetCameraDefault3d"]:["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){ns.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(ns.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:ns.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,n=ht.getLayoutRanges(t);!Ze(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(e){if(ns.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,n=[...e.hiddenlabels];t({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([e,t]){if(ns.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){ns.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=Wn.getColumnFormats(e),n=Wn.getDateTimeFormatterOptions(e),{decimalFormatOptions:s={},integerFormatOptions:i={}}=e;(!Ze(this.columnFormats,t)||!Ze(this.dateTimeFormatterOptions,n)||!Ze(this.decimalFormatOptions,s)||!Ze(this.integerFormatOptions,i))&&(this.columnFormats=Wn.getColumnFormats(e),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const{model:e}=this.props,t=new gn(e.dh,this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions);e.setFormatter(t)}updateDimensions(){const e=this.getPlotRect(),{Plotly:t}=this.props;this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&t.relayout(this.plot.current.el,{autosize:!0}).catch(n=>{ns.debug("Unable to resize, promise rejected",n)})}render(){const{PlotComponent:e}=this,{data:t,downsamplingError:n,isDownsampleFinished:s,isDownsampleInProgress:i,isDownsamplingDisabled:o,layout:l,revision:a}=this.state,d=this.getCachedConfig(n,s,i,o,t?.[0].type?.includes("3d")??!1),h=t!=null;return r.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:h&&r.jsx(e,{ref:this.plot,data:t,layout:l,revision:a,config:d,onAfterPlot:this.handleAfterPlot,onError:ns.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}}const iC=ui,Tt=J.module("FigureChartModel");class Cr extends Pn{static ADD_SERIES_DEBOUNCE=50;constructor(e,t,n={},s=kt){super(e),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.dh=e,this.chartUtils=new ht(e),this.figure=t,this.settings=n,this.theme=s,this.data=[];const i={data:{},layout:this.chartUtils.makeDefaultLayout(s)};this.layout={grid:{rows:t.rows,columns:t.cols,pattern:"independent"},template:i},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()}chartUtils;dh;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=ht.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{dh:s}=this,i=ht.groupArray(t,"type"),o=this.chartUtils.makeSeriesDataFromSeries(e,i,ht.getSeriesVisibility(e.name,this.settings),n,this.theme);if(this.seriesDataMap.set(e.name,o),this.data=[...this.seriesDataMap.values()],e.plotStyle===s.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===s.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=ht.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===s.plot.SeriesPlotStyle.PIE?n??void 0:!1,e.oneClick!=null){const{oneClick:l}=e,{columns:a}=l;for(let d=0;d<a.length;d+=1)this.filterColumnMap.set(a[d].name,a[d]);this.oneClicks.push(l)}this.updateLayoutFormats()}addPendingSeries=We(()=>{const e=ht.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){Tt.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?this.dh.plot.DownsampleOptions.DISABLE:this.dh.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){const{dh:e}=this;this.figure.addEventListener(e.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(e.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(e.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(e.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(e.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){const{dh:e}=this;this.figure.removeEventListener(e.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(e.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(e.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(e.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(e.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}getTimeZone=we((e,t)=>{if(t!=null){const n=t.getColumnTypeFormatter(e);if(n!=null)return n.dhTimeZone}});getValueTranslator=we((e,t)=>{const n=this.getTimeZone(e,t);return s=>this.chartUtils.unwrapValue(s,n)});getValueParser=we((e,t)=>{const n=this.getTimeZone(e,t);return s=>this.chartUtils.wrapValue(s,e,n)});getRangeParser=we((e,t)=>n=>{let[s,i]=n;const o=this.getValueParser(e,t);return s=o(s),i=o(i),[s,i]});getAxisRangeParser=we((e,t)=>n=>{const s=ht.getSourceForAxis(e,n);return s!=null?this.getRangeParser(s.columnType,t):i=>i});handleDownsampleStart(e){Tt.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){Tt.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){Tt.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){Tt.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:n}=t;Tt.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];Tt.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){Tt.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){Tt.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){Tt.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;Tt.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=ht.DEFAULT_MARGIN.t+t*ht.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=ht.DEFAULT_TITLE_PADDING.t+t*ht.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();this.chartUtils.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;this.chartUtils.getAxisFormats(this.figure,this.formatter).forEach((t,n)=>{Tt.debug(`Assigning ${n}`,this.layout[n],t);const s=this.layout[n];s!=null?Object.assign(s,t):Tt.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(e,t,n){const{name:s,plotStyle:i}=e,o=this.seriesDataMap.get(s),l=this.chartUtils.getPlotlyProperty(i,t);o&&_c(o,l,n)}cleanSeries(e){const{dh:t}=this,{name:n,plotStyle:s}=e,i=this.seriesDataMap.get(n);if(i!=null){if(s===t.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:o,xHigh:l}=i;if(o&&l&&o.length===l.length){const a=[];for(let d=0;d<o.length;d+=1)a.push(l[d]-o[d]);i.width=a}}else if(s===t.plot.SeriesPlotStyle.LINE){const{x:o,xLow:l,xHigh:a,y:d,yLow:h,yHigh:u}=i;l&&a&&l!==o&&(i.error_x=ht.getPlotlyErrorBars(o,l,a)),h&&u&&h!==d&&(i.error_y=ht.getPlotlyErrorBars(d,h,u))}else if(s===t.plot.SeriesPlotStyle.TREEMAP){const{ids:o,labels:l}=i;o!==void 0&&l===void 0&&(i.labels=o)}}}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){Tt.warn("Trying to set a filter, but no one click!");return}Tt.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 Ld=Cr;class Sr{static async makeModelFromSettings(e,t,n,s=kt){const i=await Sr.makeFigureFromSettings(e,t,n);return new Ld(e,i,t,s)}static async makeFigureFromSettings(e,t,n){const s=await n.copy();return s.applyCustomColumns(n.customColumns),s.applyFilter(n.filter),s.applySort(n.sort),e.plot.Figure.create(new ht(e).makeFigureSettings(t,s))}static async makeModel(e,t,n,s=kt){return new Ld(e,n,t,s)}}const gl=Sr,oC=sh(hr);function _d(c){return c.setFigure!==void 0}const lC=J.module("HeapUsage");function aC({connection:c,defaultUpdateInterval:e,hoverUpdateInterval:t,bgMonitoring:n=!0,monitorDuration:s}){const[i,o]=v.useState({freeMemory:0,maximumHeapSize:999,totalHeapSize:0}),[l,a]=v.useState(!1),d=v.useRef({timestamps:[],usages:[]});v.useEffect(function(){const k=async()=>{try{const M=await c.getWorkerHeapInfo();if(o(M),n||l){const $=(M.totalHeapSize-M.freeMemory)/M.maximumHeapSize,H=Date.now(),{timestamps:K,usages:L}=d.current;for(;K.length!==0&&H-K[0]>s*1.5;)K.shift(),L.shift();K.push(H),L.push($)}else d.current={timestamps:[],usages:[]}}catch(M){lC.warn("Unable to get heap usage",M)}};k();const _=setInterval(k,l?t:e);return()=>{clearInterval(_)}},[l,t,c,e,s,n]);const h=(O,k)=>Math.round(O*10**k)/10**k,u=2,m=1024**3,{freeMemory:g,totalHeapSize:p,maximumHeapSize:f}=i,C=h(g/m,u),S=h(p/m,u),b=h(f/m,u),w=S-C,T=(O,k,_=!1)=>r.jsxs("div",{className:z("heap-usage-info-row",{"heading-bottom-border":_}),children:[r.jsx("div",{className:"font-weight-bold",children:O}),r.jsx("div",{children:k})]}),{timestamps:E,usages:y}=d.current,R=E[E.length-1]??0,I=p/f,x=(p-g)/f;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"max-memory",children:[r.jsx("div",{className:"total-memory",style:{width:`calc(${I*100}% - ${I*2}px`}}),r.jsx("div",{className:z("used-memory",{"heap-overflow":(p-g)/f>.95}),style:{width:`calc(${x*100}% - ${x*2}px`}}),r.jsxs("div",{className:"memory-text",children:[b.toFixed(1)," GB"]})]}),r.jsx(Je,{onEntered:()=>a(!0),onExited:()=>a(!1),interactive:!0,children:r.jsxs("div",{className:"heap-tooltip",children:[T("In use:",`${w.toFixed(u)} of ${b.toFixed(u)} GB`,!0),T("Free:",`${C.toFixed(u)} GB`),T("Total:",`${S.toFixed(u)} GB`),T("Max:",`${b.toFixed(u)} GB`),r.jsx("div",{className:"heap-plot",children:r.jsx(oC,{data:[{x:[...E],y:[...y],type:"scatter",mode:"lines"}],config:{staticPlot:!0,responsive:!0},style:{width:"196px",height:"100px"},layout:{margin:{l:2,t:2,r:2,b:2},plot_bgcolor:"transparent",paper_bgcolor:"transparent",colorway:["#4878ea"],xaxis:{dtick:Math.round(s/6),gridcolor:kt.linecolor,range:[R-s,R],linecolor:kt.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:kt.linecolor,range:[0,1],linecolor:kt.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({}),rC=new Map,zl=c=>c.api,fh=c=>c.user,wr=c=>c.storage,Ch=c=>wr(c).commandHistoryStorage,Sh=c=>wr(c).fileStorage,dC=c=>wr(c).workspaceStorage,Kl=c=>c.workspace,gt=c=>Kl(c).data.settings,bh=c=>gt(c).defaultDateTimeFormat,wh=c=>gt(c).defaultDecimalFormatOptions??br,vh=c=>gt(c).defaultIntegerFormatOptions??br,Th=c=>gt(c).formatter,go=c=>gt(c).timeZone,Eh=c=>gt(c).showTimeZone,yh=c=>gt(c).showTSeparator,Rh=c=>gt(c).truncateNumbersWithPound,cC=c=>gt(c).shortcutOverrides,hC=c=>gt(c).defaultNotebookSettings??br,Yl=c=>c.activeTool,uC=c=>c.plugins??rC,xh="SET_ACTIVE_TOOL",Ih="SET_API",Dh="SET_COMMAND_HISTORY_STORAGE",Fh="SET_FILE_STORAGE",Nh="SET_PLUGINS",kh="SET_USER",Mh="SET_WORKSPACE",Ah="SET_WORKSPACE_STORAGE",Oh="SET_SERVER_CONFIG_VALUES",mC=c=>({type:kh,payload:c}),gC=c=>({type:Ih,payload:c}),Lh=c=>({type:Mh,payload:c}),pC=c=>({type:Ah,payload:c}),fC=c=>({type:Dh,payload:c}),CC=c=>({type:Fh,payload:c}),SC=c=>(e,t)=>{e(Lh(c));const{storage:n}=t(),{workspaceStorage:s}=n;return s.save(c)},_h=c=>(e,t)=>{const{workspace:n}=t(),{data:s}=n,i={...n,data:{...s,...c}};return e(SC(i))},ql=c=>e=>e(_h({settings:c})),Xl=c=>({type:xh,payload:c}),bC=c=>({type:Nh,payload:c}),wC=c=>({type:Oh,payload:c});function Ph(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 vC(c,e={},t=!0){return(n=e,s)=>{switch(s.type){case c:{const{id:i,payload:o}=s;return t&&Ze({payload:o},{payload:n[i]})?n:{...n,[i]:o}}default:return n}}}function Es(c,e){return(t=e,n)=>{switch(n.type){case c:return n.payload;default:return t}}}const TC=Es(Ih,null),EC=Es(xh,null),yC=Es(Nh,null),RC=Es(Dh,null),xC=Es(Fh,null),IC=Es(Ah,null),DC=Ja({commandHistoryStorage:RC,fileStorage:xC,workspaceStorage:IC}),FC=Ph(kh,null),NC=Ph(Mh,null),kC=Es(Oh,null),MC={activeTool:EC,api:TC,plugins:yC,storage:DC,user:FC,workspace:NC,serverConfigValues:kC},AC=MC;class OC{reducers={};listener=null;register(e,t){this.reducers={...this.reducers,[e]:t},this.listener?.(this.reducers)}setListener(e){this.listener=e}}const LC=new OC,po=LC,Pd=J.module("redux-logger"),_C=c=>e=>t=>{Pd.debug("dispatching",t);const n=e(t);return Pd.debug("next state",c.getState()),n},PC=_C,jC=J.module("redux-crashReporter"),HC=c=>e=>t=>{try{return e(t)}catch(n){throw jC.error("Error executing",t," with state ",c.getState(),":",n),n}},UC=HC,BC=[PC,UC,Xu];Object.entries(AC).map(([c,e])=>po.register(c,e));const VC=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__??Ju,jh=Zu(Ja(po.reducers),VC(Qu(...BC)));po.setListener(c=>{jh.replaceReducer(Ja(c))});const vr=jh,Hh=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 Uh(c){return c.componentName!==void 0}function $C(c){return c.component!==void 0}const Bh=Object.freeze({type:"default",isClosable:!0,isFocusOnShow:!0,reorderEnabled:!0,title:""}),WC=Object.freeze(Object.defineProperty({__proto__:null,defaultConfig:Hh,isGLComponentConfig:Uh,isReactComponentConfig:$C,itemDefaultConfig:Bh},Symbol.toStringTag,{value:"Module"}));class pl{static ALL_EVENT="__all";_mSubscriptions;constructor(){this._mSubscriptions={},this._mSubscriptions[pl.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[pl.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=pl;class Ba extends pn{width;height;title;parent;layoutManager;tab;_config;isHidden=!1;beforeCloseHandler;_element=le(['<div class="lm_item_container">','<div class="lm_content" tabindex="-1"></div>',"</div>"].join(""));_contentElement;constructor(e,t,n){super(),this.title=Uh(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(le.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 GC=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 $h(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 zC(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 KC(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 le.trim(c.replace(/(<([^>]+)>)/gi,""))}class YC 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=le(document),this._eBody=le(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=YC;class Wh{_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=le.extend(e,this._container._config.props);return oe.createElement(this._reactClass,t)}}const fl=["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"],qC=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"];function yr(c){if(fl.length>36)throw new Error("Too many keys in config minifier map");const e={};return Rr(c,e,"_min"),e}function Va(c){if(fl.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"?XC: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,fl);e[l]=o}Rr(i,o,t)}else{const o=n(i,qC);if(Array.isArray(e))e[Number.parseInt(s,10)]=o;else{const l=n(s,fl);e[l]=o}}}}function XC(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 $a{name;origin;isPropagationStopped;constructor(e,t){this.name=e,this.origin=t,this.isPropagationStopped=!1}stopPropagation(){this.isPropagationStopped=!0}}let QC=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),le(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(){le(window).off("gl_child_event",this._boundOnEventFromChild)}};const Gh=QC,JC=Object.freeze(Object.defineProperty({__proto__:null,BubblingEvent:$a,DragListener:fo,EventEmitter:pn,EventHub:Gh,ReactComponentHandler:Wh,animFrame:Zl,filterXss:KC,getHashValue:Vh,getQueryStringParam:$h,getUniqueId:Tr,minifyConfig:yr,removeFromArray:zC,stripTags:Er,unminifyConfig:Va},Symbol.toStringTag,{value:"Module"}));class zh 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=le.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;le(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=le(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(),le(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 Kh{_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(le.extend(!0,{},n)),i=new Di(e,t,this._dragListener,this._layoutManager,s,null);this._layoutManager.transitionIndicator?.transitionElements(this._element,i.element)}}class Yh{_element=le(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(le.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=le(Ql._template);constructor(){le(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=le('<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 eS extends Error{node;constructor(e,t){super(),this.name="Configuration Error",this.message=e,this.node=t}}const zs=eS,tS=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationError:zs},Symbol.toStringTag,{value:"Module"}));function oo(c){return c.isStack}function jt(c){return c.isComponent}function qh(c){return c.isRoot}class ut 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&&jt(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 $a(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(Bh)){const s=t;e[s]===void 0&&(e[s]=n)}return e}_propagateEvent(e,t){t instanceof $a&&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 Xh extends ut{config;componentName;container;parent;instance;constructor(e,t,n){super(e,t,n,le()),this.config=t,this.parent=n;const s=e.getComponent(this.config.componentName)||e.getFallbackComponent(),i=le.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(){ut.prototype._$init.call(this),this.container.emit("open")}_$hide(){this.container.hide(),ut.prototype._$hide.call(this)}_$show(){this.container.show(),this.container._config.isFocusOnShow&&this.container._contentElement[0].focus({preventScroll:!0}),ut.prototype._$show.call(this)}_$destroy(){this.container.emit("destroy",this),ut.prototype._$destroy.call(this)}_$getArea(){return null}}class Cl extends ut{isRow;isColumn;childElementContainer;parent;_splitter=[];_splitterSize;_splitterGrabSize;_isColumn;_dimension;_splitterPosition=null;_splitterMinPosition=null;_splitterMaxPosition=null;constructor(e,t,n,s){super(t,n,s,le('<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),ut.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));ut.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(ut.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 Zh(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 Wa extends ut{childElementContainer;_containerElement;constructor(e,t,n){super(e,{...t,type:"root"},null,le('<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(jt(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 Cl)||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 Ga extends ut{_activeContentItem=null;_header;childElementContainer=le('<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,le('<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(){ut.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(jt(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 nS=Object.freeze(Object.defineProperty({__proto__:null,AbstractContentItem:ut,Component:Xh,ContentItem:ut,Root:Wa,RowOrColumn:Cl,Stack:Ga,isComponent:jt,isRoot:qh,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=le(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),jt(this.contentItem)&&(this.contentItem.container._contentElement.on("focusin",this._onTabContentFocusIn).on("focusout",this._onTabContentFocusOut),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),jt(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(){le(".lm_focusin",this._layoutManager.root.element).removeClass("lm_focusin"),this.element.addClass("lm_focusin")}_onTabContentFocusOut(){jt(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&&jt(this.contentItem)?this.header.parent.setActiveContentItem(this.contentItem):jt(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.contentItem.container._contentElement.focus(),jt(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(),jt(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=le(vi._template);tabsContainer;tabDropdownContainer;tabDropdownSearch;tabDropdownList=null;controlsContainer;parent;tabs=[];activeContentItem=null;closeButton=null;tabDropdownButton=null;tabNextButton=le(vi._nextButtonTemplate);tabPreviousButton=le(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(),le(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"),le(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(),le(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)-(le(window).scrollTop()??0);t+e>(le(window).height()??0)&&this.tabDropdownContainer.css("max-height",(le(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 Zh{_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=le('<div class="lm_drag_handle"></div>'),t=le('<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 Qh{_element=le('<div class="lm_transition_indicator"></div>');_toElement=null;_fromDimensions={};_totalAnimationDuration=200;_animationStartTime=null;constructor(){le(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 sS=Object.freeze(Object.defineProperty({__proto__:null,BrowserPopout:zh,DragProxy:Di,DragSource:Kh,DragSourceFromEvent:Yh,DropTargetIndicator:Ql,Header:vi,HeaderButton:Yi,Splitter:Zh,Tab:Jl,TransitionIndicator:Qh},Symbol.toStringTag,{value:"Module"})),iS={config:WC,container:GC,controls:sS,errors:tS,items:nS,utils:JC},oS=iS;class Jh extends pn{static __lm=oS;static minifyConfig(e){return yr(e)}static unminifyConfig(e){return Va(e)}isInitialised=!1;_isFullPage=!1;_resizeTimeoutId;_components={"lm-react-component":Wh};_fallbackComponent;_itemAreas=[];_maximisedItem=null;_maximisePlaceholder=le('<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 Gh(this);config;container;_originalContainer;dropTargetIndicator=null;transitionIndicator=null;tabDropPlaceholder=le('<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&&le("body").css("visibility","hidden"),this._typeToItem={column:Cl.bind(this,!0),row:Cl.bind(this,!1),stack:Ga,component:Xh}}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 ut))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){le(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 Qh,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(),le(window).off("resize",this._onResize),le(window).off("unload beforeunload",this._onUnload),le(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 Ga)&&t&&!(this.isSubWindow===!0&&t instanceof Wa)&&(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 ut,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 zh(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 Kh(e,t,this);return this._dragSources.push(n),n}createDragSourceFromEvent(e,t){return this.config.settings.constrainDragToContainer=!1,new Yh(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 ut)return e;if(le.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&&le(window).resize(this._onResize),le(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=$h("gl-window");t&&(this.isSubWindow=!0,e=JSON.parse(localStorage.getItem(t)||"{}"),e=Va(e),localStorage.removeItem(t)),e=le.extend(!0,{},Hh,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=le('<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??""),le("head").append(le("body link, body style, template, .gl_keep")),this.container=le("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?le(this._originalContainer):le("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,le("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 Wa(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 lS="_lm_root_15d73_3",aS="_lm_row_15d73_7",rS="_lm_item_15d73_7",dS="_lm_content_15d73_11",cS="_lm_dragging_15d73_17",hS="_lm_maximised_15d73_23",uS="_lm_maximise_placeholder_15d73_30",mS="_lm_splitter_15d73_34",gS="_lm_vertical_15d73_41",pS="_lm_drag_handle_15d73_41",fS="_lm_horizontal_15d73_46",CS="_lm_header_15d73_56",SS="_lm_dropdown_open_15d73_63",bS="_lm_controls_15d73_69",wS="_lm_tabs_15d73_89",vS="_lm_tab_15d73_89",TS="_lm_title_15d73_104",ES="_lm_close_tab_15d73_111",yS="_lm_stack_15d73_120",RS="_lm_left_15d73_120",xS="_lm_right_15d73_121",IS="_lm_dragProxy_15d73_125",DS="_lm_items_15d73_148",FS="_lm_tabdropdown_list_15d73_165",NS="_lm_bottom_15d73_192",kS="_lm_drop_tab_placeholder_15d73_207",MS="_lm_tabdropdown_15d73_165",AS="_lm_dropTargetIndicator_15d73_258",OS="_lm_inner_15d73_264",LS="_lm_transition_indicator_15d73_272",_S="_lm_popin_15d73_282",PS="_lm_bg_15d73_297",jS="_lm_icon_15d73_300",HS="_lm_goldenlayout_15d73_304",US="_lm_selectable_15d73_340",BS="_lm_active_15d73_370",VS="_lm_selected_15d73_388",$S="_lm_keyboard_active_15d73_397",WS="_lm_popout_15d73_416",GS="_lm_maximise_15d73_23",zS="_lm_close_15d73_111",KS="_lm_tabnextbutton_15d73_425",YS="_lm_tabpreviousbutton_15d73_428",qS="_lm_title_before_15d73_544",XS="_lm_focusin_15d73_568",ZS="_lm_window_blur_15d73_573",QS="_lm_tabdropdown_search_15d73_631",JS="_march_15d73_1",eb="_app_15d73_712",tb="_plotly_15d73_721",jd={"tab-height":"28px","drag-border-width":"5px",lm_root:lS,lm_row:aS,lm_item:rS,lm_content:dS,lm_dragging:cS,lm_maximised:hS,lm_maximise_placeholder:uS,lm_splitter:mS,lm_vertical:gS,lm_drag_handle:pS,lm_horizontal:fS,lm_header:CS,lm_dropdown_open:SS,lm_controls:bS,lm_tabs:wS,lm_tab:vS,lm_title:TS,lm_close_tab:ES,lm_stack:yS,lm_left:RS,lm_right:xS,lm_dragProxy:IS,lm_items:DS,lm_tabdropdown_list:FS,lm_bottom:NS,lm_drop_tab_placeholder:kS,lm_tabdropdown:MS,lm_dropTargetIndicator:AS,lm_inner:OS,lm_transition_indicator:LS,lm_popin:_S,lm_bg:PS,lm_icon:jS,lm_goldenlayout:HS,lm_selectable:US,lm_active:BS,lm_selected:VS,lm_keyboard_active:$S,lm_popout:WS,lm_maximise:GS,lm_close:zS,lm_tabnextbutton:KS,lm_tabpreviousbutton:YS,lm_title_before:qS,"editor-unsaved-indicator":"_editor-unsaved-indicator_15d73_548","is-unsaved":"_is-unsaved_15d73_556",lm_focusin:XS,lm_window_blur:ZS,lm_tabdropdown_search:QS,march:JS,app:eb,"js-plotly-plot":"_js-plotly-plot_15d73_721",plotly:tb},Hd=Object.freeze({tabHeight:parseInt(jd["tab-height"],10),dragBorderWidth:parseInt(jd["drag-border-width"],10)}),ss=J.module("LayoutUtils");function eu(c){return c.componentName!==void 0}function mi(c){const e=c;return(eu(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 V{static DEFAULT_FOCUS_SELECTOR="input, select, textarea, button";static activateTab(e,t){const n=V.getStackForRoot(e,t,!1);if(!n){ss.error("Could not find stack for config",t);return}const s=V.getContentItemInStack(n,t);s&&n.setActiveContentItem(s)}static isActiveTab(e,t){const n=V.getStackForRoot(e,t,!1);if(!n)return ss.error("Could not find stack for config",t),!1;const s=V.getContentItemInStack(n,t);return n.getActiveContentItem()===s}static addStack(e,t=!0){const n=t?"column":"row";if(qh(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=V.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):ss.debug2(`dehydrateLayoutConfig: skipping unmapped component "${o}"`)}else if(l){const a={...i,content:V.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,V.dropLayoutMinorChange(s)):mi(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=V.cloneLayout(e),i=V.cloneLayout(t);return V.dropLayoutMinorChange(s),V.dropLayoutMinorChange(i),Ze(s,i)}return Ze(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(mi(i)){const{component:o,props:l={}}=i;n.push({...i,id:i?.id??Ge(),props:t(o,l)})}else if(i.content!==void 0){const o=V.hydrateLayoutConfig(i.content,t);Ud(i)&&i.activeItemIndex!=null&&i.activeItemIndex>=o.length&&(ss.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=Ge.generate()),l){e?.layoutManager.createDragSourceFromEvent(d,l);return}const h=s||{id:d.id,component:d.component};D(e);const u=i?V.addStack(e):V.getStackForRoot(e,h);D(u);const m=V.getContentItemInStack(u,h);if(o!=null){const g=p=>{ss.debug("Component created, focusing element",o),u.off("componentCreated",g);const{element:f}=p.origin;requestAnimationFrame(()=>{V.focusElement(f[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=V.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=V.getStackForRoot(e,t,!1,!1,!1);if(!s){ss.warn("Cannot find stack for component, ignoring close",t);return}const i=V.getContentItemInStack(s,t),o=document.activeElement;i&&(jt(i)?i.container.close(n):s.removeChild(i)),o&&document.contains(o)&&Po(o)&&o.focus()}static renameComponent(e,t,n){const s=V.getStackForRoot(e,t,!1);if(!s){ss.error("Could not find stack for config",t);return}const i=V.getContentItemInStack(s,t);i&&i.setTitle(n)}static cloneComponent(e,t){const n=V.getStackForRoot(e,t,!1);if(!n)return ss.error("Could not find stack for config",t),null;const{props:s={}}=t,i=V.getPanelComponentState(t),o={type:"react-component",component:t.component,props:{...s,panelState:i},title:`${t.title} Copy`,id:Ge.generate()};return V.openComponentInStack(n,o),o}static getPanelComponentState(e){return eu(e)?e.componentState?.panelState:mi(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=V.getComponentConfigFromContainer(e);return t?t.id:null}static getIdFromPanel(e){const{glContainer:t}=e.props;return V.getIdFromContainer(t)}static getComponentNameFromPanel(e){const{glContainer:t}=e.props,n=V.getComponentConfigFromContainer(t);return n&&mi(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=V.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 tu=oe.forwardRef((c,e)=>{const t=V.getComponentNameFromPanel({props:c});return r.jsxs("div",{ref:e,className:"panel-placeholder",children:['Component "',t,'" is not registered.']})});tu.displayName="PanelPlaceholder";const Se=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 Bd(c){return c?.WrappedComponent!==void 0}function nb(c){return typeof c.id=="string"&&c.layout instanceof Jh&&c.panelManager instanceof nu&&typeof c.registerComponent=="function"}function ys(c){if(!nb(c))throw new Error(`Expected dashboard plugin props, but instead received ${c}`)}const qt=J.module("PanelManager");class nu{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(Se.FOCUS,this.handleFocus),e.on(Se.MOUNT,this.handleMount),e.on(Se.UNMOUNT,this.handleUnmount),e.on(Se.REOPEN,this.handleReopen),e.on(Se.DELETE,this.handleDeleted),e.on(Se.CLOSED,this.handleClosed),e.on(Se.CLOSE,this.handleControlClose)}stopListening(){const{eventHub:e}=this.layout;e.off(Se.FOCUS,this.handleFocus),e.off(Se.MOUNT,this.handleMount),e.off(Se.UNMOUNT,this.handleUnmount),e.off(Se.REOPEN,this.handleReopen),e.off(Se.DELETE,this.handleDeleted),e.off(Se.CLOSED,this.handleClosed),e.off(Se.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 V.getComponentConfigFromContainer(t)})}getOpenedPanelConfigsOfType(e){return this.getOpenedPanelConfigs().filter(t=>t!=null&&mi(t)&&t.component===e)}getOpenedPanelById(e){return this.openedMap.get(e)}getContainerByPanelId(e){const t=V.getStackForConfig(this.layout.root,{id:e});return(t&&V.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=>Bd(n)&&t instanceof n.WrappedComponent||!Bd(n)&&t instanceof n))}updatePanel(e){const t=V.getIdFromPanel(e);if(t==null){qt.error("updatePanel Panel did not have an ID",e);return}qt.debug2(`Updating panel ID ${t} in open panels map`),this.openedMap.delete(t),this.openedMap.set(t,e)}removePanel(e){const t=V.getIdFromPanel(e);if(t==null){qt.error("removePanel Panel did not have an ID",e);return}if(!this.openedMap.has(t)){qt.error(`Missing panel ID ${t} in open panels map`);return}if(this.openedMap.get(t)!==e){qt.debug(`Panel argument doesn't match the open panels map entry for ${t}, removePanel ignored`);return}qt.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){qt.debug2("Focus: ",e),this.updatePanel(e)}handleMount(e){qt.debug2("Mount: ",e),this.updatePanel(e),this.sendUpdate()}handleUnmount(e){qt.debug2("Unmount: ",e),this.removePanel(e),this.sendUpdate()}handleReopen(e,t){qt.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;V.openComponent({root:o,config:i,replaceConfig:t})}handleDeleted(e){qt.debug2("Deleted:",e),this.removeClosedPanelConfig(e),this.sendUpdate()}handleClosed(e,t){qt.debug2("Closed: ",e),this.addClosedPanel(t),this.sendUpdate()}handleControlClose(e){const t={id:e},{root:n}=this.layout;V.closeComponent(n,t)}addClosedPanel(e){const t=V.getComponentConfigFromContainer(e);if(t&&mi(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 sb=J.module("PanelErrorBoundary");class ib extends v.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}componentWillUnmount(){const{glContainer:e,glEventHub:t}=this.props,n=V.getIdFromContainer(e);sb.debug("componentWillUnmount",n),t.emit(Se.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(Ul,{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 za={dehydrate:xr,hydrate:Ir},ob=U.shape({on:U.func,off:U.func,isHidden:U.bool,tab:U.shape({header:U.shape({tabs:U.arrayOf(U.shape({contentItem:U.shape({})}))})}),title:U.string,setTitle:U.func,close:U.func}),su=U.shape({on:U.func,off:U.func,emit:U.func}),lb=U.shape({registerComponent:U.func,root:U.shape({addChild:U.func}),on:U.func,off:U.func,eventHub:su}),Dr=Object.freeze({Container:ob,EventHub:su,Layout:lb}),_e=(c,e,t)=>v.useEffect(function(){return c.on(e,t),()=>{c.off(e,t)}},[c,e,t]),iu="SET_DASHBOARD_DATA",ab=vC(iu,{},!1),rb={dashboardData:ab},db=new Map,cb=Object.freeze({}),hb=Object.freeze([]),ub=c=>c.dashboardData,Ot=(c,e)=>ub(c)[e]??cb,mb=(c,e)=>Ot(c,e).closed??hb,ou=(c,e)=>Ot(c,e).openedMap??db,lu=(c,e)=>({type:iu,id:c,payload:e}),kn=(c,e)=>(t,n)=>t(lu(c,{...Ot(n(),c),...e}));Object.entries(rb).map(([c,e])=>po.register(c,e));const jo=J.module("DashboardLayout"),gb=Object.freeze({}),pb=[],Vd=()=>{},$d=c=>c;function au({id:c,children:e,emptyDashboard:t=r.jsx("div",{children:"Dashboard is empty."}),layout:n,layoutConfig:s=pb,onLayoutChange:i=Vd,onLayoutInitialized:o=Vd,hydrate:l=Ir,dehydrate:a=xr}){const d=vs(),h=er(),u=em(L=>Ot(L,c))??gb,[m,g]=v.useState(!1),[p,f]=v.useState(!1),[C,S]=v.useState(),[b]=v.useState(u?.closed??[]),[w,T]=v.useState(!1),E=v.useMemo(()=>new Map,[]),y=v.useMemo(()=>new Map,[]),R=tm(),I=v.useCallback((L,G,ee=l,W=a)=>{jo.debug2("registerComponent",L,G,ee,W);function j(se,ae){const q=G,{dh:ne,glContainer:he,glEventHub:Te}=se;return r.jsx(ig.Provider,{value:ne??d,children:r.jsx(Pc,{store:R,children:r.jsx(ib,{glContainer:he,glEventHub:Te,children:r.jsx(q,{...se,ref:ae})})})})}const B=oe.forwardRef(j),Z=n.registerComponent(L,B);return E.set(L,ee),y.set(L,W),Z},[d,l,a,E,y,n,R]),x=v.useCallback((L,G)=>(E.get(L)??$d)(G,c),[E,c]),O=v.useCallback((L,G)=>(y.get(L)??$d)(G,c),[y,c]),k=v.useMemo(()=>new nu(n,x,O,new Map,b,({closed:L,openedMap:G})=>{h(kn(c,{closed:L,openedMap:G}))}),[O,h,x,c,b,n]),_=v.useCallback(()=>{if(p)return;w||(o(),T(!0));const G=n.toConfig().content,ee=V.dehydrateLayoutConfig(G,O),W=C==null||!V.isEqual(C,ee);jo.debug("handleLayoutStateChanged",W,G,ee),W&&(g(n.root.contentItems.length===0),S(ee),i(ee))},[O,w,p,C,n,i,o]),M=v.useCallback(L=>{const G=V.getIdFromContainer(L);n.eventHub.emit(Se.DRAGGING,G),f(!0)},[n.eventHub]),$=v.useCallback(L=>{const G=V.getIdFromContainer(L);n.eventHub.emit(Se.DROPPED,G),f(!1)},[n.eventHub]),H=v.useCallback(L=>{if(jo.debug2("handleComponentCreated",L),L==null||L.config==null||L.config.component==null||L.element==null)return;const ee=`${L.config.component.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}-component`;L.element.addClass(ee)},[]);_e(n,"stateChanged",_),_e(n,"itemPickedUp",M),_e(n,"itemDropped",$),_e(n,"componentCreated",H),_e(n.eventHub,Se.TITLE_CHANGED,_);const K=nr(s);return v.useEffect(function(){if(K!==s&&s!==C){jo.debug("Setting new layout content...");const G=V.hydrateLayoutConfig(s,x);for(;n.root.contentItems.length>0;)n.root.contentItems[0].remove();for(let ee=0;ee<G.length;ee+=1)n.root.addChild(G[ee]);g(n.root.contentItems.length===0)}},[x,n,s,C,k,K]),r.jsxs(r.Fragment,{children:[m&&t,oe.Children.map(e,L=>L!=null?oe.cloneElement(L,{id:c,layout:n,panelManager:k,registerComponent:I}):null)]})}au.propTypes={id:U.string.isRequired,children:U.node,data:U.shape({}),emptyDashboard:U.node,layout:Dr.Layout.isRequired,layoutConfig:U.arrayOf(U.shape({})),onLayoutChange:U.func,onLayoutInitialized:U.func};const fb=100,Ca=()=>{},Cb=Object.freeze({});function Sb({id:c="default",children:e,emptyDashboard:t,layoutConfig:n,layoutSettings:s=Cb,onLayoutConfigChange:i=Ca,onGoldenLayoutChange:o=Ca,onLayoutInitialized:l=Ca,fallbackComponent:a=tu,hydrate:d,dehydrate:h}){const u=v.useRef(null),[m,g]=v.useState(!1),[p,f]=v.useState();v.useEffect(function(){if(!u.current){f(void 0);return}const b={...V.makeDefaultLayout()};b.settings===void 0&&(b.settings={}),Object.assign(b.settings,s),b.content=[];const w=new Jh(b,u.current),T=()=>{w.off("initialised",T),g(!0)};return w.on("initialised",T),a!=null&&w.setFallbackComponent(a),w.init(),f(w),o(w),()=>{w.destroy()}},[s,a,o,g,f]);const C=v.useMemo(()=>bs(()=>{p!=null&&p.isInitialised&&p?.updateSize()},fb),[p]);return v.useEffect(function(){return window.addEventListener("resize",C),()=>{window.removeEventListener("resize",C)}},[C]),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(au,{emptyDashboard:t,id:c,layout:p,layoutConfig:n,onLayoutChange:i,onLayoutInitialized:l,hydrate:d,dehydrate:h,children:e})]})}const un="default";class bb extends Error{isAssertionFailed=!0}const ru=bb;function Wd(c){if(c==null)throw new ru(`Expected 'val' to be defined, but received ${c}`)}class wb extends Error{isPasteError=!0}const Sa=wb;function ze(c){return c?.isEditable!==void 0}function Gd(c){if(!ze(c))throw new ru(`Expected 'model' to be editable, but received ${c}`)}function Pe(c){return c?.hasExpandableRows!==void 0}var mn=(c=>(c.DOWN="DOWN",c.UP="UP",c.LEFT="LEFT",c.RIGHT="RIGHT",c))(mn||{});class Q{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 Q(...Q.normalize(e,t,n,s))}static makeCell(e,t){return new Q(e,t,e,t)}static makeColumn(e){return new Q(e,null,e,null)}static makeRow(e){return new Q(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=Q.minOrNull(i.startColumn,l.startColumn),u=Q.maxOrNull(i.endColumn,l.endColumn);n=!0,t[s]=new Q(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=Q.minOrNull(i.startRow,l.startRow),u=Q.maxOrNull(i.endRow,l.endRow);n=!0,t[s]=new Q(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 Q(n,s,i,o)}static subtractFromRange(e,t){const n=[],s=Q.intersection(e,t);return s==null?[e]:(s.startRow!=null&&(e.startRow==null||e.startRow<s.startRow)&&n.push(new Q(e.startColumn,e.startRow,e.endColumn,s.startRow-1)),s.startColumn!=null&&(e.startColumn==null||e.startColumn<s.startColumn)&&n.push(new Q(e.startColumn,s.startRow,s.startColumn-1,s.endRow)),s.endColumn!=null&&(e.endColumn==null||e.endColumn>s.endColumn)&&n.push(new Q(s.endColumn+1,s.startRow,e.endColumn,s.endRow)),s.endRow!=null&&(e.endRow==null||e.endRow>s.endRow)&&n.push(new Q(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(...Q.subtractFromRange(e[s],t));return n}static subtractRangesFromRanges(e,t){let n=[...e];for(let s=0;s<t.length;s+=1)n=Q.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 Q.isBounded(e)?e:new Q(e.startColumn??0,e.startRow??0,e.endColumn??t-1,e.endRow??n-1)}static boundedRanges(e,t,n){return e.map(s=>Q.boundedRange(s,t,n))}static offset(e,t,n){return new Q(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=Q.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 Q.SELECTION_DIRECTION.DOWN:case Q.SELECTION_DIRECTION.RIGHT:{const o=i<e.length-1?i+1:0;return e[o].startCell(s)}case Q.SELECTION_DIRECTION.LEFT:case Q.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=Q.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 Q.isAxisRangeTouching(this.startRow,this.endRow,e.startRow,e.endRow)&&Q.isAxisRangeTouching(this.startColumn,this.endColumn,e.startColumn,e.endColumn)}subtract(e){return Q.subtractFromRange(this,e)}startCell(e=Q.SELECTION_DIRECTION.DOWN){if(!Q.isBounded(this))throw new Error("Cannot get the startCell of an unbounded range");switch(e){case Q.SELECTION_DIRECTION.DOWN:case Q.SELECTION_DIRECTION.RIGHT:return{column:this.startColumn,row:this.startRow};case Q.SELECTION_DIRECTION.LEFT:case Q.SELECTION_DIRECTION.UP:return{column:this.endColumn,row:this.endRow};default:throw new Error(`Invalid direction: ${e}`)}}nextCell(e,t,n){if(!Q.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 Q.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 Q.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 Q.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 Q.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=Q.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 Re=Q;function vb(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 vb(c)&&c[0]!=null&&c[1]!=null}function Sl(c){return c?.href!==void 0}class A{static PIXELS_PER_LINE=100/3;static getGridPointFromXY(e,t,n){const s=A.getColumnAtX(e,n),i=A.getRowAtY(t,n),o=A.getColumnHeaderDepthAtY(t,n);return{x:e,y:t,row:i,column:s,columnHeaderDepth:o}}static getCellInfoFromXY(e,t,n){const{row:s,column:i}=A.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,f=s!==null?d.get(s):null,C=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:f??null,columnWidth:C??null,rowHeight:S??null}}static getColumnHeaderDepthAtY(e,t){const n=A.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=A.iterateFloatingStart(e,n,s);return i!==void 0?i:A.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=A.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:A.iterateFloating(n,s,t,h=>{if(A.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(A.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 A.getNextShownItem(e,n,s,i)}static getNextShownRow(e,t){const{modelRows:n,visibleRows:s,userRowHeights:i}=t;return A.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 f=e-i,C=p*.5;let S=!1;for(let b=l.length-1;b>=0;b-=1){const w=l[b],T=h.get(w)??0,E=u.get(w)??0,y=E===0;if(!S||!y){let R=T+E;y?R+=C:S&&(R-=C);const I=R-C,x=R+C;if(I<=f&&f<=x)return w;S=y}}S=!1;for(let b=d.length-1;b>=0;b-=1){const w=d[b],T=h.get(w)??0,E=u.get(w)??0,y=E===0;if(T<a-E)return null;if(!S||!y){let R=T+E;y?R+=C:S&&(R-=C);const I=R-C,x=R+C;if(I<=f&&f<=x)return w;S=y}}return null}static isItemHidden(e,t){return t.get(e)===0}static isColumnHidden(e,t){const{allColumnWidths:n}=t;return A.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(!A.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(!A.isItemHidden(l,t))break;s.push(l)}return s}static getHiddenColumns(e,t){const{visibleColumns:n,allColumnWidths:s}=t;return A.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 f=l.length-1;f>=0;f-=1){const C=l[f],S=a.get(C)??0,b=d.get(C)??0,w=b===0;if(!p||!w){let T=S+b;w?T+=g:p&&(T-=g);const E=T-g,y=T+g;if(E<=m&&m<=y)return C;p=w}}return null}static isRowHidden(e,t){const{allRowHeights:n}=t;return A.isItemHidden(e,n)}static getHiddenRows(e,t){const{visibleRows:n,allRowHeights:s}=t;return A.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 A.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)?A.moveRange(e,t,n,s):A.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,f=[];for(let C=0;C<i.length;C+=1){const S=i[C][0]??Number.NEGATIVE_INFINITY,b=i[C][1]??Number.POSITIVE_INFINITY;let w;const T=[[S,u-1],[u,m],[m+1,b]].map(([E,y])=>[Math.max(E,S),Math.min(y,b)]).filter(([E,y])=>E<=y).map(E=>{const[y,R]=E;return u<=y&&m>=R?(w=[y+p,R+p],w):m<y?[y-d,R-d]:E}).map(E=>{const[y,R]=E;return g>y&&g<=R?[[y,g-1],[g+d,R+d]]:E===w?[E]:g<=y?[[y+d,R+d]]:[E]}).flat();f.push(...T)}i=f.map(([C,S])=>[Number.isFinite(C)?C:null,Number.isFinite(S)?S:null])}return i}static translateRange(e,t,n,s){const i=A.applyItemMoves(e.startColumn,e.endColumn,t,s),o=A.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 Re(d[0],u[0],d[1],u[1]))}}return l}static getModelIndex(e,t){return A.applyItemMoves(e,e,t,!0)[0][0]}static getModelIndexes(e,t){return e.map(n=>A.getModelIndex(n,t))}static getModelRangeIndexes(e,t,n){return A.applyItemMoves(e,t,n,!0)}static getModelRange(e,t=Ie,n=Ie){return A.translateRange(e,t,n,!0)}static getModelRanges(e,t=Ie,n=Ie){const s=[];for(let i=0;i<e.length;i+=1)s.push(...A.getModelRange(e[i],t,n));return s}static getVisibleRangeIndexes(e,t,n){return A.applyItemMoves(e,t,n,!1)}static getVisibleRange(e,t=Ie,n=Ie){return this.translateRange(e,t,n,!1)}static getVisibleRanges(e,t=Ie,n=Ie){const s=[];for(let i=0;i<e.length;i+=1)s.push(...A.getVisibleRange(e[i],t,n));return s}static getVisibleIndex(e,t){return A.applyItemMoves(e,e,t)[0][0]}static getVisibleIndexes(e,t){return e.map(n=>A.getVisibleIndex(n,t))}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return A.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){const t=A.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:f,columnCount:C,rowCount:S}=e;let b=s,w=i,T=o,E=l;return n!=null&&(n>h&&(b+=m),n<C-u&&(T-=g)),t!=null&&(t>a&&(w+=p),t<S-d&&(E-=f)),{x1:b,y1:w,x2:T,y2:E}}static getScrollDelta(e,t=1024,n=768,s=20,i=20){let{deltaX:o,deltaY:l}=e;return!A.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&&(A.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),f=Ae(a+s,a,h-m),C=Ae(a+o,a,h-m);return{x1:g,y1:f,x2:p,y2:C,token:e.token}}static findTokensWithProtocolInText(e){return Lc(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+=N(s,l);o=n;for(let l=0;l<e&&t-l-1>=0;l+=1)o-=N(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:f,columnWidth:C,columnHeaderHeight:S,minScrollHandleSize:b,scrollBarSize:w}=a;h!==this.movedRows&&(this.movedRows=h,this.modelRows.clear()),u!==this.movedColumns&&(this.movedColumns=u,this.modelColumns.clear());const{columnCount:T,rowCount:E,floatingTopRowCount:y,floatingBottomRowCount:R,floatingLeftColumnCount:I,floatingRightColumnCount:x,columnHeaderMaxDepth:O}=d,k=this.getFirstRow(e),_=this.getFirstColumn(e),M=this.getGridX(e),$=this.getGridY(e),H=Pe(d)&&d.hasExpandableRows?this.calculateTreePaddingX(e):0,K=0,L=this.getVisibleRowHeights(e),G=this.getVisibleColumnWidths(e,_,H),ee=Array.from(L.keys()),W=Array.from(G.keys()),j=new Map([...L,...this.getFloatingRowHeights(e)]),B=new Map([...G,...this.getFloatingColumnWidths(e)]),Z=this.getVisibleColumnXs(B,W,s),se=this.getVisibleRowYs(j,ee,i),ae=ee.length>0?ee[ee.length-1]:n,q=W.length>0?W[W.length-1]:t,ne=this.getBottomViewport(e,ee,se,j),he=this.getRightViewport(e,W,Z,B),Te=this.getFloatingTopHeight(e,j),ye=this.getFloatingBottomHeight(e,j),rt=this.getFloatingLeftWidth(e,B),wt=this.getFloatingRightWidth(e,B),Wt=Array.from(B.values()),fn=Array.from(j.values()),xt=Wt.reduce((Ne,Kt)=>Ne+Kt,0)-s,Ee=fn.reduce((Ne,Kt)=>Ne+Kt,0)-i,lt=s+xt+f,et=i+Ee,pt=o-M,It=l-$,Cn=this.getLastLeft(e,null,pt-f),Gt=this.getLastLeft(e,null,pt-f-w),So=this.getLastTop(e,null,It-ye),Rs=this.getLastTop(e,null,It-ye-w);let zt=Gt,Zn=Rs;Cn===0&&So===0&&(zt=0,Zn=0);const ei=zt>0,Ni=ei?w:0,ti=Zn>0,ni=ti?w:0,bo=M,wo=O*S,Qn=o-bo-ni,xs=l-wo-Ni,ia=T===1?Qn/lt:(T-zt)/T,vo=E===1?xs/et:(E-Zn)/E,ki=ei?Ae(Qn*ia,b,Qn-1):0,Mi=ti?Ae(xs*vo,b,xs-1):0,Ai=N(B,t,0),To=N(j,n,0),oa=Ai>0?s/Ai:0,la=To>0?i/To:0,aa=T===1?s/(lt-pt):(t+oa)/zt,ra=E===1?i/(et-It):(n+la)/Zn,da=ei?aa*(Qn-ki):0,Is=ti?ra*(xs-Mi):0,Eo=[...Array(y).keys(),...[...Array(R).keys()].map(Ne=>E-Ne-1)],si=new Map([...se,...this.getFloatingRowYs(e,j,Math.floor(l-$-Ni))]),yo=[...Array(I).keys(),...[...Array(x).keys()].map(Ne=>T-Ne-1)],Ds=new Map([...Z,...this.getFloatingColumnXs(e,B,Math.floor(o-M-ni))]),Ro=[];if(m)for(let Ne=m.range[0];Ne<=m.range[1];Ne+=1)Ro.push(Ne),B.has(Ne)||B.set(Ne,this.getVisibleColumnWidth(Ne,e)),Ds.has(Ne)||Ds.set(Ne,0);const Oi=ee.concat(Eo),Li=W.concat(yo).concat(Ro),xo=this.getModelRows(Oi,e),Io=this.getModelColumns(Li,e),Do=this.getVisibleRowTreeBoxes(j,xo,e),ca=this.getTopVisible(e,si,j,ee),Fo=this.getLeftVisible(e,Ds,B,W),No=Zn>0?this.getBottomVisible(e,si,j,ee,$):ae,ko=zt>0?this.getRightVisible(e,Ds,B,W,M):q,{fontWidths:Mo,userColumnWidths:Ao,userRowHeights:Oo,calculatedRowHeights:ha,calculatedColumnWidths:Ue}=this;return{rowHeight:g,rowHeaderWidth:p,rowFooterWidth:f,rowCount:E,columnWidth:C,columnCount:T,columnHeaderHeight:S,floatingTopRowCount:y,floatingBottomRowCount:R,floatingLeftColumnCount:I,floatingRightColumnCount:x,gridX:M,gridY:$,firstRow:k,firstColumn:_,treePaddingX:H,treePaddingY:K,left:t,top:n,bottom:ae,right:q,topOffset:i,leftOffset:s,topVisible:ca,leftVisible:Fo,bottomVisible:No,rightVisible:ko,bottomViewport:ne,rightViewport:he,width:o,height:l,maxX:xt,maxY:Ee,lastLeft:zt,lastTop:Zn,barHeight:xs,barTop:wo,barWidth:Qn,barLeft:bo,handleHeight:Mi,handleWidth:ki,hasHorizontalBar:ei,hasVerticalBar:ti,verticalBarWidth:ni,horizontalBarHeight:Ni,scrollX:da,scrollY:Is,scrollableContentWidth:lt,scrollableContentHeight:et,scrollableViewportWidth:pt,scrollableViewportHeight:It,visibleRows:ee,visibleColumns:W,visibleRowHeights:L,visibleColumnWidths:G,floatingRows:Eo,floatingColumns:yo,allRows:Oi,allColumns:Li,allRowHeights:j,allColumnWidths:B,floatingTopHeight:Te,floatingBottomHeight:ye,floatingLeftWidth:rt,floatingRightWidth:wt,visibleRowYs:se,visibleColumnXs:Z,allRowYs:si,allColumnXs:Ds,visibleRowTreeBoxes:Do,modelRows:xo,modelColumns:Io,movedRows:h,movedColumns:u,fontWidths:Mo,userColumnWidths:Ao,userRowHeights:Oo,calculatedRowHeights:ha,calculatedColumnWidths:Ue,columnHeaderMaxDepth:O}}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=N(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=N(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 Pe(i)&&i.hasExpandableRows&&e.forEach((d,h)=>{const u=N(t,h);if(i.isRowExpandable(u)){const m=i.depthForRow(u),g=m*l+a,p=(m+1)*l+a,f=0,C=d;s.set(h,{x1:g,y1:f,x2:p,y2:C})}}),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+=N(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+=N(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+=N(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+=N(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(N(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(N(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=N(t,m),p=N(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=N(t,m),p=N(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=N(t,o)+N(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 N(this.modelRows,e);const{movedRows:n}=t,s=A.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 N(this.modelColumns,e);const{movedColumns:s}=t,i=A.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:f,scrollBarSize:C}=l;let S=0;const b=this.getWidthForFont(u,t),w=s/g,T=Math.ceil(n+w);return A.iterateAllItems(n,T,a,d,h,E=>{const y=this.getModelRow(E,t),R=o.textForCell(e,y);if(R){const I=m*2;S=Math.max(S,R.length*b+I)}}),S=Math.max(Math.min(S,(i-p-C-f)*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(!Pe(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 N(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 Tb=Co,Eb=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"}),yb=Eb,Rb=(c,e)=>{let t=!1;const n=we(c,{...e,dispose:()=>{t||(t=!0,n.clear(),t=!1)}});return n},Bn=Rb;function xb(c,e,t=6){const n=La.hex.lab.raw(c);return n[0]=Math.max(n[0]-n[0]/t*e,0),`#${La.lab.hex(n)}`}function Ib(c,e){const[t,n,s]=La.hex.rgb(c);return`rgba(${t}, ${n}, ${s}, ${e})`}const Kd={colorWithAlpha:Ib,darkenForDepth:xb};class ot{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 Db extends ot{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 f=N(l,p),C=n-a-f-this.dragOffset,S=N(h,p),b=this.targetSizes.get(S),w=this.resizingItems.length>1,T=this.hiddenItems.indexOf(p);let E=N(d,S);p===u&&(E+=m);let y=C;Math.abs(C-E)<=o.headerResizeSnapThreshold?y=E:b!==void 0&&C>b&&(w&&T!==0||T>0)?y=b:C<=o.headerResizeHiddenSnapThreshold&&(y=0),g.set(S,y),C<-o.headerResizeSnapThreshold&&y===0?T>=0&&w?(this.resizingItems.pop(),this.removeTargetSize(i,p),p=this.resizingItems[this.resizingItems.length-1],this.dragOffset-=this.targetSizes.get(N(h,p))??0):(p=this.getNextShownItem(p,i),p!==null&&(this.resizingItems.push(p),this.addTargetSize(i,p))):b!==void 0&&C>b+o.headerResizeSnapThreshold&&y===b?T>0?(this.dragOffset+=y,p=this.hiddenItems[T-1],this.resizingItems.push(p),this.addTargetSize(i,p)):w?(this.resizingItems.pop(),this.removeTargetSize(i,p),p=this.resizingItems[this.resizingItems.length-1]):p=null:p=null}return g.forEach((f,C)=>{const S=s[this.initialSizesProperty].get(C)??d.get(C);f===S?this.resetSize(s,C):this.setSize(s,C,f)}),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=N(a,l.index),h=N(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];N(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=N(n,t);let a=s.get(l);(a==null||a===0)&&(a=N(i,l)+o),this.targetSizes.set(l,a)}removeTargetSize(e,t){const n=e[this.modelIndexesProperty],s=N(n,t);this.targetSizes.delete(s)}}const du=Db;class Fr extends du{static getColumnSeparator(e,t,n,s){if(!s.allowColumnResize)return null;const{x:i,y:o,columnHeaderDepth:l}=e,{modelColumns:a}=t,d=A.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=A.getHiddenColumns;getNextShownItem=A.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 cu=Fr;class Nt{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=Nt.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=Nt.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 Nt.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:N(m,l-1)+N(g,l-1)-.5}),a>0&&this.drawSelectedRanges(e,t,{top:h-a-1,bottom:h-1,minY:N(m,h-a)+.5,maxY:N(m,h-1)+N(g,h-1)-.5});for(let p=0;p<u.length;p+=1){const f=u[p];for(let C=0;C<d.length;C+=1){const S=d[C];this.drawCellContent(e,t,f,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:f,allColumnXs:C,allColumnWidths:S,width:b,height:w}=i;if(u.length!==0){o.floatingRowBackgroundColors&&(this.drawRowStripesForRows(e,t,f,o.floatingRowBackgroundColors,0,d),this.drawRowStripesForRows(e,t,f,o.floatingRowBackgroundColors,b-m-h,g)),n==null&&s==null&&this.drawFloatingMouseRowHover(e,t),e.save(),e.beginPath(),e.rect(0,0,d,w),e.clip(),this.drawGridLinesForItems(e,t,u,f,o.floatingGridColumnColor,o.floatingGridRowColor),e.restore(),this.drawCellBackgroundsForItems(e,t,u,f),this.drawFloatingBorders(e,t),l>0&&this.drawSelectedRanges(e,t,{left:0,maxX:N(C,l-1)+N(S,l-1)}),a>0&&this.drawSelectedRanges(e,t,{left:p-a,right:p-1,minX:N(C,p-a)+.5,maxX:N(C,p-1)+N(S,p-1)});for(let T=0;T<u.length;T+=1){const E=u[T];for(let y=0;y<f.length;y+=1){const R=f[y];this.drawCellContent(e,t,E,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:f,maxY:C}=n,{floatingDividerOuterColor:S,floatingDividerInnerColor:b}=s;if(e.lineWidth=3,e.beginPath(),e.strokeStyle=S,i>0){const w=N(u,i-1)+N(g,i-1)+.5;e.moveTo(0,w),e.lineTo(f,w)}if(o>0){const w=N(u,d-o)-.5;e.moveTo(0,w),e.lineTo(f,w)}if(l>0){const w=N(m,l-1)+N(p,l-1)+.5;e.moveTo(w,0),e.lineTo(w,C)}if(a>0){const w=N(m,h-a)-.5;e.moveTo(w,0),e.lineTo(w,C)}if(e.stroke(),e.beginPath(),e.lineWidth=1,e.strokeStyle=b,i>0){const w=N(u,i-1)+N(g,i-1)+.5;e.moveTo(0,w),e.lineTo(f,w)}if(o>0){const w=N(u,d-o)-.5;e.moveTo(0,w),e.lineTo(f,w)}if(l>0){const w=N(m,l-1)+N(p,l-1)+.5;e.moveTo(w,0),e.lineTo(w,C)}if(a>0){const w=N(m,h-a)-.5;e.moveTo(w,0),e.lineTo(w,C)}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:f,allColumnWidths:C,width:S,height:b}=s;this.drawSelectedRanges(e,t,{bottom:Math.min(i,m-l-1),right:Math.min(o,u-d-1),minX:a>0&&f.has(a+1)?N(f,a+1):-10,minY:h>0&&p.has(h+1)?N(p,h+1):-10,maxX:d>0&&f.has(u-d-1)?N(f,u-d-1)+N(C,u-d-1)-.5:S+10,maxY:l>0&&p.has(m-l-1)?N(p,m-l-1)+N(g,m-l-1)-.5:b+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:f}=a,C=new Map,S=[],b=[],w=(T,E)=>{const y=Pe(d)?d.depthForRow(T):0,R=g[T%g.length],I=R[Math.min(y,R.length-1)];if(C.has(I)||C.set(I,[]),C.get(I).push(T),E!=null){const x=Pe(d)?d.depthForRow(E):0;x<y?S.push(T):x>y&&b.push(E)}};for(let T=0;T<n.length;T+=1){const E=n[T],y=T>0?n[T-1]:void 0;w(E,y)}if(C.forEach((T,E)=>{e.fillStyle=E,e.beginPath();for(let y=0;y<T.length;y+=1){const R=T[y],I=N(p,R),x=N(f,R);e.rect(i,I,o,x)}e.fill()}),S.length>0){e.save();const T=this.getCachedColorWithAlpha(m,.15),E=this.getCachedColorWithAlpha(m,0),y=e.createLinearGradient(0,0,0,u);y.addColorStop(0,T),y.addColorStop(1,E),e.fillStyle=y;for(let R=0;R<S.length;R+=1){const I=S[R],x=N(p,I);e.translate(0,x),e.fillRect(i,0,o,u),e.translate(0,-x)}e.restore()}if(b.length>0){e.save();const T=this.getCachedColorWithAlpha(m,0),E=this.getCachedColorWithAlpha(m,.15),y=e.createLinearGradient(0,0,0,u);y.addColorStop(0,T),y.addColorStop(1,E),e.fillStyle=y;for(let R=0;R<b.length;R+=1){const I=b[R],x=N(p,I),O=N(f,I),k=x+O-u;e.translate(0,k),e.fillRect(i,0,o,u),e.translate(0,-k)}e.restore()}}drawMouseColumnHover(e,t){const{mouseX:n,mouseY:s,theme:i,metrics:o}=t;if(n==null||s==null)return;const l=A.getColumnAtX(n,o);if(l==null||i.columnHoverBackgroundColor==null)return;const{allColumnWidths:a,allColumnXs:d,maxY:h}=o;if(s>h)return;const u=N(d,l),m=N(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=A.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=A.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=N(a,n),u=N(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=N(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=N(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:f}=o,C=N(u,s),S=N(h,n),b=l.backgroundColorForCell(S,C,a),w=n===d,T=Pe(l)&&l.hasExpandableRows;if(b!=null){const E=N(m,n)+1,y=N(p,s)+1,R=N(g,n)-1,I=N(f,s)-1;e.fillStyle=b,e.fillRect(E,y,R,I)}w&&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=N(i,n),h=N(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:f,treeHorizontalPadding:C}=o,S=N(m,n),b=N(g,t),w=i.textAlignForCell(b,S),T=N(a,t),E=N(h,n),y=N(d,t),R=N(u,n),I=t===l;let x=0;Pe(i)&&i.hasExpandableRows&&I&&(x=f*(i.depthForRow(n)+1)+C);const O=y-x;let k=T+p;const _=E+R*.5;return w==="right"?k=T+O-p:w==="center"&&(k=T+O*.5),k+=x,{width:O-p*2,x:k,y:_}}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,f=N(g,s),C=N(m,s),S=N(u,n),b=i??l.textForCell(S,C),w=l.truncationCharForCell(S,C),T=n===d;if(b&&f>0){const E=l.textAlignForCell(S,C)||"left";e.textAlign=E;const y=l.colorForCell(S,C,a)||p;e.fillStyle=y,e.save();const{width:R,x:I,y:x}=this.getTextRenderMetrics(t,n,s),O=h.get(e.font)??Nt.DEFAULT_FONT_WIDTH,k=this.getCachedTruncatedString(e,b,R,O,w),_=l.tokensForCell(S,C,k.length);if(k){let M=0,$=0,H=I;const{actualBoundingBoxDescent:K}=e.measureText(k);for(;$<k.length;){const L=_[M],G=$===L?.start?L:null,ee=G?.end??L?.start??k.length,W=k.substring($,ee),{width:j}=e.measureText(W),B=W.endsWith("…")?e.measureText(W.substring(0,W.length-1)).width:j;G!=null?(e.fillStyle=a.hyperlinkColor,e.fillText(W,H,x),e.fillRect(H,x+K,B,1)):(e.fillStyle=y,e.fillText(W,H,x)),H+=j,$=ee,G!=null&&(M+=1)}}e.restore()}T&&Pe(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:f,visibleRowTreeBoxes:C}=s,{treeMarkerColor:S,treeMarkerHoverColor:b}=a,w=N(m,d),T=N(g,d),E=N(p,n),y=N(f,n);if(!Pe(i)||!i.isRowExpandable(n))return;const R=N(C,n),I=o!=null&&l!=null&&o>=h+w&&o<=h+w+T&&l>=u+E&&l<=u+E+y?b:S;this.drawTreeMarker(e,t,w,E,R,I,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(!Pe(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:f}=l,C=N(h,d),S=N(u,n),b=N(m,n),w=s!==void 0?o.depthForRow(s):0,T=a>w?a-w:0;if(e.strokeStyle=f,e.lineWidth=1,a-T>0){e.beginPath();for(let E=0;E<a-T;E+=1){const y=C+E*g+g*.5+p+.5;e.moveTo(y,S),e.lineTo(y,S+b)}e.stroke()}if(T>0){e.beginPath();for(let E=a-T;E<a;E+=1){const y=C+E*g+g*.5+p+.5;e.moveTo(y,S),e.lineTo(y,S+Math.ceil(b/2)),e.moveTo(y-.5,S+Math.ceil(b/2)+.5),e.lineTo(y+g-.5,S+Math.ceil(b/2)+.5)}e.stroke()}}getCachedTruncatedString=Bn((e,t,n,s,i)=>Nt.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=>ih.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:f,allColumnXs:C,floatingLeftColumnCount:S,floatingLeftWidth:b,floatingRightWidth:w,modelColumns:T,columnHeaderMaxDepth:E}=o;if(h<=0)return;const{headerHiddenSeparatorSize:y,headerHiddenSeparatorHoverColor:R,headerSeparatorColor:I,headerSeparatorHoverColor:x}=i,O=h*.5,k=h*(E-1)+h*.5-O*.5,_=S>0;if(e.save(),this.drawColumnHeadersForRange(e,t,[p[0],p[p.length-1]],{minX:m+b,maxX:g-w}),_&&this.drawColumnHeadersForRange(e,t,[u[0],u[u.length-1]],{minX:m,maxX:m+b}),I){e.strokeStyle=I;const M=[...f.entries()].filter(([$,H])=>H===0).map(([$])=>$);e.beginPath(),e.fillStyle=I;for(let $=0;$<M.length;$+=1){const H=M[$],K=N(C,H),L=N(f,H),G=m+K+L+.5-y*.5;e.rect(G,k,y,O)}e.fill()}if(x){let{index:M,depth:$}=l??{};if(M==null&&n!=null&&s!=null){const K=cu.getColumnSeparator(A.getGridPointFromXY(n,s,o),o,d,i);M=K?.index,$=K?.depth}let H;if(M==null)H=!1;else{const K=T.get(M),L=T.get(M+1);K==null||L==null?H=!1:H=d.textForColumnHeader(K,$)!==d.textForColumnHeader(L,$)}if(H&&M!=null&&$!=null&&(!a||l!=null)){e.strokeStyle=x;const K=N(C,M),L=N(f,M),G=m+K+L+.5,ee=p.indexOf(M),W=ee<p.length-1?p[ee+1]:null,j=W!=null?f.get(W):null,B=L===0,Z=j!=null&&j===0;B?(e.strokeStyle=R,e.fillStyle=R,e.fillRect(G,k,y*.5,O)):Z&&(e.fillStyle=x,e.fillRect(G-y*.5,k,y*.5,O)),e.beginPath(),e.moveTo(G,(E-$-1)*h),e.lineTo(G,(E-$)*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:f,columnWidth:C}=a,{columnHeaderMaxDepth:S}=l,{minX:b,maxX:w}=s,T=w-b;if(S===0)return;const E=n[0],y=n[1];if(e.save(),e.translate(0,(S-i-1)*f),i===0){this.drawColumnHeader(e,t,"",b,w);for(let R=E;R<=y;R+=1)this.drawColumnHeaderAtIndex(e,t,R,s)}if(i>0){let R=E;for(;R<=y;){const{columnCount:I}=o,x=N(d,R),O=l.textForColumnHeader(x,i),k=l.colorForColumnHeader(x,i);let _=N(h,R)+u,M=_+N(g,R);if(O!=null){let $=R-1;for(;$>=0&&(M-_<T||_>b);){const G=d.get($)??A.getModelIndex($,p);if(G==null||l.textForColumnHeader(G,i)!==O)break;const ee=m.get(G)??g.get($)??C;_-=ee,$-=1}let H=R+1;for(;H<I&&(M-_<T||M<w);){const G=d.get(H)??A.getModelIndex(H,p);if(l.textForColumnHeader(G,i)!==O)break;const ee=m.get(G)??g.get(H)??C;M+=ee,H+=1}R=H-1;const K=M-_>=T;let L=_;K&&(M<w?L=M-T:_<b&&(L=b)),this.drawColumnHeader(e,t,O,L,Math.min(M-_,T),{backgroundColor:k??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=N(a,n),m=N(d,n)+h,g=N(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:f,white:C}=d,{fontWidths:S,width:b}=a,w=S.get(e.font)??Nt.DEFAULT_FONT_WIDTH,E=(i-h*2)/w,{backgroundColor:y=m,separatorColor:R=p}=o??{};let{textColor:I=g}=o??{};try{const B=this.getCachedColorIsDark(y),Z=this.getCachedColorIsDark(I);B&&Z?I=C:!B&&!Z&&(I=f)}catch{}let{minX:x=0,maxX:O=b}=l??{};e.save(),e.rect(x,0,O-x,u),e.clip(),y!=null&&(e.fillStyle=y,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=I;let k=n;E<=0?k="":k.length>E&&(k=`${k.substring(0,E-1)}…`);const _=k.length*w;let M=s+i*.5;const $=u*.5;x+=h,O-=h;const H=s+h,K=Ae(H,x,O),L=s+i-h,ee=Ae(L,x,O)-K,W=M-_*.5<x,j=M+_*.5>O;W?_<ee?M=x+_*.5:M=L-_*.5:j&&(_<ee?M=O-_*.5:M=H+_*.5),e.textAlign="center",e.fillText(k,M,$),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:f,headerHiddenSeparatorSize:C,headerHiddenSeparatorHoverColor:S,headerSeparatorColor:b,headerSeparatorHoverColor:w}=o,T=d*.5,E=d*.5-T*.5;if(e.save(),e.beginPath(),e.fillStyle=p,e.fillRect(0,0,d,h),b){e.strokeStyle=b,e.beginPath(),e.moveTo(0,a+.5),e.lineTo(d,a+.5);const y=[];let R=!1;for(let I=0;I<u.length;I+=1){const x=u[I],O=N(g,x),k=N(m,x);if(k>0){const _=a+O+k+.5;e.moveTo(0,_),e.lineTo(d,_),R=!1}else R||(R=!0,y.push(x))}e.moveTo(d-.5,0),e.lineTo(d-.5,h),e.stroke(),e.beginPath(),e.fillStyle=b;for(let I=0;I<y.length;I+=1){const x=y[I],O=N(g,x),k=N(m,x),_=a+O+k+.5-C*.5;e.rect(E,_,T,C)}e.fill()}if(w){let{index:y=null}=l??{};if(y==null&&n!=null&&s!=null&&(y=A.getRowSeparatorIndex(n,s,i,o)),y!=null){e.strokeStyle=w;const R=N(g,y),I=N(m,y),x=a+R+I+.5,O=u.indexOf(y),k=O<u.length-1?u[O+1]:null,_=k!=null?m.get(k):null,M=I===0,$=_!=null&&_===0;M?(e.strokeStyle=S,e.fillStyle=S,e.fillRect(E,x,T,C*.5)):$&&(e.fillStyle=w,e.fillRect(E,x-C*.5,T,C*.5)),e.beginPath(),e.moveTo(.5,x),e.lineTo(d+.5,x),e.stroke()}}e.beginPath(),e.rect(0,a,d,h),e.clip(),e.fillStyle=f,e.textAlign="right";for(let y=0;y<u.length;y+=1){const R=u[y],I=N(m,R),x=N(g,R)+a;this.drawRowHeader(e,t,R,x,I)}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=N(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:f,visibleRows:C,allRowHeights:S,allRowYs:b,width:w}=i;if(g<=0)return;const{cellHorizontalPadding:T,headerBackgroundColor:E,headerColor:y,headerHiddenSeparatorSize:R,headerHiddenSeparatorHoverColor:I,headerSeparatorColor:x,headerSeparatorHoverColor:O}=l,k=g*.5,_=g*.5-k*.5,M=Math.min(h+u,w-g-f);if(e.save(),e.beginPath(),e.fillStyle=E,e.fillRect(M,d,g,p),x){e.strokeStyle=x,e.beginPath(),e.moveTo(M,d+.5),e.lineTo(g,d+.5);const H=[];let K=!1;for(let L=0;L<C.length;L+=1){const G=C[L],ee=N(b,G),W=N(S,G);if(W>0){const j=d+ee+W+.5;e.moveTo(M+.5,j),e.lineTo(M+g-.5,j),K=!1}else K||(K=!0,H.push(G))}e.moveTo(M+.5,d),e.lineTo(M+.5,p),e.stroke(),e.beginPath(),e.fillStyle=x;for(let L=0;L<H.length;L+=1){const G=H[L],ee=N(b,G),W=N(S,G),j=d+ee+W+.5-R*.5;e.rect(M+_,j,k,R)}e.fill()}if(O){let{index:H=null}=a??{};if(H==null&&n!=null&&s!=null&&(H=A.getRowSeparatorIndex(n,s,i,l)),H!=null){e.strokeStyle=O;const K=N(b,H),L=N(S,H),G=d+K+L+.5,ee=C.indexOf(H),W=ee<C.length-1?C[ee+1]:null,j=W!=null?S.get(W):null,B=L===0,Z=j!=null&&j===0;B?(e.strokeStyle=I,e.fillStyle=I,e.fillRect(_,G,k,R*.5)):Z&&(e.fillStyle=O,e.fillRect(_,G-R*.5,k,R*.5)),e.beginPath(),e.moveTo(M+.5,G),e.lineTo(M+g+.5,G),e.stroke()}}e.beginPath(),e.rect(M,d,g,p),e.clip(),e.fillStyle=y,e.textAlign="left";const $=M+T;for(let H=0;H<C.length;H+=1){const K=C[H],L=N(S,K);if(L>0){const G=N(b,K)+d,ee=N(m,K),W=G+L*.5;e.fillText(o.textForRowFooter(ee),$,W)}}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:f,allRowYs:C,width:S,height:b}=d,{left:w=d.left,top:T=d.top,right:E=d.right,bottom:y=d.bottom,minY:R=-10,maxY:I=b+10,minX:x=-10,maxX:O=S+10}=n;if(u.length===0)return;const k=ze(h)&&h.isEditable&&a==null&&o==null&&l==null&&s!=null&&i!=null&&p.has(s)&&C.has(i);if(k){const _=N(p,s),M=N(C,i),$=N(g,s),H=N(f,i);e.save(),e.beginPath(),e.rect(0,0,S,b),e.rect(_,M,$,H),e.clip("evenodd")}e.beginPath();for(let _=0;_<u.length;_+=1){const M=u[_],$=M.startColumn!==null?M.startColumn:w,H=M.startRow!==null?M.startRow:T,K=M.endColumn!==null?M.endColumn:E,L=M.endRow!==null?M.endRow:y;if(L>=T&&y>=H&&K>=w&&E>=$){const G=$>=w&&p.has($)?Math.round(N(p,$))+.5:x,ee=H>=T&&C.has(H)?Math.max(Math.round(N(C,H))+.5,.5):R,W=K<=E&&p.has(K)?Math.round(N(p,K)+N(g,K))-.5:O,j=L<=y&&C.has(L)?Math.round(N(C,L)+N(f,L))-.5:I;e.rect(G,ee,W-G,j-ee)}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()}k&&s!=null&&i!=null&&(e.restore(),this.drawActiveCell(e,t,s,i))}drawActiveCell(e,t,n,s,i=Nt.ACTIVE_CELL_BORDER_WIDTH){const{metrics:o,theme:l}=t,{allColumnWidths:a,allColumnXs:d,allRowHeights:h,allRowYs:u}=o,m=N(d,n),g=N(u,s),p=N(a,n),f=N(h,s);let C=m-i*.5,S=g-i*.5,b=p+i,w=f+i;C<=0&&(b+=C-1,C=1),S<=0&&(w+=S-1,S=1);const{lineWidth:T}=e;e.beginPath(),e.lineWidth=i,e.strokeStyle=l.selectionOutlineColor,this.drawRoundedRect(e,C,S,b,w),e.stroke(),e.lineWidth=T}drawRoundedRect(e,t,n,s,i,o=Nt.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:f,columnHeaderMaxDepth:C,columnHeaderHeight:S,movedColumns:b,modelColumns:w,floatingLeftWidth:T}=s,E=w.get(a[0])??A.getModelIndex(a[0],b),y=l.getColumnHeaderGroup(E,d);if(d>0&&!y)return;const[R,I]=a,x=N(m,R),k=N(m,I)+N(g,I)-x,_=n.left,{backgroundColor:M,font:$,headerFont:H,reorderOffset:K,shadowBlur:L,shadowColor:G}=o,ee=(C-d-1)*S;e.save(),e.translate(h,0),e.save(),e.beginPath(),e.rect(T,0,f,p),e.clip(),e.fillStyle=M,e.fillRect(x,ee,k,p),e.restore(),e.translate(0,K),e.save(),e.shadowColor=G,e.shadowBlur=L,e.fillStyle=M,e.fillRect(n.left,ee+K,n.width,p),e.restore(),e.beginPath(),e.rect(n.left,ee,n.width+1,p),e.clip(),e.translate(_-x,0),e.font=H;const W=[];for(let j=n.range[0];j<=n.range[1];j+=1)W.push(j);this.drawColumnHeaders(e,t),this.drawColumnHeadersForRange(e,t,[W[0],W[W.length-1]],{minX:x,maxX:f}),e.translate(0,u),e.font=$,this.drawGridBackground(e,t);for(let j=R;j<=I;j+=1)this.drawColumnCellContents(e,t,j);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=N(h,n),p=N(u,n)+1,{backgroundColor:f,font:C,headerFont:S,reorderOffset:b,shadowBlur:w,shadowColor:T}=l;e.save(),e.translate(0,d),e.fillStyle=f,e.fillRect(0,g,m,p),e.translate(a+b,o-g-d-(s??0)),e.save(),e.shadowColor=T,e.shadowBlur=w,e.fillStyle=f,e.fillRect(-a,g,m,p),e.restore(),e.beginPath(),e.rect(-a,g,m,p),e.clip(),e.font=C,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:f,hasHorizontalBar:C,hasVerticalBar:S,barWidth:b,barHeight:w,barLeft:T,barTop:E}=o,{scrollBarBackgroundColor:y,scrollBarHoverBackgroundColor:R,scrollBarCasingColor:I,scrollBarCornerColor:x,scrollBarColor:O,scrollBarHoverColor:k,scrollBarActiveColor:_,scrollBarSize:M,scrollBarHoverSize:$,scrollBarCasingWidth:H,scrollBarSelectionTick:K,scrollBarSelectionTickColor:L,scrollBarActiveSelectionTickColor:G,autoSelectRow:ee,autoSelectColumn:W}=d,j=l!=null&&a!=null&&l<=h&&a<=u,B=s||S&&!n&&!i&&l!=null&&a!=null&&l>=h-$&&a>=E&&j,Z=n||C&&!s&&!i&&!B&&l!=null&&a!=null&&a>=u-$&&l>=T&&j,se=Z?$:M,ae=B?$:M;if(e.translate(T,E),C&&S&&(e.fillStyle=I,e.fillRect(h-T-M,u-E-M,M,M),e.fillStyle=x,e.fillRect(h-T-M+H,u-E-M+H,M-H,M-H)),C){const q=p,ne=u-E-se;if(e.fillStyle=I,e.fillRect(0,ne,b,se-H),e.fillStyle=Z?R:y,e.fillRect(0,ne+H,b,se-H),n?e.fillStyle=_:Z?e.fillStyle=k:e.fillStyle=O,e.fillRect(q,ne+H,g,se-H),!ee&&K&&L!=null&&G!=null){e.fillStyle=L;const{selectedRanges:he,cursorColumn:Te}=t,{lastLeft:ye,columnCount:rt}=o,Wt=[...he].filter(Ee=>Ee.startColumn!=null&&Ee.endColumn!=null).map(Ee=>[Ee.startColumn,Ee.endColumn]).sort(A.compareRanges),fn=A.mergeSortedRanges(Wt),xt=Ee=>Ee<=ye?Ee/ye*(b-g):b-g+(Ee-ye)/(rt-ye)*g;for(let Ee=0;Ee<fn.length;Ee+=1){const lt=fn[Ee],et=lt[0],pt=lt[1];if(et!=null&&pt!=null&&(et!==Te||pt!==Te)){const It=xt(et),Cn=Math.max(1,Math.round(xt(pt+1)-It)),Gt=se-H;e.fillRect(It,ne+H+Math.round(Gt/3),Cn,Math.round(Gt/3))}}if(Te!=null){const Ee=xt(Te),lt=2,et=se-H;e.fillStyle=G,e.fillRect(Ee,ne+H,lt,et)}}}if(S){const q=h-T-ae,ne=f;if(e.fillStyle=I,e.fillRect(q,0,ae-H,w),e.fillStyle=B?R:y,e.fillRect(q+H,0,ae-H,w),s?e.fillStyle=_:B?e.fillStyle=k:e.fillStyle=O,e.fillRect(q+H,ne,ae-H,m),!W&&K&&L!=null&&G!=null){const{selectedRanges:he,cursorRow:Te}=t,{lastTop:ye,rowCount:rt}=o,wt=Ee=>Ee<=ye?Ee/ye*(w-m):w-m+(Ee-ye)/(rt-ye)*m;e.fillStyle=L;const fn=[...he].filter(Ee=>Ee.startRow!=null&&Ee.endRow!=null).map(Ee=>[Ee.startRow,Ee.endRow]).sort(A.compareRanges),xt=A.mergeSortedRanges(fn);for(let Ee=0;Ee<xt.length;Ee+=1){const lt=xt[Ee],et=lt[0],pt=lt[1];if(et!=null&&pt!=null&&(et!==Te||pt!==Te)){const It=wt(et),Cn=ae-H,Gt=Math.max(1,Math.round(wt(pt+1)-It));e.fillRect(q+H+Math.round(Cn/3),It,Math.round(Cn/3),Gt)}}if(Te!=null){const Ee=Math.round(wt(Te)),lt=ae-H,et=2;e.fillStyle=G,e.fillRect(q+H,Ee,lt,et)}}}e.translate(-T,-E)}getTokenBoxesForVisibleCell(e,t,n){const{metrics:s,context:i,model:o,theme:l}=n;if(i==null||s==null)return Ie;const{modelRows:a,modelColumns:d}=s,h=N(a,t),u=N(d,e),m=o.textForCell(u,h),{width:g,x:p,y:f}=this.getTextRenderMetrics(n,e,t),{fontWidths:C}=s;i.save(),this.configureContext(i,n);const S=C?.get(i.font)??Nt.DEFAULT_FONT_WIDTH,b=o.truncationCharForCell(u,h),w=this.getCachedTruncatedString(i,m,g,S,b),{actualBoundingBoxAscent:T,actualBoundingBoxDescent:E}=i.measureText(w),y=T+E,R=o.tokensForCell(u,h,w.length);if(R.length===0)return i.restore(),Ie;const I=this.getCachedTokenBoxesForVisibleCell(w,R,l.font,"middle",y,i).map(x=>({x1:x.x1+p,y1:x.y1+(f-T),x2:x.x2+p,y2:x.y2+(f-T),token:x.token}));return i.restore(),I}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:f}=g,C=f>e.length?e.substring(p):g.value;u+=o.measureText(e.substring(h,p)).width;const S=o.measureText(C).width,b=u,w=b+S,T={x1:b,y1:0,x2:w,y2:a,token:g};d.push(T),h=f,u+=S}return d},{max:1e4})}const Fb=Nt,Yd=100;class Nb extends ot{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 f=A.isModifierKeyDown(n),C=n.shiftKey;f||(C?t.trimSelectedRanges():t.clearSelectedRanges());const S=t.getTheme(),{autoSelectRow:b,autoSelectColumn:w}=S;return(o!==null||!w)&&(l!==null||!b)&&(t.focus(),t.moveCursorToPosition(o,l,C,!1,C&&f)),this.startPoint=e,this.hasExtendedFloating=!1,this.dragBounds=A.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:f}=d,C=A.getScrollDragBounds(d,n,s);let S=0,b=0;if(h<u&&(i<C.x1?S=i-C.x1:i>C.x2&&(S=i-C.x2)),m<g&&(o<C.y1?b=o-C.y1:o>C.y2&&(b=o-C.y2)),S!==0||b!==0)this.startTimer(t,e,S>0?Math.ceil(S/p):Math.floor(S/p),b>0?Math.ceil(b/f):Math.floor(b/f));else if(l!=null&&a!=null){const{floatingTopRowCount:w,floatingBottomRowCount:T,floatingLeftColumnCount:E,floatingRightColumnCount:y,columnCount:R,rowCount:I,bottom:x,right:O,topVisible:k,bottomVisible:_,leftVisible:M,rightVisible:$}=d;this.hasExtendedFloating||(n!==null&&n<w&&l>=w?(l=w,this.hasExtendedFloating=!0):n!==null&&n>=I-T&&l<I-T&&(l=I-T-1,this.hasExtendedFloating=!0),s!==null&&s<E&&a>=E?(a=E,this.hasExtendedFloating=!0):s!==null&&s>=R-y&&a<R-y&&(a=R-y-1,this.hasExtendedFloating=!0)),n!==null&&!A.isFloatingRow(n,d)&&A.isFloatingRow(l,d)&&(n>l&&l<m?l=k-1:n<l&&l>x&&(l=_+1)),s!==null&&!A.isFloatingColumn(s,d)&&A.isFloatingColumn(a,d)&&(s>a&&a<h?a=M-1:s<a&&a>O&&(a=$+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,f=s>0&&i!=null?i:h-1;e.moveCursorToPosition(Math.min(Math.max(m,d+n),g),Math.min(Math.max(p,a+s),f),!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 kb=Nb,qd=5,Mb=1e3/60,Bo=10;function is(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)??A.getModelIndex(c,i),p=n.getColumnHeaderGroup(g,e),f=p!=null;let C,S,b;if(p!=null){const[w,T]=p.getVisibleRange(i);C=o.get(w)??u,S=(o.get(T)??m)+(a.get(T)??0),b=[w,T]}else{const w=o.get(c);if(w==null)return null;C=w,S=C+(a.get(c)??d.get(g)??h.get(g)??0),b=[c,c]}return{visibleIndex:c,modelIndex:g,left:C,right:S,width:S-C,isColumnGroup:f,range:b,depth:e}}class Ab extends ot{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-=Bo;m<0;){u-=1;const f=A.getModelIndex(s-1,d),C=l.get(f)??a.get(f);C===void 0?m=0:m+=C,u<0&&(m=0,u=0)}else{m+=Bo;let f=h.get(s);for(;f!==void 0&&m>f;){u+=1,m-=f;const C=A.getModelIndex(s+1,d);f=l.get(C)??a.get(C),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"?-Bo:Bo),e.setState({left:u,leftOffset:m}),(t==="left"&&u===0&&o===0||t==="right"&&u===i)&&this.clearScrollInterval())},Mb))}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=is(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=is(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=is(a.range[0],0,d,l),m=is(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=is(this.draggingColumn.range[0],s,l,i);if(!g)return;const p=e-this.draggingOffset,f=p+g.width;this.draggingColumn={...this.draggingColumn,left:p},t.setState({draggingColumn:this.draggingColumn});const C=is(A.getColumnAtX(Ae(m?p:f,a,d),l,!0),s,l,i),S=i.getColumnHeaderParentGroup(g.modelIndex,g.depth);if(!C)return;if(S!==void 0){const R=S.getVisibleRange(o);if(C.visibleIndex<R[0]){const I=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:I});return}if(C.visibleIndex>R[1]){const I=this.moveColumn(g,R[1]-(g.range[1]-g.range[0]),o),{right:x=0}=is(R[1],0,l,i)??{};this.draggingOffset=e-(x-g.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),t.setState({draggingColumn:this.draggingColumn,movedColumns:I});return}}if(!i.isColumnMovable(C.modelIndex)){let R=C.visibleIndex;if(m)for(R+=1;R<g.visibleIndex&&!i.isColumnMovable(A.getModelIndex(R,o));)R+=1;else for(R-=1;R>g.visibleIndex&&!i.isColumnMovable(A.getModelIndex(R,o));)R-=1;if(R!==g.visibleIndex){m||(R-=g.range[1]-g.range[0]);const x=this.moveColumn(g,R,o);t.setState({movedColumns:x,draggingColumn:this.draggingColumn})}const I=is(R,0,l,i);m?this.draggingOffset=e-(I?.left??0):this.draggingOffset=e-((I?.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"):f>d?this.setScrollInterval(t,"right"):this.clearScrollInterval(),C.visibleIndex===g.visibleIndex||m&&g.visibleIndex<C.visibleIndex||!m&&g.visibleIndex>C.visibleIndex)return;const b=C.left+C.width*.5,w=i.getColumnHeaderParentGroup(g.modelIndex,g.depth);let T,E=(w?.depth??h)-1;for(;E>=0&&T===void 0;)T=i.getColumnHeaderGroup(C.modelIndex,E),E-=1;let y;m&&p<b&&(!T||C.visibleIndex===T.getVisibleRange(o)[0])&&(y=this.moveColumn(g,C.range[0],o)),!m&&f>b&&(!T||C.visibleIndex===T.getVisibleRange(o)[1])&&(y=this.moveColumn(g,C.range[1]-(g.range[1]-g.range[0]),o)),y&&(this.draggingColumn={...this.draggingColumn,left:p},t.setState({movedColumns:y,draggingColumn:this.draggingColumn}))}moveColumn(e,t,n){const s=e.isColumnGroup?A.moveRange(e.range,t,n):A.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 Ob=Ab;class Nr extends ot{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 Lb=Nr;class _b extends ot{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=N(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:y}=t.getGridPointFromXY(i,o);if(y!=null&&!n.isRowMovable(y)||(s=y,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:f,height:C}=l;let S=g;if(a<s){const y=s-1;S=N(f,y)+N(p,y)*.5+g}let b=C;if(s<h){const y=s+1;b=N(f,y)+N(p,y)*.5+g}let{movedRows:w}=t.state;o<S&&s>0&&n.isRowMovable(s-1)?(w=A.moveItem(s,s-1,w),s-=1):b<o&&s<m-1&&n.isRowMovable(s+1)&&(w=A.moveItem(s,s+1,w),s+=1),t.setState({movedRows:w,draggingRow:s});const T=g+N(p,a)*.5,E=g+N(f,u)+N(p,u)*.5;return o<T&&a>0?t.setState({top:a-1}):o>E&&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 Pb=_b;class kr extends du{static getRowSeparator(e,t,n,s){if(!s.allowRowResize)return null;const{x:i,y:o}=e,l=A.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=A.getHiddenRows;getNextShownItem=A.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 jb=kr;class bl extends ot{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:f}=l;if(n===h&&s!=null&&f.get(s)!=null&&i>a&&o>d){const C=N(u,n),S=N(m,n),b=N(p,s),w=N(g,s);if(i>=a+C&&i<=a+C+S&&o>=d+b&&o<=d+b+w)return!0}return!1}onDown(e,t){return bl.isInTreeBox(e,t)}onClick(e,t,n){if(bl.isInTreeBox(e,t)){const{row:s}=e;if(s!==null)return t.toggleRowExpanded(s,A.isModifierKeyDown(n)),!0}return!1}}const Ka=bl;class Hb extends ot{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 Ub=Hb;class Mr extends ot{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 Bb=Mr;class Vb extends ot{onDoubleClick({column:e,row:t},n){const{model:s}=n.props;return ze(s)&&e!=null&&t!=null&&s.isEditableRange(Re.makeCell(e,t))?(n.startEditing(e,t),!0):!1}}const $b=Vb;class Ar extends ot{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(Sl(h[u].token)){const m=A.translateTokenBox(h[u],a),{x1:g,x2:p,y1:f,y2:C}=m;if(i>=g&&i<=p&&o>=f&&o<=C)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 A.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),ze(l)&&i!=null&&o!=null&&l.isEditableRange(Re.makeCell(i,o))&&t.startEditing(i,o)},Ar.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 Wb=Ar;class Gb{order;constructor(e=5e3){this.order=e}onDown(e,t){return!1}}const Js=Gb;class zb extends Js{onDown(e,t){switch(e.key){case"a":if(A.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 A.isModifierKeyDown(e)?!1:this.handlePageUp(e,t);case"j":case"J":return A.isModifierKeyDown(e)?!1:this.handlePageDown(e,t);case"h":case"H":return A.isModifierKeyDown(e)?!1:(e.shiftKey||t.clearSelectedRanges(),t.moveCursorToPosition(0,t.state.cursorRow,e.shiftKey),!0);case"l":case"L":{if(A.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(A.isModifierKeyDown(e)?t.state.cursorColumn:0,A.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(A.isModifierKeyDown(e)?t.state.cursorColumn:s-1,A.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?Re.SELECTION_DIRECTION.UP:Re.SELECTION_DIRECTION.DOWN),!0;break;case"Tab":if(t.state.selectedRanges.length>0)return t.moveCursorInDirection(e.shiftKey?Re.SELECTION_DIRECTION.LEFT:Re.SELECTION_DIRECTION.RIGHT),!0;break}return!1}handleArrowMove(e,t,n,s){const i=n.shiftKey,o=A.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:f}=g,C=o&&i;let S=null,b=null;e<0?(S=0,b=m):e>0?(S=p-1,b=m):t<0?(S=u,b=0):t>0&&(S=u,b=f-1),S!=null&&b!=null&&s.moveCursorToPosition(S,b,i,!0,C)}else{if(!s.metrics)throw new Error("grid.metrics are not set");const{theme:g}=s.props,{autoSelectRow:p=!1,autoSelectColumn:f=!1}=g;if(p&&e!==0){const{lastLeft:C}=s.metrics;let{left:S}=s.state;S=Ae(S+e,0,C),s.moveCursorToPosition(S,l,i,!1),s.setViewState({left:S})}else if(f&&t!==0){const{lastTop:C}=s.metrics;let{top:S}=s.state;S=Ae(S+t,0,C),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),f=g-1;let C=h-u+o;C+=m?0:1,C=Math.min(C,f);const S=Math.min(p,C-(o-u));return t.moveCursorToPosition(l,C,n,!1),t.setViewState({top:S}),!0}}const Kb=zb;class Yb extends Js{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)&&Pe(i)&&i.isRowExpandable(a))return t.toggleRowExpanded(o),!0}}}return!1}}const qb=Yb;class Xb extends Js{onDown(e,t){if(A.isModifierKeyDown(e))return!1;const{model:n}=t.props,{cursorColumn:s,cursorRow:i}=t.state;if(s==null||i==null||!ze(n)||!n.isEditableRange(Re.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=Xb;function Qb(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 Jb(c){const e=[];return c.forEach(t=>{const n=t.textContent??"";n.length>0&&e.push(n.split(/\t|\u00a0\u00a0 \u00a0/))}),e}function ew(c){const e=c.querySelector("table");if(e!=null)return Qb(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(`
|
|
18
|
+
`)}this.bufferedMessages=[],this.appendLogText(e)}queue(e){this.bufferedMessages.push(e),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,bt.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(P,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:tg,tooltip:"Clear log"}),r.jsx(P,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:uo,tooltip:"Log Settings",onClick:()=>{},children:r.jsx($n,{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 Gf=bt;function mh(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 gh(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 ph(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 zf(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}`)}}hr.register([sp,ip,op,lp,ap,rp]);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(e){this.dh=e,this.listeners=[],this.isDownsamplingDisabled=!1}dh;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,Kf="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",Yf="#403e41",qf="#5b5a5c",Xf="#c0bfbf",Zf="#4878ea",Qf="rgba(91, 90, 92, 0.7)",ft={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:Kf,gridcolor:Yf,linecolor:qf,zerolinecolor:Xf,activecolor:Zf,rangebgcolor:Qf,"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"},kt=Object.freeze({paper_bgcolor:ft["paper-bgcolor"],plot_bgcolor:ft["plot-bgcolor"],title_color:ft["title-color"],colorway:ft.colorway,gridcolor:ft.gridcolor,linecolor:ft.linecolor,zerolinecolor:ft.zerolinecolor,activecolor:ft.activecolor,rangebgcolor:ft.rangebgcolor,area_color:ft["area-color"],trend_color:ft["trend-color"],line_color:ft["line-color"],error_band_line_color:ft["error-band-line-color"],error_band_fill_color:ft["error-band-fill-color"],ohlc_increasing:ft["ohlc-increasing"],ohlc_decreasing:ft["ohlc-decreasing"]}),Pi=J.module("ChartUtils"),Ad="io.deephaven.time.DateTime",Jf=36e5,eC=1e6;function tC(c){return c.asDate!==void 0}function nC(c){return c.asNumber!==void 0}function Od(c){return c.dhTimeZone!==void 0}function sC(c){return c!=null&&c.range!=null&&(c.autorange===!1||c.autorange===void 0)}class de{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 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 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*)(%?)(.*)/);D(i);const[,o,l,a,,d,h,u,m,g]=i,p=a.replace(",","").length,C=l.indexOf(",")>=0||a.indexOf(",")>=0?",":"",S=u!=null&&u!==""?"e":"f",b=m!==""?m:S,w=d.length+h.length,E=`0${p}${C}.${w}${b}`,y=de.convertNumberPrefix(o),R=de.convertNumberPrefix(g);return{tickformat:E,tickprefix:y,ticksuffix:R,automargin:!0}}static addTickSpacing(e,t,n){const{gapBetweenMajorTicks:s}=t;if(s>0){const i=e||{};let o=s;return n&&(o=s/eC),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=de.ORIENTATION.VERTICAL){return{type:e,mode:t,name:n,orientation:i,showlegend:s??void 0}}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 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];sC(o)&&(t[i]=[...o.range])}return t}static getAxisLayoutProperty(e,t){const n=t>0?`${t+1}`:"";return`${e??""}axis${n}`}static periodToDecimal(e){const t=e.split(":");return Number(t[0])+Number(t[1])/60}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 getColorwayFromTheme(e=kt){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 titleFromSettings(e){const{series:t,xAxis:n,title:s=`${(t??[]).join(", ")} by ${n}`}=e;return s}dh;daysOfWeek;constructor(e){this.dh=e,this.daysOfWeek=Object.freeze(e.calendar.DayOfWeek.values())}getAxisFormats(e,t){const n=new Map,s={tickformat:null,ticksuffix:null},i=de.getAllAxes(e),o=de.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 f=g[p],{axis:C}=f,{type:S}=C,b=o.get(S);D(b);const w=b.indexOf(C),T=this.getAxisPropertyName(S);if(T!=null){const E=de.getAxisLayoutProperty(T,w);if(n.has(E))Pi.debug(`${E} already added.`);else{Pi.debug(`Adding ${E} to axisFormats.`);const y=this.getPlotlyAxisFormat(f,t);if(y===null)n.set(E,s);else{n.set(E,y);const{businessCalendar:R}=C;if(R!=null){const I=[],{businessPeriods:x,businessDays:O,holidays:k,timeZone:_}=R,M=t?.getColumnTypeFormatter(Ad);let $;Od(M)&&($=M.dhTimeZone);const H=$?(_.standardOffset-$.standardOffset)/60:0;k.length>0&&I.push(...this.createRangeBreakValuesFromHolidays(k,_,$)),x.forEach(K=>I.push({pattern:"hour",bounds:[de.periodToDecimal(K.close)+H,de.periodToDecimal(K.open)+H]})),O.length<this.daysOfWeek.length&&this.createBoundsFromDays(O).forEach(K=>I.push({pattern:"day of week",bounds:K})),y.rangebreaks=I}if(n.size===d.axes.length)return n}}}}}}return n}getPlotlyChartType(e,t){const{dh:n}=this;switch(e){case n.plot.SeriesPlotStyle.SCATTER:return t?"scatter":"scattergl";case n.plot.SeriesPlotStyle.LINE:return"scatter";case n.plot.SeriesPlotStyle.BAR:case n.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case n.plot.SeriesPlotStyle.PIE:return"pie";case n.plot.SeriesPlotStyle.TREEMAP:return"treemap";case n.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case n.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}getPlotlyChartMode(e,t,n){const{dh:s}=this,i=new Set;switch(e){case s.plot.SeriesPlotStyle.SCATTER:(t??!1)&&i.add(de.MODE_LINES),(n??!0)&&i.add(de.MODE_MARKERS);break;case s.plot.SeriesPlotStyle.LINE:(t??!0)&&i.add(de.MODE_LINES),(n??!1)&&i.add(de.MODE_MARKERS);break}return i.size>0?[...i].join("+"):void 0}getPlotlyProperty(e,t){const{dh:n}=this;switch(e){case n.plot.SeriesPlotStyle.PIE:switch(t){case n.plot.SourceType.X:return"labels";case n.plot.SourceType.Y:return"values"}break;case n.plot.SeriesPlotStyle.OHLC:switch(t){case n.plot.SourceType.TIME:return"x"}break;case n.plot.SeriesPlotStyle.TREEMAP:switch(t){case n.plot.SourceType.X:return"ids";case n.plot.SourceType.Y:return"values";case n.plot.SourceType.LABEL:return"labels";case n.plot.SourceType.PARENT:return"parents";case n.plot.SourceType.COLOR:return"marker.colors"}break}switch(t){case n.plot.SourceType.X:return"x";case n.plot.SourceType.Y:return"y";case n.plot.SourceType.Z:return"z";case n.plot.SourceType.X_LOW:return"xLow";case n.plot.SourceType.X_HIGH:return"xHigh";case n.plot.SourceType.Y_LOW:return"yLow";case n.plot.SourceType.Y_HIGH:return"yHigh";case n.plot.SourceType.TIME:return"time";case n.plot.SourceType.OPEN:return"open";case n.plot.SourceType.HIGH:return"high";case n.plot.SourceType.LOW:return"low";case n.plot.SourceType.CLOSE:return"close";case n.plot.SourceType.SHAPE:return"shape";case n.plot.SourceType.SIZE:return"size";case n.plot.SourceType.LABEL:return"label";case n.plot.SourceType.COLOR:return"color";case n.plot.SourceType.PARENT:return"parent";case n.plot.SourceType.HOVER_TEXT:return"hovertext";case n.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${t}`)}}getPlotlySeriesOrientation(e){const{dh:t}=this,{sources:n}=e;return n.length===2&&n[0]?.axis?.type===t.plot.AxisType.Y?de.ORIENTATION.HORIZONTAL:de.ORIENTATION.VERTICAL}makeSeriesDataFromSeries(e,t,n,s=null,i=kt){const{name:o,isLinesVisible:l,isShapesVisible:a,plotStyle:d,lineColor:h,shapeColor:u,sources:m,shape:g,shapeSize:p}=e,f=m.some(T=>T.axis?.businessCalendar),C=this.getChartType(d,f),S=this.getPlotlyChartMode(d,l??void 0,a??void 0),b=this.getPlotlySeriesOrientation(e),w=de.makeSeriesData(C,S,o,s,b);return this.addSourcesToSeriesData(w,d,m,t),this.addStylingToSeriesData(w,d,i,h,u,g,p,n),w}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=this.getPlotlyProperty(t,d);_c(i,h,[]);const u=a!=null?this.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}`}}}}addStylingToSeriesData(e,t,n=kt,s=null,i=null,o=null,l=null,a=null){const{dh:d}=this,h=e;if(h.marker={line:{}},h.line={width:1},t===d.plot.SeriesPlotStyle.AREA?h.fill="tozeroy":t===d.plot.SeriesPlotStyle.STACKED_AREA?h.stackgroup="stack":t===d.plot.SeriesPlotStyle.STEP?h.line.shape="hv":t===d.plot.SeriesPlotStyle.HISTOGRAM?(h.width=[],h.marker.line!==void 0&&Object.assign(h.marker.line,{color:n.paper_bgcolor,width:1})):t===d.plot.SeriesPlotStyle.OHLC?(h.increasing={line:{color:n.ohlc_increasing}},h.decreasing={line:{color:n.ohlc_decreasing}}):t===d.plot.SeriesPlotStyle.PIE?(h.textinfo="label+percent",h.outsidetextfont={color:n.title_color}):t===d.plot.SeriesPlotStyle.TREEMAP&&(h.hoverinfo="text",h.textinfo="label+text",h.tiling={packing:"squarify",pad:0},h.textposition="middle center",h.outsidetextfont={color:n.title_color}),s!=null&&(t===d.plot.SeriesPlotStyle.BAR?h.marker.color=s:h.line.color=s),i!=null&&(h.marker.color=i),o!=null&&o.length>0)try{h.marker.symbol=de.getMarkerSymbol(o)}catch(u){Pi.warn("Unable to handle shape",o,":",u)}l!=null&&(h.marker.size=l*de.DEFAULT_MARKER_SIZE),a!=null&&t!==d.plot.SeriesPlotStyle.PIE&&(h.visible=a)}getChartType(e,t){const{dh:n}=this;switch(e){case n.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return this.getPlotlyChartType(e,t)}}getAxisPropertyName(e){const{dh:t}=this;switch(e){case t.plot.AxisType.X:return"x";case t.plot.AxisType.Y:return"y";default:return null}}getAxisSide(e){const{dh:t}=this;switch(e){case t.plot.AxisPosition.BOTTOM:return"bottom";case t.plot.AxisPosition.TOP:return"top";case t.plot.AxisPosition.LEFT:return"left";case t.plot.AxisPosition.RIGHT:return"right";default:return}}updateFigureAxes(e,t,n,s=0,i=0,o=kt){const l=e,a=de.getAllAxes(t);for(let d=0;d<t.charts.length;d+=1){const h=t.charts[d],u=n?.(h),m=this.getChartBounds(t,h,s,i);this.updateLayoutAxes(l,h.axes,a,s,i,m,u,o)}this.removeStaleAxes(l,a)}getChartBounds(e,t,n,s){const{dh:i}=this,{cols:o,rows:l}=e,{column:a,colspan:d,row:h,rowspan:u}=t,m=a+d,g=h+u,p=1/o,f=1/l,C=de.AXIS_SIZE_PX/n,S=de.AXIS_SIZE_PX/s,b={bottom:(l-g)*f+(g<l?S/2:0),top:(l-h)*f-(h>0?S/2:0),left:a*p+(a>0?C/2:0),right:m*p-(m<o?C/2:0)};return(de.groupArray(t.axes,"position").get(i.plot.AxisPosition.RIGHT)??[]).length>0&&(n>0?b.right-=(b.right-b.left)*Math.max(0,Math.min(de.LEGEND_WIDTH_PX/n,de.MAX_LEGEND_SIZE)):b.right-=(b.right-b.left)*de.DEFAULT_AXIS_SIZE),b}getPlotlyDateFormat(e,t,n){const{dh:s}=this,i=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 o;const l=e?.getColumnTypeFormatter(t);return l!=null&&Od(l)&&l.dhTimeZone!=null&&l.showTimeZone&&(o=s.i18n.DateTimeFormat.format(" z",new Date,l.dhTimeZone)),{tickformat:i,ticksuffix:o,automargin:!0}}getPlotlyAxisFormat(e,t=null){const{dh:n}=this,{axis:s,columnType:i}=e,{formatPattern:o}=s;let l=null;return F.isDateType(i)?(l=this.getPlotlyDateFormat(t,i,o),l=de.addTickSpacing(l,s,!0)):F.isNumberType(i)&&(l=de.getPlotlyNumberFormat(t,i,o),l=de.addTickSpacing(l,s,!1)),s.formatType===n.plot.AxisFormatType.CATEGORY&&(l?l.type="category":l={type:"category",tickformat:void 0,ticksuffix:void 0}),l}updateLayoutAxes(e,t,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},l,a=kt){const{dh:d}=this,h=s>0?Math.max(de.MIN_AXIS_SIZE,Math.min(de.AXIS_SIZE_PX/i,de.MAX_AXIS_SIZE)):de.DEFAULT_AXIS_SIZE,u=i>0?Math.max(de.MIN_AXIS_SIZE,Math.min(de.AXIS_SIZE_PX/s,de.MAX_AXIS_SIZE)):de.DEFAULT_AXIS_SIZE,m=e,g=de.groupArray(t,"position"),p=de.groupArray(t,"type"),f=[...p.keys()],C=de.groupArray(n,"type");for(let S=0;S<f.length;S+=1){const b=f[S],w=this.getAxisPropertyName(b);if(w!=null){const T=p.get(b),E=C.get(b),R=b===d.plot.AxisType.Y?i:s;D(T),D(E);for(let I=0;I<T.length;I+=1){const x=T[I],O=E.indexOf(x),k=de.getAxisLayoutProperty(w,O);m[k]==null&&(m[k]=this.makeLayoutAxis(b,a));const _=m[k];if(_!=null){this.updateLayoutAxis(_,x,I,g,h,u,o);const{range:M,autorange:$}=_;if(l!=null&&M!==void 0&&($===void 0||$===!1)){const H=l(x),[K,L]=H(M);Pi.debug("Setting downsample range",R,K,L),x.range(R,K,L)}else x.range(R)}}}}}removeStaleAxes(e,t){const n=e,s=de.groupArray(t,"type"),i=[...s.keys()];for(let o=0;o<i.length;o+=1){const l=i[o],a=s.get(l);D(a);let d=a.length;const h=this.getAxisPropertyName(l);if(h!=null){let u=de.getAxisLayoutProperty(h,d);for(;n[u]!=null;)delete n[u],d+=1,u=de.getAxisLayoutProperty(h,d)}}}updateLayoutAxis(e,t,n,s,i,o,l){const{dh:a}=this,h=t.type===a.plot.AxisType.Y?o:i,u=e,m=t.label??"";if(u.title!==void 0&&typeof u.title!="string"?u.title.text=m:u.title={text:m},t.log&&(u.type="log"),u.side=this.getAxisSide(t.position),n>0){u.overlaying=this.getAxisPropertyName(t.type)??void 0;const g=s.get(t.position)??[],p=g.indexOf(t);p>0&&(u.anchor="free",t.position===a.plot.AxisPosition.RIGHT?u.position=l.right+(p-g.length+1)*h:t.position===a.plot.AxisPosition.TOP?u.position=l.top+(p-g.length+1)*h:t.position===a.plot.AxisPosition.BOTTOM?u.position=l.bottom+(g.length-p+1)*h:t.position===a.plot.AxisPosition.LEFT&&(u.position=l.left+(g.length-p+1)*h))}else if(t.type===a.plot.AxisType.X){const g=s.get(a.plot.AxisPosition.LEFT)||[],p=s.get(a.plot.AxisPosition.RIGHT)||[],f=Math.max(l.left,l.left+(g.length-1)*o),C=Math.min(l.right-(p.length-1)*o,l.right);u.domain=[f,C]}else if(t.type===a.plot.AxisType.Y){const g=s.get(a.plot.AxisPosition.BOTTOM)||[],p=s.get(a.plot.AxisPosition.TOP)||[],f=Math.max(l.bottom,l.bottom+(g.length-1)*i),C=Math.min(l.top-(p.length-1)*i,l.top);u.domain=[f,C]}}createBoundsFromDays(e){const t=e.map(o=>this.daysOfWeek.indexOf(o)),n=this.daysOfWeek.filter(o=>!e.includes(o)).map(o=>this.daysOfWeek.indexOf(o)),s=new Set;n.forEach(o=>{for(let l=o+1;l<o+this.daysOfWeek.length;l+=1){const a=l%this.daysOfWeek.length;if(t.includes(a)){s.add(a);break}}});const i=[];return s.forEach(o=>{for(let l=o-1;l>o-this.daysOfWeek.length;l-=1){const a=l<0?l+this.daysOfWeek.length:l;if(t.includes(a)){const d=(a+1)%7;i.push([d,o]);break}}}),i}createRangeBreakValuesFromHolidays(e,t,n){const s=[],i=[];return e.forEach(o=>{o.businessPeriods.length>0?i.push(...this.createPartialHoliday(o,t,n)):s.push(this.createFullHoliday(o,t,n))}),[{values:s},...i]}createFullHoliday(e,t,n){return this.adjustDateForTimeZone(`${e.date.toString()} 00:00:00.000000`,t,n)}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=[this.adjustDateForTimeZone(`${s} ${a}:00.000000`,t,n)],u=Jf*(de.periodToDecimal(d)-de.periodToDecimal(a));o.push({values:h,dvalue:u})}}return o}adjustDateForTimeZone(e,t,n){return n&&n.standardOffset!==t.standardOffset?this.unwrapValue(this.wrapValue(e,Ad,t),n):e}makeFigureSettings(e,t){const{dh:n}=this,{series:s,xAxis:i,type:o}=e,l=de.titleFromSettings(e),a={formatType:`${n.plot.AxisFormatType.NUMBER}`,type:`${n.plot.AxisType.X}`,position:`${n.plot.AxisPosition.BOTTOM}`},d={formatType:`${n.plot.AxisFormatType.NUMBER}`,type:`${n.plot.AxisType.Y}`,position:`${n.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${n.plot.ChartType.XY}`,axes:[a,d],series:(s??[]).map(h=>({plotStyle:`${o}`,name:h,dataSources:[{type:`${n.plot.SourceType.X}`,columnName:i??"",axis:a,table:t},{type:`${n.plot.SourceType.Y}`,columnName:h,axis:d,table:t}]}))}],title:l}}unwrapValue(e,t){const{dh:n}=this;if(e!=null){if(tC(e))return n.i18n.DateTimeFormat.format(de.DATE_FORMAT,e,t);if(nC(e))return e.asNumber()}return e}wrapValue(e,t,n=null){const{dh:s}=this;if(F.isDateType(t)&&typeof e=="string"){const i=e,o=de.DATE_FORMAT.substr(0,e.length),l=s.i18n.DateTimeFormat.parse(o,i);if(!n)return l;const a=`${o} Z`,d=s.i18n.DateTimeFormat.format("Z",l,n),h=s.i18n.DateTimeFormat.parse(a,`${i} ${d}`),u=s.i18n.DateTimeFormat.format("Z",h,n);return s.i18n.DateTimeFormat.parse(a,`${i} ${u}`)}return e}makeLayoutAxis(e,t=kt){const{dh:n}=this,s={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===n.plot.AxisType.X?Object.assign(s,{showgrid:!0}):e===n.plot.AxisType.Y&&Object.assign(s,{zerolinecolor:t.zerolinecolor,zerolinewidth:2}),s}makeDefaultLayout(e=kt){const{dh:t}=this,n={...e,autosize:!0,colorway:de.getColorwayFromTheme(e),font:{family:"'Fira Sans', sans-serif",color:e.title_color},title:{font:{color:e.title_color},yanchor:"top",pad:{...de.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:e.title_color}},margin:{...de.DEFAULT_MARGIN},xaxis:this.makeLayoutAxis(t.plot.AxisType.X,e),yaxis:this.makeLayoutAxis(t.plot.AxisType.Y,e),polar:{angularaxis:this.makeLayoutAxis(t.plot.AxisType.SHAPE,e),radialaxis:this.makeLayoutAxis(t.plot.AxisType.SHAPE,e),bgcolor:e.plot_bgcolor},scene:{xaxis:this.makeLayoutAxis(t.plot.AxisType.X,e),yaxis:this.makeLayoutAxis(t.plot.AxisType.Y,e),zaxis:this.makeLayoutAxis(t.plot.AxisType.Z,e)}};return n.datarevision=0,n}hydrateSettings(e){const{dh:t}=this;return{...e,type:e.type!=null?t.plot.SeriesPlotStyle[e.type]:void 0}}}const ht=de;const ns=J.module("Chart");class ui extends v.Component{static defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Zs.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},Plotly:hr,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.PlotComponent=sh(e.Plotly),this.plot=oe.createRef(),this.plotWrapper=oe.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;PlotComponent;plot;plotWrapper;columnFormats;dateTimeFormatterOptions;decimalFormatOptions;integerFormatOptions;rect;ranges;isSubscribed;isLoadedFired;getCachedConfig=ce((e,t,n,s,i)=>{const o=[],l=Boolean(e);if(l&&o.push({name:`Downsampling failed: ${e}`,title:"Downsampling failed",click:()=>{},icon:ui.convertIcon(Zc),attr:"fill-warning"}),t||n||s||l){const a=ui.downsampleButtonTitle(n,s),d=ui.downsampleButtonAttr(n,s),h=n?ng:sg;o.push({name:a,title:"Downsampling status",icon:ui.convertIcon(h),click:this.handleDownsampleClick,attr:d})}return{displaylogo:!1,displayModeBar:n||l?!0:"hover",modeBarButtons:[o,["toImage"],i?["zoom3d","pan3d"]:["zoom2d","pan2d"],i?["orbitRotation","tableRotation","resetCameraDefault3d"]:["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){ns.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(ns.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:ns.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,n=ht.getLayoutRanges(t);!Ze(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(e){if(ns.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,n=[...e.hiddenlabels];t({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([e,t]){if(ns.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){ns.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=Wn.getColumnFormats(e),n=Wn.getDateTimeFormatterOptions(e),{decimalFormatOptions:s={},integerFormatOptions:i={}}=e;(!Ze(this.columnFormats,t)||!Ze(this.dateTimeFormatterOptions,n)||!Ze(this.decimalFormatOptions,s)||!Ze(this.integerFormatOptions,i))&&(this.columnFormats=Wn.getColumnFormats(e),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const{model:e}=this.props,t=new gn(e.dh,this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions);e.setFormatter(t)}updateDimensions(){const e=this.getPlotRect(),{Plotly:t}=this.props;this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&t.relayout(this.plot.current.el,{autosize:!0}).catch(n=>{ns.debug("Unable to resize, promise rejected",n)})}render(){const{PlotComponent:e}=this,{data:t,downsamplingError:n,isDownsampleFinished:s,isDownsampleInProgress:i,isDownsamplingDisabled:o,layout:l,revision:a}=this.state,d=this.getCachedConfig(n,s,i,o,t?.[0].type?.includes("3d")??!1),h=t!=null;return r.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:h&&r.jsx(e,{ref:this.plot,data:t,layout:l,revision:a,config:d,onAfterPlot:this.handleAfterPlot,onError:ns.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}}const iC=ui,Tt=J.module("FigureChartModel");class Cr extends Pn{static ADD_SERIES_DEBOUNCE=50;constructor(e,t,n={},s=kt){super(e),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.dh=e,this.chartUtils=new ht(e),this.figure=t,this.settings=n,this.theme=s,this.data=[];const i={data:{},layout:this.chartUtils.makeDefaultLayout(s)};this.layout={grid:{rows:t.rows,columns:t.cols,pattern:"independent"},template:i},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()}chartUtils;dh;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=ht.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{dh:s}=this,i=ht.groupArray(t,"type"),o=this.chartUtils.makeSeriesDataFromSeries(e,i,ht.getSeriesVisibility(e.name,this.settings),n,this.theme);if(this.seriesDataMap.set(e.name,o),this.data=[...this.seriesDataMap.values()],e.plotStyle===s.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===s.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=ht.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===s.plot.SeriesPlotStyle.PIE?n??void 0:!1,e.oneClick!=null){const{oneClick:l}=e,{columns:a}=l;for(let d=0;d<a.length;d+=1)this.filterColumnMap.set(a[d].name,a[d]);this.oneClicks.push(l)}this.updateLayoutFormats()}addPendingSeries=We(()=>{const e=ht.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){Tt.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?this.dh.plot.DownsampleOptions.DISABLE:this.dh.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){const{dh:e}=this;this.figure.addEventListener(e.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(e.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(e.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(e.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(e.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){const{dh:e}=this;this.figure.removeEventListener(e.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(e.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(e.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(e.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(e.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}getTimeZone=we((e,t)=>{if(t!=null){const n=t.getColumnTypeFormatter(e);if(n!=null)return n.dhTimeZone}});getValueTranslator=we((e,t)=>{const n=this.getTimeZone(e,t);return s=>this.chartUtils.unwrapValue(s,n)});getValueParser=we((e,t)=>{const n=this.getTimeZone(e,t);return s=>this.chartUtils.wrapValue(s,e,n)});getRangeParser=we((e,t)=>n=>{let[s,i]=n;const o=this.getValueParser(e,t);return s=o(s),i=o(i),[s,i]});getAxisRangeParser=we((e,t)=>n=>{const s=ht.getSourceForAxis(e,n);return s!=null?this.getRangeParser(s.columnType,t):i=>i});handleDownsampleStart(e){Tt.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){Tt.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){Tt.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){Tt.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:n}=t;Tt.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];Tt.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){Tt.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){Tt.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){Tt.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;Tt.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=ht.DEFAULT_MARGIN.t+t*ht.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=ht.DEFAULT_TITLE_PADDING.t+t*ht.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();this.chartUtils.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;this.chartUtils.getAxisFormats(this.figure,this.formatter).forEach((t,n)=>{Tt.debug(`Assigning ${n}`,this.layout[n],t);const s=this.layout[n];s!=null?Object.assign(s,t):Tt.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(e,t,n){const{name:s,plotStyle:i}=e,o=this.seriesDataMap.get(s),l=this.chartUtils.getPlotlyProperty(i,t);o&&_c(o,l,n)}cleanSeries(e){const{dh:t}=this,{name:n,plotStyle:s}=e,i=this.seriesDataMap.get(n);if(i!=null){if(s===t.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:o,xHigh:l}=i;if(o&&l&&o.length===l.length){const a=[];for(let d=0;d<o.length;d+=1)a.push(l[d]-o[d]);i.width=a}}else if(s===t.plot.SeriesPlotStyle.LINE){const{x:o,xLow:l,xHigh:a,y:d,yLow:h,yHigh:u}=i;l&&a&&l!==o&&(i.error_x=ht.getPlotlyErrorBars(o,l,a)),h&&u&&h!==d&&(i.error_y=ht.getPlotlyErrorBars(d,h,u))}else if(s===t.plot.SeriesPlotStyle.TREEMAP){const{ids:o,labels:l}=i;o!==void 0&&l===void 0&&(i.labels=o)}}}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){Tt.warn("Trying to set a filter, but no one click!");return}Tt.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 Ld=Cr;class Sr{static async makeModelFromSettings(e,t,n,s=kt){const i=await Sr.makeFigureFromSettings(e,t,n);return new Ld(e,i,t,s)}static async makeFigureFromSettings(e,t,n){const s=await n.copy();return s.applyCustomColumns(n.customColumns),s.applyFilter(n.filter),s.applySort(n.sort),e.plot.Figure.create(new ht(e).makeFigureSettings(t,s))}static async makeModel(e,t,n,s=kt){return new Ld(e,n,t,s)}}const gl=Sr,oC=sh(hr);function _d(c){return c.setFigure!==void 0}const lC=J.module("HeapUsage");function aC({connection:c,defaultUpdateInterval:e,hoverUpdateInterval:t,bgMonitoring:n=!0,monitorDuration:s}){const[i,o]=v.useState({freeMemory:0,maximumHeapSize:999,totalHeapSize:0}),[l,a]=v.useState(!1),d=v.useRef({timestamps:[],usages:[]});v.useEffect(function(){const k=async()=>{try{const M=await c.getWorkerHeapInfo();if(o(M),n||l){const $=(M.totalHeapSize-M.freeMemory)/M.maximumHeapSize,H=Date.now(),{timestamps:K,usages:L}=d.current;for(;K.length!==0&&H-K[0]>s*1.5;)K.shift(),L.shift();K.push(H),L.push($)}else d.current={timestamps:[],usages:[]}}catch(M){lC.warn("Unable to get heap usage",M)}};k();const _=setInterval(k,l?t:e);return()=>{clearInterval(_)}},[l,t,c,e,s,n]);const h=(O,k)=>Math.round(O*10**k)/10**k,u=2,m=1024**3,{freeMemory:g,totalHeapSize:p,maximumHeapSize:f}=i,C=h(g/m,u),S=h(p/m,u),b=h(f/m,u),w=S-C,T=(O,k,_=!1)=>r.jsxs("div",{className:z("heap-usage-info-row",{"heading-bottom-border":_}),children:[r.jsx("div",{className:"font-weight-bold",children:O}),r.jsx("div",{children:k})]}),{timestamps:E,usages:y}=d.current,R=E[E.length-1]??0,I=p/f,x=(p-g)/f;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"max-memory",children:[r.jsx("div",{className:"total-memory",style:{width:`calc(${I*100}% - ${I*2}px`}}),r.jsx("div",{className:z("used-memory",{"heap-overflow":(p-g)/f>.95}),style:{width:`calc(${x*100}% - ${x*2}px`}}),r.jsxs("div",{className:"memory-text",children:[b.toFixed(1)," GB"]})]}),r.jsx(Je,{onEntered:()=>a(!0),onExited:()=>a(!1),interactive:!0,children:r.jsxs("div",{className:"heap-tooltip",children:[T("In use:",`${w.toFixed(u)} of ${b.toFixed(u)} GB`,!0),T("Free:",`${C.toFixed(u)} GB`),T("Total:",`${S.toFixed(u)} GB`),T("Max:",`${b.toFixed(u)} GB`),r.jsx("div",{className:"heap-plot",children:r.jsx(oC,{data:[{x:[...E],y:[...y],type:"scatter",mode:"lines"}],config:{staticPlot:!0,responsive:!0},style:{width:"196px",height:"100px"},layout:{margin:{l:2,t:2,r:2,b:2},plot_bgcolor:"transparent",paper_bgcolor:"transparent",colorway:["#4878ea"],xaxis:{dtick:Math.round(s/6),gridcolor:kt.linecolor,range:[R-s,R],linecolor:kt.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:kt.linecolor,range:[0,1],linecolor:kt.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({}),rC=new Map,zl=c=>c.api,fh=c=>c.user,wr=c=>c.storage,Ch=c=>wr(c).commandHistoryStorage,Sh=c=>wr(c).fileStorage,dC=c=>wr(c).workspaceStorage,Kl=c=>c.workspace,gt=c=>Kl(c).data.settings,bh=c=>gt(c).defaultDateTimeFormat,wh=c=>gt(c).defaultDecimalFormatOptions??br,vh=c=>gt(c).defaultIntegerFormatOptions??br,Th=c=>gt(c).formatter,go=c=>gt(c).timeZone,Eh=c=>gt(c).showTimeZone,yh=c=>gt(c).showTSeparator,Rh=c=>gt(c).truncateNumbersWithPound,cC=c=>gt(c).shortcutOverrides,hC=c=>gt(c).defaultNotebookSettings??br,Yl=c=>c.activeTool,uC=c=>c.plugins??rC,xh="SET_ACTIVE_TOOL",Ih="SET_API",Dh="SET_COMMAND_HISTORY_STORAGE",Fh="SET_FILE_STORAGE",Nh="SET_PLUGINS",kh="SET_USER",Mh="SET_WORKSPACE",Ah="SET_WORKSPACE_STORAGE",Oh="SET_SERVER_CONFIG_VALUES",mC=c=>({type:kh,payload:c}),gC=c=>({type:Ih,payload:c}),Lh=c=>({type:Mh,payload:c}),pC=c=>({type:Ah,payload:c}),fC=c=>({type:Dh,payload:c}),CC=c=>({type:Fh,payload:c}),SC=c=>(e,t)=>{e(Lh(c));const{storage:n}=t(),{workspaceStorage:s}=n;return s.save(c)},_h=c=>(e,t)=>{const{workspace:n}=t(),{data:s}=n,i={...n,data:{...s,...c}};return e(SC(i))},ql=c=>e=>e(_h({settings:c})),Xl=c=>({type:xh,payload:c}),bC=c=>({type:Nh,payload:c}),wC=c=>({type:Oh,payload:c});function Ph(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 vC(c,e={},t=!0){return(n=e,s)=>{switch(s.type){case c:{const{id:i,payload:o}=s;return t&&Ze({payload:o},{payload:n[i]})?n:{...n,[i]:o}}default:return n}}}function Es(c,e){return(t=e,n)=>{switch(n.type){case c:return n.payload;default:return t}}}const TC=Es(Ih,null),EC=Es(xh,null),yC=Es(Nh,null),RC=Es(Dh,null),xC=Es(Fh,null),IC=Es(Ah,null),DC=Ja({commandHistoryStorage:RC,fileStorage:xC,workspaceStorage:IC}),FC=Ph(kh,null),NC=Ph(Mh,null),kC=Es(Oh,null),MC={activeTool:EC,api:TC,plugins:yC,storage:DC,user:FC,workspace:NC,serverConfigValues:kC},AC=MC;class OC{reducers={};listener=null;register(e,t){this.reducers={...this.reducers,[e]:t},this.listener?.(this.reducers)}setListener(e){this.listener=e}}const LC=new OC,po=LC,Pd=J.module("redux-logger"),_C=c=>e=>t=>{Pd.debug("dispatching",t);const n=e(t);return Pd.debug("next state",c.getState()),n},PC=_C,jC=J.module("redux-crashReporter"),HC=c=>e=>t=>{try{return e(t)}catch(n){throw jC.error("Error executing",t," with state ",c.getState(),":",n),n}},UC=HC,BC=[PC,UC,Xu];Object.entries(AC).map(([c,e])=>po.register(c,e));const VC=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__??Ju,jh=Zu(Ja(po.reducers),VC(Qu(...BC)));po.setListener(c=>{jh.replaceReducer(Ja(c))});const vr=jh,Hh=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 Uh(c){return c.componentName!==void 0}function $C(c){return c.component!==void 0}const Bh=Object.freeze({type:"default",isClosable:!0,isFocusOnShow:!0,reorderEnabled:!0,title:""}),WC=Object.freeze(Object.defineProperty({__proto__:null,defaultConfig:Hh,isGLComponentConfig:Uh,isReactComponentConfig:$C,itemDefaultConfig:Bh},Symbol.toStringTag,{value:"Module"}));class pl{static ALL_EVENT="__all";_mSubscriptions;constructor(){this._mSubscriptions={},this._mSubscriptions[pl.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[pl.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=pl;class Ba extends pn{width;height;title;parent;layoutManager;tab;_config;isHidden=!1;beforeCloseHandler;_element=le(['<div class="lm_item_container">','<div class="lm_content" tabindex="-1"></div>',"</div>"].join(""));_contentElement;constructor(e,t,n){super(),this.title=Uh(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(le.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 GC=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 $h(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 zC(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 KC(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 le.trim(c.replace(/(<([^>]+)>)/gi,""))}class YC 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=le(document),this._eBody=le(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=YC;class Wh{_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=le.extend(e,this._container._config.props);return oe.createElement(this._reactClass,t)}}const fl=["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"],qC=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"];function yr(c){if(fl.length>36)throw new Error("Too many keys in config minifier map");const e={};return Rr(c,e,"_min"),e}function Va(c){if(fl.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"?XC: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,fl);e[l]=o}Rr(i,o,t)}else{const o=n(i,qC);if(Array.isArray(e))e[Number.parseInt(s,10)]=o;else{const l=n(s,fl);e[l]=o}}}}function XC(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 $a{name;origin;isPropagationStopped;constructor(e,t){this.name=e,this.origin=t,this.isPropagationStopped=!1}stopPropagation(){this.isPropagationStopped=!0}}let QC=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),le(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(){le(window).off("gl_child_event",this._boundOnEventFromChild)}};const Gh=QC,JC=Object.freeze(Object.defineProperty({__proto__:null,BubblingEvent:$a,DragListener:fo,EventEmitter:pn,EventHub:Gh,ReactComponentHandler:Wh,animFrame:Zl,filterXss:KC,getHashValue:Vh,getQueryStringParam:$h,getUniqueId:Tr,minifyConfig:yr,removeFromArray:zC,stripTags:Er,unminifyConfig:Va},Symbol.toStringTag,{value:"Module"}));class zh 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=le.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;le(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=le(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(),le(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 Kh{_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(le.extend(!0,{},n)),i=new Di(e,t,this._dragListener,this._layoutManager,s,null);this._layoutManager.transitionIndicator?.transitionElements(this._element,i.element)}}class Yh{_element=le(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(le.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=le(Ql._template);constructor(){le(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=le('<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 eS extends Error{node;constructor(e,t){super(),this.name="Configuration Error",this.message=e,this.node=t}}const zs=eS,tS=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationError:zs},Symbol.toStringTag,{value:"Module"}));function oo(c){return c.isStack}function jt(c){return c.isComponent}function qh(c){return c.isRoot}class ut 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&&jt(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 $a(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(Bh)){const s=t;e[s]===void 0&&(e[s]=n)}return e}_propagateEvent(e,t){t instanceof $a&&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 Xh extends ut{config;componentName;container;parent;instance;constructor(e,t,n){super(e,t,n,le()),this.config=t,this.parent=n;const s=e.getComponent(this.config.componentName)||e.getFallbackComponent(),i=le.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(){ut.prototype._$init.call(this),this.container.emit("open")}_$hide(){this.container.hide(),ut.prototype._$hide.call(this)}_$show(){this.container.show(),this.container._config.isFocusOnShow&&this.container._contentElement[0].focus({preventScroll:!0}),ut.prototype._$show.call(this)}_$destroy(){this.container.emit("destroy",this),ut.prototype._$destroy.call(this)}_$getArea(){return null}}class Cl extends ut{isRow;isColumn;childElementContainer;parent;_splitter=[];_splitterSize;_splitterGrabSize;_isColumn;_dimension;_splitterPosition=null;_splitterMinPosition=null;_splitterMaxPosition=null;constructor(e,t,n,s){super(t,n,s,le('<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),ut.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));ut.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(ut.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 Zh(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 Wa extends ut{childElementContainer;_containerElement;constructor(e,t,n){super(e,{...t,type:"root"},null,le('<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(jt(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 Cl)||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 Ga extends ut{_activeContentItem=null;_header;childElementContainer=le('<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,le('<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(){ut.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(jt(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 nS=Object.freeze(Object.defineProperty({__proto__:null,AbstractContentItem:ut,Component:Xh,ContentItem:ut,Root:Wa,RowOrColumn:Cl,Stack:Ga,isComponent:jt,isRoot:qh,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=le(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),jt(this.contentItem)&&(this.contentItem.container._contentElement.on("focusin",this._onTabContentFocusIn).on("focusout",this._onTabContentFocusOut),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),jt(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(){le(".lm_focusin",this._layoutManager.root.element).removeClass("lm_focusin"),this.element.addClass("lm_focusin")}_onTabContentFocusOut(){jt(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&&jt(this.contentItem)?this.header.parent.setActiveContentItem(this.contentItem):jt(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.contentItem.container._contentElement.focus(),jt(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(),jt(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=le(vi._template);tabsContainer;tabDropdownContainer;tabDropdownSearch;tabDropdownList=null;controlsContainer;parent;tabs=[];activeContentItem=null;closeButton=null;tabDropdownButton=null;tabNextButton=le(vi._nextButtonTemplate);tabPreviousButton=le(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(),le(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"),le(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(),le(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)-(le(window).scrollTop()??0);t+e>(le(window).height()??0)&&this.tabDropdownContainer.css("max-height",(le(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 Zh{_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=le('<div class="lm_drag_handle"></div>'),t=le('<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 Qh{_element=le('<div class="lm_transition_indicator"></div>');_toElement=null;_fromDimensions={};_totalAnimationDuration=200;_animationStartTime=null;constructor(){le(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 sS=Object.freeze(Object.defineProperty({__proto__:null,BrowserPopout:zh,DragProxy:Di,DragSource:Kh,DragSourceFromEvent:Yh,DropTargetIndicator:Ql,Header:vi,HeaderButton:Yi,Splitter:Zh,Tab:Jl,TransitionIndicator:Qh},Symbol.toStringTag,{value:"Module"})),iS={config:WC,container:GC,controls:sS,errors:tS,items:nS,utils:JC},oS=iS;class Jh extends pn{static __lm=oS;static minifyConfig(e){return yr(e)}static unminifyConfig(e){return Va(e)}isInitialised=!1;_isFullPage=!1;_resizeTimeoutId;_components={"lm-react-component":Wh};_fallbackComponent;_itemAreas=[];_maximisedItem=null;_maximisePlaceholder=le('<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 Gh(this);config;container;_originalContainer;dropTargetIndicator=null;transitionIndicator=null;tabDropPlaceholder=le('<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&&le("body").css("visibility","hidden"),this._typeToItem={column:Cl.bind(this,!0),row:Cl.bind(this,!1),stack:Ga,component:Xh}}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 ut))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){le(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 Qh,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(),le(window).off("resize",this._onResize),le(window).off("unload beforeunload",this._onUnload),le(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 Ga)&&t&&!(this.isSubWindow===!0&&t instanceof Wa)&&(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 ut,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 zh(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 Kh(e,t,this);return this._dragSources.push(n),n}createDragSourceFromEvent(e,t){return this.config.settings.constrainDragToContainer=!1,new Yh(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 ut)return e;if(le.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&&le(window).resize(this._onResize),le(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=$h("gl-window");t&&(this.isSubWindow=!0,e=JSON.parse(localStorage.getItem(t)||"{}"),e=Va(e),localStorage.removeItem(t)),e=le.extend(!0,{},Hh,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=le('<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??""),le("head").append(le("body link, body style, template, .gl_keep")),this.container=le("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?le(this._originalContainer):le("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,le("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 Wa(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 lS="_lm_root_15d73_3",aS="_lm_row_15d73_7",rS="_lm_item_15d73_7",dS="_lm_content_15d73_11",cS="_lm_dragging_15d73_17",hS="_lm_maximised_15d73_23",uS="_lm_maximise_placeholder_15d73_30",mS="_lm_splitter_15d73_34",gS="_lm_vertical_15d73_41",pS="_lm_drag_handle_15d73_41",fS="_lm_horizontal_15d73_46",CS="_lm_header_15d73_56",SS="_lm_dropdown_open_15d73_63",bS="_lm_controls_15d73_69",wS="_lm_tabs_15d73_89",vS="_lm_tab_15d73_89",TS="_lm_title_15d73_104",ES="_lm_close_tab_15d73_111",yS="_lm_stack_15d73_120",RS="_lm_left_15d73_120",xS="_lm_right_15d73_121",IS="_lm_dragProxy_15d73_125",DS="_lm_items_15d73_148",FS="_lm_tabdropdown_list_15d73_165",NS="_lm_bottom_15d73_192",kS="_lm_drop_tab_placeholder_15d73_207",MS="_lm_tabdropdown_15d73_165",AS="_lm_dropTargetIndicator_15d73_258",OS="_lm_inner_15d73_264",LS="_lm_transition_indicator_15d73_272",_S="_lm_popin_15d73_282",PS="_lm_bg_15d73_297",jS="_lm_icon_15d73_300",HS="_lm_goldenlayout_15d73_304",US="_lm_selectable_15d73_340",BS="_lm_active_15d73_370",VS="_lm_selected_15d73_388",$S="_lm_keyboard_active_15d73_397",WS="_lm_popout_15d73_416",GS="_lm_maximise_15d73_23",zS="_lm_close_15d73_111",KS="_lm_tabnextbutton_15d73_425",YS="_lm_tabpreviousbutton_15d73_428",qS="_lm_title_before_15d73_544",XS="_lm_focusin_15d73_568",ZS="_lm_window_blur_15d73_573",QS="_lm_tabdropdown_search_15d73_631",JS="_march_15d73_1",eb="_app_15d73_712",tb="_plotly_15d73_721",jd={"tab-height":"28px","drag-border-width":"5px",lm_root:lS,lm_row:aS,lm_item:rS,lm_content:dS,lm_dragging:cS,lm_maximised:hS,lm_maximise_placeholder:uS,lm_splitter:mS,lm_vertical:gS,lm_drag_handle:pS,lm_horizontal:fS,lm_header:CS,lm_dropdown_open:SS,lm_controls:bS,lm_tabs:wS,lm_tab:vS,lm_title:TS,lm_close_tab:ES,lm_stack:yS,lm_left:RS,lm_right:xS,lm_dragProxy:IS,lm_items:DS,lm_tabdropdown_list:FS,lm_bottom:NS,lm_drop_tab_placeholder:kS,lm_tabdropdown:MS,lm_dropTargetIndicator:AS,lm_inner:OS,lm_transition_indicator:LS,lm_popin:_S,lm_bg:PS,lm_icon:jS,lm_goldenlayout:HS,lm_selectable:US,lm_active:BS,lm_selected:VS,lm_keyboard_active:$S,lm_popout:WS,lm_maximise:GS,lm_close:zS,lm_tabnextbutton:KS,lm_tabpreviousbutton:YS,lm_title_before:qS,"editor-unsaved-indicator":"_editor-unsaved-indicator_15d73_548","is-unsaved":"_is-unsaved_15d73_556",lm_focusin:XS,lm_window_blur:ZS,lm_tabdropdown_search:QS,march:JS,app:eb,"js-plotly-plot":"_js-plotly-plot_15d73_721",plotly:tb},Hd=Object.freeze({tabHeight:parseInt(jd["tab-height"],10),dragBorderWidth:parseInt(jd["drag-border-width"],10)}),ss=J.module("LayoutUtils");function eu(c){return c.componentName!==void 0}function mi(c){const e=c;return(eu(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 V{static DEFAULT_FOCUS_SELECTOR="input, select, textarea, button";static activateTab(e,t){const n=V.getStackForRoot(e,t,!1);if(!n){ss.error("Could not find stack for config",t);return}const s=V.getContentItemInStack(n,t);s&&n.setActiveContentItem(s)}static isActiveTab(e,t){const n=V.getStackForRoot(e,t,!1);if(!n)return ss.error("Could not find stack for config",t),!1;const s=V.getContentItemInStack(n,t);return n.getActiveContentItem()===s}static addStack(e,t=!0){const n=t?"column":"row";if(qh(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=V.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):ss.debug2(`dehydrateLayoutConfig: skipping unmapped component "${o}"`)}else if(l){const a={...i,content:V.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,V.dropLayoutMinorChange(s)):mi(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=V.cloneLayout(e),i=V.cloneLayout(t);return V.dropLayoutMinorChange(s),V.dropLayoutMinorChange(i),Ze(s,i)}return Ze(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(mi(i)){const{component:o,props:l={}}=i;n.push({...i,id:i?.id??Ge(),props:t(o,l)})}else if(i.content!==void 0){const o=V.hydrateLayoutConfig(i.content,t);Ud(i)&&i.activeItemIndex!=null&&i.activeItemIndex>=o.length&&(ss.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=Ge.generate()),l){e?.layoutManager.createDragSourceFromEvent(d,l);return}const h=s||{id:d.id,component:d.component};D(e);const u=i?V.addStack(e):V.getStackForRoot(e,h);D(u);const m=V.getContentItemInStack(u,h);if(o!=null){const g=p=>{ss.debug("Component created, focusing element",o),u.off("componentCreated",g);const{element:f}=p.origin;requestAnimationFrame(()=>{V.focusElement(f[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=V.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=V.getStackForRoot(e,t,!1,!1,!1);if(!s){ss.warn("Cannot find stack for component, ignoring close",t);return}const i=V.getContentItemInStack(s,t),o=document.activeElement;i&&(jt(i)?i.container.close(n):s.removeChild(i)),o&&document.contains(o)&&Po(o)&&o.focus()}static renameComponent(e,t,n){const s=V.getStackForRoot(e,t,!1);if(!s){ss.error("Could not find stack for config",t);return}const i=V.getContentItemInStack(s,t);i&&i.setTitle(n)}static cloneComponent(e,t){const n=V.getStackForRoot(e,t,!1);if(!n)return ss.error("Could not find stack for config",t),null;const{props:s={}}=t,i=V.getPanelComponentState(t),o={type:"react-component",component:t.component,props:{...s,panelState:i},title:`${t.title} Copy`,id:Ge.generate()};return V.openComponentInStack(n,o),o}static getPanelComponentState(e){return eu(e)?e.componentState?.panelState:mi(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=V.getComponentConfigFromContainer(e);return t?t.id:null}static getIdFromPanel(e){const{glContainer:t}=e.props;return V.getIdFromContainer(t)}static getComponentNameFromPanel(e){const{glContainer:t}=e.props,n=V.getComponentConfigFromContainer(t);return n&&mi(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=V.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 tu=oe.forwardRef((c,e)=>{const t=V.getComponentNameFromPanel({props:c});return r.jsxs("div",{ref:e,className:"panel-placeholder",children:['Component "',t,'" is not registered.']})});tu.displayName="PanelPlaceholder";const Se=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 Bd(c){return c?.WrappedComponent!==void 0}function nb(c){return typeof c.id=="string"&&c.layout instanceof Jh&&c.panelManager instanceof nu&&typeof c.registerComponent=="function"}function ys(c){if(!nb(c))throw new Error(`Expected dashboard plugin props, but instead received ${c}`)}const qt=J.module("PanelManager");class nu{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(Se.FOCUS,this.handleFocus),e.on(Se.MOUNT,this.handleMount),e.on(Se.UNMOUNT,this.handleUnmount),e.on(Se.REOPEN,this.handleReopen),e.on(Se.DELETE,this.handleDeleted),e.on(Se.CLOSED,this.handleClosed),e.on(Se.CLOSE,this.handleControlClose)}stopListening(){const{eventHub:e}=this.layout;e.off(Se.FOCUS,this.handleFocus),e.off(Se.MOUNT,this.handleMount),e.off(Se.UNMOUNT,this.handleUnmount),e.off(Se.REOPEN,this.handleReopen),e.off(Se.DELETE,this.handleDeleted),e.off(Se.CLOSED,this.handleClosed),e.off(Se.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 V.getComponentConfigFromContainer(t)})}getOpenedPanelConfigsOfType(e){return this.getOpenedPanelConfigs().filter(t=>t!=null&&mi(t)&&t.component===e)}getOpenedPanelById(e){return this.openedMap.get(e)}getContainerByPanelId(e){const t=V.getStackForConfig(this.layout.root,{id:e});return(t&&V.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=>Bd(n)&&t instanceof n.WrappedComponent||!Bd(n)&&t instanceof n))}updatePanel(e){const t=V.getIdFromPanel(e);if(t==null){qt.error("updatePanel Panel did not have an ID",e);return}qt.debug2(`Updating panel ID ${t} in open panels map`),this.openedMap.delete(t),this.openedMap.set(t,e)}removePanel(e){const t=V.getIdFromPanel(e);if(t==null){qt.error("removePanel Panel did not have an ID",e);return}if(!this.openedMap.has(t)){qt.error(`Missing panel ID ${t} in open panels map`);return}if(this.openedMap.get(t)!==e){qt.debug(`Panel argument doesn't match the open panels map entry for ${t}, removePanel ignored`);return}qt.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){qt.debug2("Focus: ",e),this.updatePanel(e)}handleMount(e){qt.debug2("Mount: ",e),this.updatePanel(e),this.sendUpdate()}handleUnmount(e){qt.debug2("Unmount: ",e),this.removePanel(e),this.sendUpdate()}handleReopen(e,t){qt.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;V.openComponent({root:o,config:i,replaceConfig:t})}handleDeleted(e){qt.debug2("Deleted:",e),this.removeClosedPanelConfig(e),this.sendUpdate()}handleClosed(e,t){qt.debug2("Closed: ",e),this.addClosedPanel(t),this.sendUpdate()}handleControlClose(e){const t={id:e},{root:n}=this.layout;V.closeComponent(n,t)}addClosedPanel(e){const t=V.getComponentConfigFromContainer(e);if(t&&mi(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 sb=J.module("PanelErrorBoundary");class ib extends v.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}componentWillUnmount(){const{glContainer:e,glEventHub:t}=this.props,n=V.getIdFromContainer(e);sb.debug("componentWillUnmount",n),t.emit(Se.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(Ul,{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 za={dehydrate:xr,hydrate:Ir},ob=U.shape({on:U.func,off:U.func,isHidden:U.bool,tab:U.shape({header:U.shape({tabs:U.arrayOf(U.shape({contentItem:U.shape({})}))})}),title:U.string,setTitle:U.func,close:U.func}),su=U.shape({on:U.func,off:U.func,emit:U.func}),lb=U.shape({registerComponent:U.func,root:U.shape({addChild:U.func}),on:U.func,off:U.func,eventHub:su}),Dr=Object.freeze({Container:ob,EventHub:su,Layout:lb}),_e=(c,e,t)=>v.useEffect(function(){return c.on(e,t),()=>{c.off(e,t)}},[c,e,t]),iu="SET_DASHBOARD_DATA",ab=vC(iu,{},!1),rb={dashboardData:ab},db=new Map,cb=Object.freeze({}),hb=Object.freeze([]),ub=c=>c.dashboardData,Ot=(c,e)=>ub(c)[e]??cb,mb=(c,e)=>Ot(c,e).closed??hb,ou=(c,e)=>Ot(c,e).openedMap??db,lu=(c,e)=>({type:iu,id:c,payload:e}),kn=(c,e)=>(t,n)=>t(lu(c,{...Ot(n(),c),...e}));Object.entries(rb).map(([c,e])=>po.register(c,e));const jo=J.module("DashboardLayout"),gb=Object.freeze({}),pb=[],Vd=()=>{},$d=c=>c;function au({id:c,children:e,emptyDashboard:t=r.jsx("div",{children:"Dashboard is empty."}),layout:n,layoutConfig:s=pb,onLayoutChange:i=Vd,onLayoutInitialized:o=Vd,hydrate:l=Ir,dehydrate:a=xr}){const d=vs(),h=er(),u=em(L=>Ot(L,c))??gb,[m,g]=v.useState(!1),[p,f]=v.useState(!1),[C,S]=v.useState(),[b]=v.useState(u?.closed??[]),[w,T]=v.useState(!1),E=v.useMemo(()=>new Map,[]),y=v.useMemo(()=>new Map,[]),R=tm(),I=v.useCallback((L,G,ee=l,W=a)=>{jo.debug2("registerComponent",L,G,ee,W);function j(se,ae){const q=G,{dh:ne,glContainer:he,glEventHub:Te}=se;return r.jsx(ig.Provider,{value:ne??d,children:r.jsx(Pc,{store:R,children:r.jsx(ib,{glContainer:he,glEventHub:Te,children:r.jsx(q,{...se,ref:ae})})})})}const B=oe.forwardRef(j),Z=n.registerComponent(L,B);return E.set(L,ee),y.set(L,W),Z},[d,l,a,E,y,n,R]),x=v.useCallback((L,G)=>(E.get(L)??$d)(G,c),[E,c]),O=v.useCallback((L,G)=>(y.get(L)??$d)(G,c),[y,c]),k=v.useMemo(()=>new nu(n,x,O,new Map,b,({closed:L,openedMap:G})=>{h(kn(c,{closed:L,openedMap:G}))}),[O,h,x,c,b,n]),_=v.useCallback(()=>{if(p)return;w||(o(),T(!0));const G=n.toConfig().content,ee=V.dehydrateLayoutConfig(G,O),W=C==null||!V.isEqual(C,ee);jo.debug("handleLayoutStateChanged",W,G,ee),W&&(g(n.root.contentItems.length===0),S(ee),i(ee))},[O,w,p,C,n,i,o]),M=v.useCallback(L=>{const G=V.getIdFromContainer(L);n.eventHub.emit(Se.DRAGGING,G),f(!0)},[n.eventHub]),$=v.useCallback(L=>{const G=V.getIdFromContainer(L);n.eventHub.emit(Se.DROPPED,G),f(!1)},[n.eventHub]),H=v.useCallback(L=>{if(jo.debug2("handleComponentCreated",L),L==null||L.config==null||L.config.component==null||L.element==null)return;const ee=`${L.config.component.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}-component`;L.element.addClass(ee)},[]);_e(n,"stateChanged",_),_e(n,"itemPickedUp",M),_e(n,"itemDropped",$),_e(n,"componentCreated",H),_e(n.eventHub,Se.TITLE_CHANGED,_);const K=nr(s);return v.useEffect(function(){if(K!==s&&s!==C){jo.debug("Setting new layout content...");const G=V.hydrateLayoutConfig(s,x);for(;n.root.contentItems.length>0;)n.root.contentItems[0].remove();for(let ee=0;ee<G.length;ee+=1)n.root.addChild(G[ee]);g(n.root.contentItems.length===0)}},[x,n,s,C,k,K]),r.jsxs(r.Fragment,{children:[m&&t,oe.Children.map(e,L=>L!=null?oe.cloneElement(L,{id:c,layout:n,panelManager:k,registerComponent:I}):null)]})}au.propTypes={id:U.string.isRequired,children:U.node,data:U.shape({}),emptyDashboard:U.node,layout:Dr.Layout.isRequired,layoutConfig:U.arrayOf(U.shape({})),onLayoutChange:U.func,onLayoutInitialized:U.func};const fb=100,Ca=()=>{},Cb=Object.freeze({});function Sb({id:c="default",children:e,emptyDashboard:t,layoutConfig:n,layoutSettings:s=Cb,onLayoutConfigChange:i=Ca,onGoldenLayoutChange:o=Ca,onLayoutInitialized:l=Ca,fallbackComponent:a=tu,hydrate:d,dehydrate:h}){const u=v.useRef(null),[m,g]=v.useState(!1),[p,f]=v.useState();v.useEffect(function(){if(!u.current){f(void 0);return}const b={...V.makeDefaultLayout()};b.settings===void 0&&(b.settings={}),Object.assign(b.settings,s),b.content=[];const w=new Jh(b,u.current),T=()=>{w.off("initialised",T),g(!0)};return w.on("initialised",T),a!=null&&w.setFallbackComponent(a),w.init(),f(w),o(w),()=>{w.destroy()}},[s,a,o,g,f]);const C=v.useMemo(()=>bs(()=>{p!=null&&p.isInitialised&&p?.updateSize()},fb),[p]);return v.useEffect(function(){return window.addEventListener("resize",C),()=>{window.removeEventListener("resize",C)}},[C]),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(au,{emptyDashboard:t,id:c,layout:p,layoutConfig:n,onLayoutChange:i,onLayoutInitialized:l,hydrate:d,dehydrate:h,children:e})]})}const un="default";class bb extends Error{isAssertionFailed=!0}const ru=bb;function Wd(c){if(c==null)throw new ru(`Expected 'val' to be defined, but received ${c}`)}class wb extends Error{isPasteError=!0}const Sa=wb;function ze(c){return c?.isEditable!==void 0}function Gd(c){if(!ze(c))throw new ru(`Expected 'model' to be editable, but received ${c}`)}function Pe(c){return c?.hasExpandableRows!==void 0}var mn=(c=>(c.DOWN="DOWN",c.UP="UP",c.LEFT="LEFT",c.RIGHT="RIGHT",c))(mn||{});class Q{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 Q(...Q.normalize(e,t,n,s))}static makeCell(e,t){return new Q(e,t,e,t)}static makeColumn(e){return new Q(e,null,e,null)}static makeRow(e){return new Q(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=Q.minOrNull(i.startColumn,l.startColumn),u=Q.maxOrNull(i.endColumn,l.endColumn);n=!0,t[s]=new Q(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=Q.minOrNull(i.startRow,l.startRow),u=Q.maxOrNull(i.endRow,l.endRow);n=!0,t[s]=new Q(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 Q(n,s,i,o)}static subtractFromRange(e,t){const n=[],s=Q.intersection(e,t);return s==null?[e]:(s.startRow!=null&&(e.startRow==null||e.startRow<s.startRow)&&n.push(new Q(e.startColumn,e.startRow,e.endColumn,s.startRow-1)),s.startColumn!=null&&(e.startColumn==null||e.startColumn<s.startColumn)&&n.push(new Q(e.startColumn,s.startRow,s.startColumn-1,s.endRow)),s.endColumn!=null&&(e.endColumn==null||e.endColumn>s.endColumn)&&n.push(new Q(s.endColumn+1,s.startRow,e.endColumn,s.endRow)),s.endRow!=null&&(e.endRow==null||e.endRow>s.endRow)&&n.push(new Q(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(...Q.subtractFromRange(e[s],t));return n}static subtractRangesFromRanges(e,t){let n=[...e];for(let s=0;s<t.length;s+=1)n=Q.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 Q.isBounded(e)?e:new Q(e.startColumn??0,e.startRow??0,e.endColumn??t-1,e.endRow??n-1)}static boundedRanges(e,t,n){return e.map(s=>Q.boundedRange(s,t,n))}static offset(e,t,n){return new Q(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=Q.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 Q.SELECTION_DIRECTION.DOWN:case Q.SELECTION_DIRECTION.RIGHT:{const o=i<e.length-1?i+1:0;return e[o].startCell(s)}case Q.SELECTION_DIRECTION.LEFT:case Q.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=Q.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 Q.isAxisRangeTouching(this.startRow,this.endRow,e.startRow,e.endRow)&&Q.isAxisRangeTouching(this.startColumn,this.endColumn,e.startColumn,e.endColumn)}subtract(e){return Q.subtractFromRange(this,e)}startCell(e=Q.SELECTION_DIRECTION.DOWN){if(!Q.isBounded(this))throw new Error("Cannot get the startCell of an unbounded range");switch(e){case Q.SELECTION_DIRECTION.DOWN:case Q.SELECTION_DIRECTION.RIGHT:return{column:this.startColumn,row:this.startRow};case Q.SELECTION_DIRECTION.LEFT:case Q.SELECTION_DIRECTION.UP:return{column:this.endColumn,row:this.endRow};default:throw new Error(`Invalid direction: ${e}`)}}nextCell(e,t,n){if(!Q.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 Q.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 Q.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 Q.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 Q.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=Q.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 Re=Q;function vb(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 vb(c)&&c[0]!=null&&c[1]!=null}function Sl(c){return c?.href!==void 0}class A{static PIXELS_PER_LINE=100/3;static getGridPointFromXY(e,t,n){const s=A.getColumnAtX(e,n),i=A.getRowAtY(t,n),o=A.getColumnHeaderDepthAtY(t,n);return{x:e,y:t,row:i,column:s,columnHeaderDepth:o}}static getCellInfoFromXY(e,t,n){const{row:s,column:i}=A.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,f=s!==null?d.get(s):null,C=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:f??null,columnWidth:C??null,rowHeight:S??null}}static getColumnHeaderDepthAtY(e,t){const n=A.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=A.iterateFloatingStart(e,n,s);return i!==void 0?i:A.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=A.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:A.iterateFloating(n,s,t,h=>{if(A.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(A.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 A.getNextShownItem(e,n,s,i)}static getNextShownRow(e,t){const{modelRows:n,visibleRows:s,userRowHeights:i}=t;return A.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 f=e-i,C=p*.5;let S=!1;for(let b=l.length-1;b>=0;b-=1){const w=l[b],T=h.get(w)??0,E=u.get(w)??0,y=E===0;if(!S||!y){let R=T+E;y?R+=C:S&&(R-=C);const I=R-C,x=R+C;if(I<=f&&f<=x)return w;S=y}}S=!1;for(let b=d.length-1;b>=0;b-=1){const w=d[b],T=h.get(w)??0,E=u.get(w)??0,y=E===0;if(T<a-E)return null;if(!S||!y){let R=T+E;y?R+=C:S&&(R-=C);const I=R-C,x=R+C;if(I<=f&&f<=x)return w;S=y}}return null}static isItemHidden(e,t){return t.get(e)===0}static isColumnHidden(e,t){const{allColumnWidths:n}=t;return A.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(!A.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(!A.isItemHidden(l,t))break;s.push(l)}return s}static getHiddenColumns(e,t){const{visibleColumns:n,allColumnWidths:s}=t;return A.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 f=l.length-1;f>=0;f-=1){const C=l[f],S=a.get(C)??0,b=d.get(C)??0,w=b===0;if(!p||!w){let T=S+b;w?T+=g:p&&(T-=g);const E=T-g,y=T+g;if(E<=m&&m<=y)return C;p=w}}return null}static isRowHidden(e,t){const{allRowHeights:n}=t;return A.isItemHidden(e,n)}static getHiddenRows(e,t){const{visibleRows:n,allRowHeights:s}=t;return A.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 A.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)?A.moveRange(e,t,n,s):A.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,f=[];for(let C=0;C<i.length;C+=1){const S=i[C][0]??Number.NEGATIVE_INFINITY,b=i[C][1]??Number.POSITIVE_INFINITY;let w;const T=[[S,u-1],[u,m],[m+1,b]].map(([E,y])=>[Math.max(E,S),Math.min(y,b)]).filter(([E,y])=>E<=y).map(E=>{const[y,R]=E;return u<=y&&m>=R?(w=[y+p,R+p],w):m<y?[y-d,R-d]:E}).map(E=>{const[y,R]=E;return g>y&&g<=R?[[y,g-1],[g+d,R+d]]:E===w?[E]:g<=y?[[y+d,R+d]]:[E]}).flat();f.push(...T)}i=f.map(([C,S])=>[Number.isFinite(C)?C:null,Number.isFinite(S)?S:null])}return i}static translateRange(e,t,n,s){const i=A.applyItemMoves(e.startColumn,e.endColumn,t,s),o=A.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 Re(d[0],u[0],d[1],u[1]))}}return l}static getModelIndex(e,t){return A.applyItemMoves(e,e,t,!0)[0][0]}static getModelIndexes(e,t){return e.map(n=>A.getModelIndex(n,t))}static getModelRangeIndexes(e,t,n){return A.applyItemMoves(e,t,n,!0)}static getModelRange(e,t=Ie,n=Ie){return A.translateRange(e,t,n,!0)}static getModelRanges(e,t=Ie,n=Ie){const s=[];for(let i=0;i<e.length;i+=1)s.push(...A.getModelRange(e[i],t,n));return s}static getVisibleRangeIndexes(e,t,n){return A.applyItemMoves(e,t,n,!1)}static getVisibleRange(e,t=Ie,n=Ie){return this.translateRange(e,t,n,!1)}static getVisibleRanges(e,t=Ie,n=Ie){const s=[];for(let i=0;i<e.length;i+=1)s.push(...A.getVisibleRange(e[i],t,n));return s}static getVisibleIndex(e,t){return A.applyItemMoves(e,e,t)[0][0]}static getVisibleIndexes(e,t){return e.map(n=>A.getVisibleIndex(n,t))}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return A.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){const t=A.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:f,columnCount:C,rowCount:S}=e;let b=s,w=i,T=o,E=l;return n!=null&&(n>h&&(b+=m),n<C-u&&(T-=g)),t!=null&&(t>a&&(w+=p),t<S-d&&(E-=f)),{x1:b,y1:w,x2:T,y2:E}}static getScrollDelta(e,t=1024,n=768,s=20,i=20){let{deltaX:o,deltaY:l}=e;return!A.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&&(A.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),f=Ae(a+s,a,h-m),C=Ae(a+o,a,h-m);return{x1:g,y1:f,x2:p,y2:C,token:e.token}}static findTokensWithProtocolInText(e){return Lc(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+=N(s,l);o=n;for(let l=0;l<e&&t-l-1>=0;l+=1)o-=N(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:f,columnWidth:C,columnHeaderHeight:S,minScrollHandleSize:b,scrollBarSize:w}=a;h!==this.movedRows&&(this.movedRows=h,this.modelRows.clear()),u!==this.movedColumns&&(this.movedColumns=u,this.modelColumns.clear());const{columnCount:T,rowCount:E,floatingTopRowCount:y,floatingBottomRowCount:R,floatingLeftColumnCount:I,floatingRightColumnCount:x,columnHeaderMaxDepth:O}=d,k=this.getFirstRow(e),_=this.getFirstColumn(e),M=this.getGridX(e),$=this.getGridY(e),H=Pe(d)&&d.hasExpandableRows?this.calculateTreePaddingX(e):0,K=0,L=this.getVisibleRowHeights(e),G=this.getVisibleColumnWidths(e,_,H),ee=Array.from(L.keys()),W=Array.from(G.keys()),j=new Map([...L,...this.getFloatingRowHeights(e)]),B=new Map([...G,...this.getFloatingColumnWidths(e)]),Z=this.getVisibleColumnXs(B,W,s),se=this.getVisibleRowYs(j,ee,i),ae=ee.length>0?ee[ee.length-1]:n,q=W.length>0?W[W.length-1]:t,ne=this.getBottomViewport(e,ee,se,j),he=this.getRightViewport(e,W,Z,B),Te=this.getFloatingTopHeight(e,j),ye=this.getFloatingBottomHeight(e,j),rt=this.getFloatingLeftWidth(e,B),wt=this.getFloatingRightWidth(e,B),Wt=Array.from(B.values()),fn=Array.from(j.values()),xt=Wt.reduce((Ne,Kt)=>Ne+Kt,0)-s,Ee=fn.reduce((Ne,Kt)=>Ne+Kt,0)-i,lt=s+xt+f,et=i+Ee,pt=o-M,It=l-$,Cn=this.getLastLeft(e,null,pt-f),Gt=this.getLastLeft(e,null,pt-f-w),So=this.getLastTop(e,null,It-ye),Rs=this.getLastTop(e,null,It-ye-w);let zt=Gt,Zn=Rs;Cn===0&&So===0&&(zt=0,Zn=0);const ei=zt>0,Ni=ei?w:0,ti=Zn>0,ni=ti?w:0,bo=M,wo=O*S,Qn=o-bo-ni,xs=l-wo-Ni,ia=T===1?Qn/lt:(T-zt)/T,vo=E===1?xs/et:(E-Zn)/E,ki=ei?Ae(Qn*ia,b,Qn-1):0,Mi=ti?Ae(xs*vo,b,xs-1):0,Ai=N(B,t,0),To=N(j,n,0),oa=Ai>0?s/Ai:0,la=To>0?i/To:0,aa=T===1?s/(lt-pt):(t+oa)/zt,ra=E===1?i/(et-It):(n+la)/Zn,da=ei?aa*(Qn-ki):0,Is=ti?ra*(xs-Mi):0,Eo=[...Array(y).keys(),...[...Array(R).keys()].map(Ne=>E-Ne-1)],si=new Map([...se,...this.getFloatingRowYs(e,j,Math.floor(l-$-Ni))]),yo=[...Array(I).keys(),...[...Array(x).keys()].map(Ne=>T-Ne-1)],Ds=new Map([...Z,...this.getFloatingColumnXs(e,B,Math.floor(o-M-ni))]),Ro=[];if(m)for(let Ne=m.range[0];Ne<=m.range[1];Ne+=1)Ro.push(Ne),B.has(Ne)||B.set(Ne,this.getVisibleColumnWidth(Ne,e)),Ds.has(Ne)||Ds.set(Ne,0);const Oi=ee.concat(Eo),Li=W.concat(yo).concat(Ro),xo=this.getModelRows(Oi,e),Io=this.getModelColumns(Li,e),Do=this.getVisibleRowTreeBoxes(j,xo,e),ca=this.getTopVisible(e,si,j,ee),Fo=this.getLeftVisible(e,Ds,B,W),No=Zn>0?this.getBottomVisible(e,si,j,ee,$):ae,ko=zt>0?this.getRightVisible(e,Ds,B,W,M):q,{fontWidths:Mo,userColumnWidths:Ao,userRowHeights:Oo,calculatedRowHeights:ha,calculatedColumnWidths:Ue}=this;return{rowHeight:g,rowHeaderWidth:p,rowFooterWidth:f,rowCount:E,columnWidth:C,columnCount:T,columnHeaderHeight:S,floatingTopRowCount:y,floatingBottomRowCount:R,floatingLeftColumnCount:I,floatingRightColumnCount:x,gridX:M,gridY:$,firstRow:k,firstColumn:_,treePaddingX:H,treePaddingY:K,left:t,top:n,bottom:ae,right:q,topOffset:i,leftOffset:s,topVisible:ca,leftVisible:Fo,bottomVisible:No,rightVisible:ko,bottomViewport:ne,rightViewport:he,width:o,height:l,maxX:xt,maxY:Ee,lastLeft:zt,lastTop:Zn,barHeight:xs,barTop:wo,barWidth:Qn,barLeft:bo,handleHeight:Mi,handleWidth:ki,hasHorizontalBar:ei,hasVerticalBar:ti,verticalBarWidth:ni,horizontalBarHeight:Ni,scrollX:da,scrollY:Is,scrollableContentWidth:lt,scrollableContentHeight:et,scrollableViewportWidth:pt,scrollableViewportHeight:It,visibleRows:ee,visibleColumns:W,visibleRowHeights:L,visibleColumnWidths:G,floatingRows:Eo,floatingColumns:yo,allRows:Oi,allColumns:Li,allRowHeights:j,allColumnWidths:B,floatingTopHeight:Te,floatingBottomHeight:ye,floatingLeftWidth:rt,floatingRightWidth:wt,visibleRowYs:se,visibleColumnXs:Z,allRowYs:si,allColumnXs:Ds,visibleRowTreeBoxes:Do,modelRows:xo,modelColumns:Io,movedRows:h,movedColumns:u,fontWidths:Mo,userColumnWidths:Ao,userRowHeights:Oo,calculatedRowHeights:ha,calculatedColumnWidths:Ue,columnHeaderMaxDepth:O}}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=N(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=N(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 Pe(i)&&i.hasExpandableRows&&e.forEach((d,h)=>{const u=N(t,h);if(i.isRowExpandable(u)){const m=i.depthForRow(u),g=m*l+a,p=(m+1)*l+a,f=0,C=d;s.set(h,{x1:g,y1:f,x2:p,y2:C})}}),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+=N(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+=N(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+=N(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+=N(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(N(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(N(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=N(t,m),p=N(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=N(t,m),p=N(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=N(t,o)+N(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 N(this.modelRows,e);const{movedRows:n}=t,s=A.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 N(this.modelColumns,e);const{movedColumns:s}=t,i=A.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:f,scrollBarSize:C}=l;let S=0;const b=this.getWidthForFont(u,t),w=s/g,T=Math.ceil(n+w);return A.iterateAllItems(n,T,a,d,h,E=>{const y=this.getModelRow(E,t),R=o.textForCell(e,y);if(R){const I=m*2;S=Math.max(S,R.length*b+I)}}),S=Math.max(Math.min(S,(i-p-C-f)*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(!Pe(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 N(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 Tb=Co,Eb=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"}),yb=Eb,Rb=(c,e)=>{let t=!1;const n=we(c,{...e,dispose:()=>{t||(t=!0,n.clear(),t=!1)}});return n},Bn=Rb;function xb(c,e,t=6){const n=La.hex.lab.raw(c);return n[0]=Math.max(n[0]-n[0]/t*e,0),`#${La.lab.hex(n)}`}function Ib(c,e){const[t,n,s]=La.hex.rgb(c);return`rgba(${t}, ${n}, ${s}, ${e})`}const Kd={colorWithAlpha:Ib,darkenForDepth:xb};class ot{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 Db extends ot{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 f=N(l,p),C=n-a-f-this.dragOffset,S=N(h,p),b=this.targetSizes.get(S),w=this.resizingItems.length>1,T=this.hiddenItems.indexOf(p);let E=N(d,S);p===u&&(E+=m);let y=C;Math.abs(C-E)<=o.headerResizeSnapThreshold?y=E:b!==void 0&&C>b&&(w&&T!==0||T>0)?y=b:C<=o.headerResizeHiddenSnapThreshold&&(y=0),g.set(S,y),C<-o.headerResizeSnapThreshold&&y===0?T>=0&&w?(this.resizingItems.pop(),this.removeTargetSize(i,p),p=this.resizingItems[this.resizingItems.length-1],this.dragOffset-=this.targetSizes.get(N(h,p))??0):(p=this.getNextShownItem(p,i),p!==null&&(this.resizingItems.push(p),this.addTargetSize(i,p))):b!==void 0&&C>b+o.headerResizeSnapThreshold&&y===b?T>0?(this.dragOffset+=y,p=this.hiddenItems[T-1],this.resizingItems.push(p),this.addTargetSize(i,p)):w?(this.resizingItems.pop(),this.removeTargetSize(i,p),p=this.resizingItems[this.resizingItems.length-1]):p=null:p=null}return g.forEach((f,C)=>{const S=s[this.initialSizesProperty].get(C)??d.get(C);f===S?this.resetSize(s,C):this.setSize(s,C,f)}),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=N(a,l.index),h=N(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];N(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=N(n,t);let a=s.get(l);(a==null||a===0)&&(a=N(i,l)+o),this.targetSizes.set(l,a)}removeTargetSize(e,t){const n=e[this.modelIndexesProperty],s=N(n,t);this.targetSizes.delete(s)}}const du=Db;class Fr extends du{static getColumnSeparator(e,t,n,s){if(!s.allowColumnResize)return null;const{x:i,y:o,columnHeaderDepth:l}=e,{modelColumns:a}=t,d=A.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=A.getHiddenColumns;getNextShownItem=A.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 cu=Fr;class Nt{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=Nt.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=Nt.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 Nt.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:N(m,l-1)+N(g,l-1)-.5}),a>0&&this.drawSelectedRanges(e,t,{top:h-a-1,bottom:h-1,minY:N(m,h-a)+.5,maxY:N(m,h-1)+N(g,h-1)-.5});for(let p=0;p<u.length;p+=1){const f=u[p];for(let C=0;C<d.length;C+=1){const S=d[C];this.drawCellContent(e,t,f,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:f,allColumnXs:C,allColumnWidths:S,width:b,height:w}=i;if(u.length!==0){o.floatingRowBackgroundColors&&(this.drawRowStripesForRows(e,t,f,o.floatingRowBackgroundColors,0,d),this.drawRowStripesForRows(e,t,f,o.floatingRowBackgroundColors,b-m-h,g)),n==null&&s==null&&this.drawFloatingMouseRowHover(e,t),e.save(),e.beginPath(),e.rect(0,0,d,w),e.clip(),this.drawGridLinesForItems(e,t,u,f,o.floatingGridColumnColor,o.floatingGridRowColor),e.restore(),this.drawCellBackgroundsForItems(e,t,u,f),this.drawFloatingBorders(e,t),l>0&&this.drawSelectedRanges(e,t,{left:0,maxX:N(C,l-1)+N(S,l-1)}),a>0&&this.drawSelectedRanges(e,t,{left:p-a,right:p-1,minX:N(C,p-a)+.5,maxX:N(C,p-1)+N(S,p-1)});for(let T=0;T<u.length;T+=1){const E=u[T];for(let y=0;y<f.length;y+=1){const R=f[y];this.drawCellContent(e,t,E,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:f,maxY:C}=n,{floatingDividerOuterColor:S,floatingDividerInnerColor:b}=s;if(e.lineWidth=3,e.beginPath(),e.strokeStyle=S,i>0){const w=N(u,i-1)+N(g,i-1)+.5;e.moveTo(0,w),e.lineTo(f,w)}if(o>0){const w=N(u,d-o)-.5;e.moveTo(0,w),e.lineTo(f,w)}if(l>0){const w=N(m,l-1)+N(p,l-1)+.5;e.moveTo(w,0),e.lineTo(w,C)}if(a>0){const w=N(m,h-a)-.5;e.moveTo(w,0),e.lineTo(w,C)}if(e.stroke(),e.beginPath(),e.lineWidth=1,e.strokeStyle=b,i>0){const w=N(u,i-1)+N(g,i-1)+.5;e.moveTo(0,w),e.lineTo(f,w)}if(o>0){const w=N(u,d-o)-.5;e.moveTo(0,w),e.lineTo(f,w)}if(l>0){const w=N(m,l-1)+N(p,l-1)+.5;e.moveTo(w,0),e.lineTo(w,C)}if(a>0){const w=N(m,h-a)-.5;e.moveTo(w,0),e.lineTo(w,C)}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:f,allColumnWidths:C,width:S,height:b}=s;this.drawSelectedRanges(e,t,{bottom:Math.min(i,m-l-1),right:Math.min(o,u-d-1),minX:a>0&&f.has(a+1)?N(f,a+1):-10,minY:h>0&&p.has(h+1)?N(p,h+1):-10,maxX:d>0&&f.has(u-d-1)?N(f,u-d-1)+N(C,u-d-1)-.5:S+10,maxY:l>0&&p.has(m-l-1)?N(p,m-l-1)+N(g,m-l-1)-.5:b+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:f}=a,C=new Map,S=[],b=[],w=(T,E)=>{const y=Pe(d)?d.depthForRow(T):0,R=g[T%g.length],I=R[Math.min(y,R.length-1)];if(C.has(I)||C.set(I,[]),C.get(I).push(T),E!=null){const x=Pe(d)?d.depthForRow(E):0;x<y?S.push(T):x>y&&b.push(E)}};for(let T=0;T<n.length;T+=1){const E=n[T],y=T>0?n[T-1]:void 0;w(E,y)}if(C.forEach((T,E)=>{e.fillStyle=E,e.beginPath();for(let y=0;y<T.length;y+=1){const R=T[y],I=N(p,R),x=N(f,R);e.rect(i,I,o,x)}e.fill()}),S.length>0){e.save();const T=this.getCachedColorWithAlpha(m,.15),E=this.getCachedColorWithAlpha(m,0),y=e.createLinearGradient(0,0,0,u);y.addColorStop(0,T),y.addColorStop(1,E),e.fillStyle=y;for(let R=0;R<S.length;R+=1){const I=S[R],x=N(p,I);e.translate(0,x),e.fillRect(i,0,o,u),e.translate(0,-x)}e.restore()}if(b.length>0){e.save();const T=this.getCachedColorWithAlpha(m,0),E=this.getCachedColorWithAlpha(m,.15),y=e.createLinearGradient(0,0,0,u);y.addColorStop(0,T),y.addColorStop(1,E),e.fillStyle=y;for(let R=0;R<b.length;R+=1){const I=b[R],x=N(p,I),O=N(f,I),k=x+O-u;e.translate(0,k),e.fillRect(i,0,o,u),e.translate(0,-k)}e.restore()}}drawMouseColumnHover(e,t){const{mouseX:n,mouseY:s,theme:i,metrics:o}=t;if(n==null||s==null)return;const l=A.getColumnAtX(n,o);if(l==null||i.columnHoverBackgroundColor==null)return;const{allColumnWidths:a,allColumnXs:d,maxY:h}=o;if(s>h)return;const u=N(d,l),m=N(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=A.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=A.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=N(a,n),u=N(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=N(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=N(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:f}=o,C=N(u,s),S=N(h,n),b=l.backgroundColorForCell(S,C,a),w=n===d,T=Pe(l)&&l.hasExpandableRows;if(b!=null){const E=N(m,n)+1,y=N(p,s)+1,R=N(g,n)-1,I=N(f,s)-1;e.fillStyle=b,e.fillRect(E,y,R,I)}w&&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=N(i,n),h=N(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:f,treeHorizontalPadding:C}=o,S=N(m,n),b=N(g,t),w=i.textAlignForCell(b,S),T=N(a,t),E=N(h,n),y=N(d,t),R=N(u,n),I=t===l;let x=0;Pe(i)&&i.hasExpandableRows&&I&&(x=f*(i.depthForRow(n)+1)+C);const O=y-x;let k=T+p;const _=E+R*.5;return w==="right"?k=T+O-p:w==="center"&&(k=T+O*.5),k+=x,{width:O-p*2,x:k,y:_}}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,f=N(g,s),C=N(m,s),S=N(u,n),b=i??l.textForCell(S,C),w=l.truncationCharForCell(S,C),T=n===d;if(b&&f>0){const E=l.textAlignForCell(S,C)||"left";e.textAlign=E;const y=l.colorForCell(S,C,a)||p;e.fillStyle=y,e.save();const{width:R,x:I,y:x}=this.getTextRenderMetrics(t,n,s),O=h.get(e.font)??Nt.DEFAULT_FONT_WIDTH,k=this.getCachedTruncatedString(e,b,R,O,w),_=l.tokensForCell(S,C,k.length);if(k){let M=0,$=0,H=I;const{actualBoundingBoxDescent:K}=e.measureText(k);for(;$<k.length;){const L=_[M],G=$===L?.start?L:null,ee=G?.end??L?.start??k.length,W=k.substring($,ee),{width:j}=e.measureText(W),B=W.endsWith("…")?e.measureText(W.substring(0,W.length-1)).width:j;G!=null?(e.fillStyle=a.hyperlinkColor,e.fillText(W,H,x),e.fillRect(H,x+K,B,1)):(e.fillStyle=y,e.fillText(W,H,x)),H+=j,$=ee,G!=null&&(M+=1)}}e.restore()}T&&Pe(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:f,visibleRowTreeBoxes:C}=s,{treeMarkerColor:S,treeMarkerHoverColor:b}=a,w=N(m,d),T=N(g,d),E=N(p,n),y=N(f,n);if(!Pe(i)||!i.isRowExpandable(n))return;const R=N(C,n),I=o!=null&&l!=null&&o>=h+w&&o<=h+w+T&&l>=u+E&&l<=u+E+y?b:S;this.drawTreeMarker(e,t,w,E,R,I,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(!Pe(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:f}=l,C=N(h,d),S=N(u,n),b=N(m,n),w=s!==void 0?o.depthForRow(s):0,T=a>w?a-w:0;if(e.strokeStyle=f,e.lineWidth=1,a-T>0){e.beginPath();for(let E=0;E<a-T;E+=1){const y=C+E*g+g*.5+p+.5;e.moveTo(y,S),e.lineTo(y,S+b)}e.stroke()}if(T>0){e.beginPath();for(let E=a-T;E<a;E+=1){const y=C+E*g+g*.5+p+.5;e.moveTo(y,S),e.lineTo(y,S+Math.ceil(b/2)),e.moveTo(y-.5,S+Math.ceil(b/2)+.5),e.lineTo(y+g-.5,S+Math.ceil(b/2)+.5)}e.stroke()}}getCachedTruncatedString=Bn((e,t,n,s,i)=>Nt.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=>ih.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:f,allColumnXs:C,floatingLeftColumnCount:S,floatingLeftWidth:b,floatingRightWidth:w,modelColumns:T,columnHeaderMaxDepth:E}=o;if(h<=0)return;const{headerHiddenSeparatorSize:y,headerHiddenSeparatorHoverColor:R,headerSeparatorColor:I,headerSeparatorHoverColor:x}=i,O=h*.5,k=h*(E-1)+h*.5-O*.5,_=S>0;if(e.save(),this.drawColumnHeadersForRange(e,t,[p[0],p[p.length-1]],{minX:m+b,maxX:g-w}),_&&this.drawColumnHeadersForRange(e,t,[u[0],u[u.length-1]],{minX:m,maxX:m+b}),I){e.strokeStyle=I;const M=[...f.entries()].filter(([$,H])=>H===0).map(([$])=>$);e.beginPath(),e.fillStyle=I;for(let $=0;$<M.length;$+=1){const H=M[$],K=N(C,H),L=N(f,H),G=m+K+L+.5-y*.5;e.rect(G,k,y,O)}e.fill()}if(x){let{index:M,depth:$}=l??{};if(M==null&&n!=null&&s!=null){const K=cu.getColumnSeparator(A.getGridPointFromXY(n,s,o),o,d,i);M=K?.index,$=K?.depth}let H;if(M==null)H=!1;else{const K=T.get(M),L=T.get(M+1);K==null||L==null?H=!1:H=d.textForColumnHeader(K,$)!==d.textForColumnHeader(L,$)}if(H&&M!=null&&$!=null&&(!a||l!=null)){e.strokeStyle=x;const K=N(C,M),L=N(f,M),G=m+K+L+.5,ee=p.indexOf(M),W=ee<p.length-1?p[ee+1]:null,j=W!=null?f.get(W):null,B=L===0,Z=j!=null&&j===0;B?(e.strokeStyle=R,e.fillStyle=R,e.fillRect(G,k,y*.5,O)):Z&&(e.fillStyle=x,e.fillRect(G-y*.5,k,y*.5,O)),e.beginPath(),e.moveTo(G,(E-$-1)*h),e.lineTo(G,(E-$)*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:f,columnWidth:C}=a,{columnHeaderMaxDepth:S}=l,{minX:b,maxX:w}=s,T=w-b;if(S===0)return;const E=n[0],y=n[1];if(e.save(),e.translate(0,(S-i-1)*f),i===0){this.drawColumnHeader(e,t,"",b,w);for(let R=E;R<=y;R+=1)this.drawColumnHeaderAtIndex(e,t,R,s)}if(i>0){let R=E;for(;R<=y;){const{columnCount:I}=o,x=N(d,R),O=l.textForColumnHeader(x,i),k=l.colorForColumnHeader(x,i);let _=N(h,R)+u,M=_+N(g,R);if(O!=null){let $=R-1;for(;$>=0&&(M-_<T||_>b);){const G=d.get($)??A.getModelIndex($,p);if(G==null||l.textForColumnHeader(G,i)!==O)break;const ee=m.get(G)??g.get($)??C;_-=ee,$-=1}let H=R+1;for(;H<I&&(M-_<T||M<w);){const G=d.get(H)??A.getModelIndex(H,p);if(l.textForColumnHeader(G,i)!==O)break;const ee=m.get(G)??g.get(H)??C;M+=ee,H+=1}R=H-1;const K=M-_>=T;let L=_;K&&(M<w?L=M-T:_<b&&(L=b)),this.drawColumnHeader(e,t,O,L,Math.min(M-_,T),{backgroundColor:k??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=N(a,n),m=N(d,n)+h,g=N(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:f,white:C}=d,{fontWidths:S,width:b}=a,w=S.get(e.font)??Nt.DEFAULT_FONT_WIDTH,E=(i-h*2)/w,{backgroundColor:y=m,separatorColor:R=p}=o??{};let{textColor:I=g}=o??{};try{const B=this.getCachedColorIsDark(y),Z=this.getCachedColorIsDark(I);B&&Z?I=C:!B&&!Z&&(I=f)}catch{}let{minX:x=0,maxX:O=b}=l??{};e.save(),e.rect(x,0,O-x,u),e.clip(),y!=null&&(e.fillStyle=y,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=I;let k=n;E<=0?k="":k.length>E&&(k=`${k.substring(0,E-1)}…`);const _=k.length*w;let M=s+i*.5;const $=u*.5;x+=h,O-=h;const H=s+h,K=Ae(H,x,O),L=s+i-h,ee=Ae(L,x,O)-K,W=M-_*.5<x,j=M+_*.5>O;W?_<ee?M=x+_*.5:M=L-_*.5:j&&(_<ee?M=O-_*.5:M=H+_*.5),e.textAlign="center",e.fillText(k,M,$),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:f,headerHiddenSeparatorSize:C,headerHiddenSeparatorHoverColor:S,headerSeparatorColor:b,headerSeparatorHoverColor:w}=o,T=d*.5,E=d*.5-T*.5;if(e.save(),e.beginPath(),e.fillStyle=p,e.fillRect(0,0,d,h),b){e.strokeStyle=b,e.beginPath(),e.moveTo(0,a+.5),e.lineTo(d,a+.5);const y=[];let R=!1;for(let I=0;I<u.length;I+=1){const x=u[I],O=N(g,x),k=N(m,x);if(k>0){const _=a+O+k+.5;e.moveTo(0,_),e.lineTo(d,_),R=!1}else R||(R=!0,y.push(x))}e.moveTo(d-.5,0),e.lineTo(d-.5,h),e.stroke(),e.beginPath(),e.fillStyle=b;for(let I=0;I<y.length;I+=1){const x=y[I],O=N(g,x),k=N(m,x),_=a+O+k+.5-C*.5;e.rect(E,_,T,C)}e.fill()}if(w){let{index:y=null}=l??{};if(y==null&&n!=null&&s!=null&&(y=A.getRowSeparatorIndex(n,s,i,o)),y!=null){e.strokeStyle=w;const R=N(g,y),I=N(m,y),x=a+R+I+.5,O=u.indexOf(y),k=O<u.length-1?u[O+1]:null,_=k!=null?m.get(k):null,M=I===0,$=_!=null&&_===0;M?(e.strokeStyle=S,e.fillStyle=S,e.fillRect(E,x,T,C*.5)):$&&(e.fillStyle=w,e.fillRect(E,x-C*.5,T,C*.5)),e.beginPath(),e.moveTo(.5,x),e.lineTo(d+.5,x),e.stroke()}}e.beginPath(),e.rect(0,a,d,h),e.clip(),e.fillStyle=f,e.textAlign="right";for(let y=0;y<u.length;y+=1){const R=u[y],I=N(m,R),x=N(g,R)+a;this.drawRowHeader(e,t,R,x,I)}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=N(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:f,visibleRows:C,allRowHeights:S,allRowYs:b,width:w}=i;if(g<=0)return;const{cellHorizontalPadding:T,headerBackgroundColor:E,headerColor:y,headerHiddenSeparatorSize:R,headerHiddenSeparatorHoverColor:I,headerSeparatorColor:x,headerSeparatorHoverColor:O}=l,k=g*.5,_=g*.5-k*.5,M=Math.min(h+u,w-g-f);if(e.save(),e.beginPath(),e.fillStyle=E,e.fillRect(M,d,g,p),x){e.strokeStyle=x,e.beginPath(),e.moveTo(M,d+.5),e.lineTo(g,d+.5);const H=[];let K=!1;for(let L=0;L<C.length;L+=1){const G=C[L],ee=N(b,G),W=N(S,G);if(W>0){const j=d+ee+W+.5;e.moveTo(M+.5,j),e.lineTo(M+g-.5,j),K=!1}else K||(K=!0,H.push(G))}e.moveTo(M+.5,d),e.lineTo(M+.5,p),e.stroke(),e.beginPath(),e.fillStyle=x;for(let L=0;L<H.length;L+=1){const G=H[L],ee=N(b,G),W=N(S,G),j=d+ee+W+.5-R*.5;e.rect(M+_,j,k,R)}e.fill()}if(O){let{index:H=null}=a??{};if(H==null&&n!=null&&s!=null&&(H=A.getRowSeparatorIndex(n,s,i,l)),H!=null){e.strokeStyle=O;const K=N(b,H),L=N(S,H),G=d+K+L+.5,ee=C.indexOf(H),W=ee<C.length-1?C[ee+1]:null,j=W!=null?S.get(W):null,B=L===0,Z=j!=null&&j===0;B?(e.strokeStyle=I,e.fillStyle=I,e.fillRect(_,G,k,R*.5)):Z&&(e.fillStyle=O,e.fillRect(_,G-R*.5,k,R*.5)),e.beginPath(),e.moveTo(M+.5,G),e.lineTo(M+g+.5,G),e.stroke()}}e.beginPath(),e.rect(M,d,g,p),e.clip(),e.fillStyle=y,e.textAlign="left";const $=M+T;for(let H=0;H<C.length;H+=1){const K=C[H],L=N(S,K);if(L>0){const G=N(b,K)+d,ee=N(m,K),W=G+L*.5;e.fillText(o.textForRowFooter(ee),$,W)}}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:f,allRowYs:C,width:S,height:b}=d,{left:w=d.left,top:T=d.top,right:E=d.right,bottom:y=d.bottom,minY:R=-10,maxY:I=b+10,minX:x=-10,maxX:O=S+10}=n;if(u.length===0)return;const k=ze(h)&&h.isEditable&&a==null&&o==null&&l==null&&s!=null&&i!=null&&p.has(s)&&C.has(i);if(k){const _=N(p,s),M=N(C,i),$=N(g,s),H=N(f,i);e.save(),e.beginPath(),e.rect(0,0,S,b),e.rect(_,M,$,H),e.clip("evenodd")}e.beginPath();for(let _=0;_<u.length;_+=1){const M=u[_],$=M.startColumn!==null?M.startColumn:w,H=M.startRow!==null?M.startRow:T,K=M.endColumn!==null?M.endColumn:E,L=M.endRow!==null?M.endRow:y;if(L>=T&&y>=H&&K>=w&&E>=$){const G=$>=w&&p.has($)?Math.round(N(p,$))+.5:x,ee=H>=T&&C.has(H)?Math.max(Math.round(N(C,H))+.5,.5):R,W=K<=E&&p.has(K)?Math.round(N(p,K)+N(g,K))-.5:O,j=L<=y&&C.has(L)?Math.round(N(C,L)+N(f,L))-.5:I;e.rect(G,ee,W-G,j-ee)}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()}k&&s!=null&&i!=null&&(e.restore(),this.drawActiveCell(e,t,s,i))}drawActiveCell(e,t,n,s,i=Nt.ACTIVE_CELL_BORDER_WIDTH){const{metrics:o,theme:l}=t,{allColumnWidths:a,allColumnXs:d,allRowHeights:h,allRowYs:u}=o,m=N(d,n),g=N(u,s),p=N(a,n),f=N(h,s);let C=m-i*.5,S=g-i*.5,b=p+i,w=f+i;C<=0&&(b+=C-1,C=1),S<=0&&(w+=S-1,S=1);const{lineWidth:T}=e;e.beginPath(),e.lineWidth=i,e.strokeStyle=l.selectionOutlineColor,this.drawRoundedRect(e,C,S,b,w),e.stroke(),e.lineWidth=T}drawRoundedRect(e,t,n,s,i,o=Nt.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:f,columnHeaderMaxDepth:C,columnHeaderHeight:S,movedColumns:b,modelColumns:w,floatingLeftWidth:T}=s,E=w.get(a[0])??A.getModelIndex(a[0],b),y=l.getColumnHeaderGroup(E,d);if(d>0&&!y)return;const[R,I]=a,x=N(m,R),k=N(m,I)+N(g,I)-x,_=n.left,{backgroundColor:M,font:$,headerFont:H,reorderOffset:K,shadowBlur:L,shadowColor:G}=o,ee=(C-d-1)*S;e.save(),e.translate(h,0),e.save(),e.beginPath(),e.rect(T,0,f,p),e.clip(),e.fillStyle=M,e.fillRect(x,ee,k,p),e.restore(),e.translate(0,K),e.save(),e.shadowColor=G,e.shadowBlur=L,e.fillStyle=M,e.fillRect(n.left,ee+K,n.width,p),e.restore(),e.beginPath(),e.rect(n.left,ee,n.width+1,p),e.clip(),e.translate(_-x,0),e.font=H;const W=[];for(let j=n.range[0];j<=n.range[1];j+=1)W.push(j);this.drawColumnHeaders(e,t),this.drawColumnHeadersForRange(e,t,[W[0],W[W.length-1]],{minX:x,maxX:f}),e.translate(0,u),e.font=$,this.drawGridBackground(e,t);for(let j=R;j<=I;j+=1)this.drawColumnCellContents(e,t,j);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=N(h,n),p=N(u,n)+1,{backgroundColor:f,font:C,headerFont:S,reorderOffset:b,shadowBlur:w,shadowColor:T}=l;e.save(),e.translate(0,d),e.fillStyle=f,e.fillRect(0,g,m,p),e.translate(a+b,o-g-d-(s??0)),e.save(),e.shadowColor=T,e.shadowBlur=w,e.fillStyle=f,e.fillRect(-a,g,m,p),e.restore(),e.beginPath(),e.rect(-a,g,m,p),e.clip(),e.font=C,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:f,hasHorizontalBar:C,hasVerticalBar:S,barWidth:b,barHeight:w,barLeft:T,barTop:E}=o,{scrollBarBackgroundColor:y,scrollBarHoverBackgroundColor:R,scrollBarCasingColor:I,scrollBarCornerColor:x,scrollBarColor:O,scrollBarHoverColor:k,scrollBarActiveColor:_,scrollBarSize:M,scrollBarHoverSize:$,scrollBarCasingWidth:H,scrollBarSelectionTick:K,scrollBarSelectionTickColor:L,scrollBarActiveSelectionTickColor:G,autoSelectRow:ee,autoSelectColumn:W}=d,j=l!=null&&a!=null&&l<=h&&a<=u,B=s||S&&!n&&!i&&l!=null&&a!=null&&l>=h-$&&a>=E&&j,Z=n||C&&!s&&!i&&!B&&l!=null&&a!=null&&a>=u-$&&l>=T&&j,se=Z?$:M,ae=B?$:M;if(e.translate(T,E),C&&S&&(e.fillStyle=I,e.fillRect(h-T-M,u-E-M,M,M),e.fillStyle=x,e.fillRect(h-T-M+H,u-E-M+H,M-H,M-H)),C){const q=p,ne=u-E-se;if(e.fillStyle=I,e.fillRect(0,ne,b,se-H),e.fillStyle=Z?R:y,e.fillRect(0,ne+H,b,se-H),n?e.fillStyle=_:Z?e.fillStyle=k:e.fillStyle=O,e.fillRect(q,ne+H,g,se-H),!ee&&K&&L!=null&&G!=null){e.fillStyle=L;const{selectedRanges:he,cursorColumn:Te}=t,{lastLeft:ye,columnCount:rt}=o,Wt=[...he].filter(Ee=>Ee.startColumn!=null&&Ee.endColumn!=null).map(Ee=>[Ee.startColumn,Ee.endColumn]).sort(A.compareRanges),fn=A.mergeSortedRanges(Wt),xt=Ee=>Ee<=ye?Ee/ye*(b-g):b-g+(Ee-ye)/(rt-ye)*g;for(let Ee=0;Ee<fn.length;Ee+=1){const lt=fn[Ee],et=lt[0],pt=lt[1];if(et!=null&&pt!=null&&(et!==Te||pt!==Te)){const It=xt(et),Cn=Math.max(1,Math.round(xt(pt+1)-It)),Gt=se-H;e.fillRect(It,ne+H+Math.round(Gt/3),Cn,Math.round(Gt/3))}}if(Te!=null){const Ee=xt(Te),lt=2,et=se-H;e.fillStyle=G,e.fillRect(Ee,ne+H,lt,et)}}}if(S){const q=h-T-ae,ne=f;if(e.fillStyle=I,e.fillRect(q,0,ae-H,w),e.fillStyle=B?R:y,e.fillRect(q+H,0,ae-H,w),s?e.fillStyle=_:B?e.fillStyle=k:e.fillStyle=O,e.fillRect(q+H,ne,ae-H,m),!W&&K&&L!=null&&G!=null){const{selectedRanges:he,cursorRow:Te}=t,{lastTop:ye,rowCount:rt}=o,wt=Ee=>Ee<=ye?Ee/ye*(w-m):w-m+(Ee-ye)/(rt-ye)*m;e.fillStyle=L;const fn=[...he].filter(Ee=>Ee.startRow!=null&&Ee.endRow!=null).map(Ee=>[Ee.startRow,Ee.endRow]).sort(A.compareRanges),xt=A.mergeSortedRanges(fn);for(let Ee=0;Ee<xt.length;Ee+=1){const lt=xt[Ee],et=lt[0],pt=lt[1];if(et!=null&&pt!=null&&(et!==Te||pt!==Te)){const It=wt(et),Cn=ae-H,Gt=Math.max(1,Math.round(wt(pt+1)-It));e.fillRect(q+H+Math.round(Cn/3),It,Math.round(Cn/3),Gt)}}if(Te!=null){const Ee=Math.round(wt(Te)),lt=ae-H,et=2;e.fillStyle=G,e.fillRect(q+H,Ee,lt,et)}}}e.translate(-T,-E)}getTokenBoxesForVisibleCell(e,t,n){const{metrics:s,context:i,model:o,theme:l}=n;if(i==null||s==null)return Ie;const{modelRows:a,modelColumns:d}=s,h=N(a,t),u=N(d,e),m=o.textForCell(u,h),{width:g,x:p,y:f}=this.getTextRenderMetrics(n,e,t),{fontWidths:C}=s;i.save(),this.configureContext(i,n);const S=C?.get(i.font)??Nt.DEFAULT_FONT_WIDTH,b=o.truncationCharForCell(u,h),w=this.getCachedTruncatedString(i,m,g,S,b),{actualBoundingBoxAscent:T,actualBoundingBoxDescent:E}=i.measureText(w),y=T+E,R=o.tokensForCell(u,h,w.length);if(R.length===0)return i.restore(),Ie;const I=this.getCachedTokenBoxesForVisibleCell(w,R,l.font,"middle",y,i).map(x=>({x1:x.x1+p,y1:x.y1+(f-T),x2:x.x2+p,y2:x.y2+(f-T),token:x.token}));return i.restore(),I}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:f}=g,C=f>e.length?e.substring(p):g.value;u+=o.measureText(e.substring(h,p)).width;const S=o.measureText(C).width,b=u,w=b+S,T={x1:b,y1:0,x2:w,y2:a,token:g};d.push(T),h=f,u+=S}return d},{max:1e4})}const Fb=Nt,Yd=100;class Nb extends ot{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 f=A.isModifierKeyDown(n),C=n.shiftKey;f||(C?t.trimSelectedRanges():t.clearSelectedRanges());const S=t.getTheme(),{autoSelectRow:b,autoSelectColumn:w}=S;return(o!==null||!w)&&(l!==null||!b)&&(t.focus(),t.moveCursorToPosition(o,l,C,!1,C&&f)),this.startPoint=e,this.hasExtendedFloating=!1,this.dragBounds=A.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:f}=d,C=A.getScrollDragBounds(d,n,s);let S=0,b=0;if(h<u&&(i<C.x1?S=i-C.x1:i>C.x2&&(S=i-C.x2)),m<g&&(o<C.y1?b=o-C.y1:o>C.y2&&(b=o-C.y2)),S!==0||b!==0)this.startTimer(t,e,S>0?Math.ceil(S/p):Math.floor(S/p),b>0?Math.ceil(b/f):Math.floor(b/f));else if(l!=null&&a!=null){const{floatingTopRowCount:w,floatingBottomRowCount:T,floatingLeftColumnCount:E,floatingRightColumnCount:y,columnCount:R,rowCount:I,bottom:x,right:O,topVisible:k,bottomVisible:_,leftVisible:M,rightVisible:$}=d;this.hasExtendedFloating||(n!==null&&n<w&&l>=w?(l=w,this.hasExtendedFloating=!0):n!==null&&n>=I-T&&l<I-T&&(l=I-T-1,this.hasExtendedFloating=!0),s!==null&&s<E&&a>=E?(a=E,this.hasExtendedFloating=!0):s!==null&&s>=R-y&&a<R-y&&(a=R-y-1,this.hasExtendedFloating=!0)),n!==null&&!A.isFloatingRow(n,d)&&A.isFloatingRow(l,d)&&(n>l&&l<m?l=k-1:n<l&&l>x&&(l=_+1)),s!==null&&!A.isFloatingColumn(s,d)&&A.isFloatingColumn(a,d)&&(s>a&&a<h?a=M-1:s<a&&a>O&&(a=$+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,f=s>0&&i!=null?i:h-1;e.moveCursorToPosition(Math.min(Math.max(m,d+n),g),Math.min(Math.max(p,a+s),f),!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 kb=Nb,qd=5,Mb=1e3/60,Bo=10;function is(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)??A.getModelIndex(c,i),p=n.getColumnHeaderGroup(g,e),f=p!=null;let C,S,b;if(p!=null){const[w,T]=p.getVisibleRange(i);C=o.get(w)??u,S=(o.get(T)??m)+(a.get(T)??0),b=[w,T]}else{const w=o.get(c);if(w==null)return null;C=w,S=C+(a.get(c)??d.get(g)??h.get(g)??0),b=[c,c]}return{visibleIndex:c,modelIndex:g,left:C,right:S,width:S-C,isColumnGroup:f,range:b,depth:e}}class Ab extends ot{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-=Bo;m<0;){u-=1;const f=A.getModelIndex(s-1,d),C=l.get(f)??a.get(f);C===void 0?m=0:m+=C,u<0&&(m=0,u=0)}else{m+=Bo;let f=h.get(s);for(;f!==void 0&&m>f;){u+=1,m-=f;const C=A.getModelIndex(s+1,d);f=l.get(C)??a.get(C),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"?-Bo:Bo),e.setState({left:u,leftOffset:m}),(t==="left"&&u===0&&o===0||t==="right"&&u===i)&&this.clearScrollInterval())},Mb))}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=is(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=is(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=is(a.range[0],0,d,l),m=is(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=is(this.draggingColumn.range[0],s,l,i);if(!g)return;const p=e-this.draggingOffset,f=p+g.width;this.draggingColumn={...this.draggingColumn,left:p},t.setState({draggingColumn:this.draggingColumn});const C=is(A.getColumnAtX(Ae(m?p:f,a,d),l,!0),s,l,i),S=i.getColumnHeaderParentGroup(g.modelIndex,g.depth);if(!C)return;if(S!==void 0){const R=S.getVisibleRange(o);if(C.visibleIndex<R[0]){const I=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:I});return}if(C.visibleIndex>R[1]){const I=this.moveColumn(g,R[1]-(g.range[1]-g.range[0]),o),{right:x=0}=is(R[1],0,l,i)??{};this.draggingOffset=e-(x-g.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),t.setState({draggingColumn:this.draggingColumn,movedColumns:I});return}}if(!i.isColumnMovable(C.modelIndex)){let R=C.visibleIndex;if(m)for(R+=1;R<g.visibleIndex&&!i.isColumnMovable(A.getModelIndex(R,o));)R+=1;else for(R-=1;R>g.visibleIndex&&!i.isColumnMovable(A.getModelIndex(R,o));)R-=1;if(R!==g.visibleIndex){m||(R-=g.range[1]-g.range[0]);const x=this.moveColumn(g,R,o);t.setState({movedColumns:x,draggingColumn:this.draggingColumn})}const I=is(R,0,l,i);m?this.draggingOffset=e-(I?.left??0):this.draggingOffset=e-((I?.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"):f>d?this.setScrollInterval(t,"right"):this.clearScrollInterval(),C.visibleIndex===g.visibleIndex||m&&g.visibleIndex<C.visibleIndex||!m&&g.visibleIndex>C.visibleIndex)return;const b=C.left+C.width*.5,w=i.getColumnHeaderParentGroup(g.modelIndex,g.depth);let T,E=(w?.depth??h)-1;for(;E>=0&&T===void 0;)T=i.getColumnHeaderGroup(C.modelIndex,E),E-=1;let y;m&&p<b&&(!T||C.visibleIndex===T.getVisibleRange(o)[0])&&(y=this.moveColumn(g,C.range[0],o)),!m&&f>b&&(!T||C.visibleIndex===T.getVisibleRange(o)[1])&&(y=this.moveColumn(g,C.range[1]-(g.range[1]-g.range[0]),o)),y&&(this.draggingColumn={...this.draggingColumn,left:p},t.setState({movedColumns:y,draggingColumn:this.draggingColumn}))}moveColumn(e,t,n){const s=e.isColumnGroup?A.moveRange(e.range,t,n):A.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 Ob=Ab;class Nr extends ot{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 Lb=Nr;class _b extends ot{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=N(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:y}=t.getGridPointFromXY(i,o);if(y!=null&&!n.isRowMovable(y)||(s=y,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:f,height:C}=l;let S=g;if(a<s){const y=s-1;S=N(f,y)+N(p,y)*.5+g}let b=C;if(s<h){const y=s+1;b=N(f,y)+N(p,y)*.5+g}let{movedRows:w}=t.state;o<S&&s>0&&n.isRowMovable(s-1)?(w=A.moveItem(s,s-1,w),s-=1):b<o&&s<m-1&&n.isRowMovable(s+1)&&(w=A.moveItem(s,s+1,w),s+=1),t.setState({movedRows:w,draggingRow:s});const T=g+N(p,a)*.5,E=g+N(f,u)+N(p,u)*.5;return o<T&&a>0?t.setState({top:a-1}):o>E&&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 Pb=_b;class kr extends du{static getRowSeparator(e,t,n,s){if(!s.allowRowResize)return null;const{x:i,y:o}=e,l=A.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=A.getHiddenRows;getNextShownItem=A.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 jb=kr;class bl extends ot{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:f}=l;if(n===h&&s!=null&&f.get(s)!=null&&i>a&&o>d){const C=N(u,n),S=N(m,n),b=N(p,s),w=N(g,s);if(i>=a+C&&i<=a+C+S&&o>=d+b&&o<=d+b+w)return!0}return!1}onDown(e,t){return bl.isInTreeBox(e,t)}onClick(e,t,n){if(bl.isInTreeBox(e,t)){const{row:s}=e;if(s!==null)return t.toggleRowExpanded(s,A.isModifierKeyDown(n)),!0}return!1}}const Ka=bl;class Hb extends ot{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 Ub=Hb;class Mr extends ot{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 Bb=Mr;class Vb extends ot{onDoubleClick({column:e,row:t},n){const{model:s}=n.props;return ze(s)&&e!=null&&t!=null&&s.isEditableRange(Re.makeCell(e,t))?(n.startEditing(e,t),!0):!1}}const $b=Vb;class Ar extends ot{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(Sl(h[u].token)){const m=A.translateTokenBox(h[u],a),{x1:g,x2:p,y1:f,y2:C}=m;if(i>=g&&i<=p&&o>=f&&o<=C)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 A.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),ze(l)&&i!=null&&o!=null&&l.isEditableRange(Re.makeCell(i,o))&&t.startEditing(i,o)},Ar.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 Wb=Ar;class Gb{order;constructor(e=5e3){this.order=e}onDown(e,t){return!1}}const Js=Gb;class zb extends Js{onDown(e,t){switch(e.key){case"a":if(A.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 A.isModifierKeyDown(e)?!1:this.handlePageUp(e,t);case"j":case"J":return A.isModifierKeyDown(e)?!1:this.handlePageDown(e,t);case"h":case"H":return A.isModifierKeyDown(e)?!1:(e.shiftKey||t.clearSelectedRanges(),t.moveCursorToPosition(0,t.state.cursorRow,e.shiftKey),!0);case"l":case"L":{if(A.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(A.isModifierKeyDown(e)?t.state.cursorColumn:0,A.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(A.isModifierKeyDown(e)?t.state.cursorColumn:s-1,A.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?Re.SELECTION_DIRECTION.UP:Re.SELECTION_DIRECTION.DOWN),!0;break;case"Tab":if(t.state.selectedRanges.length>0)return t.moveCursorInDirection(e.shiftKey?Re.SELECTION_DIRECTION.LEFT:Re.SELECTION_DIRECTION.RIGHT),!0;break}return!1}handleArrowMove(e,t,n,s){const i=n.shiftKey,o=A.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:f}=g,C=o&&i;let S=null,b=null;e<0?(S=0,b=m):e>0?(S=p-1,b=m):t<0?(S=u,b=0):t>0&&(S=u,b=f-1),S!=null&&b!=null&&s.moveCursorToPosition(S,b,i,!0,C)}else{if(!s.metrics)throw new Error("grid.metrics are not set");const{theme:g}=s.props,{autoSelectRow:p=!1,autoSelectColumn:f=!1}=g;if(p&&e!==0){const{lastLeft:C}=s.metrics;let{left:S}=s.state;S=Ae(S+e,0,C),s.moveCursorToPosition(S,l,i,!1),s.setViewState({left:S})}else if(f&&t!==0){const{lastTop:C}=s.metrics;let{top:S}=s.state;S=Ae(S+t,0,C),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),f=g-1;let C=h-u+o;C+=m?0:1,C=Math.min(C,f);const S=Math.min(p,C-(o-u));return t.moveCursorToPosition(l,C,n,!1),t.setViewState({top:S}),!0}}const Kb=zb;class Yb extends Js{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)&&Pe(i)&&i.isRowExpandable(a))return t.toggleRowExpanded(o),!0}}}return!1}}const qb=Yb;class Xb extends Js{onDown(e,t){if(A.isModifierKeyDown(e))return!1;const{model:n}=t.props,{cursorColumn:s,cursorRow:i}=t.state;if(s==null||i==null||!ze(n)||!n.isEditableRange(Re.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=Xb;function Qb(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 Jb(c){const e=[];return c.forEach(t=>{const n=t.textContent??"";n.length>0&&e.push(n.split(/\t|\u00a0\u00a0 \u00a0/))}),e}function ew(c){const e=c.querySelector("table");if(e!=null)return Qb(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
19
|
`).map(o=>o.split(" ")):n.length>1||i?Jb(c.childNodes):t}return null}class tw extends Js{onDown(e,t){switch(e.key){case"v":if(A.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=ew(n);i!=null&&t.pasteValue(i)};return n.addEventListener("input",s),n.focus(),{preventDefault:!1,stopPropagation:!0}}break}return!1}}const nw=tw;const sw=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=v.useRef(null),u=v.useRef(!1),[m]=v.useState(n),[g,p]=v.useState(!1),[f,C]=v.useState(s),[S,b]=v.useState(n);v.useEffect(function(){const{current:_}=h;_!=null&&(_.focus(),c?_.setSelectionRange(c[0],c[1]):_.setSelectionRange(_.value.length,_.value.length))},[c]);const w=v.useCallback(k=>{i(k)},[i]),T=v.useCallback(k=>{const{value:_}=k.target;b(_),p(!0),w(_)},[w,b,p]),E=v.useCallback(()=>{u.current=!0,g&&w(m),p(!1),o()},[m,g,o,w]),y=v.useCallback(()=>{C(!1)},[C]),R=v.useCallback((k,_=!1)=>{l(S,{direction:k,fillRange:_})},[l,S]),I=v.useCallback(()=>{u.current||R(null)},[u,R]),x=v.useCallback(k=>{switch(k.stopPropagation(),k.key){case"Escape":k.preventDefault(),E();break;case"Enter":if(k.preventDefault(),A.isModifierKeyDown(k))R(void 0,!0);else if(k.altKey){const _=`${S}
|
|
20
20
|
`;b(_),p(!0),w(_)}else R(k.shiftKey?mn.UP:mn.DOWN);break;case"Tab":k.preventDefault(),R(k.shiftKey?mn.LEFT:mn.RIGHT);break;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":f&&(k.preventDefault(),R(sw(k.key)));break}},[E,R,f,b,p,w,S]),O=v.useCallback(k=>{a(k)},[a]);return r.jsx("textarea",{ref:h,className:z("grid-cell-input-field",e),value:S,onBlur:I,onChange:T,onKeyDown:x,onContextMenu:O,onClick:y,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",disabled:t,style:d})}Or.propTypes={selectionRange:U.arrayOf(U.number),className:U.string,disabled:U.bool,isQuickEdit:U.bool,value:U.string,onChange:U.func,onCancel:U.func,onDone:U.func,onContextMenu:U.func,style:U.shape({})};Or.defaultProps={selectionRange:null,className:"",disabled:!1,value:"",isQuickEdit:!0,onChange:()=>{},onCancel:()=>{},onDone:()=>{},onContextMenu:()=>{},style:{}};const iw=oe.createContext({}),ow=iw;class hs extends v.PureComponent{static contextType=ow;static defaultProps={canvasOptions:{alpha:!1},isStickyBottom:!1,isStickyRight:!1,isStuckToBottom:!1,isStuckToRight:!1,keyHandlers:Ie,mouseHandlers:Ie,movedColumns:Ie,movedRows:Ie,onError:()=>{},onSelectionChanged:()=>{},onMovedColumnsChanged:e=>{},onMoveColumnComplete:()=>{},onMovedRowsChanged:()=>{},onMoveRowComplete:()=>{},onViewChanged:()=>{},onTokenClicked:e=>{Sl(e)&&window.open(e.href,"_blank","noopener,noreferrer")},stateOverride:{},theme:{autoSelectColumn:!1,autoSelectRow:!1}};static pixelsPerLine=100/3;static dragTimeout=1e3;static getTheme=ce((e,t)=>({...yb,...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 Fb,this.metricCalculator=s||new Tb,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 nw(450),new Kb(500),new qb(900)],this.mouseHandlers=[new jb(100),new cu(200),new Pb(300),new Ob(400),new $b(450),new Bb(500),new Lb(600),new Ub(700),new Ka(800),new Wb(825),new kb(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:Ie,lastSelectedRanges:Ie,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:f,movedRows:C}=t,{draggingColumn:S,draggingRow:b,movedColumns:w,movedRows:T}=this.state;g!==i&&this.setState({movedColumns:i}),p!==o&&this.setState({movedRows:o}),f!==w&&l(w),t.draggingColumn!=null&&S==null&&a(w),C!==T&&d(T),t.draggingRow!=null&&b==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 hs.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 A.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:f,draggingColumn:C}=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:f,draggingColumn:C,...s}}getCachedKeyHandlers=ce(e=>[...e,...this.keyHandlers].sort((t,n)=>t.order-n.order));getKeyHandlers(){const{keyHandlers:e}=this.props;return this.getCachedKeyHandlers(e)}getCachedMouseHandlers=ce(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;Pe(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=Re.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;D(e),D(t),D(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=hs.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 f=o[o.length-1];let C=null,S=null,b=null,w=null;s?(C=h!==void 0&&h?null:Math.min(e??0,f.startColumn??0),S=u!==void 0&&u?null:Math.min(t??0,f.startRow??0),b=h!==void 0&&h?null:Math.max(e??0,f.endColumn??0),w=u!==void 0&&u?null:Math.max(t??0,f.endRow??0)):(C=f.startColumn,S=f.startRow,(a!=null||l!=null)&&((h===void 0||!h)&&(C=a),(u===void 0||!u)&&(S=l)),b=h!==void 0&&h?null:e,w=u!==void 0&&u?null:t);const T=Re.makeNormalized(C,S,b,w);if(f.equals(T))return null;const E=[...o];return E[E.length-1]=T,{selectedRanges:E,selectionEndColumn:e,selectionEndRow:t}}const m=[...o],g=h!==void 0&&h?null:e,p=u!==void 0&&u?null:t;return m.push(Re.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?Re.rowCount(s)===1:Re.cellCount(s)===1)&&Re.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=Re.consolidate(a)}let d=l,h=o;if(!Re.containsCell(a,l,o)){const{model:u}=this.props,{columnCount:m,rowCount:g}=u,p=Re.nextCell(Re.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 Re(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 Re(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=Re.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:[Re.makeCell(o,i)];let d=null;if(a.length===1&&Re.cellCount(a)===1){const h=new Re(0,0,n-1,s-1);d=h.nextCell(o,i,e)??h.startCell(e)}else d=Re.nextCell(Re.boundedRanges(a,n,s),o,i,e);if(d!=null){const{column:h,row:u}=d;this.setState({cursorColumn:h,cursorRow:u}),Re.containsCell(l,h,u)||this.setState({selectedRanges:[Re.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&&!A.isFloatingRow(t,this.metrics)&&(t<o?(d=n.getTopForTopVisible(a,t),u=0):t>s&&(d=n.getTopForBottomVisible(a,t),u=0)),e!=null&&!A.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(!ze(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 ze(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 Sa("Can't paste in to read-only area.");if(i.length<=0)throw new Sa("Select an area to paste to.");if(typeof e=="string"){const m=[],g=A.getModelRanges(i,n,s);Re.forEachCell(g,(p,f)=>{m.push({column:p,row:f,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=>Re.cellCount([m])===1&&(m.startColumn??0)+l<=a&&(m.startRow??0)+o<=d)&&(h=h.map(m=>new Re(m.startColumn,m.startRow,(m.startColumn??0)+l-1,(m.startRow??0)+o-1)),this.setSelectedRanges(h)),!h.every(m=>Re.rowCount([m])===o&&Re.columnCount([m])===l))throw new Sa("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=A.getModelRanges(e,s,i);ze(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!==hs.getCursorClassName(e)&&(this.documentCursor!=null&&document.documentElement.classList.remove(this.documentCursor),this.documentCursor=hs.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)},hs.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:f,left:C,topOffset:S,leftOffset:b}=n;const w=this.getTheme();let{deltaX:T,deltaY:E}=A.getScrollDelta(e,n.barWidth,n.barHeight,n.rowHeight,n.rowHeight);for(;g&&T!==0;){if(b+=T,T=0,l>1){if(b>0&&C>=o||b<0&&C<=0){b=0;break}}else{if(b<=0){b=0;break}const y=d-h;if(b>=y){b=y;break}}if(b>0){const y=n.allColumnWidths.get(C)??t.getVisibleColumnWidth(C,s);b>=y?(T=b-y,b=0,C+=1):w.scrollSnapToColumn&&l>1&&(b=0,C+=1)}else if(b<0){const y=n.allColumnWidths.get(C-1)??t.getVisibleColumnWidth(C-1,s);Math.abs(b)<=y&&w.scrollSnapToColumn&&l>1?(b=0,C-=1):(T=b+y,b=0,C-=1)}}for(;p&&E!==0;){if(S+=E,E=0,a>1){if(S>0&&f>=i||S<0&&f<=0){S=0;break}}else{if(S<=0){S=0;break}const y=u-m;if(S>=y){S=y;break}}if(S>0){const y=n.allRowHeights.get(f)??t.getVisibleRowHeight(f,s);S>=y?(E=S-y,S=0,f+=1):w.scrollSnapToRow&&a>1&&(S=0,f+=1)}else if(S<0){const y=n.allRowHeights.get(f-1)??t.getVisibleRowHeight(f-1,s);Math.abs(S)<=y&&w.scrollSnapToRow&&a>1?(S=0,f-=1):(E=S+y,S=0,f-=1)}}this.setViewState({top:f,left:C,leftOffset:b,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||!ze(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,f=u.get(l),C=m.get(a),S=g.get(l),b=p.get(a),w=f!=null&&C!=null&&S!=null&&b!=null?{position:"absolute",left:d+f,top:h+C,width:S,height:b}:{opacity:0},T=this.getModelColumn(l),E=this.getModelRow(a),y=T!=null&&E!=null?{textAlign:e.textAlignForCell(T,E)}:void 0,R=e.isValidForCell(T,E,i);return r.jsx("div",{style:w,children:r.jsx(Or,{selectionRange:s,className:z({error:!R}),onCancel:this.handleEditCellCancel,onChange:this.handleEditCellChange,onDone:this.handleEditCellCommit,isQuickEdit:o,style:y,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:f,stateOverride:C}=this.props,{metrics:S}=this,b=this.canvasContext,w=this.getTheme(),T=this.canvas.clientWidth,E=this.canvas.clientHeight;return D(S),this.renderState={width:T,height:E,context:b,theme:w,model:f,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,...C},this.renderState}render(){const{cursor:e}=this.state;return r.jsxs(r.Fragment,{children:[r.jsx("canvas",{className:z("grid-canvas",hs.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 lw=hs,ba=5e3;class aw extends nm{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=ba){const s=this.textForCell(e,t);return this.getCachedTokensInText(s,n)}getCachedTokensInText=Bn((e,t)=>{if(t>=e.length)return A.findTokensWithProtocolInText(e);const n=e.slice(t-1,ba).search(/\s/);let s=t+n;n===-1&&(s=Math.min(ba,e.length));const i=e.substring(0,s);return A.findTokensWithProtocolInText(i)})}const rw=aw;function dw(c,e){const t=uw(c);return t===void 0?void 0:`${Sw(c)} ? ${t} : ${e}`}function cw(c,e){return c.Column.formatRowColor(e)}function hw(c,e){return c.formatColor(e)}const Zi=J.module("ConditionalFormattingUtils");var Fn=(c=>(c.CONDITIONAL="conditional",c.ROWS="rows",c))(Fn||{}),je=(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))(je||{}),Pt=(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))(Pt||{}),yt=(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))(yt||{}),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||{}),sn=(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))(sn||{});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 wl(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 vl(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 uw(c){const e=vl(c.style),t=wl(c.style);if(!(e===void 0||t===void 0))return`bgfg(\`${t}\`, \`${e}\`)`}function mw(c){const{column:e,value:t,start:n,end:s}=c;return Fw(e.name,c.condition,t,n,s)}function gw(c){const{column:e,value:t}=c;return Nw(e.name,c.condition,t)}function pw(c){const{column:e,value:t}=c;return kw(e.name,c.condition,t)}function fw(c){const{column:e}=c;return Mw(e.name,c.condition)}function Cw(c){const{column:e,value:t}=c;return Aw(e.name,c.condition,t)}function Sw(c){const{column:e}=c;if(F.isNumberType(e.type))return mw(c);if(F.isCharType(e.type))return Cw(c);if(F.isStringType(e.type))return gw(c);if(F.isDateType(e.type))return pw(c);if(F.isBooleanType(e.type))return fw(c);throw new Error("Invalid column type")}function bw(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 ww(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 vw(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 Tw(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 Ew(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 hu(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 uu(c){if(F.isCharType(c)||F.isStringType(c))return""}function mu(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:hu(c),value:uu(c),start:void 0,end:void 0}}function gu(){return{type:"no-formatting"}}function yw(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 Rw(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 xw(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 Iw(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 Dw(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 Fw(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 Nw(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 kw(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 Mw(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 Aw(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 Ow(c,e){if(F.isNumberType(c))return Dw(e);if(F.isCharType(c))return Iw(e);if(F.isStringType(c))return yw(e);if(F.isDateType(c))return Rw(e);if(F.isBooleanType(c))return xw(e);throw new Error("Invalid column type")}function Lw(c,e,t){if(t===void 0)return Zi.debug("no rules passed."),[];const n=[];let s;const i=new Map;return t.forEach(({config:o,type:l})=>{const{column:a}=o,d=e.find(({name:f,type:C})=>f===a.name&&C===a.type);if(d===void 0){Zi.debug(`Column ${a.name}:${a.type} not found. Ignoring format rule.`,o);return}const[h,u]=(l==="conditional"?i.get(d.name):s)??["null",void 0],m=dw(o,h);if(m===void 0){Zi.debug("Ignoring format rule.",o);return}const g=u===void 0?-1:n.indexOf(u);g>-1&&n.splice(g,1);const p=l==="conditional"?hw(d,m):cw(c,m);n.push(p),l==="conditional"?i.set(d.name,[m,p]):s=[m,p]}),n}function _w(c,e,t){switch(e){case"is-null":case"is-not-null":return!0;default:{const[n,...s]=(t??"").split(" "),i=s.join(" ");try{Zs.parseDateTimeString(n)}catch{return Zi.debug("Invalid datetime string",n),!1}try{c.i18n.TimeZone.getTimeZone(i)}catch{return Zi.debug("Invalid timezone string",i),!1}return!0}}}function Pw({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(Vt,{in:n,timeout:Ye.transitionMs,classNames:c,onEntering:i,onEntered:o,onExiting:l,onExited:a,mountOnEnter:!0,unmountOnExit:!0,children:r.jsx("div",{className:z("iris-grid-bottom-bar",t),role:"presentation",onClick:s,onKeyPress:s,children:e})})}const jw=3e3,Hw=5;function Uw({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]=v.useState(!1),[p,f]=v.useState(!1),C=v.useRef(),S=nr(c),b=v.useMemo(()=>o.size===0?i:o.size<=Hw?`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]);v.useEffect(function(){S!=null&&S&&!c&&b==null&&(g(!0),f(!0),C.current=setTimeout(()=>{g(!1)},jw))},[b,c,S]),v.useEffect(function(){C.current&&l.size>0&&(clearTimeout(C.current),g(!1),f(!1))},[l]),v.useEffect(function(){return()=>C.current?clearTimeout(C.current):void 0},[]);const w=l.size;let T;return c?T=r.jsx(Nn,{}):p&&(T=or),r.jsxs(ta,{className:"pending-data-bottom-bar",isShown:w>0||m||b!=null,onEntering:a,onEntered:d,onExiting:h,onExited:()=>{f(!1),u&&u()},children:[b!=null&&b!==""&&r.jsxs("div",{className:"error-message",children:[r.jsx(X,{icon:Ss}),r.jsx("span",{children:`${b}`})]}),(b==null||b==="")&&r.jsx("div",{className:"status-message",children:w>0&&r.jsx("span",{children:`${w} row${w>1?"s":""} pending`})}),r.jsxs("div",{className:"buttons-container",children:[!c&&!p&&r.jsx(P,{kind:"secondary",onClick:t,tooltip:n,children:"Discard"}),r.jsxs(P,{kind:p?"success":"primary",onClick:e,icon:T,disabled:c||p||b!=null,tooltip:s,children:[c&&"Committing...",!c&&p&&"Success",!c&&!p&&"Commit"]})]})]})}var pu=(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))(pu||{});const Fe=pu,Bw=[Fe.SUM,Fe.ABS_SUM,Fe.MIN,Fe.MAX,Fe.VAR,Fe.AVG,Fe.STD,Fe.FIRST,Fe.LAST,Fe.COUNT_DISTINCT,Fe.DISTINCT,Fe.COUNT,Fe.UNIQUE],Vw=c=>{switch(c){default:return!1}},$w=(c,e)=>{switch(c){case Fe.COUNT:case Fe.FIRST:case Fe.LAST:case Fe.COUNT_DISTINCT:case Fe.DISTINCT:case Fe.UNIQUE:return!0;case Fe.MIN:case Fe.MAX:return F.isNumberType(e)||F.isDateType(e)||F.isTextType(e);case Fe.SUM:case Fe.ABS_SUM:case Fe.VAR:case Fe.AVG:case Fe.STD:return F.isNumberType(e);case Fe.SKIP:return!1}},Lr=(c,e)=>c.filter(t=>$w(e,t.type)),Ww=(c,e,t,n)=>Lr(c,e).map(({name:s})=>s).filter(s=>t.includes(s)?!n:n),ps={isRollupOperation:Vw,filterValidColumns:Lr,getOperationColumnNames:Ww};var fu=(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))(fu||{});const Ri=fu,Gw=Object.freeze([[Ri.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS,!1],[Ri.LINK_CHANGE_CLEARS_ALL_FILTERS,!1]]),Cu={DEFAULTS:Gw},zw=J.module("ColumnHeaderGroup");function wa(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=ce(e=>{const t=this.childIndexes.flat(),n=A.getVisibleIndexes(t,e),s=Math.min(...n),i=Math.max(...n);return i-s!==t.length-1&&zw.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=J.module("IrisGridUtils");function os(c,e){return c>=0&&c<e.length}function Kw(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})=>os(a,l)&&(typeof d=="number"&&os(d,l)||Array.isArray(d)&&os(d[0],l)&&os(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(f=>f===p):p;return{to:g(u),from:Array.isArray(m)?[g(m[0]),g(m[1])]:g(m)}}).filter(({to:u,from:m})=>os(u,h)&&(typeof m=="number"&&os(m,h)||Array.isArray(m)&&os(m[0],h)&&os(m[1],h))),movedRows:[...l]}}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([...Cu.DEFAULTS,...o])}}static dehydrateQuickFilters(e){return[...e].map(([t,n])=>{const{text:s}=n;return[t,{text:s}]})}static dehydrateLong(e){return e!=null?`${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 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 getInputFiltersForColumns(e,t=[]){return t.filter(({name:n,type:s})=>e.find(({name:i,type:o})=>i===n&&o===s))}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=A.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=A.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=A.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=A.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 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];D(i.startColumn),D(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})=>ps.isRollupOperation(u)?[]:ps.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[Fe.FIRST]??[];h[Fe.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 f=1;u.children.forEach(S=>{if(a.has(S))throw new Error(`Column group child ${S} specified in multiple groups`);a.add(S);const b=l.get(S),w=e.getColumnIndexByName(S);if(b){const T=d(b);p.push(...T.childIndexes),f=Math.max(f,T.depth+1)}else if(w!=null)p.push(w),f=Math.max(f,1);else throw new Error(`Unknown child ${S} in group ${m}`)});const C=new dn({...u,depth:f,childIndexes:p.flat()});return i.set(m,C),u.children.forEach(S=>s.set(S,C)),n=Math.max(n,C.depth+1),C},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)&&Kw(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}`}dh;tableUtils;constructor(e){this.dh=e,this.tableUtils=new F(e)}dehydrateIrisGridState(e,t){const{aggregationSettings:n={aggregations:Ie,showOnTop:!1},advancedFilters:s,customColumnFormatMap:i,isFilterBarShown:o,metrics:l,quickFilters:a,customColumns:d,conditionalFormats:h=Ie,reverseType:u,rollupConfig:m=void 0,showSearchBar:g,searchValue:p,selectDistinctColumns:f=Ie,selectedSearchColumns:C,sorts:S,invertSearchColumns:b,pendingDataMap:w=jn,frozenColumns:T,columnHeaderGroups:E}=t;D(l);const{userColumnWidths:y,userRowHeights:R}=l,{columns:I}=e;return{advancedFilters:this.dehydrateAdvancedFilters(I,s),aggregationSettings:n,customColumnFormatMap:[...i],isFilterBarShown:o,quickFilters:Be.dehydrateQuickFilters(a),sorts:Be.dehydrateSort(S),userColumnWidths:[...y].filter(([x])=>x!=null&&x>=0&&x<I.length).map(([x,O])=>[I[x].name,O]),userRowHeights:[...R],customColumns:[...d],conditionalFormats:[...h],reverseType:u,rollupConfig:m,showSearchBar:g,searchValue:p,selectDistinctColumns:[...f],selectedSearchColumns:C,invertSearchColumns:b,pendingDataMap:this.dehydratePendingDataMap(I,w),frozenColumns:T,columnHeaderGroups:E?.map(x=>({name:x.name,children:x.children,color:x.color}))}}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:f,searchValue:C,selectDistinctColumns:S,selectedSearchColumns:b,invertSearchColumns:w=!0,pendingDataMap:T=[],frozenColumns:E,columnHeaderGroups:y}=t,{columns:R,formatter:I}=e;return{advancedFilters:this.hydrateAdvancedFilters(R,n,I.timeZone),aggregationSettings:s,customColumnFormatMap:new Map(i),isFilterBarShown:o,quickFilters:this.hydrateQuickFilters(R,l,I.timeZone),sorts:this.hydrateSort(R,a),userColumnWidths:new Map(u.map(([x,O])=>typeof x=="string"||x instanceof String?[R.findIndex(({name:k})=>k===x),O]:[x,O]).filter(([x])=>x!=null&&x>=0&&x<R.length)),customColumns:d,conditionalFormats:h,userRowHeights:new Map(m),reverseType:g,rollupConfig:p,showSearchBar:f,searchValue:C,selectDistinctColumns:S,selectedSearchColumns:b,invertSearchColumns:w,pendingDataMap:this.hydratePendingDataMap(R,T),frozenColumns:E,columnHeaderGroups:Be.parseColumnHeaderGroups(e,y??e.layoutHints?.columnGroups??[]).groups}}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=this.tableUtils.makeQuickFilter(d,l,n))}catch(d){ji.error("hydrateQuickFilters error with",l,d)}return[i,{text:l,filter:a}]});return new Map(s)}dehydrateAdvancedFilters(e,t){return[...t].map(([n,s])=>{const i=Be.getColumn(e,n);D(i);const o=this.dehydrateAdvancedFilterOptions(i,s.options);return[n,{options:o}]})}hydrateAdvancedFilters(e,t,n){const s=t.map(([i,o])=>{const l=Be.getColumn(e,i);D(l);const a=this.hydrateAdvancedFilterOptions(l,o.options);let d=null;try{Be.getColumn(e,i)!=null&&(d=this.tableUtils.makeAdvancedFilter(l,a,n))}catch(h){ji.error("hydrateAdvancedFilters error with",a,h)}return[i,{options:a,filter:d}]});return new Map(s)}dehydrateAdvancedFilterOptions(e,t){const{selectedValues:n,...s}=t;return{selectedValues:n?.map(i=>this.dehydrateValue(i,e?.type)),...s}}hydrateAdvancedFilterOptions(e,t){const{selectedValues:n,...s}=t;return{selectedValues:n?.map(i=>this.hydrateValue(i,e?.type)),...s}}dehydratePendingDataMap(e,t){return[...t].map(([n,{data:s}])=>[n,{data:[...s].map(([i,o])=>[e[i].name,this.dehydrateValue(o,e[i].type)])}])}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 D(d),[s(l)??null,this.hydrateValue(a,e[d].type)]}))}]))}dehydrateValue(e,t){return F.isDateType(t)?this.dehydrateDateTime(e):F.isLongType(t)?Be.dehydrateLong(e):e}hydrateValue(e,t){return F.isDateType(t)?this.hydrateDateTime(e):F.isLongType(t)?this.hydrateLong(e):e}dehydrateDateTime(e){return e!=null?this.dh.i18n.DateTimeFormat.format(Zs.FULL_DATE_FORMAT,e):null}hydrateDateTime(e){return e!=null?this.dh.i18n.DateTimeFormat.parse(Zs.FULL_DATE_FORMAT,e):null}hydrateLong(e){return e!=null?this.dh.LongWrapper.ofString(e):null}hydrateSort(e,t){const{dh:n}=this;return t.map(s=>{const{column:i,isAbs:o,direction:l}=s;if(l===F.sortDirection.reverse)return n.Table.reverse();const a=typeof i=="string"?Be.getColumnByName(e,i):Be.getColumn(e,i);if(a!=null){let d=a.sort();return o&&(d=d.abs()),l===F.sortDirection.descending?d=d.desc():d=d.asc(),d}return null}).filter(s=>s!=null&&s.direction!==F.sortDirection.reverse)}applyTableSettings(e,t,n){const{columns:s}=e;let i=[];t.quickFilters&&(i=Be.getFiltersFromFilterMap(this.hydrateQuickFilters(s,t.quickFilters,n)));let o=[];t.advancedFilters&&(o=Be.getFiltersFromFilterMap(this.hydrateAdvancedFilters(s,t.advancedFilters,n)));const l=this.getFiltersFromInputFilters(s,t.inputFilters,n);let a=[];t.sorts&&(a=this.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(this.dh.FilterValue.ofString(h)),...d])}d=[...l,...d],e.applyFilter(d),e.applySort(a)}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 this.tableUtils.makeQuickFilter(l,o,n)}catch(a){ji.debug("Unable to create input filter",a)}return null}).filter(s=>s!=null)}rangeSetFromRanges(e){const{dh:t}=this,n=e.slice().sort((s,i)=>(D(s.startRow),D(i.startRow),s.startRow-i.startRow)).map(s=>{const{startRow:i,endRow:o}=s;return D(i),D(o),t.RangeSet.ofRange(i,o)});return t.RangeSet.ofRanges(n)}}const Ce=Be;const Lt=J.module("IrisGridCopyHandler");class De extends v.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 De.COPY_STATES.CONFIRMATION_REQUIRED:return`Are you sure you want to copy ${t.toLocaleString()} rows to your clipboard?`;case De.COPY_STATES.CLICK_REQUIRED:return`Fetched ${t.toLocaleString()} rows!`;case De.COPY_STATES.FETCH_ERROR:return"Unable to copy data.";case De.COPY_STATES.FETCH_IN_PROGRESS:return`Fetching ${t.toLocaleString()} rows for clipboard...`;case De.COPY_STATES.DONE:return"Copied to Clipboard!";default:return""}}static getCopyButtonText(e){switch(e){case De.BUTTON_STATES.FETCH_IN_PROGRESS:return"Fetching";case De.BUTTON_STATES.CLICK_TO_COPY:return"Click to Copy";case De.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:De.COPY_STATES.IDLE,buttonState:De.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(){Lt.debug2("startCopy"),this.stopCopy();const{copyOperation:e}=this.props;if(e==null){Lt.debug2("No copy operation set, cancelling out"),this.setState({isShown:!1});return}const{ranges:t,error:n}=e;if(n!=null){Lt.debug("Showing copy error",n),this.setState({isShown:!0,copyState:De.COPY_STATES.DONE,error:n}),this.startHideTimer();return}const s=Q.rowCount(t);this.setState({rowCount:s,isShown:!0,error:void 0}),s>De.NO_PROMPT_THRESHOLD?this.setState({buttonState:De.BUTTON_STATES.COPY,copyState:De.COPY_STATES.CONFIRMATION_REQUIRED}):this.startFetch()}stopCopy(){this.textData=void 0,this.stopFetch(),this.stopHideTimer()}handleBackgroundClick(){Lt.debug2("handleBackgroundClick");const{copyState:e}=this.state;e===De.COPY_STATES.DONE&&this.setState({isShown:!1})}handleCancelClick(){Lt.debug2("handleCancelClick"),this.stopFetch(),this.setState({isShown:!1})}handleCopyClick(){Lt.debug2("handleCopyClick"),this.textData!=null?this.copyText(this.textData):this.startFetch()}handleHideTimeout(){Lt.debug2("handleHideTimeout"),this.stopHideTimer(),this.setState({isShown:!1})}copyText(e){Lt.debug2("copyText",e),this.textData=e,co(e).then(()=>{this.setState({copyState:De.COPY_STATES.DONE}),this.startHideTimer()},t=>{Lt.error("copyText error",t),this.setState({buttonState:De.BUTTON_STATES.CLICK_TO_COPY,copyState:De.COPY_STATES.CLICK_REQUIRED})})}startFetch(){this.stopFetch(),this.setState({buttonState:De.BUTTON_STATES.FETCH_IN_PROGRESS,copyState:De.COPY_STATES.FETCH_IN_PROGRESS});const{model:e,copyOperation:t}=this.props,{ranges:n,includeHeaders:s,userColumnWidths:i,movedColumns:o,formatValues:l}=t;Lt.debug("startFetch",n);const a=Ce.getHiddenColumns(i);let d=A.getModelRanges(n,o);if(a.length>0){const u=a.map(Q.makeColumn);d=Q.subtractRangesFromRanges(d,u)}const h=l!=null&&l?(u,m)=>e.displayString(u,m.type,m.name):u=>`${u}`;this.fetchPromise=be.makeCancelable(e.textSnapshot(d,s,h)),this.fetchPromise.then(u=>{this.fetchPromise=void 0,this.copyText(u)}).catch(u=>{u instanceof _l?Lt.debug("User cancelled copy."):(Lt.error("Error fetching contents",u),this.fetchPromise=void 0,this.setState({buttonState:De.BUTTON_STATES.RETRY,copyState:De.COPY_STATES.FETCH_ERROR}))})}stopFetch(){this.fetchPromise&&(Lt.debug2("stopFetch"),this.fetchPromise.cancel(),this.fetchPromise=void 0)}startHideTimer(){this.stopHideTimer(),this.hideTimer=setTimeout(this.handleHideTimeout,De.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===De.COPY_STATES.DONE?"fade":"copy-slide-up",u=De.getCopyButtonText(i),m=d??De.getStatusMessageText(o,a),g=o!==De.COPY_STATES.DONE,p=i===De.BUTTON_STATES.FETCH_IN_PROGRESS,f=o===De.COPY_STATES.DONE;return r.jsxs(ta,{animation:h,isShown:l,className:z("iris-grid-copy-handler",{"copy-done":f}),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(Vt,{in:g,timeout:Ye.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(P,{kind:p?"tertiary":"primary",className:z("btn-copy",{"btn-spinner":p}),onClick:this.handleCopyClick,disabled:p,children:[p&&r.jsx(Nn,{}),u]})]})})]})}}const Yw=De;class qw extends v.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=We(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=We(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:z("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(P,{kind:"ghost",className:z("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:lr,className:"filter-solid"}),r.jsx(X,{icon:rl,className:"filter-light"})]})})})]})}}const Xw=qw;class Zw extends Js{irisGrid;constructor(e){super(),this.irisGrid=e}onDown(e){const{selectedRanges:t}=this.irisGrid.state;return e.key==="c"&&ws.isModifierKeyDown(e)?(Ce.isValidSnapshotRanges(t)?this.irisGrid.copyRanges(t):this.irisGrid.copyRanges(t,!1,!1,"Invalid copy ranges"),!0):!1}}const Qw=Zw,Jw={TOGGLE_QUICK_FILTER:He.createAndAdd({id:"TABLE.TOGGLE_QUICK_FILTER",name:"Toggle Quick Filter",shortcut:[fe.CTRL,ve.F],macShortcut:[fe.CMD,ve.F]}),CLEAR_ALL_FILTERS:He.createAndAdd({id:"TABLE.CLEAR_ALL_FILTERS",name:"Clear All Table Filters",shortcut:[fe.CTRL,ve.E],macShortcut:[fe.CMD,ve.E]}),CLEAR_FILTERS:He.createAndAdd({id:"TABLE.CLEAR_FILTERS",name:"Clear Active Table Filters",shortcut:[fe.CTRL,fe.SHIFT,ve.E],macShortcut:[fe.CMD,fe.SHIFT,ve.E]}),REVERSE:He.createAndAdd({id:"TABLE.REVERSE",name:"Reverse",shortcut:[fe.CTRL,ve.I],macShortcut:[fe.CMD,ve.I]}),TOGGLE_SEARCH:He.createAndAdd({id:"TABLE.TOGGLE_SEARCH",name:"Toggle Search",shortcut:[fe.CTRL,fe.SHIFT,ve.F],macShortcut:[fe.CMD,fe.SHIFT,ve.F]}),GOTO_ROW:He.createAndAdd({id:"TABLE.GOTO_ROW",name:"Go to Row",shortcut:[fe.CTRL,ve.G],macShortcut:[fe.CMD,ve.G]})},ev={COMMIT:He.createAndAdd({id:"INPUT_TABLE.COMMIT",name:"Commit",shortcut:[fe.CTRL,ve.S],macShortcut:[fe.CMD,ve.S]}),DISCARD:He.createAndAdd({id:"INPUT_TABLE.DISCARD",name:"Discard",shortcut:[fe.CTRL,fe.ALT,ve.S],macShortcut:[fe.CMD,fe.OPTION,ve.S]})},tv={TABLE:Jw,INPUT_TABLE:ev},Ht=tv;class nv extends Js{irisGrid;constructor(e){super(),this.irisGrid=e}onDown(e){if(Ht.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 sv=nv;class iv extends Js{irisGrid;constructor(e){super(),this.irisGrid=e}onDown(e){return Ht.TABLE.CLEAR_FILTERS.matchesEvent(e)?(this.irisGrid.clearAllFilters(),!0):!1}}const ov=iv;class lv extends ot{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:f,width:C,height:S}=i.getCellOverflowButtonPosition(g);return p==null||C==null||f==null||S==null?null:{left:p,top:f,width:C,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,f=d.getTheme(),C={context:p,mouseX:t,mouseY:n,metrics:m,model:g,theme:f};return a.shouldRenderOverflowButton(C)&&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);Ze(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 av=lv;class rv extends ot{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 dv=rv;class cv extends ot{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 hv=cv;class _r extends v.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=oe.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=pp.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(Je,{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 uv=_r;class mv{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(uv,{formatString:e.formatString,title:e.label,placeholder:n,onChange:i})}}}const Ut=mv;class on{static dateGroup=10;static timeGroup=20;static dateTimeGroup=30;static getOptions(e,t){const n=new Date,i=[{group:on.dateGroup,formatString:"yyyy-MM-dd"},{group:on.dateGroup,formatString:"MM-dd-yyyy"},{group:on.timeGroup,formatString:"HH:mm:ss"},{group:on.timeGroup,formatString:"HH:mm:ss.SSS"},{group:on.timeGroup,formatString:"HH:mm:ss.SSSSSSSSS"},{group:on.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss"},{group:on.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSS"},{group:on.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"}].map(l=>{const a=it.makeFormat("",l.formatString,it.TYPE_CONTEXT_PRESET),d=e.getFormattedString(n,F.dataType.DATETIME,"",a);return Ut.makeOption(d,a,l.group,it.isSameFormat(a,t))});return[Ut.makeOption("Default",null,on.dateGroup,Ut.isDefaultSelected(t)),...i]}}const gv=on;class ln{static defaultGroup=10;static presetGroup=20;static presetRoundGroup=30;static customGroup=40;static getOptions(e,t,n){const s=[{format:$e.FORMAT_PERCENT,group:ln.presetGroup},{format:$e.FORMAT_BASIS_POINTS,group:ln.presetGroup},{format:$e.FORMAT_MILLIONS,group:ln.presetGroup},{format:$e.FORMAT_SCIENTIFIC_NOTATION,group:ln.presetGroup},{format:$e.FORMAT_ROUND,group:ln.presetRoundGroup},{format:$e.FORMAT_ROUND_TWO_DECIMALS,group:ln.presetRoundGroup},{format:$e.FORMAT_ROUND_FOUR_DECIMALS,group:ln.presetRoundGroup}],i=Ut.makeOption("Default",null,ln.defaultGroup,Ut.isDefaultSelected(t)),o=s.map(h=>Ut.makeOption(h.format.label,h.format,h.group,$e.isSameFormat(h.format,t))),l=Ut.isCustomSelected(t),a=l?t:$e.makeCustomFormat(),d=Ut.makeCustomFormatOption(a,ln.customGroup,$e.DEFAULT_FORMAT_STRING,l,h=>{if(h!=null){const u=$e.makeCustomFormat(h);$e.isValid(e,u)&&n(u)}else n(null)});return[i,...o,d]}}const pv=ln;class gi{static defaultGroup=10;static presetGroup=20;static customGroup=30;static getOptions(e,t,n){const s=[{format:st.FORMAT_MILLIONS,group:gi.presetGroup},{format:st.FORMAT_SCIENTIFIC_NOTATION,group:gi.presetGroup}],i=Ut.makeOption("Default",null,gi.defaultGroup,Ut.isDefaultSelected(t)),o=s.map(h=>Ut.makeOption(h.format.label,h.format,h.group,st.isSameFormat(h.format,t))),l=Ut.isCustomSelected(t),a=l?t:st.makeCustomFormat(),d=Ut.makeCustomFormatOption(a,gi.customGroup,st.DEFAULT_FORMAT_STRING,l,h=>{if(h!=null){const u=st.makeCustomFormat(h);st.isValid(e,u)&&n(u)}else n(null)});return[i,...o,d]}}const fv=gi;const Zd=J.module("IrisGridContextMenuHandler"),Cv=150,Qd="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";class Y extends ot{static GROUP_EDIT=te.groups.high+10;static GROUP_HIDE_COLUMNS=te.groups.high+25;static GROUP_FILTER=te.groups.high+50;static GROUP_EXPAND_COLLAPSE=te.groups.high+55;static GROUP_GOTO=te.groups.high+60;static GROUP_SORT=te.groups.high+75;static GROUP_COPY=te.groups.high+100;static GROUP_FORMAT=te.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 getRowOptionFormatted(e,t,n=30){return`${e} "${Nt.truncate(t,n-e.length-3)}"`}irisGrid;debouncedUpdateCustomFormat;constructor(e,t){super(),this.debouncedUpdateCustomFormat=We(e.handleFormatSelection,Cv),this.dh=t,this.irisGrid=e}componentWillUnmount(){this.debouncedUpdateCustomFormat.flush()}dh;getHeaderActions(e,t){const{irisGrid:n}=this,{column:s}=t;D(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();D(d);const{filterIconColor:f,filterBarActiveColor:C,contextMenuSortIconColor:S,contextMenuReverseIconColor:b}=p,w=i.sort,T=F.getSortForColumn(w,l.name),E=h!==F.REVERSE_TYPE.NONE,{userColumnWidths:y}=d,R=[...y.values()].some(O=>O===0),I=i.getColumnHeaderParentGroup(e,0)===void 0&&!(Pe(i)&&i.hasExpandableRows),x=i.isColumnFrozen(e);return a.push({title:"Hide Column",group:Y.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.hideColumnByVisibleIndex(s)}}),a.push({title:x?"Unfreeze Column":"Freeze Column",group:Y.GROUP_HIDE_COLUMNS,disabled:!I,action:()=>{x?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:An,iconColor:C,shortcut:Ht.TABLE.TOGGLE_QUICK_FILTER,group:Y.GROUP_FILTER,order:10,action:()=>{this.irisGrid.toggleFilterBar(s)}}),a.push({title:"Advanced Filters",icon:m.get(e)?lr:rl,iconColor:f,group:Y.GROUP_FILTER,order:20,action:()=>{this.irisGrid.handleAdvancedMenuOpened(s)}}),a.push({title:"Clear Table Filters",group:Y.GROUP_FILTER,order:40,shortcut:Ht.TABLE.CLEAR_FILTERS,action:()=>{this.irisGrid.clearAllFilters()},disabled:!(u.size>0||m.size>0||g!=null)}),a.push({title:"Sort by",icon:An,iconColor:S,group:Y.GROUP_SORT,order:10,actions:this.sortByActions(l,e,T)}),a.push({title:"Add Additional Sort",disabled:T&&w.length===1||E&&w.length===1||T&&E&&w.length===2||w.length===0,group:Y.GROUP_SORT,order:20,actions:this.additionalSortActions(l,e)}),a.push({title:"Clear Table Sorting",disabled:w.length===0||E&&w.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:An,iconColor:b,group:Y.GROUP_SORT,order:40,disabled:!i.isReversible,shortcut:Ht.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(O=>Zd.error("Unable to copy header",O))}}),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){D(e);const{dh:s,irisGrid:i}=this,{column:o,row:l}=n,{model:a,canCopy:d}=i.props,{columns:h}=a,u=i.getModelRow(l);D(u);const m=a.valueForCell(e,u),g=a.textForCell(e,u),p=h[e],f=[],{quickFilters:C}=i.state,S=i.getTheme(),{filterIconColor:b}=S,{settings:w}=i.props,T=new it(s,{timeZone:w?.timeZone,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:Qd}),E=new it(s,{timeZone:w?.timeZone,showTimeZone:w?.showTimeZone,showTSeparator:w?.showTSeparator,defaultDateTimeFormatString:Qd});if(p==null||l==null)return f;if(a.isFilterable(e)){const R={title:"Filter by Value",icon:An,iconColor:b,group:Y.GROUP_FILTER,order:10,actions:[]};if(m==null)C.get(e)&&R.actions.push({title:"And",actions:this.nullFilterActions(p,C.get(e),"&&"),order:2,group:te.groups.high}),R.actions.push(...this.nullFilterActions(p));else if(F.isBooleanType(p.type))C.get(e)&&R.actions.push({title:"Or",actions:this.booleanFilterActions(p,g,C.get(e),"||"),order:2,group:te.groups.high}),R.actions.push(...this.booleanFilterActions(p,g));else if(F.isNumberType(p.type)||F.isCharType(p.type)){D(e);const I=F.isCharType(p.type)?String.fromCharCode(m):`${m}`;C.get(e)&&R.actions.push({title:"And",actions:this.numberFilterActions(p,I,m,C.get(e),"&&"),order:2,group:te.groups.high}),R.actions.push(...this.numberFilterActions(p,I,m,C.get(e)))}else if(F.isDateType(p.type)){const I=T.format(m),x=E.format(m);C.get(e)&&R.actions.push({title:"And",actions:this.dateFilterActions(p,I,x,m,C.get(e),"&&"),order:2,group:te.groups.high}),R.actions.push(...this.dateFilterActions(p,I,x,m,C.get(e)))}else C.get(e)&&R.actions.push({title:"And",actions:this.stringFilterActions(p,g,m,C.get(e),"&&"),order:2,group:te.groups.high}),R.actions.push(...this.stringFilterActions(p,g,m));R.actions!=null&&R.actions.length>0&&f.push(R)}if(Pe(a)&&a.isRowExpandable(u)){const R=a.groupedColumns.length>0?a.depthForRow(u)-1:0,x=a.valueForCell(R,u)==null?"null":a.textForCell(R,u);f.push({title:Y.getRowOptionFormatted(a.isRowExpanded(u)?"Collapse":"Expand",x),group:Y.GROUP_EXPAND_COLLAPSE,order:10,action:()=>{a.setRowExpanded(u,!a.isRowExpanded(u))}}),a.isExpandAllAvailable===!0&&f.push({title:Y.getRowOptionFormatted("Expand All in",x),group:Y.GROUP_EXPAND_COLLAPSE,order:20,action:()=>{a.setRowExpanded(u,!0,!0)}})}Pe(a)&&a.hasExpandableRows&&a.isExpandAllAvailable===!0&&(f.push({title:"Expand Entire Table",group:Y.GROUP_EXPAND_COLLAPSE,order:30,action:()=>{a.expandAll()}}),f.push({title:"Collapse Entire Table",group:Y.GROUP_EXPAND_COLLAPSE,order:40,action:()=>{a.collapseAll()}}));const y={title:"Go to",iconColor:b,shortcut:Ht.TABLE.GOTO_ROW,group:Y.GROUP_GOTO,order:10,action:()=>this.irisGrid.toggleGotoRow(`${l+1}`,`${m}`,p.name)};return f.push(y),d&&(f.push({title:"Copy Cell",group:Y.GROUP_COPY,order:10,action:()=>{i.copyCell(o,l)}}),f.push({title:"Copy Cell Unformatted",group:Y.GROUP_COPY,order:20,action:()=>{i.copyCell(o,l,!0)}})),f}getNumberValueEqualsFilter(e,t){const{dh:n}=this,s=e.filter();if(t===Number.POSITIVE_INFINITY)return n.FilterCondition.invoke("isInf",s).and(s.greaterThan(n.FilterValue.ofNumber(0)));if(t===Number.NEGATIVE_INFINITY)return n.FilterCondition.invoke("isInf",s).and(s.lessThan(n.FilterValue.ofNumber(0)));if(Number.isNaN(t))return n.FilterCondition.invoke("isNaN",s);const i=this.getFilterValueForNumberOrChar(e.type,t);return s.eq(i)}getFilterValueForNumberOrChar(e,t){const{dh:n}=this;return F.isCharType(e)?n.FilterValue.ofString(String.fromCharCode(t)):n.FilterValue.ofNumber(t)}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:f,quickFilters:C,advancedFilters:S,selectedRanges:b}=s.state;D(p);const{columnHeaderHeight:w,gridY:T,columnHeaderMaxDepth:E}=p,y=[];if(d!=null&&h!=null){const R=u.valueForCell(d,h),I=u.textForCell(d,h),x=g[d],{onContextMenu:O}=s.props;x!=null&&y.push(O({model:u,value:R,valueText:I,column:x,rowIndex:l,columnIndex:o,modelRow:h,modelColumn:d}))}return d!=null&&u.isFilterable(d)&&y.push({title:"Clear Column Filter",group:Y.GROUP_FILTER,order:30,action:()=>{this.irisGrid.removeColumnFilter(d)},disabled:!(C.has(d)||S.has(d))}),(f?i<=T:i<=w*E&&a===0)?d!=null&&y.push(...this.getHeaderActions(d,e)):(d!=null&&h!=null&&y.push(...this.getCellActions(d,t,e)),m&&b.length>0&&(y.push({title:"Copy Selection",shortcut:Yn.COPY,group:Y.GROUP_COPY,order:30,action:()=>{s.copyRanges(b)}}),y.push({title:"Copy Selection w/ Headers",group:Y.GROUP_COPY,order:40,action:()=>{s.copyRanges(b,!0)}})),ze(u)&&u.isEditable&&b.length>0&&y.push({title:"Delete Selected Rows",group:Y.GROUP_EDIT,order:50,action:()=>{this.irisGrid.deleteRanges(b)}})),y.length===0?!1:(D(s.gridWrapper),te.triggerMenu(s.gridWrapper,n.clientX,n.clientY,y),!0)}dateFormatActions(e){const{model:t}=this.irisGrid.props,{formatter:n}=t,s=n.getColumnFormat(e.type,e.name),i=gv.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?Kn:void 0,group:h,order:l,action:()=>{const g=t.getColumnIndexByName(e.name);D(g),this.irisGrid.handleFormatSelection(g,d)}})}return o}numberFormatActions(e){const{model:t}=this.irisGrid.props,{formatter:n}=t,{dh:s}=this,i=n.getColumnFormat(e.type,e.name);let o;const l=t.getColumnIndexByName(e.name);if(F.isDecimalType(e.type))o=pv.getOptions(s,i,d=>{D(l),this.debouncedUpdateCustomFormat(l,d)});else if(F.isIntegerType(e.type))o=fv.getOptions(s,i,d=>{D(l),this.debouncedUpdateCustomFormat(l,d)});else return Zd.error("Invalid column type in numberFormatActions"),null;const a=[];for(let d=0;d<o.length;d+=1){const{format:h,isSelected:u}=o[d];a.push({...o[d],icon:u?Kn:void 0,order:d,action:()=>{l===void 0&&h&&h.type===tl.TYPE_CONTEXT_CUSTOM||(D(l),this.irisGrid.handleFormatSelection(l,h))}})}return a}stringFilterActions(e,t,n,s,i){const{dh:o}=this,l=o.FilterValue.ofString(n);let a=s;a||(a={filter:null,text:null});const{filter:d,text:h}=a,u=[],{model:m}=this.irisGrid.props,g=m.getColumnIndexByName(e.name);return D(g),u.push({menuElement:r.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[i?Y.getOperatorAsText(i):""," ",'"',t,'"']}),order:1,group:te.groups.high}),u.push({title:"text is exactly",description:`Show only rows where ${e.name} is ${n} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(g,Y.getQuickFilterCondition(d,e.filter().eq(l),i),Y.getQuickFilterText(h,`=${t}`,i))},order:10,group:te.groups.low}),u.push({title:"text is not exactly",description:`Show only rows where ${e.name} is not ${t} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(g,Y.getQuickFilterCondition(d,e.filter().notEq(l),i),Y.getQuickFilterText(h,`!=${t}`,i))},order:20,group:te.groups.low}),u.push({title:"text contains",description:`Show only rows where ${e.name} contains ${t}`,action:()=>{this.irisGrid.setQuickFilter(g,Y.getQuickFilterCondition(d,e.filter().contains(l),i),Y.getQuickFilterText(h,`~${t}`,i))},order:30,group:te.groups.low}),u.push({title:"text does not contain",description:`Show only rows where ${e.name} does not contain ${n}`,action:()=>{this.irisGrid.setQuickFilter(g,Y.getQuickFilterCondition(d,e.filter().contains(l).not(),i),Y.getQuickFilterText(h,`!~${t}`,i))},order:40,group:te.groups.low}),u.push({title:"text starts with",description:`Show only rows where ${e.name} starts with ${t}`,action:()=>{this.irisGrid.setQuickFilter(g,Y.getQuickFilterCondition(d,e.filter().invoke("startsWith",l),i),Y.getQuickFilterText(h,`${t}*`,i))},order:50,group:te.groups.low}),u.push({title:"text ends with",description:`Show only rows where ${e.name} ends with ${t}`,action:()=>{this.irisGrid.setQuickFilter(g,Y.getQuickFilterCondition(d,e.filter().invoke("endsWith",l),i),Y.getQuickFilterText(h,`*${t}`,i))},order:60,group:te.groups.low}),u}numberFilterActions(e,t,n,s,i){const o=this.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 D(m),d.push({menuElement:r.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[i?Y.getOperatorAsText(i):""," ",'"',t,'"']}),order:1,group:te.groups.high}),d.push({title:"is equal to",description:`Show only rows where ${e.name} is ${t}`,action:()=>{const g=this.getNumberValueEqualsFilter(e,n);this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(l,g,i),Y.getQuickFilterText(a,`=${t}`,i))},order:10,group:te.groups.low}),d.push({title:"is not equal to",description:`Show only rows where ${e.name} is not ${t}`,action:()=>{const g=this.getNumberValueEqualsFilter(e,n).not();this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(l,g,i),Y.getQuickFilterText(a,`!=${t}`,i))},order:20,group:te.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:te.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:te.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:te.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:te.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 D(d),i.push({menuElement:r.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[s?Y.getOperatorAsText(s):""," ",'"',t??"null",'"']}),order:1,group:te.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:te.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:te.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:te.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:te.groups.low}),i}dateFilterActions(e,t,n,s,i,o){const{dh:l}=this,a=l.FilterValue.ofNumber(s);let d=null,h=null;i&&(d=i.filter,h=i.text);const{model:u}=this.irisGrid.props,m=u.getColumnIndexByName(e.name);D(m);const g=[];return g.push({menuElement:r.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[o?Y.getOperatorAsText(o):""," ",'"',n,'"']}),order:1,group:te.groups.high}),g.push({title:"date is",description:`Show only rows where ${e.name} is ${n}`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(d,e.filter().eq(a),o),Y.getQuickFilterText(h,`=${t}`,o))},order:10,group:te.groups.low}),g.push({title:"date is not",description:`Show only rows where ${e.name} is not ${n}`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(d,e.filter().notEq(a),o),Y.getQuickFilterText(h,`!=${t}`,o))},order:20,group:te.groups.low}),g.push({title:"date is before",description:`Show only rows where ${e.name} is before ${n}`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(d,e.filter().lessThan(a),o),Y.getQuickFilterText(h,`<${t}`,o))},order:30,group:te.groups.low}),g.push({title:"date is before or equal",description:`Show only rows where ${e.name} is before or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(d,e.filter().lessThanOrEqualTo(a),o),Y.getQuickFilterText(h,`<=${t}`,o))},order:40,group:te.groups.low}),g.push({title:"date is after",description:`Show only rows where ${e.name} is greater than ${n}`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(d,e.filter().greaterThan(a),o),Y.getQuickFilterText(h,`>${t}`,o))},order:50,group:te.groups.low}),g.push({title:"date is after or equal",description:`Show only rows where ${e.name} is after or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(m,Y.getQuickFilterCondition(d,e.filter().greaterThanOrEqualTo(a),o),Y.getQuickFilterText(h,`>=${t}`,o))},order:60,group:te.groups.low}),g}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 D(a),o.push({menuElement:r.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[n?Y.getOperatorAsText(n):""," ",'"null"']}),order:1,group:te.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:te.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:te.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)?An: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)?An: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)?An: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)?An: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:An,style:{color:s??void 0}})}),r.jsx("span",{className:"title",children:"Add Additional Sort"}),r.jsx("span",{className:"shortcut",children:ws.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 Sv=Y;class bv extends ot{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 wv=bv;class vv extends ot{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 Tv=vv;class Ev extends ot{irisGrid;constructor(e){super(750),this.irisGrid=e}destroyTooltip(){this.irisGrid.setState({expandCellTooltipProps:null})}setCursor(e,t){return Ka.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=Pe(h)?h.depthForRow(s):null,{left:f,top:C,width:S,height:b}=i.getExpandButtonPosition(g,p);return f==null||S==null||C==null||b==null?null:{left:f,top:C,width:S,height:b}}onMove(e,t){if(Ka.isInTreeBox(e,t)){const{expandCellTooltipProps:n}=this.irisGrid.state,{model:s}=this.irisGrid.props,i=this.getButtonPosition(e),{row:o}=e;D(o);const l=Pe(s)&&s.isRowExpanded(o);Ze(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 yv=Ev;class Rv extends ot{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=ws.isModifierKeyDown(n);return this.irisGrid.toggleSort(s,i),!0}return!1}}const xv=Rv;class Iv extends ot{constructor(e){super(),this.irisGrid=e}onWheel(e,t,n){const{irisGrid:s}=this,{model:i}=s.props,{metrics:o,pendingRowCount:l}=s.state;D(o);const{bottom:a,rowCount:d,rowHeight:h}=o,{deltaY:u}=A.getScrollDelta(n);return ze(i)&&i.isEditable&&a>=d-1&&u>0&&s.setState({pendingRowCount:l+Math.ceil(u/h)}),!1}}const Dv=Iv;class Fv extends ot{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(Sl(h[u].token)){const m=A.translateTokenBox(h[u],a),{x1:g,x2:p,y1:f,y2:C}=m;if(i>=g&&i<=p&&o>=f&&o<=C)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&&Sl(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};Ze(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 Nv=Fv,kv=3e3;function Mv({children:c=null,onEntering:e,onEntered:t,onExiting:n,onExited:s}){const[i,o]=v.useState(!1),l=v.useRef(),a=nr(c),d=v.useCallback(()=>{o(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{o(!1)},kv)},[o,l]);return v.useEffect(()=>{a!==c&&c!=null&&d()},[c,a,o,d]),v.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 Av 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 Ov=Av,Lv=1,Su=oe.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:f=null,selectDistinctColumns:C=Ie,pendingRowCount:S=0,pendingDataMap:b=jn,frozenColumns:w,formatColumns:T,columnHeaderGroups:E})=>{const y=v.useMemo(()=>Ce.getModelViewportColumns(e,s,i,u,m,g,Lv),[e,s,i,u,m,g]);return v.useEffect(function(){c.filter=o},[c,o]),v.useEffect(function(){const I=[...d];a!==F.REVERSE_TYPE.NONE&&I.push(c.dh.Table.reverse()),c.sort=I},[c,d,a]),v.useEffect(function(){c.formatter=l},[c,l]),v.useEffect(function(){c.isCustomColumnsAvailable&&(c.customColumns=h)},[c,h]),v.useEffect(function(){c.isFormatColumnsAvailable&&(c.formatColumns=T)},[c,T]),v.useEffect(function(){c.setViewport(t,n,y)},[c,t,n,y]),v.useEffect(function(){c.isRollupAvailable&&(c.rollupConfig=p)},[c,c.isRollupAvailable,p]),v.useEffect(function(){c.isSelectDistinctAvailable&&(c.selectDistinctColumns=C)},[c,C]),v.useEffect(function(){c.isTotalsAvailable&&(c.totalsConfig=f)},[c,c.isTotalsAvailable,f]),v.useEffect(function(){c.pendingRowCount=S},[c,S]),v.useEffect(function(){c.pendingDataMap=b},[c,b]),v.useEffect(function(){w&&c.updateFrozenColumns(w)},[c,w]),v.useEffect(function(){c.columnHeaderGroups=E},[c,E]),null});Su.displayName="IrisGridModelUpdater";const _v=Su,wn=Object.freeze({SORT_UP:"sortUp",SORT_DOWN:"sortDown",CARET_DOWN:"caretDown",CARET_RIGHT:"caretRight",CELL_OVERFLOW:"cellOverflow"}),Jd=10,va=16;class Qi extends Nt{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,og),this.setIcon(wn.SORT_DOWN,lg),this.setIcon(wn.CARET_DOWN,Vn),this.setIcon(wn.CARET_RIGHT,Yc),this.setIcon(wn.CELL_OVERFLOW,ag)}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:va/t.icon[0],d:va/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=N(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=N(l,i),h=N(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,f=N(d,n,0),C=N(h,n)+u,S=a.get(n);if(S==null)return;const b=o.columns[S]?.name;if(b==null)return;const w=F.getSortForColumn(o.sort,b);if(!w)return;const T=this.getSortIcon(w);if(!T)return;const E=o.textForColumnHeader(S);if(E===void 0)return;const y=g.get(e.font)??Nt.DEFAULT_FONT_WIDTH;D(y);const R=E.length*y,I=u+C+R+p;let{maxX:x}=s;x-=p;const O=u+C+f-p-1,k=I>x?I+1:Math.min(x,O),_=w.direction===F.sortDirection.ascending?-6:-12,M=m*.5+_;e.save(),e.beginPath(),e.rect(C,0,f,m),e.clip(),e.fillStyle=l.headerSortBarColor,e.translate(k,M),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:f}=n,C=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,C,u,a-1),e.fillStyle=i.headerBarCasingColor,e.fillRect(d,C+a-1,u,1);const S=C;e.strokeStyle=i.filterBarSeparatorColor,e.beginPath();for(let b=0;b<g.length;b+=1){const w=g[b],T=N(m,w),E=N(f,w),y=N(p,w);if(s.isFilterable(T)&&y>0){const R=d+(E??0);e.rect(R+.5,S+.5,y,a-2)}}e.stroke();for(let b=0;b<g.length;b+=1){const w=g[b],T=N(p,w),y=N(f,w)+d;this.drawExpandedFilterHeader(e,t,w,y,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:f,headerColor:C}=l,S=u-m,b=h.get(n);if(b===void 0)return;const w=a.get(b),T=d.get(b);if(w==null&&T==null)return;let E=null;if(w!=null){const{text:R}=w;if(E=R,E||(E=F.getFilterText(w.filter)),E!=null){const{fontWidths:I}=o;let x=I.get(e.font);(x==null||x===0)&&(x=e.measureText("8").width,x||(x=10));const O=(i-f*2)/x;O<=0?E="":E.length>O&&(E=`${E.substring(0,O-1)}…`)}}if(e.save(),Qi.isFilterValid(T,w)&&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,I=S+2,x=i-3,O=m-5;e.strokeRect(R,I,x,O)}if(E!=null&&E!==""){const R=s+f,I=S+m*.5+1;e.fillStyle=C,e.fillText(E,R,I)}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 f=h[p],C=u.get(f),S=m.get(f);if(S!=null&&C!=null){const b=S+l;this.drawCollapsedFilterHeader(e,t,f,b,C)}}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:f,filterBarActiveColor:C,filterBarActiveBackgroundColor:S,filterBarErrorColor:b}=l;e.save();const w=Qi.isFilterValid(p,g);S!=null&&g==null&&p==null?e.fillStyle=S:C!=null&&w?e.fillStyle=C:b!=null&&(e.fillStyle=b);const T=s+1,E=u-f,y=i-1,R=f-1;e.fillRect(T,E,y,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:f,height:C,horizontalBarHeight:S,verticalBarWidth:b,allRowHeights:w,allRowYs:T,width:E}=n;if(f<=0||p.length===0)return;const{cellHorizontalPadding:y,floatingGridRowColor:R,floatingRowBackgroundColors:I,headerColor:x,rowHoverBackgroundColor:O}=l;e.translate(d,a),e.beginPath();const k=Math.min(h,E-f-b-d);e.fillStyle=I,m>0&&e.rect(k,0,f,m),g>0&&e.rect(k,C-a-S-g,f,g),e.fill();const _=i!=null&&o!=null&&i>=d&&i<=h+f?A.getRowAtY(o,n):null;if(O!=null&&_!==null&&p.includes(_)){e.fillStyle=O;const $=T.get(_),H=w.get(_);D($),D(H),e.fillRect(k,$,f,H)}if(e.beginPath(),R!=null&&(e.strokeStyle=R),m>0&&(e.moveTo(k+.5,.5),e.lineTo(k+.5,m-.5)),g>0){const $=C-a-S-g;e.moveTo(k-.5,$+.5),e.lineTo(k-.5,$+g-.5)}e.stroke(),e.fillStyle=x,e.textAlign="left";const M=k+y;for(let $=0;$<p.length;$+=1){const H=p[$],K=w.get(H),L=T.get(H),G=u.get(H);if(L!=null&&K!=null&&G!=null){const ee=L+K*.5;e.fillText(s.textForRowFooter(G),M,ee)}}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}=A.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}=A.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 f=this.getCachedTruncatedString(t,m,g,p,o.truncationCharForCell(u,h));return t.restore(),m!==""&&f!==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}=A.getCellInfoFromXY(e,t,n);if(a==null||l==null||d==null)return i;const{width:h,verticalBarWidth:u}=n,{cellHorizontalPadding:m}=s,g=va+2*m,p=o,C=Math.min(n.gridX+a+l,h-u)-g,S=n.gridY+d;return{left:C,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}=A.getCellInfoFromXY(e,t,n);D(a),D(l),D(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 Pv=Qi,jv="12px Fira Sans, sans-serif",Hv="#f0f0ee",Uv="#1a171a",ie={"grid-bg":"#211f22",font:jv,white:Hv,black:Uv,"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"},Bv=Object.freeze({backgroundColor:ie["grid-bg"],white:ie.white,black:ie.black,font:ie.font,headerBackgroundColor:ie["header-bg"],headerColor:ie["header-color"],headerSeparatorColor:ie["header-separator-color"],headerSeparatorHoverColor:ie["header-separator-hover-color"],headerHiddenSeparatorHoverColor:ie["header-hidden-separator-hover-color"],headerSortBarColor:ie["header-sort-bar-color"],headerReverseBarColor:ie["header-reverse-bar-color"],headerBarCasingColor:ie["header-bar-casing-color"],headerFont:ie["header-font"],rowBackgroundColors:ie["row-background-colors"],rowHoverBackgroundColor:ie["row-hover-bg"],selectionColor:ie["selection-color"],selectionOutlineColor:ie["selection-outline-color"],selectionOutlineCasingColor:ie["selection-outline-casing-color"],selectedRowHoverBackgroundColor:ie["selected-row-hover-bg"],scrollBarBackgroundColor:ie["scroll-bar-bg"],scrollBarHoverBackgroundColor:ie["scroll-bar-hover-bg"],scrollBarCasingColor:ie["scroll-bar-casing-color"],scrollBarCornerColor:ie["scroll-bar-corner-color"],scrollBarColor:ie["scroll-bar-color"],scrollBarHoverColor:ie["scroll-bar-hover-color"],scrollBarActiveColor:ie["scroll-bar-active-color"],scrollBarSelectionTickColor:ie["selected-row-hover-bg"],scrollBarActiveSelectionTickColor:ie["scroll-bar-active-selection-tick-color"],textColor:ie["text-color"],hyperlinkColor:ie["hyperlink-color"],positiveNumberColor:ie["positive-number-color"],negativeNumberColor:ie["negative-number-color"],zeroNumberColor:ie["zero-number-color"],dateColor:ie["date-color"],pendingTextColor:ie["pending-text-color"],errorTextColor:ie["error-text-color"],nullStringColor:ie["null-string-color"],filterBarActiveBackgroundColor:ie["filter-bar-active-bg"],filterBarExpandedBackgroundColor:ie["filter-bar-expanded-bg"],filterBarExpandedActiveBackgroundColor:ie["filter-bar-expanded-active-bg"],filterBarExpandedActiveCellBackgroundColor:ie["filter-bar-expanded-active-cell-bg"],filterBarSeparatorColor:ie["filter-bar-separator-color"],filterBarActiveColor:ie["filter-bar-active-color"],filterBarErrorColor:ie["filter-bar-error-color"],filterIconColor:ie["filter-icon-color"],scrimColor:ie["scrim-color"],contextMenuSortIconColor:ie["context-menu-sort-icon-color"],contextMenuReverseIconColor:ie["context-menu-reverse-icon-color"],allowRowResize:!1,autoSelectRow:!0,gridColumnColor:null,gridRowColor:null,groupedColumnDividerColor:ie["grouped-column-divider-color"],columnHoverBackgroundColor:null,headerHorizontalPadding:12,scrollBarSize:13,scrollBarHoverSize:16,minScrollHandleSize:24,rowHeight:parseInt(ie["row-height"],10)||19,columnWidth:100,rowHeaderWidth:0,rowFooterWidth:60,columnHeaderHeight:parseInt(ie["header-height"],10)||30,filterBarHeight:30,filterBarCollapsedHeight:5,sortHeaderBarHeight:2,reverseHeaderBarHeight:4,filterBarHorizontalPadding:4,scrimBlurSize:25,minScrimTransitionTime:150,maxScrimTransitionTime:350,scrollSnapToRow:!0,linkerColumnHoverBackgroundColor:ie["linker-column-hover-bg"],treeLineColor:ie["tree-line-color"],treeMarkerColor:ie["tree-marker-color"],treeMarkerHoverColor:ie["tree-marker-hover-color"],floatingGridColumnColor:null,floatingGridRowColor:ie["floating-grid-row-color"],floatingRowBackgroundColors:ie["floating-row-background-colors"],floatingDividerInnerColor:ie["floating-divider-inner-color"],floatingDividerOuterColor:ie["floating-divider-outer-color"],overflowButtonColor:ie["overflow-button-color"],overflowButtonHoverColor:ie["overflow-button-hover-color"]}),ec=Bv;const Ta=J.module("ColumnStatistics"),Vv={SIZE:"Number of Rows"};class Tl extends v.Component{static AUTO_GENERATE_LIMIT=1e5;static getStatsLabel(e){return Vv[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<Tl.AUTO_GENERATE_LIMIT&&this.handleGenerateStatistics():this.setState({loading:!1})}handleGenerateStatistics(){this.setState({loading:!0});const{column:e,model:t}=this.props;this.cancelablePromise=be.makeCancelable(t.columnStatistics(e)),this.cancelablePromise.then(this.handleStatistics).catch(this.handleError)}handleStatistics(e){Ta.debug("Received statistics",e);const{model:t,onStatistics:n}=this.props,s=[];e.statisticsMap.forEach((i,o)=>{s.push({operation:Tl.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&&be.isCanceled(e)){Ta.debug("Called handleError on a cancelled promise result");return}Ta.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:f,className:C,value:S,type:b}=i[p],w=b?t.displayString(S,b):t.displayString(S,e.type,e.name),T=r.jsxs(oe.Fragment,{children:[r.jsx("div",{className:z("column-statistic-operation",C),children:f}),r.jsx("div",{className:"column-statistic-value",children:w})]},f);a.push(T)}const u=Pe(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(Pl,{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)?rg:dg,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(P,{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(P,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,icon:r.jsx(X,{icon:ar,className:"mr-1"}),children:"Refresh"}),s&&r.jsxs("div",{className:"column-statistics-loading",children:[r.jsx(Nn,{className:"mr-2"}),"Calculating Stats..."]})]})}}const $v=Tl;const Vo=J.module("AdvancedFilterCreatorFilterItem");class Pr extends v.PureComponent{static getLabelForFilter(e,t){try{if(F.isNumberType(e)||F.isCharType(e))return gh(t);if(F.isTextType(e))return mh(t);if(F.isDateType(e))return ph(t);if(F.isBooleanType(e))return zf(t);throw new Error(`Unrecognized column type: ${e}`)}catch(n){return Vo.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;Vo.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){Vo.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(){Vo.debug("delete");const{onDelete:e}=this.props;e()}getCachedIsValid=ce((e,t,n,s,i)=>{try{return!n||i.makeAdvancedValueFilter(e,t,n,s)!=null}catch{return!1}});render(){const{column:e,filterTypes:t,formatter:n,tableUtils:s}=this.props,{selectedType:i,value:o}=this.state,l=!F.isBooleanType(e.type),a=[],d=this.getCachedIsValid(e,i,o,n.timeZone,s);for(let h=0;h<t.length;h+=1){const u=t[h],m=Pr.getLabelForFilter(e.type,u),g=r.jsx("option",{value:u,children:m},u);a.push(g)}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:i,onChange:this.handleTypeChange,ref:h=>{this.typeDropdown=h},children:a})}),l&&r.jsx("div",{className:"form-group col",children:r.jsx("div",{className:"input-group",children:r.jsx("input",{type:"text",className:z("form-control",{error:!d}),placeholder:"Enter value",value:o,onChange:this.handleValueChange})})}),r.jsx("div",{className:"form-group col-1 px-0",children:r.jsx(P,{kind:"ghost",className:"w-100 h-100 p-0 m-0",onClick:this.handleDelete,icon:$t,tooltip:"Remove Filter"})})]})})}}const Wv=Pr,tc=J.module("AdvancedFilterCreatorSelectValueList");class El extends v.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);const{selectedValues:t,dh:n}=this.props;this.dh=n,this.list=null,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)}dh;list;handleSelect(e,t){const{invertSelection:n}=this.props;let{selectedValues:s}=this.state;s=[...s];const i=El.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=El.indexOf(e,n);return t?s<0:s>=0}startListening(e){e.addEventListener(this.dh.Table.EVENT_UPDATED,this.handleTableUpdate)}stopListening(e){e.removeEventListener(this.dh.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(xm,{itemCount:s,items:n,offset:e,onSelect:this.handleSelect,onViewportChange:this.handleViewportChange,ref:i=>{this.list=i}}),r.jsx(Vt,{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 Gv=El;class jr extends v.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{dh:t,invertSelection:n,selectedValues:s}=e;this.tableUtils=new F(t),this.state={filters:[],invertSelection:n,selectedValues:s,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;tableUtils;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,{tableUtils:s}=this,i=e?.columns[0],o=[];if(i==null)return;let l;if(t.length>0){let a=null;F.isCharType(i.type)?a=s.makeQuickFilter(i,t):F.isTextType(i.type)?a=s.makeQuickFilter(i,`~${t}`,n):a=s.makeQuickFilter(i,`>=${t}`,n),a!=null?o.push(a):l="Invalid search text"}this.setState({filters:o,error:l})}render(){const{error:e,filters:t,invertSelection:n,selectedValues:s,searchText:i,table:o}=this.state,{dh:l,formatter:a,showSearch:d}=this.props,h=this.getColumnName(),u=this.getDisplayedValueText(),m=h?`Find ${h}...`:"";return r.jsxs("div",{className:"advanced-filter-creator-select-value",children:[r.jsxs("div",{className:d?"form-group":"",children:[r.jsx("label",{htmlFor:"advanced-filter-creator-select-value-input",children:"Select Values"}),d&&r.jsx("input",{type:"text",className:z("form-control",{"is-invalid":e!=null}),id:"advanced-filter-creator-select-value-input",placeholder:m,value:i,onChange:this.handleSearchChange})]}),r.jsx(Gv,{dh:l,table:o,filters:t,invertSelection:n,selectedValues:s,formatter:a,onChange:this.handleListChange}),r.jsxs("div",{className:"advanced-filter-creator-select-meta-row",children:[r.jsxs("div",{children:[r.jsx(P,{kind:"ghost",onClick:this.handleSelectAllClick,children:"Select All"}),r.jsx(P,{kind:"ghost",onClick:this.handleClearAllClick,children:"Clear"})]}),r.jsx(Vt,{in:u!=null,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:r.jsx("div",{className:"row-count-info",children:u})})]})]})}}const zv=jr;const Hi=J.module("AdvancedFilterCreator");class us extends v.PureComponent{static debounceFilterUpdate=250;static defaultProps={options:{filterItems:null,filterOperators:null,invertSelection:!0,selectedValues:[]},sortDirection:null};static makeFilterItem(){return{key:Ge()}}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=oe.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:Ge()}))??[];o.length===0&&o.push(us.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=ce(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=>{be.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(us.makeFilterItem()),t=t.concat(Un.and),this.setState({filterItems:e,filterOperators:t})}handleAddOr(){let{filterItems:e,filterOperators:t}=this.state;e=e.concat(us.makeFilterItem()),t=t.concat(Un.or),this.setState({filterItems:e,filterOperators:t})}handleChangeFilterOperator(e,t){let{filterOperators:n}=this.state;n=[...n],Im(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(us.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:[us.makeFilterItem()],filterOperators:[],selectedValues:[],invertSelection:!0}),this.startUpdateTimer()}handleSortDown(e){const t=ws.isModifierKeyDown(e);this.sortTable(F.sortDirection.descending,t)}handleSortUp(e){const t=ws.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,us.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,tableUtils:a}=this.props,{formatter:d}=l,h=e.filter(({selectedType:p,value:f})=>p!=null&&f!=null&&f!==""),u=t.filter((p,f)=>p!=null&&e[f].selectedType!=null&&e[f].value!=null&&e[f].value!=="").slice(0,h.length-1),m={filterItems:h,filterOperators:u,invertSelection:n,selectedValues:s},g=a.makeAdvancedFilter(i,m,d.timeZone);o(i,g,m)}render(){const{column:e,model:t,sortDirection:n,formatter:s,tableUtils:i}=this.props,{filterItems:o,filterOperators:l,invertSelection:a,selectedValues:d,valuesTable:h,valuesTableError:u}=this.state,{dh:m,isValuesTableAvailable:g}=t,p=F.isBooleanType(e.type),f=F.isDateType(e.type),C=this.getFilterTypes(e.type),S=e.type.substring(e.type.lastIndexOf(".")+1),b=[];if(!p&&C.length)for(let E=0;E<o.length;E+=1){const y=o[E],{key:R,selectedType:I,value:x}=y,O=r.jsx(Wv,{column:e,filterTypes:C,onChange:this.getFilterChangeHandler(E),onDelete:this.getFilterDeleteHandler(E),selectedType:I,value:x,formatter:s,tableUtils:i},R);if(b.push(O),E<l.length){const _=l[E]===Un.and,M=r.jsxs("div",{className:"form-row justify-content-end advanced-filter-creator-filter-operator",children:[r.jsx(P,{kind:"ghost",className:z("filter-operator",{active:_}),onClick:()=>this.handleChangeFilterOperator(E,Un.and),children:"AND"}),r.jsx(P,{kind:"ghost",className:z("filter-operator",{active:!_}),onClick:()=>this.handleChangeFilterOperator(E,Un.or),children:"OR"})]},`filterOperator${R}`);b.push(M)}}const w=this.shouldShowAddFilter(),T=r.jsxs("div",{className:z("form-row justify-content-end add-filter-item",{hidden:!w}),children:[r.jsx("span",{className:"text-muted",children:r.jsx(X,{icon:Ts})}),r.jsx(P,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddAnd,disabled:!w,tooltip:"Add filter with AND",children:"AND"}),r.jsx(P,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddOr,disabled:!w,tooltip:"Add filter with OR",children:"OR"})]},"addFilterItem");return b.push(T),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(P,{kind:"ghost",className:z("sort-operator",{active:n===F.sortDirection.descending}),onClick:this.handleSortDown,icon:fd,tooltip:`Sort ${e.name} Descending`}),r.jsx(P,{kind:"ghost",className:z("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:["(",S,")"]})]}),b,g&&u==null&&r.jsxs(r.Fragment,{children:[!p&&r.jsx("hr",{}),r.jsx("div",{className:"form-group",children:r.jsx(zv,{dh:m,table:h,onChange:this.handleSelectValueChange,invertSelection:a,selectedValues:d,formatter:s,showSearch:!f,timeZone:s.timeZone})})]}),r.jsxs("div",{className:"form-row justify-content-end",children:[r.jsx(P,{kind:"secondary",className:"mr-2",onClick:this.handleReset,children:"Reset"}),r.jsx(P,{kind:"primary",onClick:this.handleDone,children:"Done"})]})]}),r.jsx("div",{tabIndex:0,onFocus:this.handleFocusTrapEnd})]})}}const Kv=us;const nc=J.module("Aggregations");function Yv({isRollup:c,settings:e,onChange:t,onEdit:n}){const{aggregations:s,showOnTop:i}=e,o=v.useMemo(()=>Bw.filter(x=>!s.some(O=>O.operation===x)),[s]),[l,a]=v.useState(o[0]),[d,h]=v.useState([]),u=v.useCallback(x=>{t({...e,...x})},[t,e]),m=v.useCallback(x=>{u({aggregations:x})},[u]),g=v.useCallback(x=>{u({showOnTop:x})},[u]),p=v.useCallback(()=>{nc.debug("handleDragStart"),hn.startDragging()},[]),f=v.useCallback(({destination:x,source:O})=>{if(nc.debug("handleDragEnd",x,O),hn.stopDragging(),x===null)return;let k=x.index;O.index<x.index&&(k+=1);const _=[...s],M=hn.reorder(_,d,_,k),$=hn.adjustDestinationIndex(k,d),H=[[$,$+M.length-1]];m(_),h(H)},[m,s,d,h]),C=v.useCallback(x=>{a(x)},[a]),S=v.useCallback(()=>{m([...s,{operation:l,selected:[],invert:!0}])},[s,l,m]),b=v.useCallback(x=>{m(s.filter((O,k)=>k!==x))},[s,m]),w=v.useCallback(x=>{h(x)},[h]),T=v.useCallback(x=>{const O=s[x];ps.isRollupOperation(O.operation)||n(O)},[s,n]),E=v.useCallback(x=>{g(x.target.value==="true")},[g]);v.useEffect(function(){o.length>0&&!o.includes(l)&&a(o[0])},[o,l]);const y=v.useCallback(({item:x,itemIndex:O,isClone:k=!1,selectedCount:_})=>{const M=x.operation,$=k?`${_}`:void 0,H=k?"item-list-item-clone":void 0,K=ps.isRollupOperation(x.operation),L=!k&&!K;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:z("item-list-item-content","draggable-item-list-item-content",H),children:[r.jsxs("span",{className:"title",children:[M,!c&&K&&r.jsxs("span",{className:"small text-warning",children:[r.jsx(X,{icon:Zc})," Requires rollup"]})]}),rn.renderBadge({text:$}),rn.renderHandle()]}),!k&&r.jsxs(r.Fragment,{children:[r.jsx(P,{kind:"ghost",className:"btn-edit",icon:mo,tooltip:"Edit Columns",onClick:()=>n(x),disabled:!L}),r.jsx(P,{kind:"ghost",className:"btn-delete",icon:$t,tooltip:"Delete Aggregation",onClick:()=>b(O)})]})]})},[b,n,c]),R=o.length>0,I=s.length>0;return r.jsxs("div",{className:"aggregations",children:[R&&r.jsxs("div",{className:"form-inline",children:[r.jsx(Dm,{onChange:C,value:l,children:o.map(x=>r.jsx(Fm,{value:x,children:x},x))}),r.jsxs("button",{type:"button",className:"btn btn-link btn-add",onClick:S,children:[r.jsx(X,{icon:Ts}),"Add Aggregation"]})]}),R&&I&&r.jsx("hr",{}),I&&r.jsxs(r.Fragment,{children:[!c&&r.jsxs("div",{className:"form-inline",children:[r.jsx("label",{children:"Placement: "}),r.jsxs(jl,{onChange:E,value:`${i}`,children:[r.jsx(Gn,{value:"true",children:"Top"}),r.jsx(Gn,{value:"false",children:"Bottom"})]})]}),r.jsx(Ol,{onDragStart:p,onDragEnd:f,children:r.jsx(rn,{className:"selected-aggregations",itemCount:s.length,items:s,renderItem:y,offset:0,onSelectionChange:w,onSelect:T,selectedRanges:d,isMultiSelect:!0})})]})]})}const qv=30;function Xv({aggregation:c,columns:e,onChange:t}){const[n,s]=v.useState(-1),[i,o]=v.useState(-1),[l,a]=v.useState(0),{invert:d,selected:h}=c,u=v.useRef(null),m=v.useCallback(E=>h.includes(E)?!d:d,[d,h]),g=v.useMemo(()=>{let E=Lr(e,c.operation);return l!==0&&(E=F.sortColumns(E,l===1)),E},[e,c.operation,l]),p=v.useMemo(()=>n>=0?g.slice(n,i+1).map(E=>({value:E.name,displayValue:E.name,isSelected:m(E.name)})):[],[g,m,i,n]),f=v.useCallback(E=>{const{name:y}=g[E],R=h.indexOf(y);let I=[...h],x=d;R>=0?I.splice(R,1):(I.push(y),I.length===g.length&&(I=[],x=!d)),t({...c,selected:I,invert:x})},[c,d,g,h,t]),C=v.useCallback(()=>{a(0),t({...c,selected:[],invert:!0})},[c,t]),S=v.useCallback((E,y)=>{s(E),o(y)},[s,o]),b=v.useCallback(()=>{h.length===0?t({...c,invert:!d}):t({...c,selected:[],invert:!0})},[c,d,t,h]),w=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(tn,{checked:w,onChange:b,children:"Toggle All"}),r.jsx("div",{className:"spacer"}),r.jsx(Vt,{in:T,timeout:Ye.transitionSlowMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:r.jsx(P,{kind:"ghost",className:"btn-reset",onClick:C,children:"Reset"})}),r.jsx(P,{kind:"ghost",className:z({active:l===1}),icon:rr,tooltip:"Sort ascending",onClick:()=>a(1)}),r.jsx(P,{kind:"ghost",className:z({active:l===2}),icon:dr,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:E})=>r.jsx(tn,{checked:m(E.value),children:E.displayValue}),onSelect:f,onViewportChange:S,rowHeight:qv,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 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",{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 Jv(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 eT(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 tT(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 nT(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 sT(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=J.module("ChartBuilder");class an extends v.PureComponent{static getMaxSeriesCount(e,t){switch(t){case e.plot.SeriesPlotStyle.PIE:return 1;case e.plot.SeriesPlotStyle.HISTOGRAM:return 0;default:return 100}}static makeSeriesItem(e){return{id:Ge.generate(),value:e}}static makeDefaultSeriesItems(e,t,n){if(an.getMaxSeriesCount(e,t)===0||n==null||n.length===0)return[];const i=n.length>1?n[1].name:n[0].name;return[an.makeSeriesItem(i)]}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,dh:s}=t,i=this.getTypes()[0],o=an.getDefaultXAxis(i,n),l=an.makeDefaultSeriesItems(s,i,n);this.state={type:i,seriesItems:l,xAxis:o,isLinked:!0}}getTypes(){const{model:e}=this.props,{dh:t}=e;return[t.plot.SeriesPlotStyle.LINE,t.plot.SeriesPlotStyle.BAR,t.plot.SeriesPlotStyle.SCATTER,t.plot.SeriesPlotStyle.PIE]}getTypeName(e){const{model:t}=this.props,{dh:n}=t;switch(e){case n.plot.SeriesPlotStyle.LINE:return"Line";case n.plot.SeriesPlotStyle.BAR:return"Bar";case n.plot.SeriesPlotStyle.SCATTER:return"Scatter";case n.plot.SeriesPlotStyle.PIE:return"Pie";case n.plot.SeriesPlotStyle.HISTOGRAM:return"Histogram";default:return e}}getTypeIcon(e){const{model:t}=this.props,{dh:n}=t;switch(e){case n.plot.SeriesPlotStyle.LINE:return r.jsx(Jv,{});case n.plot.SeriesPlotStyle.BAR:return r.jsx(Zv,{});case n.plot.SeriesPlotStyle.SCATTER:return r.jsx(tT,{});case n.plot.SeriesPlotStyle.PIE:return r.jsx(eT,{});case n.plot.SeriesPlotStyle.HISTOGRAM:return r.jsx(Qv,{});default:return null}}getXAxisLabel(e){const{model:t}=this.props,{dh:n}=t;switch(e){case n.plot.SeriesPlotStyle.PIE:return"Labels";case n.plot.SeriesPlotStyle.HISTOGRAM:return"Data";default:return"X-Axis"}}getSeriesLabel(e){const{model:t}=this.props,{dh:n}=t;switch(e){case n.plot.SeriesPlotStyle.PIE:return"Values";default:return"Series"}}handleAddSeries(){this.setState(e=>{const{seriesItems:t}=e,n=[...t],{model:s}=this.props,{columns:i}=s;return n.push({id:Ge.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,dh:n}=e,s=this.getTypes()[0],i=an.getDefaultXAxis(s,t),o=an.makeDefaultSeriesItems(n,s,t),l=!0;this.setState({type:s,seriesItems:o,xAxis:i,isLinked:l},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=this.getTypes()[s];sc.debug2("handleTypeSelect",i),this.setState(o=>{const{model:l}=this.props,{dh:a}=l,d=an.getMaxSeriesCount(a,i);let{seriesItems:h}=o;if(h=h.slice(0,d),h.length===0&&d>0){const{columns:u}=l;h=an.makeDefaultSeriesItems(a,i,u)}return{type:i,seriesItems:h}},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,dh:n}=e,{seriesItems:s,type:i,xAxis:o,isLinked:l}=this.state,a=an.getMaxSeriesCount(n,i),d=this.getXAxisLabel(i),h=this.getSeriesLabel(i),u=s.length>0,m=s.length<a;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:this.getTypes().map((g,p)=>{const f=g;return r.jsx("div",{className:"col col-chart-type",children:r.jsxs("button",{type:"button",className:z("btn","btn-icon","btn-chart-type",{active:g===i}),"data-index":p,onClick:this.handleTypeClick,children:[this.getTypeIcon(g),this.getTypeName(g)]})},f)})})]}),r.jsx("hr",{}),r.jsxs("div",{className:"form-row form-inline",children:[r.jsx("label",{className:"col-2 label-left",children:d}),r.jsx("select",{className:"form-control custom-select select-x-axis col",value:o,onChange:this.handleXAxisChange,children:t.map(g=>r.jsx("option",{value:g.name,children:g.name},g.name))})]}),u&&r.jsx("hr",{}),s.map((g,p)=>r.jsxs("div",{className:"form-row form-inline form-series-item","data-testid":`form-series-item-${p}`,children:[r.jsx("label",{className:"col-2 label-left",children:p===0?h:""}),r.jsx("select",{className:"form-control custom-select select-series col",value:g.value,onChange:this.handleSeriesChange,"data-testid":`select-series-item-${p}`,"data-index":p,children:t.map(f=>r.jsx("option",{value:f.name,"data-index":p,children:f.name},f.name))}),s.length>1&&r.jsx(P,{kind:"ghost",className:"btn-delete-series ml-2 px-2","data-index":p,"data-testid":`delete-series-${p}`,onClick:this.handleSeriesDeleteClick,icon:$t,tooltip:"Delete"})]},g.id)),m&&r.jsxs("div",{className:"form-row",children:[r.jsx("div",{className:"col-2"}),r.jsx(P,{kind:"ghost",className:"btn-add-series mt-1",onClick:this.handleAddSeries,icon:Ts,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:ir,icon:yi,transform:"right-5 down-5"}),r.jsx(X,{icon:l?Qc:cg,transform:"grow-2 right-8 down-6"})]})}),r.jsxs(jl,{onChange:this.handleLinkStateChange,value:`${l}`,children:[r.jsx(Gn,{value:"true",children:"Sync State"}),r.jsx(Gn,{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:l?"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:z("form-row","justify-content-end","my-3"),children:[r.jsx(P,{kind:"secondary",className:"btn-reset",onClick:this.handleReset,children:"Reset"}),r.jsx(P,{kind:"primary",type:"submit",className:"btn-submit",children:"Create"})]})]})})}}const iT=an;class oT extends v.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=zn.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:z("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"}),lT=()=>{};function aT({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=v.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:z("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:z("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(P,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{i(c)},icon:$t,tooltip:"Delete custom column"}),r.jsx(P,{kind:"ghost",className:"btn-drag-handle",onClick:lT,...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(oT,{editorSettings:{language:"deephavenDb"},editorIndex:t,value:n,onContentChanged:h,onTab:o,invalid:l})]}),r.jsx("hr",{})]})})}const Ea=[];class rT extends rw{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(e){super(),this.dh=e,this.listenerCount=0}dh;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 Ea}get backColumns(){return Ea}get frozenColumns(){return Ea}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=rT;class Bs extends v.Component{static SUCCESS_SHOW_DURATION=750;static makeCustomColumnInputEventKey(){return Ge.generate()}static createCustomColumnInput(){return{eventKey:Ge.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=ce((e,t)=>e.find(n=>n.eventKey===t));getInputIndex=ce((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:Ss})," 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(aT,{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(P,{kind:n?"success":"primary",className:z("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:or})," 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(Ol,{onDragStart:hn.startDragging,onDragEnd:this.handleDragEnd,children:r.jsx(tr,{droppableId:"droppable-custom-columns",children:(n,s)=>r.jsxs("div",{ref:n.innerRef,...n.droppableProps,className:z("droppable-container",{dragging:s.draggingFromThisWith}),children:[this.renderInputs(),n.placeholder]})})}),r.jsx("div",{className:"pt-1 px-3",children:r.jsx(P,{kind:"ghost",className:"btn-add-column",onClick:this.handleAddColumnClick,icon:Ts,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(P,{kind:"secondary",className:"mr-2",onClick:e,children:"Cancel"}),this.renderSaveButton()]})]})]})}}const dT=Bs;var bu=(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))(bu||{});const xe=bu;const Ui=J.module("RollupRows"),cT=150,$o="grouped-rollup-rows",Wo="ungrouped-rollup-rows";class Zt extends v.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=oe.createRef(),this.groupedList=oe.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===Zt.SORT.ASCENDING?null:Zt.SORT.ASCENDING}))}handleSortDescending(){this.setState(({sort:e})=>({sort:e===Zt.SORT.DESCENDING?null:Zt.SORT.DESCENDING}))}resetSelection(){this.setState({ungroupedSelectedRanges:[],groupedSelectedRanges:[]})}search=We(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]));D(s),this.setState({ungroupedSelectedRanges:n}),n.length>0&&this.ungroupedList.current&&this.ungroupedList.current.scrollToItem(s)},cT);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(f=>f.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:Zt.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=we((e,t)=>e.filter(n=>Zt.isGroupable(n)&&t.find(s=>s===n.name)==null));getCachedSortedColumns=we((e,t)=>t==null?[...e]:F.sortColumns(e,t===Zt.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(P,{kind:"ghost",className:"btn btn-link btn-link-icon btn-delete-grouping float-right",onClick:()=>this.handleDeleteClicked(t),children:r.jsx(X,{icon:$t})})]})}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:z("rollup-rows",{"is-dragging":t!=null}),tabIndex:0,children:r.jsxs(Ol,{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(tr,{droppableId:"placeholder",children:(g,p)=>r.jsx("div",{className:z("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(P,{kind:"ghost",className:z("btn-link btn-link-icon",{active:a===Zt.SORT.ASCENDING}),onClick:this.handleSortAscending,children:[r.jsx(X,{icon:rr}),r.jsx(Je,{children:"Sort ascending"})]}),r.jsxs(P,{kind:"ghost",className:z("btn-link btn-link-icon",{active:a===Zt.SORT.DESCENDING}),onClick:this.handleSortDescending,children:[r.jsx(X,{icon:dr}),r.jsx(Je,{children:"Sort descending"})]})]}),r.jsx(rn,{className:"rollup-available-grouping-columns",draggablePrefix:Wo,droppableId:Wo,itemCount:d.length,items:d,renderItem:Zt.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(tn,{checked:o,onChange:this.handleShowConstituentsChange,children:"Constituents"}),r.jsx(tn,{checked:l,onChange:this.handleShowNonAggregatedColumnsChange,children:"Non-Aggregated Columns"})]})]})]})})}}const hT=Zt;const uT=J.module("TableCsvExporter");class Oe extends v.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(e){return e.i18n.DateTimeFormat.format(Oe.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{model:t,name:n}=e;this.state={fileName:`${n}-${Oe.getDateString(t.dh)}.csv`,downloadRowOption:Oe.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,customizedDownloadRowOption:Oe.CUSTOMIZED_ROWS_OPTIONS.FIRST,customizedDownloadRows:Oe.DEFAULT_DOWNLOAD_ROWS,includeColumnHeaders:!0,includeHiddenColumns:!1,useUnformattedValues:!1,errorMessage:null,id:Ge.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 Oe.DOWNLOAD_ROW_OPTIONS.ALL_ROWS:a.push(new Q(0,0,l-1,o-1));break;case Oe.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 Oe.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS:switch(s){case Oe.CUSTOMIZED_ROWS_OPTIONS.FIRST:a.push(new Q(0,0,l-1,Math.min(i-1,o-1)));break;case Oe.CUSTOMIZED_ROWS_OPTIONS.LAST:a.push(new Q(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=A.getModelRanges(e,n);if(!s&&i.length>0){const l=i.map(Q.makeColumn);o=Q.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){uT.error("CSV download failed",u),this.setState({errorMessage:r.jsxs("p",{children:[r.jsx(X,{icon:Ss})," ",`${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===Oe.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS&&e.length===0?(this.setState({errorMessage:r.jsxs("p",{children:[r.jsx(X,{icon:Ss})," No rows selected. Please select some rows in the table."]})}),!1):t===Oe.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS&&n<=0?(this.setState({errorMessage:r.jsxs("p",{children:[r.jsx(X,{icon:Ss})," 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:f}=this.state,{rowCount:C}=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(jl,{onChange:this.handleDownloadRowOptionChanged,value:a,disabled:t,children:[r.jsxs(Gn,{value:Oe.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,"data-testid":"radio-csv-exporter-download-all",children:["All Rows",r.jsx("span",{className:"text-muted ml-2",children:`(${C.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`})]}),r.jsxs(Gn,{value:Oe.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?`(${Q.rowCount(i).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`:null})]}),r.jsx(Gn,{value:Oe.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:Oe.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-${f}`,"data-testid":"input-csv-exporter-customized-rows",name:`customizedRows-${f}`,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-${f}`,children:"File Name"}),r.jsx("input",{type:"text",className:"form-control",id:`filename-${f}`,"data-testid":"input-csv-exporter-file-name",name:`filename-${f}`,value:l,onChange:S=>{this.setState({fileName:S.target.value})},disabled:t})]}),r.jsxs("div",{className:"checkbox-options",children:[r.jsx(tn,{checked:u,onChange:this.handleIncludeColumnHeadersChanged,children:"Include column headers"}),r.jsx(tn,{checked:m,onChange:this.handleIncludeHiddenColumnsChanged,children:"Include hidden columns"}),r.jsx(tn,{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===Oe.DOWNLOAD_STATUS.DOWNLOADING||o===Oe.DOWNLOAD_STATUS.INITIATING)&&r.jsxs(r.Fragment,{children:[o===Oe.DOWNLOAD_STATUS.INITIATING&&r.jsx("div",{className:"text-muted",children:"Starting Download..."}),o===Oe.DOWNLOAD_STATUS.DOWNLOADING&&r.jsxs("div",{className:"text-muted d-flex justify-content-between",children:[r.jsx("span",{children:s||s===0?`Estimated time: ${Ll.formatElapsedTime(s)}`:null}),r.jsx("span",{children:`${n}%`})]})]}),o===Oe.DOWNLOAD_STATUS.FINISHED&&r.jsx("div",{className:"text-muted text-right",children:"Download Completed"}),o===Oe.DOWNLOAD_STATUS.CANCELED&&r.jsx("div",{className:"text-muted",children:"Download Canceled"}),(o===Oe.DOWNLOAD_STATUS.DOWNLOADING||o===Oe.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===Oe.DOWNLOAD_STATUS.FINISHED&&r.jsx("div",{className:"progress",children:r.jsx("div",{className:"progress-bar bg-success",style:{width:`${n}%`}})})]}),r.jsxs(P,{kind:"primary","data-testid":"btn-csv-exporter-download",className:z("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 As=Oe,_n=J.module("TableSaver"),mT="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function gT(c){return c.added!==void 0}function pT(c){if(!gT(c))throw new Error("event is not UpdateEventData")}class Hn extends v.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(Wn.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=>{D(s),l.header!==void 0&&n.push(s(l.header)),l.rows!==void 0&&n.push(s(l.rows))},o.close=()=>{D(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
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=>(D(e.endRow),D(e.startRow),D(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);D(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(`
|
|
@@ -39,4 +39,4 @@ This note can be edited using **markdown** for styling.`;static getNewMarkdownTi
|
|
|
39
39
|
Web UI Version: ${e}
|
|
40
40
|
Java Version: ${l}
|
|
41
41
|
Barrage Version: ${o}`,children:"Copy Versions"})]})]})]}),r.jsx("div",{className:"app-settings-footer-item",children:r.jsx(hx,{})})]}),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:Uu,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=v.useRef(),h=v.useRef(),u=v.useRef(null),[m,g]=v.useState(!1),p=v.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 f(S){d.current=S.clientX,h.current=S.clientY,u.current=S.target,window.addEventListener("mousemove",p)}function C(S){u.current===S.target&&(g(!0),a(),e(),window.removeEventListener("mousemove",p)),u.current=null}return v.useEffect(function(){return function(){return window.removeEventListener("mousemove",p)}},[p]),r.jsxs("button",{type:"button",className:z("btn-context-menu",{disabled:n},{active:o&&!n},{"keyboard-active":l&&!n}),onMouseDown:f,onMouseUp:C,disabled:m,children:[r.jsx("span",{className:z("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=v.useMemo(()=>[{title:"Input Filter",icon:Zg,menuElement:r.jsx(Ci,{}),action:i=>{e(fs.INPUT_FILTER,i)},order:10},{title:"Dropdown Filter",icon:th,menuElement:r.jsx(Ci,{}),action:i=>{e(fs.DROPDOWN_FILTER,i)},order:15},{title:"Markdown Widget",icon:Qg,menuElement:r.jsx(Ci,{}),action:i=>{e(fs.MARKDOWN,i)},order:20},{title:"Filter Sets",icon:ja,menuElement:r.jsx(Ci,{}),action:i=>{e(fs.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(At.LINKER)},order:40,shortcut:Yn.LINKER},{disabled:!0,menuElement:r.jsx("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:Jg,action:()=>{n()},order:60,shortcut:Ht.TABLE.CLEAR_ALL_FILTERS}],[e,t,n]);return r.jsx($n,{popperClassName:"controls-menu-popper",actions:s})}nd.propTypes={handleControlSelect:U.func,handleToolSelect:U.func,onClearFilter:U.func};nd.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};Ci.propTypes={forwardedProps:U.shape({iconElement:U.node,displayShortcut:U.string,isMouseSelected:U.bool.isRequired,isKeyboardSelected:U.bool.isRequired,closeMenu:U.func.isRequired,menuItem:U.shape({action:U.func,title:U.string,disabled:U.bool}).isRequired})};Ci.defaultProps={forwardedProps:null};const xx=Es(Hu,null),Ix={layoutStorage:xx},Dx=c=>c.layoutStorage,Fx=c=>c.serverConfigValues;Object.entries(Ix).map(([c,e])=>po.register(c,e));const Ac=10;function Nx(c){const{onExportLayout:e,onImportLayout:t,onResetLayout:n,onSelect:s,widgets:i=[]}=c,[o,l]=v.useState(!1),[a,d]=v.useState(""),h=v.useRef(null),u=v.useRef(),m=v.useCallback((T,E)=>{T!=null&&s(T,E)},[s]),g=v.useCallback(T=>{d(T.target.value)},[]),p=v.useCallback(T=>{u.current!=null&&(Math.abs(u.current.x-T.clientX)>=Ac||Math.abs(u.current.y-T.clientY)>=Ac)&&(l(!0),window.removeEventListener("mousemove",p),m(u.current.widget,T),u.current=void 0)},[u,m]),f=v.useCallback((T,E)=>{u.current={x:T.clientX,y:T.clientY,widget:E},window.addEventListener("mousemove",p)},[p]),C=v.useCallback((T,E)=>{window.removeEventListener("mousemove",p),u.current?.widget===E&&(l(!0),m(E)),u.current=void 0},[p,u,m]),S=v.useMemo(()=>i.filter(T=>a?T.name?.toLowerCase().includes(a.toLowerCase()):!0),[a,i]).sort((T,E)=>T.name?.localeCompare(E.name??"")??0),b=v.useMemo(()=>S.map(T=>r.jsx("li",{children:r.jsxs(P,{kind:"ghost","data-testid":`panel-list-item-${T.name??""}-button`,onMouseDown:E=>{f(E,T)},onMouseUp:E=>{C(E,T)},onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&m(T)},disabled:o,onClick:()=>{},children:[r.jsx(oh,{type:T.type})," ",T.name??""]})},T.name)),[S,o,f,C,m]),w=v.useMemo(()=>b.length===0?r.jsx("span",{children:"No bound variables found."}):null,[b]);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:[w&&r.jsx("li",{className:"widget-list-message",children:w}),!w&&b]}),r.jsx("div",{children:r.jsx("hr",{})}),r.jsxs("div",{className:"widget-list-footer",children:[r.jsxs(P,{kind:"ghost",onClick:e,children:[r.jsxs("div",{className:"fa-md fa-layers",children:[r.jsx(X,{mask:Pa,icon:Sd,transform:"right-5 down-5"}),r.jsx(X,{icon:Sd,transform:"right-8 down-6"})]}),"Export Layout"]}),r.jsxs(P,{kind:"ghost",onClick:t,children:[r.jsxs("div",{className:"fa-md fa-layers",children:[r.jsx(X,{mask:Pa,icon:Ha,transform:"right-5 down-5"}),r.jsx(X,{icon:Ha,transform:"right-8 down-6"})]}),"Import Layout"]}),r.jsx(P,{kind:"ghost",icon:Gs,onClick:n,tooltip:"Reset Layout"})]})]})}const kx=async(c,e,t,n)=>{let s,i,o,l;if(sl(t)?(s=t.settings,i=t.table,o=void 0,l=t.tableSettings):(s={},i="",o=t.figure,l={}),n!==void 0&&(n.tableSettings!=null&&(l=n.tableSettings),n.table!=null&&(i=n.table),n.figure!=null&&(o=n.figure),n.settings!=null&&(s={...s,...n.settings})),o!==void 0){const h={title:o,name:o,type:c.VariableType.FIGURE},u=await e.getObject(h);return gl.makeModel(c,s,u)}const a={title:o,name:i,type:c.VariableType.TABLE},d=await e.getObject(a);return new Ce(c).applyTableSettings(d,l,go(vr.getState())),gl.makeModelFromSettings(c,s,d)},Mx=async(c,e,t,n=c.VariableType.TABLE)=>{const{table:s}=t,i={title:s,name:s,type:n},o=await e.getObject(i);return Br.makeModel(c,o)};function Ax({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(P,{kind:"tertiary",onClick:c,children:"Auto fill objects"})]})]})}function Ox(c){return c.version===2}function Lx(c){return Array.isArray(c)}const Jo=J.module("UserLayoutUtils"),_x={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:kl.COMPONENT,title:kl.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:Rl.COMPONENT,title:Rl.TITLE,isClosable:!1},{type:"react-component",component:Il.COMPONENT,title:Il.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},Px={layoutConfig:[],links:[],filterSets:[],version:2};function Ku(c){if(Ox(c))return c;if(Lx(c))return{layoutConfig:c,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${c}`)}async function jx(c,e=!0){try{const t=await c.getLayouts();if(t.length>0)try{const n=await c.getLayout(t[0]);return Ku(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?_x:Px}function Hx(c){const{filterSets:e,layoutConfig:t,links:n}=c;return{filterSets:e,layoutConfig:t,links:n,version:2}}const ol={exportLayout:Hx,getDefaultLayout:jx,normalizeLayout:Ku},el=J.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 nt=J.module("AppMainContainer");class Si extends v.Component{static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,t){return za.hydrate({...e,unzip:n=>Bc.loadAsync(n).then(s=>Object.values(s.files))},t)}static handleRefresh(){nt.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=oe.createRef(),this.state={contextActions:[{action:()=>{this.handleToolSelect(At.LINKER)},shortcut:Yn.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:Ht.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{nt.debug("Consume unhandled save shortcut")},shortcut:Yn.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){nt.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(t=>{nt.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){nt.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(Le.SELECT_NOTEBOOK,n,o,l,i,!0)}}sendClearFilter(){this.emitLayoutEvent(Ke.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...t){this.goldenLayout?.eventHub.emit(e,...t)}handleError(e){be.isCanceled(e)||nt.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,t=null){switch(nt.debug("handleControlSelect",e),e){case fs.DROPDOWN_FILTER:this.emitLayoutEvent(Ke.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:t});break;case fs.INPUT_FILTER:this.emitLayoutEvent(Ke.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:t});break;case fs.MARKDOWN:this.emitLayoutEvent(Fu.OPEN,{title:"Markdown",type:e,dragEvent:t});break;case fs.FILTER_SET_MANAGER:this.emitLayoutEvent(Ke.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:t});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){nt.debug("handleToolSelect",e);const{activeTool:t,setActiveTool:n}=this.props;n(t===e?At.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}),nt.debug("handleWidgetSelect",e,t),this.openWidget(e,t)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;nt.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(){nt.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:t}=e,n=ol.exportLayout(t);nt.info("handleExportLayoutClick exportedConfig",n);const s=new Blob([JSON.stringify(n)],{type:"application/json"}),i=_t.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){nt.error("Unable to export layout",e)}}handleImportLayoutClick(){nt.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){nt.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(){nt.info("Disconnected from server"),this.setState({isDisconnected:!0})}handleReconnect(){nt.info("Reconnected to server"),this.setState({isDisconnected:!1})}handleReconnectAuthFailed(){nt.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){nt.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 nt.error(s),r.jsx("div",{className:"error-message",children:`${s}`})}startListeningForDisconnect(){const{connection:e}=this.props;e.addEventListener(_t.IdeConnection.EVENT_DISCONNECT,this.handleDisconnect),e.addEventListener(_t.IdeConnection.EVENT_RECONNECT,this.handleReconnect),e.addEventListener(_t.CoreClient.EVENT_RECONNECT_AUTH_FAILED,this.handleReconnectAuthFailed)}stopListeningForDisconnect(){const{connection:e}=this.props;e.removeEventListener(_t.IdeConnection.EVENT_DISCONNECT,this.handleDisconnect),e.removeEventListener(_t.IdeConnection.EVENT_RECONNECT,this.handleReconnect),e.removeEventListener(_t.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 za.hydrate(e,t)}hydrateGrid(e,t){return this.hydrateTable(e,t,e.metadata.type??_t.VariableType.TABLE)}hydratePandas(e,t){return this.hydrateTable(e,t,_t.VariableType.PANDAS)}hydrateTable(e,t,n=_t.VariableType.TABLE){const{connection:s}=this.props;return{...e,getDownloadWorker:ro.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:t,makeModel:()=>Mx(_t,s,e.metadata,n)}}hydrateChart(e,t){const{connection:n}=this.props;return{...e,localDashboardId:t,makeModel:()=>{const{metadata:s,panelState:i}=e;return kx(_t,n,s,i)}}}openWidget(e,t){const{connection:n}=this.props;this.emitLayoutEvent(Se.OPEN,{dragEvent:t,fetch:()=>n.getObject(e),widget:e})}getDashboardPlugins=ce(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:f}=this.state,C=this.getDashboardPlugins(t);return r.jsxs("div",{className:z("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:Uu,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),r.jsxs("div",{children:[r.jsxs(P,{kind:"ghost",className:"btn-panels-menu",icon:ep,onClick:()=>{},children:["Controls",r.jsx(nd,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),d&&r.jsxs(P,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:tp,children:["Panels",r.jsx(Hl,{isShown:g,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:r.jsx(Nx,{widgets:f,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),r.jsx(P,{kind:"ghost",className:z("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(Sb,{emptyDashboard:r.jsx(Ax,{onAutoFillClick:this.handleAutoFillClick}),id:un,layoutConfig:l,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[r.jsx(FR,{hydrate:this.hydrateGrid,getDownloadWorker:ro.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),r.jsx(yR,{hydrate:this.hydrateChart}),r.jsx(RR,{}),r.jsx(IR,{hydrateConsole:Si.hydrateConsole,notebooksUrl:new URL("notebooks/",document.baseURI).href}),r.jsx(DR,{}),r.jsx(BR,{hydrate:this.hydratePandas}),r.jsx(UR,{}),r.jsx(HR,{}),C]}),r.jsx(Vt,{in:p,timeout:Ye.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:r.jsx(Rn,{serverConfigValues:i,onDone:this.handleSettingsMenuHide,user:n})}),r.jsx(te,{actions:h}),r.jsx("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles}),r.jsx(Pm,{isOpen:m&&!u,debounceMs:250,children:r.jsx(jm,{icon:np,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 Ux=c=>({activeTool:Yl(c),dashboardData:Ot(c,un),layoutStorage:Dx(c),plugins:uC(c),connection:ay(c,un),session:Qs(c,un)?.session,sessionConfig:Qs(c,un)?.config,user:fh(c),workspace:Kl(c),serverConfigValues:Fx(c)}),Bx=mt(Ux,{setActiveTool:Xl,updateDashboardData:kn,updateWorkspaceData:_h})(vm(Si));function Vx(){return r.jsxs("div",{className:"app",children:[r.jsx(Bx,{}),r.jsx(zc,{})]})}const $x=J.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:it.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:it.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:$e.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:st.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 $x.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 Wx{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=J.module("GrpcFileStorageTable");class Al{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=We(this.doRefresh.bind(this),Al.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 Al(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=be.makeCancelable(e.then(n=>{if(this.viewportUpdatePromise!==t)throw new _l;return this.currentViewportData=n,this.sendUpdate(),n}));t.catch(n=>{be.isCanceled(n)||zi.error("Error updating viewport",n)}),this.viewportUpdatePromise=t}refreshInternal(){try{this.refresh()}catch(e){be.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 Gx=J.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 Al(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 Gx.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=bs(()=>{this.tables.forEach(e=>e.refresh())},sd.REFRESH_THROTTLE)}const zx=J.module("AppInit");function id(c){const{workspace:e,setActiveTool:t,setApi:n,setCommandHistoryStorage:s,setDashboardData:i,setFileStorage:o,setLayoutStorage:l,setDashboardConnection:a,setDashboardSessionWrapper:d,setPlugins:h,setUser:u,setWorkspace:m,setWorkspaceStorage:g,setServerConfigValues:p}=c,f=vs(),C=Hm(),S=Um(),b=Bm(),w=v.useContext(Vm),T=v.useContext($m),[E,y]=v.useState();v.useEffect(function(){h(b)},[b,h]),v.useEffect(function(){async function k(){try{const _=await Wm(),M=await Gm(f,S,_),$=C.getStorageService(),H=new Wx($,"/layouts"),K=new sd($,"/notebooks"),L=new bi(H),G=new tx,[ee,W]=await Promise.all([C.getServerConfigValues(),L.load({isConsoleAvailable:M!==void 0})]),{data:j}=W,{settings:B}=j;B.defaultDecimalFormatOptions===void 0&&(B.defaultDecimalFormatOptions={defaultFormatString:$e.DEFAULT_FORMAT_STRING}),B.defaultIntegerFormatOptions===void 0&&(B.defaultIntegerFormatOptions={defaultFormatString:st.DEFAULT_FORMAT_STRING}),B.truncateNumbersWithPound===void 0&&(B.truncateNumbersWithPound=!1);const{shortcutOverrides:Z={}}=B,ae=nn.isMacPlatform?Z.mac??{}:Z.windows??{};Object.entries(ae).forEach(([ye,rt])=>{He.get(ye)?.setKeyState(rt)});const q={filterSets:j.filterSets,links:j.links},ne=new Map(ee),he="",Te={name:he,operateAs:he,groups:[],...w,permissions:{isACLEditor:!1,isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:ne.get("internal.webClient.appInit.canCopy")!=="false",canDownloadCsv:ne.get("internal.webClient.appInit.canDownloadCsv")!=="false",canLogout:!0,...T}};n(f),t(At.DEFAULT),p(ne),s(G),i(un,q),o(K),l(H),a(un,S),M!==void 0&&d(un,M),u(Te),g(L),m(W)}catch(_){zx.error(_),y(_)}}k()},[f,C,S,t,n,s,i,o,l,a,d,u,m,g,p,w,T]);const R=e==null&&E==null,I=!R&&E==null,x=E!=null?`${E}`:null;return r.jsxs(r.Fragment,{children:[I&&r.jsx(Vx,{}),r.jsx(Ul,{isLoading:R&&x==null,isLoaded:I,errorMessage:x})]})}id.propTypes={workspace:U.shape({}),workspaceStorage:U.shape({close:U.func}),setActiveTool:U.func.isRequired,setApi:U.func.isRequired,setCommandHistoryStorage:U.func.isRequired,setDashboardData:U.func.isRequired,setFileStorage:U.func.isRequired,setLayoutStorage:U.func.isRequired,setDashboardConnection:U.func.isRequired,setDashboardSessionWrapper:U.func.isRequired,setPlugins:U.func.isRequired,setUser:U.func.isRequired,setWorkspace:U.func.isRequired,setWorkspaceStorage:U.func.isRequired};id.defaultProps={workspace:null,workspaceStorage:null};const Kx=c=>({workspace:Kl(c),workspaceStorage:dC(c)}),Oc=mt(Kx,{setActiveTool:Xl,setApi:gC,setCommandHistoryStorage:fC,setDashboardData:lu,setFileStorage:CC,setLayoutStorage:nx,setDashboardConnection:ry,setDashboardSessionWrapper:dy,setPlugins:bC,setUser:mC,setWorkspace:Lh,setWorkspaceStorage:pC,setServerConfigValues:wC})(id),Yx=document.location.pathname;function qx(){return r.jsx(Tm,{basename:Yx,children:r.jsxs(Em,{children:[r.jsx(rd,{exact:!0,path:"/",component:Oc}),r.jsx(rd,{path:"/notebooks/:notebookPath+",component:Oc}),r.jsx(ym,{from:"*",to:"/"})]})})}function sI(){return ro.registerOnLoaded(),Mt.init({getWorker:()=>new Km}),window["__react-beautiful-dnd-disable-dev-warnings"]=!0,r.jsx(Pc,{store:vr,children:r.jsx(qx,{})})}export{sI as AppRoot,sI as default};
|
|
42
|
-
//# sourceMappingURL=AppRoot-
|
|
42
|
+
//# sourceMappingURL=AppRoot-f1671cf4.js.map
|