@ninebone/datagrid 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@ninebone/util")):typeof define==`function`&&define.amd?define([`exports`,`@ninebone/util`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.NineTable={},e.nine))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Array.prototype.nineBinarySearch=function(e){let t=0,n=this.length-1,r;for(;t<=n;){if(r=parseInt((t+n)/2),e===this[r])return r;e<this[r]?n=r-1:t=r+1}return-1};var n=new WeakMap;HTMLElement.prototype.addDebounseEventListener=function(e,t,r,i,a=500){let o=this;n.has(o)||n.set(o,{timer:null,cancelFn:null});let s=n.get(o);o.addEventListener(r,e=>{e.actualTarget=e.target,s.timer&&=(clearTimeout(s.timer),null),s.timer=setTimeout(()=>{s.timer=null,s.cancelFn=i.call(o,e)},a)}),o.addEventListener(e,e=>{s.timer&&=(clearTimeout(s.timer),null),s.cancelFn&&=(s.cancelFn(),null),t.call(o,e)})},nine.measureTextSize=(e,t=`12px sans-serif`)=>{if(typeof e==`number`&&(e+=``),!e)return{width:null,height:null};let n=e=>{let t=document.createElement(`DIV`);return t.innerHTML=e,t.textContent||t.innerText||``};e=e.replaceAll(`
2
- `,`<br>`);let r=document.body.querySelector(`canvas#_nine_measure_canvas_`);r||(r=document.createElement(`canvas`),r.id=`_nine_measure_canvas_`,r.style.cssText=`position: absolute; visibility: hidden; pointer-events: none; left: -9999px;`,document.body.appendChild(r));let i=r.getContext(`2d`);i.font=t;let a=0,o=0;for(let t of e.split(`<br>`)){let e=n(t),r=i.measureText(e);a=Math.max(a,r.width);let s=r.fontBoundingBoxAscent||10,c=r.fontBoundingBoxDescent||3;o+=s+c}return{width:a,height:o}};var r=new class extends t.trace.constructor{constructor(){super(),this.init(`nine-table`,`green`)}},i={META:{INDEX:{ROWID:0,FILTER:1,GROUP:2}},ROW_STATE:{EMPTY:`EMPTY`,NORMAL:`NORMAL`,INSERT:`INSERT`,UPDATE:`UPDATE`,DELETE:`DELETE`},EVENT:{LOAD:`load`,CELL_BUTTON_CLICK:`cell-button-click`}},a=class{#e;#t=-1;constructor(e){this.#e=e}get at(){return this.#t}set at(e){this.#t=parseInt(e,10)}count=()=>this.#e.rawRecords.length},o=class e{#e;#t;#n=0;#r=[];static META_INDEX={FILTER:0};static ROW_STATE={EMPTY:`EMPTY`,NORMAL:`NORMAL`,INSERT:`INSERT`,UPDATE:`UPDATE`,DELETE:`DELETE`};constructor(e,t){this.#e=e,this.#t=t,this.#a()}#i=()=>(this.#t.rawRecords||[]).filter(e=>!e.__ng?.deleted);get count(){return this.length}count=()=>this.length;getArray=(e,t)=>{let n=this.#i();if(e==null)return n;if(e<0||e>=n.length)return null;let r=n[e];if(t!=null){let e=this.getHostFields().indexOf(t);return e>=0?r.v[e]:null}return r};setArray=(t,n,r)=>{let i=this.#i()[t];i.v[n]!==r&&i.__ng.rowState!==e.ROW_STATE.INSERT&&(i.__ng.rowState=e.ROW_STATE.UPDATE),i.v[n]=r};get=(e,t)=>{let n=this.#i();if(e==null)return this.#u(n);if(e<0||e>=n.length)return null;let r=n[e],i=this.getHostFields();if(t!=null){let e=i.indexOf(t);return e>=0?r.v[e]:null}return this.#u(r)};getAll=()=>this.#t.rawRecords||[];getHostFields=()=>typeof this.#e.fields?.get==`function`?this.#e.fields.get():[];#a=()=>{this.#r=[];let e=this.#e.template||[];Array.from(e).forEach(e=>{this.#r.push(e.getBoundingClientRect?.().height||24)}),(this.#t.rawRecords||[]).forEach(e=>{e.__ng||=this.#s(),e.__ng.height=this.#r.slice()})};get source(){return this.#u(this.#t.rawRecords)}set source(e){this.set(e)}#o=()=>{this.#e.shadowRoot.querySelectorAll(`nine-table-sheet`).forEach(e=>{e.invalidate()}),this.#e.shadowRoot.querySelector(`nine-table-sheets-footer`)?.refresh()};set=e=>{let t=()=>{this.#e.loading=!0,setTimeout(()=>{try{this.clear(),this.add(e,!1),this.#o()}finally{this.#e.loading=!1}})};this.#e.loaded?t():this.#e.addEventListener(i.EVENT.LOAD,e=>{t()},{once:!0})};get nextId(){return this.#n++}get length(){return this.#i().length}get count(){return this.length}getRowCount(){return this.length}#s=(t=0)=>({rowState:e.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:this.#r.slice(),o:{},c:{},__:[0,0,0,0,e.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,this.#r.slice(),-1,{},{}],_:[t,[]]});reset=()=>{this.#t.rawRecords=[],this.#o()};clear=()=>{this.#t.rawRecords=[],this.#t.viewRecords?.reset&&this.#t.viewRecords.reset(),this.#n=0,this.#o()};#c=e=>{Array.isArray(e)||(e=[e]);let t=this.getHostFields().length>0?this.getHostFields():Object.keys(e[0]||{}),n=[];return e.forEach(e=>{let r={v:[]};t.forEach(t=>{r.v.push(e[t]!==void 0&&e[t]!==null?e[t]:``)}),n.push(r)}),n};#l=t=>(Array.isArray(t)||(t=[t]),t.forEach(t=>{let n=this.nextId;t.m=this.#s(n),t.__ng=t.m,t.__ng.rowid=n,t.__ng.rowState=e.ROW_STATE.INSERT,t.__ng._[0]=n}),t);add=(t,n=!0)=>{t===void 0&&(t={});let r=this.#c(t);this.#t.rawRecords=this.#t.rawRecords.concat(this.#l(r));let i=this.count()-1;return n||r.forEach((t,n)=>{let r=this.#t.rawRecords[this.#t.rawRecords.length-1-n];r&&(r.__ng.rowState=e.ROW_STATE.EMPTY)}),this.#o(),i};delete=t=>{let n=[];n=Array.isArray(t)?t:t===void 0?[this.#t.host.row.at]:[parseInt(t,10)];let r=this.#i();n.sort((e,t)=>t-e).forEach(t=>{if(r[t]){let n=r[t].__ng.rowid;r[t].__ng.rowState===e.ROW_STATE.INSERT?this.#t.rawRecords=this.#t.rawRecords.filter(e=>e.__ng.rowid!==n):this.#t.rawRecords.forEach(t=>{t.__ng.rowid===n&&(t.__ng.deleted=!0,t.__ng.rowState=e.ROW_STATE.DELETE)})}}),this.#o()};setValue=(t,n,r)=>{t=parseInt(t,10);let i=this.getHostFields().indexOf(n);if(i<0)return;let a=this.#i()[t];if(!a)return;let o=a.v[i];o!==r&&a.__ng.rowState!==e.ROW_STATE.INSERT&&(a.__ng.o.hasOwnProperty(n)||(a.__ng.o[n]=o),a.__ng.rowState=e.ROW_STATE.UPDATE),a.v[i]=r};#u=e=>{if(!e)return e;let t=!Array.isArray(e),n=t?[e]:e,r=this.getHostFields(),i=n.filter(e=>!e.__ng?.deleted).map(e=>{let t={};return r.forEach((n,r)=>{t[n]=e.v?e.v[r]:e[n]}),t.__ng=e.__ng,t});return t?i[0]:i}},s=class{#e;constructor(e){this.#e=e,this.row=new a(this),this.data=new o(this.#e,this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{this.#e.view?.redraw&&this.#e.view.redraw()},this.setDataSource=e=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(e||[])},this.getRowState=e=>{let t=parseInt(e,10);if(!(t>=this.data.count()))return this.data.getValidData()[t]?.__ng?.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=e=>{this.row.at=e},this.scrollTo_V1=e=>(e<0&&(e=0),e>=this.rawRecords.length&&(e=this.rawRecords.length-1),this.viewRecords.rawIndex=e,this.viewRecords.reset&&this.viewRecords.reset(),!(e<=0||e>=this.rawRecords.length-1)),this.getColumn=(e,t)=>this.data.get(e,t),this.setColumn=(e,t,n)=>{e=parseInt(e,10),this.data.setValue(e,t,n)},this.setDataSource([])}},c=class{#e;#t=[];constructor(e){this.#e=e,this.#r()}get(){return this.#t.map(e=>e.name)}getFields(){return this.#t}getType(e){let t=this.#t.find(t=>t.name===e);return t?t.type:`string`}add=(e,t=`string`)=>{e.forEach(e=>{this.#t.some(t=>t.name===e)||this.#t.push({name:e,type:t})}),this.#n()};indexOf(e){return this.#t.findIndex(t=>t.name===e)}includes(e){return this.#t.some(t=>t.name===e)}#n=()=>{let e=new Map;this.#t.forEach(t=>{e.set(t.name,t.type)}),this.#t=Array.from(e,([e,t])=>({name:e,type:t})),this.#t=this.#t.filter(e=>e.name!==``&&e.name!==`__ng`),this.#t.sort((e,t)=>e.name.length<t.name.length?1:-1)};#r=()=>{this.#t=[];let e=Array.from(this.#e.querySelectorAll(`table`));if(e&&e.length!==0){for(let t of e)t.querySelectorAll(`[data-bind]`).forEach(e=>{let t=e.dataset.bind,n=e.getAttribute(`data-type`)||`string`;t&&this.#t.push({name:t,type:n})}),[`data-expr`,`background-color`,`color`,`tooltip`,`visible`,`readonly`,`enable-button`,`enable-check`,`class-expr`,`icon-color`,`icon-src`].forEach(e=>{t.querySelectorAll(`[${e}]`).forEach(t=>{let n=t.getAttribute(e);if(n){if(n.indexOf(`data.`)<0){let e=n.search(/[(]/g);if(e>0)try{n=String(window[n.substring(0,e).trim()])}catch{n=``}}n.split(`data.`).forEach(e=>{if(e.trim()!=``){let t=e.search(/[^_A-Za-z0-9]/g),r=``;t>=0?r=e.substring(0,t):n.startsWith(`data.`)&&(r=e.replace(`data.`,``)),r&&this.#t.push({name:r,type:`string`})}})}})});this.#n()}}},l=class extends HTMLElement{constructor(){super()}connectedCallback(){this.#e()}#e=()=>{}};customElements.get(`nine-table-sheets`)||customElements.define(`nine-table-sheets`,l);var u=class extends HTMLElement{#e;constructor(){super()}connectedCallback(){this.#t()}refresh=()=>{this.querySelector(`#row-count`).innerHTML=this.#e.data.count().toLocaleString()};#t=()=>{this.#e=this.getRootNode().host,this.#r(),this.querySelector(`.nine-tab-bar`)?.addEventListener(`click`,e=>{let t=e.ctrlKey||e.metaKey||e.shiftKey,n=e.target.closest(`nt-sheets-tab-item`);if(!n)return;let r=parseInt(n.dataset.index,10);this.#n(r,t)}),setTimeout(()=>{this.#n(0,!1)})};#n=(e,t=!1)=>{let n=()=>{let e=Array.from(this.#e.shadowRoot.querySelectorAll(`nine-table-sheet`));Array.from(this.#e.shadowRoot.querySelectorAll(`nine-splitter`)).forEach(e=>e.style.setProperty(`display`,`none`));let t=e.map((e,t)=>({sheet:e,idx:t})).filter(({sheet:e})=>e.classList.contains(`active`));if(!(t.length<2))for(let e=0;e<t.length-1;e++){let n=t[e].idx,r=this.#e.shadowRoot.querySelector(`nine-splitter[data-split-index="${n}"]`);r&&r.style.setProperty(`display`,``)}},r=this.querySelector(`.nine-tab-bar`),i=this.#e.shadowRoot.querySelector(`nine-table-sheets-body`),a=r.querySelectorAll(`nt-sheets-tab-item`),o=i.querySelectorAll(`nine-table-sheet`);if(!a[e])return;if(!t)a.forEach((t,n)=>{t.setActive(n===e)}),o.forEach((t,n)=>{let r=n===e;t.classList.toggle(`active`,r),t.style.flex=r?`1 1 100%`:``});else{let t=a[e],n=r.querySelectorAll(`nt-sheets-tab-item.active`);if(t.classList.contains(`active`)&&n.length<=1)return;t.classList.toggle(`active`);let o=i.querySelector(`nine-table-sheet[data-index="${e}"]`);o&&(o.classList.toggle(`active`),o.classList.contains(`active`)||(o.style.flex=``))}let s=i.querySelectorAll(`nine-table-sheet.active`);s?.forEach(e=>{e.style.flex=s.length>1?`1 1 0%`:`1 1 100%`,typeof e.refreshLayout==`function`?e.refreshLayout():e.invalidate?.()}),n()};#r(){let e=Array.from(this.#e.children).filter(e=>e.tagName.toUpperCase()===`TABLE`).map((e,t)=>`<nt-sheets-tab-item class="${t===0?`active`:``}" data-index="${t}">${e.getAttribute(`caption`)||`Sheet ${t+1}`}</nt-sheets-tab-item>`).join(``);this.innerHTML=`
2
+ `,`<br>`);let r=document.body.querySelector(`canvas#_nine_measure_canvas_`);r||(r=document.createElement(`canvas`),r.id=`_nine_measure_canvas_`,r.style.cssText=`position: absolute; visibility: hidden; pointer-events: none; left: -9999px;`,document.body.appendChild(r));let i=r.getContext(`2d`);i.font=t;let a=0,o=0;for(let t of e.split(`<br>`)){let e=n(t),r=i.measureText(e);a=Math.max(a,r.width);let s=r.fontBoundingBoxAscent||10,c=r.fontBoundingBoxDescent||3;o+=s+c}return{width:a,height:o}};var r=new class extends t.trace.constructor{constructor(){super(),this.init(`nine-table`,`green`)}},i={META:{INDEX:{ROWID:0,ROW_STATE:1,FILTER:2,GROUP:3}},ROW_STATE:{EMPTY:0,NORMAL:1,INSERT:2,UPDATE:3,DELETE:9},EVENT:{LOAD:`load`,CELL_BUTTON_CLICK:`cell-button-click`}},a=class{#e;#t=-1;constructor(e){this.#e=e}get at(){return this.#t}set at(e){this.#t=parseInt(e,10)}count=()=>this.#e.rawRecords.length},o=class e{#e;#t;#n=0;#r=[];static META_INDEX={FILTER:0};static ROW_STATE={EMPTY:`EMPTY`,NORMAL:`NORMAL`,INSERT:`INSERT`,UPDATE:`UPDATE`,DELETE:`DELETE`};constructor(e,t){this.#e=e,this.#t=t,this.#a()}#i=()=>(this.#t.rawRecords||[]).filter(e=>e.m._[i.META.INDEX.ROW_STATE]!==i.ROW_STATE.DELETE);get count(){return this.length}count=()=>this.length;getArray=(e,t)=>{let n=this.#i();if(e==null)return n;if(e<0||e>=n.length)return null;let r=n[e];if(t!=null){let e=this.getHostFields().indexOf(t);return e>=0?r.v[e]:null}return r};setArray=(t,n,r)=>{let i=this.#i()[t];i.v[n]!==r&&i.__ng.rowState!==e.ROW_STATE.INSERT&&(i.__ng.rowState=e.ROW_STATE.UPDATE),i.v[n]=r};get=(e,t)=>{let n=this.#i();if(e==null)return this.#d(n);if(e<0||e>=n.length)return null;let r=n[e],i=this.getHostFields();if(t!=null){let e=i.indexOf(t);return e>=0?r.v[e]:null}return this.#d(r)};getAll=()=>this.#t.rawRecords||[];getHostFields=()=>typeof this.#e.fields?.get==`function`?this.#e.fields.get():[];#a=()=>{this.#r=[];let e=this.#e.template||[];Array.from(e).forEach(e=>{this.#r.push(e.getBoundingClientRect?.().height||24)}),(this.#t.rawRecords||[]).forEach(e=>{e.__ng||=this.#s(),e.__ng.height=this.#r.slice()})};get source(){return this.#d(this.#t.rawRecords)}set source(e){this.set(e)}#o=()=>{this.#e.shadowRoot.querySelectorAll(`nine-table-sheet`).forEach(e=>{e.invalidate()}),this.#e.shadowRoot.querySelector(`nine-table-sheets-footer`)?.refresh()};set=e=>{let t=()=>{this.#e.loading=!0,setTimeout(()=>{try{this.clear(),this.add(e,!1),this.#o()}finally{this.#e.loading=!1}})};this.#e.loaded?t():this.#e.addEventListener(i.EVENT.LOAD,e=>{t()},{once:!0})};get nextId(){return this.#n++}get length(){return this.#i().length}get count(){return this.length}getRowCount(){return this.length}#s=(t=0)=>({rowState:e.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:this.#r.slice(),o:{},c:{},__:[0,0,0,0,e.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,this.#r.slice(),-1,{},{}],_:[t,i.ROW_STATE.EMPTY,[],[]]});reset=()=>{this.#t.rawRecords=[],this.#o()};clear=()=>{this.#t.rawRecords=[],this.#t.viewRecords?.reset&&this.#t.viewRecords.reset(),this.#n=0,this.#o()};#c=e=>{Array.isArray(e)||(e=[e]);let t=this.getHostFields().length>0?this.getHostFields():Object.keys(e[0]||{}),n=[];return e.forEach(e=>{let r={v:[]};t.forEach(t=>{r.v.push(e[t]!==void 0&&e[t]!==null?e[t]:``)}),n.push(r)}),n};#l=e=>(Array.isArray(e)||(e=[e]),e.forEach(e=>{let t=this.nextId;e.m=this.#s(t),e.__ng=e.m,e.__ng.rowid=t,e.m._[i.META.INDEX.ROWID]=t,e.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.EMPTY}),e);#u=e=>this.#t.rawRecords.findIndex(t=>!t||!t.m||!t.m._?!1:t.m._[i.META.INDEX.ROWID]===e);add=(e,t=!0)=>{e===void 0&&(e={});let n=this.#c(e);this.#t.rawRecords=this.#t.rawRecords.concat(this.#l(n));let r=this.count()-1;return t&&n.forEach((e,t)=>{let n=this.#t.rawRecords[this.#t.rawRecords.length-1-t];n&&(n.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.INSERT)}),this.#o(),r};insert=(e,t,n=!0)=>{t===void 0&&(t={});let r=this.#c(t);if(r.length===0)return-1;let a=this.#u(e),o=this.#l(r);return this.#t.rawRecords.splice(a,0,...o),n&&o.forEach((e,t)=>{let n=this.#t.rawRecords[a+t];n&&n.m&&n.m._&&(n.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.INSERT)}),this.#o(),o[0].m._[i.META.INDEX.ROWID]};remove=e=>{let t=[];t=Array.isArray(e)?at:[parseInt(e,10)];let n=[];t.forEach(e=>{n.push(this.#u(e))});let r=this.#t.rawRecords;n.sort((e,t)=>t-e).forEach(e=>{let t=r[e].m._[i.META.INDEX.ROWID];r[e].m._[i.META.INDEX.ROW_STATE]===i.ROW_STATE.INSERT?this.#t.rawRecords=this.#t.rawRecords.filter(e=>e.m._[i.META.INDEX.ROWID]!==t):this.#t.rawRecords.forEach(e=>{e.m._[i.META.INDEX.ROWID]===t&&(e.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.DELETE)})}),this.#o()};setValue=(e,t,n)=>{e=parseInt(e,10);let r=this.getHostFields().indexOf(t);if(r<0)return;let a=this.#i()[e];a&&(a.v[r]!==n&&a.m._[i.META.INDEX.ROW_STATE]!==i.ROW_STATE.INSERT&&(a.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.UPDATE),a.v[r]=n)};#d=e=>{if(!e)return e;let t=!Array.isArray(e),n=t?[e]:e,r=this.getHostFields(),i=n.filter(e=>!e.__ng?.deleted).map(e=>{let t={};return r.forEach((n,r)=>{t[n]=e.v?e.v[r]:e[n]}),t.__ng=e.__ng,t});return t?i[0]:i}},s=class{#e;constructor(e){this.#e=e,this.row=new a(this),this.data=new o(this.#e,this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{this.#e.view?.redraw&&this.#e.view.redraw()},this.setDataSource=e=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(e||[])},this.getRowState=e=>{let t=parseInt(e,10);if(!(t>=this.data.count()))return this.data.getValidData()[t]?.__ng?.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=e=>{this.row.at=e},this.scrollTo_V1=e=>(e<0&&(e=0),e>=this.rawRecords.length&&(e=this.rawRecords.length-1),this.viewRecords.rawIndex=e,this.viewRecords.reset&&this.viewRecords.reset(),!(e<=0||e>=this.rawRecords.length-1)),this.getColumn=(e,t)=>this.data.get(e,t),this.setColumn=(e,t,n)=>{e=parseInt(e,10),this.data.setValue(e,t,n)},this.setDataSource([])}},c=class{#e;#t=[];constructor(e){this.#e=e,this.#r()}get(){return this.#t.map(e=>e.name)}getFields(){return this.#t}getType(e){let t=this.#t.find(t=>t.name===e);return t?t.type:`string`}add=(e,t=`string`)=>{e.forEach(e=>{this.#t.some(t=>t.name===e)||this.#t.push({name:e,type:t})}),this.#n()};indexOf(e){return this.#t.findIndex(t=>t.name===e)}includes(e){return this.#t.some(t=>t.name===e)}#n=()=>{let e=new Map;this.#t.forEach(t=>{e.set(t.name,t.type)}),this.#t=Array.from(e,([e,t])=>({name:e,type:t})),this.#t=this.#t.filter(e=>e.name!==``&&e.name!==`__ng`),this.#t.sort((e,t)=>e.name.length<t.name.length?1:-1)};#r=()=>{this.#t=[];let e=Array.from(this.#e.querySelectorAll(`table`));if(e&&e.length!==0){for(let t of e)t.querySelectorAll(`[data-bind]`).forEach(e=>{let t=e.dataset.bind,n=e.getAttribute(`data-type`)||`string`;t&&this.#t.push({name:t,type:n})}),[`data-expr`,`background-color`,`color`,`tooltip`,`visible`,`readonly`,`enable-button`,`enable-check`,`class-expr`,`icon-color`,`icon-src`].forEach(e=>{t.querySelectorAll(`[${e}]`).forEach(t=>{let n=t.getAttribute(e);if(n){if(n.indexOf(`data.`)<0){let e=n.search(/[(]/g);if(e>0)try{n=String(window[n.substring(0,e).trim()])}catch{n=``}}n.split(`data.`).forEach(e=>{if(e.trim()!=``){let t=e.search(/[^_A-Za-z0-9]/g),r=``;t>=0?r=e.substring(0,t):n.startsWith(`data.`)&&(r=e.replace(`data.`,``)),r&&this.#t.push({name:r,type:`string`})}})}})});this.#n()}}},l=class extends HTMLElement{constructor(){super()}connectedCallback(){this.#e()}#e=()=>{}};customElements.get(`nine-table-sheets`)||customElements.define(`nine-table-sheets`,l);var u=class extends HTMLElement{#e;constructor(){super()}connectedCallback(){this.#t()}refresh=()=>{this.querySelector(`#row-count`).innerHTML=this.#e.data.count().toLocaleString()};#t=()=>{this.#e=this.getRootNode().host,this.#r(),this.querySelector(`.nine-tab-bar`)?.addEventListener(`click`,e=>{let t=e.ctrlKey||e.metaKey||e.shiftKey,n=e.target.closest(`nt-sheets-tab-item`);if(!n)return;let r=parseInt(n.dataset.index,10);this.#n(r,t)}),setTimeout(()=>{this.#n(0,!1)})};#n=(e,t=!1)=>{let n=()=>{let e=Array.from(this.#e.shadowRoot.querySelectorAll(`nine-table-sheet`));Array.from(this.#e.shadowRoot.querySelectorAll(`nine-splitter`)).forEach(e=>e.style.setProperty(`display`,`none`));let t=e.map((e,t)=>({sheet:e,idx:t})).filter(({sheet:e})=>e.classList.contains(`active`));if(!(t.length<2))for(let e=0;e<t.length-1;e++){let n=t[e].idx,r=this.#e.shadowRoot.querySelector(`nine-splitter[data-split-index="${n}"]`);r&&r.style.setProperty(`display`,``)}},r=this.querySelector(`.nine-tab-bar`),i=this.#e.shadowRoot.querySelector(`nine-table-sheets-body`),a=r.querySelectorAll(`nt-sheets-tab-item`),o=i.querySelectorAll(`nine-table-sheet`);if(!a[e])return;if(!t)a.forEach((t,n)=>{t.setActive(n===e)}),o.forEach((t,n)=>{let r=n===e;t.classList.toggle(`active`,r),t.style.flex=r?`1 1 100%`:``});else{let t=a[e],n=r.querySelectorAll(`nt-sheets-tab-item.active`);if(t.classList.contains(`active`)&&n.length<=1)return;t.classList.toggle(`active`);let o=i.querySelector(`nine-table-sheet[data-index="${e}"]`);o&&(o.classList.toggle(`active`),o.classList.contains(`active`)||(o.style.flex=``))}let s=i.querySelectorAll(`nine-table-sheet.active`);s?.forEach(e=>{e.style.flex=s.length>1?`1 1 0%`:`1 1 100%`,typeof e.refreshLayout==`function`?e.refreshLayout():e.invalidate?.()}),n()};#r(){let e=Array.from(this.#e.children).filter(e=>e.tagName.toUpperCase()===`TABLE`).map((e,t)=>`<nt-sheets-tab-item class="${t===0?`active`:``}" data-index="${t}">${e.getAttribute(`caption`)||`Sheet ${t+1}`}</nt-sheets-tab-item>`).join(``);this.innerHTML=`
3
3
  <div class="nine-tab-bar">${e}</div>
4
4
  <div class="sheets-counter">Total : <span id="row-count">0</span></div>
5
5
  `}},d=class extends HTMLElement{constructor(){super()}connectedCallback(){}setActive(e){this.classList.toggle(`active`,e)}};customElements.get(`nt-sheets-tab-item`)||customElements.define(`nt-sheets-tab-item`,d),customElements.get(`nine-table-sheets-footer`)||customElements.define(`nine-table-sheets-footer`,u);var f=class extends HTMLElement{#e;#t;connectedCallback(){this.#e=this.getRootNode().host,this.#n(),this.#i()}#n(){this.innerHTML=`
@@ -23,7 +23,7 @@
23
23
  <button class='scroll-top' disabled><div class='scroll-icon'></div></button>
24
24
  <div class='scroll-track'><div class='scroll-thumb'></div></div>
25
25
  <button class='scroll-bottom' disabled><div class='scroll-icon'></div></button>
