@ninebone/datagrid 0.0.23 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,ROW_STATE:1,FILTER:2,GROUP:3}},ROW_STATE:{EMPTY:0,NORMAL:1,INSERT:2,UPDATE:3,DELETE:9},EVENT:{LOAD:`load`,ROW_ADDED:`row-added`,ROW_REMOVED:`row-removed`,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),r=this.#l(n);this.#t.rawRecords=this.#t.rawRecords.concat(r);let a=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(),this.#e.dispatchEvent(new CustomEvent(i.EVENT.ROW_ADDED,{bubbles:!0,detail:{target:this.#e,rowid:r.length>0?r[0].m._[i.META.INDEX.ROWID]:null}})),a};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(),this.#e.dispatchEvent(new CustomEvent(i.EVENT.ROW_ADDED,{bubbles:!0,detail:{target:this.#e,rowid:o.length>0?o[0].m._[i.META.INDEX.ROWID]:null}})),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(),this.#e.dispatchEvent(new CustomEvent(i.EVENT.ROW_REMOVED,{bubbles:!0,detail:{target:this.#e,rowid:t.length>0?t[0]:null}}))};setValue=(e,t,n)=>{e=parseInt(e,10);let r=this.getHostFields().indexOf(t);if(r<0)return;let a=this.#u(e),o=this.#t.rawRecords[a];o&&(o.v[r]!==n&&o.m._[i.META.INDEX.ROW_STATE]!==i.ROW_STATE.INSERT&&(o.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.UPDATE),o.v[r]=n)};getChangedData=e=>{let t=this.#t.rawRecords;return e?this.#d(t.filter(t=>t.m._[i.META.INDEX.ROW_STATE]===e)):{C:this.#d(t.filter(e=>e.m._[i.META.INDEX.ROW_STATE]===i.ROW_STATE.INSERT)),U:this.#d(t.filter(e=>e.m._[i.META.INDEX.ROW_STATE]===i.ROW_STATE.UPDATE)),D:this.#d(t.filter(e=>e.m._[i.META.INDEX.ROW_STATE]===i.ROW_STATE.DELETE))}};#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.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`,ROW_ADDED:`row-added`,ROW_REMOVED:`row-removed`,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),r=this.#l(n);this.#t.rawRecords=this.#t.rawRecords.concat(r);let a=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(),this.#e.dispatchEvent(new CustomEvent(i.EVENT.ROW_ADDED,{bubbles:!0,detail:{target:this.#e,rowid:r.length>0?r[0].m._[i.META.INDEX.ROWID]:null}})),a};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(),this.#e.dispatchEvent(new CustomEvent(i.EVENT.ROW_ADDED,{bubbles:!0,detail:{target:this.#e,rowid:o.length>0?o[0].m._[i.META.INDEX.ROWID]:null}})),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(),this.#e.dispatchEvent(new CustomEvent(i.EVENT.ROW_REMOVED,{bubbles:!0,detail:{target:this.#e,rowid:t.length>0?t[0]:null}}))};setValue=(e,t,n,r=!0)=>{e=parseInt(e,10);let a=this.getHostFields().indexOf(t);if(a<0)return;let o=this.#u(e),s=this.#t.rawRecords[o];s&&(s.v[a]!==n&&r&&s.m._[i.META.INDEX.ROW_STATE]!==i.ROW_STATE.INSERT&&(s.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.UPDATE),s.v[a]=n)};getChangedData=e=>{let t=this.#t.rawRecords;return e?this.#d(t.filter(t=>t.m._[i.META.INDEX.ROW_STATE]===e)):{C:this.#d(t.filter(e=>e.m._[i.META.INDEX.ROW_STATE]===i.ROW_STATE.INSERT)),U:this.#d(t.filter(e=>e.m._[i.META.INDEX.ROW_STATE]===i.ROW_STATE.UPDATE)),D:this.#d(t.filter(e=>e.m._[i.META.INDEX.ROW_STATE]===i.ROW_STATE.DELETE))}};#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.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=null;#o=0;#s;#c=!1;#l=!1;constructor(e){this.#t=e.getRootNode().host,this.#n=e,this.#y()}getRowHeight(){return this.#n.template.height}refresh=(e=!1)=>{if(!this.#n.classList.contains(`active`))return;let t=this.#n.querySelector(`.ng-sheet-body`);t&&((!this.#n.template.height||this.#n.template.height<=0)&&(this.#m(),this.#n.template.height&&this.#n.template.height>0&&this.#g()),this.#u(t.scrollTop,e),this.#n.querySelector(`nine-table-vscrollbar`)?.refresh())};#u=(e,t=!1)=>{if(this.#l){this.#d(e,t);return}let n=this.#n.template.height;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.elements.body.thead?.offsetHeight||0)+(this.#n.elements.body.tfoot?.offsetHeight||0)+this.#n.elements.body.tbody.head.offsetHeight,s=this.#n.querySelector(`.ng-sheet-body`).offsetHeight||0,c=Math.max(a*n-(s-o-n)-n,0),l=15e6,u=c>l,d=1,f=c;u&&(d=l/c,f=l),this.#n.elements.scrollHolder.style.height=`${f}px`;let p=u?e/d:e,m=Math.max(0,a-1),h=Math.min(p,c),g=Math.max(0,Math.min(Math.floor(h/n),m));this.#n.elements.left.tbody.body.style.transform=this.#n.elements.body.tbody.body.style.transform=this.#n.elements.right.tbody.body.style.transform=`translate3d(0px, -${h%n}px, 0px)`;let _=this.#r.firstTr,v=_&&_.dataset.row!==void 0?parseInt(_.dataset.row,10):-1;(t||v!==g)&&([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=g+Math.floor(t/this.#n.template.length);if(n>=a){e.style.display=`none`,e.dataset.matrixRow=null,e.dataset.row=null,e.dataset.index=null;return}let o=r[n];if(!o){e.style.display=`none`;return}let s=o.m._[i.META.INDEX.ROWID];e.style.display=``,this.#p(e,o,s,n)})}),this.#n.selection.refresh())};#d=(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.#n.template.height[t]||this.#n.template.height/a}{let e=0,t=this.#n.templateLength||1,n=0;for(let e=0;e<t-1;e++)n+=this.#n.template.heights[e]||0;return e=this.#n.template.height-n,e>0?e:this.#n.template.height}},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.#n.template.height/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.#f(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.#p(e,i.record,t,a)}})}}),this.#n.selection.refresh()};#f=(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()})};#p=(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.#l=!!this.#n.sourceTable.querySelector(`tbody tr[grouping='true']`),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.#o=e.clientHeight,this.#m(),this.#g(),this.#u(e.scrollTop,!0),e.addEventListener(`scroll`,t=>{if(this.#c)return;let n=this.#n.template.height||0;(this.#n.view.getArray()?.length||0)*n<=e.clientHeight||(this.#u(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.#l){let e=Math.max(r.scrollHeight-r.clientHeight,1);o=a/Math.max(i-1,1)*e}else{let e=this.#n.template.height,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.#c=!0,r.scrollTop=o,this.#u(o),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#c=!1,typeof n==`function`&&n()})})}destroy=()=>{this.#a&&=(this.#a.disconnect(),null)};#m=()=>{};#h=()=>{if(this.#o>0&&this.#n.template.height>0){let e=Math.ceil(this.#o/this.#n.template.height),t=this.#e;if(this.#l&&this.#n.grouping){let e=this.#n.grouping.columns?.length||1;t+=e*15}this.#s=e+t}};#g=()=>{[`.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.#_(t)}),this.#v()};#_=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.#s;e++)n.forEach(e=>i.appendChild(e.cloneNode(!0)));r.appendChild(i),e.classList.contains(`ng-container-body`)&&(this.#r.firstTr=r.querySelector(`tr`))};#v=()=>{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`))}}};#y=()=>{this.#n&&this.#n instanceof HTMLElement&&(this.#a=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.#o!==e&&(this.#o=e,this.#h(),this.#n.template.height!==null&&(this.#g(),this.refresh()))}}),this.#a.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(a=>{let{matrixRow:o}=this.#n(a);o<0||(o>=e&&o<=n&&i.querySelectorAll(`tbody tr[data-index="${a.dataset.index}"]`).forEach(e=>{e.classList.add(`selected`)}),a.querySelectorAll(`td, th`).forEach(i=>{let a=parseInt(i.dataset.col,10);if(isNaN(a))return;let s=parseInt(i.rowSpan||1,10),c=parseInt(i.colSpan||1,10),l=o+s-1,u=a+c-1;l>=e&&o<=n&&u>=t&&a<=r&&(i.classList.add(`selected`),o<=e&&i.classList.add(`selected-top`),l>=n&&i.classList.add(`selected-bottom`),a<=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&&(t.querySelector(`cell-row-indicator`)?this.#e.row.focus(t.dataset.index):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=null;#o=0;#s;#c=!1;#l=!1;constructor(e){this.#t=e.getRootNode().host,this.#n=e,this.#y()}getRowHeight(){return this.#n.template.height}refresh=(e=!1)=>{if(!this.#n.classList.contains(`active`))return;let t=this.#n.querySelector(`.ng-sheet-body`);t&&((!this.#n.template.height||this.#n.template.height<=0)&&(this.#m(),this.#n.template.height&&this.#n.template.height>0&&this.#g()),this.#u(t.scrollTop,e),this.#n.querySelector(`nine-table-vscrollbar`)?.refresh())};#u=(e,t=!1)=>{if(this.#l){this.#d(e,t);return}let n=this.#n.template.height;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.elements.body.thead?.offsetHeight||0)+(this.#n.elements.body.tfoot?.offsetHeight||0)+this.#n.elements.body.tbody.head.offsetHeight,s=this.#n.querySelector(`.ng-sheet-body`).offsetHeight||0,c=Math.max(a*n-(s-o-n)-n,0),l=15e6,u=c>l,d=1,f=c;u&&(d=l/c,f=l),this.#n.elements.scrollHolder.style.height=`${f}px`;let p=u?e/d:e,m=Math.max(0,a-1),h=Math.min(p,c),g=Math.max(0,Math.min(Math.floor(h/n),m));this.#n.elements.left.tbody.body.style.transform=this.#n.elements.body.tbody.body.style.transform=this.#n.elements.right.tbody.body.style.transform=`translate3d(0px, -${h%n}px, 0px)`;let _=this.#r.firstTr,v=_&&_.dataset.row!==void 0?parseInt(_.dataset.row,10):-1;(t||v!==g)&&([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=g+Math.floor(t/this.#n.template.length);if(n>=a){e.style.display=`none`,e.dataset.matrixRow=null,e.dataset.row=null,e.dataset.index=null;return}let o=r[n];if(!o){e.style.display=`none`;return}let s=o.m._[i.META.INDEX.ROWID];e.style.display=``,this.#p(e,o,s,n)})}),this.#n.selection.refresh())};#d=(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.#n.template.height[t]||this.#n.template.height/a}{let e=0,t=this.#n.templateLength||1,n=0;for(let e=0;e<t-1;e++)n+=this.#n.template.heights[e]||0;return e=this.#n.template.height-n,e>0?e:this.#n.template.height}},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.#n.template.height/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.#f(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.#p(e,i.record,t,a)}})}}),this.#n.selection.refresh()};#f=(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()})};#p=(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.#l=!!this.#n.sourceTable.querySelector(`tbody tr[grouping='true']`),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.#o=e.clientHeight,this.#m(),this.#g(),this.#u(e.scrollTop,!0),e.addEventListener(`scroll`,t=>{if(this.#n.querySelectorAll(`cell-combo-panel`).forEach(e=>{e.classList.remove(`active`)}),this.#c)return;let n=this.#n.template.height||0;(this.#n.view.getArray()?.length||0)*n<=e.clientHeight||(this.#u(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.#l){let e=Math.max(r.scrollHeight-r.clientHeight,1);o=a/Math.max(i-1,1)*e}else{let e=this.#n.template.height,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.#c=!0,r.scrollTop=o,this.#u(o),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#c=!1,typeof n==`function`&&n()})})}destroy=()=>{this.#a&&=(this.#a.disconnect(),null)};#m=()=>{this.#h()};#h=()=>{if(this.#o>0&&this.#n.template.height>0){let e=Math.ceil(this.#o/this.#n.template.height),t=this.#e;if(this.#l&&this.#n.grouping){let e=this.#n.grouping.columns?.length||1;t+=e*15}this.#s=e+t}};#g=()=>{[`.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.#_(t)}),this.#v()};#_=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`);r.querySelectorAll(`tr`).forEach(e=>e.remove());let i=document.createDocumentFragment();for(let e=0;e<this.#s;e++)n.forEach(e=>i.appendChild(e.cloneNode(!0)));r.appendChild(i),e.classList.contains(`ng-container-body`)&&(this.#r.firstTr=r.querySelector(`tr`))};#v=()=>{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`))}}};#y=()=>{this.#n&&this.#n instanceof HTMLElement&&(this.#a=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.#o!==e&&(this.#o=e,this.#h(),this.#n.template.height!==null&&(this.#g(),this.refresh()))}}),this.#a.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;#n={startRow:-1,startCol:-1,endRow:-1,endCol:-1};constructor(e){this.#e=e,this.#t=e.getRootNode().host,this.#i()}#r(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);this.#t.tagName===`NINE-TABLE-SIMPLE`&&(o=1,s=10);let 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.#r(e);t<0||e.querySelectorAll(`td, th`).forEach(e=>{let n=parseInt(e.dataset.col,10);if(!isNaN(n)&&this.#e.querySelector(`col[data-col="${n}"]`).style.display!==`none`){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)}}})})});let d=e=>Number.isFinite(e)?e:-1;this.#n={startRow:d(i),startCol:d(o),endRow:d(a),endCol:d(s)},this.render()}clear=()=>{this.#n={startRow:-1,startCol:-1,endRow:-1,endCol:-1}};get minRow(){return this.#n.startRow}get maxRow(){return this.#n.endRow}get minCol(){return this.#n.startCol}get maxCol(){return this.#n.endCol}refresh=()=>{this.render()};render=()=>{let{startRow:e,startCol:t,endRow:n,endCol:r}=this.#n,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(a=>{let{matrixRow:o}=this.#r(a);o<0||(o>=e&&o<=n&&i.querySelectorAll(`tbody tr[data-index="${a.dataset.index}"]`).forEach(e=>{e.classList.add(`selected`)}),a.querySelectorAll(`td, th`).forEach(i=>{let a=parseInt(i.dataset.col,10);if(isNaN(a))return;let s=parseInt(i.rowSpan||1,10),c=parseInt(i.colSpan||1,10),l=o+s-1,u=a+c-1;l>=e&&o<=n&&u>=t&&a<=r&&(i.classList.add(`selected`),o<=e&&i.classList.add(`selected-top`),l>=n&&i.classList.add(`selected-bottom`),a<=t&&i.classList.add(`selected-left`),u>=r&&i.classList.add(`selected-right`))}))})})};#i(){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.#r(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.#r(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)&&this.#p(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&&(t.querySelector(`cell-row-indicator`)?this.#e.row.focus(t.dataset.index):this.currentCell=t)}),this.#e.addEventListener(`keydown`,e=>{let t=e.target.closest(`td,th`);t&&this.#e.contains(t)&&(this.#t.tagName===`NINE-TABLE-SIMPLE`?[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`].includes(e.code)&&this.moveCell(e):[`Enter`,`Tab`,`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`].includes(e.code)?this.moveCell(e):[`Space`].includes(e.code)&&e.preventDefault())})}},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=>{})})}))})}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(t)}#a(e){this.#e.view.setSorting(this.#n),this.#o(),this.#e.invalidate(),requestAnimationFrame(()=>{let t=this.#e.querySelectorAll(`tbody.body th, tbody.body td`);t.forEach(t=>{t.classList.remove(`sorting-anim-asc`,`sorting-anim-desc`,`sorting-anim-none`),e.classList.contains(`asc`)?t.classList.add(`sorting-anim-asc`):e.classList.contains(`desc`)?t.classList.add(`sorting-anim-desc`):t.classList.add(`sorting-anim-none`)}),requestAnimationFrame(()=>{t.forEach(e=>{e.classList.remove(`sorting-anim-asc`,`sorting-anim-desc`,`sorting-anim-none`)})})})}#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{#e;#t;constructor(e){this.#e=e,this.#t=e.getRootNode().host}row={at:()=>Math.floor(this.#e.selection.minRow/this.#e.template.length),focus:e=>{this.#e.row.isVisible(e)||this.#e.row.moveTo(e);let t=this.#e.querySelectorAll(`tbody.body tr[data-index="${e}"]`),n=Array.from(t,e=>parseInt(e.dataset.matrixRow,10)).filter(e=>!isNaN(e)),r=[];return t.forEach(e=>{e.querySelectorAll(`td, th`).forEach(e=>{parseInt(e.dataset.col,10)!=0&&r.push(parseInt(e.dataset.col,10))})}),this.#e.selection.setRange(Math.min(...n),Math.min(...r),Math.max(...n),Math.max(...r))},isVisible:e=>{let t=this.#e.querySelector(`.ng-sheet-body`),n=t.querySelectorAll(`.ng-container-body tbody.body tr[data-index="${e}"]`);if(!n||n.length===0)return!1;let r=t.getBoundingClientRect(),i=t.querySelector(`thead`)?.offsetHeight||0,a=t.querySelector(`tfoot`)?.offsetHeight||0,o=r.top+i,s=r.bottom-a,c=!0;for(let e of n){let t=e.getBoundingClientRect(),n=t.top<o,r=t.bottom>s;if(n||r){c=!1;break}}return c},add:(e,t)=>this.#t.data.add(e,t),moveTo:(e,t)=>{this.#e.row.isVisible(e)||this.#e.scrollTo(e,t)},insert:(e,t,n=!0)=>{let r=this.#e.view.get(e).m._[i.META.INDEX.ROWID],a=this.#t.data.insert(r,t,n);return this.#e.view.getArray().findIndex(e=>!e||!e.m||!e.m._?!1:e.m._[i.META.INDEX.ROWID]===a)},remove:e=>{let t=this.#e.view.get(e).m._[i.META.INDEX.ROWID];this.#t.data.remove(t)}}},P=class extends HTMLElement{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p={table:null};#m;#h={length:0,height:0,heights:[]};static SCROLLBAR_SIZE=16;constructor(){super(),this.#t=this.getRootNode().host,this.#n=new v(this),this.#d=new N(this),this.#D()}connectedCallback(){this.#S()}get template(){return this.#h}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.#p.tbody.tr.length||0}get elements(){return this.#m}get isAutoFitCol(){let e=this.getAttribute(`auto-fit-col`)===`true`||this.#t?.getAttribute(`auto-fit-col`)===`true`,t=this.#p.table?.getAttribute(`auto-fit-col`)===`true`;return e||t}get sourceTable(){return this.#p.table}get source(){return this.#p}get#g(){return this.#t.hasAttribute(`simple`)||this.#t.getAttribute(`theme`)===`simple`}scrollTo=(e,t)=>{this.rowManager.scrollToDataRow(e,`top`,t)};recompileAndRefresh(){this.#p.table&&(y.recompile(this.#p.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.#b(),this.#y(),this.#n.initialize(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`)?.refresh(),requestAnimationFrame(()=>{this.#y(),this.#n?.refresh()}))}refreshLayout(){requestAnimationFrame(()=>{this.classList.contains(`active`)&&this.#p.table&&(this.#y(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`)?.refresh(),this.#_(),this.#a?.refreshLayout(),this.#n?.refresh())})}#_=()=>{let e=this.querySelector(`.ng-container-body thead`),t=this.querySelector(`.nodata-overlay`);t.style.top=`${e?.offsetHeight}px`};get view(){return!this.#f&&this.#t?.data&&(this.#f=new j(this)),this.#f}invalidate=()=>{this.view.refresh(),this.#n.refresh(!0),this.isAutoFitCol&&this.autoFit(!0)};autoFit=(e=!0)=>{requestAnimationFrame(()=>{this.#v?.(e)})};#v=(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()}};generateTemplate=(e,t)=>{if(this.#e=t,this.#p={table:y.compile(e),tbody:{tr:e.querySelectorAll(`tbody tr`)}},this.querySelector(`.ng-container-body`).appendChild(this.#p.table),this.#h.height=this.#h.length=0,this.#h.heights=[],this.querySelectorAll(`.ng-container-body tbody.body tr`).forEach(e=>{this.#h.height+=e.offsetHeight||0,this.#h.heights.push(e.offsetHeight||0)}),this.#h.length=this.#h.heights.length,this.#e===0){let e=parseInt(this.#t.getAttribute(`display-min-rows`),10),t=parseInt(this.#t.getAttribute(`display-max-rows`),10),n=(this.querySelector(`nine-table-toolbar`)?.offsetHeight||0)+(this.querySelector(`nine-table-footer`)?.offsetHeight||0)+(this.querySelector(`thead`)?.offsetHeight||0)+(this.querySelector(`tfoot`)?.offsetHeight||0)+(this.querySelector(`tbody.head`)?.offsetHeight||0);this.#t.getAttribute(`auto-height`)!==`true`&&isNaN(e)&&isNaN(t)||this.#t.setAttribute(`scroll-bar`,`none`),isNaN(e)||(this.#t.style.minHeight=n+this.#h.height*e+`px`),isNaN(t)||(this.#t.style.maxHeight=n+this.#h.height*t+`px`)}this.querySelectorAll(`tbody.body tr`).forEach(e=>{e.style.display=`none`}),this.querySelector(`.ng-container-body table`).remove()};generate=()=>{this.#b(),this.#y(),this.#w(),this.#E(),[`left`,`body`,`right`].forEach(e=>{let t=`.ng-container-${e}`;this.#m[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};#y=()=>{[`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`)})})};#b=()=>{[{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.#x(t))})};#x=e=>{let t=this.#p.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.#m.content.offsetHeight||0)-((this.#m.body.thead?.offsetHeight||0)+(this.#m.body.tfoot?.offsetHeight||0)+(this.#m.body.tbody.head.offsetHeight||0));isLastRow=()=>{let e=this.querySelector(`.ng-sheet-body`),t=this.querySelector(`.ng-container-body tbody.body`),n=this.#m.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)};#S=()=>{this.#C(),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.#f=new j(this),this.#l=new k(this),this.#u=new g(this),this.#g||(this.#c=new A(this)),this.#m.mainBody.addEventListener(`scroll`,()=>{this.querySelector(`nine-table-hscrollbar`).refresh()})};#C=()=>{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.selection.clear(),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(t)}#a(e){this.#e.view.setSorting(this.#n),this.#o(),this.#e.invalidate(),requestAnimationFrame(()=>{let t=this.#e.querySelectorAll(`tbody.body th, tbody.body td`);t.forEach(t=>{t.classList.remove(`sorting-anim-asc`,`sorting-anim-desc`,`sorting-anim-none`),e.classList.contains(`asc`)?t.classList.add(`sorting-anim-asc`):e.classList.contains(`desc`)?t.classList.add(`sorting-anim-desc`):t.classList.add(`sorting-anim-none`)}),requestAnimationFrame(()=>{t.forEach(e=>{e.classList.remove(`sorting-anim-asc`,`sorting-anim-desc`,`sorting-anim-none`)})})})}#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:4,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)}i>0&&`${i}`})}},N=class{#e;#t;constructor(e){this.#e=e,this.#t=e.getRootNode().host}col={setWidth:(e,t,n=null)=>{Array.from(this.#e.querySelectorAll(`table colgroup col[data-col="${e}"]`)).forEach(e=>{e.setAttribute(`width`,t),e.style.width=`${t}px`})},getWidth:e=>{let t=this.#e.querySelector(`table colgroup col[data-col="${e}"]`);return t&&parseInt(t.getAttribute(`width`)||t.style.width,10)||0},measureAutoFitColumnWidth:(e,t)=>{let n=this.#t.fields.get().indexOf(t.dataset.bind),r=window.getComputedStyle(t).font||`12px sans-serif`,i=32;return this.#e.view.getArray().forEach((e,a)=>{let o=String(t.dataset.expr?this.#t.exprEngine.evaluate(t.dataset.expr,e,a):e.v[n]??``).trim(),s=nine.measureTextSize(o,r);s.width&&s.width>i&&(i=s.width)}),i},autoFit:e=>{let t=this.#e.querySelector(`thead th[data-col="${e}"]`),n=this.#e.querySelector(`tbody.body [data-col="${e}"]`);t&&n&&this.#t.execute(()=>{let r=this.col.measureAutoFitColumnWidth(t,n);r!==null&&this.col.setWidth(e,r)})},setVisible:(e,t)=>{this.#e.querySelectorAll(`table colgroup col[data-col="${e}"], th[data-col="${e}"], td[data-col="${e}"]`).forEach(e=>{e.style.display=t?``:`none`}),this.#e.rowManager?.refresh()}};row={at:()=>this.#e.selection.minRow<0?-1:Math.floor(this.#e.selection.minRow/this.#e.template.length),focus:async(e,t)=>{this.#e.row.isVisible(e)?await new Promise(e=>requestAnimationFrame(e)):await new Promise(t=>{this.#e.row.moveTo(e,()=>{t()})});let n=this.#e.querySelectorAll(`tbody.body tr[data-index="${e}"]`),r=Array.from(n,e=>parseInt(e.dataset.matrixRow,10)).filter(e=>!isNaN(e)),i=[];if(n.forEach(e=>{e.querySelectorAll(`td, th`).forEach(e=>{parseInt(e.dataset.col,10)!=0&&i.push(parseInt(e.dataset.col,10))})}),r.length===0||i.length===0)return;let a=this.#e.selection.setRange(Math.min(...r),Math.min(...i),Math.max(...r),Math.max(...i));return typeof t==`function`&&t(),a},isVisible:e=>{let t=this.#e.querySelector(`.ng-sheet-body`),n=t.querySelectorAll(`.ng-container-body tbody.body tr[data-index="${e}"]`);if(!n||n.length===0)return!1;let r=t.getBoundingClientRect(),i=t.querySelector(`thead`)?.offsetHeight||0,a=t.querySelector(`tfoot`)?.offsetHeight||0,o=r.top+i,s=r.bottom-a,c=!0;for(let e of n){let t=e.getBoundingClientRect(),n=t.top<o,r=t.bottom>s;if(n||r){c=!1;break}}return c},add:(e,t)=>this.#t.data.add(e,t),moveTo:(e,t)=>{this.#e.row.isVisible(e)?typeof t==`function`&&t():this.#e.scrollTo(e,()=>{typeof t==`function`&&t()})},insert:(e,t,n=!0)=>{let r=this.#e.view.get(e).m._[i.META.INDEX.ROWID],a=this.#t.data.insert(r,t,n);return this.#e.view.getArray().findIndex(e=>!e||!e.m||!e.m._?!1:e.m._[i.META.INDEX.ROWID]===a)},remove:e=>{let t=this.#e.view.get(e).m._[i.META.INDEX.ROWID];this.#t.data.remove(t)}}},P=class extends HTMLElement{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p={table:null};#m;#h={length:0,height:0,heights:[]};static SCROLLBAR_SIZE=16;constructor(){super(),this.#t=this.getRootNode().host,this.#n=new v(this),this.#d=new N(this),this.#D()}connectedCallback(){this.#S()}get template(){return this.#h}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.#p.tbody.tr.length||0}get elements(){return this.#m}get isAutoFitCol(){let e=this.getAttribute(`auto-fit-col`)===`true`||this.#t?.getAttribute(`auto-fit-col`)===`true`,t=this.#p.table?.getAttribute(`auto-fit-col`)===`true`;return e||t}get sourceTable(){return this.#p.table}get source(){return this.#p}get#g(){return this.#t.hasAttribute(`simple`)||this.#t.getAttribute(`theme`)===`simple`}scrollTo=(e,t)=>{this.rowManager.scrollToDataRow(e,`top`,t)};recompileAndRefresh(){this.#p.table&&(y.recompile(this.#p.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.#b(),this.#y(),this.#n.initialize(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`)?.refresh(),requestAnimationFrame(()=>{this.#y(),this.#n?.refresh()}))}refreshLayout(){requestAnimationFrame(()=>{this.classList.contains(`active`)&&this.#p.table&&(this.#y(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`)?.refresh(),this.#_(),this.#a?.refreshLayout(),this.#n?.refresh())})}#_=()=>{let e=this.querySelector(`.ng-container-body thead`),t=this.querySelector(`.nodata-overlay`);t.style.top=`${e?.offsetHeight}px`};get view(){return!this.#f&&this.#t?.data&&(this.#f=new j(this)),this.#f}invalidate=()=>{this.view.refresh(),this.#n.refresh(!0),this.isAutoFitCol&&this.autoFit(!0)};autoFit=(e=!0)=>{requestAnimationFrame(()=>{this.#v?.(e)})};#v=(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()}};generateTemplate=(e,t)=>{let n=e=>{if([`NINE-TABLE-SIMPLE`].includes(this.#t.tagName)){let t=this.#t.closest(`nine-table-filter-panel, cell-combo-panel`);t&&(e?t.classList.add(`active`):t.classList.remove(`active`))}};if(n(!0),this.#e=t,this.#p={table:y.compile(e),tbody:{tr:e.querySelectorAll(`tbody tr`)}},this.querySelector(`.ng-container-body`).appendChild(this.#p.table),this.#h.height=this.#h.length=0,this.#h.heights=[],this.querySelectorAll(`.ng-container-body tbody.body tr`).forEach(e=>{this.#h.height+=Math.max(e.offsetHeight||0,28),this.#h.heights.push(e.offsetHeight||0)}),this.#h.length=this.#h.heights.length,this.#e===0){let e=parseInt(this.#t.getAttribute(`display-min-rows`),10),t=parseInt(this.#t.getAttribute(`display-max-rows`),10),n=(this.querySelector(`nine-table-toolbar`)?.offsetHeight||0)+(this.querySelector(`nine-table-footer`)?.offsetHeight||0)+(this.querySelector(`thead`)?.offsetHeight||0)+(this.querySelector(`tfoot`)?.offsetHeight||0)+(this.querySelector(`tbody.head`)?.offsetHeight||0);this.#t.getAttribute(`auto-height`)!==`true`&&isNaN(e)&&isNaN(t)||this.#t.setAttribute(`scroll-bar`,`none`),isNaN(e)||(this.#t.style.minHeight=n+this.#h.height*e+`px`),isNaN(t)||(this.#t.style.maxHeight=n+this.#h.height*t+`px`)}this.querySelectorAll(`tbody.body tr`).forEach(e=>{e.style.display=`none`}),this.querySelector(`.ng-container-body table`).remove(),n(!1)};generate=()=>{this.#b(),this.#y(),this.#w(),this.#E(),[`left`,`body`,`right`].forEach(e=>{let t=`.ng-container-${e}`;this.#m[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};#y=()=>{this.#t.classList.contains(`combo-list`)||[`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`)})})};#b=()=>{[{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.#x(t))})};#x=e=>{let t=this.#p.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.#m.content.offsetHeight||0)-((this.#m.body.thead?.offsetHeight||0)+(this.#m.body.tfoot?.offsetHeight||0)+(this.#m.body.tbody.head.offsetHeight||0));isLastRow=()=>{let e=this.querySelector(`.ng-sheet-body`),t=this.querySelector(`.ng-container-body tbody.body`),n=this.#m.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)};#S=()=>{this.#C(),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.#f=new j(this),this.#l=new k(this),this.#u=new g(this),this.#g||(this.#c=new A(this)),this.#m.mainBody.addEventListener(`scroll`,e=>{this.querySelectorAll(`nine-table-filter-panel,cell-combo-panel`).forEach(e=>{e.classList.remove(`active`)}),this.querySelector(`nine-table-hscrollbar`).refresh()})};#C=()=>{this.setAttribute(`tabindex`,`0`),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,9 +75,10 @@
75
75
 
