@deephaven/embed-grid 0.31.4 → 0.31.5

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.
@@ -1,6 +1,6 @@
1
- import{A as F,R as De,C as m,E as Z,T as Ca,F as y,J,D as $t,K as Oe,L as Ln,U as $e,H as Te,V as yi,B,W as Fe,S as wa,I as vt,X as it,Y as zo,O as sl,Q as Oi,Z as mr,_ as Sa,$ as Wt,a0 as Ta,a1 as ba,a2 as Ea,a3 as va,a4 as Fi,a5 as Ra,a6 as ya,a7 as Fa,a8 as gr,a9 as Da,aa as Ia,ab as pr,ac as Na,ad as Aa,ae as Ma,af as Oa,ag as xa,ah as Pn,ai as ka,aj as Di,ak as ol}from"./vendor.ec0ffec4.js";import{P as ze,C as _n,a as La,u as Pa,B as z,v as _a,b as Ha,c as Va,d as Ua,e as Xs,T as We,E as ye,f as il,L as le,g as Qn,h as dn,i as rl,j as rn,k as qo,l as xi,m as ki,n as xo,r as Be,M as ce,K as fe,o as Rt,p as oe,q as jt,G as Li,s as jn,t as Ba,w as Ga,x as Xn,y as ll,z as Wa,A as $a,D as za,F as qa,H as un,S as Ya,I as vs,J as fr,N as al,O as Dt,Q as Pi,R as Zn,U as an,V as _i,W as Hi,X as ko,Y as Vi,Z as Yo,_ as Xa,$ as Ka,a0 as Ks,a1 as Ui,a2 as Qs,a3 as Bi,a4 as Qa,a5 as Lo,a6 as ja,a7 as Gi,a8 as cl,a9 as Za,aa as Ja,ab as ec,ac as tc,ad as nc,ae as sc,af as oc,ag as dl,ah as Cr,ai as ui,aj as ic,ak as rc,al as Ss,am as lc,an as ul,ao as ac,ap as cc,aq as hl,ar as wr,as as dc,at as uc,au as hc,av as mc,aw as gc,ax as ml,ay as pc,az as fc,aA as Sr,aB as Cc,aC as Tr,aD as wc,aE as Sc,aF as Tc,aG as bc,aH as Ec,aI as vc,aJ as Rc,aK as yc,aL as Fc,aM as Dc,aN as Ic,aO as Nc,aP as Ac,aQ as Mc,aR as Oc,aS as xc,aT as kc,aU as Lc,aV as Pc,aW as _c,aX as Hc,aY as Vc,aZ as Uc,a_ as xe}from"./index.1253f311.js";import{e as cn,l as ps,K as Et,a as br,b as Mn}from"./monaco.e84eddf6.js";import{P as Po,b as Bc,h as Gc,p as Wc,o as $c,s as zc,t as qc,c as hi}from"./plotly.ac086d9a.js";import"./helpers.162e09a8.js";class Xo{static isDark(t){const n=document.createElement("div");n.style.display="none",n.style.color=t;const s=getComputedStyle(document.body.appendChild(n)).color,o=s.match(/\d+/g);let i=[];if(o)i=o.map(l=>parseInt(l,10));else throw new Error(`Invalid color received. Got ${s}`);return document.body.removeChild(n),Xo.getBrightness(i)<125}static getBrightness(t){return Math.round((t[0]*299+t[1]*587+t[2]*114)/1e3)}}function Yc(e,t){return e?e.closest(`.${t}`):null}const Xc={getClosestByClassName:Yc};class Ko{constructor(){this.pending=[],this.resolved=[]}add(t,n){const s=ze.makeCancelable(t,n);return this.pending.push(s),s.then(()=>{this.resolve(s)},()=>{this.resolve(s)}),s}remove(t){for(let n=0;n<this.pending.length;n+=1)if(this.pending[n]===t){this.pending.splice(n,1);return}}resolve(t){this.remove(t),this.resolved.push(t)}cancel(){const t=[...this.pending,...this.resolved];for(let n=0;n<t.length;n+=1)t[n].cancel();this.pending=[],this.resolved=[]}}function M(e){if(e==null)throw new Error("Value is null or undefined")}class Wi{static join(t,n="and"){if(t==null||t.length===0)return"";if(t.length===1)return t[0];if(t.length===2)return`${t[0]} ${n} ${t[1]}`;const s=t.slice(0,t.length-1).join(", "),o=t[t.length-1];return`${s}, ${n} ${o}`}static toLower(t,n=!0){if(t==null){if(n)return"";throw new Error("Null string passed in to TextUtils.toLower")}return t.toLowerCase()}static sort(t,n,s=!0){return t<n?s?-1:1:t>n?s?1:-1:0}}class Kc extends Error{constructor(){super(...arguments),this.isInvalid=!0}}class Qc extends F.exports.Component{constructor(t){super(t),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=De.createRef(),this.openMenu=De.createRef(),this.state={actions:null,left:0,top:0}}componentDidMount(){var t;(t=this.container.current)!=null&&t.parentElement&&this.container.current.parentElement.addEventListener("contextmenu",this.handleContextMenu)}componentWillUnmount(){var t;(t=this.container.current)!=null&&t.parentElement&&this.container.current.parentElement.removeEventListener("contextmenu",this.handleContextMenu)}handleContextMenu(t){if(!_n.isContextActionEvent(t)||!this.container.current||t.metaKey||t.ctrlKey)return;const n=_n.getMenuItems(t.contextActions),s=this.container.current.getBoundingClientRect(),o=t.clientY-s.top,i=t.clientX-s.left;if(n.length===0){if(t.target===this.container.current){t.preventDefault(),this.setState({actions:null},()=>{const r=document.elementFromPoint(i,o),l=new MouseEvent("contextmenu",{clientX:t.clientX,clientY:t.clientY,bubbles:!0,cancelable:!0});r==null||r.dispatchEvent(l)});return}return}t.preventDefault(),this.setState({actions:n,top:o,left:i})}handleMenuClose(t){t===this.openMenu.current&&this.setState({actions:null})}render(){let t=null;const{"data-testid":n}=this.props,{actions:s,top:o,left:i}=this.state;return s&&(t=m(La,{ref:this.openMenu,actions:s,onMenuClosed:this.handleMenuClose,top:o,left:i,updatePosition:(r,l)=>{this.setState({top:r,left:l})},"data-testid":n})),m("div",{className:Z("context-menu-root",{active:s}),ref:this.container,children:t})}}function $i(e){const t=F.exports.useRef();return F.exports.useEffect(function(){t.current=e}),t.current}function gl({copy:e,kind:t="ghost",tooltip:n="Copy",className:s,"data-testid":o,children:i}){const[r,l]=Pa();return m(z,{kind:t,className:s,"data-testid":o,icon:r?_a:Ha,tooltip:r?"Copied":n,onClick:()=>{l(typeof e=="function"?e():e)},children:i})}class dt{static reorder(t,n,s,o){const i=t===s?dt.adjustDestinationIndex(o,n):o,r=dt.removeItems(t,n);return s.splice(i,0,...r),r}static removeItems(t,n){const s=[],o=n.map((i,r)=>({range:i,index:r})).sort((i,r)=>r.range[0]-i.range[0]);for(let i=0;i<o.length;i+=1){const{range:r,index:l}=o[i],[a,c]=r;s[l]=t.splice(a,c-a+1)}return Ca(s)}static adjustDestinationIndex(t,n){let s=t;for(let o=0;o<n.length;o+=1){const[i,r]=n[o];if(i>t)break;s-=Math.min(r,t-1)-i+1}return s}static startDragging(){document.documentElement.classList.add("drag-pointer-events-none")}static stopDragging(){document.documentElement.classList.remove("drag-pointer-events-none")}}function pl({on:e,id:t,className:n,isInvalid:s,disabled:o=!1,onClick:i,"data-testid":r}){return m("button",{type:"button",className:Z("btn","btn-switch",n,{active:e},{"is-invalid":s}),id:t,onClick:i,disabled:o,"data-testid":r,children:m("div",{className:"handle"})})}function Er(e){return e.isOn!==void 0}function jc({item:e,onSelect:t=()=>{},"data-testid":n}){const{icon:s,subtitle:o,title:i}=e,r=F.exports.useMemo(()=>Er(e)?()=>{e.onChange(!e.isOn)}:t,[e,t]);return y("div",{className:"btn btn-navigation-menu-item","data-testid":`menu-item-${i}`,onClick:r,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&r()},tabIndex:0,role:"menuitem",children:[s!==void 0&&m("div",{className:"icon",children:m(J,{icon:s})}),m("div",{className:"title",children:i}),o!==void 0&&m("div",{className:"shortcut",children:o}),m("div",{className:"accessory","data-testid":n,children:Er(e)?m(pl,{on:e.isOn,onClick:l=>{l.stopPropagation(),r()}}):m(J,{icon:Va})})]})}function fl({items:e,onSelect:t=()=>{},"data-testid":n}){return m("div",{className:"navigation-menu-view","data-testid":n,children:m("ul",{className:"navigation-menu-list",children:e.map((s,o)=>m("li",{children:m(jc,{item:s,onSelect:()=>{t(o)}})},s.title))})})}function vr({children:e,onBack:t,onClose:n,title:s,"data-testid":o}){return y("div",{className:"navigation-page","data-testid":o,children:[y("div",{className:"navigation-title-bar",children:[m("div",{className:"navigation-left-buttons",children:t!==void 0&&m(z,{kind:"ghost",className:"btn-back","data-testid":"btn-page-back",onClick:t,icon:Ua,children:"Back"})}),m("div",{className:"navigation-title",children:s}),m("div",{className:"navigation-right-buttons",children:n!==void 0&&m(z,{kind:"ghost",className:"btn-close px-2 m-1","data-testid":"btn-page-close",onClick:n,icon:Xs,tooltip:"Close"})})]}),m("div",{className:"navigation-content",children:e})]})}function Zc({children:e,"data-testid":t}){const n=F.exports.useMemo(()=>De.Children.toArray(e),[e]),s=$i(n),[o,i]=F.exports.useState(n[n.length-1]),[r,l]=F.exports.useState(null),[a,c]=F.exports.useState(null);F.exports.useEffect(function(){if(s===void 0||n===s)return;const g=n[n.length-1];n.length===s.length||s.length===0||r!==null||a!==null?r!==null&&g!==r?l(g):g!==a&&g!==o&&i(g):n.length>s.length?l(g):n.length<s.length&&(i(g),c(s[s.length-1]))},[n,s,r,a,o]);const d=F.exports.useCallback(()=>{i(r),l(null)},[r]),u=F.exports.useCallback(()=>{c(null)},[]);return y("div",{className:"navigation-stack",children:[m("div",{className:"main-view","data-testid":t,children:o}),m($t,{in:a!=null,timeout:We.transitionMidMs,classNames:"slide-right",onEntered:u,children:m(Oe,{children:a!=null&&m("div",{className:"popping-view",children:a})})}),m($t,{in:r!=null,timeout:We.transitionMidMs,classNames:"slide-left",onEntered:d,children:m(Oe,{children:r!=null&&m("div",{className:"pushing-view",children:r})})})]})}function Jc({children:e,disabled:t,value:n,"data-testid":s}){return m("option",{value:n,disabled:t,"data-testid":s,children:e})}function zi(e){const{children:t,disabled:n=!1,name:s,onChange:o,value:i="","data-testid":r}=e,[l]=F.exports.useState(s!=null?s:Ln());return m(Oe,{children:De.Children.map(t,a=>{var c,d;return a?De.cloneElement(a,{name:l,onChange:(c=a.props.onChange)!=null?c:o,checked:i===a.props.value,disabled:(d=a.props.disabled)!=null?d:n,"data-testid":r}):null})})}function ed({children:e,onBlur:t,onChange:n,className:s,defaultValue:o,name:i,value:r,disabled:l,"data-testid":a}){const c=F.exports.useCallback(d=>{n(d.target.value)},[n]);return m("select",{className:Z("custom-select",s),onBlur:t,onChange:c,defaultValue:o,value:r,name:i,disabled:l,"data-testid":a,children:e})}class Cl extends Error{constructor(){super(...arguments),this.isAssertionFailed=!0}}function Rr(e){if(e==null)throw new Cl(`Expected 'val' to be defined, but received ${e}`)}class mi extends Error{constructor(){super(...arguments),this.isPasteError=!0}}function Pe(e){return(e==null?void 0:e.isEditable)!==void 0}function yr(e){if(!Pe(e))throw new Cl(`Expected 'model' to be editable, but received ${e}`)}function Me(e){return(e==null?void 0:e.hasExpandableRows)!==void 0}var At=(e=>(e.DOWN="DOWN",e.UP="UP",e.LEFT="LEFT",e.RIGHT="RIGHT",e))(At||{});const de=class{static normalize(e,t,n,s){let o=e,i=t,r=n,l=s;return o!=null&&r!=null&&r<o&&(o=r,r=e),i!=null&&l!=null&&l<i&&(i=l,l=t),[o,i,r,l]}static makeNormalized(e,t,n,s){return new de(...de.normalize(e,t,n,s))}static makeCell(e,t){return new de(e,t,e,t)}static makeColumn(e){return new de(e,null,e,null)}static makeRow(e){return new de(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 o=t[s];for(let i=t.length-1;i>s;i-=1){const r=t[i];if(o.contains(r))t.splice(i,1);else if(r.contains(o)){n=!0,t[s]=r,t.splice(i,1);break}else if(o.startRow===r.startRow&&o.endRow===r.endRow){if(o.touches(r)){const{startRow:l,endRow:a}=o,c=de.minOrNull(o.startColumn,r.startColumn),d=de.maxOrNull(o.endColumn,r.endColumn);n=!0,t[s]=new de(c,l,d,a),t.splice(i,1);break}}else if(o.startColumn===r.startColumn&&o.endColumn===r.endColumn&&o.touches(r)){const{startColumn:l,endColumn:a}=o,c=de.minOrNull(o.startRow,r.startRow),d=de.maxOrNull(o.endRow,r.endRow);n=!0,t[s]=new de(l,c,a,d),t.splice(i,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:o,endRow:i}=e;return n=n!=null&&t.startColumn!=null?Math.max(n,t.startColumn):n!=null?n:t.startColumn,o=o!=null&&t.endColumn!=null?Math.min(o,t.endColumn):o!=null?o:t.endColumn,s=s!=null&&t.startRow!=null?Math.max(s,t.startRow):s!=null?s:t.startRow,i=i!=null&&t.endRow!=null?Math.min(i,t.endRow):i!=null?i:t.endRow,n!=null&&n>(o!=null?o:-1)||s!=null&&s>(i!=null?i:-1)?null:new de(n,s,o,i)}static subtractFromRange(e,t){const n=[],s=de.intersection(e,t);return s==null?[e]:(s.startRow!=null&&(e.startRow==null||e.startRow<s.startRow)&&n.push(new de(e.startColumn,e.startRow,e.endColumn,s.startRow-1)),s.startColumn!=null&&(e.startColumn==null||e.startColumn<s.startColumn)&&n.push(new de(e.startColumn,s.startRow,s.startColumn-1,s.endRow)),s.endColumn!=null&&(e.endColumn==null||e.endColumn>s.endColumn)&&n.push(new de(s.endColumn+1,s.startRow,e.endColumn,s.endRow)),s.endRow!=null&&(e.endRow==null||e.endRow>s.endRow)&&n.push(new de(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(...de.subtractFromRange(e[s],t));return n}static subtractRangesFromRanges(e,t){let n=[...e];for(let s=0;s<t.length;s+=1)n=de.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){var s,o,i,r;return de.isBounded(e)?e:new de((s=e.startColumn)!=null?s:0,(o=e.startRow)!=null?o:0,(i=e.endColumn)!=null?i:t-1,(r=e.endRow)!=null?r:n-1)}static boundedRanges(e,t,n){return e.map(s=>de.boundedRange(s,t,n))}static offset(e,t,n){return new de(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=de.SELECTION_DIRECTION.DOWN){if(e.length===0)return null;let o=-1;if(t!=null&&n!=null&&(o=e.findIndex(i=>i.containsCell(t,n)),o>=0)){const r=e[o].nextCell(t,n,s);if(r!=null)return r}switch(s){case de.SELECTION_DIRECTION.DOWN:case de.SELECTION_DIRECTION.RIGHT:{const i=o<e.length-1?o+1:0;return e[i].startCell(s)}case de.SELECTION_DIRECTION.LEFT:case de.SELECTION_DIRECTION.UP:{const i=o>0?o-1:e.length-1;return e[i].startCell(s)}default:throw new Error(`Invalid direction: ${s}`)}}static cellCount(e){return e.reduce((t,n)=>{var s,o,i,r;return t+(((s=n.endRow)!=null?s:NaN)-((o=n.startRow)!=null?o:NaN)+1)*(((i=n.endColumn)!=null?i:NaN)-((r=n.startColumn)!=null?r:NaN)+1)},0)}static rowCount(e){return e.reduce((t,n)=>{var s,o;return t+((s=n.endRow)!=null?s:NaN)-((o=n.startRow)!=null?o:NaN)+1},0)}static columnCount(e){return e.reduce((t,n)=>{var s,o;return t+((s=n.endColumn)!=null?s:NaN)-((o=n.startColumn)!=null?o: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=de.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 de.isAxisRangeTouching(this.startRow,this.endRow,e.startRow,e.endRow)&&de.isAxisRangeTouching(this.startColumn,this.endColumn,e.startColumn,e.endColumn)}subtract(e){return de.subtractFromRange(this,e)}startCell(e=de.SELECTION_DIRECTION.DOWN){if(!de.isBounded(this))throw new Error("Cannot get the startCell of an unbounded range");switch(e){case de.SELECTION_DIRECTION.DOWN:case de.SELECTION_DIRECTION.RIGHT:return{column:this.startColumn,row:this.startRow};case de.SELECTION_DIRECTION.LEFT:case de.SELECTION_DIRECTION.UP:return{column:this.endColumn,row:this.endRow};default:throw new Error(`Invalid direction: ${e}`)}}nextCell(e,t,n){if(!de.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:o,startRow:i,endRow:r}=this;switch(n){case de.SELECTION_DIRECTION.DOWN:if(t<r)return{column:e,row:Math.max(t+1,i)};if(e<o)return{column:Math.max(e+1,s),row:i};break;case de.SELECTION_DIRECTION.UP:if(t>i)return{column:e,row:Math.min(t-1,r)};if(e>s)return{column:Math.min(e-1,o),row:r};break;case de.SELECTION_DIRECTION.RIGHT:if(e<o)return{column:Math.max(e+1,s),row:t};if(t<r)return{column:s,row:Math.max(t+1,i)};break;case de.SELECTION_DIRECTION.LEFT:if(e>s)return{column:Math.min(e-1,o),row:t};if(t>i)return{column:o,row:Math.min(t-1,r)};break;default:throw new Error(`Invalid direction: ${n}`)}return null}forEach(e,t=de.SELECTION_DIRECTION.RIGHT){var i;let n=0,{column:s,row:o}=this.startCell(t);for(;s!=null&&o!=null;)e(s,o,n),n+=1,{column:s,row:o}=(i=this.nextCell(s,o,t))!=null?i:{}}};let K=de;K.SELECTION_DIRECTION=At;function td(e){return Array.isArray(e)&&e.length===2&&(e[0]===null||typeof e[0]=="number")&&(e[1]===null||typeof e[1]=="number")}function vo(e){return td(e)&&e[0]!=null&&e[1]!=null}const pe=class{static getGridPointFromXY(e,t,n){const s=pe.getColumnAtX(e,n),o=pe.getRowAtY(t,n),i=pe.getColumnHeaderDepthAtY(t,n);return{x:e,y:t,row:o,column:s,columnHeaderDepth:i}}static getCellInfoFromXY(e,t,n){const{row:s,column:o}=pe.getGridPointFromXY(e,t,n),{allColumnWidths:i,allRowHeights:r,allColumnXs:l,allRowYs:a,modelColumns:c,modelRows:d}=n,u=s!==null?d.get(s):null,h=o!==null?c.get(o):null,g=o!==null?l.get(o):null,p=s!==null?a.get(s):null,f=o!==null?i.get(o):null,C=s!==null?r.get(s):null;return{row:s,column:o,modelRow:u!=null?u:null,modelColumn:h!=null?h:null,left:g!=null?g:null,top:p!=null?p:null,columnWidth:f!=null?f:null,rowHeight:C!=null?C:null}}static getColumnHeaderDepthAtY(e,t){const n=pe.getRowAtY(e,t),{columnHeaderHeight:s,columnHeaderMaxDepth:o}=t;if(n===null&&e<=s*o)return $e(o-Math.ceil(e/s),0,o-1)}static iterateFloatingStart(e,t,n){for(let s=0;s<e&&s<t;s+=1){const o=n(s);if(o!==void 0)return o}}static iterateFloatingEnd(e,t,n){for(let s=0;s<e&&t-(e-s)>=0;s+=1){const o=n(t-(e-s));if(o!==void 0)return o}}static iterateFloating(e,t,n,s){const o=pe.iterateFloatingStart(e,n,s);return o!==void 0?o:pe.iterateFloatingEnd(t,n,s)}static iterateAllItems(e,t,n,s,o,i){const r=Math.max(e,n),l=Math.min(t,o-s-1);let a=pe.iterateFloating(n,s,o,i);if(a!==void 0)return a;for(let c=r;c<=l;c+=1)if(a=i(c),a!==void 0)return a}static isInItem(e,t,n,s){var r,l;const o=(r=t.get(e))!=null?r:0,i=(l=n.get(e))!=null?l:0;return o<=s&&s<=o+i}static getItemAtOffset(e,t,n,s,o,i,r,l=!1){const a=l?void 0:pe.iterateFloating(n,s,t,c=>{if(pe.isInItem(c,i,r,e))return c});if(!l&&a!==void 0)return a;for(let c=0;c<o.length;c+=1){const d=o[c];if(pe.isInItem(d,i,r,e))return d}return null}static getColumnAtX(e,t,n=!1){const{columnCount:s,floatingLeftColumnCount:o,floatingRightColumnCount:i,visibleColumns:r,allColumnXs:l,allColumnWidths:a,gridX:c}=t;return e<c?null:this.getItemAtOffset(e-c,s,o,i,r,l,a,n)}static getRowAtY(e,t){const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:o,visibleRows:i,allRowYs:r,allRowHeights:l,gridY:a}=t;return e<a?null:this.getItemAtOffset(e-a,o,n,s,i,r,l)}static getNextShownItem(e,t,n,s){let o=n.findIndex(i=>i===e)||0;for(o-=1;o!=null&&o>=0;){const i=n[o],r=t.get(i);if(r!=null&&s.get(r)!==0)return i;o-=1}return null}static getNextShownColumn(e,t){const{modelColumns:n,visibleColumns:s,userColumnWidths:o}=t;return pe.getNextShownItem(e,n,s,o)}static getNextShownRow(e,t){const{modelRows:n,visibleRows:s,userRowHeights:o}=t;return pe.getNextShownItem(e,n,s,o)}static getColumnSeparatorIndex(e,t,n,s){var w,S,b,v;const{rowHeaderWidth:o,columnHeaderHeight:i,floatingColumns:r,floatingLeftWidth:l,visibleColumns:a,allColumnXs:c,allColumnWidths:d,columnHeaderMaxDepth:u}=n,{allowColumnResize:h,headerSeparatorHandleSize:g}=s;if(u*i<t||!h||g<=0)return null;const p=e-o,f=g*.5;let C=!1;for(let T=r.length-1;T>=0;T-=1){const R=r[T],D=(w=c.get(R))!=null?w:0,A=(S=d.get(R))!=null?S:0,I=A===0;if(!C||!I){let L=D+A;I?L+=f:C&&(L-=f);const k=L-f,x=L+f;if(k<=p&&p<=x)return R;C=I}}C=!1;for(let T=a.length-1;T>=0;T-=1){const R=a[T],D=(b=c.get(R))!=null?b:0,A=(v=d.get(R))!=null?v:0,I=A===0;if(D<l-A)return null;if(!C||!I){let L=D+A;I?L+=f:C&&(L-=f);const k=L-f,x=L+f;if(k<=p&&p<=x)return R;C=I}}return null}static isItemHidden(e,t){return t.get(e)===0}static isColumnHidden(e,t){const{allColumnWidths:n}=t;return pe.isItemHidden(e,n)}static isFloatingRow(e,t){if(e==null)return!1;const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:o}=t;return e<n||e>=o-s}static isFloatingColumn(e,t){if(e==null)return!1;const{floatingLeftColumnCount:n,floatingRightColumnCount:s,columnCount:o}=t;return e<n||e>=o-s}static getHiddenItems(e,t,n){if(!pe.isItemHidden(e,t))return[];const s=[e],o=n.findIndex(i=>i===e);for(let i=o-1;i>=0;i-=1){const r=n[i];if(!pe.isItemHidden(r,t))break;s.push(r)}return s}static getHiddenColumns(e,t){const{visibleColumns:n,allColumnWidths:s}=t;return pe.getHiddenItems(e,s,n)}static getRowSeparatorIndex(e,t,n,s){var p,f;const{rowHeaderWidth:o,columnHeaderHeight:i,visibleRows:r,allRowYs:l,allRowHeights:a}=n,{allowRowResize:c,headerSeparatorHandleSize:d}=s;if(o<e||!c||d<=0)return null;const u=t-i,h=d*.5;let g=!1;for(let C=r.length-1;C>=0;C-=1){const w=r[C],S=(p=l.get(w))!=null?p:0,b=(f=a.get(w))!=null?f:0,v=b===0;if(!g||!v){let T=S+b;v?T+=h:g&&(T-=h);const R=T-h,D=T+h;if(R<=u&&u<=D)return w;g=v}}return null}static isRowHidden(e,t){const{allRowHeights:n}=t;return pe.isItemHidden(e,n)}static getHiddenRows(e,t){const{visibleRows:n,allRowHeights:s}=t;return pe.getHiddenItems(e,s,n)}static moveItem(e,t,n){if(e===t)return[...n];const s=[...n],o=s[s.length-1];return o!=null&&!vo(o.from)&&o.to===e?o.from===t?s.pop():s[s.length-1]={...o,to:t}:s.push({from:e,to:t}),s}static moveRange(e,t,n,s=!1){if(e[0]===e[1])return pe.moveItem(e[0],t,n);let o=t;if(s&&e[0]<t&&(o-=e[1]-e[0]),e[0]===o)return[...n];const i=[...n],r=i[i.length-1];r!=null&&vo(r.from)&&r.from[1]-r.from[0]===e[1]-e[0]&&r.to===e[0]?i[i.length-1]={...r,to:o}:i.push({from:e,to:o});const l=i[i.length-1];return vo(l.from)&&l.from[0]===l.to&&i.pop(),i}static moveItemOrRange(e,t,n,s=!1){return Array.isArray(e)?pe.moveRange(e,t,n,s):pe.moveItem(e,t,n)}static applyItemMoves(e,t,n,s=!1){var i,r;let o=[[e,t]];for(let l=s?n.length-1:0;s?l>=0:l<n.length;s?l-=1:l+=1){const{from:a,to:c}=n[l];let d=1,u;vo(a)?(d=a[1]-a[0]+1,[u]=a):u=a;const h=s?c:u,g=h+d-1,p=s?u:c,f=p-h,C=[];for(let w=0;w<o.length;w+=1){const S=(i=o[w][0])!=null?i:Number.NEGATIVE_INFINITY,b=(r=o[w][1])!=null?r:Number.POSITIVE_INFINITY;let v;const T=[[S,h-1],[h,g],[g+1,b]].map(([R,D])=>[Math.max(R,S),Math.min(D,b)]).filter(([R,D])=>R<=D).map(R=>{const[D,A]=R;return h<=D&&g>=A?(v=[D+f,A+f],v):g<D?[D-d,A-d]:R}).map(R=>{const[D,A]=R;return p>D&&p<=A?[[D,p-1],[p+d,A+d]]:R===v?[R]:p<=D?[[D+d,A+d]]:[R]}).flat();C.push(...T)}o=C.map(([w,S])=>[Number.isFinite(w)?w:null,Number.isFinite(S)?S:null])}return o}static translateRange(e,t,n,s){const o=pe.applyItemMoves(e.startColumn,e.endColumn,t,s),i=pe.applyItemMoves(e.startRow,e.endRow,n,s),r=[];for(let l=0;l<o.length;l+=1){const a=o[l];for(let c=0;c<i.length;c+=1){const d=i[c];r.push(new K(a[0],d[0],a[1],d[1]))}}return r}static getModelIndex(e,t){return pe.applyItemMoves(e,e,t,!0)[0][0]}static getModelIndexes(e,t){return e.map(n=>pe.getModelIndex(n,t))}static getModelRangeIndexes(e,t,n){return pe.applyItemMoves(e,t,n,!0)}static getModelRange(e,t=ye,n=ye){return pe.translateRange(e,t,n,!0)}static getModelRanges(e,t=ye,n=ye){const s=[];for(let o=0;o<e.length;o+=1)s.push(...pe.getModelRange(e[o],t,n));return s}static getVisibleRangeIndexes(e,t,n){return pe.applyItemMoves(e,t,n,!1)}static getVisibleRange(e,t=ye,n=ye){return this.translateRange(e,t,n,!1)}static getVisibleRanges(e,t=ye,n=ye){const s=[];for(let o=0;o<e.length;o+=1)s.push(...pe.getVisibleRange(e[o],t,n));return s}static getVisibleIndex(e,t){return pe.applyItemMoves(e,e,t)[0][0]}static getVisibleIndexes(e,t){return e.map(n=>pe.getVisibleIndex(n,t))}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return pe.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){const t=pe.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:o,width:i,height:r,floatingTopRowCount:l,floatingBottomRowCount:a,floatingLeftColumnCount:c,floatingRightColumnCount:d,floatingLeftWidth:u,floatingRightWidth:h,floatingTopHeight:g,floatingBottomHeight:p,columnCount:f,rowCount:C}=e;let w=s,S=o,b=i,v=r;return n!=null&&(n>c&&(w+=u),n<f-d&&(b-=h)),t!=null&&(t>l&&(S+=g),t<C-a&&(v-=p)),{x1:w,y1:S,x2:b,y2:v}}static getScrollDelta(e,t=1024,n=768,s=20,o=20){let{deltaX:i,deltaY:r}=e;return!pe.isMacPlatform()&&e.shiftKey&&e.deltaX===0&&e.deltaY!==0&&(i=e.deltaY,r=e.deltaX),(e==null?void 0:e.deltaMode)===WheelEvent.DOM_DELTA_PAGE?(i*=t,r*=n):(e==null?void 0:e.deltaMode)===WheelEvent.DOM_DELTA_LINE&&(pe.isMacPlatform()?(i=Math.round(i*s),r=Math.round(r*o)):(i=Math.round(i*this.PIXELS_PER_LINE),r=Math.round(r*this.PIXELS_PER_LINE))),{deltaX:i,deltaY:r}}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],o=s[0],i=s[1];n===0?t.push([o,i]):o-1<=t[t.length-1][1]?t[t.length-1][1]=Math.max(t[t.length-1][1],i):t.push([o,i])}return t}};let _=pe;_.PIXELS_PER_LINE=100/3;function O(e,t,n=void 0){var o;const s=(o=e.get(t))!=null?o:n;if(s!==void 0)return s;throw new Error(`Missing value for key ${t}`)}function Ro(e,t=js.CACHE_SIZE,n=Math.floor(t/2)){if(e.size>t){const s=e.keys();for(;e.size>n;)e.delete(s.next().value)}}function Fr(e,t,n,s,o){const i=new Map;let r=0;for(let l=0;l<e&&l<n;l+=1)i.set(l,r),r+=O(o,l);r=s;for(let l=0;l<t&&n-l-1>=0;l+=1)r-=O(o,n-l-1),i.set(n-l-1,r);return i}const wl=class{constructor({userColumnWidths:e=new Map,userRowHeights:t=new Map,calculatedColumnWidths:n=new Map,calculatedRowHeights:s=new Map,fontWidths:o=new Map,modelRows:i=new Map,modelColumns:r=new Map,movedRows:l=[],movedColumns:a=[],initialRowHeights:c=new Map,initialColumnWidths:d=new Map}={}){this.userColumnWidths=e,this.userRowHeights=t,this.calculatedRowHeights=s,this.calculatedColumnWidths=n,this.fontWidths=o,this.modelRows=i,this.modelColumns=r,this.movedRows=l,this.movedColumns=a,this.initialRowHeights=c,this.initialColumnWidths=d}getMetrics(e){const{left:t,top:n,leftOffset:s,topOffset:o,width:i,height:r,theme:l,model:a,movedRows:c,movedColumns:d,draggingColumn:u}=e,{rowHeight:h,rowHeaderWidth:g,rowFooterWidth:p,columnWidth:f,columnHeaderHeight:C,minScrollHandleSize:w,scrollBarSize:S}=l;c!==this.movedRows&&(this.movedRows=c,this.modelRows.clear()),d!==this.movedColumns&&(this.movedColumns=d,this.modelColumns.clear());const{columnCount:b,rowCount:v,floatingTopRowCount:T,floatingBottomRowCount:R,floatingLeftColumnCount:D,floatingRightColumnCount:A,columnHeaderMaxDepth:I}=a,L=this.getFirstRow(e),k=this.getFirstColumn(e),x=this.getGridX(e),W=this.getGridY(e),V=Me(a)&&a.hasExpandableRows?this.calculateTreePaddingX(e):0,Y=0,j=this.getVisibleRowHeights(e),ie=this.getVisibleColumnWidths(e,k,V),G=Array.from(j.keys()),ee=Array.from(ie.keys()),H=new Map([...j,...this.getFloatingRowHeights(e)]),$=new Map([...ie,...this.getFloatingColumnWidths(e)]),se=this.getVisibleColumnXs($,ee,s),ne=this.getVisibleRowYs(H,G,o),he=G.length>0?G[G.length-1]:n,ve=ee.length>0?ee[ee.length-1]:t,Ie=this.getBottomViewport(e,G,ne,H),Ge=this.getRightViewport(e,ee,se,$),me=this.getFloatingTopHeight(e,H),ke=this.getFloatingBottomHeight(e,H),Ot=this.getFloatingLeftWidth(e,$),Ct=this.getFloatingRightWidth(e,$),hn=Array.from($.values()),xt=Array.from(H.values()),rt=hn.reduce((qe,ls)=>qe+ls,0)-s,ge=xt.reduce((qe,ls)=>qe+ls,0)-o,Ee=s+rt+p,Ye=o+ge,lt=i-x,wt=r-W,mn=this.getLastLeft(e,null,lt-p),kt=this.getLastLeft(e,null,lt-p-S),no=this.getLastTop(e,null,wt-ke),Kt=this.getLastTop(e,null,wt-ke-S);let St=kt,gn=Kt;mn===0&&no===0&&(St=0,gn=0);const os=St>0,Ds=os?S:0,is=gn>0,rs=is?S:0,so=x,oo=I*C,pn=i-so-rs,Hn=r-oo-Ds,si=b===1?pn/Ee:(b-St)/b,io=v===1?Hn/Ye:(v-gn)/v,Is=os?$e(pn*si,w,pn-1):0,Ns=is?$e(Hn*io,w,Hn-1):0,ro=O($,t,0),lo=O(H,n,0),oi=ro>0?s/ro:0,ii=lo>0?o/lo:0,ri=b===1?s/(Ee-lt):(t+oi)/St,Vn=v===1?o/(Ye-wt):(n+ii)/gn,li=os?ri*(pn-Is):0,ao=is?Vn*(Hn-Ns):0,co=[...Array(T).keys(),...[...Array(R).keys()].map(qe=>v-qe-1)],As=new Map([...ne,...this.getFloatingRowYs(e,H,Math.floor(r-W-Ds))]),uo=[...Array(D).keys(),...[...Array(A).keys()].map(qe=>b-qe-1)],fn=new Map([...se,...this.getFloatingColumnXs(e,$,Math.floor(i-x-rs))]),Ms=[];if(u)for(let qe=u.range[0];qe<=u.range[1];qe+=1)Ms.push(qe),$.has(qe)||$.set(qe,this.getVisibleColumnWidth(qe,e)),fn.has(qe)||fn.set(qe,0);const ho=G.concat(co),Os=ee.concat(uo).concat(Ms),xs=this.getModelRows(ho,e),ai=this.getModelColumns(Os,e),mo=this.getVisibleRowTreeBoxes(H,xs,e),go=this.getTopVisible(e,As,H,G),po=this.getLeftVisible(e,fn,$,ee),fo=gn>0?this.getBottomVisible(e,As,H,G,W):he,Co=St>0?this.getRightVisible(e,fn,$,ee,x):ve,{fontWidths:wo,userColumnWidths:ci,userRowHeights:So,calculatedRowHeights:To,calculatedColumnWidths:bo}=this;return{rowHeight:h,rowHeaderWidth:g,rowFooterWidth:p,rowCount:v,columnWidth:f,columnCount:b,columnHeaderHeight:C,floatingTopRowCount:T,floatingBottomRowCount:R,floatingLeftColumnCount:D,floatingRightColumnCount:A,gridX:x,gridY:W,firstRow:L,firstColumn:k,treePaddingX:V,treePaddingY:Y,left:t,top:n,bottom:he,right:ve,topOffset:o,leftOffset:s,topVisible:go,leftVisible:po,bottomVisible:fo,rightVisible:Co,bottomViewport:Ie,rightViewport:Ge,width:i,height:r,maxX:rt,maxY:ge,lastLeft:St,lastTop:gn,barHeight:Hn,barTop:oo,barWidth:pn,barLeft:so,handleHeight:Ns,handleWidth:Is,hasHorizontalBar:os,hasVerticalBar:is,verticalBarWidth:rs,horizontalBarHeight:Ds,scrollX:li,scrollY:ao,scrollableContentWidth:Ee,scrollableContentHeight:Ye,scrollableViewportWidth:lt,scrollableViewportHeight:wt,visibleRows:G,visibleColumns:ee,visibleRowHeights:j,visibleColumnWidths:ie,floatingRows:co,floatingColumns:uo,allRows:ho,allColumns:Os,allRowHeights:H,allColumnWidths:$,floatingTopHeight:me,floatingBottomHeight:ke,floatingLeftWidth:Ot,floatingRightWidth:Ct,visibleRowYs:ne,visibleColumnXs:se,allRowYs:As,allColumnXs:fn,visibleRowTreeBoxes:mo,modelRows:xs,modelColumns:ai,movedRows:c,movedColumns:d,fontWidths:wo,userColumnWidths:ci,userRowHeights:So,calculatedRowHeights:To,calculatedColumnWidths:bo,columnHeaderMaxDepth:I}}getGridX(e){const{theme:t}=e,{rowHeaderWidth:n}=t;return n}getGridY(e){const{theme:t,model:n}=e,{columnHeaderHeight:s}=t,{columnHeaderMaxDepth:o}=n;return o*s}getVisibleHeight(e,t=this.getFloatingRowHeights(e)){const{height:n,theme:s}=e,{scrollBarSize:o}=s,i=this.getGridY(e),r=this.getFloatingBottomHeight(e,t),l=this.getFloatingTopHeight(e,t);return n-r-l-i-o}getVisibleWidth(e,t=this.getFloatingColumnWidths(e)){const{width:n,theme:s}=e,{scrollBarSize:o,rowFooterWidth:i}=s,r=this.getGridX(e),l=this.getFloatingRightWidth(e,t),a=this.getFloatingLeftWidth(e,t);return n-a-l-r-o-i}getFirstIndex(e,t,n){const s=e.size+1;for(let o=0;o<s;o+=1){const i=t(o,n);if(e.get(i)!==0)return o}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:o,floatingRightColumnCount:i}=s;let r=Math.max(0,o-i-1);t!=null&&(r=t);let l=0;for(;r>=0;){if(l+=this.getVisibleColumnWidth(r,e),l>=n)return $e(r+1,0,t!=null?t:o-1);r-=1}return 0}getLastTop(e,t,n){const{model:s}=e,{rowCount:o,floatingBottomRowCount:i}=s;let r=Math.max(0,o-i-1);t!=null&&(r=t);let l=0;for(;r>=0;){if(l+=this.getVisibleRowHeight(r,e),l>=n)return $e(r+1,0,o-1);r-=1}return 0}getTopForTopVisible(e,t){const n=this.getFloatingTopHeight(e);let s=t,o=0;for(;s>0&&o<n;)s-=1,o+=this.getVisibleRowHeight(s,e);return s}getTopForBottomVisible(e,t){const{height:n}=e,s=this.getGridY(e),o=this.getFloatingBottomHeight(e),i=n-s-o;return this.getLastTop(e,t,i)}getLeftForLeftVisible(e,t){const n=this.getFloatingLeftWidth(e);let s=t,o=0;for(;s>0&&o<n;)s-=1,o+=this.getVisibleColumnWidth(s,e);return s}getLeftForRightVisible(e,t){const{width:n}=e,s=this.getGridX(e),o=this.getFloatingRightWidth(e),i=n-s-o;return this.getLastLeft(e,t,i)}getFloatingRowHeights(e){const{model:t}=e,{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:o}=t,i=new Map;for(let r=0;r<n&&r<o;r+=1)i.set(r,this.getVisibleRowHeight(r,e));for(let r=0;r<s&&o-r-1>=0;r+=1){const l=o-r-1;i.set(l,this.getVisibleRowHeight(l,e))}return i}getVisibleRowHeights(e){const{top:t,topOffset:n,height:s,model:o}=e;let i=0,r=t;const l=new Map,{rowCount:a}=o;for(;i<s+n&&r<a;){const c=this.getVisibleRowHeight(r,e);l.set(r,c),i+=c,r+=1}return l}getFloatingColumnWidths(e,t=this.getFirstColumn(e),n=this.calculateTreePaddingX(e)){const{model:s}=e,{columnCount:o,floatingLeftColumnCount:i,floatingRightColumnCount:r}=s,l=new Map;for(let a=0;a<i&&a<o;a+=1)l.set(a,this.getVisibleColumnWidth(a,e,t,n));for(let a=0;a<r&&o-a-1>=0;a+=1){const c=o-a-1;l.set(c,this.getVisibleColumnWidth(c,e,t,n))}return l}getVisibleColumnWidths(e,t=this.getFirstColumn(e),n=this.calculateTreePaddingX(e)){const{left:s,leftOffset:o,width:i,model:r}=e;let l=0,a=s;const c=new Map,{columnCount:d}=r;for(;l<i+o&&a<d;){const u=this.getVisibleColumnWidth(a,e,t,n);c.set(a,u),l+=u,a+=1}return c}getFloatingColumnXs(e,t,n){const{model:s}=e,{columnCount:o,floatingLeftColumnCount:i,floatingRightColumnCount:r}=s;return Fr(i,r,o,n,t)}getVisibleColumnXs(e,t,n){const s=new Map;let o=-n;for(let i=0;i<t.length;i+=1){const r=t[i],l=O(e,r);s.set(r,o),o+=l}return s}getFloatingRowYs(e,t,n){const{model:s}=e,{floatingTopRowCount:o,floatingBottomRowCount:i,rowCount:r}=s;return Fr(o,i,r,n,t)}getVisibleRowYs(e,t,n){const s=new Map;let o=-n;for(let i=0;i<t.length;i+=1){const r=t[i],l=O(e,r);s.set(r,o),o+=l}return s}getVisibleRowTreeBoxes(e,t,n){const s=new Map,{model:o,theme:i}=n,{treeDepthIndent:r,treeHorizontalPadding:l}=i;return Me(o)&&o.hasExpandableRows&&e.forEach((a,c)=>{const d=O(t,c);if(o.isRowExpandable(d)){const u=o.depthForRow(d),h=u*r+l,g=(u+1)*r+l,p=0,f=a;s.set(c,{x1:h,y1:p,x2:g,y2:f})}}),s}getFloatingLeftWidth(e,t=this.getFloatingColumnWidths(e)){const{model:n}=e,{floatingLeftColumnCount:s}=n;let o=0;for(let i=0;i<s;i+=1)o+=O(t,i);return o}getFloatingRightWidth(e,t=this.getFloatingColumnWidths(e)){const{model:n}=e,{floatingRightColumnCount:s,columnCount:o}=n;let i=0;for(let r=0;r<s;r+=1)i+=O(t,o-r-1);return i}getFloatingTopHeight(e,t=this.getFloatingRowHeights(e)){const{model:n}=e,{floatingTopRowCount:s}=n;let o=0;for(let i=0;i<s;i+=1)o+=O(t,i);return o}getFloatingBottomHeight(e,t=this.getFloatingRowHeights(e)){const{model:n}=e,{floatingBottomRowCount:s,rowCount:o}=n;let i=0;for(let r=0;r<s;r+=1)i+=O(t,o-r-1);return i}getTopVisible(e,t,n,s){const o=this.getFloatingTopHeight(e,n);for(let i=0;i<s.length;i+=1){const r=s[i];if(O(t,r)>=o)return r}return 0}getLeftVisible(e,t,n,s){const o=this.getFloatingLeftWidth(e,n);for(let i=0;i<s.length;i+=1){const r=s[i];if(O(t,r)>=o)return r}return 0}getBottomVisible(e,t,n,s,o){const{height:i,theme:r}=e,{scrollBarSize:l}=r,a=this.getFloatingBottomHeight(e,n),c=i-o-l-a;for(let d=s.length-1;d>=0;d-=1){const u=s[d],h=O(t,u),g=O(n,u);if(h+g<=c)return u}return 0}getRightVisible(e,t,n,s,o){const{width:i,theme:r}=e,{scrollBarSize:l}=r,a=this.getFloatingRightWidth(e,n),c=i-o-l-a;for(let d=s.length-1;d>=0;d-=1){const u=s[d],h=O(t,u),g=O(n,u);if(h+g<=c)return u}return 0}getBottomViewport(e,t,n,s){const{height:o,theme:i}=e,{rowHeight:r}=i;return this.getLastIndexViewport(t,n,s,o,r)}getRightViewport(e,t,n,s){const{width:o,theme:i}=e,{columnWidth:r}=i;return this.getLastIndexViewport(t,n,s,o,r)}getLastIndexViewport(e,t,n,s,o){let i=0,r=0;return e.length>0&&(i=e[e.length-1],r=O(t,i)+O(n,i)),r<s&&(i+=Math.ceil((s-r)/o)),i}getVisibleItemSize(e,t,n){var s;return(s=t.get(e))!=null?s:n()}getVisibleRowHeight(e,t){const n=this.getModelRow(e,t),s=this.calculateRowHeight(e,n,t);return this.getVisibleItemSize(n,this.userRowHeights,()=>{const o=this.initialRowHeights.get(n);return o!==void 0?o:s})}getVisibleColumnWidth(e,t,n=this.getFirstColumn(t),s=this.calculateTreePaddingX(t)){const o=this.getModelColumn(e,t),i=this.calculateColumnWidth(e,o,t,n,s);return this.getVisibleItemSize(o,this.userColumnWidths,()=>{const r=this.initialColumnWidths.get(o);return r!==void 0?r:i})}getModelRows(e,t){const n=new Map;for(let s=0;s<e.length;s+=1){const o=e[s],i=this.getModelRow(o,t);n.set(o,i)}return n}getModelRow(e,t){if(this.modelRows.has(e))return O(this.modelRows,e);const{movedRows:n}=t,s=_.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 o=e[s],i=this.getModelColumn(o,t);n.set(o,i)}return n}getModelColumn(e,t){if(this.modelColumns.has(e))return O(this.modelColumns,e);const{movedColumns:s}=t,o=_.getModelIndex(e,s);return this.modelColumns.set(e,o),o}calculateRowHeight(e,t,n){const{theme:s}=n,{autoSizeRows:o,rowHeight:i}=s;if(!o)return i;const r=this.calculatedRowHeights.get(t);return r!=null?r:(this.calculatedRowHeights.set(t,Math.ceil(i)),Ro(this.calculatedRowHeights),i)}calculateColumnWidth(e,t,n,s=this.getFirstColumn(n),o=this.calculateTreePaddingX(n)){const{theme:i}=n,{autoSizeColumns:r,minColumnWidth:l}=i;if(!r){const{columnWidth:h}=i;return h}const a=this.calculateColumnHeaderWidth(t,n),c=this.calculateColumnDataWidth(t,n),d=this.calculatedColumnWidths.get(t);let u=Math.ceil(Math.max(a,c));return u=Math.max(l,u),d!=null&&d>u?u=d:(this.calculatedColumnWidths.set(t,u),Ro(this.calculatedColumnWidths)),e===s&&(u+=o),u}calculateColumnHeaderWidth(e,t){const{model:n,theme:s}=t,{headerFont:o,headerHorizontalPadding:i}=s,r=n.textForColumnHeader(e,0);if(r!==void 0&&r!==""){const l=this.getWidthForFont(o,t);return r.length*l+i*2}return i*2}calculateColumnDataWidth(e,t){const{top:n,height:s,width:o,model:i,theme:r}=t,{floatingTopRowCount:l,floatingBottomRowCount:a,rowCount:c}=i,{font:d,cellHorizontalPadding:u,rowHeight:h,rowHeaderWidth:g,rowFooterWidth:p,scrollBarSize:f}=r;let C=0;const w=this.getWidthForFont(d,t),S=s/h,b=Math.ceil(n+S);return _.iterateAllItems(n,b,l,a,c,v=>{const T=this.getModelRow(v,t),R=i.textForCell(e,T);if(R){const D=u*2;C=Math.max(C,R.length*w+D)}}),C=Math.max(Math.min(C,(o-g-f-p)*wl.MAX_COLUMN_WIDTH),u*2),C}calculateTreePaddingX(e){const{top:t,height:n,model:s,theme:o}=e,{rowHeight:i,treeDepthIndent:r}=o;if(!Me(s)||!s.hasExpandableRows)return 0;let l=0;const a=n/i,c=Math.ceil(t+a);for(let d=t;d<=c;d+=1){const u=this.getModelRow(d,e),h=s.depthForRow(u);l=Math.max(l,r*(h+1))}return l}getWidthForFont(e,t){if(this.fontWidths.has(e))return O(this.fontWidths,e);const{context:n}=t;n.font=e;const s=n.measureText("8"),{width:o}=s;return this.fontWidths.set(e,o),this.fontWidths.set(n.font,o),o}setColumnWidth(e,t){const n=new Map(this.userColumnWidths);n.set(e,Math.ceil(t)),Ro(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)),Ro(n),this.userRowHeights=n}resetRowHeight(e){const t=new Map(this.userRowHeights);t.delete(e),this.userRowHeights=t,this.calculatedRowHeights.delete(e)}};let js=wl;js.CACHE_SIZE=1e4;js.MAX_COLUMN_WIDTH=.8;const nd=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",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"}),pt=(e,t)=>{let n=!1;const s=Te(e,{...t,dispose:()=>{n||(n=!0,s.clear(),n=!1)}});return s};function sd(e,t,n=6){const s=yi.hex.lab.raw(e);return s[0]=Math.max(s[0]-s[0]/n*t,0),`#${yi.lab.hex(s)}`}function od(e,t){const[n,s,o]=yi.hex.rgb(e);return`rgba(${n}, ${s}, ${o}, ${t})`}const Dr={colorWithAlpha:od,darkenForDepth:sd};class Ke{constructor(t=5e3){this.cursor=null,this.order=t}onDown(t,n,s){return!1}onMove(t,n,s){return!1}onDrag(t,n,s){return!1}onLeave(t,n,s){return!1}onClick(t,n,s){return!1}onContextMenu(t,n,s){return!1}onDoubleClick(t,n,s){return!1}onUp(t,n,s){return!1}onWheel(t,n,s){return!1}}class Sl extends Ke{constructor(){super(...arguments),this.resizingItems=[],this.hiddenItems=[],this.targetSizes=new Map,this.dragOffset=0}onDown(t,n){const{metrics:s}=n,{model:o}=n.props,i=n.getTheme();if(!s)throw new Error("metrics not set");const r=this.getSeparator(t,s,o,i);if(r!=null){const l=r.index;return this.dragOffset=0,this.draggingIndex=l,this.resizingItems=[l],this.hiddenItems=this.getHiddenItems(l,s).reverse(),this.targetSizes.clear(),this.addTargetSize(s,l),this.updateCursor(s,l),this.updateSeparator(n,r),!0}return!1}onMove(t,n){const{metrics:s}=n,{model:o}=n.props,i=n.getTheme();if(!s)throw new Error("metrics not set");const r=this.getSeparator(t,s,o,i);return r!=null?(this.updateCursor(s,r.index),!0):!1}onDrag(t,n){var f;if(this.draggingIndex==null)return!1;const s=t[this.pointProperty],{metricCalculator:o,metrics:i}=n;if(!i)throw new Error("metrics not set");const r=n.getTheme(),l=i[this.visibleOffsetProperty],a=i[this.marginProperty],c=i[this.calculatedSizesProperty],d=i[this.modelIndexesProperty],u=i[this.firstIndexProperty],h=i[this.treePaddingProperty],g=new Map;let p=this.resizingItems[this.resizingItems.length-1];for(;p!=null;){const C=O(l,p),w=s-a-C-this.dragOffset,S=O(d,p),b=this.targetSizes.get(S),v=this.resizingItems.length>1,T=this.hiddenItems.indexOf(p);let R=O(c,S);p===u&&(R+=h);let D=w;Math.abs(w-R)<=r.headerResizeSnapThreshold?D=R:b!==void 0&&w>b&&(v&&T!==0||T>0)?D=b:w<=r.headerResizeHiddenSnapThreshold&&(D=0),g.set(S,D),w<-r.headerResizeSnapThreshold&&D===0?T>=0&&v?(this.resizingItems.pop(),this.removeTargetSize(i,p),p=this.resizingItems[this.resizingItems.length-1],this.dragOffset-=(f=this.targetSizes.get(O(d,p)))!=null?f:0):(p=this.getNextShownItem(p,i),p!==null&&(this.resizingItems.push(p),this.addTargetSize(i,p))):b!==void 0&&w>b+r.headerResizeSnapThreshold&&D===b?T>0?(this.dragOffset+=D,p=this.hiddenItems[T-1],this.resizingItems.push(p),this.addTargetSize(i,p)):v?(this.resizingItems.pop(),this.removeTargetSize(i,p),p=this.resizingItems[this.resizingItems.length-1]):p=null:p=null}return g.forEach((C,w)=>{var b;const S=(b=o[this.initialSizesProperty].get(w))!=null?b:c.get(w);C===S?this.resetSize(o,w):this.setSize(o,w,C)}),this.updateCursor(i,this.draggingIndex),!0}onUp(t,n){return this.draggingIndex!=null&&(this.draggingIndex=void 0,this.resizingItems=[],this.hiddenItems=[],this.targetSizes.clear(),this.updateSeparator(n,null)),!1}onDoubleClick(t,n){const{metrics:s,metricCalculator:o}=n,{model:i}=n.props,r=n.getTheme();if(!s)throw new Error("metrics not set");const l=this.getSeparator(t,s,i,r);if(l!=null){const a=s[this.modelIndexesProperty],c=O(a,l.index),d=O(s[this.calculatedSizesProperty],c),u=o[this.initialSizesProperty].get(c);return d===u?this.resetSize(o,c):this.setSize(o,c,d),n.forceUpdate(),!0}return!1}updateCursor(t,n){const s=t[this.visibleSizesProperty];O(s,n)===0?this.cursor=this.hiddenCursor:this.cursor=this.defaultCursor}addTargetSize(t,n){const s=t[this.modelIndexesProperty],o=t[this.userSizesProperty],i=t[this.calculatedSizesProperty],r=n===0?t[this.treePaddingProperty]:0,l=O(s,n);let a=o.get(l);(a==null||a===0)&&(a=O(i,l)+r),this.targetSizes.set(l,a)}removeTargetSize(t,n){const s=t[this.modelIndexesProperty],o=O(s,n);this.targetSizes.delete(o)}}class Qo extends Sl{constructor(){super(...arguments),this.hiddenCursor="e-resize",this.defaultCursor="col-resize",this.pointProperty="x",this.userSizesProperty="userColumnWidths",this.visibleOffsetProperty="visibleColumnXs",this.visibleSizesProperty="visibleColumnWidths",this.marginProperty="rowHeaderWidth",this.calculatedSizesProperty="calculatedColumnWidths",this.initialSizesProperty="initialColumnWidths",this.modelIndexesProperty="modelColumns",this.firstIndexProperty="firstColumn",this.treePaddingProperty="treePaddingX",this.getHiddenItems=_.getHiddenColumns,this.getNextShownItem=_.getNextShownColumn,this.getSeparator=Qo.getColumnSeparator}static getColumnSeparator(t,n,s,o){if(!o.allowColumnResize)return null;const{x:i,y:r,columnHeaderDepth:l}=t,{modelColumns:a}=n,c=_.getColumnSeparatorIndex(i,r,n,o);return c==null||l==null||l>0?null:a.get(c)!=null?{index:c,depth:0}:null}setSize(t,n,s){t.setColumnWidth(n,s)}resetSize(t,n){t.resetColumnWidth(n)}updateSeparator(t,n){t.setState({draggingColumnSeparator:n,isDragging:n!==null})}}const nn=class{constructor(){this.getCachedTruncatedString=pt((e,t,n,s,o)=>nn.truncateToWidth(e,t,n,s,o),{max:1e4}),this.getCachedBackgroundColors=pt((e,t)=>e.split(" ").map(n=>{const s=[];for(let o=0;o<t;o+=1)s.push(Dr.darkenForDepth(n,o,t));return s}),{max:1e3}),this.getCachedColorWithAlpha=pt((e,t)=>Dr.colorWithAlpha(e,t),{max:1e3}),this.getCachedColorIsDark=pt(e=>Xo.isDark(e),{max:1e3})}static truncate(e,t){return t<e.length?e.substr(0,t)+"\u2026":e}static binaryTruncateToWidth(e,t,n,s=0,o=t.length,i){if(o>=t.length&&e.measureText(t).width<=n)return t;if(i!==void 0){const c=e.measureText(i).width;return i.repeat(Math.max(1,Math.floor(n/c)))}let r=s,l=Math.min(t.length-1,o),a=t;for(;l>=r;){const c=Math.ceil((l+r)/2),d=nn.truncate(t,c);if(e.measureText(d).width<=n){if(a=d,r===c)break;r=c}else if(c===0){a=d;break}else l=c-1}return a}static truncateToWidth(e,t,n,s=nn.DEFAULT_FONT_WIDTH,o){if(n<=0||t.length<=0)return"";const i=Math.min(Math.max(0,Math.floor(n/s/2)-5),t.length),r=Math.min(Math.ceil(n/s*2),t.length);return nn.binaryTruncateToWidth(e,t,n,i,r,o)}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:o,height:i}=s;e.fillStyle=n.backgroundColor,e.fillRect(0,0,o,i)}drawGrid(e,t){const{metrics:n,draggingRow:s,draggingColumn:o}=t,{gridX:i,gridY:r}=n;e.translate(i,r),this.drawGridBackground(e,t,s==null&&o==null),this.drawCellContents(e,t),this.drawFloatingRows(e,t),this.drawFloatingColumns(e,t),e.translate(-i,-r)}drawFloatingRows(e,t){const{draggingRow:n,draggingColumn:s,metrics:o,theme:i}=t,{floatingTopRowCount:r,floatingBottomRowCount:l,floatingRows:a,rowCount:c,visibleColumns:d,allRowYs:u,allRowHeights:h}=o;if(a.length!==0){i.floatingRowBackgroundColors&&this.drawRowStripesForRows(e,t,a,i.floatingRowBackgroundColors),n==null&&s==null&&this.drawFloatingMouseRowHover(e,t),this.drawGridLinesForItems(e,t,d,a,i.floatingGridColumnColor,i.floatingGridRowColor),this.drawCellBackgroundsForItems(e,t,d,a),this.drawFloatingBorders(e,t),r>0&&this.drawSelectedRanges(e,t,{top:0,bottom:r-1,maxY:O(u,r-1)+O(h,r-1)-.5}),l>0&&this.drawSelectedRanges(e,t,{top:c-l-1,bottom:c-1,minY:O(u,c-l)+.5,maxY:O(u,c-1)+O(h,c-1)-.5});for(let g=0;g<d.length;g+=1){const p=d[g];for(let f=0;f<a.length;f+=1){const C=a[f];this.drawCellContent(e,t,p,C)}}}}drawFloatingColumns(e,t){const{draggingRow:n,draggingColumn:s,metrics:o,theme:i}=t,{floatingLeftColumnCount:r,floatingRightColumnCount:l,floatingLeftWidth:a,floatingRightWidth:c,floatingColumns:d,gridX:u,maxX:h,columnCount:g,visibleRows:p,allColumnXs:f,allColumnWidths:C,width:w,height:S}=o;if(d.length!==0){i.floatingRowBackgroundColors&&(this.drawRowStripesForRows(e,t,p,i.floatingRowBackgroundColors,0,a),this.drawRowStripesForRows(e,t,p,i.floatingRowBackgroundColors,w-u-c,h)),n==null&&s==null&&this.drawFloatingMouseRowHover(e,t),e.save(),e.beginPath(),e.rect(0,0,a,S),e.clip(),this.drawGridLinesForItems(e,t,d,p,i.floatingGridColumnColor,i.floatingGridRowColor),e.restore(),this.drawCellBackgroundsForItems(e,t,d,p),this.drawFloatingBorders(e,t),r>0&&this.drawSelectedRanges(e,t,{left:0,maxX:O(f,r-1)+O(C,r-1)}),l>0&&this.drawSelectedRanges(e,t,{left:g-l,right:g-1,minX:O(f,g-l)+.5,maxX:O(f,g-1)+O(C,g-1)});for(let b=0;b<d.length;b+=1){const v=d[b];for(let T=0;T<p.length;T+=1){const R=p[T];this.drawCellContent(e,t,v,R)}}}}drawFloatingBorders(e,t){const{metrics:n,theme:s}=t,{floatingTopRowCount:o,floatingBottomRowCount:i,floatingLeftColumnCount:r,floatingRightColumnCount:l,rowCount:a,columnCount:c,allRowYs:d,allColumnXs:u,allRowHeights:h,allColumnWidths:g,maxX:p,maxY:f}=n,{floatingDividerOuterColor:C,floatingDividerInnerColor:w}=s;if(e.lineWidth=3,e.beginPath(),e.strokeStyle=C,o>0){const S=O(d,o-1)+O(h,o-1)+.5;e.moveTo(0,S),e.lineTo(p,S)}if(i>0){const S=O(d,a-i)-.5;e.moveTo(0,S),e.lineTo(p,S)}if(r>0){const S=O(u,r-1)+O(g,r-1)+.5;e.moveTo(S,0),e.lineTo(S,f)}if(l>0){const S=O(u,c-l)-.5;e.moveTo(S,0),e.lineTo(S,f)}if(e.stroke(),e.beginPath(),e.lineWidth=1,e.strokeStyle=w,o>0){const S=O(d,o-1)+O(h,o-1)+.5;e.moveTo(0,S),e.lineTo(p,S)}if(i>0){const S=O(d,a-i)-.5;e.moveTo(0,S),e.lineTo(p,S)}if(r>0){const S=O(u,r-1)+O(g,r-1)+.5;e.moveTo(S,0),e.lineTo(S,f)}if(l>0){const S=O(u,c-l)-.5;e.moveTo(S,0),e.lineTo(S,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:o,right:i,floatingBottomRowCount:r,floatingLeftColumnCount:l,floatingRightColumnCount:a,floatingTopRowCount:c,columnCount:d,rowCount:u,allRowHeights:h,allRowYs:g,allColumnXs:p,allColumnWidths:f,width:C,height:w}=s;this.drawSelectedRanges(e,t,{bottom:Math.min(o,u-r-1),right:Math.min(i,d-a-1),minX:l>0&&p.has(l+1)?O(p,l+1):-10,minY:c>0&&g.has(c+1)?O(g,c+1):-10,maxX:a>0&&p.has(d-a-1)?O(p,d-a-1)+O(f,d-a-1)-.5:C+10,maxY:r>0&&g.has(u-r-1)?O(g,u-r-1)+O(h,u-r-1)-.5:w+10})}drawRowStripes(e,t){const{metrics:n,theme:s}=t,{visibleRows:o}=n,{rowBackgroundColors:i}=s;!i||this.drawRowStripesForRows(e,t,o,i)}drawRowStripesForRows(e,t,n,s,o=0,i=t.metrics.maxX){const{theme:r,metrics:l,model:a}=t,{maxDepth:c,shadowBlur:d,shadowColor:u}=r,h=this.getCachedBackgroundColors(s,c),{allRowYs:g,allRowHeights:p}=l,f=new Map,C=[],w=[],S=(b,v)=>{const T=Me(a)?a.depthForRow(b):0,R=h[b%h.length],D=R[Math.min(T,R.length-1)];if(f.has(D)||f.set(D,[]),f.get(D).push(b),v!=null){const A=Me(a)?a.depthForRow(v):0;A<T?C.push(b):A>T&&w.push(v)}};for(let b=0;b<n.length;b+=1){const v=n[b],T=b>0?n[b-1]:void 0;S(v,T)}if(f.forEach((b,v)=>{e.fillStyle=v,e.beginPath();for(let T=0;T<b.length;T+=1){const R=b[T],D=O(g,R),A=O(p,R);e.rect(o,D,i,A)}e.fill()}),C.length>0){e.save();const b=this.getCachedColorWithAlpha(u,.15),v=this.getCachedColorWithAlpha(u,0),T=e.createLinearGradient(0,0,0,d);T.addColorStop(0,b),T.addColorStop(1,v),e.fillStyle=T;for(let R=0;R<C.length;R+=1){const D=C[R],A=O(g,D);e.translate(0,A),e.fillRect(o,0,i,d),e.translate(0,-A)}e.restore()}if(w.length>0){e.save();const b=this.getCachedColorWithAlpha(u,0),v=this.getCachedColorWithAlpha(u,.15),T=e.createLinearGradient(0,0,0,d);T.addColorStop(0,b),T.addColorStop(1,v),e.fillStyle=T;for(let R=0;R<w.length;R+=1){const D=w[R],A=O(g,D),I=O(p,D),L=A+I-d;e.translate(0,L),e.fillRect(o,0,i,d),e.translate(0,-L)}e.restore()}}drawMouseColumnHover(e,t){const{mouseX:n,mouseY:s,theme:o,metrics:i}=t;if(n==null||s==null)return;const r=_.getColumnAtX(n,i);if(r==null||o.columnHoverBackgroundColor==null)return;const{allColumnWidths:l,allColumnXs:a,maxY:c}=i;if(s>c)return;const d=O(a,r),u=O(l,r);e.fillStyle=o.columnHoverBackgroundColor,e.fillRect(d,0,u,c)}drawMouseRowHover(e,t){const{mouseX:n,mouseY:s,theme:o,metrics:i}=t;if(n==null||s==null)return;const{maxX:r}=i;if(n>r||o.rowHoverBackgroundColor==null)return;const l=_.getRowAtY(s,i);l!=null&&this.drawMouseRowHoverForRow(e,t,l)}drawFloatingMouseRowHover(e,t){const{mouseX:n,mouseY:s,theme:o,metrics:i}=t,{maxX:r,floatingTopRowCount:l,floatingBottomRowCount:a,rowCount:c,rowFooterWidth:d}=i;if(n==null||s==null||n>r+d||o.rowHoverBackgroundColor==null)return;const u=_.getRowAtY(s,i);u!=null&&(u<l||c-a<=u)&&this.drawMouseRowHoverForRow(e,t,u)}drawMouseRowHoverForRow(e,t,n){const{metrics:s,selectedRanges:o,theme:i}=t,{allRowHeights:r,allRowYs:l,maxX:a}=s,c=O(l,n),d=O(r,n);i.rowHoverBackgroundColor!=null&&(e.fillStyle=i.rowHoverBackgroundColor);for(let u=0;u<o.length;u+=1){const{startRow:h,endRow:g}=o[u];if(h!=null&&g!=null&&h<=n&&g>=n){i.selectedRowHoverBackgroundColor!=null&&(e.fillStyle=i.selectedRowHoverBackgroundColor);break}}e.fillRect(0,c,a,d)}drawGridLines(e,t){const{metrics:n,theme:s}=t,{visibleColumns:o,visibleRows:i}=n;this.drawGridLinesForItems(e,t,o,i,s.gridColumnColor,s.gridRowColor)}drawGridLinesForItems(e,t,n,s,o,i){o==null&&i==null||(e.lineWidth=1,e.beginPath(),o!=null&&(e.strokeStyle=o,this.drawGridLinesForColumns(e,t,n)),i!=null&&(e.strokeStyle=i,this.drawGridLinesForRows(e,t,s)),e.stroke())}drawGridLinesForColumns(e,t,n){const{metrics:s}=t,{allColumnXs:o,maxY:i}=s;for(let r=0;r<n.length;r+=1){const l=n[r],a=O(o,l)+.5;e.moveTo(a,0),e.lineTo(a,i)}}drawGridLinesForRows(e,t,n){const{metrics:s}=t,{allRowYs:o,maxX:i}=s,r=i;for(let l=0;l<n.length;l+=1){const a=n[l],c=O(o,a)+.5;e.moveTo(.5,c),e.lineTo(r-.5,c)}}drawCellBackgrounds(e,t){const{metrics:n}=t,{visibleColumns:s,visibleRows:o}=n;this.drawCellBackgroundsForItems(e,t,s,o)}drawCellBackgroundsForItems(e,t,n,s){e.save();for(let o=0;o<n.length;o+=1){const i=n[o];for(let r=0;r<s.length;r+=1){const l=s[r],a=r+1<s.length?s[r+1]:void 0;this.drawCellBackground(e,t,i,l,a)}}e.restore()}drawCellBackground(e,t,n,s,o){const{metrics:i,model:r,theme:l}=t,{firstColumn:a,modelColumns:c,modelRows:d,allColumnXs:u,allColumnWidths:h,allRowYs:g,allRowHeights:p}=i,f=O(d,s),C=O(c,n),w=r.backgroundColorForCell(C,f,l),S=n===a,b=Me(r)&&r.hasExpandableRows;if(w!=null){const v=O(u,n)+1,T=O(g,s)+1,R=O(h,n)-1,D=O(p,s)-1;e.fillStyle=w,e.fillRect(v,T,R,D)}S&&b&&this.drawCellRowTreeDepthLines(e,t,s,o)}drawCellContents(e,t){const{metrics:n}=t,{visibleColumns:s}=n;for(let o=0;o<s.length;o+=1){const i=s[o];this.drawColumnCellContents(e,t,i)}}drawColumnCellContents(e,t,n){const{metrics:s}=t,{allColumnXs:o,allColumnWidths:i,visibleRows:r,height:l}=s,a=O(o,n),c=O(i,n);e.save(),e.beginPath(),e.rect(a,0,c,l),e.clip();for(let d=0;d<r.length;d+=1){const u=r[d];this.drawCellContent(e,t,n,u)}e.restore()}getTextRenderMetrics(e,t,n,s){const{textAlign:o}=e,{metrics:i,model:r,theme:l}=t,{firstColumn:a,allColumnXs:c,allColumnWidths:d,allRowYs:u,allRowHeights:h}=i,{cellHorizontalPadding:g,treeDepthIndent:p,treeHorizontalPadding:f}=l,C=O(c,n),w=O(u,s),S=O(d,n),b=O(h,s),v=n===a;let T=0;Me(r)&&r.hasExpandableRows&&v&&(T=p*(r.depthForRow(s)+1)+f);const R=S-T;let D=C+g;const A=w+b*.5;return o==="right"?D=C+R-g:o==="center"&&(D=C+R*.5),D+=T,{width:R-g*2,x:D,y:A}}drawCellContent(e,t,n,s,o){var v;const{metrics:i,model:r,theme:l}=t,{firstColumn:a,fontWidths:c,modelColumns:d,modelRows:u,allRowHeights:h}=i,{textColor:g}=l,p=O(h,s),f=O(u,s),C=O(d,n),w=o!=null?o:r.textForCell(C,f),S=r.truncationCharForCell(C,f),b=n===a;if(w&&p>0){const T=r.textAlignForCell(C,f)||"left";e.textAlign=T;const R=r.colorForCell(C,f,l)||g;e.fillStyle=R;const{width:D,x:A,y:I}=this.getTextRenderMetrics(e,t,n,s),L=(v=c.get(e.font))!=null?v:nn.DEFAULT_FONT_WIDTH,k=this.getCachedTruncatedString(e,w,D,L,S);k&&e.fillText(k,A,I)}b&&Me(r)&&r.hasExpandableRows&&this.drawCellRowTreeMarker(e,t,s)}drawCellRowTreeMarker(e,t,n){const{metrics:s,model:o,mouseX:i,mouseY:r,theme:l}=t,{firstColumn:a,gridX:c,gridY:d,allColumnXs:u,allColumnWidths:h,allRowYs:g,allRowHeights:p,visibleRowTreeBoxes:f}=s,{treeMarkerColor:C,treeMarkerHoverColor:w}=l,S=O(u,a),b=O(h,a),v=O(g,n),T=O(p,n);if(!Me(o)||!o.isRowExpandable(n))return;const R=O(f,n),D=i!=null&&r!=null&&i>=c+S&&i<=c+S+b&&r>=d+v&&r<=d+v+T?w:C;this.drawTreeMarker(e,t,S,v,R,D,o.isRowExpanded(n))}drawTreeMarker(e,t,n,s,o,i,r){const{x1:l,y1:a,x2:c,y2:d}=o,u=r?"\u229F":"\u229E",h=n+(l+c)*.5+.5,g=s+(a+d)*.5+.5;e.fillStyle=i,e.textAlign="center",e.fillText(u,h,g)}drawCellRowTreeDepthLines(e,t,n,s){const{metrics:o,model:i,theme:r}=t;if(!Me(i))return;const l=i.depthForRow(n);if(l===0)return;const{firstColumn:a,allColumnXs:c,allRowYs:d,allRowHeights:u}=o,{treeDepthIndent:h,treeHorizontalPadding:g,treeLineColor:p}=r,f=O(c,a),C=O(d,n),w=O(u,n),S=s!==void 0?i.depthForRow(s):0,b=l>S?l-S:0;if(e.strokeStyle=p,e.lineWidth=1,l-b>0){e.beginPath();for(let v=0;v<l-b;v+=1){const T=f+v*h+h*.5+g+.5;e.moveTo(T,C),e.lineTo(T,C+w)}e.stroke()}if(b>0){e.beginPath();for(let v=l-b;v<l;v+=1){const T=f+v*h+h*.5+g+.5;e.moveTo(T,C),e.lineTo(T,C+Math.ceil(w/2)),e.moveTo(T-.5,C+Math.ceil(w/2)+.5),e.lineTo(T+h-.5,C+Math.ceil(w/2)+.5)}e.stroke()}}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:o,metrics:i,draggingColumnSeparator:r,isDragging:l,model:a}=t,{columnHeaderHeight:c,floatingColumns:d,gridX:u,width:h,visibleColumns:g,allColumnWidths:p,allColumnXs:f,floatingLeftColumnCount:C,floatingLeftWidth:w,floatingRightWidth:S,modelColumns:b,columnHeaderMaxDepth:v}=i;if(c<=0)return;const{headerHiddenSeparatorSize:T,headerHiddenSeparatorHoverColor:R,headerSeparatorColor:D,headerSeparatorHoverColor:A}=o,I=c*.5,L=c*(v-1)+c*.5-I*.5,k=C>0;if(e.save(),this.drawColumnHeadersForRange(e,t,[g[0],g[g.length-1]],{minX:u+w,maxX:h-S}),k&&this.drawColumnHeadersForRange(e,t,[d[0],d[d.length-1]],{minX:u,maxX:u+w}),D){e.strokeStyle=D;const x=[...p.entries()].filter(([W,V])=>V===0).map(([W])=>W);e.beginPath(),e.fillStyle=D;for(let W=0;W<x.length;W+=1){const V=x[W],Y=O(f,V),j=O(p,V),ie=u+Y+j+.5-T*.5;e.rect(ie,L,T,I)}e.fill()}if(A){let{index:x,depth:W}=r!=null?r:{};if(x==null&&n!=null&&s!=null){const Y=Qo.getColumnSeparator(_.getGridPointFromXY(n,s,i),i,a,o);x=Y==null?void 0:Y.index,W=Y==null?void 0:Y.depth}let V;if(x==null)V=!1;else{const Y=b.get(x),j=b.get(x+1);Y==null||j==null?V=!1:V=a.textForColumnHeader(Y,W)!==a.textForColumnHeader(j,W)}if(V&&x!=null&&W!=null&&(!l||r!=null)){e.strokeStyle=A;const Y=O(f,x),j=O(p,x),ie=u+Y+j+.5,G=g.indexOf(x),ee=G<g.length-1?g[G+1]:null,H=ee!=null?p.get(ee):null,$=j===0,se=H!=null&&H===0;$?(e.strokeStyle=R,e.fillStyle=R,e.fillRect(ie,L,T*.5,I)):se&&(e.fillStyle=A,e.fillRect(ie-T*.5,L,T*.5,I)),e.beginPath(),e.moveTo(ie,(v-W-1)*c),e.lineTo(ie,(v-W)*c-1),e.stroke()}}e.restore()}drawColumnHeadersForRange(e,t,n,s){const{model:o}=t,{columnHeaderMaxDepth:i}=o;if(i!==0)for(let r=0;r<=i;r+=1)this.drawColumnHeadersAtDepth(e,t,n,s,r)}drawColumnHeadersAtDepth(e,t,n,s,o){var D,A,I,L,k,x;const{metrics:i,model:r,theme:l}=t,{modelColumns:a,allColumnXs:c,gridX:d,calculatedColumnWidths:u,userColumnWidths:h,allColumnWidths:g,movedColumns:p}=i,{columnHeaderHeight:f,columnWidth:C}=l,{columnHeaderMaxDepth:w}=r,{minX:S,maxX:b}=s,v=b-S;if(w===0)return;const T=n[0],R=n[1];if(e.save(),e.translate(0,(w-o-1)*f),o===0){this.drawColumnHeader(e,t,"",S,b);for(let W=T;W<=R;W+=1)this.drawColumnHeaderAtIndex(e,t,W,s)}if(o>0){let W=T;for(;W<=R;){const{columnCount:V}=i,Y=O(a,W),j=r.textForColumnHeader(Y,o),ie=r.colorForColumnHeader(Y,o);let G=O(c,W)+d,ee=G+O(g,W);if(j!=null){let H=W-1;for(;H>=0&&(ee-G<v||G>S);){const he=(D=a.get(H))!=null?D:_.getModelIndex(H,p);if(he==null||r.textForColumnHeader(he,o)!==j)break;G-=(I=(A=h.get(he))!=null?A:u.get(he))!=null?I:C,H-=1}let $=W+1;for(;$<V&&(ee-G<v||ee<b);){const he=(L=a.get($))!=null?L:_.getModelIndex($,p);if(r.textForColumnHeader(he,o)!==j)break;ee+=(x=(k=h.get(he))!=null?k:u.get(he))!=null?x:C,$+=1}W=$-1;const se=ee-G>=v;let ne=G;se&&(ee<b?ne=ee-v:G<S&&(ne=S)),this.drawColumnHeader(e,t,j,ne,Math.min(ee-G,v),{backgroundColor:ie!=null?ie:void 0},s)}W+=1}}e.restore()}drawColumnHeaderAtIndex(e,t,n,s){var p;const{metrics:o,model:i}=t,{modelColumns:r,allColumnWidths:l,allColumnXs:a,gridX:c}=o,d=O(l,n),u=O(a,n)+c,h=O(r,n),g=i.textForColumnHeader(h);g!=null&&this.drawColumnHeader(e,t,g,u,d,{backgroundColor:(p=i.colorForColumnHeader(h))!=null?p:void 0},s)}drawColumnHeader(e,t,n,s,o,i,r){var $;if(o<=0)return;const{metrics:l,theme:a}=t,{headerHorizontalPadding:c,columnHeaderHeight:d,headerBackgroundColor:u,headerColor:h,headerSeparatorColor:g,black:p,white:f}=a,{fontWidths:C,width:w}=l,S=($=C.get(e.font))!=null?$:nn.DEFAULT_FONT_WIDTH,v=(o-c*2)/S,{backgroundColor:T=u,separatorColor:R=g}=i!=null?i:{};let{textColor:D=h}=i!=null?i:{};try{const se=this.getCachedColorIsDark(T),ne=this.getCachedColorIsDark(D);se&&ne?D=f:!se&&!ne&&(D=p)}catch{}let{minX:A=0,maxX:I=w}=r!=null?r:{};e.save(),e.rect(A,0,I-A,d),e.clip(),T!=null&&(e.fillStyle=T,e.fillRect(s,0,o,d)),R!=null&&(e.strokeStyle=R,e.beginPath(),s>0&&(e.moveTo(s+.5,0),e.lineTo(s+.5,d)),e.moveTo(s+o+.5,0),e.lineTo(s+o+.5,d),e.moveTo(s,d-.5),e.lineTo(s+o,d-.5),e.stroke()),e.beginPath(),e.rect(s,0,o,d),e.clip(),e.fillStyle=D;let L=n;v<=0?L="":L.length>v&&(L=`${L.substring(0,v-1)}\u2026`);const k=L.length*S;let x=s+o*.5;const W=d*.5;A+=c,I-=c;const V=s+c,Y=$e(V,A,I),j=s+o-c,G=$e(j,A,I)-Y,ee=x-k*.5<A,H=x+k*.5>I;ee?k<G?x=A+k*.5:x=j-k*.5:H&&(k<G?x=I-k*.5:x=V+k*.5),e.textAlign="center",e.fillText(L,x,W),e.restore()}drawRowHeaders(e,t){const{mouseX:n,mouseY:s,metrics:o,theme:i,draggingRowSeparator:r}=t,{gridY:l,rowHeaderWidth:a,height:c,visibleRows:d,allRowHeights:u,allRowYs:h}=o;if(a<=0)return;const{headerBackgroundColor:g,headerColor:p,headerHiddenSeparatorSize:f,headerHiddenSeparatorHoverColor:C,headerSeparatorColor:w,headerSeparatorHoverColor:S}=i,b=a*.5,v=a*.5-b*.5;if(e.save(),e.beginPath(),e.fillStyle=g,e.fillRect(0,0,a,c),w){e.strokeStyle=w,e.beginPath(),e.moveTo(0,l+.5),e.lineTo(a,l+.5);const T=[];let R=!1;for(let D=0;D<d.length;D+=1){const A=d[D],I=O(h,A),L=O(u,A);if(L>0){const k=l+I+L+.5;e.moveTo(0,k),e.lineTo(a,k),R=!1}else R||(R=!0,T.push(A))}e.moveTo(a-.5,0),e.lineTo(a-.5,c),e.stroke(),e.beginPath(),e.fillStyle=w;for(let D=0;D<T.length;D+=1){const A=T[D],I=O(h,A),L=O(u,A),k=l+I+L+.5-f*.5;e.rect(v,k,b,f)}e.fill()}if(S){let{index:T=null}=r!=null?r:{};if(T==null&&n!=null&&s!=null&&(T=_.getRowSeparatorIndex(n,s,o,i)),T!=null){e.strokeStyle=S;const R=O(h,T),D=O(u,T),A=l+R+D+.5,I=d.indexOf(T),L=I<d.length-1?d[I+1]:null,k=L!=null?u.get(L):null,x=D===0,W=k!=null&&k===0;x?(e.strokeStyle=C,e.fillStyle=C,e.fillRect(v,A,b,f*.5)):W&&(e.fillStyle=S,e.fillRect(v,A-f*.5,b,f*.5)),e.beginPath(),e.moveTo(.5,A),e.lineTo(a+.5,A),e.stroke()}}e.beginPath(),e.rect(0,l,a,c),e.clip(),e.fillStyle=p,e.textAlign="right";for(let T=0;T<d.length;T+=1){const R=d[T],D=O(u,R),A=O(h,R)+l;this.drawRowHeader(e,t,R,A,D)}e.restore()}drawRowHeader(e,t,n,s,o){if(o<=0)return;const{metrics:i,model:r,theme:l}=t,{modelRows:a,rowHeaderWidth:c}=i,d=O(a,n),u=c-l.cellHorizontalPadding,h=s+o*.5;e.fillText(r.textForRowHeader(d),u,h)}drawRowFooters(e,t){const{mouseX:n,mouseY:s,metrics:o,model:i,theme:r,draggingRowSeparator:l}=t,{gridY:a,gridX:c,maxX:d,modelRows:u,rowFooterWidth:h,height:g,verticalBarWidth:p,visibleRows:f,allRowHeights:C,allRowYs:w,width:S}=o;if(h<=0)return;const{cellHorizontalPadding:b,headerBackgroundColor:v,headerColor:T,headerHiddenSeparatorSize:R,headerHiddenSeparatorHoverColor:D,headerSeparatorColor:A,headerSeparatorHoverColor:I}=r,L=h*.5,k=h*.5-L*.5,x=Math.min(c+d,S-h-p);if(e.save(),e.beginPath(),e.fillStyle=v,e.fillRect(x,a,h,g),A){e.strokeStyle=A,e.beginPath(),e.moveTo(x,a+.5),e.lineTo(h,a+.5);const V=[];let Y=!1;for(let j=0;j<f.length;j+=1){const ie=f[j],G=O(w,ie),ee=O(C,ie);if(ee>0){const H=a+G+ee+.5;e.moveTo(x+.5,H),e.lineTo(x+h-.5,H),Y=!1}else Y||(Y=!0,V.push(ie))}e.moveTo(x+.5,a),e.lineTo(x+.5,g),e.stroke(),e.beginPath(),e.fillStyle=A;for(let j=0;j<V.length;j+=1){const ie=V[j],G=O(w,ie),ee=O(C,ie),H=a+G+ee+.5-R*.5;e.rect(x+k,H,L,R)}e.fill()}if(I){let{index:V=null}=l!=null?l:{};if(V==null&&n!=null&&s!=null&&(V=_.getRowSeparatorIndex(n,s,o,r)),V!=null){e.strokeStyle=I;const Y=O(w,V),j=O(C,V),ie=a+Y+j+.5,G=f.indexOf(V),ee=G<f.length-1?f[G+1]:null,H=ee!=null?C.get(ee):null,$=j===0,se=H!=null&&H===0;$?(e.strokeStyle=D,e.fillStyle=D,e.fillRect(k,ie,L,R*.5)):se&&(e.fillStyle=I,e.fillRect(k,ie-R*.5,L,R*.5)),e.beginPath(),e.moveTo(x+.5,ie),e.lineTo(x+h+.5,ie),e.stroke()}}e.beginPath(),e.rect(x,a,h,g),e.clip(),e.fillStyle=T,e.textAlign="left";const W=x+b;for(let V=0;V<f.length;V+=1){const Y=f[V],j=O(C,Y);if(j>0){const ie=O(w,Y)+a,G=O(u,Y),ee=ie+j*.5;e.fillText(i.textForRowFooter(G),W,ee)}}e.restore()}drawSelectedRanges(e,t,n={}){const{cursorColumn:s,cursorRow:o,draggingRow:i,draggingColumn:r,editingCell:l,metrics:a,model:c,selectedRanges:d,theme:u}=t,{allColumnWidths:h,allColumnXs:g,allRowHeights:p,allRowYs:f,width:C,height:w}=a,{left:S=a.left,top:b=a.top,right:v=a.right,bottom:T=a.bottom,minY:R=-10,maxY:D=w+10,minX:A=-10,maxX:I=C+10}=n;if(d.length===0)return;const L=Pe(c)&&c.isEditable&&l==null&&i==null&&r==null&&s!=null&&o!=null&&g.has(s)&&f.has(o);if(L){const k=O(g,s),x=O(f,o),W=O(h,s),V=O(p,o);e.save(),e.beginPath(),e.rect(0,0,C,w),e.rect(k,x,W,V),e.clip("evenodd")}e.beginPath();for(let k=0;k<d.length;k+=1){const x=d[k],W=x.startColumn!==null?x.startColumn:S,V=x.startRow!==null?x.startRow:b,Y=x.endColumn!==null?x.endColumn:v,j=x.endRow!==null?x.endRow:T;if(j>=b&&T>=V&&Y>=S&&v>=W){const ie=W>=S&&g.has(W)?Math.round(O(g,W))+.5:A,G=V>=b&&f.has(V)?Math.max(Math.round(O(f,V))+.5,.5):R,ee=Y<=v&&g.has(Y)?Math.round(O(g,Y)+O(h,Y))-.5:I,H=j<=T&&f.has(j)?Math.round(O(f,j)+O(p,j))-.5:D;e.rect(ie,G,ee-ie,H-G)}e.fillStyle=u.selectionColor,e.fill(),e.save(),e.clip(),e.strokeStyle=u.selectionOutlineCasingColor,e.lineWidth=3,e.stroke(),e.restore(),e.strokeStyle=u.selectionOutlineColor,e.lineWidth=1,e.stroke()}L&&s!=null&&o!=null&&(e.restore(),this.drawActiveCell(e,t,s,o))}drawActiveCell(e,t,n,s,o=nn.ACTIVE_CELL_BORDER_WIDTH){const{metrics:i,theme:r}=t,{allColumnWidths:l,allColumnXs:a,allRowHeights:c,allRowYs:d}=i,u=O(a,n),h=O(d,s),g=O(l,n),p=O(c,s);let f=u-o*.5,C=h-o*.5,w=g+o,S=p+o;f<=0&&(w+=f-1,f=1),C<=0&&(S+=C-1,C=1);const{lineWidth:b}=e;e.beginPath(),e.lineWidth=o,e.strokeStyle=r.selectionOutlineColor,this.drawRoundedRect(e,f,C,w,S),e.stroke(),e.lineWidth=b}drawRoundedRect(e,t,n,s,o,i=nn.DEFAULT_EDGE_RADIUS){e.beginPath(),e.moveTo(t+i,n),e.lineTo(t+s-i,n),e.quadraticCurveTo(t+s,n,t+s,n+i),e.lineTo(t+s,n+o-i),e.quadraticCurveTo(t+s,n+o,t+s-i,n+o),e.lineTo(t+i,n+o),e.quadraticCurveTo(t,n+o,t,n+o-i),e.lineTo(t,n+i),e.quadraticCurveTo(t,n,t+i,n),e.closePath()}drawDraggingColumn(e,t){var H;const{draggingColumn:n,metrics:s,mouseX:o,theme:i,model:r}=t;if(n==null||o==null)return;const{range:l,depth:a}=n,{gridX:c,gridY:d,allColumnXs:u,allColumnWidths:h,height:g,width:p,columnHeaderMaxDepth:f,columnHeaderHeight:C,movedColumns:w,modelColumns:S,floatingLeftWidth:b}=s,v=(H=S.get(l[0]))!=null?H:_.getModelIndex(l[0],w),T=r.getColumnHeaderGroup(v,a);if(a>0&&!T)return;const[R,D]=l,A=O(u,R),L=O(u,D)+O(h,D)-A,k=n.left,{backgroundColor:x,font:W,headerFont:V,reorderOffset:Y,shadowBlur:j,shadowColor:ie}=i,G=(f-a-1)*C;e.save(),e.translate(c,0),e.save(),e.beginPath(),e.rect(b,0,p,g),e.clip(),e.fillStyle=x,e.fillRect(A,G,L,g),e.restore(),e.translate(0,Y),e.save(),e.shadowColor=ie,e.shadowBlur=j,e.fillStyle=x,e.fillRect(n.left,G+Y,n.width,g),e.restore(),e.beginPath(),e.rect(n.left,G,n.width+1,g),e.clip(),e.translate(k-A,0),e.font=V;const ee=[];for(let $=n.range[0];$<=n.range[1];$+=1)ee.push($);this.drawColumnHeaders(e,t),this.drawColumnHeadersForRange(e,t,[ee[0],ee[ee.length-1]],{minX:A,maxX:p}),e.translate(0,d),e.font=W,this.drawGridBackground(e,t);for(let $=R;$<=D;$+=1)this.drawColumnCellContents(e,t,$);e.restore()}drawDraggingRow(e,t){const{draggingRow:n,draggingRowOffset:s,metrics:o,mouseY:i,theme:r}=t;if(n==null||i==null)return;const{gridX:l,gridY:a,allRowYs:c,allRowHeights:d,width:u}=o,h=O(c,n),g=O(d,n)+1,{backgroundColor:p,font:f,headerFont:C,reorderOffset:w,shadowBlur:S,shadowColor:b}=r;e.save(),e.translate(0,a),e.fillStyle=p,e.fillRect(0,h,u,g),e.translate(l+w,i-h-a-(s!=null?s:0)),e.save(),e.shadowColor=b,e.shadowBlur=S,e.fillStyle=p,e.fillRect(-l,h,u,g),e.restore(),e.beginPath(),e.rect(-l,h,u,g),e.clip(),e.font=f,this.drawGridBackground(e,t),this.drawCellContents(e,t),e.translate(-l,-a),e.font=C,this.drawRowHeaders(e,t),e.restore()}drawScrollBars(e,t){const{isDraggingHorizontalScrollBar:n,isDraggingVerticalScrollBar:s,isDragging:o,metrics:i,mouseX:r,mouseY:l,theme:a}=t;if(a.scrollBarSize<=0)return;const{width:c,height:d,handleHeight:u,handleWidth:h,scrollX:g,scrollY:p,hasHorizontalBar:f,hasVerticalBar:C,barWidth:w,barHeight:S,barLeft:b,barTop:v}=i,{scrollBarBackgroundColor:T,scrollBarHoverBackgroundColor:R,scrollBarCasingColor:D,scrollBarCornerColor:A,scrollBarColor:I,scrollBarHoverColor:L,scrollBarActiveColor:k,scrollBarSize:x,scrollBarHoverSize:W,scrollBarCasingWidth:V,scrollBarSelectionTick:Y,scrollBarSelectionTickColor:j,scrollBarActiveSelectionTickColor:ie,autoSelectRow:G,autoSelectColumn:ee}=a,H=r!=null&&l!=null&&r<=c&&l<=d,$=s||C&&!n&&!o&&r!=null&&l!=null&&r>=c-W&&l>=v&&H,se=n||f&&!s&&!o&&!$&&r!=null&&l!=null&&l>=d-W&&r>=b&&H,ne=se?W:x,he=$?W:x;if(e.translate(b,v),f&&C&&(e.fillStyle=D,e.fillRect(c-b-x,d-v-x,x,x),e.fillStyle=A,e.fillRect(c-b-x+V,d-v-x+V,x-V,x-V)),f){const ve=g,Ie=d-v-ne;if(e.fillStyle=D,e.fillRect(0,Ie,w,ne-V),e.fillStyle=se?R:T,e.fillRect(0,Ie+V,w,ne-V),n?e.fillStyle=k:se?e.fillStyle=L:e.fillStyle=I,e.fillRect(ve,Ie+V,h,ne-V),!G&&Y&&j!=null&&ie!=null){e.fillStyle=j;const{selectedRanges:Ge,cursorColumn:me}=t,{lastLeft:ke,columnCount:Ot}=i,hn=[...Ge].filter(ge=>ge.startColumn!=null&&ge.endColumn!=null).map(ge=>[ge.startColumn,ge.endColumn]).sort(_.compareRanges),xt=_.mergeSortedRanges(hn),rt=ge=>ge<=ke?ge/ke*(w-h):w-h+(ge-ke)/(Ot-ke)*h;for(let ge=0;ge<xt.length;ge+=1){const Ee=xt[ge],Ye=Ee[0],lt=Ee[1];if(Ye!=null&&lt!=null&&(Ye!==me||lt!==me)){const wt=rt(Ye),mn=Math.max(1,Math.round(rt(lt+1)-wt)),kt=ne-V;e.fillRect(wt,Ie+V+Math.round(kt/3),mn,Math.round(kt/3))}}if(me!=null){const ge=rt(me),Ee=2,Ye=ne-V;e.fillStyle=ie,e.fillRect(ge,Ie+V,Ee,Ye)}}}if(C){const ve=c-b-he,Ie=p;if(e.fillStyle=D,e.fillRect(ve,0,he-V,S),e.fillStyle=$?R:T,e.fillRect(ve+V,0,he-V,S),s?e.fillStyle=k:$?e.fillStyle=L:e.fillStyle=I,e.fillRect(ve+V,Ie,he-V,u),!ee&&Y&&j!=null&&ie!=null){const{selectedRanges:Ge,cursorRow:me}=t,{lastTop:ke,rowCount:Ot}=i,Ct=ge=>ge<=ke?ge/ke*(S-u):S-u+(ge-ke)/(Ot-ke)*u;e.fillStyle=j;const xt=[...Ge].filter(ge=>ge.startRow!=null&&ge.endRow!=null).map(ge=>[ge.startRow,ge.endRow]).sort(_.compareRanges),rt=_.mergeSortedRanges(xt);for(let ge=0;ge<rt.length;ge+=1){const Ee=rt[ge],Ye=Ee[0],lt=Ee[1];if(Ye!=null&&lt!=null&&(Ye!==me||lt!==me)){const wt=Ct(Ye),mn=he-V,kt=Math.max(1,Math.round(Ct(lt+1)-wt));e.fillRect(ve+V+Math.round(mn/3),wt,Math.round(mn/3),kt)}}if(me!=null){const ge=Math.round(Ct(me)),Ee=he-V,Ye=2;e.fillStyle=ie,e.fillRect(ve+V,ge,Ee,Ye)}}}e.translate(-b,-v)}};let ts=nn;ts.DEFAULT_FONT_WIDTH=10;ts.DEFAULT_EDGE_RADIUS=2;ts.ACTIVE_CELL_BORDER_WIDTH=2;const Ir=100;class id extends Ke{constructor(){super(...arguments),this.hasExtendedFloating=!1}onDown(t,n,s){const{x:o,y:i,column:r,row:l}=t,{metrics:a}=n;if(!a)throw new Error("metrics not set");const{gridX:c,gridY:d,maxX:u,maxY:h}=a,g=o-c,p=i-d;if(g<0||p<0||r==null&&g>u||l==null&&p>h)return!1;const f=_.isModifierKeyDown(s),C=s.shiftKey;f||(C?n.trimSelectedRanges():n.clearSelectedRanges());const w=n.getTheme(),{autoSelectRow:S,autoSelectColumn:b}=w;return(r!==null||!b)&&(l!==null||!S)&&(n.focus(),n.moveCursorToPosition(r,l,C,!1,C&&f)),this.startPoint=t,this.hasExtendedFloating=!1,this.dragBounds=_.getScrollDragBounds(a,l,r),!0}onDrag(t,n){if(this.startPoint===void 0)return!1;this.stopTimer();const{row:s,column:o}=this.startPoint,{x:i,y:r}=t;let{row:l,column:a}=t;const{metrics:c}=n;if(!c)throw new Error("metrics not set");const{left:d,lastLeft:u,top:h,lastTop:g,columnWidth:p,rowHeight:f}=c,C=_.getScrollDragBounds(c,s,o);let w=0,S=0;if(d<u&&(i<C.x1?w=i-C.x1:i>C.x2&&(w=i-C.x2)),h<g&&(r<C.y1?S=r-C.y1:r>C.y2&&(S=r-C.y2)),w!==0||S!==0)this.startTimer(n,t,w>0?Math.ceil(w/p):Math.floor(w/p),S>0?Math.ceil(S/f):Math.floor(S/f));else if(l!=null&&a!=null){const{floatingTopRowCount:b,floatingBottomRowCount:v,floatingLeftColumnCount:T,floatingRightColumnCount:R,columnCount:D,rowCount:A,bottom:I,right:L,topVisible:k,bottomVisible:x,leftVisible:W,rightVisible:V}=c;this.hasExtendedFloating||(s!==null&&s<b&&l>=b?(l=b,this.hasExtendedFloating=!0):s!==null&&s>=A-v&&l<A-v&&(l=A-v-1,this.hasExtendedFloating=!0),o!==null&&o<T&&a>=T?(a=T,this.hasExtendedFloating=!0):o!==null&&o>=D-R&&a<D-R&&(a=D-R-1,this.hasExtendedFloating=!0)),s!==null&&!_.isFloatingRow(s,c)&&_.isFloatingRow(l,c)&&(s>l&&l<h?l=k-1:s<l&&l>I&&(l=x+1)),o!==null&&!_.isFloatingColumn(o,c)&&_.isFloatingColumn(a,c)&&(o>a&&a<d?a=W-1:o<a&&a>L&&(a=V+1)),n.moveCursorToPosition(a,l,!0,!0)}return!0}onUp(t,n){return this.startPoint!==void 0&&(this.startPoint=void 0,this.dragBounds=void 0,this.stopTimer(),n.commitSelection()),!1}moveSelection(t,n,s,o){const{row:i,column:r}=n,{metrics:l}=t;if(!l)throw new Error("metrics not set");const{selectionEndRow:a,selectionEndColumn:c}=t.state;if(a==null||c==null)throw new Error("selection not set");const{rowCount:d,columnCount:u}=l,h=s<0&&r!=null?r:0,g=s>0&&r!=null?r:u-1,p=o<0&&i!=null?i:0,f=o>0&&i!=null?i:d-1;t.moveCursorToPosition(Math.min(Math.max(h,c+s),g),Math.min(Math.max(p,a+o),f),!0),this.lastTriggerTime=Date.now()}startTimer(t,n,s,o){this.stopTimer();const i=this.lastTriggerTime!=null?Ir-Math.min(Ir,Date.now()-this.lastTriggerTime):0;this.timer=setTimeout(()=>{this.moveSelection(t,n,s,o),this.startTimer(t,n,s,o)},i)}stopTimer(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0)}}const Nr=5,rd=1e3/60,yo=10;function Sn(e,t,n,s){var b,v,T,R,D,A,I;const{modelColumns:o,movedColumns:i,allColumnXs:r,columnCount:l,allColumnWidths:a,userColumnWidths:c,calculatedColumnWidths:d,floatingLeftWidth:u,maxX:h}=n;if(t==null||e==null||e>l||e<0)return null;const g=(b=o.get(e))!=null?b:_.getModelIndex(e,i),p=s.getColumnHeaderGroup(g,t),f=p!=null;let C,w,S;if(p!=null){const[L,k]=p.getVisibleRange(i);C=(v=r.get(L))!=null?v:u,w=((T=r.get(k))!=null?T:h)+((R=a.get(k))!=null?R:0),S=[L,k]}else{const L=r.get(e);if(L==null)return null;C=L,w=C+((I=(A=(D=a.get(e))!=null?D:c.get(g))!=null?A:d.get(g))!=null?I:0),S=[e,e]}return{visibleIndex:e,modelIndex:g,left:C,right:w,width:w-C,isColumnGroup:f,range:S,depth:t}}class ld extends Ke{constructor(){super(...arguments),this.cursor=null,this.draggingColumn=null}setScrollInterval(t,n){this.scrollingInterval!=null&&n===this.scrollingDirection||(this.scrollingDirection=n,this.scrollingInterval=window.setInterval(()=>{var f,C;const{metrics:s}=t;if(!s)return;const{left:o,lastLeft:i,leftOffset:r,userColumnWidths:l,calculatedColumnWidths:a,movedColumns:c,allColumnWidths:d}=s;let u=o,h=r;if(n==="left")for(h-=yo;h<0;){u-=1;const w=_.getModelIndex(o-1,c),S=(f=l.get(w))!=null?f:a.get(w);S===void 0?h=0:h+=S,u<0&&(h=0,u=0)}else{h+=yo;let w=d.get(o);for(;w!==void 0&&h>w;){u+=1,h-=w;const S=_.getModelIndex(o+1,c);w=(C=l.get(S))!=null?C:a.get(S),u>i&&(h=0,u=i)}}const{mouseX:g,mouseY:p}=t.state;s==null||g==null||p==null||(this.moveDraggingColumn(g,t,n==="left"?-yo:yo),t.setState({left:u,leftOffset:h}),(n==="left"&&u===0&&r===0||n==="right"&&u===i)&&this.clearScrollInterval())},rd))}clearScrollInterval(){this.scrollingDirection=void 0,window.clearInterval(this.scrollingInterval),this.scrollingInterval=void 0}onLeave(){return this.clearScrollInterval(),!1}onDown(t,n){const{model:s}=n.props,{x:o,column:i,columnHeaderDepth:r}=t,{metrics:l}=n;if(!l)throw new Error("Metrics not set");const a=Sn(i,r,l,s);if(i==null||a==null||r==null||r>0&&!a.isColumnGroup)return!1;const{rowHeaderWidth:c}=l;return this.initialGridPoint=t,this.draggingColumn=null,this.cursor=null,a.modelIndex!=null&&r!=null&&s.isColumnMovable(a.modelIndex,r)&&(this.draggingOffset=o-a.left-c,this.initialOffset=this.draggingOffset),!1}onDrag(t,n,s){if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0)return!1;const{x:o,y:i}=t,{columnHeaderDepth:r}=this.initialGridPoint,{model:l}=n.props;let{draggingColumn:a}=this;const{metrics:c}=n;if(!c)throw new Error("Metrics not set");if(!a&&Math.abs(this.initialGridPoint.x-o)<Nr&&Math.abs(this.initialGridPoint.y-i)<Nr)return!1;if(a==null){const d=Sn(this.initialGridPoint.column,r,c,l);if(!d||r==null||!l.isColumnMovable(d.modelIndex)||r>0&&!d.isColumnGroup||d.range[0]==null)return!1;a={range:d.range,depth:r,left:d.left,width:d.width};const u=Sn(a.range[0],0,c,l),h=Sn(a.range[1],0,c,l);if(!u||!h)return!1;this.draggingColumn=a,n.setState({draggingColumn:a,isDragging:!0})}return this.cursor="move",this.moveDraggingColumn(t.x,n,s.movementX),!0}moveDraggingColumn(t,n,s){var D,A,I,L,k;if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0||this.draggingColumn==null||s===0)return;if(this.initialOffset!==this.draggingOffset){this.draggingOffset<this.initialOffset&&this.initialOffset<this.draggingOffset+s||this.draggingOffset>this.initialOffset&&this.initialOffset>this.draggingOffset+s?this.draggingOffset=this.initialOffset:this.draggingOffset+=s,this.draggingColumn={...this.draggingColumn,left:t-this.draggingOffset},n.setState({draggingColumn:this.draggingColumn});return}const{depth:o}=this.draggingColumn,{model:i}=n.props,{movedColumns:r}=n.state,{metrics:l}=n;if(!l)throw new Error("Metrics not set");const{floatingLeftWidth:a,width:c,columnHeaderMaxDepth:d,allColumnXs:u}=l,h=s<0,g=Sn(this.draggingColumn.range[0],o,l,i);if(!g)return;const p=t-this.draggingOffset,f=p+g.width;this.draggingColumn={...this.draggingColumn,left:p},n.setState({draggingColumn:this.draggingColumn});const C=Sn(_.getColumnAtX($e(h?p:f,a,c),l,!0),o,l,i),w=i.getColumnHeaderParentGroup(g.modelIndex,g.depth);if(!C)return;if(w!==void 0){const x=w.getVisibleRange(r);if(C.visibleIndex<x[0]){const W=this.moveColumn(g,x[0],r);this.draggingOffset=t-((D=u.get(x[0]))!=null?D:0),this.draggingColumn={...this.draggingColumn,left:t-this.draggingOffset},this.clearScrollInterval(),n.setState({draggingColumn:this.draggingColumn,movedColumns:W});return}if(C.visibleIndex>x[1]){const W=this.moveColumn(g,x[1]-(g.range[1]-g.range[0]),r),{right:V=0}=(A=Sn(x[1],0,l,i))!=null?A:{};this.draggingOffset=t-(V-g.width),this.draggingColumn={...this.draggingColumn,left:t-this.draggingOffset},this.clearScrollInterval(),n.setState({draggingColumn:this.draggingColumn,movedColumns:W});return}}if(!i.isColumnMovable(C.modelIndex)){let x=C.visibleIndex;if(h)for(x+=1;x<g.visibleIndex&&!i.isColumnMovable(_.getModelIndex(x,r));)x+=1;else for(x-=1;x>g.visibleIndex&&!i.isColumnMovable(_.getModelIndex(x,r));)x-=1;if(x!==g.visibleIndex){h||(x-=g.range[1]-g.range[0]);const V=this.moveColumn(g,x,r);n.setState({movedColumns:V,draggingColumn:this.draggingColumn})}const W=Sn(x,0,l,i);h?this.draggingOffset=t-((I=W==null?void 0:W.left)!=null?I:0):this.draggingOffset=t-(((L=W==null?void 0:W.right)!=null?L:0)-g.width),this.draggingColumn={...this.draggingColumn,left:t-this.draggingOffset},n.setState({draggingColumn:this.draggingColumn});return}if(p<=a?this.setScrollInterval(n,"left"):f>c?this.setScrollInterval(n,"right"):this.clearScrollInterval(),C.visibleIndex===g.visibleIndex||h&&g.visibleIndex<C.visibleIndex||!h&&g.visibleIndex>C.visibleIndex)return;const S=C.left+C.width*.5,b=i.getColumnHeaderParentGroup(g.modelIndex,g.depth);let v,T=((k=b==null?void 0:b.depth)!=null?k:d)-1;for(;T>=0&&v===void 0;)v=i.getColumnHeaderGroup(C.modelIndex,T),T-=1;let R;h&&p<S&&(!v||C.visibleIndex===v.getVisibleRange(r)[0])&&(R=this.moveColumn(g,C.range[0],r)),!h&&f>S&&(!v||C.visibleIndex===v.getVisibleRange(r)[1])&&(R=this.moveColumn(g,C.range[1]-(g.range[1]-g.range[0]),r)),R&&(this.draggingColumn={...this.draggingColumn,left:p},n.setState({movedColumns:R,draggingColumn:this.draggingColumn}))}moveColumn(t,n,s){const o=t.isColumnGroup?_.moveRange(t.range,n,s):_.moveItem(t.visibleIndex,n,s),i=n-t.range[0],r=[t.range[0]+i,t.range[1]+i];return this.draggingColumn&&(this.draggingColumn={...this.draggingColumn,range:r}),o}onUp(t,n){return this.cursor=null,this.clearScrollInterval(),this.draggingOffset!=null?(this.draggingOffset=void 0,n.setState({draggingColumn:null,isDragging:!1}),!0):!1}}class qi extends Ke{constructor(){super(...arguments),this.cursor="default"}static getLeftWithOffsetFromRawLeft(t,n){const s=t.getTheme(),{metrics:o,metricCalculator:i}=t;if(!o)throw new Error("metrics not set");if(s.scrollSnapToColumn)return{left:Math.round(n),leftOffset:0};const r=Math.floor(n),l=n-r;let a=o.allColumnWidths.get(r);if(a==null){const d=t.getMetricState();a=i.getVisibleColumnWidth(r,d)}const c=a*l;return{left:r,leftOffset:c}}isInScrollBar(t,n){const s=n.getTheme(),{scrollBarSize:o,scrollBarHoverSize:i}=s,{metrics:r}=n;if(!r)throw new Error("metrics not set");const{x:l,y:a}=t,{barLeft:c,barWidth:d,height:u,hasHorizontalBar:h}=r;return h&&o>0&&a>=u-i&&a<u&&l>c&&l<c+d}getLeftWithOffset(t,n){var f;const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{x:o}=t,{barWidth:i,handleWidth:r,lastLeft:l,barLeft:a,columnCount:c,scrollableContentWidth:d,scrollableViewportWidth:u}=s,h=o-a,g=$e((h-((f=this.dragOffset)!=null?f:0))/(i-r),0,1);if(c===1)return{left:0,leftOffset:g*(d-u)};const p=g*l;return qi.getLeftWithOffsetFromRawLeft(n,p)}onDown(t,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{x:o}=t,{handleWidth:i,barLeft:r,scrollX:l}=s;if(!this.isInScrollBar(t,n))return!1;const a=o-r;if(a>=l&&a<=l+i)this.dragOffset=a-l,n.setState({isDraggingHorizontalScrollBar:!0});else{this.dragOffset=0;const{left:c,leftOffset:d}=this.getLeftWithOffset(t,n);n.setViewState({left:c,leftOffset:d,isDraggingHorizontalScrollBar:!0,isDragging:!0})}return!0}onDrag(t,n){if(this.dragOffset!=null){const{left:s,leftOffset:o}=this.getLeftWithOffset(t,n);return n.setViewState({left:s,leftOffset:o,isDraggingHorizontalScrollBar:!0,isDragging:!0}),!0}return!1}onMove(t,n){return this.isInScrollBar(t,n)}onUp(t,n){return this.dragOffset!==void 0&&(this.dragOffset=void 0,n.setState({isDraggingHorizontalScrollBar:!1,isDragging:!1})),this.isInScrollBar(t,n)}onClick(t,n){return this.isInScrollBar(t,n)}}class ad extends Ke{constructor(){super(...arguments),this.cursor="move"}onDown(t,n){const{model:s}=n.props,{x:o,y:i,row:r}=t,{metrics:l}=n;if(!l)throw new Error("metrics not set");const{columnHeaderHeight:a,rowHeaderWidth:c,allRowYs:d}=l;if(o<=c&&r!==null&&s.isRowMovable(r)){const u=O(d,r);this.draggingOffset=i-u-a,n.setState({draggingRowOffset:this.draggingOffset})}return!1}onDrag(t,n){if(this.draggingOffset==null)return!1;const{model:s}=n.props;let{draggingRow:o}=n.state;const{mouseX:i,mouseY:r}=n.state;if(i==null||r==null)return!1;if(o==null){const{row:R}=n.getGridPointFromXY(i,r);if(R!=null&&!s.isRowMovable(R)||(o=R,n.setState({draggingRow:o,isDragging:!0}),o==null))return!1}const{metrics:l}=n;if(!l)throw new Error("metrics not set");const{top:a,lastTop:c,bottom:d,bottomVisible:u,rowCount:h,columnHeaderHeight:g,allRowHeights:p,allRowYs:f,height:C}=l;let w=g;if(a<o){const R=o-1;w=O(f,R)+O(p,R)*.5+g}let S=C;if(o<d){const R=o+1;S=O(f,R)+O(p,R)*.5+g}let{movedRows:b}=n.state;r<w&&o>0&&s.isRowMovable(o-1)?(b=_.moveItem(o,o-1,b),o-=1):S<r&&o<h-1&&s.isRowMovable(o+1)&&(b=_.moveItem(o,o+1,b),o+=1),n.setState({movedRows:b,draggingRow:o});const v=g+O(p,a)*.5,T=g+O(f,u)+O(p,u)*.5;return r<v&&a>0?n.setState({top:a-1}):r>T&&a<c&&n.setState({top:a+1}),!0}onUp(t,n){return this.draggingOffset!==void 0?(this.draggingOffset=void 0,n.setState({draggingRowOffset:null,draggingRow:null,isDragging:!1}),!0):!1}}class Yi extends Sl{constructor(){super(...arguments),this.hiddenCursor="s-resize",this.defaultCursor="row-resize",this.pointProperty="y",this.userSizesProperty="userRowHeights",this.visibleOffsetProperty="visibleRowYs",this.visibleSizesProperty="visibleRowHeights",this.marginProperty="columnHeaderHeight",this.calculatedSizesProperty="calculatedRowHeights",this.initialSizesProperty="initialRowHeights",this.modelIndexesProperty="modelRows",this.firstIndexProperty="firstRow",this.treePaddingProperty="treePaddingY",this.getHiddenItems=_.getHiddenRows,this.getNextShownItem=_.getNextShownRow,this.getSeparator=Yi.getRowSeparator}static getRowSeparator(t,n,s,o){if(!o.allowRowResize)return null;const{x:i,y:r}=t,l=_.getRowSeparatorIndex(i,r,n,o);return l!=null?{index:l,depth:0}:null}setSize(t,n,s){t.setRowHeight(n,s)}resetSize(t,n){t.resetRowHeight(n)}updateSeparator(t,n){t.setState({draggingRowSeparator:n,isDragging:n!==null})}}class bs extends Ke{static isInTreeBox(t,n){const{column:s,row:o,x:i,y:r}=t,{metrics:l}=n;if(!l)throw new Error("metrics not set");const{gridX:a,gridY:c,firstColumn:d,allColumnXs:u,allColumnWidths:h,allRowHeights:g,allRowYs:p,visibleRowTreeBoxes:f}=l;if(s===d&&o!=null&&f.get(o)!=null&&i>a&&r>c){const C=O(u,s),w=O(h,s),S=O(p,o),b=O(g,o);if(i>=a+C&&i<=a+C+w&&r>=c+S&&r<=c+S+b)return!0}return!1}onDown(t,n){return bs.isInTreeBox(t,n)}onClick(t,n,s){if(bs.isInTreeBox(t,n)){const{row:o}=t;if(o!==null)return n.toggleRowExpanded(o,_.isModifierKeyDown(s)),!0}return!1}}class cd extends Ke{isInCorner(t,n){const s=n.getTheme(),{scrollBarSize:o}=s,{metrics:i}=n;if(!i)throw new Error("metrics not set");const{x:r,y:l}=t,{width:a,height:c,hasVerticalBar:d,hasHorizontalBar:u}=i;return o>0&&d&&u&&r>=a-o&&l>=c-o&&r<=a&&l<=c}onDown(t,n){return this.isInCorner(t,n)}onUp(t,n){return this.isInCorner(t,n)}onClick(t,n){return this.isInCorner(t,n)}}class Xi extends Ke{constructor(){super(...arguments),this.cursor="default"}static getTopWithOffsetFromRawTop(t,n){const s=t.getTheme(),{metrics:o,metricCalculator:i}=t;if(!o)throw new Error("metrics not set");if(s.scrollSnapToRow)return{top:Math.round(n),topOffset:0};const r=Math.floor(n),l=n-r;let a=o.allRowHeights.get(r);if(a==null){const d=t.getMetricState();a=i.getVisibleRowHeight(r,d)}const c=a*l;return{top:r,topOffset:c}}isInScrollBar(t,n){const s=n.getTheme(),{scrollBarSize:o,scrollBarHoverSize:i}=s,{metrics:r}=n;if(!r)throw new Error("metrics not set");const{x:l,y:a}=t,{barTop:c,barHeight:d,width:u,hasVerticalBar:h}=r;return h&&o>0&&l>=u-i&&l<u&&a>c&&a<c+d}getTopWithOffset(t,n){var f;const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{y:o}=t,{barHeight:i,handleHeight:r,lastTop:l,barTop:a,rowCount:c,scrollableContentHeight:d,scrollableViewportHeight:u}=s,h=o-a,g=$e((h-((f=this.dragOffset)!=null?f:0))/(i-r),0,1);if(c===1)return{top:0,topOffset:g*(d-u)};const p=g*l;return Xi.getTopWithOffsetFromRawTop(n,p)}onDown(t,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{y:o}=t,{handleHeight:i,barTop:r,scrollY:l}=s;if(!this.isInScrollBar(t,n))return!1;const a=o-r;if(a>=l&&a<=l+i)this.dragOffset=a-l,n.setState({isDraggingVerticalScrollBar:!0});else{this.dragOffset=0;const{top:c,topOffset:d}=this.getTopWithOffset(t,n);n.setViewState({top:c,topOffset:d,isDraggingVerticalScrollBar:!0,isDragging:!0})}return!0}onMove(t,n){return this.isInScrollBar(t,n)}onDrag(t,n){if(this.dragOffset!=null){const{top:s,topOffset:o}=this.getTopWithOffset(t,n);return n.setViewState({top:s,topOffset:o,isDraggingVerticalScrollBar:!0,isDragging:!0}),!0}return!1}onUp(t,n){return this.dragOffset!==void 0&&(this.dragOffset=void 0,n.setState({isDraggingVerticalScrollBar:!1,isDragging:!1})),this.isInScrollBar(t,n)}onClick(t,n){return this.isInScrollBar(t,n)}}class dd extends Ke{onDoubleClick({column:t,row:n},s){const{model:o}=s.props;return Pe(o)&&t!=null&&n!=null&&o.isEditableRange(K.makeCell(t,n))?(s.startEditing(t,n),!0):!1}}class ss{constructor(t=5e3){this.order=t}onDown(t,n){return!1}}class ud extends ss{onDown(t,n){switch(t.key){case"a":if(_.isModifierKeyDown(t))return n.selectAll(),!0;break;case"ArrowUp":return this.handleArrowMove(0,-1,t,n);case"ArrowDown":return this.handleArrowMove(0,1,t,n);case"ArrowRight":return this.handleArrowMove(1,0,t,n);case"ArrowLeft":return this.handleArrowMove(-1,0,t,n);case"k":case"K":return _.isModifierKeyDown(t)?!1:this.handlePageUp(t,n);case"j":case"J":return _.isModifierKeyDown(t)?!1:this.handlePageDown(t,n);case"h":case"H":return _.isModifierKeyDown(t)?!1:(t.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(0,n.state.cursorRow,t.shiftKey),!0);case"l":case"L":{if(_.isModifierKeyDown(t))return!1;const{model:s}=n.props,{columnCount:o}=s;return t.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(o-1,n.state.cursorRow,t.shiftKey),!0}case"PageDown":return this.handlePageDown(t,n);case"PageUp":return this.handlePageUp(t,n);case"Home":return t.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(_.isModifierKeyDown(t)?n.state.cursorColumn:0,_.isModifierKeyDown(t)?0:n.state.cursorRow,t.shiftKey,!0,!0),!0;case"End":{const{model:s}=n.props,{columnCount:o,rowCount:i}=s;return t.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(_.isModifierKeyDown(t)?n.state.cursorColumn:o-1,_.isModifierKeyDown(t)?i-1:n.state.cursorRow,t.shiftKey,!0,!0),!0}case"Escape":return n.clearSelectedRanges(),{preventDefault:!1,stopPropagation:!1};case"Enter":if(n.state.selectedRanges.length>0)return n.moveCursorInDirection(t.shiftKey?K.SELECTION_DIRECTION.UP:K.SELECTION_DIRECTION.DOWN),!0;break;case"Tab":if(n.state.selectedRanges.length>0)return n.moveCursorInDirection(t.shiftKey?K.SELECTION_DIRECTION.LEFT:K.SELECTION_DIRECTION.RIGHT),!0;break}return!1}handleArrowMove(t,n,s,o){const i=s.shiftKey,r=_.isModifierKeyDown(s);i?o.trimSelectedRanges():o.clearSelectedRanges();const{cursorRow:l,cursorColumn:a,selectionEndColumn:c,selectionEndRow:d}=o.state,u=i?c:a,h=i?d:l;if(r){const{model:g}=o.props,{columnCount:p,rowCount:f}=g,C=r&&i;let w=null,S=null;t<0?(w=0,S=h):t>0?(w=p-1,S=h):n<0?(w=u,S=0):n>0&&(w=u,S=f-1),w!=null&&S!=null&&o.moveCursorToPosition(w,S,i,!0,C)}else{if(!o.metrics)throw new Error("grid.metrics are not set");const{theme:g}=o.props,{autoSelectRow:p=!1,autoSelectColumn:f=!1}=g;if(p&&t!==0){const{lastLeft:C}=o.metrics;let{left:w}=o.state;w=$e(w+t,0,C),o.moveCursorToPosition(w,l,i,!1),o.setViewState({left:w})}else if(f&&n!==0){const{lastTop:C}=o.metrics;let{top:w}=o.state;w=$e(w+n,0,C),o.moveCursorToPosition(w,a,i,!1),o.setViewState({top:w})}else o.moveCursor(t,n,i)}return!0}handlePageUp(t,n){const s=t.shiftKey;s?n.trimSelectedRanges():n.clearSelectedRanges();const{cursorColumn:o,selectionEndRow:i}=n.state,r=i,l=o;if(r==null)return!1;const a=n.getMetricState(),{metricCalculator:c}=n,{bottomVisible:d,topVisible:u,hasHorizontalBar:h}=c.getMetrics(a);let g=r-(d-u);g-=h?0:1,g=Math.max(g,0);const p=Math.max(g-(r-u),0);return n.moveCursorToPosition(l,g,s,!1),n.setViewState({top:p}),!0}handlePageDown(t,n){const s=t.shiftKey;s?n.trimSelectedRanges():n.clearSelectedRanges();const{selectionEndRow:o,cursorColumn:i}=n.state,r=o,l=i;if(r===null)return!1;const a=n.getMetricState(),{metricCalculator:c}=n,{bottomVisible:d,topVisible:u,hasHorizontalBar:h,rowCount:g,lastTop:p}=c.getMetrics(a),f=g-1;let C=d-u+r;C+=h?0:1,C=Math.min(C,f);const w=Math.min(p,C-(r-u));return n.moveCursorToPosition(l,C,s,!1),n.setViewState({top:w}),!0}}class hd extends ss{onDown(t,n){switch(t.key){case"Enter":case" ":return this.handleExpandKey(t,n)}return!1}handleExpandKey(t,n){const{selectedRanges:s}=n.state;if(s.length===1){const o=s[0];if(o.startRow===o.endRow&&o.startColumn===o.endColumn){if(!n.metrics)throw new Error("grid.metrics not set");const{model:i}=n.props,{startRow:r,startColumn:l}=o;if(r!=null){const a=n.getModelRow(r);if((l===0||l==null)&&Me(i)&&i.isRowExpandable(a))return n.toggleRowExpanded(r),!0}}}return!1}}class md extends ss{onDown(t,n){if(_.isModifierKeyDown(t))return!1;const{model:s}=n.props,{cursorColumn:o,cursorRow:i}=n.state;if(o==null||i==null||!Pe(s)||!s.isEditableRange(K.makeCell(o,i)))return!1;const r=o,l=i;return r==null||l==null?!1:t.key.length===1?(n.startEditing(r,l,!0,[1,1],t.key),!0):t.key==="F2"?(n.startEditing(r,l),!0):t.key==="Backspace"?(n.startEditing(r,l,!0,void 0,""),!0):t.key==="Delete"?(n.setValueForCell(r,l,""),!0):!1}}function gd(e){var s,o;const t=[],n=e.querySelectorAll("tr");for(let i=0;i<n.length;i+=1){const l=n[i].querySelectorAll("td"),a=[];for(let c=0;c<l.length;c+=1){const d=l[c];a.push((o=(s=d.textContent)==null?void 0:s.trim())!=null?o:"")}t.push(a)}return t}function pd(e){const t=[];return e.forEach(n=>{var o;const s=(o=n.textContent)!=null?o:"";s.length>0&&t.push(s.split(/\t|\u00a0\u00a0 \u00a0/))}),t}function fd(e){var s,o;const t=e.querySelector("table");if(t!=null)return gd(t);const n=(o=(s=e.textContent)==null?void 0:s.trim())!=null?o:"";if(n.length>0){const{childNodes:i}=e,r=n.includes(" "),l=n.includes("\xA0\xA0 \xA0");return r&&i.length!==0&&(i.length===1||i.length>1&&(i[0].textContent==null||!i[0].textContent.includes(" ")))?n.split(`
1
+ import{A as F,R as De,C as m,E as Z,T as Ca,F as y,J,D as $t,K as Oe,L as Ln,U as $e,H as Te,V as yi,B,W as Fe,S as wa,I as vt,X as it,Y as zo,O as sl,Q as Oi,Z as mr,_ as Sa,$ as Wt,a0 as Ta,a1 as ba,a2 as Ea,a3 as va,a4 as Fi,a5 as Ra,a6 as ya,a7 as Fa,a8 as gr,a9 as Da,aa as Ia,ab as pr,ac as Na,ad as Aa,ae as Ma,af as Oa,ag as xa,ah as Pn,ai as ka,aj as Di,ak as ol}from"./vendor.ec0ffec4.js";import{P as ze,C as _n,a as La,u as Pa,B as z,v as _a,b as Ha,c as Va,d as Ua,e as Xs,T as We,E as ye,f as il,L as le,g as Qn,h as dn,i as rl,j as rn,k as qo,l as xi,m as ki,n as xo,r as Be,M as ce,K as fe,o as Rt,p as oe,q as jt,G as Li,s as jn,t as Ba,w as Ga,x as Xn,y as ll,z as Wa,A as $a,D as za,F as qa,H as un,S as Ya,I as vs,J as fr,N as al,O as Dt,Q as Pi,R as Zn,U as an,V as _i,W as Hi,X as ko,Y as Vi,Z as Yo,_ as Xa,$ as Ka,a0 as Ks,a1 as Ui,a2 as Qs,a3 as Bi,a4 as Qa,a5 as Lo,a6 as ja,a7 as Gi,a8 as cl,a9 as Za,aa as Ja,ab as ec,ac as tc,ad as nc,ae as sc,af as oc,ag as dl,ah as Cr,ai as ui,aj as ic,ak as rc,al as Ss,am as lc,an as ul,ao as ac,ap as cc,aq as hl,ar as wr,as as dc,at as uc,au as hc,av as mc,aw as gc,ax as ml,ay as pc,az as fc,aA as Sr,aB as Cc,aC as Tr,aD as wc,aE as Sc,aF as Tc,aG as bc,aH as Ec,aI as vc,aJ as Rc,aK as yc,aL as Fc,aM as Dc,aN as Ic,aO as Nc,aP as Ac,aQ as Mc,aR as Oc,aS as xc,aT as kc,aU as Lc,aV as Pc,aW as _c,aX as Hc,aY as Vc,aZ as Uc,a_ as xe}from"./index.4d5ceb76.js";import{e as cn,l as ps,K as Et,a as br,b as Mn}from"./monaco.e84eddf6.js";import{P as Po,b as Bc,h as Gc,p as Wc,o as $c,s as zc,t as qc,c as hi}from"./plotly.ac086d9a.js";import"./helpers.162e09a8.js";class Xo{static isDark(t){const n=document.createElement("div");n.style.display="none",n.style.color=t;const s=getComputedStyle(document.body.appendChild(n)).color,o=s.match(/\d+/g);let i=[];if(o)i=o.map(l=>parseInt(l,10));else throw new Error(`Invalid color received. Got ${s}`);return document.body.removeChild(n),Xo.getBrightness(i)<125}static getBrightness(t){return Math.round((t[0]*299+t[1]*587+t[2]*114)/1e3)}}function Yc(e,t){return e?e.closest(`.${t}`):null}const Xc={getClosestByClassName:Yc};class Ko{constructor(){this.pending=[],this.resolved=[]}add(t,n){const s=ze.makeCancelable(t,n);return this.pending.push(s),s.then(()=>{this.resolve(s)},()=>{this.resolve(s)}),s}remove(t){for(let n=0;n<this.pending.length;n+=1)if(this.pending[n]===t){this.pending.splice(n,1);return}}resolve(t){this.remove(t),this.resolved.push(t)}cancel(){const t=[...this.pending,...this.resolved];for(let n=0;n<t.length;n+=1)t[n].cancel();this.pending=[],this.resolved=[]}}function M(e){if(e==null)throw new Error("Value is null or undefined")}class Wi{static join(t,n="and"){if(t==null||t.length===0)return"";if(t.length===1)return t[0];if(t.length===2)return`${t[0]} ${n} ${t[1]}`;const s=t.slice(0,t.length-1).join(", "),o=t[t.length-1];return`${s}, ${n} ${o}`}static toLower(t,n=!0){if(t==null){if(n)return"";throw new Error("Null string passed in to TextUtils.toLower")}return t.toLowerCase()}static sort(t,n,s=!0){return t<n?s?-1:1:t>n?s?1:-1:0}}class Kc extends Error{constructor(){super(...arguments),this.isInvalid=!0}}class Qc extends F.exports.Component{constructor(t){super(t),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=De.createRef(),this.openMenu=De.createRef(),this.state={actions:null,left:0,top:0}}componentDidMount(){var t;(t=this.container.current)!=null&&t.parentElement&&this.container.current.parentElement.addEventListener("contextmenu",this.handleContextMenu)}componentWillUnmount(){var t;(t=this.container.current)!=null&&t.parentElement&&this.container.current.parentElement.removeEventListener("contextmenu",this.handleContextMenu)}handleContextMenu(t){if(!_n.isContextActionEvent(t)||!this.container.current||t.metaKey||t.ctrlKey)return;const n=_n.getMenuItems(t.contextActions),s=this.container.current.getBoundingClientRect(),o=t.clientY-s.top,i=t.clientX-s.left;if(n.length===0){if(t.target===this.container.current){t.preventDefault(),this.setState({actions:null},()=>{const r=document.elementFromPoint(i,o),l=new MouseEvent("contextmenu",{clientX:t.clientX,clientY:t.clientY,bubbles:!0,cancelable:!0});r==null||r.dispatchEvent(l)});return}return}t.preventDefault(),this.setState({actions:n,top:o,left:i})}handleMenuClose(t){t===this.openMenu.current&&this.setState({actions:null})}render(){let t=null;const{"data-testid":n}=this.props,{actions:s,top:o,left:i}=this.state;return s&&(t=m(La,{ref:this.openMenu,actions:s,onMenuClosed:this.handleMenuClose,top:o,left:i,updatePosition:(r,l)=>{this.setState({top:r,left:l})},"data-testid":n})),m("div",{className:Z("context-menu-root",{active:s}),ref:this.container,children:t})}}function $i(e){const t=F.exports.useRef();return F.exports.useEffect(function(){t.current=e}),t.current}function gl({copy:e,kind:t="ghost",tooltip:n="Copy",className:s,"data-testid":o,children:i}){const[r,l]=Pa();return m(z,{kind:t,className:s,"data-testid":o,icon:r?_a:Ha,tooltip:r?"Copied":n,onClick:()=>{l(typeof e=="function"?e():e)},children:i})}class dt{static reorder(t,n,s,o){const i=t===s?dt.adjustDestinationIndex(o,n):o,r=dt.removeItems(t,n);return s.splice(i,0,...r),r}static removeItems(t,n){const s=[],o=n.map((i,r)=>({range:i,index:r})).sort((i,r)=>r.range[0]-i.range[0]);for(let i=0;i<o.length;i+=1){const{range:r,index:l}=o[i],[a,c]=r;s[l]=t.splice(a,c-a+1)}return Ca(s)}static adjustDestinationIndex(t,n){let s=t;for(let o=0;o<n.length;o+=1){const[i,r]=n[o];if(i>t)break;s-=Math.min(r,t-1)-i+1}return s}static startDragging(){document.documentElement.classList.add("drag-pointer-events-none")}static stopDragging(){document.documentElement.classList.remove("drag-pointer-events-none")}}function pl({on:e,id:t,className:n,isInvalid:s,disabled:o=!1,onClick:i,"data-testid":r}){return m("button",{type:"button",className:Z("btn","btn-switch",n,{active:e},{"is-invalid":s}),id:t,onClick:i,disabled:o,"data-testid":r,children:m("div",{className:"handle"})})}function Er(e){return e.isOn!==void 0}function jc({item:e,onSelect:t=()=>{},"data-testid":n}){const{icon:s,subtitle:o,title:i}=e,r=F.exports.useMemo(()=>Er(e)?()=>{e.onChange(!e.isOn)}:t,[e,t]);return y("div",{className:"btn btn-navigation-menu-item","data-testid":`menu-item-${i}`,onClick:r,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&r()},tabIndex:0,role:"menuitem",children:[s!==void 0&&m("div",{className:"icon",children:m(J,{icon:s})}),m("div",{className:"title",children:i}),o!==void 0&&m("div",{className:"shortcut",children:o}),m("div",{className:"accessory","data-testid":n,children:Er(e)?m(pl,{on:e.isOn,onClick:l=>{l.stopPropagation(),r()}}):m(J,{icon:Va})})]})}function fl({items:e,onSelect:t=()=>{},"data-testid":n}){return m("div",{className:"navigation-menu-view","data-testid":n,children:m("ul",{className:"navigation-menu-list",children:e.map((s,o)=>m("li",{children:m(jc,{item:s,onSelect:()=>{t(o)}})},s.title))})})}function vr({children:e,onBack:t,onClose:n,title:s,"data-testid":o}){return y("div",{className:"navigation-page","data-testid":o,children:[y("div",{className:"navigation-title-bar",children:[m("div",{className:"navigation-left-buttons",children:t!==void 0&&m(z,{kind:"ghost",className:"btn-back","data-testid":"btn-page-back",onClick:t,icon:Ua,children:"Back"})}),m("div",{className:"navigation-title",children:s}),m("div",{className:"navigation-right-buttons",children:n!==void 0&&m(z,{kind:"ghost",className:"btn-close px-2 m-1","data-testid":"btn-page-close",onClick:n,icon:Xs,tooltip:"Close"})})]}),m("div",{className:"navigation-content",children:e})]})}function Zc({children:e,"data-testid":t}){const n=F.exports.useMemo(()=>De.Children.toArray(e),[e]),s=$i(n),[o,i]=F.exports.useState(n[n.length-1]),[r,l]=F.exports.useState(null),[a,c]=F.exports.useState(null);F.exports.useEffect(function(){if(s===void 0||n===s)return;const g=n[n.length-1];n.length===s.length||s.length===0||r!==null||a!==null?r!==null&&g!==r?l(g):g!==a&&g!==o&&i(g):n.length>s.length?l(g):n.length<s.length&&(i(g),c(s[s.length-1]))},[n,s,r,a,o]);const d=F.exports.useCallback(()=>{i(r),l(null)},[r]),u=F.exports.useCallback(()=>{c(null)},[]);return y("div",{className:"navigation-stack",children:[m("div",{className:"main-view","data-testid":t,children:o}),m($t,{in:a!=null,timeout:We.transitionMidMs,classNames:"slide-right",onEntered:u,children:m(Oe,{children:a!=null&&m("div",{className:"popping-view",children:a})})}),m($t,{in:r!=null,timeout:We.transitionMidMs,classNames:"slide-left",onEntered:d,children:m(Oe,{children:r!=null&&m("div",{className:"pushing-view",children:r})})})]})}function Jc({children:e,disabled:t,value:n,"data-testid":s}){return m("option",{value:n,disabled:t,"data-testid":s,children:e})}function zi(e){const{children:t,disabled:n=!1,name:s,onChange:o,value:i="","data-testid":r}=e,[l]=F.exports.useState(s!=null?s:Ln());return m(Oe,{children:De.Children.map(t,a=>{var c,d;return a?De.cloneElement(a,{name:l,onChange:(c=a.props.onChange)!=null?c:o,checked:i===a.props.value,disabled:(d=a.props.disabled)!=null?d:n,"data-testid":r}):null})})}function ed({children:e,onBlur:t,onChange:n,className:s,defaultValue:o,name:i,value:r,disabled:l,"data-testid":a}){const c=F.exports.useCallback(d=>{n(d.target.value)},[n]);return m("select",{className:Z("custom-select",s),onBlur:t,onChange:c,defaultValue:o,value:r,name:i,disabled:l,"data-testid":a,children:e})}class Cl extends Error{constructor(){super(...arguments),this.isAssertionFailed=!0}}function Rr(e){if(e==null)throw new Cl(`Expected 'val' to be defined, but received ${e}`)}class mi extends Error{constructor(){super(...arguments),this.isPasteError=!0}}function Pe(e){return(e==null?void 0:e.isEditable)!==void 0}function yr(e){if(!Pe(e))throw new Cl(`Expected 'model' to be editable, but received ${e}`)}function Me(e){return(e==null?void 0:e.hasExpandableRows)!==void 0}var At=(e=>(e.DOWN="DOWN",e.UP="UP",e.LEFT="LEFT",e.RIGHT="RIGHT",e))(At||{});const de=class{static normalize(e,t,n,s){let o=e,i=t,r=n,l=s;return o!=null&&r!=null&&r<o&&(o=r,r=e),i!=null&&l!=null&&l<i&&(i=l,l=t),[o,i,r,l]}static makeNormalized(e,t,n,s){return new de(...de.normalize(e,t,n,s))}static makeCell(e,t){return new de(e,t,e,t)}static makeColumn(e){return new de(e,null,e,null)}static makeRow(e){return new de(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 o=t[s];for(let i=t.length-1;i>s;i-=1){const r=t[i];if(o.contains(r))t.splice(i,1);else if(r.contains(o)){n=!0,t[s]=r,t.splice(i,1);break}else if(o.startRow===r.startRow&&o.endRow===r.endRow){if(o.touches(r)){const{startRow:l,endRow:a}=o,c=de.minOrNull(o.startColumn,r.startColumn),d=de.maxOrNull(o.endColumn,r.endColumn);n=!0,t[s]=new de(c,l,d,a),t.splice(i,1);break}}else if(o.startColumn===r.startColumn&&o.endColumn===r.endColumn&&o.touches(r)){const{startColumn:l,endColumn:a}=o,c=de.minOrNull(o.startRow,r.startRow),d=de.maxOrNull(o.endRow,r.endRow);n=!0,t[s]=new de(l,c,a,d),t.splice(i,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:o,endRow:i}=e;return n=n!=null&&t.startColumn!=null?Math.max(n,t.startColumn):n!=null?n:t.startColumn,o=o!=null&&t.endColumn!=null?Math.min(o,t.endColumn):o!=null?o:t.endColumn,s=s!=null&&t.startRow!=null?Math.max(s,t.startRow):s!=null?s:t.startRow,i=i!=null&&t.endRow!=null?Math.min(i,t.endRow):i!=null?i:t.endRow,n!=null&&n>(o!=null?o:-1)||s!=null&&s>(i!=null?i:-1)?null:new de(n,s,o,i)}static subtractFromRange(e,t){const n=[],s=de.intersection(e,t);return s==null?[e]:(s.startRow!=null&&(e.startRow==null||e.startRow<s.startRow)&&n.push(new de(e.startColumn,e.startRow,e.endColumn,s.startRow-1)),s.startColumn!=null&&(e.startColumn==null||e.startColumn<s.startColumn)&&n.push(new de(e.startColumn,s.startRow,s.startColumn-1,s.endRow)),s.endColumn!=null&&(e.endColumn==null||e.endColumn>s.endColumn)&&n.push(new de(s.endColumn+1,s.startRow,e.endColumn,s.endRow)),s.endRow!=null&&(e.endRow==null||e.endRow>s.endRow)&&n.push(new de(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(...de.subtractFromRange(e[s],t));return n}static subtractRangesFromRanges(e,t){let n=[...e];for(let s=0;s<t.length;s+=1)n=de.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){var s,o,i,r;return de.isBounded(e)?e:new de((s=e.startColumn)!=null?s:0,(o=e.startRow)!=null?o:0,(i=e.endColumn)!=null?i:t-1,(r=e.endRow)!=null?r:n-1)}static boundedRanges(e,t,n){return e.map(s=>de.boundedRange(s,t,n))}static offset(e,t,n){return new de(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=de.SELECTION_DIRECTION.DOWN){if(e.length===0)return null;let o=-1;if(t!=null&&n!=null&&(o=e.findIndex(i=>i.containsCell(t,n)),o>=0)){const r=e[o].nextCell(t,n,s);if(r!=null)return r}switch(s){case de.SELECTION_DIRECTION.DOWN:case de.SELECTION_DIRECTION.RIGHT:{const i=o<e.length-1?o+1:0;return e[i].startCell(s)}case de.SELECTION_DIRECTION.LEFT:case de.SELECTION_DIRECTION.UP:{const i=o>0?o-1:e.length-1;return e[i].startCell(s)}default:throw new Error(`Invalid direction: ${s}`)}}static cellCount(e){return e.reduce((t,n)=>{var s,o,i,r;return t+(((s=n.endRow)!=null?s:NaN)-((o=n.startRow)!=null?o:NaN)+1)*(((i=n.endColumn)!=null?i:NaN)-((r=n.startColumn)!=null?r:NaN)+1)},0)}static rowCount(e){return e.reduce((t,n)=>{var s,o;return t+((s=n.endRow)!=null?s:NaN)-((o=n.startRow)!=null?o:NaN)+1},0)}static columnCount(e){return e.reduce((t,n)=>{var s,o;return t+((s=n.endColumn)!=null?s:NaN)-((o=n.startColumn)!=null?o: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=de.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 de.isAxisRangeTouching(this.startRow,this.endRow,e.startRow,e.endRow)&&de.isAxisRangeTouching(this.startColumn,this.endColumn,e.startColumn,e.endColumn)}subtract(e){return de.subtractFromRange(this,e)}startCell(e=de.SELECTION_DIRECTION.DOWN){if(!de.isBounded(this))throw new Error("Cannot get the startCell of an unbounded range");switch(e){case de.SELECTION_DIRECTION.DOWN:case de.SELECTION_DIRECTION.RIGHT:return{column:this.startColumn,row:this.startRow};case de.SELECTION_DIRECTION.LEFT:case de.SELECTION_DIRECTION.UP:return{column:this.endColumn,row:this.endRow};default:throw new Error(`Invalid direction: ${e}`)}}nextCell(e,t,n){if(!de.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:o,startRow:i,endRow:r}=this;switch(n){case de.SELECTION_DIRECTION.DOWN:if(t<r)return{column:e,row:Math.max(t+1,i)};if(e<o)return{column:Math.max(e+1,s),row:i};break;case de.SELECTION_DIRECTION.UP:if(t>i)return{column:e,row:Math.min(t-1,r)};if(e>s)return{column:Math.min(e-1,o),row:r};break;case de.SELECTION_DIRECTION.RIGHT:if(e<o)return{column:Math.max(e+1,s),row:t};if(t<r)return{column:s,row:Math.max(t+1,i)};break;case de.SELECTION_DIRECTION.LEFT:if(e>s)return{column:Math.min(e-1,o),row:t};if(t>i)return{column:o,row:Math.min(t-1,r)};break;default:throw new Error(`Invalid direction: ${n}`)}return null}forEach(e,t=de.SELECTION_DIRECTION.RIGHT){var i;let n=0,{column:s,row:o}=this.startCell(t);for(;s!=null&&o!=null;)e(s,o,n),n+=1,{column:s,row:o}=(i=this.nextCell(s,o,t))!=null?i:{}}};let K=de;K.SELECTION_DIRECTION=At;function td(e){return Array.isArray(e)&&e.length===2&&(e[0]===null||typeof e[0]=="number")&&(e[1]===null||typeof e[1]=="number")}function vo(e){return td(e)&&e[0]!=null&&e[1]!=null}const pe=class{static getGridPointFromXY(e,t,n){const s=pe.getColumnAtX(e,n),o=pe.getRowAtY(t,n),i=pe.getColumnHeaderDepthAtY(t,n);return{x:e,y:t,row:o,column:s,columnHeaderDepth:i}}static getCellInfoFromXY(e,t,n){const{row:s,column:o}=pe.getGridPointFromXY(e,t,n),{allColumnWidths:i,allRowHeights:r,allColumnXs:l,allRowYs:a,modelColumns:c,modelRows:d}=n,u=s!==null?d.get(s):null,h=o!==null?c.get(o):null,g=o!==null?l.get(o):null,p=s!==null?a.get(s):null,f=o!==null?i.get(o):null,C=s!==null?r.get(s):null;return{row:s,column:o,modelRow:u!=null?u:null,modelColumn:h!=null?h:null,left:g!=null?g:null,top:p!=null?p:null,columnWidth:f!=null?f:null,rowHeight:C!=null?C:null}}static getColumnHeaderDepthAtY(e,t){const n=pe.getRowAtY(e,t),{columnHeaderHeight:s,columnHeaderMaxDepth:o}=t;if(n===null&&e<=s*o)return $e(o-Math.ceil(e/s),0,o-1)}static iterateFloatingStart(e,t,n){for(let s=0;s<e&&s<t;s+=1){const o=n(s);if(o!==void 0)return o}}static iterateFloatingEnd(e,t,n){for(let s=0;s<e&&t-(e-s)>=0;s+=1){const o=n(t-(e-s));if(o!==void 0)return o}}static iterateFloating(e,t,n,s){const o=pe.iterateFloatingStart(e,n,s);return o!==void 0?o:pe.iterateFloatingEnd(t,n,s)}static iterateAllItems(e,t,n,s,o,i){const r=Math.max(e,n),l=Math.min(t,o-s-1);let a=pe.iterateFloating(n,s,o,i);if(a!==void 0)return a;for(let c=r;c<=l;c+=1)if(a=i(c),a!==void 0)return a}static isInItem(e,t,n,s){var r,l;const o=(r=t.get(e))!=null?r:0,i=(l=n.get(e))!=null?l:0;return o<=s&&s<=o+i}static getItemAtOffset(e,t,n,s,o,i,r,l=!1){const a=l?void 0:pe.iterateFloating(n,s,t,c=>{if(pe.isInItem(c,i,r,e))return c});if(!l&&a!==void 0)return a;for(let c=0;c<o.length;c+=1){const d=o[c];if(pe.isInItem(d,i,r,e))return d}return null}static getColumnAtX(e,t,n=!1){const{columnCount:s,floatingLeftColumnCount:o,floatingRightColumnCount:i,visibleColumns:r,allColumnXs:l,allColumnWidths:a,gridX:c}=t;return e<c?null:this.getItemAtOffset(e-c,s,o,i,r,l,a,n)}static getRowAtY(e,t){const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:o,visibleRows:i,allRowYs:r,allRowHeights:l,gridY:a}=t;return e<a?null:this.getItemAtOffset(e-a,o,n,s,i,r,l)}static getNextShownItem(e,t,n,s){let o=n.findIndex(i=>i===e)||0;for(o-=1;o!=null&&o>=0;){const i=n[o],r=t.get(i);if(r!=null&&s.get(r)!==0)return i;o-=1}return null}static getNextShownColumn(e,t){const{modelColumns:n,visibleColumns:s,userColumnWidths:o}=t;return pe.getNextShownItem(e,n,s,o)}static getNextShownRow(e,t){const{modelRows:n,visibleRows:s,userRowHeights:o}=t;return pe.getNextShownItem(e,n,s,o)}static getColumnSeparatorIndex(e,t,n,s){var w,S,b,v;const{rowHeaderWidth:o,columnHeaderHeight:i,floatingColumns:r,floatingLeftWidth:l,visibleColumns:a,allColumnXs:c,allColumnWidths:d,columnHeaderMaxDepth:u}=n,{allowColumnResize:h,headerSeparatorHandleSize:g}=s;if(u*i<t||!h||g<=0)return null;const p=e-o,f=g*.5;let C=!1;for(let T=r.length-1;T>=0;T-=1){const R=r[T],D=(w=c.get(R))!=null?w:0,A=(S=d.get(R))!=null?S:0,I=A===0;if(!C||!I){let L=D+A;I?L+=f:C&&(L-=f);const k=L-f,x=L+f;if(k<=p&&p<=x)return R;C=I}}C=!1;for(let T=a.length-1;T>=0;T-=1){const R=a[T],D=(b=c.get(R))!=null?b:0,A=(v=d.get(R))!=null?v:0,I=A===0;if(D<l-A)return null;if(!C||!I){let L=D+A;I?L+=f:C&&(L-=f);const k=L-f,x=L+f;if(k<=p&&p<=x)return R;C=I}}return null}static isItemHidden(e,t){return t.get(e)===0}static isColumnHidden(e,t){const{allColumnWidths:n}=t;return pe.isItemHidden(e,n)}static isFloatingRow(e,t){if(e==null)return!1;const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:o}=t;return e<n||e>=o-s}static isFloatingColumn(e,t){if(e==null)return!1;const{floatingLeftColumnCount:n,floatingRightColumnCount:s,columnCount:o}=t;return e<n||e>=o-s}static getHiddenItems(e,t,n){if(!pe.isItemHidden(e,t))return[];const s=[e],o=n.findIndex(i=>i===e);for(let i=o-1;i>=0;i-=1){const r=n[i];if(!pe.isItemHidden(r,t))break;s.push(r)}return s}static getHiddenColumns(e,t){const{visibleColumns:n,allColumnWidths:s}=t;return pe.getHiddenItems(e,s,n)}static getRowSeparatorIndex(e,t,n,s){var p,f;const{rowHeaderWidth:o,columnHeaderHeight:i,visibleRows:r,allRowYs:l,allRowHeights:a}=n,{allowRowResize:c,headerSeparatorHandleSize:d}=s;if(o<e||!c||d<=0)return null;const u=t-i,h=d*.5;let g=!1;for(let C=r.length-1;C>=0;C-=1){const w=r[C],S=(p=l.get(w))!=null?p:0,b=(f=a.get(w))!=null?f:0,v=b===0;if(!g||!v){let T=S+b;v?T+=h:g&&(T-=h);const R=T-h,D=T+h;if(R<=u&&u<=D)return w;g=v}}return null}static isRowHidden(e,t){const{allRowHeights:n}=t;return pe.isItemHidden(e,n)}static getHiddenRows(e,t){const{visibleRows:n,allRowHeights:s}=t;return pe.getHiddenItems(e,s,n)}static moveItem(e,t,n){if(e===t)return[...n];const s=[...n],o=s[s.length-1];return o!=null&&!vo(o.from)&&o.to===e?o.from===t?s.pop():s[s.length-1]={...o,to:t}:s.push({from:e,to:t}),s}static moveRange(e,t,n,s=!1){if(e[0]===e[1])return pe.moveItem(e[0],t,n);let o=t;if(s&&e[0]<t&&(o-=e[1]-e[0]),e[0]===o)return[...n];const i=[...n],r=i[i.length-1];r!=null&&vo(r.from)&&r.from[1]-r.from[0]===e[1]-e[0]&&r.to===e[0]?i[i.length-1]={...r,to:o}:i.push({from:e,to:o});const l=i[i.length-1];return vo(l.from)&&l.from[0]===l.to&&i.pop(),i}static moveItemOrRange(e,t,n,s=!1){return Array.isArray(e)?pe.moveRange(e,t,n,s):pe.moveItem(e,t,n)}static applyItemMoves(e,t,n,s=!1){var i,r;let o=[[e,t]];for(let l=s?n.length-1:0;s?l>=0:l<n.length;s?l-=1:l+=1){const{from:a,to:c}=n[l];let d=1,u;vo(a)?(d=a[1]-a[0]+1,[u]=a):u=a;const h=s?c:u,g=h+d-1,p=s?u:c,f=p-h,C=[];for(let w=0;w<o.length;w+=1){const S=(i=o[w][0])!=null?i:Number.NEGATIVE_INFINITY,b=(r=o[w][1])!=null?r:Number.POSITIVE_INFINITY;let v;const T=[[S,h-1],[h,g],[g+1,b]].map(([R,D])=>[Math.max(R,S),Math.min(D,b)]).filter(([R,D])=>R<=D).map(R=>{const[D,A]=R;return h<=D&&g>=A?(v=[D+f,A+f],v):g<D?[D-d,A-d]:R}).map(R=>{const[D,A]=R;return p>D&&p<=A?[[D,p-1],[p+d,A+d]]:R===v?[R]:p<=D?[[D+d,A+d]]:[R]}).flat();C.push(...T)}o=C.map(([w,S])=>[Number.isFinite(w)?w:null,Number.isFinite(S)?S:null])}return o}static translateRange(e,t,n,s){const o=pe.applyItemMoves(e.startColumn,e.endColumn,t,s),i=pe.applyItemMoves(e.startRow,e.endRow,n,s),r=[];for(let l=0;l<o.length;l+=1){const a=o[l];for(let c=0;c<i.length;c+=1){const d=i[c];r.push(new K(a[0],d[0],a[1],d[1]))}}return r}static getModelIndex(e,t){return pe.applyItemMoves(e,e,t,!0)[0][0]}static getModelIndexes(e,t){return e.map(n=>pe.getModelIndex(n,t))}static getModelRangeIndexes(e,t,n){return pe.applyItemMoves(e,t,n,!0)}static getModelRange(e,t=ye,n=ye){return pe.translateRange(e,t,n,!0)}static getModelRanges(e,t=ye,n=ye){const s=[];for(let o=0;o<e.length;o+=1)s.push(...pe.getModelRange(e[o],t,n));return s}static getVisibleRangeIndexes(e,t,n){return pe.applyItemMoves(e,t,n,!1)}static getVisibleRange(e,t=ye,n=ye){return this.translateRange(e,t,n,!1)}static getVisibleRanges(e,t=ye,n=ye){const s=[];for(let o=0;o<e.length;o+=1)s.push(...pe.getVisibleRange(e[o],t,n));return s}static getVisibleIndex(e,t){return pe.applyItemMoves(e,e,t)[0][0]}static getVisibleIndexes(e,t){return e.map(n=>pe.getVisibleIndex(n,t))}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return pe.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){const t=pe.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:o,width:i,height:r,floatingTopRowCount:l,floatingBottomRowCount:a,floatingLeftColumnCount:c,floatingRightColumnCount:d,floatingLeftWidth:u,floatingRightWidth:h,floatingTopHeight:g,floatingBottomHeight:p,columnCount:f,rowCount:C}=e;let w=s,S=o,b=i,v=r;return n!=null&&(n>c&&(w+=u),n<f-d&&(b-=h)),t!=null&&(t>l&&(S+=g),t<C-a&&(v-=p)),{x1:w,y1:S,x2:b,y2:v}}static getScrollDelta(e,t=1024,n=768,s=20,o=20){let{deltaX:i,deltaY:r}=e;return!pe.isMacPlatform()&&e.shiftKey&&e.deltaX===0&&e.deltaY!==0&&(i=e.deltaY,r=e.deltaX),(e==null?void 0:e.deltaMode)===WheelEvent.DOM_DELTA_PAGE?(i*=t,r*=n):(e==null?void 0:e.deltaMode)===WheelEvent.DOM_DELTA_LINE&&(pe.isMacPlatform()?(i=Math.round(i*s),r=Math.round(r*o)):(i=Math.round(i*this.PIXELS_PER_LINE),r=Math.round(r*this.PIXELS_PER_LINE))),{deltaX:i,deltaY:r}}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],o=s[0],i=s[1];n===0?t.push([o,i]):o-1<=t[t.length-1][1]?t[t.length-1][1]=Math.max(t[t.length-1][1],i):t.push([o,i])}return t}};let _=pe;_.PIXELS_PER_LINE=100/3;function O(e,t,n=void 0){var o;const s=(o=e.get(t))!=null?o:n;if(s!==void 0)return s;throw new Error(`Missing value for key ${t}`)}function Ro(e,t=js.CACHE_SIZE,n=Math.floor(t/2)){if(e.size>t){const s=e.keys();for(;e.size>n;)e.delete(s.next().value)}}function Fr(e,t,n,s,o){const i=new Map;let r=0;for(let l=0;l<e&&l<n;l+=1)i.set(l,r),r+=O(o,l);r=s;for(let l=0;l<t&&n-l-1>=0;l+=1)r-=O(o,n-l-1),i.set(n-l-1,r);return i}const wl=class{constructor({userColumnWidths:e=new Map,userRowHeights:t=new Map,calculatedColumnWidths:n=new Map,calculatedRowHeights:s=new Map,fontWidths:o=new Map,modelRows:i=new Map,modelColumns:r=new Map,movedRows:l=[],movedColumns:a=[],initialRowHeights:c=new Map,initialColumnWidths:d=new Map}={}){this.userColumnWidths=e,this.userRowHeights=t,this.calculatedRowHeights=s,this.calculatedColumnWidths=n,this.fontWidths=o,this.modelRows=i,this.modelColumns=r,this.movedRows=l,this.movedColumns=a,this.initialRowHeights=c,this.initialColumnWidths=d}getMetrics(e){const{left:t,top:n,leftOffset:s,topOffset:o,width:i,height:r,theme:l,model:a,movedRows:c,movedColumns:d,draggingColumn:u}=e,{rowHeight:h,rowHeaderWidth:g,rowFooterWidth:p,columnWidth:f,columnHeaderHeight:C,minScrollHandleSize:w,scrollBarSize:S}=l;c!==this.movedRows&&(this.movedRows=c,this.modelRows.clear()),d!==this.movedColumns&&(this.movedColumns=d,this.modelColumns.clear());const{columnCount:b,rowCount:v,floatingTopRowCount:T,floatingBottomRowCount:R,floatingLeftColumnCount:D,floatingRightColumnCount:A,columnHeaderMaxDepth:I}=a,L=this.getFirstRow(e),k=this.getFirstColumn(e),x=this.getGridX(e),W=this.getGridY(e),V=Me(a)&&a.hasExpandableRows?this.calculateTreePaddingX(e):0,Y=0,j=this.getVisibleRowHeights(e),ie=this.getVisibleColumnWidths(e,k,V),G=Array.from(j.keys()),ee=Array.from(ie.keys()),H=new Map([...j,...this.getFloatingRowHeights(e)]),$=new Map([...ie,...this.getFloatingColumnWidths(e)]),se=this.getVisibleColumnXs($,ee,s),ne=this.getVisibleRowYs(H,G,o),he=G.length>0?G[G.length-1]:n,ve=ee.length>0?ee[ee.length-1]:t,Ie=this.getBottomViewport(e,G,ne,H),Ge=this.getRightViewport(e,ee,se,$),me=this.getFloatingTopHeight(e,H),ke=this.getFloatingBottomHeight(e,H),Ot=this.getFloatingLeftWidth(e,$),Ct=this.getFloatingRightWidth(e,$),hn=Array.from($.values()),xt=Array.from(H.values()),rt=hn.reduce((qe,ls)=>qe+ls,0)-s,ge=xt.reduce((qe,ls)=>qe+ls,0)-o,Ee=s+rt+p,Ye=o+ge,lt=i-x,wt=r-W,mn=this.getLastLeft(e,null,lt-p),kt=this.getLastLeft(e,null,lt-p-S),no=this.getLastTop(e,null,wt-ke),Kt=this.getLastTop(e,null,wt-ke-S);let St=kt,gn=Kt;mn===0&&no===0&&(St=0,gn=0);const os=St>0,Ds=os?S:0,is=gn>0,rs=is?S:0,so=x,oo=I*C,pn=i-so-rs,Hn=r-oo-Ds,si=b===1?pn/Ee:(b-St)/b,io=v===1?Hn/Ye:(v-gn)/v,Is=os?$e(pn*si,w,pn-1):0,Ns=is?$e(Hn*io,w,Hn-1):0,ro=O($,t,0),lo=O(H,n,0),oi=ro>0?s/ro:0,ii=lo>0?o/lo:0,ri=b===1?s/(Ee-lt):(t+oi)/St,Vn=v===1?o/(Ye-wt):(n+ii)/gn,li=os?ri*(pn-Is):0,ao=is?Vn*(Hn-Ns):0,co=[...Array(T).keys(),...[...Array(R).keys()].map(qe=>v-qe-1)],As=new Map([...ne,...this.getFloatingRowYs(e,H,Math.floor(r-W-Ds))]),uo=[...Array(D).keys(),...[...Array(A).keys()].map(qe=>b-qe-1)],fn=new Map([...se,...this.getFloatingColumnXs(e,$,Math.floor(i-x-rs))]),Ms=[];if(u)for(let qe=u.range[0];qe<=u.range[1];qe+=1)Ms.push(qe),$.has(qe)||$.set(qe,this.getVisibleColumnWidth(qe,e)),fn.has(qe)||fn.set(qe,0);const ho=G.concat(co),Os=ee.concat(uo).concat(Ms),xs=this.getModelRows(ho,e),ai=this.getModelColumns(Os,e),mo=this.getVisibleRowTreeBoxes(H,xs,e),go=this.getTopVisible(e,As,H,G),po=this.getLeftVisible(e,fn,$,ee),fo=gn>0?this.getBottomVisible(e,As,H,G,W):he,Co=St>0?this.getRightVisible(e,fn,$,ee,x):ve,{fontWidths:wo,userColumnWidths:ci,userRowHeights:So,calculatedRowHeights:To,calculatedColumnWidths:bo}=this;return{rowHeight:h,rowHeaderWidth:g,rowFooterWidth:p,rowCount:v,columnWidth:f,columnCount:b,columnHeaderHeight:C,floatingTopRowCount:T,floatingBottomRowCount:R,floatingLeftColumnCount:D,floatingRightColumnCount:A,gridX:x,gridY:W,firstRow:L,firstColumn:k,treePaddingX:V,treePaddingY:Y,left:t,top:n,bottom:he,right:ve,topOffset:o,leftOffset:s,topVisible:go,leftVisible:po,bottomVisible:fo,rightVisible:Co,bottomViewport:Ie,rightViewport:Ge,width:i,height:r,maxX:rt,maxY:ge,lastLeft:St,lastTop:gn,barHeight:Hn,barTop:oo,barWidth:pn,barLeft:so,handleHeight:Ns,handleWidth:Is,hasHorizontalBar:os,hasVerticalBar:is,verticalBarWidth:rs,horizontalBarHeight:Ds,scrollX:li,scrollY:ao,scrollableContentWidth:Ee,scrollableContentHeight:Ye,scrollableViewportWidth:lt,scrollableViewportHeight:wt,visibleRows:G,visibleColumns:ee,visibleRowHeights:j,visibleColumnWidths:ie,floatingRows:co,floatingColumns:uo,allRows:ho,allColumns:Os,allRowHeights:H,allColumnWidths:$,floatingTopHeight:me,floatingBottomHeight:ke,floatingLeftWidth:Ot,floatingRightWidth:Ct,visibleRowYs:ne,visibleColumnXs:se,allRowYs:As,allColumnXs:fn,visibleRowTreeBoxes:mo,modelRows:xs,modelColumns:ai,movedRows:c,movedColumns:d,fontWidths:wo,userColumnWidths:ci,userRowHeights:So,calculatedRowHeights:To,calculatedColumnWidths:bo,columnHeaderMaxDepth:I}}getGridX(e){const{theme:t}=e,{rowHeaderWidth:n}=t;return n}getGridY(e){const{theme:t,model:n}=e,{columnHeaderHeight:s}=t,{columnHeaderMaxDepth:o}=n;return o*s}getVisibleHeight(e,t=this.getFloatingRowHeights(e)){const{height:n,theme:s}=e,{scrollBarSize:o}=s,i=this.getGridY(e),r=this.getFloatingBottomHeight(e,t),l=this.getFloatingTopHeight(e,t);return n-r-l-i-o}getVisibleWidth(e,t=this.getFloatingColumnWidths(e)){const{width:n,theme:s}=e,{scrollBarSize:o,rowFooterWidth:i}=s,r=this.getGridX(e),l=this.getFloatingRightWidth(e,t),a=this.getFloatingLeftWidth(e,t);return n-a-l-r-o-i}getFirstIndex(e,t,n){const s=e.size+1;for(let o=0;o<s;o+=1){const i=t(o,n);if(e.get(i)!==0)return o}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:o,floatingRightColumnCount:i}=s;let r=Math.max(0,o-i-1);t!=null&&(r=t);let l=0;for(;r>=0;){if(l+=this.getVisibleColumnWidth(r,e),l>=n)return $e(r+1,0,t!=null?t:o-1);r-=1}return 0}getLastTop(e,t,n){const{model:s}=e,{rowCount:o,floatingBottomRowCount:i}=s;let r=Math.max(0,o-i-1);t!=null&&(r=t);let l=0;for(;r>=0;){if(l+=this.getVisibleRowHeight(r,e),l>=n)return $e(r+1,0,o-1);r-=1}return 0}getTopForTopVisible(e,t){const n=this.getFloatingTopHeight(e);let s=t,o=0;for(;s>0&&o<n;)s-=1,o+=this.getVisibleRowHeight(s,e);return s}getTopForBottomVisible(e,t){const{height:n}=e,s=this.getGridY(e),o=this.getFloatingBottomHeight(e),i=n-s-o;return this.getLastTop(e,t,i)}getLeftForLeftVisible(e,t){const n=this.getFloatingLeftWidth(e);let s=t,o=0;for(;s>0&&o<n;)s-=1,o+=this.getVisibleColumnWidth(s,e);return s}getLeftForRightVisible(e,t){const{width:n}=e,s=this.getGridX(e),o=this.getFloatingRightWidth(e),i=n-s-o;return this.getLastLeft(e,t,i)}getFloatingRowHeights(e){const{model:t}=e,{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:o}=t,i=new Map;for(let r=0;r<n&&r<o;r+=1)i.set(r,this.getVisibleRowHeight(r,e));for(let r=0;r<s&&o-r-1>=0;r+=1){const l=o-r-1;i.set(l,this.getVisibleRowHeight(l,e))}return i}getVisibleRowHeights(e){const{top:t,topOffset:n,height:s,model:o}=e;let i=0,r=t;const l=new Map,{rowCount:a}=o;for(;i<s+n&&r<a;){const c=this.getVisibleRowHeight(r,e);l.set(r,c),i+=c,r+=1}return l}getFloatingColumnWidths(e,t=this.getFirstColumn(e),n=this.calculateTreePaddingX(e)){const{model:s}=e,{columnCount:o,floatingLeftColumnCount:i,floatingRightColumnCount:r}=s,l=new Map;for(let a=0;a<i&&a<o;a+=1)l.set(a,this.getVisibleColumnWidth(a,e,t,n));for(let a=0;a<r&&o-a-1>=0;a+=1){const c=o-a-1;l.set(c,this.getVisibleColumnWidth(c,e,t,n))}return l}getVisibleColumnWidths(e,t=this.getFirstColumn(e),n=this.calculateTreePaddingX(e)){const{left:s,leftOffset:o,width:i,model:r}=e;let l=0,a=s;const c=new Map,{columnCount:d}=r;for(;l<i+o&&a<d;){const u=this.getVisibleColumnWidth(a,e,t,n);c.set(a,u),l+=u,a+=1}return c}getFloatingColumnXs(e,t,n){const{model:s}=e,{columnCount:o,floatingLeftColumnCount:i,floatingRightColumnCount:r}=s;return Fr(i,r,o,n,t)}getVisibleColumnXs(e,t,n){const s=new Map;let o=-n;for(let i=0;i<t.length;i+=1){const r=t[i],l=O(e,r);s.set(r,o),o+=l}return s}getFloatingRowYs(e,t,n){const{model:s}=e,{floatingTopRowCount:o,floatingBottomRowCount:i,rowCount:r}=s;return Fr(o,i,r,n,t)}getVisibleRowYs(e,t,n){const s=new Map;let o=-n;for(let i=0;i<t.length;i+=1){const r=t[i],l=O(e,r);s.set(r,o),o+=l}return s}getVisibleRowTreeBoxes(e,t,n){const s=new Map,{model:o,theme:i}=n,{treeDepthIndent:r,treeHorizontalPadding:l}=i;return Me(o)&&o.hasExpandableRows&&e.forEach((a,c)=>{const d=O(t,c);if(o.isRowExpandable(d)){const u=o.depthForRow(d),h=u*r+l,g=(u+1)*r+l,p=0,f=a;s.set(c,{x1:h,y1:p,x2:g,y2:f})}}),s}getFloatingLeftWidth(e,t=this.getFloatingColumnWidths(e)){const{model:n}=e,{floatingLeftColumnCount:s}=n;let o=0;for(let i=0;i<s;i+=1)o+=O(t,i);return o}getFloatingRightWidth(e,t=this.getFloatingColumnWidths(e)){const{model:n}=e,{floatingRightColumnCount:s,columnCount:o}=n;let i=0;for(let r=0;r<s;r+=1)i+=O(t,o-r-1);return i}getFloatingTopHeight(e,t=this.getFloatingRowHeights(e)){const{model:n}=e,{floatingTopRowCount:s}=n;let o=0;for(let i=0;i<s;i+=1)o+=O(t,i);return o}getFloatingBottomHeight(e,t=this.getFloatingRowHeights(e)){const{model:n}=e,{floatingBottomRowCount:s,rowCount:o}=n;let i=0;for(let r=0;r<s;r+=1)i+=O(t,o-r-1);return i}getTopVisible(e,t,n,s){const o=this.getFloatingTopHeight(e,n);for(let i=0;i<s.length;i+=1){const r=s[i];if(O(t,r)>=o)return r}return 0}getLeftVisible(e,t,n,s){const o=this.getFloatingLeftWidth(e,n);for(let i=0;i<s.length;i+=1){const r=s[i];if(O(t,r)>=o)return r}return 0}getBottomVisible(e,t,n,s,o){const{height:i,theme:r}=e,{scrollBarSize:l}=r,a=this.getFloatingBottomHeight(e,n),c=i-o-l-a;for(let d=s.length-1;d>=0;d-=1){const u=s[d],h=O(t,u),g=O(n,u);if(h+g<=c)return u}return 0}getRightVisible(e,t,n,s,o){const{width:i,theme:r}=e,{scrollBarSize:l}=r,a=this.getFloatingRightWidth(e,n),c=i-o-l-a;for(let d=s.length-1;d>=0;d-=1){const u=s[d],h=O(t,u),g=O(n,u);if(h+g<=c)return u}return 0}getBottomViewport(e,t,n,s){const{height:o,theme:i}=e,{rowHeight:r}=i;return this.getLastIndexViewport(t,n,s,o,r)}getRightViewport(e,t,n,s){const{width:o,theme:i}=e,{columnWidth:r}=i;return this.getLastIndexViewport(t,n,s,o,r)}getLastIndexViewport(e,t,n,s,o){let i=0,r=0;return e.length>0&&(i=e[e.length-1],r=O(t,i)+O(n,i)),r<s&&(i+=Math.ceil((s-r)/o)),i}getVisibleItemSize(e,t,n){var s;return(s=t.get(e))!=null?s:n()}getVisibleRowHeight(e,t){const n=this.getModelRow(e,t),s=this.calculateRowHeight(e,n,t);return this.getVisibleItemSize(n,this.userRowHeights,()=>{const o=this.initialRowHeights.get(n);return o!==void 0?o:s})}getVisibleColumnWidth(e,t,n=this.getFirstColumn(t),s=this.calculateTreePaddingX(t)){const o=this.getModelColumn(e,t),i=this.calculateColumnWidth(e,o,t,n,s);return this.getVisibleItemSize(o,this.userColumnWidths,()=>{const r=this.initialColumnWidths.get(o);return r!==void 0?r:i})}getModelRows(e,t){const n=new Map;for(let s=0;s<e.length;s+=1){const o=e[s],i=this.getModelRow(o,t);n.set(o,i)}return n}getModelRow(e,t){if(this.modelRows.has(e))return O(this.modelRows,e);const{movedRows:n}=t,s=_.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 o=e[s],i=this.getModelColumn(o,t);n.set(o,i)}return n}getModelColumn(e,t){if(this.modelColumns.has(e))return O(this.modelColumns,e);const{movedColumns:s}=t,o=_.getModelIndex(e,s);return this.modelColumns.set(e,o),o}calculateRowHeight(e,t,n){const{theme:s}=n,{autoSizeRows:o,rowHeight:i}=s;if(!o)return i;const r=this.calculatedRowHeights.get(t);return r!=null?r:(this.calculatedRowHeights.set(t,Math.ceil(i)),Ro(this.calculatedRowHeights),i)}calculateColumnWidth(e,t,n,s=this.getFirstColumn(n),o=this.calculateTreePaddingX(n)){const{theme:i}=n,{autoSizeColumns:r,minColumnWidth:l}=i;if(!r){const{columnWidth:h}=i;return h}const a=this.calculateColumnHeaderWidth(t,n),c=this.calculateColumnDataWidth(t,n),d=this.calculatedColumnWidths.get(t);let u=Math.ceil(Math.max(a,c));return u=Math.max(l,u),d!=null&&d>u?u=d:(this.calculatedColumnWidths.set(t,u),Ro(this.calculatedColumnWidths)),e===s&&(u+=o),u}calculateColumnHeaderWidth(e,t){const{model:n,theme:s}=t,{headerFont:o,headerHorizontalPadding:i}=s,r=n.textForColumnHeader(e,0);if(r!==void 0&&r!==""){const l=this.getWidthForFont(o,t);return r.length*l+i*2}return i*2}calculateColumnDataWidth(e,t){const{top:n,height:s,width:o,model:i,theme:r}=t,{floatingTopRowCount:l,floatingBottomRowCount:a,rowCount:c}=i,{font:d,cellHorizontalPadding:u,rowHeight:h,rowHeaderWidth:g,rowFooterWidth:p,scrollBarSize:f}=r;let C=0;const w=this.getWidthForFont(d,t),S=s/h,b=Math.ceil(n+S);return _.iterateAllItems(n,b,l,a,c,v=>{const T=this.getModelRow(v,t),R=i.textForCell(e,T);if(R){const D=u*2;C=Math.max(C,R.length*w+D)}}),C=Math.max(Math.min(C,(o-g-f-p)*wl.MAX_COLUMN_WIDTH),u*2),C}calculateTreePaddingX(e){const{top:t,height:n,model:s,theme:o}=e,{rowHeight:i,treeDepthIndent:r}=o;if(!Me(s)||!s.hasExpandableRows)return 0;let l=0;const a=n/i,c=Math.ceil(t+a);for(let d=t;d<=c;d+=1){const u=this.getModelRow(d,e),h=s.depthForRow(u);l=Math.max(l,r*(h+1))}return l}getWidthForFont(e,t){if(this.fontWidths.has(e))return O(this.fontWidths,e);const{context:n}=t;n.font=e;const s=n.measureText("8"),{width:o}=s;return this.fontWidths.set(e,o),this.fontWidths.set(n.font,o),o}setColumnWidth(e,t){const n=new Map(this.userColumnWidths);n.set(e,Math.ceil(t)),Ro(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)),Ro(n),this.userRowHeights=n}resetRowHeight(e){const t=new Map(this.userRowHeights);t.delete(e),this.userRowHeights=t,this.calculatedRowHeights.delete(e)}};let js=wl;js.CACHE_SIZE=1e4;js.MAX_COLUMN_WIDTH=.8;const nd=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",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"}),pt=(e,t)=>{let n=!1;const s=Te(e,{...t,dispose:()=>{n||(n=!0,s.clear(),n=!1)}});return s};function sd(e,t,n=6){const s=yi.hex.lab.raw(e);return s[0]=Math.max(s[0]-s[0]/n*t,0),`#${yi.lab.hex(s)}`}function od(e,t){const[n,s,o]=yi.hex.rgb(e);return`rgba(${n}, ${s}, ${o}, ${t})`}const Dr={colorWithAlpha:od,darkenForDepth:sd};class Ke{constructor(t=5e3){this.cursor=null,this.order=t}onDown(t,n,s){return!1}onMove(t,n,s){return!1}onDrag(t,n,s){return!1}onLeave(t,n,s){return!1}onClick(t,n,s){return!1}onContextMenu(t,n,s){return!1}onDoubleClick(t,n,s){return!1}onUp(t,n,s){return!1}onWheel(t,n,s){return!1}}class Sl extends Ke{constructor(){super(...arguments),this.resizingItems=[],this.hiddenItems=[],this.targetSizes=new Map,this.dragOffset=0}onDown(t,n){const{metrics:s}=n,{model:o}=n.props,i=n.getTheme();if(!s)throw new Error("metrics not set");const r=this.getSeparator(t,s,o,i);if(r!=null){const l=r.index;return this.dragOffset=0,this.draggingIndex=l,this.resizingItems=[l],this.hiddenItems=this.getHiddenItems(l,s).reverse(),this.targetSizes.clear(),this.addTargetSize(s,l),this.updateCursor(s,l),this.updateSeparator(n,r),!0}return!1}onMove(t,n){const{metrics:s}=n,{model:o}=n.props,i=n.getTheme();if(!s)throw new Error("metrics not set");const r=this.getSeparator(t,s,o,i);return r!=null?(this.updateCursor(s,r.index),!0):!1}onDrag(t,n){var f;if(this.draggingIndex==null)return!1;const s=t[this.pointProperty],{metricCalculator:o,metrics:i}=n;if(!i)throw new Error("metrics not set");const r=n.getTheme(),l=i[this.visibleOffsetProperty],a=i[this.marginProperty],c=i[this.calculatedSizesProperty],d=i[this.modelIndexesProperty],u=i[this.firstIndexProperty],h=i[this.treePaddingProperty],g=new Map;let p=this.resizingItems[this.resizingItems.length-1];for(;p!=null;){const C=O(l,p),w=s-a-C-this.dragOffset,S=O(d,p),b=this.targetSizes.get(S),v=this.resizingItems.length>1,T=this.hiddenItems.indexOf(p);let R=O(c,S);p===u&&(R+=h);let D=w;Math.abs(w-R)<=r.headerResizeSnapThreshold?D=R:b!==void 0&&w>b&&(v&&T!==0||T>0)?D=b:w<=r.headerResizeHiddenSnapThreshold&&(D=0),g.set(S,D),w<-r.headerResizeSnapThreshold&&D===0?T>=0&&v?(this.resizingItems.pop(),this.removeTargetSize(i,p),p=this.resizingItems[this.resizingItems.length-1],this.dragOffset-=(f=this.targetSizes.get(O(d,p)))!=null?f:0):(p=this.getNextShownItem(p,i),p!==null&&(this.resizingItems.push(p),this.addTargetSize(i,p))):b!==void 0&&w>b+r.headerResizeSnapThreshold&&D===b?T>0?(this.dragOffset+=D,p=this.hiddenItems[T-1],this.resizingItems.push(p),this.addTargetSize(i,p)):v?(this.resizingItems.pop(),this.removeTargetSize(i,p),p=this.resizingItems[this.resizingItems.length-1]):p=null:p=null}return g.forEach((C,w)=>{var b;const S=(b=o[this.initialSizesProperty].get(w))!=null?b:c.get(w);C===S?this.resetSize(o,w):this.setSize(o,w,C)}),this.updateCursor(i,this.draggingIndex),!0}onUp(t,n){return this.draggingIndex!=null&&(this.draggingIndex=void 0,this.resizingItems=[],this.hiddenItems=[],this.targetSizes.clear(),this.updateSeparator(n,null)),!1}onDoubleClick(t,n){const{metrics:s,metricCalculator:o}=n,{model:i}=n.props,r=n.getTheme();if(!s)throw new Error("metrics not set");const l=this.getSeparator(t,s,i,r);if(l!=null){const a=s[this.modelIndexesProperty],c=O(a,l.index),d=O(s[this.calculatedSizesProperty],c),u=o[this.initialSizesProperty].get(c);return d===u?this.resetSize(o,c):this.setSize(o,c,d),n.forceUpdate(),!0}return!1}updateCursor(t,n){const s=t[this.visibleSizesProperty];O(s,n)===0?this.cursor=this.hiddenCursor:this.cursor=this.defaultCursor}addTargetSize(t,n){const s=t[this.modelIndexesProperty],o=t[this.userSizesProperty],i=t[this.calculatedSizesProperty],r=n===0?t[this.treePaddingProperty]:0,l=O(s,n);let a=o.get(l);(a==null||a===0)&&(a=O(i,l)+r),this.targetSizes.set(l,a)}removeTargetSize(t,n){const s=t[this.modelIndexesProperty],o=O(s,n);this.targetSizes.delete(o)}}class Qo extends Sl{constructor(){super(...arguments),this.hiddenCursor="e-resize",this.defaultCursor="col-resize",this.pointProperty="x",this.userSizesProperty="userColumnWidths",this.visibleOffsetProperty="visibleColumnXs",this.visibleSizesProperty="visibleColumnWidths",this.marginProperty="rowHeaderWidth",this.calculatedSizesProperty="calculatedColumnWidths",this.initialSizesProperty="initialColumnWidths",this.modelIndexesProperty="modelColumns",this.firstIndexProperty="firstColumn",this.treePaddingProperty="treePaddingX",this.getHiddenItems=_.getHiddenColumns,this.getNextShownItem=_.getNextShownColumn,this.getSeparator=Qo.getColumnSeparator}static getColumnSeparator(t,n,s,o){if(!o.allowColumnResize)return null;const{x:i,y:r,columnHeaderDepth:l}=t,{modelColumns:a}=n,c=_.getColumnSeparatorIndex(i,r,n,o);return c==null||l==null||l>0?null:a.get(c)!=null?{index:c,depth:0}:null}setSize(t,n,s){t.setColumnWidth(n,s)}resetSize(t,n){t.resetColumnWidth(n)}updateSeparator(t,n){t.setState({draggingColumnSeparator:n,isDragging:n!==null})}}const nn=class{constructor(){this.getCachedTruncatedString=pt((e,t,n,s,o)=>nn.truncateToWidth(e,t,n,s,o),{max:1e4}),this.getCachedBackgroundColors=pt((e,t)=>e.split(" ").map(n=>{const s=[];for(let o=0;o<t;o+=1)s.push(Dr.darkenForDepth(n,o,t));return s}),{max:1e3}),this.getCachedColorWithAlpha=pt((e,t)=>Dr.colorWithAlpha(e,t),{max:1e3}),this.getCachedColorIsDark=pt(e=>Xo.isDark(e),{max:1e3})}static truncate(e,t){return t<e.length?e.substr(0,t)+"\u2026":e}static binaryTruncateToWidth(e,t,n,s=0,o=t.length,i){if(o>=t.length&&e.measureText(t).width<=n)return t;if(i!==void 0){const c=e.measureText(i).width;return i.repeat(Math.max(1,Math.floor(n/c)))}let r=s,l=Math.min(t.length-1,o),a=t;for(;l>=r;){const c=Math.ceil((l+r)/2),d=nn.truncate(t,c);if(e.measureText(d).width<=n){if(a=d,r===c)break;r=c}else if(c===0){a=d;break}else l=c-1}return a}static truncateToWidth(e,t,n,s=nn.DEFAULT_FONT_WIDTH,o){if(n<=0||t.length<=0)return"";const i=Math.min(Math.max(0,Math.floor(n/s/2)-5),t.length),r=Math.min(Math.ceil(n/s*2),t.length);return nn.binaryTruncateToWidth(e,t,n,i,r,o)}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:o,height:i}=s;e.fillStyle=n.backgroundColor,e.fillRect(0,0,o,i)}drawGrid(e,t){const{metrics:n,draggingRow:s,draggingColumn:o}=t,{gridX:i,gridY:r}=n;e.translate(i,r),this.drawGridBackground(e,t,s==null&&o==null),this.drawCellContents(e,t),this.drawFloatingRows(e,t),this.drawFloatingColumns(e,t),e.translate(-i,-r)}drawFloatingRows(e,t){const{draggingRow:n,draggingColumn:s,metrics:o,theme:i}=t,{floatingTopRowCount:r,floatingBottomRowCount:l,floatingRows:a,rowCount:c,visibleColumns:d,allRowYs:u,allRowHeights:h}=o;if(a.length!==0){i.floatingRowBackgroundColors&&this.drawRowStripesForRows(e,t,a,i.floatingRowBackgroundColors),n==null&&s==null&&this.drawFloatingMouseRowHover(e,t),this.drawGridLinesForItems(e,t,d,a,i.floatingGridColumnColor,i.floatingGridRowColor),this.drawCellBackgroundsForItems(e,t,d,a),this.drawFloatingBorders(e,t),r>0&&this.drawSelectedRanges(e,t,{top:0,bottom:r-1,maxY:O(u,r-1)+O(h,r-1)-.5}),l>0&&this.drawSelectedRanges(e,t,{top:c-l-1,bottom:c-1,minY:O(u,c-l)+.5,maxY:O(u,c-1)+O(h,c-1)-.5});for(let g=0;g<d.length;g+=1){const p=d[g];for(let f=0;f<a.length;f+=1){const C=a[f];this.drawCellContent(e,t,p,C)}}}}drawFloatingColumns(e,t){const{draggingRow:n,draggingColumn:s,metrics:o,theme:i}=t,{floatingLeftColumnCount:r,floatingRightColumnCount:l,floatingLeftWidth:a,floatingRightWidth:c,floatingColumns:d,gridX:u,maxX:h,columnCount:g,visibleRows:p,allColumnXs:f,allColumnWidths:C,width:w,height:S}=o;if(d.length!==0){i.floatingRowBackgroundColors&&(this.drawRowStripesForRows(e,t,p,i.floatingRowBackgroundColors,0,a),this.drawRowStripesForRows(e,t,p,i.floatingRowBackgroundColors,w-u-c,h)),n==null&&s==null&&this.drawFloatingMouseRowHover(e,t),e.save(),e.beginPath(),e.rect(0,0,a,S),e.clip(),this.drawGridLinesForItems(e,t,d,p,i.floatingGridColumnColor,i.floatingGridRowColor),e.restore(),this.drawCellBackgroundsForItems(e,t,d,p),this.drawFloatingBorders(e,t),r>0&&this.drawSelectedRanges(e,t,{left:0,maxX:O(f,r-1)+O(C,r-1)}),l>0&&this.drawSelectedRanges(e,t,{left:g-l,right:g-1,minX:O(f,g-l)+.5,maxX:O(f,g-1)+O(C,g-1)});for(let b=0;b<d.length;b+=1){const v=d[b];for(let T=0;T<p.length;T+=1){const R=p[T];this.drawCellContent(e,t,v,R)}}}}drawFloatingBorders(e,t){const{metrics:n,theme:s}=t,{floatingTopRowCount:o,floatingBottomRowCount:i,floatingLeftColumnCount:r,floatingRightColumnCount:l,rowCount:a,columnCount:c,allRowYs:d,allColumnXs:u,allRowHeights:h,allColumnWidths:g,maxX:p,maxY:f}=n,{floatingDividerOuterColor:C,floatingDividerInnerColor:w}=s;if(e.lineWidth=3,e.beginPath(),e.strokeStyle=C,o>0){const S=O(d,o-1)+O(h,o-1)+.5;e.moveTo(0,S),e.lineTo(p,S)}if(i>0){const S=O(d,a-i)-.5;e.moveTo(0,S),e.lineTo(p,S)}if(r>0){const S=O(u,r-1)+O(g,r-1)+.5;e.moveTo(S,0),e.lineTo(S,f)}if(l>0){const S=O(u,c-l)-.5;e.moveTo(S,0),e.lineTo(S,f)}if(e.stroke(),e.beginPath(),e.lineWidth=1,e.strokeStyle=w,o>0){const S=O(d,o-1)+O(h,o-1)+.5;e.moveTo(0,S),e.lineTo(p,S)}if(i>0){const S=O(d,a-i)-.5;e.moveTo(0,S),e.lineTo(p,S)}if(r>0){const S=O(u,r-1)+O(g,r-1)+.5;e.moveTo(S,0),e.lineTo(S,f)}if(l>0){const S=O(u,c-l)-.5;e.moveTo(S,0),e.lineTo(S,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:o,right:i,floatingBottomRowCount:r,floatingLeftColumnCount:l,floatingRightColumnCount:a,floatingTopRowCount:c,columnCount:d,rowCount:u,allRowHeights:h,allRowYs:g,allColumnXs:p,allColumnWidths:f,width:C,height:w}=s;this.drawSelectedRanges(e,t,{bottom:Math.min(o,u-r-1),right:Math.min(i,d-a-1),minX:l>0&&p.has(l+1)?O(p,l+1):-10,minY:c>0&&g.has(c+1)?O(g,c+1):-10,maxX:a>0&&p.has(d-a-1)?O(p,d-a-1)+O(f,d-a-1)-.5:C+10,maxY:r>0&&g.has(u-r-1)?O(g,u-r-1)+O(h,u-r-1)-.5:w+10})}drawRowStripes(e,t){const{metrics:n,theme:s}=t,{visibleRows:o}=n,{rowBackgroundColors:i}=s;!i||this.drawRowStripesForRows(e,t,o,i)}drawRowStripesForRows(e,t,n,s,o=0,i=t.metrics.maxX){const{theme:r,metrics:l,model:a}=t,{maxDepth:c,shadowBlur:d,shadowColor:u}=r,h=this.getCachedBackgroundColors(s,c),{allRowYs:g,allRowHeights:p}=l,f=new Map,C=[],w=[],S=(b,v)=>{const T=Me(a)?a.depthForRow(b):0,R=h[b%h.length],D=R[Math.min(T,R.length-1)];if(f.has(D)||f.set(D,[]),f.get(D).push(b),v!=null){const A=Me(a)?a.depthForRow(v):0;A<T?C.push(b):A>T&&w.push(v)}};for(let b=0;b<n.length;b+=1){const v=n[b],T=b>0?n[b-1]:void 0;S(v,T)}if(f.forEach((b,v)=>{e.fillStyle=v,e.beginPath();for(let T=0;T<b.length;T+=1){const R=b[T],D=O(g,R),A=O(p,R);e.rect(o,D,i,A)}e.fill()}),C.length>0){e.save();const b=this.getCachedColorWithAlpha(u,.15),v=this.getCachedColorWithAlpha(u,0),T=e.createLinearGradient(0,0,0,d);T.addColorStop(0,b),T.addColorStop(1,v),e.fillStyle=T;for(let R=0;R<C.length;R+=1){const D=C[R],A=O(g,D);e.translate(0,A),e.fillRect(o,0,i,d),e.translate(0,-A)}e.restore()}if(w.length>0){e.save();const b=this.getCachedColorWithAlpha(u,0),v=this.getCachedColorWithAlpha(u,.15),T=e.createLinearGradient(0,0,0,d);T.addColorStop(0,b),T.addColorStop(1,v),e.fillStyle=T;for(let R=0;R<w.length;R+=1){const D=w[R],A=O(g,D),I=O(p,D),L=A+I-d;e.translate(0,L),e.fillRect(o,0,i,d),e.translate(0,-L)}e.restore()}}drawMouseColumnHover(e,t){const{mouseX:n,mouseY:s,theme:o,metrics:i}=t;if(n==null||s==null)return;const r=_.getColumnAtX(n,i);if(r==null||o.columnHoverBackgroundColor==null)return;const{allColumnWidths:l,allColumnXs:a,maxY:c}=i;if(s>c)return;const d=O(a,r),u=O(l,r);e.fillStyle=o.columnHoverBackgroundColor,e.fillRect(d,0,u,c)}drawMouseRowHover(e,t){const{mouseX:n,mouseY:s,theme:o,metrics:i}=t;if(n==null||s==null)return;const{maxX:r}=i;if(n>r||o.rowHoverBackgroundColor==null)return;const l=_.getRowAtY(s,i);l!=null&&this.drawMouseRowHoverForRow(e,t,l)}drawFloatingMouseRowHover(e,t){const{mouseX:n,mouseY:s,theme:o,metrics:i}=t,{maxX:r,floatingTopRowCount:l,floatingBottomRowCount:a,rowCount:c,rowFooterWidth:d}=i;if(n==null||s==null||n>r+d||o.rowHoverBackgroundColor==null)return;const u=_.getRowAtY(s,i);u!=null&&(u<l||c-a<=u)&&this.drawMouseRowHoverForRow(e,t,u)}drawMouseRowHoverForRow(e,t,n){const{metrics:s,selectedRanges:o,theme:i}=t,{allRowHeights:r,allRowYs:l,maxX:a}=s,c=O(l,n),d=O(r,n);i.rowHoverBackgroundColor!=null&&(e.fillStyle=i.rowHoverBackgroundColor);for(let u=0;u<o.length;u+=1){const{startRow:h,endRow:g}=o[u];if(h!=null&&g!=null&&h<=n&&g>=n){i.selectedRowHoverBackgroundColor!=null&&(e.fillStyle=i.selectedRowHoverBackgroundColor);break}}e.fillRect(0,c,a,d)}drawGridLines(e,t){const{metrics:n,theme:s}=t,{visibleColumns:o,visibleRows:i}=n;this.drawGridLinesForItems(e,t,o,i,s.gridColumnColor,s.gridRowColor)}drawGridLinesForItems(e,t,n,s,o,i){o==null&&i==null||(e.lineWidth=1,e.beginPath(),o!=null&&(e.strokeStyle=o,this.drawGridLinesForColumns(e,t,n)),i!=null&&(e.strokeStyle=i,this.drawGridLinesForRows(e,t,s)),e.stroke())}drawGridLinesForColumns(e,t,n){const{metrics:s}=t,{allColumnXs:o,maxY:i}=s;for(let r=0;r<n.length;r+=1){const l=n[r],a=O(o,l)+.5;e.moveTo(a,0),e.lineTo(a,i)}}drawGridLinesForRows(e,t,n){const{metrics:s}=t,{allRowYs:o,maxX:i}=s,r=i;for(let l=0;l<n.length;l+=1){const a=n[l],c=O(o,a)+.5;e.moveTo(.5,c),e.lineTo(r-.5,c)}}drawCellBackgrounds(e,t){const{metrics:n}=t,{visibleColumns:s,visibleRows:o}=n;this.drawCellBackgroundsForItems(e,t,s,o)}drawCellBackgroundsForItems(e,t,n,s){e.save();for(let o=0;o<n.length;o+=1){const i=n[o];for(let r=0;r<s.length;r+=1){const l=s[r],a=r+1<s.length?s[r+1]:void 0;this.drawCellBackground(e,t,i,l,a)}}e.restore()}drawCellBackground(e,t,n,s,o){const{metrics:i,model:r,theme:l}=t,{firstColumn:a,modelColumns:c,modelRows:d,allColumnXs:u,allColumnWidths:h,allRowYs:g,allRowHeights:p}=i,f=O(d,s),C=O(c,n),w=r.backgroundColorForCell(C,f,l),S=n===a,b=Me(r)&&r.hasExpandableRows;if(w!=null){const v=O(u,n)+1,T=O(g,s)+1,R=O(h,n)-1,D=O(p,s)-1;e.fillStyle=w,e.fillRect(v,T,R,D)}S&&b&&this.drawCellRowTreeDepthLines(e,t,s,o)}drawCellContents(e,t){const{metrics:n}=t,{visibleColumns:s}=n;for(let o=0;o<s.length;o+=1){const i=s[o];this.drawColumnCellContents(e,t,i)}}drawColumnCellContents(e,t,n){const{metrics:s}=t,{allColumnXs:o,allColumnWidths:i,visibleRows:r,height:l}=s,a=O(o,n),c=O(i,n);e.save(),e.beginPath(),e.rect(a,0,c,l),e.clip();for(let d=0;d<r.length;d+=1){const u=r[d];this.drawCellContent(e,t,n,u)}e.restore()}getTextRenderMetrics(e,t,n,s){const{textAlign:o}=e,{metrics:i,model:r,theme:l}=t,{firstColumn:a,allColumnXs:c,allColumnWidths:d,allRowYs:u,allRowHeights:h}=i,{cellHorizontalPadding:g,treeDepthIndent:p,treeHorizontalPadding:f}=l,C=O(c,n),w=O(u,s),S=O(d,n),b=O(h,s),v=n===a;let T=0;Me(r)&&r.hasExpandableRows&&v&&(T=p*(r.depthForRow(s)+1)+f);const R=S-T;let D=C+g;const A=w+b*.5;return o==="right"?D=C+R-g:o==="center"&&(D=C+R*.5),D+=T,{width:R-g*2,x:D,y:A}}drawCellContent(e,t,n,s,o){var v;const{metrics:i,model:r,theme:l}=t,{firstColumn:a,fontWidths:c,modelColumns:d,modelRows:u,allRowHeights:h}=i,{textColor:g}=l,p=O(h,s),f=O(u,s),C=O(d,n),w=o!=null?o:r.textForCell(C,f),S=r.truncationCharForCell(C,f),b=n===a;if(w&&p>0){const T=r.textAlignForCell(C,f)||"left";e.textAlign=T;const R=r.colorForCell(C,f,l)||g;e.fillStyle=R;const{width:D,x:A,y:I}=this.getTextRenderMetrics(e,t,n,s),L=(v=c.get(e.font))!=null?v:nn.DEFAULT_FONT_WIDTH,k=this.getCachedTruncatedString(e,w,D,L,S);k&&e.fillText(k,A,I)}b&&Me(r)&&r.hasExpandableRows&&this.drawCellRowTreeMarker(e,t,s)}drawCellRowTreeMarker(e,t,n){const{metrics:s,model:o,mouseX:i,mouseY:r,theme:l}=t,{firstColumn:a,gridX:c,gridY:d,allColumnXs:u,allColumnWidths:h,allRowYs:g,allRowHeights:p,visibleRowTreeBoxes:f}=s,{treeMarkerColor:C,treeMarkerHoverColor:w}=l,S=O(u,a),b=O(h,a),v=O(g,n),T=O(p,n);if(!Me(o)||!o.isRowExpandable(n))return;const R=O(f,n),D=i!=null&&r!=null&&i>=c+S&&i<=c+S+b&&r>=d+v&&r<=d+v+T?w:C;this.drawTreeMarker(e,t,S,v,R,D,o.isRowExpanded(n))}drawTreeMarker(e,t,n,s,o,i,r){const{x1:l,y1:a,x2:c,y2:d}=o,u=r?"\u229F":"\u229E",h=n+(l+c)*.5+.5,g=s+(a+d)*.5+.5;e.fillStyle=i,e.textAlign="center",e.fillText(u,h,g)}drawCellRowTreeDepthLines(e,t,n,s){const{metrics:o,model:i,theme:r}=t;if(!Me(i))return;const l=i.depthForRow(n);if(l===0)return;const{firstColumn:a,allColumnXs:c,allRowYs:d,allRowHeights:u}=o,{treeDepthIndent:h,treeHorizontalPadding:g,treeLineColor:p}=r,f=O(c,a),C=O(d,n),w=O(u,n),S=s!==void 0?i.depthForRow(s):0,b=l>S?l-S:0;if(e.strokeStyle=p,e.lineWidth=1,l-b>0){e.beginPath();for(let v=0;v<l-b;v+=1){const T=f+v*h+h*.5+g+.5;e.moveTo(T,C),e.lineTo(T,C+w)}e.stroke()}if(b>0){e.beginPath();for(let v=l-b;v<l;v+=1){const T=f+v*h+h*.5+g+.5;e.moveTo(T,C),e.lineTo(T,C+Math.ceil(w/2)),e.moveTo(T-.5,C+Math.ceil(w/2)+.5),e.lineTo(T+h-.5,C+Math.ceil(w/2)+.5)}e.stroke()}}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:o,metrics:i,draggingColumnSeparator:r,isDragging:l,model:a}=t,{columnHeaderHeight:c,floatingColumns:d,gridX:u,width:h,visibleColumns:g,allColumnWidths:p,allColumnXs:f,floatingLeftColumnCount:C,floatingLeftWidth:w,floatingRightWidth:S,modelColumns:b,columnHeaderMaxDepth:v}=i;if(c<=0)return;const{headerHiddenSeparatorSize:T,headerHiddenSeparatorHoverColor:R,headerSeparatorColor:D,headerSeparatorHoverColor:A}=o,I=c*.5,L=c*(v-1)+c*.5-I*.5,k=C>0;if(e.save(),this.drawColumnHeadersForRange(e,t,[g[0],g[g.length-1]],{minX:u+w,maxX:h-S}),k&&this.drawColumnHeadersForRange(e,t,[d[0],d[d.length-1]],{minX:u,maxX:u+w}),D){e.strokeStyle=D;const x=[...p.entries()].filter(([W,V])=>V===0).map(([W])=>W);e.beginPath(),e.fillStyle=D;for(let W=0;W<x.length;W+=1){const V=x[W],Y=O(f,V),j=O(p,V),ie=u+Y+j+.5-T*.5;e.rect(ie,L,T,I)}e.fill()}if(A){let{index:x,depth:W}=r!=null?r:{};if(x==null&&n!=null&&s!=null){const Y=Qo.getColumnSeparator(_.getGridPointFromXY(n,s,i),i,a,o);x=Y==null?void 0:Y.index,W=Y==null?void 0:Y.depth}let V;if(x==null)V=!1;else{const Y=b.get(x),j=b.get(x+1);Y==null||j==null?V=!1:V=a.textForColumnHeader(Y,W)!==a.textForColumnHeader(j,W)}if(V&&x!=null&&W!=null&&(!l||r!=null)){e.strokeStyle=A;const Y=O(f,x),j=O(p,x),ie=u+Y+j+.5,G=g.indexOf(x),ee=G<g.length-1?g[G+1]:null,H=ee!=null?p.get(ee):null,$=j===0,se=H!=null&&H===0;$?(e.strokeStyle=R,e.fillStyle=R,e.fillRect(ie,L,T*.5,I)):se&&(e.fillStyle=A,e.fillRect(ie-T*.5,L,T*.5,I)),e.beginPath(),e.moveTo(ie,(v-W-1)*c),e.lineTo(ie,(v-W)*c-1),e.stroke()}}e.restore()}drawColumnHeadersForRange(e,t,n,s){const{model:o}=t,{columnHeaderMaxDepth:i}=o;if(i!==0)for(let r=0;r<=i;r+=1)this.drawColumnHeadersAtDepth(e,t,n,s,r)}drawColumnHeadersAtDepth(e,t,n,s,o){var D,A,I,L,k,x;const{metrics:i,model:r,theme:l}=t,{modelColumns:a,allColumnXs:c,gridX:d,calculatedColumnWidths:u,userColumnWidths:h,allColumnWidths:g,movedColumns:p}=i,{columnHeaderHeight:f,columnWidth:C}=l,{columnHeaderMaxDepth:w}=r,{minX:S,maxX:b}=s,v=b-S;if(w===0)return;const T=n[0],R=n[1];if(e.save(),e.translate(0,(w-o-1)*f),o===0){this.drawColumnHeader(e,t,"",S,b);for(let W=T;W<=R;W+=1)this.drawColumnHeaderAtIndex(e,t,W,s)}if(o>0){let W=T;for(;W<=R;){const{columnCount:V}=i,Y=O(a,W),j=r.textForColumnHeader(Y,o),ie=r.colorForColumnHeader(Y,o);let G=O(c,W)+d,ee=G+O(g,W);if(j!=null){let H=W-1;for(;H>=0&&(ee-G<v||G>S);){const he=(D=a.get(H))!=null?D:_.getModelIndex(H,p);if(he==null||r.textForColumnHeader(he,o)!==j)break;G-=(I=(A=h.get(he))!=null?A:u.get(he))!=null?I:C,H-=1}let $=W+1;for(;$<V&&(ee-G<v||ee<b);){const he=(L=a.get($))!=null?L:_.getModelIndex($,p);if(r.textForColumnHeader(he,o)!==j)break;ee+=(x=(k=h.get(he))!=null?k:u.get(he))!=null?x:C,$+=1}W=$-1;const se=ee-G>=v;let ne=G;se&&(ee<b?ne=ee-v:G<S&&(ne=S)),this.drawColumnHeader(e,t,j,ne,Math.min(ee-G,v),{backgroundColor:ie!=null?ie:void 0},s)}W+=1}}e.restore()}drawColumnHeaderAtIndex(e,t,n,s){var p;const{metrics:o,model:i}=t,{modelColumns:r,allColumnWidths:l,allColumnXs:a,gridX:c}=o,d=O(l,n),u=O(a,n)+c,h=O(r,n),g=i.textForColumnHeader(h);g!=null&&this.drawColumnHeader(e,t,g,u,d,{backgroundColor:(p=i.colorForColumnHeader(h))!=null?p:void 0},s)}drawColumnHeader(e,t,n,s,o,i,r){var $;if(o<=0)return;const{metrics:l,theme:a}=t,{headerHorizontalPadding:c,columnHeaderHeight:d,headerBackgroundColor:u,headerColor:h,headerSeparatorColor:g,black:p,white:f}=a,{fontWidths:C,width:w}=l,S=($=C.get(e.font))!=null?$:nn.DEFAULT_FONT_WIDTH,v=(o-c*2)/S,{backgroundColor:T=u,separatorColor:R=g}=i!=null?i:{};let{textColor:D=h}=i!=null?i:{};try{const se=this.getCachedColorIsDark(T),ne=this.getCachedColorIsDark(D);se&&ne?D=f:!se&&!ne&&(D=p)}catch{}let{minX:A=0,maxX:I=w}=r!=null?r:{};e.save(),e.rect(A,0,I-A,d),e.clip(),T!=null&&(e.fillStyle=T,e.fillRect(s,0,o,d)),R!=null&&(e.strokeStyle=R,e.beginPath(),s>0&&(e.moveTo(s+.5,0),e.lineTo(s+.5,d)),e.moveTo(s+o+.5,0),e.lineTo(s+o+.5,d),e.moveTo(s,d-.5),e.lineTo(s+o,d-.5),e.stroke()),e.beginPath(),e.rect(s,0,o,d),e.clip(),e.fillStyle=D;let L=n;v<=0?L="":L.length>v&&(L=`${L.substring(0,v-1)}\u2026`);const k=L.length*S;let x=s+o*.5;const W=d*.5;A+=c,I-=c;const V=s+c,Y=$e(V,A,I),j=s+o-c,G=$e(j,A,I)-Y,ee=x-k*.5<A,H=x+k*.5>I;ee?k<G?x=A+k*.5:x=j-k*.5:H&&(k<G?x=I-k*.5:x=V+k*.5),e.textAlign="center",e.fillText(L,x,W),e.restore()}drawRowHeaders(e,t){const{mouseX:n,mouseY:s,metrics:o,theme:i,draggingRowSeparator:r}=t,{gridY:l,rowHeaderWidth:a,height:c,visibleRows:d,allRowHeights:u,allRowYs:h}=o;if(a<=0)return;const{headerBackgroundColor:g,headerColor:p,headerHiddenSeparatorSize:f,headerHiddenSeparatorHoverColor:C,headerSeparatorColor:w,headerSeparatorHoverColor:S}=i,b=a*.5,v=a*.5-b*.5;if(e.save(),e.beginPath(),e.fillStyle=g,e.fillRect(0,0,a,c),w){e.strokeStyle=w,e.beginPath(),e.moveTo(0,l+.5),e.lineTo(a,l+.5);const T=[];let R=!1;for(let D=0;D<d.length;D+=1){const A=d[D],I=O(h,A),L=O(u,A);if(L>0){const k=l+I+L+.5;e.moveTo(0,k),e.lineTo(a,k),R=!1}else R||(R=!0,T.push(A))}e.moveTo(a-.5,0),e.lineTo(a-.5,c),e.stroke(),e.beginPath(),e.fillStyle=w;for(let D=0;D<T.length;D+=1){const A=T[D],I=O(h,A),L=O(u,A),k=l+I+L+.5-f*.5;e.rect(v,k,b,f)}e.fill()}if(S){let{index:T=null}=r!=null?r:{};if(T==null&&n!=null&&s!=null&&(T=_.getRowSeparatorIndex(n,s,o,i)),T!=null){e.strokeStyle=S;const R=O(h,T),D=O(u,T),A=l+R+D+.5,I=d.indexOf(T),L=I<d.length-1?d[I+1]:null,k=L!=null?u.get(L):null,x=D===0,W=k!=null&&k===0;x?(e.strokeStyle=C,e.fillStyle=C,e.fillRect(v,A,b,f*.5)):W&&(e.fillStyle=S,e.fillRect(v,A-f*.5,b,f*.5)),e.beginPath(),e.moveTo(.5,A),e.lineTo(a+.5,A),e.stroke()}}e.beginPath(),e.rect(0,l,a,c),e.clip(),e.fillStyle=p,e.textAlign="right";for(let T=0;T<d.length;T+=1){const R=d[T],D=O(u,R),A=O(h,R)+l;this.drawRowHeader(e,t,R,A,D)}e.restore()}drawRowHeader(e,t,n,s,o){if(o<=0)return;const{metrics:i,model:r,theme:l}=t,{modelRows:a,rowHeaderWidth:c}=i,d=O(a,n),u=c-l.cellHorizontalPadding,h=s+o*.5;e.fillText(r.textForRowHeader(d),u,h)}drawRowFooters(e,t){const{mouseX:n,mouseY:s,metrics:o,model:i,theme:r,draggingRowSeparator:l}=t,{gridY:a,gridX:c,maxX:d,modelRows:u,rowFooterWidth:h,height:g,verticalBarWidth:p,visibleRows:f,allRowHeights:C,allRowYs:w,width:S}=o;if(h<=0)return;const{cellHorizontalPadding:b,headerBackgroundColor:v,headerColor:T,headerHiddenSeparatorSize:R,headerHiddenSeparatorHoverColor:D,headerSeparatorColor:A,headerSeparatorHoverColor:I}=r,L=h*.5,k=h*.5-L*.5,x=Math.min(c+d,S-h-p);if(e.save(),e.beginPath(),e.fillStyle=v,e.fillRect(x,a,h,g),A){e.strokeStyle=A,e.beginPath(),e.moveTo(x,a+.5),e.lineTo(h,a+.5);const V=[];let Y=!1;for(let j=0;j<f.length;j+=1){const ie=f[j],G=O(w,ie),ee=O(C,ie);if(ee>0){const H=a+G+ee+.5;e.moveTo(x+.5,H),e.lineTo(x+h-.5,H),Y=!1}else Y||(Y=!0,V.push(ie))}e.moveTo(x+.5,a),e.lineTo(x+.5,g),e.stroke(),e.beginPath(),e.fillStyle=A;for(let j=0;j<V.length;j+=1){const ie=V[j],G=O(w,ie),ee=O(C,ie),H=a+G+ee+.5-R*.5;e.rect(x+k,H,L,R)}e.fill()}if(I){let{index:V=null}=l!=null?l:{};if(V==null&&n!=null&&s!=null&&(V=_.getRowSeparatorIndex(n,s,o,r)),V!=null){e.strokeStyle=I;const Y=O(w,V),j=O(C,V),ie=a+Y+j+.5,G=f.indexOf(V),ee=G<f.length-1?f[G+1]:null,H=ee!=null?C.get(ee):null,$=j===0,se=H!=null&&H===0;$?(e.strokeStyle=D,e.fillStyle=D,e.fillRect(k,ie,L,R*.5)):se&&(e.fillStyle=I,e.fillRect(k,ie-R*.5,L,R*.5)),e.beginPath(),e.moveTo(x+.5,ie),e.lineTo(x+h+.5,ie),e.stroke()}}e.beginPath(),e.rect(x,a,h,g),e.clip(),e.fillStyle=T,e.textAlign="left";const W=x+b;for(let V=0;V<f.length;V+=1){const Y=f[V],j=O(C,Y);if(j>0){const ie=O(w,Y)+a,G=O(u,Y),ee=ie+j*.5;e.fillText(i.textForRowFooter(G),W,ee)}}e.restore()}drawSelectedRanges(e,t,n={}){const{cursorColumn:s,cursorRow:o,draggingRow:i,draggingColumn:r,editingCell:l,metrics:a,model:c,selectedRanges:d,theme:u}=t,{allColumnWidths:h,allColumnXs:g,allRowHeights:p,allRowYs:f,width:C,height:w}=a,{left:S=a.left,top:b=a.top,right:v=a.right,bottom:T=a.bottom,minY:R=-10,maxY:D=w+10,minX:A=-10,maxX:I=C+10}=n;if(d.length===0)return;const L=Pe(c)&&c.isEditable&&l==null&&i==null&&r==null&&s!=null&&o!=null&&g.has(s)&&f.has(o);if(L){const k=O(g,s),x=O(f,o),W=O(h,s),V=O(p,o);e.save(),e.beginPath(),e.rect(0,0,C,w),e.rect(k,x,W,V),e.clip("evenodd")}e.beginPath();for(let k=0;k<d.length;k+=1){const x=d[k],W=x.startColumn!==null?x.startColumn:S,V=x.startRow!==null?x.startRow:b,Y=x.endColumn!==null?x.endColumn:v,j=x.endRow!==null?x.endRow:T;if(j>=b&&T>=V&&Y>=S&&v>=W){const ie=W>=S&&g.has(W)?Math.round(O(g,W))+.5:A,G=V>=b&&f.has(V)?Math.max(Math.round(O(f,V))+.5,.5):R,ee=Y<=v&&g.has(Y)?Math.round(O(g,Y)+O(h,Y))-.5:I,H=j<=T&&f.has(j)?Math.round(O(f,j)+O(p,j))-.5:D;e.rect(ie,G,ee-ie,H-G)}e.fillStyle=u.selectionColor,e.fill(),e.save(),e.clip(),e.strokeStyle=u.selectionOutlineCasingColor,e.lineWidth=3,e.stroke(),e.restore(),e.strokeStyle=u.selectionOutlineColor,e.lineWidth=1,e.stroke()}L&&s!=null&&o!=null&&(e.restore(),this.drawActiveCell(e,t,s,o))}drawActiveCell(e,t,n,s,o=nn.ACTIVE_CELL_BORDER_WIDTH){const{metrics:i,theme:r}=t,{allColumnWidths:l,allColumnXs:a,allRowHeights:c,allRowYs:d}=i,u=O(a,n),h=O(d,s),g=O(l,n),p=O(c,s);let f=u-o*.5,C=h-o*.5,w=g+o,S=p+o;f<=0&&(w+=f-1,f=1),C<=0&&(S+=C-1,C=1);const{lineWidth:b}=e;e.beginPath(),e.lineWidth=o,e.strokeStyle=r.selectionOutlineColor,this.drawRoundedRect(e,f,C,w,S),e.stroke(),e.lineWidth=b}drawRoundedRect(e,t,n,s,o,i=nn.DEFAULT_EDGE_RADIUS){e.beginPath(),e.moveTo(t+i,n),e.lineTo(t+s-i,n),e.quadraticCurveTo(t+s,n,t+s,n+i),e.lineTo(t+s,n+o-i),e.quadraticCurveTo(t+s,n+o,t+s-i,n+o),e.lineTo(t+i,n+o),e.quadraticCurveTo(t,n+o,t,n+o-i),e.lineTo(t,n+i),e.quadraticCurveTo(t,n,t+i,n),e.closePath()}drawDraggingColumn(e,t){var H;const{draggingColumn:n,metrics:s,mouseX:o,theme:i,model:r}=t;if(n==null||o==null)return;const{range:l,depth:a}=n,{gridX:c,gridY:d,allColumnXs:u,allColumnWidths:h,height:g,width:p,columnHeaderMaxDepth:f,columnHeaderHeight:C,movedColumns:w,modelColumns:S,floatingLeftWidth:b}=s,v=(H=S.get(l[0]))!=null?H:_.getModelIndex(l[0],w),T=r.getColumnHeaderGroup(v,a);if(a>0&&!T)return;const[R,D]=l,A=O(u,R),L=O(u,D)+O(h,D)-A,k=n.left,{backgroundColor:x,font:W,headerFont:V,reorderOffset:Y,shadowBlur:j,shadowColor:ie}=i,G=(f-a-1)*C;e.save(),e.translate(c,0),e.save(),e.beginPath(),e.rect(b,0,p,g),e.clip(),e.fillStyle=x,e.fillRect(A,G,L,g),e.restore(),e.translate(0,Y),e.save(),e.shadowColor=ie,e.shadowBlur=j,e.fillStyle=x,e.fillRect(n.left,G+Y,n.width,g),e.restore(),e.beginPath(),e.rect(n.left,G,n.width+1,g),e.clip(),e.translate(k-A,0),e.font=V;const ee=[];for(let $=n.range[0];$<=n.range[1];$+=1)ee.push($);this.drawColumnHeaders(e,t),this.drawColumnHeadersForRange(e,t,[ee[0],ee[ee.length-1]],{minX:A,maxX:p}),e.translate(0,d),e.font=W,this.drawGridBackground(e,t);for(let $=R;$<=D;$+=1)this.drawColumnCellContents(e,t,$);e.restore()}drawDraggingRow(e,t){const{draggingRow:n,draggingRowOffset:s,metrics:o,mouseY:i,theme:r}=t;if(n==null||i==null)return;const{gridX:l,gridY:a,allRowYs:c,allRowHeights:d,width:u}=o,h=O(c,n),g=O(d,n)+1,{backgroundColor:p,font:f,headerFont:C,reorderOffset:w,shadowBlur:S,shadowColor:b}=r;e.save(),e.translate(0,a),e.fillStyle=p,e.fillRect(0,h,u,g),e.translate(l+w,i-h-a-(s!=null?s:0)),e.save(),e.shadowColor=b,e.shadowBlur=S,e.fillStyle=p,e.fillRect(-l,h,u,g),e.restore(),e.beginPath(),e.rect(-l,h,u,g),e.clip(),e.font=f,this.drawGridBackground(e,t),this.drawCellContents(e,t),e.translate(-l,-a),e.font=C,this.drawRowHeaders(e,t),e.restore()}drawScrollBars(e,t){const{isDraggingHorizontalScrollBar:n,isDraggingVerticalScrollBar:s,isDragging:o,metrics:i,mouseX:r,mouseY:l,theme:a}=t;if(a.scrollBarSize<=0)return;const{width:c,height:d,handleHeight:u,handleWidth:h,scrollX:g,scrollY:p,hasHorizontalBar:f,hasVerticalBar:C,barWidth:w,barHeight:S,barLeft:b,barTop:v}=i,{scrollBarBackgroundColor:T,scrollBarHoverBackgroundColor:R,scrollBarCasingColor:D,scrollBarCornerColor:A,scrollBarColor:I,scrollBarHoverColor:L,scrollBarActiveColor:k,scrollBarSize:x,scrollBarHoverSize:W,scrollBarCasingWidth:V,scrollBarSelectionTick:Y,scrollBarSelectionTickColor:j,scrollBarActiveSelectionTickColor:ie,autoSelectRow:G,autoSelectColumn:ee}=a,H=r!=null&&l!=null&&r<=c&&l<=d,$=s||C&&!n&&!o&&r!=null&&l!=null&&r>=c-W&&l>=v&&H,se=n||f&&!s&&!o&&!$&&r!=null&&l!=null&&l>=d-W&&r>=b&&H,ne=se?W:x,he=$?W:x;if(e.translate(b,v),f&&C&&(e.fillStyle=D,e.fillRect(c-b-x,d-v-x,x,x),e.fillStyle=A,e.fillRect(c-b-x+V,d-v-x+V,x-V,x-V)),f){const ve=g,Ie=d-v-ne;if(e.fillStyle=D,e.fillRect(0,Ie,w,ne-V),e.fillStyle=se?R:T,e.fillRect(0,Ie+V,w,ne-V),n?e.fillStyle=k:se?e.fillStyle=L:e.fillStyle=I,e.fillRect(ve,Ie+V,h,ne-V),!G&&Y&&j!=null&&ie!=null){e.fillStyle=j;const{selectedRanges:Ge,cursorColumn:me}=t,{lastLeft:ke,columnCount:Ot}=i,hn=[...Ge].filter(ge=>ge.startColumn!=null&&ge.endColumn!=null).map(ge=>[ge.startColumn,ge.endColumn]).sort(_.compareRanges),xt=_.mergeSortedRanges(hn),rt=ge=>ge<=ke?ge/ke*(w-h):w-h+(ge-ke)/(Ot-ke)*h;for(let ge=0;ge<xt.length;ge+=1){const Ee=xt[ge],Ye=Ee[0],lt=Ee[1];if(Ye!=null&&lt!=null&&(Ye!==me||lt!==me)){const wt=rt(Ye),mn=Math.max(1,Math.round(rt(lt+1)-wt)),kt=ne-V;e.fillRect(wt,Ie+V+Math.round(kt/3),mn,Math.round(kt/3))}}if(me!=null){const ge=rt(me),Ee=2,Ye=ne-V;e.fillStyle=ie,e.fillRect(ge,Ie+V,Ee,Ye)}}}if(C){const ve=c-b-he,Ie=p;if(e.fillStyle=D,e.fillRect(ve,0,he-V,S),e.fillStyle=$?R:T,e.fillRect(ve+V,0,he-V,S),s?e.fillStyle=k:$?e.fillStyle=L:e.fillStyle=I,e.fillRect(ve+V,Ie,he-V,u),!ee&&Y&&j!=null&&ie!=null){const{selectedRanges:Ge,cursorRow:me}=t,{lastTop:ke,rowCount:Ot}=i,Ct=ge=>ge<=ke?ge/ke*(S-u):S-u+(ge-ke)/(Ot-ke)*u;e.fillStyle=j;const xt=[...Ge].filter(ge=>ge.startRow!=null&&ge.endRow!=null).map(ge=>[ge.startRow,ge.endRow]).sort(_.compareRanges),rt=_.mergeSortedRanges(xt);for(let ge=0;ge<rt.length;ge+=1){const Ee=rt[ge],Ye=Ee[0],lt=Ee[1];if(Ye!=null&&lt!=null&&(Ye!==me||lt!==me)){const wt=Ct(Ye),mn=he-V,kt=Math.max(1,Math.round(Ct(lt+1)-wt));e.fillRect(ve+V+Math.round(mn/3),wt,Math.round(mn/3),kt)}}if(me!=null){const ge=Math.round(Ct(me)),Ee=he-V,Ye=2;e.fillStyle=ie,e.fillRect(ve+V,ge,Ee,Ye)}}}e.translate(-b,-v)}};let ts=nn;ts.DEFAULT_FONT_WIDTH=10;ts.DEFAULT_EDGE_RADIUS=2;ts.ACTIVE_CELL_BORDER_WIDTH=2;const Ir=100;class id extends Ke{constructor(){super(...arguments),this.hasExtendedFloating=!1}onDown(t,n,s){const{x:o,y:i,column:r,row:l}=t,{metrics:a}=n;if(!a)throw new Error("metrics not set");const{gridX:c,gridY:d,maxX:u,maxY:h}=a,g=o-c,p=i-d;if(g<0||p<0||r==null&&g>u||l==null&&p>h)return!1;const f=_.isModifierKeyDown(s),C=s.shiftKey;f||(C?n.trimSelectedRanges():n.clearSelectedRanges());const w=n.getTheme(),{autoSelectRow:S,autoSelectColumn:b}=w;return(r!==null||!b)&&(l!==null||!S)&&(n.focus(),n.moveCursorToPosition(r,l,C,!1,C&&f)),this.startPoint=t,this.hasExtendedFloating=!1,this.dragBounds=_.getScrollDragBounds(a,l,r),!0}onDrag(t,n){if(this.startPoint===void 0)return!1;this.stopTimer();const{row:s,column:o}=this.startPoint,{x:i,y:r}=t;let{row:l,column:a}=t;const{metrics:c}=n;if(!c)throw new Error("metrics not set");const{left:d,lastLeft:u,top:h,lastTop:g,columnWidth:p,rowHeight:f}=c,C=_.getScrollDragBounds(c,s,o);let w=0,S=0;if(d<u&&(i<C.x1?w=i-C.x1:i>C.x2&&(w=i-C.x2)),h<g&&(r<C.y1?S=r-C.y1:r>C.y2&&(S=r-C.y2)),w!==0||S!==0)this.startTimer(n,t,w>0?Math.ceil(w/p):Math.floor(w/p),S>0?Math.ceil(S/f):Math.floor(S/f));else if(l!=null&&a!=null){const{floatingTopRowCount:b,floatingBottomRowCount:v,floatingLeftColumnCount:T,floatingRightColumnCount:R,columnCount:D,rowCount:A,bottom:I,right:L,topVisible:k,bottomVisible:x,leftVisible:W,rightVisible:V}=c;this.hasExtendedFloating||(s!==null&&s<b&&l>=b?(l=b,this.hasExtendedFloating=!0):s!==null&&s>=A-v&&l<A-v&&(l=A-v-1,this.hasExtendedFloating=!0),o!==null&&o<T&&a>=T?(a=T,this.hasExtendedFloating=!0):o!==null&&o>=D-R&&a<D-R&&(a=D-R-1,this.hasExtendedFloating=!0)),s!==null&&!_.isFloatingRow(s,c)&&_.isFloatingRow(l,c)&&(s>l&&l<h?l=k-1:s<l&&l>I&&(l=x+1)),o!==null&&!_.isFloatingColumn(o,c)&&_.isFloatingColumn(a,c)&&(o>a&&a<d?a=W-1:o<a&&a>L&&(a=V+1)),n.moveCursorToPosition(a,l,!0,!0)}return!0}onUp(t,n){return this.startPoint!==void 0&&(this.startPoint=void 0,this.dragBounds=void 0,this.stopTimer(),n.commitSelection()),!1}moveSelection(t,n,s,o){const{row:i,column:r}=n,{metrics:l}=t;if(!l)throw new Error("metrics not set");const{selectionEndRow:a,selectionEndColumn:c}=t.state;if(a==null||c==null)throw new Error("selection not set");const{rowCount:d,columnCount:u}=l,h=s<0&&r!=null?r:0,g=s>0&&r!=null?r:u-1,p=o<0&&i!=null?i:0,f=o>0&&i!=null?i:d-1;t.moveCursorToPosition(Math.min(Math.max(h,c+s),g),Math.min(Math.max(p,a+o),f),!0),this.lastTriggerTime=Date.now()}startTimer(t,n,s,o){this.stopTimer();const i=this.lastTriggerTime!=null?Ir-Math.min(Ir,Date.now()-this.lastTriggerTime):0;this.timer=setTimeout(()=>{this.moveSelection(t,n,s,o),this.startTimer(t,n,s,o)},i)}stopTimer(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0)}}const Nr=5,rd=1e3/60,yo=10;function Sn(e,t,n,s){var b,v,T,R,D,A,I;const{modelColumns:o,movedColumns:i,allColumnXs:r,columnCount:l,allColumnWidths:a,userColumnWidths:c,calculatedColumnWidths:d,floatingLeftWidth:u,maxX:h}=n;if(t==null||e==null||e>l||e<0)return null;const g=(b=o.get(e))!=null?b:_.getModelIndex(e,i),p=s.getColumnHeaderGroup(g,t),f=p!=null;let C,w,S;if(p!=null){const[L,k]=p.getVisibleRange(i);C=(v=r.get(L))!=null?v:u,w=((T=r.get(k))!=null?T:h)+((R=a.get(k))!=null?R:0),S=[L,k]}else{const L=r.get(e);if(L==null)return null;C=L,w=C+((I=(A=(D=a.get(e))!=null?D:c.get(g))!=null?A:d.get(g))!=null?I:0),S=[e,e]}return{visibleIndex:e,modelIndex:g,left:C,right:w,width:w-C,isColumnGroup:f,range:S,depth:t}}class ld extends Ke{constructor(){super(...arguments),this.cursor=null,this.draggingColumn=null}setScrollInterval(t,n){this.scrollingInterval!=null&&n===this.scrollingDirection||(this.scrollingDirection=n,this.scrollingInterval=window.setInterval(()=>{var f,C;const{metrics:s}=t;if(!s)return;const{left:o,lastLeft:i,leftOffset:r,userColumnWidths:l,calculatedColumnWidths:a,movedColumns:c,allColumnWidths:d}=s;let u=o,h=r;if(n==="left")for(h-=yo;h<0;){u-=1;const w=_.getModelIndex(o-1,c),S=(f=l.get(w))!=null?f:a.get(w);S===void 0?h=0:h+=S,u<0&&(h=0,u=0)}else{h+=yo;let w=d.get(o);for(;w!==void 0&&h>w;){u+=1,h-=w;const S=_.getModelIndex(o+1,c);w=(C=l.get(S))!=null?C:a.get(S),u>i&&(h=0,u=i)}}const{mouseX:g,mouseY:p}=t.state;s==null||g==null||p==null||(this.moveDraggingColumn(g,t,n==="left"?-yo:yo),t.setState({left:u,leftOffset:h}),(n==="left"&&u===0&&r===0||n==="right"&&u===i)&&this.clearScrollInterval())},rd))}clearScrollInterval(){this.scrollingDirection=void 0,window.clearInterval(this.scrollingInterval),this.scrollingInterval=void 0}onLeave(){return this.clearScrollInterval(),!1}onDown(t,n){const{model:s}=n.props,{x:o,column:i,columnHeaderDepth:r}=t,{metrics:l}=n;if(!l)throw new Error("Metrics not set");const a=Sn(i,r,l,s);if(i==null||a==null||r==null||r>0&&!a.isColumnGroup)return!1;const{rowHeaderWidth:c}=l;return this.initialGridPoint=t,this.draggingColumn=null,this.cursor=null,a.modelIndex!=null&&r!=null&&s.isColumnMovable(a.modelIndex,r)&&(this.draggingOffset=o-a.left-c,this.initialOffset=this.draggingOffset),!1}onDrag(t,n,s){if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0)return!1;const{x:o,y:i}=t,{columnHeaderDepth:r}=this.initialGridPoint,{model:l}=n.props;let{draggingColumn:a}=this;const{metrics:c}=n;if(!c)throw new Error("Metrics not set");if(!a&&Math.abs(this.initialGridPoint.x-o)<Nr&&Math.abs(this.initialGridPoint.y-i)<Nr)return!1;if(a==null){const d=Sn(this.initialGridPoint.column,r,c,l);if(!d||r==null||!l.isColumnMovable(d.modelIndex)||r>0&&!d.isColumnGroup||d.range[0]==null)return!1;a={range:d.range,depth:r,left:d.left,width:d.width};const u=Sn(a.range[0],0,c,l),h=Sn(a.range[1],0,c,l);if(!u||!h)return!1;this.draggingColumn=a,n.setState({draggingColumn:a,isDragging:!0})}return this.cursor="move",this.moveDraggingColumn(t.x,n,s.movementX),!0}moveDraggingColumn(t,n,s){var D,A,I,L,k;if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0||this.draggingColumn==null||s===0)return;if(this.initialOffset!==this.draggingOffset){this.draggingOffset<this.initialOffset&&this.initialOffset<this.draggingOffset+s||this.draggingOffset>this.initialOffset&&this.initialOffset>this.draggingOffset+s?this.draggingOffset=this.initialOffset:this.draggingOffset+=s,this.draggingColumn={...this.draggingColumn,left:t-this.draggingOffset},n.setState({draggingColumn:this.draggingColumn});return}const{depth:o}=this.draggingColumn,{model:i}=n.props,{movedColumns:r}=n.state,{metrics:l}=n;if(!l)throw new Error("Metrics not set");const{floatingLeftWidth:a,width:c,columnHeaderMaxDepth:d,allColumnXs:u}=l,h=s<0,g=Sn(this.draggingColumn.range[0],o,l,i);if(!g)return;const p=t-this.draggingOffset,f=p+g.width;this.draggingColumn={...this.draggingColumn,left:p},n.setState({draggingColumn:this.draggingColumn});const C=Sn(_.getColumnAtX($e(h?p:f,a,c),l,!0),o,l,i),w=i.getColumnHeaderParentGroup(g.modelIndex,g.depth);if(!C)return;if(w!==void 0){const x=w.getVisibleRange(r);if(C.visibleIndex<x[0]){const W=this.moveColumn(g,x[0],r);this.draggingOffset=t-((D=u.get(x[0]))!=null?D:0),this.draggingColumn={...this.draggingColumn,left:t-this.draggingOffset},this.clearScrollInterval(),n.setState({draggingColumn:this.draggingColumn,movedColumns:W});return}if(C.visibleIndex>x[1]){const W=this.moveColumn(g,x[1]-(g.range[1]-g.range[0]),r),{right:V=0}=(A=Sn(x[1],0,l,i))!=null?A:{};this.draggingOffset=t-(V-g.width),this.draggingColumn={...this.draggingColumn,left:t-this.draggingOffset},this.clearScrollInterval(),n.setState({draggingColumn:this.draggingColumn,movedColumns:W});return}}if(!i.isColumnMovable(C.modelIndex)){let x=C.visibleIndex;if(h)for(x+=1;x<g.visibleIndex&&!i.isColumnMovable(_.getModelIndex(x,r));)x+=1;else for(x-=1;x>g.visibleIndex&&!i.isColumnMovable(_.getModelIndex(x,r));)x-=1;if(x!==g.visibleIndex){h||(x-=g.range[1]-g.range[0]);const V=this.moveColumn(g,x,r);n.setState({movedColumns:V,draggingColumn:this.draggingColumn})}const W=Sn(x,0,l,i);h?this.draggingOffset=t-((I=W==null?void 0:W.left)!=null?I:0):this.draggingOffset=t-(((L=W==null?void 0:W.right)!=null?L:0)-g.width),this.draggingColumn={...this.draggingColumn,left:t-this.draggingOffset},n.setState({draggingColumn:this.draggingColumn});return}if(p<=a?this.setScrollInterval(n,"left"):f>c?this.setScrollInterval(n,"right"):this.clearScrollInterval(),C.visibleIndex===g.visibleIndex||h&&g.visibleIndex<C.visibleIndex||!h&&g.visibleIndex>C.visibleIndex)return;const S=C.left+C.width*.5,b=i.getColumnHeaderParentGroup(g.modelIndex,g.depth);let v,T=((k=b==null?void 0:b.depth)!=null?k:d)-1;for(;T>=0&&v===void 0;)v=i.getColumnHeaderGroup(C.modelIndex,T),T-=1;let R;h&&p<S&&(!v||C.visibleIndex===v.getVisibleRange(r)[0])&&(R=this.moveColumn(g,C.range[0],r)),!h&&f>S&&(!v||C.visibleIndex===v.getVisibleRange(r)[1])&&(R=this.moveColumn(g,C.range[1]-(g.range[1]-g.range[0]),r)),R&&(this.draggingColumn={...this.draggingColumn,left:p},n.setState({movedColumns:R,draggingColumn:this.draggingColumn}))}moveColumn(t,n,s){const o=t.isColumnGroup?_.moveRange(t.range,n,s):_.moveItem(t.visibleIndex,n,s),i=n-t.range[0],r=[t.range[0]+i,t.range[1]+i];return this.draggingColumn&&(this.draggingColumn={...this.draggingColumn,range:r}),o}onUp(t,n){return this.cursor=null,this.clearScrollInterval(),this.draggingOffset!=null?(this.draggingOffset=void 0,n.setState({draggingColumn:null,isDragging:!1}),!0):!1}}class qi extends Ke{constructor(){super(...arguments),this.cursor="default"}static getLeftWithOffsetFromRawLeft(t,n){const s=t.getTheme(),{metrics:o,metricCalculator:i}=t;if(!o)throw new Error("metrics not set");if(s.scrollSnapToColumn)return{left:Math.round(n),leftOffset:0};const r=Math.floor(n),l=n-r;let a=o.allColumnWidths.get(r);if(a==null){const d=t.getMetricState();a=i.getVisibleColumnWidth(r,d)}const c=a*l;return{left:r,leftOffset:c}}isInScrollBar(t,n){const s=n.getTheme(),{scrollBarSize:o,scrollBarHoverSize:i}=s,{metrics:r}=n;if(!r)throw new Error("metrics not set");const{x:l,y:a}=t,{barLeft:c,barWidth:d,height:u,hasHorizontalBar:h}=r;return h&&o>0&&a>=u-i&&a<u&&l>c&&l<c+d}getLeftWithOffset(t,n){var f;const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{x:o}=t,{barWidth:i,handleWidth:r,lastLeft:l,barLeft:a,columnCount:c,scrollableContentWidth:d,scrollableViewportWidth:u}=s,h=o-a,g=$e((h-((f=this.dragOffset)!=null?f:0))/(i-r),0,1);if(c===1)return{left:0,leftOffset:g*(d-u)};const p=g*l;return qi.getLeftWithOffsetFromRawLeft(n,p)}onDown(t,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{x:o}=t,{handleWidth:i,barLeft:r,scrollX:l}=s;if(!this.isInScrollBar(t,n))return!1;const a=o-r;if(a>=l&&a<=l+i)this.dragOffset=a-l,n.setState({isDraggingHorizontalScrollBar:!0});else{this.dragOffset=0;const{left:c,leftOffset:d}=this.getLeftWithOffset(t,n);n.setViewState({left:c,leftOffset:d,isDraggingHorizontalScrollBar:!0,isDragging:!0})}return!0}onDrag(t,n){if(this.dragOffset!=null){const{left:s,leftOffset:o}=this.getLeftWithOffset(t,n);return n.setViewState({left:s,leftOffset:o,isDraggingHorizontalScrollBar:!0,isDragging:!0}),!0}return!1}onMove(t,n){return this.isInScrollBar(t,n)}onUp(t,n){return this.dragOffset!==void 0&&(this.dragOffset=void 0,n.setState({isDraggingHorizontalScrollBar:!1,isDragging:!1})),this.isInScrollBar(t,n)}onClick(t,n){return this.isInScrollBar(t,n)}}class ad extends Ke{constructor(){super(...arguments),this.cursor="move"}onDown(t,n){const{model:s}=n.props,{x:o,y:i,row:r}=t,{metrics:l}=n;if(!l)throw new Error("metrics not set");const{columnHeaderHeight:a,rowHeaderWidth:c,allRowYs:d}=l;if(o<=c&&r!==null&&s.isRowMovable(r)){const u=O(d,r);this.draggingOffset=i-u-a,n.setState({draggingRowOffset:this.draggingOffset})}return!1}onDrag(t,n){if(this.draggingOffset==null)return!1;const{model:s}=n.props;let{draggingRow:o}=n.state;const{mouseX:i,mouseY:r}=n.state;if(i==null||r==null)return!1;if(o==null){const{row:R}=n.getGridPointFromXY(i,r);if(R!=null&&!s.isRowMovable(R)||(o=R,n.setState({draggingRow:o,isDragging:!0}),o==null))return!1}const{metrics:l}=n;if(!l)throw new Error("metrics not set");const{top:a,lastTop:c,bottom:d,bottomVisible:u,rowCount:h,columnHeaderHeight:g,allRowHeights:p,allRowYs:f,height:C}=l;let w=g;if(a<o){const R=o-1;w=O(f,R)+O(p,R)*.5+g}let S=C;if(o<d){const R=o+1;S=O(f,R)+O(p,R)*.5+g}let{movedRows:b}=n.state;r<w&&o>0&&s.isRowMovable(o-1)?(b=_.moveItem(o,o-1,b),o-=1):S<r&&o<h-1&&s.isRowMovable(o+1)&&(b=_.moveItem(o,o+1,b),o+=1),n.setState({movedRows:b,draggingRow:o});const v=g+O(p,a)*.5,T=g+O(f,u)+O(p,u)*.5;return r<v&&a>0?n.setState({top:a-1}):r>T&&a<c&&n.setState({top:a+1}),!0}onUp(t,n){return this.draggingOffset!==void 0?(this.draggingOffset=void 0,n.setState({draggingRowOffset:null,draggingRow:null,isDragging:!1}),!0):!1}}class Yi extends Sl{constructor(){super(...arguments),this.hiddenCursor="s-resize",this.defaultCursor="row-resize",this.pointProperty="y",this.userSizesProperty="userRowHeights",this.visibleOffsetProperty="visibleRowYs",this.visibleSizesProperty="visibleRowHeights",this.marginProperty="columnHeaderHeight",this.calculatedSizesProperty="calculatedRowHeights",this.initialSizesProperty="initialRowHeights",this.modelIndexesProperty="modelRows",this.firstIndexProperty="firstRow",this.treePaddingProperty="treePaddingY",this.getHiddenItems=_.getHiddenRows,this.getNextShownItem=_.getNextShownRow,this.getSeparator=Yi.getRowSeparator}static getRowSeparator(t,n,s,o){if(!o.allowRowResize)return null;const{x:i,y:r}=t,l=_.getRowSeparatorIndex(i,r,n,o);return l!=null?{index:l,depth:0}:null}setSize(t,n,s){t.setRowHeight(n,s)}resetSize(t,n){t.resetRowHeight(n)}updateSeparator(t,n){t.setState({draggingRowSeparator:n,isDragging:n!==null})}}class bs extends Ke{static isInTreeBox(t,n){const{column:s,row:o,x:i,y:r}=t,{metrics:l}=n;if(!l)throw new Error("metrics not set");const{gridX:a,gridY:c,firstColumn:d,allColumnXs:u,allColumnWidths:h,allRowHeights:g,allRowYs:p,visibleRowTreeBoxes:f}=l;if(s===d&&o!=null&&f.get(o)!=null&&i>a&&r>c){const C=O(u,s),w=O(h,s),S=O(p,o),b=O(g,o);if(i>=a+C&&i<=a+C+w&&r>=c+S&&r<=c+S+b)return!0}return!1}onDown(t,n){return bs.isInTreeBox(t,n)}onClick(t,n,s){if(bs.isInTreeBox(t,n)){const{row:o}=t;if(o!==null)return n.toggleRowExpanded(o,_.isModifierKeyDown(s)),!0}return!1}}class cd extends Ke{isInCorner(t,n){const s=n.getTheme(),{scrollBarSize:o}=s,{metrics:i}=n;if(!i)throw new Error("metrics not set");const{x:r,y:l}=t,{width:a,height:c,hasVerticalBar:d,hasHorizontalBar:u}=i;return o>0&&d&&u&&r>=a-o&&l>=c-o&&r<=a&&l<=c}onDown(t,n){return this.isInCorner(t,n)}onUp(t,n){return this.isInCorner(t,n)}onClick(t,n){return this.isInCorner(t,n)}}class Xi extends Ke{constructor(){super(...arguments),this.cursor="default"}static getTopWithOffsetFromRawTop(t,n){const s=t.getTheme(),{metrics:o,metricCalculator:i}=t;if(!o)throw new Error("metrics not set");if(s.scrollSnapToRow)return{top:Math.round(n),topOffset:0};const r=Math.floor(n),l=n-r;let a=o.allRowHeights.get(r);if(a==null){const d=t.getMetricState();a=i.getVisibleRowHeight(r,d)}const c=a*l;return{top:r,topOffset:c}}isInScrollBar(t,n){const s=n.getTheme(),{scrollBarSize:o,scrollBarHoverSize:i}=s,{metrics:r}=n;if(!r)throw new Error("metrics not set");const{x:l,y:a}=t,{barTop:c,barHeight:d,width:u,hasVerticalBar:h}=r;return h&&o>0&&l>=u-i&&l<u&&a>c&&a<c+d}getTopWithOffset(t,n){var f;const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{y:o}=t,{barHeight:i,handleHeight:r,lastTop:l,barTop:a,rowCount:c,scrollableContentHeight:d,scrollableViewportHeight:u}=s,h=o-a,g=$e((h-((f=this.dragOffset)!=null?f:0))/(i-r),0,1);if(c===1)return{top:0,topOffset:g*(d-u)};const p=g*l;return Xi.getTopWithOffsetFromRawTop(n,p)}onDown(t,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{y:o}=t,{handleHeight:i,barTop:r,scrollY:l}=s;if(!this.isInScrollBar(t,n))return!1;const a=o-r;if(a>=l&&a<=l+i)this.dragOffset=a-l,n.setState({isDraggingVerticalScrollBar:!0});else{this.dragOffset=0;const{top:c,topOffset:d}=this.getTopWithOffset(t,n);n.setViewState({top:c,topOffset:d,isDraggingVerticalScrollBar:!0,isDragging:!0})}return!0}onMove(t,n){return this.isInScrollBar(t,n)}onDrag(t,n){if(this.dragOffset!=null){const{top:s,topOffset:o}=this.getTopWithOffset(t,n);return n.setViewState({top:s,topOffset:o,isDraggingVerticalScrollBar:!0,isDragging:!0}),!0}return!1}onUp(t,n){return this.dragOffset!==void 0&&(this.dragOffset=void 0,n.setState({isDraggingVerticalScrollBar:!1,isDragging:!1})),this.isInScrollBar(t,n)}onClick(t,n){return this.isInScrollBar(t,n)}}class dd extends Ke{onDoubleClick({column:t,row:n},s){const{model:o}=s.props;return Pe(o)&&t!=null&&n!=null&&o.isEditableRange(K.makeCell(t,n))?(s.startEditing(t,n),!0):!1}}class ss{constructor(t=5e3){this.order=t}onDown(t,n){return!1}}class ud extends ss{onDown(t,n){switch(t.key){case"a":if(_.isModifierKeyDown(t))return n.selectAll(),!0;break;case"ArrowUp":return this.handleArrowMove(0,-1,t,n);case"ArrowDown":return this.handleArrowMove(0,1,t,n);case"ArrowRight":return this.handleArrowMove(1,0,t,n);case"ArrowLeft":return this.handleArrowMove(-1,0,t,n);case"k":case"K":return _.isModifierKeyDown(t)?!1:this.handlePageUp(t,n);case"j":case"J":return _.isModifierKeyDown(t)?!1:this.handlePageDown(t,n);case"h":case"H":return _.isModifierKeyDown(t)?!1:(t.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(0,n.state.cursorRow,t.shiftKey),!0);case"l":case"L":{if(_.isModifierKeyDown(t))return!1;const{model:s}=n.props,{columnCount:o}=s;return t.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(o-1,n.state.cursorRow,t.shiftKey),!0}case"PageDown":return this.handlePageDown(t,n);case"PageUp":return this.handlePageUp(t,n);case"Home":return t.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(_.isModifierKeyDown(t)?n.state.cursorColumn:0,_.isModifierKeyDown(t)?0:n.state.cursorRow,t.shiftKey,!0,!0),!0;case"End":{const{model:s}=n.props,{columnCount:o,rowCount:i}=s;return t.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(_.isModifierKeyDown(t)?n.state.cursorColumn:o-1,_.isModifierKeyDown(t)?i-1:n.state.cursorRow,t.shiftKey,!0,!0),!0}case"Escape":return n.clearSelectedRanges(),{preventDefault:!1,stopPropagation:!1};case"Enter":if(n.state.selectedRanges.length>0)return n.moveCursorInDirection(t.shiftKey?K.SELECTION_DIRECTION.UP:K.SELECTION_DIRECTION.DOWN),!0;break;case"Tab":if(n.state.selectedRanges.length>0)return n.moveCursorInDirection(t.shiftKey?K.SELECTION_DIRECTION.LEFT:K.SELECTION_DIRECTION.RIGHT),!0;break}return!1}handleArrowMove(t,n,s,o){const i=s.shiftKey,r=_.isModifierKeyDown(s);i?o.trimSelectedRanges():o.clearSelectedRanges();const{cursorRow:l,cursorColumn:a,selectionEndColumn:c,selectionEndRow:d}=o.state,u=i?c:a,h=i?d:l;if(r){const{model:g}=o.props,{columnCount:p,rowCount:f}=g,C=r&&i;let w=null,S=null;t<0?(w=0,S=h):t>0?(w=p-1,S=h):n<0?(w=u,S=0):n>0&&(w=u,S=f-1),w!=null&&S!=null&&o.moveCursorToPosition(w,S,i,!0,C)}else{if(!o.metrics)throw new Error("grid.metrics are not set");const{theme:g}=o.props,{autoSelectRow:p=!1,autoSelectColumn:f=!1}=g;if(p&&t!==0){const{lastLeft:C}=o.metrics;let{left:w}=o.state;w=$e(w+t,0,C),o.moveCursorToPosition(w,l,i,!1),o.setViewState({left:w})}else if(f&&n!==0){const{lastTop:C}=o.metrics;let{top:w}=o.state;w=$e(w+n,0,C),o.moveCursorToPosition(w,a,i,!1),o.setViewState({top:w})}else o.moveCursor(t,n,i)}return!0}handlePageUp(t,n){const s=t.shiftKey;s?n.trimSelectedRanges():n.clearSelectedRanges();const{cursorColumn:o,selectionEndRow:i}=n.state,r=i,l=o;if(r==null)return!1;const a=n.getMetricState(),{metricCalculator:c}=n,{bottomVisible:d,topVisible:u,hasHorizontalBar:h}=c.getMetrics(a);let g=r-(d-u);g-=h?0:1,g=Math.max(g,0);const p=Math.max(g-(r-u),0);return n.moveCursorToPosition(l,g,s,!1),n.setViewState({top:p}),!0}handlePageDown(t,n){const s=t.shiftKey;s?n.trimSelectedRanges():n.clearSelectedRanges();const{selectionEndRow:o,cursorColumn:i}=n.state,r=o,l=i;if(r===null)return!1;const a=n.getMetricState(),{metricCalculator:c}=n,{bottomVisible:d,topVisible:u,hasHorizontalBar:h,rowCount:g,lastTop:p}=c.getMetrics(a),f=g-1;let C=d-u+r;C+=h?0:1,C=Math.min(C,f);const w=Math.min(p,C-(r-u));return n.moveCursorToPosition(l,C,s,!1),n.setViewState({top:w}),!0}}class hd extends ss{onDown(t,n){switch(t.key){case"Enter":case" ":return this.handleExpandKey(t,n)}return!1}handleExpandKey(t,n){const{selectedRanges:s}=n.state;if(s.length===1){const o=s[0];if(o.startRow===o.endRow&&o.startColumn===o.endColumn){if(!n.metrics)throw new Error("grid.metrics not set");const{model:i}=n.props,{startRow:r,startColumn:l}=o;if(r!=null){const a=n.getModelRow(r);if((l===0||l==null)&&Me(i)&&i.isRowExpandable(a))return n.toggleRowExpanded(r),!0}}}return!1}}class md extends ss{onDown(t,n){if(_.isModifierKeyDown(t))return!1;const{model:s}=n.props,{cursorColumn:o,cursorRow:i}=n.state;if(o==null||i==null||!Pe(s)||!s.isEditableRange(K.makeCell(o,i)))return!1;const r=o,l=i;return r==null||l==null?!1:t.key.length===1?(n.startEditing(r,l,!0,[1,1],t.key),!0):t.key==="F2"?(n.startEditing(r,l),!0):t.key==="Backspace"?(n.startEditing(r,l,!0,void 0,""),!0):t.key==="Delete"?(n.setValueForCell(r,l,""),!0):!1}}function gd(e){var s,o;const t=[],n=e.querySelectorAll("tr");for(let i=0;i<n.length;i+=1){const l=n[i].querySelectorAll("td"),a=[];for(let c=0;c<l.length;c+=1){const d=l[c];a.push((o=(s=d.textContent)==null?void 0:s.trim())!=null?o:"")}t.push(a)}return t}function pd(e){const t=[];return e.forEach(n=>{var o;const s=(o=n.textContent)!=null?o:"";s.length>0&&t.push(s.split(/\t|\u00a0\u00a0 \u00a0/))}),t}function fd(e){var s,o;const t=e.querySelector("table");if(t!=null)return gd(t);const n=(o=(s=e.textContent)==null?void 0:s.trim())!=null?o:"";if(n.length>0){const{childNodes:i}=e,r=n.includes(" "),l=n.includes("\xA0\xA0 \xA0");return r&&i.length!==0&&(i.length===1||i.length>1&&(i[0].textContent==null||!i[0].textContent.includes(" ")))?n.split(`
2
2
  `).map(a=>a.split(" ")):i.length>1||l?pd(e.childNodes):n}return null}class Cd extends ss{onDown(t,n){switch(t.key){case"v":if(_.isModifierKeyDown(t)){const s=document.createElement("div");document.body.appendChild(s),s.setAttribute("contenteditable","true"),s.setAttribute("style",'clip-path: "inset(50%)"; height: 1px; width: 1px; margin: -1px; overflow: hidden; padding 0; position: absolute;');const o=()=>{s.removeEventListener("input",o),s.remove(),n.focus();const i=fd(s);i!=null&&n.pasteValue(i)};return s.addEventListener("input",o),s.focus(),{preventDefault:!1,stopPropagation:!0}}break}return!1}}const wd=e=>{switch(e){case"ArrowDown":return At.DOWN;case"ArrowUp":return At.UP;case"ArrowLeft":return At.LEFT;case"ArrowRight":return At.RIGHT;default:return}};function Ki({selectionRange:e=void 0,className:t="",disabled:n=!1,value:s="",isQuickEdit:o=!0,onChange:i=()=>{},onCancel:r=()=>{},onDone:l=()=>{},onContextMenu:a=()=>{},style:c={}}){const d=F.exports.useRef(null),u=F.exports.useRef(!1),[h]=F.exports.useState(s),[g,p]=F.exports.useState(!1),[f,C]=F.exports.useState(o),[w,S]=F.exports.useState(s);F.exports.useEffect(function(){const{current:x}=d;x!=null&&(x.focus(),e?x.setSelectionRange(e[0],e[1]):x.setSelectionRange(x.value.length,x.value.length))},[e]);const b=F.exports.useCallback(k=>{i(k)},[i]),v=F.exports.useCallback(k=>{const{value:x}=k.target;S(x),p(!0),b(x)},[b,S,p]),T=F.exports.useCallback(()=>{u.current=!0,g&&b(h),p(!1),r()},[h,g,r,b]),R=F.exports.useCallback(()=>{C(!1)},[C]),D=F.exports.useCallback((k,x=!1)=>{l(w,{direction:k,fillRange:x})},[l,w]),A=F.exports.useCallback(()=>{u.current||D(null)},[u,D]),I=F.exports.useCallback(k=>{switch(k.stopPropagation(),k.key){case"Escape":k.preventDefault(),T();break;case"Enter":if(k.preventDefault(),_.isModifierKeyDown(k))D(void 0,!0);else if(k.altKey){const x=`${w}
3
- `;S(x),p(!0),b(x)}else D(k.shiftKey?At.UP:At.DOWN);break;case"Tab":k.preventDefault(),D(k.shiftKey?At.LEFT:At.RIGHT);break;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":f&&(k.preventDefault(),D(wd(k.key)));break}},[T,D,f,S,p,b,w]),L=F.exports.useCallback(k=>{a(k)},[a]);return m("textarea",{ref:d,className:Z("grid-cell-input-field",t),value:w,onBlur:A,onChange:v,onKeyDown:I,onContextMenu:L,onClick:R,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",disabled:n,style:c})}Ki.propTypes={selectionRange:B.exports.arrayOf(B.exports.number),className:B.exports.string,disabled:B.exports.bool,isQuickEdit:B.exports.bool,value:B.exports.string,onChange:B.exports.func,onCancel:B.exports.func,onDone:B.exports.func,onContextMenu:B.exports.func,style:B.exports.shape({})};Ki.defaultProps={selectionRange:null,className:"",disabled:!1,value:"",isQuickEdit:!0,onChange:()=>{},onCancel:()=>{},onDone:()=>{},onContextMenu:()=>{},style:{}};const Sd=De.createContext({}),$n=class extends F.exports.PureComponent{constructor(e){super(e),this.getCachedKeyHandlers=Fe(l=>[...l,...this.keyHandlers].sort((a,c)=>a.order-c.order)),this.getCachedMouseHandlers=Fe(l=>[...l,...this.mouseHandlers].sort((a,c)=>a.order-c.order)),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:o,movedRows:i,renderer:r}=e;this.renderer=r||new ts,this.metricCalculator=s||new js,this.canvas=null,this.canvasContext=null,this.animationFrame=null,this.prevMetrics=null,this.metrics=null,this.documentCursor=null,this.dragTimer=null,this.keyHandlers=[new md(400),new Cd(450),new ud(500),new hd(900)],this.mouseHandlers=[new Yi(100),new Qo(200),new ad(300),new ld(400),new dd(450),new Xi(500),new qi(600),new cd(700),new bs(800),new id(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:o,movedRows:i,cursorRow:null,cursorColumn:null,selectionStartRow:null,selectionStartColumn:null,selectionEndRow:null,selectionEndColumn:null,selectedRanges:ye,lastSelectedRanges:ye,cursor:null,editingCell:null,isStuckToBottom:t,isStuckToRight:n}}static getScale(e){var o,i,r,l,a;const t=window.devicePixelRatio||1,n=e,s=(a=(l=(r=(i=(o=n.webkitBackingStorePixelRatio)!=null?o:n.mozBackingStorePixelRatio)!=null?i:n.msBackingStorePixelRatio)!=null?r:n.oBackingStorePixelRatio)!=null?l:n.backingStorePixelRatio)!=null?a:1;return t/s}static getCursorClassName(e){return e!=null&&e!==""?`grid-cursor-${e}`:null}componentDidMount(){var n;this.initContext(),(n=this.canvas)==null||n.addEventListener("wheel",this.handleWheel,{passive:!1}),window.addEventListener("resize",this.handleResize),this.updateCanvasScale(),this.updateCanvas();const{isStuckToBottom:e,isStuckToRight:t}=this.props;e&&this.scrollToBottom(),t&&this.scrollToRight()}componentDidUpdate(e,t){const{isStickyBottom:n,isStickyRight:s,movedColumns:o,movedRows:i,onMovedColumnsChanged:r,onMoveColumnComplete:l,onMovedRowsChanged:a,onMoveRowComplete:c}=this.props,{isStickyBottom:d,isStickyRight:u,movedColumns:h,movedRows:g}=e,{movedColumns:p,movedRows:f}=t,{draggingColumn:C,draggingRow:w,movedColumns:S,movedRows:b}=this.state;if(h!==o&&this.setState({movedColumns:o}),g!==i&&this.setState({movedRows:i}),p!==S&&r(S),t.draggingColumn!=null&&C==null&&l(S),f!==b&&a(b),t.draggingRow!=null&&w==null&&c(b),n!==d&&this.setState({isStuckToBottom:!1}),s!==u&&this.setState({isStuckToRight:!1}),this.updateMetrics(),this.requestUpdateCanvas(),!this.metrics||!this.prevMetrics)return;const{rowCount:v,columnCount:T,height:R,width:D}=this.metrics,{rowCount:A,columnCount:I,height:L,width:k}=this.prevMetrics;if(A!==v||R!==L){const{isStuckToBottom:x}=this.state;x&&this.scrollToBottom()}if(I!==T||D!==k){const{isStuckToRight:x}=this.state;x&&this.scrollToRight()}this.validateSelection()&&this.checkSelectionChange(t)}componentWillUnmount(){var e;this.animationFrame!=null&&cancelAnimationFrame(this.animationFrame),(e=this.canvas)==null||e.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 $n.getTheme(this.context,e)}getGridPointFromEvent(e){Rr(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 _.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 o=this.canvasContext,i=this.canvas.clientWidth,r=this.canvas.clientHeight,{left:l,top:a,leftOffset:c,topOffset:d,movedColumns:u,movedRows:h,isDraggingHorizontalScrollBar:g,isDraggingVerticalScrollBar:p,draggingColumn:f}=e;return{left:l,top:a,leftOffset:c,topOffset:d,width:i,height:r,context:o,theme:t,model:n,movedColumns:u,movedRows:h,isDraggingHorizontalScrollBar:g,isDraggingVerticalScrollBar:p,draggingColumn:f,...s}}getKeyHandlers(){const{keyHandlers:e}=this.props;return this.getCachedKeyHandlers(e)}getMouseHandlers(){const{mouseHandlers:e}=this.props;return this.getCachedMouseHandlers(e)}getModelColumn(e){var n,s;const t=(s=(n=this.metrics)==null?void 0:n.modelColumns)==null?void 0:s.get(e);if(t===void 0)throw new Error(`Unable to get ModelIndex for column ${e}`);return t}getModelRow(e){var n,s;const t=(s=(n=this.metrics)==null?void 0:n.modelRows)==null?void 0:s.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;Me(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:o,cursorColumn:i,selectedRanges:r}=this.state;if(this.setState({selectedRanges:e,lastSelectedRanges:r}),e.length>0){const l=K.boundedRange(e[0],n,s);let a=o,c=i;l.containsCell(i,o)||({row:a,column:c}=l.startCell()),this.setState({selectionStartColumn:l.startColumn,selectionStartRow:l.startRow,selectionEndColumn:l.endColumn,selectionEndRow:l.endRow,cursorColumn:c,cursorRow:a})}}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();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=$n.getScale(t),s=e.parentElement.getBoundingClientRect(),o=Math.floor(s.width),i=Math.floor(s.height);e.style.width=`${o}px`,e.style.height=`${i}px`,e.width=o*n,e.height=i*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 o=0;o<t.length;o+=1){const i=t[o];if(i.endColumn!=null&&i.endColumn>=n||i.endRow!=null&&i.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(o=>{var p,f,C,w;const{selectedRanges:i,selectionStartRow:r,selectionStartColumn:l}=o,{theme:a}=this.props,{autoSelectRow:c,autoSelectColumn:d}=a;if(n&&i.length>0){const S=i[i.length-1];let b=null,v=null,T=null,R=null;s?(b=c!==void 0&&c?null:Math.min(e!=null?e:0,(p=S.startColumn)!=null?p:0),v=d!==void 0&&d?null:Math.min(t!=null?t:0,(f=S.startRow)!=null?f:0),T=c!==void 0&&c?null:Math.max(e!=null?e:0,(C=S.endColumn)!=null?C:0),R=d!==void 0&&d?null:Math.max(t!=null?t:0,(w=S.endRow)!=null?w:0)):(b=S.startColumn,v=S.startRow,(l!=null||r!=null)&&((c===void 0||!c)&&(b=l),(d===void 0||!d)&&(v=r)),T=c!==void 0&&c?null:e,R=d!==void 0&&d?null:t);const D=K.makeNormalized(b,v,T,R);if(S.equals(D))return null;const A=[...i];return A[A.length-1]=D,{selectedRanges:A,selectionEndColumn:e,selectionEndRow:t}}const u=[...i],h=c!==void 0&&c?null:e,g=d!==void 0&&d?null:t;return u.push(K.makeNormalized(h,g,h,g)),{selectedRanges:u,selectionEndColumn:e,selectionEndRow:t}})}commitSelection(){this.setState(e=>{const{theme:t}=this.props,{autoSelectRow:n}=t,{selectedRanges:s,lastSelectedRanges:o,cursorRow:i,cursorColumn:r}=e;if(s.length===1&&(n!==void 0&&n?K.rowCount(s)===1:K.cellCount(s)===1)&&K.rangeArraysEqual(s,o))return{selectedRanges:[],lastSelectedRanges:[],cursorColumn:null,cursorRow:null};let l=s.slice();if(l.length>1){const d=l[l.length-1];for(let u=0;u<l.length-1;u+=1){const h=l[u];if(h.contains(d)){const g=h.subtract(d);l.pop(),l.splice(u,1),l=l.concat(g);break}}l=K.consolidate(l)}let a=r,c=i;if(!K.containsCell(l,r,i)){const{model:d}=this.props,{columnCount:u,rowCount:h}=d,g=K.nextCell(K.boundedRanges(s,u,h));g!=null?{column:a,row:c}=g:(a=null,c=null)}return l.length===0&&(a=null,c=null),{cursorRow:c,cursorColumn:a,selectedRanges:l,lastSelectedRanges:s}})}setFocusRow(e){var u;if(!this.metrics||!this.prevMetrics)return;const{gridY:t,height:n,lastTop:s,userRowHeights:o,rowHeight:i}=this.metrics,r=n-t,l=Math.round(r/2)+((u=o.get(e))!=null?u:i),a=this.getMetricState(),c=this.metricCalculator.getLastTop(a,e+1,l);this.setState({top:Math.min(s,c),selectedRanges:[new K(null,e,null,e)],isStuckToBottom:!1});const{cursorColumn:d}=this.state;this.moveCursorToPosition(d,e,!1,!1)}selectAll(){const{model:e,theme:t}=this.props,{autoSelectRow:n,autoSelectColumn:s}=t,o=s!==void 0&&s?null:0,i=s!==void 0&&s?null:e.rowCount-1,r=n!==void 0&&n?null:0,l=n!==void 0&&n?null:e.columnCount-1;this.setSelectedRanges([new K(r,o,l,i)])}moveCursor(e,t,n){const{cursorRow:s,cursorColumn:o,selectionEndColumn:i,selectionEndRow:r}=this.state,l=n?i:o,a=n?r:s;if(a===null||l===null){const{left:c,top:d}=this.state;this.moveCursorToPosition(c,d,n)}else{const{model:c}=this.props,{columnCount:d,rowCount:u}=c,h=$e(l+e,0,d-1),g=$e(a+t,0,u-1);this.moveCursorToPosition(h,g,n)}}moveCursorInDirection(e=K.SELECTION_DIRECTION.DOWN){var c;const{model:t}=this.props,{columnCount:n,rowCount:s}=t,{cursorRow:o,cursorColumn:i,selectedRanges:r}=this.state,l=r.length>0?r:[K.makeCell(i,o)];let a=null;if(l.length===1&&K.cellCount(l)===1){const d=new K(0,0,n-1,s-1);a=(c=d.nextCell(i,o,e))!=null?c:d.startCell(e)}else a=K.nextCell(K.boundedRanges(l,n,s),i,o,e);if(a!=null){const{column:d,row:u}=a;this.setState({cursorColumn:d,cursorRow:u}),K.containsCell(r,d,u)||this.setState({selectedRanges:[K.makeCell(d,u)],selectionStartColumn:d,selectionStartRow:u,selectionEndColumn:d,selectionEndRow:u}),this.moveViewToCell(a.column,a.row)}}moveCursorToPosition(e,t,n=!1,s=!0,o=!1){n||this.beginSelection(e,t),this.moveSelection(e,t,n,o),s&&this.moveViewToCell(e,t)}moveViewToCell(e,t){if(!this.metrics)throw new Error("metrics not set");const{metricCalculator:n}=this,{bottomVisible:s,rightVisible:o,topVisible:i,leftVisible:r}=this.metrics,l=this.getMetricState(this.state);let{top:a,left:c,topOffset:d,leftOffset:u}=this.state;t!=null&&!_.isFloatingRow(t,this.metrics)&&(t<i?(a=n.getTopForTopVisible(l,t),d=0):t>s&&(a=n.getTopForBottomVisible(l,t),d=0)),e!=null&&!_.isFloatingColumn(e,this.metrics)&&(e<r?(c=n.getLeftForLeftVisible(l,e),u=0):e>o&&(c=n.getLeftForRightVisible(l,e),u=0)),this.setViewState({top:a,left:c,topOffset:d,leftOffset:u})}setViewState(e,t=!1){if(!this.metrics)throw new Error("metrics not set");const{isStickyBottom:n,isStickyRight:s}=this.props,{top:o,left:i}=e,{lastTop:r,lastLeft:l}=this.metrics;o!=null&&this.setState({isStuckToBottom:n&&o>=r}),i!=null&&this.setState({isStuckToRight:s&&i>=l}),this.setState(e),t&&this.forceUpdate()}startEditing(e,t,n=!1,s,o){const{model:i}=this.props;if(!Pe(i))throw new Error("model is not editable");const r=this.getModelColumn(e),l=this.getModelRow(t),a={column:e,row:t,selectionRange:s,value:o!==void 0?o:i.editValueForCell(r,l),isQuickEdit:n};this.setState({editingCell:a,cursorColumn:e,cursorRow:t}),this.moveViewToCell(e,t)}isValidForCell(e,t,n){const{model:s}=this.props,o=this.getModelColumn(e),i=this.getModelRow(t);return Pe(s)&&s.isValidForCell(o,i,n)}async pasteValue(e){const{model:t}=this.props,{movedColumns:n,movedRows:s,selectedRanges:o}=this.state;try{if(yr(t),!t.isEditable||!o.every(u=>t.isEditableRange(u)))throw new mi("Can't paste in to read-only area.");if(o.length<=0)throw new mi("Select an area to paste to.");if(typeof e=="string"){const u=[],h=_.getModelRanges(o,n,s);K.forEachCell(h,(g,p)=>{u.push({column:g,row:p,text:e})}),await t.setValues(u);return}const i=e.length,r=e[0].length,{columnCount:l,rowCount:a}=t;let c=o;if(c.every(u=>{var h,g;return K.cellCount([u])===1&&((h=u.startColumn)!=null?h:0)+r<=l&&((g=u.startRow)!=null?g:0)+i<=a})&&(c=c.map(u=>{var h,g;return new K(u.startColumn,u.startRow,((h=u.startColumn)!=null?h:0)+r-1,((g=u.startRow)!=null?g:0)+i-1)}),this.setSelectedRanges(c)),!c.every(u=>K.rowCount([u])===i&&K.columnCount([u])===r))throw new mi("Copy and paste area are not same size.");const d=[];c.forEach(u=>{var h,g;for(let p=0;p<r;p+=1)for(let f=0;f<i;f+=1)d.push({column:((h=u.startColumn)!=null?h:0)+p,row:((g=u.startRow)!=null?g:0)+f,text:e[f][p]})}),await t.setValues(d)}catch(i){const{onError:r}=this.props;r(i instanceof Error?i:new Error(`${i}`))}}setValueForCell(e,t,n){const{model:s}=this.props;yr(s);const o=this.getModelColumn(e),i=this.getModelRow(t);return s.isValidForCell(o,i,n)?(s.setValueForCell(o,i,n),!0):!1}setValueForRanges(e,t){const{model:n}=this.props,{movedColumns:s,movedRows:o}=this.state,i=_.getModelRanges(e,s,o);Pe(n)&&n.setValueForRanges(i,t)}isSelected(e,t){var s,o;const{selectedRanges:n}=this.state;for(let i=0;i<n.length;i+=1){const r=n[i],l=r.startRow===null||r.startRow<=e&&e<=((s=r.endRow)!=null?s:0),a=r.startColumn===null||r.startColumn<=t&&t<=((o=r.endColumn)!=null?o:0);if(l&&a)return!0}return!1}addDocumentCursor(e=null){this.documentCursor!==$n.getCursorClassName(e)&&(this.documentCursor!=null&&document.documentElement.classList.remove(this.documentCursor),this.documentCursor=$n.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)},$n.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{cursorColumn:t,cursorRow:n,draggingColumn:s,draggingColumnSeparator:o,draggingRow:i,draggingRowOffset:r,draggingRowSeparator:l,editingCell:a,isDraggingHorizontalScrollBar:c,isDraggingVerticalScrollBar:d,isDragging:u,mouseX:h,mouseY:g,selectedRanges:p}=this.state,{model:f,stateOverride:C}=this.props,{renderer:w}=this,S=this.canvasContext,b=this.getTheme(),v=this.canvas.clientWidth,T=this.canvas.clientHeight,R={width:v,height:T,context:S,theme:b,model:f,metrics:e,mouseX:h,mouseY:g,selectedRanges:p,draggingColumn:s,draggingColumnSeparator:o,draggingRow:i,draggingRowOffset:r,draggingRowSeparator:l,editingCell:a,isDraggingHorizontalScrollBar:c,isDraggingVerticalScrollBar:d,isDragging:u,cursorColumn:t,cursorRow:n,...C};S.save(),w.drawCanvas(R),S.restore()}focus(){var e;(e=this.canvas)==null||e.focus()}isFocused(){return document.activeElement===this.canvas}handleClick(e){var s;const t=this.getGridPointFromEvent(e),n=this.getMouseHandlers();for(let o=0;o<n.length;o+=1)if(n[o].onClick(t,this,e)!==!1){e.stopPropagation(),e.preventDefault();break}(s=this.canvas)==null||s.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){var n,s;const t=this.getKeyHandlers();for(let o=0;o<t.length;o+=1){const r=t[o].onDown(e,this);if(r!==!1){const l=r;((n=l==null?void 0:l.stopPropagation)==null||n)&&e.stopPropagation(),((s=l==null?void 0:l.preventDefault)==null||s)&&e.preventDefault();break}}}notifyMouseHandlers(e,t,n=!0,s=!1){var l,a;const o=this.getGridPointFromEvent(t),i=this.getMouseHandlers();let r=null;for(let c=0;c<i.length;c+=1){const d=i[c],u=d[e]!=null&&d[e](o,this,t);if(u!==!1){d.cursor!=null&&({cursor:r}=d,s&&this.addDocumentCursor(r));const h=u;((l=h==null?void 0:h.stopPropagation)==null||l)&&t.stopPropagation(),((a=h==null?void 0:h.preventDefault)==null||a)&&t.preventDefault();break}}if(this.setState({cursor:r}),n){const{x:c,y:d}=o;this.setState({mouseX:c,mouseY:d})}}handleMouseDown(e){window.addEventListener("mousemove",this.handleMouseDrag,!0),window.addEventListener("mouseup",this.handleMouseUp,!0),!(e.button!=null&&e.button!==0)&&(this.notifyMouseHandlers("onDown",e),this.startDragTimer(e))}handleDoubleClick(e){this.notifyMouseHandlers("onDoubleClick",e)}handleMouseMove(e){this.notifyMouseHandlers("onMove",e)}handleMouseLeave(e){this.notifyMouseHandlers("onLeave",e,!1),this.setState({mouseX:null,mouseY:null})}handleMouseDrag(e){this.setState({isDragging:!0}),this.notifyMouseHandlers("onDrag",e,!0,!0),this.stopDragTimer()}handleMouseUp(e){window.removeEventListener("mousemove",this.handleMouseDrag,!0),window.removeEventListener("mouseup",this.handleMouseUp,!0),!(e.button!=null&&e.button!==0)&&(this.notifyMouseHandlers("onUp",e,!1),this.stopDragTimer(),this.removeDocumentCursor())}handleResize(){if(this.updateCanvasScale(),this.updateCanvas(),!this.metrics)throw new Error("metrics not set");this.forceUpdate()}handleWheel(e){var T,R,D,A;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:o,lastLeft:i,columnCount:r,rowCount:l,scrollableContentWidth:a,scrollableViewportWidth:c,scrollableContentHeight:d,scrollableViewportHeight:u,hasHorizontalBar:h,hasVerticalBar:g}=n;let{top:p,left:f,topOffset:C,leftOffset:w}=n;const S=this.getTheme();let{deltaX:b,deltaY:v}=_.getScrollDelta(e,n.barWidth,n.barHeight,n.rowHeight,n.rowHeight);for(;h&&b!==0;){if(w+=b,b=0,r>1){if(w>0&&f>=i||w<0&&f<=0){w=0;break}}else{if(w<=0){w=0;break}const I=a-c;if(w>=I){w=I;break}}if(w>0){const I=(T=n.allColumnWidths.get(f))!=null?T:t.getVisibleColumnWidth(f,s);w>=I?(b=w-I,w=0,f+=1):S.scrollSnapToColumn&&r>1&&(w=0,f+=1)}else if(w<0){const I=(R=n.allColumnWidths.get(f-1))!=null?R:t.getVisibleColumnWidth(f-1,s);Math.abs(w)<=I&&S.scrollSnapToColumn&&r>1?(w=0,f-=1):(b=w+I,w=0,f-=1)}}for(;g&&v!==0;){if(C+=v,v=0,l>1){if(C>0&&p>=o||C<0&&p<=0){C=0;break}}else{if(C<=0){C=0;break}const I=d-u;if(C>=I){C=I;break}}if(C>0){const I=(D=n.allRowHeights.get(p))!=null?D:t.getVisibleRowHeight(p,s);C>=I?(v=C-I,C=0,p+=1):S.scrollSnapToRow&&l>1&&(C=0,p+=1)}else if(C<0){const I=(A=n.allRowHeights.get(p-1))!=null?A:t.getVisibleRowHeight(p-1,s);Math.abs(C)<=I&&S.scrollSnapToRow&&l>1?(C=0,p-=1):(v=C+I,C=0,p-=1)}}this.setViewState({top:p,left:f,leftOffset:w,topOffset:C}),e.stopPropagation(),e.preventDefault()}handleEditCellCancel(){this.setState({editingCell:null}),this.focus()}handleEditCellChange(e){this.setState(({editingCell:t})=>{try{return Rr(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=At.DOWN,fillRange:n=!1}={}){const{editingCell:s,selectedRanges:o}=this.state;if(!s)throw new Error("editingCell not set");const{column:i,row:r}=s;if(!this.isValidForCell(i,r,e)){t===null&&this.setState({editingCell:null});return}n?this.setValueForRanges(o,e):this.setValueForCell(i,r,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||!Pe(e))return null;const{selectionRange:s,value:o,isQuickEdit:i}=t,{column:r,row:l}=t,{gridX:a,gridY:c,allColumnXs:d,allRowYs:u,allColumnWidths:h,allRowHeights:g}=n,p=d.get(r),f=u.get(l),C=h.get(r),w=g.get(l),S=p!=null&&f!=null&&C!=null&&w!=null?{position:"absolute",left:a+p,top:c+f,width:C,height:w}:{opacity:0},b=this.getModelColumn(r),v=this.getModelRow(l),T=b!=null&&v!=null?{textAlign:e.textAlignForCell(b,v)}:void 0,R=e.isValidForCell(b,v,o);return m("div",{style:S,children:m(Ki,{selectionRange:s,className:Z({error:!R}),onCancel:this.handleEditCellCancel,onChange:this.handleEditCellChange,onDone:this.handleEditCellCommit,isQuickEdit:i,style:T,value:o},`${r},${l}`)})}render(){const{cursor:e}=this.state;return y(Oe,{children:[m("canvas",{className:Z("grid-canvas",$n.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()]})}};let Rs=$n;Rs.contextType=Sd;Rs.defaultProps={canvasOptions:{alpha:!1},isStickyBottom:!1,isStickyRight:!1,isStuckToBottom:!1,isStuckToRight:!1,keyHandlers:ye,mouseHandlers:ye,movedColumns:ye,movedRows:ye,onError:()=>{},onSelectionChanged:()=>{},onMovedColumnsChanged:e=>{},onMoveColumnComplete:()=>{},onMovedRowsChanged:()=>{},onMoveRowComplete:()=>{},onViewChanged:()=>{},stateOverride:{},theme:{autoSelectColumn:!1,autoSelectRow:!1}};Rs.pixelsPerLine=100/3;Rs.dragTimeout=1e3;Rs.getTheme=Fe((e,t)=>({...nd,...e,...t}));class Tl extends wa{get floatingTopRowCount(){return 0}get floatingBottomRowCount(){return 0}get floatingLeftColumnCount(){return 0}get floatingRightColumnCount(){return 0}get columnHeaderMaxDepth(){return 1}truncationCharForCell(t,n){}textAlignForCell(t,n){return"left"}colorForCell(t,n,s){return s.textColor}backgroundColorForCell(t,n,s){return null}colorForColumnHeader(t,n=0){return null}textForRowHeader(t){return""}textForRowFooter(t){return""}isColumnMovable(t,n=0){return!0}isRowMovable(t){return!0}getColumnHeaderGroup(t,n){}getColumnHeaderParentGroup(t,n){}}class Td extends Tl{constructor({rowCount:t=1e9,columnCount:n=100,floatingTopRowCount:s=0,floatingBottomRowCount:o=0,floatingLeftColumnCount:i=0,floatingRightColumnCount:r=0,isEditable:l=!1,editedData:a=[]}={}){super(),this.numRows=t,this.numColumns=n,this.floatingTop=s,this.floatingBottom=o,this.floatingLeft=i,this.floatingRight=r,this.editable=l,this.editedData=a}get rowCount(){return this.numRows}get columnCount(){return this.numColumns}get floatingTopRowCount(){return this.floatingTop}get floatingBottomRowCount(){return this.floatingBottom}get floatingLeftColumnCount(){return this.floatingLeft}get floatingRightColumnCount(){return this.floatingRight}get isEditable(){return this.editable}textForCell(t,n){var s,o;return(o=(s=this.editedData[t])==null?void 0:s[n])!=null?o:`${t},${n}`}colorForCell(t,n,s){return s.textColor}textForColumnHeader(t,n=0){return`${t}`}textForRowHeader(t){return`${t}`}textForRowFooter(t){return`${t}`}async setValueForCell(t,n,s){this.editedData[t]==null&&(this.editedData[t]=[]),this.editedData[t][n]=`${s}`}async setValueForRanges(t,n){K.forEachCell(t,(s,o)=>{this.setValueForCell(s,o,n)})}async setValues(t){var n,s;for(let o=0;o<t.length;o+=1){const i=t[o];this.setValueForCell((n=i.column)!=null?n:i.x,(s=i.row)!=null?s:i.y,i.text)}}editValueForCell(t,n){return this.textForCell(t,n)}isValidForCell(t,n,s){return!0}isEditableRange(t){return this.isEditable}delete(t){throw new Error("Method not implemented.")}}const zn=class extends Td{constructor({rowCount:e=zn.DEFAULT_ROW_COUNT,columnCount:t=zn.DEFAULT_COLUMN_COUNT,children:n=new Map,childRowCount:s=Math.ceil(Math.max(zn.MIN_CHILD_ROW_COUNT,e*zn.DEFAULT_CHILD_ROW_COUNT_FACTOR)),maxDepth:o=zn.MAX_DEPTH}={}){super({rowCount:e,columnCount:t}),this.getCachedModelRowOffset=pt((i,r)=>{let l=null,a=r;const c=[...i].sort((d,u)=>d[0]-u[0]);for(let d=0;d<c.length;d+=1){const[u,h]=c[d];if(a<=u)break;const g=h.rowCount;if(a<=u+g){l=u,a=a-u-1;break}a-=g}return{key:l,offsetRow:a}}),this.getCachedTextForRowHeader=pt((i,r)=>{const{key:l,offsetRow:a}=this.getCachedModelRowOffset(i,r);if(l!=null){const c=i.get(l);if(c!==void 0)return`${l}.${c.textForRowHeader(a)}`}return`${a}`}),this.getCachedTextForCell=pt((i,r,l)=>{const{key:a,offsetRow:c}=this.getCachedModelRowOffset(i,l);if(a!=null){const d=i.get(a);if(d!==void 0)return`${a}.${d.textForCell(r,c)}`}return`${r},${c}`}),this.getCachedIsRowExpandable=pt((i,r,l)=>this.getCachedDepthForRow(i,r)<l),this.getCachedIsRowExpanded=pt((i,r)=>{const{key:l,offsetRow:a}=this.getCachedModelRowOffset(i,r);if(l!=null){const c=i.get(l);if(c!==void 0)return c.isRowExpanded(a)}return i.has(a)}),this.getCachedDepthForRow=pt((i,r)=>{const{key:l,offsetRow:a}=this.getCachedModelRowOffset(i,r);if(l!=null){const c=i.get(l);if(c!==void 0)return c.depthForRow(a)+1}return 0}),this.children=n,this.childRowCount=s,this.maxDepth=o}textForCell(e,t){return this.getCachedTextForCell(this.children,e,t)}textForRowHeader(e){return this.getCachedTextForRowHeader(this.children,e)}isRowMovable(e){return!1}get hasExpandableRows(){return!0}get isExpandAllAvailable(){return!1}get floatingBottomRowCount(){return 0}isRowExpandable(e){return this.getCachedIsRowExpandable(this.children,e,this.maxDepth)}isRowExpanded(e){return this.getCachedIsRowExpanded(this.children,e)}setRowExpanded(e,t,n=!1){const{key:s,offsetRow:o}=this.getCachedModelRowOffset(this.children,e),i=new Map(this.children);if(s!=null){const r=this.children.get(s);if(r!==void 0){const{rowCount:l}=r;r.setRowExpanded(o,t,n),this.numRows+=r.rowCount-l}}else if(t){const r=new zn({rowCount:this.childRowCount,columnCount:this.numColumns});i.set(o,r),this.numRows+=r.rowCount}else{const r=i.get(o);r!==void 0&&(this.numRows-=r.rowCount,i.delete(o))}this.children=i}expandAll(){throw new Error("Expand all not implemented.")}collapseAll(){throw new Error("Collapse all not implemented.")}depthForRow(e){return this.getCachedDepthForRow(this.children,e)}};let Zs=zn;Zs.DEFAULT_ROW_COUNT=1e9;Zs.DEFAULT_COLUMN_COUNT=100;Zs.DEFAULT_CHILD_ROW_COUNT_FACTOR=.01;Zs.MIN_CHILD_ROW_COUNT=10;Zs.MAX_DEPTH=10;const{dh:E}=globalThis,jo=B.exports.shape({name:B.exports.string.isRequired,type:B.exports.string.isRequired,description:B.exports.string,constituentType:B.exports.string}),bl=B.exports.shape({not:B.exports.func.isRequired,and:B.exports.func.isRequired,or:B.exports.func.isRequired}),bd=B.exports.shape({asc:B.exports.func.isRequired,desc:B.exports.func.isRequired,abs:B.exports.func.isRequired,column:jo.isRequired,direction:B.exports.string.isRequired,isAbs:B.exports.bool.isRequired}),Ed=B.exports.shape({columns:B.exports.arrayOf(jo).isRequired,customColumns:B.exports.arrayOf(B.exports.string).isRequired,filter:B.exports.arrayOf(bl),addEventListener:B.exports.func.isRequired,removeEventListener:B.exports.func.isRequired,size:B.exports.number.isRequired,sort:B.exports.arrayOf(B.exports.any),copy:B.exports.func.isRequired,applyFilter:B.exports.func.isRequired,applySort:B.exports.func.isRequired,applyCustomColumns:B.exports.func.isRequired,description:B.exports.string}),vd=B.exports.shape({columns:B.exports.arrayOf(jo),filter:B.exports.arrayOf(B.exports.any),isExpanded:B.exports.func.isRequired,saveExpandedState:B.exports.func.isRequired,addEventListener:B.exports.func.isRequired,removeEventListener:B.exports.func.isRequired,size:B.exports.number.isRequired,sort:B.exports.arrayOf(B.exports.any),applyFilter:B.exports.func.isRequired,applySort:B.exports.func.isRequired}),Oo=B.exports.shape({name:B.exports.string.isRequired,type:B.exports.string.isRequired}),Rd=B.exports.shape({created:B.exports.arrayOf(Oo).isRequired,updated:B.exports.arrayOf(Oo).isRequired,removed:B.exports.arrayOf(Oo).isRequired}),yd=B.exports.shape({groupingColumns:B.exports.arrayOf(B.exports.string),aggregations:B.exports.shape({}),includeConstituents:B.exports.bool,includeOriginalColumns:B.exports.bool,includeDescriptions:B.exports.bool}),Fd=B.exports.shape({addEventListener:B.exports.func.isRequired,removeEventListener:B.exports.func.isRequired,onLogMessage:B.exports.func,getTable:B.exports.func.isRequired,runCode:B.exports.func.isRequired});Object.freeze({Column:jo,FilterCondition:bl,IdeSession:Fd,RollupConfig:yd,Sort:bd,Table:Ed,TreeTable:vd,VariableChanges:Rd,VariableDefinition:Oo});const Dd=1e4;function Id(e,t,n=Dd){return new Promise((s,o)=>{let i;const r=setTimeout(()=>{i==null||i(),o(new il(`Variable ${t} not found`))},n);function l(a){const c=a.created.find(d=>d.title===t);c!=null&&(clearTimeout(r),i==null||i(),s(c))}i=e.subscribeToFieldUpdates(l)})}class _e{static isValid(t){return!0}static isSameFormat(t,n){throw new Error("isSameFormat not implemented")}static makeFormat(t,n,s){return{label:t,formatString:n,type:s}}format(t,n){return""}}_e.TYPE_GLOBAL="type-global";_e.TYPE_CONTEXT_PRESET="type-context-preset";_e.TYPE_CONTEXT_CUSTOM="type-context-custom";class Nd extends _e{format(t){switch(t){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}class Ad extends _e{format(t){return String.fromCharCode(t)}}const Ar=le.module("DateTimeColumnFormatter"),qn=class extends _e{constructor({timeZone:e="",showTimeZone:t=!0,showTSeparator:n=!1,defaultDateTimeFormatString:s=qn.DEFAULT_DATETIME_FORMAT_STRING}={}){super();const o=e||qn.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=E.i18n.TimeZone.getTimeZone(o)}catch{Ar.error("Unsupported time zone id",o),this.dhTimeZone=E.i18n.TimeZone.getTimeZone(qn.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=s,this.showTimeZone=t,this.showTSeparator=n,this.formatStringMap=qn.makeFormatStringMap(t,n)}static isValid(e){try{return E.i18n.DateTimeFormat.format(e.formatString,new Date),!0}catch{return!1}}static makeFormat(e,t,n=_e.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 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[...qn.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[...qn.makeFormatStringMap(e,t).keys()]}getEffectiveFormatString(e){var t;return(t=this.formatStringMap.get(e))!=null?t:e}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultDateTimeFormatString,s=this.getEffectiveFormatString(n);try{return E.i18n.DateTimeFormat.format(s,e,this.dhTimeZone)}catch{Ar.error("Invalid format arguments")}return""}};let kn=qn;kn.DEFAULT_DATETIME_FORMAT_STRING="yyyy-MM-dd HH:mm:ss.SSS";kn.DEFAULT_TIME_ZONE_ID="America/New_York";const Md=le.module("DecimalColumnFormatter"),Mt=class extends _e{constructor({defaultFormatString:e=Mt.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=e}static isValid(e){try{return E.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=_e.TYPE_CONTEXT_PRESET,s){return{label:e,type:n,formatString:t,multiplier:s}}static makePresetFormat(e,t="",n){return Mt.makeFormat(e,t,_e.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return Mt.makeFormat("Custom Format",e,_e.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}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,s=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return E.i18n.NumberFormat.format(n,s)}catch{Md.error("Invalid format arguments")}return""}};let Ve=Mt;Ve.DEFAULT_FORMAT_STRING="###,##0.0000";Ve.FORMAT_PERCENT=Mt.makePresetFormat("Percent","##0.00%");Ve.FORMAT_BASIS_POINTS=Mt.makePresetFormat("Basis Points","###,##0 bp",1e4);Ve.FORMAT_MILLIONS=Mt.makePresetFormat("Millions","###,##0.000 mm",1e-6);Ve.FORMAT_SCIENTIFIC_NOTATION=Mt.makePresetFormat("Scientific Notation","0.0000E0");Ve.FORMAT_ROUND=Mt.makePresetFormat("Round","###,##0");Ve.FORMAT_ROUND_TWO_DECIMALS=Mt.makePresetFormat("0.00","###,##0.00");Ve.FORMAT_ROUND_FOUR_DECIMALS=Mt.makePresetFormat("0.0000","###,##0.0000");class Od extends _e{format(t){return`${t}`}}const xd=le.module("IntegerColumnFormatter"),Ts=class extends _e{constructor({defaultFormatString:e=Ts.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=e}static isValid(e){try{return E.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=_e.TYPE_CONTEXT_PRESET,s){return{label:e,type:n,formatString:t,multiplier:s}}static makePresetFormat(e,t="",n){return Ts.makeFormat(e,t,_e.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return Ts.makeFormat("Custom Format",e,_e.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}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,s=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return E.i18n.NumberFormat.format(n,s)}catch{xd.error("Invalid format arguments")}return""}};let It=Ts;It.DEFAULT_FORMAT_STRING="###,##0";It.FORMAT_MILLIONS=Ts.makePresetFormat("Millions","###,##0.000 mm",1e-6);It.FORMAT_SCIENTIFIC_NOTATION=Ts.makePresetFormat("Scientific Notation","0.0000E0");class kd extends _e{format(t){return t}}const ct=class{static makeDateWrapper(e,t,n=0,s=1,o=0,i=0,r=0,l=0){if(!e)throw new Error("No timezone provided");const a=`${t}`.padStart(4,"0"),c=`${n+1}`.padStart(2,"0"),d=`${s}`.padStart(2,"0"),u=`${o}`.padStart(2,"0"),h=`${i}`.padStart(2,"0"),g=`${r}`.padStart(2,"0"),p=`${l}`.padStart(9,"0"),f=`${a}-${c}-${d} ${u}:${h}:${g}.${p}`;return E.i18n.DateTimeFormat.parse(ct.FULL_DATE_FORMAT,f,E.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:o,date:i,hours:r,minutes:l,seconds:a,nanos:c}=t;if(e.nanos!=null){if(e.nanos.length===9)return null;c=ct.getNextNanos(e.nanos),c>999999999&&(a+=1,c=0)}else e.seconds!=null?a+=1:e.minutes!=null?l+=1:e.hours!=null?r+=1:e.date!=null?i+=1:e.month!=null?o+=1:s+=1;const d=new Date(s,o,i,r,l,a);return ct.makeDateWrapper(n,d.getFullYear(),d.getMonth(),d.getDate(),d.getHours(),d.getMinutes(),d.getSeconds(),c)}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<ct.months.length;s+=1)if(ct.months[s].startsWith(n))return s}return NaN}static parseDateValues(e,t,n,s,o,i,r){const l=parseInt(e,10),a=t!=null?this.parseMonth(t):0,c=n!=null?parseInt(n,10):1,d=s!=null?parseInt(s,10):0,u=o!=null?parseInt(o,10):0,h=i!=null?parseInt(i,10):0,g=r!=null?parseInt(r.padEnd(9,"0"),10):0;return Number.isNaN(l)||Number.isNaN(a)||Number.isNaN(c)||Number.isNaN(d)||Number.isNaN(u)||Number.isNaN(h)||Number.isNaN(g)?null:{year:l,month:a,date:c,hours:d,minutes:u,seconds:h,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,,o,,i,,r,,l,,a,,c,d]=n;if(d!=null&&d.length>0)throw new Error(`Unexpected characters after date string '${e}': ${d}`);return{year:s,month:o,date:i,hours:r,minutes:l,seconds:a,nanos:c}}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 l=new Date(Date.now()),a=ct.makeDateWrapper(t,l.getFullYear(),l.getMonth(),l.getDate()),c=ct.makeDateWrapper(t,l.getFullYear(),l.getMonth(),l.getDate()+1);return[a,c]}if(n==="yesterday"){const l=new Date(Date.now()),a=ct.makeDateWrapper(t,l.getFullYear(),l.getMonth(),l.getDate()-1),c=ct.makeDateWrapper(t,l.getFullYear(),l.getMonth(),l.getDate());return[a,c]}if(n==="now"){const l=new Date(Date.now());return[E.DateWrapper.ofJsDate(l),null]}const s=ct.parseDateTimeString(n);if(s.year==null&&s.month==null&&s.date==null)throw new Error(`Unable to extract year, month, or day ${n}`);const o=ct.parseDateValues(s.year,s.month,s.date,s.hours,s.minutes,s.seconds,s.nanos);if(o==null)throw new Error(`Unable to extract date values from ${s}`);const i=ct.makeDateWrapper(t,o.year,o.month,o.date,o.hours,o.minutes,o.seconds,o.nanos),r=ct.getNextDate(s,o,t);return[i,r]}static getJsDate(e){return typeof e=="number"?new Date(e):e.asDate()}};let qt=ct;qt.FULL_DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";qt.months=["january","february","march","april","may","june","july","august","september","october","november","december"];class Gt{}Gt.not="not";Gt.and="and";Gt.or="or";function Ld(e){if(!(e==="not"||e==="and"||e==="or"))throw new Error("operator is not a valid FilterOperatorValue")}class P{}P.eq="eq";P.eqIgnoreCase="eqIgnoreCase";P.notEq="notEq";P.notEqIgnoreCase="notEqIgnoreCase";P.greaterThan="greaterThan";P.greaterThanOrEqualTo="greaterThanOrEqualTo";P.lessThan="lessThan";P.lessThanOrEqualTo="lessThanOrEqualTo";P.in="in";P.inIgnoreCase="inIgnoreCase";P.notIn="notIn";P.notInIgnoreCase="notInIgnoreCase";P.isTrue="isTrue";P.isFalse="isFalse";P.isNull="isNull";P.invoke="invoke";P.contains="contains";P.notContains="notContains";P.startsWith="startsWith";P.endsWith="endsWith";P.containsAny="containsAny";function Pd(e){switch(e){case P.eq:return"is exactly";case P.eqIgnoreCase:return"is exactly (ignore case)";case P.notEq:return"is not exactly";case P.notEqIgnoreCase:return"is not exactly (ignore case)";case P.contains:return"contains";case P.notContains:return"does not contain";case P.startsWith:return"starts with";case P.endsWith:return"ends with";default:throw new Error(`Unrecognized text filter type ${e}`)}}function _d(e){switch(e){case P.eq:return"is equal to";case P.notEq:return"is not equal to";case P.greaterThan:return"greater than";case P.greaterThanOrEqualTo:return"greater than or equal to";case P.lessThan:return"less than";case P.lessThanOrEqualTo:return"less than or equal to";default:throw new Error(`Unrecognized number filter type ${e}`)}}function Hd(e){switch(e){case P.eq:return"date is";case P.notEq:return"date is not";case P.notEqIgnoreCase:case P.greaterThan:return"date is after";case P.greaterThanOrEqualTo:return"date is after or equal";case P.lessThan:return"date is before";case P.lessThanOrEqualTo:return"date is before or equal";default:throw new Error(`Unrecognized date filter type ${e}`)}}function Vd(e){switch(e){case P.isTrue:return"Is True";case P.isFalse:return"Is False";case P.isNull:return"Is Null";default:throw new Error(`Unrecognized boolean filter type ${e}`)}}const Zt=le.module("TableUtils"),X=class{static getSortIndex(e,t){var n;for(let s=0;s<e.length;s+=1)if(((n=e[s].column)==null?void 0:n.index)===t)return s;return null}static getSortForColumn(e,t){const n=X.getSortIndex(e,t);return n!=null?e[n]:null}static getFilterText(e){return e?e.toString():null}static getFilterTypes(e){return X.isBooleanType(e)?[P.isTrue,P.isFalse,P.isNull]:X.isCharType(e)||X.isNumberType(e)||X.isDateType(e)?[P.eq,P.notEq,P.greaterThan,P.greaterThanOrEqualTo,P.lessThan,P.lessThanOrEqualTo]:X.isTextType(e)?[P.eq,P.eqIgnoreCase,P.notEq,P.notEqIgnoreCase,P.contains,P.notContains,P.startsWith,P.endsWith]:[]}static getNextSort(e,t,n){if(e==null||n<0||n>=e.length)return null;const s=X.getSortForColumn(t,n);return s===null?e[n].sort().asc():s.direction===X.sortDirection.ascending?s.desc():null}static makeColumnSort(e,t,n,s){if(e==null||t<0||t>=e.length||n===X.sortDirection.none)return null;let o=e[t].sort();switch(n){case X.sortDirection.ascending:o=o.asc();break;case X.sortDirection.descending:o=o.desc();break}return s&&(o=o.abs()),o}static toggleSortForColumn(e,t,n,s=!1){if(n<0||n>=t.length)return[];const o=X.getNextSort(t,e,n);return X.setSortForColumn(e,n,o,s)}static sortColumn(e,t,n,s,o,i){if(e==null||n<0||n>=t.length)return[];const r=X.makeColumnSort(t,n,s,o);return X.setSortForColumn(e,n,r,i)}static setSortForColumn(e,t,n,s=!1){const o=X.getSortIndex(e,t);let i=[];return s&&(i=i.concat(e.filter(({direction:r})=>r!==X.sortDirection.reverse)),o!==null&&i.splice(o,1)),n!==null&&i.push(n),i}static getNormalizedType(e){switch(e){case"boolean":case"java.lang.Boolean":case X.dataType.BOOLEAN:return X.dataType.BOOLEAN;case"char":case"java.lang.Character":case X.dataType.CHAR:return X.dataType.CHAR;case"java.lang.String":case X.dataType.STRING:return X.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 X.dataType.DATETIME:return X.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case X.dataType.DECIMAL:return X.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 X.dataType.INT:return X.dataType.INT;default:return X.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 X.isIntegerType(e)||X.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 X.getNormalizedType(e)===X.getNormalizedType(t)}static makeQuickFilter(e,t,n){const s=t.split("||");let o=null;for(let i=0;i<s.length;i+=1){const l=s[i].split("&&");let a=null;for(let c=0;c<l.length;c+=1){const d=l[c].trim();if(d.length>0){const u=X.makeQuickFilterFromComponent(e,d,n);if(u)a?a=a.and(u):a=u;else throw new Error(`Unable to parse quick filter from text ${t}`)}}o&&a?o=o.or(a):o=a}return o}static makeQuickFilterFromComponent(e,t,n){const{type:s}=e;return X.isNumberType(s)?this.makeQuickNumberFilter(e,t):X.isBooleanType(s)?this.makeQuickBooleanFilter(e,t):n!=null&&X.isDateType(s)?this.makeQuickDateFilter(e,t,n):X.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 i=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i.exec(t);let r=null,l=null,a=null,c=null,d=null;if(i!==null&&i.length>3&&([,r,l,a,c,d]=i),d!=null&&d.trim().length>0)return null;if(r==null&&(r="="),c!=null){if(!(r==="="||r==="!"||r==="!="))return null;switch(c=c.trim().toLowerCase(),c){case"null":s=n.isNull();break;case"nan":s=E.FilterCondition.invoke("isNaN",n);break;case"infinity":case"inf":case"\u221E":l!=null?s=E.FilterCondition.invoke("isInf",n).and(n.lessThan(E.FilterValue.ofNumber(0))):s=E.FilterCondition.invoke("isInf",n).and(n.greaterThan(E.FilterValue.ofNumber(0)));break}return s!==null&&(r==="!"||r==="!=")&&(s=s.not()),s}if(a==null)return null;if(a=X.removeCommas(a),X.isLongType(e.type))try{a=E.FilterValue.ofNumber(E.LongWrapper.ofString(`${l!=null?"-":""}${a}`))}catch(u){return Zt.warn("Unable to create long filter",u),null}else{if(a=parseFloat(a),a==null||Number.isNaN(a))return null;a=E.FilterValue.ofNumber(l!=null?0-a:a)}return s=e.filter(),X.makeRangeFilterWithOperation(s,r,a)}static makeQuickTextFilter(e,t){if(t==null)return null;const n=`${t}`.trim(),o=/^(!~|!=|~|=|!)?(.*)/.exec(n);let i=null,r=null;if(o!==null&&o.length>2&&([,i,r]=o,r!=null&&(r=r.trim())),r==null||r.length===0)return null;i==null&&(i="=");const l=e.filter();if(r.toLowerCase()==="null")switch(i){case"=":return l.isNull();case"!=":case"!":return l.isNull().not()}let a=null,c=null;switch(r.startsWith("*")?(a="*",r=r.substring(1)):r.endsWith("*")&&!r.endsWith("\\*")&&(c="*",r=r.substring(0,r.length-1)),r=r.replace("\\",""),i){case"~":return l.isNull().not().and(l.invoke("matches",E.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E.*`)));case"!~":return l.isNull().or(l.invoke("matches",E.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E.*`)).not());case"!=":return a==="*"?l.isNull().or(l.invoke("matches",E.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E$`)).not()):c==="*"?l.isNull().or(l.invoke("matches",E.FilterValue.ofString(`(?s)(?i)^\\Q${r}\\E.*`)).not()):l.notEqIgnoreCase(E.FilterValue.ofString(r.toLowerCase()));case"=":return a==="*"?l.isNull().not().and(l.invoke("matches",E.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E$`))):c==="*"?l.isNull().not().and(l.invoke("matches",E.FilterValue.ofString(`(?s)(?i)^\\Q${r}\\E.*`))):l.eqIgnoreCase(E.FilterValue.ofString(r.toLowerCase()))}return null}static makeQuickBooleanFilter(e,t){if(t==null)return null;const s=/^(!=|=|!)?(.*)/.exec(`${t}`.trim());if(s===null)return null;const[,o,i]=s,r=o==="!"||o==="!=",l=i.trim().toLowerCase();let a=e.filter();try{const c=X.makeBooleanValue(l);return c!=null&&c?a=a.isTrue():c===null?a=a.isNull():a=a.isFalse(),r?a.not():a}catch{return null}}static makeQuickDateFilter(e,t,n){const s=t.trim(),i=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/.exec(s);if(i==null||i.length<=2)throw new Error(`Unable to parse date filter: ${t}`);let r=null,l=null;[,r,l]=i;let a=P.eq;switch(r){case"<":a=P.lessThan;break;case"<=":case"=<":a=P.lessThanOrEqualTo;break;case">":a=P.greaterThan;break;case">=":case"=>":a=P.greaterThanOrEqualTo;break;case"!=":case"!":a=P.notEq;break;case"=":case"==":default:a=P.eq;break}return X.makeQuickDateFilterWithOperation(e,l,a,n)}static makeQuickDateFilterWithOperation(e,t,n,s){if(e==null)throw new Error("Column is null");const[o,i]=qt.parseDateRange(t,s),r=o!=null?E.FilterValue.ofNumber(o):null,l=i!=null?E.FilterValue.ofNumber(i):null,a=e.filter();if(r==null)return n===P.notEq?a.isNull().not():a.isNull();switch(n){case P.eq:{if(l!=null){const c=a.greaterThanOrEqualTo(r),d=a.lessThan(l);return c.and(d)}return a.eq(r)}case P.lessThan:return a.lessThan(r);case P.lessThanOrEqualTo:return l!=null?a.lessThan(l):a.lessThanOrEqualTo(r);case P.greaterThan:return l!=null?a.greaterThanOrEqualTo(l):a.greaterThan(r);case P.greaterThanOrEqualTo:return a.greaterThanOrEqualTo(r);case P.notEq:{if(l!=null){const c=a.lessThan(r),d=a.greaterThanOrEqualTo(l);return c.or(d)}return a.notEq(r)}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(),o=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/.exec(n);let i=null,r=null,l=null;if(o!==null&&o.length>3&&([,i,r,l]=o),l!=null&&l.trim().length>0||r==null||r.length===0)return null;i==null&&(i="=");const a=e.filter();if(r.toLowerCase()==="null")switch(i){case"=":return a.isNull();case"!=":case"!":return a.isNull().not();default:return null}const c=E.FilterValue.ofString(X.isRangeOperation(i)?X.quoteValue(r):r);return X.makeRangeFilterWithOperation(a,i,c)}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 ze.makeCancelable(e,t=>{t.close()})}static makeCancelableTableEventPromise(e,t,n=0,s=null){let o,i,r=!0;const l=new Promise((a,c)=>{i=setTimeout(()=>{o(),r=!1,c(new il(`Event "${t}" timed out.`))},n),o=e.addEventListener(t,d=>{if(s!=null&&!s(d)){Zt.debug2("Event triggered, but matcher returned false.");return}Zt.debug2("Event triggered, resolving."),o(),clearTimeout(i),r=!1,a(d)})});return l.cancel=()=>{if(r){Zt.debug2("Pending promise cleanup."),o(),clearTimeout(i),r=!1;return}Zt.debug2("Ignoring non-pending promise cancel.")},l}static makeAdvancedFilter(e,t,n){const{filterItems:s,filterOperators:o,invertSelection:i,selectedValues:r}=t;let l=null;for(let c=0;c<s.length;c+=1){const d=s[c],{selectedType:u,value:h}=d;if(u!=null&&u.length>0&&h!=null&&h.length>0)try{const g=X.makeAdvancedValueFilter(e,u,h,n);if(g!=null){if(c===0)l=g;else if(l!==null&&c-1<o.length){const p=o[c-1];if(p===Gt.and)l=l.and(g);else if(p===Gt.or)l=l.or(g);else{Zt.error("Unexpected filter operator",p,g),l=null;break}}}else Zt.debug2("Empty filter ignored for",u,h)}catch(g){Zt.error("Unable to create filter",g),l=null;break}}const a=X.makeSelectValueFilter(e,r,i);return a!=null&&(l!=null?l=l.and(a):l=a),l}static removeCommas(e){return e.replace(/[\s|,]/g,"")}static makeFilterValue(e,t){const n=X.getBaseType(e);return X.isTextType(n)?E.FilterValue.ofString(t):X.isLongType(n)?E.FilterValue.ofNumber(E.LongWrapper.ofString(X.removeCommas(t))):E.FilterValue.ofNumber(X.removeCommas(t))}static makeFilterRawValue(e,t){return X.isTextType(e)?E.FilterValue.ofString(t):X.isBooleanType(e)?E.FilterValue.ofBoolean(t):E.FilterValue.ofNumber(t)}static makeValue(e,t,n){if(t==null||t==="null")return null;if(X.isTextType(e))return t;if(X.isLongType(e))return E.LongWrapper.ofString(X.removeCommas(t));if(X.isBooleanType(e))return X.makeBooleanValue(t,!0);if(X.isDateType(e)){const[s]=qt.parseDateRange(t,n);return s}return X.isNumberType(e)?X.makeNumberValue(t):(Zt.error("Unexpected column type",e),null)}static makeBooleanValue(e,t=!1){if(e===""&&t)return null;switch(e==null?void 0: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==="\u221E"||t==="infinity"||t==="inf")return Number.POSITIVE_INFINITY;if(t==="-\u221E"||t==="-infinity"||t==="-inf")return Number.NEGATIVE_INFINITY;const n=X.removeCommas(t);if(X.NUMBER_REGEX.test(n))return parseFloat(n);throw new Error(`Invalid number '${e}'`)}static getFilterOperatorString(e){switch(e){case P.eq:return"=";case P.notEq:return"!=";case P.greaterThan:return">";case P.greaterThanOrEqualTo:return">=";case P.lessThan:return"<";case P.lessThanOrEqualTo:return"<=";case P.contains:return"~";case P.notContains:return"!~";default:throw new Error(`Unexpected filter type ${e}`)}}static makeAdvancedValueFilter(e,t,n,s){if(X.isDateType(e.type))return X.makeQuickDateFilterWithOperation(e,n,t,s);if(X.isNumberType(e.type)||X.isCharType(e.type))return X.makeQuickFilter(e,`${X.getFilterOperatorString(t)}${n}`);const o=X.makeFilterValue(e.type,n),i=e.filter();switch(t){case P.eq:return i.eq(o);case P.eqIgnoreCase:return i.eqIgnoreCase(o);case P.notEq:return i.notEq(o);case P.notEqIgnoreCase:return i.notEqIgnoreCase(o);case P.greaterThan:return i.greaterThan(o);case P.greaterThanOrEqualTo:return i.greaterThanOrEqualTo(o);case P.lessThan:return i.lessThan(o);case P.lessThanOrEqualTo:return i.lessThanOrEqualTo(o);case P.isTrue:return i.isTrue();case P.isFalse:return i.isFalse();case P.isNull:return i.isNull();case P.contains:return i.isNull().not().and(i.invoke("matches",E.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)));case P.notContains:return i.isNull().or(i.invoke("matches",E.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)).not());case P.startsWith:return i.isNull().not().and(i.invoke("matches",E.FilterValue.ofString(`(?s)(?i)^\\Q${n}\\E.*`)));case P.endsWith:return i.isNull().not().and(i.invoke("matches",E.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E$`)));case P.in:case P.inIgnoreCase:case P.notIn:case P.notInIgnoreCase:case P.invoke:default:throw new Error(`Unexpected filter operation: ${t}`)}}static makeSelectValueFilter(e,t,n){if(t.length===0){if(n)return null;let i=null;X.isTextType(e.type)?i=E.FilterValue.ofString("a"):X.isBooleanType(e.type)?i=E.FilterValue.ofBoolean(!0):X.isDateType(e.type)?i=E.FilterValue.ofNumber(E.DateWrapper.ofJsDate(new Date)):i=E.FilterValue.ofNumber(0);const r=e.filter().eq(i),l=e.filter().notEq(i);return r.and(l)}const s=[];let o=!1;for(let i=0;i<t.length;i+=1){const r=t[i];r==null?o=!0:X.isTextType(e.type)?s.push(E.FilterValue.ofString(typeof r=="number"?String.fromCharCode(r):r)):X.isBooleanType(e.type)?s.push(E.FilterValue.ofBoolean(Boolean(r))):s.push(E.FilterValue.ofNumber(r))}return o?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 o=n.name.toUpperCase(),i=s.name.toUpperCase();return Wi.sort(o,i,t)})}};let N=X;N.dataType={BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"};N.sortDirection={ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null};N.REVERSE_TYPE=Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"});N.NUMBER_REGEX=/^-?\d+(\.\d+)?$/;class zt{static makeColumnFormatMap(t){return t==null?new Map:t.reduce((n,s)=>{const o=N.getNormalizedType(s.columnType);if(o===null)return n;n.has(o)||n.set(o,new Map);const i=n.get(o);return i==null||i.set(s.columnName,s.format),n},new Map)}static makeColumnFormattingRule(t,n,s){return{columnType:t,columnName:n,format:s}}constructor(t=[],n,s,o,i=!1){this.defaultColumnFormatter=new Od,this.typeFormatterMap=new Map([[N.dataType.BOOLEAN,new Nd],[N.dataType.CHAR,new Ad],[N.dataType.DATETIME,new kn(n)],[N.dataType.DECIMAL,new Ve(s)],[N.dataType.INT,new It(o)],[N.dataType.STRING,new kd]]),this.columnFormatMap=zt.makeColumnFormatMap(t),this.truncateNumbersWithPound=i}getColumnFormatMapForType(t,n=!1){const s=N.getNormalizedType(t);if(s!==null)return n&&!this.columnFormatMap.has(s)&&this.columnFormatMap.set(s,new Map),this.columnFormatMap.get(s)}getColumnFormat(t,n){var o;const s=this.getColumnFormatMapForType(t);return(o=s==null?void 0:s.get(n))!=null?o:null}getColumnTypeFormatter(t){var o;const n=N.getNormalizedType(t);let s=this.defaultColumnFormatter;return n&&(s=(o=this.typeFormatterMap.get(n))!=null?o:s),s}getFormattedString(t,n,s="",o){if(t==null)return"";const i=this.getColumnTypeFormatter(n),r=o||this.getColumnFormat(n,s);return i.format(t,r!=null?r:void 0)}get timeZone(){var n;const t=this.typeFormatterMap.get(N.dataType.DATETIME);return(n=t==null?void 0:t.dhTimeZone)==null?void 0:n.id}}function Ud(e){if(e&&e.formatter){const{formatter:t}=e;return t}}function Bd(e){return{timeZone:e==null?void 0:e.timeZone,defaultDateTimeFormatString:e==null?void 0:e.defaultDateTimeFormat,showTimeZone:e==null?void 0:e.showTimeZone,showTSeparator:e==null?void 0:e.showTSeparator}}function Gd(e,t,n){const s=e.getColumnFormat(n,t);return s!=null&&(s.type===_e.TYPE_CONTEXT_PRESET||s.type===_e.TYPE_CONTEXT_CUSTOM)}const Jn={getColumnFormats:Ud,getDateTimeFormatterOptions:Bd,isCustomColumnFormatDefined:Gd};function Wd(e,t){const n=qd(e);return n===void 0?void 0:`${Zd(e)} ? ${n} : ${t}`}function $d(e){return dh.Column.formatRowColor(e)}function zd(e,t){return e.formatColor(t)}const qs=le.module("ConditionalFormattingUtils");var Yt=(e=>(e.CONDITIONAL="conditional",e.ROWS="rows",e))(Yt||{}),Ae=(e=>(e.IS_EQUAL="is-equal",e.IS_NOT_EQUAL="is-not-equal",e.IS_BETWEEN="is-between",e.GREATER_THAN="greater-than",e.GREATER_THAN_OR_EQUAL="greater-than-or-equal",e.LESS_THAN="less-than",e.LESS_THAN_OR_EQUAL="less-than-or-equal",e.IS_NULL="is-null",e.IS_NOT_NULL="is-not-null",e))(Ae||{}),mt=(e=>(e.IS_EXACTLY="is-exactly",e.IS_NOT_EXACTLY="is-not-exactly",e.CONTAINS="contains",e.DOES_NOT_CONTAIN="does-not-contain",e.STARTS_WITH="starts-with",e.ENDS_WITH="ends-with",e.IS_NULL="is-null",e.IS_NOT_NULL="is-not-null",e))(mt||{}),ot=(e=>(e.IS_EXACTLY="is-exactly",e.IS_NOT_EXACTLY="is-not-exactly",e.IS_BEFORE="is-before",e.IS_BEFORE_OR_EQUAL="is-before-or-equal",e.IS_AFTER="is-after",e.IS_AFTER_OR_EQUAL="is-after-or-equal",e.IS_NULL="is-null",e.IS_NOT_NULL="is-not-null",e))(ot||{}),Bs=(e=>(e.IS_TRUE="is-true",e.IS_FALSE="is-false",e.IS_NULL="is-null",e.IS_NOT_NULL="is-not-null",e))(Bs||{}),Kn=(e=>(e.IS_EQUAL="is-equal",e.IS_NOT_EQUAL="is-not-equal",e.IS_NULL="is-null",e.IS_NOT_NULL="is-not-null",e))(Kn||{}),Ft=(e=>(e.NO_FORMATTING="no-formatting",e.POSITIVE="positive",e.NEGATIVE="negative",e.WARN="warn",e.NEUTRAL="neutral",e.ACCENT_1="accent-1",e.ACCENT_2="accent-2",e.CUSTOM="custom",e))(Ft||{});function Mr(e){switch(e){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 _o(e){const{type:t,customConfig:n}=e;switch(t){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 n==null?void 0:n.background;default:return}}function Ho(e){const{type:t,customConfig:n}=e;switch(t){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 n==null?void 0:n.color;default:return}}function qd(e){const t=Ho(e.style),n=_o(e.style);if(!(t===void 0||n===void 0))return`bgfg(\`${n}\`, \`${t}\`)`}function Yd(e){const{column:t,value:n,start:s,end:o}=e;return cu(t.name,e.condition,n,s,o)}function Xd(e){const{column:t,value:n}=e;return du(t.name,e.condition,n)}function Kd(e){const{column:t,value:n}=e;return uu(t.name,e.condition,n)}function Qd(e){const{column:t}=e;return hu(t.name,e.condition)}function jd(e){const{column:t,value:n}=e;return mu(t.name,e.condition,n)}function Zd(e){const{column:t}=e;if(N.isNumberType(t.type))return Yd(e);if(N.isCharType(t.type))return jd(e);if(N.isStringType(t.type))return Xd(e);if(N.isDateType(t.type))return Kd(e);if(N.isBooleanType(t.type))return Qd(e);throw new Error("Invalid column type")}function Jd(e){switch(e){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 eu(e){switch(e){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 tu(e){switch(e){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 nu(e){switch(e){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 su(e){switch(e){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 El(e){if(N.isNumberType(e)||N.isCharType(e))return"is-equal";if(N.isStringType(e)||N.isDateType(e))return"is-exactly";if(N.isBooleanType(e))return"is-true";throw new Error("Invalid column type")}function vl(e){if(N.isCharType(e)||N.isStringType(e))return""}function Rl(e){const{condition:t,value:n,start:s,end:o}=e;return{condition:t,value:n,start:s,end:o}}function Zo(e){return{condition:El(e),value:vl(e),start:void 0,end:void 0}}function yl(){return{type:"no-formatting"}}function ou(e){switch(e){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 iu(e){switch(e){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 ru(e){switch(e){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 lu(e){switch(e){case"is-equal":return"==";case"is-not-equal":return"!=";case"is-null":return"is null";case"is-not-null":return"is not null"}}function au(e){switch(e){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 cu(e,t,n,s,o){switch(t){case"is-equal":return`${e} == ${n}`;case"is-not-equal":return`${e} != ${n}`;case"is-between":return`${e} > ${s} && ${e} < ${o}`;case"greater-than":return`${e} > ${n}`;case"greater-than-or-equal":return`${e} >= ${n}`;case"less-than":return`${e} < ${n}`;case"less-than-or-equal":return`${e} <= ${n}`;case"is-null":return`${e} == null`;case"is-not-null":return`${e} != null`}}function du(e,t,n){switch(t){case"is-exactly":return`${e} == "${n}"`;case"is-not-exactly":return`${e} != "${n}"`;case"contains":return`${e} != null && ${e}.contains("${n}")`;case"does-not-contain":return`${e} != null && !${e}.contains("${n}")`;case"starts-with":return`${e} != null && ${e}.startsWith("${n}")`;case"ends-with":return`${e} != null && ${e}.endsWith("${n}")`;case"is-null":return`${e} == null`;case"is-not-null":return`${e} != null`}}function uu(e,t,n){switch(t){case"is-exactly":return`${e} == convertDateTime("${n}")`;case"is-not-exactly":return`${e} != convertDateTime(\`${n}\`)`;case"is-before":return`${e} < convertDateTime(\`${n}\`)`;case"is-before-or-equal":return`${e} <= convertDateTime("${n}")`;case"is-after":return`${e} > convertDateTime(\`${n}\`)`;case"is-after-or-equal":return`${e} >= convertDateTime(\`${n}\`)`;case"is-null":return`${e} == null`;case"is-not-null":return`${e} != null`}}function hu(e,t){switch(t){case"is-true":return`${e} == true`;case"is-false":return`${e} == false`;case"is-null":return`${e} == null`;case"is-not-null":return`${e} != null`}}function mu(e,t,n){switch(t){case"is-equal":return`${e} == '${n}'`;case"is-not-equal":return`${e} != '${n}'`;case"is-null":return`isNull(${e})`;case"is-not-null":return`!isNull(${e})`}}function gu(e,t){if(N.isNumberType(e))return au(t);if(N.isCharType(e))return lu(t);if(N.isStringType(e))return ou(t);if(N.isDateType(e))return iu(t);if(N.isBooleanType(e))return ru(t);throw new Error("Invalid column type")}function pu(e,t){if(t===void 0)return qs.debug("no rules passed."),[];const n=[];let s;const o=new Map;return t.forEach(({config:i,type:r})=>{var p;const{column:l}=i,a=e.find(({name:f,type:C})=>f===l.name&&C===l.type);if(a===void 0){qs.debug(`Column ${l.name}:${l.type} not found. Ignoring format rule.`,i);return}const[c,d]=(p=r==="conditional"?o.get(a.name):s)!=null?p:["null",void 0],u=Wd(i,c);if(u===void 0){qs.debug("Ignoring format rule.",i);return}const h=d===void 0?-1:n.indexOf(d);h>-1&&n.splice(h,1);const g=r==="conditional"?zd(a,u):$d(u);n.push(g),r==="conditional"?o.set(a.name,[u,g]):s=[u,g]}),n}function fu(e,t){switch(e){case"is-null":case"is-not-null":return!0;default:{const[n,...s]=(t!=null?t:"").split(" "),o=s.join(" ");try{qt.parseDateTimeString(n)}catch{return qs.debug("Invalid datetime string",n),!1}try{dh.i18n.TimeZone.getTimeZone(o)}catch{return qs.debug("Invalid timezone string",o),!1}return!0}}}function Cu({type:e}){return N.isNumberType(e)||N.isCharType(e)||N.isStringType(e)||N.isDateType(e)||N.isBooleanType(e)}function Jo({animation:e="iris-grid-bottom-bar-slide-up",children:t,className:n,isShown:s,onClick:o,onEntering:i,onEntered:r,onExiting:l,onExited:a}){return m($t,{in:s,timeout:We.transitionMs,classNames:e,onEntering:i,onEntered:r,onExiting:l,onExited:a,mountOnEnter:!0,unmountOnExit:!0,children:m("div",{className:Z("iris-grid-bottom-bar",n),role:"presentation",onClick:o,onKeyPress:o,children:t})})}const wu=3e3,Su=5;function Tu({isSaving:e=!1,onSave:t,onDiscard:n,discardTooltip:s,saveTooltip:o,error:i,pendingDataErrors:r,pendingDataMap:l,onEntering:a,onEntered:c,onExiting:d,onExited:u}){const[h,g]=F.exports.useState(!1),[p,f]=F.exports.useState(!1),C=F.exports.useRef(),w=$i(e),S=F.exports.useMemo(()=>r.size===0?i:r.size<=Su?`Key can't be empty (on pending row${r.size>1?"s":""} ${Array.from(r.keys()).join(", ").trim()})`:`Key can't be empty (on ${r.size} rows)`,[i,r]);F.exports.useEffect(function(){w!=null&&w&&!e&&S==null&&(g(!0),f(!0),C.current=setTimeout(()=>{g(!1)},wu))},[S,e,w]),F.exports.useEffect(function(){C.current&&l.size>0&&(clearTimeout(C.current),g(!1),f(!1))},[l]),F.exports.useEffect(function(){return()=>C.current?clearTimeout(C.current):void 0},[]);const b=l.size;let v;return e?v=m(dn,{}):p&&(v=rl),y(Jo,{className:"pending-data-bottom-bar",isShown:b>0||h||S!=null,onEntering:a,onEntered:c,onExiting:d,onExited:()=>{f(!1),u&&u()},children:[S!=null&&S!==""&&y("div",{className:"error-message",children:[m(J,{icon:Qn}),m("span",{children:`${S}`})]}),(S==null||S==="")&&m("div",{className:"status-message",children:b>0&&m("span",{children:`${b} row${b>1?"s":""} pending`})}),y("div",{className:"buttons-container",children:[!e&&!p&&m(z,{kind:"secondary",onClick:n,tooltip:s,children:"Discard"}),y(z,{kind:p?"success":"primary",onClick:t,icon:v,disabled:e||p||S!=null,tooltip:o,children:[e&&"Committing...",!e&&p&&"Success",!e&&!p&&"Commit"]})]})]})}var be=(e=>(e.COUNT="Count",e.MIN="Min",e.MAX="Max",e.SUM="Sum",e.ABS_SUM="AbsSum",e.VAR="Var",e.AVG="Avg",e.STD="Std",e.FIRST="First",e.LAST="Last",e.SKIP="Skip",e.COUNT_DISTINCT="CountDistinct",e.DISTINCT="Distinct",e.UNIQUE="Unique",e))(be||{});const bu=e=>{switch(e){default:return!1}},Eu=(e,t)=>{switch(e){case be.COUNT:case be.FIRST:case be.LAST:case be.COUNT_DISTINCT:case be.DISTINCT:case be.UNIQUE:return!0;case be.MIN:case be.MAX:return N.isNumberType(t)||N.isDateType(t)||N.isTextType(t);case be.SUM:case be.ABS_SUM:case be.VAR:case be.AVG:case be.STD:return N.isNumberType(t);case be.SKIP:return!1}},Qi=(e,t)=>e.filter(n=>Eu(t,n.type)),vu=(e,t,n,s)=>Qi(e,t).map(({name:o})=>o).filter(o=>n.includes(o)?!s:s),On={isRollupOperation:bu,filterValidColumns:Qi,getOperationColumnNames:vu};var ns=(e=>(e.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS="filter-control-change-clears-all-filters",e.LINK_CHANGE_CLEARS_ALL_FILTERS="link-change-clears-all-filters",e))(ns||{});const Ru=Object.freeze([[ns.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS,!1],[ns.LINK_CHANGE_CLEARS_ALL_FILTERS,!1]]),yu={DEFAULTS:Ru},Fu=le.module("ColumnHeaderGroup");function gi(e){return e instanceof Bt}const Fl=class{constructor({name:e,children:t,color:n,depth:s,childIndexes:o,parent:i}){this.getVisibleRange=Fe(r=>{const l=this.childIndexes.flat(),a=_.getVisibleIndexes(l,r),c=Math.min(...a),d=Math.max(...a);return d-c!==l.length-1&&Fu.warn(`Column header group ${this.name} is not contiguous`),[c,d]}),this.name=e,this.children=t,this.color=n,this.depth=s,this.childIndexes=o,this.parent=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(Fl.NEW_GROUP_PREFIX)}};let Bt=Fl;Bt.NEW_GROUP_PREFIX=":newGroup";const Ls=le.module("IrisGridUtils");function Tn(e,t){return e>=0&&e<t.length}function Du(e){return e.asDate!=null}class Q{static dehydrateGridState(t,n){const{isStuckToBottom:s,isStuckToRight:o,movedColumns:i,movedRows:r}=n,{columns:l}=t;return{isStuckToBottom:s,isStuckToRight:o,movedColumns:[...i].filter(({to:a,from:c})=>Tn(a,l)&&(typeof c=="number"&&Tn(c,l)||Array.isArray(c)&&Tn(c[0],l)&&Tn(c[1],l))).map(({to:a,from:c})=>({to:l[a].name,from:Array.isArray(c)?[l[c[0]].name,l[c[1]].name]:l[c].name})),movedRows:[...r]}}static hydrateGridState(t,n,s=[]){const{isStuckToBottom:o,isStuckToRight:i,movedColumns:r,movedRows:l}=n,{columns:a}=t,c=Q.parseCustomColumnNames(s),d=a.map(({name:u})=>u).concat(c);return{isStuckToBottom:o,isStuckToRight:i,movedColumns:[...r].map(({to:u,from:h})=>{const g=p=>typeof p=="string"?d.findIndex(f=>f===p):p;return{to:g(u),from:Array.isArray(h)?[g(h[0]),g(h[1])]:g(h)}}).filter(({to:u,from:h})=>Tn(u,d)&&(typeof h=="number"&&Tn(h,d)||Array.isArray(h)&&Tn(h[0],d)&&Tn(h[1],d))),movedRows:[...l]}}static dehydrateIrisGridState(t,n){const{aggregationSettings:s={aggregations:ye,showOnTop:!1},advancedFilters:o,customColumnFormatMap:i,isFilterBarShown:r,metrics:l,quickFilters:a,customColumns:c,conditionalFormats:d=ye,reverseType:u,rollupConfig:h=void 0,showSearchBar:g,searchValue:p,selectDistinctColumns:f=ye,selectedSearchColumns:C,sorts:w,invertSearchColumns:S,pendingDataMap:b=rn,frozenColumns:v,columnHeaderGroups:T}=n;M(l);const{userColumnWidths:R,userRowHeights:D}=l,{columns:A}=t;return{advancedFilters:Q.dehydrateAdvancedFilters(A,o),aggregationSettings:s,customColumnFormatMap:[...i],isFilterBarShown:r,quickFilters:Q.dehydrateQuickFilters(a),sorts:Q.dehydrateSort(w),userColumnWidths:[...R].filter(([I])=>I!=null&&I>=0&&I<A.length).map(([I,L])=>[A[I].name,L]),userRowHeights:[...D],customColumns:[...c],conditionalFormats:[...d],reverseType:u,rollupConfig:h,showSearchBar:g,searchValue:p,selectDistinctColumns:[...f],selectedSearchColumns:C,invertSearchColumns:S,pendingDataMap:Q.dehydratePendingDataMap(A,b),frozenColumns:v,columnHeaderGroups:T==null?void 0:T.map(I=>({name:I.name,children:I.children,color:I.color}))}}static hydrateIrisGridState(t,n){var I,L;const{advancedFilters:s,aggregationSettings:o={aggregations:[],showOnTop:!1},customColumnFormatMap:i,isFilterBarShown:r,quickFilters:l,sorts:a,customColumns:c,conditionalFormats:d,userColumnWidths:u,userRowHeights:h,reverseType:g,rollupConfig:p=void 0,showSearchBar:f,searchValue:C,selectDistinctColumns:w,selectedSearchColumns:S,invertSearchColumns:b=!0,pendingDataMap:v=[],frozenColumns:T,columnHeaderGroups:R}=n,{columns:D,formatter:A}=t;return{advancedFilters:Q.hydrateAdvancedFilters(D,s,A.timeZone),aggregationSettings:o,customColumnFormatMap:new Map(i),isFilterBarShown:r,quickFilters:Q.hydrateQuickFilters(D,l,A.timeZone),sorts:Q.hydrateSort(D,a),userColumnWidths:new Map(u.map(([k,x])=>typeof k=="string"||k instanceof String?[D.findIndex(({name:W})=>W===k),x]:[k,x]).filter(([k])=>k!=null&&k>=0&&k<D.length)),customColumns:c,conditionalFormats:d,userRowHeights:new Map(h),reverseType:g,rollupConfig:p,showSearchBar:f,searchValue:C,selectDistinctColumns:w,selectedSearchColumns:S,invertSearchColumns:b,pendingDataMap:Q.hydratePendingDataMap(D,v),frozenColumns:T,columnHeaderGroups:Q.parseColumnHeaderGroups(t,(L=R!=null?R:(I=t.layoutHints)==null?void 0:I.columnGroups)!=null?L:[]).groups}}static dehydrateIrisGridPanelState(t,n){const{isSelectingPartition:s,partition:o,partitionColumn:i,advancedSettings:r}=n;return{isSelectingPartition:s,partition:o,partitionColumn:i!=null?i.name:void 0,advancedSettings:[...r]}}static hydrateIrisGridPanelState(t,n){const{isSelectingPartition:s,partition:o,partitionColumn:i,advancedSettings:r}=n,{columns:l}=t;return{isSelectingPartition:s,partition:o,partitionColumn:i!=null?Q.getColumnByName(l,i):void 0,advancedSettings:new Map([...yu.DEFAULTS,...r])}}static dehydrateQuickFilters(t){return[...t].map(([n,s])=>{const{text:o}=s;return[n,{text:o}]})}static hydrateQuickFilters(t,n,s){const o=n.map(([i,r])=>{const{text:l}=r;let a=null;try{const c=Q.getColumn(t,i);c!=null&&(a=N.makeQuickFilter(c,l,s))}catch(c){Ls.error("hydrateQuickFilters error with",l,c)}return[i,{text:l,filter:a}]});return new Map(o)}static dehydrateAdvancedFilters(t,n){return[...n].map(([s,o])=>{const i=Q.getColumn(t,s);M(i);const r=Q.dehydrateAdvancedFilterOptions(i,o.options);return[s,{options:r}]})}static hydrateAdvancedFilters(t,n,s){const o=n.map(([i,r])=>{const l=Q.getColumn(t,i);M(l);const a=Q.hydrateAdvancedFilterOptions(l,r.options);let c=null;try{Q.getColumn(t,i)!=null&&(c=N.makeAdvancedFilter(l,a,s))}catch(d){Ls.error("hydrateAdvancedFilters error with",a,d)}return[i,{options:a,filter:c}]});return new Map(o)}static dehydrateAdvancedFilterOptions(t,n){const{selectedValues:s,...o}=n;return{selectedValues:s==null?void 0:s.map(i=>Q.dehydrateValue(i,t==null?void 0:t.type)),...o}}static hydrateAdvancedFilterOptions(t,n){const{selectedValues:s,...o}=n;return{selectedValues:s==null?void 0:s.map(i=>Q.hydrateValue(i,t==null?void 0:t.type)),...o}}static dehydratePendingDataMap(t,n){return[...n].map(([s,{data:o}])=>[s,{data:[...o].map(([i,r])=>[t[i].name,Q.dehydrateValue(r,t[i].type)])}])}static hydratePendingDataMap(t,n){const s=new Map,o=i=>(s.has(i)||s.set(i,t.findIndex(({name:r})=>r===i)),s.get(i));return new Map(n.map(([i,{data:r}])=>[i,{data:new Map(r.map(([l,a])=>{var d;const c=o(l);return M(c),[(d=o(l))!=null?d:null,Q.hydrateValue(a,t[c].type)]}))}]))}static dehydrateValue(t,n){return N.isDateType(n)?Q.dehydrateDateTime(t):N.isLongType(n)?Q.dehydrateLong(t):t}static hydrateValue(t,n){return N.isDateType(n)?Q.hydrateDateTime(t):N.isLongType(n)?Q.hydrateLong(t):t}static dehydrateDateTime(t){return t!=null?E.i18n.DateTimeFormat.format(qt.FULL_DATE_FORMAT,t):null}static hydrateDateTime(t){return t!=null?E.i18n.DateTimeFormat.parse(qt.FULL_DATE_FORMAT,t):null}static dehydrateLong(t){return t!=null?`${t}`:null}static hydrateLong(t){return t!=null?E.LongWrapper.ofString(t):null}static dehydrateSort(t){return t.map(n=>{const{column:s,isAbs:o,direction:i}=n;return{column:s.index,isAbs:o,direction:i}})}static hydrateSort(t,n){return n.map(s=>{const{column:o,isAbs:i,direction:r}=s;if(r===N.sortDirection.reverse)return E.Table.reverse();const l=Q.getColumn(t,o);if(l!=null){let a=l.sort();return i&&(a=a.abs()),r===N.sortDirection.descending?a=a.desc():a=a.asc(),a}return null}).filter(s=>s!=null&&s.direction!==N.sortDirection.reverse)}static extractTableSettings(t,n=[]){const{irisGridPanelState:s,irisGridState:o}=t,{partitionColumn:i,partition:r}=s,{advancedFilters:l,quickFilters:a,sorts:c}=o;return{advancedFilters:l,inputFilters:n,partition:r,partitionColumn:i,quickFilters:a,sorts:c}}static applyTableSettings(t,n,s){const{columns:o}=t;let i=[];n.quickFilters&&(i=Q.getFiltersFromFilterMap(Q.hydrateQuickFilters(o,n.quickFilters,s)));let r=[];n.advancedFilters&&(r=Q.getFiltersFromFilterMap(Q.hydrateAdvancedFilters(o,n.advancedFilters,s)));const l=Q.getFiltersFromInputFilters(o,n.inputFilters,s);let a=[];n.sorts&&(a=Q.hydrateSort(o,n.sorts));let c=[...i,...r];const{partition:d,partitionColumn:u}=n;if(d!=null&&u!=null){const h=Q.getColumnByName(o,u);h&&(c=[h.filter().eq(E.FilterValue.ofString(d)),...c])}c=[...l,...c],t.applyFilter(c),t.applySort(a)}static getInputFiltersForColumns(t,n=[]){return n.filter(({name:s,type:o})=>t.find(({name:i,type:r})=>i===s&&r===o))}static getFiltersFromInputFilters(t,n=[],s){return n.map(({name:o,type:i,value:r})=>{const l=t.find(({name:a,type:c})=>a===o&&c===i);if(l)try{return N.makeQuickFilter(l,r,s)}catch(a){Ls.debug("Unable to create input filter",a)}return null}).filter(o=>o!=null)}static getFiltersFromFilterMap(t){const n=[],s=Array.from(t.keys());for(let o=0;o<s.length;o+=1){const i=s[o],r=t.get(i);(r==null?void 0:r.filter)!=null&&n.push(r.filter)}return n}static getHiddenColumns(t){return[...t.entries()].filter(([,n])=>n===0).map(([n])=>n)}static parseCustomColumnNames(t){return t.map(n=>n.split("=")[0])}static getRemovedCustomColumnNames(t,n){const s=Q.parseCustomColumnNames(t),o=Q.parseCustomColumnNames(n);return s.filter(i=>!o.includes(i))}static removeSortsInColumns(t,n){return t.filter(s=>!n.includes(s.column.name))}static removeFiltersInColumns(t,n,s){const o=t.map(({name:r})=>r),i=new Map(n);return s.forEach(r=>i.delete(o.indexOf(r))),i}static removeColumnFromMovedColumns(t,n,s){const o=t.map(({name:r})=>r);let i=[...n];for(let r=0;r<s.length;r+=1){const l=s[r];let a=o.findIndex(d=>d===l);const c=[];for(let d=0;d<i.length;d+=1){const u=i[d],h={...u};let[g,p]=Array.isArray(u.from)?u.from:[u.from,u.from];a<=u.to&&(h.to-=1),a<g&&(g-=1),a<=p&&(p-=1),g<=p&&g!==h.to&&(g===p?c.push({...h,from:g}):c.push({...h,from:[g,p]})),a=_.applyItemMoves(a,a,[u])[0][0]}i=c,o.splice(o.findIndex(d=>d===l),1)}return i}static removeColumnsFromSelectDistinctColumns(t,n){return t.filter(s=>!n.includes(s))}static getVisibleColumnsInRange(t,n,s,o,i){const r=[];for(let l=n;l<=s;l+=1){const a=_.getModelIndex(l,o);a>=0&&a<t.length&&!i.includes(a)&&r.push(t[a])}return r}static getPrevVisibleColumns(t,n,s,o,i){const r=[];let l=n;for(;l>=0&&r.length<s;){const a=_.getModelIndex(l,o);a>=0&&a<t.length&&!i.includes(a)&&r.unshift(t[a]),l-=1}return r}static getNextVisibleColumns(t,n,s,o,i){const r=[];let l=n;for(;l<t.length&&r.length<s;){const a=_.getModelIndex(l,o);a>=0&&a<t.length&&!i.includes(a)&&r.push(t[a]),l+=1}return r}static getColumnsToFetch(t,n,s){const o=[...n];return s.forEach(i=>{const r=t.find(({name:l})=>l===i);r!=null&&!n.includes(r)&&o.push(r)}),o}static getModelViewportColumns(t,n,s,o,i=[],r=[],l=0){if(n==null||s==null)return null;const a=Q.getVisibleColumnsInRange(t,n,s,o,i),c=a.length*l,d=Q.getPrevVisibleColumns(t,n-1,c,o,i),u=Q.getNextVisibleColumns(t,s+1,c,o,i),h=[...d,...a,...u];return Q.getColumnsToFetch(t,h,r)}static rangeSetFromRanges(t){const n=t.slice().sort((s,o)=>(M(s.startRow),M(o.startRow),s.startRow-o.startRow)).map(s=>{const{startRow:o,endRow:i}=s;return M(o),M(i),E.RangeSet.ofRange(o,i)});return E.RangeSet.ofRanges(n)}static isValidSnapshotRanges(t){if(t==null||t.length===0)return!1;const n=new Map;for(let i=0;i<t.length;i+=1){const r=t[i],l=`${r.startRow}:${r.endRow}`,a=`${r.startColumn}:${r.endColumn}`;n.has(l)||n.set(l,[]),n.get(l).push(a)}const s=[...n.keys()],o=n.get(s[0]).sort().join(",");for(let i=1;i<s.length;i+=1)if(n.get(s[i]).sort().join(",")!==o)return!1;return!0}static isValidIndex(t){return!Number.isInteger(t)||typeof t!="number"?!1:t>=0}static columnsFromRanges(t,n){var o,i;if(t==null||t.length===0)return[];if(t[0].startColumn===null&&t[0].endColumn===null)return[...n];const s=new Set;for(let r=0;r<t.length;r+=1){const l=t[r];M(l.startColumn),M(l.endColumn);for(let a=(o=l.startColumn)!=null?o:0;a<=((i=l.endColumn)!=null?i:n.length-1);a+=1)s.add(a)}return[...s].map(r=>n[r])}static snapshotDataToMatrix(t){const{columns:n,rows:s}=t,o=[];for(let i=0;i<s.length;i+=1){const r=s[i],l=[];for(let a=0;a<n.length;a+=1){const c=n[a],d=r.get(c);l.push(d)}o.push(l)}return o}static getModelRollupConfig(t,n,s){var u,h,g;if(((h=(u=n==null?void 0:n.columns)==null?void 0:u.length)!=null?h:0)===0)return null;const{columns:o=[],showConstituents:i=!0,showNonAggregatedColumns:r=!0,includeDescriptions:l=!0}=n!=null?n:{},{aggregations:a=[]}=s!=null?s:{},c=a.map(({operation:p,selected:f,invert:C})=>On.isRollupOperation(p)?[]:On.getOperationColumnNames(t,p,f,C)),d={};for(let p=0;p<a.length;p+=1)d[a[p].operation]=c[p];if(r){const p=new Set(t.map(f=>f.name).filter(f=>!o.includes(f)));if(c.forEach(f=>{f.forEach(C=>p.delete(C))}),p.size>0){const f=(g=d[be.FIRST])!=null?g:[];d[be.FIRST]=[...f,...p]}}return{groupingColumns:o,includeConstituents:i,includeDescriptions:l,aggregations:d}}static getPendingErrors(t){t.forEach((n,s)=>{if(!Q.isValidIndex(s))throw new Error(`Invalid rowIndex ${s}`);const{data:o}=n;o.forEach((i,r)=>{if(!Q.isValidIndex(r))throw new Error(`Invalid columnIndex ${r}`)})})}static getColumn(t,n){return n<t.length?t[n]:(Ls.error("Unable to retrieve column",n,">=",t.length),null)}static getColumnByName(t,n){const s=t.find(({name:o})=>o===n);return s==null&&Ls.error("Unable to retrieve column by name",n,t.map(({name:o})=>o)),s}static changeFilterColumnNamesToIndexes(t,n){return n.map(({name:s,filter:o})=>{const i=t.findIndex(r=>r.name===s);return i<0?null:[i,o]}).filter(s=>s!=null)}static combineFiltersFromList(t,n){n.sort((o,i)=>o.operator==="eq"&&i.operator!=="eq"?1:o.operator!=="eq"&&i.operator==="eq"?-1:o.startColumnIndex-i.startColumnIndex);let s="";for(let o=0;o<n.length;o+=1){const{text:i,value:r,operator:l}=n[o];if(r!==void 0){let a="";l!==void 0&&(r==null&&l==="eq"?a="=":l!=="eq"&&(l==="startsWith"||l==="endsWith"?a="*":a=N.getFilterOperatorString(l)));let c=`${a}${i}`;l==="startsWith"&&(c=`${i}${a}`),t!=null&&r!==null&&N.isCharType(t)&&(c=`${a}${String.fromCharCode(parseInt(i,10))}`),o!==0&&(s+=l==="eq"?" || ":" && "),s+=c}}return s}static parseColumnHeaderGroups(t,n){let s=1;const o=new Map,i=new Map,r=n==null?void 0:n.filter(({children:u})=>u.length>0);if(r.length===0)return{groups:[],maxDepth:s,parentMap:o,groupMap:i};const l=new Map(r.map(u=>[u.name,u])),a=new Set,c=u=>{const{name:h}=u;if(t.getColumnIndexByName(h)!=null)throw new Error(`Column header group has same name as column: ${h}`);const g=i.get(h);if(g)return g;const p=[];let f=1;u.children.forEach(w=>{if(a.has(w))throw new Error(`Column group child ${w} specified in multiple groups`);a.add(w);const S=l.get(w),b=t.getColumnIndexByName(w);if(S){const v=c(S);p.push(...v.childIndexes),f=Math.max(f,v.depth+1)}else if(b!=null)p.push(b),f=Math.max(f,1);else throw new Error(`Unknown child ${w} in group ${h}`)});const C=new Bt({...u,depth:f,childIndexes:p.flat()});return i.set(h,C),u.children.forEach(w=>o.set(w,C)),s=Math.max(s,C.depth+1),C},d=new Set;return r.forEach(u=>{const{name:h}=u;if(d.has(h))throw new Error(`Duplicate column group name: ${h}`);d.add(h),c(u)}),i.forEach(u=>{var h;u.setParent((h=o.get(u.name))==null?void 0:h.name)}),{groups:[...i.values()],maxDepth:s,groupMap:i,parentMap:o}}static convertValueToText(t,n){if(n!=null&&N.isCharType(n)&&t!=null&&typeof t=="number")return String.fromCharCode(t);if(N.isDateType(n)&&Du(t)){const s=new Date(t.asDate()),o=s.getTimezoneOffset();return new Date(s.getTime()-o*60*1e3).toISOString().replace("T"," ").substring(0,23)}return t==null?"":`${t}`}}const ht=le.module("IrisGridCopyHandler"),Re=class extends F.exports.Component{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:Re.COPY_STATES.IDLE,buttonState:Re.BUTTON_STATES.COPY,isShown:!1,rowCount:0}}static getStatusMessageText(e,t){switch(e){case Re.COPY_STATES.CONFIRMATION_REQUIRED:return`Are you sure you want to copy ${t.toLocaleString()} rows to your clipboard?`;case Re.COPY_STATES.CLICK_REQUIRED:return`Fetched ${t.toLocaleString()} rows!`;case Re.COPY_STATES.FETCH_ERROR:return"Unable to copy data.";case Re.COPY_STATES.FETCH_IN_PROGRESS:return`Fetching ${t.toLocaleString()} rows for clipboard...`;case Re.COPY_STATES.DONE:return"Copied to Clipboard!";default:return""}}static getCopyButtonText(e){switch(e){case Re.BUTTON_STATES.FETCH_IN_PROGRESS:return"Fetching";case Re.BUTTON_STATES.CLICK_TO_COPY:return"Click to Copy";case Re.BUTTON_STATES.RETRY:return"Retry";default:return"Copy"}}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()}startCopy(){ht.debug2("startCopy"),this.stopCopy();const{copyOperation:e}=this.props;if(e==null){ht.debug2("No copy operation set, cancelling out"),this.setState({isShown:!1});return}const{ranges:t,error:n}=e;if(n!=null){ht.debug("Showing copy error",n),this.setState({isShown:!0,copyState:Re.COPY_STATES.DONE,error:n}),this.startHideTimer();return}const s=K.rowCount(t);this.setState({rowCount:s,isShown:!0,error:void 0}),s>Re.NO_PROMPT_THRESHOLD?this.setState({buttonState:Re.BUTTON_STATES.COPY,copyState:Re.COPY_STATES.CONFIRMATION_REQUIRED}):this.startFetch()}stopCopy(){this.textData=void 0,this.stopFetch(),this.stopHideTimer()}handleBackgroundClick(){ht.debug2("handleBackgroundClick");const{copyState:e}=this.state;e===Re.COPY_STATES.DONE&&this.setState({isShown:!1})}handleCancelClick(){ht.debug2("handleCancelClick"),this.stopFetch(),this.setState({isShown:!1})}handleCopyClick(){ht.debug2("handleCopyClick"),this.textData!=null?this.copyText(this.textData):this.startFetch()}handleHideTimeout(){ht.debug2("handleHideTimeout"),this.stopHideTimer(),this.setState({isShown:!1})}copyText(e){ht.debug2("copyText",e),this.textData=e,qo(e).then(()=>{this.setState({copyState:Re.COPY_STATES.DONE}),this.startHideTimer()},t=>{ht.error("copyText error",t),this.setState({buttonState:Re.BUTTON_STATES.CLICK_TO_COPY,copyState:Re.COPY_STATES.CLICK_REQUIRED})})}startFetch(){this.stopFetch(),this.setState({buttonState:Re.BUTTON_STATES.FETCH_IN_PROGRESS,copyState:Re.COPY_STATES.FETCH_IN_PROGRESS});const{model:e,copyOperation:t}=this.props,{ranges:n,includeHeaders:s,userColumnWidths:o,movedColumns:i,formatValues:r}=t;ht.debug("startFetch",n);const l=Q.getHiddenColumns(o);let a=_.getModelRanges(n,i);if(l.length>0){const d=l.map(K.makeColumn);a=K.subtractRangesFromRanges(a,d)}const c=r!=null&&r?(d,u)=>e.displayString(d,u.type,u.name):d=>`${d}`;this.fetchPromise=ze.makeCancelable(e.textSnapshot(a,s,c)),this.fetchPromise.then(d=>{this.fetchPromise=void 0,this.copyText(d)}).catch(d=>{d instanceof xi?ht.debug("User cancelled copy."):(ht.error("Error fetching contents",d),this.fetchPromise=void 0,this.setState({buttonState:Re.BUTTON_STATES.RETRY,copyState:Re.COPY_STATES.FETCH_ERROR}))})}stopFetch(){this.fetchPromise&&(ht.debug2("stopFetch"),this.fetchPromise.cancel(),this.fetchPromise=void 0)}startHideTimer(){this.stopHideTimer(),this.hideTimer=setTimeout(this.handleHideTimeout,Re.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:o,copyState:i,isShown:r,rowCount:l,error:a}=this.state,c=i===Re.COPY_STATES.DONE?"fade":"copy-slide-up",d=Re.getCopyButtonText(o),u=a!=null?a:Re.getStatusMessageText(i,l),h=i!==Re.COPY_STATES.DONE,g=o===Re.BUTTON_STATES.FETCH_IN_PROGRESS,p=i===Re.COPY_STATES.DONE;return y(Jo,{animation:c,isShown:r,className:Z("iris-grid-copy-handler",{"copy-done":p}),onClick:this.handleBackgroundClick,onEntering:e,onEntered:t,onExiting:n,onExited:s,children:[m("div",{className:"status-message",children:m("span",{children:u})}),m($t,{in:h,timeout:We.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:y("div",{className:"buttons-container",children:[m("button",{type:"button",className:"btn btn-outline-secondary btn-cancel",onClick:this.handleCancelClick,children:"Cancel"}),y(z,{kind:g?"tertiary":"primary",className:Z("btn-copy",{"btn-spinner":g}),onClick:this.handleCopyClick,disabled:g,children:[g&&m(dn,{}),d]})]})})]})}};let ys=Re;ys.NO_PROMPT_THRESHOLD=1e4;ys.HIDE_TIMEOUT=3e3;ys.COPY_STATES={IDLE:"IDLE",CONFIRMATION_REQUIRED:"CONFIRMATION_REQUIRED",FETCH_IN_PROGRESS:"FETCH_IN_PROGRESS",FETCH_ERROR:"FETCH_ERROR",CLICK_REQUIRED:"CLICK_REQUIRED",DONE:"DONE"};ys.BUTTON_STATES={COPY:"COPY",FETCH_IN_PROGRESS:"FETCH_IN_PROGRESS",CLICK_TO_COPY:"CLICK_TO_COPY",RETRY:"RETRY"};ys.defaultProps={copyOperation:null,onEntering:()=>{},onEntered:()=>{},onExiting:()=>{},onExited:()=>{}};class Dl extends F.exports.PureComponent{constructor(t){super(t);const{debounceMs:n}=t;this.debouncedSendUpdate=vt(this.sendUpdate.bind(this),n),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:s}=t;this.initialValue=s,this.state={isChanged:!1,value:s}}componentDidMount(){var t;(t=this.inputField)==null||t.focus()}componentDidUpdate(t){const{debounceMs:n}=this.props;t.debounceMs!==n&&(this.debouncedSendUpdate.flush(),this.debouncedSendUpdate=vt(this.sendUpdate.bind(this),n))}componentWillUnmount(){this.debouncedSendUpdate.cancel()}setValue(t){this.initialValue=t,this.setState({value:t})}focus(){var t;(t=this.inputField)==null||t.focus()}handleChange(t){const{value:n}=t.target;this.setState({value:n,isChanged:!0}),this.debouncedSendUpdate(n)}handleCancel(){this.debouncedSendUpdate.cancel();const{initialValue:t}=this,{isChanged:n}=this.state;n&&this.sendUpdate(t);const{onDone:s}=this.props;s()}handleCommit(t=!0,n=!0){this.debouncedSendUpdate.flush();const{onDone:s}=this.props;s(t,n)}handleFocus(){var t;(t=this.inputField)==null||t.select()}handleBlur(t){const{relatedTarget:n}=t;n!=null&&n.classList.contains("context-menu-container")?this.handleCommit(!1,!0):n!=null&&n.classList.contains("advanced-filter-button")?this.handleCommit(!1,!1):this.handleCommit(!0,!0)}handleTab(t=!1){this.debouncedSendUpdate.flush();const{onTab:n}=this.props;n(t)}handleKeyDown(t){switch(t.key){case"Escape":t.stopPropagation(),t.preventDefault(),this.handleCancel();break;case"Enter":t.stopPropagation(),t.preventDefault(),this.handleCommit();break;case"Tab":t.stopPropagation(),t.preventDefault(),this.handleTab(t.shiftKey);break}}handleContextMenu(t){const{onContextMenu:n}=this.props;n(t)}sendUpdate(t){const{onChange:n}=this.props;n(t)}render(){const{className:t,style:n,isAdvancedFilterSet:s,onAdvancedFiltersTriggered:o}=this.props,{value:i}=this.state;return y("div",{style:n,className:"iris-grid-input-autosized-wrapper","data-value":i,children:[m("input",{ref:r=>{this.inputField=r},className:Z("iris-grid-input-field",t),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"}),m("div",{className:"advanced-filter-button-container",children:m(z,{kind:"ghost",className:Z("btn-link-icon advanced-filter-button",{"filter-set":s}),onClick:o,onContextMenu:this.handleContextMenu,children:y("div",{className:"fa-layers ",children:[m(J,{icon:ki,className:"filter-solid"}),m(J,{icon:xo,className:"filter-light"})]})})})]})}}Dl.defaultProps={style:{},className:"",value:"",isAdvancedFilterSet:!1,onAdvancedFiltersTriggered:()=>{},onChange:()=>{},onDone:()=>{},onTab:()=>{},onContextMenu:()=>{},debounceMs:150};class Iu extends ss{constructor(t){super(),this.irisGrid=t}onDown(t){const{selectedRanges:n}=this.irisGrid.state;return t.key==="c"&&_n.isModifierKeyDown(t)?(Q.isValidSnapshotRanges(n)?this.irisGrid.copyRanges(n):this.irisGrid.copyRanges(n,!1,!1,"Invalid copy ranges"),!0):!1}}const Nu={TOGGLE_QUICK_FILTER:Be.createAndAdd({id:"TABLE.TOGGLE_QUICK_FILTER",name:"Toggle Quick Filter",shortcut:[ce.CTRL,fe.F],macShortcut:[ce.CMD,fe.F]}),CLEAR_ALL_FILTERS:Be.createAndAdd({id:"TABLE.CLEAR_ALL_FILTERS",name:"Clear All Table Filters",shortcut:[ce.CTRL,fe.E],macShortcut:[ce.CMD,fe.E]}),CLEAR_FILTERS:Be.createAndAdd({id:"TABLE.CLEAR_FILTERS",name:"Clear Active Table Filters",shortcut:[ce.CTRL,ce.SHIFT,fe.E],macShortcut:[ce.CMD,ce.SHIFT,fe.E]}),REVERSE:Be.createAndAdd({id:"TABLE.REVERSE",name:"Reverse",shortcut:[ce.CTRL,fe.I],macShortcut:[ce.CMD,fe.I]}),TOGGLE_SEARCH:Be.createAndAdd({id:"TABLE.TOGGLE_SEARCH",name:"Toggle Search",shortcut:[ce.CTRL,ce.SHIFT,fe.F],macShortcut:[ce.CMD,ce.SHIFT,fe.F]}),GOTO_ROW:Be.createAndAdd({id:"TABLE.GOTO_ROW",name:"Go to Row",shortcut:[ce.CTRL,fe.G],macShortcut:[ce.CMD,fe.G]})},Au={COMMIT:Be.createAndAdd({id:"INPUT_TABLE.COMMIT",name:"Commit",shortcut:[ce.CTRL,fe.S],macShortcut:[ce.CMD,fe.S]}),DISCARD:Be.createAndAdd({id:"INPUT_TABLE.DISCARD",name:"Discard",shortcut:[ce.CTRL,ce.ALT,fe.S],macShortcut:[ce.CMD,ce.OPTION,fe.S]})},Nt={TABLE:Nu,INPUT_TABLE:Au};class Mu extends ss{constructor(t){super(),this.irisGrid=t}onDown(t){if(Nt.TABLE.REVERSE.matchesEvent(t)){if(!this.irisGrid.isReversible())return!1;const{reverseType:n}=this.irisGrid.state;return n===N.REVERSE_TYPE.NONE?this.irisGrid.reverse(N.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(N.REVERSE_TYPE.NONE),!0}return!1}}class Ou extends ss{constructor(t){super(),this.irisGrid=t}onDown(t){return Nt.TABLE.CLEAR_FILTERS.matchesEvent(t)?(this.irisGrid.clearAllFilters(),!0):!1}}class xu extends Ke{constructor(t){super(850),this.irisGrid=t}destroyColumnTooltip(){this.irisGrid.setState({overflowButtonTooltipProps:null})}setCursor(t){return this.isHoveringOverflowButton(t)?(this.cursor="pointer",{stopPropagation:!1,preventDefault:!1}):(this.cursor=null,!1)}getButtonPosition({x:t,y:n,column:s,row:o}){if(s==null||o==null)return null;const{renderer:i,grid:r,state:l,props:a}=this.irisGrid;if(!r)return null;const{metrics:c}=l,{model:d}=a,{canvasContext:u}=r,h=r.getTheme(),g={context:u,mouseX:t,mouseY:n,metrics:c,model:d,theme:h},{left:p,top:f,width:C,height:w}=i.getCellOverflowButtonPosition(g);return p==null||C==null||f==null||w==null?null:{left:p,top:f,width:C,height:w}}isHoveringOverflowButton(t){var w;const{x:n,y:s}=t,{left:o,top:i,width:r,height:l}=(w=this.getButtonPosition(t))!=null?w:{};if(o==null||r==null||i==null||l==null)return!1;const{renderer:a,grid:c,state:d,props:u}=this.irisGrid;if(!c)return!1;const{metrics:h}=d,{model:g}=u,{canvasContext:p}=c,f=c.getTheme(),C={context:p,mouseX:n,mouseY:s,metrics:h,model:g,theme:f};return a.shouldRenderOverflowButton(C)&&n>=o&&n<=o+r&&s>=i&&s<=i+l}onMove(t){if(this.isHoveringOverflowButton(t)){const{overflowButtonTooltipProps:n}=this.irisGrid.state,s=this.getButtonPosition(t);it(n,s)||this.irisGrid.setState({overflowButtonTooltipProps:s})}else this.destroyColumnTooltip();return this.setCursor(t)}onWheel(t){return this.destroyColumnTooltip(),this.onMove(t)}onDown(t){this.destroyColumnTooltip();const{column:n,row:s}=t;return this.isHoveringOverflowButton(t)&&this.irisGrid.setState({showOverflowModal:!0,overflowText:this.irisGrid.getValueForCell(n,s)}),!1}onContextMenu(){return this.destroyColumnTooltip(),!1}onLeave(){return this.destroyColumnTooltip(),!1}}class ku extends Ke{constructor(t){super(),this.irisGrid=t,this.cursor=null}isActive(){const{isSelectingColumn:t}=this.irisGrid.props;return t}isValidColumn(t){if(t==null)return!1;const{columnSelectionValidator:n}=this.irisGrid.props;return n!=null?n(t):!0}updateColumnSelectionStatus(){const{columnSelectionValidator:t}=this.irisGrid.props;t!=null&&t(null)}getTableColumn(t){if(t==null)return null;const{model:n}=this.irisGrid.props,s=this.irisGrid.getModelColumn(t);return s==null?null:n.columns[s]}onMove(t){if(!this.isActive())return!1;const{columnAllowedCursor:n,columnNotAllowedCursor:s}=this.irisGrid.props,{column:o}=t,i=this.getTableColumn(o);return this.isValidColumn(i)?(this.cursor=n,this.irisGrid.setState({hoverSelectColumn:o})):(this.cursor=s,this.irisGrid.setState({hoverSelectColumn:null})),!0}onWheel(t){if(!this.isActive())return!1;const{columnAllowedCursor:n,columnNotAllowedCursor:s}=this.irisGrid.props,{column:o}=t,i=this.getTableColumn(o);return this.isValidColumn(i)?this.cursor=n:this.cursor=s,{preventDefault:!1,stopPropagation:!1}}onLeave(){return this.isActive()&&this.irisGrid.setState({hoverSelectColumn:null}),this.updateColumnSelectionStatus(),!1}onDown(){return this.isActive()}onClick(t){if(!this.isActive())return!1;const{column:n}=t,s=this.getTableColumn(n);return s!=null&&this.isValidColumn(s)&&this.irisGrid.selectColumn(s),!0}}class Lu extends Ke{constructor(t){super(),this.irisGrid=t}hideColumnTooltip(){const{tooltip:t}=this.irisGrid;t&&(t.stopTimer(),t.hide())}onDown(){return this.hideColumnTooltip(),!1}onContextMenu(){return this.hideColumnTooltip(),!1}onWheel(){return this.hideColumnTooltip(),!1}onLeave(t,n,s){const{relatedTarget:o}=s instanceof MouseEvent?s:s.nativeEvent,{tooltip:i}=this.irisGrid;if(!i)return!1;const r=i.popper.current;return r&&o instanceof Element&&r.element.contains(o)||this.hideColumnTooltip(),!1}onMove(t){const{column:n,row:s,columnHeaderDepth:o}=t,{shownColumnTooltip:i}=this.irisGrid.state;let r=null;return n!==null&&s===null&&o===0&&(r=n),r!==i&&this.irisGrid.setState({shownColumnTooltip:r}),!1}}const Il=class extends F.exports.Component{constructor(e=Il.defaultProps){super(e),this.handleInputChange=this.handleInputChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.inputRef=De.createRef()}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=Xc.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:o},iconElement:i}=t;return y("div",{className:"form-group flex-grow mb-0",children:[y("div",{className:"custom-format-title",children:[m("span",{className:"icon",children:i}),y("label",{className:"title mb-0",htmlFor:"custom-format-input",children:[s,o!=null&&m(Rt,{children:o})]})]}),m("div",{className:"pl-2 pr-2 pb-2",children:m("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"})})]})}};let Nl=Il;Nl.defaultProps={formatString:"",forwardedProps:{menuItem:{},closeMenu(e){},iconElement:null},placeholder:"",title:"",onChange(e){}};class ft{static isDefaultSelected(t){return!t||![_e.TYPE_CONTEXT_CUSTOM,_e.TYPE_CONTEXT_PRESET].includes(t.type)}static isCustomSelected(t){return t!=null&&t.type===_e.TYPE_CONTEXT_CUSTOM}static makeOption(t,n,s,o){return{title:t,description:t,group:s,format:n,isSelected:o}}static makeCustomFormatOption(t,n,s,o,i){return{title:t.label,description:t.label,format:t,group:n,isSelected:o,menuElement:m(Nl,{formatString:t.formatString,title:t.label,placeholder:s,onChange:i})}}}const Vt=class{static getOptions(e,t){const n=new Date,o=[{group:Vt.dateGroup,formatString:"yyyy-MM-dd"},{group:Vt.dateGroup,formatString:"MM-dd-yyyy"},{group:Vt.timeGroup,formatString:"HH:mm:ss"},{group:Vt.timeGroup,formatString:"HH:mm:ss.SSS"},{group:Vt.timeGroup,formatString:"HH:mm:ss.SSSSSSSSS"},{group:Vt.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss"},{group:Vt.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSS"},{group:Vt.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"}].map(r=>{const l=kn.makeFormat("",r.formatString,kn.TYPE_CONTEXT_PRESET),a=e.getFormattedString(n,N.dataType.DATETIME,"",l);return ft.makeOption(a,l,r.group,kn.isSameFormat(l,t))});return[ft.makeOption("Default",null,Vt.dateGroup,ft.isDefaultSelected(t)),...o]}};let ei=Vt;ei.dateGroup=10;ei.timeGroup=20;ei.dateTimeGroup=30;const Ut=class{static getOptions(e,t){const n=[{format:Ve.FORMAT_PERCENT,group:Ut.presetGroup},{format:Ve.FORMAT_BASIS_POINTS,group:Ut.presetGroup},{format:Ve.FORMAT_MILLIONS,group:Ut.presetGroup},{format:Ve.FORMAT_SCIENTIFIC_NOTATION,group:Ut.presetGroup},{format:Ve.FORMAT_ROUND,group:Ut.presetRoundGroup},{format:Ve.FORMAT_ROUND_TWO_DECIMALS,group:Ut.presetRoundGroup},{format:Ve.FORMAT_ROUND_FOUR_DECIMALS,group:Ut.presetRoundGroup}],s=ft.makeOption("Default",null,Ut.defaultGroup,ft.isDefaultSelected(e)),o=n.map(a=>ft.makeOption(a.format.label,a.format,a.group,Ve.isSameFormat(a.format,e))),i=ft.isCustomSelected(e),r=i?e:Ve.makeCustomFormat(),l=ft.makeCustomFormatOption(r,Ut.customGroup,Ve.DEFAULT_FORMAT_STRING,i,a=>{if(a!=null){const c=Ve.makeCustomFormat(a);Ve.isValid(c)&&t(c)}else t(null)});return[s,...o,l]}};let Js=Ut;Js.defaultGroup=10;Js.presetGroup=20;Js.presetRoundGroup=30;Js.customGroup=40;const Gs=class{static getOptions(e,t){const n=[{format:It.FORMAT_MILLIONS,group:Gs.presetGroup},{format:It.FORMAT_SCIENTIFIC_NOTATION,group:Gs.presetGroup}],s=ft.makeOption("Default",null,Gs.defaultGroup,ft.isDefaultSelected(e)),o=n.map(a=>ft.makeOption(a.format.label,a.format,a.group,It.isSameFormat(a.format,e))),i=ft.isCustomSelected(e),r=i?e:It.makeCustomFormat(),l=ft.makeCustomFormatOption(r,Gs.customGroup,It.DEFAULT_FORMAT_STRING,i,a=>{if(a!=null){const c=It.makeCustomFormat(a);It.isValid(c)&&t(c)}else t(null)});return[s,...o,l]}};let ti=Gs;ti.defaultGroup=10;ti.presetGroup=20;ti.customGroup=30;const Or=le.module("IrisGridContextMenuHandler"),Pu=150,xr="yyyy-MM-dd HH:mm:ss.SSSSSSSSS",U=class extends Ke{constructor(e){super(),this.debouncedUpdateCustomFormat=vt(e.handleFormatSelection,Pu),this.irisGrid=e}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 E.FilterCondition.invoke("isInf",n).and(n.greaterThan(E.FilterValue.ofNumber(0)));if(t===Number.NEGATIVE_INFINITY)return E.FilterCondition.invoke("isInf",n).and(n.lessThan(E.FilterValue.ofNumber(0)));if(Number.isNaN(t))return E.FilterCondition.invoke("isNaN",n);const s=U.getFilterValueForNumberOrChar(e.type,t);return n.eq(s)}static getFilterValueForNumberOrChar(e,t){return N.isCharType(e)?E.FilterValue.ofString(String.fromCharCode(t)):E.FilterValue.ofNumber(t)}static getRowOptionFormatted(e,t,n=30){return`${e} "${ts.truncate(t,n-e.length-3)}"`}componentWillUnmount(){this.debouncedUpdateCustomFormat.flush()}getHeaderActions(e,t){var I;const{irisGrid:n}=this,{column:s}=t;M(s);const{model:o}=n.props,{columns:i}=o,r=i[e],l=[],{metrics:a,reverseType:c,quickFilters:d,advancedFilters:u,searchFilter:h}=n.state,g=n.getTheme();M(a);const{filterIconColor:p,filterBarActiveColor:f,contextMenuSortIconColor:C,contextMenuReverseIconColor:w}=g,S=o.sort,b=N.getSortForColumn(S,e),v=c!==N.REVERSE_TYPE.NONE,{userColumnWidths:T}=a,R=[...T.values()].some(L=>L===0),D=o.getColumnHeaderParentGroup(e,0)===void 0,A=o.isColumnFrozen(e);return l.push({title:"Hide Column",group:U.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.hideColumnByVisibleIndex(s)}}),l.push({title:A?"Unfreeze Column":"Freeze Column",group:U.GROUP_HIDE_COLUMNS,disabled:!D,action:()=>{A?this.irisGrid.unFreezeColumnByColumnName(r.name):this.irisGrid.freezeColumnByColumnName(r.name)},order:10}),l.push({title:"Show All Columns",group:U.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.showAllColumns()},disabled:!R}),l.push({title:"Quick Filters",icon:jt,iconColor:f,shortcut:Nt.TABLE.TOGGLE_QUICK_FILTER,group:U.GROUP_FILTER,order:10,action:()=>{this.irisGrid.toggleFilterBar(s)}}),l.push({title:"Advanced Filters",icon:u.get(e)?ki:xo,iconColor:p,group:U.GROUP_FILTER,order:20,action:()=>{this.irisGrid.handleAdvancedMenuOpened(s)}}),l.push({title:"Clear Table Filters",group:U.GROUP_FILTER,order:40,shortcut:Nt.TABLE.CLEAR_FILTERS,action:()=>{this.irisGrid.clearAllFilters()},disabled:!(d.size>0||u.size>0||h!=null)}),l.push({title:"Sort by",icon:jt,iconColor:C,group:U.GROUP_SORT,order:10,actions:this.sortByActions(r,e,b)}),l.push({title:"Add Additional Sort",disabled:b&&S.length===1||v&&S.length===1||b&&v&&S.length===2||S.length===0,group:U.GROUP_SORT,order:20,actions:this.additionalSortActions(r,e)}),l.push({title:"Clear Table Sorting",disabled:S.length===0||v&&S.length===1,group:U.GROUP_SORT,action:()=>{this.irisGrid.sortColumn(s,U.COLUMN_SORT_DIRECTION.none)},order:30}),l.push({title:c===N.REVERSE_TYPE.NONE?"Reverse Table":"Clear Reverse Table",icon:jt,iconColor:w,group:U.GROUP_SORT,order:40,disabled:!o.isReversible,shortcut:Nt.TABLE.REVERSE,action:()=>{c===N.REVERSE_TYPE.NONE?this.irisGrid.reverse(N.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(N.REVERSE_TYPE.NONE)}}),l.push({title:"Copy Column Name",group:U.GROUP_COPY,action:()=>{var L;qo((L=o.textForColumnHeader(e))!=null?L:"").catch(k=>Or.error("Unable to copy header",k))}}),N.isDateType(r.type)?l.push({title:"Date/Time Format",group:U.GROUP_FORMAT,actions:this.dateFormatActions(r)}):N.isNumberType(r.type)&&l.push({title:"Number Format",group:U.GROUP_FORMAT,actions:(I=this.numberFormatActions(r))!=null?I:void 0}),l}getCellActions(e,t,n){M(e);const{irisGrid:s}=this,{column:o,row:i}=n,{model:r,canCopy:l}=s.props,{columns:a}=r,c=s.getModelRow(i);M(c);const d=r.valueForCell(e,c),u=r.textForCell(e,c),h=a[e],g=[],{quickFilters:p}=s.state,f=s.getTheme(),{filterIconColor:C}=f,{settings:w}=s.props,S=new kn({timeZone:w==null?void 0:w.timeZone,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:xr}),b=new kn({timeZone:w==null?void 0:w.timeZone,showTimeZone:w==null?void 0:w.showTimeZone,showTSeparator:w==null?void 0:w.showTSeparator,defaultDateTimeFormatString:xr});if(h==null||i==null)return g;if(r.isFilterable(e)){const T={title:"Filter by Value",icon:jt,iconColor:C,group:U.GROUP_FILTER,order:10,actions:[]};if(d==null)p.get(e)&&T.actions.push({title:"And",actions:this.nullFilterActions(h,p.get(e),"&&"),order:2,group:oe.groups.high}),T.actions.push(...this.nullFilterActions(h));else if(N.isBooleanType(h.type))p.get(e)&&T.actions.push({title:"Or",actions:this.booleanFilterActions(h,u,p.get(e),"||"),order:2,group:oe.groups.high}),T.actions.push(...this.booleanFilterActions(h,u));else if(N.isNumberType(h.type)||N.isCharType(h.type)){M(e);const R=N.isCharType(h.type)?String.fromCharCode(d):`${d}`;p.get(e)&&T.actions.push({title:"And",actions:this.numberFilterActions(h,R,d,p.get(e),"&&"),order:2,group:oe.groups.high}),T.actions.push(...this.numberFilterActions(h,R,d,p.get(e)))}else if(N.isDateType(h.type)){const R=S.format(d),D=b.format(d);p.get(e)&&T.actions.push({title:"And",actions:this.dateFilterActions(h,R,D,d,p.get(e),"&&"),order:2,group:oe.groups.high}),T.actions.push(...this.dateFilterActions(h,R,D,d,p.get(e)))}else p.get(e)&&T.actions.push({title:"And",actions:this.stringFilterActions(h,u,d,p.get(e),"&&"),order:2,group:oe.groups.high}),T.actions.push(...this.stringFilterActions(h,u,d));T.actions!=null&&T.actions.length>0&&g.push(T)}if(Me(r)&&r.isRowExpandable(c)){const T=r.groupedColumns.length>0?r.depthForRow(c)-1:0,D=r.valueForCell(T,c)==null?"null":r.textForCell(T,c);g.push({title:U.getRowOptionFormatted(r.isRowExpanded(c)?"Collapse":"Expand",D),group:U.GROUP_EXPAND_COLLAPSE,order:10,action:()=>{r.setRowExpanded(c,!r.isRowExpanded(c))}}),r.isExpandAllAvailable===!0&&g.push({title:U.getRowOptionFormatted("Expand All in",D),group:U.GROUP_EXPAND_COLLAPSE,order:20,action:()=>{r.setRowExpanded(c,!0,!0)}})}Me(r)&&r.hasExpandableRows&&r.isExpandAllAvailable===!0&&(g.push({title:"Expand Entire Table",group:U.GROUP_EXPAND_COLLAPSE,order:30,action:()=>{r.expandAll()}}),g.push({title:"Collapse Entire Table",group:U.GROUP_EXPAND_COLLAPSE,order:40,action:()=>{r.collapseAll()}}));const v={title:"Go to",iconColor:C,shortcut:Nt.TABLE.GOTO_ROW,group:U.GROUP_GOTO,order:10,action:()=>this.irisGrid.toggleGotoRow(`${i+1}`,`${d}`,h.name)};return g.push(v),l&&(g.push({title:"Copy Cell",group:U.GROUP_COPY,order:10,action:()=>{s.copyCell(o,i)}}),g.push({title:"Copy Cell Unformatted",group:U.GROUP_COPY,order:20,action:()=>{s.copyCell(o,i,!0)}})),g}onContextMenu(e,t,n){const{irisGrid:s}=this,{y:o,column:i,row:r,columnHeaderDepth:l}=e,a=s.getModelColumn(i),c=s.getModelRow(r),{model:d,canCopy:u}=s.props,{columns:h}=d,{metrics:g,isFilterBarShown:p,quickFilters:f,advancedFilters:C,selectedRanges:w}=s.state;M(g);const{columnHeaderHeight:S,gridY:b,columnHeaderMaxDepth:v}=g,T=[];if(a!=null&&c!=null){const R=d.valueForCell(a,c),D=d.textForCell(a,c),A=h[a],{onContextMenu:I}=s.props;A!=null&&T.push(I({model:d,value:R,valueText:D,column:A,rowIndex:r,columnIndex:i,modelRow:c,modelColumn:a}))}return a!=null&&d.isFilterable(a)&&T.push({title:"Clear Column Filter",group:U.GROUP_FILTER,order:30,action:()=>{this.irisGrid.removeColumnFilter(a)},disabled:!(f.has(a)||C.has(a))}),(p?o<=b:o<=S*v&&l===0)?a!=null&&T.push(...this.getHeaderActions(a,e)):(a!=null&&c!=null&&T.push(...this.getCellActions(a,t,e)),u&&w.length>0&&(T.push({title:"Copy Selection",shortcut:Li.COPY,group:U.GROUP_COPY,order:30,action:()=>{s.copyRanges(w)}}),T.push({title:"Copy Selection w/ Headers",group:U.GROUP_COPY,order:40,action:()=>{s.copyRanges(w,!0)}})),Pe(d)&&d.isEditable&&w.length>0&&T.push({title:"Delete Selected Rows",group:U.GROUP_EDIT,order:50,action:()=>{this.irisGrid.deleteRanges(w)}})),T.length===0?!1:(M(s.gridWrapper),oe.triggerMenu(s.gridWrapper,n.pageX,n.pageY,T),!0)}dateFormatActions(e){const{model:t}=this.irisGrid.props,{formatter:n}=t,s=n.getColumnFormat(e.type,e.name),o=ei.getOptions(n,s),i=[];for(let r=0;r<o.length;r+=1){const{description:l,format:a,group:c,isSelected:d,title:u}=o[r];i.push({title:u,description:l,icon:d?jn:void 0,group:c,order:r,action:()=>{const h=t.getColumnIndexByName(e.name);M(h),this.irisGrid.handleFormatSelection(h,a)}})}return i}numberFormatActions(e){const{model:t}=this.irisGrid.props,{formatter:n}=t,s=n.getColumnFormat(e.type,e.name);let o;const i=t.getColumnIndexByName(e.name);if(N.isDecimalType(e.type))o=Js.getOptions(s,l=>{M(i),this.debouncedUpdateCustomFormat(i,l)});else if(N.isIntegerType(e.type))o=ti.getOptions(s,l=>{M(i),this.debouncedUpdateCustomFormat(i,l)});else return Or.error("Invalid column type in numberFormatActions"),null;const r=[];for(let l=0;l<o.length;l+=1){const{format:a,isSelected:c}=o[l];r.push({...o[l],icon:c?jn:void 0,order:l,action:()=>{i===void 0&&a&&a.type===_e.TYPE_CONTEXT_CUSTOM||(M(i),this.irisGrid.handleFormatSelection(i,a))}})}return r}stringFilterActions(e,t,n,s,o){const i=E.FilterValue.ofString(n);let r=s;r||(r={filter:null,text:null});const{filter:l,text:a}=r,c=[],{model:d}=this.irisGrid.props,u=d.getColumnIndexByName(e.name);return M(u),c.push({menuElement:y("div",{className:"iris-grid-filter-menu-item-value",children:[o?U.getOperatorAsText(o):""," ",'"',t,'"']}),order:1,group:oe.groups.high}),c.push({title:"text is exactly",description:`Show only rows where ${e.name} is ${n} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(l,e.filter().eq(i),o),U.getQuickFilterText(a,`=${t}`,o))},order:10,group:oe.groups.low}),c.push({title:"text is not exactly",description:`Show only rows where ${e.name} is not ${t} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(l,e.filter().notEq(i),o),U.getQuickFilterText(a,`!=${t}`,o))},order:20,group:oe.groups.low}),c.push({title:"text contains",description:`Show only rows where ${e.name} contains ${t}`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(l,e.filter().contains(i),o),U.getQuickFilterText(a,`~${t}`,o))},order:30,group:oe.groups.low}),c.push({title:"text does not contain",description:`Show only rows where ${e.name} does not contain ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(l,e.filter().contains(i).not(),o),U.getQuickFilterText(a,`!~${t}`,o))},order:40,group:oe.groups.low}),c.push({title:"text starts with",description:`Show only rows where ${e.name} starts with ${t}`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(l,e.filter().invoke("startsWith",i),o),U.getQuickFilterText(a,`${t}*`,o))},order:50,group:oe.groups.low}),c.push({title:"text ends with",description:`Show only rows where ${e.name} ends with ${t}`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(l,e.filter().invoke("endsWith",i),o),U.getQuickFilterText(a,`*${t}`,o))},order:60,group:oe.groups.low}),c}numberFilterActions(e,t,n,s,o){const i=U.getFilterValueForNumberOrChar(e.type,n);let r=null,l=null;s&&(r=s.filter,l=s.text);const a=[],c=n!==Number.POSITIVE_INFINITY&&n!==Number.NEGATIVE_INFINITY&&!Number.isNaN(n),{model:d}=this.irisGrid.props,u=d.getColumnIndexByName(e.name);return M(u),a.push({menuElement:y("div",{className:"iris-grid-filter-menu-item-value",children:[o?U.getOperatorAsText(o):""," ",'"',t,'"']}),order:1,group:oe.groups.high}),a.push({title:"is equal to",description:`Show only rows where ${e.name} is ${t}`,action:()=>{const h=U.getNumberValueEqualsFilter(e,n);this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(r,h,o),U.getQuickFilterText(l,`=${t}`,o))},order:10,group:oe.groups.low}),a.push({title:"is not equal to",description:`Show only rows where ${e.name} is not ${t}`,action:()=>{const h=U.getNumberValueEqualsFilter(e,n).not();this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(r,h,o),U.getQuickFilterText(l,`!=${t}`,o))},order:20,group:oe.groups.low}),c&&!N.isCharType(e.type)&&(a.push({title:"greater than",description:`Show only rows where ${e.name} is greater than ${t}`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(r,e.filter().greaterThan(i),o),U.getQuickFilterText(l,`>${t}`,o))},order:30,group:oe.groups.low}),a.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(u,U.getQuickFilterCondition(r,e.filter().greaterThanOrEqualTo(i),o),U.getQuickFilterText(l,`>=${t}`,o))},order:40,group:oe.groups.low}),a.push({title:"less than",description:`Show only rows where ${e.name} is less than ${t}`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(r,e.filter().lessThan(i),o),U.getQuickFilterText(l,`<${t}`,o))},order:50,group:oe.groups.low}),a.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(u,U.getQuickFilterCondition(r,e.filter().lessThanOrEqualTo(i),o),U.getQuickFilterText(l,`<=${t}`,o))},order:60,group:oe.groups.low})),a}booleanFilterActions(e,t,n,s){const o=[],{model:i}=this.irisGrid.props,{filter:r,text:l}=n||{},a=i.getColumnIndexByName(e.name);return M(a),o.push({menuElement:y("div",{className:"iris-grid-filter-menu-item-value",children:[s?U.getOperatorAsText(s):""," ",'"',t!=null?t:"null",'"']}),order:1,group:oe.groups.high}),o.push({title:"true",description:`Show only rows where ${e.name} is true`,action:()=>{this.irisGrid.setQuickFilter(a,U.getQuickFilterCondition(r,e.filter().isTrue(),s),U.getQuickFilterText(l,"true",s))},order:10,group:oe.groups.low}),o.push({title:"false",description:`Show only rows where ${e.name} is false`,action:()=>{this.irisGrid.setQuickFilter(a,U.getQuickFilterCondition(r,e.filter().isFalse(),s),U.getQuickFilterText(l,"false",s))},order:20,group:oe.groups.low}),o.push({title:"is null",description:`Show only rows where ${e.name} is null`,action:()=>{this.irisGrid.setQuickFilter(a,U.getQuickFilterCondition(r,e.filter().isNull(),s),U.getQuickFilterText(l,"null",s))},order:30,group:oe.groups.low}),o.push({title:"is not null",description:`Show only rows where ${e.name} is not null`,action:()=>{this.irisGrid.setQuickFilter(a,U.getQuickFilterCondition(r,e.filter().isNull().not(),s),U.getQuickFilterText(l,"!null",s))},order:40,group:oe.groups.low}),o}dateFilterActions(e,t,n,s,o,i){const r=E.FilterValue.ofNumber(s);let l=null,a=null;o&&(l=o.filter,a=o.text);const{model:c}=this.irisGrid.props,d=c.getColumnIndexByName(e.name);M(d);const u=[];return u.push({menuElement:y("div",{className:"iris-grid-filter-menu-item-value",children:[i?U.getOperatorAsText(i):""," ",'"',n,'"']}),order:1,group:oe.groups.high}),u.push({title:"date is",description:`Show only rows where ${e.name} is ${n}`,action:()=>{this.irisGrid.setQuickFilter(d,U.getQuickFilterCondition(l,e.filter().eq(r),i),U.getQuickFilterText(a,`=${t}`,i))},order:10,group:oe.groups.low}),u.push({title:"date is not",description:`Show only rows where ${e.name} is not ${n}`,action:()=>{this.irisGrid.setQuickFilter(d,U.getQuickFilterCondition(l,e.filter().notEq(r),i),U.getQuickFilterText(a,`!=${t}`,i))},order:20,group:oe.groups.low}),u.push({title:"date is before",description:`Show only rows where ${e.name} is before ${n}`,action:()=>{this.irisGrid.setQuickFilter(d,U.getQuickFilterCondition(l,e.filter().lessThan(r),i),U.getQuickFilterText(a,`<${t}`,i))},order:30,group:oe.groups.low}),u.push({title:"date is before or equal",description:`Show only rows where ${e.name} is before or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(d,U.getQuickFilterCondition(l,e.filter().lessThanOrEqualTo(r),i),U.getQuickFilterText(a,`<=${t}`,i))},order:40,group:oe.groups.low}),u.push({title:"date is after",description:`Show only rows where ${e.name} is greater than ${n}`,action:()=>{this.irisGrid.setQuickFilter(d,U.getQuickFilterCondition(l,e.filter().greaterThan(r),i),U.getQuickFilterText(a,`>${t}`,i))},order:50,group:oe.groups.low}),u.push({title:"date is after or equal",description:`Show only rows where ${e.name} is after or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(d,U.getQuickFilterCondition(l,e.filter().greaterThanOrEqualTo(r),i),U.getQuickFilterText(a,`>=${t}`,i))},order:60,group:oe.groups.low}),u}nullFilterActions(e,t,n){let s=null,o=null;t&&(s=t.filter,o=t.text);const i=[],{model:r}=this.irisGrid.props,l=r.getColumnIndexByName(e.name);return M(l),i.push({menuElement:y("div",{className:"iris-grid-filter-menu-item-value",children:[n?U.getOperatorAsText(n):""," ",'"null"']}),order:1,group:oe.groups.high}),i.push({title:"is null",description:`Show only rows where ${e.name} is null`,action:()=>{this.irisGrid.setQuickFilter(l,U.getQuickFilterCondition(s,e.filter().isNull(),n),U.getQuickFilterText(o,"null",n))},order:10,group:oe.groups.low}),i.push({title:"is not null",description:`Show only rows where ${e.name} is not null`,action:()=>{this.irisGrid.setQuickFilter(l,U.getQuickFilterCondition(s,e.filter().isNull().not(),n),U.getQuickFilterText(o,"!null",n))},order:20,group:oe.groups.low}),i}sortByActions(e,t,n){const s=this.irisGrid.getTheme(),{contextMenuSortIconColor:o}=s,i=[{title:`${e.name} Ascending`,order:10,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.ascending)},icon:this.checkColumnSort(n,U.COLUMN_SORT_DIRECTION.ascending)?jt:void 0,iconColor:o},{title:`${e.name} Descending`,order:20,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.descending)},icon:this.checkColumnSort(n,U.COLUMN_SORT_DIRECTION.descending)?jt:void 0,iconColor:o},{title:"Remove Sort",order:50,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.none,!1,!0)},disabled:!n}];return N.isNumberType(e.type)&&(i.push({title:`ABS(${e.name}) Ascending`,order:30,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.ascending,!0)},icon:this.checkColumnSort(n,U.COLUMN_SORT_DIRECTION.ascending,!0)?jt:void 0,iconColor:o}),i.push({title:`ABS(${e.name}) Descending`,order:40,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.descending,!0)},icon:this.checkColumnSort(n,U.COLUMN_SORT_DIRECTION.descending,!0)?jt:void 0,iconColor:o})),i}additionalSortActions(e,t){const n=this.irisGrid.getTheme(),{contextMenuSortIconColor:s}=n,o=[{title:"Add Sort By",menuElement:y("div",{className:"btn-context-menu menu-title",children:[m("span",{className:"icon",children:m(J,{icon:jt,style:{color:s!=null?s:void 0}})}),m("span",{className:"title",children:"Add Additional Sort"}),m("span",{className:"shortcut",children:_n.isMacPlatform()?"\u2318Click":"Ctrl+Click"})]}),order:1},{title:`${e.name} Ascending`,order:10,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.ascending,!1,!0)}},{title:`${e.name} Descending`,order:20,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.descending,!1,!0)}}];return N.isNumberType(e.type)&&(o.push({title:`ABS(${e.name}) Ascending`,order:30,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.ascending,!0,!0)}}),o.push({title:`ABS(${e.name}) Descending`,order:40,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.descending,!0,!0)}})),o}checkColumnSort(e,t=null,n=!1){return e?e.direction===t&&e.isAbs===n:!1}};let Xt=U;Xt.GROUP_EDIT=oe.groups.high+10;Xt.GROUP_HIDE_COLUMNS=oe.groups.high+25;Xt.GROUP_FILTER=oe.groups.high+50;Xt.GROUP_EXPAND_COLLAPSE=oe.groups.high+55;Xt.GROUP_GOTO=oe.groups.high+60;Xt.GROUP_SORT=oe.groups.high+75;Xt.GROUP_COPY=oe.groups.high+100;Xt.GROUP_FORMAT=oe.groups.high+150;Xt.COLUMN_SORT_DIRECTION={ascending:"ASC",descending:"DESC",none:null};class _u extends Ke{constructor(t){super(),this.irisGrid=t}onDoubleClick(t){const{column:n,row:s}=t;return s==null||n==null?!1:(this.irisGrid.selectData(n,s),!0)}}class Hu extends Ke{constructor(t){super(),this.irisGrid=t}onDown(t){const{y:n,column:s,row:o}=t;if(s!==null&&o===null){const{isFilterBarShown:i,metrics:r}=this.irisGrid.state;if(!r)throw new Error("Metrics not set");const{columnHeaderMaxDepth:l}=r,a=this.irisGrid.getTheme();if(i&&a.columnHeaderHeight!=null&&a.filterBarHeight!=null&&n>a.columnHeaderHeight*l&&n<=a.columnHeaderHeight*l+a.filterBarHeight)return this.irisGrid.focusFilterBar(s),!0}return!1}onMove(t){const{y:n,column:s}=t,{isFilterBarShown:o,hoverAdvancedFilter:i,metrics:r}=this.irisGrid.state;if(!r)throw new Error("Metrics not set");const{columnHeaderMaxDepth:l}=r,a=this.irisGrid.getTheme();let c=null;return o&&a.columnHeaderHeight!=null&&a.filterBarHeight!=null&&s!==null&&n>=a.columnHeaderHeight*l&&n<=a.columnHeaderHeight*l+a.filterBarHeight&&(c=s),c!==i&&this.irisGrid.setState({hoverAdvancedFilter:c}),!1}onLeave(t){const{column:n}=t,{hoverAdvancedFilter:s}=this.irisGrid.state;return s!==null&&n!==s&&this.irisGrid.setState({hoverAdvancedFilter:null}),!1}}class Vu extends Ke{constructor(t){super(750),this.irisGrid=t}destroyTooltip(){this.irisGrid.setState({expandCellTooltipProps:null})}setCursor(t,n){return bs.isInTreeBox(t,n)?(this.cursor="pointer",{stopPropagation:!1,preventDefault:!1}):(this.cursor=null,!1)}getButtonPosition({x:t,y:n,column:s,row:o}){if(s==null||o==null)return null;const{renderer:i,grid:r,state:l,props:a}=this.irisGrid;if(!r)return null;const{metrics:c}=l,{model:d}=a,{canvasContext:u}=r,h=r.getTheme(),g={context:u,mouseX:t,mouseY:n,metrics:c,model:d,theme:h},p=Me(d)?d.depthForRow(o):null,{left:f,top:C,width:w,height:S}=i.getExpandButtonPosition(g,p);return f==null||w==null||C==null||S==null?null:{left:f,top:C,width:w,height:S}}onMove(t,n){if(bs.isInTreeBox(t,n)){const{expandCellTooltipProps:s}=this.irisGrid.state,{model:o}=this.irisGrid.props,i=this.getButtonPosition(t),{row:r}=t;M(r);const l=Me(o)&&o.isRowExpanded(r);it(s,i)||this.irisGrid.setState({expandCellTooltipProps:i,expandTooltipDisplayValue:l?"collapse":"expand"})}else this.destroyTooltip();return this.setCursor(t,n)}onDown(){return this.destroyTooltip(),!1}onContextMenu(){return this.destroyTooltip(),!1}onWheel(){return this.destroyTooltip(),!1}onLeave(){return this.destroyTooltip(),!1}}class Uu extends Ke{constructor(t){super(),this.column=null,this.irisGrid=t}getColumnFromGridPoint(t){const{column:n,row:s,columnHeaderDepth:o}=t;return n!==null&&s===null&&o===0?n:null}onDown(t){return this.column=this.getColumnFromGridPoint(t),!1}onClick(t,n,s){const o=this.getColumnFromGridPoint(t);if(o!=null&&o===this.column){const i=_n.isModifierKeyDown(s);return this.irisGrid.toggleSort(o,i),!0}return!1}}class Bu extends Ke{constructor(t){super(),this.irisGrid=t}onWheel(t,n,s){const{irisGrid:o}=this,{model:i}=o.props,{metrics:r,pendingRowCount:l}=o.state;M(r);const{bottom:a,rowCount:c,rowHeight:d}=r,{deltaY:u}=_.getScrollDelta(s);return Pe(i)&&i.isEditable&&a>=c-1&&u>0&&o.setState({pendingRowCount:l+Math.ceil(u/d)}),!1}}const Gu=3e3;function Wu({children:e=null,onEntering:t,onEntered:n,onExiting:s,onExited:o}){const[i,r]=F.exports.useState(!1),l=F.exports.useRef(),a=$i(e),c=F.exports.useCallback(()=>{r(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{r(!1)},Gu)},[r,l]);return F.exports.useEffect(()=>{a!==e&&e!=null&&c()},[e,a,r,c]),F.exports.useEffect(()=>()=>l.current?clearTimeout(l.current):void 0,[]),m(Jo,{className:"toast-bottom-bar",isShown:i,onEntering:t,onEntered:n,onExiting:s,onExited:o,children:e})}class $u extends js{getGridY(t){let n=super.getGridY(t);const{isFilterBarShown:s,theme:o,advancedFilters:i,quickFilters:r,sorts:l,reverseType:a}=t;return s?n+=o.filterBarHeight:(r!=null&&r.size>0||i!=null&&i.size>0)&&(n+=o.filterBarCollapsedHeight),a!==N.REVERSE_TYPE.NONE&&l!=null&&l.length>0&&(n+=o.reverseHeaderBarHeight),n}getUserColumnWidths(){return this.userColumnWidths}}const zu=1,Al=De.memo(({model:e,modelColumns:t,top:n,bottom:s,left:o,right:i,filter:r,formatter:l,reverseType:a=N.REVERSE_TYPE.NONE,sorts:c,customColumns:d,movedColumns:u,hiddenColumns:h,alwaysFetchColumns:g,rollupConfig:p=null,totalsConfig:f=null,selectDistinctColumns:C=ye,pendingRowCount:w=0,pendingDataMap:S=rn,frozenColumns:b,formatColumns:v,columnHeaderGroups:T})=>{const R=F.exports.useMemo(()=>Q.getModelViewportColumns(t,o,i,u,h,g,zu),[t,o,i,u,h,g]);return F.exports.useEffect(function(){e.filter=r},[e,r]),F.exports.useEffect(function(){const A=[...c];a!==N.REVERSE_TYPE.NONE&&A.push(E.Table.reverse()),e.sort=A},[e,c,a]),F.exports.useEffect(function(){e.formatter=l},[e,l]),F.exports.useEffect(function(){e.isCustomColumnsAvailable&&(e.customColumns=d)},[e,d]),F.exports.useEffect(function(){e.isFormatColumnsAvailable&&(e.formatColumns=v)},[e,v]),F.exports.useEffect(function(){e.setViewport(n,s,R)},[e,n,s,R]),F.exports.useEffect(function(){e.isRollupAvailable&&(e.rollupConfig=p)},[e,e.isRollupAvailable,p]),F.exports.useEffect(function(){e.isSelectDistinctAvailable&&(e.selectDistinctColumns=C)},[e,C]),F.exports.useEffect(function(){e.isTotalsAvailable&&(e.totalsConfig=f)},[e,e.isTotalsAvailable,f]),F.exports.useEffect(function(){e.pendingRowCount=w},[e,w]),F.exports.useEffect(function(){e.pendingDataMap=S},[e,S]),F.exports.useEffect(function(){b&&e.updateFrozenColumns(b)},[e,b]),F.exports.useEffect(function(){e.columnHeaderGroups=T},[e,T]),null});Al.displayName="IrisGridModelUpdater";const _t=Object.freeze({SORT_UP:"sortUp",SORT_DOWN:"sortDown",CARET_DOWN:"caretDown",CARET_RIGHT:"caretRight",CELL_OVERFLOW:"cellOverflow"}),kr=10,pi=16;class Ys extends ts{constructor(){super(),this.icons={},this.initIcons()}static isFilterValid(t,n){const s=t==null||t.filter!=null,o=n==null||n.filter!=null;return s&&o}initIcons(){this.setIcon(_t.SORT_UP,Ba),this.setIcon(_t.SORT_DOWN,Ga),this.setIcon(_t.CARET_DOWN,Xn),this.setIcon(_t.CARET_RIGHT,ll),this.setIcon(_t.CELL_OVERFLOW,Wa)}setIcon(t,n){const s=Array.isArray(n.icon[4])?n.icon[4][0]:n.icon[4],o=new Path2D(s),i=new Path2D,r={a:pi/n.icon[0],d:pi/n.icon[1]};i.addPath(o,r),this.icons[t]=i}getIcon(t){return this.icons[t]}getSortIcon(t){return t?t.direction===N.sortDirection.ascending?this.getIcon(_t.SORT_UP):t.direction===N.sortDirection.descending?this.getIcon(_t.SORT_DOWN):null:null}drawCanvas(t){super.drawCanvas(t),this.drawScrim(t)}drawGrid(t,n){super.drawGrid(t,n),this.drawCellOverflowButton(n)}drawGridLines(t,n){super.drawGridLines(t,n),this.drawGroupedColumnLine(t,n),this.drawPendingRowLine(t,n)}drawCellContent(t,n,s,o){var h;const{metrics:i,model:r}=n,{modelColumns:l,modelRows:a}=i,c=O(a,o),d=l.get(s);if(d===void 0)return;const u=r.valueForCell(d,c);if(N.isTextType((h=r.columns[d])==null?void 0:h.type)&&(u===null||u==="")){const g=t.font;t.font=`italic ${g}`;const p=u===null?"null":"empty";super.drawCellContent(t,n,s,o,p),t.font=g;return}super.drawCellContent(t,n,s,o)}drawGroupedColumnLine(t,n){const{metrics:s,model:o,theme:i}=n,{groupedColumns:r,columns:l}=o,{maxY:a,allColumnWidths:c,allColumnXs:d}=s;if(r.length===0||i.groupedColumnDividerColor==null)return;const u=r[r.length-1],h=l.findIndex(C=>C.name===u.name),g=d.get(h),p=c.get(h);if(g==null||p==null)return;const f=g+p+.5;t.strokeStyle=i.groupedColumnDividerColor,t.lineWidth=1,t.beginPath(),t.moveTo(f,0),t.lineTo(f,a),t.stroke()}drawPendingRowLine(t,n){const{metrics:s,model:o,theme:i}=n,{allRowYs:r,maxX:l}=s,{pendingRowCount:a}=o;if(a<=0)return;const c=o.rowCount-o.pendingRowCount-o.floatingBottomRowCount;let d=r.get(c);d!=null&&(d-=.5,t.save(),t.setLineDash([4,2]),t.strokeStyle=i.pendingTextColor,t.lineWidth=1,t.beginPath(),t.moveTo(0,d),t.lineTo(l,d),t.stroke(),t.restore())}drawMouseColumnHover(t,n){const{theme:s,metrics:o,hoverSelectColumn:i}=n;if(i==null||s.linkerColumnHoverBackgroundColor==null)return;const{allColumnWidths:r,allColumnXs:l,maxY:a}=o,c=l.get(i),d=r.get(i);M(c),M(d),t.fillStyle=s.linkerColumnHoverBackgroundColor,t.fillRect(c,0,d,a)}drawMouseRowHover(t,n){const{isSelectingColumn:s}=n;s||super.drawMouseRowHover(t,n)}drawScrim(t){const{context:n,loadingScrimProgress:s,metrics:o,theme:i}=t;if(s==null)return;const{width:r,height:l,gridY:a}=o,{scrimBlurSize:c,scrimColor:d}=i;n.save(),n.globalCompositeOperation="color",n.filter=`blur(${c}px)`,d!=null&&(n.fillStyle=d),n.beginPath(),n.rect(0,a,r,l-a),n.clip(),n.fillRect(-c,-c+a,c*2+r,(c*2+(l-a))*s),n.globalCompositeOperation="overlay",n.filter=`blur(${c}px) opacity(15%)`,n.fillRect(-c,-c+a,c*2+r,(c*2+(l-a))*s),n.restore()}drawColumnHeaders(t,n){super.drawColumnHeaders(t,n);const{theme:s,metrics:o,model:i,reverseType:r}=n,{columnHeaderHeight:l}=o;if(this.drawFilterHeaders(t,n),l<=0)return;const{sort:a}=i;if(a.length===1){const c=r!==N.REVERSE_TYPE.NONE;let d;c?d=s.headerReverseBarColor:d=s.headerSortBarColor,this.drawHeaderBar(t,n,d,c?s.reverseHeaderBarHeight:s.sortHeaderBarHeight)}else a.length>1&&(r!==N.REVERSE_TYPE.NONE&&this.drawHeaderBar(t,n,s.headerReverseBarColor,s.reverseHeaderBarHeight,!1),this.drawHeaderBar(t,n,s.headerSortBarColor,s.sortHeaderBarHeight))}drawHeaderBar(t,n,s,o,i=!0){const{theme:r,metrics:l,model:a}=n,{columnHeaderHeight:c,width:d}=l;let u=0;i||(u=o),t.fillStyle=r.headerBarCasingColor,t.fillRect(0,a.columnHeaderMaxDepth*c-o-2+u,d,o+2),t.fillStyle=s,t.fillRect(0,a.columnHeaderMaxDepth*c-o-1+u,d,o)}drawColumnHeadersAtDepth(t,n,s,o,i){const{metrics:r,model:l,isMenuShown:a}=n,{columnHeaderMaxDepth:c}=l,{width:d}=r,u={...o,maxX:i===c-1&&o.maxX===d?d-(a?0:30):o.maxX};super.drawColumnHeadersAtDepth(t,n,s,u,i)}drawColumnHeaderAtIndex(t,n,s,o){var W;super.drawColumnHeaderAtIndex(t,n,s,o);const{metrics:i,model:r,theme:l}=n,{modelColumns:a,allColumnWidths:c,allColumnXs:d,gridX:u,columnHeaderHeight:h,fontWidths:g}=i,{headerHorizontalPadding:p}=l,f=O(c,s,0),C=O(d,s)+u,w=a.get(s);if(w==null)return;const S=N.getSortForColumn(r.sort,w);if(!S)return;const b=this.getSortIcon(S);if(!b)return;const v=r.textForColumnHeader(w);if(v===void 0)return;const T=(W=g.get(t.font))!=null?W:ts.DEFAULT_FONT_WIDTH;M(T);const R=v.length*T,D=u+C+R+p;let{maxX:A}=o;A-=p;const I=u+C+f-p-1,L=D>A?D+1:Math.min(A,I),k=S.direction===N.sortDirection.ascending?-6:-12,x=h*.5+k;t.save(),t.beginPath(),t.rect(C,0,f,h),t.clip(),t.fillStyle=l.headerSortBarColor,t.translate(L,x),t.fill(b),t.restore()}drawFilterHeaders(t,n){const{isFilterBarShown:s,quickFilters:o,advancedFilters:i}=n;s?this.drawExpandedFilterHeaders(t,n):(o!=null&&o.size>0||i!=null&&i.size>0)&&this.drawCollapsedFilterHeaders(t,n)}drawExpandedFilterHeaders(t,n){const{metrics:s,model:o,theme:i,quickFilters:r,advancedFilters:l}=n,{filterBarHeight:a}=i;if(a<=0)return;const{gridX:c,gridY:d,maxX:u,modelColumns:h,visibleColumns:g,allColumnWidths:p,allColumnXs:f}=s,C=d-a;t.save(),t.font=i.font,t.textAlign="left",r!=null&&r.size>0||l!=null&&l.size>0?t.fillStyle=i.filterBarExpandedActiveBackgroundColor:t.fillStyle=i.filterBarExpandedBackgroundColor,t.fillRect(c,C,u,a-1),t.fillStyle=i.headerBarCasingColor,t.fillRect(c,C+a-1,u,1);const w=C;t.strokeStyle=i.filterBarSeparatorColor,t.beginPath();for(let S=0;S<g.length;S+=1){const b=g[S],v=O(h,b),T=O(f,b),R=O(p,b);if(o.isFilterable(v)&&R>0){const D=c+(T!=null?T:0);t.rect(D+.5,w+.5,R,a-2)}}t.stroke();for(let S=0;S<g.length;S+=1){const b=g[S],v=O(p,b),R=O(f,b)+c;this.drawExpandedFilterHeader(t,n,b,R,v)}t.restore()}drawExpandedFilterHeader(t,n,s,o,i){if(i<=0)return;const{metrics:r,theme:l,quickFilters:a,advancedFilters:c}=n,{modelColumns:d,gridY:u}=r,{filterBarHeight:h,filterBarExpandedActiveCellBackgroundColor:g,filterBarErrorColor:p,filterBarHorizontalPadding:f,headerColor:C}=l,w=u-h,S=d.get(s);if(S===void 0)return;const b=a.get(S),v=c.get(S);if(b==null&&v==null)return;let T=null;if(b!=null){const{text:D}=b;if(T=D,T||(T=N.getFilterText(b.filter)),T!=null){const{fontWidths:A}=r;let I=A.get(t.font);(I==null||I===0)&&(I=t.measureText("8").width,I||(I=10));const L=(i-f*2)/I;L<=0?T="":T.length>L&&(T=`${T.substring(0,L-1)}\u2026`)}}if(t.save(),Ys.isFilterValid(v,b)&&g!=null)t.fillStyle=g,t.fillRect(o+1,w+1,i-1,h-3);else if(p!=null){t.fillStyle=p,t.lineWidth=2,t.strokeStyle=p;const D=o+2,A=w+2,I=i-3,L=h-5;t.strokeRect(D,A,I,L)}if(T!=null&&T!==""){const D=o+f,A=w+h*.5+1;t.fillStyle=C,t.fillText(T,D,A)}t.restore()}drawCollapsedFilterHeaders(t,n){const{metrics:s,theme:o}=n,{headerSeparatorColor:i,filterBarCollapsedHeight:r}=o;if(r<=0)return;const{gridX:l,gridY:a,maxX:c,visibleColumns:d,allColumnWidths:u,allColumnXs:h}=s,g=a-r;t.save(),t.fillStyle=i,t.fillRect(l,g,c,r);for(let p=0;p<d.length;p+=1){const f=d[p],C=u.get(f),w=h.get(f);if(w!=null&&C!=null){const S=w+l;this.drawCollapsedFilterHeader(t,n,f,S,C)}}t.restore()}drawCollapsedFilterHeader(t,n,s,o,i){if(i<=0)return;const{metrics:r,theme:l,quickFilters:a,advancedFilters:c}=n,{modelColumns:d,gridY:u}=r,h=d.get(s);if(h===void 0)return;const g=a.get(h),p=c.get(h),{filterBarCollapsedHeight:f,filterBarActiveColor:C,filterBarActiveBackgroundColor:w,filterBarErrorColor:S}=l;t.save();const b=Ys.isFilterValid(p,g);w!=null&&g==null&&p==null?t.fillStyle=w:C!=null&&b?t.fillStyle=C:S!=null&&(t.fillStyle=S);const v=o+1,T=u-f,R=i-1,D=f-1;t.fillRect(v,T,R,D),t.restore()}drawTreeMarker(t,n,s,o,i,r,l){t.save();const{x1:a,y1:c}=i,d=l?this.getIcon(_t.CARET_DOWN):this.getIcon(_t.CARET_RIGHT),u=s+a-2,h=o+c+2.5;t.fillStyle=r,t.textAlign="center",t.translate(u,h),t.fill(d),t.restore()}drawRowFooters(t,n){const{metrics:s,model:o,mouseX:i,mouseY:r,theme:l}=n,{gridY:a,gridX:c,maxX:d,modelRows:u,floatingTopHeight:h,floatingBottomHeight:g,floatingRows:p,rowFooterWidth:f,height:C,horizontalBarHeight:w,verticalBarWidth:S,allRowHeights:b,allRowYs:v,width:T}=s;if(f<=0||p.length===0)return;const{cellHorizontalPadding:R,floatingGridRowColor:D,floatingRowBackgroundColors:A,headerColor:I,rowHoverBackgroundColor:L}=l;t.translate(c,a),t.beginPath();const k=Math.min(d,T-f-S-c);t.fillStyle=A,h>0&&t.rect(k,0,f,h),g>0&&t.rect(k,C-a-w-g,f,g),t.fill();const x=i!=null&&r!=null&&i>=c&&i<=d+f?_.getRowAtY(r,s):null;if(L!=null&&x!==null&&p.includes(x)){t.fillStyle=L;const V=v.get(x),Y=b.get(x);M(V),M(Y),t.fillRect(k,V,f,Y)}if(t.beginPath(),D!=null&&(t.strokeStyle=D),h>0&&(t.moveTo(k+.5,.5),t.lineTo(k+.5,h-.5)),g>0){const V=C-a-w-g;t.moveTo(k-.5,V+.5),t.lineTo(k-.5,V+g-.5)}t.stroke(),t.fillStyle=I,t.textAlign="left";const W=k+R;for(let V=0;V<p.length;V+=1){const Y=p[V],j=b.get(Y),ie=v.get(Y),G=u.get(Y);if(ie!=null&&j!=null&&G!=null){const ee=ie+j*.5;t.fillText(o.textForRowFooter(G),W,ee)}}t.translate(-c,-a)}getTextRenderMetrics(t,n,s,o){const i=super.getTextRenderMetrics(t,n,s,o),{mouseX:r,mouseY:l,metrics:a}=n;if(r==null||l==null)return i;const{column:c,row:d}=_.getGridPointFromXY(r,l,a);if(s===c&&o===d){const{left:u}=this.getCellOverflowButtonPosition(n);this.shouldRenderOverflowButton(n)&&u!=null&&(i.width=u-a.gridX-i.x)}return i}shouldRenderOverflowButton(t){var C,w;const{context:n,mouseX:s,mouseY:o,metrics:i,model:r,theme:l}=t;if(s==null||o==null)return!1;const{row:a,column:c,modelRow:d,modelColumn:u}=_.getCellInfoFromXY(s,o,i);if(a==null||c==null||d==null||u==null||!N.isStringType(r.columns[u].type))return!1;const h=(C=r.textForCell(u,d))!=null?C:"",{width:g}=super.getTextRenderMetrics(n,t,c,a),p=(w=i.fontWidths.get(l.font))!=null?w:Ys.DEFAULT_FONT_WIDTH;n.save(),n.font=l.font;const f=this.getCachedTruncatedString(n,h,g,p,r.truncationCharForCell(u,d));return n.restore(),h!==""&&f!==h}getCellOverflowButtonPosition({mouseX:t,mouseY:n,metrics:s,theme:o}){const i={left:null,top:null,width:null,height:null};if(t==null||n==null||!s)return i;const{rowHeight:r,columnWidth:l,left:a,top:c}=_.getCellInfoFromXY(t,n,s);M(a),M(l),M(c);const{width:d,verticalBarWidth:u}=s,{cellHorizontalPadding:h}=o,g=pi+2*h,p=r,C=Math.min(s.gridX+a+l,d-u)-g,w=s.gridY+c;return{left:C,top:w,width:g,height:p}}drawCellOverflowButton(t){const{context:n,mouseX:s,mouseY:o,theme:i}=t;if(s==null||o==null||!this.shouldRenderOverflowButton(t))return;const{left:r,top:l,width:a,height:c}=this.getCellOverflowButtonPosition(t),{cellHorizontalPadding:d,overflowButtonColor:u,overflowButtonHoverColor:h}=i;n.save(),h!=null&&r!=null&&a!=null&&l!=null&&c!=null&&s>=r&&s<=r+a&&o>=l&&o<=l+c?n.fillStyle=h:u!=null&&(n.fillStyle=u);const g=this.getIcon(_t.CELL_OVERFLOW);r!=null&&l!=null&&n.translate(r+d,l+2),n.fill(g),n.restore()}getExpandButtonPosition({mouseX:t,mouseY:n,metrics:s,theme:o},i){const r={left:null,top:null,width:null,height:null};if(t==null||n==null||i==null||!s)return r;const{rowHeight:l,left:a,top:c}=_.getCellInfoFromXY(t,n,s);M(a),M(l),M(c);const{cellHorizontalPadding:d}=o,u=kr+2*d,h=Math.max(a+kr*i,s.gridX),g=s.gridY+c;return{left:h,top:g,width:u,height:l}}}const qu="12px Fira Sans, sans-serif",Yu="#f0f0ee",Xu="#1a171a",te={"grid-bg":"#211f22",font:qu,white:Yu,black:Xu,"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","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"},Ml=Object.freeze({backgroundColor:te["grid-bg"],white:te.white,black:te.black,font:te.font,headerBackgroundColor:te["header-bg"],headerColor:te["header-color"],headerSeparatorColor:te["header-separator-color"],headerSeparatorHoverColor:te["header-separator-hover-color"],headerHiddenSeparatorHoverColor:te["header-hidden-separator-hover-color"],headerSortBarColor:te["header-sort-bar-color"],headerReverseBarColor:te["header-reverse-bar-color"],headerBarCasingColor:te["header-bar-casing-color"],headerFont:te["header-font"],rowBackgroundColors:te["row-background-colors"],rowHoverBackgroundColor:te["row-hover-bg"],selectionColor:te["selection-color"],selectionOutlineColor:te["selection-outline-color"],selectionOutlineCasingColor:te["selection-outline-casing-color"],selectedRowHoverBackgroundColor:te["selected-row-hover-bg"],scrollBarBackgroundColor:te["scroll-bar-bg"],scrollBarHoverBackgroundColor:te["scroll-bar-hover-bg"],scrollBarCasingColor:te["scroll-bar-casing-color"],scrollBarCornerColor:te["scroll-bar-corner-color"],scrollBarColor:te["scroll-bar-color"],scrollBarHoverColor:te["scroll-bar-hover-color"],scrollBarActiveColor:te["scroll-bar-active-color"],scrollBarSelectionTickColor:te["selected-row-hover-bg"],scrollBarActiveSelectionTickColor:te["scroll-bar-active-selection-tick-color"],textColor:te["text-color"],positiveNumberColor:te["positive-number-color"],negativeNumberColor:te["negative-number-color"],zeroNumberColor:te["zero-number-color"],dateColor:te["date-color"],pendingTextColor:te["pending-text-color"],errorTextColor:te["error-text-color"],nullStringColor:te["null-string-color"],filterBarActiveBackgroundColor:te["filter-bar-active-bg"],filterBarExpandedBackgroundColor:te["filter-bar-expanded-bg"],filterBarExpandedActiveBackgroundColor:te["filter-bar-expanded-active-bg"],filterBarExpandedActiveCellBackgroundColor:te["filter-bar-expanded-active-cell-bg"],filterBarSeparatorColor:te["filter-bar-separator-color"],filterBarActiveColor:te["filter-bar-active-color"],filterBarErrorColor:te["filter-bar-error-color"],filterIconColor:te["filter-icon-color"],scrimColor:te["scrim-color"],contextMenuSortIconColor:te["context-menu-sort-icon-color"],contextMenuReverseIconColor:te["context-menu-reverse-icon-color"],allowRowResize:!1,autoSelectRow:!0,gridColumnColor:null,gridRowColor:null,groupedColumnDividerColor:te["grouped-column-divider-color"],columnHoverBackgroundColor:null,headerHorizontalPadding:12,scrollBarSize:13,scrollBarHoverSize:16,minScrollHandleSize:24,rowHeight:parseInt(te["row-height"],10)||19,columnWidth:100,rowHeaderWidth:0,rowFooterWidth:60,columnHeaderHeight:parseInt(te["header-height"],10)||30,filterBarHeight:30,filterBarCollapsedHeight:5,sortHeaderBarHeight:2,reverseHeaderBarHeight:4,filterBarHorizontalPadding:4,scrimBlurSize:25,minScrimTransitionTime:150,maxScrimTransitionTime:350,scrollSnapToRow:!0,linkerColumnHoverBackgroundColor:te["linker-column-hover-bg"],treeLineColor:te["tree-line-color"],treeMarkerColor:te["tree-marker-color"],treeMarkerHoverColor:te["tree-marker-hover-color"],floatingGridColumnColor:null,floatingGridRowColor:te["floating-grid-row-color"],floatingRowBackgroundColors:te["floating-row-background-colors"],floatingDividerInnerColor:te["floating-divider-inner-color"],floatingDividerOuterColor:te["floating-divider-outer-color"],overflowButtonColor:te["overflow-button-color"],overflowButtonHoverColor:te["overflow-button-hover-color"]});const fi=le.module("ColumnStatistics"),Ku={SIZE:"Number of Rows"},Ii=class extends F.exports.Component{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}}static getStatsLabel(e){var t;return(t=Ku[e])!=null?t:e.split(" ").map(n=>n[0].toUpperCase()+n.substr(1).toLowerCase()).join(" ")}componentDidMount(){this.maybeGenerateStatistics()}componentWillUnmount(){this.cancelablePromise&&this.cancelablePromise.cancel()}maybeGenerateStatistics(){const{model:e}=this.props,t=e.rowCount-e.pendingRowCount;this.setState({numRows:t}),e.isColumnStatisticsAvailable?t<Ii.AUTO_GENERATE_LIMIT&&this.handleGenerateStatistics():this.setState({loading:!1})}handleGenerateStatistics(){this.setState({loading:!0});const{column:e,model:t}=this.props;this.cancelablePromise=ze.makeCancelable(t.columnStatistics(e)),this.cancelablePromise.then(this.handleStatistics).catch(this.handleError)}handleStatistics(e){fi.debug("Received statistics",e);const{model:t,onStatistics:n}=this.props,s=[];e.statisticsMap.forEach((o,i)=>{s.push({operation:Ii.getStatsLabel(i),value:o,type:e.getType(i)})}),e.uniqueValues.forEach((o,i)=>{s.push({operation:i,className:"column-statistics-unique-value",value:o,type:"long"})}),this.setState({loading:!1,statistics:s,numRows:t.rowCount-t.pendingRowCount}),n()}handleError(e){if(e!=null&&ze.isCanceled(e)){fi.debug("Called handleError on a cancelled promise result");return}fi.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:o,numRows:i}=this.state,r=!s&&n==null&&o==null&&t.isColumnStatisticsAvailable,l=[],a=e.type.substring(e.type.lastIndexOf(".")+1),c=e.description===null?null:e.description;if(o!=null)for(let g=0;g<o.length;g+=1){const{operation:p,className:f,value:C,type:w}=o[g],S=w?t.displayString(C,w):t.displayString(C,e.type,e.name),b=y(De.Fragment,{children:[m("div",{className:Z("column-statistic-operation",f),children:p}),m("div",{className:"column-statistic-value",children:S})]},p);l.push(b)}const d=Me(t)&&t.hasExpandableRows?"Expanded Rows":"Number of Rows",u=t.displayString(i,"long"),h=t.getColumnIndexByName(e.name);return y("div",{className:"column-statistics",children:[y("div",{className:"column-statistics-title",children:[e.name,y("span",{className:"column-statistics-type",children:["\xA0(",a,")"]}),m(gl,{className:"column-statistics-copy",tooltip:"Copy column name",copy:e.name})]}),c!=null&&m("div",{className:"column-statistics-description",children:c}),h!=null&&!t.isColumnMovable(h)&&y("div",{className:"column-statistics-status",children:[m(J,{icon:t.isColumnFrozen(h)?$a:za,className:"mr-1"}),t.isColumnFrozen(h)?"Frozen":"Not movable"]}),y("div",{className:"column-statistics-grid",children:[o==null&&y(Oe,{children:[m("div",{className:"column-statistic-operation",children:d}),m("div",{className:"column-statistic-value",children:u})]}),l]}),r&&m(z,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,children:"Generate Stats"}),n!=null&&m("div",{className:"error-message",children:`${n}`}),o&&!s&&m(z,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,icon:m(J,{icon:qa,className:"mr-1"}),children:"Refresh"}),s&&y("div",{className:"column-statistics-loading",children:[m(dn,{className:"mr-2"}),"Calculating Stats..."]})]})}};let Ol=Ii;Ol.AUTO_GENERATE_LIMIT=1e5;const Fo=le.module("AdvancedFilterCreatorFilterItem");class ji extends F.exports.PureComponent{constructor(t){super(t),this.getCachedIsValid=Fe((i,r,l,a)=>{try{return!l||N.makeAdvancedValueFilter(i,r,l,a)!=null}catch{return!1}}),this.handleDelete=this.handleDelete.bind(this),this.handleTypeChange=this.handleTypeChange.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.typeDropdown=null;const{value:n="",filterTypes:s,selectedType:o=s[0]}=t;this.state={selectedType:o,value:n}}static getLabelForFilter(t,n){try{if(N.isNumberType(t)||N.isCharType(t))return _d(n);if(N.isTextType(t))return Pd(n);if(N.isDateType(t))return Hd(n);if(N.isBooleanType(t))return Vd(n);throw new Error(`Unrecognized column type: ${t}`)}catch(s){return Fo.warn(s),""}}componentDidMount(){var t;(t=this.typeDropdown)==null||t.focus()}componentDidUpdate(t){const{value:n,selectedType:s}=this.props;s!==void 0&&t.selectedType!==s&&this.setState({selectedType:s}),n!==void 0&&t.value!==n&&this.setState({value:n})}handleTypeChange(t){const n=t.target.value;Fo.debug2("typeChange",n),this.setState({selectedType:n});const{onChange:s}=this.props,{value:o}=this.state;o!=null&&o.length>0&&s(n,o)}handleValueChange(t){Fo.debug2("valueChange");const{value:n}=t.target;this.setState({value:n});const{onChange:s}=this.props,{selectedType:o}=this.state;o!=null&&s(o,n)}handleDelete(){Fo.debug("delete");const{onDelete:t}=this.props;t()}render(){const{column:t,filterTypes:n,formatter:s}=this.props,{selectedType:o,value:i}=this.state,r=!N.isBooleanType(t.type),l=[],a=this.getCachedIsValid(t,o,i,s.timeZone);for(let c=0;c<n.length;c+=1){const d=n[c],u=ji.getLabelForFilter(t.type,d),h=m("option",{value:d,children:u},d);l.push(h)}return m("div",{className:"advanced-filter-creator-filter-item",children:y("div",{className:"form-row",children:[m("div",{className:"form-group col",children:m("select",{className:"form-control custom-select",value:o,onChange:this.handleTypeChange,ref:c=>{this.typeDropdown=c},children:l})}),r&&m("div",{className:"form-group col",children:m("div",{className:"input-group",children:m("input",{type:"text",className:Z("form-control",{error:!a}),placeholder:"Enter value",value:i,onChange:this.handleValueChange})})}),m("div",{className:"form-group col-1 px-0",children:m(z,{kind:"ghost",className:"w-100 h-100 p-0 m-0",onClick:this.handleDelete,icon:un,tooltip:"Remove Filter"})})]})})}}const Lr=le.module("AdvancedFilterCreatorSelectValueList"),Ni=class extends F.exports.PureComponent{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}}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}componentDidMount(){const{table:e}=this.props;e&&this.startListening(e)}componentDidUpdate(e){const{filters:t,invertSelection:n,selectedValues:s,table:o}=this.props;e.table!==o&&(e.table&&this.stopListening(e.table),o&&this.startListening(o),this.resetViewport()),e.invertSelection!==n&&this.setState({selectedValues:[]},this.handleSelectionUpdate),e.selectedValues!==s&&this.setState({selectedValues:s},this.handleSelectionUpdate),e.filters!==t&&(o==null||o.applyFilter(t),this.resetViewport())}componentWillUnmount(){const{table:e}=this.props;e&&this.stopListening(e)}handleSelect(e,t){const{invertSelection:n}=this.props;let{selectedValues:s}=this.state;s=[...s];const o=Ni.indexOf(t,s);o>=0?s.splice(o,1):s.push(t);let i=o<0;n&&(i=!i);const{offset:r}=this.state;let{items:l}=this.state;l=[...l];const a=e-r;a>=0&&a<l.length&&(l[a].isSelected=i),this.setState({items:l,selectedValues:s});const{onChange:c}=this.props;c(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:o}=s,i=[],r=t.columns[0];for(let a=0;a<s.rows.length;a+=1){const d=s.rows[a].get(r),u=n.getFormattedString(d,r.type,r.name),h=this.isValueSelected(d);i.push({displayValue:u,value:d,isSelected:h})}Lr.debug2("Received table update:",o,i.length);const l=t.size;this.setState({itemCount:l,items:i,offset:o,isLoading:!1})}isValueSelected(e){const{invertSelection:t}=this.props,{selectedValues:n}=this.state,s=Ni.indexOf(e,n);return t?s<0:s>=0}startListening(e){e.addEventListener(E.Table.EVENT_UPDATED,this.handleTableUpdate)}stopListening(e){e.removeEventListener(E.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 o=t-e+1,i=Math.max(0,e-o*3),r=Math.max(i,t+o*3);Lr.debug2("Setting viewport",i,",",r),s.setViewport(i,r)}render(){const{offset:e,isLoading:t,items:n,itemCount:s}=this.state;return y("div",{className:"select-value-list-wrapper",children:[m(Ya,{itemCount:s,items:n,offset:e,onSelect:this.handleSelect,onViewportChange:this.handleViewportChange,ref:o=>{this.list=o}}),m($t,{in:t,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:m("div",{className:"loading-list",children:m(dn,{className:"loading-spinner-large"})})})]})}};let xl=Ni;xl.defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{}};const kl=class extends F.exports.PureComponent{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:o}=this.props;e.table!==o&&this.initSearchTable(),e.invertSelection!==n&&this.setState({invertSelection:n}),e.selectedValues!==s&&this.setState({selectedValues:s});const{table:i,searchText:r}=this.state;i!==t.table&&(t.table!=null&&t.table.close(),i!=null&&this.startUpdateFilterTimer()),r!==t.searchText&&this.startUpdateFilterTimer()}componentWillUnmount(){const{table:e}=this.state;e!=null&&e.close(),this.searchTablePromise=void 0,this.stopUpdateFilterTimer()}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"),o=n.getFormattedString(t.totalSize,"long");let i="";return e<1e6&&(i="Displaying "),`${i}${s} of ${o}`}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,kl.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==null?void 0:e.columns[0],o=[];if(s==null)return;let i;if(t.length>0){let r=null;N.isCharType(s.type)?r=N.makeQuickFilter(s,t):N.isTextType(s.type)?r=N.makeQuickFilter(s,`~${t}`,n):r=N.makeQuickFilter(s,`>=${t}`,n),r!=null?o.push(r):i="Invalid search text"}this.setState({filters:o,error:i})}render(){const{error:e,filters:t,invertSelection:n,selectedValues:s,searchText:o,table:i}=this.state,{formatter:r,showSearch:l}=this.props,a=this.getColumnName(),c=this.getDisplayedValueText(),d=a?`Find ${a}...`:"";return y("div",{className:"advanced-filter-creator-select-value",children:[y("div",{className:l?"form-group":"",children:[m("label",{htmlFor:"advanced-filter-creator-select-value-input",children:"Select Values"}),l&&m("input",{type:"text",className:Z("form-control",{"is-invalid":e!=null}),id:"advanced-filter-creator-select-value-input",placeholder:d,value:o,onChange:this.handleSearchChange})]}),m(xl,{table:i,filters:t,invertSelection:n,selectedValues:s,formatter:r,onChange:this.handleListChange}),y("div",{className:"advanced-filter-creator-select-meta-row",children:[y("div",{children:[m(z,{kind:"ghost",onClick:this.handleSelectAllClick,children:"Select All"}),m(z,{kind:"ghost",onClick:this.handleClearAllClick,children:"Clear"})]}),m($t,{in:c!=null,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:m("div",{className:"row-count-info",children:c})})]})]})}};let Zi=kl;Zi.searchDebounceTime=250;Zi.defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{},showSearch:!0};const Ps=le.module("AdvancedFilterCreator"),Yn=class extends F.exports.PureComponent{constructor(e){var r,l;super(e),this.getFilterTypes=Fe(a=>N.getFilterTypes(a)),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=De.createRef();const{options:t}=e;let{filterOperators:n,invertSelection:s,selectedValues:o}=t;const i=(l=(r=t.filterItems)==null?void 0:r.map(({selectedType:a,value:c})=>({selectedType:a,value:c,key:Ln()})))!=null?l:[];i.length===0&&i.push(Yn.makeFilterItem()),n==null&&(n=[]),s==null&&(s=!0),o==null&&(o=[]),this.state={filterItems:i,filterOperators:n,invertSelection:s,selectedValues:o,valuesTableError:null,valuesTable:void 0}}static makeFilterItem(){return{key:Ln()}}componentDidMount(){this.initValuesTable()}componentWillUnmount(){this.debounceTimeout!=null&&(clearTimeout(this.debounceTimeout),this.sendUpdate()),this.valuesTablePromise!=null&&this.valuesTablePromise.cancel()}getFilterChangeHandler(e){return this.handleFilterChange.bind(this,e)}getFilterDeleteHandler(e){return this.handleFilterDelete.bind(this,e)}initValuesTable(){const{model:e,column:t}=this.props;if(!e.isValuesTableAvailable){Ps.debug("No values table for this model, just ignore");return}this.valuesTablePromise=N.makeCancelableTablePromise(e.valuesTable(t)),this.valuesTablePromise.then(n=>{const s=n.columns[0].sort().asc();n.applySort([s]),this.setState({valuesTable:n})}).catch(n=>{ze.isCanceled(n)||(Ps.error("Unable to open values table",n),this.setState({valuesTableError:n}))})}handleFocusTrapEnd(){var e,t;((t=(e=this.focusTrapContainer)==null?void 0:e.current)==null?void 0:t.querySelector("button,select,input,textarea")).focus()}handleFocusTrapStart(){var t,n;const e=(n=(t=this.focusTrapContainer)==null?void 0:t.current)==null?void 0:n.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(Yn.makeFilterItem()),t=t.concat(Gt.and),this.setState({filterItems:e,filterOperators:t})}handleAddOr(){let{filterItems:e,filterOperators:t}=this.state;e=e.concat(Yn.makeFilterItem()),t=t.concat(Gt.or),this.setState({filterItems:e,filterOperators:t})}handleChangeFilterOperator(e,t){let{filterOperators:n}=this.state;n=[...n],Ld(t),n[e]=t,this.setState({filterOperators:n}),this.startUpdateTimer()}handleFilterChange(e,t,n){let{filterItems:s}=this.state;s=[...s];const{key:o}=s[e];s[e]={key:o,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(Yn.makeFilterItem()),this.setState({filterItems:t,filterOperators:n}),this.startUpdateTimer()}handleSelectValueChange(e,t){this.setState({selectedValues:e,invertSelection:t}),this.startUpdateTimer()}handleReset(){Ps.debug("Resetting Advanced Filter"),this.setState({filterItems:[Yn.makeFilterItem()],filterOperators:[],selectedValues:[],invertSelection:!0}),this.startUpdateTimer()}handleSortDown(e){const t=_n.isModifierKeyDown(e);this.sortTable(N.sortDirection.descending,t)}handleSortUp(e){const t=_n.isModifierKeyDown(e);this.sortTable(N.sortDirection.ascending,t)}handleSubmit(e){Ps.debug("Submitting Advanced Filter"),this.stopUpdateTimer(),this.sendUpdate(),e.preventDefault()}handleDone(e){Ps.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,Yn.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:o,onFilterChange:i,model:r}=this.props,{formatter:l}=r,a=e.filter(({selectedType:h,value:g})=>h!=null&&g!=null&&g!==""),c=t.filter((h,g)=>h!=null&&e[g].selectedType!=null&&e[g].value!=null&&e[g].value!=="").slice(0,a.length-1),d={filterItems:a,filterOperators:c,invertSelection:n,selectedValues:s},u=N.makeAdvancedFilter(o,d,l.timeZone);i(o,u,d)}render(){const{column:e,model:t,sortDirection:n,formatter:s}=this.props,{filterItems:o,filterOperators:i,invertSelection:r,selectedValues:l,valuesTable:a,valuesTableError:c}=this.state,{isValuesTableAvailable:d}=t,u=N.isBooleanType(e.type),h=N.isDateType(e.type),g=this.getFilterTypes(e.type),p=e.type.substring(e.type.lastIndexOf(".")+1),f=[];if(!u&&g.length)for(let S=0;S<o.length;S+=1){const b=o[S],{key:v,selectedType:T,value:R}=b,D=m(ji,{column:e,filterTypes:g,onChange:this.getFilterChangeHandler(S),onDelete:this.getFilterDeleteHandler(S),selectedType:T,value:R,formatter:s},v);if(f.push(D),S<i.length){const I=i[S]===Gt.and,L=y("div",{className:"form-row justify-content-end advanced-filter-creator-filter-operator",children:[m(z,{kind:"ghost",className:Z("filter-operator",{active:I}),onClick:()=>this.handleChangeFilterOperator(S,Gt.and),children:"AND"}),m(z,{kind:"ghost",className:Z("filter-operator",{active:!I}),onClick:()=>this.handleChangeFilterOperator(S,Gt.or),children:"OR"})]},`filterOperator${v}`);f.push(L)}}const C=this.shouldShowAddFilter(),w=y("div",{className:Z("form-row justify-content-end add-filter-item",{hidden:!C}),children:[m("span",{className:"text-muted",children:m(J,{icon:vs})}),m(z,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddAnd,disabled:!C,tooltip:"Add filter with AND",children:"AND"}),m(z,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddOr,disabled:!C,tooltip:"Add filter with OR",children:"OR"})]},"addFilterItem");return f.push(w),y("div",{className:"advanced-filter-creator",role:"presentation",children:[m("div",{tabIndex:0,onFocus:this.handleFocusTrapStart}),y("form",{onSubmit:this.handleSubmit,ref:this.focusTrapContainer,children:[y("div",{className:"title-bar",children:[m("h6",{className:"advanced-filter-title",children:"Advanced Filters"}),y("div",{className:"advanced-filter-menu-buttons",children:[m(z,{kind:"ghost",className:Z("sort-operator",{active:n===N.sortDirection.descending}),onClick:this.handleSortDown,icon:fr,tooltip:`Sort ${e.name} Descending`}),m(z,{kind:"ghost",className:Z("sort-operator",{active:n===N.sortDirection.ascending}),onClick:this.handleSortUp,icon:m(J,{icon:fr,rotation:180}),tooltip:`Sort ${e.name} Ascending`})]})]}),m("hr",{}),y("div",{className:"advanced-filter-column-name",children:[e.name,"\xA0",y("span",{className:"column-type",children:["(",p,")"]})]}),f,d&&c==null&&y(Oe,{children:[!u&&m("hr",{}),m("div",{className:"form-group",children:m(Zi,{table:a,onChange:this.handleSelectValueChange,invertSelection:r,selectedValues:l,formatter:s,showSearch:!h,timeZone:s.timeZone})})]}),y("div",{className:"form-row justify-content-end",children:[m(z,{kind:"secondary",className:"mr-2",onClick:this.handleReset,children:"Reset"}),m(z,{kind:"primary",onClick:this.handleDone,children:"Done"})]})]}),m("div",{tabIndex:0,onFocus:this.handleFocusTrapEnd})]})}};let Ji=Yn;Ji.debounceFilterUpdate=250;Ji.defaultProps={options:{filterItems:null,filterOperators:null,invertSelection:!0,selectedValues:[]},sortDirection:null};const Pr=le.module("Aggregations"),Qu=[be.SUM,be.ABS_SUM,be.MIN,be.MAX,be.VAR,be.AVG,be.STD,be.FIRST,be.LAST,be.COUNT_DISTINCT,be.DISTINCT,be.COUNT,be.UNIQUE];function ju({isRollup:e,settings:t,onChange:n,onEdit:s}){const{aggregations:o,showOnTop:i}=t,r=F.exports.useMemo(()=>Qu.filter(I=>!o.some(L=>L.operation===I)),[o]),[l,a]=F.exports.useState(r[0]),[c,d]=F.exports.useState([]),u=F.exports.useCallback(I=>{n({...t,...I})},[n,t]),h=F.exports.useCallback(I=>{u({aggregations:I})},[u]),g=F.exports.useCallback(I=>{u({showOnTop:I})},[u]),p=F.exports.useCallback(()=>{Pr.debug("handleDragStart"),dt.startDragging()},[]),f=F.exports.useCallback(({destination:I,source:L})=>{if(Pr.debug("handleDragEnd",I,L),dt.stopDragging(),I===null)return;let k=I.index;L.index<I.index&&(k+=1);const x=[...o],W=dt.reorder(x,c,x,k),V=dt.adjustDestinationIndex(k,c),Y=[[V,V+W.length-1]];h(x),d(Y)},[h,o,c,d]),C=F.exports.useCallback(I=>{a(I)},[a]),w=F.exports.useCallback(()=>{h([...o,{operation:l,selected:[],invert:!0}])},[o,l,h]),S=F.exports.useCallback(I=>{h(o.filter((L,k)=>k!==I))},[o,h]),b=F.exports.useCallback(I=>{d(I)},[d]),v=F.exports.useCallback(I=>{const L=o[I];On.isRollupOperation(L.operation)||s(L)},[o,s]),T=F.exports.useCallback(I=>{g(I.target.value==="true")},[g]);F.exports.useEffect(function(){r.length>0&&!r.includes(l)&&a(r[0])},[r,l]);const R=F.exports.useCallback(({item:I,itemIndex:L,isClone:k=!1,selectedCount:x})=>{const W=I.operation,V=k?`${x}`:void 0,Y=k?"item-list-item-clone":void 0,j=On.isRollupOperation(I.operation),ie=!k&&!j;return y(Oe,{children:[y("div",{className:Z("item-list-item-content","draggable-item-list-item-content",Y),children:[y("span",{className:"title",children:[W,!e&&j&&y("span",{className:"small text-warning",children:[m(J,{icon:al})," Requires rollup"]})]}),Dt.renderBadge({text:V}),Dt.renderHandle()]}),!k&&y(Oe,{children:[m(z,{kind:"ghost",className:"btn-edit",icon:Pi,tooltip:"Edit Columns",onClick:()=>s(I),disabled:!ie}),m(z,{kind:"ghost",className:"btn-delete",icon:un,tooltip:"Delete Aggregation",onClick:()=>S(L)})]})]})},[S,s,e]),D=r.length>0,A=o.length>0;return y("div",{className:"aggregations",children:[D&&y("div",{className:"form-inline",children:[m(ed,{onChange:C,value:l,children:r.map(I=>m(Jc,{value:I,children:I},I))}),y("button",{type:"button",className:"btn btn-link btn-add",onClick:w,children:[m(J,{icon:vs}),"Add Aggregation"]})]}),D&&A&&m("hr",{}),A&&y(Oe,{children:[!e&&y("div",{className:"form-inline",children:[m("label",{children:"Placement:\xA0"}),y(zi,{onChange:T,value:`${i}`,children:[m(Zn,{value:"true",children:"Top"}),m(Zn,{value:"false",children:"Bottom"})]})]}),m(zo,{onDragStart:p,onDragEnd:f,children:m(Dt,{className:"selected-aggregations",itemCount:o.length,items:o,renderItem:R,offset:0,onSelectionChange:b,onSelect:v,selectedRanges:c,isMultiSelect:!0})})]})]})}const Zu=30;function Ju({aggregation:e,columns:t,onChange:n}){const[s,o]=F.exports.useState(-1),[i,r]=F.exports.useState(-1),[l,a]=F.exports.useState(0),{invert:c,selected:d}=e,u=F.exports.useRef(null),h=F.exports.useCallback(T=>d.includes(T)?!c:c,[c,d]),g=F.exports.useMemo(()=>{let T=Qi(t,e.operation);return l!==0&&(T=N.sortColumns(T,l===1)),T},[t,e.operation,l]),p=F.exports.useMemo(()=>s>=0?g.slice(s,i+1).map(T=>({value:T.name,displayValue:T.name,isSelected:h(T.name)})):[],[g,h,i,s]),f=F.exports.useCallback(T=>{const{name:R}=g[T],D=d.indexOf(R);let A=[...d],I=c;D>=0?A.splice(D,1):(A.push(R),A.length===g.length&&(A=[],I=!c)),n({...e,selected:A,invert:I})},[e,c,g,d,n]),C=F.exports.useCallback(()=>{a(0),n({...e,selected:[],invert:!0})},[e,n]),w=F.exports.useCallback((T,R)=>{o(T),r(R)},[o,r]),S=F.exports.useCallback(()=>{d.length===0?n({...e,invert:!c}):n({...e,selected:[],invert:!0})},[e,c,n,d]),b=d.length===0?c:null,v=d.length!==0||!c||l!==0;return y("div",{role:"menu",className:"aggregation-edit",children:[m("div",{className:"top-menu",children:y("div",{className:"form-inline",children:[m(an,{checked:b,onChange:S,children:"Toggle All"}),m("div",{className:"spacer"}),m($t,{in:v,timeout:We.transitionSlowMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:m(z,{kind:"ghost",className:"btn-reset",onClick:C,children:"Reset"})}),m(z,{kind:"ghost",className:Z({active:l===1}),icon:_i,tooltip:"Sort ascending",onClick:()=>a(1)}),m(z,{kind:"ghost",className:Z({active:l===2}),icon:Hi,tooltip:"Sort descending",onClick:()=>a(2)})]})}),m("div",{className:"aggregation-edit-item-list",children:m(ko,{itemCount:g.length,items:p,offset:s,renderItem:({item:T})=>m(an,{checked:h(T.value),children:T.displayValue}),onSelect:f,onViewportChange:w,rowHeight:Zu,focusSelector:"input",ref:u})})]})}function eh(e){return m("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...e,children:y("g",{fill:"none",fillRule:"evenodd",children:[m("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),m("path",{fill:"#7DA4FF",d:"M8 26h4v15H8zM15 17h4v24h-4zM22 21h4v20h-4zM29 17h4v24h-4zM36 11h4v30h-4z"})]})})}function th(e){return m("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...e,children:y("g",{fill:"none",fillRule:"evenodd",children:[m("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),m("path",{fill:"#7DA4FF",d:"M7 34h4v8H7zM12 31h4v11h-4zM17 27h4v15h-4zM22 22h4v20h-4zM27 27h4v15h-4zM32 29h4v13h-4zM37 31h4v11h-4z"})]})})}function nh(e){return m("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...e,children:y("g",{fill:"none",fillRule:"evenodd",children:[m("path",{fill:"#C1C0C0",d:"M4 4h1v40H4zM44 43v1H5v-1z"}),m("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"}),m("path",{stroke:"#BECDEF",d:"M8.244 37.926L17 33.496l5 .87 10.637-10.35 10.615-1.381"})]})})}function sh(e){return m("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...e,children:y("g",{fill:"none",fillRule:"evenodd",children:[m("path",{d:"M24 10c7.732 0 14 6.268 14 14s-6.268 14-14 14-14-6.268-14-14h14V10z",fill:"#80A6FF"}),m("path",{d:"M10 24c0-7.732 6.268-14 14-14v14H10z",fill:"#C1C0C0"})]})})}function oh(e){return m("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...e,children:y("g",{fill:"none",fillRule:"evenodd",children:[m("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),m("path",{fill:"#939293",d:"M44 34v1H4v-1zM44 25v1H4v-1zM44 16v1H4v-1z"}),m("circle",{fill:"#7DA4FF",cx:9.5,cy:37.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:16.5,cy:30.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:22.5,cy:36.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:28.5,cy:30.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:15.5,cy:38.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:23.5,cy:25.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:19.5,cy:19.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:29.5,cy:19.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:32.5,cy:26.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:36.5,cy:13.5,r:1.5})]})})}function ih(e){return y("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[m("rect",{width:"48",height:"48",fill:"none"}),m("rect",{x:"26",y:"10",width:"15",height:"4",fill:"#9FDE70"}),m("rect",{x:"26",y:"22",width:"15",height:"4",fill:"#9FDE70"}),m("rect",{x:"26",y:"28",width:"15",height:"4",fill:"#FFD95C"}),m("rect",{x:"26",y:"34",width:"15",height:"4",fill:"#9FDE70"})]})}function rh(e){return y("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[m("rect",{width:"48",height:"48",fill:"none"}),m("rect",{x:"4",y:"16",width:"40",height:"4",fill:"#FFD95C"}),m("rect",{x:"4",y:"10",width:"40",height:"4",fill:"#78DCE8"}),m("rect",{x:"4",y:"34",width:"40",height:"4",fill:"#78DCE8"})]})}const _r=le.module("ChartBuilder"),Xe=class extends F.exports.PureComponent{static getTypeName(e){switch(e){case E.plot.SeriesPlotStyle.LINE:return"Line";case E.plot.SeriesPlotStyle.BAR:return"Bar";case E.plot.SeriesPlotStyle.SCATTER:return"Scatter";case E.plot.SeriesPlotStyle.PIE:return"Pie";case E.plot.SeriesPlotStyle.HISTOGRAM:return"Histogram";default:return e}}static getTypeIcon(e){switch(e){case E.plot.SeriesPlotStyle.LINE:return m(nh,{});case E.plot.SeriesPlotStyle.BAR:return m(eh,{});case E.plot.SeriesPlotStyle.SCATTER:return m(oh,{});case E.plot.SeriesPlotStyle.PIE:return m(sh,{});case E.plot.SeriesPlotStyle.HISTOGRAM:return m(th,{});default:return null}}static getMaxSeriesCount(e){switch(e){case E.plot.SeriesPlotStyle.PIE:return 1;case E.plot.SeriesPlotStyle.HISTOGRAM:return 0;default:return 100}}static getXAxisLabel(e){switch(e){case E.plot.SeriesPlotStyle.PIE:return"Labels";case E.plot.SeriesPlotStyle.HISTOGRAM:return"Data";default:return"X-Axis"}}static getSeriesLabel(e){switch(e){case E.plot.SeriesPlotStyle.PIE:return"Values";default:return"Series"}}static makeSeriesItem(e){return{id:Ln.generate(),value:e}}static makeDefaultSeriesItems(e,t){if(Xe.getMaxSeriesCount(e)===0||t==null||t.length===0)return[];const s=t.length>1?t[1].name:t[0].name;return[Xe.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=Xe.types[0],o=Xe.getDefaultXAxis(s,n),i=Xe.makeDefaultSeriesItems(s,n);this.state={type:s,seriesItems:i,xAxis:o,isLinked:!0}}handleAddSeries(){this.setState(e=>{const{seriesItems:t}=e,n=[...t],{model:s}=this.props,{columns:o}=s;return n.push({id:Ln.generate(),value:o[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=Xe.types[0],s=Xe.getDefaultXAxis(n,t),o=Xe.makeDefaultSeriesItems(n,t),i=!0;this.setState({type:n,seriesItems:o,xAxis:s,isLinked:i},this.sendChange)}handleSeriesChange(e){const{value:t}=e.target,n=e.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(o=>{let{seriesItems:i}=o;return i=[...i],i[s].value=t,{seriesItems:i}},this.sendChange)}handleSeriesDeleteClick(e){const n=e.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(o=>{const{seriesItems:i}=o,r=[...i];return r.splice(s,1),{seriesItems:r}},this.sendChange)}handleSubmit(e){e.preventDefault();const{onSubmit:t}=this.props,{type:n,seriesItems:s,xAxis:o,isLinked:i}=this.state,r=s.map(l=>l.value);t({type:`${n}`,series:r,xAxis:o,isLinked:i})}handleTypeClick(e){const n=e.target.getAttribute("data-index"),s=parseInt(n,10),o=Xe.types[s];_r.debug2("handleTypeSelect",o),this.setState(i=>{const r=Xe.getMaxSeriesCount(o);let{seriesItems:l}=i;if(l=l.slice(0,r),l.length===0&&r>0){const{model:a}=this.props,{columns:c}=a;l=Xe.makeDefaultSeriesItems(o,c)}return{type:o,seriesItems:l}},this.sendChange)}handleXAxisChange(e){const t=e.target.value;_r.debug2("x-axis change",t),this.setState({xAxis:t},this.sendChange)}sendChange(){const{onChange:e}=this.props,{isLinked:t,type:n,seriesItems:s,xAxis:o}=this.state,i=s.map(r=>r.value);e({type:n,series:i,xAxis:o,isLinked:t})}render(){const{model:e}=this.props,{columns:t}=e,{seriesItems:n,type:s,xAxis:o,isLinked:i}=this.state,r=Xe.getMaxSeriesCount(s),l=Xe.getXAxisLabel(s),a=Xe.getSeriesLabel(s),c=n.length>0,d=n.length<r;return m("div",{className:"chart-builder",children:y("form",{onSubmit:this.handleSubmit,children:[y("div",{className:"form-row",children:[m("label",{children:"Select Chart Type"}),m("div",{className:"form-row",children:Xe.types.map((u,h)=>{const g=u;return m("div",{className:"col col-chart-type",children:y("button",{type:"button",className:Z("btn","btn-icon","btn-chart-type",{active:u===s}),"data-index":h,onClick:this.handleTypeClick,children:[Xe.getTypeIcon(u),Xe.getTypeName(u)]})},g)})})]}),m("hr",{}),y("div",{className:"form-row form-inline",children:[m("label",{className:"col-2 label-left",children:l}),m("select",{className:"form-control custom-select select-x-axis col",value:o,onChange:this.handleXAxisChange,children:t.map(u=>m("option",{value:u.name,children:u.name},u.name))})]}),c&&m("hr",{}),n.map((u,h)=>y("div",{className:"form-row form-inline form-series-item","data-testid":`form-series-item-${h}`,children:[m("label",{className:"col-2 label-left",children:h===0?a:""}),m("select",{className:"form-control custom-select select-series col",value:u.value,onChange:this.handleSeriesChange,"data-testid":`select-series-item-${h}`,"data-index":h,children:t.map(g=>m("option",{value:g.name,"data-index":h,children:g.name},g.name))}),n.length>1&&m(z,{kind:"ghost",className:"btn-delete-series ml-2 px-2","data-index":h,"data-testid":`delete-series-${h}`,onClick:this.handleSeriesDeleteClick,icon:un,tooltip:"Delete"})]},u.id)),d&&y("div",{className:"form-row",children:[m("div",{className:"col-2"}),m(z,{kind:"ghost",className:"btn-add-series mt-1",onClick:this.handleAddSeries,icon:vs,children:"Add Series"})]}),y("div",{className:"form-row chart-builder-link",children:[m("label",{className:"col-2 label-right",children:y("div",{className:"fa-md fa-layers",children:[m(J,{mask:Vi,icon:Yo,transform:"right-5 down-5"}),m(J,{icon:i?Xa:Ka,transform:"grow-2 right-8 down-6"})]})}),y(zi,{onChange:this.handleLinkStateChange,value:`${i}`,children:[m(Zn,{value:"true",children:"Sync State"}),m(Zn,{value:"false",children:"Freeze State"})]})]}),y("div",{className:"form-row",children:[m("div",{className:"col-2 label-right"}),m("div",{className:"col chart-builder-link-info",children:i?"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."})]}),y("div",{className:Z("form-row","justify-content-end","my-3"),children:[m(z,{kind:"secondary",className:"btn-reset",onClick:this.handleReset,children:"Reset"}),m(z,{kind:"primary",type:"submit",className:"btn-submit",children:"Create"})]})]})})}};let Ll=Xe;Ll.types=[E.plot.SeriesPlotStyle.LINE,E.plot.SeriesPlotStyle.BAR,E.plot.SeriesPlotStyle.SCATTER,E.plot.SeriesPlotStyle.PIE];class Pl extends F.exports.Component{constructor(t){super(t),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()}initEditor(){var o;const{value:t,editorSettings:n}=this.props,s={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:t,wordWrap:"on",automaticLayout:!0,...n};if(!this.editorContainer)throw new Error("editorContainer is null");this.editor=cn.create(this.editorContainer,s),this.editor.layout(),(o=this.editor.getModel())==null||o.updateOptions({tabSize:0}),this.editor.onKeyDown(this.handleKeyDown),this.editor.onDidChangeModelContent(this.handleContentChanged),this.editor.onDidFocusEditorText(this.handleEditorFocus),this.editor.onDidBlurEditorText(this.handleEditorBlur)}destroyEditor(){var t;(t=this.editor)==null||t.dispose(),this.editor=void 0}handleContentChanged(){var s,o;const{onContentChanged:t}=this.props,n=(o=(s=this.editor)==null?void 0:s.getModel())==null?void 0:o.getValue();n!==void 0&&this.setState({isEditorEmpty:n.length===0}),t(n)}handleEditorFocus(){this.setState({isEditorFocused:!0})}handleEditorBlur(){var n,s,o;const t=(o=(s=(n=this.editor)==null?void 0:n.getModel())==null?void 0:s.getValue())!=null?o:"";this.setState({isEditorEmpty:t.length===0,isEditorFocused:!1})}handleContainerClick(){var n;const{isEditorFocused:t}=this.state;t||(n=this.editor)==null||n.focus()}handleKeyDown(t){const{onTab:n,editorIndex:s}=this.props;t.code==="Tab"&&(t.stopPropagation(),t.preventDefault(),n(s,t.shiftKey))}render(){const{value:t,invalid:n}=this.props,{isEditorFocused:s,isEditorEmpty:o}=this.state;return y("div",{className:Z("input-editor-wrapper",{focused:s,invalid:n}),role:"presentation",onClick:this.handleContainerClick,children:[m("div",{className:"editor-container",ref:i=>{this.editorContainer=i}}),o&&!t&&m("div",{className:"editor-placeholder text-muted",children:"Column Formula"})]})}}Pl.defaultProps={value:"",onContentChanged:()=>{},editorSettings:{},editorIndex:0,onTab:()=>{},invalid:!1};const Hr=Object.freeze({NAME:"name",FORMULA:"formula"}),lh=()=>{};function ah({eventKey:e,name:t,inputIndex:n,formula:s,onChange:o,onDeleteColumn:i,onTabInEditor:r,invalid:l,isDuplicate:a}){const c=t===""||Ks.isValidColumnName(t),d=F.exports.useCallback(u=>{u!==void 0&&(u.replace(/(\r\n|\n|\r)/gm,""),o(e,Hr.FORMULA,u))},[o,e]);return m(sl,{draggableId:e,index:n,disableInteractiveElementBlocking:!0,children:(u,h)=>y("div",{className:Z("draggable-container",{dragging:h.isDragging}),ref:u.innerRef,...u.draggableProps,children:[y("div",{className:"custom-column-input-container",children:[y("div",{className:"pb-3",children:[y("div",{className:"d-flex flex-row custom-column-name",children:[m("input",{className:Z("form-control custom-column-input",{"is-invalid":l||!c||a}),placeholder:"Column Name",value:t,onChange:g=>{o(e,Hr.NAME,g.target.value)}}),m(z,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{i(e)},icon:un,tooltip:"Delete custom column"}),m(z,{kind:"ghost",className:"btn-drag-handle",onClick:lh,...u.dragHandleProps,icon:Ui,tooltip:"Drag column to re-order"})]}),(!c||a)&&m("p",{className:"validate-label-error text-danger mb-0 mt-2 pl-1",children:c?"Duplicate name":"Invalid name"})]}),m(Pl,{editorSettings:{language:"deephavenDb"},editorIndex:n,value:s,onContentChanged:d,onTab:r,invalid:l})]}),m("hr",{})]})})}const Ci=[];class ue extends Tl{constructor(){super(),this.listenerCount=0}addEventListener(t,n,s){super.addEventListener(t,n,s),this.listenerCount+=1,this.listenerCount===1&&this.startListening()}removeEventListener(t,n,s){super.removeEventListener(t,n,s),this.listenerCount-=1,this.listenerCount===0&&this.stopListening()}startListening(){}stopListening(){}get originalColumns(){return this.columns}get layoutHints(){return null}get frontColumns(){return Ci}get backColumns(){return Ci}get frozenColumns(){return Ci}isColumnFrozen(t){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(t){return!1}close(){}isRowMovable(){return!1}get isSeekRowAvailable(){return!1}}ue.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"});const fs=class extends F.exports.Component{constructor(e){super(e),this.getInput=Fe((t,n)=>t.find(s=>s.eventKey===n)),this.getInputIndex=Fe((t,n)=>t.findIndex(s=>s.eventKey===n)),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}static makeCustomColumnInputEventKey(){return Ln.generate()}static createCustomColumnInput(){return{eventKey:Ln.generate(),name:"",formula:""}}componentDidMount(){const{customColumns:e}=this.props;this.parseCustomColumns(e),this.startListening()}componentWillUnmount(){this.stopListening(),this.successButtonTimer&&clearTimeout(this.successButtonTimer)}resetErrorMessage(){this.setState({errorMessage:null})}startListening(){const{model:e}=this.props;e.addEventListener(ue.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),e.addEventListener(ue.EVENT.UPDATED,this.handleCustomColumnUpdated),e.addEventListener(ue.EVENT.REQUEST_FAILED,this.handleRequestFailed)}stopListening(){const{model:e}=this.props;e.removeEventListener(ue.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),e.removeEventListener(ue.EVENT.UPDATED,this.handleCustomColumnUpdated),e.removeEventListener(ue.EVENT.REQUEST_FAILED,this.handleRequestFailed)}parseCustomColumns(e){if(e.length>0){const t=e.map(n=>{const s=n.split(/=(.+)/,2);return{eventKey:fs.makeCustomColumnInputEventKey(),name:s[0],formula:s[1]}});this.setState({inputs:t})}else this.setState({inputs:[fs.createCustomColumnInput()]})}handleAddColumnClick(){const{inputs:e}=this.state,t=[...e];t.push(fs.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(fs.createCustomColumnInput()),this.setState({inputs:s})}handleInputChange(e,t,n){const{inputs:s}=this.state,o=this.getInputIndex(s,e),r={...this.getInput(s,e)};r[t]=n;const l=[...s];l.splice(o,1,r),this.setState({inputs:l})}handleCustomColumnUpdated(){const{isCustomColumnApplying:e}=this.state;!e||this.setState({isCustomColumnApplying:!1,isSuccessShowing:!0},()=>{this.successButtonTimer=setTimeout(()=>this.setState({isSuccessShowing:!1}),fs.SUCCESS_SHOW_DURATION)})}handleRequestFailed(e){const t=e,{isCustomColumnApplying:n}=this.state;!n||this.setState({isCustomColumnApplying:!1,errorMessage:y(Oe,{children:[y("p",{children:[m(J,{icon:Qn})," Failed to apply custom columns."]}),y("div",{className:"error-box",children:[t.detail.errorMessage,m("br",{}),"Table configuration:"," ",JSON.stringify(t.detail.configuration)]})]}),hasRequestFailed:!0})}handleDragEnd(e){if(dt.stopDragging(),!e.destination)return;const{inputs:t}=this.state,n=e.source.index,s=e.destination.index,o=[...t],i=t[n];o.splice(n,1),o.splice(s,0,i),this.setState({inputs:o})}handleEditorTabNavigation(e,t){var s,o,i,r;const{inputs:n}=this.state;if(t){((s=this.container)==null?void 0:s.querySelectorAll(".btn-drag-handle")[e]).focus();return}if(e===n.length-1)(i=(o=this.container)==null?void 0:o.querySelector(".btn-add-column"))==null||i.focus();else{const l=e+1;((r=this.container)==null?void 0:r.querySelectorAll(".custom-column-input")[l]).focus()}}handleSaveClick(){const{onSave:e,customColumns:t}=this.props,{inputs:n,isCustomColumnApplying:s}=this.state;if(s)return;const o=[];n.forEach(i=>{const{name:r,formula:l}=i;r&&l&&o.push(`${r}=${l}`)}),this.resetErrorMessage(),this.setState({isCustomColumnApplying:o.length>0||t.length>0}),e(o)}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})=>{var o;return n.set(s,((o=n.get(s))!=null?o:0)+1)}),e.map((s,o)=>{var c;const{eventKey:i,name:r,formula:l}=s,a=((c=n.get(r))!=null?c:0)>1;return m(ah,{inputIndex:o,eventKey:i,name:r,formula:l,onChange:this.handleInputChange,onDeleteColumn:this.handleDeleteColumn,onTabInEditor:this.handleEditorTabNavigation,invalid:t,isDuplicate:a},i)})}renderSaveButton(){const{inputs:e,isCustomColumnApplying:t,isSuccessShowing:n}=this.state,s=e.length>1?"Save Columns":"Save Column",o=e.every(({name:l})=>l===""||Ks.isValidColumnName(l)),i=e.filter(({name:l})=>l!=="").map(({name:l})=>l),r=new Set(i).size===i.length;return y(z,{kind:n?"success":"primary",className:Z("btn-apply",{"btn-spinner":t}),disabled:n||t||!o||!r,onClick:this.handleSaveClick,children:[t&&y("span",{children:[m(dn,{}),m("span",{className:"btn-normal-content",children:"Applying"})]}),!n&&!t&&s,n&&y(Oe,{children:[m(J,{icon:rl})," Success"]})]})}render(){const{onCancel:e}=this.props,{errorMessage:t}=this.state;return y("div",{role:"presentation",className:"custom-column-builder-container",ref:n=>{this.container=n},onClick:this.resetRequestFailed,onFocus:this.resetRequestFailed,children:[m("hr",{}),m(zo,{onDragStart:dt.startDragging,onDragEnd:this.handleDragEnd,children:m(Oi,{droppableId:"droppable-custom-columns",children:(n,s)=>y("div",{ref:n.innerRef,...n.droppableProps,className:Z("droppable-container",{dragging:s.draggingFromThisWith}),children:[this.renderInputs(),n.placeholder]})})}),m("div",{className:"pt-1 px-3",children:m(z,{kind:"ghost",className:"btn-add-column",onClick:this.handleAddColumnClick,icon:vs,children:"Add Another Column"})}),y("div",{className:"custom-column-builder-footer",children:[t&&m("div",{className:"error-message",children:t}),y("div",{className:"d-flex justify-content-end",children:[m(z,{kind:"secondary",className:"mr-2",onClick:e,children:"Cancel"}),this.renderSaveButton()]})]})]})}};let _l=fs;_l.SUCCESS_SHOW_DURATION=750;var Se=(e=>(e.ADVANCED_SETTINGS="ADVANCED_SETTINGS",e.AGGREGATIONS="AGGREGATIONS",e.AGGREGATION_EDIT="AGGREGATIONS_EDIT",e.CHART_BUILDER="CHART_BUILDER",e.CUSTOM_COLUMN_BUILDER="CUSTOM_COLUMN_BUILDER",e.QUICK_FILTERS="QUICK_FILTERS",e.ROLLUP_ROWS="ROLLUP_ROWS",e.SEARCH_BAR="SEARCH_BAR",e.SELECT_DISTINCT="SELECT_DISTINCT",e.TABLE_EXPORTER="TABLE_EXPORTER",e.VISIBILITY_ORDERING_BUILDER="VISIBILITY_ORDERING_BUILDER",e.CONDITIONAL_FORMATTING="CONDITIONAL_FORMATTING",e.CONDITIONAL_FORMATTING_EDIT="CONDITIONAL_FORMATTING_EDIT",e.GOTO="GOTO",e))(Se||{});const _s=le.module("RollupRows"),ch=150,Do="grouped-rollup-rows",Io="ungrouped-rollup-rows",yt=class extends F.exports.Component{constructor(e){super(e),this.search=vt(i=>{const r=this.getSortedUngroupedColumns(),l=[];let a=null;for(let c=0;c<r.length;c+=1)r[c].name.toLowerCase().includes(i.toLowerCase())&&(a==null&&(a=c),l.push([c,c]));M(a),this.setState({ungroupedSelectedRanges:l}),l.length>0&&this.ungroupedList.current&&this.ungroupedList.current.scrollToItem(a)},ch),this.getCachedUngroupedColumns=Te((i,r)=>i.filter(l=>yt.isGroupable(l)&&r.find(a=>a===l.name)==null)),this.getCachedSortedColumns=Te((i,r)=>r==null?[...i]:N.sortColumns(i,r===yt.SORT.ASCENDING)),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=De.createRef(),this.groupedList=De.createRef();const{config:t}=e,{columns:n=[],showConstituents:s=!0,showNonAggregatedColumns:o=!0}=t!=null?t:{};this.state={ungroupedSelectedRanges:[],columns:n,groupedSelectedRanges:[],searchFilter:"",showConstituents:s,showNonAggregatedColumns:o,dragSource:null,sort:null}}static renderColumn({item:e,isClone:t,selectedCount:n}){const s=e==null?void 0:e.name,o=t!==void 0&&t?`${n}`:void 0,i=t!==void 0&&t?"item-list-item-clone":"";return Dt.renderTextItem({text:s,badgeText:o,className:i})}static addGroupings(e,t,n=e.length){if(t==null||t.length===0)return e;let s=n;const o=e.filter((i,r)=>t.includes(i)?(r<s&&(s-=1),!1):!0);return o.splice(s,0,...t),o}static isGroupable(e){return!N.isDecimalType(e.type)}componentDidUpdate(e,t){const{config:n}=this.props,{columns:s,showConstituents:o,showNonAggregatedColumns:i}=this.state;n!==e.config?this.updateFromConfig():(s!==t.columns||o!==t.showConstituents||i!==t.showNonAggregatedColumns)&&(n==null||s!==n.columns||o!==n.showConstituents||i!==n.showNonAggregatedColumns)&&this.sendChange()}componentWillUnmount(){this.search.cancel()}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===yt.SORT.ASCENDING?null:yt.SORT.ASCENDING}))}handleSortDescending(){this.setState(({sort:e})=>({sort:e===yt.SORT.DESCENDING?null:yt.SORT.DESCENDING}))}resetSelection(){this.setState({ungroupedSelectedRanges:[],groupedSelectedRanges:[]})}handleDragStart(e){_s.debug("handleDragStart",e),document.documentElement.classList.add("drag-pointer-events-none"),this.setState({dragSource:e.source})}handleDragEnd(e){_s.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===Io){this.setState(({groupedSelectedRanges:i,columns:r})=>{const l=[...r];return dt.reorder(l,i,[],0),{columns:l,ungroupedSelectedRanges:[],groupedSelectedRanges:[]}});return}const s=n.droppableId===Do;let o=t.index;s&&n.index<t.index&&(o+=1),this.setState(({columns:i,ungroupedSelectedRanges:r,groupedSelectedRanges:l})=>{const a=[...i],c=s?a:this.getSortedUngroupedColumns().map(p=>p.name),d=s?l:r,u=dt.reorder(c,d,a,o),h=s?dt.adjustDestinationIndex(o,l):o,g=[[h,h+u.length-1]];return{columns:a,ungroupedSelectedRanges:[],groupedSelectedRanges:g}}),this.resetSelection()}handleUngroupedSelect(e){_s.debug("handleUngroupedSelect"),this.setState(({columns:t})=>({columns:yt.addGroupings(t,[this.getSortedUngroupedColumns()[e].name]),ungroupedSelectedRanges:[],groupedSelectedRanges:[]}))}handleUngroupedSelectionChange(e){_s.debug2("handleUngroupedSelectionChange",e),this.setState(({ungroupedSelectedRanges:t})=>e===t?null:{ungroupedSelectedRanges:e,groupedSelectedRanges:[]})}handleGroupedSelectionChange(e){_s.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!=null?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})}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 i=`${n!==void 0&&n?"":"\xA0\xA0".repeat(t)}${e}`,r=n!==void 0&&n?`${s}`:void 0,l=n!==void 0&&n?"item-list-item-clone":"";return y(Oe,{children:[Dt.renderTextItem({text:i,badgeText:r,className:l}),(n===void 0||!n)&&m(z,{kind:"ghost",className:"btn btn-link btn-link-icon btn-delete-grouping float-right",onClick:()=>this.handleDeleteClicked(t),children:m(J,{icon:un})})]})}render(){const{columns:e,dragSource:t,searchFilter:n,groupedSelectedRanges:s,ungroupedSelectedRanges:o,showConstituents:i,showNonAggregatedColumns:r,sort:l}=this.state,a=this.getSortedUngroupedColumns();let c=e.length*Dt.DEFAULT_ROW_HEIGHT;(t==null?void 0:t.droppableId)===Io&&(c+=Dt.DEFAULT_ROW_HEIGHT);const d=a.length*Dt.DEFAULT_ROW_HEIGHT+10,u=Math.min(3*Dt.DEFAULT_ROW_HEIGHT,d);return m("div",{role:"menu",className:Z("rollup-rows",{"is-dragging":t!=null}),tabIndex:0,children:y(zo,{onDragEnd:this.handleDragEnd,onDragStart:this.handleDragStart,children:[y("div",{className:"rollup-rows-group-by",children:[m("div",{className:"section-title",children:"Group By"}),e.length===0&&m(Oi,{droppableId:"placeholder",children:(h,g)=>m("div",{className:Z("placeholder","text-muted",{"is-dragging-from-this":g.draggingFromThisWith,"is-dragging-over":g.isDraggingOver,"is-dropping":g.draggingOverWith}),ref:h.innerRef,...h.droppableProps,children:"To create a rollup, drag columns from the list below and drop them into this area."})}),e.length>0&&m(Dt,{draggingItemClassName:"rollup-rows-dragging-grouped-item",draggablePrefix:Do,droppableId:Do,itemCount:e.length,items:e,offset:0,onSelectionChange:this.handleGroupedSelectionChange,ref:this.groupedList,renderItem:this.renderGroupedItem,selectedRanges:s,style:{height:c},isMultiSelect:!0})]}),y("div",{className:"rollup-rows-available-columns",children:[m("div",{className:"section-title",children:"Available Grouping Columns"}),y("div",{className:"top-menu",children:[m(Qs,{className:"w-100",value:n,matchCount:n?o.length:void 0,placeholder:"Find column...",onChange:this.handleSearchChange}),y(z,{kind:"ghost",className:Z("btn-link btn-link-icon",{active:l===yt.SORT.ASCENDING}),onClick:this.handleSortAscending,children:[m(J,{icon:_i}),m(Rt,{children:"Sort ascending"})]}),y(z,{kind:"ghost",className:Z("btn-link btn-link-icon",{active:l===yt.SORT.DESCENDING}),onClick:this.handleSortDescending,children:[m(J,{icon:Hi}),m(Rt,{children:"Sort descending"})]})]}),m(Dt,{className:"rollup-available-grouping-columns",draggablePrefix:Io,droppableId:Io,itemCount:a.length,items:a,renderItem:yt.renderColumn,offset:0,onSelect:this.handleUngroupedSelect,onSelectionChange:this.handleUngroupedSelectionChange,ref:this.ungroupedList,selectedRanges:o,style:{maxHeight:d,minHeight:u},isDropDisabled:(t==null?void 0:t.droppableId)!==Do,isMultiSelect:!0}),y("div",{className:"bottom-menu",children:[m("div",{className:"label",children:"Show:"}),m(an,{checked:i,onChange:this.handleShowConstituentsChange,children:"Constituents"}),m(an,{checked:r,onChange:this.handleShowNonAggregatedColumnsChange,children:"Non-Aggregated Columns"})]})]})]})})}};let er=yt;er.SORT=Object.freeze({ASCENDING:"ASC",DESCENDING:"DESC"});er.defaultProps={config:null,onChange:()=>{}};const uh=le.module("TableCsvExporter"),Ne=class extends F.exports.Component{static getDateString(){return E.i18n.DateTimeFormat.format(Ne.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}-${Ne.getDateString()}.csv`,downloadRowOption:Ne.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,customizedDownloadRowOption:Ne.CUSTOMIZED_ROWS_OPTIONS.FIRST,customizedDownloadRows:Ne.DEFAULT_DOWNLOAD_ROWS,includeColumnHeaders:!0,includeHiddenColumns:!1,useUnformattedValues:!1,errorMessage:null,id:Ln.generate()}}getSnapshotRanges(){const{model:e,selectedRanges:t}=this.props,{downloadRowOption:n,customizedDownloadRowOption:s,customizedDownloadRows:o}=this.state,{rowCount:i,columnCount:r}=e;let l=[];switch(n){case Ne.DOWNLOAD_ROW_OPTIONS.ALL_ROWS:l.push(new K(0,0,r-1,i-1));break;case Ne.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS:l=t.map(a=>({...a,startColumn:0,endColumn:r-1})).sort((a,c)=>a.startRow!=null&&c.startRow!=null?a.startRow-c.startRow:0);break;case Ne.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS:switch(s){case Ne.CUSTOMIZED_ROWS_OPTIONS.FIRST:l.push(new K(0,0,r-1,Math.min(o-1,i-1)));break;case Ne.CUSTOMIZED_ROWS_OPTIONS.LAST:l.push(new K(0,Math.max(0,i-o),r-1,i-1));break}break}return l}getModelRanges(e){const{userColumnWidths:t,movedColumns:n}=this.props,{includeHiddenColumns:s}=this.state,o=Q.getHiddenColumns(t);let i=_.getModelRanges(e,n);if(!s&&o.length>0){const r=o.map(K.makeColumn);i=K.subtractRangesFromRanges(i,r)}return i}resetDownloadState(){this.setState({errorMessage:null})}async handleDownloadClick(){const{model:e,isDownloading:t,onDownloadStart:n,onDownload:s,onCancel:o}=this.props,{fileName:i,includeColumnHeaders:r,useUnformattedValues:l}=this.state;if(t){o();return}this.resetDownloadState();const a=this.getSnapshotRanges(),c=this.getModelRanges(a);if(this.validateOptionInput()){n();try{const d=await e.export(),u=d.setViewport(0,0);await u.getViewportData(),s(i,d,u,a,c,r,l)}catch(d){uh.error("CSV download failed",d),this.setState({errorMessage:y("p",{children:[m(J,{icon:Qn})," ",`${d}`]})}),o()}}}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===Ne.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS&&e.length===0?(this.setState({errorMessage:y("p",{children:[m(J,{icon:Qn})," No rows selected. Please select some rows in the table."]})}),!1):t===Ne.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS&&n<=0?(this.setState({errorMessage:y("p",{children:[m(J,{icon:Qn})," Number of rows to output must be greater than 0"]})}),!1):!0}render(){const{model:e,isDownloading:t,tableDownloadProgress:n,tableDownloadEstimatedTime:s,selectedRanges:o,tableDownloadStatus:i}=this.props,{fileName:r,downloadRowOption:l,customizedDownloadRowOption:a,customizedDownloadRows:c,includeColumnHeaders:d,includeHiddenColumns:u,useUnformattedValues:h,errorMessage:g,id:p}=this.state,{rowCount:f}=e;return y("div",{className:"table-csv-exporter",children:[m("div",{className:"section-title",children:"Download Rows"}),m("div",{className:"form-group",children:y(zi,{onChange:this.handleDownloadRowOptionChanged,value:l,disabled:t,children:[y(Zn,{value:Ne.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,"data-testid":"radio-csv-exporter-download-all",children:["All Rows",m("span",{className:"text-muted ml-2",children:`(${f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`})]}),y(Zn,{value:Ne.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS,"data-testid":"radio-csv-exporter-only-selected",children:["Only Selected Rows",m("span",{className:"text-muted ml-2",children:o.length>0?`(${K.rowCount(o).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`:null})]}),m(Zn,{value:Ne.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS,"data-testid":"radio-csv-exporter-customized-rows",children:y("div",{className:"radio-input-row",role:"presentation",onClick:()=>{this.setState({downloadRowOption:Ne.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS})},children:[y("select",{value:a,"data-testid":"select-csv-exporter-customized-rows",className:"custom-select",disabled:t,onChange:this.handleCustomizedDownloadRowOptionChanged,children:[m("option",{value:"FIRST",children:"First"}),m("option",{value:"LAST",children:"Last"})]}),m("input",{type:"number",className:"form-control",id:`customizedRows-${p}`,"data-testid":"input-csv-exporter-customized-rows",name:`customizedRows-${p}`,placeholder:"100",value:c,disabled:t,onChange:this.handleCustomizedDownloadRowsChanged}),m("div",{children:"Rows"})]})})]})}),y("div",{className:"form-group",children:[m("label",{htmlFor:`customizedRows-${p}`,children:"File Name"}),m("input",{type:"text",className:"form-control",id:`filename-${p}`,"data-testid":"input-csv-exporter-file-name",name:`filename-${p}`,value:r,onChange:C=>{this.setState({fileName:C.target.value})},disabled:t})]}),y("div",{className:"checkbox-options",children:[m(an,{checked:d,onChange:this.handleIncludeColumnHeadersChanged,children:"Include column headers"}),m(an,{checked:u,onChange:this.handleIncludeHiddenColumnsChanged,children:"Include hidden columns"}),m(an,{checked:h,onChange:this.handleUseUnformattedValuesChanged,children:"Use unformatted values"})]}),y("div",{className:"section-footer flex-column",children:[g!=null&&m("div",{className:"error-message",children:g}),i&&y("div",{className:"download-status",children:[(i===Ne.DOWNLOAD_STATUS.DOWNLOADING||i===Ne.DOWNLOAD_STATUS.INITIATING)&&y(Oe,{children:[i===Ne.DOWNLOAD_STATUS.INITIATING&&m("div",{className:"text-muted",children:"Starting Download..."}),i===Ne.DOWNLOAD_STATUS.DOWNLOADING&&y("div",{className:"text-muted d-flex justify-content-between",children:[m("span",{children:s||s===0?`Estimated time: ${Bi.formatElapsedTime(s)}`:null}),m("span",{children:`${n}%`})]})]}),i===Ne.DOWNLOAD_STATUS.FINISHED&&m("div",{className:"text-muted text-right",children:"Download Completed"}),i===Ne.DOWNLOAD_STATUS.CANCELED&&m("div",{className:"text-muted",children:"Download Canceled"}),(i===Ne.DOWNLOAD_STATUS.DOWNLOADING||i===Ne.DOWNLOAD_STATUS.INITIATING)&&m("div",{className:"progress",children:m("div",{className:"progress-bar progress-bar-striped progress-bar-animated",style:{width:`${n}%`}})}),i===Ne.DOWNLOAD_STATUS.FINISHED&&m("div",{className:"progress",children:m("div",{className:"progress-bar bg-success",style:{width:`${n}%`}})})]}),y(z,{kind:"primary","data-testid":"btn-csv-exporter-download",className:Z("btn-downloading",{"btn-spinner btn-cancelable":t}),onClick:this.handleDownloadClick,children:[t&&y("span",{children:[m(dn,{}),m("span",{className:"btn-normal-content",children:"Downloading"}),m("span",{className:"btn-hover-content",children:"Cancel"})]}),!t&&"Download"]})]})]})}};let gt=Ne;gt.FILENAME_DATE_FORMAT="yyyy-MM-dd-HHmmss";gt.DOWNLOAD_STATUS={INITIATING:"INITIATING",DOWNLOADING:"DOWNLOADING",FINISHED:"FINISHED",CANCELED:"CANCELED"};gt.DOWNLOAD_ROW_OPTIONS={ALL_ROWS:"ALL_ROWS",SELECTED_ROWS:"SELECTED_ROWS",CUSTOMIZED_ROWS:"CUSTOMIZED_ROWS"};gt.CUSTOMIZED_ROWS_OPTIONS={FIRST:"FIRST",LAST:"LAST"};gt.DEFAULT_DOWNLOAD_ROWS=100;gt.defaultProps={onDownloadStart:()=>{},isDownloading:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:null,selectedRanges:[]};const Jt=le.module("TableSaver"),hh="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function mh(e){return e.added!==void 0}function gh(e){if(!mh(e))throw new Error("event is not UpdateEventData")}const Dn=class extends F.exports.PureComponent{constructor(e){var t,n;super(e),this.WritableStream=(t=window.WritableStream)!=null?t:mr,this.getCachedCustomColumnFormatFlag=pt(Jn.isCustomColumnFormatDefined,{max:1e4}),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=(n=window.WritableStream)!=null?n:mr,this.iframes=[],this.useBlobFallback=!1}static csvEscapeString(e){return`"${e.replace(/"/g,'""')}"`}componentDidMount(){const{getDownloadWorker:e}=this.props;e().then(t=>{Jt.info("found active service worker"),this.sw=t,this.sw.postMessage("ping")}).catch(t=>{Jt.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)}createWriterStream(e){const t=this.useBlobFallback,n=[];let s=null;t&&(s=TextEncoder.prototype.encode.bind(new TextEncoder));const{fileName:o}=this,i={};return t?(i.write=r=>{M(s),r.header!==void 0&&n.push(s(r.header)),r.rows!==void 0&&n.push(s(r.rows))},i.close=()=>{M(o);const r=new Blob(n,{type:"application/octet-stream; charset=utf-8"}),l=document.createElement("a");l.href=URL.createObjectURL(r),l.download=o,l.click()},i.abort=()=>{e.postMessage({cancel:!0}),e.close()}):(i.write=r=>{e.postMessage(r)},i.close=()=>{e.postMessage({end:!0}),e.close()},i.abort=()=>{e.postMessage({cancel:!0}),e.close()}),new this.WritableStream(i)}startDownload(e,t,n,s,o,i,r){const{isDownloading:l}=this.props;if(l)return;this.downloadStartTime=Date.now(),Jt.info(`start downloading ${e}`),this.table=t,this.columns=Q.columnsFromRanges(o,t.columns),this.tableSubscription=n,this.gridRanges=s,this.includeColumnHeaders=i,this.useUnformattedValues=r;const a=encodeURIComponent(e.replace(/\//g,":")).replace(/['()]/g,escape).replace(/\*/g,"%2A"),c=new MessageChannel;if(this.port=c.port1,this.fileName=e,this.fileWriter=this.createWriterStream(this.port).getWriter(),this.useBlobFallback){this.writeCsvTable(i);return}this.sw&&this.sw.postMessage({encodedFileName:a},[c.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&&Jt.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(){Jt.info("download canceled"),this.cancelDownload()}writeTableHeader(){var t;let e="";if(this.columns)for(let n=0;n<this.columns.length;n+=1)e+=this.columns[n].name,e+=n===this.columns.length-1?`
3
+ `;S(x),p(!0),b(x)}else D(k.shiftKey?At.UP:At.DOWN);break;case"Tab":k.preventDefault(),D(k.shiftKey?At.LEFT:At.RIGHT);break;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":f&&(k.preventDefault(),D(wd(k.key)));break}},[T,D,f,S,p,b,w]),L=F.exports.useCallback(k=>{a(k)},[a]);return m("textarea",{ref:d,className:Z("grid-cell-input-field",t),value:w,onBlur:A,onChange:v,onKeyDown:I,onContextMenu:L,onClick:R,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",disabled:n,style:c})}Ki.propTypes={selectionRange:B.exports.arrayOf(B.exports.number),className:B.exports.string,disabled:B.exports.bool,isQuickEdit:B.exports.bool,value:B.exports.string,onChange:B.exports.func,onCancel:B.exports.func,onDone:B.exports.func,onContextMenu:B.exports.func,style:B.exports.shape({})};Ki.defaultProps={selectionRange:null,className:"",disabled:!1,value:"",isQuickEdit:!0,onChange:()=>{},onCancel:()=>{},onDone:()=>{},onContextMenu:()=>{},style:{}};const Sd=De.createContext({}),$n=class extends F.exports.PureComponent{constructor(e){super(e),this.getCachedKeyHandlers=Fe(l=>[...l,...this.keyHandlers].sort((a,c)=>a.order-c.order)),this.getCachedMouseHandlers=Fe(l=>[...l,...this.mouseHandlers].sort((a,c)=>a.order-c.order)),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:o,movedRows:i,renderer:r}=e;this.renderer=r||new ts,this.metricCalculator=s||new js,this.canvas=null,this.canvasContext=null,this.animationFrame=null,this.prevMetrics=null,this.metrics=null,this.documentCursor=null,this.dragTimer=null,this.keyHandlers=[new md(400),new Cd(450),new ud(500),new hd(900)],this.mouseHandlers=[new Yi(100),new Qo(200),new ad(300),new ld(400),new dd(450),new Xi(500),new qi(600),new cd(700),new bs(800),new id(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:o,movedRows:i,cursorRow:null,cursorColumn:null,selectionStartRow:null,selectionStartColumn:null,selectionEndRow:null,selectionEndColumn:null,selectedRanges:ye,lastSelectedRanges:ye,cursor:null,editingCell:null,isStuckToBottom:t,isStuckToRight:n}}static getScale(e){var o,i,r,l,a;const t=window.devicePixelRatio||1,n=e,s=(a=(l=(r=(i=(o=n.webkitBackingStorePixelRatio)!=null?o:n.mozBackingStorePixelRatio)!=null?i:n.msBackingStorePixelRatio)!=null?r:n.oBackingStorePixelRatio)!=null?l:n.backingStorePixelRatio)!=null?a:1;return t/s}static getCursorClassName(e){return e!=null&&e!==""?`grid-cursor-${e}`:null}componentDidMount(){var n;this.initContext(),(n=this.canvas)==null||n.addEventListener("wheel",this.handleWheel,{passive:!1}),window.addEventListener("resize",this.handleResize),this.updateCanvasScale(),this.updateCanvas();const{isStuckToBottom:e,isStuckToRight:t}=this.props;e&&this.scrollToBottom(),t&&this.scrollToRight()}componentDidUpdate(e,t){const{isStickyBottom:n,isStickyRight:s,movedColumns:o,movedRows:i,onMovedColumnsChanged:r,onMoveColumnComplete:l,onMovedRowsChanged:a,onMoveRowComplete:c}=this.props,{isStickyBottom:d,isStickyRight:u,movedColumns:h,movedRows:g}=e,{movedColumns:p,movedRows:f}=t,{draggingColumn:C,draggingRow:w,movedColumns:S,movedRows:b}=this.state;if(h!==o&&this.setState({movedColumns:o}),g!==i&&this.setState({movedRows:i}),p!==S&&r(S),t.draggingColumn!=null&&C==null&&l(S),f!==b&&a(b),t.draggingRow!=null&&w==null&&c(b),n!==d&&this.setState({isStuckToBottom:!1}),s!==u&&this.setState({isStuckToRight:!1}),this.updateMetrics(),this.requestUpdateCanvas(),!this.metrics||!this.prevMetrics)return;const{rowCount:v,columnCount:T,height:R,width:D}=this.metrics,{rowCount:A,columnCount:I,height:L,width:k}=this.prevMetrics;if(A!==v||R!==L){const{isStuckToBottom:x}=this.state;x&&this.scrollToBottom()}if(I!==T||D!==k){const{isStuckToRight:x}=this.state;x&&this.scrollToRight()}this.validateSelection()&&this.checkSelectionChange(t)}componentWillUnmount(){var e;this.animationFrame!=null&&cancelAnimationFrame(this.animationFrame),(e=this.canvas)==null||e.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 $n.getTheme(this.context,e)}getGridPointFromEvent(e){Rr(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 _.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 o=this.canvasContext,i=this.canvas.clientWidth,r=this.canvas.clientHeight,{left:l,top:a,leftOffset:c,topOffset:d,movedColumns:u,movedRows:h,isDraggingHorizontalScrollBar:g,isDraggingVerticalScrollBar:p,draggingColumn:f}=e;return{left:l,top:a,leftOffset:c,topOffset:d,width:i,height:r,context:o,theme:t,model:n,movedColumns:u,movedRows:h,isDraggingHorizontalScrollBar:g,isDraggingVerticalScrollBar:p,draggingColumn:f,...s}}getKeyHandlers(){const{keyHandlers:e}=this.props;return this.getCachedKeyHandlers(e)}getMouseHandlers(){const{mouseHandlers:e}=this.props;return this.getCachedMouseHandlers(e)}getModelColumn(e){var n,s;const t=(s=(n=this.metrics)==null?void 0:n.modelColumns)==null?void 0:s.get(e);if(t===void 0)throw new Error(`Unable to get ModelIndex for column ${e}`);return t}getModelRow(e){var n,s;const t=(s=(n=this.metrics)==null?void 0:n.modelRows)==null?void 0:s.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;Me(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:o,cursorColumn:i,selectedRanges:r}=this.state;if(this.setState({selectedRanges:e,lastSelectedRanges:r}),e.length>0){const l=K.boundedRange(e[0],n,s);let a=o,c=i;l.containsCell(i,o)||({row:a,column:c}=l.startCell()),this.setState({selectionStartColumn:l.startColumn,selectionStartRow:l.startRow,selectionEndColumn:l.endColumn,selectionEndRow:l.endRow,cursorColumn:c,cursorRow:a})}}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();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=$n.getScale(t),s=e.parentElement.getBoundingClientRect(),o=Math.floor(s.width),i=Math.floor(s.height);e.style.width=`${o}px`,e.style.height=`${i}px`,e.width=o*n,e.height=i*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 o=0;o<t.length;o+=1){const i=t[o];if(i.endColumn!=null&&i.endColumn>=n||i.endRow!=null&&i.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(o=>{var p,f,C,w;const{selectedRanges:i,selectionStartRow:r,selectionStartColumn:l}=o,{theme:a}=this.props,{autoSelectRow:c,autoSelectColumn:d}=a;if(n&&i.length>0){const S=i[i.length-1];let b=null,v=null,T=null,R=null;s?(b=c!==void 0&&c?null:Math.min(e!=null?e:0,(p=S.startColumn)!=null?p:0),v=d!==void 0&&d?null:Math.min(t!=null?t:0,(f=S.startRow)!=null?f:0),T=c!==void 0&&c?null:Math.max(e!=null?e:0,(C=S.endColumn)!=null?C:0),R=d!==void 0&&d?null:Math.max(t!=null?t:0,(w=S.endRow)!=null?w:0)):(b=S.startColumn,v=S.startRow,(l!=null||r!=null)&&((c===void 0||!c)&&(b=l),(d===void 0||!d)&&(v=r)),T=c!==void 0&&c?null:e,R=d!==void 0&&d?null:t);const D=K.makeNormalized(b,v,T,R);if(S.equals(D))return null;const A=[...i];return A[A.length-1]=D,{selectedRanges:A,selectionEndColumn:e,selectionEndRow:t}}const u=[...i],h=c!==void 0&&c?null:e,g=d!==void 0&&d?null:t;return u.push(K.makeNormalized(h,g,h,g)),{selectedRanges:u,selectionEndColumn:e,selectionEndRow:t}})}commitSelection(){this.setState(e=>{const{theme:t}=this.props,{autoSelectRow:n}=t,{selectedRanges:s,lastSelectedRanges:o,cursorRow:i,cursorColumn:r}=e;if(s.length===1&&(n!==void 0&&n?K.rowCount(s)===1:K.cellCount(s)===1)&&K.rangeArraysEqual(s,o))return{selectedRanges:[],lastSelectedRanges:[],cursorColumn:null,cursorRow:null};let l=s.slice();if(l.length>1){const d=l[l.length-1];for(let u=0;u<l.length-1;u+=1){const h=l[u];if(h.contains(d)){const g=h.subtract(d);l.pop(),l.splice(u,1),l=l.concat(g);break}}l=K.consolidate(l)}let a=r,c=i;if(!K.containsCell(l,r,i)){const{model:d}=this.props,{columnCount:u,rowCount:h}=d,g=K.nextCell(K.boundedRanges(s,u,h));g!=null?{column:a,row:c}=g:(a=null,c=null)}return l.length===0&&(a=null,c=null),{cursorRow:c,cursorColumn:a,selectedRanges:l,lastSelectedRanges:s}})}setFocusRow(e){var u;if(!this.metrics||!this.prevMetrics)return;const{gridY:t,height:n,lastTop:s,userRowHeights:o,rowHeight:i}=this.metrics,r=n-t,l=Math.round(r/2)+((u=o.get(e))!=null?u:i),a=this.getMetricState(),c=this.metricCalculator.getLastTop(a,e+1,l);this.setState({top:Math.min(s,c),selectedRanges:[new K(null,e,null,e)],isStuckToBottom:!1});const{cursorColumn:d}=this.state;this.moveCursorToPosition(d,e,!1,!1)}selectAll(){const{model:e,theme:t}=this.props,{autoSelectRow:n,autoSelectColumn:s}=t,o=s!==void 0&&s?null:0,i=s!==void 0&&s?null:e.rowCount-1,r=n!==void 0&&n?null:0,l=n!==void 0&&n?null:e.columnCount-1;this.setSelectedRanges([new K(r,o,l,i)])}moveCursor(e,t,n){const{cursorRow:s,cursorColumn:o,selectionEndColumn:i,selectionEndRow:r}=this.state,l=n?i:o,a=n?r:s;if(a===null||l===null){const{left:c,top:d}=this.state;this.moveCursorToPosition(c,d,n)}else{const{model:c}=this.props,{columnCount:d,rowCount:u}=c,h=$e(l+e,0,d-1),g=$e(a+t,0,u-1);this.moveCursorToPosition(h,g,n)}}moveCursorInDirection(e=K.SELECTION_DIRECTION.DOWN){var c;const{model:t}=this.props,{columnCount:n,rowCount:s}=t,{cursorRow:o,cursorColumn:i,selectedRanges:r}=this.state,l=r.length>0?r:[K.makeCell(i,o)];let a=null;if(l.length===1&&K.cellCount(l)===1){const d=new K(0,0,n-1,s-1);a=(c=d.nextCell(i,o,e))!=null?c:d.startCell(e)}else a=K.nextCell(K.boundedRanges(l,n,s),i,o,e);if(a!=null){const{column:d,row:u}=a;this.setState({cursorColumn:d,cursorRow:u}),K.containsCell(r,d,u)||this.setState({selectedRanges:[K.makeCell(d,u)],selectionStartColumn:d,selectionStartRow:u,selectionEndColumn:d,selectionEndRow:u}),this.moveViewToCell(a.column,a.row)}}moveCursorToPosition(e,t,n=!1,s=!0,o=!1){n||this.beginSelection(e,t),this.moveSelection(e,t,n,o),s&&this.moveViewToCell(e,t)}moveViewToCell(e,t){if(!this.metrics)throw new Error("metrics not set");const{metricCalculator:n}=this,{bottomVisible:s,rightVisible:o,topVisible:i,leftVisible:r}=this.metrics,l=this.getMetricState(this.state);let{top:a,left:c,topOffset:d,leftOffset:u}=this.state;t!=null&&!_.isFloatingRow(t,this.metrics)&&(t<i?(a=n.getTopForTopVisible(l,t),d=0):t>s&&(a=n.getTopForBottomVisible(l,t),d=0)),e!=null&&!_.isFloatingColumn(e,this.metrics)&&(e<r?(c=n.getLeftForLeftVisible(l,e),u=0):e>o&&(c=n.getLeftForRightVisible(l,e),u=0)),this.setViewState({top:a,left:c,topOffset:d,leftOffset:u})}setViewState(e,t=!1){if(!this.metrics)throw new Error("metrics not set");const{isStickyBottom:n,isStickyRight:s}=this.props,{top:o,left:i}=e,{lastTop:r,lastLeft:l}=this.metrics;o!=null&&this.setState({isStuckToBottom:n&&o>=r}),i!=null&&this.setState({isStuckToRight:s&&i>=l}),this.setState(e),t&&this.forceUpdate()}startEditing(e,t,n=!1,s,o){const{model:i}=this.props;if(!Pe(i))throw new Error("model is not editable");const r=this.getModelColumn(e),l=this.getModelRow(t),a={column:e,row:t,selectionRange:s,value:o!==void 0?o:i.editValueForCell(r,l),isQuickEdit:n};this.setState({editingCell:a,cursorColumn:e,cursorRow:t}),this.moveViewToCell(e,t)}isValidForCell(e,t,n){const{model:s}=this.props,o=this.getModelColumn(e),i=this.getModelRow(t);return Pe(s)&&s.isValidForCell(o,i,n)}async pasteValue(e){const{model:t}=this.props,{movedColumns:n,movedRows:s,selectedRanges:o}=this.state;try{if(yr(t),!t.isEditable||!o.every(u=>t.isEditableRange(u)))throw new mi("Can't paste in to read-only area.");if(o.length<=0)throw new mi("Select an area to paste to.");if(typeof e=="string"){const u=[],h=_.getModelRanges(o,n,s);K.forEachCell(h,(g,p)=>{u.push({column:g,row:p,text:e})}),await t.setValues(u);return}const i=e.length,r=e[0].length,{columnCount:l,rowCount:a}=t;let c=o;if(c.every(u=>{var h,g;return K.cellCount([u])===1&&((h=u.startColumn)!=null?h:0)+r<=l&&((g=u.startRow)!=null?g:0)+i<=a})&&(c=c.map(u=>{var h,g;return new K(u.startColumn,u.startRow,((h=u.startColumn)!=null?h:0)+r-1,((g=u.startRow)!=null?g:0)+i-1)}),this.setSelectedRanges(c)),!c.every(u=>K.rowCount([u])===i&&K.columnCount([u])===r))throw new mi("Copy and paste area are not same size.");const d=[];c.forEach(u=>{var h,g;for(let p=0;p<r;p+=1)for(let f=0;f<i;f+=1)d.push({column:((h=u.startColumn)!=null?h:0)+p,row:((g=u.startRow)!=null?g:0)+f,text:e[f][p]})}),await t.setValues(d)}catch(i){const{onError:r}=this.props;r(i instanceof Error?i:new Error(`${i}`))}}setValueForCell(e,t,n){const{model:s}=this.props;yr(s);const o=this.getModelColumn(e),i=this.getModelRow(t);return s.isValidForCell(o,i,n)?(s.setValueForCell(o,i,n),!0):!1}setValueForRanges(e,t){const{model:n}=this.props,{movedColumns:s,movedRows:o}=this.state,i=_.getModelRanges(e,s,o);Pe(n)&&n.setValueForRanges(i,t)}isSelected(e,t){var s,o;const{selectedRanges:n}=this.state;for(let i=0;i<n.length;i+=1){const r=n[i],l=r.startRow===null||r.startRow<=e&&e<=((s=r.endRow)!=null?s:0),a=r.startColumn===null||r.startColumn<=t&&t<=((o=r.endColumn)!=null?o:0);if(l&&a)return!0}return!1}addDocumentCursor(e=null){this.documentCursor!==$n.getCursorClassName(e)&&(this.documentCursor!=null&&document.documentElement.classList.remove(this.documentCursor),this.documentCursor=$n.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)},$n.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{cursorColumn:t,cursorRow:n,draggingColumn:s,draggingColumnSeparator:o,draggingRow:i,draggingRowOffset:r,draggingRowSeparator:l,editingCell:a,isDraggingHorizontalScrollBar:c,isDraggingVerticalScrollBar:d,isDragging:u,mouseX:h,mouseY:g,selectedRanges:p}=this.state,{model:f,stateOverride:C}=this.props,{renderer:w}=this,S=this.canvasContext,b=this.getTheme(),v=this.canvas.clientWidth,T=this.canvas.clientHeight,R={width:v,height:T,context:S,theme:b,model:f,metrics:e,mouseX:h,mouseY:g,selectedRanges:p,draggingColumn:s,draggingColumnSeparator:o,draggingRow:i,draggingRowOffset:r,draggingRowSeparator:l,editingCell:a,isDraggingHorizontalScrollBar:c,isDraggingVerticalScrollBar:d,isDragging:u,cursorColumn:t,cursorRow:n,...C};S.save(),w.drawCanvas(R),S.restore()}focus(){var e;(e=this.canvas)==null||e.focus()}isFocused(){return document.activeElement===this.canvas}handleClick(e){var s;const t=this.getGridPointFromEvent(e),n=this.getMouseHandlers();for(let o=0;o<n.length;o+=1)if(n[o].onClick(t,this,e)!==!1){e.stopPropagation(),e.preventDefault();break}(s=this.canvas)==null||s.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){var n,s;const t=this.getKeyHandlers();for(let o=0;o<t.length;o+=1){const r=t[o].onDown(e,this);if(r!==!1){const l=r;((n=l==null?void 0:l.stopPropagation)==null||n)&&e.stopPropagation(),((s=l==null?void 0:l.preventDefault)==null||s)&&e.preventDefault();break}}}notifyMouseHandlers(e,t,n=!0,s=!1){var l,a;const o=this.getGridPointFromEvent(t),i=this.getMouseHandlers();let r=null;for(let c=0;c<i.length;c+=1){const d=i[c],u=d[e]!=null&&d[e](o,this,t);if(u!==!1){d.cursor!=null&&({cursor:r}=d,s&&this.addDocumentCursor(r));const h=u;((l=h==null?void 0:h.stopPropagation)==null||l)&&t.stopPropagation(),((a=h==null?void 0:h.preventDefault)==null||a)&&t.preventDefault();break}}if(this.setState({cursor:r}),n){const{x:c,y:d}=o;this.setState({mouseX:c,mouseY:d})}}handleMouseDown(e){window.addEventListener("mousemove",this.handleMouseDrag,!0),window.addEventListener("mouseup",this.handleMouseUp,!0),!(e.button!=null&&e.button!==0)&&(this.notifyMouseHandlers("onDown",e),this.startDragTimer(e))}handleDoubleClick(e){this.notifyMouseHandlers("onDoubleClick",e)}handleMouseMove(e){this.notifyMouseHandlers("onMove",e)}handleMouseLeave(e){this.notifyMouseHandlers("onLeave",e,!1),this.setState({mouseX:null,mouseY:null})}handleMouseDrag(e){this.setState({isDragging:!0}),this.notifyMouseHandlers("onDrag",e,!0,!0),this.stopDragTimer()}handleMouseUp(e){window.removeEventListener("mousemove",this.handleMouseDrag,!0),window.removeEventListener("mouseup",this.handleMouseUp,!0),!(e.button!=null&&e.button!==0)&&(this.notifyMouseHandlers("onUp",e,!1),this.stopDragTimer(),this.removeDocumentCursor())}handleResize(){if(this.updateCanvasScale(),this.updateCanvas(),!this.metrics)throw new Error("metrics not set");this.forceUpdate()}handleWheel(e){var T,R,D,A;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:o,lastLeft:i,columnCount:r,rowCount:l,scrollableContentWidth:a,scrollableViewportWidth:c,scrollableContentHeight:d,scrollableViewportHeight:u,hasHorizontalBar:h,hasVerticalBar:g}=n;let{top:p,left:f,topOffset:C,leftOffset:w}=n;const S=this.getTheme();let{deltaX:b,deltaY:v}=_.getScrollDelta(e,n.barWidth,n.barHeight,n.rowHeight,n.rowHeight);for(;h&&b!==0;){if(w+=b,b=0,r>1){if(w>0&&f>=i||w<0&&f<=0){w=0;break}}else{if(w<=0){w=0;break}const I=a-c;if(w>=I){w=I;break}}if(w>0){const I=(T=n.allColumnWidths.get(f))!=null?T:t.getVisibleColumnWidth(f,s);w>=I?(b=w-I,w=0,f+=1):S.scrollSnapToColumn&&r>1&&(w=0,f+=1)}else if(w<0){const I=(R=n.allColumnWidths.get(f-1))!=null?R:t.getVisibleColumnWidth(f-1,s);Math.abs(w)<=I&&S.scrollSnapToColumn&&r>1?(w=0,f-=1):(b=w+I,w=0,f-=1)}}for(;g&&v!==0;){if(C+=v,v=0,l>1){if(C>0&&p>=o||C<0&&p<=0){C=0;break}}else{if(C<=0){C=0;break}const I=d-u;if(C>=I){C=I;break}}if(C>0){const I=(D=n.allRowHeights.get(p))!=null?D:t.getVisibleRowHeight(p,s);C>=I?(v=C-I,C=0,p+=1):S.scrollSnapToRow&&l>1&&(C=0,p+=1)}else if(C<0){const I=(A=n.allRowHeights.get(p-1))!=null?A:t.getVisibleRowHeight(p-1,s);Math.abs(C)<=I&&S.scrollSnapToRow&&l>1?(C=0,p-=1):(v=C+I,C=0,p-=1)}}this.setViewState({top:p,left:f,leftOffset:w,topOffset:C}),e.stopPropagation(),e.preventDefault()}handleEditCellCancel(){this.setState({editingCell:null}),this.focus()}handleEditCellChange(e){this.setState(({editingCell:t})=>{try{return Rr(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=At.DOWN,fillRange:n=!1}={}){const{editingCell:s,selectedRanges:o}=this.state;if(!s)throw new Error("editingCell not set");const{column:i,row:r}=s;if(!this.isValidForCell(i,r,e)){t===null&&this.setState({editingCell:null});return}n?this.setValueForRanges(o,e):this.setValueForCell(i,r,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||!Pe(e))return null;const{selectionRange:s,value:o,isQuickEdit:i}=t,{column:r,row:l}=t,{gridX:a,gridY:c,allColumnXs:d,allRowYs:u,allColumnWidths:h,allRowHeights:g}=n,p=d.get(r),f=u.get(l),C=h.get(r),w=g.get(l),S=p!=null&&f!=null&&C!=null&&w!=null?{position:"absolute",left:a+p,top:c+f,width:C,height:w}:{opacity:0},b=this.getModelColumn(r),v=this.getModelRow(l),T=b!=null&&v!=null?{textAlign:e.textAlignForCell(b,v)}:void 0,R=e.isValidForCell(b,v,o);return m("div",{style:S,children:m(Ki,{selectionRange:s,className:Z({error:!R}),onCancel:this.handleEditCellCancel,onChange:this.handleEditCellChange,onDone:this.handleEditCellCommit,isQuickEdit:i,style:T,value:o},`${r},${l}`)})}render(){const{cursor:e}=this.state;return y(Oe,{children:[m("canvas",{className:Z("grid-canvas",$n.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()]})}};let Rs=$n;Rs.contextType=Sd;Rs.defaultProps={canvasOptions:{alpha:!1},isStickyBottom:!1,isStickyRight:!1,isStuckToBottom:!1,isStuckToRight:!1,keyHandlers:ye,mouseHandlers:ye,movedColumns:ye,movedRows:ye,onError:()=>{},onSelectionChanged:()=>{},onMovedColumnsChanged:e=>{},onMoveColumnComplete:()=>{},onMovedRowsChanged:()=>{},onMoveRowComplete:()=>{},onViewChanged:()=>{},stateOverride:{},theme:{autoSelectColumn:!1,autoSelectRow:!1}};Rs.pixelsPerLine=100/3;Rs.dragTimeout=1e3;Rs.getTheme=Fe((e,t)=>({...nd,...e,...t}));class Tl extends wa{get floatingTopRowCount(){return 0}get floatingBottomRowCount(){return 0}get floatingLeftColumnCount(){return 0}get floatingRightColumnCount(){return 0}get columnHeaderMaxDepth(){return 1}truncationCharForCell(t,n){}textAlignForCell(t,n){return"left"}colorForCell(t,n,s){return s.textColor}backgroundColorForCell(t,n,s){return null}colorForColumnHeader(t,n=0){return null}textForRowHeader(t){return""}textForRowFooter(t){return""}isColumnMovable(t,n=0){return!0}isRowMovable(t){return!0}getColumnHeaderGroup(t,n){}getColumnHeaderParentGroup(t,n){}}class Td extends Tl{constructor({rowCount:t=1e9,columnCount:n=100,floatingTopRowCount:s=0,floatingBottomRowCount:o=0,floatingLeftColumnCount:i=0,floatingRightColumnCount:r=0,isEditable:l=!1,editedData:a=[]}={}){super(),this.numRows=t,this.numColumns=n,this.floatingTop=s,this.floatingBottom=o,this.floatingLeft=i,this.floatingRight=r,this.editable=l,this.editedData=a}get rowCount(){return this.numRows}get columnCount(){return this.numColumns}get floatingTopRowCount(){return this.floatingTop}get floatingBottomRowCount(){return this.floatingBottom}get floatingLeftColumnCount(){return this.floatingLeft}get floatingRightColumnCount(){return this.floatingRight}get isEditable(){return this.editable}textForCell(t,n){var s,o;return(o=(s=this.editedData[t])==null?void 0:s[n])!=null?o:`${t},${n}`}colorForCell(t,n,s){return s.textColor}textForColumnHeader(t,n=0){return`${t}`}textForRowHeader(t){return`${t}`}textForRowFooter(t){return`${t}`}async setValueForCell(t,n,s){this.editedData[t]==null&&(this.editedData[t]=[]),this.editedData[t][n]=`${s}`}async setValueForRanges(t,n){K.forEachCell(t,(s,o)=>{this.setValueForCell(s,o,n)})}async setValues(t){var n,s;for(let o=0;o<t.length;o+=1){const i=t[o];this.setValueForCell((n=i.column)!=null?n:i.x,(s=i.row)!=null?s:i.y,i.text)}}editValueForCell(t,n){return this.textForCell(t,n)}isValidForCell(t,n,s){return!0}isEditableRange(t){return this.isEditable}delete(t){throw new Error("Method not implemented.")}}const zn=class extends Td{constructor({rowCount:e=zn.DEFAULT_ROW_COUNT,columnCount:t=zn.DEFAULT_COLUMN_COUNT,children:n=new Map,childRowCount:s=Math.ceil(Math.max(zn.MIN_CHILD_ROW_COUNT,e*zn.DEFAULT_CHILD_ROW_COUNT_FACTOR)),maxDepth:o=zn.MAX_DEPTH}={}){super({rowCount:e,columnCount:t}),this.getCachedModelRowOffset=pt((i,r)=>{let l=null,a=r;const c=[...i].sort((d,u)=>d[0]-u[0]);for(let d=0;d<c.length;d+=1){const[u,h]=c[d];if(a<=u)break;const g=h.rowCount;if(a<=u+g){l=u,a=a-u-1;break}a-=g}return{key:l,offsetRow:a}}),this.getCachedTextForRowHeader=pt((i,r)=>{const{key:l,offsetRow:a}=this.getCachedModelRowOffset(i,r);if(l!=null){const c=i.get(l);if(c!==void 0)return`${l}.${c.textForRowHeader(a)}`}return`${a}`}),this.getCachedTextForCell=pt((i,r,l)=>{const{key:a,offsetRow:c}=this.getCachedModelRowOffset(i,l);if(a!=null){const d=i.get(a);if(d!==void 0)return`${a}.${d.textForCell(r,c)}`}return`${r},${c}`}),this.getCachedIsRowExpandable=pt((i,r,l)=>this.getCachedDepthForRow(i,r)<l),this.getCachedIsRowExpanded=pt((i,r)=>{const{key:l,offsetRow:a}=this.getCachedModelRowOffset(i,r);if(l!=null){const c=i.get(l);if(c!==void 0)return c.isRowExpanded(a)}return i.has(a)}),this.getCachedDepthForRow=pt((i,r)=>{const{key:l,offsetRow:a}=this.getCachedModelRowOffset(i,r);if(l!=null){const c=i.get(l);if(c!==void 0)return c.depthForRow(a)+1}return 0}),this.children=n,this.childRowCount=s,this.maxDepth=o}textForCell(e,t){return this.getCachedTextForCell(this.children,e,t)}textForRowHeader(e){return this.getCachedTextForRowHeader(this.children,e)}isRowMovable(e){return!1}get hasExpandableRows(){return!0}get isExpandAllAvailable(){return!1}get floatingBottomRowCount(){return 0}isRowExpandable(e){return this.getCachedIsRowExpandable(this.children,e,this.maxDepth)}isRowExpanded(e){return this.getCachedIsRowExpanded(this.children,e)}setRowExpanded(e,t,n=!1){const{key:s,offsetRow:o}=this.getCachedModelRowOffset(this.children,e),i=new Map(this.children);if(s!=null){const r=this.children.get(s);if(r!==void 0){const{rowCount:l}=r;r.setRowExpanded(o,t,n),this.numRows+=r.rowCount-l}}else if(t){const r=new zn({rowCount:this.childRowCount,columnCount:this.numColumns});i.set(o,r),this.numRows+=r.rowCount}else{const r=i.get(o);r!==void 0&&(this.numRows-=r.rowCount,i.delete(o))}this.children=i}expandAll(){throw new Error("Expand all not implemented.")}collapseAll(){throw new Error("Collapse all not implemented.")}depthForRow(e){return this.getCachedDepthForRow(this.children,e)}};let Zs=zn;Zs.DEFAULT_ROW_COUNT=1e9;Zs.DEFAULT_COLUMN_COUNT=100;Zs.DEFAULT_CHILD_ROW_COUNT_FACTOR=.01;Zs.MIN_CHILD_ROW_COUNT=10;Zs.MAX_DEPTH=10;const{dh:E}=globalThis,jo=B.exports.shape({name:B.exports.string.isRequired,type:B.exports.string.isRequired,description:B.exports.string,constituentType:B.exports.string}),bl=B.exports.shape({not:B.exports.func.isRequired,and:B.exports.func.isRequired,or:B.exports.func.isRequired}),bd=B.exports.shape({asc:B.exports.func.isRequired,desc:B.exports.func.isRequired,abs:B.exports.func.isRequired,column:jo.isRequired,direction:B.exports.string.isRequired,isAbs:B.exports.bool.isRequired}),Ed=B.exports.shape({columns:B.exports.arrayOf(jo).isRequired,customColumns:B.exports.arrayOf(B.exports.string).isRequired,filter:B.exports.arrayOf(bl),addEventListener:B.exports.func.isRequired,removeEventListener:B.exports.func.isRequired,size:B.exports.number.isRequired,sort:B.exports.arrayOf(B.exports.any),copy:B.exports.func.isRequired,applyFilter:B.exports.func.isRequired,applySort:B.exports.func.isRequired,applyCustomColumns:B.exports.func.isRequired,description:B.exports.string}),vd=B.exports.shape({columns:B.exports.arrayOf(jo),filter:B.exports.arrayOf(B.exports.any),isExpanded:B.exports.func.isRequired,saveExpandedState:B.exports.func.isRequired,addEventListener:B.exports.func.isRequired,removeEventListener:B.exports.func.isRequired,size:B.exports.number.isRequired,sort:B.exports.arrayOf(B.exports.any),applyFilter:B.exports.func.isRequired,applySort:B.exports.func.isRequired}),Oo=B.exports.shape({name:B.exports.string.isRequired,type:B.exports.string.isRequired}),Rd=B.exports.shape({created:B.exports.arrayOf(Oo).isRequired,updated:B.exports.arrayOf(Oo).isRequired,removed:B.exports.arrayOf(Oo).isRequired}),yd=B.exports.shape({groupingColumns:B.exports.arrayOf(B.exports.string),aggregations:B.exports.shape({}),includeConstituents:B.exports.bool,includeOriginalColumns:B.exports.bool,includeDescriptions:B.exports.bool}),Fd=B.exports.shape({addEventListener:B.exports.func.isRequired,removeEventListener:B.exports.func.isRequired,onLogMessage:B.exports.func,getTable:B.exports.func.isRequired,runCode:B.exports.func.isRequired});Object.freeze({Column:jo,FilterCondition:bl,IdeSession:Fd,RollupConfig:yd,Sort:bd,Table:Ed,TreeTable:vd,VariableChanges:Rd,VariableDefinition:Oo});const Dd=1e4;function Id(e,t,n=Dd){return new Promise((s,o)=>{let i;const r=setTimeout(()=>{i==null||i(),o(new il(`Variable ${t} not found`))},n);function l(a){const c=a.created.find(d=>d.title===t);c!=null&&(clearTimeout(r),i==null||i(),s(c))}i=e.subscribeToFieldUpdates(l)})}class _e{static isValid(t){return!0}static isSameFormat(t,n){throw new Error("isSameFormat not implemented")}static makeFormat(t,n,s){return{label:t,formatString:n,type:s}}format(t,n){return""}}_e.TYPE_GLOBAL="type-global";_e.TYPE_CONTEXT_PRESET="type-context-preset";_e.TYPE_CONTEXT_CUSTOM="type-context-custom";class Nd extends _e{format(t){switch(t){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}class Ad extends _e{format(t){return String.fromCharCode(t)}}const Ar=le.module("DateTimeColumnFormatter"),qn=class extends _e{constructor({timeZone:e="",showTimeZone:t=!0,showTSeparator:n=!1,defaultDateTimeFormatString:s=qn.DEFAULT_DATETIME_FORMAT_STRING}={}){super();const o=e||qn.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=E.i18n.TimeZone.getTimeZone(o)}catch{Ar.error("Unsupported time zone id",o),this.dhTimeZone=E.i18n.TimeZone.getTimeZone(qn.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=s,this.showTimeZone=t,this.showTSeparator=n,this.formatStringMap=qn.makeFormatStringMap(t,n)}static isValid(e){try{return E.i18n.DateTimeFormat.format(e.formatString,new Date),!0}catch{return!1}}static makeFormat(e,t,n=_e.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 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[...qn.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[...qn.makeFormatStringMap(e,t).keys()]}getEffectiveFormatString(e){var t;return(t=this.formatStringMap.get(e))!=null?t:e}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultDateTimeFormatString,s=this.getEffectiveFormatString(n);try{return E.i18n.DateTimeFormat.format(s,e,this.dhTimeZone)}catch{Ar.error("Invalid format arguments")}return""}};let kn=qn;kn.DEFAULT_DATETIME_FORMAT_STRING="yyyy-MM-dd HH:mm:ss.SSS";kn.DEFAULT_TIME_ZONE_ID="America/New_York";const Md=le.module("DecimalColumnFormatter"),Mt=class extends _e{constructor({defaultFormatString:e=Mt.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=e}static isValid(e){try{return E.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=_e.TYPE_CONTEXT_PRESET,s){return{label:e,type:n,formatString:t,multiplier:s}}static makePresetFormat(e,t="",n){return Mt.makeFormat(e,t,_e.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return Mt.makeFormat("Custom Format",e,_e.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}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,s=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return E.i18n.NumberFormat.format(n,s)}catch{Md.error("Invalid format arguments")}return""}};let Ve=Mt;Ve.DEFAULT_FORMAT_STRING="###,##0.0000";Ve.FORMAT_PERCENT=Mt.makePresetFormat("Percent","##0.00%");Ve.FORMAT_BASIS_POINTS=Mt.makePresetFormat("Basis Points","###,##0 bp",1e4);Ve.FORMAT_MILLIONS=Mt.makePresetFormat("Millions","###,##0.000 mm",1e-6);Ve.FORMAT_SCIENTIFIC_NOTATION=Mt.makePresetFormat("Scientific Notation","0.0000E0");Ve.FORMAT_ROUND=Mt.makePresetFormat("Round","###,##0");Ve.FORMAT_ROUND_TWO_DECIMALS=Mt.makePresetFormat("0.00","###,##0.00");Ve.FORMAT_ROUND_FOUR_DECIMALS=Mt.makePresetFormat("0.0000","###,##0.0000");class Od extends _e{format(t){return`${t}`}}const xd=le.module("IntegerColumnFormatter"),Ts=class extends _e{constructor({defaultFormatString:e=Ts.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=e}static isValid(e){try{return E.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=_e.TYPE_CONTEXT_PRESET,s){return{label:e,type:n,formatString:t,multiplier:s}}static makePresetFormat(e,t="",n){return Ts.makeFormat(e,t,_e.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return Ts.makeFormat("Custom Format",e,_e.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}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,s=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return E.i18n.NumberFormat.format(n,s)}catch{xd.error("Invalid format arguments")}return""}};let It=Ts;It.DEFAULT_FORMAT_STRING="###,##0";It.FORMAT_MILLIONS=Ts.makePresetFormat("Millions","###,##0.000 mm",1e-6);It.FORMAT_SCIENTIFIC_NOTATION=Ts.makePresetFormat("Scientific Notation","0.0000E0");class kd extends _e{format(t){return t}}const ct=class{static makeDateWrapper(e,t,n=0,s=1,o=0,i=0,r=0,l=0){if(!e)throw new Error("No timezone provided");const a=`${t}`.padStart(4,"0"),c=`${n+1}`.padStart(2,"0"),d=`${s}`.padStart(2,"0"),u=`${o}`.padStart(2,"0"),h=`${i}`.padStart(2,"0"),g=`${r}`.padStart(2,"0"),p=`${l}`.padStart(9,"0"),f=`${a}-${c}-${d} ${u}:${h}:${g}.${p}`;return E.i18n.DateTimeFormat.parse(ct.FULL_DATE_FORMAT,f,E.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:o,date:i,hours:r,minutes:l,seconds:a,nanos:c}=t;if(e.nanos!=null){if(e.nanos.length===9)return null;c=ct.getNextNanos(e.nanos),c>999999999&&(a+=1,c=0)}else e.seconds!=null?a+=1:e.minutes!=null?l+=1:e.hours!=null?r+=1:e.date!=null?i+=1:e.month!=null?o+=1:s+=1;const d=new Date(s,o,i,r,l,a);return ct.makeDateWrapper(n,d.getFullYear(),d.getMonth(),d.getDate(),d.getHours(),d.getMinutes(),d.getSeconds(),c)}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<ct.months.length;s+=1)if(ct.months[s].startsWith(n))return s}return NaN}static parseDateValues(e,t,n,s,o,i,r){const l=parseInt(e,10),a=t!=null?this.parseMonth(t):0,c=n!=null?parseInt(n,10):1,d=s!=null?parseInt(s,10):0,u=o!=null?parseInt(o,10):0,h=i!=null?parseInt(i,10):0,g=r!=null?parseInt(r.padEnd(9,"0"),10):0;return Number.isNaN(l)||Number.isNaN(a)||Number.isNaN(c)||Number.isNaN(d)||Number.isNaN(u)||Number.isNaN(h)||Number.isNaN(g)?null:{year:l,month:a,date:c,hours:d,minutes:u,seconds:h,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,,o,,i,,r,,l,,a,,c,d]=n;if(d!=null&&d.length>0)throw new Error(`Unexpected characters after date string '${e}': ${d}`);return{year:s,month:o,date:i,hours:r,minutes:l,seconds:a,nanos:c}}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 l=new Date(Date.now()),a=ct.makeDateWrapper(t,l.getFullYear(),l.getMonth(),l.getDate()),c=ct.makeDateWrapper(t,l.getFullYear(),l.getMonth(),l.getDate()+1);return[a,c]}if(n==="yesterday"){const l=new Date(Date.now()),a=ct.makeDateWrapper(t,l.getFullYear(),l.getMonth(),l.getDate()-1),c=ct.makeDateWrapper(t,l.getFullYear(),l.getMonth(),l.getDate());return[a,c]}if(n==="now"){const l=new Date(Date.now());return[E.DateWrapper.ofJsDate(l),null]}const s=ct.parseDateTimeString(n);if(s.year==null&&s.month==null&&s.date==null)throw new Error(`Unable to extract year, month, or day ${n}`);const o=ct.parseDateValues(s.year,s.month,s.date,s.hours,s.minutes,s.seconds,s.nanos);if(o==null)throw new Error(`Unable to extract date values from ${s}`);const i=ct.makeDateWrapper(t,o.year,o.month,o.date,o.hours,o.minutes,o.seconds,o.nanos),r=ct.getNextDate(s,o,t);return[i,r]}static getJsDate(e){return typeof e=="number"?new Date(e):e.asDate()}};let qt=ct;qt.FULL_DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";qt.months=["january","february","march","april","may","june","july","august","september","october","november","december"];class Gt{}Gt.not="not";Gt.and="and";Gt.or="or";function Ld(e){if(!(e==="not"||e==="and"||e==="or"))throw new Error("operator is not a valid FilterOperatorValue")}class P{}P.eq="eq";P.eqIgnoreCase="eqIgnoreCase";P.notEq="notEq";P.notEqIgnoreCase="notEqIgnoreCase";P.greaterThan="greaterThan";P.greaterThanOrEqualTo="greaterThanOrEqualTo";P.lessThan="lessThan";P.lessThanOrEqualTo="lessThanOrEqualTo";P.in="in";P.inIgnoreCase="inIgnoreCase";P.notIn="notIn";P.notInIgnoreCase="notInIgnoreCase";P.isTrue="isTrue";P.isFalse="isFalse";P.isNull="isNull";P.invoke="invoke";P.contains="contains";P.notContains="notContains";P.startsWith="startsWith";P.endsWith="endsWith";P.containsAny="containsAny";function Pd(e){switch(e){case P.eq:return"is exactly";case P.eqIgnoreCase:return"is exactly (ignore case)";case P.notEq:return"is not exactly";case P.notEqIgnoreCase:return"is not exactly (ignore case)";case P.contains:return"contains";case P.notContains:return"does not contain";case P.startsWith:return"starts with";case P.endsWith:return"ends with";default:throw new Error(`Unrecognized text filter type ${e}`)}}function _d(e){switch(e){case P.eq:return"is equal to";case P.notEq:return"is not equal to";case P.greaterThan:return"greater than";case P.greaterThanOrEqualTo:return"greater than or equal to";case P.lessThan:return"less than";case P.lessThanOrEqualTo:return"less than or equal to";default:throw new Error(`Unrecognized number filter type ${e}`)}}function Hd(e){switch(e){case P.eq:return"date is";case P.notEq:return"date is not";case P.notEqIgnoreCase:case P.greaterThan:return"date is after";case P.greaterThanOrEqualTo:return"date is after or equal";case P.lessThan:return"date is before";case P.lessThanOrEqualTo:return"date is before or equal";default:throw new Error(`Unrecognized date filter type ${e}`)}}function Vd(e){switch(e){case P.isTrue:return"Is True";case P.isFalse:return"Is False";case P.isNull:return"Is Null";default:throw new Error(`Unrecognized boolean filter type ${e}`)}}const Zt=le.module("TableUtils"),X=class{static getSortIndex(e,t){var n;for(let s=0;s<e.length;s+=1)if(((n=e[s].column)==null?void 0:n.index)===t)return s;return null}static getSortForColumn(e,t){const n=X.getSortIndex(e,t);return n!=null?e[n]:null}static getFilterText(e){return e?e.toString():null}static getFilterTypes(e){return X.isBooleanType(e)?[P.isTrue,P.isFalse,P.isNull]:X.isCharType(e)||X.isNumberType(e)||X.isDateType(e)?[P.eq,P.notEq,P.greaterThan,P.greaterThanOrEqualTo,P.lessThan,P.lessThanOrEqualTo]:X.isTextType(e)?[P.eq,P.eqIgnoreCase,P.notEq,P.notEqIgnoreCase,P.contains,P.notContains,P.startsWith,P.endsWith]:[]}static getNextSort(e,t,n){if(e==null||n<0||n>=e.length)return null;const s=X.getSortForColumn(t,n);return s===null?e[n].sort().asc():s.direction===X.sortDirection.ascending?s.desc():null}static makeColumnSort(e,t,n,s){if(e==null||t<0||t>=e.length||n===X.sortDirection.none)return null;let o=e[t].sort();switch(n){case X.sortDirection.ascending:o=o.asc();break;case X.sortDirection.descending:o=o.desc();break}return s&&(o=o.abs()),o}static toggleSortForColumn(e,t,n,s=!1){if(n<0||n>=t.length)return[];const o=X.getNextSort(t,e,n);return X.setSortForColumn(e,n,o,s)}static sortColumn(e,t,n,s,o,i){if(e==null||n<0||n>=t.length)return[];const r=X.makeColumnSort(t,n,s,o);return X.setSortForColumn(e,n,r,i)}static setSortForColumn(e,t,n,s=!1){const o=X.getSortIndex(e,t);let i=[];return s&&(i=i.concat(e.filter(({direction:r})=>r!==X.sortDirection.reverse)),o!==null&&i.splice(o,1)),n!==null&&i.push(n),i}static getNormalizedType(e){switch(e){case"boolean":case"java.lang.Boolean":case X.dataType.BOOLEAN:return X.dataType.BOOLEAN;case"char":case"java.lang.Character":case X.dataType.CHAR:return X.dataType.CHAR;case"java.lang.String":case X.dataType.STRING:return X.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 X.dataType.DATETIME:return X.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case X.dataType.DECIMAL:return X.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 X.dataType.INT:return X.dataType.INT;default:return X.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 X.isIntegerType(e)||X.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 X.getNormalizedType(e)===X.getNormalizedType(t)}static makeQuickFilter(e,t,n){const s=t.split("||");let o=null;for(let i=0;i<s.length;i+=1){const l=s[i].split("&&");let a=null;for(let c=0;c<l.length;c+=1){const d=l[c].trim();if(d.length>0){const u=X.makeQuickFilterFromComponent(e,d,n);if(u)a?a=a.and(u):a=u;else throw new Error(`Unable to parse quick filter from text ${t}`)}}o&&a?o=o.or(a):o=a}return o}static makeQuickFilterFromComponent(e,t,n){const{type:s}=e;return X.isNumberType(s)?this.makeQuickNumberFilter(e,t):X.isBooleanType(s)?this.makeQuickBooleanFilter(e,t):n!=null&&X.isDateType(s)?this.makeQuickDateFilter(e,t,n):X.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 i=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i.exec(t);let r=null,l=null,a=null,c=null,d=null;if(i!==null&&i.length>3&&([,r,l,a,c,d]=i),d!=null&&d.trim().length>0)return null;if(r==null&&(r="="),c!=null){if(!(r==="="||r==="!"||r==="!="))return null;switch(c=c.trim().toLowerCase(),c){case"null":s=n.isNull();break;case"nan":s=E.FilterCondition.invoke("isNaN",n);break;case"infinity":case"inf":case"\u221E":l!=null?s=E.FilterCondition.invoke("isInf",n).and(n.lessThan(E.FilterValue.ofNumber(0))):s=E.FilterCondition.invoke("isInf",n).and(n.greaterThan(E.FilterValue.ofNumber(0)));break}return s!==null&&(r==="!"||r==="!=")&&(s=s.not()),s}if(a==null)return null;if(a=X.removeCommas(a),X.isLongType(e.type))try{a=E.FilterValue.ofNumber(E.LongWrapper.ofString(`${l!=null?"-":""}${a}`))}catch(u){return Zt.warn("Unable to create long filter",u),null}else{if(a=parseFloat(a),a==null||Number.isNaN(a))return null;a=E.FilterValue.ofNumber(l!=null?0-a:a)}return s=e.filter(),X.makeRangeFilterWithOperation(s,r,a)}static makeQuickTextFilter(e,t){if(t==null)return null;const n=`${t}`.trim(),o=/^(!~|!=|~|=|!)?(.*)/.exec(n);let i=null,r=null;if(o!==null&&o.length>2&&([,i,r]=o,r!=null&&(r=r.trim())),r==null||r.length===0)return null;i==null&&(i="=");const l=e.filter();if(r.toLowerCase()==="null")switch(i){case"=":return l.isNull();case"!=":case"!":return l.isNull().not()}let a=null,c=null;switch(r.startsWith("*")?(a="*",r=r.substring(1)):r.endsWith("*")&&!r.endsWith("\\*")&&(c="*",r=r.substring(0,r.length-1)),r=r.replace("\\",""),i){case"~":return l.isNull().not().and(l.invoke("matches",E.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E.*`)));case"!~":return l.isNull().or(l.invoke("matches",E.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E.*`)).not());case"!=":return a==="*"?l.isNull().or(l.invoke("matches",E.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E$`)).not()):c==="*"?l.isNull().or(l.invoke("matches",E.FilterValue.ofString(`(?s)(?i)^\\Q${r}\\E.*`)).not()):l.notEqIgnoreCase(E.FilterValue.ofString(r.toLowerCase()));case"=":return a==="*"?l.isNull().not().and(l.invoke("matches",E.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E$`))):c==="*"?l.isNull().not().and(l.invoke("matches",E.FilterValue.ofString(`(?s)(?i)^\\Q${r}\\E.*`))):l.eqIgnoreCase(E.FilterValue.ofString(r.toLowerCase()))}return null}static makeQuickBooleanFilter(e,t){if(t==null)return null;const s=/^(!=|=|!)?(.*)/.exec(`${t}`.trim());if(s===null)return null;const[,o,i]=s,r=o==="!"||o==="!=",l=i.trim().toLowerCase();let a=e.filter();try{const c=X.makeBooleanValue(l);return c!=null&&c?a=a.isTrue():c===null?a=a.isNull():a=a.isFalse(),r?a.not():a}catch{return null}}static makeQuickDateFilter(e,t,n){const s=t.trim(),i=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/.exec(s);if(i==null||i.length<=2)throw new Error(`Unable to parse date filter: ${t}`);let r=null,l=null;[,r,l]=i;let a=P.eq;switch(r){case"<":a=P.lessThan;break;case"<=":case"=<":a=P.lessThanOrEqualTo;break;case">":a=P.greaterThan;break;case">=":case"=>":a=P.greaterThanOrEqualTo;break;case"!=":case"!":a=P.notEq;break;case"=":case"==":default:a=P.eq;break}return X.makeQuickDateFilterWithOperation(e,l,a,n)}static makeQuickDateFilterWithOperation(e,t,n,s){if(e==null)throw new Error("Column is null");const[o,i]=qt.parseDateRange(t,s),r=o!=null?E.FilterValue.ofNumber(o):null,l=i!=null?E.FilterValue.ofNumber(i):null,a=e.filter();if(r==null)return n===P.notEq?a.isNull().not():a.isNull();switch(n){case P.eq:{if(l!=null){const c=a.greaterThanOrEqualTo(r),d=a.lessThan(l);return c.and(d)}return a.eq(r)}case P.lessThan:return a.lessThan(r);case P.lessThanOrEqualTo:return l!=null?a.lessThan(l):a.lessThanOrEqualTo(r);case P.greaterThan:return l!=null?a.greaterThanOrEqualTo(l):a.greaterThan(r);case P.greaterThanOrEqualTo:return a.greaterThanOrEqualTo(r);case P.notEq:{if(l!=null){const c=a.lessThan(r),d=a.greaterThanOrEqualTo(l);return c.or(d)}return a.notEq(r)}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(),o=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/.exec(n);let i=null,r=null,l=null;if(o!==null&&o.length>3&&([,i,r,l]=o),l!=null&&l.trim().length>0||r==null||r.length===0)return null;i==null&&(i="=");const a=e.filter();if(r.toLowerCase()==="null")switch(i){case"=":return a.isNull();case"!=":case"!":return a.isNull().not();default:return null}const c=E.FilterValue.ofString(X.isRangeOperation(i)?X.quoteValue(r):r);return X.makeRangeFilterWithOperation(a,i,c)}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 ze.makeCancelable(e,t=>{t.close()})}static makeCancelableTableEventPromise(e,t,n=0,s=null){let o,i,r=!0;const l=new Promise((a,c)=>{i=setTimeout(()=>{o(),r=!1,c(new il(`Event "${t}" timed out.`))},n),o=e.addEventListener(t,d=>{if(s!=null&&!s(d)){Zt.debug2("Event triggered, but matcher returned false.");return}Zt.debug2("Event triggered, resolving."),o(),clearTimeout(i),r=!1,a(d)})});return l.cancel=()=>{if(r){Zt.debug2("Pending promise cleanup."),o(),clearTimeout(i),r=!1;return}Zt.debug2("Ignoring non-pending promise cancel.")},l}static makeAdvancedFilter(e,t,n){const{filterItems:s,filterOperators:o,invertSelection:i,selectedValues:r}=t;let l=null;for(let c=0;c<s.length;c+=1){const d=s[c],{selectedType:u,value:h}=d;if(u!=null&&u.length>0&&h!=null&&h.length>0)try{const g=X.makeAdvancedValueFilter(e,u,h,n);if(g!=null){if(c===0)l=g;else if(l!==null&&c-1<o.length){const p=o[c-1];if(p===Gt.and)l=l.and(g);else if(p===Gt.or)l=l.or(g);else{Zt.error("Unexpected filter operator",p,g),l=null;break}}}else Zt.debug2("Empty filter ignored for",u,h)}catch(g){Zt.error("Unable to create filter",g),l=null;break}}const a=X.makeSelectValueFilter(e,r,i);return a!=null&&(l!=null?l=l.and(a):l=a),l}static removeCommas(e){return e.replace(/[\s|,]/g,"")}static makeFilterValue(e,t){const n=X.getBaseType(e);return X.isTextType(n)?E.FilterValue.ofString(t):X.isLongType(n)?E.FilterValue.ofNumber(E.LongWrapper.ofString(X.removeCommas(t))):E.FilterValue.ofNumber(X.removeCommas(t))}static makeFilterRawValue(e,t){return X.isTextType(e)?E.FilterValue.ofString(t):X.isBooleanType(e)?E.FilterValue.ofBoolean(t):E.FilterValue.ofNumber(t)}static makeValue(e,t,n){if(t==null||t==="null")return null;if(X.isTextType(e))return t;if(X.isLongType(e))return E.LongWrapper.ofString(X.removeCommas(t));if(X.isBooleanType(e))return X.makeBooleanValue(t,!0);if(X.isDateType(e)){const[s]=qt.parseDateRange(t,n);return s}return X.isNumberType(e)?X.makeNumberValue(t):(Zt.error("Unexpected column type",e),null)}static makeBooleanValue(e,t=!1){if(e===""&&t)return null;switch(e==null?void 0: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==="\u221E"||t==="infinity"||t==="inf")return Number.POSITIVE_INFINITY;if(t==="-\u221E"||t==="-infinity"||t==="-inf")return Number.NEGATIVE_INFINITY;const n=X.removeCommas(t);if(X.NUMBER_REGEX.test(n))return parseFloat(n);throw new Error(`Invalid number '${e}'`)}static getFilterOperatorString(e){switch(e){case P.eq:return"=";case P.notEq:return"!=";case P.greaterThan:return">";case P.greaterThanOrEqualTo:return">=";case P.lessThan:return"<";case P.lessThanOrEqualTo:return"<=";case P.contains:return"~";case P.notContains:return"!~";default:throw new Error(`Unexpected filter type ${e}`)}}static makeAdvancedValueFilter(e,t,n,s){if(X.isDateType(e.type))return X.makeQuickDateFilterWithOperation(e,n,t,s);if(X.isNumberType(e.type)||X.isCharType(e.type))return X.makeQuickFilter(e,`${X.getFilterOperatorString(t)}${n}`);const o=X.makeFilterValue(e.type,n),i=e.filter();switch(t){case P.eq:return i.eq(o);case P.eqIgnoreCase:return i.eqIgnoreCase(o);case P.notEq:return i.notEq(o);case P.notEqIgnoreCase:return i.notEqIgnoreCase(o);case P.greaterThan:return i.greaterThan(o);case P.greaterThanOrEqualTo:return i.greaterThanOrEqualTo(o);case P.lessThan:return i.lessThan(o);case P.lessThanOrEqualTo:return i.lessThanOrEqualTo(o);case P.isTrue:return i.isTrue();case P.isFalse:return i.isFalse();case P.isNull:return i.isNull();case P.contains:return i.isNull().not().and(i.invoke("matches",E.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)));case P.notContains:return i.isNull().or(i.invoke("matches",E.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)).not());case P.startsWith:return i.isNull().not().and(i.invoke("matches",E.FilterValue.ofString(`(?s)(?i)^\\Q${n}\\E.*`)));case P.endsWith:return i.isNull().not().and(i.invoke("matches",E.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E$`)));case P.in:case P.inIgnoreCase:case P.notIn:case P.notInIgnoreCase:case P.invoke:default:throw new Error(`Unexpected filter operation: ${t}`)}}static makeSelectValueFilter(e,t,n){if(t.length===0){if(n)return null;let i=null;X.isTextType(e.type)?i=E.FilterValue.ofString("a"):X.isBooleanType(e.type)?i=E.FilterValue.ofBoolean(!0):X.isDateType(e.type)?i=E.FilterValue.ofNumber(E.DateWrapper.ofJsDate(new Date)):i=E.FilterValue.ofNumber(0);const r=e.filter().eq(i),l=e.filter().notEq(i);return r.and(l)}const s=[];let o=!1;for(let i=0;i<t.length;i+=1){const r=t[i];r==null?o=!0:X.isTextType(e.type)?s.push(E.FilterValue.ofString(typeof r=="number"?String.fromCharCode(r):r)):X.isBooleanType(e.type)?s.push(E.FilterValue.ofBoolean(Boolean(r))):s.push(E.FilterValue.ofNumber(r))}return o?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 o=n.name.toUpperCase(),i=s.name.toUpperCase();return Wi.sort(o,i,t)})}};let N=X;N.dataType={BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"};N.sortDirection={ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null};N.REVERSE_TYPE=Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"});N.NUMBER_REGEX=/^-?\d+(\.\d+)?$/;class zt{static makeColumnFormatMap(t){return t==null?new Map:t.reduce((n,s)=>{const o=N.getNormalizedType(s.columnType);if(o===null)return n;n.has(o)||n.set(o,new Map);const i=n.get(o);return i==null||i.set(s.columnName,s.format),n},new Map)}static makeColumnFormattingRule(t,n,s){return{columnType:t,columnName:n,format:s}}constructor(t=[],n,s,o,i=!1){this.defaultColumnFormatter=new Od,this.typeFormatterMap=new Map([[N.dataType.BOOLEAN,new Nd],[N.dataType.CHAR,new Ad],[N.dataType.DATETIME,new kn(n)],[N.dataType.DECIMAL,new Ve(s)],[N.dataType.INT,new It(o)],[N.dataType.STRING,new kd]]),this.columnFormatMap=zt.makeColumnFormatMap(t),this.truncateNumbersWithPound=i}getColumnFormatMapForType(t,n=!1){const s=N.getNormalizedType(t);if(s!==null)return n&&!this.columnFormatMap.has(s)&&this.columnFormatMap.set(s,new Map),this.columnFormatMap.get(s)}getColumnFormat(t,n){var o;const s=this.getColumnFormatMapForType(t);return(o=s==null?void 0:s.get(n))!=null?o:null}getColumnTypeFormatter(t){var o;const n=N.getNormalizedType(t);let s=this.defaultColumnFormatter;return n&&(s=(o=this.typeFormatterMap.get(n))!=null?o:s),s}getFormattedString(t,n,s="",o){if(t==null)return"";const i=this.getColumnTypeFormatter(n),r=o||this.getColumnFormat(n,s);return i.format(t,r!=null?r:void 0)}get timeZone(){var n;const t=this.typeFormatterMap.get(N.dataType.DATETIME);return(n=t==null?void 0:t.dhTimeZone)==null?void 0:n.id}}function Ud(e){if(e&&e.formatter){const{formatter:t}=e;return t}}function Bd(e){return{timeZone:e==null?void 0:e.timeZone,defaultDateTimeFormatString:e==null?void 0:e.defaultDateTimeFormat,showTimeZone:e==null?void 0:e.showTimeZone,showTSeparator:e==null?void 0:e.showTSeparator}}function Gd(e,t,n){const s=e.getColumnFormat(n,t);return s!=null&&(s.type===_e.TYPE_CONTEXT_PRESET||s.type===_e.TYPE_CONTEXT_CUSTOM)}const Jn={getColumnFormats:Ud,getDateTimeFormatterOptions:Bd,isCustomColumnFormatDefined:Gd};le.module("MessageUtils");function Wd(e,t){const n=qd(e);return n===void 0?void 0:`${Zd(e)} ? ${n} : ${t}`}function $d(e){return dh.Column.formatRowColor(e)}function zd(e,t){return e.formatColor(t)}const qs=le.module("ConditionalFormattingUtils");var Yt=(e=>(e.CONDITIONAL="conditional",e.ROWS="rows",e))(Yt||{}),Ae=(e=>(e.IS_EQUAL="is-equal",e.IS_NOT_EQUAL="is-not-equal",e.IS_BETWEEN="is-between",e.GREATER_THAN="greater-than",e.GREATER_THAN_OR_EQUAL="greater-than-or-equal",e.LESS_THAN="less-than",e.LESS_THAN_OR_EQUAL="less-than-or-equal",e.IS_NULL="is-null",e.IS_NOT_NULL="is-not-null",e))(Ae||{}),mt=(e=>(e.IS_EXACTLY="is-exactly",e.IS_NOT_EXACTLY="is-not-exactly",e.CONTAINS="contains",e.DOES_NOT_CONTAIN="does-not-contain",e.STARTS_WITH="starts-with",e.ENDS_WITH="ends-with",e.IS_NULL="is-null",e.IS_NOT_NULL="is-not-null",e))(mt||{}),ot=(e=>(e.IS_EXACTLY="is-exactly",e.IS_NOT_EXACTLY="is-not-exactly",e.IS_BEFORE="is-before",e.IS_BEFORE_OR_EQUAL="is-before-or-equal",e.IS_AFTER="is-after",e.IS_AFTER_OR_EQUAL="is-after-or-equal",e.IS_NULL="is-null",e.IS_NOT_NULL="is-not-null",e))(ot||{}),Bs=(e=>(e.IS_TRUE="is-true",e.IS_FALSE="is-false",e.IS_NULL="is-null",e.IS_NOT_NULL="is-not-null",e))(Bs||{}),Kn=(e=>(e.IS_EQUAL="is-equal",e.IS_NOT_EQUAL="is-not-equal",e.IS_NULL="is-null",e.IS_NOT_NULL="is-not-null",e))(Kn||{}),Ft=(e=>(e.NO_FORMATTING="no-formatting",e.POSITIVE="positive",e.NEGATIVE="negative",e.WARN="warn",e.NEUTRAL="neutral",e.ACCENT_1="accent-1",e.ACCENT_2="accent-2",e.CUSTOM="custom",e))(Ft||{});function Mr(e){switch(e){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 _o(e){const{type:t,customConfig:n}=e;switch(t){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 n==null?void 0:n.background;default:return}}function Ho(e){const{type:t,customConfig:n}=e;switch(t){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 n==null?void 0:n.color;default:return}}function qd(e){const t=Ho(e.style),n=_o(e.style);if(!(t===void 0||n===void 0))return`bgfg(\`${n}\`, \`${t}\`)`}function Yd(e){const{column:t,value:n,start:s,end:o}=e;return cu(t.name,e.condition,n,s,o)}function Xd(e){const{column:t,value:n}=e;return du(t.name,e.condition,n)}function Kd(e){const{column:t,value:n}=e;return uu(t.name,e.condition,n)}function Qd(e){const{column:t}=e;return hu(t.name,e.condition)}function jd(e){const{column:t,value:n}=e;return mu(t.name,e.condition,n)}function Zd(e){const{column:t}=e;if(N.isNumberType(t.type))return Yd(e);if(N.isCharType(t.type))return jd(e);if(N.isStringType(t.type))return Xd(e);if(N.isDateType(t.type))return Kd(e);if(N.isBooleanType(t.type))return Qd(e);throw new Error("Invalid column type")}function Jd(e){switch(e){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 eu(e){switch(e){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 tu(e){switch(e){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 nu(e){switch(e){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 su(e){switch(e){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 El(e){if(N.isNumberType(e)||N.isCharType(e))return"is-equal";if(N.isStringType(e)||N.isDateType(e))return"is-exactly";if(N.isBooleanType(e))return"is-true";throw new Error("Invalid column type")}function vl(e){if(N.isCharType(e)||N.isStringType(e))return""}function Rl(e){const{condition:t,value:n,start:s,end:o}=e;return{condition:t,value:n,start:s,end:o}}function Zo(e){return{condition:El(e),value:vl(e),start:void 0,end:void 0}}function yl(){return{type:"no-formatting"}}function ou(e){switch(e){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 iu(e){switch(e){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 ru(e){switch(e){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 lu(e){switch(e){case"is-equal":return"==";case"is-not-equal":return"!=";case"is-null":return"is null";case"is-not-null":return"is not null"}}function au(e){switch(e){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 cu(e,t,n,s,o){switch(t){case"is-equal":return`${e} == ${n}`;case"is-not-equal":return`${e} != ${n}`;case"is-between":return`${e} > ${s} && ${e} < ${o}`;case"greater-than":return`${e} > ${n}`;case"greater-than-or-equal":return`${e} >= ${n}`;case"less-than":return`${e} < ${n}`;case"less-than-or-equal":return`${e} <= ${n}`;case"is-null":return`${e} == null`;case"is-not-null":return`${e} != null`}}function du(e,t,n){switch(t){case"is-exactly":return`${e} == "${n}"`;case"is-not-exactly":return`${e} != "${n}"`;case"contains":return`${e} != null && ${e}.contains("${n}")`;case"does-not-contain":return`${e} != null && !${e}.contains("${n}")`;case"starts-with":return`${e} != null && ${e}.startsWith("${n}")`;case"ends-with":return`${e} != null && ${e}.endsWith("${n}")`;case"is-null":return`${e} == null`;case"is-not-null":return`${e} != null`}}function uu(e,t,n){switch(t){case"is-exactly":return`${e} == convertDateTime("${n}")`;case"is-not-exactly":return`${e} != convertDateTime(\`${n}\`)`;case"is-before":return`${e} < convertDateTime(\`${n}\`)`;case"is-before-or-equal":return`${e} <= convertDateTime("${n}")`;case"is-after":return`${e} > convertDateTime(\`${n}\`)`;case"is-after-or-equal":return`${e} >= convertDateTime(\`${n}\`)`;case"is-null":return`${e} == null`;case"is-not-null":return`${e} != null`}}function hu(e,t){switch(t){case"is-true":return`${e} == true`;case"is-false":return`${e} == false`;case"is-null":return`${e} == null`;case"is-not-null":return`${e} != null`}}function mu(e,t,n){switch(t){case"is-equal":return`${e} == '${n}'`;case"is-not-equal":return`${e} != '${n}'`;case"is-null":return`isNull(${e})`;case"is-not-null":return`!isNull(${e})`}}function gu(e,t){if(N.isNumberType(e))return au(t);if(N.isCharType(e))return lu(t);if(N.isStringType(e))return ou(t);if(N.isDateType(e))return iu(t);if(N.isBooleanType(e))return ru(t);throw new Error("Invalid column type")}function pu(e,t){if(t===void 0)return qs.debug("no rules passed."),[];const n=[];let s;const o=new Map;return t.forEach(({config:i,type:r})=>{var p;const{column:l}=i,a=e.find(({name:f,type:C})=>f===l.name&&C===l.type);if(a===void 0){qs.debug(`Column ${l.name}:${l.type} not found. Ignoring format rule.`,i);return}const[c,d]=(p=r==="conditional"?o.get(a.name):s)!=null?p:["null",void 0],u=Wd(i,c);if(u===void 0){qs.debug("Ignoring format rule.",i);return}const h=d===void 0?-1:n.indexOf(d);h>-1&&n.splice(h,1);const g=r==="conditional"?zd(a,u):$d(u);n.push(g),r==="conditional"?o.set(a.name,[u,g]):s=[u,g]}),n}function fu(e,t){switch(e){case"is-null":case"is-not-null":return!0;default:{const[n,...s]=(t!=null?t:"").split(" "),o=s.join(" ");try{qt.parseDateTimeString(n)}catch{return qs.debug("Invalid datetime string",n),!1}try{dh.i18n.TimeZone.getTimeZone(o)}catch{return qs.debug("Invalid timezone string",o),!1}return!0}}}function Cu({type:e}){return N.isNumberType(e)||N.isCharType(e)||N.isStringType(e)||N.isDateType(e)||N.isBooleanType(e)}function Jo({animation:e="iris-grid-bottom-bar-slide-up",children:t,className:n,isShown:s,onClick:o,onEntering:i,onEntered:r,onExiting:l,onExited:a}){return m($t,{in:s,timeout:We.transitionMs,classNames:e,onEntering:i,onEntered:r,onExiting:l,onExited:a,mountOnEnter:!0,unmountOnExit:!0,children:m("div",{className:Z("iris-grid-bottom-bar",n),role:"presentation",onClick:o,onKeyPress:o,children:t})})}const wu=3e3,Su=5;function Tu({isSaving:e=!1,onSave:t,onDiscard:n,discardTooltip:s,saveTooltip:o,error:i,pendingDataErrors:r,pendingDataMap:l,onEntering:a,onEntered:c,onExiting:d,onExited:u}){const[h,g]=F.exports.useState(!1),[p,f]=F.exports.useState(!1),C=F.exports.useRef(),w=$i(e),S=F.exports.useMemo(()=>r.size===0?i:r.size<=Su?`Key can't be empty (on pending row${r.size>1?"s":""} ${Array.from(r.keys()).join(", ").trim()})`:`Key can't be empty (on ${r.size} rows)`,[i,r]);F.exports.useEffect(function(){w!=null&&w&&!e&&S==null&&(g(!0),f(!0),C.current=setTimeout(()=>{g(!1)},wu))},[S,e,w]),F.exports.useEffect(function(){C.current&&l.size>0&&(clearTimeout(C.current),g(!1),f(!1))},[l]),F.exports.useEffect(function(){return()=>C.current?clearTimeout(C.current):void 0},[]);const b=l.size;let v;return e?v=m(dn,{}):p&&(v=rl),y(Jo,{className:"pending-data-bottom-bar",isShown:b>0||h||S!=null,onEntering:a,onEntered:c,onExiting:d,onExited:()=>{f(!1),u&&u()},children:[S!=null&&S!==""&&y("div",{className:"error-message",children:[m(J,{icon:Qn}),m("span",{children:`${S}`})]}),(S==null||S==="")&&m("div",{className:"status-message",children:b>0&&m("span",{children:`${b} row${b>1?"s":""} pending`})}),y("div",{className:"buttons-container",children:[!e&&!p&&m(z,{kind:"secondary",onClick:n,tooltip:s,children:"Discard"}),y(z,{kind:p?"success":"primary",onClick:t,icon:v,disabled:e||p||S!=null,tooltip:o,children:[e&&"Committing...",!e&&p&&"Success",!e&&!p&&"Commit"]})]})]})}var be=(e=>(e.COUNT="Count",e.MIN="Min",e.MAX="Max",e.SUM="Sum",e.ABS_SUM="AbsSum",e.VAR="Var",e.AVG="Avg",e.STD="Std",e.FIRST="First",e.LAST="Last",e.SKIP="Skip",e.COUNT_DISTINCT="CountDistinct",e.DISTINCT="Distinct",e.UNIQUE="Unique",e))(be||{});const bu=e=>{switch(e){default:return!1}},Eu=(e,t)=>{switch(e){case be.COUNT:case be.FIRST:case be.LAST:case be.COUNT_DISTINCT:case be.DISTINCT:case be.UNIQUE:return!0;case be.MIN:case be.MAX:return N.isNumberType(t)||N.isDateType(t)||N.isTextType(t);case be.SUM:case be.ABS_SUM:case be.VAR:case be.AVG:case be.STD:return N.isNumberType(t);case be.SKIP:return!1}},Qi=(e,t)=>e.filter(n=>Eu(t,n.type)),vu=(e,t,n,s)=>Qi(e,t).map(({name:o})=>o).filter(o=>n.includes(o)?!s:s),On={isRollupOperation:bu,filterValidColumns:Qi,getOperationColumnNames:vu};var ns=(e=>(e.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS="filter-control-change-clears-all-filters",e.LINK_CHANGE_CLEARS_ALL_FILTERS="link-change-clears-all-filters",e))(ns||{});const Ru=Object.freeze([[ns.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS,!1],[ns.LINK_CHANGE_CLEARS_ALL_FILTERS,!1]]),yu={DEFAULTS:Ru},Fu=le.module("ColumnHeaderGroup");function gi(e){return e instanceof Bt}const Fl=class{constructor({name:e,children:t,color:n,depth:s,childIndexes:o,parent:i}){this.getVisibleRange=Fe(r=>{const l=this.childIndexes.flat(),a=_.getVisibleIndexes(l,r),c=Math.min(...a),d=Math.max(...a);return d-c!==l.length-1&&Fu.warn(`Column header group ${this.name} is not contiguous`),[c,d]}),this.name=e,this.children=t,this.color=n,this.depth=s,this.childIndexes=o,this.parent=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(Fl.NEW_GROUP_PREFIX)}};let Bt=Fl;Bt.NEW_GROUP_PREFIX=":newGroup";const Ls=le.module("IrisGridUtils");function Tn(e,t){return e>=0&&e<t.length}function Du(e){return e.asDate!=null}class Q{static dehydrateGridState(t,n){const{isStuckToBottom:s,isStuckToRight:o,movedColumns:i,movedRows:r}=n,{columns:l}=t;return{isStuckToBottom:s,isStuckToRight:o,movedColumns:[...i].filter(({to:a,from:c})=>Tn(a,l)&&(typeof c=="number"&&Tn(c,l)||Array.isArray(c)&&Tn(c[0],l)&&Tn(c[1],l))).map(({to:a,from:c})=>({to:l[a].name,from:Array.isArray(c)?[l[c[0]].name,l[c[1]].name]:l[c].name})),movedRows:[...r]}}static hydrateGridState(t,n,s=[]){const{isStuckToBottom:o,isStuckToRight:i,movedColumns:r,movedRows:l}=n,{columns:a}=t,c=Q.parseCustomColumnNames(s),d=a.map(({name:u})=>u).concat(c);return{isStuckToBottom:o,isStuckToRight:i,movedColumns:[...r].map(({to:u,from:h})=>{const g=p=>typeof p=="string"?d.findIndex(f=>f===p):p;return{to:g(u),from:Array.isArray(h)?[g(h[0]),g(h[1])]:g(h)}}).filter(({to:u,from:h})=>Tn(u,d)&&(typeof h=="number"&&Tn(h,d)||Array.isArray(h)&&Tn(h[0],d)&&Tn(h[1],d))),movedRows:[...l]}}static dehydrateIrisGridState(t,n){const{aggregationSettings:s={aggregations:ye,showOnTop:!1},advancedFilters:o,customColumnFormatMap:i,isFilterBarShown:r,metrics:l,quickFilters:a,customColumns:c,conditionalFormats:d=ye,reverseType:u,rollupConfig:h=void 0,showSearchBar:g,searchValue:p,selectDistinctColumns:f=ye,selectedSearchColumns:C,sorts:w,invertSearchColumns:S,pendingDataMap:b=rn,frozenColumns:v,columnHeaderGroups:T}=n;M(l);const{userColumnWidths:R,userRowHeights:D}=l,{columns:A}=t;return{advancedFilters:Q.dehydrateAdvancedFilters(A,o),aggregationSettings:s,customColumnFormatMap:[...i],isFilterBarShown:r,quickFilters:Q.dehydrateQuickFilters(a),sorts:Q.dehydrateSort(w),userColumnWidths:[...R].filter(([I])=>I!=null&&I>=0&&I<A.length).map(([I,L])=>[A[I].name,L]),userRowHeights:[...D],customColumns:[...c],conditionalFormats:[...d],reverseType:u,rollupConfig:h,showSearchBar:g,searchValue:p,selectDistinctColumns:[...f],selectedSearchColumns:C,invertSearchColumns:S,pendingDataMap:Q.dehydratePendingDataMap(A,b),frozenColumns:v,columnHeaderGroups:T==null?void 0:T.map(I=>({name:I.name,children:I.children,color:I.color}))}}static hydrateIrisGridState(t,n){var I,L;const{advancedFilters:s,aggregationSettings:o={aggregations:[],showOnTop:!1},customColumnFormatMap:i,isFilterBarShown:r,quickFilters:l,sorts:a,customColumns:c,conditionalFormats:d,userColumnWidths:u,userRowHeights:h,reverseType:g,rollupConfig:p=void 0,showSearchBar:f,searchValue:C,selectDistinctColumns:w,selectedSearchColumns:S,invertSearchColumns:b=!0,pendingDataMap:v=[],frozenColumns:T,columnHeaderGroups:R}=n,{columns:D,formatter:A}=t;return{advancedFilters:Q.hydrateAdvancedFilters(D,s,A.timeZone),aggregationSettings:o,customColumnFormatMap:new Map(i),isFilterBarShown:r,quickFilters:Q.hydrateQuickFilters(D,l,A.timeZone),sorts:Q.hydrateSort(D,a),userColumnWidths:new Map(u.map(([k,x])=>typeof k=="string"||k instanceof String?[D.findIndex(({name:W})=>W===k),x]:[k,x]).filter(([k])=>k!=null&&k>=0&&k<D.length)),customColumns:c,conditionalFormats:d,userRowHeights:new Map(h),reverseType:g,rollupConfig:p,showSearchBar:f,searchValue:C,selectDistinctColumns:w,selectedSearchColumns:S,invertSearchColumns:b,pendingDataMap:Q.hydratePendingDataMap(D,v),frozenColumns:T,columnHeaderGroups:Q.parseColumnHeaderGroups(t,(L=R!=null?R:(I=t.layoutHints)==null?void 0:I.columnGroups)!=null?L:[]).groups}}static dehydrateIrisGridPanelState(t,n){const{isSelectingPartition:s,partition:o,partitionColumn:i,advancedSettings:r}=n;return{isSelectingPartition:s,partition:o,partitionColumn:i!=null?i.name:void 0,advancedSettings:[...r]}}static hydrateIrisGridPanelState(t,n){const{isSelectingPartition:s,partition:o,partitionColumn:i,advancedSettings:r}=n,{columns:l}=t;return{isSelectingPartition:s,partition:o,partitionColumn:i!=null?Q.getColumnByName(l,i):void 0,advancedSettings:new Map([...yu.DEFAULTS,...r])}}static dehydrateQuickFilters(t){return[...t].map(([n,s])=>{const{text:o}=s;return[n,{text:o}]})}static hydrateQuickFilters(t,n,s){const o=n.map(([i,r])=>{const{text:l}=r;let a=null;try{const c=Q.getColumn(t,i);c!=null&&(a=N.makeQuickFilter(c,l,s))}catch(c){Ls.error("hydrateQuickFilters error with",l,c)}return[i,{text:l,filter:a}]});return new Map(o)}static dehydrateAdvancedFilters(t,n){return[...n].map(([s,o])=>{const i=Q.getColumn(t,s);M(i);const r=Q.dehydrateAdvancedFilterOptions(i,o.options);return[s,{options:r}]})}static hydrateAdvancedFilters(t,n,s){const o=n.map(([i,r])=>{const l=Q.getColumn(t,i);M(l);const a=Q.hydrateAdvancedFilterOptions(l,r.options);let c=null;try{Q.getColumn(t,i)!=null&&(c=N.makeAdvancedFilter(l,a,s))}catch(d){Ls.error("hydrateAdvancedFilters error with",a,d)}return[i,{options:a,filter:c}]});return new Map(o)}static dehydrateAdvancedFilterOptions(t,n){const{selectedValues:s,...o}=n;return{selectedValues:s==null?void 0:s.map(i=>Q.dehydrateValue(i,t==null?void 0:t.type)),...o}}static hydrateAdvancedFilterOptions(t,n){const{selectedValues:s,...o}=n;return{selectedValues:s==null?void 0:s.map(i=>Q.hydrateValue(i,t==null?void 0:t.type)),...o}}static dehydratePendingDataMap(t,n){return[...n].map(([s,{data:o}])=>[s,{data:[...o].map(([i,r])=>[t[i].name,Q.dehydrateValue(r,t[i].type)])}])}static hydratePendingDataMap(t,n){const s=new Map,o=i=>(s.has(i)||s.set(i,t.findIndex(({name:r})=>r===i)),s.get(i));return new Map(n.map(([i,{data:r}])=>[i,{data:new Map(r.map(([l,a])=>{var d;const c=o(l);return M(c),[(d=o(l))!=null?d:null,Q.hydrateValue(a,t[c].type)]}))}]))}static dehydrateValue(t,n){return N.isDateType(n)?Q.dehydrateDateTime(t):N.isLongType(n)?Q.dehydrateLong(t):t}static hydrateValue(t,n){return N.isDateType(n)?Q.hydrateDateTime(t):N.isLongType(n)?Q.hydrateLong(t):t}static dehydrateDateTime(t){return t!=null?E.i18n.DateTimeFormat.format(qt.FULL_DATE_FORMAT,t):null}static hydrateDateTime(t){return t!=null?E.i18n.DateTimeFormat.parse(qt.FULL_DATE_FORMAT,t):null}static dehydrateLong(t){return t!=null?`${t}`:null}static hydrateLong(t){return t!=null?E.LongWrapper.ofString(t):null}static dehydrateSort(t){return t.map(n=>{const{column:s,isAbs:o,direction:i}=n;return{column:s.index,isAbs:o,direction:i}})}static hydrateSort(t,n){return n.map(s=>{const{column:o,isAbs:i,direction:r}=s;if(r===N.sortDirection.reverse)return E.Table.reverse();const l=Q.getColumn(t,o);if(l!=null){let a=l.sort();return i&&(a=a.abs()),r===N.sortDirection.descending?a=a.desc():a=a.asc(),a}return null}).filter(s=>s!=null&&s.direction!==N.sortDirection.reverse)}static extractTableSettings(t,n=[]){const{irisGridPanelState:s,irisGridState:o}=t,{partitionColumn:i,partition:r}=s,{advancedFilters:l,quickFilters:a,sorts:c}=o;return{advancedFilters:l,inputFilters:n,partition:r,partitionColumn:i,quickFilters:a,sorts:c}}static applyTableSettings(t,n,s){const{columns:o}=t;let i=[];n.quickFilters&&(i=Q.getFiltersFromFilterMap(Q.hydrateQuickFilters(o,n.quickFilters,s)));let r=[];n.advancedFilters&&(r=Q.getFiltersFromFilterMap(Q.hydrateAdvancedFilters(o,n.advancedFilters,s)));const l=Q.getFiltersFromInputFilters(o,n.inputFilters,s);let a=[];n.sorts&&(a=Q.hydrateSort(o,n.sorts));let c=[...i,...r];const{partition:d,partitionColumn:u}=n;if(d!=null&&u!=null){const h=Q.getColumnByName(o,u);h&&(c=[h.filter().eq(E.FilterValue.ofString(d)),...c])}c=[...l,...c],t.applyFilter(c),t.applySort(a)}static getInputFiltersForColumns(t,n=[]){return n.filter(({name:s,type:o})=>t.find(({name:i,type:r})=>i===s&&r===o))}static getFiltersFromInputFilters(t,n=[],s){return n.map(({name:o,type:i,value:r})=>{const l=t.find(({name:a,type:c})=>a===o&&c===i);if(l)try{return N.makeQuickFilter(l,r,s)}catch(a){Ls.debug("Unable to create input filter",a)}return null}).filter(o=>o!=null)}static getFiltersFromFilterMap(t){const n=[],s=Array.from(t.keys());for(let o=0;o<s.length;o+=1){const i=s[o],r=t.get(i);(r==null?void 0:r.filter)!=null&&n.push(r.filter)}return n}static getHiddenColumns(t){return[...t.entries()].filter(([,n])=>n===0).map(([n])=>n)}static parseCustomColumnNames(t){return t.map(n=>n.split("=")[0])}static getRemovedCustomColumnNames(t,n){const s=Q.parseCustomColumnNames(t),o=Q.parseCustomColumnNames(n);return s.filter(i=>!o.includes(i))}static removeSortsInColumns(t,n){return t.filter(s=>!n.includes(s.column.name))}static removeFiltersInColumns(t,n,s){const o=t.map(({name:r})=>r),i=new Map(n);return s.forEach(r=>i.delete(o.indexOf(r))),i}static removeColumnFromMovedColumns(t,n,s){const o=t.map(({name:r})=>r);let i=[...n];for(let r=0;r<s.length;r+=1){const l=s[r];let a=o.findIndex(d=>d===l);const c=[];for(let d=0;d<i.length;d+=1){const u=i[d],h={...u};let[g,p]=Array.isArray(u.from)?u.from:[u.from,u.from];a<=u.to&&(h.to-=1),a<g&&(g-=1),a<=p&&(p-=1),g<=p&&g!==h.to&&(g===p?c.push({...h,from:g}):c.push({...h,from:[g,p]})),a=_.applyItemMoves(a,a,[u])[0][0]}i=c,o.splice(o.findIndex(d=>d===l),1)}return i}static removeColumnsFromSelectDistinctColumns(t,n){return t.filter(s=>!n.includes(s))}static getVisibleColumnsInRange(t,n,s,o,i){const r=[];for(let l=n;l<=s;l+=1){const a=_.getModelIndex(l,o);a>=0&&a<t.length&&!i.includes(a)&&r.push(t[a])}return r}static getPrevVisibleColumns(t,n,s,o,i){const r=[];let l=n;for(;l>=0&&r.length<s;){const a=_.getModelIndex(l,o);a>=0&&a<t.length&&!i.includes(a)&&r.unshift(t[a]),l-=1}return r}static getNextVisibleColumns(t,n,s,o,i){const r=[];let l=n;for(;l<t.length&&r.length<s;){const a=_.getModelIndex(l,o);a>=0&&a<t.length&&!i.includes(a)&&r.push(t[a]),l+=1}return r}static getColumnsToFetch(t,n,s){const o=[...n];return s.forEach(i=>{const r=t.find(({name:l})=>l===i);r!=null&&!n.includes(r)&&o.push(r)}),o}static getModelViewportColumns(t,n,s,o,i=[],r=[],l=0){if(n==null||s==null)return null;const a=Q.getVisibleColumnsInRange(t,n,s,o,i),c=a.length*l,d=Q.getPrevVisibleColumns(t,n-1,c,o,i),u=Q.getNextVisibleColumns(t,s+1,c,o,i),h=[...d,...a,...u];return Q.getColumnsToFetch(t,h,r)}static rangeSetFromRanges(t){const n=t.slice().sort((s,o)=>(M(s.startRow),M(o.startRow),s.startRow-o.startRow)).map(s=>{const{startRow:o,endRow:i}=s;return M(o),M(i),E.RangeSet.ofRange(o,i)});return E.RangeSet.ofRanges(n)}static isValidSnapshotRanges(t){if(t==null||t.length===0)return!1;const n=new Map;for(let i=0;i<t.length;i+=1){const r=t[i],l=`${r.startRow}:${r.endRow}`,a=`${r.startColumn}:${r.endColumn}`;n.has(l)||n.set(l,[]),n.get(l).push(a)}const s=[...n.keys()],o=n.get(s[0]).sort().join(",");for(let i=1;i<s.length;i+=1)if(n.get(s[i]).sort().join(",")!==o)return!1;return!0}static isValidIndex(t){return!Number.isInteger(t)||typeof t!="number"?!1:t>=0}static columnsFromRanges(t,n){var o,i;if(t==null||t.length===0)return[];if(t[0].startColumn===null&&t[0].endColumn===null)return[...n];const s=new Set;for(let r=0;r<t.length;r+=1){const l=t[r];M(l.startColumn),M(l.endColumn);for(let a=(o=l.startColumn)!=null?o:0;a<=((i=l.endColumn)!=null?i:n.length-1);a+=1)s.add(a)}return[...s].map(r=>n[r])}static snapshotDataToMatrix(t){const{columns:n,rows:s}=t,o=[];for(let i=0;i<s.length;i+=1){const r=s[i],l=[];for(let a=0;a<n.length;a+=1){const c=n[a],d=r.get(c);l.push(d)}o.push(l)}return o}static getModelRollupConfig(t,n,s){var u,h,g;if(((h=(u=n==null?void 0:n.columns)==null?void 0:u.length)!=null?h:0)===0)return null;const{columns:o=[],showConstituents:i=!0,showNonAggregatedColumns:r=!0,includeDescriptions:l=!0}=n!=null?n:{},{aggregations:a=[]}=s!=null?s:{},c=a.map(({operation:p,selected:f,invert:C})=>On.isRollupOperation(p)?[]:On.getOperationColumnNames(t,p,f,C)),d={};for(let p=0;p<a.length;p+=1)d[a[p].operation]=c[p];if(r){const p=new Set(t.map(f=>f.name).filter(f=>!o.includes(f)));if(c.forEach(f=>{f.forEach(C=>p.delete(C))}),p.size>0){const f=(g=d[be.FIRST])!=null?g:[];d[be.FIRST]=[...f,...p]}}return{groupingColumns:o,includeConstituents:i,includeDescriptions:l,aggregations:d}}static getPendingErrors(t){t.forEach((n,s)=>{if(!Q.isValidIndex(s))throw new Error(`Invalid rowIndex ${s}`);const{data:o}=n;o.forEach((i,r)=>{if(!Q.isValidIndex(r))throw new Error(`Invalid columnIndex ${r}`)})})}static getColumn(t,n){return n<t.length?t[n]:(Ls.error("Unable to retrieve column",n,">=",t.length),null)}static getColumnByName(t,n){const s=t.find(({name:o})=>o===n);return s==null&&Ls.error("Unable to retrieve column by name",n,t.map(({name:o})=>o)),s}static changeFilterColumnNamesToIndexes(t,n){return n.map(({name:s,filter:o})=>{const i=t.findIndex(r=>r.name===s);return i<0?null:[i,o]}).filter(s=>s!=null)}static combineFiltersFromList(t,n){n.sort((o,i)=>o.operator==="eq"&&i.operator!=="eq"?1:o.operator!=="eq"&&i.operator==="eq"?-1:o.startColumnIndex-i.startColumnIndex);let s="";for(let o=0;o<n.length;o+=1){const{text:i,value:r,operator:l}=n[o];if(r!==void 0){let a="";l!==void 0&&(r==null&&l==="eq"?a="=":l!=="eq"&&(l==="startsWith"||l==="endsWith"?a="*":a=N.getFilterOperatorString(l)));let c=`${a}${i}`;l==="startsWith"&&(c=`${i}${a}`),t!=null&&r!==null&&N.isCharType(t)&&(c=`${a}${String.fromCharCode(parseInt(i,10))}`),o!==0&&(s+=l==="eq"?" || ":" && "),s+=c}}return s}static parseColumnHeaderGroups(t,n){let s=1;const o=new Map,i=new Map,r=n==null?void 0:n.filter(({children:u})=>u.length>0);if(r.length===0)return{groups:[],maxDepth:s,parentMap:o,groupMap:i};const l=new Map(r.map(u=>[u.name,u])),a=new Set,c=u=>{const{name:h}=u;if(t.getColumnIndexByName(h)!=null)throw new Error(`Column header group has same name as column: ${h}`);const g=i.get(h);if(g)return g;const p=[];let f=1;u.children.forEach(w=>{if(a.has(w))throw new Error(`Column group child ${w} specified in multiple groups`);a.add(w);const S=l.get(w),b=t.getColumnIndexByName(w);if(S){const v=c(S);p.push(...v.childIndexes),f=Math.max(f,v.depth+1)}else if(b!=null)p.push(b),f=Math.max(f,1);else throw new Error(`Unknown child ${w} in group ${h}`)});const C=new Bt({...u,depth:f,childIndexes:p.flat()});return i.set(h,C),u.children.forEach(w=>o.set(w,C)),s=Math.max(s,C.depth+1),C},d=new Set;return r.forEach(u=>{const{name:h}=u;if(d.has(h))throw new Error(`Duplicate column group name: ${h}`);d.add(h),c(u)}),i.forEach(u=>{var h;u.setParent((h=o.get(u.name))==null?void 0:h.name)}),{groups:[...i.values()],maxDepth:s,groupMap:i,parentMap:o}}static convertValueToText(t,n){if(n!=null&&N.isCharType(n)&&t!=null&&typeof t=="number")return String.fromCharCode(t);if(N.isDateType(n)&&Du(t)){const s=new Date(t.asDate()),o=s.getTimezoneOffset();return new Date(s.getTime()-o*60*1e3).toISOString().replace("T"," ").substring(0,23)}return t==null?"":`${t}`}}const ht=le.module("IrisGridCopyHandler"),Re=class extends F.exports.Component{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:Re.COPY_STATES.IDLE,buttonState:Re.BUTTON_STATES.COPY,isShown:!1,rowCount:0}}static getStatusMessageText(e,t){switch(e){case Re.COPY_STATES.CONFIRMATION_REQUIRED:return`Are you sure you want to copy ${t.toLocaleString()} rows to your clipboard?`;case Re.COPY_STATES.CLICK_REQUIRED:return`Fetched ${t.toLocaleString()} rows!`;case Re.COPY_STATES.FETCH_ERROR:return"Unable to copy data.";case Re.COPY_STATES.FETCH_IN_PROGRESS:return`Fetching ${t.toLocaleString()} rows for clipboard...`;case Re.COPY_STATES.DONE:return"Copied to Clipboard!";default:return""}}static getCopyButtonText(e){switch(e){case Re.BUTTON_STATES.FETCH_IN_PROGRESS:return"Fetching";case Re.BUTTON_STATES.CLICK_TO_COPY:return"Click to Copy";case Re.BUTTON_STATES.RETRY:return"Retry";default:return"Copy"}}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()}startCopy(){ht.debug2("startCopy"),this.stopCopy();const{copyOperation:e}=this.props;if(e==null){ht.debug2("No copy operation set, cancelling out"),this.setState({isShown:!1});return}const{ranges:t,error:n}=e;if(n!=null){ht.debug("Showing copy error",n),this.setState({isShown:!0,copyState:Re.COPY_STATES.DONE,error:n}),this.startHideTimer();return}const s=K.rowCount(t);this.setState({rowCount:s,isShown:!0,error:void 0}),s>Re.NO_PROMPT_THRESHOLD?this.setState({buttonState:Re.BUTTON_STATES.COPY,copyState:Re.COPY_STATES.CONFIRMATION_REQUIRED}):this.startFetch()}stopCopy(){this.textData=void 0,this.stopFetch(),this.stopHideTimer()}handleBackgroundClick(){ht.debug2("handleBackgroundClick");const{copyState:e}=this.state;e===Re.COPY_STATES.DONE&&this.setState({isShown:!1})}handleCancelClick(){ht.debug2("handleCancelClick"),this.stopFetch(),this.setState({isShown:!1})}handleCopyClick(){ht.debug2("handleCopyClick"),this.textData!=null?this.copyText(this.textData):this.startFetch()}handleHideTimeout(){ht.debug2("handleHideTimeout"),this.stopHideTimer(),this.setState({isShown:!1})}copyText(e){ht.debug2("copyText",e),this.textData=e,qo(e).then(()=>{this.setState({copyState:Re.COPY_STATES.DONE}),this.startHideTimer()},t=>{ht.error("copyText error",t),this.setState({buttonState:Re.BUTTON_STATES.CLICK_TO_COPY,copyState:Re.COPY_STATES.CLICK_REQUIRED})})}startFetch(){this.stopFetch(),this.setState({buttonState:Re.BUTTON_STATES.FETCH_IN_PROGRESS,copyState:Re.COPY_STATES.FETCH_IN_PROGRESS});const{model:e,copyOperation:t}=this.props,{ranges:n,includeHeaders:s,userColumnWidths:o,movedColumns:i,formatValues:r}=t;ht.debug("startFetch",n);const l=Q.getHiddenColumns(o);let a=_.getModelRanges(n,i);if(l.length>0){const d=l.map(K.makeColumn);a=K.subtractRangesFromRanges(a,d)}const c=r!=null&&r?(d,u)=>e.displayString(d,u.type,u.name):d=>`${d}`;this.fetchPromise=ze.makeCancelable(e.textSnapshot(a,s,c)),this.fetchPromise.then(d=>{this.fetchPromise=void 0,this.copyText(d)}).catch(d=>{d instanceof xi?ht.debug("User cancelled copy."):(ht.error("Error fetching contents",d),this.fetchPromise=void 0,this.setState({buttonState:Re.BUTTON_STATES.RETRY,copyState:Re.COPY_STATES.FETCH_ERROR}))})}stopFetch(){this.fetchPromise&&(ht.debug2("stopFetch"),this.fetchPromise.cancel(),this.fetchPromise=void 0)}startHideTimer(){this.stopHideTimer(),this.hideTimer=setTimeout(this.handleHideTimeout,Re.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:o,copyState:i,isShown:r,rowCount:l,error:a}=this.state,c=i===Re.COPY_STATES.DONE?"fade":"copy-slide-up",d=Re.getCopyButtonText(o),u=a!=null?a:Re.getStatusMessageText(i,l),h=i!==Re.COPY_STATES.DONE,g=o===Re.BUTTON_STATES.FETCH_IN_PROGRESS,p=i===Re.COPY_STATES.DONE;return y(Jo,{animation:c,isShown:r,className:Z("iris-grid-copy-handler",{"copy-done":p}),onClick:this.handleBackgroundClick,onEntering:e,onEntered:t,onExiting:n,onExited:s,children:[m("div",{className:"status-message",children:m("span",{children:u})}),m($t,{in:h,timeout:We.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:y("div",{className:"buttons-container",children:[m("button",{type:"button",className:"btn btn-outline-secondary btn-cancel",onClick:this.handleCancelClick,children:"Cancel"}),y(z,{kind:g?"tertiary":"primary",className:Z("btn-copy",{"btn-spinner":g}),onClick:this.handleCopyClick,disabled:g,children:[g&&m(dn,{}),d]})]})})]})}};let ys=Re;ys.NO_PROMPT_THRESHOLD=1e4;ys.HIDE_TIMEOUT=3e3;ys.COPY_STATES={IDLE:"IDLE",CONFIRMATION_REQUIRED:"CONFIRMATION_REQUIRED",FETCH_IN_PROGRESS:"FETCH_IN_PROGRESS",FETCH_ERROR:"FETCH_ERROR",CLICK_REQUIRED:"CLICK_REQUIRED",DONE:"DONE"};ys.BUTTON_STATES={COPY:"COPY",FETCH_IN_PROGRESS:"FETCH_IN_PROGRESS",CLICK_TO_COPY:"CLICK_TO_COPY",RETRY:"RETRY"};ys.defaultProps={copyOperation:null,onEntering:()=>{},onEntered:()=>{},onExiting:()=>{},onExited:()=>{}};class Dl extends F.exports.PureComponent{constructor(t){super(t);const{debounceMs:n}=t;this.debouncedSendUpdate=vt(this.sendUpdate.bind(this),n),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:s}=t;this.initialValue=s,this.state={isChanged:!1,value:s}}componentDidMount(){var t;(t=this.inputField)==null||t.focus()}componentDidUpdate(t){const{debounceMs:n}=this.props;t.debounceMs!==n&&(this.debouncedSendUpdate.flush(),this.debouncedSendUpdate=vt(this.sendUpdate.bind(this),n))}componentWillUnmount(){this.debouncedSendUpdate.cancel()}setValue(t){this.initialValue=t,this.setState({value:t})}focus(){var t;(t=this.inputField)==null||t.focus()}handleChange(t){const{value:n}=t.target;this.setState({value:n,isChanged:!0}),this.debouncedSendUpdate(n)}handleCancel(){this.debouncedSendUpdate.cancel();const{initialValue:t}=this,{isChanged:n}=this.state;n&&this.sendUpdate(t);const{onDone:s}=this.props;s()}handleCommit(t=!0,n=!0){this.debouncedSendUpdate.flush();const{onDone:s}=this.props;s(t,n)}handleFocus(){var t;(t=this.inputField)==null||t.select()}handleBlur(t){const{relatedTarget:n}=t;n!=null&&n.classList.contains("context-menu-container")?this.handleCommit(!1,!0):n!=null&&n.classList.contains("advanced-filter-button")?this.handleCommit(!1,!1):this.handleCommit(!0,!0)}handleTab(t=!1){this.debouncedSendUpdate.flush();const{onTab:n}=this.props;n(t)}handleKeyDown(t){switch(t.key){case"Escape":t.stopPropagation(),t.preventDefault(),this.handleCancel();break;case"Enter":t.stopPropagation(),t.preventDefault(),this.handleCommit();break;case"Tab":t.stopPropagation(),t.preventDefault(),this.handleTab(t.shiftKey);break}}handleContextMenu(t){const{onContextMenu:n}=this.props;n(t)}sendUpdate(t){const{onChange:n}=this.props;n(t)}render(){const{className:t,style:n,isAdvancedFilterSet:s,onAdvancedFiltersTriggered:o}=this.props,{value:i}=this.state;return y("div",{style:n,className:"iris-grid-input-autosized-wrapper","data-value":i,children:[m("input",{ref:r=>{this.inputField=r},className:Z("iris-grid-input-field",t),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"}),m("div",{className:"advanced-filter-button-container",children:m(z,{kind:"ghost",className:Z("btn-link-icon advanced-filter-button",{"filter-set":s}),onClick:o,onContextMenu:this.handleContextMenu,children:y("div",{className:"fa-layers ",children:[m(J,{icon:ki,className:"filter-solid"}),m(J,{icon:xo,className:"filter-light"})]})})})]})}}Dl.defaultProps={style:{},className:"",value:"",isAdvancedFilterSet:!1,onAdvancedFiltersTriggered:()=>{},onChange:()=>{},onDone:()=>{},onTab:()=>{},onContextMenu:()=>{},debounceMs:150};class Iu extends ss{constructor(t){super(),this.irisGrid=t}onDown(t){const{selectedRanges:n}=this.irisGrid.state;return t.key==="c"&&_n.isModifierKeyDown(t)?(Q.isValidSnapshotRanges(n)?this.irisGrid.copyRanges(n):this.irisGrid.copyRanges(n,!1,!1,"Invalid copy ranges"),!0):!1}}const Nu={TOGGLE_QUICK_FILTER:Be.createAndAdd({id:"TABLE.TOGGLE_QUICK_FILTER",name:"Toggle Quick Filter",shortcut:[ce.CTRL,fe.F],macShortcut:[ce.CMD,fe.F]}),CLEAR_ALL_FILTERS:Be.createAndAdd({id:"TABLE.CLEAR_ALL_FILTERS",name:"Clear All Table Filters",shortcut:[ce.CTRL,fe.E],macShortcut:[ce.CMD,fe.E]}),CLEAR_FILTERS:Be.createAndAdd({id:"TABLE.CLEAR_FILTERS",name:"Clear Active Table Filters",shortcut:[ce.CTRL,ce.SHIFT,fe.E],macShortcut:[ce.CMD,ce.SHIFT,fe.E]}),REVERSE:Be.createAndAdd({id:"TABLE.REVERSE",name:"Reverse",shortcut:[ce.CTRL,fe.I],macShortcut:[ce.CMD,fe.I]}),TOGGLE_SEARCH:Be.createAndAdd({id:"TABLE.TOGGLE_SEARCH",name:"Toggle Search",shortcut:[ce.CTRL,ce.SHIFT,fe.F],macShortcut:[ce.CMD,ce.SHIFT,fe.F]}),GOTO_ROW:Be.createAndAdd({id:"TABLE.GOTO_ROW",name:"Go to Row",shortcut:[ce.CTRL,fe.G],macShortcut:[ce.CMD,fe.G]})},Au={COMMIT:Be.createAndAdd({id:"INPUT_TABLE.COMMIT",name:"Commit",shortcut:[ce.CTRL,fe.S],macShortcut:[ce.CMD,fe.S]}),DISCARD:Be.createAndAdd({id:"INPUT_TABLE.DISCARD",name:"Discard",shortcut:[ce.CTRL,ce.ALT,fe.S],macShortcut:[ce.CMD,ce.OPTION,fe.S]})},Nt={TABLE:Nu,INPUT_TABLE:Au};class Mu extends ss{constructor(t){super(),this.irisGrid=t}onDown(t){if(Nt.TABLE.REVERSE.matchesEvent(t)){if(!this.irisGrid.isReversible())return!1;const{reverseType:n}=this.irisGrid.state;return n===N.REVERSE_TYPE.NONE?this.irisGrid.reverse(N.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(N.REVERSE_TYPE.NONE),!0}return!1}}class Ou extends ss{constructor(t){super(),this.irisGrid=t}onDown(t){return Nt.TABLE.CLEAR_FILTERS.matchesEvent(t)?(this.irisGrid.clearAllFilters(),!0):!1}}class xu extends Ke{constructor(t){super(850),this.irisGrid=t}destroyColumnTooltip(){this.irisGrid.setState({overflowButtonTooltipProps:null})}setCursor(t){return this.isHoveringOverflowButton(t)?(this.cursor="pointer",{stopPropagation:!1,preventDefault:!1}):(this.cursor=null,!1)}getButtonPosition({x:t,y:n,column:s,row:o}){if(s==null||o==null)return null;const{renderer:i,grid:r,state:l,props:a}=this.irisGrid;if(!r)return null;const{metrics:c}=l,{model:d}=a,{canvasContext:u}=r,h=r.getTheme(),g={context:u,mouseX:t,mouseY:n,metrics:c,model:d,theme:h},{left:p,top:f,width:C,height:w}=i.getCellOverflowButtonPosition(g);return p==null||C==null||f==null||w==null?null:{left:p,top:f,width:C,height:w}}isHoveringOverflowButton(t){var w;const{x:n,y:s}=t,{left:o,top:i,width:r,height:l}=(w=this.getButtonPosition(t))!=null?w:{};if(o==null||r==null||i==null||l==null)return!1;const{renderer:a,grid:c,state:d,props:u}=this.irisGrid;if(!c)return!1;const{metrics:h}=d,{model:g}=u,{canvasContext:p}=c,f=c.getTheme(),C={context:p,mouseX:n,mouseY:s,metrics:h,model:g,theme:f};return a.shouldRenderOverflowButton(C)&&n>=o&&n<=o+r&&s>=i&&s<=i+l}onMove(t){if(this.isHoveringOverflowButton(t)){const{overflowButtonTooltipProps:n}=this.irisGrid.state,s=this.getButtonPosition(t);it(n,s)||this.irisGrid.setState({overflowButtonTooltipProps:s})}else this.destroyColumnTooltip();return this.setCursor(t)}onWheel(t){return this.destroyColumnTooltip(),this.onMove(t)}onDown(t){this.destroyColumnTooltip();const{column:n,row:s}=t;return this.isHoveringOverflowButton(t)&&this.irisGrid.setState({showOverflowModal:!0,overflowText:this.irisGrid.getValueForCell(n,s)}),!1}onContextMenu(){return this.destroyColumnTooltip(),!1}onLeave(){return this.destroyColumnTooltip(),!1}}class ku extends Ke{constructor(t){super(),this.irisGrid=t,this.cursor=null}isActive(){const{isSelectingColumn:t}=this.irisGrid.props;return t}isValidColumn(t){if(t==null)return!1;const{columnSelectionValidator:n}=this.irisGrid.props;return n!=null?n(t):!0}updateColumnSelectionStatus(){const{columnSelectionValidator:t}=this.irisGrid.props;t!=null&&t(null)}getTableColumn(t){if(t==null)return null;const{model:n}=this.irisGrid.props,s=this.irisGrid.getModelColumn(t);return s==null?null:n.columns[s]}onMove(t){if(!this.isActive())return!1;const{columnAllowedCursor:n,columnNotAllowedCursor:s}=this.irisGrid.props,{column:o}=t,i=this.getTableColumn(o);return this.isValidColumn(i)?(this.cursor=n,this.irisGrid.setState({hoverSelectColumn:o})):(this.cursor=s,this.irisGrid.setState({hoverSelectColumn:null})),!0}onWheel(t){if(!this.isActive())return!1;const{columnAllowedCursor:n,columnNotAllowedCursor:s}=this.irisGrid.props,{column:o}=t,i=this.getTableColumn(o);return this.isValidColumn(i)?this.cursor=n:this.cursor=s,{preventDefault:!1,stopPropagation:!1}}onLeave(){return this.isActive()&&this.irisGrid.setState({hoverSelectColumn:null}),this.updateColumnSelectionStatus(),!1}onDown(){return this.isActive()}onClick(t){if(!this.isActive())return!1;const{column:n}=t,s=this.getTableColumn(n);return s!=null&&this.isValidColumn(s)&&this.irisGrid.selectColumn(s),!0}}class Lu extends Ke{constructor(t){super(),this.irisGrid=t}hideColumnTooltip(){const{tooltip:t}=this.irisGrid;t&&(t.stopTimer(),t.hide())}onDown(){return this.hideColumnTooltip(),!1}onContextMenu(){return this.hideColumnTooltip(),!1}onWheel(){return this.hideColumnTooltip(),!1}onLeave(t,n,s){const{relatedTarget:o}=s instanceof MouseEvent?s:s.nativeEvent,{tooltip:i}=this.irisGrid;if(!i)return!1;const r=i.popper.current;return r&&o instanceof Element&&r.element.contains(o)||this.hideColumnTooltip(),!1}onMove(t){const{column:n,row:s,columnHeaderDepth:o}=t,{shownColumnTooltip:i}=this.irisGrid.state;let r=null;return n!==null&&s===null&&o===0&&(r=n),r!==i&&this.irisGrid.setState({shownColumnTooltip:r}),!1}}const Il=class extends F.exports.Component{constructor(e=Il.defaultProps){super(e),this.handleInputChange=this.handleInputChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.inputRef=De.createRef()}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=Xc.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:o},iconElement:i}=t;return y("div",{className:"form-group flex-grow mb-0",children:[y("div",{className:"custom-format-title",children:[m("span",{className:"icon",children:i}),y("label",{className:"title mb-0",htmlFor:"custom-format-input",children:[s,o!=null&&m(Rt,{children:o})]})]}),m("div",{className:"pl-2 pr-2 pb-2",children:m("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"})})]})}};let Nl=Il;Nl.defaultProps={formatString:"",forwardedProps:{menuItem:{},closeMenu(e){},iconElement:null},placeholder:"",title:"",onChange(e){}};class ft{static isDefaultSelected(t){return!t||![_e.TYPE_CONTEXT_CUSTOM,_e.TYPE_CONTEXT_PRESET].includes(t.type)}static isCustomSelected(t){return t!=null&&t.type===_e.TYPE_CONTEXT_CUSTOM}static makeOption(t,n,s,o){return{title:t,description:t,group:s,format:n,isSelected:o}}static makeCustomFormatOption(t,n,s,o,i){return{title:t.label,description:t.label,format:t,group:n,isSelected:o,menuElement:m(Nl,{formatString:t.formatString,title:t.label,placeholder:s,onChange:i})}}}const Vt=class{static getOptions(e,t){const n=new Date,o=[{group:Vt.dateGroup,formatString:"yyyy-MM-dd"},{group:Vt.dateGroup,formatString:"MM-dd-yyyy"},{group:Vt.timeGroup,formatString:"HH:mm:ss"},{group:Vt.timeGroup,formatString:"HH:mm:ss.SSS"},{group:Vt.timeGroup,formatString:"HH:mm:ss.SSSSSSSSS"},{group:Vt.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss"},{group:Vt.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSS"},{group:Vt.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"}].map(r=>{const l=kn.makeFormat("",r.formatString,kn.TYPE_CONTEXT_PRESET),a=e.getFormattedString(n,N.dataType.DATETIME,"",l);return ft.makeOption(a,l,r.group,kn.isSameFormat(l,t))});return[ft.makeOption("Default",null,Vt.dateGroup,ft.isDefaultSelected(t)),...o]}};let ei=Vt;ei.dateGroup=10;ei.timeGroup=20;ei.dateTimeGroup=30;const Ut=class{static getOptions(e,t){const n=[{format:Ve.FORMAT_PERCENT,group:Ut.presetGroup},{format:Ve.FORMAT_BASIS_POINTS,group:Ut.presetGroup},{format:Ve.FORMAT_MILLIONS,group:Ut.presetGroup},{format:Ve.FORMAT_SCIENTIFIC_NOTATION,group:Ut.presetGroup},{format:Ve.FORMAT_ROUND,group:Ut.presetRoundGroup},{format:Ve.FORMAT_ROUND_TWO_DECIMALS,group:Ut.presetRoundGroup},{format:Ve.FORMAT_ROUND_FOUR_DECIMALS,group:Ut.presetRoundGroup}],s=ft.makeOption("Default",null,Ut.defaultGroup,ft.isDefaultSelected(e)),o=n.map(a=>ft.makeOption(a.format.label,a.format,a.group,Ve.isSameFormat(a.format,e))),i=ft.isCustomSelected(e),r=i?e:Ve.makeCustomFormat(),l=ft.makeCustomFormatOption(r,Ut.customGroup,Ve.DEFAULT_FORMAT_STRING,i,a=>{if(a!=null){const c=Ve.makeCustomFormat(a);Ve.isValid(c)&&t(c)}else t(null)});return[s,...o,l]}};let Js=Ut;Js.defaultGroup=10;Js.presetGroup=20;Js.presetRoundGroup=30;Js.customGroup=40;const Gs=class{static getOptions(e,t){const n=[{format:It.FORMAT_MILLIONS,group:Gs.presetGroup},{format:It.FORMAT_SCIENTIFIC_NOTATION,group:Gs.presetGroup}],s=ft.makeOption("Default",null,Gs.defaultGroup,ft.isDefaultSelected(e)),o=n.map(a=>ft.makeOption(a.format.label,a.format,a.group,It.isSameFormat(a.format,e))),i=ft.isCustomSelected(e),r=i?e:It.makeCustomFormat(),l=ft.makeCustomFormatOption(r,Gs.customGroup,It.DEFAULT_FORMAT_STRING,i,a=>{if(a!=null){const c=It.makeCustomFormat(a);It.isValid(c)&&t(c)}else t(null)});return[s,...o,l]}};let ti=Gs;ti.defaultGroup=10;ti.presetGroup=20;ti.customGroup=30;const Or=le.module("IrisGridContextMenuHandler"),Pu=150,xr="yyyy-MM-dd HH:mm:ss.SSSSSSSSS",U=class extends Ke{constructor(e){super(),this.debouncedUpdateCustomFormat=vt(e.handleFormatSelection,Pu),this.irisGrid=e}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 E.FilterCondition.invoke("isInf",n).and(n.greaterThan(E.FilterValue.ofNumber(0)));if(t===Number.NEGATIVE_INFINITY)return E.FilterCondition.invoke("isInf",n).and(n.lessThan(E.FilterValue.ofNumber(0)));if(Number.isNaN(t))return E.FilterCondition.invoke("isNaN",n);const s=U.getFilterValueForNumberOrChar(e.type,t);return n.eq(s)}static getFilterValueForNumberOrChar(e,t){return N.isCharType(e)?E.FilterValue.ofString(String.fromCharCode(t)):E.FilterValue.ofNumber(t)}static getRowOptionFormatted(e,t,n=30){return`${e} "${ts.truncate(t,n-e.length-3)}"`}componentWillUnmount(){this.debouncedUpdateCustomFormat.flush()}getHeaderActions(e,t){var I;const{irisGrid:n}=this,{column:s}=t;M(s);const{model:o}=n.props,{columns:i}=o,r=i[e],l=[],{metrics:a,reverseType:c,quickFilters:d,advancedFilters:u,searchFilter:h}=n.state,g=n.getTheme();M(a);const{filterIconColor:p,filterBarActiveColor:f,contextMenuSortIconColor:C,contextMenuReverseIconColor:w}=g,S=o.sort,b=N.getSortForColumn(S,e),v=c!==N.REVERSE_TYPE.NONE,{userColumnWidths:T}=a,R=[...T.values()].some(L=>L===0),D=o.getColumnHeaderParentGroup(e,0)===void 0,A=o.isColumnFrozen(e);return l.push({title:"Hide Column",group:U.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.hideColumnByVisibleIndex(s)}}),l.push({title:A?"Unfreeze Column":"Freeze Column",group:U.GROUP_HIDE_COLUMNS,disabled:!D,action:()=>{A?this.irisGrid.unFreezeColumnByColumnName(r.name):this.irisGrid.freezeColumnByColumnName(r.name)},order:10}),l.push({title:"Show All Columns",group:U.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.showAllColumns()},disabled:!R}),l.push({title:"Quick Filters",icon:jt,iconColor:f,shortcut:Nt.TABLE.TOGGLE_QUICK_FILTER,group:U.GROUP_FILTER,order:10,action:()=>{this.irisGrid.toggleFilterBar(s)}}),l.push({title:"Advanced Filters",icon:u.get(e)?ki:xo,iconColor:p,group:U.GROUP_FILTER,order:20,action:()=>{this.irisGrid.handleAdvancedMenuOpened(s)}}),l.push({title:"Clear Table Filters",group:U.GROUP_FILTER,order:40,shortcut:Nt.TABLE.CLEAR_FILTERS,action:()=>{this.irisGrid.clearAllFilters()},disabled:!(d.size>0||u.size>0||h!=null)}),l.push({title:"Sort by",icon:jt,iconColor:C,group:U.GROUP_SORT,order:10,actions:this.sortByActions(r,e,b)}),l.push({title:"Add Additional Sort",disabled:b&&S.length===1||v&&S.length===1||b&&v&&S.length===2||S.length===0,group:U.GROUP_SORT,order:20,actions:this.additionalSortActions(r,e)}),l.push({title:"Clear Table Sorting",disabled:S.length===0||v&&S.length===1,group:U.GROUP_SORT,action:()=>{this.irisGrid.sortColumn(s,U.COLUMN_SORT_DIRECTION.none)},order:30}),l.push({title:c===N.REVERSE_TYPE.NONE?"Reverse Table":"Clear Reverse Table",icon:jt,iconColor:w,group:U.GROUP_SORT,order:40,disabled:!o.isReversible,shortcut:Nt.TABLE.REVERSE,action:()=>{c===N.REVERSE_TYPE.NONE?this.irisGrid.reverse(N.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(N.REVERSE_TYPE.NONE)}}),l.push({title:"Copy Column Name",group:U.GROUP_COPY,action:()=>{var L;qo((L=o.textForColumnHeader(e))!=null?L:"").catch(k=>Or.error("Unable to copy header",k))}}),N.isDateType(r.type)?l.push({title:"Date/Time Format",group:U.GROUP_FORMAT,actions:this.dateFormatActions(r)}):N.isNumberType(r.type)&&l.push({title:"Number Format",group:U.GROUP_FORMAT,actions:(I=this.numberFormatActions(r))!=null?I:void 0}),l}getCellActions(e,t,n){M(e);const{irisGrid:s}=this,{column:o,row:i}=n,{model:r,canCopy:l}=s.props,{columns:a}=r,c=s.getModelRow(i);M(c);const d=r.valueForCell(e,c),u=r.textForCell(e,c),h=a[e],g=[],{quickFilters:p}=s.state,f=s.getTheme(),{filterIconColor:C}=f,{settings:w}=s.props,S=new kn({timeZone:w==null?void 0:w.timeZone,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:xr}),b=new kn({timeZone:w==null?void 0:w.timeZone,showTimeZone:w==null?void 0:w.showTimeZone,showTSeparator:w==null?void 0:w.showTSeparator,defaultDateTimeFormatString:xr});if(h==null||i==null)return g;if(r.isFilterable(e)){const T={title:"Filter by Value",icon:jt,iconColor:C,group:U.GROUP_FILTER,order:10,actions:[]};if(d==null)p.get(e)&&T.actions.push({title:"And",actions:this.nullFilterActions(h,p.get(e),"&&"),order:2,group:oe.groups.high}),T.actions.push(...this.nullFilterActions(h));else if(N.isBooleanType(h.type))p.get(e)&&T.actions.push({title:"Or",actions:this.booleanFilterActions(h,u,p.get(e),"||"),order:2,group:oe.groups.high}),T.actions.push(...this.booleanFilterActions(h,u));else if(N.isNumberType(h.type)||N.isCharType(h.type)){M(e);const R=N.isCharType(h.type)?String.fromCharCode(d):`${d}`;p.get(e)&&T.actions.push({title:"And",actions:this.numberFilterActions(h,R,d,p.get(e),"&&"),order:2,group:oe.groups.high}),T.actions.push(...this.numberFilterActions(h,R,d,p.get(e)))}else if(N.isDateType(h.type)){const R=S.format(d),D=b.format(d);p.get(e)&&T.actions.push({title:"And",actions:this.dateFilterActions(h,R,D,d,p.get(e),"&&"),order:2,group:oe.groups.high}),T.actions.push(...this.dateFilterActions(h,R,D,d,p.get(e)))}else p.get(e)&&T.actions.push({title:"And",actions:this.stringFilterActions(h,u,d,p.get(e),"&&"),order:2,group:oe.groups.high}),T.actions.push(...this.stringFilterActions(h,u,d));T.actions!=null&&T.actions.length>0&&g.push(T)}if(Me(r)&&r.isRowExpandable(c)){const T=r.groupedColumns.length>0?r.depthForRow(c)-1:0,D=r.valueForCell(T,c)==null?"null":r.textForCell(T,c);g.push({title:U.getRowOptionFormatted(r.isRowExpanded(c)?"Collapse":"Expand",D),group:U.GROUP_EXPAND_COLLAPSE,order:10,action:()=>{r.setRowExpanded(c,!r.isRowExpanded(c))}}),r.isExpandAllAvailable===!0&&g.push({title:U.getRowOptionFormatted("Expand All in",D),group:U.GROUP_EXPAND_COLLAPSE,order:20,action:()=>{r.setRowExpanded(c,!0,!0)}})}Me(r)&&r.hasExpandableRows&&r.isExpandAllAvailable===!0&&(g.push({title:"Expand Entire Table",group:U.GROUP_EXPAND_COLLAPSE,order:30,action:()=>{r.expandAll()}}),g.push({title:"Collapse Entire Table",group:U.GROUP_EXPAND_COLLAPSE,order:40,action:()=>{r.collapseAll()}}));const v={title:"Go to",iconColor:C,shortcut:Nt.TABLE.GOTO_ROW,group:U.GROUP_GOTO,order:10,action:()=>this.irisGrid.toggleGotoRow(`${i+1}`,`${d}`,h.name)};return g.push(v),l&&(g.push({title:"Copy Cell",group:U.GROUP_COPY,order:10,action:()=>{s.copyCell(o,i)}}),g.push({title:"Copy Cell Unformatted",group:U.GROUP_COPY,order:20,action:()=>{s.copyCell(o,i,!0)}})),g}onContextMenu(e,t,n){const{irisGrid:s}=this,{y:o,column:i,row:r,columnHeaderDepth:l}=e,a=s.getModelColumn(i),c=s.getModelRow(r),{model:d,canCopy:u}=s.props,{columns:h}=d,{metrics:g,isFilterBarShown:p,quickFilters:f,advancedFilters:C,selectedRanges:w}=s.state;M(g);const{columnHeaderHeight:S,gridY:b,columnHeaderMaxDepth:v}=g,T=[];if(a!=null&&c!=null){const R=d.valueForCell(a,c),D=d.textForCell(a,c),A=h[a],{onContextMenu:I}=s.props;A!=null&&T.push(I({model:d,value:R,valueText:D,column:A,rowIndex:r,columnIndex:i,modelRow:c,modelColumn:a}))}return a!=null&&d.isFilterable(a)&&T.push({title:"Clear Column Filter",group:U.GROUP_FILTER,order:30,action:()=>{this.irisGrid.removeColumnFilter(a)},disabled:!(f.has(a)||C.has(a))}),(p?o<=b:o<=S*v&&l===0)?a!=null&&T.push(...this.getHeaderActions(a,e)):(a!=null&&c!=null&&T.push(...this.getCellActions(a,t,e)),u&&w.length>0&&(T.push({title:"Copy Selection",shortcut:Li.COPY,group:U.GROUP_COPY,order:30,action:()=>{s.copyRanges(w)}}),T.push({title:"Copy Selection w/ Headers",group:U.GROUP_COPY,order:40,action:()=>{s.copyRanges(w,!0)}})),Pe(d)&&d.isEditable&&w.length>0&&T.push({title:"Delete Selected Rows",group:U.GROUP_EDIT,order:50,action:()=>{this.irisGrid.deleteRanges(w)}})),T.length===0?!1:(M(s.gridWrapper),oe.triggerMenu(s.gridWrapper,n.pageX,n.pageY,T),!0)}dateFormatActions(e){const{model:t}=this.irisGrid.props,{formatter:n}=t,s=n.getColumnFormat(e.type,e.name),o=ei.getOptions(n,s),i=[];for(let r=0;r<o.length;r+=1){const{description:l,format:a,group:c,isSelected:d,title:u}=o[r];i.push({title:u,description:l,icon:d?jn:void 0,group:c,order:r,action:()=>{const h=t.getColumnIndexByName(e.name);M(h),this.irisGrid.handleFormatSelection(h,a)}})}return i}numberFormatActions(e){const{model:t}=this.irisGrid.props,{formatter:n}=t,s=n.getColumnFormat(e.type,e.name);let o;const i=t.getColumnIndexByName(e.name);if(N.isDecimalType(e.type))o=Js.getOptions(s,l=>{M(i),this.debouncedUpdateCustomFormat(i,l)});else if(N.isIntegerType(e.type))o=ti.getOptions(s,l=>{M(i),this.debouncedUpdateCustomFormat(i,l)});else return Or.error("Invalid column type in numberFormatActions"),null;const r=[];for(let l=0;l<o.length;l+=1){const{format:a,isSelected:c}=o[l];r.push({...o[l],icon:c?jn:void 0,order:l,action:()=>{i===void 0&&a&&a.type===_e.TYPE_CONTEXT_CUSTOM||(M(i),this.irisGrid.handleFormatSelection(i,a))}})}return r}stringFilterActions(e,t,n,s,o){const i=E.FilterValue.ofString(n);let r=s;r||(r={filter:null,text:null});const{filter:l,text:a}=r,c=[],{model:d}=this.irisGrid.props,u=d.getColumnIndexByName(e.name);return M(u),c.push({menuElement:y("div",{className:"iris-grid-filter-menu-item-value",children:[o?U.getOperatorAsText(o):""," ",'"',t,'"']}),order:1,group:oe.groups.high}),c.push({title:"text is exactly",description:`Show only rows where ${e.name} is ${n} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(l,e.filter().eq(i),o),U.getQuickFilterText(a,`=${t}`,o))},order:10,group:oe.groups.low}),c.push({title:"text is not exactly",description:`Show only rows where ${e.name} is not ${t} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(l,e.filter().notEq(i),o),U.getQuickFilterText(a,`!=${t}`,o))},order:20,group:oe.groups.low}),c.push({title:"text contains",description:`Show only rows where ${e.name} contains ${t}`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(l,e.filter().contains(i),o),U.getQuickFilterText(a,`~${t}`,o))},order:30,group:oe.groups.low}),c.push({title:"text does not contain",description:`Show only rows where ${e.name} does not contain ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(l,e.filter().contains(i).not(),o),U.getQuickFilterText(a,`!~${t}`,o))},order:40,group:oe.groups.low}),c.push({title:"text starts with",description:`Show only rows where ${e.name} starts with ${t}`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(l,e.filter().invoke("startsWith",i),o),U.getQuickFilterText(a,`${t}*`,o))},order:50,group:oe.groups.low}),c.push({title:"text ends with",description:`Show only rows where ${e.name} ends with ${t}`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(l,e.filter().invoke("endsWith",i),o),U.getQuickFilterText(a,`*${t}`,o))},order:60,group:oe.groups.low}),c}numberFilterActions(e,t,n,s,o){const i=U.getFilterValueForNumberOrChar(e.type,n);let r=null,l=null;s&&(r=s.filter,l=s.text);const a=[],c=n!==Number.POSITIVE_INFINITY&&n!==Number.NEGATIVE_INFINITY&&!Number.isNaN(n),{model:d}=this.irisGrid.props,u=d.getColumnIndexByName(e.name);return M(u),a.push({menuElement:y("div",{className:"iris-grid-filter-menu-item-value",children:[o?U.getOperatorAsText(o):""," ",'"',t,'"']}),order:1,group:oe.groups.high}),a.push({title:"is equal to",description:`Show only rows where ${e.name} is ${t}`,action:()=>{const h=U.getNumberValueEqualsFilter(e,n);this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(r,h,o),U.getQuickFilterText(l,`=${t}`,o))},order:10,group:oe.groups.low}),a.push({title:"is not equal to",description:`Show only rows where ${e.name} is not ${t}`,action:()=>{const h=U.getNumberValueEqualsFilter(e,n).not();this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(r,h,o),U.getQuickFilterText(l,`!=${t}`,o))},order:20,group:oe.groups.low}),c&&!N.isCharType(e.type)&&(a.push({title:"greater than",description:`Show only rows where ${e.name} is greater than ${t}`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(r,e.filter().greaterThan(i),o),U.getQuickFilterText(l,`>${t}`,o))},order:30,group:oe.groups.low}),a.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(u,U.getQuickFilterCondition(r,e.filter().greaterThanOrEqualTo(i),o),U.getQuickFilterText(l,`>=${t}`,o))},order:40,group:oe.groups.low}),a.push({title:"less than",description:`Show only rows where ${e.name} is less than ${t}`,action:()=>{this.irisGrid.setQuickFilter(u,U.getQuickFilterCondition(r,e.filter().lessThan(i),o),U.getQuickFilterText(l,`<${t}`,o))},order:50,group:oe.groups.low}),a.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(u,U.getQuickFilterCondition(r,e.filter().lessThanOrEqualTo(i),o),U.getQuickFilterText(l,`<=${t}`,o))},order:60,group:oe.groups.low})),a}booleanFilterActions(e,t,n,s){const o=[],{model:i}=this.irisGrid.props,{filter:r,text:l}=n||{},a=i.getColumnIndexByName(e.name);return M(a),o.push({menuElement:y("div",{className:"iris-grid-filter-menu-item-value",children:[s?U.getOperatorAsText(s):""," ",'"',t!=null?t:"null",'"']}),order:1,group:oe.groups.high}),o.push({title:"true",description:`Show only rows where ${e.name} is true`,action:()=>{this.irisGrid.setQuickFilter(a,U.getQuickFilterCondition(r,e.filter().isTrue(),s),U.getQuickFilterText(l,"true",s))},order:10,group:oe.groups.low}),o.push({title:"false",description:`Show only rows where ${e.name} is false`,action:()=>{this.irisGrid.setQuickFilter(a,U.getQuickFilterCondition(r,e.filter().isFalse(),s),U.getQuickFilterText(l,"false",s))},order:20,group:oe.groups.low}),o.push({title:"is null",description:`Show only rows where ${e.name} is null`,action:()=>{this.irisGrid.setQuickFilter(a,U.getQuickFilterCondition(r,e.filter().isNull(),s),U.getQuickFilterText(l,"null",s))},order:30,group:oe.groups.low}),o.push({title:"is not null",description:`Show only rows where ${e.name} is not null`,action:()=>{this.irisGrid.setQuickFilter(a,U.getQuickFilterCondition(r,e.filter().isNull().not(),s),U.getQuickFilterText(l,"!null",s))},order:40,group:oe.groups.low}),o}dateFilterActions(e,t,n,s,o,i){const r=E.FilterValue.ofNumber(s);let l=null,a=null;o&&(l=o.filter,a=o.text);const{model:c}=this.irisGrid.props,d=c.getColumnIndexByName(e.name);M(d);const u=[];return u.push({menuElement:y("div",{className:"iris-grid-filter-menu-item-value",children:[i?U.getOperatorAsText(i):""," ",'"',n,'"']}),order:1,group:oe.groups.high}),u.push({title:"date is",description:`Show only rows where ${e.name} is ${n}`,action:()=>{this.irisGrid.setQuickFilter(d,U.getQuickFilterCondition(l,e.filter().eq(r),i),U.getQuickFilterText(a,`=${t}`,i))},order:10,group:oe.groups.low}),u.push({title:"date is not",description:`Show only rows where ${e.name} is not ${n}`,action:()=>{this.irisGrid.setQuickFilter(d,U.getQuickFilterCondition(l,e.filter().notEq(r),i),U.getQuickFilterText(a,`!=${t}`,i))},order:20,group:oe.groups.low}),u.push({title:"date is before",description:`Show only rows where ${e.name} is before ${n}`,action:()=>{this.irisGrid.setQuickFilter(d,U.getQuickFilterCondition(l,e.filter().lessThan(r),i),U.getQuickFilterText(a,`<${t}`,i))},order:30,group:oe.groups.low}),u.push({title:"date is before or equal",description:`Show only rows where ${e.name} is before or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(d,U.getQuickFilterCondition(l,e.filter().lessThanOrEqualTo(r),i),U.getQuickFilterText(a,`<=${t}`,i))},order:40,group:oe.groups.low}),u.push({title:"date is after",description:`Show only rows where ${e.name} is greater than ${n}`,action:()=>{this.irisGrid.setQuickFilter(d,U.getQuickFilterCondition(l,e.filter().greaterThan(r),i),U.getQuickFilterText(a,`>${t}`,i))},order:50,group:oe.groups.low}),u.push({title:"date is after or equal",description:`Show only rows where ${e.name} is after or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(d,U.getQuickFilterCondition(l,e.filter().greaterThanOrEqualTo(r),i),U.getQuickFilterText(a,`>=${t}`,i))},order:60,group:oe.groups.low}),u}nullFilterActions(e,t,n){let s=null,o=null;t&&(s=t.filter,o=t.text);const i=[],{model:r}=this.irisGrid.props,l=r.getColumnIndexByName(e.name);return M(l),i.push({menuElement:y("div",{className:"iris-grid-filter-menu-item-value",children:[n?U.getOperatorAsText(n):""," ",'"null"']}),order:1,group:oe.groups.high}),i.push({title:"is null",description:`Show only rows where ${e.name} is null`,action:()=>{this.irisGrid.setQuickFilter(l,U.getQuickFilterCondition(s,e.filter().isNull(),n),U.getQuickFilterText(o,"null",n))},order:10,group:oe.groups.low}),i.push({title:"is not null",description:`Show only rows where ${e.name} is not null`,action:()=>{this.irisGrid.setQuickFilter(l,U.getQuickFilterCondition(s,e.filter().isNull().not(),n),U.getQuickFilterText(o,"!null",n))},order:20,group:oe.groups.low}),i}sortByActions(e,t,n){const s=this.irisGrid.getTheme(),{contextMenuSortIconColor:o}=s,i=[{title:`${e.name} Ascending`,order:10,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.ascending)},icon:this.checkColumnSort(n,U.COLUMN_SORT_DIRECTION.ascending)?jt:void 0,iconColor:o},{title:`${e.name} Descending`,order:20,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.descending)},icon:this.checkColumnSort(n,U.COLUMN_SORT_DIRECTION.descending)?jt:void 0,iconColor:o},{title:"Remove Sort",order:50,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.none,!1,!0)},disabled:!n}];return N.isNumberType(e.type)&&(i.push({title:`ABS(${e.name}) Ascending`,order:30,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.ascending,!0)},icon:this.checkColumnSort(n,U.COLUMN_SORT_DIRECTION.ascending,!0)?jt:void 0,iconColor:o}),i.push({title:`ABS(${e.name}) Descending`,order:40,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.descending,!0)},icon:this.checkColumnSort(n,U.COLUMN_SORT_DIRECTION.descending,!0)?jt:void 0,iconColor:o})),i}additionalSortActions(e,t){const n=this.irisGrid.getTheme(),{contextMenuSortIconColor:s}=n,o=[{title:"Add Sort By",menuElement:y("div",{className:"btn-context-menu menu-title",children:[m("span",{className:"icon",children:m(J,{icon:jt,style:{color:s!=null?s:void 0}})}),m("span",{className:"title",children:"Add Additional Sort"}),m("span",{className:"shortcut",children:_n.isMacPlatform()?"\u2318Click":"Ctrl+Click"})]}),order:1},{title:`${e.name} Ascending`,order:10,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.ascending,!1,!0)}},{title:`${e.name} Descending`,order:20,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.descending,!1,!0)}}];return N.isNumberType(e.type)&&(o.push({title:`ABS(${e.name}) Ascending`,order:30,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.ascending,!0,!0)}}),o.push({title:`ABS(${e.name}) Descending`,order:40,action:()=>{this.irisGrid.sortColumn(t,U.COLUMN_SORT_DIRECTION.descending,!0,!0)}})),o}checkColumnSort(e,t=null,n=!1){return e?e.direction===t&&e.isAbs===n:!1}};let Xt=U;Xt.GROUP_EDIT=oe.groups.high+10;Xt.GROUP_HIDE_COLUMNS=oe.groups.high+25;Xt.GROUP_FILTER=oe.groups.high+50;Xt.GROUP_EXPAND_COLLAPSE=oe.groups.high+55;Xt.GROUP_GOTO=oe.groups.high+60;Xt.GROUP_SORT=oe.groups.high+75;Xt.GROUP_COPY=oe.groups.high+100;Xt.GROUP_FORMAT=oe.groups.high+150;Xt.COLUMN_SORT_DIRECTION={ascending:"ASC",descending:"DESC",none:null};class _u extends Ke{constructor(t){super(),this.irisGrid=t}onDoubleClick(t){const{column:n,row:s}=t;return s==null||n==null?!1:(this.irisGrid.selectData(n,s),!0)}}class Hu extends Ke{constructor(t){super(),this.irisGrid=t}onDown(t){const{y:n,column:s,row:o}=t;if(s!==null&&o===null){const{isFilterBarShown:i,metrics:r}=this.irisGrid.state;if(!r)throw new Error("Metrics not set");const{columnHeaderMaxDepth:l}=r,a=this.irisGrid.getTheme();if(i&&a.columnHeaderHeight!=null&&a.filterBarHeight!=null&&n>a.columnHeaderHeight*l&&n<=a.columnHeaderHeight*l+a.filterBarHeight)return this.irisGrid.focusFilterBar(s),!0}return!1}onMove(t){const{y:n,column:s}=t,{isFilterBarShown:o,hoverAdvancedFilter:i,metrics:r}=this.irisGrid.state;if(!r)throw new Error("Metrics not set");const{columnHeaderMaxDepth:l}=r,a=this.irisGrid.getTheme();let c=null;return o&&a.columnHeaderHeight!=null&&a.filterBarHeight!=null&&s!==null&&n>=a.columnHeaderHeight*l&&n<=a.columnHeaderHeight*l+a.filterBarHeight&&(c=s),c!==i&&this.irisGrid.setState({hoverAdvancedFilter:c}),!1}onLeave(t){const{column:n}=t,{hoverAdvancedFilter:s}=this.irisGrid.state;return s!==null&&n!==s&&this.irisGrid.setState({hoverAdvancedFilter:null}),!1}}class Vu extends Ke{constructor(t){super(750),this.irisGrid=t}destroyTooltip(){this.irisGrid.setState({expandCellTooltipProps:null})}setCursor(t,n){return bs.isInTreeBox(t,n)?(this.cursor="pointer",{stopPropagation:!1,preventDefault:!1}):(this.cursor=null,!1)}getButtonPosition({x:t,y:n,column:s,row:o}){if(s==null||o==null)return null;const{renderer:i,grid:r,state:l,props:a}=this.irisGrid;if(!r)return null;const{metrics:c}=l,{model:d}=a,{canvasContext:u}=r,h=r.getTheme(),g={context:u,mouseX:t,mouseY:n,metrics:c,model:d,theme:h},p=Me(d)?d.depthForRow(o):null,{left:f,top:C,width:w,height:S}=i.getExpandButtonPosition(g,p);return f==null||w==null||C==null||S==null?null:{left:f,top:C,width:w,height:S}}onMove(t,n){if(bs.isInTreeBox(t,n)){const{expandCellTooltipProps:s}=this.irisGrid.state,{model:o}=this.irisGrid.props,i=this.getButtonPosition(t),{row:r}=t;M(r);const l=Me(o)&&o.isRowExpanded(r);it(s,i)||this.irisGrid.setState({expandCellTooltipProps:i,expandTooltipDisplayValue:l?"collapse":"expand"})}else this.destroyTooltip();return this.setCursor(t,n)}onDown(){return this.destroyTooltip(),!1}onContextMenu(){return this.destroyTooltip(),!1}onWheel(){return this.destroyTooltip(),!1}onLeave(){return this.destroyTooltip(),!1}}class Uu extends Ke{constructor(t){super(),this.column=null,this.irisGrid=t}getColumnFromGridPoint(t){const{column:n,row:s,columnHeaderDepth:o}=t;return n!==null&&s===null&&o===0?n:null}onDown(t){return this.column=this.getColumnFromGridPoint(t),!1}onClick(t,n,s){const o=this.getColumnFromGridPoint(t);if(o!=null&&o===this.column){const i=_n.isModifierKeyDown(s);return this.irisGrid.toggleSort(o,i),!0}return!1}}class Bu extends Ke{constructor(t){super(),this.irisGrid=t}onWheel(t,n,s){const{irisGrid:o}=this,{model:i}=o.props,{metrics:r,pendingRowCount:l}=o.state;M(r);const{bottom:a,rowCount:c,rowHeight:d}=r,{deltaY:u}=_.getScrollDelta(s);return Pe(i)&&i.isEditable&&a>=c-1&&u>0&&o.setState({pendingRowCount:l+Math.ceil(u/d)}),!1}}const Gu=3e3;function Wu({children:e=null,onEntering:t,onEntered:n,onExiting:s,onExited:o}){const[i,r]=F.exports.useState(!1),l=F.exports.useRef(),a=$i(e),c=F.exports.useCallback(()=>{r(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{r(!1)},Gu)},[r,l]);return F.exports.useEffect(()=>{a!==e&&e!=null&&c()},[e,a,r,c]),F.exports.useEffect(()=>()=>l.current?clearTimeout(l.current):void 0,[]),m(Jo,{className:"toast-bottom-bar",isShown:i,onEntering:t,onEntered:n,onExiting:s,onExited:o,children:e})}class $u extends js{getGridY(t){let n=super.getGridY(t);const{isFilterBarShown:s,theme:o,advancedFilters:i,quickFilters:r,sorts:l,reverseType:a}=t;return s?n+=o.filterBarHeight:(r!=null&&r.size>0||i!=null&&i.size>0)&&(n+=o.filterBarCollapsedHeight),a!==N.REVERSE_TYPE.NONE&&l!=null&&l.length>0&&(n+=o.reverseHeaderBarHeight),n}getUserColumnWidths(){return this.userColumnWidths}}const zu=1,Al=De.memo(({model:e,modelColumns:t,top:n,bottom:s,left:o,right:i,filter:r,formatter:l,reverseType:a=N.REVERSE_TYPE.NONE,sorts:c,customColumns:d,movedColumns:u,hiddenColumns:h,alwaysFetchColumns:g,rollupConfig:p=null,totalsConfig:f=null,selectDistinctColumns:C=ye,pendingRowCount:w=0,pendingDataMap:S=rn,frozenColumns:b,formatColumns:v,columnHeaderGroups:T})=>{const R=F.exports.useMemo(()=>Q.getModelViewportColumns(t,o,i,u,h,g,zu),[t,o,i,u,h,g]);return F.exports.useEffect(function(){e.filter=r},[e,r]),F.exports.useEffect(function(){const A=[...c];a!==N.REVERSE_TYPE.NONE&&A.push(E.Table.reverse()),e.sort=A},[e,c,a]),F.exports.useEffect(function(){e.formatter=l},[e,l]),F.exports.useEffect(function(){e.isCustomColumnsAvailable&&(e.customColumns=d)},[e,d]),F.exports.useEffect(function(){e.isFormatColumnsAvailable&&(e.formatColumns=v)},[e,v]),F.exports.useEffect(function(){e.setViewport(n,s,R)},[e,n,s,R]),F.exports.useEffect(function(){e.isRollupAvailable&&(e.rollupConfig=p)},[e,e.isRollupAvailable,p]),F.exports.useEffect(function(){e.isSelectDistinctAvailable&&(e.selectDistinctColumns=C)},[e,C]),F.exports.useEffect(function(){e.isTotalsAvailable&&(e.totalsConfig=f)},[e,e.isTotalsAvailable,f]),F.exports.useEffect(function(){e.pendingRowCount=w},[e,w]),F.exports.useEffect(function(){e.pendingDataMap=S},[e,S]),F.exports.useEffect(function(){b&&e.updateFrozenColumns(b)},[e,b]),F.exports.useEffect(function(){e.columnHeaderGroups=T},[e,T]),null});Al.displayName="IrisGridModelUpdater";const _t=Object.freeze({SORT_UP:"sortUp",SORT_DOWN:"sortDown",CARET_DOWN:"caretDown",CARET_RIGHT:"caretRight",CELL_OVERFLOW:"cellOverflow"}),kr=10,pi=16;class Ys extends ts{constructor(){super(),this.icons={},this.initIcons()}static isFilterValid(t,n){const s=t==null||t.filter!=null,o=n==null||n.filter!=null;return s&&o}initIcons(){this.setIcon(_t.SORT_UP,Ba),this.setIcon(_t.SORT_DOWN,Ga),this.setIcon(_t.CARET_DOWN,Xn),this.setIcon(_t.CARET_RIGHT,ll),this.setIcon(_t.CELL_OVERFLOW,Wa)}setIcon(t,n){const s=Array.isArray(n.icon[4])?n.icon[4][0]:n.icon[4],o=new Path2D(s),i=new Path2D,r={a:pi/n.icon[0],d:pi/n.icon[1]};i.addPath(o,r),this.icons[t]=i}getIcon(t){return this.icons[t]}getSortIcon(t){return t?t.direction===N.sortDirection.ascending?this.getIcon(_t.SORT_UP):t.direction===N.sortDirection.descending?this.getIcon(_t.SORT_DOWN):null:null}drawCanvas(t){super.drawCanvas(t),this.drawScrim(t)}drawGrid(t,n){super.drawGrid(t,n),this.drawCellOverflowButton(n)}drawGridLines(t,n){super.drawGridLines(t,n),this.drawGroupedColumnLine(t,n),this.drawPendingRowLine(t,n)}drawCellContent(t,n,s,o){var h;const{metrics:i,model:r}=n,{modelColumns:l,modelRows:a}=i,c=O(a,o),d=l.get(s);if(d===void 0)return;const u=r.valueForCell(d,c);if(N.isTextType((h=r.columns[d])==null?void 0:h.type)&&(u===null||u==="")){const g=t.font;t.font=`italic ${g}`;const p=u===null?"null":"empty";super.drawCellContent(t,n,s,o,p),t.font=g;return}super.drawCellContent(t,n,s,o)}drawGroupedColumnLine(t,n){const{metrics:s,model:o,theme:i}=n,{groupedColumns:r,columns:l}=o,{maxY:a,allColumnWidths:c,allColumnXs:d}=s;if(r.length===0||i.groupedColumnDividerColor==null)return;const u=r[r.length-1],h=l.findIndex(C=>C.name===u.name),g=d.get(h),p=c.get(h);if(g==null||p==null)return;const f=g+p+.5;t.strokeStyle=i.groupedColumnDividerColor,t.lineWidth=1,t.beginPath(),t.moveTo(f,0),t.lineTo(f,a),t.stroke()}drawPendingRowLine(t,n){const{metrics:s,model:o,theme:i}=n,{allRowYs:r,maxX:l}=s,{pendingRowCount:a}=o;if(a<=0)return;const c=o.rowCount-o.pendingRowCount-o.floatingBottomRowCount;let d=r.get(c);d!=null&&(d-=.5,t.save(),t.setLineDash([4,2]),t.strokeStyle=i.pendingTextColor,t.lineWidth=1,t.beginPath(),t.moveTo(0,d),t.lineTo(l,d),t.stroke(),t.restore())}drawMouseColumnHover(t,n){const{theme:s,metrics:o,hoverSelectColumn:i}=n;if(i==null||s.linkerColumnHoverBackgroundColor==null)return;const{allColumnWidths:r,allColumnXs:l,maxY:a}=o,c=l.get(i),d=r.get(i);M(c),M(d),t.fillStyle=s.linkerColumnHoverBackgroundColor,t.fillRect(c,0,d,a)}drawMouseRowHover(t,n){const{isSelectingColumn:s}=n;s||super.drawMouseRowHover(t,n)}drawScrim(t){const{context:n,loadingScrimProgress:s,metrics:o,theme:i}=t;if(s==null)return;const{width:r,height:l,gridY:a}=o,{scrimBlurSize:c,scrimColor:d}=i;n.save(),n.globalCompositeOperation="color",n.filter=`blur(${c}px)`,d!=null&&(n.fillStyle=d),n.beginPath(),n.rect(0,a,r,l-a),n.clip(),n.fillRect(-c,-c+a,c*2+r,(c*2+(l-a))*s),n.globalCompositeOperation="overlay",n.filter=`blur(${c}px) opacity(15%)`,n.fillRect(-c,-c+a,c*2+r,(c*2+(l-a))*s),n.restore()}drawColumnHeaders(t,n){super.drawColumnHeaders(t,n);const{theme:s,metrics:o,model:i,reverseType:r}=n,{columnHeaderHeight:l}=o;if(this.drawFilterHeaders(t,n),l<=0)return;const{sort:a}=i;if(a.length===1){const c=r!==N.REVERSE_TYPE.NONE;let d;c?d=s.headerReverseBarColor:d=s.headerSortBarColor,this.drawHeaderBar(t,n,d,c?s.reverseHeaderBarHeight:s.sortHeaderBarHeight)}else a.length>1&&(r!==N.REVERSE_TYPE.NONE&&this.drawHeaderBar(t,n,s.headerReverseBarColor,s.reverseHeaderBarHeight,!1),this.drawHeaderBar(t,n,s.headerSortBarColor,s.sortHeaderBarHeight))}drawHeaderBar(t,n,s,o,i=!0){const{theme:r,metrics:l,model:a}=n,{columnHeaderHeight:c,width:d}=l;let u=0;i||(u=o),t.fillStyle=r.headerBarCasingColor,t.fillRect(0,a.columnHeaderMaxDepth*c-o-2+u,d,o+2),t.fillStyle=s,t.fillRect(0,a.columnHeaderMaxDepth*c-o-1+u,d,o)}drawColumnHeadersAtDepth(t,n,s,o,i){const{metrics:r,model:l,isMenuShown:a}=n,{columnHeaderMaxDepth:c}=l,{width:d}=r,u={...o,maxX:i===c-1&&o.maxX===d?d-(a?0:30):o.maxX};super.drawColumnHeadersAtDepth(t,n,s,u,i)}drawColumnHeaderAtIndex(t,n,s,o){var W;super.drawColumnHeaderAtIndex(t,n,s,o);const{metrics:i,model:r,theme:l}=n,{modelColumns:a,allColumnWidths:c,allColumnXs:d,gridX:u,columnHeaderHeight:h,fontWidths:g}=i,{headerHorizontalPadding:p}=l,f=O(c,s,0),C=O(d,s)+u,w=a.get(s);if(w==null)return;const S=N.getSortForColumn(r.sort,w);if(!S)return;const b=this.getSortIcon(S);if(!b)return;const v=r.textForColumnHeader(w);if(v===void 0)return;const T=(W=g.get(t.font))!=null?W:ts.DEFAULT_FONT_WIDTH;M(T);const R=v.length*T,D=u+C+R+p;let{maxX:A}=o;A-=p;const I=u+C+f-p-1,L=D>A?D+1:Math.min(A,I),k=S.direction===N.sortDirection.ascending?-6:-12,x=h*.5+k;t.save(),t.beginPath(),t.rect(C,0,f,h),t.clip(),t.fillStyle=l.headerSortBarColor,t.translate(L,x),t.fill(b),t.restore()}drawFilterHeaders(t,n){const{isFilterBarShown:s,quickFilters:o,advancedFilters:i}=n;s?this.drawExpandedFilterHeaders(t,n):(o!=null&&o.size>0||i!=null&&i.size>0)&&this.drawCollapsedFilterHeaders(t,n)}drawExpandedFilterHeaders(t,n){const{metrics:s,model:o,theme:i,quickFilters:r,advancedFilters:l}=n,{filterBarHeight:a}=i;if(a<=0)return;const{gridX:c,gridY:d,maxX:u,modelColumns:h,visibleColumns:g,allColumnWidths:p,allColumnXs:f}=s,C=d-a;t.save(),t.font=i.font,t.textAlign="left",r!=null&&r.size>0||l!=null&&l.size>0?t.fillStyle=i.filterBarExpandedActiveBackgroundColor:t.fillStyle=i.filterBarExpandedBackgroundColor,t.fillRect(c,C,u,a-1),t.fillStyle=i.headerBarCasingColor,t.fillRect(c,C+a-1,u,1);const w=C;t.strokeStyle=i.filterBarSeparatorColor,t.beginPath();for(let S=0;S<g.length;S+=1){const b=g[S],v=O(h,b),T=O(f,b),R=O(p,b);if(o.isFilterable(v)&&R>0){const D=c+(T!=null?T:0);t.rect(D+.5,w+.5,R,a-2)}}t.stroke();for(let S=0;S<g.length;S+=1){const b=g[S],v=O(p,b),R=O(f,b)+c;this.drawExpandedFilterHeader(t,n,b,R,v)}t.restore()}drawExpandedFilterHeader(t,n,s,o,i){if(i<=0)return;const{metrics:r,theme:l,quickFilters:a,advancedFilters:c}=n,{modelColumns:d,gridY:u}=r,{filterBarHeight:h,filterBarExpandedActiveCellBackgroundColor:g,filterBarErrorColor:p,filterBarHorizontalPadding:f,headerColor:C}=l,w=u-h,S=d.get(s);if(S===void 0)return;const b=a.get(S),v=c.get(S);if(b==null&&v==null)return;let T=null;if(b!=null){const{text:D}=b;if(T=D,T||(T=N.getFilterText(b.filter)),T!=null){const{fontWidths:A}=r;let I=A.get(t.font);(I==null||I===0)&&(I=t.measureText("8").width,I||(I=10));const L=(i-f*2)/I;L<=0?T="":T.length>L&&(T=`${T.substring(0,L-1)}\u2026`)}}if(t.save(),Ys.isFilterValid(v,b)&&g!=null)t.fillStyle=g,t.fillRect(o+1,w+1,i-1,h-3);else if(p!=null){t.fillStyle=p,t.lineWidth=2,t.strokeStyle=p;const D=o+2,A=w+2,I=i-3,L=h-5;t.strokeRect(D,A,I,L)}if(T!=null&&T!==""){const D=o+f,A=w+h*.5+1;t.fillStyle=C,t.fillText(T,D,A)}t.restore()}drawCollapsedFilterHeaders(t,n){const{metrics:s,theme:o}=n,{headerSeparatorColor:i,filterBarCollapsedHeight:r}=o;if(r<=0)return;const{gridX:l,gridY:a,maxX:c,visibleColumns:d,allColumnWidths:u,allColumnXs:h}=s,g=a-r;t.save(),t.fillStyle=i,t.fillRect(l,g,c,r);for(let p=0;p<d.length;p+=1){const f=d[p],C=u.get(f),w=h.get(f);if(w!=null&&C!=null){const S=w+l;this.drawCollapsedFilterHeader(t,n,f,S,C)}}t.restore()}drawCollapsedFilterHeader(t,n,s,o,i){if(i<=0)return;const{metrics:r,theme:l,quickFilters:a,advancedFilters:c}=n,{modelColumns:d,gridY:u}=r,h=d.get(s);if(h===void 0)return;const g=a.get(h),p=c.get(h),{filterBarCollapsedHeight:f,filterBarActiveColor:C,filterBarActiveBackgroundColor:w,filterBarErrorColor:S}=l;t.save();const b=Ys.isFilterValid(p,g);w!=null&&g==null&&p==null?t.fillStyle=w:C!=null&&b?t.fillStyle=C:S!=null&&(t.fillStyle=S);const v=o+1,T=u-f,R=i-1,D=f-1;t.fillRect(v,T,R,D),t.restore()}drawTreeMarker(t,n,s,o,i,r,l){t.save();const{x1:a,y1:c}=i,d=l?this.getIcon(_t.CARET_DOWN):this.getIcon(_t.CARET_RIGHT),u=s+a-2,h=o+c+2.5;t.fillStyle=r,t.textAlign="center",t.translate(u,h),t.fill(d),t.restore()}drawRowFooters(t,n){const{metrics:s,model:o,mouseX:i,mouseY:r,theme:l}=n,{gridY:a,gridX:c,maxX:d,modelRows:u,floatingTopHeight:h,floatingBottomHeight:g,floatingRows:p,rowFooterWidth:f,height:C,horizontalBarHeight:w,verticalBarWidth:S,allRowHeights:b,allRowYs:v,width:T}=s;if(f<=0||p.length===0)return;const{cellHorizontalPadding:R,floatingGridRowColor:D,floatingRowBackgroundColors:A,headerColor:I,rowHoverBackgroundColor:L}=l;t.translate(c,a),t.beginPath();const k=Math.min(d,T-f-S-c);t.fillStyle=A,h>0&&t.rect(k,0,f,h),g>0&&t.rect(k,C-a-w-g,f,g),t.fill();const x=i!=null&&r!=null&&i>=c&&i<=d+f?_.getRowAtY(r,s):null;if(L!=null&&x!==null&&p.includes(x)){t.fillStyle=L;const V=v.get(x),Y=b.get(x);M(V),M(Y),t.fillRect(k,V,f,Y)}if(t.beginPath(),D!=null&&(t.strokeStyle=D),h>0&&(t.moveTo(k+.5,.5),t.lineTo(k+.5,h-.5)),g>0){const V=C-a-w-g;t.moveTo(k-.5,V+.5),t.lineTo(k-.5,V+g-.5)}t.stroke(),t.fillStyle=I,t.textAlign="left";const W=k+R;for(let V=0;V<p.length;V+=1){const Y=p[V],j=b.get(Y),ie=v.get(Y),G=u.get(Y);if(ie!=null&&j!=null&&G!=null){const ee=ie+j*.5;t.fillText(o.textForRowFooter(G),W,ee)}}t.translate(-c,-a)}getTextRenderMetrics(t,n,s,o){const i=super.getTextRenderMetrics(t,n,s,o),{mouseX:r,mouseY:l,metrics:a}=n;if(r==null||l==null)return i;const{column:c,row:d}=_.getGridPointFromXY(r,l,a);if(s===c&&o===d){const{left:u}=this.getCellOverflowButtonPosition(n);this.shouldRenderOverflowButton(n)&&u!=null&&(i.width=u-a.gridX-i.x)}return i}shouldRenderOverflowButton(t){var C,w;const{context:n,mouseX:s,mouseY:o,metrics:i,model:r,theme:l}=t;if(s==null||o==null)return!1;const{row:a,column:c,modelRow:d,modelColumn:u}=_.getCellInfoFromXY(s,o,i);if(a==null||c==null||d==null||u==null||!N.isStringType(r.columns[u].type))return!1;const h=(C=r.textForCell(u,d))!=null?C:"",{width:g}=super.getTextRenderMetrics(n,t,c,a),p=(w=i.fontWidths.get(l.font))!=null?w:Ys.DEFAULT_FONT_WIDTH;n.save(),n.font=l.font;const f=this.getCachedTruncatedString(n,h,g,p,r.truncationCharForCell(u,d));return n.restore(),h!==""&&f!==h}getCellOverflowButtonPosition({mouseX:t,mouseY:n,metrics:s,theme:o}){const i={left:null,top:null,width:null,height:null};if(t==null||n==null||!s)return i;const{rowHeight:r,columnWidth:l,left:a,top:c}=_.getCellInfoFromXY(t,n,s);M(a),M(l),M(c);const{width:d,verticalBarWidth:u}=s,{cellHorizontalPadding:h}=o,g=pi+2*h,p=r,C=Math.min(s.gridX+a+l,d-u)-g,w=s.gridY+c;return{left:C,top:w,width:g,height:p}}drawCellOverflowButton(t){const{context:n,mouseX:s,mouseY:o,theme:i}=t;if(s==null||o==null||!this.shouldRenderOverflowButton(t))return;const{left:r,top:l,width:a,height:c}=this.getCellOverflowButtonPosition(t),{cellHorizontalPadding:d,overflowButtonColor:u,overflowButtonHoverColor:h}=i;n.save(),h!=null&&r!=null&&a!=null&&l!=null&&c!=null&&s>=r&&s<=r+a&&o>=l&&o<=l+c?n.fillStyle=h:u!=null&&(n.fillStyle=u);const g=this.getIcon(_t.CELL_OVERFLOW);r!=null&&l!=null&&n.translate(r+d,l+2),n.fill(g),n.restore()}getExpandButtonPosition({mouseX:t,mouseY:n,metrics:s,theme:o},i){const r={left:null,top:null,width:null,height:null};if(t==null||n==null||i==null||!s)return r;const{rowHeight:l,left:a,top:c}=_.getCellInfoFromXY(t,n,s);M(a),M(l),M(c);const{cellHorizontalPadding:d}=o,u=kr+2*d,h=Math.max(a+kr*i,s.gridX),g=s.gridY+c;return{left:h,top:g,width:u,height:l}}}const qu="12px Fira Sans, sans-serif",Yu="#f0f0ee",Xu="#1a171a",te={"grid-bg":"#211f22",font:qu,white:Yu,black:Xu,"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","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"},Ml=Object.freeze({backgroundColor:te["grid-bg"],white:te.white,black:te.black,font:te.font,headerBackgroundColor:te["header-bg"],headerColor:te["header-color"],headerSeparatorColor:te["header-separator-color"],headerSeparatorHoverColor:te["header-separator-hover-color"],headerHiddenSeparatorHoverColor:te["header-hidden-separator-hover-color"],headerSortBarColor:te["header-sort-bar-color"],headerReverseBarColor:te["header-reverse-bar-color"],headerBarCasingColor:te["header-bar-casing-color"],headerFont:te["header-font"],rowBackgroundColors:te["row-background-colors"],rowHoverBackgroundColor:te["row-hover-bg"],selectionColor:te["selection-color"],selectionOutlineColor:te["selection-outline-color"],selectionOutlineCasingColor:te["selection-outline-casing-color"],selectedRowHoverBackgroundColor:te["selected-row-hover-bg"],scrollBarBackgroundColor:te["scroll-bar-bg"],scrollBarHoverBackgroundColor:te["scroll-bar-hover-bg"],scrollBarCasingColor:te["scroll-bar-casing-color"],scrollBarCornerColor:te["scroll-bar-corner-color"],scrollBarColor:te["scroll-bar-color"],scrollBarHoverColor:te["scroll-bar-hover-color"],scrollBarActiveColor:te["scroll-bar-active-color"],scrollBarSelectionTickColor:te["selected-row-hover-bg"],scrollBarActiveSelectionTickColor:te["scroll-bar-active-selection-tick-color"],textColor:te["text-color"],positiveNumberColor:te["positive-number-color"],negativeNumberColor:te["negative-number-color"],zeroNumberColor:te["zero-number-color"],dateColor:te["date-color"],pendingTextColor:te["pending-text-color"],errorTextColor:te["error-text-color"],nullStringColor:te["null-string-color"],filterBarActiveBackgroundColor:te["filter-bar-active-bg"],filterBarExpandedBackgroundColor:te["filter-bar-expanded-bg"],filterBarExpandedActiveBackgroundColor:te["filter-bar-expanded-active-bg"],filterBarExpandedActiveCellBackgroundColor:te["filter-bar-expanded-active-cell-bg"],filterBarSeparatorColor:te["filter-bar-separator-color"],filterBarActiveColor:te["filter-bar-active-color"],filterBarErrorColor:te["filter-bar-error-color"],filterIconColor:te["filter-icon-color"],scrimColor:te["scrim-color"],contextMenuSortIconColor:te["context-menu-sort-icon-color"],contextMenuReverseIconColor:te["context-menu-reverse-icon-color"],allowRowResize:!1,autoSelectRow:!0,gridColumnColor:null,gridRowColor:null,groupedColumnDividerColor:te["grouped-column-divider-color"],columnHoverBackgroundColor:null,headerHorizontalPadding:12,scrollBarSize:13,scrollBarHoverSize:16,minScrollHandleSize:24,rowHeight:parseInt(te["row-height"],10)||19,columnWidth:100,rowHeaderWidth:0,rowFooterWidth:60,columnHeaderHeight:parseInt(te["header-height"],10)||30,filterBarHeight:30,filterBarCollapsedHeight:5,sortHeaderBarHeight:2,reverseHeaderBarHeight:4,filterBarHorizontalPadding:4,scrimBlurSize:25,minScrimTransitionTime:150,maxScrimTransitionTime:350,scrollSnapToRow:!0,linkerColumnHoverBackgroundColor:te["linker-column-hover-bg"],treeLineColor:te["tree-line-color"],treeMarkerColor:te["tree-marker-color"],treeMarkerHoverColor:te["tree-marker-hover-color"],floatingGridColumnColor:null,floatingGridRowColor:te["floating-grid-row-color"],floatingRowBackgroundColors:te["floating-row-background-colors"],floatingDividerInnerColor:te["floating-divider-inner-color"],floatingDividerOuterColor:te["floating-divider-outer-color"],overflowButtonColor:te["overflow-button-color"],overflowButtonHoverColor:te["overflow-button-hover-color"]});const fi=le.module("ColumnStatistics"),Ku={SIZE:"Number of Rows"},Ii=class extends F.exports.Component{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}}static getStatsLabel(e){var t;return(t=Ku[e])!=null?t:e.split(" ").map(n=>n[0].toUpperCase()+n.substr(1).toLowerCase()).join(" ")}componentDidMount(){this.maybeGenerateStatistics()}componentWillUnmount(){this.cancelablePromise&&this.cancelablePromise.cancel()}maybeGenerateStatistics(){const{model:e}=this.props,t=e.rowCount-e.pendingRowCount;this.setState({numRows:t}),e.isColumnStatisticsAvailable?t<Ii.AUTO_GENERATE_LIMIT&&this.handleGenerateStatistics():this.setState({loading:!1})}handleGenerateStatistics(){this.setState({loading:!0});const{column:e,model:t}=this.props;this.cancelablePromise=ze.makeCancelable(t.columnStatistics(e)),this.cancelablePromise.then(this.handleStatistics).catch(this.handleError)}handleStatistics(e){fi.debug("Received statistics",e);const{model:t,onStatistics:n}=this.props,s=[];e.statisticsMap.forEach((o,i)=>{s.push({operation:Ii.getStatsLabel(i),value:o,type:e.getType(i)})}),e.uniqueValues.forEach((o,i)=>{s.push({operation:i,className:"column-statistics-unique-value",value:o,type:"long"})}),this.setState({loading:!1,statistics:s,numRows:t.rowCount-t.pendingRowCount}),n()}handleError(e){if(e!=null&&ze.isCanceled(e)){fi.debug("Called handleError on a cancelled promise result");return}fi.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:o,numRows:i}=this.state,r=!s&&n==null&&o==null&&t.isColumnStatisticsAvailable,l=[],a=e.type.substring(e.type.lastIndexOf(".")+1),c=e.description===null?null:e.description;if(o!=null)for(let g=0;g<o.length;g+=1){const{operation:p,className:f,value:C,type:w}=o[g],S=w?t.displayString(C,w):t.displayString(C,e.type,e.name),b=y(De.Fragment,{children:[m("div",{className:Z("column-statistic-operation",f),children:p}),m("div",{className:"column-statistic-value",children:S})]},p);l.push(b)}const d=Me(t)&&t.hasExpandableRows?"Expanded Rows":"Number of Rows",u=t.displayString(i,"long"),h=t.getColumnIndexByName(e.name);return y("div",{className:"column-statistics",children:[y("div",{className:"column-statistics-title",children:[e.name,y("span",{className:"column-statistics-type",children:["\xA0(",a,")"]}),m(gl,{className:"column-statistics-copy",tooltip:"Copy column name",copy:e.name})]}),c!=null&&m("div",{className:"column-statistics-description",children:c}),h!=null&&!t.isColumnMovable(h)&&y("div",{className:"column-statistics-status",children:[m(J,{icon:t.isColumnFrozen(h)?$a:za,className:"mr-1"}),t.isColumnFrozen(h)?"Frozen":"Not movable"]}),y("div",{className:"column-statistics-grid",children:[o==null&&y(Oe,{children:[m("div",{className:"column-statistic-operation",children:d}),m("div",{className:"column-statistic-value",children:u})]}),l]}),r&&m(z,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,children:"Generate Stats"}),n!=null&&m("div",{className:"error-message",children:`${n}`}),o&&!s&&m(z,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,icon:m(J,{icon:qa,className:"mr-1"}),children:"Refresh"}),s&&y("div",{className:"column-statistics-loading",children:[m(dn,{className:"mr-2"}),"Calculating Stats..."]})]})}};let Ol=Ii;Ol.AUTO_GENERATE_LIMIT=1e5;const Fo=le.module("AdvancedFilterCreatorFilterItem");class ji extends F.exports.PureComponent{constructor(t){super(t),this.getCachedIsValid=Fe((i,r,l,a)=>{try{return!l||N.makeAdvancedValueFilter(i,r,l,a)!=null}catch{return!1}}),this.handleDelete=this.handleDelete.bind(this),this.handleTypeChange=this.handleTypeChange.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.typeDropdown=null;const{value:n="",filterTypes:s,selectedType:o=s[0]}=t;this.state={selectedType:o,value:n}}static getLabelForFilter(t,n){try{if(N.isNumberType(t)||N.isCharType(t))return _d(n);if(N.isTextType(t))return Pd(n);if(N.isDateType(t))return Hd(n);if(N.isBooleanType(t))return Vd(n);throw new Error(`Unrecognized column type: ${t}`)}catch(s){return Fo.warn(s),""}}componentDidMount(){var t;(t=this.typeDropdown)==null||t.focus()}componentDidUpdate(t){const{value:n,selectedType:s}=this.props;s!==void 0&&t.selectedType!==s&&this.setState({selectedType:s}),n!==void 0&&t.value!==n&&this.setState({value:n})}handleTypeChange(t){const n=t.target.value;Fo.debug2("typeChange",n),this.setState({selectedType:n});const{onChange:s}=this.props,{value:o}=this.state;o!=null&&o.length>0&&s(n,o)}handleValueChange(t){Fo.debug2("valueChange");const{value:n}=t.target;this.setState({value:n});const{onChange:s}=this.props,{selectedType:o}=this.state;o!=null&&s(o,n)}handleDelete(){Fo.debug("delete");const{onDelete:t}=this.props;t()}render(){const{column:t,filterTypes:n,formatter:s}=this.props,{selectedType:o,value:i}=this.state,r=!N.isBooleanType(t.type),l=[],a=this.getCachedIsValid(t,o,i,s.timeZone);for(let c=0;c<n.length;c+=1){const d=n[c],u=ji.getLabelForFilter(t.type,d),h=m("option",{value:d,children:u},d);l.push(h)}return m("div",{className:"advanced-filter-creator-filter-item",children:y("div",{className:"form-row",children:[m("div",{className:"form-group col",children:m("select",{className:"form-control custom-select",value:o,onChange:this.handleTypeChange,ref:c=>{this.typeDropdown=c},children:l})}),r&&m("div",{className:"form-group col",children:m("div",{className:"input-group",children:m("input",{type:"text",className:Z("form-control",{error:!a}),placeholder:"Enter value",value:i,onChange:this.handleValueChange})})}),m("div",{className:"form-group col-1 px-0",children:m(z,{kind:"ghost",className:"w-100 h-100 p-0 m-0",onClick:this.handleDelete,icon:un,tooltip:"Remove Filter"})})]})})}}const Lr=le.module("AdvancedFilterCreatorSelectValueList"),Ni=class extends F.exports.PureComponent{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}}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}componentDidMount(){const{table:e}=this.props;e&&this.startListening(e)}componentDidUpdate(e){const{filters:t,invertSelection:n,selectedValues:s,table:o}=this.props;e.table!==o&&(e.table&&this.stopListening(e.table),o&&this.startListening(o),this.resetViewport()),e.invertSelection!==n&&this.setState({selectedValues:[]},this.handleSelectionUpdate),e.selectedValues!==s&&this.setState({selectedValues:s},this.handleSelectionUpdate),e.filters!==t&&(o==null||o.applyFilter(t),this.resetViewport())}componentWillUnmount(){const{table:e}=this.props;e&&this.stopListening(e)}handleSelect(e,t){const{invertSelection:n}=this.props;let{selectedValues:s}=this.state;s=[...s];const o=Ni.indexOf(t,s);o>=0?s.splice(o,1):s.push(t);let i=o<0;n&&(i=!i);const{offset:r}=this.state;let{items:l}=this.state;l=[...l];const a=e-r;a>=0&&a<l.length&&(l[a].isSelected=i),this.setState({items:l,selectedValues:s});const{onChange:c}=this.props;c(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:o}=s,i=[],r=t.columns[0];for(let a=0;a<s.rows.length;a+=1){const d=s.rows[a].get(r),u=n.getFormattedString(d,r.type,r.name),h=this.isValueSelected(d);i.push({displayValue:u,value:d,isSelected:h})}Lr.debug2("Received table update:",o,i.length);const l=t.size;this.setState({itemCount:l,items:i,offset:o,isLoading:!1})}isValueSelected(e){const{invertSelection:t}=this.props,{selectedValues:n}=this.state,s=Ni.indexOf(e,n);return t?s<0:s>=0}startListening(e){e.addEventListener(E.Table.EVENT_UPDATED,this.handleTableUpdate)}stopListening(e){e.removeEventListener(E.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 o=t-e+1,i=Math.max(0,e-o*3),r=Math.max(i,t+o*3);Lr.debug2("Setting viewport",i,",",r),s.setViewport(i,r)}render(){const{offset:e,isLoading:t,items:n,itemCount:s}=this.state;return y("div",{className:"select-value-list-wrapper",children:[m(Ya,{itemCount:s,items:n,offset:e,onSelect:this.handleSelect,onViewportChange:this.handleViewportChange,ref:o=>{this.list=o}}),m($t,{in:t,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:m("div",{className:"loading-list",children:m(dn,{className:"loading-spinner-large"})})})]})}};let xl=Ni;xl.defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{}};const kl=class extends F.exports.PureComponent{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:o}=this.props;e.table!==o&&this.initSearchTable(),e.invertSelection!==n&&this.setState({invertSelection:n}),e.selectedValues!==s&&this.setState({selectedValues:s});const{table:i,searchText:r}=this.state;i!==t.table&&(t.table!=null&&t.table.close(),i!=null&&this.startUpdateFilterTimer()),r!==t.searchText&&this.startUpdateFilterTimer()}componentWillUnmount(){const{table:e}=this.state;e!=null&&e.close(),this.searchTablePromise=void 0,this.stopUpdateFilterTimer()}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"),o=n.getFormattedString(t.totalSize,"long");let i="";return e<1e6&&(i="Displaying "),`${i}${s} of ${o}`}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,kl.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==null?void 0:e.columns[0],o=[];if(s==null)return;let i;if(t.length>0){let r=null;N.isCharType(s.type)?r=N.makeQuickFilter(s,t):N.isTextType(s.type)?r=N.makeQuickFilter(s,`~${t}`,n):r=N.makeQuickFilter(s,`>=${t}`,n),r!=null?o.push(r):i="Invalid search text"}this.setState({filters:o,error:i})}render(){const{error:e,filters:t,invertSelection:n,selectedValues:s,searchText:o,table:i}=this.state,{formatter:r,showSearch:l}=this.props,a=this.getColumnName(),c=this.getDisplayedValueText(),d=a?`Find ${a}...`:"";return y("div",{className:"advanced-filter-creator-select-value",children:[y("div",{className:l?"form-group":"",children:[m("label",{htmlFor:"advanced-filter-creator-select-value-input",children:"Select Values"}),l&&m("input",{type:"text",className:Z("form-control",{"is-invalid":e!=null}),id:"advanced-filter-creator-select-value-input",placeholder:d,value:o,onChange:this.handleSearchChange})]}),m(xl,{table:i,filters:t,invertSelection:n,selectedValues:s,formatter:r,onChange:this.handleListChange}),y("div",{className:"advanced-filter-creator-select-meta-row",children:[y("div",{children:[m(z,{kind:"ghost",onClick:this.handleSelectAllClick,children:"Select All"}),m(z,{kind:"ghost",onClick:this.handleClearAllClick,children:"Clear"})]}),m($t,{in:c!=null,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:m("div",{className:"row-count-info",children:c})})]})]})}};let Zi=kl;Zi.searchDebounceTime=250;Zi.defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{},showSearch:!0};const Ps=le.module("AdvancedFilterCreator"),Yn=class extends F.exports.PureComponent{constructor(e){var r,l;super(e),this.getFilterTypes=Fe(a=>N.getFilterTypes(a)),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=De.createRef();const{options:t}=e;let{filterOperators:n,invertSelection:s,selectedValues:o}=t;const i=(l=(r=t.filterItems)==null?void 0:r.map(({selectedType:a,value:c})=>({selectedType:a,value:c,key:Ln()})))!=null?l:[];i.length===0&&i.push(Yn.makeFilterItem()),n==null&&(n=[]),s==null&&(s=!0),o==null&&(o=[]),this.state={filterItems:i,filterOperators:n,invertSelection:s,selectedValues:o,valuesTableError:null,valuesTable:void 0}}static makeFilterItem(){return{key:Ln()}}componentDidMount(){this.initValuesTable()}componentWillUnmount(){this.debounceTimeout!=null&&(clearTimeout(this.debounceTimeout),this.sendUpdate()),this.valuesTablePromise!=null&&this.valuesTablePromise.cancel()}getFilterChangeHandler(e){return this.handleFilterChange.bind(this,e)}getFilterDeleteHandler(e){return this.handleFilterDelete.bind(this,e)}initValuesTable(){const{model:e,column:t}=this.props;if(!e.isValuesTableAvailable){Ps.debug("No values table for this model, just ignore");return}this.valuesTablePromise=N.makeCancelableTablePromise(e.valuesTable(t)),this.valuesTablePromise.then(n=>{const s=n.columns[0].sort().asc();n.applySort([s]),this.setState({valuesTable:n})}).catch(n=>{ze.isCanceled(n)||(Ps.error("Unable to open values table",n),this.setState({valuesTableError:n}))})}handleFocusTrapEnd(){var e,t;((t=(e=this.focusTrapContainer)==null?void 0:e.current)==null?void 0:t.querySelector("button,select,input,textarea")).focus()}handleFocusTrapStart(){var t,n;const e=(n=(t=this.focusTrapContainer)==null?void 0:t.current)==null?void 0:n.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(Yn.makeFilterItem()),t=t.concat(Gt.and),this.setState({filterItems:e,filterOperators:t})}handleAddOr(){let{filterItems:e,filterOperators:t}=this.state;e=e.concat(Yn.makeFilterItem()),t=t.concat(Gt.or),this.setState({filterItems:e,filterOperators:t})}handleChangeFilterOperator(e,t){let{filterOperators:n}=this.state;n=[...n],Ld(t),n[e]=t,this.setState({filterOperators:n}),this.startUpdateTimer()}handleFilterChange(e,t,n){let{filterItems:s}=this.state;s=[...s];const{key:o}=s[e];s[e]={key:o,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(Yn.makeFilterItem()),this.setState({filterItems:t,filterOperators:n}),this.startUpdateTimer()}handleSelectValueChange(e,t){this.setState({selectedValues:e,invertSelection:t}),this.startUpdateTimer()}handleReset(){Ps.debug("Resetting Advanced Filter"),this.setState({filterItems:[Yn.makeFilterItem()],filterOperators:[],selectedValues:[],invertSelection:!0}),this.startUpdateTimer()}handleSortDown(e){const t=_n.isModifierKeyDown(e);this.sortTable(N.sortDirection.descending,t)}handleSortUp(e){const t=_n.isModifierKeyDown(e);this.sortTable(N.sortDirection.ascending,t)}handleSubmit(e){Ps.debug("Submitting Advanced Filter"),this.stopUpdateTimer(),this.sendUpdate(),e.preventDefault()}handleDone(e){Ps.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,Yn.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:o,onFilterChange:i,model:r}=this.props,{formatter:l}=r,a=e.filter(({selectedType:h,value:g})=>h!=null&&g!=null&&g!==""),c=t.filter((h,g)=>h!=null&&e[g].selectedType!=null&&e[g].value!=null&&e[g].value!=="").slice(0,a.length-1),d={filterItems:a,filterOperators:c,invertSelection:n,selectedValues:s},u=N.makeAdvancedFilter(o,d,l.timeZone);i(o,u,d)}render(){const{column:e,model:t,sortDirection:n,formatter:s}=this.props,{filterItems:o,filterOperators:i,invertSelection:r,selectedValues:l,valuesTable:a,valuesTableError:c}=this.state,{isValuesTableAvailable:d}=t,u=N.isBooleanType(e.type),h=N.isDateType(e.type),g=this.getFilterTypes(e.type),p=e.type.substring(e.type.lastIndexOf(".")+1),f=[];if(!u&&g.length)for(let S=0;S<o.length;S+=1){const b=o[S],{key:v,selectedType:T,value:R}=b,D=m(ji,{column:e,filterTypes:g,onChange:this.getFilterChangeHandler(S),onDelete:this.getFilterDeleteHandler(S),selectedType:T,value:R,formatter:s},v);if(f.push(D),S<i.length){const I=i[S]===Gt.and,L=y("div",{className:"form-row justify-content-end advanced-filter-creator-filter-operator",children:[m(z,{kind:"ghost",className:Z("filter-operator",{active:I}),onClick:()=>this.handleChangeFilterOperator(S,Gt.and),children:"AND"}),m(z,{kind:"ghost",className:Z("filter-operator",{active:!I}),onClick:()=>this.handleChangeFilterOperator(S,Gt.or),children:"OR"})]},`filterOperator${v}`);f.push(L)}}const C=this.shouldShowAddFilter(),w=y("div",{className:Z("form-row justify-content-end add-filter-item",{hidden:!C}),children:[m("span",{className:"text-muted",children:m(J,{icon:vs})}),m(z,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddAnd,disabled:!C,tooltip:"Add filter with AND",children:"AND"}),m(z,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddOr,disabled:!C,tooltip:"Add filter with OR",children:"OR"})]},"addFilterItem");return f.push(w),y("div",{className:"advanced-filter-creator",role:"presentation",children:[m("div",{tabIndex:0,onFocus:this.handleFocusTrapStart}),y("form",{onSubmit:this.handleSubmit,ref:this.focusTrapContainer,children:[y("div",{className:"title-bar",children:[m("h6",{className:"advanced-filter-title",children:"Advanced Filters"}),y("div",{className:"advanced-filter-menu-buttons",children:[m(z,{kind:"ghost",className:Z("sort-operator",{active:n===N.sortDirection.descending}),onClick:this.handleSortDown,icon:fr,tooltip:`Sort ${e.name} Descending`}),m(z,{kind:"ghost",className:Z("sort-operator",{active:n===N.sortDirection.ascending}),onClick:this.handleSortUp,icon:m(J,{icon:fr,rotation:180}),tooltip:`Sort ${e.name} Ascending`})]})]}),m("hr",{}),y("div",{className:"advanced-filter-column-name",children:[e.name,"\xA0",y("span",{className:"column-type",children:["(",p,")"]})]}),f,d&&c==null&&y(Oe,{children:[!u&&m("hr",{}),m("div",{className:"form-group",children:m(Zi,{table:a,onChange:this.handleSelectValueChange,invertSelection:r,selectedValues:l,formatter:s,showSearch:!h,timeZone:s.timeZone})})]}),y("div",{className:"form-row justify-content-end",children:[m(z,{kind:"secondary",className:"mr-2",onClick:this.handleReset,children:"Reset"}),m(z,{kind:"primary",onClick:this.handleDone,children:"Done"})]})]}),m("div",{tabIndex:0,onFocus:this.handleFocusTrapEnd})]})}};let Ji=Yn;Ji.debounceFilterUpdate=250;Ji.defaultProps={options:{filterItems:null,filterOperators:null,invertSelection:!0,selectedValues:[]},sortDirection:null};const Pr=le.module("Aggregations"),Qu=[be.SUM,be.ABS_SUM,be.MIN,be.MAX,be.VAR,be.AVG,be.STD,be.FIRST,be.LAST,be.COUNT_DISTINCT,be.DISTINCT,be.COUNT,be.UNIQUE];function ju({isRollup:e,settings:t,onChange:n,onEdit:s}){const{aggregations:o,showOnTop:i}=t,r=F.exports.useMemo(()=>Qu.filter(I=>!o.some(L=>L.operation===I)),[o]),[l,a]=F.exports.useState(r[0]),[c,d]=F.exports.useState([]),u=F.exports.useCallback(I=>{n({...t,...I})},[n,t]),h=F.exports.useCallback(I=>{u({aggregations:I})},[u]),g=F.exports.useCallback(I=>{u({showOnTop:I})},[u]),p=F.exports.useCallback(()=>{Pr.debug("handleDragStart"),dt.startDragging()},[]),f=F.exports.useCallback(({destination:I,source:L})=>{if(Pr.debug("handleDragEnd",I,L),dt.stopDragging(),I===null)return;let k=I.index;L.index<I.index&&(k+=1);const x=[...o],W=dt.reorder(x,c,x,k),V=dt.adjustDestinationIndex(k,c),Y=[[V,V+W.length-1]];h(x),d(Y)},[h,o,c,d]),C=F.exports.useCallback(I=>{a(I)},[a]),w=F.exports.useCallback(()=>{h([...o,{operation:l,selected:[],invert:!0}])},[o,l,h]),S=F.exports.useCallback(I=>{h(o.filter((L,k)=>k!==I))},[o,h]),b=F.exports.useCallback(I=>{d(I)},[d]),v=F.exports.useCallback(I=>{const L=o[I];On.isRollupOperation(L.operation)||s(L)},[o,s]),T=F.exports.useCallback(I=>{g(I.target.value==="true")},[g]);F.exports.useEffect(function(){r.length>0&&!r.includes(l)&&a(r[0])},[r,l]);const R=F.exports.useCallback(({item:I,itemIndex:L,isClone:k=!1,selectedCount:x})=>{const W=I.operation,V=k?`${x}`:void 0,Y=k?"item-list-item-clone":void 0,j=On.isRollupOperation(I.operation),ie=!k&&!j;return y(Oe,{children:[y("div",{className:Z("item-list-item-content","draggable-item-list-item-content",Y),children:[y("span",{className:"title",children:[W,!e&&j&&y("span",{className:"small text-warning",children:[m(J,{icon:al})," Requires rollup"]})]}),Dt.renderBadge({text:V}),Dt.renderHandle()]}),!k&&y(Oe,{children:[m(z,{kind:"ghost",className:"btn-edit",icon:Pi,tooltip:"Edit Columns",onClick:()=>s(I),disabled:!ie}),m(z,{kind:"ghost",className:"btn-delete",icon:un,tooltip:"Delete Aggregation",onClick:()=>S(L)})]})]})},[S,s,e]),D=r.length>0,A=o.length>0;return y("div",{className:"aggregations",children:[D&&y("div",{className:"form-inline",children:[m(ed,{onChange:C,value:l,children:r.map(I=>m(Jc,{value:I,children:I},I))}),y("button",{type:"button",className:"btn btn-link btn-add",onClick:w,children:[m(J,{icon:vs}),"Add Aggregation"]})]}),D&&A&&m("hr",{}),A&&y(Oe,{children:[!e&&y("div",{className:"form-inline",children:[m("label",{children:"Placement:\xA0"}),y(zi,{onChange:T,value:`${i}`,children:[m(Zn,{value:"true",children:"Top"}),m(Zn,{value:"false",children:"Bottom"})]})]}),m(zo,{onDragStart:p,onDragEnd:f,children:m(Dt,{className:"selected-aggregations",itemCount:o.length,items:o,renderItem:R,offset:0,onSelectionChange:b,onSelect:v,selectedRanges:c,isMultiSelect:!0})})]})]})}const Zu=30;function Ju({aggregation:e,columns:t,onChange:n}){const[s,o]=F.exports.useState(-1),[i,r]=F.exports.useState(-1),[l,a]=F.exports.useState(0),{invert:c,selected:d}=e,u=F.exports.useRef(null),h=F.exports.useCallback(T=>d.includes(T)?!c:c,[c,d]),g=F.exports.useMemo(()=>{let T=Qi(t,e.operation);return l!==0&&(T=N.sortColumns(T,l===1)),T},[t,e.operation,l]),p=F.exports.useMemo(()=>s>=0?g.slice(s,i+1).map(T=>({value:T.name,displayValue:T.name,isSelected:h(T.name)})):[],[g,h,i,s]),f=F.exports.useCallback(T=>{const{name:R}=g[T],D=d.indexOf(R);let A=[...d],I=c;D>=0?A.splice(D,1):(A.push(R),A.length===g.length&&(A=[],I=!c)),n({...e,selected:A,invert:I})},[e,c,g,d,n]),C=F.exports.useCallback(()=>{a(0),n({...e,selected:[],invert:!0})},[e,n]),w=F.exports.useCallback((T,R)=>{o(T),r(R)},[o,r]),S=F.exports.useCallback(()=>{d.length===0?n({...e,invert:!c}):n({...e,selected:[],invert:!0})},[e,c,n,d]),b=d.length===0?c:null,v=d.length!==0||!c||l!==0;return y("div",{role:"menu",className:"aggregation-edit",children:[m("div",{className:"top-menu",children:y("div",{className:"form-inline",children:[m(an,{checked:b,onChange:S,children:"Toggle All"}),m("div",{className:"spacer"}),m($t,{in:v,timeout:We.transitionSlowMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:m(z,{kind:"ghost",className:"btn-reset",onClick:C,children:"Reset"})}),m(z,{kind:"ghost",className:Z({active:l===1}),icon:_i,tooltip:"Sort ascending",onClick:()=>a(1)}),m(z,{kind:"ghost",className:Z({active:l===2}),icon:Hi,tooltip:"Sort descending",onClick:()=>a(2)})]})}),m("div",{className:"aggregation-edit-item-list",children:m(ko,{itemCount:g.length,items:p,offset:s,renderItem:({item:T})=>m(an,{checked:h(T.value),children:T.displayValue}),onSelect:f,onViewportChange:w,rowHeight:Zu,focusSelector:"input",ref:u})})]})}function eh(e){return m("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...e,children:y("g",{fill:"none",fillRule:"evenodd",children:[m("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),m("path",{fill:"#7DA4FF",d:"M8 26h4v15H8zM15 17h4v24h-4zM22 21h4v20h-4zM29 17h4v24h-4zM36 11h4v30h-4z"})]})})}function th(e){return m("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...e,children:y("g",{fill:"none",fillRule:"evenodd",children:[m("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),m("path",{fill:"#7DA4FF",d:"M7 34h4v8H7zM12 31h4v11h-4zM17 27h4v15h-4zM22 22h4v20h-4zM27 27h4v15h-4zM32 29h4v13h-4zM37 31h4v11h-4z"})]})})}function nh(e){return m("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...e,children:y("g",{fill:"none",fillRule:"evenodd",children:[m("path",{fill:"#C1C0C0",d:"M4 4h1v40H4zM44 43v1H5v-1z"}),m("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"}),m("path",{stroke:"#BECDEF",d:"M8.244 37.926L17 33.496l5 .87 10.637-10.35 10.615-1.381"})]})})}function sh(e){return m("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...e,children:y("g",{fill:"none",fillRule:"evenodd",children:[m("path",{d:"M24 10c7.732 0 14 6.268 14 14s-6.268 14-14 14-14-6.268-14-14h14V10z",fill:"#80A6FF"}),m("path",{d:"M10 24c0-7.732 6.268-14 14-14v14H10z",fill:"#C1C0C0"})]})})}function oh(e){return m("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...e,children:y("g",{fill:"none",fillRule:"evenodd",children:[m("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),m("path",{fill:"#939293",d:"M44 34v1H4v-1zM44 25v1H4v-1zM44 16v1H4v-1z"}),m("circle",{fill:"#7DA4FF",cx:9.5,cy:37.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:16.5,cy:30.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:22.5,cy:36.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:28.5,cy:30.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:15.5,cy:38.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:23.5,cy:25.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:19.5,cy:19.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:29.5,cy:19.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:32.5,cy:26.5,r:1.5}),m("circle",{fill:"#7DA4FF",cx:36.5,cy:13.5,r:1.5})]})})}function ih(e){return y("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[m("rect",{width:"48",height:"48",fill:"none"}),m("rect",{x:"26",y:"10",width:"15",height:"4",fill:"#9FDE70"}),m("rect",{x:"26",y:"22",width:"15",height:"4",fill:"#9FDE70"}),m("rect",{x:"26",y:"28",width:"15",height:"4",fill:"#FFD95C"}),m("rect",{x:"26",y:"34",width:"15",height:"4",fill:"#9FDE70"})]})}function rh(e){return y("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[m("rect",{width:"48",height:"48",fill:"none"}),m("rect",{x:"4",y:"16",width:"40",height:"4",fill:"#FFD95C"}),m("rect",{x:"4",y:"10",width:"40",height:"4",fill:"#78DCE8"}),m("rect",{x:"4",y:"34",width:"40",height:"4",fill:"#78DCE8"})]})}const _r=le.module("ChartBuilder"),Xe=class extends F.exports.PureComponent{static getTypeName(e){switch(e){case E.plot.SeriesPlotStyle.LINE:return"Line";case E.plot.SeriesPlotStyle.BAR:return"Bar";case E.plot.SeriesPlotStyle.SCATTER:return"Scatter";case E.plot.SeriesPlotStyle.PIE:return"Pie";case E.plot.SeriesPlotStyle.HISTOGRAM:return"Histogram";default:return e}}static getTypeIcon(e){switch(e){case E.plot.SeriesPlotStyle.LINE:return m(nh,{});case E.plot.SeriesPlotStyle.BAR:return m(eh,{});case E.plot.SeriesPlotStyle.SCATTER:return m(oh,{});case E.plot.SeriesPlotStyle.PIE:return m(sh,{});case E.plot.SeriesPlotStyle.HISTOGRAM:return m(th,{});default:return null}}static getMaxSeriesCount(e){switch(e){case E.plot.SeriesPlotStyle.PIE:return 1;case E.plot.SeriesPlotStyle.HISTOGRAM:return 0;default:return 100}}static getXAxisLabel(e){switch(e){case E.plot.SeriesPlotStyle.PIE:return"Labels";case E.plot.SeriesPlotStyle.HISTOGRAM:return"Data";default:return"X-Axis"}}static getSeriesLabel(e){switch(e){case E.plot.SeriesPlotStyle.PIE:return"Values";default:return"Series"}}static makeSeriesItem(e){return{id:Ln.generate(),value:e}}static makeDefaultSeriesItems(e,t){if(Xe.getMaxSeriesCount(e)===0||t==null||t.length===0)return[];const s=t.length>1?t[1].name:t[0].name;return[Xe.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=Xe.types[0],o=Xe.getDefaultXAxis(s,n),i=Xe.makeDefaultSeriesItems(s,n);this.state={type:s,seriesItems:i,xAxis:o,isLinked:!0}}handleAddSeries(){this.setState(e=>{const{seriesItems:t}=e,n=[...t],{model:s}=this.props,{columns:o}=s;return n.push({id:Ln.generate(),value:o[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=Xe.types[0],s=Xe.getDefaultXAxis(n,t),o=Xe.makeDefaultSeriesItems(n,t),i=!0;this.setState({type:n,seriesItems:o,xAxis:s,isLinked:i},this.sendChange)}handleSeriesChange(e){const{value:t}=e.target,n=e.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(o=>{let{seriesItems:i}=o;return i=[...i],i[s].value=t,{seriesItems:i}},this.sendChange)}handleSeriesDeleteClick(e){const n=e.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(o=>{const{seriesItems:i}=o,r=[...i];return r.splice(s,1),{seriesItems:r}},this.sendChange)}handleSubmit(e){e.preventDefault();const{onSubmit:t}=this.props,{type:n,seriesItems:s,xAxis:o,isLinked:i}=this.state,r=s.map(l=>l.value);t({type:`${n}`,series:r,xAxis:o,isLinked:i})}handleTypeClick(e){const n=e.target.getAttribute("data-index"),s=parseInt(n,10),o=Xe.types[s];_r.debug2("handleTypeSelect",o),this.setState(i=>{const r=Xe.getMaxSeriesCount(o);let{seriesItems:l}=i;if(l=l.slice(0,r),l.length===0&&r>0){const{model:a}=this.props,{columns:c}=a;l=Xe.makeDefaultSeriesItems(o,c)}return{type:o,seriesItems:l}},this.sendChange)}handleXAxisChange(e){const t=e.target.value;_r.debug2("x-axis change",t),this.setState({xAxis:t},this.sendChange)}sendChange(){const{onChange:e}=this.props,{isLinked:t,type:n,seriesItems:s,xAxis:o}=this.state,i=s.map(r=>r.value);e({type:n,series:i,xAxis:o,isLinked:t})}render(){const{model:e}=this.props,{columns:t}=e,{seriesItems:n,type:s,xAxis:o,isLinked:i}=this.state,r=Xe.getMaxSeriesCount(s),l=Xe.getXAxisLabel(s),a=Xe.getSeriesLabel(s),c=n.length>0,d=n.length<r;return m("div",{className:"chart-builder",children:y("form",{onSubmit:this.handleSubmit,children:[y("div",{className:"form-row",children:[m("label",{children:"Select Chart Type"}),m("div",{className:"form-row",children:Xe.types.map((u,h)=>{const g=u;return m("div",{className:"col col-chart-type",children:y("button",{type:"button",className:Z("btn","btn-icon","btn-chart-type",{active:u===s}),"data-index":h,onClick:this.handleTypeClick,children:[Xe.getTypeIcon(u),Xe.getTypeName(u)]})},g)})})]}),m("hr",{}),y("div",{className:"form-row form-inline",children:[m("label",{className:"col-2 label-left",children:l}),m("select",{className:"form-control custom-select select-x-axis col",value:o,onChange:this.handleXAxisChange,children:t.map(u=>m("option",{value:u.name,children:u.name},u.name))})]}),c&&m("hr",{}),n.map((u,h)=>y("div",{className:"form-row form-inline form-series-item","data-testid":`form-series-item-${h}`,children:[m("label",{className:"col-2 label-left",children:h===0?a:""}),m("select",{className:"form-control custom-select select-series col",value:u.value,onChange:this.handleSeriesChange,"data-testid":`select-series-item-${h}`,"data-index":h,children:t.map(g=>m("option",{value:g.name,"data-index":h,children:g.name},g.name))}),n.length>1&&m(z,{kind:"ghost",className:"btn-delete-series ml-2 px-2","data-index":h,"data-testid":`delete-series-${h}`,onClick:this.handleSeriesDeleteClick,icon:un,tooltip:"Delete"})]},u.id)),d&&y("div",{className:"form-row",children:[m("div",{className:"col-2"}),m(z,{kind:"ghost",className:"btn-add-series mt-1",onClick:this.handleAddSeries,icon:vs,children:"Add Series"})]}),y("div",{className:"form-row chart-builder-link",children:[m("label",{className:"col-2 label-right",children:y("div",{className:"fa-md fa-layers",children:[m(J,{mask:Vi,icon:Yo,transform:"right-5 down-5"}),m(J,{icon:i?Xa:Ka,transform:"grow-2 right-8 down-6"})]})}),y(zi,{onChange:this.handleLinkStateChange,value:`${i}`,children:[m(Zn,{value:"true",children:"Sync State"}),m(Zn,{value:"false",children:"Freeze State"})]})]}),y("div",{className:"form-row",children:[m("div",{className:"col-2 label-right"}),m("div",{className:"col chart-builder-link-info",children:i?"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."})]}),y("div",{className:Z("form-row","justify-content-end","my-3"),children:[m(z,{kind:"secondary",className:"btn-reset",onClick:this.handleReset,children:"Reset"}),m(z,{kind:"primary",type:"submit",className:"btn-submit",children:"Create"})]})]})})}};let Ll=Xe;Ll.types=[E.plot.SeriesPlotStyle.LINE,E.plot.SeriesPlotStyle.BAR,E.plot.SeriesPlotStyle.SCATTER,E.plot.SeriesPlotStyle.PIE];class Pl extends F.exports.Component{constructor(t){super(t),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()}initEditor(){var o;const{value:t,editorSettings:n}=this.props,s={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:t,wordWrap:"on",automaticLayout:!0,...n};if(!this.editorContainer)throw new Error("editorContainer is null");this.editor=cn.create(this.editorContainer,s),this.editor.layout(),(o=this.editor.getModel())==null||o.updateOptions({tabSize:0}),this.editor.onKeyDown(this.handleKeyDown),this.editor.onDidChangeModelContent(this.handleContentChanged),this.editor.onDidFocusEditorText(this.handleEditorFocus),this.editor.onDidBlurEditorText(this.handleEditorBlur)}destroyEditor(){var t;(t=this.editor)==null||t.dispose(),this.editor=void 0}handleContentChanged(){var s,o;const{onContentChanged:t}=this.props,n=(o=(s=this.editor)==null?void 0:s.getModel())==null?void 0:o.getValue();n!==void 0&&this.setState({isEditorEmpty:n.length===0}),t(n)}handleEditorFocus(){this.setState({isEditorFocused:!0})}handleEditorBlur(){var n,s,o;const t=(o=(s=(n=this.editor)==null?void 0:n.getModel())==null?void 0:s.getValue())!=null?o:"";this.setState({isEditorEmpty:t.length===0,isEditorFocused:!1})}handleContainerClick(){var n;const{isEditorFocused:t}=this.state;t||(n=this.editor)==null||n.focus()}handleKeyDown(t){const{onTab:n,editorIndex:s}=this.props;t.code==="Tab"&&(t.stopPropagation(),t.preventDefault(),n(s,t.shiftKey))}render(){const{value:t,invalid:n}=this.props,{isEditorFocused:s,isEditorEmpty:o}=this.state;return y("div",{className:Z("input-editor-wrapper",{focused:s,invalid:n}),role:"presentation",onClick:this.handleContainerClick,children:[m("div",{className:"editor-container",ref:i=>{this.editorContainer=i}}),o&&!t&&m("div",{className:"editor-placeholder text-muted",children:"Column Formula"})]})}}Pl.defaultProps={value:"",onContentChanged:()=>{},editorSettings:{},editorIndex:0,onTab:()=>{},invalid:!1};const Hr=Object.freeze({NAME:"name",FORMULA:"formula"}),lh=()=>{};function ah({eventKey:e,name:t,inputIndex:n,formula:s,onChange:o,onDeleteColumn:i,onTabInEditor:r,invalid:l,isDuplicate:a}){const c=t===""||Ks.isValidColumnName(t),d=F.exports.useCallback(u=>{u!==void 0&&(u.replace(/(\r\n|\n|\r)/gm,""),o(e,Hr.FORMULA,u))},[o,e]);return m(sl,{draggableId:e,index:n,disableInteractiveElementBlocking:!0,children:(u,h)=>y("div",{className:Z("draggable-container",{dragging:h.isDragging}),ref:u.innerRef,...u.draggableProps,children:[y("div",{className:"custom-column-input-container",children:[y("div",{className:"pb-3",children:[y("div",{className:"d-flex flex-row custom-column-name",children:[m("input",{className:Z("form-control custom-column-input",{"is-invalid":l||!c||a}),placeholder:"Column Name",value:t,onChange:g=>{o(e,Hr.NAME,g.target.value)}}),m(z,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{i(e)},icon:un,tooltip:"Delete custom column"}),m(z,{kind:"ghost",className:"btn-drag-handle",onClick:lh,...u.dragHandleProps,icon:Ui,tooltip:"Drag column to re-order"})]}),(!c||a)&&m("p",{className:"validate-label-error text-danger mb-0 mt-2 pl-1",children:c?"Duplicate name":"Invalid name"})]}),m(Pl,{editorSettings:{language:"deephavenDb"},editorIndex:n,value:s,onContentChanged:d,onTab:r,invalid:l})]}),m("hr",{})]})})}const Ci=[];class ue extends Tl{constructor(){super(),this.listenerCount=0}addEventListener(t,n,s){super.addEventListener(t,n,s),this.listenerCount+=1,this.listenerCount===1&&this.startListening()}removeEventListener(t,n,s){super.removeEventListener(t,n,s),this.listenerCount-=1,this.listenerCount===0&&this.stopListening()}startListening(){}stopListening(){}get originalColumns(){return this.columns}get layoutHints(){return null}get frontColumns(){return Ci}get backColumns(){return Ci}get frozenColumns(){return Ci}isColumnFrozen(t){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(t){return!1}close(){}isRowMovable(){return!1}get isSeekRowAvailable(){return!1}}ue.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"});const fs=class extends F.exports.Component{constructor(e){super(e),this.getInput=Fe((t,n)=>t.find(s=>s.eventKey===n)),this.getInputIndex=Fe((t,n)=>t.findIndex(s=>s.eventKey===n)),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}static makeCustomColumnInputEventKey(){return Ln.generate()}static createCustomColumnInput(){return{eventKey:Ln.generate(),name:"",formula:""}}componentDidMount(){const{customColumns:e}=this.props;this.parseCustomColumns(e),this.startListening()}componentWillUnmount(){this.stopListening(),this.successButtonTimer&&clearTimeout(this.successButtonTimer)}resetErrorMessage(){this.setState({errorMessage:null})}startListening(){const{model:e}=this.props;e.addEventListener(ue.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),e.addEventListener(ue.EVENT.UPDATED,this.handleCustomColumnUpdated),e.addEventListener(ue.EVENT.REQUEST_FAILED,this.handleRequestFailed)}stopListening(){const{model:e}=this.props;e.removeEventListener(ue.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),e.removeEventListener(ue.EVENT.UPDATED,this.handleCustomColumnUpdated),e.removeEventListener(ue.EVENT.REQUEST_FAILED,this.handleRequestFailed)}parseCustomColumns(e){if(e.length>0){const t=e.map(n=>{const s=n.split(/=(.+)/,2);return{eventKey:fs.makeCustomColumnInputEventKey(),name:s[0],formula:s[1]}});this.setState({inputs:t})}else this.setState({inputs:[fs.createCustomColumnInput()]})}handleAddColumnClick(){const{inputs:e}=this.state,t=[...e];t.push(fs.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(fs.createCustomColumnInput()),this.setState({inputs:s})}handleInputChange(e,t,n){const{inputs:s}=this.state,o=this.getInputIndex(s,e),r={...this.getInput(s,e)};r[t]=n;const l=[...s];l.splice(o,1,r),this.setState({inputs:l})}handleCustomColumnUpdated(){const{isCustomColumnApplying:e}=this.state;!e||this.setState({isCustomColumnApplying:!1,isSuccessShowing:!0},()=>{this.successButtonTimer=setTimeout(()=>this.setState({isSuccessShowing:!1}),fs.SUCCESS_SHOW_DURATION)})}handleRequestFailed(e){const t=e,{isCustomColumnApplying:n}=this.state;!n||this.setState({isCustomColumnApplying:!1,errorMessage:y(Oe,{children:[y("p",{children:[m(J,{icon:Qn})," Failed to apply custom columns."]}),y("div",{className:"error-box",children:[t.detail.errorMessage,m("br",{}),"Table configuration:"," ",JSON.stringify(t.detail.configuration)]})]}),hasRequestFailed:!0})}handleDragEnd(e){if(dt.stopDragging(),!e.destination)return;const{inputs:t}=this.state,n=e.source.index,s=e.destination.index,o=[...t],i=t[n];o.splice(n,1),o.splice(s,0,i),this.setState({inputs:o})}handleEditorTabNavigation(e,t){var s,o,i,r;const{inputs:n}=this.state;if(t){((s=this.container)==null?void 0:s.querySelectorAll(".btn-drag-handle")[e]).focus();return}if(e===n.length-1)(i=(o=this.container)==null?void 0:o.querySelector(".btn-add-column"))==null||i.focus();else{const l=e+1;((r=this.container)==null?void 0:r.querySelectorAll(".custom-column-input")[l]).focus()}}handleSaveClick(){const{onSave:e,customColumns:t}=this.props,{inputs:n,isCustomColumnApplying:s}=this.state;if(s)return;const o=[];n.forEach(i=>{const{name:r,formula:l}=i;r&&l&&o.push(`${r}=${l}`)}),this.resetErrorMessage(),this.setState({isCustomColumnApplying:o.length>0||t.length>0}),e(o)}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})=>{var o;return n.set(s,((o=n.get(s))!=null?o:0)+1)}),e.map((s,o)=>{var c;const{eventKey:i,name:r,formula:l}=s,a=((c=n.get(r))!=null?c:0)>1;return m(ah,{inputIndex:o,eventKey:i,name:r,formula:l,onChange:this.handleInputChange,onDeleteColumn:this.handleDeleteColumn,onTabInEditor:this.handleEditorTabNavigation,invalid:t,isDuplicate:a},i)})}renderSaveButton(){const{inputs:e,isCustomColumnApplying:t,isSuccessShowing:n}=this.state,s=e.length>1?"Save Columns":"Save Column",o=e.every(({name:l})=>l===""||Ks.isValidColumnName(l)),i=e.filter(({name:l})=>l!=="").map(({name:l})=>l),r=new Set(i).size===i.length;return y(z,{kind:n?"success":"primary",className:Z("btn-apply",{"btn-spinner":t}),disabled:n||t||!o||!r,onClick:this.handleSaveClick,children:[t&&y("span",{children:[m(dn,{}),m("span",{className:"btn-normal-content",children:"Applying"})]}),!n&&!t&&s,n&&y(Oe,{children:[m(J,{icon:rl})," Success"]})]})}render(){const{onCancel:e}=this.props,{errorMessage:t}=this.state;return y("div",{role:"presentation",className:"custom-column-builder-container",ref:n=>{this.container=n},onClick:this.resetRequestFailed,onFocus:this.resetRequestFailed,children:[m("hr",{}),m(zo,{onDragStart:dt.startDragging,onDragEnd:this.handleDragEnd,children:m(Oi,{droppableId:"droppable-custom-columns",children:(n,s)=>y("div",{ref:n.innerRef,...n.droppableProps,className:Z("droppable-container",{dragging:s.draggingFromThisWith}),children:[this.renderInputs(),n.placeholder]})})}),m("div",{className:"pt-1 px-3",children:m(z,{kind:"ghost",className:"btn-add-column",onClick:this.handleAddColumnClick,icon:vs,children:"Add Another Column"})}),y("div",{className:"custom-column-builder-footer",children:[t&&m("div",{className:"error-message",children:t}),y("div",{className:"d-flex justify-content-end",children:[m(z,{kind:"secondary",className:"mr-2",onClick:e,children:"Cancel"}),this.renderSaveButton()]})]})]})}};let _l=fs;_l.SUCCESS_SHOW_DURATION=750;var Se=(e=>(e.ADVANCED_SETTINGS="ADVANCED_SETTINGS",e.AGGREGATIONS="AGGREGATIONS",e.AGGREGATION_EDIT="AGGREGATIONS_EDIT",e.CHART_BUILDER="CHART_BUILDER",e.CUSTOM_COLUMN_BUILDER="CUSTOM_COLUMN_BUILDER",e.QUICK_FILTERS="QUICK_FILTERS",e.ROLLUP_ROWS="ROLLUP_ROWS",e.SEARCH_BAR="SEARCH_BAR",e.SELECT_DISTINCT="SELECT_DISTINCT",e.TABLE_EXPORTER="TABLE_EXPORTER",e.VISIBILITY_ORDERING_BUILDER="VISIBILITY_ORDERING_BUILDER",e.CONDITIONAL_FORMATTING="CONDITIONAL_FORMATTING",e.CONDITIONAL_FORMATTING_EDIT="CONDITIONAL_FORMATTING_EDIT",e.GOTO="GOTO",e))(Se||{});const _s=le.module("RollupRows"),ch=150,Do="grouped-rollup-rows",Io="ungrouped-rollup-rows",yt=class extends F.exports.Component{constructor(e){super(e),this.search=vt(i=>{const r=this.getSortedUngroupedColumns(),l=[];let a=null;for(let c=0;c<r.length;c+=1)r[c].name.toLowerCase().includes(i.toLowerCase())&&(a==null&&(a=c),l.push([c,c]));M(a),this.setState({ungroupedSelectedRanges:l}),l.length>0&&this.ungroupedList.current&&this.ungroupedList.current.scrollToItem(a)},ch),this.getCachedUngroupedColumns=Te((i,r)=>i.filter(l=>yt.isGroupable(l)&&r.find(a=>a===l.name)==null)),this.getCachedSortedColumns=Te((i,r)=>r==null?[...i]:N.sortColumns(i,r===yt.SORT.ASCENDING)),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=De.createRef(),this.groupedList=De.createRef();const{config:t}=e,{columns:n=[],showConstituents:s=!0,showNonAggregatedColumns:o=!0}=t!=null?t:{};this.state={ungroupedSelectedRanges:[],columns:n,groupedSelectedRanges:[],searchFilter:"",showConstituents:s,showNonAggregatedColumns:o,dragSource:null,sort:null}}static renderColumn({item:e,isClone:t,selectedCount:n}){const s=e==null?void 0:e.name,o=t!==void 0&&t?`${n}`:void 0,i=t!==void 0&&t?"item-list-item-clone":"";return Dt.renderTextItem({text:s,badgeText:o,className:i})}static addGroupings(e,t,n=e.length){if(t==null||t.length===0)return e;let s=n;const o=e.filter((i,r)=>t.includes(i)?(r<s&&(s-=1),!1):!0);return o.splice(s,0,...t),o}static isGroupable(e){return!N.isDecimalType(e.type)}componentDidUpdate(e,t){const{config:n}=this.props,{columns:s,showConstituents:o,showNonAggregatedColumns:i}=this.state;n!==e.config?this.updateFromConfig():(s!==t.columns||o!==t.showConstituents||i!==t.showNonAggregatedColumns)&&(n==null||s!==n.columns||o!==n.showConstituents||i!==n.showNonAggregatedColumns)&&this.sendChange()}componentWillUnmount(){this.search.cancel()}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===yt.SORT.ASCENDING?null:yt.SORT.ASCENDING}))}handleSortDescending(){this.setState(({sort:e})=>({sort:e===yt.SORT.DESCENDING?null:yt.SORT.DESCENDING}))}resetSelection(){this.setState({ungroupedSelectedRanges:[],groupedSelectedRanges:[]})}handleDragStart(e){_s.debug("handleDragStart",e),document.documentElement.classList.add("drag-pointer-events-none"),this.setState({dragSource:e.source})}handleDragEnd(e){_s.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===Io){this.setState(({groupedSelectedRanges:i,columns:r})=>{const l=[...r];return dt.reorder(l,i,[],0),{columns:l,ungroupedSelectedRanges:[],groupedSelectedRanges:[]}});return}const s=n.droppableId===Do;let o=t.index;s&&n.index<t.index&&(o+=1),this.setState(({columns:i,ungroupedSelectedRanges:r,groupedSelectedRanges:l})=>{const a=[...i],c=s?a:this.getSortedUngroupedColumns().map(p=>p.name),d=s?l:r,u=dt.reorder(c,d,a,o),h=s?dt.adjustDestinationIndex(o,l):o,g=[[h,h+u.length-1]];return{columns:a,ungroupedSelectedRanges:[],groupedSelectedRanges:g}}),this.resetSelection()}handleUngroupedSelect(e){_s.debug("handleUngroupedSelect"),this.setState(({columns:t})=>({columns:yt.addGroupings(t,[this.getSortedUngroupedColumns()[e].name]),ungroupedSelectedRanges:[],groupedSelectedRanges:[]}))}handleUngroupedSelectionChange(e){_s.debug2("handleUngroupedSelectionChange",e),this.setState(({ungroupedSelectedRanges:t})=>e===t?null:{ungroupedSelectedRanges:e,groupedSelectedRanges:[]})}handleGroupedSelectionChange(e){_s.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!=null?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})}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 i=`${n!==void 0&&n?"":"\xA0\xA0".repeat(t)}${e}`,r=n!==void 0&&n?`${s}`:void 0,l=n!==void 0&&n?"item-list-item-clone":"";return y(Oe,{children:[Dt.renderTextItem({text:i,badgeText:r,className:l}),(n===void 0||!n)&&m(z,{kind:"ghost",className:"btn btn-link btn-link-icon btn-delete-grouping float-right",onClick:()=>this.handleDeleteClicked(t),children:m(J,{icon:un})})]})}render(){const{columns:e,dragSource:t,searchFilter:n,groupedSelectedRanges:s,ungroupedSelectedRanges:o,showConstituents:i,showNonAggregatedColumns:r,sort:l}=this.state,a=this.getSortedUngroupedColumns();let c=e.length*Dt.DEFAULT_ROW_HEIGHT;(t==null?void 0:t.droppableId)===Io&&(c+=Dt.DEFAULT_ROW_HEIGHT);const d=a.length*Dt.DEFAULT_ROW_HEIGHT+10,u=Math.min(3*Dt.DEFAULT_ROW_HEIGHT,d);return m("div",{role:"menu",className:Z("rollup-rows",{"is-dragging":t!=null}),tabIndex:0,children:y(zo,{onDragEnd:this.handleDragEnd,onDragStart:this.handleDragStart,children:[y("div",{className:"rollup-rows-group-by",children:[m("div",{className:"section-title",children:"Group By"}),e.length===0&&m(Oi,{droppableId:"placeholder",children:(h,g)=>m("div",{className:Z("placeholder","text-muted",{"is-dragging-from-this":g.draggingFromThisWith,"is-dragging-over":g.isDraggingOver,"is-dropping":g.draggingOverWith}),ref:h.innerRef,...h.droppableProps,children:"To create a rollup, drag columns from the list below and drop them into this area."})}),e.length>0&&m(Dt,{draggingItemClassName:"rollup-rows-dragging-grouped-item",draggablePrefix:Do,droppableId:Do,itemCount:e.length,items:e,offset:0,onSelectionChange:this.handleGroupedSelectionChange,ref:this.groupedList,renderItem:this.renderGroupedItem,selectedRanges:s,style:{height:c},isMultiSelect:!0})]}),y("div",{className:"rollup-rows-available-columns",children:[m("div",{className:"section-title",children:"Available Grouping Columns"}),y("div",{className:"top-menu",children:[m(Qs,{className:"w-100",value:n,matchCount:n?o.length:void 0,placeholder:"Find column...",onChange:this.handleSearchChange}),y(z,{kind:"ghost",className:Z("btn-link btn-link-icon",{active:l===yt.SORT.ASCENDING}),onClick:this.handleSortAscending,children:[m(J,{icon:_i}),m(Rt,{children:"Sort ascending"})]}),y(z,{kind:"ghost",className:Z("btn-link btn-link-icon",{active:l===yt.SORT.DESCENDING}),onClick:this.handleSortDescending,children:[m(J,{icon:Hi}),m(Rt,{children:"Sort descending"})]})]}),m(Dt,{className:"rollup-available-grouping-columns",draggablePrefix:Io,droppableId:Io,itemCount:a.length,items:a,renderItem:yt.renderColumn,offset:0,onSelect:this.handleUngroupedSelect,onSelectionChange:this.handleUngroupedSelectionChange,ref:this.ungroupedList,selectedRanges:o,style:{maxHeight:d,minHeight:u},isDropDisabled:(t==null?void 0:t.droppableId)!==Do,isMultiSelect:!0}),y("div",{className:"bottom-menu",children:[m("div",{className:"label",children:"Show:"}),m(an,{checked:i,onChange:this.handleShowConstituentsChange,children:"Constituents"}),m(an,{checked:r,onChange:this.handleShowNonAggregatedColumnsChange,children:"Non-Aggregated Columns"})]})]})]})})}};let er=yt;er.SORT=Object.freeze({ASCENDING:"ASC",DESCENDING:"DESC"});er.defaultProps={config:null,onChange:()=>{}};const uh=le.module("TableCsvExporter"),Ne=class extends F.exports.Component{static getDateString(){return E.i18n.DateTimeFormat.format(Ne.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}-${Ne.getDateString()}.csv`,downloadRowOption:Ne.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,customizedDownloadRowOption:Ne.CUSTOMIZED_ROWS_OPTIONS.FIRST,customizedDownloadRows:Ne.DEFAULT_DOWNLOAD_ROWS,includeColumnHeaders:!0,includeHiddenColumns:!1,useUnformattedValues:!1,errorMessage:null,id:Ln.generate()}}getSnapshotRanges(){const{model:e,selectedRanges:t}=this.props,{downloadRowOption:n,customizedDownloadRowOption:s,customizedDownloadRows:o}=this.state,{rowCount:i,columnCount:r}=e;let l=[];switch(n){case Ne.DOWNLOAD_ROW_OPTIONS.ALL_ROWS:l.push(new K(0,0,r-1,i-1));break;case Ne.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS:l=t.map(a=>({...a,startColumn:0,endColumn:r-1})).sort((a,c)=>a.startRow!=null&&c.startRow!=null?a.startRow-c.startRow:0);break;case Ne.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS:switch(s){case Ne.CUSTOMIZED_ROWS_OPTIONS.FIRST:l.push(new K(0,0,r-1,Math.min(o-1,i-1)));break;case Ne.CUSTOMIZED_ROWS_OPTIONS.LAST:l.push(new K(0,Math.max(0,i-o),r-1,i-1));break}break}return l}getModelRanges(e){const{userColumnWidths:t,movedColumns:n}=this.props,{includeHiddenColumns:s}=this.state,o=Q.getHiddenColumns(t);let i=_.getModelRanges(e,n);if(!s&&o.length>0){const r=o.map(K.makeColumn);i=K.subtractRangesFromRanges(i,r)}return i}resetDownloadState(){this.setState({errorMessage:null})}async handleDownloadClick(){const{model:e,isDownloading:t,onDownloadStart:n,onDownload:s,onCancel:o}=this.props,{fileName:i,includeColumnHeaders:r,useUnformattedValues:l}=this.state;if(t){o();return}this.resetDownloadState();const a=this.getSnapshotRanges(),c=this.getModelRanges(a);if(this.validateOptionInput()){n();try{const d=await e.export(),u=d.setViewport(0,0);await u.getViewportData(),s(i,d,u,a,c,r,l)}catch(d){uh.error("CSV download failed",d),this.setState({errorMessage:y("p",{children:[m(J,{icon:Qn})," ",`${d}`]})}),o()}}}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===Ne.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS&&e.length===0?(this.setState({errorMessage:y("p",{children:[m(J,{icon:Qn})," No rows selected. Please select some rows in the table."]})}),!1):t===Ne.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS&&n<=0?(this.setState({errorMessage:y("p",{children:[m(J,{icon:Qn})," Number of rows to output must be greater than 0"]})}),!1):!0}render(){const{model:e,isDownloading:t,tableDownloadProgress:n,tableDownloadEstimatedTime:s,selectedRanges:o,tableDownloadStatus:i}=this.props,{fileName:r,downloadRowOption:l,customizedDownloadRowOption:a,customizedDownloadRows:c,includeColumnHeaders:d,includeHiddenColumns:u,useUnformattedValues:h,errorMessage:g,id:p}=this.state,{rowCount:f}=e;return y("div",{className:"table-csv-exporter",children:[m("div",{className:"section-title",children:"Download Rows"}),m("div",{className:"form-group",children:y(zi,{onChange:this.handleDownloadRowOptionChanged,value:l,disabled:t,children:[y(Zn,{value:Ne.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,"data-testid":"radio-csv-exporter-download-all",children:["All Rows",m("span",{className:"text-muted ml-2",children:`(${f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`})]}),y(Zn,{value:Ne.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS,"data-testid":"radio-csv-exporter-only-selected",children:["Only Selected Rows",m("span",{className:"text-muted ml-2",children:o.length>0?`(${K.rowCount(o).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`:null})]}),m(Zn,{value:Ne.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS,"data-testid":"radio-csv-exporter-customized-rows",children:y("div",{className:"radio-input-row",role:"presentation",onClick:()=>{this.setState({downloadRowOption:Ne.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS})},children:[y("select",{value:a,"data-testid":"select-csv-exporter-customized-rows",className:"custom-select",disabled:t,onChange:this.handleCustomizedDownloadRowOptionChanged,children:[m("option",{value:"FIRST",children:"First"}),m("option",{value:"LAST",children:"Last"})]}),m("input",{type:"number",className:"form-control",id:`customizedRows-${p}`,"data-testid":"input-csv-exporter-customized-rows",name:`customizedRows-${p}`,placeholder:"100",value:c,disabled:t,onChange:this.handleCustomizedDownloadRowsChanged}),m("div",{children:"Rows"})]})})]})}),y("div",{className:"form-group",children:[m("label",{htmlFor:`customizedRows-${p}`,children:"File Name"}),m("input",{type:"text",className:"form-control",id:`filename-${p}`,"data-testid":"input-csv-exporter-file-name",name:`filename-${p}`,value:r,onChange:C=>{this.setState({fileName:C.target.value})},disabled:t})]}),y("div",{className:"checkbox-options",children:[m(an,{checked:d,onChange:this.handleIncludeColumnHeadersChanged,children:"Include column headers"}),m(an,{checked:u,onChange:this.handleIncludeHiddenColumnsChanged,children:"Include hidden columns"}),m(an,{checked:h,onChange:this.handleUseUnformattedValuesChanged,children:"Use unformatted values"})]}),y("div",{className:"section-footer flex-column",children:[g!=null&&m("div",{className:"error-message",children:g}),i&&y("div",{className:"download-status",children:[(i===Ne.DOWNLOAD_STATUS.DOWNLOADING||i===Ne.DOWNLOAD_STATUS.INITIATING)&&y(Oe,{children:[i===Ne.DOWNLOAD_STATUS.INITIATING&&m("div",{className:"text-muted",children:"Starting Download..."}),i===Ne.DOWNLOAD_STATUS.DOWNLOADING&&y("div",{className:"text-muted d-flex justify-content-between",children:[m("span",{children:s||s===0?`Estimated time: ${Bi.formatElapsedTime(s)}`:null}),m("span",{children:`${n}%`})]})]}),i===Ne.DOWNLOAD_STATUS.FINISHED&&m("div",{className:"text-muted text-right",children:"Download Completed"}),i===Ne.DOWNLOAD_STATUS.CANCELED&&m("div",{className:"text-muted",children:"Download Canceled"}),(i===Ne.DOWNLOAD_STATUS.DOWNLOADING||i===Ne.DOWNLOAD_STATUS.INITIATING)&&m("div",{className:"progress",children:m("div",{className:"progress-bar progress-bar-striped progress-bar-animated",style:{width:`${n}%`}})}),i===Ne.DOWNLOAD_STATUS.FINISHED&&m("div",{className:"progress",children:m("div",{className:"progress-bar bg-success",style:{width:`${n}%`}})})]}),y(z,{kind:"primary","data-testid":"btn-csv-exporter-download",className:Z("btn-downloading",{"btn-spinner btn-cancelable":t}),onClick:this.handleDownloadClick,children:[t&&y("span",{children:[m(dn,{}),m("span",{className:"btn-normal-content",children:"Downloading"}),m("span",{className:"btn-hover-content",children:"Cancel"})]}),!t&&"Download"]})]})]})}};let gt=Ne;gt.FILENAME_DATE_FORMAT="yyyy-MM-dd-HHmmss";gt.DOWNLOAD_STATUS={INITIATING:"INITIATING",DOWNLOADING:"DOWNLOADING",FINISHED:"FINISHED",CANCELED:"CANCELED"};gt.DOWNLOAD_ROW_OPTIONS={ALL_ROWS:"ALL_ROWS",SELECTED_ROWS:"SELECTED_ROWS",CUSTOMIZED_ROWS:"CUSTOMIZED_ROWS"};gt.CUSTOMIZED_ROWS_OPTIONS={FIRST:"FIRST",LAST:"LAST"};gt.DEFAULT_DOWNLOAD_ROWS=100;gt.defaultProps={onDownloadStart:()=>{},isDownloading:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:null,selectedRanges:[]};const Jt=le.module("TableSaver"),hh="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function mh(e){return e.added!==void 0}function gh(e){if(!mh(e))throw new Error("event is not UpdateEventData")}const Dn=class extends F.exports.PureComponent{constructor(e){var t,n;super(e),this.WritableStream=(t=window.WritableStream)!=null?t:mr,this.getCachedCustomColumnFormatFlag=pt(Jn.isCustomColumnFormatDefined,{max:1e4}),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=(n=window.WritableStream)!=null?n:mr,this.iframes=[],this.useBlobFallback=!1}static csvEscapeString(e){return`"${e.replace(/"/g,'""')}"`}componentDidMount(){const{getDownloadWorker:e}=this.props;e().then(t=>{Jt.info("found active service worker"),this.sw=t,this.sw.postMessage("ping")}).catch(t=>{Jt.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)}createWriterStream(e){const t=this.useBlobFallback,n=[];let s=null;t&&(s=TextEncoder.prototype.encode.bind(new TextEncoder));const{fileName:o}=this,i={};return t?(i.write=r=>{M(s),r.header!==void 0&&n.push(s(r.header)),r.rows!==void 0&&n.push(s(r.rows))},i.close=()=>{M(o);const r=new Blob(n,{type:"application/octet-stream; charset=utf-8"}),l=document.createElement("a");l.href=URL.createObjectURL(r),l.download=o,l.click()},i.abort=()=>{e.postMessage({cancel:!0}),e.close()}):(i.write=r=>{e.postMessage(r)},i.close=()=>{e.postMessage({end:!0}),e.close()},i.abort=()=>{e.postMessage({cancel:!0}),e.close()}),new this.WritableStream(i)}startDownload(e,t,n,s,o,i,r){const{isDownloading:l}=this.props;if(l)return;this.downloadStartTime=Date.now(),Jt.info(`start downloading ${e}`),this.table=t,this.columns=Q.columnsFromRanges(o,t.columns),this.tableSubscription=n,this.gridRanges=s,this.includeColumnHeaders=i,this.useUnformattedValues=r;const a=encodeURIComponent(e.replace(/\//g,":")).replace(/['()]/g,escape).replace(/\*/g,"%2A"),c=new MessageChannel;if(this.port=c.port1,this.fileName=e,this.fileWriter=this.createWriterStream(this.port).getWriter(),this.useBlobFallback){this.writeCsvTable(i);return}this.sw&&this.sw.postMessage({encodedFileName:a},[c.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&&Jt.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(){Jt.info("download canceled"),this.cancelDownload()}writeTableHeader(){var t;let e="";if(this.columns)for(let n=0;n<this.columns.length;n+=1)e+=this.columns[n].name,e+=n===this.columns.length-1?`
4
4
  `:",";(t=this.fileWriter)==null||t.write({header:e}).then(()=>null)}startWriteTableBody(){this.columns&&this.gridRanges!=null&&(this.chunkRows=Math.floor(Dn.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),Jt.info("start writing table, total snapshots: ",this.snapshotsTotal),this.makeSnapshot(Math.min(Dn.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&&(Jt.debug2(`
5
5
  current range index: ${this.gridRangeCounter},
6
6
  snapshotIndexCounter: ${this.snapshotCounter},
@@ -29,4 +29,4 @@ ${t}`):s.setValue(`${t}`);const i=s.getLineCount(),r=s.getLineLength(i)+1;this.e
29
29
  `&&(e+=`
30
30
  `)}this.bufferedMessages=[],this.appendLogText(e)}queue(e){this.bufferedMessages.push(e),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,st.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 y("div",{className:"log-pane h-100 w-100",children:[y("div",{className:"log-pane-menu",children:[m(z,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:Sc,tooltip:"Clear log"}),m(z,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:Tc,tooltip:"Log Settings",onClick:()=>{},children:m(Ss,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:e})})]}),m("div",{className:"log-pane-editor h-100 w-100",ref:s=>{this.editorContainer=s}})]})}};let eo=st;eo.DefaultLogLevels=[je.STDOUT,je.ERROR,je.FATAL,je.STDERR,je.WARN];eo.AllLogLevels=[je.INFO,je.STDOUT,je.ERROR,je.FATAL,je.STDERR,je.WARN,je.DEBUG,je.TRACE];eo.bufferTimeout=16;eo.maxLogSize=131072;eo.truncateSize=65536;Po.register([Bc,Gc,Wc,$c,zc,qc]);const hg=typeof hi=="function"?hi(Po):hi.default(Po),on=class{constructor(){this.listeners=[],this.isDownsamplingDisabled=!1}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(on.EVENT_UPDATED,{detail:e}))}fireDisconnect(){this.fireEvent(new CustomEvent(on.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(on.EVENT_RECONNECT))}fireDownsampleStart(e){this.fireEvent(new CustomEvent(on.EVENT_DOWNSAMPLESTARTED,{detail:e}))}fireDownsampleFinish(e){this.fireEvent(new CustomEvent(on.EVENT_DOWNSAMPLEFINISHED,{detail:e}))}fireDownsampleFail(e){this.fireEvent(new CustomEvent(on.EVENT_DOWNSAMPLEFAILED,{detail:e}))}fireDownsampleNeeded(e){this.fireEvent(new CustomEvent(on.EVENT_DOWNSAMPLENEEDED,{detail:e}))}fireLoadFinished(){this.fireEvent(new CustomEvent(on.EVENT_LOADFINISHED))}};let Ze=on;Ze.EVENT_UPDATED="ChartModel.EVENT_UPDATED";Ze.EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";Ze.EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";Ze.EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";Ze.EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";Ze.EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";Ze.EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";Ze.EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";const mg="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",gg="#403e41",pg="#5b5a5c",fg="#c0bfbf",Cg="#4878ea",wg="rgba(91, 90, 92, 0.7)",Je={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:mg,gridcolor:gg,linecolor:pg,zerolinecolor:fg,activecolor:Cg,rangebgcolor:wg,"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"},In=Object.freeze({paper_bgcolor:Je["paper-bgcolor"],plot_bgcolor:Je["plot-bgcolor"],title_color:Je["title-color"],colorway:Je.colorway,gridcolor:Je.gridcolor,linecolor:Je.linecolor,zerolinecolor:Je.zerolinecolor,activecolor:Je.activecolor,rangebgcolor:Je.rangebgcolor,area_color:Je["area-color"],trend_color:Je["trend-color"],line_color:Je["line-color"],error_band_line_color:Je["error-band-line-color"],error_band_fill_color:Je["error-band-fill-color"],ohlc_increasing:Je["ohlc-increasing"],ohlc_decreasing:Je["ohlc-decreasing"]}),Us=le.module("ChartUtils"),vn=Object.freeze(E.calendar.DayOfWeek.values()),el="io.deephaven.time.DateTime",Sg=36e5,Tg=1e6;function bg(e){return e.asDate!==void 0}function Eg(e){return e.asNumber!==void 0}function tl(e){return e.dhTimeZone!==void 0}function vg(e){return e!=null&&e.range!=null&&(e.autorange===!1||e.autorange===void 0)}const q=class{static getPlotlyChartType(e,t){switch(e){case E.plot.SeriesPlotStyle.SCATTER:return t?"scatter":"scattergl";case E.plot.SeriesPlotStyle.LINE:return"scatter";case E.plot.SeriesPlotStyle.BAR:case E.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case E.plot.SeriesPlotStyle.PIE:return"pie";case E.plot.SeriesPlotStyle.TREEMAP:return"treemap";case E.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case E.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(e,t,n){const s=new Set;switch(e){case E.plot.SeriesPlotStyle.SCATTER:t!=null&&t&&s.add(q.MODE_LINES),(n==null||n)&&s.add(q.MODE_MARKERS);break;case E.plot.SeriesPlotStyle.LINE:(t==null||t)&&s.add(q.MODE_LINES),n!=null&&n&&s.add(q.MODE_MARKERS);break}return s.size>0?[...s].join("+"):void 0}static getPlotlyProperty(e,t){switch(e){case E.plot.SeriesPlotStyle.PIE:switch(t){case E.plot.SourceType.X:return"labels";case E.plot.SourceType.Y:return"values"}break;case E.plot.SeriesPlotStyle.OHLC:switch(t){case E.plot.SourceType.TIME:return"x"}break;case E.plot.SeriesPlotStyle.TREEMAP:switch(t){case E.plot.SourceType.X:return"ids";case E.plot.SourceType.Y:return"values";case E.plot.SourceType.LABEL:return"labels";case E.plot.SourceType.PARENT:return"parents";case E.plot.SourceType.COLOR:return"marker.colors"}break}switch(t){case E.plot.SourceType.X:return"x";case E.plot.SourceType.Y:return"y";case E.plot.SourceType.Z:return"z";case E.plot.SourceType.X_LOW:return"xLow";case E.plot.SourceType.X_HIGH:return"xHigh";case E.plot.SourceType.Y_LOW:return"yLow";case E.plot.SourceType.Y_HIGH:return"yHigh";case E.plot.SourceType.TIME:return"time";case E.plot.SourceType.OPEN:return"open";case E.plot.SourceType.HIGH:return"high";case E.plot.SourceType.LOW:return"low";case E.plot.SourceType.CLOSE:return"close";case E.plot.SourceType.SHAPE:return"shape";case E.plot.SourceType.SIZE:return"size";case E.plot.SourceType.LABEL:return"label";case E.plot.SourceType.COLOR:return"color";case E.plot.SourceType.PARENT:return"parent";case E.plot.SourceType.HOVER_TEXT:return"hovertext";case E.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${t}`)}}static getPlotlySeriesOrientation(e){var n,s;const{sources:t}=e;return t.length===2&&((s=(n=t[0])==null?void 0:n.axis)==null?void 0:s.type)===E.plot.AxisType.Y?q.ORIENTATION.HORIZONTAL:q.ORIENTATION.VERTICAL}static getPlotlyErrorBars(e,t,n){const s=n.map((i,r)=>i-e[r]),o=t.map((i,r)=>e[r]-i);return{type:"data",symmetric:!1,array:s,arrayminus:o}}static getPlotlyDateFormat(e,t,n){const s=n==null?void 0:n.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let o;const i=e==null?void 0:e.getColumnTypeFormatter(t);return i!=null&&tl(i)&&i.dhTimeZone!=null&&i.showTimeZone&&(o=E.i18n.DateTimeFormat.format(" z",new Date,i.dhTimeZone)),{tickformat:s,ticksuffix:o,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 o=n.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);M(o);const[,i,r,l,,a,c,d,u,h]=o,g=l.replace(",","").length,f=r.indexOf(",")>=0||l.indexOf(",")>=0?",":"",C=d!=null&&d!==""?"e":"f",w=u!==""?u:C,S=a.length+c.length,v=`0${g}${f}.${S}${w}`,T=q.convertNumberPrefix(i),R=q.convertNumberPrefix(h);return{tickformat:v,tickprefix:T,ticksuffix:R,automargin:!0}}static getPlotlyAxisFormat(e,t=null){const{axis:n,columnType:s}=e,{formatPattern:o}=n;let i=null;return N.isDateType(s)?(i=q.getPlotlyDateFormat(t,s,o),i=q.addTickSpacing(i,n,!0)):N.isNumberType(s)&&(i=q.getPlotlyNumberFormat(t,s,o),i=q.addTickSpacing(i,n,!1)),n.formatType===E.plot.AxisFormatType.CATEGORY&&(i?i.type="category":i={type:"category",tickformat:void 0,ticksuffix:void 0}),i}static addTickSpacing(e,t,n){const{gapBetweenMajorTicks:s}=t;if(s>0){const o=e||{};let i=s;return n&&(i=s/Tg),t.log&&(i=Math.log(i)),o.tickmode="linear",o.dtick=i,o}return e}static getSourceForAxis(e,t){for(let n=0;n<e.series.length;n+=1){const s=e.series[n];for(let o=0;o<s.sources.length;o+=1){const i=s.sources[o];if(i.axis===t)return i}}return null}static getSeriesVisibility(e,t){return t!=null&&t.hiddenSeries!=null&&t.hiddenSeries.includes(e)?"legendonly":!0}static getHiddenLabels(e){return e!=null&&e.hiddenSeries?[...e.hiddenSeries]:[]}static makeSeriesData(e,t,n,s,o=q.ORIENTATION.VERTICAL){return{type:e,mode:t,name:n,orientation:o,showlegend:s!=null?s:void 0}}static makeSeriesDataFromSeries(e,t,n,s=null,o=In){const{name:i,isLinesVisible:r,isShapesVisible:l,plotStyle:a,lineColor:c,shapeColor:d,sources:u,shape:h,shapeSize:g}=e,p=u.some(b=>{var v;return(v=b.axis)==null?void 0:v.businessCalendar}),f=q.getChartType(a,p),C=q.getPlotlyChartMode(a,r!=null?r:void 0,l!=null?l:void 0),w=q.getPlotlySeriesOrientation(e),S=q.makeSeriesData(f,C,i,s,w);return q.addSourcesToSeriesData(S,a,u,t),q.addStylingToSeriesData(S,a,o,c,d,h,g,n),S}static addSourcesToSeriesData(e,t,n,s){const o=e;for(let i=0;i<n.length;i+=1){const r=n[i],{axis:l,type:a}=r,c=q.getPlotlyProperty(t,a);ol(o,c,[]);const d=l!=null?q.getAxisPropertyName(l.type):null;if(d!=null){const u=s.get(l.type);if(u){const h=u.indexOf(l),g=h>0?`${h+1}`:"";o[`${d}axis`]=`${d}${g}`}}}}static addStylingToSeriesData(e,t,n=In,s=null,o=null,i=null,r=null,l=null){const a=e;if(a.marker={line:{}},a.line={width:1},t===E.plot.SeriesPlotStyle.AREA?a.fill="tozeroy":t===E.plot.SeriesPlotStyle.STACKED_AREA?a.stackgroup="stack":t===E.plot.SeriesPlotStyle.STEP?a.line.shape="hv":t===E.plot.SeriesPlotStyle.HISTOGRAM?(a.width=[],a.marker.line!==void 0&&Object.assign(a.marker.line,{color:n.paper_bgcolor,width:1})):t===E.plot.SeriesPlotStyle.OHLC?(a.increasing={line:{color:n.ohlc_increasing}},a.decreasing={line:{color:n.ohlc_decreasing}}):t===E.plot.SeriesPlotStyle.PIE?(a.textinfo="label+percent",a.outsidetextfont={color:n.title_color}):t===E.plot.SeriesPlotStyle.TREEMAP&&(a.hoverinfo="text",a.textinfo="label+text",a.tiling={packing:"squarify",pad:0},a.textposition="middle center",a.outsidetextfont={color:n.title_color}),s!=null&&(t===E.plot.SeriesPlotStyle.BAR?a.marker.color=s:a.line.color=s),o!=null&&(a.marker.color=o),i!=null&&i.length>0)try{a.marker.symbol=q.getMarkerSymbol(i)}catch(c){Us.warn("Unable to handle shape",i,":",c)}r!=null&&(a.marker.size=r*q.DEFAULT_MARKER_SIZE),l!=null&&t!==E.plot.SeriesPlotStyle.PIE&&(a.visible=l)}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},o=q.getAllAxes(e),i=q.groupArray(o,"type"),{charts:r}=e;for(let l=0;l<r.length;l+=1){const a=r[l];for(let c=0;c<a.series.length;c+=1){const d=a.series[c],{sources:u}=d,h=u.filter(g=>g.axis);for(let g=0;g<h.length;g+=1){const p=h[g],{axis:f}=p,{type:C}=f,w=i.get(C);M(w);const S=w.indexOf(f),b=q.getAxisPropertyName(C);if(b!=null){const v=q.getAxisLayoutProperty(b,S);if(n.has(v))Us.debug(`${v} already added.`);else{Us.debug(`Adding ${v} to axisFormats.`);const T=q.getPlotlyAxisFormat(p,t);if(T===null)n.set(v,s);else{n.set(v,T);const{businessCalendar:R}=f;if(R!=null){const D=[],{businessPeriods:A,businessDays:I,holidays:L,timeZone:k}=R,x=t==null?void 0:t.getColumnTypeFormatter(el);let W;tl(x)&&(W=x.dhTimeZone);const V=W?(k.standardOffset-W.standardOffset)/60:0;L.length>0&&D.push(...q.createRangeBreakValuesFromHolidays(L,k,W)),A.forEach(Y=>D.push({pattern:"hour",bounds:[q.periodToDecimal(Y.close)+V,q.periodToDecimal(Y.open)+V]})),I.length<vn.length&&q.createBoundsFromDays(I).forEach(Y=>D.push({pattern:"day of week",bounds:Y})),T.rangebreaks=D}if(n.size===a.axes.length)return n}}}}}}return n}static getChartType(e,t){switch(e){case E.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return q.getPlotlyChartType(e,t)}}static getAxisPropertyName(e){switch(e){case E.plot.AxisType.X:return"x";case E.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(e){switch(e){case E.plot.AxisPosition.BOTTOM:return"bottom";case E.plot.AxisPosition.TOP:return"top";case E.plot.AxisPosition.LEFT:return"left";case E.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 o=n[s];for(let i=0;i<o.series.length;i+=1)if(t===o.series[i])return o}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 o=n[s],i=e[o];vg(i)&&(t[o]=[...i.range])}return t}static updateFigureAxes(e,t,n,s=0,o=0,i=In){const r=e,l=q.getAllAxes(t);for(let a=0;a<t.charts.length;a+=1){const c=t.charts[a],d=n==null?void 0:n(c),u=q.getChartBounds(t,c,s,o);q.updateLayoutAxes(r,c.axes,l,s,o,u,d,i)}q.removeStaleAxes(r,l)}static getChartBounds(e,t,n,s){var b;const{cols:o,rows:i}=e,{column:r,colspan:l,row:a,rowspan:c}=t,d=r+l,u=a+c,h=1/o,g=1/i,p=q.AXIS_SIZE_PX/n,f=q.AXIS_SIZE_PX/s,C={bottom:(i-u)*g+(u<i?f/2:0),top:(i-a)*g-(a>0?f/2:0),left:r*h+(r>0?p/2:0),right:d*h-(d<o?p/2:0)};return((b=q.groupArray(t.axes,"position").get(E.plot.AxisPosition.RIGHT))!=null?b:[]).length>0&&(n>0?C.right-=(C.right-C.left)*Math.max(0,Math.min(q.LEGEND_WIDTH_PX/n,q.MAX_LEGEND_SIZE)):C.right-=(C.right-C.left)*q.DEFAULT_AXIS_SIZE),C}static updateLayoutAxes(e,t,n,s=0,o=0,i={left:0,top:0,right:1,bottom:1},r,l=In){const a=s>0?Math.max(q.MIN_AXIS_SIZE,Math.min(q.AXIS_SIZE_PX/o,q.MAX_AXIS_SIZE)):q.DEFAULT_AXIS_SIZE,c=o>0?Math.max(q.MIN_AXIS_SIZE,Math.min(q.AXIS_SIZE_PX/s,q.MAX_AXIS_SIZE)):q.DEFAULT_AXIS_SIZE,d=e,u=q.groupArray(t,"position"),h=q.groupArray(t,"type"),g=[...h.keys()],p=q.groupArray(n,"type");for(let f=0;f<g.length;f+=1){const C=g[f],w=q.getAxisPropertyName(C);if(w!=null){const S=h.get(C),b=p.get(C),T=C===E.plot.AxisType.Y?o:s;M(S),M(b);for(let R=0;R<S.length;R+=1){const D=S[R],A=b.indexOf(D),I=q.getAxisLayoutProperty(w,A);d[I]==null&&(d[I]=q.makeLayoutAxis(C,l));const L=d[I];if(L!=null){q.updateLayoutAxis(L,D,R,u,a,c,i);const{range:k,autorange:x}=L;if(r!=null&&k!==void 0&&(x===void 0||x===!1)){const W=r(D),[V,Y]=W(k);Us.debug("Setting downsample range",T,V,Y),D.range(T,V,Y)}else D.range(T)}}}}}static removeStaleAxes(e,t){const n=e,s=q.groupArray(t,"type"),o=[...s.keys()];for(let i=0;i<o.length;i+=1){const r=o[i],l=s.get(r);M(l);let a=l.length;const c=q.getAxisPropertyName(r);if(c!=null){let d=q.getAxisLayoutProperty(c,a);for(;n[d]!=null;)delete n[d],a+=1,d=q.getAxisLayoutProperty(c,a)}}}static getAxisLayoutProperty(e,t){const n=t>0?`${t+1}`:"";return`${e!=null?e:""}axis${n}`}static updateLayoutAxis(e,t,n,s,o,i,r){var u,h,g;const a=t.type===E.plot.AxisType.Y?i:o,c=e,d=(u=t.label)!=null?u:"";if(c.title!==void 0&&typeof c.title!="string"?c.title.text=d:c.title={text:d},t.log&&(c.type="log"),c.side=q.getAxisSide(t.position),n>0){c.overlaying=(h=q.getAxisPropertyName(t.type))!=null?h:void 0;const p=(g=s.get(t.position))!=null?g:[],f=p.indexOf(t);f>0&&(c.anchor="free",t.position===E.plot.AxisPosition.RIGHT?c.position=r.right+(f-p.length+1)*a:t.position===E.plot.AxisPosition.TOP?c.position=r.top+(f-p.length+1)*a:t.position===E.plot.AxisPosition.BOTTOM?c.position=r.bottom+(p.length-f+1)*a:t.position===E.plot.AxisPosition.LEFT&&(c.position=r.left+(p.length-f+1)*a))}else if(t.type===E.plot.AxisType.X){const p=s.get(E.plot.AxisPosition.LEFT)||[],f=s.get(E.plot.AxisPosition.RIGHT)||[],C=Math.max(r.left,r.left+(p.length-1)*i),w=Math.min(r.right-(f.length-1)*i,r.right);c.domain=[C,w]}else if(t.type===E.plot.AxisType.Y){const p=s.get(E.plot.AxisPosition.BOTTOM)||[],f=s.get(E.plot.AxisPosition.TOP)||[],C=Math.max(r.bottom,r.bottom+(p.length-1)*o),w=Math.min(r.top-(f.length-1)*o,r.top);c.domain=[C,w]}}static periodToDecimal(e){const t=e.split(":");return Number(t[0])+Number(t[1])/60}static createBoundsFromDays(e){const t=e.map(i=>vn.indexOf(i)),n=vn.filter(i=>!e.includes(i)).map(i=>vn.indexOf(i)),s=new Set;n.forEach(i=>{for(let r=i+1;r<i+vn.length;r+=1){const l=r%vn.length;if(t.includes(l)){s.add(l);break}}});const o=[];return s.forEach(i=>{for(let r=i-1;r>i-vn.length;r-=1){const l=r<0?r+vn.length:r;if(t.includes(l)){const a=(l+1)%7;o.push([a,i]);break}}}),o}static createRangeBreakValuesFromHolidays(e,t,n){const s=[],o=[];return e.forEach(i=>{i.businessPeriods.length>0?o.push(...q.createPartialHoliday(i,t,n)):s.push(q.createFullHoliday(i,t,n))}),[{values:s},...o]}static createFullHoliday(e,t,n){return q.adjustDateForTimeZone(`${e.date.toString()} 00:00:00.000000`,t,n)}static createPartialHoliday(e,t,n){const s=e.date.toString(),o=["00:00"];e.businessPeriods.forEach(r=>{o.push(r.open),o.push(r.close)}),o.push("24:00");const i=[];for(let r=0;r<o.length;r+=2){const l=o[r],a=o[r+1];if(l!==a){const c=[q.adjustDateForTimeZone(`${s} ${l}:00.000000`,t,n)],d=Sg*(q.periodToDecimal(a)-q.periodToDecimal(l));i.push({values:c,dvalue:d})}}return i}static adjustDateForTimeZone(e,t,n){return n&&n.standardOffset!==t.standardOffset?q.unwrapValue(q.wrapValue(e,el,t),n):e}static groupArray(e,t){return e.reduce((n,s)=>{var r;const o=s[t],i=(r=n.get(o))!=null?r:[];return i.push(s),n.set(o,i),n},new Map)}static unwrapValue(e,t){if(e!=null){if(bg(e))return E.i18n.DateTimeFormat.format(q.DATE_FORMAT,e,t);if(Eg(e))return e.asNumber()}return e}static wrapValue(e,t,n=null){if(N.isDateType(t)&&typeof e=="string"){const s=e,o=q.DATE_FORMAT.substr(0,e.length),i=E.i18n.DateTimeFormat.parse(o,s);if(!n)return i;const r=`${o} Z`,l=E.i18n.DateTimeFormat.format("Z",i,n),a=E.i18n.DateTimeFormat.parse(r,`${s} ${l}`),c=E.i18n.DateTimeFormat.format("Z",a,n);return E.i18n.DateTimeFormat.parse(r,`${s} ${c}`)}return e}static makeLayoutAxis(e,t=In){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===E.plot.AxisType.X?Object.assign(n,{showgrid:!0}):e===E.plot.AxisType.Y&&Object.assign(n,{zerolinecolor:t.zerolinecolor,zerolinewidth:2}),n}static getColorwayFromTheme(e=In){let t=[];return e.colorway&&(Array.isArray(e.colorway)?t=e.colorway:typeof e.colorway=="string"?t=e.colorway.split(" "):Us.warn(`Unable to handle colorway property: ${e.colorway}`)),t}static makeDefaultLayout(e=In){const t={...e,autosize:!0,colorway:q.getColorwayFromTheme(e),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:e.title_color},yanchor:"top",pad:{...q.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:e.title_color}},margin:{...q.DEFAULT_MARGIN},xaxis:q.makeLayoutAxis(E.plot.AxisType.X,e),yaxis:q.makeLayoutAxis(E.plot.AxisType.Y,e)};return t.datarevision=0,t}static hydrateSettings(e){return{...e,type:E.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:o}=e,i=q.titleFromSettings(e),r={formatType:`${E.plot.AxisFormatType.NUMBER}`,type:`${E.plot.AxisType.X}`,position:`${E.plot.AxisPosition.BOTTOM}`},l={formatType:`${E.plot.AxisFormatType.NUMBER}`,type:`${E.plot.AxisType.Y}`,position:`${E.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${E.plot.ChartType.XY}`,axes:[r,l],series:n.map(a=>({plotStyle:`${o}`,name:a,dataSources:[{type:`${E.plot.SourceType.X}`,columnName:s,axis:r,table:t},{type:`${E.plot.SourceType.Y}`,columnName:a,axis:l,table:t}]}))}],title:i}}};let we=q;we.DEFAULT_AXIS_SIZE=.15;we.MIN_AXIS_SIZE=.025;we.MAX_AXIS_SIZE=.2;we.AXIS_SIZE_PX=75;we.LEGEND_WIDTH_PX=50;we.MAX_LEGEND_SIZE=.25;we.ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});we.DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";we.DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});we.DEFAULT_TITLE_PADDING=Object.freeze({t:8});we.SUBTITLE_LINE_HEIGHT=25;we.DEFAULT_MARKER_SIZE=6;we.MODE_MARKERS="markers";we.MODE_LINES="lines";const Rn=le.module("Chart"),$s=class extends F.exports.Component{constructor(e){super(e),this.getCachedConfig=Fe((t,n,s,o)=>{const i=[],r=Boolean(t);if(r&&i.push({name:`Downsampling failed: ${t}`,click:()=>{},icon:$s.convertIcon(al),attr:"fill-warning"}),n||s||o||r){const l=$s.downsampleButtonTitle(s,o),a=$s.downsampleButtonAttr(s,o),c=s?bc:Ec;i.push({name:l,icon:$s.convertIcon(c),click:this.handleDownsampleClick,attr:a})}return{displaylogo:!1,displayModeBar:s||r?!0:"hover",modeBarButtons:[i,["toImage"],["zoom2d","pan2d"],["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]]}}),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=De.createRef(),this.plotWrapper=De.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}}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"}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()}getPlotRect(){var e,t;return(t=(e=this.plotWrapper.current)==null?void 0:e.getBoundingClientRect())!=null?t: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){Rn.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){var s;const{type:t,detail:n}=e;switch(Rn.debug2("Received data update",t,n),t){case Ze.EVENT_UPDATED:{this.currentSeries+=1,this.setState(i=>{const{layout:r,revision:l}=i;return typeof r.datarevision=="number"&&(r.datarevision+=1),{data:n,layout:r,revision:l+1}});const{onUpdate:o}=this.props;o({isLoading:!this.isLoadedFired});break}case Ze.EVENT_LOADFINISHED:{const{onUpdate:o}=this.props;this.isLoadedFired=!0,o({isLoading:!1});break}case Ze.EVENT_DISCONNECT:{const{onDisconnect:o}=this.props;o();break}case Ze.EVENT_RECONNECT:{const{onReconnect:o}=this.props;o();break}case Ze.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case Ze.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case Ze.EVENT_DOWNSAMPLENEEDED:case Ze.EVENT_DOWNSAMPLEFAILED:{const o=(s=n.message)!=null?s:n;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:o});const{onError:i}=this.props;i(new Error(o));break}default:Rn.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,n=we.getLayoutRanges(t);!it(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(e){if(Rn.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,n=[...e.hiddenlabels];t({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([e,t]){if(Rn.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:n}=this.state,{onSettingsChanged:s}=this.props;if(n!=null){const o=n.reduce((i,{name:r,visible:l})=>r!=null&&l==="legendonly"?[...i,r]:i,[]);s({hiddenSeries:o})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){Rn.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:o}=this.props;o.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:o={}}=e;(!it(this.columnFormats,t)||!it(this.dateTimeFormatterOptions,n)||!it(this.decimalFormatOptions,s)||!it(this.integerFormatOptions,o))&&(this.columnFormats=Jn.getColumnFormats(e),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=o,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&&Po.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{Rn.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:n,isDownsampleInProgress:s,isDownsamplingDisabled:o,layout:i,revision:r}=this.state,l=this.getCachedConfig(t,n,s,o),a=e!=null;return m("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:a&&m(hg,{ref:this.plot,data:e,layout:i,revision:r,config:l,onAfterPlot:this.handleAfterPlot,onError:Rn.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let Rg=$s;Rg.defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:qt.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};const nt=le.module("FigureChartModel"),ha=class extends Ze{constructor(e,t={},n=In){super(),this.addPendingSeries=vt(()=>{var r;const o=we.getAllAxes(this.figure),{pendingSeries:i}=this;for(let l=0;l<i.length;l+=1){const a=i[l],c=this.figure.charts.find(d=>d.series.includes(a));this.addSeries(a,o,(r=c==null?void 0:c.showLegend)!=null?r:null),a.subscribe()}this.pendingSeries=[]},ha.ADD_SERIES_DEBOUNCE),this.getTimeZone=Te((o,i)=>{if(i!=null){const r=i.getColumnTypeFormatter(o);if(r!=null)return r.dhTimeZone}}),this.getValueTranslator=Te((o,i)=>{const r=this.getTimeZone(o,i);return l=>we.unwrapValue(l,r)}),this.getValueParser=Te((o,i)=>{const r=this.getTimeZone(o,i);return l=>we.wrapValue(l,o,r)}),this.getRangeParser=Te((o,i)=>r=>{let[l,a]=r;const c=this.getValueParser(o,i);return l=c(l),a=c(a),[l,a]}),this.getAxisRangeParser=Te((o,i)=>r=>{const l=we.getSourceForAxis(o,r);return l?this.getRangeParser(l.columnType,i):a=>a}),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:we.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()}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=we.getAllAxes(this.figure),n=[];for(let i=0;i<e.length;i+=1){const r=e[i];for(let l=0;l<r.series.length;l+=1){const a=r.series[l];n.push(a.name),this.addSeries(a,t,r.showLegend)}}const o=[...this.seriesDataMap.keys()].filter(i=>n.indexOf(i)<0);for(let i=0;i<o.length;i+=1){const r=o[i];this.seriesDataMap.delete(r)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,n){const s=we.groupArray(t,"type"),o=we.makeSeriesDataFromSeries(e,s,we.getSeriesVisibility(e.name,this.settings),n,this.theme);if(this.seriesDataMap.set(e.name,o),this.data=[...this.seriesDataMap.values()],e.plotStyle===E.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===E.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=we.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===E.plot.SeriesPlotStyle.PIE?n!=null?n:void 0:!1,e.oneClick!=null){const{oneClick:i}=e,{columns:r}=i;for(let l=0;l<r.length;l+=1)this.filterColumnMap.set(r[l].name,r[l]);this.oneClicks.push(i)}this.updateLayoutFormats()}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){nt.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?E.plot.DownsampleOptions.DISABLE:E.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(E.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(E.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(E.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(E.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(E.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(E.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(E.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(E.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(e){nt.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){nt.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){nt.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){nt.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:n}=t;nt.debug2("handleFigureUpdated",n);for(let o=0;o<n.length;o+=1){const i=n[o];nt.debug2("handleFigureUpdated updating series",i.name);const{sources:r}=i;for(let l=0;l<r.length;l+=1){const a=r[l],{columnType:c,type:d}=a,u=this.getValueTranslator(c,this.formatter),h=t.getArray(i,d,u);this.setDataArrayForSeries(i,d,h)}this.seriesToProcess.delete(i.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(i)}const{data:s}=this;this.fireUpdate(s)}handleRequestFailed(e){nt.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){nt.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){nt.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;nt.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var s,o;super.setTitle(e);const t=(o=(s=(e!=null?e:"").match(/<br>/g))==null?void 0:s.length)!=null?o:0,n=we.DEFAULT_MARGIN.t+t*we.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=we.DEFAULT_TITLE_PADDING.t+t*we.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var e,t,n,s;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-((t=(e=this.layout.margin)==null?void 0:e.l)!=null?t:0)-((s=(n=this.layout.margin)==null?void 0:n.r)!=null?s:0),0)}getPlotHeight(){var e,t,n,s;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-((t=(e=this.layout.margin)==null?void 0:e.t)!=null?t:0)-((s=(n=this.layout.margin)==null?void 0:n.b)!=null?s:0),0)}updateAxisPositions(){const e=this.getPlotWidth(),t=this.getPlotHeight();we.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;we.getAxisFormats(this.figure,this.formatter).forEach((t,n)=>{nt.debug(`Assigning ${n}`,this.layout[n],t);const s=this.layout[n];s!=null?Object.assign(s,t):nt.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(e,t,n){const{name:s,plotStyle:o}=e,i=this.seriesDataMap.get(s),r=we.getPlotlyProperty(o,t);i&&ol(i,r,n)}cleanSeries(e){const{name:t,plotStyle:n}=e,s=this.seriesDataMap.get(t);if(s!=null){if(n===E.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:o,xHigh:i}=s;if(o&&i&&o.length===i.length){const r=[];for(let l=0;l<o.length;l+=1)r.push(i[l]-o[l]);s.width=r}}else if(n===E.plot.SeriesPlotStyle.LINE){const{x:o,xLow:i,xHigh:r,y:l,yLow:a,yHigh:c}=s;i&&r&&i!==o&&(s.error_x=we.getPlotlyErrorBars(o,i,r)),a&&c&&a!==l&&(s.error_y=we.getPlotlyErrorBars(l,a,c))}else if(n===E.plot.SeriesPlotStyle.TREEMAP){const{ids:o,labels:i}=s;o!==void 0&&i===void 0&&(s.labels=o)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){nt.warn("Trying to set a filter, but no one click!");return}nt.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(i=>{const r=e.get(i);this.lastFilter.get(i)!==r&&s.find(l=>l.name===i)!=null&&n.setValueForColumn(i,r)})}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}};let yg=ha;yg.ADD_SERIES_DEBOUNCE=50;function Fg({text:e,isOpen:t,onClose:n}){var b,v;const[s,o]=F.exports.useState(!1),[i,r]=F.exports.useState(0),[l,a]=F.exports.useState(!1),[c,d]=F.exports.useState(!1),[u,h]=F.exports.useState(!1),g=F.exports.useRef();F.exports.useEffect(function(){if(!!t){try{JSON.parse(e),h(!0)}catch{h(!1)}d(!1)}},[t,e]),F.exports.useEffect(function(){g.current&&g.current.layout()},[i]),F.exports.useEffect(function(){g.current&&g.current.updateOptions({lineNumbers:l?"on":"off"})},[l]);function p(){a(!l)}function f(){var R;const T=(R=g.current)==null?void 0:R.getModel();!u||!T||(c?(T.setValue(e),d(!1)):(T.setValue(JSON.stringify(JSON.parse(e),void 0,2)),d(!0)),C())}function C(){var R,D;const T=g.current;!T||a(((D=(R=T.getModel())==null?void 0:R.getLineCount())!=null?D:0)>1)}function w(){s&&(g.current=void 0,n())}function S(T){g.current=T,r(T.getContentHeight()),T.onDidContentSizeChange(({contentHeight:R})=>r(R)),C()}return!t&&!s?null:y(vc,{isOpen:t,centered:!0,keyboard:!0,toggle:w,onOpened:()=>o(!0),onClosed:()=>{o(!1),r(0)},className:"theme-bg-dark cell-overflow-modal",size:"xl",children:[y(Rc,{toggle:n,children:[m("h5",{className:"overflow-modal-title",children:"Cell Contents"}),m(gl,{kind:"inline",tooltip:"Copy cell contents",copy:(v=(b=g.current)==null?void 0:b.getValue())!=null?v:e}),m(z,{kind:"inline",active:l,icon:yc,tooltip:"Toggle line numbers",onClick:p}),u&&m(z,{kind:"inline",icon:Fc,active:c,tooltip:"Format as JSON",onClick:f})]}),m(Dc,{style:{height:i},children:m(or,{onEditorInitialized:S,settings:{value:e,readOnly:!0,wordWrap:"on",language:u?"typescript":"plaintext",folding:u,padding:{bottom:16},lineNumbers:l?"on":"off",overviewRulerLanes:0,renderLineHighlight:"none",find:{seedSearchStringFromSelection:"never"}}})})]})}function Dg(e){return e.model!==void 0}const Ig="###,##0";function Ng({gotoRow:e,gotoRowError:t,gotoValueError:n,onGotoRowSubmit:s,isShown:o,onEntering:i,onEntered:r,onExiting:l,onExited:a,model:c,onGotoRowNumberChanged:d,onClose:u,gotoValueSelectedColumnName:h,gotoValue:g,onGotoValueSelectedColumnNameChanged:p,onGotoValueSelectedFilterChanged:f,onGotoValueChanged:C,onGotoValueSubmit:w}){const S=F.exports.useRef(null),b=F.exports.useRef(null),[v,T]=F.exports.useState(!1);let R=[];Dg(c)&&c.table!==void 0&&({columns:R}=c.table);const D="Row number",{rowCount:A}=c,I=G=>{G.key==="Enter"?(G.stopPropagation(),G.preventDefault(),w()):(G.key==="Backspace"||G.key==="Delete")&&(g===`${Number.POSITIVE_INFINITY}`||g===`${Number.NEGATIVE_INFINITY}`)&&Y("")},L=G=>{G.key==="Enter"&&(G.stopPropagation(),G.preventDefault(),w())},k=c.getColumnIndexByName(h),x=R[k!=null?k:0],W=x==null?void 0:x.type,V=N.getNormalizedType(W),Y=G=>{C(G!=null?G:"")},j=()=>{var G,ee;v&&document.activeElement!==S.current?(G=S.current)==null||G.select():!v&&document.activeElement!==b.current&&((ee=b.current)==null||ee.select())};F.exports.useEffect(j,[v,e,g]);const ie=()=>{switch(V){case N.dataType.DECIMAL:case N.dataType.INT:return m("div",{className:"goto-row-input",children:m("input",{ref:b,className:Z("form-control",{"is-invalid":n!==""}),onKeyDown:I,placeholder:"value",onChange:G=>{const ee=G.target.value.toLowerCase();/^-?[0-9]*\.?[0-9]*$/.test(G.target.value)?Y(G.target.value):ee==="-i"||ee==="-infinity"?Y(`${Number.NEGATIVE_INFINITY}`):(ee==="i"||ee==="infinity")&&Y(`${Number.POSITIVE_INFINITY}`)},value:g})});case N.dataType.DATETIME:return m("div",{className:"goto-value-date-time-input",children:m(Ac,{className:Z("form-control","goto-value-date-time-input",{"is-invalid":n!==""}),defaultValue:g,onChange:Y})});case N.dataType.STRING:return y(Oe,{children:[m("div",{className:"goto-row-input",children:y("select",{className:"custom-select",onChange:G=>{f(G.target.value)},children:[m("option",{value:P.eq,children:"Equals"},P.eq),m("option",{value:P.contains,children:"Contains"},P.contains),m("option",{value:P.eqIgnoreCase,children:"EqIgnoreCase"},P.eqIgnoreCase)]})}),m("div",{className:"goto-row-input",children:m("input",{ref:b,className:Z("form-control",{"is-invalid":n!==""}),onKeyDown:L,placeholder:"value",onChange:G=>Y(G.target.value),value:g})})]});case N.dataType.BOOLEAN:return m("div",{className:"goto-row-input",children:y("select",{className:"custom-select",onChange:G=>{Y(G.target.value)},value:g,children:[m("option",{"aria-label":"null value",value:""},"null"),m("option",{value:"true",children:"true"},"true"),m("option",{value:"false",children:"false"},"false")]})});default:return m("div",{className:"goto-row-input",children:m("input",{ref:b,className:"form-control",onKeyDown:L,placeholder:"value",onChange:G=>Y(G.target.value),value:g})})}};return m(Jo,{isShown:o,className:Z("goto-row"),onEntering:i,onEntered:()=>{r(),j()},onExiting:l,onExited:a,children:y(Oe,{children:[y("div",{className:"goto-row-row",children:[y("div",{className:Z("goto-row-wrapper",{"is-inactive":!v}),onClick:()=>T(!0),onFocus:()=>T(!0),role:"group",children:[m("div",{className:"goto-row-text",children:"Go to row"}),m("div",{className:"goto-row-input",children:m("input",{ref:S,type:"number",onKeyDown:G=>{G.key==="Enter"&&(G.stopPropagation(),G.preventDefault(),s())},className:Z("form-control",{"is-invalid":t!==""}),placeholder:D,onChange:G=>{d(G)},value:e})}),y("div",{className:"goto-row-text",children:["of ",dh.i18n.NumberFormat.format(Ig,A)]}),t&&m("div",{className:"text-danger",children:t})]}),m("div",{className:"goto-row-close",children:m(z,{kind:"ghost",onClick:u,children:m(J,{icon:Xs,style:{marginRight:"0"}})})})]}),c.isSeekRowAvailable&&m("div",{className:"goto-row-row",children:y("div",{className:Z("goto-row-wrapper",{"is-inactive":v}),onClick:()=>T(!1),onFocus:()=>T(!1),role:"group",children:[m("div",{className:"goto-row-text",children:"Go to value"}),m("div",{className:"goto-row-input",children:m("select",{className:"custom-select",onChange:G=>{const ee=G.target.value;p(ee)},value:h,children:R.map(G=>m("option",{value:G.name,children:G.name},G.name))})}),ie(),y("div",{children:[m(z,{kind:"ghost",disabled:g==="",onClick:()=>{w(!0)},children:m(J,{icon:Ic})}),m(z,{kind:"ghost",disabled:g==="",onClick:()=>{w(!1)},children:m(J,{icon:Nc})})]}),n&&m("div",{className:"text-danger",children:n})]})})]})})}const re=le.module("IrisGrid"),Ag=500,Mg=250,Og=250,xg=250,ma=Object.freeze({aggregations:ye,showOnTop:!1}),kg="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function nl({advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:o,rollupConfig:i,searchFilter:r,selectDistinctColumns:l,sorts:a}){return e.size===0&&t.aggregations.length===0&&n.length===0&&s.size===0&&o===N.REVERSE_TYPE.NONE&&i==null&&r==null&&l.length===0&&a.length===0}const Nn=class extends F.exports.Component{constructor(e){var j,ie,G,ee;super(e),this.getAdvancedMenuOpenedHandler=Te(H=>this.handleAdvancedMenuOpened.bind(this,H),{max:100}),this.getCachedAdvancedFilterMenuActions=Te((H,$,se,ne,he)=>m(Ji,{model:H,column:$,onFilterChange:this.handleAdvancedFilterChange,onSortChange:this.handleAdvancedFilterSortChange,onDone:this.handleAdvancedFilterDone,options:se,sortDirection:ne,formatter:he}),{max:50}),this.getCachedOptionItems=Te((H,$,se,ne,he,ve,Ie,Ge,me,ke,Ot,Ct,hn,xt,rt,ge)=>{const Ee=[];return H&&Ee.push({type:Se.CHART_BUILDER,title:"Chart Builder",icon:Mc}),Ee.push({type:Se.VISIBILITY_ORDERING_BUILDER,title:"Organize Columns",icon:Gi}),se&&Ee.push({type:Se.CONDITIONAL_FORMATTING,title:"Conditional Formatting",icon:Pi}),$&&Ee.push({type:Se.CUSTOM_COLUMN_BUILDER,title:"Custom Columns",icon:Oc}),ne&&Ee.push({type:Se.ROLLUP_ROWS,title:"Rollup Rows",icon:xc}),he&&Ee.push({type:Se.AGGREGATIONS,title:"Aggregate Columns",icon:kc}),ve&&Ee.push({type:Se.SELECT_DISTINCT,title:"Select Distinct Values",icon:Lc}),Ie&&hn&&Ee.push({type:Se.TABLE_EXPORTER,title:"Download CSV",icon:Pc}),ge&&Ee.push({type:Se.ADVANCED_SETTINGS,title:"Advanced Settings",icon:_c}),Ee.push({type:Se.QUICK_FILTERS,title:"Quick Filters",subtitle:Ge.shortcut.getDisplayText(),icon:xo,isOn:Ot,onChange:Ge.action}),xt&&Ee.push({type:Se.SEARCH_BAR,title:"Search Bar",subtitle:me.shortcut.getDisplayText(),icon:Hc,isOn:Ct,onChange:me.action}),Ee.push({type:Se.GOTO,title:"Go to",subtitle:ke.shortcut.getDisplayText(),icon:Vc,isOn:rt,onChange:ke.action}),Object.freeze(Ee)},{max:1}),this.getCachedHiddenColumns=Te((H,$)=>Q.getHiddenColumns(new Map([...H.initialColumnWidths,...$])),{max:1}),this.getAggregationMap=Te((H,$)=>{const se={};return $.forEach(({operation:ne,selected:he,invert:ve})=>{se[ne]=On.getOperationColumnNames(H,ne,he,ve)}),se}),this.getOperationMap=Te((H,$)=>{const se={};return $.filter(ne=>!On.isRollupOperation(ne.operation)).forEach(({operation:ne,selected:he,invert:ve})=>{On.getOperationColumnNames(H,ne,he,ve).forEach(Ie=>{var me;const Ge=[...(me=se[Ie])!=null?me:[],ne];se[Ie]=Object.freeze(Ge)})}),se}),this.getOperationOrder=Te(H=>H.map($=>$.operation).filter($=>!On.isRollupOperation($))),this.getCachedFormatColumns=Te((H,$)=>pu(H,$)),this.getCachedModelColumns=Te((H,$)=>H.columns),this.getCachedPreviewFormatColumns=Te((H,$,se,ne)=>{if(re.debug("getCachedPreviewFormatColumns",$,se,ne),se!==void 0&&ne!==void 0){const he=[...$];return he[ne]=se,this.getCachedFormatColumns(H,he)}return this.getCachedFormatColumns(H,$)}),this.getModelRollupConfig=Te((H,$,se)=>Q.getModelRollupConfig(H,$,se)),this.getModelTotalsConfig=Te((H,$,se)=>{var Ge,me,ke;const{aggregations:ne,showOnTop:he}=se;if(((me=(Ge=$==null?void 0:$.columns)==null?void 0:Ge.length)!=null?me:0)>0||((ke=ne==null?void 0:ne.length)!=null?ke:0)===0)return null;const ve=this.getOperationMap(H,ne),Ie=this.getOperationOrder(ne);return{operationMap:ve,operationOrder:Ie,showOnTop:he}}),this.getCachedStateOverride=Te((H,$,se,ne,he,ve,Ie,Ge,me,ke)=>({hoverSelectColumn:H,isFilterBarShown:$,isSelectingColumn:se,loadingScrimProgress:ne,quickFilters:he,advancedFilters:ve,sorts:Ie,reverseType:Ge,rollupConfig:me,isMenuShown:ke}),{max:1}),this.getCachedFilter=Te((H,$,se,ne,he)=>[...H!=null?H:[],...ne!=null?ne:[],...Q.getFiltersFromFilterMap($),...Q.getFiltersFromFilterMap(se),...he!==void 0?[he]:[]],{max:1}),this.getCachedTheme=Te((H,$,se)=>({...Ml,...H,autoSelectRow:!$,rowFooterWidth:se>0?H.rowFooterWidth:0}),{max:1}),this.getAlwaysFetchColumns=Te((H,$,se,ne,he,ve)=>{const Ie=[];for(let me=0;me<ne;me+=1)Ie.push($[_.getModelIndex(me,se)].name);for(let me=0;me<he;me+=1)Ie.push($[_.getModelIndex($.length-1-me,se)].name);if(ve)for(let me=ve[0];me<=ve[1];me+=1)Ie.push($[_.getModelIndex(me,se)].name);const Ge=new Set([...H,...Ie]);return Object.freeze([...Ge])}),this.updateSearchFilter=vt((H,$,se,ne)=>{const he=No.createSearchFilter(H,$,se,ne);this.setState({searchFilter:he})},Mg),this.handleConditionalFormatEditorUpdate=vt(H=>{this.setState({conditionalFormatPreview:H})},xg),this.handleDownloadProgressUpdate=Pn((H,$)=>{const{tableDownloadStatus:se}=this.state;se===gt.DOWNLOAD_STATUS.DOWNLOADING&&this.setState({tableDownloadProgress:H,tableDownloadEstimatedTime:$})},Ag),this.getOverflowButtonTooltip=Te(H=>{if(H==null)return null;const $={position:"absolute",...H,pointerEvents:"none"};return m("div",{style:$,children:m(Rt,{options:{placement:"left",modifiers:{flip:{behavior:["left","right"]}}},ref:this.handleTooltipRef,children:"View full contents"},Date.now())})}),this.getExpandCellTooltip=Te(H=>{if(H==null)return null;const{expandTooltipDisplayValue:$}=this.state,se={position:"absolute",...H,pointerEvents:"none"};return m("div",{style:se,children:m(Rt,{options:{placement:"bottom-start"},ref:this.handleTooltipRef,children:y("div",{style:{textAlign:"left"},children:["Click to ",$," row",m("br",{}),_n.isMacPlatform()?"\u2318":"Ctrl+","Click to expand row and all children"]})},Date.now())})}),this.handleGotoValueChanged=H=>{this.setState({gotoValue:H}),this.debouncedSeekRow(H)},this.debouncedSeekRow=vt(H=>{this.seekRow(H)},Og),this.handleAdvancedFilterChange=this.handleAdvancedFilterChange.bind(this),this.handleAdvancedFilterSortChange=this.handleAdvancedFilterSortChange.bind(this),this.handleAdvancedFilterDone=this.handleAdvancedFilterDone.bind(this),this.handleAdvancedMenuOpened=this.handleAdvancedMenuOpened.bind(this),this.handleGotoRowOpened=this.handleGotoRowOpened.bind(this),this.handleGotoRowClosed=this.handleGotoRowClosed.bind(this),this.handleAdvancedMenuClosed=this.handleAdvancedMenuClosed.bind(this),this.handleAggregationChange=this.handleAggregationChange.bind(this),this.handleAggregationsChange=this.handleAggregationsChange.bind(this),this.handleAggregationEdit=this.handleAggregationEdit.bind(this),this.handleAnimationLoop=this.handleAnimationLoop.bind(this),this.handleAnimationStart=this.handleAnimationStart.bind(this),this.handleAnimationEnd=this.handleAnimationEnd.bind(this),this.handleChartChange=this.handleChartChange.bind(this),this.handleChartCreate=this.handleChartCreate.bind(this),this.handleGridError=this.handleGridError.bind(this),this.handleFilterBarChange=this.handleFilterBarChange.bind(this),this.handleFilterBarDone=this.handleFilterBarDone.bind(this),this.handleFilterBarTab=this.handleFilterBarTab.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleMenu=this.handleMenu.bind(this),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleMenuSelect=this.handleMenuSelect.bind(this),this.handleMenuBack=this.handleMenuBack.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleSelectionChanged=this.handleSelectionChanged.bind(this),this.handleMovedColumnsChanged=this.handleMovedColumnsChanged.bind(this),this.handleHeaderGroupsChanged=this.handleHeaderGroupsChanged.bind(this),this.handleUpdate=this.handleUpdate.bind(this),this.handleTooltipRef=this.handleTooltipRef.bind(this),this.handleViewChanged=this.handleViewChanged.bind(this),this.handleFormatSelection=this.handleFormatSelection.bind(this),this.handleConditionalFormatCreate=this.handleConditionalFormatCreate.bind(this),this.handleConditionalFormatEdit=this.handleConditionalFormatEdit.bind(this),this.handleConditionalFormatsChange=this.handleConditionalFormatsChange.bind(this),this.handleConditionalFormatEditorSave=this.handleConditionalFormatEditorSave.bind(this),this.handleConditionalFormatEditorCancel=this.handleConditionalFormatEditorCancel.bind(this),this.handleUpdateCustomColumns=this.handleUpdateCustomColumns.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.handleSelectDistinctChanged=this.handleSelectDistinctChanged.bind(this),this.handlePendingDataUpdated=this.handlePendingDataUpdated.bind(this),this.handlePendingCommitClicked=this.handlePendingCommitClicked.bind(this),this.handlePendingDiscardClicked=this.handlePendingDiscardClicked.bind(this),this.handleGotoRowSelectedRowNumberSubmit=this.handleGotoRowSelectedRowNumberSubmit.bind(this),this.focusRowInGrid=this.focusRowInGrid.bind(this),this.handleDownloadTable=this.handleDownloadTable.bind(this),this.handleDownloadTableStart=this.handleDownloadTableStart.bind(this),this.handleCancelDownloadTable=this.handleCancelDownloadTable.bind(this),this.handleDownloadCanceled=this.handleDownloadCanceled.bind(this),this.handleDownloadCompleted=this.handleDownloadCompleted.bind(this),this.handlePartitionAppend=this.handlePartitionAppend.bind(this),this.handlePartitionChange=this.handlePartitionChange.bind(this),this.handlePartitionFetchAll=this.handlePartitionFetchAll.bind(this),this.handlePartitionDone=this.handlePartitionDone.bind(this),this.handleColumnVisibilityChanged=this.handleColumnVisibilityChanged.bind(this),this.handleColumnVisibilityReset=this.handleColumnVisibilityReset.bind(this),this.handleCrossColumnSearch=this.handleCrossColumnSearch.bind(this),this.handleRollupChange=this.handleRollupChange.bind(this),this.handleOverflowClose=this.handleOverflowClose.bind(this),this.getColumnBoundingRect=this.getColumnBoundingRect.bind(this),this.handleGotoRowSelectedRowNumberChanged=this.handleGotoRowSelectedRowNumberChanged.bind(this),this.handleGotoValueSelectedColumnNameChanged=this.handleGotoValueSelectedColumnNameChanged.bind(this),this.handleGotoValueSelectedFilterChanged=this.handleGotoValueSelectedFilterChanged.bind(this),this.handleGotoValueChanged=this.handleGotoValueChanged.bind(this),this.handleGotoValueSubmitted=this.handleGotoValueSubmitted.bind(this),this.grid=null,this.gridWrapper=null,this.lastLoadedConfig=null,this.pending=new Ko,this.globalColumnFormats=ye,this.decimalFormatOptions={},this.integerFormatOptions={},this.truncateNumbersWithPound=!1,this.renderer=new Ys,this.tableSaver=null,this.crossColumnRef=De.createRef(),this.isAnimating=!1,this.filterInputRef=De.createRef(),this.toggleFilterBarAction={action:()=>this.toggleFilterBar(),shortcut:Nt.TABLE.TOGGLE_QUICK_FILTER},this.toggleSearchBarAction={action:()=>this.toggleSearchBar(),shortcut:Nt.TABLE.TOGGLE_SEARCH},this.toggleGotoRowAction={action:()=>this.toggleGotoRow(),shortcut:Nt.TABLE.GOTO_ROW},this.discardAction={action:()=>{const{model:H}=this.props;Pe(H)&&H.isEditable&&H.pendingDataMap.size>0&&this.discardPending().catch(re.error)},shortcut:Nt.INPUT_TABLE.DISCARD},this.commitAction={action:()=>{const{model:H}=this.props;Pe(H)&&H.isEditable&&H.pendingDataMap.size>0&&H.pendingDataErrors.size===0&&this.commitPending().catch(re.error)},shortcut:Nt.INPUT_TABLE.COMMIT},this.contextActions=[this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,this.discardAction,this.commitAction];const{aggregationSettings:t,conditionalFormats:n,customColumnFormatMap:s,isFilterBarShown:o,isSelectingPartition:i,model:r,movedColumns:l,movedRows:a,partition:c,partitionColumn:d,rollupConfig:u,userColumnWidths:h,userRowHeights:g,showSearchBar:p,searchValue:f,selectedSearchColumns:C,invertSearchColumns:w,advancedFilters:S,quickFilters:b,selectDistinctColumns:v,pendingDataMap:T,canCopy:R,frozenColumns:D,columnHeaderGroups:A}=e,I=[new Mu(this),new Ou(this)];R&&I.push(new Iu(this));const L=[new xu(this),new Vu(this),new ku(this),new Lu(this),new Uu(this),new Hu(this),new Xt(this),new _u(this),new Bu(this)],k=l.length>0?l:r.initialMovedColumns,x=a.length>0?a:r.initialMovedRows,W=new $u({userColumnWidths:new Map(h),userRowHeights:new Map(g),movedColumns:k,initialColumnWidths:new Map((ie=(j=r==null?void 0:r.layoutHints)==null?void 0:j.hiddenColumns)==null?void 0:ie.map(H=>[r.getColumnIndexByName(H),0]))}),V=C!=null?C:[],Y=No.createSearchFilter(f,V,r.columns,w);this.state={isFilterBarShown:o,isSelectingPartition:i,focusedFilterBarColumn:null,metricCalculator:W,metrics:void 0,keyHandlers:I,mouseHandlers:L,partition:c,partitionColumn:d,partitionTable:null,partitionFilters:[],quickFilters:b?new Map(b):new Map,advancedFilters:new Map(S),shownAdvancedFilter:null,hoverAdvancedFilter:null,sorts:[],reverseType:N.REVERSE_TYPE.NONE,customColumns:[],selectDistinctColumns:v,selectedRanges:[],copyOperation:null,loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1,movedColumns:k,movedRows:x,shownColumnTooltip:null,formatter:new zt,isMenuShown:!1,customColumnFormatMap:new Map(s),conditionalFormats:n,conditionalFormatEditIndex:null,conditionalFormatPreview:void 0,hoverSelectColumn:null,isTableDownloading:!1,isReady:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:0,showSearchBar:p,searchFilter:Y,searchValue:f,selectedSearchColumns:V,invertSearchColumns:w,rollupConfig:u,rollupSelectedColumns:[],aggregationSettings:t,selectedAggregation:null,openOptions:[],pendingRowCount:0,pendingDataMap:T!=null?T:new Map,pendingDataErrors:new Map,pendingSavePromise:null,pendingSaveError:null,toastMessage:null,frozenColumns:D,showOverflowModal:!1,overflowText:"",overflowButtonTooltipProps:null,expandCellTooltipProps:null,expandTooltipDisplayValue:"expand",isGotoShown:!1,gotoRow:"",gotoRowError:"",gotoValueError:"",gotoValueSelectedColumnName:(ee=(G=r.columns[0])==null?void 0:G.name)!=null?ee:"",gotoValueSelectedFilter:P.eq,gotoValue:"",columnHeaderGroups:A!=null?A:r.initialColumnHeaderGroups}}static makeQuickFilter(e,t,n){try{return N.makeQuickFilter(e,t,n)}catch(s){re.error("Error creating quick filter",s)}return null}componentDidMount(){const{partitionColumn:e,model:t}=this.props,n=e!=null?e:t.columns.find(s=>s.isPartitionColumn);t.isFilterRequired&&t.isValuesTableAvailable&&n!=null?this.loadPartitionsTable(n):this.initState(),this.startListening(t)}componentDidUpdate(e){var d;const{inputFilters:t,isSelectingColumn:n,settings:s,model:o,customFilters:i,sorts:r}=this.props;o!==e.model&&(this.stopListening(e.model),this.startListening(o));const l=t!==e.inputFilters?t.filter(u=>!e.inputFilters.includes(u)):[];if(l.length>0){const{advancedSettings:u}=this.props,h=(d=u.get(ns.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS))!=null?d:!1;h&&(this.clearGridInputField(),this.clearCrossColumSearch()),this.startLoading("Filtering...",!0),this.applyInputFilters(l,h)}n!==e.isSelectingColumn&&this.resetColumnSelection(),s!==e.settings&&this.updateFormatterSettings(s),i!==e.customFilters&&this.startLoading("Filtering...",!0),r!==e.sorts&&this.updateSorts(r);const{loadingScrimStartTime:a,loadingScrimFinishTime:c}=this;a!=null&&c!=null&&window.requestAnimationFrame(()=>{const u=Date.now(),h=u-a,g=c-a,p=Math.min(h/g,1);c<u&&(this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0),this.setState(f=>f.loadingScrimProgress==null?(re.debug2("Ignoring scrim update because loading cancelled."),null):{loadingScrimProgress:p})}),this.sendStateChange()}componentWillUnmount(){const{model:e}=this.props;this.stopListening(e),this.pending.cancel(),this.updateSearchFilter.cancel(),this.loadingTimer&&clearTimeout(this.loadingTimer),this.handleDownloadProgressUpdate.cancel(),this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame)}getValueForCell(e,t,n=!1){const{model:s}=this.props,o=this.getModelColumn(e),i=this.getModelRow(t);if(n&&o!=null&&i!=null){const r=s.valueForCell(o,i);if(N.isDateType(s.columns[o].type)){const{formatter:l}=s;return E.i18n.DateTimeFormat.format(kg,r,E.i18n.TimeZone.getTimeZone(l.timeZone))}return r}return n?null:o!=null&&i!=null?s.textForCell(o,i):""}getModelColumn(e){const{metrics:t}=this.state;M(t);const{modelColumns:n}=t;return n==null?null:e!=null?n.get(e):null}getModelRow(e){const{metrics:t}=this.state;M(t);const{modelRows:n}=t;return n==null?null:e!=null?n.get(e):null}getTheme(){var n;const{model:e,theme:t}=this.props;return this.getCachedTheme(t,(n=Pe(e)&&e.isEditable)!=null?n:!1,e.floatingTopRowCount+e.floatingBottomRowCount)}getVisibleColumn(e){const{movedColumns:t}=this.state;return _.getVisibleIndex(e,t)}applyInputFilters(e,t=!1){const{model:n}=this.props,{advancedFilters:s,quickFilters:o}=this.state,i=t?new Map:new Map(s),r=t?new Map:new Map(o);let l=t&&s.size>0;e.forEach(({name:a,type:c,value:d})=>{const u=n.columns.findIndex(({name:h,type:g})=>h===a&&g===c);u>=0?(l=i.delete(u)||l,l=this.applyQuickFilter(u,d,r)||l):re.error("Unable to find column for inputFilter",a,c,d)}),l&&this.setState({quickFilters:r,advancedFilters:i})}applyQuickFilter(e,t,n){const{model:s}=this.props,{formatter:o}=s,i=s.columns[e];if(t!=null&&`${t}`.trim().length>0){const r=n.get(e);if(r!=null){const{text:l}=r;if(l===t)return re.debug2("Ignoring change to existing filter"),!1}return n.set(e,{text:t,filter:Nn.makeQuickFilter(i,t,o.timeZone)}),!0}return n.delete(e)}setAdvancedFilterMap(e){this.setState({advancedFilters:e})}setAdvancedFilter(e,t,n){re.debug("Setting advanced filter",e,t),this.startLoading("Filtering...",!0),this.setState(({advancedFilters:s})=>{const o=new Map(s);return t==null?o.delete(e):o.set(e,{filter:t,options:n}),{advancedFilters:o}})}setQuickFilter(e,t,n){re.debug("Setting quick filter",e,t,n),this.startLoading("Filtering...",!0),this.setState(({quickFilters:s})=>{const o=new Map(s);return o.set(e,{filter:t,text:n}),{quickFilters:o}})}setFilterMap(e){var o;re.debug("setFilterMap",e);const{advancedSettings:t}=this.props;((o=t.get(ns.LINK_CHANGE_CLEARS_ALL_FILTERS))!=null?o:!1)&&this.clearAllFilters();const{model:s}=this.props;e.forEach(({columnType:i,filterList:r},l)=>{const a=s.columns.find(u=>u.name===l&&u.type===i);if(a==null)return;const c=s.getColumnIndexByName(a.name);M(c);const d=Q.combineFiltersFromList(i,r);if(d.length===0)this.removeQuickFilter(c);else{const{formatter:u}=s;this.setQuickFilter(c,Nn.makeQuickFilter(a,d,u.timeZone),`${d}`)}})}removeColumnFilter(e){this.startLoading("Filtering...",!0),this.setState(({advancedFilters:t,quickFilters:n})=>{const s=t?new Map(t):new Map,o=n?new Map(n):new Map;return o.delete(e),s.delete(e),{quickFilters:o,advancedFilters:s}})}removeQuickFilter(e){this.startLoading("Clearing Filter...",!0),this.setState(({quickFilters:t})=>{const n=new Map(t);return n.delete(e),{quickFilters:n}})}clearAllFilters(){re.debug("Clearing all filters");const{advancedFilters:e,quickFilters:t,searchFilter:n}=this.state;t.size===0&&e.size===0&&n===null||(this.clearGridInputField(),this.startLoading("Clearing Filters...",!0),this.setState({quickFilters:new Map,advancedFilters:new Map,searchValue:"",searchFilter:void 0}))}clearCrossColumSearch(){re.debug("Clearing cross-column search"),this.setState({searchValue:"",searchFilter:void 0})}clearGridInputField(){this.filterInputRef.current!=null&&this.filterInputRef.current.setValue("")}rebuildFilters(){re.debug("Rebuilding filters");const{model:e}=this.props,{advancedFilters:t,quickFilters:n}=this.state,{columns:s,formatter:o}=e,i=new Map,r=new Map;t.forEach((l,a)=>{const{options:c}=l,d=s[a],u=N.makeAdvancedFilter(d,c,o.timeZone);i.set(a,{options:c,filter:u})}),n.forEach((l,a)=>{const{text:c}=l,d=s[a];r.set(a,{text:c,filter:Nn.makeQuickFilter(d,c,o.timeZone)})}),this.startLoading("Rebuilding filters...",!0),this.setState({quickFilters:r,advancedFilters:i})}setFilters({quickFilters:e,advancedFilters:t}){this.setState({quickFilters:e,advancedFilters:t})}updateFormatterSettings(e,t=!0){var h,g,p;const n=Jn.getColumnFormats(e),s=Jn.getDateTimeFormatterOptions(e),o=(h=e==null?void 0:e.defaultDecimalFormatOptions)!=null?h:{},i=(g=e==null?void 0:e.defaultIntegerFormatOptions)!=null?g:{},r=(p=e==null?void 0:e.truncateNumbersWithPound)!=null?p:!1,l=!it(this.globalColumnFormats,n),a=!it(this.dateTimeFormatterOptions,s),c=!it(this.decimalFormatOptions,e==null?void 0:e.defaultDecimalFormatOptions),d=!it(this.integerFormatOptions,i),u=this.truncateNumbersWithPound!==r;(l||a||c||d||u)&&(this.globalColumnFormats=n,this.dateTimeFormatterOptions=s,this.decimalFormatOptions=o,this.integerFormatOptions=i,this.truncateNumbersWithPound=r,this.updateFormatter({},t),a&&t&&this.rebuildFilters())}updateFormatter(e,t=!0){var r;const{customColumnFormatMap:n}=this.state,s={customColumnFormatMap:n,...e},o=[...(r=this.globalColumnFormats)!=null?r:[],...s.customColumnFormatMap.values()],i=new zt(o,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions,this.truncateNumbersWithPound);re.debug("updateFormatter",this.globalColumnFormats,o),this.setState({...s,formatter:i},()=>{t&&this.grid&&this.grid.forceUpdate()})}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}initState(){const{applyInputFiltersOnInit:e,inputFilters:t,sorts:n,model:s,reverseType:o,customColumns:i,searchValue:r,selectedSearchColumns:l,invertSearchColumns:a}=this.props,c=l!=null?l:[],d=No.createSearchFilter(r,c,s.columns,a);if(e){const u=t.filter(h=>h.value!=null);this.applyInputFilters(u)}this.setState({sorts:n,reverseType:o,customColumns:i,isReady:!0,searchFilter:d}),this.initFormatter()}async loadPartitionsTable(e){const{model:t}=this.props;this.setState({isSelectingPartition:!0});try{const n=await this.pending.add(t.valuesTable(e),r=>r.close()),s=n.columns[0],o=s.sort().desc();n.applySort([o]),n.setViewport(0,0,[s]);const i=await this.pending.add(n.getViewportData());if(i.rows.length>0){const l=i.rows[0].get(s);this.updatePartition(l,e),this.setState({isSelectingPartition:!0})}else re.info("Table does not have any data, just fetching all"),this.setState({isSelectingPartition:!1}),this.handlePartitionFetchAll();this.setState({partitionTable:n,partitionColumn:e},()=>{this.initState()})}catch(n){this.handleTableLoadError(n)}}updatePartition(e,t){const s=[t.filter().eq(E.FilterValue.ofString(e))];this.setState({partition:e,partitionFilters:s})}copyCell(e,t,n=!1){const{canCopy:s}=this.props;if(s){const o=String(this.getValueForCell(e,t,n));qo(o).catch(i=>re.error("Unable to copy cell",i))}else re.error("Attempted to copyCell for user without copy permission.")}copyRanges(e,t=!1,n=!0,s){const{model:o,canCopy:i}=this.props,{metricCalculator:r,movedColumns:l}=this.state,a=r.getUserColumnWidths();if(i){const c={ranges:K.boundedRanges(e,o.columnCount,o.rowCount),includeHeaders:t,formatValues:n,movedColumns:l,userColumnWidths:a,error:s};this.setState({copyOperation:c})}else re.error("Attempted copyRanges for user without copy permission.")}startLoading(e,t=!1){var s,o;this.setState({loadingText:e});const n=this.getTheme();if(t&&this.grid&&(this.grid.clearSelectedRanges(),this.grid.setViewState({top:0},!0)),this.loadingScrimStartTime==null){const{minScrimTransitionTime:i,maxScrimTransitionTime:r}=n;M(i),M(r);const l=(o=(s=this.gridWrapper)==null?void 0:s.getBoundingClientRect().height)!=null?o:0,a=Math.max(i,Math.min(l/2,r));this.loadingScrimStartTime=Date.now(),this.loadingScrimFinishTime=this.loadingScrimStartTime+a,this.setState({loadingScrimProgress:0}),this.loadingTimer=setTimeout(()=>{this.setState({loadingSpinnerShown:!0})},Nn.loadingSpinnerDelay)}}stopLoading(){this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0,this.setState({loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1}),this.loadingTimer!=null&&(clearTimeout(this.loadingTimer),this.loadingTimer=void 0)}rollback(){if(this.lastLoadedConfig){re.debug("loading last loading config",this.lastLoadedConfig);const{advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:o,rollupConfig:i,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.lastLoadedConfig;this.lastLoadedConfig=null,this.setState({advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:o,rollupConfig:i,searchFilter:r,selectDistinctColumns:l,sorts:a})}else re.debug("remove all sorts, filters, and custom columns"),this.setState({advancedFilters:new Map,aggregationSettings:ma,customColumns:[],quickFilters:new Map,reverseType:N.REVERSE_TYPE.NONE,rollupConfig:void 0,selectDistinctColumns:[],sorts:[]})}canRollback(){return this.lastLoadedConfig!=null||!nl(this.state)}startListening(e){e.addEventListener(ue.EVENT.UPDATED,this.handleUpdate),e.addEventListener(ue.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.addEventListener(ue.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.addEventListener(ue.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}stopListening(e){e.removeEventListener(ue.EVENT.UPDATED,this.handleUpdate),e.removeEventListener(ue.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.removeEventListener(ue.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.removeEventListener(ue.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}focus(){var e;(e=this.grid)==null||e.focus()}focusFilterBar(e){var d,u,h;const{movedColumns:t}=this.state,{model:n}=this.props,{columnCount:s}=n,o=_.getModelIndex(e,t);if(e==null||e<0||s<=e||!n.isFilterable(o)){this.setState({focusedFilterBarColumn:null});return}const{metricCalculator:i,metrics:r}=this.state;M(r);const{left:l,rightVisible:a,lastLeft:c}=r;if(e<l)(d=this.grid)==null||d.setViewState({left:e},!0);else if(a<e){const g=(u=this.grid)==null?void 0:u.getMetricState();M(g);const p=i.getLastLeft(g,e,i.getVisibleWidth(g));(h=this.grid)==null||h.setViewState({left:Math.min(p,c),leftOffset:0},!0)}this.lastFocusedFilterBarColumn=e,this.setState({focusedFilterBarColumn:e,isFilterBarShown:!0})}hideColumnByVisibleIndex(e){var s;const{metricCalculator:t,movedColumns:n}=this.state;t.setColumnWidth(_.getModelIndex(e,n),0),(s=this.grid)==null||s.forceUpdate()}freezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;re.debug2("freezing column",e);const o=t==null?new Set(s.frozenColumns):new Set(t);o.add(e);const i=s.getColumnIndexByName(e);M(i);const r=_.getVisibleIndex(i,n),l=_.moveItem(r,o.size-1,n);this.setState({frozenColumns:[...o],movedColumns:l})}unFreezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;re.debug2("unfreezing column",e);const o=t==null?new Set(s.frozenColumns):new Set(t);o.delete(e);const i=s.getColumnIndexByName(e);M(i);const r=_.getVisibleIndex(i,n),l=_.moveItem(r,o.size+s.frontColumns.length,n);this.setState({frozenColumns:[...o],movedColumns:l})}handleColumnVisibilityChanged(e,t){var o;const{metricCalculator:n,metrics:s}=this.state;M(s),t?e.forEach(i=>{const r=n.initialColumnWidths.get(i),l=O(s.calculatedColumnWidths,i);r!==l?n.setColumnWidth(i,l):n.resetColumnWidth(i)}):e.forEach(i=>{n.setColumnWidth(i,0)}),(o=this.grid)==null||o.forceUpdate()}handleColumnVisibilityReset(){var s,o;const{metricCalculator:e,metrics:t}=this.state,{model:n}=this.props;M(t);for(let i=0;i<t.columnCount;i+=1)e.resetColumnWidth(i);this.handleMovedColumnsChanged(n.initialMovedColumns),this.handleHeaderGroupsChanged(n.initialColumnHeaderGroups),this.setState({frozenColumns:(o=(s=n.layoutHints)==null?void 0:s.frozenColumns)!=null?o:[]})}handleCrossColumnSearch(e,t,n){const{model:s}=this.props;this.updateSearchFilter(e,t,s.columns,n),this.setState({searchValue:e,selectedSearchColumns:t,invertSearchColumns:n})}handleAnimationLoop(){var e,t;(e=this.grid)==null||e.updateCanvasScale(),(t=this.grid)==null||t.updateCanvas(),this.isAnimating&&(this.animationFrame=requestAnimationFrame(this.handleAnimationLoop))}handleAnimationStart(){re.debug2("handleAnimationStart"),this.isAnimating=!0,this.animationFrame=requestAnimationFrame(this.handleAnimationLoop)}handleAnimationEnd(){re.debug2("handleAnimationEnd"),this.isAnimating=!1}handlePartitionAppend(e){const{onPartitionAppend:t}=this.props,{partitionColumn:n}=this.state;n!=null&&t(n,e)}handlePartitionChange(e){const{partitionColumn:t}=this.state;t!=null&&this.updatePartition(e,t)}handlePartitionFetchAll(){this.setState({partitionFilters:[],isSelectingPartition:!1})}handlePartitionDone(){this.setState({isSelectingPartition:!1})}handleTableLoadError(e){if(ze.isCanceled(e))return;re.error(e);const{onError:t}=this.props;t(e)}showAllColumns(){var s;const{metricCalculator:e}=this.state,n=[...e.getUserColumnWidths().entries()];for(let o=0;o<n.length;o+=1){const[i,r]=n[o];r===0&&e.resetColumnWidth(i)}(s=this.grid)==null||s.forceUpdate()}toggleSort(e,t){re.info("Toggling sort for column",e);const{model:n}=this.props,{sorts:s}=this.state,o=this.getModelColumn(e);M(o);const i=N.toggleSortForColumn(s,n.columns,o,t);this.updateSorts(i)}updateSorts(e){var t;this.startLoading("Sorting..."),this.setState({sorts:e}),(t=this.grid)==null||t.forceUpdate()}sortColumn(e,t=N.sortDirection.none,n=!1,s=!1){var r;M(e);const{model:o}=this.props,i=N.sortColumn(o.sort,o.columns,e,t,n,s);this.startLoading("Sorting..."),this.setState({sorts:i}),(r=this.grid)==null||r.forceUpdate()}reverse(e){var t;this.startLoading("Reversing..."),this.setState({reverseType:e}),(t=this.grid)==null||t.forceUpdate()}isReversible(){const{model:e}=this.props;return e.isReversible}toggleFilterBar(e=this.lastFocusedFilterBarColumn){var n;let{isFilterBarShown:t}=this.state;if(t=!t,this.setState({isFilterBarShown:t}),t)if(e!=null)this.focusFilterBar(e);else{let s=0;const{model:o}=this.props,{columnCount:i}=o;for(let r=0;r<i;r+=1){const l=this.getModelColumn(r);if(l!=null){const a=o.columns[l];if(a!=null&&N.isTextType(a.type)){s=r;break}}}this.focusFilterBar(s)}else(n=this.grid)==null||n.focus()}isTableSearchAvailable(){var s,o,i;const{model:e,canToggleSearch:t}=this.props,n=(s=e==null?void 0:e.layoutHints)==null?void 0:s.searchDisplayMode;return n===((o=E.SearchDisplayMode)==null?void 0:o.SEARCH_DISPLAY_HIDE)?!1:n===((i=E.SearchDisplayMode)==null?void 0:i.SEARCH_DISPLAY_SHOW)?!0:t}toggleSearchBar(){const{showSearchBar:e}=this.state;if(!this.isTableSearchAvailable())return;const t=!e;this.setState({showSearchBar:t},()=>{var n,s,o;t&&((n=this.crossColumnRef)==null?void 0:n.current)?(s=this.crossColumnRef)==null||s.current.focus():(o=this.grid)==null||o.focus()})}toggleGotoRow(e="",t="",n=""){var u,h;const{isGotoShown:s}=this.state;if(e||t){this.setState({isGotoShown:!0,gotoRow:e,gotoValue:t,gotoValueSelectedColumnName:n,gotoRowError:"",gotoValueError:""}),this.focusRowInGrid(e);return}const o=(u=this.grid)==null?void 0:u.state.cursorRow,i=(h=this.grid)==null?void 0:h.state.cursorColumn;if(o==null||i==null){this.setState({isGotoShown:!s,gotoRow:"",gotoValue:"",gotoRowError:"",gotoValueError:""});return}const{model:r}=this.props,{name:l,type:a}=r.columns[i],c=r.valueForCell(i,o),d=Q.convertValueToText(c,a);this.setState({isGotoShown:!s,gotoRow:`${o}`,gotoValue:d,gotoValueSelectedColumnName:l,gotoRowError:"",gotoValueError:""})}async commitPending(){var o,i;const{model:e}=this.props;if(!Pe(e)||!e.isEditable)throw new Error("Cannot save, table is not editable");const{pendingSavePromise:t}=this.state;if(t!=null)throw new Error("Save already in progress");const n=(o=document==null?void 0:document.activeElement)==null?void 0:o.classList.contains("grid-cell-input-field");if(n!=null&&n){if(document.activeElement!=null&&document.activeElement.classList.contains("error"))throw new Kc("Current input is invalid");(i=this.grid)==null||i.focus()}const s=this.pending.add(e.commitPending()).then(()=>{this.setState({pendingSaveError:null,pendingSavePromise:null})}).catch(r=>{ze.isCanceled(r)||this.setState({pendingSaveError:r,pendingSavePromise:null})});return this.setState({pendingSavePromise:s}),s}async discardPending(){const{pendingSavePromise:e}=this.state;if(e!=null)throw new Error("Cannot cancel a save in progress");this.setState({pendingSavePromise:null,pendingSaveError:null,pendingDataMap:new Map,pendingDataErrors:new Map})}selectColumn(e){const{onColumnSelected:t}=this.props;t(e)}selectData(e,t){const{model:n}=this.props,{columns:s,groupedColumns:o}=n,i={};for(let l=0;l<s.length;l+=1){const a=s[l],{name:c,type:d}=a,u=n.valueForCell(l,t),h=n.textForCell(l,t),g=this.getVisibleColumn(l),p=Me(n)&&n.isRowExpandable(t),f=o.find(C=>C.name===c)!=null;i[c]={value:u,text:h,type:d,isGrouped:f,isExpandable:p,visibleIndex:g}}const{onDataSelected:r}=this.props;r(t,i)}handleAdvancedFilterChange(e,t,n){const{model:s}=this.props,o=s.getColumnIndexByName(e.name);M(o),this.setAdvancedFilter(o,t,n)}handleAdvancedFilterSortChange(e,t,n=!1){var a;const{model:s}=this.props,o=s.getColumnIndexByName(e.name);M(o);const i=N.getSortForColumn(s.sort,o);let r=null;(i==null||i.direction!==t)&&(t===N.sortDirection.descending?r=e.sort().desc():r=e.sort().asc());const l=N.setSortForColumn(s.sort,o,r,n);re.info("Setting table sorts",l),this.startLoading("Sorting..."),this.setState({sorts:l}),(a=this.grid)==null||a.forceUpdate()}handleAdvancedFilterDone(){var e;(e=this.grid)==null||e.focus()}handleAdvancedMenuOpened(e){this.setState({shownAdvancedFilter:e})}handleGotoRowOpened(){this.setState({isGotoShown:!0})}handleGotoRowClosed(){this.setState({isGotoShown:!1})}handleAdvancedMenuClosed(e){var s,o;const{focusedFilterBarColumn:t,isFilterBarShown:n}=this.state;n&&t===e&&((s=this.filterInputRef)==null?void 0:s.current)!==null?((o=this.filterInputRef)==null||o.current.focus(),this.setState({shownAdvancedFilter:null})):this.setState({focusedFilterBarColumn:null,shownAdvancedFilter:null})}handleCancel(){this.rollback()}handleChartChange(){}handleChartCreate(e){const{model:t,onCreateChart:n}=this.props;n(e,t)}handleGridError(e){re.warn("Grid Error",e),this.setState({toastMessage:m("div",{className:"error-message",children:`${e}`})})}handleFilterBarChange(e){this.startLoading("Filtering...",!0),this.setState(({focusedFilterBarColumn:t,quickFilters:n})=>{const s=new Map(n);if(t!=null){const o=this.getModelColumn(t);M(o),this.applyQuickFilter(o,e,s)}return{quickFilters:s}})}handleFilterBarDone(e=!0,t=!0){var n;e&&((n=this.grid)==null||n.focus()),t&&this.setState({focusedFilterBarColumn:null})}handleFilterBarTab(e){const{focusedFilterBarColumn:t}=this.state;M(t),e?this.focusFilterBar(t-1):this.focusFilterBar(t+1)}handleFormatSelection(e,t){const{model:n}=this.props,s=n.columns[e],{customColumnFormatMap:o}=this.state,i=new Map(o);if(t!=null){const r=N.getNormalizedType(s.type);M(r);const l=zt.makeColumnFormattingRule(r,s.name,t);i.set(s.name,l)}else i.delete(s.name);this.updateFormatter({customColumnFormatMap:i})}handleMenu(e){e.stopPropagation(),this.setState({isMenuShown:!0})}handleMenuClose(){this.setState({isMenuShown:!1,openOptions:[]})}handleMenuBack(){this.setState(({openOptions:e})=>{const t=[...e];return t.pop(),{openOptions:t}})}handleMenuSelect(e){this.setState(({openOptions:t})=>({openOptions:[...t,e]}))}handleRequestFailed(e){const t=e;if(re.error("request failed:",t.detail),this.stopLoading(),this.canRollback())this.startLoading("Rolling back changes...",!0),this.rollback();else{re.error("Table failed and unable to rollback");const{onError:n}=this.props;n(new Error(`Error displaying table: ${t.detail}`))}}handleUpdate(){var d;this.stopLoading(),re.debug2("Received model update");const{advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:o,rollupConfig:i,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.state,c={advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:o,rollupConfig:i,searchFilter:r,selectDistinctColumns:l,sorts:a};nl(c)?this.lastLoadedConfig=null:this.lastLoadedConfig=c,(d=this.grid)==null||d.forceUpdate()}handleViewChanged(e){var o,i;const{model:t}=this.props,{selectionEndRow:n=0}=(i=(o=this.grid)==null?void 0:o.state)!=null?i:{};let s=0;if(Pe(t)&&t.isEditable){M(e);const{bottomViewport:r}=e,l=t.rowCount-t.floatingBottomRowCount;n===l-1?s=t.pendingRowCount+1:n===l-2?s=t.pendingRowCount:s=Math.max(0,r-(t.rowCount-t.pendingRowCount)-t.floatingTopRowCount-t.floatingBottomRowCount-1)}this.setState({metrics:e,pendingRowCount:s})}handleSelectionChanged(e){M(e);const{onSelectionChanged:t}=this.props,{copyOperation:n}=this.state;this.setState({selectedRanges:e}),n!=null&&this.setState({copyOperation:null}),t(e)}handleMovedColumnsChanged(e,t){this.setState({movedColumns:e},t)}handleHeaderGroupsChanged(e){const{model:t}=this.props;this.setState({columnHeaderGroups:Q.parseColumnHeaderGroups(t,e).groups},()=>{var n;return(n=this.grid)==null?void 0:n.forceUpdate()})}handleTooltipRef(e){e!=null&&e.startTimer(),this.tooltip=e}handleConditionalFormatsChange(e){re.debug("Updated conditional formats",e),this.setState({conditionalFormats:e})}handleConditionalFormatCreate(){re.debug("Create new conditional format");const{openOptions:e,conditionalFormats:t}=this.state;this.setState({openOptions:[...e,{type:Se.CONDITIONAL_FORMATTING_EDIT,title:"Create Formatting Rule"}],conditionalFormatEditIndex:t.length,conditionalFormatPreview:void 0})}handleConditionalFormatEdit(e){re.debug("Edit conditional format",e);const{openOptions:t,conditionalFormats:n}=this.state;this.setState({openOptions:[...t,{type:Se.CONDITIONAL_FORMATTING_EDIT,title:"Edit Formatting Rule"}],conditionalFormatEditIndex:e,conditionalFormatPreview:{...n[e]}})}handleConditionalFormatEditorSave(e){re.debug("Save conditional format changes",e),this.setState(t=>{if(t.conditionalFormatEditIndex===null)return re.debug("Invalid format index"),null;const n=[...t.conditionalFormats];return n[t.conditionalFormatEditIndex]=e,{conditionalFormats:n}},()=>{this.handleMenuBack()})}handleConditionalFormatEditorCancel(){this.handleMenuBack(),this.setState({conditionalFormatEditIndex:null})}handleUpdateCustomColumns(e){re.info("handleUpdateCustomColumns:",e);const{model:t}=this.props,{movedColumns:n,sorts:s,quickFilters:o,advancedFilters:i,selectDistinctColumns:r}=this.state,{columns:l}=t,a=t.customColumns.map(d=>`${d}`),c=Q.getRemovedCustomColumnNames(a,e);if(c.length>0){const d=Q.removeSortsInColumns(s,c),u=Q.removeFiltersInColumns(l,o,c),h=Q.removeFiltersInColumns(l,i,c),g=Q.removeColumnFromMovedColumns(l,n,c),p=Q.removeColumnsFromSelectDistinctColumns(r,c);d.length!==s.length&&(re.debug("removing sorts from removed custom columns..."),this.setState({sorts:d})),(u.size!==o.size||h.size!==i.size)&&(re.debug("removing filters from removed custom columns..."),this.setState({quickFilters:u,advancedFilters:h})),it(n,g)||(re.debug("change moved columns for removed custom columns",g),this.setState({movedColumns:g})),it(r,p)||(re.debug("change selectDistinct columns for removed custom columns",g),this.setState({selectDistinctColumns:p}))}this.setState({customColumns:e}),e.length>0&&this.startLoading("Applying custom columns...")}handleCustomColumnsChanged(){var t;re.debug("custom columns changed");const{isReady:e}=this.state;e?(this.stopLoading(),(t=this.grid)==null||t.forceUpdate()):this.initState()}handlePendingCommitClicked(){return this.commitPending()}handlePendingDiscardClicked(){return this.discardPending()}handlePendingDataUpdated(){var s;re.debug("pending data updated");const{model:e}=this.props,{pendingDataMap:t,pendingDataErrors:n}=e;this.setState({pendingDataMap:t,pendingDataErrors:n,pendingSaveError:null}),(s=this.grid)==null||s.forceUpdate()}handleAggregationsChange(e){re.debug("handleAggregationsChange",e),this.startLoading(`Aggregating ${e.aggregations.map(t=>t.operation).join(", ")}...`),this.setState({aggregationSettings:e})}handleAggregationChange(e){re.debug("handleAggregationChange",e),this.startLoading(`Aggregating ${e.operation}...`),this.setState(({aggregationSettings:t})=>({selectedAggregation:e,aggregationSettings:{...t,aggregations:t.aggregations.map(n=>n.operation===e.operation?e:n)}}))}handleAggregationEdit(e){re.debug("handleAggregationEdit",e);const{openOptions:t}=this.state;this.setState({openOptions:[...t,{type:Se.AGGREGATION_EDIT,title:`Edit Columns to ${e.operation}`}],selectedAggregation:e})}handleRollupChange(e){var t,n;re.info("Rollup change",e),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Grouping by columns ${(n=(t=e==null?void 0:e.columns)==null?void 0:t.join(", "))!=null?n:""}...`),this.setState({rollupConfig:e,movedColumns:[],sorts:[],reverseType:N.REVERSE_TYPE.NONE,selectDistinctColumns:[]})}handleSelectDistinctChanged(e){re.debug("SelectDistinct change",e),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Selecting distinct values in ${e.length>0?e.join(", "):""}...`),this.setState({selectDistinctColumns:e,movedColumns:[],sorts:[],reverseType:N.REVERSE_TYPE.NONE})}handleDownloadTableStart(){const{canDownloadCsv:e}=this.props;e?this.setState({isTableDownloading:!0,tableDownloadProgress:0,tableDownloadEstimatedTime:null,tableDownloadStatus:gt.DOWNLOAD_STATUS.INITIATING}):re.error("Attempted to handleDownloadTableStart for user without download CSV permission.")}handleDownloadTable(e,t,n,s,o,i,r){const{canDownloadCsv:l}=this.props;l?(re.info("start table downloading",e,t,n,s,o,i,r),this.setState(()=>(this.tableSaver&&this.tableSaver.startDownload(e,t,n,s,o,i,r),{tableDownloadStatus:gt.DOWNLOAD_STATUS.DOWNLOADING}))):re.error("Attempted to handleDownloadTable for user without download CSV permission.")}async seekRow(e,t=!1){var c,d;const{gotoValueSelectedColumnName:n,gotoValueSelectedFilter:s}=this.state,{model:o}=this.props;if(!o.isSeekRowAvailable||e==="")return;const i=Q.getColumnByName(o.columns,n);if(i===void 0)return;let r=(c=this.grid)==null?void 0:c.state.cursorRow;r==null&&(r=0);const l=s===P.contains,a=s===P.eq||s===P.eqIgnoreCase;try{const{formatter:u}=o,h=N.getNormalizedType(i.type);let g;switch(h){case N.dataType.CHAR:case N.dataType.STRING:{g=await o.seekRow(t===!0?r-1:r+1,i,E.ValueType.STRING,e,a,l,t!=null?t:!1);break}case N.dataType.DATETIME:{const[p]=qt.parseDateRange(e,u.timeZone);g=await o.seekRow(t===!0?r-1:r+1,i,E.ValueType.DATETIME,p,void 0,void 0,t!=null?t:!1);break}case N.dataType.DECIMAL:case N.dataType.INT:{if(!N.isBigDecimalType(i.type)&&!N.isBigIntegerType(i.type)){let p=parseInt(e,10);e==="-Infinity"?p=Number.NEGATIVE_INFINITY:e==="Infinity"&&(p=Number.POSITIVE_INFINITY),g=await o.seekRow(r,i,E.ValueType.NUMBER,p,void 0,void 0,t!=null?t:!1)}else g=await o.seekRow(r,i,E.ValueType.STRING,e,void 0,void 0,t!=null?t:!1);break}default:g=await o.seekRow(r,i,E.ValueType.STRING,N.makeValue(i.type,e,u.timeZone),void 0,void 0,t!=null?t:!1)}(d=this.grid)==null||d.setFocusRow(g),this.setState({gotoValueError:""})}catch{this.setState({gotoValueError:"invalid input"})}}handleCancelDownloadTable(){var e;(e=this.tableSaver)==null||e.cancelDownload(),this.setState({isTableDownloading:!1})}handleDownloadCompleted(){this.setState({isTableDownloading:!1,tableDownloadProgress:100,tableDownloadStatus:gt.DOWNLOAD_STATUS.FINISHED})}handleDownloadCanceled(){this.setState({isTableDownloading:!1,tableDownloadProgress:0,tableDownloadStatus:gt.DOWNLOAD_STATUS.CANCELED})}deleteRanges(e){const{model:t}=this.props;this.pending.add(t.delete(e)).catch(n=>{ze.isCanceled(n)||re.error("Unable to delete ranges",e,n)})}resetColumnSelection(){if(this.grid==null)return;const{isSelectingColumn:e}=this.props;if(e){const{columnAllowedCursor:t}=this.props;this.grid.setState({cursor:t})}else this.grid.setState({cursor:null}),this.setState({hoverSelectColumn:null})}resetGridViewState(e=!0){!this.grid||(this.grid.clearSelectedRanges(),this.grid.setViewState({left:0,top:0,topOffset:0,leftOffset:0},e))}sendStateChange(){if(!this.grid)return;const{state:e}=this,{state:t}=this.grid,{onStateChange:n}=this.props;n(e,t)}handleOverflowClose(){this.setState({showOverflowModal:!1})}getColumnBoundingRect(){var h;const{metrics:e,shownColumnTooltip:t}=this.state;M(e),M(t);const n=(h=this.gridWrapper)==null?void 0:h.getBoundingClientRect(),s=20;M(n);const{columnHeaderHeight:o,allColumnXs:i,allColumnWidths:r,width:l,columnHeaderMaxDepth:a}=e,c=i.get(t),d=r.get(t);M(c),M(d);const u=n.left+$e(c+d/2,s,l-s);return{top:n.top+(a-1)*o,left:n.left+$e(c+d/2,s,l-s),bottom:n.top+a*o,right:n.left+$e(c+d/2,s,l-s)+1,width:1,height:o,x:u,y:n.top,toJSON:()=>{throw new Error("not implemented")}}}handleGotoRowSelectedRowNumberSubmit(){const{gotoRow:e}=this.state;this.focusRowInGrid(e)}focusRowInGrid(e){var o,i,r;const{model:t}=this.props,{rowCount:n}=t;if(this.setState({gotoRow:e}),e===""){this.setState({gotoRowError:"",gotoValueError:""});return}const s=parseInt(e,10);s>n||s<-n?this.setState({gotoRowError:"Invalid row index"}):s===0?(this.setState({gotoRowError:"",gotoValueError:""}),(o=this.grid)==null||o.setFocusRow(0)):s<0?(this.setState({gotoRowError:"",gotoValueError:""}),(i=this.grid)==null||i.setFocusRow(s+n)):((r=this.grid)==null||r.setFocusRow(s-1),this.setState({gotoRowError:"",gotoValueError:""}))}handleGotoRowSelectedRowNumberChanged(e){const t=e.target.value;this.focusRowInGrid(t)}getColumnTooltip(e,t,n){const{columnHeaderHeight:s,columnHeaderMaxDepth:o,allColumnXs:i,allColumnWidths:r,width:l}=t,a=i.get(e),c=r.get(e);if(a==null||c==null)return null;const d=Math.max(0,a);let u=c;a+c>l?u=l-a:a<0&&(u=c-Math.abs(a));const h={position:"absolute",top:(o-1)*s,left:d,width:u,height:s,pointerEvents:"none"},g={clientWidth:1,clientHeight:s,getBoundingClientRect:this.getColumnBoundingRect},p={placement:"bottom",modifiers:{flip:{behavior:["bottom","top"]}}},f=this.getModelColumn(e);if(f==null)return null;const C=n.columns[f];return C==null?null:m("div",{style:h,children:m(Rt,{timeout:400,interactive:!0,options:p,ref:this.handleTooltipRef,referenceObject:g,onExited:()=>{this.setState({shownColumnTooltip:null})},children:m(Ol,{model:n,column:C,onStatistics:()=>{var w;(w=this.tooltip)==null||w.update()}})},C.name)})}handleGotoValueSelectedColumnNameChanged(e){var s;const{model:t}=this.props,n=(s=this.grid)==null?void 0:s.state.cursorRow;if(n!=null){const o=t.getColumnIndexByName(e),i=Q.getColumnByName(t.columns,e);if(o==null||i==null)return;const r=t.valueForCell(o,n),l=Q.convertValueToText(r,i.type);this.setState({gotoValueSelectedColumnName:e,gotoValue:l,gotoValueError:""})}this.setState({gotoValueSelectedColumnName:e,gotoValueError:""})}handleGotoValueSelectedFilterChanged(e){this.setState({gotoValueSelectedFilter:e,gotoValueError:""})}handleGotoValueSubmitted(e){const{gotoValue:t}=this.state;this.seekRow(t,e)}render(){var So,To,bo,qe,ls,ar,cr,dr,ur;const{children:e,customFilters:t,getDownloadWorker:n,isSelectingColumn:s,isStuckToBottom:o,isStuckToRight:i,model:r,name:l,onlyFetchVisibleColumns:a,alwaysFetchColumns:c,advancedSettings:d,onAdvancedSettingsChange:u,canDownloadCsv:h,onCreateChart:g}=this.props,{metricCalculator:p,metrics:f,isFilterBarShown:C,isSelectingPartition:w,isMenuShown:S,isReady:b,copyOperation:v,focusedFilterBarColumn:T,loadingText:R,loadingScrimProgress:D,loadingSpinnerShown:A,keyHandlers:I,mouseHandlers:L,shownColumnTooltip:k,hoverAdvancedFilter:x,shownAdvancedFilter:W,hoverSelectColumn:V,quickFilters:Y,advancedFilters:j,partition:ie,partitionFilters:G,partitionTable:ee,partitionColumn:H,searchFilter:$,selectDistinctColumns:se,movedColumns:ne,movedRows:he,formatter:ve,conditionalFormats:Ie,conditionalFormatPreview:Ge,conditionalFormatEditIndex:me,sorts:ke,reverseType:Ot,customColumns:Ct,selectedRanges:hn,isTableDownloading:xt,tableDownloadStatus:rt,tableDownloadProgress:ge,tableDownloadEstimatedTime:Ee,showSearchBar:Ye,searchValue:lt,selectedSearchColumns:wt,invertSearchColumns:mn,aggregationSettings:kt,selectedAggregation:no,rollupConfig:Kt,openOptions:St,pendingSavePromise:gn,pendingSaveError:os,pendingRowCount:Ds,pendingDataErrors:is,pendingDataMap:rs,toastMessage:so,frozenColumns:oo,columnHeaderGroups:pn,showOverflowModal:Hn,overflowText:si,overflowButtonTooltipProps:io,expandCellTooltipProps:Is,isGotoShown:Ns,gotoRow:ro,gotoRowError:lo,gotoValueError:oi,gotoValueSelectedColumnName:ii,gotoValue:ri}=this.state;if(!b)return null;const Vn=this.getTheme(),li=this.getCachedFilter(t,Y,j,G,$),ao=p.getUserColumnWidths(),co=this.getCachedStateOverride(V,C,s,D,Y,j,ke,Ot,Kt,S),As=f?f.top:0,uo=f?f.bottomViewport:0;let fn=null,Ms=null;a&&(fn=f?f.left:0,Ms=f?f.right:0);const ho=f!=null&&f.width>0&&f.height>0,Os=((To=(So=Kt==null?void 0:Kt.columns)==null?void 0:So.length)!=null?To:0)>0;let xs=null;const ai=f?Math.min(Math.max(Nn.minDebounce,Math.round(f.rowCount/200)),Nn.maxDebounce):Nn.maxDebounce;if(C&&T!=null&&f!=null){const{gridX:Le,gridY:ut,allColumnXs:Cn,allColumnWidths:ks,width:as}=f,Lt=Cn.get(T),at=ks.get(T);if(Lt!=null&&at!=null){const tt=Le+Lt,Qt=ut-((bo=Vn.filterBarHeight)!=null?bo:0),Un=at+1,Bn=((qe=Vn.filterBarHeight)!=null?qe:0)-1,Eo={top:Qt,left:tt,minWidth:Math.min(Un,as-tt),height:Bn};let Pt="",cs=!0;const Gn=this.getModelColumn(T);M(Gn);const ds=Y.get(Gn),wn=j.get(Gn);ds!=null&&(Pt=ds.text,cs=ds.filter!=null);const us=Y.size!==0||j.size!==0;xs=m(Dl,{ref:this.filterInputRef,style:Eo,className:Z({error:!cs,active:Pt!==""||wn!=null,"iris-grid-has-filter":us}),isAdvancedFilterSet:wn!=null,onAdvancedFiltersTriggered:()=>{this.setState({shownAdvancedFilter:T})},onChange:this.handleFilterBarChange,onDone:this.handleFilterBarDone,onTab:this.handleFilterBarTab,onContextMenu:(ls=this.grid)==null?void 0:ls.handleContextMenu,debounceMs:ai,value:Pt},T)}}let mo=null;if(R!=null){const Le=y("div",{className:"iris-grid-loading-status",children:[m("div",{className:Z("iris-grid-loading-status-bar",{show:A}),children:R}),y("button",{type:"button",onClick:this.handleCancel,className:Z("iris-grid-btn-cancel",{show:A}),children:[m(J,{icon:Xs,transform:"down-1"}),"Cancel"]})]}),ut=f?f.gridY:0;mo=m("div",{className:"iris-grid-loading",style:{top:ut},children:Le})}let go=null;k!=null&&f&&(go=this.getColumnTooltip(k,f,r),(ar=this.tooltip)==null||ar.update());const po=[];if(f&&C){const{gridX:Le,gridY:ut,visibleColumns:Cn,allColumnXs:ks,allColumnWidths:as}=f,{filterBarHeight:Lt}=Vn;for(let at=0;at<Cn.length;at+=1){const tt=Cn[at],Qt=ks.get(tt),Un=as.get(tt),Bn=this.getModelColumn(tt);if(Bn!=null&&r.isFilterable(Bn)&&Qt!=null&&Un!=null&&Un>0){const Pt=Le+Qt+Un-24,cs=ut-(Lt!=null?Lt:0)+2,Gn={position:"absolute",top:cs,left:Pt},wn=j.get(Bn)!=null,us=tt===x||tt===T||wn,di=m("div",{className:Z("advanced-filter-button-container",{hidden:!us}),style:Gn,children:us&&m(z,{kind:"ghost",className:Z("btn-link-icon advanced-filter-button",{"filter-set":wn}),onClick:()=>{this.setState({shownAdvancedFilter:tt})},onContextMenu:fa=>{var hr;(hr=this.grid)==null||hr.handleContextMenu(fa)},onMouseEnter:()=>{this.setState({hoverAdvancedFilter:tt})},onMouseLeave:()=>{this.setState({hoverAdvancedFilter:null})},children:y("div",{className:"fa-layers",children:[m(J,{icon:ki,className:"filter-solid"}),m(J,{icon:xo,className:"filter-light"})]})})},tt);po.push(di)}}}const fo=[];if(f){const{gridX:Le,visibleColumns:ut,allColumnXs:Cn,allColumnWidths:ks,columnHeaderHeight:as}=f;for(let Lt=0;Lt<ut.length;Lt+=1){const at=ut[Lt],tt=Cn.get(at),Qt=ks.get(at);if(tt!=null&&Qt!=null&&Qt>0){const Un=Le+tt,Bn=Le+tt+Qt-20,Eo=C?{position:"absolute",top:as,left:Bn,width:20,height:Vn.filterBarHeight}:{position:"absolute",top:0,left:Un,width:Qt,height:as},Pt=this.getModelColumn(at);if(Pt!=null){const cs=r.columns[Pt],Gn=j.get(Pt),{options:ds}=Gn||{},wn=N.getSortForColumn(r.sort,Pt),us=wn?wn.direction:null,di=m("div",{className:"advanced-filter-menu-container",style:Eo,children:m(dl,{className:"advanced-filter-menu-popper",onEntered:this.getAdvancedMenuOpenedHandler(at),onExited:()=>{this.handleAdvancedMenuClosed(at)},isShown:W===at,interactive:!0,closeOnBlur:!0,options:{positionFixed:!0},children:this.getCachedAdvancedFilterMenuActions(r,cs,ds,us,ve)})},at);fo.push(di)}}}}const Co=this.getCachedOptionItems(g!==void 0&&r.isChartBuilderAvailable,r.isCustomColumnsAvailable,r.isFormatColumnsAvailable,r.isRollupAvailable,r.isTotalsAvailable||Os,r.isSelectDistinctAvailable,r.isExportAvailable,this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,C,Ye,h,this.isTableSearchAvailable(),Ns,d.size>0),wo=this.getCachedHiddenColumns(p,ao),ci=St.map(Le=>{switch(Le.type){case Se.CHART_BUILDER:return m(Ll,{model:r,onChange:this.handleChartChange,onSubmit:this.handleChartCreate},Se.CHART_BUILDER);case Se.VISIBILITY_ORDERING_BUILDER:return m(tr,{model:r,movedColumns:ne,hiddenColumns:wo,columnHeaderGroups:pn,onColumnVisibilityChanged:this.handleColumnVisibilityChanged,onReset:this.handleColumnVisibilityReset,onMovedColumnsChanged:this.handleMovedColumnsChanged,onColumnHeaderGroupChanged:this.handleHeaderGroupsChanged},Se.VISIBILITY_ORDERING_BUILDER);case Se.CONDITIONAL_FORMATTING:return m(Wh,{rules:Ie,onChange:this.handleConditionalFormatsChange,onCreate:this.handleConditionalFormatCreate,onSelect:this.handleConditionalFormatEdit});case Se.CONDITIONAL_FORMATTING_EDIT:return M(r.columns),M(this.handleConditionalFormatEditorUpdate),m(fm,{columns:r.columns,rule:Ge,onUpdate:this.handleConditionalFormatEditorUpdate,onSave:this.handleConditionalFormatEditorSave,onCancel:this.handleConditionalFormatEditorCancel});case Se.CUSTOM_COLUMN_BUILDER:return m(_l,{model:r,customColumns:Ct,onSave:this.handleUpdateCustomColumns,onCancel:this.handleMenuBack},Se.CUSTOM_COLUMN_BUILDER);case Se.ROLLUP_ROWS:return m(er,{model:r,onChange:this.handleRollupChange,config:Kt},Se.ROLLUP_ROWS);case Se.AGGREGATIONS:return m(ju,{settings:kt,isRollup:Os,onChange:this.handleAggregationsChange,onEdit:this.handleAggregationEdit});case Se.AGGREGATION_EDIT:return no&&m(Ju,{aggregation:no,columns:r.originalColumns,onChange:this.handleAggregationChange});case Se.TABLE_EXPORTER:return m(gt,{model:r,name:l,userColumnWidths:ao,movedColumns:ne,isDownloading:xt,tableDownloadStatus:rt,tableDownloadProgress:ge,tableDownloadEstimatedTime:Ee!=null?Ee:void 0,onDownload:this.handleDownloadTable,onDownloadStart:this.handleDownloadTableStart,onCancel:this.handleCancelDownloadTable,selectedRanges:hn},Se.TABLE_EXPORTER);case Se.SELECT_DISTINCT:return m(ql,{model:r,selectDistinctColumns:se,onChange:this.handleSelectDistinctChanged});case Se.ADVANCED_SETTINGS:return m(nr,{items:d,onChange:u});default:throw Error(`Unexpected option type ${Le.type}`)}});return y("div",{className:"iris-grid",role:"presentation",children:[y("div",{className:"iris-grid-column",children:[e!=null&&m("div",{className:"iris-grid-bar",children:e}),m($t,{in:w,timeout:We.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:m("div",{className:"iris-grid-partition-selector-wrapper iris-grid-bar iris-grid-bar-primary",children:ee&&H&&ie!=null&&m(zl,{table:ee,getFormattedString:(Le,ut,Cn)=>r.displayString(Le,ut,Cn),columnName:H.name,partition:ie,onChange:this.handlePartitionChange,onFetchAll:this.handlePartitionFetchAll,onAppend:this.handlePartitionAppend,onDone:this.handlePartitionDone})})}),m($t,{in:Ye,timeout:We.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:m("div",{className:"iris-grid-bar",children:m(No,{value:lt,selectedColumns:wt,invertSelection:mn,onChange:this.handleCrossColumnSearch,columns:r.columns,ref:this.crossColumnRef})})}),y("div",{className:"grid-wrapper",ref:Le=>{this.gridWrapper=Le},children:[m(Rs,{ref:Le=>{this.grid=Le},isStickyBottom:!Pe(r)||!r.isEditable,isStuckToBottom:o,isStuckToRight:i,metricCalculator:p,model:r,keyHandlers:I,mouseHandlers:L,movedColumns:ne,movedRows:he,onError:this.handleGridError,onViewChanged:this.handleViewChanged,onSelectionChanged:this.handleSelectionChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged,renderer:this.renderer,stateOverride:co,theme:Vn}),m(Fg,{isOpen:Hn,text:si,onClose:this.handleOverflowClose}),ho&&m(Al,{model:r,modelColumns:r.columns,top:As,bottom:uo,left:fn,right:Ms,filter:li,formatter:ve,sorts:ke,reverseType:Ot,movedColumns:ne,customColumns:Ct,hiddenColumns:wo,alwaysFetchColumns:this.getAlwaysFetchColumns(c,r.columns,ne,r.floatingLeftColumnCount,r.floatingRightColumnCount,(dr=(cr=this.grid)==null?void 0:cr.state.draggingColumn)==null?void 0:dr.range),formatColumns:this.getCachedPreviewFormatColumns(this.getCachedModelColumns(r,Ct),Ie,Ge,((ur=St[St.length-1])==null?void 0:ur.type)===Se.CONDITIONAL_FORMATTING_EDIT&&me!=null?me:void 0),rollupConfig:this.getModelRollupConfig(r.originalColumns,Kt,kt),totalsConfig:this.getModelTotalsConfig(r.columns,Kt,kt),selectDistinctColumns:se,pendingRowCount:Ds,pendingDataMap:rs,frozenColumns:oo,columnHeaderGroups:pn}),!S&&m("div",{className:"grid-settings-button",children:m(z,{kind:"ghost","data-testid":`btn-iris-grid-settings-button-${l}`,onClick:this.handleMenu,icon:m(J,{icon:Uc,transform:"up-1"}),tooltip:"Table Options"})}),xs,mo,po,go,fo,io&&this.getOverflowButtonTooltip(io),Is&&this.getExpandCellTooltip(Is)]}),m(Ng,{model:r,isShown:Ns,gotoRow:ro,gotoRowError:lo,gotoValueError:oi,onGotoRowSubmit:this.handleGotoRowSelectedRowNumberSubmit,onGotoRowNumberChanged:this.handleGotoRowSelectedRowNumberChanged,onClose:this.handleGotoRowClosed,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:()=>{this.handleAnimationStart(),this.focus()},onExited:this.handleAnimationEnd,gotoValueSelectedColumnName:ii,gotoValue:ri,onGotoValueSelectedColumnNameChanged:this.handleGotoValueSelectedColumnNameChanged,onGotoValueSelectedFilterChanged:this.handleGotoValueSelectedFilterChanged,onGotoValueChanged:this.handleGotoValueChanged,onGotoValueSubmit:this.handleGotoValueSubmitted}),m(Tu,{error:os,isSaving:gn!=null,saveTooltip:`Commit (${this.commitAction.shortcut.getDisplayText()})`,discardTooltip:`Discard (${this.discardAction.shortcut.getDisplayText()})`,pendingDataErrors:is,pendingDataMap:rs,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,onSave:this.handlePendingCommitClicked,onDiscard:this.handlePendingDiscardClicked}),m(Wu,{children:so}),m(ys,{model:r,copyOperation:v!=null?v:void 0,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd}),m(Fs,{ref:Le=>{this.tableSaver=Le},getDownloadWorker:n,onDownloadCompleted:this.handleDownloadCompleted,onDownloadCanceled:this.handleDownloadCanceled,onDownloadProgressUpdate:this.handleDownloadProgressUpdate,isDownloading:rt===gt.DOWNLOAD_STATUS.DOWNLOADING,formatter:ve})]}),m($t,{in:S,timeout:We.transitionMidMs,classNames:"slide-left",onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:m("div",{className:"table-sidebar",children:y(Zc,{children:[m(vr,{title:"Table Options",onClose:this.handleMenuClose,children:m(fl,{onSelect:Le=>this.handleMenuSelect(Co[Le]),items:Co})}),ci.map((Le,ut)=>m(vr,{title:St[ut].title,onBack:this.handleMenuBack,onClose:this.handleMenuClose,children:Le},St[ut].type))]})})}),m(oe,{actions:this.contextActions})]})}};let to=Nn;to.minDebounce=150;to.maxDebounce=500;to.loadingSpinnerDelay=800;to.defaultProps={children:null,advancedFilters:rn,advancedSettings:rn,alwaysFetchColumns:ye,conditionalFormats:ye,customColumnFormatMap:rn,isFilterBarShown:!1,applyInputFiltersOnInit:!1,movedColumns:ye,movedRows:ye,inputFilters:ye,customFilters:ye,onCreateChart:void 0,onColumnSelected:()=>{},onDataSelected:()=>{},onError:()=>{},onStateChange:()=>{},onPartitionAppend:()=>{},onAdvancedSettingsChange:()=>{},partition:null,partitionColumn:null,quickFilters:rn,selectDistinctColumns:ye,sorts:ye,reverseType:N.REVERSE_TYPE.NONE,customColumns:ye,aggregationSettings:ma,rollupConfig:void 0,userColumnWidths:rn,userRowHeights:rn,onSelectionChanged:()=>{},isSelectingColumn:!1,isSelectingPartition:!1,isStuckToBottom:!1,isStuckToRight:!1,columnSelectionValidator:null,columnAllowedCursor:null,columnNotAllowedCursor:null,name:"table",onlyFetchVisibleColumns:!0,showSearchBar:!1,searchValue:"",selectedSearchColumns:null,invertSearchColumns:!0,onContextMenu:()=>{},pendingDataMap:rn,getDownloadWorker:void 0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:qt.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,truncateNumbersWithPound:!1,formatter:ye,decimalFormatOptions:B.exports.shape({defaultFormatString:B.exports.string}),integerFormatOptions:B.exports.shape({defaultFormatString:B.exports.string})},canCopy:!0,canDownloadCsv:!0,frozenColumns:null,theme:Ml,canToggleSearch:!0};class Lg extends Error{constructor(t,n){super(`${n} can't be empty (on pending row ${t+1})`),this.isMissingKey=!0,this.rowIndex=t,this.columnName=n}}const He=le.module("IrisGridTableModel"),Pg=150,_g=0,Hg=[];function Mo(e){return e.table!==void 0}const Mi=class extends ue{constructor(e,t=new zt,n=null){var s,o;super(),this.pendingNewRowCount=0,this._columnHeaderGroupMap=new Map,this.columnHeaderParentMap=new Map,this._columnHeaderMaxDepth=null,this._columnHeaderGroups=[],this._movedColumns=null,this.getMemoizedInitialMovedColumns=Fe(i=>{var p;if(!i)return[];let r=[];const{groupMap:l}=Q.parseColumnHeaderGroups(this,(p=i==null?void 0:i.columnGroups)!=null?p:[]),a=(f,C)=>{const w=this.getColumnIndexByName(f);if(w==null)throw new Error(`Unknown layout hint column: ${f}`);const S=_.getVisibleIndex(w,r);r=_.moveItem(S,C,r)},c=(f,C)=>{const w=l.get(f);if(w==null)throw new Error(`Unknown layout hint group: ${f}`);const S=w.getVisibleRange(r);r=_.moveRange(S,C,r)},{frontColumns:d=[],backColumns:u=[],frozenColumns:h=[]}=i;if(d.length||u.length||h.length){const f=new Set;let C=0;h.forEach(S=>{if(f.has(S))throw new Error(`Column specified in multiple layout hints: ${S}`);a(S,C),C+=1}),d.forEach(S=>{if(f.has(S))throw new Error(`Column specified in multiple layout hints: ${S}`);a(S,C),C+=1});let w=this.columnMap.size-1;u.forEach(S=>{if(f.has(S))throw new Error(`Column specified in multiple layout hints: ${S}`);a(S,w),w-=1})}if(i==null?void 0:i.columnGroups){const f=[...l.values()];f.sort((C,w)=>C.depth-w.depth),f.forEach(C=>{const w=C.children[0],S=this.getColumnIndexByName(w);let b;if(S!=null)b=_.getVisibleIndex(S,r);else{const v=l.get(w);if(!v)throw new Error(`Unknown column ${w} in group ${C.name}`);[,b]=v.getVisibleRange(r)}for(let v=1;v<C.children.length;v+=1){const T=C.children[v],R=l.get(T),D=this.getColumnIndexByName(T);if(R){const I=R.getVisibleRange(r)[0]<b?b-R.childIndexes.length+1:b+1;c(T,I),b=I+R.childIndexes.length-1}else if(D!=null){const I=_.getVisibleIndex(D,r)<b?b:b+1;a(T,I),b=I}}})}return this._movedColumns=r,r}),this.getMemoizedInitialColumnHeaderGroups=Fe(i=>{var r;return Q.parseColumnHeaderGroups(this,(r=i==null?void 0:i.columnGroups)!=null?r:[]).groups}),this.getMemoizedColumnMap=Fe(i=>{const r=new Map;return i.forEach(l=>r.set(l.name,l)),r}),this.getColumnIndicesByNameMap=Fe(i=>{const r=new Map;return i.forEach(({name:l},a)=>r.set(l,a)),r}),this.setViewport=Pn((i,r,l)=>{if(r<i){He.error("Invalid viewport",i,r);return}const{viewport:a}=this;if(a!=null&&a.top===i&&a.bottom===r&&a.columns===l){He.debug2("Ignoring duplicate viewport",a);return}this.viewport={top:i,bottom:r,columns:l},He.debug2("setViewport",this.viewport),this.applyViewport()},Pg),this.applyViewport=Pn(()=>{if(!this.viewport)return;He.debug2("applyViewport",this.viewport);const{top:i,bottom:r,columns:l}=this.viewport,[a,c]=this.getCachedViewportRowRange(i,r);this.applyBufferedViewport(a,c,l)},_g,{leading:!1}),this.getCachedFormattedString=pt((i,r,l,a,c)=>i.getFormattedString(r,l,a,c),{max:1e4}),this.getCachedCustomColumnFormatFlag=pt(Jn.isCustomColumnFormatDefined,{max:1e4}),this.getCachedViewportRowRange=Fe((i,r)=>{const l=r-i,a=Math.max(0,i-l*Mi.ROW_BUFFER_PAGES),c=r+l*Mi.ROW_BUFFER_PAGES;return[a,c]}),this.getCachedPendingErrors=Fe((i,r,l)=>{const a=new Map;return i.forEach((c,d)=>{var h;const{data:u}=c;for(let g=0;g<l;g+=1)u.has(g)||(a.has(d)||a.set(d,[]),(h=a.get(d))==null||h.push(new Lg(d,r[g].name)))}),a}),this.handleTableDisconnect=this.handleTableDisconnect.bind(this),this.handleTableReconnect=this.handleTableReconnect.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.handleTotalsUpdate=this.handleTotalsUpdate.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.irisFormatter=t,this.inputTable=n,this.subscription=null,this.table=e,this.viewport=null,this.viewportData=null,this.formattedStringData=[],this.pendingStringData=[],this.isSaveInProgress=!1,this.totalsTable=null,this.totalsTablePromise=null,this.totals=null,this.totalsDataMap=null,this.pendingNewDataMap=new Map,this.pendingNewRowCount=0,this.columnHeaderGroups=Q.parseColumnHeaderGroups(this,(o=(s=this.layoutHints)==null?void 0:s.columnGroups)!=null?o:[]).groups}seekRow(e,t,n,s,o,i,r){throw new Error("Method not implemented.")}export(){throw new Error("Method not implemented.")}columnStatistics(e){throw new Error("Method not implemented.")}get customColumns(){return[]}set customColumns(e){throw new Error("Method not implemented.")}get formatColumns(){return[]}set formatColumns(e){throw new Error("Method not implemented.")}updateFrozenColumns(e){throw new Error("Method not implemented.")}get rollupConfig(){throw new Error("Method not implemented.")}set rollupConfig(e){throw new Error("Method not implemented.")}get selectDistinctColumns(){throw new Error("Method not implemented.")}set selectDistinctColumns(e){throw new Error("Method not implemented.")}get columns(){return this.table.columns}close(){this.table.close(),this.totalsTable!==null&&this.totalsTable.close(),this.totalsTablePromise!==null&&this.totalsTablePromise.cancel()}startListening(){super.startListening(),this.table.addEventListener(E.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.addEventListener(E.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.addEventListener(E.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.addEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.addEventListener(E.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable),this.applyViewport()}stopListening(){super.stopListening(),this.table.removeEventListener(E.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.removeEventListener(E.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.removeEventListener(E.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.removeEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.removeEventListener(E.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.removeTotalsListeners(this.totalsTable),this.closeSubscription()}addTotalsListeners(e){e.addEventListener(E.Table.EVENT_UPDATED,this.handleTotalsUpdate),e.setViewport(0,0)}removeTotalsListeners(e){e.removeEventListener(E.Table.EVENT_UPDATED,this.handleTotalsUpdate)}handleTableDisconnect(){this.dispatchEvent(new xe(ue.EVENT.DISCONNECT))}handleTableReconnect(){this.dispatchEvent(new xe(ue.EVENT.RECONNECT))}handleTableUpdate(e){this.copyViewportData(e.detail),this.dispatchEvent(new xe(ue.EVENT.UPDATED))}handleTotalsUpdate(e){this.copyTotalsData(e.detail),this.dispatchEvent(new xe(ue.EVENT.UPDATED))}handleRequestFailed(e){this.dispatchEvent(new xe(ue.EVENT.REQUEST_FAILED,e))}handleCustomColumnsChanged(){this.dispatchEvent(new xe(ue.EVENT.COLUMNS_CHANGED,{detail:this.columns}))}get rowCount(){var e,t,n;return this.table.size+this.pendingNewRowCount+((n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0)}get pendingDataErrors(){var e,t;return this.getCachedPendingErrors(this.pendingNewDataMap,this.columns,(t=(e=this.inputTable)==null?void 0:e.keyColumns.length)!=null?t:0)}get pendingDataMap(){return this.pendingNewDataMap}set pendingDataMap(e){e!==this.pendingNewDataMap&&(e.forEach((t,n)=>{if(!Q.isValidIndex(n))throw new Error(`Invalid rowIndex ${n}`);const{data:s}=t;s.forEach((o,i)=>{if(!Q.isValidIndex(i))throw new Error(`Invalid columnIndex ${i}`)})}),this.pendingNewDataMap=e,this.pendingNewRowCount=Math.max(this.pendingNewRowCount,this.maxPendingDataRow),this.formattedStringData=[],this.dispatchEvent(new xe(ue.EVENT.PENDING_DATA_UPDATED)))}get pendingRowCount(){return this.pendingNewRowCount}set pendingRowCount(e){e!==this.pendingNewRowCount&&(this.pendingNewRowCount=Math.max(0,e,this.maxPendingDataRow),this.dispatchEvent(new xe(ue.EVENT.UPDATED)))}get maxPendingDataRow(){return this.pendingNewDataMap.size>0?Math.max(...this.pendingNewDataMap.keys())+1:0}get columnCount(){return this.columns.length}get floatingBottomRowCount(){var e,t,n;return this.totals!=null&&this.totals.showOnTop?0:(n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0}get floatingTopRowCount(){var e,t,n;return this.totals!=null&&this.totals.showOnTop&&(n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0}get isChartBuilderAvailable(){return!0}get isTotalsAvailable(){return this.table.getTotalsTable!=null}get isEditable(){return!this.isSaveInProgress&&this.inputTable!=null}cacheFormattedValue(e,t,n){this.formattedStringData[e]==null&&(this.formattedStringData[e]=[]),this.formattedStringData[e][t]=n}cachePendingValue(e,t,n){this.pendingStringData[e]==null&&(this.pendingStringData[e]=[]),this.pendingStringData[e][t]=n}clearPendingValue(e,t){const n=this.pendingStringData[e];n!=null&&delete n[t]}textValueForCell(e,t){var n,s,o;if(((n=this.pendingStringData[e])==null?void 0:n[t])!==void 0)return this.pendingStringData[e][t];if(((s=this.formattedStringData[e])==null?void 0:s[t])===void 0){const i=this.valueForCell(e,t);if(i==null)return null;const r=(o=this.totalsColumn(e,t))!=null?o:this.columns[e],l=this.getCachedCustomColumnFormatFlag(this.formatter,r.name,r.type);let a;if(!l){const d=this.formatForCell(e,t);(d==null?void 0:d.formatString)!=null&&(a=d)}const c=this.displayString(i,r.type,r.name,a);this.cacheFormattedValue(e,t,c)}return this.formattedStringData[e][t]}textForCell(e,t){const n=this.textValueForCell(e,t);if(n==null&&this.isKeyColumn(e)){const s=this.pendingRow(t);if(s!=null&&this.pendingDataMap.has(s))return"*"}return n!=null?n:""}truncationCharForCell(e){const t=this.columns[e],{type:n}=t;if(N.isNumberType(n)&&this.formatter.truncateNumbersWithPound)return"#"}colorForCell(e,t,n){var o;const s=this.dataForCell(e,t);if(s){const{format:i,value:r}=s;if(r==null||r==="")return M(n.nullStringColor),n.nullStringColor;if(i&&i.color)return i.color;if(this.isPendingRow(t))return M(n.pendingTextColor),n.pendingTextColor;if(r!=null){const l=(o=this.totalsColumn(e,t))!=null?o:this.columns[e];if(N.isDateType(l.type)||l.name==="Date")return M(n.dateColor),n.dateColor;if(N.isNumberType(l.type))return r>0?(M(n.positiveNumberColor),n.positiveNumberColor):r<0?(M(n.negativeNumberColor),n.negativeNumberColor):(M(n.zeroNumberColor),n.zeroNumberColor)}}else if(this.isPendingRow(t)&&this.isKeyColumn(e))return M(n.errorTextColor),n.errorTextColor;return n.textColor}backgroundColorForCell(e,t){var n,s;return(s=(n=this.formatForCell(e,t))==null?void 0:n.backgroundColor)!=null?s:null}textAlignForCell(e){const t=this.columns[e],{type:n}=t;return N.isNumberType(n)?"right":N.isDateType(n)||t.name==="Date"?"center":"left"}textForColumnHeader(e,t=0){const n=this.columnAtDepth(e,t);return gi(n)?n.isNew?"":n.name:n==null?void 0:n.name}colorForColumnHeader(e,t=0){var s;const n=this.columnAtDepth(e,t);return gi(n)&&(s=n.color)!=null?s:null}getColumnHeaderGroup(e,t){const n=this.columnAtDepth(e,t);if(gi(n))return n}getColumnHeaderParentGroup(e,t){var n,s;return this.columnHeaderParentMap.get((s=(n=this.columnAtDepth(e,t))==null?void 0:n.name)!=null?s:"")}columnAtDepth(e,t=0){var i;if(t===0)return this.columns[e];const n=(i=this.columns[e])==null?void 0:i.name;let s=this.columnHeaderParentMap.get(n);if(!s)return;let o=s.depth;for(;o<t;){if(s=this.columnHeaderParentMap.get(s.name),!s)return;o=s.depth}if(s.depth===t)return s}textForRowFooter(e){const t=this.totalsRow(e);return t!=null&&this.totals?this.totals.operationOrder[t]:""}get initialMovedColumns(){var e;return this.getMemoizedInitialMovedColumns((e=this.layoutHints)!=null?e:void 0)}get initialMovedRows(){return Hg}get initialColumnHeaderGroups(){var e;return this.getMemoizedInitialColumnHeaderGroups((e=this.layoutHints)!=null?e:void 0)}get columnMap(){return this.getMemoizedColumnMap(this.table.columns)}get columnHeaderMaxDepth(){var e;return(e=this._columnHeaderMaxDepth)!=null?e:1}set columnHeaderMaxDepth(e){this._columnHeaderMaxDepth=e}get columnHeaderGroupMap(){return this._columnHeaderGroupMap}get columnHeaderGroups(){return this._columnHeaderGroups}set columnHeaderGroups(e){if(e===this._columnHeaderGroups)return;const{groups:t,maxDepth:n,parentMap:s,groupMap:o}=Q.parseColumnHeaderGroups(this,e!=null?e:this.initialColumnHeaderGroups);this._columnHeaderGroups=t,this.columnHeaderMaxDepth=n,this.columnHeaderParentMap=s,this._columnHeaderGroupMap=o}get groupedColumns(){return[]}row(e){var l,a,c,d,u,h,g,p,f,C,w,S,b,v;const t=(c=(a=(l=this.totals)==null?void 0:l.operationOrder)==null?void 0:a.length)!=null?c:0,n=(u=(d=this.totals)==null?void 0:d.showOnTop)!=null?u:!1,s=this.totalsRow(e);if(s!=null){const T=(h=this.totals)==null?void 0:h.operationOrder[s];return M(T),(p=(g=this.totalsDataMap)==null?void 0:g.get(T))!=null?p:null}const o=this.pendingRow(e);if(o!=null)return(f=this.pendingNewDataMap.get(o))!=null?f:null;const i=(w=(C=this.viewportData)==null?void 0:C.offset)!=null?w:0,r=(n?e-t:e)-i;return(v=(b=(S=this.viewportData)==null?void 0:S.rows)==null?void 0:b[r])!=null?v:null}totalsColumn(e,t){var r,l,a,c;const n=this.totalsRow(t);if(n==null)return null;const s=(r=this.totals)==null?void 0:r.operationOrder[n],o=(a=(l=this.totals)==null?void 0:l.defaultOperation)!=null?a:be.SUM,i=this.columns[e];return(c=this.totalsTable)==null?void 0:c.columns.find(d=>{var u;return d.name===`${i.name}__${s}`||(s===o||((u=this.totals)==null?void 0:u.operationOrder.length)===1)&&d.name===i.name})}totalsRow(e){var o,i,r,l,a;const t=(r=(i=(o=this.totals)==null?void 0:o.operationOrder)==null?void 0:i.length)!=null?r:0,s=((a=(l=this.totals)==null?void 0:l.showOnTop)!=null?a:!1)?e:e-this.table.size;return s>=0&&s<t?s:null}pendingRow(e){const t=e-this.floatingTopRowCount-this.table.size;return t>=0&&t<this.pendingNewRowCount?t:null}isTotalsRow(e){return this.totalsRow(e)!=null}isPendingRow(e){return this.pendingRow(e)!=null}dataForCell(e,t){var n;return(n=this.row(t))==null?void 0:n.data.get(e)}formatForCell(e,t){var n;return(n=this.dataForCell(e,t))==null?void 0:n.format}valueForCell(e,t){var s;const n=this.dataForCell(e,t);if(n)return(s=n.value)!=null?s:null}copyViewportData(e){if(e==null){He.warn("invalid data!");return}this.viewportData=this.extractViewportData(e),this.formattedStringData=[]}copyTotalsData(e){var l,a,c,d,u;if(e==null){He.warn("invalid data!");return}const{columns:t,rows:n}=e;if(n.length!==1){He.error("Unexpected number of rows received for totals table, ignoring update");return}const s=new Map,o=n[0],i=(a=(l=this.totals)==null?void 0:l.defaultOperation)!=null?a:be.SUM,r=(c=this.totals)==null?void 0:c.operationMap;for(let h=0;h<t.length;h+=1){const g=t[h],[p,f=(u=(d=r==null?void 0:r[p])==null?void 0:d[0])!=null?u:i]=g.name.split("__");s.has(f)||s.set(f,{data:new Map});const{data:C}=s.get(f),w=this.columns.findIndex(S=>S.name===p);C.set(w,{value:o.get(g),format:o.getFormat(g)})}He.debug2("copyTotalsData",s),this.totalsDataMap=s,this.formattedStringData=[]}getColumnIndexByName(e){return this.getColumnIndicesByNameMap(this.columns).get(e)}extractViewportData(e){const t={offset:e.offset,rows:[]},{columns:n}=e;for(let s=0;s<e.rows.length;s+=1){const o=e.rows[s],i=this.extractViewportRow(o,n);t.rows.push(i)}return t}extractViewportRow(e,t){const n=new Map;for(let s=0;s<t.length;s+=1){const o=t[s],i=this.getColumnIndexByName(o.name);M(i),n.set(i,{value:e.get(o),format:e.getFormat(o)})}return{data:n}}closeSubscription(){He.debug2("closeSubscription",this.subscription),this.subscription&&(this.subscription.close(),this.subscription=null),this.setViewport.cancel(),this.applyViewport.cancel()}get filter(){return this.table.filter}set filter(e){this.closeSubscription(),this.table.applyFilter(e),this.applyViewport()}get formatter(){return this.irisFormatter}set formatter(e){this.irisFormatter=e,this.formattedStringData=[],this.dispatchEvent(new xe(ue.EVENT.FORMATTER_UPDATED))}displayString(e,t,n="",s){return this.getCachedFormattedString(this.formatter,e,t,n,s)}get sort(){return this.table.sort}set sort(e){this.closeSubscription(),this.table.applySort(e),this.applyViewport()}set totalsConfig(e){if(He.debug("set totalsConfig",e),e!==this.totals){if(this.totals=e,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),e==null){this.dispatchEvent(new xe(ue.EVENT.UPDATED));return}this.totalsTablePromise=ze.makeCancelable(this.table.getTotalsTable(e),t=>t.close()),this.totalsTablePromise.then(t=>{this.totalsTablePromise=null,this.setTotalsTable(t)}).catch(t=>{ze.isCanceled(t)||(He.error("Unable to set next totalsTable",t),this.totalsTablePromise=null,this.dispatchEvent(new xe(ue.EVENT.REQUEST_FAILED,{detail:t})))})}}setTotalsTable(e){He.debug("setTotalsTable",e),this.totalsTable!==null&&(this.listenerCount>0&&this.removeTotalsListeners(this.totalsTable),this.totalsTable.close()),this.totalsTable=e,this.totalsDataMap=null,this.listenerCount>0&&this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable)}applyBufferedViewport(e,t,n){He.debug2("applyBufferedViewport",e,t,n),this.subscription==null?(He.debug2("applyBufferedViewport creating new subscription"),this.subscription=this.table.setViewport(e,t,n)):(He.debug2("applyBufferedViewport using existing subscription"),this.subscription.setViewport(e,t,n))}async snapshot(e,t=!1,n=o=>o,s=!0){if(this.subscription==null)throw new Error("No subscription available");const o=s?K.consolidate(e):e;if(!Q.isValidSnapshotRanges(o))throw new Error(`Invalid snapshot ranges ${e}`);const i=new Set,r=[],l=new Set;for(let h=0;h<o.length;h+=1){const g=o[h];M(g.endRow),M(g.startRow);for(let p=g.startRow;p<=g.endRow&&p<this.floatingTopRowCount;p+=1)i.add(p);g.endRow>=this.floatingTopRowCount&&g.startRow<=this.floatingTopRowCount+this.table.size&&r.push(new K(g.startColumn,Math.min(Math.max(0,g.startRow-this.floatingTopRowCount)),g.endColumn,Math.min(Math.max(0,g.endRow-this.floatingTopRowCount),this.table.size-this.floatingTopRowCount)));for(let p=Math.max(g.startRow,this.floatingTopRowCount+this.table.size);p<=g.endRow&&p<this.floatingTopRowCount+this.table.size+this.floatingBottomRowCount;p+=1)l.add(p)}const a=Q.columnsFromRanges(o,this.columns),c=[];t&&c.push(a.map(h=>h.name));const d=[...i].sort();for(let h=0;h<d.length;h+=1){const g=d[h],p=a.map(f=>{const C=this.getColumnIndexByName(f.name);return M(C),n(this.valueForCell(C,g),f)});t&&p.push(this.textForRowFooter(g)),c.push(p)}if(r.length>0){const h=Q.rangeSetFromRanges(r),g=await this.subscription.snapshot(h,a);c.push(...g.rows.map(p=>a.map(f=>n(p.get(f),f))))}const u=[...l].sort();for(let h=0;h<u.length;h+=1){const g=u[h],p=a.map(f=>{const C=this.getColumnIndexByName(f.name);return M(C),n(this.valueForCell(C,g),f)});t&&p.push(this.textForRowFooter(g)),c.push(p)}return c}async textSnapshot(e,t=!1,n=s=>`${s}`){return He.debug2("textSnapshot",e,t),(await this.snapshot(e,t,n,!1)).map(o=>o.join(" ")).join(`
31
31
  `)}async valuesTable(e){let t=null;try{return t=await this.table.copy(),t.applyFilter([]),t.applySort([]),t.selectDistinct([e])}finally{t!=null&&t.close()}}isColumnMovable(e,t){if(e<0||e>=this.columnCount)return!1;if(t>0)return!0;const n=this.columns[e].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)||!n?!1:!this.isKeyColumn(e)}isKeyColumn(e){var t,n;return e<((n=(t=this.inputTable)==null?void 0:t.keyColumns.length)!=null?n:0)}isRowMovable(){return!1}isEditableRange(e){return!(this.inputTable==null||!K.isBounded(e)||!(this.isPendingRow(e.startRow)&&this.isPendingRow(e.endRow)||this.inputTable.keyColumns.length!==0&&e.startColumn>=this.inputTable.keyColumns.length&&e.endColumn>=this.inputTable.keyColumns.length)||e.startRow<this.floatingTopRowCount||e.startRow>=this.floatingTopRowCount+this.table.size+this.pendingRowCount||e.endRow>=this.floatingTopRowCount+this.table.size+this.pendingRowCount)}isDeletableRange(e){return this.inputTable!=null&&e.startRow!=null&&e.endRow!=null&&e.startRow>=this.floatingTopRowCount&&e.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&e.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isEditableRanges(e){return e.every(t=>this.isEditableRange(t))}isDeletableRanges(e){return e.every(t=>this.isDeletableRange(t))}getTableAreaRange(){return new K(null,this.floatingTopRowCount,null,this.floatingTopRowCount+this.table.size-1)}getPendingAreaRange(){return new K(null,this.floatingTopRowCount+this.table.size,null,this.floatingTopRowCount+this.table.size+this.pendingNewRowCount-1)}async setValueForCell(e,t,n){return this.setValueForRanges([new K(e,t,e,t)],n)}async setValueForRanges(e,t){var n;if(!this.isEditableRanges(e))throw new Error(`Uneditable ranges ${e}`);try{const s=new Set,o=[];K.forEachCell(e,(c,d)=>{const u=this.columns[c];if(s.add(u),o[c]===void 0){const h=N.makeValue(u.type,t,this.formatter.timeZone);o[c]=h!=null?this.displayString(h,u.type,u.name):null}this.cachePendingValue(c,d,o[c])});const i=this.getPendingAreaRange(),r=e.map(c=>K.intersection(i,c)).filter(c=>c!=null).map(c=>(M(c),K.offset(c,0,-(this.floatingTopRowCount+this.table.size))));if(r.length>0){const c=new Map(this.pendingNewDataMap);K.forEachCell(r,(d,u)=>{c.has(u)||c.set(u,{data:new Map});const h=this.columns[d],g=c.get(u);M(g);const{data:p}=g,f=new Map(p),C=N.makeValue(h.type,t,this.formatter.timeZone);C!=null?f.set(d,{value:C}):f.delete(d),f.size>0?c.set(u,{...g,data:f}):c.delete(u)}),this.pendingDataMap=c}this.dispatchEvent(new xe(ue.EVENT.UPDATED));const l=this.getTableAreaRange(),a=e.map(c=>K.intersection(l,c)).filter(c=>c!=null);if(a.length>0){const d=(await this.snapshot(a.map(h=>{var g,p;return new K(null,(g=h==null?void 0:h.startRow)!=null?g:null,null,(p=h==null?void 0:h.endRow)!=null?p:null)}))).map(h=>{const g={};for(let p=0;p<this.columns.length;p+=1)g[this.columns[p].name]=h[p];return s.forEach(p=>{g[p.name]=N.makeValue(p.type,t,this.formatter.timeZone)}),g}),u=await((n=this.inputTable)==null?void 0:n.addRows(d));He.debug("setValueForRanges(",e,",",t,") set tableRanges",a,"result",u)}K.forEachCell(e,(c,d)=>{const u=o[c];M(u),this.cacheFormattedValue(c,d,u)})}catch(s){He.error("Unable to set ranges",e,t,s)}finally{K.forEachCell(e,(s,o)=>{this.clearPendingValue(s,o)})}}async setValues(e=[]){var t;if(He.debug("setValues(",e,")"),!e.every(n=>{var s,o;return this.isEditableRange(K.makeCell((s=n.column)!=null?s:n.x,(o=n.row)!=null?o:n.y))}))throw new Error(`Uneditable ranges ${e}`);try{const n=new Map(this.pendingNewDataMap);e.forEach(l=>{var f,C;const{text:a}=l,c=(f=l.column)!=null?f:l.x,d=(C=l.row)!=null?C:l.y,u=this.columns[c],h=N.makeValue(u.type,a,this.formatter.timeZone),g=h!=null?this.displayString(h,u.type,u.name):null;this.cachePendingValue(c,d,g);const p=this.pendingRow(d);if(p!=null){n.has(p)||n.set(p,{data:new Map});const w=n.get(p);M(w);const{data:S}=w,b=new Map(S);h!=null?b.set(c,{value:h}):b.delete(c),b.size>0?n.set(p,{...w,data:b}):n.delete(p)}}),this.pendingDataMap=n,this.dispatchEvent(new xe(ue.EVENT.UPDATED));const s=e.reduce((l,a)=>{var d,u;const c=(d=a.row)!=null?d:a.y;return l.has(c)||l.set(c,[]),(u=l.get(c))==null||u.push(a),l},new Map),o=K.consolidate(e.map(l=>{var a,c;return K.makeCell((a=l.column)!=null?a:l.x,(c=l.row)!=null?c:l.y)})),i=this.getTableAreaRange(),r=o.map(l=>K.intersection(i,l)).filter(l=>l!=null);if(r.length>0){const a=(await this.snapshot(r.map(d=>(M(d),new K(null,d.startRow,null,d.endRow))))).map((d,u)=>{let h=null,g=u;for(let C=0;C<r.length;C+=1){const w=r[C];M(w);const S=K.rowCount([w]);if(g<S){M(w.startRow),h=w.startRow+g;break}g-=S}const p={};for(let C=0;C<this.columns.length;C+=1)p[this.columns[C].name]=d[C];M(h);const f=s.get(h);return f!=null&&f.forEach(C=>{var S;const w=this.columns[(S=C.column)!=null?S:C.x];p[w.name]=N.makeValue(w.type,C.text,this.formatter.timeZone)}),p});He.info("setValues setting tableRanges",r);const c=await((t=this.inputTable)==null?void 0:t.addRows(a));He.info("setValues set tableRanges",r,"SUCCESS",c)}e.forEach(l=>{var p,f;const{text:a}=l,c=(p=l.column)!=null?p:l.x,d=(f=l.row)!=null?f:l.y,u=this.columns[c],h=N.makeValue(u.type,a,this.formatter.timeZone),g=h!=null?this.displayString(h,u.type,u.name):null;this.cacheFormattedValue(c,d,g)})}finally{e.forEach(n=>{this.clearPendingValue(n.column,n.row)})}}async commitPending(){var e,t,n;if(this.pendingNewDataMap.size<=0)throw new Error("No pending changes to commit");try{this.isSaveInProgress=!0;const s=[];this.pendingNewDataMap.forEach(i=>{const r={};i.data.forEach(({value:l},a)=>{const c=this.columns[a];r[c.name]=l}),s.push(r)});const o=await((e=this.inputTable)==null?void 0:e.addRows(s));He.debug("commitPending()",this.pendingNewDataMap,"result",o),this.pendingNewDataMap=new Map,this.pendingNewRowCount=Math.max(0,((n=(t=this.viewport)==null?void 0:t.bottom)!=null?n:0)-this.table.size),this.formattedStringData=[],this.dispatchEvent(new xe(ue.EVENT.PENDING_DATA_UPDATED))}finally{this.isSaveInProgress=!1}}editValueForCell(e,t){return this.textValueForCell(e,t)}async delete(e){if(!this.isDeletableRanges(e))throw new Error(`Undeletable ranges ${e}`);M(this.inputTable);const{keyColumns:t}=this.inputTable;if(t.length===0)throw new Error("No key columns to allow deletion");const n=this.getPendingAreaRange(),s=e.map(d=>K.intersection(n,d)).filter(d=>d!=null).map(d=>(M(d),K.offset(d,0,-(this.floatingTopRowCount+this.table.size))));if(s.length>0){const d=new Map(this.pendingNewDataMap);for(let u=0;u<s.length;u+=1){const h=s[u];M(h.startRow),M(h.endRow);for(let g=h.startRow;g<=h.endRow;g+=1)d.delete(g)}this.pendingNewDataMap=d,this.formattedStringData=[],this.dispatchEvent(new xe(ue.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new xe(ue.EVENT.UPDATED))}const o=this.getTableAreaRange(),i=e.map(d=>K.intersection(o,d)).filter(d=>d!=null);if(i.length<=0)return;const[r,l]=await Promise.all([this.snapshot(i.map(d=>(M(d),new K(0,d.startRow,t.length-1,d.endRow)))),this.table.copy()]),c=r.map(d=>{const u=[];for(let h=0;h<t.length;h+=1){const g=t[h],p=d[h],f=N.makeFilterRawValue(g.type,p),C=g.filter().eq(f);u.push(C)}return u.reduce((h,g)=>{var p;return(p=h==null?void 0:h.and(g))!=null?p:g})}).reduce((d,u)=>{var h;return(h=d==null?void 0:d.or(u))!=null?h:u});l.applyFilter([c]),l.close()}isValidForCell(e,t,n){try{const s=this.columns[e];return N.makeValue(s.type,n,this.formatter.timeZone),!0}catch{return!1}}};let rr=Mi;rr.ROW_BUFFER_PAGES=1;const yn=le.module("IrisGridTableModel");class Vg extends rr{constructor(t,n=new zt,s=null){super(t,n,s),this.getMemoizedFrontColumns=Fe(o=>o!=null?o:[]),this.getMemoizedBackColumns=Fe(o=>o!=null?o:[]),this.getMemoizedFrozenColumns=Fe((o,i)=>{var r;return(r=i!=null?i:o)!=null?r:[]}),this.getCachedFilterableColumnSet=Fe(o=>new Set(o.map((i,r)=>r))),this.customColumnList=[],this.formatColumnList=[]}get isExportAvailable(){return this.table.freeze!=null}get isColumnStatisticsAvailable(){return this.table.getColumnStatistics!=null}get isValuesTableAvailable(){return this.table.selectDistinct!=null&&this.table.copy!=null}get isRollupAvailable(){return this.table.rollup!=null}get isSelectDistinctAvailable(){return this.table.selectDistinct!=null}get isCustomColumnsAvailable(){return this.table.applyCustomColumns!=null}get isFormatColumnsAvailable(){return this.table.applyCustomColumns!=null}get frontColumns(){var t;return this.getMemoizedFrontColumns((t=this.layoutHints)==null?void 0:t.frontColumns)}get backColumns(){var t;return this.getMemoizedBackColumns((t=this.layoutHints)==null?void 0:t.backColumns)}get frozenColumns(){var t;return this.getMemoizedFrozenColumns((t=this.layoutHints)==null?void 0:t.frozenColumns,this.userFrozenColumns)}get layoutHints(){return this.table.layoutHints}get floatingLeftColumnCount(){return this.frozenColumns.length}get description(){return this.table.description}get customColumns(){return this.customColumnList}set customColumns(t){if(yn.debug2("set customColumns",t,this.customColumnList,t===this.customColumnList),this.customColumnList.length===0&&t.length===0){yn.debug("Ignore empty initial customColumns"),this.customColumnList=t;return}if(this.customColumnList===t){yn.debug("Ignore same customColumns");return}this.closeSubscription(),this.customColumnList=t,this.table.applyCustomColumns([...t,...this.formatColumns]),this.applyViewport()}get formatColumns(){return this.formatColumnList}set formatColumns(t){if(yn.debug2("set formatColumns",t,this.formatColumnList,t===this.formatColumnList),this.formatColumnList.length===0&&t.length===0){yn.debug("Ignore empty initial formatColumns"),this.formatColumnList=t;return}if(this.formatColumnList===t){yn.debug("Ignore same formatColumns");return}this.closeSubscription(),this.formatColumnList=t,this.table.applyCustomColumns([...this.customColumns,...t]),this.applyViewport()}updateFrozenColumns(t){this.userFrozenColumns=t,this.dispatchEvent(new xe(ue.EVENT.TABLE_CHANGED,{detail:this.table}))}set totalsConfig(t){if(yn.debug("set totalsConfig",t),t!==this.totals){if(this.totals=t,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),t==null){this.dispatchEvent(new xe(ue.EVENT.UPDATED));return}this.totalsTablePromise=ze.makeCancelable(this.table.getTotalsTable(t),n=>n.close()),this.totalsTablePromise.then(n=>{this.totalsTablePromise=null,this.setTotalsTable(n)}).catch(n=>{ze.isCanceled(n)||(yn.error("Unable to set next totalsTable",n),this.totalsTablePromise=null,this.dispatchEvent(new xe(ue.EVENT.REQUEST_FAILED,{detail:n})))})}}get isFilterRequired(){return this.table.isUncoalesced}isFilterable(t){return this.getCachedFilterableColumnSet(this.columns).has(t)}async export(){return this.table.freeze()}columnStatistics(t){return this.table.getColumnStatistics(t)}isColumnMovable(t){const n=this.columns[t].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)?!1:!this.isKeyColumn(t)}isColumnFrozen(t){return this.frozenColumns.includes(this.columns[t].name)}async delete(t){var u;if(!this.isDeletableRanges(t))throw new Error(`Undeletable ranges ${t}`);M(this.inputTable);const{keyColumns:n}=this.inputTable;if(n.length===0)throw new Error("No key columns to allow deletion");const s=this.getPendingAreaRange(),o=t.map(h=>K.intersection(s,h)).filter(h=>h!=null).map(h=>(M(h),K.offset(h,0,-(this.floatingTopRowCount+this.table.size))));if(o.length>0){const h=new Map(super.pendingDataMap);for(let g=0;g<o.length;g+=1){const p=o[g];M(p.startRow),M(p.endRow);for(let f=p.startRow;f<=p.endRow;f+=1)h.delete(f)}super.pendingDataMap=h,this.formattedStringData=[],this.dispatchEvent(new xe(ue.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new xe(ue.EVENT.UPDATED))}const i=this.getTableAreaRange(),r=t.map(h=>K.intersection(i,h)).filter(h=>h!=null);if(r.length<=0)return;const[l,a]=await Promise.all([this.snapshot(r.map(h=>(M(h),new K(0,h.startRow,n.length-1,h.endRow)))),this.table.copy()]),d=l.map(h=>{const g=[];for(let p=0;p<n.length;p+=1){const f=n[p],C=h[p],w=N.makeFilterRawValue(f.type,C),S=f.filter().eq(w);g.push(S)}return g.reduce((p,f)=>{var C;return(C=p==null?void 0:p.and(f))!=null?C:f})}).reduce((h,g)=>{var p;return(p=h==null?void 0:h.or(g))!=null?p:g});a.applyFilter([d]),await((u=this.inputTable)==null?void 0:u.deleteTable(a)),a.close()}async seekRow(t,n,s,o,i,r,l){return this.table.seekRow(t,n,s,o,i,r,l)}get isSeekRowAvailable(){return this.table.seekRow!=null}}class Ug extends rr{constructor(){super(...arguments),this.getCachedFilterableColumnSet=Fe((t,n)=>new Set(((n==null?void 0:n.length)>0?n:t).map(s=>t.findIndex(o=>s.name===o.name))))}applyBufferedViewport(t,n,s){this.table.setViewport(t,n,s)}textForCell(t,n){const s=this.columns[t],o=this.row(n);if(o!=null&&s!=null&&!o.hasChildren&&s.constituentType!=null){const i=this.valueForCell(t,n);return this.displayString(i,s.constituentType,s.name)}return super.textForCell(t,n)}extractViewportRow(t,n){const{isExpanded:s,hasChildren:o,depth:i}=t;return{...super.extractViewportRow(t,n),isExpanded:s,hasChildren:o,depth:i}}async snapshot(t,n,s){var l,a;M(this.viewport),M(this.viewportData);const{columns:o}=this.viewport,i=[];n!=null&&n&&i.push(o.map(c=>c.name));const r=new K(0,(l=this.viewportData)==null?void 0:l.offset,o.length,this.viewportData.offset+this.viewportData.rows.length);for(let c=0;c<t.length;c+=1){const d=K.intersection(r,t[c]);M(d),M(d.startRow),M(d.endRow);for(let u=d.startRow;u<=d.endRow;u+=1){const h=[],g=this.viewportData.rows[u-this.viewportData.offset];M(d.startColumn),M(d.endColumn);for(let p=d.startColumn;p<=d.endColumn;p+=1)M(s),h.push(s((a=g.data.get(p))==null?void 0:a.value,this.columns[p]));i.push(h)}}return i}get groupedColumns(){return this.table.groupedColumns}get hasExpandableRows(){return!0}get isExpandAllAvailable(){return this.table.expandAll!==void 0}get isChartBuilderAvailable(){return!1}get isSelectDistinctAvailable(){return!1}get isReversible(){return!1}isFilterable(t){return this.getCachedFilterableColumnSet(this.columns,this.groupedColumns).has(t)}isColumnMovable(t){return t>=this.groupedColumns.length}isRowExpandable(t){var s;const n=this.row(t);return(s=n==null?void 0:n.hasChildren)!=null?s:!1}isRowExpanded(t){var s;const n=this.row(t);return(s=n==null?void 0:n.isExpanded)!=null?s:!1}setRowExpanded(t,n,s=!1){this.isExpandAllAvailable?this.table.setExpanded(t,n,s):this.table.setExpanded(t,n)}expandAll(){this.table.expandAll&&this.table.expandAll()}collapseAll(){this.table.collapseAll&&this.table.collapseAll()}depthForRow(t){var s;const n=this.row(t);return((s=n==null?void 0:n.depth)!=null?s:1)-1}}const Fn=le.module("IrisGridProxyModel");function Ri(e,t,n){return N.isTreeTable(e)?new Ug(e,t):new Vg(e,t,n)}class Bg extends ue{constructor(t,n=new zt,s=null){super(),this.textForCell=(...i)=>this.model.textForCell(...i),this.truncationCharForCell=(...i)=>this.model.truncationCharForCell(...i),this.textAlignForCell=(...i)=>this.model.textAlignForCell(...i),this.colorForCell=(...i)=>this.model.colorForCell(...i),this.backgroundColorForCell=(...i)=>this.model.backgroundColorForCell(...i),this.textForColumnHeader=(...i)=>this.model.textForColumnHeader(...i),this.colorForColumnHeader=(...i)=>this.model.colorForColumnHeader(...i),this.textForRowHeader=(...i)=>this.model.textForRowHeader(...i),this.textForRowFooter=(...i)=>this.model.textForRowFooter(...i),this.isRowMovable=(...i)=>this.model.isRowMovable(...i),this.isColumnMovable=(...i)=>this.model.isColumnMovable(...i),this.isRowExpandable=(...i)=>Me(this.model)?this.model.isRowExpandable(...i):!1,this.isRowExpanded=(...i)=>Me(this.model)?this.model.isRowExpanded(...i):!1,this.setRowExpanded=(...i)=>{if(Me(this.model))return this.model.setRowExpanded(...i);throw Error("Function setRowExpanded does not exist on IrisGridTableModel")},this.expandAll=()=>{if(Me(this.model))return this.model.expandAll();throw Error("Function expandAll does not exist on IrisGridTableModel")},this.collapseAll=()=>{if(Me(this.model))return this.model.collapseAll();throw Error("Function collapseAll does not exist on IrisGridTableModel")},this.depthForRow=(...i)=>Me(this.model)?this.model.depthForRow(...i):0,this.getColumnHeaderGroup=(...i)=>this.model.getColumnHeaderGroup(...i),this.getColumnHeaderParentGroup=(...i)=>this.model.getColumnHeaderParentGroup(...i),this.formatForCell=(...i)=>this.model.formatForCell(...i),this.valueForCell=(...i)=>this.model.valueForCell(...i),this.displayString=(...i)=>this.model.displayString(...i),this.isEditableRange=(...i)=>Pe(this.model)?this.model.isEditableRange(...i):!1,this.isFilterable=(...i)=>this.model.isFilterable(...i),this.setViewport=(i,r,l)=>this.model.setViewport(i,r,l),this.snapshot=(...i)=>this.model.snapshot(...i),this.textSnapshot=(...i)=>this.model.textSnapshot(...i),this.valuesTable=(...i)=>this.model.valuesTable(...i),this.editValueForCell=(...i)=>Pe(this.model)?this.model.editValueForCell(...i):"",this.setValueForCell=(...i)=>Pe(this.model)?this.model.setValueForCell(...i):Promise.reject(new Error("Model is not editable")),this.setValueForRanges=(...i)=>Pe(this.model)?this.model.setValueForRanges(...i):Promise.reject(new Error("Model is not editable")),this.setValues=(...i)=>Pe(this.model)?this.model.setValues(...i):Promise.resolve(),this.isValidForCell=(...i)=>Pe(this.model)?this.model.isValidForCell(...i):!1,this.delete=(...i)=>this.model.delete(...i),this.commitPending=(...i)=>this.model.commitPending(...i),this.handleModelEvent=this.handleModelEvent.bind(this);const o=Ri(t,n,s);this.originalModel=o,this.model=o,this.modelPromise=null,this.rollup=null,this.selectDistinct=[]}close(){this.originalModel.close(),this.model!==this.originalModel&&this.model.close(),this.modelPromise!=null&&this.modelPromise.cancel()}handleModelEvent(t){Fn.debug2("handleModelEvent",t);const{detail:n,type:s}=t;this.dispatchEvent(new xe(s,{detail:n}))}setModel(t){Fn.debug("setModel",t);const n=this.model;n!==this.originalModel&&n.close(),this.model=t,this.listenerCount>0&&this.addListeners(t),this.dispatchEvent(new xe(ue.EVENT.COLUMNS_CHANGED,{detail:t.columns})),Mo(t)&&this.dispatchEvent(new xe(ue.EVENT.TABLE_CHANGED,{detail:t.table}))}setNextModel(t){Fn.debug2("setNextModel"),this.modelPromise&&this.modelPromise.cancel(),this.listenerCount>0&&this.removeListeners(this.model),this.modelPromise=ze.makeCancelable(t,n=>n.close()),this.modelPromise.then(n=>{this.modelPromise=null,this.setModel(n)}).catch(n=>{if(ze.isCanceled(n)){Fn.debug2("setNextModel cancelled");return}Fn.error("Unable to set next model",n),this.modelPromise=null,this.dispatchEvent(new xe(ue.EVENT.REQUEST_FAILED,{detail:n}))})}startListening(){super.startListening(),this.addListeners(this.model)}stopListening(){super.stopListening(),this.removeListeners(this.model)}addListeners(t){const n=Object.keys(ue.EVENT);for(let s=0;s<n.length;s+=1)t.addEventListener(n[s],this.handleModelEvent)}removeListeners(t){const n=Object.keys(ue.EVENT);for(let s=0;s<n.length;s+=1)t.removeEventListener(n[s],this.handleModelEvent)}get rowCount(){return this.model.rowCount}get columnCount(){return this.model.columnCount}get floatingTopRowCount(){return this.model.floatingTopRowCount}get floatingBottomRowCount(){return this.model.floatingBottomRowCount}get floatingLeftColumnCount(){return this.model.floatingLeftColumnCount}get floatingRightColumnCount(){return this.model.floatingRightColumnCount}isColumnFrozen(t){return this.model.isColumnFrozen(t)}get hasExpandableRows(){return Me(this.model)?this.model.hasExpandableRows:!1}get isExpandAllAvailable(){var t;return Me(this.model)&&(t=this.model.isExpandAllAvailable)!=null?t:!1}get isExportAvailable(){return this.model.isExportAvailable}get isColumnStatisticsAvailable(){return this.model.isColumnStatisticsAvailable}get isValuesTableAvailable(){return this.model.isValuesTableAvailable}get isCustomColumnsAvailable(){return this.model.isCustomColumnsAvailable&&!(this.isSelectDistinctAvailable&&this.selectDistinctColumns.length>0)}get isFormatColumnsAvailable(){return this.model.isFormatColumnsAvailable}get isChartBuilderAvailable(){return this.model.isChartBuilderAvailable}get isRollupAvailable(){return(this.originalModel.isRollupAvailable||this.rollup!=null)&&this.selectDistinct.length===0}get isSelectDistinctAvailable(){return(this.originalModel.isSelectDistinctAvailable||this.selectDistinct.length>0)&&this.rollup==null}get isTotalsAvailable(){return this.model.isTotalsAvailable}get isReversible(){return this.model.isReversible}get columns(){return this.model.columns}get initialMovedColumns(){return this.model.initialMovedColumns}get initialMovedRows(){return this.model.initialMovedRows}get layoutHints(){return this.model.layoutHints}get frontColumns(){return this.model.frontColumns}get backColumns(){return this.model.backColumns}get frozenColumns(){return this.model.frozenColumns}get columnHeaderGroups(){return this.model.columnHeaderGroups}set columnHeaderGroups(t){this.model.columnHeaderGroups=t}get initialColumnHeaderGroups(){return this.model.initialColumnHeaderGroups}get columnHeaderGroupMap(){return this.model.columnHeaderGroupMap}get columnHeaderMaxDepth(){return this.model.columnHeaderMaxDepth}updateFrozenColumns(t){return this.model.updateFrozenColumns(t)}get originalColumns(){return this.originalModel.columns}get groupedColumns(){return this.model.groupedColumns}get description(){return this.model.description}get filter(){return this.model.filter}set filter(t){this.model.filter=t}get formatter(){return this.model.formatter}set formatter(t){this.model.formatter=t}get sort(){return this.model.sort}set sort(t){this.model.sort=t}get customColumns(){return this.model.customColumns}set customColumns(t){this.model.customColumns=t}get formatColumns(){return this.model.formatColumns}set formatColumns(t){this.model.formatColumns=t}get rollupConfig(){return this.rollup}set rollupConfig(t){if(Fn.debug("set rollupConfig",t),!this.isRollupAvailable)throw new Error("Rollup Rows are not available");if(it(t,this.rollup))return;this.rollup=t;let n=Promise.resolve(this.originalModel);Mo(this.originalModel)&&t!=null&&(n=this.originalModel.table.rollup(t).then(s=>Ri(s,this.formatter))),this.setNextModel(n)}get selectDistinctColumns(){return this.selectDistinct}set selectDistinctColumns(t){if(Fn.debug("set selectDistinctColumns",t),!this.isSelectDistinctAvailable)throw new Error("Select distinct is not available");if(t===this.selectDistinctColumns||t.length===0&&this.selectDistinctColumns.length===0){Fn.debug("Ignore same selectDistinctColumns",t);return}this.selectDistinct=t;const n=t.map(o=>this.originalColumns.find(i=>i.name===o)).filter(o=>o!=null);let s=Promise.resolve(this.originalModel);Mo(this.originalModel)&&n.length>0&&(s=this.originalModel.table.selectDistinct(n).then(o=>Ri(o,this.formatter))),this.setNextModel(s)}get table(){if(Mo(this.model))return this.model.table}get totalsConfig(){return this.model.totalsConfig}set totalsConfig(t){this.model.totalsConfig=t}get isFilterRequired(){return this.model.isFilterRequired}get isEditable(){return Pe(this.model)&&this.model.isEditable}export(){if(N.isTreeTable(this.model))throw new Error("TreeTable has no 'export' property");return this.model.export()}columnStatistics(t){if(N.isTreeTable(this.model))throw new Error("TreeTable has no 'columnStatistics' function");return this.model.columnStatistics(t)}get pendingDataMap(){return this.model.pendingDataMap}set pendingDataMap(t){this.model.pendingDataMap=t}get pendingRowCount(){return this.model.pendingRowCount}set pendingRowCount(t){this.model.pendingRowCount=t}get pendingDataErrors(){return this.model.pendingDataErrors}getColumnIndexByName(t){return this.model.getColumnIndexByName(t)}async seekRow(t,n,s,o,i,r,l){return this.model.seekRow(t,n,s,o,i,r,l)}get isSeekRowAvailable(){return this.model.isSeekRowAvailable}}class Gg{static async makeModel(t,n=new zt){let s=null;return!N.isTreeTable(t)&&t.hasInputTable&&(s=await t.inputTable()),new Bg(t,n,s)}}const tn=le.module("TableViewportUpdater"),Wg=150,zs=class extends F.exports.PureComponent{constructor(){super(...arguments),this.getViewportRowRange=Fe((e,t,n)=>{const s=n-t,o=Math.max(0,t-s*zs.ROW_BUFFER_PAGES),i=n+s*zs.ROW_BUFFER_PAGES;return[o,i]}),this.getViewportColumns=Fe((e,t,n,s)=>{if(t==null||n==null)return null;const o=n-t,i=Math.max(0,t-o*zs.COLUMN_BUFFER_PAGES),r=Math.min(n+o*zs.COLUMN_BUFFER_PAGES,e.columns.length-1),l=[];for(let a=i;a<=r;a+=1){const c=_.getModelIndex(a,s);l.push(e.columns[c])}return l}),this.updateViewport=Pn((e,t,n,s,o)=>{if(t<e){tn.error("Invalid viewport",e,t);return}if(e===0&&t===0){tn.debug2("Ignoring 0-0 viewport");return}const{movedColumns:i,table:r}=this.props,[l,a]=this.getViewportRowRange(r,e,t),c=o!=null?o:this.getViewportColumns(r,n,s,i);if(tn.debug2("Setting Viewport Top:",l,"Bottom:",a,"Columns:",c),this.subscription==null){tn.debug2("updateViewport creating new subscription"),this.subscription=r.setViewport(l,a,c);const{onSubscription:d}=this.props;d(this.subscription)}else tn.debug2("updateViewport using existing subscription"),this.subscription.setViewport(l,a,c)},Wg)}componentDidMount(){const{top:e,bottom:t,left:n,right:s,table:o,filters:i,sorts:r,columns:l,customColumns:a}=this.props;o.applyFilter(i),o.applySort(r),o.applyCustomColumns(a),this.updateViewport(e,t,n,s,l)}componentDidUpdate(e){const{top:t,bottom:n,left:s,right:o,table:i,filters:r,sorts:l,customColumns:a,columns:c}=this.props,d=r!==e.filters,u=l!==e.sorts,h=a!==e.customColumns,g=i!==e.table;(d||u||h||g)&&this.closeSubscription(),(d||g)&&(tn.debug("update table filter",r),i.applyFilter(r)),(u||g)&&(tn.debug("update table sort",l),i.applySort(l)),(h||g)&&(tn.debug("update table custom columns",a),i.applyCustomColumns(a)),this.updateViewport(t,n,s,o,c)}componentWillUnmount(){this.closeSubscription()}closeSubscription(){if(tn.debug2("closeSubscription",this.subscription),this.subscription){this.subscription.close(),this.subscription=void 0;const{onSubscription:e}=this.props;e()}this.updateViewport.cancel()}render(){return null}};let lr=zs;lr.ROW_BUFFER_PAGES=3;lr.COLUMN_BUFFER_PAGES=1;lr.defaultProps={top:0,bottom:0,left:null,right:null,columns:null,onSubscription:()=>{},filters:[],sorts:[],customColumns:[],movedColumns:[]};const gs=le.module("TreeTableViewportUpdater"),$g=150,ga=class extends F.exports.PureComponent{constructor(e){super(e),this.updateViewport=Pn((t,n)=>{if(n<t){gs.error("Invalid viewport",t,n);return}if(t===0&&n===0){gs.debug2("Ignoring 0-0 viewport");return}const{table:s,updateInterval:o}=this.props,i=n-t,r=Math.max(0,t-i*3),l=n+i*3+1;if(gs.debug2("Setting Viewport Top:",r,"Bottom:",l,s),!this.listenerCleanup){const{onViewportUpdate:a}=this.props;this.listenerCleanup=s.addEventListener(E.TreeTable.EVENT_UPDATED,a)}s.setViewport(r,l,void 0,o)},$g),this.listenerCleanup=null}componentDidMount(){const{top:e,bottom:t,table:n,filters:s,sorts:o}=this.props;gs.debug("componentDidMount",this.props),n.applyFilter(s),n.applySort(o),this.updateViewport(e,t)}componentDidUpdate(e){const{top:t,bottom:n,table:s,filters:o,sorts:i}=this.props;o!==e.filters&&(gs.debug("update table filter",o),s.applyFilter(o)),i!==e.sorts&&(gs.debug("update table sort",i),s.applySort(i)),this.updateViewport(t,n)}componentWillUnmount(){this.updateViewport.cancel(),this.listenerCleanup&&this.listenerCleanup()}render(){return null}};let pa=ga;pa.UPDATE_INTERVAL=1e3;pa.defaultProps={top:0,bottom:0,onViewportUpdate:()=>{},filters:[],sorts:[],updateInterval:ga.UPDATE_INTERVAL};le.setLogLevel(parseInt("2",10));const ws=le.module("EmbedGrid.App"),zg=[E.VariableType.TABLE,E.VariableType.TREETABLE,E.VariableType.HIERARCHICALTABLE,E.VariableType.PANDAS];async function qg(e,t){ws.info(`Fetching table ${t}...`);const n=await Id(e,t);if(!zg.includes(n.type))throw new Error(`Unsupported type '${n.type}' for variable named '${t}'`);return await e.getObject(n)}function Zg(){const[e,t]=F.exports.useState(),[n,s]=F.exports.useState(),[o,i]=F.exports.useState(),[r,l]=F.exports.useState(),[a,c]=F.exports.useState(!0),d=F.exports.useMemo(()=>new URLSearchParams(window.location.search),[]),u=d.get("canCopy")!=null,h=d.get("canDownloadCsv")!=null;F.exports.useEffect(function(){async function f(){try{const C=d.get("name");if(C==null)throw new Error("No name param provided");const w=new URL("/jsapi",`${window.location}`),S=`${w.protocol}//${w.host}`;ws.debug("Starting connection...");const b=new E.IdeConnection(S);ws.debug("Loading table",C,"...");const v=await qg(b,C);ws.debug("Creating model...");const T=await Gg.makeModel(v);t(T),ws.debug("Table successfully loaded!")}catch(C){ws.error("Unable to load table",C),s(`${C}`)}c(!1)}f()},[d]),F.exports.useEffect(function(){function f(C){const{command:w,value:S}=C.data;switch(w){case"filter":{const v=S.map(({name:T,value:R})=>{const D=e==null?void 0:e.columns.find(A=>A.name===T);if(D==null)throw new Error(`Could not find column named ${T}`);return{name:T,value:R,type:N.getNormalizedType(D.type)}});i(v);break}case"sort":{const v=S.map(({name:T,direction:R})=>{const D=e==null?void 0:e.columns.find(A=>A.name===T);if(D==null)throw new Error(`Could not find column named ${T}`);return R==="DESC"?D.sort().desc():D.sort().asc()});l(v);break}}}return window.addEventListener("message",f),()=>{window.removeEventListener("message",f)}},[e]);const g=e!=null;return y("div",{className:"App",children:[g&&m(to,{canCopy:u,canDownloadCsv:h,model:e,inputFilters:o,sorts:r}),!g&&m(ml,{isLoaded:g,isLoading:a,errorMessage:n!=null?n:null}),m(Qc,{})]})}export{zg as SUPPORTED_TYPES,Zg as default};
32
- //# sourceMappingURL=App.851d3f6a.js.map
32
+ //# sourceMappingURL=App.7fdb50de.js.map