26
- `;let e=()=>{let t=this.#t.querySelector(`.ng-sheet-body`);t?(this.#r={container:t,track:this.querySelector(`.scroll-track`),thumb:this.querySelector(`.scroll-thumb`),top:this.querySelector(`.scroll-top`),bottom:this.querySelector(`.scroll-bottom`)},this.#s(),this.refresh()):setTimeout(e,10)};e()}#o=()=>{let e=this.#t.view.getArray(),t=e?e.length:0,n=this.#t.elements?.scrollHolder,r=n&&parseFloat(n.style.height)||0;(!r||r<=0)&&(r=this.#t.sourceTable?.querySelector(`tbody tr[grouping='true']`)&&this.#t.rowManager?body.scrollHeight>body.clientHeight?body.scrollHeight:t*30:t*(this.#t.getRowHeight()||1));let i=15e6,a=r>i,o=1,s=r;return a&&(o=i/r,s=i),{rawContentHeight:r,contentHeight:s,scaleFactor:o,useScaling:a,totalCount:t}};refresh=()=>{if(this.#n||!this.#t||!this.#t.elements||!this.#r)return;let e=this.#r.container,t=this.#r.track,n=this.#r.thumb,{contentHeight:r}=this.#o(),i=(this.#t.querySelector(`thead`)?.offsetHeight||0)+(this.#t.querySelector(`tfoot`)?.offsetHeight||0)+(this.#t.querySelector(`tbody.head`)?.offsetHeight||0),a=this.#t.querySelector(`.ng-sheet-body`).offsetHeight||0,o=a-i,s=this.#t.view.getArray().length,c=this.#t.getRowHeight()*s,l=c>o;if(this.#t.classList.toggle(`vscroll-visible`,l),!l)return;let u=t.clientHeight;if(u<=0)return;let d=Math.max(Math.min(a/c*u,u),20);n.style.height=`${d}px`;let f=e.scrollTop,p=Math.max(r-this.#t.rowManager.getRowHeight(),1),m=0;p>0&&(m=f/p*(u-d));let h=u-d;m<0&&(m=0),m>h&&(m=h),n.style.top=`${m}px`,this.#r.top.disabled=f<=0,this.#r.bottom.disabled=f>=p-1};#s=()=>{this.#r.thumb.addEventListener(`mousedown`,e=>{if(e.button!==0)return;e.stopPropagation(),e.preventDefault(),this.#n=!0,this.#i=e.clientY,this.#a=parseFloat(this.#r.thumb.style.top)||0;let t=this.#r.track.getBoundingClientRect().height-this.#r.thumb.clientHeight,n=e=>{if(!this.#n||t<=0)return;let n=e.clientY-this.#i,r=this.#a+n;r<0&&(r=0),r>t&&(r=t),this.#r.thumb.style.top=`${r}px`;let i=r/t,a=this.#t.getRowHeight(),o=(this.#t.querySelector(`.ng-sheet-body`).offsetHeight||0)-(this.#t.elements.body.thead?.offsetHeight||0)-(this.#t.elements.body.tfoot?.offsetHeight||0)-(this.#t.elements.body.tbody.head.offsetHeight||0),s=Math.floor(o/a),{totalCount:c}=this.#o(),l=Math.floor(i*(c-s+1));this.#t.rowManager.scrollToDataRow(l);let{rawContentHeight:u,contentHeight:d}=this.#o(),f=this.#r.container.scrollTop,p=Math.max(d-this.#t.rowManager.getRowHeight(),0);this.#r.top.disabled=f<=0,this.#r.bottom.disabled=f>=p-1},r=()=>{this.#n=!1,document.removeEventListener(`mousemove`,n),document.removeEventListener(`mouseup`,r)};document.addEventListener(`mousemove`,n),document.addEventListener(`mouseup`,r)}),this.#r.track.addEventListener(`mousedown`,e=>{if(e.button!==0||e.target===this.#r.thumb)return;let t=this.#r.track.getBoundingClientRect(),n=this.#r.thumb.clientHeight,r=this.#r.track.clientHeight-n;if(r>0){let i=e.clientY-t.top-n/2,a=Math.max(0,Math.min(1,i/r)),{totalCount:o}=this.#o(),s=Math.max(0,Math.min(Math.floor(a*(o-1)),o-1));s>=0&&this.#t.rowManager&&typeof this.#t.rowManager.scrollToDataRow==`function`&&this.#t.rowManager.scrollToDataRow(s,`top`)}this.refresh()});let e=null,t=t=>{if(e)return;let n=()=>{let e=this.#t.querySelector(`tbody.body tr`);if(!e||e.dataset.row===void 0||t===`down`&&this.#t.isLastRow())return;let n=parseInt(e.dataset.row,10),r=t===`down`?n+1:Math.max(0,n-1);this.#t.rowManager.scrollToDataRow(r,null,()=>{this.refresh()})};n(),e=setInterval(n,200)},n=()=>{e&&=(clearInterval(e),null)};this.#r.top.addEventListener(`mousedown`,e=>{e.button===0&&t(`up`)}),this.#r.bottom.addEventListener(`mousedown`,e=>{e.button===0&&t(`down`)}),document.addEventListener(`mouseup`,n),this.#r.top.addEventListener(`mouseleave`,n),this.#r.bottom.addEventListener(`mouseleave`,n)}};customElements.get(`nine-table-vscrollbar`)||customElements.define(`nine-table-vscrollbar`,m);var h={ID:0,DEPTH:1,NAME:2,CHILDREN:3},g=class{#e;#t;#n=[];#r=new Map;#i=!1;constructor(e){this.#e=e,this.#t=this.#e.getRootNode().host}get columns(){return this.#n}get groupMap(){return this.#r}initialize=()=>{let e=[],t=this.#e.sourceTable;t&&t.querySelectorAll(`tbody tr[grouping="true"]`).forEach(t=>{let n=t.querySelector(`[cell-type="tree"]`);n&&n.dataset.bind&&e.push(n.dataset.bind)}),this.#n=e};apply(){if(this.#i)return;this.#i=!0;let e=[],t=this.#e.sourceTable;t&&t.querySelectorAll(`tbody tr[grouping="true"]`).forEach(t=>{let n=t.querySelector(`[cell-type="tree"]`);n&&n.dataset.bind&&e.push(n.dataset.bind)}),this.#n=e,this.#i=!1,this.#e.scrollToY(0),this.#e.view.refresh()}clear(){this.#n=[],this.#r.clear(),this.#i=!1,this.#e.scrollToY(0),this.#e.view.refresh()}setGroupMap(e){this.#r=e}getChildrenRowIds(e){return this.#r.get(e)||[]}getChildrenRecords(e){let t=this.getChildrenRowIds(e),n=this.#t.data;return t.map(e=>n.getArray(e)).filter(Boolean)}},_=class e{static apply(t,n=[],r=[]){if(!n||n.length===0)return{headers:[],renderItems:[],groupMap:new Map};let i=t.filter(e=>!e.__ng?.deleted),a=new Map,o=e.#t(i,n,r),s=[],c=[];return e.#e(o,0,n,s,c,a,``),{headers:s,renderItems:c,groupMap:a}}static#e(t,n,r,i,a,o,s){let c=0,l=n===r.length-1;for(let[u,d]of t.entries()){let t=s?`${s}_${c++}`:`g_${c++}`,f=e.#n(d);o.set(t,f);let p=[];p[h.ID]=t,p[h.DEPTH]=n,p[h.NAME]=u,p[h.CHILDREN]=f,p.__isGroupHeader=!0,p.__groupId=t,i.push(p),a.push({type:`group`,record:p,groupId:t}),!l&&d instanceof Map?e.#e(d,n+1,r,i,a,o,t):e.#r(d).forEach(e=>{e.__isGroupHeader=!1,e.__groupId=t,i.push(e),a.push({type:`data`,record:e,groupId:t})})}}static#t(t,n,r){let i=r.indexOf(n[0]),a=n.slice(1),o=new Map;if(t.forEach(e=>{let t=i>=0?e.v[i]:`(Unknown)`;o.has(t)||o.set(t,[]),o.get(t).push(e)}),a.length>0){let t=new Map;for(let[n,i]of o.entries())t.set(n,e.#t(i,a,r));return t}return o}static#n(t){let n=[];if(t instanceof Map)for(let r of t.values())n=n.concat(e.#n(r));else Array.isArray(t)&&(n=n.concat(t.map(e=>e.__ng?.rowid??e.m?._?.[0])));return n}static#r(t){let n=[];if(t instanceof Map)for(let r of t.values())n=n.concat(e.#r(r));else Array.isArray(t)&&(n=n.concat(t));return n}},v=class{#e=3;#t;#n;#r;#i=new Map;#a=[];#o=null;#s=null;#c=0;#l;#u=!1;#d=!1;constructor(e){this.#t=e.getRootNode().host,this.#n=e,this.#x()}getRowHeight(){return this.#a.reduce((e,t)=>e+t,0)}refresh=(e=!1)=>{if(!this.#n.classList.contains(`active`))return;let t=this.#n.querySelector(`.ng-sheet-body`);t&&((!this.#o||this.#o<=0)&&(this.#g(),this.#o&&this.#o>0&&this.#v()),this.#f(t.scrollTop,e),this.#n.querySelector(`nine-table-vscrollbar`)?.refresh())};#f=(e,t=!1)=>{if(this.#d){this.#p(e,t);return}let n=this.#o;if(!n||n<=0)return;let r=this.#n.view.getArray(),a=r.length;if(a===0){this.#n.elements.scrollHolder.style.height=`0px`;return}let o=this.#n.templateLength,s=(this.#n.elements.body.thead?.offsetHeight||0)+(this.#n.elements.body.tfoot?.offsetHeight||0)+this.#n.elements.body.tbody.head.offsetHeight,c=this.#n.querySelector(`.ng-sheet-body`).offsetHeight||0,l=Math.max(a*n-(c-s-n),0),u=15e6,d=l>u,f=1,p=l;d&&(f=u/l,p=u),this.#n.elements.scrollHolder.style.height=`${p}px`;let m=d?e/f:e,h=Math.max(0,a-1),g=Math.min(m,l),_=Math.max(0,Math.min(Math.floor(g/n),h)),v=g%n;this.#n.elements.left.tbody.body.style.top=this.#n.elements.body.tbody.body.style.top=this.#n.elements.right.tbody.body.style.top=`-${v}px`;let y=this.#r.firstTr,b=y&&y.dataset.row!==void 0?parseInt(y.dataset.row,10):-1;(t||b!==_)&&([this.#n.elements.left.tbody.body,this.#n.elements.body.tbody.body,this.#n.elements.right.tbody.body].forEach((e,t)=>{e&&e.querySelectorAll(`tbody.body tr`).forEach((e,t)=>{let n=_+Math.floor(t/o);if(n>=a){e.style.display=`none`,e.dataset.matrixRow=null,e.dataset.row=null,e.dataset.index=null;return}let s=r[n];if(!s){e.style.display=`none`;return}let c=s.m._[i.META.INDEX.ROWID];e.style.display=``,this.#h(e,s,c,n)})}),this.#n.selection.refresh())};#p=(e,t=!1)=>{let n=this.#n.view.getArray()||[],r=n.length;if(r===0){this.#n.elements.scrollHolder.style.height=`0px`;return}let i=this.#n.querySelector(`.ng-sheet-body .ng-sheet-body-content`),a=this.#n.templateLength||1,o=e=>{if(e.type===`group`){let t=e.record[h.DEPTH]||0;return this.#a[t]||this.#o/a}{let e=0,t=this.#n.templateLength||1,n=0;for(let e=0;e<t-1;e++)n+=this.#a[e]||0;return e=this.#o-n,e>0?e:this.#o}},s=0,c=Array(r);for(let e=0;e<r;e++){let t=o(n[e]);c[e]=t,s+=t}this.#n.elements.scrollHolder.style.height=`${s}px`;let l=this.#n.clientHeight,u=0,d=0;for(let t=0;t<r;t++){let n=c[t];if(u+n>e){d=t;break}u+=n,d=t}let f=e-u;i&&i.querySelectorAll(`tbody`).forEach(e=>{e.style.top=`-${Math.max(0,f)}px`});let p=this.#r.firstTr,m=p&&p.dataset.virtualIndex!==void 0?parseInt(p.dataset.virtualIndex,10):-1;if(!t&&m===d)return;let g=Math.ceil(l/(this.#o/a)),_=(this.#n.grouping.columns?.length||1)*15,v=d,y=Math.min(r,d+g+_),b=n.slice(v,y);[`.ng-container-body`,`.ng-container-left`,`.ng-container-right`].forEach(e=>{let t=this.#n.querySelector(`.ng-sheet-body ${e}`);if(!t)return;let r=Array.from(t.querySelectorAll(`tbody.body tr`));for(let e=0;e<r.length;e+=a){let t=Math.floor(e/a),i=b[t],o=r.slice(e,e+a);if(!i||t>=b.length){o.forEach(e=>{e.style.display=`none`,e.dataset.matrixRow=null,e.dataset.row=null,e.dataset.index=null});continue}let s=d+t;o.forEach((e,r)=>{let a=d+t;e.dataset.virtualIndex=a,e.dataset.row=i.type===`data`?s:``;let o=e.getAttribute(`grouping`)===`true`;if(i.type===`group`)o&&r===i.record[h.DEPTH]?(e.style.display=``,this.#m(e,n,i.record,a)):(e.style.display=`none`,e.dataset.matrixRow=null,e.dataset.row=null,e.dataset.index=null);else if(o)e.style.display=`none`,e.dataset.matrixRow=null,e.dataset.row=null,e.dataset.index=null;else{e.style.display=``;let t=i.record.m?.rowid??0;this.#h(e,i.record,t,a)}})}}),this.#n.selection.refresh()};#m=(e,t,n,r)=>{let i=this.#n.templateLength||1,a=parseInt(e.dataset.subrow,10)||0,o=r*i+a,s=n[h.CHILDREN],c=this.#t.data.getArray(),l=s?s.map(e=>c[e]).filter(Boolean):[];e.dataset.virtualIndex=r,e.dataset.row=``,e.dataset.matrixRow=o,e.data=l,e.dataset.groupId=n[h.ID],Array.from(e.cells).forEach(e=>{e.dataset.row=r;let t=Array.from(e.children).find(e=>e.tagName.toLowerCase().startsWith(`cell-`)||typeof e.refresh==`function`);t!==void 0&&typeof t.refresh==`function`&&t?.refresh()})};#h=(e,t,n,r)=>{let i=this.#n.templateLength||1,a=parseInt(e.dataset.subrow,10)||0,o=r*i+a;e.dataset.index=r,e.dataset.row=n,e.dataset.matrixRow=o,e.data=t,Array.from(e.cells).forEach(e=>{e.dataset.index=r,e.dataset.row=n,Array.from(e.children).find(e=>e.tagName.toLowerCase().startsWith(`cell-`)&&typeof e.refresh==`function`)?.refresh()})};initialize=()=>{this.#d=!!this.#n.sourceTable.querySelector(`tbody tr[grouping='true']`),this.#o=null,this.#i.clear(),this.#r={scrollTables:this.#n.querySelectorAll(`.ng-sheet-body table`),firstTr:this.#n.querySelector(`.ng-sheet-body .ng-container-body tbody.body tr`)},[`.ng-container-body`,`.ng-container-left`,`.ng-container-right`].forEach(e=>{let t=this.#n.querySelector(`.ng-sheet-body ${e}`);if(!t)return;let n=t.querySelector(`table`);if(!n)return;let r=n.querySelector(`tbody.body`);if(!r)return;let i=Array.from(r.querySelectorAll(`tr`)).map(e=>e.cloneNode(!0));this.#i.set(e,i)});let e=this.#n.querySelector(`.ng-sheet-body`);e&&(this.#c=e.clientHeight,this.#g(),this.#v(),this.#f(e.scrollTop,!0),e.addEventListener(`scroll`,t=>{if(this.#u)return;let n=this.#o||0;(this.#n.view.getArray()?.length||0)*n<=e.clientHeight||(this.#f(e.scrollTop),this.#n.querySelector(`nine-table-vscrollbar`).refresh())},{passive:!0}))};scrollToDataRow(e,t=`top`,n){let r=this.#n.querySelector(`.ng-sheet-body`),i=this.#n.view.getArray()?.length||0,a=Math.max(0,Math.min(e,i-1)),o=0;if(this.#d){let e=Math.max(r.scrollHeight-r.clientHeight,1);o=a/Math.max(i-1,1)*e}else{let e=this.#o,t=a*e,n=(this.#n.elements.body.thead?.offsetHeight||0)+(this.#n.elements.body.tfoot?.offsetHeight||0)+this.#n.elements.body.tbody.head.offsetHeight,s=r.offsetHeight||0,c=Math.max(i*e+n-s,0),l=15e6,u=c>l,d=1;u&&(d=l/c),o=t*d}this.#u=!0,r.scrollTop=o,this.#f(o),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#u=!1,typeof n==`function`&&n()})})}destroy=()=>{this.#s&&=(this.#s.disconnect(),null)};#g=()=>{if(!this.#n.classList.contains(`active`)||!this.#n.sourceTable)return;let e=this.#n.sourceTable?.querySelectorAll(`tbody.body tr`),t=this.#n.querySelector(`.ng-sheet-body .ng-container-body tbody.body`);t.querySelectorAll(`tr`).forEach(e=>e.remove());let n=document.createDocumentFragment();e.forEach(e=>n.appendChild(e.cloneNode(!0))),t.appendChild(n);let r=t.querySelectorAll(`tr`);this.#a=[],r.forEach(e=>{this.#a.push(Math.max(e.offsetHeight,24))}),r.forEach(e=>e.remove()),this.#o=this.#a.reduce((e,t)=>e+t,0),this.#_()};#_=()=>{if(this.#c>0&&this.#o>0){let e=Math.ceil(this.#c/this.#o),t=this.#e;if(this.#d&&this.#n.grouping){let e=this.#n.grouping.columns?.length||1;t+=e*15}this.#l=e+t}};#v=()=>{[`.ng-container-body`,`.ng-container-left`,`.ng-container-right`].forEach(e=>{let t=this.#n.querySelector(`.ng-sheet-body ${e}`);t&&t.querySelector(`tbody`)&&this.#y(t)}),this.#b()};#y=e=>{let t=null;e.classList.contains(`ng-container-left`)?t=`left`:e.classList.contains(`ng-container-right`)&&(t=`right`);let n=Array.from(this.#n.sourceTable.querySelectorAll(`tbody.body tr`)).map(e=>{let n=e.cloneNode(!0);return t===`left`?n.querySelectorAll(`th,td`).forEach(e=>{e.getAttribute(`fixed`)!==`left`&&e.remove()}):t===`right`?n.querySelectorAll(`th,td`).forEach(e=>{e.getAttribute(`fixed`)!==`right`&&e.remove()}):n.querySelectorAll(`[fixed=left], [fixed=right]`).forEach(e=>{e.remove()}),n});if(n.length===0)return;let r=e.querySelector(`tbody.body`);if(!r)return;r.querySelectorAll(`tr`).forEach(e=>e.remove());let i=document.createDocumentFragment();for(let e=0;e<this.#l;e++)n.forEach(e=>i.appendChild(e.cloneNode(!0)));r.appendChild(i),e.classList.contains(`ng-container-body`)&&(this.#r.firstTr=r.querySelector(`tr`))};#b=()=>{let e=this.#n.querySelector(`.ng-sheet-body .ng-container-left table`),t=this.#n.querySelector(`.ng-sheet-body .ng-container-body table`),n=this.#n.querySelector(`.ng-sheet-body .ng-container-right table`);if(t){let r=e?Array.from(e.querySelectorAll(`tbody tr`)):[],i=Array.from(t.querySelectorAll(`tbody tr`)),a=n?Array.from(n.querySelectorAll(`tbody tr`)):[],o=Math.max(r.length,i.length,a.length);for(let e=0;e<o;e++){let t=[r[e]?.getBoundingClientRect().height||0,i[e]?.getBoundingClientRect().height||0,a[e]?.getBoundingClientRect().height||0],n=Math.max(...t);n>0&&(r[e]&&(r[e].style.height=`${n}px`),i[e]&&(i[e].style.height=`${n}px`),a[e]&&(a[e].style.height=`${n}px`))}}};#x=()=>{this.#n&&this.#n instanceof HTMLElement&&(this.#s=new ResizeObserver(e=>{for(let t of e){if(!t.target.classList.contains(`active`))continue;let e=t.contentRect.height;t.contentRect.width>0&&this.#n.isAutoFitCol&&this.#n.autoFit(!0),e>0&&this.#c!==e&&(this.#c=e,this.#_(),this.#o!==null&&(this.#v(),this.refresh()))}}),this.#s.observe(this.#n))}},y=class e{static compile(t){let n=t.cloneNode(!0);return e.resetColIndex(n,n.querySelectorAll(`thead tr`)),e.resetColIndex(n,n.querySelectorAll(`tbody.body tr[grouping="true"]`)),e.resetColIndex(n,n.querySelectorAll(`tbody.body tr:not([grouping="true"])`)),e.resetColIndex(n,n.querySelectorAll(`tfoot tr`)),e.#e(n),n}static recompile(t){return e.resetColIndex(t,t.querySelectorAll(`thead tr`)),e.resetColIndex(t,t.querySelectorAll(`tbody.body tr[grouping="true"]`)),e.resetColIndex(t,t.querySelectorAll(`tbody.body tr:not([grouping="true"])`)),e.resetColIndex(t,t.querySelectorAll(`tfoot tr`)),e.#e(t),t}static#e(e){e.querySelectorAll(`colgroup col`).forEach((t,n)=>{t.setAttribute(`data-col`,n);let r=t.getAttribute(`fixed`);e.querySelectorAll(`[data-col="${n}"]`).forEach(e=>{r?e.setAttribute(`fixed`,r):e.removeAttribute(`fixed`)})})}static resetColIndex(e,t){let n=e.querySelectorAll(`colgroup col`),r=Array.from({length:t.length},()=>Array(n.length).fill(null));t.forEach((e,i)=>{e.dataset.subrow=i;let a=0;e.querySelectorAll(`th, td`).forEach(e=>{for(;a<n.length&&r[i][a]!==null;)a++;e.dataset.col=a;let o=e.rowSpan||1,s=e.colSpan||1;for(let c=0;c<o;c++)for(let o=0;o<s;o++)i+c<t.length&&a+o<n.length&&(r[i+c][a+o]=e);a+=s})})}},b=class{#e;#t={startRow:-1,startCol:-1,endRow:-1,endCol:-1};constructor(e){this.#e=e,this.#r()}#n(e){if(!e)return{dataRow:-1,subRowIndex:-1,matrixRow:-1};let t=parseInt(e.dataset.index,10);if(isNaN(t))return{dataRow:-1,subRowIndex:-1,matrixRow:-1};let n=e.closest(`tbody`),r=Array.from(n.querySelectorAll(`tr`)).filter(e=>parseInt(e.dataset.index,10)===t),i=r.indexOf(e),a=r.length>0?r.length:1;return{dataRow:t,subRowIndex:i,matrixRow:t*a+(i>=0?i:e.sectionRowIndex%a)}}setFocus(e,t){this.#e.querySelectorAll(`tr.selected-start`).forEach(e=>{e.classList.remove(`selected-start`),e.querySelectorAll(`td.selected-start`).forEach(e=>{e.classList.remove(`selected-start`)})});let n=this.#e.querySelector(`.ng-sheet-body-content tr[data-matrix-row="${e}"] td[data-col="${t}"]`);n&&(n.classList.add(`selected-start`),n.closest(`tr`)?.classList.add(`selected-start`))}setRange(e,t,n,r){let i=Math.min(e,n),a=Math.max(e,n),o=Math.min(t,r),s=Math.max(t,r),c=this.#e.querySelectorAll(`.ng-container-left, .ng-container-body, .ng-container-right`),l=!0,u=0;for(;l&&u<5;)l=!1,u++,c.forEach(e=>{Array.from(e.querySelectorAll(`tbody tr`)).filter(e=>e.style.display!==`none`).forEach(e=>{let{matrixRow:t}=this.#n(e);t<0||e.querySelectorAll(`td, th`).forEach(e=>{let n=parseInt(e.dataset.col,10);if(isNaN(n))return;let r=parseInt(e.rowSpan||1,10),c=parseInt(e.colSpan||1,10),u=t+r-1,d=n+c-1;if(u>=i&&t<=a&&d>=o&&n<=s){let e=Math.min(i,t),r=Math.max(a,u),c=Math.min(o,n),f=Math.max(s,d);(e!==i||r!==a||c!==o||f!==s)&&(i=e,a=r,o=c,s=f,l=!0)}})})});this.#t={startRow:i,startCol:o,endRow:a,endCol:s},this.render()}refresh=()=>{this.render()};render=()=>{let{startRow:e,startCol:t,endRow:n,endCol:r}=this.#t,i=this.#e.querySelectorAll(`.ng-container-left, .ng-container-body, .ng-container-right`);i.forEach(e=>{e.querySelectorAll(`.selected, .selected-top, .selected-bottom, .selected-left, .selected-right, .selected-start`).forEach(e=>{e.classList.remove(`selected`,`selected-top`,`selected-bottom`,`selected-left`,`selected-right`,`selected-start`)}),e.querySelectorAll(`tr.selected-start`).forEach(e=>{e.classList.remove(`selected-start`)})}),e<0||t<0||i.forEach(i=>{Array.from(i.querySelectorAll(`tbody tr`)).filter(e=>e.style.display!==`none`).forEach(i=>{let{matrixRow:a}=this.#n(i);a<0||i.querySelectorAll(`td, th`).forEach(i=>{let o=parseInt(i.dataset.col,10);if(isNaN(o))return;let s=parseInt(i.rowSpan||1,10),c=parseInt(i.colSpan||1,10),l=a+s-1,u=o+c-1;l>=e&&a<=n&&u>=t&&o<=r&&(i.classList.add(`selected`),a<=e&&i.classList.add(`selected-top`),l>=n&&i.classList.add(`selected-bottom`),o<=t&&i.classList.add(`selected-left`),u>=r&&i.classList.add(`selected-right`))})})})};#r(){let e=this.#e.querySelector(`.ng-sheet-body`);e&&e.addEventListener(`mousedown`,e=>{if(e.button!==0)return;let t=e.target.closest(`td, th`);if(!t||t.dataset.row===void 0||t.dataset.col===void 0)return;this.#e.style.userSelect=`none`,this.#e.style.webkitUserSelect=`none`;let n=t.closest(`tr`),{matrixRow:r}=this.#n(n),i=parseInt(t.dataset.col,10);if(r<0){this.#e.style.userSelect=``,this.#e.style.webkitUserSelect=``;return}this.setFocus(r,i),this.setRange(r,i,r,i);let a=r,o=i,s=e=>{let t=document.elementFromPoint(e.clientX,e.clientY)?.closest(`td, th`);if(!t||!this.#e.contains(t)){let n=this.#e.querySelectorAll(`.ng-sheet-body-content tbody tr td, .ng-sheet-body-content tbody tr:not(.nodata) th`);for(let r of n){let n=r.getBoundingClientRect();if(e.clientX>=n.left&&e.clientX<=n.right&&e.clientY>=n.top&&e.clientY<=n.bottom){t=r;break}}}if(!t||t.dataset.row===void 0||t.dataset.col===void 0)return;let n=t.closest(`tr`),{matrixRow:s}=this.#n(n),c=parseInt(t.dataset.col,10);s<0||(a!==s||o!==c)&&(a=s,o=c,this.setRange(r,i,s,c))},c=()=>{this.#e.style.userSelect=``,this.#e.style.webkitUserSelect=``,document.removeEventListener(`mousemove`,s),document.removeEventListener(`mouseup`,c)};document.addEventListener(`mousemove`,s),document.addEventListener(`mouseup`,c)})}},x=class{#e;#t;#n=null;#r=null;constructor(e){this.#e=e,this.#t=e.getRootNode().host,this.#g()}get currentCell(){return this.#n}set currentCell(e){if(!e)return;this.#n=e,e.focus({preventScroll:!0}),this.#r=e.closest(`tr`);let t=parseInt(this.#r.dataset.matrixRow,10);this.#e.selection.setFocus(t,this.#n.dataset.col)}#i=(e,t)=>{if(t){switch(e.code){case`Tab`:e.shiftKey?this.#p(t)||t.scrollIntoView({inline:`nearest`,block:`nearest`}):this.#m(t)||t.scrollIntoView({inline:`nearest`,block:`nearest`});break;case`ArrowRight`:this.#m(t)||t.scrollIntoView({inline:`nearest`,block:`nearest`});break;case`ArrowLeft`:this.#p(t)||t.scrollIntoView({inline:`nearest`,block:`nearest`})}this.currentCell=t,this.#e.selection.setRange(this.#r.dataset.matrixRow,t.dataset.col,this.#r.dataset.matrixRow,t.dataset.col)}};#a=(e,t)=>{if(t){let n=!1;switch(e.code){case`Enter`:e.shiftKey,this.#f(t)&&(n=!0);break;case`ArrowDown`:this.#f(t)&&(n=!0);break;case`ArrowUp`:this.#d(t)&&(n=!0)}if(n){this.currentCell=t,this.#e.selection.setRange(this.#r.dataset.matrixRow,t.dataset.col,this.#r.dataset.matrixRow,t.dataset.col);return}}let n=parseInt(this.#r.dataset.index,10),r=-1;switch(e.code){case`Enter`:if(e.shiftKey){let e=this.#h();r=Math.max(n-e+0,0)}else r=Math.min(n,this.#e.view.count());break;case`ArrowDown`:r=Math.min(n,this.#e.view.count());break;case`ArrowUp`:let t=this.#h();r=Math.max(n-t+0,0)}if(r<0)return;let i=parseInt(this.#r.dataset.matrixRow,10),a=parseInt(this.#n.dataset.col,10),o=parseInt(this.#n.rowSpan,10)||1;switch(e.code){case`ArrowDown`:i+=o;break;case`ArrowUp`:i--}this.#e.rowManager.scrollToDataRow(r,null,()=>{let e=this.#c(i,a);e&&(this.currentCell=e,this.#e.selection.setRange(this.#r.dataset.matrixRow,e.dataset.col,this.#r.dataset.matrixRow,e.dataset.col))})};moveCell=e=>{if(e.target.tagName===`INPUT`&&([`text`].includes(e.target.type)&&[`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.code)||[`date`,`datetime-local`,`time`,`week`,`month`].includes(e.target.type))||!this.#n||!this.#r)return;let t;switch(e.code){case`Tab`:t=e.shiftKey?this.#s():this.#o();break;case`ArrowRight`:t=this.#o();break;case`ArrowLeft`:t=this.#s();break;case`Enter`:t=e.shiftKey?this.#l():this.#u();break;case`ArrowDown`:t=this.#u();break;case`ArrowUp`:t=this.#l()}e.preventDefault(),[`ArrowLeft`,`ArrowRight`,`Tab`].includes(e.code)?this.#i(e,t):[`Enter`,`ArrowUp`,`ArrowDown`].includes(e.code)&&this.#a(e,t)};#o=()=>{let e=parseInt(this.#n.dataset.col,10),t=parseInt(this.#n.colSpan,10)||1,n=parseInt(this.#r.dataset.index,10),r=parseInt(this.#r.dataset.matrixRow,10),i=e+t,a=this.#e.querySelector(`tbody tr[data-matrix-row="${r}"] td[data-col="${i}"]`);return a||=this.#e.querySelector(`tbody tr[data-index="${n}"] td[data-col="${i}"]`),a};#s=()=>{let e=parseInt(this.#n.dataset.col,10),t=parseInt(this.#r.dataset.index,10),n=parseInt(this.#r.dataset.matrixRow,10),r;for(let i=e-1;i>=0&&(r=this.#e.querySelector(`tbody tr[data-matrix-row="${n}"] td[data-col="${i}"]`),r||=this.#e.querySelector(`tbody tr[data-index="${t}"] td[data-col="${i}"]`),!r);i--);return r};#c=(e,t)=>{let n=this.#e.querySelector(`tbody tr[data-matrix-row="${e}"]`);if(!n)return;let r=parseInt(n.dataset.index,10),i=this.#e.querySelector(`tbody tr[data-matrix-row="${e}"] td[data-col="${t}"]`);return i||(this.#e.querySelectorAll(`tbody tr[data-matrix-row="${e}"] td`).forEach(e=>{let n=parseInt(e.dataset.col,10),r=parseInt(e.colSpan,10)||1;t>=n&&t<n+r&&(i=e)}),i||(i=this.#e.querySelector(`tbody tr[data-index="${r}"] td[data-col="${t}"]`),i||this.#e.querySelectorAll(`tbody tr[data-index="${r}"] td`).forEach(e=>{let n=parseInt(e.dataset.col,10),r=parseInt(e.colSpan,10)||1;t>=n&&t<n+r&&(i=e)}))),i};#l=()=>{let e=parseInt(this.#n.dataset.col,10),t=parseInt(this.#r.dataset.matrixRow,10);return this.#c(t-1,e)};#u=()=>{let e=parseInt(this.#n.dataset.col,10),t=parseInt(this.#r.dataset.matrixRow,10),n=parseInt(this.#n.rowSpan,10)||1;return this.#c(t+n,e)};#d=e=>{let t=this.#e.querySelector(`.ng-sheet-body`);if(!t||!e)return!0;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=t.querySelector(`thead`)?.offsetHeight||0;return n.top>=r.top+i};#f=e=>{let t=this.#e.querySelector(`.ng-sheet-body`);if(!t||!e)return!0;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.bottom<=r.bottom};#p=e=>{let t=this.#e.querySelector(`.ng-container-body`);if(!t||!e)return!0;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.left>=r.left};#m=e=>{let t=this.#e.querySelector(`.ng-container-body`);if(!t||!e)return!0;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.right<=r.right};#h=()=>{let e=this.#e.querySelector(`.ng-sheet-body`),t=e.clientHeight-(e.querySelector(`thead`)?.offsetHeight||0),n=this.#e.rowManager.getRowHeight();return Math.max(1,Math.floor(t/n))};#g(){this.#e.addEventListener(`mousedown`,e=>{if(e.button!==0)return;let t=e.target.closest(`td, th`);t&&t.dataset.index!==void 0&&t.dataset.col!==void 0&&(this.currentCell=t)}),this.#e.addEventListener(`keydown`,e=>{[`Enter`,`Tab`,`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`].includes(e.code)&&this.moveCell(e)})}},S=2,C=class{#e;#t;#n;#r;#i=null;#a=null;#o=null;#s=null;#c=0;#l=0;#u=0;#d=0;#f=0;constructor(e){this.#e=e,this.#t=e.getRootNode().host,this.#n=this.#e.querySelector(`nine-table-col-resizer-panel`),this.#r=this.#n.querySelector(`.resizer-overlay`),this.bindEvents()}destroy(){this.#e.removeEventListener(`pointermove`,this.#h),this.#e.removeEventListener(`pointerdown`,this.#g),this.#e.removeEventListener(`dblclick`,this.#b)}refreshLayout(e=`body`){let t=Array.from(this.#e.querySelectorAll(`.ng-container-${e}`));if(t.length!==0){if(e===`left`||e===`right`||!this.#e.isAutoFitCol&&t[0].querySelector(`table`)?.getAttribute(`auto-fit-col`)!==`true`){let n=t[0].querySelector(`table colgroup`);if(!n)return;let r=0,i={};Array.from(n.querySelectorAll(`col`)).forEach(e=>{let t=e.getAttribute(`data-col`),n=parseInt(e.getAttribute(`width`),10);isNaN(n)||(i[t]=n,r+=n)}),t.forEach(t=>{let n=t.querySelectorAll(`table`);e===`body`?n.forEach(e=>{e.style.width=`${r}px`}):(t.style.flex=`0 0 ${r}px`,t.style.width=`${r}px`,t.style.minWidth=`${r}px`,t.style.maxWidth=`${r}px`,n.forEach(e=>{e.style.width=`${r}px`,e.style.minWidth=`${r}px`,e.style.maxWidth=`${r}px`,Object.entries(i).forEach(([t,n])=>{e.querySelectorAll(`th[data-col="${t}"], td[data-col="${t}"]`).forEach(e=>{e.style.width=`${n}px`,e.style.minWidth=`${n}px`,e.style.maxWidth=`${n}px`})})}))})}else t.forEach(e=>{e.querySelectorAll(`table`).forEach(e=>{})});this.#e.querySelector(`nine-table-hscrollbar`)?.refresh()}}setColumnWidth(e,t,n=null){let r=[];if(r=Array.from(this.#e.querySelectorAll(`table colgroup col[data-col="${e}"]`)),r.length===0)return;let i=r[0].closest(`.ng-container-left, .ng-container-body, .ng-container-right`),a=n||(i?.classList.contains(`ng-container-left`)?`left`:i?.classList.contains(`ng-container-right`)?`right`:`body`);r.forEach(e=>{e.setAttribute(`width`,t),e.style.width=`${t}px`});let o=this.#e.sourceTable?.querySelector(`colgroup col[data-col="${e}"]`);o&&(o.setAttribute(`width`,t),o.style.width=`${t}px`),this.refreshLayout(a),(a===`left`||a===`right`)&&this.refreshLayout(`body`),this.#e.rowManager?.refresh()}#p(e){if(this.#e.isAutoFitCol)return!0;let t=e?.closest(`table`);return!!(t&&t.getAttribute(`auto-fit-col`)===`true`)}bindEvents(){this.#e.addEventListener(`pointermove`,this.#h),this.#e.addDebounseEventListener(`dblclick`,this.#b,`pointerdown`,this.#g)}#m(e){let t=e.closest(`.ng-container-left, .ng-container-body, .ng-container-right`);return t?t.classList.contains(`ng-container-left`)?`left`:t.classList.contains(`ng-container-right`)?`right`:`body`:null}#h=e=>{let t=e.target.closest(`thead`);if(!t)return;let n=e.target.closest(`th, td`);if(t.querySelectorAll(`.resizable-edge`).forEach(e=>{e!==n&&e.classList.remove(`resizable-edge`)}),!n||n.dataset.col===void 0||n.getAttribute(`collapsed`)===`true`)return;let r=n.getBoundingClientRect(),i=e.clientX-r.left,a=i<=S,o=r.width-i<=S;if(a){let e=n.previousElementSibling;if(!e||e.getAttribute(`collapsed`)===`true`){n.classList.remove(`resizable-edge`);return}}a||o?n.classList.add(`resizable-edge`):n.classList.remove(`resizable-edge`)};#g=e=>{if(!e.actualTarget.closest(`thead`))return;let t=e.actualTarget.closest(`th, td`);if(!t||!t.classList.contains(`resizable-edge`))return;e.preventDefault();let n=t.getBoundingClientRect(),r=e.clientX-n.left,i=t;if(r<=S){let e=t.previousElementSibling;if(e&&e.dataset.col!==void 0&&e.getAttribute(`collapsed`)!==`true`)i=e;else if(!t.previousElementSibling)return}this.#s=i,this.#o=this.#m(i);let a=this.#e.querySelector(`.ng-container-${this.#o}`);if(!a)return;let o=parseInt(i.dataset.col,10),s=i.colSpan||1;if(this.#i=o+s-1,this.#p(i)){this.#a=this.#i+1;let e=a.querySelector(`col[data-col="${this.#a}"]`);e?this.#u=parseInt(e.getAttribute(`width`),10)||100:this.#a=null}else this.#a=null;let c=i.getBoundingClientRect(),l=this.#e.getBoundingClientRect();this.#d=c.width,this.#f=c.left-l.left;let u=a.querySelector(`col[data-col="${this.#i}"]`)?.getAttribute(`width`);this.#l=u&&!isNaN(parseInt(u,10))?parseInt(u,10):c.width/s,this.#c=e.clientX,this.#n&&(this.#n.classList.add(`active`),this.#_(e.clientX)),window.addEventListener(`pointermove`,this.#v),window.addEventListener(`pointerup`,this.#y,{once:!0})};#_(e){let t=e-this.#c,n=this.#p(this.#s);if(n&&this.#a!==null){let e=this.#u-16,n=-(this.#l-16);t=Math.max(n,Math.min(t,e))}let r=Math.max(16,this.#l+t),i=e-this.#s.getBoundingClientRect().left;if(n&&this.#a!==null){let e=this.#d+(this.#u-16);i=Math.min(i,e)}let a=Math.max(16,i);this.#n&&(this.#n.style.setProperty(`--col-resizer-tooltip-left`,`${this.#f}px`),this.#n.style.setProperty(`--col-resizer-tooltip-width`,`${a}px`));let o=this.#r?.querySelector(`.size-badge`);o&&(o.textContent=`${Math.round(r)}px`)}#v=e=>{this.#_(e.clientX)};#y=e=>{window.removeEventListener(`pointermove`,this.#v);let t=e.clientX-this.#c,n=this.#p(this.#s),r=0;if(n&&this.#a!==null){let e=Math.max(16,this.#l+t),n=this.#l+this.#u-e;n<16&&(n=16,e=this.#l+this.#u-16),this.setColumnWidth(this.#i,e,this.#o),this.setColumnWidth(this.#a,n,this.#o),r=e}else{let e=Math.max(16,this.#l+t);this.#i!==null&&this.#o&&(this.setColumnWidth(this.#i,e,this.#o),r=e)}if(this.#s){let e=this.#s;e.getAttribute(`collapsed`)!==`true`&&r>20&&(e.dataset.expandWidth=String(r))}this.#n&&(this.#r?.classList.add(`fade-out`),setTimeout(()=>{this.#n.classList.remove(`active`),this.#r?.classList.remove(`fade-out`)},150)),this.#i=null,this.#a=null,this.#o=null,this.#s=null};#b=e=>{let t=e.target.closest(`th, td`);if(!t||!t.classList.contains(`resizable-edge`))return;let n=t.getBoundingClientRect();e.clientX-n.left<=S&&(t=t.previousElementSibling);let r=parseInt(t.dataset.col,10),i=this.#e.querySelector(`tbody.body [data-col="${r}"]`);if(!i||!i.dataset.bind||i.classList.contains(`CELL-RADIO`))return;let a=0;Array.from(i.firstElementChild.children).forEach(e=>{switch(e.tagName){case`SPAN`:a+=8;break;case`DIV`:a+=8;break;case`BUTTON`:a+=32;break;case`SELECT`:a+=32;break;case`INPUT`:switch((e.type||`text`).toLowerCase()){case`checkbox`:case`radio`:a+=12;break;case`button`:case`submit`:case`reset`:case`image`:a+=16;break;case`color`:case`file`:case`range`:a+=24;break;case`hidden`:a+=0;break;default:a+=16}}});let o=this.#t.fields.get().indexOf(i.dataset.bind),s=window.getComputedStyle(i).font||`12px sans-serif`,c=t.innerText||``,l=(nine.measureTextSize(c,s).width||0)+16;this.#t.execute(()=>{this.#e.view.getArray().forEach((e,t)=>{let n=String(i.dataset.expr?this.#t.exprEngine.evaluate(i.dataset.expr,e,t):e.v[o]??``).trim(),r=nine.measureTextSize(n,s);r.width&&r.width>l&&(l=r.width)});let e=Math.max(32,Math.min(400,Math.ceil(l)+a));this.setColumnWidth(i.dataset.col,e,this.#m(t))})}},w=class extends HTMLElement{constructor(){super()}connectedCallback(){this.#e()}#e=()=>{this.innerHTML=`
26
+ `;let e=()=>{let t=this.#t.querySelector(`.ng-sheet-body`);t?(this.#r={container:t,track:this.querySelector(`.scroll-track`),thumb:this.querySelector(`.scroll-thumb`),top:this.querySelector(`.scroll-top`),bottom:this.querySelector(`.scroll-bottom`)},this.#s(),this.refresh()):setTimeout(e,10)};e()}#o=()=>{let e=this.#t.view.getArray(),t=e?e.length:0,n=this.#t.elements?.scrollHolder,r=n&&parseFloat(n.style.height)||0;(!r||r<=0)&&(r=this.#t.sourceTable?.querySelector(`tbody tr[grouping='true']`)&&this.#t.rowManager?body.scrollHeight>body.clientHeight?body.scrollHeight:t*30:t*(this.#t.getRowHeight()||1));let i=15e6,a=r>i,o=1,s=r;return a&&(o=i/r,s=i),{rawContentHeight:r,contentHeight:s,scaleFactor:o,useScaling:a,totalCount:t}};refresh=()=>{if(this.#n||!this.#t||!this.#t.elements||!this.#r)return;let e=this.#r.container,t=this.#r.track,n=this.#r.thumb,{contentHeight:r}=this.#o(),i=(this.#t.querySelector(`thead`)?.offsetHeight||0)+(this.#t.querySelector(`tfoot`)?.offsetHeight||0)+(this.#t.querySelector(`tbody.head`)?.offsetHeight||0),a=this.#t.querySelector(`.ng-sheet-body`).offsetHeight||0,o=a-i,s=this.#t.view.getArray().length,c=this.#t.getRowHeight()*s,l=c>o;if(this.#t.classList.toggle(`vscroll-visible`,l),!l)return;let u=t.clientHeight;if(u<=0)return;let d=Math.max(Math.min(a/c*u,u),20);n.style.height=`${d}px`;let f=e.scrollTop,p=Math.max(r-this.#t.rowManager.getRowHeight(),1),m=0;p>0&&(m=f/p*(u-d));let h=u-d;m<0&&(m=0),m>h&&(m=h),n.style.top=`${m}px`,this.#r.top.disabled=f<=0,this.#r.bottom.disabled=f>=p-1};#s=()=>{this.#r.thumb.addEventListener(`mousedown`,e=>{if(e.button!==0)return;e.stopPropagation(),e.preventDefault(),this.#n=!0,this.#i=e.clientY,this.#a=parseFloat(this.#r.thumb.style.top)||0;let t=this.#r.track.getBoundingClientRect().height-this.#r.thumb.clientHeight,n=e=>{if(!this.#n||t<=0)return;let n=e.clientY-this.#i,r=this.#a+n;r<0&&(r=0),r>t&&(r=t),this.#r.thumb.style.top=`${r}px`;let i=r/t,a=this.#t.getRowHeight(),o=(this.#t.querySelector(`.ng-sheet-body`).offsetHeight||0)-(this.#t.elements.body.thead?.offsetHeight||0)-(this.#t.elements.body.tfoot?.offsetHeight||0)-(this.#t.elements.body.tbody.head.offsetHeight||0),s=Math.floor(o/a),{totalCount:c}=this.#o(),l=Math.floor(i*(c-s+1));this.#t.rowManager.scrollToDataRow(l);let{rawContentHeight:u,contentHeight:d}=this.#o(),f=this.#r.container.scrollTop,p=Math.max(d-this.#t.rowManager.getRowHeight(),0);this.#r.top.disabled=f<=0,this.#r.bottom.disabled=f>=p-1},r=()=>{this.#n=!1,document.removeEventListener(`mousemove`,n),document.removeEventListener(`mouseup`,r)};document.addEventListener(`mousemove`,n),document.addEventListener(`mouseup`,r)}),this.#r.track.addEventListener(`mousedown`,e=>{if(e.button!==0||e.target===this.#r.thumb)return;let t=this.#r.track.getBoundingClientRect(),n=this.#r.thumb.clientHeight,r=this.#r.track.clientHeight-n;if(r>0){let i=e.clientY-t.top-n/2,a=Math.max(0,Math.min(1,i/r)),{totalCount:o}=this.#o(),s=Math.max(0,Math.min(Math.floor(a*(o-1)),o-1));s>=0&&this.#t.rowManager&&typeof this.#t.rowManager.scrollToDataRow==`function`&&this.#t.rowManager.scrollToDataRow(s,`top`)}this.refresh()});let e=null,t=t=>{if(e)return;let n=()=>{let e=this.#t.querySelector(`tbody.body tr`);if(!e||e.dataset.row===void 0||t===`down`&&this.#t.isLastRow())return;let n=parseInt(e.dataset.row,10),r=t===`down`?n+1:Math.max(0,n-1);this.#t.rowManager.scrollToDataRow(r,null,()=>{this.refresh()})};n(),e=setInterval(n,200)},n=()=>{e&&=(clearInterval(e),null)};this.#r.top.addEventListener(`mousedown`,e=>{e.button===0&&t(`up`)}),this.#r.bottom.addEventListener(`mousedown`,e=>{e.button===0&&t(`down`)}),document.addEventListener(`mouseup`,n),this.#r.top.addEventListener(`mouseleave`,n),this.#r.bottom.addEventListener(`mouseleave`,n)}};customElements.get(`nine-table-vscrollbar`)||customElements.define(`nine-table-vscrollbar`,m);var h={ID:0,DEPTH:1,NAME:2,CHILDREN:3},g=class{#e;#t;#n=[];#r=new Map;#i=!1;constructor(e){this.#e=e,this.#t=this.#e.getRootNode().host}get columns(){return this.#n}get groupMap(){return this.#r}initialize=()=>{let e=[],t=this.#e.sourceTable;t&&t.querySelectorAll(`tbody tr[grouping="true"]`).forEach(t=>{let n=t.querySelector(`[cell-type="tree"]`);n&&n.dataset.bind&&e.push(n.dataset.bind)}),this.#n=e};apply(){if(this.#i)return;this.#i=!0;let e=[],t=this.#e.sourceTable;t&&t.querySelectorAll(`tbody tr[grouping="true"]`).forEach(t=>{let n=t.querySelector(`[cell-type="tree"]`);n&&n.dataset.bind&&e.push(n.dataset.bind)}),this.#n=e,this.#i=!1,this.#e.scrollToY(0),this.#e.view.refresh()}clear(){this.#n=[],this.#r.clear(),this.#i=!1,this.#e.scrollToY(0),this.#e.view.refresh()}setGroupMap(e){this.#r=e}getChildrenRowIds(e){return this.#r.get(e)||[]}getChildrenRecords(e){let t=this.getChildrenRowIds(e),n=this.#t.data;return t.map(e=>n.getArray(e)).filter(Boolean)}},_=class e{static apply(t,n=[],r=[]){if(!n||n.length===0)return{headers:[],renderItems:[],groupMap:new Map};let i=t.filter(e=>!e.__ng?.deleted),a=new Map,o=e.#t(i,n,r),s=[],c=[];return e.#e(o,0,n,s,c,a,``),{headers:s,renderItems:c,groupMap:a}}static#e(t,n,r,i,a,o,s){let c=0,l=n===r.length-1;for(let[u,d]of t.entries()){let t=s?`${s}_${c++}`:`g_${c++}`,f=e.#n(d);o.set(t,f);let p=[];p[h.ID]=t,p[h.DEPTH]=n,p[h.NAME]=u,p[h.CHILDREN]=f,p.__isGroupHeader=!0,p.__groupId=t,i.push(p),a.push({type:`group`,record:p,groupId:t}),!l&&d instanceof Map?e.#e(d,n+1,r,i,a,o,t):e.#r(d).forEach(e=>{e.__isGroupHeader=!1,e.__groupId=t,i.push(e),a.push({type:`data`,record:e,groupId:t})})}}static#t(t,n,r){let i=r.indexOf(n[0]),a=n.slice(1),o=new Map;if(t.forEach(e=>{let t=i>=0?e.v[i]:`(Unknown)`;o.has(t)||o.set(t,[]),o.get(t).push(e)}),a.length>0){let t=new Map;for(let[n,i]of o.entries())t.set(n,e.#t(i,a,r));return t}return o}static#n(t){let n=[];if(t instanceof Map)for(let r of t.values())n=n.concat(e.#n(r));else Array.isArray(t)&&(n=n.concat(t.map(e=>e.__ng?.rowid??e.m?._?.[0])));return n}static#r(t){let n=[];if(t instanceof Map)for(let r of t.values())n=n.concat(e.#r(r));else Array.isArray(t)&&(n=n.concat(t));return n}},v=class{#e=3;#t;#n;#r;#i=new Map;#a=[];#o=null;#s=null;#c=0;#l;#u=!1;#d=!1;constructor(e){this.#t=e.getRootNode().host,this.#n=e,this.#x()}getRowHeight(){return this.#a.reduce((e,t)=>e+t,0)}refresh=(e=!1)=>{if(!this.#n.classList.contains(`active`))return;let t=this.#n.querySelector(`.ng-sheet-body`);t&&((!this.#o||this.#o<=0)&&(this.#g(),this.#o&&this.#o>0&&this.#v()),this.#f(t.scrollTop,e),this.#n.querySelector(`nine-table-vscrollbar`)?.refresh())};#f=(e,t=!1)=>{if(this.#d){this.#p(e,t);return}let n=this.#o;if(!n||n<=0)return;let r=this.#n.view.getArray(),a=r.length;if(a===0){this.#n.elements.scrollHolder.style.height=`0px`;return}let o=this.#n.templateLength,s=(this.#n.elements.body.thead?.offsetHeight||0)+(this.#n.elements.body.tfoot?.offsetHeight||0)+this.#n.elements.body.tbody.head.offsetHeight,c=this.#n.querySelector(`.ng-sheet-body`).offsetHeight||0,l=Math.max(a*n-(c-s-n),0),u=15e6,d=l>u,f=1,p=l;d&&(f=u/l,p=u),this.#n.elements.scrollHolder.style.height=`${p}px`;let m=d?e/f:e,h=Math.max(0,a-1),g=Math.min(m,l),_=Math.max(0,Math.min(Math.floor(g/n),h)),v=g%n;this.#n.elements.left.tbody.body.style.top=this.#n.elements.body.tbody.body.style.top=this.#n.elements.right.tbody.body.style.top=`-${v}px`;let y=this.#r.firstTr,b=y&&y.dataset.row!==void 0?parseInt(y.dataset.row,10):-1;(t||b!==_)&&([this.#n.elements.left.tbody.body,this.#n.elements.body.tbody.body,this.#n.elements.right.tbody.body].forEach((e,t)=>{e&&e.querySelectorAll(`tbody.body tr`).forEach((e,t)=>{let n=_+Math.floor(t/o);if(n>=a){e.style.display=`none`,e.dataset.matrixRow=null,e.dataset.row=null,e.dataset.index=null;return}let s=r[n];if(!s){e.style.display=`none`;return}let c=s.m._[i.META.INDEX.ROWID];e.style.display=``,this.#h(e,s,c,n)})}),this.#n.selection.refresh())};#p=(e,t=!1)=>{let n=this.#n.view.getArray()||[],r=n.length;if(r===0){this.#n.elements.scrollHolder.style.height=`0px`;return}let i=this.#n.querySelector(`.ng-sheet-body .ng-sheet-body-content`),a=this.#n.templateLength||1,o=e=>{if(e.type===`group`){let t=e.record[h.DEPTH]||0;return this.#a[t]||this.#o/a}{let e=0,t=this.#n.templateLength||1,n=0;for(let e=0;e<t-1;e++)n+=this.#a[e]||0;return e=this.#o-n,e>0?e:this.#o}},s=0,c=Array(r);for(let e=0;e<r;e++){let t=o(n[e]);c[e]=t,s+=t}this.#n.elements.scrollHolder.style.height=`${s}px`;let l=this.#n.clientHeight,u=0,d=0;for(let t=0;t<r;t++){let n=c[t];if(u+n>e){d=t;break}u+=n,d=t}let f=e-u;i&&i.querySelectorAll(`tbody`).forEach(e=>{e.style.top=`-${Math.max(0,f)}px`});let p=this.#r.firstTr,m=p&&p.dataset.virtualIndex!==void 0?parseInt(p.dataset.virtualIndex,10):-1;if(!t&&m===d)return;let g=Math.ceil(l/(this.#o/a)),_=(this.#n.grouping.columns?.length||1)*15,v=d,y=Math.min(r,d+g+_),b=n.slice(v,y);[`.ng-container-body`,`.ng-container-left`,`.ng-container-right`].forEach(e=>{let t=this.#n.querySelector(`.ng-sheet-body ${e}`);if(!t)return;let r=Array.from(t.querySelectorAll(`tbody.body tr`));for(let e=0;e<r.length;e+=a){let t=Math.floor(e/a),i=b[t],o=r.slice(e,e+a);if(!i||t>=b.length){o.forEach(e=>{e.style.display=`none`,e.dataset.matrixRow=null,e.dataset.row=null,e.dataset.index=null});continue}let s=d+t;o.forEach((e,r)=>{let a=d+t;e.dataset.virtualIndex=a,e.dataset.row=i.type===`data`?s:``;let o=e.getAttribute(`grouping`)===`true`;if(i.type===`group`)o&&r===i.record[h.DEPTH]?(e.style.display=``,this.#m(e,n,i.record,a)):(e.style.display=`none`,e.dataset.matrixRow=null,e.dataset.row=null,e.dataset.index=null);else if(o)e.style.display=`none`,e.dataset.matrixRow=null,e.dataset.row=null,e.dataset.index=null;else{e.style.display=``;let t=i.record.m?.rowid??0;this.#h(e,i.record,t,a)}})}}),this.#n.selection.refresh()};#m=(e,t,n,r)=>{let i=this.#n.templateLength||1,a=parseInt(e.dataset.subrow,10)||0,o=r*i+a,s=n[h.CHILDREN],c=this.#t.data.getArray(),l=s?s.map(e=>c[e]).filter(Boolean):[];e.dataset.virtualIndex=r,e.dataset.row=``,e.dataset.matrixRow=o,e.data=l,e.dataset.groupId=n[h.ID],Array.from(e.cells).forEach(e=>{e.dataset.row=r;let t=Array.from(e.children).find(e=>e.tagName.toLowerCase().startsWith(`cell-`)||typeof e.refresh==`function`);t!==void 0&&typeof t.refresh==`function`&&t?.refresh()})};#h=(e,t,n,r)=>{let i=this.#n.templateLength||1,a=parseInt(e.dataset.subrow,10)||0,o=r*i+a;e.dataset.index=r,e.dataset.row=n,e.dataset.matrixRow=o,e.data=t,Array.from(e.cells).forEach(e=>{e.dataset.index=r,e.dataset.row=n,Array.from(e.children).find(e=>e.tagName.toLowerCase().startsWith(`cell-`)&&typeof e.refresh==`function`)?.refresh()})};initialize=()=>{this.#d=!!this.#n.sourceTable.querySelector(`tbody tr[grouping='true']`),this.#o=null,this.#i.clear(),this.#r={scrollTables:this.#n.querySelectorAll(`.ng-sheet-body table`),firstTr:this.#n.querySelector(`.ng-sheet-body .ng-container-body tbody.body tr`)},[`.ng-container-body`,`.ng-container-left`,`.ng-container-right`].forEach(e=>{let t=this.#n.querySelector(`.ng-sheet-body ${e}`);if(!t)return;let n=t.querySelector(`table`);if(!n)return;let r=n.querySelector(`tbody.body`);if(!r)return;let i=Array.from(r.querySelectorAll(`tr`)).map(e=>e.cloneNode(!0));this.#i.set(e,i)});let e=this.#n.querySelector(`.ng-sheet-body`);e&&(this.#c=e.clientHeight,this.#g(),this.#v(),this.#f(e.scrollTop,!0),e.addEventListener(`scroll`,t=>{if(this.#u)return;let n=this.#o||0;(this.#n.view.getArray()?.length||0)*n<=e.clientHeight||(this.#f(e.scrollTop),this.#n.querySelector(`nine-table-vscrollbar`).refresh())},{passive:!0}))};scrollToDataRow(e,t=`top`,n){let r=this.#n.querySelector(`.ng-sheet-body`),i=this.#n.view.getArray()?.length||0,a=Math.max(0,Math.min(e,i-1)),o=0;if(this.#d){let e=Math.max(r.scrollHeight-r.clientHeight,1);o=a/Math.max(i-1,1)*e}else{let e=this.#o,t=a*e,n=(this.#n.elements.body.thead?.offsetHeight||0)+(this.#n.elements.body.tfoot?.offsetHeight||0)+this.#n.elements.body.tbody.head.offsetHeight,s=r.offsetHeight||0,c=Math.max(i*e+n-s,0),l=15e6,u=c>l,d=1;u&&(d=l/c),o=t*d}this.#u=!0,r.scrollTop=o,this.#f(o),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#u=!1,typeof n==`function`&&n()})})}destroy=()=>{this.#s&&=(this.#s.disconnect(),null)};#g=()=>{if(!this.#n.classList.contains(`active`)||!this.#n.sourceTable)return;let e=this.#n.sourceTable?.querySelectorAll(`tbody.body tr`),t=this.#n.querySelector(`.ng-sheet-body .ng-container-body tbody.body`);t.querySelectorAll(`tr`).forEach(e=>e.remove());let n=document.createDocumentFragment();e.forEach(e=>n.appendChild(e.cloneNode(!0))),t.appendChild(n);let r=t.querySelectorAll(`tr`);this.#a=[],r.forEach(e=>{this.#a.push(Math.max(e.offsetHeight,24))}),r.forEach(e=>e.remove()),this.#o=this.#a.reduce((e,t)=>e+t,0),this.#_()};#_=()=>{if(this.#c>0&&this.#o>0){let e=Math.ceil(this.#c/this.#o),t=this.#e;if(this.#d&&this.#n.grouping){let e=this.#n.grouping.columns?.length||1;t+=e*15}this.#l=e+t}};#v=()=>{[`.ng-container-body`,`.ng-container-left`,`.ng-container-right`].forEach(e=>{let t=this.#n.querySelector(`.ng-sheet-body ${e}`);t&&t.querySelector(`tbody`)&&this.#y(t)}),this.#b()};#y=e=>{let t=null;e.classList.contains(`ng-container-left`)?t=`left`:e.classList.contains(`ng-container-right`)&&(t=`right`);let n=Array.from(this.#n.sourceTable.querySelectorAll(`tbody.body tr`)).map(e=>{let n=e.cloneNode(!0);return t===`left`?n.querySelectorAll(`th,td`).forEach(e=>{e.getAttribute(`fixed`)!==`left`&&e.remove()}):t===`right`?n.querySelectorAll(`th,td`).forEach(e=>{e.getAttribute(`fixed`)!==`right`&&e.remove()}):n.querySelectorAll(`[fixed=left], [fixed=right]`).forEach(e=>{e.remove()}),n});if(n.length===0)return;let r=e.querySelector(`tbody.body`);if(!r)return;r.querySelectorAll(`tr`).forEach(e=>e.remove());let i=document.createDocumentFragment();for(let e=0;e<this.#l;e++)n.forEach(e=>i.appendChild(e.cloneNode(!0)));r.appendChild(i),e.classList.contains(`ng-container-body`)&&(this.#r.firstTr=r.querySelector(`tr`))};#b=()=>{let e=this.#n.querySelector(`.ng-sheet-body .ng-container-left table`),t=this.#n.querySelector(`.ng-sheet-body .ng-container-body table`),n=this.#n.querySelector(`.ng-sheet-body .ng-container-right table`);if(t){let r=e?Array.from(e.querySelectorAll(`tbody tr`)):[],i=Array.from(t.querySelectorAll(`tbody tr`)),a=n?Array.from(n.querySelectorAll(`tbody tr`)):[],o=Math.max(r.length,i.length,a.length);for(let e=0;e<o;e++){let t=[r[e]?.getBoundingClientRect().height||0,i[e]?.getBoundingClientRect().height||0,a[e]?.getBoundingClientRect().height||0],n=Math.max(...t);n>0&&(r[e]&&(r[e].style.height=`${n}px`),i[e]&&(i[e].style.height=`${n}px`),a[e]&&(a[e].style.height=`${n}px`))}}};#x=()=>{this.#n&&this.#n instanceof HTMLElement&&(this.#s=new ResizeObserver(e=>{for(let t of e){if(!t.target.classList.contains(`active`))continue;let e=t.contentRect.height;t.contentRect.width>0&&this.#n.isAutoFitCol&&this.#n.autoFit(!0),e>0&&this.#c!==e&&(this.#c=e,this.#_(),this.#o!==null&&(this.#v(),this.refresh()))}}),this.#s.observe(this.#n))}},y=class e{static compile(t){let n=t.cloneNode(!0);return e.resetColIndex(n,n.querySelectorAll(`thead tr`)),e.resetColIndex(n,n.querySelectorAll(`tbody.body tr[grouping="true"]`)),e.resetColIndex(n,n.querySelectorAll(`tbody.body tr:not([grouping="true"])`)),e.resetColIndex(n,n.querySelectorAll(`tfoot tr`)),e.#e(n),n}static recompile(t){return e.resetColIndex(t,t.querySelectorAll(`thead tr`)),e.resetColIndex(t,t.querySelectorAll(`tbody.body tr[grouping="true"]`)),e.resetColIndex(t,t.querySelectorAll(`tbody.body tr:not([grouping="true"])`)),e.resetColIndex(t,t.querySelectorAll(`tfoot tr`)),e.#e(t),t}static#e(e){e.querySelectorAll(`colgroup col`).forEach((t,n)=>{t.setAttribute(`data-col`,n);let r=t.getAttribute(`fixed`);e.querySelectorAll(`[data-col="${n}"]`).forEach(e=>{r?e.setAttribute(`fixed`,r):e.removeAttribute(`fixed`)})})}static resetColIndex(e,t){let n=e.querySelectorAll(`colgroup col`),r=Array.from({length:t.length},()=>Array(n.length).fill(null));t.forEach((e,i)=>{e.dataset.subrow=i;let a=0;e.querySelectorAll(`th, td`).forEach(e=>{for(;a<n.length&&r[i][a]!==null;)a++;e.dataset.col=a;let o=e.rowSpan||1,s=e.colSpan||1;for(let c=0;c<o;c++)for(let o=0;o<s;o++)i+c<t.length&&a+o<n.length&&(r[i+c][a+o]=e);a+=s})})}},b=class{#e;#t={startRow:-1,startCol:-1,endRow:-1,endCol:-1};constructor(e){this.#e=e,this.#r()}#n(e){if(!e)return{dataRow:-1,subRowIndex:-1,matrixRow:-1};let t=parseInt(e.dataset.index,10);if(isNaN(t))return{dataRow:-1,subRowIndex:-1,matrixRow:-1};let n=e.closest(`tbody`),r=Array.from(n.querySelectorAll(`tr`)).filter(e=>parseInt(e.dataset.index,10)===t),i=r.indexOf(e),a=r.length>0?r.length:1;return{dataRow:t,subRowIndex:i,matrixRow:t*a+(i>=0?i:e.sectionRowIndex%a)}}setFocus(e,t){this.#e.querySelectorAll(`tr.selected-start`).forEach(e=>{e.classList.remove(`selected-start`),e.querySelectorAll(`td.selected-start`).forEach(e=>{e.classList.remove(`selected-start`)})});let n=this.#e.querySelector(`.ng-sheet-body-content tr[data-matrix-row="${e}"] td[data-col="${t}"]`);n&&(n.classList.add(`selected-start`),n.closest(`tr`)?.classList.add(`selected-start`))}setRange(e,t,n,r){let i=Math.min(e,n),a=Math.max(e,n),o=Math.min(t,r),s=Math.max(t,r),c=this.#e.querySelectorAll(`.ng-container-left, .ng-container-body, .ng-container-right`),l=!0,u=0;for(;l&&u<5;)l=!1,u++,c.forEach(e=>{Array.from(e.querySelectorAll(`tbody tr`)).filter(e=>e.style.display!==`none`).forEach(e=>{let{matrixRow:t}=this.#n(e);t<0||e.querySelectorAll(`td, th`).forEach(e=>{let n=parseInt(e.dataset.col,10);if(isNaN(n))return;let r=parseInt(e.rowSpan||1,10),c=parseInt(e.colSpan||1,10),u=t+r-1,d=n+c-1;if(u>=i&&t<=a&&d>=o&&n<=s){let e=Math.min(i,t),r=Math.max(a,u),c=Math.min(o,n),f=Math.max(s,d);(e!==i||r!==a||c!==o||f!==s)&&(i=e,a=r,o=c,s=f,l=!0)}})})});this.#t={startRow:i,startCol:o,endRow:a,endCol:s},this.render()}get minRow(){return this.#t.startRow}get maxRow(){return this.#t.endRow}get minCol(){return this.#t.startCol}get maxCol(){return this.#t.endCol}refresh=()=>{this.render()};render=()=>{let{startRow:e,startCol:t,endRow:n,endCol:r}=this.#t,i=this.#e.querySelectorAll(`.ng-container-left, .ng-container-body, .ng-container-right`);i.forEach(e=>{e.querySelectorAll(`.selected, .selected-top, .selected-bottom, .selected-left, .selected-right, .selected-start`).forEach(e=>{e.classList.remove(`selected`,`selected-top`,`selected-bottom`,`selected-left`,`selected-right`,`selected-start`)}),e.querySelectorAll(`tr.selected-start`).forEach(e=>{e.classList.remove(`selected-start`)})}),e<0||t<0||i.forEach(i=>{Array.from(i.querySelectorAll(`tbody tr`)).filter(e=>e.style.display!==`none`).forEach(i=>{let{matrixRow:a}=this.#n(i);a<0||(a>=e&&a<=n&&i.classList.add(`selected`),i.querySelectorAll(`td, th`).forEach(i=>{let o=parseInt(i.dataset.col,10);if(isNaN(o))return;let s=parseInt(i.rowSpan||1,10),c=parseInt(i.colSpan||1,10),l=a+s-1,u=o+c-1;l>=e&&a<=n&&u>=t&&o<=r&&(i.classList.add(`selected`),a<=e&&i.classList.add(`selected-top`),l>=n&&i.classList.add(`selected-bottom`),o<=t&&i.classList.add(`selected-left`),u>=r&&i.classList.add(`selected-right`))}))})})};#r(){let e=this.#e.querySelector(`.ng-sheet-body`);e&&e.addEventListener(`mousedown`,e=>{if(e.button!==0)return;let t=e.target.closest(`td, th`);if(!t||t.dataset.row===void 0||t.dataset.col===void 0)return;this.#e.style.userSelect=`none`,this.#e.style.webkitUserSelect=`none`;let n=t.closest(`tr`),{matrixRow:r}=this.#n(n),i=parseInt(t.dataset.col,10);if(r<0){this.#e.style.userSelect=``,this.#e.style.webkitUserSelect=``;return}this.setFocus(r,i),this.setRange(r,i,r,i);let a=r,o=i,s=e=>{let t=document.elementFromPoint(e.clientX,e.clientY)?.closest(`td, th`);if(!t||!this.#e.contains(t)){let n=this.#e.querySelectorAll(`.ng-sheet-body-content tbody tr td, .ng-sheet-body-content tbody tr:not(.nodata) th`);for(let r of n){let n=r.getBoundingClientRect();if(e.clientX>=n.left&&e.clientX<=n.right&&e.clientY>=n.top&&e.clientY<=n.bottom){t=r;break}}}if(!t||t.dataset.row===void 0||t.dataset.col===void 0)return;let n=t.closest(`tr`),{matrixRow:s}=this.#n(n),c=parseInt(t.dataset.col,10);s<0||(a!==s||o!==c)&&(a=s,o=c,this.setRange(r,i,s,c))},c=()=>{this.#e.style.userSelect=``,this.#e.style.webkitUserSelect=``,document.removeEventListener(`mousemove`,s),document.removeEventListener(`mouseup`,c)};document.addEventListener(`mousemove`,s),document.addEventListener(`mouseup`,c)})}},x=class{#e;#t;#n=null;#r=null;constructor(e){this.#e=e,this.#t=e.getRootNode().host,this.#g()}get currentCell(){return this.#n}set currentCell(e){if(!e)return;this.#n=e,e.focus({preventScroll:!0}),this.#r=e.closest(`tr`);let t=parseInt(this.#r.dataset.matrixRow,10);this.#e.selection.setFocus(t,this.#n.dataset.col)}#i=(e,t)=>{if(t){switch(e.code){case`Tab`:e.shiftKey?this.#p(t)||t.scrollIntoView({inline:`nearest`,block:`nearest`}):this.#m(t)||t.scrollIntoView({inline:`nearest`,block:`nearest`});break;case`ArrowRight`:this.#m(t)||t.scrollIntoView({inline:`nearest`,block:`nearest`});break;case`ArrowLeft`:this.#p(t)||t.scrollIntoView({inline:`nearest`,block:`nearest`})}this.currentCell=t,this.#e.selection.setRange(this.#r.dataset.matrixRow,t.dataset.col,this.#r.dataset.matrixRow,t.dataset.col)}};#a=(e,t)=>{if(t){let n=!1;switch(e.code){case`Enter`:e.shiftKey,this.#f(t)&&(n=!0);break;case`ArrowDown`:this.#f(t)&&(n=!0);break;case`ArrowUp`:this.#d(t)&&(n=!0)}if(n){this.currentCell=t,this.#e.selection.setRange(this.#r.dataset.matrixRow,t.dataset.col,this.#r.dataset.matrixRow,t.dataset.col);return}}let n=parseInt(this.#r.dataset.index,10),r=-1;switch(e.code){case`Enter`:if(e.shiftKey){let e=this.#h();r=Math.max(n-e+0,0)}else r=Math.min(n,this.#e.view.count());break;case`ArrowDown`:r=Math.min(n,this.#e.view.count());break;case`ArrowUp`:let t=this.#h();r=Math.max(n-t+0,0)}if(r<0)return;let i=parseInt(this.#r.dataset.matrixRow,10),a=parseInt(this.#n.dataset.col,10),o=parseInt(this.#n.rowSpan,10)||1;switch(e.code){case`ArrowDown`:i+=o;break;case`ArrowUp`:i--}this.#e.rowManager.scrollToDataRow(r,null,()=>{let e=this.#c(i,a);e&&(this.currentCell=e,this.#e.selection.setRange(this.#r.dataset.matrixRow,e.dataset.col,this.#r.dataset.matrixRow,e.dataset.col))})};moveCell=e=>{if(e.target.tagName===`INPUT`&&([`text`].includes(e.target.type)&&[`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.code)||[`date`,`datetime-local`,`time`,`week`,`month`].includes(e.target.type))||!this.#n||!this.#r)return;let t;switch(e.code){case`Tab`:t=e.shiftKey?this.#s():this.#o();break;case`ArrowRight`:t=this.#o();break;case`ArrowLeft`:t=this.#s();break;case`Enter`:t=e.shiftKey?this.#l():this.#u();break;case`ArrowDown`:t=this.#u();break;case`ArrowUp`:t=this.#l()}e.preventDefault(),[`ArrowLeft`,`ArrowRight`,`Tab`].includes(e.code)?this.#i(e,t):[`Enter`,`ArrowUp`,`ArrowDown`].includes(e.code)&&this.#a(e,t)};#o=()=>{let e=parseInt(this.#n.dataset.col,10),t=parseInt(this.#n.colSpan,10)||1,n=parseInt(this.#r.dataset.index,10),r=parseInt(this.#r.dataset.matrixRow,10),i=e+t,a=this.#e.querySelector(`tbody tr[data-matrix-row="${r}"] td[data-col="${i}"]`);return a||=this.#e.querySelector(`tbody tr[data-index="${n}"] td[data-col="${i}"]`),a};#s=()=>{let e=parseInt(this.#n.dataset.col,10),t=parseInt(this.#r.dataset.index,10),n=parseInt(this.#r.dataset.matrixRow,10),r;for(let i=e-1;i>=0&&(r=this.#e.querySelector(`tbody tr[data-matrix-row="${n}"] td[data-col="${i}"]`),r||=this.#e.querySelector(`tbody tr[data-index="${t}"] td[data-col="${i}"]`),!r);i--);return r};#c=(e,t)=>{let n=this.#e.querySelector(`tbody tr[data-matrix-row="${e}"]`);if(!n)return;let r=parseInt(n.dataset.index,10),i=this.#e.querySelector(`tbody tr[data-matrix-row="${e}"] td[data-col="${t}"]`);return i||(this.#e.querySelectorAll(`tbody tr[data-matrix-row="${e}"] td`).forEach(e=>{let n=parseInt(e.dataset.col,10),r=parseInt(e.colSpan,10)||1;t>=n&&t<n+r&&(i=e)}),i||(i=this.#e.querySelector(`tbody tr[data-index="${r}"] td[data-col="${t}"]`),i||this.#e.querySelectorAll(`tbody tr[data-index="${r}"] td`).forEach(e=>{let n=parseInt(e.dataset.col,10),r=parseInt(e.colSpan,10)||1;t>=n&&t<n+r&&(i=e)}))),i};#l=()=>{let e=parseInt(this.#n.dataset.col,10),t=parseInt(this.#r.dataset.matrixRow,10);return this.#c(t-1,e)};#u=()=>{let e=parseInt(this.#n.dataset.col,10),t=parseInt(this.#r.dataset.matrixRow,10),n=parseInt(this.#n.rowSpan,10)||1;return this.#c(t+n,e)};#d=e=>{let t=this.#e.querySelector(`.ng-sheet-body`);if(!t||!e)return!0;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=t.querySelector(`thead`)?.offsetHeight||0;return n.top>=r.top+i};#f=e=>{let t=this.#e.querySelector(`.ng-sheet-body`);if(!t||!e)return!0;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.bottom<=r.bottom};#p=e=>{let t=this.#e.querySelector(`.ng-container-body`);if(!t||!e)return!0;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.left>=r.left};#m=e=>{let t=this.#e.querySelector(`.ng-container-body`);if(!t||!e)return!0;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.right<=r.right};#h=()=>{let e=this.#e.querySelector(`.ng-sheet-body`),t=e.clientHeight-(e.querySelector(`thead`)?.offsetHeight||0),n=this.#e.rowManager.getRowHeight();return Math.max(1,Math.floor(t/n))};#g(){this.#e.addEventListener(`mousedown`,e=>{if(e.button!==0)return;let t=e.target.closest(`td, th`);t&&t.dataset.index!==void 0&&t.dataset.col!==void 0&&(this.currentCell=t)}),this.#e.addEventListener(`keydown`,e=>{[`Enter`,`Tab`,`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`].includes(e.code)&&this.moveCell(e)})}},S=2,C=class{#e;#t;#n;#r;#i=null;#a=null;#o=null;#s=null;#c=0;#l=0;#u=0;#d=0;#f=0;constructor(e){this.#e=e,this.#t=e.getRootNode().host,this.#n=this.#e.querySelector(`nine-table-col-resizer-panel`),this.#r=this.#n.querySelector(`.resizer-overlay`),this.bindEvents()}destroy(){this.#e.removeEventListener(`pointermove`,this.#h),this.#e.removeEventListener(`pointerdown`,this.#g),this.#e.removeEventListener(`dblclick`,this.#b)}refreshLayout(e=`body`){let t=Array.from(this.#e.querySelectorAll(`.ng-container-${e}`));if(t.length!==0){if(e===`left`||e===`right`||!this.#e.isAutoFitCol&&t[0].querySelector(`table`)?.getAttribute(`auto-fit-col`)!==`true`){let n=t[0].querySelector(`table colgroup`);if(!n)return;let r=0,i={};Array.from(n.querySelectorAll(`col`)).forEach(e=>{let t=e.getAttribute(`data-col`),n=parseInt(e.getAttribute(`width`),10);isNaN(n)||(i[t]=n,r+=n)}),t.forEach(t=>{let n=t.querySelectorAll(`table`);e===`body`?n.forEach(e=>{e.style.width=`${r}px`}):(t.style.flex=`0 0 ${r}px`,t.style.width=`${r}px`,t.style.minWidth=`${r}px`,t.style.maxWidth=`${r}px`,n.forEach(e=>{e.style.width=`${r}px`,e.style.minWidth=`${r}px`,e.style.maxWidth=`${r}px`,Object.entries(i).forEach(([t,n])=>{e.querySelectorAll(`th[data-col="${t}"], td[data-col="${t}"]`).forEach(e=>{e.style.width=`${n}px`,e.style.minWidth=`${n}px`,e.style.maxWidth=`${n}px`})})}))})}else t.forEach(e=>{e.querySelectorAll(`table`).forEach(e=>{})});this.#e.querySelector(`nine-table-hscrollbar`)?.refresh()}}setColumnWidth(e,t,n=null){let r=[];if(r=Array.from(this.#e.querySelectorAll(`table colgroup col[data-col="${e}"]`)),r.length===0)return;let i=r[0].closest(`.ng-container-left, .ng-container-body, .ng-container-right`),a=n||(i?.classList.contains(`ng-container-left`)?`left`:i?.classList.contains(`ng-container-right`)?`right`:`body`);r.forEach(e=>{e.setAttribute(`width`,t),e.style.width=`${t}px`});let o=this.#e.sourceTable?.querySelector(`colgroup col[data-col="${e}"]`);o&&(o.setAttribute(`width`,t),o.style.width=`${t}px`),this.refreshLayout(a),(a===`left`||a===`right`)&&this.refreshLayout(`body`),this.#e.rowManager?.refresh()}#p(e){if(this.#e.isAutoFitCol)return!0;let t=e?.closest(`table`);return!!(t&&t.getAttribute(`auto-fit-col`)===`true`)}bindEvents(){this.#e.addEventListener(`pointermove`,this.#h),this.#e.addDebounseEventListener(`dblclick`,this.#b,`pointerdown`,this.#g)}#m(e){let t=e.closest(`.ng-container-left, .ng-container-body, .ng-container-right`);return t?t.classList.contains(`ng-container-left`)?`left`:t.classList.contains(`ng-container-right`)?`right`:`body`:null}#h=e=>{let t=e.target.closest(`thead`);if(!t)return;let n=e.target.closest(`th, td`);if(t.querySelectorAll(`.resizable-edge`).forEach(e=>{e!==n&&e.classList.remove(`resizable-edge`)}),!n||n.dataset.col===void 0||n.getAttribute(`collapsed`)===`true`)return;let r=n.getBoundingClientRect(),i=e.clientX-r.left,a=i<=S,o=r.width-i<=S;if(a){let e=n.previousElementSibling;if(!e||e.getAttribute(`collapsed`)===`true`){n.classList.remove(`resizable-edge`);return}}a||o?n.classList.add(`resizable-edge`):n.classList.remove(`resizable-edge`)};#g=e=>{if(!e.actualTarget.closest(`thead`))return;let t=e.actualTarget.closest(`th, td`);if(!t||!t.classList.contains(`resizable-edge`))return;e.preventDefault();let n=t.getBoundingClientRect(),r=e.clientX-n.left,i=t;if(r<=S){let e=t.previousElementSibling;if(e&&e.dataset.col!==void 0&&e.getAttribute(`collapsed`)!==`true`)i=e;else if(!t.previousElementSibling)return}this.#s=i,this.#o=this.#m(i);let a=this.#e.querySelector(`.ng-container-${this.#o}`);if(!a)return;let o=parseInt(i.dataset.col,10),s=i.colSpan||1;if(this.#i=o+s-1,this.#p(i)){this.#a=this.#i+1;let e=a.querySelector(`col[data-col="${this.#a}"]`);e?this.#u=parseInt(e.getAttribute(`width`),10)||100:this.#a=null}else this.#a=null;let c=i.getBoundingClientRect(),l=this.#e.getBoundingClientRect();this.#d=c.width,this.#f=c.left-l.left;let u=a.querySelector(`col[data-col="${this.#i}"]`)?.getAttribute(`width`);this.#l=u&&!isNaN(parseInt(u,10))?parseInt(u,10):c.width/s,this.#c=e.clientX,this.#n&&(this.#n.classList.add(`active`),this.#_(e.clientX)),window.addEventListener(`pointermove`,this.#v),window.addEventListener(`pointerup`,this.#y,{once:!0})};#_(e){let t=e-this.#c,n=this.#p(this.#s);if(n&&this.#a!==null){let e=this.#u-16,n=-(this.#l-16);t=Math.max(n,Math.min(t,e))}let r=Math.max(16,this.#l+t),i=e-this.#s.getBoundingClientRect().left;if(n&&this.#a!==null){let e=this.#d+(this.#u-16);i=Math.min(i,e)}let a=Math.max(16,i);this.#n&&(this.#n.style.setProperty(`--col-resizer-tooltip-left`,`${this.#f}px`),this.#n.style.setProperty(`--col-resizer-tooltip-width`,`${a}px`));let o=this.#r?.querySelector(`.size-badge`);o&&(o.textContent=`${Math.round(r)}px`)}#v=e=>{this.#_(e.clientX)};#y=e=>{window.removeEventListener(`pointermove`,this.#v);let t=e.clientX-this.#c,n=this.#p(this.#s),r=0;if(n&&this.#a!==null){let e=Math.max(16,this.#l+t),n=this.#l+this.#u-e;n<16&&(n=16,e=this.#l+this.#u-16),this.setColumnWidth(this.#i,e,this.#o),this.setColumnWidth(this.#a,n,this.#o),r=e}else{let e=Math.max(16,this.#l+t);this.#i!==null&&this.#o&&(this.setColumnWidth(this.#i,e,this.#o),r=e)}if(this.#s){let e=this.#s;e.getAttribute(`collapsed`)!==`true`&&r>20&&(e.dataset.expandWidth=String(r))}this.#n&&(this.#r?.classList.add(`fade-out`),setTimeout(()=>{this.#n.classList.remove(`active`),this.#r?.classList.remove(`fade-out`)},150)),this.#i=null,this.#a=null,this.#o=null,this.#s=null};#b=e=>{let t=e.target.closest(`th, td`);if(!t||!t.classList.contains(`resizable-edge`))return;let n=t.getBoundingClientRect();e.clientX-n.left<=S&&(t=t.previousElementSibling);let r=parseInt(t.dataset.col,10),i=this.#e.querySelector(`tbody.body [data-col="${r}"]`);if(!i||!i.dataset.bind||i.classList.contains(`CELL-RADIO`))return;let a=0;Array.from(i.firstElementChild.children).forEach(e=>{switch(e.tagName){case`SPAN`:a+=8;break;case`DIV`:a+=8;break;case`BUTTON`:a+=32;break;case`SELECT`:a+=32;break;case`INPUT`:switch((e.type||`text`).toLowerCase()){case`checkbox`:case`radio`:a+=12;break;case`button`:case`submit`:case`reset`:case`image`:a+=16;break;case`color`:case`file`:case`range`:a+=24;break;case`hidden`:a+=0;break;default:a+=16}}});let o=this.#t.fields.get().indexOf(i.dataset.bind),s=window.getComputedStyle(i).font||`12px sans-serif`,c=t.innerText||``,l=(nine.measureTextSize(c,s).width||0)+16;this.#t.execute(()=>{this.#e.view.getArray().forEach((e,t)=>{let n=String(i.dataset.expr?this.#t.exprEngine.evaluate(i.dataset.expr,e,t):e.v[o]??``).trim(),r=nine.measureTextSize(n,s);r.width&&r.width>l&&(l=r.width)});let e=Math.max(32,Math.min(400,Math.ceil(l)+a));this.setColumnWidth(i.dataset.col,e,this.#m(t))})}},w=class extends HTMLElement{constructor(){super()}connectedCallback(){this.#e()}#e=()=>{this.innerHTML=`
27
27
  <div class="resizer-overlay">
