@guiexpert/svelte-table 4.0.9 → 4.0.10

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 (3) hide show
  1. package/index.cjs +5 -5
  2. package/index.js +88 -71
  3. package/package.json +2 -2
package/index.cjs CHANGED
@@ -1,11 +1,11 @@
1
- "use strict";var ye=Object.defineProperty;var ve=(a,e,t)=>e in a?ye(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var N=(a,e,t)=>(ve(a,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ie=require("svelte");function L(){}function ce(a){return a()}function re(){return Object.create(null)}function V(a){a.forEach(ce)}function he(a){return typeof a=="function"}function we(a,e){return a!=a?e==e:a!==e||a&&typeof a=="object"||typeof a=="function"}function Ce(a){return Object.keys(a).length===0}function xe(a,e,t){a.insertBefore(e,t||null)}function ge(a){a.parentNode&&a.parentNode.removeChild(a)}function Ee(a){return document.createElement(a)}function Ae(a,e,t){t==null?a.removeAttribute(e):a.getAttribute(e)!==t&&a.setAttribute(e,t)}function Me(a){return Array.from(a.childNodes)}function _(a,e,t,o){t==null?a.style.removeProperty(e):a.style.setProperty(e,t,o?"important":"")}let J;function B(a){J=a}const I=[],X=[];let $=[];const le=[],Re=Promise.resolve();let K=!1;function Te(){K||(K=!0,Re.then(pe))}function Y(a){$.push(a)}const j=new Set;let O=0;function pe(){if(O!==0)return;const a=J;do{try{for(;O<I.length;){const e=I[O];O++,B(e),De(e.$$)}}catch(e){throw I.length=0,O=0,e}for(B(null),I.length=0,O=0;X.length;)X.pop()();for(let e=0;e<$.length;e+=1){const t=$[e];j.has(t)||(j.add(t),t())}$.length=0}while(I.length);for(;le.length;)le.pop()();K=!1,j.clear(),B(a)}function De(a){if(a.fragment!==null){a.update(),V(a.before_update);const e=a.dirty;a.dirty=[-1],a.fragment&&a.fragment.p(a.ctx,e),a.after_update.forEach(Y)}}function ke(a){const e=[],t=[];$.forEach(o=>a.indexOf(o)===-1?e.push(o):t.push(o)),t.forEach(o=>o()),$=e}const Oe=new Set;function Ie(a,e){a&&a.i&&(Oe.delete(a),a.i(e))}function Fe(a,e,t){const{fragment:o,after_update:s}=a.$$;o&&o.m(e,t),Y(()=>{const i=a.$$.on_mount.map(ce).filter(he);a.$$.on_destroy?a.$$.on_destroy.push(...i):V(i),a.$$.on_mount=[]}),s.forEach(Y)}function Le(a,e){const t=a.$$;t.fragment!==null&&(ke(t.after_update),V(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function $e(a,e){a.$$.dirty[0]===-1&&(I.push(a),Te(),a.$$.dirty.fill(0)),a.$$.dirty[e/31|0]|=1<<e%31}function _e(a,e,t,o,s,i,r=null,n=[-1]){const l=J;B(a);const d=a.$$={fragment:null,ctx:[],props:i,update:L,not_equal:s,bound:re(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:re(),dirty:n,skip_bound:!1,root:e.target||l.$$.root};r&&r(d.root);let c=!1;if(d.ctx=t?t(a,e.props||{},(h,g,...S)=>{const b=S.length?S[0]:g;return d.ctx&&s(d.ctx[h],d.ctx[h]=b)&&(!d.skip_bound&&d.bound[h]&&d.bound[h](b),c&&$e(a,h)),g}):[],d.update(),c=!0,V(d.before_update),d.fragment=o?o(d.ctx):!1,e.target){if(e.hydrate){const h=Me(e.target);d.fragment&&d.fragment.l(h),h.forEach(ge)}else d.fragment&&d.fragment.c();e.intro&&Ie(a.$$.fragment),Fe(a,e.target,e.anchor),pe()}B(l)}class Be{constructor(){N(this,"$$");N(this,"$$set")}$destroy(){Le(this,1),this.$destroy=L}$on(e,t){if(!he(t))return L;const o=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return o.push(t),()=>{const s=o.indexOf(t);s!==-1&&o.splice(s,1)}}$set(e){this.$$set&&!Ce(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Pe="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Pe);class k{constructor(){this.alreadySet=!1}static getInstance(){return k.instance||(k.instance=new k),k.instance}setLicenseKey(e){if(e&&!this.alreadySet){const t=document.createElement("meta");t.content="license="+e,t.name="guiexperttable",document.getElementsByTagName("head")[0].appendChild(t),this.alreadySet=!0}}}function q(a){return a&&a.type==="TreeRow"}function U(a){return a&&a.type==="AreaModelTree"}class Q{constructor(e=-1,t=-1,o=-1,s=-1,i,r,n,l=0,d=0,c=0,h=""){this.rowIndex=e,this.rowTop=t,this.columnIndex=o,this.columnLeft=s,this.areaIdent=i,this.sideIdent=r,this.originalEvent=n,this.clickCount=l,this.draggingX=d,this.draggingY=c,this.action=h}clone(){return new Q(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="",o=[]){this.content=e,this.style=t,this.classes=o}}class ue{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"]),o=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=o,this.arrowExpandCollapseAll=s}}class be{constructor(e=new D("↑","",["ge-header-sorted-asc"]),t=new D("↓","",["ge-header-sorted-desc"]),o=new D("↑","color:transparent;",[])){this.iconAsc=e,this.iconDesc=t,this.iconPlaceholder=o}}class We{constructor(e){this.domService=e}setStyle(e,t,o){return this.domService.setStyle(e,t,o),e}applyStyle(e,t){for(const o in t)this.domService.setStyle(e,o,t[o]);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(([o,s])=>this.domService.setStyle(e,o,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",o){return this.domService.setStyle(o,"overflow-x",e),this.domService.setStyle(o,"overflow-y",t),o}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 o=this.domService.createText(t);return this.domService.appendChild(e,o),o}addClass(e,t){return e.includes(" ")?e.split(" ").forEach(o=>this.domService.addClass(t,o)):this.domService.addClass(t,e),t}removeClass(e,t){return e.includes(" ")?e.split(" ").forEach(o=>this.domService.removeClass(t,o)):this.domService.removeClass(t,e),t}addClasses(e,t){if(e)for(const o of e)this.domService.addClass(t,o);return t}setAttribute(e,t,o){return t&&o&&this.domService.setAttribute(e,t,o),e}createAreaDivWithClass(e,t,o,s){const i=this.domService.createElement("div");return this.addClass(e,i),this.domService.setAttribute(i,"data-area",o),this.domService.setAttribute(i,"data-side",s),this.domService.appendChild(t,i),i}createDivWithClass(e,t){const o=this.domService.createElement("div");return this.addClass(e,o),this.domService.appendChild(t,o),o}addRowDiv(e,t,o=-1,s,i,r=""){const n=t.index??-1,l=this.getDivOrCreateDiv(n,e);if(this.domService.addClass(l,"ge-table-row-div"),this.domService.addClass(l,`ge-table-row-div-${t.index}`),s==="body"&&i==="center"){const d=((t==null?void 0:t.index)??0)%2===0?"even":"odd";this.domService.addClass(l,`ge-table-row-${d}`)}if(this.domService.setStyle(l,"display","clip"),this.domService.setStyle(l,"position","absolute"),this.domService.setStyle(l,"left",`${t.left}px`),this.domService.setStyle(l,"top",`${t.top}px`),this.domService.setStyle(l,"width",`${t.width}px`),this.domService.setStyle(l,"height",`${t.height}px`),this.domService.setAttribute(l,"data-row-index",`${o}`),this.domService.setAttribute(l,"data-area",`${s}`),r){const d=this.domService.createText(r);this.domService.appendChild(l,d)}return this.domService.appendChild(e.child,l),l}addColumnDiv(e){const{parent:t,geo:o,rowIndex:s=-1,columnIndex:i=-1,areaIdent:r,sideIdent:n,text:l="",treeArrow:d,tableOptions:c,checkedType:h=void 0,sortState:g}=e,S=c==null?void 0:c.treeOptions,b=c==null?void 0:c.showCheckboxWihoutExtraColumn,f=this.domService.createElement("div");this.domService.addClass(f,"ge-table-col-div"),b&&this.domService.addClass(f,"ge-with-checkbox"),this.domService.addClass(f,`ge-table-col-div-${o.index}`),this.domService.setAttribute(f,"data-col-index",`${o.index}`),this.domService.setAttribute(f,"data-row-index",`${s}`),this.domService.setAttribute(f,"data-area",`${r}`);const u=((o==null?void 0:o.index)??0)%2===0?"even":"odd";if(r==="body"&&n==="center"&&this.domService.addClass(f,`ge-table-column-${u}`),this.domService.setStyle(f,"display","clip"),this.domService.setStyle(f,"position","absolute"),this.domService.setStyle(f,"left",`${o.left}px`),this.domService.setStyle(f,"top",`${o.top}px`),this.domService.setStyle(f,"width",`${o.width}px`),this.domService.setStyle(f,"height",`${o.height}px`),d&&d!=="none"&&(this.domService.addClass(f,"ge-table-col-tree"),this.addArrowDiv(f,d,S,s,i,r)),b&&i===0&&h&&this.addCheckboxToDiv(f,h,r,s),l){const p=d!=="none"&&i===0;this.addLabelDiv(f,l,p,s,i,r)}return g&&this.addSortedIcon(f,g,c==null?void 0:c.sortedOptions,i),this.domService.appendChild(t,f),f}addCheckboxToDiv(e,t,o,s){const i=this.domService.createElement("div"),r=t==="full"?"checked":"";return i.innerHTML=`
1
+ "use strict";var ye=Object.defineProperty;var ve=(a,e,t)=>e in a?ye(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var N=(a,e,t)=>(ve(a,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ie=require("svelte");function L(){}function ce(a){return a()}function re(){return Object.create(null)}function z(a){a.forEach(ce)}function he(a){return typeof a=="function"}function we(a,e){return a!=a?e==e:a!==e||a&&typeof a=="object"||typeof a=="function"}function Ce(a){return Object.keys(a).length===0}function xe(a,e,t){a.insertBefore(e,t||null)}function ge(a){a.parentNode&&a.parentNode.removeChild(a)}function Ee(a){return document.createElement(a)}function Ae(a,e,t){t==null?a.removeAttribute(e):a.getAttribute(e)!==t&&a.setAttribute(e,t)}function Me(a){return Array.from(a.childNodes)}function _(a,e,t,o){t==null?a.style.removeProperty(e):a.style.setProperty(e,t,o?"important":"")}let J;function B(a){J=a}const I=[],X=[];let $=[];const le=[],Re=Promise.resolve();let K=!1;function Te(){K||(K=!0,Re.then(pe))}function Y(a){$.push(a)}const j=new Set;let O=0;function pe(){if(O!==0)return;const a=J;do{try{for(;O<I.length;){const e=I[O];O++,B(e),De(e.$$)}}catch(e){throw I.length=0,O=0,e}for(B(null),I.length=0,O=0;X.length;)X.pop()();for(let e=0;e<$.length;e+=1){const t=$[e];j.has(t)||(j.add(t),t())}$.length=0}while(I.length);for(;le.length;)le.pop()();K=!1,j.clear(),B(a)}function De(a){if(a.fragment!==null){a.update(),z(a.before_update);const e=a.dirty;a.dirty=[-1],a.fragment&&a.fragment.p(a.ctx,e),a.after_update.forEach(Y)}}function ke(a){const e=[],t=[];$.forEach(o=>a.indexOf(o)===-1?e.push(o):t.push(o)),t.forEach(o=>o()),$=e}const Oe=new Set;function Ie(a,e){a&&a.i&&(Oe.delete(a),a.i(e))}function Fe(a,e,t){const{fragment:o,after_update:s}=a.$$;o&&o.m(e,t),Y(()=>{const i=a.$$.on_mount.map(ce).filter(he);a.$$.on_destroy?a.$$.on_destroy.push(...i):z(i),a.$$.on_mount=[]}),s.forEach(Y)}function Le(a,e){const t=a.$$;t.fragment!==null&&(ke(t.after_update),z(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function $e(a,e){a.$$.dirty[0]===-1&&(I.push(a),Te(),a.$$.dirty.fill(0)),a.$$.dirty[e/31|0]|=1<<e%31}function _e(a,e,t,o,s,i,r=null,n=[-1]){const l=J;B(a);const d=a.$$={fragment:null,ctx:[],props:i,update:L,not_equal:s,bound:re(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:re(),dirty:n,skip_bound:!1,root:e.target||l.$$.root};r&&r(d.root);let c=!1;if(d.ctx=t?t(a,e.props||{},(h,g,...S)=>{const b=S.length?S[0]:g;return d.ctx&&s(d.ctx[h],d.ctx[h]=b)&&(!d.skip_bound&&d.bound[h]&&d.bound[h](b),c&&$e(a,h)),g}):[],d.update(),c=!0,z(d.before_update),d.fragment=o?o(d.ctx):!1,e.target){if(e.hydrate){const h=Me(e.target);d.fragment&&d.fragment.l(h),h.forEach(ge)}else d.fragment&&d.fragment.c();e.intro&&Ie(a.$$.fragment),Fe(a,e.target,e.anchor),pe()}B(l)}class Be{constructor(){N(this,"$$");N(this,"$$set")}$destroy(){Le(this,1),this.$destroy=L}$on(e,t){if(!he(t))return L;const o=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return o.push(t),()=>{const s=o.indexOf(t);s!==-1&&o.splice(s,1)}}$set(e){this.$$set&&!Ce(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Pe="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Pe);function We(a,e=500){let t=null;return function(...o){t&&window.clearTimeout(t),t=window.setTimeout(()=>{a.apply(this,o),t=null},e)}}class k{constructor(){this.alreadySet=!1}static getInstance(){return k.instance||(k.instance=new k),k.instance}setLicenseKey(e){if(e&&!this.alreadySet){const t=document.createElement("meta");t.content="license="+e,t.name="guiexperttable",document.getElementsByTagName("head")[0].appendChild(t),this.alreadySet=!0}}}function q(a){return a&&a.type==="TreeRow"}function U(a){return a&&a.type==="AreaModelTree"}class Q{constructor(e=-1,t=-1,o=-1,s=-1,i,r,n,l=0,d=0,c=0,h=""){this.rowIndex=e,this.rowTop=t,this.columnIndex=o,this.columnLeft=s,this.areaIdent=i,this.sideIdent=r,this.originalEvent=n,this.clickCount=l,this.draggingX=d,this.draggingY=c,this.action=h}clone(){return new Q(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="",o=[]){this.content=e,this.style=t,this.classes=o}}class ue{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"]),o=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=o,this.arrowExpandCollapseAll=s}}class be{constructor(e=new D("↑","",["ge-header-sorted-asc"]),t=new D("↓","",["ge-header-sorted-desc"]),o=new D("↑","color:transparent;",[])){this.iconAsc=e,this.iconDesc=t,this.iconPlaceholder=o}}class He{constructor(e){this.domService=e}setStyle(e,t,o){return this.domService.setStyle(e,t,o),e}applyStyle(e,t){for(const o in t)this.domService.setStyle(e,o,t[o]);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(([o,s])=>this.domService.setStyle(e,o,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",o){return this.domService.setStyle(o,"overflow-x",e),this.domService.setStyle(o,"overflow-y",t),o}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 o=this.domService.createText(t);return this.domService.appendChild(e,o),o}addClass(e,t){return e.includes(" ")?e.split(" ").forEach(o=>this.domService.addClass(t,o)):this.domService.addClass(t,e),t}removeClass(e,t){return e.includes(" ")?e.split(" ").forEach(o=>this.domService.removeClass(t,o)):this.domService.removeClass(t,e),t}addClasses(e,t){if(e)for(const o of e)this.domService.addClass(t,o);return t}setAttribute(e,t,o){return t&&o&&this.domService.setAttribute(e,t,o),e}createAreaDivWithClass(e,t,o,s){const i=this.domService.createElement("div");return this.addClass(e,i),this.domService.setAttribute(i,"data-area",o),this.domService.setAttribute(i,"data-side",s),this.domService.appendChild(t,i),i}createDivWithClass(e,t){const o=this.domService.createElement("div");return this.addClass(e,o),this.domService.appendChild(t,o),o}addRowDiv(e,t,o=-1,s,i,r=""){const n=t.index??-1,l=this.getDivOrCreateDiv(n,e);if(this.domService.addClass(l,"ge-table-row-div"),this.domService.addClass(l,`ge-table-row-div-${t.index}`),s==="body"&&i==="center"){const d=((t==null?void 0:t.index)??0)%2===0?"even":"odd";this.domService.addClass(l,`ge-table-row-${d}`)}if(this.domService.setStyle(l,"display","clip"),this.domService.setStyle(l,"position","absolute"),this.domService.setStyle(l,"left",`${t.left}px`),this.domService.setStyle(l,"top",`${t.top}px`),this.domService.setStyle(l,"width",`${t.width}px`),this.domService.setStyle(l,"height",`${t.height}px`),this.domService.setAttribute(l,"data-row-index",`${o}`),this.domService.setAttribute(l,"data-area",`${s}`),r){const d=this.domService.createText(r);this.domService.appendChild(l,d)}return this.domService.appendChild(e.child,l),l}addColumnDiv(e){const{parent:t,geo:o,rowIndex:s=-1,columnIndex:i=-1,areaIdent:r,sideIdent:n,text:l="",treeArrow:d,tableOptions:c,checkedType:h=void 0,sortState:g}=e,S=c==null?void 0:c.treeOptions,b=c==null?void 0:c.showCheckboxWihoutExtraColumn,f=this.domService.createElement("div");this.domService.addClass(f,"ge-table-col-div"),b&&this.domService.addClass(f,"ge-with-checkbox"),this.domService.addClass(f,`ge-table-col-div-${o.index}`),this.domService.setAttribute(f,"data-col-index",`${o.index}`),this.domService.setAttribute(f,"data-row-index",`${s}`),this.domService.setAttribute(f,"data-area",`${r}`);const u=((o==null?void 0:o.index)??0)%2===0?"even":"odd";if(r==="body"&&n==="center"&&this.domService.addClass(f,`ge-table-column-${u}`),this.domService.setStyle(f,"display","clip"),this.domService.setStyle(f,"position","absolute"),this.domService.setStyle(f,"left",`${o.left}px`),this.domService.setStyle(f,"top",`${o.top}px`),this.domService.setStyle(f,"width",`${o.width}px`),this.domService.setStyle(f,"height",`${o.height}px`),d&&d!=="none"&&(this.domService.addClass(f,"ge-table-col-tree"),this.addArrowDiv(f,d,S,s,i,r)),b&&i===0&&h&&this.addCheckboxToDiv(f,h,r,s),l){const p=d!=="none"&&i===0;this.addLabelDiv(f,l,p,s,i,r)}return g&&this.addSortedIcon(f,g,c==null?void 0:c.sortedOptions,i),this.domService.appendChild(t,f),f}addCheckboxToDiv(e,t,o,s){const i=this.domService.createElement("div"),r=t==="full"?"checked":"";return i.innerHTML=`
2
2
  <input
3
3
  type="checkbox"
4
4
  data-area="${o}"
5
5
  data-row-index="${s}"
6
6
  data-input-type="checkbox"
7
7
  ${r}
8
- class="ge-table-row-checkbox"> `,this.domService.setStyle(i,"display","inline"),this.domService.setStyle(i,"width","inherit"),this.domService.setAttribute(i,"data-row-index",`${s}`),this.domService.appendChild(e,i),i}addLabelDiv(e,t="",o=!1,s=-1,i=-1,r="body"){const n=this.domService.createElement("div");if(this.domService.addClass(n,"ge-table-label-div"),this.domService.setStyle(n,"position","relative"),this.domService.setStyle(n,"background","transparent"),this.domService.setStyle(n,"width","100%"),this.domService.setStyle(n,"height","100%"),this.domService.setAttribute(n,"data-row-index",`${s}`),this.domService.setAttribute(n,"data-col-index",`${i}`),this.domService.setAttribute(n,"data-area",`${r}`),t)if(o){const l=this.domService.createText(t);this.domService.appendChild(n,l)}else{const l=this.domService.createElement("div");this.domService.appendChild(n,l);const d=this.domService.createText(t);this.domService.addClass(l,"ge-table-label"),this.domService.appendChild(l,d),this.domService.setAttribute(l,"data-row-index",`${s}`),this.domService.setAttribute(l,"data-col-index",`${i}`),this.domService.setAttribute(l,"data-area",`${r}`)}return this.domService.appendChild(e,n),n}addSortedIcon(e,t="",o=new be,s=-1){const i=this.domService.createElement("div");this.domService.addClass(i,"ge-table-sorted-icon-div"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"top","0"),this.domService.setStyle(i,"right","0"),this.domService.setStyle(i,"width","20px"),this.domService.setStyle(i,"background","transparent"),this.domService.setStyle(i,"cursor","pointer"),this.domService.setAttribute(i,"data-col-index",`${s}`),this.domService.setAttribute(i,"data-area","header");let r;t==="asc"?r=o.iconAsc:t==="desc"?r=o.iconDesc:r=o.iconPlaceholder;const n=r.content,l=this.domService.createText(n);this.domService.appendChild(i,l),r.style&&this.applyStyleString(i,r.style);for(const d of r.classes)this.domService.addClass(i,d);return this.domService.appendChild(e,i),i}addArrowDiv(e,t="none",o=new ue,s=-1,i=-1,r="body"){const n=this.domService.createElement("div");this.domService.addClass(n,"ge-table-tree-arrow-div"),this.domService.setStyle(n,"display","inline-block"),this.domService.setStyle(n,"position",""),this.domService.setStyle(n,"width","20px"),this.domService.setStyle(n,"background","transparent"),this.domService.setStyle(n,"cursor","pointer"),this.domService.setAttribute(n,"data-row-index",`${s}`),this.domService.setAttribute(n,"data-col-index",`${i}`),this.domService.setAttribute(n,"data-area",`${r}`);let l;t==="expanded"?l=o.arrowExpanded:t==="collapsed"?l=o.arrowCollapsed:l=o.arrowPlaceholder;const d=l.content,c=this.domService.createText(d);this.domService.appendChild(n,c),l.style&&this.applyStyleString(n,l.style);for(const h of l.classes)this.domService.addClass(n,h);return this.domService.appendChild(e,n),n}addColumnBorderDivs(e,t,o,s,i){if(e.verticalBorderVisible){const r=`ge-table-${s}-${i}-vertical-border`;this.addVerticalBorder(o,t,r)}if(e.horizontalBorderVisible){const r=`ge-table-${s}-${i}-horizontal-border`;this.addHorizontalBorder(o,t,r)}return t}addHorizontalBorder(e,t,o="ge-table-body-center-horizontal-border"){const s=this.domService.createElement("div");return this.domService.addClass(s,o),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,o){t={...t,width:t.width+1,height:t.height+1};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.domService.setStyle(s,"z-index","9999"),this.applyStyle(s,o),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.domService.setStyle(s,"z-index","9999"),this.applyStyle(s,o),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.domService.setStyle(s,"z-index","9999"),this.applyStyle(s,o),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.domService.setStyle(s,"z-index","9999"),this.applyStyle(s,o),this.domService.appendChild(e,s),e}addVerticalBorder(e,t,o="ge-table-body-center-vertical-border"){const s=this.domService.createElement("div");return this.domService.addClass(s,o),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,o=""){const s=this.domService.createElement("div");return o&&this.domService.addClass(s,o),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 o=t.split(";").map(s=>s.trim()).filter(s=>s);for(const s of o){const[i,r]=s.split(":");this.domService.setStyle(e,i.trim(),r.trim())}}getDivOrCreateDiv(e,t){let o=t.cache[e];return o?(o.innerText="",o):(o=this.domService.createElement("div"),t.cache[e]=o,o)}}const Z=a=>a==="header"?"header":a==="footer"?"footer":"body";class He{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 o=e.getAttribute("data-area");if(o&&(this.areaIdent=Z(o),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 Ge{constructor(e){this.tableScope=e,this.doubleClickDelay=500,this.expandedAll=!0,this.mouseDown=!1,this.dragging=!1,this.lastClicked=0,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=Date.now();if(t-this.lastClicked<this.doubleClickDelay)return;this.lastClicked=t;const o=new He(e.target,this.tableScope);if(o.action==="toggleExpandCollapseAll")this.expandedAll=!this.expandedAll,this.tableScope.toggleExpandCollapseAll(this.expandedAll),e.preventDefault(),e.stopPropagation();else if(o.action==="toggleHeaderGroup")this.tableScope.toggleHeaderGroup(o),e.preventDefault(),e.stopPropagation();else if(o.inputType==="checkbox"&&o.areaIdent)this.tableScope.toggleRowCheckbox(o.rowIdx,o.colIdx,o.areaIdent),e.preventDefault(),e.stopPropagation();else if(q(o.row)&&o.areaModel){const s=o.colIdx===this.getArrowColumnIndex()&&e.altKey,i=o.className.includes("ge-table-tree-arrow-div");if(s||i){e.preventDefault(),e.stopPropagation();const r=o.row;r.expanded=!r.expanded,"recalcVisibleTreeRows"in o.areaModel&&o.areaModel.recalcVisibleTreeRows(),this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth),this.tableScope.adjustContainersAndRows(),this.updateCollapsedExpandedState(r)}}if(o.areaIdent==="body"&&this.tableScope.tableOptions.getFocusModel){const s=this.tableScope.tableOptions.getFocusModel();s==null||s.clear(),s==null||s.setFocus(o.rowIdx,o.colIdx)}this.publishGeMouseEvent(e,1)}onHostElementDblClicked(e){if(this.lastClicked=Date.now(),e.target instanceof HTMLElement){const t=e.target,o=t.getAttribute("data-area"),s=Z(o),i=Number(t.getAttribute("data-row-index")),r=Number(t.getAttribute("data-col-index")),n=this.tableScope.tableModel.getAreaModel(s);if(o&&s==="header")this.tableScope.tableModel.isSortable(r)&&(this.tableScope.clearSelection(),this.tableScope.onHeaderDblClicked(e,i,r));else if(t.getAttribute("data-row-index")){const l=n.getRowByIndex(i);if(o&&s==="body"&&n.isEditable(i,r)&&(this.tableScope.clearSelection(),this.tableScope.initRenderEditor(i,r)),q(l)&&r===this.getArrowColumnIndex()){e.preventDefault(),e.stopPropagation();const d=l;d.expanded=!d.expanded,"recalcVisibleTreeRows"in n&&n.recalcVisibleTreeRows(),this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth),this.tableScope.adjustContainersAndRows(),this.updateCollapsedExpandedState(d)}}}this.publishGeMouseEvent(e,2)}publishGeMouseEvent(e,t){var o;this.mouseEvent=e,this.geMouseEventOld=(o=this.geMouseEvent)==null?void 0:o.clone(),this.geMouseEvent=this.tableScope.createGeMouseEvent(e),this.geMouseEvent&&(this.geMouseEvent.clickCount=t),this.tableScope.onMouseClicked(this.geMouseEvent,this.geMouseEventOld),this.tableScope.publishGeMouseEvent(this.geMouseEvent),t===1&&this.tableScope.debounceRepaint()}updateCollapsedExpandedState(e){var o,s,i,r,n;const t=(s=(o=this.tableScope.tableOptions)==null?void 0:o.autoRestoreOptions)==null?void 0:s.getRowId;if(t){const l=(i=this.tableScope.storeStateCollapsedExpandService)==null?void 0:i.collapsedExpandedStateGet().mode,d=l==="collapsed"&&!e.expanded||l==="expanded"&&e.expanded,c=l==="collapsed"&&e.expanded||l==="expanded"&&!e.expanded,h=t(e.data);d?(r=this.tableScope.storeStateCollapsedExpandService)==null||r.collapsedStateIdsPush(h):c&&((n=this.tableScope.storeStateCollapsedExpandService)==null||n.collapsedStateIdsRemove(h))}}getArrowColumnIndex(){return this.tableScope.tableModel.isRowCheckboxVisible()?1:0}onMouseDown(e){this.dragging||(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||(this.dragging=!0,this.tableScope.setDragging(!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,this.tableScope.setDragging(!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,this.startMouseEvent)}}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 Ve{constructor(e){this.tableScope=e}updateCells(e,t=!1){this.tableScope.updateCells(e,t)}externalFilterChanged(){this.tableScope.externalFilterChanged()}scrollToPixel(e=0,t=0){this.tableScope.scrollToPixel(e,t)}scrollToIndex(e=0,t=0){this.tableScope.scrollToIndex(e,t)}setHeaderVisible(e=!0){}setColumnVisible(e,t=!0){}isColumnVisible(e){return!0}isHeaderVisible(){return!0}setFooterVisible(e=!0){}isFooterVisible(){return!0}repaint(){this.tableScope.repaint()}repaintHard(){this.tableScope.repaintHard()}recalcColumnWidths(e){this.tableScope.recalcColumnWidths(e)}clearSelection(){this.tableScope.clearSelection(!0)}setSelectionModel(e,t=!0){this.tableScope.setSelectionModel(e,t)}triggerAction(e){this.tableScope.onActionTriggered(e)}getShortcutActionMapping(){return this.tableScope.shortcutService.getShortcutActionMapping()}copyToClipboard(){return this.tableScope.copyService.copyToClipboard(this.tableScope.tableModel,this.tableScope.selectionModel(),this.tableScope.focusModel())}getTableScope(){return this.tableScope}getSelectionModel(){return this.tableScope.selectionModel()}}class ee{constructor(e){this.getStorageKeyFn=e}autoConvertMapToObject(e){const t={};if(e instanceof Map){const o=e;for(const s of[...o]){const[i,r]=s;t[i]=r}}return t}checkAndPersistItem(e,t){const o=this.getStorageKeyFn;if(o){const s=o();if(s){const i=s+e;if((t+"").includes("Map")){const r=this.autoConvertMapToObject(t);this.persistItem(i,r)}else this.persistItem(i,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 ze extends ee{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 o=t+this.SCROLL_STATE;let s=this.loadFromLocalStorage(o);this.scrollOffset=s||[0,0]}}}}class Ne{constructor(e="collapsed",t=[],o=!1,s=!1){this.mode=e,this.rowIds=t,this.allCollapsed=o,this.allExpanded=s}}class je extends ee{constructor(e){super(e),this.COLLAPSED_EXPANDED_STATE="collapsedExpandedState",this.collapsedExpandedState=new Ne,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 o=t+this.COLLAPSED_EXPANDED_STATE,s=this.loadFromLocalStorage(o);s&&(this.collapsedExpandedState=s)}}}persist(){this.checkAndPersistItem(this.COLLAPSED_EXPANDED_STATE,this.collapsedExpandedState)}}class Xe extends ee{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 o=t+this.SORTING_STATE,s=this.loadFromLocalStorage(o);this.sortItems=s||[]}}}}class T{constructor(e=0,t=0,o=0,s=0,i){this.left=e,this.width=t,this.height=o,this.top=s,this.index=i}}class Ke{constructor(e,t,o,s){this.hostElement=e,this.tableModel=t,this.dom=o,this.tableOptions=s,this.scrollTop=0,this.areaBodyWestGeo=new T,this.areaBodyCenterGeo=new T,this.areaBodyEastGeo=new T;const i=this.hostElement;i.innerText="",this.dom.setAttribute(i,"tabindex","0"),this.dom.setStyle(this.dom.addClass("ge-table",i),"position","relative"),this.hoverRow=o.applyStylePosistionAbsolute(o.createDivWithClass("ge-table-hover-row",i)),this.hoverColumn=o.applyStylePosistionAbsolute(o.createDivWithClass("ge-table-hover-column",i)),this.draggingColumn=o.applyStylePosistionAbsolute(o.createDivWithClass("ge-table-dragging-column",i)),this.areaHeaderWest=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-header ge-table-header-west",i,"header","west"))),this.areaHeaderCenter=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-header ge-table-header-center",i,"header","center"))),this.areaHeaderEast=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-header ge-table-header-east",i,"body","east"))),this.areaBodyWest=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-body ge-table-body-west",i,"body","west"))),this.areaBodyEast=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-body ge-table-body-east",i,"body","east"))),this.areaFooterWest=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-footer ge-table-footer-west",i,"footer","west"))),this.areaFooterCenter=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-footer ge-table-footer-center",i,"footer","center"))),this.areaFooterEast=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-footer ge-table-footer-east",i,"footer","east"))),this.scrollViewport=o.applyStyleOverflowAuto(this.tableOptions.overflowX??"auto",this.tableOptions.overflowY??"auto",o.applyStyleNoPadding(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-scroll-viewport",i,"body","center")))),this.contentWrapperDiv=o.applyStyleNoPadding(o.applyStylePosistionRelative(o.createDivWithClass("ge-table-scroll-content-wrapper",this.scrollViewport))),this.contentDiv=o.applyStyleNoPadding(o.applyStylePosistionRelative(o.createDivWithClass("ge-table-scroll-content",this.contentWrapperDiv))),this.areaBodyCenter=o.appendRelativeChildDiv(o.createDivWithClass("ge-table-body-center",this.contentDiv)),this.borderHeaderBottom=o.applyStylePosistionAbsolute(o.createDivWithClass("ge-table-header-border",i)),this.borderFixedWest=o.applyStylePosistionAbsolute(o.createDivWithClass("ge-table-west-fixed-column-border",i)),this.borderFixedEast=o.applyStylePosistionAbsolute(o.createDivWithClass("ge-table-east-fixed-column-border",i)),this.borderFooterTop=o.applyStylePosistionAbsolute(o.createDivWithClass("ge-table-footer-border",i))}adjustContainersAndRows(){const e=this.tableModel.getPadding(),t=this.hostElement.clientWidth,o=this.hostElement.clientHeight;this.dom.applyStyle(this.scrollViewport,{width:`${t-e.left}px`,height:`${o-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=o-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=o-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=o-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:`${o-e.bottom}px`,left:"0"}),this.dom.applyStyle(this.areaFooterCenter.parent,{width:`${t-e.left-e.right}px`,height:`${e.bottom}px`,top:`${o-e.bottom}px`,left:`${e.left}px`}),this.dom.applyStyle(this.areaFooterEast.parent,{width:`${e.right}px`,height:`${e.bottom}px`,top:`${o-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:`${o-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 E{constructor(e,t,o,s,i=!1){this.r1=e,this.c1=t,this.r2=o,this.c2=s,this.gammaRange=i}static create(e){return e.gammaRange===void 0&&(e.gammaRange=!1),new E(e.rowIndex1,e.columnIndex1,e.rowIndex2,e.columnIndex2,e.gammaRange)}static singleCell(e,t){return new E(e,t,e,t)}static singleRow(e){return new E(e,0,e,Number.MAX_SAFE_INTEGER)}static singleColumn(e){return new E(0,e,Number.MAX_SAFE_INTEGER,e)}isInRange(e,t){return e>=this.r1&&e<=this.r2&&t>=this.c1&&t<=this.c2}}class Ye{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 o=0;o<e;o++)for(let s=0;s<t;s++){let i=this.areaModel.getColspanAt(o,s),r=this.areaModel.getRowspanAt(o,s);if(i>1||r>1){i===0&&(i=1),r===0&&(r=1);const n="gammaCells"in this.areaModel;this.colAndRowspanRanges.push(new E(o,s,o+r-1,s+i-1,n))}}}getRanges(){return this.colAndRowspanRanges?this.colAndRowspanRanges:[]}isInRange(e,t){if(this.colAndRowspanRanges){for(const o of this.colAndRowspanRanges)if(o.isInRange(e,t))return!0}return!1}}class qe{constructor(e,t,o){this.header=e,this.body=t,this.footer=o}}class Ue extends Ke{constructor(e,t,o,s){var r,n;super(e,t,o,s),this.dragging=!1,this.editing=!1,this.storedColumnWidths=[],this.scrollLeft=0,this.scrollViewportLeft=0,this.scrollFactorY=0,this.scrollFactorX=0,this.cleanupFunctions={header:[],body:[],footer:[]},this.tree=!1,this.colAndRowspanModels=new qe,this.firstVisibleRowIndex=-1,this.draggingTargetColumnIndex=-1,this.removables=[],this.tableModel.getSelectionModel?this.getSelectionModel=this.tableModel.getSelectionModel:(r=this.tableOptions)!=null&&r.getSelectionModel&&(this.getSelectionModel=this.tableOptions.getSelectionModel),(n=this.tableOptions)!=null&&n.getFocusModel&&(this.getFocusModel=this.tableOptions.getFocusModel),U(t.getAreaModel("body"))&&(this.tree=!0),["header","body","footer"].forEach(l=>{var d;this.colAndRowspanModels[l]=new Ye(t,t.getAreaModel(l)),(d=this.colAndRowspanModels[l])==null||d.init()})}isEditing(){return this.editing}resetEditorRenderer(){this.editorRenderer=void 0,this.editorRendererRow=-1,this.editorRendererColumn=-1,this.editing=!1}clearSelection(e=!1){if(this.getSelectionModel){const t=this.getSelectionModel();t==null||t.clear(),e&&this.repaint()}}initRenderEditor(e,t){var s;let o=(s=this.tableModel.getColumnDef(t))==null?void 0:s.getEditRenderer;if(o||(o=this.tableOptions.getEditRenderer),o)if(this.editorRenderer=o(e,t),this.editorRenderer){this.editorRendererRow=e,this.editorRendererColumn=t,this.editing=!0,this.repaint();const i=document.querySelector("input.ge-table-cell-editor-input");i&&i.focus()}else this.resetEditorRenderer()}repaint(){this.adjustAfterScrolling()}repaintHard(){this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows(),this.adjustAfterScrolling()}recalcColumnWidths(e){let t=e||this.scrollViewport.clientWidth;this.tableModel.setParentWidth(t),this.tableModel.init(),this.repaintHard()}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,t=!1){e.forEach(o=>{this.tableModel.getAreaModel(o.area).setValue(o.rowIndex,o.columnIndex,o.value),t||this.rerenderCellContent(o)}),t&&this.repaint()}rerenderCellContent({area:e,rowIndex:t,columnIndex:o,value:s,cssClasses:i}){const r=this.tableModel.getAreaModel(e),n='div[data-col-index="'+o+'"][data-row-index="'+t+'"][data-area="'+e+'"]',l=document.querySelector(n);if(l){let d;const h=this.editorRenderer&&this.editorRendererRow===t&&this.editorRendererColumn===o?this.editorRenderer:r.getCellRenderer(t,o);if(l.innerText="",this.applyCssClasses(l,i),h)d=h.render(l,t,o,e,r,s,this.dom.domService),d&&this.cleanupFunctions[e].push(d);else{const b=`${s}`;this.dom.addLabelDiv(l,b,!1,t,o,e)}const g=r.getCustomClassesAt(t,o);g.length&&this.dom.addClasses(g,l);const S=r.getCustomStyleAt(t,o);if(S)for(const b in S)this.dom.setStyle(l,b,S[b])}}storeColumnWidths(){const e=this.tableModel.getColumnDefs();e!=null&&e.length&&(this.storedColumnWidths=e.map((t,o)=>this.tableModel.getColumnWidth(o)))}getAreaAndSideIdentByAttr(e){if(e){const t=this.getStringByAttr(e,"data-area"),o=this.getStringByAttr(e,"data-side");if(o&&t)return[t,o]}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 o;if(e){const s=(o=e.closest("["+t+"]"))==null?void 0:o.getAttribute(t);if(s)return Number(s)}return-1}getStringByAttr(e,t){var o;if(e){const s=(o=e.closest("["+t+"]"))==null?void 0:o.getAttribute(t);if(s)return s}return""}adjustArea(e,t=0){var u;const o=this.getArea(e,"west"),s=this.getArea(e,"center"),i=this.getArea(e,"east"),r=s.child.clientHeight;o.child.innerText="",s.child.innerText="",i.child.innerText="";const n=0,l=this.areaBodyCenterGeo.width,d=this.tableModel.getPadding(),c=this.tableModel.getAreaModel(e),h=c.getRowCount();for(;this.cleanupFunctions[e].length;){const p=this.cleanupFunctions[e].shift();p&&p()}let g=t;const S=this.tableModel.getColumnCount(),b=this.tableModel.getFixedRightColumnCount(),f=this.tableModel.getFixedLeftColumnCount();for(let p=0;p<h;p++){const v=g,w=p===h-1,x=this.tableModel.getRowHeight(e,p);if(v+x>0){this.firstVisibleRowIndex=p;let y={left:n,width:l,height:x,top:v,index:p},m=this.dom.addRowDiv(s,y,p,e,"center");const R=f;if(this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"center",areaModel:c,geo:y,parent:m,rowIndex:p,columnIndexStart:R,columnIndexEnd:S-b-1,verticalFixed:!1,lastRowOfModel:w}),d.left>0&&(y={left:n,width:this.areaBodyWestGeo.width,height:x,top:v,index:p},m=this.dom.addRowDiv(o,y,p,e,"west"),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"west",areaModel:c,geo:y,parent:m,rowIndex:p,columnIndexStart:0,columnIndexEnd:R-1,verticalFixed:!0,lastRowOfModel:w})),d.right>0&&(y={left:n,width:this.areaBodyEastGeo.width,height:x,top:v,index:p},m=this.dom.addRowDiv(i,y,p,e,"east"),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"east",areaModel:c,geo:y,parent:m,rowIndex:p,columnIndexStart:S-b,columnIndexEnd:S-1,verticalFixed:!0,lastRowOfModel:w})),e==="header"&&this.tree&&p===h-1){const A=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 P=this.dom.domService.createText(M.content);this.dom.domService.appendChild(A,P),M.style&&this.dom.applyStyleString(A,M.style)}}}if(g=g+x,g>r)break}if(this.colAndRowspanModels&&this.colAndRowspanModels[e]){const p=((u=this.colAndRowspanModels[e])==null?void 0:u.getRanges())??[];if(p.length)for(const v of p){let w=0,x=s.child,y="center";if(v.c1<f)x=o.child,y="west";else if(b>0&&v.c1>=S-b)x=i.child,y="east";else{const m=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();w=this.scrollFactorX*m-this.areaBodyWestGeo.width,y="center"}this.drawBigCell(v,w,t,c,x,y)}}}drawBigCell(e,t,o,s,i,r){const n=o+this.getRowHeights(0,e.r1-1,s).reduce((u,p)=>u+p,0),l=this.tableModel.getColumnCount(),d=this.tableModel.getFixedRightColumnCount();let c=0;d>0&&e.c1>=l-d&&(c=l-d);const h=t+this.getColumnWidths(c,e.c1-1).reduce((u,p)=>u+p,0),g=this.getRowHeights(e.r1,e.r2,s).reduce((u,p)=>u+p,0),S=this.getColumnWidths(e.c1,e.c2).reduce((u,p)=>u+p,0);let b=!1;const f=this.getSelectionModel?this.getSelectionModel():void 0;f&&(b=f.getSelectionCount(e.r1,e.c1)>0),e.gammaRange?this.renderCell({areaModel:s,areaIdent:s.areaIdent,sideIdent:r,rowIndex:e.r1,columnIndex:e.c1,left:h,top:n,width:S,height:g,parent:i,cellSelected:b,lastRowOfModel:!0,gammaRange:e.gammaRange}):this.renderCell({areaModel:s,areaIdent:s.areaIdent,sideIdent:r,rowIndex:e.r1,columnIndex:e.c1,left:h,top:n,width:S,height:g,parent:i,cellSelected:b,lastRowOfModel:!0,gammaRange:e.gammaRange}),s.areaIdent==="header"&&this.tableOptions.columnsResizable&&this.renderHeaderCellResizeHandle({rowIndex:e.r1,columnIndex:e.c1,cellLeft:h,cellTop:n,cellWidth:S,cellHeight:g,parent:i})}findRowOfImportantRowspanCell(e,t,o){const s=e.getMaxRowspan();for(let i=t-1;i>-1;i--){const r=e.getRowspanAt(i,o);if(r>1&&i+r+1>=t)return i;if(t-i>s)return-1}return-1}adjustColumnsToRowParent({areaIdent:e,sideIdent:t,areaModel:o,geo:s,parent:i,rowIndex:r,columnIndexStart:n,columnIndexEnd:l,verticalFixed:d=!1,lastRowOfModel:c=!1}){var f;this.scrollViewportLeft=this.scrollViewport.scrollLeft;let h=0;if(!d){const u=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();h=this.scrollFactorX*u}const g=0,S=!!(e==="body"&&t);let b=h;for(let u=n;u<=l;u++){const p=b,v=this.tableModel.getColumnWidth(u);if(v>0&&p+v>0){let w=s.height;const x=o.getRowspanAt(r,u),y=o.getColspanAt(r,u);x>1&&(w=this.getRowHeights(r,r+x-1,o).reduce((A,M)=>A+M,0));let m=v;y>1&&(m=this.getColumnWidths(u,u+y-1).reduce((A,M)=>A+M,0));let R=!1;if(this.colAndRowspanModels&&this.colAndRowspanModels[e]&&(f=this.colAndRowspanModels[e])!=null&&f.isInRange(r,u)&&(R=!0),this.draggingTargetColumnIndex===u&&e!=="header"){this.renderDragTargetDiv(i,p,g,m,w);const A={left:p,top:g,width:m,height:w};this.dom.addColumnBorderDivs(this.tableOptions,i,A,e,t)}else{const A=this.renderSelectedBackgroundDiv(R,S,t,o,r,u,i,p,g,m,w);"gammaCells"in o&&o.getValueAt(r,u)&&(R=!1),R||this.renderCell({areaModel:o,areaIdent:e,sideIdent:t,rowIndex:r,columnIndex:u,left:p,top:g,width:m,height:w,parent:i,cellSelected:A,lastRowOfModel:c,gammaRange:!0}),e==="header"&&this.tableOptions.columnsResizable&&this.renderHeaderCellResizeHandle({rowIndex:r,columnIndex:u,cellLeft:p,cellTop:g,cellWidth:m,cellHeight:w,parent:i})}}if(b=b+v,b>this.areaBodyCenterGeo.width)break}this.tableOptions.verticalBorderVisible&&this.dom.addVerticalBorder(new T(b-1,1,s.height,0),i)}getTreeArrowColumnIndex(){return this.tableOptions.showCheckboxWihoutExtraColumn?0:this.tableModel.isRowCheckboxVisible()?1:0}addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:o,rowIndex:s,index:i,left:r,width:n,height:l,top:d,parent:c,lastRowOfModel:h}){var se;const S=this.editorRenderer&&this.editorRendererRow===s&&this.editorRendererColumn===i?this.editorRenderer:e.getCellRenderer(s,i),b={left:r,width:n,height:l,top:d,index:i},f=e.getRowByIndex(s);let u="none";if(i===this.getTreeArrowColumnIndex()&&q(f)){const C=f;(se=C.children)!=null&&se.length?C.expanded?u="expanded":u="collapsed":u="hidden"}let v;if(t==="header"){const C=this.tableModel.getColumnDef(i);(!(C!=null&&C.sortIconVisible)||C!=null&&C.sortIconVisible())&&(v=C==null?void 0:C.sortState)}const w=e.getValueAt(s,i),x=S?"":`${w}`,y=e.isRowChecked(s),m=this.dom.addColumnDiv({parent:c,geo:b,rowIndex:s,columnIndex:i,areaIdent:t,sideIdent:o,text:x,treeArrow:u,tableOptions:this.tableOptions,checkedType:y,sortState:v}),R=e.getTooltipAt(s,i);R&&this.dom.setAttribute(m,"title",R);const A=this.tableModel.getColumnDef(i);A&&A.classes[t]&&this.dom.addClasses(A.classes[t],m);let M;S&&(M=S.render(m,s,i,t,e,w,this.dom.domService));const P=e.getCustomClassesAt(s,i);if(P.length&&this.dom.addClasses(P,m),this.dom.addColumnBorderDivs(this.tableOptions,c,b,t,o),h&&this.dom.addHorizontalBorder({left:r,width:n,height:l,top:d+l},c),this.getFocusModel&&t==="body"){const C=this.getFocusModel();C!=null&&C.hasFocus(s,i)&&this.dom.addFocusBorderDivs(c,b,{})}t==="header"&&this.dom.setAttribute(m,"data-ge-action","drag-column");const z=e.getCustomStyleAt(s,i);if(z)for(const C in z)this.dom.setStyle(m,C,z[C]);return[m,M]}applyCssClasses(e,t={}){e&&Object.entries(t).forEach(([o,s])=>{s?this.dom.addClass(o,e):this.dom.removeClass(o,e)})}getColumnWidths(e,t){const o=[];for(let s=e;s<=t;s++)o.push(this.tableModel.getColumnWidth(s));return o}getRowHeights(e,t,o){const s=[];for(let i=e;i<=t;i++)s.push(o.getRowHeight(i));return s}adjustHoverRows(e){if(this.tableOptions.hoverRowVisible&&e.rowIndex>-1){const t=this.hostElement.clientWidth,o=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:o+"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,o=this.tableModel.getColumnWidth(e.columnIndex),s=this.areaBodyWestGeo.width,i=e.columnLeft+this.tableModel.getPadding().left-this.scrollLeft-s;this.dom.applyStyle(this.hoverColumn,{left:i+"px",top:"0px",width:o+"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)}adjustDraggingColumn(e,t,o){var s,i;if(this.dragging){const r=this.hostElement.clientHeight,n=this.storedColumnWidths[t];if((s=e.originalEvent)!=null&&s.clientX){const c={left:((i=e.originalEvent)==null?void 0:i.clientX)-n/2,width:n,height:r,top:0,index:t};this.dom.applyStyle(this.draggingColumn,{background:"rgba(128,128,128,0.2)",display:"block",overfllow:"clip"}),this.dom.applyStyleInPx(this.draggingColumn,c),o&&this.renderContentOfDraggingColumn(c)}}else this.hideDraggingColumn()}renderContentOfDraggingColumn(e){const t=this.renderContentOfDraggingColumnForArea(e,"header",0);this.renderContentOfDraggingColumnForArea(e,"body",t)}renderContentOfDraggingColumnForArea(e,t,o=0){const s="center",i=this.tableModel.getAreaModel(t),r=i==null?void 0:i.getRowCount();if(r){const n=e.index??0,l=this.draggingColumn;for(let d=0;d<r;d++){const c=o,h=i.getRowHeight(d),g={left:0,width:e.width,height:h,top:c,index:d},S=i.getValueAt(d,n),b=i.getCellRenderer(d,n),f=b?"":`${S}`,u={parent:l,geo:g,rowIndex:d,columnIndex:n,areaIdent:t,sideIdent:s,text:f},p=this.dom.addColumnDiv(u);let v;b&&(v=b.render(p,d,n,t,i,S,this.dom.domService),v&&this.cleanupFunctions[t].push(v));const w=i.getCustomClassesAt(d,n);w.length&&this.dom.addClasses(w,p);const x=this.tableModel.getColumnDef(n);x&&x.classes[t]&&this.dom.addClasses(x.classes[t],p),this.dom.addColumnBorderDivs(this.tableOptions,l,g,t,s);const y=i.getCustomStyleAt(d,n);if(y)for(const m in y)this.dom.setStyle(p,m,y[m]);o=o+h}}return o}hideDraggingColumn(){this.dom.applyStyle(this.draggingColumn,{display:"none"})}renderDragTargetDiv(e,t,o,s,i){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",`${o}px`),this.dom.setStyle(r,"width",`${s}px`),this.dom.setStyle(r,"height",`${i}px`),r}renderSelectedBackgroundDiv(e,t,o,s,i,r,n,l,d,c,h){let g=!1;if(!e&&t&&s.isSelectable(i,r)&&this.getSelectionModel){const S=this.getSelectionModel();if(S){const b=S.getSelectionCount(i,r);g=b>0;for(let f=0;f<b;f++){const u=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass(`ge-table-${s.areaIdent}-${o}-selected-range`,n));this.dom.setStyle(u,"left",`${l}px`),this.dom.setStyle(u,"top",`${d}px`),this.dom.setStyle(u,"width",`${c}px`),this.dom.setStyle(u,"height",`${h}px`)}}}return g}renderCell({areaModel:e,areaIdent:t,sideIdent:o,rowIndex:s,columnIndex:i,left:r,top:n,width:l,height:d,parent:c,cellSelected:h,lastRowOfModel:g}){const[S,b]=this.addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:o,rowIndex:s,index:i,left:r,width:l,height:d,top:n,parent:c,lastRowOfModel:g});h&&this.dom.addClass(`ge-table-${t}-${o}-selected-range`,S),b&&this.cleanupFunctions[t].push(b)}renderHeaderCellResizeHandle({rowIndex:e,columnIndex:t,cellLeft:o,cellTop:s,cellWidth:i,cellHeight:r,parent:n}){const l=this.dom.domService,d=this.tableOptions.columnResizeHandleWidthInPx??2,c=l.createElement("div");l.setAttribute(c,"data-col-index",`${t}`),l.setAttribute(c,"data-row-index",`${e}`),l.setAttribute(c,"data-area","header"),l.setAttribute(c,"data-ge-action","resize-column"),l.addClass(c,"ge-table-column-resize-handle"),l.setStyle(c,"display","clip"),l.setStyle(c,"position","absolute"),l.setStyle(c,"cursor","col-resize"),l.setStyle(c,"left",`${o+i-d}px`),l.setStyle(c,"top",`${s}px`),l.setStyle(c,"width",`${d}px`),l.setStyle(c,"height",`${r}px`),l.appendChild(n,c)}}class Je{constructor(e,t){this.columnIndex=e,this.sortState=t}}class Qe{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,o=t.getAttribute("data-area"),s=t.getAttribute("data-row-index"),i=t.getAttribute("data-col-index");if(o&&s&&i){const r=Z(o),n=Number(s),l=Number(i);this.tableScope.updateModelValueAfterEdit(r,n,l,t.value)}}}}class Ze{constructor(e=-1,t=-1){this.rowIndex=e,this.columnIndex=t}}class te{constructor(e){this.cells=e}static createSingle(e,t){return new te([new Ze(e,t)])}}class et{constructor(e){var t,o;this.tableScope=e,(t=this.tableScope.tableOptions)!=null&&t.getSelectionModel&&(this.getSelectionModel=this.tableScope.tableOptions.getSelectionModel),(o=this.tableScope.tableOptions)!=null&&o.getFocusModel&&(this.getFocusModel=this.tableScope.tableOptions.getFocusModel)}onMouseClicked(e,t){var i,r,n,l,d,c,h;let o=!1,s=!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),this.tableScope.onFocusChanged(S),o=!0),(i=e.originalEvent)!=null&&i.shiftKey||g.hasSelection()&&(g.clear(),o=!0),(r=e.originalEvent)!=null&&r.shiftKey&&this.previousEvt?(g.addSelection(this.createRangeByEvents(e,this.previousEvt)),s=!0,o=!0):(n=e.originalEvent)!=null&&n.altKey&&((l=e.originalEvent)!=null&&l.ctrlKey||(d=e.originalEvent)!=null&&d.metaKey)?(g.removeSelection(E.singleCell(e.rowIndex,e.columnIndex)),s=!0,o=!0):(c=e.originalEvent)!=null&&c.ctrlKey||(h=e.originalEvent)!=null&&h.metaKey?(g.addSelection(E.singleCell(e.rowIndex,e.columnIndex)),s=!0,o=!0):(g.firstClick(e.rowIndex,e.columnIndex),o=!0),this.tableScope.onSelectionChanged(g))}return s?this.previousEvt=void 0:this.previousEvt=e==null?void 0:e.clone(),o}onActionTriggered(e){if(this.getSelectionModel&&this.getFocusModel){const t=this.getSelectionModel(),o=this.getFocusModel();if(t&&o){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,i]=o.getFocus();return t.togglePoint(s,i),this.tableScope.repaint(),!0}}}return!1}createRangeByEvents(e,t){t||(t=e);const o=Math.min(e.rowIndex,t==null?void 0:t.rowIndex),s=Math.max(e.rowIndex,t==null?void 0:t.rowIndex),i=Math.min(e.columnIndex,t==null?void 0:t.columnIndex),r=Math.max(e.columnIndex,t==null?void 0:t.columnIndex);return E.create({rowIndex1:o,columnIndex1:i,rowIndex2:s,columnIndex2:r})}}class tt{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","meta -":"DESELECT_ALL",arrowup:"NAVIGATE_UP",arrowdown:"NAVIGATE_DOWN",arrowleft:"NAVIGATE_LEFT",arrowright:"NAVIGATE_RIGHT","meta+c":"COPY_2_CLIPBOARD","ctrl+c":"COPY_2_CLIPBOARD"}}}class ot{get(){return{f2:"START_EDITING",space:"TOGGLE_SELECTION","ctrl+num_add":"SELECT_ALL","meta+a":"SELECT_ALL","ctrl+a":"SELECT_ALL","meta+x":"DESELECT_ALL","meta+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","meta+c":"COPY_2_CLIPBOARD","ctrl+c":"COPY_2_CLIPBOARD"}}}class st{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.assignPredefinedSystemShortcutMappings(),Object.assign(this.shortcutActionIdMapping,this.tableScope.tableOptions.shortcutActionIdMapping),this.isDebug()&&console.debug("ShortcutService",this.shortcutActionIdMapping),this.tableScope.hostElement.addEventListener("keydown",this.onKeyDown.bind(this))}assignPredefinedSystemShortcutMappings(){this.isMacintosh()?Object.assign(this.shortcutActionIdMapping,new ot().get()):Object.assign(this.shortcutActionIdMapping,new tt().get())}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.findEntity(e);t&&this.emit(t)&&(e.preventDefault(),e.stopPropagation())}emit(e){this.isDebug()&&console.debug("ShortcutService emit :",e);let t=!1;for(const o of this.listener)o.onActionTriggered(e)&&(t=!0);return t}findEntity(e){const t=this.getTokenByEvent(e);this.isDebug()&&console.debug("ShortcutService tokens :",t);for(const o in this.shortcutActionIdMapping){const s=o.replace(/opt/g,"alt").replace(/cmd/g,"meta").split(/[+ ]/g).sort();if(this.areTokensEquals(t,s))return this.shortcutActionIdMapping[o]}}areTokensEquals(e,t){if(e.length!==t.length||e.length===0)return!1;for(let o=0;o<e.length;o++)if(e[o]!==t[o])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()}getShortcutActionMapping(){return this.shortcutActionIdMapping}}class ae{onCheckboxChanged(e){}onContextmenu(e){}onModelChanged(e){}onMouseClicked(e){}onMouseDragging(e){}onMouseDraggingEnd(e){}onMouseMoved(e){}onSelectionChanged(e){}onFocusChanged(e){}}class fe{setStyle(e,t,o){return e.style[t]=o,e}appendText(e,t){const o=this.createText(t);return this.appendChild(e,o),o}addClass(e,t){return t.includes(" ")?t.split(" ").forEach(o=>e.classList.add(o)):e.classList.add(t),e}removeClass(e,t){return t.includes(" ")?t.split(" ").forEach(o=>e.classList.remove(o)):e.classList.remove(t),e}appendChild(e,t){e.appendChild(t)}createElement(e){return document.createElement(e)}createText(e){return document.createTextNode(e)}setAttribute(e,t,o){e.setAttribute(t,o)}}class it{render(e,t,o,s,i,r,n){if(i.isEditable(t,o)){n.addClass(e,"ge-table-row-input-div");const l=i.getValueAt(t,o);e.innerHTML=`
8
+ class="ge-table-row-checkbox"> `,this.domService.setStyle(i,"display","inline"),this.domService.setStyle(i,"width","inherit"),this.domService.setAttribute(i,"data-row-index",`${s}`),this.domService.appendChild(e,i),i}addLabelDiv(e,t="",o=!1,s=-1,i=-1,r="body"){const n=this.domService.createElement("div");if(this.domService.addClass(n,"ge-table-label-div"),this.domService.setStyle(n,"position","relative"),this.domService.setStyle(n,"background","transparent"),this.domService.setStyle(n,"width","100%"),this.domService.setStyle(n,"height","100%"),this.domService.setAttribute(n,"data-row-index",`${s}`),this.domService.setAttribute(n,"data-col-index",`${i}`),this.domService.setAttribute(n,"data-area",`${r}`),t)if(o){const l=this.domService.createText(t);this.domService.appendChild(n,l)}else{const l=this.domService.createElement("div");this.domService.appendChild(n,l);const d=this.domService.createText(t);this.domService.addClass(l,"ge-table-label"),this.domService.appendChild(l,d),this.domService.setAttribute(l,"data-row-index",`${s}`),this.domService.setAttribute(l,"data-col-index",`${i}`),this.domService.setAttribute(l,"data-area",`${r}`)}return this.domService.appendChild(e,n),n}addSortedIcon(e,t="",o=new be,s=-1){const i=this.domService.createElement("div");this.domService.addClass(i,"ge-table-sorted-icon-div"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"top","0"),this.domService.setStyle(i,"right","0"),this.domService.setStyle(i,"width","20px"),this.domService.setStyle(i,"background","transparent"),this.domService.setStyle(i,"cursor","pointer"),this.domService.setAttribute(i,"data-col-index",`${s}`),this.domService.setAttribute(i,"data-area","header");let r;t==="asc"?r=o.iconAsc:t==="desc"?r=o.iconDesc:r=o.iconPlaceholder;const n=r.content,l=this.domService.createText(n);this.domService.appendChild(i,l),r.style&&this.applyStyleString(i,r.style);for(const d of r.classes)this.domService.addClass(i,d);return this.domService.appendChild(e,i),i}addArrowDiv(e,t="none",o=new ue,s=-1,i=-1,r="body"){const n=this.domService.createElement("div");this.domService.addClass(n,"ge-table-tree-arrow-div"),this.domService.setStyle(n,"display","inline-block"),this.domService.setStyle(n,"position",""),this.domService.setStyle(n,"width","20px"),this.domService.setStyle(n,"background","transparent"),this.domService.setStyle(n,"cursor","pointer"),this.domService.setAttribute(n,"data-row-index",`${s}`),this.domService.setAttribute(n,"data-col-index",`${i}`),this.domService.setAttribute(n,"data-area",`${r}`);let l;t==="expanded"?l=o.arrowExpanded:t==="collapsed"?l=o.arrowCollapsed:l=o.arrowPlaceholder;const d=l.content,c=this.domService.createText(d);this.domService.appendChild(n,c),l.style&&this.applyStyleString(n,l.style);for(const h of l.classes)this.domService.addClass(n,h);return this.domService.appendChild(e,n),n}addColumnBorderDivs(e,t,o,s,i){if(e.verticalBorderVisible){const r=`ge-table-${s}-${i}-vertical-border`;this.addVerticalBorder(o,t,r)}if(e.horizontalBorderVisible){const r=`ge-table-${s}-${i}-horizontal-border`;this.addHorizontalBorder(o,t,r)}return t}addHorizontalBorder(e,t,o="ge-table-body-center-horizontal-border"){const s=this.domService.createElement("div");return this.domService.addClass(s,o),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,o){t={...t,width:t.width+1,height:t.height+1};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.domService.setStyle(s,"z-index","9999"),this.applyStyle(s,o),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.domService.setStyle(s,"z-index","9999"),this.applyStyle(s,o),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.domService.setStyle(s,"z-index","9999"),this.applyStyle(s,o),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.domService.setStyle(s,"z-index","9999"),this.applyStyle(s,o),this.domService.appendChild(e,s),e}addVerticalBorder(e,t,o="ge-table-body-center-vertical-border"){const s=this.domService.createElement("div");return this.domService.addClass(s,o),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,o=""){const s=this.domService.createElement("div");return o&&this.domService.addClass(s,o),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 o=t.split(";").map(s=>s.trim()).filter(s=>s);for(const s of o){const[i,r]=s.split(":");this.domService.setStyle(e,i.trim(),r.trim())}}getDivOrCreateDiv(e,t){let o=t.cache[e];return o?(o.innerText="",o):(o=this.domService.createElement("div"),t.cache[e]=o,o)}}const Z=a=>a==="header"?"header":a==="footer"?"footer":"body";class Ge{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 o=e.getAttribute("data-area");if(o&&(this.areaIdent=Z(o),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 ze{constructor(e){this.tableScope=e,this.doubleClickDelay=500,this.expandedAll=!0,this.mouseDown=!1,this.dragging=!1,this.lastClicked=0,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=Date.now();if(t-this.lastClicked<this.doubleClickDelay)return;this.lastClicked=t;const o=new Ge(e.target,this.tableScope);if(o.action==="toggleExpandCollapseAll")this.expandedAll=!this.expandedAll,this.tableScope.toggleExpandCollapseAll(this.expandedAll),e.preventDefault(),e.stopPropagation();else if(o.action==="toggleHeaderGroup")this.tableScope.toggleHeaderGroup(o),e.preventDefault(),e.stopPropagation();else if(o.inputType==="checkbox"&&o.areaIdent)this.tableScope.toggleRowCheckbox(o.rowIdx,o.colIdx,o.areaIdent),e.preventDefault(),e.stopPropagation();else if(q(o.row)&&o.areaModel){const s=o.colIdx===this.getArrowColumnIndex()&&e.altKey,i=o.className.includes("ge-table-tree-arrow-div");if(s||i){e.preventDefault(),e.stopPropagation();const r=o.row;r.expanded=!r.expanded,"recalcVisibleTreeRows"in o.areaModel&&o.areaModel.recalcVisibleTreeRows(),this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth),this.tableScope.adjustContainersAndRows(),this.updateCollapsedExpandedState(r)}}if(o.areaIdent==="body"&&this.tableScope.tableOptions.getFocusModel){const s=this.tableScope.tableOptions.getFocusModel();s==null||s.clear(),s==null||s.setFocus(o.rowIdx,o.colIdx)}this.publishGeMouseEvent(e,1)}onHostElementDblClicked(e){if(this.lastClicked=Date.now(),e.target instanceof HTMLElement){const t=e.target,o=t.getAttribute("data-area"),s=Z(o),i=Number(t.getAttribute("data-row-index")),r=Number(t.getAttribute("data-col-index")),n=this.tableScope.tableModel.getAreaModel(s);if(o&&s==="header")this.tableScope.tableModel.isSortable(r)&&(this.tableScope.clearSelection(),this.tableScope.onHeaderDblClicked(e,i,r));else if(t.getAttribute("data-row-index")){const l=n.getRowByIndex(i);if(o&&s==="body"&&n.isEditable(i,r)&&(this.tableScope.clearSelection(),this.tableScope.initRenderEditor(i,r)),q(l)&&r===this.getArrowColumnIndex()){e.preventDefault(),e.stopPropagation();const d=l;d.expanded=!d.expanded,"recalcVisibleTreeRows"in n&&n.recalcVisibleTreeRows(),this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth),this.tableScope.adjustContainersAndRows(),this.updateCollapsedExpandedState(d)}}}this.publishGeMouseEvent(e,2)}publishGeMouseEvent(e,t){var o;this.mouseEvent=e,this.geMouseEventOld=(o=this.geMouseEvent)==null?void 0:o.clone(),this.geMouseEvent=this.tableScope.createGeMouseEvent(e),this.geMouseEvent&&(this.geMouseEvent.clickCount=t),this.tableScope.onMouseClicked(this.geMouseEvent,this.geMouseEventOld),this.tableScope.publishGeMouseEvent(this.geMouseEvent),t===1&&this.tableScope.debounceRepaint()}updateCollapsedExpandedState(e){var o,s,i,r,n;const t=(s=(o=this.tableScope.tableOptions)==null?void 0:o.autoRestoreOptions)==null?void 0:s.getRowId;if(t){const l=(i=this.tableScope.storeStateCollapsedExpandService)==null?void 0:i.collapsedExpandedStateGet().mode,d=l==="collapsed"&&!e.expanded||l==="expanded"&&e.expanded,c=l==="collapsed"&&e.expanded||l==="expanded"&&!e.expanded,h=t(e.data);d?(r=this.tableScope.storeStateCollapsedExpandService)==null||r.collapsedStateIdsPush(h):c&&((n=this.tableScope.storeStateCollapsedExpandService)==null||n.collapsedStateIdsRemove(h))}}getArrowColumnIndex(){return this.tableScope.tableModel.isRowCheckboxVisible()?1:0}onMouseDown(e){this.dragging||(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||(this.dragging=!0,this.tableScope.setDragging(!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,this.tableScope.setDragging(!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,this.startMouseEvent)}}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 Ve{constructor(e){this.tableScope=e}updateCells(e,t=!1){this.tableScope.updateCells(e,t)}externalFilterChanged(){this.tableScope.externalFilterChanged()}scrollToPixel(e=0,t=0){this.tableScope.scrollToPixel(e,t)}scrollToIndex(e=0,t=0){this.tableScope.scrollToIndex(e,t)}setHeaderVisible(e=!0){}setColumnVisible(e,t=!0){}isColumnVisible(e){return!0}isHeaderVisible(){return!0}setFooterVisible(e=!0){}isFooterVisible(){return!0}repaint(){this.tableScope.repaint()}repaintHard(){this.tableScope.repaintHard()}recalcColumnWidths(e){this.tableScope.recalcColumnWidths(e)}clearSelection(){this.tableScope.clearSelection(!0)}setSelectionModel(e,t=!0){this.tableScope.setSelectionModel(e,t)}triggerAction(e){this.tableScope.onActionTriggered(e)}getShortcutActionMapping(){return this.tableScope.shortcutService.getShortcutActionMapping()}copyToClipboard(){return this.tableScope.copyService.copyToClipboard(this.tableScope.tableModel,this.tableScope.selectionModel(),this.tableScope.focusModel())}getTableScope(){return this.tableScope}getSelectionModel(){return this.tableScope.selectionModel()}}class ee{constructor(e){this.getStorageKeyFn=e}autoConvertMapToObject(e){const t={};if(e instanceof Map){const o=e;for(const s of[...o]){const[i,r]=s;t[i]=r}}return t}checkAndPersistItem(e,t){const o=this.getStorageKeyFn;if(o){const s=o();if(s){const i=s+e;if((t+"").includes("Map")){const r=this.autoConvertMapToObject(t);this.persistItem(i,r)}else this.persistItem(i,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 Ne extends ee{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 o=t+this.SCROLL_STATE;let s=this.loadFromLocalStorage(o);this.scrollOffset=s||[0,0]}}}}class je{constructor(e="collapsed",t=[],o=!1,s=!1){this.mode=e,this.rowIds=t,this.allCollapsed=o,this.allExpanded=s}}class Xe extends ee{constructor(e){super(e),this.COLLAPSED_EXPANDED_STATE="collapsedExpandedState",this.collapsedExpandedState=new je,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 o=t+this.COLLAPSED_EXPANDED_STATE,s=this.loadFromLocalStorage(o);s&&(this.collapsedExpandedState=s)}}}persist(){this.checkAndPersistItem(this.COLLAPSED_EXPANDED_STATE,this.collapsedExpandedState)}}class Ke extends ee{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 o=t+this.SORTING_STATE,s=this.loadFromLocalStorage(o);this.sortItems=s||[]}}}}class T{constructor(e=0,t=0,o=0,s=0,i){this.left=e,this.width=t,this.height=o,this.top=s,this.index=i}}class Ye{constructor(e,t,o,s){this.hostElement=e,this.tableModel=t,this.dom=o,this.tableOptions=s,this.scrollTop=0,this.areaBodyWestGeo=new T,this.areaBodyCenterGeo=new T,this.areaBodyEastGeo=new T;const i=this.hostElement;i.innerText="",this.dom.setAttribute(i,"tabindex","0"),this.dom.setStyle(this.dom.addClass("ge-table",i),"position","relative"),this.hoverRow=o.applyStylePosistionAbsolute(o.createDivWithClass("ge-table-hover-row",i)),this.hoverColumn=o.applyStylePosistionAbsolute(o.createDivWithClass("ge-table-hover-column",i)),this.draggingColumn=o.applyStylePosistionAbsolute(o.createDivWithClass("ge-table-dragging-column",i)),this.areaHeaderWest=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-header ge-table-header-west",i,"header","west"))),this.areaHeaderCenter=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-header ge-table-header-center",i,"header","center"))),this.areaHeaderEast=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-header ge-table-header-east",i,"body","east"))),this.areaBodyWest=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-body ge-table-body-west",i,"body","west"))),this.areaBodyEast=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-body ge-table-body-east",i,"body","east"))),this.areaFooterWest=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-footer ge-table-footer-west",i,"footer","west"))),this.areaFooterCenter=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-footer ge-table-footer-center",i,"footer","center"))),this.areaFooterEast=o.appendRelativeChildDiv(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-footer ge-table-footer-east",i,"footer","east"))),this.scrollViewport=o.applyStyleOverflowAuto(this.tableOptions.overflowX??"auto",this.tableOptions.overflowY??"auto",o.applyStyleNoPadding(o.applyStylePosistionAbsolute(o.createAreaDivWithClass("ge-table-scroll-viewport",i,"body","center")))),this.contentWrapperDiv=o.applyStyleNoPadding(o.applyStylePosistionRelative(o.createDivWithClass("ge-table-scroll-content-wrapper",this.scrollViewport))),this.contentDiv=o.applyStyleNoPadding(o.applyStylePosistionRelative(o.createDivWithClass("ge-table-scroll-content",this.contentWrapperDiv))),this.areaBodyCenter=o.appendRelativeChildDiv(o.createDivWithClass("ge-table-body-center",this.contentDiv)),this.borderHeaderBottom=o.applyStylePosistionAbsolute(o.createDivWithClass("ge-table-header-border",i)),this.borderFixedWest=o.applyStylePosistionAbsolute(o.createDivWithClass("ge-table-west-fixed-column-border",i)),this.borderFixedEast=o.applyStylePosistionAbsolute(o.createDivWithClass("ge-table-east-fixed-column-border",i)),this.borderFooterTop=o.applyStylePosistionAbsolute(o.createDivWithClass("ge-table-footer-border",i))}adjustContainersAndRows(){const e=this.tableModel.getPadding(),t=this.hostElement.clientWidth,o=this.hostElement.clientHeight;this.dom.applyStyle(this.scrollViewport,{width:`${t-e.left}px`,height:`${o-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=o-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=o-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=o-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:`${o-e.bottom}px`,left:"0"}),this.dom.applyStyle(this.areaFooterCenter.parent,{width:`${t-e.left-e.right}px`,height:`${e.bottom}px`,top:`${o-e.bottom}px`,left:`${e.left}px`}),this.dom.applyStyle(this.areaFooterEast.parent,{width:`${e.right}px`,height:`${e.bottom}px`,top:`${o-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:`${o-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 E{constructor(e,t,o,s,i=!1){this.r1=e,this.c1=t,this.r2=o,this.c2=s,this.gammaRange=i}static create(e){return e.gammaRange===void 0&&(e.gammaRange=!1),new E(e.rowIndex1,e.columnIndex1,e.rowIndex2,e.columnIndex2,e.gammaRange)}static singleCell(e,t){return new E(e,t,e,t)}static singleRow(e){return new E(e,0,e,Number.MAX_SAFE_INTEGER)}static singleColumn(e){return new E(0,e,Number.MAX_SAFE_INTEGER,e)}isInRange(e,t){return e>=this.r1&&e<=this.r2&&t>=this.c1&&t<=this.c2}}class qe{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 o=0;o<e;o++)for(let s=0;s<t;s++){let i=this.areaModel.getColspanAt(o,s),r=this.areaModel.getRowspanAt(o,s);if(i>1||r>1){i===0&&(i=1),r===0&&(r=1);const n="gammaCells"in this.areaModel;this.colAndRowspanRanges.push(new E(o,s,o+r-1,s+i-1,n))}}}getRanges(){return this.colAndRowspanRanges?this.colAndRowspanRanges:[]}isInRange(e,t){if(this.colAndRowspanRanges){for(const o of this.colAndRowspanRanges)if(o.isInRange(e,t))return!0}return!1}}class Ue{constructor(e,t,o){this.header=e,this.body=t,this.footer=o}}class Je extends Ye{constructor(e,t,o,s){var r,n;super(e,t,o,s),this.dragging=!1,this.editing=!1,this.storedColumnWidths=[],this.scrollLeft=0,this.scrollViewportLeft=0,this.scrollFactorY=0,this.scrollFactorX=0,this.cleanupFunctions={header:[],body:[],footer:[]},this.tree=!1,this.colAndRowspanModels=new Ue,this.firstVisibleRowIndex=-1,this.draggingTargetColumnIndex=-1,this.removables=[],this.tableModel.getSelectionModel?this.getSelectionModel=this.tableModel.getSelectionModel:(r=this.tableOptions)!=null&&r.getSelectionModel&&(this.getSelectionModel=this.tableOptions.getSelectionModel),(n=this.tableOptions)!=null&&n.getFocusModel&&(this.getFocusModel=this.tableOptions.getFocusModel),U(t.getAreaModel("body"))&&(this.tree=!0),["header","body","footer"].forEach(l=>{var d;this.colAndRowspanModels[l]=new qe(t,t.getAreaModel(l)),(d=this.colAndRowspanModels[l])==null||d.init()})}isEditing(){return this.editing}resetEditorRenderer(){this.editorRenderer=void 0,this.editorRendererRow=-1,this.editorRendererColumn=-1,this.editing=!1}clearSelection(e=!1){if(this.getSelectionModel){const t=this.getSelectionModel();t==null||t.clear(),e&&this.repaint()}}initRenderEditor(e,t){var s;let o=(s=this.tableModel.getColumnDef(t))==null?void 0:s.getEditRenderer;if(o||(o=this.tableOptions.getEditRenderer),o)if(this.editorRenderer=o(e,t),this.editorRenderer){this.editorRendererRow=e,this.editorRendererColumn=t,this.editing=!0,this.repaint();const i=document.querySelector("input.ge-table-cell-editor-input");i&&i.focus()}else this.resetEditorRenderer()}repaint(){this.adjustAfterScrolling()}repaintHard(){this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows(),this.adjustAfterScrolling()}recalcColumnWidths(e){let t=e||this.scrollViewport.clientWidth;this.tableModel.setParentWidth(t),this.tableModel.init(),this.repaintHard()}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,t=!1){e.forEach(o=>{this.tableModel.getAreaModel(o.area).setValue(o.rowIndex,o.columnIndex,o.value),t||this.rerenderCellContent(o)}),t&&this.repaint()}rerenderCellContent({area:e,rowIndex:t,columnIndex:o,value:s,cssClasses:i}){const r=this.tableModel.getAreaModel(e),n='div[data-col-index="'+o+'"][data-row-index="'+t+'"][data-area="'+e+'"]',l=document.querySelector(n);if(l){let d;const h=this.editorRenderer&&this.editorRendererRow===t&&this.editorRendererColumn===o?this.editorRenderer:r.getCellRenderer(t,o);if(l.innerText="",this.applyCssClasses(l,i),h)d=h.render(l,t,o,e,r,s,this.dom.domService),d&&this.cleanupFunctions[e].push(d);else{const b=`${s}`;this.dom.addLabelDiv(l,b,!1,t,o,e)}const g=r.getCustomClassesAt(t,o);g.length&&this.dom.addClasses(g,l);const S=r.getCustomStyleAt(t,o);if(S)for(const b in S)this.dom.setStyle(l,b,S[b])}}storeColumnWidths(){const e=this.tableModel.getColumnDefs();e!=null&&e.length&&(this.storedColumnWidths=e.map((t,o)=>this.tableModel.getColumnWidth(o)))}getAreaAndSideIdentByAttr(e){if(e){const t=this.getStringByAttr(e,"data-area"),o=this.getStringByAttr(e,"data-side");if(o&&t)return[t,o]}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 o;if(e){const s=(o=e.closest("["+t+"]"))==null?void 0:o.getAttribute(t);if(s)return Number(s)}return-1}getStringByAttr(e,t){var o;if(e){const s=(o=e.closest("["+t+"]"))==null?void 0:o.getAttribute(t);if(s)return s}return""}adjustArea(e,t=0){var u;const o=this.getArea(e,"west"),s=this.getArea(e,"center"),i=this.getArea(e,"east"),r=s.child.clientHeight;o.child.innerText="",s.child.innerText="",i.child.innerText="";const n=0,l=this.areaBodyCenterGeo.width,d=this.tableModel.getPadding(),c=this.tableModel.getAreaModel(e),h=c.getRowCount();for(;this.cleanupFunctions[e].length;){const p=this.cleanupFunctions[e].shift();p&&p()}let g=t;const S=this.tableModel.getColumnCount(),b=this.tableModel.getFixedRightColumnCount(),f=this.tableModel.getFixedLeftColumnCount();for(let p=0;p<h;p++){const v=g,w=p===h-1,x=this.tableModel.getRowHeight(e,p);if(v+x>0){this.firstVisibleRowIndex=p;let y={left:n,width:l,height:x,top:v,index:p},m=this.dom.addRowDiv(s,y,p,e,"center");const R=f;if(this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"center",areaModel:c,geo:y,parent:m,rowIndex:p,columnIndexStart:R,columnIndexEnd:S-b-1,verticalFixed:!1,lastRowOfModel:w}),d.left>0&&(y={left:n,width:this.areaBodyWestGeo.width,height:x,top:v,index:p},m=this.dom.addRowDiv(o,y,p,e,"west"),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"west",areaModel:c,geo:y,parent:m,rowIndex:p,columnIndexStart:0,columnIndexEnd:R-1,verticalFixed:!0,lastRowOfModel:w})),d.right>0&&(y={left:n,width:this.areaBodyEastGeo.width,height:x,top:v,index:p},m=this.dom.addRowDiv(i,y,p,e,"east"),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"east",areaModel:c,geo:y,parent:m,rowIndex:p,columnIndexStart:S-b,columnIndexEnd:S-1,verticalFixed:!0,lastRowOfModel:w})),e==="header"&&this.tree&&p===h-1){const A=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 P=this.dom.domService.createText(M.content);this.dom.domService.appendChild(A,P),M.style&&this.dom.applyStyleString(A,M.style)}}}if(g=g+x,g>r)break}if(this.colAndRowspanModels&&this.colAndRowspanModels[e]){const p=((u=this.colAndRowspanModels[e])==null?void 0:u.getRanges())??[];if(p.length)for(const v of p){let w=0,x=s.child,y="center";if(v.c1<f)x=o.child,y="west";else if(b>0&&v.c1>=S-b)x=i.child,y="east";else{const m=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();w=this.scrollFactorX*m-this.areaBodyWestGeo.width,y="center"}this.drawBigCell(v,w,t,c,x,y)}}}drawBigCell(e,t,o,s,i,r){const n=o+this.getRowHeights(0,e.r1-1,s).reduce((u,p)=>u+p,0),l=this.tableModel.getColumnCount(),d=this.tableModel.getFixedRightColumnCount();let c=0;d>0&&e.c1>=l-d&&(c=l-d);const h=t+this.getColumnWidths(c,e.c1-1).reduce((u,p)=>u+p,0),g=this.getRowHeights(e.r1,e.r2,s).reduce((u,p)=>u+p,0),S=this.getColumnWidths(e.c1,e.c2).reduce((u,p)=>u+p,0);let b=!1;const f=this.getSelectionModel?this.getSelectionModel():void 0;f&&(b=f.getSelectionCount(e.r1,e.c1)>0),e.gammaRange?this.renderCell({areaModel:s,areaIdent:s.areaIdent,sideIdent:r,rowIndex:e.r1,columnIndex:e.c1,left:h,top:n,width:S,height:g,parent:i,cellSelected:b,lastRowOfModel:!0,gammaRange:e.gammaRange}):this.renderCell({areaModel:s,areaIdent:s.areaIdent,sideIdent:r,rowIndex:e.r1,columnIndex:e.c1,left:h,top:n,width:S,height:g,parent:i,cellSelected:b,lastRowOfModel:!0,gammaRange:e.gammaRange}),s.areaIdent==="header"&&this.tableOptions.columnsResizable&&this.renderHeaderCellResizeHandle({rowIndex:e.r1,columnIndex:e.c1,cellLeft:h,cellTop:n,cellWidth:S,cellHeight:g,parent:i})}findRowOfImportantRowspanCell(e,t,o){const s=e.getMaxRowspan();for(let i=t-1;i>-1;i--){const r=e.getRowspanAt(i,o);if(r>1&&i+r+1>=t)return i;if(t-i>s)return-1}return-1}adjustColumnsToRowParent({areaIdent:e,sideIdent:t,areaModel:o,geo:s,parent:i,rowIndex:r,columnIndexStart:n,columnIndexEnd:l,verticalFixed:d=!1,lastRowOfModel:c=!1}){var f;this.scrollViewportLeft=this.scrollViewport.scrollLeft;let h=0;if(!d){const u=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();h=this.scrollFactorX*u}const g=0,S=!!(e==="body"&&t);let b=h;for(let u=n;u<=l;u++){const p=b,v=this.tableModel.getColumnWidth(u);if(v>0&&p+v>0){let w=s.height;const x=o.getRowspanAt(r,u),y=o.getColspanAt(r,u);x>1&&(w=this.getRowHeights(r,r+x-1,o).reduce((A,M)=>A+M,0));let m=v;y>1&&(m=this.getColumnWidths(u,u+y-1).reduce((A,M)=>A+M,0));let R=!1;if(this.colAndRowspanModels&&this.colAndRowspanModels[e]&&(f=this.colAndRowspanModels[e])!=null&&f.isInRange(r,u)&&(R=!0),this.draggingTargetColumnIndex===u&&e!=="header"){this.renderDragTargetDiv(i,p,g,m,w);const A={left:p,top:g,width:m,height:w};this.dom.addColumnBorderDivs(this.tableOptions,i,A,e,t)}else{const A=this.renderSelectedBackgroundDiv(R,S,t,o,r,u,i,p,g,m,w);"gammaCells"in o&&o.getValueAt(r,u)&&(R=!1),R||this.renderCell({areaModel:o,areaIdent:e,sideIdent:t,rowIndex:r,columnIndex:u,left:p,top:g,width:m,height:w,parent:i,cellSelected:A,lastRowOfModel:c,gammaRange:!0}),e==="header"&&this.tableOptions.columnsResizable&&this.renderHeaderCellResizeHandle({rowIndex:r,columnIndex:u,cellLeft:p,cellTop:g,cellWidth:m,cellHeight:w,parent:i})}}if(b=b+v,b>this.areaBodyCenterGeo.width)break}this.tableOptions.verticalBorderVisible&&this.dom.addVerticalBorder(new T(b-1,1,s.height,0),i)}getTreeArrowColumnIndex(){return this.tableOptions.showCheckboxWihoutExtraColumn?0:this.tableModel.isRowCheckboxVisible()?1:0}addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:o,rowIndex:s,index:i,left:r,width:n,height:l,top:d,parent:c,lastRowOfModel:h}){var se;const S=this.editorRenderer&&this.editorRendererRow===s&&this.editorRendererColumn===i?this.editorRenderer:e.getCellRenderer(s,i),b={left:r,width:n,height:l,top:d,index:i},f=e.getRowByIndex(s);let u="none";if(i===this.getTreeArrowColumnIndex()&&q(f)){const C=f;(se=C.children)!=null&&se.length?C.expanded?u="expanded":u="collapsed":u="hidden"}let v;if(t==="header"){const C=this.tableModel.getColumnDef(i);(!(C!=null&&C.sortIconVisible)||C!=null&&C.sortIconVisible())&&(v=C==null?void 0:C.sortState)}const w=e.getValueAt(s,i),x=S?"":`${w}`,y=e.isRowChecked(s),m=this.dom.addColumnDiv({parent:c,geo:b,rowIndex:s,columnIndex:i,areaIdent:t,sideIdent:o,text:x,treeArrow:u,tableOptions:this.tableOptions,checkedType:y,sortState:v}),R=e.getTooltipAt(s,i);R&&this.dom.setAttribute(m,"title",R);const A=this.tableModel.getColumnDef(i);A&&A.classes[t]&&this.dom.addClasses(A.classes[t],m);let M;S&&(M=S.render(m,s,i,t,e,w,this.dom.domService));const P=e.getCustomClassesAt(s,i);if(P.length&&this.dom.addClasses(P,m),this.dom.addColumnBorderDivs(this.tableOptions,c,b,t,o),h&&this.dom.addHorizontalBorder({left:r,width:n,height:l,top:d+l},c),this.getFocusModel&&t==="body"){const C=this.getFocusModel();C!=null&&C.hasFocus(s,i)&&this.dom.addFocusBorderDivs(c,b,{})}t==="header"&&this.dom.setAttribute(m,"data-ge-action","drag-column");const V=e.getCustomStyleAt(s,i);if(V)for(const C in V)this.dom.setStyle(m,C,V[C]);return[m,M]}applyCssClasses(e,t={}){e&&Object.entries(t).forEach(([o,s])=>{s?this.dom.addClass(o,e):this.dom.removeClass(o,e)})}getColumnWidths(e,t){const o=[];for(let s=e;s<=t;s++)o.push(this.tableModel.getColumnWidth(s));return o}getRowHeights(e,t,o){const s=[];for(let i=e;i<=t;i++)s.push(o.getRowHeight(i));return s}adjustHoverRows(e){if(this.tableOptions.hoverRowVisible&&e.rowIndex>-1){const t=this.hostElement.clientWidth,o=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:o+"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,o=this.tableModel.getColumnWidth(e.columnIndex),s=this.areaBodyWestGeo.width,i=e.columnLeft+this.tableModel.getPadding().left-this.scrollLeft-s;this.dom.applyStyle(this.hoverColumn,{left:i+"px",top:"0px",width:o+"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)}adjustDraggingColumn(e,t,o){var s,i;if(this.dragging){const r=this.hostElement.clientHeight,n=this.storedColumnWidths[t];if((s=e.originalEvent)!=null&&s.clientX){const c={left:((i=e.originalEvent)==null?void 0:i.clientX)-n/2,width:n,height:r,top:0,index:t};this.dom.applyStyle(this.draggingColumn,{background:"rgba(128,128,128,0.2)",display:"block",overfllow:"clip"}),this.dom.applyStyleInPx(this.draggingColumn,c),o&&this.renderContentOfDraggingColumn(c)}}else this.hideDraggingColumn()}renderContentOfDraggingColumn(e){const t=this.renderContentOfDraggingColumnForArea(e,"header",0);this.renderContentOfDraggingColumnForArea(e,"body",t)}renderContentOfDraggingColumnForArea(e,t,o=0){const s="center",i=this.tableModel.getAreaModel(t),r=i==null?void 0:i.getRowCount();if(r){const n=e.index??0,l=this.draggingColumn;for(let d=0;d<r;d++){const c=o,h=i.getRowHeight(d),g={left:0,width:e.width,height:h,top:c,index:d},S=i.getValueAt(d,n),b=i.getCellRenderer(d,n),f=b?"":`${S}`,u={parent:l,geo:g,rowIndex:d,columnIndex:n,areaIdent:t,sideIdent:s,text:f},p=this.dom.addColumnDiv(u);let v;b&&(v=b.render(p,d,n,t,i,S,this.dom.domService),v&&this.cleanupFunctions[t].push(v));const w=i.getCustomClassesAt(d,n);w.length&&this.dom.addClasses(w,p);const x=this.tableModel.getColumnDef(n);x&&x.classes[t]&&this.dom.addClasses(x.classes[t],p),this.dom.addColumnBorderDivs(this.tableOptions,l,g,t,s);const y=i.getCustomStyleAt(d,n);if(y)for(const m in y)this.dom.setStyle(p,m,y[m]);o=o+h}}return o}hideDraggingColumn(){this.dom.applyStyle(this.draggingColumn,{display:"none"})}renderDragTargetDiv(e,t,o,s,i){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",`${o}px`),this.dom.setStyle(r,"width",`${s}px`),this.dom.setStyle(r,"height",`${i}px`),r}renderSelectedBackgroundDiv(e,t,o,s,i,r,n,l,d,c,h){let g=!1;if(!e&&t&&s.isSelectable(i,r)&&this.getSelectionModel){const S=this.getSelectionModel();if(S){const b=S.getSelectionCount(i,r);g=b>0;for(let f=0;f<b;f++){const u=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass(`ge-table-${s.areaIdent}-${o}-selected-range`,n));this.dom.setStyle(u,"left",`${l}px`),this.dom.setStyle(u,"top",`${d}px`),this.dom.setStyle(u,"width",`${c}px`),this.dom.setStyle(u,"height",`${h}px`)}}}return g}renderCell({areaModel:e,areaIdent:t,sideIdent:o,rowIndex:s,columnIndex:i,left:r,top:n,width:l,height:d,parent:c,cellSelected:h,lastRowOfModel:g}){const[S,b]=this.addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:o,rowIndex:s,index:i,left:r,width:l,height:d,top:n,parent:c,lastRowOfModel:g});h&&this.dom.addClass(`ge-table-${t}-${o}-selected-range`,S),b&&this.cleanupFunctions[t].push(b)}renderHeaderCellResizeHandle({rowIndex:e,columnIndex:t,cellLeft:o,cellTop:s,cellWidth:i,cellHeight:r,parent:n}){const l=this.dom.domService,d=this.tableOptions.columnResizeHandleWidthInPx??2,c=l.createElement("div");l.setAttribute(c,"data-col-index",`${t}`),l.setAttribute(c,"data-row-index",`${e}`),l.setAttribute(c,"data-area","header"),l.setAttribute(c,"data-ge-action","resize-column"),l.addClass(c,"ge-table-column-resize-handle"),l.setStyle(c,"display","clip"),l.setStyle(c,"position","absolute"),l.setStyle(c,"cursor","col-resize"),l.setStyle(c,"left",`${o+i-d}px`),l.setStyle(c,"top",`${s}px`),l.setStyle(c,"width",`${d}px`),l.setStyle(c,"height",`${r}px`),l.appendChild(n,c)}}class Qe{constructor(e,t){this.columnIndex=e,this.sortState=t}}class Ze{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,o=t.getAttribute("data-area"),s=t.getAttribute("data-row-index"),i=t.getAttribute("data-col-index");if(o&&s&&i){const r=Z(o),n=Number(s),l=Number(i);this.tableScope.updateModelValueAfterEdit(r,n,l,t.value)}}}}class et{constructor(e=-1,t=-1){this.rowIndex=e,this.columnIndex=t}}class te{constructor(e){this.cells=e}static createSingle(e,t){return new te([new et(e,t)])}}class tt{constructor(e){var t,o;this.tableScope=e,(t=this.tableScope.tableOptions)!=null&&t.getSelectionModel&&(this.getSelectionModel=this.tableScope.tableOptions.getSelectionModel),(o=this.tableScope.tableOptions)!=null&&o.getFocusModel&&(this.getFocusModel=this.tableScope.tableOptions.getFocusModel)}onMouseClicked(e,t){var i,r,n,l,d,c,h;let o=!1,s=!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),this.tableScope.onFocusChanged(S),o=!0),(i=e.originalEvent)!=null&&i.shiftKey||g.hasSelection()&&(g.clear(),o=!0),(r=e.originalEvent)!=null&&r.shiftKey&&this.previousEvt?(g.addSelection(this.createRangeByEvents(e,this.previousEvt)),s=!0,o=!0):(n=e.originalEvent)!=null&&n.altKey&&((l=e.originalEvent)!=null&&l.ctrlKey||(d=e.originalEvent)!=null&&d.metaKey)?(g.removeSelection(E.singleCell(e.rowIndex,e.columnIndex)),s=!0,o=!0):(c=e.originalEvent)!=null&&c.ctrlKey||(h=e.originalEvent)!=null&&h.metaKey?(g.addSelection(E.singleCell(e.rowIndex,e.columnIndex)),s=!0,o=!0):(g.firstClick(e.rowIndex,e.columnIndex),o=!0),this.tableScope.onSelectionChanged(g))}return s?this.previousEvt=void 0:this.previousEvt=e==null?void 0:e.clone(),o}onActionTriggered(e){if(this.getSelectionModel&&this.getFocusModel){const t=this.getSelectionModel(),o=this.getFocusModel();if(t&&o){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,i]=o.getFocus();return t.togglePoint(s,i),this.tableScope.repaint(),!0}}}return!1}createRangeByEvents(e,t){t||(t=e);const o=Math.min(e.rowIndex,t==null?void 0:t.rowIndex),s=Math.max(e.rowIndex,t==null?void 0:t.rowIndex),i=Math.min(e.columnIndex,t==null?void 0:t.columnIndex),r=Math.max(e.columnIndex,t==null?void 0:t.columnIndex);return E.create({rowIndex1:o,columnIndex1:i,rowIndex2:s,columnIndex2:r})}}class ot{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","meta -":"DESELECT_ALL",arrowup:"NAVIGATE_UP",arrowdown:"NAVIGATE_DOWN",arrowleft:"NAVIGATE_LEFT",arrowright:"NAVIGATE_RIGHT","meta+c":"COPY_2_CLIPBOARD","ctrl+c":"COPY_2_CLIPBOARD"}}}class st{get(){return{f2:"START_EDITING",space:"TOGGLE_SELECTION","ctrl+num_add":"SELECT_ALL","meta+a":"SELECT_ALL","ctrl+a":"SELECT_ALL","meta+x":"DESELECT_ALL","meta+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","meta+c":"COPY_2_CLIPBOARD","ctrl+c":"COPY_2_CLIPBOARD"}}}class it{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.assignPredefinedSystemShortcutMappings(),Object.assign(this.shortcutActionIdMapping,this.tableScope.tableOptions.shortcutActionIdMapping),this.isDebug()&&console.debug("ShortcutService",this.shortcutActionIdMapping),this.tableScope.hostElement.addEventListener("keydown",this.onKeyDown.bind(this))}assignPredefinedSystemShortcutMappings(){this.isMacintosh()?Object.assign(this.shortcutActionIdMapping,new st().get()):Object.assign(this.shortcutActionIdMapping,new ot().get())}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.findEntity(e);t&&this.emit(t)&&(e.preventDefault(),e.stopPropagation())}emit(e){this.isDebug()&&console.debug("ShortcutService emit :",e);let t=!1;for(const o of this.listener)o.onActionTriggered(e)&&(t=!0);return t}findEntity(e){const t=this.getTokenByEvent(e);this.isDebug()&&console.debug("ShortcutService tokens :",t);for(const o in this.shortcutActionIdMapping){const s=o.replace(/opt/g,"alt").replace(/cmd/g,"meta").split(/[+ ]/g).sort();if(this.areTokensEquals(t,s))return this.shortcutActionIdMapping[o]}}areTokensEquals(e,t){if(e.length!==t.length||e.length===0)return!1;for(let o=0;o<e.length;o++)if(e[o]!==t[o])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()}getShortcutActionMapping(){return this.shortcutActionIdMapping}}class ae{onCheckboxChanged(e){}onContextmenu(e){}onModelChanged(e){}onMouseClicked(e){}onMouseDragging(e){}onMouseDraggingEnd(e){}onMouseMoved(e){}onSelectionChanged(e){}onFocusChanged(e){}}class fe{setStyle(e,t,o){return e.style[t]=o,e}appendText(e,t){const o=this.createText(t);return this.appendChild(e,o),o}addClass(e,t){return t.includes(" ")?t.split(" ").forEach(o=>e.classList.add(o)):e.classList.add(t),e}removeClass(e,t){return t.includes(" ")?t.split(" ").forEach(o=>e.classList.remove(o)):e.classList.remove(t),e}appendChild(e,t){e.appendChild(t)}createElement(e){return document.createElement(e)}createText(e){return document.createTextNode(e)}setAttribute(e,t,o){e.setAttribute(t,o)}}class rt{render(e,t,o,s,i,r,n){if(i.isEditable(t,o)){n.addClass(e,"ge-table-row-input-div");const l=i.getValueAt(t,o);e.innerHTML=`
9
9
  <input
10
10
  type="text"
11
11
  value="${l}"
@@ -17,8 +17,8 @@
17
17
  data-col-index="${o}"
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 rt{constructor(e="none",t="single"){this.selectionType=e,this.selectionMode=t,this.ranges=[],this.negativeRanges=[],this.allSelected=!1,this.silent=!1,this.listenerArr=[]}getEventSelectionChangedListeners(){return this.listenerArr}addEventSelectionChangedListener(e){this.listenerArr.includes(e)||this.listenerArr.push(e)}removeEventSelectionChangedListener(e){const t=this.listenerArr.indexOf(e,0);t>-1&&this.listenerArr.splice(t,1)}fireChangeEvent(){this.silent||this.listenerArr.forEach(e=>e.onSelectionChanged(this))}firstClick(e,t){this.selectionType==="row"?this.addRange(E.singleRow(e)):this.selectionType==="column"&&this.addRange(E.singleColumn(t))}getSelectionCount(e,t){let o=0;for(const s of this.ranges)s.isInRange(e,t)&&o++;return this.allSelected&&o++,this.isInNegativeRange(e,t)&&(o=0),o}isInNegativeRange(e,t){for(const o of this.negativeRanges)if(o.isInRange(e,t))return!0;return!1}getRanges(){return this.ranges}clear(){this.ranges=[],this.negativeRanges=[],this.allSelected=!1,this.fireChangeEvent()}hasSelection(){return this.allSelected||!!this.ranges.length}hasNoSelection(){return!this.hasSelection()}getMergedRowIndices(){const e=new Set;for(const t of this.ranges)for(let o=t.r1;o<=t.r2;o++)!e.has(o)&&!this.isInNegativeRange(o,0)&&e.add(o);return Array.from(e)}selectAll(){this.allSelected=!0,this.fireChangeEvent()}isAllSelected(){return this.allSelected}addSelection(e){this.addRange(e),this.fireChangeEvent()}removeSelection(e){if(this.selectionType==="none")return;let t=e;this.selectionType==="row"?t=E.singleRow(e.r1):this.selectionType==="column"&&(t=E.singleColumn(e.c1)),this.negativeRanges.push(t),this.fireChangeEvent()}togglePoint(e,t){this.getSelectionCount(e,t)>0?this.removeSelection(E.singleCell(e,t)):this.addSelection(E.singleCell(e,t))}isSelected(e,t){return this.getSelectionCount(e,t)>0}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),this.fireChangeEvent())}}class lt{constructor(e="none"){this.selectionType=e,this.rowIndex=-1,this.columnIndex=-1,this.changed=!1,this.listenerArr=[]}getEventFocusChangedListeners(){return this.listenerArr}addEventFocusChangedListener(e){this.listenerArr.includes(e)||this.listenerArr.push(e)}removeEventFocusChangedListener(e){const t=this.listenerArr.indexOf(e,0);t>-1&&this.listenerArr.splice(t,1)}fireChangeEvent(){this.listenerArr.forEach(e=>e.onFocusChanged(this))}clearChanged(){this.changed=!1}hasChanged(){return this.changed}clear(){this.rowIndex=-1,this.columnIndex=-1,this.fireChangeEvent()}setFocus(e,t){(this.rowIndex!==e||this.columnIndex!==t)&&(this.rowIndex=e,this.columnIndex=t,this.changed=!0,this.fireChangeEvent())}hasFocus(e,t){return this.rowIndex===e&&this.columnIndex===t}getFocus(){return[this.rowIndex,this.columnIndex]}}class Se{constructor(e=new D("❯","",["gt-table-icon-expanded"]),t=new D("❯","transform: rotate(180deg) translate(-100%, -100%); transform-origin: 0 0;",["ge-table-icon-collapsed"])){this.iconExpanded=e,this.iconCollapsed=t}}const at=new rt,nt=new lt("cell");class me{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 ue,this.headerGroupOptions=new Se,this.showCheckboxWihoutExtraColumn=!1,this.externalFilterFunction=void 0,this.sortedOptions=new be,this.sortOrder=["asc","desc"],this.getEditRenderer=(e,t)=>new it,this.getSelectionModel=()=>at,this.getFocusModel=()=>nt}}const F=class F{createContent(e,t,o){return new Promise((s,i)=>{if(t!=null&&t.hasSelection()){const r=this.mergeRanges(t.getRanges());if(r){r.c2=Math.min(r.c2,e.getColumnCount()-1),r.r2=Math.min(r.r2,e.getBodyModel().getRowCount()-1);const n=[];for(let l=r.r1;l<=r.r2;l++){const d=[];for(let c=r.c1;c<=r.c2;c++){const h=t.isSelected(l,c)?e.getBodyModel().getTextValueAt(l,c):"";d.push(h)}n.push(d.join(F.columnSeparatorChar))}return s(n.join(F.rowSeparatorChar))}}if(o){const[r,n]=o.getFocus(),l=e.getBodyModel().getTextValueAt(r,n);return s(l)}i("Cannot copy, neither selection nor focus defined.")})}copyContent(e){return navigator.clipboard.writeText(e)}copyToClipboard(e,t,o){return new Promise((s,i)=>{this.createContent(e,t,o).then(r=>{r&&this.copyContent(r).then(n=>{s(r)}).catch(n=>{i()})}).catch(r=>{i()})})}mergeRanges(e){let t;for(const o of e)t?(t.r1=Math.min(t.r1,o.r1),t.c1=Math.min(t.c1,o.c1),t.r2=Math.max(t.r2,o.r2),t.c2=Math.max(t.c2,o.c2)):t=new E(o.r1,o.c1,o.r2,o.c2);return t}};F.columnSeparatorChar=" ",F.rowSeparatorChar=`
21
- `;let W=F;class oe extends Ue{constructor(e,t,o,s,i,r=new W){var d;if(super(e,t,new We(o),s),this.eventListener=i,this.copyService=r,this.licenseManager=k.getInstance(),this.selectionService=new et(this),this.api=new Ve(this),this.mouseStartAction="",this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,this.lastDragFrom=-1,this.lastDragTo=-1,this.firstDraggingRendering=!0,i||(this.eventListener=new ae),(d=this.tableOptions)!=null&&d.autoRestoreOptions){const c=this.tableOptions.autoRestoreOptions,h=c.getStorageKeyFn;h&&(c.autoRestoreScrollPosition&&(this.storeScrollPosStateService=new ze(h)),c.autoRestoreCollapsedExpandedState&&(this.storeStateCollapsedExpandService=new je(h)),c.autoRestoreSortingState&&(this.storeSortingService=new Xe(h)))}this.mouseHandler=new Ge(this),this.inputHandler=new Qe(this),this.shortcutService=new st(this),this.shortcutService.addListener(this.selectionService);const n=this.getSelectionModel?this.getSelectionModel():void 0;n&&n.addEventSelectionChangedListener(this);const l=this.getFocusModel?this.getFocusModel():void 0;l&&l.addEventFocusChangedListener(this)}static create(e,t,o=new me,s=new ae,i=new fe,r=new W){return new oe(e,t,i,o,s,r)}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[o,s]=t.getFocus();this.tableModel.getBodyModel().isEditable(o,s)&&(this.clearSelection(),this.initRenderEditor(o,s))}return!0}if(e==="COPY_2_CLIPBOARD"){const t=this.getSelectionModel?this.getSelectionModel():void 0,o=this.getFocusModel?this.getFocusModel():void 0;this.copyService.createContent(this.tableModel,t,o).then(s=>this.copyService.copyContent(s))}return!1}updateModelValueAfterEdit(e,t,o,s){e==="body"&&this.tableModel.getAreaModel(e).setValue(t,o,s)&&(this.resetEditorRenderer(),this.repaint(),this.eventListener.onModelChanged(te.createSingle(t,o)),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 Q;if(t.originalEvent=e,e){const o=e.target;if([t.areaIdent,t.sideIdent]=this.getAreaAndSideIdentByAttr(o),t.rowIndex=this.getNumberByAttr(o,"data-row-index"),t.columnIndex=this.getNumberByAttr(o,"data-col-index"),t.action=this.getStringByAttr(o,"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,i=e.clientX-this.hostElement.offsetLeft-this.areaBodyWestGeo.width;this.debugOnce(i,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.firstDraggingRendering=!0,this.dragFrom=this.mouseStartColumnIndex))}mouseDraggingOnFrame(e,t){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.lastDragFrom===this.dragTo&&this.lastDragTo===this.dragFrom||(this.tableModel.changeColumnOrder(this.dragFrom,this.dragTo),this.lastDragFrom=this.dragFrom,this.lastDragTo=this.dragTo,this.dragFrom=this.dragTo,this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows())),t&&(this.adjustDraggingColumn(e,t.columnIndex,this.firstDraggingRendering),this.firstDraggingRendering=!1),this.repaint())}mouseDraggingEndOnFrame(e){this.eventListener.onMouseDraggingEnd(e),this.draggingTargetColumnIndex=-1,this.mouseStartAction==="resize-column"?this.resizeColumn(e):this.mouseStartAction==="drag-column"&&(this.hideDraggingColumn(),this.repaint()),this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,this.firstDraggingRendering=!0,this.mouseStartAction=""}mouseMove(e){this.eventListener.onMouseMoved(e),this.adjustHoverRows(e),this.adjustHoverColumns(e)}contextmenu(e){this.eventListener.onContextmenu(e)}toggleExpandCollapseAll(e=!0){var o;const t=this.tableModel.getBodyModel();U(t)&&(t.toggleExpandCollapseAll(e),this.repaint(),(o=this.storeStateCollapsedExpandService)==null||o.collapsedStateAll(e))}toggleRowCheckbox(e,t,o){var l;const s=this.tableModel.getAreaModel(o),i=s.isRowChecked(e),r=i===void 0||i==="semi"||i==="none";s.setRowChecked(e,r),this.repaint();const n=(l=s.rowSelectionModel)==null?void 0:l.getCheckedRows();this.eventListener.onCheckboxChanged(n||[])}onMouseClicked(e,t){let o=this.selectionService.onMouseClicked(e,t);if(!o&&this.getFocusModel){this.resetEditorRenderer();const s=this.getFocusModel();s&&(o=s.hasChanged(),s.clearChanged())}return o}debounceRepaint(){this.debounce(this.repaint.bind(this),1)}publishGeMouseEvent(e){this.eventListener.onMouseClicked(e)}onFocusChanged(e){this.eventListener.onFocusChanged(e)}onSelectionChanged(e){this.eventListener.onSelectionChanged(e)}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,o){var i,r;const s=this.tableModel.getColumnDef(o);if(s!=null&&s.sortable&&s.sortable()){e.preventDefault(),e.stopPropagation();const n=s.sortStatesOrder?s.sortStatesOrder:this.tableOptions.sortOrder,l=s.sortState??"",d=n[(n.indexOf(l)+1)%n.length],c=new Je(o,d);this.tableModel.doSort([c])&&((i=this.tableModel.getColumnDefs())==null||i.forEach(g=>g.sortState=""),s.sortState=d),this.repaint(),(r=this.storeSortingService)==null||r.setSortItems([c])}}scrollToPixel(e,t){this.scrollViewport.scrollTo(e,t)}scrollToIndex(e,t){const s=this.tableModel.getAreaModel("body").getYPosByRowIndex(t);this.scrollToPixel(0,s)}setSelectionModel(e,t=!1){const o=()=>e;this.tableOptions.getSelectionModel=o,this.getSelectionModel=o,this.selectionService.getSelectionModel=o,t&&this.repaint()}toggleHeaderGroup(e){const t=this.tableModel.getAreaModel("header");"columnDefs"in this.tableModel&&(this.tableModel.columnDefs=t.toggleHeaderGroup(e),console.info("####### !!!!!! *******, this.tableModel.columnDefs")),this.firstInit()}selectionModel(){if(this!=null&&this.getSelectionModel)return this.getSelectionModel()}focusModel(){if(this!=null&&this.getFocusModel)return this.getFocusModel()}setDragging(e){this.dragging=e,this.dragging?(this.storeColumnWidths(),this.lastDragFrom=-1,this.lastDragTo=-1):this.storedColumnWidths=[]}changeFocusCell(e,t){if(!this.isEditing()&&this.getFocusModel){const o=this.getFocusModel();if(o){const[s,i]=o.getFocus();return o.setFocus(s+t,i+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 o;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",(o=this.mouseHandler.mouseEvent)==null?void 0:o.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 o=this.storeScrollPosStateService.getScrollOffset();o&&this.scrollViewport.scrollTo(...o)}}autoRestoreSortingState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.autoRestoreSortingState&&this.storeSortingService){const o=this.storeSortingService.getSortItems();o!=null&&o.length&&this.tableModel.getBodyModel().doSort(o)}}autoRestoreCollapsedExpandedState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.getRowId&&this.storeStateCollapsedExpandService){const o=this.tableOptions.autoRestoreOptions,s=o.getRowId;if(o.autoRestoreCollapsedExpandedState&&s){const i=this.storeStateCollapsedExpandService.collapsedExpandedStateGet(),r=this.tableModel.getAreaModel("body");if(U(r)){const n=r,l=r.getRowCount();for(let d=0;d<l;d++){const c=r.getRowByIndex(d);if(c)if(i.allExpanded)c.expanded=!0;else if(i.allCollapsed)c.expanded=!1;else{const h=s(c.data);i.mode==="expanded"?c.expanded=this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(h):i.mode==="collapsed"&&(c.expanded=!this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(h))}}n.recalcVisibleTreeRows()}}}}}const H=class H{};H.themes=["light","combat","paper","blackboard"],H.vars={light:`html[data-theme="light"] {
20
+ class="ge-table-cell-editor-input">`}}}class lt{constructor(e="none",t="single"){this.selectionType=e,this.selectionMode=t,this.ranges=[],this.negativeRanges=[],this.allSelected=!1,this.silent=!1,this.listenerArr=[]}getEventSelectionChangedListeners(){return this.listenerArr}addEventSelectionChangedListener(e){this.listenerArr.includes(e)||this.listenerArr.push(e)}removeEventSelectionChangedListener(e){const t=this.listenerArr.indexOf(e,0);t>-1&&this.listenerArr.splice(t,1)}fireChangeEvent(){this.silent||this.listenerArr.forEach(e=>e.onSelectionChanged(this))}firstClick(e,t){this.selectionType==="row"?this.addRange(E.singleRow(e)):this.selectionType==="column"&&this.addRange(E.singleColumn(t))}getSelectionCount(e,t){let o=0;for(const s of this.ranges)s.isInRange(e,t)&&o++;return this.allSelected&&o++,this.isInNegativeRange(e,t)&&(o=0),o}isInNegativeRange(e,t){for(const o of this.negativeRanges)if(o.isInRange(e,t))return!0;return!1}getRanges(){return this.ranges}clear(){this.ranges=[],this.negativeRanges=[],this.allSelected=!1,this.fireChangeEvent()}hasSelection(){return this.allSelected||!!this.ranges.length}hasNoSelection(){return!this.hasSelection()}getMergedRowIndices(){const e=new Set;for(const t of this.ranges)for(let o=t.r1;o<=t.r2;o++)!e.has(o)&&!this.isInNegativeRange(o,0)&&e.add(o);return Array.from(e)}selectAll(){this.allSelected=!0,this.fireChangeEvent()}isAllSelected(){return this.allSelected}addSelection(e){this.addRange(e),this.fireChangeEvent()}removeSelection(e){if(this.selectionType==="none")return;let t=e;this.selectionType==="row"?t=E.singleRow(e.r1):this.selectionType==="column"&&(t=E.singleColumn(e.c1)),this.negativeRanges.push(t),this.fireChangeEvent()}togglePoint(e,t){this.getSelectionCount(e,t)>0?this.removeSelection(E.singleCell(e,t)):this.addSelection(E.singleCell(e,t))}isSelected(e,t){return this.getSelectionCount(e,t)>0}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),this.fireChangeEvent())}}class at{constructor(e="none"){this.selectionType=e,this.rowIndex=-1,this.columnIndex=-1,this.changed=!1,this.listenerArr=[]}getEventFocusChangedListeners(){return this.listenerArr}addEventFocusChangedListener(e){this.listenerArr.includes(e)||this.listenerArr.push(e)}removeEventFocusChangedListener(e){const t=this.listenerArr.indexOf(e,0);t>-1&&this.listenerArr.splice(t,1)}fireChangeEvent(){this.listenerArr.forEach(e=>e.onFocusChanged(this))}clearChanged(){this.changed=!1}hasChanged(){return this.changed}clear(){this.rowIndex=-1,this.columnIndex=-1,this.fireChangeEvent()}setFocus(e,t){(this.rowIndex!==e||this.columnIndex!==t)&&(this.rowIndex=e,this.columnIndex=t,this.changed=!0,this.fireChangeEvent())}hasFocus(e,t){return this.rowIndex===e&&this.columnIndex===t}getFocus(){return[this.rowIndex,this.columnIndex]}}class Se{constructor(e=new D("❯","",["gt-table-icon-expanded"]),t=new D("❯","transform: rotate(180deg) translate(-100%, -100%); transform-origin: 0 0;",["ge-table-icon-collapsed"])){this.iconExpanded=e,this.iconCollapsed=t}}const nt=new lt,dt=new at("cell");class me{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 ue,this.headerGroupOptions=new Se,this.showCheckboxWihoutExtraColumn=!1,this.externalFilterFunction=void 0,this.sortedOptions=new be,this.sortOrder=["asc","desc"],this.getEditRenderer=(e,t)=>new rt,this.getSelectionModel=()=>nt,this.getFocusModel=()=>dt}}const F=class F{createContent(e,t,o){return new Promise((s,i)=>{if(t!=null&&t.hasSelection()){const r=this.mergeRanges(t.getRanges());if(r){r.c2=Math.min(r.c2,e.getColumnCount()-1),r.r2=Math.min(r.r2,e.getBodyModel().getRowCount()-1);const n=[];for(let l=r.r1;l<=r.r2;l++){const d=[];for(let c=r.c1;c<=r.c2;c++){const h=t.isSelected(l,c)?e.getBodyModel().getTextValueAt(l,c):"";d.push(h)}n.push(d.join(F.columnSeparatorChar))}return s(n.join(F.rowSeparatorChar))}}if(o){const[r,n]=o.getFocus(),l=e.getBodyModel().getTextValueAt(r,n);return s(l)}i("Cannot copy, neither selection nor focus defined.")})}copyContent(e){return navigator.clipboard.writeText(e)}copyToClipboard(e,t,o){return new Promise((s,i)=>{this.createContent(e,t,o).then(r=>{r&&this.copyContent(r).then(n=>{s(r)}).catch(n=>{i()})}).catch(r=>{i()})})}mergeRanges(e){let t;for(const o of e)t?(t.r1=Math.min(t.r1,o.r1),t.c1=Math.min(t.c1,o.c1),t.r2=Math.max(t.r2,o.r2),t.c2=Math.max(t.c2,o.c2)):t=new E(o.r1,o.c1,o.r2,o.c2);return t}};F.columnSeparatorChar=" ",F.rowSeparatorChar=`
21
+ `;let W=F;class ct{constructor(e){this.tableScope=e,new ResizeObserver(We(this.handleResize.bind(this),500)).observe(this.tableScope.hostElement)}handleResize(e){const t=e[0],{width:o}=t.contentRect;this.tableScope.recalcColumnWidths(o)}}class oe extends Je{constructor(e,t,o,s,i,r=new W){var d;if(super(e,t,new He(o),s),this.eventListener=i,this.copyService=r,this.licenseManager=k.getInstance(),this.selectionService=new tt(this),this.api=new Ve(this),this.mouseStartAction="",this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,this.lastDragFrom=-1,this.lastDragTo=-1,this.firstDraggingRendering=!0,i||(this.eventListener=new ae),(d=this.tableOptions)!=null&&d.autoRestoreOptions){const c=this.tableOptions.autoRestoreOptions,h=c.getStorageKeyFn;h&&(c.autoRestoreScrollPosition&&(this.storeScrollPosStateService=new Ne(h)),c.autoRestoreCollapsedExpandedState&&(this.storeStateCollapsedExpandService=new Xe(h)),c.autoRestoreSortingState&&(this.storeSortingService=new Ke(h)))}this.mouseHandler=new ze(this),this.inputHandler=new Ze(this),this.resizeHandler=new ct(this),this.shortcutService=new it(this),this.shortcutService.addListener(this.selectionService);const n=this.getSelectionModel?this.getSelectionModel():void 0;n&&n.addEventSelectionChangedListener(this);const l=this.getFocusModel?this.getFocusModel():void 0;l&&l.addEventFocusChangedListener(this)}static create(e,t,o=new me,s=new ae,i=new fe,r=new W){return new oe(e,t,i,o,s,r)}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[o,s]=t.getFocus();this.tableModel.getBodyModel().isEditable(o,s)&&(this.clearSelection(),this.initRenderEditor(o,s))}return!0}if(e==="COPY_2_CLIPBOARD"){const t=this.getSelectionModel?this.getSelectionModel():void 0,o=this.getFocusModel?this.getFocusModel():void 0;this.copyService.createContent(this.tableModel,t,o).then(s=>this.copyService.copyContent(s))}return!1}updateModelValueAfterEdit(e,t,o,s){e==="body"&&this.tableModel.getAreaModel(e).setValue(t,o,s)&&(this.resetEditorRenderer(),this.repaint(),this.eventListener.onModelChanged(te.createSingle(t,o)),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 Q;if(t.originalEvent=e,e){const o=e.target;if([t.areaIdent,t.sideIdent]=this.getAreaAndSideIdentByAttr(o),t.rowIndex=this.getNumberByAttr(o,"data-row-index"),t.columnIndex=this.getNumberByAttr(o,"data-col-index"),t.action=this.getStringByAttr(o,"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,i=e.clientX-this.hostElement.offsetLeft-this.areaBodyWestGeo.width;this.debugOnce(i,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.firstDraggingRendering=!0,this.dragFrom=this.mouseStartColumnIndex))}mouseDraggingOnFrame(e,t){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.lastDragFrom===this.dragTo&&this.lastDragTo===this.dragFrom||(this.tableModel.changeColumnOrder(this.dragFrom,this.dragTo),this.lastDragFrom=this.dragFrom,this.lastDragTo=this.dragTo,this.dragFrom=this.dragTo,this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows())),t&&(this.adjustDraggingColumn(e,t.columnIndex,this.firstDraggingRendering),this.firstDraggingRendering=!1),this.repaint())}mouseDraggingEndOnFrame(e){this.eventListener.onMouseDraggingEnd(e),this.draggingTargetColumnIndex=-1,this.mouseStartAction==="resize-column"?this.resizeColumn(e):this.mouseStartAction==="drag-column"&&(this.hideDraggingColumn(),this.repaint()),this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,this.firstDraggingRendering=!0,this.mouseStartAction=""}mouseMove(e){this.eventListener.onMouseMoved(e),this.adjustHoverRows(e),this.adjustHoverColumns(e)}contextmenu(e){this.eventListener.onContextmenu(e)}toggleExpandCollapseAll(e=!0){var o;const t=this.tableModel.getBodyModel();U(t)&&(t.toggleExpandCollapseAll(e),this.repaint(),(o=this.storeStateCollapsedExpandService)==null||o.collapsedStateAll(e))}toggleRowCheckbox(e,t,o){var l;const s=this.tableModel.getAreaModel(o),i=s.isRowChecked(e),r=i===void 0||i==="semi"||i==="none";s.setRowChecked(e,r),this.repaint();const n=(l=s.rowSelectionModel)==null?void 0:l.getCheckedRows();this.eventListener.onCheckboxChanged(n||[])}onMouseClicked(e,t){let o=this.selectionService.onMouseClicked(e,t);if(!o&&this.getFocusModel){this.resetEditorRenderer();const s=this.getFocusModel();s&&(o=s.hasChanged(),s.clearChanged())}return o}debounceRepaint(){this.debounce(this.repaint.bind(this),1)}publishGeMouseEvent(e){this.eventListener.onMouseClicked(e)}onFocusChanged(e){this.eventListener.onFocusChanged(e)}onSelectionChanged(e){this.eventListener.onSelectionChanged(e)}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,o){var i,r;const s=this.tableModel.getColumnDef(o);if(s!=null&&s.sortable&&s.sortable()){e.preventDefault(),e.stopPropagation();const n=s.sortStatesOrder?s.sortStatesOrder:this.tableOptions.sortOrder,l=s.sortState??"",d=n[(n.indexOf(l)+1)%n.length],c=new Qe(o,d);this.tableModel.doSort([c])&&((i=this.tableModel.getColumnDefs())==null||i.forEach(g=>g.sortState=""),s.sortState=d),this.repaint(),(r=this.storeSortingService)==null||r.setSortItems([c])}}scrollToPixel(e,t){this.scrollViewport.scrollTo(e,t)}scrollToIndex(e,t){const s=this.tableModel.getAreaModel("body").getYPosByRowIndex(t);this.scrollToPixel(0,s)}setSelectionModel(e,t=!1){const o=()=>e;this.tableOptions.getSelectionModel=o,this.getSelectionModel=o,this.selectionService.getSelectionModel=o,t&&this.repaint()}toggleHeaderGroup(e){const t=this.tableModel.getAreaModel("header");"columnDefs"in this.tableModel&&(this.tableModel.columnDefs=t.toggleHeaderGroup(e),console.info("####### !!!!!! *******, this.tableModel.columnDefs")),this.firstInit()}selectionModel(){if(this!=null&&this.getSelectionModel)return this.getSelectionModel()}focusModel(){if(this!=null&&this.getFocusModel)return this.getFocusModel()}setDragging(e){this.dragging=e,this.dragging?(this.storeColumnWidths(),this.lastDragFrom=-1,this.lastDragTo=-1):this.storedColumnWidths=[]}changeFocusCell(e,t){if(!this.isEditing()&&this.getFocusModel){const o=this.getFocusModel();if(o){const[s,i]=o.getFocus();return o.setFocus(s+t,i+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 o;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",(o=this.mouseHandler.mouseEvent)==null?void 0:o.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 o=this.storeScrollPosStateService.getScrollOffset();o&&this.scrollViewport.scrollTo(...o)}}autoRestoreSortingState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.autoRestoreSortingState&&this.storeSortingService){const o=this.storeSortingService.getSortItems();o!=null&&o.length&&this.tableModel.getBodyModel().doSort(o)}}autoRestoreCollapsedExpandedState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.getRowId&&this.storeStateCollapsedExpandService){const o=this.tableOptions.autoRestoreOptions,s=o.getRowId;if(o.autoRestoreCollapsedExpandedState&&s){const i=this.storeStateCollapsedExpandService.collapsedExpandedStateGet(),r=this.tableModel.getAreaModel("body");if(U(r)){const n=r,l=r.getRowCount();for(let d=0;d<l;d++){const c=r.getRowByIndex(d);if(c)if(i.allExpanded)c.expanded=!0;else if(i.allCollapsed)c.expanded=!1;else{const h=s(c.data);i.mode==="expanded"?c.expanded=this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(h):i.mode==="collapsed"&&(c.expanded=!this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(h))}}n.recalcVisibleTreeRows()}}}}}const H=class H{};H.themes=["light","combat","paper","blackboard"],H.vars={light:`html[data-theme="light"] {
22
22
  --ge-table-bg: rgba(255,255,255, 0.5);
23
23
  --ge-table-header-west-bg: rgba(233, 233, 233, 0.5);
24
24
  --ge-table-header-center-bg: rgba(233, 233, 233, 0.5);
@@ -251,4 +251,4 @@
251
251
  data-area="${t}"
252
252
  data-row-index="${o}"
253
253
  data-col-index="${s}"
254
- >${i}</span>`}addArrowDiv(e,t,o=!0,s=-1,i=-1,r="header",n){const l=e.createElement("div");e.addClass(l,"ge-table-toggle-icon-div"),e.setStyle(l,"display","inline-block"),e.setStyle(l,"position",""),e.setStyle(l,"width","20px"),e.setStyle(l,"background","transparent"),e.setStyle(l,"cursor","pointer"),e.setAttribute(l,"data-row-index",`${s}`),e.setAttribute(l,"data-col-index",`${i}`),e.setAttribute(l,"data-area",`${r}`),e.setAttribute(l,"data-ge-action",`${n}`);let d;o?d=this.headerGroupOptions.iconExpanded:d=this.headerGroupOptions.iconCollapsed;const c=d.content,h=e.createText(c);e.appendChild(l,h),d.style&&this.applyStyleString(e,l,d.style);for(const g of d.classes)e.addClass(l,g);return e.appendChild(t,l),l}applyStyleString(e,t,o){const s=o.split(";").map(i=>i.trim()).filter(i=>i);for(const i of s){const[r,n]=i.split(":");e.setStyle(t,r.trim(),n.trim())}}};G.toggleHeaderGroup="toggleHeaderGroup";let de=G;function dt(a){let e;return{c(){e=Ee("div"),Ae(e,"class","ge-table"),_(e,"width","100%"),_(e,"height","100%"),_(e,"background-color","transparent"),_(e,"padding","0"),_(e,"margin","0")},m(t,o){xe(t,e,o),a[4](e)},p:L,i:L,o:L,d(t){t&&ge(e),a[4](null)}}}function ct(a,e,t){let{tableModel:o}=e,{tableOptions:s=new me}=e,{licenseKey:i}=e,r;const n=ie.createEventDispatcher();ie.onMount(()=>{const d={onSelectionChanged(h){n("selectionChanged",h)},onFocusChanged(h){n("focusChanged",h)},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)}},c=new oe(r,o,new fe,s,d);c.firstInit(),n("tableReady",c.getApi()),i&&k.getInstance().setLicenseKey(i)});function l(d){X[d?"unshift":"push"](()=>{r=d,t(0,r)})}return a.$$set=d=>{"tableModel"in d&&t(1,o=d.tableModel),"tableOptions"in d&&t(2,s=d.tableOptions),"licenseKey"in d&&t(3,i=d.licenseKey)},[r,o,s,i,l]}class ht extends Be{constructor(e){super(),_e(this,e,ct,dt,we,{tableModel:1,tableOptions:2,licenseKey:3})}}class gt{constructor(e){this.Component=e}render(e,t,o,s,i,r,n){const l=new this.Component({target:e,props:{cellDiv:e,rowIndex:t,columnIndex:o,areaIdent:s,areaModel:i,cellValue:r}});return()=>{l.$destroy()}}}exports.ComponentRendererWrapper=gt;exports.GuiexpertTable=ht;
254
+ >${i}</span>`}addArrowDiv(e,t,o=!0,s=-1,i=-1,r="header",n){const l=e.createElement("div");e.addClass(l,"ge-table-toggle-icon-div"),e.setStyle(l,"display","inline-block"),e.setStyle(l,"position",""),e.setStyle(l,"width","20px"),e.setStyle(l,"background","transparent"),e.setStyle(l,"cursor","pointer"),e.setAttribute(l,"data-row-index",`${s}`),e.setAttribute(l,"data-col-index",`${i}`),e.setAttribute(l,"data-area",`${r}`),e.setAttribute(l,"data-ge-action",`${n}`);let d;o?d=this.headerGroupOptions.iconExpanded:d=this.headerGroupOptions.iconCollapsed;const c=d.content,h=e.createText(c);e.appendChild(l,h),d.style&&this.applyStyleString(e,l,d.style);for(const g of d.classes)e.addClass(l,g);return e.appendChild(t,l),l}applyStyleString(e,t,o){const s=o.split(";").map(i=>i.trim()).filter(i=>i);for(const i of s){const[r,n]=i.split(":");e.setStyle(t,r.trim(),n.trim())}}};G.toggleHeaderGroup="toggleHeaderGroup";let de=G;function ht(a){let e;return{c(){e=Ee("div"),Ae(e,"class","ge-table"),_(e,"width","100%"),_(e,"height","100%"),_(e,"background-color","transparent"),_(e,"padding","0"),_(e,"margin","0")},m(t,o){xe(t,e,o),a[4](e)},p:L,i:L,o:L,d(t){t&&ge(e),a[4](null)}}}function gt(a,e,t){let{tableModel:o}=e,{tableOptions:s=new me}=e,{licenseKey:i}=e,r;const n=ie.createEventDispatcher();ie.onMount(()=>{const d={onSelectionChanged(h){n("selectionChanged",h)},onFocusChanged(h){n("focusChanged",h)},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)}},c=new oe(r,o,new fe,s,d);c.firstInit(),n("tableReady",c.getApi()),i&&k.getInstance().setLicenseKey(i)});function l(d){X[d?"unshift":"push"](()=>{r=d,t(0,r)})}return a.$$set=d=>{"tableModel"in d&&t(1,o=d.tableModel),"tableOptions"in d&&t(2,s=d.tableOptions),"licenseKey"in d&&t(3,i=d.licenseKey)},[r,o,s,i,l]}class pt extends Be{constructor(e){super(),_e(this,e,gt,ht,we,{tableModel:1,tableOptions:2,licenseKey:3})}}class ut{constructor(e){this.Component=e}render(e,t,o,s,i,r,n){const l=new this.Component({target:e,props:{cellDiv:e,rowIndex:t,columnIndex:o,areaIdent:s,areaModel:i,cellValue:r}});return()=>{l.$destroy()}}}exports.ComponentRendererWrapper=ut;exports.GuiexpertTable=pt;
package/index.js CHANGED
@@ -10,7 +10,7 @@ function de(a) {
10
10
  function ie() {
11
11
  return /* @__PURE__ */ Object.create(null);
12
12
  }
13
- function V(a) {
13
+ function z(a) {
14
14
  a.forEach(de);
15
15
  }
16
16
  function ce(a) {
@@ -44,7 +44,7 @@ let J;
44
44
  function B(a) {
45
45
  J = a;
46
46
  }
47
- const O = [], X = [];
47
+ const I = [], X = [];
48
48
  let $ = [];
49
49
  const re = [], Te = /* @__PURE__ */ Promise.resolve();
50
50
  let K = !1;
@@ -55,60 +55,60 @@ function Y(a) {
55
55
  $.push(a);
56
56
  }
57
57
  const j = /* @__PURE__ */ new Set();
58
- let I = 0;
58
+ let O = 0;
59
59
  function ge() {
60
- if (I !== 0)
60
+ if (O !== 0)
61
61
  return;
62
62
  const a = J;
63
63
  do {
64
64
  try {
65
- for (; I < O.length; ) {
66
- const e = O[I];
67
- I++, B(e), ke(e.$$);
65
+ for (; O < I.length; ) {
66
+ const e = I[O];
67
+ O++, B(e), ke(e.$$);
68
68
  }
69
69
  } catch (e) {
70
- throw O.length = 0, I = 0, e;
70
+ throw I.length = 0, O = 0, e;
71
71
  }
72
- for (B(null), O.length = 0, I = 0; X.length; )
72
+ for (B(null), I.length = 0, O = 0; X.length; )
73
73
  X.pop()();
74
74
  for (let e = 0; e < $.length; e += 1) {
75
75
  const t = $[e];
76
76
  j.has(t) || (j.add(t), t());
77
77
  }
78
78
  $.length = 0;
79
- } while (O.length);
79
+ } while (I.length);
80
80
  for (; re.length; )
81
81
  re.pop()();
82
82
  K = !1, j.clear(), B(a);
83
83
  }
84
84
  function ke(a) {
85
85
  if (a.fragment !== null) {
86
- a.update(), V(a.before_update);
86
+ a.update(), z(a.before_update);
87
87
  const e = a.dirty;
88
88
  a.dirty = [-1], a.fragment && a.fragment.p(a.ctx, e), a.after_update.forEach(Y);
89
89
  }
90
90
  }
91
- function Ie(a) {
91
+ function Oe(a) {
92
92
  const e = [], t = [];
93
93
  $.forEach((o) => a.indexOf(o) === -1 ? e.push(o) : t.push(o)), t.forEach((o) => o()), $ = e;
94
94
  }
95
- const Oe = /* @__PURE__ */ new Set();
95
+ const Ie = /* @__PURE__ */ new Set();
96
96
  function Fe(a, e) {
97
- a && a.i && (Oe.delete(a), a.i(e));
97
+ a && a.i && (Ie.delete(a), a.i(e));
98
98
  }
99
99
  function Le(a, e, t) {
100
100
  const { fragment: o, after_update: s } = a.$$;
101
101
  o && o.m(e, t), Y(() => {
102
102
  const i = a.$$.on_mount.map(de).filter(ce);
103
- a.$$.on_destroy ? a.$$.on_destroy.push(...i) : V(i), a.$$.on_mount = [];
103
+ a.$$.on_destroy ? a.$$.on_destroy.push(...i) : z(i), a.$$.on_mount = [];
104
104
  }), s.forEach(Y);
105
105
  }
106
106
  function $e(a, e) {
107
107
  const t = a.$$;
108
- t.fragment !== null && (Ie(t.after_update), V(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []);
108
+ t.fragment !== null && (Oe(t.after_update), z(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []);
109
109
  }
110
110
  function _e(a, e) {
111
- a.$$.dirty[0] === -1 && (O.push(a), De(), a.$$.dirty.fill(0)), a.$$.dirty[e / 31 | 0] |= 1 << e % 31;
111
+ a.$$.dirty[0] === -1 && (I.push(a), De(), a.$$.dirty.fill(0)), a.$$.dirty[e / 31 | 0] |= 1 << e % 31;
112
112
  }
113
113
  function Be(a, e, t, o, s, i, r = null, n = [-1]) {
114
114
  const l = J;
@@ -139,7 +139,7 @@ function Be(a, e, t, o, s, i, r = null, n = [-1]) {
139
139
  if (d.ctx = t ? t(a, e.props || {}, (h, g, ...S) => {
140
140
  const b = S.length ? S[0] : g;
141
141
  return d.ctx && s(d.ctx[h], d.ctx[h] = b) && (!d.skip_bound && d.bound[h] && d.bound[h](b), c && _e(a, h)), g;
142
- }) : [], d.update(), c = !0, V(d.before_update), d.fragment = o ? o(d.ctx) : !1, e.target) {
142
+ }) : [], d.update(), c = !0, z(d.before_update), d.fragment = o ? o(d.ctx) : !1, e.target) {
143
143
  if (e.hydrate) {
144
144
  const h = Re(e.target);
145
145
  d.fragment && d.fragment.l(h), h.forEach(he);
@@ -195,8 +195,16 @@ class Pe {
195
195
  this.$$set && !xe(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1);
196
196
  }
197
197
  }
198
- const We = "4";
199
- typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(We);
198
+ const He = "4";
199
+ typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(He);
200
+ function We(a, e = 500) {
201
+ let t = null;
202
+ return function(...o) {
203
+ t && window.clearTimeout(t), t = window.setTimeout(() => {
204
+ a.apply(this, o), t = null;
205
+ }, e);
206
+ };
207
+ }
200
208
  class k {
201
209
  // The constructor is private to prevent direct construction calls
202
210
  // with the `new` operator
@@ -279,7 +287,7 @@ class ue {
279
287
  this.iconAsc = e, this.iconDesc = t, this.iconPlaceholder = o;
280
288
  }
281
289
  }
282
- class He {
290
+ class Ge {
283
291
  constructor(e) {
284
292
  this.domService = e;
285
293
  }
@@ -462,7 +470,7 @@ class He {
462
470
  }
463
471
  }
464
472
  const Z = (a) => a === "header" ? "header" : a === "footer" ? "footer" : "body";
465
- class Ge {
473
+ class ze {
466
474
  constructor(e, t) {
467
475
  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)) {
468
476
  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"));
@@ -504,7 +512,7 @@ class Ve {
504
512
  if (t - this.lastClicked < this.doubleClickDelay)
505
513
  return;
506
514
  this.lastClicked = t;
507
- const o = new Ge(e.target, this.tableScope);
515
+ const o = new ze(e.target, this.tableScope);
508
516
  if (o.action === "toggleExpandCollapseAll")
509
517
  this.expandedAll = !this.expandedAll, this.tableScope.toggleExpandCollapseAll(this.expandedAll), e.preventDefault(), e.stopPropagation();
510
518
  else if (o.action === "toggleHeaderGroup")
@@ -606,7 +614,7 @@ class Ve {
606
614
  }
607
615
  }
608
616
  }
609
- class ze {
617
+ class Ne {
610
618
  constructor(e) {
611
619
  this.tableScope = e;
612
620
  }
@@ -869,7 +877,7 @@ class ee {
869
877
  // }
870
878
  // }
871
879
  }
872
- class Ne extends ee {
880
+ class je extends ee {
873
881
  constructor(e) {
874
882
  super(e), this.SCROLL_STATE = "scrollState", this.scrollOffset = [0, 0], this.load();
875
883
  }
@@ -891,14 +899,14 @@ class Ne extends ee {
891
899
  }
892
900
  }
893
901
  }
894
- class je {
902
+ class Xe {
895
903
  constructor(e = "collapsed", t = [], o = !1, s = !1) {
896
904
  this.mode = e, this.rowIds = t, this.allCollapsed = o, this.allExpanded = s;
897
905
  }
898
906
  }
899
- class Xe extends ee {
907
+ class Ke extends ee {
900
908
  constructor(e) {
901
- super(e), this.COLLAPSED_EXPANDED_STATE = "collapsedExpandedState", this.collapsedExpandedState = new je(), this.load();
909
+ super(e), this.COLLAPSED_EXPANDED_STATE = "collapsedExpandedState", this.collapsedExpandedState = new Xe(), this.load();
902
910
  }
903
911
  collapsedExpandedStateGet() {
904
912
  return this.collapsedExpandedState;
@@ -930,7 +938,7 @@ class Xe extends ee {
930
938
  this.checkAndPersistItem(this.COLLAPSED_EXPANDED_STATE, this.collapsedExpandedState);
931
939
  }
932
940
  }
933
- class Ke extends ee {
941
+ class Ye extends ee {
934
942
  constructor(e) {
935
943
  super(e), this.SORTING_STATE = "sortingState", this.sortItems = [], this.load();
936
944
  }
@@ -956,7 +964,7 @@ class T {
956
964
  this.left = e, this.width = t, this.height = o, this.top = s, this.index = i;
957
965
  }
958
966
  }
959
- class Ye {
967
+ class qe {
960
968
  constructor(e, t, o, s) {
961
969
  this.hostElement = e, this.tableModel = t, this.dom = o, this.tableOptions = s, this.scrollTop = 0, this.areaBodyWestGeo = new T(), this.areaBodyCenterGeo = new T(), this.areaBodyEastGeo = new T();
962
970
  const i = this.hostElement;
@@ -1162,7 +1170,7 @@ class E {
1162
1170
  return e >= this.r1 && e <= this.r2 && t >= this.c1 && t <= this.c2;
1163
1171
  }
1164
1172
  }
1165
- class qe {
1173
+ class Ue {
1166
1174
  constructor(e, t) {
1167
1175
  this.tableModel = e, this.areaModel = t, this.colAndRowspanRanges = void 0;
1168
1176
  }
@@ -1195,22 +1203,22 @@ class qe {
1195
1203
  return !1;
1196
1204
  }
1197
1205
  }
1198
- class Ue {
1206
+ class Je {
1199
1207
  constructor(e, t, o) {
1200
1208
  this.header = e, this.body = t, this.footer = o;
1201
1209
  }
1202
1210
  }
1203
- class Je extends Ye {
1211
+ class Qe extends qe {
1204
1212
  constructor(e, t, o, s) {
1205
1213
  var r, n;
1206
1214
  super(e, t, o, s), this.dragging = !1, this.editing = !1, this.storedColumnWidths = [], this.scrollLeft = 0, this.scrollViewportLeft = 0, this.scrollFactorY = 0, this.scrollFactorX = 0, this.cleanupFunctions = {
1207
1215
  header: [],
1208
1216
  body: [],
1209
1217
  footer: []
1210
- }, this.tree = !1, this.colAndRowspanModels = new Ue(), this.firstVisibleRowIndex = -1, this.draggingTargetColumnIndex = -1, this.removables = [], this.tableModel.getSelectionModel ? this.getSelectionModel = this.tableModel.getSelectionModel : (r = this.tableOptions) != null && r.getSelectionModel && (this.getSelectionModel = this.tableOptions.getSelectionModel), (n = this.tableOptions) != null && n.getFocusModel && (this.getFocusModel = this.tableOptions.getFocusModel), U(t.getAreaModel("body")) && (this.tree = !0), ["header", "body", "footer"].forEach(
1218
+ }, this.tree = !1, this.colAndRowspanModels = new Je(), this.firstVisibleRowIndex = -1, this.draggingTargetColumnIndex = -1, this.removables = [], this.tableModel.getSelectionModel ? this.getSelectionModel = this.tableModel.getSelectionModel : (r = this.tableOptions) != null && r.getSelectionModel && (this.getSelectionModel = this.tableOptions.getSelectionModel), (n = this.tableOptions) != null && n.getFocusModel && (this.getFocusModel = this.tableOptions.getFocusModel), U(t.getAreaModel("body")) && (this.tree = !0), ["header", "body", "footer"].forEach(
1211
1219
  (l) => {
1212
1220
  var d;
1213
- this.colAndRowspanModels[l] = new qe(t, t.getAreaModel(l)), (d = this.colAndRowspanModels[l]) == null || d.init();
1221
+ this.colAndRowspanModels[l] = new Ue(t, t.getAreaModel(l)), (d = this.colAndRowspanModels[l]) == null || d.init();
1214
1222
  }
1215
1223
  );
1216
1224
  }
@@ -1766,10 +1774,10 @@ class Je extends Ye {
1766
1774
  C != null && C.hasFocus(s, i) && this.dom.addFocusBorderDivs(c, b, {});
1767
1775
  }
1768
1776
  t === "header" && this.dom.setAttribute(m, "data-ge-action", "drag-column");
1769
- const z = e.getCustomStyleAt(s, i);
1770
- if (z)
1771
- for (const C in z)
1772
- this.dom.setStyle(m, C, z[C]);
1777
+ const V = e.getCustomStyleAt(s, i);
1778
+ if (V)
1779
+ for (const C in V)
1780
+ this.dom.setStyle(m, C, V[C]);
1773
1781
  return [m, M];
1774
1782
  }
1775
1783
  /**
@@ -2089,12 +2097,12 @@ class Je extends Ye {
2089
2097
  l.setAttribute(c, "data-col-index", `${t}`), l.setAttribute(c, "data-row-index", `${e}`), l.setAttribute(c, "data-area", "header"), l.setAttribute(c, "data-ge-action", "resize-column"), l.addClass(c, "ge-table-column-resize-handle"), l.setStyle(c, "display", "clip"), l.setStyle(c, "position", "absolute"), l.setStyle(c, "cursor", "col-resize"), l.setStyle(c, "left", `${o + i - d}px`), l.setStyle(c, "top", `${s}px`), l.setStyle(c, "width", `${d}px`), l.setStyle(c, "height", `${r}px`), l.appendChild(n, c);
2090
2098
  }
2091
2099
  }
2092
- class Qe {
2100
+ class Ze {
2093
2101
  constructor(e, t) {
2094
2102
  this.columnIndex = e, this.sortState = t;
2095
2103
  }
2096
2104
  }
2097
- class Ze {
2105
+ class et {
2098
2106
  constructor(e) {
2099
2107
  this.tableScope = e, this.tableScope.hostElement.addEventListener("change", this.onHostElementChanged.bind(this));
2100
2108
  }
@@ -2116,7 +2124,7 @@ class Ze {
2116
2124
  }
2117
2125
  }
2118
2126
  }
2119
- class et {
2127
+ class tt {
2120
2128
  constructor(e = -1, t = -1) {
2121
2129
  this.rowIndex = e, this.columnIndex = t;
2122
2130
  }
@@ -2126,10 +2134,10 @@ class te {
2126
2134
  this.cells = e;
2127
2135
  }
2128
2136
  static createSingle(e, t) {
2129
- return new te([new et(e, t)]);
2137
+ return new te([new tt(e, t)]);
2130
2138
  }
2131
2139
  }
2132
- class tt {
2140
+ class ot {
2133
2141
  constructor(e) {
2134
2142
  var t, o;
2135
2143
  this.tableScope = e, (t = this.tableScope.tableOptions) != null && t.getSelectionModel && (this.getSelectionModel = this.tableScope.tableOptions.getSelectionModel), (o = this.tableScope.tableOptions) != null && o.getFocusModel && (this.getFocusModel = this.tableScope.tableOptions.getFocusModel);
@@ -2170,7 +2178,7 @@ class tt {
2170
2178
  });
2171
2179
  }
2172
2180
  }
2173
- class ot {
2181
+ class st {
2174
2182
  get() {
2175
2183
  return {
2176
2184
  f2: "START_EDITING",
@@ -2190,7 +2198,7 @@ class ot {
2190
2198
  };
2191
2199
  }
2192
2200
  }
2193
- class st {
2201
+ class it {
2194
2202
  get() {
2195
2203
  return {
2196
2204
  f2: "START_EDITING",
@@ -2212,7 +2220,7 @@ class st {
2212
2220
  };
2213
2221
  }
2214
2222
  }
2215
- class it {
2223
+ class rt {
2216
2224
  constructor(e) {
2217
2225
  this.tableScope = e, this.shortcutActionIdMapping = {}, this.listener = [], this.listener.push(e), this.init();
2218
2226
  }
@@ -2233,7 +2241,7 @@ class it {
2233
2241
  this.assignPredefinedSystemShortcutMappings(), Object.assign(this.shortcutActionIdMapping, this.tableScope.tableOptions.shortcutActionIdMapping), this.isDebug() && console.debug("ShortcutService", this.shortcutActionIdMapping), this.tableScope.hostElement.addEventListener("keydown", this.onKeyDown.bind(this));
2234
2242
  }
2235
2243
  assignPredefinedSystemShortcutMappings() {
2236
- this.isMacintosh() ? Object.assign(this.shortcutActionIdMapping, new st().get()) : Object.assign(this.shortcutActionIdMapping, new ot().get());
2244
+ this.isMacintosh() ? Object.assign(this.shortcutActionIdMapping, new it().get()) : Object.assign(this.shortcutActionIdMapping, new st().get());
2237
2245
  }
2238
2246
  isMacintosh() {
2239
2247
  return navigator.platform.indexOf("Mac") > -1;
@@ -2332,7 +2340,7 @@ class be {
2332
2340
  e.setAttribute(t, o);
2333
2341
  }
2334
2342
  }
2335
- class rt {
2343
+ class lt {
2336
2344
  render(e, t, o, s, i, r, n) {
2337
2345
  if (i.isEditable(t, o)) {
2338
2346
  n.addClass(e, "ge-table-row-input-div");
@@ -2353,7 +2361,7 @@ class rt {
2353
2361
  }
2354
2362
  }
2355
2363
  }
2356
- class lt {
2364
+ class at {
2357
2365
  constructor(e = "none", t = "single") {
2358
2366
  this.selectionType = e, this.selectionMode = t, this.ranges = [], this.negativeRanges = [], this.allSelected = !1, this.silent = !1, this.listenerArr = [];
2359
2367
  }
@@ -2435,7 +2443,7 @@ class lt {
2435
2443
  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), this.fireChangeEvent());
2436
2444
  }
2437
2445
  }
2438
- class at {
2446
+ class nt {
2439
2447
  constructor(e = "none") {
2440
2448
  this.selectionType = e, this.rowIndex = -1, this.columnIndex = -1, this.changed = !1, this.listenerArr = [];
2441
2449
  }
@@ -2486,14 +2494,14 @@ class fe {
2486
2494
  }
2487
2495
  // `⊖ `, `⊕ `;
2488
2496
  }
2489
- const nt = new lt(), dt = new at("cell");
2497
+ const dt = new at(), ct = new nt("cell");
2490
2498
  class Se {
2491
2499
  constructor() {
2492
2500
  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 = {
2493
2501
  header: 34,
2494
2502
  body: 34,
2495
2503
  footer: 34
2496
- }, this.footerVerticalSeparator = !1, this.headerToggleExpandCollapseIcons = !1, this.headerVerticalSeparator = !1, this.treeOptions = new pe(), this.headerGroupOptions = new fe(), this.showCheckboxWihoutExtraColumn = !1, this.externalFilterFunction = void 0, this.sortedOptions = new ue(), this.sortOrder = ["asc", "desc"], this.getEditRenderer = (e, t) => new rt(), this.getSelectionModel = () => nt, this.getFocusModel = () => dt;
2504
+ }, this.footerVerticalSeparator = !1, this.headerToggleExpandCollapseIcons = !1, this.headerVerticalSeparator = !1, this.treeOptions = new pe(), this.headerGroupOptions = new fe(), this.showCheckboxWihoutExtraColumn = !1, this.externalFilterFunction = void 0, this.sortedOptions = new ue(), this.sortOrder = ["asc", "desc"], this.getEditRenderer = (e, t) => new lt(), this.getSelectionModel = () => dt, this.getFocusModel = () => ct;
2497
2505
  }
2498
2506
  }
2499
2507
  const F = class F {
@@ -2580,15 +2588,24 @@ const F = class F {
2580
2588
  };
2581
2589
  F.columnSeparatorChar = " ", F.rowSeparatorChar = `
2582
2590
  `;
2583
- let W = F;
2584
- class oe extends Je {
2585
- constructor(e, t, o, s, i, r = new W()) {
2591
+ let H = F;
2592
+ class ht {
2593
+ constructor(e) {
2594
+ this.tableScope = e, new ResizeObserver(We(this.handleResize.bind(this), 500)).observe(this.tableScope.hostElement);
2595
+ }
2596
+ handleResize(e) {
2597
+ const t = e[0], { width: o } = t.contentRect;
2598
+ this.tableScope.recalcColumnWidths(o);
2599
+ }
2600
+ }
2601
+ class oe extends Qe {
2602
+ constructor(e, t, o, s, i, r = new H()) {
2586
2603
  var d;
2587
- if (super(e, t, new He(o), s), this.eventListener = i, this.copyService = r, this.licenseManager = k.getInstance(), this.selectionService = new tt(this), this.api = new ze(this), this.mouseStartAction = "", this.mouseStartWidth = -1, this.mouseStartColumnIndex = -1, this.dragFrom = -1, this.dragTo = -1, this.lastDragFrom = -1, this.lastDragTo = -1, this.firstDraggingRendering = !0, i || (this.eventListener = new le()), (d = this.tableOptions) != null && d.autoRestoreOptions) {
2604
+ if (super(e, t, new Ge(o), s), this.eventListener = i, this.copyService = r, this.licenseManager = k.getInstance(), this.selectionService = new ot(this), this.api = new Ne(this), this.mouseStartAction = "", this.mouseStartWidth = -1, this.mouseStartColumnIndex = -1, this.dragFrom = -1, this.dragTo = -1, this.lastDragFrom = -1, this.lastDragTo = -1, this.firstDraggingRendering = !0, i || (this.eventListener = new le()), (d = this.tableOptions) != null && d.autoRestoreOptions) {
2588
2605
  const c = this.tableOptions.autoRestoreOptions, h = c.getStorageKeyFn;
2589
- h && (c.autoRestoreScrollPosition && (this.storeScrollPosStateService = new Ne(h)), c.autoRestoreCollapsedExpandedState && (this.storeStateCollapsedExpandService = new Xe(h)), c.autoRestoreSortingState && (this.storeSortingService = new Ke(h)));
2606
+ h && (c.autoRestoreScrollPosition && (this.storeScrollPosStateService = new je(h)), c.autoRestoreCollapsedExpandedState && (this.storeStateCollapsedExpandService = new Ke(h)), c.autoRestoreSortingState && (this.storeSortingService = new Ye(h)));
2590
2607
  }
2591
- this.mouseHandler = new Ve(this), this.inputHandler = new Ze(this), this.shortcutService = new it(this), this.shortcutService.addListener(this.selectionService);
2608
+ this.mouseHandler = new Ve(this), this.inputHandler = new et(this), this.resizeHandler = new ht(this), this.shortcutService = new rt(this), this.shortcutService.addListener(this.selectionService);
2592
2609
  const n = this.getSelectionModel ? this.getSelectionModel() : void 0;
2593
2610
  n && n.addEventSelectionChangedListener(this);
2594
2611
  const l = this.getFocusModel ? this.getFocusModel() : void 0;
@@ -2606,7 +2623,7 @@ class oe extends Je {
2606
2623
  *
2607
2624
  * @return {TableScope} - The newly created TableScope instance.
2608
2625
  */
2609
- static create(e, t, o = new Se(), s = new le(), i = new be(), r = new W()) {
2626
+ static create(e, t, o = new Se(), s = new le(), i = new be(), r = new H()) {
2610
2627
  return new oe(e, t, i, o, s, r);
2611
2628
  }
2612
2629
  /**
@@ -2804,7 +2821,7 @@ class oe extends Je {
2804
2821
  const s = this.tableModel.getColumnDef(o);
2805
2822
  if (s != null && s.sortable && s.sortable()) {
2806
2823
  e.preventDefault(), e.stopPropagation();
2807
- const n = s.sortStatesOrder ? s.sortStatesOrder : this.tableOptions.sortOrder, l = s.sortState ?? "", d = n[(n.indexOf(l) + 1) % n.length], c = new Qe(o, d);
2824
+ const n = s.sortStatesOrder ? s.sortStatesOrder : this.tableOptions.sortOrder, l = s.sortState ?? "", d = n[(n.indexOf(l) + 1) % n.length], c = new Ze(o, d);
2808
2825
  this.tableModel.doSort([c]) && ((i = this.tableModel.getColumnDefs()) == null || i.forEach((g) => g.sortState = ""), s.sortState = d), this.repaint(), (r = this.storeSortingService) == null || r.setSortItems([c]);
2809
2826
  }
2810
2827
  }
@@ -2970,9 +2987,9 @@ class oe extends Je {
2970
2987
  }
2971
2988
  }
2972
2989
  }
2973
- const H = class H {
2990
+ const W = class W {
2974
2991
  };
2975
- H.themes = ["light", "combat", "paper", "blackboard"], H.vars = {
2992
+ W.themes = ["light", "combat", "paper", "blackboard"], W.vars = {
2976
2993
  light: `html[data-theme="light"] {
2977
2994
  --ge-table-bg: rgba(255,255,255, 0.5);
2978
2995
  --ge-table-header-west-bg: rgba(233, 233, 233, 0.5);
@@ -3206,7 +3223,7 @@ H.themes = ["light", "combat", "paper", "blackboard"], H.vars = {
3206
3223
  --ge-table-drop-zone-bg: #758129;
3207
3224
  }`
3208
3225
  };
3209
- let ae = H;
3226
+ let ae = W;
3210
3227
  const G = class G {
3211
3228
  constructor(e = new fe()) {
3212
3229
  this.headerGroupOptions = e;
@@ -3248,7 +3265,7 @@ const G = class G {
3248
3265
  };
3249
3266
  G.toggleHeaderGroup = "toggleHeaderGroup";
3250
3267
  let ne = G;
3251
- function ct(a) {
3268
+ function gt(a) {
3252
3269
  let e;
3253
3270
  return {
3254
3271
  c() {
@@ -3265,7 +3282,7 @@ function ct(a) {
3265
3282
  }
3266
3283
  };
3267
3284
  }
3268
- function ht(a, e, t) {
3285
+ function pt(a, e, t) {
3269
3286
  let { tableModel: o } = e, { tableOptions: s = new Se() } = e, { licenseKey: i } = e, r;
3270
3287
  const n = ve();
3271
3288
  we(() => {
@@ -3309,16 +3326,16 @@ function ht(a, e, t) {
3309
3326
  "tableModel" in d && t(1, o = d.tableModel), "tableOptions" in d && t(2, s = d.tableOptions), "licenseKey" in d && t(3, i = d.licenseKey);
3310
3327
  }, [r, o, s, i, l];
3311
3328
  }
3312
- class ut extends Pe {
3329
+ class ft extends Pe {
3313
3330
  constructor(e) {
3314
- super(), Be(this, e, ht, ct, Ce, {
3331
+ super(), Be(this, e, pt, gt, Ce, {
3315
3332
  tableModel: 1,
3316
3333
  tableOptions: 2,
3317
3334
  licenseKey: 3
3318
3335
  });
3319
3336
  }
3320
3337
  }
3321
- class bt {
3338
+ class St {
3322
3339
  constructor(e) {
3323
3340
  this.Component = e;
3324
3341
  }
@@ -3340,6 +3357,6 @@ class bt {
3340
3357
  }
3341
3358
  }
3342
3359
  export {
3343
- bt as ComponentRendererWrapper,
3344
- ut as GuiexpertTable
3360
+ St as ComponentRendererWrapper,
3361
+ ft as GuiexpertTable
3345
3362
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guiexpert/svelte-table",
3
- "version": "4.0.9",
3
+ "version": "4.0.10",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "tslib": "^2.3.0",
21
21
  "preact": "^10.19.4",
22
- "@guiexpert/table": "^1.1.28"
22
+ "@guiexpert/table": "^1.1.29"
23
23
  },
24
24
  "devDependencies": {
25
25
  "svelte": "^4.2.1",