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