28
28
  <span class="size-badge">0px</span>
29
29
  </div>
@@ -55,7 +55,7 @@
55
55
  </div>
56
56
  </div>
57
57
  </div>
58
- `};open(e){this.#i=e;let t=e.closest(`th, td`);this.currentCol=t?.dataset.col;let n=t.getBoundingClientRect(),r=this.#e.getBoundingClientRect(),i=this.offsetWidth||240,a=n.right-r.left-i,o=n.bottom-r.top;a<0&&(a=Math.max(0,n.left-r.left)),this.style.left=`${a}px`,this.style.top=`${o}px`;let s=this.querySelector(`.search-box`);s.value=``,this.classList.add(`active`),this.classList.add(`loading`),setTimeout(()=>{try{this.#c(),this.#r.rowManager.scrollToDataRow(0),s.focus()}finally{this.classList.remove(`loading`)}})}#s=e=>{let t=e.composedPath?e.composedPath():[];t.includes(this)||this.#i&&t.includes(this.#i)||this.close()};close(){this.currentCol=null,this.classList.remove(`active`),this.#i=null}#c(){let e=this.#t.data.getArray(),t=this.#i?.columns||[],n=this.#t.fields.get()||[],r=this.#e.filtering?.filters||{},i=this.#t.exprEngine,a=t.flatMap(t=>{let a=t.bind,o=t.expr,s=a||o,c=a?n.indexOf(a):-1,l=r[s]||[],u=new Map;for(let t=0;t<e.length;t++){let n=e[t];if(!n)continue;let r;c>=0&&n.v?r=n.v[c]:a&&a.includes(`data.`)?r=i?i.evaluate(a,n,t):void 0:o&&i&&(r=i.evaluate(o,n,t));let s=r;o&&i&&(s=i.evaluate(o,n,t)),s!=null&&!u.has(s)&&u.set(s,{v:r,v2:s})}let d=[...u.values()];return d.sort((e,t)=>{let n=e.v2,r=t.v2;if(n===r)return 0;if(n==null||n===``)return 1;if(r==null||r===``)return-1;let i=Number(n),a=Number(r);return!isNaN(i)&&!isNaN(a)?i-a:String(n).localeCompare(String(r))}),l.sort((e,t)=>e>t?1:-1),d.map(e=>({LVL:2,DATA:e.v,DATA2:e.v2===``||e.v2===null||e.v2===void 0?`<span class="empty-value">(empty)</span>`:e.v2,COLNM:s,CHK:l.length===0||l.nineBinarySearch(e.v)>=0?`Y`:`N`}))});this.#n.data.set(a);let o=this.querySelector(`#chkSelectAll`);o&&(o.checked=a.length>0&&a.every(e=>e.CHK===`Y`))}#l=()=>{this.#t.loading=!0;let e=this.#r.view.getArray(),t=this.#n.data.getHostFields(),n=e.filter(e=>{let n=e.v[t.indexOf(`CHK`)];return n===`Y`||n===!0}),r={...this.#e.filtering?.filters||{}};this.#i.columns.forEach(e=>{let i=e.expr||e.bind,a=e.expr?t.indexOf(`DATA2`):t.indexOf(`DATA`),o=n.map(e=>e.v[a]);o.length>0?r[i]=o:delete r[i]});let i=this.#n.data.count();setTimeout(()=>{try{i===n.length?this.#i.columns.forEach(e=>{let t=e.expr||e.bind;t&&this.#e.filtering.clear(t)}):this.#e.filtering.set(r),this.#e.querySelectorAll(`nine-table-filter-button`).forEach(e=>{e.updateFilteredState()}),this.#e.invalidate(),this.close()}finally{this.#t.loading=!1}})};#u=e=>{let t=e.target.value.toLowerCase().trim();if(!t)this.#r.filtering.clear();else{let e=this.#n.data.getArray(),n=this.#n.data.getHostFields().indexOf(`DATA2`),r=[];e.forEach(e=>{let i=n>=0&&e.v?e.v[n]:``;String(i).replace(/<[^>]*>?/gm,``).toLowerCase().includes(t)&&r.push(i)}),this.#r.filtering.set({DATA2:[...new Set(r)]})}};#d=e=>{let t=e.target.checked,n=this.#n?.data?.getArray()||[],r=this.#n.data.getHostFields().indexOf(`CHK`);r>=0&&n.forEach(e=>{e.v[r]=t?`Y`:`N`}),this.#n.refresh()}},O=class extends HTMLElement{#e;#t=null;connectedCallback(){this.#e=this.closest(`nine-table-sheet`)||this.getRootNode().host,this.removeEventListener(`click`,this.#n),this.addEventListener(`click`,this.#n)}get columns(){if(this.#t)return this.#t;let e=this.closest(`th, td`)?.dataset.col,t=this.#e.sourceTable,n=[],r=new Set;return t&&e!==void 0&&t.querySelectorAll(`tbody [data-col="${e}"]`).forEach(e=>{let t=e.dataset.bind,i=e.dataset.expr;if(t||i){let e=`${t||``}_${i||``}`;r.has(e)||(r.add(e),n.push({bind:t,expr:i}))}}),this.#t=n,this.#t}updateFilteredState=()=>{let e=this.#e.filtering?.filters||{},t=this.columns.some(t=>{let n=t.expr||t.bind;return n&&e[n]&&e[n].length>0});this.classList.toggle(`filtered`,t)};#n=e=>{e.preventDefault(),e.stopPropagation();let t=this.#e.querySelector(`nine-table-filter-panel`),n=this.closest(`th, td`).dataset.col;t&&t.currentCol===n&&t.classList.contains(`active`)?t.close():t&&t.open(this)}},k=class{#e;#t;#n=!1;#r=null;#i={};constructor(e){this.#e=e,this.#t=this.#e.getRootNode().host,this.#a()}get filters(){return this.#i}#a=()=>{this.#o()};#o=()=>{if(this.#t.tagName.toLowerCase()===`nine-table-simple`)return;let e=this.#e.querySelector(`nine-table-filter-panel`);e||(e=document.createElement(`nine-table-filter-panel`),this.#e.appendChild(e)),this.#r=e};isFiltering(){return this.#n}clear=e=>{e?delete this.#i[e]:this.#i={},this.#n=Object.keys(this.#i).length>0,this.#s(),this.#e.querySelectorAll(`nine-table-filter-button`).forEach(e=>{e.updateFilteredState()})};set=e=>{let t=Array.isArray(e)?Object.fromEntries(Object.keys(e[0]).map(t=>[t,[...new Set(e.map(e=>e[t]))]])):e;this.#i=t,this.#n=Object.keys(t).length>0,this.#e.toggleAttribute(`filtering`,this.#n),this.#s()};#s(){let e=this.#t.data.getArray(),t=this.#t.data.getHostFields(),n=this.#e.index,r=this.#t.exprEngine;if(!(Object.keys(this.#i).length>0)){e.forEach(e=>{e?.m?._?.[i.META.INDEX.FILTER]&&(e.m._[i.META.INDEX.FILTER][n]=!0)}),this.#e.invalidate();return}let a=Object.entries(this.#i).map(([e,n])=>{let r=e.includes(`data.`)||e.includes(`host.`)||e.includes(`rowItem.v`);return{targetKey:e,isExpr:r,fieldIdx:r?-1:t.indexOf(e),allowedSet:new Set(n)}});e.forEach((e,t)=>{if(!e)return;e.m._[i.META.INDEX.FILTER]||(e.m._[i.META.INDEX.FILTER]=[]);let o=!0;for(let n=0;n<a.length;n++){let{targetKey:i,isExpr:s,fieldIdx:c,allowedSet:l}=a[n],u;if(s&&r?u=r.evaluate(i,e,t):c>=0&&e.v&&(u=e.v[c]),!l.has(u)){o=!1;break}}e.m._[i.META.INDEX.FILTER][n]=o}),this.#e.invalidate()}};customElements.get(`nine-table-filter-panel`)||customElements.define(`nine-table-filter-panel`,D),customElements.get(`nine-table-filter-button`)||customElements.define(`nine-table-filter-button`,O);var A=class{#e;#t;#n=[];constructor(e){this.#e=e,this.#t=e.getRootNode().host,setTimeout(()=>{this.#r()},300)}#r(){this.#e.querySelectorAll(`thead`).forEach(e=>{e.addEventListener(`dblclick`,e=>{let t=e.target.closest(`th, td`);if(!t||t.classList.contains(`resizable-edge`)||[`INPUT`,`CELL-CHECKBOX`].includes(e.target.tagName)||e.offsetX<=2||e.offsetX>=t.offsetWidth-2)return;let n=this.#e.getRootNode().host;n.loading=!0,setTimeout(()=>{try{this.#i(e,t)}finally{n.loading=!1}})})})}#i(e,t){let n=t.dataset.col,r=t.closest(`tr`),i=r?r.dataset.subrow||String(r.sectionRowIndex):`0`;if(n===void 0)return;let a=this.#e.sourceTable;if(!a)return;let o=null,s=null;if(a.querySelectorAll(`tbody [data-col="${n}"]`).forEach(e=>{e.dataset.bind&&(o=e.dataset.bind),e.dataset.expr&&(s=e.dataset.expr)}),!o&&!s)return;let c=t.classList.contains(`asc`),l=t.classList.contains(`desc`);!e.ctrlKey&&!e.shiftKey&&(this.#n=[]);let u=this.#n.findIndex(e=>e.colIndex===n&&e.subRowIndex===i||e.colName===o),d={colIndex:n,subRowIndex:i,colname:o||s,colName:o||s,expr:s,asc:!0,"expr-func":s?(e,t)=>this.#t.exprEngine(s,e,t):null};!c&&!l?u>=0?this.#n[u].asc=!0:this.#n.push({...d,asc:!0}):c?u>=0?this.#n[u].asc=!1:this.#n.push({...d,asc:!1}):this.#n=this.#n.filter(e=>!(e.colIndex===n&&e.subRowIndex===i||e.colName===o)),this.#a()}#a(){this.#e.view&&(this.#e.view.setSorting(this.#n),this.#o(),this.#e.invalidate())}#o(){this.#e.querySelectorAll(`thead th, thead td`).forEach(e=>{e.classList.remove(`asc`,`desc`)}),this.#n.length!==0&&this.#n.forEach(e=>{let{colIndex:t,subRowIndex:n,asc:r}=e;if(t!==void 0){let e=`thead [data-col="${t}"]`;n!==void 0&&(e=`thead tr[data-subrow="${n}"] [data-col="${t}"]`),this.#e.querySelectorAll(e).forEach(e=>{e.classList.add(r?`asc`:`desc`)})}})}restore(){this.#n=[],this.#e.view&&this.#e.view.resetSorting(),this.#o(),this.#e.rowManager?.refresh(!0)}},j=class{#e;#t;#n=[];#r=[];#i=null;constructor(e){this.#e=e,this.#t=e.getRootNode().host,this.refresh()}getArray=(e,t)=>{if(!this.#i){let e=this.#t.data.getArray();this.#i=this.#r.map(t=>e[t])}let n=this.#i;if(e==null)return n;if(e<0||e>=n.length)return null;let r=n[e];if(t!=null){let e=this.#t.data.getHostFields().indexOf(t);return e>=0&&r.v?r.v[e]:null}return r};count=()=>{if(!this.#i){let e=this.#t.data.getArray();this.#i=this.#r.map(t=>e[t])}return this.#i.length};get=(e,t)=>{let n=this.getArray(),r=this.#t.data.getHostFields?.()||[];if(e==null)return n.map(e=>this.#a(e,r));if(e<0||e>=n.length)return null;let i=n[e];if(!i)return null;if(t!=null){let e=r.indexOf(t);return e>=0&&i.v?i.v[e]:null}return this.#a(i,r)};#a=(e,t)=>{if(!e)return null;let n={};return t.forEach((t,r)=>{n[t]=e.v?e.v[r]:e[t]}),e.m&&(n.m=e.m),e._&&(n._=e._),n};refresh=()=>{this.#i=null;let e=this.#t.data.getArray(),t=[];e.forEach((e,n)=>{if(!e)return;let r=e.m?._?.[i.META.INDEX.FILTER];r&&r[this.#e.index]===!1||t.push(n)}),this.#n.length>0&&(t=this.#o(t,e)),this.#r=t;let n=t.map(t=>e[t]),r=this.#e.grouping?.columns||[];if(r.length>0){let e=_.apply(n,r,this.#t.data.getHostFields());this.#i=e.renderItems,this.#e.grouping.setGroupMap(e.groupMap)}else this.#i=n};setSorting=e=>{this.#n=e||[],this.refresh()};getSorting=()=>this.#n;resetSorting=()=>{this.#n=[],this.refresh()};#o=(e,t)=>{let n=typeof this.#t.data.getHostFields==`function`?this.#t.data.getHostFields():[],r=this.#n.map(e=>({...e,colIndex:n.indexOf(e.colname||e.colName)}));return e.sort((e,n)=>{let i=t[e],a=t[n];for(let t of r){let r=t.asc,o=t.expr,s,c;o?(s=this.#t.exprEngine.evaluate(o,i,e),c=this.#t.exprEngine.evaluate(o,a,n)):t.colIndex>=0&&i.v&&a.v&&(s=i.v[t.colIndex],c=a.v[t.colIndex]);let l=s==null||s===``,u=c==null||c===``;if(!(l&&u)){if(l)return 1;if(u)return-1;if(s!==c){let e=0;if(typeof s==`number`&&typeof c==`number`)e=s-c;else{let t=String(s),n=String(c);e=t>n?1:t<n?-1:0}if(e!==0)return r?e:-e}}}return e-n})}},M=class e{static initializeTable(t,n){return e.#r(n),e.#a(n),e.#n(n),e.#u(n),e.#i(n),y.resetColIndex(n,n.querySelectorAll(`thead tr`)),y.resetColIndex(n,n.querySelectorAll(`tbody.body tr[grouping="true"]`)),y.resetColIndex(n,n.querySelectorAll(`tbody.body tr:not([grouping="true"])`)),y.resetColIndex(n,n.querySelectorAll(`tfoot tr`)),e.#e(n),e.#o(n),e.#s(t,n),e.#l(n),e.#c(t,n),e.#d(n),n}static#e(t){let n=t.querySelector(`thead`);if(!n||n.querySelector(`.col-indicator-rowgroup`))return;let r=n.insertRow(0);r.setAttribute(`role`,`row`),r.classList.add(`col-indicator-rowgroup`),r.classList.add(`collapse`);let i=t.querySelector(`tbody tr`);if(!i)return;let a=0;i.querySelectorAll(`th, td`).forEach(t=>{if(!t.classList.contains(`dummy`)){let n=t.colSpan||1;for(let t=0;t<n;t++){let t=`<th data-col="@col" class="col-indicator" scope="col"></th>`.replace(`@col`,a).replace(`@text`,e.#t(a++));r.insertAdjacentHTML(`beforeend`,t)}}});let o=Array.from(t.querySelectorAll(`colgroup col`));r.querySelectorAll(`.col-indicator`).forEach((e,t)=>{let n=o[t].getAttribute(`background`);n&&(e.style.background=n)})}static#t(e){let t=``;for(let n=e;n>=0;n=Math.floor(n/26)-1)t=String.fromCharCode(65+n%26)+t;return t}static#n(e){let t=e.querySelector(`tbody:not(.head):not(.foot)`);if(t){if(t.classList.add(`body`),!e.querySelector(`tbody.head`)){let e=document.createElement(`tbody`);e.classList.add(`head`),t.before(e)}if(!e.querySelector(`tbody.foot`)){let e=document.createElement(`tbody`);e.classList.add(`foot`),t.after(e)}}}static#r(e){let t=e.querySelector(`colgroup`);if(t||(t=document.createElement(`colgroup`),e.prepend(t)),t.querySelectorAll(`col`).length===0){let n=e.querySelector(`tbody tr`),r=1;n&&(r=Array.from(n.querySelectorAll(`th, td`)).reduce((e,t)=>e+(parseInt(t.getAttribute(`colspan`)||t.colSpan,10)||1),0)),r=Math.max(r,1);for(let e=0;e<r;e++){let e=document.createElement(`col`);t.appendChild(e)}}}static#i(e){let t=Array.from(e.querySelectorAll(`colgroup col`));if(t.length===0)return;let n=e.clientWidth||0,r=Math.max(Math.floor(n/t.length),100);t.forEach((e,t)=>{e.hasAttribute(`data-col`)||e.setAttribute(`data-col`,t);let n=e.getAttribute(`width`)||parseInt(e.style.width,10)||r;e.setAttribute(`width`,n);let i=String(n).includes(`px`)?n:`${n}px`;e.style.width=i})}static#a(e){if(e.querySelector(`thead`))return;let t=document.createElement(`thead`),n=e.querySelector(`colgroup`);n?n.after(t):e.prepend(t)}static#o(e){e.querySelectorAll(`thead th, thead td`).forEach(e=>{e.getAttribute(`collapsed`)===`true`&&e.getAttribute(`collapsible`)!==`true`&&e.setAttribute(`collapsible`,`true`)})}static#s(e,t){let n=[`data-bind`,`data-expr`,`type`],r=0;t.querySelectorAll(`tbody th, tbody td`).forEach(t=>{let i=`cell-${t.getAttribute(`cell-type`)||`renderer`}`,a=t.querySelector(`datalist`);if(a){let n=[];a.querySelectorAll(`option`).forEach(e=>{n.push({k:e.getAttribute(`k`),v:e.getAttribute(`v`),value:e.getAttribute(`value`)})});let i=`__ds_${Date.now()}_${++r}`;e&&(e[i]=()=>n),t.setAttribute(`data-source`,`host.${i}()`),a.remove()}let o=t.dataset.expr;o&&t.setAttribute(`data-expr`,e.exprEngine.precompile(o)),Array.from(t.attributes).forEach(n=>{[`data-bind`,`data-expr`,`cell-type`,`validator`].includes(n.name)||(n.value.includes(`data.`)||n.value.includes(`host.`))&&t.setAttribute(n.name,e.exprEngine.precompile(n.value))}),t.innerHTML=`<${i} ${n.filter(e=>t.hasAttribute(e)).map(e=>`${e}="${t.getAttribute(e)}"`).join(` `)}></${i}>`,t.setAttribute(`tabindex`,`0`)}),t.querySelectorAll(`thead th, thead td, tfoot th, tfoot td`).forEach(e=>{let t=e.getAttribute(`cell-type`);if(t){let r=e.innerHTML,i=`cell-${t}`;e.innerHTML=`<${i} ${n.filter(t=>e.hasAttribute(t)).map(t=>`${t}="${e.getAttribute(t)}"`).join(` `)} content="${r}"></${i}>`}})}static#c(e,t){let n=e.getAttribute(`filtering`)===`true`,r=t.getAttribute(`filtering`)===`true`;t.querySelectorAll(`thead tr:not(.col-indicator-rowgroup) th, thead tr:not(.col-indicator-rowgroup) td`).forEach(e=>{let t=e.getAttribute(`filtering`)===`true`||r||n;e.setAttribute(`filtering`,t?`true`:`false`),t&&e.appendChild(document.createElement(`nine-table-filter-button`))})}static#l(e){e.querySelectorAll(`thead th, thead td`).forEach(t=>{if(t.getAttribute(`collapsible`)!==`true`&&t.getAttribute(`expandable`)!==`true`)return;let n=parseInt(t.dataset.col,10),r=t.colSpan||1,i=e.querySelector(`colgroup col[data-col="${n}"]`),a=i&&parseInt(i.getAttribute(`width`),10)||100;(!t.dataset.expandWidth||parseInt(t.dataset.expandWidth,10)<=16)&&(t.dataset.expandWidth=String(a>16?a:100));let o=t.querySelector(`nine-table-col-expand`);if(o||(o=document.createElement(`nine-table-col-expand`),t.insertBefore(o,t.firstChild)),t.getAttribute(`collapsed`)===`true`){o.classList.add(`collapsed`),o.classList.remove(`expand`),o.setAttribute(`collapsed`,`true`),t.style.color=`transparent`;let i=Math.max(10,Math.floor(16/r));if(!isNaN(n))for(let t=0;t<r;t++){let r=e.querySelector(`colgroup col[data-col="${n+t}"]`);r&&(r.setAttribute(`width`,i),r.style.width=`${i}px`)}}else o.classList.remove(`collapsed`),o.classList.add(`expand`),o.setAttribute(`collapsed`,`false`),t.style.color=``})}static#u(e,t){let n=e.getAttribute(`row-indicator`)===`true`?48:0,r=e.querySelector(`colgroup`),i=document.createElement(`col`);i.setAttribute(`fixed`,`left`),i.setAttribute(`width`,n),i.style.width=`${n}px`,r.prepend(i),e.querySelectorAll(`thead, tbody, tfoot`).forEach(e=>{let t=Array.from(e.querySelectorAll(`tr`));if(t.length===0)return;let n=t[0],r=document.createElement(`th`);r.className=`row-indicator`,r.setAttribute(`cell-type`,`row-indicator`),t.length>1&&(r.rowSpan=t.length),n.insertBefore(r,n.firstElementChild)})}static#d(e){e.querySelectorAll(`th[data-col], td[data-col]`).forEach(t=>{let n=parseInt(t.getAttribute(`data-col`),10);if(isNaN(n))return;let r=parseInt(t.getAttribute(`colspan`)||t.colSpan,10)||1,i=0;for(let t=0;t<r;t++){let r=n+t,a=e.querySelector(`colgroup col[data-col="${r}"]`);a&&(i+=parseInt(a.getAttribute(`width`),10)||100)}if(i>0){let e=`${i}px`;t.style.width=e,t.style.minWidth=e,t.style.maxWidth=e}})}},N=class extends HTMLElement{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f={table:null};#p;static SCROLLBAR_SIZE=16;constructor(){super(),this.#t=this.getRootNode().host,this.#n=new v(this)}connectedCallback(){this.#b()}get index(){return this.#e}get colResizer(){return this.#a}get filtering(){return this.#l}get grouping(){return this.#u}get colMover(){return this.#o}get colFix(){return this.#s}get rowManager(){return this.#n}get selection(){return this.#r}get navigation(){return this.#i}get templateLength(){return this.#f.tbody.tr.length||0}get elements(){return this.#p}get isAutoFitCol(){let e=this.getAttribute(`auto-fit-col`)===`true`||this.#t?.getAttribute(`auto-fit-col`)===`true`,t=this.#f.table?.getAttribute(`auto-fit-col`)===`true`;return e||t}get sourceTable(){return this.#f.table}get source(){return this.#f}get#m(){return this.#t.hasAttribute(`simple`)||this.#t.getAttribute(`theme`)===`simple`}recompileAndRefresh(){this.#f.table&&(y.recompile(this.#f.table),[`left`,`right`,`body`].forEach(e=>{[`header`,`body`,`footer`].forEach(t=>{let n=this.querySelector(`.ng-sheet-${t} .ng-container-${e}`);n&&n.querySelectorAll(`table`).forEach(e=>e.remove())})}),this.#v(),this.#_(),this.#n.initialize(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`)?.refresh(),requestAnimationFrame(()=>{this.#_(),this.#n?.refresh()}))}refreshLayout(){requestAnimationFrame(()=>{this.classList.contains(`active`)&&this.#f.table&&(this.#_(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`)?.refresh(),this.#h(),this.#a?.refreshLayout(),this.#n?.refresh())})}#h=()=>{let e=this.querySelector(`.ng-container-body thead`),t=this.querySelector(`.nodata-overlay`);t.style.top=`${e.offsetHeight}px`};get view(){return!this.#d&&this.#t?.data&&(this.#d=new j(this)),this.#d}invalidate=()=>{this.view.refresh(),this.#n.refresh(!0),this.isAutoFitCol&&this.autoFit(!0)};autoFit=(e=!0)=>{requestAnimationFrame(()=>{this.#g?.(e)})};#g=(e=!0)=>{let t=this.querySelector(`.ng-sheet-body .ng-container-body`);if(!t)return;let n=this.querySelector(`.ng-container-body table colgroup`);if(n){if(e){this.setAttribute(`auto-fit-col`,`true`);let e=t.clientWidth;if(e<=0)return;let r=0,i=[];n.querySelectorAll(`col`).forEach(e=>{let t=e.getAttribute(`data-col`);if(this.querySelector(`thead th[data-col="${t}"]`)?.getAttribute(`collapsed`)===`true`)i.unshift({globalColIndex:t,width:16,isCollapsed:!0});else{let n=parseInt(e.getAttribute(`width`),10)||100;i.push({globalColIndex:t,width:n,isCollapsed:!1}),r+=n}});let a=i.filter(e=>e.isCollapsed).reduce((e,t)=>e+t.width,0),o=Math.max(0,e-a);if(r>0&&i.length>0){let e=0,t=i.map(t=>{if(t.isCollapsed)return{globalColIndex:t.globalColIndex,remainder:0,width:16};let n=t.width*o/r,i=Math.max(30,Math.floor(n));return e+=i,{globalColIndex:t.globalColIndex,remainder:n-Math.floor(n),width:i}}),n=o-e,a=t.filter(e=>!i.find(t=>t.globalColIndex===e.globalColIndex)?.isCollapsed);if(n>0&&a.length>0){a.sort((e,t)=>t.remainder-e.remainder);for(let e=0;e<n;e++)a[e%a.length].width+=1}else if(n<0&&a.length>0){a.sort((e,t)=>e.remainder-t.remainder);for(let e=0;e<Math.abs(n);e++){let t=a[e%a.length];t.width>30&&--t.width}}t.forEach(({globalColIndex:e,width:t})=>{this.#a?.setColumnWidth(e,t,`body`)})}}else this.removeAttribute(`auto-fit-col`);this.querySelector(`nine-table-hscrollbar`)?.refresh()}};generate=(e,t)=>{e.style.display=`none`,this.#e=t,M.initializeTable(this.#t,e),e.style.display=``,this.#f={table:y.compile(e),tbody:{tr:e.querySelectorAll(`tbody tr`)}},this.#v(),this.#_(),this.#S(),this.#w(),[`left`,`body`,`right`].forEach(e=>{let t=`.ng-container-${e}`;this.#p[e]={thead:this.querySelector(`${t} thead`),tbody:{head:this.querySelector(`${t} tbody.head`),body:this.querySelector(`${t} tbody.body`),foot:this.querySelector(`${t} tbody.foot`)},tfoot:this.querySelector(`${t} tfoot`)}}),this.#n.initialize(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`).refresh(),this.#u.initialize(),this.loaded=!0};#_=()=>{[`left`,`right`,`body`].forEach(e=>{let t=this.querySelectorAll(`.ng-container-${e}`);if(t.length===0)return;let n=t[0].querySelector(`table`);if(!n)return;let r=0;n.querySelectorAll(`col`).forEach(e=>{let t=parseInt(e.getAttribute(`width`),10);isNaN(t)||(r+=t)}),t.forEach(t=>{t.querySelectorAll(`table`),e===`body`?t.style.flex=`1`:(t.style.flex=`0 0 ${r}px`,t.style.width=`${r}px`,t.style.minWidth=`${r}px`,t.style.maxWidth=`${r}px`)})})};#v=()=>{[{selector:`.ng-container-left`,type:`left`},{selector:`.ng-container-body`,type:null},{selector:`.ng-container-right`,type:`right`}].forEach(({selector:e,type:t})=>{this.querySelector(`.ng-sheet-body ${e}`).appendChild(this.#y(t))})};#y=e=>{let t=this.#f.table.cloneNode(!0);return e===`left`?t.querySelectorAll(`col, th, td`).forEach(e=>{e.getAttribute(`fixed`)!==`left`&&e.remove()}):e===`right`?t.querySelectorAll(`col, th, td`).forEach(e=>{e.getAttribute(`fixed`)!==`right`&&e.remove()}):t.querySelectorAll(`[fixed=left], [fixed=right]`).forEach(e=>{e.remove()}),t};getRowHeight=()=>this.#n.getRowHeight();getViewHeight=()=>(this.#p.content.offsetHeight||0)-((this.#p.body.thead?.offsetHeight||0)+(this.#p.body.tfoot?.offsetHeight||0)+(this.#p.body.tbody.head.offsetHeight||0));isLastRow=()=>{let e=this.querySelector(`.ng-sheet-body`),t=this.querySelector(`.ng-container-body tbody.body`),n=this.#p.body.tfoot?.offsetHeight||0,r=e.getBoundingClientRect().bottom,i=t.getBoundingClientRect().bottom;return r-n>=i};scrollToX=e=>{let t=this.querySelector(`.ng-sheet-body .ng-container-body`);t&&(t.scrollLeft=e)};scrollToY=e=>{let t=this.querySelector(`.ng-sheet-body`);t&&(t.scrollTop=e)};#b=()=>{this.#x(),this.#r=new b(this),this.#i=new x(this),this.#a=new C(this),this.#o=new T(this),this.#s=new E(this),this.#d=new j(this),this.#l=new k(this),this.#u=new g(this),this.#m||(this.#c=new A(this)),this.#p.mainBody.addEventListener(`scroll`,()=>{this.querySelector(`nine-table-hscrollbar`).refresh()})};#x=()=>{this.innerHTML=`
58
+ `};open(e){this.#i=e;let t=e.closest(`th, td`);this.currentCol=t?.dataset.col;let n=t.getBoundingClientRect(),r=this.#e.getBoundingClientRect(),i=this.offsetWidth||240,a=n.right-r.left-i,o=n.bottom-r.top;a<0&&(a=Math.max(0,n.left-r.left)),this.style.left=`${a}px`,this.style.top=`${o}px`;let s=this.querySelector(`.search-box`);s.value=``,this.classList.add(`active`),this.classList.add(`loading`),setTimeout(()=>{try{this.#c(),this.#r.rowManager.scrollToDataRow(0),s.focus()}finally{this.classList.remove(`loading`)}})}#s=e=>{let t=e.composedPath?e.composedPath():[];t.includes(this)||this.#i&&t.includes(this.#i)||this.close()};close(){this.currentCol=null,this.classList.remove(`active`),this.#i=null}#c(){let e=this.#t.data.getArray(),t=this.#i?.columns||[],n=this.#t.fields.get()||[],r=this.#e.filtering?.filters||{},i=this.#t.exprEngine,a=t.flatMap(t=>{let a=t.bind,o=t.expr,s=a||o,c=a?n.indexOf(a):-1,l=r[s]||[],u=new Map;for(let t=0;t<e.length;t++){let n=e[t];if(!n)continue;let r;c>=0&&n.v?r=n.v[c]:a&&a.includes(`data.`)?r=i?i.evaluate(a,n,t):void 0:o&&i&&(r=i.evaluate(o,n,t));let s=r;o&&i&&(s=i.evaluate(o,n,t)),s!=null&&!u.has(s)&&u.set(s,{v:r,v2:s})}let d=[...u.values()];return d.sort((e,t)=>{let n=e.v2,r=t.v2;if(n===r)return 0;if(n==null||n===``)return 1;if(r==null||r===``)return-1;let i=Number(n),a=Number(r);return!isNaN(i)&&!isNaN(a)?i-a:String(n).localeCompare(String(r))}),l.sort((e,t)=>e>t?1:-1),d.map(e=>({LVL:2,DATA:e.v,DATA2:e.v2===``||e.v2===null||e.v2===void 0?`<span class="empty-value">(empty)</span>`:e.v2,COLNM:s,CHK:l.length===0||l.nineBinarySearch(e.v)>=0?`Y`:`N`}))});this.#n.data.set(a);let o=this.querySelector(`#chkSelectAll`);o&&(o.checked=a.length>0&&a.every(e=>e.CHK===`Y`))}#l=()=>{this.#t.loading=!0;let e=this.#r.view.getArray(),t=this.#n.data.getHostFields(),n=e.filter(e=>{let n=e.v[t.indexOf(`CHK`)];return n===`Y`||n===!0}),r={...this.#e.filtering?.filters||{}};this.#i.columns.forEach(e=>{let i=e.expr||e.bind,a=e.expr?t.indexOf(`DATA2`):t.indexOf(`DATA`),o=n.map(e=>e.v[a]);o.length>0?r[i]=o:delete r[i]});let i=this.#n.data.count();setTimeout(()=>{try{i===n.length?this.#i.columns.forEach(e=>{let t=e.expr||e.bind;t&&this.#e.filtering.clear(t)}):this.#e.filtering.set(r),this.#e.querySelectorAll(`nine-table-filter-button`).forEach(e=>{e.updateFilteredState()}),this.#e.invalidate(),this.close()}finally{this.#t.loading=!1}})};#u=e=>{let t=e.target.value.toLowerCase().trim();if(!t)this.#r.filtering.clear();else{let e=this.#n.data.getArray(),n=this.#n.data.getHostFields().indexOf(`DATA2`),r=[];e.forEach(e=>{let i=n>=0&&e.v?e.v[n]:``;String(i).replace(/<[^>]*>?/gm,``).toLowerCase().includes(t)&&r.push(i)}),this.#r.filtering.set({DATA2:[...new Set(r)]})}};#d=e=>{let t=e.target.checked,n=this.#n?.data?.getArray()||[],r=this.#n.data.getHostFields().indexOf(`CHK`);r>=0&&n.forEach(e=>{e.v[r]=t?`Y`:`N`}),this.#n.refresh()}},O=class extends HTMLElement{#e;#t=null;connectedCallback(){this.#e=this.closest(`nine-table-sheet`)||this.getRootNode().host,this.removeEventListener(`click`,this.#n),this.addEventListener(`click`,this.#n)}get columns(){if(this.#t)return this.#t;let e=this.closest(`th, td`)?.dataset.col,t=this.#e.sourceTable,n=[],r=new Set;return t&&e!==void 0&&t.querySelectorAll(`tbody [data-col="${e}"]`).forEach(e=>{let t=e.dataset.bind,i=e.dataset.expr;if(t||i){let e=`${t||``}_${i||``}`;r.has(e)||(r.add(e),n.push({bind:t,expr:i}))}}),this.#t=n,this.#t}updateFilteredState=()=>{let e=this.#e.filtering?.filters||{},t=this.columns.some(t=>{let n=t.expr||t.bind;return n&&e[n]&&e[n].length>0});this.classList.toggle(`filtered`,t)};#n=e=>{e.preventDefault(),e.stopPropagation();let t=this.#e.querySelector(`nine-table-filter-panel`),n=this.closest(`th, td`).dataset.col;t&&t.currentCol===n&&t.classList.contains(`active`)?t.close():t&&t.open(this)}},k=class{#e;#t;#n=!1;#r=null;#i={};constructor(e){this.#e=e,this.#t=this.#e.getRootNode().host,this.#a()}get filters(){return this.#i}#a=()=>{this.#o()};#o=()=>{if(this.#t.tagName.toLowerCase()===`nine-table-simple`)return;let e=this.#e.querySelector(`nine-table-filter-panel`);e||(e=document.createElement(`nine-table-filter-panel`),this.#e.appendChild(e)),this.#r=e};isFiltering(){return this.#n}clear=e=>{e?delete this.#i[e]:this.#i={},this.#n=Object.keys(this.#i).length>0,this.#s(),this.#e.querySelectorAll(`nine-table-filter-button`).forEach(e=>{e.updateFilteredState()})};set=e=>{let t=Array.isArray(e)?Object.fromEntries(Object.keys(e[0]).map(t=>[t,[...new Set(e.map(e=>e[t]))]])):e;this.#i=t,this.#n=Object.keys(t).length>0,this.#e.toggleAttribute(`filtering`,this.#n),this.#s()};#s(){let e=this.#t.data.getArray(),t=this.#t.data.getHostFields(),n=this.#e.index,r=this.#t.exprEngine;if(!(Object.keys(this.#i).length>0)){e.forEach(e=>{e?.m?._?.[i.META.INDEX.FILTER]&&(e.m._[i.META.INDEX.FILTER][n]=!0)}),this.#e.invalidate();return}let a=Object.entries(this.#i).map(([e,n])=>{let r=e.includes(`data.`)||e.includes(`host.`)||e.includes(`rowItem.v`);return{targetKey:e,isExpr:r,fieldIdx:r?-1:t.indexOf(e),allowedSet:new Set(n)}});e.forEach((e,t)=>{if(!e)return;e.m._[i.META.INDEX.FILTER]||(e.m._[i.META.INDEX.FILTER]=[]);let o=!0;for(let n=0;n<a.length;n++){let{targetKey:i,isExpr:s,fieldIdx:c,allowedSet:l}=a[n],u;if(s&&r?u=r.evaluate(i,e,t):c>=0&&e.v&&(u=e.v[c]),!l.has(u)){o=!1;break}}e.m._[i.META.INDEX.FILTER][n]=o}),this.#e.invalidate()}};customElements.get(`nine-table-filter-panel`)||customElements.define(`nine-table-filter-panel`,D),customElements.get(`nine-table-filter-button`)||customElements.define(`nine-table-filter-button`,O);var A=class{#e;#t;#n=[];constructor(e){this.#e=e,this.#t=e.getRootNode().host,setTimeout(()=>{this.#r()},300)}#r(){this.#e.querySelectorAll(`thead`).forEach(e=>{e.addEventListener(`dblclick`,e=>{let t=e.target.closest(`th, td`);if(!t||t.classList.contains(`resizable-edge`)||[`INPUT`,`CELL-CHECKBOX`].includes(e.target.tagName)||e.offsetX<=2||e.offsetX>=t.offsetWidth-2)return;let n=this.#e.getRootNode().host;n.loading=!0,setTimeout(()=>{try{this.#i(e,t)}finally{n.loading=!1}})})})}#i(e,t){let n=t.dataset.col,r=t.closest(`tr`),i=r?r.dataset.subrow||String(r.sectionRowIndex):`0`;if(n===void 0)return;let a=this.#e.sourceTable;if(!a)return;let o=null,s=null;if(a.querySelectorAll(`tbody [data-col="${n}"]`).forEach(e=>{e.dataset.bind&&(o=e.dataset.bind),e.dataset.expr&&(s=e.dataset.expr)}),!o&&!s)return;let c=t.classList.contains(`asc`),l=t.classList.contains(`desc`);!e.ctrlKey&&!e.shiftKey&&(this.#n=[]);let u=this.#n.findIndex(e=>e.colIndex===n&&e.subRowIndex===i||e.colName===o),d={colIndex:n,subRowIndex:i,colname:o||s,colName:o||s,expr:s,asc:!0,"expr-func":s?(e,t)=>this.#t.exprEngine(s,e,t):null};!c&&!l?u>=0?this.#n[u].asc=!0:this.#n.push({...d,asc:!0}):c?u>=0?this.#n[u].asc=!1:this.#n.push({...d,asc:!1}):this.#n=this.#n.filter(e=>!(e.colIndex===n&&e.subRowIndex===i||e.colName===o)),this.#a()}#a(){this.#e.view&&(this.#e.view.setSorting(this.#n),this.#o(),this.#e.invalidate())}#o(){this.#e.querySelectorAll(`thead th, thead td`).forEach(e=>{e.classList.remove(`asc`,`desc`)}),this.#n.length!==0&&this.#n.forEach(e=>{let{colIndex:t,subRowIndex:n,asc:r}=e;if(t!==void 0){let e=`thead [data-col="${t}"]`;n!==void 0&&(e=`thead tr[data-subrow="${n}"] [data-col="${t}"]`),this.#e.querySelectorAll(e).forEach(e=>{e.classList.add(r?`asc`:`desc`)})}})}restore(){this.#n=[],this.#e.view&&this.#e.view.resetSorting(),this.#o(),this.#e.rowManager?.refresh(!0)}},j=class{#e;#t;#n=[];#r=[];#i=null;constructor(e){this.#e=e,this.#t=e.getRootNode().host,this.refresh()}getArray=(e,t)=>{if(!this.#i){let e=this.#t.data.getArray();this.#i=this.#r.map(t=>e[t])}let n=this.#i;if(e==null)return n;if(e<0||e>=n.length)return null;let r=n[e];if(t!=null){let e=this.#t.data.getHostFields().indexOf(t);return e>=0&&r.v?r.v[e]:null}return r};count=()=>{if(!this.#i){let e=this.#t.data.getArray();this.#i=this.#r.map(t=>e[t])}return this.#i.length};get=(e,t)=>{let n=this.getArray(),r=this.#t.data.getHostFields?.()||[];if(e==null)return n.map(e=>this.#a(e,r));if(e<0||e>=n.length)return null;let i=n[e];if(!i)return null;if(t!=null){let e=r.indexOf(t);return e>=0&&i.v?i.v[e]:null}return this.#a(i,r)};#a=(e,t)=>{if(!e)return null;let n={};return t.forEach((t,r)=>{n[t]=e.v?e.v[r]:e[t]}),e.m&&(n.m=e.m),e._&&(n._=e._),n};refresh=()=>{this.#i=null;let e=this.#t.data.getArray(),t=[];e.forEach((e,n)=>{if(!e)return;let r=e.m?._?.[i.META.INDEX.FILTER];r&&r[this.#e.index]===!1||t.push(n)}),this.#n.length>0&&(t=this.#o(t,e)),this.#r=t;let n=t.map(t=>e[t]),r=this.#e.grouping?.columns||[];if(r.length>0){let e=_.apply(n,r,this.#t.data.getHostFields());this.#i=e.renderItems,this.#e.grouping.setGroupMap(e.groupMap)}else this.#i=n};setSorting=e=>{this.#n=e||[],this.refresh()};getSorting=()=>this.#n;resetSorting=()=>{this.#n=[],this.refresh()};#o=(e,t)=>{let n=typeof this.#t.data.getHostFields==`function`?this.#t.data.getHostFields():[],r=this.#n.map(e=>({...e,colIndex:n.indexOf(e.colname||e.colName)}));return e.sort((e,n)=>{let i=t[e],a=t[n];for(let t of r){let r=t.asc,o=t.expr,s,c;o?(s=this.#t.exprEngine.evaluate(o,i,e),c=this.#t.exprEngine.evaluate(o,a,n)):t.colIndex>=0&&i.v&&a.v&&(s=i.v[t.colIndex],c=a.v[t.colIndex]);let l=s==null||s===``,u=c==null||c===``;if(!(l&&u)){if(l)return 1;if(u)return-1;if(s!==c){let e=0;if(typeof s==`number`&&typeof c==`number`)e=s-c;else{let t=String(s),n=String(c);e=t>n?1:t<n?-1:0}if(e!==0)return r?e:-e}}}return e-n})}},M=class e{static initializeTable(t,n){return e.#r(n),e.#a(n),e.#n(n),e.#u(n),e.#i(n),y.resetColIndex(n,n.querySelectorAll(`thead tr`)),y.resetColIndex(n,n.querySelectorAll(`tbody.body tr[grouping="true"]`)),y.resetColIndex(n,n.querySelectorAll(`tbody.body tr:not([grouping="true"])`)),y.resetColIndex(n,n.querySelectorAll(`tfoot tr`)),e.#e(n),e.#o(n),e.#s(t,n),e.#l(n),e.#c(t,n),e.#d(n),n}static#e(t){let n=t.querySelector(`thead`);if(!n||n.querySelector(`.col-indicator-rowgroup`))return;let r=n.insertRow(0);r.setAttribute(`role`,`row`),r.classList.add(`col-indicator-rowgroup`),r.classList.add(`collapse`);let i=t.querySelector(`tbody tr`);if(!i)return;let a=0;i.querySelectorAll(`th, td`).forEach(t=>{if(!t.classList.contains(`dummy`)){let n=t.colSpan||1;for(let t=0;t<n;t++){let t=`<th data-col="@col" class="col-indicator" scope="col"></th>`.replace(`@col`,a).replace(`@text`,e.#t(a++));r.insertAdjacentHTML(`beforeend`,t)}}});let o=Array.from(t.querySelectorAll(`colgroup col`));r.querySelectorAll(`.col-indicator`).forEach((e,t)=>{let n=o[t].getAttribute(`background`);n&&(e.style.background=n)})}static#t(e){let t=``;for(let n=e;n>=0;n=Math.floor(n/26)-1)t=String.fromCharCode(65+n%26)+t;return t}static#n(e){let t=e.querySelector(`tbody:not(.head):not(.foot)`);if(t){if(t.classList.add(`body`),!e.querySelector(`tbody.head`)){let e=document.createElement(`tbody`);e.classList.add(`head`),t.before(e)}if(!e.querySelector(`tbody.foot`)){let e=document.createElement(`tbody`);e.classList.add(`foot`),t.after(e)}}}static#r(e){let t=e.querySelector(`colgroup`);if(t||(t=document.createElement(`colgroup`),e.prepend(t)),t.querySelectorAll(`col`).length===0){let n=e.querySelector(`tbody tr`),r=1;n&&(r=Array.from(n.querySelectorAll(`th, td`)).reduce((e,t)=>e+(parseInt(t.getAttribute(`colspan`)||t.colSpan,10)||1),0)),r=Math.max(r,1);for(let e=0;e<r;e++){let e=document.createElement(`col`);t.appendChild(e)}}}static#i(e){let t=Array.from(e.querySelectorAll(`colgroup col`));if(t.length===0)return;let n=e.clientWidth||0,r=Math.max(Math.floor(n/t.length),100);t.forEach((e,t)=>{e.hasAttribute(`data-col`)||e.setAttribute(`data-col`,t);let n=e.getAttribute(`width`)||parseInt(e.style.width,10)||r;e.setAttribute(`width`,n);let i=String(n).includes(`px`)?n:`${n}px`;e.style.width=i})}static#a(e){if(e.querySelector(`thead`))return;let t=document.createElement(`thead`),n=e.querySelector(`colgroup`);n?n.after(t):e.prepend(t)}static#o(e){e.querySelectorAll(`thead th, thead td`).forEach(e=>{e.getAttribute(`collapsed`)===`true`&&e.getAttribute(`collapsible`)!==`true`&&e.setAttribute(`collapsible`,`true`)})}static#s(e,t){let n=[`data-bind`,`data-expr`,`type`],r=0;t.querySelectorAll(`tbody th, tbody td`).forEach(t=>{let i=`cell-${t.getAttribute(`cell-type`)||`renderer`}`,a=t.querySelector(`datalist`);if(a){let n=[];a.querySelectorAll(`option`).forEach(e=>{n.push({k:e.getAttribute(`k`),v:e.getAttribute(`v`),value:e.getAttribute(`value`)})});let i=`__ds_${Date.now()}_${++r}`;e&&(e[i]=()=>n),t.setAttribute(`data-source`,`host.${i}()`),a.remove()}let o=t.dataset.expr;o&&t.setAttribute(`data-expr`,e.exprEngine.precompile(o)),Array.from(t.attributes).forEach(n=>{[`data-bind`,`data-expr`,`cell-type`,`validator`].includes(n.name)||(n.value.includes(`data.`)||n.value.includes(`host.`))&&t.setAttribute(n.name,e.exprEngine.precompile(n.value))}),t.innerHTML=`<${i} ${n.filter(e=>t.hasAttribute(e)).map(e=>`${e}="${t.getAttribute(e)}"`).join(` `)}></${i}>`,t.setAttribute(`tabindex`,`0`)}),t.querySelectorAll(`thead th, thead td, tfoot th, tfoot td`).forEach(e=>{let t=e.getAttribute(`cell-type`);if(t){let r=e.innerHTML,i=`cell-${t}`;e.innerHTML=`<${i} ${n.filter(t=>e.hasAttribute(t)).map(t=>`${t}="${e.getAttribute(t)}"`).join(` `)} content="${r}"></${i}>`}})}static#c(e,t){let n=e.getAttribute(`filtering`)===`true`,r=t.getAttribute(`filtering`)===`true`;t.querySelectorAll(`thead tr:not(.col-indicator-rowgroup) th, thead tr:not(.col-indicator-rowgroup) td`).forEach(e=>{let t=e.getAttribute(`filtering`)===`true`||r||n;e.setAttribute(`filtering`,t?`true`:`false`),t&&e.appendChild(document.createElement(`nine-table-filter-button`))})}static#l(e){e.querySelectorAll(`thead th, thead td`).forEach(t=>{if(t.getAttribute(`collapsible`)!==`true`&&t.getAttribute(`expandable`)!==`true`)return;let n=parseInt(t.dataset.col,10),r=t.colSpan||1,i=e.querySelector(`colgroup col[data-col="${n}"]`),a=i&&parseInt(i.getAttribute(`width`),10)||100;(!t.dataset.expandWidth||parseInt(t.dataset.expandWidth,10)<=16)&&(t.dataset.expandWidth=String(a>16?a:100));let o=t.querySelector(`nine-table-col-expand`);if(o||(o=document.createElement(`nine-table-col-expand`),t.insertBefore(o,t.firstChild)),t.getAttribute(`collapsed`)===`true`){o.classList.add(`collapsed`),o.classList.remove(`expand`),o.setAttribute(`collapsed`,`true`),t.style.color=`transparent`;let i=Math.max(10,Math.floor(16/r));if(!isNaN(n))for(let t=0;t<r;t++){let r=e.querySelector(`colgroup col[data-col="${n+t}"]`);r&&(r.setAttribute(`width`,i),r.style.width=`${i}px`)}}else o.classList.remove(`collapsed`),o.classList.add(`expand`),o.setAttribute(`collapsed`,`false`),t.style.color=``})}static#u(e,t){let n=e.getAttribute(`row-indicator`)===`true`?48:0,r=e.querySelector(`colgroup`),i=document.createElement(`col`);i.setAttribute(`fixed`,`left`),i.setAttribute(`width`,n),i.style.width=`${n}px`,r.prepend(i),e.querySelectorAll(`thead, tbody, tfoot`).forEach(e=>{let t=Array.from(e.querySelectorAll(`tr`));if(t.length===0)return;let n=t[0],r=document.createElement(`th`);r.className=`row-indicator`,r.setAttribute(`cell-type`,`row-indicator`),t.length>1&&(r.rowSpan=t.length),n.insertBefore(r,n.firstElementChild)})}static#d(e){e.querySelectorAll(`th[data-col], td[data-col]`).forEach(t=>{let n=parseInt(t.getAttribute(`data-col`),10);if(isNaN(n))return;let r=parseInt(t.getAttribute(`colspan`)||t.colSpan,10)||1,i=0;for(let t=0;t<r;t++){let r=n+t,a=e.querySelector(`colgroup col[data-col="${r}"]`);a&&(i+=parseInt(a.getAttribute(`width`),10)||100)}if(i>0){let e=`${i}px`;t.style.width=e,t.style.minWidth=e,t.style.maxWidth=e}})}},N=class extends HTMLElement{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f={table:null};#p;static SCROLLBAR_SIZE=16;constructor(){super(),this.#t=this.getRootNode().host,this.#n=new v(this)}connectedCallback(){this.#b()}get index(){return this.#e}get colResizer(){return this.#a}get filtering(){return this.#l}get grouping(){return this.#u}get colMover(){return this.#o}get colFix(){return this.#s}get rowManager(){return this.#n}get selection(){return this.#r}get navigation(){return this.#i}get templateLength(){return this.#f.tbody.tr.length||0}get elements(){return this.#p}get isAutoFitCol(){let e=this.getAttribute(`auto-fit-col`)===`true`||this.#t?.getAttribute(`auto-fit-col`)===`true`,t=this.#f.table?.getAttribute(`auto-fit-col`)===`true`;return e||t}get sourceTable(){return this.#f.table}get source(){return this.#f}get#m(){return this.#t.hasAttribute(`simple`)||this.#t.getAttribute(`theme`)===`simple`}scrollTo=(e,t)=>{this.rowManager.scrollToDataRow(e,`top`,t)};recompileAndRefresh(){this.#f.table&&(y.recompile(this.#f.table),[`left`,`right`,`body`].forEach(e=>{[`header`,`body`,`footer`].forEach(t=>{let n=this.querySelector(`.ng-sheet-${t} .ng-container-${e}`);n&&n.querySelectorAll(`table`).forEach(e=>e.remove())})}),this.#v(),this.#_(),this.#n.initialize(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`)?.refresh(),requestAnimationFrame(()=>{this.#_(),this.#n?.refresh()}))}refreshLayout(){requestAnimationFrame(()=>{this.classList.contains(`active`)&&this.#f.table&&(this.#_(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`)?.refresh(),this.#h(),this.#a?.refreshLayout(),this.#n?.refresh())})}#h=()=>{let e=this.querySelector(`.ng-container-body thead`),t=this.querySelector(`.nodata-overlay`);t.style.top=`${e.offsetHeight}px`};get view(){return!this.#d&&this.#t?.data&&(this.#d=new j(this)),this.#d}invalidate=()=>{this.view.refresh(),this.#n.refresh(!0),this.isAutoFitCol&&this.autoFit(!0)};autoFit=(e=!0)=>{requestAnimationFrame(()=>{this.#g?.(e)})};#g=(e=!0)=>{let t=this.querySelector(`.ng-sheet-body .ng-container-body`);if(!t)return;let n=this.querySelector(`.ng-container-body table colgroup`);if(n){if(e){this.setAttribute(`auto-fit-col`,`true`);let e=t.clientWidth;if(e<=0)return;let r=0,i=[];n.querySelectorAll(`col`).forEach(e=>{let t=e.getAttribute(`data-col`);if(this.querySelector(`thead th[data-col="${t}"]`)?.getAttribute(`collapsed`)===`true`)i.unshift({globalColIndex:t,width:16,isCollapsed:!0});else{let n=parseInt(e.getAttribute(`width`),10)||100;i.push({globalColIndex:t,width:n,isCollapsed:!1}),r+=n}});let a=i.filter(e=>e.isCollapsed).reduce((e,t)=>e+t.width,0),o=Math.max(0,e-a);if(r>0&&i.length>0){let e=0,t=i.map(t=>{if(t.isCollapsed)return{globalColIndex:t.globalColIndex,remainder:0,width:16};let n=t.width*o/r,i=Math.max(30,Math.floor(n));return e+=i,{globalColIndex:t.globalColIndex,remainder:n-Math.floor(n),width:i}}),n=o-e,a=t.filter(e=>!i.find(t=>t.globalColIndex===e.globalColIndex)?.isCollapsed);if(n>0&&a.length>0){a.sort((e,t)=>t.remainder-e.remainder);for(let e=0;e<n;e++)a[e%a.length].width+=1}else if(n<0&&a.length>0){a.sort((e,t)=>e.remainder-t.remainder);for(let e=0;e<Math.abs(n);e++){let t=a[e%a.length];t.width>30&&--t.width}}t.forEach(({globalColIndex:e,width:t})=>{this.#a?.setColumnWidth(e,t,`body`)})}}else this.removeAttribute(`auto-fit-col`);this.querySelector(`nine-table-hscrollbar`)?.refresh()}};generate=(e,t)=>{e.style.display=`none`,this.#e=t,M.initializeTable(this.#t,e),e.style.display=``,this.#f={table:y.compile(e),tbody:{tr:e.querySelectorAll(`tbody tr`)}},this.#v(),this.#_(),this.#S(),this.#w(),[`left`,`body`,`right`].forEach(e=>{let t=`.ng-container-${e}`;this.#p[e]={thead:this.querySelector(`${t} thead`),tbody:{head:this.querySelector(`${t} tbody.head`),body:this.querySelector(`${t} tbody.body`),foot:this.querySelector(`${t} tbody.foot`)},tfoot:this.querySelector(`${t} tfoot`)}}),this.#n.initialize(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`).refresh(),this.#u.initialize(),this.loaded=!0};#_=()=>{[`left`,`right`,`body`].forEach(e=>{let t=this.querySelectorAll(`.ng-container-${e}`);if(t.length===0)return;let n=t[0].querySelector(`table`);if(!n)return;let r=0;n.querySelectorAll(`col`).forEach(e=>{let t=parseInt(e.getAttribute(`width`),10);isNaN(t)||(r+=t)}),t.forEach(t=>{t.querySelectorAll(`table`),e===`body`?t.style.flex=`1`:(t.style.flex=`0 0 ${r}px`,t.style.width=`${r}px`,t.style.minWidth=`${r}px`,t.style.maxWidth=`${r}px`)})})};#v=()=>{[{selector:`.ng-container-left`,type:`left`},{selector:`.ng-container-body`,type:null},{selector:`.ng-container-right`,type:`right`}].forEach(({selector:e,type:t})=>{this.querySelector(`.ng-sheet-body ${e}`).appendChild(this.#y(t))})};#y=e=>{let t=this.#f.table.cloneNode(!0);return e===`left`?t.querySelectorAll(`col, th, td`).forEach(e=>{e.getAttribute(`fixed`)!==`left`&&e.remove()}):e===`right`?t.querySelectorAll(`col, th, td`).forEach(e=>{e.getAttribute(`fixed`)!==`right`&&e.remove()}):t.querySelectorAll(`[fixed=left], [fixed=right]`).forEach(e=>{e.remove()}),t};getRowHeight=()=>this.#n.getRowHeight();getViewHeight=()=>(this.#p.content.offsetHeight||0)-((this.#p.body.thead?.offsetHeight||0)+(this.#p.body.tfoot?.offsetHeight||0)+(this.#p.body.tbody.head.offsetHeight||0));isLastRow=()=>{let e=this.querySelector(`.ng-sheet-body`),t=this.querySelector(`.ng-container-body tbody.body`),n=this.#p.body.tfoot?.offsetHeight||0,r=e.getBoundingClientRect().bottom,i=t.getBoundingClientRect().bottom;return r-n>=i};scrollToX=e=>{let t=this.querySelector(`.ng-sheet-body .ng-container-body`);t&&(t.scrollLeft=e)};scrollToY=e=>{let t=this.querySelector(`.ng-sheet-body`);t&&(t.scrollTop=e)};#b=()=>{this.#x(),this.#r=new b(this),this.#i=new x(this),this.#a=new C(this),this.#o=new T(this),this.#s=new E(this),this.#d=new j(this),this.#l=new k(this),this.#u=new g(this),this.#m||(this.#c=new A(this)),this.#p.mainBody.addEventListener(`scroll`,()=>{this.querySelector(`nine-table-hscrollbar`).refresh()})};#x=()=>{this.innerHTML=`
59
59
  <div class="ng-sheet-body">
