@deephaven/code-studio 0.32.0 → 0.32.1-beta.1
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-c431861b.js → AppRoot-caede86f.js} +4 -4
- package/build/assets/AppRoot-caede86f.js.map +1 -0
- package/build/assets/{index-3517d713.js → index-be1665ce.js} +2 -2
- package/build/assets/{index-3517d713.js.map → index-be1665ce.js.map} +1 -1
- package/build/index.html +1 -1
- package/package.json +28 -28
- package/build/assets/AppRoot-c431861b.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as b,B as D,H as X,P as Pm,C as l,D as gt,F as $,R as Pi,G as J,I as Pe,J as pe,K as Ye,L as _m,M as jm,N as wl,O as Za,Q as Hm,E as vl,S as Bm,T as fe,U as el,V as ks,W as bh,X as it,Y as Tl,Z as Vm,_ as Um,$ as $m,a0 as Wm,a1 as me,a2 as Fd,a3 as El,a4 as Gm,a5 as zm,a6 as wh,a7 as je,a8 as tl,a9 as Nd,aa as Qa,ab as Md,ac as Km,ad as Mn,ae as qm,af as Ym,ag as Xm,ah as Zm,ai as nl,aj as Qm,ak as Jm,al as ep,am as kd,an as tp,ao as Od,ap as np,aq as sp,ar as ip,as as op,at as ap,au as rp,av as ft,aw as vh,ax as lp,ay as Th,az as dp,aA as Eh,aB as cp,aC as hp,aD as up,aE as mp,aF as pp,aG as gp,aH as fp,aI as Cp,aJ as Sp,aK as bp,aL as Ad,aM as wp}from"./vendor-0d2b9258.js";import{e as Yn,l as wi,K as rn,a as Ld,b as xs,W as vp}from"./monaco-1ecfd680.js";import{T as We,L as Z,M as Do,a as Fo,b as No,v as yh,c as Ln,d as xh,e as kn,f as Tp,g as Ep,h as Mo,i as yp,j as Ui,k as yl,l as xp,m as sl,n as Rp,o as Rh,p as xl,q as Ih,r as Pd,s as Ip,t as Dp,u as Fp,w as Np,x as Qt,y as Ms,z as Dh,A as Xn,B as Ja,C as _i,D as Mp,E as kp,F as _d,G as ya,H as jd,I as Fh,J as Op,K as ko,N as Nh,O as Ap,P as Lp,Q as Rl,R as Il,S as xa,U as Bn,V as Pp,W as _p,X as jp,Y as Hp,Z as Bp,_ as Dl,$ as Os,a0 as Hd,a1 as Oo,a2 as Fl,a3 as Nl,a4 as Vp,a5 as Up,a6 as Ra,a7 as $p,a8 as Ml,a9 as Mh,aa as ei,ab as Wp,ac as Gp,ad as zp,ae as Kp,af as qp,ag as Yp,ah as Bd,ai as Mr,aj as Xp,ak as Zp,al as Qp,am as Jp,an as eg,ao as kh,ap as tg,aq as ng,ar as sg,as as Oh,at as ig,au as og,av as ag,aw as rg,ax as lg,ay as dg,az as cg,aA as hg,aB as ug,aC as mg,aD as pg,aE as gg,aF as Ah,aG as fg,aH as il,aI as ol,aJ as Cg,aK as Sg,aL as bg,aM as wg,aN as vg,aO as Tg,aP as Eg,aQ as yg,aR as xg,aS as Rg,aT as Ig,aU as Vd,aV as Dg,aW as Fg}from"./index-3517d713.js";import{P as Ia,b as Ng,h as Mg,p as kg,o as Og,s as Ag,t as Lg,c as kr}from"./plotly-08ea603d.js";import"./helpers-042e6b4d.js";class Pg extends b.Component{static propTypes={children:D.node.isRequired,options:D.shape({}),className:D.string,timeout:D.number,onEntered:D.func,onExited:D.func,isShown:D.bool,closeOnBlur:D.bool,interactive:D.bool,referenceObject:D.shape({}),"data-testid":D.string};static defaultProps={options:{},className:"",timeout:We.transitionMs,onEntered(){},onExited(){},isShown:!1,interactive:!1,closeOnBlur:!1,referenceObject:null,"data-testid":void 0};constructor(e){super(e),this.handleEnter=this.handleEnter.bind(this),this.handleExit=this.handleExit.bind(this),this.handleBlur=this.handleBlur.bind(this),this.element=document.createElement("div"),this.element.className="popper-container",this.container=X.createRef(),this.rAF=0;const{isShown:t}=this.props;this.state={show:t,popper:null}}componentDidUpdate(e){const{isShown:t}=this.props;e.isShown!==t&&(t?(cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{this.show()})):this.hide())}componentWillUnmount(){this.destroyPopper(!1)}element;container;rAF;getVisibleElement(e){return e==null||e.clientHeight>0||e.clientWidth>0?e:this.getVisibleElement(e.parentElement)}initPopper(){let{popper:e}=this.state;const{closeOnBlur:t,referenceObject:n}=this.props;if(e||this.container.current===null)return;let{options:s}=this.props;s={placement:"auto",modifiers:{preventOverflow:{boundariesElement:"viewport"}},...s},document.body.appendChild(this.element);let i=this.getVisibleElement(this.container.current);i==null&&(i=this.container.current),e=new Pm(n||i,this.element,s),e.scheduleUpdate(),cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{if(t&&!this.element.contains(document.activeElement)){const o=this.element.firstElementChild;o instanceof HTMLElement&&o.focus()}}),this.setState({popper:e})}destroyPopper(e=!0){cancelAnimationFrame(this.rAF);const{popper:t}=this.state;t&&(t.destroy(),document.body.contains(this.element)&&document.body.removeChild(this.element),e&&this.setState({popper:null}))}show(){this.initPopper(),this.setState({show:!0})}hide(){this.setState({show:!1})}scheduleUpdate(){const{popper:e}=this.state;e&&e.scheduleUpdate()}handleBlur(e){e.relatedTarget instanceof HTMLElement&&(this.element.contains(e.relatedTarget)||this.hide())}handleEnter(){const{onEntered:e}=this.props;e()}handleExit(){const{onExited:e}=this.props,{show:t}=this.state;t||this.destroyPopper(),e()}renderContent(){const{className:e,children:t,timeout:n,interactive:s,closeOnBlur:i}=this.props,{show:o}=this.state;return l.jsx(gt,{in:o,timeout:n,classNames:"popper-transition",onEntered:this.handleEnter,onExited:this.handleExit,children:l.jsx("div",{onClick:a=>{a.stopPropagation()},onKeyDown:a=>{a.key==="Escape"&&this.hide()},className:$("popper",{interactive:s},e),onBlur:i?this.handleBlur:void 0,tabIndex:i?-1:void 0,role:"presentation",children:l.jsxs("div",{className:"popper-content",children:[t,l.jsx("div",{className:"popper-arrow","x-arrow":""})]})})})}render(){const{popper:e}=this.state,{"data-testid":t}=this.props;return l.jsx("div",{className:"popper-parent-container",ref:this.container,style:{display:"none"},"data-testid":t,children:e&&Pi.createPortal(this.renderContent(),this.element)})}}const ri=Pg,_g=Z.module("Tooltip");class Lt extends b.Component{static defaultTimeout=500;static defaultReshowTimeout=100;static triggerReshowThreshold=300;static shownTooltipCount=0;static lastHiddenTime=Date.now();static defaultProps={interactive:!1,options:{},popperClassName:"",reshowTimeout:Lt.defaultReshowTimeout,timeout:Lt.defaultTimeout,onEntered:()=>{},onExited:()=>{},"data-testid":void 0};static handleHidden(){Lt.shownTooltipCount-=1,Lt.shownTooltipCount===0&&(Lt.lastHiddenTime=Date.now())}static handleShown(){Lt.shownTooltipCount+=1}constructor(e){super(e),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleWindowMouseMove=this.handleWindowMouseMove.bind(this),this.handleWheel=this.handleWheel.bind(this),this.handleTimeout=this.handleTimeout.bind(this),this.handleExited=this.handleExited.bind(this),this.stopShowingTooltip=this.stopShowingTooltip.bind(this),this.container=X.createRef(),this.popper=X.createRef(),this.parent=null,this.timer=null,this.state={isShown:!1}}componentDidMount(){this.startListening();const{timeout:e}=this.props;e===0&&this.show()}componentDidUpdate(e,t){const{isShown:n}=t,{isShown:s}=this.state;s!==n&&(s?Lt.handleShown():Lt.handleHidden())}componentWillUnmount(){this.stopListening(),this.stopListeningWindow(),this.stopTimer();const{isShown:e}=this.state;e&&Lt.handleHidden()}container;popper;parent;timer;startListening(){if(!this.container.current||!this.container.current.parentElement){_g.error("Tooltip doesn't have a container or a parent set!");return}this.parent=this.container.current.parentElement,this.parent.addEventListener("mousemove",this.handleMouseMove),this.parent.addEventListener("mouseleave",this.handleMouseLeave),this.parent.addEventListener("mousedown",this.stopShowingTooltip)}stopListening(){this.parent&&(this.parent.removeEventListener("mousemove",this.handleMouseMove),this.parent.removeEventListener("mouseleave",this.handleMouseLeave),this.parent.removeEventListener("mousedown",this.stopShowingTooltip))}startListeningWindow(){window.addEventListener("mousemove",this.handleWindowMouseMove,!0),window.addEventListener("contextmenu",this.stopShowingTooltip,!0),window.addEventListener("wheel",this.handleWheel)}stopListeningWindow(){window.removeEventListener("mousemove",this.handleWindowMouseMove,!0),window.removeEventListener("contextmenu",this.stopShowingTooltip,!0),window.removeEventListener("wheel",this.handleWheel)}handleMouseMove(){this.startTimer()}handleWheel(){const{isShown:e}=this.state;this.popper.current&&this.parent&&e&&!this.popper.current.element.matches(":hover")&&!this.parent.matches(":hover")&&(this.stopTimer(),this.hide())}handleMouseLeave(){const{isShown:e}=this.state;this.stopTimer();const{interactive:t}=this.props;!t&&e&&this.hide()}handleTimeout(){this.show()}handleWindowMouseMove(e){const t=e.clientX,n=e.clientY,{isShown:s}=this.state;if(!this.popper.current||!this.parent)return;const i=this.popper.current.element.getBoundingClientRect(),o=this.parent.getBoundingClientRect();t>=i.left&&t<=i.left+i.width&&n>=i.top&&n<=i.top+i.height?this.handleMouseMove():t>=o.left&&t<=o.left+o.width&&n>=o.top&&n<=o.top+o.height?this.handleMouseMove():s&&(this.stopTimer(),this.hide())}startTimer(){this.stopTimer();const{timeout:e,reshowTimeout:t}=this.props;let n=e;(Lt.shownTooltipCount>0||Date.now()-Lt.lastHiddenTime<Lt.triggerReshowThreshold)&&(n=t),this.timer=window.setTimeout(this.handleTimeout,n)}stopTimer(){this.timer!=null&&(clearTimeout(this.timer),this.timer=null)}show(){const{isShown:e}=this.state;if(this.stopTimer(),!e){this.popper.current?.show(),this.setState({isShown:!0});const{interactive:t}=this.props;t&&this.startListeningWindow()}}hide(){this.popper.current?.hide(),this.stopListeningWindow()}update(){this.popper.current?.scheduleUpdate()}handleExited(){this.setState({isShown:!1});const{onExited:e}=this.props;e()}stopShowingTooltip(){const{isShown:e}=this.state;this.stopTimer(),e&&this.hide()}render(){const{interactive:e,children:t,referenceObject:n,popperClassName:s,"data-testid":i,onEntered:o}=this.props,{isShown:a}=this.state;let{options:r}=this.props;return r={placement:"bottom",...r},l.jsx("div",{ref:this.container,style:{display:"none"},"data-testid":i,children:l.jsx(ri,{className:$(s),options:r,ref:this.popper,onEntered:o,onExited:this.handleExited,interactive:e,referenceObject:n,children:l.jsxs("div",{className:"tooltip-content",children:[" ",a&&t]})})})}}const tt=Lt;function er(d){const{children:e,className:t,style:n,"data-testid":s}=d;return l.jsx("div",{className:$("btn-group",t),style:n,role:"group","data-testid":s,children:e})}er.displayName="ButtonGroup";er.propTypes={children:D.node.isRequired,className:D.string,style:D.object,"data-testid":D.string};er.defaultProps={className:null,style:{},"data-testid":void 0};const jg=["primary","secondary","tertiary","success","danger","inline","ghost"],Hg=["group-end"];function Bg(d,e){switch(d){case"primary":return"btn-primary";case"secondary":return"btn-outline-primary";case"tertiary":return"btn-secondary";case"success":return"btn-success";case"danger":return"btn-danger";case"inline":return"btn-inline";case"ghost":return $("btn-link",{"btn-link-icon":e,"btn-link-icon-only":e})}}function Vg(d){switch(d){case"group-end":return $("pl-2","pr-3")}}const tr=X.forwardRef((d,e)=>{const{kind:t,variant:n,type:s,tooltip:i,icon:o,disabled:a=!1,active:r,onClick:c,onContextMenu:h,onMouseDown:u,onMouseUp:m,onMouseEnter:p,onMouseLeave:g,onKeyDown:C,className:f,style:S,children:v,tabIndex:w,"data-testid":T,"aria-label":y}=d,E=Boolean(o&&v==null),I=Bg(t,E);let F;n&&(F=Vg(n));let N;o&&(N=X.isValidElement(o)?o:l.jsx(J,{icon:o}));let H;i!==void 0&&(H=typeof i=="string"?l.jsx(tt,{children:i}):i);let P=y;y===void 0&&E&&i!=null&&typeof i=="string"&&(P=i);const O=l.jsxs("button",{"data-testid":T,ref:e,type:s,className:$("btn",I,F,{active:r},f),onClick:c,onContextMenu:h,onMouseUp:m,onMouseDown:u,onMouseEnter:p,onMouseLeave:g,onKeyDown:C,style:S,disabled:a,tabIndex:w,"aria-label":P,children:[o&&N,v,i!=null&&!a&&H]});return a?l.jsxs("span",{className:"btn-disabled-wrapper",children:[O,i!==void 0&&H]}):O});tr.displayName="Button";tr.propTypes={kind:D.oneOf(jg).isRequired,variant:D.oneOf(Hg),type:D.oneOf(["submit","reset","button"]),tooltip(d){const{tooltip:e,icon:t,children:n}=d;return e===void 0&&t!=null&&n==null?new Error("Tooltip is required for icon only buttons"):null},icon(d){const{children:e,icon:t}=d;return t==null&&e==null?new Error("Icon is required if no children are provided"):e==null&&!X.isValidElement(t)&&(t==null||t.iconName===""||t.iconName==null)?new Error("Icon must be react element or fontawesome IconDefinition"):null},disabled:D.bool,active:D.bool,onClick(d){const{onClick:e,type:t}=d;return t==="button"&&typeof e!="function"?new Error("type button requires an onClick function"):e!==void 0&&typeof e!="function"?new Error("onClick must be a function"):null},onContextMenu:D.func,onMouseUp:D.func,onMouseDown:D.func,onMouseEnter:D.func,onMouseLeave:D.func,onKeyDown:D.func,tabIndex:D.number,children:D.node,className:D.string,style:D.object,"data-testid":D.string};tr.defaultProps={type:"button",onClick:void 0,onContextMenu:void 0,onMouseUp:void 0,onMouseDown:void 0,onMouseEnter:void 0,onMouseLeave:void 0,onKeyDown:void 0,variant:void 0,tooltip:void 0,icon:void 0,disabled:!1,active:void 0,tabIndex:void 0,children:void 0,className:void 0,style:{},"data-testid":void 0};const V=tr;function kl({className:d="modal-footer",children:e,"data-testid":t}){return l.jsx("div",{className:d,"data-testid":t,children:e})}function ji(d){const{isOpen:e,headerText:t,bodyText:n,onCancel:s,onConfirm:i,onDiscard:o,onModalDisable:a,cancelButtonText:r="Cancel",confirmButtonText:c="Okay",discardButtonText:h="Discard",isConfirmDanger:u=!1,children:m,"data-testid":p}=d,g=b.useRef(null),C=b.useRef(null),f=b.useCallback(()=>{C.current!==null&&C.current.checked&&a&&a(),i()},[i,a]),S=b.useCallback(()=>{g.current?.focus()},[]);let v="";return e&&(v=typeof n=="function"?n():n),l.jsxs(Do,{isOpen:e,className:"theme-bg-light",onOpened:S,children:[l.jsx(Fo,{closeButton:!1,children:t}),l.jsx(No,{children:v}),l.jsxs(kl,{children:[a&&l.jsxs("div",{className:"custom-control custom-checkbox form-group mr-auto",children:[l.jsx("input",{type:"checkbox",className:"custom-control-input",id:"move-confirmation-checkbox",defaultChecked:!1,ref:C,"data-testid":p!==void 0?`${p}-checkbox-confirm`:void 0}),l.jsx("label",{className:"custom-control-label",htmlFor:"move-confirmation-checkbox",children:"Don't ask me again"})]}),o&&l.jsx(V,{kind:"secondary",className:"mr-auto","data-dismiss":"modal",onClick:o,"data-testid":p!==void 0?`${p}-btn-discard`:void 0,children:h}),s&&l.jsx(V,{kind:"secondary","data-dismiss":"modal",onClick:s,"data-testid":p!==void 0?`${p}-btn-cancel`:void 0,children:r}),l.jsxs(er,{children:[l.jsx(V,{kind:u?"danger":"primary",onClick:f,ref:g,"data-testid":p!==void 0?`${p}-btn-confirm`:void 0,children:c}),m]})]})]})}ji.propTypes={isOpen:D.bool.isRequired,headerText:D.string.isRequired,bodyText:D.oneOfType([D.string,D.func]).isRequired,onCancel:D.func,onConfirm:D.func.isRequired,onDiscard:D.func,onModalDisable:D.func,cancelButtonText:D.string,confirmButtonText:D.string,discardButtonText:D.string,children:D.node,"data-testid":D.string};ji.defaultProps={children:void 0,cancelButtonText:"Cancel",confirmButtonText:"Okay",discardButtonText:"Discard",onCancel:void 0,onDiscard:void 0,onModalDisable:void 0,"data-testid":void 0};const nr=X.forwardRef((d,e)=>{const{children:t,className:n,disabled:s,onClick:i,style:o,id:a}=d;return l.jsx("button",{ref:e,type:"button",className:$("btn",n),onClick:i,style:o,disabled:s,id:a,children:t})});nr.displayName="Button";nr.propTypes={children:D.node,className:D.string,disabled:D.bool,onClick:D.func,style:D.shape({}),id:D.string};nr.defaultProps={children:null,className:"",disabled:!1,onClick:()=>null,style:{},id:""};const Ud=nr;function Ol({className:d,isFlipped:e,children:t,"data-testid":n}){const s=r=>{if(t.length!==2)throw new Error("CardFlip requires 2 children to function");return t[r]},i=b.useRef(null),o=b.useCallback(r=>{r.target===r.currentTarget&&document.body.classList.add("card-flip--is-flipping")},[]),a=b.useCallback(r=>{r.target===r.currentTarget&&document.body.classList.remove("card-flip--is-flipping")},[]);return b.useEffect(function(){if(!i.current)throw Error("ref undefined");i.current.addEventListener("transitionstart",o);const c=i.current;return function(){if(c!=null)return c.removeEventListener("transitionstart",o)}},[o]),l.jsxs("div",{className:$(d,{"card-flip--show-front":e,"card-flip--show-back":!e}),"data-testid":n,children:[l.jsx("div",{className:"card-flip--back",children:s(0)}),l.jsx("div",{ref:i,className:"card-flip--front",onTransitionEnd:a,children:s(1)})]})}function Or(d){return d.then!==void 0}class Xs{static actionsDisabled=!1;static disableAllActions(){Xs.actionsDisabled=!0}static enableAllActions(){Xs.actionsDisabled=!1}static isContextActionEvent(e){return Array.isArray(e.contextActions)}static compareActions(e,t){return e.group!==t.group?(e.group??0)>(t.group??0)?1:-1:e.order!==t.order?(e.order??0)>(t.order??0)?1:-1:e.title!==t.title?(e.title??"")>(t.title??"")?1:-1:e!==t?e>t?1:-1:0}static sortActions(e){if(e==null||!Array.isArray(e))return[];const t=e.slice();return t.sort(Xs.compareActions),t}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return Xs.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){const t=Xs.getModifierKey();return e[t]}static getMenuItems(e,t=!0){let n=[],s=e;Array.isArray(s)||(s=[s]);for(let i=0;i<s.length;i+=1){const o=s[i];let a;typeof o=="function"?a=o():a=o,a!=null&&(a instanceof Promise?t&&n.push(a):Array.isArray(a)?n=n.concat(a):n.push(a))}return n=n.filter(i=>i.title!==void 0||i.then!=null||i.menuElement),n}static getNextMenuItem(e,t,n){let s=e;s<0&&t<0&&(s=n.length);for(let i=1;i<n.length+1;i+=1){const o=(s+t*i+n.length)%n.length,a=n[o];if(!(a instanceof Promise)&&a.disabled!==!0)return o}return e}}const He=Xs,$d=Z.module("GlobalContextAction");class Ug extends b.Component{constructor(e){super(e),this.handleContextMenu=this.handleContextMenu.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}componentDidMount(){document.body.addEventListener("contextmenu",this.handleContextMenu),document.body.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.body.removeEventListener("contextmenu",this.handleContextMenu),document.body.removeEventListener("keydown",this.handleKeyDown)}handleContextMenu(e){const t=e;t.contextActions==null&&(t.contextActions=[]);const{action:n}=this.props;n.title==null&&!n.menuElement||(t.contextActions==null&&(t.contextActions=[]),t.contextActions.push(n),$d.debug("Received context menu event at global action! Menu items are now: ",t.contextActions))}handleKeyDown(e){const{action:t}=this.props;!He.actionsDisabled&&t.shortcut!==void 0&&t.shortcut.matchesEvent(e)&&($d.debug("Global hotkey matched!",e),t.action?.(e),e.preventDefault(),e.stopPropagation())}render(){return null}}const $g=Ug;class Wg extends b.Component{render(){const{actions:e,"data-testid":t}=this.props,n=[];for(let s=0;s<e.length;s+=1){const i=e[s],{shortcut:o}=i;if(i.title!=null||i.menuElement||o){const a=l.jsx($g,{action:i,"data-testid":t},`${i.title}.${o?.id}`);n.push(a)}}return n}}const Gg=Wg;const Qo=Z.module("ContextActions");class zg extends b.Component{static groups={default:null,high:100,medium:5e3,low:1e4,global:1e5,edit:100};static triggerMenu(e,t,n,s){if(s.length===0)return;const i=new MouseEvent("contextmenu",{clientX:t,clientY:n,bubbles:!0,cancelable:!0});i.contextActions=s,e.dispatchEvent(i)}constructor(e){super(e),this.handleContextMenu=this.handleContextMenu.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.container=X.createRef(),this.state={globalActions:[],keyboardActions:[]}}static getDerivedStateFromProps(e){if(e.actions==null||!Array.isArray(e.actions))return{globalActions:[],keyboardActions:[]};const t=e.actions.filter(s=>!Or(s)&&typeof s!="function"&&s.isGlobal),n=e.actions.filter(s=>!Or(s)&&typeof s!="function"&&(s.isGlobal===void 0||!s.isGlobal)&&s.shortcut!=null);return{globalActions:t,keyboardActions:n}}componentDidMount(){this.container.current?.parentElement&&(this.container.current.parentElement.addEventListener("contextmenu",this.handleContextMenu),this.container.current.parentElement.addEventListener("keydown",this.handleKeyDown))}componentWillUnmount(){this.container.current?.parentElement&&(this.container.current.parentElement.removeEventListener("contextmenu",this.handleContextMenu),this.container.current.parentElement.removeEventListener("keydown",this.handleKeyDown))}container;handleContextMenu(e){const{ignoreClassNames:t=[]}=this.props;if(t.length>0){let s=e.target;for(;s!=null;){const{classList:i}=s,o=t.find(a=>i.contains(a));if(o!==void 0){Qo.debug2(`Contextmenu event ignored based on the target className "${o}"`);return}s=s.parentElement}}if(He.isContextActionEvent(e)||(e.contextActions=[]),!He.isContextActionEvent(e))return;const{actions:n}=this.props;if(n!=null){let s=n;Array.isArray(s)&&(s=s.filter(i=>Or(i)||typeof i=="function"||i.isGlobal===void 0||!i.isGlobal)),e.contextActions=e.contextActions.concat(s)}Qo.debug("Received context menu event! Menu items are now: ",e.contextActions)}handleKeyDown(e){const{keyboardActions:t}=this.state;for(let n=0;n<t.length;n+=1){const s=t[n];!He.actionsDisabled&&s.shortcut!=null&&s.shortcut.matchesEvent(e)&&(Qo.debug("Context hotkey matched!",e),s.action?.(e),e.stopPropagation(),e.preventDefault(),Qo.debug2("Matched hotkey returned false, key event not consumed"))}}render(){const{"data-testid":e}=this.props,{globalActions:t}=this.state;return l.jsx("div",{className:"context-actions-listener",ref:this.container,"data-testid":e,children:l.jsx(Gg,{actions:t})})}}const ae=zg,Al=X.forwardRef((d,e)=>{function t(f){const{menuItem:S,onMenuItemClick:v}=d;v(S,f)}function n(f){const{menuItem:S,onMenuItemMouseMove:v}=d;v(S,f)}function s(f){const{menuItem:S,onMenuItemContextMenu:v}=d;v(S,f)}function i(f,S,v){if(typeof f.type=="string")return f;const{closeMenu:w,menuItem:T,isKeyboardSelected:y,isMouseSelected:E,"data-testid":I}=d,F={menuItem:T,closeMenu:w,isKeyboardSelected:y,isMouseSelected:E,iconElement:S,displayShortcut:v,"data-testid":I};return X.cloneElement(f,{forwardedProps:F})}const{children:o,menuItem:a,isKeyboardSelected:r=!1,isMouseSelected:c=!1,"data-testid":h}=d,u=a.shortcut?.getDisplayText();let m=null;if(a.icon){const f=a.icon;if(X.isValidElement(f))m=f;else{let S;a.iconColor!=null&&(a.disabled===void 0||!a.disabled)&&(S={color:a.iconColor}),m=l.jsx(J,{icon:f,style:S})}}let p=null;const g=Boolean(o);a.actions&&(p=l.jsx(J,{icon:yh}));let C=null;if(a.menuElement)C=l.jsx("div",{className:"custom-menu-item",onMouseMove:n,children:i(a.menuElement,m,u)});else{const f=a.disabled,S=a.iconOutline;C=l.jsx("button",{type:"button",className:$("btn-context-menu",{disabled:f},{active:(g||c)&&(f===void 0||!f)},{"keyboard-active":r&&(f===void 0||!f)}),onClick:t,onMouseMove:n,onContextMenu:s,title:a.description??"",children:l.jsxs("div",{className:"btn-context-menu-wrapper",children:[l.jsx("span",{className:$("icon",{outline:S}),children:m}),l.jsx("span",{className:"title",children:a.title}),u!==void 0&&l.jsx("span",{className:"shortcut",children:u}),p&&l.jsx("span",{className:$("submenu-indicator",{disabled:f}),children:p})]})})}return l.jsxs("div",{className:"context-menu-item",ref:e,"data-testid":h,children:[o,C]})});Al.displayName="ContextMenuItem";Al.defaultProps={children:null,isKeyboardSelected:!1,isMouseSelected:!1,"data-testid":void 0};const Lh=Al,De=Object.freeze([]),Gn=new Map;class Kg extends Error{isCanceled=!0}const Hi=Kg;class sr{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(a=>parseInt(a,10));else throw new Error(`Invalid color received. Got ${n}`);return document.body.removeChild(t),sr.getBrightness(i)<125}static getBrightness(e){return Math.round((e[0]*299+e[1]*587+e[2]*114)/1e3)}}async function $i(d){const{clipboard:e}=navigator;if(e!==void 0)try{return navigator.clipboard.writeText(d)}catch{return Wd(d)}Wd(d)}function Wd(d){const e=document.activeElement,t=document.createElement("textarea");t.value=d,document.body.appendChild(t),t.focus(),t.select();const n=document.execCommand("copy");if(document.body.removeChild(t),e instanceof HTMLElement&&e.focus(),!n)throw new Error("Unable to execute copy command")}const qg="table_",Gd="column_",Yg=new Set(["in","not","i","ii","k"]),Xg=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"]),Zg=/[^a-zA-Z0-9_$+@-]/g,Qg=/[^A-Za-z0-9_$]/g;class cn{static legalize=(e,t,n,s,i)=>{let o=e.trim().replace(/[- ]/g,"_");return s&&(Yg.has(o)||Xg.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=>cn.legalize(e,qg,Zg,!1,0);static legalizeColumnNames=e=>{const t=[];return e.forEach((n,s)=>{let i=cn.legalizeColumnName(n,s);t.includes(i)&&(i=Gd+s),t.push(i)}),t};static legalizeColumnName=(e,t=0)=>cn.legalize(e,Gd,Qg,!0,t);static isValidTableName=e=>cn.legalizeTableName(e)===e;static isValidColumnName=e=>cn.legalizeColumnName(e)===e}function Jg(d,e){return d?d.closest(`.${e}`):null}const ef={getClosestByClassName:Jg};class Ve extends CustomEvent{constructor(e,t){super(e,t)}}class tf extends Error{isTimeout=!0}const Ph=tf;class ve{static makeCancelable(e,t){let n=!1,s,i;const o=new Promise((a,r)=>{i=r,Promise.resolve(e).then(c=>{n?t&&t(c):(s=c,a(c))}).catch(c=>r(c))});return o.cancel=()=>{n=!0,i(new Hi),s!=null&&t&&t(s)},o}static isCanceled(e){return e instanceof Hi}static isTimedOut(e){return e instanceof Ph}}class nf{pending=[];resolved=[];add(e,t){const n=ve.makeCancelable(e,t);return this.pending.push(n),n.then(()=>{this.resolve(n)},()=>{this.resolve(n)}),n}remove(e){for(let t=0;t<this.pending.length;t+=1)if(this.pending[t]===e){this.pending.splice(t,1);return}}resolve(e){this.remove(e),this.resolved.push(e)}cancel(){const e=[...this.pending,...this.resolved];for(let t=0;t<e.length;t+=1)e[t].cancel();this.pending=[],this.resolved=[]}}const ts=nf;function M(d){if(d==null)throw new Error("Value is null or undefined")}function _(d,e,t=void 0){const n=d.get(e)??t;if(n!==void 0)return n;throw new Error(`Missing value for key ${e}`)}class ln{static isValidRange(e){return e!=null&&e.length===2&&Number.isInteger(e[0])&&Number.isInteger(e[1])&&e[0]<=e[1]}static validateRange(e){if(!ln.isValidRange(e))throw new Error(`Invalid range! ${e}`)}static isSelected(e,t){for(let n=0;n<e.length;n+=1){const s=e[n],i=s[0],o=s[1];if(i<=t&&t<=o)return!0}return!1}static selectRange(e,t){let[n,s]=t;const i=[...e];for(let o=i.length-1;o>=0;o-=1){const a=i[o],r=a[0],c=a[1];if(r<=n&&s<=c)return i;n<=c&&r<=s&&(n=Math.min(n,r),s=Math.max(s,c),i.splice(o,1))}return i.push([n,s]),i}static deselectRange(e,t){const[n,s]=t,i=[...e];for(let o=i.length-1;o>=0;o-=1){const a=i[o],r=a[0],c=a[1];if(!(s<r||c<n))if(r<n&&s<c){i[o]=[r,n-1],i.splice(o+1,0,[s+1,c]);break}else n<=r&&c<=s?i.splice(o,1):r<n?i[o]=[r,n-1]:i[o]=[s+1,c]}return i}static count(e){return e.reduce((t,n)=>t+(n[1]-n[0]+1),0)}static getItemsInRanges(e,t){return t.reduce((n,s)=>{const i=[...n];for(let o=s[0];o<=s[1];o+=1)i.push(e[o]);return i},[])}}class sf{static join(e,t="and"){if(e==null||e.length===0)return"";if(e.length===1)return e[0];if(e.length===2)return`${e[0]} ${t} ${e[1]}`;const n=e.slice(0,e.length-1).join(", "),s=e[e.length-1];return`${n}, ${t} ${s}`}static toLower(e,t=!0){if(e==null){if(t)return"";throw new Error("Null string passed in to TextUtils.toLower")}return e.toLowerCase()}static sort(e,t,n=!0){return e<t?n?-1:1:e>t?n?1:-1:0}}const Wt=sf;class Wi{static TIME_PATTERN="([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]";static TIME_ZONES=Object.freeze([{label:"Tokyo UTC+9 No DST",value:"Asia/Tokyo"},{label:"Seoul UTC+9 No DST",value:"Asia/Seoul"},{label:"Hong Kong UTC+8 No DST",value:"Asia/Hong_Kong"},{label:"Singapore UTC+8 No DST",value:"Asia/Singapore"},{label:"Kolkata UTC+5:30 No DST",value:"Asia/Kolkata"},{label:"Berlin UTC+1",value:"Europe/Berlin"},{label:"UTC UTC±0 No DST",value:"UTC"},{label:"London UTC±0",value:"Europe/London"},{label:"Sao Paulo UTC-2",value:"America/Sao_Paulo"},{label:"Newfoundland UTC-3:30",value:"America/St_Johns"},{label:"Halifax UTC-4",value:"America/Halifax"},{label:"New York UTC−5",value:"America/New_York"},{label:"Chicago UTC-6",value:"America/Chicago"},{label:"Denver UTC-7",value:"America/Denver"},{label:"Los Angeles UTC-8",value:"America/Los_Angeles"},{label:"Anchorage UTC-9",value:"America/Anchorage"},{label:"Honolulu UTC-10 No DST",value:"Pacific/Honolulu"},{label:"Zurich UTC+1",value:"Europe/Zurich"},{label:"Amsterdam UTC+1",value:"Europe/Amsterdam"},{label:"Taipei UTC+8 No DST",value:"Asia/Taipei"},{label:"Sydney UTC+10",value:"Australia/Sydney"}]);static formatElapsedTime(e){if(typeof e!="number"||!Number.isInteger(e))throw new Error(`${e} is not a number that can be expressed as a formatted time`);const t=Math.floor(e/3600),n=Math.floor(e%3600/60),s=e%60;return`${t>0?`${t}h `:""}${n>0||t>0?`${n}m `:""}${e>=60?`${s}s`.padStart(3,"0"):`${s}s`}`}static formatTime(e){if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new Error(`${e} is not a number that can be expressed as a formatted time`);const t=String(Math.floor(e/(60*60))).padStart(2,"0"),n=e%(60*60),s=String(Math.floor(n/60)).padStart(2,"0"),i=n%60,o=String(Math.ceil(i)).padStart(2,"0");return`${t}:${s}:${o}`}static isTimeString(e){return new RegExp(Wi.TIME_PATTERN).test(e)}static parseTime(e){if(e==null||typeof e!="string")throw new Error(`${e} is not a valid string`);const t=e.split(":");if(t.length!==3)throw new Error(`${e} is not a time string that can be parsed`);return Number(t[0])*60*60+Number(t[1])*60+Number(t[2])}}class of extends Error{isInvalid=!0}const Ni=of,zd=Z.module("ContextMenu");class Da extends b.PureComponent{static defaultProps={subMenuParentWidth:0,subMenuParentHeight:0,closeMenu(){},onMenuOpened(){},onMenuClosed(){},options:{},menuStyle:{},"data-testid":void 0};static handleContextMenu(e){e.metaKey||(e.stopPropagation(),e.preventDefault())}constructor(e){super(e),this.handleBlur=this.handleBlur.bind(this),this.handleCloseSubMenu=this.handleCloseSubMenu.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleMenuItemClick=this.handleMenuItemClick.bind(this),this.handleMenuItemContextMenu=this.handleMenuItemContextMenu.bind(this),this.handleMenuItemMouseMove=this.handleMenuItemMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleWindowResize=this.handleWindowResize.bind(this),this.container=X.createRef(),this.oldFocus=document.activeElement,this.activeSubMenuRef=X.createRef(),this.subMenuTimer=0,this.rAF=0,this.initialPosition={top:e.top,left:e.left},this.state={menuItems:[],pendingItems:[],activeSubMenu:null,hasOverflow:!1,subMenuTop:null,subMenuLeft:null,subMenuParentWidth:0,subMenuParentHeight:0,keyboardIndex:-1,mouseIndex:-1}}componentDidMount(){this.initMenu(),this.verifyPosition(),window.addEventListener("resize",this.handleWindowResize),this.rAF=window.requestAnimationFrame(()=>{this.container.current?.focus();const{onMenuOpened:e}=this.props;e(this)})}componentDidUpdate(e,t){const{actions:n}=this.props,{activeSubMenu:s}=this.state;s!==t.activeSubMenu&&(s==null?this.container.current?.focus():this.setActiveSubMenuPosition()),e.actions!==n&&(this.initMenu(),(this.container.current==null||!this.container.current.contains(document.activeElement))&&this.container.current?.focus()),this.verifyPosition()}componentWillUnmount(){this.cancelPromises(),window.removeEventListener("resize",this.handleWindowResize),cancelAnimationFrame(this.rAF)}container;oldFocus;activeSubMenuRef;subMenuTimer;rAF;initialPosition;getKeyboardIndex(){const{options:e}=this.props;if(e.separateKeyboardMouse!==void 0&&e.separateKeyboardMouse){const{keyboardIndex:t}=this.state;return t}return this.getMouseIndex()}setKeyboardIndex(e){const{options:t}=this.props;t.separateKeyboardMouse!==void 0&&t.separateKeyboardMouse?this.setState({keyboardIndex:e}):this.setMouseIndex(e)}getMouseIndex(){const{mouseIndex:e}=this.state;return e}setMouseIndex(e){this.setState({mouseIndex:e})}initMenu(){this.cancelPromises(),cancelAnimationFrame(this.rAF);const{options:e}=this.props;let t=e.initialKeyboardIndex;t===void 0&&(t=-1);const{actions:n}=this.props,s=He.getMenuItems(n),i=[];for(let o=s.length-1;o>=0;o-=1){const a=s[o];a instanceof Promise?this.initMenuPromise(a):i.push(a)}this.setState({mouseIndex:-1,keyboardIndex:t,activeSubMenu:null,menuItems:He.sortActions(i)})}initMenuPromise(e){const t=ve.makeCancelable(e);this.setState(n=>({pendingItems:n.pendingItems.concat(t)})),t.then(n=>{this.setState(s=>{const i=s.pendingItems.indexOf(t);if(i>=0){const o=s.pendingItems.slice();return o.splice(i,1),{menuItems:He.sortActions(s.menuItems.concat(n)),pendingItems:o}}return null})},n=>{ve.isCanceled(n)||(this.setState(s=>{const i=s.pendingItems.indexOf(t);if(i>=0){const o=s.pendingItems.slice();return o.splice(i,1),{pendingItems:o}}return null}),zd.error(n))})}cancelPromises(){const{pendingItems:e}=this.state;e.map(t=>t.cancel())}setActiveSubMenuPosition(){if(this.activeSubMenuRef.current===null)return;const e=this.activeSubMenuRef.current.getBoundingClientRect();this.setState({subMenuTop:e.top,subMenuLeft:e.right,subMenuParentHeight:e.height,subMenuParentWidth:e.width})}verifyPosition(){const{options:e,updatePosition:t,subMenuParentWidth:n,subMenuParentHeight:s,top:i,left:o}=this.props;if(!this.container.current||e.doNotVerifyPosition!=null&&e.doNotVerifyPosition)return;let{top:a,left:r}=this.initialPosition;const{width:c,height:h}=this.container.current?.getBoundingClientRect()??{width:0,height:0},u=(this.container.current?.scrollHeight??0)>window.innerHeight;h===0||c===0||(a+h>window.innerHeight&&(a-h-s>0?a-=h-s:a=window.innerHeight-h),r+c>window.innerWidth&&(r=r-c-n),(o!==r||i!==a)&&(this.setState({hasOverflow:u}),t(a,r)))}handleWindowResize(){this.container.current&&this.closeMenu(!0)}handleBlur(e){if(!this.container.current){zd.warn("Container is null!");return}if(!this.container.current.contains(e.relatedTarget)){let t=e.relatedTarget,n=!1;for(;t&&!n;)n=t.hasAttribute("data-dh-context-menu"),t=t.parentElement;n||this.closeMenu(!0)}}isEscapeKey(e){const{left:t}=this.props;return e==="Escape"||t<0&&e==="ArrowRight"||e==="ArrowLeft"}handleKeyDown(e){const{menuItems:t}=this.state,n=this.getKeyboardIndex();let s=n,i=!1;if(e.key==="Enter"||e.key===" "){n>=0&&n<t.length&&this.handleMenuItemClick(t[n],e);return}if(e.key==="ArrowRight"?n>=0&&n<=t.length?i=!0:s=0:this.isEscapeKey(e.key)?s=null:e.key==="ArrowUp"||e.shiftKey&&e.key==="Tab"?s=He.getNextMenuItem(s,-1,t):(e.key==="ArrowDown"||e.key==="Tab")&&(s=He.getNextMenuItem(s,1,t)),i){this.openSubMenu(n),e.preventDefault(),e.stopPropagation();return}n!==s&&(s!==null?this.setKeyboardIndex(s):(this.closeMenu(),this.oldFocus instanceof HTMLElement&&this.oldFocus.focus()),e.preventDefault(),e.stopPropagation())}openSubMenu(e){const{menuItems:t,activeSubMenu:n}=this.state,s=t[e].actions?e:null;n!==s&&this.setState({activeSubMenu:s,subMenuTop:null,subMenuLeft:null})}closeMenu(e=!1){const{closeMenu:t,onMenuClosed:n}=this.props;cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{t(e),n(this)})}closeSubMenu(){this.setState({activeSubMenu:null})}handleCloseSubMenu(e){e?this.closeMenu(!0):this.closeSubMenu()}handleMenuItemClick(e,t){t.preventDefault(),t.stopPropagation();const{menuItems:n}=this.state;e!=null&&(e.disabled===void 0||!e.disabled)&&(e.actions!=null?this.openSubMenu(n.indexOf(e)):e.action!=null&&(e.action(),this.closeMenu(!0)))}handleMenuItemContextMenu(e,t){t.metaKey||this.handleMenuItemClick(e,t)}handleMenuItemMouseMove(e){const{menuItems:t}=this.state,n=t.indexOf(e);this.setMouseIndex(n),n>=0&&n<t.length&&(e.disabled===void 0||!e.disabled)&&this.openSubMenu(n)}handleMouseLeave(){this.setMouseIndex(-1)}render(){const e=[],{top:t,left:n}=this.props,{activeSubMenu:s,hasOverflow:i,keyboardIndex:o,menuItems:a,mouseIndex:r,pendingItems:c,subMenuTop:h,subMenuLeft:u,subMenuParentWidth:m,subMenuParentHeight:p}=this.state;for(let v=0;v<a.length;v+=1){const w=a[v];v>0&&w.group!==a[v-1].group&&e.push(l.jsx("hr",{},`${v}.separator`));const T=l.jsx(Lh,{ref:s===v?this.activeSubMenuRef:null,isKeyboardSelected:o===v,isMouseSelected:r===v,menuItem:w,closeMenu:this.handleCloseSubMenu,onMenuItemClick:this.handleMenuItemClick,onMenuItemMouseMove:this.handleMenuItemMouseMove,onMenuItemContextMenu:this.handleMenuItemContextMenu},v);e.push(T)}let g=null;c.length>0&&(g=l.jsx("div",{className:"loading",children:l.jsx(Ln,{})}));const{menuStyle:C,"data-testid":f}=this.props,S=s!==null&&h!==null&&u!==null;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:$({"has-overflow":i},"context-menu-container"),style:{top:t,left:n,...C},ref:this.container,"data-dh-context-menu":!0,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown,onMouseLeave:this.handleMouseLeave,onContextMenu:Da.handleContextMenu,role:"menuitem",tabIndex:0,"data-testid":f,children:[e,g]}),S&&s!==null&&h!==null&&u!==null&&l.jsx(Da,{actions:a[s].actions||[],closeMenu:this.handleCloseSubMenu,top:h,left:u,updatePosition:(v,w)=>{this.setState({subMenuTop:v,subMenuLeft:w})},subMenuParentWidth:m,subMenuParentHeight:p},`sub-${s}`)]})}}const af=Da;class rf extends b.Component{constructor(e){super(e),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=X.createRef(),this.openMenu=X.createRef(),this.state={actions:null,left:0,top:0}}componentDidMount(){this.container.current?.parentElement&&this.container.current.parentElement.addEventListener("contextmenu",this.handleContextMenu)}componentWillUnmount(){this.container.current?.parentElement&&this.container.current.parentElement.removeEventListener("contextmenu",this.handleContextMenu)}container;openMenu;handleContextMenu(e){if(!He.isContextActionEvent(e)||!this.container.current||e.metaKey||e.ctrlKey)return;const t=He.getMenuItems(e.contextActions),n=this.container.current.getBoundingClientRect(),s=e.clientY-n.top,i=e.clientX-n.left;if(t.length===0){if(e.target===this.container.current){e.preventDefault(),this.setState({actions:null},()=>{const o=document.elementFromPoint(i,s),a=new MouseEvent("contextmenu",{clientX:e.clientX,clientY:e.clientY,bubbles:!0,cancelable:!0});o?.dispatchEvent(a)});return}return}e.preventDefault(),this.setState({actions:t,top:s,left:i})}handleMenuClose(e){e===this.openMenu.current&&this.setState({actions:null})}render(){let e=null;const{"data-testid":t}=this.props,{actions:n,top:s,left:i}=this.state;return n&&(e=l.jsx(af,{ref:this.openMenu,actions:n,onMenuClosed:this.handleMenuClose,top:s,left:i,updatePosition:(o,a)=>{this.setState({top:o,left:a})},"data-testid":t})),l.jsx("div",{className:$("context-menu-root",{active:n}),ref:this.container,children:e})}}const _h=rf;class Ss extends b.Component{static propTypes={className:D.string,in:D.bool.isRequired,children:D.node.isRequired,autoFocusOnShow:D.bool,"data-testid":D.string};static defaultProps={className:"",autoFocusOnShow:!1,"data-testid":void 0};static handleEnter(e){const t=e;t.style.height="0"}static handleEntering(e){const t=e;t.style.height=`${Ss.getHeight(t)}px`}static handleExiting(e){const t=e;t.style.height="0"}static handleExit(e){const t=e;t.style.height=`${Ss.getHeight(t)}px`}static getHeight(e){const t=e.scrollWidth-e.clientWidth;return e.scrollHeight-t}constructor(e){super(e),this.handleEntered=this.handleEntered.bind(this)}handleEntered(e){const t=e;t.style.height="";const{autoFocusOnShow:n}=this.props;if(n!==void 0&&n){const s=t.querySelector("input, select, textarea");s?.focus()}}render(){const{children:e,className:t,in:n,"data-testid":s}=this.props;return l.jsx(gt,{in:n,classNames:{enterActive:"collapsing",enterDone:"collapse show",exitActive:"collapsing",exitDone:"collapse"},onEnter:Ss.handleEnter,onEntering:Ss.handleEntering,onEntered:this.handleEntered,onExit:Ss.handleExit,onExiting:Ss.handleExiting,timeout:350,children:i=>l.jsx("div",{className:$({collapse:i==="exited"},t),"data-testid":s,children:e})})}}const lf=Ss;function ir(d){const e=b.useRef();return b.useEffect(function(){e.current=d}),e.current}function jh(d){const e=b.useRef(null);return b.useEffect(function(){d&&(typeof d=="function"?d(e.current):d.current=e.current)}),e}const df=3500,cf=Z.module("useCopyToClipboard");function hf(){const[d,e]=b.useState(!1),t=b.useRef(null),n=b.useCallback(s=>{$i(s).then(()=>{e(!0)}).catch(i=>cf.error(`Unable to copy ${s}`,`
|
|
1
|
+
import{A as b,B as D,H as X,P as Pm,C as l,D as gt,F as $,R as Pi,G as J,I as Pe,J as pe,K as Ye,L as _m,M as jm,N as wl,O as Za,Q as Hm,E as vl,S as Bm,T as fe,U as el,V as ks,W as bh,X as it,Y as Tl,Z as Vm,_ as Um,$ as $m,a0 as Wm,a1 as me,a2 as Fd,a3 as El,a4 as Gm,a5 as zm,a6 as wh,a7 as je,a8 as tl,a9 as Nd,aa as Qa,ab as Md,ac as Km,ad as Mn,ae as qm,af as Ym,ag as Xm,ah as Zm,ai as nl,aj as Qm,ak as Jm,al as ep,am as kd,an as tp,ao as Od,ap as np,aq as sp,ar as ip,as as op,at as ap,au as rp,av as ft,aw as vh,ax as lp,ay as Th,az as dp,aA as Eh,aB as cp,aC as hp,aD as up,aE as mp,aF as pp,aG as gp,aH as fp,aI as Cp,aJ as Sp,aK as bp,aL as Ad,aM as wp}from"./vendor-0d2b9258.js";import{e as Yn,l as wi,K as rn,a as Ld,b as xs,W as vp}from"./monaco-1ecfd680.js";import{T as We,L as Z,M as Do,a as Fo,b as No,v as yh,c as Ln,d as xh,e as kn,f as Tp,g as Ep,h as Mo,i as yp,j as Ui,k as yl,l as xp,m as sl,n as Rp,o as Rh,p as xl,q as Ih,r as Pd,s as Ip,t as Dp,u as Fp,w as Np,x as Qt,y as Ms,z as Dh,A as Xn,B as Ja,C as _i,D as Mp,E as kp,F as _d,G as ya,H as jd,I as Fh,J as Op,K as ko,N as Nh,O as Ap,P as Lp,Q as Rl,R as Il,S as xa,U as Bn,V as Pp,W as _p,X as jp,Y as Hp,Z as Bp,_ as Dl,$ as Os,a0 as Hd,a1 as Oo,a2 as Fl,a3 as Nl,a4 as Vp,a5 as Up,a6 as Ra,a7 as $p,a8 as Ml,a9 as Mh,aa as ei,ab as Wp,ac as Gp,ad as zp,ae as Kp,af as qp,ag as Yp,ah as Bd,ai as Mr,aj as Xp,ak as Zp,al as Qp,am as Jp,an as eg,ao as kh,ap as tg,aq as ng,ar as sg,as as Oh,at as ig,au as og,av as ag,aw as rg,ax as lg,ay as dg,az as cg,aA as hg,aB as ug,aC as mg,aD as pg,aE as gg,aF as Ah,aG as fg,aH as il,aI as ol,aJ as Cg,aK as Sg,aL as bg,aM as wg,aN as vg,aO as Tg,aP as Eg,aQ as yg,aR as xg,aS as Rg,aT as Ig,aU as Vd,aV as Dg,aW as Fg}from"./index-be1665ce.js";import{P as Ia,b as Ng,h as Mg,p as kg,o as Og,s as Ag,t as Lg,c as kr}from"./plotly-08ea603d.js";import"./helpers-042e6b4d.js";class Pg extends b.Component{static propTypes={children:D.node.isRequired,options:D.shape({}),className:D.string,timeout:D.number,onEntered:D.func,onExited:D.func,isShown:D.bool,closeOnBlur:D.bool,interactive:D.bool,referenceObject:D.shape({}),"data-testid":D.string};static defaultProps={options:{},className:"",timeout:We.transitionMs,onEntered(){},onExited(){},isShown:!1,interactive:!1,closeOnBlur:!1,referenceObject:null,"data-testid":void 0};constructor(e){super(e),this.handleEnter=this.handleEnter.bind(this),this.handleExit=this.handleExit.bind(this),this.handleBlur=this.handleBlur.bind(this),this.element=document.createElement("div"),this.element.className="popper-container",this.container=X.createRef(),this.rAF=0;const{isShown:t}=this.props;this.state={show:t,popper:null}}componentDidUpdate(e){const{isShown:t}=this.props;e.isShown!==t&&(t?(cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{this.show()})):this.hide())}componentWillUnmount(){this.destroyPopper(!1)}element;container;rAF;getVisibleElement(e){return e==null||e.clientHeight>0||e.clientWidth>0?e:this.getVisibleElement(e.parentElement)}initPopper(){let{popper:e}=this.state;const{closeOnBlur:t,referenceObject:n}=this.props;if(e||this.container.current===null)return;let{options:s}=this.props;s={placement:"auto",modifiers:{preventOverflow:{boundariesElement:"viewport"}},...s},document.body.appendChild(this.element);let i=this.getVisibleElement(this.container.current);i==null&&(i=this.container.current),e=new Pm(n||i,this.element,s),e.scheduleUpdate(),cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{if(t&&!this.element.contains(document.activeElement)){const o=this.element.firstElementChild;o instanceof HTMLElement&&o.focus()}}),this.setState({popper:e})}destroyPopper(e=!0){cancelAnimationFrame(this.rAF);const{popper:t}=this.state;t&&(t.destroy(),document.body.contains(this.element)&&document.body.removeChild(this.element),e&&this.setState({popper:null}))}show(){this.initPopper(),this.setState({show:!0})}hide(){this.setState({show:!1})}scheduleUpdate(){const{popper:e}=this.state;e&&e.scheduleUpdate()}handleBlur(e){e.relatedTarget instanceof HTMLElement&&(this.element.contains(e.relatedTarget)||this.hide())}handleEnter(){const{onEntered:e}=this.props;e()}handleExit(){const{onExited:e}=this.props,{show:t}=this.state;t||this.destroyPopper(),e()}renderContent(){const{className:e,children:t,timeout:n,interactive:s,closeOnBlur:i}=this.props,{show:o}=this.state;return l.jsx(gt,{in:o,timeout:n,classNames:"popper-transition",onEntered:this.handleEnter,onExited:this.handleExit,children:l.jsx("div",{onClick:a=>{a.stopPropagation()},onKeyDown:a=>{a.key==="Escape"&&this.hide()},className:$("popper",{interactive:s},e),onBlur:i?this.handleBlur:void 0,tabIndex:i?-1:void 0,role:"presentation",children:l.jsxs("div",{className:"popper-content",children:[t,l.jsx("div",{className:"popper-arrow","x-arrow":""})]})})})}render(){const{popper:e}=this.state,{"data-testid":t}=this.props;return l.jsx("div",{className:"popper-parent-container",ref:this.container,style:{display:"none"},"data-testid":t,children:e&&Pi.createPortal(this.renderContent(),this.element)})}}const ri=Pg,_g=Z.module("Tooltip");class Lt extends b.Component{static defaultTimeout=500;static defaultReshowTimeout=100;static triggerReshowThreshold=300;static shownTooltipCount=0;static lastHiddenTime=Date.now();static defaultProps={interactive:!1,options:{},popperClassName:"",reshowTimeout:Lt.defaultReshowTimeout,timeout:Lt.defaultTimeout,onEntered:()=>{},onExited:()=>{},"data-testid":void 0};static handleHidden(){Lt.shownTooltipCount-=1,Lt.shownTooltipCount===0&&(Lt.lastHiddenTime=Date.now())}static handleShown(){Lt.shownTooltipCount+=1}constructor(e){super(e),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleWindowMouseMove=this.handleWindowMouseMove.bind(this),this.handleWheel=this.handleWheel.bind(this),this.handleTimeout=this.handleTimeout.bind(this),this.handleExited=this.handleExited.bind(this),this.stopShowingTooltip=this.stopShowingTooltip.bind(this),this.container=X.createRef(),this.popper=X.createRef(),this.parent=null,this.timer=null,this.state={isShown:!1}}componentDidMount(){this.startListening();const{timeout:e}=this.props;e===0&&this.show()}componentDidUpdate(e,t){const{isShown:n}=t,{isShown:s}=this.state;s!==n&&(s?Lt.handleShown():Lt.handleHidden())}componentWillUnmount(){this.stopListening(),this.stopListeningWindow(),this.stopTimer();const{isShown:e}=this.state;e&&Lt.handleHidden()}container;popper;parent;timer;startListening(){if(!this.container.current||!this.container.current.parentElement){_g.error("Tooltip doesn't have a container or a parent set!");return}this.parent=this.container.current.parentElement,this.parent.addEventListener("mousemove",this.handleMouseMove),this.parent.addEventListener("mouseleave",this.handleMouseLeave),this.parent.addEventListener("mousedown",this.stopShowingTooltip)}stopListening(){this.parent&&(this.parent.removeEventListener("mousemove",this.handleMouseMove),this.parent.removeEventListener("mouseleave",this.handleMouseLeave),this.parent.removeEventListener("mousedown",this.stopShowingTooltip))}startListeningWindow(){window.addEventListener("mousemove",this.handleWindowMouseMove,!0),window.addEventListener("contextmenu",this.stopShowingTooltip,!0),window.addEventListener("wheel",this.handleWheel)}stopListeningWindow(){window.removeEventListener("mousemove",this.handleWindowMouseMove,!0),window.removeEventListener("contextmenu",this.stopShowingTooltip,!0),window.removeEventListener("wheel",this.handleWheel)}handleMouseMove(){this.startTimer()}handleWheel(){const{isShown:e}=this.state;this.popper.current&&this.parent&&e&&!this.popper.current.element.matches(":hover")&&!this.parent.matches(":hover")&&(this.stopTimer(),this.hide())}handleMouseLeave(){const{isShown:e}=this.state;this.stopTimer();const{interactive:t}=this.props;!t&&e&&this.hide()}handleTimeout(){this.show()}handleWindowMouseMove(e){const t=e.clientX,n=e.clientY,{isShown:s}=this.state;if(!this.popper.current||!this.parent)return;const i=this.popper.current.element.getBoundingClientRect(),o=this.parent.getBoundingClientRect();t>=i.left&&t<=i.left+i.width&&n>=i.top&&n<=i.top+i.height?this.handleMouseMove():t>=o.left&&t<=o.left+o.width&&n>=o.top&&n<=o.top+o.height?this.handleMouseMove():s&&(this.stopTimer(),this.hide())}startTimer(){this.stopTimer();const{timeout:e,reshowTimeout:t}=this.props;let n=e;(Lt.shownTooltipCount>0||Date.now()-Lt.lastHiddenTime<Lt.triggerReshowThreshold)&&(n=t),this.timer=window.setTimeout(this.handleTimeout,n)}stopTimer(){this.timer!=null&&(clearTimeout(this.timer),this.timer=null)}show(){const{isShown:e}=this.state;if(this.stopTimer(),!e){this.popper.current?.show(),this.setState({isShown:!0});const{interactive:t}=this.props;t&&this.startListeningWindow()}}hide(){this.popper.current?.hide(),this.stopListeningWindow()}update(){this.popper.current?.scheduleUpdate()}handleExited(){this.setState({isShown:!1});const{onExited:e}=this.props;e()}stopShowingTooltip(){const{isShown:e}=this.state;this.stopTimer(),e&&this.hide()}render(){const{interactive:e,children:t,referenceObject:n,popperClassName:s,"data-testid":i,onEntered:o}=this.props,{isShown:a}=this.state;let{options:r}=this.props;return r={placement:"bottom",...r},l.jsx("div",{ref:this.container,style:{display:"none"},"data-testid":i,children:l.jsx(ri,{className:$(s),options:r,ref:this.popper,onEntered:o,onExited:this.handleExited,interactive:e,referenceObject:n,children:l.jsxs("div",{className:"tooltip-content",children:[" ",a&&t]})})})}}const tt=Lt;function er(d){const{children:e,className:t,style:n,"data-testid":s}=d;return l.jsx("div",{className:$("btn-group",t),style:n,role:"group","data-testid":s,children:e})}er.displayName="ButtonGroup";er.propTypes={children:D.node.isRequired,className:D.string,style:D.object,"data-testid":D.string};er.defaultProps={className:null,style:{},"data-testid":void 0};const jg=["primary","secondary","tertiary","success","danger","inline","ghost"],Hg=["group-end"];function Bg(d,e){switch(d){case"primary":return"btn-primary";case"secondary":return"btn-outline-primary";case"tertiary":return"btn-secondary";case"success":return"btn-success";case"danger":return"btn-danger";case"inline":return"btn-inline";case"ghost":return $("btn-link",{"btn-link-icon":e,"btn-link-icon-only":e})}}function Vg(d){switch(d){case"group-end":return $("pl-2","pr-3")}}const tr=X.forwardRef((d,e)=>{const{kind:t,variant:n,type:s,tooltip:i,icon:o,disabled:a=!1,active:r,onClick:c,onContextMenu:h,onMouseDown:u,onMouseUp:m,onMouseEnter:p,onMouseLeave:g,onKeyDown:C,className:f,style:S,children:v,tabIndex:w,"data-testid":T,"aria-label":y}=d,E=Boolean(o&&v==null),I=Bg(t,E);let F;n&&(F=Vg(n));let N;o&&(N=X.isValidElement(o)?o:l.jsx(J,{icon:o}));let H;i!==void 0&&(H=typeof i=="string"?l.jsx(tt,{children:i}):i);let P=y;y===void 0&&E&&i!=null&&typeof i=="string"&&(P=i);const O=l.jsxs("button",{"data-testid":T,ref:e,type:s,className:$("btn",I,F,{active:r},f),onClick:c,onContextMenu:h,onMouseUp:m,onMouseDown:u,onMouseEnter:p,onMouseLeave:g,onKeyDown:C,style:S,disabled:a,tabIndex:w,"aria-label":P,children:[o&&N,v,i!=null&&!a&&H]});return a?l.jsxs("span",{className:"btn-disabled-wrapper",children:[O,i!==void 0&&H]}):O});tr.displayName="Button";tr.propTypes={kind:D.oneOf(jg).isRequired,variant:D.oneOf(Hg),type:D.oneOf(["submit","reset","button"]),tooltip(d){const{tooltip:e,icon:t,children:n}=d;return e===void 0&&t!=null&&n==null?new Error("Tooltip is required for icon only buttons"):null},icon(d){const{children:e,icon:t}=d;return t==null&&e==null?new Error("Icon is required if no children are provided"):e==null&&!X.isValidElement(t)&&(t==null||t.iconName===""||t.iconName==null)?new Error("Icon must be react element or fontawesome IconDefinition"):null},disabled:D.bool,active:D.bool,onClick(d){const{onClick:e,type:t}=d;return t==="button"&&typeof e!="function"?new Error("type button requires an onClick function"):e!==void 0&&typeof e!="function"?new Error("onClick must be a function"):null},onContextMenu:D.func,onMouseUp:D.func,onMouseDown:D.func,onMouseEnter:D.func,onMouseLeave:D.func,onKeyDown:D.func,tabIndex:D.number,children:D.node,className:D.string,style:D.object,"data-testid":D.string};tr.defaultProps={type:"button",onClick:void 0,onContextMenu:void 0,onMouseUp:void 0,onMouseDown:void 0,onMouseEnter:void 0,onMouseLeave:void 0,onKeyDown:void 0,variant:void 0,tooltip:void 0,icon:void 0,disabled:!1,active:void 0,tabIndex:void 0,children:void 0,className:void 0,style:{},"data-testid":void 0};const V=tr;function kl({className:d="modal-footer",children:e,"data-testid":t}){return l.jsx("div",{className:d,"data-testid":t,children:e})}function ji(d){const{isOpen:e,headerText:t,bodyText:n,onCancel:s,onConfirm:i,onDiscard:o,onModalDisable:a,cancelButtonText:r="Cancel",confirmButtonText:c="Okay",discardButtonText:h="Discard",isConfirmDanger:u=!1,children:m,"data-testid":p}=d,g=b.useRef(null),C=b.useRef(null),f=b.useCallback(()=>{C.current!==null&&C.current.checked&&a&&a(),i()},[i,a]),S=b.useCallback(()=>{g.current?.focus()},[]);let v="";return e&&(v=typeof n=="function"?n():n),l.jsxs(Do,{isOpen:e,className:"theme-bg-light",onOpened:S,children:[l.jsx(Fo,{closeButton:!1,children:t}),l.jsx(No,{children:v}),l.jsxs(kl,{children:[a&&l.jsxs("div",{className:"custom-control custom-checkbox form-group mr-auto",children:[l.jsx("input",{type:"checkbox",className:"custom-control-input",id:"move-confirmation-checkbox",defaultChecked:!1,ref:C,"data-testid":p!==void 0?`${p}-checkbox-confirm`:void 0}),l.jsx("label",{className:"custom-control-label",htmlFor:"move-confirmation-checkbox",children:"Don't ask me again"})]}),o&&l.jsx(V,{kind:"secondary",className:"mr-auto","data-dismiss":"modal",onClick:o,"data-testid":p!==void 0?`${p}-btn-discard`:void 0,children:h}),s&&l.jsx(V,{kind:"secondary","data-dismiss":"modal",onClick:s,"data-testid":p!==void 0?`${p}-btn-cancel`:void 0,children:r}),l.jsxs(er,{children:[l.jsx(V,{kind:u?"danger":"primary",onClick:f,ref:g,"data-testid":p!==void 0?`${p}-btn-confirm`:void 0,children:c}),m]})]})]})}ji.propTypes={isOpen:D.bool.isRequired,headerText:D.string.isRequired,bodyText:D.oneOfType([D.string,D.func]).isRequired,onCancel:D.func,onConfirm:D.func.isRequired,onDiscard:D.func,onModalDisable:D.func,cancelButtonText:D.string,confirmButtonText:D.string,discardButtonText:D.string,children:D.node,"data-testid":D.string};ji.defaultProps={children:void 0,cancelButtonText:"Cancel",confirmButtonText:"Okay",discardButtonText:"Discard",onCancel:void 0,onDiscard:void 0,onModalDisable:void 0,"data-testid":void 0};const nr=X.forwardRef((d,e)=>{const{children:t,className:n,disabled:s,onClick:i,style:o,id:a}=d;return l.jsx("button",{ref:e,type:"button",className:$("btn",n),onClick:i,style:o,disabled:s,id:a,children:t})});nr.displayName="Button";nr.propTypes={children:D.node,className:D.string,disabled:D.bool,onClick:D.func,style:D.shape({}),id:D.string};nr.defaultProps={children:null,className:"",disabled:!1,onClick:()=>null,style:{},id:""};const Ud=nr;function Ol({className:d,isFlipped:e,children:t,"data-testid":n}){const s=r=>{if(t.length!==2)throw new Error("CardFlip requires 2 children to function");return t[r]},i=b.useRef(null),o=b.useCallback(r=>{r.target===r.currentTarget&&document.body.classList.add("card-flip--is-flipping")},[]),a=b.useCallback(r=>{r.target===r.currentTarget&&document.body.classList.remove("card-flip--is-flipping")},[]);return b.useEffect(function(){if(!i.current)throw Error("ref undefined");i.current.addEventListener("transitionstart",o);const c=i.current;return function(){if(c!=null)return c.removeEventListener("transitionstart",o)}},[o]),l.jsxs("div",{className:$(d,{"card-flip--show-front":e,"card-flip--show-back":!e}),"data-testid":n,children:[l.jsx("div",{className:"card-flip--back",children:s(0)}),l.jsx("div",{ref:i,className:"card-flip--front",onTransitionEnd:a,children:s(1)})]})}function Or(d){return d.then!==void 0}class Xs{static actionsDisabled=!1;static disableAllActions(){Xs.actionsDisabled=!0}static enableAllActions(){Xs.actionsDisabled=!1}static isContextActionEvent(e){return Array.isArray(e.contextActions)}static compareActions(e,t){return e.group!==t.group?(e.group??0)>(t.group??0)?1:-1:e.order!==t.order?(e.order??0)>(t.order??0)?1:-1:e.title!==t.title?(e.title??"")>(t.title??"")?1:-1:e!==t?e>t?1:-1:0}static sortActions(e){if(e==null||!Array.isArray(e))return[];const t=e.slice();return t.sort(Xs.compareActions),t}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return Xs.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){const t=Xs.getModifierKey();return e[t]}static getMenuItems(e,t=!0){let n=[],s=e;Array.isArray(s)||(s=[s]);for(let i=0;i<s.length;i+=1){const o=s[i];let a;typeof o=="function"?a=o():a=o,a!=null&&(a instanceof Promise?t&&n.push(a):Array.isArray(a)?n=n.concat(a):n.push(a))}return n=n.filter(i=>i.title!==void 0||i.then!=null||i.menuElement),n}static getNextMenuItem(e,t,n){let s=e;s<0&&t<0&&(s=n.length);for(let i=1;i<n.length+1;i+=1){const o=(s+t*i+n.length)%n.length,a=n[o];if(!(a instanceof Promise)&&a.disabled!==!0)return o}return e}}const He=Xs,$d=Z.module("GlobalContextAction");class Ug extends b.Component{constructor(e){super(e),this.handleContextMenu=this.handleContextMenu.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}componentDidMount(){document.body.addEventListener("contextmenu",this.handleContextMenu),document.body.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.body.removeEventListener("contextmenu",this.handleContextMenu),document.body.removeEventListener("keydown",this.handleKeyDown)}handleContextMenu(e){const t=e;t.contextActions==null&&(t.contextActions=[]);const{action:n}=this.props;n.title==null&&!n.menuElement||(t.contextActions==null&&(t.contextActions=[]),t.contextActions.push(n),$d.debug("Received context menu event at global action! Menu items are now: ",t.contextActions))}handleKeyDown(e){const{action:t}=this.props;!He.actionsDisabled&&t.shortcut!==void 0&&t.shortcut.matchesEvent(e)&&($d.debug("Global hotkey matched!",e),t.action?.(e),e.preventDefault(),e.stopPropagation())}render(){return null}}const $g=Ug;class Wg extends b.Component{render(){const{actions:e,"data-testid":t}=this.props,n=[];for(let s=0;s<e.length;s+=1){const i=e[s],{shortcut:o}=i;if(i.title!=null||i.menuElement||o){const a=l.jsx($g,{action:i,"data-testid":t},`${i.title}.${o?.id}`);n.push(a)}}return n}}const Gg=Wg;const Qo=Z.module("ContextActions");class zg extends b.Component{static groups={default:null,high:100,medium:5e3,low:1e4,global:1e5,edit:100};static triggerMenu(e,t,n,s){if(s.length===0)return;const i=new MouseEvent("contextmenu",{clientX:t,clientY:n,bubbles:!0,cancelable:!0});i.contextActions=s,e.dispatchEvent(i)}constructor(e){super(e),this.handleContextMenu=this.handleContextMenu.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.container=X.createRef(),this.state={globalActions:[],keyboardActions:[]}}static getDerivedStateFromProps(e){if(e.actions==null||!Array.isArray(e.actions))return{globalActions:[],keyboardActions:[]};const t=e.actions.filter(s=>!Or(s)&&typeof s!="function"&&s.isGlobal),n=e.actions.filter(s=>!Or(s)&&typeof s!="function"&&(s.isGlobal===void 0||!s.isGlobal)&&s.shortcut!=null);return{globalActions:t,keyboardActions:n}}componentDidMount(){this.container.current?.parentElement&&(this.container.current.parentElement.addEventListener("contextmenu",this.handleContextMenu),this.container.current.parentElement.addEventListener("keydown",this.handleKeyDown))}componentWillUnmount(){this.container.current?.parentElement&&(this.container.current.parentElement.removeEventListener("contextmenu",this.handleContextMenu),this.container.current.parentElement.removeEventListener("keydown",this.handleKeyDown))}container;handleContextMenu(e){const{ignoreClassNames:t=[]}=this.props;if(t.length>0){let s=e.target;for(;s!=null;){const{classList:i}=s,o=t.find(a=>i.contains(a));if(o!==void 0){Qo.debug2(`Contextmenu event ignored based on the target className "${o}"`);return}s=s.parentElement}}if(He.isContextActionEvent(e)||(e.contextActions=[]),!He.isContextActionEvent(e))return;const{actions:n}=this.props;if(n!=null){let s=n;Array.isArray(s)&&(s=s.filter(i=>Or(i)||typeof i=="function"||i.isGlobal===void 0||!i.isGlobal)),e.contextActions=e.contextActions.concat(s)}Qo.debug("Received context menu event! Menu items are now: ",e.contextActions)}handleKeyDown(e){const{keyboardActions:t}=this.state;for(let n=0;n<t.length;n+=1){const s=t[n];!He.actionsDisabled&&s.shortcut!=null&&s.shortcut.matchesEvent(e)&&(Qo.debug("Context hotkey matched!",e),s.action?.(e),e.stopPropagation(),e.preventDefault(),Qo.debug2("Matched hotkey returned false, key event not consumed"))}}render(){const{"data-testid":e}=this.props,{globalActions:t}=this.state;return l.jsx("div",{className:"context-actions-listener",ref:this.container,"data-testid":e,children:l.jsx(Gg,{actions:t})})}}const ae=zg,Al=X.forwardRef((d,e)=>{function t(f){const{menuItem:S,onMenuItemClick:v}=d;v(S,f)}function n(f){const{menuItem:S,onMenuItemMouseMove:v}=d;v(S,f)}function s(f){const{menuItem:S,onMenuItemContextMenu:v}=d;v(S,f)}function i(f,S,v){if(typeof f.type=="string")return f;const{closeMenu:w,menuItem:T,isKeyboardSelected:y,isMouseSelected:E,"data-testid":I}=d,F={menuItem:T,closeMenu:w,isKeyboardSelected:y,isMouseSelected:E,iconElement:S,displayShortcut:v,"data-testid":I};return X.cloneElement(f,{forwardedProps:F})}const{children:o,menuItem:a,isKeyboardSelected:r=!1,isMouseSelected:c=!1,"data-testid":h}=d,u=a.shortcut?.getDisplayText();let m=null;if(a.icon){const f=a.icon;if(X.isValidElement(f))m=f;else{let S;a.iconColor!=null&&(a.disabled===void 0||!a.disabled)&&(S={color:a.iconColor}),m=l.jsx(J,{icon:f,style:S})}}let p=null;const g=Boolean(o);a.actions&&(p=l.jsx(J,{icon:yh}));let C=null;if(a.menuElement)C=l.jsx("div",{className:"custom-menu-item",onMouseMove:n,children:i(a.menuElement,m,u)});else{const f=a.disabled,S=a.iconOutline;C=l.jsx("button",{type:"button",className:$("btn-context-menu",{disabled:f},{active:(g||c)&&(f===void 0||!f)},{"keyboard-active":r&&(f===void 0||!f)}),onClick:t,onMouseMove:n,onContextMenu:s,title:a.description??"",children:l.jsxs("div",{className:"btn-context-menu-wrapper",children:[l.jsx("span",{className:$("icon",{outline:S}),children:m}),l.jsx("span",{className:"title",children:a.title}),u!==void 0&&l.jsx("span",{className:"shortcut",children:u}),p&&l.jsx("span",{className:$("submenu-indicator",{disabled:f}),children:p})]})})}return l.jsxs("div",{className:"context-menu-item",ref:e,"data-testid":h,children:[o,C]})});Al.displayName="ContextMenuItem";Al.defaultProps={children:null,isKeyboardSelected:!1,isMouseSelected:!1,"data-testid":void 0};const Lh=Al,De=Object.freeze([]),Gn=new Map;class Kg extends Error{isCanceled=!0}const Hi=Kg;class sr{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(a=>parseInt(a,10));else throw new Error(`Invalid color received. Got ${n}`);return document.body.removeChild(t),sr.getBrightness(i)<125}static getBrightness(e){return Math.round((e[0]*299+e[1]*587+e[2]*114)/1e3)}}async function $i(d){const{clipboard:e}=navigator;if(e!==void 0)try{return navigator.clipboard.writeText(d)}catch{return Wd(d)}Wd(d)}function Wd(d){const e=document.activeElement,t=document.createElement("textarea");t.value=d,document.body.appendChild(t),t.focus(),t.select();const n=document.execCommand("copy");if(document.body.removeChild(t),e instanceof HTMLElement&&e.focus(),!n)throw new Error("Unable to execute copy command")}const qg="table_",Gd="column_",Yg=new Set(["in","not","i","ii","k"]),Xg=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"]),Zg=/[^a-zA-Z0-9_$+@-]/g,Qg=/[^A-Za-z0-9_$]/g;class cn{static legalize=(e,t,n,s,i)=>{let o=e.trim().replace(/[- ]/g,"_");return s&&(Yg.has(o)||Xg.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=>cn.legalize(e,qg,Zg,!1,0);static legalizeColumnNames=e=>{const t=[];return e.forEach((n,s)=>{let i=cn.legalizeColumnName(n,s);t.includes(i)&&(i=Gd+s),t.push(i)}),t};static legalizeColumnName=(e,t=0)=>cn.legalize(e,Gd,Qg,!0,t);static isValidTableName=e=>cn.legalizeTableName(e)===e;static isValidColumnName=e=>cn.legalizeColumnName(e)===e}function Jg(d,e){return d?d.closest(`.${e}`):null}const ef={getClosestByClassName:Jg};class Ve extends CustomEvent{constructor(e,t){super(e,t)}}class tf extends Error{isTimeout=!0}const Ph=tf;class ve{static makeCancelable(e,t){let n=!1,s,i;const o=new Promise((a,r)=>{i=r,Promise.resolve(e).then(c=>{n?t&&t(c):(s=c,a(c))}).catch(c=>r(c))});return o.cancel=()=>{n=!0,i(new Hi),s!=null&&t&&t(s)},o}static isCanceled(e){return e instanceof Hi}static isTimedOut(e){return e instanceof Ph}}class nf{pending=[];resolved=[];add(e,t){const n=ve.makeCancelable(e,t);return this.pending.push(n),n.then(()=>{this.resolve(n)},()=>{this.resolve(n)}),n}remove(e){for(let t=0;t<this.pending.length;t+=1)if(this.pending[t]===e){this.pending.splice(t,1);return}}resolve(e){this.remove(e),this.resolved.push(e)}cancel(){const e=[...this.pending,...this.resolved];for(let t=0;t<e.length;t+=1)e[t].cancel();this.pending=[],this.resolved=[]}}const ts=nf;function M(d){if(d==null)throw new Error("Value is null or undefined")}function _(d,e,t=void 0){const n=d.get(e)??t;if(n!==void 0)return n;throw new Error(`Missing value for key ${e}`)}class ln{static isValidRange(e){return e!=null&&e.length===2&&Number.isInteger(e[0])&&Number.isInteger(e[1])&&e[0]<=e[1]}static validateRange(e){if(!ln.isValidRange(e))throw new Error(`Invalid range! ${e}`)}static isSelected(e,t){for(let n=0;n<e.length;n+=1){const s=e[n],i=s[0],o=s[1];if(i<=t&&t<=o)return!0}return!1}static selectRange(e,t){let[n,s]=t;const i=[...e];for(let o=i.length-1;o>=0;o-=1){const a=i[o],r=a[0],c=a[1];if(r<=n&&s<=c)return i;n<=c&&r<=s&&(n=Math.min(n,r),s=Math.max(s,c),i.splice(o,1))}return i.push([n,s]),i}static deselectRange(e,t){const[n,s]=t,i=[...e];for(let o=i.length-1;o>=0;o-=1){const a=i[o],r=a[0],c=a[1];if(!(s<r||c<n))if(r<n&&s<c){i[o]=[r,n-1],i.splice(o+1,0,[s+1,c]);break}else n<=r&&c<=s?i.splice(o,1):r<n?i[o]=[r,n-1]:i[o]=[s+1,c]}return i}static count(e){return e.reduce((t,n)=>t+(n[1]-n[0]+1),0)}static getItemsInRanges(e,t){return t.reduce((n,s)=>{const i=[...n];for(let o=s[0];o<=s[1];o+=1)i.push(e[o]);return i},[])}}class sf{static join(e,t="and"){if(e==null||e.length===0)return"";if(e.length===1)return e[0];if(e.length===2)return`${e[0]} ${t} ${e[1]}`;const n=e.slice(0,e.length-1).join(", "),s=e[e.length-1];return`${n}, ${t} ${s}`}static toLower(e,t=!0){if(e==null){if(t)return"";throw new Error("Null string passed in to TextUtils.toLower")}return e.toLowerCase()}static sort(e,t,n=!0){return e<t?n?-1:1:e>t?n?1:-1:0}}const Wt=sf;class Wi{static TIME_PATTERN="([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]";static TIME_ZONES=Object.freeze([{label:"Tokyo UTC+9 No DST",value:"Asia/Tokyo"},{label:"Seoul UTC+9 No DST",value:"Asia/Seoul"},{label:"Hong Kong UTC+8 No DST",value:"Asia/Hong_Kong"},{label:"Singapore UTC+8 No DST",value:"Asia/Singapore"},{label:"Kolkata UTC+5:30 No DST",value:"Asia/Kolkata"},{label:"Berlin UTC+1",value:"Europe/Berlin"},{label:"UTC UTC±0 No DST",value:"UTC"},{label:"London UTC±0",value:"Europe/London"},{label:"Sao Paulo UTC-2",value:"America/Sao_Paulo"},{label:"Newfoundland UTC-3:30",value:"America/St_Johns"},{label:"Halifax UTC-4",value:"America/Halifax"},{label:"New York UTC−5",value:"America/New_York"},{label:"Chicago UTC-6",value:"America/Chicago"},{label:"Denver UTC-7",value:"America/Denver"},{label:"Los Angeles UTC-8",value:"America/Los_Angeles"},{label:"Anchorage UTC-9",value:"America/Anchorage"},{label:"Honolulu UTC-10 No DST",value:"Pacific/Honolulu"},{label:"Zurich UTC+1",value:"Europe/Zurich"},{label:"Amsterdam UTC+1",value:"Europe/Amsterdam"},{label:"Taipei UTC+8 No DST",value:"Asia/Taipei"},{label:"Sydney UTC+10",value:"Australia/Sydney"}]);static formatElapsedTime(e){if(typeof e!="number"||!Number.isInteger(e))throw new Error(`${e} is not a number that can be expressed as a formatted time`);const t=Math.floor(e/3600),n=Math.floor(e%3600/60),s=e%60;return`${t>0?`${t}h `:""}${n>0||t>0?`${n}m `:""}${e>=60?`${s}s`.padStart(3,"0"):`${s}s`}`}static formatTime(e){if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new Error(`${e} is not a number that can be expressed as a formatted time`);const t=String(Math.floor(e/(60*60))).padStart(2,"0"),n=e%(60*60),s=String(Math.floor(n/60)).padStart(2,"0"),i=n%60,o=String(Math.ceil(i)).padStart(2,"0");return`${t}:${s}:${o}`}static isTimeString(e){return new RegExp(Wi.TIME_PATTERN).test(e)}static parseTime(e){if(e==null||typeof e!="string")throw new Error(`${e} is not a valid string`);const t=e.split(":");if(t.length!==3)throw new Error(`${e} is not a time string that can be parsed`);return Number(t[0])*60*60+Number(t[1])*60+Number(t[2])}}class of extends Error{isInvalid=!0}const Ni=of,zd=Z.module("ContextMenu");class Da extends b.PureComponent{static defaultProps={subMenuParentWidth:0,subMenuParentHeight:0,closeMenu(){},onMenuOpened(){},onMenuClosed(){},options:{},menuStyle:{},"data-testid":void 0};static handleContextMenu(e){e.metaKey||(e.stopPropagation(),e.preventDefault())}constructor(e){super(e),this.handleBlur=this.handleBlur.bind(this),this.handleCloseSubMenu=this.handleCloseSubMenu.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleMenuItemClick=this.handleMenuItemClick.bind(this),this.handleMenuItemContextMenu=this.handleMenuItemContextMenu.bind(this),this.handleMenuItemMouseMove=this.handleMenuItemMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleWindowResize=this.handleWindowResize.bind(this),this.container=X.createRef(),this.oldFocus=document.activeElement,this.activeSubMenuRef=X.createRef(),this.subMenuTimer=0,this.rAF=0,this.initialPosition={top:e.top,left:e.left},this.state={menuItems:[],pendingItems:[],activeSubMenu:null,hasOverflow:!1,subMenuTop:null,subMenuLeft:null,subMenuParentWidth:0,subMenuParentHeight:0,keyboardIndex:-1,mouseIndex:-1}}componentDidMount(){this.initMenu(),this.verifyPosition(),window.addEventListener("resize",this.handleWindowResize),this.rAF=window.requestAnimationFrame(()=>{this.container.current?.focus();const{onMenuOpened:e}=this.props;e(this)})}componentDidUpdate(e,t){const{actions:n}=this.props,{activeSubMenu:s}=this.state;s!==t.activeSubMenu&&(s==null?this.container.current?.focus():this.setActiveSubMenuPosition()),e.actions!==n&&(this.initMenu(),(this.container.current==null||!this.container.current.contains(document.activeElement))&&this.container.current?.focus()),this.verifyPosition()}componentWillUnmount(){this.cancelPromises(),window.removeEventListener("resize",this.handleWindowResize),cancelAnimationFrame(this.rAF)}container;oldFocus;activeSubMenuRef;subMenuTimer;rAF;initialPosition;getKeyboardIndex(){const{options:e}=this.props;if(e.separateKeyboardMouse!==void 0&&e.separateKeyboardMouse){const{keyboardIndex:t}=this.state;return t}return this.getMouseIndex()}setKeyboardIndex(e){const{options:t}=this.props;t.separateKeyboardMouse!==void 0&&t.separateKeyboardMouse?this.setState({keyboardIndex:e}):this.setMouseIndex(e)}getMouseIndex(){const{mouseIndex:e}=this.state;return e}setMouseIndex(e){this.setState({mouseIndex:e})}initMenu(){this.cancelPromises(),cancelAnimationFrame(this.rAF);const{options:e}=this.props;let t=e.initialKeyboardIndex;t===void 0&&(t=-1);const{actions:n}=this.props,s=He.getMenuItems(n),i=[];for(let o=s.length-1;o>=0;o-=1){const a=s[o];a instanceof Promise?this.initMenuPromise(a):i.push(a)}this.setState({mouseIndex:-1,keyboardIndex:t,activeSubMenu:null,menuItems:He.sortActions(i)})}initMenuPromise(e){const t=ve.makeCancelable(e);this.setState(n=>({pendingItems:n.pendingItems.concat(t)})),t.then(n=>{this.setState(s=>{const i=s.pendingItems.indexOf(t);if(i>=0){const o=s.pendingItems.slice();return o.splice(i,1),{menuItems:He.sortActions(s.menuItems.concat(n)),pendingItems:o}}return null})},n=>{ve.isCanceled(n)||(this.setState(s=>{const i=s.pendingItems.indexOf(t);if(i>=0){const o=s.pendingItems.slice();return o.splice(i,1),{pendingItems:o}}return null}),zd.error(n))})}cancelPromises(){const{pendingItems:e}=this.state;e.map(t=>t.cancel())}setActiveSubMenuPosition(){if(this.activeSubMenuRef.current===null)return;const e=this.activeSubMenuRef.current.getBoundingClientRect();this.setState({subMenuTop:e.top,subMenuLeft:e.right,subMenuParentHeight:e.height,subMenuParentWidth:e.width})}verifyPosition(){const{options:e,updatePosition:t,subMenuParentWidth:n,subMenuParentHeight:s,top:i,left:o}=this.props;if(!this.container.current||e.doNotVerifyPosition!=null&&e.doNotVerifyPosition)return;let{top:a,left:r}=this.initialPosition;const{width:c,height:h}=this.container.current?.getBoundingClientRect()??{width:0,height:0},u=(this.container.current?.scrollHeight??0)>window.innerHeight;h===0||c===0||(a+h>window.innerHeight&&(a-h-s>0?a-=h-s:a=window.innerHeight-h),r+c>window.innerWidth&&(r=r-c-n),(o!==r||i!==a)&&(this.setState({hasOverflow:u}),t(a,r)))}handleWindowResize(){this.container.current&&this.closeMenu(!0)}handleBlur(e){if(!this.container.current){zd.warn("Container is null!");return}if(!this.container.current.contains(e.relatedTarget)){let t=e.relatedTarget,n=!1;for(;t&&!n;)n=t.hasAttribute("data-dh-context-menu"),t=t.parentElement;n||this.closeMenu(!0)}}isEscapeKey(e){const{left:t}=this.props;return e==="Escape"||t<0&&e==="ArrowRight"||e==="ArrowLeft"}handleKeyDown(e){const{menuItems:t}=this.state,n=this.getKeyboardIndex();let s=n,i=!1;if(e.key==="Enter"||e.key===" "){n>=0&&n<t.length&&this.handleMenuItemClick(t[n],e);return}if(e.key==="ArrowRight"?n>=0&&n<=t.length?i=!0:s=0:this.isEscapeKey(e.key)?s=null:e.key==="ArrowUp"||e.shiftKey&&e.key==="Tab"?s=He.getNextMenuItem(s,-1,t):(e.key==="ArrowDown"||e.key==="Tab")&&(s=He.getNextMenuItem(s,1,t)),i){this.openSubMenu(n),e.preventDefault(),e.stopPropagation();return}n!==s&&(s!==null?this.setKeyboardIndex(s):(this.closeMenu(),this.oldFocus instanceof HTMLElement&&this.oldFocus.focus()),e.preventDefault(),e.stopPropagation())}openSubMenu(e){const{menuItems:t,activeSubMenu:n}=this.state,s=t[e].actions?e:null;n!==s&&this.setState({activeSubMenu:s,subMenuTop:null,subMenuLeft:null})}closeMenu(e=!1){const{closeMenu:t,onMenuClosed:n}=this.props;cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{t(e),n(this)})}closeSubMenu(){this.setState({activeSubMenu:null})}handleCloseSubMenu(e){e?this.closeMenu(!0):this.closeSubMenu()}handleMenuItemClick(e,t){t.preventDefault(),t.stopPropagation();const{menuItems:n}=this.state;e!=null&&(e.disabled===void 0||!e.disabled)&&(e.actions!=null?this.openSubMenu(n.indexOf(e)):e.action!=null&&(e.action(),this.closeMenu(!0)))}handleMenuItemContextMenu(e,t){t.metaKey||this.handleMenuItemClick(e,t)}handleMenuItemMouseMove(e){const{menuItems:t}=this.state,n=t.indexOf(e);this.setMouseIndex(n),n>=0&&n<t.length&&(e.disabled===void 0||!e.disabled)&&this.openSubMenu(n)}handleMouseLeave(){this.setMouseIndex(-1)}render(){const e=[],{top:t,left:n}=this.props,{activeSubMenu:s,hasOverflow:i,keyboardIndex:o,menuItems:a,mouseIndex:r,pendingItems:c,subMenuTop:h,subMenuLeft:u,subMenuParentWidth:m,subMenuParentHeight:p}=this.state;for(let v=0;v<a.length;v+=1){const w=a[v];v>0&&w.group!==a[v-1].group&&e.push(l.jsx("hr",{},`${v}.separator`));const T=l.jsx(Lh,{ref:s===v?this.activeSubMenuRef:null,isKeyboardSelected:o===v,isMouseSelected:r===v,menuItem:w,closeMenu:this.handleCloseSubMenu,onMenuItemClick:this.handleMenuItemClick,onMenuItemMouseMove:this.handleMenuItemMouseMove,onMenuItemContextMenu:this.handleMenuItemContextMenu},v);e.push(T)}let g=null;c.length>0&&(g=l.jsx("div",{className:"loading",children:l.jsx(Ln,{})}));const{menuStyle:C,"data-testid":f}=this.props,S=s!==null&&h!==null&&u!==null;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:$({"has-overflow":i},"context-menu-container"),style:{top:t,left:n,...C},ref:this.container,"data-dh-context-menu":!0,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown,onMouseLeave:this.handleMouseLeave,onContextMenu:Da.handleContextMenu,role:"menuitem",tabIndex:0,"data-testid":f,children:[e,g]}),S&&s!==null&&h!==null&&u!==null&&l.jsx(Da,{actions:a[s].actions||[],closeMenu:this.handleCloseSubMenu,top:h,left:u,updatePosition:(v,w)=>{this.setState({subMenuTop:v,subMenuLeft:w})},subMenuParentWidth:m,subMenuParentHeight:p},`sub-${s}`)]})}}const af=Da;class rf extends b.Component{constructor(e){super(e),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=X.createRef(),this.openMenu=X.createRef(),this.state={actions:null,left:0,top:0}}componentDidMount(){this.container.current?.parentElement&&this.container.current.parentElement.addEventListener("contextmenu",this.handleContextMenu)}componentWillUnmount(){this.container.current?.parentElement&&this.container.current.parentElement.removeEventListener("contextmenu",this.handleContextMenu)}container;openMenu;handleContextMenu(e){if(!He.isContextActionEvent(e)||!this.container.current||e.metaKey||e.ctrlKey)return;const t=He.getMenuItems(e.contextActions),n=this.container.current.getBoundingClientRect(),s=e.clientY-n.top,i=e.clientX-n.left;if(t.length===0){if(e.target===this.container.current){e.preventDefault(),this.setState({actions:null},()=>{const o=document.elementFromPoint(i,s),a=new MouseEvent("contextmenu",{clientX:e.clientX,clientY:e.clientY,bubbles:!0,cancelable:!0});o?.dispatchEvent(a)});return}return}e.preventDefault(),this.setState({actions:t,top:s,left:i})}handleMenuClose(e){e===this.openMenu.current&&this.setState({actions:null})}render(){let e=null;const{"data-testid":t}=this.props,{actions:n,top:s,left:i}=this.state;return n&&(e=l.jsx(af,{ref:this.openMenu,actions:n,onMenuClosed:this.handleMenuClose,top:s,left:i,updatePosition:(o,a)=>{this.setState({top:o,left:a})},"data-testid":t})),l.jsx("div",{className:$("context-menu-root",{active:n}),ref:this.container,children:e})}}const _h=rf;class Ss extends b.Component{static propTypes={className:D.string,in:D.bool.isRequired,children:D.node.isRequired,autoFocusOnShow:D.bool,"data-testid":D.string};static defaultProps={className:"",autoFocusOnShow:!1,"data-testid":void 0};static handleEnter(e){const t=e;t.style.height="0"}static handleEntering(e){const t=e;t.style.height=`${Ss.getHeight(t)}px`}static handleExiting(e){const t=e;t.style.height="0"}static handleExit(e){const t=e;t.style.height=`${Ss.getHeight(t)}px`}static getHeight(e){const t=e.scrollWidth-e.clientWidth;return e.scrollHeight-t}constructor(e){super(e),this.handleEntered=this.handleEntered.bind(this)}handleEntered(e){const t=e;t.style.height="";const{autoFocusOnShow:n}=this.props;if(n!==void 0&&n){const s=t.querySelector("input, select, textarea");s?.focus()}}render(){const{children:e,className:t,in:n,"data-testid":s}=this.props;return l.jsx(gt,{in:n,classNames:{enterActive:"collapsing",enterDone:"collapse show",exitActive:"collapsing",exitDone:"collapse"},onEnter:Ss.handleEnter,onEntering:Ss.handleEntering,onEntered:this.handleEntered,onExit:Ss.handleExit,onExiting:Ss.handleExiting,timeout:350,children:i=>l.jsx("div",{className:$({collapse:i==="exited"},t),"data-testid":s,children:e})})}}const lf=Ss;function ir(d){const e=b.useRef();return b.useEffect(function(){e.current=d}),e.current}function jh(d){const e=b.useRef(null);return b.useEffect(function(){d&&(typeof d=="function"?d(e.current):d.current=e.current)}),e}const df=3500,cf=Z.module("useCopyToClipboard");function hf(){const[d,e]=b.useState(!1),t=b.useRef(null),n=b.useCallback(s=>{$i(s).then(()=>{e(!0)}).catch(i=>cf.error(`Unable to copy ${s}`,`
|
|
2
2
|
`,i))},[]);return b.useEffect(()=>(t.current&&clearTimeout(t.current),d&&(t.current=setTimeout(()=>{e(!1)},df)),()=>{t.current&&clearTimeout(t.current)}),[d]),[d,n]}const or=X.forwardRef((d,e)=>{const{checked:t=!1,children:n,className:s,disabled:i,inputClassName:o,isInvalid:a,labelClassName:r,name:c,onChange:h,"data-testid":u}=d,[m]=b.useState(Pe()),p=jh(e);b.useEffect(function(){p.current&&(p.current.indeterminate=t===null)},[p,t]);const g=b.useCallback(C=>{p.current&&(p.current.indeterminate=t===null),h&&h(C)},[p,t,h]);return l.jsxs("div",{className:$("custom-control custom-checkbox",s),children:[l.jsx("input",{type:"checkbox",ref:p,checked:t??!1,className:$("custom-control-input",o,{"is-invalid":a}),disabled:i,id:m,name:c,onChange:g,"data-testid":u}),l.jsx("label",{className:$("custom-control-label",r),htmlFor:m,children:n})]})});or.displayName="Checkbox";or.propTypes={checked:(d,e)=>{const{[e]:t}=d;return t!==null&&typeof t!="boolean"?new Error("Checked must be a boolean or null for indeterminate"):null},children:D.node.isRequired,className:D.string,disabled:D.bool,inputClassName:D.string,isInvalid:D.bool,labelClassName:D.string,name:D.string,onChange:D.func,"data-testid":D.string};or.defaultProps={checked:!1,className:"",disabled:!1,inputClassName:"",isInvalid:!1,labelClassName:"",name:void 0,onChange:void 0,"data-testid":void 0};const Xt=or;class uf extends b.PureComponent{static defaultProps={placeholder:"Search",className:"",matchCount:null,onKeyDown(){},id:"","data-testid":void 0};constructor(e){super(e),this.inputField=X.createRef()}inputField;focus(){this.inputField.current?.focus()}render(){const{value:e,placeholder:t,onBlur:n,onChange:s,className:i,disabled:o,matchCount:a,id:r,onKeyDown:c,"data-testid":h}=this.props;return l.jsxs("div",{className:$("search-group",i),children:[l.jsx("input",{type:"search",value:e,onBlur:n,onChange:s,onKeyDown:c,className:"form-control",disabled:o,placeholder:t,ref:this.inputField,id:r,"data-testid":h}),a!=null&&l.jsx("span",{className:"search-match",children:a}),l.jsx("span",{className:"search-icon",children:l.jsx(J,{icon:xh})})]})}}const As=uf;var Hh=(d=>(d.UP="UP",d.DOWN="DOWN",d))(Hh||{});class Ti extends b.Component{static MENU_NAVIGATION_DIRECTION=Hh;static DROP_DOWN_MENU_HEIGHT=200;static propTypes={options:D.arrayOf(D.shape({title:D.string.isRequired,value:D.string.isRequired})).isRequired,popperOptions:D.shape({title:D.string.isRequired,value:D.string.isRequired}),onChange:D.func,inputPlaceholder:D.string,searchPlaceholder:D.string,disabled:D.bool,className:D.string,defaultValue:D.string,spellCheck:D.bool,onEnter:D.func,"data-testid":D.string};static defaultProps={onChange(){},inputPlaceholder:"",searchPlaceholder:"Search",disabled:!1,className:"",defaultValue:"",popperOptions:null,spellCheck:!0,onEnter(){},"data-testid":void 0};constructor(e){super(e),this.state={value:"",filter:"",filteredOptions:e.options,keyboardOptionIndex:-1,menuIsOpen:!1,inputWidth:100},this.toggleMenu=this.toggleMenu.bind(this),this.handleMenuKeyDown=this.handleMenuKeyDown.bind(this),this.handleMenuBlur=this.handleMenuBlur.bind(this),this.closeMenu=this.closeMenu.bind(this),this.handleInputChange=this.handleInputChange.bind(this),this.handleInputKeyDown=this.handleInputKeyDown.bind(this),this.handleInputBlur=this.handleInputBlur.bind(this),this.handleFilterChange=this.handleFilterChange.bind(this),this.handleOptionClick=this.handleOptionClick.bind(this),this.handleOptionFocus=this.handleOptionFocus.bind(this),this.handleMenuOpened=this.handleMenuOpened.bind(this),this.handleMenuExited=this.handleMenuExited.bind(this),this.popper=X.createRef(),this.cbContainer=X.createRef(),this.toggleButton=X.createRef(),this.menuContainer=X.createRef(),this.input=X.createRef(),this.searchInput=X.createRef()}componentDidUpdate(){const{menuIsOpen:e,keyboardOptionIndex:t}=this.state;e&&t>=0&&this.scrollOptionIntoView()}popper;cbContainer;toggleButton;menuContainer;input;searchInput;setInputWidth(){this.cbContainer.current&&this.setState({inputWidth:this.cbContainer.current.getBoundingClientRect().width})}getCachedFilteredOptions=pe((e,t)=>e.filter(n=>n.title.toLowerCase().indexOf(t.toLowerCase())>=0||n.value.toLowerCase().indexOf(t.toLowerCase())>=0));focus(){this.input.current?.focus()}resetValue(){this.setState({value:""})}updateInputValue(e){const{onChange:t}=this.props;this.setState({value:e}),t(e)}handleResize(){this.setInputWidth()}handleMenuKeyDown(e){const{filter:t,filteredOptions:n,keyboardOptionIndex:s}=this.state,{options:i}=this.props,o=t?n:i;switch(e.key){case"Enter":o[s]?.value!=null&&this.updateInputValue(o[s].value),this.closeMenu(),this.input.current?.focus(),e.stopPropagation(),e.preventDefault();break;case"ArrowUp":this.handleMenuNavigation(Ti.MENU_NAVIGATION_DIRECTION.UP),e.stopPropagation(),e.preventDefault();break;case"ArrowDown":this.handleMenuNavigation(Ti.MENU_NAVIGATION_DIRECTION.DOWN),e.stopPropagation(),e.preventDefault();break;case"Escape":t!==""?(this.setState({filter:""}),e.stopPropagation()):this.closeMenu();break;case"Tab":!e.shiftKey&&s===o.length-1&&this.closeMenu();break}}handleMenuNavigation(e){const{filter:t,filteredOptions:n,keyboardOptionIndex:s}=this.state,{options:i}=this.props,a=(t?n:i).length;let r=0;switch(e){case Ti.MENU_NAVIGATION_DIRECTION.UP:r=-1;break;case Ti.MENU_NAVIGATION_DIRECTION.DOWN:r=1;break}r!==0&&this.setState({keyboardOptionIndex:(s+r+a)%a})}handleInputKeyDown(e){const{onEnter:t}=this.props,{menuIsOpen:n}=this.state;e.key==="ArrowDown"||e.key==="ArrowUp"?n||this.openMenu():e.key==="Enter"&&t()}handleInputChange(e){this.updateInputValue(e.target.value)}handleOptionClick(e){const t=Number(e.currentTarget.value),{filter:n,filteredOptions:s}=this.state,{options:i}=this.props,o=n?s:i;this.updateInputValue(o[t].value),this.closeMenu(),this.input.current?.focus()}handleOptionFocus(e){this.setState({keyboardOptionIndex:Number(e.target.value)})}handleFilterChange(e){const{options:t}=this.props,n=e.target.value,s=this.getCachedFilteredOptions(t,n);this.setState({filter:n,filteredOptions:s,keyboardOptionIndex:0}),this.popper.current?.scheduleUpdate()}handleMenuBlur(e){e.relatedTarget instanceof Element&&this.popper.current!=null&&this.popper.current.element.contains(e.relatedTarget)||e.relatedTarget===this.toggleButton.current||this.closeMenu(!1)}handleInputBlur(e){const{menuIsOpen:t}=this.state;t&&e.relatedTarget instanceof Element&&this.popper.current!=null&&this.popper.current.element.contains(e.relatedTarget)||this.closeMenu(!1)}handleMenuOpened(){this.scrollOptionIntoView(),this.searchInput.current?.focus()}handleMenuExited(){const{menuIsOpen:e}=this.state;e&&(this.setState({menuIsOpen:!1}),this.popper.current?.hide()),this.setState({filter:""})}toggleMenu(e){const{menuIsOpen:t}=this.state;t?this.closeMenu():this.openMenu(),e.stopPropagation()}openMenu(){this.updateKeyboardIndex(),this.setInputWidth(),this.setState({menuIsOpen:!0}),window.requestAnimationFrame(()=>{this.popper.current?.show()})}closeMenu(e=!0){this.setState({menuIsOpen:!1}),e&&this.input.current?.focus(),this.popper.current?.hide()}updateKeyboardIndex(){const{value:e,filter:t,filteredOptions:n}=this.state,{options:s}=this.props,o=(t?n:s).findIndex(a=>a.value===e);this.setState({keyboardOptionIndex:o})}scrollOptionIntoView(){const e=this.menuContainer.current?.querySelector(".cb-option-btn.keyboard-active");e instanceof HTMLElement&&e.scrollIntoView({block:"nearest",inline:"nearest"})}renderMenuElement(){const{searchPlaceholder:e}=this.props,{filter:t,inputWidth:n}=this.state;return l.jsxs("div",{className:"cb-menu-container",ref:this.menuContainer,role:"presentation",onKeyDown:this.handleMenuKeyDown,onClick:s=>{s.stopPropagation()},style:{width:n},onBlur:this.handleMenuBlur,children:[l.jsx("div",{className:"cb-search-input-container",children:l.jsx(As,{value:t,ref:this.searchInput,onChange:this.handleFilterChange,className:"cb-search-input",placeholder:e})}),l.jsx("div",{className:"cb-options-container",children:l.jsx("div",{className:"cb-options",children:this.renderOptions()})})]})}renderOptions(){const{options:e}=this.props,{keyboardOptionIndex:t,filter:n,filteredOptions:s}=this.state;return(n?s:e).map((o,a)=>{const r=`option-${a}-${o.value}`;return l.jsx("button",{type:"button",value:a,className:$("cb-option-btn",{"keyboard-active":t===a}),onClick:this.handleOptionClick,onFocus:this.handleOptionFocus,children:o.title},r)})}render(){const{options:e,inputPlaceholder:t,disabled:n,className:s,defaultValue:i,spellCheck:o,"data-testid":a}=this.props,{value:r}=this.state;let{popperOptions:c}=this.props;return c={placement:"bottom-end",modifiers:{preventOverflow:{enabled:!1}},...c},l.jsxs("div",{className:"input-group cb-container",ref:this.cbContainer,children:[l.jsx("input",{value:r||i,className:$("form-control",s,"cb-input"),ref:this.input,onChange:this.handleInputChange,placeholder:t||(e[0]!=null?e[0].title:void 0),disabled:n,onBlur:this.handleInputBlur,onKeyDown:this.handleInputKeyDown,spellCheck:o,"data-testid":a!==void 0?`${a}-input`:void 0}),l.jsx("div",{className:"input-group-append cb-dropdown",children:l.jsxs("button",{type:"button",className:"btn cb-btn form-control",ref:this.toggleButton,onClick:this.toggleMenu,onKeyDown:this.handleInputKeyDown,disabled:n,"data-testid":a!==void 0?`${a}-btn`:void 0,children:[l.jsx(J,{icon:kn}),l.jsx(ri,{ref:this.popper,options:c,className:$("combobox interactive"),onEntered:this.handleMenuOpened,onExited:this.handleMenuExited,children:this.renderMenuElement()})]})})]})}}const Bh=Ti;function ar({copy:d,kind:e="ghost",tooltip:t="Copy",className:n,"data-testid":s,children:i}){const[o,a]=hf();return l.jsx(V,{kind:e,className:n,"data-testid":s,icon:o?Tp:Ep,tooltip:o?"Copied":t,onClick:()=>{a(typeof d=="function"?d():d)},children:i})}const hn=Z.module("MaskedInput"),fi={FORWARD:"forward",BACKWARD:"backward",NONE:"none"},Jo=" ";function Vh(d,e,t){return d.substring(0,e)+t+d.substring(e+1)}function mf(d,e,t){return d.length<t?`${d}${e.substring(d.length,t)}`:d}function Kd(d,e){let{length:t}=d;for(let n=d.length-1;n>=0&&e[n]===d[n];n-=1)t=n;return d.substring(0,t)}const Uh=X.forwardRef((d,e)=>{const{className:t,example:n,getNextSegmentValue:s=(O,k,L)=>L,getPreferredReplacementString:i=Vh,onChange:o=()=>!1,onSelect:a=()=>!1,pattern:r,placeholder:c,selection:h,value:u,onFocus:m=()=>!1,onBlur:p=()=>!1,"data-testid":g}=d,C=jh(e),f=b.useMemo(()=>Array.isArray(n)?n:[n],[n]),S=b.useMemo(()=>f[0].replace(/[a-zA-Z0-9]/g,Jo),[f]);b.useEffect(function(){if(h!=null){hn.debug("setting selection...",h);const{selectionStart:k,selectionEnd:L,selectionDirection:A}=h;C.current?.setSelectionRange(k,L,A),hn.debug("selection set!")}},[h,C]);const v=b.useCallback(O=>{let k=O,L=O;const A=f.length>0?f[0]:u;for(let j=k-1;j>=0&&/[a-zA-Z0-9]/g.test(A.charAt(j));j-=1)k=j;for(let j=L;j<A.length&&/[a-zA-Z0-9]/g.test(A.charAt(j));j+=1)L=j+1;const U=k===L?fi.NONE:fi.BACKWARD;return{selectionStart:k,selectionEnd:L,selectionDirection:U}},[f,u]);function w(O,k,L=O.length){let A="";for(let U=0;U<L;U+=1)O.charAt(U)!==Jo?A=A.concat(O[U]):A=A.concat(k[U]);return A=A.concat(k.substring(L)),A}function T(O,k=O.length){const L=new RegExp(`^${r}$`);if(L.test(O))return!0;for(let A=0;A<f.length;A+=1){const U=w(O,f[A],k);if(L.test(U))return!0}return!1}function y(O){const k=v(O),L=k.selectionEnd+1;return L>=u.length?k:v(L)}function E(O){const k=v(O),L=k.selectionStart-1;return L<=0?k:v(L)}function I(O,k){const L=v(O),A=u.substring(L.selectionStart,L.selectionEnd),U=s(L,k,A,u),j=u.substring(0,L.selectionStart)+U+u.substring(L.selectionEnd);T(j,L.selectionEnd)&&(o(j),a(L))}const F=b.useCallback(O=>{const{selectionStart:k=0,selectionEnd:L=0,selectionDirection:A="none"}=O.target;if(k===null||L===null||A===null){hn.error("Selection attempted on non-text input element",O.target);return}if(hn.debug2("handleSelect",k,L,A),!(h!=null&&k===h.selectionStart&&L===h.selectionEnd)){if(h!=null&&k===u.length&&L===u.length&&O.nativeEvent.type!=="mouseup"){a({...h});return}if(k===L){const U=v(k);hn.debug("Selection segment from ",k,L,"=>",U),a(U)}else a({selectionStart:k,selectionEnd:L,selectionDirection:A})}},[v,a,h,u]),N=b.useCallback(O=>{if(!C.current)return;hn.debug("handleSelectCapture",O);const k=C.current.selectionStart??0;k===u.length&&h!=null&&k!==h.selectionStart&&(O.preventDefault(),O.stopPropagation())},[C,h,u]);function H(O){if(O.preventDefault(),O.stopPropagation(),!C.current)return;const{key:k}=O,{selectionStart:L=0,selectionEnd:A=0}=C.current;if(L===null||A===null){hn.error("Selection arrow nvaigation attempted on non-text input element",O.target);return}k==="ArrowLeft"?a(E(L)):k==="ArrowRight"?a(y(A)):k==="ArrowUp"?I(L,-1):k==="ArrowDown"&&I(L,1)}function P(O){if(!C.current)return;hn.debug("handleKeyDown",O);const{key:k}=O,{selectionStart:L=0,selectionEnd:A=0}=C.current;if(L===null||A===null){hn.error("Selection key event on non-text input element",O.target);return}if(k.startsWith("Arrow")){H(O);return}if(k==="Delete"||k==="Backspace"){if(O.preventDefault(),O.stopPropagation(),A>=Kd(u,S).length){const j=u.substring(0,L===A?L-1:L),W=Kd(j,S);W!==u&&(o(W),a({selectionStart:W.length,selectionEnd:W.length,selectionDirection:fi.NONE}));return}if(L!==A){const j=u.substring(0,L)+u.substring(L,A).replace(/[a-zA-Z0-9]/g,Jo)+u.substring(A);hn.debug("Range ",L,A,"deleted, setting value",j),o(j),a({selectionStart:L,selectionEnd:L,selectionDirection:fi.NONE})}else if(L>0)for(let j=L-1;j>=0;j-=1){const W=u.substring(0,j)+u.substring(j,L).replace(/[a-zA-Z0-9]/g,Jo)+u.substring(L);if(W!==u){o(W),a({selectionStart:j,selectionEnd:j,selectionDirection:fi.NONE});return}}return}if(O.altKey||O.metaKey||O.ctrlKey||k.length>1)return;O.preventDefault(),O.stopPropagation();const U=Array.from(new Set([k,k.toUpperCase(),k.toLowerCase()]));for(let j=0;j<U.length;j+=1){const W=U[j],ie=/[a-zA-Z0-9]/g.test(W)?f[0].length-1:L;for(let se=L;se<=ie;se+=1){const G=mf(u,f[0],se+1),K=i(G,se,W,L,A);if(T(K,se+1)){const te=v(se),oe=se+1;let de={selectionStart:oe,selectionEnd:oe,selectionDirection:fi.NONE};if(oe>=te.selectionEnd){const ee=y(se);ee.selectionStart!==te.selectionStart&&(de=ee)}hn.debug("handleKeyDown",k,"=>",K,de),o(K),a(de);return}}}}return l.jsx("input",{ref:C,className:$("form-control masked-input",t),type:"text",pattern:r,placeholder:c,value:u,onChange:()=>{},onKeyDown:P,onSelect:F,onSelectCapture:N,onFocus:m,onBlur:p,"data-testid":g})});Uh.defaultProps={className:"",placeholder:void 0,onChange(){},onSelect(){},getNextSegmentValue:(d,e,t)=>t,getPreferredReplacementString:Vh,selection:void 0,onFocus(){},onBlur(){},"data-testid":void 0};const pf=Uh;let gf=class extends b.PureComponent{static defaultProps={closeMenu(){},onMenuOpened(){},onMenuClosed(){},options:{},menuStyle:{},"data-testid":void 0};constructor(e){super(e),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleMenuItemClick=this.handleMenuItemClick.bind(this),this.handleMenuItemMouseMove=this.handleMenuItemMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleCloseMenu=this.handleCloseMenu.bind(this),this.container=X.createRef(),this.oldFocus=document.activeElement,this.rAF=0;const{options:t}=e,n=t.initialKeyboardIndex??-1;this.state={menuItems:[],keyboardIndex:n,mouseIndex:-1}}componentDidMount(){this.initMenu(),this.rAF=window.requestAnimationFrame(()=>{this.container.current?.focus();const{onMenuOpened:e}=this.props;e(this)})}componentDidUpdate(e){const{actions:t}=this.props;e.actions!==t&&this.initMenu()}componentWillUnmount(){cancelAnimationFrame(this.rAF)}container;oldFocus;rAF;getKeyboardIndex(){const{options:e}=this.props;if(e.separateKeyboardMouse!==void 0&&e.separateKeyboardMouse){const{keyboardIndex:t}=this.state;return t}return this.getMouseIndex()}setKeyboardIndex(e){const{options:t}=this.props;t.separateKeyboardMouse!==void 0&&t.separateKeyboardMouse?this.setState({keyboardIndex:e}):this.setMouseIndex(e)}getMouseIndex(){const{mouseIndex:e}=this.state;return e}setMouseIndex(e){this.setState({mouseIndex:e})}initMenu(){cancelAnimationFrame(this.rAF),this.setState({menuItems:[]});const{actions:e}=this.props,t=He.getMenuItems(e,!1);t.length>0&&this.setState(n=>({menuItems:He.sortActions(n.menuItems.concat(t))}))}handleKeyDown(e){const{menuItems:t}=this.state,n=this.getKeyboardIndex();let s=n;if(e.key==="Enter"||e.key===" "){n!=null&&n>=0&&n<t.length&&this.handleMenuItemClick(t[n],e);return}e.key==="Escape"?s=null:e.key==="ArrowUp"||e.key==="Tab"&&e.shiftKey===!0?s=He.getNextMenuItem(s??0,-1,t):(e.key==="ArrowDown"||e.key==="Tab"&&e.shiftKey===!1)&&(s=He.getNextMenuItem(s??0,1,t)),n!==s&&(s!==null?this.setKeyboardIndex(s):(this.closeMenu(),this.oldFocus instanceof HTMLElement&&this.oldFocus.focus()),e.preventDefault(),e.stopPropagation())}closeMenu(e=!1){const{closeMenu:t,onMenuClosed:n}=this.props;cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{t(e),n(this)})}handleCloseMenu(){this.closeMenu()}handleMenuItemClick(e,t){t.preventDefault(),t.stopPropagation(),e!=null&&(e.disabled===void 0||!e.disabled)&&e.action!=null&&(e.action(),this.closeMenu(!0))}handleMenuItemMouseMove(e){const{menuItems:t}=this.state,n=t.indexOf(e);this.setMouseIndex(n)}handleMouseLeave(){this.setMouseIndex(-1)}render(){const e=[],{"data-testid":t}=this.props,{keyboardIndex:n,menuItems:s,mouseIndex:i}=this.state;for(let a=0;a<s.length;a+=1){const r=s[a];a>0&&r.group!==s[a-1].group&&e.push(l.jsx("hr",{},`${a}.separator`));const c=l.jsx(Lh,{isKeyboardSelected:n===a,isMouseSelected:i===a,menuItem:r,closeMenu:this.handleCloseMenu,onMenuItemClick:this.handleMenuItemClick,onMenuItemMouseMove:this.handleMenuItemMouseMove,onMenuItemContextMenu:()=>!1},a);e.push(c)}const{menuStyle:o}=this.props;return l.jsx("div",{className:"context-menu-container",style:{...o},ref:this.container,onKeyDown:this.handleKeyDown,onMouseLeave:this.handleMouseLeave,role:"menuitem",tabIndex:0,"data-testid":t,children:e})}};const ff=gf;class Cf extends b.PureComponent{static defaultProps={isShown:null,onMenuClosed(){},onMenuOpened(){},options:{},popperOptions:{},popperClassName:"",menuStyle:{},"data-testid":void 0};constructor(e){super(e),this.handleClick=this.handleClick.bind(this),this.handleCloseMenu=this.handleCloseMenu.bind(this),this.handleExited=this.handleExited.bind(this),this.container=X.createRef(),this.parent=null,this.popper=X.createRef(),this.isOpen=!1}componentDidMount(){const{isShown:e}=this.props;e===null?this.container.current?.parentElement&&(this.parent=this.container.current.parentElement,this.parent.addEventListener("click",this.handleClick)):e&&this.openMenu()}componentDidUpdate(e){const{isShown:t}=this.props;e.isShown!==t&&(t!==null&&t?window.requestAnimationFrame(()=>{this.openMenu()}):this.closeMenu())}componentWillUnmount(){this.parent&&this.parent.removeEventListener("click",this.handleClick)}container;parent;popper;isOpen;closeMenu(){this.popper.current?.hide()}openMenu(){this.popper.current&&!this.isOpen&&(this.popper.current.show(),this.isOpen=!0)}scheduleUpdate(){this.popper.current?.scheduleUpdate()}handleClick(e){e.preventDefault(),e.stopPropagation(),this.openMenu()}handleCloseMenu(){this.closeMenu()}handleExited(){this.isOpen=!1;const{onMenuClosed:e}=this.props;e()}render(){const{actions:e,onMenuOpened:t,popperClassName:n,"data-testid":s}=this.props,{menuStyle:i}=this.props;let{options:o,popperOptions:a}=this.props;return a={placement:"bottom",...a},o={separateKeyboardMouse:!0,...o},l.jsx("div",{className:"menu-actions-listener",ref:this.container,"data-testid":s,children:l.jsx(ri,{ref:this.popper,options:a,className:$("menu-popper",n),onExited:this.handleExited,closeOnBlur:!0,interactive:!0,children:l.jsx(ff,{actions:e,closeMenu:this.handleCloseMenu,onMenuOpened:t,options:o,menuStyle:i})})})}}const Zn=Cf;function Ci(d,e,t,n,s){const i=n-t+1;return`${((parseInt(e,10)-d-t)%i+i)%i+t}`.padStart(s,"0")}function Sf(d,e,t){const{selectionStart:n}=d;return n===0?Ci(e,t,1900,2099,4):n===5?Ci(e,t,1,12,2):n===8?Ci(e,t,1,31,2):n===11?Ci(e,t,0,23,2):n===17||n===14?Ci(e,t,0,59,2):n===20||n===24||n===28?Ci(e,t,0,999,3):t}const bf=Z.module("DateTimeInput"),wf="[12][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])",vf="([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]\\.[0-9]{3}[0-9]{3}[0-9]{3}",Tf=`${wf} ${vf}`,ba="2022-01-01",$h=`${ba} 00:00:00.000000000`,Ef="YYYY-MM-DD HH:MM:SS.SSSSSSSSS";function qd(d){return d!=null&&d.length>=ba.length?`${d.substring(0,ba.length)}${d.substring(ba.length).replace(/\u2007/g,"0")}${$h.substring(d.length)}`:d}function al(d){const e=d.substring(0,23),t=d.substring(23,26),n=d.substring(26);return[e,t,n].filter(s=>s!=="").join("")}const Yd=d=>d.replace(/\u200B/g,""),yf=[al($h)],Ll=X.forwardRef((d,e)=>{const{className:t="",onChange:n=()=>{},defaultValue:s="",onFocus:i=()=>{},onBlur:o=()=>{},"data-testid":a}=d,[r,c]=b.useState(s.length>0?al(s):""),[h,u]=b.useState(),m=b.useCallback(g=>{bf.debug("handleChange",g),c(g),n(qd(Yd(g)))},[n]),p=b.useCallback(()=>{const g=Yd(r),C=qd(g);C!==g&&c(al(C)),o()},[r,o]);return l.jsx("div",{className:"d-flex flex-row align-items-center",children:l.jsx(pf,{ref:e,className:$(t),example:yf,getNextSegmentValue:Sf,onChange:m,onSelect:u,pattern:Tf,placeholder:Ef,selection:h,value:r,onFocus:i,onBlur:p,"data-testid":a})})});Ll.displayName="DateTimeInput";Ll.defaultProps={className:"",onChange:()=>{},defaultValue:"",onFocus:()=>{},onBlur:()=>{},"data-testid":void 0};const xf=Ll;class Rf extends b.PureComponent{static defaultProps={placeholder:"Search",className:"",matchCount:null,debounceMs:250,id:"","data-testid":void 0};constructor(e){super(e),this.searchInput=X.createRef(),this.handleChange=this.handleChange.bind(this),this.sendUpdate=Ye(this.sendUpdate.bind(this),e.debounceMs),this.state={value:e.value}}componentDidUpdate(e){const{value:t}=this.props;e.value!==t&&this.setState({value:t})}searchInput;focus(){this.searchInput.current?.focus()}handleChange(e){this.setState({value:e.target.value},this.sendUpdate)}sendUpdate(){const{onChange:e}=this.props,{value:t}=this.state;e(t)}render(){const{placeholder:e,className:t,matchCount:n,id:s,"data-testid":i}=this.props,{value:o}=this.state;return l.jsx(As,{value:o,placeholder:e,onChange:this.handleChange,className:t,matchCount:n,ref:this.searchInput,id:s,"data-testid":i})}}const If=Rf;const Df=Z.module("ItemListItem");class Pl extends b.Component{static defaultProps={children:null,isDraggable:!1,isFocused:!1,isSelected:!1,itemIndex:0,"data-testid":void 0,onBlur(){},onClick(){},onContextMenu(){},onDragStart(){},onDrag(){},onDragOver(){},onDragEnd(){},onDrop(){},onDoubleClick(){},onFocus(){},onMouseDown(){},onMouseMove(){},onMouseUp(){},style:{}};static handleKeyDown(){return Df.log("ItemListItem.handleKeyDown false"),!1}constructor(e){super(e),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleClick=this.handleClick.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.handleDragStart=this.handleDragStart.bind(this),this.handleDrag=this.handleDrag.bind(this),this.handleDragOver=this.handleDragOver.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleDrop=this.handleDrop.bind(this),this.handleDoubleClick=this.handleDoubleClick.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.itemRef=X.createRef()}itemRef;handleBlur(e){const{itemIndex:t,onBlur:n}=this.props;n(t,e)}handleFocus(e){const{itemIndex:t,onFocus:n}=this.props;n(t,e)}handleClick(e){const{itemIndex:t,onClick:n}=this.props;n(t,e)}handleContextMenu(e){const{itemIndex:t,onContextMenu:n}=this.props;n(t,e)}handleDragStart(e){const{itemIndex:t,onDragStart:n}=this.props;n(t,e)}handleDrag(e){const{itemIndex:t,onDrag:n}=this.props;n(t,e)}handleDragOver(e){e.preventDefault();const{itemIndex:t,onDragOver:n}=this.props;n(t,e)}handleDragEnd(e){const{itemIndex:t,onDragEnd:n}=this.props;n(t,e)}handleDrop(e){const{itemIndex:t,onDrop:n}=this.props;n(t,e)}handleDoubleClick(e){const{itemIndex:t,onDoubleClick:n}=this.props;n(t,e)}handleMouseMove(e){const{itemIndex:t,onMouseMove:n}=this.props;n(t,e)}handleMouseDown(e){const{itemIndex:t,onMouseDown:n}=this.props;n(t,e)}handleMouseUp(e){const{itemIndex:t,onMouseUp:n}=this.props;n(t,e)}render(){const{isDraggable:e,isFocused:t,isSelected:n,style:s,children:i,"data-testid":o}=this.props;return l.jsx("div",{className:$("item-list-item",{active:n},{"is-focused":t},{"is-draggable":e}),onKeyDown:Pl.handleKeyDown,onContextMenuCapture:this.handleContextMenu,onClick:this.handleClick,onDrag:this.handleDrag,onDragStart:this.handleDragStart,onDragOver:this.handleDragOver,onDragEnd:this.handleDragEnd,onDrop:this.handleDrop,onDoubleClick:this.handleDoubleClick,onMouseDown:this.handleMouseDown,onMouseMove:this.handleMouseMove,onMouseUp:this.handleMouseUp,tabIndex:-1,ref:this.itemRef,role:"listitem",style:s,onFocus:this.handleFocus,onBlur:this.handleBlur,draggable:e,"data-testid":o,children:i})}}const Ff=Pl;const Xd=Z.module("ItemList"),Zd=5;class Ht extends b.PureComponent{static CACHE_SIZE=1e3;static DEFAULT_ROW_HEIGHT=20;static DEFAULT_OVERSCAN=10;static defaultProps={offset:0,items:[],rowHeight:Ht.DEFAULT_ROW_HEIGHT,isDeselectOnClick:!0,isDoubleClickSelect:!1,isDragSelect:!0,isMultiSelect:!1,isStickyBottom:!1,disableSelect:!1,onFocusChange(){},onSelect(){},onSelectionChange(){},onViewportChange(){},overscanCount:Ht.DEFAULT_OVERSCAN,renderItem:Ht.renderItem,selectedRanges:[],focusSelector:".item-list-item","data-testid":void 0};static renderItem({item:e}){return l.jsx("div",{className:"item-list-item-content",children:e!=null&&(e.displayValue??e.value??`${e}`)})}constructor(e){super(e),this.handleItemBlur=this.handleItemBlur.bind(this),this.handleItemContextMenu=this.handleItemContextMenu.bind(this),this.handleItemFocus=this.handleItemFocus.bind(this),this.handleItemDoubleClick=this.handleItemDoubleClick.bind(this),this.handleItemMouseDown=this.handleItemMouseDown.bind(this),this.handleItemMouseMove=this.handleItemMouseMove.bind(this),this.handleItemMouseUp=this.handleItemMouseUp.bind(this),this.handleItemsRendered=this.handleItemsRendered.bind(this),this.handleWindowMouseUp=this.handleWindowMouseUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleScroll=this.handleScroll.bind(this),this.handleResize=this.handleResize.bind(this),this.renderInnerElement=this.renderInnerElement.bind(this),this.list=X.createRef(),this.listContainer=X.createRef();const{isStickyBottom:t,selectedRanges:n}=e;this.state={focusIndex:null,mouseDownIndex:null,selectedRanges:n,overscanStartIndex:0,height:null,isDragging:!1,isStuckToBottom:t,scrollOffset:null,mouseX:null,mouseY:null}}componentDidUpdate(e,t){const{selectedRanges:n,itemCount:s}=this.props,{focusIndex:i,isStuckToBottom:o,scrollOffset:a,height:r,selectedRanges:c}=this.state;if(o&&!this.isListAtBottom()&&s>0&&this.scrollToBottom(),(a!==t.scrollOffset||r!==t.height)&&this.sendViewportUpdate(),n!==e.selectedRanges&&n!==c)this.setSelectedRanges(n);else if(c!==t.selectedRanges){const{onSelectionChange:h}=this.props;h(c)}if(i!==t.focusIndex){const{onFocusChange:h}=this.props;h(i)}}componentWillUnmount(){window.removeEventListener("mouseup",this.handleWindowMouseUp)}list;listContainer;getItemSelected=pe((e,t)=>ln.isSelected(t,e),{max:Ht.CACHE_SIZE});getCachedItem=pe((e,t,n,s,i,o,a,r)=>{const c=o({item:n,itemIndex:e,isFocused:s,isSelected:i,style:a});return l.jsx(Ff,{onContextMenu:this.handleItemContextMenu,onDoubleClick:this.handleItemDoubleClick,onMouseDown:this.handleItemMouseDown,onFocus:this.handleItemFocus,onBlur:this.handleItemBlur,disableSelect:r,onMouseMove:this.handleItemMouseMove,onMouseUp:this.handleItemMouseUp,isFocused:s,isSelected:i,itemIndex:e,style:a,children:c},t)},{max:Ht.CACHE_SIZE});getOuterElement=pe(e=>{const t=X.forwardRef((n,s)=>l.jsx("div",{ref:s,tabIndex:-1,onKeyDown:e,role:"presentation",...n}));return t.displayName="ItemListOuterElement",t});getInnerElement=pe(()=>{const e=X.forwardRef((t,n)=>l.jsx("div",{className:"item-list-inner-element",ref:n,...t}));return e.displayName="ItemListInnerElement",e});getItemData=pe((e,t,n)=>({items:e,selectedRanges:t,renderItem:n}));focus(){this.listContainer.current?.focus()}restoreScrollPosition(){const{scrollOffset:e}=this.state;e!=null&&this.listContainer.current?.scrollTo(0,e)}getElement(e){if(this.listContainer.current==null)return null;const{focusSelector:t}=this.props,{overscanStartIndex:n}=this.state,s=this.listContainer.current.querySelectorAll(t),i=e-n;return s[i]}focusItem(e){const{disableSelect:t}=this.props;if(t)return;this.setState({focusIndex:e});const n=this.getElement(e);n instanceof HTMLElement&&n.focus()}scrollToItem(e){const t=this.getElement(e);t?.scrollIntoView({block:"center"})}handleItemContextMenu(e,t){const{selectedRanges:n}=this.state,i=ln.isSelected(n,e)||He.isModifierKeyDown(t);this.toggleSelect(e,t.shiftKey,i,!1)}handleItemDoubleClick(e,t){const{isDoubleClickSelect:n,onSelect:s}=this.props;n&&this.setState(({selectedRanges:i})=>({selectedRanges:ln.selectRange(i,[e,e])}),()=>{s(e,t)})}handleItemMouseDown(e,t){const{selectedRanges:n}=this.state;if(!(t.target instanceof HTMLElement&&["button","select","input","textarea"].indexOf(t.target.tagName.toLowerCase())!==-1)){if(t.button===2&&n.length===0){this.focusItem(e),this.selectItem(e);return}t.button!=null&&t.button!==0||(this.setState({mouseDownIndex:e,mouseX:t.clientX,mouseY:t.clientY}),window.addEventListener("mouseup",this.handleWindowMouseUp))}}handleItemBlur(e,t){Xd.debug2("item blur",e,t.currentTarget,t.relatedTarget),(!t.relatedTarget||this.listContainer.current&&t.relatedTarget instanceof HTMLElement&&!this.listContainer.current.contains(t.relatedTarget))&&this.setState({focusIndex:null})}handleItemFocus(e,t){Xd.debug2("item focus",e,t.target),this.setState(n=>{const{focusIndex:s}=n;return s!==e?{focusIndex:e}:null})}handleItemMouseMove(e,t){const{isDragSelect:n,isMultiSelect:s,disableSelect:i}=this.props,{mouseDownIndex:o,selectedRanges:a,mouseX:r,mouseY:c}=this.state;if(o==null||i)return;const h=Math.abs(t.clientX-(r??0)),u=Math.abs(t.clientY-(c??0));h>Zd&&u>Zd&&this.setState({isDragging:!0}),(n||o===e)&&(this.focusItem(e),s?(!n&&!this.getItemSelected(e,a)&&!He.isModifierKeyDown(t)&&this.deselectAll(),this.selectRange([Math.min(o,e),Math.max(o,e)])):this.toggleSelect(e,t.shiftKey,He.isModifierKeyDown(t),!1))}handleItemMouseUp(e,t){const{isDeselectOnClick:n,isDoubleClickSelect:s,onSelect:i}=this.props,{mouseDownIndex:o,isDragging:a}=this.state;if(!(t.target instanceof HTMLElement&&["button","select","input","textarea"].indexOf(t.target.tagName.toLowerCase())!==-1)){if(o===e&&!a){const r=t.shiftKey,c=He.isModifierKeyDown(t);this.focusItem(e),this.toggleSelect(e,r,c,n),!s&&!r&&!c&&i(e,t)}this.resetMouseState()}}handleItemsRendered({overscanStartIndex:e}){this.setState({overscanStartIndex:e})}handleResize({height:e}){this.setState({height:e})}handleMouseLeave(){this.setState({mouseDownIndex:null})}handleWindowMouseUp(){this.resetMouseState(),window.removeEventListener("mouseup",this.handleWindowMouseUp)}handleKeyDown(e){const{isMultiSelect:t,itemCount:n,onSelect:s}=this.props,{focusIndex:i}=this.state;let o=i;if(e.key==="Enter"||e.key===" "){!t&&o!=null&&this.setState({selectedRanges:[[o,o]]},()=>{o!=null&&s(o,e)});return}if(e.key==="ArrowUp")o!=null&&o>=0?o=Math.max(0,o-1):o=n-1;else if(e.key==="ArrowDown")o!=null&&o>=0?o=Math.min(o+1,n-1):o=0;else return;if(i!==o){e.stopPropagation(),e.preventDefault(),this.focusItem(o);const{selectedRanges:a}=this.state;if(e.shiftKey&&a.length>0){const r=a[a.length-1];this.selectRange([Math.min(o,r[0]),Math.max(o,r[1])])}else this.deselectAll(),o!==null?this.selectItem(o):this.listContainer.current?.focus();this.scrollIntoView(o)}}handleScroll({scrollUpdateWasRequested:e,scrollOffset:t}){this.setState(n=>{if(e)return{scrollOffset:t};const{isStickyBottom:s}=this.props,{height:i}=n;return{isStuckToBottom:s&&this.isListAtBottom({scrollOffset:t,height:i}),scrollOffset:t}})}resetMouseState(){this.setState({mouseDownIndex:null,isDragging:!1})}scrollToBottom(){const{itemCount:e}=this.props;this.list.current&&this.list.current.scrollToItem(e)}scrollIntoView(e){this.list.current&&this.list.current.scrollToItem(e)}toggleSelect(e,t,n,s=!0){const{isMultiSelect:i}=this.props,{selectedRanges:o}=this.state;if(i&&t&&o.length>0){const a=o[o.length-1];this.selectRange([Math.min(a[0],e),Math.max(e,a[1])])}else i&&o.length===1&&o[0][0]===e&&o[0][1]===e?s&&this.deselectItem(e):i&&n?this.getItemSelected(e,o)?s&&this.deselectItem(e):this.selectItem(e):(this.deselectAll(),this.selectItem(e))}deselectAll(){const{itemCount:e}=this.props;this.deselectRange([0,e])}deselectItem(e){this.deselectRange([e,e])}deselectRange(e){ln.validateRange(e),this.setState(({selectedRanges:t})=>({selectedRanges:ln.deselectRange(t,e)}))}selectItem(e){const{disableSelect:t}=this.props;t||this.selectRange([e,e])}selectRange(e){ln.validateRange(e),this.setState(({selectedRanges:t})=>({selectedRanges:ln.selectRange(t,e)}))}setSelectedRanges(e){this.setState({selectedRanges:e})}sendViewportUpdate(){const{scrollOffset:e,height:t}=this.state;if(e!=null&&t!=null){const{onViewportChange:n,rowHeight:s}=this.props,i=Math.floor(e/s),o=i+Math.ceil(t/s);n(i,o)}}isListAtBottom({scrollOffset:e,height:t}=this.state){if(t==null||e==null)return!1;const{itemCount:n,rowHeight:s}=this.props;return e+t>=n*s}renderInnerElement({index:e,style:t}){const{items:n,offset:s,renderItem:i,disableSelect:o}=this.props,{focusIndex:a,selectedRanges:r}=this.state;if(e<s||e>=s+n.length)return null;const c=n[e-s];return this.getCachedItem(e,e,c,e===a&&!o,this.getItemSelected(e,r),i,t,o)}render(){const{items:e,itemCount:t,overscanCount:n,renderItem:s,rowHeight:i,"data-testid":o}=this.props,{selectedRanges:a,isStuckToBottom:r}=this.state;return l.jsx(_m,{className:"item-list-auto-sizer",onResize:this.handleResize,children:({width:c,height:h})=>l.jsx(jm,{className:"item-list-scroll-pane",height:h,width:c,initialScrollOffset:r?t*i:0,itemCount:t,itemSize:i,itemData:this.getItemData(e,a,s),onScroll:this.handleScroll,onItemsRendered:this.handleItemsRendered,ref:this.list,outerElementType:this.getOuterElement(this.handleKeyDown),outerRef:this.listContainer,innerElementType:this.getInnerElement(),overscanCount:n,"data-testid":o,children:this.renderInnerElement})})}}class bs extends b.PureComponent{static DEFAULT_ROW_HEIGHT=30;static defaultProps={className:"",draggingItemClassName:"",offset:0,items:[],rowHeight:bs.DEFAULT_ROW_HEIGHT,isDeselectOnClick:!0,isDoubleClickSelect:!0,isDropDisabled:!1,isDragDisabled:!1,isMultiSelect:!1,isStickyBottom:!1,disableSelect:!1,style:null,onFocusChange(){},onSelect(){},onSelectionChange(){},onViewportChange(){},renderItem:bs.renderItem,selectedRanges:[],draggablePrefix:"draggable-item",droppableId:"droppable-item-list","data-testid":void 0};static renderHandle(){return l.jsxs("div",{children:[l.jsx(tt,{children:"Drag to re-order"}),l.jsx(J,{icon:Mo})]})}static renderBadge({text:e}){return e!=null&&e.length>0?l.jsx("span",{className:"number-badge",children:e}):null}static renderTextItem({text:e,badgeText:t="",className:n=""}){return l.jsxs("div",{className:$("item-list-item-content","draggable-item-list-item-content",n),children:[l.jsx("span",{className:"title",children:e}),bs.renderBadge({text:t}),bs.renderHandle()]})}static renderItem({item:e,isClone:t,selectedCount:n}){const s=e!=null?e.displayValue??e.value??`${e}`:"",i=t!==void 0&&t?`${n}`:"",o=t!==void 0&&t?"item-list-item-clone":"";return bs.renderTextItem({text:s,badgeText:i,className:o})}static getDraggableId(e,t){return`${e}/${t}`}static getDraggableIndex(e){const t=e.split("/").pop();return parseInt(t!==void 0?t:"",10)}constructor(e){super(e),this.handleSelectionChange=this.handleSelectionChange.bind(this),this.itemList=X.createRef(),this.state={selectedCount:0}}itemList;selectItem(e){this.itemList.current?.selectItem(e)}focusItem(e){this.itemList.current?.focusItem(e)}scrollToItem(e){this.itemList.current?.scrollToItem(e)}getCachedDraggableItem=pe((e,t,n,s,i,o,a,r)=>l.jsx(wl,{draggableId:bs.getDraggableId(e,s),index:s,isDragDisabled:a,children:c=>l.jsx("div",{role:"menuitem",className:"draggable-item-list-item",ref:c.innerRef,tabIndex:-1,...c.draggableProps,...c.dragHandleProps,children:t({item:n,itemIndex:s,isFocused:i,isSelected:o,style:r,isClone:!1})})},s),{max:Ht.CACHE_SIZE});handleSelectionChange(e){this.setState({selectedCount:ln.count(e)});const{onSelectionChange:t}=this.props;t(e)}getCachedRenderDraggableItem=pe((e,t,n)=>({item:s,itemIndex:i,isFocused:o,isSelected:a,style:r})=>this.getCachedDraggableItem(e,n,s,i,o,a,t,r),{max:1});getCachedRenderClone=pe((e,t,n,s)=>(i,o,a)=>{const{selectedCount:r}=this.state,{draggableProps:c,dragHandleProps:h,innerRef:u}=i,{index:m}=a.source,p=t[m-n];return l.jsx("div",{className:$("draggable-item-list-dragging-item-container",e),...c,...h,ref:u,children:l.jsx("div",{className:$("draggable-item-list-dragging-item",{"two-dragged":r===2},{"multiple-dragged":r>2}),children:s({item:p,itemIndex:m,isFocused:!1,isSelected:!0,style:{},isClone:!0,selectedCount:r})})})},{max:1});render(){const{className:e,draggablePrefix:t,draggingItemClassName:n,droppableId:s,isDoubleClickSelect:i,isDragDisabled:o,isDropDisabled:a,isMultiSelect:r,isStickyBottom:c,itemCount:h,items:u,offset:m,onFocusChange:p,onSelect:g,onViewportChange:C,renderItem:f,rowHeight:S,selectedRanges:v,style:w,"data-testid":T}=this.props;return l.jsx(Za,{isDropDisabled:a,droppableId:s,mode:"virtual",renderClone:this.getCachedRenderClone(n,u,m,f),"data-testid":T,children:(y,E)=>l.jsx("div",{role:"menu",className:$("draggable-item-list",e,{"is-drop-disabled":a,"is-drag-disabled":o,"is-dragging-from-this":E.draggingFromThisWith,"is-dragging-over":E.isDraggingOver,"is-dropping":E.draggingOverWith}),style:w,ref:y.innerRef,...y.droppableProps,children:l.jsx(Ht,{focusSelector:".draggable-item-list-item",isDoubleClickSelect:i,isDragSelect:!1,isMultiSelect:r,isStickyBottom:c,itemCount:h,items:u,onFocusChange:p,onSelect:g,onSelectionChange:this.handleSelectionChange,onViewportChange:C,offset:m,ref:this.itemList,renderItem:this.getCachedRenderDraggableItem(t,o,f),rowHeight:S,selectedRanges:v})})})}}const gn=bs;class Fa{static reorder(e,t,n,s){const i=e===n?Fa.adjustDestinationIndex(s,t):s,o=Fa.removeItems(e,t);return n.splice(i,0,...o),o}static removeItems(e,t){const n=[],s=t.map((i,o)=>({range:i,index:o})).sort((i,o)=>o.range[0]-i.range[0]);for(let i=0;i<s.length;i+=1){const{range:o,index:a}=s[i],[r,c]=o;n[a]=e.splice(r,c-r+1)}return Hm(n)}static adjustDestinationIndex(e,t){let n=e;for(let s=0;s<t.length;s+=1){const[i,o]=t[s];if(i>e)break;n-=Math.min(o,e-1)-i+1}return n}static startDragging(){document.documentElement.classList.add("drag-pointer-events-none")}static stopDragging(){document.documentElement.classList.remove("drag-pointer-events-none")}}const bn=Fa;function Wh({on:d,id:e,className:t,isInvalid:n,disabled:s=!1,onClick:i,"data-testid":o}){return l.jsx("button",{type:"button",className:$("btn","btn-switch",t,{active:d},{"is-invalid":n}),id:e,onClick:i,disabled:s,"data-testid":o,children:l.jsx("div",{className:"handle"})})}function Qd(d){return d.isOn!==void 0}function Nf({item:d,onSelect:e=()=>{},"data-testid":t}){const{icon:n,subtitle:s,title:i}=d,o=b.useMemo(()=>Qd(d)?()=>{d.onChange(!d.isOn)}:e,[d,e]);return l.jsxs("div",{className:"btn btn-navigation-menu-item","data-testid":`menu-item-${i}`,onClick:o,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&o()},tabIndex:0,role:"menuitem",children:[n!==void 0&&l.jsx("div",{className:"icon",children:l.jsx(J,{icon:n})}),l.jsx("div",{className:"title",children:i}),s!==void 0&&l.jsx("div",{className:"shortcut",children:s}),l.jsx("div",{className:"accessory","data-testid":t,children:Qd(d)?l.jsx(Wh,{on:d.isOn,onClick:a=>{a.stopPropagation(),o()}}):l.jsx(J,{icon:yh})})]})}function Gh({items:d,onSelect:e=()=>{},"data-testid":t}){return l.jsx("div",{className:"navigation-menu-view","data-testid":t,children:l.jsx("ul",{className:"navigation-menu-list",children:d.map((n,s)=>l.jsx("li",{children:l.jsx(Nf,{item:n,onSelect:()=>{e(s)}})},n.title))})})}function Jd({children:d,onBack:e,onClose:t,title:n,"data-testid":s}){return l.jsxs("div",{className:"navigation-page","data-testid":s,children:[l.jsxs("div",{className:"navigation-title-bar",children:[l.jsx("div",{className:"navigation-left-buttons",children:e!==void 0&&l.jsx(V,{kind:"ghost",className:"btn-back","data-testid":"btn-page-back",onClick:e,icon:yp,children:"Back"})}),l.jsx("div",{className:"navigation-title",children:n}),l.jsx("div",{className:"navigation-right-buttons",children:t!==void 0&&l.jsx(V,{kind:"ghost",className:"btn-close px-2 m-1","data-testid":"btn-page-close",onClick:t,icon:Ui,tooltip:"Close"})})]}),l.jsx("div",{className:"navigation-content",children:d})]})}function Mf({children:d,"data-testid":e}){const t=b.useMemo(()=>X.Children.toArray(d),[d]),n=ir(t),[s,i]=b.useState(t[t.length-1]),[o,a]=b.useState(null),[r,c]=b.useState(null);b.useEffect(function(){if(n===void 0||t===n)return;const p=t[t.length-1];t.length===n.length||n.length===0||o!==null||r!==null?o!==null&&p!==o?a(p):p!==r&&p!==s&&i(p):t.length>n.length?a(p):t.length<n.length&&(i(p),c(n[n.length-1]))},[t,n,o,r,s]);const h=b.useCallback(()=>{i(o),a(null)},[o]),u=b.useCallback(()=>{c(null)},[]);return l.jsxs("div",{className:"navigation-stack",children:[l.jsx("div",{className:"main-view","data-testid":e,children:s}),l.jsx(gt,{in:r!=null,timeout:We.transitionMidMs,classNames:"slide-right",onEntered:u,children:l.jsx(l.Fragment,{children:r!=null&&l.jsx("div",{className:"popping-view",children:r})})}),l.jsx(gt,{in:o!=null,timeout:We.transitionMidMs,classNames:"slide-left",onEntered:h,children:l.jsx(l.Fragment,{children:o!=null&&l.jsx("div",{className:"pushing-view",children:o})})})]})}function kf({children:d,disabled:e,value:t,"data-testid":n}){return l.jsx("option",{value:t,disabled:e,"data-testid":n,children:d})}function rr(d){const{children:e,disabled:t=!1,name:n,onChange:s,value:i="","data-testid":o}=d,[a]=b.useState(n??Pe());return l.jsx(l.Fragment,{children:X.Children.map(e,r=>r?X.cloneElement(r,{name:a,onChange:r.props.onChange??s,checked:i===r.props.value,disabled:r.props.disabled??t,"data-testid":o}):null)})}const _l=X.forwardRef((d,e)=>{const{checked:t,children:n,className:s="",disabled:i=!1,inputClassName:o="",isInvalid:a=!1,labelClassName:r="",name:c,onChange:h,value:u,"data-testid":m}=d,[p]=b.useState(Pe());return l.jsxs("div",{className:$("custom-control custom-radio",s),children:[l.jsx("input",{type:"radio",id:p,"data-testid":m,name:c,ref:e,className:$("custom-control-input",o,{"is-invalid":a}),checked:t,disabled:i,value:u,onChange:h}),l.jsx("label",{className:$("custom-control-label",r),htmlFor:p,children:n})]})});_l.displayName="RadioItem";_l.defaultProps={checked:void 0,className:"",disabled:!1,inputClassName:"",isInvalid:!1,labelClassName:"",name:void 0,onChange:void 0,"data-testid":void 0};const Qn=_l;function Of({children:d,onBlur:e,onChange:t,className:n,defaultValue:s,name:i,value:o,disabled:a,"data-testid":r}){const c=b.useCallback(h=>{t(h.target.value)},[t]);return l.jsx("select",{className:$("custom-select",n),onBlur:e,onChange:c,defaultValue:s,value:o,name:i,disabled:a,"data-testid":r,children:d})}class Af extends b.PureComponent{static defaultProps={disabled:!1,rowHeight:21,onBlur:()=>{},"data-testid":void 0};constructor(e){super(e),this.handleBlur=this.handleBlur.bind(this),this.handleScroll=this.handleScroll.bind(this),this.handleSelect=this.handleSelect.bind(this),this.list=X.createRef(),this.topRow=null,this.bottomRow=null}componentDidMount(){this.sendViewportUpdate()}componentDidUpdate(){this.sendViewportUpdate()}list;topRow;bottomRow;getCachedItem=pe((e,t,n,s,i,o,a)=>{const r={height:i},c=s??n;return l.jsx("li",{className:"value-list-item",style:r,tabIndex:-1,children:l.jsx(Xt,{checked:o,disabled:a,onChange:()=>this.handleSelect(e),children:c})},t)},{max:1e3});getCachedItems=pe((e,t,n,s)=>{const i=[];for(let o=0;o<e.length;o+=1){const a=e[o],{value:r,displayValue:c,isSelected:h}=a,u=n+o,m=u,p=this.getCachedItem(u,m,r,c,t,h,s);i.push(p)}return i},{max:1});handleBlur(e){if(!e.relatedTarget||this.list.current&&e.relatedTarget instanceof HTMLElement&&!this.list.current.contains(e.relatedTarget)){const{onBlur:t}=this.props;t?.(e)}}handleScroll(){this.sendViewportUpdate()}handleSelect(e){const{items:t,offset:n,onSelect:s}=this.props,i=e-n;if(i>=0&&i<t.length){const o=t[i],{value:a}=o;s(e,a)}else s(e,null)}sendViewportUpdate(){if(!this.list.current||this.list.current.clientHeight===0)return;const{onViewportChange:e,rowHeight:t}=this.props,n=this.list.current.scrollTop,s=n+this.list.current.clientHeight,i=Math.floor(n/t),o=Math.ceil(s/t);(this.topRow!==i||this.bottomRow!==o)&&(this.topRow=i,this.bottomRow=o,e(i,o))}getElement(e){return this.list.current==null?null:this.list.current.querySelectorAll(".value-list-item")[e]}scrollIntoView(e){this.getElement(e)?.scrollIntoView({block:"center"})}render(){const{className:e,disabled:t,isInvalid:n,items:s,itemCount:i,offset:o,rowHeight:a,"data-testid":r}=this.props,c=this.getCachedItems(s,a,o,t);return l.jsx("div",{className:$("select-value-list-scroll-pane h-100 w-100",{"is-invalid":n},e),onBlur:this.handleBlur,onScroll:this.handleScroll,ref:this.list,"data-testid":r,children:l.jsx("div",{className:"select-value-list",style:{height:i*a},children:l.jsx("ol",{className:"select-value-list-content",style:{position:"absolute",height:s.length*a,top:o*a,left:0},children:c})})})}}const Lf=Af,ec=Z.module("Shortcut");var ce=(d=>(d.CTRL="MODIFIER_CTRL",d.CMD="MODIFIER_CMD",d.ALT="MODIFIER_ALT",d.OPTION="MODIFIER_OPTION",d.SHIFT="MODIFIER_SHIFT",d))(ce||{}),ue=(d=>(d.A="A",d.B="B",d.C="C",d.D="D",d.E="E",d.F="F",d.G="G",d.H="H",d.I="I",d.J="J",d.K="K",d.L="L",d.M="M",d.N="N",d.O="O",d.P="P",d.Q="Q",d.R="R",d.S="S",d.T="T",d.U="U",d.V="V",d.W="W",d.X="X",d.Y="Y",d.Z="Z",d.ZERO="0",d.ONE="1",d.TWO="2",d.THREE="3",d.FOUR="4",d.FIVE="5",d.SIX="6",d.SEVEN="7",d.EIGHT="8",d.NINE="9",d.BACKSPACE="Backspace",d.ESCAPE="Escape",d.ENTER="Enter",d.DELETE="Delete",d.SLASH="/",d.QUESTION_MARK="?",d.BACKSLASH="\\",d.PIPE="|",d.MINUS="-",d.UNDERSCORE="_",d.EQUALS="=",d.PLUS="+",d.BACKTICK="`",d.TILDE="~",d.COMMA=",",d.LEFT_CHEVRON="<",d.PERIOD=".",d.RIGHT_CHEVRON=">",d.SEMICOLON=";",d.COLON=":",d.SINGLE_QUOTE="'",d.DOUBLE_QUOTE='"',d.LEFT_BRACKET="[",d.RIGHT_BRACKET="]",d.LEFT_CURLY="{",d.RIGHT_CURLY="}",d.F1="F1",d.F2="F2",d.F3="F3",d.F4="F4",d.F5="F5",d.F6="F6",d.F7="F7",d.F8="F8",d.F9="F9",d.F10="F10",d.F11="F11",d.F12="F12",d))(ue||{});const Pf=new Set(["Enter","Delete","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]);class ke extends vl{id;name;tooltip;isEditable;defaultKeyState;keyState;static NULL_KEY_STATE={metaKey:!1,shiftKey:!1,altKey:!1,ctrlKey:!1,keyValue:null};static isAllowedKey(e){return Object.values(ue).includes(e)}static isValidKeyState(e){const{keyValue:t}=e;return t===null?!0:!ke.isMacPlatform&&e.metaKey||!ke.isAllowedKey(t)?!1:!(!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey)||Pf.has(t)}static isMacPlatform=He.isMacPlatform();static createKeyState(e){const t={altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1,keyValue:e[e.length-1]};return e.forEach(n=>{switch(n){case"MODIFIER_CTRL":t.ctrlKey=!0;break;case"MODIFIER_ALT":case"MODIFIER_OPTION":t.altKey=!0;break;case"MODIFIER_CMD":t.metaKey=!0;break;case"MODIFIER_SHIFT":t.shiftKey=!0;break}}),t}static getKeyStateFromEvent(e){const{key:t,keyCode:n}=e;let s="";return t==="Shift"||t==="Meta"||t==="Control"||t==="Alt"?s="":!ke.isAllowedKey(t)&&ke.isAllowedKey(String.fromCharCode(n))?s=String.fromCharCode(n):s=t,{keyValue:s,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey}}static getWindowsDisplayText(e){let t="";return e.ctrlKey&&(t+="Ctrl+"),e.altKey&&(t+="Alt+"),e.shiftKey&&(t+="Shift+"),e.keyValue==="Escape"?t+="Esc":e.keyValue!==null&&(t+=e.keyValue),t}static getMacDisplayText(e){let t="";switch(e.ctrlKey&&(t+="⌃"),e.altKey&&(t+="⌥"),e.shiftKey&&(t+="⇧"),e.metaKey&&(t+="⌘"),e.keyValue){case"Enter":t+="⏎";break;case"Escape":t+="⎋";break;case"Backspace":t+="⌫";break;case"Delete":t+="⌦";break;case null:break;default:t+=e.keyValue}return t}static doKeyStatesMatch(e,t){return e.keyValue?.toUpperCase()===t.keyValue?.toUpperCase()&&e.altKey===t.altKey&&e.ctrlKey===t.ctrlKey&&e.metaKey===t.metaKey&&e.shiftKey===t.shiftKey}static getDisplayText(e){return e.keyValue===null?"":ke.isMacPlatform?ke.getMacDisplayText(e):ke.getWindowsDisplayText(e)}constructor({id:e,shortcut:t,macShortcut:n,isEditable:s=!0,name:i,tooltip:o}){super(),this.id=e,this.name=i,this.tooltip=o,this.isEditable=s;const r=ke.isMacPlatform?n:t;this.defaultKeyState=ke.createKeyState(r),this.keyState=this.defaultKeyState}getDisplayText(){return ke.getDisplayText(this.keyState)}getKeyState(){return this.keyState}setKeyState(e){ke.isValidKeyState(e)?(ec.debug2(`Shortcut ${this.id} updated to ${JSON.stringify(e)}`),this.keyState=e,this.dispatchEvent(new Ve("onUpdate",{detail:this}))):ec.debug2(`Shortcut ${this.id} tried to update to invalid keyState ${JSON.stringify(e)}`)}getDefaultKeyState(){return this.defaultKeyState}isDefault(){return ke.doKeyStatesMatch(this.getDefaultKeyState(),this.getKeyState())}setToNull(){this.setKeyState(ke.NULL_KEY_STATE)}isNull(){return ke.doKeyStatesMatch(this.keyState,ke.NULL_KEY_STATE)}setToDefault(){this.setKeyState(this.defaultKeyState)}matchesKeyState(e){return ke.doKeyStatesMatch(e,this.keyState)}matchesEvent(e){return this.matchesKeyState(ke.getKeyStateFromEvent(e))}}const tc=Z.module("ShortcutRegistry");class _f extends vl{shortcutMap=new Map;shortcutsByCategory=new Map;createAndAdd(e){const t=new ke(e);return this.add(t)}add(e){const t=this.shortcutMap.get(e.id);if(t)return tc.warn(`Skipping attempt to add duplicate shortcut ID to registry: ${e.id}`),t;tc.debug2(`Adding shortcut to registry: ${e.id}`),e.addEventListener("onUpdate",({detail:s})=>this.dispatchEvent(new Ve("onUpdate",{detail:s})));const n=e.id.split(".")[0];return this.shortcutMap.set(e.id,e),this.shortcutsByCategory.has(n)?this.shortcutsByCategory.get(n)?.push(e):this.shortcutsByCategory.set(n,[e]),e}get(e){return this.shortcutMap.get(e)}getConflictingShortcuts(e){return Array.from(this.shortcutMap.values()).filter(t=>!t.isNull()&&t.matchesKeyState(e))}}const jf=Object.freeze(new _f),Fe=jf,Hf={COPY:Fe.createAndAdd({id:"GLOBAL.COPY",name:"Copy",shortcut:[ce.CTRL,ue.C],macShortcut:[ce.CMD,ue.C],isEditable:!1}),PASTE:Fe.createAndAdd({id:"GLOBAL.PASTE",name:"Paste",shortcut:[ce.CTRL,ue.V],macShortcut:[ce.CMD,ue.V],isEditable:!1}),SAVE:Fe.createAndAdd({id:"GLOBAL.SAVE",name:"Save",shortcut:[ce.CTRL,ue.S],macShortcut:[ce.CMD,ue.S],isEditable:!1}),SELECT_ALL:Fe.createAndAdd({id:"GLOBAL.SELECT_ALL",name:"Select All",shortcut:[ce.CTRL,ue.A],macShortcut:[ce.CMD,ue.A],isEditable:!1}),LINKER:Fe.createAndAdd({id:"GLOBAL.LINKER",name:"Linker",shortcut:[ce.CTRL,ue.L],macShortcut:[ce.CMD,ue.L]}),LINKER_CLOSE:Fe.createAndAdd({id:"GLOBAL.LINKER_CLOSE",name:"Close Linker Overlay",shortcut:[ue.ESCAPE],macShortcut:[ue.ESCAPE],isEditable:!1})},es=Hf;const jl=X.forwardRef((d,e)=>{const{children:t,className:n,disabled:s,id:i,isLinked:o,isLinkedSource:a,isInvalid:r,onClick:c,onMouseEnter:h,onMouseLeave:u,style:m,"data-testid":p}=d;return l.jsxs("button",{ref:e,type:"button",className:$("btn-socketed",{"btn-socketed-linked":o!==void 0&&o||a},{"btn-socketed-linked-source":a},{"is-invalid":r},n),id:i,onClick:c,onMouseEnter:h,onMouseLeave:u,style:m,disabled:s,"data-testid":p,children:[t,l.jsx(J,{icon:yl,className:"linked btn-socketed-icon",transform:"down-1"}),l.jsx(J,{icon:xp,className:"is-invalid btn-socketed-icon"})]})});jl.displayName="SocketedButton";jl.defaultProps={children:void 0,className:"",disabled:!1,id:void 0,isLinked:!1,isLinkedSource:!1,isInvalid:!1,onClick:void 0,onMouseEnter:void 0,onMouseLeave:void 0,style:void 0,"data-testid":void 0};const zh=jl,{dh:x}=globalThis,Hl=D.shape({name:D.string.isRequired,type:D.string.isRequired,description:D.string,constituentType:D.string}),Bf=D.shape({not:D.func.isRequired,and:D.func.isRequired,or:D.func.isRequired});D.shape({asc:D.func.isRequired,desc:D.func.isRequired,abs:D.func.isRequired,column:Hl.isRequired,direction:D.string.isRequired,isAbs:D.bool.isRequired});D.shape({columns:D.arrayOf(Hl).isRequired,customColumns:D.arrayOf(D.string).isRequired,filter:D.arrayOf(Bf),addEventListener:D.func.isRequired,removeEventListener:D.func.isRequired,size:D.number.isRequired,sort:D.arrayOf(D.any),copy:D.func.isRequired,applyFilter:D.func.isRequired,applySort:D.func.isRequired,applyCustomColumns:D.func.isRequired,description:D.string});D.shape({columns:D.arrayOf(Hl),filter:D.arrayOf(D.any),isExpanded:D.func.isRequired,saveExpandedState:D.func.isRequired,addEventListener:D.func.isRequired,removeEventListener:D.func.isRequired,size:D.number.isRequired,sort:D.arrayOf(D.any),applyFilter:D.func.isRequired,applySort:D.func.isRequired});const Ar=D.shape({name:D.string.isRequired,type:D.string.isRequired});D.shape({created:D.arrayOf(Ar).isRequired,updated:D.arrayOf(Ar).isRequired,removed:D.arrayOf(Ar).isRequired});D.shape({groupingColumns:D.arrayOf(D.string),aggregations:D.shape({}),includeConstituents:D.bool,includeOriginalColumns:D.bool,includeDescriptions:D.bool});D.shape({addEventListener:D.func.isRequired,removeEventListener:D.func.isRequired,onLogMessage:D.func,getTable:D.func.isRequired,runCode:D.func.isRequired});function Kh({type:d}){switch(d){case x.VariableType.TABLE:case x.VariableType.TABLEMAP:case x.VariableType.TREETABLE:case x.VariableType.HIERARCHICALTABLE:return l.jsx(J,{icon:xl});case x.VariableType.FIGURE:return l.jsx(J,{icon:Rh});case x.VariableType.PANDAS:return l.jsx(J,{icon:Rp});default:return l.jsx(J,{icon:sl})}}class Vf extends b.Component{constructor(e){super(e),this.container=null}componentDidMount(){this.colorize()}container;colorize(){const{children:e}=this.props;this.container&&e!=null&&Yn.colorizeElement(this.container,{theme:"dh-dark"})}render(){const{children:e,language:t}=this.props;return l.jsx("div",{children:l.jsx("div",{"data-lang":t,ref:n=>{this.container=n},style:{pointerEvents:"none"},children:e})})}}const lr=Vf;class Uf{static get LANGUAGE_MAP(){return new Map([["python","Python"],["groovy","Groovy"],["scala","Scala"]])}}const qh=Uf;class Na{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)?[]:Bm.parse(e).filter(t=>!this.hasComment(t)).map(t=>this.hasPattern(t)?t.pattern:this.hasOp(t)?t.op:`${t}`)}static formatTimestamp(e){if(e==null||!(e instanceof Date))return null;const t=`${e.getHours()}`.padStart(2,"0"),n=`${e.getMinutes()}`.padStart(2,"0"),s=`${e.getSeconds()}`.padStart(2,"0"),i=`${e.getMilliseconds()}`.padStart(3,"0");return`${t}:${n}:${s}.${i}`}static isTableType(e){return e===x.VariableType.TABLE||e===x.VariableType.TREETABLE||e===x.VariableType.HIERARCHICALTABLE}static isWidgetType(e){return e===x.VariableType.FIGURE||e===x.VariableType.OTHERWIDGET||e===x.VariableType.PANDAS}static isOpenableType(e){return Na.isTableType(e)||Na.isWidgetType(e)}static isFigureType(e){return e===x.VariableType.FIGURE}static isPandas(e){return e===x.VariableType.PANDAS}}const rl=Na;function Yh({children:d}){return l.jsxs("div",{className:"console-history-item-result",children:[l.jsx("div",{className:"console-history-gutter",children:"-"}),l.jsx("div",{className:"console-history-content",children:d})]})}Yh.propTypes={children:D.node.isRequired};class $f extends b.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 l.jsx("div",{className:$("console-history-result-in-progress",{disabled:e}),children:l.jsxs("span",{className:"badge",children:[l.jsx(Ln,{})," Running... ",Wi.formatElapsedTime(n)," ",l.jsx(V,{className:"console-history-result-in-progress-cancel",kind:"ghost",icon:Ui,tooltip:"Cancel",onClick:t,disabled:e})]})})}}const Wf=$f;class Ma extends b.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)>=Ma.mouseDragThreshold||Math.abs(e.clientY-this.mouseY)>=Ma.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;M(n);const s=n.indexOf(`
|
|
3
3
|
`),i=s>-1;let o=n;i&&(o=n.slice(0,s));const a=n.slice(s),r=t?"error-btn-link error-btn-link--active":"error-btn-link";return l.jsxs("div",{className:$("error-message",{expanded:e}),children:[i&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"error-gutter",children:l.jsx("button",{type:"button",onClick:this.handleToggleError,className:r,tabIndex:-1,children:l.jsx(J,{icon:e?kn:Ih,transform:"left-3"})})}),l.jsxs("div",{className:"error-content",children:[l.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?a:""]})]}),!i&&l.jsx("div",{className:"error-content",children:l.jsx("div",{className:"console-error-text",children:o})})]},"error")}}const Gf=Ma;const nc=Z.module("ConsoleHistoryItem");class zf extends b.PureComponent{static defaultProps={disabled:!1};constructor(e){super(e),this.handleCancelClick=this.handleCancelClick.bind(this),this.handleObjectClick=this.handleObjectClick.bind(this)}handleObjectClick(e){nc.debug("handleObjectClick",e);const{openObject:t}=this.props;t(e)}handleCancelClick(){const{item:e}=this.props;e!=null&&e.cancelResult&&(nc.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=l.jsxs("div",{className:"console-history-item-command",children:[l.jsx("div",{className:"console-history-gutter",children:">"}),l.jsx("div",{className:"console-history-content",children:l.jsx(lr,{language:n,children:t.command})})]}));const a=[];let r=!1;if(i){const{error:h,message:u,changes:m}=i;if(m){const{created:p,updated:g}=m;[...p,...g].forEach(C=>{r=!0;const{title:f}=C,S=`${f}`,v=e===void 0||e||(s??[]).indexOf(S)>=0,w=l.jsx(V,{kind:"primary",onClick:()=>this.handleObjectClick(C),className:"btn-console-object",disabled:v,icon:l.jsx(Kh,{type:C.type}),children:f},S);a.push(w)})}if(h!=null&&t.command==null){let p=`${h.message??h}`;p||(p=h);const g=l.jsx(Gf,{message:p},"result-error");a.push(g)}if(u!==void 0&&u!==""){const p=l.jsx("div",{className:"log-message",children:u},"log-message");a.push(p)}}else{r=!0;const h=l.jsx(Wf,{onCancelClick:this.handleCancelClick,disabled:e},"in_progress");a.push(h)}let c=null;return a.length>0&&(c=l.jsx(Yh,{children:a})),l.jsxs("div",{className:$("console-command-result",{"console-result-buttons":r}),children:[o,c]})}}const Kf=zf;class Bl extends b.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 a=t[o],r=l.jsx(Kf,{disabled:e,item:a,openObject:s,language:n},Bl.itemKey(o,a));i.push(r)}return l.jsx("div",{className:"container-fluid console-history",children:i})}}const qf=Bl,Yf={name:"Console",CLEAR:Fe.createAndAdd({id:"CONSOLE.CLEAR",name:"Clear",shortcut:[ce.CTRL,ue.L],macShortcut:[ce.CTRL,ue.C]}),FOCUS_HISTORY:Fe.createAndAdd({id:"CONSOLE.FOCUS_HISTORY",name:"Focus History",shortcut:[ce.CTRL,ue.H],macShortcut:[ce.CTRL,ce.OPTION,ue.H]})},Xf={name:"Command History",FOCUS_HISTORY:Fe.createAndAdd({id:"COMMAND_HISTORY.FOCUS_HISTORY",name:"Focus History Search",shortcut:[ce.CTRL,ue.H],macShortcut:[ce.CTRL,ce.OPTION,ue.H]}),SEND_TO_CONSOLE:Fe.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_CONSOLE",name:"Send to Console",shortcut:[ue.ENTER],macShortcut:[ue.ENTER]}),SEND_TO_NOTEBOOK:Fe.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_NOTEBOOK",name:"Send to Notebook",shortcut:[ce.CTRL,ue.ENTER],macShortcut:[ce.CMD,ue.ENTER]}),RUN:Fe.createAndAdd({id:"COMMAND_HISTORY.RUN",name:"Run",shortcut:[ce.ALT,ue.R],macShortcut:[ce.OPTION,ue.R]})},Zf={name:"Notebook",RUN:Fe.createAndAdd({id:"NOTEBOOK.RUN",name:"Run",shortcut:[ce.ALT,ue.R],macShortcut:[ce.OPTION,ue.R]}),RUN_SELECTED:Fe.createAndAdd({id:"NOTEBOOK.RUN_SELECTED",name:"Run Selected",shortcut:[ce.ALT,ce.SHIFT,ue.R],macShortcut:[ce.OPTION,ce.SHIFT,ue.R]}),FIND:Fe.createAndAdd({id:"NOTEBOOK.FIND",name:"Find",shortcut:[ce.CTRL,ue.F],macShortcut:[ce.CMD,ue.F],isEditable:!1}),MINIMAP:Fe.createAndAdd({id:"NOTEBOOK.MINIMAP",name:"Show Minimap",shortcut:[ce.ALT,ue.M],macShortcut:[ce.OPTION,ue.M]}),WORDWRAP:Fe.createAndAdd({id:"NOTEBOOK.WORDWRAP",name:"Word Wrap",shortcut:[ce.ALT,ue.Z],macShortcut:[ce.OPTION,ue.Z]})},Qf={CONSOLE:Yf,COMMAND_HISTORY:Xf,NOTEBOOK:Zf},Nt=Qf,mt=Object.freeze({FATAL:"FATAL",STDERR:"STDERR",ERROR:"ERROR",WARN:"WARN",STDOUT:"STDOUT",INFO:"INFO",DEBUG:"DEBUG",TRACE:"TRACE"}),Jf="#2d2a2e",eC="#fcfcfa",tC="#fcd65b",nC="#b2b1b2",sC="#9edc6f",iC="#76d9e4",oC="#f95d84",aC="#aa9af4",rC="#f95d84",lC="#fcfcfa",dC="#7c7b7c",Se={"error-foreground":"#f95d84",background:Jf,foreground:eC,"line-height":"19px",string:tC,"string-delim":"#929192",delimiter:nC,predefined:sC,keyword:iC,storage:oC,number:aC,operator:rC,identifier:lC,"namespace-identifier":"#f95d84","identifier-js":"#fcd65b",comment:dC,"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"},cC="python",hC={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/}}},uC={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"]]}},mC={id:cC,conf:hC,language:uC},pC=mC,gC="groovy",fC={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/}}},CC={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"]]}},SC={id:gC,conf:fC,language:CC},bC=SC,wC="scala",vC={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>))/}}},TC={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"]]}},EC={id:wC,conf:vC,language:TC},yC=EC,xC="deephavenDb",RC={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/}}},IC={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"]]}},DC={id:xC,conf:RC,language:IC},FC=DC,NC="log",MC={},kC={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"}]]}},OC={id:NC,conf:MC,language:kC},AC=OC,yn=Z.module("MonacoUtils");class In{static init({getWorker:e}={}){yn.debug("Initializing Monaco..."),e!==void 0&&In.registerGetWorker(e);const{registerLanguages:t,removeHashtag:n}=In,s=[{token:"",foreground:n(Se.foreground)},{token:"string",foreground:n(Se.string)},{token:"string.delim",foreground:n(Se["string-delim"])},{token:"keyword",foreground:n(Se.keyword)},{token:"identifier.js",foreground:n(Se["identifier-js"])},{token:"delimiter",foreground:n(Se.delimiter)},{token:"comment",foreground:n(Se.comment)},{token:"number",foreground:n(Se.number)},{token:"storage",foreground:n(Se.storage)},{token:"identifier",foreground:n(Se.identifier)},{token:"namespace.identifier",foreground:n(Se["namespace-identifier"])},{token:"operator",foreground:n(Se.operator)},{token:"predefined",foreground:n(Se.predefined)},{token:"error.log",foreground:Se["log-error"].substring(1)},{token:"warn.log",foreground:n(Se["log-warn"])},{token:"info.log",foreground:n(Se["log-info"])},{token:"stdout.log",foreground:n(Se["log-stdout"])},{token:"trace.log",foreground:n(Se["log-trace"])},{token:"debug.log",foreground:n(Se["log-debug"])},{token:"date.log",foreground:n(Se["log-date"])}],i={errorForeground:Se["error-foreground"],"inputOption.activeBorder":Se["input-option-active-border"],"editor.background":Se.background,"editor.foreground":Se.foreground,"editor.lineHighlightBackground":Se["editor-line-highlight-bg"],"editorLineNumber.foreground":Se["editor-line-number-foreground"],"editor.selectionBackground":Se["editor-selection-background"],"editor.findMatchBackground":Se["editor-find-match-background"],"editor.findMatchHighlightBackground":Se["editor-find-match-highlight-background"],"editorSuggestWidget.background":Se["editor-suggest-widget-background"],"editorSuggestWidget.border":Se["editor-suggest-widget-border"],"editorSuggestWidget.foreground":Se["editor-suggest-widget-foreground"],"editorSuggestWidget.selectedBackground":Se["editor-suggest-widget-selected-background"],"editorSuggestWidget.highlightForeground":Se["editor-suggest-widget-highlightForeground"],"list.hoverBackground":Se["list-hover-background"],"dropdown.background":Se["context-menu-background"],"dropdown.foreground":Se["context-menu-foreground"],"menu.selectionBackground":Se["menu-selection-background"],"list.focusBackground":Se["menu-selection-background"],"editorWidget.background":Se["editor-widget-background"],"inputOption.activeBackground":Se["input-option-active-background"],"inputOption.activeForeground":Se["input-option-active-foreground"],focusBorder:Se["focus-border"],"input.background":Se["input-background"],"input.foreground":Se["input-foreground"],"input.border":Se["input-border"]};Yn.defineTheme("dh-dark",{base:"vs-dark",inherit:!0,rules:s,colors:i}),yn.debug2("monaco theme: ",Se),Yn.setTheme("dh-dark"),t([FC,pC,bC,AC,yC]),yn.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);wi.getLanguages().filter(({id:n})=>t.includes(n)).forEach(n=>{const s=n;yn.debug2("Overriding default language loader:",s.id)}),e.forEach(n=>{In.registerLanguage(n)})}static registerLanguage(e){yn.debug2("Registering language: ",e.id),wi.register(e),wi.onLanguage(e.id,()=>{wi.setLanguageConfiguration(e.id,e.conf),wi.setMonarchTokensProvider(e.id,e.language)})}static setEOL(e,t=Yn.EndOfLineSequence.LF){e.getModel()?.setEOL(t)}static openDocument(e,t){const n=e.getModel();M(n);const s={textDocument:{uri:`${n.uri}`,languageId:n.getLanguageId(),version:n.getVersionId(),text:n.getValue()}};return yn.debug2("didOpenDocumentParams: ",s),t.openDocument(s),e.onDidChangeModelContent(o=>{const{changes:a,versionId:r}=o,c=[];for(let h=0;h<a.length;h+=1){const u=a[h],{range:m,rangeLength:p,text:g}=u,C={range:{start:{line:m.startLineNumber-1,character:m.startColumn-1},end:{line:m.endLineNumber-1,character:m.endColumn-1}},rangeLength:p,text:g};c.push(C)}if(c.length>0){const h={textDocument:{version:r,uri:`${n.uri}`},contentChanges:c};yn.debug2("didChangeDocumentParams",h),t.changeDocument(h)}})}static closeDocument(e,t){const n=e.getModel();M(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();M(o);const a=o.getValueInRange(t.range);(n.test(a)||s.test(a)||i.test(a))&&o.applyEdits([{range:t.range,text:a.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=>{In.isMacPlatform()&&n.mac===""||!In.isMacPlatform()&&n.windows===""||In.removeKeybinding(e,In.isMacPlatform()?n.mac:n.windows)})}catch(n){yn.error(n)}}static removeKeybinding(e,t){if(t===void 0)return;const n=e._standaloneKeybindingService._getResolver()._map.get(t);n!=null?n.forEach(s=>{yn.debug2(`Removing Monaco keybinding ${t} for ${s.command}`),e._standaloneKeybindingService.addDynamicKeybinding(`-${s.command}`,null,()=>{})}):yn.warn(`Did not find any keybindings to remove for ${t}`)}static getMonacoKeyCodeFromShortcut(e){const{keyState:t}=e,{keyValue:n}=t;return n===null?0:In.isMacPlatform()?(t.metaKey?rn.CtrlCmd:0)|(t.shiftKey?rn.Shift:0)|(t.altKey?rn.Alt:0)|(t.ctrlKey?rn.WinCtrl:0)|Ld.fromString(n):(t.ctrlKey?rn.CtrlCmd:0)|(t.shiftKey?rn.Shift:0)|(t.altKey?rn.Alt:0)|(t.metaKey?rn.WinCtrl:0)|Ld.fromString(n)}}const zt=In,sc=Z.module("MonacoCompletionProvider");class LC extends b.PureComponent{constructor(e){super(e),this.handleCompletionRequest=this.handleCompletionRequest.bind(this)}componentDidMount(){const{language:e}=this.props;this.registeredCompletionProvider=wi.registerCompletionItemProvider(e??"",{provideCompletionItems:this.handleCompletionRequest,triggerCharacters:['"',".","'","(","[","{",","]})}componentWillUnmount(){this.registeredCompletionProvider?.dispose()}registeredCompletionProvider;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:{line:t.lineNumber-1,character:t.column-1},context:n},a=i.getCompletionItems(o);return sc.debug("Completion items received: ",o,a),a.then(c=>({incomplete:!0,suggestions:c.map(u=>{const{label:m,kind:p,detail:g,documentation:C,sortText:f,filterText:S,textEdit:v,insertTextFormat:w}=u,{start:T,end:y}=v.range,E={startLineNumber:T.line+1,startColumn:T.character+1,endLineNumber:y.line+1,endColumn:y.character+1};return{label:m,kind:p,detail:g,documentation:C,sortText:f,filterText:S,insertText:v.text,insertTextRules:w===2?4:w,range:E}})})).catch(c=>(sc.error("There was an error retrieving completion items",c),{suggestions:[]}))}render(){return null}}const Xh=LC;const Lr=Z.module("ConsoleInput"),wa=parseInt(Se["line-height"],10),Zh=6,Qh=6,PC=wa+Zh+Qh,Pr=100;class Vl extends b.PureComponent{static defaultProps={maxHeight:wa*10,scope:null,disabled:!1};static INPUT_CLASS_NAME="console-input";constructor(e){super(e),this.handleWindowResize=this.handleWindowResize.bind(this),this.commandContainer=X.createRef(),this.commandHistoryIndex=null,this.timestamp=Date.now(),this.bufferIndex=0,this.history=[],this.modifiedCommands=new Map,this.state={commandEditorHeight:wa,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&&(Lr.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:wa,lineDecorationsWidth:3,lineNumbers:"off",minimap:{enabled:!1},renderLineHighlight:"none",scrollBeyondLastLine:!1,scrollbar:{arrowSize:0,horizontal:"hidden",horizontalScrollbarSize:0},padding:{top:Zh,bottom:Qh},tabCompletion:"on",value:"",wordWrap:"on"},s=this.commandContainer.current;M(s),this.commandEditor=Yn.create(s,n),zt.setEOL(this.commandEditor),zt.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:a}=this,r=o?.getPosition();M(r);const{lineNumber:c}=r,h=o?.getModel();if(i.code==="ArrowUp"&&!this.isSuggestionMenuPopulated()&&c===1){a!=null?this.loadCommand(a+1):this.loadCommand(0),this.focusStart(),i.stopPropagation(),i.preventDefault();return}if(i.code==="ArrowDown"&&!this.isSuggestionMenuPopulated()&&c===h?.getLineCount()){a!=null&&a>0?this.loadCommand(a-1):this.loadCommand(null),this.focusEnd(),i.stopPropagation(),i.preventDefault();return}if(!i.altKey&&!i.shiftKey&&!i.metaKey)if(i.keyCode===xs.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===xs.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(rn.CtrlCmd|xs.KeyF,()=>{}),zt.removeConflictingKeybindings(this.commandEditor),zt.registerPasteHandler(this.commandEditor),this.commandEditor.focus(),this.updateDimensions(),this.setState({model:this.commandEditor.getModel()})}destroyCommandEditor(){const{session:e}=this.props;this.commandEditor&&(zt.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();M(e);const t=e.getLineLength(1)+1,n=this.commandEditor?.getTopForPosition(1,t);M(n),this.commandEditor?.setPosition({lineNumber:1,column:t}),this.commandEditor?.setScrollTop(n),this.commandEditor?.focus()}focusEnd(){const e=this.commandEditor?.getModel();M(e);const t=e.getLineCount(),n=e.getLineLength(t)+1,s=this.commandEditor?.getTopForPosition(t,n);M(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-Pr&&this.loadMoreHistory()}async loadMoreHistory(){try{if(this.loadingPromise!=null||this.bufferIndex==null)return;const{commandHistoryStorage:e,language:t,scope:n}=this.props;this.loadingPromise=ve.makeCancelable(e.getTable(t,n??"",this.timestamp),o=>o.close());const s=await this.loadingPromise;s.setReversed(!0),s.setViewport({top:this.bufferIndex,bottom:this.bufferIndex+Pr-1}),this.loadingPromise=ve.makeCancelable(s.getViewportData(),()=>s.close());const i=await this.loadingPromise;this.bufferIndex+=Pr,this.bufferIndex>=s.size&&(this.bufferIndex=null),this.history=[...i.items.filter(({name:o},a,r)=>a===0||o!==r[a-1].name).map(({name:o})=>o).reverse(),...this.history],this.loadingPromise=void 0,s.close()}catch(e){if(this.loadingPromise=void 0,ve.isCanceled(e)){Lr.debug2("Promise canceled, not loading history");return}Lr.error("Error fetching history",e)}}processCommand(e){this.commandHistoryIndex=null,this.modifiedCommands.clear(),M(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;M(e);const t=this.commandEditor.getContentHeight(),n=Math.max(Math.min(t,e),PC),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 l.jsx("div",{className:$("console-input-wrapper",{disabled:e}),children:l.jsxs("div",{className:$("console-input-inner-wrapper",{focus:i}),children:[l.jsx("div",{className:Vl.INPUT_CLASS_NAME,ref:this.commandContainer,style:{height:s}}),o&&l.jsx(Xh,{model:o,language:t,session:n})]})})}}const ic=Vl;const oc="pasted values",_C=[/^audio.*/,/^font.*/,/^image.*/,/^video.*/],_r=[".csv",".tsv",".tab",".psv",".dsv",".txt"],ac=[".zip"];class Zs extends b.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"&&!_C.find(t=>t.test(e.type))}static isValidExtension(e,t=!1){return _r.some(n=>e.endsWith(n))||t&&ac.some(n=>e.endsWith(n))}static handleDragOver(e){e.preventDefault(),e.stopPropagation()}static getIcon(e){return e===oc?Pd:e.endsWith(".csv")?Ip:e.endsWith(".zip")?Dp:Fp}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=X.createRef(),this.divElem=X.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();M(i),Zs.isValidExtension(i.name,t)?this.handleFile(i):this.setState({dropError:Zs.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:oc,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:Pd,action:this.handleMenuPaste,shortcut:es.PASTE,disabled:e}]}getValidExtensions=fe(e=>e?[..._r,...ac]:[..._r]);getAcceptString=fe(e=>this.getValidExtensions(e).join(", "));getFileTypeErrorString=fe(e=>Wt.join(this.getValidExtensions(e),"or"));render(){const{allowZip:e,dragError:t,uploadInProgress:n}=this.props,{selectedFileName:s,dropError:i}=this.state,o=t??i,a=this.makeContextMenuItems();return l.jsxs("div",{ref:this.divElem,className:"csv-overlay fill-parent-absolute",onDragOver:Zs.handleDragOver,onDrop:this.handleDrop,tabIndex:-1,children:[l.jsx(ae,{actions:a}),l.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==="")&&l.jsxs("div",{className:"message-content",children:[l.jsx("div",{className:"message-icon",children:l.jsx(J,{icon:Np})}),l.jsx("label",{children:"Drop file (or paste values) here to import"}),l.jsx("div",{className:"message-small",children:l.jsx("label",{children:"or"})}),l.jsx(V,{kind:"primary",onClick:this.handleSelectFile,children:"Select File..."})]}),s&&(o===void 0||o==="")&&l.jsxs("div",{className:"selected-content",children:[l.jsx("div",{className:"selected-icon",children:l.jsx(J,{icon:Zs.getIcon(s)})}),l.jsxs("div",{className:"selected-text",children:[l.jsx("label",{children:"Selected File"}),l.jsxs("label",{className:"selected-name",children:[s,!n&&l.jsx(V,{kind:"ghost",className:"ml-2",onClick:this.unstageFile,icon:Qt,tooltip:"Remove"})]})]})]}),Boolean(o)&&l.jsxs("div",{className:"message-content",children:[l.jsx("div",{className:"message-icon",children:l.jsx(J,{icon:Ms})}),l.jsx("label",{children:o}),o===Zs.FILE_TYPE_ERROR&&l.jsx("div",{className:"message-small",children:l.jsx("label",{children:this.getFileTypeErrorString(e)})})]})]})}}const vi=Zs;class jC{static INTEGER="int";static LONG="long";static DOUBLE="double";static BOOLEAN="bool";static STRING="string";static DATE_TIME="datetime";static LOCAL_TIME="localtime"}const Ae=jC,rc="unknown",HC=2147483647,BC=-2147483648,lc=/^[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]+)?$/,dc=/^([0-9]+T)?([0-9]+):([0-9]+)(:[0-9]+)?(?:\.[0-9]{1,9})?$/;class Tt{static determineType(e,t,n){if(!e||e===n)return t;switch(t){case Ae.STRING:return Ae.STRING;case Ae.INTEGER:return Tt.checkInteger(e);case Ae.LONG:return Tt.checkLong(e);case Ae.DOUBLE:return Tt.checkDouble(e);case Ae.BOOLEAN:return Tt.checkBoolean(e);case Ae.DATE_TIME:return Tt.checkDateTime(e);case Ae.LOCAL_TIME:return Tt.checkLocalTime(e);default:return Tt.getTypeFromUnknown(e)}}static isNotParsableNumber(e){return isNaN(e)||e==="Infinity"||e==="-Infinity"}static checkInteger(e){const t=e.replace(/,/g,"");return Tt.isNotParsableNumber(t)?Ae.STRING:Tt.getNumberType(t)}static checkLong(e){const t=e.replace(/,/g,"");return Tt.isNotParsableNumber(t)?Ae.STRING:t.includes(".")?Ae.DOUBLE:Ae.LONG}static checkDouble(e){const t=e.replace(/,/g,"");return Tt.isNotParsableNumber(t)?Ae.STRING:Ae.DOUBLE}static checkBoolean(e){const t=e.toLowerCase();return t==="true"||t==="false"?Ae.BOOLEAN:Ae.STRING}static checkDateTime(e){return lc.test(e)?Ae.DATE_TIME:Ae.STRING}static checkLocalTime(e){return dc.test(e)?Ae.LOCAL_TIME:Ae.STRING}static getTypeFromUnknown(e){const t=e.replace(/,/g,"");if(Tt.isNotParsableNumber(t)){const n=e.toLowerCase();return n==="true"||n==="false"?Ae.BOOLEAN:lc.test(e)&&e.includes(":")?Ae.DATE_TIME:dc.test(e)?Ae.LOCAL_TIME:Ae.STRING}return Tt.getNumberType(t)}static getNumberType(e){if(e.includes("."))return Ae.DOUBLE;const t=e.startsWith("-")?11:10;if(e.length>t)return Ae.LONG;const n=parseInt(e,10);return n>HC||n<BC?Ae.LONG:Ae.INTEGER}constructor(e,t,n,s,i,o,a,r,c,h){this.onFileCompleted=e,this.file=t,this.readHeaders=n,this.nullString=i,this.onProgress=o,this.onError=a,this.chunks=0,this.totalChunks=r,this.isZip=c,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;el.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(rc),this.readHeaders&&(n=n.slice(1))}M(this.types);const s=[...this.types];n.forEach(a=>{if(a.length>=s.length){for(let r=0;r<s.length;r+=1)s[r]=Tt.determineType(this.shouldTrim?a[r].trim():a[r],s[r],this.nullString);this.types=s}else t.abort(),this.onError(`Error parsing CSV: Insufficient data in row.
|
|
4
4
|
Expected length ${s.length} but found ${a.length}.
|
|
@@ -16,7 +16,7 @@ ${e}`):n.setValue(`${e}`);const i=n.getLineCount(),o=n.getLineLength(i)+1;this.e
|
|
|
16
16
|
`&&(n+=`
|
|
17
17
|
`))}}if(n=n.trimRight(),this.editor.setValue(n),t){const s=this.editor.getModel()?.getLineCount();M(s),this.editor.revealLine(s,1)}this.stopFlushTimer(),this.bufferedMessages=[]}truncateLogIfNecessary(){this.messages.length>Et.maxLogSize&&(this.messages=this.messages.splice(this.messages.length-Et.truncateSize))}scrollToBottom(){if(!this.editor)return;const e=this.editor?.getModel?.()?.getLineCount();M(e),this.editor.revealLine(e,1)}isBottomVisible(){if(!this.editor)return!0;const t=this.editor.getModel()?.getLineCount();return M(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=Et.getLogText(n);e+=s,s.charAt(s.length-1)!==`
|
|
18
18
|
`&&(e+=`
|
|
19
|
-
`)}this.bufferedMessages=[],this.appendLogText(e)}queue(e){this.bufferedMessages.push(e),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,Et.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 l.jsxs("div",{className:"log-pane h-100 w-100",children:[l.jsxs("div",{className:"log-pane-menu",children:[l.jsx(V,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:Op,tooltip:"Clear log"}),l.jsx(V,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:ko,tooltip:"Log Settings",onClick:()=>{},children:l.jsx(Zn,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:e})})]}),l.jsx("div",{className:"log-pane-editor h-100 w-100",ref:s=>{this.editorContainer=s}})]})}}const mS=Et;class lt{static TYPE_GLOBAL="type-global";static TYPE_CONTEXT_PRESET="type-context-preset";static TYPE_CONTEXT_CUSTOM="type-context-custom";static isValid(e){return!0}static isSameFormat(e,t){throw new Error("isSameFormat not implemented")}static makeFormat(e,t,n){return{label:e,formatString:t,type:n}}format(e,t){return""}}class pS extends lt{format(e){switch(e){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}class gS extends lt{format(e){return String.fromCharCode(e)}}const fc=Z.module("DateTimeColumnFormatter");class _e extends lt{static isValid(e){try{return x.i18n.DateTimeFormat.format(e.formatString,new Date),!0}catch{return!1}}static makeFormat(e,t,n=lt.TYPE_CONTEXT_PRESET){return{label:e,formatString:t,type:n}}static isSameFormat(e,t){return e===t||e!==null&&t!==null&&e.type===t.type&&e.formatString===t.formatString}static DEFAULT_DATETIME_FORMAT_STRING="yyyy-MM-dd HH:mm:ss.SSS";static DEFAULT_TIME_ZONE_ID="America/New_York";static makeGlobalFormatStringMap(e,t){const n=t?"'T'":" ",s=e?" z":"";return new Map([["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${s}`]])}static getGlobalFormats(e,t){return[..._e.makeGlobalFormatStringMap(e,t).keys()]}static makeFormatStringMap(e,t){const n=t!==void 0&&t?"'T'":" ",s=e!==void 0&&e?" z":"";return new Map([["yyyy-MM-dd",`yyyy-MM-dd${s}`],["MM-dd-yyyy",`MM-dd-yyyy${s}`],["HH:mm:ss",`HH:mm:ss${s}`],["HH:mm:ss.SSS",`HH:mm:ss.SSS${s}`],["HH:mm:ss.SSSSSSSSS",`HH:mm:ss.SSSSSSSSS${s}`],["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${s}`]])}static getFormats(e,t){return[..._e.makeFormatStringMap(e,t).keys()]}dhTimeZone;defaultDateTimeFormatString;showTimeZone;showTSeparator;formatStringMap;constructor({timeZone:e="",showTimeZone:t=!0,showTSeparator:n=!1,defaultDateTimeFormatString:s=_e.DEFAULT_DATETIME_FORMAT_STRING}={}){super();const i=e||_e.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=x.i18n.TimeZone.getTimeZone(i)}catch{fc.error("Unsupported time zone id",i),this.dhTimeZone=x.i18n.TimeZone.getTimeZone(_e.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=s,this.showTimeZone=t,this.showTSeparator=n,this.formatStringMap=_e.makeFormatStringMap(t,n)}getEffectiveFormatString(e){return this.formatStringMap.get(e)??e}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultDateTimeFormatString,s=this.getEffectiveFormatString(n);try{return x.i18n.DateTimeFormat.format(s,e,this.dhTimeZone)}catch{fc.error("Invalid format arguments")}return""}}const fS=Z.module("DecimalColumnFormatter");class Re extends lt{static isValid(e){try{return x.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=lt.TYPE_CONTEXT_PRESET,s){return{label:e,type:n,formatString:t,multiplier:s}}static makePresetFormat(e,t="",n){return Re.makeFormat(e,t,lt.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return Re.makeFormat("Custom Format",e,lt.TYPE_CONTEXT_CUSTOM,t)}static DEFAULT_FORMAT_STRING="###,##0.0000";static FORMAT_PERCENT=Re.makePresetFormat("Percent","##0.00%");static FORMAT_BASIS_POINTS=Re.makePresetFormat("Basis Points","###,##0 bp",1e4);static FORMAT_MILLIONS=Re.makePresetFormat("Millions","###,##0.000 mm",1e-6);static FORMAT_SCIENTIFIC_NOTATION=Re.makePresetFormat("Scientific Notation","0.0000E0");static FORMAT_ROUND=Re.makePresetFormat("Round","###,##0");static FORMAT_ROUND_TWO_DECIMALS=Re.makePresetFormat("0.00","###,##0.00");static FORMAT_ROUND_FOUR_DECIMALS=Re.makePresetFormat("0.0000","###,##0.0000");static isSameFormat(e,t){return e===t||e!=null&&t!=null&&e.type===t.type&&e.formatString===t.formatString&&e.multiplier===t.multiplier}defaultFormatString;constructor({defaultFormatString:e=Re.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=e}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,s=t.multiplier!==void 0&&t.multiplier!==0?e*t.multiplier:e;try{return x.i18n.NumberFormat.format(n,s)}catch{fS.error("Invalid format arguments")}return""}}class CS extends lt{format(e){return`${e}`}}const SS=Z.module("IntegerColumnFormatter");class $e extends lt{static isValid(e){try{return x.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=lt.TYPE_CONTEXT_PRESET,s){return{label:e,type:n,formatString:t,multiplier:s}}static makePresetFormat(e,t="",n){return $e.makeFormat(e,t,lt.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return $e.makeFormat("Custom Format",e,lt.TYPE_CONTEXT_CUSTOM,t)}static isSameFormat(e,t){return e===t||e!=null&&t!=null&&e.type===t.type&&e.formatString===t.formatString&&e.multiplier===t.multiplier}static DEFAULT_FORMAT_STRING="###,##0";static FORMAT_MILLIONS=$e.makePresetFormat("Millions","###,##0.000 mm",1e-6);static FORMAT_SCIENTIFIC_NOTATION=$e.makePresetFormat("Scientific Notation","0.0000E0");defaultFormatString;constructor({defaultFormatString:e=$e.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=e}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,s=t.multiplier!==void 0&&t.multiplier!==0?e*t.multiplier:e;try{return x.i18n.NumberFormat.format(n,s)}catch{SS.error("Invalid format arguments")}return""}}class bS extends lt{format(e){return e}}class et{static FULL_DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";static months=["january","february","march","april","may","june","july","august","september","october","november","december"];static makeDateWrapper(e,t,n=0,s=1,i=0,o=0,a=0,r=0){if(!e)throw new Error("No timezone provided");const c=`${t}`.padStart(4,"0"),h=`${n+1}`.padStart(2,"0"),u=`${s}`.padStart(2,"0"),m=`${i}`.padStart(2,"0"),p=`${o}`.padStart(2,"0"),g=`${a}`.padStart(2,"0"),C=`${r}`.padStart(9,"0"),f=`${c}-${h}-${u} ${m}:${p}:${g}.${C}`;return x.i18n.DateTimeFormat.parse(et.FULL_DATE_FORMAT,f,x.i18n.TimeZone.getTimeZone(e))}static getNextNanos(e){const t=parseInt(e,10),n="0".repeat(9-e.length),s=`${t+1}${n}`;return parseInt(s,10)}static getNextDate(e,t,n){let{year:s,month:i,date:o,hours:a,minutes:r,seconds:c,nanos:h}=t;if(e.nanos!=null){if(e.nanos.length===9)return null;h=et.getNextNanos(e.nanos),h>999999999&&(c+=1,h=0)}else e.seconds!=null?c+=1:e.minutes!=null?r+=1:e.hours!=null?a+=1:e.date!=null?o+=1:e.month!=null?i+=1:s+=1;const u=new Date(s,i,o,a,r,c);return et.makeDateWrapper(n,u.getFullYear(),u.getMonth(),u.getDate(),u.getHours(),u.getMinutes(),u.getSeconds(),h)}static parseMonth(e){const t=parseInt(e,10);if(!Number.isNaN(t))return t>=1&&t<=12?t-1:NaN;const n=e.trim().toLowerCase();if(n.length>=3){for(let s=0;s<et.months.length;s+=1)if(et.months[s].startsWith(n))return s}return NaN}static parseDateValues(e,t,n,s,i,o,a){const r=parseInt(e,10),c=t!=null?this.parseMonth(t):0,h=n!=null?parseInt(n,10):1,u=s!=null?parseInt(s,10):0,m=i!=null?parseInt(i,10):0,p=o!=null?parseInt(o,10):0,g=a!=null?parseInt(a.padEnd(9,"0"),10):0;return Number.isNaN(r)||Number.isNaN(c)||Number.isNaN(h)||Number.isNaN(u)||Number.isNaN(m)||Number.isNaN(p)||Number.isNaN(g)?null:{year:r,month:c,date:h,hours:u,minutes:m,seconds:p,nanos:g}}static parseDateTimeString(e){const n=/\s*(\d{4})([-./]([\da-z]+))?([-./](\d{1,2}))?([tT\s](\d{2})([:](\d{2}))?([:](\d{2}))?([.](\d{1,9}))?)?(.*)/.exec(e);if(n==null)throw new Error(`Unexpected date string: ${e}`);const[,s,,i,,o,,a,,r,,c,,h,u]=n;if(u!=null&&u.length>0)throw new Error(`Unexpected characters after date string '${e}': ${u}`);return{year:s,month:i,date:o,hours:a,minutes:r,seconds:c,nanos:h}}static parseDateRange(e,t){const n=e.trim().toLowerCase();if(n.length===0)throw new Error("Cannot parse date range from empty string");if(n==="null")return[null,null];if(n==="today"){const r=new Date(Date.now()),c=et.makeDateWrapper(t,r.getFullYear(),r.getMonth(),r.getDate()),h=et.makeDateWrapper(t,r.getFullYear(),r.getMonth(),r.getDate()+1);return[c,h]}if(n==="yesterday"){const r=new Date(Date.now()),c=et.makeDateWrapper(t,r.getFullYear(),r.getMonth(),r.getDate()-1),h=et.makeDateWrapper(t,r.getFullYear(),r.getMonth(),r.getDate());return[c,h]}if(n==="now"){const r=new Date(Date.now());return[x.DateWrapper.ofJsDate(r),null]}const s=et.parseDateTimeString(n);if(s.year==null&&s.month==null&&s.date==null)throw new Error(`Unable to extract year, month, or day ${n}`);const i=et.parseDateValues(s.year,s.month,s.date,s.hours,s.minutes,s.seconds,s.nanos);if(i==null)throw new Error(`Unable to extract date values from ${s}`);const o=et.makeDateWrapper(t,i.year,i.month,i.date,i.hours,i.minutes,i.seconds,i.nanos),a=et.getNextDate(s,i,t);return[o,a]}static getJsDate(e){return typeof e=="number"?new Date(e):e.asDate()}}class Sn{static not="not";static and="and";static or="or"}function wS(d){if(!(d==="not"||d==="and"||d==="or"))throw new Error("operator is not a valid FilterOperatorValue")}class Y{static eq="eq";static eqIgnoreCase="eqIgnoreCase";static notEq="notEq";static notEqIgnoreCase="notEqIgnoreCase";static greaterThan="greaterThan";static greaterThanOrEqualTo="greaterThanOrEqualTo";static lessThan="lessThan";static lessThanOrEqualTo="lessThanOrEqualTo";static in="in";static inIgnoreCase="inIgnoreCase";static notIn="notIn";static notInIgnoreCase="notInIgnoreCase";static isTrue="isTrue";static isFalse="isFalse";static isNull="isNull";static invoke="invoke";static contains="contains";static notContains="notContains";static startsWith="startsWith";static endsWith="endsWith";static containsAny="containsAny"}function eu(d){switch(d){case Y.eq:return"is exactly";case Y.eqIgnoreCase:return"is exactly (ignore case)";case Y.notEq:return"is not exactly";case Y.notEqIgnoreCase:return"is not exactly (ignore case)";case Y.contains:return"contains";case Y.notContains:return"does not contain";case Y.startsWith:return"starts with";case Y.endsWith:return"ends with";default:throw new Error(`Unrecognized text filter type ${d}`)}}function tu(d){switch(d){case Y.eq:return"is equal to";case Y.notEq:return"is not equal to";case Y.greaterThan:return"greater than";case Y.greaterThanOrEqualTo:return"greater than or equal to";case Y.lessThan:return"less than";case Y.lessThanOrEqualTo:return"less than or equal to";default:throw new Error(`Unrecognized number filter type ${d}`)}}function nu(d){switch(d){case Y.eq:return"date is";case Y.notEq:return"date is not";case Y.notEqIgnoreCase:case Y.greaterThan:return"date is after";case Y.greaterThanOrEqualTo:return"date is after or equal";case Y.lessThan:return"date is before";case Y.lessThanOrEqualTo:return"date is before or equal";default:throw new Error(`Unrecognized date filter type ${d}`)}}function vS(d){switch(d){case Y.isTrue:return"Is True";case Y.isFalse:return"Is False";case Y.isNull:return"Is Null";default:throw new Error(`Unrecognized boolean filter type ${d}`)}}const Un=Z.module("TableUtils");class R{static dataType={BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"};static sortDirection={ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null};static REVERSE_TYPE=Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"});static NUMBER_REGEX=/^-?\d+(\.\d+)?$/;static getSortIndex(e,t){for(let n=0;n<e.length;n+=1)if(e[n].column?.name===t)return n;return null}static getSortForColumn(e,t){const n=R.getSortIndex(e,t);return n!=null?e[n]:null}static getFilterText(e){return e?e.toString():null}static getFilterTypes(e){return R.isBooleanType(e)?[Y.isTrue,Y.isFalse,Y.isNull]:R.isCharType(e)||R.isNumberType(e)||R.isDateType(e)?[Y.eq,Y.notEq,Y.greaterThan,Y.greaterThanOrEqualTo,Y.lessThan,Y.lessThanOrEqualTo]:R.isTextType(e)?[Y.eq,Y.eqIgnoreCase,Y.notEq,Y.notEqIgnoreCase,Y.contains,Y.notContains,Y.startsWith,Y.endsWith]:[]}static getNextSort(e,t,n){if(e==null||n<0||n>=e.length)return null;const s=R.getSortForColumn(t,e[n].name);return s===null?e[n].sort().asc():s.direction===R.sortDirection.ascending?s.desc():null}static makeColumnSort(e,t,n,s){if(e==null||t<0||t>=e.length||n===R.sortDirection.none)return null;let i=e[t].sort();switch(n){case R.sortDirection.ascending:i=i.asc();break;case R.sortDirection.descending:i=i.desc();break}return s&&(i=i.abs()),i}static toggleSortForColumn(e,t,n,s=!1){if(n<0||n>=t.length)return[];const i=R.getNextSort(t,e,n);return R.setSortForColumn(e,t[n].name,i,s)}static sortColumn(e,t,n,s,i,o){if(e==null||n<0||n>=t.length)return[];const a=R.makeColumnSort(t,n,s,i);return R.setSortForColumn(e,t[n].name,a,o)}static setSortForColumn(e,t,n,s=!1){const i=R.getSortIndex(e,t);let o=[];return s&&(o=o.concat(e.filter(({direction:a})=>a!==R.sortDirection.reverse)),i!==null&&o.splice(i,1)),n!==null&&o.push(n),o}static getNormalizedType(e){switch(e){case"boolean":case"java.lang.Boolean":case R.dataType.BOOLEAN:return R.dataType.BOOLEAN;case"char":case"java.lang.Character":case R.dataType.CHAR:return R.dataType.CHAR;case"java.lang.String":case R.dataType.STRING:return R.dataType.STRING;case"io.deephaven.db.tables.utils.DBDateTime":case"io.deephaven.time.DateTime":case"com.illumon.iris.db.tables.utils.DBDateTime":case"java.time.Instant":case"java.time.ZonedDateTime":case R.dataType.DATETIME:return R.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case R.dataType.DECIMAL:return R.dataType.DECIMAL;case"int":case"java.lang.Integer":case"long":case"java.lang.Long":case"short":case"java.lang.Short":case"byte":case"java.lang.Byte":case"java.math.BigInteger":case R.dataType.INT:return R.dataType.INT;default:return R.dataType.UNKNOWN}}static isLongType(e){switch(e){case"long":case"java.lang.Long":return!0;default:return!1}}static isDateType(e){switch(e){case"io.deephaven.db.tables.utils.DBDateTime":case"io.deephaven.time.DateTime":case"java.time.Instant":case"java.time.ZonedDateTime":case"com.illumon.iris.db.tables.utils.DBDateTime":return!0;default:return!1}}static isNumberType(e){return R.isIntegerType(e)||R.isDecimalType(e)}static isIntegerType(e){switch(e){case"int":case"java.lang.Integer":case"java.math.BigInteger":case"long":case"java.lang.Long":case"short":case"java.lang.Short":case"byte":case"java.lang.Byte":return!0;default:return!1}}static isDecimalType(e){switch(e){case"double":case"java.lang.Double":case"java.math.BigDecimal":case"float":case"java.lang.Float":return!0;default:return!1}}static isBigDecimalType(e){switch(e){case"java.math.BigDecimal":return!0;default:return!1}}static isBigIntegerType(e){switch(e){case"java.math.BigInteger":return!0;default:return!1}}static isBooleanType(e){switch(e){case"boolean":case"java.lang.Boolean":return!0;default:return!1}}static isCharType(e){switch(e){case"char":case"java.lang.Character":return!0;default:return!1}}static isStringType(e){switch(e){case"java.lang.String":return!0;default:return!1}}static isTextType(e){return this.isStringType(e)||this.isCharType(e)}static getBaseType(e){return e.split("[]")[0]}static isCompatibleType(e,t){return R.getNormalizedType(e)===R.getNormalizedType(t)}static makeQuickFilter(e,t,n){const s=t.split("||");let i=null;for(let o=0;o<s.length;o+=1){const r=s[o].split("&&");let c=null;for(let h=0;h<r.length;h+=1){const u=r[h].trim();if(u.length>0){const m=R.makeQuickFilterFromComponent(e,u,n);if(m)c?c=c.and(m):c=m;else throw new Error(`Unable to parse quick filter from text ${t}`)}}i&&c?i=i.or(c):i=c}return i}static makeQuickFilterFromComponent(e,t,n){const{type:s}=e;return R.isNumberType(s)?this.makeQuickNumberFilter(e,t):R.isBooleanType(s)?this.makeQuickBooleanFilter(e,t):n!=null&&R.isDateType(s)?this.makeQuickDateFilter(e,t,n):R.isCharType(s)?this.makeQuickCharFilter(e,t):this.makeQuickTextFilter(e,t)}static makeQuickNumberFilter(e,t){if(t==null)return null;const n=e.filter();let s=null;const o=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i.exec(t);let a=null,r=null,c=null,h=null,u=null;if(o!==null&&o.length>3&&([,a,r,c,h,u]=o),u!=null&&u.trim().length>0)return null;if(a==null&&(a="="),h!=null){if(!(a==="="||a==="!"||a==="!="))return null;switch(h=h.trim().toLowerCase(),h){case"null":s=n.isNull();break;case"nan":s=x.FilterCondition.invoke("isNaN",n);break;case"infinity":case"inf":case"∞":r!=null?s=x.FilterCondition.invoke("isInf",n).and(n.lessThan(x.FilterValue.ofNumber(0))):s=x.FilterCondition.invoke("isInf",n).and(n.greaterThan(x.FilterValue.ofNumber(0)));break}return s!==null&&(a==="!"||a==="!=")&&(s=s.not()),s}if(c==null)return null;if(c=R.removeCommas(c),R.isLongType(e.type))try{c=x.FilterValue.ofNumber(x.LongWrapper.ofString(`${r!=null?"-":""}${c}`))}catch(m){return Un.warn("Unable to create long filter",m),null}else{if(c=parseFloat(c),c==null||Number.isNaN(c))return null;c=x.FilterValue.ofNumber(r!=null?0-c:c)}return s=e.filter(),R.makeRangeFilterWithOperation(s,a,c)}static makeQuickTextFilter(e,t){if(t==null)return null;const n=`${t}`.trim(),i=/^(!~|!=|~|=|!)?(.*)/.exec(n);let o=null,a=null;if(i!==null&&i.length>2&&([,o,a]=i,a!=null&&(a=a.trim())),a==null||a.length===0)return null;o==null&&(o="=");const r=e.filter();if(a.toLowerCase()==="null")switch(o){case"=":return r.isNull();case"!=":case"!":return r.isNull().not();default:return null}let c=null,h=null;switch(a.startsWith("*")?(c="*",a=a.substring(1)):a.endsWith("*")&&!a.endsWith("\\*")&&(h="*",a=a.substring(0,a.length-1)),a=a.replace("\\",""),o){case"~":return r.isNull().not().and(r.invoke("matches",x.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E.*`)));case"!~":return r.isNull().or(r.invoke("matches",x.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E.*`)).not());case"!=":return c==="*"?r.isNull().or(r.invoke("matches",x.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E$`)).not()):h==="*"?r.isNull().or(r.invoke("matches",x.FilterValue.ofString(`(?s)(?i)^\\Q${a}\\E.*`)).not()):r.notEqIgnoreCase(x.FilterValue.ofString(a.toLowerCase()));case"=":return c==="*"?r.isNull().not().and(r.invoke("matches",x.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E$`))):h==="*"?r.isNull().not().and(r.invoke("matches",x.FilterValue.ofString(`(?s)(?i)^\\Q${a}\\E.*`))):r.eqIgnoreCase(x.FilterValue.ofString(a.toLowerCase()))}return null}static makeQuickBooleanFilter(e,t){if(t==null)return null;const s=/^(!=|=|!)?(.*)/.exec(`${t}`.trim());if(s===null)return null;const[,i,o]=s,a=i==="!"||i==="!=",r=o.trim().toLowerCase();let c=e.filter();try{const h=R.makeBooleanValue(r);return h!=null&&h?c=c.isTrue():h===null?c=c.isNull():c=c.isFalse(),a?c.not():c}catch{return null}}static makeQuickDateFilter(e,t,n){const s=t.trim(),o=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/.exec(s);if(o==null||o.length<=2)throw new Error(`Unable to parse date filter: ${t}`);let a=null,r=null;[,a,r]=o;let c=Y.eq;switch(a){case"<":c=Y.lessThan;break;case"<=":case"=<":c=Y.lessThanOrEqualTo;break;case">":c=Y.greaterThan;break;case">=":case"=>":c=Y.greaterThanOrEqualTo;break;case"!=":case"!":c=Y.notEq;break;case"=":case"==":default:c=Y.eq;break}return R.makeQuickDateFilterWithOperation(e,r,c,n)}static makeQuickDateFilterWithOperation(e,t,n,s){if(e==null)throw new Error("Column is null");const[i,o]=et.parseDateRange(t,s),a=i!=null?x.FilterValue.ofNumber(i):null,r=o!=null?x.FilterValue.ofNumber(o):null,c=e.filter();if(a==null)return n===Y.notEq?c.isNull().not():c.isNull();switch(n){case Y.eq:{if(r!=null){const h=c.greaterThanOrEqualTo(a),u=c.lessThan(r);return h.and(u)}return c.eq(a)}case Y.lessThan:return c.lessThan(a);case Y.lessThanOrEqualTo:return r!=null?c.lessThan(r):c.lessThanOrEqualTo(a);case Y.greaterThan:return r!=null?c.greaterThanOrEqualTo(r):c.greaterThan(a);case Y.greaterThanOrEqualTo:return c.greaterThanOrEqualTo(a);case Y.notEq:{if(r!=null){const h=c.lessThan(a),u=c.greaterThanOrEqualTo(r);return h.or(u)}return c.notEq(a)}default:throw new Error(`Invalid operator: ${n}`)}}static quoteValue(e){return e.length>=2&&(e.charAt(0)==='"'&&e.charAt(e.length-1)==='"'||e.charAt(0)==="'"&&e.charAt(e.length-1)==="'")?e:`"${e}"`}static isRangeOperation(e){switch(e){case"<":case"<=":case"=<":case">":case">=":case"=>":return!0;default:return!1}}static makeQuickCharFilter(e,t){if(t==null)return null;const n=`${t}`.trim(),i=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/.exec(n);let o=null,a=null,r=null;if(i!==null&&i.length>3&&([,o,a,r]=i),r!=null&&r.trim().length>0||a==null||a.length===0)return null;o==null&&(o="=");const c=e.filter();if(a.toLowerCase()==="null")switch(o){case"=":return c.isNull();case"!=":case"!":return c.isNull().not();default:return null}const h=x.FilterValue.ofString(R.isRangeOperation(o)?R.quoteValue(a):a);return R.makeRangeFilterWithOperation(c,o,h)}static makeRangeFilterWithOperation(e,t,n){switch(t){case"=":return e.eq(n);case"<":return e.lessThan(n);case"<=":case"=<":return e.lessThanOrEqualTo(n);case">":return e.greaterThan(n);case">=":case"=>":return e.greaterThanOrEqualTo(n);case"!=":case"!":return e.notEq(n);default:return null}}static makeCancelableTablePromise(e){return ve.makeCancelable(e,t=>{t.close()})}static makeCancelableTableEventPromise(e,t,n=0,s=null){let i,o,a=!0;const r=new Promise((c,h)=>{o=setTimeout(()=>{i(),a=!1,h(new Ph(`Event "${t}" timed out.`))},n),i=e.addEventListener(t,u=>{if(s!=null&&!s(u)){Un.debug2("Event triggered, but matcher returned false.");return}Un.debug2("Event triggered, resolving."),i(),clearTimeout(o),a=!1,c(u)})});return r.cancel=()=>{if(a){Un.debug2("Pending promise cleanup."),i(),clearTimeout(o),a=!1;return}Un.debug2("Ignoring non-pending promise cancel.")},r}static makeAdvancedFilter(e,t,n){const{filterItems:s,filterOperators:i,invertSelection:o,selectedValues:a}=t;let r=null;for(let h=0;h<s.length;h+=1){const u=s[h],{selectedType:m,value:p}=u;if(m!=null&&m.length>0&&p!=null&&p.length>0)try{const g=R.makeAdvancedValueFilter(e,m,p,n);if(g!=null){if(h===0)r=g;else if(r!==null&&h-1<i.length){const C=i[h-1];if(C===Sn.and)r=r.and(g);else if(C===Sn.or)r=r.or(g);else{Un.error("Unexpected filter operator",C,g),r=null;break}}}else Un.debug2("Empty filter ignored for",m,p)}catch(g){Un.error("Unable to create filter",g),r=null;break}}const c=R.makeSelectValueFilter(e,a,o);return c!=null&&(r!=null?r=r.and(c):r=c),r}static removeCommas(e){return e.replace(/[\s|,]/g,"")}static makeFilterValue(e,t){const n=R.getBaseType(e);return R.isTextType(n)?x.FilterValue.ofString(t):R.isLongType(n)?x.FilterValue.ofNumber(x.LongWrapper.ofString(R.removeCommas(t))):x.FilterValue.ofNumber(R.removeCommas(t))}static makeFilterRawValue(e,t){return R.isTextType(e)?x.FilterValue.ofString(t):R.isBooleanType(e)?x.FilterValue.ofBoolean(t):x.FilterValue.ofNumber(t)}static makeValue(e,t,n){if(t==null||t==="null")return null;if(R.isTextType(e))return t;if(R.isLongType(e))return x.LongWrapper.ofString(R.removeCommas(t));if(R.isBooleanType(e))return R.makeBooleanValue(t,!0);if(R.isDateType(e)){const[s]=et.parseDateRange(t,n);return s}return R.isNumberType(e)?R.makeNumberValue(t):(Un.error("Unexpected column type",e),null)}static makeBooleanValue(e,t=!1){if(e===""&&t)return null;switch(e?.toLowerCase()){case"null":return null;case"0":case"f":case"fa":case"fal":case"fals":case"false":case"n":case"no":return!1;case"1":case"t":case"tr":case"tru":case"true":case"y":case"ye":case"yes":return!0;default:throw new Error(`Invalid boolean '${e}'`)}}static makeNumberValue(e){if(e==null||e==="null"||e==="")return null;const t=e.toLowerCase().trim();if(t==="∞"||t==="infinity"||t==="inf")return Number.POSITIVE_INFINITY;if(t==="-∞"||t==="-infinity"||t==="-inf")return Number.NEGATIVE_INFINITY;const n=R.removeCommas(t);if(R.NUMBER_REGEX.test(n))return parseFloat(n);throw new Error(`Invalid number '${e}'`)}static getFilterOperatorString(e){switch(e){case Y.eq:return"=";case Y.notEq:return"!=";case Y.greaterThan:return">";case Y.greaterThanOrEqualTo:return">=";case Y.lessThan:return"<";case Y.lessThanOrEqualTo:return"<=";case Y.contains:return"~";case Y.notContains:return"!~";default:throw new Error(`Unexpected filter type ${e}`)}}static makeAdvancedValueFilter(e,t,n,s){if(R.isDateType(e.type))return R.makeQuickDateFilterWithOperation(e,n,t,s);if(R.isNumberType(e.type)||R.isCharType(e.type))return R.makeQuickFilter(e,`${R.getFilterOperatorString(t)}${n}`);const i=R.makeFilterValue(e.type,n),o=e.filter();switch(t){case Y.eq:return o.eq(i);case Y.eqIgnoreCase:return o.eqIgnoreCase(i);case Y.notEq:return o.notEq(i);case Y.notEqIgnoreCase:return o.notEqIgnoreCase(i);case Y.greaterThan:return o.greaterThan(i);case Y.greaterThanOrEqualTo:return o.greaterThanOrEqualTo(i);case Y.lessThan:return o.lessThan(i);case Y.lessThanOrEqualTo:return o.lessThanOrEqualTo(i);case Y.isTrue:return o.isTrue();case Y.isFalse:return o.isFalse();case Y.isNull:return o.isNull();case Y.contains:return o.isNull().not().and(o.invoke("matches",x.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)));case Y.notContains:return o.isNull().or(o.invoke("matches",x.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)).not());case Y.startsWith:return o.isNull().not().and(o.invoke("matches",x.FilterValue.ofString(`(?s)(?i)^\\Q${n}\\E.*`)));case Y.endsWith:return o.isNull().not().and(o.invoke("matches",x.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E$`)));case Y.in:case Y.inIgnoreCase:case Y.notIn:case Y.notInIgnoreCase:case Y.invoke:default:throw new Error(`Unexpected filter operation: ${t}`)}}static makeSelectValueFilter(e,t,n){if(t.length===0){if(n)return null;let o=null;R.isTextType(e.type)?o=x.FilterValue.ofString("a"):R.isBooleanType(e.type)?o=x.FilterValue.ofBoolean(!0):R.isDateType(e.type)?o=x.FilterValue.ofNumber(x.DateWrapper.ofJsDate(new Date)):o=x.FilterValue.ofNumber(0);const a=e.filter().eq(o),r=e.filter().notEq(o);return a.and(r)}const s=[];let i=!1;for(let o=0;o<t.length;o+=1){const a=t[o];a==null?i=!0:R.isTextType(e.type)?s.push(x.FilterValue.ofString(typeof a=="number"?String.fromCharCode(a):a)):R.isBooleanType(e.type)?s.push(x.FilterValue.ofBoolean(Boolean(a))):s.push(x.FilterValue.ofNumber(a))}return i?s.length>0?n?e.filter().isNull().not().and(e.filter().notIn(s)):e.filter().isNull().or(e.filter().in(s)):n?e.filter().isNull().not():e.filter().isNull():n?e.filter().notIn(s):e.filter().in(s)}static isTreeTable(e){return e!=null&&e.expand!==void 0&&e.collapse!==void 0}static sortColumns(e,t=!0){return[...e].sort((n,s)=>{const i=n.name.toUpperCase(),o=s.name.toUpperCase();return Wt.sort(i,o,t)})}}class Zt{static makeColumnFormatMap(e){return e==null?new Map:e.reduce((t,n)=>{const s=R.getNormalizedType(n.columnType);return s===null||(t.has(s)||t.set(s,new Map),t.get(s)?.set(n.columnName,n.format)),t},new Map)}static makeColumnFormattingRule(e,t,n){return{columnType:e,columnName:t,format:n}}constructor(e=[],t,n,s,i=!1){this.defaultColumnFormatter=new CS,this.typeFormatterMap=new Map([[R.dataType.BOOLEAN,new pS],[R.dataType.CHAR,new gS],[R.dataType.DATETIME,new _e(t)],[R.dataType.DECIMAL,new Re(n)],[R.dataType.INT,new $e(s)],[R.dataType.STRING,new bS]]),this.columnFormatMap=Zt.makeColumnFormatMap(e),this.truncateNumbersWithPound=i}defaultColumnFormatter;typeFormatterMap;columnFormatMap;truncateNumbersWithPound;getColumnFormatMapForType(e,t=!1){const n=R.getNormalizedType(e);if(n!==null)return t&&!this.columnFormatMap.has(n)&&this.columnFormatMap.set(n,new Map),this.columnFormatMap.get(n)}getColumnFormat(e,t){return this.getColumnFormatMapForType(e)?.get(t)??null}getColumnTypeFormatter(e){const t=R.getNormalizedType(e);let n=this.defaultColumnFormatter;return t&&(n=this.typeFormatterMap.get(t)??n),n}getFormattedString(e,t,n="",s){if(e==null)return"";const i=this.getColumnTypeFormatter(t),o=s||this.getColumnFormat(t,n);return i.format(e,o??void 0)}get timeZone(){return this.typeFormatterMap.get(R.dataType.DATETIME)?.dhTimeZone?.id}}function TS(d){if(d&&d.formatter){const{formatter:e}=d;return e}}function ES(d){return{timeZone:d?.timeZone,defaultDateTimeFormatString:d?.defaultDateTimeFormat,showTimeZone:d?.showTimeZone,showTSeparator:d?.showTSeparator}}function yS(d,e,t){const n=d.getColumnFormat(t,e);return n!=null&&(n.type===lt.TYPE_CONTEXT_PRESET||n.type===lt.TYPE_CONTEXT_CUSTOM)}const Jn={getColumnFormats:TS,getDateTimeFormatterOptions:ES,isCustomColumnFormatDefined:yS};Ia.register([Ng,Mg,kg,Og,Ag,Lg]);const su=typeof kr=="function"?kr(Ia):kr.default(Ia);class Fn{static EVENT_UPDATED="ChartModel.EVENT_UPDATED";static EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";static EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";static EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";static EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";static EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";static EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";static EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";constructor(){this.listeners=[],this.isDownsamplingDisabled=!1}listeners;formatter;rect;isDownsamplingDisabled;title;getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(e){}close(){}setFormatter(e){this.formatter=e}setDownsamplingDisabled(e){this.isDownsamplingDisabled=e}setDimensions(e){this.rect=e}setTitle(e){this.title=e}subscribe(e){this.listeners.push(e)}unsubscribe(e){this.listeners=this.listeners.filter(t=>t!==e)}fireEvent(e){for(let t=0;t<this.listeners.length;t+=1)this.listeners[t](e)}fireUpdate(e){this.fireEvent(new CustomEvent(Fn.EVENT_UPDATED,{detail:e}))}fireDisconnect(){this.fireEvent(new CustomEvent(Fn.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(Fn.EVENT_RECONNECT))}fireDownsampleStart(e){this.fireEvent(new CustomEvent(Fn.EVENT_DOWNSAMPLESTARTED,{detail:e}))}fireDownsampleFinish(e){this.fireEvent(new CustomEvent(Fn.EVENT_DOWNSAMPLEFINISHED,{detail:e}))}fireDownsampleFail(e){this.fireEvent(new CustomEvent(Fn.EVENT_DOWNSAMPLEFAILED,{detail:e}))}fireDownsampleNeeded(e){this.fireEvent(new CustomEvent(Fn.EVENT_DOWNSAMPLENEEDED,{detail:e}))}fireLoadFinished(){this.fireEvent(new CustomEvent(Fn.EVENT_LOADFINISHED))}}const Wn=Fn,xS="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",RS="#403e41",IS="#5b5a5c",DS="#c0bfbf",FS="#4878ea",NS="rgba(91, 90, 92, 0.7)",bt={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:xS,gridcolor:RS,linecolor:IS,zerolinecolor:DS,activecolor:FS,rangebgcolor:NS,"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"},_t=Object.freeze({paper_bgcolor:bt["paper-bgcolor"],plot_bgcolor:bt["plot-bgcolor"],title_color:bt["title-color"],colorway:bt.colorway,gridcolor:bt.gridcolor,linecolor:bt.linecolor,zerolinecolor:bt.zerolinecolor,activecolor:bt.activecolor,rangebgcolor:bt.rangebgcolor,area_color:bt["area-color"],trend_color:bt["trend-color"],line_color:bt["line-color"],error_band_line_color:bt["error-band-line-color"],error_band_fill_color:bt["error-band-fill-color"],ohlc_increasing:bt["ohlc-increasing"],ohlc_decreasing:bt["ohlc-decreasing"]}),so=Z.module("ChartUtils"),ds=Object.freeze(x.calendar.DayOfWeek.values()),Cc="io.deephaven.time.DateTime",MS=36e5,kS=1e6;function OS(d){return d.asDate!==void 0}function AS(d){return d.asNumber!==void 0}function Sc(d){return d.dhTimeZone!==void 0}function LS(d){return d!=null&&d.range!=null&&(d.autorange===!1||d.autorange===void 0)}class ne{static DEFAULT_AXIS_SIZE=.15;static MIN_AXIS_SIZE=.025;static MAX_AXIS_SIZE=.2;static AXIS_SIZE_PX=75;static LEGEND_WIDTH_PX=50;static MAX_LEGEND_SIZE=.25;static ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});static DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";static DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});static DEFAULT_TITLE_PADDING=Object.freeze({t:8});static SUBTITLE_LINE_HEIGHT=25;static DEFAULT_MARKER_SIZE=6;static MODE_MARKERS="markers";static MODE_LINES="lines";static getPlotlyChartType(e,t){switch(e){case x.plot.SeriesPlotStyle.SCATTER:return t?"scatter":"scattergl";case x.plot.SeriesPlotStyle.LINE:return"scatter";case x.plot.SeriesPlotStyle.BAR:case x.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case x.plot.SeriesPlotStyle.PIE:return"pie";case x.plot.SeriesPlotStyle.TREEMAP:return"treemap";case x.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case x.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(e,t,n){const s=new Set;switch(e){case x.plot.SeriesPlotStyle.SCATTER:(t??!1)&&s.add(ne.MODE_LINES),(n??!0)&&s.add(ne.MODE_MARKERS);break;case x.plot.SeriesPlotStyle.LINE:(t??!0)&&s.add(ne.MODE_LINES),(n??!1)&&s.add(ne.MODE_MARKERS);break}return s.size>0?[...s].join("+"):void 0}static getPlotlyProperty(e,t){switch(e){case x.plot.SeriesPlotStyle.PIE:switch(t){case x.plot.SourceType.X:return"labels";case x.plot.SourceType.Y:return"values"}break;case x.plot.SeriesPlotStyle.OHLC:switch(t){case x.plot.SourceType.TIME:return"x"}break;case x.plot.SeriesPlotStyle.TREEMAP:switch(t){case x.plot.SourceType.X:return"ids";case x.plot.SourceType.Y:return"values";case x.plot.SourceType.LABEL:return"labels";case x.plot.SourceType.PARENT:return"parents";case x.plot.SourceType.COLOR:return"marker.colors"}break}switch(t){case x.plot.SourceType.X:return"x";case x.plot.SourceType.Y:return"y";case x.plot.SourceType.Z:return"z";case x.plot.SourceType.X_LOW:return"xLow";case x.plot.SourceType.X_HIGH:return"xHigh";case x.plot.SourceType.Y_LOW:return"yLow";case x.plot.SourceType.Y_HIGH:return"yHigh";case x.plot.SourceType.TIME:return"time";case x.plot.SourceType.OPEN:return"open";case x.plot.SourceType.HIGH:return"high";case x.plot.SourceType.LOW:return"low";case x.plot.SourceType.CLOSE:return"close";case x.plot.SourceType.SHAPE:return"shape";case x.plot.SourceType.SIZE:return"size";case x.plot.SourceType.LABEL:return"label";case x.plot.SourceType.COLOR:return"color";case x.plot.SourceType.PARENT:return"parent";case x.plot.SourceType.HOVER_TEXT:return"hovertext";case x.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${t}`)}}static getPlotlySeriesOrientation(e){const{sources:t}=e;return t.length===2&&t[0]?.axis?.type===x.plot.AxisType.Y?ne.ORIENTATION.HORIZONTAL:ne.ORIENTATION.VERTICAL}static getPlotlyErrorBars(e,t,n){const s=n.map((o,a)=>o-e[a]),i=t.map((o,a)=>e[a]-o);return{type:"data",symmetric:!1,array:s,arrayminus:i}}static getPlotlyDateFormat(e,t,n){const s=n?.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let i;const o=e?.getColumnTypeFormatter(t);return o!=null&&Sc(o)&&o.dhTimeZone!=null&&o.showTimeZone&&(i=x.i18n.DateTimeFormat.format(" z",new Date,o.dhTimeZone)),{tickformat:s,ticksuffix:i,automargin:!0}}static convertNumberPrefix(e){return e.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(e,t,n){if(!n)return null;const i=n.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);M(i);const[,o,a,r,,c,h,u,m,p]=i,g=r.replace(",","").length,f=a.indexOf(",")>=0||r.indexOf(",")>=0?",":"",S=u!=null&&u!==""?"e":"f",v=m!==""?m:S,w=c.length+h.length,y=`0${g}${f}.${w}${v}`,E=ne.convertNumberPrefix(o),I=ne.convertNumberPrefix(p);return{tickformat:y,tickprefix:E,ticksuffix:I,automargin:!0}}static getPlotlyAxisFormat(e,t=null){const{axis:n,columnType:s}=e,{formatPattern:i}=n;let o=null;return R.isDateType(s)?(o=ne.getPlotlyDateFormat(t,s,i),o=ne.addTickSpacing(o,n,!0)):R.isNumberType(s)&&(o=ne.getPlotlyNumberFormat(t,s,i),o=ne.addTickSpacing(o,n,!1)),n.formatType===x.plot.AxisFormatType.CATEGORY&&(o?o.type="category":o={type:"category",tickformat:void 0,ticksuffix:void 0}),o}static addTickSpacing(e,t,n){const{gapBetweenMajorTicks:s}=t;if(s>0){const i=e||{};let o=s;return n&&(o=s/kS),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=ne.ORIENTATION.VERTICAL){return{type:e,mode:t,name:n,orientation:i,showlegend:s??void 0}}static makeSeriesDataFromSeries(e,t,n,s=null,i=_t){const{name:o,isLinesVisible:a,isShapesVisible:r,plotStyle:c,lineColor:h,shapeColor:u,sources:m,shape:p,shapeSize:g}=e,C=m.some(T=>T.axis?.businessCalendar),f=ne.getChartType(c,C),S=ne.getPlotlyChartMode(c,a??void 0,r??void 0),v=ne.getPlotlySeriesOrientation(e),w=ne.makeSeriesData(f,S,o,s,v);return ne.addSourcesToSeriesData(w,c,m,t),ne.addStylingToSeriesData(w,c,i,h,u,p,g,n),w}static addSourcesToSeriesData(e,t,n,s){const i=e;for(let o=0;o<n.length;o+=1){const a=n[o],{axis:r,type:c}=a,h=ne.getPlotlyProperty(t,c);bh(i,h,[]);const u=r!=null?ne.getAxisPropertyName(r.type):null;if(u!=null){const m=s.get(r.type);if(m){const p=m.indexOf(r),g=p>0?`${p+1}`:"";i[`${u}axis`]=`${u}${g}`}}}}static addStylingToSeriesData(e,t,n=_t,s=null,i=null,o=null,a=null,r=null){const c=e;if(c.marker={line:{}},c.line={width:1},t===x.plot.SeriesPlotStyle.AREA?c.fill="tozeroy":t===x.plot.SeriesPlotStyle.STACKED_AREA?c.stackgroup="stack":t===x.plot.SeriesPlotStyle.STEP?c.line.shape="hv":t===x.plot.SeriesPlotStyle.HISTOGRAM?(c.width=[],c.marker.line!==void 0&&Object.assign(c.marker.line,{color:n.paper_bgcolor,width:1})):t===x.plot.SeriesPlotStyle.OHLC?(c.increasing={line:{color:n.ohlc_increasing}},c.decreasing={line:{color:n.ohlc_decreasing}}):t===x.plot.SeriesPlotStyle.PIE?(c.textinfo="label+percent",c.outsidetextfont={color:n.title_color}):t===x.plot.SeriesPlotStyle.TREEMAP&&(c.hoverinfo="text",c.textinfo="label+text",c.tiling={packing:"squarify",pad:0},c.textposition="middle center",c.outsidetextfont={color:n.title_color}),s!=null&&(t===x.plot.SeriesPlotStyle.BAR?c.marker.color=s:c.line.color=s),i!=null&&(c.marker.color=i),o!=null&&o.length>0)try{c.marker.symbol=ne.getMarkerSymbol(o)}catch(h){so.warn("Unable to handle shape",o,":",h)}a!=null&&(c.marker.size=a*ne.DEFAULT_MARKER_SIZE),r!=null&&t!==x.plot.SeriesPlotStyle.PIE&&(c.visible=r)}static getMarkerSymbol(e){switch(e){case"SQUARE":return"square";case"CIRCLE":return"circle";case"DIAMOND":return"diamond";case"UP_TRIANGLE":return"triangle-up";case"DOWN_TRIANGLE":return"triangle-down";case"RIGHT_TRIANGLE":return"triangle-right";case"LEFT_TRIANGLE":return"triangle-left";case"ELLIPSE":case"HORIZONTAL_RECTANGLE":case"VERTICAL_RECTANGLE":default:throw new Error(`Unrecognized shape ${e}`)}}static getAxisFormats(e,t){const n=new Map,s={tickformat:null,ticksuffix:null},i=ne.getAllAxes(e),o=ne.groupArray(i,"type"),{charts:a}=e;for(let r=0;r<a.length;r+=1){const c=a[r];for(let h=0;h<c.series.length;h+=1){const u=c.series[h],{sources:m}=u,p=m.filter(g=>g.axis);for(let g=0;g<p.length;g+=1){const C=p[g],{axis:f}=C,{type:S}=f,v=o.get(S);M(v);const w=v.indexOf(f),T=ne.getAxisPropertyName(S);if(T!=null){const y=ne.getAxisLayoutProperty(T,w);if(n.has(y))so.debug(`${y} already added.`);else{so.debug(`Adding ${y} to axisFormats.`);const E=ne.getPlotlyAxisFormat(C,t);if(E===null)n.set(y,s);else{n.set(y,E);const{businessCalendar:I}=f;if(I!=null){const F=[],{businessPeriods:N,businessDays:H,holidays:P,timeZone:O}=I,k=t?.getColumnTypeFormatter(Cc);let L;Sc(k)&&(L=k.dhTimeZone);const A=L?(O.standardOffset-L.standardOffset)/60:0;P.length>0&&F.push(...ne.createRangeBreakValuesFromHolidays(P,O,L)),N.forEach(U=>F.push({pattern:"hour",bounds:[ne.periodToDecimal(U.close)+A,ne.periodToDecimal(U.open)+A]})),H.length<ds.length&&ne.createBoundsFromDays(H).forEach(U=>F.push({pattern:"day of week",bounds:U})),E.rangebreaks=F}if(n.size===c.axes.length)return n}}}}}}return n}static getChartType(e,t){switch(e){case x.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return ne.getPlotlyChartType(e,t)}}static getAxisPropertyName(e){switch(e){case x.plot.AxisType.X:return"x";case x.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(e){switch(e){case x.plot.AxisPosition.BOTTOM:return"bottom";case x.plot.AxisPosition.TOP:return"top";case x.plot.AxisPosition.LEFT:return"left";case x.plot.AxisPosition.RIGHT:return"right";default:return}}static getAllAxes(e){return e.charts.reduce((t,n)=>[...t,...n.axes],[])}static getChartForSeries(e,t){const{charts:n}=e;for(let s=0;s<n.length;s+=1){const i=n[s];for(let o=0;o<i.series.length;o+=1)if(t===i.series[o])return i}return null}static getLayoutRanges(e){const t={},n=Object.keys(e).filter(s=>s.indexOf("axis")>=0);for(let s=0;s<n.length;s+=1){const i=n[s],o=e[i];LS(o)&&(t[i]=[...o.range])}return t}static updateFigureAxes(e,t,n,s=0,i=0,o=_t){const a=e,r=ne.getAllAxes(t);for(let c=0;c<t.charts.length;c+=1){const h=t.charts[c],u=n?.(h),m=ne.getChartBounds(t,h,s,i);ne.updateLayoutAxes(a,h.axes,r,s,i,m,u,o)}ne.removeStaleAxes(a,r)}static getChartBounds(e,t,n,s){const{cols:i,rows:o}=e,{column:a,colspan:r,row:c,rowspan:h}=t,u=a+r,m=c+h,p=1/i,g=1/o,C=ne.AXIS_SIZE_PX/n,f=ne.AXIS_SIZE_PX/s,S={bottom:(o-m)*g+(m<o?f/2:0),top:(o-c)*g-(c>0?f/2:0),left:a*p+(a>0?C/2:0),right:u*p-(u<i?C/2:0)};return(ne.groupArray(t.axes,"position").get(x.plot.AxisPosition.RIGHT)??[]).length>0&&(n>0?S.right-=(S.right-S.left)*Math.max(0,Math.min(ne.LEGEND_WIDTH_PX/n,ne.MAX_LEGEND_SIZE)):S.right-=(S.right-S.left)*ne.DEFAULT_AXIS_SIZE),S}static updateLayoutAxes(e,t,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},a,r=_t){const c=s>0?Math.max(ne.MIN_AXIS_SIZE,Math.min(ne.AXIS_SIZE_PX/i,ne.MAX_AXIS_SIZE)):ne.DEFAULT_AXIS_SIZE,h=i>0?Math.max(ne.MIN_AXIS_SIZE,Math.min(ne.AXIS_SIZE_PX/s,ne.MAX_AXIS_SIZE)):ne.DEFAULT_AXIS_SIZE,u=e,m=ne.groupArray(t,"position"),p=ne.groupArray(t,"type"),g=[...p.keys()],C=ne.groupArray(n,"type");for(let f=0;f<g.length;f+=1){const S=g[f],v=ne.getAxisPropertyName(S);if(v!=null){const w=p.get(S),T=C.get(S),E=S===x.plot.AxisType.Y?i:s;M(w),M(T);for(let I=0;I<w.length;I+=1){const F=w[I],N=T.indexOf(F),H=ne.getAxisLayoutProperty(v,N);u[H]==null&&(u[H]=ne.makeLayoutAxis(S,r));const P=u[H];if(P!=null){ne.updateLayoutAxis(P,F,I,m,c,h,o);const{range:O,autorange:k}=P;if(a!=null&&O!==void 0&&(k===void 0||k===!1)){const L=a(F),[A,U]=L(O);so.debug("Setting downsample range",E,A,U),F.range(E,A,U)}else F.range(E)}}}}}static removeStaleAxes(e,t){const n=e,s=ne.groupArray(t,"type"),i=[...s.keys()];for(let o=0;o<i.length;o+=1){const a=i[o],r=s.get(a);M(r);let c=r.length;const h=ne.getAxisPropertyName(a);if(h!=null){let u=ne.getAxisLayoutProperty(h,c);for(;n[u]!=null;)delete n[u],c+=1,u=ne.getAxisLayoutProperty(h,c)}}}static getAxisLayoutProperty(e,t){const n=t>0?`${t+1}`:"";return`${e??""}axis${n}`}static updateLayoutAxis(e,t,n,s,i,o,a){const c=t.type===x.plot.AxisType.Y?o:i,h=e,u=t.label??"";if(h.title!==void 0&&typeof h.title!="string"?h.title.text=u:h.title={text:u},t.log&&(h.type="log"),h.side=ne.getAxisSide(t.position),n>0){h.overlaying=ne.getAxisPropertyName(t.type)??void 0;const m=s.get(t.position)??[],p=m.indexOf(t);p>0&&(h.anchor="free",t.position===x.plot.AxisPosition.RIGHT?h.position=a.right+(p-m.length+1)*c:t.position===x.plot.AxisPosition.TOP?h.position=a.top+(p-m.length+1)*c:t.position===x.plot.AxisPosition.BOTTOM?h.position=a.bottom+(m.length-p+1)*c:t.position===x.plot.AxisPosition.LEFT&&(h.position=a.left+(m.length-p+1)*c))}else if(t.type===x.plot.AxisType.X){const m=s.get(x.plot.AxisPosition.LEFT)||[],p=s.get(x.plot.AxisPosition.RIGHT)||[],g=Math.max(a.left,a.left+(m.length-1)*o),C=Math.min(a.right-(p.length-1)*o,a.right);h.domain=[g,C]}else if(t.type===x.plot.AxisType.Y){const m=s.get(x.plot.AxisPosition.BOTTOM)||[],p=s.get(x.plot.AxisPosition.TOP)||[],g=Math.max(a.bottom,a.bottom+(m.length-1)*i),C=Math.min(a.top-(p.length-1)*i,a.top);h.domain=[g,C]}}static periodToDecimal(e){const t=e.split(":");return Number(t[0])+Number(t[1])/60}static createBoundsFromDays(e){const t=e.map(o=>ds.indexOf(o)),n=ds.filter(o=>!e.includes(o)).map(o=>ds.indexOf(o)),s=new Set;n.forEach(o=>{for(let a=o+1;a<o+ds.length;a+=1){const r=a%ds.length;if(t.includes(r)){s.add(r);break}}});const i=[];return s.forEach(o=>{for(let a=o-1;a>o-ds.length;a-=1){const r=a<0?a+ds.length:a;if(t.includes(r)){const c=(r+1)%7;i.push([c,o]);break}}}),i}static createRangeBreakValuesFromHolidays(e,t,n){const s=[],i=[];return e.forEach(o=>{o.businessPeriods.length>0?i.push(...ne.createPartialHoliday(o,t,n)):s.push(ne.createFullHoliday(o,t,n))}),[{values:s},...i]}static createFullHoliday(e,t,n){return ne.adjustDateForTimeZone(`${e.date.toString()} 00:00:00.000000`,t,n)}static createPartialHoliday(e,t,n){const s=e.date.toString(),i=["00:00"];e.businessPeriods.forEach(a=>{i.push(a.open),i.push(a.close)}),i.push("24:00");const o=[];for(let a=0;a<i.length;a+=2){const r=i[a],c=i[a+1];if(r!==c){const h=[ne.adjustDateForTimeZone(`${s} ${r}:00.000000`,t,n)],u=MS*(ne.periodToDecimal(c)-ne.periodToDecimal(r));o.push({values:h,dvalue:u})}}return o}static adjustDateForTimeZone(e,t,n){return n&&n.standardOffset!==t.standardOffset?ne.unwrapValue(ne.wrapValue(e,Cc,t),n):e}static groupArray(e,t){return e.reduce((n,s)=>{const i=s[t],o=n.get(i)??[];return o.push(s),n.set(i,o),n},new Map)}static unwrapValue(e,t){if(e!=null){if(OS(e))return x.i18n.DateTimeFormat.format(ne.DATE_FORMAT,e,t);if(AS(e))return e.asNumber()}return e}static wrapValue(e,t,n=null){if(R.isDateType(t)&&typeof e=="string"){const s=e,i=ne.DATE_FORMAT.substr(0,e.length),o=x.i18n.DateTimeFormat.parse(i,s);if(!n)return o;const a=`${i} Z`,r=x.i18n.DateTimeFormat.format("Z",o,n),c=x.i18n.DateTimeFormat.parse(a,`${s} ${r}`),h=x.i18n.DateTimeFormat.format("Z",c,n);return x.i18n.DateTimeFormat.parse(a,`${s} ${h}`)}return e}static makeLayoutAxis(e,t=_t){const n={automargin:!0,gridcolor:t.gridcolor,linecolor:t.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:t.paper_bgcolor,tickfont:{color:t.zerolinecolor},title:{font:{color:t.title_color}}};return e===x.plot.AxisType.X?Object.assign(n,{showgrid:!0}):e===x.plot.AxisType.Y&&Object.assign(n,{zerolinecolor:t.zerolinecolor,zerolinewidth:2}),n}static getColorwayFromTheme(e=_t){let t=[];return e.colorway&&(Array.isArray(e.colorway)?t=e.colorway:typeof e.colorway=="string"?t=e.colorway.split(" "):so.warn(`Unable to handle colorway property: ${e.colorway}`)),t}static makeDefaultLayout(e=_t){const t={...e,autosize:!0,colorway:ne.getColorwayFromTheme(e),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:e.title_color},yanchor:"top",pad:{...ne.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:e.title_color}},margin:{...ne.DEFAULT_MARGIN},xaxis:ne.makeLayoutAxis(x.plot.AxisType.X,e),yaxis:ne.makeLayoutAxis(x.plot.AxisType.Y,e)};return t.datarevision=0,t}static hydrateSettings(e){return{...e,type:x.plot.SeriesPlotStyle[e.type]}}static titleFromSettings(e){const{series:t,xAxis:n,title:s=`${t.join(", ")} by ${n}`}=e;return s}static makeFigureSettings(e,t){const{series:n,xAxis:s,type:i}=e,o=ne.titleFromSettings(e),a={formatType:`${x.plot.AxisFormatType.NUMBER}`,type:`${x.plot.AxisType.X}`,position:`${x.plot.AxisPosition.BOTTOM}`},r={formatType:`${x.plot.AxisFormatType.NUMBER}`,type:`${x.plot.AxisType.Y}`,position:`${x.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${x.plot.ChartType.XY}`,axes:[a,r],series:n.map(c=>({plotStyle:`${i}`,name:c,dataSources:[{type:`${x.plot.SourceType.X}`,columnName:s,axis:a,table:t},{type:`${x.plot.SourceType.Y}`,columnName:c,axis:r,table:t}]}))}],title:o}}}const Je=ne;const cs=Z.module("Chart");class yi extends b.Component{static defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:et.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};static convertIcon(e){const[t,,,,n]=e.icon,s=`${n}`;return{width:t,path:s,ascent:t,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(e,t){return e?"Downsampling in progress...":t?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(e,t){return e?"animation-spin":t?void 0:"fill-active"}constructor(e){super(e),this.handleAfterPlot=this.handleAfterPlot.bind(this),this.handleDownsampleClick=this.handleDownsampleClick.bind(this),this.handleModelEvent=this.handleModelEvent.bind(this),this.handlePlotUpdate=this.handlePlotUpdate.bind(this),this.handleRelayout=this.handleRelayout.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.plot=X.createRef(),this.plotWrapper=X.createRef(),this.columnFormats=[],this.dateTimeFormatterOptions={},this.decimalFormatOptions={},this.integerFormatOptions={},this.isSubscribed=!1,this.isLoadedFired=!1,this.currentSeries=0,this.state={data:null,downsamplingError:null,isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,layout:{datarevision:0},revision:0}}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:e}=this.props;e&&this.subscribe()}componentDidUpdate(e){const{isActive:t,settings:n}=this.props;this.updateFormatterSettings(n),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}currentSeries;plot;plotWrapper;columnFormats;dateTimeFormatterOptions;decimalFormatOptions;integerFormatOptions;rect;ranges;isSubscribed;isLoadedFired;getCachedConfig=fe((e,t,n,s)=>{const i=[],o=Boolean(e);if(o&&i.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:yi.convertIcon(Nh),attr:"fill-warning"}),t||n||s||o){const a=yi.downsampleButtonTitle(n,s),r=yi.downsampleButtonAttr(n,s),c=n?Ap:Lp;i.push({name:a,icon:yi.convertIcon(c),click:this.handleDownsampleClick,attr:r})}return{displaylogo:!1,displayModeBar:n||o?!0:"hover",modeBarButtons:[i,["toImage"],["zoom2d","pan2d"],["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]]}});getPlotRect(){return this.plotWrapper.current?.getBoundingClientRect()??null}initData(){const{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:{...t,...e.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:e}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){cs.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(cs.debug2("Received data update",t,n),t){case Wn.EVENT_UPDATED:{this.currentSeries+=1,this.setState(i=>{const{layout:o,revision:a}=i;return typeof o.datarevision=="number"&&(o.datarevision+=1),{data:n,layout:o,revision:a+1}});const{onUpdate:s}=this.props;s({isLoading:!this.isLoadedFired});break}case Wn.EVENT_LOADFINISHED:{const{onUpdate:s}=this.props;this.isLoadedFired=!0,s({isLoading:!1});break}case Wn.EVENT_DISCONNECT:{const{onDisconnect:s}=this.props;s();break}case Wn.EVENT_RECONNECT:{const{onReconnect:s}=this.props;s();break}case Wn.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case Wn.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case Wn.EVENT_DOWNSAMPLENEEDED:case Wn.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:cs.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,n=Je.getLayoutRanges(t);!it(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(e){if(cs.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,n=[...e.hiddenlabels];t({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([e,t]){if(cs.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:a,visible:r})=>a!=null&&r==="legendonly"?[...o,a]:o,[]);s({hiddenSeries:i})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){cs.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=Jn.getColumnFormats(e),n=Jn.getDateTimeFormatterOptions(e),{decimalFormatOptions:s={},integerFormatOptions:i={}}=e;(!it(this.columnFormats,t)||!it(this.dateTimeFormatterOptions,n)||!it(this.decimalFormatOptions,s)||!it(this.integerFormatOptions,i))&&(this.columnFormats=Jn.getColumnFormats(e),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const e=new Zt(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:t}=this.props;t.setFormatter(e)}updateDimensions(){const e=this.getPlotRect();this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&Ia.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{cs.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:n,isDownsampleInProgress:s,isDownsamplingDisabled:i,layout:o,revision:a}=this.state,r=this.getCachedConfig(t,n,s,i),c=e!=null;return l.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:c&&l.jsx(su,{ref:this.plot,data:e,layout:o,revision:a,config:r,onAfterPlot:this.handleAfterPlot,onError:cs.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}}const PS=yi,Rt=Z.module("FigureChartModel");class Wl extends Wn{static ADD_SERIES_DEBOUNCE=50;constructor(e,t={},n=_t){super(),this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.figure=e,this.settings=t,this.theme=n,this.data=[];const s={data:{},layout:Je.makeDefaultLayout(n)};this.layout={grid:{rows:e.rows,columns:e.cols,pattern:"independent"},template:s},this.seriesDataMap=new Map,this.pendingSeries=[],this.oneClicks=[],this.filterColumnMap=new Map,this.lastFilter=new Map,this.isConnected=!0,this.seriesToProcess=new Set,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure()}figure;settings;theme;data;layout;seriesDataMap;pendingSeries;oneClicks;filterColumnMap;lastFilter;isConnected;seriesToProcess;close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=Je.getAllAxes(this.figure),n=[];for(let o=0;o<e.length;o+=1){const a=e[o];for(let r=0;r<a.series.length;r+=1){const c=a.series[r];n.push(c.name),this.addSeries(c,t,a.showLegend)}}const i=[...this.seriesDataMap.keys()].filter(o=>n.indexOf(o)<0);for(let o=0;o<i.length;o+=1){const a=i[o];this.seriesDataMap.delete(a)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,n){const s=Je.groupArray(t,"type"),i=Je.makeSeriesDataFromSeries(e,s,Je.getSeriesVisibility(e.name,this.settings),n,this.theme);if(this.seriesDataMap.set(e.name,i),this.data=[...this.seriesDataMap.values()],e.plotStyle===x.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===x.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=Je.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===x.plot.SeriesPlotStyle.PIE?n??void 0:!1,e.oneClick!=null){const{oneClick:o}=e,{columns:a}=o;for(let r=0;r<a.length;r+=1)this.filterColumnMap.set(a[r].name,a[r]);this.oneClicks.push(o)}this.updateLayoutFormats()}addPendingSeries=Ye(()=>{const e=Je.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=[]},Wl.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){Rt.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?x.plot.DownsampleOptions.DISABLE:x.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(x.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(x.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(x.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(x.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(x.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(x.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(x.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(x.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(x.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(x.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(x.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(x.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(x.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(x.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(x.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(x.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(x.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(x.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}getTimeZone=pe((e,t)=>{if(t!=null){const n=t.getColumnTypeFormatter(e);if(n!=null)return n.dhTimeZone}});getValueTranslator=pe((e,t)=>{const n=this.getTimeZone(e,t);return s=>Je.unwrapValue(s,n)});getValueParser=pe((e,t)=>{const n=this.getTimeZone(e,t);return s=>Je.wrapValue(s,e,n)});getRangeParser=pe((e,t)=>n=>{let[s,i]=n;const o=this.getValueParser(e,t);return s=o(s),i=o(i),[s,i]});getAxisRangeParser=pe((e,t)=>n=>{const s=Je.getSourceForAxis(e,n);return s?this.getRangeParser(s.columnType,t):i=>i});handleDownsampleStart(e){Rt.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){Rt.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){Rt.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){Rt.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:n}=t;Rt.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];Rt.debug2("handleFigureUpdated updating series",o.name);const{sources:a}=o;for(let r=0;r<a.length;r+=1){const c=a[r],{columnType:h,type:u}=c,m=this.getValueTranslator(h,this.formatter),p=t.getArray(o,u,m);this.setDataArrayForSeries(o,u,p)}this.seriesToProcess.delete(o.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(o)}const{data:s}=this;this.fireUpdate(s)}handleRequestFailed(e){Rt.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){Rt.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){Rt.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;Rt.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=Je.DEFAULT_MARGIN.t+t*Je.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=Je.DEFAULT_TITLE_PADDING.t+t*Je.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();Je.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;Je.getAxisFormats(this.figure,this.formatter).forEach((t,n)=>{Rt.debug(`Assigning ${n}`,this.layout[n],t);const s=this.layout[n];s!=null?Object.assign(s,t):Rt.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(e,t,n){const{name:s,plotStyle:i}=e,o=this.seriesDataMap.get(s),a=Je.getPlotlyProperty(i,t);o&&bh(o,a,n)}cleanSeries(e){const{name:t,plotStyle:n}=e,s=this.seriesDataMap.get(t);if(s!=null){if(n===x.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:i,xHigh:o}=s;if(i&&o&&i.length===o.length){const a=[];for(let r=0;r<i.length;r+=1)a.push(o[r]-i[r]);s.width=a}}else if(n===x.plot.SeriesPlotStyle.LINE){const{x:i,xLow:o,xHigh:a,y:r,yLow:c,yHigh:h}=s;o&&a&&o!==i&&(s.error_x=Je.getPlotlyErrorBars(i,o,a)),c&&h&&c!==r&&(s.error_y=Je.getPlotlyErrorBars(r,c,h))}else if(n===x.plot.SeriesPlotStyle.TREEMAP){const{ids:i,labels:o}=s;i!==void 0&&o===void 0&&(s.labels=i)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){Rt.warn("Trying to set a filter, but no one click!");return}Rt.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 a=e.get(o);this.lastFilter.get(o)!==a&&s.find(r=>r.name===o)!=null&&n.setValueForColumn(o,a)})}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 bc=Wl;class Gl{static async makeModelFromSettings(e,t,n=_t){const s=await Gl.makeFigureFromSettings(e,t);return new bc(s,e,n)}static async makeFigureFromSettings(e,t){const n=await t.copy();return n.applyCustomColumns(t.customColumns),n.applyFilter(t.filter),n.applySort(t.sort),x.plot.Figure.create(Je.makeFigureSettings(e,n))}static async makeModel(e,t,n=_t){return new bc(t,e,n)}}const Aa=Gl;function wc(d){return d.setFigure!==void 0}function _S({connection:d,defaultUpdateInterval:e,hoverUpdateInterval:t,bgMonitoring:n=!0,monitorDuration:s}){const[i,o]=b.useState({freeMemory:0,maximumHeapSize:999,totalHeapSize:0}),[a,r]=b.useState(!1),c=b.useRef({timestamps:[],usages:[]});b.useEffect(function(){const P=async()=>{const k=await d.getWorkerHeapInfo();if(o(k),n||a){const L=(k.totalHeapSize-k.freeMemory)/k.maximumHeapSize,A=Date.now(),{timestamps:U,usages:j}=c.current;for(;U.length!==0&&A-U[0]>s*1.5;)U.shift(),j.shift();U.push(A),j.push(L)}else c.current={timestamps:[],usages:[]}};P();const O=setInterval(P,a?t:e);return()=>{clearInterval(O)}},[a,t,d,e,s,n]);const h=(H,P)=>Math.round(H*10**P)/10**P,u=2,m=1024**3,{freeMemory:p,totalHeapSize:g,maximumHeapSize:C}=i,f=h(p/m,u),S=h(g/m,u),v=h(C/m,u),w=S-f,T=(H,P,O=!1)=>l.jsxs("div",{className:$("heap-usage-info-row",{"heading-bottom-border":O}),children:[l.jsx("div",{className:"font-weight-bold",children:H}),l.jsx("div",{children:P})]}),{timestamps:y,usages:E}=c.current,I=y[y.length-1]??0,F=g/C,N=(g-p)/C;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"max-memory",children:[l.jsx("div",{className:"total-memory",style:{width:`calc(${F*100}% - ${F*2}px`}}),l.jsx("div",{className:$("used-memory",{"heap-overflow":(g-p)/C>.95}),style:{width:`calc(${N*100}% - ${N*2}px`}}),l.jsxs("div",{className:"memory-text",children:[v.toFixed(1)," GB"]})]}),l.jsx(tt,{onEntered:()=>r(!0),onExited:()=>r(!1),interactive:!0,children:l.jsxs("div",{className:"heap-tooltip",children:[T("In use:",`${w.toFixed(u)} of ${v.toFixed(u)} GB`,!0),T("Free:",`${f.toFixed(u)} GB`),T("Total:",`${S.toFixed(u)} GB`),T("Max:",`${v.toFixed(u)} GB`),l.jsx("div",{className:"heap-plot",children:l.jsx(su,{data:[{x:[...y],y:[...E],type:"scatter",mode:"lines"}],config:{staticPlot:!0,responsive:!0},style:{width:"196px",height:"100px"},layout:{legend:!1,margin:{l:2,t:2,r:2,b:2},plot_bgcolor:"transparent",paper_bgcolor:"transparent",colorway:["#4878ea"],xaxis:{dtick:Math.round(s/6),gridcolor:_t.linecolor,range:[I-s,I],linecolor:_t.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:_t.linecolor,range:[0,1],linecolor:_t.linecolor,linewidth:2,mirror:!0}}})}),l.jsxs("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(s/1e3/60)," min."]})]})})]})}const zl=Object.freeze({}),jS=new Map,iu=d=>d.user,Kl=d=>d.storage,ou=d=>Kl(d).commandHistoryStorage,au=d=>Kl(d).fileStorage,HS=d=>Kl(d).workspaceStorage,dr=d=>d.workspace,Ct=d=>dr(d).data.settings,ru=d=>Ct(d).defaultDateTimeFormat,lu=d=>Ct(d).defaultDecimalFormatOptions??zl,du=d=>Ct(d).defaultIntegerFormatOptions??zl,cu=d=>Ct(d).formatter,Ao=d=>Ct(d).timeZone,hu=d=>Ct(d).showTimeZone,uu=d=>Ct(d).showTSeparator,mu=d=>Ct(d).truncateNumbersWithPound,BS=d=>Ct(d).shortcutOverrides,VS=d=>Ct(d).defaultNotebookSettings??zl,cr=d=>d.activeTool,US=d=>d.plugins??jS,pu="SET_ACTIVE_TOOL",gu="SET_COMMAND_HISTORY_STORAGE",fu="SET_FILE_STORAGE",Cu="SET_PLUGINS",Su="SET_USER",bu="SET_WORKSPACE",wu="SET_WORKSPACE_STORAGE",vu="SET_SERVER_CONFIG_VALUES",$S=d=>({type:Su,payload:d}),Tu=d=>({type:bu,payload:d}),WS=d=>({type:wu,payload:d}),GS=d=>({type:gu,payload:d}),zS=d=>({type:fu,payload:d}),KS=d=>(e,t)=>{e(Tu(d));const{storage:n}=t(),{workspaceStorage:s}=n;return s.save(d)},Eu=d=>(e,t)=>{const{workspace:n}=t(),{data:s}=n,i={...n,data:{...s,...d}};return e(KS(i))},hr=d=>e=>e(Eu({settings:d})),ur=d=>({type:pu,payload:d}),qS=d=>({type:Cu,payload:d}),YS=d=>({type:vu,payload:d});function yu(d,e){return(t=e,n)=>{switch(n.type){case d:{const s=n.payload;return s==null?null:t!=null?{...t,...s}:{...s}}default:return t}}}function XS(d,e={},t=!0){return(n=e,s)=>{switch(s.type){case d:{const{id:i,payload:o}=s;return t&&it({payload:o},{payload:n[i]})?n:{...n,[i]:o}}default:return n}}}function Ls(d,e){return(t=e,n)=>{switch(n.type){case d:return n.payload;default:return t}}}const ZS=Ls(pu,null),QS=Ls(Cu,null),JS=Ls(gu,null),eb=Ls(fu,null),tb=Ls(wu,null),nb=Tl({commandHistoryStorage:JS,fileStorage:eb,workspaceStorage:tb}),sb=yu(Su,null),ib=yu(bu,null),ob=Ls(vu,null),ab={activeTool:ZS,plugins:QS,storage:nb,user:sb,workspace:ib,serverConfigValues:ob};class rb{reducers={};listener=null;register(e,t){this.reducers={...this.reducers,[e]:t},this.listener?.(this.reducers)}setListener(e){this.listener=e}}const Gi=new rb,vc=Z.module("redux-logger"),lb=d=>e=>t=>{vc.debug("dispatching",t);const n=e(t);return vc.debug("next state",d.getState()),n},db=Z.module("redux-crashReporter"),cb=d=>e=>t=>{try{return e(t)}catch(n){throw db.error("Error executing",t," with state ",d.getState(),":",n),n}},hb=[lb,cb,Vm];Object.entries(ab).map(([d,e])=>Gi.register(d,e));const ub=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__??Wm,mr=Um(Tl(Gi.reducers),ub($m(...hb)));Gi.setListener(d=>{mr.replaceReducer(Tl(d))});const xu=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 Ru(d){return d.componentName!==void 0}function mb(d){return d.component!==void 0}const Iu=Object.freeze({type:"default",isClosable:!0,isFocusOnShow:!0,reorderEnabled:!0,title:""}),pb=Object.freeze(Object.defineProperty({__proto__:null,defaultConfig:xu,isGLComponentConfig:Ru,isReactComponentConfig:mb,itemDefaultConfig:Iu},Symbol.toStringTag,{value:"Module"}));class Bt{static ALL_EVENT="__all";_mSubscriptions;constructor(){this._mSubscriptions={},this._mSubscriptions[Bt.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[Bt.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}class ll extends Bt{width;height;title;parent;layoutManager;tab;_config;isHidden=!1;beforeCloseHandler;_element=me(['<div class="lm_item_container">','<div class="lm_content" tabindex="-1"></div>',"</div>"].join(""));_contentElement;constructor(e,t,n){super(),this.title=Ru(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,a=(this[i]??0)*(1/((s.config[i]??0)/100)),r=o/a*100,c=((s.config[i]??0)-r)/(n.contentItems.length-1);for(let h=0;h<n.contentItems.length;h++)n.contentItems[h]===s?n.contentItems[h].config[i]=r:n.contentItems[h].config[i]=(n.contentItems[h].config[i]??0)+c;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(me.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 gb=Object.freeze(Object.defineProperty({__proto__:null,Container:ll,ItemContainer:ll},Symbol.toStringTag,{value:"Module"}));function Du(d){var e=location.hash.match(new RegExp(d+"=([^&]*)"));return e?e[1]:null}function Fu(d){if(window.location.hash)return Du(d);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[d]||null}function pr(d){return window.requestAnimationFrame(d)}function fb(d,e){var t=e.indexOf(d);if(t===-1)throw new Error("Can't remove item from array. Item is not in the array");e.splice(t,1)}function ql(){return(Math.random()*1e15).toString(36).replace(".","")}function Cb(d,e){var t=d.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 Yl(d){return me.trim(d.replace(/(<([^>]+)>)/gi,""))}class Lo extends Bt{_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=me(document),this._eBody=me(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}}}class Nu{_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(){Pi.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(){Pi.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=me.extend(e,this._container._config.props);return X.createElement(this._reactClass,t)}}const La=["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"],Sb=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"];function Xl(d){if(La.length>36)throw new Error("Too many keys in config minifier map");const e={};return Zl(d,e,"_min"),e}function dl(d){if(La.length>36)throw new Error("Too many keys in config minifier map");const e={};return Zl(d,e,"_max"),e}function Zl(d,e,t){const n=t==="_min"?bb:wb;for(let s in d){if(!d.hasOwnProperty(s))continue;const i=Array.isArray(d)?d[Number.parseInt(s,10)]:d[s];if(typeof i=="object"&&i!=null){const o=i instanceof Array?[]:{};if(Array.isArray(e))e[Number.parseInt(s,10)]=o;else{const a=n(s,La);e[a]=o}Zl(i,o,t)}else{const o=n(i,Sb);if(Array.isArray(e))e[Number.parseInt(s,10)]=o;else{const a=n(s,La);e[a]=o}}}}function bb(d,e){if(typeof d=="string"&&d.length===1)return"___"+d;var t=e.indexOf(d);return t===-1?d:t.toString(36)}function wb(d,e){return typeof d=="string"&&d.length===1?e[parseInt(d,36)]:typeof d=="string"&&d.substr(0,3)==="___"?d[3]:d}class cl{name;origin;isPropagationStopped;constructor(e,t){this.name=e,this.origin=t,this.isPropagationStopped=!1}stopPropagation(){this.isPropagationStopped=!0}}let Mu=class extends Bt{_layoutManager;_dontPropagateToParent;_childEventSource;_boundOnEventFromChild;constructor(e){super(),this._layoutManager=e,this._dontPropagateToParent=null,this._childEventSource=null,this.on(Bt.ALL_EVENT,this._onEventFromThis.bind(this)),this._boundOnEventFromChild=this._onEventFromChild.bind(this),me(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(){me(window).off("gl_child_event",this._boundOnEventFromChild)}};const vb=Object.freeze(Object.defineProperty({__proto__:null,BubblingEvent:cl,DragListener:Lo,EventEmitter:Bt,EventHub:Mu,ReactComponentHandler:Nu,animFrame:pr,filterXss:Cb,getHashValue:Du,getQueryStringParam:Fu,getUniqueId:ql,minifyConfig:Xl,removeFromArray:fb,stripTags:Yl,unminifyConfig:dl},Symbol.toStringTag,{value:"Module"}));class ku extends Bt{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=me.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;me(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-"+ql();e=Xl(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 zi extends Bt{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=me(zi._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",Yl(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(),this._setDimensions(),me(document.body).append(this.element),!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 a=this._layoutManager.container.offset();this._minX=a?.left??0,this._minY=a?.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 Ou{_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 Lo(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(me.extend(!0,{},n)),i=new zi(e,t,this._dragListener,this._layoutManager,s,null);this._layoutManager.transitionIndicator?.transitionElements(this._element,i.element)}}class Au{_element=me(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 Lo(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(me.extend(!0,{},n));new zi(e,t,this._dragListener,this._layoutManager,s,null)}}}class gr{static _template='<div class="lm_dropTargetIndicator"><div class="lm_inner"></div></div>';element=me(gr._template);constructor(){me(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 go{element;_header;_action;constructor(e,t,n,s){this._header=e,this.element=me('<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 ti extends Error{node;constructor(e,t){super(),this.name="Configuration Error",this.message=e,this.node=t}}const Tb=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationError:ti},Symbol.toStringTag,{value:"Module"}));function yo(d){return d.isStack}function dn(d){return d.isComponent}function Lu(d){return d.isRoot}class pt extends Bt{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(Bt.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,yo(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&&dn(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 cl(e,this);this.emit(e,t)}_createContentItems(e){var t;if(!(e.content instanceof Array))throw new ti("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(Iu)){const s=t;e[s]===void 0&&(e[s]=n)}return e}_propagateEvent(e,t){t instanceof cl&&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,pr(this._propagateEventToLayoutManager.bind(this,e,t)))}_propagateEventToLayoutManager(e,t){this._pendingEventPropagations[e]=!1,this.layoutManager.emit(e,t)}}class Pu extends pt{config;componentName;container;parent;instance;constructor(e,t,n){super(e,t,n,me()),this.config=t,this.parent=n;const s=e.getComponent(this.config.componentName)||e.getFallbackComponent(),i=me.extend(!0,{},this.config.componentState||{});if(s==null)throw new ti('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 ll(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(){pt.prototype._$init.call(this),this.container.emit("open")}_$hide(){this.container.hide(),pt.prototype._$hide.call(this)}_$show(){this.container.show(),this.container._config.isFocusOnShow&&this.container._contentElement[0].focus({preventScroll:!0}),pt.prototype._$show.call(this)}_$destroy(){this.container.emit("destroy",this),pt.prototype._$destroy.call(this)}_$getArea(){return null}}class Pa extends pt{isRow;isColumn;childElementContainer;parent;_splitter=[];_splitterSize;_splitterGrabSize;_isColumn;_dimension;_splitterPosition=null;_splitterMinPosition=null;_splitterMaxPosition=null;constructor(e,t,n,s){super(t,n,s,me('<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,a;if(e=this.layoutManager._$normalizeContentItem(e,this),t===void 0&&(t=this.contentItems.length),this.contentItems.length>0?(a=this._createSplitter(Math.max(0,t-1)).element,t>0?(this.contentItems[t-1].element.after(a),a.after(e.element)):(this.contentItems[0].element.before(a),a.before(e.element))):this.childElementContainer.append(e.element),pt.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,a;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));pt.prototype.removeChild.call(this,e,t),this.contentItems.length===1&&this.config.isClosable===!0?(a=this.contentItems[0],this.contentItems=[],this.parent.replaceChild(this,a,!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(pt.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 a=0;a<this.contentItems.length;a++){const r=this._isColumn?Math.floor(n*((this.contentItems[a].config.height??0)/100)):Math.floor(t*((this.contentItems[a].config.width??0)/100));s+=r,i.push(r)}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 a;if(this._isColumn||!e||this.contentItems.length<=1)return;const r=this._calculateAbsoluteSizes();for(let h=0;h<this.contentItems.length;h++){this.contentItems[h];const u=r.itemSizes[h];u<e?(s+=e-u,a={width:e}):(n+=u-e,a={width:u},t.push(a)),o.push(a)}if(s===0||s>n)return;const c=s/n;i=s;for(let h=0;h<t.length;h++){a=t[h];const u=Math.round((a.width-e)*c);i-=u,a.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/r.totalWidth*100}_createSplitter(e){var t;return t=new _u(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??[]),a=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)-(a||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}),pr(this.callDownwards.bind(this,"setSize",void 0,void 0,void 0))}}class hl extends pt{childElementContainer;_containerElement;constructor(e,t,n){super(e,{...t,type:"root"},null,me('<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(dn(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",a=s==="left"||s==="top",r=this.contentItems[0];if(!(r instanceof Pa)||r.type!=i){const c=this.layoutManager.createContentItem({type:i},this);this.replaceChild(r,c),c.addChild(e,a?0:void 0,!0),c.addChild(r,a?void 0:0,!0),r.config[o]=50,e.config[o]=50,c.callDownwards("setSize")}else{const c=r.contentItems[a?0:r.contentItems.length-1];r.addChild(e,a?0:void 0,!0),c.config[o]=(c.config[o]??0)*.5,e.config[o]=c.config[o],r.callDownwards("setSize")}}}}class ul extends pt{_activeContentItem=null;_header;childElementContainer=me('<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,me('<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 Mi(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(){pt.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",a=t?"height":"width";if(dn(e)){const r=this.layoutManager.createContentItem({type:"stack",header:e.config.header||{}},this);r._$init(),r.addChild(e),e=r}if(i){const r=this.parent.contentItems.indexOf(this);this.parent.addChild(e,s?r:r+1,!0),this.config[a]=(this.config[a]??0)*.5,e.config[a]=this.config[a],this.parent.callDownwards("setSize")}else{const r=this.layoutManager.createContentItem({type:o},this);this.parent.replaceChild(this,r),r.addChild(e,s?0:void 0,!0),r.addChild(this,s?void 0:0,!0),this.config[a]=50,e.config[a]=50,r.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,a;if(!(i.left<e&&e<i.right)){for(var r=0;r<t;r++)if(o=this.header.tabs[r].element,a=o.get(0)?.getBoundingClientRect(),a&&a.left<e&&e<a.right){this._dropIndex=r;break}o&&a&&e<a.left+a.width*.5?o.before(this.layoutManager.tabDropPlaceholder):o&&(this._dropIndex=Math.min((this._dropIndex??0)+1,t),o.after(this.layoutManager.tabDropPlaceholder))}let c=this.layoutManager.tabDropPlaceholder.offset()?.left??0;c=Math.max(c,this.header.tabsContainer.offset()?.left??0);var h=c+(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:c,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 Eb=Object.freeze(Object.defineProperty({__proto__:null,AbstractContentItem:pt,Component:Pu,ContentItem:pt,Root:hl,RowOrColumn:Pa,Stack:ul,isComponent:dn,isRoot:Lu,isStack:yo},Symbol.toStringTag,{value:"Module"}));class fr{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=me(fr._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 Lo(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),dn(this.contentItem)&&(this.contentItem.container._contentElement.on("focusin",this._onTabContentFocusIn).on("focusout",this._onTabContentFocusOut),this.contentItem.container._contentElement[0].addEventListener("click",this._onTabContentFocusIn,!0),this.contentItem.container.tab=this,this.contentItem.container.emit("tab",this))}setTitle(e=""){this.titleElement.html(e)}setActive(e){e!==this.isActive&&(this.isActive=e,e?this.element.addClass("lm_active"):this.element.removeClass("lm_active"))}_$destroy(){this.element.off("click",this._onTabClick),this.element.off("auxclick",this._onTabClick),this.closeElement.off("click",this._onCloseClick),dn(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 zi(e,t,this._dragListener,this._layoutManager,this.contentItem,this.header.parent)}_onTabContentFocusIn(){dn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.contentItem.container._contentElement[0].focus(),this.element.addClass("lm_focusin")}_onTabContentFocusOut(){dn(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&&dn(this.contentItem)?(this.header.parent.setActiveContentItem(this.contentItem),this.contentItem.container.emit("tabClicked")):dn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&(this.contentItem.container._contentElement.focus(),this.contentItem.container.emit("tabClicked")),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(),dn(this.contentItem)?this.contentItem.container.close():this.header.parent.removeChild(this.contentItem)}_onCloseMousedown(e){e.stopPropagation()}}class Mi extends Bt{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=me(Mi._template);tabsContainer;tabDropdownContainer;tabDropdownSearch;tabDropdownList=null;controlsContainer;parent;tabs=[];activeContentItem=null;closeButton=null;tabDropdownButton=null;tabNextButton=me(Mi._nextButtonTemplate);tabPreviousButton=me(Mi._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 fr(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(a=>{var r=s||a,c=a-r,h=this.START_SPEED*c+.5*this.ACCELERATION*(c*c);h=Math.min(h,this.tabsContainer.get(0)?.scrollWidth??1/0),this._handleScrollRepeat(e,t,h,r)})}_$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(),me(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 go(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 go(this,n,"lm_popout",t)),this._getHeaderSetting("maximise")){s=this.parent.toggleMaximise.bind(this.parent);const o=this._getHeaderSetting("maximise"),a=this._getHeaderSetting("minimise"),r=new go(this,o,"lm_maximise",s);this.parent.on("maximised",function(){r.element.attr("title",a??"")}),this.parent.on("minimised",function(){r.element.attr("title",o??"")})}this._isClosable()&&(e=this.parent.remove.bind(this.parent),n=this._getHeaderSetting("close"),this.closeButton=new go(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"),me(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(),me(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)-(me(window).scrollTop()??0);t+e>(me(window).height()??0)&&this.tabDropdownContainer.css("max-height",(me(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 _u{_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 Lo(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=me('<div class="lm_drag_handle"></div>'),t=me('<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 ju{_element=me('<div class="lm_transition_indicator"></div>');_toElement=null;_fromDimensions={};_totalAnimationDuration=200;_animationStartTime=null;constructor(){me(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),pr(this._nextAnimationFrame.bind(this))}_measure(e){const t=e.offset();return{left:t?.left,top:t?.top,width:e.outerWidth(),height:e.outerHeight()}}}const yb=Object.freeze(Object.defineProperty({__proto__:null,BrowserPopout:ku,DragProxy:zi,DragSource:Ou,DragSourceFromEvent:Au,DropTargetIndicator:gr,Header:Mi,HeaderButton:go,Splitter:_u,Tab:fr,TransitionIndicator:ju},Symbol.toStringTag,{value:"Module"})),xb={config:pb,container:gb,controls:yb,errors:Tb,items:Eb,utils:vb};class Hu extends Bt{static __lm=xb;static minifyConfig(e){return Xl(e)}static unminifyConfig(e){return dl(e)}isInitialised=!1;_isFullPage=!1;_resizeTimeoutId;_components={"lm-react-component":Nu};_fallbackComponent;_itemAreas=[];_maximisedItem=null;_maximisePlaceholder=me('<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 Mu(this);config;container;_originalContainer;dropTargetIndicator=null;transitionIndicator=null;tabDropPlaceholder=me('<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&&me("body").css("visibility","hidden"),this._typeToItem={column:Pa.bind(this,!0),row:Pa.bind(this,!1),stack:ul,component:Pu}}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 pt))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){me(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 gr,this.transitionIndicator=new ju,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(),me(window).off("resize",this._onResize),me(window).off("unload beforeunload",this._onUnload),me(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 ti("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 ti(n);return e.type==="component"&&!(t instanceof ul)&&t&&!(this.isSubWindow===!0&&t instanceof hl)&&(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 pt,a=this;if(o){i=this.toConfig(e).content,n=ql();let c=e.parent,h=e;for(;c?.contentItems.length===1&&!c.isRoot;)h=c,c=c.parent;c?.addId(n),(s==null||Number.isNaN(s))&&(s=c?.contentItems.indexOf(h))}else e instanceof Array?i=e:i=[e];if(!t&&o){const c=window.screenX||window.screenLeft,h=window.screenY||window.screenTop,u=e.element.offset()??{left:0,top:0};t={left:c+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 r=new ku(i,t,n,s,this);return r.on("initialised",function(){a.emit("windowOpened",r)}),r.on("closed",function(){a._$reconcilePopoutWindows()}),this.openPopouts.push(r),r}createDragSource(e,t){this.config.settings.constrainDragToContainer=!1;var n=new Ou(e,t,this);return this._dragSources.push(n),n}createDragSourceFromEvent(e,t){return this.config.settings.constrainDragToContainer=!1,new Au(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(!yo(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 pt)return e;if(me.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&&me(window).resize(this._onResize),me(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=Fu("gl-window");t&&(this.isSubWindow=!0,e=JSON.parse(localStorage.getItem(t)||"{}"),e=dl(e),localStorage.removeItem(t)),e=me.extend(!0,{},xu,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=me('<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=Yl(this.config.content[0].title??""),me("head").append(me("body link, body style, template, .gl_keep")),this.container=me("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?me(this._originalContainer):me("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,me("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 ti(t,e);if(e.content.length>1)throw t="Top level content can't contain more then one element.",new ti(t,e);this.root=new hl(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],a=this._findAllStackContainers()[0],r=0;r<i;r++){var c=o.contentItems[o.contentItems.length-1];this._addChildContentItemsToContainer(a,c)}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=>{yo(n)?e.push(n):n.isComponent||this._findAllStackContainersRecursive(e,n)})}}const Rb="_lm_root_15d73_3",Ib="_lm_row_15d73_7",Db="_lm_item_15d73_7",Fb="_lm_content_15d73_11",Nb="_lm_dragging_15d73_17",Mb="_lm_maximised_15d73_23",kb="_lm_maximise_placeholder_15d73_30",Ob="_lm_splitter_15d73_34",Ab="_lm_vertical_15d73_41",Lb="_lm_drag_handle_15d73_41",Pb="_lm_horizontal_15d73_46",_b="_lm_header_15d73_56",jb="_lm_dropdown_open_15d73_63",Hb="_lm_controls_15d73_69",Bb="_lm_tabs_15d73_89",Vb="_lm_tab_15d73_89",Ub="_lm_title_15d73_104",$b="_lm_close_tab_15d73_111",Wb="_lm_stack_15d73_120",Gb="_lm_left_15d73_120",zb="_lm_right_15d73_121",Kb="_lm_dragProxy_15d73_125",qb="_lm_items_15d73_148",Yb="_lm_tabdropdown_list_15d73_165",Xb="_lm_bottom_15d73_192",Zb="_lm_drop_tab_placeholder_15d73_207",Qb="_lm_tabdropdown_15d73_165",Jb="_lm_dropTargetIndicator_15d73_258",ew="_lm_inner_15d73_264",tw="_lm_transition_indicator_15d73_272",nw="_lm_popin_15d73_282",sw="_lm_bg_15d73_297",iw="_lm_icon_15d73_300",ow="_lm_goldenlayout_15d73_304",aw="_lm_selectable_15d73_340",rw="_lm_active_15d73_370",lw="_lm_selected_15d73_388",dw="_lm_keyboard_active_15d73_397",cw="_lm_popout_15d73_416",hw="_lm_maximise_15d73_23",uw="_lm_close_15d73_111",mw="_lm_tabnextbutton_15d73_425",pw="_lm_tabpreviousbutton_15d73_428",gw="_lm_title_before_15d73_544",fw="_lm_focusin_15d73_568",Cw="_lm_window_blur_15d73_573",Sw="_lm_tabdropdown_search_15d73_631",bw="_march_15d73_1",ww="_app_15d73_712",vw="_plotly_15d73_721",Tc={"tab-height":"28px","drag-border-width":"5px",lm_root:Rb,lm_row:Ib,lm_item:Db,lm_content:Fb,lm_dragging:Nb,lm_maximised:Mb,lm_maximise_placeholder:kb,lm_splitter:Ob,lm_vertical:Ab,lm_drag_handle:Lb,lm_horizontal:Pb,lm_header:_b,lm_dropdown_open:jb,lm_controls:Hb,lm_tabs:Bb,lm_tab:Vb,lm_title:Ub,lm_close_tab:$b,lm_stack:Wb,lm_left:Gb,lm_right:zb,lm_dragProxy:Kb,lm_items:qb,lm_tabdropdown_list:Yb,lm_bottom:Xb,lm_drop_tab_placeholder:Zb,lm_tabdropdown:Qb,lm_dropTargetIndicator:Jb,lm_inner:ew,lm_transition_indicator:tw,lm_popin:nw,lm_bg:sw,lm_icon:iw,lm_goldenlayout:ow,lm_selectable:aw,lm_active:rw,lm_selected:lw,lm_keyboard_active:dw,lm_popout:cw,lm_maximise:hw,lm_close:uw,lm_tabnextbutton:mw,lm_tabpreviousbutton:pw,lm_title_before:gw,"editor-unsaved-indicator":"_editor-unsaved-indicator_15d73_548","is-unsaved":"_is-unsaved_15d73_556",lm_focusin:fw,lm_window_blur:Cw,lm_tabdropdown_search:Sw,march:bw,app:ww,"js-plotly-plot":"_js-plotly-plot_15d73_721",plotly:vw},Ec=Object.freeze({tabHeight:parseInt(Tc["tab-height"],10),dragBorderWidth:parseInt(Tc["drag-border-width"],10)}),hs=Z.module("LayoutUtils");function Bu(d){return d.componentName!==void 0}function xi(d){const e=d;return(Bu(d)&&d.componentName==="lm-react-component"||d.type==="react-component")&&e.component!==void 0}function ta(d){return d.focus!==void 0}function yc(d){return d.type==="stack"}class q{static DEFAULT_FOCUS_SELECTOR="input, select, textarea, button";static activateTab(e,t){const n=q.getStackForRoot(e,t,!1);if(!n){hs.error("Could not find stack for config",t);return}const s=q.getContentItemInStack(n,t);s&&n.setActiveContentItem(s)}static isActiveTab(e,t){const n=q.getStackForRoot(e,t,!1);if(!n)return hs.error("Could not find stack for config",t),!1;const s=q.getContentItemInStack(n,t);return n.getActiveContentItem()===s}static addStack(e,t=!0){const n=t?"column":"row";if(Lu(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 r=document.activeElement;e.contentItems[0].addChild(o),r&&r.focus!=null&&r.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&&yo(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&&Fd(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 a=t[o],r=o===t.length-1,c=q.getStackForRoot(e,{component:a},n&&r,s,i);if(c)return c}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&&Fd(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:a}=i;if(o){const r=t(o,i);r!=null?n.push(r):hs.debug2(`dehydrateLayoutConfig: skipping unmapped component "${o}"`)}else if(a){const r={...i,content:q.dehydrateLayoutConfig(a,t)};n.push(r)}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?(yc(n)&&delete n.activeItemIndex,q.dropLayoutMinorChange(s)):xi(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=q.cloneLayout(e),i=q.cloneLayout(t);return q.dropLayoutMinorChange(s),q.dropLayoutMinorChange(i),it(s,i)}return it(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(xi(i)){const{component:o,props:a={}}=i;n.push({...i,id:i?.id??Pe(),props:t(o,a)})}else if(i.content!==void 0){const o=q.hydrateLayoutConfig(i.content,t);yc(i)&&i.activeItemIndex!=null&&i.activeItemIndex>=o.length&&(hs.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:a=void 0}={}){const r=document.activeElement,c={...t};if(c.id==null&&(c.id=Pe.generate()),a){e?.layoutManager.createDragSourceFromEvent(c,a);return}const h=s||{id:c.id,component:c.component};M(e);const u=i?q.addStack(e):q.getStackForRoot(e,h);M(u);const m=q.getContentItemInStack(u,h);if(o!=null){const p=g=>{hs.debug("Component created, focusing element",o),u.off("componentCreated",p);const{element:C}=g.origin;requestAnimationFrame(()=>{q.focusElement(C[0],o)})};u.on("componentCreated",p)}if(n&&m){const p=u.contentItems.indexOf(m);u.addChild(c,p+1),u.removeChild(m),u.setActiveContentItem(u.contentItems[p])}else u.addChild(c);o==null&&r&&ta(r)&&r.focus()}static openComponentInStack(e,t,n=!0){const s=document.activeElement,i={id:t.id},o=q.getContentItemInStack(e,i);if(n&&o&&e){const a=e?.contentItems.indexOf(o);e.addChild(t,a+1),e.removeChild(o),e.setActiveContentItem(e.contentItems[a])}else e?.addChild(t);s&&ta(s)&&s.focus()}static closeComponent(e,t,n){const s=q.getStackForRoot(e,t,!1,!1,!1);if(!s){hs.warn("Cannot find stack for component, ignoring close",t);return}const i=q.getContentItemInStack(s,t),o=document.activeElement;i&&(dn(i)?i.container.close(n):s.removeChild(i)),o&&document.contains(o)&&ta(o)&&o.focus()}static renameComponent(e,t,n){const s=q.getStackForRoot(e,t,!1);if(!s){hs.error("Could not find stack for config",t);return}const i=q.getContentItemInStack(s,t);i&&i.setTitle(n)}static cloneComponent(e,t){const n=q.getStackForRoot(e,t,!1);if(!n)return hs.error("Could not find stack for config",t),null;const{props:s={}}=t,i=q.getPanelComponentState(t),o={type:"react-component",component:t.component,props:{...s,panelState:i},title:`${t.title} Copy`,id:Pe.generate()};return q.openComponentInStack(n,o),o}static getPanelComponentState(e){return Bu(e)?e.componentState?.panelState:xi(e)?e.props?.panelState:null}static makeDefaultLayout(){return{dimensions:{headerHeight:Ec.tabHeight,borderWidth:Ec.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=q.getComponentConfigFromContainer(e);return t?t.id:null}static getIdFromPanel(e){const{glContainer:t}=e.props;return q.getIdFromContainer(t)}static getComponentNameFromPanel(e){const{glContainer:t}=e.props,n=q.getComponentConfigFromContainer(t);return n&&xi(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=q.DEFAULT_FOCUS_SELECTOR){if(e==null)return null;const n=e.querySelector(t);return n==null?null:(ta(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 Vu=X.forwardRef((d,e)=>{const t=q.getComponentNameFromPanel({props:d});return l.jsxs("div",{ref:e,className:"panel-placeholder",children:['Component "',t,'" is not registered.']})});Vu.displayName="PanelPlaceholder";const Ee=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 xc(d){return d?.WrappedComponent!==void 0}function Tw(d){return typeof d.id=="string"&&d.layout instanceof Hu&&d.panelManager instanceof Uu&&typeof d.registerComponent=="function"}function Ps(d){if(!Tw(d))throw new Error(`Expected dashboard plugin props, but instead received ${d}`)}const sn=Z.module("PanelManager");class Uu{static MAX_CLOSED_PANEL_COUNT=100;layout;hydrateComponent;dehydrateComponent;onPanelsUpdated;closed;openedMap;constructor(e,t=(a,r)=>r,n=(a,r)=>r,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(Ee.FOCUS,this.handleFocus),e.on(Ee.MOUNT,this.handleMount),e.on(Ee.UNMOUNT,this.handleUnmount),e.on(Ee.REOPEN,this.handleReopen),e.on(Ee.DELETE,this.handleDeleted),e.on(Ee.CLOSED,this.handleClosed),e.on(Ee.CLOSE,this.handleControlClose)}stopListening(){const{eventHub:e}=this.layout;e.off(Ee.FOCUS,this.handleFocus),e.off(Ee.MOUNT,this.handleMount),e.off(Ee.UNMOUNT,this.handleUnmount),e.off(Ee.REOPEN,this.handleReopen),e.off(Ee.DELETE,this.handleDeleted),e.off(Ee.CLOSED,this.handleClosed),e.off(Ee.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 q.getComponentConfigFromContainer(t)})}getOpenedPanelConfigsOfType(e){return this.getOpenedPanelConfigs().filter(t=>t!=null&&xi(t)&&t.component===e)}getOpenedPanelById(e){return this.openedMap.get(e)}getContainerByPanelId(e){const t=q.getStackForConfig(this.layout.root,{id:e});return(t&&q.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=>xc(n)&&t instanceof n.WrappedComponent||!xc(n)&&t instanceof n))}updatePanel(e){const t=q.getIdFromPanel(e);if(t==null){sn.error("updatePanel Panel did not have an ID",e);return}sn.debug2(`Updating panel ID ${t} in open panels map`),this.openedMap.delete(t),this.openedMap.set(t,e)}removePanel(e){const t=q.getIdFromPanel(e);if(t==null){sn.error("removePanel Panel did not have an ID",e);return}if(!this.openedMap.has(t)){sn.error(`Missing panel ID ${t} in open panels map`);return}if(this.openedMap.get(t)!==e){sn.debug(`Panel argument doesn't match the open panels map entry for ${t}, removePanel ignored`);return}sn.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){sn.debug2("Focus: ",e),this.updatePanel(e)}handleMount(e){sn.debug2("Mount: ",e),this.updatePanel(e),this.sendUpdate()}handleUnmount(e){sn.debug2("Unmount: ",e),this.removePanel(e),this.sendUpdate()}handleReopen(e,t){sn.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;q.openComponent({root:o,config:i,replaceConfig:t})}handleDeleted(e){sn.debug2("Deleted:",e),this.removeClosedPanelConfig(e),this.sendUpdate()}handleClosed(e,t){sn.debug2("Closed: ",e),this.addClosedPanel(t),this.sendUpdate()}handleControlClose(e){const t={id:e},{root:n}=this.layout;q.closeComponent(n,t)}addClosedPanel(e){const t=q.getComponentConfigFromContainer(e);if(t&&xi(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 Ew=Z.module("PanelErrorBoundary");class yw extends b.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}componentWillUnmount(){const{glContainer:e,glEventHub:t}=this.props,n=q.getIdFromContainer(e);Ew.debug("componentWillUnmount",n),t.emit(Ee.CLOSED,n,e)}render(){const{children:e}=this.props,{error:t}=this.state;return t!=null?l.jsx("div",{className:"panel-error-boundary",children:l.jsx(Ja,{errorMessage:`${t}`,isLoading:!1,isLoaded:!1})}):e}}function Ql(d){const{props:e,componentState:t}=d,{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),{...d,componentState:null,props:i,type:"react-component"}}function Jl(d,e=""){return{metadata:{},...d,localDashboardId:e}}const ml={dehydrate:Ql,hydrate:Jl},xw=D.shape({on:D.func,off:D.func,isHidden:D.bool,tab:D.shape({header:D.shape({tabs:D.arrayOf(D.shape({contentItem:D.shape({})}))})}),title:D.string,setTitle:D.func,close:D.func}),$u=D.shape({on:D.func,off:D.func,emit:D.func}),Rw=D.shape({registerComponent:D.func,root:D.shape({addChild:D.func}),on:D.func,off:D.func,eventHub:$u}),ed=Object.freeze({Container:xw,EventHub:$u,Layout:Rw}),Ue=(d,e,t)=>b.useEffect(function(){return d.on(e,t),()=>{d.off(e,t)}},[d,e,t]),Wu="SET_DASHBOARD_DATA",Iw=XS(Wu,{},!1),Dw={dashboardData:Iw},Fw=new Map,Nw=Object.freeze({}),Mw=Object.freeze([]),kw=d=>d.dashboardData,Vt=(d,e)=>kw(d)[e]??Nw,Ow=(d,e)=>Vt(d,e).closed??Mw,Gu=(d,e)=>Vt(d,e).openedMap??Fw,zu=(d,e)=>({type:Wu,id:d,payload:e}),Pn=(d,e)=>(t,n)=>t(zu(d,{...Vt(n(),d),...e}));Object.entries(Dw).map(([d,e])=>Gi.register(d,e));const na=Z.module("DashboardLayout"),Aw=Object.freeze({}),Lw=[],Rc=()=>{},Ic=d=>d;function Ku({id:d,children:e,emptyDashboard:t=l.jsx("div",{children:"Dashboard is empty."}),layout:n,layoutConfig:s=Lw,onLayoutChange:i=Rc,onLayoutInitialized:o=Rc,hydrate:a=Jl,dehydrate:r=Ql}){const c=El(),h=Gm(U=>Vt(U,d))??Aw,[u,m]=b.useState(!1),[p,g]=b.useState(!1),[C,f]=b.useState(),[S]=b.useState(h?.closed??[]),[v,w]=b.useState(!1),T=b.useMemo(()=>new Map,[]),y=b.useMemo(()=>new Map,[]),E=zm(),I=b.useCallback((U,j,W=a,ie=r)=>{na.debug2("registerComponent",U,j,W,ie);function se(te,oe){const de=j,{glContainer:ee,glEventHub:re}=te;return l.jsx(wh,{store:E,children:l.jsx(yw,{glContainer:ee,glEventHub:re,children:l.jsx(de,{...te,ref:oe})})})}const G=X.forwardRef(se),K=n.registerComponent(U,G);return T.set(U,W),y.set(U,ie),K},[a,r,T,y,n,E]),F=b.useCallback((U,j)=>(T.get(U)??Ic)(j,d),[T,d]),N=b.useCallback((U,j)=>(y.get(U)??Ic)(j,d),[y,d]),H=b.useMemo(()=>new Uu(n,F,N,new Map,S,({closed:U,openedMap:j})=>{c(Pn(d,{closed:U,openedMap:j}))}),[N,c,F,d,S,n]),P=b.useCallback(()=>{if(p)return;v||(o(),w(!0));const j=n.toConfig().content,W=q.dehydrateLayoutConfig(j,N),ie=C==null||!q.isEqual(C,W);na.debug("handleLayoutStateChanged",ie,j,W),ie&&(m(n.root.contentItems.length===0),f(W),i(W))},[N,v,p,C,n,i,o]),O=b.useCallback(U=>{const j=q.getIdFromContainer(U);n.eventHub.emit(Ee.DRAGGING,j),g(!0)},[n.eventHub]),k=b.useCallback(U=>{const j=q.getIdFromContainer(U);n.eventHub.emit(Ee.DROPPED,j),g(!1)},[n.eventHub]),L=b.useCallback(U=>{if(na.debug2("handleComponentCreated",U),U==null||U.config==null||U.config.component==null||U.element==null)return;const W=`${U.config.component.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}-component`;U.element.addClass(W)},[]);Ue(n,"stateChanged",P),Ue(n,"itemPickedUp",O),Ue(n,"itemDropped",k),Ue(n,"componentCreated",L),Ue(n.eventHub,Ee.TITLE_CHANGED,P);const A=ir(s);return b.useEffect(function(){if(A!==s&&s!==C){na.debug("Setting new layout content...");const j=q.hydrateLayoutConfig(s,F);for(;n.root.contentItems.length>0;)n.root.contentItems[0].remove();for(let W=0;W<j.length;W+=1)n.root.addChild(j[W]);m(n.root.contentItems.length===0)}},[F,n,s,C,H,A]),l.jsxs(l.Fragment,{children:[u&&t,X.Children.map(e,U=>U!=null?X.cloneElement(U,{id:d,layout:n,panelManager:H,registerComponent:I}):null)]})}Ku.propTypes={id:D.string.isRequired,children:D.node,data:D.shape({}),emptyDashboard:D.node,layout:ed.Layout.isRequired,layoutConfig:D.arrayOf(D.shape({})),onLayoutChange:D.func,onLayoutInitialized:D.func};const Pw=100,jr=()=>{},_w=Object.freeze({});function jw({id:d="default",children:e,emptyDashboard:t,layoutConfig:n,layoutSettings:s=_w,onLayoutConfigChange:i=jr,onGoldenLayoutChange:o=jr,onLayoutInitialized:a=jr,fallbackComponent:r=Vu,hydrate:c,dehydrate:h}){const u=b.useRef(null),[m,p]=b.useState(!1),[g,C]=b.useState();b.useEffect(function(){if(!u.current){C(void 0);return}const v={...q.makeDefaultLayout()};v.settings===void 0&&(v.settings={}),Object.assign(v.settings,s),v.content=[];const w=new Hu(v,u.current),T=()=>{w.off("initialised",T),p(!0)};return w.on("initialised",T),r!=null&&w.setFallbackComponent(r),w.init(),C(w),o(w),()=>{w.destroy()}},[s,r,o,p,C]);const f=b.useMemo(()=>ks(()=>{g!=null&&g.isInitialised&&g?.updateSize()},Pw),[g]);return b.useEffect(function(){return window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}},[f]),l.jsxs("div",{className:"dashboard-container w-100 h-100",children:[l.jsx("div",{className:"w-100 h-100",ref:u}),m&&g&&l.jsx(Ku,{emptyDashboard:t,id:d,layout:g,layoutConfig:n,onLayoutChange:i,onLayoutInitialized:a,hydrate:c,dehydrate:h,children:e})]})}const wn="default";class qu extends Error{isAssertionFailed=!0}function Dc(d){if(d==null)throw new qu(`Expected 'val' to be defined, but received ${d}`)}class Hr extends Error{isPasteError=!0}function Ze(d){return d?.isEditable!==void 0}function Fc(d){if(!Ze(d))throw new qu(`Expected 'model' to be editable, but received ${d}`)}function ze(d){return d?.hasExpandableRows!==void 0}var vn=(d=>(d.DOWN="DOWN",d.UP="UP",d.LEFT="LEFT",d.RIGHT="RIGHT",d))(vn||{});class z{startColumn;startRow;endColumn;endRow;static SELECTION_DIRECTION=vn;static normalize(e,t,n,s){let i=e,o=t,a=n,r=s;return i!=null&&a!=null&&a<i&&(i=a,a=e),o!=null&&r!=null&&r<o&&(o=r,r=t),[i,o,a,r]}static makeNormalized(e,t,n,s){return new z(...z.normalize(e,t,n,s))}static makeCell(e,t){return new z(e,t,e,t)}static makeColumn(e){return new z(e,null,e,null)}static makeRow(e){return new z(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 a=t[o];if(i.contains(a))t.splice(o,1);else if(a.contains(i)){n=!0,t[s]=a,t.splice(o,1);break}else if(i.startRow===a.startRow&&i.endRow===a.endRow){if(i.touches(a)){const{startRow:r,endRow:c}=i,h=z.minOrNull(i.startColumn,a.startColumn),u=z.maxOrNull(i.endColumn,a.endColumn);n=!0,t[s]=new z(h,r,u,c),t.splice(o,1);break}}else if(i.startColumn===a.startColumn&&i.endColumn===a.endColumn&&i.touches(a)){const{startColumn:r,endColumn:c}=i,h=z.minOrNull(i.startRow,a.startRow),u=z.maxOrNull(i.endRow,a.endRow);n=!0,t[s]=new z(r,h,c,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 z(n,s,i,o)}static subtractFromRange(e,t){const n=[],s=z.intersection(e,t);return s==null?[e]:(s.startRow!=null&&(e.startRow==null||e.startRow<s.startRow)&&n.push(new z(e.startColumn,e.startRow,e.endColumn,s.startRow-1)),s.startColumn!=null&&(e.startColumn==null||e.startColumn<s.startColumn)&&n.push(new z(e.startColumn,s.startRow,s.startColumn-1,s.endRow)),s.endColumn!=null&&(e.endColumn==null||e.endColumn>s.endColumn)&&n.push(new z(s.endColumn+1,s.startRow,e.endColumn,s.endRow)),s.endRow!=null&&(e.endRow==null||e.endRow>s.endRow)&&n.push(new z(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(...z.subtractFromRange(e[s],t));return n}static subtractRangesFromRanges(e,t){let n=[...e];for(let s=0;s<t.length;s+=1)n=z.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 z.isBounded(e)?e:new z(e.startColumn??0,e.startRow??0,e.endColumn??t-1,e.endRow??n-1)}static boundedRanges(e,t,n){return e.map(s=>z.boundedRange(s,t,n))}static offset(e,t,n){return new z(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=z.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 a=e[i].nextCell(t,n,s);if(a!=null)return a}switch(s){case z.SELECTION_DIRECTION.DOWN:case z.SELECTION_DIRECTION.RIGHT:{const o=i<e.length-1?i+1:0;return e[o].startCell(s)}case z.SELECTION_DIRECTION.LEFT:case z.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=z.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 z.isAxisRangeTouching(this.startRow,this.endRow,e.startRow,e.endRow)&&z.isAxisRangeTouching(this.startColumn,this.endColumn,e.startColumn,e.endColumn)}subtract(e){return z.subtractFromRange(this,e)}startCell(e=z.SELECTION_DIRECTION.DOWN){if(!z.isBounded(this))throw new Error("Cannot get the startCell of an unbounded range");switch(e){case z.SELECTION_DIRECTION.DOWN:case z.SELECTION_DIRECTION.RIGHT:return{column:this.startColumn,row:this.startRow};case z.SELECTION_DIRECTION.LEFT:case z.SELECTION_DIRECTION.UP:return{column:this.endColumn,row:this.endRow};default:throw new Error(`Invalid direction: ${e}`)}}nextCell(e,t,n){if(!z.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:a}=this;switch(n){case z.SELECTION_DIRECTION.DOWN:if(t<a)return{column:e,row:Math.max(t+1,o)};if(e<i)return{column:Math.max(e+1,s),row:o};break;case z.SELECTION_DIRECTION.UP:if(t>o)return{column:e,row:Math.min(t-1,a)};if(e>s)return{column:Math.min(e-1,i),row:a};break;case z.SELECTION_DIRECTION.RIGHT:if(e<i)return{column:Math.max(e+1,s),row:t};if(t<a)return{column:s,row:Math.max(t+1,o)};break;case z.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,a)};break;default:throw new Error(`Invalid direction: ${n}`)}return null}forEach(e,t=z.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)??{}}}function Hw(d){return Array.isArray(d)&&d.length===2&&(d[0]===null||typeof d[0]=="number")&&(d[1]===null||typeof d[1]=="number")}function sa(d){return Hw(d)&&d[0]!=null&&d[1]!=null}function _a(d){return d?.href!==void 0}class B{static PIXELS_PER_LINE=100/3;static getGridPointFromXY(e,t,n){const s=B.getColumnAtX(e,n),i=B.getRowAtY(t,n),o=B.getColumnHeaderDepthAtY(t,n);return{x:e,y:t,row:i,column:s,columnHeaderDepth:o}}static getCellInfoFromXY(e,t,n){const{row:s,column:i}=B.getGridPointFromXY(e,t,n),{allColumnWidths:o,allRowHeights:a,allColumnXs:r,allRowYs:c,modelColumns:h,modelRows:u}=n,m=s!==null?u.get(s):null,p=i!==null?h.get(i):null,g=i!==null?r.get(i):null,C=s!==null?c.get(s):null,f=i!==null?o.get(i):null,S=s!==null?a.get(s):null;return{row:s,column:i,modelRow:m??null,modelColumn:p??null,left:g??null,top:C??null,columnWidth:f??null,rowHeight:S??null}}static getColumnHeaderDepthAtY(e,t){const n=B.getRowAtY(e,t),{columnHeaderHeight:s,columnHeaderMaxDepth:i}=t;if(n===null&&e<=s*i)return je(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=B.iterateFloatingStart(e,n,s);return i!==void 0?i:B.iterateFloatingEnd(t,n,s)}static iterateAllItems(e,t,n,s,i,o){const a=Math.max(e,n),r=Math.min(t,i-s-1);let c=B.iterateFloating(n,s,i,o);if(c!==void 0)return c;for(let h=a;h<=r;h+=1)if(c=o(h),c!==void 0)return c}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,a,r=!1){const c=r?void 0:B.iterateFloating(n,s,t,h=>{if(B.isInItem(h,o,a,e))return h});if(!r&&c!==void 0)return c;for(let h=0;h<i.length;h+=1){const u=i[h];if(B.isInItem(u,o,a,e))return u}return null}static getColumnAtX(e,t,n=!1){const{columnCount:s,floatingLeftColumnCount:i,floatingRightColumnCount:o,visibleColumns:a,allColumnXs:r,allColumnWidths:c,gridX:h}=t;return e<h?null:this.getItemAtOffset(e-h,s,i,o,a,r,c,n)}static getRowAtY(e,t){const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i,visibleRows:o,allRowYs:a,allRowHeights:r,gridY:c}=t;return e<c?null:this.getItemAtOffset(e-c,i,n,s,o,a,r)}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],a=t.get(o);if(a!=null&&s.get(a)!==0)return o;i-=1}return null}static getNextShownColumn(e,t){const{modelColumns:n,visibleColumns:s,userColumnWidths:i}=t;return B.getNextShownItem(e,n,s,i)}static getNextShownRow(e,t){const{modelRows:n,visibleRows:s,userRowHeights:i}=t;return B.getNextShownItem(e,n,s,i)}static getColumnSeparatorIndex(e,t,n,s){const{rowHeaderWidth:i,columnHeaderHeight:o,floatingColumns:a,floatingLeftWidth:r,visibleColumns:c,allColumnXs:h,allColumnWidths:u,columnHeaderMaxDepth:m}=n,{allowColumnResize:p,headerSeparatorHandleSize:g}=s;if(m*o<t||!p||g<=0)return null;const C=e-i,f=g*.5;let S=!1;for(let v=a.length-1;v>=0;v-=1){const w=a[v],T=h.get(w)??0,y=u.get(w)??0,E=y===0;if(!S||!E){let I=T+y;E?I+=f:S&&(I-=f);const F=I-f,N=I+f;if(F<=C&&C<=N)return w;S=E}}S=!1;for(let v=c.length-1;v>=0;v-=1){const w=c[v],T=h.get(w)??0,y=u.get(w)??0,E=y===0;if(T<r-y)return null;if(!S||!E){let I=T+y;E?I+=f:S&&(I-=f);const F=I-f,N=I+f;if(F<=C&&C<=N)return w;S=E}}return null}static isItemHidden(e,t){return t.get(e)===0}static isColumnHidden(e,t){const{allColumnWidths:n}=t;return B.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(!B.isItemHidden(e,t))return[];const s=[e],i=n.findIndex(o=>o===e);for(let o=i-1;o>=0;o-=1){const a=n[o];if(!B.isItemHidden(a,t))break;s.push(a)}return s}static getHiddenColumns(e,t){const{visibleColumns:n,allColumnWidths:s}=t;return B.getHiddenItems(e,s,n)}static getRowSeparatorIndex(e,t,n,s){const{rowHeaderWidth:i,columnHeaderHeight:o,visibleRows:a,allRowYs:r,allRowHeights:c}=n,{allowRowResize:h,headerSeparatorHandleSize:u}=s;if(i<e||!h||u<=0)return null;const m=t-o,p=u*.5;let g=!1;for(let C=a.length-1;C>=0;C-=1){const f=a[C],S=r.get(f)??0,v=c.get(f)??0,w=v===0;if(!g||!w){let T=S+v;w?T+=p:g&&(T-=p);const y=T-p,E=T+p;if(y<=m&&m<=E)return f;g=w}}return null}static isRowHidden(e,t){const{allRowHeights:n}=t;return B.isItemHidden(e,n)}static getHiddenRows(e,t){const{visibleRows:n,allRowHeights:s}=t;return B.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&&!sa(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 B.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],a=o[o.length-1];a!=null&&sa(a.from)&&a.from[1]-a.from[0]===e[1]-e[0]&&a.to===e[0]?o[o.length-1]={...a,to:i}:o.push({from:e,to:i});const r=o[o.length-1];return sa(r.from)&&r.from[0]===r.to&&o.pop(),o}static moveItemOrRange(e,t,n,s=!1){return Array.isArray(e)?B.moveRange(e,t,n,s):B.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:a,to:r}=n[o];let c=1,h;sa(a)?(c=a[1]-a[0]+1,[h]=a):h=a;const u=s?r:h,m=u+c-1,p=s?h:r,g=p-u,C=[];for(let f=0;f<i.length;f+=1){const S=i[f][0]??Number.NEGATIVE_INFINITY,v=i[f][1]??Number.POSITIVE_INFINITY;let w;const T=[[S,u-1],[u,m],[m+1,v]].map(([y,E])=>[Math.max(y,S),Math.min(E,v)]).filter(([y,E])=>y<=E).map(y=>{const[E,I]=y;return u<=E&&m>=I?(w=[E+g,I+g],w):m<E?[E-c,I-c]:y}).map(y=>{const[E,I]=y;return p>E&&p<=I?[[E,p-1],[p+c,I+c]]:y===w?[y]:p<=E?[[E+c,I+c]]:[y]}).flat();C.push(...T)}i=C.map(([f,S])=>[Number.isFinite(f)?f:null,Number.isFinite(S)?S:null])}return i}static translateRange(e,t,n,s){const i=B.applyItemMoves(e.startColumn,e.endColumn,t,s),o=B.applyItemMoves(e.startRow,e.endRow,n,s),a=[];for(let r=0;r<i.length;r+=1){const c=i[r];for(let h=0;h<o.length;h+=1){const u=o[h];a.push(new z(c[0],u[0],c[1],u[1]))}}return a}static getModelIndex(e,t){return B.applyItemMoves(e,e,t,!0)[0][0]}static getModelIndexes(e,t){return e.map(n=>B.getModelIndex(n,t))}static getModelRangeIndexes(e,t,n){return B.applyItemMoves(e,t,n,!0)}static getModelRange(e,t=De,n=De){return B.translateRange(e,t,n,!0)}static getModelRanges(e,t=De,n=De){const s=[];for(let i=0;i<e.length;i+=1)s.push(...B.getModelRange(e[i],t,n));return s}static getVisibleRangeIndexes(e,t,n){return B.applyItemMoves(e,t,n,!1)}static getVisibleRange(e,t=De,n=De){return this.translateRange(e,t,n,!1)}static getVisibleRanges(e,t=De,n=De){const s=[];for(let i=0;i<e.length;i+=1)s.push(...B.getVisibleRange(e[i],t,n));return s}static getVisibleIndex(e,t){return B.applyItemMoves(e,e,t)[0][0]}static getVisibleIndexes(e,t){return e.map(n=>B.getVisibleIndex(n,t))}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return B.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){const t=B.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:a,floatingTopRowCount:r,floatingBottomRowCount:c,floatingLeftColumnCount:h,floatingRightColumnCount:u,floatingLeftWidth:m,floatingRightWidth:p,floatingTopHeight:g,floatingBottomHeight:C,columnCount:f,rowCount:S}=e;let v=s,w=i,T=o,y=a;return n!=null&&(n>h&&(v+=m),n<f-u&&(T-=p)),t!=null&&(t>r&&(w+=g),t<S-c&&(y-=C)),{x1:v,y1:w,x2:T,y2:y}}static getScrollDelta(e,t=1024,n=768,s=20,i=20){let{deltaX:o,deltaY:a}=e;return!B.isMacPlatform()&&e.shiftKey&&e.deltaX===0&&e.deltaY!==0&&(o=e.deltaY,a=e.deltaX),e?.deltaMode===WheelEvent.DOM_DELTA_PAGE?(o*=t,a*=n):e?.deltaMode===WheelEvent.DOM_DELTA_LINE&&(B.isMacPlatform()?(o=Math.round(o*s),a=Math.round(a*i)):(o=Math.round(o*this.PIXELS_PER_LINE),a=Math.round(a*this.PIXELS_PER_LINE))),{deltaX:o,deltaY:a}}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:a,gridY:r,width:c,height:h,verticalBarWidth:u,horizontalBarHeight:m}=t,p=je(a+n,a,c-u),g=je(a+i,a,c-u),C=je(r+s,r,h-m),f=je(r+o,r,h-m);return{x1:p,y1:C,x2:g,y2:f,token:e.token}}}function ia(d,e=Po.CACHE_SIZE,t=Math.floor(e/2)){if(d.size>e){const n=d.keys();for(;d.size>t;)d.delete(n.next().value)}}function Nc(d,e,t,n,s){const i=new Map;let o=0;for(let a=0;a<d&&a<t;a+=1)i.set(a,o),o+=_(s,a);o=n;for(let a=0;a<e&&t-a-1>=0;a+=1)o-=_(s,t-a-1),i.set(t-a-1,o);return i}class Po{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:a=new Map,movedRows:r=[],movedColumns:c=[],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=a,this.movedRows=r,this.movedColumns=c,this.initialRowHeights=h,this.initialColumnWidths=u}getMetrics(e){const{left:t,top:n,leftOffset:s,topOffset:i,width:o,height:a,theme:r,model:c,movedRows:h,movedColumns:u,draggingColumn:m}=e,{rowHeight:p,rowHeaderWidth:g,rowFooterWidth:C,columnWidth:f,columnHeaderHeight:S,minScrollHandleSize:v,scrollBarSize:w}=r;h!==this.movedRows&&(this.movedRows=h,this.modelRows.clear()),u!==this.movedColumns&&(this.movedColumns=u,this.modelColumns.clear());const{columnCount:T,rowCount:y,floatingTopRowCount:E,floatingBottomRowCount:I,floatingLeftColumnCount:F,floatingRightColumnCount:N,columnHeaderMaxDepth:H}=c,P=this.getFirstRow(e),O=this.getFirstColumn(e),k=this.getGridX(e),L=this.getGridY(e),A=ze(c)&&c.hasExpandableRows?this.calculateTreePaddingX(e):0,U=0,j=this.getVisibleRowHeights(e),W=this.getVisibleColumnWidths(e,O,A),ie=Array.from(j.keys()),se=Array.from(W.keys()),G=new Map([...j,...this.getFloatingRowHeights(e)]),K=new Map([...W,...this.getFloatingColumnWidths(e)]),te=this.getVisibleColumnXs(K,se,s),oe=this.getVisibleRowYs(G,ie,i),de=ie.length>0?ie[ie.length-1]:n,ee=se.length>0?se[se.length-1]:t,re=this.getBottomViewport(e,ie,oe,G),we=this.getRightViewport(e,se,te,K),xe=this.getFloatingTopHeight(e,G),Oe=this.getFloatingBottomHeight(e,G),Jt=this.getFloatingLeftWidth(e,K),Mt=this.getFloatingRightWidth(e,K),ss=Array.from(K.values()),Tn=Array.from(G.values()),kt=ss.reduce((qe,_n)=>qe+_n,0)-s,ye=Tn.reduce((qe,_n)=>qe+_n,0)-i,ht=s+kt+C,at=i+ye,St=o-k,Ot=a-L,En=this.getLastLeft(e,null,St-C),en=this.getLastLeft(e,null,St-C-w),_o=this.getLastTop(e,null,Ot-Oe),_s=this.getLastTop(e,null,Ot-Oe-w);let tn=en,is=_s;En===0&&_o===0&&(tn=0,is=0);const di=tn>0,qi=di?w:0,ci=is>0,hi=ci?w:0,jo=k,Ho=H*S,os=o-jo-hi,js=a-Ho-qi,Tr=T===1?os/ht:(T-tn)/T,Bo=y===1?js/at:(y-is)/y,Yi=di?je(os*Tr,v,os-1):0,Xi=ci?je(js*Bo,v,js-1):0,Zi=_(K,t,0),Vo=_(G,n,0),Er=Zi>0?s/Zi:0,yr=Vo>0?i/Vo:0,xr=T===1?s/(ht-St):(t+Er)/tn,Rr=y===1?i/(at-Ot):(n+yr)/is,Hs=di?xr*(os-Yi):0,Ir=ci?Rr*(js-Xi):0,Qi=[...Array(E).keys(),...[...Array(I).keys()].map(qe=>y-qe-1)],Ji=new Map([...oe,...this.getFloatingRowYs(e,G,Math.floor(a-L-qi))]),Uo=[...Array(F).keys(),...[...Array(N).keys()].map(qe=>T-qe-1)],Bs=new Map([...te,...this.getFloatingColumnXs(e,K,Math.floor(o-k-hi))]),eo=[];if(m)for(let qe=m.range[0];qe<=m.range[1];qe+=1)eo.push(qe),K.has(qe)||K.set(qe,this.getVisibleColumnWidth(qe,e)),Bs.has(qe)||Bs.set(qe,0);const to=ie.concat(Qi),$o=se.concat(Uo).concat(eo),no=this.getModelRows(to,e),Wo=this.getModelColumns($o,e),Dr=this.getVisibleRowTreeBoxes(G,no,e),Go=this.getTopVisible(e,Ji,G,ie),zo=this.getLeftVisible(e,Bs,K,se),Ko=is>0?this.getBottomVisible(e,Ji,G,ie,L):de,qo=tn>0?this.getRightVisible(e,Bs,K,se,k):ee,{fontWidths:Yo,userColumnWidths:Xo,userRowHeights:Fr,calculatedRowHeights:Ke,calculatedColumnWidths:yt}=this;return{rowHeight:p,rowHeaderWidth:g,rowFooterWidth:C,rowCount:y,columnWidth:f,columnCount:T,columnHeaderHeight:S,floatingTopRowCount:E,floatingBottomRowCount:I,floatingLeftColumnCount:F,floatingRightColumnCount:N,gridX:k,gridY:L,firstRow:P,firstColumn:O,treePaddingX:A,treePaddingY:U,left:t,top:n,bottom:de,right:ee,topOffset:i,leftOffset:s,topVisible:Go,leftVisible:zo,bottomVisible:Ko,rightVisible:qo,bottomViewport:re,rightViewport:we,width:o,height:a,maxX:kt,maxY:ye,lastLeft:tn,lastTop:is,barHeight:js,barTop:Ho,barWidth:os,barLeft:jo,handleHeight:Xi,handleWidth:Yi,hasHorizontalBar:di,hasVerticalBar:ci,verticalBarWidth:hi,horizontalBarHeight:qi,scrollX:Hs,scrollY:Ir,scrollableContentWidth:ht,scrollableContentHeight:at,scrollableViewportWidth:St,scrollableViewportHeight:Ot,visibleRows:ie,visibleColumns:se,visibleRowHeights:j,visibleColumnWidths:W,floatingRows:Qi,floatingColumns:Uo,allRows:to,allColumns:$o,allRowHeights:G,allColumnWidths:K,floatingTopHeight:xe,floatingBottomHeight:Oe,floatingLeftWidth:Jt,floatingRightWidth:Mt,visibleRowYs:oe,visibleColumnXs:te,allRowYs:Ji,allColumnXs:Bs,visibleRowTreeBoxes:Dr,modelRows:no,modelColumns:Wo,movedRows:h,movedColumns:u,fontWidths:Yo,userColumnWidths:Xo,userRowHeights:Fr,calculatedRowHeights:Ke,calculatedColumnWidths:yt,columnHeaderMaxDepth:H}}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),a=this.getFloatingBottomHeight(e,t),r=this.getFloatingTopHeight(e,t);return n-a-r-o-i}getVisibleWidth(e,t=this.getFloatingColumnWidths(e)){const{width:n,theme:s}=e,{scrollBarSize:i,rowFooterWidth:o}=s,a=this.getGridX(e),r=this.getFloatingRightWidth(e,t),c=this.getFloatingLeftWidth(e,t);return n-c-r-a-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 a=Math.max(0,i-o-1);t!=null&&(a=t);let r=0;for(;a>=0;){const c=this.getVisibleColumnWidth(a,e);if(r+=c,r>=n)return je(a+1,0,t??i-1);a-=1}return 0}getLastTop(e,t,n){const{model:s}=e,{rowCount:i,floatingBottomRowCount:o}=s;let a=Math.max(0,i-o-1);t!=null&&(a=t);let r=0;for(;a>=0;){const c=this.getVisibleRowHeight(a,e);if(r+=c,r>=n)return je(a+1,0,i-1);a-=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 a=0;a<n&&a<i;a+=1)o.set(a,this.getVisibleRowHeight(a,e));for(let a=0;a<s&&i-a-1>=0;a+=1){const r=i-a-1;o.set(r,this.getVisibleRowHeight(r,e))}return o}getVisibleRowHeights(e){const{top:t,topOffset:n,height:s,model:i}=e;let o=0,a=t;const r=new Map,{rowCount:c}=i;for(;o<s+n&&a<c;){const h=this.getVisibleRowHeight(a,e);r.set(a,h),o+=h,a+=1}return r}getFloatingColumnWidths(e,t=this.getFirstColumn(e),n=this.calculateTreePaddingX(e)){const{model:s}=e,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:a}=s,r=new Map;for(let c=0;c<o&&c<i;c+=1)r.set(c,this.getVisibleColumnWidth(c,e,t,n));for(let c=0;c<a&&i-c-1>=0;c+=1){const h=i-c-1;r.set(h,this.getVisibleColumnWidth(h,e,t,n))}return r}getVisibleColumnWidths(e,t=this.getFirstColumn(e),n=this.calculateTreePaddingX(e)){const{left:s,leftOffset:i,width:o,model:a}=e;let r=0,c=s;const h=new Map,{columnCount:u}=a;for(;r<o+i&&c<u;){const m=this.getVisibleColumnWidth(c,e,t,n);h.set(c,m),r+=m,c+=1}return h}getFloatingColumnXs(e,t,n){const{model:s}=e,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:a}=s;return Nc(o,a,i,n,t)}getVisibleColumnXs(e,t,n){const s=new Map;let i=-n;for(let o=0;o<t.length;o+=1){const a=t[o],r=_(e,a);s.set(a,i),i+=r}return s}getFloatingRowYs(e,t,n){const{model:s}=e,{floatingTopRowCount:i,floatingBottomRowCount:o,rowCount:a}=s;return Nc(i,o,a,n,t)}getVisibleRowYs(e,t,n){const s=new Map;let i=-n;for(let o=0;o<t.length;o+=1){const a=t[o],r=_(e,a);s.set(a,i),i+=r}return s}getVisibleRowTreeBoxes(e,t,n){const s=new Map,{model:i,theme:o}=n,{treeDepthIndent:a,treeHorizontalPadding:r}=o;return ze(i)&&i.hasExpandableRows&&e.forEach((c,h)=>{const u=_(t,h);if(i.isRowExpandable(u)){const m=i.depthForRow(u),p=m*a+r,g=(m+1)*a+r,C=0,f=c;s.set(h,{x1:p,y1:C,x2:g,y2:f})}}),s}getFloatingLeftWidth(e,t=this.getFloatingColumnWidths(e)){const{model:n}=e,{floatingLeftColumnCount:s}=n;let i=0;for(let o=0;o<s;o+=1)i+=_(t,o);return i}getFloatingRightWidth(e,t=this.getFloatingColumnWidths(e)){const{model:n}=e,{floatingRightColumnCount:s,columnCount:i}=n;let o=0;for(let a=0;a<s;a+=1)o+=_(t,i-a-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+=_(t,o);return i}getFloatingBottomHeight(e,t=this.getFloatingRowHeights(e)){const{model:n}=e,{floatingBottomRowCount:s,rowCount:i}=n;let o=0;for(let a=0;a<s;a+=1)o+=_(t,i-a-1);return o}getTopVisible(e,t,n,s){const i=this.getFloatingTopHeight(e,n);for(let o=0;o<s.length;o+=1){const a=s[o];if(_(t,a)>=i)return a}return 0}getLeftVisible(e,t,n,s){const i=this.getFloatingLeftWidth(e,n);for(let o=0;o<s.length;o+=1){const a=s[o];if(_(t,a)>=i)return a}return 0}getBottomVisible(e,t,n,s,i){const{height:o,theme:a}=e,{scrollBarSize:r}=a,c=this.getFloatingBottomHeight(e,n),h=o-i-r-c;for(let u=s.length-1;u>=0;u-=1){const m=s[u],p=_(t,m),g=_(n,m);if(p+g<=h)return m}return 0}getRightVisible(e,t,n,s,i){const{width:o,theme:a}=e,{scrollBarSize:r}=a,c=this.getFloatingRightWidth(e,n),h=o-i-r-c;for(let u=s.length-1;u>=0;u-=1){const m=s[u],p=_(t,m),g=_(n,m);if(p+g<=h)return m}return 0}getBottomViewport(e,t,n,s){const{height:i,theme:o}=e,{rowHeight:a}=o;return this.getLastIndexViewport(t,n,s,i,a)}getRightViewport(e,t,n,s){const{width:i,theme:o}=e,{columnWidth:a}=o;return this.getLastIndexViewport(t,n,s,i,a)}getLastIndexViewport(e,t,n,s,i){let o=0,a=0;return e.length>0&&(o=e[e.length-1],a=_(t,o)+_(n,o)),a<s&&(o+=Math.ceil((s-a)/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 a=this.initialColumnWidths.get(i);return a!==void 0?a: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 _(this.modelRows,e);const{movedRows:n}=t,s=B.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 _(this.modelColumns,e);const{movedColumns:s}=t,i=B.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 a=this.calculatedRowHeights.get(t);return a??(this.calculatedRowHeights.set(t,Math.ceil(o)),ia(this.calculatedRowHeights),o)}calculateColumnWidth(e,t,n,s=this.getFirstColumn(n),i=this.calculateTreePaddingX(n)){const{theme:o}=n,{autoSizeColumns:a,minColumnWidth:r}=o;if(!a){const{columnWidth:p}=o;return p}const c=this.calculateColumnHeaderWidth(t,n),h=this.calculateColumnDataWidth(t,n),u=this.calculatedColumnWidths.get(t);let m=Math.ceil(Math.max(c,h));return m=Math.max(r,m),u!=null&&u>m?m=u:(this.calculatedColumnWidths.set(t,m),ia(this.calculatedColumnWidths)),e===s&&(m+=i),m}calculateColumnHeaderWidth(e,t){const{model:n,theme:s}=t,{headerFont:i,headerHorizontalPadding:o}=s,a=n.textForColumnHeader(e,0);if(a!==void 0&&a!==""){const r=this.getWidthForFont(i,t);return a.length*r+o*2}return o*2}calculateColumnDataWidth(e,t){const{top:n,height:s,width:i,model:o,theme:a}=t,{floatingTopRowCount:r,floatingBottomRowCount:c,rowCount:h}=o,{font:u,cellHorizontalPadding:m,rowHeight:p,rowHeaderWidth:g,rowFooterWidth:C,scrollBarSize:f}=a;let S=0;const v=this.getWidthForFont(u,t),w=s/p,T=Math.ceil(n+w);return B.iterateAllItems(n,T,r,c,h,y=>{const E=this.getModelRow(y,t),I=o.textForCell(e,E);if(I){const F=m*2;S=Math.max(S,I.length*v+F)}}),S=Math.max(Math.min(S,(i-g-f-C)*Po.MAX_COLUMN_WIDTH),m*2),S}calculateTreePaddingX(e){const{top:t,height:n,model:s,theme:i}=e,{rowHeight:o,treeDepthIndent:a}=i;if(!ze(s)||!s.hasExpandableRows)return 0;let r=0;const c=n/o,h=Math.ceil(t+c);for(let u=t;u<=h;u+=1){const m=this.getModelRow(u,e),p=s.depthForRow(m);r=Math.max(r,a*(p+1))}return r}getWidthForFont(e,t){if(this.fontWidths.has(e))return _(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)),ia(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)),ia(n),this.userRowHeights=n}resetRowHeight(e){const t=new Map(this.userRowHeights);t.delete(e),this.userRowHeights=t,this.calculatedRowHeights.delete(e)}}const Bw=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"}),qn=(d,e)=>{let t=!1;const n=pe(d,{...e,dispose:()=>{t||(t=!0,n.clear(),t=!1)}});return n};function Vw(d,e,t=6){const n=tl.hex.lab.raw(d);return n[0]=Math.max(n[0]-n[0]/t*e,0),`#${tl.lab.hex(n)}`}function Uw(d,e){const[t,n,s]=tl.hex.rgb(d);return`rgba(${t}, ${n}, ${s}, ${e})`}const Mc={colorWithAlpha:Uw,darkenForDepth:Vw};class dt{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 Yu extends dt{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 a=o.index;return this.dragOffset=0,this.draggingIndex=a,this.resizingItems=[a],this.hiddenItems=this.getHiddenItems(a,n).reverse(),this.targetSizes.clear(),this.addTargetSize(n,a),this.updateCursor(n,a),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(),a=i[this.visibleOffsetProperty],r=i[this.marginProperty],c=i[this.calculatedSizesProperty],h=i[this.modelIndexesProperty],u=i[this.firstIndexProperty],m=i[this.treePaddingProperty],p=new Map;let g=this.resizingItems[this.resizingItems.length-1];for(;g!=null;){const C=_(a,g),f=n-r-C-this.dragOffset,S=_(h,g),v=this.targetSizes.get(S),w=this.resizingItems.length>1,T=this.hiddenItems.indexOf(g);let y=_(c,S);g===u&&(y+=m);let E=f;Math.abs(f-y)<=o.headerResizeSnapThreshold?E=y:v!==void 0&&f>v&&(w&&T!==0||T>0)?E=v:f<=o.headerResizeHiddenSnapThreshold&&(E=0),p.set(S,E),f<-o.headerResizeSnapThreshold&&E===0?T>=0&&w?(this.resizingItems.pop(),this.removeTargetSize(i,g),g=this.resizingItems[this.resizingItems.length-1],this.dragOffset-=this.targetSizes.get(_(h,g))??0):(g=this.getNextShownItem(g,i),g!==null&&(this.resizingItems.push(g),this.addTargetSize(i,g))):v!==void 0&&f>v+o.headerResizeSnapThreshold&&E===v?T>0?(this.dragOffset+=E,g=this.hiddenItems[T-1],this.resizingItems.push(g),this.addTargetSize(i,g)):w?(this.resizingItems.pop(),this.removeTargetSize(i,g),g=this.resizingItems[this.resizingItems.length-1]):g=null:g=null}return p.forEach((C,f)=>{const S=s[this.initialSizesProperty].get(f)??c.get(f);C===S?this.resetSize(s,f):this.setSize(s,f,C)}),this.updateCursor(i,this.draggingIndex),!0}onUp(e,t){return this.draggingIndex!=null&&(this.draggingIndex=void 0,this.resizingItems=[],this.hiddenItems=[],this.targetSizes.clear(),this.updateSeparator(t,null)),!1}onDoubleClick(e,t){const{metrics:n,metricCalculator:s}=t,{model:i}=t.props,o=t.getTheme();if(!n)throw new Error("metrics not set");const a=this.getSeparator(e,n,i,o);if(a!=null){const r=n[this.modelIndexesProperty],c=_(r,a.index),h=_(n[this.calculatedSizesProperty],c),u=s[this.initialSizesProperty].get(c);return h===u?this.resetSize(s,c):this.setSize(s,c,h),t.forceUpdate(),!0}return!1}updateCursor(e,t){const n=e[this.visibleSizesProperty];_(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,a=_(n,t);let r=s.get(a);(r==null||r===0)&&(r=_(i,a)+o),this.targetSizes.set(a,r)}removeTargetSize(e,t){const n=e[this.modelIndexesProperty],s=_(n,t);this.targetSizes.delete(s)}}class Cr extends Yu{static getColumnSeparator(e,t,n,s){if(!s.allowColumnResize)return null;const{x:i,y:o,columnHeaderDepth:a}=e,{modelColumns:r}=t,c=B.getColumnSeparatorIndex(i,o,t,s);return c==null||a==null||a>0?null:r.get(c)!=null?{index:c,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=B.getHiddenColumns;getNextShownItem=B.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=Cr.getColumnSeparator}class Pt{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 a=s,r=Math.min(t.length-1,i),c=t;for(;r>=a;){const h=Math.ceil((r+a)/2),u=Pt.truncate(t,h);if(e.measureText(u).width<=n){if(c=u,a===h)break;a=h}else if(h===0){c=u;break}else r=h-1}return c}static truncateToWidth(e,t,n,s=Pt.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),a=Math.min(Math.ceil(n/s*2),t.length);return Pt.binaryTruncateToWidth(e,t,n,o,a,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:a}=n;e.translate(o,a),this.drawGridBackground(e,t,s==null&&i==null),this.drawCellContents(e,t),this.drawFloatingRows(e,t),this.drawFloatingColumns(e,t),e.translate(-o,-a)}drawFloatingRows(e,t){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=t,{floatingTopRowCount:a,floatingBottomRowCount:r,floatingRows:c,rowCount:h,visibleColumns:u,allRowYs:m,allRowHeights:p}=i;if(c.length!==0){o.floatingRowBackgroundColors&&this.drawRowStripesForRows(e,t,c,o.floatingRowBackgroundColors),n==null&&s==null&&this.drawFloatingMouseRowHover(e,t),this.drawGridLinesForItems(e,t,u,c,o.floatingGridColumnColor,o.floatingGridRowColor),this.drawCellBackgroundsForItems(e,t,u,c),this.drawFloatingBorders(e,t),a>0&&this.drawSelectedRanges(e,t,{top:0,bottom:a-1,maxY:_(m,a-1)+_(p,a-1)-.5}),r>0&&this.drawSelectedRanges(e,t,{top:h-r-1,bottom:h-1,minY:_(m,h-r)+.5,maxY:_(m,h-1)+_(p,h-1)-.5});for(let g=0;g<u.length;g+=1){const C=u[g];for(let f=0;f<c.length;f+=1){const S=c[f];this.drawCellContent(e,t,C,S)}}}}drawFloatingColumns(e,t){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=t,{floatingLeftColumnCount:a,floatingRightColumnCount:r,floatingLeftWidth:c,floatingRightWidth:h,floatingColumns:u,gridX:m,maxX:p,columnCount:g,visibleRows:C,allColumnXs:f,allColumnWidths:S,width:v,height:w}=i;if(u.length!==0){o.floatingRowBackgroundColors&&(this.drawRowStripesForRows(e,t,C,o.floatingRowBackgroundColors,0,c),this.drawRowStripesForRows(e,t,C,o.floatingRowBackgroundColors,v-m-h,p)),n==null&&s==null&&this.drawFloatingMouseRowHover(e,t),e.save(),e.beginPath(),e.rect(0,0,c,w),e.clip(),this.drawGridLinesForItems(e,t,u,C,o.floatingGridColumnColor,o.floatingGridRowColor),e.restore(),this.drawCellBackgroundsForItems(e,t,u,C),this.drawFloatingBorders(e,t),a>0&&this.drawSelectedRanges(e,t,{left:0,maxX:_(f,a-1)+_(S,a-1)}),r>0&&this.drawSelectedRanges(e,t,{left:g-r,right:g-1,minX:_(f,g-r)+.5,maxX:_(f,g-1)+_(S,g-1)});for(let T=0;T<u.length;T+=1){const y=u[T];for(let E=0;E<C.length;E+=1){const I=C[E];this.drawCellContent(e,t,y,I)}}}}drawFloatingBorders(e,t){const{metrics:n,theme:s}=t,{floatingTopRowCount:i,floatingBottomRowCount:o,floatingLeftColumnCount:a,floatingRightColumnCount:r,rowCount:c,columnCount:h,allRowYs:u,allColumnXs:m,allRowHeights:p,allColumnWidths:g,maxX:C,maxY:f}=n,{floatingDividerOuterColor:S,floatingDividerInnerColor:v}=s;if(e.lineWidth=3,e.beginPath(),e.strokeStyle=S,i>0){const w=_(u,i-1)+_(p,i-1)+.5;e.moveTo(0,w),e.lineTo(C,w)}if(o>0){const w=_(u,c-o)-.5;e.moveTo(0,w),e.lineTo(C,w)}if(a>0){const w=_(m,a-1)+_(g,a-1)+.5;e.moveTo(w,0),e.lineTo(w,f)}if(r>0){const w=_(m,h-r)-.5;e.moveTo(w,0),e.lineTo(w,f)}if(e.stroke(),e.beginPath(),e.lineWidth=1,e.strokeStyle=v,i>0){const w=_(u,i-1)+_(p,i-1)+.5;e.moveTo(0,w),e.lineTo(C,w)}if(o>0){const w=_(u,c-o)-.5;e.moveTo(0,w),e.lineTo(C,w)}if(a>0){const w=_(m,a-1)+_(g,a-1)+.5;e.moveTo(w,0),e.lineTo(w,f)}if(r>0){const w=_(m,h-r)-.5;e.moveTo(w,0),e.lineTo(w,f)}e.stroke()}drawGridBackground(e,t,n=!1){this.drawRowStripes(e,t),n&&(this.drawMouseColumnHover(e,t),this.drawMouseRowHover(e,t)),this.drawGridLines(e,t),this.drawCellBackgrounds(e,t);const{metrics:s}=t,{bottom:i,right:o,floatingBottomRowCount:a,floatingLeftColumnCount:r,floatingRightColumnCount:c,floatingTopRowCount:h,columnCount:u,rowCount:m,allRowHeights:p,allRowYs:g,allColumnXs:C,allColumnWidths:f,width:S,height:v}=s;this.drawSelectedRanges(e,t,{bottom:Math.min(i,m-a-1),right:Math.min(o,u-c-1),minX:r>0&&C.has(r+1)?_(C,r+1):-10,minY:h>0&&g.has(h+1)?_(g,h+1):-10,maxX:c>0&&C.has(u-c-1)?_(C,u-c-1)+_(f,u-c-1)-.5:S+10,maxY:a>0&&g.has(m-a-1)?_(g,m-a-1)+_(p,m-a-1)-.5:v+10})}drawRowStripes(e,t){const{metrics:n,theme:s}=t,{visibleRows:i}=n,{rowBackgroundColors:o}=s;o&&this.drawRowStripesForRows(e,t,i,o)}drawRowStripesForRows(e,t,n,s,i=0,o=t.metrics.maxX){const{theme:a,metrics:r,model:c}=t,{maxDepth:h,shadowBlur:u,shadowColor:m}=a,p=this.getCachedBackgroundColors(s,h),{allRowYs:g,allRowHeights:C}=r,f=new Map,S=[],v=[],w=(T,y)=>{const E=ze(c)?c.depthForRow(T):0,I=p[T%p.length],F=I[Math.min(E,I.length-1)];if(f.has(F)||f.set(F,[]),f.get(F).push(T),y!=null){const N=ze(c)?c.depthForRow(y):0;N<E?S.push(T):N>E&&v.push(y)}};for(let T=0;T<n.length;T+=1){const y=n[T],E=T>0?n[T-1]:void 0;w(y,E)}if(f.forEach((T,y)=>{e.fillStyle=y,e.beginPath();for(let E=0;E<T.length;E+=1){const I=T[E],F=_(g,I),N=_(C,I);e.rect(i,F,o,N)}e.fill()}),S.length>0){e.save();const T=this.getCachedColorWithAlpha(m,.15),y=this.getCachedColorWithAlpha(m,0),E=e.createLinearGradient(0,0,0,u);E.addColorStop(0,T),E.addColorStop(1,y),e.fillStyle=E;for(let I=0;I<S.length;I+=1){const F=S[I],N=_(g,F);e.translate(0,N),e.fillRect(i,0,o,u),e.translate(0,-N)}e.restore()}if(v.length>0){e.save();const T=this.getCachedColorWithAlpha(m,0),y=this.getCachedColorWithAlpha(m,.15),E=e.createLinearGradient(0,0,0,u);E.addColorStop(0,T),E.addColorStop(1,y),e.fillStyle=E;for(let I=0;I<v.length;I+=1){const F=v[I],N=_(g,F),H=_(C,F),P=N+H-u;e.translate(0,P),e.fillRect(i,0,o,u),e.translate(0,-P)}e.restore()}}drawMouseColumnHover(e,t){const{mouseX:n,mouseY:s,theme:i,metrics:o}=t;if(n==null||s==null)return;const a=B.getColumnAtX(n,o);if(a==null||i.columnHoverBackgroundColor==null)return;const{allColumnWidths:r,allColumnXs:c,maxY:h}=o;if(s>h)return;const u=_(c,a),m=_(r,a);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:a}=o;if(n>a||i.rowHoverBackgroundColor==null)return;const r=B.getRowAtY(s,o);r!=null&&this.drawMouseRowHoverForRow(e,t,r)}drawFloatingMouseRowHover(e,t){const{mouseX:n,mouseY:s,theme:i,metrics:o}=t,{maxX:a,floatingTopRowCount:r,floatingBottomRowCount:c,rowCount:h,rowFooterWidth:u}=o;if(n==null||s==null||n>a+u||i.rowHoverBackgroundColor==null)return;const m=B.getRowAtY(s,o);m!=null&&(m<r||h-c<=m)&&this.drawMouseRowHoverForRow(e,t,m)}drawMouseRowHoverForRow(e,t,n){const{metrics:s,selectedRanges:i,theme:o}=t,{allRowHeights:a,allRowYs:r,maxX:c}=s,h=_(r,n),u=_(a,n);o.rowHoverBackgroundColor!=null&&(e.fillStyle=o.rowHoverBackgroundColor);for(let m=0;m<i.length;m+=1){const{startRow:p,endRow:g}=i[m];if(p!=null&&g!=null&&p<=n&&g>=n){o.selectedRowHoverBackgroundColor!=null&&(e.fillStyle=o.selectedRowHoverBackgroundColor);break}}e.fillRect(0,h,c,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 a=0;a<n.length;a+=1){const r=n[a],c=_(i,r)+.5;e.moveTo(c,0),e.lineTo(c,o)}}drawGridLinesForRows(e,t,n){const{metrics:s}=t,{allRowYs:i,maxX:o}=s,a=o;for(let r=0;r<n.length;r+=1){const c=n[r],h=_(i,c)+.5;e.moveTo(.5,h),e.lineTo(a-.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 a=0;a<s.length;a+=1){const r=s[a],c=a+1<s.length?s[a+1]:void 0;this.drawCellBackground(e,t,o,r,c)}}e.restore()}drawCellBackground(e,t,n,s,i){const{metrics:o,model:a,theme:r}=t,{firstColumn:c,modelColumns:h,modelRows:u,allColumnXs:m,allColumnWidths:p,allRowYs:g,allRowHeights:C}=o,f=_(u,s),S=_(h,n),v=a.backgroundColorForCell(S,f,r),w=n===c,T=ze(a)&&a.hasExpandableRows;if(v!=null){const y=_(m,n)+1,E=_(g,s)+1,I=_(p,n)-1,F=_(C,s)-1;e.fillStyle=v,e.fillRect(y,E,I,F)}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:a,height:r}=s,c=_(i,n),h=_(o,n);e.save(),e.beginPath(),e.rect(c,0,h,r),e.clip();for(let u=0;u<a.length;u+=1){const m=a[u];this.drawCellContent(e,t,n,m)}e.restore()}getTextRenderMetrics(e,t,n){const{metrics:s,model:i,theme:o}=e,{firstColumn:a,allColumnXs:r,allColumnWidths:c,allRowYs:h,allRowHeights:u,modelRows:m,modelColumns:p}=s,{cellHorizontalPadding:g,treeDepthIndent:C,treeHorizontalPadding:f}=o,S=_(m,n),v=_(p,t),w=i.textAlignForCell(v,S),T=_(r,t),y=_(h,n),E=_(c,t),I=_(u,n),F=t===a;let N=0;ze(i)&&i.hasExpandableRows&&F&&(N=C*(i.depthForRow(n)+1)+f);const H=E-N;let P=T+g;const O=y+I*.5;return w==="right"?P=T+H-g:w==="center"&&(P=T+H*.5),P+=N,{width:H-g*2,x:P,y:O}}drawCellContent(e,t,n,s,i){const{metrics:o,model:a,theme:r}=t,{firstColumn:c,fontWidths:h,modelColumns:u,modelRows:m,allRowHeights:p}=o,{textColor:g}=r,C=_(p,s),f=_(m,s),S=_(u,n),v=i??a.textForCell(S,f),w=a.truncationCharForCell(S,f),T=n===c;if(v&&C>0){const y=a.textAlignForCell(S,f)||"left";e.textAlign=y;const E=a.colorForCell(S,f,r)||g;e.fillStyle=E,e.save();const{width:I,x:F,y:N}=this.getTextRenderMetrics(t,n,s),H=h.get(e.font)??Pt.DEFAULT_FONT_WIDTH,P=this.getCachedTruncatedString(e,v,I,H,w),O=a.tokensForCell(S,f,P.length);if(P){let k=0,L=0,A=F;const{actualBoundingBoxDescent:U}=e.measureText(P);for(;L<P.length;){const j=O[k],W=L===j?.start?j:null,ie=W?.end??j?.start??P.length,se=P.substring(L,ie),{width:G}=e.measureText(se),K=se.endsWith("…")?e.measureText(se.substring(0,se.length-1)).width:G;W!=null?(e.fillStyle=r.hyperlinkColor,e.fillText(se,A,N),e.fillRect(A,N+U,K,1)):(e.fillStyle=E,e.fillText(se,A,N)),A+=G,L=ie,W!=null&&(k+=1)}}e.restore()}T&&ze(a)&&a.hasExpandableRows&&this.drawCellRowTreeMarker(e,t,s)}drawCellRowTreeMarker(e,t,n){const{metrics:s,model:i,mouseX:o,mouseY:a,theme:r}=t,{firstColumn:c,gridX:h,gridY:u,allColumnXs:m,allColumnWidths:p,allRowYs:g,allRowHeights:C,visibleRowTreeBoxes:f}=s,{treeMarkerColor:S,treeMarkerHoverColor:v}=r,w=_(m,c),T=_(p,c),y=_(g,n),E=_(C,n);if(!ze(i)||!i.isRowExpandable(n))return;const I=_(f,n),F=o!=null&&a!=null&&o>=h+w&&o<=h+w+T&&a>=u+y&&a<=u+y+E?v:S;this.drawTreeMarker(e,t,w,y,I,F,i.isRowExpanded(n))}drawTreeMarker(e,t,n,s,i,o,a){const{x1:r,y1:c,x2:h,y2:u}=i,m=a?"⊟":"⊞",p=n+(r+h)*.5+.5,g=s+(c+u)*.5+.5;e.fillStyle=o,e.textAlign="center",e.fillText(m,p,g)}drawCellRowTreeDepthLines(e,t,n,s){const{metrics:i,model:o,theme:a}=t;if(!ze(o))return;const r=o.depthForRow(n);if(r===0)return;const{firstColumn:c,allColumnXs:h,allRowYs:u,allRowHeights:m}=i,{treeDepthIndent:p,treeHorizontalPadding:g,treeLineColor:C}=a,f=_(h,c),S=_(u,n),v=_(m,n),w=s!==void 0?o.depthForRow(s):0,T=r>w?r-w:0;if(e.strokeStyle=C,e.lineWidth=1,r-T>0){e.beginPath();for(let y=0;y<r-T;y+=1){const E=f+y*p+p*.5+g+.5;e.moveTo(E,S),e.lineTo(E,S+v)}e.stroke()}if(T>0){e.beginPath();for(let y=r-T;y<r;y+=1){const E=f+y*p+p*.5+g+.5;e.moveTo(E,S),e.lineTo(E,S+Math.ceil(v/2)),e.moveTo(E-.5,S+Math.ceil(v/2)+.5),e.lineTo(E+p-.5,S+Math.ceil(v/2)+.5)}e.stroke()}}getCachedTruncatedString=qn((e,t,n,s,i)=>Pt.truncateToWidth(e,t,n,s,i),{max:1e4});getCachedBackgroundColors=qn((e,t)=>e.split(" ").map(n=>{const s=[];for(let i=0;i<t;i+=1)s.push(Mc.darkenForDepth(n,i,t));return s}),{max:1e3});getCachedColorWithAlpha=qn((e,t)=>Mc.colorWithAlpha(e,t),{max:1e3});getCachedColorIsDark=qn(e=>sr.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:a,isDragging:r,model:c}=t,{columnHeaderHeight:h,floatingColumns:u,gridX:m,width:p,visibleColumns:g,allColumnWidths:C,allColumnXs:f,floatingLeftColumnCount:S,floatingLeftWidth:v,floatingRightWidth:w,modelColumns:T,columnHeaderMaxDepth:y}=o;if(h<=0)return;const{headerHiddenSeparatorSize:E,headerHiddenSeparatorHoverColor:I,headerSeparatorColor:F,headerSeparatorHoverColor:N}=i,H=h*.5,P=h*(y-1)+h*.5-H*.5,O=S>0;if(e.save(),this.drawColumnHeadersForRange(e,t,[g[0],g[g.length-1]],{minX:m+v,maxX:p-w}),O&&this.drawColumnHeadersForRange(e,t,[u[0],u[u.length-1]],{minX:m,maxX:m+v}),F){e.strokeStyle=F;const k=[...C.entries()].filter(([L,A])=>A===0).map(([L])=>L);e.beginPath(),e.fillStyle=F;for(let L=0;L<k.length;L+=1){const A=k[L],U=_(f,A),j=_(C,A),W=m+U+j+.5-E*.5;e.rect(W,P,E,H)}e.fill()}if(N){let{index:k,depth:L}=a??{};if(k==null&&n!=null&&s!=null){const U=Cr.getColumnSeparator(B.getGridPointFromXY(n,s,o),o,c,i);k=U?.index,L=U?.depth}let A;if(k==null)A=!1;else{const U=T.get(k),j=T.get(k+1);U==null||j==null?A=!1:A=c.textForColumnHeader(U,L)!==c.textForColumnHeader(j,L)}if(A&&k!=null&&L!=null&&(!r||a!=null)){e.strokeStyle=N;const U=_(f,k),j=_(C,k),W=m+U+j+.5,ie=g.indexOf(k),se=ie<g.length-1?g[ie+1]:null,G=se!=null?C.get(se):null,K=j===0,te=G!=null&&G===0;K?(e.strokeStyle=I,e.fillStyle=I,e.fillRect(W,P,E*.5,H)):te&&(e.fillStyle=N,e.fillRect(W-E*.5,P,E*.5,H)),e.beginPath(),e.moveTo(W,(y-L-1)*h),e.lineTo(W,(y-L)*h-1),e.stroke()}}e.restore()}drawColumnHeadersForRange(e,t,n,s){const{model:i}=t,{columnHeaderMaxDepth:o}=i;if(o!==0)for(let a=0;a<=o;a+=1)this.drawColumnHeadersAtDepth(e,t,n,s,a)}drawColumnHeadersAtDepth(e,t,n,s,i){const{metrics:o,model:a,theme:r}=t,{modelColumns:c,allColumnXs:h,gridX:u,userColumnWidths:m,allColumnWidths:p,movedColumns:g}=o,{columnHeaderHeight:C,columnWidth:f}=r,{columnHeaderMaxDepth:S}=a,{minX:v,maxX:w}=s,T=w-v;if(S===0)return;const y=n[0],E=n[1];if(e.save(),e.translate(0,(S-i-1)*C),i===0){this.drawColumnHeader(e,t,"",v,w);for(let I=y;I<=E;I+=1)this.drawColumnHeaderAtIndex(e,t,I,s)}if(i>0){let I=y;for(;I<=E;){const{columnCount:F}=o,N=_(c,I),H=a.textForColumnHeader(N,i),P=a.colorForColumnHeader(N,i);let O=_(h,I)+u,k=O+_(p,I);if(H!=null){let L=I-1;for(;L>=0&&(k-O<T||O>v);){const W=c.get(L)??B.getModelIndex(L,g);if(W==null||a.textForColumnHeader(W,i)!==H)break;const ie=m.get(W)??p.get(L)??f;O-=ie,L-=1}let A=I+1;for(;A<F&&(k-O<T||k<w);){const W=c.get(A)??B.getModelIndex(A,g);if(a.textForColumnHeader(W,i)!==H)break;const ie=m.get(W)??p.get(A)??f;k+=ie,A+=1}I=A-1;const U=k-O>=T;let j=O;U&&(k<w?j=k-T:O<v&&(j=v)),this.drawColumnHeader(e,t,H,j,Math.min(k-O,T),{backgroundColor:P??void 0},s)}I+=1}}e.restore()}drawColumnHeaderAtIndex(e,t,n,s){const{metrics:i,model:o}=t,{modelColumns:a,allColumnWidths:r,allColumnXs:c,gridX:h}=i,u=_(r,n),m=_(c,n)+h,p=_(a,n),g=o.textForColumnHeader(p);g!=null&&this.drawColumnHeader(e,t,g,m,u,{backgroundColor:o.colorForColumnHeader(p)??void 0},s)}drawColumnHeader(e,t,n,s,i,o,a){if(i<=0)return;const{metrics:r,theme:c}=t,{headerHorizontalPadding:h,columnHeaderHeight:u,headerBackgroundColor:m,headerColor:p,headerSeparatorColor:g,black:C,white:f}=c,{fontWidths:S,width:v}=r,w=S.get(e.font)??Pt.DEFAULT_FONT_WIDTH,y=(i-h*2)/w,{backgroundColor:E=m,separatorColor:I=g}=o??{};let{textColor:F=p}=o??{};try{const K=this.getCachedColorIsDark(E),te=this.getCachedColorIsDark(F);K&&te?F=f:!K&&!te&&(F=C)}catch{}let{minX:N=0,maxX:H=v}=a??{};e.save(),e.rect(N,0,H-N,u),e.clip(),E!=null&&(e.fillStyle=E,e.fillRect(s,0,i,u)),I!=null&&(e.strokeStyle=I,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=F;let P=n;y<=0?P="":P.length>y&&(P=`${P.substring(0,y-1)}…`);const O=P.length*w;let k=s+i*.5;const L=u*.5;N+=h,H-=h;const A=s+h,U=je(A,N,H),j=s+i-h,ie=je(j,N,H)-U,se=k-O*.5<N,G=k+O*.5>H;se?O<ie?k=N+O*.5:k=j-O*.5:G&&(O<ie?k=H-O*.5:k=A+O*.5),e.textAlign="center",e.fillText(P,k,L),e.restore()}drawRowHeaders(e,t){const{mouseX:n,mouseY:s,metrics:i,theme:o,draggingRowSeparator:a}=t,{gridY:r,rowHeaderWidth:c,height:h,visibleRows:u,allRowHeights:m,allRowYs:p}=i;if(c<=0)return;const{headerBackgroundColor:g,headerColor:C,headerHiddenSeparatorSize:f,headerHiddenSeparatorHoverColor:S,headerSeparatorColor:v,headerSeparatorHoverColor:w}=o,T=c*.5,y=c*.5-T*.5;if(e.save(),e.beginPath(),e.fillStyle=g,e.fillRect(0,0,c,h),v){e.strokeStyle=v,e.beginPath(),e.moveTo(0,r+.5),e.lineTo(c,r+.5);const E=[];let I=!1;for(let F=0;F<u.length;F+=1){const N=u[F],H=_(p,N),P=_(m,N);if(P>0){const O=r+H+P+.5;e.moveTo(0,O),e.lineTo(c,O),I=!1}else I||(I=!0,E.push(N))}e.moveTo(c-.5,0),e.lineTo(c-.5,h),e.stroke(),e.beginPath(),e.fillStyle=v;for(let F=0;F<E.length;F+=1){const N=E[F],H=_(p,N),P=_(m,N),O=r+H+P+.5-f*.5;e.rect(y,O,T,f)}e.fill()}if(w){let{index:E=null}=a??{};if(E==null&&n!=null&&s!=null&&(E=B.getRowSeparatorIndex(n,s,i,o)),E!=null){e.strokeStyle=w;const I=_(p,E),F=_(m,E),N=r+I+F+.5,H=u.indexOf(E),P=H<u.length-1?u[H+1]:null,O=P!=null?m.get(P):null,k=F===0,L=O!=null&&O===0;k?(e.strokeStyle=S,e.fillStyle=S,e.fillRect(y,N,T,f*.5)):L&&(e.fillStyle=w,e.fillRect(y,N-f*.5,T,f*.5)),e.beginPath(),e.moveTo(.5,N),e.lineTo(c+.5,N),e.stroke()}}e.beginPath(),e.rect(0,r,c,h),e.clip(),e.fillStyle=C,e.textAlign="right";for(let E=0;E<u.length;E+=1){const I=u[E],F=_(m,I),N=_(p,I)+r;this.drawRowHeader(e,t,I,N,F)}e.restore()}drawRowHeader(e,t,n,s,i){if(i<=0)return;const{metrics:o,model:a,theme:r}=t,{modelRows:c,rowHeaderWidth:h}=o,u=_(c,n),m=h-r.cellHorizontalPadding,p=s+i*.5;e.fillText(a.textForRowHeader(u),m,p)}drawRowFooters(e,t){const{mouseX:n,mouseY:s,metrics:i,model:o,theme:a,draggingRowSeparator:r}=t,{gridY:c,gridX:h,maxX:u,modelRows:m,rowFooterWidth:p,height:g,verticalBarWidth:C,visibleRows:f,allRowHeights:S,allRowYs:v,width:w}=i;if(p<=0)return;const{cellHorizontalPadding:T,headerBackgroundColor:y,headerColor:E,headerHiddenSeparatorSize:I,headerHiddenSeparatorHoverColor:F,headerSeparatorColor:N,headerSeparatorHoverColor:H}=a,P=p*.5,O=p*.5-P*.5,k=Math.min(h+u,w-p-C);if(e.save(),e.beginPath(),e.fillStyle=y,e.fillRect(k,c,p,g),N){e.strokeStyle=N,e.beginPath(),e.moveTo(k,c+.5),e.lineTo(p,c+.5);const A=[];let U=!1;for(let j=0;j<f.length;j+=1){const W=f[j],ie=_(v,W),se=_(S,W);if(se>0){const G=c+ie+se+.5;e.moveTo(k+.5,G),e.lineTo(k+p-.5,G),U=!1}else U||(U=!0,A.push(W))}e.moveTo(k+.5,c),e.lineTo(k+.5,g),e.stroke(),e.beginPath(),e.fillStyle=N;for(let j=0;j<A.length;j+=1){const W=A[j],ie=_(v,W),se=_(S,W),G=c+ie+se+.5-I*.5;e.rect(k+O,G,P,I)}e.fill()}if(H){let{index:A=null}=r??{};if(A==null&&n!=null&&s!=null&&(A=B.getRowSeparatorIndex(n,s,i,a)),A!=null){e.strokeStyle=H;const U=_(v,A),j=_(S,A),W=c+U+j+.5,ie=f.indexOf(A),se=ie<f.length-1?f[ie+1]:null,G=se!=null?S.get(se):null,K=j===0,te=G!=null&&G===0;K?(e.strokeStyle=F,e.fillStyle=F,e.fillRect(O,W,P,I*.5)):te&&(e.fillStyle=H,e.fillRect(O,W-I*.5,P,I*.5)),e.beginPath(),e.moveTo(k+.5,W),e.lineTo(k+p+.5,W),e.stroke()}}e.beginPath(),e.rect(k,c,p,g),e.clip(),e.fillStyle=E,e.textAlign="left";const L=k+T;for(let A=0;A<f.length;A+=1){const U=f[A],j=_(S,U);if(j>0){const W=_(v,U)+c,ie=_(m,U),se=W+j*.5;e.fillText(o.textForRowFooter(ie),L,se)}}e.restore()}drawSelectedRanges(e,t,n={}){const{cursorColumn:s,cursorRow:i,draggingRow:o,draggingColumn:a,editingCell:r,metrics:c,model:h,selectedRanges:u,theme:m}=t,{allColumnWidths:p,allColumnXs:g,allRowHeights:C,allRowYs:f,width:S,height:v}=c,{left:w=c.left,top:T=c.top,right:y=c.right,bottom:E=c.bottom,minY:I=-10,maxY:F=v+10,minX:N=-10,maxX:H=S+10}=n;if(u.length===0)return;const P=Ze(h)&&h.isEditable&&r==null&&o==null&&a==null&&s!=null&&i!=null&&g.has(s)&&f.has(i);if(P){const O=_(g,s),k=_(f,i),L=_(p,s),A=_(C,i);e.save(),e.beginPath(),e.rect(0,0,S,v),e.rect(O,k,L,A),e.clip("evenodd")}e.beginPath();for(let O=0;O<u.length;O+=1){const k=u[O],L=k.startColumn!==null?k.startColumn:w,A=k.startRow!==null?k.startRow:T,U=k.endColumn!==null?k.endColumn:y,j=k.endRow!==null?k.endRow:E;if(j>=T&&E>=A&&U>=w&&y>=L){const W=L>=w&&g.has(L)?Math.round(_(g,L))+.5:N,ie=A>=T&&f.has(A)?Math.max(Math.round(_(f,A))+.5,.5):I,se=U<=y&&g.has(U)?Math.round(_(g,U)+_(p,U))-.5:H,G=j<=E&&f.has(j)?Math.round(_(f,j)+_(C,j))-.5:F;e.rect(W,ie,se-W,G-ie)}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()}P&&s!=null&&i!=null&&(e.restore(),this.drawActiveCell(e,t,s,i))}drawActiveCell(e,t,n,s,i=Pt.ACTIVE_CELL_BORDER_WIDTH){const{metrics:o,theme:a}=t,{allColumnWidths:r,allColumnXs:c,allRowHeights:h,allRowYs:u}=o,m=_(c,n),p=_(u,s),g=_(r,n),C=_(h,s);let f=m-i*.5,S=p-i*.5,v=g+i,w=C+i;f<=0&&(v+=f-1,f=1),S<=0&&(w+=S-1,S=1);const{lineWidth:T}=e;e.beginPath(),e.lineWidth=i,e.strokeStyle=a.selectionOutlineColor,this.drawRoundedRect(e,f,S,v,w),e.stroke(),e.lineWidth=T}drawRoundedRect(e,t,n,s,i,o=Pt.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:a}=t;if(n==null||i==null)return;const{range:r,depth:c}=n,{gridX:h,gridY:u,allColumnXs:m,allColumnWidths:p,height:g,width:C,columnHeaderMaxDepth:f,columnHeaderHeight:S,movedColumns:v,modelColumns:w,floatingLeftWidth:T}=s,y=w.get(r[0])??B.getModelIndex(r[0],v),E=a.getColumnHeaderGroup(y,c);if(c>0&&!E)return;const[I,F]=r,N=_(m,I),P=_(m,F)+_(p,F)-N,O=n.left,{backgroundColor:k,font:L,headerFont:A,reorderOffset:U,shadowBlur:j,shadowColor:W}=o,ie=(f-c-1)*S;e.save(),e.translate(h,0),e.save(),e.beginPath(),e.rect(T,0,C,g),e.clip(),e.fillStyle=k,e.fillRect(N,ie,P,g),e.restore(),e.translate(0,U),e.save(),e.shadowColor=W,e.shadowBlur=j,e.fillStyle=k,e.fillRect(n.left,ie+U,n.width,g),e.restore(),e.beginPath(),e.rect(n.left,ie,n.width+1,g),e.clip(),e.translate(O-N,0),e.font=A;const se=[];for(let G=n.range[0];G<=n.range[1];G+=1)se.push(G);this.drawColumnHeaders(e,t),this.drawColumnHeadersForRange(e,t,[se[0],se[se.length-1]],{minX:N,maxX:C}),e.translate(0,u),e.font=L,this.drawGridBackground(e,t);for(let G=I;G<=F;G+=1)this.drawColumnCellContents(e,t,G);e.restore()}drawDraggingRow(e,t){const{draggingRow:n,draggingRowOffset:s,metrics:i,mouseY:o,theme:a}=t;if(n==null||o==null)return;const{gridX:r,gridY:c,allRowYs:h,allRowHeights:u,width:m}=i,p=_(h,n),g=_(u,n)+1,{backgroundColor:C,font:f,headerFont:S,reorderOffset:v,shadowBlur:w,shadowColor:T}=a;e.save(),e.translate(0,c),e.fillStyle=C,e.fillRect(0,p,m,g),e.translate(r+v,o-p-c-(s??0)),e.save(),e.shadowColor=T,e.shadowBlur=w,e.fillStyle=C,e.fillRect(-r,p,m,g),e.restore(),e.beginPath(),e.rect(-r,p,m,g),e.clip(),e.font=f,this.drawGridBackground(e,t),this.drawCellContents(e,t),e.translate(-r,-c),e.font=S,this.drawRowHeaders(e,t),e.restore()}drawScrollBars(e,t){const{isDraggingHorizontalScrollBar:n,isDraggingVerticalScrollBar:s,isDragging:i,metrics:o,mouseX:a,mouseY:r,theme:c}=t;if(c.scrollBarSize<=0)return;const{width:h,height:u,handleHeight:m,handleWidth:p,scrollX:g,scrollY:C,hasHorizontalBar:f,hasVerticalBar:S,barWidth:v,barHeight:w,barLeft:T,barTop:y}=o,{scrollBarBackgroundColor:E,scrollBarHoverBackgroundColor:I,scrollBarCasingColor:F,scrollBarCornerColor:N,scrollBarColor:H,scrollBarHoverColor:P,scrollBarActiveColor:O,scrollBarSize:k,scrollBarHoverSize:L,scrollBarCasingWidth:A,scrollBarSelectionTick:U,scrollBarSelectionTickColor:j,scrollBarActiveSelectionTickColor:W,autoSelectRow:ie,autoSelectColumn:se}=c,G=a!=null&&r!=null&&a<=h&&r<=u,K=s||S&&!n&&!i&&a!=null&&r!=null&&a>=h-L&&r>=y&&G,te=n||f&&!s&&!i&&!K&&a!=null&&r!=null&&r>=u-L&&a>=T&&G,oe=te?L:k,de=K?L:k;if(e.translate(T,y),f&&S&&(e.fillStyle=F,e.fillRect(h-T-k,u-y-k,k,k),e.fillStyle=N,e.fillRect(h-T-k+A,u-y-k+A,k-A,k-A)),f){const ee=g,re=u-y-oe;if(e.fillStyle=F,e.fillRect(0,re,v,oe-A),e.fillStyle=te?I:E,e.fillRect(0,re+A,v,oe-A),n?e.fillStyle=O:te?e.fillStyle=P:e.fillStyle=H,e.fillRect(ee,re+A,p,oe-A),!ie&&U&&j!=null&&W!=null){e.fillStyle=j;const{selectedRanges:we,cursorColumn:xe}=t,{lastLeft:Oe,columnCount:Jt}=o,ss=[...we].filter(ye=>ye.startColumn!=null&&ye.endColumn!=null).map(ye=>[ye.startColumn,ye.endColumn]).sort(B.compareRanges),Tn=B.mergeSortedRanges(ss),kt=ye=>ye<=Oe?ye/Oe*(v-p):v-p+(ye-Oe)/(Jt-Oe)*p;for(let ye=0;ye<Tn.length;ye+=1){const ht=Tn[ye],at=ht[0],St=ht[1];if(at!=null&&St!=null&&(at!==xe||St!==xe)){const Ot=kt(at),En=Math.max(1,Math.round(kt(St+1)-Ot)),en=oe-A;e.fillRect(Ot,re+A+Math.round(en/3),En,Math.round(en/3))}}if(xe!=null){const ye=kt(xe),ht=2,at=oe-A;e.fillStyle=W,e.fillRect(ye,re+A,ht,at)}}}if(S){const ee=h-T-de,re=C;if(e.fillStyle=F,e.fillRect(ee,0,de-A,w),e.fillStyle=K?I:E,e.fillRect(ee+A,0,de-A,w),s?e.fillStyle=O:K?e.fillStyle=P:e.fillStyle=H,e.fillRect(ee+A,re,de-A,m),!se&&U&&j!=null&&W!=null){const{selectedRanges:we,cursorRow:xe}=t,{lastTop:Oe,rowCount:Jt}=o,Mt=ye=>ye<=Oe?ye/Oe*(w-m):w-m+(ye-Oe)/(Jt-Oe)*m;e.fillStyle=j;const Tn=[...we].filter(ye=>ye.startRow!=null&&ye.endRow!=null).map(ye=>[ye.startRow,ye.endRow]).sort(B.compareRanges),kt=B.mergeSortedRanges(Tn);for(let ye=0;ye<kt.length;ye+=1){const ht=kt[ye],at=ht[0],St=ht[1];if(at!=null&&St!=null&&(at!==xe||St!==xe)){const Ot=Mt(at),En=de-A,en=Math.max(1,Math.round(Mt(St+1)-Ot));e.fillRect(ee+A+Math.round(En/3),Ot,Math.round(En/3),en)}}if(xe!=null){const ye=Math.round(Mt(xe)),ht=de-A,at=2;e.fillStyle=W,e.fillRect(ee+A,ye,ht,at)}}}e.translate(-T,-y)}getTokenBoxesForVisibleCell(e,t,n){const{metrics:s,context:i,model:o,theme:a}=n;if(i==null||s==null)return De;const{modelRows:r,modelColumns:c}=s,h=_(r,t),u=_(c,e),m=o.textForCell(u,h),{width:p,x:g,y:C}=this.getTextRenderMetrics(n,e,t),{fontWidths:f}=s;i.save(),this.configureContext(i,n);const S=f?.get(i.font)??Pt.DEFAULT_FONT_WIDTH,v=o.truncationCharForCell(u,h),w=this.getCachedTruncatedString(i,m,p,S,v),{actualBoundingBoxAscent:T,actualBoundingBoxDescent:y}=i.measureText(w),E=T+y,I=o.tokensForCell(u,h,w.length);if(I.length===0)return i.restore(),De;const F=this.getCachedTokenBoxesForVisibleCell(w,I,a.font,"middle",E,i).map(N=>({x1:N.x1+g,y1:N.y1+(C-T),x2:N.x2+g,y2:N.y2+(C-T),token:N.token}));return i.restore(),F}getCachedTokenBoxesForVisibleCell=qn((e,t,n,s,i,o)=>{const r=i,c=[];let h=0,u=0;for(let m=0;m<t.length;m+=1){const p=t[m],{start:g,end:C}=p,f=C>e.length?e.substring(g):p.value;u+=o.measureText(e.substring(h,g)).width;const S=o.measureText(f).width,v=u,w=v+S,T={x1:v,y1:0,x2:w,y2:r,token:p};c.push(T),h=C,u+=S}return c},{max:1e4})}const kc=100;class $w extends dt{startPoint;hasExtendedFloating=!1;timer;lastTriggerTime;dragBounds;onDown(e,t,n){const{x:s,y:i,column:o,row:a}=e,{metrics:r}=t;if(!r)throw new Error("metrics not set");const{gridX:c,gridY:h,maxX:u,maxY:m}=r,p=s-c,g=i-h;if(p<0||g<0||o==null&&p>u||a==null&&g>m)return!1;const C=B.isModifierKeyDown(n),f=n.shiftKey;C||(f?t.trimSelectedRanges():t.clearSelectedRanges());const S=t.getTheme(),{autoSelectRow:v,autoSelectColumn:w}=S;return(o!==null||!w)&&(a!==null||!v)&&(t.focus(),t.moveCursorToPosition(o,a,f,!1,f&&C)),this.startPoint=e,this.hasExtendedFloating=!1,this.dragBounds=B.getScrollDragBounds(r,a,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:a,column:r}=e;const{metrics:c}=t;if(!c)throw new Error("metrics not set");const{left:h,lastLeft:u,top:m,lastTop:p,columnWidth:g,rowHeight:C}=c,f=B.getScrollDragBounds(c,n,s);let S=0,v=0;if(h<u&&(i<f.x1?S=i-f.x1:i>f.x2&&(S=i-f.x2)),m<p&&(o<f.y1?v=o-f.y1:o>f.y2&&(v=o-f.y2)),S!==0||v!==0)this.startTimer(t,e,S>0?Math.ceil(S/g):Math.floor(S/g),v>0?Math.ceil(v/C):Math.floor(v/C));else if(a!=null&&r!=null){const{floatingTopRowCount:w,floatingBottomRowCount:T,floatingLeftColumnCount:y,floatingRightColumnCount:E,columnCount:I,rowCount:F,bottom:N,right:H,topVisible:P,bottomVisible:O,leftVisible:k,rightVisible:L}=c;this.hasExtendedFloating||(n!==null&&n<w&&a>=w?(a=w,this.hasExtendedFloating=!0):n!==null&&n>=F-T&&a<F-T&&(a=F-T-1,this.hasExtendedFloating=!0),s!==null&&s<y&&r>=y?(r=y,this.hasExtendedFloating=!0):s!==null&&s>=I-E&&r<I-E&&(r=I-E-1,this.hasExtendedFloating=!0)),n!==null&&!B.isFloatingRow(n,c)&&B.isFloatingRow(a,c)&&(n>a&&a<m?a=P-1:n<a&&a>N&&(a=O+1)),s!==null&&!B.isFloatingColumn(s,c)&&B.isFloatingColumn(r,c)&&(s>r&&r<h?r=k-1:s<r&&r>H&&(r=L+1)),t.moveCursorToPosition(r,a,!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:a}=e;if(!a)throw new Error("metrics not set");const{selectionEndRow:r,selectionEndColumn:c}=e.state;if(r==null||c==null)throw new Error("selection not set");const{rowCount:h,columnCount:u}=a,m=n<0&&o!=null?o:0,p=n>0&&o!=null?o:u-1,g=s<0&&i!=null?i:0,C=s>0&&i!=null?i:h-1;e.moveCursorToPosition(Math.min(Math.max(m,c+n),p),Math.min(Math.max(g,r+s),C),!0),this.lastTriggerTime=Date.now()}startTimer(e,t,n,s){this.stopTimer();const i=this.lastTriggerTime!=null?kc-Math.min(kc,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 Oc=5,Ww=1e3/60,oa=10;function us(d,e,t,n){const{modelColumns:s,movedColumns:i,allColumnXs:o,columnCount:a,allColumnWidths:r,userColumnWidths:c,calculatedColumnWidths:h,floatingLeftWidth:u,maxX:m}=t;if(e==null||d==null||d>a||d<0)return null;const p=s.get(d)??B.getModelIndex(d,i),g=n.getColumnHeaderGroup(p,e),C=g!=null;let f,S,v;if(g!=null){const[w,T]=g.getVisibleRange(i);f=o.get(w)??u,S=(o.get(T)??m)+(r.get(T)??0),v=[w,T]}else{const w=o.get(d);if(w==null)return null;f=w,S=f+(r.get(d)??c.get(p)??h.get(p)??0),v=[d,d]}return{visibleIndex:d,modelIndex:p,left:f,right:S,width:S-f,isColumnGroup:C,range:v,depth:e}}class Gw extends dt{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:a,calculatedColumnWidths:r,movedColumns:c,allColumnWidths:h}=n;let u=s,m=o;if(t==="left")for(m-=oa;m<0;){u-=1;const C=B.getModelIndex(s-1,c),f=a.get(C)??r.get(C);f===void 0?m=0:m+=f,u<0&&(m=0,u=0)}else{m+=oa;let C=h.get(s);for(;C!==void 0&&m>C;){u+=1,m-=C;const f=B.getModelIndex(s+1,c);C=a.get(f)??r.get(f),u>i&&(m=0,u=i)}}const{mouseX:p,mouseY:g}=e.state;n==null||p==null||g==null||(this.moveDraggingColumn(p,e,t==="left"?-oa:oa),e.setState({left:u,leftOffset:m}),(t==="left"&&u===0&&o===0||t==="right"&&u===i)&&this.clearScrollInterval())},Ww))}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:a}=t;if(!a)throw new Error("Metrics not set");const r=us(i,o,a,n);if(i==null||r==null||o==null||o>0&&!r.isColumnGroup)return!1;const{rowHeaderWidth:c}=a;return this.initialGridPoint=e,this.draggingColumn=null,this.cursor=null,r.modelIndex!=null&&o!=null&&n.isColumnMovable(r.modelIndex,o)&&(this.draggingOffset=s-r.left-c,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:a}=t.props;let{draggingColumn:r}=this;const{metrics:c}=t;if(!c)throw new Error("Metrics not set");if(!r&&Math.abs(this.initialGridPoint.x-s)<Oc&&Math.abs(this.initialGridPoint.y-i)<Oc)return!1;if(r==null){const h=us(this.initialGridPoint.column,o,c,a);if(!h||o==null||!a.isColumnMovable(h.modelIndex)||o>0&&!h.isColumnGroup||h.range[0]==null)return!1;r={range:h.range,depth:o,left:h.left,width:h.width};const u=us(r.range[0],0,c,a),m=us(r.range[1],0,c,a);if(!u||!m)return!1;this.draggingColumn=r,t.setState({draggingColumn:r,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:a}=t;if(!a)throw new Error("Metrics not set");const{floatingLeftWidth:r,width:c,columnHeaderMaxDepth:h,allColumnXs:u}=a,m=n<0,p=us(this.draggingColumn.range[0],s,a,i);if(!p)return;const g=e-this.draggingOffset,C=g+p.width;this.draggingColumn={...this.draggingColumn,left:g},t.setState({draggingColumn:this.draggingColumn});const f=us(B.getColumnAtX(je(m?g:C,r,c),a,!0),s,a,i),S=i.getColumnHeaderParentGroup(p.modelIndex,p.depth);if(!f)return;if(S!==void 0){const I=S.getVisibleRange(o);if(f.visibleIndex<I[0]){const F=this.moveColumn(p,I[0],o);this.draggingOffset=e-(u.get(I[0])??0),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),t.setState({draggingColumn:this.draggingColumn,movedColumns:F});return}if(f.visibleIndex>I[1]){const F=this.moveColumn(p,I[1]-(p.range[1]-p.range[0]),o),{right:N=0}=us(I[1],0,a,i)??{};this.draggingOffset=e-(N-p.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),t.setState({draggingColumn:this.draggingColumn,movedColumns:F});return}}if(!i.isColumnMovable(f.modelIndex)){let I=f.visibleIndex;if(m)for(I+=1;I<p.visibleIndex&&!i.isColumnMovable(B.getModelIndex(I,o));)I+=1;else for(I-=1;I>p.visibleIndex&&!i.isColumnMovable(B.getModelIndex(I,o));)I-=1;if(I!==p.visibleIndex){m||(I-=p.range[1]-p.range[0]);const N=this.moveColumn(p,I,o);t.setState({movedColumns:N,draggingColumn:this.draggingColumn})}const F=us(I,0,a,i);m?this.draggingOffset=e-(F?.left??0):this.draggingOffset=e-((F?.right??0)-p.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},t.setState({draggingColumn:this.draggingColumn});return}if(g<=r?this.setScrollInterval(t,"left"):C>c?this.setScrollInterval(t,"right"):this.clearScrollInterval(),f.visibleIndex===p.visibleIndex||m&&p.visibleIndex<f.visibleIndex||!m&&p.visibleIndex>f.visibleIndex)return;const v=f.left+f.width*.5,w=i.getColumnHeaderParentGroup(p.modelIndex,p.depth);let T,y=(w?.depth??h)-1;for(;y>=0&&T===void 0;)T=i.getColumnHeaderGroup(f.modelIndex,y),y-=1;let E;m&&g<v&&(!T||f.visibleIndex===T.getVisibleRange(o)[0])&&(E=this.moveColumn(p,f.range[0],o)),!m&&C>v&&(!T||f.visibleIndex===T.getVisibleRange(o)[1])&&(E=this.moveColumn(p,f.range[1]-(p.range[1]-p.range[0]),o)),E&&(this.draggingColumn={...this.draggingColumn,left:g},t.setState({movedColumns:E,draggingColumn:this.draggingColumn}))}moveColumn(e,t,n){const s=e.isColumnGroup?B.moveRange(e.range,t,n):B.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}}class td extends dt{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),a=t-o;let r=s.allColumnWidths.get(o);if(r==null){const h=e.getMetricState();r=i.getVisibleColumnWidth(o,h)}const c=r*a;return{left:o,leftOffset:c}}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:a,y:r}=e,{barLeft:c,barWidth:h,height:u,hasHorizontalBar:m}=o;return m&&s>0&&r>=u-i&&r<u&&a>c&&a<c+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:a,barLeft:r,columnCount:c,scrollableContentWidth:h,scrollableViewportWidth:u}=n,m=s-r,p=je((m-(this.dragOffset??0))/(i-o),0,1);if(c===1)return{left:0,leftOffset:p*(h-u)};const g=p*a;return td.getLeftWithOffsetFromRawLeft(t,g)}onDown(e,t){const{metrics:n}=t;if(!n)throw new Error("metrics not set");const{x:s}=e,{handleWidth:i,barLeft:o,scrollX:a}=n;if(!this.isInScrollBar(e,t))return!1;const r=s-o;if(r>=a&&r<=a+i)this.dragOffset=r-a,t.setState({isDraggingHorizontalScrollBar:!0});else{this.dragOffset=0;const{left:c,leftOffset:h}=this.getLeftWithOffset(e,t);t.setViewState({left:c,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)}}class zw extends dt{cursor="move";draggingOffset;onDown(e,t){const{model:n}=t.props,{x:s,y:i,row:o}=e,{metrics:a}=t;if(!a)throw new Error("metrics not set");const{columnHeaderHeight:r,rowHeaderWidth:c,allRowYs:h}=a;if(s<=c&&o!==null&&n.isRowMovable(o)){const u=_(h,o);this.draggingOffset=i-u-r,t.setState({draggingRowOffset:this.draggingOffset})}return!1}onDrag(e,t){if(this.draggingOffset==null)return!1;const{model:n}=t.props;let{draggingRow:s}=t.state;const{mouseX:i,mouseY:o}=t.state;if(i==null||o==null)return!1;if(s==null){const{row:E}=t.getGridPointFromXY(i,o);if(E!=null&&!n.isRowMovable(E)||(s=E,t.setState({draggingRow:s,isDragging:!0}),s==null))return!1}const{metrics:a}=t;if(!a)throw new Error("metrics not set");const{top:r,lastTop:c,bottom:h,bottomVisible:u,rowCount:m,columnHeaderHeight:p,allRowHeights:g,allRowYs:C,height:f}=a;let S=p;if(r<s){const E=s-1;S=_(C,E)+_(g,E)*.5+p}let v=f;if(s<h){const E=s+1;v=_(C,E)+_(g,E)*.5+p}let{movedRows:w}=t.state;o<S&&s>0&&n.isRowMovable(s-1)?(w=B.moveItem(s,s-1,w),s-=1):v<o&&s<m-1&&n.isRowMovable(s+1)&&(w=B.moveItem(s,s+1,w),s+=1),t.setState({movedRows:w,draggingRow:s});const T=p+_(g,r)*.5,y=p+_(C,u)+_(g,u)*.5;return o<T&&r>0?t.setState({top:r-1}):o>y&&r<c&&t.setState({top:r+1}),!0}onUp(e,t){return this.draggingOffset!==void 0?(this.draggingOffset=void 0,t.setState({draggingRowOffset:null,draggingRow:null,isDragging:!1}),!0):!1}}class nd extends Yu{static getRowSeparator(e,t,n,s){if(!s.allowRowResize)return null;const{x:i,y:o}=e,a=B.getRowSeparatorIndex(i,o,t,s);return a!=null?{index:a,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=B.getHiddenRows;getNextShownItem=B.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=nd.getRowSeparator}class Bi extends dt{static isInTreeBox(e,t){const{column:n,row:s,x:i,y:o}=e,{metrics:a}=t;if(!a)throw new Error("metrics not set");const{gridX:r,gridY:c,firstColumn:h,allColumnXs:u,allColumnWidths:m,allRowHeights:p,allRowYs:g,visibleRowTreeBoxes:C}=a;if(n===h&&s!=null&&C.get(s)!=null&&i>r&&o>c){const f=_(u,n),S=_(m,n),v=_(g,s),w=_(p,s);if(i>=r+f&&i<=r+f+S&&o>=c+v&&o<=c+v+w)return!0}return!1}onDown(e,t){return Bi.isInTreeBox(e,t)}onClick(e,t,n){if(Bi.isInTreeBox(e,t)){const{row:s}=e;if(s!==null)return t.toggleRowExpanded(s,B.isModifierKeyDown(n)),!0}return!1}}class Kw extends dt{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:a}=e,{width:r,height:c,hasVerticalBar:h,hasHorizontalBar:u}=i;return s>0&&h&&u&&o>=r-s&&a>=c-s&&o<=r&&a<=c}onDown(e,t){return this.isInCorner(e,t)}onUp(e,t){return this.isInCorner(e,t)}onClick(e,t){return this.isInCorner(e,t)}}class sd extends dt{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),a=t-o;let r=s.allRowHeights.get(o);if(r==null){const h=e.getMetricState();r=i.getVisibleRowHeight(o,h)}const c=r*a;return{top:o,topOffset:c}}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:a,y:r}=e,{barTop:c,barHeight:h,width:u,hasVerticalBar:m}=o;return m&&s>0&&a>=u-i&&a<u&&r>c&&r<c+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:a,barTop:r,rowCount:c,scrollableContentHeight:h,scrollableViewportHeight:u}=n,m=s-r,p=je((m-(this.dragOffset??0))/(i-o),0,1);if(c===1)return{top:0,topOffset:p*(h-u)};const g=p*a;return sd.getTopWithOffsetFromRawTop(t,g)}onDown(e,t){const{metrics:n}=t;if(!n)throw new Error("metrics not set");const{y:s}=e,{handleHeight:i,barTop:o,scrollY:a}=n;if(!this.isInScrollBar(e,t))return!1;const r=s-o;if(r>=a&&r<=a+i)this.dragOffset=r-a,t.setState({isDraggingVerticalScrollBar:!0});else{this.dragOffset=0;const{top:c,topOffset:h}=this.getTopWithOffset(e,t);t.setViewState({top:c,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)}}class qw extends dt{onDoubleClick({column:e,row:t},n){const{model:s}=n.props;return Ze(s)&&e!=null&&t!=null&&s.isEditableRange(z.makeCell(e,t))?(n.startEditing(e,t),!0):!1}}class id extends dt{timeoutId;isHold=!1;isDown=!1;currentLinkBox;static HOLD_LENGTH=1e3;isHoveringLink(e,t){const{column:n,row:s,x:i,y:o}=e,{renderer:a,metrics:r}=t;if(n==null||s==null||r==null)return this.currentLinkBox=void 0,!1;if(this.currentLinkBox!=null){const{x1:u,y1:m,x2:p,y2:g}=this.currentLinkBox;if(i>=u&&i<=p&&o>=m&&o<=g)return!0}const c=t.updateRenderState(),h=a.getTokenBoxesForVisibleCell(n,s,c);for(let u=0;u<h.length;u+=1)if(_a(h[u].token)){const m=B.translateTokenBox(h[u],r),{x1:p,x2:g,y1:C,y2:f}=m;if(i>=p&&i<=g&&o>=C&&o<=f)return this.currentLinkBox=m,!0}return this.currentLinkBox=void 0,!1}setCursor(e,t){return this.isHoveringLink(e,t)?this.cursor="pointer":this.cursor=null,!1}onMove(e,t){return this.setCursor(e,t)}onDown(e,t,n){const s=this.isHoveringLink(e,t);return B.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:a}=t.props;t.clearSelectedRanges(),t.focus(),t.moveCursorToPosition(i,o),Ze(a)&&i!=null&&o!=null&&a.isEditableRange(z.makeCell(i,o))&&t.startEditing(i,o)},id.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)}}class li{order;constructor(e=5e3){this.order=e}onDown(e,t){return!1}}class Yw extends li{onDown(e,t){switch(e.key){case"a":if(B.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 B.isModifierKeyDown(e)?!1:this.handlePageUp(e,t);case"j":case"J":return B.isModifierKeyDown(e)?!1:this.handlePageDown(e,t);case"h":case"H":return B.isModifierKeyDown(e)?!1:(e.shiftKey||t.clearSelectedRanges(),t.moveCursorToPosition(0,t.state.cursorRow,e.shiftKey),!0);case"l":case"L":{if(B.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(B.isModifierKeyDown(e)?t.state.cursorColumn:0,B.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(B.isModifierKeyDown(e)?t.state.cursorColumn:s-1,B.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?z.SELECTION_DIRECTION.UP:z.SELECTION_DIRECTION.DOWN),!0;break;case"Tab":if(t.state.selectedRanges.length>0)return t.moveCursorInDirection(e.shiftKey?z.SELECTION_DIRECTION.LEFT:z.SELECTION_DIRECTION.RIGHT),!0;break}return!1}handleArrowMove(e,t,n,s){const i=n.shiftKey,o=B.isModifierKeyDown(n);i?s.trimSelectedRanges():s.clearSelectedRanges();const{cursorRow:a,cursorColumn:r,selectionEndColumn:c,selectionEndRow:h}=s.state,u=i?c:r,m=i?h:a;if(o){const{model:p}=s.props,{columnCount:g,rowCount:C}=p,f=o&&i;let S=null,v=null;e<0?(S=0,v=m):e>0?(S=g-1,v=m):t<0?(S=u,v=0):t>0&&(S=u,v=C-1),S!=null&&v!=null&&s.moveCursorToPosition(S,v,i,!0,f)}else{if(!s.metrics)throw new Error("grid.metrics are not set");const{theme:p}=s.props,{autoSelectRow:g=!1,autoSelectColumn:C=!1}=p;if(g&&e!==0){const{lastLeft:f}=s.metrics;let{left:S}=s.state;S=je(S+e,0,f),s.moveCursorToPosition(S,a,i,!1),s.setViewState({left:S})}else if(C&&t!==0){const{lastTop:f}=s.metrics;let{top:S}=s.state;S=je(S+t,0,f),s.moveCursorToPosition(S,r,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,a=s;if(o==null)return!1;const r=t.getMetricState(),{metricCalculator:c}=t,{bottomVisible:h,topVisible:u,hasHorizontalBar:m}=c.getMetrics(r);let p=o-(h-u);p-=m?0:1,p=Math.max(p,0);const g=Math.max(p-(o-u),0);return t.moveCursorToPosition(a,p,n,!1),t.setViewState({top:g}),!0}handlePageDown(e,t){const n=e.shiftKey;n?t.trimSelectedRanges():t.clearSelectedRanges();const{selectionEndRow:s,cursorColumn:i}=t.state,o=s,a=i;if(o===null)return!1;const r=t.getMetricState(),{metricCalculator:c}=t,{bottomVisible:h,topVisible:u,hasHorizontalBar:m,rowCount:p,lastTop:g}=c.getMetrics(r),C=p-1;let f=h-u+o;f+=m?0:1,f=Math.min(f,C);const S=Math.min(g,f-(o-u));return t.moveCursorToPosition(a,f,n,!1),t.setViewState({top:S}),!0}}class Xw extends li{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:a}=s;if(o!=null){const r=t.getModelRow(o);if((a===0||a==null)&&ze(i)&&i.isRowExpandable(r))return t.toggleRowExpanded(o),!0}}}return!1}}class Zw extends li{onDown(e,t){if(B.isModifierKeyDown(e))return!1;const{model:n}=t.props,{cursorColumn:s,cursorRow:i}=t.state;if(s==null||i==null||!Ze(n)||!n.isEditableRange(z.makeCell(s,i)))return!1;const o=s,a=i;return o==null||a==null?!1:e.key.length===1?(t.startEditing(o,a,!0,[1,1],e.key),!0):e.key==="F2"?(t.startEditing(o,a),!0):e.key==="Backspace"?(t.startEditing(o,a,!0,void 0,""),!0):e.key==="Delete"?(t.setValueForCell(o,a,""),!0):!1}}function Qw(d){const e=[],t=d.querySelectorAll("tr");for(let n=0;n<t.length;n+=1){const i=t[n].querySelectorAll("td"),o=[];for(let a=0;a<i.length;a+=1){const r=i[a];o.push(r.textContent?.trim()??"")}e.push(o)}return e}function Jw(d){const e=[];return d.forEach(t=>{const n=t.textContent??"";n.length>0&&e.push(n.split(/\t|\u00a0\u00a0 \u00a0/))}),e}function ev(d){const e=d.querySelector("table");if(e!=null)return Qw(e);const t=d.textContent?.trim()??"";if(t.length>0){const{childNodes:n}=d,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
|
+
`)}this.bufferedMessages=[],this.appendLogText(e)}queue(e){this.bufferedMessages.push(e),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,Et.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 l.jsxs("div",{className:"log-pane h-100 w-100",children:[l.jsxs("div",{className:"log-pane-menu",children:[l.jsx(V,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:Op,tooltip:"Clear log"}),l.jsx(V,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:ko,tooltip:"Log Settings",onClick:()=>{},children:l.jsx(Zn,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:e})})]}),l.jsx("div",{className:"log-pane-editor h-100 w-100",ref:s=>{this.editorContainer=s}})]})}}const mS=Et;class lt{static TYPE_GLOBAL="type-global";static TYPE_CONTEXT_PRESET="type-context-preset";static TYPE_CONTEXT_CUSTOM="type-context-custom";static isValid(e){return!0}static isSameFormat(e,t){throw new Error("isSameFormat not implemented")}static makeFormat(e,t,n){return{label:e,formatString:t,type:n}}format(e,t){return""}}class pS extends lt{format(e){switch(e){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}class gS extends lt{format(e){return String.fromCharCode(e)}}const fc=Z.module("DateTimeColumnFormatter");class _e extends lt{static isValid(e){try{return x.i18n.DateTimeFormat.format(e.formatString,new Date),!0}catch{return!1}}static makeFormat(e,t,n=lt.TYPE_CONTEXT_PRESET){return{label:e,formatString:t,type:n}}static isSameFormat(e,t){return e===t||e!==null&&t!==null&&e.type===t.type&&e.formatString===t.formatString}static DEFAULT_DATETIME_FORMAT_STRING="yyyy-MM-dd HH:mm:ss.SSS";static DEFAULT_TIME_ZONE_ID="America/New_York";static makeGlobalFormatStringMap(e,t){const n=t?"'T'":" ",s=e?" z":"";return new Map([["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${s}`]])}static getGlobalFormats(e,t){return[..._e.makeGlobalFormatStringMap(e,t).keys()]}static makeFormatStringMap(e,t){const n=t!==void 0&&t?"'T'":" ",s=e!==void 0&&e?" z":"";return new Map([["yyyy-MM-dd",`yyyy-MM-dd${s}`],["MM-dd-yyyy",`MM-dd-yyyy${s}`],["HH:mm:ss",`HH:mm:ss${s}`],["HH:mm:ss.SSS",`HH:mm:ss.SSS${s}`],["HH:mm:ss.SSSSSSSSS",`HH:mm:ss.SSSSSSSSS${s}`],["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${s}`]])}static getFormats(e,t){return[..._e.makeFormatStringMap(e,t).keys()]}dhTimeZone;defaultDateTimeFormatString;showTimeZone;showTSeparator;formatStringMap;constructor({timeZone:e="",showTimeZone:t=!0,showTSeparator:n=!1,defaultDateTimeFormatString:s=_e.DEFAULT_DATETIME_FORMAT_STRING}={}){super();const i=e||_e.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=x.i18n.TimeZone.getTimeZone(i)}catch{fc.error("Unsupported time zone id",i),this.dhTimeZone=x.i18n.TimeZone.getTimeZone(_e.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=s,this.showTimeZone=t,this.showTSeparator=n,this.formatStringMap=_e.makeFormatStringMap(t,n)}getEffectiveFormatString(e){return this.formatStringMap.get(e)??e}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultDateTimeFormatString,s=this.getEffectiveFormatString(n);try{return x.i18n.DateTimeFormat.format(s,e,this.dhTimeZone)}catch{fc.error("Invalid format arguments")}return""}}const fS=Z.module("DecimalColumnFormatter");class Re extends lt{static isValid(e){try{return x.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=lt.TYPE_CONTEXT_PRESET,s){return{label:e,type:n,formatString:t,multiplier:s}}static makePresetFormat(e,t="",n){return Re.makeFormat(e,t,lt.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return Re.makeFormat("Custom Format",e,lt.TYPE_CONTEXT_CUSTOM,t)}static DEFAULT_FORMAT_STRING="###,##0.0000";static FORMAT_PERCENT=Re.makePresetFormat("Percent","##0.00%");static FORMAT_BASIS_POINTS=Re.makePresetFormat("Basis Points","###,##0 bp",1e4);static FORMAT_MILLIONS=Re.makePresetFormat("Millions","###,##0.000 mm",1e-6);static FORMAT_SCIENTIFIC_NOTATION=Re.makePresetFormat("Scientific Notation","0.0000E0");static FORMAT_ROUND=Re.makePresetFormat("Round","###,##0");static FORMAT_ROUND_TWO_DECIMALS=Re.makePresetFormat("0.00","###,##0.00");static FORMAT_ROUND_FOUR_DECIMALS=Re.makePresetFormat("0.0000","###,##0.0000");static isSameFormat(e,t){return e===t||e!=null&&t!=null&&e.type===t.type&&e.formatString===t.formatString&&e.multiplier===t.multiplier}defaultFormatString;constructor({defaultFormatString:e=Re.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=e}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,s=t.multiplier!==void 0&&t.multiplier!==0?e*t.multiplier:e;try{return x.i18n.NumberFormat.format(n,s)}catch{fS.error("Invalid format arguments")}return""}}class CS extends lt{format(e){return`${e}`}}const SS=Z.module("IntegerColumnFormatter");class $e extends lt{static isValid(e){try{return x.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=lt.TYPE_CONTEXT_PRESET,s){return{label:e,type:n,formatString:t,multiplier:s}}static makePresetFormat(e,t="",n){return $e.makeFormat(e,t,lt.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return $e.makeFormat("Custom Format",e,lt.TYPE_CONTEXT_CUSTOM,t)}static isSameFormat(e,t){return e===t||e!=null&&t!=null&&e.type===t.type&&e.formatString===t.formatString&&e.multiplier===t.multiplier}static DEFAULT_FORMAT_STRING="###,##0";static FORMAT_MILLIONS=$e.makePresetFormat("Millions","###,##0.000 mm",1e-6);static FORMAT_SCIENTIFIC_NOTATION=$e.makePresetFormat("Scientific Notation","0.0000E0");defaultFormatString;constructor({defaultFormatString:e=$e.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=e}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,s=t.multiplier!==void 0&&t.multiplier!==0?e*t.multiplier:e;try{return x.i18n.NumberFormat.format(n,s)}catch{SS.error("Invalid format arguments")}return""}}class bS extends lt{format(e){return e}}class et{static FULL_DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";static months=["january","february","march","april","may","june","july","august","september","october","november","december"];static makeDateWrapper(e,t,n=0,s=1,i=0,o=0,a=0,r=0){if(!e)throw new Error("No timezone provided");const c=`${t}`.padStart(4,"0"),h=`${n+1}`.padStart(2,"0"),u=`${s}`.padStart(2,"0"),m=`${i}`.padStart(2,"0"),p=`${o}`.padStart(2,"0"),g=`${a}`.padStart(2,"0"),C=`${r}`.padStart(9,"0"),f=`${c}-${h}-${u} ${m}:${p}:${g}.${C}`;return x.i18n.DateTimeFormat.parse(et.FULL_DATE_FORMAT,f,x.i18n.TimeZone.getTimeZone(e))}static getNextNanos(e){const t=parseInt(e,10),n="0".repeat(9-e.length),s=`${t+1}${n}`;return parseInt(s,10)}static getNextDate(e,t,n){let{year:s,month:i,date:o,hours:a,minutes:r,seconds:c,nanos:h}=t;if(e.nanos!=null){if(e.nanos.length===9)return null;h=et.getNextNanos(e.nanos),h>999999999&&(c+=1,h=0)}else e.seconds!=null?c+=1:e.minutes!=null?r+=1:e.hours!=null?a+=1:e.date!=null?o+=1:e.month!=null?i+=1:s+=1;const u=new Date(s,i,o,a,r,c);return et.makeDateWrapper(n,u.getFullYear(),u.getMonth(),u.getDate(),u.getHours(),u.getMinutes(),u.getSeconds(),h)}static parseMonth(e){const t=parseInt(e,10);if(!Number.isNaN(t))return t>=1&&t<=12?t-1:NaN;const n=e.trim().toLowerCase();if(n.length>=3){for(let s=0;s<et.months.length;s+=1)if(et.months[s].startsWith(n))return s}return NaN}static parseDateValues(e,t,n,s,i,o,a){const r=parseInt(e,10),c=t!=null?this.parseMonth(t):0,h=n!=null?parseInt(n,10):1,u=s!=null?parseInt(s,10):0,m=i!=null?parseInt(i,10):0,p=o!=null?parseInt(o,10):0,g=a!=null?parseInt(a.padEnd(9,"0"),10):0;return Number.isNaN(r)||Number.isNaN(c)||Number.isNaN(h)||Number.isNaN(u)||Number.isNaN(m)||Number.isNaN(p)||Number.isNaN(g)?null:{year:r,month:c,date:h,hours:u,minutes:m,seconds:p,nanos:g}}static parseDateTimeString(e){const n=/\s*(\d{4})([-./]([\da-z]+))?([-./](\d{1,2}))?([tT\s](\d{2})([:](\d{2}))?([:](\d{2}))?([.](\d{1,9}))?)?(.*)/.exec(e);if(n==null)throw new Error(`Unexpected date string: ${e}`);const[,s,,i,,o,,a,,r,,c,,h,u]=n;if(u!=null&&u.length>0)throw new Error(`Unexpected characters after date string '${e}': ${u}`);return{year:s,month:i,date:o,hours:a,minutes:r,seconds:c,nanos:h}}static parseDateRange(e,t){const n=e.trim().toLowerCase();if(n.length===0)throw new Error("Cannot parse date range from empty string");if(n==="null")return[null,null];if(n==="today"){const r=new Date(Date.now()),c=et.makeDateWrapper(t,r.getFullYear(),r.getMonth(),r.getDate()),h=et.makeDateWrapper(t,r.getFullYear(),r.getMonth(),r.getDate()+1);return[c,h]}if(n==="yesterday"){const r=new Date(Date.now()),c=et.makeDateWrapper(t,r.getFullYear(),r.getMonth(),r.getDate()-1),h=et.makeDateWrapper(t,r.getFullYear(),r.getMonth(),r.getDate());return[c,h]}if(n==="now"){const r=new Date(Date.now());return[x.DateWrapper.ofJsDate(r),null]}const s=et.parseDateTimeString(n);if(s.year==null&&s.month==null&&s.date==null)throw new Error(`Unable to extract year, month, or day ${n}`);const i=et.parseDateValues(s.year,s.month,s.date,s.hours,s.minutes,s.seconds,s.nanos);if(i==null)throw new Error(`Unable to extract date values from ${s}`);const o=et.makeDateWrapper(t,i.year,i.month,i.date,i.hours,i.minutes,i.seconds,i.nanos),a=et.getNextDate(s,i,t);return[o,a]}static getJsDate(e){return typeof e=="number"?new Date(e):e.asDate()}}class Sn{static not="not";static and="and";static or="or"}function wS(d){if(!(d==="not"||d==="and"||d==="or"))throw new Error("operator is not a valid FilterOperatorValue")}class Y{static eq="eq";static eqIgnoreCase="eqIgnoreCase";static notEq="notEq";static notEqIgnoreCase="notEqIgnoreCase";static greaterThan="greaterThan";static greaterThanOrEqualTo="greaterThanOrEqualTo";static lessThan="lessThan";static lessThanOrEqualTo="lessThanOrEqualTo";static in="in";static inIgnoreCase="inIgnoreCase";static notIn="notIn";static notInIgnoreCase="notInIgnoreCase";static isTrue="isTrue";static isFalse="isFalse";static isNull="isNull";static invoke="invoke";static contains="contains";static notContains="notContains";static startsWith="startsWith";static endsWith="endsWith";static containsAny="containsAny"}function eu(d){switch(d){case Y.eq:return"is exactly";case Y.eqIgnoreCase:return"is exactly (ignore case)";case Y.notEq:return"is not exactly";case Y.notEqIgnoreCase:return"is not exactly (ignore case)";case Y.contains:return"contains";case Y.notContains:return"does not contain";case Y.startsWith:return"starts with";case Y.endsWith:return"ends with";default:throw new Error(`Unrecognized text filter type ${d}`)}}function tu(d){switch(d){case Y.eq:return"is equal to";case Y.notEq:return"is not equal to";case Y.greaterThan:return"greater than";case Y.greaterThanOrEqualTo:return"greater than or equal to";case Y.lessThan:return"less than";case Y.lessThanOrEqualTo:return"less than or equal to";default:throw new Error(`Unrecognized number filter type ${d}`)}}function nu(d){switch(d){case Y.eq:return"date is";case Y.notEq:return"date is not";case Y.notEqIgnoreCase:case Y.greaterThan:return"date is after";case Y.greaterThanOrEqualTo:return"date is after or equal";case Y.lessThan:return"date is before";case Y.lessThanOrEqualTo:return"date is before or equal";default:throw new Error(`Unrecognized date filter type ${d}`)}}function vS(d){switch(d){case Y.isTrue:return"Is True";case Y.isFalse:return"Is False";case Y.isNull:return"Is Null";default:throw new Error(`Unrecognized boolean filter type ${d}`)}}const Un=Z.module("TableUtils");class R{static dataType={BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"};static sortDirection={ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null};static REVERSE_TYPE=Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"});static NUMBER_REGEX=/^-?\d+(\.\d+)?$/;static getSortIndex(e,t){for(let n=0;n<e.length;n+=1)if(e[n].column?.name===t)return n;return null}static getSortForColumn(e,t){const n=R.getSortIndex(e,t);return n!=null?e[n]:null}static getFilterText(e){return e?e.toString():null}static getFilterTypes(e){return R.isBooleanType(e)?[Y.isTrue,Y.isFalse,Y.isNull]:R.isCharType(e)||R.isNumberType(e)||R.isDateType(e)?[Y.eq,Y.notEq,Y.greaterThan,Y.greaterThanOrEqualTo,Y.lessThan,Y.lessThanOrEqualTo]:R.isTextType(e)?[Y.eq,Y.eqIgnoreCase,Y.notEq,Y.notEqIgnoreCase,Y.contains,Y.notContains,Y.startsWith,Y.endsWith]:[]}static getNextSort(e,t,n){if(n<0||n>=e.length)return null;const s=R.getSortForColumn(t,e[n].name);return s===null?e[n].sort().asc():s.direction===R.sortDirection.ascending?s.desc():null}static makeColumnSort(e,t,n,s){if(t<0||t>=e.length||n===R.sortDirection.none)return null;let i=e[t].sort();switch(n){case R.sortDirection.ascending:i=i.asc();break;case R.sortDirection.descending:i=i.desc();break}return s&&(i=i.abs()),i}static toggleSortForColumn(e,t,n,s=!1){if(n<0||n>=t.length)return[];const i=R.getNextSort(t,e,n);return R.setSortForColumn(e,t[n].name,i,s)}static sortColumn(e,t,n,s,i,o){if(n<0||n>=t.length)return[];const a=R.makeColumnSort(t,n,s,i);return R.setSortForColumn(e,t[n].name,a,o)}static setSortForColumn(e,t,n,s=!1){const i=R.getSortIndex(e,t);let o=[];return s&&(o=o.concat(e.filter(({direction:a})=>a!==R.sortDirection.reverse)),i!==null&&o.splice(i,1)),n!==null&&o.push(n),o}static getNormalizedType(e){switch(e){case"boolean":case"java.lang.Boolean":case R.dataType.BOOLEAN:return R.dataType.BOOLEAN;case"char":case"java.lang.Character":case R.dataType.CHAR:return R.dataType.CHAR;case"java.lang.String":case R.dataType.STRING:return R.dataType.STRING;case"io.deephaven.db.tables.utils.DBDateTime":case"io.deephaven.time.DateTime":case"com.illumon.iris.db.tables.utils.DBDateTime":case"java.time.Instant":case"java.time.ZonedDateTime":case R.dataType.DATETIME:return R.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case R.dataType.DECIMAL:return R.dataType.DECIMAL;case"int":case"java.lang.Integer":case"long":case"java.lang.Long":case"short":case"java.lang.Short":case"byte":case"java.lang.Byte":case"java.math.BigInteger":case R.dataType.INT:return R.dataType.INT;default:return R.dataType.UNKNOWN}}static isLongType(e){switch(e){case"long":case"java.lang.Long":return!0;default:return!1}}static isDateType(e){switch(e){case"io.deephaven.db.tables.utils.DBDateTime":case"io.deephaven.time.DateTime":case"java.time.Instant":case"java.time.ZonedDateTime":case"com.illumon.iris.db.tables.utils.DBDateTime":return!0;default:return!1}}static isNumberType(e){return R.isIntegerType(e)||R.isDecimalType(e)}static isIntegerType(e){switch(e){case"int":case"java.lang.Integer":case"java.math.BigInteger":case"long":case"java.lang.Long":case"short":case"java.lang.Short":case"byte":case"java.lang.Byte":return!0;default:return!1}}static isDecimalType(e){switch(e){case"double":case"java.lang.Double":case"java.math.BigDecimal":case"float":case"java.lang.Float":return!0;default:return!1}}static isBigDecimalType(e){switch(e){case"java.math.BigDecimal":return!0;default:return!1}}static isBigIntegerType(e){switch(e){case"java.math.BigInteger":return!0;default:return!1}}static isBooleanType(e){switch(e){case"boolean":case"java.lang.Boolean":return!0;default:return!1}}static isCharType(e){switch(e){case"char":case"java.lang.Character":return!0;default:return!1}}static isStringType(e){switch(e){case"java.lang.String":return!0;default:return!1}}static isTextType(e){return this.isStringType(e)||this.isCharType(e)}static getBaseType(e){return e.split("[]")[0]}static isCompatibleType(e,t){return R.getNormalizedType(e)===R.getNormalizedType(t)}static makeQuickFilter(e,t,n){const s=t.split("||");let i=null;for(let o=0;o<s.length;o+=1){const r=s[o].split("&&");let c=null;for(let h=0;h<r.length;h+=1){const u=r[h].trim();if(u.length>0){const m=R.makeQuickFilterFromComponent(e,u,n);if(m)c?c=c.and(m):c=m;else throw new Error(`Unable to parse quick filter from text ${t}`)}}i&&c?i=i.or(c):i=c}return i}static makeQuickFilterFromComponent(e,t,n){const{type:s}=e;return R.isNumberType(s)?this.makeQuickNumberFilter(e,t):R.isBooleanType(s)?this.makeQuickBooleanFilter(e,t):n!=null&&R.isDateType(s)?this.makeQuickDateFilter(e,t,n):R.isCharType(s)?this.makeQuickCharFilter(e,t):this.makeQuickTextFilter(e,t)}static makeQuickNumberFilter(e,t){const n=e.filter();let s=null;const o=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i.exec(t);let a=null,r=null,c=null,h=null,u=null;if(o!==null&&o.length>3&&([,a,r,c,h,u]=o),u!=null&&u.trim().length>0)return null;if(a==null&&(a="="),h!=null){if(!(a==="="||a==="!"||a==="!="))return null;switch(h=h.trim().toLowerCase(),h){case"null":s=n.isNull();break;case"nan":s=x.FilterCondition.invoke("isNaN",n);break;case"infinity":case"inf":case"∞":r!=null?s=x.FilterCondition.invoke("isInf",n).and(n.lessThan(x.FilterValue.ofNumber(0))):s=x.FilterCondition.invoke("isInf",n).and(n.greaterThan(x.FilterValue.ofNumber(0)));break}return s!==null&&(a==="!"||a==="!=")&&(s=s.not()),s}if(c==null)return null;if(c=R.removeCommas(c),R.isLongType(e.type))try{c=x.FilterValue.ofNumber(x.LongWrapper.ofString(`${r!=null?"-":""}${c}`))}catch(m){return Un.warn("Unable to create long filter",m),null}else{if(c=parseFloat(c),c==null||Number.isNaN(c))return null;c=x.FilterValue.ofNumber(r!=null?0-c:c)}return s=e.filter(),R.makeRangeFilterWithOperation(s,a,c)}static makeQuickTextFilter(e,t){const n=`${t}`.trim(),i=/^(!~|!=|~|=|!)?(.*)/.exec(n);let o=null,a=null;if(i!==null&&i.length>2&&([,o,a]=i,a!=null&&(a=a.trim())),a==null||a.length===0)return null;o==null&&(o="=");const r=e.filter();if(a.toLowerCase()==="null")switch(o){case"=":return r.isNull();case"!=":case"!":return r.isNull().not();default:return null}let c=null,h=null;switch(a.startsWith("*")?(c="*",a=a.substring(1)):a.endsWith("*")&&!a.endsWith("\\*")&&(h="*",a=a.substring(0,a.length-1)),a=a.replace("\\",""),o){case"~":return r.isNull().not().and(r.invoke("matches",x.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E.*`)));case"!~":return r.isNull().or(r.invoke("matches",x.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E.*`)).not());case"!=":return c==="*"?r.isNull().or(r.invoke("matches",x.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E$`)).not()):h==="*"?r.isNull().or(r.invoke("matches",x.FilterValue.ofString(`(?s)(?i)^\\Q${a}\\E.*`)).not()):r.notEqIgnoreCase(x.FilterValue.ofString(a.toLowerCase()));case"=":return c==="*"?r.isNull().not().and(r.invoke("matches",x.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E$`))):h==="*"?r.isNull().not().and(r.invoke("matches",x.FilterValue.ofString(`(?s)(?i)^\\Q${a}\\E.*`))):r.eqIgnoreCase(x.FilterValue.ofString(a.toLowerCase()))}return null}static makeQuickBooleanFilter(e,t){const s=/^(!=|=|!)?(.*)/.exec(`${t}`.trim());if(s===null)return null;const[,i,o]=s,a=i==="!"||i==="!=",r=o.trim().toLowerCase();let c=e.filter();try{const h=R.makeBooleanValue(r);return h!=null&&h?c=c.isTrue():h===null?c=c.isNull():c=c.isFalse(),a?c.not():c}catch{return null}}static makeQuickDateFilter(e,t,n){const s=t.trim(),o=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/.exec(s);if(o==null||o.length<=2)throw new Error(`Unable to parse date filter: ${t}`);let a=null,r=null;[,a,r]=o;let c=Y.eq;switch(a){case"<":c=Y.lessThan;break;case"<=":case"=<":c=Y.lessThanOrEqualTo;break;case">":c=Y.greaterThan;break;case">=":case"=>":c=Y.greaterThanOrEqualTo;break;case"!=":case"!":c=Y.notEq;break;case"=":case"==":default:c=Y.eq;break}return R.makeQuickDateFilterWithOperation(e,r,c,n)}static makeQuickDateFilterWithOperation(e,t,n,s){const[i,o]=et.parseDateRange(t,s),a=i!=null?x.FilterValue.ofNumber(i):null,r=o!=null?x.FilterValue.ofNumber(o):null,c=e.filter();if(a==null)return n===Y.notEq?c.isNull().not():c.isNull();switch(n){case Y.eq:{if(r!=null){const h=c.greaterThanOrEqualTo(a),u=c.lessThan(r);return h.and(u)}return c.eq(a)}case Y.lessThan:return c.lessThan(a);case Y.lessThanOrEqualTo:return r!=null?c.lessThan(r):c.lessThanOrEqualTo(a);case Y.greaterThan:return r!=null?c.greaterThanOrEqualTo(r):c.greaterThan(a);case Y.greaterThanOrEqualTo:return c.greaterThanOrEqualTo(a);case Y.notEq:{if(r!=null){const h=c.lessThan(a),u=c.greaterThanOrEqualTo(r);return h.or(u)}return c.notEq(a)}default:throw new Error(`Invalid operator: ${n}`)}}static quoteValue(e){return e.length>=2&&(e.charAt(0)==='"'&&e.charAt(e.length-1)==='"'||e.charAt(0)==="'"&&e.charAt(e.length-1)==="'")?e:`"${e}"`}static isRangeOperation(e){switch(e){case"<":case"<=":case"=<":case">":case">=":case"=>":return!0;default:return!1}}static makeQuickCharFilter(e,t){const n=`${t}`.trim(),i=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/.exec(n);let o=null,a=null,r=null;if(i!==null&&i.length>3&&([,o,a,r]=i),r!=null&&r.trim().length>0||a==null||a.length===0)return null;o==null&&(o="=");const c=e.filter();if(a.toLowerCase()==="null")switch(o){case"=":return c.isNull();case"!=":case"!":return c.isNull().not();default:return null}const h=x.FilterValue.ofString(R.isRangeOperation(o)?R.quoteValue(a):a);return R.makeRangeFilterWithOperation(c,o,h)}static makeRangeFilterWithOperation(e,t,n){switch(t){case"=":return e.eq(n);case"<":return e.lessThan(n);case"<=":case"=<":return e.lessThanOrEqualTo(n);case">":return e.greaterThan(n);case">=":case"=>":return e.greaterThanOrEqualTo(n);case"!=":case"!":return e.notEq(n);default:return null}}static makeCancelableTablePromise(e){return ve.makeCancelable(e,t=>{t.close()})}static makeCancelableTableEventPromise(e,t,n=0,s=null){let i,o,a=!0;const r=new Promise((c,h)=>{o=setTimeout(()=>{i(),a=!1,h(new Ph(`Event "${t}" timed out.`))},n),i=e.addEventListener(t,u=>{if(s!=null&&!s(u)){Un.debug2("Event triggered, but matcher returned false.");return}Un.debug2("Event triggered, resolving."),i(),clearTimeout(o),a=!1,c(u)})});return r.cancel=()=>{if(a){Un.debug2("Pending promise cleanup."),i(),clearTimeout(o),a=!1;return}Un.debug2("Ignoring non-pending promise cancel.")},r}static makeAdvancedFilter(e,t,n){const{filterItems:s,filterOperators:i,invertSelection:o,selectedValues:a}=t;let r=null;for(let h=0;h<s.length;h+=1){const u=s[h],{selectedType:m,value:p}=u;if(m!=null&&m.length>0&&p!=null&&p.length>0)try{const g=R.makeAdvancedValueFilter(e,m,p,n);if(g!=null){if(h===0)r=g;else if(r!==null&&h-1<i.length){const C=i[h-1];if(C===Sn.and)r=r.and(g);else if(C===Sn.or)r=r.or(g);else{Un.error("Unexpected filter operator",C,g),r=null;break}}}else Un.debug2("Empty filter ignored for",m,p)}catch(g){Un.error("Unable to create filter",g),r=null;break}}const c=R.makeSelectValueFilter(e,a,o);return c!=null&&(r!=null?r=r.and(c):r=c),r}static removeCommas(e){return e.replace(/[\s|,]/g,"")}static makeFilterValue(e,t){const n=R.getBaseType(e);return R.isTextType(n)?x.FilterValue.ofString(t):R.isLongType(n)?x.FilterValue.ofNumber(x.LongWrapper.ofString(R.removeCommas(t))):x.FilterValue.ofNumber(R.removeCommas(t))}static makeFilterRawValue(e,t){return R.isTextType(e)?x.FilterValue.ofString(t):R.isBooleanType(e)?x.FilterValue.ofBoolean(t):x.FilterValue.ofNumber(t)}static makeValue(e,t,n){if(t==="null")return null;if(R.isTextType(e))return t;if(R.isLongType(e))return x.LongWrapper.ofString(R.removeCommas(t));if(R.isBooleanType(e))return R.makeBooleanValue(t,!0);if(R.isDateType(e)){const[s]=et.parseDateRange(t,n);return s}return R.isNumberType(e)?R.makeNumberValue(t):(Un.error("Unexpected column type",e),null)}static makeBooleanValue(e,t=!1){if(e===""&&t)return null;switch(e?.toLowerCase()){case"null":return null;case"0":case"f":case"fa":case"fal":case"fals":case"false":case"n":case"no":return!1;case"1":case"t":case"tr":case"tru":case"true":case"y":case"ye":case"yes":return!0;default:throw new Error(`Invalid boolean '${e}'`)}}static makeNumberValue(e){if(e==="null"||e==="")return null;const t=e.toLowerCase().trim();if(t==="∞"||t==="infinity"||t==="inf")return Number.POSITIVE_INFINITY;if(t==="-∞"||t==="-infinity"||t==="-inf")return Number.NEGATIVE_INFINITY;const n=R.removeCommas(t);if(R.NUMBER_REGEX.test(n))return parseFloat(n);throw new Error(`Invalid number '${e}'`)}static getFilterOperatorString(e){switch(e){case Y.eq:return"=";case Y.notEq:return"!=";case Y.greaterThan:return">";case Y.greaterThanOrEqualTo:return">=";case Y.lessThan:return"<";case Y.lessThanOrEqualTo:return"<=";case Y.contains:return"~";case Y.notContains:return"!~";default:throw new Error(`Unexpected filter type ${e}`)}}static makeAdvancedValueFilter(e,t,n,s){if(R.isDateType(e.type))return R.makeQuickDateFilterWithOperation(e,n,t,s);if(R.isNumberType(e.type)||R.isCharType(e.type))return R.makeQuickFilter(e,`${R.getFilterOperatorString(t)}${n}`);const i=R.makeFilterValue(e.type,n),o=e.filter();switch(t){case Y.eq:return o.eq(i);case Y.eqIgnoreCase:return o.eqIgnoreCase(i);case Y.notEq:return o.notEq(i);case Y.notEqIgnoreCase:return o.notEqIgnoreCase(i);case Y.greaterThan:return o.greaterThan(i);case Y.greaterThanOrEqualTo:return o.greaterThanOrEqualTo(i);case Y.lessThan:return o.lessThan(i);case Y.lessThanOrEqualTo:return o.lessThanOrEqualTo(i);case Y.isTrue:return o.isTrue();case Y.isFalse:return o.isFalse();case Y.isNull:return o.isNull();case Y.contains:return o.isNull().not().and(o.invoke("matches",x.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)));case Y.notContains:return o.isNull().or(o.invoke("matches",x.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)).not());case Y.startsWith:return o.isNull().not().and(o.invoke("matches",x.FilterValue.ofString(`(?s)(?i)^\\Q${n}\\E.*`)));case Y.endsWith:return o.isNull().not().and(o.invoke("matches",x.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E$`)));case Y.in:case Y.inIgnoreCase:case Y.notIn:case Y.notInIgnoreCase:case Y.invoke:default:throw new Error(`Unexpected filter operation: ${t}`)}}static makeSelectValueFilter(e,t,n){if(t.length===0){if(n)return null;let o=null;R.isTextType(e.type)?o=x.FilterValue.ofString("a"):R.isBooleanType(e.type)?o=x.FilterValue.ofBoolean(!0):R.isDateType(e.type)?o=x.FilterValue.ofNumber(x.DateWrapper.ofJsDate(new Date)):o=x.FilterValue.ofNumber(0);const a=e.filter().eq(o),r=e.filter().notEq(o);return a.and(r)}const s=[];let i=!1;for(let o=0;o<t.length;o+=1){const a=t[o];a==null?i=!0:R.isTextType(e.type)?s.push(x.FilterValue.ofString(typeof a=="number"?String.fromCharCode(a):a)):R.isBooleanType(e.type)?s.push(x.FilterValue.ofBoolean(Boolean(a))):s.push(x.FilterValue.ofNumber(a))}return i?s.length>0?n?e.filter().isNull().not().and(e.filter().notIn(s)):e.filter().isNull().or(e.filter().in(s)):n?e.filter().isNull().not():e.filter().isNull():n?e.filter().notIn(s):e.filter().in(s)}static isTreeTable(e){return e!=null&&e.expand!==void 0&&e.collapse!==void 0}static sortColumns(e,t=!0){return[...e].sort((n,s)=>{const i=n.name.toUpperCase(),o=s.name.toUpperCase();return Wt.sort(i,o,t)})}}class Zt{static makeColumnFormatMap(e){return e==null?new Map:e.reduce((t,n)=>{const s=R.getNormalizedType(n.columnType);return s===null||(t.has(s)||t.set(s,new Map),t.get(s)?.set(n.columnName,n.format)),t},new Map)}static makeColumnFormattingRule(e,t,n){return{columnType:e,columnName:t,format:n}}constructor(e=[],t,n,s,i=!1){this.defaultColumnFormatter=new CS,this.typeFormatterMap=new Map([[R.dataType.BOOLEAN,new pS],[R.dataType.CHAR,new gS],[R.dataType.DATETIME,new _e(t)],[R.dataType.DECIMAL,new Re(n)],[R.dataType.INT,new $e(s)],[R.dataType.STRING,new bS]]),this.columnFormatMap=Zt.makeColumnFormatMap(e),this.truncateNumbersWithPound=i}defaultColumnFormatter;typeFormatterMap;columnFormatMap;truncateNumbersWithPound;getColumnFormatMapForType(e,t=!1){const n=R.getNormalizedType(e);if(n!==null)return t&&!this.columnFormatMap.has(n)&&this.columnFormatMap.set(n,new Map),this.columnFormatMap.get(n)}getColumnFormat(e,t){return this.getColumnFormatMapForType(e)?.get(t)??null}getColumnTypeFormatter(e){const t=R.getNormalizedType(e);let n=this.defaultColumnFormatter;return t&&(n=this.typeFormatterMap.get(t)??n),n}getFormattedString(e,t,n="",s){if(e==null)return"";const i=this.getColumnTypeFormatter(t),o=s||this.getColumnFormat(t,n);return i.format(e,o??void 0)}get timeZone(){return this.typeFormatterMap.get(R.dataType.DATETIME)?.dhTimeZone?.id}}function TS(d){if(d&&d.formatter){const{formatter:e}=d;return e}}function ES(d){return{timeZone:d?.timeZone,defaultDateTimeFormatString:d?.defaultDateTimeFormat,showTimeZone:d?.showTimeZone,showTSeparator:d?.showTSeparator}}function yS(d,e,t){const n=d.getColumnFormat(t,e);return n!=null&&(n.type===lt.TYPE_CONTEXT_PRESET||n.type===lt.TYPE_CONTEXT_CUSTOM)}const Jn={getColumnFormats:TS,getDateTimeFormatterOptions:ES,isCustomColumnFormatDefined:yS};Ia.register([Ng,Mg,kg,Og,Ag,Lg]);const su=typeof kr=="function"?kr(Ia):kr.default(Ia);class Fn{static EVENT_UPDATED="ChartModel.EVENT_UPDATED";static EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";static EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";static EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";static EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";static EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";static EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";static EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";constructor(){this.listeners=[],this.isDownsamplingDisabled=!1}listeners;formatter;rect;isDownsamplingDisabled;title;getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(e){}close(){}setFormatter(e){this.formatter=e}setDownsamplingDisabled(e){this.isDownsamplingDisabled=e}setDimensions(e){this.rect=e}setTitle(e){this.title=e}subscribe(e){this.listeners.push(e)}unsubscribe(e){this.listeners=this.listeners.filter(t=>t!==e)}fireEvent(e){for(let t=0;t<this.listeners.length;t+=1)this.listeners[t](e)}fireUpdate(e){this.fireEvent(new CustomEvent(Fn.EVENT_UPDATED,{detail:e}))}fireDisconnect(){this.fireEvent(new CustomEvent(Fn.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(Fn.EVENT_RECONNECT))}fireDownsampleStart(e){this.fireEvent(new CustomEvent(Fn.EVENT_DOWNSAMPLESTARTED,{detail:e}))}fireDownsampleFinish(e){this.fireEvent(new CustomEvent(Fn.EVENT_DOWNSAMPLEFINISHED,{detail:e}))}fireDownsampleFail(e){this.fireEvent(new CustomEvent(Fn.EVENT_DOWNSAMPLEFAILED,{detail:e}))}fireDownsampleNeeded(e){this.fireEvent(new CustomEvent(Fn.EVENT_DOWNSAMPLENEEDED,{detail:e}))}fireLoadFinished(){this.fireEvent(new CustomEvent(Fn.EVENT_LOADFINISHED))}}const Wn=Fn,xS="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",RS="#403e41",IS="#5b5a5c",DS="#c0bfbf",FS="#4878ea",NS="rgba(91, 90, 92, 0.7)",bt={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:xS,gridcolor:RS,linecolor:IS,zerolinecolor:DS,activecolor:FS,rangebgcolor:NS,"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"},_t=Object.freeze({paper_bgcolor:bt["paper-bgcolor"],plot_bgcolor:bt["plot-bgcolor"],title_color:bt["title-color"],colorway:bt.colorway,gridcolor:bt.gridcolor,linecolor:bt.linecolor,zerolinecolor:bt.zerolinecolor,activecolor:bt.activecolor,rangebgcolor:bt.rangebgcolor,area_color:bt["area-color"],trend_color:bt["trend-color"],line_color:bt["line-color"],error_band_line_color:bt["error-band-line-color"],error_band_fill_color:bt["error-band-fill-color"],ohlc_increasing:bt["ohlc-increasing"],ohlc_decreasing:bt["ohlc-decreasing"]}),so=Z.module("ChartUtils"),ds=Object.freeze(x.calendar.DayOfWeek.values()),Cc="io.deephaven.time.DateTime",MS=36e5,kS=1e6;function OS(d){return d.asDate!==void 0}function AS(d){return d.asNumber!==void 0}function Sc(d){return d.dhTimeZone!==void 0}function LS(d){return d!=null&&d.range!=null&&(d.autorange===!1||d.autorange===void 0)}class ne{static DEFAULT_AXIS_SIZE=.15;static MIN_AXIS_SIZE=.025;static MAX_AXIS_SIZE=.2;static AXIS_SIZE_PX=75;static LEGEND_WIDTH_PX=50;static MAX_LEGEND_SIZE=.25;static ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});static DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";static DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});static DEFAULT_TITLE_PADDING=Object.freeze({t:8});static SUBTITLE_LINE_HEIGHT=25;static DEFAULT_MARKER_SIZE=6;static MODE_MARKERS="markers";static MODE_LINES="lines";static getPlotlyChartType(e,t){switch(e){case x.plot.SeriesPlotStyle.SCATTER:return t?"scatter":"scattergl";case x.plot.SeriesPlotStyle.LINE:return"scatter";case x.plot.SeriesPlotStyle.BAR:case x.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case x.plot.SeriesPlotStyle.PIE:return"pie";case x.plot.SeriesPlotStyle.TREEMAP:return"treemap";case x.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case x.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(e,t,n){const s=new Set;switch(e){case x.plot.SeriesPlotStyle.SCATTER:(t??!1)&&s.add(ne.MODE_LINES),(n??!0)&&s.add(ne.MODE_MARKERS);break;case x.plot.SeriesPlotStyle.LINE:(t??!0)&&s.add(ne.MODE_LINES),(n??!1)&&s.add(ne.MODE_MARKERS);break}return s.size>0?[...s].join("+"):void 0}static getPlotlyProperty(e,t){switch(e){case x.plot.SeriesPlotStyle.PIE:switch(t){case x.plot.SourceType.X:return"labels";case x.plot.SourceType.Y:return"values"}break;case x.plot.SeriesPlotStyle.OHLC:switch(t){case x.plot.SourceType.TIME:return"x"}break;case x.plot.SeriesPlotStyle.TREEMAP:switch(t){case x.plot.SourceType.X:return"ids";case x.plot.SourceType.Y:return"values";case x.plot.SourceType.LABEL:return"labels";case x.plot.SourceType.PARENT:return"parents";case x.plot.SourceType.COLOR:return"marker.colors"}break}switch(t){case x.plot.SourceType.X:return"x";case x.plot.SourceType.Y:return"y";case x.plot.SourceType.Z:return"z";case x.plot.SourceType.X_LOW:return"xLow";case x.plot.SourceType.X_HIGH:return"xHigh";case x.plot.SourceType.Y_LOW:return"yLow";case x.plot.SourceType.Y_HIGH:return"yHigh";case x.plot.SourceType.TIME:return"time";case x.plot.SourceType.OPEN:return"open";case x.plot.SourceType.HIGH:return"high";case x.plot.SourceType.LOW:return"low";case x.plot.SourceType.CLOSE:return"close";case x.plot.SourceType.SHAPE:return"shape";case x.plot.SourceType.SIZE:return"size";case x.plot.SourceType.LABEL:return"label";case x.plot.SourceType.COLOR:return"color";case x.plot.SourceType.PARENT:return"parent";case x.plot.SourceType.HOVER_TEXT:return"hovertext";case x.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${t}`)}}static getPlotlySeriesOrientation(e){const{sources:t}=e;return t.length===2&&t[0]?.axis?.type===x.plot.AxisType.Y?ne.ORIENTATION.HORIZONTAL:ne.ORIENTATION.VERTICAL}static getPlotlyErrorBars(e,t,n){const s=n.map((o,a)=>o-e[a]),i=t.map((o,a)=>e[a]-o);return{type:"data",symmetric:!1,array:s,arrayminus:i}}static getPlotlyDateFormat(e,t,n){const s=n?.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let i;const o=e?.getColumnTypeFormatter(t);return o!=null&&Sc(o)&&o.dhTimeZone!=null&&o.showTimeZone&&(i=x.i18n.DateTimeFormat.format(" z",new Date,o.dhTimeZone)),{tickformat:s,ticksuffix:i,automargin:!0}}static convertNumberPrefix(e){return e.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(e,t,n){if(!n)return null;const i=n.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);M(i);const[,o,a,r,,c,h,u,m,p]=i,g=r.replace(",","").length,f=a.indexOf(",")>=0||r.indexOf(",")>=0?",":"",S=u!=null&&u!==""?"e":"f",v=m!==""?m:S,w=c.length+h.length,y=`0${g}${f}.${w}${v}`,E=ne.convertNumberPrefix(o),I=ne.convertNumberPrefix(p);return{tickformat:y,tickprefix:E,ticksuffix:I,automargin:!0}}static getPlotlyAxisFormat(e,t=null){const{axis:n,columnType:s}=e,{formatPattern:i}=n;let o=null;return R.isDateType(s)?(o=ne.getPlotlyDateFormat(t,s,i),o=ne.addTickSpacing(o,n,!0)):R.isNumberType(s)&&(o=ne.getPlotlyNumberFormat(t,s,i),o=ne.addTickSpacing(o,n,!1)),n.formatType===x.plot.AxisFormatType.CATEGORY&&(o?o.type="category":o={type:"category",tickformat:void 0,ticksuffix:void 0}),o}static addTickSpacing(e,t,n){const{gapBetweenMajorTicks:s}=t;if(s>0){const i=e||{};let o=s;return n&&(o=s/kS),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=ne.ORIENTATION.VERTICAL){return{type:e,mode:t,name:n,orientation:i,showlegend:s??void 0}}static makeSeriesDataFromSeries(e,t,n,s=null,i=_t){const{name:o,isLinesVisible:a,isShapesVisible:r,plotStyle:c,lineColor:h,shapeColor:u,sources:m,shape:p,shapeSize:g}=e,C=m.some(T=>T.axis?.businessCalendar),f=ne.getChartType(c,C),S=ne.getPlotlyChartMode(c,a??void 0,r??void 0),v=ne.getPlotlySeriesOrientation(e),w=ne.makeSeriesData(f,S,o,s,v);return ne.addSourcesToSeriesData(w,c,m,t),ne.addStylingToSeriesData(w,c,i,h,u,p,g,n),w}static addSourcesToSeriesData(e,t,n,s){const i=e;for(let o=0;o<n.length;o+=1){const a=n[o],{axis:r,type:c}=a,h=ne.getPlotlyProperty(t,c);bh(i,h,[]);const u=r!=null?ne.getAxisPropertyName(r.type):null;if(u!=null){const m=s.get(r.type);if(m){const p=m.indexOf(r),g=p>0?`${p+1}`:"";i[`${u}axis`]=`${u}${g}`}}}}static addStylingToSeriesData(e,t,n=_t,s=null,i=null,o=null,a=null,r=null){const c=e;if(c.marker={line:{}},c.line={width:1},t===x.plot.SeriesPlotStyle.AREA?c.fill="tozeroy":t===x.plot.SeriesPlotStyle.STACKED_AREA?c.stackgroup="stack":t===x.plot.SeriesPlotStyle.STEP?c.line.shape="hv":t===x.plot.SeriesPlotStyle.HISTOGRAM?(c.width=[],c.marker.line!==void 0&&Object.assign(c.marker.line,{color:n.paper_bgcolor,width:1})):t===x.plot.SeriesPlotStyle.OHLC?(c.increasing={line:{color:n.ohlc_increasing}},c.decreasing={line:{color:n.ohlc_decreasing}}):t===x.plot.SeriesPlotStyle.PIE?(c.textinfo="label+percent",c.outsidetextfont={color:n.title_color}):t===x.plot.SeriesPlotStyle.TREEMAP&&(c.hoverinfo="text",c.textinfo="label+text",c.tiling={packing:"squarify",pad:0},c.textposition="middle center",c.outsidetextfont={color:n.title_color}),s!=null&&(t===x.plot.SeriesPlotStyle.BAR?c.marker.color=s:c.line.color=s),i!=null&&(c.marker.color=i),o!=null&&o.length>0)try{c.marker.symbol=ne.getMarkerSymbol(o)}catch(h){so.warn("Unable to handle shape",o,":",h)}a!=null&&(c.marker.size=a*ne.DEFAULT_MARKER_SIZE),r!=null&&t!==x.plot.SeriesPlotStyle.PIE&&(c.visible=r)}static getMarkerSymbol(e){switch(e){case"SQUARE":return"square";case"CIRCLE":return"circle";case"DIAMOND":return"diamond";case"UP_TRIANGLE":return"triangle-up";case"DOWN_TRIANGLE":return"triangle-down";case"RIGHT_TRIANGLE":return"triangle-right";case"LEFT_TRIANGLE":return"triangle-left";case"ELLIPSE":case"HORIZONTAL_RECTANGLE":case"VERTICAL_RECTANGLE":default:throw new Error(`Unrecognized shape ${e}`)}}static getAxisFormats(e,t){const n=new Map,s={tickformat:null,ticksuffix:null},i=ne.getAllAxes(e),o=ne.groupArray(i,"type"),{charts:a}=e;for(let r=0;r<a.length;r+=1){const c=a[r];for(let h=0;h<c.series.length;h+=1){const u=c.series[h],{sources:m}=u,p=m.filter(g=>g.axis);for(let g=0;g<p.length;g+=1){const C=p[g],{axis:f}=C,{type:S}=f,v=o.get(S);M(v);const w=v.indexOf(f),T=ne.getAxisPropertyName(S);if(T!=null){const y=ne.getAxisLayoutProperty(T,w);if(n.has(y))so.debug(`${y} already added.`);else{so.debug(`Adding ${y} to axisFormats.`);const E=ne.getPlotlyAxisFormat(C,t);if(E===null)n.set(y,s);else{n.set(y,E);const{businessCalendar:I}=f;if(I!=null){const F=[],{businessPeriods:N,businessDays:H,holidays:P,timeZone:O}=I,k=t?.getColumnTypeFormatter(Cc);let L;Sc(k)&&(L=k.dhTimeZone);const A=L?(O.standardOffset-L.standardOffset)/60:0;P.length>0&&F.push(...ne.createRangeBreakValuesFromHolidays(P,O,L)),N.forEach(U=>F.push({pattern:"hour",bounds:[ne.periodToDecimal(U.close)+A,ne.periodToDecimal(U.open)+A]})),H.length<ds.length&&ne.createBoundsFromDays(H).forEach(U=>F.push({pattern:"day of week",bounds:U})),E.rangebreaks=F}if(n.size===c.axes.length)return n}}}}}}return n}static getChartType(e,t){switch(e){case x.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return ne.getPlotlyChartType(e,t)}}static getAxisPropertyName(e){switch(e){case x.plot.AxisType.X:return"x";case x.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(e){switch(e){case x.plot.AxisPosition.BOTTOM:return"bottom";case x.plot.AxisPosition.TOP:return"top";case x.plot.AxisPosition.LEFT:return"left";case x.plot.AxisPosition.RIGHT:return"right";default:return}}static getAllAxes(e){return e.charts.reduce((t,n)=>[...t,...n.axes],[])}static getChartForSeries(e,t){const{charts:n}=e;for(let s=0;s<n.length;s+=1){const i=n[s];for(let o=0;o<i.series.length;o+=1)if(t===i.series[o])return i}return null}static getLayoutRanges(e){const t={},n=Object.keys(e).filter(s=>s.indexOf("axis")>=0);for(let s=0;s<n.length;s+=1){const i=n[s],o=e[i];LS(o)&&(t[i]=[...o.range])}return t}static updateFigureAxes(e,t,n,s=0,i=0,o=_t){const a=e,r=ne.getAllAxes(t);for(let c=0;c<t.charts.length;c+=1){const h=t.charts[c],u=n?.(h),m=ne.getChartBounds(t,h,s,i);ne.updateLayoutAxes(a,h.axes,r,s,i,m,u,o)}ne.removeStaleAxes(a,r)}static getChartBounds(e,t,n,s){const{cols:i,rows:o}=e,{column:a,colspan:r,row:c,rowspan:h}=t,u=a+r,m=c+h,p=1/i,g=1/o,C=ne.AXIS_SIZE_PX/n,f=ne.AXIS_SIZE_PX/s,S={bottom:(o-m)*g+(m<o?f/2:0),top:(o-c)*g-(c>0?f/2:0),left:a*p+(a>0?C/2:0),right:u*p-(u<i?C/2:0)};return(ne.groupArray(t.axes,"position").get(x.plot.AxisPosition.RIGHT)??[]).length>0&&(n>0?S.right-=(S.right-S.left)*Math.max(0,Math.min(ne.LEGEND_WIDTH_PX/n,ne.MAX_LEGEND_SIZE)):S.right-=(S.right-S.left)*ne.DEFAULT_AXIS_SIZE),S}static updateLayoutAxes(e,t,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},a,r=_t){const c=s>0?Math.max(ne.MIN_AXIS_SIZE,Math.min(ne.AXIS_SIZE_PX/i,ne.MAX_AXIS_SIZE)):ne.DEFAULT_AXIS_SIZE,h=i>0?Math.max(ne.MIN_AXIS_SIZE,Math.min(ne.AXIS_SIZE_PX/s,ne.MAX_AXIS_SIZE)):ne.DEFAULT_AXIS_SIZE,u=e,m=ne.groupArray(t,"position"),p=ne.groupArray(t,"type"),g=[...p.keys()],C=ne.groupArray(n,"type");for(let f=0;f<g.length;f+=1){const S=g[f],v=ne.getAxisPropertyName(S);if(v!=null){const w=p.get(S),T=C.get(S),E=S===x.plot.AxisType.Y?i:s;M(w),M(T);for(let I=0;I<w.length;I+=1){const F=w[I],N=T.indexOf(F),H=ne.getAxisLayoutProperty(v,N);u[H]==null&&(u[H]=ne.makeLayoutAxis(S,r));const P=u[H];if(P!=null){ne.updateLayoutAxis(P,F,I,m,c,h,o);const{range:O,autorange:k}=P;if(a!=null&&O!==void 0&&(k===void 0||k===!1)){const L=a(F),[A,U]=L(O);so.debug("Setting downsample range",E,A,U),F.range(E,A,U)}else F.range(E)}}}}}static removeStaleAxes(e,t){const n=e,s=ne.groupArray(t,"type"),i=[...s.keys()];for(let o=0;o<i.length;o+=1){const a=i[o],r=s.get(a);M(r);let c=r.length;const h=ne.getAxisPropertyName(a);if(h!=null){let u=ne.getAxisLayoutProperty(h,c);for(;n[u]!=null;)delete n[u],c+=1,u=ne.getAxisLayoutProperty(h,c)}}}static getAxisLayoutProperty(e,t){const n=t>0?`${t+1}`:"";return`${e??""}axis${n}`}static updateLayoutAxis(e,t,n,s,i,o,a){const c=t.type===x.plot.AxisType.Y?o:i,h=e,u=t.label??"";if(h.title!==void 0&&typeof h.title!="string"?h.title.text=u:h.title={text:u},t.log&&(h.type="log"),h.side=ne.getAxisSide(t.position),n>0){h.overlaying=ne.getAxisPropertyName(t.type)??void 0;const m=s.get(t.position)??[],p=m.indexOf(t);p>0&&(h.anchor="free",t.position===x.plot.AxisPosition.RIGHT?h.position=a.right+(p-m.length+1)*c:t.position===x.plot.AxisPosition.TOP?h.position=a.top+(p-m.length+1)*c:t.position===x.plot.AxisPosition.BOTTOM?h.position=a.bottom+(m.length-p+1)*c:t.position===x.plot.AxisPosition.LEFT&&(h.position=a.left+(m.length-p+1)*c))}else if(t.type===x.plot.AxisType.X){const m=s.get(x.plot.AxisPosition.LEFT)||[],p=s.get(x.plot.AxisPosition.RIGHT)||[],g=Math.max(a.left,a.left+(m.length-1)*o),C=Math.min(a.right-(p.length-1)*o,a.right);h.domain=[g,C]}else if(t.type===x.plot.AxisType.Y){const m=s.get(x.plot.AxisPosition.BOTTOM)||[],p=s.get(x.plot.AxisPosition.TOP)||[],g=Math.max(a.bottom,a.bottom+(m.length-1)*i),C=Math.min(a.top-(p.length-1)*i,a.top);h.domain=[g,C]}}static periodToDecimal(e){const t=e.split(":");return Number(t[0])+Number(t[1])/60}static createBoundsFromDays(e){const t=e.map(o=>ds.indexOf(o)),n=ds.filter(o=>!e.includes(o)).map(o=>ds.indexOf(o)),s=new Set;n.forEach(o=>{for(let a=o+1;a<o+ds.length;a+=1){const r=a%ds.length;if(t.includes(r)){s.add(r);break}}});const i=[];return s.forEach(o=>{for(let a=o-1;a>o-ds.length;a-=1){const r=a<0?a+ds.length:a;if(t.includes(r)){const c=(r+1)%7;i.push([c,o]);break}}}),i}static createRangeBreakValuesFromHolidays(e,t,n){const s=[],i=[];return e.forEach(o=>{o.businessPeriods.length>0?i.push(...ne.createPartialHoliday(o,t,n)):s.push(ne.createFullHoliday(o,t,n))}),[{values:s},...i]}static createFullHoliday(e,t,n){return ne.adjustDateForTimeZone(`${e.date.toString()} 00:00:00.000000`,t,n)}static createPartialHoliday(e,t,n){const s=e.date.toString(),i=["00:00"];e.businessPeriods.forEach(a=>{i.push(a.open),i.push(a.close)}),i.push("24:00");const o=[];for(let a=0;a<i.length;a+=2){const r=i[a],c=i[a+1];if(r!==c){const h=[ne.adjustDateForTimeZone(`${s} ${r}:00.000000`,t,n)],u=MS*(ne.periodToDecimal(c)-ne.periodToDecimal(r));o.push({values:h,dvalue:u})}}return o}static adjustDateForTimeZone(e,t,n){return n&&n.standardOffset!==t.standardOffset?ne.unwrapValue(ne.wrapValue(e,Cc,t),n):e}static groupArray(e,t){return e.reduce((n,s)=>{const i=s[t],o=n.get(i)??[];return o.push(s),n.set(i,o),n},new Map)}static unwrapValue(e,t){if(e!=null){if(OS(e))return x.i18n.DateTimeFormat.format(ne.DATE_FORMAT,e,t);if(AS(e))return e.asNumber()}return e}static wrapValue(e,t,n=null){if(R.isDateType(t)&&typeof e=="string"){const s=e,i=ne.DATE_FORMAT.substr(0,e.length),o=x.i18n.DateTimeFormat.parse(i,s);if(!n)return o;const a=`${i} Z`,r=x.i18n.DateTimeFormat.format("Z",o,n),c=x.i18n.DateTimeFormat.parse(a,`${s} ${r}`),h=x.i18n.DateTimeFormat.format("Z",c,n);return x.i18n.DateTimeFormat.parse(a,`${s} ${h}`)}return e}static makeLayoutAxis(e,t=_t){const n={automargin:!0,gridcolor:t.gridcolor,linecolor:t.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:t.paper_bgcolor,tickfont:{color:t.zerolinecolor},title:{font:{color:t.title_color}}};return e===x.plot.AxisType.X?Object.assign(n,{showgrid:!0}):e===x.plot.AxisType.Y&&Object.assign(n,{zerolinecolor:t.zerolinecolor,zerolinewidth:2}),n}static getColorwayFromTheme(e=_t){let t=[];return e.colorway&&(Array.isArray(e.colorway)?t=e.colorway:typeof e.colorway=="string"?t=e.colorway.split(" "):so.warn(`Unable to handle colorway property: ${e.colorway}`)),t}static makeDefaultLayout(e=_t){const t={...e,autosize:!0,colorway:ne.getColorwayFromTheme(e),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:e.title_color},yanchor:"top",pad:{...ne.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:e.title_color}},margin:{...ne.DEFAULT_MARGIN},xaxis:ne.makeLayoutAxis(x.plot.AxisType.X,e),yaxis:ne.makeLayoutAxis(x.plot.AxisType.Y,e)};return t.datarevision=0,t}static hydrateSettings(e){return{...e,type:e.type!=null?x.plot.SeriesPlotStyle[e.type]:void 0}}static titleFromSettings(e){const{series:t,xAxis:n,title:s=`${(t??[]).join(", ")} by ${n}`}=e;return s}static makeFigureSettings(e,t){const{series:n,xAxis:s,type:i}=e,o=ne.titleFromSettings(e),a={formatType:`${x.plot.AxisFormatType.NUMBER}`,type:`${x.plot.AxisType.X}`,position:`${x.plot.AxisPosition.BOTTOM}`},r={formatType:`${x.plot.AxisFormatType.NUMBER}`,type:`${x.plot.AxisType.Y}`,position:`${x.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${x.plot.ChartType.XY}`,axes:[a,r],series:(n??[]).map(c=>({plotStyle:`${i}`,name:c,dataSources:[{type:`${x.plot.SourceType.X}`,columnName:s??"",axis:a,table:t},{type:`${x.plot.SourceType.Y}`,columnName:c,axis:r,table:t}]}))}],title:o}}}const Je=ne;const cs=Z.module("Chart");class yi extends b.Component{static defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:et.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};static convertIcon(e){const[t,,,,n]=e.icon,s=`${n}`;return{width:t,path:s,ascent:t,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(e,t){return e?"Downsampling in progress...":t?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(e,t){return e?"animation-spin":t?void 0:"fill-active"}constructor(e){super(e),this.handleAfterPlot=this.handleAfterPlot.bind(this),this.handleDownsampleClick=this.handleDownsampleClick.bind(this),this.handleModelEvent=this.handleModelEvent.bind(this),this.handlePlotUpdate=this.handlePlotUpdate.bind(this),this.handleRelayout=this.handleRelayout.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.plot=X.createRef(),this.plotWrapper=X.createRef(),this.columnFormats=[],this.dateTimeFormatterOptions={},this.decimalFormatOptions={},this.integerFormatOptions={},this.isSubscribed=!1,this.isLoadedFired=!1,this.currentSeries=0,this.state={data:null,downsamplingError:null,isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,layout:{datarevision:0},revision:0}}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:e}=this.props;e&&this.subscribe()}componentDidUpdate(e){const{isActive:t,settings:n}=this.props;this.updateFormatterSettings(n),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}currentSeries;plot;plotWrapper;columnFormats;dateTimeFormatterOptions;decimalFormatOptions;integerFormatOptions;rect;ranges;isSubscribed;isLoadedFired;getCachedConfig=fe((e,t,n,s)=>{const i=[],o=Boolean(e);if(o&&i.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:yi.convertIcon(Nh),attr:"fill-warning"}),t||n||s||o){const a=yi.downsampleButtonTitle(n,s),r=yi.downsampleButtonAttr(n,s),c=n?Ap:Lp;i.push({name:a,icon:yi.convertIcon(c),click:this.handleDownsampleClick,attr:r})}return{displaylogo:!1,displayModeBar:n||o?!0:"hover",modeBarButtons:[i,["toImage"],["zoom2d","pan2d"],["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]]}});getPlotRect(){return this.plotWrapper.current?.getBoundingClientRect()??null}initData(){const{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:{...t,...e.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:e}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){cs.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(cs.debug2("Received data update",t,n),t){case Wn.EVENT_UPDATED:{this.currentSeries+=1,this.setState(i=>{const{layout:o,revision:a}=i;return typeof o.datarevision=="number"&&(o.datarevision+=1),{data:n,layout:o,revision:a+1}});const{onUpdate:s}=this.props;s({isLoading:!this.isLoadedFired});break}case Wn.EVENT_LOADFINISHED:{const{onUpdate:s}=this.props;this.isLoadedFired=!0,s({isLoading:!1});break}case Wn.EVENT_DISCONNECT:{const{onDisconnect:s}=this.props;s();break}case Wn.EVENT_RECONNECT:{const{onReconnect:s}=this.props;s();break}case Wn.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case Wn.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case Wn.EVENT_DOWNSAMPLENEEDED:case Wn.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:cs.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,n=Je.getLayoutRanges(t);!it(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(e){if(cs.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,n=[...e.hiddenlabels];t({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([e,t]){if(cs.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:a,visible:r})=>a!=null&&r==="legendonly"?[...o,a]:o,[]);s({hiddenSeries:i})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){cs.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=Jn.getColumnFormats(e),n=Jn.getDateTimeFormatterOptions(e),{decimalFormatOptions:s={},integerFormatOptions:i={}}=e;(!it(this.columnFormats,t)||!it(this.dateTimeFormatterOptions,n)||!it(this.decimalFormatOptions,s)||!it(this.integerFormatOptions,i))&&(this.columnFormats=Jn.getColumnFormats(e),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const e=new Zt(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:t}=this.props;t.setFormatter(e)}updateDimensions(){const e=this.getPlotRect();this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&Ia.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{cs.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:n,isDownsampleInProgress:s,isDownsamplingDisabled:i,layout:o,revision:a}=this.state,r=this.getCachedConfig(t,n,s,i),c=e!=null;return l.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:c&&l.jsx(su,{ref:this.plot,data:e,layout:o,revision:a,config:r,onAfterPlot:this.handleAfterPlot,onError:cs.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}}const PS=yi,Rt=Z.module("FigureChartModel");class Wl extends Wn{static ADD_SERIES_DEBOUNCE=50;constructor(e,t={},n=_t){super(),this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.figure=e,this.settings=t,this.theme=n,this.data=[];const s={data:{},layout:Je.makeDefaultLayout(n)};this.layout={grid:{rows:e.rows,columns:e.cols,pattern:"independent"},template:s},this.seriesDataMap=new Map,this.pendingSeries=[],this.oneClicks=[],this.filterColumnMap=new Map,this.lastFilter=new Map,this.isConnected=!0,this.seriesToProcess=new Set,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure()}figure;settings;theme;data;layout;seriesDataMap;pendingSeries;oneClicks;filterColumnMap;lastFilter;isConnected;seriesToProcess;close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=Je.getAllAxes(this.figure),n=[];for(let o=0;o<e.length;o+=1){const a=e[o];for(let r=0;r<a.series.length;r+=1){const c=a.series[r];n.push(c.name),this.addSeries(c,t,a.showLegend)}}const i=[...this.seriesDataMap.keys()].filter(o=>n.indexOf(o)<0);for(let o=0;o<i.length;o+=1){const a=i[o];this.seriesDataMap.delete(a)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,n){const s=Je.groupArray(t,"type"),i=Je.makeSeriesDataFromSeries(e,s,Je.getSeriesVisibility(e.name,this.settings),n,this.theme);if(this.seriesDataMap.set(e.name,i),this.data=[...this.seriesDataMap.values()],e.plotStyle===x.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===x.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=Je.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===x.plot.SeriesPlotStyle.PIE?n??void 0:!1,e.oneClick!=null){const{oneClick:o}=e,{columns:a}=o;for(let r=0;r<a.length;r+=1)this.filterColumnMap.set(a[r].name,a[r]);this.oneClicks.push(o)}this.updateLayoutFormats()}addPendingSeries=Ye(()=>{const e=Je.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=[]},Wl.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){Rt.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?x.plot.DownsampleOptions.DISABLE:x.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(x.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(x.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(x.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(x.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(x.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(x.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(x.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(x.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(x.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(x.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(x.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(x.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(x.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(x.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(x.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(x.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(x.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(x.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}getTimeZone=pe((e,t)=>{if(t!=null){const n=t.getColumnTypeFormatter(e);if(n!=null)return n.dhTimeZone}});getValueTranslator=pe((e,t)=>{const n=this.getTimeZone(e,t);return s=>Je.unwrapValue(s,n)});getValueParser=pe((e,t)=>{const n=this.getTimeZone(e,t);return s=>Je.wrapValue(s,e,n)});getRangeParser=pe((e,t)=>n=>{let[s,i]=n;const o=this.getValueParser(e,t);return s=o(s),i=o(i),[s,i]});getAxisRangeParser=pe((e,t)=>n=>{const s=Je.getSourceForAxis(e,n);return s?this.getRangeParser(s.columnType,t):i=>i});handleDownsampleStart(e){Rt.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){Rt.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){Rt.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){Rt.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:n}=t;Rt.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];Rt.debug2("handleFigureUpdated updating series",o.name);const{sources:a}=o;for(let r=0;r<a.length;r+=1){const c=a[r],{columnType:h,type:u}=c,m=this.getValueTranslator(h,this.formatter),p=t.getArray(o,u,m);this.setDataArrayForSeries(o,u,p)}this.seriesToProcess.delete(o.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(o)}const{data:s}=this;this.fireUpdate(s)}handleRequestFailed(e){Rt.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){Rt.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){Rt.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;Rt.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=Je.DEFAULT_MARGIN.t+t*Je.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=Je.DEFAULT_TITLE_PADDING.t+t*Je.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();Je.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;Je.getAxisFormats(this.figure,this.formatter).forEach((t,n)=>{Rt.debug(`Assigning ${n}`,this.layout[n],t);const s=this.layout[n];s!=null?Object.assign(s,t):Rt.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(e,t,n){const{name:s,plotStyle:i}=e,o=this.seriesDataMap.get(s),a=Je.getPlotlyProperty(i,t);o&&bh(o,a,n)}cleanSeries(e){const{name:t,plotStyle:n}=e,s=this.seriesDataMap.get(t);if(s!=null){if(n===x.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:i,xHigh:o}=s;if(i&&o&&i.length===o.length){const a=[];for(let r=0;r<i.length;r+=1)a.push(o[r]-i[r]);s.width=a}}else if(n===x.plot.SeriesPlotStyle.LINE){const{x:i,xLow:o,xHigh:a,y:r,yLow:c,yHigh:h}=s;o&&a&&o!==i&&(s.error_x=Je.getPlotlyErrorBars(i,o,a)),c&&h&&c!==r&&(s.error_y=Je.getPlotlyErrorBars(r,c,h))}else if(n===x.plot.SeriesPlotStyle.TREEMAP){const{ids:i,labels:o}=s;i!==void 0&&o===void 0&&(s.labels=i)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){Rt.warn("Trying to set a filter, but no one click!");return}Rt.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 a=e.get(o);this.lastFilter.get(o)!==a&&s.find(r=>r.name===o)!=null&&n.setValueForColumn(o,a)})}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 bc=Wl;class Gl{static async makeModelFromSettings(e,t,n=_t){const s=await Gl.makeFigureFromSettings(e,t);return new bc(s,e,n)}static async makeFigureFromSettings(e,t){const n=await t.copy();return n.applyCustomColumns(t.customColumns),n.applyFilter(t.filter),n.applySort(t.sort),x.plot.Figure.create(Je.makeFigureSettings(e,n))}static async makeModel(e,t,n=_t){return new bc(t,e,n)}}const Aa=Gl;function wc(d){return d.setFigure!==void 0}function _S({connection:d,defaultUpdateInterval:e,hoverUpdateInterval:t,bgMonitoring:n=!0,monitorDuration:s}){const[i,o]=b.useState({freeMemory:0,maximumHeapSize:999,totalHeapSize:0}),[a,r]=b.useState(!1),c=b.useRef({timestamps:[],usages:[]});b.useEffect(function(){const P=async()=>{const k=await d.getWorkerHeapInfo();if(o(k),n||a){const L=(k.totalHeapSize-k.freeMemory)/k.maximumHeapSize,A=Date.now(),{timestamps:U,usages:j}=c.current;for(;U.length!==0&&A-U[0]>s*1.5;)U.shift(),j.shift();U.push(A),j.push(L)}else c.current={timestamps:[],usages:[]}};P();const O=setInterval(P,a?t:e);return()=>{clearInterval(O)}},[a,t,d,e,s,n]);const h=(H,P)=>Math.round(H*10**P)/10**P,u=2,m=1024**3,{freeMemory:p,totalHeapSize:g,maximumHeapSize:C}=i,f=h(p/m,u),S=h(g/m,u),v=h(C/m,u),w=S-f,T=(H,P,O=!1)=>l.jsxs("div",{className:$("heap-usage-info-row",{"heading-bottom-border":O}),children:[l.jsx("div",{className:"font-weight-bold",children:H}),l.jsx("div",{children:P})]}),{timestamps:y,usages:E}=c.current,I=y[y.length-1]??0,F=g/C,N=(g-p)/C;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"max-memory",children:[l.jsx("div",{className:"total-memory",style:{width:`calc(${F*100}% - ${F*2}px`}}),l.jsx("div",{className:$("used-memory",{"heap-overflow":(g-p)/C>.95}),style:{width:`calc(${N*100}% - ${N*2}px`}}),l.jsxs("div",{className:"memory-text",children:[v.toFixed(1)," GB"]})]}),l.jsx(tt,{onEntered:()=>r(!0),onExited:()=>r(!1),interactive:!0,children:l.jsxs("div",{className:"heap-tooltip",children:[T("In use:",`${w.toFixed(u)} of ${v.toFixed(u)} GB`,!0),T("Free:",`${f.toFixed(u)} GB`),T("Total:",`${S.toFixed(u)} GB`),T("Max:",`${v.toFixed(u)} GB`),l.jsx("div",{className:"heap-plot",children:l.jsx(su,{data:[{x:[...y],y:[...E],type:"scatter",mode:"lines"}],config:{staticPlot:!0,responsive:!0},style:{width:"196px",height:"100px"},layout:{legend:!1,margin:{l:2,t:2,r:2,b:2},plot_bgcolor:"transparent",paper_bgcolor:"transparent",colorway:["#4878ea"],xaxis:{dtick:Math.round(s/6),gridcolor:_t.linecolor,range:[I-s,I],linecolor:_t.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:_t.linecolor,range:[0,1],linecolor:_t.linecolor,linewidth:2,mirror:!0}}})}),l.jsxs("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(s/1e3/60)," min."]})]})})]})}const zl=Object.freeze({}),jS=new Map,iu=d=>d.user,Kl=d=>d.storage,ou=d=>Kl(d).commandHistoryStorage,au=d=>Kl(d).fileStorage,HS=d=>Kl(d).workspaceStorage,dr=d=>d.workspace,Ct=d=>dr(d).data.settings,ru=d=>Ct(d).defaultDateTimeFormat,lu=d=>Ct(d).defaultDecimalFormatOptions??zl,du=d=>Ct(d).defaultIntegerFormatOptions??zl,cu=d=>Ct(d).formatter,Ao=d=>Ct(d).timeZone,hu=d=>Ct(d).showTimeZone,uu=d=>Ct(d).showTSeparator,mu=d=>Ct(d).truncateNumbersWithPound,BS=d=>Ct(d).shortcutOverrides,VS=d=>Ct(d).defaultNotebookSettings??zl,cr=d=>d.activeTool,US=d=>d.plugins??jS,pu="SET_ACTIVE_TOOL",gu="SET_COMMAND_HISTORY_STORAGE",fu="SET_FILE_STORAGE",Cu="SET_PLUGINS",Su="SET_USER",bu="SET_WORKSPACE",wu="SET_WORKSPACE_STORAGE",vu="SET_SERVER_CONFIG_VALUES",$S=d=>({type:Su,payload:d}),Tu=d=>({type:bu,payload:d}),WS=d=>({type:wu,payload:d}),GS=d=>({type:gu,payload:d}),zS=d=>({type:fu,payload:d}),KS=d=>(e,t)=>{e(Tu(d));const{storage:n}=t(),{workspaceStorage:s}=n;return s.save(d)},Eu=d=>(e,t)=>{const{workspace:n}=t(),{data:s}=n,i={...n,data:{...s,...d}};return e(KS(i))},hr=d=>e=>e(Eu({settings:d})),ur=d=>({type:pu,payload:d}),qS=d=>({type:Cu,payload:d}),YS=d=>({type:vu,payload:d});function yu(d,e){return(t=e,n)=>{switch(n.type){case d:{const s=n.payload;return s==null?null:t!=null?{...t,...s}:{...s}}default:return t}}}function XS(d,e={},t=!0){return(n=e,s)=>{switch(s.type){case d:{const{id:i,payload:o}=s;return t&&it({payload:o},{payload:n[i]})?n:{...n,[i]:o}}default:return n}}}function Ls(d,e){return(t=e,n)=>{switch(n.type){case d:return n.payload;default:return t}}}const ZS=Ls(pu,null),QS=Ls(Cu,null),JS=Ls(gu,null),eb=Ls(fu,null),tb=Ls(wu,null),nb=Tl({commandHistoryStorage:JS,fileStorage:eb,workspaceStorage:tb}),sb=yu(Su,null),ib=yu(bu,null),ob=Ls(vu,null),ab={activeTool:ZS,plugins:QS,storage:nb,user:sb,workspace:ib,serverConfigValues:ob};class rb{reducers={};listener=null;register(e,t){this.reducers={...this.reducers,[e]:t},this.listener?.(this.reducers)}setListener(e){this.listener=e}}const Gi=new rb,vc=Z.module("redux-logger"),lb=d=>e=>t=>{vc.debug("dispatching",t);const n=e(t);return vc.debug("next state",d.getState()),n},db=Z.module("redux-crashReporter"),cb=d=>e=>t=>{try{return e(t)}catch(n){throw db.error("Error executing",t," with state ",d.getState(),":",n),n}},hb=[lb,cb,Vm];Object.entries(ab).map(([d,e])=>Gi.register(d,e));const ub=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__??Wm,mr=Um(Tl(Gi.reducers),ub($m(...hb)));Gi.setListener(d=>{mr.replaceReducer(Tl(d))});const xu=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 Ru(d){return d.componentName!==void 0}function mb(d){return d.component!==void 0}const Iu=Object.freeze({type:"default",isClosable:!0,isFocusOnShow:!0,reorderEnabled:!0,title:""}),pb=Object.freeze(Object.defineProperty({__proto__:null,defaultConfig:xu,isGLComponentConfig:Ru,isReactComponentConfig:mb,itemDefaultConfig:Iu},Symbol.toStringTag,{value:"Module"}));class Bt{static ALL_EVENT="__all";_mSubscriptions;constructor(){this._mSubscriptions={},this._mSubscriptions[Bt.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[Bt.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}class ll extends Bt{width;height;title;parent;layoutManager;tab;_config;isHidden=!1;beforeCloseHandler;_element=me(['<div class="lm_item_container">','<div class="lm_content" tabindex="-1"></div>',"</div>"].join(""));_contentElement;constructor(e,t,n){super(),this.title=Ru(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,a=(this[i]??0)*(1/((s.config[i]??0)/100)),r=o/a*100,c=((s.config[i]??0)-r)/(n.contentItems.length-1);for(let h=0;h<n.contentItems.length;h++)n.contentItems[h]===s?n.contentItems[h].config[i]=r:n.contentItems[h].config[i]=(n.contentItems[h].config[i]??0)+c;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(me.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 gb=Object.freeze(Object.defineProperty({__proto__:null,Container:ll,ItemContainer:ll},Symbol.toStringTag,{value:"Module"}));function Du(d){var e=location.hash.match(new RegExp(d+"=([^&]*)"));return e?e[1]:null}function Fu(d){if(window.location.hash)return Du(d);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[d]||null}function pr(d){return window.requestAnimationFrame(d)}function fb(d,e){var t=e.indexOf(d);if(t===-1)throw new Error("Can't remove item from array. Item is not in the array");e.splice(t,1)}function ql(){return(Math.random()*1e15).toString(36).replace(".","")}function Cb(d,e){var t=d.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 Yl(d){return me.trim(d.replace(/(<([^>]+)>)/gi,""))}class Lo extends Bt{_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=me(document),this._eBody=me(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}}}class Nu{_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(){Pi.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(){Pi.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=me.extend(e,this._container._config.props);return X.createElement(this._reactClass,t)}}const La=["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"],Sb=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"];function Xl(d){if(La.length>36)throw new Error("Too many keys in config minifier map");const e={};return Zl(d,e,"_min"),e}function dl(d){if(La.length>36)throw new Error("Too many keys in config minifier map");const e={};return Zl(d,e,"_max"),e}function Zl(d,e,t){const n=t==="_min"?bb:wb;for(let s in d){if(!d.hasOwnProperty(s))continue;const i=Array.isArray(d)?d[Number.parseInt(s,10)]:d[s];if(typeof i=="object"&&i!=null){const o=i instanceof Array?[]:{};if(Array.isArray(e))e[Number.parseInt(s,10)]=o;else{const a=n(s,La);e[a]=o}Zl(i,o,t)}else{const o=n(i,Sb);if(Array.isArray(e))e[Number.parseInt(s,10)]=o;else{const a=n(s,La);e[a]=o}}}}function bb(d,e){if(typeof d=="string"&&d.length===1)return"___"+d;var t=e.indexOf(d);return t===-1?d:t.toString(36)}function wb(d,e){return typeof d=="string"&&d.length===1?e[parseInt(d,36)]:typeof d=="string"&&d.substr(0,3)==="___"?d[3]:d}class cl{name;origin;isPropagationStopped;constructor(e,t){this.name=e,this.origin=t,this.isPropagationStopped=!1}stopPropagation(){this.isPropagationStopped=!0}}let Mu=class extends Bt{_layoutManager;_dontPropagateToParent;_childEventSource;_boundOnEventFromChild;constructor(e){super(),this._layoutManager=e,this._dontPropagateToParent=null,this._childEventSource=null,this.on(Bt.ALL_EVENT,this._onEventFromThis.bind(this)),this._boundOnEventFromChild=this._onEventFromChild.bind(this),me(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(){me(window).off("gl_child_event",this._boundOnEventFromChild)}};const vb=Object.freeze(Object.defineProperty({__proto__:null,BubblingEvent:cl,DragListener:Lo,EventEmitter:Bt,EventHub:Mu,ReactComponentHandler:Nu,animFrame:pr,filterXss:Cb,getHashValue:Du,getQueryStringParam:Fu,getUniqueId:ql,minifyConfig:Xl,removeFromArray:fb,stripTags:Yl,unminifyConfig:dl},Symbol.toStringTag,{value:"Module"}));class ku extends Bt{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=me.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;me(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-"+ql();e=Xl(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 zi extends Bt{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=me(zi._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",Yl(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(),this._setDimensions(),me(document.body).append(this.element),!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 a=this._layoutManager.container.offset();this._minX=a?.left??0,this._minY=a?.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 Ou{_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 Lo(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(me.extend(!0,{},n)),i=new zi(e,t,this._dragListener,this._layoutManager,s,null);this._layoutManager.transitionIndicator?.transitionElements(this._element,i.element)}}class Au{_element=me(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 Lo(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(me.extend(!0,{},n));new zi(e,t,this._dragListener,this._layoutManager,s,null)}}}class gr{static _template='<div class="lm_dropTargetIndicator"><div class="lm_inner"></div></div>';element=me(gr._template);constructor(){me(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 go{element;_header;_action;constructor(e,t,n,s){this._header=e,this.element=me('<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 ti extends Error{node;constructor(e,t){super(),this.name="Configuration Error",this.message=e,this.node=t}}const Tb=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationError:ti},Symbol.toStringTag,{value:"Module"}));function yo(d){return d.isStack}function dn(d){return d.isComponent}function Lu(d){return d.isRoot}class pt extends Bt{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(Bt.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,yo(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&&dn(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 cl(e,this);this.emit(e,t)}_createContentItems(e){var t;if(!(e.content instanceof Array))throw new ti("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(Iu)){const s=t;e[s]===void 0&&(e[s]=n)}return e}_propagateEvent(e,t){t instanceof cl&&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,pr(this._propagateEventToLayoutManager.bind(this,e,t)))}_propagateEventToLayoutManager(e,t){this._pendingEventPropagations[e]=!1,this.layoutManager.emit(e,t)}}class Pu extends pt{config;componentName;container;parent;instance;constructor(e,t,n){super(e,t,n,me()),this.config=t,this.parent=n;const s=e.getComponent(this.config.componentName)||e.getFallbackComponent(),i=me.extend(!0,{},this.config.componentState||{});if(s==null)throw new ti('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 ll(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(){pt.prototype._$init.call(this),this.container.emit("open")}_$hide(){this.container.hide(),pt.prototype._$hide.call(this)}_$show(){this.container.show(),this.container._config.isFocusOnShow&&this.container._contentElement[0].focus({preventScroll:!0}),pt.prototype._$show.call(this)}_$destroy(){this.container.emit("destroy",this),pt.prototype._$destroy.call(this)}_$getArea(){return null}}class Pa extends pt{isRow;isColumn;childElementContainer;parent;_splitter=[];_splitterSize;_splitterGrabSize;_isColumn;_dimension;_splitterPosition=null;_splitterMinPosition=null;_splitterMaxPosition=null;constructor(e,t,n,s){super(t,n,s,me('<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,a;if(e=this.layoutManager._$normalizeContentItem(e,this),t===void 0&&(t=this.contentItems.length),this.contentItems.length>0?(a=this._createSplitter(Math.max(0,t-1)).element,t>0?(this.contentItems[t-1].element.after(a),a.after(e.element)):(this.contentItems[0].element.before(a),a.before(e.element))):this.childElementContainer.append(e.element),pt.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,a;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));pt.prototype.removeChild.call(this,e,t),this.contentItems.length===1&&this.config.isClosable===!0?(a=this.contentItems[0],this.contentItems=[],this.parent.replaceChild(this,a,!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(pt.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 a=0;a<this.contentItems.length;a++){const r=this._isColumn?Math.floor(n*((this.contentItems[a].config.height??0)/100)):Math.floor(t*((this.contentItems[a].config.width??0)/100));s+=r,i.push(r)}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 a;if(this._isColumn||!e||this.contentItems.length<=1)return;const r=this._calculateAbsoluteSizes();for(let h=0;h<this.contentItems.length;h++){this.contentItems[h];const u=r.itemSizes[h];u<e?(s+=e-u,a={width:e}):(n+=u-e,a={width:u},t.push(a)),o.push(a)}if(s===0||s>n)return;const c=s/n;i=s;for(let h=0;h<t.length;h++){a=t[h];const u=Math.round((a.width-e)*c);i-=u,a.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/r.totalWidth*100}_createSplitter(e){var t;return t=new _u(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??[]),a=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)-(a||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}),pr(this.callDownwards.bind(this,"setSize",void 0,void 0,void 0))}}class hl extends pt{childElementContainer;_containerElement;constructor(e,t,n){super(e,{...t,type:"root"},null,me('<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(dn(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",a=s==="left"||s==="top",r=this.contentItems[0];if(!(r instanceof Pa)||r.type!=i){const c=this.layoutManager.createContentItem({type:i},this);this.replaceChild(r,c),c.addChild(e,a?0:void 0,!0),c.addChild(r,a?void 0:0,!0),r.config[o]=50,e.config[o]=50,c.callDownwards("setSize")}else{const c=r.contentItems[a?0:r.contentItems.length-1];r.addChild(e,a?0:void 0,!0),c.config[o]=(c.config[o]??0)*.5,e.config[o]=c.config[o],r.callDownwards("setSize")}}}}class ul extends pt{_activeContentItem=null;_header;childElementContainer=me('<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,me('<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 Mi(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(){pt.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",a=t?"height":"width";if(dn(e)){const r=this.layoutManager.createContentItem({type:"stack",header:e.config.header||{}},this);r._$init(),r.addChild(e),e=r}if(i){const r=this.parent.contentItems.indexOf(this);this.parent.addChild(e,s?r:r+1,!0),this.config[a]=(this.config[a]??0)*.5,e.config[a]=this.config[a],this.parent.callDownwards("setSize")}else{const r=this.layoutManager.createContentItem({type:o},this);this.parent.replaceChild(this,r),r.addChild(e,s?0:void 0,!0),r.addChild(this,s?void 0:0,!0),this.config[a]=50,e.config[a]=50,r.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,a;if(!(i.left<e&&e<i.right)){for(var r=0;r<t;r++)if(o=this.header.tabs[r].element,a=o.get(0)?.getBoundingClientRect(),a&&a.left<e&&e<a.right){this._dropIndex=r;break}o&&a&&e<a.left+a.width*.5?o.before(this.layoutManager.tabDropPlaceholder):o&&(this._dropIndex=Math.min((this._dropIndex??0)+1,t),o.after(this.layoutManager.tabDropPlaceholder))}let c=this.layoutManager.tabDropPlaceholder.offset()?.left??0;c=Math.max(c,this.header.tabsContainer.offset()?.left??0);var h=c+(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:c,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 Eb=Object.freeze(Object.defineProperty({__proto__:null,AbstractContentItem:pt,Component:Pu,ContentItem:pt,Root:hl,RowOrColumn:Pa,Stack:ul,isComponent:dn,isRoot:Lu,isStack:yo},Symbol.toStringTag,{value:"Module"}));class fr{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=me(fr._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 Lo(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),dn(this.contentItem)&&(this.contentItem.container._contentElement.on("focusin",this._onTabContentFocusIn).on("focusout",this._onTabContentFocusOut),this.contentItem.container._contentElement[0].addEventListener("click",this._onTabContentFocusIn,!0),this.contentItem.container.tab=this,this.contentItem.container.emit("tab",this))}setTitle(e=""){this.titleElement.html(e)}setActive(e){e!==this.isActive&&(this.isActive=e,e?this.element.addClass("lm_active"):this.element.removeClass("lm_active"))}_$destroy(){this.element.off("click",this._onTabClick),this.element.off("auxclick",this._onTabClick),this.closeElement.off("click",this._onCloseClick),dn(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 zi(e,t,this._dragListener,this._layoutManager,this.contentItem,this.header.parent)}_onTabContentFocusIn(){dn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.contentItem.container._contentElement[0].focus(),this.element.addClass("lm_focusin")}_onTabContentFocusOut(){dn(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&&dn(this.contentItem)?(this.header.parent.setActiveContentItem(this.contentItem),this.contentItem.container.emit("tabClicked")):dn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&(this.contentItem.container._contentElement.focus(),this.contentItem.container.emit("tabClicked")),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(),dn(this.contentItem)?this.contentItem.container.close():this.header.parent.removeChild(this.contentItem)}_onCloseMousedown(e){e.stopPropagation()}}class Mi extends Bt{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=me(Mi._template);tabsContainer;tabDropdownContainer;tabDropdownSearch;tabDropdownList=null;controlsContainer;parent;tabs=[];activeContentItem=null;closeButton=null;tabDropdownButton=null;tabNextButton=me(Mi._nextButtonTemplate);tabPreviousButton=me(Mi._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 fr(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(a=>{var r=s||a,c=a-r,h=this.START_SPEED*c+.5*this.ACCELERATION*(c*c);h=Math.min(h,this.tabsContainer.get(0)?.scrollWidth??1/0),this._handleScrollRepeat(e,t,h,r)})}_$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(),me(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 go(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 go(this,n,"lm_popout",t)),this._getHeaderSetting("maximise")){s=this.parent.toggleMaximise.bind(this.parent);const o=this._getHeaderSetting("maximise"),a=this._getHeaderSetting("minimise"),r=new go(this,o,"lm_maximise",s);this.parent.on("maximised",function(){r.element.attr("title",a??"")}),this.parent.on("minimised",function(){r.element.attr("title",o??"")})}this._isClosable()&&(e=this.parent.remove.bind(this.parent),n=this._getHeaderSetting("close"),this.closeButton=new go(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"),me(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(),me(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)-(me(window).scrollTop()??0);t+e>(me(window).height()??0)&&this.tabDropdownContainer.css("max-height",(me(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 _u{_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 Lo(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=me('<div class="lm_drag_handle"></div>'),t=me('<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 ju{_element=me('<div class="lm_transition_indicator"></div>');_toElement=null;_fromDimensions={};_totalAnimationDuration=200;_animationStartTime=null;constructor(){me(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),pr(this._nextAnimationFrame.bind(this))}_measure(e){const t=e.offset();return{left:t?.left,top:t?.top,width:e.outerWidth(),height:e.outerHeight()}}}const yb=Object.freeze(Object.defineProperty({__proto__:null,BrowserPopout:ku,DragProxy:zi,DragSource:Ou,DragSourceFromEvent:Au,DropTargetIndicator:gr,Header:Mi,HeaderButton:go,Splitter:_u,Tab:fr,TransitionIndicator:ju},Symbol.toStringTag,{value:"Module"})),xb={config:pb,container:gb,controls:yb,errors:Tb,items:Eb,utils:vb};class Hu extends Bt{static __lm=xb;static minifyConfig(e){return Xl(e)}static unminifyConfig(e){return dl(e)}isInitialised=!1;_isFullPage=!1;_resizeTimeoutId;_components={"lm-react-component":Nu};_fallbackComponent;_itemAreas=[];_maximisedItem=null;_maximisePlaceholder=me('<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 Mu(this);config;container;_originalContainer;dropTargetIndicator=null;transitionIndicator=null;tabDropPlaceholder=me('<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&&me("body").css("visibility","hidden"),this._typeToItem={column:Pa.bind(this,!0),row:Pa.bind(this,!1),stack:ul,component:Pu}}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 pt))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){me(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 gr,this.transitionIndicator=new ju,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(),me(window).off("resize",this._onResize),me(window).off("unload beforeunload",this._onUnload),me(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 ti("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 ti(n);return e.type==="component"&&!(t instanceof ul)&&t&&!(this.isSubWindow===!0&&t instanceof hl)&&(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 pt,a=this;if(o){i=this.toConfig(e).content,n=ql();let c=e.parent,h=e;for(;c?.contentItems.length===1&&!c.isRoot;)h=c,c=c.parent;c?.addId(n),(s==null||Number.isNaN(s))&&(s=c?.contentItems.indexOf(h))}else e instanceof Array?i=e:i=[e];if(!t&&o){const c=window.screenX||window.screenLeft,h=window.screenY||window.screenTop,u=e.element.offset()??{left:0,top:0};t={left:c+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 r=new ku(i,t,n,s,this);return r.on("initialised",function(){a.emit("windowOpened",r)}),r.on("closed",function(){a._$reconcilePopoutWindows()}),this.openPopouts.push(r),r}createDragSource(e,t){this.config.settings.constrainDragToContainer=!1;var n=new Ou(e,t,this);return this._dragSources.push(n),n}createDragSourceFromEvent(e,t){return this.config.settings.constrainDragToContainer=!1,new Au(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(!yo(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 pt)return e;if(me.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&&me(window).resize(this._onResize),me(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=Fu("gl-window");t&&(this.isSubWindow=!0,e=JSON.parse(localStorage.getItem(t)||"{}"),e=dl(e),localStorage.removeItem(t)),e=me.extend(!0,{},xu,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=me('<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=Yl(this.config.content[0].title??""),me("head").append(me("body link, body style, template, .gl_keep")),this.container=me("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?me(this._originalContainer):me("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,me("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 ti(t,e);if(e.content.length>1)throw t="Top level content can't contain more then one element.",new ti(t,e);this.root=new hl(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],a=this._findAllStackContainers()[0],r=0;r<i;r++){var c=o.contentItems[o.contentItems.length-1];this._addChildContentItemsToContainer(a,c)}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=>{yo(n)?e.push(n):n.isComponent||this._findAllStackContainersRecursive(e,n)})}}const Rb="_lm_root_15d73_3",Ib="_lm_row_15d73_7",Db="_lm_item_15d73_7",Fb="_lm_content_15d73_11",Nb="_lm_dragging_15d73_17",Mb="_lm_maximised_15d73_23",kb="_lm_maximise_placeholder_15d73_30",Ob="_lm_splitter_15d73_34",Ab="_lm_vertical_15d73_41",Lb="_lm_drag_handle_15d73_41",Pb="_lm_horizontal_15d73_46",_b="_lm_header_15d73_56",jb="_lm_dropdown_open_15d73_63",Hb="_lm_controls_15d73_69",Bb="_lm_tabs_15d73_89",Vb="_lm_tab_15d73_89",Ub="_lm_title_15d73_104",$b="_lm_close_tab_15d73_111",Wb="_lm_stack_15d73_120",Gb="_lm_left_15d73_120",zb="_lm_right_15d73_121",Kb="_lm_dragProxy_15d73_125",qb="_lm_items_15d73_148",Yb="_lm_tabdropdown_list_15d73_165",Xb="_lm_bottom_15d73_192",Zb="_lm_drop_tab_placeholder_15d73_207",Qb="_lm_tabdropdown_15d73_165",Jb="_lm_dropTargetIndicator_15d73_258",ew="_lm_inner_15d73_264",tw="_lm_transition_indicator_15d73_272",nw="_lm_popin_15d73_282",sw="_lm_bg_15d73_297",iw="_lm_icon_15d73_300",ow="_lm_goldenlayout_15d73_304",aw="_lm_selectable_15d73_340",rw="_lm_active_15d73_370",lw="_lm_selected_15d73_388",dw="_lm_keyboard_active_15d73_397",cw="_lm_popout_15d73_416",hw="_lm_maximise_15d73_23",uw="_lm_close_15d73_111",mw="_lm_tabnextbutton_15d73_425",pw="_lm_tabpreviousbutton_15d73_428",gw="_lm_title_before_15d73_544",fw="_lm_focusin_15d73_568",Cw="_lm_window_blur_15d73_573",Sw="_lm_tabdropdown_search_15d73_631",bw="_march_15d73_1",ww="_app_15d73_712",vw="_plotly_15d73_721",Tc={"tab-height":"28px","drag-border-width":"5px",lm_root:Rb,lm_row:Ib,lm_item:Db,lm_content:Fb,lm_dragging:Nb,lm_maximised:Mb,lm_maximise_placeholder:kb,lm_splitter:Ob,lm_vertical:Ab,lm_drag_handle:Lb,lm_horizontal:Pb,lm_header:_b,lm_dropdown_open:jb,lm_controls:Hb,lm_tabs:Bb,lm_tab:Vb,lm_title:Ub,lm_close_tab:$b,lm_stack:Wb,lm_left:Gb,lm_right:zb,lm_dragProxy:Kb,lm_items:qb,lm_tabdropdown_list:Yb,lm_bottom:Xb,lm_drop_tab_placeholder:Zb,lm_tabdropdown:Qb,lm_dropTargetIndicator:Jb,lm_inner:ew,lm_transition_indicator:tw,lm_popin:nw,lm_bg:sw,lm_icon:iw,lm_goldenlayout:ow,lm_selectable:aw,lm_active:rw,lm_selected:lw,lm_keyboard_active:dw,lm_popout:cw,lm_maximise:hw,lm_close:uw,lm_tabnextbutton:mw,lm_tabpreviousbutton:pw,lm_title_before:gw,"editor-unsaved-indicator":"_editor-unsaved-indicator_15d73_548","is-unsaved":"_is-unsaved_15d73_556",lm_focusin:fw,lm_window_blur:Cw,lm_tabdropdown_search:Sw,march:bw,app:ww,"js-plotly-plot":"_js-plotly-plot_15d73_721",plotly:vw},Ec=Object.freeze({tabHeight:parseInt(Tc["tab-height"],10),dragBorderWidth:parseInt(Tc["drag-border-width"],10)}),hs=Z.module("LayoutUtils");function Bu(d){return d.componentName!==void 0}function xi(d){const e=d;return(Bu(d)&&d.componentName==="lm-react-component"||d.type==="react-component")&&e.component!==void 0}function ta(d){return d.focus!==void 0}function yc(d){return d.type==="stack"}class q{static DEFAULT_FOCUS_SELECTOR="input, select, textarea, button";static activateTab(e,t){const n=q.getStackForRoot(e,t,!1);if(!n){hs.error("Could not find stack for config",t);return}const s=q.getContentItemInStack(n,t);s&&n.setActiveContentItem(s)}static isActiveTab(e,t){const n=q.getStackForRoot(e,t,!1);if(!n)return hs.error("Could not find stack for config",t),!1;const s=q.getContentItemInStack(n,t);return n.getActiveContentItem()===s}static addStack(e,t=!0){const n=t?"column":"row";if(Lu(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 r=document.activeElement;e.contentItems[0].addChild(o),r&&r.focus!=null&&r.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&&yo(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&&Fd(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 a=t[o],r=o===t.length-1,c=q.getStackForRoot(e,{component:a},n&&r,s,i);if(c)return c}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&&Fd(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:a}=i;if(o){const r=t(o,i);r!=null?n.push(r):hs.debug2(`dehydrateLayoutConfig: skipping unmapped component "${o}"`)}else if(a){const r={...i,content:q.dehydrateLayoutConfig(a,t)};n.push(r)}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?(yc(n)&&delete n.activeItemIndex,q.dropLayoutMinorChange(s)):xi(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=q.cloneLayout(e),i=q.cloneLayout(t);return q.dropLayoutMinorChange(s),q.dropLayoutMinorChange(i),it(s,i)}return it(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(xi(i)){const{component:o,props:a={}}=i;n.push({...i,id:i?.id??Pe(),props:t(o,a)})}else if(i.content!==void 0){const o=q.hydrateLayoutConfig(i.content,t);yc(i)&&i.activeItemIndex!=null&&i.activeItemIndex>=o.length&&(hs.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:a=void 0}={}){const r=document.activeElement,c={...t};if(c.id==null&&(c.id=Pe.generate()),a){e?.layoutManager.createDragSourceFromEvent(c,a);return}const h=s||{id:c.id,component:c.component};M(e);const u=i?q.addStack(e):q.getStackForRoot(e,h);M(u);const m=q.getContentItemInStack(u,h);if(o!=null){const p=g=>{hs.debug("Component created, focusing element",o),u.off("componentCreated",p);const{element:C}=g.origin;requestAnimationFrame(()=>{q.focusElement(C[0],o)})};u.on("componentCreated",p)}if(n&&m){const p=u.contentItems.indexOf(m);u.addChild(c,p+1),u.removeChild(m),u.setActiveContentItem(u.contentItems[p])}else u.addChild(c);o==null&&r&&ta(r)&&r.focus()}static openComponentInStack(e,t,n=!0){const s=document.activeElement,i={id:t.id},o=q.getContentItemInStack(e,i);if(n&&o&&e){const a=e?.contentItems.indexOf(o);e.addChild(t,a+1),e.removeChild(o),e.setActiveContentItem(e.contentItems[a])}else e?.addChild(t);s&&ta(s)&&s.focus()}static closeComponent(e,t,n){const s=q.getStackForRoot(e,t,!1,!1,!1);if(!s){hs.warn("Cannot find stack for component, ignoring close",t);return}const i=q.getContentItemInStack(s,t),o=document.activeElement;i&&(dn(i)?i.container.close(n):s.removeChild(i)),o&&document.contains(o)&&ta(o)&&o.focus()}static renameComponent(e,t,n){const s=q.getStackForRoot(e,t,!1);if(!s){hs.error("Could not find stack for config",t);return}const i=q.getContentItemInStack(s,t);i&&i.setTitle(n)}static cloneComponent(e,t){const n=q.getStackForRoot(e,t,!1);if(!n)return hs.error("Could not find stack for config",t),null;const{props:s={}}=t,i=q.getPanelComponentState(t),o={type:"react-component",component:t.component,props:{...s,panelState:i},title:`${t.title} Copy`,id:Pe.generate()};return q.openComponentInStack(n,o),o}static getPanelComponentState(e){return Bu(e)?e.componentState?.panelState:xi(e)?e.props?.panelState:null}static makeDefaultLayout(){return{dimensions:{headerHeight:Ec.tabHeight,borderWidth:Ec.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=q.getComponentConfigFromContainer(e);return t?t.id:null}static getIdFromPanel(e){const{glContainer:t}=e.props;return q.getIdFromContainer(t)}static getComponentNameFromPanel(e){const{glContainer:t}=e.props,n=q.getComponentConfigFromContainer(t);return n&&xi(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=q.DEFAULT_FOCUS_SELECTOR){if(e==null)return null;const n=e.querySelector(t);return n==null?null:(ta(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 Vu=X.forwardRef((d,e)=>{const t=q.getComponentNameFromPanel({props:d});return l.jsxs("div",{ref:e,className:"panel-placeholder",children:['Component "',t,'" is not registered.']})});Vu.displayName="PanelPlaceholder";const Ee=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 xc(d){return d?.WrappedComponent!==void 0}function Tw(d){return typeof d.id=="string"&&d.layout instanceof Hu&&d.panelManager instanceof Uu&&typeof d.registerComponent=="function"}function Ps(d){if(!Tw(d))throw new Error(`Expected dashboard plugin props, but instead received ${d}`)}const sn=Z.module("PanelManager");class Uu{static MAX_CLOSED_PANEL_COUNT=100;layout;hydrateComponent;dehydrateComponent;onPanelsUpdated;closed;openedMap;constructor(e,t=(a,r)=>r,n=(a,r)=>r,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(Ee.FOCUS,this.handleFocus),e.on(Ee.MOUNT,this.handleMount),e.on(Ee.UNMOUNT,this.handleUnmount),e.on(Ee.REOPEN,this.handleReopen),e.on(Ee.DELETE,this.handleDeleted),e.on(Ee.CLOSED,this.handleClosed),e.on(Ee.CLOSE,this.handleControlClose)}stopListening(){const{eventHub:e}=this.layout;e.off(Ee.FOCUS,this.handleFocus),e.off(Ee.MOUNT,this.handleMount),e.off(Ee.UNMOUNT,this.handleUnmount),e.off(Ee.REOPEN,this.handleReopen),e.off(Ee.DELETE,this.handleDeleted),e.off(Ee.CLOSED,this.handleClosed),e.off(Ee.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 q.getComponentConfigFromContainer(t)})}getOpenedPanelConfigsOfType(e){return this.getOpenedPanelConfigs().filter(t=>t!=null&&xi(t)&&t.component===e)}getOpenedPanelById(e){return this.openedMap.get(e)}getContainerByPanelId(e){const t=q.getStackForConfig(this.layout.root,{id:e});return(t&&q.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=>xc(n)&&t instanceof n.WrappedComponent||!xc(n)&&t instanceof n))}updatePanel(e){const t=q.getIdFromPanel(e);if(t==null){sn.error("updatePanel Panel did not have an ID",e);return}sn.debug2(`Updating panel ID ${t} in open panels map`),this.openedMap.delete(t),this.openedMap.set(t,e)}removePanel(e){const t=q.getIdFromPanel(e);if(t==null){sn.error("removePanel Panel did not have an ID",e);return}if(!this.openedMap.has(t)){sn.error(`Missing panel ID ${t} in open panels map`);return}if(this.openedMap.get(t)!==e){sn.debug(`Panel argument doesn't match the open panels map entry for ${t}, removePanel ignored`);return}sn.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){sn.debug2("Focus: ",e),this.updatePanel(e)}handleMount(e){sn.debug2("Mount: ",e),this.updatePanel(e),this.sendUpdate()}handleUnmount(e){sn.debug2("Unmount: ",e),this.removePanel(e),this.sendUpdate()}handleReopen(e,t){sn.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;q.openComponent({root:o,config:i,replaceConfig:t})}handleDeleted(e){sn.debug2("Deleted:",e),this.removeClosedPanelConfig(e),this.sendUpdate()}handleClosed(e,t){sn.debug2("Closed: ",e),this.addClosedPanel(t),this.sendUpdate()}handleControlClose(e){const t={id:e},{root:n}=this.layout;q.closeComponent(n,t)}addClosedPanel(e){const t=q.getComponentConfigFromContainer(e);if(t&&xi(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 Ew=Z.module("PanelErrorBoundary");class yw extends b.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}componentWillUnmount(){const{glContainer:e,glEventHub:t}=this.props,n=q.getIdFromContainer(e);Ew.debug("componentWillUnmount",n),t.emit(Ee.CLOSED,n,e)}render(){const{children:e}=this.props,{error:t}=this.state;return t!=null?l.jsx("div",{className:"panel-error-boundary",children:l.jsx(Ja,{errorMessage:`${t}`,isLoading:!1,isLoaded:!1})}):e}}function Ql(d){const{props:e,componentState:t}=d,{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),{...d,componentState:null,props:i,type:"react-component"}}function Jl(d,e=""){return{metadata:{},...d,localDashboardId:e}}const ml={dehydrate:Ql,hydrate:Jl},xw=D.shape({on:D.func,off:D.func,isHidden:D.bool,tab:D.shape({header:D.shape({tabs:D.arrayOf(D.shape({contentItem:D.shape({})}))})}),title:D.string,setTitle:D.func,close:D.func}),$u=D.shape({on:D.func,off:D.func,emit:D.func}),Rw=D.shape({registerComponent:D.func,root:D.shape({addChild:D.func}),on:D.func,off:D.func,eventHub:$u}),ed=Object.freeze({Container:xw,EventHub:$u,Layout:Rw}),Ue=(d,e,t)=>b.useEffect(function(){return d.on(e,t),()=>{d.off(e,t)}},[d,e,t]),Wu="SET_DASHBOARD_DATA",Iw=XS(Wu,{},!1),Dw={dashboardData:Iw},Fw=new Map,Nw=Object.freeze({}),Mw=Object.freeze([]),kw=d=>d.dashboardData,Vt=(d,e)=>kw(d)[e]??Nw,Ow=(d,e)=>Vt(d,e).closed??Mw,Gu=(d,e)=>Vt(d,e).openedMap??Fw,zu=(d,e)=>({type:Wu,id:d,payload:e}),Pn=(d,e)=>(t,n)=>t(zu(d,{...Vt(n(),d),...e}));Object.entries(Dw).map(([d,e])=>Gi.register(d,e));const na=Z.module("DashboardLayout"),Aw=Object.freeze({}),Lw=[],Rc=()=>{},Ic=d=>d;function Ku({id:d,children:e,emptyDashboard:t=l.jsx("div",{children:"Dashboard is empty."}),layout:n,layoutConfig:s=Lw,onLayoutChange:i=Rc,onLayoutInitialized:o=Rc,hydrate:a=Jl,dehydrate:r=Ql}){const c=El(),h=Gm(U=>Vt(U,d))??Aw,[u,m]=b.useState(!1),[p,g]=b.useState(!1),[C,f]=b.useState(),[S]=b.useState(h?.closed??[]),[v,w]=b.useState(!1),T=b.useMemo(()=>new Map,[]),y=b.useMemo(()=>new Map,[]),E=zm(),I=b.useCallback((U,j,W=a,ie=r)=>{na.debug2("registerComponent",U,j,W,ie);function se(te,oe){const de=j,{glContainer:ee,glEventHub:re}=te;return l.jsx(wh,{store:E,children:l.jsx(yw,{glContainer:ee,glEventHub:re,children:l.jsx(de,{...te,ref:oe})})})}const G=X.forwardRef(se),K=n.registerComponent(U,G);return T.set(U,W),y.set(U,ie),K},[a,r,T,y,n,E]),F=b.useCallback((U,j)=>(T.get(U)??Ic)(j,d),[T,d]),N=b.useCallback((U,j)=>(y.get(U)??Ic)(j,d),[y,d]),H=b.useMemo(()=>new Uu(n,F,N,new Map,S,({closed:U,openedMap:j})=>{c(Pn(d,{closed:U,openedMap:j}))}),[N,c,F,d,S,n]),P=b.useCallback(()=>{if(p)return;v||(o(),w(!0));const j=n.toConfig().content,W=q.dehydrateLayoutConfig(j,N),ie=C==null||!q.isEqual(C,W);na.debug("handleLayoutStateChanged",ie,j,W),ie&&(m(n.root.contentItems.length===0),f(W),i(W))},[N,v,p,C,n,i,o]),O=b.useCallback(U=>{const j=q.getIdFromContainer(U);n.eventHub.emit(Ee.DRAGGING,j),g(!0)},[n.eventHub]),k=b.useCallback(U=>{const j=q.getIdFromContainer(U);n.eventHub.emit(Ee.DROPPED,j),g(!1)},[n.eventHub]),L=b.useCallback(U=>{if(na.debug2("handleComponentCreated",U),U==null||U.config==null||U.config.component==null||U.element==null)return;const W=`${U.config.component.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}-component`;U.element.addClass(W)},[]);Ue(n,"stateChanged",P),Ue(n,"itemPickedUp",O),Ue(n,"itemDropped",k),Ue(n,"componentCreated",L),Ue(n.eventHub,Ee.TITLE_CHANGED,P);const A=ir(s);return b.useEffect(function(){if(A!==s&&s!==C){na.debug("Setting new layout content...");const j=q.hydrateLayoutConfig(s,F);for(;n.root.contentItems.length>0;)n.root.contentItems[0].remove();for(let W=0;W<j.length;W+=1)n.root.addChild(j[W]);m(n.root.contentItems.length===0)}},[F,n,s,C,H,A]),l.jsxs(l.Fragment,{children:[u&&t,X.Children.map(e,U=>U!=null?X.cloneElement(U,{id:d,layout:n,panelManager:H,registerComponent:I}):null)]})}Ku.propTypes={id:D.string.isRequired,children:D.node,data:D.shape({}),emptyDashboard:D.node,layout:ed.Layout.isRequired,layoutConfig:D.arrayOf(D.shape({})),onLayoutChange:D.func,onLayoutInitialized:D.func};const Pw=100,jr=()=>{},_w=Object.freeze({});function jw({id:d="default",children:e,emptyDashboard:t,layoutConfig:n,layoutSettings:s=_w,onLayoutConfigChange:i=jr,onGoldenLayoutChange:o=jr,onLayoutInitialized:a=jr,fallbackComponent:r=Vu,hydrate:c,dehydrate:h}){const u=b.useRef(null),[m,p]=b.useState(!1),[g,C]=b.useState();b.useEffect(function(){if(!u.current){C(void 0);return}const v={...q.makeDefaultLayout()};v.settings===void 0&&(v.settings={}),Object.assign(v.settings,s),v.content=[];const w=new Hu(v,u.current),T=()=>{w.off("initialised",T),p(!0)};return w.on("initialised",T),r!=null&&w.setFallbackComponent(r),w.init(),C(w),o(w),()=>{w.destroy()}},[s,r,o,p,C]);const f=b.useMemo(()=>ks(()=>{g!=null&&g.isInitialised&&g?.updateSize()},Pw),[g]);return b.useEffect(function(){return window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}},[f]),l.jsxs("div",{className:"dashboard-container w-100 h-100",children:[l.jsx("div",{className:"w-100 h-100",ref:u}),m&&g&&l.jsx(Ku,{emptyDashboard:t,id:d,layout:g,layoutConfig:n,onLayoutChange:i,onLayoutInitialized:a,hydrate:c,dehydrate:h,children:e})]})}const wn="default";class qu extends Error{isAssertionFailed=!0}function Dc(d){if(d==null)throw new qu(`Expected 'val' to be defined, but received ${d}`)}class Hr extends Error{isPasteError=!0}function Ze(d){return d?.isEditable!==void 0}function Fc(d){if(!Ze(d))throw new qu(`Expected 'model' to be editable, but received ${d}`)}function ze(d){return d?.hasExpandableRows!==void 0}var vn=(d=>(d.DOWN="DOWN",d.UP="UP",d.LEFT="LEFT",d.RIGHT="RIGHT",d))(vn||{});class z{startColumn;startRow;endColumn;endRow;static SELECTION_DIRECTION=vn;static normalize(e,t,n,s){let i=e,o=t,a=n,r=s;return i!=null&&a!=null&&a<i&&(i=a,a=e),o!=null&&r!=null&&r<o&&(o=r,r=t),[i,o,a,r]}static makeNormalized(e,t,n,s){return new z(...z.normalize(e,t,n,s))}static makeCell(e,t){return new z(e,t,e,t)}static makeColumn(e){return new z(e,null,e,null)}static makeRow(e){return new z(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 a=t[o];if(i.contains(a))t.splice(o,1);else if(a.contains(i)){n=!0,t[s]=a,t.splice(o,1);break}else if(i.startRow===a.startRow&&i.endRow===a.endRow){if(i.touches(a)){const{startRow:r,endRow:c}=i,h=z.minOrNull(i.startColumn,a.startColumn),u=z.maxOrNull(i.endColumn,a.endColumn);n=!0,t[s]=new z(h,r,u,c),t.splice(o,1);break}}else if(i.startColumn===a.startColumn&&i.endColumn===a.endColumn&&i.touches(a)){const{startColumn:r,endColumn:c}=i,h=z.minOrNull(i.startRow,a.startRow),u=z.maxOrNull(i.endRow,a.endRow);n=!0,t[s]=new z(r,h,c,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 z(n,s,i,o)}static subtractFromRange(e,t){const n=[],s=z.intersection(e,t);return s==null?[e]:(s.startRow!=null&&(e.startRow==null||e.startRow<s.startRow)&&n.push(new z(e.startColumn,e.startRow,e.endColumn,s.startRow-1)),s.startColumn!=null&&(e.startColumn==null||e.startColumn<s.startColumn)&&n.push(new z(e.startColumn,s.startRow,s.startColumn-1,s.endRow)),s.endColumn!=null&&(e.endColumn==null||e.endColumn>s.endColumn)&&n.push(new z(s.endColumn+1,s.startRow,e.endColumn,s.endRow)),s.endRow!=null&&(e.endRow==null||e.endRow>s.endRow)&&n.push(new z(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(...z.subtractFromRange(e[s],t));return n}static subtractRangesFromRanges(e,t){let n=[...e];for(let s=0;s<t.length;s+=1)n=z.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 z.isBounded(e)?e:new z(e.startColumn??0,e.startRow??0,e.endColumn??t-1,e.endRow??n-1)}static boundedRanges(e,t,n){return e.map(s=>z.boundedRange(s,t,n))}static offset(e,t,n){return new z(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=z.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 a=e[i].nextCell(t,n,s);if(a!=null)return a}switch(s){case z.SELECTION_DIRECTION.DOWN:case z.SELECTION_DIRECTION.RIGHT:{const o=i<e.length-1?i+1:0;return e[o].startCell(s)}case z.SELECTION_DIRECTION.LEFT:case z.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=z.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 z.isAxisRangeTouching(this.startRow,this.endRow,e.startRow,e.endRow)&&z.isAxisRangeTouching(this.startColumn,this.endColumn,e.startColumn,e.endColumn)}subtract(e){return z.subtractFromRange(this,e)}startCell(e=z.SELECTION_DIRECTION.DOWN){if(!z.isBounded(this))throw new Error("Cannot get the startCell of an unbounded range");switch(e){case z.SELECTION_DIRECTION.DOWN:case z.SELECTION_DIRECTION.RIGHT:return{column:this.startColumn,row:this.startRow};case z.SELECTION_DIRECTION.LEFT:case z.SELECTION_DIRECTION.UP:return{column:this.endColumn,row:this.endRow};default:throw new Error(`Invalid direction: ${e}`)}}nextCell(e,t,n){if(!z.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:a}=this;switch(n){case z.SELECTION_DIRECTION.DOWN:if(t<a)return{column:e,row:Math.max(t+1,o)};if(e<i)return{column:Math.max(e+1,s),row:o};break;case z.SELECTION_DIRECTION.UP:if(t>o)return{column:e,row:Math.min(t-1,a)};if(e>s)return{column:Math.min(e-1,i),row:a};break;case z.SELECTION_DIRECTION.RIGHT:if(e<i)return{column:Math.max(e+1,s),row:t};if(t<a)return{column:s,row:Math.max(t+1,o)};break;case z.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,a)};break;default:throw new Error(`Invalid direction: ${n}`)}return null}forEach(e,t=z.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)??{}}}function Hw(d){return Array.isArray(d)&&d.length===2&&(d[0]===null||typeof d[0]=="number")&&(d[1]===null||typeof d[1]=="number")}function sa(d){return Hw(d)&&d[0]!=null&&d[1]!=null}function _a(d){return d?.href!==void 0}class B{static PIXELS_PER_LINE=100/3;static getGridPointFromXY(e,t,n){const s=B.getColumnAtX(e,n),i=B.getRowAtY(t,n),o=B.getColumnHeaderDepthAtY(t,n);return{x:e,y:t,row:i,column:s,columnHeaderDepth:o}}static getCellInfoFromXY(e,t,n){const{row:s,column:i}=B.getGridPointFromXY(e,t,n),{allColumnWidths:o,allRowHeights:a,allColumnXs:r,allRowYs:c,modelColumns:h,modelRows:u}=n,m=s!==null?u.get(s):null,p=i!==null?h.get(i):null,g=i!==null?r.get(i):null,C=s!==null?c.get(s):null,f=i!==null?o.get(i):null,S=s!==null?a.get(s):null;return{row:s,column:i,modelRow:m??null,modelColumn:p??null,left:g??null,top:C??null,columnWidth:f??null,rowHeight:S??null}}static getColumnHeaderDepthAtY(e,t){const n=B.getRowAtY(e,t),{columnHeaderHeight:s,columnHeaderMaxDepth:i}=t;if(n===null&&e<=s*i)return je(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=B.iterateFloatingStart(e,n,s);return i!==void 0?i:B.iterateFloatingEnd(t,n,s)}static iterateAllItems(e,t,n,s,i,o){const a=Math.max(e,n),r=Math.min(t,i-s-1);let c=B.iterateFloating(n,s,i,o);if(c!==void 0)return c;for(let h=a;h<=r;h+=1)if(c=o(h),c!==void 0)return c}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,a,r=!1){const c=r?void 0:B.iterateFloating(n,s,t,h=>{if(B.isInItem(h,o,a,e))return h});if(!r&&c!==void 0)return c;for(let h=0;h<i.length;h+=1){const u=i[h];if(B.isInItem(u,o,a,e))return u}return null}static getColumnAtX(e,t,n=!1){const{columnCount:s,floatingLeftColumnCount:i,floatingRightColumnCount:o,visibleColumns:a,allColumnXs:r,allColumnWidths:c,gridX:h}=t;return e<h?null:this.getItemAtOffset(e-h,s,i,o,a,r,c,n)}static getRowAtY(e,t){const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i,visibleRows:o,allRowYs:a,allRowHeights:r,gridY:c}=t;return e<c?null:this.getItemAtOffset(e-c,i,n,s,o,a,r)}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],a=t.get(o);if(a!=null&&s.get(a)!==0)return o;i-=1}return null}static getNextShownColumn(e,t){const{modelColumns:n,visibleColumns:s,userColumnWidths:i}=t;return B.getNextShownItem(e,n,s,i)}static getNextShownRow(e,t){const{modelRows:n,visibleRows:s,userRowHeights:i}=t;return B.getNextShownItem(e,n,s,i)}static getColumnSeparatorIndex(e,t,n,s){const{rowHeaderWidth:i,columnHeaderHeight:o,floatingColumns:a,floatingLeftWidth:r,visibleColumns:c,allColumnXs:h,allColumnWidths:u,columnHeaderMaxDepth:m}=n,{allowColumnResize:p,headerSeparatorHandleSize:g}=s;if(m*o<t||!p||g<=0)return null;const C=e-i,f=g*.5;let S=!1;for(let v=a.length-1;v>=0;v-=1){const w=a[v],T=h.get(w)??0,y=u.get(w)??0,E=y===0;if(!S||!E){let I=T+y;E?I+=f:S&&(I-=f);const F=I-f,N=I+f;if(F<=C&&C<=N)return w;S=E}}S=!1;for(let v=c.length-1;v>=0;v-=1){const w=c[v],T=h.get(w)??0,y=u.get(w)??0,E=y===0;if(T<r-y)return null;if(!S||!E){let I=T+y;E?I+=f:S&&(I-=f);const F=I-f,N=I+f;if(F<=C&&C<=N)return w;S=E}}return null}static isItemHidden(e,t){return t.get(e)===0}static isColumnHidden(e,t){const{allColumnWidths:n}=t;return B.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(!B.isItemHidden(e,t))return[];const s=[e],i=n.findIndex(o=>o===e);for(let o=i-1;o>=0;o-=1){const a=n[o];if(!B.isItemHidden(a,t))break;s.push(a)}return s}static getHiddenColumns(e,t){const{visibleColumns:n,allColumnWidths:s}=t;return B.getHiddenItems(e,s,n)}static getRowSeparatorIndex(e,t,n,s){const{rowHeaderWidth:i,columnHeaderHeight:o,visibleRows:a,allRowYs:r,allRowHeights:c}=n,{allowRowResize:h,headerSeparatorHandleSize:u}=s;if(i<e||!h||u<=0)return null;const m=t-o,p=u*.5;let g=!1;for(let C=a.length-1;C>=0;C-=1){const f=a[C],S=r.get(f)??0,v=c.get(f)??0,w=v===0;if(!g||!w){let T=S+v;w?T+=p:g&&(T-=p);const y=T-p,E=T+p;if(y<=m&&m<=E)return f;g=w}}return null}static isRowHidden(e,t){const{allRowHeights:n}=t;return B.isItemHidden(e,n)}static getHiddenRows(e,t){const{visibleRows:n,allRowHeights:s}=t;return B.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&&!sa(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 B.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],a=o[o.length-1];a!=null&&sa(a.from)&&a.from[1]-a.from[0]===e[1]-e[0]&&a.to===e[0]?o[o.length-1]={...a,to:i}:o.push({from:e,to:i});const r=o[o.length-1];return sa(r.from)&&r.from[0]===r.to&&o.pop(),o}static moveItemOrRange(e,t,n,s=!1){return Array.isArray(e)?B.moveRange(e,t,n,s):B.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:a,to:r}=n[o];let c=1,h;sa(a)?(c=a[1]-a[0]+1,[h]=a):h=a;const u=s?r:h,m=u+c-1,p=s?h:r,g=p-u,C=[];for(let f=0;f<i.length;f+=1){const S=i[f][0]??Number.NEGATIVE_INFINITY,v=i[f][1]??Number.POSITIVE_INFINITY;let w;const T=[[S,u-1],[u,m],[m+1,v]].map(([y,E])=>[Math.max(y,S),Math.min(E,v)]).filter(([y,E])=>y<=E).map(y=>{const[E,I]=y;return u<=E&&m>=I?(w=[E+g,I+g],w):m<E?[E-c,I-c]:y}).map(y=>{const[E,I]=y;return p>E&&p<=I?[[E,p-1],[p+c,I+c]]:y===w?[y]:p<=E?[[E+c,I+c]]:[y]}).flat();C.push(...T)}i=C.map(([f,S])=>[Number.isFinite(f)?f:null,Number.isFinite(S)?S:null])}return i}static translateRange(e,t,n,s){const i=B.applyItemMoves(e.startColumn,e.endColumn,t,s),o=B.applyItemMoves(e.startRow,e.endRow,n,s),a=[];for(let r=0;r<i.length;r+=1){const c=i[r];for(let h=0;h<o.length;h+=1){const u=o[h];a.push(new z(c[0],u[0],c[1],u[1]))}}return a}static getModelIndex(e,t){return B.applyItemMoves(e,e,t,!0)[0][0]}static getModelIndexes(e,t){return e.map(n=>B.getModelIndex(n,t))}static getModelRangeIndexes(e,t,n){return B.applyItemMoves(e,t,n,!0)}static getModelRange(e,t=De,n=De){return B.translateRange(e,t,n,!0)}static getModelRanges(e,t=De,n=De){const s=[];for(let i=0;i<e.length;i+=1)s.push(...B.getModelRange(e[i],t,n));return s}static getVisibleRangeIndexes(e,t,n){return B.applyItemMoves(e,t,n,!1)}static getVisibleRange(e,t=De,n=De){return this.translateRange(e,t,n,!1)}static getVisibleRanges(e,t=De,n=De){const s=[];for(let i=0;i<e.length;i+=1)s.push(...B.getVisibleRange(e[i],t,n));return s}static getVisibleIndex(e,t){return B.applyItemMoves(e,e,t)[0][0]}static getVisibleIndexes(e,t){return e.map(n=>B.getVisibleIndex(n,t))}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return B.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){const t=B.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:a,floatingTopRowCount:r,floatingBottomRowCount:c,floatingLeftColumnCount:h,floatingRightColumnCount:u,floatingLeftWidth:m,floatingRightWidth:p,floatingTopHeight:g,floatingBottomHeight:C,columnCount:f,rowCount:S}=e;let v=s,w=i,T=o,y=a;return n!=null&&(n>h&&(v+=m),n<f-u&&(T-=p)),t!=null&&(t>r&&(w+=g),t<S-c&&(y-=C)),{x1:v,y1:w,x2:T,y2:y}}static getScrollDelta(e,t=1024,n=768,s=20,i=20){let{deltaX:o,deltaY:a}=e;return!B.isMacPlatform()&&e.shiftKey&&e.deltaX===0&&e.deltaY!==0&&(o=e.deltaY,a=e.deltaX),e?.deltaMode===WheelEvent.DOM_DELTA_PAGE?(o*=t,a*=n):e?.deltaMode===WheelEvent.DOM_DELTA_LINE&&(B.isMacPlatform()?(o=Math.round(o*s),a=Math.round(a*i)):(o=Math.round(o*this.PIXELS_PER_LINE),a=Math.round(a*this.PIXELS_PER_LINE))),{deltaX:o,deltaY:a}}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:a,gridY:r,width:c,height:h,verticalBarWidth:u,horizontalBarHeight:m}=t,p=je(a+n,a,c-u),g=je(a+i,a,c-u),C=je(r+s,r,h-m),f=je(r+o,r,h-m);return{x1:p,y1:C,x2:g,y2:f,token:e.token}}}function ia(d,e=Po.CACHE_SIZE,t=Math.floor(e/2)){if(d.size>e){const n=d.keys();for(;d.size>t;)d.delete(n.next().value)}}function Nc(d,e,t,n,s){const i=new Map;let o=0;for(let a=0;a<d&&a<t;a+=1)i.set(a,o),o+=_(s,a);o=n;for(let a=0;a<e&&t-a-1>=0;a+=1)o-=_(s,t-a-1),i.set(t-a-1,o);return i}class Po{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:a=new Map,movedRows:r=[],movedColumns:c=[],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=a,this.movedRows=r,this.movedColumns=c,this.initialRowHeights=h,this.initialColumnWidths=u}getMetrics(e){const{left:t,top:n,leftOffset:s,topOffset:i,width:o,height:a,theme:r,model:c,movedRows:h,movedColumns:u,draggingColumn:m}=e,{rowHeight:p,rowHeaderWidth:g,rowFooterWidth:C,columnWidth:f,columnHeaderHeight:S,minScrollHandleSize:v,scrollBarSize:w}=r;h!==this.movedRows&&(this.movedRows=h,this.modelRows.clear()),u!==this.movedColumns&&(this.movedColumns=u,this.modelColumns.clear());const{columnCount:T,rowCount:y,floatingTopRowCount:E,floatingBottomRowCount:I,floatingLeftColumnCount:F,floatingRightColumnCount:N,columnHeaderMaxDepth:H}=c,P=this.getFirstRow(e),O=this.getFirstColumn(e),k=this.getGridX(e),L=this.getGridY(e),A=ze(c)&&c.hasExpandableRows?this.calculateTreePaddingX(e):0,U=0,j=this.getVisibleRowHeights(e),W=this.getVisibleColumnWidths(e,O,A),ie=Array.from(j.keys()),se=Array.from(W.keys()),G=new Map([...j,...this.getFloatingRowHeights(e)]),K=new Map([...W,...this.getFloatingColumnWidths(e)]),te=this.getVisibleColumnXs(K,se,s),oe=this.getVisibleRowYs(G,ie,i),de=ie.length>0?ie[ie.length-1]:n,ee=se.length>0?se[se.length-1]:t,re=this.getBottomViewport(e,ie,oe,G),we=this.getRightViewport(e,se,te,K),xe=this.getFloatingTopHeight(e,G),Oe=this.getFloatingBottomHeight(e,G),Jt=this.getFloatingLeftWidth(e,K),Mt=this.getFloatingRightWidth(e,K),ss=Array.from(K.values()),Tn=Array.from(G.values()),kt=ss.reduce((qe,_n)=>qe+_n,0)-s,ye=Tn.reduce((qe,_n)=>qe+_n,0)-i,ht=s+kt+C,at=i+ye,St=o-k,Ot=a-L,En=this.getLastLeft(e,null,St-C),en=this.getLastLeft(e,null,St-C-w),_o=this.getLastTop(e,null,Ot-Oe),_s=this.getLastTop(e,null,Ot-Oe-w);let tn=en,is=_s;En===0&&_o===0&&(tn=0,is=0);const di=tn>0,qi=di?w:0,ci=is>0,hi=ci?w:0,jo=k,Ho=H*S,os=o-jo-hi,js=a-Ho-qi,Tr=T===1?os/ht:(T-tn)/T,Bo=y===1?js/at:(y-is)/y,Yi=di?je(os*Tr,v,os-1):0,Xi=ci?je(js*Bo,v,js-1):0,Zi=_(K,t,0),Vo=_(G,n,0),Er=Zi>0?s/Zi:0,yr=Vo>0?i/Vo:0,xr=T===1?s/(ht-St):(t+Er)/tn,Rr=y===1?i/(at-Ot):(n+yr)/is,Hs=di?xr*(os-Yi):0,Ir=ci?Rr*(js-Xi):0,Qi=[...Array(E).keys(),...[...Array(I).keys()].map(qe=>y-qe-1)],Ji=new Map([...oe,...this.getFloatingRowYs(e,G,Math.floor(a-L-qi))]),Uo=[...Array(F).keys(),...[...Array(N).keys()].map(qe=>T-qe-1)],Bs=new Map([...te,...this.getFloatingColumnXs(e,K,Math.floor(o-k-hi))]),eo=[];if(m)for(let qe=m.range[0];qe<=m.range[1];qe+=1)eo.push(qe),K.has(qe)||K.set(qe,this.getVisibleColumnWidth(qe,e)),Bs.has(qe)||Bs.set(qe,0);const to=ie.concat(Qi),$o=se.concat(Uo).concat(eo),no=this.getModelRows(to,e),Wo=this.getModelColumns($o,e),Dr=this.getVisibleRowTreeBoxes(G,no,e),Go=this.getTopVisible(e,Ji,G,ie),zo=this.getLeftVisible(e,Bs,K,se),Ko=is>0?this.getBottomVisible(e,Ji,G,ie,L):de,qo=tn>0?this.getRightVisible(e,Bs,K,se,k):ee,{fontWidths:Yo,userColumnWidths:Xo,userRowHeights:Fr,calculatedRowHeights:Ke,calculatedColumnWidths:yt}=this;return{rowHeight:p,rowHeaderWidth:g,rowFooterWidth:C,rowCount:y,columnWidth:f,columnCount:T,columnHeaderHeight:S,floatingTopRowCount:E,floatingBottomRowCount:I,floatingLeftColumnCount:F,floatingRightColumnCount:N,gridX:k,gridY:L,firstRow:P,firstColumn:O,treePaddingX:A,treePaddingY:U,left:t,top:n,bottom:de,right:ee,topOffset:i,leftOffset:s,topVisible:Go,leftVisible:zo,bottomVisible:Ko,rightVisible:qo,bottomViewport:re,rightViewport:we,width:o,height:a,maxX:kt,maxY:ye,lastLeft:tn,lastTop:is,barHeight:js,barTop:Ho,barWidth:os,barLeft:jo,handleHeight:Xi,handleWidth:Yi,hasHorizontalBar:di,hasVerticalBar:ci,verticalBarWidth:hi,horizontalBarHeight:qi,scrollX:Hs,scrollY:Ir,scrollableContentWidth:ht,scrollableContentHeight:at,scrollableViewportWidth:St,scrollableViewportHeight:Ot,visibleRows:ie,visibleColumns:se,visibleRowHeights:j,visibleColumnWidths:W,floatingRows:Qi,floatingColumns:Uo,allRows:to,allColumns:$o,allRowHeights:G,allColumnWidths:K,floatingTopHeight:xe,floatingBottomHeight:Oe,floatingLeftWidth:Jt,floatingRightWidth:Mt,visibleRowYs:oe,visibleColumnXs:te,allRowYs:Ji,allColumnXs:Bs,visibleRowTreeBoxes:Dr,modelRows:no,modelColumns:Wo,movedRows:h,movedColumns:u,fontWidths:Yo,userColumnWidths:Xo,userRowHeights:Fr,calculatedRowHeights:Ke,calculatedColumnWidths:yt,columnHeaderMaxDepth:H}}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),a=this.getFloatingBottomHeight(e,t),r=this.getFloatingTopHeight(e,t);return n-a-r-o-i}getVisibleWidth(e,t=this.getFloatingColumnWidths(e)){const{width:n,theme:s}=e,{scrollBarSize:i,rowFooterWidth:o}=s,a=this.getGridX(e),r=this.getFloatingRightWidth(e,t),c=this.getFloatingLeftWidth(e,t);return n-c-r-a-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 a=Math.max(0,i-o-1);t!=null&&(a=t);let r=0;for(;a>=0;){const c=this.getVisibleColumnWidth(a,e);if(r+=c,r>=n)return je(a+1,0,t??i-1);a-=1}return 0}getLastTop(e,t,n){const{model:s}=e,{rowCount:i,floatingBottomRowCount:o}=s;let a=Math.max(0,i-o-1);t!=null&&(a=t);let r=0;for(;a>=0;){const c=this.getVisibleRowHeight(a,e);if(r+=c,r>=n)return je(a+1,0,i-1);a-=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 a=0;a<n&&a<i;a+=1)o.set(a,this.getVisibleRowHeight(a,e));for(let a=0;a<s&&i-a-1>=0;a+=1){const r=i-a-1;o.set(r,this.getVisibleRowHeight(r,e))}return o}getVisibleRowHeights(e){const{top:t,topOffset:n,height:s,model:i}=e;let o=0,a=t;const r=new Map,{rowCount:c}=i;for(;o<s+n&&a<c;){const h=this.getVisibleRowHeight(a,e);r.set(a,h),o+=h,a+=1}return r}getFloatingColumnWidths(e,t=this.getFirstColumn(e),n=this.calculateTreePaddingX(e)){const{model:s}=e,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:a}=s,r=new Map;for(let c=0;c<o&&c<i;c+=1)r.set(c,this.getVisibleColumnWidth(c,e,t,n));for(let c=0;c<a&&i-c-1>=0;c+=1){const h=i-c-1;r.set(h,this.getVisibleColumnWidth(h,e,t,n))}return r}getVisibleColumnWidths(e,t=this.getFirstColumn(e),n=this.calculateTreePaddingX(e)){const{left:s,leftOffset:i,width:o,model:a}=e;let r=0,c=s;const h=new Map,{columnCount:u}=a;for(;r<o+i&&c<u;){const m=this.getVisibleColumnWidth(c,e,t,n);h.set(c,m),r+=m,c+=1}return h}getFloatingColumnXs(e,t,n){const{model:s}=e,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:a}=s;return Nc(o,a,i,n,t)}getVisibleColumnXs(e,t,n){const s=new Map;let i=-n;for(let o=0;o<t.length;o+=1){const a=t[o],r=_(e,a);s.set(a,i),i+=r}return s}getFloatingRowYs(e,t,n){const{model:s}=e,{floatingTopRowCount:i,floatingBottomRowCount:o,rowCount:a}=s;return Nc(i,o,a,n,t)}getVisibleRowYs(e,t,n){const s=new Map;let i=-n;for(let o=0;o<t.length;o+=1){const a=t[o],r=_(e,a);s.set(a,i),i+=r}return s}getVisibleRowTreeBoxes(e,t,n){const s=new Map,{model:i,theme:o}=n,{treeDepthIndent:a,treeHorizontalPadding:r}=o;return ze(i)&&i.hasExpandableRows&&e.forEach((c,h)=>{const u=_(t,h);if(i.isRowExpandable(u)){const m=i.depthForRow(u),p=m*a+r,g=(m+1)*a+r,C=0,f=c;s.set(h,{x1:p,y1:C,x2:g,y2:f})}}),s}getFloatingLeftWidth(e,t=this.getFloatingColumnWidths(e)){const{model:n}=e,{floatingLeftColumnCount:s}=n;let i=0;for(let o=0;o<s;o+=1)i+=_(t,o);return i}getFloatingRightWidth(e,t=this.getFloatingColumnWidths(e)){const{model:n}=e,{floatingRightColumnCount:s,columnCount:i}=n;let o=0;for(let a=0;a<s;a+=1)o+=_(t,i-a-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+=_(t,o);return i}getFloatingBottomHeight(e,t=this.getFloatingRowHeights(e)){const{model:n}=e,{floatingBottomRowCount:s,rowCount:i}=n;let o=0;for(let a=0;a<s;a+=1)o+=_(t,i-a-1);return o}getTopVisible(e,t,n,s){const i=this.getFloatingTopHeight(e,n);for(let o=0;o<s.length;o+=1){const a=s[o];if(_(t,a)>=i)return a}return 0}getLeftVisible(e,t,n,s){const i=this.getFloatingLeftWidth(e,n);for(let o=0;o<s.length;o+=1){const a=s[o];if(_(t,a)>=i)return a}return 0}getBottomVisible(e,t,n,s,i){const{height:o,theme:a}=e,{scrollBarSize:r}=a,c=this.getFloatingBottomHeight(e,n),h=o-i-r-c;for(let u=s.length-1;u>=0;u-=1){const m=s[u],p=_(t,m),g=_(n,m);if(p+g<=h)return m}return 0}getRightVisible(e,t,n,s,i){const{width:o,theme:a}=e,{scrollBarSize:r}=a,c=this.getFloatingRightWidth(e,n),h=o-i-r-c;for(let u=s.length-1;u>=0;u-=1){const m=s[u],p=_(t,m),g=_(n,m);if(p+g<=h)return m}return 0}getBottomViewport(e,t,n,s){const{height:i,theme:o}=e,{rowHeight:a}=o;return this.getLastIndexViewport(t,n,s,i,a)}getRightViewport(e,t,n,s){const{width:i,theme:o}=e,{columnWidth:a}=o;return this.getLastIndexViewport(t,n,s,i,a)}getLastIndexViewport(e,t,n,s,i){let o=0,a=0;return e.length>0&&(o=e[e.length-1],a=_(t,o)+_(n,o)),a<s&&(o+=Math.ceil((s-a)/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 a=this.initialColumnWidths.get(i);return a!==void 0?a: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 _(this.modelRows,e);const{movedRows:n}=t,s=B.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 _(this.modelColumns,e);const{movedColumns:s}=t,i=B.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 a=this.calculatedRowHeights.get(t);return a??(this.calculatedRowHeights.set(t,Math.ceil(o)),ia(this.calculatedRowHeights),o)}calculateColumnWidth(e,t,n,s=this.getFirstColumn(n),i=this.calculateTreePaddingX(n)){const{theme:o}=n,{autoSizeColumns:a,minColumnWidth:r}=o;if(!a){const{columnWidth:p}=o;return p}const c=this.calculateColumnHeaderWidth(t,n),h=this.calculateColumnDataWidth(t,n),u=this.calculatedColumnWidths.get(t);let m=Math.ceil(Math.max(c,h));return m=Math.max(r,m),u!=null&&u>m?m=u:(this.calculatedColumnWidths.set(t,m),ia(this.calculatedColumnWidths)),e===s&&(m+=i),m}calculateColumnHeaderWidth(e,t){const{model:n,theme:s}=t,{headerFont:i,headerHorizontalPadding:o}=s,a=n.textForColumnHeader(e,0);if(a!==void 0&&a!==""){const r=this.getWidthForFont(i,t);return a.length*r+o*2}return o*2}calculateColumnDataWidth(e,t){const{top:n,height:s,width:i,model:o,theme:a}=t,{floatingTopRowCount:r,floatingBottomRowCount:c,rowCount:h}=o,{font:u,cellHorizontalPadding:m,rowHeight:p,rowHeaderWidth:g,rowFooterWidth:C,scrollBarSize:f}=a;let S=0;const v=this.getWidthForFont(u,t),w=s/p,T=Math.ceil(n+w);return B.iterateAllItems(n,T,r,c,h,y=>{const E=this.getModelRow(y,t),I=o.textForCell(e,E);if(I){const F=m*2;S=Math.max(S,I.length*v+F)}}),S=Math.max(Math.min(S,(i-g-f-C)*Po.MAX_COLUMN_WIDTH),m*2),S}calculateTreePaddingX(e){const{top:t,height:n,model:s,theme:i}=e,{rowHeight:o,treeDepthIndent:a}=i;if(!ze(s)||!s.hasExpandableRows)return 0;let r=0;const c=n/o,h=Math.ceil(t+c);for(let u=t;u<=h;u+=1){const m=this.getModelRow(u,e),p=s.depthForRow(m);r=Math.max(r,a*(p+1))}return r}getWidthForFont(e,t){if(this.fontWidths.has(e))return _(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)),ia(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)),ia(n),this.userRowHeights=n}resetRowHeight(e){const t=new Map(this.userRowHeights);t.delete(e),this.userRowHeights=t,this.calculatedRowHeights.delete(e)}}const Bw=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"}),qn=(d,e)=>{let t=!1;const n=pe(d,{...e,dispose:()=>{t||(t=!0,n.clear(),t=!1)}});return n};function Vw(d,e,t=6){const n=tl.hex.lab.raw(d);return n[0]=Math.max(n[0]-n[0]/t*e,0),`#${tl.lab.hex(n)}`}function Uw(d,e){const[t,n,s]=tl.hex.rgb(d);return`rgba(${t}, ${n}, ${s}, ${e})`}const Mc={colorWithAlpha:Uw,darkenForDepth:Vw};class dt{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 Yu extends dt{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 a=o.index;return this.dragOffset=0,this.draggingIndex=a,this.resizingItems=[a],this.hiddenItems=this.getHiddenItems(a,n).reverse(),this.targetSizes.clear(),this.addTargetSize(n,a),this.updateCursor(n,a),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(),a=i[this.visibleOffsetProperty],r=i[this.marginProperty],c=i[this.calculatedSizesProperty],h=i[this.modelIndexesProperty],u=i[this.firstIndexProperty],m=i[this.treePaddingProperty],p=new Map;let g=this.resizingItems[this.resizingItems.length-1];for(;g!=null;){const C=_(a,g),f=n-r-C-this.dragOffset,S=_(h,g),v=this.targetSizes.get(S),w=this.resizingItems.length>1,T=this.hiddenItems.indexOf(g);let y=_(c,S);g===u&&(y+=m);let E=f;Math.abs(f-y)<=o.headerResizeSnapThreshold?E=y:v!==void 0&&f>v&&(w&&T!==0||T>0)?E=v:f<=o.headerResizeHiddenSnapThreshold&&(E=0),p.set(S,E),f<-o.headerResizeSnapThreshold&&E===0?T>=0&&w?(this.resizingItems.pop(),this.removeTargetSize(i,g),g=this.resizingItems[this.resizingItems.length-1],this.dragOffset-=this.targetSizes.get(_(h,g))??0):(g=this.getNextShownItem(g,i),g!==null&&(this.resizingItems.push(g),this.addTargetSize(i,g))):v!==void 0&&f>v+o.headerResizeSnapThreshold&&E===v?T>0?(this.dragOffset+=E,g=this.hiddenItems[T-1],this.resizingItems.push(g),this.addTargetSize(i,g)):w?(this.resizingItems.pop(),this.removeTargetSize(i,g),g=this.resizingItems[this.resizingItems.length-1]):g=null:g=null}return p.forEach((C,f)=>{const S=s[this.initialSizesProperty].get(f)??c.get(f);C===S?this.resetSize(s,f):this.setSize(s,f,C)}),this.updateCursor(i,this.draggingIndex),!0}onUp(e,t){return this.draggingIndex!=null&&(this.draggingIndex=void 0,this.resizingItems=[],this.hiddenItems=[],this.targetSizes.clear(),this.updateSeparator(t,null)),!1}onDoubleClick(e,t){const{metrics:n,metricCalculator:s}=t,{model:i}=t.props,o=t.getTheme();if(!n)throw new Error("metrics not set");const a=this.getSeparator(e,n,i,o);if(a!=null){const r=n[this.modelIndexesProperty],c=_(r,a.index),h=_(n[this.calculatedSizesProperty],c),u=s[this.initialSizesProperty].get(c);return h===u?this.resetSize(s,c):this.setSize(s,c,h),t.forceUpdate(),!0}return!1}updateCursor(e,t){const n=e[this.visibleSizesProperty];_(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,a=_(n,t);let r=s.get(a);(r==null||r===0)&&(r=_(i,a)+o),this.targetSizes.set(a,r)}removeTargetSize(e,t){const n=e[this.modelIndexesProperty],s=_(n,t);this.targetSizes.delete(s)}}class Cr extends Yu{static getColumnSeparator(e,t,n,s){if(!s.allowColumnResize)return null;const{x:i,y:o,columnHeaderDepth:a}=e,{modelColumns:r}=t,c=B.getColumnSeparatorIndex(i,o,t,s);return c==null||a==null||a>0?null:r.get(c)!=null?{index:c,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=B.getHiddenColumns;getNextShownItem=B.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=Cr.getColumnSeparator}class Pt{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 a=s,r=Math.min(t.length-1,i),c=t;for(;r>=a;){const h=Math.ceil((r+a)/2),u=Pt.truncate(t,h);if(e.measureText(u).width<=n){if(c=u,a===h)break;a=h}else if(h===0){c=u;break}else r=h-1}return c}static truncateToWidth(e,t,n,s=Pt.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),a=Math.min(Math.ceil(n/s*2),t.length);return Pt.binaryTruncateToWidth(e,t,n,o,a,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:a}=n;e.translate(o,a),this.drawGridBackground(e,t,s==null&&i==null),this.drawCellContents(e,t),this.drawFloatingRows(e,t),this.drawFloatingColumns(e,t),e.translate(-o,-a)}drawFloatingRows(e,t){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=t,{floatingTopRowCount:a,floatingBottomRowCount:r,floatingRows:c,rowCount:h,visibleColumns:u,allRowYs:m,allRowHeights:p}=i;if(c.length!==0){o.floatingRowBackgroundColors&&this.drawRowStripesForRows(e,t,c,o.floatingRowBackgroundColors),n==null&&s==null&&this.drawFloatingMouseRowHover(e,t),this.drawGridLinesForItems(e,t,u,c,o.floatingGridColumnColor,o.floatingGridRowColor),this.drawCellBackgroundsForItems(e,t,u,c),this.drawFloatingBorders(e,t),a>0&&this.drawSelectedRanges(e,t,{top:0,bottom:a-1,maxY:_(m,a-1)+_(p,a-1)-.5}),r>0&&this.drawSelectedRanges(e,t,{top:h-r-1,bottom:h-1,minY:_(m,h-r)+.5,maxY:_(m,h-1)+_(p,h-1)-.5});for(let g=0;g<u.length;g+=1){const C=u[g];for(let f=0;f<c.length;f+=1){const S=c[f];this.drawCellContent(e,t,C,S)}}}}drawFloatingColumns(e,t){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=t,{floatingLeftColumnCount:a,floatingRightColumnCount:r,floatingLeftWidth:c,floatingRightWidth:h,floatingColumns:u,gridX:m,maxX:p,columnCount:g,visibleRows:C,allColumnXs:f,allColumnWidths:S,width:v,height:w}=i;if(u.length!==0){o.floatingRowBackgroundColors&&(this.drawRowStripesForRows(e,t,C,o.floatingRowBackgroundColors,0,c),this.drawRowStripesForRows(e,t,C,o.floatingRowBackgroundColors,v-m-h,p)),n==null&&s==null&&this.drawFloatingMouseRowHover(e,t),e.save(),e.beginPath(),e.rect(0,0,c,w),e.clip(),this.drawGridLinesForItems(e,t,u,C,o.floatingGridColumnColor,o.floatingGridRowColor),e.restore(),this.drawCellBackgroundsForItems(e,t,u,C),this.drawFloatingBorders(e,t),a>0&&this.drawSelectedRanges(e,t,{left:0,maxX:_(f,a-1)+_(S,a-1)}),r>0&&this.drawSelectedRanges(e,t,{left:g-r,right:g-1,minX:_(f,g-r)+.5,maxX:_(f,g-1)+_(S,g-1)});for(let T=0;T<u.length;T+=1){const y=u[T];for(let E=0;E<C.length;E+=1){const I=C[E];this.drawCellContent(e,t,y,I)}}}}drawFloatingBorders(e,t){const{metrics:n,theme:s}=t,{floatingTopRowCount:i,floatingBottomRowCount:o,floatingLeftColumnCount:a,floatingRightColumnCount:r,rowCount:c,columnCount:h,allRowYs:u,allColumnXs:m,allRowHeights:p,allColumnWidths:g,maxX:C,maxY:f}=n,{floatingDividerOuterColor:S,floatingDividerInnerColor:v}=s;if(e.lineWidth=3,e.beginPath(),e.strokeStyle=S,i>0){const w=_(u,i-1)+_(p,i-1)+.5;e.moveTo(0,w),e.lineTo(C,w)}if(o>0){const w=_(u,c-o)-.5;e.moveTo(0,w),e.lineTo(C,w)}if(a>0){const w=_(m,a-1)+_(g,a-1)+.5;e.moveTo(w,0),e.lineTo(w,f)}if(r>0){const w=_(m,h-r)-.5;e.moveTo(w,0),e.lineTo(w,f)}if(e.stroke(),e.beginPath(),e.lineWidth=1,e.strokeStyle=v,i>0){const w=_(u,i-1)+_(p,i-1)+.5;e.moveTo(0,w),e.lineTo(C,w)}if(o>0){const w=_(u,c-o)-.5;e.moveTo(0,w),e.lineTo(C,w)}if(a>0){const w=_(m,a-1)+_(g,a-1)+.5;e.moveTo(w,0),e.lineTo(w,f)}if(r>0){const w=_(m,h-r)-.5;e.moveTo(w,0),e.lineTo(w,f)}e.stroke()}drawGridBackground(e,t,n=!1){this.drawRowStripes(e,t),n&&(this.drawMouseColumnHover(e,t),this.drawMouseRowHover(e,t)),this.drawGridLines(e,t),this.drawCellBackgrounds(e,t);const{metrics:s}=t,{bottom:i,right:o,floatingBottomRowCount:a,floatingLeftColumnCount:r,floatingRightColumnCount:c,floatingTopRowCount:h,columnCount:u,rowCount:m,allRowHeights:p,allRowYs:g,allColumnXs:C,allColumnWidths:f,width:S,height:v}=s;this.drawSelectedRanges(e,t,{bottom:Math.min(i,m-a-1),right:Math.min(o,u-c-1),minX:r>0&&C.has(r+1)?_(C,r+1):-10,minY:h>0&&g.has(h+1)?_(g,h+1):-10,maxX:c>0&&C.has(u-c-1)?_(C,u-c-1)+_(f,u-c-1)-.5:S+10,maxY:a>0&&g.has(m-a-1)?_(g,m-a-1)+_(p,m-a-1)-.5:v+10})}drawRowStripes(e,t){const{metrics:n,theme:s}=t,{visibleRows:i}=n,{rowBackgroundColors:o}=s;o&&this.drawRowStripesForRows(e,t,i,o)}drawRowStripesForRows(e,t,n,s,i=0,o=t.metrics.maxX){const{theme:a,metrics:r,model:c}=t,{maxDepth:h,shadowBlur:u,shadowColor:m}=a,p=this.getCachedBackgroundColors(s,h),{allRowYs:g,allRowHeights:C}=r,f=new Map,S=[],v=[],w=(T,y)=>{const E=ze(c)?c.depthForRow(T):0,I=p[T%p.length],F=I[Math.min(E,I.length-1)];if(f.has(F)||f.set(F,[]),f.get(F).push(T),y!=null){const N=ze(c)?c.depthForRow(y):0;N<E?S.push(T):N>E&&v.push(y)}};for(let T=0;T<n.length;T+=1){const y=n[T],E=T>0?n[T-1]:void 0;w(y,E)}if(f.forEach((T,y)=>{e.fillStyle=y,e.beginPath();for(let E=0;E<T.length;E+=1){const I=T[E],F=_(g,I),N=_(C,I);e.rect(i,F,o,N)}e.fill()}),S.length>0){e.save();const T=this.getCachedColorWithAlpha(m,.15),y=this.getCachedColorWithAlpha(m,0),E=e.createLinearGradient(0,0,0,u);E.addColorStop(0,T),E.addColorStop(1,y),e.fillStyle=E;for(let I=0;I<S.length;I+=1){const F=S[I],N=_(g,F);e.translate(0,N),e.fillRect(i,0,o,u),e.translate(0,-N)}e.restore()}if(v.length>0){e.save();const T=this.getCachedColorWithAlpha(m,0),y=this.getCachedColorWithAlpha(m,.15),E=e.createLinearGradient(0,0,0,u);E.addColorStop(0,T),E.addColorStop(1,y),e.fillStyle=E;for(let I=0;I<v.length;I+=1){const F=v[I],N=_(g,F),H=_(C,F),P=N+H-u;e.translate(0,P),e.fillRect(i,0,o,u),e.translate(0,-P)}e.restore()}}drawMouseColumnHover(e,t){const{mouseX:n,mouseY:s,theme:i,metrics:o}=t;if(n==null||s==null)return;const a=B.getColumnAtX(n,o);if(a==null||i.columnHoverBackgroundColor==null)return;const{allColumnWidths:r,allColumnXs:c,maxY:h}=o;if(s>h)return;const u=_(c,a),m=_(r,a);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:a}=o;if(n>a||i.rowHoverBackgroundColor==null)return;const r=B.getRowAtY(s,o);r!=null&&this.drawMouseRowHoverForRow(e,t,r)}drawFloatingMouseRowHover(e,t){const{mouseX:n,mouseY:s,theme:i,metrics:o}=t,{maxX:a,floatingTopRowCount:r,floatingBottomRowCount:c,rowCount:h,rowFooterWidth:u}=o;if(n==null||s==null||n>a+u||i.rowHoverBackgroundColor==null)return;const m=B.getRowAtY(s,o);m!=null&&(m<r||h-c<=m)&&this.drawMouseRowHoverForRow(e,t,m)}drawMouseRowHoverForRow(e,t,n){const{metrics:s,selectedRanges:i,theme:o}=t,{allRowHeights:a,allRowYs:r,maxX:c}=s,h=_(r,n),u=_(a,n);o.rowHoverBackgroundColor!=null&&(e.fillStyle=o.rowHoverBackgroundColor);for(let m=0;m<i.length;m+=1){const{startRow:p,endRow:g}=i[m];if(p!=null&&g!=null&&p<=n&&g>=n){o.selectedRowHoverBackgroundColor!=null&&(e.fillStyle=o.selectedRowHoverBackgroundColor);break}}e.fillRect(0,h,c,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 a=0;a<n.length;a+=1){const r=n[a],c=_(i,r)+.5;e.moveTo(c,0),e.lineTo(c,o)}}drawGridLinesForRows(e,t,n){const{metrics:s}=t,{allRowYs:i,maxX:o}=s,a=o;for(let r=0;r<n.length;r+=1){const c=n[r],h=_(i,c)+.5;e.moveTo(.5,h),e.lineTo(a-.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 a=0;a<s.length;a+=1){const r=s[a],c=a+1<s.length?s[a+1]:void 0;this.drawCellBackground(e,t,o,r,c)}}e.restore()}drawCellBackground(e,t,n,s,i){const{metrics:o,model:a,theme:r}=t,{firstColumn:c,modelColumns:h,modelRows:u,allColumnXs:m,allColumnWidths:p,allRowYs:g,allRowHeights:C}=o,f=_(u,s),S=_(h,n),v=a.backgroundColorForCell(S,f,r),w=n===c,T=ze(a)&&a.hasExpandableRows;if(v!=null){const y=_(m,n)+1,E=_(g,s)+1,I=_(p,n)-1,F=_(C,s)-1;e.fillStyle=v,e.fillRect(y,E,I,F)}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:a,height:r}=s,c=_(i,n),h=_(o,n);e.save(),e.beginPath(),e.rect(c,0,h,r),e.clip();for(let u=0;u<a.length;u+=1){const m=a[u];this.drawCellContent(e,t,n,m)}e.restore()}getTextRenderMetrics(e,t,n){const{metrics:s,model:i,theme:o}=e,{firstColumn:a,allColumnXs:r,allColumnWidths:c,allRowYs:h,allRowHeights:u,modelRows:m,modelColumns:p}=s,{cellHorizontalPadding:g,treeDepthIndent:C,treeHorizontalPadding:f}=o,S=_(m,n),v=_(p,t),w=i.textAlignForCell(v,S),T=_(r,t),y=_(h,n),E=_(c,t),I=_(u,n),F=t===a;let N=0;ze(i)&&i.hasExpandableRows&&F&&(N=C*(i.depthForRow(n)+1)+f);const H=E-N;let P=T+g;const O=y+I*.5;return w==="right"?P=T+H-g:w==="center"&&(P=T+H*.5),P+=N,{width:H-g*2,x:P,y:O}}drawCellContent(e,t,n,s,i){const{metrics:o,model:a,theme:r}=t,{firstColumn:c,fontWidths:h,modelColumns:u,modelRows:m,allRowHeights:p}=o,{textColor:g}=r,C=_(p,s),f=_(m,s),S=_(u,n),v=i??a.textForCell(S,f),w=a.truncationCharForCell(S,f),T=n===c;if(v&&C>0){const y=a.textAlignForCell(S,f)||"left";e.textAlign=y;const E=a.colorForCell(S,f,r)||g;e.fillStyle=E,e.save();const{width:I,x:F,y:N}=this.getTextRenderMetrics(t,n,s),H=h.get(e.font)??Pt.DEFAULT_FONT_WIDTH,P=this.getCachedTruncatedString(e,v,I,H,w),O=a.tokensForCell(S,f,P.length);if(P){let k=0,L=0,A=F;const{actualBoundingBoxDescent:U}=e.measureText(P);for(;L<P.length;){const j=O[k],W=L===j?.start?j:null,ie=W?.end??j?.start??P.length,se=P.substring(L,ie),{width:G}=e.measureText(se),K=se.endsWith("…")?e.measureText(se.substring(0,se.length-1)).width:G;W!=null?(e.fillStyle=r.hyperlinkColor,e.fillText(se,A,N),e.fillRect(A,N+U,K,1)):(e.fillStyle=E,e.fillText(se,A,N)),A+=G,L=ie,W!=null&&(k+=1)}}e.restore()}T&&ze(a)&&a.hasExpandableRows&&this.drawCellRowTreeMarker(e,t,s)}drawCellRowTreeMarker(e,t,n){const{metrics:s,model:i,mouseX:o,mouseY:a,theme:r}=t,{firstColumn:c,gridX:h,gridY:u,allColumnXs:m,allColumnWidths:p,allRowYs:g,allRowHeights:C,visibleRowTreeBoxes:f}=s,{treeMarkerColor:S,treeMarkerHoverColor:v}=r,w=_(m,c),T=_(p,c),y=_(g,n),E=_(C,n);if(!ze(i)||!i.isRowExpandable(n))return;const I=_(f,n),F=o!=null&&a!=null&&o>=h+w&&o<=h+w+T&&a>=u+y&&a<=u+y+E?v:S;this.drawTreeMarker(e,t,w,y,I,F,i.isRowExpanded(n))}drawTreeMarker(e,t,n,s,i,o,a){const{x1:r,y1:c,x2:h,y2:u}=i,m=a?"⊟":"⊞",p=n+(r+h)*.5+.5,g=s+(c+u)*.5+.5;e.fillStyle=o,e.textAlign="center",e.fillText(m,p,g)}drawCellRowTreeDepthLines(e,t,n,s){const{metrics:i,model:o,theme:a}=t;if(!ze(o))return;const r=o.depthForRow(n);if(r===0)return;const{firstColumn:c,allColumnXs:h,allRowYs:u,allRowHeights:m}=i,{treeDepthIndent:p,treeHorizontalPadding:g,treeLineColor:C}=a,f=_(h,c),S=_(u,n),v=_(m,n),w=s!==void 0?o.depthForRow(s):0,T=r>w?r-w:0;if(e.strokeStyle=C,e.lineWidth=1,r-T>0){e.beginPath();for(let y=0;y<r-T;y+=1){const E=f+y*p+p*.5+g+.5;e.moveTo(E,S),e.lineTo(E,S+v)}e.stroke()}if(T>0){e.beginPath();for(let y=r-T;y<r;y+=1){const E=f+y*p+p*.5+g+.5;e.moveTo(E,S),e.lineTo(E,S+Math.ceil(v/2)),e.moveTo(E-.5,S+Math.ceil(v/2)+.5),e.lineTo(E+p-.5,S+Math.ceil(v/2)+.5)}e.stroke()}}getCachedTruncatedString=qn((e,t,n,s,i)=>Pt.truncateToWidth(e,t,n,s,i),{max:1e4});getCachedBackgroundColors=qn((e,t)=>e.split(" ").map(n=>{const s=[];for(let i=0;i<t;i+=1)s.push(Mc.darkenForDepth(n,i,t));return s}),{max:1e3});getCachedColorWithAlpha=qn((e,t)=>Mc.colorWithAlpha(e,t),{max:1e3});getCachedColorIsDark=qn(e=>sr.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:a,isDragging:r,model:c}=t,{columnHeaderHeight:h,floatingColumns:u,gridX:m,width:p,visibleColumns:g,allColumnWidths:C,allColumnXs:f,floatingLeftColumnCount:S,floatingLeftWidth:v,floatingRightWidth:w,modelColumns:T,columnHeaderMaxDepth:y}=o;if(h<=0)return;const{headerHiddenSeparatorSize:E,headerHiddenSeparatorHoverColor:I,headerSeparatorColor:F,headerSeparatorHoverColor:N}=i,H=h*.5,P=h*(y-1)+h*.5-H*.5,O=S>0;if(e.save(),this.drawColumnHeadersForRange(e,t,[g[0],g[g.length-1]],{minX:m+v,maxX:p-w}),O&&this.drawColumnHeadersForRange(e,t,[u[0],u[u.length-1]],{minX:m,maxX:m+v}),F){e.strokeStyle=F;const k=[...C.entries()].filter(([L,A])=>A===0).map(([L])=>L);e.beginPath(),e.fillStyle=F;for(let L=0;L<k.length;L+=1){const A=k[L],U=_(f,A),j=_(C,A),W=m+U+j+.5-E*.5;e.rect(W,P,E,H)}e.fill()}if(N){let{index:k,depth:L}=a??{};if(k==null&&n!=null&&s!=null){const U=Cr.getColumnSeparator(B.getGridPointFromXY(n,s,o),o,c,i);k=U?.index,L=U?.depth}let A;if(k==null)A=!1;else{const U=T.get(k),j=T.get(k+1);U==null||j==null?A=!1:A=c.textForColumnHeader(U,L)!==c.textForColumnHeader(j,L)}if(A&&k!=null&&L!=null&&(!r||a!=null)){e.strokeStyle=N;const U=_(f,k),j=_(C,k),W=m+U+j+.5,ie=g.indexOf(k),se=ie<g.length-1?g[ie+1]:null,G=se!=null?C.get(se):null,K=j===0,te=G!=null&&G===0;K?(e.strokeStyle=I,e.fillStyle=I,e.fillRect(W,P,E*.5,H)):te&&(e.fillStyle=N,e.fillRect(W-E*.5,P,E*.5,H)),e.beginPath(),e.moveTo(W,(y-L-1)*h),e.lineTo(W,(y-L)*h-1),e.stroke()}}e.restore()}drawColumnHeadersForRange(e,t,n,s){const{model:i}=t,{columnHeaderMaxDepth:o}=i;if(o!==0)for(let a=0;a<=o;a+=1)this.drawColumnHeadersAtDepth(e,t,n,s,a)}drawColumnHeadersAtDepth(e,t,n,s,i){const{metrics:o,model:a,theme:r}=t,{modelColumns:c,allColumnXs:h,gridX:u,userColumnWidths:m,allColumnWidths:p,movedColumns:g}=o,{columnHeaderHeight:C,columnWidth:f}=r,{columnHeaderMaxDepth:S}=a,{minX:v,maxX:w}=s,T=w-v;if(S===0)return;const y=n[0],E=n[1];if(e.save(),e.translate(0,(S-i-1)*C),i===0){this.drawColumnHeader(e,t,"",v,w);for(let I=y;I<=E;I+=1)this.drawColumnHeaderAtIndex(e,t,I,s)}if(i>0){let I=y;for(;I<=E;){const{columnCount:F}=o,N=_(c,I),H=a.textForColumnHeader(N,i),P=a.colorForColumnHeader(N,i);let O=_(h,I)+u,k=O+_(p,I);if(H!=null){let L=I-1;for(;L>=0&&(k-O<T||O>v);){const W=c.get(L)??B.getModelIndex(L,g);if(W==null||a.textForColumnHeader(W,i)!==H)break;const ie=m.get(W)??p.get(L)??f;O-=ie,L-=1}let A=I+1;for(;A<F&&(k-O<T||k<w);){const W=c.get(A)??B.getModelIndex(A,g);if(a.textForColumnHeader(W,i)!==H)break;const ie=m.get(W)??p.get(A)??f;k+=ie,A+=1}I=A-1;const U=k-O>=T;let j=O;U&&(k<w?j=k-T:O<v&&(j=v)),this.drawColumnHeader(e,t,H,j,Math.min(k-O,T),{backgroundColor:P??void 0},s)}I+=1}}e.restore()}drawColumnHeaderAtIndex(e,t,n,s){const{metrics:i,model:o}=t,{modelColumns:a,allColumnWidths:r,allColumnXs:c,gridX:h}=i,u=_(r,n),m=_(c,n)+h,p=_(a,n),g=o.textForColumnHeader(p);g!=null&&this.drawColumnHeader(e,t,g,m,u,{backgroundColor:o.colorForColumnHeader(p)??void 0},s)}drawColumnHeader(e,t,n,s,i,o,a){if(i<=0)return;const{metrics:r,theme:c}=t,{headerHorizontalPadding:h,columnHeaderHeight:u,headerBackgroundColor:m,headerColor:p,headerSeparatorColor:g,black:C,white:f}=c,{fontWidths:S,width:v}=r,w=S.get(e.font)??Pt.DEFAULT_FONT_WIDTH,y=(i-h*2)/w,{backgroundColor:E=m,separatorColor:I=g}=o??{};let{textColor:F=p}=o??{};try{const K=this.getCachedColorIsDark(E),te=this.getCachedColorIsDark(F);K&&te?F=f:!K&&!te&&(F=C)}catch{}let{minX:N=0,maxX:H=v}=a??{};e.save(),e.rect(N,0,H-N,u),e.clip(),E!=null&&(e.fillStyle=E,e.fillRect(s,0,i,u)),I!=null&&(e.strokeStyle=I,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=F;let P=n;y<=0?P="":P.length>y&&(P=`${P.substring(0,y-1)}…`);const O=P.length*w;let k=s+i*.5;const L=u*.5;N+=h,H-=h;const A=s+h,U=je(A,N,H),j=s+i-h,ie=je(j,N,H)-U,se=k-O*.5<N,G=k+O*.5>H;se?O<ie?k=N+O*.5:k=j-O*.5:G&&(O<ie?k=H-O*.5:k=A+O*.5),e.textAlign="center",e.fillText(P,k,L),e.restore()}drawRowHeaders(e,t){const{mouseX:n,mouseY:s,metrics:i,theme:o,draggingRowSeparator:a}=t,{gridY:r,rowHeaderWidth:c,height:h,visibleRows:u,allRowHeights:m,allRowYs:p}=i;if(c<=0)return;const{headerBackgroundColor:g,headerColor:C,headerHiddenSeparatorSize:f,headerHiddenSeparatorHoverColor:S,headerSeparatorColor:v,headerSeparatorHoverColor:w}=o,T=c*.5,y=c*.5-T*.5;if(e.save(),e.beginPath(),e.fillStyle=g,e.fillRect(0,0,c,h),v){e.strokeStyle=v,e.beginPath(),e.moveTo(0,r+.5),e.lineTo(c,r+.5);const E=[];let I=!1;for(let F=0;F<u.length;F+=1){const N=u[F],H=_(p,N),P=_(m,N);if(P>0){const O=r+H+P+.5;e.moveTo(0,O),e.lineTo(c,O),I=!1}else I||(I=!0,E.push(N))}e.moveTo(c-.5,0),e.lineTo(c-.5,h),e.stroke(),e.beginPath(),e.fillStyle=v;for(let F=0;F<E.length;F+=1){const N=E[F],H=_(p,N),P=_(m,N),O=r+H+P+.5-f*.5;e.rect(y,O,T,f)}e.fill()}if(w){let{index:E=null}=a??{};if(E==null&&n!=null&&s!=null&&(E=B.getRowSeparatorIndex(n,s,i,o)),E!=null){e.strokeStyle=w;const I=_(p,E),F=_(m,E),N=r+I+F+.5,H=u.indexOf(E),P=H<u.length-1?u[H+1]:null,O=P!=null?m.get(P):null,k=F===0,L=O!=null&&O===0;k?(e.strokeStyle=S,e.fillStyle=S,e.fillRect(y,N,T,f*.5)):L&&(e.fillStyle=w,e.fillRect(y,N-f*.5,T,f*.5)),e.beginPath(),e.moveTo(.5,N),e.lineTo(c+.5,N),e.stroke()}}e.beginPath(),e.rect(0,r,c,h),e.clip(),e.fillStyle=C,e.textAlign="right";for(let E=0;E<u.length;E+=1){const I=u[E],F=_(m,I),N=_(p,I)+r;this.drawRowHeader(e,t,I,N,F)}e.restore()}drawRowHeader(e,t,n,s,i){if(i<=0)return;const{metrics:o,model:a,theme:r}=t,{modelRows:c,rowHeaderWidth:h}=o,u=_(c,n),m=h-r.cellHorizontalPadding,p=s+i*.5;e.fillText(a.textForRowHeader(u),m,p)}drawRowFooters(e,t){const{mouseX:n,mouseY:s,metrics:i,model:o,theme:a,draggingRowSeparator:r}=t,{gridY:c,gridX:h,maxX:u,modelRows:m,rowFooterWidth:p,height:g,verticalBarWidth:C,visibleRows:f,allRowHeights:S,allRowYs:v,width:w}=i;if(p<=0)return;const{cellHorizontalPadding:T,headerBackgroundColor:y,headerColor:E,headerHiddenSeparatorSize:I,headerHiddenSeparatorHoverColor:F,headerSeparatorColor:N,headerSeparatorHoverColor:H}=a,P=p*.5,O=p*.5-P*.5,k=Math.min(h+u,w-p-C);if(e.save(),e.beginPath(),e.fillStyle=y,e.fillRect(k,c,p,g),N){e.strokeStyle=N,e.beginPath(),e.moveTo(k,c+.5),e.lineTo(p,c+.5);const A=[];let U=!1;for(let j=0;j<f.length;j+=1){const W=f[j],ie=_(v,W),se=_(S,W);if(se>0){const G=c+ie+se+.5;e.moveTo(k+.5,G),e.lineTo(k+p-.5,G),U=!1}else U||(U=!0,A.push(W))}e.moveTo(k+.5,c),e.lineTo(k+.5,g),e.stroke(),e.beginPath(),e.fillStyle=N;for(let j=0;j<A.length;j+=1){const W=A[j],ie=_(v,W),se=_(S,W),G=c+ie+se+.5-I*.5;e.rect(k+O,G,P,I)}e.fill()}if(H){let{index:A=null}=r??{};if(A==null&&n!=null&&s!=null&&(A=B.getRowSeparatorIndex(n,s,i,a)),A!=null){e.strokeStyle=H;const U=_(v,A),j=_(S,A),W=c+U+j+.5,ie=f.indexOf(A),se=ie<f.length-1?f[ie+1]:null,G=se!=null?S.get(se):null,K=j===0,te=G!=null&&G===0;K?(e.strokeStyle=F,e.fillStyle=F,e.fillRect(O,W,P,I*.5)):te&&(e.fillStyle=H,e.fillRect(O,W-I*.5,P,I*.5)),e.beginPath(),e.moveTo(k+.5,W),e.lineTo(k+p+.5,W),e.stroke()}}e.beginPath(),e.rect(k,c,p,g),e.clip(),e.fillStyle=E,e.textAlign="left";const L=k+T;for(let A=0;A<f.length;A+=1){const U=f[A],j=_(S,U);if(j>0){const W=_(v,U)+c,ie=_(m,U),se=W+j*.5;e.fillText(o.textForRowFooter(ie),L,se)}}e.restore()}drawSelectedRanges(e,t,n={}){const{cursorColumn:s,cursorRow:i,draggingRow:o,draggingColumn:a,editingCell:r,metrics:c,model:h,selectedRanges:u,theme:m}=t,{allColumnWidths:p,allColumnXs:g,allRowHeights:C,allRowYs:f,width:S,height:v}=c,{left:w=c.left,top:T=c.top,right:y=c.right,bottom:E=c.bottom,minY:I=-10,maxY:F=v+10,minX:N=-10,maxX:H=S+10}=n;if(u.length===0)return;const P=Ze(h)&&h.isEditable&&r==null&&o==null&&a==null&&s!=null&&i!=null&&g.has(s)&&f.has(i);if(P){const O=_(g,s),k=_(f,i),L=_(p,s),A=_(C,i);e.save(),e.beginPath(),e.rect(0,0,S,v),e.rect(O,k,L,A),e.clip("evenodd")}e.beginPath();for(let O=0;O<u.length;O+=1){const k=u[O],L=k.startColumn!==null?k.startColumn:w,A=k.startRow!==null?k.startRow:T,U=k.endColumn!==null?k.endColumn:y,j=k.endRow!==null?k.endRow:E;if(j>=T&&E>=A&&U>=w&&y>=L){const W=L>=w&&g.has(L)?Math.round(_(g,L))+.5:N,ie=A>=T&&f.has(A)?Math.max(Math.round(_(f,A))+.5,.5):I,se=U<=y&&g.has(U)?Math.round(_(g,U)+_(p,U))-.5:H,G=j<=E&&f.has(j)?Math.round(_(f,j)+_(C,j))-.5:F;e.rect(W,ie,se-W,G-ie)}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()}P&&s!=null&&i!=null&&(e.restore(),this.drawActiveCell(e,t,s,i))}drawActiveCell(e,t,n,s,i=Pt.ACTIVE_CELL_BORDER_WIDTH){const{metrics:o,theme:a}=t,{allColumnWidths:r,allColumnXs:c,allRowHeights:h,allRowYs:u}=o,m=_(c,n),p=_(u,s),g=_(r,n),C=_(h,s);let f=m-i*.5,S=p-i*.5,v=g+i,w=C+i;f<=0&&(v+=f-1,f=1),S<=0&&(w+=S-1,S=1);const{lineWidth:T}=e;e.beginPath(),e.lineWidth=i,e.strokeStyle=a.selectionOutlineColor,this.drawRoundedRect(e,f,S,v,w),e.stroke(),e.lineWidth=T}drawRoundedRect(e,t,n,s,i,o=Pt.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:a}=t;if(n==null||i==null)return;const{range:r,depth:c}=n,{gridX:h,gridY:u,allColumnXs:m,allColumnWidths:p,height:g,width:C,columnHeaderMaxDepth:f,columnHeaderHeight:S,movedColumns:v,modelColumns:w,floatingLeftWidth:T}=s,y=w.get(r[0])??B.getModelIndex(r[0],v),E=a.getColumnHeaderGroup(y,c);if(c>0&&!E)return;const[I,F]=r,N=_(m,I),P=_(m,F)+_(p,F)-N,O=n.left,{backgroundColor:k,font:L,headerFont:A,reorderOffset:U,shadowBlur:j,shadowColor:W}=o,ie=(f-c-1)*S;e.save(),e.translate(h,0),e.save(),e.beginPath(),e.rect(T,0,C,g),e.clip(),e.fillStyle=k,e.fillRect(N,ie,P,g),e.restore(),e.translate(0,U),e.save(),e.shadowColor=W,e.shadowBlur=j,e.fillStyle=k,e.fillRect(n.left,ie+U,n.width,g),e.restore(),e.beginPath(),e.rect(n.left,ie,n.width+1,g),e.clip(),e.translate(O-N,0),e.font=A;const se=[];for(let G=n.range[0];G<=n.range[1];G+=1)se.push(G);this.drawColumnHeaders(e,t),this.drawColumnHeadersForRange(e,t,[se[0],se[se.length-1]],{minX:N,maxX:C}),e.translate(0,u),e.font=L,this.drawGridBackground(e,t);for(let G=I;G<=F;G+=1)this.drawColumnCellContents(e,t,G);e.restore()}drawDraggingRow(e,t){const{draggingRow:n,draggingRowOffset:s,metrics:i,mouseY:o,theme:a}=t;if(n==null||o==null)return;const{gridX:r,gridY:c,allRowYs:h,allRowHeights:u,width:m}=i,p=_(h,n),g=_(u,n)+1,{backgroundColor:C,font:f,headerFont:S,reorderOffset:v,shadowBlur:w,shadowColor:T}=a;e.save(),e.translate(0,c),e.fillStyle=C,e.fillRect(0,p,m,g),e.translate(r+v,o-p-c-(s??0)),e.save(),e.shadowColor=T,e.shadowBlur=w,e.fillStyle=C,e.fillRect(-r,p,m,g),e.restore(),e.beginPath(),e.rect(-r,p,m,g),e.clip(),e.font=f,this.drawGridBackground(e,t),this.drawCellContents(e,t),e.translate(-r,-c),e.font=S,this.drawRowHeaders(e,t),e.restore()}drawScrollBars(e,t){const{isDraggingHorizontalScrollBar:n,isDraggingVerticalScrollBar:s,isDragging:i,metrics:o,mouseX:a,mouseY:r,theme:c}=t;if(c.scrollBarSize<=0)return;const{width:h,height:u,handleHeight:m,handleWidth:p,scrollX:g,scrollY:C,hasHorizontalBar:f,hasVerticalBar:S,barWidth:v,barHeight:w,barLeft:T,barTop:y}=o,{scrollBarBackgroundColor:E,scrollBarHoverBackgroundColor:I,scrollBarCasingColor:F,scrollBarCornerColor:N,scrollBarColor:H,scrollBarHoverColor:P,scrollBarActiveColor:O,scrollBarSize:k,scrollBarHoverSize:L,scrollBarCasingWidth:A,scrollBarSelectionTick:U,scrollBarSelectionTickColor:j,scrollBarActiveSelectionTickColor:W,autoSelectRow:ie,autoSelectColumn:se}=c,G=a!=null&&r!=null&&a<=h&&r<=u,K=s||S&&!n&&!i&&a!=null&&r!=null&&a>=h-L&&r>=y&&G,te=n||f&&!s&&!i&&!K&&a!=null&&r!=null&&r>=u-L&&a>=T&&G,oe=te?L:k,de=K?L:k;if(e.translate(T,y),f&&S&&(e.fillStyle=F,e.fillRect(h-T-k,u-y-k,k,k),e.fillStyle=N,e.fillRect(h-T-k+A,u-y-k+A,k-A,k-A)),f){const ee=g,re=u-y-oe;if(e.fillStyle=F,e.fillRect(0,re,v,oe-A),e.fillStyle=te?I:E,e.fillRect(0,re+A,v,oe-A),n?e.fillStyle=O:te?e.fillStyle=P:e.fillStyle=H,e.fillRect(ee,re+A,p,oe-A),!ie&&U&&j!=null&&W!=null){e.fillStyle=j;const{selectedRanges:we,cursorColumn:xe}=t,{lastLeft:Oe,columnCount:Jt}=o,ss=[...we].filter(ye=>ye.startColumn!=null&&ye.endColumn!=null).map(ye=>[ye.startColumn,ye.endColumn]).sort(B.compareRanges),Tn=B.mergeSortedRanges(ss),kt=ye=>ye<=Oe?ye/Oe*(v-p):v-p+(ye-Oe)/(Jt-Oe)*p;for(let ye=0;ye<Tn.length;ye+=1){const ht=Tn[ye],at=ht[0],St=ht[1];if(at!=null&&St!=null&&(at!==xe||St!==xe)){const Ot=kt(at),En=Math.max(1,Math.round(kt(St+1)-Ot)),en=oe-A;e.fillRect(Ot,re+A+Math.round(en/3),En,Math.round(en/3))}}if(xe!=null){const ye=kt(xe),ht=2,at=oe-A;e.fillStyle=W,e.fillRect(ye,re+A,ht,at)}}}if(S){const ee=h-T-de,re=C;if(e.fillStyle=F,e.fillRect(ee,0,de-A,w),e.fillStyle=K?I:E,e.fillRect(ee+A,0,de-A,w),s?e.fillStyle=O:K?e.fillStyle=P:e.fillStyle=H,e.fillRect(ee+A,re,de-A,m),!se&&U&&j!=null&&W!=null){const{selectedRanges:we,cursorRow:xe}=t,{lastTop:Oe,rowCount:Jt}=o,Mt=ye=>ye<=Oe?ye/Oe*(w-m):w-m+(ye-Oe)/(Jt-Oe)*m;e.fillStyle=j;const Tn=[...we].filter(ye=>ye.startRow!=null&&ye.endRow!=null).map(ye=>[ye.startRow,ye.endRow]).sort(B.compareRanges),kt=B.mergeSortedRanges(Tn);for(let ye=0;ye<kt.length;ye+=1){const ht=kt[ye],at=ht[0],St=ht[1];if(at!=null&&St!=null&&(at!==xe||St!==xe)){const Ot=Mt(at),En=de-A,en=Math.max(1,Math.round(Mt(St+1)-Ot));e.fillRect(ee+A+Math.round(En/3),Ot,Math.round(En/3),en)}}if(xe!=null){const ye=Math.round(Mt(xe)),ht=de-A,at=2;e.fillStyle=W,e.fillRect(ee+A,ye,ht,at)}}}e.translate(-T,-y)}getTokenBoxesForVisibleCell(e,t,n){const{metrics:s,context:i,model:o,theme:a}=n;if(i==null||s==null)return De;const{modelRows:r,modelColumns:c}=s,h=_(r,t),u=_(c,e),m=o.textForCell(u,h),{width:p,x:g,y:C}=this.getTextRenderMetrics(n,e,t),{fontWidths:f}=s;i.save(),this.configureContext(i,n);const S=f?.get(i.font)??Pt.DEFAULT_FONT_WIDTH,v=o.truncationCharForCell(u,h),w=this.getCachedTruncatedString(i,m,p,S,v),{actualBoundingBoxAscent:T,actualBoundingBoxDescent:y}=i.measureText(w),E=T+y,I=o.tokensForCell(u,h,w.length);if(I.length===0)return i.restore(),De;const F=this.getCachedTokenBoxesForVisibleCell(w,I,a.font,"middle",E,i).map(N=>({x1:N.x1+g,y1:N.y1+(C-T),x2:N.x2+g,y2:N.y2+(C-T),token:N.token}));return i.restore(),F}getCachedTokenBoxesForVisibleCell=qn((e,t,n,s,i,o)=>{const r=i,c=[];let h=0,u=0;for(let m=0;m<t.length;m+=1){const p=t[m],{start:g,end:C}=p,f=C>e.length?e.substring(g):p.value;u+=o.measureText(e.substring(h,g)).width;const S=o.measureText(f).width,v=u,w=v+S,T={x1:v,y1:0,x2:w,y2:r,token:p};c.push(T),h=C,u+=S}return c},{max:1e4})}const kc=100;class $w extends dt{startPoint;hasExtendedFloating=!1;timer;lastTriggerTime;dragBounds;onDown(e,t,n){const{x:s,y:i,column:o,row:a}=e,{metrics:r}=t;if(!r)throw new Error("metrics not set");const{gridX:c,gridY:h,maxX:u,maxY:m}=r,p=s-c,g=i-h;if(p<0||g<0||o==null&&p>u||a==null&&g>m)return!1;const C=B.isModifierKeyDown(n),f=n.shiftKey;C||(f?t.trimSelectedRanges():t.clearSelectedRanges());const S=t.getTheme(),{autoSelectRow:v,autoSelectColumn:w}=S;return(o!==null||!w)&&(a!==null||!v)&&(t.focus(),t.moveCursorToPosition(o,a,f,!1,f&&C)),this.startPoint=e,this.hasExtendedFloating=!1,this.dragBounds=B.getScrollDragBounds(r,a,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:a,column:r}=e;const{metrics:c}=t;if(!c)throw new Error("metrics not set");const{left:h,lastLeft:u,top:m,lastTop:p,columnWidth:g,rowHeight:C}=c,f=B.getScrollDragBounds(c,n,s);let S=0,v=0;if(h<u&&(i<f.x1?S=i-f.x1:i>f.x2&&(S=i-f.x2)),m<p&&(o<f.y1?v=o-f.y1:o>f.y2&&(v=o-f.y2)),S!==0||v!==0)this.startTimer(t,e,S>0?Math.ceil(S/g):Math.floor(S/g),v>0?Math.ceil(v/C):Math.floor(v/C));else if(a!=null&&r!=null){const{floatingTopRowCount:w,floatingBottomRowCount:T,floatingLeftColumnCount:y,floatingRightColumnCount:E,columnCount:I,rowCount:F,bottom:N,right:H,topVisible:P,bottomVisible:O,leftVisible:k,rightVisible:L}=c;this.hasExtendedFloating||(n!==null&&n<w&&a>=w?(a=w,this.hasExtendedFloating=!0):n!==null&&n>=F-T&&a<F-T&&(a=F-T-1,this.hasExtendedFloating=!0),s!==null&&s<y&&r>=y?(r=y,this.hasExtendedFloating=!0):s!==null&&s>=I-E&&r<I-E&&(r=I-E-1,this.hasExtendedFloating=!0)),n!==null&&!B.isFloatingRow(n,c)&&B.isFloatingRow(a,c)&&(n>a&&a<m?a=P-1:n<a&&a>N&&(a=O+1)),s!==null&&!B.isFloatingColumn(s,c)&&B.isFloatingColumn(r,c)&&(s>r&&r<h?r=k-1:s<r&&r>H&&(r=L+1)),t.moveCursorToPosition(r,a,!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:a}=e;if(!a)throw new Error("metrics not set");const{selectionEndRow:r,selectionEndColumn:c}=e.state;if(r==null||c==null)throw new Error("selection not set");const{rowCount:h,columnCount:u}=a,m=n<0&&o!=null?o:0,p=n>0&&o!=null?o:u-1,g=s<0&&i!=null?i:0,C=s>0&&i!=null?i:h-1;e.moveCursorToPosition(Math.min(Math.max(m,c+n),p),Math.min(Math.max(g,r+s),C),!0),this.lastTriggerTime=Date.now()}startTimer(e,t,n,s){this.stopTimer();const i=this.lastTriggerTime!=null?kc-Math.min(kc,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 Oc=5,Ww=1e3/60,oa=10;function us(d,e,t,n){const{modelColumns:s,movedColumns:i,allColumnXs:o,columnCount:a,allColumnWidths:r,userColumnWidths:c,calculatedColumnWidths:h,floatingLeftWidth:u,maxX:m}=t;if(e==null||d==null||d>a||d<0)return null;const p=s.get(d)??B.getModelIndex(d,i),g=n.getColumnHeaderGroup(p,e),C=g!=null;let f,S,v;if(g!=null){const[w,T]=g.getVisibleRange(i);f=o.get(w)??u,S=(o.get(T)??m)+(r.get(T)??0),v=[w,T]}else{const w=o.get(d);if(w==null)return null;f=w,S=f+(r.get(d)??c.get(p)??h.get(p)??0),v=[d,d]}return{visibleIndex:d,modelIndex:p,left:f,right:S,width:S-f,isColumnGroup:C,range:v,depth:e}}class Gw extends dt{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:a,calculatedColumnWidths:r,movedColumns:c,allColumnWidths:h}=n;let u=s,m=o;if(t==="left")for(m-=oa;m<0;){u-=1;const C=B.getModelIndex(s-1,c),f=a.get(C)??r.get(C);f===void 0?m=0:m+=f,u<0&&(m=0,u=0)}else{m+=oa;let C=h.get(s);for(;C!==void 0&&m>C;){u+=1,m-=C;const f=B.getModelIndex(s+1,c);C=a.get(f)??r.get(f),u>i&&(m=0,u=i)}}const{mouseX:p,mouseY:g}=e.state;n==null||p==null||g==null||(this.moveDraggingColumn(p,e,t==="left"?-oa:oa),e.setState({left:u,leftOffset:m}),(t==="left"&&u===0&&o===0||t==="right"&&u===i)&&this.clearScrollInterval())},Ww))}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:a}=t;if(!a)throw new Error("Metrics not set");const r=us(i,o,a,n);if(i==null||r==null||o==null||o>0&&!r.isColumnGroup)return!1;const{rowHeaderWidth:c}=a;return this.initialGridPoint=e,this.draggingColumn=null,this.cursor=null,r.modelIndex!=null&&o!=null&&n.isColumnMovable(r.modelIndex,o)&&(this.draggingOffset=s-r.left-c,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:a}=t.props;let{draggingColumn:r}=this;const{metrics:c}=t;if(!c)throw new Error("Metrics not set");if(!r&&Math.abs(this.initialGridPoint.x-s)<Oc&&Math.abs(this.initialGridPoint.y-i)<Oc)return!1;if(r==null){const h=us(this.initialGridPoint.column,o,c,a);if(!h||o==null||!a.isColumnMovable(h.modelIndex)||o>0&&!h.isColumnGroup||h.range[0]==null)return!1;r={range:h.range,depth:o,left:h.left,width:h.width};const u=us(r.range[0],0,c,a),m=us(r.range[1],0,c,a);if(!u||!m)return!1;this.draggingColumn=r,t.setState({draggingColumn:r,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:a}=t;if(!a)throw new Error("Metrics not set");const{floatingLeftWidth:r,width:c,columnHeaderMaxDepth:h,allColumnXs:u}=a,m=n<0,p=us(this.draggingColumn.range[0],s,a,i);if(!p)return;const g=e-this.draggingOffset,C=g+p.width;this.draggingColumn={...this.draggingColumn,left:g},t.setState({draggingColumn:this.draggingColumn});const f=us(B.getColumnAtX(je(m?g:C,r,c),a,!0),s,a,i),S=i.getColumnHeaderParentGroup(p.modelIndex,p.depth);if(!f)return;if(S!==void 0){const I=S.getVisibleRange(o);if(f.visibleIndex<I[0]){const F=this.moveColumn(p,I[0],o);this.draggingOffset=e-(u.get(I[0])??0),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),t.setState({draggingColumn:this.draggingColumn,movedColumns:F});return}if(f.visibleIndex>I[1]){const F=this.moveColumn(p,I[1]-(p.range[1]-p.range[0]),o),{right:N=0}=us(I[1],0,a,i)??{};this.draggingOffset=e-(N-p.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),t.setState({draggingColumn:this.draggingColumn,movedColumns:F});return}}if(!i.isColumnMovable(f.modelIndex)){let I=f.visibleIndex;if(m)for(I+=1;I<p.visibleIndex&&!i.isColumnMovable(B.getModelIndex(I,o));)I+=1;else for(I-=1;I>p.visibleIndex&&!i.isColumnMovable(B.getModelIndex(I,o));)I-=1;if(I!==p.visibleIndex){m||(I-=p.range[1]-p.range[0]);const N=this.moveColumn(p,I,o);t.setState({movedColumns:N,draggingColumn:this.draggingColumn})}const F=us(I,0,a,i);m?this.draggingOffset=e-(F?.left??0):this.draggingOffset=e-((F?.right??0)-p.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},t.setState({draggingColumn:this.draggingColumn});return}if(g<=r?this.setScrollInterval(t,"left"):C>c?this.setScrollInterval(t,"right"):this.clearScrollInterval(),f.visibleIndex===p.visibleIndex||m&&p.visibleIndex<f.visibleIndex||!m&&p.visibleIndex>f.visibleIndex)return;const v=f.left+f.width*.5,w=i.getColumnHeaderParentGroup(p.modelIndex,p.depth);let T,y=(w?.depth??h)-1;for(;y>=0&&T===void 0;)T=i.getColumnHeaderGroup(f.modelIndex,y),y-=1;let E;m&&g<v&&(!T||f.visibleIndex===T.getVisibleRange(o)[0])&&(E=this.moveColumn(p,f.range[0],o)),!m&&C>v&&(!T||f.visibleIndex===T.getVisibleRange(o)[1])&&(E=this.moveColumn(p,f.range[1]-(p.range[1]-p.range[0]),o)),E&&(this.draggingColumn={...this.draggingColumn,left:g},t.setState({movedColumns:E,draggingColumn:this.draggingColumn}))}moveColumn(e,t,n){const s=e.isColumnGroup?B.moveRange(e.range,t,n):B.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}}class td extends dt{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),a=t-o;let r=s.allColumnWidths.get(o);if(r==null){const h=e.getMetricState();r=i.getVisibleColumnWidth(o,h)}const c=r*a;return{left:o,leftOffset:c}}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:a,y:r}=e,{barLeft:c,barWidth:h,height:u,hasHorizontalBar:m}=o;return m&&s>0&&r>=u-i&&r<u&&a>c&&a<c+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:a,barLeft:r,columnCount:c,scrollableContentWidth:h,scrollableViewportWidth:u}=n,m=s-r,p=je((m-(this.dragOffset??0))/(i-o),0,1);if(c===1)return{left:0,leftOffset:p*(h-u)};const g=p*a;return td.getLeftWithOffsetFromRawLeft(t,g)}onDown(e,t){const{metrics:n}=t;if(!n)throw new Error("metrics not set");const{x:s}=e,{handleWidth:i,barLeft:o,scrollX:a}=n;if(!this.isInScrollBar(e,t))return!1;const r=s-o;if(r>=a&&r<=a+i)this.dragOffset=r-a,t.setState({isDraggingHorizontalScrollBar:!0});else{this.dragOffset=0;const{left:c,leftOffset:h}=this.getLeftWithOffset(e,t);t.setViewState({left:c,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)}}class zw extends dt{cursor="move";draggingOffset;onDown(e,t){const{model:n}=t.props,{x:s,y:i,row:o}=e,{metrics:a}=t;if(!a)throw new Error("metrics not set");const{columnHeaderHeight:r,rowHeaderWidth:c,allRowYs:h}=a;if(s<=c&&o!==null&&n.isRowMovable(o)){const u=_(h,o);this.draggingOffset=i-u-r,t.setState({draggingRowOffset:this.draggingOffset})}return!1}onDrag(e,t){if(this.draggingOffset==null)return!1;const{model:n}=t.props;let{draggingRow:s}=t.state;const{mouseX:i,mouseY:o}=t.state;if(i==null||o==null)return!1;if(s==null){const{row:E}=t.getGridPointFromXY(i,o);if(E!=null&&!n.isRowMovable(E)||(s=E,t.setState({draggingRow:s,isDragging:!0}),s==null))return!1}const{metrics:a}=t;if(!a)throw new Error("metrics not set");const{top:r,lastTop:c,bottom:h,bottomVisible:u,rowCount:m,columnHeaderHeight:p,allRowHeights:g,allRowYs:C,height:f}=a;let S=p;if(r<s){const E=s-1;S=_(C,E)+_(g,E)*.5+p}let v=f;if(s<h){const E=s+1;v=_(C,E)+_(g,E)*.5+p}let{movedRows:w}=t.state;o<S&&s>0&&n.isRowMovable(s-1)?(w=B.moveItem(s,s-1,w),s-=1):v<o&&s<m-1&&n.isRowMovable(s+1)&&(w=B.moveItem(s,s+1,w),s+=1),t.setState({movedRows:w,draggingRow:s});const T=p+_(g,r)*.5,y=p+_(C,u)+_(g,u)*.5;return o<T&&r>0?t.setState({top:r-1}):o>y&&r<c&&t.setState({top:r+1}),!0}onUp(e,t){return this.draggingOffset!==void 0?(this.draggingOffset=void 0,t.setState({draggingRowOffset:null,draggingRow:null,isDragging:!1}),!0):!1}}class nd extends Yu{static getRowSeparator(e,t,n,s){if(!s.allowRowResize)return null;const{x:i,y:o}=e,a=B.getRowSeparatorIndex(i,o,t,s);return a!=null?{index:a,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=B.getHiddenRows;getNextShownItem=B.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=nd.getRowSeparator}class Bi extends dt{static isInTreeBox(e,t){const{column:n,row:s,x:i,y:o}=e,{metrics:a}=t;if(!a)throw new Error("metrics not set");const{gridX:r,gridY:c,firstColumn:h,allColumnXs:u,allColumnWidths:m,allRowHeights:p,allRowYs:g,visibleRowTreeBoxes:C}=a;if(n===h&&s!=null&&C.get(s)!=null&&i>r&&o>c){const f=_(u,n),S=_(m,n),v=_(g,s),w=_(p,s);if(i>=r+f&&i<=r+f+S&&o>=c+v&&o<=c+v+w)return!0}return!1}onDown(e,t){return Bi.isInTreeBox(e,t)}onClick(e,t,n){if(Bi.isInTreeBox(e,t)){const{row:s}=e;if(s!==null)return t.toggleRowExpanded(s,B.isModifierKeyDown(n)),!0}return!1}}class Kw extends dt{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:a}=e,{width:r,height:c,hasVerticalBar:h,hasHorizontalBar:u}=i;return s>0&&h&&u&&o>=r-s&&a>=c-s&&o<=r&&a<=c}onDown(e,t){return this.isInCorner(e,t)}onUp(e,t){return this.isInCorner(e,t)}onClick(e,t){return this.isInCorner(e,t)}}class sd extends dt{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),a=t-o;let r=s.allRowHeights.get(o);if(r==null){const h=e.getMetricState();r=i.getVisibleRowHeight(o,h)}const c=r*a;return{top:o,topOffset:c}}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:a,y:r}=e,{barTop:c,barHeight:h,width:u,hasVerticalBar:m}=o;return m&&s>0&&a>=u-i&&a<u&&r>c&&r<c+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:a,barTop:r,rowCount:c,scrollableContentHeight:h,scrollableViewportHeight:u}=n,m=s-r,p=je((m-(this.dragOffset??0))/(i-o),0,1);if(c===1)return{top:0,topOffset:p*(h-u)};const g=p*a;return sd.getTopWithOffsetFromRawTop(t,g)}onDown(e,t){const{metrics:n}=t;if(!n)throw new Error("metrics not set");const{y:s}=e,{handleHeight:i,barTop:o,scrollY:a}=n;if(!this.isInScrollBar(e,t))return!1;const r=s-o;if(r>=a&&r<=a+i)this.dragOffset=r-a,t.setState({isDraggingVerticalScrollBar:!0});else{this.dragOffset=0;const{top:c,topOffset:h}=this.getTopWithOffset(e,t);t.setViewState({top:c,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)}}class qw extends dt{onDoubleClick({column:e,row:t},n){const{model:s}=n.props;return Ze(s)&&e!=null&&t!=null&&s.isEditableRange(z.makeCell(e,t))?(n.startEditing(e,t),!0):!1}}class id extends dt{timeoutId;isHold=!1;isDown=!1;currentLinkBox;static HOLD_LENGTH=1e3;isHoveringLink(e,t){const{column:n,row:s,x:i,y:o}=e,{renderer:a,metrics:r}=t;if(n==null||s==null||r==null)return this.currentLinkBox=void 0,!1;if(this.currentLinkBox!=null){const{x1:u,y1:m,x2:p,y2:g}=this.currentLinkBox;if(i>=u&&i<=p&&o>=m&&o<=g)return!0}const c=t.updateRenderState(),h=a.getTokenBoxesForVisibleCell(n,s,c);for(let u=0;u<h.length;u+=1)if(_a(h[u].token)){const m=B.translateTokenBox(h[u],r),{x1:p,x2:g,y1:C,y2:f}=m;if(i>=p&&i<=g&&o>=C&&o<=f)return this.currentLinkBox=m,!0}return this.currentLinkBox=void 0,!1}setCursor(e,t){return this.isHoveringLink(e,t)?this.cursor="pointer":this.cursor=null,!1}onMove(e,t){return this.setCursor(e,t)}onDown(e,t,n){const s=this.isHoveringLink(e,t);return B.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:a}=t.props;t.clearSelectedRanges(),t.focus(),t.moveCursorToPosition(i,o),Ze(a)&&i!=null&&o!=null&&a.isEditableRange(z.makeCell(i,o))&&t.startEditing(i,o)},id.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)}}class li{order;constructor(e=5e3){this.order=e}onDown(e,t){return!1}}class Yw extends li{onDown(e,t){switch(e.key){case"a":if(B.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 B.isModifierKeyDown(e)?!1:this.handlePageUp(e,t);case"j":case"J":return B.isModifierKeyDown(e)?!1:this.handlePageDown(e,t);case"h":case"H":return B.isModifierKeyDown(e)?!1:(e.shiftKey||t.clearSelectedRanges(),t.moveCursorToPosition(0,t.state.cursorRow,e.shiftKey),!0);case"l":case"L":{if(B.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(B.isModifierKeyDown(e)?t.state.cursorColumn:0,B.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(B.isModifierKeyDown(e)?t.state.cursorColumn:s-1,B.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?z.SELECTION_DIRECTION.UP:z.SELECTION_DIRECTION.DOWN),!0;break;case"Tab":if(t.state.selectedRanges.length>0)return t.moveCursorInDirection(e.shiftKey?z.SELECTION_DIRECTION.LEFT:z.SELECTION_DIRECTION.RIGHT),!0;break}return!1}handleArrowMove(e,t,n,s){const i=n.shiftKey,o=B.isModifierKeyDown(n);i?s.trimSelectedRanges():s.clearSelectedRanges();const{cursorRow:a,cursorColumn:r,selectionEndColumn:c,selectionEndRow:h}=s.state,u=i?c:r,m=i?h:a;if(o){const{model:p}=s.props,{columnCount:g,rowCount:C}=p,f=o&&i;let S=null,v=null;e<0?(S=0,v=m):e>0?(S=g-1,v=m):t<0?(S=u,v=0):t>0&&(S=u,v=C-1),S!=null&&v!=null&&s.moveCursorToPosition(S,v,i,!0,f)}else{if(!s.metrics)throw new Error("grid.metrics are not set");const{theme:p}=s.props,{autoSelectRow:g=!1,autoSelectColumn:C=!1}=p;if(g&&e!==0){const{lastLeft:f}=s.metrics;let{left:S}=s.state;S=je(S+e,0,f),s.moveCursorToPosition(S,a,i,!1),s.setViewState({left:S})}else if(C&&t!==0){const{lastTop:f}=s.metrics;let{top:S}=s.state;S=je(S+t,0,f),s.moveCursorToPosition(S,r,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,a=s;if(o==null)return!1;const r=t.getMetricState(),{metricCalculator:c}=t,{bottomVisible:h,topVisible:u,hasHorizontalBar:m}=c.getMetrics(r);let p=o-(h-u);p-=m?0:1,p=Math.max(p,0);const g=Math.max(p-(o-u),0);return t.moveCursorToPosition(a,p,n,!1),t.setViewState({top:g}),!0}handlePageDown(e,t){const n=e.shiftKey;n?t.trimSelectedRanges():t.clearSelectedRanges();const{selectionEndRow:s,cursorColumn:i}=t.state,o=s,a=i;if(o===null)return!1;const r=t.getMetricState(),{metricCalculator:c}=t,{bottomVisible:h,topVisible:u,hasHorizontalBar:m,rowCount:p,lastTop:g}=c.getMetrics(r),C=p-1;let f=h-u+o;f+=m?0:1,f=Math.min(f,C);const S=Math.min(g,f-(o-u));return t.moveCursorToPosition(a,f,n,!1),t.setViewState({top:S}),!0}}class Xw extends li{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:a}=s;if(o!=null){const r=t.getModelRow(o);if((a===0||a==null)&&ze(i)&&i.isRowExpandable(r))return t.toggleRowExpanded(o),!0}}}return!1}}class Zw extends li{onDown(e,t){if(B.isModifierKeyDown(e))return!1;const{model:n}=t.props,{cursorColumn:s,cursorRow:i}=t.state;if(s==null||i==null||!Ze(n)||!n.isEditableRange(z.makeCell(s,i)))return!1;const o=s,a=i;return o==null||a==null?!1:e.key.length===1?(t.startEditing(o,a,!0,[1,1],e.key),!0):e.key==="F2"?(t.startEditing(o,a),!0):e.key==="Backspace"?(t.startEditing(o,a,!0,void 0,""),!0):e.key==="Delete"?(t.setValueForCell(o,a,""),!0):!1}}function Qw(d){const e=[],t=d.querySelectorAll("tr");for(let n=0;n<t.length;n+=1){const i=t[n].querySelectorAll("td"),o=[];for(let a=0;a<i.length;a+=1){const r=i[a];o.push(r.textContent?.trim()??"")}e.push(o)}return e}function Jw(d){const e=[];return d.forEach(t=>{const n=t.textContent??"";n.length>0&&e.push(n.split(/\t|\u00a0\u00a0 \u00a0/))}),e}function ev(d){const e=d.querySelector("table");if(e!=null)return Qw(e);const t=d.textContent?.trim()??"";if(t.length>0){const{childNodes:n}=d,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(`
|
|
20
20
|
`).map(o=>o.split(" ")):n.length>1||i?Jw(d.childNodes):t}return null}class tv extends li{onDown(e,t){switch(e.key){case"v":if(B.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=ev(n);i!=null&&t.pasteValue(i)};return n.addEventListener("input",s),n.focus(),{preventDefault:!1,stopPropagation:!0}}break}return!1}}const nv=d=>{switch(d){case"ArrowDown":return vn.DOWN;case"ArrowUp":return vn.UP;case"ArrowLeft":return vn.LEFT;case"ArrowRight":return vn.RIGHT;default:return}};function od({selectionRange:d=void 0,className:e="",disabled:t=!1,value:n="",isQuickEdit:s=!0,onChange:i=()=>{},onCancel:o=()=>{},onDone:a=()=>{},onContextMenu:r=()=>{},style:c={}}){const h=b.useRef(null),u=b.useRef(!1),[m]=b.useState(n),[p,g]=b.useState(!1),[C,f]=b.useState(s),[S,v]=b.useState(n);b.useEffect(function(){const{current:O}=h;O!=null&&(O.focus(),d?O.setSelectionRange(d[0],d[1]):O.setSelectionRange(O.value.length,O.value.length))},[d]);const w=b.useCallback(P=>{i(P)},[i]),T=b.useCallback(P=>{const{value:O}=P.target;v(O),g(!0),w(O)},[w,v,g]),y=b.useCallback(()=>{u.current=!0,p&&w(m),g(!1),o()},[m,p,o,w]),E=b.useCallback(()=>{f(!1)},[f]),I=b.useCallback((P,O=!1)=>{a(S,{direction:P,fillRange:O})},[a,S]),F=b.useCallback(()=>{u.current||I(null)},[u,I]),N=b.useCallback(P=>{switch(P.stopPropagation(),P.key){case"Escape":P.preventDefault(),y();break;case"Enter":if(P.preventDefault(),B.isModifierKeyDown(P))I(void 0,!0);else if(P.altKey){const O=`${S}
|
|
21
21
|
`;v(O),g(!0),w(O)}else I(P.shiftKey?vn.UP:vn.DOWN);break;case"Tab":P.preventDefault(),I(P.shiftKey?vn.LEFT:vn.RIGHT);break;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":C&&(P.preventDefault(),I(nv(P.key)));break}},[y,I,C,v,g,w,S]),H=b.useCallback(P=>{r(P)},[r]);return l.jsx("textarea",{ref:h,className:$("grid-cell-input-field",e),value:S,onBlur:F,onChange:T,onKeyDown:N,onContextMenu:H,onClick:E,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",disabled:t,style:c})}od.propTypes={selectionRange:D.arrayOf(D.number),className:D.string,disabled:D.bool,isQuickEdit:D.bool,value:D.string,onChange:D.func,onCancel:D.func,onDone:D.func,onContextMenu:D.func,style:D.shape({})};od.defaultProps={selectionRange:null,className:"",disabled:!1,value:"",isQuickEdit:!0,onChange:()=>{},onCancel:()=>{},onDone:()=>{},onContextMenu:()=>{},style:{}};const sv=X.createContext({});class ws extends b.PureComponent{static contextType=sv;static defaultProps={canvasOptions:{alpha:!1},isStickyBottom:!1,isStickyRight:!1,isStuckToBottom:!1,isStuckToRight:!1,keyHandlers:De,mouseHandlers:De,movedColumns:De,movedRows:De,onError:()=>{},onSelectionChanged:()=>{},onMovedColumnsChanged:e=>{},onMoveColumnComplete:()=>{},onMovedRowsChanged:()=>{},onMoveRowComplete:()=>{},onViewChanged:()=>{},onTokenClicked:e=>{_a(e)&&window.open(e.href,"_blank","noopener,noreferrer")},stateOverride:{},theme:{autoSelectColumn:!1,autoSelectRow:!1}};static pixelsPerLine=100/3;static dragTimeout=1e3;static getTheme=fe((e,t)=>({...Bw,...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:a}=e;this.renderer=a||new Pt,this.metricCalculator=s||new Po,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 Zw(400),new tv(450),new Yw(500),new Xw(900)],this.mouseHandlers=[new nd(100),new Cr(200),new zw(300),new Gw(400),new qw(450),new sd(500),new td(600),new Kw(700),new Bi(800),new id(825),new $w(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:De,lastSelectedRanges:De,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:a,onMoveColumnComplete:r,onMovedRowsChanged:c,onMoveRowComplete:h}=this.props,{isStickyBottom:u,isStickyRight:m,movedColumns:p,movedRows:g}=e,{movedColumns:C,movedRows:f}=t,{draggingColumn:S,draggingRow:v,movedColumns:w,movedRows:T}=this.state;if(p!==i&&this.setState({movedColumns:i}),g!==o&&this.setState({movedRows:o}),C!==w&&a(w),t.draggingColumn!=null&&S==null&&r(w),f!==T&&c(T),t.draggingRow!=null&&v==null&&h(T),n!==u&&this.setState({isStuckToBottom:!1}),s!==m&&this.setState({isStuckToRight:!1}),this.updateMetrics(),this.requestUpdateCanvas(),!this.metrics||!this.prevMetrics)return;const{rowCount:y,columnCount:E,height:I,width:F}=this.metrics,{rowCount:N,columnCount:H,height:P,width:O}=this.prevMetrics;if(N!==y||I!==P){const{isStuckToBottom:k}=this.state;k&&this.scrollToBottom()}if(H!==E||F!==O){const{isStuckToRight:k}=this.state;k&&this.scrollToRight()}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 ws.getTheme(this.context,e)}getGridPointFromEvent(e){Dc(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 B.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,a=this.canvas.clientHeight,{left:r,top:c,leftOffset:h,topOffset:u,movedColumns:m,movedRows:p,isDraggingHorizontalScrollBar:g,isDraggingVerticalScrollBar:C,draggingColumn:f}=e;return{left:r,top:c,leftOffset:h,topOffset:u,width:o,height:a,context:i,theme:t,model:n,movedColumns:m,movedRows:p,isDraggingHorizontalScrollBar:g,isDraggingVerticalScrollBar:C,draggingColumn:f,...s}}getCachedKeyHandlers=fe(e=>[...e,...this.keyHandlers].sort((t,n)=>t.order-n.order));getKeyHandlers(){const{keyHandlers:e}=this.props;return this.getCachedKeyHandlers(e)}getCachedMouseHandlers=fe(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;ze(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:a}=this.state;if(this.setState({selectedRanges:e,lastSelectedRanges:a}),e.length>0){const r=z.boundedRange(e[0],n,s);let c=i,h=o;r.containsCell(o,i)||({row:c,column:h}=r.startCell()),this.setState({selectionStartColumn:r.startColumn,selectionStartRow:r.startRow,selectionEndColumn:r.endColumn,selectionEndRow:r.endRow,cursorColumn:h,cursorRow:c})}}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(()=>{if(this.animationFrame=null,!this.metrics)throw new Error("Metrics not set");this.updateCanvas(this.metrics)}))}updateCanvas(e=this.updateMetrics()){this.updateCanvasScale(),this.updateRenderState(),this.renderer.configureContext(this.canvasContext,this.renderState);const{onViewChanged:t}=this.props;t(e),this.drawCanvas(e)}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=ws.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})}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:a,selectionStartColumn:r}=i,{theme:c}=this.props,{autoSelectRow:h,autoSelectColumn:u}=c;if(n&&o.length>0){const C=o[o.length-1];let f=null,S=null,v=null,w=null;s?(f=h!==void 0&&h?null:Math.min(e??0,C.startColumn??0),S=u!==void 0&&u?null:Math.min(t??0,C.startRow??0),v=h!==void 0&&h?null:Math.max(e??0,C.endColumn??0),w=u!==void 0&&u?null:Math.max(t??0,C.endRow??0)):(f=C.startColumn,S=C.startRow,(r!=null||a!=null)&&((h===void 0||!h)&&(f=r),(u===void 0||!u)&&(S=a)),v=h!==void 0&&h?null:e,w=u!==void 0&&u?null:t);const T=z.makeNormalized(f,S,v,w);if(C.equals(T))return null;const y=[...o];return y[y.length-1]=T,{selectedRanges:y,selectionEndColumn:e,selectionEndRow:t}}const m=[...o],p=h!==void 0&&h?null:e,g=u!==void 0&&u?null:t;return m.push(z.makeNormalized(p,g,p,g)),{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:a}=e;if(s.length===1&&(n!==void 0&&n?z.rowCount(s)===1:z.cellCount(s)===1)&&z.rangeArraysEqual(s,i))return{selectedRanges:[],lastSelectedRanges:[],cursorColumn:null,cursorRow:null};let r=s.slice();if(r.length>1){const u=r[r.length-1];for(let m=0;m<r.length-1;m+=1){const p=r[m];if(p.contains(u)){const g=p.subtract(u);r.pop(),r.splice(m,1),r=r.concat(g);break}}r=z.consolidate(r)}let c=a,h=o;if(!z.containsCell(r,a,o)){const{model:u}=this.props,{columnCount:m,rowCount:p}=u,g=z.nextCell(z.boundedRanges(s,m,p));g!=null?{column:c,row:h}=g:(c=null,h=null)}return r.length===0&&(c=null,h=null),{cursorRow:h,cursorColumn:c,selectedRanges:r,lastSelectedRanges:s}})}setFocusRow(e){if(!this.metrics||!this.prevMetrics)return;const{gridY:t,height:n,lastTop:s,userRowHeights:i,rowHeight:o}=this.metrics,a=n-t,r=Math.round(a/2)+(i.get(e)??o),c=this.getMetricState(),h=this.metricCalculator.getLastTop(c,e+1,r);this.setState({top:Math.min(s,h),selectedRanges:[new z(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,a=n!==void 0&&n?null:0,r=n!==void 0&&n?null:e.columnCount-1;this.setSelectedRanges([new z(a,i,r,o)])}moveCursor(e,t,n){const{cursorRow:s,cursorColumn:i,selectionEndColumn:o,selectionEndRow:a}=this.state,r=n?o:i,c=n?a:s;if(c===null||r===null){const{left:h,top:u}=this.state;this.moveCursorToPosition(h,u,n)}else{const{model:h}=this.props,{columnCount:u,rowCount:m}=h,p=je(r+e,0,u-1),g=je(c+t,0,m-1);this.moveCursorToPosition(p,g,n)}}moveCursorInDirection(e=z.SELECTION_DIRECTION.DOWN){const{model:t}=this.props,{columnCount:n,rowCount:s}=t,{cursorRow:i,cursorColumn:o,selectedRanges:a}=this.state,r=a.length>0?a:[z.makeCell(o,i)];let c=null;if(r.length===1&&z.cellCount(r)===1){const h=new z(0,0,n-1,s-1);c=h.nextCell(o,i,e)??h.startCell(e)}else c=z.nextCell(z.boundedRanges(r,n,s),o,i,e);if(c!=null){const{column:h,row:u}=c;this.setState({cursorColumn:h,cursorRow:u}),z.containsCell(a,h,u)||this.setState({selectedRanges:[z.makeCell(h,u)],selectionStartColumn:h,selectionStartRow:u,selectionEndColumn:h,selectionEndRow:u}),this.moveViewToCell(c.column,c.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:a}=this.metrics,r=this.getMetricState(this.state);let{top:c,left:h,topOffset:u,leftOffset:m}=this.state;t!=null&&!B.isFloatingRow(t,this.metrics)&&(t<o?(c=n.getTopForTopVisible(r,t),u=0):t>s&&(c=n.getTopForBottomVisible(r,t),u=0)),e!=null&&!B.isFloatingColumn(e,this.metrics)&&(e<a?(h=n.getLeftForLeftVisible(r,e),m=0):e>i&&(h=n.getLeftForRightVisible(r,e),m=0)),this.setViewState({top:c,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:a,lastLeft:r}=this.metrics;i!=null&&this.setState({isStuckToBottom:n&&i>=a}),o!=null&&this.setState({isStuckToRight:s&&o>=r}),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 a=this.getModelColumn(e),r=this.getModelRow(t),c={column:e,row:t,selectionRange:s,value:i!==void 0?i:o.editValueForCell(a,r),isQuickEdit:n};this.setState({editingCell:c,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(Fc(t),!t.isEditable||!i.every(m=>t.isEditableRange(m)))throw new Hr("Can't paste in to read-only area.");if(i.length<=0)throw new Hr("Select an area to paste to.");if(typeof e=="string"){const m=[],p=B.getModelRanges(i,n,s);z.forEachCell(p,(g,C)=>{m.push({column:g,row:C,text:e})}),await t.setValues(m);return}const o=e.length,a=e[0].length,{columnCount:r,rowCount:c}=t;let h=i;if(h.every(m=>z.cellCount([m])===1&&(m.startColumn??0)+a<=r&&(m.startRow??0)+o<=c)&&(h=h.map(m=>new z(m.startColumn,m.startRow,(m.startColumn??0)+a-1,(m.startRow??0)+o-1)),this.setSelectedRanges(h)),!h.every(m=>z.rowCount([m])===o&&z.columnCount([m])===a))throw new Hr("Copy and paste area are not same size.");const u=[];h.forEach(m=>{for(let p=0;p<a;p+=1)for(let g=0;g<o;g+=1)u.push({column:(m.startColumn??0)+p,row:(m.startRow??0)+g,text:e[g][p]})}),await t.setValues(u)}catch(o){const{onError:a}=this.props;a(o instanceof Error?o:new Error(`${o}`))}}setValueForCell(e,t,n){const{model:s}=this.props;Fc(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=B.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),a=i.startColumn===null||i.startColumn<=t&&t<=(i.endColumn??0);if(o&&a)return!0}return!1}addDocumentCursor(e=null){this.documentCursor!==ws.getCursorClassName(e)&&(this.documentCursor!=null&&document.documentElement.classList.remove(this.documentCursor),this.documentCursor=ws.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)},ws.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 a=null;for(let r=0;r<o.length;r+=1){const c=o[r],h=c[e]!=null&&c[e](i,this,t);if(h!==!1){c.cursor!=null&&({cursor:a}=c,s&&this.addDocumentCursor(a));const u=h;(u?.stopPropagation??!0)&&t.stopPropagation(),(u?.preventDefault??!0)&&t.preventDefault();break}}if(this.setState({cursor:a}),n){const{x:r,y:c}=i;this.setState({mouseX:r,mouseY:c})}}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:a,rowCount:r,scrollableContentWidth:c,scrollableViewportWidth:h,scrollableContentHeight:u,scrollableViewportHeight:m,hasHorizontalBar:p,hasVerticalBar:g}=n;let{top:C,left:f,topOffset:S,leftOffset:v}=n;const w=this.getTheme();let{deltaX:T,deltaY:y}=B.getScrollDelta(e,n.barWidth,n.barHeight,n.rowHeight,n.rowHeight);for(;p&&T!==0;){if(v+=T,T=0,a>1){if(v>0&&f>=o||v<0&&f<=0){v=0;break}}else{if(v<=0){v=0;break}const E=c-h;if(v>=E){v=E;break}}if(v>0){const E=n.allColumnWidths.get(f)??t.getVisibleColumnWidth(f,s);v>=E?(T=v-E,v=0,f+=1):w.scrollSnapToColumn&&a>1&&(v=0,f+=1)}else if(v<0){const E=n.allColumnWidths.get(f-1)??t.getVisibleColumnWidth(f-1,s);Math.abs(v)<=E&&w.scrollSnapToColumn&&a>1?(v=0,f-=1):(T=v+E,v=0,f-=1)}}for(;g&&y!==0;){if(S+=y,y=0,r>1){if(S>0&&C>=i||S<0&&C<=0){S=0;break}}else{if(S<=0){S=0;break}const E=u-m;if(S>=E){S=E;break}}if(S>0){const E=n.allRowHeights.get(C)??t.getVisibleRowHeight(C,s);S>=E?(y=S-E,S=0,C+=1):w.scrollSnapToRow&&r>1&&(S=0,C+=1)}else if(S<0){const E=n.allRowHeights.get(C-1)??t.getVisibleRowHeight(C-1,s);Math.abs(S)<=E&&w.scrollSnapToRow&&r>1?(S=0,C-=1):(y=S+E,S=0,C-=1)}}this.setViewState({top:C,left:f,leftOffset:v,topOffset:S}),e.stopPropagation(),e.preventDefault()}handleEditCellCancel(){this.setState({editingCell:null}),this.focus()}handleEditCellChange(e){this.setState(({editingCell:t})=>{try{return Dc(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=vn.DOWN,fillRange:n=!1}={}){const{editingCell:s,selectedRanges:i}=this.state;if(!s)throw new Error("editingCell not set");const{column:o,row:a}=s;if(!this.isValidForCell(o,a,e)){t===null&&this.setState({editingCell:null});return}n?this.setValueForRanges(i,e):this.setValueForCell(o,a,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:a,row:r}=t,{gridX:c,gridY:h,allColumnXs:u,allRowYs:m,allColumnWidths:p,allRowHeights:g}=n,C=u.get(a),f=m.get(r),S=p.get(a),v=g.get(r),w=C!=null&&f!=null&&S!=null&&v!=null?{position:"absolute",left:c+C,top:h+f,width:S,height:v}:{opacity:0},T=this.getModelColumn(a),y=this.getModelRow(r),E=T!=null&&y!=null?{textAlign:e.textAlignForCell(T,y)}:void 0,I=e.isValidForCell(T,y,i);return l.jsx("div",{style:w,children:l.jsx(od,{selectionRange:s,className:$({error:!I}),onCancel:this.handleEditCellCancel,onChange:this.handleEditCellChange,onDone:this.handleEditCellCommit,isQuickEdit:o,style:E,value:i},`${a},${r}`)})}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:a,editingCell:r,isDraggingHorizontalScrollBar:c,isDraggingVerticalScrollBar:h,isDragging:u,mouseX:m,mouseY:p,selectedRanges:g}=this.state,{model:C,stateOverride:f}=this.props,{metrics:S}=this,v=this.canvasContext,w=this.getTheme(),T=this.canvas.clientWidth,y=this.canvas.clientHeight;return M(S),this.renderState={width:T,height:y,context:v,theme:w,model:C,metrics:S,mouseX:m,mouseY:p,selectedRanges:g,draggingColumn:n,draggingColumnSeparator:s,draggingRow:i,draggingRowOffset:o,draggingRowSeparator:a,editingCell:r,isDraggingHorizontalScrollBar:c,isDraggingVerticalScrollBar:h,isDragging:u,cursorColumn:e,cursorRow:t,...f},this.renderState}render(){const{cursor:e}=this.state;return l.jsxs(l.Fragment,{children:[l.jsx("canvas",{className:$("grid-canvas",ws.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 Br=5e3;class iv extends vl{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=Br){const s=this.textForCell(e,t);return this.getCachedTokensInText(s,n)}getCachedTokensInText=qn((e,t)=>{if(t>=e.length)return Nd(e);const n=e.slice(t-1,Br).search(/\s/);let s=t+n;n===-1&&(s=Math.min(Br,e.length));const i=e.substring(0,s);return Nd(i)})}function ov(d,e){const t=lv(d);return t===void 0?void 0:`${pv(d)} ? ${t} : ${e}`}function av(d){return dh.Column.formatRowColor(d)}function rv(d,e){return d.formatColor(e)}const So=Z.module("ConditionalFormattingUtils");var An=(d=>(d.CONDITIONAL="conditional",d.ROWS="rows",d))(An||{}),Ge=(d=>(d.IS_EQUAL="is-equal",d.IS_NOT_EQUAL="is-not-equal",d.IS_BETWEEN="is-between",d.GREATER_THAN="greater-than",d.GREATER_THAN_OR_EQUAL="greater-than-or-equal",d.LESS_THAN="less-than",d.LESS_THAN_OR_EQUAL="less-than-or-equal",d.IS_NULL="is-null",d.IS_NOT_NULL="is-not-null",d))(Ge||{}),Gt=(d=>(d.IS_EXACTLY="is-exactly",d.IS_NOT_EXACTLY="is-not-exactly",d.CONTAINS="contains",d.DOES_NOT_CONTAIN="does-not-contain",d.STARTS_WITH="starts-with",d.ENDS_WITH="ends-with",d.IS_NULL="is-null",d.IS_NOT_NULL="is-not-null",d))(Gt||{}),Ft=(d=>(d.IS_EXACTLY="is-exactly",d.IS_NOT_EXACTLY="is-not-exactly",d.IS_BEFORE="is-before",d.IS_BEFORE_OR_EQUAL="is-before-or-equal",d.IS_AFTER="is-after",d.IS_AFTER_OR_EQUAL="is-after-or-equal",d.IS_NULL="is-null",d.IS_NOT_NULL="is-not-null",d))(Ft||{}),fo=(d=>(d.IS_TRUE="is-true",d.IS_FALSE="is-false",d.IS_NULL="is-null",d.IS_NOT_NULL="is-not-null",d))(fo||{}),ni=(d=>(d.IS_EQUAL="is-equal",d.IS_NOT_EQUAL="is-not-equal",d.IS_NULL="is-null",d.IS_NOT_NULL="is-not-null",d))(ni||{}),un=(d=>(d.NO_FORMATTING="no-formatting",d.POSITIVE="positive",d.NEGATIVE="negative",d.WARN="warn",d.NEUTRAL="neutral",d.ACCENT_1="accent-1",d.ACCENT_2="accent-2",d.CUSTOM="custom",d))(un||{});function Ac(d){switch(d){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 ja(d){const{type:e,customConfig:t}=d;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 Ha(d){const{type:e,customConfig:t}=d;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 lv(d){const e=Ha(d.style),t=ja(d.style);if(!(e===void 0||t===void 0))return`bgfg(\`${t}\`, \`${e}\`)`}function dv(d){const{column:e,value:t,start:n,end:s}=d;return xv(e.name,d.condition,t,n,s)}function cv(d){const{column:e,value:t}=d;return Rv(e.name,d.condition,t)}function hv(d){const{column:e,value:t}=d;return Iv(e.name,d.condition,t)}function uv(d){const{column:e}=d;return Dv(e.name,d.condition)}function mv(d){const{column:e,value:t}=d;return Fv(e.name,d.condition,t)}function pv(d){const{column:e}=d;if(R.isNumberType(e.type))return dv(d);if(R.isCharType(e.type))return mv(d);if(R.isStringType(e.type))return cv(d);if(R.isDateType(e.type))return hv(d);if(R.isBooleanType(e.type))return uv(d);throw new Error("Invalid column type")}function gv(d){switch(d){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 fv(d){switch(d){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 Cv(d){switch(d){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 Sv(d){switch(d){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 bv(d){switch(d){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 Xu(d){if(R.isNumberType(d)||R.isCharType(d))return"is-equal";if(R.isStringType(d)||R.isDateType(d))return"is-exactly";if(R.isBooleanType(d))return"is-true";throw new Error("Invalid column type")}function Zu(d){if(R.isCharType(d)||R.isStringType(d))return""}function Qu(d){const{condition:e,value:t,start:n,end:s}=d;return{condition:e,value:t,start:n,end:s}}function Sr(d){return{condition:Xu(d),value:Zu(d),start:void 0,end:void 0}}function Ju(){return{type:"no-formatting"}}function wv(d){switch(d){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 vv(d){switch(d){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 Tv(d){switch(d){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 Ev(d){switch(d){case"is-equal":return"==";case"is-not-equal":return"!=";case"is-null":return"is null";case"is-not-null":return"is not null"}}function yv(d){switch(d){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 xv(d,e,t,n,s){switch(e){case"is-equal":return`${d} == ${t}`;case"is-not-equal":return`${d} != ${t}`;case"is-between":return`${d} > ${n} && ${d} < ${s}`;case"greater-than":return`${d} > ${t}`;case"greater-than-or-equal":return`${d} >= ${t}`;case"less-than":return`${d} < ${t}`;case"less-than-or-equal":return`${d} <= ${t}`;case"is-null":return`${d} == null`;case"is-not-null":return`${d} != null`}}function Rv(d,e,t){switch(e){case"is-exactly":return`${d} == "${t}"`;case"is-not-exactly":return`${d} != "${t}"`;case"contains":return`${d} != null && ${d}.contains("${t}")`;case"does-not-contain":return`${d} != null && !${d}.contains("${t}")`;case"starts-with":return`${d} != null && ${d}.startsWith("${t}")`;case"ends-with":return`${d} != null && ${d}.endsWith("${t}")`;case"is-null":return`${d} == null`;case"is-not-null":return`${d} != null`}}function Iv(d,e,t){switch(e){case"is-exactly":return`${d} == convertDateTime("${t}")`;case"is-not-exactly":return`${d} != convertDateTime(\`${t}\`)`;case"is-before":return`${d} < convertDateTime(\`${t}\`)`;case"is-before-or-equal":return`${d} <= convertDateTime("${t}")`;case"is-after":return`${d} > convertDateTime(\`${t}\`)`;case"is-after-or-equal":return`${d} >= convertDateTime(\`${t}\`)`;case"is-null":return`${d} == null`;case"is-not-null":return`${d} != null`}}function Dv(d,e){switch(e){case"is-true":return`${d} == true`;case"is-false":return`${d} == false`;case"is-null":return`${d} == null`;case"is-not-null":return`${d} != null`}}function Fv(d,e,t){switch(e){case"is-equal":return`${d} == '${t}'`;case"is-not-equal":return`${d} != '${t}'`;case"is-null":return`isNull(${d})`;case"is-not-null":return`!isNull(${d})`}}function Nv(d,e){if(R.isNumberType(d))return yv(e);if(R.isCharType(d))return Ev(e);if(R.isStringType(d))return wv(e);if(R.isDateType(d))return vv(e);if(R.isBooleanType(d))return Tv(e);throw new Error("Invalid column type")}function Mv(d,e){if(e===void 0)return So.debug("no rules passed."),[];const t=[];let n;const s=new Map;return e.forEach(({config:i,type:o})=>{const{column:a}=i,r=d.find(({name:g,type:C})=>g===a.name&&C===a.type);if(r===void 0){So.debug(`Column ${a.name}:${a.type} not found. Ignoring format rule.`,i);return}const[c,h]=(o==="conditional"?s.get(r.name):n)??["null",void 0],u=ov(i,c);if(u===void 0){So.debug("Ignoring format rule.",i);return}const m=h===void 0?-1:t.indexOf(h);m>-1&&t.splice(m,1);const p=o==="conditional"?rv(r,u):av(u);t.push(p),o==="conditional"?s.set(r.name,[u,p]):n=[u,p]}),t}function kv(d,e){switch(d){case"is-null":case"is-not-null":return!0;default:{const[t,...n]=(e??"").split(" "),s=n.join(" ");try{et.parseDateTimeString(t)}catch{return So.debug("Invalid datetime string",t),!1}try{dh.i18n.TimeZone.getTimeZone(s)}catch{return So.debug("Invalid timezone string",s),!1}return!0}}}function Ov({type:d}){return R.isNumberType(d)||R.isCharType(d)||R.isStringType(d)||R.isDateType(d)||R.isBooleanType(d)}function br({animation:d="iris-grid-bottom-bar-slide-up",children:e,className:t,isShown:n,onClick:s,onEntering:i,onEntered:o,onExiting:a,onExited:r}){return l.jsx(gt,{in:n,timeout:We.transitionMs,classNames:d,onEntering:i,onEntered:o,onExiting:a,onExited:r,mountOnEnter:!0,unmountOnExit:!0,children:l.jsx("div",{className:$("iris-grid-bottom-bar",t),role:"presentation",onClick:s,onKeyPress:s,children:e})})}const Av=3e3,Lv=5;function Pv({isSaving:d=!1,onSave:e,onDiscard:t,discardTooltip:n,saveTooltip:s,error:i,pendingDataErrors:o,pendingDataMap:a,onEntering:r,onEntered:c,onExiting:h,onExited:u}){const[m,p]=b.useState(!1),[g,C]=b.useState(!1),f=b.useRef(),S=ir(d),v=b.useMemo(()=>o.size===0?i:o.size<=Lv?`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]);b.useEffect(function(){S!=null&&S&&!d&&v==null&&(p(!0),C(!0),f.current=setTimeout(()=>{p(!1)},Av))},[v,d,S]),b.useEffect(function(){f.current&&a.size>0&&(clearTimeout(f.current),p(!1),C(!1))},[a]),b.useEffect(function(){return()=>f.current?clearTimeout(f.current):void 0},[]);const w=a.size;let T;return d?T=l.jsx(Ln,{}):g&&(T=Rl),l.jsxs(br,{className:"pending-data-bottom-bar",isShown:w>0||m||v!=null,onEntering:r,onEntered:c,onExiting:h,onExited:()=>{C(!1),u&&u()},children:[v!=null&&v!==""&&l.jsxs("div",{className:"error-message",children:[l.jsx(J,{icon:Ms}),l.jsx("span",{children:`${v}`})]}),(v==null||v==="")&&l.jsx("div",{className:"status-message",children:w>0&&l.jsx("span",{children:`${w} row${w>1?"s":""} pending`})}),l.jsxs("div",{className:"buttons-container",children:[!d&&!g&&l.jsx(V,{kind:"secondary",onClick:t,tooltip:n,children:"Discard"}),l.jsxs(V,{kind:g?"success":"primary",onClick:e,icon:T,disabled:d||g||v!=null,tooltip:s,children:[d&&"Committing...",!d&&g&&"Success",!d&&!g&&"Commit"]})]})]})}var em=(d=>(d.COUNT="Count",d.MIN="Min",d.MAX="Max",d.SUM="Sum",d.ABS_SUM="AbsSum",d.VAR="Var",d.AVG="Avg",d.STD="Std",d.FIRST="First",d.LAST="Last",d.SKIP="Skip",d.COUNT_DISTINCT="CountDistinct",d.DISTINCT="Distinct",d.UNIQUE="Unique",d))(em||{});const Me=em,_v=d=>{switch(d){default:return!1}},jv=(d,e)=>{switch(d){case Me.COUNT:case Me.FIRST:case Me.LAST:case Me.COUNT_DISTINCT:case Me.DISTINCT:case Me.UNIQUE:return!0;case Me.MIN:case Me.MAX:return R.isNumberType(e)||R.isDateType(e)||R.isTextType(e);case Me.SUM:case Me.ABS_SUM:case Me.VAR:case Me.AVG:case Me.STD:return R.isNumberType(e);case Me.SKIP:return!1}},ad=(d,e)=>d.filter(t=>jv(e,t.type)),Hv=(d,e,t,n)=>ad(d,e).map(({name:s})=>s).filter(s=>t.includes(s)?!n:n),Rs={isRollupOperation:_v,filterValidColumns:ad,getOperationColumnNames:Hv};var tm=(d=>(d.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS="filter-control-change-clears-all-filters",d.LINK_CHANGE_CLEARS_ALL_FILTERS="link-change-clears-all-filters",d))(tm||{});const Vi=tm,Bv=Object.freeze([[Vi.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS,!1],[Vi.LINK_CHANGE_CLEARS_ALL_FILTERS,!1]]),nm={DEFAULTS:Bv},Vv=Z.module("ColumnHeaderGroup");function Vr(d){return d instanceof fn}class fn{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=fe(e=>{const t=this.childIndexes.flat(),n=B.getVisibleIndexes(t,e),s=Math.min(...n),i=Math.max(...n);return i-s!==t.length-1&&Vv.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(fn.NEW_GROUP_PREFIX)}}const io=Z.module("IrisGridUtils");function ms(d,e){return d>=0&&d<e.length}function Uv(d){return d.asDate!=null}class Te{static dehydrateGridState(e,t){const{isStuckToBottom:n,isStuckToRight:s,movedColumns:i,movedRows:o}=t,{columns:a}=e;return{isStuckToBottom:n,isStuckToRight:s,movedColumns:[...i].filter(({to:r,from:c})=>ms(r,a)&&(typeof c=="number"&&ms(c,a)||Array.isArray(c)&&ms(c[0],a)&&ms(c[1],a))).map(({to:r,from:c})=>({to:a[r].name,from:Array.isArray(c)?[a[c[0]].name,a[c[1]].name]:a[c].name})),movedRows:[...o]}}static hydrateGridState(e,t,n=[]){const{isStuckToBottom:s,isStuckToRight:i,movedColumns:o,movedRows:a}=t,{columns:r}=e,c=Te.parseCustomColumnNames(n),h=r.map(({name:u})=>u).concat(c);return{isStuckToBottom:s,isStuckToRight:i,movedColumns:[...o].map(({to:u,from:m})=>{const p=g=>typeof g=="string"?h.findIndex(C=>C===g):g;return{to:p(u),from:Array.isArray(m)?[p(m[0]),p(m[1])]:p(m)}}).filter(({to:u,from:m})=>ms(u,h)&&(typeof m=="number"&&ms(m,h)||Array.isArray(m)&&ms(m[0],h)&&ms(m[1],h))),movedRows:[...a]}}static dehydrateIrisGridState(e,t){const{aggregationSettings:n={aggregations:De,showOnTop:!1},advancedFilters:s,customColumnFormatMap:i,isFilterBarShown:o,metrics:a,quickFilters:r,customColumns:c,conditionalFormats:h=De,reverseType:u,rollupConfig:m=void 0,showSearchBar:p,searchValue:g,selectDistinctColumns:C=De,selectedSearchColumns:f,sorts:S,invertSearchColumns:v,pendingDataMap:w=Gn,frozenColumns:T,columnHeaderGroups:y}=t;M(a);const{userColumnWidths:E,userRowHeights:I}=a,{columns:F}=e;return{advancedFilters:Te.dehydrateAdvancedFilters(F,s),aggregationSettings:n,customColumnFormatMap:[...i],isFilterBarShown:o,quickFilters:Te.dehydrateQuickFilters(r),sorts:Te.dehydrateSort(S),userColumnWidths:[...E].filter(([N])=>N!=null&&N>=0&&N<F.length).map(([N,H])=>[F[N].name,H]),userRowHeights:[...I],customColumns:[...c],conditionalFormats:[...h],reverseType:u,rollupConfig:m,showSearchBar:p,searchValue:g,selectDistinctColumns:[...C],selectedSearchColumns:f,invertSearchColumns:v,pendingDataMap:Te.dehydratePendingDataMap(F,w),frozenColumns:T,columnHeaderGroups:y?.map(N=>({name:N.name,children:N.children,color:N.color}))}}static hydrateIrisGridState(e,t){const{advancedFilters:n,aggregationSettings:s={aggregations:[],showOnTop:!1},customColumnFormatMap:i,isFilterBarShown:o,quickFilters:a,sorts:r,customColumns:c,conditionalFormats:h,userColumnWidths:u,userRowHeights:m,reverseType:p,rollupConfig:g=void 0,showSearchBar:C,searchValue:f,selectDistinctColumns:S,selectedSearchColumns:v,invertSearchColumns:w=!0,pendingDataMap:T=[],frozenColumns:y,columnHeaderGroups:E}=t,{columns:I,formatter:F}=e;return{advancedFilters:Te.hydrateAdvancedFilters(I,n,F.timeZone),aggregationSettings:s,customColumnFormatMap:new Map(i),isFilterBarShown:o,quickFilters:Te.hydrateQuickFilters(I,a,F.timeZone),sorts:Te.hydrateSort(I,r),userColumnWidths:new Map(u.map(([N,H])=>typeof N=="string"||N instanceof String?[I.findIndex(({name:P})=>P===N),H]:[N,H]).filter(([N])=>N!=null&&N>=0&&N<I.length)),customColumns:c,conditionalFormats:h,userRowHeights:new Map(m),reverseType:p,rollupConfig:g,showSearchBar:C,searchValue:f,selectDistinctColumns:S,selectedSearchColumns:v,invertSearchColumns:w,pendingDataMap:Te.hydratePendingDataMap(I,T),frozenColumns:y,columnHeaderGroups:Te.parseColumnHeaderGroups(e,E??e.layoutHints?.columnGroups??[]).groups}}static dehydrateIrisGridPanelState(e,t){const{isSelectingPartition:n,partition:s,partitionColumn:i,advancedSettings:o}=t;return{isSelectingPartition:n,partition:s,partitionColumn:i?.name,advancedSettings:[...o]}}static hydrateIrisGridPanelState(e,t){const{isSelectingPartition:n,partition:s,partitionColumn:i,advancedSettings:o}=t,{columns:a}=e;return{isSelectingPartition:n,partition:s,partitionColumn:i!=null?Te.getColumnByName(a,i):void 0,advancedSettings:new Map([...nm.DEFAULTS,...o])}}static dehydrateQuickFilters(e){return[...e].map(([t,n])=>{const{text:s}=n;return[t,{text:s}]})}static hydrateQuickFilters(e,t,n){const s=t.map(([i,o])=>{const{text:a}=o;let r=null;try{const c=Te.getColumn(e,i);c!=null&&(r=R.makeQuickFilter(c,a,n))}catch(c){io.error("hydrateQuickFilters error with",a,c)}return[i,{text:a,filter:r}]});return new Map(s)}static dehydrateAdvancedFilters(e,t){return[...t].map(([n,s])=>{const i=Te.getColumn(e,n);M(i);const o=Te.dehydrateAdvancedFilterOptions(i,s.options);return[n,{options:o}]})}static hydrateAdvancedFilters(e,t,n){const s=t.map(([i,o])=>{const a=Te.getColumn(e,i);M(a);const r=Te.hydrateAdvancedFilterOptions(a,o.options);let c=null;try{Te.getColumn(e,i)!=null&&(c=R.makeAdvancedFilter(a,r,n))}catch(h){io.error("hydrateAdvancedFilters error with",r,h)}return[i,{options:r,filter:c}]});return new Map(s)}static dehydrateAdvancedFilterOptions(e,t){const{selectedValues:n,...s}=t;return{selectedValues:n?.map(i=>Te.dehydrateValue(i,e?.type)),...s}}static hydrateAdvancedFilterOptions(e,t){const{selectedValues:n,...s}=t;return{selectedValues:n?.map(i=>Te.hydrateValue(i,e?.type)),...s}}static dehydratePendingDataMap(e,t){return[...t].map(([n,{data:s}])=>[n,{data:[...s].map(([i,o])=>[e[i].name,Te.dehydrateValue(o,e[i].type)])}])}static hydratePendingDataMap(e,t){const n=new Map,s=i=>(n.has(i)||n.set(i,e.findIndex(({name:o})=>o===i)),n.get(i));return new Map(t.map(([i,{data:o}])=>[i,{data:new Map(o.map(([a,r])=>{const c=s(a);return M(c),[s(a)??null,Te.hydrateValue(r,e[c].type)]}))}]))}static dehydrateValue(e,t){return R.isDateType(t)?Te.dehydrateDateTime(e):R.isLongType(t)?Te.dehydrateLong(e):e}static hydrateValue(e,t){return R.isDateType(t)?Te.hydrateDateTime(e):R.isLongType(t)?Te.hydrateLong(e):e}static dehydrateDateTime(e){return e!=null?x.i18n.DateTimeFormat.format(et.FULL_DATE_FORMAT,e):null}static hydrateDateTime(e){return e!=null?x.i18n.DateTimeFormat.parse(et.FULL_DATE_FORMAT,e):null}static dehydrateLong(e){return e!=null?`${e}`:null}static hydrateLong(e){return e!=null?x.LongWrapper.ofString(e):null}static dehydrateSort(e){return e.map(t=>{const{column:n,isAbs:s,direction:i}=t;return{column:n.name,isAbs:s,direction:i}})}static hydrateSort(e,t){return t.map(n=>{const{column:s,isAbs:i,direction:o}=n;if(o===R.sortDirection.reverse)return x.Table.reverse();const a=typeof s=="string"?Te.getColumnByName(e,s):Te.getColumn(e,s);if(a!=null){let r=a.sort();return i&&(r=r.abs()),o===R.sortDirection.descending?r=r.desc():r=r.asc(),r}return null}).filter(n=>n!=null&&n.direction!==R.sortDirection.reverse)}static extractTableSettings(e,t=[]){const{irisGridPanelState:n,irisGridState:s}=e,{partitionColumn:i,partition:o}=n,{advancedFilters:a,quickFilters:r,sorts:c}=s;return{advancedFilters:a,inputFilters:t,partition:o,partitionColumn:i,quickFilters:r,sorts:c}}static applyTableSettings(e,t,n){const{columns:s}=e;let i=[];t.quickFilters&&(i=Te.getFiltersFromFilterMap(Te.hydrateQuickFilters(s,t.quickFilters,n)));let o=[];t.advancedFilters&&(o=Te.getFiltersFromFilterMap(Te.hydrateAdvancedFilters(s,t.advancedFilters,n)));const a=Te.getFiltersFromInputFilters(s,t.inputFilters,n);let r=[];t.sorts&&(r=Te.hydrateSort(s,t.sorts));let c=[...i,...o];const{partition:h,partitionColumn:u}=t;if(h!=null&&u!=null){const m=Te.getColumnByName(s,u);m&&(c=[m.filter().eq(x.FilterValue.ofString(h)),...c])}c=[...a,...c],e.applyFilter(c),e.applySort(r)}static getInputFiltersForColumns(e,t=[]){return t.filter(({name:n,type:s})=>e.find(({name:i,type:o})=>i===n&&o===s))}static getFiltersFromInputFilters(e,t=[],n){return t.map(({name:s,type:i,value:o})=>{const a=e.find(({name:r,type:c})=>r===s&&c===i);if(a)try{return R.makeQuickFilter(a,o,n)}catch(r){io.debug("Unable to create input filter",r)}return null}).filter(s=>s!=null)}static getFiltersFromFilterMap(e){const t=[],n=Array.from(e.keys());for(let s=0;s<n.length;s+=1){const i=n[s],o=e.get(i);o?.filter!=null&&t.push(o.filter)}return t}static getHiddenColumns(e){return[...e.entries()].filter(([,t])=>t===0).map(([t])=>t)}static parseCustomColumnNames(e){return e.map(t=>t.split("=")[0])}static getRemovedCustomColumnNames(e,t){const n=Te.parseCustomColumnNames(e),s=Te.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 a=n[o];let r=s.findIndex(h=>h===a);const c=[];for(let h=0;h<i.length;h+=1){const u=i[h],m={...u};let[p,g]=Array.isArray(u.from)?u.from:[u.from,u.from];r<=u.to&&(m.to-=1),r<p&&(p-=1),r<=g&&(g-=1),p<=g&&p!==m.to&&(p===g?c.push({...m,from:p}):c.push({...m,from:[p,g]})),r=B.applyItemMoves(r,r,[u])[0][0]}i=c,s.splice(s.findIndex(h=>h===a),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 a=t;a<=n;a+=1){const r=B.getModelIndex(a,s);r>=0&&r<e.length&&!i.includes(r)&&o.push(e[r])}return o}static getPrevVisibleColumns(e,t,n,s,i){const o=[];let a=t;for(;a>=0&&o.length<n;){const r=B.getModelIndex(a,s);r>=0&&r<e.length&&!i.includes(r)&&o.unshift(e[r]),a-=1}return o}static getNextVisibleColumns(e,t,n,s,i){const o=[];let a=t;for(;a<e.length&&o.length<n;){const r=B.getModelIndex(a,s);r>=0&&r<e.length&&!i.includes(r)&&o.push(e[r]),a+=1}return o}static getColumnsToFetch(e,t,n){const s=[...t];return n.forEach(i=>{const o=e.find(({name:a})=>a===i);o!=null&&!t.includes(o)&&s.push(o)}),s}static getModelViewportColumns(e,t,n,s,i=[],o=[],a=0){if(t==null||n==null)return null;const r=Te.getVisibleColumnsInRange(e,t,n,s,i),c=r.length*a,h=Te.getPrevVisibleColumns(e,t-1,c,s,i),u=Te.getNextVisibleColumns(e,n+1,c,s,i),m=[...h,...r,...u];return Te.getColumnsToFetch(e,m,o)}static rangeSetFromRanges(e){const t=e.slice().sort((n,s)=>(M(n.startRow),M(s.startRow),n.startRow-s.startRow)).map(n=>{const{startRow:s,endRow:i}=n;return M(s),M(i),x.RangeSet.ofRange(s,i)});return x.RangeSet.ofRanges(t)}static isValidSnapshotRanges(e){if(e==null||e.length===0)return!1;const t=new Map;for(let i=0;i<e.length;i+=1){const o=e[i],a=`${o.startRow}:${o.endRow}`,r=`${o.startColumn}:${o.endColumn}`;t.has(a)||t.set(a,[]),t.get(a).push(r)}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];M(i.startColumn),M(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],a=[];for(let r=0;r<t.length;r+=1){const c=t[r],h=o.get(c);a.push(h)}s.push(a)}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:a=!0}=t??{},{aggregations:r=[]}=n??{},c=r.map(({operation:u,selected:m,invert:p})=>Rs.isRollupOperation(u)?[]:Rs.getOperationColumnNames(e,u,m,p)),h={};for(let u=0;u<r.length;u+=1)h[r[u].operation]=c[u];if(o){const u=new Set(e.map(m=>m.name).filter(m=>!s.includes(m)));if(c.forEach(m=>{m.forEach(p=>u.delete(p))}),u.size>0){const m=h[Me.FIRST]??[];h[Me.FIRST]=[...m,...u]}}return{groupingColumns:s,includeConstituents:i,includeDescriptions:a,aggregations:h}}static getPendingErrors(e){e.forEach((t,n)=>{if(!Te.isValidIndex(n))throw new Error(`Invalid rowIndex ${n}`);const{data:s}=t;s.forEach((i,o)=>{if(!Te.isValidIndex(o))throw new Error(`Invalid columnIndex ${o}`)})})}static getColumn(e,t){return t<e.length?e[t]:(io.error("Unable to retrieve column",t,">=",e.length),null)}static getColumnByName(e,t){const n=e.find(({name:s})=>s===t);return n==null&&io.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:a}=t[s];if(o!==void 0){let r="";a!==void 0&&(o==null&&a==="eq"?r="=":a!=="eq"&&(a==="startsWith"||a==="endsWith"?r="*":r=R.getFilterOperatorString(a)));let c=`${r}${i}`;a==="startsWith"&&(c=`${i}${r}`),e!=null&&o!==null&&R.isCharType(e)&&(c=`${r}${String.fromCharCode(parseInt(i,10))}`),s!==0&&(n+=a==="eq"?" || ":" && "),n+=c}}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 a=new Map(o.map(u=>[u.name,u])),r=new Set,c=u=>{const{name:m}=u;if(e.getColumnIndexByName(m)!=null)throw new Error(`Column header group has same name as column: ${m}`);const p=i.get(m);if(p)return p;const g=[];let C=1;u.children.forEach(S=>{if(r.has(S))throw new Error(`Column group child ${S} specified in multiple groups`);r.add(S);const v=a.get(S),w=e.getColumnIndexByName(S);if(v){const T=c(v);g.push(...T.childIndexes),C=Math.max(C,T.depth+1)}else if(w!=null)g.push(w),C=Math.max(C,1);else throw new Error(`Unknown child ${S} in group ${m}`)});const f=new fn({...u,depth:C,childIndexes:g.flat()});return i.set(m,f),u.children.forEach(S=>s.set(S,f)),n=Math.max(n,f.depth+1),f},h=new Set;return o.forEach(u=>{const{name:m}=u;if(h.has(m))throw new Error(`Duplicate column group name: ${m}`);h.add(m),c(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&&R.isCharType(t)&&e!=null&&typeof e=="number")return String.fromCharCode(e);if(R.isDateType(t)&&Uv(e)){const n=new Date(e.asDate()),s=n.getTimezoneOffset();return new Date(n.getTime()-s*60*1e3).toISOString().replace("T"," ").substring(0,23)}return e==null?"":`${e}`}}const be=Te;const Ut=Z.module("IrisGridCopyHandler");class Ne extends b.Component{static NO_PROMPT_THRESHOLD=1e4;static HIDE_TIMEOUT=3e3;static COPY_STATES={IDLE:"IDLE",CONFIRMATION_REQUIRED:"CONFIRMATION_REQUIRED",FETCH_IN_PROGRESS:"FETCH_IN_PROGRESS",FETCH_ERROR:"FETCH_ERROR",CLICK_REQUIRED:"CLICK_REQUIRED",DONE:"DONE"};static BUTTON_STATES={COPY:"COPY",FETCH_IN_PROGRESS:"FETCH_IN_PROGRESS",CLICK_TO_COPY:"CLICK_TO_COPY",RETRY:"RETRY"};static defaultProps={copyOperation:null,onEntering:()=>{},onEntered:()=>{},onExiting:()=>{},onExited:()=>{}};static getStatusMessageText(e,t){switch(e){case Ne.COPY_STATES.CONFIRMATION_REQUIRED:return`Are you sure you want to copy ${t.toLocaleString()} rows to your clipboard?`;case Ne.COPY_STATES.CLICK_REQUIRED:return`Fetched ${t.toLocaleString()} rows!`;case Ne.COPY_STATES.FETCH_ERROR:return"Unable to copy data.";case Ne.COPY_STATES.FETCH_IN_PROGRESS:return`Fetching ${t.toLocaleString()} rows for clipboard...`;case Ne.COPY_STATES.DONE:return"Copied to Clipboard!";default:return""}}static getCopyButtonText(e){switch(e){case Ne.BUTTON_STATES.FETCH_IN_PROGRESS:return"Fetching";case Ne.BUTTON_STATES.CLICK_TO_COPY:return"Click to Copy";case Ne.BUTTON_STATES.RETRY:return"Retry";default:return"Copy"}}constructor(e){super(e),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleCancelClick=this.handleCancelClick.bind(this),this.handleCopyClick=this.handleCopyClick.bind(this),this.handleHideTimeout=this.handleHideTimeout.bind(this),this.state={error:void 0,copyState:Ne.COPY_STATES.IDLE,buttonState:Ne.BUTTON_STATES.COPY,isShown:!1,rowCount:0}}componentDidMount(){const{copyOperation:e}=this.props;e!=null&&this.startCopy()}componentDidUpdate(e){const{copyOperation:t}=this.props;e.copyOperation!==t&&this.startCopy()}componentWillUnmount(){this.stopCopy()}textData;hideTimer;fetchPromise;startCopy(){Ut.debug2("startCopy"),this.stopCopy();const{copyOperation:e}=this.props;if(e==null){Ut.debug2("No copy operation set, cancelling out"),this.setState({isShown:!1});return}const{ranges:t,error:n}=e;if(n!=null){Ut.debug("Showing copy error",n),this.setState({isShown:!0,copyState:Ne.COPY_STATES.DONE,error:n}),this.startHideTimer();return}const s=z.rowCount(t);this.setState({rowCount:s,isShown:!0,error:void 0}),s>Ne.NO_PROMPT_THRESHOLD?this.setState({buttonState:Ne.BUTTON_STATES.COPY,copyState:Ne.COPY_STATES.CONFIRMATION_REQUIRED}):this.startFetch()}stopCopy(){this.textData=void 0,this.stopFetch(),this.stopHideTimer()}handleBackgroundClick(){Ut.debug2("handleBackgroundClick");const{copyState:e}=this.state;e===Ne.COPY_STATES.DONE&&this.setState({isShown:!1})}handleCancelClick(){Ut.debug2("handleCancelClick"),this.stopFetch(),this.setState({isShown:!1})}handleCopyClick(){Ut.debug2("handleCopyClick"),this.textData!=null?this.copyText(this.textData):this.startFetch()}handleHideTimeout(){Ut.debug2("handleHideTimeout"),this.stopHideTimer(),this.setState({isShown:!1})}copyText(e){Ut.debug2("copyText",e),this.textData=e,$i(e).then(()=>{this.setState({copyState:Ne.COPY_STATES.DONE}),this.startHideTimer()},t=>{Ut.error("copyText error",t),this.setState({buttonState:Ne.BUTTON_STATES.CLICK_TO_COPY,copyState:Ne.COPY_STATES.CLICK_REQUIRED})})}startFetch(){this.stopFetch(),this.setState({buttonState:Ne.BUTTON_STATES.FETCH_IN_PROGRESS,copyState:Ne.COPY_STATES.FETCH_IN_PROGRESS});const{model:e,copyOperation:t}=this.props,{ranges:n,includeHeaders:s,userColumnWidths:i,movedColumns:o,formatValues:a}=t;Ut.debug("startFetch",n);const r=be.getHiddenColumns(i);let c=B.getModelRanges(n,o);if(r.length>0){const u=r.map(z.makeColumn);c=z.subtractRangesFromRanges(c,u)}const h=a!=null&&a?(u,m)=>e.displayString(u,m.type,m.name):u=>`${u}`;this.fetchPromise=ve.makeCancelable(e.textSnapshot(c,s,h)),this.fetchPromise.then(u=>{this.fetchPromise=void 0,this.copyText(u)}).catch(u=>{u instanceof Hi?Ut.debug("User cancelled copy."):(Ut.error("Error fetching contents",u),this.fetchPromise=void 0,this.setState({buttonState:Ne.BUTTON_STATES.RETRY,copyState:Ne.COPY_STATES.FETCH_ERROR}))})}stopFetch(){this.fetchPromise&&(Ut.debug2("stopFetch"),this.fetchPromise.cancel(),this.fetchPromise=void 0)}startHideTimer(){this.stopHideTimer(),this.hideTimer=setTimeout(this.handleHideTimeout,Ne.HIDE_TIMEOUT)}stopHideTimer(){this.hideTimer!=null&&(clearTimeout(this.hideTimer),this.hideTimer=void 0)}render(){const{onEntering:e,onEntered:t,onExiting:n,onExited:s}=this.props,{buttonState:i,copyState:o,isShown:a,rowCount:r,error:c}=this.state,h=o===Ne.COPY_STATES.DONE?"fade":"copy-slide-up",u=Ne.getCopyButtonText(i),m=c??Ne.getStatusMessageText(o,r),p=o!==Ne.COPY_STATES.DONE,g=i===Ne.BUTTON_STATES.FETCH_IN_PROGRESS,C=o===Ne.COPY_STATES.DONE;return l.jsxs(br,{animation:h,isShown:a,className:$("iris-grid-copy-handler",{"copy-done":C}),onClick:this.handleBackgroundClick,onEntering:e,onEntered:t,onExiting:n,onExited:s,children:[l.jsx("div",{className:"status-message",children:l.jsx("span",{children:m})}),l.jsx(gt,{in:p,timeout:We.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:l.jsxs("div",{className:"buttons-container",children:[l.jsx("button",{type:"button",className:"btn btn-outline-secondary btn-cancel",onClick:this.handleCancelClick,children:"Cancel"}),l.jsxs(V,{kind:g?"tertiary":"primary",className:$("btn-copy",{"btn-spinner":g}),onClick:this.handleCopyClick,disabled:g,children:[g&&l.jsx(Ln,{}),u]})]})})]})}}const $v=Ne;class Wv extends b.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=Ye(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=Ye(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 l.jsxs("div",{style:t,className:"iris-grid-input-autosized-wrapper","data-value":i,children:[l.jsx("input",{ref:o=>{this.inputField=o},className:$("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"}),l.jsx("div",{className:"advanced-filter-button-container",children:l.jsx(V,{kind:"ghost",className:$("btn-link-icon advanced-filter-button",{"filter-set":n}),onClick:s,onContextMenu:this.handleContextMenu,children:l.jsxs("div",{className:"fa-layers ",children:[l.jsx(J,{icon:Il,className:"filter-solid"}),l.jsx(J,{icon:xa,className:"filter-light"})]})})})]})}}const Gv=Wv;class zv extends li{irisGrid;constructor(e){super(),this.irisGrid=e}onDown(e){const{selectedRanges:t}=this.irisGrid.state;return e.key==="c"&&He.isModifierKeyDown(e)?(be.isValidSnapshotRanges(t)?this.irisGrid.copyRanges(t):this.irisGrid.copyRanges(t,!1,!1,"Invalid copy ranges"),!0):!1}}const Kv=zv,qv={TOGGLE_QUICK_FILTER:Fe.createAndAdd({id:"TABLE.TOGGLE_QUICK_FILTER",name:"Toggle Quick Filter",shortcut:[ce.CTRL,ue.F],macShortcut:[ce.CMD,ue.F]}),CLEAR_ALL_FILTERS:Fe.createAndAdd({id:"TABLE.CLEAR_ALL_FILTERS",name:"Clear All Table Filters",shortcut:[ce.CTRL,ue.E],macShortcut:[ce.CMD,ue.E]}),CLEAR_FILTERS:Fe.createAndAdd({id:"TABLE.CLEAR_FILTERS",name:"Clear Active Table Filters",shortcut:[ce.CTRL,ce.SHIFT,ue.E],macShortcut:[ce.CMD,ce.SHIFT,ue.E]}),REVERSE:Fe.createAndAdd({id:"TABLE.REVERSE",name:"Reverse",shortcut:[ce.CTRL,ue.I],macShortcut:[ce.CMD,ue.I]}),TOGGLE_SEARCH:Fe.createAndAdd({id:"TABLE.TOGGLE_SEARCH",name:"Toggle Search",shortcut:[ce.CTRL,ce.SHIFT,ue.F],macShortcut:[ce.CMD,ce.SHIFT,ue.F]}),GOTO_ROW:Fe.createAndAdd({id:"TABLE.GOTO_ROW",name:"Go to Row",shortcut:[ce.CTRL,ue.G],macShortcut:[ce.CMD,ue.G]})},Yv={COMMIT:Fe.createAndAdd({id:"INPUT_TABLE.COMMIT",name:"Commit",shortcut:[ce.CTRL,ue.S],macShortcut:[ce.CMD,ue.S]}),DISCARD:Fe.createAndAdd({id:"INPUT_TABLE.DISCARD",name:"Discard",shortcut:[ce.CTRL,ce.ALT,ue.S],macShortcut:[ce.CMD,ce.OPTION,ue.S]})},Xv={TABLE:qv,INPUT_TABLE:Yv},Kt=Xv;class Zv extends li{irisGrid;constructor(e){super(),this.irisGrid=e}onDown(e){if(Kt.TABLE.REVERSE.matchesEvent(e)){if(!this.irisGrid.isReversible())return!1;const{reverseType:t}=this.irisGrid.state;return t===R.REVERSE_TYPE.NONE?this.irisGrid.reverse(R.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(R.REVERSE_TYPE.NONE),!0}return!1}}const Qv=Zv;class Jv extends li{irisGrid;constructor(e){super(),this.irisGrid=e}onDown(e){return Kt.TABLE.CLEAR_FILTERS.matchesEvent(e)?(this.irisGrid.clearAllFilters(),!0):!1}}const eT=Jv;class tT extends dt{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:a,props:r}=this.irisGrid;if(!o)return null;const{metrics:c}=a,{model:h}=r,{canvasContext:u}=o,m=o.getTheme(),p={context:u,mouseX:e,mouseY:t,metrics:c,model:h,theme:m},{left:g,top:C,width:f,height:S}=i.getCellOverflowButtonPosition(p);return g==null||f==null||C==null||S==null?null:{left:g,top:C,width:f,height:S}}isHoveringOverflowButton(e){const{x:t,y:n}=e,{left:s,top:i,width:o,height:a}=this.getButtonPosition(e)??{};if(s==null||o==null||i==null||a==null)return!1;const{renderer:r,grid:c,state:h,props:u}=this.irisGrid;if(!c)return!1;const{metrics:m}=h,{model:p}=u,{canvasContext:g}=c,C=c.getTheme(),f={context:g,mouseX:t,mouseY:n,metrics:m,model:p,theme:C};return r.shouldRenderOverflowButton(f)&&t>=s&&t<=s+o&&n>=i&&n<=i+a}onMove(e){if(this.isHoveringOverflowButton(e)){const{overflowButtonTooltipProps:t}=this.irisGrid.state,n=this.getButtonPosition(e);it(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 nT=tT;class sT extends dt{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.cursor=n,{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 iT=sT;class oT extends dt{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 aT=oT;class rd extends b.Component{static defaultProps={formatString:"",forwardedProps:{menuItem:{},closeMenu(e){},iconElement:null},placeholder:"",title:"",onChange(e){}};constructor(e=rd.defaultProps){super(e),this.handleInputChange=this.handleInputChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.inputRef=X.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=ef.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 l.jsxs("div",{className:"form-group flex-grow mb-0",children:[l.jsxs("div",{className:"custom-format-title",children:[l.jsx("span",{className:"icon",children:o}),l.jsxs("label",{className:"title mb-0",htmlFor:"custom-format-input",children:[s,i!=null&&l.jsx(tt,{children:i})]})]}),l.jsx("div",{className:"pl-2 pr-2 pb-2",children:l.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 rT=rd;class lT{static isDefaultSelected(e){return!e||![lt.TYPE_CONTEXT_CUSTOM,lt.TYPE_CONTEXT_PRESET].includes(e.type)}static isCustomSelected(e){return e!=null&&e.type===lt.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:l.jsx(rT,{formatString:e.formatString,title:e.label,placeholder:n,onChange:i})}}}const qt=lT;class mn{static dateGroup=10;static timeGroup=20;static dateTimeGroup=30;static getOptions(e,t){const n=new Date,i=[{group:mn.dateGroup,formatString:"yyyy-MM-dd"},{group:mn.dateGroup,formatString:"MM-dd-yyyy"},{group:mn.timeGroup,formatString:"HH:mm:ss"},{group:mn.timeGroup,formatString:"HH:mm:ss.SSS"},{group:mn.timeGroup,formatString:"HH:mm:ss.SSSSSSSSS"},{group:mn.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss"},{group:mn.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSS"},{group:mn.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"}].map(a=>{const r=_e.makeFormat("",a.formatString,_e.TYPE_CONTEXT_PRESET),c=e.getFormattedString(n,R.dataType.DATETIME,"",r);return qt.makeOption(c,r,a.group,_e.isSameFormat(r,t))});return[qt.makeOption("Default",null,mn.dateGroup,qt.isDefaultSelected(t)),...i]}}const dT=mn;class pn{static defaultGroup=10;static presetGroup=20;static presetRoundGroup=30;static customGroup=40;static getOptions(e,t){const n=[{format:Re.FORMAT_PERCENT,group:pn.presetGroup},{format:Re.FORMAT_BASIS_POINTS,group:pn.presetGroup},{format:Re.FORMAT_MILLIONS,group:pn.presetGroup},{format:Re.FORMAT_SCIENTIFIC_NOTATION,group:pn.presetGroup},{format:Re.FORMAT_ROUND,group:pn.presetRoundGroup},{format:Re.FORMAT_ROUND_TWO_DECIMALS,group:pn.presetRoundGroup},{format:Re.FORMAT_ROUND_FOUR_DECIMALS,group:pn.presetRoundGroup}],s=qt.makeOption("Default",null,pn.defaultGroup,qt.isDefaultSelected(e)),i=n.map(c=>qt.makeOption(c.format.label,c.format,c.group,Re.isSameFormat(c.format,e))),o=qt.isCustomSelected(e),a=o?e:Re.makeCustomFormat(),r=qt.makeCustomFormatOption(a,pn.customGroup,Re.DEFAULT_FORMAT_STRING,o,c=>{if(c!=null){const h=Re.makeCustomFormat(c);Re.isValid(h)&&t(h)}else t(null)});return[s,...i,r]}}const cT=pn;class Ri{static defaultGroup=10;static presetGroup=20;static customGroup=30;static getOptions(e,t){const n=[{format:$e.FORMAT_MILLIONS,group:Ri.presetGroup},{format:$e.FORMAT_SCIENTIFIC_NOTATION,group:Ri.presetGroup}],s=qt.makeOption("Default",null,Ri.defaultGroup,qt.isDefaultSelected(e)),i=n.map(c=>qt.makeOption(c.format.label,c.format,c.group,$e.isSameFormat(c.format,e))),o=qt.isCustomSelected(e),a=o?e:$e.makeCustomFormat(),r=qt.makeCustomFormatOption(a,Ri.customGroup,$e.DEFAULT_FORMAT_STRING,o,c=>{if(c!=null){const h=$e.makeCustomFormat(c);$e.isValid(h)&&t(h)}else t(null)});return[s,...i,r]}}const hT=Ri;const Lc=Z.module("IrisGridContextMenuHandler"),uT=150,Pc="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";class Q extends dt{static GROUP_EDIT=ae.groups.high+10;static GROUP_HIDE_COLUMNS=ae.groups.high+25;static GROUP_FILTER=ae.groups.high+50;static GROUP_EXPAND_COLLAPSE=ae.groups.high+55;static GROUP_GOTO=ae.groups.high+60;static GROUP_SORT=ae.groups.high+75;static GROUP_COPY=ae.groups.high+100;static GROUP_FORMAT=ae.groups.high+150;static COLUMN_SORT_DIRECTION={ascending:"ASC",descending:"DESC",none:null};static getQuickFilterCondition(e,t,n){return e&&n==="&&"?e.and(t):e&&n==="||"?e.or(t):t}static getQuickFilterText(e,t,n){return n&&e!=null?`${e} ${n} ${t}`:t}static getOperatorAsText(e){return e==="&&"?"And":"Or"}static getNumberValueEqualsFilter(e,t){const n=e.filter();if(t===Number.POSITIVE_INFINITY)return x.FilterCondition.invoke("isInf",n).and(n.greaterThan(x.FilterValue.ofNumber(0)));if(t===Number.NEGATIVE_INFINITY)return x.FilterCondition.invoke("isInf",n).and(n.lessThan(x.FilterValue.ofNumber(0)));if(Number.isNaN(t))return x.FilterCondition.invoke("isNaN",n);const s=Q.getFilterValueForNumberOrChar(e.type,t);return n.eq(s)}static getFilterValueForNumberOrChar(e,t){return R.isCharType(e)?x.FilterValue.ofString(String.fromCharCode(t)):x.FilterValue.ofNumber(t)}static getRowOptionFormatted(e,t,n=30){return`${e} "${Pt.truncate(t,n-e.length-3)}"`}irisGrid;debouncedUpdateCustomFormat;constructor(e){super(),this.debouncedUpdateCustomFormat=Ye(e.handleFormatSelection,uT),this.irisGrid=e}componentWillUnmount(){this.debouncedUpdateCustomFormat.flush()}getHeaderActions(e,t){const{irisGrid:n}=this,{column:s}=t;M(s);const{model:i}=n.props,{columns:o}=i,a=o[e],r=[],{metrics:c,reverseType:h,quickFilters:u,advancedFilters:m,searchFilter:p}=n.state,g=n.getTheme();M(c);const{filterIconColor:C,filterBarActiveColor:f,contextMenuSortIconColor:S,contextMenuReverseIconColor:v}=g,w=i.sort,T=R.getSortForColumn(w,a.name),y=h!==R.REVERSE_TYPE.NONE,{userColumnWidths:E}=c,I=[...E.values()].some(H=>H===0),F=i.getColumnHeaderParentGroup(e,0)===void 0,N=i.isColumnFrozen(e);return r.push({title:"Hide Column",group:Q.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.hideColumnByVisibleIndex(s)}}),r.push({title:N?"Unfreeze Column":"Freeze Column",group:Q.GROUP_HIDE_COLUMNS,disabled:!F,action:()=>{N?this.irisGrid.unFreezeColumnByColumnName(a.name):this.irisGrid.freezeColumnByColumnName(a.name)},order:10}),r.push({title:"Show All Columns",group:Q.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.showAllColumns()},disabled:!I}),r.push({title:"Quick Filters",icon:Bn,iconColor:f,shortcut:Kt.TABLE.TOGGLE_QUICK_FILTER,group:Q.GROUP_FILTER,order:10,action:()=>{this.irisGrid.toggleFilterBar(s)}}),r.push({title:"Advanced Filters",icon:m.get(e)?Il:xa,iconColor:C,group:Q.GROUP_FILTER,order:20,action:()=>{this.irisGrid.handleAdvancedMenuOpened(s)}}),r.push({title:"Clear Table Filters",group:Q.GROUP_FILTER,order:40,shortcut:Kt.TABLE.CLEAR_FILTERS,action:()=>{this.irisGrid.clearAllFilters()},disabled:!(u.size>0||m.size>0||p!=null)}),r.push({title:"Sort by",icon:Bn,iconColor:S,group:Q.GROUP_SORT,order:10,actions:this.sortByActions(a,e,T)}),r.push({title:"Add Additional Sort",disabled:T&&w.length===1||y&&w.length===1||T&&y&&w.length===2||w.length===0,group:Q.GROUP_SORT,order:20,actions:this.additionalSortActions(a,e)}),r.push({title:"Clear Table Sorting",disabled:w.length===0||y&&w.length===1,group:Q.GROUP_SORT,action:()=>{this.irisGrid.sortColumn(s,Q.COLUMN_SORT_DIRECTION.none)},order:30}),r.push({title:h===R.REVERSE_TYPE.NONE?"Reverse Table":"Clear Reverse Table",icon:Bn,iconColor:v,group:Q.GROUP_SORT,order:40,disabled:!i.isReversible,shortcut:Kt.TABLE.REVERSE,action:()=>{h===R.REVERSE_TYPE.NONE?this.irisGrid.reverse(R.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(R.REVERSE_TYPE.NONE)}}),r.push({title:"Copy Column Name",group:Q.GROUP_COPY,action:()=>{$i(i.textForColumnHeader(e)??"").catch(H=>Lc.error("Unable to copy header",H))}}),R.isDateType(a.type)?r.push({title:"Date/Time Format",group:Q.GROUP_FORMAT,actions:this.dateFormatActions(a)}):R.isNumberType(a.type)&&r.push({title:"Number Format",group:Q.GROUP_FORMAT,actions:this.numberFormatActions(a)??void 0}),r}getCellActions(e,t,n){M(e);const{irisGrid:s}=this,{column:i,row:o}=n,{model:a,canCopy:r}=s.props,{columns:c}=a,h=s.getModelRow(o);M(h);const u=a.valueForCell(e,h),m=a.textForCell(e,h),p=c[e],g=[],{quickFilters:C}=s.state,f=s.getTheme(),{filterIconColor:S}=f,{settings:v}=s.props,w=new _e({timeZone:v?.timeZone,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:Pc}),T=new _e({timeZone:v?.timeZone,showTimeZone:v?.showTimeZone,showTSeparator:v?.showTSeparator,defaultDateTimeFormatString:Pc});if(p==null||o==null)return g;if(a.isFilterable(e)){const E={title:"Filter by Value",icon:Bn,iconColor:S,group:Q.GROUP_FILTER,order:10,actions:[]};if(u==null)C.get(e)&&E.actions.push({title:"And",actions:this.nullFilterActions(p,C.get(e),"&&"),order:2,group:ae.groups.high}),E.actions.push(...this.nullFilterActions(p));else if(R.isBooleanType(p.type))C.get(e)&&E.actions.push({title:"Or",actions:this.booleanFilterActions(p,m,C.get(e),"||"),order:2,group:ae.groups.high}),E.actions.push(...this.booleanFilterActions(p,m));else if(R.isNumberType(p.type)||R.isCharType(p.type)){M(e);const I=R.isCharType(p.type)?String.fromCharCode(u):`${u}`;C.get(e)&&E.actions.push({title:"And",actions:this.numberFilterActions(p,I,u,C.get(e),"&&"),order:2,group:ae.groups.high}),E.actions.push(...this.numberFilterActions(p,I,u,C.get(e)))}else if(R.isDateType(p.type)){const I=w.format(u),F=T.format(u);C.get(e)&&E.actions.push({title:"And",actions:this.dateFilterActions(p,I,F,u,C.get(e),"&&"),order:2,group:ae.groups.high}),E.actions.push(...this.dateFilterActions(p,I,F,u,C.get(e)))}else C.get(e)&&E.actions.push({title:"And",actions:this.stringFilterActions(p,m,u,C.get(e),"&&"),order:2,group:ae.groups.high}),E.actions.push(...this.stringFilterActions(p,m,u));E.actions!=null&&E.actions.length>0&&g.push(E)}if(ze(a)&&a.isRowExpandable(h)){const E=a.groupedColumns.length>0?a.depthForRow(h)-1:0,F=a.valueForCell(E,h)==null?"null":a.textForCell(E,h);g.push({title:Q.getRowOptionFormatted(a.isRowExpanded(h)?"Collapse":"Expand",F),group:Q.GROUP_EXPAND_COLLAPSE,order:10,action:()=>{a.setRowExpanded(h,!a.isRowExpanded(h))}}),a.isExpandAllAvailable===!0&&g.push({title:Q.getRowOptionFormatted("Expand All in",F),group:Q.GROUP_EXPAND_COLLAPSE,order:20,action:()=>{a.setRowExpanded(h,!0,!0)}})}ze(a)&&a.hasExpandableRows&&a.isExpandAllAvailable===!0&&(g.push({title:"Expand Entire Table",group:Q.GROUP_EXPAND_COLLAPSE,order:30,action:()=>{a.expandAll()}}),g.push({title:"Collapse Entire Table",group:Q.GROUP_EXPAND_COLLAPSE,order:40,action:()=>{a.collapseAll()}}));const y={title:"Go to",iconColor:S,shortcut:Kt.TABLE.GOTO_ROW,group:Q.GROUP_GOTO,order:10,action:()=>this.irisGrid.toggleGotoRow(`${o+1}`,`${u}`,p.name)};return g.push(y),r&&(g.push({title:"Copy Cell",group:Q.GROUP_COPY,order:10,action:()=>{s.copyCell(i,o)}}),g.push({title:"Copy Cell Unformatted",group:Q.GROUP_COPY,order:20,action:()=>{s.copyCell(i,o,!0)}})),g}onContextMenu(e,t,n){const{irisGrid:s}=this,{y:i,column:o,row:a,columnHeaderDepth:r}=e,c=s.getModelColumn(o),h=s.getModelRow(a),{model:u,canCopy:m}=s.props,{columns:p}=u,{metrics:g,isFilterBarShown:C,quickFilters:f,advancedFilters:S,selectedRanges:v}=s.state;M(g);const{columnHeaderHeight:w,gridY:T,columnHeaderMaxDepth:y}=g,E=[];if(c!=null&&h!=null){const I=u.valueForCell(c,h),F=u.textForCell(c,h),N=p[c],{onContextMenu:H}=s.props;N!=null&&E.push(H({model:u,value:I,valueText:F,column:N,rowIndex:a,columnIndex:o,modelRow:h,modelColumn:c}))}return c!=null&&u.isFilterable(c)&&E.push({title:"Clear Column Filter",group:Q.GROUP_FILTER,order:30,action:()=>{this.irisGrid.removeColumnFilter(c)},disabled:!(f.has(c)||S.has(c))}),(C?i<=T:i<=w*y&&r===0)?c!=null&&E.push(...this.getHeaderActions(c,e)):(c!=null&&h!=null&&E.push(...this.getCellActions(c,t,e)),m&&v.length>0&&(E.push({title:"Copy Selection",shortcut:es.COPY,group:Q.GROUP_COPY,order:30,action:()=>{s.copyRanges(v)}}),E.push({title:"Copy Selection w/ Headers",group:Q.GROUP_COPY,order:40,action:()=>{s.copyRanges(v,!0)}})),Ze(u)&&u.isEditable&&v.length>0&&E.push({title:"Delete Selected Rows",group:Q.GROUP_EDIT,order:50,action:()=>{this.irisGrid.deleteRanges(v)}})),E.length===0?!1:(M(s.gridWrapper),ae.triggerMenu(s.gridWrapper,n.pageX,n.pageY,E),!0)}dateFormatActions(e){const{model:t}=this.irisGrid.props,{formatter:n}=t,s=n.getColumnFormat(e.type,e.name),i=dT.getOptions(n,s),o=[];for(let a=0;a<i.length;a+=1){const{description:r,format:c,group:h,isSelected:u,title:m}=i[a];o.push({title:m,description:r,icon:u?Xn:void 0,group:h,order:a,action:()=>{const p=t.getColumnIndexByName(e.name);M(p),this.irisGrid.handleFormatSelection(p,c)}})}return o}numberFormatActions(e){const{model:t}=this.irisGrid.props,{formatter:n}=t,s=n.getColumnFormat(e.type,e.name);let i;const o=t.getColumnIndexByName(e.name);if(R.isDecimalType(e.type))i=cT.getOptions(s,r=>{M(o),this.debouncedUpdateCustomFormat(o,r)});else if(R.isIntegerType(e.type))i=hT.getOptions(s,r=>{M(o),this.debouncedUpdateCustomFormat(o,r)});else return Lc.error("Invalid column type in numberFormatActions"),null;const a=[];for(let r=0;r<i.length;r+=1){const{format:c,isSelected:h}=i[r];a.push({...i[r],icon:h?Xn:void 0,order:r,action:()=>{o===void 0&&c&&c.type===lt.TYPE_CONTEXT_CUSTOM||(M(o),this.irisGrid.handleFormatSelection(o,c))}})}return a}stringFilterActions(e,t,n,s,i){const o=x.FilterValue.ofString(n);let a=s;a||(a={filter:null,text:null});const{filter:r,text:c}=a,h=[],{model:u}=this.irisGrid.props,m=u.getColumnIndexByName(e.name);return M(m),h.push({menuElement:l.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[i?Q.getOperatorAsText(i):""," ",'"',t,'"']}),order:1,group:ae.groups.high}),h.push({title:"text is exactly",description:`Show only rows where ${e.name} is ${n} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(m,Q.getQuickFilterCondition(r,e.filter().eq(o),i),Q.getQuickFilterText(c,`=${t}`,i))},order:10,group:ae.groups.low}),h.push({title:"text is not exactly",description:`Show only rows where ${e.name} is not ${t} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(m,Q.getQuickFilterCondition(r,e.filter().notEq(o),i),Q.getQuickFilterText(c,`!=${t}`,i))},order:20,group:ae.groups.low}),h.push({title:"text contains",description:`Show only rows where ${e.name} contains ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,Q.getQuickFilterCondition(r,e.filter().contains(o),i),Q.getQuickFilterText(c,`~${t}`,i))},order:30,group:ae.groups.low}),h.push({title:"text does not contain",description:`Show only rows where ${e.name} does not contain ${n}`,action:()=>{this.irisGrid.setQuickFilter(m,Q.getQuickFilterCondition(r,e.filter().contains(o).not(),i),Q.getQuickFilterText(c,`!~${t}`,i))},order:40,group:ae.groups.low}),h.push({title:"text starts with",description:`Show only rows where ${e.name} starts with ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,Q.getQuickFilterCondition(r,e.filter().invoke("startsWith",o),i),Q.getQuickFilterText(c,`${t}*`,i))},order:50,group:ae.groups.low}),h.push({title:"text ends with",description:`Show only rows where ${e.name} ends with ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,Q.getQuickFilterCondition(r,e.filter().invoke("endsWith",o),i),Q.getQuickFilterText(c,`*${t}`,i))},order:60,group:ae.groups.low}),h}numberFilterActions(e,t,n,s,i){const o=Q.getFilterValueForNumberOrChar(e.type,n);let a=null,r=null;s&&(a=s.filter,r=s.text);const c=[],h=n!==Number.POSITIVE_INFINITY&&n!==Number.NEGATIVE_INFINITY&&!Number.isNaN(n),{model:u}=this.irisGrid.props,m=u.getColumnIndexByName(e.name);return M(m),c.push({menuElement:l.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[i?Q.getOperatorAsText(i):""," ",'"',t,'"']}),order:1,group:ae.groups.high}),c.push({title:"is equal to",description:`Show only rows where ${e.name} is ${t}`,action:()=>{const p=Q.getNumberValueEqualsFilter(e,n);this.irisGrid.setQuickFilter(m,Q.getQuickFilterCondition(a,p,i),Q.getQuickFilterText(r,`=${t}`,i))},order:10,group:ae.groups.low}),c.push({title:"is not equal to",description:`Show only rows where ${e.name} is not ${t}`,action:()=>{const p=Q.getNumberValueEqualsFilter(e,n).not();this.irisGrid.setQuickFilter(m,Q.getQuickFilterCondition(a,p,i),Q.getQuickFilterText(r,`!=${t}`,i))},order:20,group:ae.groups.low}),h&&!R.isCharType(e.type)&&(c.push({title:"greater than",description:`Show only rows where ${e.name} is greater than ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,Q.getQuickFilterCondition(a,e.filter().greaterThan(o),i),Q.getQuickFilterText(r,`>${t}`,i))},order:30,group:ae.groups.low}),c.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,Q.getQuickFilterCondition(a,e.filter().greaterThanOrEqualTo(o),i),Q.getQuickFilterText(r,`>=${t}`,i))},order:40,group:ae.groups.low}),c.push({title:"less than",description:`Show only rows where ${e.name} is less than ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,Q.getQuickFilterCondition(a,e.filter().lessThan(o),i),Q.getQuickFilterText(r,`<${t}`,i))},order:50,group:ae.groups.low}),c.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,Q.getQuickFilterCondition(a,e.filter().lessThanOrEqualTo(o),i),Q.getQuickFilterText(r,`<=${t}`,i))},order:60,group:ae.groups.low})),c}booleanFilterActions(e,t,n,s){const i=[],{model:o}=this.irisGrid.props,{filter:a,text:r}=n||{},c=o.getColumnIndexByName(e.name);return M(c),i.push({menuElement:l.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[s?Q.getOperatorAsText(s):""," ",'"',t??"null",'"']}),order:1,group:ae.groups.high}),i.push({title:"true",description:`Show only rows where ${e.name} is true`,action:()=>{this.irisGrid.setQuickFilter(c,Q.getQuickFilterCondition(a,e.filter().isTrue(),s),Q.getQuickFilterText(r,"true",s))},order:10,group:ae.groups.low}),i.push({title:"false",description:`Show only rows where ${e.name} is false`,action:()=>{this.irisGrid.setQuickFilter(c,Q.getQuickFilterCondition(a,e.filter().isFalse(),s),Q.getQuickFilterText(r,"false",s))},order:20,group:ae.groups.low}),i.push({title:"is null",description:`Show only rows where ${e.name} is null`,action:()=>{this.irisGrid.setQuickFilter(c,Q.getQuickFilterCondition(a,e.filter().isNull(),s),Q.getQuickFilterText(r,"null",s))},order:30,group:ae.groups.low}),i.push({title:"is not null",description:`Show only rows where ${e.name} is not null`,action:()=>{this.irisGrid.setQuickFilter(c,Q.getQuickFilterCondition(a,e.filter().isNull().not(),s),Q.getQuickFilterText(r,"!null",s))},order:40,group:ae.groups.low}),i}dateFilterActions(e,t,n,s,i,o){const a=x.FilterValue.ofNumber(s);let r=null,c=null;i&&(r=i.filter,c=i.text);const{model:h}=this.irisGrid.props,u=h.getColumnIndexByName(e.name);M(u);const m=[];return m.push({menuElement:l.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[o?Q.getOperatorAsText(o):""," ",'"',n,'"']}),order:1,group:ae.groups.high}),m.push({title:"date is",description:`Show only rows where ${e.name} is ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,Q.getQuickFilterCondition(r,e.filter().eq(a),o),Q.getQuickFilterText(c,`=${t}`,o))},order:10,group:ae.groups.low}),m.push({title:"date is not",description:`Show only rows where ${e.name} is not ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,Q.getQuickFilterCondition(r,e.filter().notEq(a),o),Q.getQuickFilterText(c,`!=${t}`,o))},order:20,group:ae.groups.low}),m.push({title:"date is before",description:`Show only rows where ${e.name} is before ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,Q.getQuickFilterCondition(r,e.filter().lessThan(a),o),Q.getQuickFilterText(c,`<${t}`,o))},order:30,group:ae.groups.low}),m.push({title:"date is before or equal",description:`Show only rows where ${e.name} is before or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,Q.getQuickFilterCondition(r,e.filter().lessThanOrEqualTo(a),o),Q.getQuickFilterText(c,`<=${t}`,o))},order:40,group:ae.groups.low}),m.push({title:"date is after",description:`Show only rows where ${e.name} is greater than ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,Q.getQuickFilterCondition(r,e.filter().greaterThan(a),o),Q.getQuickFilterText(c,`>${t}`,o))},order:50,group:ae.groups.low}),m.push({title:"date is after or equal",description:`Show only rows where ${e.name} is after or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,Q.getQuickFilterCondition(r,e.filter().greaterThanOrEqualTo(a),o),Q.getQuickFilterText(c,`>=${t}`,o))},order:60,group:ae.groups.low}),m}nullFilterActions(e,t,n){let s=null,i=null;t&&(s=t.filter,i=t.text);const o=[],{model:a}=this.irisGrid.props,r=a.getColumnIndexByName(e.name);return M(r),o.push({menuElement:l.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[n?Q.getOperatorAsText(n):""," ",'"null"']}),order:1,group:ae.groups.high}),o.push({title:"is null",description:`Show only rows where ${e.name} is null`,action:()=>{this.irisGrid.setQuickFilter(r,Q.getQuickFilterCondition(s,e.filter().isNull(),n),Q.getQuickFilterText(i,"null",n))},order:10,group:ae.groups.low}),o.push({title:"is not null",description:`Show only rows where ${e.name} is not null`,action:()=>{this.irisGrid.setQuickFilter(r,Q.getQuickFilterCondition(s,e.filter().isNull().not(),n),Q.getQuickFilterText(i,"!null",n))},order:20,group:ae.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,Q.COLUMN_SORT_DIRECTION.ascending)},icon:this.checkColumnSort(n,Q.COLUMN_SORT_DIRECTION.ascending)?Bn:void 0,iconColor:i},{title:`${e.name} Descending`,order:20,action:()=>{this.irisGrid.sortColumn(t,Q.COLUMN_SORT_DIRECTION.descending)},icon:this.checkColumnSort(n,Q.COLUMN_SORT_DIRECTION.descending)?Bn:void 0,iconColor:i},{title:"Remove Sort",order:50,action:()=>{this.irisGrid.sortColumn(t,Q.COLUMN_SORT_DIRECTION.none,!1,!0)},disabled:!n}];return R.isNumberType(e.type)&&(o.push({title:`ABS(${e.name}) Ascending`,order:30,action:()=>{this.irisGrid.sortColumn(t,Q.COLUMN_SORT_DIRECTION.ascending,!0)},icon:this.checkColumnSort(n,Q.COLUMN_SORT_DIRECTION.ascending,!0)?Bn:void 0,iconColor:i}),o.push({title:`ABS(${e.name}) Descending`,order:40,action:()=>{this.irisGrid.sortColumn(t,Q.COLUMN_SORT_DIRECTION.descending,!0)},icon:this.checkColumnSort(n,Q.COLUMN_SORT_DIRECTION.descending,!0)?Bn:void 0,iconColor:i})),o}additionalSortActions(e,t){const n=this.irisGrid.getTheme(),{contextMenuSortIconColor:s}=n,i=[{title:"Add Sort By",menuElement:l.jsxs("div",{className:"btn-context-menu menu-title",children:[l.jsx("span",{className:"icon",children:l.jsx(J,{icon:Bn,style:{color:s??void 0}})}),l.jsx("span",{className:"title",children:"Add Additional Sort"}),l.jsx("span",{className:"shortcut",children:He.isMacPlatform()?"⌘Click":"Ctrl+Click"})]}),order:1},{title:`${e.name} Ascending`,order:10,action:()=>{this.irisGrid.sortColumn(t,Q.COLUMN_SORT_DIRECTION.ascending,!1,!0)}},{title:`${e.name} Descending`,order:20,action:()=>{this.irisGrid.sortColumn(t,Q.COLUMN_SORT_DIRECTION.descending,!1,!0)}}];return R.isNumberType(e.type)&&(i.push({title:`ABS(${e.name}) Ascending`,order:30,action:()=>{this.irisGrid.sortColumn(t,Q.COLUMN_SORT_DIRECTION.ascending,!0,!0)}}),i.push({title:`ABS(${e.name}) Descending`,order:40,action:()=>{this.irisGrid.sortColumn(t,Q.COLUMN_SORT_DIRECTION.descending,!0,!0)}})),i}checkColumnSort(e,t=null,n=!1){return e?e.direction===t&&e.isAbs===n:!1}}const mT=Q;class pT extends dt{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 gT=pT;class fT extends dt{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:a}=o,r=this.irisGrid.getTheme();if(i&&r.columnHeaderHeight!=null&&r.filterBarHeight!=null&&t>r.columnHeaderHeight*a&&t<=r.columnHeaderHeight*a+r.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:a}=o,r=this.irisGrid.getTheme();let c=null;return s&&r.columnHeaderHeight!=null&&r.filterBarHeight!=null&&n!==null&&t>=r.columnHeaderHeight*a&&t<=r.columnHeaderHeight*a+r.filterBarHeight&&(c=n),c!==i&&this.irisGrid.setState({hoverAdvancedFilter:c}),!1}onLeave(e){const{column:t}=e,{hoverAdvancedFilter:n}=this.irisGrid.state;return n!==null&&t!==n&&this.irisGrid.setState({hoverAdvancedFilter:null}),!1}}const CT=fT;class ST extends dt{irisGrid;constructor(e){super(750),this.irisGrid=e}destroyTooltip(){this.irisGrid.setState({expandCellTooltipProps:null})}setCursor(e,t){return Bi.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:a,props:r}=this.irisGrid;if(!o)return null;const{metrics:c}=a,{model:h}=r,{canvasContext:u}=o,m=o.getTheme(),p={context:u,mouseX:e,mouseY:t,metrics:c,model:h,theme:m},g=ze(h)?h.depthForRow(s):null,{left:C,top:f,width:S,height:v}=i.getExpandButtonPosition(p,g);return C==null||S==null||f==null||v==null?null:{left:C,top:f,width:S,height:v}}onMove(e,t){if(Bi.isInTreeBox(e,t)){const{expandCellTooltipProps:n}=this.irisGrid.state,{model:s}=this.irisGrid.props,i=this.getButtonPosition(e),{row:o}=e;M(o);const a=ze(s)&&s.isRowExpanded(o);it(n,i)||this.irisGrid.setState({expandCellTooltipProps:i,expandTooltipDisplayValue:a?"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 bT=ST;class wT extends dt{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=He.isModifierKeyDown(n);return this.irisGrid.toggleSort(s,i),!0}return!1}}const vT=wT;class TT extends dt{constructor(e){super(),this.irisGrid=e}onWheel(e,t,n){const{irisGrid:s}=this,{model:i}=s.props,{metrics:o,pendingRowCount:a}=s.state;M(o);const{bottom:r,rowCount:c,rowHeight:h}=o,{deltaY:u}=B.getScrollDelta(n);return Ze(i)&&i.isEditable&&r>=c-1&&u>0&&s.setState({pendingRowCount:a+Math.ceil(u/h)}),!1}}const ET=TT;class yT extends dt{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:a,metrics:r}=t;if(n==null||s==null||r==null)return this.currentLinkBox=void 0,!1;if(this.currentLinkBox!=null){const{x1:u,y1:m,x2:p,y2:g}=this.currentLinkBox;if(i>=u&&i<=p&&o>=m&&o<=g)return!0}const c=t.updateRenderState(),h=a.getTokenBoxesForVisibleCell(n,s,c);for(let u=0;u<h.length;u+=1)if(_a(h[u].token)){const m=B.translateTokenBox(h[u],r),{x1:p,x2:g,y1:C,y2:f}=m;if(i>=p&&i<=g&&o>=C&&o<=f)return this.currentLinkBox=m,!0}return this.currentLinkBox=void 0,!1}setCursor(e,t){return this.isHoveringLink(e,t)?(this.cursor="pointer",{stopPropagation:!1,preventDefault:!1}):(this.cursor=null,!1)}onMove(e,t){if(this.isHoveringLink(e,t)&&this.currentLinkBox!=null&&_a(this.currentLinkBox.token)){const{linkHoverTooltipProps:s}=this.irisGrid.state;if(this.currentLinkBox==null)return!1;const{x1:i,y1:o,x2:a,y2:r}=this.currentLinkBox,{href:c}=this.currentLinkBox.token,h=a-i,u=r-o,m={left:i,top:o+1,width:h,height:u};it(s,m)||this.irisGrid.setState({linkHoverTooltipProps:m,linkHoverDisplayValue:c})}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 xT=yT,RT=3e3;function IT({children:d=null,onEntering:e,onEntered:t,onExiting:n,onExited:s}){const[i,o]=b.useState(!1),a=b.useRef(),r=ir(d),c=b.useCallback(()=>{o(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{o(!1)},RT)},[o,a]);return b.useEffect(()=>{r!==d&&d!=null&&c()},[d,r,o,c]),b.useEffect(()=>()=>a.current?clearTimeout(a.current):void 0,[]),l.jsx(br,{className:"toast-bottom-bar",isShown:i,onEntering:e,onEntered:t,onExiting:n,onExited:s,children:d})}class DT extends Po{getGridY(e){let t=super.getGridY(e);const{isFilterBarShown:n,theme:s,advancedFilters:i,quickFilters:o,sorts:a,reverseType:r}=e;return n?t+=s.filterBarHeight:(o!=null&&o.size>0||i!=null&&i.size>0)&&(t+=s.filterBarCollapsedHeight),r!==R.REVERSE_TYPE.NONE&&a!=null&&a.length>0&&(t+=s.reverseHeaderBarHeight),t}getUserColumnWidths(){return this.userColumnWidths}}const FT=DT,NT=1,sm=X.memo(({model:d,modelColumns:e,top:t,bottom:n,left:s,right:i,filter:o,formatter:a,reverseType:r=R.REVERSE_TYPE.NONE,sorts:c,customColumns:h,movedColumns:u,hiddenColumns:m,alwaysFetchColumns:p,rollupConfig:g=null,totalsConfig:C=null,selectDistinctColumns:f=De,pendingRowCount:S=0,pendingDataMap:v=Gn,frozenColumns:w,formatColumns:T,columnHeaderGroups:y})=>{const E=b.useMemo(()=>be.getModelViewportColumns(e,s,i,u,m,p,NT),[e,s,i,u,m,p]);return b.useEffect(function(){d.filter=o},[d,o]),b.useEffect(function(){const F=[...c];r!==R.REVERSE_TYPE.NONE&&F.push(x.Table.reverse()),d.sort=F},[d,c,r]),b.useEffect(function(){d.formatter=a},[d,a]),b.useEffect(function(){d.isCustomColumnsAvailable&&(d.customColumns=h)},[d,h]),b.useEffect(function(){d.isFormatColumnsAvailable&&(d.formatColumns=T)},[d,T]),b.useEffect(function(){d.setViewport(t,n,E)},[d,t,n,E]),b.useEffect(function(){d.isRollupAvailable&&(d.rollupConfig=g)},[d,d.isRollupAvailable,g]),b.useEffect(function(){d.isSelectDistinctAvailable&&(d.selectDistinctColumns=f)},[d,f]),b.useEffect(function(){d.isTotalsAvailable&&(d.totalsConfig=C)},[d,d.isTotalsAvailable,C]),b.useEffect(function(){d.pendingRowCount=S},[d,S]),b.useEffect(function(){d.pendingDataMap=v},[d,v]),b.useEffect(function(){w&&d.updateFrozenColumns(w)},[d,w]),b.useEffect(function(){d.columnHeaderGroups=y},[d,y]),null});sm.displayName="IrisGridModelUpdater";const MT=sm,xn=Object.freeze({SORT_UP:"sortUp",SORT_DOWN:"sortDown",CARET_DOWN:"caretDown",CARET_RIGHT:"caretRight",CELL_OVERFLOW:"cellOverflow"}),_c=10,Ur=16;class bo extends Pt{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(xn.SORT_UP,Pp),this.setIcon(xn.SORT_DOWN,_p),this.setIcon(xn.CARET_DOWN,kn),this.setIcon(xn.CARET_RIGHT,Ih),this.setIcon(xn.CELL_OVERFLOW,jp)}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:Ur/t.icon[0],d:Ur/t.icon[1]};i.addPath(s,o),this.icons[e]=i}getIcon(e){return this.icons[e]}getSortIcon(e){return e?e.direction===R.sortDirection.ascending?this.getIcon(xn.SORT_UP):e.direction===R.sortDirection.descending?this.getIcon(xn.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:a,modelRows:r}=i,c=_(r,s),h=a.get(n);if(h===void 0)return;const u=o.valueForCell(h,c);if(R.isTextType(o.columns[h]?.type)&&(u===null||u==="")){const m=e.font;e.font=`italic ${m}`;const p=u===null?"null":"empty";super.drawCellContent(e,t,n,s,p),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:a,allColumnWidths:r,allColumnXs:c}=n;if(o.length===0||i.groupedColumnDividerColor==null)return;const h=o.length-1,u=c.get(h),m=r.get(h);if(u==null||m==null)return;const p=u+m+.5;e.strokeStyle=i.groupedColumnDividerColor,e.lineWidth=1,e.beginPath(),e.moveTo(p,0),e.lineTo(p,a),e.stroke()}drawPendingRowLine(e,t){const{metrics:n,model:s,theme:i}=t,{allRowYs:o,maxX:a}=n,{pendingRowCount:r}=s;if(r<=0)return;const c=s.rowCount-s.pendingRowCount-s.floatingBottomRowCount;let h=o.get(c);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(a,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:a,maxY:r}=s,c=a.get(i),h=o.get(i);M(c),M(h),e.fillStyle=n.linkerColumnHoverBackgroundColor,e.fillRect(c,0,h,r)}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:a,gridY:r}=s,{scrimBlurSize:c,scrimColor:h}=i;t.save(),t.globalCompositeOperation="color",t.filter=`blur(${c}px)`,h!=null&&(t.fillStyle=h),t.beginPath(),t.rect(0,r,o,a-r),t.clip(),t.fillRect(-c,-c+r,c*2+o,(c*2+(a-r))*n),t.globalCompositeOperation="overlay",t.filter=`blur(${c}px) opacity(15%)`,t.fillRect(-c,-c+r,c*2+o,(c*2+(a-r))*n),t.restore()}drawColumnHeaders(e,t){super.drawColumnHeaders(e,t);const{theme:n,metrics:s,model:i,reverseType:o}=t,{columnHeaderHeight:a}=s;if(this.drawFilterHeaders(e,t),a<=0)return;const{sort:r}=i;if(r.length===1){const c=o!==R.REVERSE_TYPE.NONE;let h;c?h=n.headerReverseBarColor:h=n.headerSortBarColor,this.drawHeaderBar(e,t,h,c?n.reverseHeaderBarHeight:n.sortHeaderBarHeight)}else r.length>1&&(o!==R.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:a,model:r}=t,{columnHeaderHeight:c,width:h}=a;let u=0;i||(u=s),e.fillStyle=o.headerBarCasingColor,e.fillRect(0,r.columnHeaderMaxDepth*c-s-2+u,h,s+2),e.fillStyle=n,e.fillRect(0,r.columnHeaderMaxDepth*c-s-1+u,h,s)}drawColumnHeadersAtDepth(e,t,n,s,i){const{metrics:o,model:a,isMenuShown:r}=t,{columnHeaderMaxDepth:c}=a,{width:h}=o,u={...s,maxX:i===c-1&&s.maxX===h?h-(r?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:a}=t,{modelColumns:r,allColumnWidths:c,allColumnXs:h,gridX:u,columnHeaderHeight:m,fontWidths:p}=i,{headerHorizontalPadding:g}=a,C=_(c,n,0),f=_(h,n)+u,S=r.get(n);if(S==null)return;const v=o.columns[S]?.name;if(v==null)return;const w=R.getSortForColumn(o.sort,v);if(!w)return;const T=this.getSortIcon(w);if(!T)return;const y=o.textForColumnHeader(S);if(y===void 0)return;const E=p.get(e.font)??Pt.DEFAULT_FONT_WIDTH;M(E);const I=y.length*E,F=u+f+I+g;let{maxX:N}=s;N-=g;const H=u+f+C-g-1,P=F>N?F+1:Math.min(N,H),O=w.direction===R.sortDirection.ascending?-6:-12,k=m*.5+O;e.save(),e.beginPath(),e.rect(f,0,C,m),e.clip(),e.fillStyle=a.headerSortBarColor,e.translate(P,k),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:a}=t,{filterBarHeight:r}=i;if(r<=0)return;const{gridX:c,gridY:h,maxX:u,modelColumns:m,visibleColumns:p,allColumnWidths:g,allColumnXs:C}=n,f=h-r;e.save(),e.font=i.font,e.textAlign="left",o!=null&&o.size>0||a!=null&&a.size>0?e.fillStyle=i.filterBarExpandedActiveBackgroundColor:e.fillStyle=i.filterBarExpandedBackgroundColor,e.fillRect(c,f,u,r-1),e.fillStyle=i.headerBarCasingColor,e.fillRect(c,f+r-1,u,1);const S=f;e.strokeStyle=i.filterBarSeparatorColor,e.beginPath();for(let v=0;v<p.length;v+=1){const w=p[v],T=_(m,w),y=_(C,w),E=_(g,w);if(s.isFilterable(T)&&E>0){const I=c+(y??0);e.rect(I+.5,S+.5,E,r-2)}}e.stroke();for(let v=0;v<p.length;v+=1){const w=p[v],T=_(g,w),E=_(C,w)+c;this.drawExpandedFilterHeader(e,t,w,E,T)}e.restore()}drawExpandedFilterHeader(e,t,n,s,i){if(i<=0)return;const{metrics:o,theme:a,quickFilters:r,advancedFilters:c}=t,{modelColumns:h,gridY:u}=o,{filterBarHeight:m,filterBarExpandedActiveCellBackgroundColor:p,filterBarErrorColor:g,filterBarHorizontalPadding:C,headerColor:f}=a,S=u-m,v=h.get(n);if(v===void 0)return;const w=r.get(v),T=c.get(v);if(w==null&&T==null)return;let y=null;if(w!=null){const{text:I}=w;if(y=I,y||(y=R.getFilterText(w.filter)),y!=null){const{fontWidths:F}=o;let N=F.get(e.font);(N==null||N===0)&&(N=e.measureText("8").width,N||(N=10));const H=(i-C*2)/N;H<=0?y="":y.length>H&&(y=`${y.substring(0,H-1)}…`)}}if(e.save(),bo.isFilterValid(T,w)&&p!=null)e.fillStyle=p,e.fillRect(s+1,S+1,i-1,m-3);else if(g!=null){e.fillStyle=g,e.lineWidth=2,e.strokeStyle=g;const I=s+2,F=S+2,N=i-3,H=m-5;e.strokeRect(I,F,N,H)}if(y!=null&&y!==""){const I=s+C,F=S+m*.5+1;e.fillStyle=f,e.fillText(y,I,F)}e.restore()}drawCollapsedFilterHeaders(e,t){const{metrics:n,theme:s}=t,{headerSeparatorColor:i,filterBarCollapsedHeight:o}=s;if(o<=0)return;const{gridX:a,gridY:r,maxX:c,visibleColumns:h,allColumnWidths:u,allColumnXs:m}=n,p=r-o;e.save(),e.fillStyle=i,e.fillRect(a,p,c,o);for(let g=0;g<h.length;g+=1){const C=h[g],f=u.get(C),S=m.get(C);if(S!=null&&f!=null){const v=S+a;this.drawCollapsedFilterHeader(e,t,C,v,f)}}e.restore()}drawCollapsedFilterHeader(e,t,n,s,i){if(i<=0)return;const{metrics:o,theme:a,quickFilters:r,advancedFilters:c}=t,{modelColumns:h,gridY:u}=o,m=h.get(n);if(m===void 0)return;const p=r.get(m),g=c.get(m),{filterBarCollapsedHeight:C,filterBarActiveColor:f,filterBarActiveBackgroundColor:S,filterBarErrorColor:v}=a;e.save();const w=bo.isFilterValid(g,p);S!=null&&p==null&&g==null?e.fillStyle=S:f!=null&&w?e.fillStyle=f:v!=null&&(e.fillStyle=v);const T=s+1,y=u-C,E=i-1,I=C-1;e.fillRect(T,y,E,I),e.restore()}drawTreeMarker(e,t,n,s,i,o,a){e.save();const{x1:r,y1:c}=i,h=a?this.getIcon(xn.CARET_DOWN):this.getIcon(xn.CARET_RIGHT),u=n+r-2,m=s+c+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:a}=t,{gridY:r,gridX:c,maxX:h,modelRows:u,floatingTopHeight:m,floatingBottomHeight:p,floatingRows:g,rowFooterWidth:C,height:f,horizontalBarHeight:S,verticalBarWidth:v,allRowHeights:w,allRowYs:T,width:y}=n;if(C<=0||g.length===0)return;const{cellHorizontalPadding:E,floatingGridRowColor:I,floatingRowBackgroundColors:F,headerColor:N,rowHoverBackgroundColor:H}=a;e.translate(c,r),e.beginPath();const P=Math.min(h,y-C-v-c);e.fillStyle=F,m>0&&e.rect(P,0,C,m),p>0&&e.rect(P,f-r-S-p,C,p),e.fill();const O=i!=null&&o!=null&&i>=c&&i<=h+C?B.getRowAtY(o,n):null;if(H!=null&&O!==null&&g.includes(O)){e.fillStyle=H;const L=T.get(O),A=w.get(O);M(L),M(A),e.fillRect(P,L,C,A)}if(e.beginPath(),I!=null&&(e.strokeStyle=I),m>0&&(e.moveTo(P+.5,.5),e.lineTo(P+.5,m-.5)),p>0){const L=f-r-S-p;e.moveTo(P-.5,L+.5),e.lineTo(P-.5,L+p-.5)}e.stroke(),e.fillStyle=N,e.textAlign="left";const k=P+E;for(let L=0;L<g.length;L+=1){const A=g[L],U=w.get(A),j=T.get(A),W=u.get(A);if(j!=null&&U!=null&&W!=null){const ie=j+U*.5;e.fillText(s.textForRowFooter(W),k,ie)}}e.translate(-c,-r)}getTextRenderMetrics(e,t,n){const s=super.getTextRenderMetrics(e,t,n),{mouseX:i,mouseY:o,metrics:a}=e;if(i==null||o==null)return s;const{column:r,row:c}=B.getGridPointFromXY(i,o,a);if(t===r&&n===c){const{left:h}=this.getCellOverflowButtonPosition(e);this.shouldRenderOverflowButton(e)&&h!=null&&(s.width=h-a.gridX-s.x)}return s}shouldRenderOverflowButton(e){const{context:t,mouseX:n,mouseY:s,metrics:i,model:o,theme:a}=e;if(n==null||s==null)return!1;const{row:r,column:c,modelRow:h,modelColumn:u}=B.getCellInfoFromXY(n,s,i);if(r==null||c==null||h==null||u==null||!R.isStringType(o.columns[u].type))return!1;const m=o.textForCell(u,h)??"",{width:p}=super.getTextRenderMetrics(e,c,r),g=i.fontWidths.get(a.font)??bo.DEFAULT_FONT_WIDTH;t.save(),t.font=a.font;const C=this.getCachedTruncatedString(t,m,p,g,o.truncationCharForCell(u,h));return t.restore(),m!==""&&C!==m}getCellOverflowButtonPosition({mouseX:e,mouseY:t,metrics:n,theme:s}){const i={left:null,top:null,width:null,height:null};if(e==null||t==null||!n)return i;const{rowHeight:o,columnWidth:a,left:r,top:c}=B.getCellInfoFromXY(e,t,n);M(r),M(a),M(c);const{width:h,verticalBarWidth:u}=n,{cellHorizontalPadding:m}=s,p=Ur+2*m,g=o,f=Math.min(n.gridX+r+a,h-u)-p,S=n.gridY+c;return{left:f,top:S,width:p,height:g}}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:a,width:r,height:c}=this.getCellOverflowButtonPosition(e),{cellHorizontalPadding:h,overflowButtonColor:u,overflowButtonHoverColor:m}=i;t.save(),m!=null&&o!=null&&r!=null&&a!=null&&c!=null&&n>=o&&n<=o+r&&s>=a&&s<=a+c?t.fillStyle=m:u!=null&&(t.fillStyle=u);const p=this.getIcon(xn.CELL_OVERFLOW);o!=null&&a!=null&&t.translate(o+h,a+2),t.fill(p),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:a,left:r,top:c}=B.getCellInfoFromXY(e,t,n);M(r),M(a),M(c);const{cellHorizontalPadding:h}=s,u=_c+2*h,m=Math.max(r+_c*i,n.gridX),p=n.gridY+c;return{left:m,top:p,width:u,height:a}}}const kT=bo,OT="12px Fira Sans, sans-serif",AT="#f0f0ee",LT="#1a171a",le={"grid-bg":"#211f22",font:OT,white:AT,black:LT,"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"},PT=Object.freeze({backgroundColor:le["grid-bg"],white:le.white,black:le.black,font:le.font,headerBackgroundColor:le["header-bg"],headerColor:le["header-color"],headerSeparatorColor:le["header-separator-color"],headerSeparatorHoverColor:le["header-separator-hover-color"],headerHiddenSeparatorHoverColor:le["header-hidden-separator-hover-color"],headerSortBarColor:le["header-sort-bar-color"],headerReverseBarColor:le["header-reverse-bar-color"],headerBarCasingColor:le["header-bar-casing-color"],headerFont:le["header-font"],rowBackgroundColors:le["row-background-colors"],rowHoverBackgroundColor:le["row-hover-bg"],selectionColor:le["selection-color"],selectionOutlineColor:le["selection-outline-color"],selectionOutlineCasingColor:le["selection-outline-casing-color"],selectedRowHoverBackgroundColor:le["selected-row-hover-bg"],scrollBarBackgroundColor:le["scroll-bar-bg"],scrollBarHoverBackgroundColor:le["scroll-bar-hover-bg"],scrollBarCasingColor:le["scroll-bar-casing-color"],scrollBarCornerColor:le["scroll-bar-corner-color"],scrollBarColor:le["scroll-bar-color"],scrollBarHoverColor:le["scroll-bar-hover-color"],scrollBarActiveColor:le["scroll-bar-active-color"],scrollBarSelectionTickColor:le["selected-row-hover-bg"],scrollBarActiveSelectionTickColor:le["scroll-bar-active-selection-tick-color"],textColor:le["text-color"],hyperlinkColor:le["hyperlink-color"],positiveNumberColor:le["positive-number-color"],negativeNumberColor:le["negative-number-color"],zeroNumberColor:le["zero-number-color"],dateColor:le["date-color"],pendingTextColor:le["pending-text-color"],errorTextColor:le["error-text-color"],nullStringColor:le["null-string-color"],filterBarActiveBackgroundColor:le["filter-bar-active-bg"],filterBarExpandedBackgroundColor:le["filter-bar-expanded-bg"],filterBarExpandedActiveBackgroundColor:le["filter-bar-expanded-active-bg"],filterBarExpandedActiveCellBackgroundColor:le["filter-bar-expanded-active-cell-bg"],filterBarSeparatorColor:le["filter-bar-separator-color"],filterBarActiveColor:le["filter-bar-active-color"],filterBarErrorColor:le["filter-bar-error-color"],filterIconColor:le["filter-icon-color"],scrimColor:le["scrim-color"],contextMenuSortIconColor:le["context-menu-sort-icon-color"],contextMenuReverseIconColor:le["context-menu-reverse-icon-color"],allowRowResize:!1,autoSelectRow:!0,gridColumnColor:null,gridRowColor:null,groupedColumnDividerColor:le["grouped-column-divider-color"],columnHoverBackgroundColor:null,headerHorizontalPadding:12,scrollBarSize:13,scrollBarHoverSize:16,minScrollHandleSize:24,rowHeight:parseInt(le["row-height"],10)||19,columnWidth:100,rowHeaderWidth:0,rowFooterWidth:60,columnHeaderHeight:parseInt(le["header-height"],10)||30,filterBarHeight:30,filterBarCollapsedHeight:5,sortHeaderBarHeight:2,reverseHeaderBarHeight:4,filterBarHorizontalPadding:4,scrimBlurSize:25,minScrimTransitionTime:150,maxScrimTransitionTime:350,scrollSnapToRow:!0,linkerColumnHoverBackgroundColor:le["linker-column-hover-bg"],treeLineColor:le["tree-line-color"],treeMarkerColor:le["tree-marker-color"],treeMarkerHoverColor:le["tree-marker-hover-color"],floatingGridColumnColor:null,floatingGridRowColor:le["floating-grid-row-color"],floatingRowBackgroundColors:le["floating-row-background-colors"],floatingDividerInnerColor:le["floating-divider-inner-color"],floatingDividerOuterColor:le["floating-divider-outer-color"],overflowButtonColor:le["overflow-button-color"],overflowButtonHoverColor:le["overflow-button-hover-color"]}),jc=PT;const $r=Z.module("ColumnStatistics"),_T={SIZE:"Number of Rows"};class Ba extends b.Component{static AUTO_GENERATE_LIMIT=1e5;static getStatsLabel(e){return _T[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<Ba.AUTO_GENERATE_LIMIT&&this.handleGenerateStatistics():this.setState({loading:!1})}handleGenerateStatistics(){this.setState({loading:!0});const{column:e,model:t}=this.props;this.cancelablePromise=ve.makeCancelable(t.columnStatistics(e)),this.cancelablePromise.then(this.handleStatistics).catch(this.handleError)}handleStatistics(e){$r.debug("Received statistics",e);const{model:t,onStatistics:n}=this.props,s=[];e.statisticsMap.forEach((i,o)=>{s.push({operation:Ba.getStatsLabel(o),value:i,type:e.getType(o)})}),e.uniqueValues.forEach((i,o)=>{s.push({operation:o,className:"column-statistics-unique-value",value:i,type:"long"})}),this.setState({loading:!1,statistics:s,numRows:t.rowCount-t.pendingRowCount}),n()}handleError(e){if(e!=null&&ve.isCanceled(e)){$r.debug("Called handleError on a cancelled promise result");return}$r.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,a=!s&&n==null&&i==null&&t.isColumnStatisticsAvailable,r=[],c=e.type.substring(e.type.lastIndexOf(".")+1),h=e.description===null?null:e.description;if(i!=null)for(let g=0;g<i.length;g+=1){const{operation:C,className:f,value:S,type:v}=i[g],w=v?t.displayString(S,v):t.displayString(S,e.type,e.name),T=l.jsxs(X.Fragment,{children:[l.jsx("div",{className:$("column-statistic-operation",f),children:C}),l.jsx("div",{className:"column-statistic-value",children:w})]},C);r.push(T)}const u=ze(t)&&t.hasExpandableRows?"Expanded Rows":"Number of Rows",m=t.displayString(o,"long"),p=t.getColumnIndexByName(e.name);return l.jsxs("div",{className:"column-statistics",children:[l.jsxs("div",{className:"column-statistics-title",children:[e.name,l.jsxs("span",{className:"column-statistics-type",children:[" (",c,")"]}),l.jsx(ar,{className:"column-statistics-copy",tooltip:"Copy column name",copy:e.name})]}),h!=null&&l.jsx("div",{className:"column-statistics-description",children:h}),p!=null&&!t.isColumnMovable(p)&&l.jsxs("div",{className:"column-statistics-status",children:[l.jsx(J,{icon:t.isColumnFrozen(p)?Hp:Bp,className:"mr-1"}),t.isColumnFrozen(p)?"Frozen":"Not movable"]}),l.jsxs("div",{className:"column-statistics-grid",children:[i==null&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"column-statistic-operation",children:u}),l.jsx("div",{className:"column-statistic-value",children:m})]}),r]}),a&&l.jsx(V,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,children:"Generate Stats"}),n!=null&&l.jsx("div",{className:"error-message",children:`${n}`}),i&&!s&&l.jsx(V,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,icon:l.jsx(J,{icon:Dl,className:"mr-1"}),children:"Refresh"}),s&&l.jsxs("div",{className:"column-statistics-loading",children:[l.jsx(Ln,{className:"mr-2"}),"Calculating Stats..."]})]})}}const jT=Ba;const aa=Z.module("AdvancedFilterCreatorFilterItem");class ld extends b.PureComponent{static getLabelForFilter(e,t){try{if(R.isNumberType(e)||R.isCharType(e))return tu(t);if(R.isTextType(e))return eu(t);if(R.isDateType(e))return nu(t);if(R.isBooleanType(e))return vS(t);throw new Error(`Unrecognized column type: ${e}`)}catch(n){return aa.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;aa.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){aa.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(){aa.debug("delete");const{onDelete:e}=this.props;e()}getCachedIsValid=fe((e,t,n,s)=>{try{return!n||R.makeAdvancedValueFilter(e,t,n,s)!=null}catch{return!1}});render(){const{column:e,filterTypes:t,formatter:n}=this.props,{selectedType:s,value:i}=this.state,o=!R.isBooleanType(e.type),a=[],r=this.getCachedIsValid(e,s,i,n.timeZone);for(let c=0;c<t.length;c+=1){const h=t[c],u=ld.getLabelForFilter(e.type,h),m=l.jsx("option",{value:h,children:u},h);a.push(m)}return l.jsx("div",{className:"advanced-filter-creator-filter-item",children:l.jsxs("div",{className:"form-row",children:[l.jsx("div",{className:"form-group col",children:l.jsx("select",{className:"form-control custom-select",value:s,onChange:this.handleTypeChange,ref:c=>{this.typeDropdown=c},children:a})}),o&&l.jsx("div",{className:"form-group col",children:l.jsx("div",{className:"input-group",children:l.jsx("input",{type:"text",className:$("form-control",{error:!r}),placeholder:"Enter value",value:i,onChange:this.handleValueChange})})}),l.jsx("div",{className:"form-group col-1 px-0",children:l.jsx(V,{kind:"ghost",className:"w-100 h-100 p-0 m-0",onClick:this.handleDelete,icon:Qt,tooltip:"Remove Filter"})})]})})}}const HT=ld,Hc=Z.module("AdvancedFilterCreatorSelectValueList");class Va extends b.PureComponent{static defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{}};static indexOf(e,t){for(let n=0;n<t.length;n+=1){const s=t[n];if(s===e||s!=null&&s.valueOf!=null&&e!=null&&e.valueOf!=null&&s.valueOf()===e.valueOf())return n}return-1}constructor(e){super(e),this.handleSelect=this.handleSelect.bind(this),this.handleViewportChange=this.handleViewportChange.bind(this),this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.list=null;const{selectedValues:t}=this.props;this.state={itemCount:0,items:[],offset:0,selectedValues:t,isLoading:!0}}componentDidMount(){const{table:e}=this.props;e&&this.startListening(e)}componentDidUpdate(e){const{filters:t,invertSelection:n,selectedValues:s,table:i}=this.props;e.table!==i&&(e.table&&this.stopListening(e.table),i&&this.startListening(i),this.resetViewport()),e.invertSelection!==n&&this.setState({selectedValues:[]},this.handleSelectionUpdate),e.selectedValues!==s&&this.setState({selectedValues:s},this.handleSelectionUpdate),e.filters!==t&&(i?.applyFilter(t),this.resetViewport())}componentWillUnmount(){const{table:e}=this.props;e&&this.stopListening(e)}list;handleSelect(e,t){const{invertSelection:n}=this.props;let{selectedValues:s}=this.state;s=[...s];const i=Va.indexOf(t,s);i>=0?s.splice(i,1):s.push(t);let o=i<0;n&&(o=!o);const{offset:a}=this.state;let{items:r}=this.state;r=[...r];const c=e-a;c>=0&&c<r.length&&(r[c].isSelected=o),this.setState({items:r,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=[],a=t.columns[0];for(let c=0;c<s.rows.length;c+=1){const u=s.rows[c].get(a),m=n.getFormattedString(u,a.type,a.name),p=this.isValueSelected(u);o.push({displayValue:m,value:u,isSelected:p})}Hc.debug2("Received table update:",i,o.length);const r=t.size;this.setState({itemCount:r,items:o,offset:i,isLoading:!1})}isValueSelected(e){const{invertSelection:t}=this.props,{selectedValues:n}=this.state,s=Va.indexOf(e,n);return t?s<0:s>=0}startListening(e){e.addEventListener(x.Table.EVENT_UPDATED,this.handleTableUpdate)}stopListening(e){e.removeEventListener(x.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),a=Math.max(o,t+i*3);Hc.debug2("Setting viewport",o,",",a),s.setViewport(o,a)}render(){const{offset:e,isLoading:t,items:n,itemCount:s}=this.state;return l.jsxs("div",{className:"select-value-list-wrapper",children:[l.jsx(Lf,{itemCount:s,items:n,offset:e,onSelect:this.handleSelect,onViewportChange:this.handleViewportChange,ref:i=>{this.list=i}}),l.jsx(gt,{in:t,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx("div",{className:"loading-list",children:l.jsx(Ln,{className:"loading-spinner-large"})})})]})}}const BT=Va;class dd extends b.PureComponent{static searchDebounceTime=250;static defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{},showSearch:!0};constructor(e){super(e),this.handleSelectAllClick=this.handleSelectAllClick.bind(this),this.handleClearAllClick=this.handleClearAllClick.bind(this),this.handleListChange=this.handleListChange.bind(this),this.handleSearchChange=this.handleSearchChange.bind(this),this.handleUpdateFilterTimeout=this.handleUpdateFilterTimeout.bind(this);const{invertSelection:t,selectedValues:n}=e;this.state={filters:[],invertSelection:t,selectedValues:n,searchText:""}}componentDidMount(){this.initSearchTable()}componentDidUpdate(e,t){const{invertSelection:n,selectedValues:s,table:i}=this.props;e.table!==i&&this.initSearchTable(),e.invertSelection!==n&&this.setState({invertSelection:n}),e.selectedValues!==s&&this.setState({selectedValues:s});const{table:o,searchText:a}=this.state;o!==t.table&&(t.table!=null&&t.table.close(),o!=null&&this.startUpdateFilterTimer()),a!==t.searchText&&this.startUpdateFilterTimer()}componentWillUnmount(){const{table:e}=this.state;e?.close(),this.searchTablePromise=void 0,this.stopUpdateFilterTimer()}searchTablePromise;updateFilterTimer;getColumnName(){const{table:e}=this.props;return e!=null?e.columns[0].name:""}getDisplayedValuesCount(){const{invertSelection:e,selectedValues:t,table:n}=this.state;return n==null?null:e?n.totalSize-t.length:t.length}getDisplayedValueText(){const e=this.getDisplayedValuesCount(),{table:t}=this.state,{formatter:n}=this.props;if(e!=null&&t!=null){const s=n.getFormattedString(e,"long"),i=n.getFormattedString(t.totalSize,"long");let o="";return e<1e6&&(o="Displaying "),`${o}${s} of ${i}`}return null}initSearchTable(){const{table:e}=this.props;if(e==null)return;const t=e.copy();this.searchTablePromise=t,this.searchTablePromise.then(n=>{this.searchTablePromise===t?(this.setState({table:n}),this.searchTablePromise=void 0):n.close()})}handleListChange(e,t){this.setState({selectedValues:e,invertSelection:t});const{onChange:n}=this.props;n(e,t)}handleSearchChange(e){const t=e.target.value;this.setState({searchText:t})}handleSelectAllClick(){this.resetSelection(!0)}handleClearAllClick(){this.resetSelection(!1)}handleUpdateFilterTimeout(){this.updateFilterTimer=void 0,this.updateTableFilter()}resetSelection(e){const t=[];this.setState({invertSelection:e,selectedValues:t});const{onChange:n}=this.props;n(t,e)}startUpdateFilterTimer(){this.stopUpdateFilterTimer(),this.updateFilterTimer=setTimeout(this.handleUpdateFilterTimeout,dd.searchDebounceTime)}stopUpdateFilterTimer(){this.updateFilterTimer!=null&&(clearTimeout(this.updateFilterTimer),this.updateFilterTimer=void 0)}updateTableFilter(){const{table:e,searchText:t}=this.state,{timeZone:n}=this.props,s=e?.columns[0],i=[];if(s==null)return;let o;if(t.length>0){let a=null;R.isCharType(s.type)?a=R.makeQuickFilter(s,t):R.isTextType(s.type)?a=R.makeQuickFilter(s,`~${t}`,n):a=R.makeQuickFilter(s,`>=${t}`,n),a!=null?i.push(a):o="Invalid search text"}this.setState({filters:i,error:o})}render(){const{error:e,filters:t,invertSelection:n,selectedValues:s,searchText:i,table:o}=this.state,{formatter:a,showSearch:r}=this.props,c=this.getColumnName(),h=this.getDisplayedValueText(),u=c?`Find ${c}...`:"";return l.jsxs("div",{className:"advanced-filter-creator-select-value",children:[l.jsxs("div",{className:r?"form-group":"",children:[l.jsx("label",{htmlFor:"advanced-filter-creator-select-value-input",children:"Select Values"}),r&&l.jsx("input",{type:"text",className:$("form-control",{"is-invalid":e!=null}),id:"advanced-filter-creator-select-value-input",placeholder:u,value:i,onChange:this.handleSearchChange})]}),l.jsx(BT,{table:o,filters:t,invertSelection:n,selectedValues:s,formatter:a,onChange:this.handleListChange}),l.jsxs("div",{className:"advanced-filter-creator-select-meta-row",children:[l.jsxs("div",{children:[l.jsx(V,{kind:"ghost",onClick:this.handleSelectAllClick,children:"Select All"}),l.jsx(V,{kind:"ghost",onClick:this.handleClearAllClick,children:"Clear"})]}),l.jsx(gt,{in:h!=null,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx("div",{className:"row-count-info",children:h})})]})]})}}const VT=dd;const oo=Z.module("AdvancedFilterCreator");class vs extends b.PureComponent{static debounceFilterUpdate=250;static defaultProps={options:{filterItems:null,filterOperators:null,invertSelection:!0,selectedValues:[]},sortDirection:null};static makeFilterItem(){return{key:Pe()}}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=X.createRef();const{options:t}=e;let{filterOperators:n,invertSelection:s,selectedValues:i}=t;const o=t.filterItems?.map(({selectedType:a,value:r})=>({selectedType:a,value:r,key:Pe()}))??[];o.length===0&&o.push(vs.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=fe(e=>R.getFilterTypes(e));initValuesTable(){const{model:e,column:t}=this.props;if(!e.isValuesTableAvailable){oo.debug("No values table for this model, just ignore");return}this.valuesTablePromise=R.makeCancelableTablePromise(e.valuesTable(t)),this.valuesTablePromise.then(n=>{const s=n.columns[0].sort().asc();n.applySort([s]),this.setState({valuesTable:n})}).catch(n=>{ve.isCanceled(n)||(oo.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(vs.makeFilterItem()),t=t.concat(Sn.and),this.setState({filterItems:e,filterOperators:t})}handleAddOr(){let{filterItems:e,filterOperators:t}=this.state;e=e.concat(vs.makeFilterItem()),t=t.concat(Sn.or),this.setState({filterItems:e,filterOperators:t})}handleChangeFilterOperator(e,t){let{filterOperators:n}=this.state;n=[...n],wS(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(vs.makeFilterItem()),this.setState({filterItems:t,filterOperators:n}),this.startUpdateTimer()}handleSelectValueChange(e,t){this.setState({selectedValues:e,invertSelection:t}),this.startUpdateTimer()}handleReset(){oo.debug("Resetting Advanced Filter"),this.setState({filterItems:[vs.makeFilterItem()],filterOperators:[],selectedValues:[],invertSelection:!0}),this.startUpdateTimer()}handleSortDown(e){const t=He.isModifierKeyDown(e);this.sortTable(R.sortDirection.descending,t)}handleSortUp(e){const t=He.isModifierKeyDown(e);this.sortTable(R.sortDirection.ascending,t)}handleSubmit(e){oo.debug("Submitting Advanced Filter"),this.stopUpdateTimer(),this.sendUpdate(),e.preventDefault()}handleDone(e){oo.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,vs.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:a}=this.props,{formatter:r}=a,c=e.filter(({selectedType:p,value:g})=>p!=null&&g!=null&&g!==""),h=t.filter((p,g)=>p!=null&&e[g].selectedType!=null&&e[g].value!=null&&e[g].value!=="").slice(0,c.length-1),u={filterItems:c,filterOperators:h,invertSelection:n,selectedValues:s},m=R.makeAdvancedFilter(i,u,r.timeZone);o(i,m,u)}render(){const{column:e,model:t,sortDirection:n,formatter:s}=this.props,{filterItems:i,filterOperators:o,invertSelection:a,selectedValues:r,valuesTable:c,valuesTableError:h}=this.state,{isValuesTableAvailable:u}=t,m=R.isBooleanType(e.type),p=R.isDateType(e.type),g=this.getFilterTypes(e.type),C=e.type.substring(e.type.lastIndexOf(".")+1),f=[];if(!m&&g.length)for(let w=0;w<i.length;w+=1){const T=i[w],{key:y,selectedType:E,value:I}=T,F=l.jsx(HT,{column:e,filterTypes:g,onChange:this.getFilterChangeHandler(w),onDelete:this.getFilterDeleteHandler(w),selectedType:E,value:I,formatter:s},y);if(f.push(F),w<o.length){const H=o[w]===Sn.and,P=l.jsxs("div",{className:"form-row justify-content-end advanced-filter-creator-filter-operator",children:[l.jsx(V,{kind:"ghost",className:$("filter-operator",{active:H}),onClick:()=>this.handleChangeFilterOperator(w,Sn.and),children:"AND"}),l.jsx(V,{kind:"ghost",className:$("filter-operator",{active:!H}),onClick:()=>this.handleChangeFilterOperator(w,Sn.or),children:"OR"})]},`filterOperator${y}`);f.push(P)}}const S=this.shouldShowAddFilter(),v=l.jsxs("div",{className:$("form-row justify-content-end add-filter-item",{hidden:!S}),children:[l.jsx("span",{className:"text-muted",children:l.jsx(J,{icon:Os})}),l.jsx(V,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddAnd,disabled:!S,tooltip:"Add filter with AND",children:"AND"}),l.jsx(V,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddOr,disabled:!S,tooltip:"Add filter with OR",children:"OR"})]},"addFilterItem");return f.push(v),l.jsxs("div",{className:"advanced-filter-creator",role:"presentation",children:[l.jsx("div",{tabIndex:0,onFocus:this.handleFocusTrapStart}),l.jsxs("form",{onSubmit:this.handleSubmit,ref:this.focusTrapContainer,children:[l.jsxs("div",{className:"title-bar",children:[l.jsx("h6",{className:"advanced-filter-title",children:"Advanced Filters"}),l.jsxs("div",{className:"advanced-filter-menu-buttons",children:[l.jsx(V,{kind:"ghost",className:$("sort-operator",{active:n===R.sortDirection.descending}),onClick:this.handleSortDown,icon:Hd,tooltip:`Sort ${e.name} Descending`}),l.jsx(V,{kind:"ghost",className:$("sort-operator",{active:n===R.sortDirection.ascending}),onClick:this.handleSortUp,icon:l.jsx(J,{icon:Hd,rotation:180}),tooltip:`Sort ${e.name} Ascending`})]})]}),l.jsx("hr",{}),l.jsxs("div",{className:"advanced-filter-column-name",children:[e.name," ",l.jsxs("span",{className:"column-type",children:["(",C,")"]})]}),f,u&&h==null&&l.jsxs(l.Fragment,{children:[!m&&l.jsx("hr",{}),l.jsx("div",{className:"form-group",children:l.jsx(VT,{table:c,onChange:this.handleSelectValueChange,invertSelection:a,selectedValues:r,formatter:s,showSearch:!p,timeZone:s.timeZone})})]}),l.jsxs("div",{className:"form-row justify-content-end",children:[l.jsx(V,{kind:"secondary",className:"mr-2",onClick:this.handleReset,children:"Reset"}),l.jsx(V,{kind:"primary",onClick:this.handleDone,children:"Done"})]})]}),l.jsx("div",{tabIndex:0,onFocus:this.handleFocusTrapEnd})]})}}const UT=vs;const Bc=Z.module("Aggregations"),$T=[Me.SUM,Me.ABS_SUM,Me.MIN,Me.MAX,Me.VAR,Me.AVG,Me.STD,Me.FIRST,Me.LAST,Me.COUNT_DISTINCT,Me.DISTINCT,Me.COUNT,Me.UNIQUE];function WT({isRollup:d,settings:e,onChange:t,onEdit:n}){const{aggregations:s,showOnTop:i}=e,o=b.useMemo(()=>$T.filter(N=>!s.some(H=>H.operation===N)),[s]),[a,r]=b.useState(o[0]),[c,h]=b.useState([]),u=b.useCallback(N=>{t({...e,...N})},[t,e]),m=b.useCallback(N=>{u({aggregations:N})},[u]),p=b.useCallback(N=>{u({showOnTop:N})},[u]),g=b.useCallback(()=>{Bc.debug("handleDragStart"),bn.startDragging()},[]),C=b.useCallback(({destination:N,source:H})=>{if(Bc.debug("handleDragEnd",N,H),bn.stopDragging(),N===null)return;let P=N.index;H.index<N.index&&(P+=1);const O=[...s],k=bn.reorder(O,c,O,P),L=bn.adjustDestinationIndex(P,c),A=[[L,L+k.length-1]];m(O),h(A)},[m,s,c,h]),f=b.useCallback(N=>{r(N)},[r]),S=b.useCallback(()=>{m([...s,{operation:a,selected:[],invert:!0}])},[s,a,m]),v=b.useCallback(N=>{m(s.filter((H,P)=>P!==N))},[s,m]),w=b.useCallback(N=>{h(N)},[h]),T=b.useCallback(N=>{const H=s[N];Rs.isRollupOperation(H.operation)||n(H)},[s,n]),y=b.useCallback(N=>{p(N.target.value==="true")},[p]);b.useEffect(function(){o.length>0&&!o.includes(a)&&r(o[0])},[o,a]);const E=b.useCallback(({item:N,itemIndex:H,isClone:P=!1,selectedCount:O})=>{const k=N.operation,L=P?`${O}`:void 0,A=P?"item-list-item-clone":void 0,U=Rs.isRollupOperation(N.operation),j=!P&&!U;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:$("item-list-item-content","draggable-item-list-item-content",A),children:[l.jsxs("span",{className:"title",children:[k,!d&&U&&l.jsxs("span",{className:"small text-warning",children:[l.jsx(J,{icon:Nh})," Requires rollup"]})]}),gn.renderBadge({text:L}),gn.renderHandle()]}),!P&&l.jsxs(l.Fragment,{children:[l.jsx(V,{kind:"ghost",className:"btn-edit",icon:Oo,tooltip:"Edit Columns",onClick:()=>n(N),disabled:!j}),l.jsx(V,{kind:"ghost",className:"btn-delete",icon:Qt,tooltip:"Delete Aggregation",onClick:()=>v(H)})]})]})},[v,n,d]),I=o.length>0,F=s.length>0;return l.jsxs("div",{className:"aggregations",children:[I&&l.jsxs("div",{className:"form-inline",children:[l.jsx(Of,{onChange:f,value:a,children:o.map(N=>l.jsx(kf,{value:N,children:N},N))}),l.jsxs("button",{type:"button",className:"btn btn-link btn-add",onClick:S,children:[l.jsx(J,{icon:Os}),"Add Aggregation"]})]}),I&&F&&l.jsx("hr",{}),F&&l.jsxs(l.Fragment,{children:[!d&&l.jsxs("div",{className:"form-inline",children:[l.jsx("label",{children:"Placement: "}),l.jsxs(rr,{onChange:y,value:`${i}`,children:[l.jsx(Qn,{value:"true",children:"Top"}),l.jsx(Qn,{value:"false",children:"Bottom"})]})]}),l.jsx(Qa,{onDragStart:g,onDragEnd:C,children:l.jsx(gn,{className:"selected-aggregations",itemCount:s.length,items:s,renderItem:E,offset:0,onSelectionChange:w,onSelect:T,selectedRanges:c,isMultiSelect:!0})})]})]})}const GT=30;function zT({aggregation:d,columns:e,onChange:t}){const[n,s]=b.useState(-1),[i,o]=b.useState(-1),[a,r]=b.useState(0),{invert:c,selected:h}=d,u=b.useRef(null),m=b.useCallback(y=>h.includes(y)?!c:c,[c,h]),p=b.useMemo(()=>{let y=ad(e,d.operation);return a!==0&&(y=R.sortColumns(y,a===1)),y},[e,d.operation,a]),g=b.useMemo(()=>n>=0?p.slice(n,i+1).map(y=>({value:y.name,displayValue:y.name,isSelected:m(y.name)})):[],[p,m,i,n]),C=b.useCallback(y=>{const{name:E}=p[y],I=h.indexOf(E);let F=[...h],N=c;I>=0?F.splice(I,1):(F.push(E),F.length===p.length&&(F=[],N=!c)),t({...d,selected:F,invert:N})},[d,c,p,h,t]),f=b.useCallback(()=>{r(0),t({...d,selected:[],invert:!0})},[d,t]),S=b.useCallback((y,E)=>{s(y),o(E)},[s,o]),v=b.useCallback(()=>{h.length===0?t({...d,invert:!c}):t({...d,selected:[],invert:!0})},[d,c,t,h]),w=h.length===0?c:null,T=h.length!==0||!c||a!==0;return l.jsxs("div",{role:"menu",className:"aggregation-edit",children:[l.jsx("div",{className:"top-menu",children:l.jsxs("div",{className:"form-inline",children:[l.jsx(Xt,{checked:w,onChange:v,children:"Toggle All"}),l.jsx("div",{className:"spacer"}),l.jsx(gt,{in:T,timeout:We.transitionSlowMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx(V,{kind:"ghost",className:"btn-reset",onClick:f,children:"Reset"})}),l.jsx(V,{kind:"ghost",className:$({active:a===1}),icon:Fl,tooltip:"Sort ascending",onClick:()=>r(1)}),l.jsx(V,{kind:"ghost",className:$({active:a===2}),icon:Nl,tooltip:"Sort descending",onClick:()=>r(2)})]})}),l.jsx("div",{className:"aggregation-edit-item-list",children:l.jsx(Ht,{itemCount:p.length,items:g,offset:n,renderItem:({item:y})=>l.jsx(Xt,{checked:m(y.value),children:y.displayValue}),onSelect:C,onViewportChange:S,rowHeight:GT,focusSelector:"input",ref:u})})]})}function KT(d){return l.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...d,children:l.jsxs("g",{fill:"none",fillRule:"evenodd",children:[l.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),l.jsx("path",{fill:"#7DA4FF",d:"M8 26h4v15H8zM15 17h4v24h-4zM22 21h4v20h-4zM29 17h4v24h-4zM36 11h4v30h-4z"})]})})}function qT(d){return l.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...d,children:l.jsxs("g",{fill:"none",fillRule:"evenodd",children:[l.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),l.jsx("path",{fill:"#7DA4FF",d:"M7 34h4v8H7zM12 31h4v11h-4zM17 27h4v15h-4zM22 22h4v20h-4zM27 27h4v15h-4zM32 29h4v13h-4zM37 31h4v11h-4z"})]})})}function YT(d){return l.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...d,children:l.jsxs("g",{fill:"none",fillRule:"evenodd",children:[l.jsx("path",{fill:"#C1C0C0",d:"M4 4h1v40H4zM44 43v1H5v-1z"}),l.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"}),l.jsx("path",{stroke:"#BECDEF",d:"M8.244 37.926L17 33.496l5 .87 10.637-10.35 10.615-1.381"})]})})}function XT(d){return l.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...d,children:l.jsxs("g",{fill:"none",fillRule:"evenodd",children:[l.jsx("path",{d:"M24 10c7.732 0 14 6.268 14 14s-6.268 14-14 14-14-6.268-14-14h14V10z",fill:"#80A6FF"}),l.jsx("path",{d:"M10 24c0-7.732 6.268-14 14-14v14H10z",fill:"#C1C0C0"})]})})}function ZT(d){return l.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...d,children:l.jsxs("g",{fill:"none",fillRule:"evenodd",children:[l.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),l.jsx("path",{fill:"#939293",d:"M44 34v1H4v-1zM44 25v1H4v-1zM44 16v1H4v-1z"}),l.jsx("circle",{fill:"#7DA4FF",cx:9.5,cy:37.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:16.5,cy:30.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:22.5,cy:36.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:28.5,cy:30.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:15.5,cy:38.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:23.5,cy:25.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:19.5,cy:19.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:29.5,cy:19.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:32.5,cy:26.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:36.5,cy:13.5,r:1.5})]})})}function QT(d){return l.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d,children:[l.jsx("rect",{width:"48",height:"48",fill:"none"}),l.jsx("rect",{x:"26",y:"10",width:"15",height:"4",fill:"#9FDE70"}),l.jsx("rect",{x:"26",y:"22",width:"15",height:"4",fill:"#9FDE70"}),l.jsx("rect",{x:"26",y:"28",width:"15",height:"4",fill:"#FFD95C"}),l.jsx("rect",{x:"26",y:"34",width:"15",height:"4",fill:"#9FDE70"})]})}function JT(d){return l.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d,children:[l.jsx("rect",{width:"48",height:"48",fill:"none"}),l.jsx("rect",{x:"4",y:"16",width:"40",height:"4",fill:"#FFD95C"}),l.jsx("rect",{x:"4",y:"10",width:"40",height:"4",fill:"#78DCE8"}),l.jsx("rect",{x:"4",y:"34",width:"40",height:"4",fill:"#78DCE8"})]})}const Vc=Z.module("ChartBuilder");class ct extends b.PureComponent{static types=[x.plot.SeriesPlotStyle.LINE,x.plot.SeriesPlotStyle.BAR,x.plot.SeriesPlotStyle.SCATTER,x.plot.SeriesPlotStyle.PIE];static getTypeName(e){switch(e){case x.plot.SeriesPlotStyle.LINE:return"Line";case x.plot.SeriesPlotStyle.BAR:return"Bar";case x.plot.SeriesPlotStyle.SCATTER:return"Scatter";case x.plot.SeriesPlotStyle.PIE:return"Pie";case x.plot.SeriesPlotStyle.HISTOGRAM:return"Histogram";default:return e}}static getTypeIcon(e){switch(e){case x.plot.SeriesPlotStyle.LINE:return l.jsx(YT,{});case x.plot.SeriesPlotStyle.BAR:return l.jsx(KT,{});case x.plot.SeriesPlotStyle.SCATTER:return l.jsx(ZT,{});case x.plot.SeriesPlotStyle.PIE:return l.jsx(XT,{});case x.plot.SeriesPlotStyle.HISTOGRAM:return l.jsx(qT,{});default:return null}}static getMaxSeriesCount(e){switch(e){case x.plot.SeriesPlotStyle.PIE:return 1;case x.plot.SeriesPlotStyle.HISTOGRAM:return 0;default:return 100}}static getXAxisLabel(e){switch(e){case x.plot.SeriesPlotStyle.PIE:return"Labels";case x.plot.SeriesPlotStyle.HISTOGRAM:return"Data";default:return"X-Axis"}}static getSeriesLabel(e){switch(e){case x.plot.SeriesPlotStyle.PIE:return"Values";default:return"Series"}}static makeSeriesItem(e){return{id:Pe.generate(),value:e}}static makeDefaultSeriesItems(e,t){if(ct.getMaxSeriesCount(e)===0||t==null||t.length===0)return[];const s=t.length>1?t[1].name:t[0].name;return[ct.makeSeriesItem(s)]}static getDefaultXAxis(e,t){return t!=null&&t.length>0?t[0].name:null}constructor(e){super(e),this.handleAddSeries=this.handleAddSeries.bind(this),this.handleLinkStateChange=this.handleLinkStateChange.bind(this),this.handleReset=this.handleReset.bind(this),this.handleSeriesChange=this.handleSeriesChange.bind(this),this.handleSeriesDeleteClick=this.handleSeriesDeleteClick.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleTypeClick=this.handleTypeClick.bind(this),this.handleXAxisChange=this.handleXAxisChange.bind(this),this.sendChange=this.sendChange.bind(this);const{model:t}=e,{columns:n}=t,s=ct.types[0],i=ct.getDefaultXAxis(s,n),o=ct.makeDefaultSeriesItems(s,n);this.state={type:s,seriesItems:o,xAxis:i,isLinked:!0}}handleAddSeries(){this.setState(e=>{const{seriesItems:t}=e,n=[...t],{model:s}=this.props,{columns:i}=s;return n.push({id:Pe.generate(),value:i[0].name}),{seriesItems:n}},this.sendChange)}handleLinkStateChange(e){this.setState({isLinked:e.target.value==="true"},this.sendChange)}handleReset(){const{model:e}=this.props,{columns:t}=e,n=ct.types[0],s=ct.getDefaultXAxis(n,t),i=ct.makeDefaultSeriesItems(n,t),o=!0;this.setState({type:n,seriesItems:i,xAxis:s,isLinked:o},this.sendChange)}handleSeriesChange(e){const{value:t}=e.target,n=e.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(i=>{let{seriesItems:o}=i;return o=[...o],o[s].value=t,{seriesItems:o}},this.sendChange)}handleSeriesDeleteClick(e){const n=e.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(i=>{const{seriesItems:o}=i,a=[...o];return a.splice(s,1),{seriesItems:a}},this.sendChange)}handleSubmit(e){e.preventDefault();const{onSubmit:t}=this.props,{type:n,seriesItems:s,xAxis:i,isLinked:o}=this.state,a=s.map(r=>r.value);t({type:`${n}`,series:a,xAxis:i,isLinked:o})}handleTypeClick(e){const n=e.target.getAttribute("data-index"),s=parseInt(n,10),i=ct.types[s];Vc.debug2("handleTypeSelect",i),this.setState(o=>{const a=ct.getMaxSeriesCount(i);let{seriesItems:r}=o;if(r=r.slice(0,a),r.length===0&&a>0){const{model:c}=this.props,{columns:h}=c;r=ct.makeDefaultSeriesItems(i,h)}return{type:i,seriesItems:r}},this.sendChange)}handleXAxisChange(e){const t=e.target.value;Vc.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(a=>a.value);e({type:n,series:o,xAxis:i,isLinked:t})}render(){const{model:e}=this.props,{columns:t}=e,{seriesItems:n,type:s,xAxis:i,isLinked:o}=this.state,a=ct.getMaxSeriesCount(s),r=ct.getXAxisLabel(s),c=ct.getSeriesLabel(s),h=n.length>0,u=n.length<a;return l.jsx("div",{className:"chart-builder",children:l.jsxs("form",{onSubmit:this.handleSubmit,children:[l.jsxs("div",{className:"form-row",children:[l.jsx("label",{children:"Select Chart Type"}),l.jsx("div",{className:"form-row",children:ct.types.map((m,p)=>{const g=m;return l.jsx("div",{className:"col col-chart-type",children:l.jsxs("button",{type:"button",className:$("btn","btn-icon","btn-chart-type",{active:m===s}),"data-index":p,onClick:this.handleTypeClick,children:[ct.getTypeIcon(m),ct.getTypeName(m)]})},g)})})]}),l.jsx("hr",{}),l.jsxs("div",{className:"form-row form-inline",children:[l.jsx("label",{className:"col-2 label-left",children:r}),l.jsx("select",{className:"form-control custom-select select-x-axis col",value:i,onChange:this.handleXAxisChange,children:t.map(m=>l.jsx("option",{value:m.name,children:m.name},m.name))})]}),h&&l.jsx("hr",{}),n.map((m,p)=>l.jsxs("div",{className:"form-row form-inline form-series-item","data-testid":`form-series-item-${p}`,children:[l.jsx("label",{className:"col-2 label-left",children:p===0?c:""}),l.jsx("select",{className:"form-control custom-select select-series col",value:m.value,onChange:this.handleSeriesChange,"data-testid":`select-series-item-${p}`,"data-index":p,children:t.map(g=>l.jsx("option",{value:g.name,"data-index":p,children:g.name},g.name))}),n.length>1&&l.jsx(V,{kind:"ghost",className:"btn-delete-series ml-2 px-2","data-index":p,"data-testid":`delete-series-${p}`,onClick:this.handleSeriesDeleteClick,icon:Qt,tooltip:"Delete"})]},m.id)),u&&l.jsxs("div",{className:"form-row",children:[l.jsx("div",{className:"col-2"}),l.jsx(V,{kind:"ghost",className:"btn-add-series mt-1",onClick:this.handleAddSeries,icon:Os,children:"Add Series"})]}),l.jsxs("div",{className:"form-row chart-builder-link",children:[l.jsx("label",{className:"col-2 label-right",children:l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(J,{mask:xl,icon:_i,transform:"right-5 down-5"}),l.jsx(J,{icon:o?yl:Vp,transform:"grow-2 right-8 down-6"})]})}),l.jsxs(rr,{onChange:this.handleLinkStateChange,value:`${o}`,children:[l.jsx(Qn,{value:"true",children:"Sync State"}),l.jsx(Qn,{value:"false",children:"Freeze State"})]})]}),l.jsxs("div",{className:"form-row",children:[l.jsx("div",{className:"col-2 label-right"}),l.jsx("div",{className:"col chart-builder-link-info",children:o?"Charts with synced state will update to match any filters or user modifications applied to the parent table.":"Freeze State disconnects the chart state from the parent table. New filters or user modifications on the parent table will not be applied."})]}),l.jsxs("div",{className:$("form-row","justify-content-end","my-3"),children:[l.jsx(V,{kind:"secondary",className:"btn-reset",onClick:this.handleReset,children:"Reset"}),l.jsx(V,{kind:"primary",type:"submit",className:"btn-submit",children:"Create"})]})]})})}}const eE=ct;class tE extends b.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=Yn.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 l.jsxs("div",{className:$("input-editor-wrapper",{focused:n,invalid:t}),role:"presentation",onClick:this.handleContainerClick,children:[l.jsx("div",{className:"editor-container",ref:i=>{this.editorContainer=i}}),s&&!e&&l.jsx("div",{className:"editor-placeholder text-muted",children:"Column Formula"})]})}}const Uc=Object.freeze({NAME:"name",FORMULA:"formula"}),nE=()=>{};function sE({eventKey:d,name:e,inputIndex:t,formula:n,onChange:s,onDeleteColumn:i,onTabInEditor:o,invalid:a,isDuplicate:r}){const c=e===""||cn.isValidColumnName(e),h=b.useCallback(u=>{u!==void 0&&(u.replace(/(\r\n|\n|\r)/gm,""),s(d,Uc.FORMULA,u))},[s,d]);return l.jsx(wl,{draggableId:d,index:t,disableInteractiveElementBlocking:!0,children:(u,m)=>l.jsxs("div",{className:$("draggable-container",{dragging:m.isDragging}),ref:u.innerRef,...u.draggableProps,children:[l.jsxs("div",{className:"custom-column-input-container",children:[l.jsxs("div",{className:"pb-3",children:[l.jsxs("div",{className:"d-flex flex-row custom-column-name",children:[l.jsx("input",{className:$("form-control custom-column-input",{"is-invalid":a||!c||r}),placeholder:"Column Name",value:e,onChange:p=>{s(d,Uc.NAME,p.target.value)}}),l.jsx(V,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{i(d)},icon:Qt,tooltip:"Delete custom column"}),l.jsx(V,{kind:"ghost",className:"btn-drag-handle",onClick:nE,...u.dragHandleProps,icon:Mo,tooltip:"Drag column to re-order"})]}),(!c||r)&&l.jsx("p",{className:"validate-label-error text-danger mb-0 mt-2 pl-1",children:c?"Duplicate name":"Invalid name"})]}),l.jsx(tE,{editorSettings:{language:"deephavenDb"},editorIndex:t,value:n,onContentChanged:h,onTab:o,invalid:a})]}),l.jsx("hr",{})]})})}const Wr=[];class iE extends iv{static EVENT=Object.freeze({UPDATED:"UPDATED",FORMATTER_UPDATED:"FORMATTER_UPDATED",REQUEST_FAILED:"REQUEST_FAILED",COLUMNS_CHANGED:"COLUMNS_CHANGED",TABLE_CHANGED:"TABLE_CHANGED",FILTERS_CHANGED:"FILTERS_CHANGED",SORTS_CHANGED:"SORTS_CHANGED",DISCONNECT:"DISCONNECT",RECONNECT:"RECONNECT",TOTALS_UPDATED:"TOTALS_UPDATED",PENDING_DATA_UPDATED:"PENDING_DATA_UPDATED"});constructor(){super(),this.listenerCount=0}listenerCount;addEventListener(e,t,n){super.addEventListener(e,t,n),this.listenerCount+=1,this.listenerCount===1&&this.startListening()}removeEventListener(e,t,n){super.removeEventListener(e,t,n),this.listenerCount-=1,this.listenerCount===0&&this.stopListening()}startListening(){}stopListening(){}get originalColumns(){return this.columns}get layoutHints(){return null}get frontColumns(){return Wr}get backColumns(){return Wr}get frozenColumns(){return Wr}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 Ce=iE;class Qs extends b.Component{static SUCCESS_SHOW_DURATION=750;static makeCustomColumnInputEventKey(){return Pe.generate()}static createCustomColumnInput(){return{eventKey:Pe.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=fe((e,t)=>e.find(n=>n.eventKey===t));getInputIndex=fe((e,t)=>e.findIndex(n=>n.eventKey===t));resetErrorMessage(){this.setState({errorMessage:null})}startListening(){const{model:e}=this.props;e.addEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),e.addEventListener(Ce.EVENT.UPDATED,this.handleCustomColumnUpdated),e.addEventListener(Ce.EVENT.REQUEST_FAILED,this.handleRequestFailed)}stopListening(){const{model:e}=this.props;e.removeEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),e.removeEventListener(Ce.EVENT.UPDATED,this.handleCustomColumnUpdated),e.removeEventListener(Ce.EVENT.REQUEST_FAILED,this.handleRequestFailed)}parseCustomColumns(e){if(e.length>0){const t=e.map(n=>{const s=n.split(/=(.+)/,2);return{eventKey:Qs.makeCustomColumnInputEventKey(),name:s[0],formula:s[1]}});this.setState({inputs:t})}else this.setState({inputs:[Qs.createCustomColumnInput()]})}handleAddColumnClick(){const{inputs:e}=this.state,t=[...e];t.push(Qs.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(Qs.createCustomColumnInput()),this.setState({inputs:s})}handleInputChange(e,t,n){const{inputs:s}=this.state,i=this.getInputIndex(s,e),a={...this.getInput(s,e)};a[t]=n;const r=[...s];r.splice(i,1,a),this.setState({inputs:r})}handleCustomColumnUpdated(){const{isCustomColumnApplying:e}=this.state;e&&this.setState({isCustomColumnApplying:!1,isSuccessShowing:!0},()=>{this.successButtonTimer=setTimeout(()=>this.setState({isSuccessShowing:!1}),Qs.SUCCESS_SHOW_DURATION)})}handleRequestFailed(e){const t=e,{isCustomColumnApplying:n}=this.state;n&&this.setState({isCustomColumnApplying:!1,errorMessage:l.jsxs(l.Fragment,{children:[l.jsxs("p",{children:[l.jsx(J,{icon:Ms})," Failed to apply custom columns."]}),l.jsxs("div",{className:"error-box",children:[t.detail.errorMessage,l.jsx("br",{}),"Table configuration:"," ",JSON.stringify(t.detail.configuration)]})]}),hasRequestFailed:!0})}handleDragEnd(e){if(bn.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:a,formula:r}=o;a&&r&&i.push(`${a}=${r}`)}),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:a,formula:r}=s,c=(n.get(a)??0)>1;return l.jsx(sE,{inputIndex:i,eventKey:o,name:a,formula:r,onChange:this.handleInputChange,onDeleteColumn:this.handleDeleteColumn,onTabInEditor:this.handleEditorTabNavigation,invalid:t,isDuplicate:c},o)})}renderSaveButton(){const{inputs:e,isCustomColumnApplying:t,isSuccessShowing:n}=this.state,s=e.length>1?"Save Columns":"Save Column",i=e.every(({name:r})=>r===""||cn.isValidColumnName(r)),o=e.filter(({name:r})=>r!=="").map(({name:r})=>r),a=new Set(o).size===o.length;return l.jsxs(V,{kind:n?"success":"primary",className:$("btn-apply",{"btn-spinner":t}),disabled:n||t||!i||!a,onClick:this.handleSaveClick,children:[t&&l.jsxs("span",{children:[l.jsx(Ln,{}),l.jsx("span",{className:"btn-normal-content",children:"Applying"})]}),!n&&!t&&s,n&&l.jsxs(l.Fragment,{children:[l.jsx(J,{icon:Rl})," Success"]})]})}render(){const{onCancel:e}=this.props,{errorMessage:t}=this.state;return l.jsxs("div",{role:"presentation",className:"custom-column-builder-container",ref:n=>{this.container=n},onClick:this.resetRequestFailed,onFocus:this.resetRequestFailed,children:[l.jsx("hr",{}),l.jsx(Qa,{onDragStart:bn.startDragging,onDragEnd:this.handleDragEnd,children:l.jsx(Za,{droppableId:"droppable-custom-columns",children:(n,s)=>l.jsxs("div",{ref:n.innerRef,...n.droppableProps,className:$("droppable-container",{dragging:s.draggingFromThisWith}),children:[this.renderInputs(),n.placeholder]})})}),l.jsx("div",{className:"pt-1 px-3",children:l.jsx(V,{kind:"ghost",className:"btn-add-column",onClick:this.handleAddColumnClick,icon:Os,children:"Add Another Column"})}),l.jsxs("div",{className:"custom-column-builder-footer",children:[t&&l.jsx("div",{className:"error-message",children:t}),l.jsxs("div",{className:"d-flex justify-content-end",children:[l.jsx(V,{kind:"secondary",className:"mr-2",onClick:e,children:"Cancel"}),this.renderSaveButton()]})]})]})}}const oE=Qs;var im=(d=>(d.ADVANCED_SETTINGS="ADVANCED_SETTINGS",d.AGGREGATIONS="AGGREGATIONS",d.AGGREGATION_EDIT="AGGREGATIONS_EDIT",d.CHART_BUILDER="CHART_BUILDER",d.CUSTOM_COLUMN_BUILDER="CUSTOM_COLUMN_BUILDER",d.QUICK_FILTERS="QUICK_FILTERS",d.ROLLUP_ROWS="ROLLUP_ROWS",d.SEARCH_BAR="SEARCH_BAR",d.SELECT_DISTINCT="SELECT_DISTINCT",d.TABLE_EXPORTER="TABLE_EXPORTER",d.VISIBILITY_ORDERING_BUILDER="VISIBILITY_ORDERING_BUILDER",d.CONDITIONAL_FORMATTING="CONDITIONAL_FORMATTING",d.CONDITIONAL_FORMATTING_EDIT="CONDITIONAL_FORMATTING_EDIT",d.GOTO="GOTO",d))(im||{});const Ie=im;const ao=Z.module("RollupRows"),aE=150,ra="grouped-rollup-rows",la="ungrouped-rollup-rows";class on extends b.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 gn.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,a)=>t.includes(o)?(a<s&&(s-=1),!1):!0);return i.splice(s,0,...t),i}static isGroupable(e){return!R.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=X.createRef(),this.groupedList=X.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===on.SORT.ASCENDING?null:on.SORT.ASCENDING}))}handleSortDescending(){this.setState(({sort:e})=>({sort:e===on.SORT.DESCENDING?null:on.SORT.DESCENDING}))}resetSelection(){this.setState({ungroupedSelectedRanges:[],groupedSelectedRanges:[]})}search=Ye(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]));M(s),this.setState({ungroupedSelectedRanges:n}),n.length>0&&this.ungroupedList.current&&this.ungroupedList.current.scrollToItem(s)},aE);handleDragStart(e){ao.debug("handleDragStart",e),document.documentElement.classList.add("drag-pointer-events-none"),this.setState({dragSource:e.source})}handleDragEnd(e){ao.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===la){this.setState(({groupedSelectedRanges:o,columns:a})=>{const r=[...a];return bn.reorder(r,o,[],0),{columns:r,ungroupedSelectedRanges:[],groupedSelectedRanges:[]}});return}const s=n.droppableId===ra;let i=t.index;s&&n.index<t.index&&(i+=1),this.setState(({columns:o,ungroupedSelectedRanges:a,groupedSelectedRanges:r})=>{const c=[...o],h=s?c:this.getSortedUngroupedColumns().map(C=>C.name),u=s?r:a,m=bn.reorder(h,u,c,i),p=s?bn.adjustDestinationIndex(i,r):i,g=[[p,p+m.length-1]];return{columns:c,ungroupedSelectedRanges:[],groupedSelectedRanges:g}}),this.resetSelection()}handleUngroupedSelect(e){ao.debug("handleUngroupedSelect"),this.setState(({columns:t})=>({columns:on.addGroupings(t,[this.getSortedUngroupedColumns()[e].name]),ungroupedSelectedRanges:[],groupedSelectedRanges:[]}))}handleUngroupedSelectionChange(e){ao.debug2("handleUngroupedSelectionChange",e),this.setState(({ungroupedSelectedRanges:t})=>e===t?null:{ungroupedSelectedRanges:e,groupedSelectedRanges:[]})}handleGroupedSelectionChange(e){ao.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=pe((e,t)=>e.filter(n=>on.isGroupable(n)&&t.find(s=>s===n.name)==null));getCachedSortedColumns=pe((e,t)=>t==null?[...e]:R.sortColumns(e,t===on.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}`,a=n!==void 0&&n?`${s}`:void 0,r=n!==void 0&&n?"item-list-item-clone":"";return l.jsxs(l.Fragment,{children:[gn.renderTextItem({text:o,badgeText:a,className:r}),(n===void 0||!n)&&l.jsx(V,{kind:"ghost",className:"btn btn-link btn-link-icon btn-delete-grouping float-right",onClick:()=>this.handleDeleteClicked(t),children:l.jsx(J,{icon:Qt})})]})}render(){const{columns:e,dragSource:t,searchFilter:n,groupedSelectedRanges:s,ungroupedSelectedRanges:i,showConstituents:o,showNonAggregatedColumns:a,sort:r}=this.state,c=this.getSortedUngroupedColumns();let h=e.length*gn.DEFAULT_ROW_HEIGHT;t?.droppableId===la&&(h+=gn.DEFAULT_ROW_HEIGHT);const u=c.length*gn.DEFAULT_ROW_HEIGHT+10,m=Math.min(3*gn.DEFAULT_ROW_HEIGHT,u);return l.jsx("div",{role:"menu",className:$("rollup-rows",{"is-dragging":t!=null}),tabIndex:0,children:l.jsxs(Qa,{onDragEnd:this.handleDragEnd,onDragStart:this.handleDragStart,children:[l.jsxs("div",{className:"rollup-rows-group-by",children:[l.jsx("div",{className:"section-title",children:"Group By"}),e.length===0&&l.jsx(Za,{droppableId:"placeholder",children:(p,g)=>l.jsx("div",{className:$("placeholder","text-muted",{"is-dragging-from-this":g.draggingFromThisWith,"is-dragging-over":g.isDraggingOver,"is-dropping":g.draggingOverWith}),ref:p.innerRef,...p.droppableProps,children:"To create a rollup, drag columns from the list below and drop them into this area."})}),e.length>0&&l.jsx(gn,{draggingItemClassName:"rollup-rows-dragging-grouped-item",draggablePrefix:ra,droppableId:ra,itemCount:e.length,items:e,offset:0,onSelectionChange:this.handleGroupedSelectionChange,ref:this.groupedList,renderItem:this.renderGroupedItem,selectedRanges:s,style:{height:h},isMultiSelect:!0})]}),l.jsxs("div",{className:"rollup-rows-available-columns",children:[l.jsx("div",{className:"section-title",children:"Available Grouping Columns"}),l.jsxs("div",{className:"top-menu",children:[l.jsx(As,{className:"w-100",value:n,matchCount:n?i.length:void 0,placeholder:"Find column...",onChange:this.handleSearchChange}),l.jsxs(V,{kind:"ghost",className:$("btn-link btn-link-icon",{active:r===on.SORT.ASCENDING}),onClick:this.handleSortAscending,children:[l.jsx(J,{icon:Fl}),l.jsx(tt,{children:"Sort ascending"})]}),l.jsxs(V,{kind:"ghost",className:$("btn-link btn-link-icon",{active:r===on.SORT.DESCENDING}),onClick:this.handleSortDescending,children:[l.jsx(J,{icon:Nl}),l.jsx(tt,{children:"Sort descending"})]})]}),l.jsx(gn,{className:"rollup-available-grouping-columns",draggablePrefix:la,droppableId:la,itemCount:c.length,items:c,renderItem:on.renderColumn,offset:0,onSelect:this.handleUngroupedSelect,onSelectionChange:this.handleUngroupedSelectionChange,ref:this.ungroupedList,selectedRanges:i,style:{maxHeight:u,minHeight:m},isDropDisabled:t?.droppableId!==ra,isMultiSelect:!0}),l.jsxs("div",{className:"bottom-menu",children:[l.jsx("div",{className:"label",children:"Show:"}),l.jsx(Xt,{checked:o,onChange:this.handleShowConstituentsChange,children:"Constituents"}),l.jsx(Xt,{checked:a,onChange:this.handleShowNonAggregatedColumnsChange,children:"Non-Aggregated Columns"})]})]})]})})}}const rE=on;const lE=Z.module("TableCsvExporter");class Be extends b.Component{static FILENAME_DATE_FORMAT="yyyy-MM-dd-HHmmss";static DOWNLOAD_STATUS={INITIATING:"INITIATING",DOWNLOADING:"DOWNLOADING",FINISHED:"FINISHED",CANCELED:"CANCELED"};static DOWNLOAD_ROW_OPTIONS={ALL_ROWS:"ALL_ROWS",SELECTED_ROWS:"SELECTED_ROWS",CUSTOMIZED_ROWS:"CUSTOMIZED_ROWS"};static CUSTOMIZED_ROWS_OPTIONS={FIRST:"FIRST",LAST:"LAST"};static DEFAULT_DOWNLOAD_ROWS=100;static defaultProps={onDownloadStart:()=>{},isDownloading:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:null,selectedRanges:[]};static getDateString(){return x.i18n.DateTimeFormat.format(Be.FILENAME_DATE_FORMAT,new Date)}constructor(e){super(e),this.handleDownloadClick=this.handleDownloadClick.bind(this),this.handleDownloadRowOptionChanged=this.handleDownloadRowOptionChanged.bind(this),this.handleCustomizedDownloadRowOptionChanged=this.handleCustomizedDownloadRowOptionChanged.bind(this),this.handleCustomizedDownloadRowsChanged=this.handleCustomizedDownloadRowsChanged.bind(this),this.handleIncludeColumnHeadersChanged=this.handleIncludeColumnHeadersChanged.bind(this),this.handleIncludeHiddenColumnsChanged=this.handleIncludeHiddenColumnsChanged.bind(this),this.handleUseUnformattedValuesChanged=this.handleUseUnformattedValuesChanged.bind(this);const{name:t}=e;this.state={fileName:`${t}-${Be.getDateString()}.csv`,downloadRowOption:Be.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,customizedDownloadRowOption:Be.CUSTOMIZED_ROWS_OPTIONS.FIRST,customizedDownloadRows:Be.DEFAULT_DOWNLOAD_ROWS,includeColumnHeaders:!0,includeHiddenColumns:!1,useUnformattedValues:!1,errorMessage:null,id:Pe.generate()}}getSnapshotRanges(){const{model:e,selectedRanges:t}=this.props,{downloadRowOption:n,customizedDownloadRowOption:s,customizedDownloadRows:i}=this.state,{rowCount:o,columnCount:a}=e;let r=[];switch(n){case Be.DOWNLOAD_ROW_OPTIONS.ALL_ROWS:r.push(new z(0,0,a-1,o-1));break;case Be.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS:r=t.map(c=>({...c,startColumn:0,endColumn:a-1})).sort((c,h)=>c.startRow!=null&&h.startRow!=null?c.startRow-h.startRow:0);break;case Be.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS:switch(s){case Be.CUSTOMIZED_ROWS_OPTIONS.FIRST:r.push(new z(0,0,a-1,Math.min(i-1,o-1)));break;case Be.CUSTOMIZED_ROWS_OPTIONS.LAST:r.push(new z(0,Math.max(0,o-i),a-1,o-1));break}break}return r}getModelRanges(e){const{userColumnWidths:t,movedColumns:n}=this.props,{includeHiddenColumns:s}=this.state,i=be.getHiddenColumns(t);let o=B.getModelRanges(e,n);if(!s&&i.length>0){const a=i.map(z.makeColumn);o=z.subtractRangesFromRanges(o,a)}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:a,useUnformattedValues:r}=this.state;if(t){i();return}this.resetDownloadState();const c=this.getSnapshotRanges(),h=this.getModelRanges(c);if(this.validateOptionInput()){n();try{const u=await e.export(),m=u.setViewport(0,0);await m.getViewportData(),s(o,u,m,c,h,a,r)}catch(u){lE.error("CSV download failed",u),this.setState({errorMessage:l.jsxs("p",{children:[l.jsx(J,{icon:Ms})," ",`${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===Be.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS&&e.length===0?(this.setState({errorMessage:l.jsxs("p",{children:[l.jsx(J,{icon:Ms})," No rows selected. Please select some rows in the table."]})}),!1):t===Be.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS&&n<=0?(this.setState({errorMessage:l.jsxs("p",{children:[l.jsx(J,{icon:Ms})," 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:a,downloadRowOption:r,customizedDownloadRowOption:c,customizedDownloadRows:h,includeColumnHeaders:u,includeHiddenColumns:m,useUnformattedValues:p,errorMessage:g,id:C}=this.state,{rowCount:f}=e;return l.jsxs("div",{className:"table-csv-exporter",children:[l.jsx("div",{className:"section-title",children:"Download Rows"}),l.jsx("div",{className:"form-group",children:l.jsxs(rr,{onChange:this.handleDownloadRowOptionChanged,value:r,disabled:t,children:[l.jsxs(Qn,{value:Be.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,"data-testid":"radio-csv-exporter-download-all",children:["All Rows",l.jsx("span",{className:"text-muted ml-2",children:`(${f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`})]}),l.jsxs(Qn,{value:Be.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS,"data-testid":"radio-csv-exporter-only-selected",children:["Only Selected Rows",l.jsx("span",{className:"text-muted ml-2",children:i.length>0?`(${z.rowCount(i).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`:null})]}),l.jsx(Qn,{value:Be.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS,"data-testid":"radio-csv-exporter-customized-rows",children:l.jsxs("div",{className:"radio-input-row",role:"presentation",onClick:()=>{this.setState({downloadRowOption:Be.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS})},children:[l.jsxs("select",{value:c,"data-testid":"select-csv-exporter-customized-rows",className:"custom-select",disabled:t,onChange:this.handleCustomizedDownloadRowOptionChanged,children:[l.jsx("option",{value:"FIRST",children:"First"}),l.jsx("option",{value:"LAST",children:"Last"})]}),l.jsx("input",{type:"number",className:"form-control",id:`customizedRows-${C}`,"data-testid":"input-csv-exporter-customized-rows",name:`customizedRows-${C}`,placeholder:"100",value:h,disabled:t,onChange:this.handleCustomizedDownloadRowsChanged}),l.jsx("div",{children:"Rows"})]})})]})}),l.jsxs("div",{className:"form-group",children:[l.jsx("label",{htmlFor:`customizedRows-${C}`,children:"File Name"}),l.jsx("input",{type:"text",className:"form-control",id:`filename-${C}`,"data-testid":"input-csv-exporter-file-name",name:`filename-${C}`,value:a,onChange:S=>{this.setState({fileName:S.target.value})},disabled:t})]}),l.jsxs("div",{className:"checkbox-options",children:[l.jsx(Xt,{checked:u,onChange:this.handleIncludeColumnHeadersChanged,children:"Include column headers"}),l.jsx(Xt,{checked:m,onChange:this.handleIncludeHiddenColumnsChanged,children:"Include hidden columns"}),l.jsx(Xt,{checked:p,onChange:this.handleUseUnformattedValuesChanged,children:"Use unformatted values"})]}),l.jsxs("div",{className:"section-footer flex-column",children:[g!=null&&l.jsx("div",{className:"error-message",children:g}),o&&l.jsxs("div",{className:"download-status",children:[(o===Be.DOWNLOAD_STATUS.DOWNLOADING||o===Be.DOWNLOAD_STATUS.INITIATING)&&l.jsxs(l.Fragment,{children:[o===Be.DOWNLOAD_STATUS.INITIATING&&l.jsx("div",{className:"text-muted",children:"Starting Download..."}),o===Be.DOWNLOAD_STATUS.DOWNLOADING&&l.jsxs("div",{className:"text-muted d-flex justify-content-between",children:[l.jsx("span",{children:s||s===0?`Estimated time: ${Wi.formatElapsedTime(s)}`:null}),l.jsx("span",{children:`${n}%`})]})]}),o===Be.DOWNLOAD_STATUS.FINISHED&&l.jsx("div",{className:"text-muted text-right",children:"Download Completed"}),o===Be.DOWNLOAD_STATUS.CANCELED&&l.jsx("div",{className:"text-muted",children:"Download Canceled"}),(o===Be.DOWNLOAD_STATUS.DOWNLOADING||o===Be.DOWNLOAD_STATUS.INITIATING)&&l.jsx("div",{className:"progress",children:l.jsx("div",{className:"progress-bar progress-bar-striped progress-bar-animated",style:{width:`${n}%`}})}),o===Be.DOWNLOAD_STATUS.FINISHED&&l.jsx("div",{className:"progress",children:l.jsx("div",{className:"progress-bar bg-success",style:{width:`${n}%`}})})]}),l.jsxs(V,{kind:"primary","data-testid":"btn-csv-exporter-download",className:$("btn-downloading",{"btn-spinner btn-cancelable":t}),onClick:this.handleDownloadClick,children:[t&&l.jsxs("span",{children:[l.jsx(Ln,{}),l.jsx("span",{className:"btn-normal-content",children:"Downloading"}),l.jsx("span",{className:"btn-hover-content",children:"Cancel"})]}),!t&&"Download"]})]})]})}}const Ws=Be,$n=Z.module("TableSaver"),dE="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function cE(d){return d.added!==void 0}function hE(d){if(!cE(d))throw new Error("event is not UpdateEventData")}class zn extends b.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.WritableStream=window.WritableStream??Md,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;WritableStream=window.WritableStream??Md;streamTimeout;snapshotHandlerTimeout;downloadStartTime;iframes;useBlobFallback;getCachedCustomColumnFormatFlag=qn(Jn.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=a=>{M(s),a.header!==void 0&&n.push(s(a.header)),a.rows!==void 0&&n.push(s(a.rows))},o.close=()=>{M(i);const a=new Blob(n,{type:"application/octet-stream; charset=utf-8"}),r=document.createElement("a");r.href=URL.createObjectURL(a),r.download=i,r.click()},o.abort=()=>{e.postMessage({cancel:!0}),e.close()}):(o.write=a=>{e.postMessage(a)},o.close=()=>{e.postMessage({end:!0}),e.close()},o.abort=()=>{e.postMessage({cancel:!0}),e.close()}),new this.WritableStream(o)}startDownload(e,t,n,s,i,o,a){const{isDownloading:r}=this.props;if(r)return;this.downloadStartTime=Date.now(),$n.info(`start downloading ${e}`),this.table=t,this.columns=be.columnsFromRanges(i,t.columns),this.tableSubscription=n,this.gridRanges=s,this.includeColumnHeaders=o,this.useUnformattedValues=a;const c=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:c},[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?`
|
|
22
22
|
`:",";this.fileWriter?.write({header:e}).then(()=>null)}startWriteTableBody(){this.columns&&this.gridRanges!=null&&(this.chunkRows=Math.floor(zn.DOWNLOAD_CELL_CHUNK/this.columns.length),this.rangedSnapshotsTotal=this.gridRanges.map(e=>(M(e.endRow),M(e.startRow),M(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(zn.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);M(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(`
|
|
@@ -35,9 +35,9 @@ ${a} does not exist yet.`}if(s){const{widgetName:o}=this.props;return`${o} is un
|
|
|
35
35
|
${vo.makeCirclePath(s,i,hh)}
|
|
36
36
|
${vo.makeCirclePath(o,a,hh)}`,I=`link-select-clip-${r}`,F=Math.atan2(a-T,o-w),N=F-ch+Math.PI,H=F+ch+Math.PI,P=o+Math.cos(F)*lh,O=a+Math.sin(F)*lh,k=P+Math.cos(N)*fa,L=O+Math.sin(N)*fa,A=P+Math.cos(H)*fa,U=O+Math.sin(H)*fa,j=`${P},${O} ${k},${L} ${A},${U}`,W=.25*s+.5*w+.25*o,ie=.25*i+.5*T+.25*a,se=w-s+(o-w),K=(T-i+(a-T))/se;let oe=20/Math.sqrt(1+K**2),de=oe*K,ee=oe*-1,re=de*-1;Number.isFinite(K)?K>0?(oe*=-1,de*=-1,ee*=-1,re*=-1,ee-=50-10*(Math.abs(m)%Cs),re+=10*(Math.abs(m)%Cs),oe-=50-10*(Math.abs(m)%Cs),de+=10*(Math.abs(m)%Cs)):K<0?(ee+=10*(Math.abs(m)%Cs),re+=10*(Math.abs(m)%Cs),oe+=10*(Math.abs(m)%Cs),de+=10*(Math.abs(m)%Cs)):(ee=15,re=10,oe=-25,de=10):(ee=10,re=5,oe=10,de=-35);let we="";return t!==void 0&&(t==="startsWith"?we="a*":t==="endsWith"?we="*z":we=R.getFilterOperatorString(t)),l.jsxs(l.Fragment,{children:[l.jsxs("svg",{className:$(e,{hovering:h}),children:[l.jsx("clipPath",{id:I,children:l.jsx("path",{d:E,clipRule:"evenodd"})}),l.jsx("path",{className:"link-select",d:y,onClick:this.handleClick,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,clipPath:`url(#${I})`}),l.jsx("path",{className:"link-background",d:y}),l.jsx("path",{className:"link-foreground",d:y}),l.jsx("circle",{className:"link-dot",cx:s,cy:i,r:"5"}),l.jsx("polygon",{className:"link-triangle",points:j})]}),c!=null&&n&&l.jsxs(l.Fragment,{children:[l.jsx(V,{kind:"primary",className:"btn-fab btn-operator",style:{top:ie+(K>=0?de:re),left:W+(K>=0?oe:ee)},onClick:()=>{},icon:l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx("b",{children:we}),l.jsx(J,{icon:kn,transform:"right-8 down-9 shrink-5"})]}),tooltip:"Change comparison operator",children:l.jsx(Zn,{actions:this.getDropdownActions,popperOptions:{placement:"bottom-start"}})}),l.jsx(V,{kind:"primary",className:"btn-fab btn-delete",style:{top:ie+(K<0?de:re),left:W+(K<0?oe:ee)},onClick:this.handleDelete,icon:Qt,tooltip:"Delete"})]})]})}}const Zr=Z.module("LinkerOverlayContent");class iR extends b.Component{static defaultProps={disabled:"false"};constructor(e){super(e),this.handleBlur=this.handleBlur.bind(this),this.handleResize=this.handleResize.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleKeyUp=this.handleKeyUp.bind(this),this.handleEscapePressed=this.handleEscapePressed.bind(this),this.handleOperatorChanged=this.handleOperatorChanged.bind(this),this.dialogRef=X.createRef(),this.state={mouse:void 0,dialog:void 0,offset:{x:0,y:0},isDragging:!1,mode:"select"}}componentDidMount(){window.addEventListener("blur",this.handleBlur,!0),window.addEventListener("mousemove",this.handleMouseMove,!0),window.addEventListener("mouseup",this.handleMouseUp,!0),window.addEventListener("keydown",this.handleKeyDown,!0),window.addEventListener("keyup",this.handleKeyUp,!0),window.addEventListener("resize",this.handleResize,!0)}componentDidCatch(e,t){Zr.error("componentDidCatch",e,t)}componentWillUnmount(){window.removeEventListener("blur",this.handleBlur,!0),window.removeEventListener("mousemove",this.handleMouseMove,!0),window.removeEventListener("mouseup",this.handleMouseUp,!0),window.removeEventListener("keydown",this.handleKeyDown,!0),window.removeEventListener("keyup",this.handleKeyUp,!0),window.removeEventListener("resize",this.handleResize,!0)}dialogRef;getPointFromLinkPoint(e){const{panelManager:t}=this.props,{panelId:n,columnName:s}=e,i=t.getOpenedPanelById(n);if(i!=null){if(!wm(i))throw new Error(`Panel does not have getCoordinateForColumn method: ${n}`);try{const a=i.getCoordinateForColumn(s);if(a!=null)return a}catch{Zr.error("Could not get coordinate for column",s,i)}}const o=t.getContainerByPanelId(n);if(o==null)throw new Error(`Unable to find panel container for id: ${n}`);return q.getTabPoint(o)}handleOperatorChanged(e,t){const{links:n,onLinksUpdated:s}=this.props,i=n.map(o=>o.id===e?{...o,operator:t}:o);s(i)}handleBlur(){this.setState({mode:"select"})}handleResize(){const{dialog:e}=this.state;if(e&&this.dialogRef.current){const t=this.dialogRef.current.getBoundingClientRect(),n=je(e.x,0,window.innerWidth-t.width),s=je(e.y,0,window.innerHeight-t.height);this.setState({dialog:{x:n,y:s}})}}handleMouseMove(e){const{offset:t,isDragging:n}=this.state;if(this.setState({mouse:{x:e.clientX,y:e.clientY}}),n&&this.dialogRef.current){const s=this.dialogRef.current.getBoundingClientRect(),i=je(window.innerWidth-(e.clientX+s.width+t.x),0,window.innerWidth-s.width),o=je(window.innerHeight-(e.clientY+s.height+t.y),0,window.innerHeight-s.height);this.setState({dialog:{x:i,y:o}})}}handleMouseDown(e){const t={x:0,y:0};if(this.dialogRef.current){const n=this.dialogRef.current.getBoundingClientRect();t.x=n.right-(n.width+e.clientX),t.y=n.bottom-(n.height+e.clientY)}this.setState({isDragging:!0,offset:t})}handleMouseUp(){this.setState({isDragging:!1})}handleKeyDown(e){if(e.key==="Alt")e.preventDefault(),this.setState({mode:"delete"});else if(e.key==="Delete"||e.key==="Backspace"){const{selectedIds:t,onLinkDeleted:n}=this.props;e.preventDefault(),t.forEach(s=>n(s))}}handleKeyUp(e){e.key==="Alt"&&(e.preventDefault(),this.setState({mode:"select"}))}handleEscapePressed(){const{onCancel:e}=this.props;e()}render(){const{disabled:e,links:t,selectedIds:n,messageText:s,onLinkSelected:i,onLinkDeleted:o,onAllLinksDeleted:a,onDone:r}=this.props,{mouse:c,dialog:h,isDragging:u,mode:m}=this.state,p=t.map(g=>{try{const{id:C,type:f,isReversed:S,start:v,end:w,operator:T}=g,y=v.columnType;let[E,I]=this.getPointFromLinkPoint(v),F=c?.x??E,N=c?.y??I;if(w!=null&&([F,N]=this.getPointFromLinkPoint(w)),S!=null&&S){const[P,O]=[E,I];[E,I]=[F,N],[F,N]=[P,O]}const H=$("linker-link",{disabled:e},{"link-filter-source":f==="filterSource"},{"link-invalid":f==="invalid"},{interactive:g.end==null},{"link-is-selected":n.has(C)},{"danger-delete":m==="delete"});return{x1:E,y1:I,x2:F,y2:N,id:C,className:H,operator:T,startColumnType:y}}catch(C){return Zr.warn("Unable to get point for link",g,C),null}}).filter(g=>g!=null);return l.jsxs("div",{className:$("linker-overlay",{"danger-delete":m==="delete"}),children:[p.map(({x1:g,y1:C,x2:f,y2:S,id:v,className:w,operator:T,startColumnType:y})=>l.jsx(vo,{className:w,id:v,x1:g,y1:C,x2:f,y2:S,onClick:i,onDelete:o,isSelected:n.has(v),operator:T,startColumnType:y,onOperatorChanged:this.handleOperatorChanged},v)),l.jsxs("div",{className:$("linker-toast-dialog",{dragging:u}),ref:this.dialogRef,style:{bottom:h?.y,right:h?.x},children:[l.jsx(V,{draggable:!0,kind:"inline",className:"btn-drag-handle",icon:Mo,onClick:()=>{},onMouseDown:this.handleMouseDown,children:!u&&l.jsx(tt,{children:"Drag to reposition"})}),l.jsx("div",{className:"toast-body",children:s}),l.jsxs("div",{className:"toast-footer",children:[l.jsx(V,{kind:"secondary",onClick:a,children:"Clear All"}),l.jsx(V,{kind:"primary",onClick:r,children:"Done"})]})]}),l.jsx(ae,{actions:[{action:this.handleEscapePressed,shortcut:es.LINKER_CLOSE,isGlobal:!0}]})]})}}const vt=Z.module("Linker"),oR=(d,e)=>({activeTool:cr(d),isolatedLinkerPanelId:fd(d,e.localDashboardId),links:Ki(d,e.localDashboardId),timeZone:Ao(d)}),aR=ft(oR,{setActiveTool:ur,setDashboardLinks:Sd,addDashboardLinks:ex,deleteDashboardLinks:tx,setDashboardIsolatedLinkerPanelId:fm,setDashboardColumnSelectionValidator:nx});class rR extends b.Component{constructor(e){super(e),this.handleCancel=this.handleCancel.bind(this),this.handleDone=this.handleDone.bind(this),this.handlePanelCloned=this.handlePanelCloned.bind(this),this.handleFilterColumnSelect=this.handleFilterColumnSelect.bind(this),this.handleColumnsChanged=this.handleColumnsChanged.bind(this),this.handlePanelClosed=this.handlePanelClosed.bind(this),this.handleLayoutStateChanged=this.handleLayoutStateChanged.bind(this),this.handleAllLinksDeleted=this.handleAllLinksDeleted.bind(this),this.handleLinkDeleted=this.handleLinkDeleted.bind(this),this.handleLinksUpdated=this.handleLinksUpdated.bind(this),this.handleChartColumnSelect=this.handleChartColumnSelect.bind(this),this.handleGridColumnSelect=this.handleGridColumnSelect.bind(this),this.handleUpdateValues=this.handleUpdateValues.bind(this),this.handleStateChange=this.handleStateChange.bind(this),this.handleExited=this.handleExited.bind(this),this.handleLinkSelected=this.handleLinkSelected.bind(this),this.handlePanelDragging=this.handlePanelDragging.bind(this),this.handlePanelDropped=this.handlePanelDropped.bind(this),this.isColumnSelectionValid=this.isColumnSelectionValid.bind(this),this.state={linkInProgress:void 0,selectedIds:new Set,isDraggingPanel:!1}}componentDidMount(){const{layout:e}=this.props;this.startListening(e),this.updateSelectionValidators()}componentDidUpdate(e){const{activeTool:t,layout:n}=this.props;n!==e.layout&&(this.stopListening(e.layout),this.startListening(n)),t!==e.activeTool&&(this.updateSelectionValidators(),t===jt.DEFAULT&&this.reset())}componentDidCatch(e,t){vt.error("componentDidCatch",e,t)}componentWillUnmount(){const{layout:e}=this.props;this.stopListening(e)}startListening(e){e.on("stateChanged",this.handleLayoutStateChanged);const{eventHub:t}=e;t.on(Cn.COLUMN_SELECTED,this.handleGridColumnSelect),t.on(Cn.DATA_SELECTED,this.handleUpdateValues),t.on(Cn.STATE_CHANGED,this.handleStateChange),t.on(pl.COLUMN_SELECTED,this.handleChartColumnSelect),t.on(Ee.CLONED,this.handlePanelCloned),t.on(Qe.COLUMN_SELECTED,this.handleFilterColumnSelect),t.on(Qe.COLUMNS_CHANGED,this.handleColumnsChanged),t.on(Ee.CLOSE,this.handlePanelClosed),t.on(Ee.CLOSED,this.handlePanelClosed),t.on(Ee.DRAGGING,this.handlePanelDragging),t.on(Ee.DROPPED,this.handlePanelDropped)}stopListening(e){e.off("stateChanged",this.handleLayoutStateChanged);const{eventHub:t}=e;t.off(Cn.COLUMN_SELECTED,this.handleGridColumnSelect),t.off(Cn.DATA_SELECTED,this.handleUpdateValues),t.off(Cn.STATE_CHANGED,this.handleStateChange),t.off(pl.COLUMN_SELECTED,this.handleChartColumnSelect),t.off(Ee.CLONED,this.handlePanelCloned),t.off(Qe.COLUMN_SELECTED,this.handleFilterColumnSelect),t.off(Qe.COLUMNS_CHANGED,this.handleColumnsChanged),t.off(Ee.CLOSE,this.handlePanelClosed),t.off(Ee.CLOSED,this.handlePanelClosed),t.off(Ee.DRAGGING,this.handlePanelDragging),t.off(Ee.DROPPED,this.handlePanelDropped)}reset(){this.setState({linkInProgress:void 0,selectedIds:new Set})}handleCancel(){const{linkInProgress:e}=this.state;if(e==null){const{setActiveTool:t}=this.props;t(jt.DEFAULT)}this.setState({linkInProgress:void 0})}handleDone(){const{setActiveTool:e}=this.props;e(jt.DEFAULT)}handleChartColumnSelect(e,t){this.columnSelected(e,t,!0)}handleFilterColumnSelect(e,t){vt.debug("handleFilterColumnSelect",this.isOverlayShown());const{links:n,localDashboardId:s,setActiveTool:i,setDashboardIsolatedLinkerPanelId:o}=this.props,a=q.getIdFromPanel(e),r=n.filter(c=>c.start?.panelId===a||c.end?.panelId===a);if(!this.isOverlayShown()&&a!=null){i(jt.LINKER),o(s,a),r.length===0&&this.columnSelected(e,t,!0,a);return}this.columnSelected(e,t,!0)}handleColumnsChanged(e,t){vt.debug("handleColumnsChanged",e,t);const{links:n}=this.props,s=q.getIdFromPanel(e);if(s==null){vt.error("Invalid panelId",e);return}const i=n.filter(({start:o,end:a})=>o.panelId===s&&ys.findColumn(t,o)==null||a!=null&&a.panelId===s&&ys.findColumn(t,a)==null);this.deleteLinks(i)}handleGridColumnSelect(e,t){if(!oh(t)){vt.debug2("Column is not filterable");return}this.columnSelected(e,t)}columnSelected(e,t,n=!1,s){if(s===void 0&&!this.isOverlayShown())return;const{isolatedLinkerPanelId:i}=this.props,{linkInProgress:o}=this.state,a=q.getIdFromPanel(e);if(a==null)return;const r=q.getComponentNameFromPanel(e),{name:c,type:h}=t;if(o==null||o.start==null){const u={id:Pe.generate(),start:{panelId:a,panelComponent:r,columnName:c,columnType:h},type:"invalid",isReversed:n};vt.debug("starting link",u),this.setState({linkInProgress:u})}else{const{links:u}=this.props,{start:m,id:p,isReversed:g}=o,C={panelId:a,panelComponent:r,columnName:c,columnType:h},f=ys.getLinkType(g!==void 0&&g?C:m,g!==void 0&&g?m:C,s??i);switch(f){case"invalid":vt.debug("Ignore invalid link connection",o,C);return;case"filterSource":{const v=g!==void 0&&g?m.panelId:C.panelId,w=u.filter(({end:T})=>T?.panelId===v);this.deleteLinks(w);break}}const S={start:g!==void 0&&g?C:m,end:g!==void 0&&g?m:C,id:p,type:f,operator:Y.eq};vt.info("creating link",S),this.setState({linkInProgress:void 0,selectedIds:new Set([p])},()=>{this.addLinks([S])})}}unsetFilterValueForLink(e){const{panelManager:t}=this.props;if(e.end){const{end:n}=e,{panelId:s,columnName:i,columnType:o}=n,a=t.getOpenedPanelById(s);a?ih(a)?a.unsetFilterValue(i,o):vt.debug("endPanel.unsetFilterValue not implemented",a):vt.debug("endPanel no longer exists, ignoring unsetFilterValue",s)}}setPanelFilterMap(e,t){vt.debug("Set filter data for panel:",e,t);const{panelManager:n}=this.props,s=n.getOpenedPanelById(e);s?ih(s)?s.setFilterMap(t):vt.debug("panel.setFilterMap not implemented",e,s):vt.debug("panel no longer exists, ignoring setFilterMap",e)}addLinks(e){const{addDashboardLinks:t,localDashboardId:n}=this.props;t(n,e)}deleteLinks(e,t=!1){const{localDashboardId:n}=this.props;if(e.forEach(s=>this.unsetFilterValueForLink(s)),t){const{setDashboardLinks:s}=this.props;s(n,[])}else if(e.length>0){const{deleteDashboardLinks:s}=this.props;s(n,e.map(({id:i})=>i))}}handleAllLinksDeleted(){const{links:e,isolatedLinkerPanelId:t}=this.props;if(t===void 0)this.deleteLinks(e,!0);else{const n=e.filter(s=>s?.start?.panelId===t||s?.end?.panelId===t);this.deleteLinks(n)}this.reset()}handleLinkDeleted(e){const{links:t}=this.props,n=t.find(s=>s.id===e);n?this.deleteLinks([n]):vt.error("Unable to find link to delete",e)}handleUpdateValues(e,t){const n=q.getIdFromPanel(e),{links:s,timeZone:i}=this.props,o=new Map;for(let a=0;a<s.length;a+=1){const{start:r,end:c,operator:h}=s[a];if(r.panelId===n&&c!=null){const{panelId:u,columnName:m,columnType:p}=c,g=o.has(u)?o.get(u):new Map,C=g.has(m)===!0?g.get(m).filterList:[],{visibleIndex:f,isExpandable:S,isGrouped:v}=t[r.columnName];let{value:w}=t[r.columnName],T=`${w}`;w===null&&S&&v&&(w=void 0),p!=null&&R.isDateType(p)&&(T=new _e({timeZone:i,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:et.FULL_DATE_FORMAT}).format(w));const y={operator:h,text:T,value:w,startColumnIndex:f};C.push(y),g.set(m,{columnType:p,filterList:C}),o.set(u,g)}}o.forEach((a,r)=>{this.setPanelFilterMap(r,a)})}handlePanelCloned(e,t){const{links:n}=this.props,s=q.getIdFromPanel(e),i=t.id;if(s!=null){const o=ys.cloneLinksForPanel(n,s,i);this.addLinks(o)}}handlePanelDragging(e){const{links:t}=this.props;for(let n=0;n<t.length;n+=1){const s=t[n],{start:i,end:o}=s;if(i.panelId===e||o?.panelId===e){this.setState({isDraggingPanel:!0});return}}}handlePanelDropped(){this.setState({isDraggingPanel:!1})}handlePanelClosed(e){vt.debug(`Panel ${e} closed, deleting links.`),this.deleteLinksForPanelId(e)}handleLinkSelected(e){this.setState({selectedIds:new Set([e])})}handleLinksUpdated(e){const{localDashboardId:t,setDashboardLinks:n}=this.props;n(t,e)}handleLayoutStateChanged(){this.forceUpdate()}handleStateChange(){this.forceUpdate()}handleExited(){const{localDashboardId:e,setDashboardIsolatedLinkerPanelId:t}=this.props;t(e,void 0)}deleteLinksForPanelId(e){const{links:t}=this.props;for(let n=0;n<t.length;n+=1){const s=t[n],{start:i,end:o,id:a}=s;(i.panelId===e||o?.panelId===e)&&this.handleLinkDeleted(a)}}getCachedLinks=fe((e,t,n)=>{const s=[...e];return t!=null&&t.start!=null&&s.push(t),n!==void 0?s.filter(i=>i?.start?.panelId===n||i?.end?.panelId===n||i?.end==null):s});isOverlayShown(){const{activeTool:e}=this.props;return e===jt.LINKER}updateSelectionValidators(){const{activeTool:e,setDashboardColumnSelectionValidator:t,localDashboardId:n}=this.props;switch(e){case jt.LINKER:t(n,this.isColumnSelectionValid);break;default:t(n,void 0);break}}updateLinkInProgressType(e,t="invalid"){this.setState({linkInProgress:{...e,type:t}})}isColumnSelectionValid(e,t){const{linkInProgress:n}=this.state,{isolatedLinkerPanelId:s}=this.props;if(t==null)return n?.start!=null&&this.updateLinkInProgressType(n),!1;if(!oh(t))return vt.debug2("Column is not filterable",t.description),n?.start!=null&&this.updateLinkInProgressType(n,"invalid"),!1;if(n?.start==null)return!0;const{isReversed:i,start:o}=n,a=q.getIdFromPanel(e);if(a==null)return!1;const r={panelId:a,panelComponent:q.getComponentNameFromPanel(e),columnName:t.name,columnType:t.type},c=i!==void 0&&i?ys.getLinkType(r,o,s):ys.getLinkType(o,r,s);return this.updateLinkInProgressType(n,c),c!=="invalid"}render(){const{links:e,isolatedLinkerPanelId:t,panelManager:n}=this.props,{linkInProgress:s,selectedIds:i,isDraggingPanel:o}=this.state,a=this.isOverlayShown(),r=s!=null&&s.start!=null,c=t===void 0?"Click a column source, then click a column target to create a filter link. The filter comparison operator used by a selected link can be changed. Delete a filter link by clicking the delete button or with alt+click. Click done when finished.":"Create a link between the source column button and a table column by clicking on one, then the other. Delete a filter link by clicking the delete button or with alt+click. Click done when finished.";return o?null:l.jsx(gt,{in:a,timeout:We.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,onExited:this.handleExited,children:l.jsx(iR,{disabled:r,panelManager:n,links:this.getCachedLinks(e,s,t),selectedIds:i,messageText:c,onLinkSelected:this.handleLinkSelected,onLinkDeleted:this.handleLinkDeleted,onAllLinksDeleted:this.handleAllLinksDeleted,onLinksUpdated:this.handleLinksUpdated,onDone:this.handleDone,onCancel:this.handleCancel})})}}const lR=aR(rR);function dR(d){Ps(d);const{id:e,layout:t,panelManager:n}=d;return l.jsx(lR,{layout:t,localDashboardId:e,panelManager:n})}class Li{static DEFAULT_TITLE="Note";static DEFAULT_CONTENT=`# Markdown Note
|
|
37
37
|
|
|
38
|
-
This note can be edited using **markdown** for styling.`;static getNewMarkdownTitle(e){let t=`${Li.DEFAULT_TITLE}`,n=0;for(;e.indexOf(t)>=0;)n+=1,t=`${Li.DEFAULT_TITLE}-${n}`;return t}}function cR(d){Ps(d);const{id:e,layout:t,panelManager:n,registerComponent:s}=d,i=b.useCallback(a=>{const{title:r,componentState:c,props:h}=a;let{panelState:u=null}=h;return c!=null&&({panelState:u=null}=c),r==null||u==null||u.content==null||u.content.length===0||u.content===Li.DEFAULT_CONTENT?null:Ql(a)},[]),o=b.useCallback(({title:a="",metadata:r={},id:c=Pe.generate(),focusElement:h=q.DEFAULT_FOCUS_SELECTOR,createNewStack:u=!1,dragEvent:m=null}={})=>{const p=n.getOpenedPanelConfigsOfType(co.COMPONENT),g=n.getClosedPanelConfigsOfType(co.COMPONENT),C=p.map(T=>T.title??""),f=a!=null&&a!==""?a:Li.getNewMarkdownTitle(C),S=g.length>0?null:Li.DEFAULT_CONTENT,v={type:"react-component",component:co.COMPONENT,props:{id:c,metadata:r,panelState:{content:S},localDashboardId:e},title:f,id:c},{root:w}=t;q.openComponent({root:w,config:v,focusElement:h,createNewStack:u,dragEvent:m})},[e,t,n]);return b.useEffect(function(){const r=[s(co.COMPONENT,co,Jl,i)];return()=>{r.forEach(c=>c())}},[i,s]),Ue(t.eventHub,pm.OPEN,o),null}function hR(d){Ps(d);const{hydrate:e,id:t,layout:n,registerComponent:s}=d,i=b.useCallback(({dragEvent:o,fetch:a,panelId:r=Pe.generate(),widget:c})=>{const{name:h,type:u}=c;if(u!==dh.VariableType.PANDAS)return;const m={name:h,table:h},p=()=>a().then(f=>ud.makeModel(f)),g={type:"react-component",component:Xr.COMPONENT,props:{localDashboardId:t,id:r,metadata:m,makeModel:p},title:h,id:r},{root:C}=n;q.openComponent({root:C,config:g,dragEvent:o})},[t,n]);return b.useEffect(function(){const a=[s(Xr.COMPONENT,Xr,e)];return()=>{a.forEach(r=>r())}},[e,s]),Ue(n.eventHub,Ee.OPEN,i),null}class Is{static DROPDOWN_FILTER="ControlType.DROPDOWN_FILTER";static INPUT_FILTER="ControlType.INPUT_FILTER";static MARKDOWN="ControlType.MARKDOWN";static FILTER_SET_MANAGER="ControlType.FILTER_SET_MANAGER"}D.shape({state:D.shape({panelState:D.shape({})})});D.shape({panelId:D.string.isRequired,columnName:D.string.isRequired,columnType:D.string.isRequired});const uh=D.shape({panelId:D.string.isRequired,columnName:D.string.isRequired}),uR=D.shape({start:uh,end:uh,id:D.string,isReversed:D.bool});D.arrayOf(uR);D.shape({name:D.string.isRequired,operateAs:D.string.isRequired,groups:D.arrayOf(D.string).isRequired,permissions:D.shape({isSuperUser:D.bool.isRequired,isQueryViewOnly:D.bool.isRequired,isNonInteractive:D.bool.isRequired,canUsePanels:D.bool.isRequired,canCreateDashboard:D.bool.isRequired,canCreateCodeStudio:D.bool.isRequired,canCreateQueryMonitor:D.bool.isRequired,canCopy:D.bool.isRequired,canDownloadCsv:D.bool.isRequired}).isRequired});Z.module("StorageTableViewportUpdater");class mh{static makeSortConfig(e,t){return{column:e,direction:t}}static makeFilterConfig(e){const t=[],n=[];return e.forEach((s,i)=>{t.push(s),i>0&&n.push(Sn.and)}),{filterItems:t,filterOperators:n}}static combineFilterConfigs(e,t,n=Sn.and){return{filterItems:[...e.filterItems,...t.filterItems],filterOperators:[...e.filterOperators,n,...t.filterOperators]}}static makeFilterItem(e,t,n){return{columnName:e,type:t,value:n}}}const Qr=Z.module("PouchStorageTable"),mR="Deephaven.";Th.plugin(dp);function pR(d,e){switch(d){case Y.in:case Y.contains:return{$regex:new RegExp(`${e}`)};case Y.inIgnoreCase:return{$regex:new RegExp(`${e}`,"i")};case Y.eq:return{$eq:e};case Y.notEq:return{$neq:e};case Y.greaterThan:return{$gt:e};case Y.greaterThanOrEqualTo:return{$gte:e};case Y.lessThan:return{$lt:e};case Y.lessThanOrEqualTo:return{$lte:e};case Y.startsWith:return{$regex:new RegExp(`^(?${e}).*`)};default:throw new Error(`Unsupported type: ${d}`)}}function gR(d){const{filterItems:e,filterOperators:t}=d;let n=null;for(let s=0;s<e.length;s+=1){const i=e[s],{columnName:o,type:a,value:r}=i,c={[o]:pR(a,r)};if(s===0)n=c;else if(n!==null&&s-1<t.length){const h=t[s-1];if(h===Sn.and)n={$and:[n,c]};else if(h===Sn.or)n={$or:[n,c]};else throw new Error(`Unexpected filter operator ${h}, ${c}`)}}if(n==null)throw new Error(`Invalid filter config ${d}`);return n}function Jr(d=[]){return{$and:[...d.map(e=>gR(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function fR(d,e=!1){return[{id:e?"desc":"asc"},...d?.map(t=>({[t.column]:t.direction}))??[]]}class CR{db;listeners=[];itemListeners=new Map;currentSize=0;currentViewport;currentReverse=!1;currentFilter=null;currentSort=null;infoUpdatePromise;viewportUpdatePromise;currentViewportData;constructor(e){this.db=new Th(`${mR}${e}`),this.db._remote=!1,this.db.changes({live:!0,since:"now",include_docs:!0}).on("change",this.dbUpdate.bind(this)),this.db.createIndex({index:{fields:["id","name"]}}),this.refreshInfo()}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(t=>t!==e)}}onItemUpdate(e,t){return this.itemListeners.has(e)||this.itemListeners.set(e,[]),this.itemListeners.set(e,[...this.itemListeners.get(e),t]),this.refreshItem(e),()=>{this.itemListeners.set(e,this.itemListeners.get(e).filter(n=>n!==t))}}close(){this.listeners=[]}get size(){return this.currentSize}get viewport(){return this.currentViewport}setReversed(e){this.currentReverse=e,this.currentViewportData=void 0,this.refreshData()}setViewport(e){this.currentViewport=e,this.refreshInfo(),this.refreshData()}setSorts(e){this.currentSort=e,this.currentViewportData=void 0,this.refreshData()}setFilters(e){this.currentFilter=e,this.currentViewportData=void 0,this.refreshInfo(),this.refreshData()}get data(){return this.currentViewportData}async getViewportData(){return this.viewportUpdatePromise||this.refreshData(),this.viewportUpdatePromise??Promise.resolve({items:[],offset:0})}async put(e){const t={...e,_id:e.id};return await this.db.put(t),t}sendUpdate(){const{listeners:e}=this,t=this.currentViewportData??{items:[],offset:0};for(let n=0;n<e.length;n+=1)e[n](t)}sendItemUpdate(e){const t=this.itemListeners.get(e.id);if(t!==void 0)for(let n=0;n<t.length;n+=1)t[n](e)}dbUpdate(e){Qr.debug("Update received",e),this.refreshInfo(),e.doc!==void 0&&this.sendItemUpdate(e.doc),this.refreshData()}async refreshInfo(){try{this.infoUpdatePromise?.cancel(),this.infoUpdatePromise=ve.makeCancelable(this.db.find({selector:Jr(this.currentFilter??[]),fields:[]}));const e=await this.infoUpdatePromise;this.currentSize=e.docs.length,this.sendUpdate()}catch(e){if(!ve.isCanceled(e))throw Qr.error("Unable to refreshInfo",e),e}}async refreshData(){if(this.currentViewport)try{const{currentViewport:e}=this,t=fR(this.currentSort,this.currentReverse);this.viewportUpdatePromise?.cancel(),this.viewportUpdatePromise=ve.makeCancelable(this.db.find({selector:Jr(this.currentFilter??[]),skip:e.top,limit:e.bottom-e.top+1,sort:t,fields:["id","name"]}).then(s=>({items:s.docs,offset:e.top})));const n=await this.viewportUpdatePromise;return this.currentViewportData=n,this.sendUpdate(),n}catch(e){if(!ve.isCanceled(e))throw Qr.error("Unable to refreshData",e),e}}async refreshItem(e){const n=(await this.db.find({selector:{id:e},limit:1})).docs[0];return n!==void 0&&this.sendItemUpdate(n),n}async getSnapshot(e){const t=new Map,n=[{id:this.currentReverse?"desc":"asc"}];return await Promise.all(e.map(async([s,i])=>{const o=i-s+1;return this.db.find({selector:Jr(this.currentFilter??[]),skip:s,limit:o,sort:n,fields:["id","name"]}).then(a=>{for(let r=0;r<o;r+=1){const c=s+r;t.set(c,a.docs[r])}})})),t}}class ph extends CR{constructor(e){super(`CommandHistoryStorage.${e}`)}setSearch(e){this.setFilters(e?[mh.makeFilterConfig([mh.makeFilterItem("name",Y.contains,e)])]:[])}}const gh=Z.module("PouchCommandHistoryStorage");class SR{updateTableMap=new Map;getUpdateTable(e){return this.updateTableMap.has(e)||this.updateTableMap.set(e,new ph(e)),this.updateTableMap.get(e)}async getTable(e){return new ph(e)}async addItem(e,t,n,s){return this.updateItem(e,{id:`${new Date().getTime()}`,name:n,data:s})}async updateItem(e,t){const n=this.getUpdateTable(e),i={...await n.refreshItem(t.id)??{},...t};return gh.debug("Updating item",i),await n.put(i),gh.debug("Update saved"),t}listenItem(e,t,n){return this.getUpdateTable(e).onItemUpdate(t,n)}}const Em="SET_LAYOUT_STORAGE",bR=d=>({type:Em,payload:d}),ym="/ide/assets/community-wordmark-app-d2c5c1eb.svg";const wR=Z.module("FormattingSectionContent");function vR(d){return d.formatString!=null}function Sl(d){const e=d?.querySelector("input, select, textarea");e&&e.focus()}function xm(d,e){return d.defaultFormatString===e.defaultFormatString}function TR(d,e){return xm(d,e)}function ER(d,e){return xm(d,e)}function Rm(d){return d!==""&&cn.isValidColumnName(d)}function Ds(d,e){if(!d||e.formatString==null||!vR(e))return!1;switch(d){case"datetime":return _e.isValid(e);case"decimal":return Re.isValid(e);case"int":return $e.isValid(e);default:return wR.warn("Trying to validate format of unknown type"),!0}}function Im(d){const{id:e,isNewRule:t,...n}=d;return n}function Dm(d){return Rm(d.columnName)&&Ds(d.columnType,d.format)}function Fm(d){const{timestamp:e,timeZone:t,showTimeZone:n,showTSeparator:s,isGlobalOptions:i,legacyGlobalFormat:o}=d,a=new Zt([],{timeZone:t,showTimeZone:n,showTSeparator:s}),r=i?_e.getGlobalFormats(n,s):_e.getFormats(n,s);return o!=null&&!r.includes(o)&&r.unshift(o),l.jsx(l.Fragment,{children:r.map(c=>{const h=_e.makeFormat("",c,_e.TYPE_GLOBAL);return l.jsx("option",{value:c,"data-testid":"time-format",children:a.getFormattedString(e,R.dataType.DATETIME,"",h)},c)})})}function yR(){return l.jsx(l.Fragment,{children:Wi.TIME_ZONES.map(d=>{const{label:e,value:t}=d;return l.jsx("option",{value:t,children:e},t)})})}const Ys=Z.module("FormattingSectionContent");class yd extends b.PureComponent{static defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:_e.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:Re.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:$e.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:_e.DEFAULT_TIME_ZONE_ID}};static inputDebounceTime=250;constructor(e){super(e),this.debouncedCommitChanges=Ye(this.commitChanges.bind(this),yd.inputDebounceTime),this.handleDefaultDateTimeFormatChange=this.handleDefaultDateTimeFormatChange.bind(this),this.handleDefaultDecimalFormatChange=this.handleDefaultDecimalFormatChange.bind(this),this.handleDefaultIntegerFormatChange=this.handleDefaultIntegerFormatChange.bind(this),this.handleShowTimeZoneChange=this.handleShowTimeZoneChange.bind(this),this.handleShowTSeparatorChange=this.handleShowTSeparatorChange.bind(this),this.handleTimeZoneChange=this.handleTimeZoneChange.bind(this),this.handleResetDateTimeFormat=this.handleResetDateTimeFormat.bind(this),this.handleResetDecimalFormat=this.handleResetDecimalFormat.bind(this),this.handleResetIntegerFormat=this.handleResetIntegerFormat.bind(this),this.handleResetTimeZone=this.handleResetTimeZone.bind(this),this.handleTruncateNumbersWithPoundChange=this.handleTruncateNumbersWithPoundChange.bind(this);const{formatter:t,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:a,timeZone:r,truncateNumbersWithPound:c}=e,h=t.map((u,m)=>({...u,id:m}));this.containerRef=X.createRef(),this.state={formatSettings:h,showTimeZone:o,showTSeparator:a,timeZone:r,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:c,timestampAtMenuOpen:new Date}}componentDidMount(){Sl(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}debouncedCommitChanges;containerRef;getCachedDateTimeFormatOptions=pe((e,t,n,s=!1,i)=>{const{timestampAtMenuOpen:o}=this.state;return l.jsx(Fm,{timestamp:o,timeZone:e,showTimeZone:t,showTSeparator:n,isGlobalOptions:s,legacyGlobalFormat:i})});handleDefaultDateTimeFormatChange(e){Ys.debug("handleDefaultDateTimeFormatChange",e.target.value),this.setState({defaultDateTimeFormat:e.target.value},()=>{this.debouncedCommitChanges()})}handleDefaultDecimalFormatChange(e){Ys.debug("handleDefaultDecimalFormatChange",e.target.value),this.setState({defaultDecimalFormatOptions:{defaultFormatString:e.target.value}},()=>{this.debouncedCommitChanges()})}handleDefaultIntegerFormatChange(e){Ys.debug("handleDefaultIntegerFormatChange",e.target.value),this.setState({defaultIntegerFormatOptions:{defaultFormatString:e.target.value}},()=>{this.debouncedCommitChanges()})}handleShowTimeZoneChange(){this.setState(e=>({showTimeZone:!e.showTimeZone}),()=>{this.debouncedCommitChanges()})}handleShowTSeparatorChange(){this.setState(e=>({showTSeparator:!e.showTSeparator}),()=>{this.debouncedCommitChanges()})}handleTimeZoneChange(e){this.setState({timeZone:e.target.value},()=>{this.debouncedCommitChanges()})}handleResetDateTimeFormat(){const{defaults:e}=this.props,{defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s}=e;Ys.debug("handleResetDateTimeFormat"),this.setState({defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s},()=>{this.debouncedCommitChanges()})}handleResetTimeZone(){const{defaults:e}=this.props,{timeZone:t}=e;Ys.debug("handleResetTimeZone"),this.setState({timeZone:t},()=>{this.debouncedCommitChanges()})}handleResetDecimalFormat(){const{defaults:e}=this.props,{defaultDecimalFormatOptions:t}=e;Ys.debug("handleResetDecimalFormat"),this.setState({defaultDecimalFormatOptions:t},()=>{this.debouncedCommitChanges()})}handleResetIntegerFormat(){const{defaults:e}=this.props,{defaultIntegerFormatOptions:t}=e;Ys.debug("handleResetIntegerFormat"),this.setState({defaultIntegerFormatOptions:t},()=>{this.debouncedCommitChanges()})}handleTruncateNumbersWithPoundChange(){this.setState(e=>({truncateNumbersWithPound:!e.truncateNumbersWithPound}),()=>{this.debouncedCommitChanges()})}commitChanges(){const{formatSettings:e,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:a,truncateNumbersWithPound:r}=this.state,c=e.filter(Dm).map(Im)??[],{settings:h,saveSettings:u}=this.props,m={...h,formatter:c,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:r};Ds(R.dataType.DECIMAL,Re.makeCustomFormat(o.defaultFormatString))&&(m.defaultDecimalFormatOptions=o),Ds(R.dataType.INT,$e.makeCustomFormat(a.defaultFormatString))&&(m.defaultIntegerFormatOptions=a),u(m)}render(){const{defaults:e}=this.props,{defaultDateTimeFormat:t,defaultDecimalFormatOptions:n,defaultIntegerFormatOptions:s,timeZone:i,showTimeZone:o,showTSeparator:a,truncateNumbersWithPound:r}=this.state,{defaultFormatString:c=Re.DEFAULT_FORMAT_STRING}=n??{},{defaultFormatString:h=$e.DEFAULT_FORMAT_STRING}=s??{},u=i===e.timeZone,m=a===e.showTSeparator&&o===e.showTimeZone&&t===e.defaultDateTimeFormat,p=TR(n,e.defaultDecimalFormatOptions),g=ER(s,e.defaultIntegerFormatOptions);return l.jsx("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:l.jsxs("div",{className:"container-fluid p-0",children:[l.jsx("div",{className:"app-settings-menu-description mb-3",children:"Choose the default formatting rule to apply to all table columns based on their type."}),l.jsxs("div",{className:"form-row mb-2",children:[l.jsx("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),l.jsx("div",{className:"col pr-0",children:l.jsx("select",{className:"custom-select",value:i,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:l.jsx(yR,{})})}),l.jsx("div",{className:"col-1 btn-col",children:l.jsx(V,{kind:"ghost",icon:ei,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:$("btn-reset","btn-reset-time-zone",{hidden:u})})})]}),l.jsxs("div",{className:"form-row mb-2",children:[l.jsx("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),l.jsx("div",{className:"col pr-0",children:l.jsx("select",{className:"custom-select",value:t,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(i,o,a,!0,t)})}),l.jsx("div",{className:"col-1 btn-col",children:l.jsx(V,{kind:"ghost",icon:ei,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:$("btn-reset","btn-reset-date-time",{hidden:m})})})]}),l.jsx("div",{className:"form-row",children:l.jsx("div",{className:"offset-3 col-9",children:l.jsx(Xt,{checked:o??null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),l.jsx("div",{className:"form-row mb-3",children:l.jsx("div",{className:"offset-3 col-9",children:l.jsx(Xt,{checked:a??null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),l.jsxs("div",{className:"form-row mb-2",children:[l.jsx("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),l.jsx("div",{className:"col pr-0",children:l.jsx("input",{className:$("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!Ds(R.dataType.DECIMAL,Re.makeCustomFormat(c))}),"data-lpignore":!0,placeholder:Re.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:c,onChange:this.handleDefaultDecimalFormatChange})}),l.jsx("div",{className:"col-1 btn-col",children:l.jsx(V,{kind:"ghost",icon:ei,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:$("btn-reset","btn-reset-decimal",{hidden:p}),"data-testid":"btn-reset-decimal"})})]}),l.jsxs("div",{className:"form-row mb-2",children:[l.jsx("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),l.jsx("div",{className:"col pr-0",children:l.jsx("input",{className:$("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!Ds(R.dataType.INT,$e.makeCustomFormat(h))}),"data-lpignore":!0,placeholder:$e.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:h,onChange:this.handleDefaultIntegerFormatChange})}),l.jsx("div",{className:"col-1 btn-col",children:l.jsx(V,{kind:"ghost",icon:ei,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:$("btn-reset","btn-reset-integer",{hidden:g}),"data-testid":"btn-reset-integer"})})]}),l.jsx("div",{className:"form-row mb-3",children:l.jsx("div",{className:"offset-3 col-9",children:l.jsx(Xt,{checked:r??null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Truncate numbers with #"})})})]})})}}const xR=d=>({formatter:cu(d),defaultDateTimeFormat:ru(d),defaultDecimalFormatOptions:lu(d),defaultIntegerFormatOptions:du(d),showTimeZone:hu(d),showTSeparator:uu(d),truncateNumbersWithPound:mu(d),timeZone:Ao(d),settings:Ct(d)}),RR=ft(xR,{saveSettings:hr})(yd);function IR(){const[d,e]=b.useState(!1),t=()=>{e(!d)};return l.jsxs(V,{kind:"ghost",onClick:t,icon:bg,children:["Legal Notices",l.jsxs(Do,{isOpen:d,toggle:t,className:"theme-bg-light",children:[l.jsx(Fo,{toggle:t,children:"Legal Notice"}),l.jsxs(No,{children:[l.jsx("p",{children:"Deephaven software is protected by U.S. Patent Nos. 9,612,959; 9,613,018; 9,613,109; 9,619,210; 9,633,060; 9,639,570; 9,672,238; 9,679,006; 9,690,821; 9,710,511; 9,760,591; 9,805,084; 9,836,495; 9,836,494; 9,886,469; 9,898,496; 9,934,266; 10,002,153; 10,002,154; 10,002,155; 10,003,673; 10,019,138; 10,069,943; 10,176,211; 10,198,465; 10,198,466; 10,198,469; 10,212,257; 10,241,960; 10,241,965; 10,242,040; 10,242,041; 10,353,893; 10,346,394; 10,452,649; 10,496,639; 10,540,351; 10,552,412; 10,565,194; 10,565,206; 10,572,474; 10,621,168; 10,642,829; 10,657,184; 10,678,787; 10,691,686; and 10,783,191. Other patents pending."}),l.jsxs("p",{children:["© 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})}function To(d){const{children:e,isExpanded:t,sectionKey:n,title:s,onToggle:i}=d;return l.jsxs(l.Fragment,{children:[l.jsx("div",{children:l.jsxs(V,{kind:"ghost",className:"btn-collapse-trigger",onClick:()=>i(n),children:[l.jsx("div",{className:"flex-grow-1",children:s}),l.jsx("div",{className:"flex-shrink-0",children:l.jsx(J,{transform:t?"flip-v":"",icon:kn})})]})}),l.jsx(lf,{in:t,autoFocusOnShow:!0,children:e})]})}To.propTypes={children:D.node,isExpanded:D.bool.isRequired,sectionKey:D.string.isRequired,title:D.node.isRequired,onToggle:D.func};To.defaultProps={children:null,onToggle:()=>{}};function DR({shortcut:d,displayText:e,categoryName:t,onChange:n}){const[s,i]=b.useState(e),[o,a]=b.useState(d.getKeyState()),[r,c]=b.useState(!1),[h,u]=b.useState("");b.useEffect(function(){i(e),a(d.getKeyState())},[e,d]),b.useEffect(function(){i(ke.getDisplayText(o)),d.matchesKeyState(o)&&c(!1)},[o,d]),b.useEffect(function(){if(r){if(!ke.isValidKeyState(o)){ke.isAllowedKey(o.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const T=Fe.getConflictingShortcuts(o).filter(y=>y.id.startsWith(t)&&y!==d).map(y=>y.name);if(T.length){u(`Conflicts with ${T.join(", ")}`);return}u("")}else u("")},[r,o,t,d]);function m(w){if(w.stopPropagation(),w.preventDefault(),d.isEditable&&!w.repeat){const T=ke.getKeyStateFromEvent(w),y=ke.createKeyState([ue.BACKSPACE]);ke.doKeyStatesMatch(T,y)?a(ke.NULL_KEY_STATE):a(T)}}function p(w){w.stopPropagation(),w.preventDefault(),d.matchesKeyState(o)||c(!0)}function g(){He.disableAllActions()}function C(){He.enableAllActions()}function f(){d.setKeyState(o),c(!1),n(d)}function S(){const w=d.getKeyState();a(w),c(!1)}function v(){c(!0),a(d.getDefaultKeyState())}return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"shortcut-item-container",children:[l.jsxs("label",{className:"shortcut-item-name",children:[d.name,d.tooltip!==void 0&&l.jsx(tt,{children:d.tooltip})]}),l.jsxs("div",{className:"shortcut-item-input-container",children:[l.jsx("input",{className:$("form-control",{"is-invalid":h}),onKeyDown:m,onKeyUp:p,onFocus:g,onBlur:C,disabled:!d.isEditable,value:s,readOnly:!0}),!ke.doKeyStatesMatch(o,d.getDefaultKeyState())&&!h&&l.jsx(V,{className:"reset-to-default-button",kind:"ghost",icon:l.jsx(J,{icon:ei,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:v})]})]}),r&&l.jsxs("div",{className:$("shortcut-item-message-container",{"is-invalid":h}),children:[l.jsx("div",{className:"shortcut-item-message",children:h}),l.jsxs("div",{className:"shortcut-item-message-buttons",children:[ke.isValidKeyState(o)&&l.jsx(V,{kind:"ghost",onClick:f,children:"Confirm"}),l.jsx(V,{kind:"ghost",onClick:S,children:"Undo"})]})]})]})}function FR({shortcutOverrides:d={},settings:e,saveSettings:t}){const n=b.useCallback(a=>{const r=ke.isMacPlatform,c={mac:{...d.mac},windows:{...d.windows}},h=r?c.mac:c.windows;a.forEach(u=>{u.isDefault()?delete h[u.id]:h[u.id]=u.getKeyState()}),t({...e,shortcutOverrides:c})},[e,t,d]);let s=Array.from(Fe.shortcutsByCategory.entries()).map(([a,r])=>({name:a,shortcuts:r}));const i=s.findIndex(a=>a.name.toUpperCase()==="GLOBAL"),o=s.splice(i,1);return s=s.concat(o),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. To prevent unexpected results, avoid conflicting shortcuts with the browser or IDE editor."}),s.map(a=>l.jsx(NR,{name:a.name,shortcuts:a.shortcuts,saveShortcutOverrides:n},a.name))]})}function NR({name:d,shortcuts:e,saveShortcutOverrides:t}){function n(r){return r.split("_").map(c=>`${c[0].toUpperCase()}${c.slice(1).toLowerCase()}`).join(" ")}const[s,i]=b.useState(e);function o(r){const c=s.filter(u=>u!==r&&!u.isNull()&&u.matchesKeyState(r.getKeyState()));c.forEach(u=>u.setToNull());const h=[r,...c];t(h),i(u=>[...u])}const a=b.useMemo(()=>s.map(r=>r.getDisplayText()),[s]);return l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"font-weight-bold",children:n(d)}),s.map((r,c)=>l.jsx(DR,{shortcut:r,displayText:a[c],categoryName:d,onChange:o},r.id))]})}const MR=d=>({settings:Ct(d),shortcutOverrides:BS(d)}),kR={saveSettings:hr},OR=ft(MR,kR)(FR),AR="yyyy-MM-dd-HHmmss";function Nm(d,e="root",t=new Map([[d,""]])){const n={};return Object.entries(d).forEach(([s,i])=>{try{JSON.stringify(i),n[s]=i}catch{const a=i;if(typeof i=="bigint")n[s]=i.toString();else if(t.has(a))n[s]=`Circular ref to ${t.get(a)}`;else{const r=`${e}.${s}`;t.set(a,r),n[s]=Nm(i,r,t)}}}),n}function LR(){const d=mr.getState();return JSON.stringify(Nm(d),null,2)}function PR(d){const e={uiVersion:"0.32.0",userAgent:navigator.userAgent,...d};return JSON.stringify(e,null,2)}async function _R(d=`${x.i18n.DateTimeFormat.format(AR,new Date)}_support_logs`,e){const t=new Eh,n=t.folder(d);n.file("console.txt",wg.getFormattedHistory()),n.file("redux.json",LR()),n.file("metadata.json",PR(e));const s=await t.generateAsync({type:"blob"}),i=document.createElement("a");i.href=URL.createObjectURL(s),i.download=`${d}.zip`,i.click()}const jR=[{value:R.dataType.DATETIME,label:"DateTime"},{value:R.dataType.DECIMAL,label:"Decimal"},{value:R.dataType.INT,label:"Integer"}];function HR(){const d=jR.map(e=>l.jsx("option",{value:e.value,children:e.label},`key-columnType-${e.value}`));return l.jsxs(l.Fragment,{children:[l.jsx("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),d]})}class xd extends b.PureComponent{static defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:_e.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:Re.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:$e.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:_e.DEFAULT_TIME_ZONE_ID}};static inputDebounceTime=250;constructor(e){super(e),this.debouncedCommitChanges=Ye(this.commitChanges.bind(this),xd.inputDebounceTime),this.handleFormatRuleEntered=this.handleFormatRuleEntered.bind(this),this.handleFormatRuleChange=this.handleFormatRuleChange.bind(this),this.handleFormatRuleCreate=this.handleFormatRuleCreate.bind(this),this.handleFormatRuleDelete=this.handleFormatRuleDelete.bind(this);const{formatter:t,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:a,timeZone:r,truncateNumbersWithPound:c}=e,h=t.map((u,m)=>({...u,id:m}));this.containerRef=X.createRef(),this.addFormatRuleButtonRef=X.createRef(),this.lastFormatRuleIndex=h.length,this.state={formatSettings:h,formatRulesChanged:!1,showTimeZone:o,showTSeparator:a,timeZone:r,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:c,timestampAtMenuOpen:new Date}}componentDidMount(){Sl(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}debouncedCommitChanges;containerRef;addFormatRuleButtonRef;lastFormatRuleIndex;isDuplicateRule(e){const{formatSettings:t}=this.state;return t.some(n=>n.id!==e.id&&n.columnName===e.columnName&&n.columnType===e.columnType)??!1}getAutoIncrementFormatRuleIndex(){const{lastFormatRuleIndex:e}=this;return this.lastFormatRuleIndex+=1,e}getCachedColumnTypeOptions=pe(()=>l.jsx(HR,{}));getCachedDateTimeFormatOptions=pe((e,t,n,s=!1,i)=>{const{timestampAtMenuOpen:o}=this.state;return l.jsx(Fm,{timestamp:o,timeZone:e,showTimeZone:t,showTSeparator:n,isGlobalOptions:s,legacyGlobalFormat:i})});handleFormatRuleChange(e,t,n){this.setState(s=>{const{formatSettings:i}=s;M(i);const o=[...i];let a={};t==="columnType"&&(a={format:""});const r={...o[e],...a,[t]:n};return o[e]=r,{formatSettings:o}},()=>{this.debouncedCommitChanges()})}handleFormatRuleCreate(){this.setState(e=>{const{formatSettings:t}=e,n={columnType:R.dataType.DATETIME,columnName:"",format:{},id:this.getAutoIncrementFormatRuleIndex(),isNewRule:!0};return{formatSettings:t!=null?[...t,n]:[n],formatRulesChanged:!0}})}handleFormatRuleDelete(e){this.setState(t=>{const{formatSettings:n}=t;return{formatSettings:n.filter((i,o)=>o!==e),formatRulesChanged:!0}},()=>{this.debouncedCommitChanges()})}handleFormatRuleEntered(e){this.scrollToFormatBlockBottom(),Sl(e)}commitChanges(){const{formatSettings:e,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:a,truncateNumbersWithPound:r}=this.state,c=e.filter(Dm).map(Im)??[],{settings:h,saveSettings:u}=this.props,m={...h,formatter:c,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:r};Ds(R.dataType.DECIMAL,Re.makeCustomFormat(o.defaultFormatString))&&(m.defaultDecimalFormatOptions=o),Ds(R.dataType.INT,$e.makeCustomFormat(a.defaultFormatString))&&(m.defaultIntegerFormatOptions=a),u(m)}scrollToFormatBlockBottom(){const{scrollTo:e}=this.props;e(0,(this.addFormatRuleButtonRef.current?.offsetHeight??0)+(this.addFormatRuleButtonRef.current?.offsetTop??0))}getRuleError(e){const t={hasColumnNameError:!1,hasFormatError:!1,message:""},n=[];return e.isNewRule!==void 0&&e.isNewRule||(this.isDuplicateRule(e)&&(t.hasColumnNameError=!0,n.push("Duplicate column name/type combo.")),Rm(e.columnName)||(t.hasColumnNameError=!0,n.push("Column names must start with a letter or underscore and contain only alphanumeric characters or underscores.")),e.format.formatString!==void 0&&e.format.formatString.length===0?(t.hasFormatError=!0,n.push("Empty formatting rule.")):Ds(e.columnType,e.format)||(t.hasFormatError=!0,n.push("Invalid formatting rule.")),t.message=n.join(`
|
|
38
|
+
This note can be edited using **markdown** for styling.`;static getNewMarkdownTitle(e){let t=`${Li.DEFAULT_TITLE}`,n=0;for(;e.indexOf(t)>=0;)n+=1,t=`${Li.DEFAULT_TITLE}-${n}`;return t}}function cR(d){Ps(d);const{id:e,layout:t,panelManager:n,registerComponent:s}=d,i=b.useCallback(a=>{const{title:r,componentState:c,props:h}=a;let{panelState:u=null}=h;return c!=null&&({panelState:u=null}=c),r==null||u==null||u.content==null||u.content.length===0||u.content===Li.DEFAULT_CONTENT?null:Ql(a)},[]),o=b.useCallback(({title:a="",metadata:r={},id:c=Pe.generate(),focusElement:h=q.DEFAULT_FOCUS_SELECTOR,createNewStack:u=!1,dragEvent:m=null}={})=>{const p=n.getOpenedPanelConfigsOfType(co.COMPONENT),g=n.getClosedPanelConfigsOfType(co.COMPONENT),C=p.map(T=>T.title??""),f=a!=null&&a!==""?a:Li.getNewMarkdownTitle(C),S=g.length>0?null:Li.DEFAULT_CONTENT,v={type:"react-component",component:co.COMPONENT,props:{id:c,metadata:r,panelState:{content:S},localDashboardId:e},title:f,id:c},{root:w}=t;q.openComponent({root:w,config:v,focusElement:h,createNewStack:u,dragEvent:m})},[e,t,n]);return b.useEffect(function(){const r=[s(co.COMPONENT,co,Jl,i)];return()=>{r.forEach(c=>c())}},[i,s]),Ue(t.eventHub,pm.OPEN,o),null}function hR(d){Ps(d);const{hydrate:e,id:t,layout:n,registerComponent:s}=d,i=b.useCallback(({dragEvent:o,fetch:a,panelId:r=Pe.generate(),widget:c})=>{const{name:h,type:u}=c;if(u!==dh.VariableType.PANDAS)return;const m={name:h,table:h},p=()=>a().then(f=>ud.makeModel(f)),g={type:"react-component",component:Xr.COMPONENT,props:{localDashboardId:t,id:r,metadata:m,makeModel:p},title:h,id:r},{root:C}=n;q.openComponent({root:C,config:g,dragEvent:o})},[t,n]);return b.useEffect(function(){const a=[s(Xr.COMPONENT,Xr,e)];return()=>{a.forEach(r=>r())}},[e,s]),Ue(n.eventHub,Ee.OPEN,i),null}class Is{static DROPDOWN_FILTER="ControlType.DROPDOWN_FILTER";static INPUT_FILTER="ControlType.INPUT_FILTER";static MARKDOWN="ControlType.MARKDOWN";static FILTER_SET_MANAGER="ControlType.FILTER_SET_MANAGER"}D.shape({state:D.shape({panelState:D.shape({})})});D.shape({panelId:D.string.isRequired,columnName:D.string.isRequired,columnType:D.string.isRequired});const uh=D.shape({panelId:D.string.isRequired,columnName:D.string.isRequired}),uR=D.shape({start:uh,end:uh,id:D.string,isReversed:D.bool});D.arrayOf(uR);D.shape({name:D.string.isRequired,operateAs:D.string.isRequired,groups:D.arrayOf(D.string).isRequired,permissions:D.shape({isSuperUser:D.bool.isRequired,isQueryViewOnly:D.bool.isRequired,isNonInteractive:D.bool.isRequired,canUsePanels:D.bool.isRequired,canCreateDashboard:D.bool.isRequired,canCreateCodeStudio:D.bool.isRequired,canCreateQueryMonitor:D.bool.isRequired,canCopy:D.bool.isRequired,canDownloadCsv:D.bool.isRequired}).isRequired});Z.module("StorageTableViewportUpdater");class mh{static makeSortConfig(e,t){return{column:e,direction:t}}static makeFilterConfig(e){const t=[],n=[];return e.forEach((s,i)=>{t.push(s),i>0&&n.push(Sn.and)}),{filterItems:t,filterOperators:n}}static combineFilterConfigs(e,t,n=Sn.and){return{filterItems:[...e.filterItems,...t.filterItems],filterOperators:[...e.filterOperators,n,...t.filterOperators]}}static makeFilterItem(e,t,n){return{columnName:e,type:t,value:n}}}const Qr=Z.module("PouchStorageTable"),mR="Deephaven.";Th.plugin(dp);function pR(d,e){switch(d){case Y.in:case Y.contains:return{$regex:new RegExp(`${e}`)};case Y.inIgnoreCase:return{$regex:new RegExp(`${e}`,"i")};case Y.eq:return{$eq:e};case Y.notEq:return{$neq:e};case Y.greaterThan:return{$gt:e};case Y.greaterThanOrEqualTo:return{$gte:e};case Y.lessThan:return{$lt:e};case Y.lessThanOrEqualTo:return{$lte:e};case Y.startsWith:return{$regex:new RegExp(`^(?${e}).*`)};default:throw new Error(`Unsupported type: ${d}`)}}function gR(d){const{filterItems:e,filterOperators:t}=d;let n=null;for(let s=0;s<e.length;s+=1){const i=e[s],{columnName:o,type:a,value:r}=i,c={[o]:pR(a,r)};if(s===0)n=c;else if(n!==null&&s-1<t.length){const h=t[s-1];if(h===Sn.and)n={$and:[n,c]};else if(h===Sn.or)n={$or:[n,c]};else throw new Error(`Unexpected filter operator ${h}, ${c}`)}}if(n==null)throw new Error(`Invalid filter config ${d}`);return n}function Jr(d=[]){return{$and:[...d.map(e=>gR(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function fR(d,e=!1){return[{id:e?"desc":"asc"},...d?.map(t=>({[t.column]:t.direction}))??[]]}class CR{db;listeners=[];itemListeners=new Map;currentSize=0;currentViewport;currentReverse=!1;currentFilter=null;currentSort=null;infoUpdatePromise;viewportUpdatePromise;currentViewportData;constructor(e){this.db=new Th(`${mR}${e}`),this.db._remote=!1,this.db.changes({live:!0,since:"now",include_docs:!0}).on("change",this.dbUpdate.bind(this)),this.db.createIndex({index:{fields:["id","name"]}}),this.refreshInfo()}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(t=>t!==e)}}onItemUpdate(e,t){return this.itemListeners.has(e)||this.itemListeners.set(e,[]),this.itemListeners.set(e,[...this.itemListeners.get(e),t]),this.refreshItem(e),()=>{this.itemListeners.set(e,this.itemListeners.get(e).filter(n=>n!==t))}}close(){this.listeners=[]}get size(){return this.currentSize}get viewport(){return this.currentViewport}setReversed(e){this.currentReverse=e,this.currentViewportData=void 0,this.refreshData()}setViewport(e){this.currentViewport=e,this.refreshInfo(),this.refreshData()}setSorts(e){this.currentSort=e,this.currentViewportData=void 0,this.refreshData()}setFilters(e){this.currentFilter=e,this.currentViewportData=void 0,this.refreshInfo(),this.refreshData()}get data(){return this.currentViewportData}async getViewportData(){return this.viewportUpdatePromise||this.refreshData(),this.viewportUpdatePromise??Promise.resolve({items:[],offset:0})}async put(e){const t={...e,_id:e.id};return await this.db.put(t),t}sendUpdate(){const{listeners:e}=this,t=this.currentViewportData??{items:[],offset:0};for(let n=0;n<e.length;n+=1)e[n](t)}sendItemUpdate(e){const t=this.itemListeners.get(e.id);if(t!==void 0)for(let n=0;n<t.length;n+=1)t[n](e)}dbUpdate(e){Qr.debug("Update received",e),this.refreshInfo(),e.doc!==void 0&&this.sendItemUpdate(e.doc),this.refreshData()}async refreshInfo(){try{this.infoUpdatePromise?.cancel(),this.infoUpdatePromise=ve.makeCancelable(this.db.find({selector:Jr(this.currentFilter??[]),fields:[]}));const e=await this.infoUpdatePromise;this.currentSize=e.docs.length,this.sendUpdate()}catch(e){if(!ve.isCanceled(e))throw Qr.error("Unable to refreshInfo",e),e}}async refreshData(){if(this.currentViewport)try{const{currentViewport:e}=this,t=fR(this.currentSort,this.currentReverse);this.viewportUpdatePromise?.cancel(),this.viewportUpdatePromise=ve.makeCancelable(this.db.find({selector:Jr(this.currentFilter??[]),skip:e.top,limit:e.bottom-e.top+1,sort:t,fields:["id","name"]}).then(s=>({items:s.docs,offset:e.top})));const n=await this.viewportUpdatePromise;return this.currentViewportData=n,this.sendUpdate(),n}catch(e){if(!ve.isCanceled(e))throw Qr.error("Unable to refreshData",e),e}}async refreshItem(e){const n=(await this.db.find({selector:{id:e},limit:1})).docs[0];return n!==void 0&&this.sendItemUpdate(n),n}async getSnapshot(e){const t=new Map,n=[{id:this.currentReverse?"desc":"asc"}];return await Promise.all(e.map(async([s,i])=>{const o=i-s+1;return this.db.find({selector:Jr(this.currentFilter??[]),skip:s,limit:o,sort:n,fields:["id","name"]}).then(a=>{for(let r=0;r<o;r+=1){const c=s+r;t.set(c,a.docs[r])}})})),t}}class ph extends CR{constructor(e){super(`CommandHistoryStorage.${e}`)}setSearch(e){this.setFilters(e?[mh.makeFilterConfig([mh.makeFilterItem("name",Y.contains,e)])]:[])}}const gh=Z.module("PouchCommandHistoryStorage");class SR{updateTableMap=new Map;getUpdateTable(e){return this.updateTableMap.has(e)||this.updateTableMap.set(e,new ph(e)),this.updateTableMap.get(e)}async getTable(e){return new ph(e)}async addItem(e,t,n,s){return this.updateItem(e,{id:`${new Date().getTime()}`,name:n,data:s})}async updateItem(e,t){const n=this.getUpdateTable(e),i={...await n.refreshItem(t.id)??{},...t};return gh.debug("Updating item",i),await n.put(i),gh.debug("Update saved"),t}listenItem(e,t,n){return this.getUpdateTable(e).onItemUpdate(t,n)}}const Em="SET_LAYOUT_STORAGE",bR=d=>({type:Em,payload:d}),ym="/ide/assets/community-wordmark-app-d2c5c1eb.svg";const wR=Z.module("FormattingSectionContent");function vR(d){return d.formatString!=null}function Sl(d){const e=d?.querySelector("input, select, textarea");e&&e.focus()}function xm(d,e){return d.defaultFormatString===e.defaultFormatString}function TR(d,e){return xm(d,e)}function ER(d,e){return xm(d,e)}function Rm(d){return d!==""&&cn.isValidColumnName(d)}function Ds(d,e){if(!d||e.formatString==null||!vR(e))return!1;switch(d){case"datetime":return _e.isValid(e);case"decimal":return Re.isValid(e);case"int":return $e.isValid(e);default:return wR.warn("Trying to validate format of unknown type"),!0}}function Im(d){const{id:e,isNewRule:t,...n}=d;return n}function Dm(d){return Rm(d.columnName)&&Ds(d.columnType,d.format)}function Fm(d){const{timestamp:e,timeZone:t,showTimeZone:n,showTSeparator:s,isGlobalOptions:i,legacyGlobalFormat:o}=d,a=new Zt([],{timeZone:t,showTimeZone:n,showTSeparator:s}),r=i?_e.getGlobalFormats(n,s):_e.getFormats(n,s);return o!=null&&!r.includes(o)&&r.unshift(o),l.jsx(l.Fragment,{children:r.map(c=>{const h=_e.makeFormat("",c,_e.TYPE_GLOBAL);return l.jsx("option",{value:c,"data-testid":"time-format",children:a.getFormattedString(e,R.dataType.DATETIME,"",h)},c)})})}function yR(){return l.jsx(l.Fragment,{children:Wi.TIME_ZONES.map(d=>{const{label:e,value:t}=d;return l.jsx("option",{value:t,children:e},t)})})}const Ys=Z.module("FormattingSectionContent");class yd extends b.PureComponent{static defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:_e.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:Re.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:$e.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:_e.DEFAULT_TIME_ZONE_ID}};static inputDebounceTime=250;constructor(e){super(e),this.debouncedCommitChanges=Ye(this.commitChanges.bind(this),yd.inputDebounceTime),this.handleDefaultDateTimeFormatChange=this.handleDefaultDateTimeFormatChange.bind(this),this.handleDefaultDecimalFormatChange=this.handleDefaultDecimalFormatChange.bind(this),this.handleDefaultIntegerFormatChange=this.handleDefaultIntegerFormatChange.bind(this),this.handleShowTimeZoneChange=this.handleShowTimeZoneChange.bind(this),this.handleShowTSeparatorChange=this.handleShowTSeparatorChange.bind(this),this.handleTimeZoneChange=this.handleTimeZoneChange.bind(this),this.handleResetDateTimeFormat=this.handleResetDateTimeFormat.bind(this),this.handleResetDecimalFormat=this.handleResetDecimalFormat.bind(this),this.handleResetIntegerFormat=this.handleResetIntegerFormat.bind(this),this.handleResetTimeZone=this.handleResetTimeZone.bind(this),this.handleTruncateNumbersWithPoundChange=this.handleTruncateNumbersWithPoundChange.bind(this);const{formatter:t,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:a,timeZone:r,truncateNumbersWithPound:c}=e,h=t.map((u,m)=>({...u,id:m}));this.containerRef=X.createRef(),this.state={formatSettings:h,showTimeZone:o,showTSeparator:a,timeZone:r,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:c,timestampAtMenuOpen:new Date}}componentDidMount(){Sl(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}debouncedCommitChanges;containerRef;getCachedDateTimeFormatOptions=pe((e,t,n,s=!1,i)=>{const{timestampAtMenuOpen:o}=this.state;return l.jsx(Fm,{timestamp:o,timeZone:e,showTimeZone:t,showTSeparator:n,isGlobalOptions:s,legacyGlobalFormat:i})});handleDefaultDateTimeFormatChange(e){Ys.debug("handleDefaultDateTimeFormatChange",e.target.value),this.setState({defaultDateTimeFormat:e.target.value},()=>{this.debouncedCommitChanges()})}handleDefaultDecimalFormatChange(e){Ys.debug("handleDefaultDecimalFormatChange",e.target.value),this.setState({defaultDecimalFormatOptions:{defaultFormatString:e.target.value}},()=>{this.debouncedCommitChanges()})}handleDefaultIntegerFormatChange(e){Ys.debug("handleDefaultIntegerFormatChange",e.target.value),this.setState({defaultIntegerFormatOptions:{defaultFormatString:e.target.value}},()=>{this.debouncedCommitChanges()})}handleShowTimeZoneChange(){this.setState(e=>({showTimeZone:!e.showTimeZone}),()=>{this.debouncedCommitChanges()})}handleShowTSeparatorChange(){this.setState(e=>({showTSeparator:!e.showTSeparator}),()=>{this.debouncedCommitChanges()})}handleTimeZoneChange(e){this.setState({timeZone:e.target.value},()=>{this.debouncedCommitChanges()})}handleResetDateTimeFormat(){const{defaults:e}=this.props,{defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s}=e;Ys.debug("handleResetDateTimeFormat"),this.setState({defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s},()=>{this.debouncedCommitChanges()})}handleResetTimeZone(){const{defaults:e}=this.props,{timeZone:t}=e;Ys.debug("handleResetTimeZone"),this.setState({timeZone:t},()=>{this.debouncedCommitChanges()})}handleResetDecimalFormat(){const{defaults:e}=this.props,{defaultDecimalFormatOptions:t}=e;Ys.debug("handleResetDecimalFormat"),this.setState({defaultDecimalFormatOptions:t},()=>{this.debouncedCommitChanges()})}handleResetIntegerFormat(){const{defaults:e}=this.props,{defaultIntegerFormatOptions:t}=e;Ys.debug("handleResetIntegerFormat"),this.setState({defaultIntegerFormatOptions:t},()=>{this.debouncedCommitChanges()})}handleTruncateNumbersWithPoundChange(){this.setState(e=>({truncateNumbersWithPound:!e.truncateNumbersWithPound}),()=>{this.debouncedCommitChanges()})}commitChanges(){const{formatSettings:e,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:a,truncateNumbersWithPound:r}=this.state,c=e.filter(Dm).map(Im)??[],{settings:h,saveSettings:u}=this.props,m={...h,formatter:c,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:r};Ds(R.dataType.DECIMAL,Re.makeCustomFormat(o.defaultFormatString))&&(m.defaultDecimalFormatOptions=o),Ds(R.dataType.INT,$e.makeCustomFormat(a.defaultFormatString))&&(m.defaultIntegerFormatOptions=a),u(m)}render(){const{defaults:e}=this.props,{defaultDateTimeFormat:t,defaultDecimalFormatOptions:n,defaultIntegerFormatOptions:s,timeZone:i,showTimeZone:o,showTSeparator:a,truncateNumbersWithPound:r}=this.state,{defaultFormatString:c=Re.DEFAULT_FORMAT_STRING}=n??{},{defaultFormatString:h=$e.DEFAULT_FORMAT_STRING}=s??{},u=i===e.timeZone,m=a===e.showTSeparator&&o===e.showTimeZone&&t===e.defaultDateTimeFormat,p=TR(n,e.defaultDecimalFormatOptions),g=ER(s,e.defaultIntegerFormatOptions);return l.jsx("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:l.jsxs("div",{className:"container-fluid p-0",children:[l.jsx("div",{className:"app-settings-menu-description mb-3",children:"Choose the default formatting rule to apply to all table columns based on their type."}),l.jsxs("div",{className:"form-row mb-2",children:[l.jsx("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),l.jsx("div",{className:"col pr-0",children:l.jsx("select",{className:"custom-select",value:i,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:l.jsx(yR,{})})}),l.jsx("div",{className:"col-1 btn-col",children:l.jsx(V,{kind:"ghost",icon:ei,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:$("btn-reset","btn-reset-time-zone",{hidden:u})})})]}),l.jsxs("div",{className:"form-row mb-2",children:[l.jsx("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),l.jsx("div",{className:"col pr-0",children:l.jsx("select",{className:"custom-select",value:t,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(i,o,a,!0,t)})}),l.jsx("div",{className:"col-1 btn-col",children:l.jsx(V,{kind:"ghost",icon:ei,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:$("btn-reset","btn-reset-date-time",{hidden:m})})})]}),l.jsx("div",{className:"form-row",children:l.jsx("div",{className:"offset-3 col-9",children:l.jsx(Xt,{checked:o??null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),l.jsx("div",{className:"form-row mb-3",children:l.jsx("div",{className:"offset-3 col-9",children:l.jsx(Xt,{checked:a??null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),l.jsxs("div",{className:"form-row mb-2",children:[l.jsx("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),l.jsx("div",{className:"col pr-0",children:l.jsx("input",{className:$("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!Ds(R.dataType.DECIMAL,Re.makeCustomFormat(c))}),"data-lpignore":!0,placeholder:Re.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:c,onChange:this.handleDefaultDecimalFormatChange})}),l.jsx("div",{className:"col-1 btn-col",children:l.jsx(V,{kind:"ghost",icon:ei,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:$("btn-reset","btn-reset-decimal",{hidden:p}),"data-testid":"btn-reset-decimal"})})]}),l.jsxs("div",{className:"form-row mb-2",children:[l.jsx("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),l.jsx("div",{className:"col pr-0",children:l.jsx("input",{className:$("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!Ds(R.dataType.INT,$e.makeCustomFormat(h))}),"data-lpignore":!0,placeholder:$e.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:h,onChange:this.handleDefaultIntegerFormatChange})}),l.jsx("div",{className:"col-1 btn-col",children:l.jsx(V,{kind:"ghost",icon:ei,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:$("btn-reset","btn-reset-integer",{hidden:g}),"data-testid":"btn-reset-integer"})})]}),l.jsx("div",{className:"form-row mb-3",children:l.jsx("div",{className:"offset-3 col-9",children:l.jsx(Xt,{checked:r??null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Truncate numbers with #"})})})]})})}}const xR=d=>({formatter:cu(d),defaultDateTimeFormat:ru(d),defaultDecimalFormatOptions:lu(d),defaultIntegerFormatOptions:du(d),showTimeZone:hu(d),showTSeparator:uu(d),truncateNumbersWithPound:mu(d),timeZone:Ao(d),settings:Ct(d)}),RR=ft(xR,{saveSettings:hr})(yd);function IR(){const[d,e]=b.useState(!1),t=()=>{e(!d)};return l.jsxs(V,{kind:"ghost",onClick:t,icon:bg,children:["Legal Notices",l.jsxs(Do,{isOpen:d,toggle:t,className:"theme-bg-light",children:[l.jsx(Fo,{toggle:t,children:"Legal Notice"}),l.jsxs(No,{children:[l.jsx("p",{children:"Deephaven software is protected by U.S. Patent Nos. 9,612,959; 9,613,018; 9,613,109; 9,619,210; 9,633,060; 9,639,570; 9,672,238; 9,679,006; 9,690,821; 9,710,511; 9,760,591; 9,805,084; 9,836,495; 9,836,494; 9,886,469; 9,898,496; 9,934,266; 10,002,153; 10,002,154; 10,002,155; 10,003,673; 10,019,138; 10,069,943; 10,176,211; 10,198,465; 10,198,466; 10,198,469; 10,212,257; 10,241,960; 10,241,965; 10,242,040; 10,242,041; 10,353,893; 10,346,394; 10,452,649; 10,496,639; 10,540,351; 10,552,412; 10,565,194; 10,565,206; 10,572,474; 10,621,168; 10,642,829; 10,657,184; 10,678,787; 10,691,686; and 10,783,191. Other patents pending."}),l.jsxs("p",{children:["© 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})}function To(d){const{children:e,isExpanded:t,sectionKey:n,title:s,onToggle:i}=d;return l.jsxs(l.Fragment,{children:[l.jsx("div",{children:l.jsxs(V,{kind:"ghost",className:"btn-collapse-trigger",onClick:()=>i(n),children:[l.jsx("div",{className:"flex-grow-1",children:s}),l.jsx("div",{className:"flex-shrink-0",children:l.jsx(J,{transform:t?"flip-v":"",icon:kn})})]})}),l.jsx(lf,{in:t,autoFocusOnShow:!0,children:e})]})}To.propTypes={children:D.node,isExpanded:D.bool.isRequired,sectionKey:D.string.isRequired,title:D.node.isRequired,onToggle:D.func};To.defaultProps={children:null,onToggle:()=>{}};function DR({shortcut:d,displayText:e,categoryName:t,onChange:n}){const[s,i]=b.useState(e),[o,a]=b.useState(d.getKeyState()),[r,c]=b.useState(!1),[h,u]=b.useState("");b.useEffect(function(){i(e),a(d.getKeyState())},[e,d]),b.useEffect(function(){i(ke.getDisplayText(o)),d.matchesKeyState(o)&&c(!1)},[o,d]),b.useEffect(function(){if(r){if(!ke.isValidKeyState(o)){ke.isAllowedKey(o.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const T=Fe.getConflictingShortcuts(o).filter(y=>y.id.startsWith(t)&&y!==d).map(y=>y.name);if(T.length){u(`Conflicts with ${T.join(", ")}`);return}u("")}else u("")},[r,o,t,d]);function m(w){if(w.stopPropagation(),w.preventDefault(),d.isEditable&&!w.repeat){const T=ke.getKeyStateFromEvent(w),y=ke.createKeyState([ue.BACKSPACE]);ke.doKeyStatesMatch(T,y)?a(ke.NULL_KEY_STATE):a(T)}}function p(w){w.stopPropagation(),w.preventDefault(),d.matchesKeyState(o)||c(!0)}function g(){He.disableAllActions()}function C(){He.enableAllActions()}function f(){d.setKeyState(o),c(!1),n(d)}function S(){const w=d.getKeyState();a(w),c(!1)}function v(){c(!0),a(d.getDefaultKeyState())}return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"shortcut-item-container",children:[l.jsxs("label",{className:"shortcut-item-name",children:[d.name,d.tooltip!==void 0&&l.jsx(tt,{children:d.tooltip})]}),l.jsxs("div",{className:"shortcut-item-input-container",children:[l.jsx("input",{className:$("form-control",{"is-invalid":h}),onKeyDown:m,onKeyUp:p,onFocus:g,onBlur:C,disabled:!d.isEditable,value:s,readOnly:!0}),!ke.doKeyStatesMatch(o,d.getDefaultKeyState())&&!h&&l.jsx(V,{className:"reset-to-default-button",kind:"ghost",icon:l.jsx(J,{icon:ei,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:v})]})]}),r&&l.jsxs("div",{className:$("shortcut-item-message-container",{"is-invalid":h}),children:[l.jsx("div",{className:"shortcut-item-message",children:h}),l.jsxs("div",{className:"shortcut-item-message-buttons",children:[ke.isValidKeyState(o)&&l.jsx(V,{kind:"ghost",onClick:f,children:"Confirm"}),l.jsx(V,{kind:"ghost",onClick:S,children:"Undo"})]})]})]})}function FR({shortcutOverrides:d={},settings:e,saveSettings:t}){const n=b.useCallback(a=>{const r=ke.isMacPlatform,c={mac:{...d.mac},windows:{...d.windows}},h=r?c.mac:c.windows;a.forEach(u=>{u.isDefault()?delete h[u.id]:h[u.id]=u.getKeyState()}),t({...e,shortcutOverrides:c})},[e,t,d]);let s=Array.from(Fe.shortcutsByCategory.entries()).map(([a,r])=>({name:a,shortcuts:r}));const i=s.findIndex(a=>a.name.toUpperCase()==="GLOBAL"),o=s.splice(i,1);return s=s.concat(o),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. To prevent unexpected results, avoid conflicting shortcuts with the browser or IDE editor."}),s.map(a=>l.jsx(NR,{name:a.name,shortcuts:a.shortcuts,saveShortcutOverrides:n},a.name))]})}function NR({name:d,shortcuts:e,saveShortcutOverrides:t}){function n(r){return r.split("_").map(c=>`${c[0].toUpperCase()}${c.slice(1).toLowerCase()}`).join(" ")}const[s,i]=b.useState(e);function o(r){const c=s.filter(u=>u!==r&&!u.isNull()&&u.matchesKeyState(r.getKeyState()));c.forEach(u=>u.setToNull());const h=[r,...c];t(h),i(u=>[...u])}const a=b.useMemo(()=>s.map(r=>r.getDisplayText()),[s]);return l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"font-weight-bold",children:n(d)}),s.map((r,c)=>l.jsx(DR,{shortcut:r,displayText:a[c],categoryName:d,onChange:o},r.id))]})}const MR=d=>({settings:Ct(d),shortcutOverrides:BS(d)}),kR={saveSettings:hr},OR=ft(MR,kR)(FR),AR="yyyy-MM-dd-HHmmss";function Nm(d,e="root",t=new Map([[d,""]])){const n={};return Object.entries(d).forEach(([s,i])=>{try{JSON.stringify(i),n[s]=i}catch{const a=i;if(typeof i=="bigint")n[s]=i.toString();else if(t.has(a))n[s]=`Circular ref to ${t.get(a)}`;else{const r=`${e}.${s}`;t.set(a,r),n[s]=Nm(i,r,t)}}}),n}function LR(){const d=mr.getState();return JSON.stringify(Nm(d),null,2)}function PR(d){const e={uiVersion:"0.32.0",userAgent:navigator.userAgent,...d};return JSON.stringify(e,null,2)}async function _R(d=`${x.i18n.DateTimeFormat.format(AR,new Date)}_support_logs`,e){const t=new Eh,n=t.folder(d);n.file("console.txt",wg.getFormattedHistory()),n.file("redux.json",LR()),n.file("metadata.json",PR(e));const s=await t.generateAsync({type:"blob"}),i=document.createElement("a");i.href=URL.createObjectURL(s),i.download=`${d}.zip`,i.click()}const jR=[{value:R.dataType.DATETIME,label:"DateTime"},{value:R.dataType.DECIMAL,label:"Decimal"},{value:R.dataType.INT,label:"Integer"}];function HR(){const d=jR.map(e=>l.jsx("option",{value:e.value,children:e.label},`key-columnType-${e.value}`));return l.jsxs(l.Fragment,{children:[l.jsx("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),d]})}class xd extends b.PureComponent{static defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:_e.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:Re.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:$e.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:_e.DEFAULT_TIME_ZONE_ID}};static inputDebounceTime=250;constructor(e){super(e),this.debouncedCommitChanges=Ye(this.commitChanges.bind(this),xd.inputDebounceTime),this.handleFormatRuleEntered=this.handleFormatRuleEntered.bind(this),this.handleFormatRuleChange=this.handleFormatRuleChange.bind(this),this.handleFormatRuleCreate=this.handleFormatRuleCreate.bind(this),this.handleFormatRuleDelete=this.handleFormatRuleDelete.bind(this);const{formatter:t,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:a,timeZone:r,truncateNumbersWithPound:c}=e,h=t.map((u,m)=>({...u,id:m}));this.containerRef=X.createRef(),this.addFormatRuleButtonRef=X.createRef(),this.lastFormatRuleIndex=h.length,this.state={formatSettings:h,formatRulesChanged:!1,showTimeZone:o,showTSeparator:a,timeZone:r,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:c,timestampAtMenuOpen:new Date}}componentDidMount(){Sl(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}debouncedCommitChanges;containerRef;addFormatRuleButtonRef;lastFormatRuleIndex;isDuplicateRule(e){const{formatSettings:t}=this.state;return t.some(n=>n.id!==e.id&&n.columnName===e.columnName&&n.columnType===e.columnType)??!1}getAutoIncrementFormatRuleIndex(){const{lastFormatRuleIndex:e}=this;return this.lastFormatRuleIndex+=1,e}getCachedColumnTypeOptions=pe(()=>l.jsx(HR,{}));getCachedDateTimeFormatOptions=pe((e,t,n,s=!1,i)=>{const{timestampAtMenuOpen:o}=this.state;return l.jsx(Fm,{timestamp:o,timeZone:e,showTimeZone:t,showTSeparator:n,isGlobalOptions:s,legacyGlobalFormat:i})});handleFormatRuleChange(e,t,n){this.setState(s=>{const{formatSettings:i}=s;M(i);const o=[...i];let a={};t==="columnType"&&(a={format:""});const r={...o[e],...a,[t]:n};return o[e]=r,{formatSettings:o}},()=>{this.debouncedCommitChanges()})}handleFormatRuleCreate(){this.setState(e=>{const{formatSettings:t}=e,n={columnType:R.dataType.DATETIME,columnName:"",format:{},id:this.getAutoIncrementFormatRuleIndex(),isNewRule:!0};return{formatSettings:[...t,n],formatRulesChanged:!0}})}handleFormatRuleDelete(e){this.setState(t=>{const{formatSettings:n}=t;return{formatSettings:n.filter((i,o)=>o!==e),formatRulesChanged:!0}},()=>{this.debouncedCommitChanges()})}handleFormatRuleEntered(e){this.scrollToFormatBlockBottom(),Sl(e)}commitChanges(){const{formatSettings:e,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:a,truncateNumbersWithPound:r}=this.state,c=e.filter(Dm).map(Im)??[],{settings:h,saveSettings:u}=this.props,m={...h,formatter:c,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:r};Ds(R.dataType.DECIMAL,Re.makeCustomFormat(o.defaultFormatString))&&(m.defaultDecimalFormatOptions=o),Ds(R.dataType.INT,$e.makeCustomFormat(a.defaultFormatString))&&(m.defaultIntegerFormatOptions=a),u(m)}scrollToFormatBlockBottom(){const{scrollTo:e}=this.props;e(0,(this.addFormatRuleButtonRef.current?.offsetHeight??0)+(this.addFormatRuleButtonRef.current?.offsetTop??0))}getRuleError(e){const t={hasColumnNameError:!1,hasFormatError:!1,message:""},n=[];return e.isNewRule!==void 0&&e.isNewRule||(this.isDuplicateRule(e)&&(t.hasColumnNameError=!0,n.push("Duplicate column name/type combo.")),Rm(e.columnName)||(t.hasColumnNameError=!0,n.push("Column names must start with a letter or underscore and contain only alphanumeric characters or underscores.")),e.format.formatString!==void 0&&e.format.formatString.length===0?(t.hasFormatError=!0,n.push("Empty formatting rule.")):Ds(e.columnType,e.format)||(t.hasFormatError=!0,n.push("Invalid formatting rule.")),t.message=n.join(`
|
|
39
39
|
`)),t}renderFormatRule(e,t){const n=`input-${e}-columnName`,s=`input-${e}-columnType`,i=`input-${e}-format`,o=this.getCachedColumnTypeOptions(),a=u=>this.handleFormatRuleChange(e,"columnName",u.target.value),r=()=>this.handleFormatRuleChange(e,"isNewRule",!1),c=u=>this.handleFormatRuleChange(e,"columnType",u.target.value),h=this.getRuleError(t);return l.jsxs("fieldset",{className:"container-fluid format-rule-container",children:[l.jsxs("div",{className:"form-row",children:[l.jsxs("div",{className:"form-group col-7 mb-2",children:[l.jsx("label",{htmlFor:n,children:"Column Name"}),l.jsx("input",{id:n,className:$("form-control",{"is-invalid":h.hasColumnNameError}),"data-lpignore":!0,type:"text",value:t.columnName,onChange:a,onBlur:r})]}),l.jsxs("div",{className:"form-group col mb-2",children:[l.jsx(V,{kind:"ghost",className:"btn-delete-format-rule float-right",tabIndex:-1,onClick:()=>this.handleFormatRuleDelete(e),icon:Qt,tooltip:"Delete","aria-label":"Delete Format Rule"}),l.jsx("label",{htmlFor:s,children:"Column Type"}),l.jsx("select",{id:s,className:"custom-select",value:t.columnType,onChange:c,children:o})]})]}),l.jsx("div",{className:"form-row",children:l.jsxs("div",{className:"form-group col-12 d-flex mb-2",children:[l.jsx("label",{className:"flex-shrink-0 col-form-label mr-3",htmlFor:i,children:"Formatting Rule"}),this.renderFormatRuleInput(e,t.columnType,i,t.format,h.hasFormatError)]})}),l.jsx("div",{className:"form-row",children:l.jsx("div",{className:"form-group col-12 d-flex mb-2",children:h.message&&l.jsx("p",{className:"text-danger",children:h.message})})})]},e)}renderFormatRuleInput(e,t,n,s,i){switch(R.getNormalizedType(t)){case R.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(e,n,s,i);case R.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(e,n,s,i);case R.dataType.INT:return this.renderIntegerFormatRuleInput(e,n,s,i);default:throw new Error(`Unrecognized column type: ${t}`)}}renderDateTimeFormatRuleInput(e,t,n,s){const{showTimeZone:i,showTSeparator:o,timeZone:a}=this.state,r=n.formatString??"";return l.jsxs("select",{className:$("custom-select",{"is-invalid":s}),value:r,id:t,onChange:c=>{const h=_e.makeFormat("",c.target.value,_e.TYPE_GLOBAL);this.handleFormatRuleChange(e,"format",h)},children:[l.jsx("option",{value:"",disabled:!0,children:"Select format"},"default"),this.getCachedDateTimeFormatOptions(a,i,o)]})}renderIntegerFormatRuleInput(e,t,n,s){const i=n.formatString??"";return l.jsx("input",{className:$("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:t,placeholder:$e.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const a=$e.makeFormat("",o.target.value,$e.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(e,"format",a)}})}renderDecimalFormatRuleInput(e,t,n,s){const i=n.formatString??"";return l.jsx("input",{className:$("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:t,placeholder:Re.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const a=Re.makeFormat("",o.target.value,Re.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(e,"format",a)}})}render(){const{formatRulesChanged:e,formatSettings:t}=this.state,n=t.map((i,o)=>l.jsx(gt,{classNames:"fade",timeout:We.transitionMs,onEnter:this.handleFormatRuleEntered,children:this.renderFormatRule(o,i)},i.id)),s=l.jsx(V,{kind:"ghost",className:"mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,icon:Os,children:"Add New Rule"});return l.jsxs("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[l.jsx("div",{className:"app-settings-menu-description mb-3",children:"Customize the formatting of table columns by applying rules based on matching both a column name and column type."}),l.jsx(cp,{appear:e,enter:e,exit:e,children:n}),s]})}}const BR=d=>({formatter:cu(d),defaultDateTimeFormat:ru(d),defaultDecimalFormatOptions:lu(d),defaultIntegerFormatOptions:du(d),showTimeZone:hu(d),showTSeparator:uu(d),truncateNumbersWithPound:mu(d),timeZone:Ao(d),settings:Ct(d)}),VR=ft(BR,{saveSettings:hr})(xd);class Nn extends b.Component{static defaultProps={onDone:()=>{}};static FORMATTING_SECTION_KEY="SettingsMenu.formatting";static COLUMN_SPECIFIC_SECTION_KEY="SettingsMenu.columnFormatting";static APPLICATION_SECTION_KEY="ApplicationMenu.settings";static SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";static focusFirstInputInContainer(e){const t=e?.querySelector("input, select, textarea");t&&t.focus()}constructor(e){super(e),this.handleClose=this.handleClose.bind(this),this.handleScrollTo=this.handleScrollTo.bind(this),this.handleSectionToggle=this.handleSectionToggle.bind(this),this.handleExportSupportLogs=this.handleExportSupportLogs.bind(this),this.menuContentRef=X.createRef(),this.state={expandedSectionKey:Nn.FORMATTING_SECTION_KEY}}componentDidMount(){Nn.focusFirstInputInContainer(this.menuContentRef.current)}menuContentRef;isSectionExpanded(e){const{expandedSectionKey:t}=this.state;return t===e}handleScrollTo(e,t){this.menuContentRef.current?.scrollTo(e,t)}handleSectionToggle(e){this.setState(t=>({expandedSectionKey:t.expandedSectionKey===e?void 0:e}))}handleClose(){const{onDone:e}=this.props;e()}handleExportSupportLogs(){const{serverConfigValues:e}=this.props;_R(void 0,Object.fromEntries(e))}render(){const e="0.32.0",t="https://github.com/deephaven/web-client-ui/",n="https://deephaven.io/core/docs/",{serverConfigValues:s}=this.props,i=s.get("barrage.version"),o=s.get("java.version"),a=s.get("deephaven.version"),r=(c,h)=>l.jsxs(l.Fragment,{children:[l.jsx("div",{children:c}),l.jsx("div",{children:h})]});return l.jsxs("div",{className:"app-settings-menu",children:[l.jsxs("header",{className:"app-settings-menu-header",children:[l.jsx("div",{className:"flex-spacer"}),l.jsx(V,{kind:"ghost",className:"btn-close-settings-menu",onClick:this.handleClose,icon:l.jsx(J,{icon:Ui,transform:"grow-4"}),tooltip:"Close"})]}),l.jsxs("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[l.jsx("h5",{children:"Settings"}),l.jsx("hr",{className:"my-0"}),l.jsx(To,{sectionKey:Nn.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(Nn.FORMATTING_SECTION_KEY),title:l.jsxs(l.Fragment,{children:[l.jsx(J,{icon:vg,transform:"grow-4",className:"mr-2"}),"Default Format & Time zone"]}),onToggle:this.handleSectionToggle,children:l.jsx(RR,{})}),l.jsx(To,{sectionKey:Nn.COLUMN_SPECIFIC_SECTION_KEY,isExpanded:this.isSectionExpanded(Nn.COLUMN_SPECIFIC_SECTION_KEY),title:l.jsxs(l.Fragment,{children:[l.jsx(J,{icon:Tg,transform:"grow-4",className:"mr-2"}),"Format by Column Name & Type"]}),onToggle:this.handleSectionToggle,children:l.jsx(VR,{scrollTo:this.handleScrollTo})}),l.jsx(To,{sectionKey:Nn.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(Nn.SHORTCUT_SECTION_KEY),title:l.jsxs(l.Fragment,{children:[l.jsx(J,{icon:Eg,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:l.jsx(OR,{})}),l.jsxs("div",{className:"app-settings-footer",children:[l.jsxs("div",{className:"app-settings-footer-section",children:[l.jsxs("div",{className:"app-settings-footer-item",children:[l.jsx("div",{className:"font-weight-bold",children:"Support"}),l.jsxs("div",{children:["GitHub: ",l.jsx("a",{href:t,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:t})]}),l.jsx(V,{kind:"tertiary",className:"mt-2 py-2",onClick:this.handleExportSupportLogs,children:"Export Logs"})]}),l.jsxs("div",{className:"app-settings-footer-item",children:[l.jsx("div",{className:"font-weight-bold",children:"Documentation"}),l.jsx("a",{target:"_blank",rel:"noreferrer noopener",href:n,className:"custom-link",children:n})]}),l.jsxs("div",{className:"app-settings-footer-item",children:[l.jsx("div",{className:"font-weight-bold",children:"Version"}),l.jsxs("span",{className:"d-inline-block text-muted",children:[a," ",l.jsx(J,{icon:yg}),l.jsxs(tt,{interactive:!0,children:[l.jsxs("div",{className:"detailed-server-config",children:[r("Engine Version",a),r("Web UI Version",e),r("Java Version",o),r("Barrage Version",i)]}),l.jsx(ar,{tooltip:"Copy version numbers",copy:`Engine Version: ${a}
|
|
40
40
|
Web UI Version: ${e}
|
|
41
41
|
Java Version: ${o}
|
|
42
42
|
Barrage Version: ${i}`,children:"Copy Versions"})]})]})]}),l.jsx("div",{className:"app-settings-footer-item",children:l.jsx(IR,{})})]}),l.jsx("div",{className:"app-settings-footer-section",children:l.jsx("div",{className:"logo",children:l.jsx("a",{target:"_blank",rel:"noreferrer noopener",href:"https://deephaven.io",className:"d-inline-block custom-link p-1",children:l.jsx("img",{src:ym,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}}const fh=10;function Di(d){const{forwardedProps:{menuItem:{action:e,title:t,disabled:n},iconElement:s,displayShortcut:i,isMouseSelected:o,isKeyboardSelected:a,closeMenu:r}}=d,c=b.useRef(),h=b.useRef(),u=b.useRef(null),[m,p]=b.useState(!1),g=b.useCallback(S=>{c.current!=null&&h.current!=null&&u.current&&(Math.abs(c.current-S.clientX)>=fh||Math.abs(h.current-S.clientY)>=fh)&&(p(!0),window.removeEventListener("mousemove",g),r(),e(S),u.current=null)},[e,r]);function C(S){c.current=S.clientX,h.current=S.clientY,u.current=S.target,window.addEventListener("mousemove",g)}function f(S){u.current===S.target&&(p(!0),r(),e(),window.removeEventListener("mousemove",g)),u.current=null}return b.useEffect(function(){return function(){return window.removeEventListener("mousemove",g)}},[g]),l.jsxs("button",{type:"button",className:$("btn-context-menu",{disabled:n},{active:o&&!n},{"keyboard-active":a&&!n}),onMouseDown:C,onMouseUp:f,disabled:m,children:[l.jsx("span",{className:$("icon"),children:s}),l.jsx("span",{className:"title",children:t}),l.jsx("span",{className:"shortcut",children:i})]})}function Rd(d){const{handleControlSelect:e,handleToolSelect:t,onClearFilter:n}=d,s=b.useMemo(()=>[{title:"Input Filter",icon:xg,menuElement:l.jsx(Di,{}),action:i=>{e(Is.INPUT_FILTER,i)},order:10},{title:"Dropdown Filter",icon:Oh,menuElement:l.jsx(Di,{}),action:i=>{e(Is.DROPDOWN_FILTER,i)},order:15},{title:"Markdown Widget",icon:Rg,menuElement:l.jsx(Di,{}),action:i=>{e(Is.MARKDOWN,i)},order:20},{title:"Filter Sets",icon:il,menuElement:l.jsx(Di,{}),action:i=>{e(Is.FILTER_SET_MANAGER,i)},order:25},{disabled:!0,menuElement:l.jsx("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:yl,action:()=>{t(jt.LINKER)},order:40,shortcut:es.LINKER},{disabled:!0,menuElement:l.jsx("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:Ig,action:()=>{n()},order:60,shortcut:Kt.TABLE.CLEAR_ALL_FILTERS}],[e,t,n]);return l.jsx(Zn,{popperClassName:"controls-menu-popper",actions:s})}Rd.propTypes={handleControlSelect:D.func,handleToolSelect:D.func,onClearFilter:D.func};Rd.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};Di.propTypes={forwardedProps:D.shape({iconElement:D.node,displayShortcut:D.string,isMouseSelected:D.bool.isRequired,isKeyboardSelected:D.bool.isRequired,closeMenu:D.func.isRequired,menuItem:D.shape({action:D.func,title:D.string,disabled:D.bool}).isRequired})};Di.defaultProps={forwardedProps:null};const UR=Ls(Em,null),$R={layoutStorage:UR},WR=d=>d.layoutStorage,GR=d=>d.serverConfigValues;Object.entries($R).map(([d,e])=>Gi.register(d,e));const Ch=10;function zR(d){const{onExportLayout:e,onImportLayout:t,onResetLayout:n,onSelect:s,widgets:i=[]}=d,[o,a]=b.useState(!1),[r,c]=b.useState(""),h=b.useRef(null),u=b.useRef(),m=b.useCallback((T,y)=>{T!=null&&s(T,y)},[s]),p=b.useCallback(T=>{c(T.target.value)},[]),g=b.useCallback(T=>{u.current!=null&&(Math.abs(u.current.x-T.clientX)>=Ch||Math.abs(u.current.y-T.clientY)>=Ch)&&(a(!0),window.removeEventListener("mousemove",g),m(u.current.widget,T),u.current=void 0)},[u,m]),C=b.useCallback((T,y)=>{u.current={x:T.clientX,y:T.clientY,widget:y},window.addEventListener("mousemove",g)},[g]),f=b.useCallback((T,y)=>{window.removeEventListener("mousemove",g),u.current?.widget===y&&(a(!0),m(y)),u.current=void 0},[g,u,m]),S=b.useMemo(()=>i.filter(T=>r?T.name?.toLowerCase().includes(r.toLowerCase()):!0),[r,i]).sort((T,y)=>T.name?.localeCompare(y.name??"")??0),v=b.useMemo(()=>S.map(T=>l.jsx("li",{children:l.jsxs(V,{kind:"ghost","data-testid":`panel-list-item-${T.name??""}-button`,onMouseDown:y=>{C(y,T)},onMouseUp:y=>{f(y,T)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&m(T)},disabled:o,onClick:()=>{},children:[l.jsx(Kh,{type:T.type})," ",T.name??""]})},T.name)),[S,o,C,f,m]),w=b.useMemo(()=>v.length===0?l.jsx("span",{children:"No bound variables found."}):null,[v]);return l.jsxs("div",{className:"widget-list-container d-flex flex-column",children:[l.jsx("div",{className:"widget-list-header",children:l.jsx(As,{value:r,placeholder:"Find Table, Plot or Widget",onChange:p,ref:h})}),l.jsxs("ul",{className:"widget-list flex-grow-1",children:[w&&l.jsx("li",{className:"widget-list-message",children:w}),!w&&v]}),l.jsx("div",{children:l.jsx("hr",{})}),l.jsxs("div",{className:"widget-list-footer",children:[l.jsxs(V,{kind:"ghost",onClick:e,children:[l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(J,{mask:sl,icon:Vd,transform:"right-5 down-5"}),l.jsx(J,{icon:Vd,transform:"right-8 down-6"})]}),"Export Layout"]}),l.jsxs(V,{kind:"ghost",onClick:t,children:[l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(J,{mask:sl,icon:ol,transform:"right-5 down-5"}),l.jsx(J,{icon:ol,transform:"right-8 down-6"})]}),"Import Layout"]}),l.jsx(V,{kind:"ghost",icon:ei,onClick:n,tooltip:"Reset Layout"})]})]})}const KR=async(d,e,t)=>{let n,s,i,o;if(va(e)?(n=e.settings,s=e.table,i=void 0,o=e.tableSettings):(n={},s="",i=e.figure,o={}),t!==void 0&&(t.tableSettings!=null&&(o=t.tableSettings),t.table!=null&&(s=t.table),t.figure!=null&&(i=t.figure),t.settings!=null&&(n={...n,...t.settings})),i!==void 0){const c={title:i,name:i,type:x.VariableType.FIGURE},h=await d.getObject(c);return Aa.makeModel(n,h)}const a={title:i,name:s,type:x.VariableType.TABLE},r=await d.getObject(a);return be.applyTableSettings(r,o,Ao(mr.getState())),Aa.makeModelFromSettings(n,r)},qR=async(d,e,t=x.VariableType.TABLE)=>{const{table:n}=e,s={title:n,name:n,type:t},i=await d.getObject(s);return ud.makeModel(i)};function YR({onAutoFillClick:d=()=>{}}){return l.jsxs("div",{className:"empty-dashboard-container",children:[l.jsxs("div",{className:"hint-container",children:[l.jsx(J,{icon:kh})," ",l.jsx("br",{}),"Use the panel list to add objects from a query."]}),l.jsxs("div",{className:"empty-dashboard",children:[l.jsx("div",{className:"add-panels-hint",children:"Drag Panels Here"}),l.jsx(V,{kind:"tertiary",onClick:d,children:"Auto fill objects"})]})]})}function XR(d){return d.version===2}function ZR(d){return Array.isArray(d)}const Ca=Z.module("UserLayoutUtils"),QR={layoutConfig:[{type:"column",content:[{type:"row",height:40,content:[{type:"stack",content:[{type:"react-component",component:Ii.COMPONENT,title:Ii.TITLE,isClosable:!1},{type:"react-component",component:Ya.COMPONENT,title:Ya.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:$a.COMPONENT,title:$a.TITLE,isClosable:!1},{type:"react-component",component:Ga.COMPONENT,title:Ga.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},JR={layoutConfig:[],links:[],filterSets:[],version:2};function Mm(d){if(XR(d))return d;if(ZR(d))return{layoutConfig:d,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${d}`)}async function eI(d,e=!0){try{const t=await d.getLayouts();if(t.length>0)try{const n=await d.getLayout(t[0]);return Mm(n)}catch(n){Ca.error("Unable to load layout",t[0],":",n),Ca.warn("No valid layouts found, falling back to default layout")}}catch(t){Ca.error("Unable to fetch layout list",t),Ca.warn("Falling back to default layout")}return e?QR:JR}function tI(d){const{filterSets:e,layoutConfig:t,links:n}=d;return{filterSets:e,layoutConfig:t,links:n,version:2}}const Ea={exportLayout:tI,getDefaultLayout:eI,normalizeLayout:Mm},Sa=Z.module("DownloadServiceWorkerUtils");class Io{static DOWNLOAD_PATH="/download/";static registerOnLoaded(){new URL("/ide/",window.location.href).origin===window.location.origin&&("serviceWorker"in navigator?window.addEventListener("load",()=>{const t=new URL("/ide/download/serviceWorker.js",window.location.href);navigator.serviceWorker.register(t).then(n=>{n.update(),Sa.info("Registering service worker on ",t,n)}).catch(n=>{Sa.error("Failed to register service worker",n)})}):Sa.info("Service worker is not supported."))}static async getServiceWorker(){if("serviceWorker"in navigator){const t=(await navigator.serviceWorker.getRegistrations()).find(n=>n.scope.endsWith(Io.DOWNLOAD_PATH));if(t&&t.active)return Sa.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 km={react:X,"react-dom":Pi,redux:hp,"react-redux":up},nI=mp(km),sI=pp({requires:nI}),iI=gp.createRequires(km),oI=fp({requires:iI}),aI=Z.module("PluginUtils");class bl{static loadComponentPlugin(e){const t=new URL("/ide/plugins/",`${window.location}`),n=new URL(`${e}.js`,t),s=X.forwardRef((i,o)=>l.jsx(sI,{url:n,render:({err:a,Component:r})=>{if(a!=null&&a!==""){const c=`Error loading plugin ${e} from ${n} due to ${a}`;return aI.error(c),l.jsx("div",{className:"error-message",children:`${c}`})}return l.jsx(r,{ref:o,...i})}}));return s.pluginName=e,s.displayName="Plugin",s}static async loadModulePlugin(e){return await oI(e)}static async loadJson(e){return new Promise((t,n)=>{const s=new XMLHttpRequest;s.addEventListener("load",()=>{try{const i=JSON.parse(s.responseText);t(i)}catch(i){n(i)}}),s.addEventListener("error",i=>{n(i)}),s.open("GET",e),s.send()})}}const Dt=Z.module("AppMainContainer");class Eo extends b.Component{static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,t){return ml.hydrate({...e,unzip:n=>Eh.loadAsync(n).then(s=>Object.values(s.files))},t)}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.importElement=X.createRef(),this.state={contextActions:[{action:()=>{this.handleToolSelect(jt.LINKER)},shortcut:es.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:Kt.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{Dt.debug("Consume unhandled save shortcut")},shortcut:es.SAVE,isGlobal:!0}],isPanelsMenuShown:!1,isSettingsMenuShown:!1,widgets:[]}}componentDidMount(){this.initWidgets(),window.addEventListener("beforeunload",Eo.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:t}=this.props;e.dashboardData!==t&&this.handleDataChange(t)}componentWillUnmount(){this.deinitWidgets(),window.removeEventListener("beforeunload",Eo.handleWindowBeforeUnload)}goldenLayout;importElement;widgetListenerRemover;initWidgets(){const{connection:e}=this.props;if(e.subscribeToFieldUpdates==null){Dt.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(t=>{Dt.debug("Got updates",t),this.setState(({widgets:n})=>{const{updated:s,created:i,removed:o}=t,a=[...s,...o],r=n.filter(h=>!a.some(u=>u.name===h.name));return[...s,...i].forEach(h=>{h.name!=null&&h.name!==""&&r.push(h)}),{widgets:r}})})}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){Dt.error("No session available to open notebook URL",t);return}const i={id:`/${t}`,itemName:`/${t}`},o=s.type,a={value:null,language:o};this.emitLayoutEvent(Xe.SELECT_NOTEBOOK,n,o,a,i,!0)}}sendClearFilter(){this.emitLayoutEvent(Qe.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...t){this.goldenLayout?.eventHub.emit(e,...t)}handleError(e){ve.isCanceled(e)||Dt.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,t=null){switch(Dt.debug("handleControlSelect",e),e){case Is.DROPDOWN_FILTER:this.emitLayoutEvent(Qe.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:t});break;case Is.INPUT_FILTER:this.emitLayoutEvent(Qe.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:t});break;case Is.MARKDOWN:this.emitLayoutEvent(pm.OPEN,{title:"Markdown",type:e,dragEvent:t});break;case Is.FILTER_SET_MANAGER:this.emitLayoutEvent(Qe.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:t});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){Dt.debug("handleToolSelect",e);const{activeTool:t,setActiveTool:n}=this.props;n(t===e?jt.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}),Dt.debug("handleWidgetSelect",e,t),this.openWidget(e,t)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;Dt.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(){Dt.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:t}=e,n=Ea.exportLayout(t);Dt.info("handleExportLayoutClick exportedConfig",n);const s=new Blob([JSON.stringify(n)],{type:"application/json"}),i=x.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){Dt.error("Unable to export layout",e)}}handleImportLayoutClick(){Dt.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){Dt.info("handleResetLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.resetLayout()}handleImportLayoutFiles(e){e.stopPropagation(),e.preventDefault(),e.target.files!=null&&this.importLayoutFile(e.target.files?.[0])}async importLayoutFile(e){try{const{updateDashboardData:t,updateWorkspaceData:n}=this.props,s=await e.text(),i=JSON.parse(s),{filterSets:o,layoutConfig:a,links:r}=Ea.normalizeLayout(i);n({layoutConfig:a}),t(wn,{filterSets:o,links:r})}catch(t){Dt.error("Unable to import layout",t)}}async resetLayout(){const{layoutStorage:e,session:t}=this.props,{filterSets:n,layoutConfig:s,links:i}=await Ea.getDefaultLayout(e,t!==void 0),{updateDashboardData:o,updateWorkspaceData:a}=this.props;a({layoutConfig:s}),o(wn,{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);return n!=null&&n.TablePlugin!=null?n.TablePlugin:bl.loadComponentPlugin(e)}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 ml.hydrate(e,t)}hydrateGrid(e,t){return this.hydrateTable(e,t,e.metadata.type??x.VariableType.TABLE)}hydratePandas(e,t){return this.hydrateTable(e,t,x.VariableType.PANDAS)}hydrateTable(e,t,n=x.VariableType.TABLE){const{connection:s}=this.props;return{...e,getDownloadWorker:Io.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:t,makeModel:()=>qR(s,e.metadata,n)}}hydrateChart(e,t){const{connection:n}=this.props;return{...e,localDashboardId:t,makeModel:()=>{const{metadata:s,panelState:i}=e;return KR(n,s,i)}}}openWidget(e,t){const{connection:n}=this.props;this.emitLayoutEvent(Ee.OPEN,{dragEvent:t,fetch:()=>n.getObject(e),widget:e})}getDashboardPlugins=fe(e=>[...e.entries()].filter(([,t])=>t.DashboardPlugin!=null).map(([t,{DashboardPlugin:n}])=>l.jsx(n,{},t)));render(){const{activeTool:e,plugins:t,user:n,workspace:s,serverConfigValues:i}=this.props,{data:o}=s,{layoutConfig:a}=o,{permissions:r}=n,{canUsePanels:c}=r,{contextActions:h,isPanelsMenuShown:u,isSettingsMenuShown:m,widgets:p}=this.state,g=this.getDashboardPlugins(t);return l.jsxs("div",{className:$("app-main-tabs","w-100","h-100","d-flex","flex-column",e?`active-tool-${e.toLowerCase()}`:""),onPaste:this.handlePaste,tabIndex:-1,children:[l.jsx("nav",{className:"nav-container",children:l.jsxs("div",{className:"app-main-top-nav-menus",children:[l.jsx("img",{src:ym,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),l.jsxs("div",{children:[l.jsxs(V,{kind:"ghost",className:"btn-panels-menu",icon:Dg,onClick:()=>{},children:["Controls",l.jsx(Rd,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),c&&l.jsxs(V,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:Fg,children:["Panels",l.jsx(ri,{isShown:u,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:l.jsx(zR,{widgets:p,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),l.jsx(V,{kind:"ghost",className:$("btn-settings-menu",{"text-warning":n.operateAs!==n.name}),onClick:this.handleSettingsMenuShow,icon:l.jsx(J,{icon:ko,transform:"grow-3 right-1 down-1"}),tooltip:"User Settings"})]})]})}),l.jsxs(jw,{emptyDashboard:l.jsx(YR,{onAutoFillClick:this.handleAutoFillClick}),id:wn,layoutConfig:a,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[l.jsx(nR,{hydrate:this.hydrateGrid,getDownloadWorker:Io.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),l.jsx(Xx,{hydrate:this.hydrateChart}),l.jsx(Zx,{}),l.jsx(Jx,{hydrateConsole:Eo.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),l.jsx(eR,{}),l.jsx(hR,{hydrate:this.hydratePandas}),l.jsx(cR,{}),l.jsx(dR,{}),g]}),l.jsx(gt,{in:m,timeout:We.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx(Nn,{serverConfigValues:i,onDone:this.handleSettingsMenuHide})}),l.jsx(ae,{actions:h}),l.jsx("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles})]})}}const rI=d=>({activeTool:cr(d),dashboardData:Vt(d,wn),layoutStorage:WR(d),plugins:US(d),connection:Zy(d,wn),session:ai(d,wn)?.session,sessionConfig:ai(d,wn)?.config,user:iu(d),workspace:dr(d),serverConfigValues:GR(d)}),lI=ft(rI,{setActiveTool:ur,updateDashboardData:Pn,updateWorkspaceData:Eu})(Cp(Eo));function dI(){return l.jsxs("div",{className:"app",children:[l.jsx(lI,{}),l.jsx(_h,{})]})}const cI=Z.module("LocalWorkspaceStorage");class Fi{static STORAGE_KEY="deephaven.WorkspaceStorage";static async makeDefaultWorkspaceData(e,t){const{filterSets:n,links:s,layoutConfig:i}=await Ea.getDefaultLayout(e,t?.isConsoleAvailable);return{settings:{defaultDateTimeFormat:_e.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:_e.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:Re.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:$e.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1,defaultNotebookSettings:{isMinimapEnabled:!1}},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(e,t){return{data:await Fi.makeDefaultWorkspaceData(e,t)}}layoutStorage;constructor(e){this.layoutStorage=e}async load(e){try{return JSON.parse(localStorage.getItem(Fi.STORAGE_KEY)??"")}catch{return cI.info("Unable to load workspace data, initializing to default data"),Fi.makeDefaultWorkspace(this.layoutStorage,e)}}async save(e){return localStorage.setItem(Fi.STORAGE_KEY,JSON.stringify(e)),e}}class hI extends Error{isNoConsolesError=!0}function uI(d){return d.isNoConsolesError}const Fs=Z.module("SessionUtils");var Om=(d=>(d.ANONYMOUS="anonymous",d.PARENT="parent",d))(Om||{});function mI(){return new URL("/jsapi",`${window.location}`)}function Am(){const d=mI();return`${d.protocol}//${d.host}`}function pI(){switch(new URLSearchParams(window.location.search).get("authProvider")){case"parent":return"parent";default:return"anonymous"}}function gI(){const d=Am();return Fs.info(`Starting connection to '${d}'...`),new x.IdeConnection(d)}async function fI(d){Fs.info("Getting console types...");const e=await d.getConsoleTypes();if(Fs.info("Available types:",e),e.length===0)throw new hI("No console types available");const t=e[0];Fs.info("Starting session with type",t);const n=await d.startSession(t),s={type:t,id:Pe.generate()};return Fs.info("Console session established",s),{session:n,config:s,connection:d}}function CI(){const d=Am();return Fs.info("createCoreClient",d),new x.CoreClient(d)}async function SI(){if(window.opener==null)throw new Error("window.opener is null, unable to send auth request.");return new Promise(d=>{const e=t=>{const{data:n}=t;if(Fs.debug("Received message",n),n?.message!=="loginOptions"){Fs.debug("Ignore received message",n);return}window.removeEventListener("message",e),d(n.payload)};window.addEventListener("message",e),window.opener.postMessage("requestLoginOptionsFromParent","*")})}async function bI(d){switch(d){case"parent":return SI();case"anonymous":return{type:x.CoreClient.LOGIN_TYPE_ANONYMOUS};default:throw new Error(`Unknown auth type: ${d}`)}}class wI{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 mo=Z.module("GrpcFileStorageTable");class Xa{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=Ye(this.doRefresh.bind(this),Xa.REFRESH_DEBOUNCE))}removeBaseRoot(e){return he.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 Xa(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){mo.debug2("doRefresh",this.root),e(this.fetchData())}refresh(){mo.debug2("refresh",this.root),this.viewportUpdatePromise?.cancel();const e=new Promise(n=>{this.doRefresh(n)}),t=ve.makeCancelable(e.then(n=>{if(this.viewportUpdatePromise!==t)throw new Hi;return this.currentViewportData=n,this.sendUpdate(),n}));t.catch(n=>{ve.isCanceled(n)||mo.error("Error updating viewport",n)}),this.viewportUpdatePromise=t}refreshInternal(){try{this.refresh()}catch(e){ve.isCanceled(e)||mo.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:a}=i;if(a===this.removeBaseRoot(`${this.root}/${o}`)&&i.type==="directory"){const r=this.childTables.get(o);if(r!=null){r.setViewport({top:0,bottom:e.bottom-s});const c=await r.getViewportData();n.splice(s+1,0,...c.items)}}}return this.currentSize=n.length,mo.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 vI=Z.module("GrpcFileStorage");class Id{static REFRESH_THROTTLE=150;storageService;tables=[];root;constructor(e,t=""){this.storageService=e,this.root=t}removeRoot(e){return he.removeRoot(this.root,e)}addRoot(e){return he.addRoot(this.root,e)}async createDirectory(e){return await this.storageService.createDirectory(this.addRoot(e)),this.refreshTables(),{type:"directory",id:e,filename:e,basename:he.getBaseName(e)}}async getTable(){const e=new Xa(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:he.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(he.getPath(e)),he.getBaseName(e));if(t.length===0)throw new vd;if(t.length>1)throw vI.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=ks(()=>{this.tables.forEach(e=>e.refresh())},Id.REFRESH_THROTTLE)}const Ns=Z.module("AppInit");async function TI(){Ns.debug("Loading plugins...");try{const d=await bl.loadJson("/js-plugins/manifest.json");Ns.debug("Plugin manifest loaded:",d);const e=[];for(let s=0;s<d.plugins.length;s+=1){const{name:i,main:o}=d.plugins[s],a=`/js-plugins/${i}/${o}`;e.push(bl.loadModulePlugin(a))}const t=await Promise.all(e),n=new Map;for(let s=0;s<t.length;s+=1){const{name:i}=d.plugins[s];n.set(i,t[s])}return Ns.info("Plugins loaded:",n),n}catch(d){return Ns.error("Unable to load plugins:",d),new Map}}async function EI(d){let e;try{e=await fI(d)}catch(t){if(!uI(t))throw t}return e}function Dd(d){const{workspace:e,setActiveTool:t,setCommandHistoryStorage:n,setDashboardData:s,setFileStorage:i,setLayoutStorage:o,setDashboardConnection:a,setDashboardSessionWrapper:r,setPlugins:c,setUser:h,setWorkspace:u,setWorkspaceStorage:m,setServerConfigValues:p}=d,[g,C]=b.useState(),[f,S]=b.useState(!0),v=b.useCallback(async()=>{try{Ns.info("Initializing Web UI","0.32.0",navigator.userAgent);const I=CI(),F=pI();Ns.info(`Login using auth type ${F}...`),await I.login(await bI(F));const N=await TI(),H=await(F===Om.ANONYMOUS&&I.getAsIdeConnection==null?gI():I.getAsIdeConnection());H.addEventListener(x.IdeConnection.HACK_CONNECTION_FAILURE,we=>{const{detail:xe}=we;Ns.error("Connection failure",`${JSON.stringify(xe)}`),C(`Unable to connect: ${xe.details??"Unknown Error"}`)});const P=await EI(H),O="user",k=I.getStorageService(),L=new wI(k,"/layouts"),A=new Id(k,"/notebooks"),U=new Fi(L),j=new SR,W=await U.load({isConsoleAvailable:P!==void 0}),{data:ie}=W,{settings:se}=ie;se.defaultDecimalFormatOptions===void 0&&(se.defaultDecimalFormatOptions={defaultFormatString:Re.DEFAULT_FORMAT_STRING}),se.defaultIntegerFormatOptions===void 0&&(se.defaultIntegerFormatOptions={defaultFormatString:$e.DEFAULT_FORMAT_STRING}),se.truncateNumbersWithPound===void 0&&(se.truncateNumbersWithPound=!1);const{shortcutOverrides:G={}}=se,te=ke.isMacPlatform?G.mac??{}:G.windows??{};Object.entries(te).forEach(([we,xe])=>{Fe.get(we)?.setKeyState(xe)});const oe={filterSets:ie.filterSets,links:ie.links},de=await I.getServerConfigValues(),ee=new Map(de),re={name:O,operateAs:O,groups:[],permissions:{isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:ee.get("internal.webClient.appInit.canCopy")!=="false",canDownloadCsv:ee.get("internal.webClient.appInit.canDownloadCsv")!=="false"}};t(jt.DEFAULT),p(ee),n(j),s(wn,oe),i(A),o(L),a(wn,H),P!==void 0&&r(wn,P),c(N),h(re),m(U),u(W)}catch(I){Ns.error(I),C(I)}},[t,n,s,i,o,a,r,c,h,u,m,p]),w=b.useCallback(()=>{document.fonts!=null?document.fonts.ready.then(()=>{S(!1)}):S(!1)},[]);b.useEffect(function(){v(),w()},[v,w]);const T=e==null&&g==null||f,y=!T&&g==null,E=g!=null?`${g}`:null;return l.jsxs(l.Fragment,{children:[y&&l.jsx(dI,{}),l.jsx(Ja,{isLoading:T,isLoaded:y,errorMessage:E}),l.jsxs("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:[l.jsx("p",{className:"fira-sans-regular",children:"preload"}),l.jsx("p",{className:"fira-sans-semibold",children:"preload"}),l.jsx("p",{className:"fira-mono",children:"preload"})]})]})}Dd.propTypes={workspace:D.shape({}),workspaceStorage:D.shape({close:D.func}),setActiveTool:D.func.isRequired,setCommandHistoryStorage:D.func.isRequired,setDashboardData:D.func.isRequired,setFileStorage:D.func.isRequired,setLayoutStorage:D.func.isRequired,setDashboardConnection:D.func.isRequired,setDashboardSessionWrapper:D.func.isRequired,setPlugins:D.func.isRequired,setUser:D.func.isRequired,setWorkspace:D.func.isRequired,setWorkspaceStorage:D.func.isRequired};Dd.defaultProps={workspace:null,workspaceStorage:null};const yI=d=>({workspace:dr(d),workspaceStorage:HS(d)}),Sh=ft(yI,{setActiveTool:ur,setCommandHistoryStorage:GS,setDashboardData:zu,setFileStorage:zS,setLayoutStorage:bR,setDashboardConnection:Qy,setDashboardSessionWrapper:Jy,setPlugins:qS,setUser:$S,setWorkspace:Tu,setWorkspaceStorage:WS,setServerConfigValues:YS})(Dd);function xI(){return l.jsx(Sp,{basename:"/ide/",children:l.jsxs(bp,{children:[l.jsx(Ad,{exact:!0,path:"/",component:Sh}),l.jsx(Ad,{path:"/notebook/:notebookPath+",component:Sh}),l.jsx(wp,{from:"*",to:"/"})]})})}Boolean(window.location.hostname==="localhost"||window.location.hostname==="[::1]"||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function RI(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(d=>{d.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}function AI(){return RI(),Io.registerOnLoaded(),zt.init({getWorker:()=>new vp}),window["__react-beautiful-dnd-disable-dev-warnings"]=!0,l.jsx(wh,{store:mr,children:l.jsx(xI,{})})}export{AI as AppRoot,AI as default};
|
|
43
|
-
//# sourceMappingURL=AppRoot-
|
|
43
|
+
//# sourceMappingURL=AppRoot-caede86f.js.map
|