@ninebone/table 0.0.833 → 0.0.834

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.
@@ -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=d(()=>{const s=t(this,ot).querySelector(".ng-container-body .ng-part-body");if(!s){setTimeout(e,10);return}p(this,L,{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,ee).call(this),this.refresh()},"initWhenReady");e()}};rt=new WeakMap,ot=new WeakMap,yt=new WeakMap,L=new WeakMap,Ct=new WeakMap,kt=new WeakMap,ee=new WeakMap,d(Ue,"NineTableVScrollBar");let Tt=Ue;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",Tt);const Ke=class Ke{constructor(n){h(this,it);h(this,q);h(this,at);h(this,U,new Map);h(this,O,null);h(this,Z,null);h(this,lt,0);h(this,Lt,40);h(this,Ve,!1);h(this,Ye,!1);h(this,se,3);h(this,Xe,3);h(this,ne,0);k(this,"refresh",d(()=>{var e;w.log("rowManager.refresh");const n=t(this,q).querySelector(".ng-container-body .ng-part-body");n&&(t(this,It).call(this),t(this,Mt).call(this),t(this,mt).call(this,n.scrollTop),(e=t(this,q).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));k(this,"initialize",d(()=>{w.log("rowManager.initialize"),p(this,at,{scrollTables:t(this,q).querySelectorAll(".ng-part-body table"),firstTr:t(this,q).querySelector(".ng-container-body .ng-part-body tbody.bindable-tbody tr:not(.nodata)")}),p(this,O,null),t(this,U).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const i=t(this,q).querySelector(o);if(!i)return;const c=i.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(b=>b.cloneNode(!0));t(this,U).set(o,u)});const n=t(this,q).querySelector(".ng-container-body .ng-part-body"),e=t(this,q).querySelector(".ng-container-left .ng-part-body"),s=t(this,q).querySelector(".ng-container-right .ng-part-body"),r=t(this,q).querySelector(".ng-container-body .ng-part-header"),a=t(this,q).querySelector(".ng-container-body .ng-part-footer");if(n){t(this,It).call(this),t(this,$t).call(this),t(this,Mt).call(this),t(this,mt).call(this,n.scrollTop);let o=!1;p(this,ne,n.scrollLeft);const i=d(c=>{var u;if(o)return;o=!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),a&&a.scrollLeft!==f&&(a.scrollLeft=f),t(this,mt).call(this,l),(u=t(this,q).querySelector("nine-table-vscrollbar"))==null||u.refresh(),o=!1},"handleContainerScroll");n==null||n.addEventListener("scroll",c=>{i(n)}),[e,s].forEach(c=>{c==null||c.addEventListener("scroll",l=>{if(o)return;o=!0;const f=c.scrollTop;n&&n.scrollTop!==f&&(n.scrollTop=f),o=!1})})}},"initialize"));h(this,re,d((n,e)=>{w.log("rowManager.#renderRows");const s=t(this,U).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(i=>i.remove());const a=r.querySelector("tr.nodata"),o=document.createDocumentFragment();for(let i=0;i<t(this,Lt);i++)s.forEach(c=>{o.appendChild(c.cloneNode(!0))});a?a.before(o):r.appendChild(o),e===".ng-container-body"&&(t(this,at).firstTr=r.querySelector("tr:not(.nodata)"))},"#renderRows"));h(this,It,d(()=>{if(t(this,O)!==null&&t(this,O)>0)return t(this,O);const n=t(this,q).querySelector(".ng-container-body .ng-part-body");w.log("rowManager.#measureAndCacheHeight");const e=t(this,U).get(".ng-container-body");if(!e||e.length===0)throw new Error("invalid dom");const s=n.querySelector("tbody.bindable-tbody");if(!s)throw new Error("invalid dom");s.querySelectorAll("tr:not(.nodata)").forEach(b=>b.remove());const r=s.querySelector("tr.nodata"),a=document.createDocumentFragment();e.forEach(b=>{a.appendChild(b.cloneNode(!0))}),r?r.before(a):s.appendChild(a);const o=t(this,q),i=o.style.display,c=o.style.visibility,l=o.style.position;(i==="none"||window.getComputedStyle(o).display==="none")&&(o.style.display="block",o.style.visibility="hidden",o.style.position="absolute");let f=0;const u=s.querySelectorAll("tr");return u.forEach(b=>{let g=b.offsetHeight||b.getBoundingClientRect().height;if(g===0){const y=window.getComputedStyle(b);g=parseFloat(y.height)||parseFloat(y.minHeight)||0}f+=g}),u.forEach(b=>b.remove()),o.style.display=i,o.style.visibility=c,o.style.position=l,f<=0?-1:(p(this,O,f),t(this,Ht).call(this),t(this,O))},"#measureAndCacheHeight"));h(this,Mt,d(()=>{w.log("rowManager.#updateVirtualScrollHeight");const e=(t(this,it).data.get()||[]).length,s=t(this,O),r=e*s;[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(a=>{const o=t(this,q).querySelector(a);if(!o)return;const i=o.querySelector(".ng-part-body .ng-virtual-spacer");i&&(i.style.height=`${r}px`)})},"#updateVirtualScrollHeight"));h(this,Ht,d(()=>{if(t(this,lt)>0&&t(this,O)>0){const n=Math.ceil(t(this,lt)/t(this,O));p(this,Lt,n+t(this,se))}},"#updateRowCount"));h(this,oe,d(()=>{var i,c,l,f,u,b;const n=t(this,q).querySelector(".ng-container-left .ng-part-body table"),e=t(this,q).querySelector(".ng-container-body .ng-part-body table"),s=t(this,q).querySelector(".ng-container-right .ng-part-body table");if(e){const g=n?Array.from(n.querySelectorAll("tbody tr")):[],y=Array.from(e.querySelectorAll("tbody tr")),x=s?Array.from(s.querySelectorAll("tbody tr")):[],S=Math.max(g.length,y.length,x.length);for(let m=0;m<S;m++){const C=[((i=g[m])==null?void 0:i.getBoundingClientRect().height)||0,((c=y[m])==null?void 0:c.getBoundingClientRect().height)||0,((l=x[m])==null?void 0:l.getBoundingClientRect().height)||0],E=Math.max(...C);E>0&&(g[m]&&(g[m].style.height=`${E}px`),y[m]&&(y[m].style.height=`${E}px`),x[m]&&(x[m].style.height=`${E}px`))}}const r=t(this,q).querySelector(".ng-container-left .ng-part-footer table"),a=t(this,q).querySelector(".ng-container-body .ng-part-footer table"),o=t(this,q).querySelector(".ng-container-right .ng-part-footer table");if(a){const g=r?Array.from(r.querySelectorAll("tfoot tr")):[],y=Array.from(a.querySelectorAll("tfoot tr")),x=o?Array.from(o.querySelectorAll("tfoot tr")):[],S=Math.max(g.length,y.length,x.length);for(let m=0;m<S;m++){const C=[((f=g[m])==null?void 0:f.getBoundingClientRect().height)||0,((u=y[m])==null?void 0:u.getBoundingClientRect().height)||0,((b=x[m])==null?void 0:b.getBoundingClientRect().height)||0],E=Math.max(...C);E>0&&(g[m]&&(g[m].style.height=`${E}px`),y[m]&&(y[m].style.height=`${E}px`),x[m]&&(x[m].style.height=`${E}px`))}}},"#syncRowHeights"));h(this,ie,d(()=>{!t(this,q)||!(t(this,q)instanceof HTMLElement)||(p(this,Z,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 a=0;const o=s.querySelector(".ng-part-header"),i=s.querySelector(".ng-part-footer");o&&(a+=o.offsetHeight),i&&(a+=i.offsetHeight);const c=Math.max(r-a,100);t(this,lt)!==c&&(p(this,lt,c),t(this,Ht).call(this),t(this,O)!==null&&(t(this,$t).call(this),this.refresh()))}}})),t(this,Z).observe(t(this,q)))},"#initResizeObserver"));h(this,$t,d(()=>{w.log("rowManager.#renderAllContainers"),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const e=t(this,q).querySelector(n);e&&e.querySelector(".ng-part-body tbody.bindable-tbody")&&t(this,re).call(this,e,n)}),t(this,le).call(this),t(this,oe).call(this)},"#renderAllContainers"));h(this,mt,d(n=>{var u,b;const e=t(this,O);if(!e||e<=0)return;const s=t(this,it).data.length;if(s===0)return;const r=((u=t(this,U).get(".ng-container-body"))==null?void 0:u.length)||1,a=t(this,q).querySelector(".ng-container-body .ng-part-body"),o=Math.max(0,s-Math.floor(a.clientHeight/e)),i=Math.min(o,Math.max(0,Math.floor(n/e)));let c=Math.floor(i*e);const l=t(this,at).firstTr,f=l&&l.dataset.row!==void 0?parseInt(l.dataset.row,10):-1;(b=t(this,at))==null||b.scrollTables.forEach(g=>{g.style.transform=`translate3d(0, ${c}px, 0)`}),f!==i&&[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(g=>{const y=t(this,q).querySelector(g);if(!y)return;const x=y.querySelector(".ng-part-body tbody.bindable-tbody");if(!x)return;Array.from(x.querySelectorAll("tr:not(.nodata)")).forEach((m,C)=>{const E=i+Math.floor(C/r);if(E>=s){m.style.display="none";return}const W=t(this,it).data.get(E);m.style.display="",t(this,ae).call(this,m,W,E)})})},"#handleScroll"));h(this,ae,d((n,e,s)=>{n.dataset.row=s,n.data=e,Array.from(n.cells).forEach((r,a)=>{r.dataset.row=s;const o=Array.from(r.children).find(i=>i.tagName.toLowerCase().startsWith("cell-")||typeof i.refresh=="function");o&&typeof o.refresh=="function"&&o.refresh()})},"#bindRowData"));h(this,le,d(()=>{var c,l,f;w.log("rowManager.#syncHeaderHeights");const n=t(this,q).querySelector(".ng-container-left .ng-part-header table"),e=t(this,q).querySelector(".ng-container-body .ng-part-header table"),s=t(this,q).querySelector(".ng-container-right .ng-part-header table");if(!e)return;const r=n?Array.from(n.querySelectorAll("tr")):[],a=Array.from(e.querySelectorAll("tr")),o=s?Array.from(s.querySelectorAll("tr")):[],i=Math.max(r.length,a.length,o.length);for(let u=0;u<i;u++){const b=[((c=r[u])==null?void 0:c.getBoundingClientRect().height)||0,((l=a[u])==null?void 0:l.getBoundingClientRect().height)||0,((f=o[u])==null?void 0:f.getBoundingClientRect().height)||0],g=Math.max(...b);g>0&&(r[u]&&(r[u].style.height=`${g}px`),a[u]&&(a[u].style.height=`${g}px`),o[u]&&(o[u].style.height=`${g}px`))}},"#syncHeaderHeights"));k(this,"destroy",d(()=>{t(this,Z)&&(t(this,Z).disconnect(),p(this,Z,null))},"destroy"));p(this,it,n.getRootNode().host),p(this,q,n),t(this,ie).call(this)}getRowHeight(){return t(this,O)}templateLength(n=".ng-container-body"){var e;return((e=t(this,U).get(n))==null?void 0:e.length)||1}};it=new WeakMap,q=new WeakMap,at=new WeakMap,U=new WeakMap,O=new WeakMap,Z=new WeakMap,lt=new WeakMap,Lt=new WeakMap,Ve=new WeakMap,Ye=new WeakMap,se=new WeakMap,Xe=new WeakMap,ne=new WeakMap,re=new WeakMap,It=new WeakMap,Mt=new WeakMap,Ht=new WeakMap,oe=new WeakMap,ie=new WeakMap,$t=new WeakMap,mt=new WeakMap,ae=new WeakMap,le=new WeakMap,d(Ke,"RowManager");let Ce=Ke;const ce=class ce{static compileAll(n){return Array.isArray(n)?n.map(e=>ce.compile(e)):[]}static compile(n){if(!n)return null;const e=d(i=>{i.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 b=l.getAttribute("data-bind"),g=l.getAttribute("data-expr"),y=l.getAttribute("maxbyte"),x=l.getAttribute("type");let S=[];b&&S.push(`data-bind="${b}"`),g&&S.push(`data-expr="${g}"`),y&&S.push(`maxbyte="${y}"`),x&&S.push(`type="${x}"`),l.innerHTML=`<${u} ${S.join(" ")}></${u}>`}),i.querySelectorAll("tbody td, tfoot td").forEach(l=>{l.setAttribute("tabindex","0")})},"processCellTypes"),s=d(i=>{if(!i.querySelector("colgroup")){const c=i.querySelector("tbody tr")||i.querySelector("tr"),l=c?c.querySelectorAll("th, td").length:1,f=document.createElement("colgroup"),u=Math.max(Math.floor(i.clientWidth/l),100);for(let b=0;b<l;b++){const g=document.createElement("col");g.setAttribute("width",u),f.appendChild(g)}i.prepend(f)}if(!i.querySelector("thead")){const c=document.createElement("thead"),l=i.querySelector("colgroup");l?l.after(c):i.prepend(c)}i.classList.add("nine-table-element")},"ensureTableStructure"),r=d((i,c)=>{const l=Array.from(i.querySelectorAll(c+" tr")),f=Array.from(i.querySelectorAll(c+" th,"+c+" td")),u=l.length;if(u===0||f.length===0)return;let b=0;f.forEach(y=>{b+=y.colSpan||1});const g=Array.from(Array(u),()=>Array(b).fill(null));l.forEach(y=>{const x=y.sectionRowIndex;let S=0;y.dataset.subrow=x,Array.from(y.querySelectorAll("th,td")).forEach(m=>{for(let W=0;W<g[x].length;W++)if(g[x][W]===null){S=W;break}const C=m.rowSpan||1,E=m.colSpan||1;for(let W=0;W<C;W++)for(let qt=0;qt<E;qt++)x+W<u&&S+qt<b&&(g[x+W][S+qt]=W===0&&qt===0?"1":"0")})}),l.forEach(y=>{const x=y.sectionRowIndex;Array.from(y.querySelectorAll("th,td")).forEach(S=>{for(let m=0;m<g[x].length;m++)if(g[x][m]==="1"){S.dataset.col=m,g[x][m]="0";break}})})},"resetColIndex"),a=n.cloneNode(!0);return s(a),e(a),r(a,"thead"),r(a,"tbody"),r(a,"tfoot"),Array.from(a.querySelectorAll("colgroup col")).forEach((i,c)=>{const l=i.getAttribute("fixed");l&&a.querySelectorAll(`thead [data-col="${c}"], tbody [data-col="${c}"], tfoot [data-col="${c}"]`).forEach(f=>{f.setAttribute("fixed",l)})}),a}};d(ce,"TableCompiler");let ke=ce;const Ge=class Ge{constructor(n){h(this,Y);h(this,N);h(this,V,{startRow:-1,startCol:-1,endRow:-1,endCol:-1});k(this,"render",d(()=>{const{startRow:n,startCol:e,endRow:s,endCol:r}=t(this,V);w.log("🎨 [CellSelection.render] Rendering range ->",t(this,V));const a=t(this,N).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");if(a.forEach(i=>{i.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){w.log("⚠️ [CellSelection.render] Range is invalid (< 0), skipping render.");return}let o=0;a.forEach(i=>{i.querySelectorAll("tbody tr").forEach(c=>{const{matrixRow:l}=X(this,Y,Zt).call(this,c);l<0||c.querySelectorAll("td, th").forEach(f=>{const u=parseInt(f.dataset.col,10);if(isNaN(u))return;const b=parseInt(f.rowSpan||1,10),g=parseInt(f.colSpan||1,10),y=l+b-1,x=u+g-1;y>=n&&l<=s&&x>=e&&u<=r&&(o++,f.classList.add("selected"),w.log(f,n,e,s,r),l<=n&&f.classList.add("selected-top"),y>=s&&f.classList.add("selected-bottom"),u<=e&&f.classList.add("selected-left"),x>=r&&f.classList.add("selected-right"))})})}),w.log(`✨ [CellSelection.render] Total rendered cells marked: ${o}`)},"render"));p(this,N,n),X(this,Y,Ss).call(this),t(this,N).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body").forEach(s=>{s.addEventListener("scroll",()=>{t(this,V).startRow>=0&&t(this,V).startCol>=0&&this.render()})}),w.log("🎯 [CellSelection] Initialized")}setRange(n,e,s,r){w.log(`🔍 [CellSelection.setRange] Input -> startRow: ${n}, startCol: ${e}, endRow: ${s}, endCol: ${r}`);let a=Math.min(n,s),o=Math.max(n,s),i=Math.min(e,r),c=Math.max(e,r);const l=t(this,N).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");let f=!0,u=0;for(;f&&u<5;)f=!1,u++,l.forEach(b=>{b.querySelectorAll("tbody tr").forEach(g=>{if(g.classList.contains("nodata"))return;const{matrixRow:y}=X(this,Y,Zt).call(this,g);y<0||g.querySelectorAll("td, th").forEach(x=>{const S=parseInt(x.dataset.col,10);if(isNaN(S))return;const m=parseInt(x.rowSpan||1,10),C=parseInt(x.colSpan||1,10),E=y+m-1,W=S+C-1;if(E>=a&&y<=o&&W>=i&&S<=c){const bs=Math.min(a,y),ps=Math.max(o,E),ys=Math.min(i,S),ms=Math.max(c,W);(bs!==a||ps!==o||ys!==i||ms!==c)&&(a=bs,o=ps,i=ys,c=ms,f=!0)}})})});p(this,V,{startRow:a,startCol:i,endRow:o,endCol:c}),w.log("📦 [CellSelection.setRange] Final Range ->",t(this,V)),this.render()}};N=new WeakMap,V=new WeakMap,Y=new WeakSet,Zt=d(function(n){if(!n||n.classList.contains("nodata"))return{dataRow:-1,subRowIndex:-1,matrixRow:-1};const e=parseInt(n.dataset.row,10);if(isNaN(e))return{dataRow:-1,subRowIndex:-1,matrixRow:-1};const s=n.closest("tbody"),a=Array.from(s.querySelectorAll("tr:not(.nodata)")).filter(l=>parseInt(l.dataset.row,10)===e),o=a.indexOf(n),i=a.length>0?a.length:1,c=e*i+(o>=0?o:n.sectionRowIndex%i);return{dataRow:e,subRowIndex:o,matrixRow:c}},"#getMatrixRow"),Ss=d(function(){const n=t(this,N).querySelector(".ng-container-top");if(!n){w.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||s.dataset.row===void 0||s.dataset.col===void 0||s.closest("tr").classList.contains("nodata"))return;t(this,N).style.userSelect="none",t(this,N).style.webkitUserSelect="none";const r=s.closest("tr"),{matrixRow:a}=X(this,Y,Zt).call(this,r),o=parseInt(s.dataset.col,10);if(a<0){t(this,N).style.userSelect="",t(this,N).style.webkitUserSelect="";return}w.log(`🖱️ [MouseDown Success] startRow: ${a}, startCol: ${o}`),t(this,N).navigation.currentCell=s;let i=a,c=o;const l=d(u=>{const b=document.elementFromPoint(u.clientX,u.clientY);let g=b==null?void 0:b.closest("td, th");if(!g||!t(this,N).contains(g)){const m=t(this,N).querySelectorAll(".ng-part-body tbody tr:not(.nodata) td, .ng-part-body tbody tr:not(.nodata) th");for(const C of m){const E=C.getBoundingClientRect();if(u.clientX>=E.left&&u.clientX<=E.right&&u.clientY>=E.top&&u.clientY<=E.bottom){g=C;break}}}if(!g||g.dataset.row===void 0||g.dataset.col===void 0||g.closest("tr").classList.contains("nodata"))return;const y=g.closest("tr"),{matrixRow:x}=X(this,Y,Zt).call(this,y),S=parseInt(g.dataset.col,10);x<0||i===x&&c===S||(i=x,c=S,this.setRange(a,o,x,S))},"onMouseMove"),f=d(()=>{w.log("🖱️ [MouseUp] Drag ended."),t(this,N).style.userSelect="",t(this,N).style.webkitUserSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",f)},"onMouseUp");document.addEventListener("mousemove",l),document.addEventListener("mouseup",f)})},"#initEvents"),d(Ge,"CellSelection");let Le=Ge;const Ze=class Ze{constructor(n){h(this,ht);h(this,B);h(this,ct,null);h(this,Nt,null);h(this,he,-1);h(this,de,-1);h(this,_t,d(n=>{const e=[];return n.forEach(s=>e.push(...Array.from(s.querySelectorAll("td")))),e.length===0?null:(e.sort((s,r)=>parseInt(s.dataset.col,10)-parseInt(r.dataset.col,10)),e[e.length-1])},"#getMaxColCell"));h(this,Ot,d((n,e)=>{const s=t(this,dt).call(this,n);if(s.length===0)return e+1;let r=e+1;const a=[];s.forEach(o=>a.push(...Array.from(o.querySelectorAll("td")))),a.sort((o,i)=>parseInt(o.dataset.col,10)-parseInt(i.dataset.col,10));for(const o of a){const i=parseInt(o.dataset.col,10),c=parseInt(o.colSpan||1,10);if(e>=i&&e<i+c){r=i+c;break}}return r},"#getNextCol"));h(this,Dt,d((n,e)=>{const s=t(this,dt).call(this,n);if(s.length===0)return Math.max(0,e-1);let r=-1;const a=[];s.forEach(o=>a.push(...Array.from(o.querySelectorAll("td")))),a.sort((o,i)=>parseInt(o.dataset.col,10)-parseInt(i.dataset.col,10));for(const o of a){const i=parseInt(o.dataset.col,10);if(i<e)r=i;else break}return r},"#getPreviousCol"));h(this,dt,d(n=>{const e=t(this,B).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body"),s=[];return e.forEach(r=>{const a=Array.from(r.querySelectorAll("tbody tr:not(.nodata)"));for(const o of a){const i=parseInt(o.dataset.row,10),c=a.filter(y=>parseInt(y.dataset.row,10)===i),l=c.length>0?c.length:1,f=c.indexOf(o),u=i*l+(f>=0?f:0);if(u===n){s.push(o);break}const b=Array.from(o.querySelectorAll("td"));let g=!1;for(const y of b){const x=parseInt(y.rowSpan||1,10);if(x>1&&n>=u&&n<u+x){s.push(o),g=!0;break}}if(g)break}}),s},"#findTargetTrsByMatrix"));h(this,Wt,d((n,e,s,r)=>{const a=t(this,B).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body"),o=r!==void 0?r:n*1+e;for(const i of a){const c=Array.from(i.querySelectorAll("tbody tr:not(.nodata)"));for(const l of c){const f=parseInt(l.dataset.row,10),u=c.filter(S=>parseInt(S.dataset.row,10)===f),b=u.length>0?u.length:1,g=u.indexOf(l),y=f*b+(g>=0?g:0),x=Array.from(l.querySelectorAll("td"));for(const S of x){const m=parseInt(S.dataset.col,10),C=parseInt(S.colSpan||1,10),E=parseInt(S.rowSpan||1,10);if(!isNaN(m)&&s>=m&&s<m+C&&o>=y&&o<y+E&&window.getComputedStyle(S).display!=="none")return S}}}return null},"#getNearElement"));p(this,B,n),X(this,ht,Rs).call(this),w.log("🎯 [CellNavigation] Initialized")}get currentCell(){return t(this,ct)}set currentCell(n){if(!n)return;p(this,ct,n),n.focus({preventScroll:!0}),p(this,Nt,n.closest("tr"));const e=parseInt(n.dataset.row,10),s=parseInt(n.dataset.col,10);if(!isNaN(e)&&!isNaN(s)){p(this,he,e),p(this,de,s);const r=n.closest("tr"),a=r==null?void 0:r.closest("tbody");if(a){const i=Array.from(a.querySelectorAll("tr:not(.nodata)")).filter(u=>parseInt(u.dataset.row,10)===e),c=i.length>0?i.length:1,l=i.indexOf(r),f=e*c+(l>=0?l:0);t(this,B).selection.setRange(f,s,f,s)}}}moveCell(n){var g,y,x,S;if(!t(this,ct))return;const e=t(this,ct),s=parseInt(e.dataset.row,10),r=parseInt(e.dataset.col,10),a=t(this,B).templateLength,o=t(this,Nt).dataset.subrow,i=s*a+(o>=0?o:0);let c=i,l=r;switch(n.code){case"Tab":if(n.preventDefault(),n.shiftKey){if(l=t(this,Dt).call(this,i,r),l<0&&i>0){c=i-1;const m=t(this,dt).call(this,c),C=t(this,_t).call(this,m);l=C?parseInt(C.dataset.col,10):0}}else{l=t(this,Ot).call(this,i,r);const m=t(this,dt).call(this,i),C=t(this,_t).call(this,m),E=C?parseInt(C.dataset.col,10)+parseInt(C.colSpan||1,10):0;l>=E&&(c=i+1,l=0)}break;case"ArrowRight":l=t(this,Ot).call(this,i,r);break;case"ArrowLeft":l=t(this,Dt).call(this,i,r);break;case"ArrowDown":n.preventDefault(),c=i+(e.rowSpan||1),w.log("templateLength",a,"matrixRow:",i,"nextMatrixRow",c);break;case"ArrowUp":n.preventDefault(),c=Math.max(0,i-(e.rowSpan||1));break}const f=Math.floor(c/a),u=c%a;let b=t(this,Wt).call(this,f,u,l,c);if(w.log(b,f,u,l,c),b)this.currentCell=b,X(this,ht,gs).call(this,b);else if(f!==s&&f>=0){const m=((y=(g=t(this,B)).getRowHeight)==null?void 0:y.call(g))||40;(S=(x=t(this,B)).scrollToY)==null||S.call(x,f*m),setTimeout(()=>{const C=t(this,Wt).call(this,f,u,l,c);C&&(this.currentCell=C,X(this,ht,gs).call(this,C))},0)}}};B=new WeakMap,ct=new WeakMap,Nt=new WeakMap,he=new WeakMap,de=new WeakMap,ht=new WeakSet,gs=d(function(n){const e=t(this,B).querySelector(".ng-container-body .ng-part-body");if(!e)return;const s=n.getBoundingClientRect(),r=e.getBoundingClientRect();s.top<r.top?e.scrollTop-=r.top-s.top:s.bottom>r.bottom&&(e.scrollTop+=s.bottom-r.bottom),s.left<r.left?e.scrollLeft-=r.left-s.left:s.right>r.right&&(e.scrollLeft+=s.right-r.right)},"#ensureCellVisible"),_t=new WeakMap,Ot=new WeakMap,Dt=new WeakMap,dt=new WeakMap,Wt=new WeakMap,Rs=d(function(){t(this,B).addEventListener("keydown",n=>{["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(n.code)&&this.moveCell(n)})},"#initEvents"),d(Ze,"CellNavigation");let Ie=Ze;const Pt=class Pt extends HTMLElement{constructor(){super();h(this,fe);h(this,ft);h(this,zt);h(this,Bt);h(this,j,{table:null});k(this,"invalidate",d(()=>{w.log("sheet.invalidate()"),t(this,ft).refresh()},"invalidate"));k(this,"generate",d(e=>{if(w.log("sheet.generate()"),!e)return;t(this,j).table=ke.compile(e),t(this,j).tbody={tr:t(this,j).table.querySelectorAll("tbody tr")},t(this,ue).call(this),t(this,ge).call(this);const s=this.querySelector(".ng-container-body .ng-part-header"),r=this.querySelector(".ng-container-body .ng-part-footer"),a=this.querySelector(".ng-nodata-overlay");s&&a&&(a.style.top=`${s.offsetHeight}px`),r&&a&&(a.style.bottom=`${r.offsetHeight}px`),t(this,ft).initialize(),setTimeout(()=>{var o;(o=this.querySelector("nine-table-hscrollbar"))==null||o.refresh()},0)},"generate"));h(this,ue,d(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:s,type:r})=>{var a,o,i;(a=this.querySelector(`${s} .ng-part-header`))==null||a.appendChild(t(this,xt).call(this,t(this,j).table,r,"header")),(o=this.querySelector(`${s} .ng-virtual-spacer`))==null||o.before(t(this,xt).call(this,t(this,j).table,r,"body")),(i=this.querySelector(`${s} .ng-part-footer`))==null||i.appendChild(t(this,xt).call(this,t(this,j).table,r,"footer"))})},"#renderSplitContainers"));h(this,ge,d(()=>{["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 a=0;r[0].querySelectorAll("col").forEach(o=>{const i=parseInt(o.getAttribute("width"),10);isNaN(i)||(a+=i)}),e==="body"?(s.style.flex="1",r.forEach(o=>{o.style.width=`${a}px`,o.style.minWidth=`${a}px`})):(s.style.flex=`0 0 ${a}px`,s.style.width=`${a}px`,r.forEach(o=>{o.style.width=`${a}px`,o.style.minWidth=`${a}px`}))})},"#updateContainerWidths"));h(this,xt,d((e,s,r)=>{const a=e.cloneNode(!0),o=a.querySelector("thead"),i=a.querySelector("tbody"),c=a.querySelector("tfoot");if(r==="header"){if(i&&i.remove(),c&&c.remove(),e.querySelector("tbody")){const f=document.createElement("tbody");f.className="fixed-tbody",a.appendChild(f)}}else r==="body"?(o&&o.remove(),c&&c.remove(),i&&(i.className="bindable-tbody")):r==="footer"&&(o&&o.remove(),i&&i.remove());return s==="left"?a.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="left"&&l.remove()}):s==="right"?a.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="right"&&l.remove()}):a.querySelectorAll("[fixed=left], [fixed=right]").forEach(l=>{l.remove()}),a},"#createSplitTable"));k(this,"getRowHeight",d(()=>t(this,ft).getRowHeight(),"getRowHeight"));k(this,"scrollToX",d(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollLeft=e)},"scrollToX"));k(this,"scrollToY",d(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollTop=e)},"scrollToY"));h(this,be,d(()=>{t(this,pe).call(this),p(this,zt,new Le(this)),p(this,Bt,new Ie(this))},"#init"));h(this,pe,d(()=>{const e=Pt.SCROLLBAR_SIZE;this.innerHTML=`
126
+ `;const e=d(()=>{const s=t(this,ot).querySelector(".ng-container-body .ng-part-body");if(!s){setTimeout(e,10);return}p(this,L,{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,ee).call(this),this.refresh()},"initWhenReady");e()}};rt=new WeakMap,ot=new WeakMap,yt=new WeakMap,L=new WeakMap,Ct=new WeakMap,kt=new WeakMap,ee=new WeakMap,d(Ue,"NineTableVScrollBar");let Tt=Ue;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",Tt);const Ke=class Ke{constructor(n){h(this,it);h(this,q);h(this,at);h(this,U,new Map);h(this,O,null);h(this,Z,null);h(this,lt,0);h(this,Lt,40);h(this,Ve,!1);h(this,Ye,!1);h(this,se,3);h(this,Xe,3);h(this,ne,0);k(this,"refresh",d(()=>{var e;w.log("rowManager.refresh");const n=t(this,q).querySelector(".ng-container-body .ng-part-body");n&&(t(this,It).call(this),t(this,Mt).call(this),t(this,mt).call(this,n.scrollTop),(e=t(this,q).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));k(this,"initialize",d(()=>{w.log("rowManager.initialize"),p(this,at,{scrollTables:t(this,q).querySelectorAll(".ng-part-body table"),firstTr:t(this,q).querySelector(".ng-container-body .ng-part-body tbody.bindable-tbody tr:not(.nodata)")}),p(this,O,null),t(this,U).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const i=t(this,q).querySelector(o);if(!i)return;const c=i.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(b=>b.cloneNode(!0));t(this,U).set(o,u)});const n=t(this,q).querySelector(".ng-container-body .ng-part-body"),e=t(this,q).querySelector(".ng-container-left .ng-part-body"),s=t(this,q).querySelector(".ng-container-right .ng-part-body"),r=t(this,q).querySelector(".ng-container-body .ng-part-header"),a=t(this,q).querySelector(".ng-container-body .ng-part-footer");if(n){t(this,It).call(this),t(this,$t).call(this),t(this,Mt).call(this),t(this,mt).call(this,n.scrollTop);let o=!1;p(this,ne,n.scrollLeft);const i=d(c=>{var u;if(o)return;o=!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),a&&a.scrollLeft!==f&&(a.scrollLeft=f),t(this,mt).call(this,l),(u=t(this,q).querySelector("nine-table-vscrollbar"))==null||u.refresh(),o=!1},"handleContainerScroll");n==null||n.addEventListener("scroll",c=>{i(n)}),[e,s].forEach(c=>{c==null||c.addEventListener("scroll",l=>{if(o)return;o=!0;const f=c.scrollTop;n&&n.scrollTop!==f&&(n.scrollTop=f),o=!1})})}},"initialize"));h(this,re,d((n,e)=>{w.log("rowManager.#renderRows");const s=t(this,U).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(i=>i.remove());const a=r.querySelector("tr.nodata"),o=document.createDocumentFragment();for(let i=0;i<t(this,Lt);i++)s.forEach(c=>{o.appendChild(c.cloneNode(!0))});a?a.before(o):r.appendChild(o),e===".ng-container-body"&&(t(this,at).firstTr=r.querySelector("tr:not(.nodata)"))},"#renderRows"));h(this,It,d(()=>{if(t(this,O)!==null&&t(this,O)>0)return t(this,O);const n=t(this,q).querySelector(".ng-container-body .ng-part-body");w.log("rowManager.#measureAndCacheHeight");const e=t(this,U).get(".ng-container-body");if(!e||e.length===0)throw new Error("invalid dom");const s=n.querySelector("tbody.bindable-tbody");if(!s)throw new Error("invalid dom");s.querySelectorAll("tr:not(.nodata)").forEach(b=>b.remove());const r=s.querySelector("tr.nodata"),a=document.createDocumentFragment();e.forEach(b=>{a.appendChild(b.cloneNode(!0))}),r?r.before(a):s.appendChild(a);const o=t(this,q),i=o.style.display,c=o.style.visibility,l=o.style.position;(i==="none"||window.getComputedStyle(o).display==="none")&&(o.style.display="block",o.style.visibility="hidden",o.style.position="absolute");let f=0;const u=s.querySelectorAll("tr");return u.forEach(b=>{let g=b.offsetHeight||b.getBoundingClientRect().height;if(g===0){const y=window.getComputedStyle(b);g=parseFloat(y.height)||parseFloat(y.minHeight)||0}f+=g}),u.forEach(b=>b.remove()),o.style.display=i,o.style.visibility=c,o.style.position=l,f<=0?-1:(p(this,O,f),t(this,Ht).call(this),t(this,O))},"#measureAndCacheHeight"));h(this,Mt,d(()=>{w.log("rowManager.#updateVirtualScrollHeight");const e=(t(this,it).data.get()||[]).length,s=t(this,O),r=e*s;[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(a=>{const o=t(this,q).querySelector(a);if(!o)return;const i=o.querySelector(".ng-part-body .ng-virtual-spacer");i&&(i.style.height=`${r}px`)})},"#updateVirtualScrollHeight"));h(this,Ht,d(()=>{if(t(this,lt)>0&&t(this,O)>0){const n=Math.ceil(t(this,lt)/t(this,O));p(this,Lt,n+t(this,se))}},"#updateRowCount"));h(this,oe,d(()=>{var i,c,l,f,u,b;const n=t(this,q).querySelector(".ng-container-left .ng-part-body table"),e=t(this,q).querySelector(".ng-container-body .ng-part-body table"),s=t(this,q).querySelector(".ng-container-right .ng-part-body table");if(e){const g=n?Array.from(n.querySelectorAll("tbody tr")):[],y=Array.from(e.querySelectorAll("tbody tr")),x=s?Array.from(s.querySelectorAll("tbody tr")):[],S=Math.max(g.length,y.length,x.length);for(let m=0;m<S;m++){const C=[((i=g[m])==null?void 0:i.getBoundingClientRect().height)||0,((c=y[m])==null?void 0:c.getBoundingClientRect().height)||0,((l=x[m])==null?void 0:l.getBoundingClientRect().height)||0],E=Math.max(...C);E>0&&(g[m]&&(g[m].style.height=`${E}px`),y[m]&&(y[m].style.height=`${E}px`),x[m]&&(x[m].style.height=`${E}px`))}}const r=t(this,q).querySelector(".ng-container-left .ng-part-footer table"),a=t(this,q).querySelector(".ng-container-body .ng-part-footer table"),o=t(this,q).querySelector(".ng-container-right .ng-part-footer table");if(a){const g=r?Array.from(r.querySelectorAll("tfoot tr")):[],y=Array.from(a.querySelectorAll("tfoot tr")),x=o?Array.from(o.querySelectorAll("tfoot tr")):[],S=Math.max(g.length,y.length,x.length);for(let m=0;m<S;m++){const C=[((f=g[m])==null?void 0:f.getBoundingClientRect().height)||0,((u=y[m])==null?void 0:u.getBoundingClientRect().height)||0,((b=x[m])==null?void 0:b.getBoundingClientRect().height)||0],E=Math.max(...C);E>0&&(g[m]&&(g[m].style.height=`${E}px`),y[m]&&(y[m].style.height=`${E}px`),x[m]&&(x[m].style.height=`${E}px`))}}},"#syncRowHeights"));h(this,ie,d(()=>{!t(this,q)||!(t(this,q)instanceof HTMLElement)||(p(this,Z,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 a=0;const o=s.querySelector(".ng-part-header"),i=s.querySelector(".ng-part-footer");o&&(a+=o.offsetHeight),i&&(a+=i.offsetHeight);const c=Math.max(r-a,100);t(this,lt)!==c&&(p(this,lt,c),t(this,Ht).call(this),t(this,O)!==null&&(t(this,$t).call(this),this.refresh()))}}})),t(this,Z).observe(t(this,q)))},"#initResizeObserver"));h(this,$t,d(()=>{w.log("rowManager.#renderAllContainers"),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const e=t(this,q).querySelector(n);e&&e.querySelector(".ng-part-body tbody.bindable-tbody")&&t(this,re).call(this,e,n)}),t(this,le).call(this),t(this,oe).call(this)},"#renderAllContainers"));h(this,mt,d(n=>{var u,b;const e=t(this,O);if(!e||e<=0)return;const s=t(this,it).data.length;if(s===0)return;const r=((u=t(this,U).get(".ng-container-body"))==null?void 0:u.length)||1,a=t(this,q).querySelector(".ng-container-body .ng-part-body"),o=Math.max(0,s-Math.floor(a.clientHeight/e)),i=Math.min(o,Math.max(0,Math.floor(n/e)));let c=Math.floor(i*e);const l=t(this,at).firstTr,f=l&&l.dataset.row!==void 0?parseInt(l.dataset.row,10):-1;(b=t(this,at))==null||b.scrollTables.forEach(g=>{g.style.transform=`translate3d(0, ${c}px, 0)`}),f!==i&&[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(g=>{const y=t(this,q).querySelector(g);if(!y)return;const x=y.querySelector(".ng-part-body tbody.bindable-tbody");if(!x)return;Array.from(x.querySelectorAll("tr:not(.nodata)")).forEach((m,C)=>{const E=i+Math.floor(C/r);if(E>=s){m.style.display="none";return}const W=t(this,it).data.get(E);m.style.display="",t(this,ae).call(this,m,W,E)})})},"#handleScroll"));h(this,ae,d((n,e,s)=>{n.dataset.row=s,n.data=e,Array.from(n.cells).forEach((r,a)=>{r.dataset.row=s;const o=Array.from(r.children).find(i=>i.tagName.toLowerCase().startsWith("cell-")||typeof i.refresh=="function");o&&typeof o.refresh=="function"&&o.refresh()})},"#bindRowData"));h(this,le,d(()=>{var c,l,f;w.log("rowManager.#syncHeaderHeights");const n=t(this,q).querySelector(".ng-container-left .ng-part-header table"),e=t(this,q).querySelector(".ng-container-body .ng-part-header table"),s=t(this,q).querySelector(".ng-container-right .ng-part-header table");if(!e)return;const r=n?Array.from(n.querySelectorAll("tr")):[],a=Array.from(e.querySelectorAll("tr")),o=s?Array.from(s.querySelectorAll("tr")):[],i=Math.max(r.length,a.length,o.length);for(let u=0;u<i;u++){const b=[((c=r[u])==null?void 0:c.getBoundingClientRect().height)||0,((l=a[u])==null?void 0:l.getBoundingClientRect().height)||0,((f=o[u])==null?void 0:f.getBoundingClientRect().height)||0],g=Math.max(...b);g>0&&(r[u]&&(r[u].style.height=`${g}px`),a[u]&&(a[u].style.height=`${g}px`),o[u]&&(o[u].style.height=`${g}px`))}},"#syncHeaderHeights"));k(this,"destroy",d(()=>{t(this,Z)&&(t(this,Z).disconnect(),p(this,Z,null))},"destroy"));p(this,it,n.getRootNode().host),p(this,q,n),t(this,ie).call(this)}getRowHeight(){return t(this,O)}templateLength(n=".ng-container-body"){var e;return((e=t(this,U).get(n))==null?void 0:e.length)||1}};it=new WeakMap,q=new WeakMap,at=new WeakMap,U=new WeakMap,O=new WeakMap,Z=new WeakMap,lt=new WeakMap,Lt=new WeakMap,Ve=new WeakMap,Ye=new WeakMap,se=new WeakMap,Xe=new WeakMap,ne=new WeakMap,re=new WeakMap,It=new WeakMap,Mt=new WeakMap,Ht=new WeakMap,oe=new WeakMap,ie=new WeakMap,$t=new WeakMap,mt=new WeakMap,ae=new WeakMap,le=new WeakMap,d(Ke,"RowManager");let Ce=Ke;const ce=class ce{static compileAll(n){return Array.isArray(n)?n.map(e=>ce.compile(e)):[]}static compile(n){if(!n)return null;const e=d(i=>{i.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 b=l.getAttribute("data-bind"),g=l.getAttribute("data-expr"),y=l.getAttribute("maxbyte"),x=l.getAttribute("type");let S=[];b&&S.push(`data-bind="${b}"`),g&&S.push(`data-expr="${g}"`),y&&S.push(`maxbyte="${y}"`),x&&S.push(`type="${x}"`),l.innerHTML=`<${u} ${S.join(" ")}></${u}>`}),i.querySelectorAll("tbody td, tfoot td").forEach(l=>{l.setAttribute("tabindex","0")})},"processCellTypes"),s=d(i=>{if(!i.querySelector("colgroup")){const c=i.querySelector("tbody tr")||i.querySelector("tr"),l=c?c.querySelectorAll("th, td").length:1,f=document.createElement("colgroup"),u=Math.max(Math.floor(i.clientWidth/l),100);for(let b=0;b<l;b++){const g=document.createElement("col");g.setAttribute("width",u),f.appendChild(g)}i.prepend(f)}if(!i.querySelector("thead")){const c=document.createElement("thead"),l=i.querySelector("colgroup");l?l.after(c):i.prepend(c)}i.classList.add("nine-table-element")},"ensureTableStructure"),r=d((i,c)=>{const l=Array.from(i.querySelectorAll(c+" tr")),f=Array.from(i.querySelectorAll(c+" th,"+c+" td")),u=l.length;if(u===0||f.length===0)return;let b=0;f.forEach(y=>{b+=y.colSpan||1});const g=Array.from(Array(u),()=>Array(b).fill(null));l.forEach(y=>{const x=y.sectionRowIndex;let S=0;y.dataset.subrow=x,Array.from(y.querySelectorAll("th,td")).forEach(m=>{for(let W=0;W<g[x].length;W++)if(g[x][W]===null){S=W;break}const C=m.rowSpan||1,E=m.colSpan||1;for(let W=0;W<C;W++)for(let qt=0;qt<E;qt++)x+W<u&&S+qt<b&&(g[x+W][S+qt]=W===0&&qt===0?"1":"0")})}),l.forEach(y=>{const x=y.sectionRowIndex;Array.from(y.querySelectorAll("th,td")).forEach(S=>{for(let m=0;m<g[x].length;m++)if(g[x][m]==="1"){S.dataset.col=m,g[x][m]="0";break}})})},"resetColIndex"),a=n.cloneNode(!0);return s(a),e(a),r(a,"thead"),r(a,"tbody"),r(a,"tfoot"),Array.from(a.querySelectorAll("colgroup col")).forEach((i,c)=>{const l=i.getAttribute("fixed");l&&a.querySelectorAll(`thead [data-col="${c}"], tbody [data-col="${c}"], tfoot [data-col="${c}"]`).forEach(f=>{f.setAttribute("fixed",l)})}),a}};d(ce,"TableCompiler");let ke=ce;const Ge=class Ge{constructor(n){h(this,Y);h(this,N);h(this,V,{startRow:-1,startCol:-1,endRow:-1,endCol:-1});k(this,"render",d(()=>{const{startRow:n,startCol:e,endRow:s,endCol:r}=t(this,V);w.log("🎨 [CellSelection.render] Rendering range ->",t(this,V));const a=t(this,N).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");if(a.forEach(i=>{i.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){w.log("⚠️ [CellSelection.render] Range is invalid (< 0), skipping render.");return}let o=0;a.forEach(i=>{i.querySelectorAll("tbody tr").forEach(c=>{const{matrixRow:l}=X(this,Y,Zt).call(this,c);l<0||c.querySelectorAll("td, th").forEach(f=>{const u=parseInt(f.dataset.col,10);if(isNaN(u))return;const b=parseInt(f.rowSpan||1,10),g=parseInt(f.colSpan||1,10),y=l+b-1,x=u+g-1;y>=n&&l<=s&&x>=e&&u<=r&&(o++,f.classList.add("selected"),w.log(f,n,e,s,r),l<=n&&f.classList.add("selected-top"),y>=s&&f.classList.add("selected-bottom"),u<=e&&f.classList.add("selected-left"),x>=r&&f.classList.add("selected-right"))})})}),w.log(`✨ [CellSelection.render] Total rendered cells marked: ${o}`)},"render"));p(this,N,n),X(this,Y,Ss).call(this),t(this,N).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body").forEach(s=>{s.addEventListener("scroll",()=>{t(this,V).startRow>=0&&t(this,V).startCol>=0&&this.render()})}),w.log("🎯 [CellSelection] Initialized")}setRange(n,e,s,r){w.log(`🔍 [CellSelection.setRange] Input -> startRow: ${n}, startCol: ${e}, endRow: ${s}, endCol: ${r}`);let a=Math.min(n,s),o=Math.max(n,s),i=Math.min(e,r),c=Math.max(e,r);const l=t(this,N).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");let f=!0,u=0;for(;f&&u<5;)f=!1,u++,l.forEach(b=>{b.querySelectorAll("tbody tr").forEach(g=>{if(g.classList.contains("nodata"))return;const{matrixRow:y}=X(this,Y,Zt).call(this,g);y<0||g.querySelectorAll("td, th").forEach(x=>{const S=parseInt(x.dataset.col,10);if(isNaN(S))return;const m=parseInt(x.rowSpan||1,10),C=parseInt(x.colSpan||1,10),E=y+m-1,W=S+C-1;if(E>=a&&y<=o&&W>=i&&S<=c){const bs=Math.min(a,y),ps=Math.max(o,E),ys=Math.min(i,S),ms=Math.max(c,W);(bs!==a||ps!==o||ys!==i||ms!==c)&&(a=bs,o=ps,i=ys,c=ms,f=!0)}})})});p(this,V,{startRow:a,startCol:i,endRow:o,endCol:c}),w.log("📦 [CellSelection.setRange] Final Range ->",t(this,V)),this.render()}};N=new WeakMap,V=new WeakMap,Y=new WeakSet,Zt=d(function(n){if(!n||n.classList.contains("nodata"))return{dataRow:-1,subRowIndex:-1,matrixRow:-1};const e=parseInt(n.dataset.row,10);if(isNaN(e))return{dataRow:-1,subRowIndex:-1,matrixRow:-1};const s=n.closest("tbody"),a=Array.from(s.querySelectorAll("tr:not(.nodata)")).filter(l=>parseInt(l.dataset.row,10)===e),o=a.indexOf(n),i=a.length>0?a.length:1,c=e*i+(o>=0?o:n.sectionRowIndex%i);return{dataRow:e,subRowIndex:o,matrixRow:c}},"#getMatrixRow"),Ss=d(function(){const n=t(this,N).querySelector(".ng-container-top");if(!n){w.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||s.dataset.row===void 0||s.dataset.col===void 0||s.closest("tr").classList.contains("nodata"))return;t(this,N).style.userSelect="none",t(this,N).style.webkitUserSelect="none";const r=s.closest("tr"),{matrixRow:a}=X(this,Y,Zt).call(this,r),o=parseInt(s.dataset.col,10);if(a<0){t(this,N).style.userSelect="",t(this,N).style.webkitUserSelect="";return}w.log(`🖱️ [MouseDown Success] startRow: ${a}, startCol: ${o}`),t(this,N).navigation.currentCell=s;let i=a,c=o;const l=d(u=>{const b=document.elementFromPoint(u.clientX,u.clientY);let g=b==null?void 0:b.closest("td, th");if(!g||!t(this,N).contains(g)){const m=t(this,N).querySelectorAll(".ng-part-body tbody tr:not(.nodata) td, .ng-part-body tbody tr:not(.nodata) th");for(const C of m){const E=C.getBoundingClientRect();if(u.clientX>=E.left&&u.clientX<=E.right&&u.clientY>=E.top&&u.clientY<=E.bottom){g=C;break}}}if(!g||g.dataset.row===void 0||g.dataset.col===void 0||g.closest("tr").classList.contains("nodata"))return;const y=g.closest("tr"),{matrixRow:x}=X(this,Y,Zt).call(this,y),S=parseInt(g.dataset.col,10);x<0||i===x&&c===S||(i=x,c=S,this.setRange(a,o,x,S))},"onMouseMove"),f=d(()=>{w.log("🖱️ [MouseUp] Drag ended."),t(this,N).style.userSelect="",t(this,N).style.webkitUserSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",f)},"onMouseUp");document.addEventListener("mousemove",l),document.addEventListener("mouseup",f)})},"#initEvents"),d(Ge,"CellSelection");let Le=Ge;const Ze=class Ze{constructor(n){h(this,ht);h(this,B);h(this,ct,null);h(this,Nt,null);h(this,he,-1);h(this,de,-1);h(this,_t,d(n=>{const e=[];return n.forEach(s=>e.push(...Array.from(s.querySelectorAll("td")))),e.length===0?null:(e.sort((s,r)=>parseInt(s.dataset.col,10)-parseInt(r.dataset.col,10)),e[e.length-1])},"#getMaxColCell"));h(this,Ot,d((n,e)=>{const s=t(this,dt).call(this,n);if(s.length===0)return e+1;let r=e+1;const a=[];s.forEach(o=>a.push(...Array.from(o.querySelectorAll("td")))),a.sort((o,i)=>parseInt(o.dataset.col,10)-parseInt(i.dataset.col,10));for(const o of a){const i=parseInt(o.dataset.col,10),c=parseInt(o.colSpan||1,10);if(e>=i&&e<i+c){r=i+c;break}}return r},"#getNextCol"));h(this,Dt,d((n,e)=>{const s=t(this,dt).call(this,n);if(s.length===0)return Math.max(0,e-1);let r=-1;const a=[];s.forEach(o=>a.push(...Array.from(o.querySelectorAll("td")))),a.sort((o,i)=>parseInt(o.dataset.col,10)-parseInt(i.dataset.col,10));for(const o of a){const i=parseInt(o.dataset.col,10);if(i<e)r=i;else break}return r},"#getPreviousCol"));h(this,dt,d(n=>{const e=t(this,B).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body"),s=[];return e.forEach(r=>{const a=Array.from(r.querySelectorAll("tbody tr:not(.nodata)"));for(const o of a){const i=parseInt(o.dataset.row,10),c=a.filter(y=>parseInt(y.dataset.row,10)===i),l=c.length>0?c.length:1,f=c.indexOf(o),u=i*l+(f>=0?f:0);if(u===n){s.push(o);break}const b=Array.from(o.querySelectorAll("td"));let g=!1;for(const y of b){const x=parseInt(y.rowSpan||1,10);if(x>1&&n>=u&&n<u+x){s.push(o),g=!0;break}}if(g)break}}),s},"#findTargetTrsByMatrix"));h(this,Wt,d((n,e,s,r)=>{const a=t(this,B).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body"),o=r!==void 0?r:n*1+e;for(const i of a){const c=Array.from(i.querySelectorAll("tbody tr:not(.nodata)"));for(const l of c){const f=parseInt(l.dataset.row,10),u=c.filter(S=>parseInt(S.dataset.row,10)===f),b=u.length>0?u.length:1,g=u.indexOf(l),y=f*b+(g>=0?g:0),x=Array.from(l.querySelectorAll("td"));for(const S of x){const m=parseInt(S.dataset.col,10),C=parseInt(S.colSpan||1,10),E=parseInt(S.rowSpan||1,10);if(!isNaN(m)&&s>=m&&s<m+C&&o>=y&&o<y+E&&window.getComputedStyle(S).display!=="none")return S}}}return null},"#getNearElement"));p(this,B,n),X(this,ht,Rs).call(this),w.log("🎯 [CellNavigation] Initialized")}get currentCell(){return t(this,ct)}set currentCell(n){if(!n)return;p(this,ct,n),n.focus({preventScroll:!0}),p(this,Nt,n.closest("tr"));const e=parseInt(n.dataset.row,10),s=parseInt(n.dataset.col,10);if(!isNaN(e)&&!isNaN(s)){p(this,he,e),p(this,de,s);const r=n.closest("tr"),a=r==null?void 0:r.closest("tbody");if(a){const i=Array.from(a.querySelectorAll("tr:not(.nodata)")).filter(u=>parseInt(u.dataset.row,10)===e),c=i.length>0?i.length:1,l=i.indexOf(r),f=e*c+(l>=0?l:0);t(this,B).selection.setRange(f,s,f,s)}}}moveCell(n){var g,y,x,S;if(!t(this,ct))return;const e=t(this,ct),s=parseInt(e.dataset.row,10),r=parseInt(e.dataset.col,10),a=t(this,B).templateLength,o=parseInt(t(this,Nt).dataset.subrow,10),i=s*a+(o>=0?o:0);let c=i,l=r;switch(n.code){case"Tab":if(n.preventDefault(),n.shiftKey){if(l=t(this,Dt).call(this,i,r),l<0&&i>0){c=i-1;const m=t(this,dt).call(this,c),C=t(this,_t).call(this,m);l=C?parseInt(C.dataset.col,10):0}}else{l=t(this,Ot).call(this,i,r);const m=t(this,dt).call(this,i),C=t(this,_t).call(this,m),E=C?parseInt(C.dataset.col,10)+parseInt(C.colSpan||1,10):0;l>=E&&(c=i+1,l=0)}break;case"ArrowRight":l=t(this,Ot).call(this,i,r);break;case"ArrowLeft":l=t(this,Dt).call(this,i,r);break;case"ArrowDown":n.preventDefault(),c=i+(e.rowSpan||1),w.log("templateLength",a,"matrixRow:",i,"nextMatrixRow",c);break;case"ArrowUp":n.preventDefault(),c=Math.max(0,i-(e.rowSpan||1));break}const f=Math.floor(c/a),u=c%a;let b=t(this,Wt).call(this,f,u,l,c);if(w.log(b,f,u,l,c),b)this.currentCell=b,X(this,ht,gs).call(this,b);else if(f!==s&&f>=0){const m=((y=(g=t(this,B)).getRowHeight)==null?void 0:y.call(g))||40;(S=(x=t(this,B)).scrollToY)==null||S.call(x,f*m),setTimeout(()=>{const C=t(this,Wt).call(this,f,u,l,c);C&&(this.currentCell=C,X(this,ht,gs).call(this,C))},0)}}};B=new WeakMap,ct=new WeakMap,Nt=new WeakMap,he=new WeakMap,de=new WeakMap,ht=new WeakSet,gs=d(function(n){const e=t(this,B).querySelector(".ng-container-body .ng-part-body");if(!e)return;const s=n.getBoundingClientRect(),r=e.getBoundingClientRect();s.top<r.top?e.scrollTop-=r.top-s.top:s.bottom>r.bottom&&(e.scrollTop+=s.bottom-r.bottom),s.left<r.left?e.scrollLeft-=r.left-s.left:s.right>r.right&&(e.scrollLeft+=s.right-r.right)},"#ensureCellVisible"),_t=new WeakMap,Ot=new WeakMap,Dt=new WeakMap,dt=new WeakMap,Wt=new WeakMap,Rs=d(function(){t(this,B).addEventListener("keydown",n=>{["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(n.code)&&this.moveCell(n)})},"#initEvents"),d(Ze,"CellNavigation");let Ie=Ze;const Pt=class Pt extends HTMLElement{constructor(){super();h(this,fe);h(this,ft);h(this,zt);h(this,Bt);h(this,j,{table:null});k(this,"invalidate",d(()=>{w.log("sheet.invalidate()"),t(this,ft).refresh()},"invalidate"));k(this,"generate",d(e=>{if(w.log("sheet.generate()"),!e)return;t(this,j).table=ke.compile(e),t(this,j).tbody={tr:t(this,j).table.querySelectorAll("tbody tr")},t(this,ue).call(this),t(this,ge).call(this);const s=this.querySelector(".ng-container-body .ng-part-header"),r=this.querySelector(".ng-container-body .ng-part-footer"),a=this.querySelector(".ng-nodata-overlay");s&&a&&(a.style.top=`${s.offsetHeight}px`),r&&a&&(a.style.bottom=`${r.offsetHeight}px`),t(this,ft).initialize(),setTimeout(()=>{var o;(o=this.querySelector("nine-table-hscrollbar"))==null||o.refresh()},0)},"generate"));h(this,ue,d(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:s,type:r})=>{var a,o,i;(a=this.querySelector(`${s} .ng-part-header`))==null||a.appendChild(t(this,xt).call(this,t(this,j).table,r,"header")),(o=this.querySelector(`${s} .ng-virtual-spacer`))==null||o.before(t(this,xt).call(this,t(this,j).table,r,"body")),(i=this.querySelector(`${s} .ng-part-footer`))==null||i.appendChild(t(this,xt).call(this,t(this,j).table,r,"footer"))})},"#renderSplitContainers"));h(this,ge,d(()=>{["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 a=0;r[0].querySelectorAll("col").forEach(o=>{const i=parseInt(o.getAttribute("width"),10);isNaN(i)||(a+=i)}),e==="body"?(s.style.flex="1",r.forEach(o=>{o.style.width=`${a}px`,o.style.minWidth=`${a}px`})):(s.style.flex=`0 0 ${a}px`,s.style.width=`${a}px`,r.forEach(o=>{o.style.width=`${a}px`,o.style.minWidth=`${a}px`}))})},"#updateContainerWidths"));h(this,xt,d((e,s,r)=>{const a=e.cloneNode(!0),o=a.querySelector("thead"),i=a.querySelector("tbody"),c=a.querySelector("tfoot");if(r==="header"){if(i&&i.remove(),c&&c.remove(),e.querySelector("tbody")){const f=document.createElement("tbody");f.className="fixed-tbody",a.appendChild(f)}}else r==="body"?(o&&o.remove(),c&&c.remove(),i&&(i.className="bindable-tbody")):r==="footer"&&(o&&o.remove(),i&&i.remove());return s==="left"?a.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="left"&&l.remove()}):s==="right"?a.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="right"&&l.remove()}):a.querySelectorAll("[fixed=left], [fixed=right]").forEach(l=>{l.remove()}),a},"#createSplitTable"));k(this,"getRowHeight",d(()=>t(this,ft).getRowHeight(),"getRowHeight"));k(this,"scrollToX",d(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollLeft=e)},"scrollToX"));k(this,"scrollToY",d(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollTop=e)},"scrollToY"));h(this,be,d(()=>{t(this,pe).call(this),p(this,zt,new Le(this)),p(this,Bt,new Ie(this))},"#init"));h(this,pe,d(()=>{const e=Pt.SCROLLBAR_SIZE;this.innerHTML=`
127
127
  <style>
128
128
  nine-table-sheet {
129
129
  display: none;