76
76
  <nine-table-col-resizer-panel></nine-table-col-resizer-panel>
77
77
 
78
+
78
79
  <div class="ng-col-mover-grip"></div>
79
80
  <div class="ng-col-mover-indi"></div>
80
- `,this.#m={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`)}};#w=()=>{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.#T(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.#T(o,s,c)};#T=(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`))}})};#E=()=>{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)})};#D=()=>{[this.#d].forEach(e=>{new Set([...Reflect.ownKeys(e),...Reflect.ownKeys(Object.getPrototypeOf(e))]).forEach(t=>{if(t===`constructor`||String(t).startsWith(`#`))return;let n=e[t];typeof n==`function`?this[t]||(this[t]=(...t)=>n.apply(e,t)):typeof n==`object`&&n&&(this[t]||(this[t]=n))})})};disconnectedCallback(){this.#a?.destroy(),this.#o?.destroy(),this.innerHTML=``}};customElements.get(`nine-table-sheet`)||customElements.define(`nine-table-sheet`,P);var F=class{#e;constructor(e){this.#e=e,this.#t()}#t=()=>{this.#n(),this.#r()};set loading(e){e?this.#e.classList.add(`loading`):this.#e.classList.remove(`loading`)}#n=()=>{let e=Array.from(this.#e.children).filter(e=>e.tagName.toUpperCase()===`TABLE`),t=e.length,n=e.map((e,n)=>{let r=n===0?`active`:``,i=e.id||`sheet${n+1}`;return`<nine-table-sheet class="${r}" data-index="${n}" data-sheet-id="${i}" id="${i}"></nine-table-sheet>`+(n<t-1?`<nine-splitter class="h" data-split-index="${n}"></nine-splitter>`:``)}).join(``),r=[`@import "https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.0.23/dist/css/nine-table.css";`];nine[`nine-table`]&&nine[`nine-table`].cssFile&&r.push(`@import "${nine[`nine-table`].cssFile}";`),this.#e.shadowRoot.innerHTML=`
81
+ `,this.#m={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`)}};#w=()=>{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.#T(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.#T(o,s,c)};#T=(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`))}})};#E=()=>{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)})};#D=()=>{[this.#d].forEach(e=>{new Set([...Reflect.ownKeys(e),...Reflect.ownKeys(Object.getPrototypeOf(e))]).forEach(t=>{if(t===`constructor`||String(t).startsWith(`#`))return;let n=e[t];typeof n==`function`?this[t]||(this[t]=(...t)=>n.apply(e,t)):typeof n==`object`&&n&&(this[t]||(this[t]=n))})})};disconnectedCallback(){this.#a?.destroy(),this.#o?.destroy(),this.innerHTML=``}};customElements.get(`nine-table-sheet`)||customElements.define(`nine-table-sheet`,P);var F=class{#e;constructor(e){this.#e=e,this.#t()}#t=()=>{this.#n(),this.#r()};set loading(e){e?this.#e.classList.add(`loading`):this.#e.classList.remove(`loading`)}#n=()=>{let e=Array.from(this.#e.children).filter(e=>e.tagName.toUpperCase()===`TABLE`),t=e.length,n=e.map((e,n)=>{let r=n===0?`active`:``,i=e.id||`sheet${n+1}`;return`<nine-table-sheet class="${r}" data-index="${n}" data-sheet-id="${i}" id="${i}"></nine-table-sheet>`+(n<t-1?`<nine-splitter class="h" data-split-index="${n}"></nine-splitter>`:``)}).join(``),r=[`@import "https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.1.1/dist/css/nine-table.css";`];nine[`nine-table`]&&nine[`nine-table`].cssFile&&r.push(`@import "${nine[`nine-table`].cssFile}";`),this.#e.shadowRoot.innerHTML=`
81
82
  <style>