60
60
  <div class="ng-sheet-body-content">
61
61
  <div class="ng-container-left"></div>
@@ -75,10 +75,11 @@
75
75
 
76
76
  <div class="ng-col-mover-grip"></div>
77
77
  <div class="ng-col-mover-indi"></div>
78
- `,this.#p={mainBody:this.querySelector(`.ng-sheet-body .ng-container-body`),hscrollbar:this.querySelector(`nine-table-hscrollbar`),vscrollbar:this.querySelector(`nine-table-vscrollbar`),content:this.querySelector(`.ng-sheet-body .ng-sheet-body-content`),scrollHolder:this.querySelector(`.ng-sheet-body .ng-virtual-height-holder`)}};#S=()=>{let e=this.querySelector(`.ng-container-left table`),t=this.querySelector(`.ng-container-body table`),n=this.querySelector(`.ng-container-right table`),r=Array.from(e.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`)),i=Array.from(t.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`)),a=Array.from(n.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`));this.#C(r,i,a);let o=Array.from(e.querySelectorAll(`tfoot tr`)),s=Array.from(t.querySelectorAll(`tfoot tr`)),c=Array.from(n.querySelectorAll(`tfoot tr`));this.#C(o,s,c)};#C=(e,t,n)=>{setTimeout(()=>{let r=Math.max(e.length,t.length,n.length);for(let i=0;i<r;i++){let r=[e[i]?.getBoundingClientRect().height||0,t[i]?.getBoundingClientRect().height||0,n[i]?.getBoundingClientRect().height||0],a=Math.max(...r);a>0&&(e[i]&&(e[i].style.height=`${a}px`),t[i]&&(t[i].style.height=`${a}px`),n[i]&&(n[i].style.height=`${a}px`))}})};#w=()=>{let e=this.querySelector(`.ng-sheet-body`);if(!e)return;let t=null;e.addEventListener(`mouseover`,n=>{let r=n.target.closest(`tr`);if(!r||!r.dataset.row&&r.dataset.row!==`0`)return;let i=r.dataset.row;t!==i&&(t=i,e.querySelectorAll(`tr[data-row="${i}"]`).forEach(e=>{e.classList.add(`hover`)}))}),e.addEventListener(`mouseout`,n=>{let r=n.target.closest(`tr`);if(!r)return;let i=n.relatedTarget;r.contains(i)||(e.querySelectorAll(`tr.hover`).forEach(e=>{e.classList.remove(`hover`)}),t=null)})};disconnectedCallback(){this.#a?.destroy(),this.#o?.destroy(),this.innerHTML=``}};customElements.get(`nine-table-sheet`)||customElements.define(`nine-table-sheet`,N);var P=class{#e;constructor(e){this.#e=e,this.#t()}#t=()=>{this.#r(),new ResizeObserver(e=>{for(let t of e)this.#e.getAttribute(`auto-height`)===`true`&&this.#n()}).observe(this.#e)};set loading(e){e?this.#e.classList.add(`loading`):this.#e.classList.remove(`loading`)}#n=()=>{let e=Array.from(this.#e.shadowRoot.querySelectorAll(`nine-table-sheet.active`));if(e.length===0)return;let t=parseInt(this.#e.getAttribute(`max-display-row`),10)||10,n=Math.max(...e.map(e=>e.getRowHeight())),r=this.#e.shadowRoot.querySelector(`nine-table-toolbar`),i=this.#e.shadowRoot.querySelector(`nine-table-sheets-footer`),a=r?r.getBoundingClientRect().height:0,o=i?i.getBoundingClientRect().height:0,s=N.SCROLLBAR_SIZE,c=t*n+a+o+s;this.#e.style.height=`${c}px`};#r=()=>{let e=Array.from(this.#e.children).filter(e=>e.tagName.toUpperCase()===`TABLE`),t=this.#e.getAttribute(`auto-height`)===`true`,n=e.length,r=e.map((e,t)=>{let r=t===0?`active`:``,i=e.id||`sheet${t+1}`;return`<nine-table-sheet class="${r}" data-index="${t}" data-sheet-id="${i}" id="${i}"></nine-table-sheet>`+(t<n-1?`<nine-splitter class="h" data-split-index="${t}"></nine-splitter>`:``)}).join(``),i=[`@import "https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.0.9/dist/css/nine-table.css";`];nine[`nine-table`]&&nine[`nine-table`].cssFile&&i.push(`@import "${nine[`nine-table`].cssFile}";`),this.#e.shadowRoot.innerHTML=`
78
+ `,this.#p={mainBody:this.querySelector(`.ng-sheet-body .ng-container-body`),hscrollbar:this.querySelector(`nine-table-hscrollbar`),vscrollbar:this.querySelector(`nine-table-vscrollbar`),content:this.querySelector(`.ng-sheet-body .ng-sheet-body-content`),scrollHolder:this.querySelector(`.ng-sheet-body .ng-virtual-height-holder`)}};#S=()=>{let e=this.querySelector(`.ng-container-left table`),t=this.querySelector(`.ng-container-body table`),n=this.querySelector(`.ng-container-right table`),r=Array.from(e.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`)),i=Array.from(t.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`)),a=Array.from(n.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`));this.#C(r,i,a);let o=Array.from(e.querySelectorAll(`tfoot tr`)),s=Array.from(t.querySelectorAll(`tfoot tr`)),c=Array.from(n.querySelectorAll(`tfoot tr`));this.#C(o,s,c)};#C=(e,t,n)=>{setTimeout(()=>{let r=Math.max(e.length,t.length,n.length);for(let i=0;i<r;i++){let r=[e[i]?.getBoundingClientRect().height||0,t[i]?.getBoundingClientRect().height||0,n[i]?.getBoundingClientRect().height||0],a=Math.max(...r);a>0&&(e[i]&&(e[i].style.height=`${a}px`),t[i]&&(t[i].style.height=`${a}px`),n[i]&&(n[i].style.height=`${a}px`))}})};#w=()=>{let e=this.querySelector(`.ng-sheet-body`);if(!e)return;let t=null;e.addEventListener(`mouseover`,n=>{let r=n.target.closest(`tr`);if(!r||!r.dataset.row&&r.dataset.row!==`0`)return;let i=r.dataset.row;t!==i&&(t=i,e.querySelectorAll(`tr[data-row="${i}"]`).forEach(e=>{e.classList.add(`hover`)}))}),e.addEventListener(`mouseout`,n=>{let r=n.target.closest(`tr`);if(!r)return;let i=n.relatedTarget;r.contains(i)||(e.querySelectorAll(`tr.hover`).forEach(e=>{e.classList.remove(`hover`)}),t=null)})};disconnectedCallback(){this.#a?.destroy(),this.#o?.destroy(),this.innerHTML=``}};customElements.get(`nine-table-sheet`)||customElements.define(`nine-table-sheet`,N);var P=class{#e;constructor(e){this.#e=e,this.#t()}#t=()=>{this.#r(),new ResizeObserver(e=>{for(let t of e)this.#e.getAttribute(`auto-height`)===`true`&&this.#n()}).observe(this.#e)};set loading(e){e?this.#e.classList.add(`loading`):this.#e.classList.remove(`loading`)}#n=()=>{let e=Array.from(this.#e.shadowRoot.querySelectorAll(`nine-table-sheet.active`));if(e.length===0)return;let t=parseInt(this.#e.getAttribute(`max-display-row`),10)||10,n=Math.max(...e.map(e=>e.getRowHeight())),r=this.#e.shadowRoot.querySelector(`nine-table-toolbar`),i=this.#e.shadowRoot.querySelector(`nine-table-sheets-footer`),a=r?r.getBoundingClientRect().height:0,o=i?i.getBoundingClientRect().height:0,s=N.SCROLLBAR_SIZE,c=t*n+a+o+s;this.#e.style.height=`${c}px`};#r=()=>{let e=Array.from(this.#e.children).filter(e=>e.tagName.toUpperCase()===`TABLE`),t=this.#e.getAttribute(`auto-height`)===`true`,n=e.length,r=e.map((e,t)=>{let r=t===0?`active`:``,i=e.id||`sheet${t+1}`;return`<nine-table-sheet class="${r}" data-index="${t}" data-sheet-id="${i}" id="${i}"></nine-table-sheet>`+(t<n-1?`<nine-splitter class="h" data-split-index="${t}"></nine-splitter>`:``)}).join(``),i=[`@import "https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.0.11/dist/css/nine-table.css";`];nine[`nine-table`]&&nine[`nine-table`].cssFile&&i.push(`@import "${nine[`nine-table`].cssFile}";`),this.#e.shadowRoot.innerHTML=`
79
79
  <style>
