@ninebone/table 0.1.42 → 0.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- (function(k,H){typeof exports=="object"&&typeof module<"u"?H(exports,require("@ninebone/util")):typeof define=="function"&&define.amd?define(["exports","@ninebone/util"],H):(k=typeof globalThis<"u"?globalThis:k||self,H(k.NineTable={},k.nine))})(this,function(k,H){"use strict";var vl=Object.defineProperty;var Sl=k=>{throw TypeError(k)};var ia=(k,H,B)=>H in k?vl(k,H,{enumerable:!0,configurable:!0,writable:!0,value:B}):k[H]=B;var h=(k,H)=>vl(k,"name",{value:H,configurable:!0});var E=(k,H,B)=>ia(k,typeof H!="symbol"?H+"":H,B),nl=(k,H,B)=>H.has(k)||Sl("Cannot "+B);var t=(k,H,B)=>(nl(k,H,"read from private field"),B?B.call(k):H.get(k)),d=(k,H,B)=>H.has(k)?Sl("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(k):H.set(k,B),p=(k,H,B,de)=>(nl(k,H,"write to private field"),de?de.call(k,B):H.set(k,B),B),A=(k,H,B)=>(nl(k,H,"access private method"),B);var Al=(k,H,B,de)=>({set _(v){p(k,H,v,B)},get _(){return t(k,H,de)}});var Fs,Ws,At,U,Os,ge,Qt,Ui,pe,zs,Gi,ji,ds,Ie,us,Z,Bs,Ki,Yi,Vt,Zi,Ps,Ji,El,Et,fs,be,Ll,Rl,Cl,Lt,qe,N,Me,He,Ne,Qi,De,tr,er,M,$e,F,Vs,mo,Xs,Fe,sr,ir,$t,_s,We,Oe,ze,ft,ol,ll,al,cl,rr,Us,L,Be,Gs,te,G,me,ee,gs,ps,Pe,Ve,nr,or,js,Ks,Ys,bs,lr,ar,cr,Zs,hl,J,Js,se,zi,Tl,$,Qs,ye,Xt,So,Ao,pt,cs,dl,ti,ei,si,ii,ri,ms,ni,kl,X,Xe,Ct,_e,_t,Tt,Ut,Gt,ys,jt,xe,oi,li,kt,yn,ul,ai,ci,fl,hi,hr,di,K,P,et,we,ie,re,Ft,ui,Ue,st,Il,ql,xn,Ml,fi,Hl,gi,gl,dr,ve,Wt,ne,bt,oe,Kt,ur,fr,gr,pr,Nl,br,mr,yr,To,Ge,je,pi,It,Se,Ke,xr,Yt,wr,vr,bi,pl,ct,mi,ht,Ot,Dl,$l,Fl,bl,Ye,yt,Ae,Ho,yi,le,xi,Sr,O,Wl,Ol,zl,Bl,Pl,Vl,Xl,_l,Ul,Gl,jl,Kl,wi,ae,zt,vi,Si,Ee,xs,Ai,Ar,Ei,ws,Ze,qt,Je,Er,Yl,Lr,Rr,Qe,Li,Cr,Tr,kr,Ir,Ri,qr,it,Mr,Ti,Hr,ki,vs,Ii,qi,Le,Mi,Ss,Nr,Dr,Zl,I,Ni,dt,q,ts,es,$r,Fr,Mt,Wr,Or,zr,xt,As,Br,Es,Pr,wt,ce,Vr,Ls,Xr,he,Rs,ss,Cs,Ts,_r,Ur,Gr,is,Bt,rs,ks,_o,Uo,Go,jo,jr,Di,Kr,Yr,ot,Zr,Jr,Is,Qr,tn,en,sn,rn,nn,on,qs,Pt,Re,ns,os,Ce,Ht,$i,ln,Fi,an,cn,hn,Ms,dn,ls,Wi,un,Hs,Ns,fn,gn,ut,Y,Ds,Q,vt,pn,j,wn,ml,Jl,yl,Ql,ta,ea,Oi,Zt,as,xl,sa;Array.prototype.nineBinarySearch=function(Nt){let n=0,e=this.length-1,s;for(;n<=e;){if(s=parseInt((n+e)/2),Nt===this[s])return s;Nt<this[s]?e=s-1:n=s+1}return-1};const B=new WeakMap;HTMLElement.prototype.addDebounseEventListener=function(Nt,n,e,s,i=500){const r=this;B.has(r)||B.set(r,{timer:null,cancelFn:null});const o=B.get(r);r.addEventListener(e,l=>{l.actualTarget=l.target,o.timer&&(clearTimeout(o.timer),o.timer=null),o.timer=setTimeout(()=>{o.timer=null,o.cancelFn=s.call(r,l)},i)}),r.addEventListener(Nt,l=>{o.timer&&(clearTimeout(o.timer),o.timer=null),o.cancelFn&&(o.cancelFn(),o.cancelFn=null),n.call(r,l)})},nine.measureTextSize=(Nt,n="12px sans-serif")=>{if(typeof Nt=="number"&&(Nt=Nt+""),!Nt)return{width:null,height:null};const e=h(l=>{const a=document.createElement("DIV");return a.innerHTML=l,a.textContent||a.innerText||""},"stripHtml");Nt=Nt.replaceAll(`
2
- `,"<br>");let s=document.body.querySelector("canvas#_nine_measure_canvas_");s||(s=document.createElement("canvas"),s.id="_nine_measure_canvas_",s.style.cssText="position: absolute; visibility: hidden; pointer-events: none; left: -9999px;",document.body.appendChild(s));const i=s.getContext("2d");i.font=n;let r=0,o=0;for(let l of Nt.split("<br>")){const a=e(l),c=i.measureText(a);r=Math.max(r,c.width);const u=c.fontBoundingBoxAscent||10,g=c.fontBoundingBoxDescent||3;o+=u+g}return{width:r,height:o}};const lo=class lo extends H.trace.constructor{constructor(){super(),this.init("nine-table","green")}};h(lo,"Trace");let de=lo;const v=new de,Dt={META:{INDEX:{ROWID:0,FILTER:1,GROUP:2}},ROW_STATE:{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"},EVENT:{LOAD:"load",CELL_BUTTON_CLICK:"cell-button-click"}},ao=class ao{constructor(n){d(this,Fs);d(this,Ws,-1);E(this,"count",h(()=>t(this,Fs).rawRecords.length,"count"));p(this,Fs,n)}get at(){return t(this,Ws)}set at(n){p(this,Ws,parseInt(n,10))}};Fs=new WeakMap,Ws=new WeakMap,h(ao,"ngRow");let vn=ao;const at=class at{constructor(n,e){d(this,At);d(this,U);d(this,Os,0);d(this,ge,[]);d(this,Qt,h(()=>(t(this,U).rawRecords||[]).filter(e=>{var s;return!((s=e.__ng)!=null&&s.deleted)}),"#getValidRecords"));E(this,"count",h(()=>this.length,"count"));E(this,"getArray",h((n,e)=>{const s=t(this,Qt).call(this);if(n==null)return s;if(n<0||n>=s.length)return null;const i=s[n];if(e!=null){const o=this.getHostFields().indexOf(e);return o>=0?i.v[o]:null}return i},"getArray"));E(this,"setArray",h((n,e,s)=>{const r=t(this,Qt).call(this)[n];r.v[e]!==s&&r.__ng.rowState!==at.ROW_STATE.INSERT&&(r.__ng.rowState=at.ROW_STATE.UPDATE),r.v[e]=s},"setArray"));E(this,"get",h((n,e)=>{const s=t(this,Qt).call(this);if(n==null)return t(this,ds).call(this,s);if(n<0||n>=s.length)return null;const i=s[n],r=this.getHostFields();if(e!=null){const o=r.indexOf(e);return o>=0?i.v[o]:null}return t(this,ds).call(this,i)},"get"));E(this,"getAll",h(()=>t(this,U).rawRecords||[],"getAll"));E(this,"getHostFields",h(()=>{var n;return typeof((n=t(this,At).fields)==null?void 0:n.get)=="function"?t(this,At).fields.get():[]},"getHostFields"));d(this,Ui,h(()=>{p(this,ge,[]);const n=t(this,At).template||[];Array.from(n).forEach(e=>{var s;t(this,ge).push(((s=e.getBoundingClientRect)==null?void 0:s.call(e).height)||24)}),(t(this,U).rawRecords||[]).forEach(e=>{e.__ng||(e.__ng=t(this,zs).call(this)),e.__ng.height=t(this,ge).slice()})},"#initialize"));d(this,pe,h(()=>{var e;const n=t(this,At).shadowRoot.querySelector("nine-table-sheets");n==null||n.classList.toggle("nodata",this.length===0),t(this,At).shadowRoot.querySelectorAll("nine-table-sheet").forEach(s=>{s.invalidate()}),(e=t(this,At).shadowRoot.querySelector("nine-table-sheets-footer"))==null||e.refresh()},"#invalidate"));E(this,"set",h(n=>{const e=h(()=>{this.clear(),this.add(n,!1),t(this,pe).call(this)},"loadData");t(this,At).loaded?e():t(this,At).addEventListener(Dt.EVENT.LOAD,s=>{e()},{once:!0})},"set"));d(this,zs,h((n=0)=>({rowState:at.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:t(this,ge).slice(),o:{},c:{},__:[0,0,0,0,at.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,t(this,ge).slice(),-1,{},{}],_:[n,[]]}),"#getDefaultMeta"));E(this,"reset",h(()=>{t(this,U).rawRecords=[],t(this,pe).call(this)},"reset"));E(this,"clear",h(()=>{var n;t(this,U).rawRecords=[],(n=t(this,U).viewRecords)!=null&&n.reset&&t(this,U).viewRecords.reset(),p(this,Os,0),t(this,pe).call(this)},"clear"));d(this,Gi,h(n=>{Array.isArray(n)||(n=[n]);const e=this.getHostFields().length>0?this.getHostFields():Object.keys(n[0]||{}),s=[];return n.forEach(i=>{const r={v:[]};e.forEach(o=>{r.v.push(i[o]!==void 0&&i[o]!==null?i[o]:"")}),s.push(r)}),s},"#json2Array"));d(this,ji,h(n=>(Array.isArray(n)||(n=[n]),n.forEach(e=>{const s=this.nextId;e.m=t(this,zs).call(this,s),e.__ng=e.m,e.__ng.rowid=s,e.__ng.rowState=at.ROW_STATE.INSERT,e.__ng._[0]=s}),n),"#defaultInsert"));E(this,"add",h((n,e=!0)=>{n===void 0&&(n={});const s=t(this,Gi).call(this,n);t(this,U).rawRecords=t(this,U).rawRecords.concat(t(this,ji).call(this,s));const i=this.count()-1;return e||s.forEach((r,o)=>{const l=t(this,U).rawRecords[t(this,U).rawRecords.length-1-o];l&&(l.__ng.rowState=at.ROW_STATE.EMPTY)}),t(this,pe).call(this),i},"add"));E(this,"delete",h(n=>{let e=[];Array.isArray(n)?e=n:typeof n>"u"?e=[t(this,U).host.row.at]:e=[parseInt(n,10)];const s=t(this,Qt).call(this);e.sort((i,r)=>r-i).forEach(i=>{if(s[i]){const r=s[i].__ng.rowid;s[i].__ng.rowState===at.ROW_STATE.INSERT?t(this,U).rawRecords=t(this,U).rawRecords.filter(o=>o.__ng.rowid!==r):t(this,U).rawRecords.forEach(o=>{o.__ng.rowid===r&&(o.__ng.deleted=!0,o.__ng.rowState=at.ROW_STATE.DELETE)})}}),t(this,pe).call(this)},"delete"));E(this,"setValue",h((n,e,s)=>{n=parseInt(n,10);const r=this.getHostFields().indexOf(e);if(r<0)return;const l=t(this,Qt).call(this)[n];if(!l)return;const a=l.v[r];a!==s&&l.__ng.rowState!==at.ROW_STATE.INSERT&&(l.__ng.o.hasOwnProperty(e)||(l.__ng.o[e]=a),l.__ng.rowState=at.ROW_STATE.UPDATE),l.v[r]=s},"setValue"));d(this,ds,h(n=>{if(!n)return n;const e=!Array.isArray(n),s=e?[n]:n,i=this.getHostFields(),r=s.filter(o=>{var l;return!((l=o.__ng)!=null&&l.deleted)}).map(o=>{const l={};return i.forEach((a,c)=>{l[a]=o.v?o.v[c]:o[a]}),l.__ng=o.__ng,l});return e?r[0]:r},"#conv"));p(this,At,n),p(this,U,e),t(this,Ui).call(this)}get count(){return this.length}get source(){return t(this,ds).call(this,t(this,U).rawRecords)}set source(n){this.set(n)}get nextId(){return Al(this,Os)._++}get length(){return t(this,Qt).call(this).length}get count(){return this.length}getRowCount(){return this.length}};At=new WeakMap,U=new WeakMap,Os=new WeakMap,ge=new WeakMap,Qt=new WeakMap,Ui=new WeakMap,pe=new WeakMap,zs=new WeakMap,Gi=new WeakMap,ji=new WeakMap,ds=new WeakMap,h(at,"ngData"),E(at,"META_INDEX",{FILTER:0}),E(at,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let Sn=at;const co=class co{constructor(n){d(this,Ie);p(this,Ie,n),this.row=new vn(this),this.data=new Sn(t(this,Ie),this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{var e;(e=t(this,Ie).view)!=null&&e.redraw&&t(this,Ie).view.redraw()},this.setDataSource=e=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(e||[])},this.getRowState=e=>{var i,r;const s=parseInt(e,10);if(!(s>=this.data.count()))return(r=(i=this.data.getValidData()[s])==null?void 0:i.__ng)==null?void 0:r.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=e=>{this.row.at=e},this.scrollTo_V1=e=>(e<0&&(e=0),e>=this.rawRecords.length&&(e=this.rawRecords.length-1),this.viewRecords.rawIndex=e,this.viewRecords.reset&&this.viewRecords.reset(),!(e<=0||e>=this.rawRecords.length-1)),this.getColumn=(e,s)=>this.data.get(e,s),this.setColumn=(e,s,i)=>{e=parseInt(e,10),this.data.setValue(e,s,i)},this.setDataSource([])}};Ie=new WeakMap,h(co,"ngDataManager");let An=co;const ho=class ho{constructor(n){d(this,us);d(this,Z,[]);E(this,"add",h((n,e="string")=>{n.forEach(s=>{t(this,Z).some(i=>i.name===s)||t(this,Z).push({name:s,type:e})}),t(this,Bs).call(this)},"add"));d(this,Bs,h(()=>{const n=new Map;t(this,Z).forEach(e=>{n.set(e.name,e.type)}),p(this,Z,Array.from(n,([e,s])=>({name:e,type:s}))),p(this,Z,t(this,Z).filter(e=>e.name!==""&&e.name!=="__ng")),t(this,Z).sort((e,s)=>e.name.length<s.name.length?1:-1)},"#adjust"));d(this,Ki,h(()=>{p(this,Z,[]),v.log(t(this,us).querySelectorAll("table"));const n=Array.from(t(this,us).querySelectorAll("table"));if(!(!n||n.length===0)){for(const e of n)v.log(e),e.querySelectorAll("[data-bind]").forEach(i=>{const r=i.dataset.bind,o=i.getAttribute("data-type")||"string";r&&t(this,Z).push({name:r,type:o})}),["data-expr","background-color","color","tooltip","visible","readonly","enable-button","enable-check","class-expr","icon-color","icon-src"].forEach(i=>{e.querySelectorAll(`[${i}]`).forEach(r=>{let o=r.getAttribute(i);if(o){if(o.indexOf("data.")<0){const l=o.search(/[(]/g);if(l>0)try{o=String(window[o.substring(0,l).trim()])}catch{o=""}}o.split("data.").forEach(l=>{if(l.trim()!=""){const a=l.search(/[^_A-Za-z0-9]/g);let c="";a>=0?c=l.substring(0,a):o.startsWith("data.")&&(c=l.replace("data.","")),c&&t(this,Z).push({name:c,type:"string"})}})}})});t(this,Bs).call(this)}},"#init"));p(this,us,n),t(this,Ki).call(this)}get(){return t(this,Z).map(n=>n.name)}getFields(){return t(this,Z)}getType(n){const e=t(this,Z).find(s=>s.name===n);return e?e.type:"string"}indexOf(n){return t(this,Z).findIndex(e=>e.name===n)}includes(n){return t(this,Z).some(e=>e.name===n)}};us=new WeakMap,Z=new WeakMap,Bs=new WeakMap,Ki=new WeakMap,h(ho,"fields");let En=ho;const uo=class uo extends HTMLElement{constructor(){super();d(this,Yi,h(()=>{},"#init"))}connectedCallback(){t(this,Yi).call(this)}};Yi=new WeakMap,h(uo,"NineTableSheets");let Ln=uo;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",Ln);const fo=class fo extends HTMLElement{constructor(){super();d(this,Ji);d(this,Vt);E(this,"refresh",h(()=>{this.querySelector("#row-count").innerHTML=t(this,Vt).data.count().toLocaleString()},"refresh"));d(this,Zi,h(()=>{var e;p(this,Vt,this.getRootNode().host),A(this,Ji,El).call(this),(e=this.querySelector(".nine-tab-bar"))==null||e.addEventListener("click",s=>{const i=s.ctrlKey||s.metaKey||s.shiftKey,r=s.target.closest("nt-sheets-tab-item");if(!r)return;const o=parseInt(r.dataset.index,10);t(this,Ps).call(this,o,i)}),t(this,Ps).call(this,0,!1)},"#init"));d(this,Ps,h((e,s=!1)=>{const i=h(()=>{const u=Array.from(t(this,Vt).shadowRoot.querySelectorAll("nine-table-sheet"));Array.from(t(this,Vt).shadowRoot.querySelectorAll("nine-splitter")).forEach(b=>b.style.setProperty("display","none"));const f=u.map((b,m)=>({sheet:b,idx:m})).filter(({sheet:b})=>b.classList.contains("active"));if(!(f.length<2))for(let b=0;b<f.length-1;b++){const m=f[b].idx,y=t(this,Vt).shadowRoot.querySelector(`nine-splitter[data-split-index="${m}"]`);y&&y.style.setProperty("display","")}},"updateSplitters"),r=this.querySelector(".nine-tab-bar"),o=t(this,Vt).shadowRoot.querySelector("nine-table-sheets-body"),l=r.querySelectorAll("nt-sheets-tab-item"),a=o.querySelectorAll("nine-table-sheet");if(!l[e])return;if(!s)l.forEach((u,g)=>{u.setActive(g===e)}),a.forEach((u,g)=>{const f=g===e;u.classList.toggle("active",f),u.style.flex=f?"1 1 100%":""});else{const u=l[e],g=r.querySelectorAll("nt-sheets-tab-item.active");if(u.classList.contains("active")&&g.length<=1)return;u.classList.toggle("active");const f=o.querySelector(`nine-table-sheet[data-index="${e}"]`);f&&(f.classList.toggle("active"),f.classList.contains("active")||(f.style.flex=""))}const c=o.querySelectorAll("nine-table-sheet.active");c==null||c.forEach(u=>{var g;u.style.flex=c.length>1?"1 1 0%":"1 1 100%",typeof u.refreshLayout=="function"?u.refreshLayout():(g=u.invalidate)==null||g.call(u)}),i()},"#switchSheet"))}connectedCallback(){t(this,Zi).call(this)}};Vt=new WeakMap,Zi=new WeakMap,Ps=new WeakMap,Ji=new WeakSet,El=h(function(){const i=Array.from(t(this,Vt).children).filter(r=>r.tagName.toUpperCase()==="TABLE").map((r,o)=>{const l=o===0?"active":"",a=r.getAttribute("caption")||`Sheet ${o+1}`;return`<nt-sheets-tab-item class="${l}" data-index="${o}">${a}</nt-sheets-tab-item>`}).join("");this.innerHTML=`
1
+ (function(k,H){typeof exports=="object"&&typeof module<"u"?H(exports,require("@ninebone/util")):typeof define=="function"&&define.amd?define(["exports","@ninebone/util"],H):(k=typeof globalThis<"u"?globalThis:k||self,H(k.NineTable={},k.nine))})(this,function(k,H){"use strict";var vl=Object.defineProperty;var Sl=k=>{throw TypeError(k)};var ia=(k,H,B)=>H in k?vl(k,H,{enumerable:!0,configurable:!0,writable:!0,value:B}):k[H]=B;var h=(k,H)=>vl(k,"name",{value:H,configurable:!0});var E=(k,H,B)=>ia(k,typeof H!="symbol"?H+"":H,B),nl=(k,H,B)=>H.has(k)||Sl("Cannot "+B);var t=(k,H,B)=>(nl(k,H,"read from private field"),B?B.call(k):H.get(k)),d=(k,H,B)=>H.has(k)?Sl("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(k):H.set(k,B),p=(k,H,B,de)=>(nl(k,H,"write to private field"),de?de.call(k,B):H.set(k,B),B),A=(k,H,B)=>(nl(k,H,"access private method"),B);var Al=(k,H,B,de)=>({set _(v){p(k,H,v,B)},get _(){return t(k,H,de)}});var Fs,Ws,At,U,Os,ge,Qt,Ui,pe,zs,Gi,ji,ds,Ie,us,Z,Bs,Ki,Yi,Pt,Zi,Ps,Ji,El,Et,fs,be,Rl,Ll,Cl,Vt,qe,N,Me,He,Ne,Qi,De,tr,er,M,$e,F,Vs,mo,Xs,Fe,sr,ir,Dt,_s,We,Oe,ze,ft,ol,ll,al,cl,rr,Us,R,Be,Gs,te,G,me,ee,gs,ps,Pe,Ve,nr,or,js,Ks,Ys,bs,lr,ar,cr,Zs,hl,J,Js,se,zi,Tl,$,Qs,ye,Xt,So,Ao,pt,cs,dl,ti,ei,si,ii,ri,ms,ni,kl,X,Xe,Lt,_e,_t,Ct,Ut,Gt,ys,jt,xe,oi,li,Tt,yn,ul,ai,ci,fl,hi,hr,di,K,P,et,we,ie,re,$t,ui,Ue,st,Il,ql,xn,Ml,fi,Hl,gi,gl,dr,ve,Ft,ne,bt,oe,Kt,ur,fr,gr,pr,Nl,br,mr,yr,To,Ge,je,pi,kt,Se,Ke,xr,Yt,wr,vr,bi,pl,ct,mi,ht,Wt,Dl,$l,Fl,bl,Ye,yt,Ae,Ho,yi,le,xi,Sr,O,Wl,Ol,zl,Bl,Pl,Vl,Xl,_l,Ul,Gl,jl,Kl,wi,ae,Ot,vi,Si,Ee,xs,Ai,Ar,Ei,ws,Ze,It,Je,Er,Yl,Rr,Lr,Qe,Ri,Cr,Tr,kr,Ir,Li,qr,it,Mr,Ti,Hr,ki,vs,Ii,qi,Re,Mi,Ss,Nr,Dr,Zl,I,Ni,dt,q,ts,es,$r,Fr,qt,Wr,Or,zr,xt,As,Br,Es,Pr,wt,ce,Vr,Rs,Xr,he,Ls,ss,Cs,Ts,_r,Ur,Gr,is,zt,rs,ks,_o,Uo,Go,jo,jr,Di,Kr,Yr,ot,Zr,Jr,Is,Qr,tn,en,sn,rn,nn,on,qs,Bt,Le,ns,os,Ce,Mt,$i,ln,Fi,an,cn,hn,Ms,dn,ls,Wi,un,Hs,Ns,fn,gn,ut,Y,Ds,Q,vt,pn,j,wn,ml,Jl,yl,Ql,ta,ea,Oi,Zt,as,xl,sa;Array.prototype.nineBinarySearch=function(Ht){let n=0,e=this.length-1,s;for(;n<=e;){if(s=parseInt((n+e)/2),Ht===this[s])return s;Ht<this[s]?e=s-1:n=s+1}return-1};const B=new WeakMap;HTMLElement.prototype.addDebounseEventListener=function(Ht,n,e,s,i=500){const r=this;B.has(r)||B.set(r,{timer:null,cancelFn:null});const o=B.get(r);r.addEventListener(e,l=>{l.actualTarget=l.target,o.timer&&(clearTimeout(o.timer),o.timer=null),o.timer=setTimeout(()=>{o.timer=null,o.cancelFn=s.call(r,l)},i)}),r.addEventListener(Ht,l=>{o.timer&&(clearTimeout(o.timer),o.timer=null),o.cancelFn&&(o.cancelFn(),o.cancelFn=null),n.call(r,l)})},nine.measureTextSize=(Ht,n="12px sans-serif")=>{if(typeof Ht=="number"&&(Ht=Ht+""),!Ht)return{width:null,height:null};const e=h(l=>{const a=document.createElement("DIV");return a.innerHTML=l,a.textContent||a.innerText||""},"stripHtml");Ht=Ht.replaceAll(`
2
+ `,"<br>");let s=document.body.querySelector("canvas#_nine_measure_canvas_");s||(s=document.createElement("canvas"),s.id="_nine_measure_canvas_",s.style.cssText="position: absolute; visibility: hidden; pointer-events: none; left: -9999px;",document.body.appendChild(s));const i=s.getContext("2d");i.font=n;let r=0,o=0;for(let l of Ht.split("<br>")){const a=e(l),c=i.measureText(a);r=Math.max(r,c.width);const u=c.fontBoundingBoxAscent||10,f=c.fontBoundingBoxDescent||3;o+=u+f}return{width:r,height:o}};const lo=class lo extends H.trace.constructor{constructor(){super(),this.init("nine-table","green")}};h(lo,"Trace");let de=lo;const v=new de,Nt={META:{INDEX:{ROWID:0,FILTER:1,GROUP:2}},ROW_STATE:{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"},EVENT:{LOAD:"load",CELL_BUTTON_CLICK:"cell-button-click"}},ao=class ao{constructor(n){d(this,Fs);d(this,Ws,-1);E(this,"count",h(()=>t(this,Fs).rawRecords.length,"count"));p(this,Fs,n)}get at(){return t(this,Ws)}set at(n){p(this,Ws,parseInt(n,10))}};Fs=new WeakMap,Ws=new WeakMap,h(ao,"ngRow");let vn=ao;const at=class at{constructor(n,e){d(this,At);d(this,U);d(this,Os,0);d(this,ge,[]);d(this,Qt,h(()=>(t(this,U).rawRecords||[]).filter(e=>{var s;return!((s=e.__ng)!=null&&s.deleted)}),"#getValidRecords"));E(this,"count",h(()=>this.length,"count"));E(this,"getArray",h((n,e)=>{const s=t(this,Qt).call(this);if(n==null)return s;if(n<0||n>=s.length)return null;const i=s[n];if(e!=null){const o=this.getHostFields().indexOf(e);return o>=0?i.v[o]:null}return i},"getArray"));E(this,"setArray",h((n,e,s)=>{const r=t(this,Qt).call(this)[n];r.v[e]!==s&&r.__ng.rowState!==at.ROW_STATE.INSERT&&(r.__ng.rowState=at.ROW_STATE.UPDATE),r.v[e]=s},"setArray"));E(this,"get",h((n,e)=>{const s=t(this,Qt).call(this);if(n==null)return t(this,ds).call(this,s);if(n<0||n>=s.length)return null;const i=s[n],r=this.getHostFields();if(e!=null){const o=r.indexOf(e);return o>=0?i.v[o]:null}return t(this,ds).call(this,i)},"get"));E(this,"getAll",h(()=>t(this,U).rawRecords||[],"getAll"));E(this,"getHostFields",h(()=>{var n;return typeof((n=t(this,At).fields)==null?void 0:n.get)=="function"?t(this,At).fields.get():[]},"getHostFields"));d(this,Ui,h(()=>{p(this,ge,[]);const n=t(this,At).template||[];Array.from(n).forEach(e=>{var s;t(this,ge).push(((s=e.getBoundingClientRect)==null?void 0:s.call(e).height)||24)}),(t(this,U).rawRecords||[]).forEach(e=>{e.__ng||(e.__ng=t(this,zs).call(this)),e.__ng.height=t(this,ge).slice()})},"#initialize"));d(this,pe,h(()=>{var e;const n=t(this,At).shadowRoot.querySelector("nine-table-sheets");n==null||n.classList.toggle("nodata",this.length===0),t(this,At).shadowRoot.querySelectorAll("nine-table-sheet").forEach(s=>{s.invalidate()}),(e=t(this,At).shadowRoot.querySelector("nine-table-sheets-footer"))==null||e.refresh()},"#invalidate"));E(this,"set",h(n=>{const e=h(()=>{this.clear(),this.add(n,!1),t(this,pe).call(this)},"loadData");t(this,At).loaded?e():t(this,At).addEventListener(Nt.EVENT.LOAD,s=>{e()},{once:!0})},"set"));d(this,zs,h((n=0)=>({rowState:at.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:t(this,ge).slice(),o:{},c:{},__:[0,0,0,0,at.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,t(this,ge).slice(),-1,{},{}],_:[n,[]]}),"#getDefaultMeta"));E(this,"reset",h(()=>{t(this,U).rawRecords=[],t(this,pe).call(this)},"reset"));E(this,"clear",h(()=>{var n;t(this,U).rawRecords=[],(n=t(this,U).viewRecords)!=null&&n.reset&&t(this,U).viewRecords.reset(),p(this,Os,0),t(this,pe).call(this)},"clear"));d(this,Gi,h(n=>{Array.isArray(n)||(n=[n]);const e=this.getHostFields().length>0?this.getHostFields():Object.keys(n[0]||{}),s=[];return n.forEach(i=>{const r={v:[]};e.forEach(o=>{r.v.push(i[o]!==void 0&&i[o]!==null?i[o]:"")}),s.push(r)}),s},"#json2Array"));d(this,ji,h(n=>(Array.isArray(n)||(n=[n]),n.forEach(e=>{const s=this.nextId;e.m=t(this,zs).call(this,s),e.__ng=e.m,e.__ng.rowid=s,e.__ng.rowState=at.ROW_STATE.INSERT,e.__ng._[0]=s}),n),"#defaultInsert"));E(this,"add",h((n,e=!0)=>{n===void 0&&(n={});const s=t(this,Gi).call(this,n);t(this,U).rawRecords=t(this,U).rawRecords.concat(t(this,ji).call(this,s));const i=this.count()-1;return e||s.forEach((r,o)=>{const l=t(this,U).rawRecords[t(this,U).rawRecords.length-1-o];l&&(l.__ng.rowState=at.ROW_STATE.EMPTY)}),t(this,pe).call(this),i},"add"));E(this,"delete",h(n=>{let e=[];Array.isArray(n)?e=n:typeof n>"u"?e=[t(this,U).host.row.at]:e=[parseInt(n,10)];const s=t(this,Qt).call(this);e.sort((i,r)=>r-i).forEach(i=>{if(s[i]){const r=s[i].__ng.rowid;s[i].__ng.rowState===at.ROW_STATE.INSERT?t(this,U).rawRecords=t(this,U).rawRecords.filter(o=>o.__ng.rowid!==r):t(this,U).rawRecords.forEach(o=>{o.__ng.rowid===r&&(o.__ng.deleted=!0,o.__ng.rowState=at.ROW_STATE.DELETE)})}}),t(this,pe).call(this)},"delete"));E(this,"setValue",h((n,e,s)=>{n=parseInt(n,10);const r=this.getHostFields().indexOf(e);if(r<0)return;const l=t(this,Qt).call(this)[n];if(!l)return;const a=l.v[r];a!==s&&l.__ng.rowState!==at.ROW_STATE.INSERT&&(l.__ng.o.hasOwnProperty(e)||(l.__ng.o[e]=a),l.__ng.rowState=at.ROW_STATE.UPDATE),l.v[r]=s},"setValue"));d(this,ds,h(n=>{if(!n)return n;const e=!Array.isArray(n),s=e?[n]:n,i=this.getHostFields(),r=s.filter(o=>{var l;return!((l=o.__ng)!=null&&l.deleted)}).map(o=>{const l={};return i.forEach((a,c)=>{l[a]=o.v?o.v[c]:o[a]}),l.__ng=o.__ng,l});return e?r[0]:r},"#conv"));p(this,At,n),p(this,U,e),t(this,Ui).call(this)}get count(){return this.length}get source(){return t(this,ds).call(this,t(this,U).rawRecords)}set source(n){this.set(n)}get nextId(){return Al(this,Os)._++}get length(){return t(this,Qt).call(this).length}get count(){return this.length}getRowCount(){return this.length}};At=new WeakMap,U=new WeakMap,Os=new WeakMap,ge=new WeakMap,Qt=new WeakMap,Ui=new WeakMap,pe=new WeakMap,zs=new WeakMap,Gi=new WeakMap,ji=new WeakMap,ds=new WeakMap,h(at,"ngData"),E(at,"META_INDEX",{FILTER:0}),E(at,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let Sn=at;const co=class co{constructor(n){d(this,Ie);p(this,Ie,n),this.row=new vn(this),this.data=new Sn(t(this,Ie),this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{var e;(e=t(this,Ie).view)!=null&&e.redraw&&t(this,Ie).view.redraw()},this.setDataSource=e=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(e||[])},this.getRowState=e=>{var i,r;const s=parseInt(e,10);if(!(s>=this.data.count()))return(r=(i=this.data.getValidData()[s])==null?void 0:i.__ng)==null?void 0:r.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=e=>{this.row.at=e},this.scrollTo_V1=e=>(e<0&&(e=0),e>=this.rawRecords.length&&(e=this.rawRecords.length-1),this.viewRecords.rawIndex=e,this.viewRecords.reset&&this.viewRecords.reset(),!(e<=0||e>=this.rawRecords.length-1)),this.getColumn=(e,s)=>this.data.get(e,s),this.setColumn=(e,s,i)=>{e=parseInt(e,10),this.data.setValue(e,s,i)},this.setDataSource([])}};Ie=new WeakMap,h(co,"ngDataManager");let An=co;const ho=class ho{constructor(n){d(this,us);d(this,Z,[]);E(this,"add",h((n,e="string")=>{n.forEach(s=>{t(this,Z).some(i=>i.name===s)||t(this,Z).push({name:s,type:e})}),t(this,Bs).call(this)},"add"));d(this,Bs,h(()=>{const n=new Map;t(this,Z).forEach(e=>{n.set(e.name,e.type)}),p(this,Z,Array.from(n,([e,s])=>({name:e,type:s}))),p(this,Z,t(this,Z).filter(e=>e.name!==""&&e.name!=="__ng")),t(this,Z).sort((e,s)=>e.name.length<s.name.length?1:-1)},"#adjust"));d(this,Ki,h(()=>{p(this,Z,[]),v.log(t(this,us).querySelectorAll("table"));const n=Array.from(t(this,us).querySelectorAll("table"));if(!(!n||n.length===0)){for(const e of n)v.log(e),e.querySelectorAll("[data-bind]").forEach(i=>{const r=i.dataset.bind,o=i.getAttribute("data-type")||"string";r&&t(this,Z).push({name:r,type:o})}),["data-expr","background-color","color","tooltip","visible","readonly","enable-button","enable-check","class-expr","icon-color","icon-src"].forEach(i=>{e.querySelectorAll(`[${i}]`).forEach(r=>{let o=r.getAttribute(i);if(o){if(o.indexOf("data.")<0){const l=o.search(/[(]/g);if(l>0)try{o=String(window[o.substring(0,l).trim()])}catch{o=""}}o.split("data.").forEach(l=>{if(l.trim()!=""){const a=l.search(/[^_A-Za-z0-9]/g);let c="";a>=0?c=l.substring(0,a):o.startsWith("data.")&&(c=l.replace("data.","")),c&&t(this,Z).push({name:c,type:"string"})}})}})});t(this,Bs).call(this)}},"#init"));p(this,us,n),t(this,Ki).call(this)}get(){return t(this,Z).map(n=>n.name)}getFields(){return t(this,Z)}getType(n){const e=t(this,Z).find(s=>s.name===n);return e?e.type:"string"}indexOf(n){return t(this,Z).findIndex(e=>e.name===n)}includes(n){return t(this,Z).some(e=>e.name===n)}};us=new WeakMap,Z=new WeakMap,Bs=new WeakMap,Ki=new WeakMap,h(ho,"fields");let En=ho;const uo=class uo extends HTMLElement{constructor(){super();d(this,Yi,h(()=>{},"#init"))}connectedCallback(){t(this,Yi).call(this)}};Yi=new WeakMap,h(uo,"NineTableSheets");let Rn=uo;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",Rn);const fo=class fo extends HTMLElement{constructor(){super();d(this,Ji);d(this,Pt);E(this,"refresh",h(()=>{this.querySelector("#row-count").innerHTML=t(this,Pt).data.count().toLocaleString()},"refresh"));d(this,Zi,h(()=>{var e;p(this,Pt,this.getRootNode().host),A(this,Ji,El).call(this),(e=this.querySelector(".nine-tab-bar"))==null||e.addEventListener("click",s=>{const i=s.ctrlKey||s.metaKey||s.shiftKey,r=s.target.closest("nt-sheets-tab-item");if(!r)return;const o=parseInt(r.dataset.index,10);t(this,Ps).call(this,o,i)}),t(this,Ps).call(this,0,!1)},"#init"));d(this,Ps,h((e,s=!1)=>{const i=h(()=>{const u=Array.from(t(this,Pt).shadowRoot.querySelectorAll("nine-table-sheet"));Array.from(t(this,Pt).shadowRoot.querySelectorAll("nine-splitter")).forEach(b=>b.style.setProperty("display","none"));const g=u.map((b,m)=>({sheet:b,idx:m})).filter(({sheet:b})=>b.classList.contains("active"));if(!(g.length<2))for(let b=0;b<g.length-1;b++){const m=g[b].idx,y=t(this,Pt).shadowRoot.querySelector(`nine-splitter[data-split-index="${m}"]`);y&&y.style.setProperty("display","")}},"updateSplitters"),r=this.querySelector(".nine-tab-bar"),o=t(this,Pt).shadowRoot.querySelector("nine-table-sheets-body"),l=r.querySelectorAll("nt-sheets-tab-item"),a=o.querySelectorAll("nine-table-sheet");if(!l[e])return;if(!s)l.forEach((u,f)=>{u.setActive(f===e)}),a.forEach((u,f)=>{const g=f===e;u.classList.toggle("active",g),u.style.flex=g?"1 1 100%":""});else{const u=l[e],f=r.querySelectorAll("nt-sheets-tab-item.active");if(u.classList.contains("active")&&f.length<=1)return;u.classList.toggle("active");const g=o.querySelector(`nine-table-sheet[data-index="${e}"]`);g&&(g.classList.toggle("active"),g.classList.contains("active")||(g.style.flex=""))}const c=o.querySelectorAll("nine-table-sheet.active");c==null||c.forEach(u=>{var f;u.style.flex=c.length>1?"1 1 0%":"1 1 100%",typeof u.refreshLayout=="function"?u.refreshLayout():(f=u.invalidate)==null||f.call(u)}),i()},"#switchSheet"))}connectedCallback(){t(this,Zi).call(this)}};Pt=new WeakMap,Zi=new WeakMap,Ps=new WeakMap,Ji=new WeakSet,El=h(function(){const i=Array.from(t(this,Pt).children).filter(r=>r.tagName.toUpperCase()==="TABLE").map((r,o)=>{const l=o===0?"active":"",a=r.getAttribute("caption")||`Sheet ${o+1}`;return`<nt-sheets-tab-item class="${l}" data-index="${o}">${a}</nt-sheets-tab-item>`}).join("");this.innerHTML=`
3
3
  <div class="nine-tab-bar">${i}</div>
4
4
  <div class="sheets-counter">Total : <span id="row-count">0</span></div>
5
- `},"#render"),h(fo,"NineTableSheetsFooter");let Rn=fo;const go=class go extends HTMLElement{constructor(){super()}connectedCallback(){}setActive(n){this.classList.toggle("active",n)}};h(go,"SheetTabItem");let Cn=go;customElements.get("nt-sheets-tab-item")||customElements.define("nt-sheets-tab-item",Cn),customElements.get("nine-table-sheets-footer")||customElements.define("nine-table-sheets-footer",Rn);const po=class po extends HTMLElement{constructor(){super(...arguments);d(this,be);d(this,Et);d(this,fs)}connectedCallback(){p(this,Et,this.getRootNode().host),A(this,be,Ll).call(this),A(this,be,Cl).call(this)}addCustomElement(e){t(this,fs)&&t(this,fs).append(e)}updateCaption(e){const s=this.querySelector(".ng-toolbar-title");s&&(s.textContent=e)}};Et=new WeakMap,fs=new WeakMap,be=new WeakSet,Ll=h(function(){this.innerHTML=`
5
+ `},"#render"),h(fo,"NineTableSheetsFooter");let Ln=fo;const go=class go extends HTMLElement{constructor(){super()}connectedCallback(){}setActive(n){this.classList.toggle("active",n)}};h(go,"SheetTabItem");let Cn=go;customElements.get("nt-sheets-tab-item")||customElements.define("nt-sheets-tab-item",Cn),customElements.get("nine-table-sheets-footer")||customElements.define("nine-table-sheets-footer",Ln);const po=class po extends HTMLElement{constructor(){super(...arguments);d(this,be);d(this,Et);d(this,fs)}connectedCallback(){p(this,Et,this.getRootNode().host),A(this,be,Rl).call(this),A(this,be,Cl).call(this)}addCustomElement(e){t(this,fs)&&t(this,fs).append(e)}updateCaption(e){const s=this.querySelector(".ng-toolbar-title");s&&(s.textContent=e)}};Et=new WeakMap,fs=new WeakMap,be=new WeakSet,Rl=h(function(){this.innerHTML=`
6
6
  <div class="ng-toolbar-left">
7
7
  <button type="button" class="ng-toolbar-menu-btn" title="Menu">
8
8
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#374151" stroke-width="2">
@@ -15,7 +15,7 @@
15
15
  </div>
16
16
 
17
17
  <div class="ng-toolbar-custom" id="custom-container"></div>
18
- `,p(this,fs,this.querySelector("#custom-container")),A(this,be,Rl).call(this)},"#render"),Rl=h(function(){const e=t(this,Et).getAttribute("theme")==="simple"||t(this,Et).classList.contains("simple"),s=t(this,Et).getAttribute("show-toolbar")!=="false",i=t(this,Et).getAttribute("show-menu")!=="false",r=t(this,Et).getAttribute("caption")||"";e||!s?this.setAttribute("hidden",""):this.removeAttribute("hidden"),this.setAttribute("show-menu",i?"true":"false"),this.updateCaption(r)},"#syncStateFromHost"),Cl=h(function(){const e=this.querySelector(".ng-toolbar-title");e&&e.addEventListener("dblclick",()=>{const i='<font color="green">https://www.ninegrid.net</font>',r=t(this,Et).getAttribute("caption")||"";e.innerHTML=e.innerHTML===i?r:i});const s=this.querySelector(".ng-toolbar-menu-btn");s&&s.addEventListener("click",()=>{t(this,Et).dispatchEvent(new CustomEvent("toolbar-menu-click",{bubbles:!0,composed:!0,detail:{targetTable:t(this,Et)}}))})},"#bindEvents"),h(po,"Toolbar");let Tn=po;customElements.get("nine-table-toolbar")||customElements.define("nine-table-toolbar",Tn);const bo=class bo extends HTMLElement{constructor(){super();d(this,Lt);d(this,qe,!1);d(this,N);d(this,Me);d(this,He);d(this,Ne);d(this,Qi,h(()=>{if(!t(this,Lt))return;const e=t(this,Lt).querySelector(".ng-sheet-body .ng-container-body");e&&(p(this,Ne,new ResizeObserver(()=>{this.refresh()})),t(this,Ne).observe(e))},"#observeResize"));E(this,"refresh",h(()=>{if(!t(this,Lt)||!t(this,N)||t(this,qe))return;const e=t(this,N).container,s=e.querySelector("table");if(!s)return;const i=t(this,N).track,r=t(this,N).thumb,o=e.clientWidth,l=s.scrollWidth,a=o!==0&&l>o;if(t(this,Lt).classList.toggle("hscroll-visible",a),!a)return;const c=i.clientWidth;if(c<=0)return;const u=Math.max(Math.min(c*(o/l),c),20);r.style.width=`${u}px`;const g=e.scrollLeft,f=l-o;let b=0;f>0&&(b=parseInt(g/f*(c-u),10)),b<0&&(b=0);const m=c-u;b>m&&(b=m),r.style.left=`${b}px`,t(this,N).left.disabled=b===0,t(this,N).right.disabled=b>=m-1},"refresh"));d(this,De,h(e=>{if(!t(this,N))return!1;const s=t(this,N).container,i=s.querySelector("table");if(!i)return!1;const r=t(this,N).track.getBoundingClientRect(),o=t(this,N).thumb.clientWidth;let l=e;l<0&&(l=0);const a=r.width-o;l>a&&(l=a),l=parseInt(l,10),t(this,N).thumb.style.left=`${l}px`,t(this,N).left.disabled=l===0,t(this,N).right.disabled=l>=a-1;const c=s.clientWidth,g=i.scrollWidth-c;if(a>0&&g>0){const f=l/a*g;s.scrollLeft=f;const b=t(this,Lt).querySelector(".ng-sheet-header .ng-container-body"),m=t(this,Lt).querySelector(".ng-sheet-footer .ng-container-body");b&&(b.scrollLeft=f),m&&(m.scrollLeft=f)}return l>0&&l<a-1},"#thumbMoveTo"));d(this,tr,h(()=>{const e=h(i=>{clearInterval(t(this,Me)),clearInterval(t(this,He));const r=parseInt(t(this,N).thumb.style.left||0,10);t(this,De).call(this,r+i),p(this,Me,setInterval(()=>{clearInterval(t(this,Me)),p(this,He,setInterval(()=>{const o=parseInt(t(this,N).thumb.style.left||0,10);t(this,De).call(this,o+i)||clearInterval(t(this,He))},50))},500))},"delayScroll"),s=h(()=>{clearInterval(t(this,Me)),clearInterval(t(this,He))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(i=>{t(this,N).left.addEventListener(i,s),t(this,N).right.addEventListener(i,s),t(this,N).track.addEventListener(i,s)}),t(this,N).left.addEventListener("mousedown",i=>{i.button===0&&e(-20)}),t(this,N).right.addEventListener("mousedown",i=>{i.button===0&&e(20)}),t(this,N).left.addEventListener("touchstart",()=>e(-20)),t(this,N).right.addEventListener("touchstart",()=>e(20)),t(this,N).track.addEventListener("mousedown",i=>{if(i.button!==0)return;i.preventDefault();const r=t(this,N).track.getBoundingClientRect(),o=t(this,N).thumb.clientWidth;t(this,De).call(this,i.clientX-r.left-o/2)}),t(this,N).thumb.addEventListener("mousedown",i=>{if(i.button!==0)return;i.stopPropagation(),i.preventDefault(),p(this,qe,!0),this.shiftX=i.clientX-t(this,N).thumb.getBoundingClientRect().left;const r=h(l=>{if(!t(this,qe))return;const a=t(this,N).track.getBoundingClientRect();t(this,De).call(this,l.clientX-a.left-this.shiftX)},"onMouseMove"),o=h(()=>{p(this,qe,!1),s(),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",o),this.refresh()},"onMouseUp");document.addEventListener("mousemove",r),document.addEventListener("mouseup",o)})},"#init"))}connectedCallback(){if(p(this,Lt,this.closest("nine-table-sheet")||this.getRootNode().host),!t(this,Lt))return;this.innerHTML=`
18
+ `,p(this,fs,this.querySelector("#custom-container")),A(this,be,Ll).call(this)},"#render"),Ll=h(function(){const e=t(this,Et).getAttribute("theme")==="simple"||t(this,Et).classList.contains("simple"),s=t(this,Et).getAttribute("show-toolbar")!=="false",i=t(this,Et).getAttribute("show-menu")!=="false",r=t(this,Et).getAttribute("caption")||"";e||!s?this.setAttribute("hidden",""):this.removeAttribute("hidden"),this.setAttribute("show-menu",i?"true":"false"),this.updateCaption(r)},"#syncStateFromHost"),Cl=h(function(){const e=this.querySelector(".ng-toolbar-title");e&&e.addEventListener("dblclick",()=>{const i='<font color="green">https://www.ninegrid.net</font>',r=t(this,Et).getAttribute("caption")||"";e.innerHTML=e.innerHTML===i?r:i});const s=this.querySelector(".ng-toolbar-menu-btn");s&&s.addEventListener("click",()=>{t(this,Et).dispatchEvent(new CustomEvent("toolbar-menu-click",{bubbles:!0,composed:!0,detail:{targetTable:t(this,Et)}}))})},"#bindEvents"),h(po,"Toolbar");let Tn=po;customElements.get("nine-table-toolbar")||customElements.define("nine-table-toolbar",Tn);const bo=class bo extends HTMLElement{constructor(){super();d(this,Vt);d(this,qe,!1);d(this,N);d(this,Me);d(this,He);d(this,Ne);d(this,Qi,h(()=>{if(!t(this,Vt))return;const e=t(this,Vt).querySelector(".ng-sheet-body .ng-container-body");e&&(p(this,Ne,new ResizeObserver(()=>{this.refresh()})),t(this,Ne).observe(e))},"#observeResize"));E(this,"refresh",h(()=>{if(!t(this,Vt)||!t(this,N)||t(this,qe))return;const e=t(this,N).container,s=e.querySelector("table");if(!s)return;const i=t(this,N).track,r=t(this,N).thumb,o=e.clientWidth,l=s.scrollWidth,a=o!==0&&l>o;if(t(this,Vt).classList.toggle("hscroll-visible",a),!a)return;const c=i.clientWidth;if(c<=0)return;const u=Math.max(Math.min(c*(o/l),c),20);r.style.width=`${u}px`;const f=e.scrollLeft,g=l-o;let b=0;g>0&&(b=parseInt(f/g*(c-u),10)),b<0&&(b=0);const m=c-u;b>m&&(b=m),r.style.left=`${b}px`,t(this,N).left.disabled=b===0,t(this,N).right.disabled=b>=m-1},"refresh"));d(this,De,h(e=>{if(!t(this,N))return!1;const s=t(this,N).container,i=s.querySelector("table");if(!i)return!1;const r=t(this,N).track.getBoundingClientRect(),o=t(this,N).thumb.clientWidth;let l=e;l<0&&(l=0);const a=r.width-o;l>a&&(l=a),l=parseInt(l,10),t(this,N).thumb.style.left=`${l}px`,t(this,N).left.disabled=l===0,t(this,N).right.disabled=l>=a-1;const c=s.clientWidth,f=i.scrollWidth-c;if(a>0&&f>0){const g=l/a*f;s.scrollLeft=g}return l>0&&l<a-1},"#thumbMoveTo"));d(this,tr,h(()=>{const e=h(i=>{clearInterval(t(this,Me)),clearInterval(t(this,He));const r=parseInt(t(this,N).thumb.style.left||0,10);t(this,De).call(this,r+i),p(this,Me,setInterval(()=>{clearInterval(t(this,Me)),p(this,He,setInterval(()=>{const o=parseInt(t(this,N).thumb.style.left||0,10);t(this,De).call(this,o+i)||clearInterval(t(this,He))},50))},500))},"delayScroll"),s=h(()=>{clearInterval(t(this,Me)),clearInterval(t(this,He))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(i=>{t(this,N).left.addEventListener(i,s),t(this,N).right.addEventListener(i,s),t(this,N).track.addEventListener(i,s)}),t(this,N).left.addEventListener("mousedown",i=>{i.button===0&&e(-20)}),t(this,N).right.addEventListener("mousedown",i=>{i.button===0&&e(20)}),t(this,N).left.addEventListener("touchstart",()=>e(-20)),t(this,N).right.addEventListener("touchstart",()=>e(20)),t(this,N).track.addEventListener("mousedown",i=>{if(i.button!==0)return;i.preventDefault();const r=t(this,N).track.getBoundingClientRect(),o=t(this,N).thumb.clientWidth;t(this,De).call(this,i.clientX-r.left-o/2)}),t(this,N).thumb.addEventListener("mousedown",i=>{if(i.button!==0)return;i.stopPropagation(),i.preventDefault(),p(this,qe,!0),this.shiftX=i.clientX-t(this,N).thumb.getBoundingClientRect().left;const r=h(l=>{if(!t(this,qe))return;const a=t(this,N).track.getBoundingClientRect();t(this,De).call(this,l.clientX-a.left-this.shiftX)},"onMouseMove"),o=h(()=>{p(this,qe,!1),s(),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",o),this.refresh()},"onMouseUp");document.addEventListener("mousemove",r),document.addEventListener("mouseup",o)})},"#init"))}connectedCallback(){if(p(this,Vt,this.closest("nine-table-sheet")||this.getRootNode().host),!t(this,Vt))return;this.innerHTML=`
19
19
  <style>
20
20
  nine-table-hscrollbar {
21
21
  display: flex;
@@ -77,7 +77,7 @@
77
77
  <button class='ng-scroll-left' disabled><div class='ng-scroll-icon'></div></button>
78
78
  <div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
79
79
  <button class='ng-scroll-right' disabled><div class='ng-scroll-icon'></div></button>
80
- `;const e=h(()=>{const s=t(this,Lt).querySelector(".ng-sheet-body .ng-container-body");if(!s){setTimeout(e,10);return}p(this,N,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),left:this.querySelector(".ng-scroll-left"),right:this.querySelector(".ng-scroll-right")}),t(this,tr).call(this),t(this,Qi).call(this),this.refresh()},"initWhenReady");e()}disconnectedCallback(){t(this,Ne)&&t(this,Ne).disconnect()}};Lt=new WeakMap,qe=new WeakMap,N=new WeakMap,Me=new WeakMap,He=new WeakMap,Ne=new WeakMap,Qi=new WeakMap,De=new WeakMap,tr=new WeakMap,h(bo,"NineTableHScrollBar");let kn=bo;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",kn);const yo=class yo extends HTMLElement{constructor(){super();d(this,er);d(this,M);d(this,$e,!1);d(this,F);d(this,Vs,0);d(this,mo,0);d(this,Xs,0);d(this,Fe,h(()=>{var u,g;const e=t(this,M).view.getArray(),s=e?e.length:0,i=(u=t(this,M).elements)==null?void 0:u.scrollHolder;let r=i&&parseFloat(i.style.height)||0;if(!r||r<=0)if(!!((g=t(this,M).sourceTable)!=null&&g.querySelector("tbody tr[grouping='true']"))&&t(this,M).rowManager)r=body.scrollHeight>body.clientHeight?body.scrollHeight:s*30;else{const b=t(this,M).getRowHeight()||1;r=s*b}const o=15e6,l=r>o;let a=1,c=r;return l&&(a=o/r,c=o),{rawContentHeight:r,contentHeight:c,scaleFactor:a,useScaling:l,totalCount:s}},"#getScaleInfo"));d(this,sr,h(()=>{var l,a,c,u,g,f,b,m,y,x;const e=t(this,F).container;if(!e)return 0;const s=((c=(a=(l=t(this,M).elements)==null?void 0:l.body)==null?void 0:a.thead)==null?void 0:c.offsetHeight)||0,i=((f=(g=(u=t(this,M).elements)==null?void 0:u.body)==null?void 0:g.tfoot)==null?void 0:f.offsetHeight)||0,r=((x=(y=(m=(b=t(this,M).elements)==null?void 0:b.body)==null?void 0:m.tbody)==null?void 0:y.head)==null?void 0:x.offsetHeight)||0,o=s+i+r;return e.clientHeight-o},"#getViewHeight"));E(this,"refresh",h(()=>{if(v.log("=================","vscrollbar.refresh"),t(this,$e)||!t(this,M)||!t(this,M).elements||!t(this,F))return;const e=t(this,F).container,s=t(this,F).track,i=t(this,F).thumb,r=t(this,sr).call(this),{rawContentHeight:o,contentHeight:l}=t(this,Fe).call(this),a=o>r&&o>0&&r>0;if(t(this,M).classList.toggle("vscroll-visible",a),!a)return;const c=s.clientHeight;if(c<=0)return;const u=Math.max(Math.min(c*(r/l),c),20);i.style.height=`${u}px`;const g=e.scrollTop,f=Math.max(l-t(this,M).rowManager.getRowHeight(),1);let b=0;f>0&&(b=g/f*(c-u));const m=c-u;b<0&&(b=0),b>m&&(b=m),i.style.top=`${b}px`,t(this,F).top.disabled=g<=0,t(this,F).bottom.disabled=g>=f-1},"refresh"));d(this,ir,h(()=>{v.log("nine-table-vscrollbar.#init");const e=t(this,F).container;t(this,F).thumb.addEventListener("mousedown",s=>{if(s.button!==0)return;s.stopPropagation(),s.preventDefault(),p(this,$e,!0),p(this,Vs,s.clientY),p(this,Xs,parseFloat(t(this,F).thumb.style.top)||0);const r=t(this,F).track.getBoundingClientRect().height,o=t(this,F).thumb.clientHeight,l=r-o,a=h(u=>{var D,_;if(!t(this,$e)||l<=0)return;const g=u.clientY-t(this,Vs);let f=t(this,Xs)+g;f<0&&(f=0),f>l&&(f=l),t(this,F).thumb.style.top=`${f}px`;const b=f/l,m=t(this,M).getRowHeight(),y=(t(this,M).querySelector(".ng-sheet-body").offsetHeight||0)-(((D=t(this,M).elements.body.thead)==null?void 0:D.offsetHeight)||0)-(((_=t(this,M).elements.body.tfoot)==null?void 0:_.offsetHeight)||0)-(t(this,M).elements.body.tbody.head.offsetHeight||0),x=Math.floor(y/m),{totalCount:w}=t(this,Fe).call(this),S=Math.floor(b*(w-x+1));t(this,M).rowManager.scrollToDataRow(S);const{rawContentHeight:R,contentHeight:C}=t(this,Fe).call(this),W=t(this,F).container.scrollTop,T=Math.max(C-t(this,M).rowManager.getRowHeight(),0);t(this,F).top.disabled=W<=0,t(this,F).bottom.disabled=W>=T-1},"onMouseMove"),c=h(()=>{p(this,$e,!1),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",c)},"onMouseUp");document.addEventListener("mousemove",a),document.addEventListener("mouseup",c)}),t(this,F).track.addEventListener("mousedown",s=>{if(s.button!==0||s.target===t(this,F).thumb)return;const i=t(this,F).track.getBoundingClientRect(),r=t(this,F).thumb.clientHeight,l=t(this,F).track.clientHeight-r;if(l>0){const a=s.clientY-i.top-r/2,c=Math.max(0,Math.min(1,a/l)),{totalCount:u}=t(this,Fe).call(this),g=Math.max(0,Math.min(Math.floor(c*(u-1)),u-1));v.log("🎯 [VScroll Track Click]",{ratio:c,clickY:a,totalCount:u,targetRow:g}),g>=0&&t(this,M).rowManager&&typeof t(this,M).rowManager.scrollToDataRow=="function"&&t(this,M).rowManager.scrollToDataRow(g,"top")}this.refresh()}),t(this,F).top.addEventListener("click",()=>{const s=Math.floor(e.scrollTop/t(this,M).getRowHeight()),i=Math.max(0,s-1);t(this,M).rowManager&&typeof t(this,M).rowManager.scrollToDataRow=="function"&&t(this,M).rowManager.scrollToDataRow(i,"top")}),t(this,F).bottom.addEventListener("click",()=>{const i=Math.floor(e.scrollTop/t(this,M).getRowHeight())+1;t(this,M).rowManager&&typeof t(this,M).rowManager.scrollToDataRow=="function"&&t(this,M).rowManager.scrollToDataRow(i,"top")})},"#init"))}connectedCallback(){p(this,er,this.getRootNode().host),p(this,M,this.closest("nine-table-sheet")),this.innerHTML=`
80
+ `;const e=h(()=>{const s=t(this,Vt).querySelector(".ng-sheet-body .ng-container-body");if(!s){setTimeout(e,10);return}p(this,N,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),left:this.querySelector(".ng-scroll-left"),right:this.querySelector(".ng-scroll-right")}),t(this,tr).call(this),t(this,Qi).call(this),this.refresh()},"initWhenReady");e()}disconnectedCallback(){t(this,Ne)&&t(this,Ne).disconnect()}};Vt=new WeakMap,qe=new WeakMap,N=new WeakMap,Me=new WeakMap,He=new WeakMap,Ne=new WeakMap,Qi=new WeakMap,De=new WeakMap,tr=new WeakMap,h(bo,"NineTableHScrollBar");let kn=bo;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",kn);const yo=class yo extends HTMLElement{constructor(){super();d(this,er);d(this,M);d(this,$e,!1);d(this,F);d(this,Vs,0);d(this,mo,0);d(this,Xs,0);d(this,Fe,h(()=>{var u,f;const e=t(this,M).view.getArray(),s=e?e.length:0,i=(u=t(this,M).elements)==null?void 0:u.scrollHolder;let r=i&&parseFloat(i.style.height)||0;if(!r||r<=0)if(!!((f=t(this,M).sourceTable)!=null&&f.querySelector("tbody tr[grouping='true']"))&&t(this,M).rowManager)r=body.scrollHeight>body.clientHeight?body.scrollHeight:s*30;else{const b=t(this,M).getRowHeight()||1;r=s*b}const o=15e6,l=r>o;let a=1,c=r;return l&&(a=o/r,c=o),{rawContentHeight:r,contentHeight:c,scaleFactor:a,useScaling:l,totalCount:s}},"#getScaleInfo"));d(this,sr,h(()=>{var l,a,c,u,f,g,b,m,y,x;const e=t(this,F).container;if(!e)return 0;const s=((c=(a=(l=t(this,M).elements)==null?void 0:l.body)==null?void 0:a.thead)==null?void 0:c.offsetHeight)||0,i=((g=(f=(u=t(this,M).elements)==null?void 0:u.body)==null?void 0:f.tfoot)==null?void 0:g.offsetHeight)||0,r=((x=(y=(m=(b=t(this,M).elements)==null?void 0:b.body)==null?void 0:m.tbody)==null?void 0:y.head)==null?void 0:x.offsetHeight)||0,o=s+i+r;return e.clientHeight-o},"#getViewHeight"));E(this,"refresh",h(()=>{if(v.log("=================","vscrollbar.refresh"),t(this,$e)||!t(this,M)||!t(this,M).elements||!t(this,F))return;const e=t(this,F).container,s=t(this,F).track,i=t(this,F).thumb,r=t(this,sr).call(this),{rawContentHeight:o,contentHeight:l}=t(this,Fe).call(this),a=o>r&&o>0&&r>0;if(t(this,M).classList.toggle("vscroll-visible",a),!a)return;const c=s.clientHeight;if(c<=0)return;const u=Math.max(Math.min(c*(r/l),c),20);i.style.height=`${u}px`;const f=e.scrollTop,g=Math.max(l-t(this,M).rowManager.getRowHeight(),1);let b=0;g>0&&(b=f/g*(c-u));const m=c-u;b<0&&(b=0),b>m&&(b=m),i.style.top=`${b}px`,t(this,F).top.disabled=f<=0,t(this,F).bottom.disabled=f>=g-1},"refresh"));d(this,ir,h(()=>{v.log("nine-table-vscrollbar.#init");const e=t(this,F).container;t(this,F).thumb.addEventListener("mousedown",s=>{if(s.button!==0)return;s.stopPropagation(),s.preventDefault(),p(this,$e,!0),p(this,Vs,s.clientY),p(this,Xs,parseFloat(t(this,F).thumb.style.top)||0);const r=t(this,F).track.getBoundingClientRect().height,o=t(this,F).thumb.clientHeight,l=r-o,a=h(u=>{var D,_;if(!t(this,$e)||l<=0)return;const f=u.clientY-t(this,Vs);let g=t(this,Xs)+f;g<0&&(g=0),g>l&&(g=l),t(this,F).thumb.style.top=`${g}px`;const b=g/l,m=t(this,M).getRowHeight(),y=(t(this,M).querySelector(".ng-sheet-body").offsetHeight||0)-(((D=t(this,M).elements.body.thead)==null?void 0:D.offsetHeight)||0)-(((_=t(this,M).elements.body.tfoot)==null?void 0:_.offsetHeight)||0)-(t(this,M).elements.body.tbody.head.offsetHeight||0),x=Math.floor(y/m),{totalCount:w}=t(this,Fe).call(this),S=Math.floor(b*(w-x+1));t(this,M).rowManager.scrollToDataRow(S);const{rawContentHeight:L,contentHeight:C}=t(this,Fe).call(this),W=t(this,F).container.scrollTop,T=Math.max(C-t(this,M).rowManager.getRowHeight(),0);t(this,F).top.disabled=W<=0,t(this,F).bottom.disabled=W>=T-1},"onMouseMove"),c=h(()=>{p(this,$e,!1),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",c)},"onMouseUp");document.addEventListener("mousemove",a),document.addEventListener("mouseup",c)}),t(this,F).track.addEventListener("mousedown",s=>{if(s.button!==0||s.target===t(this,F).thumb)return;const i=t(this,F).track.getBoundingClientRect(),r=t(this,F).thumb.clientHeight,l=t(this,F).track.clientHeight-r;if(l>0){const a=s.clientY-i.top-r/2,c=Math.max(0,Math.min(1,a/l)),{totalCount:u}=t(this,Fe).call(this),f=Math.max(0,Math.min(Math.floor(c*(u-1)),u-1));v.log("🎯 [VScroll Track Click]",{ratio:c,clickY:a,totalCount:u,targetRow:f}),f>=0&&t(this,M).rowManager&&typeof t(this,M).rowManager.scrollToDataRow=="function"&&t(this,M).rowManager.scrollToDataRow(f,"top")}this.refresh()}),t(this,F).top.addEventListener("click",()=>{const s=Math.floor(e.scrollTop/t(this,M).getRowHeight()),i=Math.max(0,s-1);t(this,M).rowManager&&typeof t(this,M).rowManager.scrollToDataRow=="function"&&t(this,M).rowManager.scrollToDataRow(i,"top")}),t(this,F).bottom.addEventListener("click",()=>{const i=Math.floor(e.scrollTop/t(this,M).getRowHeight())+1;t(this,M).rowManager&&typeof t(this,M).rowManager.scrollToDataRow=="function"&&t(this,M).rowManager.scrollToDataRow(i,"top")})},"#init"))}connectedCallback(){p(this,er,this.getRootNode().host),p(this,M,this.closest("nine-table-sheet")),this.innerHTML=`
81
81
  <style>
82
82
  nine-table-vscrollbar {
83
83
  display: flex;
@@ -140,13 +140,12 @@
140
140
  <button class='ng-scroll-top' disabled><div class='ng-scroll-icon'></div></button>
141
141
  <div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
142
142
  <button class='ng-scroll-bottom' disabled><div class='ng-scroll-icon'></div></button>
143
- `;const e=h(()=>{const s=t(this,M).querySelector(".ng-sheet-body");if(!s){setTimeout(e,10);return}p(this,F,{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,ir).call(this),this.refresh()},"initWhenReady");e()}};er=new WeakMap,M=new WeakMap,$e=new WeakMap,F=new WeakMap,Vs=new WeakMap,mo=new WeakMap,Xs=new WeakMap,Fe=new WeakMap,sr=new WeakMap,ir=new WeakMap,h(yo,"NineTableVScrollBar");let In=yo;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",In);const ue={ID:0,DEPTH:1,NAME:2,CHILDREN:3},xo=class xo{constructor(n){d(this,$t);d(this,_s);d(this,We,[]);d(this,Oe,new Map);d(this,ze,!1);E(this,"initialize",h(()=>{let n=[];const e=t(this,$t).sourceTable;e&&e.querySelectorAll('tbody tr[grouping="true"]').forEach(s=>{const i=s.querySelector('[cell-type="tree"]');i&&i.dataset.bind&&n.push(i.dataset.bind)}),p(this,We,n)},"initialize"));p(this,$t,n),p(this,_s,t(this,$t).getRootNode().host)}get columns(){return t(this,We)}get groupMap(){return t(this,Oe)}apply(){if(v.log("==================","Grouping.Apply"),t(this,ze))return;p(this,ze,!0);let n=[];const e=t(this,$t).sourceTable;e&&e.querySelectorAll('tbody tr[grouping="true"]').forEach(s=>{const i=s.querySelector('[cell-type="tree"]');i&&i.dataset.bind&&n.push(i.dataset.bind)}),p(this,We,n),p(this,ze,!1),t(this,$t).scrollToY(0),t(this,$t).view.refresh()}clear(){p(this,We,[]),t(this,Oe).clear(),p(this,ze,!1),t(this,$t).scrollToY(0),t(this,$t).view.refresh()}setGroupMap(n){p(this,Oe,n)}getChildrenRowIds(n){return t(this,Oe).get(n)||[]}getChildrenRecords(n){const e=this.getChildrenRowIds(n),s=t(this,_s).data;return e.map(i=>s.getArray(i)).filter(Boolean)}};$t=new WeakMap,_s=new WeakMap,We=new WeakMap,Oe=new WeakMap,ze=new WeakMap,h(xo,"GroupingManager");let qn=xo;const Rt=class Rt{static apply(n,e=[],s=[]){var c,u;if(!e||e.length===0)return{headers:[],renderItems:[],groupMap:new Map};const i=n.filter(g=>{var f;return!((f=g.__ng)!=null&&f.deleted)}),r=new Map,o=A(c=Rt,ft,ll).call(c,i,e,s),l=[],a=[];return A(u=Rt,ft,ol).call(u,o,0,e,l,a,r,""),{headers:l,renderItems:a,groupMap:r}}};ft=new WeakSet,ol=h(function(n,e,s,i,r,o,l){var u,g,f;let a=0;const c=e===s.length-1;for(let[b,m]of n.entries()){const y=l?`${l}_${a++}`:`g_${a++}`,x=A(u=Rt,ft,al).call(u,m);o.set(y,x);const w=[];w[ue.ID]=y,w[ue.DEPTH]=e,w[ue.NAME]=b,w[ue.CHILDREN]=x,w.__isGroupHeader=!0,w.__groupId=y,i.push(w),r.push({type:"group",record:w,groupId:y}),!c&&m instanceof Map?A(g=Rt,ft,ol).call(g,m,e+1,s,i,r,o,y):A(f=Rt,ft,cl).call(f,m).forEach(R=>{R.__isGroupHeader=!1,R.__groupId=y,i.push(R),r.push({type:"data",record:R,groupId:y})})}},"#flattenTree"),ll=h(function(n,e,s){var l;const i=s.indexOf(e[0]),r=e.slice(1),o=new Map;if(n.forEach(a=>{const c=i>=0?a.v[i]:"(Unknown)";o.has(c)||o.set(c,[]),o.get(c).push(a)}),r.length>0){const a=new Map;for(let[c,u]of o.entries())a.set(c,A(l=Rt,ft,ll).call(l,u,r,s));return a}return o},"#buildNestedMap"),al=h(function(n){var s;let e=[];if(n instanceof Map)for(let i of n.values())e=e.concat(A(s=Rt,ft,al).call(s,i));else Array.isArray(n)&&(e=e.concat(n.map(i=>{var r,o,l;return((r=i.__ng)==null?void 0:r.rowid)??((l=(o=i.m)==null?void 0:o._)==null?void 0:l[0])})));return e},"#collectLeafRowIds"),cl=h(function(n){var s;let e=[];if(n instanceof Map)for(let i of n.values())e=e.concat(A(s=Rt,ft,cl).call(s,i));else Array.isArray(n)&&(e=e.concat(n));return e},"#collectLeafRecords"),d(Rt,ft),h(Rt,"Grouping");let Mn=Rt;const wo=class wo{constructor(n){d(this,rr,3);d(this,Us);d(this,L);d(this,Be);d(this,Gs,new Map);d(this,te,[]);d(this,G,null);d(this,me,null);d(this,ee,0);d(this,gs);d(this,ps,!1);d(this,Pe,!1);E(this,"refresh",h((n=!1)=>{var i;if(!t(this,L).classList.contains("active"))return;const e=t(this,L).querySelector(".ng-sheet-body");if(!e)return;(!t(this,G)||t(this,G)<=0)&&(t(this,Ks).call(this),t(this,G)&&t(this,G)>0&&t(this,bs).call(this)),t(this,Ve).call(this,e.scrollTop,n),(i=t(this,L).querySelector("nine-table-vscrollbar"))==null||i.refresh()},"refresh"));d(this,Ve,h((n,e=!1)=>{var W,T;if(t(this,Pe)){t(this,nr).call(this,n,e);return}const s=t(this,G);if(!s||s<=0)return;const i=t(this,L).view.getArray(),r=i.length;if(r===0){t(this,L).elements.scrollHolder.style.height="0px";return}const o=t(this,L).templateLength,l=(((W=t(this,L).elements.body.thead)==null?void 0:W.offsetHeight)||0)+(((T=t(this,L).elements.body.tfoot)==null?void 0:T.offsetHeight)||0)+t(this,L).elements.body.tbody.head.offsetHeight,a=t(this,L).querySelector(".ng-sheet-body").offsetHeight||0,c=Math.max(r*s+s*2+l-a,0),u=15e6,g=c>u;let f=1,b=c;g&&(f=u/c,b=u),t(this,L).elements.scrollHolder.style.height=`${b}px`;const m=g?n/f:n,y=Math.max(0,r-1),x=Math.min(m,c),w=Math.max(0,Math.min(Math.floor(x/s)-1,y)),S=x%s;t(this,L).elements.left.tbody.body.style.top=t(this,L).elements.body.tbody.body.style.top=t(this,L).elements.right.tbody.body.style.top=`-${S}px`;const R=t(this,Be).firstTr,C=R&&R.dataset.row!==void 0?parseInt(R.dataset.row,10):-1;!e&&C===w||([t(this,L).elements.left.tbody.body,t(this,L).elements.body.tbody.body,t(this,L).elements.right.tbody.body].forEach((D,_)=>{if(!D)return;D.querySelectorAll("tbody.body tr").forEach((lt,z)=>{const tt=w+Math.floor(z/o);if(tt>=r){lt.style.display="none",lt.dataset.matrixRow=null,lt.dataset.row=null;return}const St=i[tt];if(!St){lt.style.display="none";return}const V=St.m._[Dt.META.INDEX.ROWID];lt.style.display="",t(this,js).call(this,lt,St,V,tt)})}),t(this,L).selection.refresh())},"#handleScroll"));d(this,nr,h((n,e=!1)=>{var W;v.log("handleGroupdScroll() start");const s=t(this,L).view.getArray()||[],i=s.length;if(i===0){t(this,L).elements.scrollHolder.style.height="0px";return}const r=t(this,L).querySelector(".ng-sheet-body .ng-sheet-body-content"),o=t(this,L).templateLength||1,l=h(T=>{if(T.type==="group"){const D=T.record[ue.DEPTH]||0;return t(this,te)[D]||t(this,G)/o}else{let D=0;const _=t(this,L).templateLength||1;let rt=0;for(let lt=0;lt<_-1;lt++)rt+=t(this,te)[lt]||0;return D=t(this,G)-rt,D>0?D:t(this,G)}},"getItemHeight");let a=0;const c=new Array(i);for(let T=0;T<i;T++){const D=l(s[T]);c[T]=D,a+=D}t(this,L).elements.scrollHolder.style.height=`${a}px`,v.log("*************",a);const u=t(this,L).clientHeight;let g=0,f=0;for(let T=0;T<i;T++){const D=c[T];if(g+D>n){f=T;break}g+=D,f=T}const b=n-g;r&&r.querySelectorAll("tbody").forEach(T=>{T.style.top=`-${Math.max(0,b)}px`});const m=t(this,Be).firstTr,y=m&&m.dataset.virtualIndex!==void 0?parseInt(m.dataset.virtualIndex,10):-1;if(!e&&y===f)return;const x=Math.ceil(u/(t(this,G)/o)),w=(((W=t(this,L).grouping.columns)==null?void 0:W.length)||1)*15,S=f,R=Math.min(i,f+x+w),C=s.slice(S,R);[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(T=>{const D=t(this,L).querySelector(`.ng-sheet-body ${T}`);if(!D)return;const _=Array.from(D.querySelectorAll("tbody.body tr"));for(let rt=0;rt<_.length;rt+=o){const lt=Math.floor(rt/o),z=C[lt],tt=_.slice(rt,rt+o);if(!z||lt>=C.length){tt.forEach(V=>{V.dataset.matrixRow=null,V.dataset.row=null,V.style.display="none"});continue}const St=f+lt;tt.forEach((V,$s)=>{var mn;const bn=f+lt;V.dataset.virtualIndex=bn,V.dataset.row=z.type==="data"?St:"";const Te=V.getAttribute("grouping")==="true";if(z.type==="group")if(Te){const ke=z.record[ue.DEPTH];$s===ke?(V.style.display="",t(this,or).call(this,V,s,z.record,bn)):V.style.display="none"}else V.style.display="none";else if(Te)V.style.display="none";else{V.style.display="";const ke=((mn=z.record.m)==null?void 0:mn.rowid)??0;t(this,js).call(this,V,z.record,ke,bn)}})}}),t(this,L).selection.refresh(),v.log("handleGroupdScroll() end")},"#handleGroupedScroll"));d(this,or,h((n,e,s,i)=>{const r=t(this,L).templateLength||1,o=parseInt(n.dataset.subrow,10)||0,l=i*r+o,a=s[ue.CHILDREN],c=t(this,Us).data.getArray(),u=a?a.map(g=>c[g]).filter(Boolean):[];n.dataset.virtualIndex=i,n.dataset.row="",n.dataset.matrixRow=l,n.data=u,n.dataset.groupId=s[ue.ID],Array.from(n.cells).forEach(g=>{g.dataset.row=i;const f=Array.from(g.children).find(b=>b.tagName.toLowerCase().startsWith("cell-")||typeof b.refresh=="function");f!==void 0&&typeof f.refresh=="function"&&(f==null||f.refresh())})},"#bindGroupRowData"));d(this,js,h((n,e,s,i)=>{const r=t(this,L).templateLength||1,o=parseInt(n.dataset.subrow,10)||0,l=i*r+o;n.dataset.index=i,n.dataset.row=s,n.dataset.matrixRow=l,n.data=e,Array.from(n.cells).forEach(a=>{a.dataset.index=i,a.dataset.row=s;const c=Array.from(a.children).find(u=>u.tagName.toLowerCase().startsWith("cell-")&&typeof u.refresh=="function");c==null||c.refresh()})},"#bindRowData"));E(this,"initialize",h(()=>{p(this,Pe,!!t(this,L).sourceTable.querySelector("tbody tr[grouping='true']")),p(this,G,null),t(this,Gs).clear(),p(this,Be,{scrollTables:t(this,L).querySelectorAll(".ng-sheet-body table"),firstTr:t(this,L).querySelector(".ng-sheet-body .ng-container-body tbody.body tr")}),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(e=>{const s=t(this,L).querySelector(`.ng-sheet-body ${e}`);if(!s)return;const i=s.querySelector("table");if(!i)return;const r=i.querySelector("tbody.body");if(!r)return;const l=Array.from(r.querySelectorAll("tr")).map(a=>a.cloneNode(!0));t(this,Gs).set(e,l)});const n=t(this,L).querySelector(".ng-sheet-body");n&&(p(this,ee,n.clientHeight),t(this,Ks).call(this),t(this,bs).call(this),t(this,Ve).call(this,n.scrollTop,!0),n.addEventListener("scroll",()=>{var r;if(t(this,ps))return;const e=t(this,G)||0;(((r=t(this,L).view.getArray())==null?void 0:r.length)||0)*e<=n.clientHeight||(t(this,Ve).call(this,n.scrollTop),t(this,L).querySelector("nine-table-vscrollbar").refresh())},{passive:!0}))},"initialize"));E(this,"destroy",h(()=>{t(this,me)&&(t(this,me).disconnect(),p(this,me,null))},"destroy"));d(this,Ks,h(()=>{var r;if(!t(this,L).classList.contains("active")||!t(this,L).sourceTable)return;const n=(r=t(this,L).sourceTable)==null?void 0:r.querySelectorAll("tbody.body tr"),e=t(this,L).querySelector(".ng-sheet-body .ng-container-body tbody.body");e.querySelectorAll("tr").forEach(o=>o.remove());const s=document.createDocumentFragment();n.forEach(o=>s.appendChild(o.cloneNode(!0))),e.appendChild(s);const i=e.querySelectorAll("tr");p(this,te,[]),i.forEach(o=>{t(this,te).push(o.offsetHeight)}),i.forEach(o=>o.remove()),p(this,G,t(this,te).reduce((o,l)=>o+l,0)),t(this,Ys).call(this)},"#measureAndCacheHeight"));d(this,Ys,h(()=>{var n;if(v.log("[DEBUG #updateRowCount] sheetHeight:",t(this,ee),"cachedTemplateHeight:",t(this,G)),t(this,ee)>0&&t(this,G)>0){const e=Math.ceil(t(this,ee)/t(this,G));let s=t(this,rr);if(t(this,Pe)&&t(this,L).grouping){const i=((n=t(this,L).grouping.columns)==null?void 0:n.length)||1;s+=i*15}p(this,gs,e+s),v.log("[DEBUG #updateRowCount] calculated cachedRowCount:",t(this,gs))}},"#updateRowCount"));d(this,bs,h(()=>{v.log("rowManager.#renderAllContainers"),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const e=t(this,L).querySelector(`.ng-sheet-body ${n}`);e&&e.querySelector("tbody")&&t(this,lr).call(this,e)}),t(this,ar).call(this)},"#renderAllContainers"));d(this,lr,h(n=>{let e=null;n.classList.contains("ng-container-left")?e="left":n.classList.contains("ng-container-right")&&(e="right");const s=Array.from(t(this,L).sourceTable.querySelectorAll("tbody.body tr")).map(o=>{const l=o.cloneNode(!0);return e==="left"?l.querySelectorAll("th,td").forEach(a=>{a.getAttribute("fixed")!=="left"&&a.remove()}):e==="right"?l.querySelectorAll("th,td").forEach(a=>{a.getAttribute("fixed")!=="right"&&a.remove()}):l.querySelectorAll("[fixed=left], [fixed=right]").forEach(a=>{a.remove()}),l});if(s.length===0)return;const i=n.querySelector("tbody.body");if(!i)return;i.querySelectorAll("tr").forEach(o=>o.remove());const r=document.createDocumentFragment();for(let o=0;o<t(this,gs);o++)s.forEach(l=>r.appendChild(l.cloneNode(!0)));i.appendChild(r),n.classList.contains("ng-container-body")&&(t(this,Be).firstTr=i.querySelector("tr"))},"#renderRows"));d(this,ar,h(()=>{var i,r,o;const n=t(this,L).querySelector(".ng-sheet-body .ng-container-left table"),e=t(this,L).querySelector(".ng-sheet-body .ng-container-body table"),s=t(this,L).querySelector(".ng-sheet-body .ng-container-right table");if(e){const l=n?Array.from(n.querySelectorAll("tbody tr")):[],a=Array.from(e.querySelectorAll("tbody tr")),c=s?Array.from(s.querySelectorAll("tbody tr")):[],u=Math.max(l.length,a.length,c.length);for(let g=0;g<u;g++){const f=[((i=l[g])==null?void 0:i.getBoundingClientRect().height)||0,((r=a[g])==null?void 0:r.getBoundingClientRect().height)||0,((o=c[g])==null?void 0:o.getBoundingClientRect().height)||0],b=Math.max(...f);b>0&&(l[g]&&(l[g].style.height=`${b}px`),a[g]&&(a[g].style.height=`${b}px`),c[g]&&(c[g].style.height=`${b}px`))}}},"#syncRowHeights"));d(this,cr,h(()=>{!t(this,L)||!(t(this,L)instanceof HTMLElement)||(p(this,me,new ResizeObserver(n=>{for(const e of n){if(!e.target.classList.contains("active"))continue;const i=e.contentRect.height;e.contentRect.width>0&&t(this,L).isAutoFitCol&&t(this,L).autoFit(!0),i>0&&t(this,ee)!==i&&(p(this,ee,i),t(this,Ys).call(this),t(this,G)!==null&&(t(this,bs).call(this),this.refresh()))}})),t(this,me).observe(t(this,L)))},"#initResizeObserver"));p(this,Us,n.getRootNode().host),p(this,L,n),t(this,cr).call(this)}getRowHeight(){return t(this,te).reduce((n,e)=>n+e,0)}scrollToDataRow(n,e="top",s){var c,u;const i=t(this,L).querySelector(".ng-sheet-body");if(!i){typeof s=="function"&&s();return}const r=t(this,L).view.getArray(),o=(r==null?void 0:r.length)||0;if(o===0){typeof s=="function"&&s();return}const l=Math.max(0,Math.min(n,o-1));let a=0;if(t(this,Pe)){const g=Math.max(i.scrollHeight-i.clientHeight,1);a=l/Math.max(o-1,1)*g}else{const g=t(this,G);if(!g||g<=0){typeof s=="function"&&s();return}let f=l*g;t(this,L).templateLength;const b=(((c=t(this,L).elements.body.thead)==null?void 0:c.offsetHeight)||0)+(((u=t(this,L).elements.body.tfoot)==null?void 0:u.offsetHeight)||0)+t(this,L).elements.body.tbody.head.offsetHeight,m=t(this,L).querySelector(".ng-sheet-body").offsetHeight||0,y=Math.max(o*g+g*2+b-m,0),x=15e6,w=y>x;let S=1;w&&(S=x/y),a=f*S}p(this,ps,!0),i.scrollTop=a,t(this,Ve).call(this,a),requestAnimationFrame(()=>{requestAnimationFrame(()=>{p(this,ps,!1),typeof s=="function"&&s()})})}};rr=new WeakMap,Us=new WeakMap,L=new WeakMap,Be=new WeakMap,Gs=new WeakMap,te=new WeakMap,G=new WeakMap,me=new WeakMap,ee=new WeakMap,gs=new WeakMap,ps=new WeakMap,Pe=new WeakMap,Ve=new WeakMap,nr=new WeakMap,or=new WeakMap,js=new WeakMap,Ks=new WeakMap,Ys=new WeakMap,bs=new WeakMap,lr=new WeakMap,ar=new WeakMap,cr=new WeakMap,h(wo,"RowManager");let Hn=wo;const mt=16,gt=class gt{static compile(n){var s;const e=n.cloneNode(!0);return gt.resetColIndex(e,e.querySelectorAll("thead tr")),gt.resetColIndex(e,e.querySelectorAll('tbody.body tr[grouping="true"]')),gt.resetColIndex(e,e.querySelectorAll('tbody.body tr:not([grouping="true"])')),gt.resetColIndex(e,e.querySelectorAll("tfoot tr")),A(s=gt,Zs,hl).call(s,e),e}static recompile(n){var e;return gt.resetColIndex(n,n.querySelectorAll("thead tr")),gt.resetColIndex(n,n.querySelectorAll('tbody.body tr[grouping="true"]')),gt.resetColIndex(n,n.querySelectorAll('tbody.body tr:not([grouping="true"])')),gt.resetColIndex(n,n.querySelectorAll("tfoot tr")),A(e=gt,Zs,hl).call(e,n),n}static resetColIndex(n,e){const s=n.querySelectorAll("colgroup col"),i=Array.from({length:e.length},()=>Array(s.length).fill(null));e.forEach((r,o)=>{r.dataset.subrow=o;let l=0;r.querySelectorAll("th, td").forEach(a=>{for(;l<s.length&&i[o][l]!==null;)l++;a.dataset.col=l;const c=a.rowSpan||1,u=a.colSpan||1;for(let g=0;g<c;g++)for(let f=0;f<u;f++)o+g<e.length&&l+f<s.length&&(i[o+g][l+f]=a);l+=u})})}};Zs=new WeakSet,hl=h(function(n){n.querySelectorAll("colgroup col").forEach((e,s)=>{e.setAttribute("data-col",s);const i=e.getAttribute("fixed");n.querySelectorAll(`[data-col="${s}"]`).forEach(r=>{i?r.setAttribute("fixed",i):r.removeAttribute("fixed")})})},"#syncColAttributes"),d(gt,Zs),h(gt,"TableCompiler");let fe=gt;const vo=class vo{constructor(n){d(this,se);d(this,J);d(this,Js,{startRow:-1,startCol:-1,endRow:-1,endCol:-1});E(this,"refresh",h(()=>{this.render()},"refresh"));E(this,"render",h(()=>{var l;const{startRow:n,startCol:e,endRow:s,endCol:i}=t(this,Js),r=t(this,J).querySelectorAll(".ng-sheet-body-content .ng-container-left, .ng-sheet-body-content .ng-container-body, .ng-sheet-body-content .ng-container-right");if(r.forEach(a=>{a.querySelectorAll(".selected, .selected-top, .selected-bottom, .selected-left, .selected-right, .selected-start").forEach(c=>{c.classList.remove("selected","selected-top","selected-bottom","selected-left","selected-right","selected-start")}),a.querySelectorAll("tr.selected-start").forEach(c=>{c.classList.remove("selected-start")})}),n<0||e<0)return;r.forEach(a=>{a.querySelectorAll("tbody tr").forEach(c=>{const{matrixRow:u}=A(this,se,zi).call(this,c);u<0||c.querySelectorAll("td, th").forEach(g=>{const f=parseInt(g.dataset.col,10);if(isNaN(f))return;const b=parseInt(g.rowSpan||1,10),m=parseInt(g.colSpan||1,10),y=u+b-1,x=f+m-1;y>=n&&u<=s&&x>=e&&f<=i&&(g.classList.add("selected"),u<=n&&g.classList.add("selected-top"),y>=s&&g.classList.add("selected-bottom"),f<=e&&g.classList.add("selected-left"),x>=i&&g.classList.add("selected-right"))})})});const o=t(this,J).querySelector(`.ng-sheet-body-content tr[data-matrix-row="${n}"] td[data-col="${e}"]`);o&&(o.classList.add("selected-start"),(l=o.closest("tr"))==null||l.classList.add("selected-start"))},"render"));p(this,J,n),A(this,se,Tl).call(this),v.log("🎯 [CellSelection] Initialized (New Structure Compatible)")}setFocus(n,e){var i;t(this,J).querySelectorAll("tr.selected-start").forEach(r=>{r.classList.remove("selected-start"),r.querySelectorAll("td.selected-start").forEach(o=>{o.classList.remove("selected-start")})});const s=t(this,J).querySelector(`.ng-sheet-body-content tr[data-matrix-row="${n}"] td[data-col="${e}"]`);s&&(s.classList.add("selected-start"),(i=s.closest("tr"))==null||i.classList.add("selected-start"))}setRange(n,e,s,i){let r=Math.min(n,s),o=Math.max(n,s),l=Math.min(e,i),a=Math.max(e,i);const c=t(this,J).querySelectorAll(".ng-sheet-body-content .ng-container-left, .ng-sheet-body-content .ng-container-body, .ng-sheet-body-content .ng-container-right");let u=!0,g=0;for(;u&&g<5;)u=!1,g++,c.forEach(f=>{f.querySelectorAll("tbody tr").forEach(b=>{if(b.classList.contains("nodata"))return;const{matrixRow:m}=A(this,se,zi).call(this,b);m<0||b.querySelectorAll("td, th").forEach(y=>{const x=parseInt(y.dataset.col,10);if(isNaN(x))return;const w=parseInt(y.rowSpan||1,10),S=parseInt(y.colSpan||1,10),R=m+w-1,C=x+S-1;if(R>=r&&m<=o&&C>=l&&x<=a){const T=Math.min(r,m),D=Math.max(o,R),_=Math.min(l,x),rt=Math.max(a,C);(T!==r||D!==o||_!==l||rt!==a)&&(r=T,o=D,l=_,a=rt,u=!0)}})})});p(this,Js,{startRow:r,startCol:l,endRow:o,endCol:a}),this.render()}};J=new WeakMap,Js=new WeakMap,se=new WeakSet,zi=h(function(n){if(!n)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"),r=Array.from(s.querySelectorAll("tr:not(.nodata)")).filter(c=>parseInt(c.dataset.row,10)===e),o=r.indexOf(n),l=r.length>0?r.length:1,a=e*l+(o>=0?o:n.sectionRowIndex%l);return{dataRow:e,subRowIndex:o,matrixRow:a}},"#getMatrixRow"),Tl=h(function(){const n=t(this,J).querySelector(".ng-sheet-body");if(!n){v.log("❌ [CellSelection] .ng-sheet-body 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,J).style.userSelect="none",t(this,J).style.webkitUserSelect="none";const i=s.closest("tr"),{matrixRow:r}=A(this,se,zi).call(this,i),o=parseInt(s.dataset.col,10);if(r<0){t(this,J).style.userSelect="",t(this,J).style.webkitUserSelect="";return}this.setFocus(r,o),this.setRange(r,o,r,o);let l=r,a=o;const c=h(g=>{const f=document.elementFromPoint(g.clientX,g.clientY);let b=f==null?void 0:f.closest("td, th");if(!b||!t(this,J).contains(b)){const w=t(this,J).querySelectorAll(".ng-sheet-body-content tbody tr:not(.nodata) td, .ng-sheet-body-content tbody tr:not(.nodata) th");for(const S of w){const R=S.getBoundingClientRect();if(g.clientX>=R.left&&g.clientX<=R.right&&g.clientY>=R.top&&g.clientY<=R.bottom){b=S;break}}}if(!b||b.dataset.row===void 0||b.dataset.col===void 0||b.closest("tr").classList.contains("nodata"))return;const m=b.closest("tr"),{matrixRow:y}=A(this,se,zi).call(this,m),x=parseInt(b.dataset.col,10);y<0||l===y&&a===x||(l=y,a=x,this.setRange(r,o,y,x))},"onMouseMove"),u=h(()=>{t(this,J).style.userSelect="",t(this,J).style.webkitUserSelect="",document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",u)},"onMouseUp");document.addEventListener("mousemove",c),document.addEventListener("mouseup",u)})},"#initEvents"),h(vo,"CellSelection");let Nn=vo;const Eo=class Eo{constructor(n){d(this,pt);d(this,$);d(this,Qs);d(this,ye,null);d(this,Xt,null);d(this,So,-1);d(this,Ao,-1);d(this,ti,h(n=>{const e=t(this,$).querySelectorAll(`.ng-sheet-body td[data-row="${n}"]`);if(!e||e.length===0)return 0;let s=1/0;return e.forEach(i=>{const r=parseInt(i.dataset.col,10);!isNaN(r)&&window.getComputedStyle(i).display!=="none"&&(s=Math.min(s,r))}),s===1/0?0:s},"#getMinCol"));d(this,ei,h(n=>{const e=t(this,$).querySelectorAll(`.ng-sheet-body td[data-row="${n}"]`);if(!e||e.length===0)return 0;let s=0;return e.forEach(i=>{const r=parseInt(i.dataset.col,10);!isNaN(r)&&window.getComputedStyle(i).display!=="none"&&(s=Math.max(s,r))}),s},"#getMaxCol"));d(this,si,h(n=>{const e=[];return n.forEach(s=>e.push(...Array.from(s.querySelectorAll("td")))),e.length===0?null:(e.sort((s,i)=>parseInt(s.dataset.col,10)-parseInt(i.dataset.col,10)),e[e.length-1])},"#getMaxColCell"));d(this,ii,h((n,e)=>{const s=t(this,$).querySelector(`.ng-sheet-body tr[data-matrix-row="${n}"] td[data-col="${e}"]`)||t(this,$).querySelector(`.ng-sheet-body td[data-col="${e}"]`),i=(s==null?void 0:s.colSpan)||1,r=e+i;return v.log(`🔍 [#getNextCol] current col: ${e}, found td colSpan: ${i}, calculated next col: ${r}`),r},"#getNextCol"));d(this,ri,h((n,e)=>{if(e<=0)return 0;const s=t(this,Xt)?Array.from(t(this,Xt).querySelectorAll("td, th")):[],i=new Set;s.forEach(o=>{const l=parseInt(o.dataset.col,10);!isNaN(l)&&window.getComputedStyle(o).display!=="none"&&i.add(l)}),i.size===0&&t(this,ms).call(this,n).forEach(l=>{Array.from(l.querySelectorAll("td, th")).forEach(a=>{const c=parseInt(a.dataset.col,10);!isNaN(c)&&window.getComputedStyle(a).display!=="none"&&i.add(c)})});const r=Array.from(i).filter(o=>o<e);return r.length===0?Math.max(0,e-1):Math.max(...r)},"#getPreviousCol"));d(this,ms,h(n=>{const e=t(this,$).querySelectorAll(".ng-sheet-body .ng-container-left, .ng-sheet-body .ng-container-body, .ng-sheet-body .ng-container-right"),s=[];return e.forEach(i=>{const r=Array.from(i.querySelectorAll("tbody tr"));for(const o of r){const l=A(this,pt,cs).call(this,o);if(l===n){s.push(o);break}const a=Array.from(o.querySelectorAll("td"));let c=!1;for(const u of a){const g=parseInt(u.rowSpan||1,10);if(g>1&&n>=l&&n<l+g){s.push(o),c=!0;break}}if(c)break}}),s},"#findTargetTrsByMatrix"));d(this,ni,h((n,e,s,i)=>{const r=i!==void 0?i:n*(t(this,$).templateLength||1)+e,o=t(this,$).templateLength||1,l=t(this,$).querySelectorAll(".ng-sheet-body, .ng-container-left, .ng-container-body, .ng-container-right, .ng-part-body"),a=new Set;l.forEach(c=>{c.querySelectorAll("tbody tr").forEach(u=>a.add(u))});for(const c of Array.from(a)){const u=parseInt(c.dataset.row,10);if(isNaN(u))continue;const g=c.closest("tbody"),b=(g?Array.from(g.querySelectorAll(`tr[data-row="${u}"]`)):[c]).indexOf(c);for(const m of Array.from(c.querySelectorAll("td"))){const y=parseInt(m.dataset.col,10),x=parseInt(m.colSpan||1,10),w=parseInt(m.rowSpan||1,10);if(isNaN(y)||window.getComputedStyle(m).display==="none")continue;const S=u,R=b,C=S*o+R,W=C+w-1;if(r>=C&&r<=W&&s>=y&&s<y+x)return m}}return null},"#getNearElement"));p(this,$,n),p(this,Qs,n.getRootNode().host),A(this,pt,kl).call(this),v.log("🎯 [CellNavigation] Initialized (Diagnostic Logging Restored)")}get currentCell(){return t(this,ye)}set currentCell(n){var s;if(!n)return;p(this,ye,n),n.focus({preventScroll:!0}),p(this,Xt,n.closest("tr"));const e=A(this,pt,cs).call(this,t(this,Xt));v.log(`📌 [setCurCell] Active set -> dataRow: ${n.dataset.row}, subrow: ${(s=n.closest("tr"))==null?void 0:s.dataset.subrow}, matrixRow: ${e}, col: ${n.dataset.col}`),t(this,$).selection.setFocus(e,t(this,ye).dataset.col)}moveCell(n){var m;if(!["TH","TD"].includes(n.target.tagName))return;if(!t(this,ye)||!t(this,Xt)){v.log("⚠️ [moveCell] currentCell or currentTr is missing!");return}const e=t(this,ye),s=parseInt(e.dataset.row,10),i=parseInt(e.dataset.col,10),r=t(this,$).templateLength||1,o=A(this,pt,cs).call(this,t(this,Xt));let l=o,a=i;switch(n.code){case"ArrowDown":n.preventDefault(),l=o+(e.rowSpan||1);break;case"ArrowUp":n.preventDefault(),l=Math.max(0,o-(e.rowSpan||1));break;case"ArrowRight":a=t(this,ii).call(this,o,i);break;case"ArrowLeft":a=t(this,ri).call(this,o,i);break;case"Tab":if(n.preventDefault(),n.shiftKey){if(a=t(this,ri).call(this,o,i),a<0&&o>0){l=o-1;const y=t(this,ms).call(this,l),x=t(this,si).call(this,y);a=x?parseInt(x.dataset.col,10):0}}else{a=t(this,ii).call(this,o,i);const y=t(this,ms).call(this,o),x=t(this,si).call(this,y),w=x?parseInt(x.dataset.col,10)+parseInt(x.colSpan||1,10):0;a>=w&&(l=o+1,a=0)}break}switch(n.code){case"ArrowDown":const x=t(this,Qs).data.length*r-1;if(o+(e.rowSpan||1)>x)return;break;case"ArrowUp":if(o<=0)return;break;case"ArrowRight":if(i===a||a>t(this,ei).call(this,s,i))return;break;case"ArrowLeft":if(i===a||a<t(this,ti).call(this,s,i))return;break;case"Tab":if(n.shiftKey){if(i===a||a<t(this,ti).call(this,s,i))return}else if(i===a||a>t(this,ei).call(this,s,i))return;break}v.log("========");const u=(((m=t(this,$).view.getArray())==null?void 0:m.length)||0)*r-1;l=Math.max(0,Math.min(l,u)),v.log(`⌨️ [Key: ${n.code}] Current matrixRow: ${o} -> Target nextMatrixRow: ${l}, nextCol: ${a}`);const g=Math.floor(l/r),f=l%r;h((y=0)=>{let x=t(this,ni).call(this,g,f,a,l);if(x){v.log(`✅ [Found Cell] Attempt ${y} -> dataRow: ${x.dataset.row}, col: ${x.dataset.col}`),this.currentCell=x;const w=A(this,pt,cs).call(this,t(this,Xt));t(this,$).selection.setRange(w,x.dataset.col,w,x.dataset.col),A(this,pt,dl).call(this,x)}else v.log(`📜 [Scroll Trigger] Cell not found in DOM, invoking rowManager.scrollToDataRow(${g})`),t(this,$).rowManager.scrollToDataRow(g,"bottom",()=>{v.log("nextDataRow",g),h(()=>{let S=t(this,ni).call(this,g,f,a,l);if(S){v.log(`✅ [Found After Scroll] RetryLoop success -> dataRow: ${S.dataset.row}`),this.currentCell=S;const R=S.closest("tr"),C=A(this,pt,cs).call(this,R);t(this,$).selection.setRange(C,S.dataset.col,C,S.dataset.col),A(this,pt,dl).call(this,S)}},"retryLoop")()})},"attemptFindAndMove")()}};$=new WeakMap,Qs=new WeakMap,ye=new WeakMap,Xt=new WeakMap,So=new WeakMap,Ao=new WeakMap,pt=new WeakSet,cs=h(function(n){if(!n)return 0;const e=parseInt(n.dataset.row,10)||0,s=t(this,$).templateLength||1,i=parseInt(n.dataset.matrixRow,10);if(!isNaN(i))return i;const r=n.closest("tbody");if(r){const a=Array.from(r.querySelectorAll(`tr[data-row="${e}"]`)).indexOf(n);if(a>=0)return e*s+a}const o=parseInt(n.dataset.subrow,10)||0;return e*s+o},"#getMatrixRowFromTr"),dl=h(function(n){const e=t(this,$).querySelector(".ng-sheet-body"),s=t(this,$).querySelector(".ng-sheet-body .ng-container-body"),i=t(this,$).querySelector(".ng-sheet-header .ng-container-body");if(!e||!s)return;const r=n.getBoundingClientRect(),o=e.getBoundingClientRect(),l=s.getBoundingClientRect(),a=i?i.getBoundingClientRect():null;v.log(`📐 [DIAGNOSTIC VISIBILITY]
143
+ `;const e=h(()=>{const s=t(this,M).querySelector(".ng-sheet-body");if(!s){setTimeout(e,10);return}p(this,F,{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,ir).call(this),this.refresh()},"initWhenReady");e()}};er=new WeakMap,M=new WeakMap,$e=new WeakMap,F=new WeakMap,Vs=new WeakMap,mo=new WeakMap,Xs=new WeakMap,Fe=new WeakMap,sr=new WeakMap,ir=new WeakMap,h(yo,"NineTableVScrollBar");let In=yo;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",In);const ue={ID:0,DEPTH:1,NAME:2,CHILDREN:3},xo=class xo{constructor(n){d(this,Dt);d(this,_s);d(this,We,[]);d(this,Oe,new Map);d(this,ze,!1);E(this,"initialize",h(()=>{let n=[];const e=t(this,Dt).sourceTable;e&&e.querySelectorAll('tbody tr[grouping="true"]').forEach(s=>{const i=s.querySelector('[cell-type="tree"]');i&&i.dataset.bind&&n.push(i.dataset.bind)}),p(this,We,n)},"initialize"));p(this,Dt,n),p(this,_s,t(this,Dt).getRootNode().host)}get columns(){return t(this,We)}get groupMap(){return t(this,Oe)}apply(){if(v.log("==================","Grouping.Apply"),t(this,ze))return;p(this,ze,!0);let n=[];const e=t(this,Dt).sourceTable;e&&e.querySelectorAll('tbody tr[grouping="true"]').forEach(s=>{const i=s.querySelector('[cell-type="tree"]');i&&i.dataset.bind&&n.push(i.dataset.bind)}),p(this,We,n),p(this,ze,!1),t(this,Dt).scrollToY(0),t(this,Dt).view.refresh()}clear(){p(this,We,[]),t(this,Oe).clear(),p(this,ze,!1),t(this,Dt).scrollToY(0),t(this,Dt).view.refresh()}setGroupMap(n){p(this,Oe,n)}getChildrenRowIds(n){return t(this,Oe).get(n)||[]}getChildrenRecords(n){const e=this.getChildrenRowIds(n),s=t(this,_s).data;return e.map(i=>s.getArray(i)).filter(Boolean)}};Dt=new WeakMap,_s=new WeakMap,We=new WeakMap,Oe=new WeakMap,ze=new WeakMap,h(xo,"GroupingManager");let qn=xo;const Rt=class Rt{static apply(n,e=[],s=[]){var c,u;if(!e||e.length===0)return{headers:[],renderItems:[],groupMap:new Map};const i=n.filter(f=>{var g;return!((g=f.__ng)!=null&&g.deleted)}),r=new Map,o=A(c=Rt,ft,ll).call(c,i,e,s),l=[],a=[];return A(u=Rt,ft,ol).call(u,o,0,e,l,a,r,""),{headers:l,renderItems:a,groupMap:r}}};ft=new WeakSet,ol=h(function(n,e,s,i,r,o,l){var u,f,g;let a=0;const c=e===s.length-1;for(let[b,m]of n.entries()){const y=l?`${l}_${a++}`:`g_${a++}`,x=A(u=Rt,ft,al).call(u,m);o.set(y,x);const w=[];w[ue.ID]=y,w[ue.DEPTH]=e,w[ue.NAME]=b,w[ue.CHILDREN]=x,w.__isGroupHeader=!0,w.__groupId=y,i.push(w),r.push({type:"group",record:w,groupId:y}),!c&&m instanceof Map?A(f=Rt,ft,ol).call(f,m,e+1,s,i,r,o,y):A(g=Rt,ft,cl).call(g,m).forEach(L=>{L.__isGroupHeader=!1,L.__groupId=y,i.push(L),r.push({type:"data",record:L,groupId:y})})}},"#flattenTree"),ll=h(function(n,e,s){var l;const i=s.indexOf(e[0]),r=e.slice(1),o=new Map;if(n.forEach(a=>{const c=i>=0?a.v[i]:"(Unknown)";o.has(c)||o.set(c,[]),o.get(c).push(a)}),r.length>0){const a=new Map;for(let[c,u]of o.entries())a.set(c,A(l=Rt,ft,ll).call(l,u,r,s));return a}return o},"#buildNestedMap"),al=h(function(n){var s;let e=[];if(n instanceof Map)for(let i of n.values())e=e.concat(A(s=Rt,ft,al).call(s,i));else Array.isArray(n)&&(e=e.concat(n.map(i=>{var r,o,l;return((r=i.__ng)==null?void 0:r.rowid)??((l=(o=i.m)==null?void 0:o._)==null?void 0:l[0])})));return e},"#collectLeafRowIds"),cl=h(function(n){var s;let e=[];if(n instanceof Map)for(let i of n.values())e=e.concat(A(s=Rt,ft,cl).call(s,i));else Array.isArray(n)&&(e=e.concat(n));return e},"#collectLeafRecords"),d(Rt,ft),h(Rt,"Grouping");let Mn=Rt;const wo=class wo{constructor(n){d(this,rr,3);d(this,Us);d(this,R);d(this,Be);d(this,Gs,new Map);d(this,te,[]);d(this,G,null);d(this,me,null);d(this,ee,0);d(this,gs);d(this,ps,!1);d(this,Pe,!1);E(this,"refresh",h((n=!1)=>{var i;if(!t(this,R).classList.contains("active"))return;const e=t(this,R).querySelector(".ng-sheet-body");if(!e)return;(!t(this,G)||t(this,G)<=0)&&(t(this,Ks).call(this),t(this,G)&&t(this,G)>0&&t(this,bs).call(this)),t(this,Ve).call(this,e.scrollTop,n),(i=t(this,R).querySelector("nine-table-vscrollbar"))==null||i.refresh()},"refresh"));d(this,Ve,h((n,e=!1)=>{var W,T;if(t(this,Pe)){t(this,nr).call(this,n,e);return}const s=t(this,G);if(!s||s<=0)return;const i=t(this,R).view.getArray(),r=i.length;if(r===0){t(this,R).elements.scrollHolder.style.height="0px";return}const o=t(this,R).templateLength,l=(((W=t(this,R).elements.body.thead)==null?void 0:W.offsetHeight)||0)+(((T=t(this,R).elements.body.tfoot)==null?void 0:T.offsetHeight)||0)+t(this,R).elements.body.tbody.head.offsetHeight,a=t(this,R).querySelector(".ng-sheet-body").offsetHeight||0,c=Math.max(r*s+s*2+l-a,0),u=15e6,f=c>u;let g=1,b=c;f&&(g=u/c,b=u),t(this,R).elements.scrollHolder.style.height=`${b}px`;const m=f?n/g:n,y=Math.max(0,r-1),x=Math.min(m,c),w=Math.max(0,Math.min(Math.floor(x/s)-1,y)),S=x%s;t(this,R).elements.left.tbody.body.style.top=t(this,R).elements.body.tbody.body.style.top=t(this,R).elements.right.tbody.body.style.top=`-${S}px`;const L=t(this,Be).firstTr,C=L&&L.dataset.row!==void 0?parseInt(L.dataset.row,10):-1;!e&&C===w||([t(this,R).elements.left.tbody.body,t(this,R).elements.body.tbody.body,t(this,R).elements.right.tbody.body].forEach((D,_)=>{if(!D)return;D.querySelectorAll("tbody.body tr").forEach((lt,z)=>{const tt=w+Math.floor(z/o);if(tt>=r){lt.style.display="none",lt.dataset.matrixRow=null,lt.dataset.row=null;return}const St=i[tt];if(!St){lt.style.display="none";return}const V=St.m._[Nt.META.INDEX.ROWID];lt.style.display="",t(this,js).call(this,lt,St,V,tt)})}),t(this,R).selection.refresh())},"#handleScroll"));d(this,nr,h((n,e=!1)=>{var W;v.log("handleGroupdScroll() start");const s=t(this,R).view.getArray()||[],i=s.length;if(i===0){t(this,R).elements.scrollHolder.style.height="0px";return}const r=t(this,R).querySelector(".ng-sheet-body .ng-sheet-body-content"),o=t(this,R).templateLength||1,l=h(T=>{if(T.type==="group"){const D=T.record[ue.DEPTH]||0;return t(this,te)[D]||t(this,G)/o}else{let D=0;const _=t(this,R).templateLength||1;let rt=0;for(let lt=0;lt<_-1;lt++)rt+=t(this,te)[lt]||0;return D=t(this,G)-rt,D>0?D:t(this,G)}},"getItemHeight");let a=0;const c=new Array(i);for(let T=0;T<i;T++){const D=l(s[T]);c[T]=D,a+=D}t(this,R).elements.scrollHolder.style.height=`${a}px`,v.log("*************",a);const u=t(this,R).clientHeight;let f=0,g=0;for(let T=0;T<i;T++){const D=c[T];if(f+D>n){g=T;break}f+=D,g=T}const b=n-f;r&&r.querySelectorAll("tbody").forEach(T=>{T.style.top=`-${Math.max(0,b)}px`});const m=t(this,Be).firstTr,y=m&&m.dataset.virtualIndex!==void 0?parseInt(m.dataset.virtualIndex,10):-1;if(!e&&y===g)return;const x=Math.ceil(u/(t(this,G)/o)),w=(((W=t(this,R).grouping.columns)==null?void 0:W.length)||1)*15,S=g,L=Math.min(i,g+x+w),C=s.slice(S,L);[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(T=>{const D=t(this,R).querySelector(`.ng-sheet-body ${T}`);if(!D)return;const _=Array.from(D.querySelectorAll("tbody.body tr"));for(let rt=0;rt<_.length;rt+=o){const lt=Math.floor(rt/o),z=C[lt],tt=_.slice(rt,rt+o);if(!z||lt>=C.length){tt.forEach(V=>{V.dataset.matrixRow=null,V.dataset.row=null,V.style.display="none"});continue}const St=g+lt;tt.forEach((V,$s)=>{var mn;const bn=g+lt;V.dataset.virtualIndex=bn,V.dataset.row=z.type==="data"?St:"";const Te=V.getAttribute("grouping")==="true";if(z.type==="group")if(Te){const ke=z.record[ue.DEPTH];$s===ke?(V.style.display="",t(this,or).call(this,V,s,z.record,bn)):V.style.display="none"}else V.style.display="none";else if(Te)V.style.display="none";else{V.style.display="";const ke=((mn=z.record.m)==null?void 0:mn.rowid)??0;t(this,js).call(this,V,z.record,ke,bn)}})}}),t(this,R).selection.refresh(),v.log("handleGroupdScroll() end")},"#handleGroupedScroll"));d(this,or,h((n,e,s,i)=>{const r=t(this,R).templateLength||1,o=parseInt(n.dataset.subrow,10)||0,l=i*r+o,a=s[ue.CHILDREN],c=t(this,Us).data.getArray(),u=a?a.map(f=>c[f]).filter(Boolean):[];n.dataset.virtualIndex=i,n.dataset.row="",n.dataset.matrixRow=l,n.data=u,n.dataset.groupId=s[ue.ID],Array.from(n.cells).forEach(f=>{f.dataset.row=i;const g=Array.from(f.children).find(b=>b.tagName.toLowerCase().startsWith("cell-")||typeof b.refresh=="function");g!==void 0&&typeof g.refresh=="function"&&(g==null||g.refresh())})},"#bindGroupRowData"));d(this,js,h((n,e,s,i)=>{const r=t(this,R).templateLength||1,o=parseInt(n.dataset.subrow,10)||0,l=i*r+o;n.dataset.index=i,n.dataset.row=s,n.dataset.matrixRow=l,n.data=e,Array.from(n.cells).forEach(a=>{a.dataset.index=i,a.dataset.row=s;const c=Array.from(a.children).find(u=>u.tagName.toLowerCase().startsWith("cell-")&&typeof u.refresh=="function");c==null||c.refresh()})},"#bindRowData"));E(this,"initialize",h(()=>{p(this,Pe,!!t(this,R).sourceTable.querySelector("tbody tr[grouping='true']")),p(this,G,null),t(this,Gs).clear(),p(this,Be,{scrollTables:t(this,R).querySelectorAll(".ng-sheet-body table"),firstTr:t(this,R).querySelector(".ng-sheet-body .ng-container-body tbody.body tr")}),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(e=>{const s=t(this,R).querySelector(`.ng-sheet-body ${e}`);if(!s)return;const i=s.querySelector("table");if(!i)return;const r=i.querySelector("tbody.body");if(!r)return;const l=Array.from(r.querySelectorAll("tr")).map(a=>a.cloneNode(!0));t(this,Gs).set(e,l)});const n=t(this,R).querySelector(".ng-sheet-body");n&&(p(this,ee,n.clientHeight),t(this,Ks).call(this),t(this,bs).call(this),t(this,Ve).call(this,n.scrollTop,!0),n.addEventListener("scroll",()=>{var r;if(t(this,ps))return;const e=t(this,G)||0;(((r=t(this,R).view.getArray())==null?void 0:r.length)||0)*e<=n.clientHeight||(t(this,Ve).call(this,n.scrollTop),t(this,R).querySelector("nine-table-vscrollbar").refresh())},{passive:!0}))},"initialize"));E(this,"destroy",h(()=>{t(this,me)&&(t(this,me).disconnect(),p(this,me,null))},"destroy"));d(this,Ks,h(()=>{var r;if(!t(this,R).classList.contains("active")||!t(this,R).sourceTable)return;const n=(r=t(this,R).sourceTable)==null?void 0:r.querySelectorAll("tbody.body tr"),e=t(this,R).querySelector(".ng-sheet-body .ng-container-body tbody.body");e.querySelectorAll("tr").forEach(o=>o.remove());const s=document.createDocumentFragment();n.forEach(o=>s.appendChild(o.cloneNode(!0))),e.appendChild(s);const i=e.querySelectorAll("tr");p(this,te,[]),i.forEach(o=>{t(this,te).push(o.offsetHeight)}),i.forEach(o=>o.remove()),p(this,G,t(this,te).reduce((o,l)=>o+l,0)),t(this,Ys).call(this)},"#measureAndCacheHeight"));d(this,Ys,h(()=>{var n;if(v.log("[DEBUG #updateRowCount] sheetHeight:",t(this,ee),"cachedTemplateHeight:",t(this,G)),t(this,ee)>0&&t(this,G)>0){const e=Math.ceil(t(this,ee)/t(this,G));let s=t(this,rr);if(t(this,Pe)&&t(this,R).grouping){const i=((n=t(this,R).grouping.columns)==null?void 0:n.length)||1;s+=i*15}p(this,gs,e+s),v.log("[DEBUG #updateRowCount] calculated cachedRowCount:",t(this,gs))}},"#updateRowCount"));d(this,bs,h(()=>{v.log("rowManager.#renderAllContainers"),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const e=t(this,R).querySelector(`.ng-sheet-body ${n}`);e&&e.querySelector("tbody")&&t(this,lr).call(this,e)}),t(this,ar).call(this)},"#renderAllContainers"));d(this,lr,h(n=>{let e=null;n.classList.contains("ng-container-left")?e="left":n.classList.contains("ng-container-right")&&(e="right");const s=Array.from(t(this,R).sourceTable.querySelectorAll("tbody.body tr")).map(o=>{const l=o.cloneNode(!0);return e==="left"?l.querySelectorAll("th,td").forEach(a=>{a.getAttribute("fixed")!=="left"&&a.remove()}):e==="right"?l.querySelectorAll("th,td").forEach(a=>{a.getAttribute("fixed")!=="right"&&a.remove()}):l.querySelectorAll("[fixed=left], [fixed=right]").forEach(a=>{a.remove()}),l});if(s.length===0)return;const i=n.querySelector("tbody.body");if(!i)return;i.querySelectorAll("tr").forEach(o=>o.remove());const r=document.createDocumentFragment();for(let o=0;o<t(this,gs);o++)s.forEach(l=>r.appendChild(l.cloneNode(!0)));i.appendChild(r),n.classList.contains("ng-container-body")&&(t(this,Be).firstTr=i.querySelector("tr"))},"#renderRows"));d(this,ar,h(()=>{var i,r,o;const n=t(this,R).querySelector(".ng-sheet-body .ng-container-left table"),e=t(this,R).querySelector(".ng-sheet-body .ng-container-body table"),s=t(this,R).querySelector(".ng-sheet-body .ng-container-right table");if(e){const l=n?Array.from(n.querySelectorAll("tbody tr")):[],a=Array.from(e.querySelectorAll("tbody tr")),c=s?Array.from(s.querySelectorAll("tbody tr")):[],u=Math.max(l.length,a.length,c.length);for(let f=0;f<u;f++){const g=[((i=l[f])==null?void 0:i.getBoundingClientRect().height)||0,((r=a[f])==null?void 0:r.getBoundingClientRect().height)||0,((o=c[f])==null?void 0:o.getBoundingClientRect().height)||0],b=Math.max(...g);b>0&&(l[f]&&(l[f].style.height=`${b}px`),a[f]&&(a[f].style.height=`${b}px`),c[f]&&(c[f].style.height=`${b}px`))}}},"#syncRowHeights"));d(this,cr,h(()=>{!t(this,R)||!(t(this,R)instanceof HTMLElement)||(p(this,me,new ResizeObserver(n=>{for(const e of n){if(!e.target.classList.contains("active"))continue;const i=e.contentRect.height;e.contentRect.width>0&&t(this,R).isAutoFitCol&&t(this,R).autoFit(!0),i>0&&t(this,ee)!==i&&(p(this,ee,i),t(this,Ys).call(this),t(this,G)!==null&&(t(this,bs).call(this),this.refresh()))}})),t(this,me).observe(t(this,R)))},"#initResizeObserver"));p(this,Us,n.getRootNode().host),p(this,R,n),t(this,cr).call(this)}getRowHeight(){return t(this,te).reduce((n,e)=>n+e,0)}scrollToDataRow(n,e="top",s){var c,u;const i=t(this,R).querySelector(".ng-sheet-body");if(!i){typeof s=="function"&&s();return}const r=t(this,R).view.getArray(),o=(r==null?void 0:r.length)||0;if(o===0){typeof s=="function"&&s();return}const l=Math.max(0,Math.min(n,o-1));let a=0;if(t(this,Pe)){const f=Math.max(i.scrollHeight-i.clientHeight,1);a=l/Math.max(o-1,1)*f}else{const f=t(this,G);if(!f||f<=0){typeof s=="function"&&s();return}let g=l*f;t(this,R).templateLength;const b=(((c=t(this,R).elements.body.thead)==null?void 0:c.offsetHeight)||0)+(((u=t(this,R).elements.body.tfoot)==null?void 0:u.offsetHeight)||0)+t(this,R).elements.body.tbody.head.offsetHeight,m=t(this,R).querySelector(".ng-sheet-body").offsetHeight||0,y=Math.max(o*f+f*2+b-m,0),x=15e6,w=y>x;let S=1;w&&(S=x/y),a=g*S}p(this,ps,!0),i.scrollTop=a,t(this,Ve).call(this,a),requestAnimationFrame(()=>{requestAnimationFrame(()=>{p(this,ps,!1),typeof s=="function"&&s()})})}};rr=new WeakMap,Us=new WeakMap,R=new WeakMap,Be=new WeakMap,Gs=new WeakMap,te=new WeakMap,G=new WeakMap,me=new WeakMap,ee=new WeakMap,gs=new WeakMap,ps=new WeakMap,Pe=new WeakMap,Ve=new WeakMap,nr=new WeakMap,or=new WeakMap,js=new WeakMap,Ks=new WeakMap,Ys=new WeakMap,bs=new WeakMap,lr=new WeakMap,ar=new WeakMap,cr=new WeakMap,h(wo,"RowManager");let Hn=wo;const mt=16,gt=class gt{static compile(n){var s;const e=n.cloneNode(!0);return gt.resetColIndex(e,e.querySelectorAll("thead tr")),gt.resetColIndex(e,e.querySelectorAll('tbody.body tr[grouping="true"]')),gt.resetColIndex(e,e.querySelectorAll('tbody.body tr:not([grouping="true"])')),gt.resetColIndex(e,e.querySelectorAll("tfoot tr")),A(s=gt,Zs,hl).call(s,e),e}static recompile(n){var e;return gt.resetColIndex(n,n.querySelectorAll("thead tr")),gt.resetColIndex(n,n.querySelectorAll('tbody.body tr[grouping="true"]')),gt.resetColIndex(n,n.querySelectorAll('tbody.body tr:not([grouping="true"])')),gt.resetColIndex(n,n.querySelectorAll("tfoot tr")),A(e=gt,Zs,hl).call(e,n),n}static resetColIndex(n,e){const s=n.querySelectorAll("colgroup col"),i=Array.from({length:e.length},()=>Array(s.length).fill(null));e.forEach((r,o)=>{r.dataset.subrow=o;let l=0;r.querySelectorAll("th, td").forEach(a=>{for(;l<s.length&&i[o][l]!==null;)l++;a.dataset.col=l;const c=a.rowSpan||1,u=a.colSpan||1;for(let f=0;f<c;f++)for(let g=0;g<u;g++)o+f<e.length&&l+g<s.length&&(i[o+f][l+g]=a);l+=u})})}};Zs=new WeakSet,hl=h(function(n){n.querySelectorAll("colgroup col").forEach((e,s)=>{e.setAttribute("data-col",s);const i=e.getAttribute("fixed");n.querySelectorAll(`[data-col="${s}"]`).forEach(r=>{i?r.setAttribute("fixed",i):r.removeAttribute("fixed")})})},"#syncColAttributes"),d(gt,Zs),h(gt,"TableCompiler");let fe=gt;const vo=class vo{constructor(n){d(this,se);d(this,J);d(this,Js,{startRow:-1,startCol:-1,endRow:-1,endCol:-1});E(this,"refresh",h(()=>{this.render()},"refresh"));E(this,"render",h(()=>{var l;const{startRow:n,startCol:e,endRow:s,endCol:i}=t(this,Js),r=t(this,J).querySelectorAll(".ng-sheet-body-content .ng-container-left, .ng-sheet-body-content .ng-container-body, .ng-sheet-body-content .ng-container-right");if(r.forEach(a=>{a.querySelectorAll(".selected, .selected-top, .selected-bottom, .selected-left, .selected-right, .selected-start").forEach(c=>{c.classList.remove("selected","selected-top","selected-bottom","selected-left","selected-right","selected-start")}),a.querySelectorAll("tr.selected-start").forEach(c=>{c.classList.remove("selected-start")})}),n<0||e<0)return;r.forEach(a=>{a.querySelectorAll("tbody tr").forEach(c=>{const{matrixRow:u}=A(this,se,zi).call(this,c);u<0||c.querySelectorAll("td, th").forEach(f=>{const g=parseInt(f.dataset.col,10);if(isNaN(g))return;const b=parseInt(f.rowSpan||1,10),m=parseInt(f.colSpan||1,10),y=u+b-1,x=g+m-1;y>=n&&u<=s&&x>=e&&g<=i&&(f.classList.add("selected"),u<=n&&f.classList.add("selected-top"),y>=s&&f.classList.add("selected-bottom"),g<=e&&f.classList.add("selected-left"),x>=i&&f.classList.add("selected-right"))})})});const o=t(this,J).querySelector(`.ng-sheet-body-content tr[data-matrix-row="${n}"] td[data-col="${e}"]`);o&&(o.classList.add("selected-start"),(l=o.closest("tr"))==null||l.classList.add("selected-start"))},"render"));p(this,J,n),A(this,se,Tl).call(this),v.log("🎯 [CellSelection] Initialized (New Structure Compatible)")}setFocus(n,e){var i;t(this,J).querySelectorAll("tr.selected-start").forEach(r=>{r.classList.remove("selected-start"),r.querySelectorAll("td.selected-start").forEach(o=>{o.classList.remove("selected-start")})});const s=t(this,J).querySelector(`.ng-sheet-body-content tr[data-matrix-row="${n}"] td[data-col="${e}"]`);s&&(s.classList.add("selected-start"),(i=s.closest("tr"))==null||i.classList.add("selected-start"))}setRange(n,e,s,i){let r=Math.min(n,s),o=Math.max(n,s),l=Math.min(e,i),a=Math.max(e,i);const c=t(this,J).querySelectorAll(".ng-sheet-body-content .ng-container-left, .ng-sheet-body-content .ng-container-body, .ng-sheet-body-content .ng-container-right");let u=!0,f=0;for(;u&&f<5;)u=!1,f++,c.forEach(g=>{g.querySelectorAll("tbody tr").forEach(b=>{if(b.classList.contains("nodata"))return;const{matrixRow:m}=A(this,se,zi).call(this,b);m<0||b.querySelectorAll("td, th").forEach(y=>{const x=parseInt(y.dataset.col,10);if(isNaN(x))return;const w=parseInt(y.rowSpan||1,10),S=parseInt(y.colSpan||1,10),L=m+w-1,C=x+S-1;if(L>=r&&m<=o&&C>=l&&x<=a){const T=Math.min(r,m),D=Math.max(o,L),_=Math.min(l,x),rt=Math.max(a,C);(T!==r||D!==o||_!==l||rt!==a)&&(r=T,o=D,l=_,a=rt,u=!0)}})})});p(this,Js,{startRow:r,startCol:l,endRow:o,endCol:a}),this.render()}};J=new WeakMap,Js=new WeakMap,se=new WeakSet,zi=h(function(n){if(!n)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"),r=Array.from(s.querySelectorAll("tr:not(.nodata)")).filter(c=>parseInt(c.dataset.row,10)===e),o=r.indexOf(n),l=r.length>0?r.length:1,a=e*l+(o>=0?o:n.sectionRowIndex%l);return{dataRow:e,subRowIndex:o,matrixRow:a}},"#getMatrixRow"),Tl=h(function(){const n=t(this,J).querySelector(".ng-sheet-body");if(!n){v.log("❌ [CellSelection] .ng-sheet-body 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,J).style.userSelect="none",t(this,J).style.webkitUserSelect="none";const i=s.closest("tr"),{matrixRow:r}=A(this,se,zi).call(this,i),o=parseInt(s.dataset.col,10);if(r<0){t(this,J).style.userSelect="",t(this,J).style.webkitUserSelect="";return}this.setFocus(r,o),this.setRange(r,o,r,o);let l=r,a=o;const c=h(f=>{const g=document.elementFromPoint(f.clientX,f.clientY);let b=g==null?void 0:g.closest("td, th");if(!b||!t(this,J).contains(b)){const w=t(this,J).querySelectorAll(".ng-sheet-body-content tbody tr:not(.nodata) td, .ng-sheet-body-content tbody tr:not(.nodata) th");for(const S of w){const L=S.getBoundingClientRect();if(f.clientX>=L.left&&f.clientX<=L.right&&f.clientY>=L.top&&f.clientY<=L.bottom){b=S;break}}}if(!b||b.dataset.row===void 0||b.dataset.col===void 0||b.closest("tr").classList.contains("nodata"))return;const m=b.closest("tr"),{matrixRow:y}=A(this,se,zi).call(this,m),x=parseInt(b.dataset.col,10);y<0||l===y&&a===x||(l=y,a=x,this.setRange(r,o,y,x))},"onMouseMove"),u=h(()=>{t(this,J).style.userSelect="",t(this,J).style.webkitUserSelect="",document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",u)},"onMouseUp");document.addEventListener("mousemove",c),document.addEventListener("mouseup",u)})},"#initEvents"),h(vo,"CellSelection");let Nn=vo;const Eo=class Eo{constructor(n){d(this,pt);d(this,$);d(this,Qs);d(this,ye,null);d(this,Xt,null);d(this,So,-1);d(this,Ao,-1);d(this,ti,h(n=>{const e=t(this,$).querySelectorAll(`.ng-sheet-body td[data-row="${n}"]`);if(!e||e.length===0)return 0;let s=1/0;return e.forEach(i=>{const r=parseInt(i.dataset.col,10);!isNaN(r)&&window.getComputedStyle(i).display!=="none"&&(s=Math.min(s,r))}),s===1/0?0:s},"#getMinCol"));d(this,ei,h(n=>{const e=t(this,$).querySelectorAll(`.ng-sheet-body td[data-row="${n}"]`);if(!e||e.length===0)return 0;let s=0;return e.forEach(i=>{const r=parseInt(i.dataset.col,10);!isNaN(r)&&window.getComputedStyle(i).display!=="none"&&(s=Math.max(s,r))}),s},"#getMaxCol"));d(this,si,h(n=>{const e=[];return n.forEach(s=>e.push(...Array.from(s.querySelectorAll("td")))),e.length===0?null:(e.sort((s,i)=>parseInt(s.dataset.col,10)-parseInt(i.dataset.col,10)),e[e.length-1])},"#getMaxColCell"));d(this,ii,h((n,e)=>{const s=t(this,$).querySelector(`.ng-sheet-body tr[data-matrix-row="${n}"] td[data-col="${e}"]`)||t(this,$).querySelector(`.ng-sheet-body td[data-col="${e}"]`),i=(s==null?void 0:s.colSpan)||1,r=e+i;return v.log(`🔍 [#getNextCol] current col: ${e}, found td colSpan: ${i}, calculated next col: ${r}`),r},"#getNextCol"));d(this,ri,h((n,e)=>{if(e<=0)return 0;const s=t(this,Xt)?Array.from(t(this,Xt).querySelectorAll("td, th")):[],i=new Set;s.forEach(o=>{const l=parseInt(o.dataset.col,10);!isNaN(l)&&window.getComputedStyle(o).display!=="none"&&i.add(l)}),i.size===0&&t(this,ms).call(this,n).forEach(l=>{Array.from(l.querySelectorAll("td, th")).forEach(a=>{const c=parseInt(a.dataset.col,10);!isNaN(c)&&window.getComputedStyle(a).display!=="none"&&i.add(c)})});const r=Array.from(i).filter(o=>o<e);return r.length===0?Math.max(0,e-1):Math.max(...r)},"#getPreviousCol"));d(this,ms,h(n=>{const e=t(this,$).querySelectorAll(".ng-sheet-body .ng-container-left, .ng-sheet-body .ng-container-body, .ng-sheet-body .ng-container-right"),s=[];return e.forEach(i=>{const r=Array.from(i.querySelectorAll("tbody tr"));for(const o of r){const l=A(this,pt,cs).call(this,o);if(l===n){s.push(o);break}const a=Array.from(o.querySelectorAll("td"));let c=!1;for(const u of a){const f=parseInt(u.rowSpan||1,10);if(f>1&&n>=l&&n<l+f){s.push(o),c=!0;break}}if(c)break}}),s},"#findTargetTrsByMatrix"));d(this,ni,h((n,e,s,i)=>{const r=i!==void 0?i:n*(t(this,$).templateLength||1)+e,o=t(this,$).templateLength||1,l=t(this,$).querySelectorAll(".ng-sheet-body, .ng-container-left, .ng-container-body, .ng-container-right, .ng-part-body"),a=new Set;l.forEach(c=>{c.querySelectorAll("tbody tr").forEach(u=>a.add(u))});for(const c of Array.from(a)){const u=parseInt(c.dataset.row,10);if(isNaN(u))continue;const f=c.closest("tbody"),b=(f?Array.from(f.querySelectorAll(`tr[data-row="${u}"]`)):[c]).indexOf(c);for(const m of Array.from(c.querySelectorAll("td"))){const y=parseInt(m.dataset.col,10),x=parseInt(m.colSpan||1,10),w=parseInt(m.rowSpan||1,10);if(isNaN(y)||window.getComputedStyle(m).display==="none")continue;const S=u,L=b,C=S*o+L,W=C+w-1;if(r>=C&&r<=W&&s>=y&&s<y+x)return m}}return null},"#getNearElement"));p(this,$,n),p(this,Qs,n.getRootNode().host),A(this,pt,kl).call(this),v.log("🎯 [CellNavigation] Initialized (Diagnostic Logging Restored)")}get currentCell(){return t(this,ye)}set currentCell(n){var s;if(!n)return;p(this,ye,n),n.focus({preventScroll:!0}),p(this,Xt,n.closest("tr"));const e=A(this,pt,cs).call(this,t(this,Xt));v.log(`📌 [setCurCell] Active set -> dataRow: ${n.dataset.row}, subrow: ${(s=n.closest("tr"))==null?void 0:s.dataset.subrow}, matrixRow: ${e}, col: ${n.dataset.col}`),t(this,$).selection.setFocus(e,t(this,ye).dataset.col)}moveCell(n){var m;if(!["TH","TD"].includes(n.target.tagName))return;if(!t(this,ye)||!t(this,Xt)){v.log("⚠️ [moveCell] currentCell or currentTr is missing!");return}const e=t(this,ye),s=parseInt(e.dataset.row,10),i=parseInt(e.dataset.col,10),r=t(this,$).templateLength||1,o=A(this,pt,cs).call(this,t(this,Xt));let l=o,a=i;switch(n.code){case"ArrowDown":n.preventDefault(),l=o+(e.rowSpan||1);break;case"ArrowUp":n.preventDefault(),l=Math.max(0,o-(e.rowSpan||1));break;case"ArrowRight":a=t(this,ii).call(this,o,i);break;case"ArrowLeft":a=t(this,ri).call(this,o,i);break;case"Tab":if(n.preventDefault(),n.shiftKey){if(a=t(this,ri).call(this,o,i),a<0&&o>0){l=o-1;const y=t(this,ms).call(this,l),x=t(this,si).call(this,y);a=x?parseInt(x.dataset.col,10):0}}else{a=t(this,ii).call(this,o,i);const y=t(this,ms).call(this,o),x=t(this,si).call(this,y),w=x?parseInt(x.dataset.col,10)+parseInt(x.colSpan||1,10):0;a>=w&&(l=o+1,a=0)}break}switch(n.code){case"ArrowDown":const x=t(this,Qs).data.length*r-1;if(o+(e.rowSpan||1)>x)return;break;case"ArrowUp":if(o<=0)return;break;case"ArrowRight":if(i===a||a>t(this,ei).call(this,s,i))return;break;case"ArrowLeft":if(i===a||a<t(this,ti).call(this,s,i))return;break;case"Tab":if(n.shiftKey){if(i===a||a<t(this,ti).call(this,s,i))return}else if(i===a||a>t(this,ei).call(this,s,i))return;break}v.log("========");const u=(((m=t(this,$).view.getArray())==null?void 0:m.length)||0)*r-1;l=Math.max(0,Math.min(l,u)),v.log(`⌨️ [Key: ${n.code}] Current matrixRow: ${o} -> Target nextMatrixRow: ${l}, nextCol: ${a}`);const f=Math.floor(l/r),g=l%r;h((y=0)=>{let x=t(this,ni).call(this,f,g,a,l);if(x){v.log(`✅ [Found Cell] Attempt ${y} -> dataRow: ${x.dataset.row}, col: ${x.dataset.col}`),this.currentCell=x;const w=A(this,pt,cs).call(this,t(this,Xt));t(this,$).selection.setRange(w,x.dataset.col,w,x.dataset.col),A(this,pt,dl).call(this,x)}else v.log(`📜 [Scroll Trigger] Cell not found in DOM, invoking rowManager.scrollToDataRow(${f})`),t(this,$).rowManager.scrollToDataRow(f,"bottom",()=>{v.log("nextDataRow",f),h(()=>{let S=t(this,ni).call(this,f,g,a,l);if(S){v.log(`✅ [Found After Scroll] RetryLoop success -> dataRow: ${S.dataset.row}`),this.currentCell=S;const L=S.closest("tr"),C=A(this,pt,cs).call(this,L);t(this,$).selection.setRange(C,S.dataset.col,C,S.dataset.col),A(this,pt,dl).call(this,S)}},"retryLoop")()})},"attemptFindAndMove")()}};$=new WeakMap,Qs=new WeakMap,ye=new WeakMap,Xt=new WeakMap,So=new WeakMap,Ao=new WeakMap,pt=new WeakSet,cs=h(function(n){if(!n)return 0;const e=parseInt(n.dataset.row,10)||0,s=t(this,$).templateLength||1,i=parseInt(n.dataset.matrixRow,10);if(!isNaN(i))return i;const r=n.closest("tbody");if(r){const a=Array.from(r.querySelectorAll(`tr[data-row="${e}"]`)).indexOf(n);if(a>=0)return e*s+a}const o=parseInt(n.dataset.subrow,10)||0;return e*s+o},"#getMatrixRowFromTr"),dl=h(function(n){const e=t(this,$).querySelector(".ng-sheet-body"),s=t(this,$).querySelector(".ng-sheet-body .ng-container-body");if(!e||!s)return;const i=n.getBoundingClientRect(),r=e.getBoundingClientRect(),o=s.getBoundingClientRect();v.log(`📐 [DIAGNOSTIC VISIBILITY]
144
144
  - cell.dataset.col: ${n.dataset.col}
145
- - cellRect (left: ${r.left}, right: ${r.right})
146
- - containerRect (left: ${l.left}, right: ${l.right}, width: ${l.width}, scrollLeft: ${s.scrollLeft}, scrollWidth: ${s.scrollWidth}, clientWidth: ${s.clientWidth})
147
- - viewportRect (width: ${o.width})
148
- - headerBody (scrollLeft: ${i==null?void 0:i.scrollLeft}, width: ${a==null?void 0:a.width})
149
- `);const c=r.top<o.top,u=r.bottom>o.bottom;if(c||u){const g=parseInt(n.dataset.row,10),f=n.dataset.col,b=n.closest("tr"),m=(b==null?void 0:b.dataset.subrow)||0;!isNaN(g)&&t(this,$).rowManager&&(v.log("11111111111"),t(this,$).rowManager.scrollToDataRow(g,"top",()=>{const y=t(this,$).querySelector(`.ng-sheet-body tr[data-row="${g}"][data-subrow="${m}"] td[data-col="${f}"]`);if(y){this.currentCell=y;const x=y.closest("tr"),w=A(this,pt,cs).call(this,x);t(this,$).selection.setRange(w,f,w,f)}}))}r.left<l.left?(v.log("↔️ [Scroll X Left] cell out of left bound"),s.scrollLeft-=l.left-r.left+10,t(this,$).scrollToX(s.scrollLeft)):r.right>l.right&&(v.log(`↔️ [Scroll X Right] cell out of right bound. cellRect.right: ${r.right} > containerRect.right: ${l.right}`),s.scrollLeft+=r.right-l.right+10,t(this,$).scrollToX(s.scrollLeft))},"#ensureCellVisible"),ti=new WeakMap,ei=new WeakMap,si=new WeakMap,ii=new WeakMap,ri=new WeakMap,ms=new WeakMap,ni=new WeakMap,kl=h(function(){t(this,$).addEventListener("mousedown",n=>{if(n.button!==0)return;const e=n.target.closest("td, th");e&&(e.dataset.row===void 0||e.dataset.col===void 0||(this.currentCell=e))}),t(this,$).addEventListener("keydown",n=>{["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(n.code)&&this.moveCell(n)})},"#initEvents"),h(Eo,"CellNavigation");let Dn=Eo;const Bi=2,Lo=class Lo{constructor(n){d(this,kt);d(this,X);d(this,Xe);d(this,Ct);d(this,_e);d(this,_t,null);d(this,Tt,null);d(this,Ut,null);d(this,Gt,null);d(this,ys,0);d(this,jt,0);d(this,xe,0);d(this,oi,0);d(this,li,0);d(this,ai,h(n=>{const e=n.target.closest("thead");if(!e)return;const s=n.target.closest("th, td");if(e.querySelectorAll(".resizable-edge").forEach(a=>{a!==s&&a.classList.remove("resizable-edge")}),!s||s.dataset.col===void 0||s.getAttribute("collapsed")==="true")return;const i=s.getBoundingClientRect(),r=n.clientX-i.left,o=r<=Bi,l=i.width-r<=Bi;if(o){const a=s.previousElementSibling;if(!a||a.getAttribute("collapsed")==="true"){s.classList.remove("resizable-edge");return}}o||l?s.classList.add("resizable-edge"):s.classList.remove("resizable-edge")},"#onPointerMove"));d(this,ci,h(n=>{if(v.log(n.actualTarget,n.target),!n.actualTarget.closest("thead"))return;const s=n.actualTarget.closest("th, td");if(v.log(s,n.actualTarget),!s||!s.classList.contains("resizable-edge"))return;n.preventDefault();const i=s.getBoundingClientRect(),r=n.clientX-i.left;let o=s;if(r<=Bi){const y=s.previousElementSibling;if(y&&y.dataset.col!==void 0&&y.getAttribute("collapsed")!=="true")o=y;else if(!s.previousElementSibling)return}p(this,Gt,o),p(this,Ut,A(this,kt,ul).call(this,o));const l=t(this,X).querySelector(`.ng-container-${t(this,Ut)}`);if(!l)return;const a=parseInt(o.dataset.col,10),c=o.colSpan||1;if(p(this,_t,a+c-1),A(this,kt,yn).call(this,o)){p(this,Tt,t(this,_t)+1);const y=l.querySelector(`col[data-col="${t(this,Tt)}"]`);y?p(this,xe,parseInt(y.getAttribute("width"),10)||100):p(this,Tt,null)}else p(this,Tt,null);const g=o.getBoundingClientRect(),f=t(this,X).getBoundingClientRect();p(this,oi,g.width),p(this,li,g.left-f.left);const b=l.querySelector(`col[data-col="${t(this,_t)}"]`),m=b==null?void 0:b.getAttribute("width");p(this,jt,m&&!isNaN(parseInt(m,10))?parseInt(m,10):g.width/c),p(this,ys,n.clientX),t(this,Ct)&&(t(this,Ct).classList.add("active"),A(this,kt,fl).call(this,n.clientX)),window.addEventListener("pointermove",t(this,hi)),window.addEventListener("pointerup",t(this,hr),{once:!0})},"#onPointerDown"));d(this,hi,h(n=>{v.log(n),A(this,kt,fl).call(this,n.clientX)},"#onDragMove"));d(this,hr,h(n=>{var r;window.removeEventListener("pointermove",t(this,hi));const e=n.clientX-t(this,ys),s=A(this,kt,yn).call(this,t(this,Gt));let i=0;if(s&&t(this,Tt)!==null){let o=Math.max(mt,t(this,jt)+e),l=t(this,jt)+t(this,xe)-o;l<mt&&(l=mt,o=t(this,jt)+t(this,xe)-mt),this.setColumnWidth(t(this,_t),o,t(this,Ut)),this.setColumnWidth(t(this,Tt),l,t(this,Ut)),i=o}else{const o=Math.max(mt,t(this,jt)+e);t(this,_t)!==null&&t(this,Ut)&&(this.setColumnWidth(t(this,_t),o,t(this,Ut)),i=o)}if(t(this,Gt)){const o=t(this,Gt);o.getAttribute("collapsed")!=="true"&&i>20&&(o.dataset.expandWidth=String(i))}t(this,Ct)&&((r=t(this,_e))==null||r.classList.add("fade-out"),setTimeout(()=>{var o;t(this,Ct).classList.remove("active"),(o=t(this,_e))==null||o.classList.remove("fade-out")},150)),p(this,_t,null),p(this,Tt,null),p(this,Ut,null),p(this,Gt,null)},"#onDragEnd"));d(this,di,h(n=>{let s=n.target.closest("th, td");if(!s||!s.classList.contains("resizable-edge"))return;const i=s.getBoundingClientRect();n.clientX-i.left<=Bi&&(s=s.previousElementSibling);const o=parseInt(s.dataset.col,10),l=t(this,X).querySelector(`tbody.body [data-col="${o}"]`);if(!l||!l.dataset.bind||l.classList.contains("CELL-RADIO"))return;let a=0;Array.from(l.firstElementChild.children).forEach(y=>{switch(y.tagName){case"SPAN":a+=8;break;case"DIV":a+=8;break;case"BUTTON":a+=32;break;case"SELECT":a+=32;break;case"INPUT":switch((y.type||"text").toLowerCase()){case"checkbox":case"radio":a+=12;break;case"button":case"submit":case"reset":case"image":a+=16;break;case"color":case"file":case"range":a+=24;break;case"hidden":a+=0;break;case"text":case"search":case"tel":case"url":case"email":case"password":case"number":case"date":case"time":case"datetime-local":case"month":case"week":default:a+=16;break}break}}),v.log(a);const c=t(this,Xe).fields.get().indexOf(l.dataset.bind),g=window.getComputedStyle(l).font||"12px sans-serif",f=s.innerText||"";let m=(nine.measureTextSize(f,g).width||0)+16;t(this,Xe).execute(()=>{t(this,X).view.getArray().forEach((x,w)=>{const S=String(l.dataset.expr?t(this,Xe).exprEngine.evaluate(l.dataset.expr,x,w):x.v[c]??"").trim(),R=nine.measureTextSize(S,g);R.width&&R.width>m&&(m=R.width)});const y=Math.max(32,Math.min(400,Math.ceil(m)+a));this.setColumnWidth(l.dataset.col,y,A(this,kt,ul).call(this,s))})},"#onDblClick"));var e;p(this,X,n),p(this,Xe,n.getRootNode().host),p(this,Ct,t(this,X).querySelector(".ng-col-resizer-panel")),p(this,_e,(e=t(this,Ct))==null?void 0:e.querySelector(".resizer-overlay")),this.bindEvents()}destroy(){t(this,X).removeEventListener("pointermove",t(this,ai)),t(this,X).removeEventListener("pointerdown",t(this,ci)),t(this,X).removeEventListener("dblclick",t(this,di))}refreshLayout(n="body"){var r,o;const e=Array.from(t(this,X).querySelectorAll(`.ng-container-${n}`));if(e.length===0)return;if(!(n==="left"||n==="right")&&(t(this,X).isAutoFitCol||((r=e[0].querySelector("table"))==null?void 0:r.getAttribute("auto-fit-col"))==="true"))e.forEach(l=>{l.querySelectorAll("table").forEach(c=>{})});else{const l=e[0].querySelector("table colgroup");if(!l)return;let a=0;const c={};Array.from(l.querySelectorAll("col")).forEach(u=>{const g=u.getAttribute("data-col"),f=parseInt(u.getAttribute("width"),10);isNaN(f)||(c[g]=f,a+=f)}),e.forEach(u=>{const g=u.querySelectorAll("table");v.log("====================",e,n),n==="body"?g.forEach(f=>{f.style.width=`${a}px`}):(u.style.flex=`0 0 ${a}px`,u.style.width=`${a}px`,u.style.minWidth=`${a}px`,u.style.maxWidth=`${a}px`,g.forEach(f=>{f.style.width=`${a}px`,f.style.minWidth=`${a}px`,f.style.maxWidth=`${a}px`,Object.entries(c).forEach(([b,m])=>{f.querySelectorAll(`th[data-col="${b}"], td[data-col="${b}"]`).forEach(y=>{y.style.width=`${m}px`,y.style.minWidth=`${m}px`,y.style.maxWidth=`${m}px`})})}))})}(o=t(this,X).querySelector("nine-table-hscrollbar"))==null||o.refresh()}setColumnWidth(n,e,s=null){var a,c;v.log("setColumnWidth");let i=[];if(i=Array.from(t(this,X).querySelectorAll(`table colgroup col[data-col="${n}"]`)),i.length===0)return;const r=i[0].closest(".ng-container-left, .ng-container-body, .ng-container-right"),o=s||(r!=null&&r.classList.contains("ng-container-left")?"left":r!=null&&r.classList.contains("ng-container-right")?"right":"body");i.forEach(u=>{u.setAttribute("width",e),u.style.width=`${e}px`,v.log(u,e)});const l=(a=t(this,X).sourceTable)==null?void 0:a.querySelector(`colgroup col[data-col="${n}"]`);l&&(l.setAttribute("width",e),l.style.width=`${e}px`),this.refreshLayout(o),(o==="left"||o==="right")&&this.refreshLayout("body"),(c=t(this,X).rowManager)==null||c.refresh()}bindEvents(){t(this,X).addEventListener("pointermove",t(this,ai)),t(this,X).addDebounseEventListener("dblclick",t(this,di),"pointerdown",t(this,ci))}};X=new WeakMap,Xe=new WeakMap,Ct=new WeakMap,_e=new WeakMap,_t=new WeakMap,Tt=new WeakMap,Ut=new WeakMap,Gt=new WeakMap,ys=new WeakMap,jt=new WeakMap,xe=new WeakMap,oi=new WeakMap,li=new WeakMap,kt=new WeakSet,yn=h(function(n){if(t(this,X).isAutoFitCol)return!0;const e=n==null?void 0:n.closest("table");return!!(e&&e.getAttribute("auto-fit-col")==="true")},"#checkIsAutoFit"),ul=h(function(n){const e=n.closest(".ng-container-left, .ng-container-body, .ng-container-right");return e?e.classList.contains("ng-container-left")?"left":e.classList.contains("ng-container-right")?"right":"body":null},"#getContainerType"),ai=new WeakMap,ci=new WeakMap,fl=h(function(n){var c;let e=n-t(this,ys);const s=A(this,kt,yn).call(this,t(this,Gt));if(s&&t(this,Tt)!==null){const u=t(this,xe)-mt,g=-(t(this,jt)-mt);e=Math.max(g,Math.min(e,u))}const i=Math.max(mt,t(this,jt)+e),r=t(this,Gt).getBoundingClientRect();let o=n-r.left;if(s&&t(this,Tt)!==null){const u=t(this,oi)+(t(this,xe)-mt);o=Math.min(o,u)}const l=Math.max(mt,o);t(this,Ct)&&(t(this,Ct).style.setProperty("--tooltip-left",`${t(this,li)}px`),t(this,Ct).style.setProperty("--tooltip-width",`${l}px`));const a=(c=t(this,_e))==null?void 0:c.querySelector(".size-badge");a&&(a.textContent=`${Math.round(i)}px`)},"#updatePositions"),hi=new WeakMap,hr=new WeakMap,di=new WeakMap,h(Lo,"ColResizer");let $n=Lo;const Ro=class Ro{constructor(n){d(this,st);d(this,K);d(this,P);d(this,et);d(this,we,!1);d(this,ie,null);d(this,re,null);d(this,Ft,null);d(this,ui,0);d(this,Ue,null);d(this,fi,h(n=>{if(!A(this,st,Il).call(this)||!n.target.closest(".ng-sheet-header"))return;const s=n.target.closest("th, td");if(!s||s.classList.contains("resizable-edge")||["INPUT","BUTTON"].includes(n.target.tagName)||s.dataset.col===void 0)return;n.preventDefault();const i=n.clientX,r=n.clientY,o=h(()=>{t(this,Ue)&&(clearTimeout(t(this,Ue)),p(this,Ue,null)),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",o),window.removeEventListener("pointercancel",o)},"cancelTimer"),l=h(a=>{Math.hypot(a.clientX-i,a.clientY-r)>5&&o()},"onPointerMovePending");p(this,Ue,setTimeout(()=>{o(),A(this,st,Hl).call(this,n,s)},500)),window.addEventListener("pointermove",l),window.addEventListener("pointerup",o,{once:!0}),window.addEventListener("pointercancel",o,{once:!0})},"#onPointerDown"));d(this,gi,h(n=>{var i,r;if(!t(this,we))return;A(this,st,gl).call(this,n.clientX),t(this,P)&&(t(this,P).style.pointerEvents="none"),t(this,et)&&(t(this,et).style.pointerEvents="none");const e=A(this,st,ql).call(this,n.clientX,n.clientY),s=e==null?void 0:e.closest(".ng-sheet-header th, .ng-sheet-header td");if(s&&s.dataset.col!==void 0){const o=parseInt(s.dataset.col,10),l=t(this,K).getBoundingClientRect(),a=s.closest("table");let c=1/0,u=-1/0;if(a&&a.querySelectorAll("thead th, thead td").forEach(z=>{if(z.dataset.col===void 0)return;const tt=parseInt(z.dataset.col,10),St=z.colSpan||1,V=tt+St-1;if(tt<=o&&V>=o){const $s=z.getBoundingClientRect();c=Math.min(c,$s.left),u=Math.max(u,$s.right)}}),c===1/0){const z=s.getBoundingClientRect();c=z.left,u=z.right}const g=c+(u-c)/2;let f=0,b=0;if(n.clientX<g)f=o,b=c-l.left;else{const z=s.colSpan||1;f=o+z,b=u-l.left}const m=A(this,st,xn).call(this,t(this,ie)),y=m.colSpan,x=m.rowIndex,w=t(this,ie).rowSpan||1,S=x+w-1,R=((i=s.closest("tr"))==null?void 0:i.sectionRowIndex)??0,C=s.rowSpan||1,W=R+C-1,T=!(S<R||x>W);let D=!1;if(m.parentGroupRange){const{startCol:z,endCol:tt}=m.parentGroupRange;(f<z||f+y-1>tt)&&(D=!0)}let _=!1;if(a){const z=a.querySelectorAll("thead th[colspan], thead td[colspan]");for(const tt of z){if(tt===t(this,ie))continue;const St=((r=tt.closest("tr"))==null?void 0:r.sectionRowIndex)??0,V=tt.rowSpan||1,$s=St+V-1;if(!!(S<St||x>$s))continue;const Te=parseInt(tt.dataset.col,10),mn=tt.colSpan||1,ke=Te+mn-1;if(f>Te&&f<ke+1){_=!0;break}const rl=f+y-1;if(f>Te&&f<=ke&&rl>ke||f<Te&&rl>=Te&&rl<ke){_=!0;break}}}const rt=f>=m.startCol&&f<=m.endCol+1;if(!T||rt||D||_||!m.isValidGroup)p(this,Ft,null),t(this,et)&&(t(this,et).style.display="none"),t(this,P)&&t(this,P).classList.add("invalid");else if(p(this,Ft,f),t(this,P)&&t(this,P).classList.remove("invalid"),t(this,et)){const St=s.closest(".ng-sheet-header").getBoundingClientRect().top-l.top,V=l.height-St;t(this,et).style.top=`${St}px`,t(this,et).style.height=`${V}px`,t(this,et).style.left=`${b-1}px`,t(this,et).style.display="block"}}else t(this,et)&&(t(this,et).style.display="none"),t(this,P)&&t(this,P).classList.add("invalid"),p(this,Ft,null)},"#onPointerMove"));d(this,dr,h(n=>{t(this,we)&&(window.removeEventListener("pointermove",t(this,gi)),document.body.style.cursor="",t(this,P)&&(t(this,P).style.display="none",t(this,P).replaceChildren()),t(this,et)&&(t(this,et).style.display="none"),t(this,Ft)!==null&&t(this,re)!==null&&t(this,Ft)!==t(this,re)&&t(this,Ft)!==t(this,re)+1&&this.moveColumn(t(this,re),t(this,Ft)),p(this,we,!1),p(this,ie,null),p(this,re,null),p(this,Ft,null))},"#onPointerUp"));p(this,K,n),p(this,P,t(this,K).querySelector(".ng-col-mover-grip")),p(this,et,t(this,K).querySelector(".ng-col-mover-indi")),this.bindEvents()}bindEvents(){t(this,K).addEventListener("pointerdown",t(this,fi))}moveColumn(n,e){v.log(t(this,K).sourceTable.cloneNode(!0));const s=t(this,K).sourceTable.querySelector("colgroup"),i=s.querySelector(`col[data-col="${e}"]`),r=A(this,st,xn).call(this,t(this,ie));if(!r||!r.isValidGroup)return;const o=r.colSpan,l=h(u=>u>=n&&u<n+o,"isInRange"),a=t(this,K).querySelector(`.ng-sheet-body-content col[data-col="${e}"]`),c=a!=null&&a.closest(".ng-container-left")?"left":a!=null&&a.closest(".ng-container-right")?"right":null;s.querySelectorAll("col").forEach(u=>{l(parseInt(u.getAttribute("data-col"),10))&&(c?u.setAttribute("fixed",c):u.removeAttribute("fixed"),s.insertBefore(u,i))}),["thead","tbody","tfoot"].forEach(u=>{t(this,K).sourceTable.querySelectorAll(`${u} tr`).forEach(g=>{const f=Array.from(g.children),b=f.find(m=>parseInt(m.dataset.col,10)>=e);f.forEach(m=>{l(parseInt(m.dataset.col,10))&&g.insertBefore(m,b||null)})})}),t(this,K).recompileAndRefresh()}destroy(){t(this,K).removeEventListener("pointerdown",t(this,fi))}};K=new WeakMap,P=new WeakMap,et=new WeakMap,we=new WeakMap,ie=new WeakMap,re=new WeakMap,Ft=new WeakMap,ui=new WeakMap,Ue=new WeakMap,st=new WeakSet,Il=h(function(){var e;const n=(e=t(this,K).getRootNode())==null?void 0:e.host;return t(this,K).getAttribute("col-movable")==="true"||(n==null?void 0:n.getAttribute("col-movable"))==="true"},"#checkIsMovable"),ql=h(function(n,e){const s=t(this,K).getRootNode();let i=s.elementFromPoint?s.elementFromPoint(n,e):document.elementFromPoint(n,e);for(;i&&i.shadowRoot&&i.shadowRoot.elementFromPoint;){const r=i.shadowRoot.elementFromPoint(n,e);if(!r||r===i)break;i=r}return i},"#getDeepElementFromPoint"),xn=h(function(n){var f,b;if(!n||n.dataset.col===void 0)return null;const e=parseInt(n.dataset.col,10),s=n.colSpan||1,i=e+s-1,r=((f=n.closest("tr"))==null?void 0:f.sectionRowIndex)??0,o=n.closest("table");if(!o)return{startCol:e,colSpan:s,endCol:i,rowIndex:r,isGroup:!1,parentGroupRange:null,isValidGroup:!0};const l=o.querySelectorAll("thead th, thead td");let a=!1,c=!0,u=null;for(const m of l){if(m===n||m.dataset.col===void 0)continue;const y=parseInt(m.dataset.col,10),x=m.colSpan||1,w=y+x-1;(((b=m.closest("tr"))==null?void 0:b.sectionRowIndex)??0)<r&&y<=e&&w>=i&&x>s&&(u?(u.startCol=Math.max(u.startCol,y),u.endCol=Math.min(u.endCol,w)):u={startCol:y,endCol:w}),!(w<e||y>i)&&(y>=e&&w<=i?x<s&&(a=!0):(y<e||w>i)&&(y<=e&&w>=i||(c=!1)))}const g=a&&c;return{startCol:e,colSpan:g?s:1,endCol:g?i:e,rowIndex:r,isGroup:g,parentGroupRange:u,isValidGroup:c}},"#getColGroupRange"),Ml=h(function(n){const e=A(this,st,xn).call(this,n);if(!e)return null;const{startCol:s,endCol:i,isGroup:r}=e,o=n.closest("table");if(!o)return null;let l=1/0,a=-1/0,c=1/0,u=-1/0;const g=[];if(o.querySelectorAll("thead th, thead td").forEach(y=>{if(y.dataset.col===void 0)return;const x=parseInt(y.dataset.col,10),w=y.colSpan||1,S=x+w-1;if(r?x>=s&&S<=i:y===n){const C=y.getBoundingClientRect();l=Math.min(l,C.left),a=Math.max(a,C.right),c=Math.min(c,C.top),u=Math.max(u,C.bottom);const W=window.getComputedStyle(y);g.push({el:y,rect:C,style:W})}}),g.length===0)return null;const f=a-l,b=u-c,m=document.createElement("div");return m.className="grip-header-content",m.style.position="relative",m.style.width=`${f}px`,m.style.height=`${b}px`,g.forEach(({el:y,rect:x,style:w})=>{const S=y.cloneNode(!0);S.style.position="absolute",S.style.left=`${x.left-l}px`,S.style.top=`${x.top-c}px`,S.style.width=`${x.width}px`,S.style.minWidth=`${x.width}px`,S.style.maxWidth="none",S.style.height=`${x.height}px`,S.style.boxSizing="border-box",S.style.margin="0",S.style.backgroundColor=w.backgroundColor!=="transparent"&&w.backgroundColor!=="rgba(0, 0, 0, 0)"?w.backgroundColor:"#f9fafb",S.style.color=w.color,S.style.font=w.font,S.style.fontWeight=w.fontWeight,S.style.fontSize=w.fontSize,S.style.textAlign=w.textAlign,S.style.padding=w.padding,S.style.border=w.border,S.style.borderRight=w.borderRight,S.style.borderBottom=w.borderBottom,S.style.display="flex",S.style.alignItems="center",S.style.justifyContent=w.textAlign==="center"?"center":w.textAlign==="right"?"flex-end":"flex-start",m.appendChild(S)}),{element:m,bounds:{left:l,right:a,top:c,bottom:u,width:f,height:b}}},"#createGroupHeaderPreview"),fi=new WeakMap,Hl=h(function(n,e){if(t(this,we))return;const s=A(this,st,Ml).call(this,e);if(!s)return;p(this,we,!0),p(this,ie,e),p(this,re,parseInt(e.dataset.col,10));const i=t(this,K).getBoundingClientRect(),{bounds:r,element:o}=s;if(p(this,ui,n.clientX-r.left),t(this,P)){t(this,P).replaceChildren(o);const l=r.top-i.top,a=i.height-l;t(this,P).style.width=`${r.width}px`,t(this,P).style.height=`${a}px`,t(this,P).style.top=`${l}px`,t(this,P).style.display="block",A(this,st,gl).call(this,n.clientX)}document.body.style.cursor="move",window.addEventListener("pointermove",t(this,gi)),window.addEventListener("pointerup",t(this,dr),{once:!0})},"#startDrag"),gi=new WeakMap,gl=h(function(n){if(!t(this,P))return;const e=t(this,K).getBoundingClientRect(),s=n-e.left-t(this,ui);t(this,P).style.left=`${s}px`},"#updateGripPosition"),dr=new WeakMap,h(Ro,"ColMover");let Fn=Ro;const Co=class Co{constructor(n){d(this,ve);p(this,ve,n)}getFixState(n,e){if(!n||!e)return"none";const s=n.closest(".ng-container-left, .ng-container-right, .ng-container-body");if(s!=null&&s.classList.contains("ng-container-left"))return"left";if(s!=null&&s.classList.contains("ng-container-right"))return"right";const i=parseInt(n.dataset.col,10);if(!isNaN(i)){const r=e.querySelector(`colgroup col[data-col="${i}"]`),o=r==null?void 0:r.getAttribute("fixed");if(o)return o}return"none"}canFixColumn(n,e){if(!n||n.tagName!=="TH"||!e)return!1;const s=parseInt(n.dataset.col,10),i=n.colSpan||1;if(isNaN(s))return!1;const r=s+i-1,o=Array.from(e.querySelectorAll("thead tr"));if(o.length<=1)return!0;for(const l of o){const a=Array.from(l.querySelectorAll("th, td"));let c=!1;for(const u of a){const g=parseInt(u.dataset.col,10),f=u.colSpan||1,b=g+f-1;if(g<=r&&r<b)return!1;if(b===r){c=!0;break}}if(!c)return!1}return!0}executeFixToggle(n,e,s="left"){var u,g;if(!t(this,ve)||!e)return;const i=t(this,ve).sourceTable;if(!i)return;const r=parseInt(e.dataset.col,10),o=e.colSpan||1,l=r+o-1;if(isNaN(l))return;const a=i.querySelector("colgroup");if(!a)return;const c=Array.from(a.querySelectorAll("col"));if(n==="fix-column")c.forEach(f=>{parseInt(f.getAttribute("data-col"),10)<=l&&f.setAttribute("fixed",s)}),["thead","tbody","tfoot"].forEach(f=>{i.querySelectorAll(`${f} tr`).forEach(b=>{Array.from(b.children).forEach(m=>{const y=parseInt(m.dataset.col,10);!isNaN(y)&&y<=l&&m.setAttribute("fixed",s)})})});else if(n==="unfix-column"){let f=r;["thead","tbody","tfoot"].forEach(m=>{i.querySelectorAll(`${m} tr`).forEach((y,x)=>{Array.from(y.children).forEach(w=>{const S=parseInt(w.dataset.col,10),R=w.colSpan||1,C=S+R-1,W=w.rowSpan||1,T=y.sectionRowIndex??x;T+W-1<w.closest("tr").sectionRowIndex||T>w.closest("tr").sectionRowIndex+W-1,!(C<r||S>l)&&(f=Math.min(f,S))})})}),c.forEach(m=>{parseInt(m.getAttribute("data-col"),10)>=f&&m.removeAttribute("fixed")});let b=!1;c.forEach(m=>{b?m.removeAttribute("fixed"):m.getAttribute("fixed")||(b=!0)}),["thead","tbody","tfoot"].forEach(m=>{i.querySelectorAll(`${m} tr`).forEach(y=>{Array.from(y.children).forEach(x=>{const w=parseInt(x.dataset.col,10);if(isNaN(w))return;const S=c.find(C=>parseInt(C.getAttribute("data-col"),10)===w),R=S==null?void 0:S.getAttribute("fixed");R?x.setAttribute("fixed",R):x.removeAttribute("fixed")})})})}v.log(t(this,ve).sourceTable),(g=(u=t(this,ve)).recompileAndRefresh)==null||g.call(u)}};ve=new WeakMap,h(Co,"ColFixManager");let Pi=Co;const ko=class ko extends HTMLElement{constructor(){super(...arguments);d(this,pr);d(this,Wt);d(this,ne);d(this,bt);d(this,oe);d(this,Kt);E(this,"currentCol",null);d(this,ur,h(()=>{t(this,fr).call(this),p(this,Wt,this.closest("nine-table-sheet")),p(this,ne,this.getRootNode().host),p(this,bt,this.querySelector("nine-table-simple")),v.log("1***********************",t(this,bt)),setTimeout(()=>{p(this,oe,t(this,bt).shadowRoot.querySelector("nine-table-sheet")),v.log("2***********************",t(this,oe))}),this.querySelector(".search-box").addEventListener("focusin",e=>{e.stopPropagation()}),this.querySelector(".search-box").addEventListener("input",t(this,mr)),this.querySelector("#chkSelectAll").addEventListener("change",t(this,yr)),this.querySelector("#btnOk").addEventListener("click",t(this,br))},"#init"));d(this,fr,h(()=>{this.innerHTML=`
145
+ - cellRect (left: ${i.left}, right: ${i.right})
146
+ - containerRect (left: ${o.left}, right: ${o.right}, width: ${o.width}, scrollLeft: ${s.scrollLeft}, scrollWidth: ${s.scrollWidth}, clientWidth: ${s.clientWidth})
147
+ - viewportRect (width: ${r.width})
148
+ `);const l=i.top<r.top,a=i.bottom>r.bottom;if(l||a){const c=parseInt(n.dataset.row,10),u=n.dataset.col,f=n.closest("tr"),g=(f==null?void 0:f.dataset.subrow)||0;!isNaN(c)&&t(this,$).rowManager&&t(this,$).rowManager.scrollToDataRow(c,"top",()=>{const b=t(this,$).querySelector(`.ng-sheet-body tr[data-row="${c}"][data-subrow="${g}"] td[data-col="${u}"]`);if(b){this.currentCell=b;const m=b.closest("tr"),y=A(this,pt,cs).call(this,m);t(this,$).selection.setRange(y,u,y,u)}})}i.left<o.left?(v.log("↔️ [Scroll X Left] cell out of left bound"),s.scrollLeft-=o.left-i.left+10,t(this,$).scrollToX(s.scrollLeft)):i.right>o.right&&(v.log(`↔️ [Scroll X Right] cell out of right bound. cellRect.right: ${i.right} > containerRect.right: ${o.right}`),s.scrollLeft+=i.right-o.right+10,t(this,$).scrollToX(s.scrollLeft))},"#ensureCellVisible"),ti=new WeakMap,ei=new WeakMap,si=new WeakMap,ii=new WeakMap,ri=new WeakMap,ms=new WeakMap,ni=new WeakMap,kl=h(function(){t(this,$).addEventListener("mousedown",n=>{if(n.button!==0)return;const e=n.target.closest("td, th");e&&(e.dataset.row===void 0||e.dataset.col===void 0||(this.currentCell=e))}),t(this,$).addEventListener("keydown",n=>{["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(n.code)&&this.moveCell(n)})},"#initEvents"),h(Eo,"CellNavigation");let Dn=Eo;const Bi=2,Ro=class Ro{constructor(n){d(this,Tt);d(this,X);d(this,Xe);d(this,Lt);d(this,_e);d(this,_t,null);d(this,Ct,null);d(this,Ut,null);d(this,Gt,null);d(this,ys,0);d(this,jt,0);d(this,xe,0);d(this,oi,0);d(this,li,0);d(this,ai,h(n=>{const e=n.target.closest("thead");if(!e)return;const s=n.target.closest("th, td");if(e.querySelectorAll(".resizable-edge").forEach(a=>{a!==s&&a.classList.remove("resizable-edge")}),!s||s.dataset.col===void 0||s.getAttribute("collapsed")==="true")return;const i=s.getBoundingClientRect(),r=n.clientX-i.left,o=r<=Bi,l=i.width-r<=Bi;if(o){const a=s.previousElementSibling;if(!a||a.getAttribute("collapsed")==="true"){s.classList.remove("resizable-edge");return}}o||l?s.classList.add("resizable-edge"):s.classList.remove("resizable-edge")},"#onPointerMove"));d(this,ci,h(n=>{if(v.log(n.actualTarget,n.target),!n.actualTarget.closest("thead"))return;const s=n.actualTarget.closest("th, td");if(v.log(s,n.actualTarget),!s||!s.classList.contains("resizable-edge"))return;n.preventDefault();const i=s.getBoundingClientRect(),r=n.clientX-i.left;let o=s;if(r<=Bi){const y=s.previousElementSibling;if(y&&y.dataset.col!==void 0&&y.getAttribute("collapsed")!=="true")o=y;else if(!s.previousElementSibling)return}p(this,Gt,o),p(this,Ut,A(this,Tt,ul).call(this,o));const l=t(this,X).querySelector(`.ng-container-${t(this,Ut)}`);if(!l)return;const a=parseInt(o.dataset.col,10),c=o.colSpan||1;if(p(this,_t,a+c-1),A(this,Tt,yn).call(this,o)){p(this,Ct,t(this,_t)+1);const y=l.querySelector(`col[data-col="${t(this,Ct)}"]`);y?p(this,xe,parseInt(y.getAttribute("width"),10)||100):p(this,Ct,null)}else p(this,Ct,null);const f=o.getBoundingClientRect(),g=t(this,X).getBoundingClientRect();p(this,oi,f.width),p(this,li,f.left-g.left);const b=l.querySelector(`col[data-col="${t(this,_t)}"]`),m=b==null?void 0:b.getAttribute("width");p(this,jt,m&&!isNaN(parseInt(m,10))?parseInt(m,10):f.width/c),p(this,ys,n.clientX),t(this,Lt)&&(t(this,Lt).classList.add("active"),A(this,Tt,fl).call(this,n.clientX)),window.addEventListener("pointermove",t(this,hi)),window.addEventListener("pointerup",t(this,hr),{once:!0})},"#onPointerDown"));d(this,hi,h(n=>{v.log(n),A(this,Tt,fl).call(this,n.clientX)},"#onDragMove"));d(this,hr,h(n=>{var r;window.removeEventListener("pointermove",t(this,hi));const e=n.clientX-t(this,ys),s=A(this,Tt,yn).call(this,t(this,Gt));let i=0;if(s&&t(this,Ct)!==null){let o=Math.max(mt,t(this,jt)+e),l=t(this,jt)+t(this,xe)-o;l<mt&&(l=mt,o=t(this,jt)+t(this,xe)-mt),this.setColumnWidth(t(this,_t),o,t(this,Ut)),this.setColumnWidth(t(this,Ct),l,t(this,Ut)),i=o}else{const o=Math.max(mt,t(this,jt)+e);t(this,_t)!==null&&t(this,Ut)&&(this.setColumnWidth(t(this,_t),o,t(this,Ut)),i=o)}if(t(this,Gt)){const o=t(this,Gt);o.getAttribute("collapsed")!=="true"&&i>20&&(o.dataset.expandWidth=String(i))}t(this,Lt)&&((r=t(this,_e))==null||r.classList.add("fade-out"),setTimeout(()=>{var o;t(this,Lt).classList.remove("active"),(o=t(this,_e))==null||o.classList.remove("fade-out")},150)),p(this,_t,null),p(this,Ct,null),p(this,Ut,null),p(this,Gt,null)},"#onDragEnd"));d(this,di,h(n=>{let s=n.target.closest("th, td");if(!s||!s.classList.contains("resizable-edge"))return;const i=s.getBoundingClientRect();n.clientX-i.left<=Bi&&(s=s.previousElementSibling);const o=parseInt(s.dataset.col,10),l=t(this,X).querySelector(`tbody.body [data-col="${o}"]`);if(!l||!l.dataset.bind||l.classList.contains("CELL-RADIO"))return;let a=0;Array.from(l.firstElementChild.children).forEach(y=>{switch(y.tagName){case"SPAN":a+=8;break;case"DIV":a+=8;break;case"BUTTON":a+=32;break;case"SELECT":a+=32;break;case"INPUT":switch((y.type||"text").toLowerCase()){case"checkbox":case"radio":a+=12;break;case"button":case"submit":case"reset":case"image":a+=16;break;case"color":case"file":case"range":a+=24;break;case"hidden":a+=0;break;case"text":case"search":case"tel":case"url":case"email":case"password":case"number":case"date":case"time":case"datetime-local":case"month":case"week":default:a+=16;break}break}}),v.log(a);const c=t(this,Xe).fields.get().indexOf(l.dataset.bind),f=window.getComputedStyle(l).font||"12px sans-serif",g=s.innerText||"";let m=(nine.measureTextSize(g,f).width||0)+16;t(this,Xe).execute(()=>{t(this,X).view.getArray().forEach((x,w)=>{const S=String(l.dataset.expr?t(this,Xe).exprEngine.evaluate(l.dataset.expr,x,w):x.v[c]??"").trim(),L=nine.measureTextSize(S,f);L.width&&L.width>m&&(m=L.width)});const y=Math.max(32,Math.min(400,Math.ceil(m)+a));this.setColumnWidth(l.dataset.col,y,A(this,Tt,ul).call(this,s))})},"#onDblClick"));var e;p(this,X,n),p(this,Xe,n.getRootNode().host),p(this,Lt,t(this,X).querySelector(".ng-col-resizer-panel")),p(this,_e,(e=t(this,Lt))==null?void 0:e.querySelector(".resizer-overlay")),this.bindEvents()}destroy(){t(this,X).removeEventListener("pointermove",t(this,ai)),t(this,X).removeEventListener("pointerdown",t(this,ci)),t(this,X).removeEventListener("dblclick",t(this,di))}refreshLayout(n="body"){var r,o;const e=Array.from(t(this,X).querySelectorAll(`.ng-container-${n}`));if(e.length===0)return;if(!(n==="left"||n==="right")&&(t(this,X).isAutoFitCol||((r=e[0].querySelector("table"))==null?void 0:r.getAttribute("auto-fit-col"))==="true"))e.forEach(l=>{l.querySelectorAll("table").forEach(c=>{})});else{const l=e[0].querySelector("table colgroup");if(!l)return;let a=0;const c={};Array.from(l.querySelectorAll("col")).forEach(u=>{const f=u.getAttribute("data-col"),g=parseInt(u.getAttribute("width"),10);isNaN(g)||(c[f]=g,a+=g)}),e.forEach(u=>{const f=u.querySelectorAll("table");v.log("====================",e,n),n==="body"?f.forEach(g=>{g.style.width=`${a}px`}):(u.style.flex=`0 0 ${a}px`,u.style.width=`${a}px`,u.style.minWidth=`${a}px`,u.style.maxWidth=`${a}px`,f.forEach(g=>{g.style.width=`${a}px`,g.style.minWidth=`${a}px`,g.style.maxWidth=`${a}px`,Object.entries(c).forEach(([b,m])=>{g.querySelectorAll(`th[data-col="${b}"], td[data-col="${b}"]`).forEach(y=>{y.style.width=`${m}px`,y.style.minWidth=`${m}px`,y.style.maxWidth=`${m}px`})})}))})}(o=t(this,X).querySelector("nine-table-hscrollbar"))==null||o.refresh()}setColumnWidth(n,e,s=null){var a,c;v.log("setColumnWidth");let i=[];if(i=Array.from(t(this,X).querySelectorAll(`table colgroup col[data-col="${n}"]`)),i.length===0)return;const r=i[0].closest(".ng-container-left, .ng-container-body, .ng-container-right"),o=s||(r!=null&&r.classList.contains("ng-container-left")?"left":r!=null&&r.classList.contains("ng-container-right")?"right":"body");i.forEach(u=>{u.setAttribute("width",e),u.style.width=`${e}px`,v.log(u,e)});const l=(a=t(this,X).sourceTable)==null?void 0:a.querySelector(`colgroup col[data-col="${n}"]`);l&&(l.setAttribute("width",e),l.style.width=`${e}px`),this.refreshLayout(o),(o==="left"||o==="right")&&this.refreshLayout("body"),(c=t(this,X).rowManager)==null||c.refresh()}bindEvents(){t(this,X).addEventListener("pointermove",t(this,ai)),t(this,X).addDebounseEventListener("dblclick",t(this,di),"pointerdown",t(this,ci))}};X=new WeakMap,Xe=new WeakMap,Lt=new WeakMap,_e=new WeakMap,_t=new WeakMap,Ct=new WeakMap,Ut=new WeakMap,Gt=new WeakMap,ys=new WeakMap,jt=new WeakMap,xe=new WeakMap,oi=new WeakMap,li=new WeakMap,Tt=new WeakSet,yn=h(function(n){if(t(this,X).isAutoFitCol)return!0;const e=n==null?void 0:n.closest("table");return!!(e&&e.getAttribute("auto-fit-col")==="true")},"#checkIsAutoFit"),ul=h(function(n){const e=n.closest(".ng-container-left, .ng-container-body, .ng-container-right");return e?e.classList.contains("ng-container-left")?"left":e.classList.contains("ng-container-right")?"right":"body":null},"#getContainerType"),ai=new WeakMap,ci=new WeakMap,fl=h(function(n){var c;let e=n-t(this,ys);const s=A(this,Tt,yn).call(this,t(this,Gt));if(s&&t(this,Ct)!==null){const u=t(this,xe)-mt,f=-(t(this,jt)-mt);e=Math.max(f,Math.min(e,u))}const i=Math.max(mt,t(this,jt)+e),r=t(this,Gt).getBoundingClientRect();let o=n-r.left;if(s&&t(this,Ct)!==null){const u=t(this,oi)+(t(this,xe)-mt);o=Math.min(o,u)}const l=Math.max(mt,o);t(this,Lt)&&(t(this,Lt).style.setProperty("--tooltip-left",`${t(this,li)}px`),t(this,Lt).style.setProperty("--tooltip-width",`${l}px`));const a=(c=t(this,_e))==null?void 0:c.querySelector(".size-badge");a&&(a.textContent=`${Math.round(i)}px`)},"#updatePositions"),hi=new WeakMap,hr=new WeakMap,di=new WeakMap,h(Ro,"ColResizer");let $n=Ro;const Lo=class Lo{constructor(n){d(this,st);d(this,K);d(this,P);d(this,et);d(this,we,!1);d(this,ie,null);d(this,re,null);d(this,$t,null);d(this,ui,0);d(this,Ue,null);d(this,fi,h(n=>{if(!A(this,st,Il).call(this)||!n.target.closest(".ng-sheet-header"))return;const s=n.target.closest("th, td");if(!s||s.classList.contains("resizable-edge")||["INPUT","BUTTON"].includes(n.target.tagName)||s.dataset.col===void 0)return;n.preventDefault();const i=n.clientX,r=n.clientY,o=h(()=>{t(this,Ue)&&(clearTimeout(t(this,Ue)),p(this,Ue,null)),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",o),window.removeEventListener("pointercancel",o)},"cancelTimer"),l=h(a=>{Math.hypot(a.clientX-i,a.clientY-r)>5&&o()},"onPointerMovePending");p(this,Ue,setTimeout(()=>{o(),A(this,st,Hl).call(this,n,s)},500)),window.addEventListener("pointermove",l),window.addEventListener("pointerup",o,{once:!0}),window.addEventListener("pointercancel",o,{once:!0})},"#onPointerDown"));d(this,gi,h(n=>{var i,r;if(!t(this,we))return;A(this,st,gl).call(this,n.clientX),t(this,P)&&(t(this,P).style.pointerEvents="none"),t(this,et)&&(t(this,et).style.pointerEvents="none");const e=A(this,st,ql).call(this,n.clientX,n.clientY),s=e==null?void 0:e.closest(".ng-sheet-header th, .ng-sheet-header td");if(s&&s.dataset.col!==void 0){const o=parseInt(s.dataset.col,10),l=t(this,K).getBoundingClientRect(),a=s.closest("table");let c=1/0,u=-1/0;if(a&&a.querySelectorAll("thead th, thead td").forEach(z=>{if(z.dataset.col===void 0)return;const tt=parseInt(z.dataset.col,10),St=z.colSpan||1,V=tt+St-1;if(tt<=o&&V>=o){const $s=z.getBoundingClientRect();c=Math.min(c,$s.left),u=Math.max(u,$s.right)}}),c===1/0){const z=s.getBoundingClientRect();c=z.left,u=z.right}const f=c+(u-c)/2;let g=0,b=0;if(n.clientX<f)g=o,b=c-l.left;else{const z=s.colSpan||1;g=o+z,b=u-l.left}const m=A(this,st,xn).call(this,t(this,ie)),y=m.colSpan,x=m.rowIndex,w=t(this,ie).rowSpan||1,S=x+w-1,L=((i=s.closest("tr"))==null?void 0:i.sectionRowIndex)??0,C=s.rowSpan||1,W=L+C-1,T=!(S<L||x>W);let D=!1;if(m.parentGroupRange){const{startCol:z,endCol:tt}=m.parentGroupRange;(g<z||g+y-1>tt)&&(D=!0)}let _=!1;if(a){const z=a.querySelectorAll("thead th[colspan], thead td[colspan]");for(const tt of z){if(tt===t(this,ie))continue;const St=((r=tt.closest("tr"))==null?void 0:r.sectionRowIndex)??0,V=tt.rowSpan||1,$s=St+V-1;if(!!(S<St||x>$s))continue;const Te=parseInt(tt.dataset.col,10),mn=tt.colSpan||1,ke=Te+mn-1;if(g>Te&&g<ke+1){_=!0;break}const rl=g+y-1;if(g>Te&&g<=ke&&rl>ke||g<Te&&rl>=Te&&rl<ke){_=!0;break}}}const rt=g>=m.startCol&&g<=m.endCol+1;if(!T||rt||D||_||!m.isValidGroup)p(this,$t,null),t(this,et)&&(t(this,et).style.display="none"),t(this,P)&&t(this,P).classList.add("invalid");else if(p(this,$t,g),t(this,P)&&t(this,P).classList.remove("invalid"),t(this,et)){const St=s.closest(".ng-sheet-header").getBoundingClientRect().top-l.top,V=l.height-St;t(this,et).style.top=`${St}px`,t(this,et).style.height=`${V}px`,t(this,et).style.left=`${b-1}px`,t(this,et).style.display="block"}}else t(this,et)&&(t(this,et).style.display="none"),t(this,P)&&t(this,P).classList.add("invalid"),p(this,$t,null)},"#onPointerMove"));d(this,dr,h(n=>{t(this,we)&&(window.removeEventListener("pointermove",t(this,gi)),document.body.style.cursor="",t(this,P)&&(t(this,P).style.display="none",t(this,P).replaceChildren()),t(this,et)&&(t(this,et).style.display="none"),t(this,$t)!==null&&t(this,re)!==null&&t(this,$t)!==t(this,re)&&t(this,$t)!==t(this,re)+1&&this.moveColumn(t(this,re),t(this,$t)),p(this,we,!1),p(this,ie,null),p(this,re,null),p(this,$t,null))},"#onPointerUp"));p(this,K,n),p(this,P,t(this,K).querySelector(".ng-col-mover-grip")),p(this,et,t(this,K).querySelector(".ng-col-mover-indi")),this.bindEvents()}bindEvents(){t(this,K).addEventListener("pointerdown",t(this,fi))}moveColumn(n,e){v.log(t(this,K).sourceTable.cloneNode(!0));const s=t(this,K).sourceTable.querySelector("colgroup"),i=s.querySelector(`col[data-col="${e}"]`),r=A(this,st,xn).call(this,t(this,ie));if(!r||!r.isValidGroup)return;const o=r.colSpan,l=h(u=>u>=n&&u<n+o,"isInRange"),a=t(this,K).querySelector(`.ng-sheet-body-content col[data-col="${e}"]`),c=a!=null&&a.closest(".ng-container-left")?"left":a!=null&&a.closest(".ng-container-right")?"right":null;s.querySelectorAll("col").forEach(u=>{l(parseInt(u.getAttribute("data-col"),10))&&(c?u.setAttribute("fixed",c):u.removeAttribute("fixed"),s.insertBefore(u,i))}),["thead","tbody","tfoot"].forEach(u=>{t(this,K).sourceTable.querySelectorAll(`${u} tr`).forEach(f=>{const g=Array.from(f.children),b=g.find(m=>parseInt(m.dataset.col,10)>=e);g.forEach(m=>{l(parseInt(m.dataset.col,10))&&f.insertBefore(m,b||null)})})}),t(this,K).recompileAndRefresh()}destroy(){t(this,K).removeEventListener("pointerdown",t(this,fi))}};K=new WeakMap,P=new WeakMap,et=new WeakMap,we=new WeakMap,ie=new WeakMap,re=new WeakMap,$t=new WeakMap,ui=new WeakMap,Ue=new WeakMap,st=new WeakSet,Il=h(function(){var e;const n=(e=t(this,K).getRootNode())==null?void 0:e.host;return t(this,K).getAttribute("col-movable")==="true"||(n==null?void 0:n.getAttribute("col-movable"))==="true"},"#checkIsMovable"),ql=h(function(n,e){const s=t(this,K).getRootNode();let i=s.elementFromPoint?s.elementFromPoint(n,e):document.elementFromPoint(n,e);for(;i&&i.shadowRoot&&i.shadowRoot.elementFromPoint;){const r=i.shadowRoot.elementFromPoint(n,e);if(!r||r===i)break;i=r}return i},"#getDeepElementFromPoint"),xn=h(function(n){var g,b;if(!n||n.dataset.col===void 0)return null;const e=parseInt(n.dataset.col,10),s=n.colSpan||1,i=e+s-1,r=((g=n.closest("tr"))==null?void 0:g.sectionRowIndex)??0,o=n.closest("table");if(!o)return{startCol:e,colSpan:s,endCol:i,rowIndex:r,isGroup:!1,parentGroupRange:null,isValidGroup:!0};const l=o.querySelectorAll("thead th, thead td");let a=!1,c=!0,u=null;for(const m of l){if(m===n||m.dataset.col===void 0)continue;const y=parseInt(m.dataset.col,10),x=m.colSpan||1,w=y+x-1;(((b=m.closest("tr"))==null?void 0:b.sectionRowIndex)??0)<r&&y<=e&&w>=i&&x>s&&(u?(u.startCol=Math.max(u.startCol,y),u.endCol=Math.min(u.endCol,w)):u={startCol:y,endCol:w}),!(w<e||y>i)&&(y>=e&&w<=i?x<s&&(a=!0):(y<e||w>i)&&(y<=e&&w>=i||(c=!1)))}const f=a&&c;return{startCol:e,colSpan:f?s:1,endCol:f?i:e,rowIndex:r,isGroup:f,parentGroupRange:u,isValidGroup:c}},"#getColGroupRange"),Ml=h(function(n){const e=A(this,st,xn).call(this,n);if(!e)return null;const{startCol:s,endCol:i,isGroup:r}=e,o=n.closest("table");if(!o)return null;let l=1/0,a=-1/0,c=1/0,u=-1/0;const f=[];if(o.querySelectorAll("thead th, thead td").forEach(y=>{if(y.dataset.col===void 0)return;const x=parseInt(y.dataset.col,10),w=y.colSpan||1,S=x+w-1;if(r?x>=s&&S<=i:y===n){const C=y.getBoundingClientRect();l=Math.min(l,C.left),a=Math.max(a,C.right),c=Math.min(c,C.top),u=Math.max(u,C.bottom);const W=window.getComputedStyle(y);f.push({el:y,rect:C,style:W})}}),f.length===0)return null;const g=a-l,b=u-c,m=document.createElement("div");return m.className="grip-header-content",m.style.position="relative",m.style.width=`${g}px`,m.style.height=`${b}px`,f.forEach(({el:y,rect:x,style:w})=>{const S=y.cloneNode(!0);S.style.position="absolute",S.style.left=`${x.left-l}px`,S.style.top=`${x.top-c}px`,S.style.width=`${x.width}px`,S.style.minWidth=`${x.width}px`,S.style.maxWidth="none",S.style.height=`${x.height}px`,S.style.boxSizing="border-box",S.style.margin="0",S.style.backgroundColor=w.backgroundColor!=="transparent"&&w.backgroundColor!=="rgba(0, 0, 0, 0)"?w.backgroundColor:"#f9fafb",S.style.color=w.color,S.style.font=w.font,S.style.fontWeight=w.fontWeight,S.style.fontSize=w.fontSize,S.style.textAlign=w.textAlign,S.style.padding=w.padding,S.style.border=w.border,S.style.borderRight=w.borderRight,S.style.borderBottom=w.borderBottom,S.style.display="flex",S.style.alignItems="center",S.style.justifyContent=w.textAlign==="center"?"center":w.textAlign==="right"?"flex-end":"flex-start",m.appendChild(S)}),{element:m,bounds:{left:l,right:a,top:c,bottom:u,width:g,height:b}}},"#createGroupHeaderPreview"),fi=new WeakMap,Hl=h(function(n,e){if(t(this,we))return;const s=A(this,st,Ml).call(this,e);if(!s)return;p(this,we,!0),p(this,ie,e),p(this,re,parseInt(e.dataset.col,10));const i=t(this,K).getBoundingClientRect(),{bounds:r,element:o}=s;if(p(this,ui,n.clientX-r.left),t(this,P)){t(this,P).replaceChildren(o);const l=r.top-i.top,a=i.height-l;t(this,P).style.width=`${r.width}px`,t(this,P).style.height=`${a}px`,t(this,P).style.top=`${l}px`,t(this,P).style.display="block",A(this,st,gl).call(this,n.clientX)}document.body.style.cursor="move",window.addEventListener("pointermove",t(this,gi)),window.addEventListener("pointerup",t(this,dr),{once:!0})},"#startDrag"),gi=new WeakMap,gl=h(function(n){if(!t(this,P))return;const e=t(this,K).getBoundingClientRect(),s=n-e.left-t(this,ui);t(this,P).style.left=`${s}px`},"#updateGripPosition"),dr=new WeakMap,h(Lo,"ColMover");let Fn=Lo;const Co=class Co{constructor(n){d(this,ve);p(this,ve,n)}getFixState(n,e){if(!n||!e)return"none";const s=n.closest(".ng-container-left, .ng-container-right, .ng-container-body");if(s!=null&&s.classList.contains("ng-container-left"))return"left";if(s!=null&&s.classList.contains("ng-container-right"))return"right";const i=parseInt(n.dataset.col,10);if(!isNaN(i)){const r=e.querySelector(`colgroup col[data-col="${i}"]`),o=r==null?void 0:r.getAttribute("fixed");if(o)return o}return"none"}canFixColumn(n,e){if(!n||n.tagName!=="TH"||!e)return!1;const s=parseInt(n.dataset.col,10),i=n.colSpan||1;if(isNaN(s))return!1;const r=s+i-1,o=Array.from(e.querySelectorAll("thead tr"));if(o.length<=1)return!0;for(const l of o){const a=Array.from(l.querySelectorAll("th, td"));let c=!1;for(const u of a){const f=parseInt(u.dataset.col,10),g=u.colSpan||1,b=f+g-1;if(f<=r&&r<b)return!1;if(b===r){c=!0;break}}if(!c)return!1}return!0}executeFixToggle(n,e,s="left"){var u,f;if(!t(this,ve)||!e)return;const i=t(this,ve).sourceTable;if(!i)return;const r=parseInt(e.dataset.col,10),o=e.colSpan||1,l=r+o-1;if(isNaN(l))return;const a=i.querySelector("colgroup");if(!a)return;const c=Array.from(a.querySelectorAll("col"));if(n==="fix-column")c.forEach(g=>{parseInt(g.getAttribute("data-col"),10)<=l&&g.setAttribute("fixed",s)}),["thead","tbody","tfoot"].forEach(g=>{i.querySelectorAll(`${g} tr`).forEach(b=>{Array.from(b.children).forEach(m=>{const y=parseInt(m.dataset.col,10);!isNaN(y)&&y<=l&&m.setAttribute("fixed",s)})})});else if(n==="unfix-column"){let g=r;["thead","tbody","tfoot"].forEach(m=>{i.querySelectorAll(`${m} tr`).forEach((y,x)=>{Array.from(y.children).forEach(w=>{const S=parseInt(w.dataset.col,10),L=w.colSpan||1,C=S+L-1,W=w.rowSpan||1,T=y.sectionRowIndex??x;T+W-1<w.closest("tr").sectionRowIndex||T>w.closest("tr").sectionRowIndex+W-1,!(C<r||S>l)&&(g=Math.min(g,S))})})}),c.forEach(m=>{parseInt(m.getAttribute("data-col"),10)>=g&&m.removeAttribute("fixed")});let b=!1;c.forEach(m=>{b?m.removeAttribute("fixed"):m.getAttribute("fixed")||(b=!0)}),["thead","tbody","tfoot"].forEach(m=>{i.querySelectorAll(`${m} tr`).forEach(y=>{Array.from(y.children).forEach(x=>{const w=parseInt(x.dataset.col,10);if(isNaN(w))return;const S=c.find(C=>parseInt(C.getAttribute("data-col"),10)===w),L=S==null?void 0:S.getAttribute("fixed");L?x.setAttribute("fixed",L):x.removeAttribute("fixed")})})})}v.log(t(this,ve).sourceTable),(f=(u=t(this,ve)).recompileAndRefresh)==null||f.call(u)}};ve=new WeakMap,h(Co,"ColFixManager");let Pi=Co;const ko=class ko extends HTMLElement{constructor(){super(...arguments);d(this,pr);d(this,Ft);d(this,ne);d(this,bt);d(this,oe);d(this,Kt);E(this,"currentCol",null);d(this,ur,h(()=>{t(this,fr).call(this),p(this,Ft,this.closest("nine-table-sheet")),p(this,ne,this.getRootNode().host),p(this,bt,this.querySelector("nine-table-simple")),v.log("1***********************",t(this,bt)),setTimeout(()=>{p(this,oe,t(this,bt).shadowRoot.querySelector("nine-table-sheet")),v.log("2***********************",t(this,oe))}),this.querySelector(".search-box").addEventListener("focusin",e=>{e.stopPropagation()}),this.querySelector(".search-box").addEventListener("input",t(this,mr)),this.querySelector("#chkSelectAll").addEventListener("change",t(this,yr)),this.querySelector("#btnOk").addEventListener("click",t(this,br))},"#init"));d(this,fr,h(()=>{this.innerHTML=`
150
149
  <style>
151
150
  nine-table-filter-panel nine-table-simple {
152
151
  width: 100%;
@@ -243,7 +242,7 @@
243
242
  </div>
244
243
  </div>
245
244
  </div>
246
- `},"#renderer"));d(this,gr,h(e=>{const s=e.composedPath?e.composedPath():[];s.includes(this)||t(this,Kt)&&s.includes(t(this,Kt))||this.close()},"#closeHandler"));d(this,br,h(()=>{var l;t(this,ne).loading=!0;const e=t(this,oe).view.getArray(),s=t(this,bt).data.getHostFields(),i=e.filter(a=>{const c=a.v[s.indexOf("CHK")];return c==="Y"||c===!0}),r={...((l=t(this,Wt).filtering)==null?void 0:l.filters)||{}};t(this,Kt).columns.forEach(a=>{const c=a.expr||a.bind,u=a.expr?s.indexOf("DATA2"):s.indexOf("DATA"),g=i.map(f=>f.v[u]);g.length>0?r[c]=g:delete r[c]});const o=t(this,bt).data.count();setTimeout(()=>{try{o===i.length?t(this,Kt).columns.forEach(a=>{const c=a.expr||a.bind;c&&t(this,Wt).filtering.clear(c)}):t(this,Wt).filtering.set(r),t(this,Wt).querySelectorAll("nine-table-filter-button").forEach(a=>{a.updateFilteredState()}),t(this,Wt).invalidate(),this.close()}finally{t(this,ne).loading=!1}})},"#onOk"));d(this,mr,h(e=>{const s=e.target.value.toLowerCase().trim();if(!s)t(this,oe).filtering.clear();else{const i=t(this,bt).data.getArray(),o=t(this,bt).data.getHostFields().indexOf("DATA2"),l=[];i.forEach(a=>{const c=o>=0&&a.v?a.v[o]:"";String(c).replace(/<[^>]*>?/gm,"").toLowerCase().includes(s)&&l.push(c)}),v.log(l),t(this,oe).filtering.set({DATA2:[...new Set(l)]})}},"#onInput"));d(this,yr,h(e=>{var l,a;const s=e.target.checked,i=((a=(l=t(this,bt))==null?void 0:l.data)==null?void 0:a.getArray())||[],o=t(this,bt).data.getHostFields().indexOf("CHK");o>=0&&i.forEach(c=>{c.v[o]=s?"Y":"N"}),t(this,bt).refresh()},"#onSelectAll"));d(this,To,h(()=>{this.close()},"#onCancel"))}connectedCallback(){t(this,ur).call(this),document.addEventListener("mousedown",t(this,gr))}open(e){p(this,Kt,e);const s=e.closest("th, td");this.currentCol=s==null?void 0:s.dataset.col;const i=s.getBoundingClientRect(),r=t(this,Wt).getBoundingClientRect(),o=this.offsetWidth||240;let l=i.right-r.left-o,a=i.bottom-r.top;l<0&&(l=Math.max(0,i.left-r.left)),this.style.left=`${l}px`,this.style.top=`${a}px`;const c=this.querySelector(".search-box");c.value="",this.classList.add("active"),this.classList.add("loading"),setTimeout(()=>{try{A(this,pr,Nl).call(this),t(this,oe).rowManager.scrollToDataRow(0)}finally{this.classList.remove("loading")}})}close(){this.currentCol=null,this.classList.remove("active"),p(this,Kt,null)}};Wt=new WeakMap,ne=new WeakMap,bt=new WeakMap,oe=new WeakMap,Kt=new WeakMap,ur=new WeakMap,fr=new WeakMap,gr=new WeakMap,pr=new WeakSet,Nl=h(function(){var c,u;const e=t(this,ne).data.getArray(),s=((c=t(this,Kt))==null?void 0:c.columns)||[],i=t(this,ne).fields.get()||[],r=((u=t(this,Wt).filtering)==null?void 0:u.filters)||{},o=t(this,ne).exprEngine,l=s.flatMap(g=>{const f=g.bind,b=g.expr,m=f||b,y=f?i.indexOf(f):-1,x=r[m]||[],w=new Map;for(let R=0;R<e.length;R++){const C=e[R];if(!C)continue;let W;y>=0&&C.v?W=C.v[y]:f&&f.includes("data.")?W=o?o.evaluate(f,C,R):void 0:b&&o&&(W=o.evaluate(b,C,R));let T=W;b&&o&&(T=o.evaluate(b,C,R)),T!=null&&!w.has(T)&&w.set(T,{v:W,v2:T})}const S=[...w.values()];return S.sort((R,C)=>String(R.v2||"").localeCompare(String(C.v2||""))),x.sort((R,C)=>R>C?1:-1),S.map(R=>({LVL:2,DATA:R.v,DATA2:R.v2===""||R.v2===null||R.v2===void 0?'<span class="empty-value">(empty)</span>':R.v2,COLNM:m,CHK:x.length===0||x.nineBinarySearch(R.v||"")>=0?"Y":"N"}))});t(this,bt).data.set(l);const a=this.querySelector("#chkSelectAll");a&&(a.checked=l.length>0&&l.every(g=>g.CHK==="Y"))},"#loadVirtualFilterItems"),br=new WeakMap,mr=new WeakMap,yr=new WeakMap,To=new WeakMap,h(ko,"NineTableFilterPanel");let Wn=ko;const Io=class Io extends HTMLElement{constructor(){super(...arguments);d(this,Ge);d(this,je,null);E(this,"updateFilteredState",h(()=>{var i;const e=((i=t(this,Ge).filtering)==null?void 0:i.filters)||{},s=this.columns.some(r=>{const o=r.expr||r.bind;return o&&e[o]&&e[o].length>0});this.classList.toggle("filtered",s)},"updateFilteredState"));d(this,pi,h(e=>{e.preventDefault(),e.stopPropagation();const s=t(this,Ge).querySelector("nine-table-filter-panel"),i=this.closest("th, td"),r=i==null?void 0:i.dataset.col;s&&s.currentCol===r&&s.classList.contains("active")?s.close():s&&s.open(this)},"#onClick"))}connectedCallback(){p(this,Ge,this.closest("nine-table-sheet")||this.getRootNode().host),this.removeEventListener("click",t(this,pi)),this.addEventListener("click",t(this,pi))}get columns(){if(t(this,je))return t(this,je);const e=this.closest("th, td"),s=e==null?void 0:e.dataset.col,i=t(this,Ge).sourceTable,r=[],o=new Set;return i&&s!==void 0&&i.querySelectorAll(`tbody [data-col="${s}"]`).forEach(l=>{const a=l.dataset.bind,c=l.dataset.expr;if(a||c){const u=`${a||""}_${c||""}`;o.has(u)||(o.add(u),r.push({bind:a,expr:c}))}}),p(this,je,r),t(this,je)}};Ge=new WeakMap,je=new WeakMap,pi=new WeakMap,h(Io,"NineTableFilterButton");let On=Io;const qo=class qo{constructor(n){d(this,bi);d(this,It);d(this,Se);d(this,Ke,!1);d(this,xr,null);d(this,Yt,{});d(this,wr,h(()=>{t(this,vr).call(this)},"#init"));d(this,vr,h(()=>{if(t(this,Se).tagName.toLowerCase()==="nine-table-simple")return;let n=t(this,It).querySelector("nine-table-filter-panel");n||(n=document.createElement("nine-table-filter-panel"),t(this,It).appendChild(n)),p(this,xr,n)},"#initFilterPanel"));E(this,"clear",h(n=>{n?delete t(this,Yt)[n]:p(this,Yt,{}),p(this,Ke,Object.keys(t(this,Yt)).length>0),A(this,bi,pl).call(this),t(this,It).querySelectorAll("nine-table-filter-button").forEach(e=>{e.updateFilteredState()}),v.log(`🔄 [NineTableFiltering] Filter cleared for ${n||"all"}`)},"clear"));E(this,"set",h(n=>{v.log(n);let e=Array.isArray(n)?Object.fromEntries(Object.keys(n[0]).map(s=>[s,[...new Set(n.map(i=>i[s]))]])):n;p(this,Yt,e),p(this,Ke,Object.keys(e).length>0),t(this,It).toggleAttribute("filtering",t(this,Ke)),A(this,bi,pl).call(this)},"set"));p(this,It,n),p(this,Se,t(this,It).getRootNode().host),t(this,wr).call(this)}get filters(){return t(this,Yt)}isFiltering(){return t(this,Ke)}};It=new WeakMap,Se=new WeakMap,Ke=new WeakMap,xr=new WeakMap,Yt=new WeakMap,wr=new WeakMap,vr=new WeakMap,bi=new WeakSet,pl=h(function(){const e=t(this,Se).data.getArray(),s=t(this,Se).data.getHostFields(),i=t(this,It).index,r=t(this,Se).exprEngine;if(!(Object.keys(t(this,Yt)).length>0)){e.forEach(a=>{var c,u;(u=(c=a==null?void 0:a.m)==null?void 0:c._)!=null&&u[Dt.META.INDEX.FILTER]&&(a.m._[Dt.META.INDEX.FILTER][i]=!0)}),t(this,It).invalidate();return}const l=Object.entries(t(this,Yt)).map(([a,c])=>{const u=a.includes("data.")||a.includes("host.")||a.includes("rowItem.v");return{targetKey:a,isExpr:u,fieldIdx:u?-1:s.indexOf(a),allowedSet:new Set(c)}});e.forEach((a,c)=>{if(!a)return;a.m._[Dt.META.INDEX.FILTER]||(a.m._[Dt.META.INDEX.FILTER]=[]);let u=!0;for(let g=0;g<l.length;g++){const{targetKey:f,isExpr:b,fieldIdx:m,allowedSet:y}=l[g];let x;if(b&&r?x=r.evaluate(f,a,c):m>=0&&a.v&&(x=a.v[m]),!y.has(x)){u=!1;break}}a.m._[Dt.META.INDEX.FILTER][i]=u}),t(this,It).invalidate()},"#applyFiltering"),h(qo,"Filtering");let zn=qo;customElements.get("nine-table-filter-panel")||customElements.define("nine-table-filter-panel",Wn),customElements.get("nine-table-filter-button")||customElements.define("nine-table-filter-button",On);const Mo=class Mo{constructor(n){d(this,Ot);d(this,ct);d(this,mi);d(this,ht,[]);p(this,ct,n),p(this,mi,n.getRootNode().host),setTimeout(()=>{A(this,Ot,Dl).call(this)},300)}restore(){var n;p(this,ht,[]),t(this,ct).view&&t(this,ct).view.resetSorting(),A(this,Ot,bl).call(this),(n=t(this,ct).rowManager)==null||n.refresh(!0)}};ct=new WeakMap,mi=new WeakMap,ht=new WeakMap,Ot=new WeakSet,Dl=h(function(){t(this,ct).querySelectorAll("thead").forEach(n=>{n.addEventListener("dblclick",e=>{const s=e.target.closest("th, td");if(!s||s.classList.contains("resizable-edge")||["INPUT","CELL-CHECKBOX"].includes(e.target.tagName)||e.offsetX<=2||e.offsetX>=s.offsetWidth-2)return;const i=t(this,ct).getRootNode().host;i.loading=!0,setTimeout(()=>{try{A(this,Ot,$l).call(this,e,s)}finally{i.loading=!1}})})}),v.log("🎯 [NineTableSorting] Initialized")},"#initEvents"),$l=h(function(n,e){const s=e.dataset.col,i=e.closest("tr"),r=i?i.dataset.subrow||String(i.sectionRowIndex):"0";if(s===void 0)return;const o=t(this,ct).sourceTable;if(!o)return;let l=null,a=null;if(o.querySelectorAll(`tbody [data-col="${s}"]`).forEach(b=>{b.dataset.bind&&(l=b.dataset.bind),b.dataset.expr&&(a=b.dataset.expr)}),!l&&!a)return;const c=e.classList.contains("asc"),u=e.classList.contains("desc");!n.ctrlKey&&!n.shiftKey&&p(this,ht,[]);const g=t(this,ht).findIndex(b=>b.colIndex===s&&b.subRowIndex===r||b.colName===l),f={colIndex:s,subRowIndex:r,colname:l||a,colName:l||a,expr:a,asc:!0,"expr-func":a?(b,m)=>t(this,mi).exprEngine(a,b,m):null};!c&&!u?g>=0?t(this,ht)[g].asc=!0:t(this,ht).push({...f,asc:!0}):c?g>=0?t(this,ht)[g].asc=!1:t(this,ht).push({...f,asc:!1}):p(this,ht,t(this,ht).filter(b=>!(b.colIndex===s&&b.subRowIndex===r||b.colName===l))),A(this,Ot,Fl).call(this)},"#handleSort"),Fl=h(function(){if(!t(this,ct).view){console.warn("⚠️ [NineTableSorting] Sheet view (SheetView) is not initialized.");return}t(this,ct).view.setSorting(t(this,ht)),A(this,Ot,bl).call(this),t(this,ct).invalidate(),v.log("🔄 [NineTableSorting] Sorting applied via RowManager.refresh(true)")},"#applySorting"),bl=h(function(){t(this,ct).querySelectorAll("thead th, thead td").forEach(n=>{n.classList.remove("asc","desc")}),t(this,ht).length!==0&&t(this,ht).forEach(n=>{const{colIndex:e,subRowIndex:s,asc:i}=n;if(e!==void 0){let r=`thead [data-col="${e}"]`;s!==void 0&&(r=`thead tr[data-subrow="${s}"] [data-col="${e}"]`),t(this,ct).querySelectorAll(r).forEach(l=>{l.classList.add(i?"asc":"desc")})}})},"#syncHeaderUI"),h(Mo,"Sorting");let Bn=Mo;const No=class No{constructor(n){d(this,Ye);d(this,yt);d(this,Ae,[]);d(this,Ho,[]);d(this,yi,[]);d(this,le,null);E(this,"getArray",h((n,e)=>{if(!t(this,le)){const r=t(this,yt).data.getArray();p(this,le,t(this,yi).map(o=>r[o]))}const s=t(this,le);if(n==null)return s;if(n<0||n>=s.length)return null;const i=s[n];if(e!=null){const o=t(this,yt).data.getHostFields().indexOf(e);return o>=0&&i.v?i.v[o]:null}return i},"getArray"));E(this,"get",h((n,e)=>{var o,l;const s=this.getArray(),i=((l=(o=t(this,yt).data).getHostFields)==null?void 0:l.call(o))||[];if(n==null)return s.map(a=>t(this,xi).call(this,a,i));if(n<0||n>=s.length)return null;const r=s[n];if(!r)return null;if(e!=null){const a=i.indexOf(e);return a>=0&&r.v?r.v[a]:null}return t(this,xi).call(this,r,i)},"get"));d(this,xi,h((n,e)=>{if(!n)return null;const s={};return e.forEach((i,r)=>{s[i]=n.v?n.v[r]:n[i]}),n.m&&(s.m=n.m),n._&&(s._=n._),s},"#convSingle"));E(this,"refresh",h(()=>{var r;p(this,le,null);const n=t(this,yt).data.getArray();let e=[];n.forEach((o,l)=>{var c,u;if(!o)return;const a=(u=(c=o.m)==null?void 0:c._)==null?void 0:u[Dt.META.INDEX.FILTER];a&&a[t(this,Ye).index]===!1||e.push(l)}),v.log(e),t(this,Ae).length>0&&(e=t(this,Sr).call(this,e,n)),p(this,yi,e);const s=e.map(o=>n[o]),i=((r=t(this,Ye).grouping)==null?void 0:r.columns)||[];if(i.length>0){const o=Mn.apply(s,i,t(this,yt).data.getHostFields());p(this,le,o.renderItems),t(this,Ye).grouping.setGroupMap(o.groupMap)}else p(this,le,s)},"refresh"));E(this,"setSorting",h(n=>{p(this,Ae,n||[]),this.refresh()},"setSorting"));E(this,"getSorting",h(()=>t(this,Ae),"getSorting"));E(this,"resetSorting",h(()=>{p(this,Ae,[]),this.refresh()},"resetSorting"));d(this,Sr,h((n,e)=>{v.log(new Date);const s=typeof t(this,yt).data.getHostFields=="function"?t(this,yt).data.getHostFields():[],i=t(this,Ae).map(r=>({...r,colIndex:s.indexOf(r.colname||r.colName)}));return n.sort((r,o)=>{const l=e[r],a=e[o];for(const c of i){const u=c.asc,g=c.expr;let f,b;g?(f=t(this,yt).exprEngine.evaluate(g,l,r),b=t(this,yt).exprEngine.evaluate(g,a,o)):c.colIndex>=0&&l.v&&a.v&&(f=l.v[c.colIndex],b=a.v[c.colIndex]);const m=f==null||f==="",y=b==null||b==="";if(!(m&&y)){if(m)return 1;if(y)return-1;if(f!==b){let x=0;if(typeof f=="number"&&typeof b=="number")x=f-b;else{const w=String(f),S=String(b);x=w>S?1:w<S?-1:0}if(x!==0)return u?x:-x}}}return r-o})},"#applySorting"));p(this,Ye,n),p(this,yt,n.getRootNode().host),this.refresh()}};Ye=new WeakMap,yt=new WeakMap,Ae=new WeakMap,Ho=new WeakMap,yi=new WeakMap,le=new WeakMap,xi=new WeakMap,Sr=new WeakMap,h(No,"SheetView");let Vi=No;const Pn=16,nt=class nt{static initializeTable(n,e){var s,i,r,o,l,a,c,u,g,f,b;return!n||!e?null:(A(s=nt,O,Bl).call(s,e),A(i=nt,O,Vl).call(i,e),A(r=nt,O,zl).call(r,e),A(o=nt,O,jl).call(o,e),A(l=nt,O,Pl).call(l,e),fe.resetColIndex(e,e.querySelectorAll("thead tr")),fe.resetColIndex(e,e.querySelectorAll('tbody.body tr[grouping="true"]')),fe.resetColIndex(e,e.querySelectorAll('tbody.body tr:not([grouping="true"])')),fe.resetColIndex(e,e.querySelectorAll("tfoot tr")),A(a=nt,O,Wl).call(a,e),A(c=nt,O,Xl).call(c,e),A(u=nt,O,_l).call(u,n,e),A(g=nt,O,Gl).call(g,e),A(f=nt,O,Ul).call(f,n,e),A(b=nt,O,Kl).call(b,e),e)}};O=new WeakSet,Wl=h(function(n){const e=n.querySelector("thead");if(!e||e.querySelector(".col-indicator-rowgroup"))return;const s='<th data-col="@col" class="col-indicator" scope="col"></th>',i=e.insertRow(0);i.setAttribute("role","row"),i.classList.add("col-indicator-rowgroup"),i.classList.add("collapse");const r=n.querySelector("tbody tr");if(!r)return;let o=0;r.querySelectorAll("th, td").forEach(a=>{var c;if(!a.classList.contains("dummy")){const u=a.colSpan||1;for(let g=0;g<u;g++){const f=s.replace("@col",o).replace("@text",A(c=nt,O,Ol).call(c,o++));i.insertAdjacentHTML("beforeend",f)}}});const l=Array.from(n.querySelectorAll("colgroup col"));i.querySelectorAll(".col-indicator").forEach((a,c)=>{const u=l[c].getAttribute("background");u&&(a.style.background=u)})},"#createColIndicator"),Ol=h(function(n){let e="";for(let s=n;s>=0;s=Math.floor(s/26)-1)e=String.fromCharCode(65+s%26)+e;return e},"#numToExcelCol"),zl=h(function(n){let e=n.querySelector("tbody:not(.head):not(.foot)");if(e){if(e.classList.add("body"),!n.querySelector("tbody.head")){const s=document.createElement("tbody");s.classList.add("head"),e.before(s)}if(!n.querySelector("tbody.foot")){const s=document.createElement("tbody");s.classList.add("foot"),e.after(s)}}},"#ensureSectionTbodys"),Bl=h(function(n){let e=n.querySelector("colgroup");if(e||(e=document.createElement("colgroup"),n.prepend(e)),e.querySelectorAll("col").length===0){const s=n.querySelector("tbody tr");let i=1;s&&(i=Array.from(s.querySelectorAll("th, td")).reduce((r,o)=>r+(parseInt(o.getAttribute("colspan")||o.colSpan,10)||1),0)),i=Math.max(i,1);for(let r=0;r<i;r++){const o=document.createElement("col");e.appendChild(o)}}},"#ensureColgroup"),Pl=h(function(n){const e=Array.from(n.querySelectorAll("colgroup col"));if(e.length===0)return;const s=n.clientWidth||0,i=Math.max(Math.floor(s/e.length),100);e.forEach((r,o)=>{r.hasAttribute("data-col")||r.setAttribute("data-col",o);const l=r.getAttribute("width")||parseInt(r.style.width,10)||i;r.setAttribute("width",l);const a=String(l).includes("px")?l:`${l}px`;r.style.width=a})},"#normalizeColAttributes"),Vl=h(function(n){if(n.querySelector("thead"))return;const e=document.createElement("thead"),s=n.querySelector("colgroup");s?s.after(e):n.prepend(e)},"#ensureThead"),Xl=h(function(n){n.querySelectorAll("thead th, thead td").forEach(s=>{s.getAttribute("collapsed")==="true"&&s.getAttribute("collapsible")!=="true"&&s.setAttribute("collapsible","true")})},"#normalizeCollapsibleAttributes"),_l=h(function(n,e){const s=["data-bind","data-expr","type"];let i=0;e.querySelectorAll("tbody th, tbody td").forEach(r=>{const l=`cell-${r.getAttribute("cell-type")||"renderer"}`,a=r.querySelector("datalist");if(a){let g=[];a.querySelectorAll("option").forEach(b=>{g.push({k:b.getAttribute("k"),v:b.getAttribute("v")})});const f=`__ds_${Date.now()}_${++i}`;n&&(n[f]=()=>g),r.setAttribute("data-source",`host.${f}()`),a.remove()}const c=r.dataset.expr;c&&r.setAttribute("data-expr",n.exprEngine.precompile(c)),Array.from(r.attributes).forEach(g=>{["data-bind","data-expr","cell-type"].includes(g.name)||(g.value.includes("data.")||g.value.includes("host."))&&r.setAttribute(g.name,n.exprEngine.precompile(g.value))});const u=s.filter(g=>r.hasAttribute(g)).map(g=>`${g}="${r.getAttribute(g)}"`);r.innerHTML=`<${l} ${u.join(" ")}></${l}>`,r.setAttribute("tabindex","0")}),e.querySelectorAll("thead th, thead td, tfoot th, tfoot td").forEach(r=>{const o=r.getAttribute("cell-type");if(o){const l=r.innerHTML,a=`cell-${o}`,c=s.filter(u=>r.hasAttribute(u)).map(u=>`${u}="${r.getAttribute(u)}"`);r.innerHTML=`<${a} ${c.join(" ")} content="${l}"></${a}>`}})},"#generateCell"),Ul=h(function(n,e){const s=n.getAttribute("filtering")==="true",i=e.getAttribute("filtering")==="true";e.querySelectorAll("thead tr:not(.col-indicator-rowgroup) th, thead tr:not(.col-indicator-rowgroup) td").forEach(r=>{const o=r.getAttribute("filtering")==="true"||i||s;r.setAttribute("filtering",o?"true":"false"),o&&r.appendChild(document.createElement("nine-table-filter-button"))})},"#initFilterButtons"),Gl=h(function(n){n.querySelectorAll("thead th, thead td").forEach(e=>{if(!(e.getAttribute("collapsible")==="true"||e.getAttribute("expandable")==="true"))return;v.log("11.*******************************",e.dataset.col);const i=parseInt(e.dataset.col,10),r=e.colSpan||1,o=n.querySelector(`colgroup col[data-col="${i}"]`);v.log("11.*******************************",o);const l=o&&parseInt(o.getAttribute("width"),10)||100;(!e.dataset.expandWidth||parseInt(e.dataset.expandWidth,10)<=Pn)&&(e.dataset.expandWidth=String(l>Pn?l:100));let a=e.querySelector("nine-table-col-expand");if(a||(a=document.createElement("nine-table-col-expand"),e.insertBefore(a,e.firstChild)),e.getAttribute("collapsed")==="true"){a.classList.add("collapsed"),a.classList.remove("expand"),a.setAttribute("collapsed","true"),e.style.color="transparent";const u=Math.max(10,Math.floor(Pn/r));if(!isNaN(i))for(let g=0;g<r;g++){const f=n.querySelector(`colgroup col[data-col="${i+g}"]`);f&&(f.setAttribute("width",u),f.style.width=`${u}px`)}}else a.classList.remove("collapsed"),a.classList.add("expand"),a.setAttribute("collapsed","false"),e.style.color=""})},"#initColExpanders"),jl=h(function(n,e){const s=n.getAttribute("row-indicator")==="true"?48:0,i=n.querySelector("colgroup"),r=document.createElement("col");r.setAttribute("fixed","left"),r.setAttribute("width",s),r.style.width=`${s}px`,i.prepend(r),n.querySelectorAll("thead, tbody, tfoot").forEach(o=>{const l=Array.from(o.querySelectorAll("tr"));if(l.length===0)return;const a=l[0],c=document.createElement("th");c.className="row-indicator",c.setAttribute("cell-type","row-indicator"),l.length>1&&(c.rowSpan=l.length),a.insertBefore(c,a.firstElementChild)})},"#ensureRowIndicator"),Kl=h(function(n){n.querySelectorAll("th[data-col], td[data-col]").forEach(e=>{v.log(e);const s=parseInt(e.getAttribute("data-col"),10);if(isNaN(s))return;const i=parseInt(e.getAttribute("colspan")||e.colSpan,10)||1;let r=0;for(let o=0;o<i;o++){const l=s+o,a=n.querySelector(`colgroup col[data-col="${l}"]`);a&&(r+=parseInt(a.getAttribute("width"),10)||100)}if(r>0){const o=`${r}px`;e.style.width=o,e.style.minWidth=o,e.style.maxWidth=o}})},"#applyInitialCellWidths"),d(nt,O),h(nt,"PreCompiler");let Vn=nt;const Ci=class Ci extends HTMLElement{constructor(){super();d(this,Er);d(this,wi);d(this,ae);d(this,zt);d(this,vi);d(this,Si);d(this,Ee);d(this,xs);d(this,Ai);d(this,Ar);d(this,Ei);d(this,ws);d(this,Ze);d(this,qt,{table:null});d(this,Je);d(this,Lr,h(()=>{const e=this.querySelector(".ng-container-body thead"),s=this.querySelector(".ng-nodata-overlay");s.style.top=`${e.offsetHeight}px`},"#adjustOverlay"));E(this,"invalidate",h(()=>{this.view.refresh(),t(this,zt).refresh(!0),this.isAutoFitCol&&this.autoFit(!0)},"invalidate"));E(this,"autoFit",h((e=!0)=>{requestAnimationFrame(()=>{var s;(s=t(this,Rr))==null||s.call(this,e)})},"autoFit"));d(this,Rr,h((e=!0)=>{var r;v.log("autoFit",this);const s=this.querySelector(".ng-sheet-body .ng-container-body");if(!s)return;s.querySelectorAll("table");const i=this.querySelector(".ng-sheet-header .ng-container-body table colgroup");if(i){if(e){this.setAttribute("auto-fit-col","true");const o=s.clientWidth;if(o<=0)return;let l=0;const a=[];i.querySelectorAll("col").forEach(g=>{const f=g.getAttribute("data-col"),b=this.querySelector(`.ng-sheet-header th[data-col="${f}"]`);if((b==null?void 0:b.getAttribute("collapsed"))==="true")a.unshift({globalColIndex:f,width:16,isCollapsed:!0}),v.log(`[AutoFit Col] Index ${f}: COLLAPSED (forced 16px)`);else{const y=parseInt(g.getAttribute("width"),10)||100;a.push({globalColIndex:f,width:y,isCollapsed:!1}),l+=y,v.log(`[AutoFit Col] Index ${f}: NORMAL (original width: ${y}px)`)}}),v.log(`[AutoFit] Total Original Width of Normal Cols: ${l}px`);const c=a.filter(g=>g.isCollapsed).reduce((g,f)=>g+f.width,0),u=Math.max(0,o-c);if(v.log(`[AutoFit] Collapsed Total Width: ${c}px | Available Width for Normal Cols: ${u}px`),l>0&&a.length>0){let g=0;const f=a.map(x=>{if(x.isCollapsed)return{globalColIndex:x.globalColIndex,remainder:0,width:16};const w=x.width*u/l,S=Math.max(30,Math.floor(w));return g+=S,{globalColIndex:x.globalColIndex,remainder:w-Math.floor(w),width:S}});let b=u-g;v.log(`[AutoFit] Initial Allocated Total: ${g}px | Remainder Pixels to distribute: ${b}`);const m=f.filter(x=>{var w;return!((w=a.find(S=>S.globalColIndex===x.globalColIndex))!=null&&w.isCollapsed)});if(b>0&&m.length>0){m.sort((x,w)=>w.remainder-x.remainder);for(let x=0;x<b;x++)m[x%m.length].width+=1}else if(b<0&&m.length>0){m.sort((x,w)=>x.remainder-w.remainder);for(let x=0;x<Math.abs(b);x++){const w=m[x%m.length];w.width>30&&(w.width-=1)}}const y=f.reduce((x,w)=>x+w.width,0);v.log(`[AutoFit Verification] Target Container Width: ${o}px | Sum of All Calculated Cols: ${y}px`),o!==y?v.log(`⚠️ [AutoFit Mismatch Warning!] 오차 발생: ${o-y}px 차이가 납니다.`):v.log("✅ [AutoFit Success] 완벽하게 일치합니다!"),f.forEach(({globalColIndex:x,width:w})=>{var S;v.log(`[AutoFit Apply] Col Index ${x} -> ${w}px`),(S=t(this,Ee))==null||S.setColumnWidth(x,w,"body")})}}else this.removeAttribute("auto-fit-col");(r=this.querySelector("nine-table-hscrollbar"))==null||r.refresh()}},"#autoFit"));E(this,"generate",h((e,s)=>{p(this,wi,s),Vn.initializeTable(t(this,ae),e),v.log("=======",e),p(this,qt,{table:fe.compile(e),tbody:{tr:e.querySelectorAll("tbody tr")}}),t(this,Li).call(this),t(this,Qe).call(this),t(this,Ir).call(this),t(this,qr).call(this),["left","body","right"].forEach(i=>{const r=`.ng-container-${i}`;t(this,Je)[i]={thead:this.querySelector(`${r} thead`),tbody:{head:this.querySelector(`${r} tbody.head`),body:this.querySelector(`${r} tbody.body`),foot:this.querySelector(`${r} tbody.foot`)},tfoot:this.querySelector(`${r} tfoot`)}}),t(this,zt).initialize(),this.isAutoFitCol?this.autoFit(!0):this.querySelector("nine-table-hscrollbar").refresh(),t(this,ws).initialize(),this.loaded=!0},"generate"));d(this,Qe,h(()=>{this.isAutoFitCol,["left","right","body"].forEach(e=>{const s=this.querySelectorAll(`.ng-container-${e}`);if(s.length===0)return;const i=s[0].querySelector("table");if(!i)return;let r=0;i.querySelectorAll("col").forEach(o=>{const l=parseInt(o.getAttribute("width"),10);isNaN(l)||(r+=l)}),s.forEach(o=>{const l=o.querySelectorAll("table");e==="body"?(o.style.flex="1",l.forEach(a=>{})):(o.style.flex=`0 0 ${r}px`,o.style.width=`${r}px`,o.style.minWidth=`${r}px`,o.style.maxWidth=`${r}px`,l.forEach(a=>{}))})})},"#updateContainerWidths"));d(this,Li,h(()=>{[{selector:".ng-container-left",type:"left"},{selector:".ng-container-body",type:null},{selector:".ng-container-right",type:"right"}].forEach(({selector:s,type:i})=>{this.querySelector(`.ng-sheet-body ${s}`).appendChild(t(this,Cr).call(this,i))})},"#renderSplitContainers"));d(this,Cr,h(e=>{const s=t(this,qt).table.cloneNode(!0);return e==="left"?s.querySelectorAll("col, th, td").forEach(i=>{i.getAttribute("fixed")!=="left"&&i.remove()}):e==="right"?s.querySelectorAll("col, th, td").forEach(i=>{i.getAttribute("fixed")!=="right"&&i.remove()}):s.querySelectorAll("[fixed=left], [fixed=right]").forEach(i=>{i.remove()}),s},"#createSplitTable"));E(this,"getRowHeight",h(()=>t(this,zt).getRowHeight(),"getRowHeight"));E(this,"scrollToX",h(e=>{const s=this.querySelector(".ng-sheet-body .ng-container-body");s&&(s.scrollLeft=e)},"scrollToX"));E(this,"scrollToY",h(e=>{const s=this.querySelector(".ng-sheet-body");s&&(s.scrollTop=e)},"scrollToY"));d(this,Tr,h(()=>{v.log("11111*****************"),t(this,kr).call(this),p(this,vi,new Nn(this)),p(this,Si,new Dn(this)),p(this,Ee,new $n(this)),p(this,xs,new Fn(this)),p(this,Ai,new Pi(this)),p(this,Ze,new Vi(this)),p(this,Ei,new zn(this)),p(this,ws,new qn(this)),t(this,Er,Yl)||p(this,Ar,new Bn(this)),t(this,Je).mainBody.addEventListener("scroll",()=>{this.querySelector("nine-table-hscrollbar").refresh()})},"#init"));d(this,kr,h(()=>{v.log("11111*****************"),Ci.SCROLLBAR_SIZE,v.log("2222*****************"),this.innerHTML=`
245
+ `},"#renderer"));d(this,gr,h(e=>{const s=e.composedPath?e.composedPath():[];s.includes(this)||t(this,Kt)&&s.includes(t(this,Kt))||this.close()},"#closeHandler"));d(this,br,h(()=>{var l;t(this,ne).loading=!0;const e=t(this,oe).view.getArray(),s=t(this,bt).data.getHostFields(),i=e.filter(a=>{const c=a.v[s.indexOf("CHK")];return c==="Y"||c===!0}),r={...((l=t(this,Ft).filtering)==null?void 0:l.filters)||{}};t(this,Kt).columns.forEach(a=>{const c=a.expr||a.bind,u=a.expr?s.indexOf("DATA2"):s.indexOf("DATA"),f=i.map(g=>g.v[u]);f.length>0?r[c]=f:delete r[c]});const o=t(this,bt).data.count();setTimeout(()=>{try{o===i.length?t(this,Kt).columns.forEach(a=>{const c=a.expr||a.bind;c&&t(this,Ft).filtering.clear(c)}):t(this,Ft).filtering.set(r),t(this,Ft).querySelectorAll("nine-table-filter-button").forEach(a=>{a.updateFilteredState()}),t(this,Ft).invalidate(),this.close()}finally{t(this,ne).loading=!1}})},"#onOk"));d(this,mr,h(e=>{const s=e.target.value.toLowerCase().trim();if(!s)t(this,oe).filtering.clear();else{const i=t(this,bt).data.getArray(),o=t(this,bt).data.getHostFields().indexOf("DATA2"),l=[];i.forEach(a=>{const c=o>=0&&a.v?a.v[o]:"";String(c).replace(/<[^>]*>?/gm,"").toLowerCase().includes(s)&&l.push(c)}),v.log(l),t(this,oe).filtering.set({DATA2:[...new Set(l)]})}},"#onInput"));d(this,yr,h(e=>{var l,a;const s=e.target.checked,i=((a=(l=t(this,bt))==null?void 0:l.data)==null?void 0:a.getArray())||[],o=t(this,bt).data.getHostFields().indexOf("CHK");o>=0&&i.forEach(c=>{c.v[o]=s?"Y":"N"}),t(this,bt).refresh()},"#onSelectAll"));d(this,To,h(()=>{this.close()},"#onCancel"))}connectedCallback(){t(this,ur).call(this),document.addEventListener("mousedown",t(this,gr))}open(e){p(this,Kt,e);const s=e.closest("th, td");this.currentCol=s==null?void 0:s.dataset.col;const i=s.getBoundingClientRect(),r=t(this,Ft).getBoundingClientRect(),o=this.offsetWidth||240;let l=i.right-r.left-o,a=i.bottom-r.top;l<0&&(l=Math.max(0,i.left-r.left)),this.style.left=`${l}px`,this.style.top=`${a}px`;const c=this.querySelector(".search-box");c.value="",this.classList.add("active"),this.classList.add("loading"),setTimeout(()=>{try{A(this,pr,Nl).call(this),t(this,oe).rowManager.scrollToDataRow(0)}finally{this.classList.remove("loading")}})}close(){this.currentCol=null,this.classList.remove("active"),p(this,Kt,null)}};Ft=new WeakMap,ne=new WeakMap,bt=new WeakMap,oe=new WeakMap,Kt=new WeakMap,ur=new WeakMap,fr=new WeakMap,gr=new WeakMap,pr=new WeakSet,Nl=h(function(){var c,u;const e=t(this,ne).data.getArray(),s=((c=t(this,Kt))==null?void 0:c.columns)||[],i=t(this,ne).fields.get()||[],r=((u=t(this,Ft).filtering)==null?void 0:u.filters)||{},o=t(this,ne).exprEngine,l=s.flatMap(f=>{const g=f.bind,b=f.expr,m=g||b,y=g?i.indexOf(g):-1,x=r[m]||[],w=new Map;for(let L=0;L<e.length;L++){const C=e[L];if(!C)continue;let W;y>=0&&C.v?W=C.v[y]:g&&g.includes("data.")?W=o?o.evaluate(g,C,L):void 0:b&&o&&(W=o.evaluate(b,C,L));let T=W;b&&o&&(T=o.evaluate(b,C,L)),T!=null&&!w.has(T)&&w.set(T,{v:W,v2:T})}const S=[...w.values()];return S.sort((L,C)=>String(L.v2||"").localeCompare(String(C.v2||""))),x.sort((L,C)=>L>C?1:-1),S.map(L=>({LVL:2,DATA:L.v,DATA2:L.v2===""||L.v2===null||L.v2===void 0?'<span class="empty-value">(empty)</span>':L.v2,COLNM:m,CHK:x.length===0||x.nineBinarySearch(L.v||"")>=0?"Y":"N"}))});t(this,bt).data.set(l);const a=this.querySelector("#chkSelectAll");a&&(a.checked=l.length>0&&l.every(f=>f.CHK==="Y"))},"#loadVirtualFilterItems"),br=new WeakMap,mr=new WeakMap,yr=new WeakMap,To=new WeakMap,h(ko,"NineTableFilterPanel");let Wn=ko;const Io=class Io extends HTMLElement{constructor(){super(...arguments);d(this,Ge);d(this,je,null);E(this,"updateFilteredState",h(()=>{var i;const e=((i=t(this,Ge).filtering)==null?void 0:i.filters)||{},s=this.columns.some(r=>{const o=r.expr||r.bind;return o&&e[o]&&e[o].length>0});this.classList.toggle("filtered",s)},"updateFilteredState"));d(this,pi,h(e=>{e.preventDefault(),e.stopPropagation();const s=t(this,Ge).querySelector("nine-table-filter-panel"),i=this.closest("th, td"),r=i==null?void 0:i.dataset.col;s&&s.currentCol===r&&s.classList.contains("active")?s.close():s&&s.open(this)},"#onClick"))}connectedCallback(){p(this,Ge,this.closest("nine-table-sheet")||this.getRootNode().host),this.removeEventListener("click",t(this,pi)),this.addEventListener("click",t(this,pi))}get columns(){if(t(this,je))return t(this,je);const e=this.closest("th, td"),s=e==null?void 0:e.dataset.col,i=t(this,Ge).sourceTable,r=[],o=new Set;return i&&s!==void 0&&i.querySelectorAll(`tbody [data-col="${s}"]`).forEach(l=>{const a=l.dataset.bind,c=l.dataset.expr;if(a||c){const u=`${a||""}_${c||""}`;o.has(u)||(o.add(u),r.push({bind:a,expr:c}))}}),p(this,je,r),t(this,je)}};Ge=new WeakMap,je=new WeakMap,pi=new WeakMap,h(Io,"NineTableFilterButton");let On=Io;const qo=class qo{constructor(n){d(this,bi);d(this,kt);d(this,Se);d(this,Ke,!1);d(this,xr,null);d(this,Yt,{});d(this,wr,h(()=>{t(this,vr).call(this)},"#init"));d(this,vr,h(()=>{if(t(this,Se).tagName.toLowerCase()==="nine-table-simple")return;let n=t(this,kt).querySelector("nine-table-filter-panel");n||(n=document.createElement("nine-table-filter-panel"),t(this,kt).appendChild(n)),p(this,xr,n)},"#initFilterPanel"));E(this,"clear",h(n=>{n?delete t(this,Yt)[n]:p(this,Yt,{}),p(this,Ke,Object.keys(t(this,Yt)).length>0),A(this,bi,pl).call(this),t(this,kt).querySelectorAll("nine-table-filter-button").forEach(e=>{e.updateFilteredState()}),v.log(`🔄 [NineTableFiltering] Filter cleared for ${n||"all"}`)},"clear"));E(this,"set",h(n=>{v.log(n);let e=Array.isArray(n)?Object.fromEntries(Object.keys(n[0]).map(s=>[s,[...new Set(n.map(i=>i[s]))]])):n;p(this,Yt,e),p(this,Ke,Object.keys(e).length>0),t(this,kt).toggleAttribute("filtering",t(this,Ke)),A(this,bi,pl).call(this)},"set"));p(this,kt,n),p(this,Se,t(this,kt).getRootNode().host),t(this,wr).call(this)}get filters(){return t(this,Yt)}isFiltering(){return t(this,Ke)}};kt=new WeakMap,Se=new WeakMap,Ke=new WeakMap,xr=new WeakMap,Yt=new WeakMap,wr=new WeakMap,vr=new WeakMap,bi=new WeakSet,pl=h(function(){const e=t(this,Se).data.getArray(),s=t(this,Se).data.getHostFields(),i=t(this,kt).index,r=t(this,Se).exprEngine;if(!(Object.keys(t(this,Yt)).length>0)){e.forEach(a=>{var c,u;(u=(c=a==null?void 0:a.m)==null?void 0:c._)!=null&&u[Nt.META.INDEX.FILTER]&&(a.m._[Nt.META.INDEX.FILTER][i]=!0)}),t(this,kt).invalidate();return}const l=Object.entries(t(this,Yt)).map(([a,c])=>{const u=a.includes("data.")||a.includes("host.")||a.includes("rowItem.v");return{targetKey:a,isExpr:u,fieldIdx:u?-1:s.indexOf(a),allowedSet:new Set(c)}});e.forEach((a,c)=>{if(!a)return;a.m._[Nt.META.INDEX.FILTER]||(a.m._[Nt.META.INDEX.FILTER]=[]);let u=!0;for(let f=0;f<l.length;f++){const{targetKey:g,isExpr:b,fieldIdx:m,allowedSet:y}=l[f];let x;if(b&&r?x=r.evaluate(g,a,c):m>=0&&a.v&&(x=a.v[m]),!y.has(x)){u=!1;break}}a.m._[Nt.META.INDEX.FILTER][i]=u}),t(this,kt).invalidate()},"#applyFiltering"),h(qo,"Filtering");let zn=qo;customElements.get("nine-table-filter-panel")||customElements.define("nine-table-filter-panel",Wn),customElements.get("nine-table-filter-button")||customElements.define("nine-table-filter-button",On);const Mo=class Mo{constructor(n){d(this,Wt);d(this,ct);d(this,mi);d(this,ht,[]);p(this,ct,n),p(this,mi,n.getRootNode().host),setTimeout(()=>{A(this,Wt,Dl).call(this)},300)}restore(){var n;p(this,ht,[]),t(this,ct).view&&t(this,ct).view.resetSorting(),A(this,Wt,bl).call(this),(n=t(this,ct).rowManager)==null||n.refresh(!0)}};ct=new WeakMap,mi=new WeakMap,ht=new WeakMap,Wt=new WeakSet,Dl=h(function(){t(this,ct).querySelectorAll("thead").forEach(n=>{n.addEventListener("dblclick",e=>{const s=e.target.closest("th, td");if(!s||s.classList.contains("resizable-edge")||["INPUT","CELL-CHECKBOX"].includes(e.target.tagName)||e.offsetX<=2||e.offsetX>=s.offsetWidth-2)return;const i=t(this,ct).getRootNode().host;i.loading=!0,setTimeout(()=>{try{A(this,Wt,$l).call(this,e,s)}finally{i.loading=!1}})})}),v.log("🎯 [NineTableSorting] Initialized")},"#initEvents"),$l=h(function(n,e){const s=e.dataset.col,i=e.closest("tr"),r=i?i.dataset.subrow||String(i.sectionRowIndex):"0";if(s===void 0)return;const o=t(this,ct).sourceTable;if(!o)return;let l=null,a=null;if(o.querySelectorAll(`tbody [data-col="${s}"]`).forEach(b=>{b.dataset.bind&&(l=b.dataset.bind),b.dataset.expr&&(a=b.dataset.expr)}),!l&&!a)return;const c=e.classList.contains("asc"),u=e.classList.contains("desc");!n.ctrlKey&&!n.shiftKey&&p(this,ht,[]);const f=t(this,ht).findIndex(b=>b.colIndex===s&&b.subRowIndex===r||b.colName===l),g={colIndex:s,subRowIndex:r,colname:l||a,colName:l||a,expr:a,asc:!0,"expr-func":a?(b,m)=>t(this,mi).exprEngine(a,b,m):null};!c&&!u?f>=0?t(this,ht)[f].asc=!0:t(this,ht).push({...g,asc:!0}):c?f>=0?t(this,ht)[f].asc=!1:t(this,ht).push({...g,asc:!1}):p(this,ht,t(this,ht).filter(b=>!(b.colIndex===s&&b.subRowIndex===r||b.colName===l))),A(this,Wt,Fl).call(this)},"#handleSort"),Fl=h(function(){if(!t(this,ct).view){console.warn("⚠️ [NineTableSorting] Sheet view (SheetView) is not initialized.");return}t(this,ct).view.setSorting(t(this,ht)),A(this,Wt,bl).call(this),t(this,ct).invalidate(),v.log("🔄 [NineTableSorting] Sorting applied via RowManager.refresh(true)")},"#applySorting"),bl=h(function(){t(this,ct).querySelectorAll("thead th, thead td").forEach(n=>{n.classList.remove("asc","desc")}),t(this,ht).length!==0&&t(this,ht).forEach(n=>{const{colIndex:e,subRowIndex:s,asc:i}=n;if(e!==void 0){let r=`thead [data-col="${e}"]`;s!==void 0&&(r=`thead tr[data-subrow="${s}"] [data-col="${e}"]`),t(this,ct).querySelectorAll(r).forEach(l=>{l.classList.add(i?"asc":"desc")})}})},"#syncHeaderUI"),h(Mo,"Sorting");let Bn=Mo;const No=class No{constructor(n){d(this,Ye);d(this,yt);d(this,Ae,[]);d(this,Ho,[]);d(this,yi,[]);d(this,le,null);E(this,"getArray",h((n,e)=>{if(!t(this,le)){const r=t(this,yt).data.getArray();p(this,le,t(this,yi).map(o=>r[o]))}const s=t(this,le);if(n==null)return s;if(n<0||n>=s.length)return null;const i=s[n];if(e!=null){const o=t(this,yt).data.getHostFields().indexOf(e);return o>=0&&i.v?i.v[o]:null}return i},"getArray"));E(this,"get",h((n,e)=>{var o,l;const s=this.getArray(),i=((l=(o=t(this,yt).data).getHostFields)==null?void 0:l.call(o))||[];if(n==null)return s.map(a=>t(this,xi).call(this,a,i));if(n<0||n>=s.length)return null;const r=s[n];if(!r)return null;if(e!=null){const a=i.indexOf(e);return a>=0&&r.v?r.v[a]:null}return t(this,xi).call(this,r,i)},"get"));d(this,xi,h((n,e)=>{if(!n)return null;const s={};return e.forEach((i,r)=>{s[i]=n.v?n.v[r]:n[i]}),n.m&&(s.m=n.m),n._&&(s._=n._),s},"#convSingle"));E(this,"refresh",h(()=>{var r;p(this,le,null);const n=t(this,yt).data.getArray();let e=[];n.forEach((o,l)=>{var c,u;if(!o)return;const a=(u=(c=o.m)==null?void 0:c._)==null?void 0:u[Nt.META.INDEX.FILTER];a&&a[t(this,Ye).index]===!1||e.push(l)}),v.log(e),t(this,Ae).length>0&&(e=t(this,Sr).call(this,e,n)),p(this,yi,e);const s=e.map(o=>n[o]),i=((r=t(this,Ye).grouping)==null?void 0:r.columns)||[];if(i.length>0){const o=Mn.apply(s,i,t(this,yt).data.getHostFields());p(this,le,o.renderItems),t(this,Ye).grouping.setGroupMap(o.groupMap)}else p(this,le,s)},"refresh"));E(this,"setSorting",h(n=>{p(this,Ae,n||[]),this.refresh()},"setSorting"));E(this,"getSorting",h(()=>t(this,Ae),"getSorting"));E(this,"resetSorting",h(()=>{p(this,Ae,[]),this.refresh()},"resetSorting"));d(this,Sr,h((n,e)=>{v.log(new Date);const s=typeof t(this,yt).data.getHostFields=="function"?t(this,yt).data.getHostFields():[],i=t(this,Ae).map(r=>({...r,colIndex:s.indexOf(r.colname||r.colName)}));return n.sort((r,o)=>{const l=e[r],a=e[o];for(const c of i){const u=c.asc,f=c.expr;let g,b;f?(g=t(this,yt).exprEngine.evaluate(f,l,r),b=t(this,yt).exprEngine.evaluate(f,a,o)):c.colIndex>=0&&l.v&&a.v&&(g=l.v[c.colIndex],b=a.v[c.colIndex]);const m=g==null||g==="",y=b==null||b==="";if(!(m&&y)){if(m)return 1;if(y)return-1;if(g!==b){let x=0;if(typeof g=="number"&&typeof b=="number")x=g-b;else{const w=String(g),S=String(b);x=w>S?1:w<S?-1:0}if(x!==0)return u?x:-x}}}return r-o})},"#applySorting"));p(this,Ye,n),p(this,yt,n.getRootNode().host),this.refresh()}};Ye=new WeakMap,yt=new WeakMap,Ae=new WeakMap,Ho=new WeakMap,yi=new WeakMap,le=new WeakMap,xi=new WeakMap,Sr=new WeakMap,h(No,"SheetView");let Vi=No;const Pn=16,nt=class nt{static initializeTable(n,e){var s,i,r,o,l,a,c,u,f,g,b;return!n||!e?null:(A(s=nt,O,Bl).call(s,e),A(i=nt,O,Vl).call(i,e),A(r=nt,O,zl).call(r,e),A(o=nt,O,jl).call(o,e),A(l=nt,O,Pl).call(l,e),fe.resetColIndex(e,e.querySelectorAll("thead tr")),fe.resetColIndex(e,e.querySelectorAll('tbody.body tr[grouping="true"]')),fe.resetColIndex(e,e.querySelectorAll('tbody.body tr:not([grouping="true"])')),fe.resetColIndex(e,e.querySelectorAll("tfoot tr")),A(a=nt,O,Wl).call(a,e),A(c=nt,O,Xl).call(c,e),A(u=nt,O,_l).call(u,n,e),A(f=nt,O,Gl).call(f,e),A(g=nt,O,Ul).call(g,n,e),A(b=nt,O,Kl).call(b,e),e)}};O=new WeakSet,Wl=h(function(n){const e=n.querySelector("thead");if(!e||e.querySelector(".col-indicator-rowgroup"))return;const s='<th data-col="@col" class="col-indicator" scope="col"></th>',i=e.insertRow(0);i.setAttribute("role","row"),i.classList.add("col-indicator-rowgroup"),i.classList.add("collapse");const r=n.querySelector("tbody tr");if(!r)return;let o=0;r.querySelectorAll("th, td").forEach(a=>{var c;if(!a.classList.contains("dummy")){const u=a.colSpan||1;for(let f=0;f<u;f++){const g=s.replace("@col",o).replace("@text",A(c=nt,O,Ol).call(c,o++));i.insertAdjacentHTML("beforeend",g)}}});const l=Array.from(n.querySelectorAll("colgroup col"));i.querySelectorAll(".col-indicator").forEach((a,c)=>{const u=l[c].getAttribute("background");u&&(a.style.background=u)})},"#createColIndicator"),Ol=h(function(n){let e="";for(let s=n;s>=0;s=Math.floor(s/26)-1)e=String.fromCharCode(65+s%26)+e;return e},"#numToExcelCol"),zl=h(function(n){let e=n.querySelector("tbody:not(.head):not(.foot)");if(e){if(e.classList.add("body"),!n.querySelector("tbody.head")){const s=document.createElement("tbody");s.classList.add("head"),e.before(s)}if(!n.querySelector("tbody.foot")){const s=document.createElement("tbody");s.classList.add("foot"),e.after(s)}}},"#ensureSectionTbodys"),Bl=h(function(n){let e=n.querySelector("colgroup");if(e||(e=document.createElement("colgroup"),n.prepend(e)),e.querySelectorAll("col").length===0){const s=n.querySelector("tbody tr");let i=1;s&&(i=Array.from(s.querySelectorAll("th, td")).reduce((r,o)=>r+(parseInt(o.getAttribute("colspan")||o.colSpan,10)||1),0)),i=Math.max(i,1);for(let r=0;r<i;r++){const o=document.createElement("col");e.appendChild(o)}}},"#ensureColgroup"),Pl=h(function(n){const e=Array.from(n.querySelectorAll("colgroup col"));if(e.length===0)return;const s=n.clientWidth||0,i=Math.max(Math.floor(s/e.length),100);e.forEach((r,o)=>{r.hasAttribute("data-col")||r.setAttribute("data-col",o);const l=r.getAttribute("width")||parseInt(r.style.width,10)||i;r.setAttribute("width",l);const a=String(l).includes("px")?l:`${l}px`;r.style.width=a})},"#normalizeColAttributes"),Vl=h(function(n){if(n.querySelector("thead"))return;const e=document.createElement("thead"),s=n.querySelector("colgroup");s?s.after(e):n.prepend(e)},"#ensureThead"),Xl=h(function(n){n.querySelectorAll("thead th, thead td").forEach(s=>{s.getAttribute("collapsed")==="true"&&s.getAttribute("collapsible")!=="true"&&s.setAttribute("collapsible","true")})},"#normalizeCollapsibleAttributes"),_l=h(function(n,e){const s=["data-bind","data-expr","type"];let i=0;e.querySelectorAll("tbody th, tbody td").forEach(r=>{const l=`cell-${r.getAttribute("cell-type")||"renderer"}`,a=r.querySelector("datalist");if(a){let f=[];a.querySelectorAll("option").forEach(b=>{f.push({k:b.getAttribute("k"),v:b.getAttribute("v")})});const g=`__ds_${Date.now()}_${++i}`;n&&(n[g]=()=>f),r.setAttribute("data-source",`host.${g}()`),a.remove()}const c=r.dataset.expr;c&&r.setAttribute("data-expr",n.exprEngine.precompile(c)),Array.from(r.attributes).forEach(f=>{["data-bind","data-expr","cell-type"].includes(f.name)||(f.value.includes("data.")||f.value.includes("host."))&&r.setAttribute(f.name,n.exprEngine.precompile(f.value))});const u=s.filter(f=>r.hasAttribute(f)).map(f=>`${f}="${r.getAttribute(f)}"`);r.innerHTML=`<${l} ${u.join(" ")}></${l}>`,r.setAttribute("tabindex","0")}),e.querySelectorAll("thead th, thead td, tfoot th, tfoot td").forEach(r=>{const o=r.getAttribute("cell-type");if(o){const l=r.innerHTML,a=`cell-${o}`,c=s.filter(u=>r.hasAttribute(u)).map(u=>`${u}="${r.getAttribute(u)}"`);r.innerHTML=`<${a} ${c.join(" ")} content="${l}"></${a}>`}})},"#generateCell"),Ul=h(function(n,e){const s=n.getAttribute("filtering")==="true",i=e.getAttribute("filtering")==="true";e.querySelectorAll("thead tr:not(.col-indicator-rowgroup) th, thead tr:not(.col-indicator-rowgroup) td").forEach(r=>{const o=r.getAttribute("filtering")==="true"||i||s;r.setAttribute("filtering",o?"true":"false"),o&&r.appendChild(document.createElement("nine-table-filter-button"))})},"#initFilterButtons"),Gl=h(function(n){n.querySelectorAll("thead th, thead td").forEach(e=>{if(!(e.getAttribute("collapsible")==="true"||e.getAttribute("expandable")==="true"))return;v.log("11.*******************************",e.dataset.col);const i=parseInt(e.dataset.col,10),r=e.colSpan||1,o=n.querySelector(`colgroup col[data-col="${i}"]`);v.log("11.*******************************",o);const l=o&&parseInt(o.getAttribute("width"),10)||100;(!e.dataset.expandWidth||parseInt(e.dataset.expandWidth,10)<=Pn)&&(e.dataset.expandWidth=String(l>Pn?l:100));let a=e.querySelector("nine-table-col-expand");if(a||(a=document.createElement("nine-table-col-expand"),e.insertBefore(a,e.firstChild)),e.getAttribute("collapsed")==="true"){a.classList.add("collapsed"),a.classList.remove("expand"),a.setAttribute("collapsed","true"),e.style.color="transparent";const u=Math.max(10,Math.floor(Pn/r));if(!isNaN(i))for(let f=0;f<r;f++){const g=n.querySelector(`colgroup col[data-col="${i+f}"]`);g&&(g.setAttribute("width",u),g.style.width=`${u}px`)}}else a.classList.remove("collapsed"),a.classList.add("expand"),a.setAttribute("collapsed","false"),e.style.color=""})},"#initColExpanders"),jl=h(function(n,e){const s=n.getAttribute("row-indicator")==="true"?48:0,i=n.querySelector("colgroup"),r=document.createElement("col");r.setAttribute("fixed","left"),r.setAttribute("width",s),r.style.width=`${s}px`,i.prepend(r),n.querySelectorAll("thead, tbody, tfoot").forEach(o=>{const l=Array.from(o.querySelectorAll("tr"));if(l.length===0)return;const a=l[0],c=document.createElement("th");c.className="row-indicator",c.setAttribute("cell-type","row-indicator"),l.length>1&&(c.rowSpan=l.length),a.insertBefore(c,a.firstElementChild)})},"#ensureRowIndicator"),Kl=h(function(n){n.querySelectorAll("th[data-col], td[data-col]").forEach(e=>{v.log(e);const s=parseInt(e.getAttribute("data-col"),10);if(isNaN(s))return;const i=parseInt(e.getAttribute("colspan")||e.colSpan,10)||1;let r=0;for(let o=0;o<i;o++){const l=s+o,a=n.querySelector(`colgroup col[data-col="${l}"]`);a&&(r+=parseInt(a.getAttribute("width"),10)||100)}if(r>0){const o=`${r}px`;e.style.width=o,e.style.minWidth=o,e.style.maxWidth=o}})},"#applyInitialCellWidths"),d(nt,O),h(nt,"PreCompiler");let Vn=nt;const Ci=class Ci extends HTMLElement{constructor(){super();d(this,Er);d(this,wi);d(this,ae);d(this,Ot);d(this,vi);d(this,Si);d(this,Ee);d(this,xs);d(this,Ai);d(this,Ar);d(this,Ei);d(this,ws);d(this,Ze);d(this,It,{table:null});d(this,Je);d(this,Rr,h(()=>{const e=this.querySelector(".ng-container-body thead"),s=this.querySelector(".ng-nodata-overlay");s.style.top=`${e.offsetHeight}px`},"#adjustOverlay"));E(this,"invalidate",h(()=>{this.view.refresh(),t(this,Ot).refresh(!0),this.isAutoFitCol&&this.autoFit(!0)},"invalidate"));E(this,"autoFit",h((e=!0)=>{requestAnimationFrame(()=>{var s;(s=t(this,Lr))==null||s.call(this,e)})},"autoFit"));d(this,Lr,h((e=!0)=>{var r;v.log("***************** autoFit",this);const s=this.querySelector(".ng-sheet-body .ng-container-body");if(!s)return;const i=this.querySelector(".ng-container-body table colgroup");if(i){if(e){this.setAttribute("auto-fit-col","true");const o=s.clientWidth;if(o<=0)return;let l=0;const a=[];i.querySelectorAll("col").forEach(f=>{const g=f.getAttribute("data-col"),b=this.querySelector(`thead th[data-col="${g}"]`);if((b==null?void 0:b.getAttribute("collapsed"))==="true")a.unshift({globalColIndex:g,width:16,isCollapsed:!0}),v.log(`[AutoFit Col] Index ${g}: COLLAPSED (forced 16px)`);else{const y=parseInt(f.getAttribute("width"),10)||100;a.push({globalColIndex:g,width:y,isCollapsed:!1}),l+=y,v.log(`[AutoFit Col] Index ${g}: NORMAL (original width: ${y}px)`)}}),v.log(`[AutoFit] Total Original Width of Normal Cols: ${l}px`);const c=a.filter(f=>f.isCollapsed).reduce((f,g)=>f+g.width,0),u=Math.max(0,o-c);if(v.log(`[AutoFit] Collapsed Total Width: ${c}px | Available Width for Normal Cols: ${u}px`),l>0&&a.length>0){let f=0;const g=a.map(x=>{if(x.isCollapsed)return{globalColIndex:x.globalColIndex,remainder:0,width:16};const w=x.width*u/l,S=Math.max(30,Math.floor(w));return f+=S,{globalColIndex:x.globalColIndex,remainder:w-Math.floor(w),width:S}});let b=u-f;v.log(`[AutoFit] Initial Allocated Total: ${f}px | Remainder Pixels to distribute: ${b}`);const m=g.filter(x=>{var w;return!((w=a.find(S=>S.globalColIndex===x.globalColIndex))!=null&&w.isCollapsed)});if(b>0&&m.length>0){m.sort((x,w)=>w.remainder-x.remainder);for(let x=0;x<b;x++)m[x%m.length].width+=1}else if(b<0&&m.length>0){m.sort((x,w)=>x.remainder-w.remainder);for(let x=0;x<Math.abs(b);x++){const w=m[x%m.length];w.width>30&&(w.width-=1)}}const y=g.reduce((x,w)=>x+w.width,0);v.log(`[AutoFit Verification] Target Container Width: ${o}px | Sum of All Calculated Cols: ${y}px`),o!==y?v.log(`⚠️ [AutoFit Mismatch Warning!] 오차 발생: ${o-y}px 차이가 납니다.`):v.log("✅ [AutoFit Success] 완벽하게 일치합니다!"),g.forEach(({globalColIndex:x,width:w})=>{var S;v.log(`[AutoFit Apply] Col Index ${x} -> ${w}px`),(S=t(this,Ee))==null||S.setColumnWidth(x,w,"body")})}}else this.removeAttribute("auto-fit-col");(r=this.querySelector("nine-table-hscrollbar"))==null||r.refresh()}},"#autoFit"));E(this,"generate",h((e,s)=>{p(this,wi,s),Vn.initializeTable(t(this,ae),e),v.log("=======",e),p(this,It,{table:fe.compile(e),tbody:{tr:e.querySelectorAll("tbody tr")}}),t(this,Ri).call(this),t(this,Qe).call(this),t(this,Ir).call(this),t(this,qr).call(this),["left","body","right"].forEach(i=>{const r=`.ng-container-${i}`;t(this,Je)[i]={thead:this.querySelector(`${r} thead`),tbody:{head:this.querySelector(`${r} tbody.head`),body:this.querySelector(`${r} tbody.body`),foot:this.querySelector(`${r} tbody.foot`)},tfoot:this.querySelector(`${r} tfoot`)}}),t(this,Ot).initialize(),this.isAutoFitCol?this.autoFit(!0):this.querySelector("nine-table-hscrollbar").refresh(),t(this,ws).initialize(),this.loaded=!0},"generate"));d(this,Qe,h(()=>{this.isAutoFitCol,["left","right","body"].forEach(e=>{const s=this.querySelectorAll(`.ng-container-${e}`);if(s.length===0)return;const i=s[0].querySelector("table");if(!i)return;let r=0;i.querySelectorAll("col").forEach(o=>{const l=parseInt(o.getAttribute("width"),10);isNaN(l)||(r+=l)}),s.forEach(o=>{const l=o.querySelectorAll("table");e==="body"?(o.style.flex="1",l.forEach(a=>{})):(o.style.flex=`0 0 ${r}px`,o.style.width=`${r}px`,o.style.minWidth=`${r}px`,o.style.maxWidth=`${r}px`,l.forEach(a=>{}))})})},"#updateContainerWidths"));d(this,Ri,h(()=>{[{selector:".ng-container-left",type:"left"},{selector:".ng-container-body",type:null},{selector:".ng-container-right",type:"right"}].forEach(({selector:s,type:i})=>{this.querySelector(`.ng-sheet-body ${s}`).appendChild(t(this,Cr).call(this,i))})},"#renderSplitContainers"));d(this,Cr,h(e=>{const s=t(this,It).table.cloneNode(!0);return e==="left"?s.querySelectorAll("col, th, td").forEach(i=>{i.getAttribute("fixed")!=="left"&&i.remove()}):e==="right"?s.querySelectorAll("col, th, td").forEach(i=>{i.getAttribute("fixed")!=="right"&&i.remove()}):s.querySelectorAll("[fixed=left], [fixed=right]").forEach(i=>{i.remove()}),s},"#createSplitTable"));E(this,"getRowHeight",h(()=>t(this,Ot).getRowHeight(),"getRowHeight"));E(this,"scrollToX",h(e=>{const s=this.querySelector(".ng-sheet-body .ng-container-body");s&&(s.scrollLeft=e)},"scrollToX"));E(this,"scrollToY",h(e=>{const s=this.querySelector(".ng-sheet-body");s&&(s.scrollTop=e)},"scrollToY"));d(this,Tr,h(()=>{v.log("11111*****************"),t(this,kr).call(this),p(this,vi,new Nn(this)),p(this,Si,new Dn(this)),p(this,Ee,new $n(this)),p(this,xs,new Fn(this)),p(this,Ai,new Pi(this)),p(this,Ze,new Vi(this)),p(this,Ei,new zn(this)),p(this,ws,new qn(this)),t(this,Er,Yl)||p(this,Ar,new Bn(this)),t(this,Je).mainBody.addEventListener("scroll",()=>{this.querySelector("nine-table-hscrollbar").refresh()})},"#init"));d(this,kr,h(()=>{v.log("11111*****************"),Ci.SCROLLBAR_SIZE,v.log("2222*****************"),this.innerHTML=`
247
246
  <div class="ng-sheet-body">
248
247
  <div class="ng-sheet-body-content">
249
248
  <div class="ng-container-left"></div>
@@ -273,7 +272,7 @@
273
272
 
274
273
  <div class="ng-col-mover-grip"></div>
275
274
  <div class="ng-col-mover-indi"></div>
276
- `,v.log("3333*****************"),p(this,Je,{mainBody:this.querySelector(".ng-sheet-body .ng-container-body"),hscrollbar:this.querySelector("nine-table-hscrollbar"),vscrollbar:this.querySelector("nine-table-vscrollbar"),content:this.querySelector(".ng-sheet-body .ng-sheet-body-content"),scrollHolder:this.querySelector(".ng-sheet-body .ng-virtual-height-holder")}),v.log("444*****************")},"#render"));d(this,Ir,h(()=>{v.log("**********************","#syncHeaderAndFooterHeights");const e=this.querySelector(".ng-container-left table"),s=this.querySelector(".ng-container-body table"),i=this.querySelector(".ng-container-right table"),r=Array.from(e.querySelectorAll("thead tr:not(.col-indicator-rowgroup)")),o=Array.from(s.querySelectorAll("thead tr:not(.col-indicator-rowgroup)")),l=Array.from(i.querySelectorAll("thead tr:not(.col-indicator-rowgroup)"));t(this,Ri).call(this,r,o,l);const a=Array.from(e.querySelectorAll("tfoot tr")),c=Array.from(s.querySelectorAll("tfoot tr")),u=Array.from(i.querySelectorAll("tfoot tr"));t(this,Ri).call(this,a,c,u)},"#syncHeaderAndFooterHeights"));d(this,Ri,h((e,s,i)=>{var o,l,a;const r=Math.max(e.length,s.length,i.length);for(let c=0;c<r;c++){const u=[((o=e[c])==null?void 0:o.getBoundingClientRect().height)||0,((l=s[c])==null?void 0:l.getBoundingClientRect().height)||0,((a=i[c])==null?void 0:a.getBoundingClientRect().height)||0],g=Math.max(...u);g>0&&(e[c]&&(e[c].style.height=`${g}px`),s[c]&&(s[c].style.height=`${g}px`),i[c]&&(i[c].style.height=`${g}px`))}},"#applyMaxHeights"));d(this,qr,h(()=>{const e=this.querySelector(".ng-sheet-body");if(!e)return;let s=null;e.addEventListener("mouseover",i=>{const r=i.target.closest("tr");if(!r||!r.dataset.row&&r.dataset.row!=="0")return;const o=r.dataset.row;s!==o&&(s=o,e.querySelectorAll(`tr[data-row="${o}"]`).forEach(l=>{l.classList.add("hover")}))}),e.addEventListener("mouseout",i=>{const r=i.target.closest("tr");if(!r)return;const o=i.relatedTarget;r.contains(o)||(e.querySelectorAll("tr.hover").forEach(l=>{l.classList.remove("hover")}),s=null)})},"#initRowHoverEvent"));v.log("11111"),p(this,zt,new Hn(this)),v.log("222"),p(this,ae,this.getRootNode().host),v.log("333")}connectedCallback(){t(this,Tr).call(this)}get index(){return t(this,wi)}get colResizer(){return t(this,Ee)}get filtering(){return t(this,Ei)}get grouping(){return t(this,ws)}get colMover(){return t(this,xs)}get colFix(){return t(this,Ai)}get rowManager(){return t(this,zt)}get selection(){return t(this,vi)}get navigation(){return t(this,Si)}get templateLength(){return t(this,qt).tbody.tr.length||0}get elements(){return t(this,Je)}get isAutoFitCol(){var i,r;const e=this.getAttribute("auto-fit-col")==="true"||((i=t(this,ae))==null?void 0:i.getAttribute("auto-fit-col"))==="true",s=((r=t(this,qt).table)==null?void 0:r.getAttribute("auto-fit-col"))==="true";return e||s}get sourceTable(){return t(this,qt).table}get source(){return t(this,qt)}recompileAndRefresh(){var e;t(this,qt).table&&(fe.recompile(t(this,qt).table),["left","right","body"].forEach(s=>{["header","body","footer"].forEach(i=>{const r=this.querySelector(`.ng-sheet-${i} .ng-container-${s}`);r&&r.querySelectorAll("table").forEach(o=>o.remove())})}),t(this,Li).call(this),t(this,Qe).call(this),t(this,zt).initialize(),this.isAutoFitCol?this.autoFit(!0):(e=this.querySelector("nine-table-hscrollbar"))==null||e.refresh(),requestAnimationFrame(()=>{var s;t(this,Qe).call(this),(s=t(this,zt))==null||s.refresh()}))}refreshLayout(){!this.classList.contains("active")||!t(this,qt).table||requestAnimationFrame(()=>{var e,s,i;t(this,Qe).call(this),this.isAutoFitCol?this.autoFit(!0):(e=this.querySelector("nine-table-hscrollbar"))==null||e.refresh(),t(this,Lr).call(this),(s=t(this,Ee))==null||s.refreshLayout(),(i=t(this,zt))==null||i.refresh()})}get view(){var e;return!t(this,Ze)&&((e=t(this,ae))!=null&&e.data)&&p(this,Ze,new Vi(this)),t(this,Ze)}disconnectedCallback(){var e,s;(e=t(this,Ee))==null||e.destroy(),(s=t(this,xs))==null||s.destroy(),this.innerHTML=""}};wi=new WeakMap,ae=new WeakMap,zt=new WeakMap,vi=new WeakMap,Si=new WeakMap,Ee=new WeakMap,xs=new WeakMap,Ai=new WeakMap,Ar=new WeakMap,Ei=new WeakMap,ws=new WeakMap,Ze=new WeakMap,qt=new WeakMap,Je=new WeakMap,Er=new WeakSet,Yl=h(function(){return t(this,ae).hasAttribute("simple")||t(this,ae).getAttribute("theme")==="simple"},"#isSimple"),Lr=new WeakMap,Rr=new WeakMap,Qe=new WeakMap,Li=new WeakMap,Cr=new WeakMap,Tr=new WeakMap,kr=new WeakMap,Ir=new WeakMap,Ri=new WeakMap,qr=new WeakMap,h(Ci,"NineTableSheet"),E(Ci,"SCROLLBAR_SIZE",16);let Xi=Ci;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",Xi);const Do=class Do{constructor(n){d(this,it);d(this,Mr,h(()=>{t(this,Hr).call(this),new ResizeObserver(n=>{for(let e of n)t(this,it).getAttribute("auto-height")==="true"&&t(this,Ti).call(this)}).observe(t(this,it))},"#init"));d(this,Ti,h(()=>{const n=Array.from(t(this,it).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(n.length===0)return;const e=parseInt(t(this,it).getAttribute("max-display-row"),10)||10,s=Math.max(...n.map(u=>u.getRowHeight())),i=t(this,it).shadowRoot.querySelector("nine-table-toolbar"),r=t(this,it).shadowRoot.querySelector("nine-table-sheets-footer"),o=i?i.getBoundingClientRect().height:0,l=r?r.getBoundingClientRect().height:0,a=Xi.SCROLLBAR_SIZE,c=e*s+o+l+a;t(this,it).style.height=`${c}px`},"#applyAutoHeight"));d(this,Hr,h(()=>{const e=Array.from(t(this,it).children).filter(c=>c.tagName.toUpperCase()==="TABLE"),s=t(this,it).getAttribute("auto-height")==="true",i=e.length,r=e.map((c,u)=>{const g=u===0?"active":"",f=c.id||`sheet${u+1}`,b=`<nine-table-sheet class="${g}" data-index="${u}" data-sheet-id="${f}" id="${f}"></nine-table-sheet>`,m=u<i-1?`<nine-splitter class="h" data-split-index="${u}"></nine-splitter>`:"";return b+m}).join(""),o=["layout","nine-table-sheet","nine-table-vscrollbar","nine-table-hscrollbar","table"],l=o.map(c=>`@import "https://cdn.jsdelivr.net/npm/@ninebone/table@0.1.42/dist/css/${c}.css";`),a=[];nine.cssPath&&o.forEach(c=>{a.push(`@import "${nine.cssPath}/${c}.css";`)}),t(this,it).shadowRoot.innerHTML=`
275
+ `,v.log("3333*****************"),p(this,Je,{mainBody:this.querySelector(".ng-sheet-body .ng-container-body"),hscrollbar:this.querySelector("nine-table-hscrollbar"),vscrollbar:this.querySelector("nine-table-vscrollbar"),content:this.querySelector(".ng-sheet-body .ng-sheet-body-content"),scrollHolder:this.querySelector(".ng-sheet-body .ng-virtual-height-holder")}),v.log("444*****************")},"#render"));d(this,Ir,h(()=>{v.log("**********************","#syncHeaderAndFooterHeights");const e=this.querySelector(".ng-container-left table"),s=this.querySelector(".ng-container-body table"),i=this.querySelector(".ng-container-right table"),r=Array.from(e.querySelectorAll("thead tr:not(.col-indicator-rowgroup)")),o=Array.from(s.querySelectorAll("thead tr:not(.col-indicator-rowgroup)")),l=Array.from(i.querySelectorAll("thead tr:not(.col-indicator-rowgroup)"));t(this,Li).call(this,r,o,l);const a=Array.from(e.querySelectorAll("tfoot tr")),c=Array.from(s.querySelectorAll("tfoot tr")),u=Array.from(i.querySelectorAll("tfoot tr"));t(this,Li).call(this,a,c,u)},"#syncHeaderAndFooterHeights"));d(this,Li,h((e,s,i)=>{var o,l,a;const r=Math.max(e.length,s.length,i.length);for(let c=0;c<r;c++){const u=[((o=e[c])==null?void 0:o.getBoundingClientRect().height)||0,((l=s[c])==null?void 0:l.getBoundingClientRect().height)||0,((a=i[c])==null?void 0:a.getBoundingClientRect().height)||0],f=Math.max(...u);f>0&&(e[c]&&(e[c].style.height=`${f}px`),s[c]&&(s[c].style.height=`${f}px`),i[c]&&(i[c].style.height=`${f}px`))}},"#applyMaxHeights"));d(this,qr,h(()=>{const e=this.querySelector(".ng-sheet-body");if(!e)return;let s=null;e.addEventListener("mouseover",i=>{const r=i.target.closest("tr");if(!r||!r.dataset.row&&r.dataset.row!=="0")return;const o=r.dataset.row;s!==o&&(s=o,e.querySelectorAll(`tr[data-row="${o}"]`).forEach(l=>{l.classList.add("hover")}))}),e.addEventListener("mouseout",i=>{const r=i.target.closest("tr");if(!r)return;const o=i.relatedTarget;r.contains(o)||(e.querySelectorAll("tr.hover").forEach(l=>{l.classList.remove("hover")}),s=null)})},"#initRowHoverEvent"));v.log("11111"),p(this,Ot,new Hn(this)),v.log("222"),p(this,ae,this.getRootNode().host),v.log("333")}connectedCallback(){t(this,Tr).call(this)}get index(){return t(this,wi)}get colResizer(){return t(this,Ee)}get filtering(){return t(this,Ei)}get grouping(){return t(this,ws)}get colMover(){return t(this,xs)}get colFix(){return t(this,Ai)}get rowManager(){return t(this,Ot)}get selection(){return t(this,vi)}get navigation(){return t(this,Si)}get templateLength(){return t(this,It).tbody.tr.length||0}get elements(){return t(this,Je)}get isAutoFitCol(){var i,r;const e=this.getAttribute("auto-fit-col")==="true"||((i=t(this,ae))==null?void 0:i.getAttribute("auto-fit-col"))==="true",s=((r=t(this,It).table)==null?void 0:r.getAttribute("auto-fit-col"))==="true";return e||s}get sourceTable(){return t(this,It).table}get source(){return t(this,It)}recompileAndRefresh(){var e;t(this,It).table&&(fe.recompile(t(this,It).table),["left","right","body"].forEach(s=>{["header","body","footer"].forEach(i=>{const r=this.querySelector(`.ng-sheet-${i} .ng-container-${s}`);r&&r.querySelectorAll("table").forEach(o=>o.remove())})}),t(this,Ri).call(this),t(this,Qe).call(this),t(this,Ot).initialize(),this.isAutoFitCol?this.autoFit(!0):(e=this.querySelector("nine-table-hscrollbar"))==null||e.refresh(),requestAnimationFrame(()=>{var s;t(this,Qe).call(this),(s=t(this,Ot))==null||s.refresh()}))}refreshLayout(){!this.classList.contains("active")||!t(this,It).table||requestAnimationFrame(()=>{var e,s,i;t(this,Qe).call(this),this.isAutoFitCol?this.autoFit(!0):(e=this.querySelector("nine-table-hscrollbar"))==null||e.refresh(),t(this,Rr).call(this),(s=t(this,Ee))==null||s.refreshLayout(),(i=t(this,Ot))==null||i.refresh()})}get view(){var e;return!t(this,Ze)&&((e=t(this,ae))!=null&&e.data)&&p(this,Ze,new Vi(this)),t(this,Ze)}disconnectedCallback(){var e,s;(e=t(this,Ee))==null||e.destroy(),(s=t(this,xs))==null||s.destroy(),this.innerHTML=""}};wi=new WeakMap,ae=new WeakMap,Ot=new WeakMap,vi=new WeakMap,Si=new WeakMap,Ee=new WeakMap,xs=new WeakMap,Ai=new WeakMap,Ar=new WeakMap,Ei=new WeakMap,ws=new WeakMap,Ze=new WeakMap,It=new WeakMap,Je=new WeakMap,Er=new WeakSet,Yl=h(function(){return t(this,ae).hasAttribute("simple")||t(this,ae).getAttribute("theme")==="simple"},"#isSimple"),Rr=new WeakMap,Lr=new WeakMap,Qe=new WeakMap,Ri=new WeakMap,Cr=new WeakMap,Tr=new WeakMap,kr=new WeakMap,Ir=new WeakMap,Li=new WeakMap,qr=new WeakMap,h(Ci,"NineTableSheet"),E(Ci,"SCROLLBAR_SIZE",16);let Xi=Ci;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",Xi);const Do=class Do{constructor(n){d(this,it);d(this,Mr,h(()=>{t(this,Hr).call(this),new ResizeObserver(n=>{for(let e of n)t(this,it).getAttribute("auto-height")==="true"&&t(this,Ti).call(this)}).observe(t(this,it))},"#init"));d(this,Ti,h(()=>{const n=Array.from(t(this,it).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(n.length===0)return;const e=parseInt(t(this,it).getAttribute("max-display-row"),10)||10,s=Math.max(...n.map(u=>u.getRowHeight())),i=t(this,it).shadowRoot.querySelector("nine-table-toolbar"),r=t(this,it).shadowRoot.querySelector("nine-table-sheets-footer"),o=i?i.getBoundingClientRect().height:0,l=r?r.getBoundingClientRect().height:0,a=Xi.SCROLLBAR_SIZE,c=e*s+o+l+a;t(this,it).style.height=`${c}px`},"#applyAutoHeight"));d(this,Hr,h(()=>{const e=Array.from(t(this,it).children).filter(c=>c.tagName.toUpperCase()==="TABLE"),s=t(this,it).getAttribute("auto-height")==="true",i=e.length,r=e.map((c,u)=>{const f=u===0?"active":"",g=c.id||`sheet${u+1}`,b=`<nine-table-sheet class="${f}" data-index="${u}" data-sheet-id="${g}" id="${g}"></nine-table-sheet>`,m=u<i-1?`<nine-splitter class="h" data-split-index="${u}"></nine-splitter>`:"";return b+m}).join(""),o=["layout","nine-table-sheet","nine-table-vscrollbar","nine-table-hscrollbar","table","col-resize","sorting","fitering","cell-select","col-expand","cell-combo"],l=o.map(c=>`@import "https://cdn.jsdelivr.net/npm/@ninebone/table@0.1.43/dist/css/${c}.css";`),a=[];nine.cssPath&&o.forEach(c=>{a.push(`@import "${nine.cssPath}/${c}.css";`)}),t(this,it).shadowRoot.innerHTML=`
277
276
  <style>
278
277
  ${[...l,...a].join(`
279
278
  `)}
@@ -297,7 +296,7 @@
297
296
  const data = rowItem;
298
297
  if (!data && !host) return "";
299
298
  return ${r};
300
- `),t(this,Ii).set(r,o)),o(e,s,t(this,ki))}return r}catch{return n}}};ki=new WeakMap,vs=new WeakMap,Ii=new WeakMap,h($o,"ExprEngine");let _n=$o;const Fo=class Fo extends HTMLElement{constructor(){super();d(this,Dr);d(this,qi);d(this,Le);d(this,Mi);d(this,Ss,0);d(this,Nr,h(()=>{let e=0;const s=50,i=setInterval(()=>{e++;const r=this.shadow.querySelectorAll("nine-table-sheet");if(e>=s&&clearInterval(i),r.length>=t(this,Ss)){let o=0;r.forEach(l=>{l.loaded&&o++}),o>=t(this,Ss)&&(clearInterval(i),this.loaded=!0,this.dispatchEvent(new CustomEvent(Dt.EVENT.LOAD,{bubbles:!0,detail:{target:this}})))}},100)},"#dispatchLoad"));E(this,"sheet",h(e=>{if(e===null||e<0)return this.activeSheet;const s=Array.from(this.shadow.querySelectorAll("nine-table-sheet"));return typeof e=="number"?s[e]||null:typeof e=="string"?this.shadow.querySelector(`nine-table-sheet#${e}, nine-table-sheet[data-sheet-id="${e}"]`)||null:s[0]||null},"sheet"));E(this,"execute",h(e=>{this.loading=!0,setTimeout(()=>{try{e.call(this)}finally{this.loading=!1}})},"execute"));p(this,qi,this.attachShadow({mode:"open"})),p(this,Le,new An(this))}connectedCallback(){setTimeout(()=>{var e;p(this,Ss,(e=this.querySelectorAll("table"))==null?void 0:e.length),this.fields=new En(this),this.exprEngine=new _n(this),A(this,Dr,Zl).call(this),p(this,Mi,new Xn(this)),t(this,Nr).call(this)})}disconnectedCallback(){v.log("NineTable disconnected.")}get shadow(){return t(this,qi)}get dataManager(){return t(this,Le)}get data(){return t(this,Le).data}get row(){return t(this,Le).row}setData(e){t(this,Le).data.set(e),this.refresh()}refresh(){var e;(e=this.activeSheet)==null||e.invalidate()}set loading(e){t(this,Mi).loading=e}rerenderer(){var e;(e=this.activeSheet)==null||e.querySelectorAll("tbody.body th,tbody.body td").forEach(s=>{const i=Array.from(s.children).find(r=>r.tagName.toLowerCase().startsWith("cell-")&&typeof r.rerenderer=="function");i==null||i.rerenderer()})}get sheets(){return Array.from(this.shadow.querySelectorAll("nine-table-sheet"))}get activeSheet(){return this.shadow.querySelector("nine-table-sheet.active")||null}};qi=new WeakMap,Le=new WeakMap,Mi=new WeakMap,Ss=new WeakMap,Nr=new WeakMap,Dr=new WeakSet,Zl=h(function(){const e=new Set;this.querySelectorAll("[data-source]").forEach(s=>{const i=s.getAttribute("data-source");if(!i)return;const r=i.matchAll(/(?:host\.)?([a-zA-Z0-9_$]+)\s*\(/g);for(const o of r){const l=o[1];l&&l!=="host"&&e.add(l)}}),e.forEach(s=>{let i=null;Object.defineProperty(this,s,{set:h(r=>{i=r,this.rerenderer()},"set"),get:h(()=>i,"get"),configurable:!0,enumerable:!0})})},"#bindDynamicSetters"),h(Fo,"NineTable");let _i=Fo;customElements.get("nine-table")||customElements.define("nine-table",_i),customElements.get("nine-table-simple")||customElements.define("nine-table-simple",class extends _i{connectedCallback(){this.setAttribute("theme","simple"),super.connectedCallback()}});const Hi=class Hi extends HTMLElement{constructor(){super()}applyBaseStyle(){this.constructor.name}connectedCallback(){}};h(Hi,"BasicCellElement"),E(Hi,"_styleCache",new Map),E(Hi,"_customStyleCache",new Map);let Un=Hi;const wl=new Map,Wo=class Wo extends Un{constructor(){super();d(this,I);d(this,Ni);d(this,dt);d(this,q);d(this,ts);E(this,"getDisplayText",h((e="")=>{if(v.log("================================="),!t(this,q)||!t(this,q).closest("tbody"))return e;const s=t(this,dt).data;if(v.log("==============================",s),!s)return e;const i=t(this,q).dataset.expr,r=t(this,q).dataset.bind,o=parseInt(t(this,q).dataset.row,10);if(i)try{return t(this,dt).getAttribute("grouping")==="true"?this.getGroupExprValue(i,t(this,dt).data,o,t(this,q)):t(this,I).exprEngine.evaluate(i,t(this,dt).data,o)}catch(l){return console.trace(l),e}if(v.log("==============================",r,this.value),r){const l=this.value;return l??e}return e},"getDisplayText"));E(this,"getGroupExprValue",h((e,s,i,r)=>{var o,l,a,c,u,g;if(!e)return"";try{i=parseInt(i,10);const f=e.replace("()","").trim();if(t(this,I)&&typeof t(this,I)[f]=="function")return t(this,I)[f].call(this,s,i,r);const b=f.match(/^(\w+)\s*\(\s*([\w\-]*)\s*\)/);if(b){const m=s[GROUP_IDX.CHILDREN],y=(l=(o=t(this,I))==null?void 0:o.data)!=null&&l.getArray?t(this,I).data.getArray():[],x=m?m.map(C=>y[C]).filter(Boolean):[],[,w,S]=b,R=t(this,I);switch(w.toLowerCase()){case"count":return x.length;case"sum":{const C=((c=(a=R==null?void 0:R.fields)==null?void 0:a.indexOf)==null?void 0:c.call(a,S))??-1;return x.reduce((W,T)=>{var _;const D=C>=0?(_=T.v)==null?void 0:_[C]:T[S];return W+(Number(D)||0)},0)}case"avg":{if(x.length===0)return 0;const C=((g=(u=R==null?void 0:R.fields)==null?void 0:u.indexOf)==null?void 0:g.call(u,S))??-1;return x.reduce((T,D)=>{var rt;const _=C>=0?(rt=D.v)==null?void 0:rt[C]:D[S];return T+(Number(_)||0)},0)/x.length}}}if(t(this,I)&&typeof t(this,I).exprFunction=="function")return t(this,I).exprFunction(e).call(this,s,i,t(this,I).data);if(e.includes("data.")||e.includes("childRecords")||e.includes("groupRecord")){let m=wl.get("grp_"+e);return m||(m=new Function("groupRecord","row","cell","host",`
299
+ `),t(this,Ii).set(r,o)),o(e,s,t(this,ki))}return r}catch{return n}}};ki=new WeakMap,vs=new WeakMap,Ii=new WeakMap,h($o,"ExprEngine");let _n=$o;const Fo=class Fo extends HTMLElement{constructor(){super();d(this,Dr);d(this,qi);d(this,Re);d(this,Mi);d(this,Ss,0);d(this,Nr,h(()=>{let e=0;const s=50,i=setInterval(()=>{e++;const r=this.shadow.querySelectorAll("nine-table-sheet");if(e>=s&&clearInterval(i),r.length>=t(this,Ss)){let o=0;r.forEach(l=>{l.loaded&&o++}),o>=t(this,Ss)&&(clearInterval(i),this.loaded=!0,this.dispatchEvent(new CustomEvent(Nt.EVENT.LOAD,{bubbles:!0,detail:{target:this}})))}},100)},"#dispatchLoad"));E(this,"sheet",h(e=>{if(e===null||e<0)return this.activeSheet;const s=Array.from(this.shadow.querySelectorAll("nine-table-sheet"));return typeof e=="number"?s[e]||null:typeof e=="string"?this.shadow.querySelector(`nine-table-sheet#${e}, nine-table-sheet[data-sheet-id="${e}"]`)||null:s[0]||null},"sheet"));E(this,"execute",h(e=>{this.loading=!0,setTimeout(()=>{try{e.call(this)}finally{this.loading=!1}})},"execute"));p(this,qi,this.attachShadow({mode:"open"})),p(this,Re,new An(this))}connectedCallback(){setTimeout(()=>{var e;p(this,Ss,(e=this.querySelectorAll("table"))==null?void 0:e.length),this.fields=new En(this),this.exprEngine=new _n(this),A(this,Dr,Zl).call(this),p(this,Mi,new Xn(this)),t(this,Nr).call(this)})}disconnectedCallback(){v.log("NineTable disconnected.")}get shadow(){return t(this,qi)}get dataManager(){return t(this,Re)}get data(){return t(this,Re).data}get row(){return t(this,Re).row}setData(e){t(this,Re).data.set(e),this.refresh()}refresh(){var e;(e=this.activeSheet)==null||e.invalidate()}set loading(e){t(this,Mi).loading=e}rerenderer(){var e;(e=this.activeSheet)==null||e.querySelectorAll("tbody.body th,tbody.body td").forEach(s=>{const i=Array.from(s.children).find(r=>r.tagName.toLowerCase().startsWith("cell-")&&typeof r.rerenderer=="function");i==null||i.rerenderer()})}get sheets(){return Array.from(this.shadow.querySelectorAll("nine-table-sheet"))}get activeSheet(){return this.shadow.querySelector("nine-table-sheet.active")||null}};qi=new WeakMap,Re=new WeakMap,Mi=new WeakMap,Ss=new WeakMap,Nr=new WeakMap,Dr=new WeakSet,Zl=h(function(){const e=new Set;this.querySelectorAll("[data-source]").forEach(s=>{const i=s.getAttribute("data-source");if(!i)return;const r=i.matchAll(/(?:host\.)?([a-zA-Z0-9_$]+)\s*\(/g);for(const o of r){const l=o[1];l&&l!=="host"&&e.add(l)}}),e.forEach(s=>{let i=null;Object.defineProperty(this,s,{set:h(r=>{i=r,this.rerenderer()},"set"),get:h(()=>i,"get"),configurable:!0,enumerable:!0})})},"#bindDynamicSetters"),h(Fo,"NineTable");let _i=Fo;customElements.get("nine-table")||customElements.define("nine-table",_i),customElements.get("nine-table-simple")||customElements.define("nine-table-simple",class extends _i{connectedCallback(){this.setAttribute("theme","simple"),super.connectedCallback()}});const Hi=class Hi extends HTMLElement{constructor(){super()}applyBaseStyle(){this.constructor.name}connectedCallback(){}};h(Hi,"BasicCellElement"),E(Hi,"_styleCache",new Map),E(Hi,"_customStyleCache",new Map);let Un=Hi;const wl=new Map,Wo=class Wo extends Un{constructor(){super();d(this,I);d(this,Ni);d(this,dt);d(this,q);d(this,ts);E(this,"getDisplayText",h((e="")=>{if(v.log("================================="),!t(this,q)||!t(this,q).closest("tbody"))return e;const s=t(this,dt).data;if(v.log("==============================",s),!s)return e;const i=t(this,q).dataset.expr,r=t(this,q).dataset.bind,o=parseInt(t(this,q).dataset.row,10);if(i)try{return t(this,dt).getAttribute("grouping")==="true"?this.getGroupExprValue(i,t(this,dt).data,o,t(this,q)):t(this,I).exprEngine.evaluate(i,t(this,dt).data,o)}catch(l){return console.trace(l),e}if(v.log("==============================",r,this.value),r){const l=this.value;return l??e}return e},"getDisplayText"));E(this,"getGroupExprValue",h((e,s,i,r)=>{var o,l,a,c,u,f;if(!e)return"";try{i=parseInt(i,10);const g=e.replace("()","").trim();if(t(this,I)&&typeof t(this,I)[g]=="function")return t(this,I)[g].call(this,s,i,r);const b=g.match(/^(\w+)\s*\(\s*([\w\-]*)\s*\)/);if(b){const m=s[GROUP_IDX.CHILDREN],y=(l=(o=t(this,I))==null?void 0:o.data)!=null&&l.getArray?t(this,I).data.getArray():[],x=m?m.map(C=>y[C]).filter(Boolean):[],[,w,S]=b,L=t(this,I);switch(w.toLowerCase()){case"count":return x.length;case"sum":{const C=((c=(a=L==null?void 0:L.fields)==null?void 0:a.indexOf)==null?void 0:c.call(a,S))??-1;return x.reduce((W,T)=>{var _;const D=C>=0?(_=T.v)==null?void 0:_[C]:T[S];return W+(Number(D)||0)},0)}case"avg":{if(x.length===0)return 0;const C=((f=(u=L==null?void 0:L.fields)==null?void 0:u.indexOf)==null?void 0:f.call(u,S))??-1;return x.reduce((T,D)=>{var rt;const _=C>=0?(rt=D.v)==null?void 0:rt[C]:D[S];return T+(Number(_)||0)},0)/x.length}}}if(t(this,I)&&typeof t(this,I).exprFunction=="function")return t(this,I).exprFunction(e).call(this,s,i,t(this,I).data);if(e.includes("data.")||e.includes("childRecords")||e.includes("groupRecord")){let m=wl.get("grp_"+e);return m||(m=new Function("groupRecord","row","cell","host",`
301
300
  const indices = groupRecord[3]; // GROUP_IDX.CHILDREN = 3
302
301
  const allRecords = host?.data?.getArray ? host.data.getArray() : [];
303
302
 
@@ -321,7 +320,7 @@
321
320
 
322
321
  const data = childRecords; // data.length 등을 쓸 수 있도록 호환
323
322
  return ${e};
324
- `),wl.set("grp_"+e,m)),m(s,i,r,t(this,I))}return e}catch(f){return console.error("Group expr evaluation error:",e,f),e}},"getGroupExprValue"))}get host(){return t(this,I)}get sheet(){return t(this,Ni)}get cell(){return t(this,q)}get tr(){return t(this,dt)}get attr(){return t(this,ts)}connectedCallback(){super.connectedCallback(),p(this,I,this.getRootNode().host),p(this,q,this.closest("th,td")),p(this,dt,t(this,q).closest("tr")),p(this,Ni,t(this,dt).closest("nine-table-sheet")),t(this,q).classList.add(this.tagName),p(this,ts,{});for(let i=0;i<t(this,q).attributes.length;i++){const r=t(this,q).attributes[i].name;["text-align","class","cell-type","data-bind","data-expr","data-col","tabindex"].includes(r)||(t(this,ts)[r]=t(this,q).attributes[i].value)}if(!t(this,q))return;const e=this.shadowRoot||this;e.querySelectorAll("button, ng-expand-button").forEach(i=>{i.addEventListener("click",()=>{var a,c;let r=this.getAttribute("onbuttonclick")||this.getAttribute("onButtonClick")||((a=t(this,q))==null?void 0:a.getAttribute("onbuttonclick"))||((c=t(this,q))==null?void 0:c.getAttribute("onButtonClick"));const o=this.data,l=parseInt(t(this,q).dataset.row,10);if(r&&t(this,I)){r=r.replace("()","");const u=r.match(/^(\w+)\s*\(/),g=(u==null?void 0:u[1])||r;typeof t(this,I)[g]=="function"?t(this,I)[g].call(t(this,I),o,l,t(this,q)):typeof t(this,I).exprFunction=="function"&&t(this,I).exprFunction(r).call(this,o,l)}})});const s=e.querySelector(".renderer");s&&this.getAttribute("link")==="true"&&(s.classList.add("link"),s.addEventListener("click",()=>{var l;let i=this.getAttribute("onlinkclick")||this.getAttribute("onLinkClick");const r=this.data,o=parseInt(t(this,q).dataset.row,10);if(i&&t(this,I)){i=i.replace("()","");const a=i.match(/^(\w+)\s*\(/),c=(a==null?void 0:a[1])||i;typeof t(this,I)[c]=="function"?t(this,I)[c].call(t(this,I),r,o,t(this,q)):typeof t(this,I).exprFunction=="function"&&t(this,I).exprFunction(i).call(this,r,o)}(l=t(this,I))==null||l.dispatchEvent(new CustomEvent(ninegrid.EVENT.LINK_CLICK,{detail:{target:t(this,q),data:r,currow:o},bubbles:!0,composed:!0}))}))}get data(){var i;const e=(i=t(this,dt))==null?void 0:i.data;if(!e)return null;if(!e.v)return e;const s=t(this,I);return new Proxy(e,{get(r,o){var a,c;if(o==="__ng")return r.__ng;if(o==="v")return r.v;const l=((c=(a=s==null?void 0:s.fields)==null?void 0:a.indexOf)==null?void 0:c.call(a,o))??-1;return l>=0?r.v[l]:r[o]}})}get value(){var i,r;if(!t(this,q)||!((i=t(this,dt))!=null&&i.data))return"";const e=(r=t(this,q).dataset)==null?void 0:r.bind;if(!e)return"";const s=t(this,dt).data;if(s.v&&Array.isArray(s.v)){const o=t(this,I).fields.get().indexOf(e)??-1;return o>=0?s.v[o]??"":""}return s[e]??""}set value(e){var o;if(!t(this,q)||!((o=t(this,I))!=null&&o.data))return;const s=parseInt(t(this,q).dataset.row,10),i=t(this,q).dataset.bind;if(isNaN(s)||!i)return;const r=this.getAttribute("update-row-state")!=="false";t(this,I).data.setValue(s,i,e,r)}get row(){var e,s;return parseInt((s=(e=t(this,q))==null?void 0:e.dataset)==null?void 0:s.row,10)}get index(){var e,s;return parseInt((s=(e=t(this,q))==null?void 0:e.dataset)==null?void 0:s.index,10)}refresh(){if(!t(this,q)||!t(this,dt))return;const e=this.value;return["color","background","background-color","class","visible","enable"].forEach(s=>{const i=t(this,ts)[s];if(i){const r=t(this,I).exprEngine.evaluate(i,t(this,dt).data,parseInt(t(this,q).dataset.row,10));s==="visible"?this.style.display=r?"":"none":s==="enable"?(this.querySelectorAll("input, button, textarea, select").forEach(o=>{o.disabled=!r}),r?t(this,q).removeAttribute("disabled"):t(this,q).setAttribute("disabled","true")):t(this,q).style[s]=r}}),e}getExprValue(e,s,i){return t(this,I).exprEngine.evaluate(e,s,i)}};I=new WeakMap,Ni=new WeakMap,dt=new WeakMap,q=new WeakMap,ts=new WeakMap,h(Wo,"CellElement");let hs=Wo;const Oo=class Oo extends hs{constructor(){super();E(this,"getExprValue",h((e,s,i,r)=>super.getExprValue(e,s,i,r),"getExprValue"))}get host(){return super.host}get sheet(){return super.sheet}get cell(){return super.cell}get tr(){return super.tr}get attr(){return super.attr}getExprValue(e,s,i,r){return super.getExprValue(e,s,i,r)}connectedCallback(){super.connectedCallback()}refresh(){return super.refresh()}};h(Oo,"EditableCellElement");let Jt=Oo;const zo=class zo extends Jt{constructor(){super();d(this,es);E(this,"refresh",h(()=>{super.refresh(),t(this,es).value=this.value},"refresh"));d(this,$r,h(()=>{t(this,es).addEventListener("input",e=>{const s=this.cell.getAttribute("maxbyte")||this.cell.getAttribute("max-byte");if(s){const i=Number(s);nine.getByteLength(e.target.value)>i&&(e.target.value=nine.cut(e.target.value,i),this.value=e.target.value)}}),t(this,es).addEventListener("change",e=>{this.value=e.target.value,super.sheet.rowManager.refresh(!0)})},"#initEvent"));d(this,Fr,h(()=>{this.innerHTML=`
323
+ `),wl.set("grp_"+e,m)),m(s,i,r,t(this,I))}return e}catch(g){return console.error("Group expr evaluation error:",e,g),e}},"getGroupExprValue"))}get host(){return t(this,I)}get sheet(){return t(this,Ni)}get cell(){return t(this,q)}get tr(){return t(this,dt)}get attr(){return t(this,ts)}connectedCallback(){super.connectedCallback(),p(this,I,this.getRootNode().host),p(this,q,this.closest("th,td")),p(this,dt,t(this,q).closest("tr")),p(this,Ni,t(this,dt).closest("nine-table-sheet")),t(this,q).classList.add(this.tagName),p(this,ts,{});for(let i=0;i<t(this,q).attributes.length;i++){const r=t(this,q).attributes[i].name;["text-align","class","cell-type","data-bind","data-expr","data-col","tabindex"].includes(r)||(t(this,ts)[r]=t(this,q).attributes[i].value)}if(!t(this,q))return;const e=this.shadowRoot||this;e.querySelectorAll("button, ng-expand-button").forEach(i=>{i.addEventListener("click",()=>{var a,c;let r=this.getAttribute("onbuttonclick")||this.getAttribute("onButtonClick")||((a=t(this,q))==null?void 0:a.getAttribute("onbuttonclick"))||((c=t(this,q))==null?void 0:c.getAttribute("onButtonClick"));const o=this.data,l=parseInt(t(this,q).dataset.row,10);if(r&&t(this,I)){r=r.replace("()","");const u=r.match(/^(\w+)\s*\(/),f=(u==null?void 0:u[1])||r;typeof t(this,I)[f]=="function"?t(this,I)[f].call(t(this,I),o,l,t(this,q)):typeof t(this,I).exprFunction=="function"&&t(this,I).exprFunction(r).call(this,o,l)}})});const s=e.querySelector(".renderer");s&&this.getAttribute("link")==="true"&&(s.classList.add("link"),s.addEventListener("click",()=>{var l;let i=this.getAttribute("onlinkclick")||this.getAttribute("onLinkClick");const r=this.data,o=parseInt(t(this,q).dataset.row,10);if(i&&t(this,I)){i=i.replace("()","");const a=i.match(/^(\w+)\s*\(/),c=(a==null?void 0:a[1])||i;typeof t(this,I)[c]=="function"?t(this,I)[c].call(t(this,I),r,o,t(this,q)):typeof t(this,I).exprFunction=="function"&&t(this,I).exprFunction(i).call(this,r,o)}(l=t(this,I))==null||l.dispatchEvent(new CustomEvent(ninegrid.EVENT.LINK_CLICK,{detail:{target:t(this,q),data:r,currow:o},bubbles:!0,composed:!0}))}))}get data(){var i;const e=(i=t(this,dt))==null?void 0:i.data;if(!e)return null;if(!e.v)return e;const s=t(this,I);return new Proxy(e,{get(r,o){var a,c;if(o==="__ng")return r.__ng;if(o==="v")return r.v;const l=((c=(a=s==null?void 0:s.fields)==null?void 0:a.indexOf)==null?void 0:c.call(a,o))??-1;return l>=0?r.v[l]:r[o]}})}get value(){var i,r;if(!t(this,q)||!((i=t(this,dt))!=null&&i.data))return"";const e=(r=t(this,q).dataset)==null?void 0:r.bind;if(!e)return"";const s=t(this,dt).data;if(s.v&&Array.isArray(s.v)){const o=t(this,I).fields.get().indexOf(e)??-1;return o>=0?s.v[o]??"":""}return s[e]??""}set value(e){var o;if(!t(this,q)||!((o=t(this,I))!=null&&o.data))return;const s=parseInt(t(this,q).dataset.row,10),i=t(this,q).dataset.bind;if(isNaN(s)||!i)return;const r=this.getAttribute("update-row-state")!=="false";t(this,I).data.setValue(s,i,e,r)}get row(){var e,s;return parseInt((s=(e=t(this,q))==null?void 0:e.dataset)==null?void 0:s.row,10)}get index(){var e,s;return parseInt((s=(e=t(this,q))==null?void 0:e.dataset)==null?void 0:s.index,10)}refresh(){if(!t(this,q)||!t(this,dt))return;const e=this.value;return["color","background","background-color","class","visible","enable"].forEach(s=>{const i=t(this,ts)[s];if(i){const r=t(this,I).exprEngine.evaluate(i,t(this,dt).data,parseInt(t(this,q).dataset.row,10));s==="visible"?this.style.display=r?"":"none":s==="enable"?(this.querySelectorAll("input, button, textarea, select").forEach(o=>{o.disabled=!r}),r?t(this,q).removeAttribute("disabled"):t(this,q).setAttribute("disabled","true")):t(this,q).style[s]=r}}),e}getExprValue(e,s,i){return t(this,I).exprEngine.evaluate(e,s,i)}};I=new WeakMap,Ni=new WeakMap,dt=new WeakMap,q=new WeakMap,ts=new WeakMap,h(Wo,"CellElement");let hs=Wo;const Oo=class Oo extends hs{constructor(){super();E(this,"getExprValue",h((e,s,i,r)=>super.getExprValue(e,s,i,r),"getExprValue"))}get host(){return super.host}get sheet(){return super.sheet}get cell(){return super.cell}get tr(){return super.tr}get attr(){return super.attr}getExprValue(e,s,i,r){return super.getExprValue(e,s,i,r)}connectedCallback(){super.connectedCallback()}refresh(){return super.refresh()}};h(Oo,"EditableCellElement");let Jt=Oo;const zo=class zo extends Jt{constructor(){super();d(this,es);E(this,"refresh",h(()=>{super.refresh(),t(this,es).value=this.value},"refresh"));d(this,$r,h(()=>{t(this,es).addEventListener("input",e=>{const s=this.cell.getAttribute("maxbyte")||this.cell.getAttribute("max-byte");if(s){const i=Number(s);nine.getByteLength(e.target.value)>i&&(e.target.value=nine.cut(e.target.value,i),this.value=e.target.value)}}),t(this,es).addEventListener("change",e=>{this.value=e.target.value,super.sheet.rowManager.refresh(!0)})},"#initEvent"));d(this,Fr,h(()=>{this.innerHTML=`
325
324
  <style>
326
325
  cell-input {
327
326
  input {
@@ -350,7 +349,7 @@
350
349
  </style>
351
350
 
352
351
  <input type="text" ondragstart="return false;">
353
- `},"#renderer"))}connectedCallback(){super.connectedCallback(),t(this,Fr).call(this),p(this,es,this.querySelector("input")),t(this,$r).call(this)}};es=new WeakMap,$r=new WeakMap,Fr=new WeakMap,h(zo,"CellInputText");let Gn=zo;customElements.get("cell-input")||customElements.define("cell-input",Gn);const Bo=class Bo extends Jt{constructor(){super();d(this,Mt);d(this,Wr,h(()=>{for(var e=[],s=0;s<this.attributes.length;s++)["type","maxlength","maxbyte","min","max","step","scale","text-align"].includes(this.attributes[s].name);this.innerHTML=`
352
+ `},"#renderer"))}connectedCallback(){super.connectedCallback(),t(this,Fr).call(this),p(this,es,this.querySelector("input")),t(this,$r).call(this)}};es=new WeakMap,$r=new WeakMap,Fr=new WeakMap,h(zo,"CellInputText");let Gn=zo;customElements.get("cell-input")||customElements.define("cell-input",Gn);const Bo=class Bo extends Jt{constructor(){super();d(this,qt);d(this,Wr,h(()=>{for(var e=[],s=0;s<this.attributes.length;s++)["type","maxlength","maxbyte","min","max","step","scale","text-align"].includes(this.attributes[s].name);this.innerHTML=`
354
353
  <style>
355
354
  cell-input-number {
356
355
  input[type=text].border-left-none {
@@ -391,7 +390,7 @@
391
390
  </style>
392
391
 
393
392
  <input type="text" ${e.join(" ")} ondragstart="return false;">
394
- `},"#renderer"));E(this,"refresh",h(()=>{const e=super.refresh();return t(this,Mt)&&(t(this,Mt).value=e??"",t(this,Or).call(this,t(this,Mt).value)),e},"refresh"));d(this,Or,h(e=>{if(t(this,Mt)&&(super.cell.classList.remove("invalid"),e!==""&&e!==null&&e!==void 0)){const s=Number(e);if(isNaN(s)||super.attr.max!==null&&super.attr.max!==void 0&&s>Number(super.attr.max)||super.attr.min!==null&&super.attr.min!==void 0&&s<Number(super.attr.min))super.cell.classList.add("invalid");else if(super.attr.scale!==null&&super.attr.scale!==void 0){const i=String(e),r=i.indexOf(".");r>=0&&i.substring(r+1).length>Number(super.attr.scale)&&super.cell.classList.add("invalid")}}},"#validateInput"));d(this,zr,h(e=>{if(["Escape","Enter","Tab","Home","End","ArrowLeft","ArrowRight","PageUp","PageDown","Backspace","Delete"].includes(e.code))return;const s=e.target,i=s.value,r=s.selectionStart;s.selectionEnd;const o=e.key;if(o==="-"&&(i.includes("-")||r!==0)){e.preventDefault();return}if(o==="."){const c=Number(super.attr.scale);if(isNaN(c)||c<=0||i.includes(".")){e.preventDefault();return}}let l=[];super.attr.scale!==null&&super.attr.scale!==void 0&&Number(super.attr.scale)>0&&l.push("."),(super.attr.min===null||super.attr.min===void 0||Number(super.attr.min)>0)&&l.push("-");const a=e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=105;if(!a&&!l.includes(e.key)){e.preventDefault();return}if(super.attr.scale!==null&&super.attr.scale!==void 0&&a&&e.target.selectionStart==e.target.selectionEnd){const c=e.target.value,u=c.indexOf(".");u>=0&&e.target.selectionStart>u&&c.substr(u+1).length>=Number(super.attr.scale)&&e.preventDefault()}super.attr.maxbyte&&nine.getByteLength(e.target.value)>=Number(super.attr.maxbyte)&&e.target.selectionStart==e.target.selectionEnd&&e.preventDefault()},"#onKeyDown"));this.applyBaseStyle()}connectedCallback(){t(this,Wr).call(this),super.connectedCallback(),p(this,Mt,this.querySelector("input")),t(this,Mt)&&(t(this,Mt).addEventListener("keydown",t(this,zr)),t(this,Mt).addEventListener("input",e=>{this.value=e.target.value,super.sheet.rowManager.refresh(!0)}),t(this,Mt).addEventListener("change",e=>{this.value=e.target.value,super.sheet.rowManager.refresh(!0)}))}};Mt=new WeakMap,Wr=new WeakMap,Or=new WeakMap,zr=new WeakMap,h(Bo,"CellInputNumber");let jn=Bo;customElements.get("cell-input-number")||customElements.define("cell-input-number",jn);const Po=class Po extends Jt{constructor(){super();d(this,xt);d(this,As);d(this,Br,h(()=>{for(var e=[],s=0;s<this.attributes.length;s++)["type","maxlength","maxbyte","min","max","step","scale","text-align"].includes(this.attributes[s].name);this.innerHTML=`
393
+ `},"#renderer"));E(this,"refresh",h(()=>{const e=super.refresh();return t(this,qt)&&(t(this,qt).value=e??"",t(this,Or).call(this,t(this,qt).value)),e},"refresh"));d(this,Or,h(e=>{if(t(this,qt)&&(super.cell.classList.remove("invalid"),e!==""&&e!==null&&e!==void 0)){const s=Number(e);if(isNaN(s)||super.attr.max!==null&&super.attr.max!==void 0&&s>Number(super.attr.max)||super.attr.min!==null&&super.attr.min!==void 0&&s<Number(super.attr.min))super.cell.classList.add("invalid");else if(super.attr.scale!==null&&super.attr.scale!==void 0){const i=String(e),r=i.indexOf(".");r>=0&&i.substring(r+1).length>Number(super.attr.scale)&&super.cell.classList.add("invalid")}}},"#validateInput"));d(this,zr,h(e=>{if(["Escape","Enter","Tab","Home","End","ArrowLeft","ArrowRight","PageUp","PageDown","Backspace","Delete"].includes(e.code))return;const s=e.target,i=s.value,r=s.selectionStart;s.selectionEnd;const o=e.key;if(o==="-"&&(i.includes("-")||r!==0)){e.preventDefault();return}if(o==="."){const c=Number(super.attr.scale);if(isNaN(c)||c<=0||i.includes(".")){e.preventDefault();return}}let l=[];super.attr.scale!==null&&super.attr.scale!==void 0&&Number(super.attr.scale)>0&&l.push("."),(super.attr.min===null||super.attr.min===void 0||Number(super.attr.min)>0)&&l.push("-");const a=e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=105;if(!a&&!l.includes(e.key)){e.preventDefault();return}if(super.attr.scale!==null&&super.attr.scale!==void 0&&a&&e.target.selectionStart==e.target.selectionEnd){const c=e.target.value,u=c.indexOf(".");u>=0&&e.target.selectionStart>u&&c.substr(u+1).length>=Number(super.attr.scale)&&e.preventDefault()}super.attr.maxbyte&&nine.getByteLength(e.target.value)>=Number(super.attr.maxbyte)&&e.target.selectionStart==e.target.selectionEnd&&e.preventDefault()},"#onKeyDown"));this.applyBaseStyle()}connectedCallback(){t(this,Wr).call(this),super.connectedCallback(),p(this,qt,this.querySelector("input")),t(this,qt)&&(t(this,qt).addEventListener("keydown",t(this,zr)),t(this,qt).addEventListener("input",e=>{this.value=e.target.value,super.sheet.rowManager.refresh(!0)}),t(this,qt).addEventListener("change",e=>{this.value=e.target.value,super.sheet.rowManager.refresh(!0)}))}};qt=new WeakMap,Wr=new WeakMap,Or=new WeakMap,zr=new WeakMap,h(Bo,"CellInputNumber");let jn=Bo;customElements.get("cell-input-number")||customElements.define("cell-input-number",jn);const Po=class Po extends Jt{constructor(){super();d(this,xt);d(this,As);d(this,Br,h(()=>{for(var e=[],s=0;s<this.attributes.length;s++)["type","maxlength","maxbyte","min","max","step","scale","text-align"].includes(this.attributes[s].name);this.innerHTML=`
395
394
  <style>
396
395
  cell-input-color {
397
396
  --position: relative;
@@ -562,7 +561,7 @@
562
561
  ${s.join(" ")}
563
562
  required
564
563
  />
565
- `},"#renderer"));E(this,"refresh",h(()=>{const e=super.refresh();if(!t(this,wt))return e;let s=e;if(s)switch(t(this,ce)){case"date":s=s.substr(0,10);break;case"datetime-local":s=s.substr(0,16);break;case"time":var i=new Date(e);i!="Invalid Date"&&!isNaN(i)&&(s=("00"+i.getHours()).slice(-2)+":"+("00"+i.getMinutes()).slice(-2));break;case"month":var i=new Date(e);i!="Invalid Date"&&!isNaN(i)&&(s=("0000"+i.getFullYear()).slice(-4)+"-"+("00"+(i.getMonth()+1)).slice(-2));break}return t(this,wt).value=s||"",t(this,wt).classList.toggle("has-value",!!s),t(this,Ls).call(this,s),e},"refresh"));d(this,Ls,h(e=>{if(!t(this,wt)||!super.cell)return;const s=this.closest("th,td"),i=s==null?void 0:s.getAttribute("min"),r=s==null?void 0:s.getAttribute("max");if(super.cell.classList.remove("invalid"),e!==""&&e!==null&&e!==void 0){let o=t(this,Xr).call(this,e);o&&(i&&e<i&&(o=!1),r&&e>r&&(o=!1)),o||super.cell.classList.add("invalid")}},"#validateInput"));d(this,Xr,h(e=>{if(typeof e!="string")return!1;let s=!0;switch(t(this,ce)){case"date":case"datetime-local":const g=Number(e.substr(0,4)),f=Number(e.substr(5,2)),b=Number(e.substr(8,2));if(isNaN(g)||isNaN(f)||isNaN(b))s=!1;else if(f<1||f>12||b<1||b>31)s=!1;else if([4,6,9,11].includes(f)&&b==31)s=!1;else if(f==2){let m=g%4==0&&(g%100!=0||g%400==0);(b>29||b==29&&!m)&&(s=!1)}break}if(s)switch(t(this,ce)){case"datetime-local":var i=e.substr(10,1),r=Number(e.substr(11,2)),o=Number(e.substr(14,2));(i!="T"||isNaN(r)||isNaN(o)||r<0||r>23||o<0||o>59)&&(s=!1);break;case"month":var a=Number(e.substr(0,4)),l=Number(e.substr(5,2));(isNaN(a)||isNaN(l)||l<1||l>12)&&(s=!1);break;case"week":var a=Number(e.substr(0,4)),c=e.substr(5,1),u=Number(e.substr(6,2));(c!="W"||isNaN(a)||isNaN(u)||u<=0||u>53)&&(s=!1);break}return s},"#isValidDate"));this.applyBaseStyle()}connectedCallback(){if(t(this,Vr).call(this),super.connectedCallback(),p(this,ce,super.attr["date-type"]||"date"),!["date","datetime-local","time","week","month"].includes(t(this,ce)))throw`invalid type : ${t(this,ce)}`;p(this,wt,this.querySelector("input")),t(this,wt)&&(t(this,wt).addEventListener("input",e=>{const s=e.target.value;this.value=s,t(this,wt).classList.toggle("has-value",!!s),t(this,Ls).call(this,s),super.sheet.rowManager.refresh(!0)}),t(this,wt).addEventListener("change",e=>{const s=e.target.value;this.value=s,t(this,Ls).call(this,s),super.sheet.rowManager.refresh(!0)}),t(this,wt).addEventListener("keydown",e=>{["Enter"].includes(e.code)||(["Escape"].includes(e.code)?this.owner.cell.currentCell=this.cell:["Tab","PageUp","PageDown","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.code)&&(this.owner.cell.currentCell=this.cell,this.owner.cell.moveCell(e)))}))}};wt=new WeakMap,ce=new WeakMap,Vr=new WeakMap,Ls=new WeakMap,Xr=new WeakMap,h(Vo,"CellInputDate");let Yn=Vo;customElements.get("cell-input-date")||customElements.define("cell-input-date",Yn);const Xo=class Xo extends Jt{constructor(){super();d(this,he);d(this,Rs);d(this,ss);d(this,Cs);d(this,Ts);d(this,_r,h(()=>{var e;p(this,he,this.querySelector("input")),p(this,Rs,this.querySelector("span")),p(this,Cs,super.attr["true-text"]||""),p(this,Ts,super.attr["false-text"]||""),this.closest("thead")&&t(this,he).addEventListener("change",s=>{var i;(i=super.sheet.querySelector(`tbody.body [data-col="${super.cell.dataset.col}"] cell-checkbox`))==null||i.selectAll(s.target.checked)}),(e=this.cell)==null||e.addEventListener("keydown",s=>{if(s.preventDefault(),s.code==="Space"||this.closest("thead")||this.cell.hasAttribute("readonly")||this.cell.classList.contains("readonly")||this.cell.getAttribute("disabled")==="true")return;const i=this.value===this.trueValue?this.falseValue:this.trueValue;t(this,ss)&&this.selectAll(!1),this.value=i,super.sheet.invalidate()}),t(this,he).addEventListener("change",s=>{this.closest("tbody")&&(t(this,ss)?(this.selectAll(!1),this.value=this.trueValue):this.value=s.target.checked?this.trueValue:this.falseValue,super.sheet.rowManager.refresh(!0))})},"#init"));d(this,Ur,h(()=>{const e=this.closest("th,td");p(this,ss,(e==null?void 0:e.getAttribute("is-radio"))||!1);const s=(e==null?void 0:e.getAttribute("true-value"))||!1,i=(e==null?void 0:e.getAttribute("content"))||"",r=t(this,ss)?`<input type="radio" value="${s}" />`:`<label><input type="checkbox" /><span>${i}</span></label>`;this.innerHTML=`
564
+ `},"#renderer"));E(this,"refresh",h(()=>{const e=super.refresh();if(!t(this,wt))return e;let s=e;if(s)switch(t(this,ce)){case"date":s=s.substr(0,10);break;case"datetime-local":s=s.substr(0,16);break;case"time":var i=new Date(e);i!="Invalid Date"&&!isNaN(i)&&(s=("00"+i.getHours()).slice(-2)+":"+("00"+i.getMinutes()).slice(-2));break;case"month":var i=new Date(e);i!="Invalid Date"&&!isNaN(i)&&(s=("0000"+i.getFullYear()).slice(-4)+"-"+("00"+(i.getMonth()+1)).slice(-2));break}return t(this,wt).value=s||"",t(this,wt).classList.toggle("has-value",!!s),t(this,Rs).call(this,s),e},"refresh"));d(this,Rs,h(e=>{if(!t(this,wt)||!super.cell)return;const s=this.closest("th,td"),i=s==null?void 0:s.getAttribute("min"),r=s==null?void 0:s.getAttribute("max");if(super.cell.classList.remove("invalid"),e!==""&&e!==null&&e!==void 0){let o=t(this,Xr).call(this,e);o&&(i&&e<i&&(o=!1),r&&e>r&&(o=!1)),o||super.cell.classList.add("invalid")}},"#validateInput"));d(this,Xr,h(e=>{if(typeof e!="string")return!1;let s=!0;switch(t(this,ce)){case"date":case"datetime-local":const f=Number(e.substr(0,4)),g=Number(e.substr(5,2)),b=Number(e.substr(8,2));if(isNaN(f)||isNaN(g)||isNaN(b))s=!1;else if(g<1||g>12||b<1||b>31)s=!1;else if([4,6,9,11].includes(g)&&b==31)s=!1;else if(g==2){let m=f%4==0&&(f%100!=0||f%400==0);(b>29||b==29&&!m)&&(s=!1)}break}if(s)switch(t(this,ce)){case"datetime-local":var i=e.substr(10,1),r=Number(e.substr(11,2)),o=Number(e.substr(14,2));(i!="T"||isNaN(r)||isNaN(o)||r<0||r>23||o<0||o>59)&&(s=!1);break;case"month":var a=Number(e.substr(0,4)),l=Number(e.substr(5,2));(isNaN(a)||isNaN(l)||l<1||l>12)&&(s=!1);break;case"week":var a=Number(e.substr(0,4)),c=e.substr(5,1),u=Number(e.substr(6,2));(c!="W"||isNaN(a)||isNaN(u)||u<=0||u>53)&&(s=!1);break}return s},"#isValidDate"));this.applyBaseStyle()}connectedCallback(){if(t(this,Vr).call(this),super.connectedCallback(),p(this,ce,super.attr["date-type"]||"date"),!["date","datetime-local","time","week","month"].includes(t(this,ce)))throw`invalid type : ${t(this,ce)}`;p(this,wt,this.querySelector("input")),t(this,wt)&&(t(this,wt).addEventListener("input",e=>{const s=e.target.value;this.value=s,t(this,wt).classList.toggle("has-value",!!s),t(this,Rs).call(this,s),super.sheet.rowManager.refresh(!0)}),t(this,wt).addEventListener("change",e=>{const s=e.target.value;this.value=s,t(this,Rs).call(this,s),super.sheet.rowManager.refresh(!0)}),t(this,wt).addEventListener("keydown",e=>{["Enter"].includes(e.code)||(["Escape"].includes(e.code)?this.owner.cell.currentCell=this.cell:["Tab","PageUp","PageDown","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.code)&&(this.owner.cell.currentCell=this.cell,this.owner.cell.moveCell(e)))}))}};wt=new WeakMap,ce=new WeakMap,Vr=new WeakMap,Rs=new WeakMap,Xr=new WeakMap,h(Vo,"CellInputDate");let Yn=Vo;customElements.get("cell-input-date")||customElements.define("cell-input-date",Yn);const Xo=class Xo extends Jt{constructor(){super();d(this,he);d(this,Ls);d(this,ss);d(this,Cs);d(this,Ts);d(this,_r,h(()=>{var e;p(this,he,this.querySelector("input")),p(this,Ls,this.querySelector("span")),p(this,Cs,super.attr["true-text"]||""),p(this,Ts,super.attr["false-text"]||""),this.closest("thead")&&t(this,he).addEventListener("change",s=>{var i;(i=super.sheet.querySelector(`tbody.body [data-col="${super.cell.dataset.col}"] cell-checkbox`))==null||i.selectAll(s.target.checked)}),(e=this.cell)==null||e.addEventListener("keydown",s=>{if(s.preventDefault(),s.code==="Space"||this.closest("thead")||this.cell.hasAttribute("readonly")||this.cell.classList.contains("readonly")||this.cell.getAttribute("disabled")==="true")return;const i=this.value===this.trueValue?this.falseValue:this.trueValue;t(this,ss)&&this.selectAll(!1),this.value=i,super.sheet.invalidate()}),t(this,he).addEventListener("change",s=>{this.closest("tbody")&&(t(this,ss)?(this.selectAll(!1),this.value=this.trueValue):this.value=s.target.checked?this.trueValue:this.falseValue,super.sheet.rowManager.refresh(!0))})},"#init"));d(this,Ur,h(()=>{const e=this.closest("th,td");p(this,ss,(e==null?void 0:e.getAttribute("is-radio"))||!1);const s=(e==null?void 0:e.getAttribute("true-value"))||!1,i=(e==null?void 0:e.getAttribute("content"))||"",r=t(this,ss)?`<input type="radio" value="${s}" />`:`<label><input type="checkbox" /><span>${i}</span></label>`;this.innerHTML=`
566
565
  <style>
567
566
  .CELL-CHECKBOX {
568
567
  cell-checkbox {
@@ -645,7 +644,7 @@
645
644
 
646
645
  </style>
647
646
  ${r}
648
- `},"#renderer"));E(this,"refresh",h(()=>{const e=super.refresh();if(!this.closest("tbody")&&!this.closest("thead"))return e;if(t(this,he)&&(t(this,he).checked=e===this.trueValue,t(this,Gr).call(this,e)),t(this,Rs)){const s=e===this.trueValue?t(this,Cs):e===this.falseValue?t(this,Ts):e;t(this,Rs).textContent=s}return e},"refresh"));d(this,Gr,h(e=>{t(this,he)&&(super.cell.classList.remove("invalid"),e!==""&&e!==null&&e!==void 0&&e!==this.trueValue&&e!==this.falseValue&&super.cell.classList.add("invalid"))},"#validateInput"));E(this,"selectAll",h(e=>{if(this.closest("thead"))return;const s=super.host.data.getArray(),i=super.host.fields.indexOf(super.cell.dataset.bind);if(!(i<0)){for(let r=0;r<s.length;r++)super.attr.enable&&super.getExprValue(super.attr.enable,s[r],r,super.cell)===!1||super.attr.readonly&&super.getExprValue(super.attr.readonly,s[r],r,super.cell)===!0||super.attr.visible&&super.getExprValue(super.attr.visible,s[r],r,super.cell)===!1||(s[r].v[i]=e?this.trueValue:this.falseValue);super.sheet.invalidate()}},"selectAll"))}connectedCallback(){t(this,Ur).call(this),super.connectedCallback(),t(this,_r).call(this)}get trueValue(){return super.attr["true-value"]||"Y"}get falseValue(){return super.attr["false-value"]||"N"}get dataSource(){return[{value:this.trueValue,text:t(this,Cs)},{value:this.falseValue,text:t(this,Ts)}]}};he=new WeakMap,Rs=new WeakMap,ss=new WeakMap,Cs=new WeakMap,Ts=new WeakMap,_r=new WeakMap,Ur=new WeakMap,Gr=new WeakMap,h(Xo,"CellCheckbox");let Zn=Xo;customElements.get("cell-checkbox")||customElements.define("cell-checkbox",Zn);const Ko=class Ko extends Jt{constructor(){super();d(this,is);d(this,Bt,[]);d(this,rs);d(this,ks);d(this,_o);d(this,Uo);d(this,Go);d(this,jo);d(this,jr,h(()=>{super.cell.addEventListener("keydown",e=>{if(e.preventDefault(),e.code!=="Space"||this.cell.hasAttribute("readonly")||this.cell.classList.contains("readonly")||this.cell.getAttribute("disabled")==="true")return;let s=-1;const i=Array.from(this.querySelectorAll("input"));i.forEach((r,o)=>{if(this.value===r.getAttribute("value"))return s=o,!1}),s=s===i.length-1?0:s>=0?s+1:0,this.value=i[s].getAttribute("value"),super.sheet.rowManager.refresh(!0)})},"#initEvent"));d(this,Di,h(()=>{var s;if(!super.sheet||!super.cell)return;const e=(s=super.cell)==null?void 0:s.getAttribute("data-source");if(e&&(p(this,Bt,super.getExprValue(e,super.tr.data,super.tr.dataset.row)),v.log("=============================================="),v.log(this.sheet,t(this,Bt)),setTimeout(()=>{v.log("1111")},300),t(this,is).replaceChildren(),t(this,Bt)&&Array.isArray(t(this,Bt)))){const i=document.createDocumentFragment();t(this,Bt).forEach(r=>{const o=r[t(this,rs)]!==void 0?r[t(this,rs)]:"",l=r[t(this,ks)]!==void 0?r[t(this,ks)]:"",a=document.createElement("label"),c=document.createElement("input");c.type="radio",c.value=o;const u=document.createElement("span");u.textContent=l,a.appendChild(c),a.appendChild(u),i.appendChild(a)}),t(this,is).appendChild(i),this.querySelectorAll("input").forEach(r=>{r.addEventListener("change",o=>{this.value=o.target.value,super.sheet.rowManager.refresh(!0)})})}},"#rendererRadio"));d(this,Kr,h(()=>{this.innerHTML=`
647
+ `},"#renderer"));E(this,"refresh",h(()=>{const e=super.refresh();if(!this.closest("tbody")&&!this.closest("thead"))return e;if(t(this,he)&&(t(this,he).checked=e===this.trueValue,t(this,Gr).call(this,e)),t(this,Ls)){const s=e===this.trueValue?t(this,Cs):e===this.falseValue?t(this,Ts):e;t(this,Ls).textContent=s}return e},"refresh"));d(this,Gr,h(e=>{t(this,he)&&(super.cell.classList.remove("invalid"),e!==""&&e!==null&&e!==void 0&&e!==this.trueValue&&e!==this.falseValue&&super.cell.classList.add("invalid"))},"#validateInput"));E(this,"selectAll",h(e=>{if(this.closest("thead"))return;const s=super.host.data.getArray(),i=super.host.fields.indexOf(super.cell.dataset.bind);if(!(i<0)){for(let r=0;r<s.length;r++)super.attr.enable&&super.getExprValue(super.attr.enable,s[r],r,super.cell)===!1||super.attr.readonly&&super.getExprValue(super.attr.readonly,s[r],r,super.cell)===!0||super.attr.visible&&super.getExprValue(super.attr.visible,s[r],r,super.cell)===!1||(s[r].v[i]=e?this.trueValue:this.falseValue);super.sheet.invalidate()}},"selectAll"))}connectedCallback(){t(this,Ur).call(this),super.connectedCallback(),t(this,_r).call(this)}get trueValue(){return super.attr["true-value"]||"Y"}get falseValue(){return super.attr["false-value"]||"N"}get dataSource(){return[{value:this.trueValue,text:t(this,Cs)},{value:this.falseValue,text:t(this,Ts)}]}};he=new WeakMap,Ls=new WeakMap,ss=new WeakMap,Cs=new WeakMap,Ts=new WeakMap,_r=new WeakMap,Ur=new WeakMap,Gr=new WeakMap,h(Xo,"CellCheckbox");let Zn=Xo;customElements.get("cell-checkbox")||customElements.define("cell-checkbox",Zn);const Ko=class Ko extends Jt{constructor(){super();d(this,is);d(this,zt,[]);d(this,rs);d(this,ks);d(this,_o);d(this,Uo);d(this,Go);d(this,jo);d(this,jr,h(()=>{super.cell.addEventListener("keydown",e=>{if(e.preventDefault(),e.code!=="Space"||this.cell.hasAttribute("readonly")||this.cell.classList.contains("readonly")||this.cell.getAttribute("disabled")==="true")return;let s=-1;const i=Array.from(this.querySelectorAll("input"));i.forEach((r,o)=>{if(this.value===r.getAttribute("value"))return s=o,!1}),s=s===i.length-1?0:s>=0?s+1:0,this.value=i[s].getAttribute("value"),super.sheet.rowManager.refresh(!0)})},"#initEvent"));d(this,Di,h(()=>{var s;if(!super.sheet||!super.cell)return;const e=(s=super.cell)==null?void 0:s.getAttribute("data-source");if(e&&(p(this,zt,super.getExprValue(e,super.tr.data,super.tr.dataset.row)),v.log("=============================================="),v.log(this.sheet,t(this,zt)),setTimeout(()=>{v.log("1111")},300),t(this,is).replaceChildren(),t(this,zt)&&Array.isArray(t(this,zt)))){const i=document.createDocumentFragment();t(this,zt).forEach(r=>{const o=r[t(this,rs)]!==void 0?r[t(this,rs)]:"",l=r[t(this,ks)]!==void 0?r[t(this,ks)]:"",a=document.createElement("label"),c=document.createElement("input");c.type="radio",c.value=o;const u=document.createElement("span");u.textContent=l,a.appendChild(c),a.appendChild(u),i.appendChild(a)}),t(this,is).appendChild(i),this.querySelectorAll("input").forEach(r=>{r.addEventListener("change",o=>{this.value=o.target.value,super.sheet.rowManager.refresh(!0)})})}},"#rendererRadio"));d(this,Kr,h(()=>{this.innerHTML=`
649
648
  <style>
650
649
  .CELL-RADIO {
651
650
  input[type="radio"] {
@@ -761,7 +760,7 @@
761
760
  </style>
762
761
 
763
762
  <div></div>
764
- `,p(this,is,this.querySelector("div"))},"#renderer"));E(this,"rerenderer",h(()=>{t(this,Di).call(this),this.refresh()},"rerenderer"));E(this,"refresh",h(()=>{const e=super.refresh();return t(this,is)&&(this.querySelectorAll("input").forEach(s=>{s.checked=this.value==s.getAttribute("value")}),t(this,Yr).call(this)),e},"refresh"));d(this,Yr,h(()=>{if(!super.cell||(super.cell.classList.remove("invalid"),this.value===null||this.value===void 0||this.value===""||!Array.isArray(t(this,Bt))))return;t(this,Bt).findIndex(s=>this.value===s[t(this,rs)])<0&&super.cell.classList.add("invalid")},"#validateInput"));this.applyBaseStyle()}connectedCallback(){p(this,rs,this.closest("th,td").getAttribute("key-name")||"k"),p(this,ks,this.closest("th,td").getAttribute("value-name")||"v"),t(this,Kr).call(this),super.connectedCallback(),t(this,Di).call(this),t(this,jr).call(this)}get dataSource(){return t(this,Bt)}};is=new WeakMap,Bt=new WeakMap,rs=new WeakMap,ks=new WeakMap,_o=new WeakMap,Uo=new WeakMap,Go=new WeakMap,jo=new WeakMap,jr=new WeakMap,Di=new WeakMap,Kr=new WeakMap,Yr=new WeakMap,h(Ko,"CellRadio");let Jn=Ko;customElements.get("cell-radio")||customElements.define("cell-radio",Jn);const Yo=class Yo extends HTMLElement{constructor(){super();d(this,ot);d(this,Zr);d(this,Jr);d(this,Is,!1);d(this,Qr,h((e,s,i,r,o)=>{const l=this.querySelector("nine-table-simple");if(!l||!e||e.length===0)return;const a=t(this,ot).getAttribute("items");let c=[];a?c=a.split(",").map(f=>f.trim()):c=[i].filter(Boolean);const u=c.length;l.shadowRoot.querySelector(".ng-container-left").style.display=r?"":"none",l.shadowRoot.querySelectorAll("table colgroup col, tbody td").forEach((f,b)=>{v.log(f);const m=parseInt(f.dataset.col,10);m>=2&&(f.style.display=m-2>=u?"none":"")});const g=e.map(f=>{const b={CHK:"N",k:s&&f[s]!==void 0?f[s]:f[0]!==void 0?f[0]:""};return c.forEach((m,y)=>{b[`tmp${y+1}`]=f[m]!==void 0?f[m]:f[y]!==void 0?f[y]:""}),b});if(l.data.set(g),r&&t(this,ot).value){const f=String(t(this,ot).value).split(o||",");l.data.getValidData().forEach(b=>{f.includes(String(b.v[1]))&&(b.v[0]="Y")}),l.refreshData()}},"#initData"));E(this,"open",h((e,s,i,r,o,l)=>{p(this,ot,e),p(this,Zr,i),p(this,Jr,r),p(this,Is,!0),v.log(new Date),this.classList.add("active");const a=this.querySelector("nine-table-simple");if(!a||!s)return;this.querySelector(".search-input").value="",this.querySelector("#chkAll").checked=!0,s.length>10?this.classList.add("expand"):this.classList.remove("expand"),o?this.classList.add("multi"):this.classList.remove("multi");const c=e.closest("nine-table-sheet"),u=e.querySelector(".btn1");if(!u||!c)return;const g=u.getBoundingClientRect(),f=c.getBoundingClientRect();let b=g.left-f.left,m=g.bottom-f.top+2;const y=this.offsetWidth||250,x=this.offsetHeight||250;if(b+y>f.width&&(b=Math.max(0,f.width-y-5)),b<0&&(b=5),m+x>f.height){const w=g.top-f.top-x-2;w>=0?m=w:m=Math.max(0,f.height-x-5)}this.style.left=`${b}px`,this.style.top=`${m}px`,v.log(new Date),setTimeout(()=>{v.log(new Date),t(this,Qr).call(this,s,i,r,o,l),v.log(new Date);const w=a.shadowRoot.querySelector(".ng-container-body table tbody.body");w.__hasClickEvent||(w.addEventListener("mousedown",S=>{v.log("==========================================",S.target),S.target.closest("tr")&&(v.log("==========================================",o),o||t(this,tn).call(this,S))}),w.__hasClickEvent=!0),v.log(new Date)},100)},"open"));E(this,"close",h(()=>{this.classList.remove("active"),p(this,Is,!1),t(this,ot)&&t(this,ot).cell&&t(this,ot).cell.focus()},"close"));d(this,tn,h(e=>{const s=e.target.closest("nine-table-sheet"),i=e.target.closest("tr"),r=parseInt(i.dataset.row,10),o=s.view.get(r);t(this,ot).value=o.k,t(this,ot).sheet.rowManager.refresh(!0),this.close()},"#onClickRow"));d(this,en,h(()=>{const s=this.querySelector("nine-table-simple").data.getValidData(),i=[];s.forEach(r=>{r.v[0]==="Y"&&i.push(r.v[1])}),t(this,ot).value=i.join(t(this,ot).getAttribute("multi-separator")||","),t(this,ot).sheet.rowManager.refresh(!0),this.close()},"#onOk"));d(this,sn,h(e=>{const s=this.querySelector("nine-table-simple"),i=e.target.checked?"Y":"N";s.data.getValidData().forEach(r=>{r.v[0]=i}),s.refreshData()},"#onSelectAll"));d(this,rn,h(e=>{const s=e.target.value.toLowerCase(),i=this.querySelector("nine-table-simple");i.data.getValidDataNF().forEach(r=>{const o=Object.values(r.v).some(l=>l!=null&&String(l).toLowerCase().includes(s));r.__ng.filtered=!o}),i.data.resetRecords(),i.dataManager.viewRecords.reset()},"#onInput"));d(this,nn,h(()=>{this.querySelector(".search-input").addEventListener("input",t(this,rn)),this.querySelector("#btnOk").addEventListener("click",t(this,en)),this.querySelector("#chkAll").addEventListener("change",t(this,sn)),document.addEventListener("mousedown",e=>{(e.composedPath?e.composedPath():[]).includes(this)||this.close()})},"#initEvents"));d(this,on,h(()=>{this.innerHTML=`
763
+ `,p(this,is,this.querySelector("div"))},"#renderer"));E(this,"rerenderer",h(()=>{t(this,Di).call(this),this.refresh()},"rerenderer"));E(this,"refresh",h(()=>{const e=super.refresh();return t(this,is)&&(this.querySelectorAll("input").forEach(s=>{s.checked=this.value==s.getAttribute("value")}),t(this,Yr).call(this)),e},"refresh"));d(this,Yr,h(()=>{if(!super.cell||(super.cell.classList.remove("invalid"),this.value===null||this.value===void 0||this.value===""||!Array.isArray(t(this,zt))))return;t(this,zt).findIndex(s=>this.value===s[t(this,rs)])<0&&super.cell.classList.add("invalid")},"#validateInput"));this.applyBaseStyle()}connectedCallback(){p(this,rs,this.closest("th,td").getAttribute("key-name")||"k"),p(this,ks,this.closest("th,td").getAttribute("value-name")||"v"),t(this,Kr).call(this),super.connectedCallback(),t(this,Di).call(this),t(this,jr).call(this)}get dataSource(){return t(this,zt)}};is=new WeakMap,zt=new WeakMap,rs=new WeakMap,ks=new WeakMap,_o=new WeakMap,Uo=new WeakMap,Go=new WeakMap,jo=new WeakMap,jr=new WeakMap,Di=new WeakMap,Kr=new WeakMap,Yr=new WeakMap,h(Ko,"CellRadio");let Jn=Ko;customElements.get("cell-radio")||customElements.define("cell-radio",Jn);const Yo=class Yo extends HTMLElement{constructor(){super();d(this,ot);d(this,Zr);d(this,Jr);d(this,Is,!1);d(this,Qr,h((e,s,i,r,o)=>{const l=this.querySelector("nine-table-simple");if(!l||!e||e.length===0)return;const a=t(this,ot).getAttribute("items");let c=[];a?c=a.split(",").map(g=>g.trim()):c=[i].filter(Boolean);const u=c.length;l.shadowRoot.querySelector(".ng-container-left").style.display=r?"":"none",l.shadowRoot.querySelectorAll("table colgroup col, tbody td").forEach((g,b)=>{v.log(g);const m=parseInt(g.dataset.col,10);m>=2&&(g.style.display=m-2>=u?"none":"")});const f=e.map(g=>{const b={CHK:"N",k:s&&g[s]!==void 0?g[s]:g[0]!==void 0?g[0]:""};return c.forEach((m,y)=>{b[`tmp${y+1}`]=g[m]!==void 0?g[m]:g[y]!==void 0?g[y]:""}),b});if(l.data.set(f),r&&t(this,ot).value){const g=String(t(this,ot).value).split(o||",");l.data.getValidData().forEach(b=>{g.includes(String(b.v[1]))&&(b.v[0]="Y")}),l.refreshData()}},"#initData"));E(this,"open",h((e,s,i,r,o,l)=>{p(this,ot,e),p(this,Zr,i),p(this,Jr,r),p(this,Is,!0),v.log(new Date),this.classList.add("active");const a=this.querySelector("nine-table-simple");if(!a||!s)return;this.querySelector(".search-input").value="",this.querySelector("#chkAll").checked=!0,s.length>10?this.classList.add("expand"):this.classList.remove("expand"),o?this.classList.add("multi"):this.classList.remove("multi");const c=e.closest("nine-table-sheet"),u=e.querySelector(".btn1");if(!u||!c)return;const f=u.getBoundingClientRect(),g=c.getBoundingClientRect();let b=f.left-g.left,m=f.bottom-g.top+2;const y=this.offsetWidth||250,x=this.offsetHeight||250;if(b+y>g.width&&(b=Math.max(0,g.width-y-5)),b<0&&(b=5),m+x>g.height){const w=f.top-g.top-x-2;w>=0?m=w:m=Math.max(0,g.height-x-5)}this.style.left=`${b}px`,this.style.top=`${m}px`,v.log(new Date),setTimeout(()=>{v.log(new Date),t(this,Qr).call(this,s,i,r,o,l),v.log(new Date);const w=a.shadowRoot.querySelector(".ng-container-body table tbody.body");w.__hasClickEvent||(w.addEventListener("mousedown",S=>{v.log("==========================================",S.target),S.target.closest("tr")&&(v.log("==========================================",o),o||t(this,tn).call(this,S))}),w.__hasClickEvent=!0),v.log(new Date)},100)},"open"));E(this,"close",h(()=>{this.classList.remove("active"),p(this,Is,!1),t(this,ot)&&t(this,ot).cell&&t(this,ot).cell.focus()},"close"));d(this,tn,h(e=>{const s=e.target.closest("nine-table-sheet"),i=e.target.closest("tr"),r=parseInt(i.dataset.row,10),o=s.view.get(r);t(this,ot).value=o.k,t(this,ot).sheet.rowManager.refresh(!0),this.close()},"#onClickRow"));d(this,en,h(()=>{const s=this.querySelector("nine-table-simple").data.getValidData(),i=[];s.forEach(r=>{r.v[0]==="Y"&&i.push(r.v[1])}),t(this,ot).value=i.join(t(this,ot).getAttribute("multi-separator")||","),t(this,ot).sheet.rowManager.refresh(!0),this.close()},"#onOk"));d(this,sn,h(e=>{const s=this.querySelector("nine-table-simple"),i=e.target.checked?"Y":"N";s.data.getValidData().forEach(r=>{r.v[0]=i}),s.refreshData()},"#onSelectAll"));d(this,rn,h(e=>{const s=e.target.value.toLowerCase(),i=this.querySelector("nine-table-simple");i.data.getValidDataNF().forEach(r=>{const o=Object.values(r.v).some(l=>l!=null&&String(l).toLowerCase().includes(s));r.__ng.filtered=!o}),i.data.resetRecords(),i.dataManager.viewRecords.reset()},"#onInput"));d(this,nn,h(()=>{this.querySelector(".search-input").addEventListener("input",t(this,rn)),this.querySelector("#btnOk").addEventListener("click",t(this,en)),this.querySelector("#chkAll").addEventListener("change",t(this,sn)),document.addEventListener("mousedown",e=>{(e.composedPath?e.composedPath():[]).includes(this)||this.close()})},"#initEvents"));d(this,on,h(()=>{this.innerHTML=`
765
764
  <style>
766
765
 
767
766
  cell-combo-panel.active {
@@ -870,7 +869,7 @@
870
869
  </div>
871
870
  <button id="btnOk">OK</button>
872
871
  </div>
873
- `},"#renderer"))}connectedCallback(){t(this,on).call(this),t(this,nn).call(this)}get isOpen(){return t(this,Is)}get targetCell(){return t(this,ot)}};ot=new WeakMap,Zr=new WeakMap,Jr=new WeakMap,Is=new WeakMap,Qr=new WeakMap,tn=new WeakMap,en=new WeakMap,sn=new WeakMap,rn=new WeakMap,nn=new WeakMap,on=new WeakMap,h(Yo,"CellComboPanel");let Qn=Yo;customElements.get("cell-combo-panel")||customElements.define("cell-combo-panel",Qn);const Zo=class Zo extends Jt{constructor(){super();d(this,qs);d(this,Pt,[]);d(this,Re);d(this,ns);d(this,os);d(this,Ce);d(this,Ht);E(this,"rerenderer",h(()=>{v.log("rerenderer"),t(this,$i).call(this),this.refresh()},"rerenderer"));d(this,$i,h(()=>{var s;if(!super.sheet||!super.cell)return;const e=(s=super.cell)==null?void 0:s.getAttribute("data-source");e&&p(this,Pt,super.getExprValue(e,super.tr.data,super.tr.dataset.row))},"#initData"));d(this,ln,h(()=>{this.addEventListener("keydown",e=>{e.code==="Enter"&&(e.preventDefault(),t(this,Fi).call(this))}),this.querySelectorAll("button").forEach(e=>{e.addEventListener("click",s=>{s.stopPropagation(),t(this,Fi).call(this)})})},"#initEvent"));d(this,Fi,h(()=>{v.log(new Date),t(this,Ht)||(p(this,Ht,super.sheet.querySelector("cell-combo-panel")),t(this,Ht)||(p(this,Ht,document.createElement("cell-combo-panel")),super.sheet.appendChild(t(this,Ht)))),v.log(new Date),t(this,Ht).isOpen&&t(this,Ht).targetCell===this?t(this,Ht).close():t(this,Ht).open(this,t(this,Pt),t(this,Re),t(this,ns),t(this,os),t(this,Ce)),v.log(new Date)},"#togglePanel"));d(this,an,h(()=>{this.innerHTML=`
872
+ `},"#renderer"))}connectedCallback(){t(this,on).call(this),t(this,nn).call(this)}get isOpen(){return t(this,Is)}get targetCell(){return t(this,ot)}};ot=new WeakMap,Zr=new WeakMap,Jr=new WeakMap,Is=new WeakMap,Qr=new WeakMap,tn=new WeakMap,en=new WeakMap,sn=new WeakMap,rn=new WeakMap,nn=new WeakMap,on=new WeakMap,h(Yo,"CellComboPanel");let Qn=Yo;customElements.get("cell-combo-panel")||customElements.define("cell-combo-panel",Qn);const Zo=class Zo extends Jt{constructor(){super();d(this,qs);d(this,Bt,[]);d(this,Le);d(this,ns);d(this,os);d(this,Ce);d(this,Mt);E(this,"rerenderer",h(()=>{v.log("rerenderer"),t(this,$i).call(this),this.refresh()},"rerenderer"));d(this,$i,h(()=>{var s;if(!super.sheet||!super.cell)return;const e=(s=super.cell)==null?void 0:s.getAttribute("data-source");e&&p(this,Bt,super.getExprValue(e,super.tr.data,super.tr.dataset.row))},"#initData"));d(this,ln,h(()=>{this.addEventListener("keydown",e=>{e.code==="Enter"&&(e.preventDefault(),t(this,Fi).call(this))}),this.querySelectorAll("button").forEach(e=>{e.addEventListener("click",s=>{s.stopPropagation(),t(this,Fi).call(this)})})},"#initEvent"));d(this,Fi,h(()=>{v.log(new Date),t(this,Mt)||(p(this,Mt,super.sheet.querySelector("cell-combo-panel")),t(this,Mt)||(p(this,Mt,document.createElement("cell-combo-panel")),super.sheet.appendChild(t(this,Mt)))),v.log(new Date),t(this,Mt).isOpen&&t(this,Mt).targetCell===this?t(this,Mt).close():t(this,Mt).open(this,t(this,Bt),t(this,Le),t(this,ns),t(this,os),t(this,Ce)),v.log(new Date)},"#togglePanel"));d(this,an,h(()=>{this.innerHTML=`
874
873
  <style>
875
874
  cell-combo {
876
875
  height: 100%;
@@ -934,9 +933,9 @@
934
933
  </style>
935
934
  <button class="btn1" type="button" tabindex="-1">Select</button>
936
935
  <button class="btn2" type="button" tabindex="-1"></button>
937
- `,p(this,qs,this.querySelector(".btn1"))},"#renderer"));E(this,"refresh",h(()=>{const e=super.refresh();return t(this,qs)&&(t(this,qs).textContent=t(this,cn).call(this)||"Select",t(this,hn).call(this)),e},"refresh"));d(this,cn,h(()=>{if(!this.value||!Array.isArray(t(this,Pt)))return"";if(t(this,os)){const e=String(this.value).split(t(this,Ce));return t(this,Pt).filter(s=>e.includes(String(s[t(this,Re)]))).map(s=>s[t(this,ns)]).join(t(this,Ce))}else{const e=t(this,Pt).find(s=>String(s[t(this,Re)])===String(this.value));return e?e[t(this,ns)]:this.value}},"#getDisplayText"));d(this,hn,h(()=>{if(!super.cell||(super.cell.classList.remove("invalid"),this.value===null||this.value===void 0||this.value===""||!Array.isArray(t(this,Pt))))return;const e=t(this,os)?String(this.value).split(t(this,Ce)):[this.value];for(const s of e)if(t(this,Pt).findIndex(r=>String(s)===String(r[t(this,Re)]))<0){super.cell.classList.add("invalid");break}},"#validateInput"));this.applyBaseStyle()}connectedCallback(){t(this,an).call(this),super.connectedCallback(),p(this,Re,super.cell.getAttribute("key-name")||"k"),p(this,ns,super.cell.getAttribute("value-name")||"v"),p(this,os,super.cell.getAttribute("multi")==="true"),p(this,Ce,super.cell.getAttribute("multi-separator")||","),t(this,$i).call(this),t(this,ln).call(this)}get dataSource(){return t(this,Pt)}};qs=new WeakMap,Pt=new WeakMap,Re=new WeakMap,ns=new WeakMap,os=new WeakMap,Ce=new WeakMap,Ht=new WeakMap,$i=new WeakMap,ln=new WeakMap,Fi=new WeakMap,an=new WeakMap,cn=new WeakMap,hn=new WeakMap,h(Zo,"CellCombo");let to=Zo;customElements.get("cell-combo")||customElements.define("cell-combo",to);const Jo=class Jo extends hs{constructor(){super();d(this,Ms);E(this,"refresh",h(()=>{super.refresh(),this.cell.getAttribute("html")==="true"?t(this,Ms).innerHTML=this.getDisplayText():t(this,Ms).textContent=this.getDisplayText()},"refresh"));d(this,dn,h(()=>{this.innerHTML=`
936
+ `,p(this,qs,this.querySelector(".btn1"))},"#renderer"));E(this,"refresh",h(()=>{const e=super.refresh();return t(this,qs)&&(t(this,qs).textContent=t(this,cn).call(this)||"Select",t(this,hn).call(this)),e},"refresh"));d(this,cn,h(()=>{if(!this.value||!Array.isArray(t(this,Bt)))return"";if(t(this,os)){const e=String(this.value).split(t(this,Ce));return t(this,Bt).filter(s=>e.includes(String(s[t(this,Le)]))).map(s=>s[t(this,ns)]).join(t(this,Ce))}else{const e=t(this,Bt).find(s=>String(s[t(this,Le)])===String(this.value));return e?e[t(this,ns)]:this.value}},"#getDisplayText"));d(this,hn,h(()=>{if(!super.cell||(super.cell.classList.remove("invalid"),this.value===null||this.value===void 0||this.value===""||!Array.isArray(t(this,Bt))))return;const e=t(this,os)?String(this.value).split(t(this,Ce)):[this.value];for(const s of e)if(t(this,Bt).findIndex(r=>String(s)===String(r[t(this,Le)]))<0){super.cell.classList.add("invalid");break}},"#validateInput"));this.applyBaseStyle()}connectedCallback(){t(this,an).call(this),super.connectedCallback(),p(this,Le,super.cell.getAttribute("key-name")||"k"),p(this,ns,super.cell.getAttribute("value-name")||"v"),p(this,os,super.cell.getAttribute("multi")==="true"),p(this,Ce,super.cell.getAttribute("multi-separator")||","),t(this,$i).call(this),t(this,ln).call(this)}get dataSource(){return t(this,Bt)}};qs=new WeakMap,Bt=new WeakMap,Le=new WeakMap,ns=new WeakMap,os=new WeakMap,Ce=new WeakMap,Mt=new WeakMap,$i=new WeakMap,ln=new WeakMap,Fi=new WeakMap,an=new WeakMap,cn=new WeakMap,hn=new WeakMap,h(Zo,"CellCombo");let to=Zo;customElements.get("cell-combo")||customElements.define("cell-combo",to);const Jo=class Jo extends hs{constructor(){super();d(this,Ms);E(this,"refresh",h(()=>{super.refresh(),this.cell.getAttribute("html")==="true"?t(this,Ms).innerHTML=this.getDisplayText():t(this,Ms).textContent=this.getDisplayText()},"refresh"));d(this,dn,h(()=>{this.innerHTML=`
938
937
  <span></span>
939
- `},"#renderer"))}connectedCallback(){super.connectedCallback(),t(this,dn).call(this),p(this,Ms,this.querySelector("span"))}};Ms=new WeakMap,dn=new WeakMap,h(Jo,"CellRenderer");let eo=Jo;customElements.get("cell-renderer")||customElements.define("cell-renderer",eo);const Qo=class Qo extends hs{constructor(){super();d(this,ls);d(this,Wi,h(e=>{e.stopPropagation();const s=parseInt(this.cell.dataset.row,10),i=new CustomEvent(Dt.EVENT.CELL_BUTTON_CLICK,{bubbles:!0,composed:!0,detail:{originalEvent:e,cell:this.cell,row:s,col:parseInt(this.cell.dataset.col,10),bind:this.dataset.bind,data:this.host.data.get(s),value:this.value}});this.dispatchEvent(i)},"#cellButtonClick"));E(this,"refresh",h(()=>{const e=super.refresh?super.refresh():this.value;t(this,ls).innerHTML=this.getDisplayText(e)},"refresh"));d(this,un,h(()=>{const e=this.closest("th,td"),s="...",i=(parseInt(e.offsetHeight,10)||32)-8;this.innerHTML=`
938
+ `},"#renderer"))}connectedCallback(){super.connectedCallback(),t(this,dn).call(this),p(this,Ms,this.querySelector("span"))}};Ms=new WeakMap,dn=new WeakMap,h(Jo,"CellRenderer");let eo=Jo;customElements.get("cell-renderer")||customElements.define("cell-renderer",eo);const Qo=class Qo extends hs{constructor(){super();d(this,ls);d(this,Wi,h(e=>{e.stopPropagation();const s=parseInt(this.cell.dataset.row,10),i=new CustomEvent(Nt.EVENT.CELL_BUTTON_CLICK,{bubbles:!0,composed:!0,detail:{originalEvent:e,cell:this.cell,row:s,col:parseInt(this.cell.dataset.col,10),bind:this.dataset.bind,data:this.host.data.get(s),value:this.value}});this.dispatchEvent(i)},"#cellButtonClick"));E(this,"refresh",h(()=>{const e=super.refresh?super.refresh():this.value;t(this,ls).innerHTML=this.getDisplayText(e)},"refresh"));d(this,un,h(()=>{const e=this.closest("th,td"),s="...",i=(parseInt(e.offsetHeight,10)||32)-8;this.innerHTML=`
940
939
  <style>
941
940
  /* 셀(td, th) 내부 패딩 제거 및 꽉 채우기 설정 */
942
941
  cell-button {
@@ -1034,7 +1033,7 @@
1034
1033
  `},"#renderer"));E(this,"refresh",h(()=>{if(!this.cell||!this.tr)return;const e=this.row;if(isNaN(e))return;const s=this.tr.data;s&&s.__ng&&s.__ng.rowState;const i=this.index+1,r=i.toLocaleString();if(i>=1e4){const a=r.length-4,c=r.substring(0,a+1),u=r.substring(a+1);t(this,Hs).innerHTML=`
1035
1034
  <span class="ng-row-prefix">${c}</span>
1036
1035
  <span class="ng-row-suffix">${u}</span>
1037
- `}else t(this,Hs).innerHTML=`${r}`;const o=!!this.sheet.querySelector("thead .asc,thead .desc"),l=!!this.sheet.querySelector("thead nine-table-filter-button.filtered");t(this,Ns).innerHTML=e,t(this,Ns).style.display=o||l?"":"none"},"refresh"));this.applyBaseStyle()}connectedCallback(){var e;t(this,gn).call(this),(e=super.connectedCallback)==null||e.call(this),this.cell&&(this.cell.removeAttribute("tabindex"),this.cell.dataset.bind="rowState",this.cell.dataset.expr||(this.cell.dataset.expr="data.__ng._[ninegrid.ROW.ORDER]"),this.cell.setAttribute("text-align","center")),p(this,Hs,this.querySelector(".ng-row-main")),p(this,Ns,this.querySelector(".ng-row-sub")),p(this,fn,this.querySelector(".ng-row-status"))}};Hs=new WeakMap,Ns=new WeakMap,fn=new WeakMap,gn=new WeakMap,h(tl,"CellRowIndicator");let io=tl;customElements.get("cell-row-indicator")||customElements.define("cell-row-indicator",io);const el=class el extends HTMLElement{constructor(){super();d(this,ut);d(this,Y);d(this,Ds,h(e=>{e.preventDefault(),e.stopPropagation(),this.classList.contains("expand")?this.collapse():this.expand()},"#onClick"));E(this,"expand",h(()=>{var r;if(!((r=t(this,ut))!=null&&r.colResizer)||!t(this,Y))return;const e=parseInt(t(this,Y).dataset.col,10),s=t(this,Y).colSpan||1;this.classList.remove("collapsed"),this.classList.add("expand"),t(this,Y).setAttribute("collapsed","false"),t(this,Y).style.color="";const i=parseInt(t(this,Y).dataset.expandWidth,10)||100;if(s===1)t(this,ut).colResizer.setColumnWidth(e,i);else{const o=Math.max(30,Math.floor(i/s));for(let l=0;l<s;l++)t(this,ut).colResizer.setColumnWidth(e+l,o)}requestAnimationFrame(()=>{typeof t(this,ut).refreshLayout=="function"&&t(this,ut).refreshLayout()})},"expand"));E(this,"collapse",h((e=!1)=>{var r;if(!((r=t(this,ut))!=null&&r.colResizer)||!t(this,Y))return;const s=parseInt(t(this,Y).dataset.col,10),i=t(this,Y).colSpan||1;if(this.classList.contains("expand")){const o=t(this,ut).querySelector(`colgroup col[data-col="${s}"]`),l=o?parseInt(o.getAttribute("width"),10):0;l>mt&&(t(this,Y).dataset.expandWidth=String(l*i))}if(this.classList.remove("expand"),this.classList.add("collapsed"),t(this,Y).setAttribute("collapsed","true"),t(this,Y).style.color="transparent",i===1)t(this,ut).colResizer.setColumnWidth(s,mt);else{const o=Math.max(10,Math.floor(mt/i));for(let l=0;l<i;l++)t(this,ut).colResizer.setColumnWidth(s+l,o)}requestAnimationFrame(()=>{typeof t(this,ut).refreshLayout=="function"&&t(this,ut).refreshLayout()})},"collapse"))}connectedCallback(){var s;p(this,Y,this.closest("th, td")),p(this,ut,this.closest("nine-table-sheet")),t(this,Y)&&(t(this,Y).style.position="relative"),this.getAttribute("collapsed")==="true"||((s=t(this,Y))==null?void 0:s.getAttribute("collapsed"))==="true"?requestAnimationFrame(()=>{this.collapse(!0)}):(this.classList.remove("collapsed"),this.classList.add("expand")),this.removeEventListener("click",t(this,Ds)),this.addEventListener("click",t(this,Ds))}disconnectedCallback(){this.removeEventListener("click",t(this,Ds))}};ut=new WeakMap,Y=new WeakMap,Ds=new WeakMap,h(el,"ColExpand");let ro=el;customElements.get("nine-table-col-expand")||customElements.define("nine-table-col-expand",ro);const sl=class sl extends HTMLElement{constructor(){super(...arguments);d(this,j);d(this,Q);d(this,vt);d(this,pn,h(e=>{const s=e.composedPath?e.composedPath():[],i=s.find(o=>o.tagName==="TH"||o.tagName==="TD");if(!i)return;const r=s.find(o=>o.tagName==="TABLE")||i.closest("table");e.preventDefault(),e.stopPropagation(),this.openMenu(e.clientX,e.clientY,i,r)},"#onContextMenu"))}connectedCallback(){var s,i;const e=this.getRootNode();p(this,Q,e instanceof ShadowRoot?e.host:this.closest("nine-table")||e.host),t(this,Q)||p(this,Q,((s=this.parentElement)==null?void 0:s.closest("nine-table"))||((i=this.assignedSlot)==null?void 0:i.closest("nine-table"))),t(this,Q)}openMenu(e,s,i,r){const o=t(this,Q).shadowRoot||t(this,Q);t(this,vt)||(p(this,vt,document.createElement("nine-table-menu-panel")),o.appendChild(t(this,vt)));const l=!!i.closest("thead"),a=A(this,j,Ql).call(this,r,l,i);t(this,vt).render(a,u=>A(this,j,ea).call(this,u,i,r));const c=A(this,j,wn).call(this,i);A(this,j,ta).call(this,c),t(this,vt).openAt(e,s)}disconnectedCallback(){var e;(e=t(this,Q))==null||e.removeEventListener("contextmenu",t(this,pn))}};Q=new WeakMap,vt=new WeakMap,pn=new WeakMap,j=new WeakSet,wn=h(function(e){return(e==null?void 0:e.closest("nine-table-sheet"))||t(this,Q).activeSheet||t(this,Q)},"#getTargetSheet"),ml=h(function(e){const s=A(this,j,wn).call(this,e);return s?(s.colFix||(s.colFix=new Pi(s)),s.colFix):null},"#getFixManager"),Jl=h(function(e,s){const i=[],r=s==null?void 0:s.id;return Array.from(e.querySelectorAll(":scope > ul")).forEach(l=>{const a=l.getAttribute("target-table");if(!a||r&&a===r){const c=A(this,j,yl).call(this,l);i.push(...c)}}),i},"#parseCustomMenuItems"),yl=h(function(e){const s=[];return Array.from(e.children).forEach(i=>{const r=i.tagName.toLowerCase();if(r==="hr"||i.classList.contains("separator")){s.push({type:"separator"});return}if(r==="li"){let o="";const l=i.querySelector(":scope > span");l?o=l.textContent.trim():o=Array.from(i.childNodes).filter(u=>u.nodeType===Node.TEXT_NODE).map(u=>u.textContent.trim()).join("");const a=i.querySelector(":scope > ul"),c={menuId:i.id||o,name:o,className:i.className||"",disabled:i.hasAttribute("disabled")||i.getAttribute("disabled")==="true",isCustom:!0};a&&(c.items=A(this,j,yl).call(this,a)),s.push(c)}}),s},"#traverseUl"),Ql=h(function(e,s,i){const r=this.getAttribute("use-default-menu")!=="false";let o=[];const l=A(this,j,Jl).call(this,this,e);l.length>0&&o.push(...l);const a=A(this,j,ml).call(this,i),c=(a==null?void 0:a.getFixState(i,e))??"none",u=s&&((a==null?void 0:a.canFixColumn(i,e))??!1);let g=null;c==="left"||c==="right"?g={menuId:"unfix-column",name:"Unfix Column",className:"ng-menu-unfix-col",disabled:!s}:g={menuId:"fix-column",name:"Fix Column",className:"ng-menu-fix-col",disabled:!u},r&&o.push({type:"separator"},{menuId:"sort",name:"Sort",className:"ng-menu-sort",disabled:!s},g,{type:"separator"},{menuId:"filtering",name:"Filtering",className:"ng-menu-filtering"},{menuId:"maximize",name:"Maximize",className:"maximize"},{menuId:"export",name:"Export",className:"export",items:[{menuId:"export-excel",name:"Excel",className:"export-excel"},{menuId:"export-pdf",name:"PDF",className:"export-pdf",disabled:!0}]},{menuId:"properties",name:"Options",className:"options",items:[{menuId:"show-title-bar",name:"Title Bar Show/Hide",className:"show-title-bar"},{menuId:"show-status-bar",name:"Status Bar Show/Hide",className:"show-status-bar"},{menuId:"auto-fit-col",name:"Auto Fit Columns",className:"auto-fit-col"}]});const f=[];return o.forEach(b=>{b.type==="separator"&&(f.length===0||f[f.length-1].type==="separator")||f.push(b)}),f.length>0&&f[f.length-1].type==="separator"&&f.pop(),f},"#buildMenuItems"),ta=h(function(e){var o,l;if(!t(this,vt)||!e)return;const s=((l=(o=e.filtering)==null?void 0:o.isFiltering)==null?void 0:l.call(o))||!1;t(this,vt).toggleItemState("filtering","on",s);const i=t(this,Q).getAttribute("auto-fit-col")==="true";t(this,vt).toggleItemState("auto-fit-col","on",i);const r=t(this,Q).getAttribute("show-title-bar")==="true";t(this,vt).toggleItemState("show-title-bar","on",r)},"#syncMenuStates"),ea=h(function(e,s,i){var c,u,g;const r=e.menuId,o=new CustomEvent("menu-click",{detail:{menuId:r,targetCell:s,targetTable:i,originalEvent:e},bubbles:!0,composed:!0});this.dispatchEvent(o);const l=parseInt(s.dataset.col,10),a=A(this,j,wn).call(this,s);switch(r){case"fix-column":case"unfix-column":const f=A(this,j,ml).call(this,s);f==null||f.executeFixToggle(r,s);break;case"sort":isNaN(l)||(u=(c=a.sorting)==null?void 0:c.handleSortFromMenu)==null||u.call(c,l,s);break;case"filtering":(g=a==null?void 0:a.filtering)==null||g.toggle();break;case"auto-fit-col":t(this,Q).setAttribute("auto-fit-col",t(this,Q).getAttribute("auto-fit-col")==="true"?"false":"true");break;case"show-title-bar":t(this,Q).setAttribute("show-title-bar",t(this,Q).getAttribute("show-title-bar")==="true"?"false":"true");break}t(this,vt).close()},"#handleMenuClick"),h(sl,"ContextMenu");let no=sl;customElements.get("nine-table-menu")||customElements.define("nine-table-menu",no);const il=class il extends HTMLElement{constructor(){super();d(this,as);d(this,Oi);d(this,Zt,null)}connectedCallback(){this.style.position="fixed",this.style.display="none",this.style.zIndex="99999",this.innerHTML=`
1036
+ `}else t(this,Hs).innerHTML=`${r}`;const o=!!this.sheet.querySelector("thead .asc,thead .desc"),l=!!this.sheet.querySelector("thead nine-table-filter-button.filtered");t(this,Ns).innerHTML=e,t(this,Ns).style.display=o||l?"":"none"},"refresh"));this.applyBaseStyle()}connectedCallback(){var e;t(this,gn).call(this),(e=super.connectedCallback)==null||e.call(this),this.cell&&(this.cell.removeAttribute("tabindex"),this.cell.dataset.bind="rowState",this.cell.dataset.expr||(this.cell.dataset.expr="data.__ng._[ninegrid.ROW.ORDER]"),this.cell.setAttribute("text-align","center")),p(this,Hs,this.querySelector(".ng-row-main")),p(this,Ns,this.querySelector(".ng-row-sub")),p(this,fn,this.querySelector(".ng-row-status"))}};Hs=new WeakMap,Ns=new WeakMap,fn=new WeakMap,gn=new WeakMap,h(tl,"CellRowIndicator");let io=tl;customElements.get("cell-row-indicator")||customElements.define("cell-row-indicator",io);const el=class el extends HTMLElement{constructor(){super();d(this,ut);d(this,Y);d(this,Ds,h(e=>{e.preventDefault(),e.stopPropagation(),this.classList.contains("expand")?this.collapse():this.expand()},"#onClick"));E(this,"expand",h(()=>{var r;if(!((r=t(this,ut))!=null&&r.colResizer)||!t(this,Y))return;const e=parseInt(t(this,Y).dataset.col,10),s=t(this,Y).colSpan||1;this.classList.remove("collapsed"),this.classList.add("expand"),t(this,Y).setAttribute("collapsed","false"),t(this,Y).style.color="";const i=parseInt(t(this,Y).dataset.expandWidth,10)||100;if(s===1)t(this,ut).colResizer.setColumnWidth(e,i);else{const o=Math.max(30,Math.floor(i/s));for(let l=0;l<s;l++)t(this,ut).colResizer.setColumnWidth(e+l,o)}requestAnimationFrame(()=>{typeof t(this,ut).refreshLayout=="function"&&t(this,ut).refreshLayout()})},"expand"));E(this,"collapse",h((e=!1)=>{var r;if(!((r=t(this,ut))!=null&&r.colResizer)||!t(this,Y))return;const s=parseInt(t(this,Y).dataset.col,10),i=t(this,Y).colSpan||1;if(this.classList.contains("expand")){const o=t(this,ut).querySelector(`colgroup col[data-col="${s}"]`),l=o?parseInt(o.getAttribute("width"),10):0;l>mt&&(t(this,Y).dataset.expandWidth=String(l*i))}if(this.classList.remove("expand"),this.classList.add("collapsed"),t(this,Y).setAttribute("collapsed","true"),t(this,Y).style.color="transparent",i===1)t(this,ut).colResizer.setColumnWidth(s,mt);else{const o=Math.max(10,Math.floor(mt/i));for(let l=0;l<i;l++)t(this,ut).colResizer.setColumnWidth(s+l,o)}requestAnimationFrame(()=>{typeof t(this,ut).refreshLayout=="function"&&t(this,ut).refreshLayout()})},"collapse"))}connectedCallback(){var s;p(this,Y,this.closest("th, td")),p(this,ut,this.closest("nine-table-sheet")),t(this,Y)&&(t(this,Y).style.position="relative"),this.getAttribute("collapsed")==="true"||((s=t(this,Y))==null?void 0:s.getAttribute("collapsed"))==="true"?requestAnimationFrame(()=>{this.collapse(!0)}):(this.classList.remove("collapsed"),this.classList.add("expand")),this.removeEventListener("click",t(this,Ds)),this.addEventListener("click",t(this,Ds))}disconnectedCallback(){this.removeEventListener("click",t(this,Ds))}};ut=new WeakMap,Y=new WeakMap,Ds=new WeakMap,h(el,"ColExpand");let ro=el;customElements.get("nine-table-col-expand")||customElements.define("nine-table-col-expand",ro);const sl=class sl extends HTMLElement{constructor(){super(...arguments);d(this,j);d(this,Q);d(this,vt);d(this,pn,h(e=>{const s=e.composedPath?e.composedPath():[],i=s.find(o=>o.tagName==="TH"||o.tagName==="TD");if(!i)return;const r=s.find(o=>o.tagName==="TABLE")||i.closest("table");e.preventDefault(),e.stopPropagation(),this.openMenu(e.clientX,e.clientY,i,r)},"#onContextMenu"))}connectedCallback(){var s,i;const e=this.getRootNode();p(this,Q,e instanceof ShadowRoot?e.host:this.closest("nine-table")||e.host),t(this,Q)||p(this,Q,((s=this.parentElement)==null?void 0:s.closest("nine-table"))||((i=this.assignedSlot)==null?void 0:i.closest("nine-table"))),t(this,Q)}openMenu(e,s,i,r){const o=t(this,Q).shadowRoot||t(this,Q);t(this,vt)||(p(this,vt,document.createElement("nine-table-menu-panel")),o.appendChild(t(this,vt)));const l=!!i.closest("thead"),a=A(this,j,Ql).call(this,r,l,i);t(this,vt).render(a,u=>A(this,j,ea).call(this,u,i,r));const c=A(this,j,wn).call(this,i);A(this,j,ta).call(this,c),t(this,vt).openAt(e,s)}disconnectedCallback(){var e;(e=t(this,Q))==null||e.removeEventListener("contextmenu",t(this,pn))}};Q=new WeakMap,vt=new WeakMap,pn=new WeakMap,j=new WeakSet,wn=h(function(e){return(e==null?void 0:e.closest("nine-table-sheet"))||t(this,Q).activeSheet||t(this,Q)},"#getTargetSheet"),ml=h(function(e){const s=A(this,j,wn).call(this,e);return s?(s.colFix||(s.colFix=new Pi(s)),s.colFix):null},"#getFixManager"),Jl=h(function(e,s){const i=[],r=s==null?void 0:s.id;return Array.from(e.querySelectorAll(":scope > ul")).forEach(l=>{const a=l.getAttribute("target-table");if(!a||r&&a===r){const c=A(this,j,yl).call(this,l);i.push(...c)}}),i},"#parseCustomMenuItems"),yl=h(function(e){const s=[];return Array.from(e.children).forEach(i=>{const r=i.tagName.toLowerCase();if(r==="hr"||i.classList.contains("separator")){s.push({type:"separator"});return}if(r==="li"){let o="";const l=i.querySelector(":scope > span");l?o=l.textContent.trim():o=Array.from(i.childNodes).filter(u=>u.nodeType===Node.TEXT_NODE).map(u=>u.textContent.trim()).join("");const a=i.querySelector(":scope > ul"),c={menuId:i.id||o,name:o,className:i.className||"",disabled:i.hasAttribute("disabled")||i.getAttribute("disabled")==="true",isCustom:!0};a&&(c.items=A(this,j,yl).call(this,a)),s.push(c)}}),s},"#traverseUl"),Ql=h(function(e,s,i){const r=this.getAttribute("use-default-menu")!=="false";let o=[];const l=A(this,j,Jl).call(this,this,e);l.length>0&&o.push(...l);const a=A(this,j,ml).call(this,i),c=(a==null?void 0:a.getFixState(i,e))??"none",u=s&&((a==null?void 0:a.canFixColumn(i,e))??!1);let f=null;c==="left"||c==="right"?f={menuId:"unfix-column",name:"Unfix Column",className:"ng-menu-unfix-col",disabled:!s}:f={menuId:"fix-column",name:"Fix Column",className:"ng-menu-fix-col",disabled:!u},r&&o.push({type:"separator"},{menuId:"sort",name:"Sort",className:"ng-menu-sort",disabled:!s},f,{type:"separator"},{menuId:"filtering",name:"Filtering",className:"ng-menu-filtering"},{menuId:"maximize",name:"Maximize",className:"maximize"},{menuId:"export",name:"Export",className:"export",items:[{menuId:"export-excel",name:"Excel",className:"export-excel"},{menuId:"export-pdf",name:"PDF",className:"export-pdf",disabled:!0}]},{menuId:"properties",name:"Options",className:"options",items:[{menuId:"show-title-bar",name:"Title Bar Show/Hide",className:"show-title-bar"},{menuId:"show-status-bar",name:"Status Bar Show/Hide",className:"show-status-bar"},{menuId:"auto-fit-col",name:"Auto Fit Columns",className:"auto-fit-col"}]});const g=[];return o.forEach(b=>{b.type==="separator"&&(g.length===0||g[g.length-1].type==="separator")||g.push(b)}),g.length>0&&g[g.length-1].type==="separator"&&g.pop(),g},"#buildMenuItems"),ta=h(function(e){var o,l;if(!t(this,vt)||!e)return;const s=((l=(o=e.filtering)==null?void 0:o.isFiltering)==null?void 0:l.call(o))||!1;t(this,vt).toggleItemState("filtering","on",s);const i=t(this,Q).getAttribute("auto-fit-col")==="true";t(this,vt).toggleItemState("auto-fit-col","on",i);const r=t(this,Q).getAttribute("show-title-bar")==="true";t(this,vt).toggleItemState("show-title-bar","on",r)},"#syncMenuStates"),ea=h(function(e,s,i){var c,u,f;const r=e.menuId,o=new CustomEvent("menu-click",{detail:{menuId:r,targetCell:s,targetTable:i,originalEvent:e},bubbles:!0,composed:!0});this.dispatchEvent(o);const l=parseInt(s.dataset.col,10),a=A(this,j,wn).call(this,s);switch(r){case"fix-column":case"unfix-column":const g=A(this,j,ml).call(this,s);g==null||g.executeFixToggle(r,s);break;case"sort":isNaN(l)||(u=(c=a.sorting)==null?void 0:c.handleSortFromMenu)==null||u.call(c,l,s);break;case"filtering":(f=a==null?void 0:a.filtering)==null||f.toggle();break;case"auto-fit-col":t(this,Q).setAttribute("auto-fit-col",t(this,Q).getAttribute("auto-fit-col")==="true"?"false":"true");break;case"show-title-bar":t(this,Q).setAttribute("show-title-bar",t(this,Q).getAttribute("show-title-bar")==="true"?"false":"true");break}t(this,vt).close()},"#handleMenuClick"),h(sl,"ContextMenu");let no=sl;customElements.get("nine-table-menu")||customElements.define("nine-table-menu",no);const il=class il extends HTMLElement{constructor(){super();d(this,as);d(this,Oi);d(this,Zt,null)}connectedCallback(){this.style.position="fixed",this.style.display="none",this.style.zIndex="99999",this.innerHTML=`
1038
1037
  <style>
1039
1038
 
1040
1039
  nine-table-menu-panel .menu-wrapper {
@@ -1109,5 +1108,5 @@
1109
1108
  <div class="menu-wrapper">
1110
1109
  <ul class="menu-container"></ul>
1111
1110
  </div>
1112
- `}render(e,s){p(this,Oi,s);const i=this.querySelector(".menu-container");i&&(i.innerHTML="",A(this,as,xl).call(this,i,e),A(this,as,sa).call(this))}openAt(e,s,i=null){if(this.style.display="block",i){const r=i.getBoundingClientRect(),o=r.right;requestAnimationFrame(()=>{const l=this.querySelector(".menu-wrapper");if(!l)return;const a=l.getBoundingClientRect().width;let c=o-a;c<0&&(c=r.left);const u=l.getBoundingClientRect().height;let g=s;s+u>window.innerHeight&&(g=s-u),this.style.left=`${c}px`,this.style.top=`${g}px`})}else this.style.left=`${e}px`,this.style.top=`${s}px`,requestAnimationFrame(()=>{const r=this.querySelector(".menu-wrapper");if(!r)return;const o=r.getBoundingClientRect();e+o.width>window.innerWidth&&(this.style.left=`${e-o.width}px`),s+o.height>window.innerHeight&&(this.style.top=`${s-o.height}px`)});t(this,Zt)&&window.removeEventListener("pointerdown",t(this,Zt)),p(this,Zt,r=>{!(r.composedPath?r.composedPath():[]).includes(this)&&!this.contains(r.target)&&this.close()}),setTimeout(()=>{window.addEventListener("pointerdown",t(this,Zt))},0)}close(){this.style.display="none",t(this,Zt)&&(window.removeEventListener("pointerdown",t(this,Zt)),p(this,Zt,null))}toggleItemState(e,s,i){const r=this.querySelector(`li[menu-id="${e}"]`);r&&(i?r.classList.add(s):r.classList.remove(s))}disconnectedCallback(){this.close()}};Oi=new WeakMap,Zt=new WeakMap,as=new WeakSet,xl=h(function(e,s){s.forEach(i=>{if(i.type==="separator"){const l=document.createElement("li");l.className="ng-menu-separator",e.appendChild(l);return}const r=document.createElement("li");r.setAttribute("menu-id",i.menuId),r.className=`${i.className||""} ${i.items?"submenu":""} ${i.disabled?"disabled":""}`.trim();const o=document.createElement("span");if(o.textContent=i.name,r.appendChild(o),i.items&&i.items.length>0){const l=document.createElement("ul");l.className="ng-menu-sublist",A(this,as,xl).call(this,l,i.items),r.appendChild(l)}e.appendChild(r)})},"#appendItems"),sa=h(function(){this.querySelectorAll("li[menu-id]").forEach(e=>{e.addEventListener("click",s=>{var r;if(s.stopPropagation(),e.classList.contains("disabled"))return;const i=e.getAttribute("menu-id");(r=t(this,Oi))==null||r.call(this,{menuId:i,target:e}),this.close()})})},"#bindClickEvents"),h(il,"MenuPanel");let oo=il;customElements.get("nine-table-menu-panel")||customElements.define("nine-table-menu-panel",oo),k.NINE_TABLE=Dt,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
1111
+ `}render(e,s){p(this,Oi,s);const i=this.querySelector(".menu-container");i&&(i.innerHTML="",A(this,as,xl).call(this,i,e),A(this,as,sa).call(this))}openAt(e,s,i=null){if(this.style.display="block",i){const r=i.getBoundingClientRect(),o=r.right;requestAnimationFrame(()=>{const l=this.querySelector(".menu-wrapper");if(!l)return;const a=l.getBoundingClientRect().width;let c=o-a;c<0&&(c=r.left);const u=l.getBoundingClientRect().height;let f=s;s+u>window.innerHeight&&(f=s-u),this.style.left=`${c}px`,this.style.top=`${f}px`})}else this.style.left=`${e}px`,this.style.top=`${s}px`,requestAnimationFrame(()=>{const r=this.querySelector(".menu-wrapper");if(!r)return;const o=r.getBoundingClientRect();e+o.width>window.innerWidth&&(this.style.left=`${e-o.width}px`),s+o.height>window.innerHeight&&(this.style.top=`${s-o.height}px`)});t(this,Zt)&&window.removeEventListener("pointerdown",t(this,Zt)),p(this,Zt,r=>{!(r.composedPath?r.composedPath():[]).includes(this)&&!this.contains(r.target)&&this.close()}),setTimeout(()=>{window.addEventListener("pointerdown",t(this,Zt))},0)}close(){this.style.display="none",t(this,Zt)&&(window.removeEventListener("pointerdown",t(this,Zt)),p(this,Zt,null))}toggleItemState(e,s,i){const r=this.querySelector(`li[menu-id="${e}"]`);r&&(i?r.classList.add(s):r.classList.remove(s))}disconnectedCallback(){this.close()}};Oi=new WeakMap,Zt=new WeakMap,as=new WeakSet,xl=h(function(e,s){s.forEach(i=>{if(i.type==="separator"){const l=document.createElement("li");l.className="ng-menu-separator",e.appendChild(l);return}const r=document.createElement("li");r.setAttribute("menu-id",i.menuId),r.className=`${i.className||""} ${i.items?"submenu":""} ${i.disabled?"disabled":""}`.trim();const o=document.createElement("span");if(o.textContent=i.name,r.appendChild(o),i.items&&i.items.length>0){const l=document.createElement("ul");l.className="ng-menu-sublist",A(this,as,xl).call(this,l,i.items),r.appendChild(l)}e.appendChild(r)})},"#appendItems"),sa=h(function(){this.querySelectorAll("li[menu-id]").forEach(e=>{e.addEventListener("click",s=>{var r;if(s.stopPropagation(),e.classList.contains("disabled"))return;const i=e.getAttribute("menu-id");(r=t(this,Oi))==null||r.call(this,{menuId:i,target:e}),this.close()})})},"#bindClickEvents"),h(il,"MenuPanel");let oo=il;customElements.get("nine-table-menu-panel")||customElements.define("nine-table-menu-panel",oo),k.NINE_TABLE=Nt,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
1113
1112
  //# sourceMappingURL=nine-table.umd.js.map