82
83
  ${r.join(`
83
84
  `)}
@@ -98,13 +99,13 @@
98
99
  <nine-table-analysis></nine-table-analysis>
99
100
  </nine-table-body>
100
101
  <nine-table-footer></nine-table-footer>
101
- `,e.forEach(e=>{M.initializeTable(this.#e,e)}),this.#e.shadowRoot.querySelectorAll(`nine-table-sheet`).forEach((t,n)=>{t.classList.add(`active`),t.generateTemplate(e[n],n)}),this.#e.shadowRoot.querySelectorAll(`nine-table-sheet`).forEach(e=>{setTimeout(()=>{e.generate(),this.#a&&this.#i()})}),setTimeout(()=>{this.#e.data.clear()})};#r=()=>{this.#e.addEventListener(i.EVENT.ROW_ADDED,()=>{this.#a&&this.#i()}),this.#e.addEventListener(i.EVENT.ROW_REMOVED,()=>{this.#a&&this.#i()});let e=0;new ResizeObserver(t=>{for(let n of t)if(n.target.tagName===`NINE-TABLE`){let t=n.contentRect.height;t!==e&&(e=t,this.#a&&this.#i())}}).observe(this.#e)};#i=()=>{this.#e.shadowRoot.querySelectorAll(`nine-table-sheet`).forEach(e=>{if(e.index===0){r.log(e,e.template.height,e.view.count());let t=(e.querySelector(`thead`)?.offsetHeight||0)+(e.querySelector(`tfoot`)?.offsetHeight||0)+(e.querySelector(`tbody.head`)?.offsetHeight||0),n=this.#e.offsetHeight-e.offsetHeight+t,i=Math.min(e.template.height*e.view.count(),window.innerHeight*.8);this.#e.style.height=n+i+`px`}})};get#a(){return this.#e.getAttribute(`auto-height`)===`true`}},I=class{#e;#t;#n=new Map;constructor(e){this.#e=e,this.#t=e.fields.get()}rewriteExpr(e){return!e||!this.#t.length?e:e.replace(/data\.([a-zA-Z_$][\w$]*)/g,(e,t)=>{let n=this.#t.indexOf(t);return n>=0?`rowItem.v[${n}]`:e})}precompile(e){return e&&this.rewriteExpr(e)}evaluate(e,t,n=0){if(e==null)return``;try{let r=String(e).trim(),i=this.rewriteExpr(r);if(i.includes(`provider.`)||i.includes(`host.`)||i.includes(`data.`)||i.includes(`rowItem.v`)||i.includes(`(`)){let e=this.#n.get(i);return e||(e=Function(`rowItem`,`row`,`host`,`
102
+ `,e.forEach(e=>{M.initializeTable(this.#e,e)}),this.#e.shadowRoot.querySelectorAll(`nine-table-sheet`).forEach((t,n)=>{t.classList.add(`active`),t.generateTemplate(e[n],n)}),this.#e.shadowRoot.querySelectorAll(`nine-table-sheet`).forEach(e=>{setTimeout(()=>{e.generate(),this.#a&&this.#i()})}),setTimeout(()=>{this.#e.data.clear()})};#r=()=>{this.#e.addEventListener(i.EVENT.ROW_ADDED,()=>{this.#a&&this.#i()}),this.#e.addEventListener(i.EVENT.ROW_REMOVED,()=>{this.#a&&this.#i()});let e=0;new ResizeObserver(t=>{for(let n of t)if(n.target.tagName===`NINE-TABLE`){let t=n.contentRect.height;t!==e&&(e=t,this.#a&&this.#i())}}).observe(this.#e)};#i=()=>{this.#e.shadowRoot.querySelectorAll(`nine-table-sheet`).forEach(e=>{if(e.index===0){let t=(e.querySelector(`thead`)?.offsetHeight||0)+(e.querySelector(`tfoot`)?.offsetHeight||0)+(e.querySelector(`tbody.head`)?.offsetHeight||0),n=this.#e.offsetHeight-e.offsetHeight+t,r=Math.min(e.template.height*e.view.count(),window.innerHeight*.8);this.#e.style.height=n+r+`px`}})};get#a(){return this.#e.getAttribute(`auto-height`)===`true`}},I=class{#e;#t;#n=new Map;constructor(e){this.#e=e,this.#t=e.fields.get()}rewriteExpr(e){return!e||!this.#t.length?e:e.replace(/data\.([a-zA-Z_$][\w$]*)/g,(e,t)=>{let n=this.#t.indexOf(t);return n>=0?`rowItem.v[${n}]`:e})}precompile(e){return e&&this.rewriteExpr(e)}evaluate(e,t,n=0){if(e==null)return``;try{let r=String(e).trim(),i=this.rewriteExpr(r);if(i.includes(`provider.`)||i.includes(`host.`)||i.includes(`data.`)||i.includes(`rowItem.v`)||i.includes(`(`)){let e=this.#n.get(i);return e||(e=Function(`rowItem`,`row`,`host`,`
102
103
  const data = rowItem;
103
104
  const provider = host;
104
105
 
105
106
  if (!data && !host) return "";
106
107
  return ${i};
107
- `),this.#n.set(i,e)),e(t,n,this.#e)}return i}catch{return e}}},L=class{#e;constructor(e){this.#e=e}provider={style:{value:``},add:e=>{if(!e||typeof e!=`object`)return;let{style:t,...n}=e;t&&typeof t==`string`&&(this.provider.style.value=t),Object.keys(n).length>0&&setTimeout(()=>{Object.entries(n).forEach(([e,t])=>{typeof t==`function`&&(this.#e[e]=t)}),this.#e.rerenderer()})}}},R=class{#e;constructor(e){this.#e=e,[`row`].forEach(e=>{this[e]=new Proxy({},{get:(t,n)=>{let r=this.#t();if(!r||!r[e])return;let i=r[e][n];return typeof i==`function`?(...t)=>i.apply(r[e],t):i}})})}getActiveSheets(){return this.#e.shadow.querySelectorAll(`nine-table-sheet.active`)}#t(){let e=this.getActiveSheets();return e.length>0?e[0]:null}},z=class extends HTMLElement{#e;#t;#n;#r;#i;#a=0;constructor(){super(),[`NINE-TABLE`].includes(this.tagName)&&r.log(`Welcome nine-table`,`0.0.23`),this.#e=this.attachShadow({mode:`open`}),this.#t=new s(this),this.#r=new L(this),this.#i=new R(this),this.#c()}connectedCallback(){setTimeout(()=>{this.#a=this.querySelectorAll(`table`)?.length,this.fields=new c(this),this.exprEngine=new I(this),this.#s(),this.#n=new F(this),this.#o()})}disconnectedCallback(){}#o=()=>{let e=0,t=setInterval(()=>{e++;let n=this.shadow.querySelectorAll(`nine-table-sheet`);if(e>=50&&clearInterval(t),n.length>=this.#a){let e=0;n.forEach(t=>{t.loaded&&e++}),e>=this.#a&&(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}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}#s(){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}})})};#c(){[this.#r,this.#i].forEach(e=>{new Set([...Reflect.ownKeys(e),...Reflect.ownKeys(Object.getPrototypeOf(e))]).forEach(t=>{if(t===`constructor`||String(t).startsWith(`#`))return;let n=e[t];typeof n==`function`?this[t]||(this[t]=(...t)=>n.apply(e,t)):typeof n==`object`&&n&&(this[t]||(this[t]=n))})})}};customElements.get(`nine-table`)||customElements.define(`nine-table`,z),customElements.get(`nine-table-simple`)||customElements.define(`nine-table-simple`,class extends z{connectedCallback(){this.setAttribute(`theme`,`simple`),super.connectedCallback()}});var B=class extends HTMLElement{constructor(){super()}applyBaseStyle(){}connectedCallback(){}},V=new Map,H=class extends B{#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=V.get(`grp_`+e);return i||(i=Function(`groupRecord`,`row`,`cell`,`host`,`
108
+ `),this.#n.set(i,e)),e(t,n,this.#e)}return i}catch{return e}}},L=class{#e;constructor(e){this.#e=e}provider={style:{value:``},add:e=>{if(!e||typeof e!=`object`)return;let{style:t,...n}=e;t&&typeof t==`string`&&(this.provider.style.value=t),Object.keys(n).length>0&&setTimeout(()=>{Object.entries(n).forEach(([e,t])=>{typeof t==`function`&&(this.#e[e]=t)}),this.#e.rerenderer()})}}},R=class{#e;constructor(e){this.#e=e,[`col`,`row`].forEach(e=>{this[e]=new Proxy({},{get:(t,n)=>{let r=this.#t();if(!r||!r[e])return;let i=r[e][n];return typeof i==`function`?(...t)=>i.apply(r[e],t):i}})})}getActiveSheets(){return this.#e.shadow.querySelectorAll(`nine-table-sheet.active`)}#t(){let e=this.getActiveSheets();return e.length>0?e[0]:null}},z=class extends HTMLElement{#e;#t;#n;#r;#i;#a=0;constructor(){super(),[`NINE-TABLE`].includes(this.tagName)&&r.log(`Welcome nine-table`,`0.1.1`),this.#e=this.attachShadow({mode:`open`}),this.#t=new s(this),this.#r=new L(this),this.#i=new R(this),this.#c()}connectedCallback(){setTimeout(()=>{this.#a=this.querySelectorAll(`table`)?.length,this.fields=new c(this),this.exprEngine=new I(this),this.#s(),this.#n=new F(this),this.#o()})}disconnectedCallback(){}#o=()=>{let e=0,t=setInterval(()=>{e++;let n=this.shadow.querySelectorAll(`nine-table-sheet`);if(e>=50&&clearInterval(t),n.length>=this.#a){let e=0;n.forEach(t=>{t.loaded&&e++}),e>=this.#a&&(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}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}#s(){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}})})};#c(){[this.#r,this.#i].forEach(e=>{new Set([...Reflect.ownKeys(e),...Reflect.ownKeys(Object.getPrototypeOf(e))]).forEach(t=>{if(t===`constructor`||String(t).startsWith(`#`))return;let n=e[t];typeof n==`function`?this[t]||(this[t]=(...t)=>n.apply(e,t)):typeof n==`object`&&n&&(this[t]||(this[t]=n))})})}};customElements.get(`nine-table`)||customElements.define(`nine-table`,z),customElements.get(`nine-table-simple`)||customElements.define(`nine-table-simple`,class extends z{connectedCallback(){this.setAttribute(`theme`,`simple`),super.connectedCallback()}});var B=class extends HTMLElement{constructor(){super()}applyBaseStyle(){}connectedCallback(){}},V=new Map,H=class extends B{#e;#t;#n;#r;#i;constructor(){super()}get#a(){return this.#r.getAttribute(`update-row-state`)===`false`}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,this.#a)}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=V.get(`grp_`+e);return i||(i=Function(`groupRecord`,`row`,`cell`,`host`,`
108
109
  const indices = groupRecord[3]; // GROUP_IDX.CHILDREN = 3
109
110
  const allRecords = host?.data?.getArray ? host.data.getArray() : [];
110
111
 
@@ -146,10 +147,8 @@
146
147
  ${n}
147
148
  `};refresh=()=>{let e=super.refresh();this.#e.checked=e===this.trueValue,this.isValid()&&this.#i(e);let t=e===this.trueValue?this.#a:e===this.falseValue?this.#o:e;this.#t&&(this.#t.textContent=t)};#i=e=>{this.cell.classList.remove(`invalid`),e!==``&&e!=null&&e!==this.trueValue&&e!==this.falseValue&&this.cell.classList.add(`invalid`)};selectAll=e=>{if(this.closest(`thead`))return;let t=this.host.data.getArray(),n=this.host.fields.indexOf(this.cell.dataset.bind);if(!(n<0)){for(let r=0;r<t.length;r++)this.#c&&super.getExprValue(this.#c,t[r],r,this.cell)===!1||this.#l&&super.getExprValue(this.#l,t[r],r,this.cell)===!0||this.#u&&super.getExprValue(this.#u,t[r],r,this.cell)===!1||(t[r].v[n]=e?this.trueValue:this.falseValue);super.sheet.invalidate()}};get trueValue(){return this.cell.getAttribute(`true-value`)||`Y`}get falseValue(){return this.cell.getAttribute(`false-value`)||`N`}get#a(){return this.cell.getAttribute(`true-text`)||``}get#o(){return this.cell.getAttribute(`false-text`)||``}get#s(){return this.cell.getAttribute(`is-radio`)||!1}get#c(){return this.cell.getAttribute(`enable`)||!1}get#l(){return this.cell.getAttribute(`readonly`)||!1}get#u(){return this.cell.getAttribute(`visible`)||!1}};customElements.get(`cell-checkbox`)||customElements.define(`cell-checkbox`,J);var Y=class extends U{#e;#t=[];#n=[];constructor(){super()}connectedCallback(){super.connectedCallback(),this.#a(),this.#i(),this.#r()}#r=()=>{this.cell.addEventListener(`keydown`,e=>{if(!(this.cell.hasAttribute(`readonly`)||this.cell.classList.contains(`readonly`))&&this.cell.getAttribute(`disabled`)!==`true`&&e.code===`Space`){e.preventDefault();let t=-1;this.#t.forEach((e,n)=>{if(this.value===e.getAttribute(`value`))return t=n,!1}),t=t===this.#t.length-1?0:t>=0?t+1:0,this.value=this.#t[t].getAttribute(`value`),this.sheet.rowManager.refresh(!0)}})};#i=()=>{if(!this.host)return;let e=this.cell.getAttribute(`data-source`);if(e&&(this.#n=super.getExprValue(e,this.tr.data,this.tr.dataset.row),this.#e.replaceChildren(),this.#n&&Array.isArray(this.#n))){let e=document.createDocumentFragment();this.#n.forEach(t=>{let n=t[this.#s]===void 0?``:t[this.#s],r=t[this.#c]===void 0?``:t[this.#c],i=document.createElement(`label`),a=document.createElement(`input`);a.type=`radio`,a.value=n;let o=document.createElement(`span`);o.textContent=r,i.appendChild(a),i.appendChild(o),e.appendChild(i)}),this.#e.appendChild(e),this.#t=Array.from(this.querySelectorAll(`input`)),this.#t.forEach(e=>{e.addEventListener(`change`,e=>{this.value=e.target.value,this.sheet.rowManager.refresh(!0)})})}};#a=()=>{this.innerHTML=`
148
149
  <div></div>
149
- `,this.#e=this.querySelector(`div`)};rerenderer=()=>{this.#i(),this.refresh()};refresh=()=>{let e=super.refresh();this.#t.forEach(t=>{t.checked=e===t.value}),this.isValid()&&this.#o()};#o=()=>{this.value!==null&&this.value!==void 0&&this.value!==``&&Array.isArray(this.#n)&&this.#n.findIndex(e=>this.value===e[this.#s])<0&&this.cell.classList.add(`invalid`)};get dataSource(){return this.#n}get#s(){return this.cell.getAttribute(`key-name`)||`k`}get#c(){return this.cell.getAttribute(`value-name`)||`v`}};customElements.get(`cell-radio`)||customElements.define(`cell-radio`,Y);var X=class extends HTMLElement{#e;#t;#n;#r=!1;constructor(){super()}connectedCallback(){this.#u(),this.#l()}#i=(e,t,n,r,i)=>{let a=this.querySelector(`nine-table-simple`);if(!a||!e||e.length===0)return;let o=this.#e.getAttribute(`items`),s=[];s=o?o.split(`,`).map(e=>e.trim()):[n].filter(Boolean);let c=s.length;a.shadowRoot.querySelector(`.ng-container-left`).style.display=r?``:`none`,a.shadowRoot.querySelectorAll(`table colgroup col, tbody td`).forEach((e,t)=>{let n=parseInt(e.dataset.col,10);n>=2&&(e.style.display=n-2>=c?`none`:``)});let l=e.map(e=>{let n={CHK:`N`,k:t&&e[t]!==void 0?e[t]:e[0]===void 0?``:e[0]};return s.forEach((t,r)=>{n[`tmp${r+1}`]=e[t]===void 0?e[r]===void 0?``:e[r]:e[t]}),n});if(a.data.set(l),r&&this.#e.value){let e=String(this.#e.value).split(i||`,`);a.data.getValidData().forEach(t=>{e.includes(String(t.v[1]))&&(t.v[0]=`Y`)}),a.refreshData()}};open=(e,t,n,r,i,a)=>{this.#e=e,this.#t=n,this.#n=r,this.#r=!0,this.classList.add(`active`);let o=this.querySelector(`nine-table-simple`);if(!o||!t)return;this.querySelector(`.search-input`).value=``,this.querySelector(`#chkAll`).checked=!0,t.length>10?this.classList.add(`expand`):this.classList.remove(`expand`),i?this.classList.add(`multi`):this.classList.remove(`multi`);let s=e.closest(`nine-table-sheet`),c=e.querySelector(`.btn1`);if(!c||!s)return;let l=c.getBoundingClientRect(),u=s.getBoundingClientRect(),d=l.left-u.left,f=l.bottom-u.top+2,p=this.offsetWidth||250,m=this.offsetHeight||250;if(d+p>u.width&&(d=Math.max(0,u.width-p-5)),d<0&&(d=5),f+m>u.height){let e=l.top-u.top-m-2;f=e>=0?e:Math.max(0,u.height-m-5)}this.style.left=`${d}px`,this.style.top=`${f}px`,setTimeout(()=>{this.#i(t,n,r,i,a);let e=o.shadowRoot.querySelector(`.ng-container-body table tbody.body`);e.__hasClickEvent||=(e.addEventListener(`mousedown`,e=>{e.target.closest(`tr`)&&(i||this.#a(e))}),!0)},100)};close=()=>{this.classList.remove(`active`),this.#r=!1,this.#e&&this.#e.cell&&this.#e.cell.focus()};#a=e=>{let t=e.target.closest(`nine-table-sheet`),n=e.target.closest(`tr`),r=parseInt(n.dataset.row,10),i=t.view.get(r);this.#e.value=i.k,this.#e.sheet.rowManager.refresh(!0),this.close()};#o=()=>{let e=this.querySelector(`nine-table-simple`).data.getValidData(),t=[];e.forEach(e=>{e.v[0]===`Y`&&t.push(e.v[1])}),this.#e.value=t.join(this.#e.getAttribute(`multi-separator`)||`,`),this.#e.sheet.rowManager.refresh(!0),this.close()};#s=e=>{let t=this.querySelector(`nine-table-simple`),n=e.target.checked?`Y`:`N`;t.data.getValidData().forEach(e=>{e.v[0]=n}),t.refreshData()};#c=e=>{let t=e.target.value.toLowerCase(),n=this.querySelector(`nine-table-simple`);n.data.getValidDataNF().forEach(e=>{let n=Object.values(e.v).some(e=>e!=null&&String(e).toLowerCase().includes(t));e.__ng.filtered=!n}),n.data.resetRecords(),n.dataManager.viewRecords.reset()};get isOpen(){return this.#r}get targetCell(){return this.#e}#l=()=>{this.querySelector(`.search-input`).addEventListener(`input`,this.#c),this.querySelector(`#btnOk`).addEventListener(`click`,this.#o),this.querySelector(`#chkAll`).addEventListener(`change`,this.#s),document.addEventListener(`mousedown`,e=>{(e.composedPath?e.composedPath():[]).includes(this)||this.close()})};#u=()=>{this.innerHTML=`
150
- <div class="head">
151
- <input type="text" class="search-input" placeholder="Search..." />
152
- </div>
150
+ `,this.#e=this.querySelector(`div`)};rerenderer=()=>{this.#i(),this.refresh()};refresh=()=>{let e=super.refresh();this.#t.forEach(t=>{t.checked=e===t.value}),this.isValid()&&this.#o()};#o=()=>{this.value!==null&&this.value!==void 0&&this.value!==``&&Array.isArray(this.#n)&&this.#n.findIndex(e=>this.value===e[this.#s])<0&&this.cell.classList.add(`invalid`)};get dataSource(){return this.#n}get#s(){return this.cell.getAttribute(`key-name`)||`k`}get#c(){return this.cell.getAttribute(`value-name`)||`v`}};customElements.get(`cell-radio`)||customElements.define(`cell-radio`,Y);var X=class extends HTMLElement{#e;#t;#n;#r=!1;#i;#a;#o;constructor(){super()}connectedCallback(){this.#x(),this.#i=this.querySelector(`nine-table-simple`),setTimeout(()=>{this.#a=this.#i.shadowRoot.querySelector(`nine-table-sheet`),this.#b()})}#s=(e,t,n,r)=>{let a=this.querySelector(`nine-table-simple`);if(!a||!e||e.length===0)return;let o=this.#e.closest(`th,td`).getAttribute(`items`),s=[];s=o?o.split(`,`).map(e=>e.trim()):[n].filter(Boolean);let c=s.length,l=a.shadowRoot.querySelector(`nine-table-sheet`);l.source.table.querySelectorAll(`colgroup col, tbody td`).forEach((e,t)=>{let n=parseInt(e.dataset.col,10);n>=2&&(e.style.display=n-2>=c?`none`:``)}),a.shadowRoot.querySelectorAll(`table colgroup col`).forEach((e,t)=>{let n=parseInt(e.dataset.col,10);n>=2&&(e.style.display=n-2>=c?`none`:``)});let u=e.map(e=>{let n={CHK:`N`,k:t&&e[t]!==void 0?e[t]:e[0]===void 0?``:e[0]};return s.forEach((t,r)=>{n[`tmp${r+1}`]=e[t]===void 0?e[r]===void 0?``:e[r]:e[t]}),n});a.addEventListener(i.EVENT.ROW_ADDED,()=>{setTimeout(()=>{this.style.opacity=``,this.classList.add(`active`),a.shadowRoot.querySelectorAll(`colgroup col`).forEach((e,t)=>{let n=parseInt(e.dataset.col,10);n>=2&&e.style.display!==`none`&&l.col.autoFit(n)});let e=this.#i.fields.get();if(r){let t=this.#e.value?String(this.#e.value).split(this.#o).map(e=>e.trim()):[],n=e.indexOf(`k`),r=e.indexOf(`CHK`);this.#i.data.getArray().forEach(e=>{e.v[r]=t.includes(String(e.v[n]))?`Y`:`N`});let i=this.#a.view.getArray().findIndex((e,r)=>e.v[n]===t[0]);this.#_(i)}else{let t=this.#e.value,n=e.indexOf(`k`),r=this.#a.view.getArray().findIndex((e,r)=>e.v[n]===t);this.#_(r)}})},{once:!0}),r&&this.#e.value,u.length*this.#a.template.height>=this.offsetHeight?this.classList.add(`expand`):this.classList.remove(`expand`),a.data.set(u)};#c=e=>{let t=e.closest(`.ng-sheet-body`),n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return r.bottom-n.bottom>=n.top-r.top};#l=(e,t=0)=>{let n=e.closest(`.ng-sheet-body`),r=e.getBoundingClientRect(),i=n.getBoundingClientRect();return(t?i.bottom-r.bottom:r.top-i.top)-5};#u=e=>{let t=e.closest(`th,td`),n=t.closest(`.ng-sheet-body`),r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.left-i.left,o=this.offsetWidth;return a+o>i.width&&(a=Math.max(0,i.width-o-2)),a<0&&(a=5),a};open=(e,t,n,r,i,a)=>{this.#e=e,this.#t=n,this.#n=r,this.#r=!0,this.#o=a,this.classList.add(`active`),this.style.opacity=`0`,setTimeout(()=>{if(!this.querySelector(`nine-table-simple`)||!t)return;this.querySelector(`.search-input`).value=``,this.querySelector(`#chkAll`).checked=!0;let a=e.closest(`.ng-sheet-body`),o=e.getBoundingClientRect(),s=a.getBoundingClientRect(),c=this.#c(e),l=this.#l(e,c),u=this.#u(e),d=c?o.bottom-s.top:o.top-s.top-l;this.style.height=`${l}px`,this.style.left=`${u}px`,this.style.top=`${d}px`,i?(this.classList.add(`multi`),this.#i.classList.add(`multi`)):(this.classList.remove(`multi`),this.#i.classList.remove(`multi`)),this.#s(t,n,r,i)},100)};close=()=>{this.classList.remove(`active`),this.#r=!1,this.#e&&this.#e.cell&&this.#e.cell.focus()};#d=e=>{let t=e.target.closest(`th,td`);if(this.#i.classList.contains(`multi`)){let e=parseInt(t?.dataset.index,10);this.#g(e)}else parseInt(t?.dataset.col,10)>=2&&this.#h()};#f=e=>{switch(e.code){case`Enter`:case`ArrowDown`:let e=this.#i.row.at();e<0?this.#_(0):this.#_(e);break;case`Tab`:this.#_(this.#i.row.at())}};#p=e=>{let t;switch(e.code){case`Escape`:this.close();break;case`Enter`:this.classList.contains(`multi`)?this.#m():this.#h();break;case`Tab`:this.classList.contains(`expand`)&&(e.preventDefault(),this.querySelector(`input[type='text']`).focus());break;case`ArrowDown`:t=this.#i.row.at(),t<0&&this.#_(0);break;case`Space`:e.preventDefault(),[`TH`,`TD`].includes(e.target.tagName)&&this.#g(this.#i.row.at())}};#m=()=>{let e=this.#i.fields.get(),t=e.indexOf(`k`),n=e.indexOf(`CHK`),r=[];this.#a.view.getArray().forEach(e=>{e.v[n]===`Y`&&r.push(e.v[t])}),this.#e.value=r.join(this.#o),this.#e.sheet.rowManager.refresh(!0),this.close()};#h=()=>{let e=this.#i.row.at();if(e>=0){let t=this.#a.view.get(e);this.#e.value=t.k,this.#e.sheet.rowManager.refresh(!0),this.close()}};#g=e=>{if(this.#i.classList.contains(`multi`)&&e>=0){let t=this.#a.view.get(e);this.#i.data.setValue(t.m._[i.META.INDEX.ROWID],`CHK`,t.CHK===`Y`?`N`:`Y`),this.#i.refresh()}};#_=e=>{e===-1?(this.#a.row.focus(-1,()=>{}),setTimeout(()=>{this.#a.selection.clear(),this.#a.navigation.currentCell=this.#a.querySelector(`tr[data-index="0"] td[data-col="2"]`),this.#a.focus(),this.#a.invalidate()})):this.#a.row.focus(e,()=>{setTimeout(()=>{let t=this.#a.querySelector(`tr[data-index="${e}"] td[data-col="2"]`);this.#a.navigation.currentCell=t,t.focus(),this.#a.invalidate()})})};#v=e=>{let t=this.#i.fields.get().indexOf(`CHK`);this.#i.data.getArray().forEach(n=>{n.v[t]=e.target.checked?`Y`:`N`}),this.#a.invalidate()};#y=e=>{let t=e.target.value.toLowerCase().trim();if(!t)this.#a.filtering.clear();else{let e=this.#i.data.getArray(),n=this.#i.fields.get(),r=`tmp1`,i=n.indexOf(r),a=[];e.forEach(e=>{let n=i>=0&&e.v?e.v[i]:``;String(n).replace(/<[^>]*>?/gm,``).toLowerCase().includes(t)&&a.push(n)}),this.#a.filtering.set({[r]:[...new Set(a)]})}};get isOpen(){return this.#r}get targetCell(){return this.#e}#b=()=>{this.querySelector(`.search-input`).addEventListener(`input`,this.#y),this.querySelector(`.search-input`).addEventListener(`keydown`,this.#f),this.querySelector(`#btnOk`).addEventListener(`click`,this.#m),this.querySelector(`#chkAll`).addEventListener(`change`,this.#v),this.#a.addEventListener(`keydown`,this.#p),this.#a.addEventListener(`click`,this.#d),document.addEventListener(`mousedown`,e=>{(e.composedPath?e.composedPath():[]).includes(this)||this.close()})};#x=()=>{this.innerHTML=`
151
+ <input type="text" class="search-input" placeholder="Search..." />
153
152
 
154
153
  <nine-table-simple class="combo-list" theme="simple">
155
154
  <table auto-fit-col="true">
@@ -187,16 +186,13 @@
187
186
  </nine-table-simple>
188
187
 
189
188
  <div class="footer">
190
- <div>
191
- <input id="chkAll" type="checkbox" checked>
192
- <label for="chkAll">Select All</label>
193
- </div>
189
+ <label for="chkAll"><input id="chkAll" type="checkbox" checked><span>Select All</span></label>
194
190
  <button id="btnOk">OK</button>
195
191
  </div>
196
- `}};customElements.get(`cell-combo-panel`)||customElements.define(`cell-combo-panel`,X);var Z=class extends U{#e;#t=[];#n;#r;#i;#a;#o;constructor(){super()}connectedCallback(){this.#u(),super.connectedCallback(),this.#n=super.cell.getAttribute(`key-name`)||`k`,this.#r=super.cell.getAttribute(`value-name`)||`v`,this.#i=super.cell.getAttribute(`multi`)===`true`,this.#a=super.cell.getAttribute(`multi-separator`)||`,`,this.#s(),this.#c()}rerenderer=()=>{this.#s(),this.refresh()};#s=()=>{if(!super.sheet||!super.cell)return;let e=super.cell?.getAttribute(`data-source`);e&&(this.#t=super.getExprValue(e,super.tr.data,super.tr.dataset.row))};#c=()=>{this.querySelectorAll(`button`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),this.#l()})})};#l=()=>{this.#o||(this.#o=super.sheet.querySelector(`cell-combo-panel`),this.#o||(this.#o=document.createElement(`cell-combo-panel`),super.sheet.appendChild(this.#o))),this.#o.isOpen&&this.#o.targetCell===this?this.#o.close():this.#o.open(this,this.#t,this.#n,this.#r,this.#i,this.#a)};#u=()=>{this.innerHTML=`
192
+ `}};customElements.get(`cell-combo-panel`)||customElements.define(`cell-combo-panel`,X);var Z=class extends U{#e;#t=[];#n;#r;#i;#a;#o;constructor(){super()}connectedCallback(){super.connectedCallback(),this.#l()}rerenderer=()=>{this.#u(),this.refresh()};refresh=()=>{let e=super.refresh();return this.#e&&(this.#e.textContent=this.#s()||`Select`,this.#c()),e};#s=()=>{if(!this.value||!Array.isArray(this.#t))return``;if(this.#i){let e=String(this.value).split(this.#a);return this.#t.filter(t=>e.includes(String(t[this.#n]))).map(e=>e[this.#r]).join(this.#a)}{let e=this.#t.find(e=>String(e[this.#n])===String(this.value));return e?e[this.#r]:this.value}};#c=()=>{if(!super.cell||(super.cell.classList.remove(`invalid`),this.value===null||this.value===void 0||this.value===``||!Array.isArray(this.#t)))return;let e=this.#i?String(this.value).split(this.#a):[this.value];for(let t of e)if(this.#t.findIndex(e=>String(t)===String(e[this.#n]))<0){super.cell.classList.add(`invalid`);break}};#l=()=>{this.#d(),this.#n=this.cell.getAttribute(`key-name`)||`k`,this.#r=this.cell.getAttribute(`value-name`)||`v`,this.#i=this.cell.getAttribute(`multi`)===`true`,this.#a=this.cell.getAttribute(`multi-separator`)||`,`,this.#u(),this.#f()};#u=()=>{if(!super.sheet||!super.cell)return;let e=super.cell?.getAttribute(`data-source`);e&&(this.#t=super.getExprValue(e,super.tr.data,super.tr.dataset.row))};#d=()=>{this.innerHTML=`
197
193
  <button class="btn1" type="button" tabindex="-1">Select</button>
198
194
  <button class="btn2" type="button" tabindex="-1"></button>
199
- `,this.#e=this.querySelector(`.btn1`)};refresh=()=>{let e=super.refresh();return this.#e&&(this.#e.textContent=this.#d()||`Select`,this.#f()),e};#d=()=>{if(!this.value||!Array.isArray(this.#t))return``;if(this.#i){let e=String(this.value).split(this.#a);return this.#t.filter(t=>e.includes(String(t[this.#n]))).map(e=>e[this.#r]).join(this.#a)}{let e=this.#t.find(e=>String(e[this.#n])===String(this.value));return e?e[this.#r]:this.value}};#f=()=>{if(!super.cell||(super.cell.classList.remove(`invalid`),this.value===null||this.value===void 0||this.value===``||!Array.isArray(this.#t)))return;let e=this.#i?String(this.value).split(this.#a):[this.value];for(let t of e)if(this.#t.findIndex(e=>String(t)===String(e[this.#n]))<0){super.cell.classList.add(`invalid`);break}};get dataSource(){return this.#t}};customElements.get(`cell-combo`)||customElements.define(`cell-combo`,Z);var Q=class extends H{#e;constructor(){super()}connectedCallback(){super.connectedCallback(),this.#t(),this.#e=this.querySelector(`span`)}refresh=()=>{super.refresh(),this.cell.getAttribute(`html`)===`true`?this.#e.innerHTML=this.getDisplayText():this.#e.textContent=this.getDisplayText()};#t=()=>{this.innerHTML=`
195
+ `,this.#e=this.querySelector(`.btn1`)};#f=()=>{this.querySelectorAll(`button`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),this.#p()})}),this.cell.addEventListener(`keydown`,e=>{[`Space`].includes(e.code)&&this.#p()})};#p=()=>{this.#o||(this.#o=super.sheet.querySelector(`cell-combo-panel`),this.#o||(this.#o=document.createElement(`cell-combo-panel`),super.sheet.appendChild(this.#o))),this.#o.isOpen&&this.#o.targetCell===this?this.#o.close():this.#o.open(this,this.#t,this.#n,this.#r,this.#i,this.#a)};get dataSource(){return this.#t}};customElements.get(`cell-combo`)||customElements.define(`cell-combo`,Z);var Q=class extends H{#e;constructor(){super()}connectedCallback(){super.connectedCallback(),this.#t(),this.#e=this.querySelector(`span`)}refresh=()=>{super.refresh(),this.cell.getAttribute(`html`)===`true`?this.#e.innerHTML=this.getDisplayText():this.#e.textContent=this.getDisplayText()};#t=()=>{this.innerHTML=`
200
196
  <span class="wrapper"></span>
201
197
  `}};customElements.get(`cell-renderer`)||customElements.define(`cell-renderer`,Q);var $=class extends H{#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=`
202
198
  <button class="button">...</button>