80
80
  ${i.join(`
81
81
  `)}
82
+ ${this.#e.customStyle}
82
83
  </style>
83
84
 
84
85
  <nine-table-toolbar></nine-table-toolbar>
@@ -101,7 +102,7 @@
101
102
 
102
103
  if (!data && !host) return "";
103
104
  return ${i};
104
- `),this.#n.set(i,e)),e(t,n,this.#e)}return i}catch{return e}}},I=class extends HTMLElement{#e;#t;#n;#r=0;constructor(){super(),[`NINE-TABLE`].includes(this.tagName)&&r.log(`Welcome nine-table`,`0.0.9`),this.#e=this.attachShadow({mode:`open`}),this.#t=new s(this)}connectedCallback(){setTimeout(()=>{this.#r=this.querySelectorAll(`table`)?.length,this.fields=new c(this),this.exprEngine=new F(this),this.#a(),this.#n=new P(this),this.#i()})}disconnectedCallback(){}#i=()=>{let e=0,t=setInterval(()=>{e++;let n=this.shadow.querySelectorAll(`nine-table-sheet`);if(e>=50&&clearInterval(t),n.length>=this.#r){let e=0;n.forEach(t=>{t.loaded&&e++}),e>=this.#r&&(clearInterval(t),this.loaded=!0,this.dispatchEvent(new CustomEvent(i.EVENT.LOAD,{bubbles:!0,detail:{target:this}})))}},100)};get shadow(){return this.#e}get dataManager(){return this.#t}get data(){return this.#t.data}get row(){return this.#t.row}addProvider(e){e&&typeof e==`object`&&setTimeout(()=>{Object.entries(e).forEach(([e,t])=>{typeof t==`function`&&(this[e]=t)}),this.rerenderer()})}setData(e){this.#t.data.set(e),this.refresh()}refresh(){this.activeSheet?.invalidate()}set loading(e){this.#n&&(this.#n.loading=e)}rerenderer(){this.activeSheet?.querySelectorAll(`tbody.body th,tbody.body td`).forEach(e=>{Array.from(e.children).find(e=>e.tagName.toLowerCase().startsWith(`cell-`)&&typeof e.rerenderer==`function`)?.rerenderer()})}sheet=e=>{if(e===null||e<0)return this.activeSheet;let t=Array.from(this.shadow.querySelectorAll(`nine-table-sheet`));return typeof e==`number`?t[e]||null:typeof e==`string`?this.shadow.querySelector(`nine-table-sheet#${e}, nine-table-sheet[data-sheet-id="${e}"]`)||null:t[0]||null};get sheets(){return Array.from(this.shadow.querySelectorAll(`nine-table-sheet`))}get activeSheet(){return this.shadow.querySelector(`nine-table-sheet.active`)||null}#a(){let e=new Set;this.querySelectorAll(`[data-source]`).forEach(t=>{let n=t.getAttribute(`data-source`);if(!n)return;let r=n.matchAll(/(?:host\.)?([a-zA-Z0-9_$]+)\s*\(/g);for(let t of r){let n=t[1];n&&n!==`host`&&e.add(n)}}),e.forEach(e=>{let t=null;Object.defineProperty(this,e,{set:e=>{t=e,this.rerenderer()},get:()=>t,configurable:!0,enumerable:!0})})}execute=e=>{setTimeout(()=>{this.loading=!0,setTimeout(()=>{try{e.call(this)}finally{this.loading=!1}})})}};customElements.get(`nine-table`)||customElements.define(`nine-table`,I),customElements.get(`nine-table-simple`)||customElements.define(`nine-table-simple`,class extends I{connectedCallback(){this.setAttribute(`theme`,`simple`),super.connectedCallback()}});var L=class extends HTMLElement{constructor(){super()}applyBaseStyle(){}connectedCallback(){}},R=new Map,z=class extends L{#e;#t;#n;#r;#i;constructor(){super()}get host(){return this.#e}get sheet(){return this.#t}get cell(){return this.#r}get tr(){return this.#n}get attr(){return this.#i}connectedCallback(){super.connectedCallback(),this.#e=this.getRootNode().host,this.#r=this.closest(`th,td`),this.#n=this.#r.closest(`tr`),this.#t=this.#n.closest(`nine-table-sheet`),this.#r.classList.add(this.tagName),this.#i={};for(let e=0;e<this.#r.attributes.length;e++){let t=this.#r.attributes[e].name;[`text-align`,`class`,`cell-type`,`data-bind`,`data-expr`,`data-col`,`tabindex`].includes(t)||(this.#i[t]=this.#r.attributes[e].value)}if(!this.#r)return;let e=this.shadowRoot||this;e.querySelectorAll(`button, ng-expand-button`).forEach(e=>{e.addEventListener(`click`,()=>{let e=this.getAttribute(`onbuttonclick`)||this.getAttribute(`onButtonClick`)||this.#r?.getAttribute(`onbuttonclick`)||this.#r?.getAttribute(`onButtonClick`),t=this.data,n=parseInt(this.#r.dataset.row,10);if(e&&this.#e){e=e.replace(`()`,``);let r=e.match(/^(\w+)\s*\(/)?.[1]||e;typeof this.#e[r]==`function`?this.#e[r].call(this.#e,t,n,this.#r):typeof this.#e.exprFunction==`function`&&this.#e.exprFunction(e).call(this,t,n)}})});let t=e.querySelector(`.renderer`);t&&this.getAttribute(`link`)===`true`&&(t.classList.add(`link`),t.addEventListener(`click`,()=>{let e=this.getAttribute(`onlinkclick`)||this.getAttribute(`onLinkClick`),t=this.data,n=parseInt(this.#r.dataset.row,10);if(e&&this.#e){e=e.replace(`()`,``);let r=e.match(/^(\w+)\s*\(/)?.[1]||e;typeof this.#e[r]==`function`?this.#e[r].call(this.#e,t,n,this.#r):typeof this.#e.exprFunction==`function`&&this.#e.exprFunction(e).call(this,t,n)}this.#e?.dispatchEvent(new CustomEvent(ninegrid.EVENT.LINK_CLICK,{detail:{target:this.#r,data:t,currow:n},bubbles:!0,composed:!0}))}))}get data(){let e=this.#n?.data;if(!e)return null;if(!e.v)return e;let t=this.#e;return new Proxy(e,{get(e,n){if(n===`__ng`)return e.__ng;if(n===`v`)return e.v;let r=t?.fields?.indexOf?.(n)??-1;return r>=0?e.v[r]:e[n]}})}get value(){if(!this.#r||!this.#n?.data)return``;let e=this.#r.dataset?.bind;if(!e)return``;let t=this.#n.data;if(t.v&&Array.isArray(t.v)){let n=this.#e.fields.get().indexOf(e)??-1;return n>=0?t.v[n]??``:``}return t[e]??``}set value(e){if(!this.#r||!this.#e?.data)return;let t=parseInt(this.#r.dataset.row,10),n=this.#r.dataset.bind;if(isNaN(t)||!n)return;let r=this.getAttribute(`update-row-state`)!==`false`;this.#e.data.setValue(t,n,e,r)}get row(){return parseInt(this.#r?.dataset?.row,10)}get index(){return parseInt(this.#r?.dataset?.index,10)}isValid(){return!this.#r.classList.contains(`invalid`)}isInvalid(){return!this.isValid()}getDisplayText=(e=``)=>{if(!this.#r||!this.#r.closest(`tbody`)||!this.#n.data)return e;let t=this.#r.dataset.expr,n=this.#r.dataset.bind,r=parseInt(this.#r.dataset.row,10);if(t)try{return this.#n.getAttribute(`grouping`)===`true`?this.getGroupExprValue(t,this.#n.data,r,this.#r):this.#e.exprEngine.evaluate(t,this.#n.data,r)}catch{return e}return n?this.value??e:e};refresh(){if(!this.#r||!this.#n)return;let e=this.value;return this.#r.classList.remove(`invalid`),[`color`,`background`,`background-color`,`visible`,`enable`,`validator`].forEach(e=>{let t=this.#i[e];if(t){let n=this.#e.exprEngine.evaluate(t,this.#n.data,parseInt(this.#r.dataset.row,10));e===`validator`?n||this.#r.classList.add(`invalid`):e===`visible`?this.style.display=n?``:`none`:e===`enable`?(this.querySelectorAll(`input, button, textarea, select`).forEach(e=>{e.disabled=!n}),n?this.#r.removeAttribute(`disabled`):this.#r.setAttribute(`disabled`,`true`)):this.#r.style[e]=n}}),e}getExprValue(e,t,n){return!this.#e||!this.#e.exprEngine||e==null||e===``?e:this.#e.exprEngine.evaluate(e,t,n)}getGroupExprValue=(e,t,n,r)=>{if(!e)return``;try{n=parseInt(n,10);let i=e.replace(`()`,``).trim();if(this.#e&&typeof this.#e[i]==`function`)return this.#e[i].call(this,t,n,r);let a=i.match(/^(\w+)\s*\(\s*([\w\-]*)\s*\)/);if(a){let e=t[GROUP_IDX.CHILDREN],n=this.#e?.data?.getArray?this.#e.data.getArray():[],r=e?e.map(e=>n[e]).filter(Boolean):[],[,i,o]=a,s=this.#e;switch(i.toLowerCase()){case`count`:return r.length;case`sum`:{let e=s?.fields?.indexOf?.(o)??-1;return r.reduce((t,n)=>{let r=e>=0?n.v?.[e]:n[o];return t+(Number(r)||0)},0)}case`avg`:{if(r.length===0)return 0;let e=s?.fields?.indexOf?.(o)??-1;return r.reduce((t,n)=>{let r=e>=0?n.v?.[e]:n[o];return t+(Number(r)||0)},0)/r.length}}}if(this.#e&&typeof this.#e.exprFunction==`function`)return this.#e.exprFunction(e).call(this,t,n,this.#e.data);if(e.includes(`data.`)||e.includes(`childRecords`)||e.includes(`groupRecord`)){let i=R.get(`grp_`+e);return i||(i=Function(`groupRecord`,`row`,`cell`,`host`,`
105
+ `),this.#n.set(i,e)),e(t,n,this.#e)}return i}catch{return e}}},I=class extends HTMLElement{#e;#t;#n;#r=0;#i=``;constructor(){super(),[`NINE-TABLE`].includes(this.tagName)&&r.log(`Welcome nine-table`,`0.0.11`),this.#e=this.attachShadow({mode:`open`}),this.#t=new s(this)}connectedCallback(){setTimeout(()=>{this.#r=this.querySelectorAll(`table`)?.length,this.fields=new c(this),this.exprEngine=new F(this),this.#o(),this.#n=new P(this),this.#a()})}disconnectedCallback(){}#a=()=>{let e=0,t=setInterval(()=>{e++;let n=this.shadow.querySelectorAll(`nine-table-sheet`);if(e>=50&&clearInterval(t),n.length>=this.#r){let e=0;n.forEach(t=>{t.loaded&&e++}),e>=this.#r&&(clearInterval(t),this.loaded=!0,this.dispatchEvent(new CustomEvent(i.EVENT.LOAD,{bubbles:!0,detail:{target:this}})))}},100)};get shadow(){return this.#e}get dataManager(){return this.#t}get data(){return this.#t.data}get row(){return this.#t.row}get customStyle(){return this.#i}scrollTo=(e,t)=>{this.#e.querySelectorAll(`nine-table-sheet.active`).forEach(n=>{n.scrollTo(e,t)})};currentRow=()=>{let e=this.currentRows();return e.length===0?-1:e[0]};currentRows=()=>{let e=[];return this.#e.querySelectorAll(`nine-table-sheet.active`).forEach(t=>{let n=t.view.getArray(t.selection.minRow).m._[i.META.INDEX.ROWID];e.push(n)}),e};addRow=(e,t=!0)=>this.data.add(e,t);insertRow=(e,t,n=!0)=>{let r=this.#e.querySelector(`nine-table-sheet.active`);if(!r)return;let a=r.view.get(e).m._[i.META.INDEX.ROWID],o=this.data.insert(a,t,n);return r.view.getArray().findIndex(e=>!e||!e.m||!e.m._?!1:e.m._[i.META.INDEX.ROWID]===o)};removeRow=e=>{let t=this.#e.querySelector(`nine-table-sheet.active`);if(!t)return;let n=t.view.get(e).m._[i.META.INDEX.ROWID];this.data.remove(n)};currentIndex=()=>{let e=this.currentIndexs();return e.length===0?-1:e[0]};currentIndexs=()=>{let e=[];return this.#e.querySelectorAll(`nine-table-sheet.active`).forEach(t=>{e.push(t.selection.minRow)}),e};addProvider(e){if(!e||typeof e!=`object`)return;let{style:t,...n}=e;if(t&&typeof t==`string`){this.#i=t;let e=this.#e.getElementById(`nine-table-scoped-custom-style`);e&&(e.textContent=t)}Object.keys(n).length>0&&setTimeout(()=>{Object.entries(n).forEach(([e,t])=>{typeof t==`function`&&(this[e]=t)}),this.rerenderer()})}setData(e){this.#t.data.set(e),this.refresh()}refresh(){this.activeSheet?.invalidate()}set loading(e){this.#n&&(this.#n.loading=e)}rerenderer(){this.activeSheet?.querySelectorAll(`tbody.body th,tbody.body td`).forEach(e=>{Array.from(e.children).find(e=>e.tagName.toLowerCase().startsWith(`cell-`)&&typeof e.rerenderer==`function`)?.rerenderer()})}sheet=e=>{if(e===null||e<0)return this.activeSheet;let t=Array.from(this.shadow.querySelectorAll(`nine-table-sheet`));return typeof e==`number`?t[e]||null:typeof e==`string`?this.shadow.querySelector(`nine-table-sheet#${e}, nine-table-sheet[data-sheet-id="${e}"]`)||null:t[0]||null};get sheets(){return Array.from(this.shadow.querySelectorAll(`nine-table-sheet`))}get activeSheet(){return this.shadow.querySelector(`nine-table-sheet.active`)||null}#o(){let e=new Set;this.querySelectorAll(`[data-source]`).forEach(t=>{let n=t.getAttribute(`data-source`);if(!n)return;let r=n.matchAll(/(?:host\.)?([a-zA-Z0-9_$]+)\s*\(/g);for(let t of r){let n=t[1];n&&n!==`host`&&e.add(n)}}),e.forEach(e=>{let t=null;Object.defineProperty(this,e,{set:e=>{t=e,this.rerenderer()},get:()=>t,configurable:!0,enumerable:!0})})}execute=e=>{setTimeout(()=>{this.loading=!0,setTimeout(()=>{try{e.call(this)}finally{this.loading=!1}})})}};customElements.get(`nine-table`)||customElements.define(`nine-table`,I),customElements.get(`nine-table-simple`)||customElements.define(`nine-table-simple`,class extends I{connectedCallback(){this.setAttribute(`theme`,`simple`),super.connectedCallback()}});var L=class extends HTMLElement{constructor(){super()}applyBaseStyle(){}connectedCallback(){}},R=new Map,z=class extends L{#e;#t;#n;#r;#i;constructor(){super()}get host(){return this.#e}get sheet(){return this.#t}get cell(){return this.#r}get tr(){return this.#n}get attr(){return this.#i}connectedCallback(){super.connectedCallback(),this.#e=this.getRootNode().host,this.#r=this.closest(`th,td`),this.#n=this.#r.closest(`tr`),this.#t=this.#n.closest(`nine-table-sheet`),this.#r.classList.add(this.tagName),this.#i={};for(let e=0;e<this.#r.attributes.length;e++){let t=this.#r.attributes[e].name;[`text-align`,`class`,`cell-type`,`data-bind`,`data-expr`,`data-col`,`tabindex`].includes(t)||(this.#i[t]=this.#r.attributes[e].value)}if(!this.#r)return;let e=this.shadowRoot||this;e.querySelectorAll(`button, ng-expand-button`).forEach(e=>{e.addEventListener(`click`,()=>{let e=this.getAttribute(`onbuttonclick`)||this.getAttribute(`onButtonClick`)||this.#r?.getAttribute(`onbuttonclick`)||this.#r?.getAttribute(`onButtonClick`),t=this.data,n=parseInt(this.#r.dataset.row,10);if(e&&this.#e){e=e.replace(`()`,``);let r=e.match(/^(\w+)\s*\(/)?.[1]||e;typeof this.#e[r]==`function`?this.#e[r].call(this.#e,t,n,this.#r):typeof this.#e.exprFunction==`function`&&this.#e.exprFunction(e).call(this,t,n)}})});let t=e.querySelector(`.renderer`);t&&this.getAttribute(`link`)===`true`&&(t.classList.add(`link`),t.addEventListener(`click`,()=>{let e=this.getAttribute(`onlinkclick`)||this.getAttribute(`onLinkClick`),t=this.data,n=parseInt(this.#r.dataset.row,10);if(e&&this.#e){e=e.replace(`()`,``);let r=e.match(/^(\w+)\s*\(/)?.[1]||e;typeof this.#e[r]==`function`?this.#e[r].call(this.#e,t,n,this.#r):typeof this.#e.exprFunction==`function`&&this.#e.exprFunction(e).call(this,t,n)}this.#e?.dispatchEvent(new CustomEvent(ninegrid.EVENT.LINK_CLICK,{detail:{target:this.#r,data:t,currow:n},bubbles:!0,composed:!0}))}))}get data(){let e=this.#n?.data;if(!e)return null;if(!e.v)return e;let t=this.#e;return new Proxy(e,{get(e,n){if(n===`__ng`)return e.__ng;if(n===`v`)return e.v;let r=t?.fields?.indexOf?.(n)??-1;return r>=0?e.v[r]:e[n]}})}get value(){if(!this.#r||!this.#n?.data)return``;let e=this.#r.dataset?.bind;if(!e)return``;let t=this.#n.data;if(t.v&&Array.isArray(t.v)){let n=this.#e.fields.get().indexOf(e)??-1;return n>=0?t.v[n]??``:``}return t[e]??``}set value(e){if(!this.#r||!this.#e?.data)return;let t=parseInt(this.#n.dataset.row,10),n=this.#r.dataset.bind;!isNaN(t)&&n&&this.#e.data.setValue(t,n,e)}get row(){return parseInt(this.#r?.dataset?.row,10)}get index(){return parseInt(this.#r?.dataset?.index,10)}isValid(){return!this.#r.classList.contains(`invalid`)}isInvalid(){return!this.isValid()}getDisplayText=(e=``)=>{if(!this.#r||!this.#r.closest(`tbody`)||!this.#n.data)return e;let t=this.#r.dataset.expr,n=this.#r.dataset.bind,r=parseInt(this.#r.dataset.row,10);if(t)try{return this.#n.getAttribute(`grouping`)===`true`?this.getGroupExprValue(t,this.#n.data,r,this.#r):this.#e.exprEngine.evaluate(t,this.#n.data,r)}catch{return e}return n?this.value??e:e};refresh(){if(!this.#r||!this.#n)return;let e=this.value;return this.#r.classList.remove(`invalid`),[`color`,`background`,`background-color`,`visible`,`enable`,`validator`].forEach(e=>{let t=this.#i[e];if(t){let n=this.#e.exprEngine.evaluate(t,this.#n.data,parseInt(this.#r.dataset.row,10));e===`validator`?n||this.#r.classList.add(`invalid`):e===`visible`?this.style.display=n?``:`none`:e===`enable`?(this.querySelectorAll(`input, button, textarea, select`).forEach(e=>{e.disabled=!n}),n?this.#r.removeAttribute(`disabled`):this.#r.setAttribute(`disabled`,`true`)):this.#r.style[e]=n}}),e}getExprValue(e,t,n){return!this.#e||!this.#e.exprEngine||e==null||e===``?e:this.#e.exprEngine.evaluate(e,t,n)}getGroupExprValue=(e,t,n,r)=>{if(!e)return``;try{n=parseInt(n,10);let i=e.replace(`()`,``).trim();if(this.#e&&typeof this.#e[i]==`function`)return this.#e[i].call(this,t,n,r);let a=i.match(/^(\w+)\s*\(\s*([\w\-]*)\s*\)/);if(a){let e=t[GROUP_IDX.CHILDREN],n=this.#e?.data?.getArray?this.#e.data.getArray():[],r=e?e.map(e=>n[e]).filter(Boolean):[],[,i,o]=a,s=this.#e;switch(i.toLowerCase()){case`count`:return r.length;case`sum`:{let e=s?.fields?.indexOf?.(o)??-1;return r.reduce((t,n)=>{let r=e>=0?n.v?.[e]:n[o];return t+(Number(r)||0)},0)}case`avg`:{if(r.length===0)return 0;let e=s?.fields?.indexOf?.(o)??-1;return r.reduce((t,n)=>{let r=e>=0?n.v?.[e]:n[o];return t+(Number(r)||0)},0)/r.length}}}if(this.#e&&typeof this.#e.exprFunction==`function`)return this.#e.exprFunction(e).call(this,t,n,this.#e.data);if(e.includes(`data.`)||e.includes(`childRecords`)||e.includes(`groupRecord`)){let i=R.get(`grp_`+e);return i||(i=Function(`groupRecord`,`row`,`cell`,`host`,`
105
106
  const indices = groupRecord[3]; // GROUP_IDX.CHILDREN = 3
106
107
  const allRecords = host?.data?.getArray ? host.data.getArray() : [];
107
108
 
@@ -197,14 +198,15 @@
197
198
  <span class="wrapper"></span>
198
199
  `}};customElements.get(`cell-renderer`)||customElements.define(`cell-renderer`,Y);var X=class extends z{#e;constructor(){super()}connectedCallback(){this.#n(),super.connectedCallback(),this.#e=this.querySelector(`button`),this.#e.removeEventListener(`click`,this.#t),this.#e.addEventListener(`click`,this.#t)}#t=e=>{e.stopPropagation();let t=parseInt(this.cell.dataset.row,10),n=new CustomEvent(i.EVENT.CELL_BUTTON_CLICK,{bubbles:!0,composed:!0,detail:{originalEvent:e,cell:this.cell,row:t,col:parseInt(this.cell.dataset.col,10),bind:this.dataset.bind,data:this.host.data.get(t),value:this.value}});this.dispatchEvent(n)};refresh=()=>{let e=super.refresh?super.refresh():this.value;this.#e.innerHTML=this.getDisplayText(e)};#n=()=>{this.innerHTML=`
199
200
  <button class="button">...</button>
200
- `}};customElements.get(`cell-button`)||customElements.define(`cell-button`,X);var Z=class extends z{#e;#t;#n;constructor(){super()}connectedCallback(){this.#r(),super.connectedCallback(),this.cell&&(this.cell.removeAttribute(`tabindex`),this.cell.dataset.bind=`rowState`),this.#e=this.querySelector(`.ng-row-main`),this.#t=this.querySelector(`.ng-row-sub`),this.#n=this.querySelector(`.ng-row-status`)}#r=()=>{this.innerHTML=`
201
+ `}};customElements.get(`cell-button`)||customElements.define(`cell-button`,X);var Z=class extends z{#e;#t;#n;constructor(){super()}connectedCallback(){this.#r(),super.connectedCallback(),this.cell&&(this.cell.removeAttribute(`tabindex`),this.cell.dataset.bind=`rowState`),this.#e=this.querySelector(`.ng-row-main`),this.#t=this.querySelector(`.ng-row-sub`),this.#n=this.querySelector(`.row-status`)}#r=()=>{this.innerHTML=`
201
202
  <span class="ng-row-main"></span>
202
203
  <span class="ng-row-sub"></span>
203
- <span class="ng-row-status"></span>
204
- `};refresh=()=>{if(!this.cell||!this.tr)return;let e=this.row;if(isNaN(e))return;let t=this.tr.data;t&&t.__ng;let n=this.index+1,r=n.toLocaleString();if(n>=1e4){let e=r.length-4,t=r.substring(0,e+1),n=r.substring(e+1);this.#e.innerHTML=`
204
+ <span class="row-status"></span>
205
+ `};refresh=()=>{if(!this.cell||!this.tr)return;this.classList.remove(`is-insert`,`is-update`,`is-delete`);let e=this.row;if(isNaN(e))return;let t=this.tr.data;if(t)switch(t.m._[i.META.INDEX.ROW_STATE]){case i.ROW_STATE.INSERT:this.classList.add(`is-insert`);break;case i.ROW_STATE.UPDATE:this.classList.add(`is-update`);break;case i.ROW_STATE.DELETE:this.classList.add(`is-delete`)}let n=this.index+1,r=n.toLocaleString();if(n>=1e4){let e=r.length-4,t=r.substring(0,e+1),n=r.substring(e+1);this.#e.innerHTML=`
205
206
  <span class="ng-row-prefix">${t}</span>
206
207
  <span class="ng-row-suffix">${n}</span>
207
- `}else this.#e.innerHTML=`${r}`;let i=!!this.sheet.querySelector(`thead .asc,thead .desc`),a=!!this.sheet.querySelector(`thead nine-table-filter-button.filtered`);this.#t.innerHTML=e,this.#t.style.display=i||a?``:`none`}};customElements.get(`cell-row-indicator`)||customElements.define(`cell-row-indicator`,Z);var Q=class extends HTMLElement{#e;#t;constructor(){super()}connectedCallback(){this.#t=this.closest(`th, td`),this.#e=this.closest(`nine-table-sheet`),this.#t&&(this.#t.style.position=`relative`),this.getAttribute(`collapsed`)===`true`||this.#t?.getAttribute(`collapsed`)===`true`?requestAnimationFrame(()=>{this.collapse(!0)}):(this.classList.remove(`collapsed`),this.classList.add(`expand`)),this.removeEventListener(`click`,this.#n),this.addEventListener(`click`,this.#n)}#n=e=>{e.preventDefault(),e.stopPropagation(),this.classList.contains(`expand`)?this.collapse():this.expand()};expand=()=>{if(!this.#e?.colResizer||!this.#t)return;let e=parseInt(this.#t.dataset.col,10),t=this.#t.colSpan||1;this.classList.remove(`collapsed`),this.classList.add(`expand`),this.#t.setAttribute(`collapsed`,`false`),this.#t.style.color=``;let n=parseInt(this.#t.dataset.expandWidth,10)||100;if(t===1)this.#e.colResizer.setColumnWidth(e,n);else{let r=Math.max(30,Math.floor(n/t));for(let n=0;n<t;n++)this.#e.colResizer.setColumnWidth(e+n,r)}requestAnimationFrame(()=>{typeof this.#e.refreshLayout==`function`&&this.#e.refreshLayout()})};collapse=(e=!1)=>{if(!this.#e?.colResizer||!this.#t)return;let t=parseInt(this.#t.dataset.col,10),n=this.#t.colSpan||1;if(this.classList.contains(`expand`)){let e=this.#e.querySelector(`colgroup col[data-col="${t}"]`),r=e?parseInt(e.getAttribute(`width`),10):0;r>16&&(this.#t.dataset.expandWidth=String(r*n))}if(this.classList.remove(`expand`),this.classList.add(`collapsed`),this.#t.setAttribute(`collapsed`,`true`),this.#t.style.color=`transparent`,n===1)this.#e.colResizer.setColumnWidth(t,16);else{let e=Math.max(10,Math.floor(16/n));for(let r=0;r<n;r++)this.#e.colResizer.setColumnWidth(t+r,e)}requestAnimationFrame(()=>{typeof this.#e.refreshLayout==`function`&&this.#e.refreshLayout()})};disconnectedCallback(){this.removeEventListener(`click`,this.#n)}};customElements.get(`nine-table-col-expand`)||customElements.define(`nine-table-col-expand`,Q);var $=class extends HTMLElement{#e;#t;connectedCallback(){let e=this.getRootNode();this.#e=e instanceof ShadowRoot?e.host:this.closest(`nine-table`)||e.host,this.#e||=this.parentElement?.closest(`nine-table`)||this.assignedSlot?.closest(`nine-table`),this.#e}#n=e=>{let t=e.composedPath?e.composedPath():[],n=t.find(e=>e.tagName===`TH`||e.tagName===`TD`);if(!n)return;let r=t.find(e=>e.tagName===`TABLE`)||n.closest(`table`);e.preventDefault(),e.stopPropagation(),this.openMenu(e.clientX,e.clientY,n,r)};#r(e){return e?.closest(`nine-table-sheet`)||this.#e.activeSheet||this.#e}#i(e){let t=this.#r(e);return t?(t.colFix||=new E(t),t.colFix):null}#a(e,t){let n=[],r=t?.id;return Array.from(e.querySelectorAll(`:scope > ul`)).forEach(e=>{let t=e.getAttribute(`target-table`);if(!t||r&&t===r){let t=this.#o(e);n.push(...t)}}),n}#o(e){let t=[];return Array.from(e.children).forEach(e=>{let n=e.tagName.toLowerCase();if(n===`hr`||e.classList.contains(`separator`))t.push({type:`separator`});else if(n===`li`){let n=``,r=e.querySelector(`:scope > span`);n=r?r.textContent.trim():Array.from(e.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.textContent.trim()).join(``);let i=e.querySelector(`:scope > ul`),a={menuId:e.id||n,name:n,className:e.className||``,disabled:e.hasAttribute(`disabled`)||e.getAttribute(`disabled`)===`true`,isCustom:!0};i&&(a.items=this.#o(i)),t.push(a)}}),t}#s(e,t,n){let r=this.getAttribute(`use-default-menu`)!==`false`,i=[],a=this.#a(this,e);a.length>0&&i.push(...a);let o=this.#i(n),s=o?.getFixState(n,e)??`none`,c=t&&(o?.canFixColumn(n,e)??!1),l=null;l=s===`left`||s===`right`?{menuId:`unfix-column`,name:`Unfix Column`,className:`ng-menu-unfix-col`,disabled:!t}:{menuId:`fix-column`,name:`Fix Column`,className:`ng-menu-fix-col`,disabled:!c},r&&i.push({type:`separator`},{menuId:`sort`,name:`Sort`,className:`ng-menu-sort`,disabled:!t},l,{type:`separator`},{menuId:`filtering`,name:`Filtering`,className:`ng-menu-filtering`},{menuId:`maximize`,name:`Maximize`,className:`maximize`},{menuId:`export`,name:`Export`,className:`export`,items:[{menuId:`export-excel`,name:`Excel`,className:`export-excel`},{menuId:`export-pdf`,name:`PDF`,className:`export-pdf`,disabled:!0}]},{menuId:`properties`,name:`Options`,className:`options`,items:[{menuId:`show-title-bar`,name:`Title Bar Show/Hide`,className:`show-title-bar`},{menuId:`show-status-bar`,name:`Status Bar Show/Hide`,className:`show-status-bar`},{menuId:`auto-fit-col`,name:`Auto Fit Columns`,className:`auto-fit-col`}]});let u=[];return i.forEach(e=>{(e.type!==`separator`||u.length!==0&&u[u.length-1].type!==`separator`)&&u.push(e)}),u.length>0&&u[u.length-1].type===`separator`&&u.pop(),u}openMenu(e,t,n,r){let i=this.#e.shadowRoot||this.#e;this.#t||(this.#t=document.createElement(`nine-table-menu-panel`),i.appendChild(this.#t));let a=!!n.closest(`thead`),o=this.#s(r,a,n);this.#t.render(o,e=>this.#l(e,n,r));let s=this.#r(n);this.#c(s),this.#t.openAt(e,t)}#c(e){if(!this.#t||!e)return;let t=e.filtering?.isFiltering?.()||!1;this.#t.toggleItemState(`filtering`,`on`,t);let n=this.#e.getAttribute(`auto-fit-col`)===`true`;this.#t.toggleItemState(`auto-fit-col`,`on`,n);let r=this.#e.getAttribute(`show-title-bar`)===`true`;this.#t.toggleItemState(`show-title-bar`,`on`,r)}#l(e,t,n){let r=e.menuId,i=new CustomEvent(`menu-click`,{detail:{menuId:r,targetCell:t,targetTable:n,originalEvent:e},bubbles:!0,composed:!0});this.dispatchEvent(i);let a=parseInt(t.dataset.col,10),o=this.#r(t);switch(r){case`fix-column`:case`unfix-column`:this.#i(t)?.executeFixToggle(r,t);break;case`sort`:isNaN(a)||o.sorting?.handleSortFromMenu?.(a,t);break;case`filtering`:o?.filtering?.toggle();break;case`auto-fit-col`:this.#e.setAttribute(`auto-fit-col`,this.#e.getAttribute(`auto-fit-col`)===`true`?`false`:`true`);break;case`show-title-bar`:this.#e.setAttribute(`show-title-bar`,this.#e.getAttribute(`show-title-bar`)===`true`?`false`:`true`)}this.#t.close()}disconnectedCallback(){this.#e?.removeEventListener(`contextmenu`,this.#n)}};customElements.get(`nine-table-menu`)||customElements.define(`nine-table-menu`,$);var ee=class extends HTMLElement{#e;#t=null;constructor(){super()}connectedCallback(){this.style.position=`fixed`,this.style.display=`none`,this.style.zIndex=`99999`,this.innerHTML=`
208
+ <div class="row-status"></div>
209
+ `}else this.#e.innerHTML=`${r}`;let a=!!this.sheet.querySelector(`thead .asc,thead .desc`),o=!!this.sheet.querySelector(`thead nine-table-filter-button.filtered`);this.#t.innerHTML=e,this.#t.style.display=a||o?``:`none`}};customElements.get(`cell-row-indicator`)||customElements.define(`cell-row-indicator`,Z);var Q=class extends HTMLElement{#e;#t;constructor(){super()}connectedCallback(){this.#t=this.closest(`th, td`),this.#e=this.closest(`nine-table-sheet`),this.#t&&(this.#t.style.position=`relative`),this.getAttribute(`collapsed`)===`true`||this.#t?.getAttribute(`collapsed`)===`true`?requestAnimationFrame(()=>{this.collapse(!0)}):(this.classList.remove(`collapsed`),this.classList.add(`expand`)),this.removeEventListener(`click`,this.#n),this.addEventListener(`click`,this.#n)}#n=e=>{e.preventDefault(),e.stopPropagation(),this.classList.contains(`expand`)?this.collapse():this.expand()};expand=()=>{if(!this.#e?.colResizer||!this.#t)return;let e=parseInt(this.#t.dataset.col,10),t=this.#t.colSpan||1;this.classList.remove(`collapsed`),this.classList.add(`expand`),this.#t.setAttribute(`collapsed`,`false`),this.#t.style.color=``;let n=parseInt(this.#t.dataset.expandWidth,10)||100;if(t===1)this.#e.colResizer.setColumnWidth(e,n);else{let r=Math.max(30,Math.floor(n/t));for(let n=0;n<t;n++)this.#e.colResizer.setColumnWidth(e+n,r)}requestAnimationFrame(()=>{typeof this.#e.refreshLayout==`function`&&this.#e.refreshLayout()})};collapse=(e=!1)=>{if(!this.#e?.colResizer||!this.#t)return;let t=parseInt(this.#t.dataset.col,10),n=this.#t.colSpan||1;if(this.classList.contains(`expand`)){let e=this.#e.querySelector(`colgroup col[data-col="${t}"]`),r=e?parseInt(e.getAttribute(`width`),10):0;r>16&&(this.#t.dataset.expandWidth=String(r*n))}if(this.classList.remove(`expand`),this.classList.add(`collapsed`),this.#t.setAttribute(`collapsed`,`true`),this.#t.style.color=`transparent`,n===1)this.#e.colResizer.setColumnWidth(t,16);else{let e=Math.max(10,Math.floor(16/n));for(let r=0;r<n;r++)this.#e.colResizer.setColumnWidth(t+r,e)}requestAnimationFrame(()=>{typeof this.#e.refreshLayout==`function`&&this.#e.refreshLayout()})};disconnectedCallback(){this.removeEventListener(`click`,this.#n)}};customElements.get(`nine-table-col-expand`)||customElements.define(`nine-table-col-expand`,Q);var $=class extends HTMLElement{#e;#t;connectedCallback(){let e=this.getRootNode();this.#e=e instanceof ShadowRoot?e.host:this.closest(`nine-table`)||e.host,this.#e||=this.parentElement?.closest(`nine-table`)||this.assignedSlot?.closest(`nine-table`),this.#e}#n=e=>{let t=e.composedPath?e.composedPath():[],n=t.find(e=>e.tagName===`TH`||e.tagName===`TD`);if(!n)return;let r=t.find(e=>e.tagName===`TABLE`)||n.closest(`table`);e.preventDefault(),e.stopPropagation(),this.openMenu(e.clientX,e.clientY,n,r)};#r(e){return e?.closest(`nine-table-sheet`)||this.#e.activeSheet||this.#e}#i(e){let t=this.#r(e);return t?(t.colFix||=new E(t),t.colFix):null}#a(e,t){let n=[],r=t?.id;return Array.from(e.querySelectorAll(`:scope > ul`)).forEach(e=>{let t=e.getAttribute(`target-table`);if(!t||r&&t===r){let t=this.#o(e);n.push(...t)}}),n}#o(e){let t=[];return Array.from(e.children).forEach(e=>{let n=e.tagName.toLowerCase();if(n===`hr`||e.classList.contains(`separator`))t.push({type:`separator`});else if(n===`li`){let n=``,r=e.querySelector(`:scope > span`);n=r?r.textContent.trim():Array.from(e.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.textContent.trim()).join(``);let i=e.querySelector(`:scope > ul`),a={menuId:e.id||n,name:n,className:e.className||``,disabled:e.hasAttribute(`disabled`)||e.getAttribute(`disabled`)===`true`,isCustom:!0};i&&(a.items=this.#o(i)),t.push(a)}}),t}#s(e,t,n){let r=this.getAttribute(`use-default-menu`)!==`false`,i=[],a=this.#a(this,e);a.length>0&&i.push(...a);let o=this.#i(n),s=o?.getFixState(n,e)??`none`,c=t&&(o?.canFixColumn(n,e)??!1),l=null;l=s===`left`||s===`right`?{menuId:`unfix-column`,name:`Unfix Column`,className:`ng-menu-unfix-col`,disabled:!t}:{menuId:`fix-column`,name:`Fix Column`,className:`ng-menu-fix-col`,disabled:!c},r&&i.push({type:`separator`},{menuId:`sort`,name:`Sort`,className:`ng-menu-sort`,disabled:!t},l,{type:`separator`},{menuId:`filtering`,name:`Filtering`,className:`ng-menu-filtering`},{menuId:`maximize`,name:`Maximize`,className:`maximize`},{menuId:`export`,name:`Export`,className:`export`,items:[{menuId:`export-excel`,name:`Excel`,className:`export-excel`},{menuId:`export-pdf`,name:`PDF`,className:`export-pdf`,disabled:!0}]},{menuId:`properties`,name:`Options`,className:`options`,items:[{menuId:`show-title-bar`,name:`Title Bar Show/Hide`,className:`show-title-bar`},{menuId:`show-status-bar`,name:`Status Bar Show/Hide`,className:`show-status-bar`},{menuId:`auto-fit-col`,name:`Auto Fit Columns`,className:`auto-fit-col`}]});let u=[];return i.forEach(e=>{(e.type!==`separator`||u.length!==0&&u[u.length-1].type!==`separator`)&&u.push(e)}),u.length>0&&u[u.length-1].type===`separator`&&u.pop(),u}openMenu(e,t,n,r){let i=this.#e.shadowRoot||this.#e;this.#t||(this.#t=document.createElement(`nine-table-menu-panel`),i.appendChild(this.#t));let a=!!n.closest(`thead`),o=this.#s(r,a,n);this.#t.render(o,e=>this.#l(e,n,r));let s=this.#r(n);this.#c(s),this.#t.openAt(e,t)}#c(e){if(!this.#t||!e)return;let t=e.filtering?.isFiltering?.()||!1;this.#t.toggleItemState(`filtering`,`on`,t);let n=this.#e.getAttribute(`auto-fit-col`)===`true`;this.#t.toggleItemState(`auto-fit-col`,`on`,n);let r=this.#e.getAttribute(`show-title-bar`)===`true`;this.#t.toggleItemState(`show-title-bar`,`on`,r)}#l(e,t,n){let r=e.menuId,i=new CustomEvent(`menu-click`,{detail:{menuId:r,targetCell:t,targetTable:n,originalEvent:e},bubbles:!0,composed:!0});this.dispatchEvent(i);let a=parseInt(t.dataset.col,10),o=this.#r(t);switch(r){case`fix-column`:case`unfix-column`:this.#i(t)?.executeFixToggle(r,t);break;case`sort`:isNaN(a)||o.sorting?.handleSortFromMenu?.(a,t);break;case`filtering`:o?.filtering?.toggle();break;case`auto-fit-col`:this.#e.setAttribute(`auto-fit-col`,this.#e.getAttribute(`auto-fit-col`)===`true`?`false`:`true`);break;case`show-title-bar`:this.#e.setAttribute(`show-title-bar`,this.#e.getAttribute(`show-title-bar`)===`true`?`false`:`true`)}this.#t.close()}disconnectedCallback(){this.#e?.removeEventListener(`contextmenu`,this.#n)}};customElements.get(`nine-table-menu`)||customElements.define(`nine-table-menu`,$);var ee=class extends HTMLElement{#e;#t=null;constructor(){super()}connectedCallback(){this.style.position=`fixed`,this.style.display=`none`,this.style.zIndex=`99999`,this.innerHTML=`
208
210
  <div class="menu-wrapper">
209
211
  <ul class="menu-container"></ul>
210
212
  </div>