@ninebone/table 0.0.699 → 0.0.701

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,4 +1,4 @@
1
- (function(E,S){typeof exports=="object"&&typeof module<"u"?S(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],S):(E=typeof globalThis<"u"?globalThis:E||self,S(E.NineboneUtil))})(this,function(E){"use strict";var es=Object.defineProperty;var ss=E=>{throw TypeError(E)};var os=(E,S,v)=>S in E?es(E,S,{enumerable:!0,configurable:!0,writable:!0,value:v}):E[S]=v;var h=(E,S)=>es(E,"name",{value:S,configurable:!0});var q=(E,S,v)=>os(E,typeof S!="symbol"?S+"":S,v),Ze=(E,S,v)=>S.has(E)||ss("Cannot "+v);var t=(E,S,v)=>(Ze(E,S,"read from private field"),v?v.call(E):S.get(E)),d=(E,S,v)=>S.has(E)?ss("Cannot add the same private member more than once"):S instanceof WeakSet?S.add(E):S.set(E,v),p=(E,S,v,F)=>(Ze(E,S,"write to private field"),F?F.call(E,v):S.set(E,v),v),Ge=(E,S,v)=>(Ze(E,S,"access private method"),v);var ns=(E,S,v,F)=>({set _(wt){p(E,S,wt,v)},get _(){return t(E,S,F)}});var P,V,R,G,J,Q,Dt,tt,jt,et,st,dt,C,St,Et,Ft,j,A,nt,D,N,Y,rt,At,Le,He,Vt,Yt,Rt,qt,Tt,Ut,Xt,kt,Me,ft,Ct,Kt,U,Lt,ut,rs,is,Gt,it,ot,Ht,Jt,Qt,gt,te,ee,se,It,I,ne,$t,re,_t,bt,z,L,W,pt,ie,X,oe,at,Nt,ae,le,yt,lt,mt,M,zt,ce,ct,he,de,H,Ot,y,Pe,De,je,Fe,Ve,Bt,ht,xt,vt,fe,K,Xe;const Te=class Te extends E.trace.constructor{constructor(){super(),this.init("nine-table","green")}};h(Te,"Trace");let S=Te;const v=new S,ke=class ke extends HTMLElement{constructor(){super();d(this,P);d(this,V,!1);d(this,R);d(this,G);d(this,J);d(this,Q);d(this,Dt,h(()=>{if(!t(this,P))return;const e=t(this,P).querySelector(".ng-container-body .ng-part-body");e&&(p(this,Q,new ResizeObserver(()=>{this.refresh()})),t(this,Q).observe(e))},"#observeResize"));q(this,"refresh",h(()=>{if(!t(this,P)||!t(this,R)||t(this,V))return;const e=t(this,R).container,s=e.querySelector("table");if(!s)return;const r=t(this,R).track,o=t(this,R).thumb,i=t(this,P).querySelector(".ng-container-bottom"),a=e.clientWidth,c=s.scrollWidth;if(a!==0&&c>a)i&&(i.style.display="flex");else{i&&(i.style.display="none");return}const l=r.clientWidth;if(l<=0)return;const f=Math.max(Math.min(l*(a/c),l),20);o.style.width=`${f}px`;const g=e.scrollLeft,b=c-a;let u=0;b>0&&(u=parseInt(g/b*(l-f),10)),u<0&&(u=0);const m=l-f;u>m&&(u=m),o.style.left=`${u}px`,t(this,R).left.disabled=u===0,t(this,R).right.disabled=u>=m-1},"refresh"));d(this,tt,h(e=>{if(!t(this,R))return!1;const s=t(this,R).container,r=s.querySelector("table");if(!r)return!1;const o=t(this,R).track.getBoundingClientRect(),i=t(this,R).thumb.clientWidth;let a=e;a<0&&(a=0);const c=o.width-i;a>c&&(a=c),a=parseInt(a,10),t(this,R).thumb.style.left=`${a}px`,t(this,R).left.disabled=a===0,t(this,R).right.disabled=a>=c-1;const l=s.clientWidth,g=r.scrollWidth-l;return c>0&&g>0&&(s.scrollLeft=a/c*g),a>0&&a<c-1},"#thumbMoveTo"));d(this,jt,h(()=>{const e=h(r=>{clearInterval(t(this,G)),clearInterval(t(this,J));const o=parseInt(t(this,R).thumb.style.left||0,10);t(this,tt).call(this,o+r),p(this,G,setInterval(()=>{clearInterval(t(this,G)),p(this,J,setInterval(()=>{const i=parseInt(t(this,R).thumb.style.left||0,10);t(this,tt).call(this,i+r)||clearInterval(t(this,J))},50))},500))},"delayScroll"),s=h(()=>{clearInterval(t(this,G)),clearInterval(t(this,J))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(r=>{t(this,R).left.addEventListener(r,s),t(this,R).right.addEventListener(r,s),t(this,R).track.addEventListener(r,s)}),t(this,R).left.addEventListener("mousedown",r=>{r.button===0&&e(-20)}),t(this,R).right.addEventListener("mousedown",r=>{r.button===0&&e(20)}),t(this,R).left.addEventListener("touchstart",()=>e(-20)),t(this,R).right.addEventListener("touchstart",()=>e(20)),t(this,R).track.addEventListener("mousedown",r=>{if(r.button!==0)return;r.preventDefault();const o=t(this,R).track.getBoundingClientRect(),i=t(this,R).thumb.clientWidth;t(this,tt).call(this,r.clientX-o.left-i/2)}),t(this,R).thumb.addEventListener("mousedown",r=>{if(r.button!==0)return;r.stopPropagation(),r.preventDefault(),p(this,V,!0),this.shiftX=r.clientX-t(this,R).thumb.getBoundingClientRect().left;const o=h(a=>{if(!t(this,V))return;const c=t(this,R).track.getBoundingClientRect();t(this,tt).call(this,a.clientX-c.left-this.shiftX)},"onMouseMove"),i=h(()=>{p(this,V,!1),s(),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",i),this.refresh()},"onMouseUp");document.addEventListener("mousemove",o),document.addEventListener("mouseup",i)})},"#init"))}connectedCallback(){if(p(this,P,this.closest("nine-table-sheet")||this.getRootNode().host),!t(this,P))return;this.innerHTML=`
1
+ (function(E,S){typeof exports=="object"&&typeof module<"u"?S(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],S):(E=typeof globalThis<"u"?globalThis:E||self,S(E.NineboneUtil))})(this,function(E){"use strict";var ss=Object.defineProperty;var ns=E=>{throw TypeError(E)};var as=(E,S,y)=>S in E?ss(E,S,{enumerable:!0,configurable:!0,writable:!0,value:y}):E[S]=y;var h=(E,S)=>ss(E,"name",{value:S,configurable:!0});var C=(E,S,y)=>as(E,typeof S!="symbol"?S+"":S,y),Ze=(E,S,y)=>S.has(E)||ns("Cannot "+y);var t=(E,S,y)=>(Ze(E,S,"read from private field"),y?y.call(E):S.get(E)),d=(E,S,y)=>S.has(E)?ns("Cannot add the same private member more than once"):S instanceof WeakSet?S.add(E):S.set(E,y),p=(E,S,y,F)=>(Ze(E,S,"write to private field"),F?F.call(E,y):S.set(E,y),y),Ge=(E,S,y)=>(Ze(E,S,"access private method"),y);var rs=(E,S,y,F)=>({set _(St){p(E,S,St,y)},get _(){return t(E,S,F)}});var B,V,q,G,J,Q,Pt,tt,jt,et,st,ft,k,Et,Rt,Ft,j,R,nt,P,_,Y,rt,At,Le,Me,Vt,Yt,qt,Ct,Tt,Ut,Xt,kt,He,ut,Lt,Kt,U,ot,gt,os,is,Gt,it,at,Mt,Jt,Qt,bt,te,ee,se,It,I,ne,$t,re,_t,pt,N,L,W,yt,oe,X,ie,lt,Nt,ae,le,mt,ct,xt,H,zt,ce,ht,he,de,M,Wt,x,Be,Pe,je,Fe,Ve,Ot,dt,vt,wt,fe,K,Xe;const Ce=class Ce extends E.trace.constructor{constructor(){super(),this.init("nine-table","green")}};h(Ce,"Trace");let S=Ce;const y=new S,Te=class Te extends HTMLElement{constructor(){super();d(this,B);d(this,V,!1);d(this,q);d(this,G);d(this,J);d(this,Q);d(this,Pt,h(()=>{if(!t(this,B))return;const e=t(this,B).querySelector(".ng-container-body .ng-part-body");e&&(p(this,Q,new ResizeObserver(()=>{this.refresh()})),t(this,Q).observe(e))},"#observeResize"));C(this,"refresh",h(()=>{if(!t(this,B)||!t(this,q)||t(this,V))return;const e=t(this,q).container,s=e.querySelector("table");if(!s)return;const r=t(this,q).track,o=t(this,q).thumb,i=t(this,B).querySelector(".ng-container-bottom"),a=e.clientWidth,c=s.scrollWidth;if(a!==0&&c>a)i&&(i.style.display="flex");else{i&&(i.style.display="none");return}const l=r.clientWidth;if(l<=0)return;const f=Math.max(Math.min(l*(a/c),l),20);o.style.width=`${f}px`;const u=e.scrollLeft,g=c-a;let b=0;g>0&&(b=parseInt(u/g*(l-f),10)),b<0&&(b=0);const v=l-f;b>v&&(b=v),o.style.left=`${b}px`,t(this,q).left.disabled=b===0,t(this,q).right.disabled=b>=v-1},"refresh"));d(this,tt,h(e=>{if(!t(this,q))return!1;const s=t(this,q).container,r=s.querySelector("table");if(!r)return!1;const o=t(this,q).track.getBoundingClientRect(),i=t(this,q).thumb.clientWidth;let a=e;a<0&&(a=0);const c=o.width-i;a>c&&(a=c),a=parseInt(a,10),t(this,q).thumb.style.left=`${a}px`,t(this,q).left.disabled=a===0,t(this,q).right.disabled=a>=c-1;const l=s.clientWidth,u=r.scrollWidth-l;return c>0&&u>0&&(s.scrollLeft=a/c*u),a>0&&a<c-1},"#thumbMoveTo"));d(this,jt,h(()=>{const e=h(r=>{clearInterval(t(this,G)),clearInterval(t(this,J));const o=parseInt(t(this,q).thumb.style.left||0,10);t(this,tt).call(this,o+r),p(this,G,setInterval(()=>{clearInterval(t(this,G)),p(this,J,setInterval(()=>{const i=parseInt(t(this,q).thumb.style.left||0,10);t(this,tt).call(this,i+r)||clearInterval(t(this,J))},50))},500))},"delayScroll"),s=h(()=>{clearInterval(t(this,G)),clearInterval(t(this,J))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(r=>{t(this,q).left.addEventListener(r,s),t(this,q).right.addEventListener(r,s),t(this,q).track.addEventListener(r,s)}),t(this,q).left.addEventListener("mousedown",r=>{r.button===0&&e(-20)}),t(this,q).right.addEventListener("mousedown",r=>{r.button===0&&e(20)}),t(this,q).left.addEventListener("touchstart",()=>e(-20)),t(this,q).right.addEventListener("touchstart",()=>e(20)),t(this,q).track.addEventListener("mousedown",r=>{if(r.button!==0)return;r.preventDefault();const o=t(this,q).track.getBoundingClientRect(),i=t(this,q).thumb.clientWidth;t(this,tt).call(this,r.clientX-o.left-i/2)}),t(this,q).thumb.addEventListener("mousedown",r=>{if(r.button!==0)return;r.stopPropagation(),r.preventDefault(),p(this,V,!0),this.shiftX=r.clientX-t(this,q).thumb.getBoundingClientRect().left;const o=h(a=>{if(!t(this,V))return;const c=t(this,q).track.getBoundingClientRect();t(this,tt).call(this,a.clientX-c.left-this.shiftX)},"onMouseMove"),i=h(()=>{p(this,V,!1),s(),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",i),this.refresh()},"onMouseUp");document.addEventListener("mousemove",o),document.addEventListener("mouseup",i)})},"#init"))}connectedCallback(){if(p(this,B,this.closest("nine-table-sheet")||this.getRootNode().host),!t(this,B))return;this.innerHTML=`
2
2
  <style>
3
3
  nine-table-hscrollbar {
4
4
  display: flex;
@@ -60,7 +60,7 @@
60
60
  <button class='ng-scroll-left' disabled><div class='ng-scroll-icon'></div></button>
61
61
  <div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
62
62
  <button class='ng-scroll-right' disabled><div class='ng-scroll-icon'></div></button>
63
- `;const e=h(()=>{const s=t(this,P).querySelector(".ng-container-body .ng-part-body");if(!s){setTimeout(e,10);return}p(this,R,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),left:this.querySelector(".ng-scroll-left"),right:this.querySelector(".ng-scroll-right")}),s.addEventListener("scroll",()=>{t(this,V)||this.refresh()}),t(this,jt).call(this),t(this,Dt).call(this),this.refresh()},"initWhenReady");e()}disconnectedCallback(){t(this,Q)&&t(this,Q).disconnect()}};P=new WeakMap,V=new WeakMap,R=new WeakMap,G=new WeakMap,J=new WeakMap,Q=new WeakMap,Dt=new WeakMap,tt=new WeakMap,jt=new WeakMap,h(ke,"NineTableHScrollBar");let F=ke;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",F);const Ce=class Ce extends HTMLElement{constructor(){super();d(this,et);d(this,st);d(this,dt,!1);d(this,C);d(this,St,0);d(this,Et,0);q(this,"refresh",h(()=>{if(v.log("vscrollbar.refresh"),!t(this,et)||!t(this,C))return;const e=t(this,C).container,s=t(this,C).track,r=t(this,C).thumb,o=e.clientHeight,i=t(this,et).data.length,a=t(this,st).getRowHeight(),c=i*a;if(c<=o||i===0){this.style.display="none";return}else this.style.display="flex";const l=s.clientHeight;if(l<=0)return;const f=Math.max(Math.min(l*(o/c),l),20);r.style.height=`${f}px`;const g=e.scrollTop,b=Math.max(c-o,1);v.log(e,g,b);let u=0;b>0&&(u=g/b*(l-f));const m=l-f;u<0&&(u=0),u>m&&(u=m),r.style.top=`${u}px`,t(this,C).top.disabled=g<=0,t(this,C).bottom.disabled=g>=b-1},"refresh"));d(this,Ft,h(()=>{v.log("nine-table-vscrollbar.#init");const e=t(this,C).container,s=h(()=>{const o=(t(this,et).data.get()||[]).length,i=t(this,st).getRowHeight();return o*i},"getContentHeight");t(this,C).thumb.addEventListener("mousedown",r=>{if(r.button!==0)return;r.stopPropagation(),r.preventDefault(),p(this,dt,!0),p(this,St,r.clientY),p(this,Et,e.scrollTop);const o=h(a=>{if(!t(this,dt))return;const c=t(this,C).track.getBoundingClientRect(),l=t(this,C).thumb.clientHeight,g=c.height-l,b=a.clientY-t(this,St),u=e.clientHeight,m=s(),w=Math.max(m-u,1);if(g>0&&w>0){const T=b/g*w;let x=t(this,Et)+T;const _=Math.max(0,m-u);x<0&&(x=0),x>_&&(x=_),e.scrollTop=x}this.refresh()},"onMouseMove"),i=h(()=>{p(this,dt,!1),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",i),this.refresh()},"onMouseUp");document.addEventListener("mousemove",o),document.addEventListener("mouseup",i)}),t(this,C).track.addEventListener("mousedown",r=>{if(r.button!==0||r.target===t(this,C).thumb)return;const o=t(this,C).track.getBoundingClientRect(),i=t(this,C).thumb.clientHeight,a=r.clientY-o.top-i/2,l=o.height-i,f=e.clientHeight,g=s(),b=Math.max(g-f,1);if(l>0&&b>0){const u=Math.max(0,Math.min(1,a/l));e.scrollTop=u*b}this.refresh()}),t(this,C).top.addEventListener("click",()=>{e.scrollTop-=40}),t(this,C).bottom.addEventListener("click",()=>{e.scrollTop+=40})},"#init"))}connectedCallback(){p(this,et,this.getRootNode().host),p(this,st,this.closest("nine-table-sheet")),this.innerHTML=`
63
+ `;const e=h(()=>{const s=t(this,B).querySelector(".ng-container-body .ng-part-body");if(!s){setTimeout(e,10);return}p(this,q,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),left:this.querySelector(".ng-scroll-left"),right:this.querySelector(".ng-scroll-right")}),s.addEventListener("scroll",()=>{t(this,V)||this.refresh()}),t(this,jt).call(this),t(this,Pt).call(this),this.refresh()},"initWhenReady");e()}disconnectedCallback(){t(this,Q)&&t(this,Q).disconnect()}};B=new WeakMap,V=new WeakMap,q=new WeakMap,G=new WeakMap,J=new WeakMap,Q=new WeakMap,Pt=new WeakMap,tt=new WeakMap,jt=new WeakMap,h(Te,"NineTableHScrollBar");let F=Te;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",F);const ke=class ke extends HTMLElement{constructor(){super();d(this,et);d(this,st);d(this,ft,!1);d(this,k);d(this,Et,0);d(this,Rt,0);C(this,"refresh",h(()=>{if(y.log("vscrollbar.refresh"),!t(this,et)||!t(this,k))return;const e=t(this,k).container,s=t(this,k).track,r=t(this,k).thumb,o=e.clientHeight,i=t(this,et).data.length,a=t(this,st).getRowHeight(),c=i*a;if(c<=o||i===0){this.style.display="none";return}else this.style.display="flex";const l=s.clientHeight;if(l<=0)return;const f=Math.max(Math.min(l*(o/c),l),20);r.style.height=`${f}px`;const u=e.scrollTop,g=Math.max(c-o,1);y.log(e,u,g);let b=0;g>0&&(b=u/g*(l-f));const v=l-f;b<0&&(b=0),b>v&&(b=v),r.style.top=`${b}px`,t(this,k).top.disabled=u<=0,t(this,k).bottom.disabled=u>=g-1},"refresh"));d(this,Ft,h(()=>{y.log("nine-table-vscrollbar.#init");const e=t(this,k).container,s=h(()=>{const o=(t(this,et).data.get()||[]).length,i=t(this,st).getRowHeight();return o*i},"getContentHeight");t(this,k).thumb.addEventListener("mousedown",r=>{if(r.button!==0)return;r.stopPropagation(),r.preventDefault(),p(this,ft,!0),p(this,Et,r.clientY),p(this,Rt,e.scrollTop);const o=h(a=>{if(!t(this,ft))return;const c=t(this,k).track.getBoundingClientRect(),l=t(this,k).thumb.clientHeight,u=c.height-l,g=a.clientY-t(this,Et),b=e.clientHeight,v=s(),w=Math.max(v-b,1);if(u>0&&w>0){const A=g/u*w;let m=t(this,Rt)+A;const z=Math.max(0,v-b);m<0&&(m=0),m>z&&(m=z),e.scrollTop=m}this.refresh()},"onMouseMove"),i=h(()=>{p(this,ft,!1),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",i),this.refresh()},"onMouseUp");document.addEventListener("mousemove",o),document.addEventListener("mouseup",i)}),t(this,k).track.addEventListener("mousedown",r=>{if(r.button!==0||r.target===t(this,k).thumb)return;const o=t(this,k).track.getBoundingClientRect(),i=t(this,k).thumb.clientHeight,a=r.clientY-o.top-i/2,l=o.height-i,f=e.clientHeight,u=s(),g=Math.max(u-f,1);if(l>0&&g>0){const b=Math.max(0,Math.min(1,a/l));e.scrollTop=b*g}this.refresh()}),t(this,k).top.addEventListener("click",()=>{e.scrollTop-=40}),t(this,k).bottom.addEventListener("click",()=>{e.scrollTop+=40})},"#init"))}connectedCallback(){p(this,et,this.getRootNode().host),p(this,st,this.closest("nine-table-sheet")),this.innerHTML=`
64
64
  <style>
65
65
  nine-table-vscrollbar {
66
66
  display: flex;
@@ -123,7 +123,7 @@
123
123
  <button class='ng-scroll-top' disabled><div class='ng-scroll-icon'></div></button>
124
124
  <div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
125
125
  <button class='ng-scroll-bottom' disabled><div class='ng-scroll-icon'></div></button>
126
- `;const e=h(()=>{const s=t(this,st).querySelector(".ng-container-body .ng-part-body");if(!s){setTimeout(e,10);return}p(this,C,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),top:this.querySelector(".ng-scroll-top"),bottom:this.querySelector(".ng-scroll-bottom")}),t(this,Ft).call(this),this.refresh()},"initWhenReady");e()}};et=new WeakMap,st=new WeakMap,dt=new WeakMap,C=new WeakMap,St=new WeakMap,Et=new WeakMap,Ft=new WeakMap,h(Ce,"NineTableVScrollBar");let wt=Ce;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",wt);const Ie=class Ie{constructor(n){d(this,j);d(this,A);d(this,nt);d(this,D,new Map);d(this,N,null);d(this,Y,null);d(this,rt,0);d(this,At,40);d(this,Le,!1);d(this,He,!1);d(this,Vt,3);q(this,"refresh",h(()=>{var e;v.log("rowManager.refresh");const n=t(this,A).querySelector(".ng-container-body .ng-part-body");n&&(t(this,Rt).call(this),t(this,qt).call(this),t(this,ft).call(this,n.scrollTop),(e=t(this,A).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));q(this,"initialize",h(()=>{v.log("rowManager.initialize"),p(this,nt,{scrollTables:t(this,A).querySelectorAll(".ng-part-body table"),firstTr:t(this,A).querySelector(".ng-container-body .ng-part-body tbody.bindable-tbody tr:not(.nodata)")}),p(this,N,null),t(this,D).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(i=>{const a=t(this,A).querySelector(i);if(!a)return;const c=a.querySelector(".ng-part-body table");if(!c)return;const l=c.querySelector("tbody.bindable-tbody");if(!l)return;const g=Array.from(l.querySelectorAll("tr")).map(b=>b.cloneNode(!0));t(this,D).set(i,g)});const n=t(this,A).querySelector(".ng-container-body .ng-part-body"),e=t(this,A).querySelector(".ng-container-left .ng-part-body"),s=t(this,A).querySelector(".ng-container-right .ng-part-body"),r=t(this,A).querySelector(".ng-container-body .ng-part-header"),o=t(this,A).querySelector(".ng-container-body .ng-part-footer");if(n){t(this,Rt).call(this),t(this,kt).call(this),t(this,qt).call(this),t(this,ft).call(this,n.scrollTop);let i=!1;const a=h(c=>{var g;if(i)return;i=!0;const l=c.scrollTop,f=c.scrollLeft;n&&n.scrollTop!==l&&(n.scrollTop=l),e&&e.scrollTop!==l&&(e.scrollTop=l),s&&s.scrollTop!==l&&(s.scrollTop=l),r&&r.scrollLeft!==f&&(r.scrollLeft=f),o&&o.scrollLeft!==f&&(o.scrollLeft=f),t(this,ft).call(this,l),(g=t(this,A).querySelector("nine-table-vscrollbar"))==null||g.refresh(),i=!1},"handleContainerScroll");[n,e,s].forEach(c=>{c==null||c.addEventListener("scroll",()=>{a(c)})})}},"initialize"));d(this,Yt,h((n,e)=>{v.log("rowManager.#renderRows");const s=t(this,D).get(e);if(!s||s.length===0)return;const r=n.querySelector(".ng-part-body tbody.bindable-tbody");if(!r)return;r.querySelectorAll("tr:not(.nodata)").forEach(a=>a.remove());const o=r.querySelector("tr.nodata"),i=document.createDocumentFragment();for(let a=0;a<t(this,At);a++)s.forEach(c=>{i.appendChild(c.cloneNode(!0))});o?o.before(i):r.appendChild(i),e===".ng-container-body"&&(t(this,nt).firstTr=r.querySelector("tr:not(.nodata)"))},"#renderRows"));d(this,Rt,h(()=>{if(t(this,N)!==null&&t(this,N)>0)return t(this,N);const n=t(this,A).querySelector(".ng-container-body .ng-part-body");v.log("rowManager.#measureAndCacheHeight");const e=t(this,D).get(".ng-container-body");if(!e||e.length===0)throw new Error("invalid dom");const s=n.querySelector("tbody.bindable-tbody");if(v.log(s),!s)throw new Error("invalid dom");s.querySelectorAll("tr:not(.nodata)").forEach(b=>b.remove());const r=s.querySelector("tr.nodata"),o=document.createDocumentFragment();e.forEach(b=>{o.appendChild(b.cloneNode(!0))}),r?r.before(o):s.appendChild(o);const i=t(this,A),a=i.style.display,c=i.style.visibility,l=i.style.position;(a==="none"||window.getComputedStyle(i).display==="none")&&(i.style.display="block",i.style.visibility="hidden",i.style.position="absolute");let f=0;const g=s.querySelectorAll("tr");return g.forEach(b=>{let u=b.offsetHeight||b.getBoundingClientRect().height;if(u===0){const m=window.getComputedStyle(b);u=parseFloat(m.height)||parseFloat(m.minHeight)||0}f+=u}),g.forEach(b=>b.remove()),i.style.display=a,i.style.visibility=c,i.style.position=l,f<=0?-1:(p(this,N,f),t(this,Tt).call(this),t(this,N))},"#measureAndCacheHeight"));d(this,qt,h(()=>{v.log("rowManager.#updateVirtualScrollHeight");const e=(t(this,j).data.get()||[]).length,s=t(this,N),r=e*s;v.log("🔍 [VirtualHeight]",{totalCount:e,rowHeight:s,totalVirtualHeight:r}),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const i=t(this,A).querySelector(o);if(!i)return;const a=i.querySelector(".ng-part-body .ng-virtual-spacer");a&&(a.style.height=`${r}px`)})},"#updateVirtualScrollHeight"));d(this,Tt,h(()=>{if(t(this,rt)>0&&t(this,N)>0){const n=Math.ceil(t(this,rt)/t(this,N));p(this,At,n+t(this,Vt))}},"#updateRowCount"));d(this,Ut,h(()=>{var a,c,l,f,g,b;const n=t(this,A).querySelector(".ng-container-left .ng-part-body table"),e=t(this,A).querySelector(".ng-container-body .ng-part-body table"),s=t(this,A).querySelector(".ng-container-right .ng-part-body table");if(e){const u=n?Array.from(n.querySelectorAll("tbody tr")):[],m=Array.from(e.querySelectorAll("tbody tr")),w=s?Array.from(s.querySelectorAll("tbody tr")):[],T=Math.max(u.length,m.length,w.length);for(let x=0;x<T;x++){const _=[((a=u[x])==null?void 0:a.getBoundingClientRect().height)||0,((c=m[x])==null?void 0:c.getBoundingClientRect().height)||0,((l=w[x])==null?void 0:l.getBoundingClientRect().height)||0],k=Math.max(..._);k>0&&(u[x]&&(u[x].style.height=`${k}px`),m[x]&&(m[x].style.height=`${k}px`),w[x]&&(w[x].style.height=`${k}px`))}}const r=t(this,A).querySelector(".ng-container-left .ng-part-footer table"),o=t(this,A).querySelector(".ng-container-body .ng-part-footer table"),i=t(this,A).querySelector(".ng-container-right .ng-part-footer table");if(o){const u=r?Array.from(r.querySelectorAll("tfoot tr")):[],m=Array.from(o.querySelectorAll("tfoot tr")),w=i?Array.from(i.querySelectorAll("tfoot tr")):[],T=Math.max(u.length,m.length,w.length);for(let x=0;x<T;x++){const _=[((f=u[x])==null?void 0:f.getBoundingClientRect().height)||0,((g=m[x])==null?void 0:g.getBoundingClientRect().height)||0,((b=w[x])==null?void 0:b.getBoundingClientRect().height)||0],k=Math.max(..._);k>0&&(u[x]&&(u[x].style.height=`${k}px`),m[x]&&(m[x].style.height=`${k}px`),w[x]&&(w[x].style.height=`${k}px`))}}},"#syncRowHeights"));d(this,Xt,h(()=>{!t(this,A)||!(t(this,A)instanceof HTMLElement)||(p(this,Y,new ResizeObserver(n=>{for(const e of n){const s=e.target;if(!s.classList.contains("active"))continue;const r=e.contentRect.height;if(r>0){let o=0;const i=s.querySelector(".ng-part-header"),a=s.querySelector(".ng-part-footer");i&&(o+=i.offsetHeight),a&&(o+=a.offsetHeight);const c=Math.max(r-o,100);t(this,rt)!==c&&(p(this,rt,c),t(this,Tt).call(this),t(this,N)!==null&&(t(this,kt).call(this),this.refresh()))}}})),t(this,Y).observe(t(this,A)))},"#initResizeObserver"));d(this,kt,h(()=>{v.log("rowManager.#renderAllContainers"),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const e=t(this,A).querySelector(n);e&&e.querySelector(".ng-part-body tbody.bindable-tbody")&&t(this,Yt).call(this,e,n)}),t(this,Kt).call(this),t(this,Ut).call(this)},"#renderAllContainers"));d(this,Me,h(n=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(e=>{var l;const s=t(this,A).querySelector(e);if(!s)return;const r=s.querySelector(".ng-part-body tbody.bindable-tbody");if(!r)return;const o=Array.from(r.querySelectorAll("tr:not(.nodata)")),i=((l=t(this,D).get(e))==null?void 0:l.length)||1,c=(t(this,j).data.get()||[]).length;o.forEach((f,g)=>{const b=n+Math.floor(g/i);if(b>=c){f.style.visibility="hidden";return}const u=t(this,j).data.get(b);f.style.display="",t(this,Ct).call(this,f,u,b)})})},"#adjustBufferRows"));d(this,ft,h(n=>{var g,b;const e=t(this,N);if(!e||e<=0)return;const s=t(this,j).data.length;if(s===0)return;const r=((g=t(this,D).get(".ng-container-body"))==null?void 0:g.length)||1,o=t(this,A).querySelector(".ng-container-body .ng-part-body");v.log("bodyContainer.clientHeight",o.clientHeight);const i=Math.max(0,s-Math.floor(o.clientHeight/e)),a=Math.min(i,Math.max(0,Math.floor(n/e)));let c=Math.floor(a*e);v.log(`📜 [Scroll Calc] maxStartIndex: ${i}, startIndex: ${a}, offsetY: ${c}`),a===i&&v.log(`📜 [Scroll Inspect] scrollTop: ${n}, rowHeight: ${e}, maxStartIndex: ${i}, startIndex: ${a}, offsetY: ${c}`);const l=t(this,nt).firstTr,f=l&&l.dataset.row!==void 0?parseInt(l.dataset.row,10):-1;(b=t(this,nt))==null||b.scrollTables.forEach(u=>{u.style.transform=`translate3d(0, ${c}px, 0)`}),f!==a&&(v.log(`🔄 [Row Bind Trigger] currentStartIndex(${f}) !== startIndex(${a})`),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(u=>{const m=t(this,A).querySelector(u);if(!m)return;const w=m.querySelector(".ng-part-body tbody.bindable-tbody");if(!w)return;Array.from(w.querySelectorAll("tr:not(.nodata)")).forEach((x,_)=>{const k=a+Math.floor(_/r);if(k>=s){x.style.display="none";return}const O=t(this,j).data.get(k);x.style.display="",t(this,Ct).call(this,x,O,k)})}))},"#handleScroll"));d(this,Ct,h((n,e,s)=>{n.dataset.row=s,n.data=e,Array.from(n.cells).forEach((r,o)=>{r.dataset.row=s;const i=Array.from(r.children).find(a=>a.tagName.toLowerCase().startsWith("cell-")||typeof a.refresh=="function");i&&typeof i.refresh=="function"&&i.refresh()})},"#bindRowData"));d(this,Kt,h(()=>{var c,l,f;v.log("rowManager.#syncHeaderHeights");const n=t(this,A).querySelector(".ng-container-left .ng-part-header table"),e=t(this,A).querySelector(".ng-container-body .ng-part-header table"),s=t(this,A).querySelector(".ng-container-right .ng-part-header table");if(!e)return;const r=n?Array.from(n.querySelectorAll("tr")):[],o=Array.from(e.querySelectorAll("tr")),i=s?Array.from(s.querySelectorAll("tr")):[],a=Math.max(r.length,o.length,i.length);for(let g=0;g<a;g++){const b=[((c=r[g])==null?void 0:c.getBoundingClientRect().height)||0,((l=o[g])==null?void 0:l.getBoundingClientRect().height)||0,((f=i[g])==null?void 0:f.getBoundingClientRect().height)||0],u=Math.max(...b);u>0&&(r[g]&&(r[g].style.height=`${u}px`),o[g]&&(o[g].style.height=`${u}px`),i[g]&&(i[g].style.height=`${u}px`))}},"#syncHeaderHeights"));q(this,"destroy",h(()=>{t(this,Y)&&(t(this,Y).disconnect(),p(this,Y,null))},"destroy"));p(this,j,n.getRootNode().host),p(this,A,n),t(this,Xt).call(this)}getRowHeight(){return t(this,N)}templateLength(n=".ng-container-body"){var e;return((e=t(this,D).get(n))==null?void 0:e.length)||1}};j=new WeakMap,A=new WeakMap,nt=new WeakMap,D=new WeakMap,N=new WeakMap,Y=new WeakMap,rt=new WeakMap,At=new WeakMap,Le=new WeakMap,He=new WeakMap,Vt=new WeakMap,Yt=new WeakMap,Rt=new WeakMap,qt=new WeakMap,Tt=new WeakMap,Ut=new WeakMap,Xt=new WeakMap,kt=new WeakMap,Me=new WeakMap,ft=new WeakMap,Ct=new WeakMap,Kt=new WeakMap,h(Ie,"RowManager");let ue=Ie;const Zt=class Zt{static compileAll(n){return Array.isArray(n)?n.map(e=>Zt.compile(e)):[]}static compile(n){if(!n)return null;const e=h(a=>{a.querySelectorAll("tbody td, tbody th, tfoot td, tfoot th").forEach(l=>{const f=l.getAttribute("cell-type")||"renderer";if(l.children.length>0&&l.firstElementChild.tagName.includes("-"))return;let g=`cell-${f}`;const b=l.getAttribute("data-bind"),u=l.getAttribute("data-expr"),m=l.getAttribute("maxbyte"),w=l.getAttribute("type");let T=[];b&&T.push(`data-bind="${b}"`),u&&T.push(`data-expr="${u}"`),m&&T.push(`maxbyte="${m}"`),w&&T.push(`type="${w}"`),l.innerHTML=`<${g} ${T.join(" ")}></${g}>`})},"processCellTypes"),s=h(a=>{if(!a.querySelector("colgroup")){const c=a.querySelector("tbody tr")||a.querySelector("tr"),l=c?c.querySelectorAll("th, td").length:1,f=document.createElement("colgroup"),g=Math.max(Math.floor(a.clientWidth/l),100);for(let b=0;b<l;b++){const u=document.createElement("col");u.setAttribute("width",g),f.appendChild(u)}a.prepend(f)}if(!a.querySelector("thead")){const c=document.createElement("thead"),l=a.querySelector("colgroup");l?l.after(c):a.prepend(c)}a.classList.add("nine-table-element")},"ensureTableStructure"),r=h((a,c)=>{const l=Array.from(a.querySelectorAll(c+" tr")),f=Array.from(a.querySelectorAll(c+" th,"+c+" td")),g=l.length;if(g===0||f.length===0)return;let b=0;f.forEach(m=>{b+=m.colSpan||1});const u=Array.from(Array(g),()=>Array(b).fill(null));l.forEach(m=>{const w=m.sectionRowIndex;let T=0;Array.from(m.querySelectorAll("th,td")).forEach(x=>{for(let O=0;O<u[w].length;O++)if(u[w][O]===null){T=O;break}const _=x.rowSpan||1,k=x.colSpan||1;for(let O=0;O<_;O++)for(let Z=0;Z<k;Z++)w+O<g&&T+Z<b&&(u[w+O][T+Z]=O===0&&Z===0?"1":"0")})}),l.forEach(m=>{const w=m.sectionRowIndex;Array.from(m.querySelectorAll("th,td")).forEach(T=>{for(let x=0;x<u[w].length;x++)if(u[w][x]==="1"){T.dataset.col=x,u[w][x]="0";break}})})},"resetColIndex"),o=n.cloneNode(!0);return s(o),e(o),r(o,"thead"),r(o,"tbody"),r(o,"tfoot"),Array.from(o.querySelectorAll("colgroup col")).forEach((a,c)=>{const l=a.getAttribute("fixed");l&&o.querySelectorAll(`thead [data-col="${c}"], tbody [data-col="${c}"], tfoot [data-col="${c}"]`).forEach(f=>{f.setAttribute("fixed",l)})}),o}};h(Zt,"TableCompiler");let ge=Zt;const $e=class $e{constructor(n){d(this,ut);d(this,U);d(this,Lt,{startRow:-1,startCol:-1,endRow:-1,endCol:-1});q(this,"render",h(()=>{const{startRow:n,startCol:e,endRow:s,endCol:r}=t(this,Lt),o=t(this,U).querySelectorAll(".ng-container-top td, .ng-container-top th");o.forEach(i=>{i.classList.remove("selected","selected-top","selected-bottom","selected-left","selected-right")}),!(n<0||e<0)&&o.forEach(i=>{const a=i.closest("tr");if(!a||a.classList.contains("nodata"))return;const c=parseInt(a.dataset.row,10),l=parseInt(i.dataset.col,10);if(isNaN(c)||isNaN(l))return;const f=parseInt(i.rowSpan||1,10),g=parseInt(i.colSpan||1,10),b=c+f-1,u=l+g-1;c<=s&&b>=n&&l<=r&&u>=e&&(i.classList.add("selected"),c===n&&i.classList.add("selected-top"),b===s&&i.classList.add("selected-bottom"),l===e&&i.classList.add("selected-left"),u===r&&i.classList.add("selected-right"))})},"render"));p(this,U,n),Ge(this,ut,is).call(this)}setRange(n,e,s,r){let o=Math.min(n,s),i=Math.max(n,s),a=Math.min(e,r),c=Math.max(e,r);const l=Ge(this,ut,rs).call(this,o,a,i,c);p(this,Lt,l),this.render()}};U=new WeakMap,Lt=new WeakMap,ut=new WeakSet,rs=h(function(n,e,s,r){let o=n,i=e,a=s,c=r,l=!0;const f=t(this,U).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");for(;l;)l=!1,f.forEach(g=>{g.querySelectorAll("tbody tr").forEach(b=>{const u=parseInt(b.dataset.row,10);isNaN(u)||b.querySelectorAll("td, th").forEach(m=>{const w=parseInt(m.dataset.col,10);if(isNaN(w))return;const T=parseInt(m.rowSpan||1,10),x=parseInt(m.colSpan||1,10),_=u+T-1,k=w+x-1;if(u<=a&&_>=o&&w<=c&&k>=i){const Z=Math.min(o,u),Je=Math.max(a,_),Qe=Math.min(i,w),ts=Math.max(c,k);(Z!==o||Je!==a||Qe!==i||ts!==c)&&(o=Z,a=Je,i=Qe,c=ts,l=!0)}})})});return{startRow:o,startCol:i,endRow:a,endCol:c}},"#expandRangeByMerge"),is=h(function(){const n=t(this,U).querySelector(".ng-container-top");n&&n.addEventListener("mousedown",e=>{if(e.button!==0)return;const s=e.target.closest("td, th");if(!s||s.dataset.row===void 0||s.dataset.col===void 0||s.closest("tr").classList.contains("nodata"))return;const r=parseInt(s.dataset.row,10),o=parseInt(s.dataset.col,10);this.setRange(r,o,r,o);const i=h(c=>{const l=document.elementFromPoint(c.clientX,c.clientY),f=l==null?void 0:l.closest("td, th");if(!f||!t(this,U).contains(f)||f.dataset.row===void 0||f.dataset.col===void 0||f.closest("tr").classList.contains("nodata"))return;const g=parseInt(f.dataset.row,10),b=parseInt(f.dataset.col,10);this.setRange(r,o,g,b)},"onMouseMove"),a=h(()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",a)},"onMouseUp");document.addEventListener("mousemove",i),document.addEventListener("mouseup",a)})},"#initEvents"),h($e,"CellSelection");let be=$e;const Mt=class Mt extends HTMLElement{constructor(){super();d(this,Gt);d(this,it,null);d(this,ot);d(this,Ht);q(this,"invalidate",h(()=>{v.log("sheet.invalidate()"),t(this,ot).refresh()},"invalidate"));q(this,"generate",h(e=>{if(v.log("sheet.generate()"),!e)return;p(this,it,ge.compile(e)),t(this,Jt).call(this),t(this,Qt).call(this);const s=this.querySelector(".ng-container-body .ng-part-header"),r=this.querySelector(".ng-container-body .ng-part-footer"),o=this.querySelector(".ng-nodata-overlay");s&&o&&(o.style.top=`${s.offsetHeight}px`),r&&o&&(o.style.bottom=`${r.offsetHeight}px`),t(this,ot).initialize(),setTimeout(()=>{var i;(i=this.querySelector("nine-table-hscrollbar"))==null||i.refresh()},0)},"generate"));d(this,Jt,h(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:s,type:r})=>{var o,i,a;(o=this.querySelector(`${s} .ng-part-header`))==null||o.appendChild(t(this,gt).call(this,t(this,it),r,"header")),(i=this.querySelector(`${s} .ng-virtual-spacer`))==null||i.before(t(this,gt).call(this,t(this,it),r,"body")),(a=this.querySelector(`${s} .ng-part-footer`))==null||a.appendChild(t(this,gt).call(this,t(this,it),r,"footer"))})},"#renderSplitContainers"));d(this,Qt,h(()=>{["left","right","body"].forEach(e=>{const s=this.querySelector(`.ng-container-${e}`),r=s==null?void 0:s.querySelectorAll("table");if(!s||!r||r.length===0)return;let o=0;r[0].querySelectorAll("col").forEach(i=>{const a=parseInt(i.getAttribute("width"),10);isNaN(o)||(o+=a)}),e==="body"?s.style.flex="1":(s.style.flex=`0 0 ${o}px`,s.style.width=`${o}px`)})},"#updateContainerWidths"));d(this,gt,h((e,s,r)=>{const o=e.cloneNode(!0),i=o.querySelector("thead"),a=o.querySelector("tbody"),c=o.querySelector("tfoot");if(r==="header"){if(a&&a.remove(),c&&c.remove(),e.querySelector("tbody")){const f=document.createElement("tbody");f.className="fixed-tbody",o.appendChild(f)}}else r==="body"?(i&&i.remove(),c&&c.remove(),a&&(a.className="bindable-tbody")):r==="footer"&&(i&&i.remove(),a&&a.remove());return s==="left"?o.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="left"&&l.remove()}):s==="right"?o.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="right"&&l.remove()}):o.querySelectorAll("[fixed=left], [fixed=right]").forEach(l=>{l.remove()}),o},"#createSplitTable"));q(this,"getRowHeight",h(()=>t(this,ot).getRowHeight(),"getRowHeight"));q(this,"scrollToX",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollLeft=e)},"scrollToX"));q(this,"scrollToY",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollTop=e)},"scrollToY"));d(this,te,h(()=>{t(this,ee).call(this),p(this,Ht,new be(this))},"#init"));d(this,ee,h(()=>{const e=Mt.SCROLLBAR_SIZE;this.innerHTML=`
126
+ `;const e=h(()=>{const s=t(this,st).querySelector(".ng-container-body .ng-part-body");if(!s){setTimeout(e,10);return}p(this,k,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),top:this.querySelector(".ng-scroll-top"),bottom:this.querySelector(".ng-scroll-bottom")}),t(this,Ft).call(this),this.refresh()},"initWhenReady");e()}};et=new WeakMap,st=new WeakMap,ft=new WeakMap,k=new WeakMap,Et=new WeakMap,Rt=new WeakMap,Ft=new WeakMap,h(ke,"NineTableVScrollBar");let St=ke;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",St);const Ie=class Ie{constructor(n){d(this,j);d(this,R);d(this,nt);d(this,P,new Map);d(this,_,null);d(this,Y,null);d(this,rt,0);d(this,At,40);d(this,Le,!1);d(this,Me,!1);d(this,Vt,3);C(this,"refresh",h(()=>{var e;y.log("rowManager.refresh");const n=t(this,R).querySelector(".ng-container-body .ng-part-body");n&&(t(this,qt).call(this),t(this,Ct).call(this),t(this,ut).call(this,n.scrollTop),(e=t(this,R).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));C(this,"initialize",h(()=>{y.log("rowManager.initialize"),p(this,nt,{scrollTables:t(this,R).querySelectorAll(".ng-part-body table"),firstTr:t(this,R).querySelector(".ng-container-body .ng-part-body tbody.bindable-tbody tr:not(.nodata)")}),p(this,_,null),t(this,P).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(i=>{const a=t(this,R).querySelector(i);if(!a)return;const c=a.querySelector(".ng-part-body table");if(!c)return;const l=c.querySelector("tbody.bindable-tbody");if(!l)return;const u=Array.from(l.querySelectorAll("tr")).map(g=>g.cloneNode(!0));t(this,P).set(i,u)});const n=t(this,R).querySelector(".ng-container-body .ng-part-body"),e=t(this,R).querySelector(".ng-container-left .ng-part-body"),s=t(this,R).querySelector(".ng-container-right .ng-part-body"),r=t(this,R).querySelector(".ng-container-body .ng-part-header"),o=t(this,R).querySelector(".ng-container-body .ng-part-footer");if(n){t(this,qt).call(this),t(this,kt).call(this),t(this,Ct).call(this),t(this,ut).call(this,n.scrollTop);let i=!1;const a=h(c=>{var u;if(i)return;i=!0;const l=c.scrollTop,f=c.scrollLeft;n&&n.scrollTop!==l&&(n.scrollTop=l),e&&e.scrollTop!==l&&(e.scrollTop=l),s&&s.scrollTop!==l&&(s.scrollTop=l),r&&r.scrollLeft!==f&&(r.scrollLeft=f),o&&o.scrollLeft!==f&&(o.scrollLeft=f),t(this,ut).call(this,l),(u=t(this,R).querySelector("nine-table-vscrollbar"))==null||u.refresh(),i=!1},"handleContainerScroll");[n,e,s].forEach(c=>{c==null||c.addEventListener("scroll",()=>{a(c)})})}},"initialize"));d(this,Yt,h((n,e)=>{y.log("rowManager.#renderRows");const s=t(this,P).get(e);if(!s||s.length===0)return;const r=n.querySelector(".ng-part-body tbody.bindable-tbody");if(!r)return;r.querySelectorAll("tr:not(.nodata)").forEach(a=>a.remove());const o=r.querySelector("tr.nodata"),i=document.createDocumentFragment();for(let a=0;a<t(this,At);a++)s.forEach(c=>{i.appendChild(c.cloneNode(!0))});o?o.before(i):r.appendChild(i),e===".ng-container-body"&&(t(this,nt).firstTr=r.querySelector("tr:not(.nodata)"))},"#renderRows"));d(this,qt,h(()=>{if(t(this,_)!==null&&t(this,_)>0)return t(this,_);const n=t(this,R).querySelector(".ng-container-body .ng-part-body");y.log("rowManager.#measureAndCacheHeight");const e=t(this,P).get(".ng-container-body");if(!e||e.length===0)throw new Error("invalid dom");const s=n.querySelector("tbody.bindable-tbody");if(y.log(s),!s)throw new Error("invalid dom");s.querySelectorAll("tr:not(.nodata)").forEach(g=>g.remove());const r=s.querySelector("tr.nodata"),o=document.createDocumentFragment();e.forEach(g=>{o.appendChild(g.cloneNode(!0))}),r?r.before(o):s.appendChild(o);const i=t(this,R),a=i.style.display,c=i.style.visibility,l=i.style.position;(a==="none"||window.getComputedStyle(i).display==="none")&&(i.style.display="block",i.style.visibility="hidden",i.style.position="absolute");let f=0;const u=s.querySelectorAll("tr");return u.forEach(g=>{let b=g.offsetHeight||g.getBoundingClientRect().height;if(b===0){const v=window.getComputedStyle(g);b=parseFloat(v.height)||parseFloat(v.minHeight)||0}f+=b}),u.forEach(g=>g.remove()),i.style.display=a,i.style.visibility=c,i.style.position=l,f<=0?-1:(p(this,_,f),t(this,Tt).call(this),t(this,_))},"#measureAndCacheHeight"));d(this,Ct,h(()=>{y.log("rowManager.#updateVirtualScrollHeight");const e=(t(this,j).data.get()||[]).length,s=t(this,_),r=e*s;y.log("🔍 [VirtualHeight]",{totalCount:e,rowHeight:s,totalVirtualHeight:r}),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const i=t(this,R).querySelector(o);if(!i)return;const a=i.querySelector(".ng-part-body .ng-virtual-spacer");a&&(a.style.height=`${r}px`)})},"#updateVirtualScrollHeight"));d(this,Tt,h(()=>{if(t(this,rt)>0&&t(this,_)>0){const n=Math.ceil(t(this,rt)/t(this,_));p(this,At,n+t(this,Vt))}},"#updateRowCount"));d(this,Ut,h(()=>{var a,c,l,f,u,g;const n=t(this,R).querySelector(".ng-container-left .ng-part-body table"),e=t(this,R).querySelector(".ng-container-body .ng-part-body table"),s=t(this,R).querySelector(".ng-container-right .ng-part-body table");if(e){const b=n?Array.from(n.querySelectorAll("tbody tr")):[],v=Array.from(e.querySelectorAll("tbody tr")),w=s?Array.from(s.querySelectorAll("tbody tr")):[],A=Math.max(b.length,v.length,w.length);for(let m=0;m<A;m++){const z=[((a=b[m])==null?void 0:a.getBoundingClientRect().height)||0,((c=v[m])==null?void 0:c.getBoundingClientRect().height)||0,((l=w[m])==null?void 0:l.getBoundingClientRect().height)||0],T=Math.max(...z);T>0&&(b[m]&&(b[m].style.height=`${T}px`),v[m]&&(v[m].style.height=`${T}px`),w[m]&&(w[m].style.height=`${T}px`))}}const r=t(this,R).querySelector(".ng-container-left .ng-part-footer table"),o=t(this,R).querySelector(".ng-container-body .ng-part-footer table"),i=t(this,R).querySelector(".ng-container-right .ng-part-footer table");if(o){const b=r?Array.from(r.querySelectorAll("tfoot tr")):[],v=Array.from(o.querySelectorAll("tfoot tr")),w=i?Array.from(i.querySelectorAll("tfoot tr")):[],A=Math.max(b.length,v.length,w.length);for(let m=0;m<A;m++){const z=[((f=b[m])==null?void 0:f.getBoundingClientRect().height)||0,((u=v[m])==null?void 0:u.getBoundingClientRect().height)||0,((g=w[m])==null?void 0:g.getBoundingClientRect().height)||0],T=Math.max(...z);T>0&&(b[m]&&(b[m].style.height=`${T}px`),v[m]&&(v[m].style.height=`${T}px`),w[m]&&(w[m].style.height=`${T}px`))}}},"#syncRowHeights"));d(this,Xt,h(()=>{!t(this,R)||!(t(this,R)instanceof HTMLElement)||(p(this,Y,new ResizeObserver(n=>{for(const e of n){const s=e.target;if(!s.classList.contains("active"))continue;const r=e.contentRect.height;if(r>0){let o=0;const i=s.querySelector(".ng-part-header"),a=s.querySelector(".ng-part-footer");i&&(o+=i.offsetHeight),a&&(o+=a.offsetHeight);const c=Math.max(r-o,100);t(this,rt)!==c&&(p(this,rt,c),t(this,Tt).call(this),t(this,_)!==null&&(t(this,kt).call(this),this.refresh()))}}})),t(this,Y).observe(t(this,R)))},"#initResizeObserver"));d(this,kt,h(()=>{y.log("rowManager.#renderAllContainers"),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const e=t(this,R).querySelector(n);e&&e.querySelector(".ng-part-body tbody.bindable-tbody")&&t(this,Yt).call(this,e,n)}),t(this,Kt).call(this),t(this,Ut).call(this)},"#renderAllContainers"));d(this,He,h(n=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(e=>{var l;const s=t(this,R).querySelector(e);if(!s)return;const r=s.querySelector(".ng-part-body tbody.bindable-tbody");if(!r)return;const o=Array.from(r.querySelectorAll("tr:not(.nodata)")),i=((l=t(this,P).get(e))==null?void 0:l.length)||1,c=(t(this,j).data.get()||[]).length;o.forEach((f,u)=>{const g=n+Math.floor(u/i);if(g>=c){f.style.visibility="hidden";return}const b=t(this,j).data.get(g);f.style.display="",t(this,Lt).call(this,f,b,g)})})},"#adjustBufferRows"));d(this,ut,h(n=>{var u,g;const e=t(this,_);if(!e||e<=0)return;const s=t(this,j).data.length;if(s===0)return;const r=((u=t(this,P).get(".ng-container-body"))==null?void 0:u.length)||1,o=t(this,R).querySelector(".ng-container-body .ng-part-body");y.log("bodyContainer.clientHeight",o.clientHeight);const i=Math.max(0,s-Math.floor(o.clientHeight/e)),a=Math.min(i,Math.max(0,Math.floor(n/e)));let c=Math.floor(a*e);y.log(`📜 [Scroll Calc] maxStartIndex: ${i}, startIndex: ${a}, offsetY: ${c}`),a===i&&y.log(`📜 [Scroll Inspect] scrollTop: ${n}, rowHeight: ${e}, maxStartIndex: ${i}, startIndex: ${a}, offsetY: ${c}`);const l=t(this,nt).firstTr,f=l&&l.dataset.row!==void 0?parseInt(l.dataset.row,10):-1;(g=t(this,nt))==null||g.scrollTables.forEach(b=>{b.style.transform=`translate3d(0, ${c}px, 0)`}),f!==a&&(y.log(`🔄 [Row Bind Trigger] currentStartIndex(${f}) !== startIndex(${a})`),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(b=>{const v=t(this,R).querySelector(b);if(!v)return;const w=v.querySelector(".ng-part-body tbody.bindable-tbody");if(!w)return;Array.from(w.querySelectorAll("tr:not(.nodata)")).forEach((m,z)=>{const T=a+Math.floor(z/r);if(T>=s){m.style.display="none";return}const D=t(this,j).data.get(T);m.style.display="",t(this,Lt).call(this,m,D,T)})}))},"#handleScroll"));d(this,Lt,h((n,e,s)=>{n.dataset.row=s,n.data=e,Array.from(n.cells).forEach((r,o)=>{r.dataset.row=s;const i=Array.from(r.children).find(a=>a.tagName.toLowerCase().startsWith("cell-")||typeof a.refresh=="function");i&&typeof i.refresh=="function"&&i.refresh()})},"#bindRowData"));d(this,Kt,h(()=>{var c,l,f;y.log("rowManager.#syncHeaderHeights");const n=t(this,R).querySelector(".ng-container-left .ng-part-header table"),e=t(this,R).querySelector(".ng-container-body .ng-part-header table"),s=t(this,R).querySelector(".ng-container-right .ng-part-header table");if(!e)return;const r=n?Array.from(n.querySelectorAll("tr")):[],o=Array.from(e.querySelectorAll("tr")),i=s?Array.from(s.querySelectorAll("tr")):[],a=Math.max(r.length,o.length,i.length);for(let u=0;u<a;u++){const g=[((c=r[u])==null?void 0:c.getBoundingClientRect().height)||0,((l=o[u])==null?void 0:l.getBoundingClientRect().height)||0,((f=i[u])==null?void 0:f.getBoundingClientRect().height)||0],b=Math.max(...g);b>0&&(r[u]&&(r[u].style.height=`${b}px`),o[u]&&(o[u].style.height=`${b}px`),i[u]&&(i[u].style.height=`${b}px`))}},"#syncHeaderHeights"));C(this,"destroy",h(()=>{t(this,Y)&&(t(this,Y).disconnect(),p(this,Y,null))},"destroy"));p(this,j,n.getRootNode().host),p(this,R,n),t(this,Xt).call(this)}getRowHeight(){return t(this,_)}templateLength(n=".ng-container-body"){var e;return((e=t(this,P).get(n))==null?void 0:e.length)||1}};j=new WeakMap,R=new WeakMap,nt=new WeakMap,P=new WeakMap,_=new WeakMap,Y=new WeakMap,rt=new WeakMap,At=new WeakMap,Le=new WeakMap,Me=new WeakMap,Vt=new WeakMap,Yt=new WeakMap,qt=new WeakMap,Ct=new WeakMap,Tt=new WeakMap,Ut=new WeakMap,Xt=new WeakMap,kt=new WeakMap,He=new WeakMap,ut=new WeakMap,Lt=new WeakMap,Kt=new WeakMap,h(Ie,"RowManager");let ue=Ie;const Zt=class Zt{static compileAll(n){return Array.isArray(n)?n.map(e=>Zt.compile(e)):[]}static compile(n){if(!n)return null;const e=h(a=>{a.querySelectorAll("tbody td, tbody th, tfoot td, tfoot th").forEach(l=>{const f=l.getAttribute("cell-type")||"renderer";if(l.children.length>0&&l.firstElementChild.tagName.includes("-"))return;let u=`cell-${f}`;const g=l.getAttribute("data-bind"),b=l.getAttribute("data-expr"),v=l.getAttribute("maxbyte"),w=l.getAttribute("type");let A=[];g&&A.push(`data-bind="${g}"`),b&&A.push(`data-expr="${b}"`),v&&A.push(`maxbyte="${v}"`),w&&A.push(`type="${w}"`),l.innerHTML=`<${u} ${A.join(" ")}></${u}>`})},"processCellTypes"),s=h(a=>{if(!a.querySelector("colgroup")){const c=a.querySelector("tbody tr")||a.querySelector("tr"),l=c?c.querySelectorAll("th, td").length:1,f=document.createElement("colgroup"),u=Math.max(Math.floor(a.clientWidth/l),100);for(let g=0;g<l;g++){const b=document.createElement("col");b.setAttribute("width",u),f.appendChild(b)}a.prepend(f)}if(!a.querySelector("thead")){const c=document.createElement("thead"),l=a.querySelector("colgroup");l?l.after(c):a.prepend(c)}a.classList.add("nine-table-element")},"ensureTableStructure"),r=h((a,c)=>{const l=Array.from(a.querySelectorAll(c+" tr")),f=Array.from(a.querySelectorAll(c+" th,"+c+" td")),u=l.length;if(u===0||f.length===0)return;let g=0;f.forEach(v=>{g+=v.colSpan||1});const b=Array.from(Array(u),()=>Array(g).fill(null));l.forEach(v=>{const w=v.sectionRowIndex;let A=0;Array.from(v.querySelectorAll("th,td")).forEach(m=>{for(let D=0;D<b[w].length;D++)if(b[w][D]===null){A=D;break}const z=m.rowSpan||1,T=m.colSpan||1;for(let D=0;D<z;D++)for(let Z=0;Z<T;Z++)w+D<u&&A+Z<g&&(b[w+D][A+Z]=D===0&&Z===0?"1":"0")})}),l.forEach(v=>{const w=v.sectionRowIndex;Array.from(v.querySelectorAll("th,td")).forEach(A=>{for(let m=0;m<b[w].length;m++)if(b[w][m]==="1"){A.dataset.col=m,b[w][m]="0";break}})})},"resetColIndex"),o=n.cloneNode(!0);return s(o),e(o),r(o,"thead"),r(o,"tbody"),r(o,"tfoot"),Array.from(o.querySelectorAll("colgroup col")).forEach((a,c)=>{const l=a.getAttribute("fixed");l&&o.querySelectorAll(`thead [data-col="${c}"], tbody [data-col="${c}"], tfoot [data-col="${c}"]`).forEach(f=>{f.setAttribute("fixed",l)})}),o}};h(Zt,"TableCompiler");let ge=Zt;const $e=class $e{constructor(n){d(this,gt);d(this,U);d(this,ot,{startRow:-1,startCol:-1,endRow:-1,endCol:-1});C(this,"render",h(()=>{const{startRow:n,startCol:e,endRow:s,endCol:r}=t(this,ot);y.log("🎨 [CellSelection.render] Rendering range ->",t(this,ot));const o=t(this,U).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");if(o.forEach(a=>{a.querySelectorAll(".selected, .selected-top, .selected-bottom, .selected-left, .selected-right").forEach(c=>{c.classList.remove("selected","selected-top","selected-bottom","selected-left","selected-right")})}),n<0||e<0){y.log("⚠️ [CellSelection.render] Range is invalid (< 0), skipping render.");return}let i=0;o.forEach((a,c)=>{a.querySelectorAll("tbody tr").forEach(l=>{if(l.classList.contains("nodata"))return;const f=parseInt(l.dataset.row,10);isNaN(f)||l.querySelectorAll("td, th").forEach(u=>{const g=parseInt(u.dataset.col,10);if(isNaN(g))return;const b=parseInt(u.rowSpan||1,10),v=parseInt(u.colSpan||1,10),w=f+b-1,A=g+v-1;f<=s&&w>=n&&g<=r&&A>=e&&(i++,u.classList.add("selected"),f===n&&u.classList.add("selected-top"),w===s&&u.classList.add("selected-bottom"),g===e&&u.classList.add("selected-left"),A===r&&u.classList.add("selected-right"))})})}),y.log(`✨ [CellSelection.render] Total rendered cells marked: ${i}`)},"render"));p(this,U,n),Ge(this,gt,is).call(this),y.log("🎯 [CellSelection] Initialized")}setRange(n,e,s,r){y.log(`🔍 [CellSelection.setRange] Input -> startRow: ${n}, startCol: ${e}, endRow: ${s}, endCol: ${r}`);let o=Math.min(n,s),i=Math.max(n,s),a=Math.min(e,r),c=Math.max(e,r);const l=Ge(this,gt,os).call(this,o,a,i,c);p(this,ot,l),y.log("📦 [CellSelection.setRange] Expanded Range ->",t(this,ot)),this.render()}};U=new WeakMap,ot=new WeakMap,gt=new WeakSet,os=h(function(n,e,s,r){let o=n,i=e,a=s,c=r,l=!0,f=0;const u=t(this,U).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");for(;l&&f<10;)l=!1,f++,u.forEach((g,b)=>{g.querySelectorAll("tbody tr").forEach(v=>{const w=parseInt(v.dataset.row,10);isNaN(w)||v.querySelectorAll("td, th").forEach(A=>{const m=parseInt(A.dataset.col,10);if(isNaN(m))return;const z=parseInt(A.rowSpan||1,10),T=parseInt(A.colSpan||1,10),D=w+z-1,Z=m+T-1;if(w<=a&&D>=o&&m<=c&&Z>=i){const Je=Math.min(o,w),Qe=Math.max(a,D),ts=Math.min(i,m),es=Math.max(c,Z);(Je!==o||Qe!==a||ts!==i||es!==c)&&(o=Je,a=Qe,i=ts,c=es,l=!0)}})})});return{startRow:o,startCol:i,endRow:a,endCol:c}},"#expandRangeByMerge"),is=h(function(){const n=t(this,U).querySelector(".ng-container-top");if(!n){y.log("❌ [CellSelection] .ng-container-top not found!");return}n.addEventListener("mousedown",e=>{if(e.button!==0)return;const s=e.target.closest("td, th");if(!s){y.log("🖱️ [MouseDown] Target is not td or th:",e.target);return}if(s.dataset.row===void 0||s.dataset.col===void 0){y.log("🖱️ [MouseDown] Cell missing dataset.row or dataset.col:",s);return}if(s.closest("tr").classList.contains("nodata")){y.log("🖱️ [MouseDown] Clicked on .nodata row");return}const r=parseInt(s.dataset.row,10),o=parseInt(s.dataset.col,10);y.log(`🖱️ [MouseDown Success] startRow: ${r}, startCol: ${o}`),this.setRange(r,o,r,o);const i=h(c=>{const l=document.elementFromPoint(c.clientX,c.clientY),f=l==null?void 0:l.closest("td, th");if(!f||!t(this,U).contains(f)||f.dataset.row===void 0||f.dataset.col===void 0||f.closest("tr").classList.contains("nodata"))return;const u=parseInt(f.dataset.row,10),g=parseInt(f.dataset.col,10);y.log(`🏃 [MouseMove Dragging] endRow: ${u}, endCol: ${g}`),this.setRange(r,o,u,g)},"onMouseMove"),a=h(()=>{y.log("🖱️ [MouseUp] Drag ended."),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",a)},"onMouseUp");document.addEventListener("mousemove",i),document.addEventListener("mouseup",a)})},"#initEvents"),h($e,"CellSelection");let be=$e;const Ht=class Ht extends HTMLElement{constructor(){super();d(this,Gt);d(this,it,null);d(this,at);d(this,Mt);C(this,"invalidate",h(()=>{y.log("sheet.invalidate()"),t(this,at).refresh()},"invalidate"));C(this,"generate",h(e=>{if(y.log("sheet.generate()"),!e)return;p(this,it,ge.compile(e)),t(this,Jt).call(this),t(this,Qt).call(this);const s=this.querySelector(".ng-container-body .ng-part-header"),r=this.querySelector(".ng-container-body .ng-part-footer"),o=this.querySelector(".ng-nodata-overlay");s&&o&&(o.style.top=`${s.offsetHeight}px`),r&&o&&(o.style.bottom=`${r.offsetHeight}px`),t(this,at).initialize(),setTimeout(()=>{var i;(i=this.querySelector("nine-table-hscrollbar"))==null||i.refresh()},0)},"generate"));d(this,Jt,h(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:s,type:r})=>{var o,i,a;(o=this.querySelector(`${s} .ng-part-header`))==null||o.appendChild(t(this,bt).call(this,t(this,it),r,"header")),(i=this.querySelector(`${s} .ng-virtual-spacer`))==null||i.before(t(this,bt).call(this,t(this,it),r,"body")),(a=this.querySelector(`${s} .ng-part-footer`))==null||a.appendChild(t(this,bt).call(this,t(this,it),r,"footer"))})},"#renderSplitContainers"));d(this,Qt,h(()=>{["left","right","body"].forEach(e=>{const s=this.querySelector(`.ng-container-${e}`),r=s==null?void 0:s.querySelectorAll("table");if(!s||!r||r.length===0)return;let o=0;r[0].querySelectorAll("col").forEach(i=>{const a=parseInt(i.getAttribute("width"),10);isNaN(o)||(o+=a)}),e==="body"?s.style.flex="1":(s.style.flex=`0 0 ${o}px`,s.style.width=`${o}px`)})},"#updateContainerWidths"));d(this,bt,h((e,s,r)=>{const o=e.cloneNode(!0),i=o.querySelector("thead"),a=o.querySelector("tbody"),c=o.querySelector("tfoot");if(r==="header"){if(a&&a.remove(),c&&c.remove(),e.querySelector("tbody")){const f=document.createElement("tbody");f.className="fixed-tbody",o.appendChild(f)}}else r==="body"?(i&&i.remove(),c&&c.remove(),a&&(a.className="bindable-tbody")):r==="footer"&&(i&&i.remove(),a&&a.remove());return s==="left"?o.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="left"&&l.remove()}):s==="right"?o.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="right"&&l.remove()}):o.querySelectorAll("[fixed=left], [fixed=right]").forEach(l=>{l.remove()}),o},"#createSplitTable"));C(this,"getRowHeight",h(()=>t(this,at).getRowHeight(),"getRowHeight"));C(this,"scrollToX",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollLeft=e)},"scrollToX"));C(this,"scrollToY",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollTop=e)},"scrollToY"));d(this,te,h(()=>{t(this,ee).call(this),p(this,Mt,new be(this))},"#init"));d(this,ee,h(()=>{const e=Ht.SCROLLBAR_SIZE;this.innerHTML=`
127
127
  <style>
128
128
  nine-table-sheet {
129
129
  display: none;
@@ -320,7 +320,7 @@
320
320
  <nine-table-hscrollbar></nine-table-hscrollbar>
321
321
  <div class='ng-scroll-edge'></div>
322
322
  </div>
323
- `},"#render"));p(this,ot,new ue(this)),p(this,Gt,this.getRootNode().host)}connectedCallback(){t(this,te).call(this)}get selection(){return t(this,Ht)}disconnectedCallback(){this.innerHTML="",v.log("NineTableSheet destroyed.")}};Gt=new WeakMap,it=new WeakMap,ot=new WeakMap,Ht=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,gt=new WeakMap,te=new WeakMap,ee=new WeakMap,h(Mt,"NineTableSheet"),q(Mt,"SCROLLBAR_SIZE",16);let Pt=Mt;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",Pt);const _e=class _e extends HTMLElement{constructor(){super();d(this,se,h(()=>{var e;(e=this.querySelector(".nine-tab-bar"))==null||e.addEventListener("click",s=>{var i;const r=s.ctrlKey||s.metaKey||s.shiftKey,o=parseInt((i=s.target.closest(".nine-tab-item"))==null?void 0:i.dataset.index,10);t(this,It).call(this,o,r)}),t(this,It).call(this,0,!1)},"#init"));d(this,It,h((e,s=!1)=>{const r=h(()=>{const f=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(u=>u.style.setProperty("display","none"));const b=f.filter(u=>u.classList.contains("active"));b.length<2||b.forEach(u=>{const m=parseInt(u.getAttribute("data-index"),10),w=this.querySelector(`nine-splitter[data-split-index="${m}"]`),T=f[m+1];w&&T&&T.classList.contains("active")&&w.style.setProperty("display","flex")})},"updateSplitters"),o=this.querySelector(".nine-tab-bar"),i=this.querySelector("nine-table-sheets-body"),a=o.querySelectorAll(".nine-tab-item"),c=i.querySelectorAll("nine-table-sheet");if(!a[e])return;if(!s)a.forEach((f,g)=>{f.classList.toggle("active",g===e)}),c.forEach((f,g)=>{const b=g===e;f.classList.toggle("active",b),f.style.flex=b?"1 1 100%":""});else{const f=a[e],g=o.querySelectorAll(".nine-tab-item.active");if(f.classList.contains("active")&&g.length<=1)return;f.classList.toggle("active");const b=i.querySelector(`nine-table-sheet[data-index="${e}"]`);b&&(b.classList.toggle("active"),b.classList.contains("active")||(b.style.flex=""))}const l=i.querySelectorAll("nine-table-sheet.active");l==null||l.forEach(f=>{f.style.flex=l.length>1?"1 1 0%":"1 1 100%"}),r()},"#switchSheet"))}connectedCallback(){t(this,se).call(this)}};se=new WeakMap,It=new WeakMap,h(_e,"NineTableSheets");let pe=_e;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",pe);const Ne=class Ne{constructor(n){d(this,I);d(this,ne,h(()=>{t(this,re).call(this),new ResizeObserver(n=>{for(let e of n)t(this,I).getAttribute("auto-height")==="true"&&t(this,$t).call(this)}).observe(t(this,I))},"#init"));d(this,$t,h(()=>{var c,l;const n=Array.from(t(this,I).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(n.length===0)return;const e=parseInt(t(this,I).getAttribute("max-display-row"),10)||10,s=Math.max(...n.map(f=>f.getRowHeight())),r=(c=t(this,I).shadowRoot.querySelector("nine-table-header"))==null?void 0:c.getBoundingClientRect().height,o=(l=t(this,I).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:l.getBoundingClientRect().height,i=Pt.SCROLLBAR_SIZE,a=e*s+r+o+i;t(this,I).style.height=`${a}px`},"#applyAutoHeight"));d(this,re,h(()=>{const e=Array.from(t(this,I).children).filter(c=>c.tagName==="TABLE"),s=t(this,I).getAttribute("auto-height")==="true",r=e.length,o=e.map((c,l)=>{const g=`<nine-table-sheet class="${l===0?"active":""}" data-index="${l}"></nine-table-sheet>`,b=l<r-1?`<nine-splitter class="h" data-split-index="${l}"></nine-splitter>`:"";return g+b}).join(""),i=e.map((c,l)=>`<div class="nine-tab-item ${l===0?"active":""}" data-index="${l}">Sheet ${l+1}</div>`).join("");t(this,I).shadowRoot.innerHTML=`
323
+ `},"#render"));p(this,at,new ue(this)),p(this,Gt,this.getRootNode().host)}connectedCallback(){t(this,te).call(this)}get selection(){return t(this,Mt)}disconnectedCallback(){this.innerHTML="",y.log("NineTableSheet destroyed.")}};Gt=new WeakMap,it=new WeakMap,at=new WeakMap,Mt=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,bt=new WeakMap,te=new WeakMap,ee=new WeakMap,h(Ht,"NineTableSheet"),C(Ht,"SCROLLBAR_SIZE",16);let Bt=Ht;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",Bt);const _e=class _e extends HTMLElement{constructor(){super();d(this,se,h(()=>{var e;(e=this.querySelector(".nine-tab-bar"))==null||e.addEventListener("click",s=>{var i;const r=s.ctrlKey||s.metaKey||s.shiftKey,o=parseInt((i=s.target.closest(".nine-tab-item"))==null?void 0:i.dataset.index,10);t(this,It).call(this,o,r)}),t(this,It).call(this,0,!1)},"#init"));d(this,It,h((e,s=!1)=>{const r=h(()=>{const f=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(b=>b.style.setProperty("display","none"));const g=f.filter(b=>b.classList.contains("active"));g.length<2||g.forEach(b=>{const v=parseInt(b.getAttribute("data-index"),10),w=this.querySelector(`nine-splitter[data-split-index="${v}"]`),A=f[v+1];w&&A&&A.classList.contains("active")&&w.style.setProperty("display","flex")})},"updateSplitters"),o=this.querySelector(".nine-tab-bar"),i=this.querySelector("nine-table-sheets-body"),a=o.querySelectorAll(".nine-tab-item"),c=i.querySelectorAll("nine-table-sheet");if(!a[e])return;if(!s)a.forEach((f,u)=>{f.classList.toggle("active",u===e)}),c.forEach((f,u)=>{const g=u===e;f.classList.toggle("active",g),f.style.flex=g?"1 1 100%":""});else{const f=a[e],u=o.querySelectorAll(".nine-tab-item.active");if(f.classList.contains("active")&&u.length<=1)return;f.classList.toggle("active");const g=i.querySelector(`nine-table-sheet[data-index="${e}"]`);g&&(g.classList.toggle("active"),g.classList.contains("active")||(g.style.flex=""))}const l=i.querySelectorAll("nine-table-sheet.active");l==null||l.forEach(f=>{f.style.flex=l.length>1?"1 1 0%":"1 1 100%"}),r()},"#switchSheet"))}connectedCallback(){t(this,se).call(this)}};se=new WeakMap,It=new WeakMap,h(_e,"NineTableSheets");let pe=_e;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",pe);const Ne=class Ne{constructor(n){d(this,I);d(this,ne,h(()=>{t(this,re).call(this),new ResizeObserver(n=>{for(let e of n)t(this,I).getAttribute("auto-height")==="true"&&t(this,$t).call(this)}).observe(t(this,I))},"#init"));d(this,$t,h(()=>{var c,l;const n=Array.from(t(this,I).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(n.length===0)return;const e=parseInt(t(this,I).getAttribute("max-display-row"),10)||10,s=Math.max(...n.map(f=>f.getRowHeight())),r=(c=t(this,I).shadowRoot.querySelector("nine-table-header"))==null?void 0:c.getBoundingClientRect().height,o=(l=t(this,I).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:l.getBoundingClientRect().height,i=Bt.SCROLLBAR_SIZE,a=e*s+r+o+i;t(this,I).style.height=`${a}px`},"#applyAutoHeight"));d(this,re,h(()=>{const e=Array.from(t(this,I).children).filter(c=>c.tagName==="TABLE"),s=t(this,I).getAttribute("auto-height")==="true",r=e.length,o=e.map((c,l)=>{const u=`<nine-table-sheet class="${l===0?"active":""}" data-index="${l}"></nine-table-sheet>`,g=l<r-1?`<nine-splitter class="h" data-split-index="${l}"></nine-splitter>`:"";return u+g}).join(""),i=e.map((c,l)=>`<div class="nine-tab-item ${l===0?"active":""}" data-index="${l}">Sheet ${l+1}</div>`).join("");t(this,I).shadowRoot.innerHTML=`
324
324
  <style>
325
325
  :host {
326
326
  display: flex;
@@ -440,10 +440,10 @@
440
440
  <nine-table-analysis></nine-table-analysis>
441
441
  </nine-table-body>
442
442
  <nine-table-footer></nine-table-footer>
443
- `,t(this,I).shadowRoot.querySelector("nine-table-sheets").classList.add("nodata");const a=t(this,I).shadowRoot.querySelectorAll("nine-table-sheet");a==null||a.forEach((c,l)=>{e[l]&&setTimeout(()=>{c.generate(e[l]),s&&t(this,$t).call(this)})})},"#render"));p(this,I,n),t(this,ne).call(this)}};I=new WeakMap,ne=new WeakMap,$t=new WeakMap,re=new WeakMap,h(Ne,"LayoutManager");let ye=Ne;const ze=class ze{constructor(n){d(this,_t);d(this,bt,-1);q(this,"count",h(()=>t(this,_t).rawRecords.length,"count"));p(this,_t,n)}get at(){return t(this,bt)}set at(n){p(this,bt,parseInt(n,10)),body&&!body.querySelector(`tbody.bindable tr[data-row="${t(this,bt)}"]`)&&setTimeout(()=>{})}};_t=new WeakMap,bt=new WeakMap,h(ze,"ngRow");let me=ze;const B=class B{constructor(n,e){d(this,z);d(this,L);d(this,W,[]);d(this,pt,[]);d(this,ie,0);d(this,X,[]);d(this,oe,h(()=>{p(this,X,[]);const n=t(this,z).template||[];Array.from(n).forEach(e=>{var s;t(this,X).push(((s=e.getBoundingClientRect)==null?void 0:s.call(e).height)||24)}),(t(this,L).rawRecords||[]).forEach(e=>{e.__ng||(e.__ng=t(this,Nt).call(this)),e.__ng.height=t(this,X).slice()})},"#initialize"));d(this,at,h(()=>{const n=t(this,z).shadowRoot.querySelector("nine-table-sheets");n==null||n.classList.toggle("nodata",this.length===0),t(this,z).shadowRoot.querySelectorAll("nine-table-sheet").forEach(e=>{e.invalidate()})},"#invalidate"));q(this,"get",h((n,e)=>{var o;const s=this.getValidData();if(!s||s.length<=0)return;if(n==null)return t(this,yt).call(this,s);if(n<0||n>=s.length)return null;const r=typeof((o=t(this,z).fields)==null?void 0:o.get)=="function"?t(this,z).fields.get():[];if(e!=null){const i=r.indexOf(e);return i>=0?s[n].v[i]:null}return t(this,yt).call(this,s[n])},"get"));q(this,"set",h(n=>{this.clear(),this.add(n,!1),t(this,at).call(this)},"set"));d(this,Nt,h(()=>({rowState:B.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:t(this,X).slice(),o:{},c:{},_:[0,0,0,0,B.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,t(this,X).slice(),-1,{},{}]}),"#getDefaultMeta"));q(this,"reset",h(()=>{p(this,W,[]),p(this,pt,[]),t(this,at).call(this)},"reset"));q(this,"clear",h(()=>{var n;t(this,L).rawRecords=[],p(this,W,[]),p(this,pt,[]),(n=t(this,L).viewRecords)!=null&&n.reset&&t(this,L).viewRecords.reset()},"clear"));d(this,ae,h(n=>{var r;Array.isArray(n)||(n=[n]);const e=typeof((r=t(this,z).fields)==null?void 0:r.get)=="function"?t(this,z).fields.get():Object.keys(n[0]||{}),s=[];return n.forEach(o=>{const i={v:[]};e.forEach(a=>{i.v.push(o[a]!==void 0&&o[a]!==null?o[a]:"")}),s.push(i)}),s},"#json2Array"));d(this,le,h(n=>(Array.isArray(n)||(n=[n]),n.forEach(e=>{e.__ng=t(this,Nt).call(this),e.__ng.rowid=this.nextId,e.__ng.rowState=B.ROW_STATE.INSERT,e.__ng._[0]=e.__ng.rowid}),n),"#defaultInsert"));q(this,"add",h((n,e=!0)=>{n===void 0&&(n={});const s=t(this,ae).call(this,n);t(this,L).rawRecords=t(this,L).rawRecords.concat(t(this,le).call(this,s)),this.resetRecords();const r=this.count()-1;return e||s.forEach((o,i)=>{const a=t(this,L).rawRecords[r-i];a&&(a.__ng.rowState=B.ROW_STATE.EMPTY)}),t(this,at).call(this),r},"add"));q(this,"delete",h(n=>{let e=[];Array.isArray(n)?e=n:typeof n>"u"?e=[t(this,L).host.row.at]:e=[parseInt(n,10)],e.sort((s,r)=>r-s).forEach(s=>{if(t(this,W)[s]){const r=t(this,W)[s].__ng.rowid;t(this,W)[s].__ng.rowState===B.ROW_STATE.INSERT?t(this,L).rawRecords=t(this,L).rawRecords.filter(o=>o.__ng.rowid!==r):t(this,L).rawRecords.forEach(o=>{o.__ng.rowid===r&&(o.__ng.deleted=!0,o.__ng.rowState=B.ROW_STATE.DELETE)})}}),this.resetRecords(),t(this,at).call(this)},"delete"));q(this,"setValue",h((n,e,s)=>{var c;n=parseInt(n,10);const o=(typeof((c=t(this,z).fields)==null?void 0:c.get)=="function"?t(this,z).fields.get():[]).indexOf(e);if(o<0)return;const i=this.getValidData()[n];if(!i)return;const a=i.v[o];a!==s&&i.__ng.rowState!==B.ROW_STATE.INSERT&&(i.__ng.o.hasOwnProperty(e)||(i.__ng.o[e]=a),i.__ng.rowState=B.ROW_STATE.UPDATE),i.v[o]=s},"setValue"));q(this,"resetRecords",h(()=>{p(this,pt,t(this,L).rawRecords.filter(n=>!n.__ng.deleted)),p(this,W,t(this,L).rawRecords.filter(n=>!n.__ng.deleted&&!n.__ng.filtered)),t(this,L).rawRecords.forEach((n,e)=>{n.__ng.rowidx=e}),t(this,W).forEach((n,e)=>{n.__ng.i=e})},"resetRecords"));q(this,"getValidData",h(()=>(t(this,W).length===0&&t(this,L).rawRecords.length>0&&this.resetRecords(),t(this,W)),"getValidData"));d(this,yt,h(n=>{var i;if(!n)return n;const e=!Array.isArray(n),s=e?[n]:n,r=typeof((i=t(this,z).fields)==null?void 0:i.get)=="function"?t(this,z).fields.get():[],o=s.filter(a=>!a.__ng.deleted).map(a=>{const c={};return r.forEach((l,f)=>{c[l]=a.v?a.v[f]:a[l]}),c.__ng=a.__ng,c});return e?o[0]:o},"#conv"));q(this,"count",h(()=>this.getValidData().length,"count"));p(this,z,n),p(this,L,e),t(this,oe).call(this)}get source(){return t(this,yt).call(this,t(this,L).rawRecords)}set source(n){this.clear(),this.add(n,!1)}get nextId(){return++ns(this,ie)._}get count(){return t(this,W).length}get length(){return t(this,W).length}getRowCount(){return this.length}};z=new WeakMap,L=new WeakMap,W=new WeakMap,pt=new WeakMap,ie=new WeakMap,X=new WeakMap,oe=new WeakMap,at=new WeakMap,Nt=new WeakMap,ae=new WeakMap,le=new WeakMap,yt=new WeakMap,h(B,"ngData"),q(B,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let xe=B;const We=class We{constructor(n){d(this,lt);p(this,lt,n),this.row=new me(this),this.data=new xe(t(this,lt),this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{var e;(e=t(this,lt).view)!=null&&e.redraw&&t(this,lt).view.redraw()},this.setDataSource=e=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(e||[])},this.getRowState=e=>{var r,o;const s=parseInt(e,10);if(!(s>=this.data.count()))return(o=(r=this.data.getValidData()[s])==null?void 0:r.__ng)==null?void 0:o.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=e=>{this.row.at=e},this.scrollTo_V1=e=>(e<0&&(e=0),e>=this.rawRecords.length&&(e=this.rawRecords.length-1),this.viewRecords.rawIndex=e,this.viewRecords.reset&&this.viewRecords.reset(),!(e<=0||e>=this.rawRecords.length-1)),this.getColumn=(e,s)=>this.data.get(e,s),this.setColumn=(e,s,r)=>{e=parseInt(e,10),this.data.setValue(e,s,r)},this.setDataSource([])}};lt=new WeakMap,h(We,"ngDataManager");let ve=We;const Oe=class Oe{constructor(n){d(this,mt);d(this,M,[]);q(this,"add",h((n,e="string")=>{n.forEach(s=>{t(this,M).some(r=>r.name===s)||t(this,M).push({name:s,type:e})}),t(this,zt).call(this)},"add"));d(this,zt,h(()=>{const n=new Map;t(this,M).forEach(e=>{n.set(e.name,e.type)}),p(this,M,Array.from(n,([e,s])=>({name:e,type:s}))),p(this,M,t(this,M).filter(e=>e.name!==""&&e.name!=="__ng")),t(this,M).sort((e,s)=>e.name.length<s.name.length?1:-1)},"#adjust"));d(this,ce,h(()=>{p(this,M,[]),v.log(t(this,mt).querySelectorAll("table"));const n=Array.from(t(this,mt).querySelectorAll("table"));if(!(!n||n.length===0)){for(const e of n)v.log(e),$("[data-bind]",e).each((s,r)=>{const o=r.dataset.bind,i=r.getAttribute("data-type")||"string";o&&t(this,M).push({name:o,type:i})}),["data-expr","background-color","color","tooltip","visible","readonly","enable-button","enable-check","class-expr","icon-color","icon-src"].forEach(s=>{$(`[${s}]`,e).each((r,o)=>{var i=o.getAttribute(s);if(i.indexOf("data.")<0){const a=i.search(/[(]/g);if(a>0)try{i=String(window[i.substring(0,a).trim()])}catch{i=""}}i.split("data.").forEach(a=>{if(a.trim()!=""){const c=a.search(/[^_A-Za-z0-9]/g);let l="";c>=0?l=a.substring(0,c):i.startsWith("data.")&&(l=a.replace("data.","")),l&&t(this,M).push({name:l,type:"string"})}})})});t(this,zt).call(this)}},"#init"));p(this,mt,n),t(this,ce).call(this)}get(){return t(this,M).map(n=>n.name)}getFields(){return t(this,M)}getType(n){const e=t(this,M).find(s=>s.name===n);return e?e.type:"string"}indexOf(n){return t(this,M).findIndex(e=>e.name===n)}includes(n){return t(this,M).some(e=>e.name===n)}};mt=new WeakMap,M=new WeakMap,zt=new WeakMap,ce=new WeakMap,h(Oe,"ngFields");let we=Oe;const Be=class Be extends HTMLElement{constructor(){super();d(this,ct);d(this,he);d(this,de,h(()=>{this.fields=new we(this),p(this,he,new ye(this)),v.log("NineTable connected."),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{target:this}}))},"#init"));this.attachShadow({mode:"open"}),p(this,ct,new ve(this))}connectedCallback(){t(this,de).call(this)}disconnectedCallback(){v.log("NineTable disconnected.")}get data(){return t(this,ct).data}get row(){return t(this,ct).row}get dataManager(){return t(this,ct)}};ct=new WeakMap,he=new WeakMap,de=new WeakMap,h(Be,"NineTable");let Se=Be;customElements.get("nine-table")||customElements.define("nine-table",Se);const Wt=class Wt extends HTMLElement{constructor(){super()}applyBaseStyle(){this.constructor.name}connectedCallback(){}};h(Wt,"BasicCellElement"),q(Wt,"_styleCache",new Map),q(Wt,"_customStyleCache",new Map);let Ee=Wt;const Ye=class Ye extends Ee{constructor(){super();d(this,H);d(this,Ot);d(this,y);d(this,Pe);d(this,De);d(this,je);d(this,Fe);q(this,"getDisplayText",h(e=>{if(t(this,y))if(t(this,y).closest("tbody")){const s=t(this,y).closest("tr").data,r=parseInt(t(this,y).dataset.row);if(!s)return"";if(ninegrid.isNull(t(this,y).dataset.expr)){if(!ninegrid.isNull(t(this,y).dataset.bind))return s[t(this,y).dataset.bind]||ninegrid.nvl(e,"")}else try{return this.getExprValue(t(this,y).dataset.expr,s,r,t(this,y))}catch{console.error(t(this,y).dataset.expr,s,t(this,y).dataset.row)}return ninegrid.nvl(e,"")}else try{return t(this,H).exprFunction(t(this,y).dataset.expr).call(this,null,-1,t(this,H).data)}catch{}},"getDisplayText"));d(this,Ve,h(()=>{if(!(!t(this,H)||!t(this,H).template||!t(this,y).closest("tbody.bindable"))){var e=ninegrid.j.querySelectorAll(t(this,y)).attr("suppress");if(e&&(e=parseInt(e)),e&&!isNaN(e)){var s=t(this,y).closest("tr"),r=[];$("th,td",s).each((x,_)=>{var k=ninegrid.j.querySelectorAll(_).attr("suppress");k&&_.dataset.row&&(k=parseInt(k),!isNaN(k)&&k<=e&&r.push(k))}),r.sort();var o=!1;if(parseInt(s.sectionRowIndex/t(this,H).template.length)>0)for(var i of r){if(i>e)break;var a=parseInt(t(this,y).dataset.row),c=a-1,l=t(this,y).closest("tr").data,f=t(this,H).data.get(c);t(this,y).dataset.matrixRow;var g=t(this,H).body.querySelector(`tbody.bindable [suppress="${i}"][data-matrix-row="${t(this,y).dataset.matrixRow}"]`),b=g.dataset.expr?this.getExprValue(g.dataset.expr,l,a):l[g.dataset.bind],u=g.dataset.expr?this.getExprValue(g.dataset.expr,f,c):f[g.dataset.bind];if(b!=u){o=!0;break}}else o=!0;o?ninegrid.j.querySelectorAll(t(this,y)).removeClass("suppress"):ninegrid.j.querySelectorAll(t(this,y)).addClass("suppress"),ninegrid.j.querySelectorAll(t(this,y)).hasClass("hidden")||(o?ninegrid.j.querySelectorAll(t(this,y)).removeClass("hidden"):ninegrid.j.querySelectorAll(t(this,y)).addClass("hidden"));var m=parseInt(t(this,y).dataset.matrixRow),w=m-1,T=t(this,H).body.querySelector(`tbody.bindable [data-col="${t(this,y).dataset.col}"][data-matrix-row="${w}"]`);$(T).hasClass("suppress")&&!ninegrid.j.querySelectorAll(t(this,y)).hasClass("suppress")?ninegrid.j.querySelectorAll(T).removeClass("last-none-suppress").addClass("last-suppress"):!$(T).hasClass("suppress")&&ninegrid.j.querySelectorAll(t(this,y)).hasClass("suppress")?ninegrid.j.querySelectorAll(T).removeClass("last-suppress").addClass("last-none-suppress"):ninegrid.j.querySelectorAll(T).removeClass("last-none-suppress").removeClass("last-suppress")}}},"#resetSuppress"));q(this,"getExprValue",h((e,s,r,o)=>{if(typeof e<"u")try{r=parseInt(r);const i=e.replace("()","");return t(this,H)[i]?t(this,H)[i].call(this,s,r,t(this,y)):t(this,H).exprFunction(e).call(this,s,r,t(this,H).data)}catch{return["NG-COMBO"].includes(this.tagName)?"":e}else return e},"getExprValue"))}connectedCallback(){super.connectedCallback(),p(this,H,this.getRootNode().host),p(this,y,this.closest("th,td")),p(this,Ot,t(this,y).closest("tr"))}get value(){var e=!t(this,H)||!t(this,H).dataManager||!t(this,y)||!t(this,y).dataset||!t(this,y).dataset.row||!t(this,y).dataset.bind?"":t(this,y).closest("tr").data[t(this,y).dataset.bind];return e??""}set value(e){var s=parseInt(t(this,y).dataset.row);const r=this.getAttribute("update-row-state")!="false";s<0?t(this,H).data.setValueNF(parseInt(t(this,y).dataset.index),t(this,y).dataset.bind,e,r):t(this,H).data.setValue(s,t(this,y).dataset.bind,e,r)}get row(){return parseInt(t(this,y).dataset.row)}get data(){return t(this,y).closest("tr").data}refresh(){const e=t(this,y).dataset.bind;return parseInt(t(this,y).dataset.row),t(this,Ot).data[e]}};H=new WeakMap,Ot=new WeakMap,y=new WeakMap,Pe=new WeakMap,De=new WeakMap,je=new WeakMap,Fe=new WeakMap,Ve=new WeakMap,h(Ye,"CellElement");let Ae=Ye;const Ue=class Ue extends Ae{constructor(){super()}connectedCallback(){super.connectedCallback()}refresh(){return super.refresh()}};h(Ue,"EditableCellElement");let Re=Ue;const Ke=class Ke extends Re{constructor(){super();d(this,Bt);d(this,ht);d(this,xt);d(this,vt);d(this,fe);d(this,K);q(this,"refresh",h(()=>{const e=super.refresh();t(this,Bt).value=e},"refresh"));d(this,Xe,h(e=>{if(!["Escape","Enter","Tab","Home","End","ArrowLeft","ArrowRight","PageUp","PageDown","Backspace","Delete"].includes(e.code)){if(t(this,ht)=="number"){let o=[];if(t(this,K)&&Number(t(this,K))>0&&o.push("."),t(this,vt)&&Number(t(this,vt))>=0&&o.push("-"),!(e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=105)&&!o.includes(e.key)&&e.preventDefault(),t(this,K)&&(e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=105)&&e.target.selectionStart==e.target.selectionEnd){var s=e.target.value,r=s.indexOf(".");if(r>=0){var s=s.substr(r+1,s.length);s.length>=Number(t(this,K))&&e.preventDefault()}}}t(this,xt)&&ninegrid.getByteLength(e.target.value)>=Number(t(this,xt))&&e.target.selectionStart==e.target.selectionEnd&&e.preventDefault()}},"#onKeyDown"));if(this.applyBaseStyle(),p(this,ht,this.getAttribute("type")||"text"),p(this,xt,this.getAttribute("maxbyte")),p(this,vt,this.getAttribute("min")),p(this,fe,this.getAttribute("max")),p(this,K,this.getAttribute("scale")),!["text","number"].includes(t(this,ht)))throw`invalid type : ${t(this,ht)}`}connectedCallback(){for(var e=[],s=0;s<this.attributes.length;s++)["type","maxlength","maxbyte","min","max","step","scale","text-align"].includes(this.attributes[s].name)&&e.push(`${this.attributes[s].name}="${this.attributes[s].value}"`);this.innerHTML=`
443
+ `,t(this,I).shadowRoot.querySelector("nine-table-sheets").classList.add("nodata");const a=t(this,I).shadowRoot.querySelectorAll("nine-table-sheet");a==null||a.forEach((c,l)=>{e[l]&&setTimeout(()=>{c.generate(e[l]),s&&t(this,$t).call(this)})})},"#render"));p(this,I,n),t(this,ne).call(this)}};I=new WeakMap,ne=new WeakMap,$t=new WeakMap,re=new WeakMap,h(Ne,"LayoutManager");let ye=Ne;const ze=class ze{constructor(n){d(this,_t);d(this,pt,-1);C(this,"count",h(()=>t(this,_t).rawRecords.length,"count"));p(this,_t,n)}get at(){return t(this,pt)}set at(n){p(this,pt,parseInt(n,10)),body&&!body.querySelector(`tbody.bindable tr[data-row="${t(this,pt)}"]`)&&setTimeout(()=>{})}};_t=new WeakMap,pt=new WeakMap,h(ze,"ngRow");let me=ze;const O=class O{constructor(n,e){d(this,N);d(this,L);d(this,W,[]);d(this,yt,[]);d(this,oe,0);d(this,X,[]);d(this,ie,h(()=>{p(this,X,[]);const n=t(this,N).template||[];Array.from(n).forEach(e=>{var s;t(this,X).push(((s=e.getBoundingClientRect)==null?void 0:s.call(e).height)||24)}),(t(this,L).rawRecords||[]).forEach(e=>{e.__ng||(e.__ng=t(this,Nt).call(this)),e.__ng.height=t(this,X).slice()})},"#initialize"));d(this,lt,h(()=>{const n=t(this,N).shadowRoot.querySelector("nine-table-sheets");n==null||n.classList.toggle("nodata",this.length===0),t(this,N).shadowRoot.querySelectorAll("nine-table-sheet").forEach(e=>{e.invalidate()})},"#invalidate"));C(this,"get",h((n,e)=>{var o;const s=this.getValidData();if(!s||s.length<=0)return;if(n==null)return t(this,mt).call(this,s);if(n<0||n>=s.length)return null;const r=typeof((o=t(this,N).fields)==null?void 0:o.get)=="function"?t(this,N).fields.get():[];if(e!=null){const i=r.indexOf(e);return i>=0?s[n].v[i]:null}return t(this,mt).call(this,s[n])},"get"));C(this,"set",h(n=>{this.clear(),this.add(n,!1),t(this,lt).call(this)},"set"));d(this,Nt,h(()=>({rowState:O.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:t(this,X).slice(),o:{},c:{},_:[0,0,0,0,O.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,t(this,X).slice(),-1,{},{}]}),"#getDefaultMeta"));C(this,"reset",h(()=>{p(this,W,[]),p(this,yt,[]),t(this,lt).call(this)},"reset"));C(this,"clear",h(()=>{var n;t(this,L).rawRecords=[],p(this,W,[]),p(this,yt,[]),(n=t(this,L).viewRecords)!=null&&n.reset&&t(this,L).viewRecords.reset()},"clear"));d(this,ae,h(n=>{var r;Array.isArray(n)||(n=[n]);const e=typeof((r=t(this,N).fields)==null?void 0:r.get)=="function"?t(this,N).fields.get():Object.keys(n[0]||{}),s=[];return n.forEach(o=>{const i={v:[]};e.forEach(a=>{i.v.push(o[a]!==void 0&&o[a]!==null?o[a]:"")}),s.push(i)}),s},"#json2Array"));d(this,le,h(n=>(Array.isArray(n)||(n=[n]),n.forEach(e=>{e.__ng=t(this,Nt).call(this),e.__ng.rowid=this.nextId,e.__ng.rowState=O.ROW_STATE.INSERT,e.__ng._[0]=e.__ng.rowid}),n),"#defaultInsert"));C(this,"add",h((n,e=!0)=>{n===void 0&&(n={});const s=t(this,ae).call(this,n);t(this,L).rawRecords=t(this,L).rawRecords.concat(t(this,le).call(this,s)),this.resetRecords();const r=this.count()-1;return e||s.forEach((o,i)=>{const a=t(this,L).rawRecords[r-i];a&&(a.__ng.rowState=O.ROW_STATE.EMPTY)}),t(this,lt).call(this),r},"add"));C(this,"delete",h(n=>{let e=[];Array.isArray(n)?e=n:typeof n>"u"?e=[t(this,L).host.row.at]:e=[parseInt(n,10)],e.sort((s,r)=>r-s).forEach(s=>{if(t(this,W)[s]){const r=t(this,W)[s].__ng.rowid;t(this,W)[s].__ng.rowState===O.ROW_STATE.INSERT?t(this,L).rawRecords=t(this,L).rawRecords.filter(o=>o.__ng.rowid!==r):t(this,L).rawRecords.forEach(o=>{o.__ng.rowid===r&&(o.__ng.deleted=!0,o.__ng.rowState=O.ROW_STATE.DELETE)})}}),this.resetRecords(),t(this,lt).call(this)},"delete"));C(this,"setValue",h((n,e,s)=>{var c;n=parseInt(n,10);const o=(typeof((c=t(this,N).fields)==null?void 0:c.get)=="function"?t(this,N).fields.get():[]).indexOf(e);if(o<0)return;const i=this.getValidData()[n];if(!i)return;const a=i.v[o];a!==s&&i.__ng.rowState!==O.ROW_STATE.INSERT&&(i.__ng.o.hasOwnProperty(e)||(i.__ng.o[e]=a),i.__ng.rowState=O.ROW_STATE.UPDATE),i.v[o]=s},"setValue"));C(this,"resetRecords",h(()=>{p(this,yt,t(this,L).rawRecords.filter(n=>!n.__ng.deleted)),p(this,W,t(this,L).rawRecords.filter(n=>!n.__ng.deleted&&!n.__ng.filtered)),t(this,L).rawRecords.forEach((n,e)=>{n.__ng.rowidx=e}),t(this,W).forEach((n,e)=>{n.__ng.i=e})},"resetRecords"));C(this,"getValidData",h(()=>(t(this,W).length===0&&t(this,L).rawRecords.length>0&&this.resetRecords(),t(this,W)),"getValidData"));d(this,mt,h(n=>{var i;if(!n)return n;const e=!Array.isArray(n),s=e?[n]:n,r=typeof((i=t(this,N).fields)==null?void 0:i.get)=="function"?t(this,N).fields.get():[],o=s.filter(a=>!a.__ng.deleted).map(a=>{const c={};return r.forEach((l,f)=>{c[l]=a.v?a.v[f]:a[l]}),c.__ng=a.__ng,c});return e?o[0]:o},"#conv"));C(this,"count",h(()=>this.getValidData().length,"count"));p(this,N,n),p(this,L,e),t(this,ie).call(this)}get source(){return t(this,mt).call(this,t(this,L).rawRecords)}set source(n){this.clear(),this.add(n,!1)}get nextId(){return++rs(this,oe)._}get count(){return t(this,W).length}get length(){return t(this,W).length}getRowCount(){return this.length}};N=new WeakMap,L=new WeakMap,W=new WeakMap,yt=new WeakMap,oe=new WeakMap,X=new WeakMap,ie=new WeakMap,lt=new WeakMap,Nt=new WeakMap,ae=new WeakMap,le=new WeakMap,mt=new WeakMap,h(O,"ngData"),C(O,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let xe=O;const De=class De{constructor(n){d(this,ct);p(this,ct,n),this.row=new me(this),this.data=new xe(t(this,ct),this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{var e;(e=t(this,ct).view)!=null&&e.redraw&&t(this,ct).view.redraw()},this.setDataSource=e=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(e||[])},this.getRowState=e=>{var r,o;const s=parseInt(e,10);if(!(s>=this.data.count()))return(o=(r=this.data.getValidData()[s])==null?void 0:r.__ng)==null?void 0:o.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=e=>{this.row.at=e},this.scrollTo_V1=e=>(e<0&&(e=0),e>=this.rawRecords.length&&(e=this.rawRecords.length-1),this.viewRecords.rawIndex=e,this.viewRecords.reset&&this.viewRecords.reset(),!(e<=0||e>=this.rawRecords.length-1)),this.getColumn=(e,s)=>this.data.get(e,s),this.setColumn=(e,s,r)=>{e=parseInt(e,10),this.data.setValue(e,s,r)},this.setDataSource([])}};ct=new WeakMap,h(De,"ngDataManager");let ve=De;const We=class We{constructor(n){d(this,xt);d(this,H,[]);C(this,"add",h((n,e="string")=>{n.forEach(s=>{t(this,H).some(r=>r.name===s)||t(this,H).push({name:s,type:e})}),t(this,zt).call(this)},"add"));d(this,zt,h(()=>{const n=new Map;t(this,H).forEach(e=>{n.set(e.name,e.type)}),p(this,H,Array.from(n,([e,s])=>({name:e,type:s}))),p(this,H,t(this,H).filter(e=>e.name!==""&&e.name!=="__ng")),t(this,H).sort((e,s)=>e.name.length<s.name.length?1:-1)},"#adjust"));d(this,ce,h(()=>{p(this,H,[]),y.log(t(this,xt).querySelectorAll("table"));const n=Array.from(t(this,xt).querySelectorAll("table"));if(!(!n||n.length===0)){for(const e of n)y.log(e),$("[data-bind]",e).each((s,r)=>{const o=r.dataset.bind,i=r.getAttribute("data-type")||"string";o&&t(this,H).push({name:o,type:i})}),["data-expr","background-color","color","tooltip","visible","readonly","enable-button","enable-check","class-expr","icon-color","icon-src"].forEach(s=>{$(`[${s}]`,e).each((r,o)=>{var i=o.getAttribute(s);if(i.indexOf("data.")<0){const a=i.search(/[(]/g);if(a>0)try{i=String(window[i.substring(0,a).trim()])}catch{i=""}}i.split("data.").forEach(a=>{if(a.trim()!=""){const c=a.search(/[^_A-Za-z0-9]/g);let l="";c>=0?l=a.substring(0,c):i.startsWith("data.")&&(l=a.replace("data.","")),l&&t(this,H).push({name:l,type:"string"})}})})});t(this,zt).call(this)}},"#init"));p(this,xt,n),t(this,ce).call(this)}get(){return t(this,H).map(n=>n.name)}getFields(){return t(this,H)}getType(n){const e=t(this,H).find(s=>s.name===n);return e?e.type:"string"}indexOf(n){return t(this,H).findIndex(e=>e.name===n)}includes(n){return t(this,H).some(e=>e.name===n)}};xt=new WeakMap,H=new WeakMap,zt=new WeakMap,ce=new WeakMap,h(We,"ngFields");let we=We;const Oe=class Oe extends HTMLElement{constructor(){super();d(this,ht);d(this,he);d(this,de,h(()=>{this.fields=new we(this),p(this,he,new ye(this)),y.log("NineTable connected."),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{target:this}}))},"#init"));this.attachShadow({mode:"open"}),p(this,ht,new ve(this))}connectedCallback(){t(this,de).call(this)}disconnectedCallback(){y.log("NineTable disconnected.")}get data(){return t(this,ht).data}get row(){return t(this,ht).row}get dataManager(){return t(this,ht)}};ht=new WeakMap,he=new WeakMap,de=new WeakMap,h(Oe,"NineTable");let Se=Oe;customElements.get("nine-table")||customElements.define("nine-table",Se);const Dt=class Dt extends HTMLElement{constructor(){super()}applyBaseStyle(){this.constructor.name}connectedCallback(){}};h(Dt,"BasicCellElement"),C(Dt,"_styleCache",new Map),C(Dt,"_customStyleCache",new Map);let Ee=Dt;const Ye=class Ye extends Ee{constructor(){super();d(this,M);d(this,Wt);d(this,x);d(this,Be);d(this,Pe);d(this,je);d(this,Fe);C(this,"getDisplayText",h(e=>{if(t(this,x))if(t(this,x).closest("tbody")){const s=t(this,x).closest("tr").data,r=parseInt(t(this,x).dataset.row);if(!s)return"";if(ninegrid.isNull(t(this,x).dataset.expr)){if(!ninegrid.isNull(t(this,x).dataset.bind))return s[t(this,x).dataset.bind]||ninegrid.nvl(e,"")}else try{return this.getExprValue(t(this,x).dataset.expr,s,r,t(this,x))}catch{console.error(t(this,x).dataset.expr,s,t(this,x).dataset.row)}return ninegrid.nvl(e,"")}else try{return t(this,M).exprFunction(t(this,x).dataset.expr).call(this,null,-1,t(this,M).data)}catch{}},"getDisplayText"));d(this,Ve,h(()=>{if(!(!t(this,M)||!t(this,M).template||!t(this,x).closest("tbody.bindable"))){var e=ninegrid.j.querySelectorAll(t(this,x)).attr("suppress");if(e&&(e=parseInt(e)),e&&!isNaN(e)){var s=t(this,x).closest("tr"),r=[];$("th,td",s).each((m,z)=>{var T=ninegrid.j.querySelectorAll(z).attr("suppress");T&&z.dataset.row&&(T=parseInt(T),!isNaN(T)&&T<=e&&r.push(T))}),r.sort();var o=!1;if(parseInt(s.sectionRowIndex/t(this,M).template.length)>0)for(var i of r){if(i>e)break;var a=parseInt(t(this,x).dataset.row),c=a-1,l=t(this,x).closest("tr").data,f=t(this,M).data.get(c);t(this,x).dataset.matrixRow;var u=t(this,M).body.querySelector(`tbody.bindable [suppress="${i}"][data-matrix-row="${t(this,x).dataset.matrixRow}"]`),g=u.dataset.expr?this.getExprValue(u.dataset.expr,l,a):l[u.dataset.bind],b=u.dataset.expr?this.getExprValue(u.dataset.expr,f,c):f[u.dataset.bind];if(g!=b){o=!0;break}}else o=!0;o?ninegrid.j.querySelectorAll(t(this,x)).removeClass("suppress"):ninegrid.j.querySelectorAll(t(this,x)).addClass("suppress"),ninegrid.j.querySelectorAll(t(this,x)).hasClass("hidden")||(o?ninegrid.j.querySelectorAll(t(this,x)).removeClass("hidden"):ninegrid.j.querySelectorAll(t(this,x)).addClass("hidden"));var v=parseInt(t(this,x).dataset.matrixRow),w=v-1,A=t(this,M).body.querySelector(`tbody.bindable [data-col="${t(this,x).dataset.col}"][data-matrix-row="${w}"]`);$(A).hasClass("suppress")&&!ninegrid.j.querySelectorAll(t(this,x)).hasClass("suppress")?ninegrid.j.querySelectorAll(A).removeClass("last-none-suppress").addClass("last-suppress"):!$(A).hasClass("suppress")&&ninegrid.j.querySelectorAll(t(this,x)).hasClass("suppress")?ninegrid.j.querySelectorAll(A).removeClass("last-suppress").addClass("last-none-suppress"):ninegrid.j.querySelectorAll(A).removeClass("last-none-suppress").removeClass("last-suppress")}}},"#resetSuppress"));C(this,"getExprValue",h((e,s,r,o)=>{if(typeof e<"u")try{r=parseInt(r);const i=e.replace("()","");return t(this,M)[i]?t(this,M)[i].call(this,s,r,t(this,x)):t(this,M).exprFunction(e).call(this,s,r,t(this,M).data)}catch{return["NG-COMBO"].includes(this.tagName)?"":e}else return e},"getExprValue"))}connectedCallback(){super.connectedCallback(),p(this,M,this.getRootNode().host),p(this,x,this.closest("th,td")),p(this,Wt,t(this,x).closest("tr"))}get value(){var e=!t(this,M)||!t(this,M).dataManager||!t(this,x)||!t(this,x).dataset||!t(this,x).dataset.row||!t(this,x).dataset.bind?"":t(this,x).closest("tr").data[t(this,x).dataset.bind];return e??""}set value(e){var s=parseInt(t(this,x).dataset.row);const r=this.getAttribute("update-row-state")!="false";s<0?t(this,M).data.setValueNF(parseInt(t(this,x).dataset.index),t(this,x).dataset.bind,e,r):t(this,M).data.setValue(s,t(this,x).dataset.bind,e,r)}get row(){return parseInt(t(this,x).dataset.row)}get data(){return t(this,x).closest("tr").data}refresh(){const e=t(this,x).dataset.bind;return parseInt(t(this,x).dataset.row),t(this,Wt).data[e]}};M=new WeakMap,Wt=new WeakMap,x=new WeakMap,Be=new WeakMap,Pe=new WeakMap,je=new WeakMap,Fe=new WeakMap,Ve=new WeakMap,h(Ye,"CellElement");let Re=Ye;const Ue=class Ue extends Re{constructor(){super()}connectedCallback(){super.connectedCallback()}refresh(){return super.refresh()}};h(Ue,"EditableCellElement");let Ae=Ue;const Ke=class Ke extends Ae{constructor(){super();d(this,Ot);d(this,dt);d(this,vt);d(this,wt);d(this,fe);d(this,K);C(this,"refresh",h(()=>{const e=super.refresh();t(this,Ot).value=e},"refresh"));d(this,Xe,h(e=>{if(!["Escape","Enter","Tab","Home","End","ArrowLeft","ArrowRight","PageUp","PageDown","Backspace","Delete"].includes(e.code)){if(t(this,dt)=="number"){let o=[];if(t(this,K)&&Number(t(this,K))>0&&o.push("."),t(this,wt)&&Number(t(this,wt))>=0&&o.push("-"),!(e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=105)&&!o.includes(e.key)&&e.preventDefault(),t(this,K)&&(e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=105)&&e.target.selectionStart==e.target.selectionEnd){var s=e.target.value,r=s.indexOf(".");if(r>=0){var s=s.substr(r+1,s.length);s.length>=Number(t(this,K))&&e.preventDefault()}}}t(this,vt)&&ninegrid.getByteLength(e.target.value)>=Number(t(this,vt))&&e.target.selectionStart==e.target.selectionEnd&&e.preventDefault()}},"#onKeyDown"));if(this.applyBaseStyle(),p(this,dt,this.getAttribute("type")||"text"),p(this,vt,this.getAttribute("maxbyte")),p(this,wt,this.getAttribute("min")),p(this,fe,this.getAttribute("max")),p(this,K,this.getAttribute("scale")),!["text","number"].includes(t(this,dt)))throw`invalid type : ${t(this,dt)}`}connectedCallback(){for(var e=[],s=0;s<this.attributes.length;s++)["type","maxlength","maxbyte","min","max","step","scale","text-align"].includes(this.attributes[s].name)&&e.push(`${this.attributes[s].name}="${this.attributes[s].value}"`);this.innerHTML=`
444
444
  <input type="text"
445
445
  ${e.join(" ")}
446
446
  ondragstart="return false;"
447
447
  >
448
- `,super.connectedCallback(),p(this,Bt,this.querySelector("input"))}};Bt=new WeakMap,ht=new WeakMap,xt=new WeakMap,vt=new WeakMap,fe=new WeakMap,K=new WeakMap,Xe=new WeakMap,h(Ke,"CellInputText");let qe=Ke;customElements.get("cell-input-text"),customElements.get("cell-input")||customElements.define("cell-input",qe)});
448
+ `,super.connectedCallback(),p(this,Ot,this.querySelector("input"))}};Ot=new WeakMap,dt=new WeakMap,vt=new WeakMap,wt=new WeakMap,fe=new WeakMap,K=new WeakMap,Xe=new WeakMap,h(Ke,"CellInputText");let qe=Ke;customElements.get("cell-input-text"),customElements.get("cell-input")||customElements.define("cell-input",qe)});
449
449
  //# sourceMappingURL=nine-table.umd.js.map