@guiexpert/svelte-table 1.0.6 → 1.0.7

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.
Files changed (4) hide show
  1. package/README.md +14 -15
  2. package/index.cjs +9 -9
  3. package/index.js +751 -965
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -13,7 +13,7 @@ This is the UI-agnostic table component for your next web app. 😊
13
13
  - Handle large datasets easily
14
14
  - Excellent performance for large tables by vertical and horizontal virtual scrolling
15
15
  - Fully-featured (advanced sorting and filtering)
16
- - Highly customizable data grid
16
+ - Highly customizable orderData grid
17
17
  - Outstanding performance
18
18
  - No third-party dependencies
19
19
  - UI-agnostic
@@ -51,10 +51,10 @@ Add the following two NPM packages to your existing Svelte project (run this in
51
51
  npm install --save @guiexpert/table @guiexpert/svelte-table
52
52
  ```
53
53
 
54
- Add SvelteTable component to a template:
54
+ Add GuiexpertTable component to a template:
55
55
 
56
56
  ```
57
- <SvelteTable
57
+ <GuiexpertTable
58
58
  on:mouseClicked={handleMouseClicked}
59
59
  on:tableReady={handleTableReady}
60
60
  tableModel={tableModel}
@@ -66,11 +66,11 @@ Import the following classes in your component:
66
66
  ```
67
67
  <script lang="ts">
68
68
 
69
- import { SvelteTable } from "@guiexpert/svelte-table";
69
+ import { GuiexpertTable } from "@guiexpert/svelte-table";
70
70
  import {
71
71
  GeMouseEvent,
72
72
  TableApi
73
- TableModelFactory,
73
+ TableFactory,
74
74
  TableModelIf,
75
75
  TableOptions,
76
76
  TableOptionsIf
@@ -81,16 +81,15 @@ import {
81
81
  Add a tableModel property and a onTableReady method to the component:
82
82
 
83
83
  ```
84
- const tableModel: TableModelIf = TableModelFactory
85
- .createByArrayOfArraysParams<any>(param: {
86
- columnLabels: [
87
- ['Header 1', 'Header 2']
88
- ],
89
- data: [
90
- ['Text 1a', 'Text 2a'],
91
- ['Text 1b', 'Text 2b'],
92
- ]
93
- };
84
+ const tableModel: TableModelIf = TableFactory.createTableModel({
85
+ headerData: [
86
+ ['Header 1', 'Header 2']
87
+ ],
88
+ bodyData: [
89
+ ['Text 1a', 'Text 2a'],
90
+ ['Text 1b', 'Text 2b'],
91
+ ]
92
+ });
94
93
 
95
94
  function onTableReady(api: TableApi) {
96
95
  console.info("onTableReady API:", api);
package/index.cjs CHANGED
@@ -1,20 +1,20 @@
1
- "use strict";var ne=Object.defineProperty;var ae=(l,e,t)=>e in l?ne(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t;var H=(l,e,t)=>(ae(l,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("svelte");function _(){}function te(l){return l()}function Z(){return Object.create(null)}function P(l){l.forEach(te)}function se(l){return typeof l=="function"}function de(l,e){return l!=l?e==e:l!==e||l&&typeof l=="object"||typeof l=="function"}function he(l){return Object.keys(l).length===0}function ce(l,e,t){l.insertBefore(e,t||null)}function ie(l){l.parentNode&&l.parentNode.removeChild(l)}function pe(l){return document.createElement(l)}function ue(l,e,t){t==null?l.removeAttribute(e):l.getAttribute(e)!==t&&l.setAttribute(e,t)}function fe(l){return Array.from(l.childNodes)}function $(l,e,t,s){t==null?l.style.removeProperty(e):l.style.setProperty(e,t,s?"important":"")}let X;function L(l){X=l}const F=[],W=[];let O=[];const ee=[],ge=Promise.resolve();let G=!1;function Se(){G||(G=!0,ge.then(oe))}function N(l){O.push(l)}const V=new Set;let D=0;function oe(){if(D!==0)return;const l=X;do{try{for(;D<F.length;){const e=F[D];D++,L(e),me(e.$$)}}catch(e){throw F.length=0,D=0,e}for(L(null),F.length=0,D=0;W.length;)W.pop()();for(let e=0;e<O.length;e+=1){const t=O[e];V.has(t)||(V.add(t),t())}O.length=0}while(F.length);for(;ee.length;)ee.pop()();G=!1,V.clear(),L(l)}function me(l){if(l.fragment!==null){l.update(),P(l.before_update);const e=l.dirty;l.dirty=[-1],l.fragment&&l.fragment.p(l.ctx,e),l.after_update.forEach(N)}}function be(l){const e=[],t=[];O.forEach(s=>l.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),O=e}const ye=new Set;function we(l,e){l&&l.i&&(ye.delete(l),l.i(e))}function xe(l,e,t){const{fragment:s,after_update:i}=l.$$;s&&s.m(e,t),N(()=>{const o=l.$$.on_mount.map(te).filter(se);l.$$.on_destroy?l.$$.on_destroy.push(...o):P(o),l.$$.on_mount=[]}),i.forEach(N)}function ve(l,e){const t=l.$$;t.fragment!==null&&(be(t.after_update),P(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Ce(l,e){l.$$.dirty[0]===-1&&(F.push(l),Se(),l.$$.dirty.fill(0)),l.$$.dirty[e/31|0]|=1<<e%31}function Ee(l,e,t,s,i,o,r=null,a=[-1]){const n=X;L(l);const d=l.$$={fragment:null,ctx:[],props:o,update:_,not_equal:i,bound:Z(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(n?n.$$.context:[])),callbacks:Z(),dirty:a,skip_bound:!1,root:e.target||n.$$.root};r&&r(d.root);let h=!1;if(d.ctx=t?t(l,e.props||{},(p,g,...S)=>{const c=S.length?S[0]:g;return d.ctx&&i(d.ctx[p],d.ctx[p]=c)&&(!d.skip_bound&&d.bound[p]&&d.bound[p](c),h&&Ce(l,p)),g}):[],d.update(),h=!0,P(d.before_update),d.fragment=s?s(d.ctx):!1,e.target){if(e.hydrate){const p=fe(e.target);d.fragment&&d.fragment.l(p),p.forEach(ie)}else d.fragment&&d.fragment.c();e.intro&&we(l.$$.fragment),xe(l,e.target,e.anchor),oe()}L(n)}class Ae{constructor(){H(this,"$$");H(this,"$$set")}$destroy(){ve(this,1),this.$destroy=_}$on(e,t){if(!se(t))return _;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const i=s.indexOf(t);i!==-1&&s.splice(i,1)}}$set(e){this.$$set&&!he(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Re="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Re);class K{constructor(e=-1,t=-1,s=-1,i=-1,o,r,a,n=0,d=0,h=0,p=""){this.rowIndex=e,this.rowTop=t,this.columnIndex=s,this.columnLeft=i,this.areaIdent=o,this.sideIdent=r,this.originalEvent=a,this.clickCount=n,this.draggingX=d,this.draggingY=h,this.action=p}clone(){return new K(this.rowIndex,this.rowTop,this.columnIndex,this.columnLeft,this.areaIdent,this.sideIdent,this.originalEvent,this.clickCount,this.draggingX,this.draggingY,this.action)}}class I{constructor(e=">",t="",s=[]){this.content=e,this.style=t,this.classes=s}}class re{constructor(e=new I(">","transform: rotate(90deg) translate(66%, -66%); transform-origin: 0 0;",["gt-table-tree-arrow-expanded"]),t=new I(">","",["ge-table-tree-arrow-collapsed"]),s=new I(">","color:transparent;",["gt-table-tree-arrow-hidden"]),i=new I("↕","",["gt-table-tree-arrow-expanded-all"])){this.arrowExpanded=e,this.arrowCollapsed=t,this.arrowPlaceholder=s,this.arrowExpandCollapseAll=i}}class le{constructor(e=new I("↑","",["ge-header-sorted-asc"]),t=new I("↓","",["ge-header-sorted-desc"]),s=new I("↑","color:transparent;",[])){this.iconAsc=e,this.iconDesc=t,this.iconPlaceholder=s}}class Me{constructor(e){this.domService=e}setStyle(e,t,s){return this.domService.setStyle(e,t,s),e}applyStyle(e,t){for(const s in t)this.domService.setStyle(e,s,t[s]);return e}applyDisplayNoneStyle(e){return this.domService.setStyle(e,"display","none"),e}applyDisplayBlockStyle(e){return this.domService.setStyle(e,"display","block"),e}applyStyleInPx(e,t){return Object.entries(t).forEach(([s,i])=>this.domService.setStyle(e,s,i+"px")),e}applyStylePosistionRelative(e){return this.domService.setStyle(e,"position","relative"),this.domService.setStyle(e,"overflow","clip"),e}applyStylePosistionAbsolute(e){return this.domService.setStyle(e,"position","absolute"),e}applyStyleFullSize(e){return this.domService.setStyle(e,"width","100%"),this.domService.setStyle(e,"height","100%"),e}applyStyleOverflowAuto(e="auto",t="auto",s){return this.domService.setStyle(s,"overflow-x",e),this.domService.setStyle(s,"overflow-y",t),s}applyStyleNoPadding(e){return this.domService.setStyle(e,"padding","0"),this.domService.setStyle(e,"margin","0"),this.domService.setStyle(e,"border","0"),e}appendRelativeChildDiv(e){const t=this.applyStylePosistionRelative(this.applyStyleFullSize(this.applyStyleNoPadding(this.domService.createElement("div"))));return this.domService.appendChild(e,t),this.applyStylePosistionAbsolute(e),{parent:e,child:t,cache:{}}}appendText(e,t){const s=this.domService.createText(t);return this.domService.appendChild(e,s),s}addClass(e,t){return e.includes(" ")?e.split(" ").forEach(s=>this.domService.addClass(t,s)):this.domService.addClass(t,e),t}addClasses(e,t){if(e)for(const s of e)this.domService.addClass(t,s);return t}setAttribute(e,t,s){return t&&s&&this.domService.setAttribute(e,t,s),e}createAreaDivWithClass(e,t,s,i){const o=this.domService.createElement("div");return this.addClass(e,o),this.domService.setAttribute(o,"data-area",s),this.domService.setAttribute(o,"data-side",i),this.domService.appendChild(t,o),o}createDivWithClass(e,t){const s=this.domService.createElement("div");return this.addClass(e,s),this.domService.appendChild(t,s),s}addRowDiv(e,t,s=-1,i,o,r=""){const a=t.index??-1,n=this.getDivOrCreateDiv(a,e);if(this.domService.addClass(n,"ge-table-row-div"),this.domService.addClass(n,`ge-table-row-div-${t.index}`),i==="body"&&o==="center"){const d=((t==null?void 0:t.index)??0)%2===0?"even":"odd";this.domService.addClass(n,`ge-table-row-${d}`)}if(this.domService.setStyle(n,"display","clip"),this.domService.setStyle(n,"position","absolute"),this.domService.setStyle(n,"left",`${t.left}px`),this.domService.setStyle(n,"top",`${t.top}px`),this.domService.setStyle(n,"width",`${t.width}px`),this.domService.setStyle(n,"height",`${t.height}px`),this.domService.setAttribute(n,"data-row-index",`${s}`),this.domService.setAttribute(n,"data-area",`${i}`),r){const d=this.domService.createText(r);this.domService.appendChild(n,d)}return this.domService.appendChild(e.child,n),n}addColumnDiv(e,t,s=-1,i=-1,o,r,a="",n,d,h=void 0,p){const g=d==null?void 0:d.treeOptions,S=d==null?void 0:d.showCheckboxWihoutExtraColumn,c=this.domService.createElement("div");this.domService.addClass(c,"ge-table-col-div"),this.domService.addClass(c,`ge-table-col-div-${t.index}`),this.domService.setAttribute(c,"data-col-index",`${t.index}`),this.domService.setAttribute(c,"data-row-index",`${s}`),this.domService.setAttribute(c,"data-area",`${o}`);const b=((t==null?void 0:t.index)??0)%2===0?"even":"odd";if(o==="body"&&r==="center"&&this.domService.addClass(c,`ge-table-column-${b}`),this.domService.setStyle(c,"display","clip"),this.domService.setStyle(c,"position","absolute"),this.domService.setStyle(c,"left",`${t.left}px`),this.domService.setStyle(c,"top",`${t.top}px`),this.domService.setStyle(c,"width",`${t.width}px`),this.domService.setStyle(c,"height",`${t.height}px`),n&&n!=="none"&&(this.domService.addClass(c,"ge-table-col-tree"),this.addArrowDiv(c,n,g,s,i,o)),S&&i===0&&h&&this.addCheckboxToDiv(c,h,o,s),a){const u=n!=="none"&&i===0;this.addLabelDiv(c,a,u,s,i,o)}return p&&this.addSortedIcon(c,p,d==null?void 0:d.sortedOptions,i),this.domService.appendChild(e,c),c}addCheckboxToDiv(e,t,s,i){const o=this.domService.createElement("div"),r=t==="full"?"checked":"";return o.innerHTML=`
1
+ "use strict";var ce=Object.defineProperty;var pe=(l,e,t)=>e in l?ce(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t;var k=(l,e,t)=>(pe(l,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("svelte");function F(){}function se(l){return l()}function ee(){return Object.create(null)}function W(l){l.forEach(se)}function oe(l){return typeof l=="function"}function ue(l,e){return l!=l?e==e:l!==e||l&&typeof l=="object"||typeof l=="function"}function Se(l){return Object.keys(l).length===0}function ge(l,e,t){l.insertBefore(e,t||null)}function le(l){l.parentNode&&l.parentNode.removeChild(l)}function fe(l){return document.createElement(l)}function me(l,e,t){t==null?l.removeAttribute(e):l.getAttribute(e)!==t&&l.setAttribute(e,t)}function be(l){return Array.from(l.childNodes)}function L(l,e,t,i){t==null?l.style.removeProperty(e):l.style.setProperty(e,t,i?"important":"")}let X;function _(l){X=l}const $=[],V=[];let O=[];const te=[],ye=Promise.resolve();let G=!1;function ve(){G||(G=!0,ye.then(re))}function N(l){O.push(l)}const P=new Set;let I=0;function re(){if(I!==0)return;const l=X;do{try{for(;I<$.length;){const e=$[I];I++,_(e),xe(e.$$)}}catch(e){throw $.length=0,I=0,e}for(_(null),$.length=0,I=0;V.length;)V.pop()();for(let e=0;e<O.length;e+=1){const t=O[e];P.has(t)||(P.add(t),t())}O.length=0}while($.length);for(;te.length;)te.pop()();G=!1,P.clear(),_(l)}function xe(l){if(l.fragment!==null){l.update(),W(l.before_update);const e=l.dirty;l.dirty=[-1],l.fragment&&l.fragment.p(l.ctx,e),l.after_update.forEach(N)}}function we(l){const e=[],t=[];O.forEach(i=>l.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),O=e}const Ce=new Set;function Ee(l,e){l&&l.i&&(Ce.delete(l),l.i(e))}function Ae(l,e,t){const{fragment:i,after_update:s}=l.$$;i&&i.m(e,t),N(()=>{const o=l.$$.on_mount.map(se).filter(oe);l.$$.on_destroy?l.$$.on_destroy.push(...o):W(o),l.$$.on_mount=[]}),s.forEach(N)}function Me(l,e){const t=l.$$;t.fragment!==null&&(we(t.after_update),W(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Re(l,e){l.$$.dirty[0]===-1&&($.push(l),ve(),l.$$.dirty.fill(0)),l.$$.dirty[e/31|0]|=1<<e%31}function Te(l,e,t,i,s,o,n=null,a=[-1]){const r=X;_(l);const d=l.$$={fragment:null,ctx:[],props:o,update:F,not_equal:s,bound:ee(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(r?r.$$.context:[])),callbacks:ee(),dirty:a,skip_bound:!1,root:e.target||r.$$.root};n&&n(d.root);let h=!1;if(d.ctx=t?t(l,e.props||{},(p,g,...f)=>{const c=f.length?f[0]:g;return d.ctx&&s(d.ctx[p],d.ctx[p]=c)&&(!d.skip_bound&&d.bound[p]&&d.bound[p](c),h&&Re(l,p)),g}):[],d.update(),h=!0,W(d.before_update),d.fragment=i?i(d.ctx):!1,e.target){if(e.hydrate){const p=be(e.target);d.fragment&&d.fragment.l(p),p.forEach(le)}else d.fragment&&d.fragment.c();e.intro&&Ee(l.$$.fragment),Ae(l,e.target,e.anchor),re()}_(r)}class De{constructor(){k(this,"$$");k(this,"$$set")}$destroy(){Me(this,1),this.$destroy=F}$on(e,t){if(!oe(t))return F;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}$set(e){this.$$set&&!Se(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Ie="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Ie);function j(l){return l&&l.type==="TreeRow"}function z(l){return l&&l.type==="AreaModelTree"}class K{constructor(e=-1,t=-1,i=-1,s=-1,o,n,a,r=0,d=0,h=0,p=""){this.rowIndex=e,this.rowTop=t,this.columnIndex=i,this.columnLeft=s,this.areaIdent=o,this.sideIdent=n,this.originalEvent=a,this.clickCount=r,this.draggingX=d,this.draggingY=h,this.action=p}clone(){return new K(this.rowIndex,this.rowTop,this.columnIndex,this.columnLeft,this.areaIdent,this.sideIdent,this.originalEvent,this.clickCount,this.draggingX,this.draggingY,this.action)}}class D{constructor(e=">",t="",i=[]){this.content=e,this.style=t,this.classes=i}}class ne{constructor(e=new D(">","transform: rotate(90deg) translate(66%, -66%); transform-origin: 0 0;",["gt-table-tree-arrow-expanded"]),t=new D(">","",["ge-table-tree-arrow-collapsed"]),i=new D(">","color:transparent;",["gt-table-tree-arrow-hidden"]),s=new D("↕","",["gt-table-tree-arrow-expanded-all"])){this.arrowExpanded=e,this.arrowCollapsed=t,this.arrowPlaceholder=i,this.arrowExpandCollapseAll=s}}class ae{constructor(e=new D("↑","",["ge-header-sorted-asc"]),t=new D("↓","",["ge-header-sorted-desc"]),i=new D("↑","color:transparent;",[])){this.iconAsc=e,this.iconDesc=t,this.iconPlaceholder=i}}class $e{constructor(e){this.domService=e}setStyle(e,t,i){return this.domService.setStyle(e,t,i),e}applyStyle(e,t){for(const i in t)this.domService.setStyle(e,i,t[i]);return e}applyDisplayNoneStyle(e){return this.domService.setStyle(e,"display","none"),e}applyDisplayBlockStyle(e){return this.domService.setStyle(e,"display","block"),e}applyStyleInPx(e,t){return Object.entries(t).forEach(([i,s])=>this.domService.setStyle(e,i,s+"px")),e}applyStylePosistionRelative(e){return this.domService.setStyle(e,"position","relative"),this.domService.setStyle(e,"overflow","clip"),e}applyStylePosistionAbsolute(e){return this.domService.setStyle(e,"position","absolute"),e}applyStyleFullSize(e){return this.domService.setStyle(e,"width","100%"),this.domService.setStyle(e,"height","100%"),e}applyStyleOverflowAuto(e="auto",t="auto",i){return this.domService.setStyle(i,"overflow-x",e),this.domService.setStyle(i,"overflow-y",t),i}applyStyleNoPadding(e){return this.domService.setStyle(e,"padding","0"),this.domService.setStyle(e,"margin","0"),this.domService.setStyle(e,"border","0"),e}appendRelativeChildDiv(e){const t=this.applyStylePosistionRelative(this.applyStyleFullSize(this.applyStyleNoPadding(this.domService.createElement("div"))));return this.domService.appendChild(e,t),this.applyStylePosistionAbsolute(e),{parent:e,child:t,cache:{}}}appendText(e,t){const i=this.domService.createText(t);return this.domService.appendChild(e,i),i}addClass(e,t){return e.includes(" ")?e.split(" ").forEach(i=>this.domService.addClass(t,i)):this.domService.addClass(t,e),t}addClasses(e,t){if(e)for(const i of e)this.domService.addClass(t,i);return t}setAttribute(e,t,i){return t&&i&&this.domService.setAttribute(e,t,i),e}createAreaDivWithClass(e,t,i,s){const o=this.domService.createElement("div");return this.addClass(e,o),this.domService.setAttribute(o,"data-area",i),this.domService.setAttribute(o,"data-side",s),this.domService.appendChild(t,o),o}createDivWithClass(e,t){const i=this.domService.createElement("div");return this.addClass(e,i),this.domService.appendChild(t,i),i}addRowDiv(e,t,i=-1,s,o,n=""){const a=t.index??-1,r=this.getDivOrCreateDiv(a,e);if(this.domService.addClass(r,"ge-table-row-div"),this.domService.addClass(r,`ge-table-row-div-${t.index}`),s==="body"&&o==="center"){const d=((t==null?void 0:t.index)??0)%2===0?"even":"odd";this.domService.addClass(r,`ge-table-row-${d}`)}if(this.domService.setStyle(r,"display","clip"),this.domService.setStyle(r,"position","absolute"),this.domService.setStyle(r,"left",`${t.left}px`),this.domService.setStyle(r,"top",`${t.top}px`),this.domService.setStyle(r,"width",`${t.width}px`),this.domService.setStyle(r,"height",`${t.height}px`),this.domService.setAttribute(r,"data-row-index",`${i}`),this.domService.setAttribute(r,"data-area",`${s}`),n){const d=this.domService.createText(n);this.domService.appendChild(r,d)}return this.domService.appendChild(e.child,r),r}addColumnDiv(e,t,i=-1,s=-1,o,n,a="",r,d,h=void 0,p){const g=d==null?void 0:d.treeOptions,f=d==null?void 0:d.showCheckboxWihoutExtraColumn,c=this.domService.createElement("div");this.domService.addClass(c,"ge-table-col-div"),this.domService.addClass(c,`ge-table-col-div-${t.index}`),this.domService.setAttribute(c,"data-col-index",`${t.index}`),this.domService.setAttribute(c,"data-row-index",`${i}`),this.domService.setAttribute(c,"data-area",`${o}`);const b=((t==null?void 0:t.index)??0)%2===0?"even":"odd";if(o==="body"&&n==="center"&&this.domService.addClass(c,`ge-table-column-${b}`),this.domService.setStyle(c,"display","clip"),this.domService.setStyle(c,"position","absolute"),this.domService.setStyle(c,"left",`${t.left}px`),this.domService.setStyle(c,"top",`${t.top}px`),this.domService.setStyle(c,"width",`${t.width}px`),this.domService.setStyle(c,"height",`${t.height}px`),r&&r!=="none"&&(this.domService.addClass(c,"ge-table-col-tree"),this.addArrowDiv(c,r,g,i,s,o)),f&&s===0&&h&&this.addCheckboxToDiv(c,h,o,i),a){const u=r!=="none"&&s===0;this.addLabelDiv(c,a,u,i,s,o)}return p&&this.addSortedIcon(c,p,d==null?void 0:d.sortedOptions,s),this.domService.appendChild(e,c),c}addCheckboxToDiv(e,t,i,s){const o=this.domService.createElement("div"),n=t==="full"?"checked":"";return o.innerHTML=`
2
2
  <input
3
3
  type="checkbox"
4
- data-area="${s}"
5
- data-row-index="${i}"
4
+ data-area="${i}"
5
+ data-row-index="${s}"
6
6
  data-input-type="checkbox"
7
- ${r}
8
- class="ge-table-row-checkbox"> `,this.domService.setStyle(o,"display","inline"),this.domService.setStyle(o,"width","inherit"),this.domService.setAttribute(o,"data-row-index",`${i}`),this.domService.appendChild(e,o),o}addLabelDiv(e,t="",s=!1,i=-1,o=-1,r="body"){const a=this.domService.createElement("div");if(this.domService.addClass(a,"ge-table-label-div"),this.domService.setStyle(a,"position","relative"),this.domService.setStyle(a,"background","transparent"),this.domService.setStyle(a,"width","100%"),this.domService.setStyle(a,"height","100%"),this.domService.setAttribute(a,"data-row-index",`${i}`),this.domService.setAttribute(a,"data-col-index",`${o}`),this.domService.setAttribute(a,"data-area",`${r}`),t)if(s){const n=this.domService.createText(t);this.domService.appendChild(a,n)}else{const n=this.domService.createElement("div");this.domService.appendChild(a,n);const d=this.domService.createText(t);this.domService.addClass(n,"ge-table-label"),this.domService.appendChild(n,d),this.domService.setAttribute(n,"data-row-index",`${i}`),this.domService.setAttribute(n,"data-col-index",`${o}`),this.domService.setAttribute(n,"data-area",`${r}`)}return this.domService.appendChild(e,a),a}addSortedIcon(e,t="",s=new le,i=-1){const o=this.domService.createElement("div");this.domService.addClass(o,"ge-table-sorted-icon-div"),this.domService.setStyle(o,"position","absolute"),this.domService.setStyle(o,"top","0"),this.domService.setStyle(o,"right","0"),this.domService.setStyle(o,"width","20px"),this.domService.setStyle(o,"background","transparent"),this.domService.setStyle(o,"cursor","pointer"),this.domService.setAttribute(o,"data-col-index",`${i}`),this.domService.setAttribute(o,"data-area","header");let r;t==="asc"?r=s.iconAsc:t==="desc"?r=s.iconDesc:r=s.iconPlaceholder;const a=r.content,n=this.domService.createText(a);this.domService.appendChild(o,n),r.style&&this.applyStyleString(o,r.style);for(const d of r.classes)this.domService.addClass(o,d);return this.domService.appendChild(e,o),o}addArrowDiv(e,t="none",s=new re,i=-1,o=-1,r="body"){const a=this.domService.createElement("div");this.domService.addClass(a,"ge-table-tree-arrow-div"),this.domService.setStyle(a,"display","inline-block"),this.domService.setStyle(a,"position",""),this.domService.setStyle(a,"width","20px"),this.domService.setStyle(a,"background","transparent"),this.domService.setStyle(a,"cursor","pointer"),this.domService.setAttribute(a,"data-row-index",`${i}`),this.domService.setAttribute(a,"data-col-index",`${o}`),this.domService.setAttribute(a,"data-area",`${r}`);let n;t==="expanded"?n=s.arrowExpanded:t==="collapsed"?n=s.arrowCollapsed:n=s.arrowPlaceholder;const d=n.content,h=this.domService.createText(d);this.domService.appendChild(a,h),n.style&&this.applyStyleString(a,n.style);for(const p of n.classes)this.domService.addClass(a,p);return this.domService.appendChild(e,a),a}addColumnBorderDivs(e,t,s,i,o){if(e.verticalBorderVisible){const r=`ge-table-${i}-${o}-vertical-border`;this.addVerticalBorder(s,t,r)}if(e.horizontalBorderVisible){const r=`ge-table-${i}-${o}-horizontal-border`;this.addHorizontalBorder(s,t,r)}return t}addHorizontalBorder(e,t,s="ge-table-body-center-horizontal-border"){const i=this.domService.createElement("div");return this.domService.addClass(i,s),this.domService.setStyle(i,"display","clip"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"left",`${e.left}px`),this.domService.setStyle(i,"top",`${e.top}px`),this.domService.setStyle(i,"width",`${e.width}px`),this.domService.setStyle(i,"height","1px"),this.domService.appendChild(t,i),i}addFocusBorderDivs(e,t,s){let i=this.domService.createElement("div");return this.domService.addClass(i,"ge-table-focus-border"),this.domService.setStyle(i,"display","clip"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"left",`${t.left}px`),this.domService.setStyle(i,"top",`${t.top}px`),this.domService.setStyle(i,"width","1px"),this.domService.setStyle(i,"height",`${t.height}px`),this.applyStyle(i,s),this.domService.appendChild(e,i),i=this.domService.createElement("div"),this.domService.addClass(i,"ge-table-focus-border"),this.domService.setStyle(i,"display","clip"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"left",`${t.left+t.width-1}px`),this.domService.setStyle(i,"top",`${t.top}px`),this.domService.setStyle(i,"width","1px"),this.domService.setStyle(i,"height",`${t.height}px`),this.applyStyle(i,s),this.domService.appendChild(e,i),i=this.domService.createElement("div"),this.domService.addClass(i,"ge-table-focus-border"),this.domService.setStyle(i,"display","clip"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"left",`${t.left}px`),this.domService.setStyle(i,"top",`${t.top}px`),this.domService.setStyle(i,"width",`${t.width}px`),this.domService.setStyle(i,"height","1px"),this.applyStyle(i,s),this.domService.appendChild(e,i),i=this.domService.createElement("div"),this.domService.addClass(i,"ge-table-focus-border"),this.domService.setStyle(i,"display","clip"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"left",`${t.left}px`),this.domService.setStyle(i,"top",`${t.top+t.height-1}px`),this.domService.setStyle(i,"width",`${t.width}px`),this.domService.setStyle(i,"height","1px"),this.applyStyle(i,s),this.domService.appendChild(e,i),e}addVerticalBorder(e,t,s="ge-table-body-center-vertical-border"){const i=this.domService.createElement("div");return this.domService.addClass(i,s),this.domService.setStyle(i,"display","clip"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"left",`${e.left}px`),this.domService.setStyle(i,"top",`${e.top}px`),this.domService.setStyle(i,"width","1px"),this.domService.setStyle(i,"height",`${e.height}px`),this.domService.appendChild(t,i),i}addDiv(e,t,s=""){const i=this.domService.createElement("div");return s&&this.domService.addClass(i,s),this.domService.setStyle(i,"display","clip"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"left",`${t.left}px`),this.domService.setStyle(i,"top",`${t.top}px`),this.domService.setStyle(i,"width",`${t.width}px`),this.domService.setStyle(i,"height",`${t.height}px`),this.domService.appendChild(e,i),i}applyStyleString(e,t){const s=t.split(";").map(i=>i.trim()).filter(i=>i);for(const i of s){const[o,r]=i.split(":");this.domService.setStyle(e,o.trim(),r.trim())}}getDivOrCreateDiv(e,t){let s=t.cache[e];return s?(s.innerText="",s):(s=this.domService.createElement("div"),t.cache[e]=s,s)}}class j{constructor(e,t=!0,s,i,o=0,r=!1,a=!1){this.data=e,this.expanded=t,this.children=s,this.parent=i,this.deep=o,this.checked=r,this.keep=a}}const Y=l=>l==="header"?"header":l==="footer"?"footer":"body";class Te{constructor(e,t){if(this.rowIdx=-1,this.colIdx=-1,this.action=null,this.inputType=null,this.className="",e!==null&&(e instanceof HTMLDivElement||e instanceof HTMLSpanElement||e instanceof HTMLInputElement)){this.className=e.className,this.action=e.getAttribute("data-ge-action"),this.inputType=e.getAttribute("data-input-type"),this.rowIdx=Number(e.getAttribute("data-row-index")),this.colIdx=Number(e.getAttribute("data-col-index"));const s=e.getAttribute("data-area");if(s&&(this.areaIdent=Y(s),this.areaModel=t.tableModel.getAreaModel(this.areaIdent),this.row=this.areaModel.getRowByIndex(this.rowIdx)),e instanceof HTMLInputElement){const i=e;this.value=i.value}}}}class Ie{constructor(e){this.tableScope=e,this.expandedAll=!0,this.mouseDown=!1,this.dragging=!1,this.tableScope.hostElement.addEventListener("click",this.onHostElementClicked.bind(this)),this.tableScope.hostElement.addEventListener("dblclick",this.onHostElementDblClicked.bind(this)),this.tableScope.hostElement.addEventListener("mousedown",this.onMouseDown.bind(this)),this.tableScope.hostElement.addEventListener("mousemove",this.onMouseMove.bind(this)),this.tableScope.hostElement.addEventListener("mouseup",this.onMouseUp.bind(this)),this.tableScope.hostElement.addEventListener("contextmenu",this.onContextmenu.bind(this)),this.tableScope.hostElement._MouseHandler="true",this.tableScope.scrollViewport.addEventListener("scroll",this.tableScope.adjustAfterScrolling.bind(this.tableScope)),[window,this.tableScope.hostElement].forEach(t=>t.addEventListener("resize",this.tableScope.adjustContainersAndRows.bind(this.tableScope)))}onContextmenu(e){this.mouseEvent=e;const t=this.tableScope.createGeMouseEvent(this.mouseEvent);this.tableScope.contextmenu(t)}onHostElementClicked(e){const t=new Te(e.target,this.tableScope);if(t.action==="toggleExpandCollapseAll")this.expandedAll=!this.expandedAll,this.tableScope.toggleExpandCollapseAll(this.expandedAll),e.preventDefault(),e.stopPropagation();else if(t.inputType==="checkbox"&&t.areaIdent)this.tableScope.toggleRowCheckbox(t.rowIdx,t.colIdx,t.areaIdent),e.preventDefault(),e.stopPropagation();else if(t.row instanceof j&&t.areaModel){const s=t.colIdx===this.getArrowColumnIndex()&&e.altKey,i=t.className.includes("ge-table-tree-arrow-div");if(console.info(i,s),s||i){e.preventDefault(),e.stopPropagation();const o=t.row;o.expanded=!o.expanded,"recalcVisibleTreeRows"in t.areaModel&&t.areaModel.recalcVisibleTreeRows(),this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth),this.tableScope.adjustContainersAndRows(),this.updateCollapsedExpandedState(o)}}if(t.areaIdent==="body"&&this.tableScope.tableOptions.getFocusModel){const s=this.tableScope.tableOptions.getFocusModel();s==null||s.clear(),s==null||s.setFocus(t.rowIdx,t.colIdx)}this.publishGeMouseEvent(e,1)}onHostElementDblClicked(e){if(e.target instanceof HTMLElement){const t=e.target,s=t.getAttribute("data-area"),i=Y(s),o=Number(t.getAttribute("data-row-index")),r=Number(t.getAttribute("data-col-index")),a=this.tableScope.tableModel.getAreaModel(i);if(s&&i==="header")this.tableScope.tableModel.isSortable(r)&&(this.tableScope.clearSelection(),this.tableScope.onHeaderDblClicked(e,o,r));else if(t.getAttribute("data-row-index")){const n=a.getRowByIndex(o);if(s&&i==="body"&&a.isEditable(o,r)&&(this.tableScope.clearSelection(),this.tableScope.initRenderEditor(o,r)),n instanceof j&&r===this.getArrowColumnIndex()){e.preventDefault(),e.stopPropagation();const d=n;d.expanded=!d.expanded,"recalcVisibleTreeRows"in a&&a.recalcVisibleTreeRows(),this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth),this.tableScope.adjustContainersAndRows(),this.updateCollapsedExpandedState(d)}}}this.publishGeMouseEvent(e,2)}publishGeMouseEvent(e,t){var s;this.mouseEvent=e,this.geMouseEventOld=(s=this.geMouseEvent)==null?void 0:s.clone(),this.geMouseEvent=this.tableScope.createGeMouseEvent(e),this.geMouseEvent&&(this.geMouseEvent.clickCount=t),this.tableScope.onMouseClicked(this.geMouseEvent,this.geMouseEventOld)}updateCollapsedExpandedState(e){var s,i,o,r,a;const t=(i=(s=this.tableScope.tableOptions)==null?void 0:s.autoRestoreOptions)==null?void 0:i.getRowId;if(t){const n=(o=this.tableScope.storeStateCollapsedExpandService)==null?void 0:o.collapsedExpandedStateGet().mode,d=n==="collapsed"&&!e.expanded||n==="expanded"&&e.expanded,h=n==="collapsed"&&e.expanded||n==="expanded"&&!e.expanded,p=t(e.data);d?(r=this.tableScope.storeStateCollapsedExpandService)==null||r.collapsedStateIdsPush(p):h&&((a=this.tableScope.storeStateCollapsedExpandService)==null||a.collapsedStateIdsRemove(p))}}getArrowColumnIndex(){return this.tableScope.tableModel.isRowCheckboxVisible()?1:0}onMouseDown(e){this.mouseEvent=e,this.startMouseEvent=this.tableScope.createGeMouseEvent(this.mouseEvent),this.tableScope.onMouseDown(this.startMouseEvent),this.mouseDown=!0}onMouseMove(e){this.mouseEvent=e,this.mouseDown?(this.dragging=!0,requestAnimationFrame(this.mouseDraggingOnFrame.bind(this))):requestAnimationFrame(this.mouseMoveOnFrame.bind(this))}onMouseUp(e){this.mouseEvent=e,this.dragging&&requestAnimationFrame(this.mouseDraggingEndOnFrame.bind(this)),this.mouseDown=!1,this.dragging=!1}mouseDraggingOnFrame(){var e;if(this.mouseEvent){const t=this.tableScope.createGeMouseEvent(this.mouseEvent);(e=this.startMouseEvent)!=null&&e.originalEvent&&(t.draggingX=this.mouseEvent.clientX-this.startMouseEvent.originalEvent.clientX,t.draggingY=this.mouseEvent.clientY-this.startMouseEvent.originalEvent.clientY),this.tableScope.mouseDraggingOnFrame(t)}}mouseDraggingEndOnFrame(){var e;if(this.mouseEvent){const t=this.tableScope.createGeMouseEvent(this.mouseEvent);(e=this.startMouseEvent)!=null&&e.originalEvent&&(t.draggingX=this.mouseEvent.clientX-this.startMouseEvent.originalEvent.clientX,t.draggingY=this.mouseEvent.clientY-this.startMouseEvent.originalEvent.clientY),this.tableScope.mouseDraggingEndOnFrame(t)}}mouseMoveOnFrame(){if(this.mouseEvent){const e=this.tableScope.createGeMouseEvent(this.mouseEvent);this.tableScope.mouseMove(e)}}}class De{constructor(e){this.tableScope=e}updateCells(e){this.tableScope.updateCells(e)}externalFilterChanged(){this.tableScope.externalFilterChanged()}scrollToPixel(e=0,t=0){}scrollToIndex(e=0,t=0){}setHeaderVisible(e=!0){}setColumnVisible(e,t=!0){}isColumnVisible(e){return!0}isHeaderVisible(){return!0}setFooterVisible(e=!0){}isFooterVisible(){return!0}repaint(){this.tableScope.repaint()}}class Fe{flattenTree(e,t=[]){var s;for(const i of e)this.isVisible(i)&&t.push(i),(s=i.children)!=null&&s.length&&this.flattenTree(i.children,t);return t}isVisible(e){return e.parent?e.parent.expanded?this.isVisible(e.parent):!1:!0}}class _e{constructor(e,t=[],s=-1){this.areaIdent=e,this.columnDefs=t,this.defaultRowHeight=s,this.rowSelectionModel=void 0,this.yPositions=[],this.cellRenderers=t.map(i=>i.rendererMap[e])}getTooltipAt(e,t){return""}getCellRenderer(e,t){if(t<this.cellRenderers.length)return this.cellRenderers[t]}getColspanAt(e,t){return 0}getCustomClassesAt(e,t){return[]}getCustomStyleAt(e,t){}getRowspanAt(e,t){return 0}getRowByIndex(e){}isRowCheckable(e){return!0}isRowChecked(e){var s;const t=this.getRowByIndex(e);return(s=this.rowSelectionModel)==null?void 0:s.isRowChecked(t)}setRowChecked(e,t){if(this.rowSelectionModel){const s=this.getRowByIndex(e);this.rowSelectionModel.checkRow(s,t)}}getMaxColspan(){return 31}getMaxRowspan(){return 31}getYPosByRowIndex(e){return this.defaultRowHeight>0?this.defaultRowHeight*e:this.yPositions[e]}init(){!this.yPositions.length&&this.getRowCount()!==void 0&&this.defaultRowHeight===-1&&this.calcYPositions()}isFilterable(){return this.areaIdent==="body"}doSort(e){return!1}isEditable(e,t){return this.columnDefs&&t<this.columnDefs.length&&this.columnDefs[t].editable?this.columnDefs[t].editable():!1}setValue(e,t,s){var a;const i=(a=this.columnDefs[t])==null?void 0:a.editInputPipe;i&&(s=i(s,e,t));const o=this.getRowByIndex(e),r=this.columnDefs[t].property;return r.includes(".")?this.setPropertyValue(o,r.split("."),s):(o[r]=s,!0)}isSelectable(e,t){return!0}changeColumnOrder(e,t){this.arrayMove(this.cellRenderers,e,t)}setPropertyValue(e,t,s){const i=t.shift();if(i){let o=e[i];return o&&t.length?this.setPropertyValue(o,t,s):(e[i]=s,!0)}return!1}arrayMove(e,t,s){const i=e.splice(t,1)[0];return e.splice(s,0,i),e}calcYPositions(){const e=this.getRowCount();this.yPositions=new Array(e+1),this.yPositions[0]=0;for(let t=0;t<e;t++)this.yPositions[t+1]=this.getRowHeight(t)+this.yPositions[t]}}class Oe{genericSortComparator(e,t,s){if(typeof e=="number"&&typeof t=="number")return s*(e-t);if(typeof e=="string"&&typeof t=="string")return s*e.localeCompare(t);if(typeof e=="boolean"&&typeof t=="boolean")return s*((e?-1:1)-(t?-1:1));if(e instanceof Date&&t instanceof Date)return s*(e.getTime()-t.getTime());if(e instanceof Array&&t instanceof Array){const i=e,o=t;if(i.length&&o.length)return this.genericSortComparator(i[0],o[0],s)}return s*(""+e).localeCompare(""+t)}}class z extends _e{constructor(e,t,s,i=[]){super(e,i,s),this.areaIdent=e,this.rows=t,this.defaultRowHeight=s,this.columnDefs=i,this.sorterService=new Oe,this.service=new Fe,this.properties=i.map(o=>o.property),this.flattenRows=this.service.flattenTree(t),this.filteredFlattenRows=[...this.flattenRows]}changeColumnOrder(e,t){this.arrayMove(this.properties,e,t),super.changeColumnOrder(e,t)}recalcVisibleTreeRows(){this.filteredFlattenRows=this.service.flattenTree(this.rows)}getFilteredFlattenRows(){return this.filteredFlattenRows}getRowCount(){let e=0;for(const t of this.filteredFlattenRows)this.service.isVisible(t)&&e++;return e}getValueAt(e,t){const s=this.getRowByIndex(e);if(s){const i=this.properties[t];if(i)return i.includes(".")?this.getPropertyValue(s.data,i.split(".")):s.data[i]}return""}getRowHeight(e){return this.defaultRowHeight}getCustomClassesAt(e,t){return["ge-table-tree-cell","ge-table-tree-deep-"+this.filteredFlattenRows[e].deep]}getRowByIndex(e){return this.filteredFlattenRows[e]}getValueByT(e,t){return t.includes(".")?this.getPropertyValue(e,t.split(".")):e[t]}externalFilterChanged(e){this.lastPredictFn=e,this.doFiltering()}doSort(e){const{columnIndex:t,sortState:s}=e[e.length-1],i=s==="asc"?1:s==="desc"?-1:0,o=this.properties[t];return this.treeSort(this.rows,o,i),this.flattenRows=this.service.flattenTree(this.rows),this.filteredFlattenRows=[...this.flattenRows],!0}toggleExpandCollapseAll(e){this.expandAllRecursive(this.rows,e),this.flattenRows=this.service.flattenTree(this.rows),this.doFiltering()}setAllParentsOk(e){return e.parent&&(e.parent.keep=!0,this.setAllParentsOk(e.parent)),!1}setValue(e,t,s){var r;const i=(r=this.columnDefs[t])==null?void 0:r.editInputPipe;i&&(s=i(s,e,t));const o=this.getRowByIndex(e);if(o){const a=o.data,n=this.columnDefs[t].property;return n.includes(".")?this.setPropertyValue(a,n.split("."),s):(a[n]=s,!0)}return!1}genericTreeTableSortComparator(e,t){return(s,i)=>{const o=this.getValueByT(s.data,e),r=this.getValueByT(i.data,e);return this.sorterService.genericSortComparator(o,r,t)}}expandAllRecursive(e,t){for(const s of e)s.expanded=t,s.children&&this.expandAllRecursive(s.children,t)}doFiltering(){if(!this.lastPredictFn)this.filteredFlattenRows=[...this.flattenRows?this.flattenRows:[]];else{this.flattenRows||(this.flattenRows=[]);let e=0;this.flattenRows.forEach(s=>{e=Math.max(e,s.deep)});const t=this.flattenRows.filter((s,i,o)=>this.lastPredictFn(s,i,o));this.flattenRows.forEach(s=>s.keep=!1),this.flattenRows.forEach(s=>{t.includes(s)&&(s.keep=!0,this.setAllParentsOk(s))}),this.filteredFlattenRows=this.flattenRows.filter((s,i,o)=>s.keep)}}getPropertyValue(e,t){const s=t.shift();let i=e[s];return i&&t.length?this.getPropertyValue(i,t):i}treeSort(e,t,s){e.sort(this.genericTreeTableSortComparator(t,s));for(const i of e)i.children&&this.treeSort(i.children,t,s)}}class q{constructor(e){this.getStorageKeyFn=e}autoConvertMapToObject(e){const t={};if(e instanceof Map){const s=e;for(const i of[...s]){const[o,r]=i;t[o]=r}}return t}checkAndPersistItem(e,t){const s=this.getStorageKeyFn;if(s){const i=s();if(i){const o=i+e;if((t+"").includes("Map")){const r=this.autoConvertMapToObject(t);this.persistItem(o,r)}else this.persistItem(o,t)}}}persistItem(e,t){t?localStorage.setItem(e,JSON.stringify(t)):localStorage.removeItem(e)}loadFromLocalStorage(e){const t=localStorage.getItem(e);return t?JSON.parse(t):null}}class $e extends q{constructor(e){super(e),this.SCROLL_STATE="scrollState",this.scrollOffset=[0,0],this.load()}getScrollOffset(){return this.scrollOffset}updateScrollOffset(e){this.scrollOffset=e,this.checkAndPersistItem(this.SCROLL_STATE,this.scrollOffset)}load(){const e=this.getStorageKeyFn;if(e){const t=e();if(t){const s=t+this.SCROLL_STATE;let i=this.loadFromLocalStorage(s);this.scrollOffset=i||[0,0]}}}}class Le{constructor(e="collapsed",t=[],s=!1,i=!1){this.mode=e,this.rowIds=t,this.allCollapsed=s,this.allExpanded=i}}class Be extends q{constructor(e){super(e),this.COLLAPSED_EXPANDED_STATE="collapsedExpandedState",this.collapsedExpandedState=new Le,this.load()}collapsedExpandedStateGet(){return this.collapsedExpandedState}collapsedExpandedStateIncludes(e){return this.collapsedExpandedState.rowIds.includes(e)}collapsedStateIdsPush(e){this.collapsedExpandedState.rowIds.includes(e)||(this.collapsedExpandedState.rowIds.push(e),this.collapsedExpandedState.allCollapsed=!1,this.collapsedExpandedState.allExpanded=!1,this.persist())}collapsedStateIdsRemove(e){const t=this.collapsedExpandedState.rowIds.indexOf(e);t!==-1&&(this.collapsedExpandedState.rowIds.splice(t,1),this.collapsedExpandedState.allCollapsed=!1,this.collapsedExpandedState.allExpanded=!1,this.persist())}collapsedStateAll(e){this.collapsedExpandedState.rowIds=[],this.collapsedExpandedState.mode=e?"collapsed":"expanded",this.collapsedExpandedState.allCollapsed=!e,this.collapsedExpandedState.allExpanded=e,this.persist()}load(){const e=this.getStorageKeyFn;if(e){const t=e();if(t){const s=t+this.COLLAPSED_EXPANDED_STATE,i=this.loadFromLocalStorage(s);i&&(this.collapsedExpandedState=i)}}}persist(){this.checkAndPersistItem(this.COLLAPSED_EXPANDED_STATE,this.collapsedExpandedState)}}class Pe extends q{constructor(e){super(e),this.SORTING_STATE="sortingState",this.sortItems=[],this.load()}getSortItems(){return this.sortItems}setSortItems(e){this.sortItems=e,this.checkAndPersistItem(this.SORTING_STATE,this.sortItems)}load(){const e=this.getStorageKeyFn;if(e){const t=e();if(t){const s=t+this.SORTING_STATE;let i=this.loadFromLocalStorage(s);this.sortItems=i||[]}}}}class T{constructor(e=0,t=0,s=0,i=0,o){this.left=e,this.width=t,this.height=s,this.top=i,this.index=o}}class ke{constructor(e,t,s,i){this.hostElement=e,this.tableModel=t,this.dom=s,this.tableOptions=i,this.scrollTop=0,this.areaBodyWestGeo=new T,this.areaBodyCenterGeo=new T,this.areaBodyEastGeo=new T;const o=this.hostElement;o.innerText="",this.dom.setAttribute(o,"tabindex","0"),this.dom.setStyle(this.dom.addClass("ge-table",o),"position","relative"),this.hoverRow=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-hover-row",o)),this.hoverColumn=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-hover-column",o)),this.areaHeaderWest=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-header ge-table-header-west",o,"header","west"))),this.areaHeaderCenter=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-header ge-table-header-center",o,"header","center"))),this.areaHeaderEast=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-header ge-table-header-east",o,"body","east"))),this.areaBodyWest=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-body ge-table-body-west",o,"body","west"))),this.areaBodyEast=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-body ge-table-body-east",o,"body","east"))),this.areaFooterWest=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-footer ge-table-footer-west",o,"footer","west"))),this.areaFooterCenter=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-footer ge-table-footer-center",o,"footer","center"))),this.areaFooterEast=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-footer ge-table-footer-east",o,"footer","east"))),this.scrollViewport=s.applyStyleOverflowAuto(this.tableOptions.overflowX??"auto",this.tableOptions.overflowY??"auto",s.applyStyleNoPadding(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-scroll-viewport",o,"body","center")))),this.contentWrapperDiv=s.applyStyleNoPadding(s.applyStylePosistionRelative(s.createDivWithClass("ge-table-scroll-content-wrapper",this.scrollViewport))),this.contentDiv=s.applyStyleNoPadding(s.applyStylePosistionRelative(s.createDivWithClass("ge-table-scroll-content",this.contentWrapperDiv))),this.areaBodyCenter=s.appendRelativeChildDiv(s.createDivWithClass("ge-table-body-center",this.contentDiv)),this.borderHeaderBottom=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-header-border",o)),this.borderFixedWest=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-west-fixed-column-border",o)),this.borderFixedEast=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-east-fixed-column-border",o)),this.borderFooterTop=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-footer-border",o))}adjustContainersAndRows(){const e=this.tableModel.getPadding(),t=this.hostElement.clientWidth,s=this.hostElement.clientHeight;this.dom.applyStyle(this.scrollViewport,{width:`${t-e.left}px`,height:`${s-e.top}px`,top:`${e.top}px`,left:`${e.left}px`}),this.scrollTop=this.scrollViewport.scrollTop,this.dom.applyStyle(this.contentDiv,{width:`${this.scrollViewport.clientWidth}px`,height:`${this.scrollViewport.clientHeight}px`,top:`${this.scrollTop}px`,left:`${this.scrollViewport.scrollLeft}px`}),this.areaBodyWestGeo.width=e.left,this.areaBodyWestGeo.height=s-e.top-e.bottom,this.areaBodyWestGeo.top=e.top,this.areaBodyWestGeo.left=0,this.dom.applyStyleInPx(this.areaBodyWest.parent,this.areaBodyWestGeo),this.tableOptions.fixedWestSeparatorBorderVisible&&this.tableModel.getFixedLeftColumnCount()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFixedWest,{width:"1px",height:`${this.areaBodyWestGeo.height}px`,top:`${this.areaBodyWestGeo.top}px`,left:`${this.areaBodyWestGeo.width}px`})):this.dom.applyDisplayNoneStyle(this.borderFixedWest),this.areaBodyEastGeo.width=e.right,this.areaBodyEastGeo.height=s-e.top-e.bottom,this.areaBodyEastGeo.top=e.top,this.areaBodyEastGeo.left=t-e.right,this.dom.applyStyleInPx(this.areaBodyEast.parent,this.areaBodyEastGeo),this.tableOptions.fixedEastSeparatorBorderVisible&&this.tableModel.getFixedLeftColumnCount()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFixedEast,{width:"1px",height:`${this.areaBodyEastGeo.height}px`,top:`${this.areaBodyEastGeo.top}px`,left:`${this.areaBodyEastGeo.left}px`})):this.dom.applyDisplayNoneStyle(this.borderFixedEast),this.areaBodyCenterGeo.width=t-e.left-e.right,this.areaBodyCenterGeo.height=s-e.top-e.bottom,this.areaBodyCenterGeo.top=0,this.areaBodyCenterGeo.left=0,this.dom.applyStyleInPx(this.areaBodyCenter.parent,this.areaBodyCenterGeo),this.dom.applyStyle(this.areaHeaderCenter.parent,{width:`${t-e.left-e.right}px`,height:`${e.top}px`,top:"0",left:`${e.left}px`}),this.dom.applyStyle(this.areaHeaderWest.parent,{width:`${e.left}px`,height:`${e.top}px`,top:"0",left:"0"}),this.dom.applyStyle(this.areaHeaderEast.parent,{width:`${e.right}px`,height:`${e.top}px`,top:"0",left:`${t-e.right}px`}),this.tableOptions.headerSeparatorBorderVisible&&this.tableModel.isHeaderVisibe()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderHeaderBottom,{width:`${t}px`,height:"1px",top:`${e.top}px`,left:"0px"})):this.dom.applyDisplayNoneStyle(this.borderHeaderBottom),this.dom.applyStyle(this.areaFooterWest.parent,{width:`${e.left}px`,height:`${e.bottom}px`,top:`${s-e.bottom}px`,left:"0"}),this.dom.applyStyle(this.areaFooterCenter.parent,{width:`${t-e.left-e.right}px`,height:`${e.bottom}px`,top:`${s-e.bottom}px`,left:`${e.left}px`}),this.dom.applyStyle(this.areaFooterEast.parent,{width:`${e.right}px`,height:`${e.bottom}px`,top:`${s-e.bottom}px`,left:`${t-e.right}px`}),this.tableOptions.footerSeparatorBorderVisible&&this.tableModel.isFooterVisibe()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFooterTop,{width:`${t}px`,height:"1px",top:`${s-e.bottom}px`,left:"0px"})):this.dom.applyDisplayNoneStyle(this.borderFooterTop),this.adjustAfterScrolling()}adjustAfterScrolling(){}resetSizeOfWrapperDiv(){const e=`${this.tableModel.getContentWidthInPixel()}px`,t=`${this.tableModel.getContentHeightInPixel()+1}px`;this.dom.setStyle(this.contentWrapperDiv,"width",e),this.dom.setStyle(this.contentWrapperDiv,"height",t)}}class A{constructor(e,t,s,i,o=!1){this.r1=e,this.c1=t,this.r2=s,this.c2=i,this.gammaRange=o}static create(e){return e.gammaRange===void 0&&(e.gammaRange=!1),new A(e.rowIndex1,e.columnIndex1,e.rowIndex2,e.columnIndex2,e.gammaRange)}static singleCell(e,t){return new A(e,t,e,t)}static singleRow(e){return new A(e,0,e,Number.MAX_SAFE_INTEGER)}static singleColumn(e){return new A(0,e,Number.MAX_SAFE_INTEGER,e)}isInRange(e,t){return e>=this.r1&&e<=this.r2&&t>=this.c1&&t<=this.c2}}class He{constructor(e,t){this.tableModel=e,this.areaModel=t,this.colAndRowspanRanges=void 0}init(){if(this.areaModel.getMaxColspan()<2&&this.areaModel.getMaxRowspan()<2)return;this.colAndRowspanRanges=[];const e=this.areaModel.getRowCount(),t=this.tableModel.getColumnCount();for(let s=0;s<e;s++)for(let i=0;i<t;i++){let o=this.areaModel.getColspanAt(s,i),r=this.areaModel.getRowspanAt(s,i);if(o>1||r>1){o===0&&(o=1),r===0&&(r=1);const a=this.areaModel.hasOwnProperty("gammaCells");this.colAndRowspanRanges.push(new A(s,i,s+r-1,i+o-1,a))}}}getRanges(){return this.colAndRowspanRanges?this.colAndRowspanRanges:[]}isInRange(e,t){if(this.colAndRowspanRanges){for(const s of this.colAndRowspanRanges)if(s.isInRange(e,t))return!0}return!1}}class Ve{constructor(e,t,s){this.header=e,this.body=t,this.footer=s}}class We extends ke{constructor(e,t,s,i){var r,a;super(e,t,s,i),this.scrollLeft=0,this.scrollViewportLeft=0,this.scrollFactorY=0,this.scrollFactorX=0,this.cleanupFunctions={header:[],body:[],footer:[]},this.tree=!1,this.colAndRowspanModels=new Ve,this.firstVisibleRowIndex=-1,this.draggingTargetColumnIndex=-1,this.removables=[],this.editing=!1,this.tableModel.getSelectionModel?this.getSelectionModel=this.tableModel.getSelectionModel:(r=this.tableOptions)!=null&&r.getSelectionModel&&(this.getSelectionModel=this.tableOptions.getSelectionModel),(a=this.tableOptions)!=null&&a.getFocusModel&&(this.getFocusModel=this.tableOptions.getFocusModel),t.getAreaModel("body")instanceof z&&(this.tree=!0),["header","body","footer"].forEach(n=>{var d;this.colAndRowspanModels[n]=new He(t,t.getAreaModel(n)),(d=this.colAndRowspanModels[n])==null||d.init()})}isEditing(){return this.editing}resetEditorRenderer(){this.editorRenderer=void 0,this.editorRendererRow=-1,this.editorRendererColumn=-1,this.editing=!1}clearSelection(){if(this.getSelectionModel){const e=this.getSelectionModel();e==null||e.clear()}}initRenderEditor(e,t){var i;let s=(i=this.tableModel.getColumnDef(t))==null?void 0:i.getEditRenderer;if(s||(s=this.tableOptions.getEditRenderer),s)if(this.editorRenderer=s(e,t),this.editorRenderer){this.editorRendererRow=e,this.editorRendererColumn=t,this.editing=!0,this.repaint();const o=document.querySelector("input.ge-table-cell-editor-input");o&&o.focus()}else this.resetEditorRenderer()}repaint(){this.adjustAfterScrolling()}adjustAfterScrolling(){var e;for(const t of this.removables)t.remove();this.hideHoverRow(),this.hideHoverColumn(),this.scrollTop=this.scrollViewport.scrollTop,this.scrollLeft=this.scrollViewport.scrollLeft,this.debounce(this.checkForScrollPosSaving.bind(this)),this.scrollFactorY=this.scrollTop/(this.scrollViewport.scrollHeight-this.scrollViewport.clientHeight),this.scrollFactorX=this.scrollLeft/(this.scrollViewport.scrollWidth-this.scrollViewport.clientWidth),isNaN(this.scrollFactorY)&&(this.scrollFactorY=0),isNaN(this.scrollFactorX)&&(this.scrollFactorX=0),this.adjustBody(),this.adjustArea("footer"),this.adjustArea("header"),this.tableOptions.tableTopBorderVisible&&this.removables.push(this.dom.addHorizontalBorder(new T(0,this.hostElement.clientWidth,1,0),this.hostElement,"ge-table-border")),this.tableOptions.tableBottomBorderVisible&&this.removables.push(this.dom.addHorizontalBorder(new T(0,this.hostElement.clientWidth,1,this.hostElement.clientHeight-1),this.hostElement,"ge-table-border")),this.tableModel.getFixedLeftColumnCount()>0&&this.removables.push(this.dom.addVerticalBorder(new T(this.areaBodyWest.child.clientWidth,1,this.hostElement.clientHeight,0),this.hostElement,"ge-table-body-west-vertical-border")),((e=this.tableModel.getAreaModel("header"))==null?void 0:e.getRowCount())>0&&this.removables.push(this.dom.addHorizontalBorder(new T(0,this.hostElement.clientWidth,1,this.areaHeaderCenter.child.clientHeight),this.hostElement,"ge-table-body-west-vertical-border"))}checkForScrollPosSaving(){var e,t;this.storeScrollPosStateService&&((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.autoRestoreScrollPosition)&&this.storeScrollPosStateService.updateScrollOffset([this.scrollLeft,this.scrollTop])}updateCells(e){e.forEach(t=>this.tableModel.getAreaModel(t.area).setValue(t.rowIndex,t.columnIndex,t.value)),this.repaint()}getAreaAndSideIdentByAttr(e){if(e){const t=this.getStringByAttr(e,"data-area"),s=this.getStringByAttr(e,"data-side");if(s&&t)return[t,s]}return[void 0,void 0]}getArea(e,t){if(e==="header"){if(t==="west")return this.areaHeaderWest;if(t==="center")return this.areaHeaderCenter;if(t==="east")return this.areaHeaderEast}else if(e==="body"){if(t==="west")return this.areaBodyWest;if(t==="center")return this.areaBodyCenter;if(t==="east")return this.areaBodyEast}else if(e==="footer"){if(t==="west")return this.areaFooterWest;if(t==="center")return this.areaFooterCenter;if(t==="east")return this.areaFooterEast}throw Error(`Wrong area identifier: row:${e}, col:${t}`)}adjustBody(){const e=this.areaBodyCenterGeo.height-this.tableModel.getContentHeightInPixel(),t=this.scrollFactorY*e;this.dom.setStyle(this.contentDiv,"top",`${this.scrollTop}px`),this.dom.setStyle(this.contentDiv,"left",`${this.scrollViewport.scrollLeft}px`),this.adjustArea("body",t)}getNumberByAttr(e,t){var s;if(e){const i=(s=e.closest("["+t+"]"))==null?void 0:s.getAttribute(t);if(i)return Number(i)}return-1}getStringByAttr(e,t){var s;if(e){const i=(s=e.closest("["+t+"]"))==null?void 0:s.getAttribute(t);if(i)return i}return""}adjustArea(e,t=0){var u;const s=this.getArea(e,"west"),i=this.getArea(e,"center"),o=this.getArea(e,"east"),r=i.child.clientHeight;s.child.innerText="",i.child.innerText="",o.child.innerText="";const a=0,n=this.areaBodyCenterGeo.width,d=this.tableModel.getPadding(),h=this.tableModel.getAreaModel(e),p=h.getRowCount();for(;this.cleanupFunctions[e].length;){const f=this.cleanupFunctions[e].shift();f&&f()}let g=t;const S=this.tableModel.getColumnCount(),c=this.tableModel.getFixedRightColumnCount(),b=this.tableModel.getFixedLeftColumnCount();for(let f=0;f<p;f++){const x=g,v=f===p-1,C=this.tableModel.getRowHeight(e,f);if(x+C>0){this.firstVisibleRowIndex=f;let w={left:a,width:n,height:C,top:x,index:f},m=this.dom.addRowDiv(i,w,f,e,"center");const M=b;if(this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"center",areaModel:h,geo:w,parent:m,rowIndex:f,columnIndexStart:M,columnIndexEnd:S-c-1,verticalFixed:!1,lastRowOfModel:v}),d.left>0&&(w={left:a,width:this.areaBodyWestGeo.width,height:C,top:x,index:f},m=this.dom.addRowDiv(s,w,f,e,"west"),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"west",areaModel:h,geo:w,parent:m,rowIndex:f,columnIndexStart:0,columnIndexEnd:M-1,verticalFixed:!0,lastRowOfModel:v})),d.right>0&&(w={left:a,width:this.areaBodyEastGeo.width,height:C,top:x,index:f},m=this.dom.addRowDiv(o,w,f,e,"east"),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"east",areaModel:h,geo:w,parent:m,rowIndex:f,columnIndexStart:S-c,columnIndexEnd:S-1,verticalFixed:!0,lastRowOfModel:v})),e==="header"&&this.tree&&f===p-1){const E=this.dom.applyStyle(this.dom.setAttribute(this.dom.addDiv(m,new T(16,20,20,8)),"data-ge-action","toggleExpandCollapseAll"),{cursor:"pointer"}),R=this.tableOptions.treeOptions.arrowExpandCollapseAll;if(R){const B=this.dom.domService.createText(R.content);this.dom.domService.appendChild(E,B),R.style&&this.dom.applyStyleString(E,R.style)}}}if(g=g+C,g>r)break}if(this.colAndRowspanModels&&this.colAndRowspanModels[e]){const f=((u=this.colAndRowspanModels[e])==null?void 0:u.getRanges())??[];if(f.length)for(const x of f){let v=0,C=i.child,w="center";if(x.c1<b)C=s.child,w="west";else if(c>0&&x.c1>=S-c)C=o.child,w="east";else{const m=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();v=this.scrollFactorX*m-this.areaBodyWestGeo.width,w="center"}this.drawBigCell(x,v,t,h,C,w)}}}drawBigCell(e,t,s,i,o,r){const a=s+this.getRowHeights(0,e.r1-1,i).reduce((u,f)=>u+f,0),n=this.tableModel.getColumnCount(),d=this.tableModel.getFixedRightColumnCount();let h=0;d>0&&e.c1>=n-d&&(h=n-d);const p=t+this.getColumnWidths(h,e.c1-1).reduce((u,f)=>u+f,0),g=this.getRowHeights(e.r1,e.r2,i).reduce((u,f)=>u+f,0),S=this.getColumnWidths(e.c1,e.c2).reduce((u,f)=>u+f,0);let c=!1;const b=this.getSelectionModel?this.getSelectionModel():void 0;b&&(c=b.getSelectionCount(e.r1,e.c1)>0),e.gammaRange?(console.info("TODO here",e),this.renderCell({areaModel:i,areaIdent:i.areaIdent,sideIdent:r,rowIndex:e.r1,columnIndex:e.c1,left:p,top:a,width:S,height:g,parent:o,cellSelected:c,lastRowOfModel:!0,gammaRange:e.gammaRange})):this.renderCell({areaModel:i,areaIdent:i.areaIdent,sideIdent:r,rowIndex:e.r1,columnIndex:e.c1,left:p,top:a,width:S,height:g,parent:o,cellSelected:c,lastRowOfModel:!0,gammaRange:e.gammaRange}),i.areaIdent==="header"&&this.tableOptions.columnsResizable&&this.renderHeaderCellResizeHandle({rowIndex:e.r1,columnIndex:e.c1,cellLeft:p,cellTop:a,cellWidth:S,cellHeight:g,parent:o})}findRowOfImportantRowspanCell(e,t,s){const i=e.getMaxRowspan();for(let o=t-1;o>-1;o--){const r=e.getRowspanAt(o,s);if(r>1&&o+r+1>=t)return o;if(t-o>i)return-1}return-1}adjustColumnsToRowParent({areaIdent:e,sideIdent:t,areaModel:s,geo:i,parent:o,rowIndex:r,columnIndexStart:a,columnIndexEnd:n,verticalFixed:d=!1,lastRowOfModel:h=!1}){var b;this.scrollViewportLeft=this.scrollViewport.scrollLeft;let p=0;if(!d){const u=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();p=this.scrollFactorX*u}const g=0,S=!!(e==="body"&&t);let c=p;for(let u=a;u<=n;u++){const f=c,x=this.tableModel.getColumnWidth(u);if(x>0&&f+x>0){let v=i.height;const C=s.getRowspanAt(r,u),w=s.getColspanAt(r,u);C>1&&(v=this.getRowHeights(r,r+C-1,s).reduce((E,R)=>E+R,0));let m=x;w>1&&(m=this.getColumnWidths(u,u+w-1).reduce((E,R)=>E+R,0));let M=!1;if(this.colAndRowspanModels&&this.colAndRowspanModels[e]&&(b=this.colAndRowspanModels[e])!=null&&b.isInRange(r,u)&&(M=!0),this.draggingTargetColumnIndex===u&&e!=="header"){this.renderDragTargetDiv(o,f,g,m,v);const E={left:f,top:g,width:m,height:v};this.dom.addColumnBorderDivs(this.tableOptions,o,E,e,t)}else{const E=this.renderSelectedBackgroundDiv(M,S,t,s,r,u,o,f,g,m,v);M||this.renderCell({areaModel:s,areaIdent:e,sideIdent:t,rowIndex:r,columnIndex:u,left:f,top:g,width:m,height:v,parent:o,cellSelected:E,lastRowOfModel:h,gammaRange:!0}),e==="header"&&this.tableOptions.columnsResizable&&this.renderHeaderCellResizeHandle({rowIndex:r,columnIndex:u,cellLeft:f,cellTop:g,cellWidth:m,cellHeight:v,parent:o})}}if(c=c+x,c>this.areaBodyCenterGeo.width)break}this.tableOptions.verticalBorderVisible&&this.dom.addVerticalBorder(new T(c-1,1,i.height,0),o)}getTreeArrowColumnIndex(){return this.tableOptions.showCheckboxWihoutExtraColumn?0:this.tableModel.isRowCheckboxVisible()?1:0}addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:s,rowIndex:i,index:o,left:r,width:a,height:n,top:d,parent:h,lastRowOfModel:p}){var J;const S=this.editorRenderer&&this.editorRendererRow===i&&this.editorRendererColumn===o?this.editorRenderer:e.getCellRenderer(i,o),c={left:r,width:a,height:n,top:d,index:o},b=e.getRowByIndex(i);let u="none";if(o===this.getTreeArrowColumnIndex()&&b instanceof j){const y=b;(J=y.children)!=null&&J.length?y.expanded?u="expanded":u="collapsed":u="hidden"}let x;if(t==="header"){const y=this.tableModel.getColumnDef(o);(!(y!=null&&y.sortIconVisible)||y!=null&&y.sortIconVisible())&&(x=y==null?void 0:y.sortState)}const v=e.getValueAt(i,o),C=S?"":`${v}`,w=e.isRowChecked(i),m=this.dom.addColumnDiv(h,c,i,o,t,s,C,u,this.tableOptions,w,x),M=e.getTooltipAt(i,o);M&&this.dom.setAttribute(m,"title",M);const E=this.tableModel.getColumnDef(o);E&&E.classes[t]&&this.dom.addClasses(E.classes[t],m);let R;S&&(R=S.render(m,i,o,t,e,v,this.dom.domService));const B=e.getCustomClassesAt(i,o);if(B.length&&this.dom.addClasses(B,m),this.dom.addColumnBorderDivs(this.tableOptions,h,c,t,s),p&&this.dom.addHorizontalBorder({left:r,width:a,height:n,top:d+n},h),this.getFocusModel&&t==="body"){const y=this.getFocusModel();y!=null&&y.hasFocus(i,o)&&this.dom.addFocusBorderDivs(h,c,{})}t==="header"&&this.dom.setAttribute(m,"data-ge-action","drag-column");const k=e.getCustomStyleAt(i,o);if(k)for(const y in k)this.dom.setStyle(m,y,k[y]);return[m,R]}getColumnWidths(e,t){const s=[];for(let i=e;i<=t;i++)s.push(this.tableModel.getColumnWidth(i));return s}getRowHeights(e,t,s){const i=[];for(let o=e;o<=t;o++)i.push(s.getRowHeight(o));return i}adjustHoverRows(e){if(this.tableOptions.hoverRowVisible&&e.rowIndex>-1){const t=this.hostElement.clientWidth,s=this.tableModel.getAreaModel("body").getRowHeight(e.rowIndex),i=e.rowTop+this.areaHeaderCenter.parent.clientHeight-this.scrollTop;this.dom.applyStyle(this.hoverRow,{left:"0",top:i+"px",width:t+"px",height:s+"px",display:"block"})}else this.hideHoverRow()}hideHoverRow(){this.dom.applyStyle(this.hoverRow,{display:"none"})}adjustHoverColumns(e){if(this.tableOptions.hoverColumnVisible&&e.rowIndex>-1){const t=this.hostElement.clientHeight,s=this.tableModel.getColumnWidth(e.columnIndex),i=this.areaBodyWestGeo.width,o=e.columnLeft+this.tableModel.getPadding().left-this.scrollLeft-i;this.dom.applyStyle(this.hoverColumn,{left:o+"px",top:"0px",width:s+"px",height:t+"px",display:"block"})}else this.hideHoverColumn()}hideHoverColumn(){this.dom.applyStyle(this.hoverColumn,{display:"none"})}debounce(e,t=1e3){this.debounceTimeout&&clearTimeout(this.debounceTimeout),this.debounceTimeout=setTimeout(e.bind(this),t)}renderDragTargetDiv(e,t,s,i,o){const r=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass("ge-table-drop-zone",e));return this.dom.setStyle(r,"left",`${t}px`),this.dom.setStyle(r,"top",`${s}px`),this.dom.setStyle(r,"width",`${i}px`),this.dom.setStyle(r,"height",`${o}px`),r}renderSelectedBackgroundDiv(e,t,s,i,o,r,a,n,d,h,p){let g=!1;if(!e&&t&&i.isSelectable(o,r)&&this.getSelectionModel){const S=this.getSelectionModel();if(S){const c=S.getSelectionCount(o,r);g=c>0;for(let b=0;b<c;b++){const u=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass(`ge-table-${i.areaIdent}-${s}-selected-range`,a));this.dom.setStyle(u,"left",`${n}px`),this.dom.setStyle(u,"top",`${d}px`),this.dom.setStyle(u,"width",`${h}px`),this.dom.setStyle(u,"height",`${p}px`)}}}return g}renderCell({areaModel:e,areaIdent:t,sideIdent:s,rowIndex:i,columnIndex:o,left:r,top:a,width:n,height:d,parent:h,cellSelected:p,lastRowOfModel:g,gammaRange:S}){const[c,b]=this.addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:s,rowIndex:i,index:o,left:r,width:n,height:d,top:a,parent:h,lastRowOfModel:g,gammaRange:S});p&&this.dom.addClass(`ge-table-${t}-${s}-selected-range`,c),b&&this.cleanupFunctions[t].push(b)}renderHeaderCellResizeHandle({rowIndex:e,columnIndex:t,cellLeft:s,cellTop:i,cellWidth:o,cellHeight:r,parent:a}){const n=this.dom.domService,d=this.tableOptions.columnResizeHandleWidthInPx??2,h=n.createElement("div");n.setAttribute(h,"data-col-index",`${t}`),n.setAttribute(h,"data-row-index",`${e}`),n.setAttribute(h,"data-area","header"),n.setAttribute(h,"data-ge-action","resize-column"),n.addClass(h,"ge-table-column-resize-handle"),n.setStyle(h,"display","clip"),n.setStyle(h,"position","absolute"),n.setStyle(h,"cursor","col-resize"),n.setStyle(h,"left",`${s+o-d}px`),n.setStyle(h,"top",`${i}px`),n.setStyle(h,"width",`${d}px`),n.setStyle(h,"height",`${r}px`),n.appendChild(a,h)}}class Ge{constructor(e,t){this.columnIndex=e,this.sortState=t}}class Ne{constructor(e){this.tableScope=e,this.tableScope.hostElement.addEventListener("change",this.onHostElementChanged.bind(this))}onHostElementChanged(e){if(e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||e.target instanceof HTMLTextAreaElement){const t=e.target,s=t.getAttribute("data-area"),i=t.getAttribute("data-row-index"),o=t.getAttribute("data-col-index");if(s&&i&&o){const r=Y(s),a=Number(i),n=Number(o);this.tableScope.updateModelValueAfterEdit(r,a,n,t.value)}}}}class je{constructor(e=-1,t=-1){this.rowIndex=e,this.columnIndex=t}}class U{constructor(e){this.cells=e}static createSingle(e,t){return new U([new je(e,t)])}}class ze{constructor(e){var t,s;this.tableScope=e,(t=this.tableScope.tableOptions)!=null&&t.getSelectionModel&&(this.getSelectionModel=this.tableScope.tableOptions.getSelectionModel),(s=this.tableScope.tableOptions)!=null&&s.getFocusModel&&(this.getFocusModel=this.tableScope.tableOptions.getFocusModel)}onMouseClicked(e,t){var o,r,a,n,d,h,p;let s=!1,i=!1;if(this.getSelectionModel&&this.getFocusModel){const g=this.getSelectionModel(),S=this.getFocusModel();g&&S&&(S.hasFocus(e.rowIndex,e.columnIndex)||(S.setFocus(e.rowIndex,e.columnIndex),s=!0),(o=e.originalEvent)!=null&&o.shiftKey||g.hasSelection()&&(g.clear(),s=!0),(r=e.originalEvent)!=null&&r.shiftKey&&this.previousEvt?(g.addSelection(this.createRangeByEvents(e,this.previousEvt)),i=!0,s=!0):(a=e.originalEvent)!=null&&a.ctrlKey||(n=e.originalEvent)!=null&&n.metaKey?(g.addSelection(A.singleCell(e.rowIndex,e.columnIndex)),i=!0,s=!0):(d=e.originalEvent)!=null&&d.altKey&&((h=e.originalEvent)!=null&&h.ctrlKey||(p=e.originalEvent)!=null&&p.metaKey)&&(g.removeSelection(A.singleCell(e.rowIndex,e.columnIndex)),i=!0,s=!0))}return i?this.previousEvt=void 0:this.previousEvt=e==null?void 0:e.clone(),s}onActionTriggered(e){if(this.getSelectionModel&&this.getFocusModel){const t=this.getSelectionModel(),s=this.getFocusModel();if(t&&s){if(e==="SELECT_ALL")return t.selectAll(),this.tableScope.repaint(),!0;if(e==="DESELECT_ALL")return t.clear(),this.tableScope.repaint(),!0;if(e==="TOGGLE_SELECTION"){const[i,o]=s.getFocus();return t.togglePoint(i,o),this.tableScope.repaint(),!0}}}return!1}createRangeByEvents(e,t){t||(t=e);const s=Math.min(e.rowIndex,t==null?void 0:t.rowIndex),i=Math.max(e.rowIndex,t==null?void 0:t.rowIndex),o=Math.min(e.columnIndex,t==null?void 0:t.columnIndex),r=Math.max(e.columnIndex,t==null?void 0:t.columnIndex);return A.create({rowIndex1:s,columnIndex1:o,rowIndex2:i,columnIndex2:r})}}class Xe{get(){return{f2:"START_EDITING",space:"TOGGLE_SELECTION","ctrl+num_add":"SELECT_ALL","ctrl+a":"SELECT_ALL","ctrl+shift+a":"DESELECT_ALL","ctrl+x":"DESELECT_ALL","ctrl+num_subtract":"DESELECT_ALL","cmd -":"DESELECT_ALL",arrowup:"NAVIGATE_UP",arrowdown:"NAVIGATE_DOWN",arrowleft:"NAVIGATE_LEFT",arrowright:"NAVIGATE_RIGHT"}}}class Ke{get(){return{f2:"START_EDITING",space:"TOGGLE_SELECTION","ctrl+num_add":"SELECT_ALL","cmd+a":"SELECT_ALL","ctrl+a":"SELECT_ALL","cmd+x":"DESELECT_ALL","cmd+shift+a":"DESELECT_ALL","ctrl+shift+a":"DESELECT_ALL","ctrl+num_subtract":"DESELECT_ALL","ctrl -":"DESELECT_ALL",arrowup:"NAVIGATE_UP",arrowdown:"NAVIGATE_DOWN",arrowleft:"NAVIGATE_LEFT",arrowright:"NAVIGATE_RIGHT"}}}class Ye{constructor(e){this.tableScope=e,this.shortcutActionIdMapping={},this.listener=[],this.listener.push(e),this.init()}addListener(e){this.listener.includes(e)||this.listener.push(e)}init(){this.isMacintosh()?Object.assign(this.shortcutActionIdMapping,new Ke().get()):Object.assign(this.shortcutActionIdMapping,new Xe().get()),Object.assign(this.shortcutActionIdMapping,this.tableScope.tableOptions.shortcutActionIdMapping),this.isDebug()&&console.debug("ShortcutService",this.shortcutActionIdMapping),this.tableScope.hostElement.addEventListener("keydown",this.onKeyDown.bind(this))}isMacintosh(){return navigator.platform.indexOf("Mac")>-1}isDebug(){return this.isLocalhost()}isLocalhost(){return location.hostname==="localhost"||location.hostname==="127.0.0.1"}onKeyDown(e){const t=this.findEnty(e);t&&this.emit(t)&&(e.preventDefault(),e.stopPropagation())}emit(e){this.isDebug()&&console.debug("ShortcutService emit:",e);let t=!1;for(const s of this.listener)s.onActionTriggered(e)&&(t=!0);return t}findEnty(e){const t=this.getTokenByEvent(e);this.isDebug()&&console.debug("ShortcutService tokens:",t);for(const s in this.shortcutActionIdMapping){const i=s.replace(/opt/g,"alt").replace(/cmd/g,"meta").split(/[\+ ]/g).sort();if(this.areTokensEquals(t,i))return this.shortcutActionIdMapping[s]}}areTokensEquals(e,t){if(e.length!==t.length||e.length===0)return!1;for(let s=0;s<e.length;s++)if(e[s]!==t[s])return!1;return!0}getTokenByEvent(e){const t=[];return e.altKey&&t.push("alt"),e.shiftKey&&t.push("shift"),e.ctrlKey&&t.push("ctrl"),e.metaKey&&t.push("meta"),e.code&&t.push(e.code.toLowerCase().replace(/key/g,"")),t.sort()}}class qe{onCheckboxChanged(e){}onContextmenu(e){}onModelChanged(e){}onMouseClicked(e){}onMouseDragging(e){}onMouseDraggingEnd(e){}onMouseMoved(e){}}class Ue extends We{constructor(e,t,s,i,o){var r;if(super(e,t,new Me(s),i),this.eventListener=o,this.selectionService=new ze(this),this.api=new De(this),this.mouseStartAction="",this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,o||(this.eventListener=new qe),(r=this.tableOptions)!=null&&r.autoRestoreOptions){const a=this.tableOptions.autoRestoreOptions,n=a.getStorageKeyFn;n&&(a.autoRestoreScrollPosition&&(this.storeScrollPosStateService=new $e(n)),a.autoRestoreCollapsedExpandedState&&(this.storeStateCollapsedExpandService=new Be(n)),a.autoRestoreSortingState&&(this.storeSortingService=new Pe(n)))}this.mouseHandler=new Ie(this),this.inputHandler=new Ne(this),this.shortcutService=new Ye(this),this.shortcutService.addListener(this.selectionService)}onActionTriggered(e){if(e==="NAVIGATE_DOWN"&&this.changeFocusCell(0,1)||e==="NAVIGATE_UP"&&this.changeFocusCell(0,-1)||e==="NAVIGATE_LEFT"&&this.changeFocusCell(-1,0)||e==="NAVIGATE_RIGHT"&&this.changeFocusCell(1,0))return!0;if(e==="START_EDITING"&&this.getFocusModel){const t=this.getFocusModel();if(t){const[s,i]=t.getFocus();this.tableModel.getBodyModel().isEditable(s,i)&&(this.clearSelection(),this.initRenderEditor(s,i))}return!0}return!1}updateModelValueAfterEdit(e,t,s,i){e==="body"&&this.tableModel.getAreaModel(e).setValue(t,s,i)&&(this.resetEditorRenderer(),this.repaint(),this.eventListener.onModelChanged(U.createSingle(t,s)),this.hostElement.focus())}getApi(){return this.api}firstInit(){var e;this.tableModel.init(),(e=this.tableOptions)!=null&&e.externalFilterFunction&&this.externalFilterChanged(!1),this.autoRestoreCollapsedExpandedState(),this.autoRestoreSortingState(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows(),this.autoRestoreScrollPosition()}createGeMouseEvent(e){const t=new K;if(t.originalEvent=e,e){const s=e.target;if([t.areaIdent,t.sideIdent]=this.getAreaAndSideIdentByAttr(s),t.rowIndex=this.getNumberByAttr(s,"data-row-index"),t.columnIndex=this.getNumberByAttr(s,"data-col-index"),t.action=this.getStringByAttr(s,"data-ge-action"),t.areaIdent){const i=this.tableModel.getAreaModel(t.areaIdent);t.rowTop=i.getYPosByRowIndex(t.rowIndex)}if(t.columnLeft=this.tableModel.getXPosByColumnIndex(t.columnIndex),e.ctrlKey&&e.altKey){const i=e.clientY-this.hostElement.offsetTop-this.areaHeaderCenter.parent.clientHeight,o=e.clientX-this.hostElement.offsetLeft-this.areaBodyWestGeo.width;this.debugOnce(o,i)}}return t}onMouseDown(e){e.columnIndex>-1&&e.action&&["resize-column","drag-column"].includes(e.action)&&(this.mouseStartWidth=this.tableModel.getColumnWidth(e.columnIndex),this.mouseStartAction=e.action,this.mouseStartColumnIndex=e.columnIndex,this.mouseStartAction==="drag-column"&&(this.dragFrom=this.mouseStartColumnIndex))}mouseDraggingOnFrame(e){this.eventListener.onMouseDragging(e),this.mouseEvent=e,this.mouseStartColumnIndex>-1&&this.mouseStartAction==="resize-column"&&this.tableOptions.columnsResizable?this.resizeColumn(e):this.mouseStartAction==="drag-column"&&e.columnIndex>-1&&this.tableOptions.columnsDraggable&&(this.draggingTargetColumnIndex=e.columnIndex,this.dragTo=this.draggingTargetColumnIndex,this.dragFrom>-1&&this.dragTo>-1&&this.dragFrom!==this.dragTo&&(this.tableModel.changeColumnOrder(this.dragFrom,this.dragTo),this.dragFrom=this.dragTo,this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()),this.repaint())}mouseDraggingEndOnFrame(e){this.eventListener.onMouseDraggingEnd(e),this.draggingTargetColumnIndex=-1,this.mouseStartAction==="resize-column"?this.resizeColumn(e):this.mouseStartAction==="drag-column"&&this.repaint(),this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,this.mouseStartAction=""}mouseMove(e){this.eventListener.onMouseMoved(e),this.adjustHoverRows(e),this.adjustHoverColumns(e)}contextmenu(e){this.eventListener.onContextmenu(e)}toggleExpandCollapseAll(e=!0){var s;const t=this.tableModel.getBodyModel();t instanceof z&&(t.toggleExpandCollapseAll(e),this.repaint(),(s=this.storeStateCollapsedExpandService)==null||s.collapsedStateAll(e))}toggleRowCheckbox(e,t,s){var n;const i=this.tableModel.getAreaModel(s),o=i.isRowChecked(e),r=o===void 0||o==="semi"||o==="none";i.setRowChecked(e,r),this.repaint();const a=(n=i.rowSelectionModel)==null?void 0:n.getCheckedRows();this.eventListener.onCheckboxChanged(a||[])}onMouseClicked(e,t){let s=this.selectionService.onMouseClicked(e,t);if(!s&&this.getFocusModel){const i=this.getFocusModel();i&&(s=i.hasChanged(),i.clearChanged(),s&&this.resetEditorRenderer())}this.eventListener.onMouseClicked(e),s&&this.debounce(this.repaint.bind(this),10)}externalFilterChanged(e=!0){const t=this.tableOptions.externalFilterFunction;t&&(e&&this.clearSelectionModel(),this.tableModel.externalFilterChanged(t),this.scrollViewport.scrollTo(0,0),this.tableModel.recalcHeightAndPadding(),this.resetSizeOfWrapperDiv(),this.repaint())}onHeaderDblClicked(e,t,s){var o,r;const i=this.tableModel.getColumnDef(s);if(i!=null&&i.sortable&&i.sortable()){e.preventDefault(),e.stopPropagation();const a=i.sortStatesOrder?i.sortStatesOrder:this.tableOptions.sortOrder,n=i.sortState??"",d=a[(a.indexOf(n)+1)%a.length],h=new Ge(s,d);this.tableModel.doSort([h])&&((o=this.tableModel.getColumnDefs())==null||o.forEach(g=>g.sortState=""),i.sortState=d),this.repaint(),(r=this.storeSortingService)==null||r.setSortItems([h])}}changeFocusCell(e,t){if(!this.isEditing()&&this.getFocusModel){const s=this.getFocusModel();if(s){const[i,o]=s.getFocus();return s.setFocus(i+t,o+e),this.repaint(),!0}}return!1}resizeColumn(e){this.tableModel.setColumnWidth(this.mouseStartColumnIndex,this.mouseStartWidth+e.draggingX),this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()}clearSelectionModel(){var e;this.getSelectionModel&&((e=this.getSelectionModel())==null||e.clear())}debugOnce(e,t){var s;console.clear(),console.info("this.hostElement.offsetTop",this.hostElement.offsetTop),console.info("this.hostElement.scrollHeight",this.hostElement.scrollHeight),console.info("this.scrollViewportTop",this.scrollTop),console.info("this.areaHeaderCenter.parent.clientHeight",this.areaHeaderCenter.parent.clientHeight),console.info("bodyY",t),console.info("bodyX",e),console.info("rows",this.firstVisibleRowIndex),console.info(""),console.info("this.tableModel",this.tableModel),console.info(""),console.info("this.mouseMoveEvent.clientX",(s=this.mouseHandler.mouseEvent)==null?void 0:s.clientX),console.info("this.hostElement.offsetLeft",this.hostElement.offsetLeft),console.info("this.areaBodyWestGeo.width",this.areaBodyWestGeo.width)}autoRestoreScrollPosition(){var e;if((e=this.tableOptions)!=null&&e.autoRestoreOptions&&this.storeScrollPosStateService&&this.tableOptions.autoRestoreOptions.autoRestoreScrollPosition){const s=this.storeScrollPosStateService.getScrollOffset();s&&this.scrollViewport.scrollTo(...s)}}autoRestoreSortingState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.autoRestoreSortingState&&this.storeSortingService){const s=this.storeSortingService.getSortItems();s!=null&&s.length&&this.tableModel.getBodyModel().doSort(s)}}autoRestoreCollapsedExpandedState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.getRowId&&this.storeStateCollapsedExpandService){const s=this.tableOptions.autoRestoreOptions,i=s.getRowId;if(s.autoRestoreCollapsedExpandedState&&i){const o=this.storeStateCollapsedExpandService.collapsedExpandedStateGet(),r=this.tableModel.getAreaModel("body");if(r instanceof z){const a=r,n=r.getRowCount();for(let d=0;d<n;d++){const h=r.getRowByIndex(d);if(h)if(o.allExpanded)h.expanded=!0;else if(o.allCollapsed)h.expanded=!1;else{const p=i(h.data);o.mode==="expanded"?h.expanded=this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(p):o.mode==="collapsed"&&(h.expanded=!this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(p))}}a.recalcVisibleTreeRows()}}}}}class Je{render(e,t,s,i,o,r,a){if(o.isEditable(t,s)){a.addClass(e,"ge-table-row-input-div");const n=o.getValueAt(t,s);e.innerHTML=`
7
+ ${n}
8
+ class="ge-table-row-checkbox"> `,this.domService.setStyle(o,"display","inline"),this.domService.setStyle(o,"width","inherit"),this.domService.setAttribute(o,"data-row-index",`${s}`),this.domService.appendChild(e,o),o}addLabelDiv(e,t="",i=!1,s=-1,o=-1,n="body"){const a=this.domService.createElement("div");if(this.domService.addClass(a,"ge-table-label-div"),this.domService.setStyle(a,"position","relative"),this.domService.setStyle(a,"background","transparent"),this.domService.setStyle(a,"width","100%"),this.domService.setStyle(a,"height","100%"),this.domService.setAttribute(a,"data-row-index",`${s}`),this.domService.setAttribute(a,"data-col-index",`${o}`),this.domService.setAttribute(a,"data-area",`${n}`),t)if(i){const r=this.domService.createText(t);this.domService.appendChild(a,r)}else{const r=this.domService.createElement("div");this.domService.appendChild(a,r);const d=this.domService.createText(t);this.domService.addClass(r,"ge-table-label"),this.domService.appendChild(r,d),this.domService.setAttribute(r,"data-row-index",`${s}`),this.domService.setAttribute(r,"data-col-index",`${o}`),this.domService.setAttribute(r,"data-area",`${n}`)}return this.domService.appendChild(e,a),a}addSortedIcon(e,t="",i=new ae,s=-1){const o=this.domService.createElement("div");this.domService.addClass(o,"ge-table-sorted-icon-div"),this.domService.setStyle(o,"position","absolute"),this.domService.setStyle(o,"top","0"),this.domService.setStyle(o,"right","0"),this.domService.setStyle(o,"width","20px"),this.domService.setStyle(o,"background","transparent"),this.domService.setStyle(o,"cursor","pointer"),this.domService.setAttribute(o,"data-col-index",`${s}`),this.domService.setAttribute(o,"data-area","header");let n;t==="asc"?n=i.iconAsc:t==="desc"?n=i.iconDesc:n=i.iconPlaceholder;const a=n.content,r=this.domService.createText(a);this.domService.appendChild(o,r),n.style&&this.applyStyleString(o,n.style);for(const d of n.classes)this.domService.addClass(o,d);return this.domService.appendChild(e,o),o}addArrowDiv(e,t="none",i=new ne,s=-1,o=-1,n="body"){const a=this.domService.createElement("div");this.domService.addClass(a,"ge-table-tree-arrow-div"),this.domService.setStyle(a,"display","inline-block"),this.domService.setStyle(a,"position",""),this.domService.setStyle(a,"width","20px"),this.domService.setStyle(a,"background","transparent"),this.domService.setStyle(a,"cursor","pointer"),this.domService.setAttribute(a,"data-row-index",`${s}`),this.domService.setAttribute(a,"data-col-index",`${o}`),this.domService.setAttribute(a,"data-area",`${n}`);let r;t==="expanded"?r=i.arrowExpanded:t==="collapsed"?r=i.arrowCollapsed:r=i.arrowPlaceholder;const d=r.content,h=this.domService.createText(d);this.domService.appendChild(a,h),r.style&&this.applyStyleString(a,r.style);for(const p of r.classes)this.domService.addClass(a,p);return this.domService.appendChild(e,a),a}addColumnBorderDivs(e,t,i,s,o){if(e.verticalBorderVisible){const n=`ge-table-${s}-${o}-vertical-border`;this.addVerticalBorder(i,t,n)}if(e.horizontalBorderVisible){const n=`ge-table-${s}-${o}-horizontal-border`;this.addHorizontalBorder(i,t,n)}return t}addHorizontalBorder(e,t,i="ge-table-body-center-horizontal-border"){const s=this.domService.createElement("div");return this.domService.addClass(s,i),this.domService.setStyle(s,"display","clip"),this.domService.setStyle(s,"position","absolute"),this.domService.setStyle(s,"left",`${e.left}px`),this.domService.setStyle(s,"top",`${e.top}px`),this.domService.setStyle(s,"width",`${e.width}px`),this.domService.setStyle(s,"height","1px"),this.domService.appendChild(t,s),s}addFocusBorderDivs(e,t,i){let s=this.domService.createElement("div");return this.domService.addClass(s,"ge-table-focus-border"),this.domService.setStyle(s,"display","clip"),this.domService.setStyle(s,"position","absolute"),this.domService.setStyle(s,"left",`${t.left}px`),this.domService.setStyle(s,"top",`${t.top}px`),this.domService.setStyle(s,"width","1px"),this.domService.setStyle(s,"height",`${t.height}px`),this.applyStyle(s,i),this.domService.appendChild(e,s),s=this.domService.createElement("div"),this.domService.addClass(s,"ge-table-focus-border"),this.domService.setStyle(s,"display","clip"),this.domService.setStyle(s,"position","absolute"),this.domService.setStyle(s,"left",`${t.left+t.width-1}px`),this.domService.setStyle(s,"top",`${t.top}px`),this.domService.setStyle(s,"width","1px"),this.domService.setStyle(s,"height",`${t.height}px`),this.applyStyle(s,i),this.domService.appendChild(e,s),s=this.domService.createElement("div"),this.domService.addClass(s,"ge-table-focus-border"),this.domService.setStyle(s,"display","clip"),this.domService.setStyle(s,"position","absolute"),this.domService.setStyle(s,"left",`${t.left}px`),this.domService.setStyle(s,"top",`${t.top}px`),this.domService.setStyle(s,"width",`${t.width}px`),this.domService.setStyle(s,"height","1px"),this.applyStyle(s,i),this.domService.appendChild(e,s),s=this.domService.createElement("div"),this.domService.addClass(s,"ge-table-focus-border"),this.domService.setStyle(s,"display","clip"),this.domService.setStyle(s,"position","absolute"),this.domService.setStyle(s,"left",`${t.left}px`),this.domService.setStyle(s,"top",`${t.top+t.height-1}px`),this.domService.setStyle(s,"width",`${t.width}px`),this.domService.setStyle(s,"height","1px"),this.applyStyle(s,i),this.domService.appendChild(e,s),e}addVerticalBorder(e,t,i="ge-table-body-center-vertical-border"){const s=this.domService.createElement("div");return this.domService.addClass(s,i),this.domService.setStyle(s,"display","clip"),this.domService.setStyle(s,"position","absolute"),this.domService.setStyle(s,"left",`${e.left}px`),this.domService.setStyle(s,"top",`${e.top}px`),this.domService.setStyle(s,"width","1px"),this.domService.setStyle(s,"height",`${e.height}px`),this.domService.appendChild(t,s),s}addDiv(e,t,i=""){const s=this.domService.createElement("div");return i&&this.domService.addClass(s,i),this.domService.setStyle(s,"display","clip"),this.domService.setStyle(s,"position","absolute"),this.domService.setStyle(s,"left",`${t.left}px`),this.domService.setStyle(s,"top",`${t.top}px`),this.domService.setStyle(s,"width",`${t.width}px`),this.domService.setStyle(s,"height",`${t.height}px`),this.domService.appendChild(e,s),s}applyStyleString(e,t){const i=t.split(";").map(s=>s.trim()).filter(s=>s);for(const s of i){const[o,n]=s.split(":");this.domService.setStyle(e,o.trim(),n.trim())}}getDivOrCreateDiv(e,t){let i=t.cache[e];return i?(i.innerText="",i):(i=this.domService.createElement("div"),t.cache[e]=i,i)}}const Y=l=>l==="header"?"header":l==="footer"?"footer":"body";class Fe{constructor(e,t){if(this.rowIdx=-1,this.colIdx=-1,this.action=null,this.inputType=null,this.className="",e!==null&&(e instanceof HTMLDivElement||e instanceof HTMLSpanElement||e instanceof HTMLInputElement)){this.className=e.className,this.action=e.getAttribute("data-ge-action"),this.inputType=e.getAttribute("data-input-type"),this.rowIdx=Number(e.getAttribute("data-row-index")),this.colIdx=Number(e.getAttribute("data-col-index"));const i=e.getAttribute("data-area");if(i&&(this.areaIdent=Y(i),this.areaModel=t.tableModel.getAreaModel(this.areaIdent),this.row=this.areaModel.getRowByIndex(this.rowIdx)),e instanceof HTMLInputElement){const s=e;this.value=s.value}}}}class Oe{constructor(e){this.tableScope=e,this.expandedAll=!0,this.mouseDown=!1,this.dragging=!1,this.tableScope.hostElement.addEventListener("click",this.onHostElementClicked.bind(this)),this.tableScope.hostElement.addEventListener("dblclick",this.onHostElementDblClicked.bind(this)),this.tableScope.hostElement.addEventListener("mousedown",this.onMouseDown.bind(this)),this.tableScope.hostElement.addEventListener("mousemove",this.onMouseMove.bind(this)),this.tableScope.hostElement.addEventListener("mouseup",this.onMouseUp.bind(this)),this.tableScope.hostElement.addEventListener("contextmenu",this.onContextmenu.bind(this)),this.tableScope.hostElement._MouseHandler="true",this.tableScope.scrollViewport.addEventListener("scroll",this.tableScope.adjustAfterScrolling.bind(this.tableScope)),[window,this.tableScope.hostElement].forEach(t=>t.addEventListener("resize",this.tableScope.adjustContainersAndRows.bind(this.tableScope)))}onContextmenu(e){this.mouseEvent=e;const t=this.tableScope.createGeMouseEvent(this.mouseEvent);this.tableScope.contextmenu(t)}onHostElementClicked(e){const t=new Fe(e.target,this.tableScope);if(t.action==="toggleExpandCollapseAll")this.expandedAll=!this.expandedAll,this.tableScope.toggleExpandCollapseAll(this.expandedAll),e.preventDefault(),e.stopPropagation();else if(t.inputType==="checkbox"&&t.areaIdent)this.tableScope.toggleRowCheckbox(t.rowIdx,t.colIdx,t.areaIdent),e.preventDefault(),e.stopPropagation();else if(j(t.row)&&t.areaModel){const i=t.colIdx===this.getArrowColumnIndex()&&e.altKey,s=t.className.includes("ge-table-tree-arrow-div");if(console.info(s,i),i||s){e.preventDefault(),e.stopPropagation();const o=t.row;o.expanded=!o.expanded,"recalcVisibleTreeRows"in t.areaModel&&t.areaModel.recalcVisibleTreeRows(),this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth),this.tableScope.adjustContainersAndRows(),this.updateCollapsedExpandedState(o)}}if(t.areaIdent==="body"&&this.tableScope.tableOptions.getFocusModel){const i=this.tableScope.tableOptions.getFocusModel();i==null||i.clear(),i==null||i.setFocus(t.rowIdx,t.colIdx)}this.publishGeMouseEvent(e,1)}onHostElementDblClicked(e){if(e.target instanceof HTMLElement){const t=e.target,i=t.getAttribute("data-area"),s=Y(i),o=Number(t.getAttribute("data-row-index")),n=Number(t.getAttribute("data-col-index")),a=this.tableScope.tableModel.getAreaModel(s);if(i&&s==="header")this.tableScope.tableModel.isSortable(n)&&(this.tableScope.clearSelection(),this.tableScope.onHeaderDblClicked(e,o,n));else if(t.getAttribute("data-row-index")){const r=a.getRowByIndex(o);if(i&&s==="body"&&a.isEditable(o,n)&&(this.tableScope.clearSelection(),this.tableScope.initRenderEditor(o,n)),j(r)&&n===this.getArrowColumnIndex()){e.preventDefault(),e.stopPropagation();const d=r;d.expanded=!d.expanded,"recalcVisibleTreeRows"in a&&a.recalcVisibleTreeRows(),this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth),this.tableScope.adjustContainersAndRows(),this.updateCollapsedExpandedState(d)}}}this.publishGeMouseEvent(e,2)}publishGeMouseEvent(e,t){var i;this.mouseEvent=e,this.geMouseEventOld=(i=this.geMouseEvent)==null?void 0:i.clone(),this.geMouseEvent=this.tableScope.createGeMouseEvent(e),this.geMouseEvent&&(this.geMouseEvent.clickCount=t),this.tableScope.onMouseClicked(this.geMouseEvent,this.geMouseEventOld)}updateCollapsedExpandedState(e){var i,s,o,n,a;const t=(s=(i=this.tableScope.tableOptions)==null?void 0:i.autoRestoreOptions)==null?void 0:s.getRowId;if(t){const r=(o=this.tableScope.storeStateCollapsedExpandService)==null?void 0:o.collapsedExpandedStateGet().mode,d=r==="collapsed"&&!e.expanded||r==="expanded"&&e.expanded,h=r==="collapsed"&&e.expanded||r==="expanded"&&!e.expanded,p=t(e.data);d?(n=this.tableScope.storeStateCollapsedExpandService)==null||n.collapsedStateIdsPush(p):h&&((a=this.tableScope.storeStateCollapsedExpandService)==null||a.collapsedStateIdsRemove(p))}}getArrowColumnIndex(){return this.tableScope.tableModel.isRowCheckboxVisible()?1:0}onMouseDown(e){this.mouseEvent=e,this.startMouseEvent=this.tableScope.createGeMouseEvent(this.mouseEvent),this.tableScope.onMouseDown(this.startMouseEvent),this.mouseDown=!0}onMouseMove(e){this.mouseEvent=e,this.mouseDown?(this.dragging=!0,requestAnimationFrame(this.mouseDraggingOnFrame.bind(this))):requestAnimationFrame(this.mouseMoveOnFrame.bind(this))}onMouseUp(e){this.mouseEvent=e,this.dragging&&requestAnimationFrame(this.mouseDraggingEndOnFrame.bind(this)),this.mouseDown=!1,this.dragging=!1}mouseDraggingOnFrame(){var e;if(this.mouseEvent){const t=this.tableScope.createGeMouseEvent(this.mouseEvent);(e=this.startMouseEvent)!=null&&e.originalEvent&&(t.draggingX=this.mouseEvent.clientX-this.startMouseEvent.originalEvent.clientX,t.draggingY=this.mouseEvent.clientY-this.startMouseEvent.originalEvent.clientY),this.tableScope.mouseDraggingOnFrame(t)}}mouseDraggingEndOnFrame(){var e;if(this.mouseEvent){const t=this.tableScope.createGeMouseEvent(this.mouseEvent);(e=this.startMouseEvent)!=null&&e.originalEvent&&(t.draggingX=this.mouseEvent.clientX-this.startMouseEvent.originalEvent.clientX,t.draggingY=this.mouseEvent.clientY-this.startMouseEvent.originalEvent.clientY),this.tableScope.mouseDraggingEndOnFrame(t)}}mouseMoveOnFrame(){if(this.mouseEvent){const e=this.tableScope.createGeMouseEvent(this.mouseEvent);this.tableScope.mouseMove(e)}}}class Le{constructor(e){this.tableScope=e}updateCells(e){this.tableScope.updateCells(e)}externalFilterChanged(){this.tableScope.externalFilterChanged()}scrollToPixel(e=0,t=0){}scrollToIndex(e=0,t=0){}setHeaderVisible(e=!0){}setColumnVisible(e,t=!0){}isColumnVisible(e){return!0}isHeaderVisible(){return!0}setFooterVisible(e=!0){}isFooterVisible(){return!0}repaint(){this.tableScope.repaint()}}class q{constructor(e){this.getStorageKeyFn=e}autoConvertMapToObject(e){const t={};if(e instanceof Map){const i=e;for(const s of[...i]){const[o,n]=s;t[o]=n}}return t}checkAndPersistItem(e,t){const i=this.getStorageKeyFn;if(i){const s=i();if(s){const o=s+e;if((t+"").includes("Map")){const n=this.autoConvertMapToObject(t);this.persistItem(o,n)}else this.persistItem(o,t)}}}persistItem(e,t){t?localStorage.setItem(e,JSON.stringify(t)):localStorage.removeItem(e)}loadFromLocalStorage(e){const t=localStorage.getItem(e);return t?JSON.parse(t):null}}class _e extends q{constructor(e){super(e),this.SCROLL_STATE="scrollState",this.scrollOffset=[0,0],this.load()}getScrollOffset(){return this.scrollOffset}updateScrollOffset(e){this.scrollOffset=e,this.checkAndPersistItem(this.SCROLL_STATE,this.scrollOffset)}load(){const e=this.getStorageKeyFn;if(e){const t=e();if(t){const i=t+this.SCROLL_STATE;let s=this.loadFromLocalStorage(i);this.scrollOffset=s||[0,0]}}}}class Be{constructor(e="collapsed",t=[],i=!1,s=!1){this.mode=e,this.rowIds=t,this.allCollapsed=i,this.allExpanded=s}}class We extends q{constructor(e){super(e),this.COLLAPSED_EXPANDED_STATE="collapsedExpandedState",this.collapsedExpandedState=new Be,this.load()}collapsedExpandedStateGet(){return this.collapsedExpandedState}collapsedExpandedStateIncludes(e){return this.collapsedExpandedState.rowIds.includes(e)}collapsedStateIdsPush(e){this.collapsedExpandedState.rowIds.includes(e)||(this.collapsedExpandedState.rowIds.push(e),this.collapsedExpandedState.allCollapsed=!1,this.collapsedExpandedState.allExpanded=!1,this.persist())}collapsedStateIdsRemove(e){const t=this.collapsedExpandedState.rowIds.indexOf(e);t!==-1&&(this.collapsedExpandedState.rowIds.splice(t,1),this.collapsedExpandedState.allCollapsed=!1,this.collapsedExpandedState.allExpanded=!1,this.persist())}collapsedStateAll(e){this.collapsedExpandedState.rowIds=[],this.collapsedExpandedState.mode=e?"collapsed":"expanded",this.collapsedExpandedState.allCollapsed=!e,this.collapsedExpandedState.allExpanded=e,this.persist()}load(){const e=this.getStorageKeyFn;if(e){const t=e();if(t){const i=t+this.COLLAPSED_EXPANDED_STATE,s=this.loadFromLocalStorage(i);s&&(this.collapsedExpandedState=s)}}}persist(){this.checkAndPersistItem(this.COLLAPSED_EXPANDED_STATE,this.collapsedExpandedState)}}class He extends q{constructor(e){super(e),this.SORTING_STATE="sortingState",this.sortItems=[],this.load()}getSortItems(){return this.sortItems}setSortItems(e){this.sortItems=e,this.checkAndPersistItem(this.SORTING_STATE,this.sortItems)}load(){const e=this.getStorageKeyFn;if(e){const t=e();if(t){const i=t+this.SORTING_STATE;let s=this.loadFromLocalStorage(i);this.sortItems=s||[]}}}}class T{constructor(e=0,t=0,i=0,s=0,o){this.left=e,this.width=t,this.height=i,this.top=s,this.index=o}}class ke{constructor(e,t,i,s){this.hostElement=e,this.tableModel=t,this.dom=i,this.tableOptions=s,this.scrollTop=0,this.areaBodyWestGeo=new T,this.areaBodyCenterGeo=new T,this.areaBodyEastGeo=new T;const o=this.hostElement;o.innerText="",this.dom.setAttribute(o,"tabindex","0"),this.dom.setStyle(this.dom.addClass("ge-table",o),"position","relative"),this.hoverRow=i.applyStylePosistionAbsolute(i.createDivWithClass("ge-table-hover-row",o)),this.hoverColumn=i.applyStylePosistionAbsolute(i.createDivWithClass("ge-table-hover-column",o)),this.areaHeaderWest=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-header ge-table-header-west",o,"header","west"))),this.areaHeaderCenter=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-header ge-table-header-center",o,"header","center"))),this.areaHeaderEast=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-header ge-table-header-east",o,"body","east"))),this.areaBodyWest=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-body ge-table-body-west",o,"body","west"))),this.areaBodyEast=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-body ge-table-body-east",o,"body","east"))),this.areaFooterWest=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-footer ge-table-footer-west",o,"footer","west"))),this.areaFooterCenter=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-footer ge-table-footer-center",o,"footer","center"))),this.areaFooterEast=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-footer ge-table-footer-east",o,"footer","east"))),this.scrollViewport=i.applyStyleOverflowAuto(this.tableOptions.overflowX??"auto",this.tableOptions.overflowY??"auto",i.applyStyleNoPadding(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-scroll-viewport",o,"body","center")))),this.contentWrapperDiv=i.applyStyleNoPadding(i.applyStylePosistionRelative(i.createDivWithClass("ge-table-scroll-content-wrapper",this.scrollViewport))),this.contentDiv=i.applyStyleNoPadding(i.applyStylePosistionRelative(i.createDivWithClass("ge-table-scroll-content",this.contentWrapperDiv))),this.areaBodyCenter=i.appendRelativeChildDiv(i.createDivWithClass("ge-table-body-center",this.contentDiv)),this.borderHeaderBottom=i.applyStylePosistionAbsolute(i.createDivWithClass("ge-table-header-border",o)),this.borderFixedWest=i.applyStylePosistionAbsolute(i.createDivWithClass("ge-table-west-fixed-column-border",o)),this.borderFixedEast=i.applyStylePosistionAbsolute(i.createDivWithClass("ge-table-east-fixed-column-border",o)),this.borderFooterTop=i.applyStylePosistionAbsolute(i.createDivWithClass("ge-table-footer-border",o))}adjustContainersAndRows(){const e=this.tableModel.getPadding(),t=this.hostElement.clientWidth,i=this.hostElement.clientHeight;this.dom.applyStyle(this.scrollViewport,{width:`${t-e.left}px`,height:`${i-e.top}px`,top:`${e.top}px`,left:`${e.left}px`}),this.scrollTop=this.scrollViewport.scrollTop,this.dom.applyStyle(this.contentDiv,{width:`${this.scrollViewport.clientWidth}px`,height:`${this.scrollViewport.clientHeight}px`,top:`${this.scrollTop}px`,left:`${this.scrollViewport.scrollLeft}px`}),this.areaBodyWestGeo.width=e.left,this.areaBodyWestGeo.height=i-e.top-e.bottom,this.areaBodyWestGeo.top=e.top,this.areaBodyWestGeo.left=0,this.dom.applyStyleInPx(this.areaBodyWest.parent,this.areaBodyWestGeo),this.tableOptions.fixedWestSeparatorBorderVisible&&this.tableModel.getFixedLeftColumnCount()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFixedWest,{width:"1px",height:`${this.areaBodyWestGeo.height}px`,top:`${this.areaBodyWestGeo.top}px`,left:`${this.areaBodyWestGeo.width}px`})):this.dom.applyDisplayNoneStyle(this.borderFixedWest),this.areaBodyEastGeo.width=e.right,this.areaBodyEastGeo.height=i-e.top-e.bottom,this.areaBodyEastGeo.top=e.top,this.areaBodyEastGeo.left=t-e.right,this.dom.applyStyleInPx(this.areaBodyEast.parent,this.areaBodyEastGeo),this.tableOptions.fixedEastSeparatorBorderVisible&&this.tableModel.getFixedLeftColumnCount()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFixedEast,{width:"1px",height:`${this.areaBodyEastGeo.height}px`,top:`${this.areaBodyEastGeo.top}px`,left:`${this.areaBodyEastGeo.left}px`})):this.dom.applyDisplayNoneStyle(this.borderFixedEast),this.areaBodyCenterGeo.width=t-e.left-e.right,this.areaBodyCenterGeo.height=i-e.top-e.bottom,this.areaBodyCenterGeo.top=0,this.areaBodyCenterGeo.left=0,this.dom.applyStyleInPx(this.areaBodyCenter.parent,this.areaBodyCenterGeo),this.dom.applyStyle(this.areaHeaderCenter.parent,{width:`${t-e.left-e.right}px`,height:`${e.top}px`,top:"0",left:`${e.left}px`}),this.dom.applyStyle(this.areaHeaderWest.parent,{width:`${e.left}px`,height:`${e.top}px`,top:"0",left:"0"}),this.dom.applyStyle(this.areaHeaderEast.parent,{width:`${e.right}px`,height:`${e.top}px`,top:"0",left:`${t-e.right}px`}),this.tableOptions.headerSeparatorBorderVisible&&this.tableModel.isHeaderVisibe()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderHeaderBottom,{width:`${t}px`,height:"1px",top:`${e.top}px`,left:"0px"})):this.dom.applyDisplayNoneStyle(this.borderHeaderBottom),this.dom.applyStyle(this.areaFooterWest.parent,{width:`${e.left}px`,height:`${e.bottom}px`,top:`${i-e.bottom}px`,left:"0"}),this.dom.applyStyle(this.areaFooterCenter.parent,{width:`${t-e.left-e.right}px`,height:`${e.bottom}px`,top:`${i-e.bottom}px`,left:`${e.left}px`}),this.dom.applyStyle(this.areaFooterEast.parent,{width:`${e.right}px`,height:`${e.bottom}px`,top:`${i-e.bottom}px`,left:`${t-e.right}px`}),this.tableOptions.footerSeparatorBorderVisible&&this.tableModel.isFooterVisibe()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFooterTop,{width:`${t}px`,height:"1px",top:`${i-e.bottom}px`,left:"0px"})):this.dom.applyDisplayNoneStyle(this.borderFooterTop),this.adjustAfterScrolling()}adjustAfterScrolling(){}resetSizeOfWrapperDiv(){const e=`${this.tableModel.getContentWidthInPixel()}px`,t=`${this.tableModel.getContentHeightInPixel()+1}px`;this.dom.setStyle(this.contentWrapperDiv,"width",e),this.dom.setStyle(this.contentWrapperDiv,"height",t)}}class A{constructor(e,t,i,s,o=!1){this.r1=e,this.c1=t,this.r2=i,this.c2=s,this.gammaRange=o}static create(e){return e.gammaRange===void 0&&(e.gammaRange=!1),new A(e.rowIndex1,e.columnIndex1,e.rowIndex2,e.columnIndex2,e.gammaRange)}static singleCell(e,t){return new A(e,t,e,t)}static singleRow(e){return new A(e,0,e,Number.MAX_SAFE_INTEGER)}static singleColumn(e){return new A(0,e,Number.MAX_SAFE_INTEGER,e)}isInRange(e,t){return e>=this.r1&&e<=this.r2&&t>=this.c1&&t<=this.c2}}class Pe{constructor(e,t){this.tableModel=e,this.areaModel=t,this.colAndRowspanRanges=void 0}init(){if(this.areaModel.getMaxColspan()<2&&this.areaModel.getMaxRowspan()<2)return;this.colAndRowspanRanges=[];const e=this.areaModel.getRowCount(),t=this.tableModel.getColumnCount();for(let i=0;i<e;i++)for(let s=0;s<t;s++){let o=this.areaModel.getColspanAt(i,s),n=this.areaModel.getRowspanAt(i,s);if(o>1||n>1){o===0&&(o=1),n===0&&(n=1);const a=this.areaModel.hasOwnProperty("gammaCells");this.colAndRowspanRanges.push(new A(i,s,i+n-1,s+o-1,a))}}}getRanges(){return this.colAndRowspanRanges?this.colAndRowspanRanges:[]}isInRange(e,t){if(this.colAndRowspanRanges){for(const i of this.colAndRowspanRanges)if(i.isInRange(e,t))return!0}return!1}}class Ve{constructor(e,t,i){this.header=e,this.body=t,this.footer=i}}class Ge extends ke{constructor(e,t,i,s){var n,a;super(e,t,i,s),this.scrollLeft=0,this.scrollViewportLeft=0,this.scrollFactorY=0,this.scrollFactorX=0,this.cleanupFunctions={header:[],body:[],footer:[]},this.tree=!1,this.colAndRowspanModels=new Ve,this.firstVisibleRowIndex=-1,this.draggingTargetColumnIndex=-1,this.removables=[],this.editing=!1,this.tableModel.getSelectionModel?this.getSelectionModel=this.tableModel.getSelectionModel:(n=this.tableOptions)!=null&&n.getSelectionModel&&(this.getSelectionModel=this.tableOptions.getSelectionModel),(a=this.tableOptions)!=null&&a.getFocusModel&&(this.getFocusModel=this.tableOptions.getFocusModel),z(t.getAreaModel("body"))&&(this.tree=!0),["header","body","footer"].forEach(r=>{var d;this.colAndRowspanModels[r]=new Pe(t,t.getAreaModel(r)),(d=this.colAndRowspanModels[r])==null||d.init()})}isEditing(){return this.editing}resetEditorRenderer(){this.editorRenderer=void 0,this.editorRendererRow=-1,this.editorRendererColumn=-1,this.editing=!1}clearSelection(){if(this.getSelectionModel){const e=this.getSelectionModel();e==null||e.clear()}}initRenderEditor(e,t){var s;let i=(s=this.tableModel.getColumnDef(t))==null?void 0:s.getEditRenderer;if(i||(i=this.tableOptions.getEditRenderer),i)if(this.editorRenderer=i(e,t),this.editorRenderer){this.editorRendererRow=e,this.editorRendererColumn=t,this.editing=!0,this.repaint();const o=document.querySelector("input.ge-table-cell-editor-input");o&&o.focus()}else this.resetEditorRenderer()}repaint(){this.adjustAfterScrolling()}adjustAfterScrolling(){var e;for(const t of this.removables)t.remove();this.hideHoverRow(),this.hideHoverColumn(),this.scrollTop=this.scrollViewport.scrollTop,this.scrollLeft=this.scrollViewport.scrollLeft,this.debounce(this.checkForScrollPosSaving.bind(this)),this.scrollFactorY=this.scrollTop/(this.scrollViewport.scrollHeight-this.scrollViewport.clientHeight),this.scrollFactorX=this.scrollLeft/(this.scrollViewport.scrollWidth-this.scrollViewport.clientWidth),isNaN(this.scrollFactorY)&&(this.scrollFactorY=0),isNaN(this.scrollFactorX)&&(this.scrollFactorX=0),this.adjustBody(),this.adjustArea("footer"),this.adjustArea("header"),this.tableOptions.tableTopBorderVisible&&this.removables.push(this.dom.addHorizontalBorder(new T(0,this.hostElement.clientWidth,1,0),this.hostElement,"ge-table-border")),this.tableOptions.tableBottomBorderVisible&&this.removables.push(this.dom.addHorizontalBorder(new T(0,this.hostElement.clientWidth,1,this.hostElement.clientHeight-1),this.hostElement,"ge-table-border")),this.tableModel.getFixedLeftColumnCount()>0&&this.removables.push(this.dom.addVerticalBorder(new T(this.areaBodyWest.child.clientWidth,1,this.hostElement.clientHeight,0),this.hostElement,"ge-table-body-west-vertical-border")),((e=this.tableModel.getAreaModel("header"))==null?void 0:e.getRowCount())>0&&this.removables.push(this.dom.addHorizontalBorder(new T(0,this.hostElement.clientWidth,1,this.areaHeaderCenter.child.clientHeight),this.hostElement,"ge-table-body-west-vertical-border"))}checkForScrollPosSaving(){var e,t;this.storeScrollPosStateService&&((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.autoRestoreScrollPosition)&&this.storeScrollPosStateService.updateScrollOffset([this.scrollLeft,this.scrollTop])}updateCells(e){e.forEach(t=>this.tableModel.getAreaModel(t.area).setValue(t.rowIndex,t.columnIndex,t.value)),this.repaint()}getAreaAndSideIdentByAttr(e){if(e){const t=this.getStringByAttr(e,"data-area"),i=this.getStringByAttr(e,"data-side");if(i&&t)return[t,i]}return[void 0,void 0]}getArea(e,t){if(e==="header"){if(t==="west")return this.areaHeaderWest;if(t==="center")return this.areaHeaderCenter;if(t==="east")return this.areaHeaderEast}else if(e==="body"){if(t==="west")return this.areaBodyWest;if(t==="center")return this.areaBodyCenter;if(t==="east")return this.areaBodyEast}else if(e==="footer"){if(t==="west")return this.areaFooterWest;if(t==="center")return this.areaFooterCenter;if(t==="east")return this.areaFooterEast}throw Error(`Wrong area identifier: row:${e}, col:${t}`)}adjustBody(){const e=this.areaBodyCenterGeo.height-this.tableModel.getContentHeightInPixel(),t=this.scrollFactorY*e;this.dom.setStyle(this.contentDiv,"top",`${this.scrollTop}px`),this.dom.setStyle(this.contentDiv,"left",`${this.scrollViewport.scrollLeft}px`),this.adjustArea("body",t)}getNumberByAttr(e,t){var i;if(e){const s=(i=e.closest("["+t+"]"))==null?void 0:i.getAttribute(t);if(s)return Number(s)}return-1}getStringByAttr(e,t){var i;if(e){const s=(i=e.closest("["+t+"]"))==null?void 0:i.getAttribute(t);if(s)return s}return""}adjustArea(e,t=0){var u;const i=this.getArea(e,"west"),s=this.getArea(e,"center"),o=this.getArea(e,"east"),n=s.child.clientHeight;i.child.innerText="",s.child.innerText="",o.child.innerText="";const a=0,r=this.areaBodyCenterGeo.width,d=this.tableModel.getPadding(),h=this.tableModel.getAreaModel(e),p=h.getRowCount();for(;this.cleanupFunctions[e].length;){const S=this.cleanupFunctions[e].shift();S&&S()}let g=t;const f=this.tableModel.getColumnCount(),c=this.tableModel.getFixedRightColumnCount(),b=this.tableModel.getFixedLeftColumnCount();for(let S=0;S<p;S++){const x=g,w=S===p-1,C=this.tableModel.getRowHeight(e,S);if(x+C>0){this.firstVisibleRowIndex=S;let v={left:a,width:r,height:C,top:x,index:S},m=this.dom.addRowDiv(s,v,S,e,"center");const R=b;if(this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"center",areaModel:h,geo:v,parent:m,rowIndex:S,columnIndexStart:R,columnIndexEnd:f-c-1,verticalFixed:!1,lastRowOfModel:w}),d.left>0&&(v={left:a,width:this.areaBodyWestGeo.width,height:C,top:x,index:S},m=this.dom.addRowDiv(i,v,S,e,"west"),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"west",areaModel:h,geo:v,parent:m,rowIndex:S,columnIndexStart:0,columnIndexEnd:R-1,verticalFixed:!0,lastRowOfModel:w})),d.right>0&&(v={left:a,width:this.areaBodyEastGeo.width,height:C,top:x,index:S},m=this.dom.addRowDiv(o,v,S,e,"east"),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"east",areaModel:h,geo:v,parent:m,rowIndex:S,columnIndexStart:f-c,columnIndexEnd:f-1,verticalFixed:!0,lastRowOfModel:w})),e==="header"&&this.tree&&S===p-1){const E=this.dom.applyStyle(this.dom.setAttribute(this.dom.addDiv(m,new T(16,20,20,8)),"data-ge-action","toggleExpandCollapseAll"),{cursor:"pointer"}),M=this.tableOptions.treeOptions.arrowExpandCollapseAll;if(M){const B=this.dom.domService.createText(M.content);this.dom.domService.appendChild(E,B),M.style&&this.dom.applyStyleString(E,M.style)}}}if(g=g+C,g>n)break}if(this.colAndRowspanModels&&this.colAndRowspanModels[e]){const S=((u=this.colAndRowspanModels[e])==null?void 0:u.getRanges())??[];if(S.length)for(const x of S){let w=0,C=s.child,v="center";if(x.c1<b)C=i.child,v="west";else if(c>0&&x.c1>=f-c)C=o.child,v="east";else{const m=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();w=this.scrollFactorX*m-this.areaBodyWestGeo.width,v="center"}this.drawBigCell(x,w,t,h,C,v)}}}drawBigCell(e,t,i,s,o,n){const a=i+this.getRowHeights(0,e.r1-1,s).reduce((u,S)=>u+S,0),r=this.tableModel.getColumnCount(),d=this.tableModel.getFixedRightColumnCount();let h=0;d>0&&e.c1>=r-d&&(h=r-d);const p=t+this.getColumnWidths(h,e.c1-1).reduce((u,S)=>u+S,0),g=this.getRowHeights(e.r1,e.r2,s).reduce((u,S)=>u+S,0),f=this.getColumnWidths(e.c1,e.c2).reduce((u,S)=>u+S,0);let c=!1;const b=this.getSelectionModel?this.getSelectionModel():void 0;b&&(c=b.getSelectionCount(e.r1,e.c1)>0),e.gammaRange?(console.info("TODO here",e),this.renderCell({areaModel:s,areaIdent:s.areaIdent,sideIdent:n,rowIndex:e.r1,columnIndex:e.c1,left:p,top:a,width:f,height:g,parent:o,cellSelected:c,lastRowOfModel:!0,gammaRange:e.gammaRange})):this.renderCell({areaModel:s,areaIdent:s.areaIdent,sideIdent:n,rowIndex:e.r1,columnIndex:e.c1,left:p,top:a,width:f,height:g,parent:o,cellSelected:c,lastRowOfModel:!0,gammaRange:e.gammaRange}),s.areaIdent==="header"&&this.tableOptions.columnsResizable&&this.renderHeaderCellResizeHandle({rowIndex:e.r1,columnIndex:e.c1,cellLeft:p,cellTop:a,cellWidth:f,cellHeight:g,parent:o})}findRowOfImportantRowspanCell(e,t,i){const s=e.getMaxRowspan();for(let o=t-1;o>-1;o--){const n=e.getRowspanAt(o,i);if(n>1&&o+n+1>=t)return o;if(t-o>s)return-1}return-1}adjustColumnsToRowParent({areaIdent:e,sideIdent:t,areaModel:i,geo:s,parent:o,rowIndex:n,columnIndexStart:a,columnIndexEnd:r,verticalFixed:d=!1,lastRowOfModel:h=!1}){var b;this.scrollViewportLeft=this.scrollViewport.scrollLeft;let p=0;if(!d){const u=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();p=this.scrollFactorX*u}const g=0,f=!!(e==="body"&&t);let c=p;for(let u=a;u<=r;u++){const S=c,x=this.tableModel.getColumnWidth(u);if(x>0&&S+x>0){let w=s.height;const C=i.getRowspanAt(n,u),v=i.getColspanAt(n,u);C>1&&(w=this.getRowHeights(n,n+C-1,i).reduce((E,M)=>E+M,0));let m=x;v>1&&(m=this.getColumnWidths(u,u+v-1).reduce((E,M)=>E+M,0));let R=!1;if(this.colAndRowspanModels&&this.colAndRowspanModels[e]&&(b=this.colAndRowspanModels[e])!=null&&b.isInRange(n,u)&&(R=!0),this.draggingTargetColumnIndex===u&&e!=="header"){this.renderDragTargetDiv(o,S,g,m,w);const E={left:S,top:g,width:m,height:w};this.dom.addColumnBorderDivs(this.tableOptions,o,E,e,t)}else{const E=this.renderSelectedBackgroundDiv(R,f,t,i,n,u,o,S,g,m,w);R||this.renderCell({areaModel:i,areaIdent:e,sideIdent:t,rowIndex:n,columnIndex:u,left:S,top:g,width:m,height:w,parent:o,cellSelected:E,lastRowOfModel:h,gammaRange:!0}),e==="header"&&this.tableOptions.columnsResizable&&this.renderHeaderCellResizeHandle({rowIndex:n,columnIndex:u,cellLeft:S,cellTop:g,cellWidth:m,cellHeight:w,parent:o})}}if(c=c+x,c>this.areaBodyCenterGeo.width)break}this.tableOptions.verticalBorderVisible&&this.dom.addVerticalBorder(new T(c-1,1,s.height,0),o)}getTreeArrowColumnIndex(){return this.tableOptions.showCheckboxWihoutExtraColumn?0:this.tableModel.isRowCheckboxVisible()?1:0}addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:i,rowIndex:s,index:o,left:n,width:a,height:r,top:d,parent:h,lastRowOfModel:p}){var Q;const f=this.editorRenderer&&this.editorRendererRow===s&&this.editorRendererColumn===o?this.editorRenderer:e.getCellRenderer(s,o),c={left:n,width:a,height:r,top:d,index:o},b=e.getRowByIndex(s);let u="none";if(o===this.getTreeArrowColumnIndex()&&j(b)){const y=b;(Q=y.children)!=null&&Q.length?y.expanded?u="expanded":u="collapsed":u="hidden"}let x;if(t==="header"){const y=this.tableModel.getColumnDef(o);(!(y!=null&&y.sortIconVisible)||y!=null&&y.sortIconVisible())&&(x=y==null?void 0:y.sortState)}const w=e.getValueAt(s,o),C=f?"":`${w}`,v=e.isRowChecked(s),m=this.dom.addColumnDiv(h,c,s,o,t,i,C,u,this.tableOptions,v,x),R=e.getTooltipAt(s,o);R&&this.dom.setAttribute(m,"title",R);const E=this.tableModel.getColumnDef(o);E&&E.classes[t]&&this.dom.addClasses(E.classes[t],m);let M;f&&(M=f.render(m,s,o,t,e,w,this.dom.domService));const B=e.getCustomClassesAt(s,o);if(B.length&&this.dom.addClasses(B,m),this.dom.addColumnBorderDivs(this.tableOptions,h,c,t,i),p&&this.dom.addHorizontalBorder({left:n,width:a,height:r,top:d+r},h),this.getFocusModel&&t==="body"){const y=this.getFocusModel();y!=null&&y.hasFocus(s,o)&&this.dom.addFocusBorderDivs(h,c,{})}t==="header"&&this.dom.setAttribute(m,"data-ge-action","drag-column");const H=e.getCustomStyleAt(s,o);if(H)for(const y in H)this.dom.setStyle(m,y,H[y]);return[m,M]}getColumnWidths(e,t){const i=[];for(let s=e;s<=t;s++)i.push(this.tableModel.getColumnWidth(s));return i}getRowHeights(e,t,i){const s=[];for(let o=e;o<=t;o++)s.push(i.getRowHeight(o));return s}adjustHoverRows(e){if(this.tableOptions.hoverRowVisible&&e.rowIndex>-1){const t=this.hostElement.clientWidth,i=this.tableModel.getAreaModel("body").getRowHeight(e.rowIndex),s=e.rowTop+this.areaHeaderCenter.parent.clientHeight-this.scrollTop;this.dom.applyStyle(this.hoverRow,{left:"0",top:s+"px",width:t+"px",height:i+"px",display:"block"})}else this.hideHoverRow()}hideHoverRow(){this.dom.applyStyle(this.hoverRow,{display:"none"})}adjustHoverColumns(e){if(this.tableOptions.hoverColumnVisible&&e.rowIndex>-1){const t=this.hostElement.clientHeight,i=this.tableModel.getColumnWidth(e.columnIndex),s=this.areaBodyWestGeo.width,o=e.columnLeft+this.tableModel.getPadding().left-this.scrollLeft-s;this.dom.applyStyle(this.hoverColumn,{left:o+"px",top:"0px",width:i+"px",height:t+"px",display:"block"})}else this.hideHoverColumn()}hideHoverColumn(){this.dom.applyStyle(this.hoverColumn,{display:"none"})}debounce(e,t=1e3){this.debounceTimeout&&clearTimeout(this.debounceTimeout),this.debounceTimeout=setTimeout(e.bind(this),t)}renderDragTargetDiv(e,t,i,s,o){const n=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass("ge-table-drop-zone",e));return this.dom.setStyle(n,"left",`${t}px`),this.dom.setStyle(n,"top",`${i}px`),this.dom.setStyle(n,"width",`${s}px`),this.dom.setStyle(n,"height",`${o}px`),n}renderSelectedBackgroundDiv(e,t,i,s,o,n,a,r,d,h,p){let g=!1;if(!e&&t&&s.isSelectable(o,n)&&this.getSelectionModel){const f=this.getSelectionModel();if(f){const c=f.getSelectionCount(o,n);g=c>0;for(let b=0;b<c;b++){const u=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass(`ge-table-${s.areaIdent}-${i}-selected-range`,a));this.dom.setStyle(u,"left",`${r}px`),this.dom.setStyle(u,"top",`${d}px`),this.dom.setStyle(u,"width",`${h}px`),this.dom.setStyle(u,"height",`${p}px`)}}}return g}renderCell({areaModel:e,areaIdent:t,sideIdent:i,rowIndex:s,columnIndex:o,left:n,top:a,width:r,height:d,parent:h,cellSelected:p,lastRowOfModel:g,gammaRange:f}){const[c,b]=this.addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:i,rowIndex:s,index:o,left:n,width:r,height:d,top:a,parent:h,lastRowOfModel:g,gammaRange:f});p&&this.dom.addClass(`ge-table-${t}-${i}-selected-range`,c),b&&this.cleanupFunctions[t].push(b)}renderHeaderCellResizeHandle({rowIndex:e,columnIndex:t,cellLeft:i,cellTop:s,cellWidth:o,cellHeight:n,parent:a}){const r=this.dom.domService,d=this.tableOptions.columnResizeHandleWidthInPx??2,h=r.createElement("div");r.setAttribute(h,"data-col-index",`${t}`),r.setAttribute(h,"data-row-index",`${e}`),r.setAttribute(h,"data-area","header"),r.setAttribute(h,"data-ge-action","resize-column"),r.addClass(h,"ge-table-column-resize-handle"),r.setStyle(h,"display","clip"),r.setStyle(h,"position","absolute"),r.setStyle(h,"cursor","col-resize"),r.setStyle(h,"left",`${i+o-d}px`),r.setStyle(h,"top",`${s}px`),r.setStyle(h,"width",`${d}px`),r.setStyle(h,"height",`${n}px`),r.appendChild(a,h)}}class Ne{constructor(e,t){this.columnIndex=e,this.sortState=t}}class je{constructor(e){this.tableScope=e,this.tableScope.hostElement.addEventListener("change",this.onHostElementChanged.bind(this))}onHostElementChanged(e){if(e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||e.target instanceof HTMLTextAreaElement){const t=e.target,i=t.getAttribute("data-area"),s=t.getAttribute("data-row-index"),o=t.getAttribute("data-col-index");if(i&&s&&o){const n=Y(i),a=Number(s),r=Number(o);this.tableScope.updateModelValueAfterEdit(n,a,r,t.value)}}}}class ze{constructor(e=-1,t=-1){this.rowIndex=e,this.columnIndex=t}}class U{constructor(e){this.cells=e}static createSingle(e,t){return new U([new ze(e,t)])}}class Xe{constructor(e){var t,i;this.tableScope=e,(t=this.tableScope.tableOptions)!=null&&t.getSelectionModel&&(this.getSelectionModel=this.tableScope.tableOptions.getSelectionModel),(i=this.tableScope.tableOptions)!=null&&i.getFocusModel&&(this.getFocusModel=this.tableScope.tableOptions.getFocusModel)}onMouseClicked(e,t){var o,n,a,r,d,h,p;let i=!1,s=!1;if(this.getSelectionModel&&this.getFocusModel){const g=this.getSelectionModel(),f=this.getFocusModel();g&&f&&(f.hasFocus(e.rowIndex,e.columnIndex)||(f.setFocus(e.rowIndex,e.columnIndex),i=!0),(o=e.originalEvent)!=null&&o.shiftKey||g.hasSelection()&&(g.clear(),i=!0),(n=e.originalEvent)!=null&&n.shiftKey&&this.previousEvt?(g.addSelection(this.createRangeByEvents(e,this.previousEvt)),s=!0,i=!0):(a=e.originalEvent)!=null&&a.ctrlKey||(r=e.originalEvent)!=null&&r.metaKey?(g.addSelection(A.singleCell(e.rowIndex,e.columnIndex)),s=!0,i=!0):(d=e.originalEvent)!=null&&d.altKey&&((h=e.originalEvent)!=null&&h.ctrlKey||(p=e.originalEvent)!=null&&p.metaKey)&&(g.removeSelection(A.singleCell(e.rowIndex,e.columnIndex)),s=!0,i=!0))}return s?this.previousEvt=void 0:this.previousEvt=e==null?void 0:e.clone(),i}onActionTriggered(e){if(this.getSelectionModel&&this.getFocusModel){const t=this.getSelectionModel(),i=this.getFocusModel();if(t&&i){if(e==="SELECT_ALL")return t.selectAll(),this.tableScope.repaint(),!0;if(e==="DESELECT_ALL")return t.clear(),this.tableScope.repaint(),!0;if(e==="TOGGLE_SELECTION"){const[s,o]=i.getFocus();return t.togglePoint(s,o),this.tableScope.repaint(),!0}}}return!1}createRangeByEvents(e,t){t||(t=e);const i=Math.min(e.rowIndex,t==null?void 0:t.rowIndex),s=Math.max(e.rowIndex,t==null?void 0:t.rowIndex),o=Math.min(e.columnIndex,t==null?void 0:t.columnIndex),n=Math.max(e.columnIndex,t==null?void 0:t.columnIndex);return A.create({rowIndex1:i,columnIndex1:o,rowIndex2:s,columnIndex2:n})}}class Ke{get(){return{f2:"START_EDITING",space:"TOGGLE_SELECTION","ctrl+num_add":"SELECT_ALL","ctrl+a":"SELECT_ALL","ctrl+shift+a":"DESELECT_ALL","ctrl+x":"DESELECT_ALL","ctrl+num_subtract":"DESELECT_ALL","cmd -":"DESELECT_ALL",arrowup:"NAVIGATE_UP",arrowdown:"NAVIGATE_DOWN",arrowleft:"NAVIGATE_LEFT",arrowright:"NAVIGATE_RIGHT"}}}class Ye{get(){return{f2:"START_EDITING",space:"TOGGLE_SELECTION","ctrl+num_add":"SELECT_ALL","cmd+a":"SELECT_ALL","ctrl+a":"SELECT_ALL","cmd+x":"DESELECT_ALL","cmd+shift+a":"DESELECT_ALL","ctrl+shift+a":"DESELECT_ALL","ctrl+num_subtract":"DESELECT_ALL","ctrl -":"DESELECT_ALL",arrowup:"NAVIGATE_UP",arrowdown:"NAVIGATE_DOWN",arrowleft:"NAVIGATE_LEFT",arrowright:"NAVIGATE_RIGHT"}}}class qe{constructor(e){this.tableScope=e,this.shortcutActionIdMapping={},this.listener=[],this.listener.push(e),this.init()}addListener(e){this.listener.includes(e)||this.listener.push(e)}init(){this.isMacintosh()?Object.assign(this.shortcutActionIdMapping,new Ye().get()):Object.assign(this.shortcutActionIdMapping,new Ke().get()),Object.assign(this.shortcutActionIdMapping,this.tableScope.tableOptions.shortcutActionIdMapping),this.isDebug()&&console.debug("ShortcutService",this.shortcutActionIdMapping),this.tableScope.hostElement.addEventListener("keydown",this.onKeyDown.bind(this))}isMacintosh(){return navigator.platform.indexOf("Mac")>-1}isDebug(){return this.isLocalhost()}isLocalhost(){return location.hostname==="localhost"||location.hostname==="127.0.0.1"}onKeyDown(e){const t=this.findEnty(e);t&&this.emit(t)&&(e.preventDefault(),e.stopPropagation())}emit(e){this.isDebug()&&console.debug("ShortcutService emit:",e);let t=!1;for(const i of this.listener)i.onActionTriggered(e)&&(t=!0);return t}findEnty(e){const t=this.getTokenByEvent(e);this.isDebug()&&console.debug("ShortcutService tokens:",t);for(const i in this.shortcutActionIdMapping){const s=i.replace(/opt/g,"alt").replace(/cmd/g,"meta").split(/[\+ ]/g).sort();if(this.areTokensEquals(t,s))return this.shortcutActionIdMapping[i]}}areTokensEquals(e,t){if(e.length!==t.length||e.length===0)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}getTokenByEvent(e){const t=[];return e.altKey&&t.push("alt"),e.shiftKey&&t.push("shift"),e.ctrlKey&&t.push("ctrl"),e.metaKey&&t.push("meta"),e.code&&t.push(e.code.toLowerCase().replace(/key/g,"")),t.sort()}}class ie{onCheckboxChanged(e){}onContextmenu(e){}onModelChanged(e){}onMouseClicked(e){}onMouseDragging(e){}onMouseDraggingEnd(e){}onMouseMoved(e){}}class de{setStyle(e,t,i){return e.style[t]=i,e}appendText(e,t){const i=this.createText(t);return this.appendChild(e,i),i}addClass(e,t){return t.includes(" ")?t.split(" ").forEach(i=>e.classList.add(i)):e.classList.add(t),e}appendChild(e,t){e.appendChild(t)}createElement(e){return document.createElement(e)}createText(e){return document.createTextNode(e)}setAttribute(e,t,i){e.setAttribute(t,i)}}class Ue{render(e,t,i,s,o,n,a){if(o.isEditable(t,i)){a.addClass(e,"ge-table-row-input-div");const r=o.getValueAt(t,i);e.innerHTML=`
9
9
  <input
10
10
  type="text"
11
- value="${n}"
11
+ value="${r}"
12
12
  autofocus
13
13
  onfocus="this.setSelectionRange(0, this.value.length)"
14
14
  data-listen="change"
15
- data-area="${i}"
15
+ data-area="${s}"
16
16
  data-row-index="${t}"
17
- data-col-index="${s}"
17
+ data-col-index="${i}"
18
18
  data-input-type="text"
19
19
  style="width:calc(100% - 8px);height:100%;border:0;padding:0 0 0 8px;"
20
- class="ge-table-cell-editor-input">`}}}class Qe{constructor(e="none",t="single"){this.selectionType=e,this.selectionMode=t,this.ranges=[],this.negativeRanges=[],this.allSelected=!1}getSelectionCount(e,t){let s=0;for(const i of this.ranges)i.isInRange(e,t)&&s++;return this.allSelected&&s++,this.isInNegativeRange(e,t)&&(s=0),s}isInNegativeRange(e,t){for(const s of this.negativeRanges)if(s.isInRange(e,t))return!0;return!1}getRanges(){return this.ranges}clear(){this.ranges=[],this.negativeRanges=[],this.allSelected=!1}hasSelection(){return!!this.ranges.length}selectAll(){this.allSelected=!0}addSelection(e){this.addRange(e)}removeSelection(e){if(this.selectionType==="none")return;let t=e;this.selectionType==="row"?t=A.singleRow(e.r1):this.selectionType==="column"&&(t=A.singleColumn(e.c1)),this.negativeRanges.push(t)}togglePoint(e,t){this.getSelectionCount(e,t)>0?this.removeSelection(A.singleCell(e,t)):this.addSelection(A.singleCell(e,t))}addRange(e){this.selectionType!=="none"&&(this.allSelected=!1,this.selectionMode==="single"&&(this.ranges=[]),this.selectionType==="row"?(e.c1=0,e.c2=Number.MAX_SAFE_INTEGER):this.selectionType==="column"?(e.r1=0,e.r2=Number.MAX_SAFE_INTEGER):this.selectionType==="cell"?(e.r2=e.r1,e.c2=e.c1):this.selectionType,this.ranges.push(e))}}class Ze{constructor(e="none"){this.selectionType=e,this.rowIndex=-1,this.columnIndex=-1,this.changed=!1}clearChanged(){this.changed=!1}hasChanged(){return this.changed}clear(){this.rowIndex=-1,this.columnIndex=-1}setFocus(e,t){(this.rowIndex!==e||this.columnIndex!==t)&&(this.rowIndex=e,this.columnIndex=t,this.changed=!0)}hasFocus(e,t){return this.rowIndex===e&&this.columnIndex===t}getFocus(){return[this.rowIndex,this.columnIndex]}}const et=new Qe,tt=new Ze("cell");class st{constructor(){this.overflowX="auto",this.overflowY="auto",this.horizontalBorderVisible=!0,this.verticalBorderVisible=!0,this.footerSeparatorBorderVisible=!0,this.headerSeparatorBorderVisible=!0,this.fixedEastSeparatorBorderVisible=!0,this.fixedWestSeparatorBorderVisible=!0,this.tableTopBorderVisible=!0,this.tableBottomBorderVisible=!0,this.hoverRowVisible=!0,this.hoverColumnVisible=!0,this.columnsResizable=!0,this.columnsDraggable=!0,this.columnResizeHandleWidthInPx=4,this.defaultRowHeights={header:34,body:34,footer:34},this.footerVerticalSeparator=!1,this.headerToggleExpandCollapseIcons=!1,this.headerVerticalSeparator=!1,this.treeOptions=new re,this.showCheckboxWihoutExtraColumn=!1,this.externalFilterFunction=void 0,this.sortedOptions=new le,this.sortOrder=["asc","desc"],this.getEditRenderer=(e,t)=>new Je,this.getSelectionModel=()=>et,this.getFocusModel=()=>tt}}class it{setStyle(e,t,s){return e.style[t]=s,e}appendText(e,t){const s=this.createText(t);return this.appendChild(e,s),s}addClass(e,t){return t.includes(" ")?t.split(" ").forEach(s=>e.classList.add(s)):e.classList.add(t),e}appendChild(e,t){e.appendChild(t)}createElement(e){return document.createElement(e)}createText(e){return document.createTextNode(e)}setAttribute(e,t,s){e.setAttribute(t,s)}}function ot(l){let e;return{c(){e=pe("div"),e.innerHTML="",ue(e,"class","ge-table"),$(e,"width","100%"),$(e,"height","100%"),$(e,"background-color","transparent"),$(e,"padding","0"),$(e,"margin","0")},m(t,s){ce(t,e,s),l[3](e)},p:_,i:_,o:_,d(t){t&&ie(e),l[3](null)}}}function rt(l,e,t){let{tableModel:s}=e,{tableOptions:i=new st}=e,o;const r=Q.createEventDispatcher();Q.onMount(()=>{const n={onCheckboxChanged:h=>{r("checkboxChanged",h)},onContextmenu:h=>{r("contextmenu",h)},onModelChanged:h=>{r("modelChanged",h)},onMouseClicked:h=>{r("mouseClicked",h)},onMouseDragging:h=>{r("mouseDragging",h)},onMouseDraggingEnd:h=>{r("mouseDraggingEnd",h)},onMouseMoved:h=>{r("mouseMoved",h)}},d=new Ue(o,s,new it,i,n);d.firstInit(),r("tableReady",d.getApi())});function a(n){W[n?"unshift":"push"](()=>{o=n,t(0,o)})}return l.$$set=n=>{"tableModel"in n&&t(1,s=n.tableModel),"tableOptions"in n&&t(2,i=n.tableOptions)},[o,s,i,a]}class lt extends Ae{constructor(e){super(),Ee(this,e,rt,ot,de,{tableModel:1,tableOptions:2})}}class nt{constructor(e){this.Component=e}render(e,t,s,i,o,r,a){const n=new this.Component({target:e,props:{cellDiv:e,rowIndex:t,columnIndex:s,areaIdent:i,areaModel:o,cellValue:r}});return()=>{n.$destroy()}}}exports.ComponentRendererWrapper=nt;exports.GuiexpertTable=lt;
20
+ class="ge-table-cell-editor-input">`}}}class Je{constructor(e="none",t="single"){this.selectionType=e,this.selectionMode=t,this.ranges=[],this.negativeRanges=[],this.allSelected=!1}getSelectionCount(e,t){let i=0;for(const s of this.ranges)s.isInRange(e,t)&&i++;return this.allSelected&&i++,this.isInNegativeRange(e,t)&&(i=0),i}isInNegativeRange(e,t){for(const i of this.negativeRanges)if(i.isInRange(e,t))return!0;return!1}getRanges(){return this.ranges}clear(){this.ranges=[],this.negativeRanges=[],this.allSelected=!1}hasSelection(){return!!this.ranges.length}selectAll(){this.allSelected=!0}addSelection(e){this.addRange(e)}removeSelection(e){if(this.selectionType==="none")return;let t=e;this.selectionType==="row"?t=A.singleRow(e.r1):this.selectionType==="column"&&(t=A.singleColumn(e.c1)),this.negativeRanges.push(t)}togglePoint(e,t){this.getSelectionCount(e,t)>0?this.removeSelection(A.singleCell(e,t)):this.addSelection(A.singleCell(e,t))}addRange(e){this.selectionType!=="none"&&(this.allSelected=!1,this.selectionMode==="single"&&(this.ranges=[]),this.selectionType==="row"?(e.c1=0,e.c2=Number.MAX_SAFE_INTEGER):this.selectionType==="column"?(e.r1=0,e.r2=Number.MAX_SAFE_INTEGER):this.selectionType==="cell"?(e.r2=e.r1,e.c2=e.c1):this.selectionType,this.ranges.push(e))}}class Qe{constructor(e="none"){this.selectionType=e,this.rowIndex=-1,this.columnIndex=-1,this.changed=!1}clearChanged(){this.changed=!1}hasChanged(){return this.changed}clear(){this.rowIndex=-1,this.columnIndex=-1}setFocus(e,t){(this.rowIndex!==e||this.columnIndex!==t)&&(this.rowIndex=e,this.columnIndex=t,this.changed=!0)}hasFocus(e,t){return this.rowIndex===e&&this.columnIndex===t}getFocus(){return[this.rowIndex,this.columnIndex]}}const Ze=new Je,et=new Qe("cell");class he{constructor(){this.overflowX="auto",this.overflowY="auto",this.horizontalBorderVisible=!0,this.verticalBorderVisible=!0,this.footerSeparatorBorderVisible=!0,this.headerSeparatorBorderVisible=!0,this.fixedEastSeparatorBorderVisible=!0,this.fixedWestSeparatorBorderVisible=!0,this.tableTopBorderVisible=!0,this.tableBottomBorderVisible=!0,this.hoverRowVisible=!0,this.hoverColumnVisible=!0,this.columnsResizable=!0,this.columnsDraggable=!0,this.columnResizeHandleWidthInPx=4,this.defaultRowHeights={header:34,body:34,footer:34},this.footerVerticalSeparator=!1,this.headerToggleExpandCollapseIcons=!1,this.headerVerticalSeparator=!1,this.treeOptions=new ne,this.showCheckboxWihoutExtraColumn=!1,this.externalFilterFunction=void 0,this.sortedOptions=new ae,this.sortOrder=["asc","desc"],this.getEditRenderer=(e,t)=>new Ue,this.getSelectionModel=()=>Ze,this.getFocusModel=()=>et}}class J extends Ge{constructor(e,t,i,s,o){var n;if(super(e,t,new $e(i),s),this.eventListener=o,this.selectionService=new Xe(this),this.api=new Le(this),this.mouseStartAction="",this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,o||(this.eventListener=new ie),(n=this.tableOptions)!=null&&n.autoRestoreOptions){const a=this.tableOptions.autoRestoreOptions,r=a.getStorageKeyFn;r&&(a.autoRestoreScrollPosition&&(this.storeScrollPosStateService=new _e(r)),a.autoRestoreCollapsedExpandedState&&(this.storeStateCollapsedExpandService=new We(r)),a.autoRestoreSortingState&&(this.storeSortingService=new He(r)))}this.mouseHandler=new Oe(this),this.inputHandler=new je(this),this.shortcutService=new qe(this),this.shortcutService.addListener(this.selectionService)}static create(e,t,i=new he,s=new ie,o=new de){return new J(e,t,o,i,s)}onActionTriggered(e){if(e==="NAVIGATE_DOWN"&&this.changeFocusCell(0,1)||e==="NAVIGATE_UP"&&this.changeFocusCell(0,-1)||e==="NAVIGATE_LEFT"&&this.changeFocusCell(-1,0)||e==="NAVIGATE_RIGHT"&&this.changeFocusCell(1,0))return!0;if(e==="START_EDITING"&&this.getFocusModel){const t=this.getFocusModel();if(t){const[i,s]=t.getFocus();this.tableModel.getBodyModel().isEditable(i,s)&&(this.clearSelection(),this.initRenderEditor(i,s))}return!0}return!1}updateModelValueAfterEdit(e,t,i,s){e==="body"&&this.tableModel.getAreaModel(e).setValue(t,i,s)&&(this.resetEditorRenderer(),this.repaint(),this.eventListener.onModelChanged(U.createSingle(t,i)),this.hostElement.focus())}getApi(){return this.api}firstInit(){var e;return this.tableModel.init(),(e=this.tableOptions)!=null&&e.externalFilterFunction&&this.externalFilterChanged(!1),this.autoRestoreCollapsedExpandedState(),this.autoRestoreSortingState(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows(),this.autoRestoreScrollPosition(),this}createGeMouseEvent(e){const t=new K;if(t.originalEvent=e,e){const i=e.target;if([t.areaIdent,t.sideIdent]=this.getAreaAndSideIdentByAttr(i),t.rowIndex=this.getNumberByAttr(i,"data-row-index"),t.columnIndex=this.getNumberByAttr(i,"data-col-index"),t.action=this.getStringByAttr(i,"data-ge-action"),t.areaIdent){const s=this.tableModel.getAreaModel(t.areaIdent);t.rowTop=s.getYPosByRowIndex(t.rowIndex)}if(t.columnLeft=this.tableModel.getXPosByColumnIndex(t.columnIndex),e.ctrlKey&&e.altKey){const s=e.clientY-this.hostElement.offsetTop-this.areaHeaderCenter.parent.clientHeight,o=e.clientX-this.hostElement.offsetLeft-this.areaBodyWestGeo.width;this.debugOnce(o,s)}}return t}onMouseDown(e){e.columnIndex>-1&&e.action&&["resize-column","drag-column"].includes(e.action)&&(this.mouseStartWidth=this.tableModel.getColumnWidth(e.columnIndex),this.mouseStartAction=e.action,this.mouseStartColumnIndex=e.columnIndex,this.mouseStartAction==="drag-column"&&(this.dragFrom=this.mouseStartColumnIndex))}mouseDraggingOnFrame(e){this.eventListener.onMouseDragging(e),this.mouseEvent=e,this.mouseStartColumnIndex>-1&&this.mouseStartAction==="resize-column"&&this.tableOptions.columnsResizable?this.resizeColumn(e):this.mouseStartAction==="drag-column"&&e.columnIndex>-1&&this.tableOptions.columnsDraggable&&(this.draggingTargetColumnIndex=e.columnIndex,this.dragTo=this.draggingTargetColumnIndex,this.dragFrom>-1&&this.dragTo>-1&&this.dragFrom!==this.dragTo&&(this.tableModel.changeColumnOrder(this.dragFrom,this.dragTo),this.dragFrom=this.dragTo,this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()),this.repaint())}mouseDraggingEndOnFrame(e){this.eventListener.onMouseDraggingEnd(e),this.draggingTargetColumnIndex=-1,this.mouseStartAction==="resize-column"?this.resizeColumn(e):this.mouseStartAction==="drag-column"&&this.repaint(),this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,this.mouseStartAction=""}mouseMove(e){this.eventListener.onMouseMoved(e),this.adjustHoverRows(e),this.adjustHoverColumns(e)}contextmenu(e){this.eventListener.onContextmenu(e)}toggleExpandCollapseAll(e=!0){var i;const t=this.tableModel.getBodyModel();z(t)&&(t.toggleExpandCollapseAll(e),this.repaint(),(i=this.storeStateCollapsedExpandService)==null||i.collapsedStateAll(e))}toggleRowCheckbox(e,t,i){var r;const s=this.tableModel.getAreaModel(i),o=s.isRowChecked(e),n=o===void 0||o==="semi"||o==="none";s.setRowChecked(e,n),this.repaint();const a=(r=s.rowSelectionModel)==null?void 0:r.getCheckedRows();this.eventListener.onCheckboxChanged(a||[])}onMouseClicked(e,t){let i=this.selectionService.onMouseClicked(e,t);if(!i&&this.getFocusModel){const s=this.getFocusModel();s&&(i=s.hasChanged(),s.clearChanged(),i&&this.resetEditorRenderer())}this.eventListener.onMouseClicked(e),i&&this.debounce(this.repaint.bind(this),10)}externalFilterChanged(e=!0){const t=this.tableOptions.externalFilterFunction;t&&(e&&this.clearSelectionModel(),this.tableModel.externalFilterChanged(t),this.scrollViewport.scrollTo(0,0),this.tableModel.recalcHeightAndPadding(),this.resetSizeOfWrapperDiv(),this.repaint())}onHeaderDblClicked(e,t,i){var o,n;const s=this.tableModel.getColumnDef(i);if(s!=null&&s.sortable&&s.sortable()){e.preventDefault(),e.stopPropagation();const a=s.sortStatesOrder?s.sortStatesOrder:this.tableOptions.sortOrder,r=s.sortState??"",d=a[(a.indexOf(r)+1)%a.length],h=new Ne(i,d);this.tableModel.doSort([h])&&((o=this.tableModel.getColumnDefs())==null||o.forEach(g=>g.sortState=""),s.sortState=d),this.repaint(),(n=this.storeSortingService)==null||n.setSortItems([h])}}changeFocusCell(e,t){if(!this.isEditing()&&this.getFocusModel){const i=this.getFocusModel();if(i){const[s,o]=i.getFocus();return i.setFocus(s+t,o+e),this.repaint(),!0}}return!1}resizeColumn(e){this.tableModel.setColumnWidth(this.mouseStartColumnIndex,this.mouseStartWidth+e.draggingX),this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()}clearSelectionModel(){var e;this.getSelectionModel&&((e=this.getSelectionModel())==null||e.clear())}debugOnce(e,t){var i;console.clear(),console.info("this.hostElement.offsetTop",this.hostElement.offsetTop),console.info("this.hostElement.scrollHeight",this.hostElement.scrollHeight),console.info("this.scrollViewportTop",this.scrollTop),console.info("this.areaHeaderCenter.parent.clientHeight",this.areaHeaderCenter.parent.clientHeight),console.info("bodyY",t),console.info("bodyX",e),console.info("rows",this.firstVisibleRowIndex),console.info(""),console.info("this.tableModel",this.tableModel),console.info(""),console.info("this.mouseMoveEvent.clientX",(i=this.mouseHandler.mouseEvent)==null?void 0:i.clientX),console.info("this.hostElement.offsetLeft",this.hostElement.offsetLeft),console.info("this.areaBodyWestGeo.width",this.areaBodyWestGeo.width)}autoRestoreScrollPosition(){var e;if((e=this.tableOptions)!=null&&e.autoRestoreOptions&&this.storeScrollPosStateService&&this.tableOptions.autoRestoreOptions.autoRestoreScrollPosition){const i=this.storeScrollPosStateService.getScrollOffset();i&&this.scrollViewport.scrollTo(...i)}}autoRestoreSortingState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.autoRestoreSortingState&&this.storeSortingService){const i=this.storeSortingService.getSortItems();i!=null&&i.length&&this.tableModel.getBodyModel().doSort(i)}}autoRestoreCollapsedExpandedState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.getRowId&&this.storeStateCollapsedExpandService){const i=this.tableOptions.autoRestoreOptions,s=i.getRowId;if(i.autoRestoreCollapsedExpandedState&&s){const o=this.storeStateCollapsedExpandService.collapsedExpandedStateGet(),n=this.tableModel.getAreaModel("body");if(z(n)){const a=n,r=n.getRowCount();for(let d=0;d<r;d++){const h=n.getRowByIndex(d);if(h)if(o.allExpanded)h.expanded=!0;else if(o.allCollapsed)h.expanded=!1;else{const p=s(h.data);o.mode==="expanded"?h.expanded=this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(p):o.mode==="collapsed"&&(h.expanded=!this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(p))}}a.recalcVisibleTreeRows()}}}}}function tt(l){let e;return{c(){e=fe("div"),e.innerHTML="",me(e,"class","ge-table"),L(e,"width","100%"),L(e,"height","100%"),L(e,"background-color","transparent"),L(e,"padding","0"),L(e,"margin","0")},m(t,i){ge(t,e,i),l[3](e)},p:F,i:F,o:F,d(t){t&&le(e),l[3](null)}}}function it(l,e,t){let{tableModel:i}=e,{tableOptions:s=new he}=e,o;const n=Z.createEventDispatcher();Z.onMount(()=>{const r={onCheckboxChanged:h=>{n("checkboxChanged",h)},onContextmenu:h=>{n("contextmenu",h)},onModelChanged:h=>{n("modelChanged",h)},onMouseClicked:h=>{n("mouseClicked",h)},onMouseDragging:h=>{n("mouseDragging",h)},onMouseDraggingEnd:h=>{n("mouseDraggingEnd",h)},onMouseMoved:h=>{n("mouseMoved",h)}},d=new J(o,i,new de,s,r);d.firstInit(),n("tableReady",d.getApi())});function a(r){V[r?"unshift":"push"](()=>{o=r,t(0,o)})}return l.$$set=r=>{"tableModel"in r&&t(1,i=r.tableModel),"tableOptions"in r&&t(2,s=r.tableOptions)},[o,i,s,a]}class st extends De{constructor(e){super(),Te(this,e,it,tt,ue,{tableModel:1,tableOptions:2})}}class ot{constructor(e){this.Component=e}render(e,t,i,s,o,n,a){const r=new this.Component({target:e,props:{cellDiv:e,rowIndex:t,columnIndex:i,areaIdent:s,areaModel:o,cellValue:n}});return()=>{r.$destroy()}}}exports.ComponentRendererWrapper=ot;exports.GuiexpertTable=st;