@guiexpert/table 1.1.108 → 1.1.109

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.
Files changed (3) hide show
  1. package/index.cjs +1 -1
  2. package/index.js +1 -1
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -38,7 +38,7 @@ export class ${t} implements CellRendererIf {
38
38
 
39
39
  }
40
40
 
41
- `)}}class Eo{fixJSON(e){const t=[];let s="",o=!1,i=!1;for(let r=0;r<e.length;r++){const l=e[r];if(s+=l,l==='"'&&!i&&(o=!o),l==="\\"&&!i){i=!0;continue}else i=!1;if(!o){if(l==="{"||l==="[")t.push(l);else if(l==="}"||l==="]"){const a=t.pop();if(l==="}"&&a!=="{"||l==="]"&&a!=="[")throw new Error("Invalid JSON structure detected.")}}}for(;t.length>0;){const r=t.pop();r==="{"?s+="}":r==="["&&(s+="]")}return s}}class Or{constructor(){this.property="",this.value="",this.path="",this.propertyItem=new ii("",[new oi("")])}toString(){var e;return`${this.path} -> : ${((e=this.propertyItem)==null?void 0:e.toString())??""}`}}const Mo="Entity";function Nr(n){let e=Pr(Vr(n));return e.includes(Mo)||(e=e+Mo),e}function Pr(n){if(!n||n.length===0)return n;const e=["Array","Arr","List","s"];for(const t of e)if(n.endsWith(t))return n.slice(0,-t.length);return n}function Vr(n){return!n||n.length===0?"":n[0].toUpperCase()+n.slice(1)}class wa{constructor(){this.debugging=!1}json2PropertyType(e,t=""){let s;if(typeof e=="string"){const o=new Eo().fixJSON(e);s=this.json2Object(o)}else s=e;return this.object2PropertyType(s,t)}json2Object(e){return JSON.parse(e)}object2PropertyType(e,t=""){const s=this.object2ValueInfos(e,t);this.debugging&&this.logValueInfos(s);const o=this.valueInfos2PropertyType(s);return"name"in o&&(o.name=t),o}json2ValueInfos(e,t=""){let s;if(typeof e=="string"){const o=new Eo().fixJSON(e);s=this.json2Object(o)}else s=e;return this.object2ValueInfos(s,t)}object2ValueInfos(e,t=""){const s=this.extractValueInfos(e,t),o=this.mergeValueInfos(s);return o.length>0&&(o[0].propertyItem.propertyName=t),this.debugging&&this.logValueInfos(o),o}getParentPath(e){const t=e.lastIndexOf("/");return t===-1?"":e.substring(0,t)}valueInfos2PropertyType(e){const t=e[0].propertyItem.types[0],s=new Map;for(const o of e)s.set(o.path,o);for(const o of e){const i=this.getParentPath(o.path);if(i){const r=s.get(i);if(r){let l=!1;const a=r.propertyItem.types.filter(c=>!Zt.includes(c.type));if(a.length===1){const c=a[0];if(c instanceof We){l=!0;for(const h of o.propertyItem.types)c.items.push(h)}else c instanceof Se&&(l=!0,c.properties.push(o.propertyItem))}if(!l)for(const c of o.propertyItem.types)r.propertyItem.types.push(c)}}}return t||new oi("")}logValueInfos(e){for(let t=0;t<e.length;t++){const s=e[t];s.value=null;const o=t.toString().padStart(2,"0");console.info(o+") "+s.toString()+" parent: "+this.getParentPath(s.path))}}mergeValueInfos(e){const t=[];let s=e.length-1;t.push(e[s]);let o=e[s].path;for(let i=s-1;i>=0;i--){if(e[i].path===o){const r=e[i].propertyItem.types[0];e[s].propertyItem.types.some(l=>l.type===r.type)||e[s].propertyItem.types.push(r)}(i===0||e[i].path!==o)&&(s=i,t.push(e[i]),o=e[s].path)}for(const i of e){const r=this.getParentPath(i.path);if(r){const l=this.getParentPath(r);if(l){const a=this.getFirstValueInfoByPath(e,l);if(Array.isArray(a==null?void 0:a.value)){const c=(a==null?void 0:a.value.length)??0,h=this.countPath(e,i.path);c>h&&(i.propertyItem.types.some(d=>d.type===St)||i.propertyItem.types.push(new ys(i.property)))}}}}return t.reverse(),t}countPath(e,t){let s=0;for(const o of e)o.path===t&&s++;return s}getFirstValueInfoByPath(e,t){for(let s=e.length-1;s>=0;s--)if(e[s].path===t)return e[s];return null}extractValueInfos(e,t){const s=[],o=(i,r,l)=>{const a=new Or;let c=r.split("/").pop()||"";if(c==="[]"?c=l:c==="root"&&(c=t),a.property=c,a.value=i,a.path=r,a.propertyItem=this.createPropertyItem(i,a.property),s.push(a),i&&typeof i===xt&&!Array.isArray(i)){for(const h in i)if(i.hasOwnProperty(h)){const d=r?`${r}/${h}`:h;o(i[h],d,c)}}else Array.isArray(i)&&i.forEach((h,d)=>{const u=`${r}/[]`;o(h,u,c)})};return o(e,"root",t),s.sort((i,r)=>i.path.localeCompare(r.path))}createPropertyItem(e,t){return new ii(t,[this.createPropertyType(e,t)])}createPropertyType(e,t){return e===null?new Dr(t):e===void 0?new ys(t):typeof e===ti?new kr(t):typeof e===Ks&&!isNaN(e)?new Fr(t):typeof e===zs?new Lr(t):Array.isArray(e)?new We(t):typeof e===xt?new Se(t,Nr(t)):new ys(t)}}class ya{constructor(){this.orOperator="|",this.rootPropertyType=null,this.rootName="Root",this.renderTypeScriptInterfacesFifo=[],this.renderTypeScriptInterfacesDone=[]}renderTypeScriptInterfaces(e){"name"in e&&(this.rootName=e.name+""),this.rootPropertyType=e;const t=[];return this.rootPropertyType&&(this.renderTypeScriptInterfacesFifo=[],this.renderTypeScriptInterfacesDone=[],this.renderTypeScriptInterfacesRecursive(this.rootPropertyType,t),this.renderTypeScriptInterfacesFifoNext(t)),t}renderTypeScriptInterfacesFifoNext(e){var t;for(;(t=this.renderTypeScriptInterfacesFifo)!=null&&t.length;){const s=this.renderTypeScriptInterfacesFifo.shift();s&&this.renderTypeScriptInterfacesRecursive(s,e,s.propertyName)}}renderTypeScriptInterfacesRecursive(e=this.rootPropertyType,t=[],s=this.rootName){if(!e)return t;if(e instanceof We){for(const o of e.items)if(this.renderTypeScriptInterfacesRecursive(o,t,s),o instanceof Se){const i=o;i!==this.rootPropertyType&&this.renderTypeScriptInterfacesFifo.push(i)}}else if(e instanceof Se){const o=e,i=o.className;if(!this.renderTypeScriptInterfacesDone.includes(i)){this.renderTypeScriptInterfacesDone.push(i),t.push(`export interface ${i} {`);for(const r of o.properties){let l=this.propertyItem2InterfaceDateType(r);l==="[]"?l="any[]":l.startsWith("(")&&l.endsWith(")")&&(l=l.substring(1,l.length-1));const a=this.containsUndefinedPropertyType(r)?"?":"";t.push(" "+r.propertyName+a+": "+l+";");for(const c of r.types)if(c instanceof Se)c!==this.rootPropertyType&&this.renderTypeScriptInterfacesFifo.push(c);else if(c instanceof We)for(const h of c.items)h instanceof Se&&this.renderTypeScriptInterfacesFifo.push(h)}t.push("}"),t.push("")}}return t}propertyItem2InterfaceDateType(e){var s,o;if(((s=e.types)==null?void 0:s.length)===0)return"any";if(((o=e.types)==null?void 0:o.length)===1)return this.renderType(e.types[0],e);const t=e.types.map(i=>this.renderType(i,e)).filter(i=>i!==St).sort((i,r)=>Zt.includes(i)?100:Zt.includes(r)?-100:i.localeCompare(r)).join(this.orOperator);return t.includes(this.orOperator)?"("+t+")":t}renderType(e,t){if(e instanceof We){const s=e.items.map(o=>this.renderType(o,t)).join(this.orOperator);return s.includes(this.orOperator)?`(${s})[]`:`${s}[]`}return e instanceof Se?e.className:e.type}containsUndefinedPropertyType(e){for(const t of e.types)if(t.type===St)return!0;return!1}}class Qe{constructor(){this.alreadySet=!1}static getInstance(){return Qe.instance||(Qe.instance=new Qe),Qe.instance}setLicenseKey(e){if(e&&!this.alreadySet){const t=document.createElement("meta");t.content="license="+e,t.name="guiexperttable",document.getElementsByTagName("head")[0].appendChild(t),this.alreadySet=!0}}}function U(n){return n&&n.type==="TreeRow"}function Z(n){return n&&n.type==="AreaModelTree"}function ri(n){return!!n&&n.type==="CheckboxCellRenderer"}function be(n){return n&&n.type==="CheckboxColumnDef"}function O(n){return!!n&&n.type==="RowNumberColumnDef"}function _r(n){return!!n&&n.type==="AreaModelAggregateFooter"}function le(n){return!!n&&n.type==="RowGroup"}function To(n){return U(n)&&le(n.data)}function ne(n){return!!n&&n.kind==="AreaModelRowGroups"}function ot(n){return!!n&&n.type==="RowGroupColumnDef"}function vs(n){return!!n&&n.kind==="PivotTableModel"}function Io(n){return!!n&&n.kind==="AreaModelPivot"}function js(n){return!!n&&n.type==="PivotColumnDef"}class Qt{constructor(e=-1,t=-1,s=-1,o=-1,i,r,l,a=0,c=0,h=0,d=""){this.rowIndex=e,this.rowTop=t,this.columnIndex=s,this.columnLeft=o,this.areaIdent=i,this.sideIdent=r,this.originalEvent=l,this.clickCount=a,this.draggingX=c,this.draggingY=h,this.action=d}clone(){return new Qt(this.rowIndex,this.rowTop,this.columnIndex,this.columnLeft,this.areaIdent,this.sideIdent,this.originalEvent,this.clickCount,this.draggingX,this.draggingY,this.action)}}class Me{constructor(e=">",t="",s=[]){this.content=e,this.style=t,this.classes=s}}class ni{constructor(e=new Me(">","transform: rotate(90deg) translate(66%, -66%); transform-origin: 0 0;",["gt-table-tree-arrow-expanded"]),t=new Me(">","",["ge-table-tree-arrow-collapsed"]),s=new Me(">","color:transparent;",["gt-table-tree-arrow-hidden"]),o=new Me("↕","",["gt-table-tree-arrow-expanded-all"])){this.arrowExpanded=e,this.arrowCollapsed=t,this.arrowPlaceholder=s,this.arrowExpandCollapseAll=o}}class li{constructor(e=new Me("↑","",["ge-header-sorted-asc"]),t=new Me("↓","",["ge-header-sorted-desc"]),s=new Me("↑","color:transparent;",[])){this.iconAsc=e,this.iconDesc=t,this.iconPlaceholder=s}}const Vs=class Vs{constructor(e){this.domService=e,this.rtl=!1,this.startKey="left",this.endKey="right"}setDirection(e){this.rtl=e==="rtl",this.startKey=this.rtl?"right":"left",this.endKey=this.rtl?"left":"right"}getDirection(){return this.rtl?"rtl":"ltr"}toPhysicalStyleKey(e){if(this.rtl){if(e==="left")return"right";if(e==="right")return"left"}return e}getInlineStart(e){return parseFloat(e.style.getPropertyValue(this.startKey))||0}setStyle(e,t,s){return this.domService.setStyle(e,this.toPhysicalStyleKey(t),s),e}applyStyle(e,t){for(const s in t)this.domService.setStyle(e,this.toPhysicalStyleKey(s),t[s]);return e}applyDisplayNoneStyle(e){return this.domService.setStyle(e,"display","none"),e}applyDisplayBlockStyle(e){return this.domService.setStyle(e,"display","block"),e}applyStyleInPx(e,t){return Object.entries(t).forEach(([s,o])=>this.domService.setStyle(e,this.toPhysicalStyleKey(s),o+"px")),e}applyStylePosistionRelative(e){return this.domService.setStyle(e,"position","relative"),this.domService.setStyle(e,"overflow","clip"),e}applyStylePosistionAbsolute(e){return this.domService.setStyle(e,"position","absolute"),e}applyStyleFullSize(e){return this.domService.setStyle(e,"width","100%"),this.domService.setStyle(e,"height","100%"),e}applyStyleOverflowAuto(e="auto",t="auto",s){return this.domService.setStyle(s,"overflow-x",e),this.domService.setStyle(s,"overflow-y",t),s}applyStyleNoPadding(e){return this.domService.setStyle(e,"padding","0"),this.domService.setStyle(e,"margin","0"),this.domService.setStyle(e,"border","0"),e}appendRelativeChildDiv(e){const t=this.applyStylePosistionRelative(this.applyStyleFullSize(this.applyStyleNoPadding(this.domService.createElement("div"))));return this.domService.appendChild(e,t),this.applyStylePosistionAbsolute(e),{parent:e,child:t,cache:{}}}appendText(e,t){const s=this.domService.createText(t);return this.domService.appendChild(e,s),s}addClass(e,t){return e.includes(" ")?e.split(" ").forEach(s=>this.domService.addClass(t,s)):this.domService.addClass(t,e),t}removeClass(e,t){return e.includes(" ")?e.split(" ").forEach(s=>this.domService.removeClass(t,s)):this.domService.removeClass(t,e),t}addClasses(e,t){if(e)for(const s of e)this.domService.addClass(t,s);return t}setAttribute(e,t,s){return t&&s&&this.domService.setAttribute(e,t,s),e}removeAttribute(e,t){return this.domService.removeAttribute?this.domService.removeAttribute(e,t):e.removeAttribute(t),e}setAriaHidden(e){return this.domService.setAttribute(e,"aria-hidden","true"),e}createAreaDivWithClass(e,t,s,o){const i=this.domService.createElement("div");return this.addClass(e,i),this.domService.setAttribute(i,"data-area",s),this.domService.setAttribute(i,"data-side",o),this.domService.appendChild(t,i),i}createDivWithClass(e,t){const s=this.domService.createElement("div");return this.addClass(e,s),this.domService.appendChild(t,s),s}addRowDiv(e,t,s=-1,o,i,r=""){const l=t.index??-1,a=this.getDivOrCreateDiv(l,e);if(this.domService.addClass(a,"ge-table-row-div"),this.domService.addClass(a,`ge-table-row-div-${t.index}`),o==="body"&&i==="center"){const c=((t==null?void 0:t.index)??0)%2===0?"even":"odd";this.domService.addClass(a,`ge-table-row-${c}`)}if(this.domService.setStyle(a,"display","clip"),this.domService.setStyle(a,"position","absolute"),this.domService.setStyle(a,this.startKey,`${t.left}px`),this.domService.setStyle(a,"top",`${t.top}px`),this.domService.setStyle(a,"width",`${t.width}px`),this.domService.setStyle(a,"height",`${t.height}px`),this.domService.setAttribute(a,"data-row-index",`${s}`),this.domService.setAttribute(a,"data-area",`${o}`),r){const c=this.domService.createText(r);this.domService.appendChild(a,c)}return this.domService.appendChild(e.child,a),a}addColumnDiv(e){const{parent:t,geo:s,rowIndex:o=-1,columnIndex:i=-1,areaIdent:r,sideIdent:l,text:a="",treeArrow:c,tableOptions:h,checkedType:d=void 0,sortState:u,checkboxAriaLabel:f,firstDataColumnIndex:g=0}=e,p=h==null?void 0:h.treeOptions,m=h==null?void 0:h.showCheckboxWihoutExtraColumn,b=this.domService.createElement("div");this.domService.addClass(b,"ge-table-col-div"),m&&this.domService.addClass(b,"ge-with-checkbox"),this.domService.addClass(b,`ge-table-col-div-${s.index}`),this.domService.setAttribute(b,"data-col-index",`${s.index}`),this.domService.setAttribute(b,"data-row-index",`${o}`),this.domService.setAttribute(b,"data-area",`${r}`);const y=((s==null?void 0:s.index)??0)%2===0?"even":"odd";if(r==="body"&&l==="center"&&this.domService.addClass(b,`ge-table-column-${y}`),this.domService.setStyle(b,"display","clip"),this.domService.setStyle(b,"position","absolute"),this.domService.setStyle(b,this.startKey,`${s.left}px`),this.domService.setStyle(b,"top",`${s.top}px`),this.domService.setStyle(b,"width",`${s.width}px`),this.domService.setStyle(b,"height",`${s.height}px`),c&&c!=="none"&&(this.domService.addClass(b,"ge-table-col-tree"),this.addArrowDiv(b,c,p,o,i,r)),m&&i===g&&d&&this.addCheckboxToDiv(b,d,r,o,f),a){const C=c!=="none"&&i===g;this.addLabelDiv(b,a,C,o,i,r)}return u&&this.addSortedIcon(b,u,h==null?void 0:h.sortedOptions,i),this.domService.appendChild(t,b),b}addCheckboxToDiv(e,t,s,o,i){const r=this.domService.createElement("div"),l=this.domService.createElement("input");return this.domService.setAttribute(l,"type","checkbox"),this.domService.setAttribute(l,"data-area",`${s}`),this.domService.setAttribute(l,"data-row-index",`${o}`),this.domService.setAttribute(l,"data-input-type","checkbox"),this.domService.setAttribute(l,"tabindex","-1"),t==="full"&&(this.domService.setAttribute(l,"checked",""),l.checked=!0),t==="semi"&&(l.indeterminate=!0),this.domService.addClass(l,"ge-table-row-checkbox"),i&&this.domService.setAttribute(l,"aria-label",i),this.domService.appendChild(r,l),this.domService.setStyle(r,"display","inline"),this.domService.setStyle(r,"width","inherit"),this.domService.setAttribute(r,"data-row-index",`${o}`),this.domService.appendChild(e,r),r}addLabelDiv(e,t="",s=!1,o=-1,i=-1,r="body"){const l=this.domService.createElement("div");if(this.domService.addClass(l,"ge-table-label-div"),this.domService.setStyle(l,"position","relative"),this.domService.setStyle(l,"background","transparent"),this.domService.setStyle(l,"width","100%"),this.domService.setStyle(l,"height","100%"),this.domService.setAttribute(l,"data-row-index",`${o}`),this.domService.setAttribute(l,"data-col-index",`${i}`),this.domService.setAttribute(l,"data-area",`${r}`),t)if(s){const a=this.domService.createText(t);this.domService.appendChild(l,a)}else{const a=this.domService.createElement("div");this.domService.appendChild(l,a);const c=this.domService.createText(t);this.domService.addClass(a,"ge-table-label"),this.domService.appendChild(a,c),this.domService.setAttribute(a,"data-row-index",`${o}`),this.domService.setAttribute(a,"data-col-index",`${i}`),this.domService.setAttribute(a,"data-area",`${r}`)}return this.domService.appendChild(e,l),l}addSortedIcon(e,t="",s=new li,o=-1){const i=this.domService.createElement("div");this.domService.addClass(i,"ge-table-sorted-icon-div"),this.setAriaHidden(i),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"top","0"),this.domService.setStyle(i,this.endKey,"0"),this.domService.setStyle(i,"width","20px"),this.domService.setStyle(i,"background","transparent"),this.domService.setStyle(i,"cursor","pointer"),this.domService.setAttribute(i,"data-col-index",`${o}`),this.domService.setAttribute(i,"data-area","header");let r;t==="asc"?r=s.iconAsc:t==="desc"?r=s.iconDesc:r=s.iconPlaceholder;const l=r.content,a=this.domService.createText(l);this.domService.appendChild(i,a),r.style&&this.applyStyleString(i,r.style);for(const c of r.classes)this.domService.addClass(i,c);return this.domService.appendChild(e,i),i}addArrowDiv(e,t="none",s=new ni,o=-1,i=-1,r="body"){const l=this.domService.createElement("div");this.domService.addClass(l,"ge-table-tree-arrow-div"),this.setAriaHidden(l),this.domService.setStyle(l,"display","inline-block"),this.domService.setStyle(l,"position",""),this.domService.setStyle(l,"width","20px"),this.domService.setStyle(l,"background","transparent"),this.domService.setStyle(l,"cursor","pointer"),this.domService.setAttribute(l,"data-row-index",`${o}`),this.domService.setAttribute(l,"data-col-index",`${i}`),this.domService.setAttribute(l,"data-area",`${r}`);let a;t==="expanded"?a=s.arrowExpanded:t==="collapsed"?a=s.arrowCollapsed:a=s.arrowPlaceholder;const c=a.content,h=this.domService.createText(c);this.domService.appendChild(l,h),a.style&&this.applyStyleString(l,a.style);for(const d of a.classes)this.domService.addClass(l,d);return this.domService.appendChild(e,l),l}addColumnBorderDivs(e,t,s,o,i){if(e.verticalBorderVisible){const r=`ge-table-${o}-${i}-vertical-border`;this.addVerticalBorder(s,t,r)}if(e.horizontalBorderVisible){const r=`ge-table-${o}-${i}-horizontal-border`;this.addHorizontalBorder(s,t,r)}return t}addHorizontalBorder(e,t,s="ge-table-body-center-horizontal-border"){const o=this.domService.createElement("div");return this.domService.addClass(o,s),this.setAriaHidden(o),this.domService.setStyle(o,"display","clip"),this.domService.setStyle(o,"position","absolute"),this.domService.setStyle(o,this.startKey,`${e.left}px`),this.domService.setStyle(o,"top",`${e.top}px`),this.domService.setStyle(o,"width",`${e.width}px`),this.domService.setStyle(o,"height","1px"),this.domService.appendChild(t,o),o}addFocusBorderDivs(e,t,s){t={...t,width:t.width+1,height:t.height+1};const o=Vs.focusBorderWidthInPx,i=[[t.left,t.top,o,t.height],[t.left+t.width-o,t.top,o,t.height],[t.left,t.top,t.width,o],[t.left,t.top+t.height-o,t.width,o]];for(const[r,l,a,c]of i){const h=this.domService.createElement("div");this.domService.addClass(h,"ge-table-focus-border"),this.setAriaHidden(h),this.domService.setStyle(h,"display","clip"),this.domService.setStyle(h,"position","absolute"),this.domService.setStyle(h,this.startKey,`${r}px`),this.domService.setStyle(h,"top",`${l}px`),this.domService.setStyle(h,"width",`${a}px`),this.domService.setStyle(h,"height",`${c}px`),this.domService.setStyle(h,"z-index","9999"),this.applyStyle(h,s),this.domService.appendChild(e,h)}return e}addVerticalBorder(e,t,s="ge-table-body-center-vertical-border"){const o=this.domService.createElement("div");return this.domService.addClass(o,s),this.setAriaHidden(o),this.domService.setStyle(o,"display","clip"),this.domService.setStyle(o,"position","absolute"),this.domService.setStyle(o,this.startKey,`${e.left}px`),this.domService.setStyle(o,"top",`${e.top}px`),this.domService.setStyle(o,"width","1px"),this.domService.setStyle(o,"height",`${e.height}px`),this.domService.appendChild(t,o),o}addDiv(e,t,s=""){const o=this.domService.createElement("div");return s&&this.domService.addClass(o,s),this.setAriaHidden(o),this.domService.setStyle(o,"display","clip"),this.domService.setStyle(o,"position","absolute"),this.domService.setStyle(o,this.startKey,`${t.left}px`),this.domService.setStyle(o,"top",`${t.top}px`),this.domService.setStyle(o,"width",`${t.width}px`),this.domService.setStyle(o,"height",`${t.height}px`),this.domService.appendChild(e,o),o}applyStyleString(e,t){const s=t.split(";").map(o=>o.trim()).filter(o=>o);for(const o of s){const[i,r]=o.split(":");this.domService.setStyle(e,i.trim(),r.trim())}}getDivOrCreateDiv(e,t){let s=t.cache[e];return s?(s.innerText="",s):(s=this.domService.createElement("div"),t.cache[e]=s,s)}};Vs.focusBorderWidthInPx=2;let Rs=Vs;const vt=n=>n==="header"?"header":n==="footer"?"footer":"body";class As{constructor(e,t){if(this.rowIdx=-1,this.colIdx=-1,this.action=null,this.inputType=null,this.className="",e!==null&&(e instanceof HTMLDivElement||e instanceof HTMLSpanElement||e instanceof HTMLInputElement)){this.className=e.className,this.action=e.getAttribute("data-ge-action"),this.inputType=e.getAttribute("data-input-type"),this.rowIdx=Number(e.getAttribute("data-row-index")),this.colIdx=Number(e.getAttribute("data-col-index"));const s=e.getAttribute("data-area");if(s&&(this.areaIdent=vt(s),this.areaModel=t.tableModel.getAreaModel(this.areaIdent),this.row=this.areaModel.getRowByIndex(this.rowIdx)),e instanceof HTMLInputElement){const o=e;this.value=o.value}}}}class Br{constructor(e){this.tableScope=e,this.doubleClickDelay=500,this.clickMoveTolerance=4,this.lastClickedCellKey="",this.nativeClickCount=0,this.nativeDblClickCount=0,this.mouseDown=!1,this.repaintAfterMouseUp=!1,this.dragging=!1,this.dragGeneration=0,this.lastClicked=0;const t=this.tableScope.listenerAbortController.signal;this.tableScope.hostElement.addEventListener("click",this.onHostElementClicked.bind(this),{signal:t}),this.tableScope.hostElement.addEventListener("dblclick",this.onHostElementDblClicked.bind(this),{signal:t}),this.tableScope.hostElement.addEventListener("mousedown",this.onMouseDown.bind(this),{signal:t}),this.tableScope.hostElement.addEventListener("mousemove",this.onMouseMove.bind(this),{signal:t}),this.tableScope.hostElement.addEventListener("mouseup",this.onMouseUp.bind(this),{signal:t}),this.tableScope.hostElement.addEventListener("contextmenu",this.onContextmenu.bind(this),{signal:t}),t.addEventListener("abort",()=>clearTimeout(this.lostClickTimer)),this.tableScope.hostElement._MouseHandler="true",this.tableScope.scrollViewport.addEventListener("scroll",()=>this.tableScope.onViewportScroll(),{signal:t}),this.tableScope.scrollViewport.addEventListener("wheel",this.tableScope.onWheel.bind(this.tableScope),{passive:!1,signal:t}),[window,this.tableScope.hostElement].forEach(s=>s.addEventListener("resize",this.tableScope.adjustContainersAndRows.bind(this.tableScope),{signal:t}))}onContextmenu(e){if(this.isBlocked(e)||!(e instanceof MouseEvent))return;this.pressedCell=void 0,this.mouseEvent=e;const t=this.tableScope.createGeMouseEvent(this.mouseEvent);this.tableScope.contextmenu(t)}onHostElementClicked(e){this.nativeClickCount++,!this.isBlocked(e)&&this.handleClick(e,this.tableScope.getMouseEventTarget(e))}handleClick(e,t,s){var c;const o=Date.now(),i=s?this.toCellKey(s):this.getCellKey(t),r=e.detail>=2||e.detail===0&&o-this.lastClicked<this.doubleClickDelay&&i===this.lastClickedCellKey;this.lastClicked=o,this.lastClickedCellKey=i;const l=new As(t,this.tableScope);s&&this.applyCell(l,s);const a=s?this.createCellEvent(e,s):void 0;if(r&&(this.reportedDoubleClick={time:o,cellKey:i}),r&&!this.isClickAction(l)){this.publishGeMouseEvent(e,2,a,t);return}if(l.action==="toggleExpandCollapseAll")this.tableScope.toggleExpandCollapseAll(!this.tableScope.allExpanded),e.preventDefault(),e.stopPropagation();else if(l.action==="toggle-detail")this.tableScope.toggleDetail(l.rowIdx,"mouse"),e.preventDefault(),e.stopPropagation();else if(l.action==="toggleHeaderGroup")this.tableScope.toggleHeaderGroup(l),e.preventDefault(),e.stopPropagation();else if(l.inputType==="checkbox"&&l.areaIdent)this.tableScope.toggleRowCheckbox(l.rowIdx,l.colIdx,l.areaIdent),e.preventDefault(),e.stopPropagation();else if(U(l.row)&&l.areaModel){const h=l.colIdx===this.getArrowColumnIndex()&&e.altKey,d=l.className.includes("ge-table-tree-arrow-div");if(h||d){e.preventDefault(),e.stopPropagation();const u=l.row;this.tableScope.setTreeRowExpanded(u,!u.expanded)}}l.areaIdent==="body"&&((c=this.tableScope.focusModel())==null||c.setFocus(l.rowIdx,l.colIdx)),this.publishGeMouseEvent(e,r?2:1,a,t)}toCellKey(e){return e.areaIdent+":"+e.rowIdx+":"+e.colIdx}applyCell(e,t){e.areaIdent=t.areaIdent,e.areaModel=this.tableScope.tableModel.getAreaModel(t.areaIdent),e.rowIdx=t.rowIdx,e.colIdx=t.colIdx,e.row=e.areaModel.getRowByIndex(t.rowIdx)}createCellEvent(e,t){return this.tableScope.createGeMouseEventForCell(e,{areaIdent:t.areaIdent,sideIdent:t.sideIdent,rowIndex:t.rowIdx,columnIndex:t.colIdx,action:t.action})}getCellKey(e){var s;const t=e instanceof Element?e:null;return(s=t==null?void 0:t.closest)!=null&&s.call(t,"[data-col-index]")?["data-area","data-row-index","data-col-index"].map(o=>{var i;return((i=t.closest("["+o+"]"))==null?void 0:i.getAttribute(o))??""}).join(":"):""}isClickAction(e){return e.action==="toggleExpandCollapseAll"||e.action==="toggleHeaderGroup"||e.action==="toggle-detail"||e.inputType==="checkbox"&&!!e.areaIdent||e.className.includes("ge-table-tree-arrow-div")}onHostElementDblClicked(e){this.nativeDblClickCount++,!this.isBlocked(e)&&this.handleDblClick(e,this.tableScope.getMouseEventTarget(e))}handleDblClick(e,t,s){var a,c,h;this.lastClicked=Date.now();const o=s?this.createCellEvent(e,s):this.tableScope.createGeMouseEvent(e),i=new As(t,this.tableScope);if(t instanceof HTMLElement&&!this.isClickAction(i)){const d=t.closest("[data-col-index]")??t,u=s?s.areaIdent:((a=d.closest("[data-area]"))==null?void 0:a.getAttribute("data-area"))??null,f=vt(u),g=s?s.rowIdx:Number((c=d.closest("[data-row-index]"))==null?void 0:c.getAttribute("data-row-index")),p=s?s.colIdx:Number(d.getAttribute("data-col-index")),m=this.tableScope.tableModel.getAreaModel(f);if(u&&f==="header"){const b=(h=m.isColumnLetterRow)==null?void 0:h.call(m,g);this.tableScope.tableModel.isSortable(p)&&!b&&(this.tableScope.clearSelection(),this.tableScope.onHeaderDblClicked(e,g,p))}else if(s||d.getAttribute("data-row-index")){const b=m.getRowByIndex(g);if(u&&f==="body"&&m.isEditable(g,p)&&this.tableScope.startEditing(g,p,"edit"),U(b)&&p===this.getArrowColumnIndex()){e.preventDefault(),e.stopPropagation();const y=b;this.tableScope.setTreeRowExpanded(y,!y.expanded)}}}const r=this.reportedDoubleClick,l=s?this.toCellKey(s):this.getCellKey(t);(!r||Date.now()-r.time>this.doubleClickDelay||r.cellKey!==l)&&this.publishGeMouseEvent(e,2,o),this.reportedDoubleClick=void 0}publishGeMouseEvent(e,t,s,o=e.target){var r;this.mouseEvent=e,this.geMouseEventOld=(r=this.geMouseEvent)==null?void 0:r.clone(),this.geMouseEvent=s??this.tableScope.createGeMouseEvent(e),this.geMouseEvent&&(this.geMouseEvent.clickCount=t);const i=this.tableScope.onMouseClicked(this.geMouseEvent,this.geMouseEventOld);this.tableScope.publishGeMouseEvent(this.geMouseEvent),i&&!this.isInteractiveCellElement(o)&&this.tableScope.debounceRepaint()}isInteractiveCellElement(e){const t=e instanceof Element?e:null,s=t==null?void 0:t.closest('input, select, textarea, button, a[href], [contenteditable]:not([contenteditable="false"])');return!!s&&this.tableScope.hostElement.contains(s)}getArrowColumnIndex(){const e=this.tableScope.tableModel.isRowCheckboxVisible();return this.tableScope.getFirstDataColumnIndex()+(e?1:0)}onMouseDown(e){if(!this.isBlocked(e)&&(this.tableScope.cancelPendingRepaint()&&(this.repaintAfterMouseUp=!0),this.pressedCell=e.button===0?this.readPressedCell(e):void 0,!this.dragging)){this.mouseEvent=e,this.startMouseEvent=this.tableScope.createGeMouseEvent(this.mouseEvent),this.flushDraggingEnd(),this.tableScope.onMouseDown(this.startMouseEvent),this.mouseDown=!0;const t=this.tableScope.listenerAbortController.signal;document.addEventListener("mouseup",s=>this.onDocumentMouseUp(s),{once:!0,signal:t})}}onDocumentMouseUp(e){this.mouseDown&&!this.tableScope.hostElement.contains(e.target)&&this.onMouseUp(e)}adjustForRowChanges(e){const t=this.startMouseEvent;this.mouseDown&&t&&t.areaIdent==="body"&&t.rowIndex>=0&&(t.rowIndex=Math.max(0,e.mapIndexOrNext(t.rowIndex)))}onMouseMove(e){var t,s,o,i;if(!this.mouseDown&&((s=(t=this.tableScope).isEventInDetail)!=null&&s.call(t,e))){(i=(o=this.tableScope).hideHover)==null||i.call(o);return}if(!(!this.mouseDown&&this.isBlocked(e)))if(this.mouseEvent=e,this.mouseDown){this.dragging||(this.dragging=!0,this.tableScope.setDragging(!0));const r=this.dragGeneration;requestAnimationFrame(()=>{r===this.dragGeneration&&this.mouseDraggingOnFrame()})}else requestAnimationFrame(this.mouseMoveOnFrame.bind(this))}onMouseUp(e){var s,o;const t=this.pressedCell;if(this.pressedCell=void 0,!(!this.mouseDown&&((o=(s=this.tableScope).isEventInDetail)!=null&&o.call(s,e)))){if(this.mouseEvent=e,t&&e.button===0&&this.checkLostClick(t,e),this.repaintAfterMouseUp&&(this.repaintAfterMouseUp=!1,this.tableScope.debounceRepaint()),this.dragging){const i={evt:e,start:this.startMouseEvent,frameId:0};i.frameId=requestAnimationFrame(()=>this.flushDraggingEnd()),this.pendingDraggingEnd=i}this.mouseDown=!1,this.dragging=!1,this.tableScope.setDragging(!1)}}readPressedCell(e){var f,g,p;const t=this.tableScope.getMouseEventTarget(e),s=t instanceof Element?t:null,o=(f=s==null?void 0:s.closest)==null?void 0:f.call(s,"[data-col-index]"),i=(g=o==null?void 0:o.closest("[data-area]"))==null?void 0:g.getAttribute("data-area"),r=(p=o==null?void 0:o.closest("[data-row-index]"))==null?void 0:p.getAttribute("data-row-index");if(!s||!o||!i||r===null||r===void 0)return;const l=this.tableScope.createGeMouseEvent(e),a=Number(r),c=Number(o.getAttribute("data-col-index")),h=vt(i);let d,u=!1;if(h==="body"){const m=this.tableScope.tableModel.getBodyModel();d=this.rowAt(m,a),u=typeof d=="object"&&d!==null&&this.rowAt(m,a)===d}return{target:s,areaIdent:h,sideIdent:l.sideIdent,rowIdx:a,colIdx:c,action:l.action,row:d,stableRow:u,clientX:e.clientX,clientY:e.clientY}}checkLostClick(e,t){if(e.target.isConnected)return;const s=t.clientX-e.clientX,o=t.clientY-e.clientY;if(s*s+o*o>this.clickMoveTolerance*this.clickMoveTolerance)return;const i=this.nativeClickCount,r=this.nativeDblClickCount;clearTimeout(this.lostClickTimer),this.lostClickTimer=setTimeout(()=>{if(this.lostClickTimer=void 0,this.nativeClickCount!==i||this.tableScope.isDestroyed()||this.isBlocked(t))return;const l=this.resolveRowIndex(e);if(l<0)return;const a={areaIdent:e.areaIdent,sideIdent:e.sideIdent,rowIdx:l,colIdx:e.colIdx,action:e.action};this.handleClick(t,e.target,a),t.detail===2&&this.nativeDblClickCount===r&&this.handleDblClick(t,e.target,a)},0)}resolveRowIndex(e){if(e.areaIdent!=="body"||!e.stableRow)return e.rowIdx;const t=this.tableScope.tableModel.getBodyModel();if(this.rowAt(t,e.rowIdx)===e.row)return e.rowIdx;const s=t.getRowCount();for(let o=1;o<s;o++){const i=e.rowIdx-o,r=e.rowIdx+o;if(i<0&&r>=s)break;if(i>=0&&this.rowAt(t,i)===e.row)return i;if(r<s&&this.rowAt(t,r)===e.row)return r}return-1}rowAt(e,t){try{return e.getRowByIndex(t)}catch{return}}mouseDraggingOnFrame(){var e;if(this.mouseEvent){const t=this.tableScope.createGeMouseEvent(this.mouseEvent);(e=this.startMouseEvent)!=null&&e.originalEvent&&(t.draggingX=this.mouseEvent.clientX-this.startMouseEvent.originalEvent.clientX,t.draggingY=this.mouseEvent.clientY-this.startMouseEvent.originalEvent.clientY),this.tableScope.mouseDraggingOnFrame(t,this.startMouseEvent)}}flushDraggingEnd(){var s;const e=this.pendingDraggingEnd;if(!e)return;this.pendingDraggingEnd=void 0,cancelAnimationFrame(e.frameId),this.dragGeneration++;const t=this.tableScope.createGeMouseEvent(e.evt);(s=e.start)!=null&&s.originalEvent&&(t.draggingX=e.evt.clientX-e.start.originalEvent.clientX,t.draggingY=e.evt.clientY-e.start.originalEvent.clientY),this.tableScope.mouseDraggingEndOnFrame(t)}mouseMoveOnFrame(){if(this.mouseEvent){const e=this.tableScope.createGeMouseEvent(this.mouseEvent);this.tableScope.mouseMove(e)}}isButtonDown(){return this.mouseDown}isBlocked(e){var t,s,o;return(((t=this.tableScope.tableOverlay)==null?void 0:t.isEventBlocked(e))??!1)||!!((o=(s=this.tableScope).isEventInDetail)!=null&&o.call(s,e))}}const $r=()=>!1;function Hr(n){return n.editable===void 0||n.editable===$r}function ai(n){return typeof n=="number"&&!Number.isNaN(n)}function Ca(n){if(ai(n))return n;if(n instanceof Date){const e=n.getTime();return Number.isNaN(e)?void 0:e}}function ci(n,e){const t=n.sum,s=t+e;Number.isFinite(s)&&(n.compensation+=Math.abs(t)>=Math.abs(e)?t-s+e:e-s+t),n.sum=s}function Gr(n){return Number.isFinite(n.sum)?n.sum+n.compensation:n.sum}function Wr(n,e){ci(n,e.sum),n.compensation+=e.compensation}const Sa={name:"sum",init:()=>({sum:0,compensation:0}),add:(n,e)=>(ai(e)&&ci(n,e),n),merge:(n,e)=>(Wr(n,e),n),result:n=>Gr(n)},xa={name:"count",init:()=>0,add:n=>n+1,merge:(n,e)=>n+e,result:n=>n},va={name:"avg",init:()=>({sum:0,compensation:0,count:0}),add:(n,e)=>(ai(e)&&(ci(n,e),n.count++),n),merge:(n,e)=>(Wr(n,e),n.count+=e.count,n),result:n=>n.count?Gr(n)/n.count:void 0};function $i(n,e){return{name:n,init:()=>({has:!1,value:void 0,key:0}),add:(t,s)=>{const o=Ca(s);return o!==void 0&&(!t.has||e(o,t.key))&&(t.has=!0,t.value=s,t.key=o),t},merge:(t,s)=>(s.has&&(!t.has||e(s.key,t.key))&&(t.has=!0,t.value=s.value,t.key=s.key),t),result:t=>t.has?t.value:void 0}}const Ra={name:"countDistinct",init:()=>({values:new Set,dates:new Set}),add:(n,e)=>(e instanceof Date?n.dates.add(e.getTime()):e!=null&&n.values.add(e),n),merge:(n,e)=>(e.values.forEach(t=>n.values.add(t)),e.dates.forEach(t=>n.dates.add(t)),n),result:n=>n.values.size+n.dates.size},Aa={name:"first",init:()=>({has:!1,value:void 0}),add:(n,e)=>(n.has||(n.has=!0,n.value=e),n),merge:(n,e)=>(!n.has&&e.has&&(n.has=!0,n.value=e.value),n),result:n=>n.value},Ea={name:"last",init:()=>({has:!1,value:void 0}),add:(n,e)=>(n.has=!0,n.value=e,n),merge:(n,e)=>(e.has&&(n.has=!0,n.value=e.value),n),result:n=>n.value},Oe=Object.freeze({sum:Sa,count:xa,avg:va,min:$i("min",(n,e)=>n<e),max:$i("max",(n,e)=>n>e),countDistinct:Ra,first:Aa,last:Ea});function Xs(n){if(typeof n!="string")return n;const e=Oe[n];if(!e)throw new Error(`Unknown aggregator "${n}" – use one of: ${Object.keys(Oe).join(", ")}, or an own AggregatorIf.`);return e}function as(n){if(typeof n=="function")return n;const e=n.split(".");return e.length===1?t=>t==null?void 0:t[n]:t=>{let s=t;for(const o of e){if(s==null)return;s=s[o]}return s}}function cs(n,e){const t=typeof e=="string"||!("aggregator"in e)?{aggregator:e}:e,s=Xs(t.aggregator),o=t.value??n;return{key:n,aggregator:s,value:o,getValue:s===Oe.count?void 0:as(o),format:t.format}}function Ys(n,e){const t=e.map(o=>o.aggregator.init()),s=e.length;for(let o=0;o<n.length;o++){const i=n[o];for(let r=0;r<s;r++){const l=e[r];t[r]=l.aggregator.add(t[r],l.getValue?l.getValue(i):i)}}return t}function Ma(n,e){const t=e.map(o=>o.aggregator.init()),s=e.length;for(let o=0;o<n;o++)for(let i=0;i<s;i++){const r=e[i];t[i]=r.aggregator.add(t[i],r.getValue?r.getValue(o):o)}return t}function Ta(n,e,t){const s=cs("",{aggregator:t,value:e}),[o]=Ys(n,[s]);return s.aggregator.result(o)}function Ia(n,e){const t=Object.keys(e).map(i=>cs(i,e[i])),s=Ys(n,t),o={};return t.forEach((i,r)=>o[i.key]=i.aggregator.result(s[r])),o}const Da=new Intl.NumberFormat("en-US",{maximumFractionDigits:2});function kt(n){return n==null?"":typeof n=="number"?Number.isFinite(n)?Da.format(n):String(n):n instanceof Date?Number.isNaN(n.getTime())?"":n.toLocaleDateString("en-US"):String(n)}const ka=new Set(["percentOfColumnTotal","percentOfGrandTotal","percentOfParentTotal","percentOfRowTotal"]),Hi=new Map,Fa=new Intl.NumberFormat("en-US",{maximumFractionDigits:0});function Ft(n){if(!n)return;const e=typeof n=="string"?{mode:n}:n;return Ur.includes(e.mode)?e:void 0}const Ur=Object.freeze(["percentOfColumnTotal","percentOfGrandTotal","percentOfParentTotal","percentOfRowTotal","differenceFromPrevious","runningTotal","rank"]);function hi(n){return!!n&&ka.has(n)}function Js(n,e){const t=Ft(e);if(typeof n!="number"||Number.isNaN(n)||!t)return n==null?"":`${n}`;if(t.format)return`${t.format(n)??""}`;if(hi(t.mode)){const s=Gi(t.fractionDigits??1);let o=Hi.get(s);return o||(o=new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:s,maximumFractionDigits:s}),Hi.set(s,o)),o.format(n)}if(t.mode==="rank")return Fa.format(n);if(t.fractionDigits!==void 0){const s=Gi(t.fractionDigits);return new Intl.NumberFormat("en-US",{minimumFractionDigits:s,maximumFractionDigits:s}).format(n)}return kt(n)}function Gi(n){return Math.min(10,Math.max(0,Math.trunc(Number(n)||0)))}function at(n){return typeof n=="number"&&!Number.isNaN(n)}function qs(n){const e=Oe.sum;let t=e.init();for(let s=0;s<n.length;s++)t=e.add(t,n[s]);return e.result(t)??0}function di(n,e){const t=n.length,s=new Array(t);switch(e){case"percentOfColumnTotal":case"percentOfGrandTotal":case"percentOfParentTotal":{const o=qs(n);for(let i=0;i<t;i++)s[i]=La(n[i],o);return s}case"runningTotal":{const o=Oe.sum;let i=o.init();for(let r=0;r<t;r++){const l=n[r];i=o.add(i,l),s[r]=at(l)?o.result(i):void 0}return s}case"differenceFromPrevious":for(let o=0;o<t;o++){const i=n[o],r=o>0?n[o-1]:void 0;s[o]=at(i)&&at(r)?i-r:void 0}return s;case"rank":{const o=[];for(let r=0;r<t;r++)at(n[r])&&o.push(r);o.sort((r,l)=>n[l]-n[r]);let i=0;for(let r=0;r<o.length;r++)(r===0||n[o[r]]!==n[o[r-1]])&&(i=r+1),s[o[r]]=i;return s}default:for(let o=0;o<t;o++)s[o]=at(n[o])?n[o]:void 0;return s}}function La(n,e){return at(n)&&e!==0?n/e:void 0}class I{constructor(e,t,s){this.code=e,this.message=t,this.position=s,this.type="FormulaError"}toString(){return this.code}}function w(n){return!!n&&typeof n=="object"&&n.type==="FormulaError"}class Oa{constructor(e){this.owner=e,this.defsLength=-1,this.computing=new Map,this.contexts=new Map,this.aggregates=new Map,this.aggSignal=void 0,this.aggLength=-1}invalidate(){this.getters=void 0,this.showValuesAs=void 0,this.properties=void 0,this.aggregates.clear()}getter(e){if(e!==void 0)return this.lookup().get(e)}hasGetters(){return this.lookup().size>0}isCalculated(e){return this.lookup().has(e)}hasColumn(e){return this.lookup(),this.properties.has(e)}getShowValuesAs(e){if(e!==void 0)return this.lookup(),this.showValuesAs.get(e)}hasShowValuesAs(){return this.lookup(),this.showValuesAs.size>0}get(e,t){const s=this.lookup().get(t);if(!s)return this.owner.readPath(e,t);if(e!=null)return this.call(s,e,t)}aggregate(e,t){var c;if((c=this.computing.get(e))!=null&&c.size)return new I("#CIRC!",`Circular reference: the column "${e}" uses its own aggregate`);const s=this.owner.getAggregationSource();(s.signal!==this.aggSignal||s.length!==this.aggLength)&&(this.aggregates.clear(),this.aggSignal=s.signal,this.aggLength=s.length);const o=Xs(t),i=`${o.name}\0${e}`;if(this.aggregates.has(i))return this.aggregates.get(i);const r=s.rows();let l=o.init(),a;for(let h=0;h<r.length;h++){const d=this.get(r[h],e);if(w(d)&&d.code==="#CIRC!"){a=d;break}l=o.add(l,d)}return a===void 0&&(a=o.result(l)),this.aggregates.set(i,a),a}context(e){let t=this.contexts.get(e);return t||(t={property:e,getValue:(s,o)=>this.get(s,o),hasColumn:s=>this.hasColumn(s),isCalculated:s=>{var o,i;return this.isCalculated(s)||!!((i=(o=this.owner).isSheetFormula)!=null&&i.call(o,s))},aggregate:(s,o)=>this.aggregate(s,o)},this.contexts.set(e,t)),t}call(e,t,s){let o=this.computing.get(s);if(o!=null&&o.has(t))return new I("#CIRC!",`Circular reference: the column "${s}" depends on itself`);o||(o=new Set,this.computing.set(s,o)),o.add(t);try{return e(t,this.context(s))}catch(i){return new I("#VALUE!",`valueGetter of "${s}": ${i instanceof Error?i.message.slice(0,200):"failed"}`)}finally{o.delete(t)}}lookup(){const e=this.owner.getColumnDefsForValues()??[];if(this.getters&&this.defsLength===e.length)return this.getters;const t=new Map,s=new Map,o=new Set;for(const i of e){if(!i)continue;o.add(i.property),typeof i.valueGetter=="function"&&t.set(i.property,i.valueGetter);const r=Ft(i.showValuesAs);r&&s.set(i.property,r)}return this.getters=t,this.showValuesAs=s,this.properties=o,this.defsLength=e.length,t}}class Lt{constructor(){this.type="AggregateCellRenderer"}render(e,t,s,o,i,r,l){const a=i.getTextValueAt(t,s);if(!a)return;const c=l.createElement("div");l.addClass(c,"ge-table-label-div");const h=l.createElement("div");l.addClass(h,"ge-table-label"),l.setAttribute(h,"data-row-index",`${t}`),l.setAttribute(h,"data-col-index",`${s}`),l.setAttribute(h,"data-area",o),l.appendChild(h,l.createText(a)),l.appendChild(c,h),l.appendChild(e,c)}}class hs{constructor(e,t=[],s=-1){this.areaIdent=e,this.columnDefs=t,this.defaultRowHeight=s,this.rowSelectionModel=void 0,this.yPositions=[],this.defaultEditable=!1,this.cellRenderers=t.map(o=>o.rendererMap[e])}getTextValueAt(e,t){return""+this.getValueAt(e,t)}getTooltipAt(e,t){var s;if((s=this.sheetCells)!=null&&s.isFormulaColumnIndex(t)){const o=this.getValueAt(e,t);if(w(o))return o.message}return""}getCellRenderer(e,t){if(t<this.cellRenderers.length)return this.cellRenderers[t]}getColspanAt(e,t){return 0}getCustomClassesAt(e,t){var s;return(s=this.sheetCells)!=null&&s.isFormulaColumnIndex(t)&&w(this.getValueAt(e,t))?["ge-table-cell-error"]:[]}getCustomStyleAt(e,t){}getRowspanAt(e,t){return 0}getRowByIndex(e){}isRowCheckable(e){return!0}isRowChecked(e){var s;const t=this.getRowByIndex(e);return(s=this.rowSelectionModel)==null?void 0:s.isRowChecked(t)}setRowChecked(e,t){if(this.rowSelectionModel){const s=this.getRowByIndex(e);this.rowSelectionModel.checkRow(s,t)}}getMaxColspan(){return 31}getMaxRowspan(){return 31}getYPosByRowIndex(e){var o;const t=(o=this.getConstantRowHeight)==null?void 0:o.call(this);if(t!==void 0&&t>0)return t*e;let s=0;for(let i=0;i<e;i++)s+=this.getRowHeight(i);return s}init(){!this.yPositions.length&&this.getRowCount()!==void 0&&this.defaultRowHeight===-1&&this.calcYPositions()}isFilterable(){return this.areaIdent==="body"}doSort(e){return!1}sort(e){}isEditable(e,t){var o,i;const s=(o=this.columnDefs)==null?void 0:o[t];return this.areaIdent==="body"&&(s!=null&&s.valueGetter)&&!s.valueSetter?!1:this.defaultEditable&&this.areaIdent==="body"&&s&&Hr(s)?!be(s)&&!O(s)&&!ot(s):((i=s==null?void 0:s.editable)==null?void 0:i.call(s))??!1}setValue(e,t,s){var a;const o=(a=this.columnDefs[t])==null?void 0:a.editInputPipe;o&&(s=o(s,e,t));const i=this.getRowByIndex(e),r=this.columnDefs[t];if(this.areaIdent==="body"&&(r!=null&&r.valueGetter))return this.setCalculatedValue(i,r,s);const l=this.columnDefs[t].property;return l.includes(".")?this.setPropertyValue(i,l.split("."),s):(i[l]=s,!0)}isSelectable(e,t){return!0}changeColumnOrder(e,t){this.arrayMove(this.cellRenderers,e,t)}setPropertyValue(e,t,s){const o=t.shift();if(o){const i=e[o];return i&&t.length?this.setPropertyValue(i,t,s):(e[o]=s,!0)}return!1}arrayMove(e,t,s){const o=e.splice(t,1)[0];return e.splice(s,0,o),e}calcYPositions(){const e=this.getRowCount();this.yPositions=new Array(e+1),this.yPositions[0]=0;for(let t=0;t<e;t++)this.yPositions[t+1]=this.getRowHeight(t)+this.yPositions[t]}isCalculatedProperty(e){var t;return this.getColumnValues().isCalculated(e)||!!((t=this.sheetCells)!=null&&t.isFormulaProperty(e))}getRowValue(e,t){U(e)&&(e=e.data);const s=this.getColumnValues().get(e,t);return this.sheetCells&&typeof s=="string"?this.sheetCells.valueOfProperty(e,t,s):s}hasDerivedColumns(){const e=this.getColumnValues();return e.hasGetters()||e.hasShowValuesAs()}isDerivedProperty(e){const t=this.getColumnValues();return t.isCalculated(e)||!!t.getShowValuesAs(e)}getColumnValues(){return this.columnValuesInstance??(this.columnValuesInstance=new Oa({getColumnDefsForValues:()=>this.areaIdent==="body"?this.columnDefs:[],readPath:(e,t)=>{const s=this.readPropertyPath(e,t);return this.sheetCells&&typeof s=="string"?this.sheetCells.valueOfProperty(e,t,s):s},getAggregationSource:()=>this.getAggregationSourceForValues(),isSheetFormula:e=>{var t;return!!((t=this.sheetCells)!=null&&t.isFormulaProperty(e))}}))}invalidateColumnValues(){var e;(e=this.columnValuesInstance)==null||e.invalidate()}readPropertyPath(e,t){if(e==null||!t)return;let s=e;for(const o of t.split(".")){if(s==null)return;s=s[o]}return s}getAggregationSourceForValues(){const e=this.getRowCount();return{signal:void 0,length:e,rows:()=>Array.from({length:e},(t,s)=>this.getRowByIndex(s))}}setCalculatedValue(e,t,s){return!t.valueSetter||e===void 0||e===null?!1:(U(e)&&(e=e.data),t.valueSetter(e,s)!==!1)}getCalculatedText(e,t){if(e===void 0)return;const s=this.getColumnValues(),o=s.getShowValuesAs(e),i=s.isCalculated(e);if(i&&w(t))return t.code;if(o)return Js(t,o);if(i)return t==null?"":`${t}`}getCalculatedRenderer(e){if(e!==void 0&&this.getColumnValues().getShowValuesAs(e))return this.calcTextRenderer??(this.calcTextRenderer=new Lt)}addCalculatedClasses(e,t,s){return t!==void 0&&this.getColumnValues().isCalculated(t)&&w(s())?[...e,"ge-table-cell-error"]:e}}class ui{genericSortComparator(e,t,s){if(typeof e=="number"&&typeof t=="number")return s*(e-t);if(typeof e=="string"&&typeof t=="string")return s*e.localeCompare(t);if(typeof e=="boolean"&&typeof t=="boolean")return s*((e?-1:1)-(t?-1:1));if(e instanceof Date&&t instanceof Date)return s*(e.getTime()-t.getTime());if(e instanceof Array&&t instanceof Array){const o=e,i=t;if(o.length&&i.length)return this.genericSortComparator(o[0],i[0],s)}return s*(""+e).localeCompare(""+t)}}function it(n,e){return Na(n,e)?n:Array.from(new Set(n)).filter(t=>Number.isInteger(t)&&t>=0&&t<e).sort((t,s)=>t-s)}function Na(n,e){let t=-1;for(const s of n){if(!Number.isInteger(s)||s<=t||s>=e)return!1;t=s}return!0}function fi(n){return n.position==="before"?n.rowIndex:n.rowIndex+1}function Do(n,e){if(!n.length)return-1;const t=fi(e);return t-n.filter(s=>s<t).length}function Kr(n,e,t){const s=it(e,n.length);if(!s.length)return-1;const o=Math.min(Math.max(0,t),n.length),i=new Uint8Array(n.length);s.forEach(h=>i[h]=1);const r=new Array(s.length);s.forEach((h,d)=>r[d]=n[h]);const l=[];let a=-1;for(let h=0;h<=n.length;h++)h===o&&(a=l.length),h<n.length&&!i[h]&&l.push(n[h]);let c=0;for(let h=0;h<a;h++)n[c++]=l[h];for(const h of r)n[c++]=h;for(let h=a;h<l.length;h++)n[c++]=l[h];return a}function gi(n){const e=new Set(n);return n.filter(t=>{for(let s=t.parent;s;s=s.parent)if(e.has(s))return!1;return!0})}function pi(n,e){if(!e||!n.length)return!1;const t=new Set(n);for(let s=e;s;s=s.parent)if(t.has(s))return!1;return!0}function zr(n,e,t,s){const o=gi(e);if(!pi(o,t))return!1;for(const a of o){const c=a.parent?a.parent.children:n,h=(c==null?void 0:c.indexOf(a))??-1;c&&h>-1&&c.splice(h,1)}let i,r,l;s==="inside"?(i=t,t.children=t.children??[],r=t.children,l=r.length,t.expanded=!0):(i=t.parent,r=i?i.children??(i.children=[]):n,l=r.indexOf(t)+(s==="after"?1:0)),r.splice(l,0,...o);for(const a of o)a.parent=i,jr(a,i?i.deep+1:0);return!0}function jr(n,e){n.deep=e;for(const t of n.children??[])jr(t,e+1)}function Zs(n,e,t,s){return n===e&&s.position!=="inside"&&Number.isInteger(s.rowIndex)&&s.rowIndex>=0&&s.rowIndex<n&&it(t,n).length>0}function mi(n,e,t,s){if(!Zs(n.length,e.length,t,s))return!1;if(Kr(n,it(t,n.length),fi(s)),e!==n)for(let o=0;o<n.length;o++)e[o]=n[o];return!0}function Pa(n,e,t,s){if(e<1)return-1;if(s&&s>0)return Math.min(e-1,Math.max(0,Math.floor(n/s)));let o=0,i=e-1;for(;o<i;){const r=o+i+1>>1;t(r)<=n?o=r:i=r-1}return o}const Va=new Int32Array(0);class K extends hs{constructor(e,t,s,o=[],i="ge-selected-row",r="ge-focused-row"){super(e,o,s),this.areaIdent=e,this.rows=t,this.defaultRowHeight=s,this.columnDefs=o,this.selectedRowClass=i,this.focusedRowClass=r,this.sorterService=new ui,this.displayInDataOrder=!0,this.showValuesCache=new Map,this._focusedRowIndex=0,this.filteredRows=[...t],this.properties=o.map(l=>l.property)}getFocusedRowIndex(){return this._focusedRowIndex}setFocusedRowIndex(e){this._focusedRowIndex=e}setRows(e){this.rows=e,this.filteredRows=[...e],this.displayInDataOrder=!0,this.showValuesCache.clear()}appendRows(e,t={}){const s=this.rows,o=t.maxRows!==void 0&&t.maxRows>=0?Math.floor(t.maxRows):Number.POSITIVE_INFINITY,i=Math.max(0,s.length+e.length-o),r=i>0?Math.max(i,Math.ceil(o/100)):0,l=Math.min(r,s.length),a=Math.max(0,i-l),c=l>0?this.removeFirstRows(l):Va,h=[],d=t.filter;for(let f=a;f<e.length;f++){const g=e[f];s.push(g),(!d||d(g))&&h.push(g)}const u=t.compare?this.mergeSorted(h,t.compare):this.appendShown(h);return(h.length||c.length)&&this.showValuesCache.clear(),{added:e.length-a,shown:h.length,removed:l,removedPositions:c,insertedPositions:u}}removeFirstRows(e){const t=this.rows.splice(0,e),s=this.filteredRows;if(this.displayInDataOrder){let l=0;for(let c=0;c<t.length&&l<s.length;c++)s[l]===t[c]&&l++;s.splice(0,l);const a=new Int32Array(l);for(let c=0;c<l;c++)a[c]=c;return a}const o=new Set(t),i=[];let r=0;for(let l=0;l<s.length;l++){const a=s[l];o.has(a)?i.push(l):s[r++]=a}return s.length=r,Int32Array.from(i)}appendShown(e){const t=this.filteredRows,s=new Int32Array(e.length);for(let o=0;o<e.length;o++)s[o]=t.length,t.push(e[o]);return s}mergeSorted(e,t){const s=this.filteredRows,o=e.length,i=new Int32Array(o);if(!o)return i;e.sort(t),this.displayInDataOrder=!1;let r=s.length;for(let l=0;l<o;l++)s.push(e[l]);for(let l=o-1;l>=0;l--){const a=e[l];let c=0,h=r;for(;c<h;){const d=c+h>>>1;t(s[d],a)>0?h=d:c=d+1}c<r&&s.copyWithin(c+l+1,c,r),s[c+l]=a,i[l]=c+l,r=c}return i}createSortComparator(e){const t=e.filter(({sortState:s})=>s==="asc"||s==="desc").map(({columnIndex:s,sortState:o})=>this.genericFlatTableSortComparator(this.properties[s],o==="asc"?1:-1));if(t.length)return(s,o)=>{for(const i of t){const r=i(s,o);if(r)return r}return 0}}filterRowsByPredict(e){this.rows=this.rows.filter(e),this.filteredRows=this.filteredRows.filter(e)}getRowCount(){var e;return((e=this.filteredRows)==null?void 0:e.length)??0}getUnfilteredRowCount(){var e;return((e=this.rows)==null?void 0:e.length)??0}canMoveRows(e,t){return Zs(this.filteredRows.length,this.rows.length,e,t)}moveRows(e,t){const s=mi(this.filteredRows,this.rows,e,t);return s&&(this.displayInDataOrder=!0,this.invalidateDerivedValues()),s}getValueAt(e,t){const s=this.properties[t];let o=this.filteredRows[e];if(U(o)&&(o=o.data),o){const i=this.getValueByT(o,s),r=this.getColumnValues().getShowValuesAs(s);return r?this.applyShowValuesAs(e,s,i,r):i}return""}getTextValueAt(e,t){const s=this.getValueAt(e,t);return this.getCalculatedText(this.properties[t],s)??""+s}getCellRenderer(e,t){return super.getCellRenderer(e,t)??this.getCalculatedRenderer(this.properties[t])}getTooltipAt(e,t){const s=this.properties[t];if(s!==void 0&&this.getColumnValues().isCalculated(s)){const o=this.getValueAt(e,t);if(w(o))return o.message}return super.getTooltipAt(e,t)}invalidateDerivedValues(e){this.invalidateColumnValues(),this.showValuesCache.clear()}applyShowValuesAs(e,t,s,o){if(w(s))return s;let i=this.showValuesCache.get(t);switch(i||(i={},this.showValuesCache.set(t,i)),o.mode){case"percentOfColumnTotal":case"percentOfGrandTotal":case"percentOfParentTotal":return i.total===void 0&&(i.total=qs(this.filteredRows.map(r=>this.getValueByT(U(r)?r.data:r,t)))),typeof s=="number"&&!Number.isNaN(s)&&i.total!==0?s/i.total:void 0;case"percentOfRowTotal":return s;default:return(!i.values||i.values.length!==this.filteredRows.length)&&(i.values=di(this.filteredRows.map(r=>this.getValueByT(U(r)?r.data:r,t)),o.mode)),i.values[e]}}readPropertyPath(e,t){return t.includes(".")?this.getPropertyValue(e,t.split(".")):e[t]}getAggregationSourceForValues(){const e=this.filteredRows;return{signal:e,length:e.length,rows:()=>e.some(t=>U(t))?e.map(t=>U(t)?t.data:t):e}}getFilteredRows(){return this.filteredRows}getAllRows(){return this.rows}findRowFromFilteredRowsByAllCriteria(e,t){return this.getFilteredRows().find(s=>t(e,s))}findRowFromAllRowsByAllCriteria(e,t){return this.getAllRows().find(s=>t(e,s))}getRowHeight(e){return this.defaultRowHeight}getConstantRowHeight(){return this.getRowHeight===K.prototype.getRowHeight&&this.defaultRowHeight>0?this.defaultRowHeight:void 0}getRowByIndex(e){return this.filteredRows[e]}externalFilterChanged(e){this.filteredRows=this.rows?this.rows.filter(e):[],this.displayInDataOrder=!0,this.showValuesCache.clear()}doSort(e){const t=e.map(({columnIndex:s,sortState:o})=>{const i=o==="asc"?1:o==="desc"?-1:0;return this.genericFlatTableSortComparator(this.properties[s],i)});return this.showValuesCache.clear(),e.some(({sortState:s})=>s==="asc"||s==="desc")&&(this.displayInDataOrder=!1),t.length&&(this.filteredRows=this.filteredRows.sort((s,o)=>{for(const i of t){const r=i(s,o);if(r)return r}return 0})),!0}sort(e){this.displayInDataOrder=!1,this.filteredRows=this.filteredRows.sort(e),this.showValuesCache.clear()}getValueByT(e,t){if(!e||!t)return;const s=this.getColumnValues();if(s.getter(t))return s.get(e,t);const o=t.includes(".")?this.getPropertyValue(e,t.split(".")):e[t];return this.sheetCells&&typeof o=="string"?this.sheetCells.valueOfProperty(e,t,o):o}getInputValueAt(e,t){const s=this.sheetCells;this.sheetCells=void 0;try{return this.getValueAt(e,t)}finally{this.sheetCells=s}}changeColumnOrder(e,t){this.arrayMove(this.properties,e,t),super.changeColumnOrder(e,t)}getCustomClassesAt(e,t){let s=super.getCustomClassesAt(e,t);return s=this.addCalculatedClasses(s,this.properties[t],()=>this.getValueAt(e,t)),this.getRowByIndex(e).selected&&s.push(this.selectedRowClass),this._focusedRowIndex===e&&s.push(this.focusedRowClass),s}genericFlatTableSortComparator(e,t){const s=this.columnDefs.find(r=>r.property===e),o=this.createSortValueReader(e),i=this.getColumnValues().isCalculated(e);return(r,l)=>{const a=o(r),c=o(l);return i&&(a===void 0||c===void 0)?a===c?0:a===void 0?1:-1:s!=null&&s.sortComparator?t*s.sortComparator(a,c,r,l,t):this.sorterService.genericSortComparator(a,c,t)}}createSortValueReader(e){if(!this.getColumnValues().getter(e))return s=>this.getValueByT(s,e);const t=new Map;return s=>{if(t.has(s))return t.get(s);const o=this.getValueByT(s,e),i=w(o)?void 0:o;return t.set(s,i),i}}getPropertyValue(e,t){const s=t.shift(),o=e[s];return o&&t.length?this.getPropertyValue(o,t):o}}class M{constructor(e,t,s,o,i=!1){this.r1=e,this.c1=t,this.r2=s,this.c2=o,this.gammaRange=i}static create(e){return e.gammaRange===void 0&&(e.gammaRange=!1),new M(e.rowIndex1,e.columnIndex1,e.rowIndex2,e.columnIndex2,e.gammaRange)}static singleCell(e,t){return new M(e,t,e,t)}static singleRow(e){return new M(e,0,e,Number.MAX_SAFE_INTEGER)}static singleColumn(e){return new M(0,e,Number.MAX_SAFE_INTEGER,e)}isInRange(e,t){return e>=this.r1&&e<=this.r2&&t>=this.c1&&t<=this.c2}}const _s=class _s{aggregate(e,t){const s={count:0,numericCount:0,sum:0,avg:void 0,min:void 0,max:void 0,capped:!1};if(!(t!=null&&t.hasSelection()))return s;const o=e.getBodyModel(),i=o.getRowCount(),r=e.getColumnCount(),l=(t.isAllSelected()?[new M(0,0,i-1,r-1)]:t.getRanges()).map(p=>({r1:Math.max(0,Math.min(p.r1,p.r2)),r2:Math.min(i-1,Math.max(p.r1,p.r2)),columns:this.dataColumns(e,Math.max(0,Math.min(p.c1,p.c2)),Math.min(r-1,Math.max(p.c1,p.c2)))})).filter(p=>p.r2>=p.r1&&p.columns.length);if(l.reduce((p,m)=>p+(m.r2-m.r1+1)*m.columns.length,0)>_s.maxCells)return s.capped=!0,s;const{sum:c,min:h,max:d}=Oe;let u=c.init(),f=h.init(),g=d.init();return l.forEach((p,m)=>{const b=l.slice(0,m);for(let y=p.r1;y<=p.r2;y++)for(const C of p.columns){if(b.length&&b.some(A=>y>=A.r1&&y<=A.r2&&A.columns.includes(C))||!t.isSelected(y,C))continue;s.count++;const S=o.getValueAt(y,C);typeof S=="number"&&!Number.isNaN(S)&&(s.numericCount++,u=c.add(u,S),f=h.add(f,S),g=d.add(g,S))}}),s.numericCount&&(s.sum=c.result(u),s.avg=s.sum/s.numericCount,s.min=h.result(f),s.max=d.result(g)),s}dataColumns(e,t,s){var i;const o=[];for(let r=t;r<=s;r++){const l=e.getColumnDef(r);((i=l==null?void 0:l.isVisible)==null?void 0:i.call(l))===!1||O(l)||be(l)||o.push(r)}return o}};_s.maxCells=1e6;let Es=_s;function _a(n){const e=Ft(n);if(!e||!hi(e.mode))return;const t=Math.min(10,Math.max(0,Math.trunc(Number(e.fractionDigits??1)||0)));return t?`0.${"0".repeat(t)}%`:"0%"}const ie=1048576,q=16384;function Ne(n){if(!Number.isInteger(n)||n<0||n>=q)return"";let e="",t=n+1;for(;t>0;){const s=(t-1)%26;e=String.fromCharCode(65+s)+e,t=Math.floor((t-1)/26)}return e}function Fe(n){if(!/^[A-Za-z]{1,3}$/.test(n))return-1;let e=0;for(const t of n.toUpperCase())e=e*26+(t.charCodeAt(0)-64);return e-1<q?e-1:-1}function mt(n,e,t={}){const s=Ne(e);return!s||!Number.isInteger(n)||n<0||n>=ie?"#REF!":`${t.absCol?"$":""}${s}${t.absRow?"$":""}${n+1}`}function Ue(n){const e=/^(\$?)([A-Za-z]{1,3})(\$?)([1-9]\d{0,6})$/.exec(n.trim());if(!e)return;const t=Fe(e[2]),s=Number(e[4])-1;if(!(t<0||s>=ie))return{row:s,col:t,absRow:e[3]==="$",absCol:e[1]==="$"}}function Xr(n){const e=n.trim(),t=e.split(":");if(t.length===1){const c=Ue(e);return c?{from:c,to:{...c}}:void 0}if(t.length!==2)return;const s=Ue(t[0]),o=Ue(t[1]);if(s&&o)return{from:{row:Math.min(s.row,o.row),col:Math.min(s.col,o.col),absRow:s.absRow,absCol:s.absCol},to:{row:Math.max(s.row,o.row),col:Math.max(s.col,o.col),absRow:o.absRow,absCol:o.absCol}};const i=/^(\$?)([A-Za-z]{1,3})$/.exec(t[0]),r=/^(\$?)([A-Za-z]{1,3})$/.exec(t[1]);if(i&&r){const c=Fe(i[2]),h=Fe(r[2]);return c<0||h<0?void 0:{from:{row:0,col:Math.min(c,h),absRow:!1,absCol:i[1]==="$"},to:{row:ie-1,col:Math.max(c,h),absRow:!1,absCol:r[1]==="$"},wholeColumns:!0}}const l=/^(\$?)([1-9]\d{0,6})$/.exec(t[0]),a=/^(\$?)([1-9]\d{0,6})$/.exec(t[1]);if(l&&a){const c=Number(l[2])-1,h=Number(a[2])-1;return c>=ie||h>=ie?void 0:{from:{row:Math.min(c,h),col:0,absRow:l[1]==="$",absCol:!1},to:{row:Math.max(c,h),col:q-1,absRow:a[1]==="$",absCol:!1},wholeRows:!0}}}class B extends Error{constructor(e,t){super(e),this.pos=t}toFormulaError(){return new I("#ERROR!",`${this.message} (at ${this.pos+1})`,this.pos)}}const Ba=["<=",">=","<>","!=","==","+","-","*","/","^","&","=","<",">"],$a=["<=",">=","<>","+","-","*","/","^","&","=","<",">",":","%"],Ha=/^#(REF!|N\/A|DIV\/0!|VALUE!|NAME\?|NUM!|NULL!|CIRC!|ERROR!)/i,Ga={n:`
41
+ `)}}class Eo{fixJSON(e){const t=[];let s="",o=!1,i=!1;for(let r=0;r<e.length;r++){const l=e[r];if(s+=l,l==='"'&&!i&&(o=!o),l==="\\"&&!i){i=!0;continue}else i=!1;if(!o){if(l==="{"||l==="[")t.push(l);else if(l==="}"||l==="]"){const a=t.pop();if(l==="}"&&a!=="{"||l==="]"&&a!=="[")throw new Error("Invalid JSON structure detected.")}}}for(;t.length>0;){const r=t.pop();r==="{"?s+="}":r==="["&&(s+="]")}return s}}class Or{constructor(){this.property="",this.value="",this.path="",this.propertyItem=new ii("",[new oi("")])}toString(){var e;return`${this.path} -> : ${((e=this.propertyItem)==null?void 0:e.toString())??""}`}}const Mo="Entity";function Nr(n){let e=Pr(Vr(n));return e.includes(Mo)||(e=e+Mo),e}function Pr(n){if(!n||n.length===0)return n;const e=["Array","Arr","List","s"];for(const t of e)if(n.endsWith(t))return n.slice(0,-t.length);return n}function Vr(n){return!n||n.length===0?"":n[0].toUpperCase()+n.slice(1)}class wa{constructor(){this.debugging=!1}json2PropertyType(e,t=""){let s;if(typeof e=="string"){const o=new Eo().fixJSON(e);s=this.json2Object(o)}else s=e;return this.object2PropertyType(s,t)}json2Object(e){return JSON.parse(e)}object2PropertyType(e,t=""){const s=this.object2ValueInfos(e,t);this.debugging&&this.logValueInfos(s);const o=this.valueInfos2PropertyType(s);return"name"in o&&(o.name=t),o}json2ValueInfos(e,t=""){let s;if(typeof e=="string"){const o=new Eo().fixJSON(e);s=this.json2Object(o)}else s=e;return this.object2ValueInfos(s,t)}object2ValueInfos(e,t=""){const s=this.extractValueInfos(e,t),o=this.mergeValueInfos(s);return o.length>0&&(o[0].propertyItem.propertyName=t),this.debugging&&this.logValueInfos(o),o}getParentPath(e){const t=e.lastIndexOf("/");return t===-1?"":e.substring(0,t)}valueInfos2PropertyType(e){const t=e[0].propertyItem.types[0],s=new Map;for(const o of e)s.set(o.path,o);for(const o of e){const i=this.getParentPath(o.path);if(i){const r=s.get(i);if(r){let l=!1;const a=r.propertyItem.types.filter(c=>!Zt.includes(c.type));if(a.length===1){const c=a[0];if(c instanceof We){l=!0;for(const h of o.propertyItem.types)c.items.push(h)}else c instanceof Se&&(l=!0,c.properties.push(o.propertyItem))}if(!l)for(const c of o.propertyItem.types)r.propertyItem.types.push(c)}}}return t||new oi("")}logValueInfos(e){for(let t=0;t<e.length;t++){const s=e[t];s.value=null;const o=t.toString().padStart(2,"0");console.info(o+") "+s.toString()+" parent: "+this.getParentPath(s.path))}}mergeValueInfos(e){const t=[];let s=e.length-1;t.push(e[s]);let o=e[s].path;for(let i=s-1;i>=0;i--){if(e[i].path===o){const r=e[i].propertyItem.types[0];e[s].propertyItem.types.some(l=>l.type===r.type)||e[s].propertyItem.types.push(r)}(i===0||e[i].path!==o)&&(s=i,t.push(e[i]),o=e[s].path)}for(const i of e){const r=this.getParentPath(i.path);if(r){const l=this.getParentPath(r);if(l){const a=this.getFirstValueInfoByPath(e,l);if(Array.isArray(a==null?void 0:a.value)){const c=(a==null?void 0:a.value.length)??0,h=this.countPath(e,i.path);c>h&&(i.propertyItem.types.some(d=>d.type===St)||i.propertyItem.types.push(new ys(i.property)))}}}}return t.reverse(),t}countPath(e,t){let s=0;for(const o of e)o.path===t&&s++;return s}getFirstValueInfoByPath(e,t){for(let s=e.length-1;s>=0;s--)if(e[s].path===t)return e[s];return null}extractValueInfos(e,t){const s=[],o=(i,r,l)=>{const a=new Or;let c=r.split("/").pop()||"";if(c==="[]"?c=l:c==="root"&&(c=t),a.property=c,a.value=i,a.path=r,a.propertyItem=this.createPropertyItem(i,a.property),s.push(a),i&&typeof i===xt&&!Array.isArray(i)){for(const h in i)if(i.hasOwnProperty(h)){const d=r?`${r}/${h}`:h;o(i[h],d,c)}}else Array.isArray(i)&&i.forEach((h,d)=>{const u=`${r}/[]`;o(h,u,c)})};return o(e,"root",t),s.sort((i,r)=>i.path.localeCompare(r.path))}createPropertyItem(e,t){return new ii(t,[this.createPropertyType(e,t)])}createPropertyType(e,t){return e===null?new Dr(t):e===void 0?new ys(t):typeof e===ti?new kr(t):typeof e===Ks&&!isNaN(e)?new Fr(t):typeof e===zs?new Lr(t):Array.isArray(e)?new We(t):typeof e===xt?new Se(t,Nr(t)):new ys(t)}}class ya{constructor(){this.orOperator="|",this.rootPropertyType=null,this.rootName="Root",this.renderTypeScriptInterfacesFifo=[],this.renderTypeScriptInterfacesDone=[]}renderTypeScriptInterfaces(e){"name"in e&&(this.rootName=e.name+""),this.rootPropertyType=e;const t=[];return this.rootPropertyType&&(this.renderTypeScriptInterfacesFifo=[],this.renderTypeScriptInterfacesDone=[],this.renderTypeScriptInterfacesRecursive(this.rootPropertyType,t),this.renderTypeScriptInterfacesFifoNext(t)),t}renderTypeScriptInterfacesFifoNext(e){var t;for(;(t=this.renderTypeScriptInterfacesFifo)!=null&&t.length;){const s=this.renderTypeScriptInterfacesFifo.shift();s&&this.renderTypeScriptInterfacesRecursive(s,e,s.propertyName)}}renderTypeScriptInterfacesRecursive(e=this.rootPropertyType,t=[],s=this.rootName){if(!e)return t;if(e instanceof We){for(const o of e.items)if(this.renderTypeScriptInterfacesRecursive(o,t,s),o instanceof Se){const i=o;i!==this.rootPropertyType&&this.renderTypeScriptInterfacesFifo.push(i)}}else if(e instanceof Se){const o=e,i=o.className;if(!this.renderTypeScriptInterfacesDone.includes(i)){this.renderTypeScriptInterfacesDone.push(i),t.push(`export interface ${i} {`);for(const r of o.properties){let l=this.propertyItem2InterfaceDateType(r);l==="[]"?l="any[]":l.startsWith("(")&&l.endsWith(")")&&(l=l.substring(1,l.length-1));const a=this.containsUndefinedPropertyType(r)?"?":"";t.push(" "+r.propertyName+a+": "+l+";");for(const c of r.types)if(c instanceof Se)c!==this.rootPropertyType&&this.renderTypeScriptInterfacesFifo.push(c);else if(c instanceof We)for(const h of c.items)h instanceof Se&&this.renderTypeScriptInterfacesFifo.push(h)}t.push("}"),t.push("")}}return t}propertyItem2InterfaceDateType(e){var s,o;if(((s=e.types)==null?void 0:s.length)===0)return"any";if(((o=e.types)==null?void 0:o.length)===1)return this.renderType(e.types[0],e);const t=e.types.map(i=>this.renderType(i,e)).filter(i=>i!==St).sort((i,r)=>Zt.includes(i)?100:Zt.includes(r)?-100:i.localeCompare(r)).join(this.orOperator);return t.includes(this.orOperator)?"("+t+")":t}renderType(e,t){if(e instanceof We){const s=e.items.map(o=>this.renderType(o,t)).join(this.orOperator);return s.includes(this.orOperator)?`(${s})[]`:`${s}[]`}return e instanceof Se?e.className:e.type}containsUndefinedPropertyType(e){for(const t of e.types)if(t.type===St)return!0;return!1}}class Qe{constructor(){this.alreadySet=!1}static getInstance(){return Qe.instance||(Qe.instance=new Qe),Qe.instance}setLicenseKey(e){if(e&&!this.alreadySet){const t=document.createElement("meta");t.content="license="+e,t.name="guiexperttable",document.getElementsByTagName("head")[0].appendChild(t),this.alreadySet=!0}}}function U(n){return n&&n.type==="TreeRow"}function Z(n){return n&&n.type==="AreaModelTree"}function ri(n){return!!n&&n.type==="CheckboxCellRenderer"}function be(n){return n&&n.type==="CheckboxColumnDef"}function O(n){return!!n&&n.type==="RowNumberColumnDef"}function _r(n){return!!n&&n.type==="AreaModelAggregateFooter"}function le(n){return!!n&&n.type==="RowGroup"}function To(n){return U(n)&&le(n.data)}function ne(n){return!!n&&n.kind==="AreaModelRowGroups"}function ot(n){return!!n&&n.type==="RowGroupColumnDef"}function vs(n){return!!n&&n.kind==="PivotTableModel"}function Io(n){return!!n&&n.kind==="AreaModelPivot"}function js(n){return!!n&&n.type==="PivotColumnDef"}class Qt{constructor(e=-1,t=-1,s=-1,o=-1,i,r,l,a=0,c=0,h=0,d=""){this.rowIndex=e,this.rowTop=t,this.columnIndex=s,this.columnLeft=o,this.areaIdent=i,this.sideIdent=r,this.originalEvent=l,this.clickCount=a,this.draggingX=c,this.draggingY=h,this.action=d}clone(){return new Qt(this.rowIndex,this.rowTop,this.columnIndex,this.columnLeft,this.areaIdent,this.sideIdent,this.originalEvent,this.clickCount,this.draggingX,this.draggingY,this.action)}}class Me{constructor(e=">",t="",s=[]){this.content=e,this.style=t,this.classes=s}}class ni{constructor(e=new Me(">","transform: rotate(90deg) translate(66%, -66%); transform-origin: 0 0;",["gt-table-tree-arrow-expanded"]),t=new Me(">","",["ge-table-tree-arrow-collapsed"]),s=new Me(">","color:transparent;",["gt-table-tree-arrow-hidden"]),o=new Me("↕","",["gt-table-tree-arrow-expanded-all"])){this.arrowExpanded=e,this.arrowCollapsed=t,this.arrowPlaceholder=s,this.arrowExpandCollapseAll=o}}class li{constructor(e=new Me("↑","",["ge-header-sorted-asc"]),t=new Me("↓","",["ge-header-sorted-desc"]),s=new Me("↑","color:transparent;",[])){this.iconAsc=e,this.iconDesc=t,this.iconPlaceholder=s}}const Vs=class Vs{constructor(e){this.domService=e,this.rtl=!1,this.startKey="left",this.endKey="right"}setDirection(e){this.rtl=e==="rtl",this.startKey=this.rtl?"right":"left",this.endKey=this.rtl?"left":"right"}getDirection(){return this.rtl?"rtl":"ltr"}toPhysicalStyleKey(e){if(this.rtl){if(e==="left")return"right";if(e==="right")return"left"}return e}getInlineStart(e){return parseFloat(e.style.getPropertyValue(this.startKey))||0}setStyle(e,t,s){return this.domService.setStyle(e,this.toPhysicalStyleKey(t),s),e}applyStyle(e,t){for(const s in t)this.domService.setStyle(e,this.toPhysicalStyleKey(s),t[s]);return e}applyDisplayNoneStyle(e){return this.domService.setStyle(e,"display","none"),e}applyDisplayBlockStyle(e){return this.domService.setStyle(e,"display","block"),e}applyStyleInPx(e,t){return Object.entries(t).forEach(([s,o])=>this.domService.setStyle(e,this.toPhysicalStyleKey(s),o+"px")),e}applyStylePosistionRelative(e){return this.domService.setStyle(e,"position","relative"),this.domService.setStyle(e,"overflow","clip"),e}applyStylePosistionAbsolute(e){return this.domService.setStyle(e,"position","absolute"),e}applyStyleFullSize(e){return this.domService.setStyle(e,"width","100%"),this.domService.setStyle(e,"height","100%"),e}applyStyleOverflowAuto(e="auto",t="auto",s){return this.domService.setStyle(s,"overflow-x",e),this.domService.setStyle(s,"overflow-y",t),s}applyStyleNoPadding(e){return this.domService.setStyle(e,"padding","0"),this.domService.setStyle(e,"margin","0"),this.domService.setStyle(e,"border","0"),e}appendRelativeChildDiv(e){const t=this.applyStylePosistionRelative(this.applyStyleFullSize(this.applyStyleNoPadding(this.domService.createElement("div"))));return this.domService.appendChild(e,t),this.applyStylePosistionAbsolute(e),{parent:e,child:t,cache:{}}}appendText(e,t){const s=this.domService.createText(t);return this.domService.appendChild(e,s),s}addClass(e,t){return e.includes(" ")?e.split(" ").forEach(s=>this.domService.addClass(t,s)):this.domService.addClass(t,e),t}removeClass(e,t){return e.includes(" ")?e.split(" ").forEach(s=>this.domService.removeClass(t,s)):this.domService.removeClass(t,e),t}addClasses(e,t){if(e)for(const s of e)this.domService.addClass(t,s);return t}setAttribute(e,t,s){return t&&s&&this.domService.setAttribute(e,t,s),e}removeAttribute(e,t){return this.domService.removeAttribute?this.domService.removeAttribute(e,t):e.removeAttribute(t),e}setAriaHidden(e){return this.domService.setAttribute(e,"aria-hidden","true"),e}createAreaDivWithClass(e,t,s,o){const i=this.domService.createElement("div");return this.addClass(e,i),this.domService.setAttribute(i,"data-area",s),this.domService.setAttribute(i,"data-side",o),this.domService.appendChild(t,i),i}createDivWithClass(e,t){const s=this.domService.createElement("div");return this.addClass(e,s),this.domService.appendChild(t,s),s}addRowDiv(e,t,s=-1,o,i,r=""){const l=t.index??-1,a=this.getDivOrCreateDiv(l,e);if(this.domService.addClass(a,"ge-table-row-div"),this.domService.addClass(a,`ge-table-row-div-${t.index}`),o==="body"&&i==="center"){const c=((t==null?void 0:t.index)??0)%2===0?"even":"odd";this.domService.addClass(a,`ge-table-row-${c}`)}if(this.domService.setStyle(a,"display","clip"),this.domService.setStyle(a,"position","absolute"),this.domService.setStyle(a,this.startKey,`${t.left}px`),this.domService.setStyle(a,"top",`${t.top}px`),this.domService.setStyle(a,"width",`${t.width}px`),this.domService.setStyle(a,"height",`${t.height}px`),this.domService.setAttribute(a,"data-row-index",`${s}`),this.domService.setAttribute(a,"data-area",`${o}`),r){const c=this.domService.createText(r);this.domService.appendChild(a,c)}return this.domService.appendChild(e.child,a),a}addColumnDiv(e){const{parent:t,geo:s,rowIndex:o=-1,columnIndex:i=-1,areaIdent:r,sideIdent:l,text:a="",treeArrow:c,tableOptions:h,checkedType:d=void 0,sortState:u,checkboxAriaLabel:f,firstDataColumnIndex:g=0}=e,p=h==null?void 0:h.treeOptions,m=h==null?void 0:h.showCheckboxWihoutExtraColumn,b=this.domService.createElement("div");this.domService.addClass(b,"ge-table-col-div"),m&&this.domService.addClass(b,"ge-with-checkbox"),this.domService.addClass(b,`ge-table-col-div-${s.index}`),this.domService.setAttribute(b,"data-col-index",`${s.index}`),this.domService.setAttribute(b,"data-row-index",`${o}`),this.domService.setAttribute(b,"data-area",`${r}`);const y=((s==null?void 0:s.index)??0)%2===0?"even":"odd";if(r==="body"&&l==="center"&&this.domService.addClass(b,`ge-table-column-${y}`),this.domService.setStyle(b,"display","clip"),this.domService.setStyle(b,"position","absolute"),this.domService.setStyle(b,this.startKey,`${s.left}px`),this.domService.setStyle(b,"top",`${s.top}px`),this.domService.setStyle(b,"width",`${s.width}px`),this.domService.setStyle(b,"height",`${s.height}px`),c&&c!=="none"&&(this.domService.addClass(b,"ge-table-col-tree"),this.addArrowDiv(b,c,p,o,i,r)),m&&i===g&&d&&this.addCheckboxToDiv(b,d,r,o,f),a){const C=c!=="none"&&i===g;this.addLabelDiv(b,a,C,o,i,r)}return u&&this.addSortedIcon(b,u,h==null?void 0:h.sortedOptions,i),this.domService.appendChild(t,b),b}addCheckboxToDiv(e,t,s,o,i){const r=this.domService.createElement("div"),l=this.domService.createElement("input");return this.domService.setAttribute(l,"type","checkbox"),this.domService.setAttribute(l,"data-area",`${s}`),this.domService.setAttribute(l,"data-row-index",`${o}`),this.domService.setAttribute(l,"data-input-type","checkbox"),this.domService.setAttribute(l,"tabindex","-1"),t==="full"&&(this.domService.setAttribute(l,"checked",""),l.checked=!0),t==="semi"&&(l.indeterminate=!0),this.domService.addClass(l,"ge-table-row-checkbox"),i&&this.domService.setAttribute(l,"aria-label",i),this.domService.appendChild(r,l),this.domService.setStyle(r,"display","inline"),this.domService.setStyle(r,"width","inherit"),this.domService.setAttribute(r,"data-row-index",`${o}`),this.domService.appendChild(e,r),r}addLabelDiv(e,t="",s=!1,o=-1,i=-1,r="body"){const l=this.domService.createElement("div");if(this.domService.addClass(l,"ge-table-label-div"),this.domService.setStyle(l,"position","relative"),this.domService.setStyle(l,"background","transparent"),this.domService.setStyle(l,"width","100%"),this.domService.setStyle(l,"height","100%"),this.domService.setAttribute(l,"data-row-index",`${o}`),this.domService.setAttribute(l,"data-col-index",`${i}`),this.domService.setAttribute(l,"data-area",`${r}`),t)if(s){const a=this.domService.createText(t);this.domService.appendChild(l,a)}else{const a=this.domService.createElement("div");this.domService.appendChild(l,a);const c=this.domService.createText(t);this.domService.addClass(a,"ge-table-label"),this.domService.appendChild(a,c),this.domService.setAttribute(a,"data-row-index",`${o}`),this.domService.setAttribute(a,"data-col-index",`${i}`),this.domService.setAttribute(a,"data-area",`${r}`)}return this.domService.appendChild(e,l),l}addSortedIcon(e,t="",s=new li,o=-1){const i=this.domService.createElement("div");this.domService.addClass(i,"ge-table-sorted-icon-div"),this.setAriaHidden(i),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"top","0"),this.domService.setStyle(i,this.endKey,"0"),this.domService.setStyle(i,"width","20px"),this.domService.setStyle(i,"background","transparent"),this.domService.setStyle(i,"cursor","pointer"),this.domService.setAttribute(i,"data-col-index",`${o}`),this.domService.setAttribute(i,"data-area","header");let r;t==="asc"?r=s.iconAsc:t==="desc"?r=s.iconDesc:r=s.iconPlaceholder;const l=r.content,a=this.domService.createText(l);this.domService.appendChild(i,a),r.style&&this.applyStyleString(i,r.style);for(const c of r.classes)this.domService.addClass(i,c);return this.domService.appendChild(e,i),i}addArrowDiv(e,t="none",s=new ni,o=-1,i=-1,r="body"){const l=this.domService.createElement("div");this.domService.addClass(l,"ge-table-tree-arrow-div"),this.setAriaHidden(l),this.domService.setStyle(l,"display","inline-block"),this.domService.setStyle(l,"position",""),this.domService.setStyle(l,"width","20px"),this.domService.setStyle(l,"background","transparent"),this.domService.setStyle(l,"cursor","pointer"),this.domService.setAttribute(l,"data-row-index",`${o}`),this.domService.setAttribute(l,"data-col-index",`${i}`),this.domService.setAttribute(l,"data-area",`${r}`);let a;t==="expanded"?a=s.arrowExpanded:t==="collapsed"?a=s.arrowCollapsed:a=s.arrowPlaceholder;const c=a.content,h=this.domService.createText(c);this.domService.appendChild(l,h),a.style&&this.applyStyleString(l,a.style);for(const d of a.classes)this.domService.addClass(l,d);return this.domService.appendChild(e,l),l}addColumnBorderDivs(e,t,s,o,i){if(e.verticalBorderVisible){const r=`ge-table-${o}-${i}-vertical-border`;this.addVerticalBorder(s,t,r)}if(e.horizontalBorderVisible){const r=`ge-table-${o}-${i}-horizontal-border`;this.addHorizontalBorder(s,t,r)}return t}addHorizontalBorder(e,t,s="ge-table-body-center-horizontal-border"){const o=this.domService.createElement("div");return this.domService.addClass(o,s),this.setAriaHidden(o),this.domService.setStyle(o,"display","clip"),this.domService.setStyle(o,"position","absolute"),this.domService.setStyle(o,this.startKey,`${e.left}px`),this.domService.setStyle(o,"top",`${e.top}px`),this.domService.setStyle(o,"width",`${e.width}px`),this.domService.setStyle(o,"height","1px"),this.domService.appendChild(t,o),o}addFocusBorderDivs(e,t,s){t={...t,width:t.width+1,height:t.height+1};const o=Vs.focusBorderWidthInPx,i=[[t.left,t.top,o,t.height],[t.left+t.width-o,t.top,o,t.height],[t.left,t.top,t.width,o],[t.left,t.top+t.height-o,t.width,o]];for(const[r,l,a,c]of i){const h=this.domService.createElement("div");this.domService.addClass(h,"ge-table-focus-border"),this.setAriaHidden(h),this.domService.setStyle(h,"display","clip"),this.domService.setStyle(h,"position","absolute"),this.domService.setStyle(h,this.startKey,`${r}px`),this.domService.setStyle(h,"top",`${l}px`),this.domService.setStyle(h,"width",`${a}px`),this.domService.setStyle(h,"height",`${c}px`),this.domService.setStyle(h,"z-index","9999"),this.applyStyle(h,s),this.domService.appendChild(e,h)}return e}addVerticalBorder(e,t,s="ge-table-body-center-vertical-border"){const o=this.domService.createElement("div");return this.domService.addClass(o,s),this.setAriaHidden(o),this.domService.setStyle(o,"display","clip"),this.domService.setStyle(o,"position","absolute"),this.domService.setStyle(o,this.startKey,`${e.left}px`),this.domService.setStyle(o,"top",`${e.top}px`),this.domService.setStyle(o,"width","1px"),this.domService.setStyle(o,"height",`${e.height}px`),this.domService.appendChild(t,o),o}addDiv(e,t,s=""){const o=this.domService.createElement("div");return s&&this.domService.addClass(o,s),this.setAriaHidden(o),this.domService.setStyle(o,"display","clip"),this.domService.setStyle(o,"position","absolute"),this.domService.setStyle(o,this.startKey,`${t.left}px`),this.domService.setStyle(o,"top",`${t.top}px`),this.domService.setStyle(o,"width",`${t.width}px`),this.domService.setStyle(o,"height",`${t.height}px`),this.domService.appendChild(e,o),o}applyStyleString(e,t){const s=t.split(";").map(o=>o.trim()).filter(o=>o);for(const o of s){const[i,r]=o.split(":");this.domService.setStyle(e,i.trim(),r.trim())}}getDivOrCreateDiv(e,t){let s=t.cache[e];return s?(s.innerText="",s):(s=this.domService.createElement("div"),t.cache[e]=s,s)}};Vs.focusBorderWidthInPx=2;let Rs=Vs;const vt=n=>n==="header"?"header":n==="footer"?"footer":"body";class As{constructor(e,t){if(this.rowIdx=-1,this.colIdx=-1,this.action=null,this.inputType=null,this.className="",e!==null&&(e instanceof HTMLDivElement||e instanceof HTMLSpanElement||e instanceof HTMLInputElement)){this.className=e.className,this.action=e.getAttribute("data-ge-action"),this.inputType=e.getAttribute("data-input-type"),this.rowIdx=Number(e.getAttribute("data-row-index")),this.colIdx=Number(e.getAttribute("data-col-index"));const s=e.getAttribute("data-area");if(s&&(this.areaIdent=vt(s),this.areaModel=t.tableModel.getAreaModel(this.areaIdent),this.row=this.areaModel.getRowByIndex(this.rowIdx)),e instanceof HTMLInputElement){const o=e;this.value=o.value}}}}class Br{constructor(e){this.tableScope=e,this.doubleClickDelay=500,this.clickMoveTolerance=4,this.lastClickedCellKey="",this.nativeClickCount=0,this.nativeDblClickCount=0,this.mouseDown=!1,this.repaintAfterMouseUp=!1,this.dragging=!1,this.dragGeneration=0,this.lastClicked=0;const t=this.tableScope.listenerAbortController.signal;this.tableScope.hostElement.addEventListener("click",this.onHostElementClicked.bind(this),{signal:t}),this.tableScope.hostElement.addEventListener("dblclick",this.onHostElementDblClicked.bind(this),{signal:t}),this.tableScope.hostElement.addEventListener("mousedown",this.onMouseDown.bind(this),{signal:t}),this.tableScope.hostElement.addEventListener("mousemove",this.onMouseMove.bind(this),{signal:t}),this.tableScope.hostElement.addEventListener("mouseup",this.onMouseUp.bind(this),{signal:t}),this.tableScope.hostElement.addEventListener("contextmenu",this.onContextmenu.bind(this),{signal:t}),t.addEventListener("abort",()=>clearTimeout(this.lostClickTimer)),this.tableScope.hostElement._MouseHandler="true",this.tableScope.scrollViewport.addEventListener("scroll",()=>this.tableScope.onViewportScroll(),{signal:t}),this.tableScope.scrollViewport.addEventListener("wheel",this.tableScope.onWheel.bind(this.tableScope),{passive:!1,signal:t}),[window,this.tableScope.hostElement].forEach(s=>s.addEventListener("resize",this.tableScope.adjustContainersAndRows.bind(this.tableScope),{signal:t}))}onContextmenu(e){if(this.isBlocked(e)||!(e instanceof MouseEvent))return;this.pressedCell=void 0,this.mouseEvent=e;const t=this.tableScope.createGeMouseEvent(this.mouseEvent);this.tableScope.contextmenu(t)}onHostElementClicked(e){this.nativeClickCount++,!this.isBlocked(e)&&this.handleClick(e,this.tableScope.getMouseEventTarget(e))}handleClick(e,t,s){var c;const o=Date.now(),i=s?this.toCellKey(s):this.getCellKey(t),r=e.detail>=2||e.detail===0&&o-this.lastClicked<this.doubleClickDelay&&i===this.lastClickedCellKey;this.lastClicked=o,this.lastClickedCellKey=i;const l=new As(t,this.tableScope);s&&this.applyCell(l,s);const a=s?this.createCellEvent(e,s):void 0;if(r&&(this.reportedDoubleClick={time:o,cellKey:i}),r&&!this.isClickAction(l)){this.publishGeMouseEvent(e,2,a,t);return}if(l.action==="toggleExpandCollapseAll")this.tableScope.toggleExpandCollapseAll(!this.tableScope.allExpanded),e.preventDefault(),e.stopPropagation();else if(l.action==="toggle-detail")this.tableScope.toggleDetail(l.rowIdx,"mouse"),e.preventDefault(),e.stopPropagation();else if(l.action==="toggleHeaderGroup")this.tableScope.toggleHeaderGroup(l),e.preventDefault(),e.stopPropagation();else if(l.inputType==="checkbox"&&l.areaIdent)this.tableScope.toggleRowCheckbox(l.rowIdx,l.colIdx,l.areaIdent),e.preventDefault(),e.stopPropagation();else if(U(l.row)&&l.areaModel){const h=l.colIdx===this.getArrowColumnIndex()&&e.altKey,d=l.className.includes("ge-table-tree-arrow-div");if(h||d){e.preventDefault(),e.stopPropagation();const u=l.row;this.tableScope.setTreeRowExpanded(u,!u.expanded)}}l.areaIdent==="body"&&((c=this.tableScope.focusModel())==null||c.setFocus(l.rowIdx,l.colIdx)),this.publishGeMouseEvent(e,r?2:1,a,t)}toCellKey(e){return e.areaIdent+":"+e.rowIdx+":"+e.colIdx}applyCell(e,t){e.areaIdent=t.areaIdent,e.areaModel=this.tableScope.tableModel.getAreaModel(t.areaIdent),e.rowIdx=t.rowIdx,e.colIdx=t.colIdx,e.row=e.areaModel.getRowByIndex(t.rowIdx)}createCellEvent(e,t){return this.tableScope.createGeMouseEventForCell(e,{areaIdent:t.areaIdent,sideIdent:t.sideIdent,rowIndex:t.rowIdx,columnIndex:t.colIdx,action:t.action})}getCellKey(e){var s;const t=e instanceof Element?e:null;return(s=t==null?void 0:t.closest)!=null&&s.call(t,"[data-col-index]")?["data-area","data-row-index","data-col-index"].map(o=>{var i;return((i=t.closest("["+o+"]"))==null?void 0:i.getAttribute(o))??""}).join(":"):""}isClickAction(e){return e.action==="toggleExpandCollapseAll"||e.action==="toggleHeaderGroup"||e.action==="toggle-detail"||e.inputType==="checkbox"&&!!e.areaIdent||e.className.includes("ge-table-tree-arrow-div")}onHostElementDblClicked(e){this.nativeDblClickCount++,!this.isBlocked(e)&&this.handleDblClick(e,this.tableScope.getMouseEventTarget(e))}handleDblClick(e,t,s){var a,c,h;this.lastClicked=Date.now();const o=s?this.createCellEvent(e,s):this.tableScope.createGeMouseEvent(e),i=new As(t,this.tableScope);if(t instanceof HTMLElement&&!this.isClickAction(i)){const d=t.closest("[data-col-index]")??t,u=s?s.areaIdent:((a=d.closest("[data-area]"))==null?void 0:a.getAttribute("data-area"))??null,f=vt(u),g=s?s.rowIdx:Number((c=d.closest("[data-row-index]"))==null?void 0:c.getAttribute("data-row-index")),p=s?s.colIdx:Number(d.getAttribute("data-col-index")),m=this.tableScope.tableModel.getAreaModel(f);if(u&&f==="header"){const b=(h=m.isColumnLetterRow)==null?void 0:h.call(m,g);this.tableScope.tableModel.isSortable(p)&&!b&&(this.tableScope.clearSelection(),this.tableScope.onHeaderDblClicked(e,g,p))}else if(s||d.getAttribute("data-row-index")){const b=m.getRowByIndex(g);if(u&&f==="body"&&m.isEditable(g,p)&&this.tableScope.startEditing(g,p,"edit"),U(b)&&p===this.getArrowColumnIndex()){e.preventDefault(),e.stopPropagation();const y=b;this.tableScope.setTreeRowExpanded(y,!y.expanded)}}}const r=this.reportedDoubleClick,l=s?this.toCellKey(s):this.getCellKey(t);(!r||Date.now()-r.time>this.doubleClickDelay||r.cellKey!==l)&&this.publishGeMouseEvent(e,2,o),this.reportedDoubleClick=void 0}publishGeMouseEvent(e,t,s,o=e.target){var r;this.mouseEvent=e,this.geMouseEventOld=(r=this.geMouseEvent)==null?void 0:r.clone(),this.geMouseEvent=s??this.tableScope.createGeMouseEvent(e),this.geMouseEvent&&(this.geMouseEvent.clickCount=t);const i=this.tableScope.onMouseClicked(this.geMouseEvent,this.geMouseEventOld);this.tableScope.publishGeMouseEvent(this.geMouseEvent),i&&!this.isInteractiveCellElement(o)&&this.tableScope.debounceRepaint()}isInteractiveCellElement(e){const t=e instanceof Element?e:null,s=t==null?void 0:t.closest('input, select, textarea, button, a[href], [contenteditable]:not([contenteditable="false"])');return!!s&&this.tableScope.hostElement.contains(s)}getArrowColumnIndex(){const e=this.tableScope.tableModel.isRowCheckboxVisible();return this.tableScope.getFirstDataColumnIndex()+(e?1:0)}onMouseDown(e){if(!this.isBlocked(e)&&(this.tableScope.cancelPendingRepaint()&&(this.repaintAfterMouseUp=!0),this.pressedCell=e.button===0?this.readPressedCell(e):void 0,!this.dragging)){this.mouseEvent=e,this.startMouseEvent=this.tableScope.createGeMouseEvent(this.mouseEvent),this.flushDraggingEnd(),this.tableScope.onMouseDown(this.startMouseEvent),this.mouseDown=!0;const t=this.tableScope.listenerAbortController.signal;document.addEventListener("mouseup",s=>this.onDocumentMouseUp(s),{once:!0,signal:t})}}onDocumentMouseUp(e){this.mouseDown&&!this.tableScope.hostElement.contains(e.target)&&this.onMouseUp(e)}adjustForRowChanges(e){const t=this.startMouseEvent;(this.mouseDown||this.pendingDraggingEnd)&&t&&t.areaIdent==="body"&&t.rowIndex>=0&&(t.rowIndex=Math.max(0,e.mapIndexOrNext(t.rowIndex)))}onMouseMove(e){var t,s,o,i;if(!this.mouseDown&&((s=(t=this.tableScope).isEventInDetail)!=null&&s.call(t,e))){(i=(o=this.tableScope).hideHover)==null||i.call(o);return}if(!(!this.mouseDown&&this.isBlocked(e)))if(this.mouseEvent=e,this.mouseDown){this.dragging||(this.dragging=!0,this.tableScope.setDragging(!0));const r=this.dragGeneration;requestAnimationFrame(()=>{r===this.dragGeneration&&this.mouseDraggingOnFrame()})}else requestAnimationFrame(this.mouseMoveOnFrame.bind(this))}onMouseUp(e){var s,o;const t=this.pressedCell;if(this.pressedCell=void 0,!(!this.mouseDown&&((o=(s=this.tableScope).isEventInDetail)!=null&&o.call(s,e)))){if(this.mouseEvent=e,t&&e.button===0&&this.checkLostClick(t,e),this.repaintAfterMouseUp&&(this.repaintAfterMouseUp=!1,this.tableScope.debounceRepaint()),this.dragging){const i={evt:e,start:this.startMouseEvent,frameId:0};i.frameId=requestAnimationFrame(()=>this.flushDraggingEnd()),this.pendingDraggingEnd=i}this.mouseDown=!1,this.dragging=!1,this.tableScope.setDragging(!1)}}readPressedCell(e){var f,g,p;const t=this.tableScope.getMouseEventTarget(e),s=t instanceof Element?t:null,o=(f=s==null?void 0:s.closest)==null?void 0:f.call(s,"[data-col-index]"),i=(g=o==null?void 0:o.closest("[data-area]"))==null?void 0:g.getAttribute("data-area"),r=(p=o==null?void 0:o.closest("[data-row-index]"))==null?void 0:p.getAttribute("data-row-index");if(!s||!o||!i||r===null||r===void 0)return;const l=this.tableScope.createGeMouseEvent(e),a=Number(r),c=Number(o.getAttribute("data-col-index")),h=vt(i);let d,u=!1;if(h==="body"){const m=this.tableScope.tableModel.getBodyModel();d=this.rowAt(m,a),u=typeof d=="object"&&d!==null&&this.rowAt(m,a)===d}return{target:s,areaIdent:h,sideIdent:l.sideIdent,rowIdx:a,colIdx:c,action:l.action,row:d,stableRow:u,clientX:e.clientX,clientY:e.clientY}}checkLostClick(e,t){if(e.target.isConnected)return;const s=t.clientX-e.clientX,o=t.clientY-e.clientY;if(s*s+o*o>this.clickMoveTolerance*this.clickMoveTolerance)return;const i=this.nativeClickCount,r=this.nativeDblClickCount;clearTimeout(this.lostClickTimer),this.lostClickTimer=setTimeout(()=>{if(this.lostClickTimer=void 0,this.nativeClickCount!==i||this.tableScope.isDestroyed()||this.isBlocked(t))return;const l=this.resolveRowIndex(e);if(l<0)return;const a={areaIdent:e.areaIdent,sideIdent:e.sideIdent,rowIdx:l,colIdx:e.colIdx,action:e.action};this.handleClick(t,e.target,a),t.detail===2&&this.nativeDblClickCount===r&&this.handleDblClick(t,e.target,a)},0)}resolveRowIndex(e){if(e.areaIdent!=="body"||!e.stableRow)return e.rowIdx;const t=this.tableScope.tableModel.getBodyModel();if(this.rowAt(t,e.rowIdx)===e.row)return e.rowIdx;const s=t.getRowCount();for(let o=1;o<s;o++){const i=e.rowIdx-o,r=e.rowIdx+o;if(i<0&&r>=s)break;if(i>=0&&this.rowAt(t,i)===e.row)return i;if(r<s&&this.rowAt(t,r)===e.row)return r}return-1}rowAt(e,t){try{return e.getRowByIndex(t)}catch{return}}mouseDraggingOnFrame(){var e;if(this.mouseEvent){const t=this.tableScope.createGeMouseEvent(this.mouseEvent);(e=this.startMouseEvent)!=null&&e.originalEvent&&(t.draggingX=this.mouseEvent.clientX-this.startMouseEvent.originalEvent.clientX,t.draggingY=this.mouseEvent.clientY-this.startMouseEvent.originalEvent.clientY),this.tableScope.mouseDraggingOnFrame(t,this.startMouseEvent)}}flushDraggingEnd(){var s;const e=this.pendingDraggingEnd;if(!e)return;this.pendingDraggingEnd=void 0,cancelAnimationFrame(e.frameId),this.dragGeneration++;const t=this.tableScope.createGeMouseEvent(e.evt);(s=e.start)!=null&&s.originalEvent&&(t.draggingX=e.evt.clientX-e.start.originalEvent.clientX,t.draggingY=e.evt.clientY-e.start.originalEvent.clientY),this.tableScope.mouseDraggingEndOnFrame(t)}mouseMoveOnFrame(){if(this.mouseEvent){const e=this.tableScope.createGeMouseEvent(this.mouseEvent);this.tableScope.mouseMove(e)}}isButtonDown(){return this.mouseDown}isBlocked(e){var t,s,o;return(((t=this.tableScope.tableOverlay)==null?void 0:t.isEventBlocked(e))??!1)||!!((o=(s=this.tableScope).isEventInDetail)!=null&&o.call(s,e))}}const $r=()=>!1;function Hr(n){return n.editable===void 0||n.editable===$r}function ai(n){return typeof n=="number"&&!Number.isNaN(n)}function Ca(n){if(ai(n))return n;if(n instanceof Date){const e=n.getTime();return Number.isNaN(e)?void 0:e}}function ci(n,e){const t=n.sum,s=t+e;Number.isFinite(s)&&(n.compensation+=Math.abs(t)>=Math.abs(e)?t-s+e:e-s+t),n.sum=s}function Gr(n){return Number.isFinite(n.sum)?n.sum+n.compensation:n.sum}function Wr(n,e){ci(n,e.sum),n.compensation+=e.compensation}const Sa={name:"sum",init:()=>({sum:0,compensation:0}),add:(n,e)=>(ai(e)&&ci(n,e),n),merge:(n,e)=>(Wr(n,e),n),result:n=>Gr(n)},xa={name:"count",init:()=>0,add:n=>n+1,merge:(n,e)=>n+e,result:n=>n},va={name:"avg",init:()=>({sum:0,compensation:0,count:0}),add:(n,e)=>(ai(e)&&(ci(n,e),n.count++),n),merge:(n,e)=>(Wr(n,e),n.count+=e.count,n),result:n=>n.count?Gr(n)/n.count:void 0};function $i(n,e){return{name:n,init:()=>({has:!1,value:void 0,key:0}),add:(t,s)=>{const o=Ca(s);return o!==void 0&&(!t.has||e(o,t.key))&&(t.has=!0,t.value=s,t.key=o),t},merge:(t,s)=>(s.has&&(!t.has||e(s.key,t.key))&&(t.has=!0,t.value=s.value,t.key=s.key),t),result:t=>t.has?t.value:void 0}}const Ra={name:"countDistinct",init:()=>({values:new Set,dates:new Set}),add:(n,e)=>(e instanceof Date?n.dates.add(e.getTime()):e!=null&&n.values.add(e),n),merge:(n,e)=>(e.values.forEach(t=>n.values.add(t)),e.dates.forEach(t=>n.dates.add(t)),n),result:n=>n.values.size+n.dates.size},Aa={name:"first",init:()=>({has:!1,value:void 0}),add:(n,e)=>(n.has||(n.has=!0,n.value=e),n),merge:(n,e)=>(!n.has&&e.has&&(n.has=!0,n.value=e.value),n),result:n=>n.value},Ea={name:"last",init:()=>({has:!1,value:void 0}),add:(n,e)=>(n.has=!0,n.value=e,n),merge:(n,e)=>(e.has&&(n.has=!0,n.value=e.value),n),result:n=>n.value},Oe=Object.freeze({sum:Sa,count:xa,avg:va,min:$i("min",(n,e)=>n<e),max:$i("max",(n,e)=>n>e),countDistinct:Ra,first:Aa,last:Ea});function Xs(n){if(typeof n!="string")return n;const e=Oe[n];if(!e)throw new Error(`Unknown aggregator "${n}" – use one of: ${Object.keys(Oe).join(", ")}, or an own AggregatorIf.`);return e}function as(n){if(typeof n=="function")return n;const e=n.split(".");return e.length===1?t=>t==null?void 0:t[n]:t=>{let s=t;for(const o of e){if(s==null)return;s=s[o]}return s}}function cs(n,e){const t=typeof e=="string"||!("aggregator"in e)?{aggregator:e}:e,s=Xs(t.aggregator),o=t.value??n;return{key:n,aggregator:s,value:o,getValue:s===Oe.count?void 0:as(o),format:t.format}}function Ys(n,e){const t=e.map(o=>o.aggregator.init()),s=e.length;for(let o=0;o<n.length;o++){const i=n[o];for(let r=0;r<s;r++){const l=e[r];t[r]=l.aggregator.add(t[r],l.getValue?l.getValue(i):i)}}return t}function Ma(n,e){const t=e.map(o=>o.aggregator.init()),s=e.length;for(let o=0;o<n;o++)for(let i=0;i<s;i++){const r=e[i];t[i]=r.aggregator.add(t[i],r.getValue?r.getValue(o):o)}return t}function Ta(n,e,t){const s=cs("",{aggregator:t,value:e}),[o]=Ys(n,[s]);return s.aggregator.result(o)}function Ia(n,e){const t=Object.keys(e).map(i=>cs(i,e[i])),s=Ys(n,t),o={};return t.forEach((i,r)=>o[i.key]=i.aggregator.result(s[r])),o}const Da=new Intl.NumberFormat("en-US",{maximumFractionDigits:2});function kt(n){return n==null?"":typeof n=="number"?Number.isFinite(n)?Da.format(n):String(n):n instanceof Date?Number.isNaN(n.getTime())?"":n.toLocaleDateString("en-US"):String(n)}const ka=new Set(["percentOfColumnTotal","percentOfGrandTotal","percentOfParentTotal","percentOfRowTotal"]),Hi=new Map,Fa=new Intl.NumberFormat("en-US",{maximumFractionDigits:0});function Ft(n){if(!n)return;const e=typeof n=="string"?{mode:n}:n;return Ur.includes(e.mode)?e:void 0}const Ur=Object.freeze(["percentOfColumnTotal","percentOfGrandTotal","percentOfParentTotal","percentOfRowTotal","differenceFromPrevious","runningTotal","rank"]);function hi(n){return!!n&&ka.has(n)}function Js(n,e){const t=Ft(e);if(typeof n!="number"||Number.isNaN(n)||!t)return n==null?"":`${n}`;if(t.format)return`${t.format(n)??""}`;if(hi(t.mode)){const s=Gi(t.fractionDigits??1);let o=Hi.get(s);return o||(o=new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:s,maximumFractionDigits:s}),Hi.set(s,o)),o.format(n)}if(t.mode==="rank")return Fa.format(n);if(t.fractionDigits!==void 0){const s=Gi(t.fractionDigits);return new Intl.NumberFormat("en-US",{minimumFractionDigits:s,maximumFractionDigits:s}).format(n)}return kt(n)}function Gi(n){return Math.min(10,Math.max(0,Math.trunc(Number(n)||0)))}function at(n){return typeof n=="number"&&!Number.isNaN(n)}function qs(n){const e=Oe.sum;let t=e.init();for(let s=0;s<n.length;s++)t=e.add(t,n[s]);return e.result(t)??0}function di(n,e){const t=n.length,s=new Array(t);switch(e){case"percentOfColumnTotal":case"percentOfGrandTotal":case"percentOfParentTotal":{const o=qs(n);for(let i=0;i<t;i++)s[i]=La(n[i],o);return s}case"runningTotal":{const o=Oe.sum;let i=o.init();for(let r=0;r<t;r++){const l=n[r];i=o.add(i,l),s[r]=at(l)?o.result(i):void 0}return s}case"differenceFromPrevious":for(let o=0;o<t;o++){const i=n[o],r=o>0?n[o-1]:void 0;s[o]=at(i)&&at(r)?i-r:void 0}return s;case"rank":{const o=[];for(let r=0;r<t;r++)at(n[r])&&o.push(r);o.sort((r,l)=>n[l]-n[r]);let i=0;for(let r=0;r<o.length;r++)(r===0||n[o[r]]!==n[o[r-1]])&&(i=r+1),s[o[r]]=i;return s}default:for(let o=0;o<t;o++)s[o]=at(n[o])?n[o]:void 0;return s}}function La(n,e){return at(n)&&e!==0?n/e:void 0}class I{constructor(e,t,s){this.code=e,this.message=t,this.position=s,this.type="FormulaError"}toString(){return this.code}}function w(n){return!!n&&typeof n=="object"&&n.type==="FormulaError"}class Oa{constructor(e){this.owner=e,this.defsLength=-1,this.computing=new Map,this.contexts=new Map,this.aggregates=new Map,this.aggSignal=void 0,this.aggLength=-1}invalidate(){this.getters=void 0,this.showValuesAs=void 0,this.properties=void 0,this.aggregates.clear()}getter(e){if(e!==void 0)return this.lookup().get(e)}hasGetters(){return this.lookup().size>0}isCalculated(e){return this.lookup().has(e)}hasColumn(e){return this.lookup(),this.properties.has(e)}getShowValuesAs(e){if(e!==void 0)return this.lookup(),this.showValuesAs.get(e)}hasShowValuesAs(){return this.lookup(),this.showValuesAs.size>0}get(e,t){const s=this.lookup().get(t);if(!s)return this.owner.readPath(e,t);if(e!=null)return this.call(s,e,t)}aggregate(e,t){var c;if((c=this.computing.get(e))!=null&&c.size)return new I("#CIRC!",`Circular reference: the column "${e}" uses its own aggregate`);const s=this.owner.getAggregationSource();(s.signal!==this.aggSignal||s.length!==this.aggLength)&&(this.aggregates.clear(),this.aggSignal=s.signal,this.aggLength=s.length);const o=Xs(t),i=`${o.name}\0${e}`;if(this.aggregates.has(i))return this.aggregates.get(i);const r=s.rows();let l=o.init(),a;for(let h=0;h<r.length;h++){const d=this.get(r[h],e);if(w(d)&&d.code==="#CIRC!"){a=d;break}l=o.add(l,d)}return a===void 0&&(a=o.result(l)),this.aggregates.set(i,a),a}context(e){let t=this.contexts.get(e);return t||(t={property:e,getValue:(s,o)=>this.get(s,o),hasColumn:s=>this.hasColumn(s),isCalculated:s=>{var o,i;return this.isCalculated(s)||!!((i=(o=this.owner).isSheetFormula)!=null&&i.call(o,s))},aggregate:(s,o)=>this.aggregate(s,o)},this.contexts.set(e,t)),t}call(e,t,s){let o=this.computing.get(s);if(o!=null&&o.has(t))return new I("#CIRC!",`Circular reference: the column "${s}" depends on itself`);o||(o=new Set,this.computing.set(s,o)),o.add(t);try{return e(t,this.context(s))}catch(i){return new I("#VALUE!",`valueGetter of "${s}": ${i instanceof Error?i.message.slice(0,200):"failed"}`)}finally{o.delete(t)}}lookup(){const e=this.owner.getColumnDefsForValues()??[];if(this.getters&&this.defsLength===e.length)return this.getters;const t=new Map,s=new Map,o=new Set;for(const i of e){if(!i)continue;o.add(i.property),typeof i.valueGetter=="function"&&t.set(i.property,i.valueGetter);const r=Ft(i.showValuesAs);r&&s.set(i.property,r)}return this.getters=t,this.showValuesAs=s,this.properties=o,this.defsLength=e.length,t}}class Lt{constructor(){this.type="AggregateCellRenderer"}render(e,t,s,o,i,r,l){const a=i.getTextValueAt(t,s);if(!a)return;const c=l.createElement("div");l.addClass(c,"ge-table-label-div");const h=l.createElement("div");l.addClass(h,"ge-table-label"),l.setAttribute(h,"data-row-index",`${t}`),l.setAttribute(h,"data-col-index",`${s}`),l.setAttribute(h,"data-area",o),l.appendChild(h,l.createText(a)),l.appendChild(c,h),l.appendChild(e,c)}}class hs{constructor(e,t=[],s=-1){this.areaIdent=e,this.columnDefs=t,this.defaultRowHeight=s,this.rowSelectionModel=void 0,this.yPositions=[],this.defaultEditable=!1,this.cellRenderers=t.map(o=>o.rendererMap[e])}getTextValueAt(e,t){return""+this.getValueAt(e,t)}getTooltipAt(e,t){var s;if((s=this.sheetCells)!=null&&s.isFormulaColumnIndex(t)){const o=this.getValueAt(e,t);if(w(o))return o.message}return""}getCellRenderer(e,t){if(t<this.cellRenderers.length)return this.cellRenderers[t]}getColspanAt(e,t){return 0}getCustomClassesAt(e,t){var s;return(s=this.sheetCells)!=null&&s.isFormulaColumnIndex(t)&&w(this.getValueAt(e,t))?["ge-table-cell-error"]:[]}getCustomStyleAt(e,t){}getRowspanAt(e,t){return 0}getRowByIndex(e){}isRowCheckable(e){return!0}isRowChecked(e){var s;const t=this.getRowByIndex(e);return(s=this.rowSelectionModel)==null?void 0:s.isRowChecked(t)}setRowChecked(e,t){if(this.rowSelectionModel){const s=this.getRowByIndex(e);this.rowSelectionModel.checkRow(s,t)}}getMaxColspan(){return 31}getMaxRowspan(){return 31}getYPosByRowIndex(e){var o;const t=(o=this.getConstantRowHeight)==null?void 0:o.call(this);if(t!==void 0&&t>0)return t*e;let s=0;for(let i=0;i<e;i++)s+=this.getRowHeight(i);return s}init(){!this.yPositions.length&&this.getRowCount()!==void 0&&this.defaultRowHeight===-1&&this.calcYPositions()}isFilterable(){return this.areaIdent==="body"}doSort(e){return!1}sort(e){}isEditable(e,t){var o,i;const s=(o=this.columnDefs)==null?void 0:o[t];return this.areaIdent==="body"&&(s!=null&&s.valueGetter)&&!s.valueSetter?!1:this.defaultEditable&&this.areaIdent==="body"&&s&&Hr(s)?!be(s)&&!O(s)&&!ot(s):((i=s==null?void 0:s.editable)==null?void 0:i.call(s))??!1}setValue(e,t,s){var a;const o=(a=this.columnDefs[t])==null?void 0:a.editInputPipe;o&&(s=o(s,e,t));const i=this.getRowByIndex(e),r=this.columnDefs[t];if(this.areaIdent==="body"&&(r!=null&&r.valueGetter))return this.setCalculatedValue(i,r,s);const l=this.columnDefs[t].property;return l.includes(".")?this.setPropertyValue(i,l.split("."),s):(i[l]=s,!0)}isSelectable(e,t){return!0}changeColumnOrder(e,t){this.arrayMove(this.cellRenderers,e,t)}setPropertyValue(e,t,s){const o=t.shift();if(o){const i=e[o];return i&&t.length?this.setPropertyValue(i,t,s):(e[o]=s,!0)}return!1}arrayMove(e,t,s){const o=e.splice(t,1)[0];return e.splice(s,0,o),e}calcYPositions(){const e=this.getRowCount();this.yPositions=new Array(e+1),this.yPositions[0]=0;for(let t=0;t<e;t++)this.yPositions[t+1]=this.getRowHeight(t)+this.yPositions[t]}isCalculatedProperty(e){var t;return this.getColumnValues().isCalculated(e)||!!((t=this.sheetCells)!=null&&t.isFormulaProperty(e))}getRowValue(e,t){U(e)&&(e=e.data);const s=this.getColumnValues().get(e,t);return this.sheetCells&&typeof s=="string"?this.sheetCells.valueOfProperty(e,t,s):s}hasDerivedColumns(){const e=this.getColumnValues();return e.hasGetters()||e.hasShowValuesAs()}isDerivedProperty(e){const t=this.getColumnValues();return t.isCalculated(e)||!!t.getShowValuesAs(e)}getColumnValues(){return this.columnValuesInstance??(this.columnValuesInstance=new Oa({getColumnDefsForValues:()=>this.areaIdent==="body"?this.columnDefs:[],readPath:(e,t)=>{const s=this.readPropertyPath(e,t);return this.sheetCells&&typeof s=="string"?this.sheetCells.valueOfProperty(e,t,s):s},getAggregationSource:()=>this.getAggregationSourceForValues(),isSheetFormula:e=>{var t;return!!((t=this.sheetCells)!=null&&t.isFormulaProperty(e))}}))}invalidateColumnValues(){var e;(e=this.columnValuesInstance)==null||e.invalidate()}readPropertyPath(e,t){if(e==null||!t)return;let s=e;for(const o of t.split(".")){if(s==null)return;s=s[o]}return s}getAggregationSourceForValues(){const e=this.getRowCount();return{signal:void 0,length:e,rows:()=>Array.from({length:e},(t,s)=>this.getRowByIndex(s))}}setCalculatedValue(e,t,s){return!t.valueSetter||e===void 0||e===null?!1:(U(e)&&(e=e.data),t.valueSetter(e,s)!==!1)}getCalculatedText(e,t){if(e===void 0)return;const s=this.getColumnValues(),o=s.getShowValuesAs(e),i=s.isCalculated(e);if(i&&w(t))return t.code;if(o)return Js(t,o);if(i)return t==null?"":`${t}`}getCalculatedRenderer(e){if(e!==void 0&&this.getColumnValues().getShowValuesAs(e))return this.calcTextRenderer??(this.calcTextRenderer=new Lt)}addCalculatedClasses(e,t,s){return t!==void 0&&this.getColumnValues().isCalculated(t)&&w(s())?[...e,"ge-table-cell-error"]:e}}class ui{genericSortComparator(e,t,s){if(typeof e=="number"&&typeof t=="number")return s*(e-t);if(typeof e=="string"&&typeof t=="string")return s*e.localeCompare(t);if(typeof e=="boolean"&&typeof t=="boolean")return s*((e?-1:1)-(t?-1:1));if(e instanceof Date&&t instanceof Date)return s*(e.getTime()-t.getTime());if(e instanceof Array&&t instanceof Array){const o=e,i=t;if(o.length&&i.length)return this.genericSortComparator(o[0],i[0],s)}return s*(""+e).localeCompare(""+t)}}function it(n,e){return Na(n,e)?n:Array.from(new Set(n)).filter(t=>Number.isInteger(t)&&t>=0&&t<e).sort((t,s)=>t-s)}function Na(n,e){let t=-1;for(const s of n){if(!Number.isInteger(s)||s<=t||s>=e)return!1;t=s}return!0}function fi(n){return n.position==="before"?n.rowIndex:n.rowIndex+1}function Do(n,e){if(!n.length)return-1;const t=fi(e);return t-n.filter(s=>s<t).length}function Kr(n,e,t){const s=it(e,n.length);if(!s.length)return-1;const o=Math.min(Math.max(0,t),n.length),i=new Uint8Array(n.length);s.forEach(h=>i[h]=1);const r=new Array(s.length);s.forEach((h,d)=>r[d]=n[h]);const l=[];let a=-1;for(let h=0;h<=n.length;h++)h===o&&(a=l.length),h<n.length&&!i[h]&&l.push(n[h]);let c=0;for(let h=0;h<a;h++)n[c++]=l[h];for(const h of r)n[c++]=h;for(let h=a;h<l.length;h++)n[c++]=l[h];return a}function gi(n){const e=new Set(n);return n.filter(t=>{for(let s=t.parent;s;s=s.parent)if(e.has(s))return!1;return!0})}function pi(n,e){if(!e||!n.length)return!1;const t=new Set(n);for(let s=e;s;s=s.parent)if(t.has(s))return!1;return!0}function zr(n,e,t,s){const o=gi(e);if(!pi(o,t))return!1;for(const a of o){const c=a.parent?a.parent.children:n,h=(c==null?void 0:c.indexOf(a))??-1;c&&h>-1&&c.splice(h,1)}let i,r,l;s==="inside"?(i=t,t.children=t.children??[],r=t.children,l=r.length,t.expanded=!0):(i=t.parent,r=i?i.children??(i.children=[]):n,l=r.indexOf(t)+(s==="after"?1:0)),r.splice(l,0,...o);for(const a of o)a.parent=i,jr(a,i?i.deep+1:0);return!0}function jr(n,e){n.deep=e;for(const t of n.children??[])jr(t,e+1)}function Zs(n,e,t,s){return n===e&&s.position!=="inside"&&Number.isInteger(s.rowIndex)&&s.rowIndex>=0&&s.rowIndex<n&&it(t,n).length>0}function mi(n,e,t,s){if(!Zs(n.length,e.length,t,s))return!1;if(Kr(n,it(t,n.length),fi(s)),e!==n)for(let o=0;o<n.length;o++)e[o]=n[o];return!0}function Pa(n,e,t,s){if(e<1)return-1;if(s&&s>0)return Math.min(e-1,Math.max(0,Math.floor(n/s)));let o=0,i=e-1;for(;o<i;){const r=o+i+1>>1;t(r)<=n?o=r:i=r-1}return o}const Va=new Int32Array(0);class K extends hs{constructor(e,t,s,o=[],i="ge-selected-row",r="ge-focused-row"){super(e,o,s),this.areaIdent=e,this.rows=t,this.defaultRowHeight=s,this.columnDefs=o,this.selectedRowClass=i,this.focusedRowClass=r,this.sorterService=new ui,this.displayInDataOrder=!0,this.showValuesCache=new Map,this._focusedRowIndex=0,this.filteredRows=[...t],this.properties=o.map(l=>l.property)}getFocusedRowIndex(){return this._focusedRowIndex}setFocusedRowIndex(e){this._focusedRowIndex=e}setRows(e){this.rows=e,this.filteredRows=[...e],this.displayInDataOrder=!0,this.showValuesCache.clear()}appendRows(e,t={}){const s=this.rows,o=t.maxRows!==void 0&&t.maxRows>=0?Math.floor(t.maxRows):Number.POSITIVE_INFINITY,i=Math.max(0,s.length+e.length-o),r=i>0?Math.max(i,Math.ceil(o/100)):0,l=Math.min(r,s.length),a=Math.max(0,i-l),c=l>0?this.removeFirstRows(l):Va,h=[],d=t.filter;for(let f=a;f<e.length;f++){const g=e[f];s.push(g),(!d||d(g))&&h.push(g)}const u=t.compare?this.mergeSorted(h,t.compare):this.appendShown(h);return(h.length||c.length)&&this.showValuesCache.clear(),{added:e.length-a,shown:h.length,removed:l,removedPositions:c,insertedPositions:u}}removeFirstRows(e){const t=this.rows.splice(0,e),s=this.filteredRows;if(this.displayInDataOrder){let l=0;for(let c=0;c<t.length&&l<s.length;c++)s[l]===t[c]&&l++;s.splice(0,l);const a=new Int32Array(l);for(let c=0;c<l;c++)a[c]=c;return a}const o=new Set(t),i=[];let r=0;for(let l=0;l<s.length;l++){const a=s[l];o.has(a)?i.push(l):s[r++]=a}return s.length=r,Int32Array.from(i)}appendShown(e){const t=this.filteredRows,s=new Int32Array(e.length);for(let o=0;o<e.length;o++)s[o]=t.length,t.push(e[o]);return s}mergeSorted(e,t){const s=this.filteredRows,o=e.length,i=new Int32Array(o);if(!o)return i;e.sort(t),this.displayInDataOrder=!1;let r=s.length;for(let l=0;l<o;l++)s.push(e[l]);for(let l=o-1;l>=0;l--){const a=e[l];let c=0,h=r;for(;c<h;){const d=c+h>>>1;t(s[d],a)>0?h=d:c=d+1}c<r&&s.copyWithin(c+l+1,c,r),s[c+l]=a,i[l]=c+l,r=c}return i}createSortComparator(e){const t=e.filter(({sortState:s})=>s==="asc"||s==="desc").map(({columnIndex:s,sortState:o})=>this.genericFlatTableSortComparator(this.properties[s],o==="asc"?1:-1));if(t.length)return(s,o)=>{for(const i of t){const r=i(s,o);if(r)return r}return 0}}filterRowsByPredict(e){this.rows=this.rows.filter(e),this.filteredRows=this.filteredRows.filter(e)}getRowCount(){var e;return((e=this.filteredRows)==null?void 0:e.length)??0}getUnfilteredRowCount(){var e;return((e=this.rows)==null?void 0:e.length)??0}canMoveRows(e,t){return Zs(this.filteredRows.length,this.rows.length,e,t)}moveRows(e,t){const s=mi(this.filteredRows,this.rows,e,t);return s&&(this.displayInDataOrder=!0,this.invalidateDerivedValues()),s}getValueAt(e,t){const s=this.properties[t];let o=this.filteredRows[e];if(U(o)&&(o=o.data),o){const i=this.getValueByT(o,s),r=this.getColumnValues().getShowValuesAs(s);return r?this.applyShowValuesAs(e,s,i,r):i}return""}getTextValueAt(e,t){const s=this.getValueAt(e,t);return this.getCalculatedText(this.properties[t],s)??""+s}getCellRenderer(e,t){return super.getCellRenderer(e,t)??this.getCalculatedRenderer(this.properties[t])}getTooltipAt(e,t){const s=this.properties[t];if(s!==void 0&&this.getColumnValues().isCalculated(s)){const o=this.getValueAt(e,t);if(w(o))return o.message}return super.getTooltipAt(e,t)}invalidateDerivedValues(e){this.invalidateColumnValues(),this.showValuesCache.clear()}applyShowValuesAs(e,t,s,o){if(w(s))return s;let i=this.showValuesCache.get(t);switch(i||(i={},this.showValuesCache.set(t,i)),o.mode){case"percentOfColumnTotal":case"percentOfGrandTotal":case"percentOfParentTotal":return i.total===void 0&&(i.total=qs(this.filteredRows.map(r=>this.getValueByT(U(r)?r.data:r,t)))),typeof s=="number"&&!Number.isNaN(s)&&i.total!==0?s/i.total:void 0;case"percentOfRowTotal":return s;default:return(!i.values||i.values.length!==this.filteredRows.length)&&(i.values=di(this.filteredRows.map(r=>this.getValueByT(U(r)?r.data:r,t)),o.mode)),i.values[e]}}readPropertyPath(e,t){return t.includes(".")?this.getPropertyValue(e,t.split(".")):e[t]}getAggregationSourceForValues(){const e=this.filteredRows;return{signal:e,length:e.length,rows:()=>e.some(t=>U(t))?e.map(t=>U(t)?t.data:t):e}}getFilteredRows(){return this.filteredRows}getAllRows(){return this.rows}findRowFromFilteredRowsByAllCriteria(e,t){return this.getFilteredRows().find(s=>t(e,s))}findRowFromAllRowsByAllCriteria(e,t){return this.getAllRows().find(s=>t(e,s))}getRowHeight(e){return this.defaultRowHeight}getConstantRowHeight(){return this.getRowHeight===K.prototype.getRowHeight&&this.defaultRowHeight>0?this.defaultRowHeight:void 0}getRowByIndex(e){return this.filteredRows[e]}externalFilterChanged(e){this.filteredRows=this.rows?this.rows.filter(e):[],this.displayInDataOrder=!0,this.showValuesCache.clear()}doSort(e){const t=e.map(({columnIndex:s,sortState:o})=>{const i=o==="asc"?1:o==="desc"?-1:0;return this.genericFlatTableSortComparator(this.properties[s],i)});return this.showValuesCache.clear(),e.some(({sortState:s})=>s==="asc"||s==="desc")&&(this.displayInDataOrder=!1),t.length&&(this.filteredRows=this.filteredRows.sort((s,o)=>{for(const i of t){const r=i(s,o);if(r)return r}return 0})),!0}sort(e){this.displayInDataOrder=!1,this.filteredRows=this.filteredRows.sort(e),this.showValuesCache.clear()}getValueByT(e,t){if(!e||!t)return;const s=this.getColumnValues();if(s.getter(t))return s.get(e,t);const o=t.includes(".")?this.getPropertyValue(e,t.split(".")):e[t];return this.sheetCells&&typeof o=="string"?this.sheetCells.valueOfProperty(e,t,o):o}getInputValueAt(e,t){const s=this.sheetCells;this.sheetCells=void 0;try{return this.getValueAt(e,t)}finally{this.sheetCells=s}}changeColumnOrder(e,t){this.arrayMove(this.properties,e,t),super.changeColumnOrder(e,t)}getCustomClassesAt(e,t){let s=super.getCustomClassesAt(e,t);return s=this.addCalculatedClasses(s,this.properties[t],()=>this.getValueAt(e,t)),this.getRowByIndex(e).selected&&s.push(this.selectedRowClass),this._focusedRowIndex===e&&s.push(this.focusedRowClass),s}genericFlatTableSortComparator(e,t){const s=this.columnDefs.find(r=>r.property===e),o=this.createSortValueReader(e),i=this.getColumnValues().isCalculated(e);return(r,l)=>{const a=o(r),c=o(l);return i&&(a===void 0||c===void 0)?a===c?0:a===void 0?1:-1:s!=null&&s.sortComparator?t*s.sortComparator(a,c,r,l,t):this.sorterService.genericSortComparator(a,c,t)}}createSortValueReader(e){if(!this.getColumnValues().getter(e))return s=>this.getValueByT(s,e);const t=new Map;return s=>{if(t.has(s))return t.get(s);const o=this.getValueByT(s,e),i=w(o)?void 0:o;return t.set(s,i),i}}getPropertyValue(e,t){const s=t.shift(),o=e[s];return o&&t.length?this.getPropertyValue(o,t):o}}class M{constructor(e,t,s,o,i=!1){this.r1=e,this.c1=t,this.r2=s,this.c2=o,this.gammaRange=i}static create(e){return e.gammaRange===void 0&&(e.gammaRange=!1),new M(e.rowIndex1,e.columnIndex1,e.rowIndex2,e.columnIndex2,e.gammaRange)}static singleCell(e,t){return new M(e,t,e,t)}static singleRow(e){return new M(e,0,e,Number.MAX_SAFE_INTEGER)}static singleColumn(e){return new M(0,e,Number.MAX_SAFE_INTEGER,e)}isInRange(e,t){return e>=this.r1&&e<=this.r2&&t>=this.c1&&t<=this.c2}}const _s=class _s{aggregate(e,t){const s={count:0,numericCount:0,sum:0,avg:void 0,min:void 0,max:void 0,capped:!1};if(!(t!=null&&t.hasSelection()))return s;const o=e.getBodyModel(),i=o.getRowCount(),r=e.getColumnCount(),l=(t.isAllSelected()?[new M(0,0,i-1,r-1)]:t.getRanges()).map(p=>({r1:Math.max(0,Math.min(p.r1,p.r2)),r2:Math.min(i-1,Math.max(p.r1,p.r2)),columns:this.dataColumns(e,Math.max(0,Math.min(p.c1,p.c2)),Math.min(r-1,Math.max(p.c1,p.c2)))})).filter(p=>p.r2>=p.r1&&p.columns.length);if(l.reduce((p,m)=>p+(m.r2-m.r1+1)*m.columns.length,0)>_s.maxCells)return s.capped=!0,s;const{sum:c,min:h,max:d}=Oe;let u=c.init(),f=h.init(),g=d.init();return l.forEach((p,m)=>{const b=l.slice(0,m);for(let y=p.r1;y<=p.r2;y++)for(const C of p.columns){if(b.length&&b.some(A=>y>=A.r1&&y<=A.r2&&A.columns.includes(C))||!t.isSelected(y,C))continue;s.count++;const S=o.getValueAt(y,C);typeof S=="number"&&!Number.isNaN(S)&&(s.numericCount++,u=c.add(u,S),f=h.add(f,S),g=d.add(g,S))}}),s.numericCount&&(s.sum=c.result(u),s.avg=s.sum/s.numericCount,s.min=h.result(f),s.max=d.result(g)),s}dataColumns(e,t,s){var i;const o=[];for(let r=t;r<=s;r++){const l=e.getColumnDef(r);((i=l==null?void 0:l.isVisible)==null?void 0:i.call(l))===!1||O(l)||be(l)||o.push(r)}return o}};_s.maxCells=1e6;let Es=_s;function _a(n){const e=Ft(n);if(!e||!hi(e.mode))return;const t=Math.min(10,Math.max(0,Math.trunc(Number(e.fractionDigits??1)||0)));return t?`0.${"0".repeat(t)}%`:"0%"}const ie=1048576,q=16384;function Ne(n){if(!Number.isInteger(n)||n<0||n>=q)return"";let e="",t=n+1;for(;t>0;){const s=(t-1)%26;e=String.fromCharCode(65+s)+e,t=Math.floor((t-1)/26)}return e}function Fe(n){if(!/^[A-Za-z]{1,3}$/.test(n))return-1;let e=0;for(const t of n.toUpperCase())e=e*26+(t.charCodeAt(0)-64);return e-1<q?e-1:-1}function mt(n,e,t={}){const s=Ne(e);return!s||!Number.isInteger(n)||n<0||n>=ie?"#REF!":`${t.absCol?"$":""}${s}${t.absRow?"$":""}${n+1}`}function Ue(n){const e=/^(\$?)([A-Za-z]{1,3})(\$?)([1-9]\d{0,6})$/.exec(n.trim());if(!e)return;const t=Fe(e[2]),s=Number(e[4])-1;if(!(t<0||s>=ie))return{row:s,col:t,absRow:e[3]==="$",absCol:e[1]==="$"}}function Xr(n){const e=n.trim(),t=e.split(":");if(t.length===1){const c=Ue(e);return c?{from:c,to:{...c}}:void 0}if(t.length!==2)return;const s=Ue(t[0]),o=Ue(t[1]);if(s&&o)return{from:{row:Math.min(s.row,o.row),col:Math.min(s.col,o.col),absRow:s.absRow,absCol:s.absCol},to:{row:Math.max(s.row,o.row),col:Math.max(s.col,o.col),absRow:o.absRow,absCol:o.absCol}};const i=/^(\$?)([A-Za-z]{1,3})$/.exec(t[0]),r=/^(\$?)([A-Za-z]{1,3})$/.exec(t[1]);if(i&&r){const c=Fe(i[2]),h=Fe(r[2]);return c<0||h<0?void 0:{from:{row:0,col:Math.min(c,h),absRow:!1,absCol:i[1]==="$"},to:{row:ie-1,col:Math.max(c,h),absRow:!1,absCol:r[1]==="$"},wholeColumns:!0}}const l=/^(\$?)([1-9]\d{0,6})$/.exec(t[0]),a=/^(\$?)([1-9]\d{0,6})$/.exec(t[1]);if(l&&a){const c=Number(l[2])-1,h=Number(a[2])-1;return c>=ie||h>=ie?void 0:{from:{row:Math.min(c,h),col:0,absRow:l[1]==="$",absCol:!1},to:{row:Math.max(c,h),col:q-1,absRow:a[1]==="$",absCol:!1},wholeRows:!0}}}class B extends Error{constructor(e,t){super(e),this.pos=t}toFormulaError(){return new I("#ERROR!",`${this.message} (at ${this.pos+1})`,this.pos)}}const Ba=["<=",">=","<>","!=","==","+","-","*","/","^","&","=","<",">"],$a=["<=",">=","<>","+","-","*","/","^","&","=","<",">",":","%"],Ha=/^#(REF!|N\/A|DIV\/0!|VALUE!|NAME\?|NUM!|NULL!|CIRC!|ERROR!)/i,Ga={n:`
42
42
  `,t:" ",r:"\r","\\":"\\",'"':'"',"'":"'"};function he(n){return n>="0"&&n<="9"}function es(n){return n>="a"&&n<="z"||n>="A"&&n<="Z"||n==="_"}function Yr(n){return es(n)||he(n)||n==="."}function Wa(n,e=!1){if(e)return Ua(n);const t=[],s=n.length;let o=0;for(;o<s;){const i=n[o];if(i===" "||i===" "||i===`
43
43
  `||i==="\r"){o++;continue}const r=o;if(he(i)||i==="."&&o+1<s&&he(n[o+1])){for(;o<s&&he(n[o]);)o++;if(n[o]===".")for(o++;o<s&&he(n[o]);)o++;if(n[o]==="e"||n[o]==="E"){let c=o+1;if((n[c]==="+"||n[c]==="-")&&c++,c<s&&he(n[c]))for(o=c;o<s&&he(n[o]);)o++}if(o<s&&(es(n[o])||n[o]==="."))throw new B(`Invalid number "${n.slice(r,o+1)}"`,r);const a=n.slice(r,o);t.push({kind:"number",text:a,value:Number(a),pos:r});continue}if(i==='"'||i==="'"){o++;let a="",c=!1;for(;o<s;){const h=n[o];if(h==="\\"){const d=n[o+1];if(d===void 0)break;a+=Ga[d]??d,o+=2;continue}if(h===i){c=!0,o++;break}a+=h,o++}if(!c)throw new B("Unterminated text",r);t.push({kind:"string",text:a,pos:r});continue}if(i==="["){o++;let a="",c=!1;for(;o<s;){const d=n[o];if(d==="\\"&&o+1<s){a+=n[o+1],o+=2;continue}if(d==="]"){c=!0,o++;break}if(d==="[")break;a+=d,o++}if(!c)throw new B("Unterminated field reference, missing ]",r);const h=a.trim();if(!h)throw new B("Empty field reference []",r);t.push({kind:"field",text:h,pos:r});continue}if(es(i)){for(;o<s&&Yr(n[o]);)o++;t.push({kind:"ident",text:n.slice(r,o),pos:r});continue}if(i==="("||i===")"||i===","){t.push({kind:i,text:i,pos:r}),o++;continue}const l=Ba.find(a=>n.startsWith(a,o));if(l){t.push({kind:"op",text:l,pos:r}),o+=l.length;continue}throw new B(`Unexpected character "${i}"`,r)}return t.push({kind:"eof",text:"",pos:s}),t}function Ua(n){const e=[],t=n.length;let s=0;for(;s<t;){const o=n[s];if(o===" "||o===" "||o===`
44
44
  `||o==="\r"){s++;continue}const i=s;if(he(o)||o==="."&&s+1<t&&he(n[s+1])){for(;s<t&&he(n[s]);)s++;if(n[s]===".")for(s++;s<t&&he(n[s]);)s++;if(n[s]==="e"||n[s]==="E"){let a=s+1;if((n[a]==="+"||n[a]==="-")&&a++,a<t&&he(n[a]))for(s=a;s<t&&he(n[s]);)s++}if(s<t&&(es(n[s])||n[s]==="."||n[s]==="$"))throw new B(`Invalid number "${n.slice(i,s+1)}"`,i);const l=n.slice(i,s);e.push({kind:"number",text:l,value:Number(l),pos:i});continue}if(o==='"'){s++;let l="",a=!1;for(;s<t;){if(n[s]==='"'){if(n[s+1]==='"'){l+='"',s+=2;continue}a=!0,s++;break}l+=n[s++]}if(!a)throw new B("Unterminated text",i);e.push({kind:"string",text:l,pos:i});continue}if(o==="["){const l=n.indexOf("]",s+1),a=l<0?"":n.slice(s+1,l);if(l<0||a.includes("["))throw new B("Unterminated field reference, missing ]",i);const c=a.trim();if(!c)throw new B("Empty field reference []",i);e.push({kind:"field",text:c,pos:i}),s=l+1;continue}if(o==="#"){const l=Ha.exec(n.slice(s));if(!l)throw new B('Unexpected character "#"',i);e.push({kind:"error",text:l[0].toUpperCase(),pos:i}),s+=l[0].length;continue}if(es(o)||o==="$"){for(;s<t&&(Yr(n[s])||n[s]==="$");)s++;e.push({kind:"ident",text:n.slice(i,s),pos:i});continue}if(o==="("||o===")"||o===","){e.push({kind:o,text:o,pos:i}),s++;continue}if(o===";"){e.push({kind:",",text:";",pos:i}),s++;continue}const r=$a.find(l=>n.startsWith(l,s));if(r){e.push({kind:"op",text:r,pos:i}),s+=r.length;continue}throw new B(`Unexpected character "${o}"`,i)}return e.push({kind:"eof",text:"",pos:t}),e}const uo=1e4,Wi=64,Ui=1e3,Ka={"=":{bp:10,op:"="},"==":{bp:10,op:"="},"<>":{bp:10,op:"<>"},"!=":{bp:10,op:"<>"},"<":{bp:10,op:"<"},"<=":{bp:10,op:"<="},">":{bp:10,op:">"},">=":{bp:10,op:">="},"&":{bp:20,op:"&"},"+":{bp:30,op:"+"},"-":{bp:30,op:"-"},"*":{bp:40,op:"*"},"/":{bp:40,op:"/"},"^":{bp:60,right:!0,op:"^"}},za=50,ja=75,Xa=70,Ya=80;class Ja{constructor(e,t=!1){this.tokens=e,this.references=t,this.index=0,this.depth=0,this.operators=0}parse(){if(this.peek().kind==="eof")throw new B("Empty formula",0);const e=this.expression(0),t=this.peek();if(t.kind!=="eof")throw new B(`Unexpected "${t.text}"`,t.pos);return e}peek(){return this.tokens[this.index]}next(){return this.tokens[this.index++]}enter(e){if(++this.depth>Wi)throw new B(`Nested too deeply (more than ${Wi} levels)`,e)}expression(e){let t=this.prefix();for(;;){const s=this.peek();if(s.kind!=="op")break;if(this.references&&s.text==="%"){if(Xa<=e)break;this.next(),t={kind:"unary",op:"%",operand:t};continue}if(this.references&&s.text===":"){if(Ya<=e)break;this.next(),t=this.range(t,s.pos);continue}const o=Ka[s.text];if(!o||o.bp<=e)break;if(this.next(),++this.operators>Ui)throw new B(`Too many operators (more than ${Ui})`,s.pos);this.enter(s.pos);const i=this.expression(o.right&&!this.references?o.bp-1:o.bp);this.depth--,t={kind:"binary",op:o.op,left:t,right:i}}return t}prefix(){const e=this.next();switch(e.kind){case"number":return this.references&&this.peekRangeOp()&&/^\d+$/.test(e.text)?this.rowRef(e.text,e.pos):{kind:"literal",value:e.value};case"string":return{kind:"literal",value:e.text};case"field":return{kind:"field",name:e.text};case"error":return{kind:"error",code:e.text};case"op":if(e.text==="-"||e.text==="+"){this.enter(e.pos);const t=this.expression(this.references?ja:za);return this.depth--,{kind:"unary",op:e.text,operand:t}}throw new B(`Unexpected "${e.text}"`,e.pos);case"(":{this.enter(e.pos);const t=this.expression(0);return this.depth--,this.expect(")","Missing )"),t}case"ident":return this.identifier(e);case"eof":throw new B("Unexpected end of formula",e.pos);default:throw new B(`Unexpected "${e.text}"`,e.pos)}}identifier(e){const t=e.text.toUpperCase();if(this.references&&this.peek().kind!=="("){if(t==="TRUE")return{kind:"literal",value:!0};if(t==="FALSE")return{kind:"literal",value:!1};const o=Ue(e.text);if(o)return{kind:"ref",row:o.row,col:o.col,absRow:o.absRow,absCol:o.absCol};if(this.peekRangeOp()){const i=/^(\$?)([A-Za-z]{1,3})$/.exec(e.text);if(i&&Fe(i[2])>=0)return{kind:"ref",row:-1,col:Fe(i[2]),absRow:!1,absCol:i[1]==="$"};const r=/^\$(\d+)$/.exec(e.text);if(r)return this.rowRef(r[1],e.pos,!0)}return{kind:"error",code:"#NAME?",message:`Unknown name "${e.text}"`,text:e.text}}if(this.references&&t.includes("$"))throw new B(`Unexpected "${e.text}"`,e.pos);if(this.peek().kind!=="("){if(t==="TRUE")return{kind:"literal",value:!0};if(t==="FALSE")return{kind:"literal",value:!1};throw new B(`Unknown name "${e.text}" – fields are written in brackets: [${e.text}]`,e.pos)}this.next(),this.enter(e.pos);const s=[];if(this.peek().kind!==")")for(;;){const o=this.peek().kind;if(s.push(this.references&&(o===","||o===")")?{kind:"literal",value:null}:this.expression(0)),this.peek().kind===","){this.next();continue}break}return this.expect(")",`Missing ) after the arguments of ${t}`),this.depth--,{kind:"call",name:t,args:s}}peekRangeOp(){const e=this.peek();return e.kind==="op"&&e.text===":"}rowRef(e,t,s=!1){const o=Number(e)-1;if(!(o>=0&&o<ie))throw new B(`Invalid row "${e}"`,t);return{kind:"ref",row:o,col:-1,absRow:s,absCol:!1}}rangeOperand(){const e=this.next();if(e.kind==="number"&&/^\d+$/.test(e.text))return this.rowRef(e.text,e.pos);if(e.kind==="ident"){const t=Ue(e.text);if(t)return{kind:"ref",row:t.row,col:t.col,absRow:t.absRow,absCol:t.absCol};const s=/^(\$?)([A-Za-z]{1,3})$/.exec(e.text);if(s&&Fe(s[2])>=0)return{kind:"ref",row:-1,col:Fe(s[2]),absRow:!1,absCol:s[1]==="$"};const o=/^\$(\d+)$/.exec(e.text);if(o)return this.rowRef(o[1],e.pos,!0)}throw new B("A range needs two cells, columns or rows (A1:B5, A:A, 3:3)",e.pos)}range(e,t){const s=this.rangeOperand();if(e.kind!=="ref"||s.kind!=="ref")throw new B("A range needs two cells, columns or rows (A1:B5, A:A, 3:3)",t);const o=c=>c.row<0?"col":c.col<0?"row":"cell";if(o(e)!==o(s))throw new B("A range needs two cells, columns or rows (A1:B5, A:A, 3:3)",t);const[i,r]=e.row<=s.row?[e,s]:[s,e],[l,a]=e.col<=s.col?[e,s]:[s,e];return{kind:"range",from:{kind:"ref",row:i.row,col:l.col,absRow:i.absRow,absCol:l.absCol},to:{kind:"ref",row:r.row,col:a.col,absRow:r.absRow,absCol:a.absCol}}}expect(e,t){const s=this.peek();if(s.kind!==e)throw new B(t,s.pos);this.next()}}function ds(n,e=!1){if(n.length>uo)throw new B(`Formula too long (more than ${uo} characters)`,uo);return new Ja(Wa(n,e),e).parse()}const qa=/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i;function ut(n){return n===null||n===""}function Ms(n,e,t=!1){if(n==null)return null;switch(typeof n){case"number":return Number.isNaN(n)?null:n;case"string":case"boolean":return n;case"bigint":return Number(n)}if(t&&w(n))return n;if(n instanceof Date){const s=n.getTime();return Number.isNaN(s)?null:s}return new I("#VALUE!",`[${e}] is not a number, text or boolean`)}function oe(n){if(typeof n=="number")return n;if(n===null||n==="")return 0;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const e=n.trim();if(qa.test(e)){const t=Number(e);if(Number.isFinite(t))return t}return new I("#VALUE!",`"${n.length>40?n.slice(0,40)+"…":n}" is not a number`)}return n}function ke(n){return typeof n=="string"?n:n===null?"":typeof n=="number"?String(n):typeof n=="boolean"?n?"TRUE":"FALSE":n}function ko(n){if(typeof n=="boolean")return n;if(n===null||n==="")return!1;if(typeof n=="number")return n!==0;if(typeof n=="string"){const e=n.trim().toUpperCase();return e==="TRUE"?!0:e==="FALSE"?!1:new I("#VALUE!",`"${n.length>40?n.slice(0,40)+"…":n}" is not TRUE or FALSE`)}return n}function de(n){return Number.isFinite(n)?n===0?0:n:new I("#NUM!","The result is not a finite number")}function Za(n,e){if(w(n))return n;if(w(e))return e;if(ut(n)&&ut(e))return 0;const t=typeof n=="string"&&!ut(n),s=typeof e=="string"&&!ut(e);if(t||s){if(t&&s){const u=n.toLowerCase(),f=e.toLowerCase();return u<f?-1:u>f?1:0}const r=oe(n),l=oe(e);if(!w(r)&&!w(l))return r-l;const a=ke(n),c=ke(e),h=a.toLowerCase(),d=c.toLowerCase();return h<d?-1:h>d?1:0}const o=oe(n),i=oe(e);return o-i}const Jr={IF:{min:2,max:3},IFERROR:{min:2,max:2},AND:{min:1,max:255},OR:{min:1,max:255}},Qa={SUM:"sum",AVG:"avg",AVERAGE:"avg",MIN:"min",MAX:"max",COUNT:"count"};function gs(n){const e=[];for(const t of n){if(ut(t))continue;const s=oe(t);if(w(s))return s;e.push(s)}return e}function fo(n){return{min:1,max:1,fn:e=>{const t=oe(e[0]);return w(t)?t:de(n(t))}}}function bi(n,e){const t=Math.trunc(e),s=Math.pow(10,t);if(s===0)return 0;const o=Math.abs(n)*s;if(!Number.isFinite(o))return n;const i=Math.round(o>=1e15?o:Number(o.toPrecision(15)))/s;return n<0?-i:i}const ts={ABS:fo(Math.abs),FLOOR:fo(Math.floor),CEILING:fo(Math.ceil),SQRT:{min:1,max:1,fn:n=>{const e=oe(n[0]);return w(e)?e:e<0?new I("#NUM!","SQRT of a negative number"):Math.sqrt(e)}},ROUND:{min:1,max:2,fn:n=>{const e=oe(n[0]);if(w(e))return e;const t=n.length>1?oe(n[1]):0;return w(t)?t:de(bi(e,t))}},MOD:{min:2,max:2,fn:n=>{const e=oe(n[0]);if(w(e))return e;const t=oe(n[1]);return w(t)?t:t===0?new I("#DIV/0!","MOD by zero"):de(e-t*Math.floor(e/t))}},POWER:{min:2,max:2,fn:n=>{const e=oe(n[0]);if(w(e))return e;const t=oe(n[1]);return w(t)?t:de(Math.pow(e,t))}},SUM:{min:1,max:255,fn:n=>{const e=gs(n);return w(e)?e:de(e.reduce((t,s)=>t+s,0))}},AVG:{min:1,max:255,fn:n=>{const e=gs(n);return w(e)?e:e.length?de(e.reduce((t,s)=>t+s,0)/e.length):new I("#DIV/0!","AVG of no numbers")}},MIN:{min:1,max:255,fn:n=>{const e=gs(n);return w(e)?e:e.length?Math.min(...e):0}},MAX:{min:1,max:255,fn:n=>{const e=gs(n);return w(e)?e:e.length?Math.max(...e):0}},COUNT:{min:1,max:255,fn:n=>n.filter(e=>typeof e=="number").length},NOT:{min:1,max:1,fn:n=>{const e=ko(n[0]);return w(e)?e:!e}},CONCAT:{min:1,max:255,fn:n=>{let e="";for(const t of n){const s=ke(t);if(w(s))return s;e+=s}return e}},LEN:{min:1,max:1,fn:n=>{const e=ke(n[0]);return w(e)?e:e.length}},UPPER:{min:1,max:1,fn:n=>{const e=ke(n[0]);return w(e)?e:e.toUpperCase()}},LOWER:{min:1,max:1,fn:n=>{const e=ke(n[0]);return w(e)?e:e.toLowerCase()}},TRIM:{min:1,max:1,fn:n=>{const e=ke(n[0]);return w(e)?e:e.trim().replace(/\s+/g," ")}},ISBLANK:{min:1,max:1,fn:n=>ut(n[0])}};ts.AVERAGE=ts.AVG;const ec=new Set(["__proto__","constructor","prototype"]),tc=(n,e)=>Object.prototype.hasOwnProperty.call(n,e);function sc(n,e,t,s=e.split(".")){if(t!=null&&t.isCalculated(e))return Ms(t.getValue(n,e),e,!0);if(s.some(i=>ec.has(i)))return new I("#NAME?",`Unknown field [${e}]`);let o=n;for(let i=0;i<s.length;i++){if(o==null||typeof o!="object")return null;if(!tc(o,s[i]))return i===0&&!(t!=null&&t.hasColumn(e))?new I("#NAME?",`Unknown field [${e}]`):null;o=o[s[i]]}return Ms(o,e)}function Ki(n,e,t){if(w(e))return e;if(w(t))return t;if(n==="&"){const i=ke(e);if(w(i))return i;const r=ke(t);return w(r)?r:i+r}if(n==="="||n==="<>"||n==="<"||n==="<="||n===">"||n===">="){const i=Za(e,t);if(w(i))return i;switch(n){case"=":return i===0;case"<>":return i!==0;case"<":return i<0;case"<=":return i<=0;case">":return i>0;default:return i>=0}}const s=typeof e=="number"?e:oe(e);if(w(s))return s;const o=typeof t=="number"?t:oe(t);if(w(o))return o;switch(n){case"+":return de(s+o);case"-":return de(s-o);case"*":return de(s*o);case"/":return o===0?new I("#DIV/0!","Division by zero"):de(s/o);default:return de(Math.pow(s,o))}}function oc(n,e){return n==null?null:typeof n=="number"?Number.isNaN(n)?new I("#NUM!",`${e} returned NaN`):n:typeof n=="string"||typeof n=="boolean"||w(n)?n:n instanceof Date?Ms(n,e):new I("#VALUE!",`${e} returned no number, text or boolean`)}function zi(n,e,t){const s=new Array(n.length);for(let o=0;o<n.length;o++){const i=n[o](e,t);if(w(i))return i;s[o]=i}return s}class ic{constructor(e){this.functions=e}compile(e){const t=this.node(e);return(s,o)=>{try{const i=t(s,o);return typeof i=="number"?de(i):i}catch(i){return new I("#VALUE!",i instanceof Error?i.message.slice(0,200):"Evaluation failed")}}}evaluate(e,t,s){return this.compile(e)(t,s)}node(e){switch(e.kind){case"literal":{const t=e.value;return()=>t}case"field":{const t=e.name,s=t.split(".");return(o,i)=>sc(o,t,i,s)}case"unary":{const t=this.node(e.operand),s=e.op==="-";return(o,i)=>{const r=t(o,i),l=typeof r=="number"?r:oe(r);return w(l)?l:s?-l:l}}case"binary":{const t=this.node(e.left),s=this.node(e.right),o=e.op;return o==="*"||o==="+"||o==="-"?(i,r)=>{const l=t(i,r),a=s(i,r);return typeof l=="number"&&typeof a=="number"?de(o==="*"?l*a:o==="+"?l+a:l-a):Ki(o,l,a)}:(i,r)=>Ki(o,t(i,r),s(i,r))}case"call":return this.call(e.name,e.args);default:{const t=new I("#ERROR!","Cell references are not allowed in column formulas");return()=>t}}}call(e,t){const s=this.functions.get(e);if(s){const a=t.map(c=>this.node(c));return(c,h)=>{const d=zi(a,c,h);if(w(d))return d;try{return oc(s(...d),e)}catch(u){return new I("#VALUE!",`${e}: ${u instanceof Error?u.message.slice(0,200):"failed"}`)}}}switch(e){case"IF":{const[a,c,h]=t.map(d=>this.node(d));return(d,u)=>{const f=ko(a(d,u));return w(f)?f:f?c(d,u):h?h(d,u):!1}}case"IFERROR":{const[a,c]=t.map(h=>this.node(h));return(h,d)=>{const u=a(h,d);return w(u)?c(h,d):u}}case"AND":case"OR":{const a=e==="AND",c=t.map(h=>this.node(h));return(h,d)=>{for(const u of c){const f=ko(u(h,d));if(w(f))return f;if(a&&!f)return!1;if(!a&&f)return!0}return a}}}const o=Qa[e],i=t[0];if(o&&t.length===1&&i.kind==="field"){const a=i.name;return(c,h)=>{if(!h)return new I("#VALUE!",`${e}([${a}]) needs the rows of a table`);if(!h.hasColumn(a))return new I("#NAME?",`Unknown column [${a}] in ${e}`);const d=h.aggregate(a,o);return d===void 0?o==="avg"?new I("#DIV/0!","AVG of no numbers"):0:Ms(d,a,!0)}}const r=ts[e];if(!r){const a=new I("#NAME?",`Unknown function ${e}`);return()=>a}const l=t.map(a=>this.node(a));return(a,c)=>{const h=zi(l,a,c);return w(h)?h:r.fn(h)}}}const rc=Object.freeze([...Object.keys(ts),...Object.keys(Jr)].sort());function $t(n,e,t,s){switch(n.kind){case"literal":return;case"field":t.includes(n.name)||t.push(n.name);return;case"unary":return $t(n.operand,e,t,s);case"binary":return $t(n.left,e,t,s)??$t(n.right,e,t,s);case"call":{if(!e.has(n.name)){const o=ts[n.name]??Jr[n.name];if(!o)return new I("#NAME?",`Unknown function ${n.name}`);if(n.args.length<o.min||n.args.length>o.max){const i=o.min===o.max?`${o.min}`:o.max>=255?`at least ${o.min}`:`${o.min} to ${o.max}`;return new I("#ERROR!",`${n.name} needs ${i} argument${o.max===1?"":"s"}, got ${n.args.length}`)}["SUM","AVG","AVERAGE","MIN","MAX","COUNT"].includes(n.name)&&n.args.length===1&&n.args[0].kind==="field"&&(s.aggregates=!0)}for(const o of n.args){const i=$t(o,e,t,s);if(i)return i}return}default:return new I("#ERROR!","Cell references are not allowed in column formulas")}}function wi(n,e){let t="";const s=new Map;for(const c of Object.keys((e==null?void 0:e.functions)??{})){const h=e.functions[c];typeof h=="function"&&s.set(c.toUpperCase(),h)}let o,i;const r=[],l={aggregates:!1};let a;try{t=typeof n=="string"?n:String(n??"");const c=t.replace(/^\s+/,"");o=ds(c.startsWith("=")&&!c.startsWith("==")?c.slice(1):t),i=$t(o,s,r,l),i||(a=new ic(s).compile(o))}catch(c){i=c instanceof B?c.toFormulaError():new I("#ERROR!","Invalid formula")}return i&&(o=void 0,r.length=0),i&&(a=void 0),Object.freeze({source:t,ast:o,error:i,fields:Object.freeze([...r]),usesAggregates:l.aggregates,evaluate:(c,h)=>a?a(c,h):i})}function yi(n,e){const t=typeof n=="string"?wi(n,e):n;return(s,o)=>t.evaluate(s,o)}const nc={"=":10,"<>":10,"<":10,"<=":10,">":10,">=":10,"&":20,"+":30,"-":30,"*":40,"/":40,"^":60};function go(n){return n.row<0?`${n.absCol?"$":""}${Ne(n.col)}`:n.col<0?`${n.absRow?"$":""}${n.row+1}`:n.row>=ie||n.col>=q?"#REF!":`${n.absCol?"$":""}${Ne(n.col)}${n.absRow?"$":""}${n.row+1}`}function lc(n){return String(n)}function ct(n,e){switch(n.kind){case"literal":return n.value===null?"":typeof n.value=="string"?`"${n.value.replace(/"/g,'""')}"`:typeof n.value=="boolean"?n.value?"TRUE":"FALSE":lc(n.value);case"field":return`[${n.name}]`;case"ref":return go(n);case"range":return`${go(n.from)}:${go(n.to)}`;case"error":return n.text??n.code;case"call":return`${n.name}(${n.args.map(t=>ct(t,0)).join(",")})`;case"unary":{if(n.op==="%")return`${ct(n.operand,70)}%`;const t=ct(n.operand,75);return`${n.op}${t}`}case"binary":{const t=nc[n.op],s=`${ct(n.left,t)}${n.op}${ct(n.right,t+1)}`;return t<e?`(${s})`:s}}}function Ut(n){return ct(n,0)}const ac=new Set(["XLOOKUP","IFS","SWITCH","TEXTJOIN","CONCAT","IFNA","XOR"]);function cc(n,e){let t;try{t=ds(n.slice(1),!0)}catch{return}let s=!0;const o=(l,a)=>({...l,row:l.row<0?e.dRow+(a?e.rows-1:0):l.row+e.dRow,col:l.col<0?e.dCol+(a?e.cols-1:0):l.col+e.dCol,absRow:l.row<0?!0:l.absRow,absCol:l.col<0?!0:l.absCol}),i=l=>{switch(l.kind){case"field":return s=!1,l;case"ref":return o(l,!1);case"range":return{kind:"range",from:o(l.from,!1),to:o(l.to,!0)};case"unary":return{...l,operand:i(l.operand)};case"binary":return{...l,left:i(l.left),right:i(l.right)};case"call":return{...l,name:ac.has(l.name)?`_xlfn.${l.name}`:l.name,args:l.args.map(i)};default:return l}},r=i(t);return s?Ut(r):void 0}class Q extends hs{constructor(e,t,s,o=[]){super(e,o,s),this.areaIdent=e,this.arr=t,this.defaultRowHeight=s,this.columnDefs=o,this.filteredArr=[...t]}externalFilterChanged(e){this.filteredArr=this.arr?this.arr.filter(e):[]}getRowCount(){return this.filteredArr?this.filteredArr.length:0}getUnfilteredRowCount(){var e;return((e=this.arr)==null?void 0:e.length)??0}canMoveRows(e,t){return Zs(this.filteredArr.length,this.arr.length,e,t)}moveRows(e,t){return mi(this.filteredArr,this.arr,e,t)}getValueAt(e,t){const s=this.filteredArr[e],o=s[t];return this.sheetCells&&typeof o=="string"?this.sheetCells.valueAt(s,t,o):o}getInputValueAt(e,t){var s;return(s=this.filteredArr[e])==null?void 0:s[t]}setValue(e,t,s){var r;const o=(r=this.columnDefs[t])==null?void 0:r.editInputPipe;o&&(s=o(s,e,t));const i=this.filteredArr[e];return i?(i[t]=s,!0):!1}getRowByIndex(e){return this.filteredArr[e]}getRowHeight(e){return this.defaultRowHeight}getConstantRowHeight(){return this.getRowHeight===Q.prototype.getRowHeight&&this.defaultRowHeight>0?this.defaultRowHeight:void 0}changeColumnOrder(e,t){const s=new Set,o=i=>{i&&!s.has(i)&&(s.add(i),this.arrayMove(i,e,t))};(this.arr??[]).forEach(o),this.filteredArr.forEach(o),super.changeColumnOrder(e,t)}}class Rt{constructor(e){this.serial=e,this.type="SheetDate"}toDate(){return Ci(this.serial)}}function G(n){return!!n&&typeof n=="object"&&n.type==="SheetDate"&&typeof n.serial=="number"}const qr=864e5,Zr=Date.UTC(1899,11,30);function Ot(n){const e=n.getTime();if(Number.isNaN(e))return NaN;let s=(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds())-Zr)/qr;return s<61&&(s-=1),s}function Ci(n){const e=n<60?n+1:n>=60&&n<61?61+(n-60):n,t=new Date(Zr+Math.round(e*qr));return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}function Kt(n,e,t){return Ot(new Date(n,e-1,t))}function et(n){if(Math.floor(n)===60)return{y:1900,m:2,d:29};const e=Ci(Math.floor(n));return{y:e.getFullYear(),m:e.getMonth()+1,d:e.getDate()}}class tt{constructor(e,t,s,o,i){this.row=e,this.col=t,this.rows=s,this.cols=o,this.read=i,this.type="FormulaRange"}get(e,t){return e<0||t<0||e>=this.rows||t>=this.cols?null:this.read(this.row+e,this.col+t)}values(){const e=[];for(let t=0;t<this.rows;t++)for(let s=0;s<this.cols;s++)e.push(this.get(t,s));return e}}function Ye(n){return!!n&&typeof n=="object"&&n.type==="FormulaRange"}function ve(n){if(n===0||!Number.isFinite(n))return n===0?0:n;const e=Number(n.toPrecision(15));return e===0?0:e}function W(n){return Number.isFinite(n)?ve(n):new I("#NUM!","The result is not a finite number")}const ji=/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i,hc=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function At(n){const e=hc.exec(n);if(!e)return;const t=new Date(+e[1],+e[2]-1,+e[3],+(e[4]??0),+(e[5]??0),+(e[6]??0));if(t.getMonth()===+e[2]-1)return Ot(t)}function Qr(n){if(n==null)return null;switch(typeof n){case"number":return Number.isNaN(n)?null:n;case"string":return n;case"boolean":return n;case"bigint":return Number(n)}if(w(n)||G(n))return n;if(n instanceof Date){const e=Ot(n);return Number.isNaN(e)?null:new Rt(e)}return new I("#VALUE!","The cell holds no number, text or boolean")}function _(n){return Ye(n)?n.rows===1&&n.cols===1?_(n.get(0,0)):new I("#VALUE!","A range where one value is expected"):n}function z(n,e){const t=_(n);if(typeof t=="number")return t;if(t===null||t==="")return 0;if(typeof t=="boolean")return t?1:0;if(G(t))return t.serial;if(typeof t=="string"){const s=t.trim();if(ji.test(s)){const o=Number(s);if(Number.isFinite(o))return o}if(s.endsWith("%")&&ji.test(s.slice(0,-1).trim()))return Number(s.slice(0,-1).trim())/100;if(e.isoDatesAsDates){const o=At(s);if(o!==void 0)return o}return new I("#VALUE!",`"${t.length>40?t.slice(0,40)+"…":t}" is not a number`)}return t}function Xi(n){const e=ve(n),t=Math.abs(e);return t!==0&&(t>=1e15||t<1e-9)?e.toExponential().replace("e","E"):String(e)}function re(n){const e=_(n);return typeof e=="string"?e:e===null?"":typeof e=="number"?Xi(e):typeof e=="boolean"?e?"TRUE":"FALSE":G(e)?Xi(e.serial):e}function ft(n){const e=_(n);if(typeof e=="boolean")return e;if(e===null||e==="")return!1;if(typeof e=="number")return e!==0;if(G(e))return e.serial!==0;if(typeof e=="string"){const t=e.trim().toUpperCase();return t==="TRUE"?!0:t==="FALSE"?!1:new I("#VALUE!",`"${e.length>40?e.slice(0,40)+"…":e}" is not TRUE or FALSE`)}return e}function Yi(n){return typeof n=="string"?1:typeof n=="boolean"?2:0}function us(n,e){let t=_(n),s=_(e);if(w(t))return t;if(w(s))return s;if(G(t)&&(t=t.serial),G(s)&&(s=s.serial),t===null&&s===null)return 0;t===null&&(t=typeof s=="string"?"":typeof s=="boolean"?!1:0),s===null&&(s=typeof t=="string"?"":typeof t=="boolean"?!1:0);const o=Yi(t),i=Yi(s);if(o!==i)return o-i;if(typeof t=="number"&&typeof s=="number"){const r=ve(t)-ve(s);return r===0?0:r<0?-1:1}if(typeof t=="string"&&typeof s=="string"){const r=t.toLowerCase(),l=s.toLowerCase();return r<l?-1:r>l?1:0}return(t?1:0)-(s?1:0)}function Fo(n){return n===null||n===""}function Ji(n){return G(n)?n.toDate():Ye(n)?_(n):n}class Pe extends hs{constructor(e,t,s,o,i,r=[],l=0){super(e,r,i),this.rowCount=s,this.columnCount=o,this.columnOffset=l,this.version=0,this.rows=new Map,this.physicalOfArray=new Map,this.setSheetData(t,s,o)}setSheetData(e,t=this.rowCount,s=this.columnCount){this.rows.clear(),this.physicalOfArray.clear(),e.forEach((o,i)=>{if(o&&o.some(r=>r!=null&&r!=="")){const r=[...o];this.rows.set(i,r),this.physicalOfArray.set(r,i)}}),this.rowCount=Math.max(t,e.length),this.columnCount=Math.max(s,e.reduce((o,i)=>Math.max(o,(i==null?void 0:i.length)??0),0)),this.perm=void 0,this.inverse=void 0,this.version++}getSheetData(){let e=-1,t=-1;this.rows.forEach((o,i)=>{for(let r=o.length-1;r>=0;r--)if(!Vt(o[r])){e=Math.max(e,i),t=Math.max(t,r);break}});const s=[];for(let o=0;o<=e;o++){const i=this.rows.get(o);s.push(Array.from({length:t+1},(r,l)=>i&&!Vt(i[l])?i[l]:""))}return s}getCell(e,t){var s;return(s=this.rows.get(e))==null?void 0:s[t]}setCell(e,t,s){let o=this.rows.get(e);if(!o){if(Vt(s))return;o=[],this.rows.set(e,o),this.physicalOfArray.set(o,e)}o[t]=s}getRowArray(e){return this.rows.get(e)}forEachCell(e){this.rows.forEach((t,s)=>t.forEach((o,i)=>e(s,i,o)))}getPhysicalRowOfArray(e){return this.physicalOfArray.get(e)}getSheetColumnCount(){return this.columnCount}setColumnDefs(e){this.columnDefs=e,this.cellRenderers=e.map(t=>{var s;return(s=t.rendererMap)==null?void 0:s[this.areaIdent]})}getRowCount(){return this.perm?this.perm.length:this.rowCount}getUnfilteredRowCount(){return this.rowCount}getPhysicalRowIndex(e){return this.perm?this.perm[e]:e}getDisplayRowIndex(e){return this.perm?(this.inverse||(this.inverse=new Map,this.perm.forEach((t,s)=>this.inverse.set(t,s))),this.inverse.get(e)??-1):e<this.rowCount?e:-1}getValueAt(e,t){const s=this.rows.get(this.getPhysicalRowIndex(e)),o=s==null?void 0:s[t-this.columnOffset];return o==null?"":this.sheetCells&&typeof o=="string"?this.sheetCells.valueAt(s,t,o):o}getInputValueAt(e,t){var s;return((s=this.rows.get(this.getPhysicalRowIndex(e)))==null?void 0:s[t-this.columnOffset])??""}getTextValueAt(e,t){const s=this.getValueAt(e,t);return w(s)?s.code:String(s)}setValue(e,t,s){var i;const o=(i=this.columnDefs[t])==null?void 0:i.editInputPipe;return o&&(s=o(s,e,t)),t<this.columnOffset||e<0||e>=this.getRowCount()?!1:(this.setCell(this.getPhysicalRowIndex(e),t-this.columnOffset,s),!0)}getRowByIndex(e){return this.rows.get(this.getPhysicalRowIndex(e))}getRowHeight(e){return this.defaultRowHeight}getConstantRowHeight(){return this.defaultRowHeight>0?this.defaultRowHeight:void 0}getMaxColspan(){return 1}getMaxRowspan(){return 1}externalFilterChanged(e){const t=[];for(let s=0;s<this.rowCount;s++)e(this.rows.get(s)??[],s,[])&&t.push(s);this.perm=t.length===this.rowCount?void 0:Int32Array.from(t),this.inverse=void 0}doSort(e){const t=e.filter(o=>o.sortState==="asc"||o.sortState==="desc"),s=this.perm?Array.from(this.perm):Array.from({length:this.rowCount},(o,i)=>i);return s.sort((o,i)=>{for(const{columnIndex:r,sortState:l}of t){const a=this.valueOfPhysical(o,r),c=this.valueOfPhysical(i,r),h=a===""||w(a),d=c===""||w(c);if(h||d){if(h!==d)return h?1:-1;continue}const u=us(a,c),f=typeof u=="number"?u:0;if(f)return l==="asc"?f:-f}return o-i}),!t.length&&s.length===this.rowCount?(this.perm=void 0,this.inverse=void 0,!0):(this.perm=Int32Array.from(s),this.inverse=void 0,!0)}insertRows(e,t){this.shiftRows(e,t),this.rowCount+=t}deleteRows(e,t){const s=[];for(let o=e;o<e+t;o++){const i=this.rows.get(o);i&&(s.push([o-e,i]),this.physicalOfArray.delete(i),this.rows.delete(o))}return this.shiftRows(e+t,-t),this.rowCount=Math.max(0,this.rowCount-t),s}restoreRows(e,t,s){this.insertRows(e,t);for(const[o,i]of s)this.rows.set(e+o,i),this.physicalOfArray.set(i,e+o)}insertColumns(e,t){this.rows.forEach(s=>{s.length>e&&s.splice(e,0,...new Array(t))}),this.columnCount+=t,this.changed()}deleteColumns(e,t){const s=[];return this.rows.forEach(o=>{const i=o.splice(e,t);i.some(r=>!Vt(r))&&s.push([o,i])}),this.columnCount=Math.max(0,this.columnCount-t),this.changed(),s}restoreColumns(e,t,s){this.insertColumns(e,t);for(const[o,i]of s)i.forEach((r,l)=>{o[e+l]=r})}getContentExtent(){let e=-1,t=-1;return this.rows.forEach((s,o)=>{let i=-1;for(let l=s.length-1;l>=0;l--)if(!Vt(s[l])){i=l;break}if(i<0)return;const r=this.getDisplayRowIndex(o);r<0||(e=Math.max(e,r),t=Math.max(t,i+this.columnOffset))}),[e,t]}valueOfPhysical(e,t){const s=this.rows.get(e),o=s==null?void 0:s[t-this.columnOffset];return o==null?"":this.sheetCells&&typeof o=="string"?this.sheetCells.valueAt(s,t,o):o}shiftRows(e,t){const s=Array.from(this.rows).filter(([o])=>o>=e).sort((o,i)=>t>0?i[0]-o[0]:o[0]-i[0]);for(const[o]of s)this.rows.delete(o);for(const[o,i]of s)this.rows.set(o+t,i),this.physicalOfArray.set(i,o+t);this.changed()}changed(){this.perm=void 0,this.inverse=void 0,this.version++}}function Vt(n){return n==null||n===""}class Ts{constructor(e=0,t=0,s=0,o=0){this.top=e,this.right=t,this.bottom=s,this.left=o}}class Le{constructor(e=34,t=34,s=34){this.header=e,this.body=t,this.footer=s}}class en{constructor(){this.checkedRows=[]}getCheckedRows(){return this.checkedRows}setCheckedRows(e){this.checkedRows=e}addCheckedRows(e){this.checkedRows||(this.checkedRows=[]);for(const t of e)this.checkedRows.includes(t)||this.checkedRows.push(t)}checkRow(e,t){this.checkedRows||(this.checkedRows=[]),t?this.checkedRows.includes(e)||this.checkedRows.push(e):this.removeSelectedRow(e)}isRowChecked(e){return this.checkedRows&&this.checkedRows.includes(e)?"full":"none"}checkAll(e){this.checkedRows=[]}removeSelectedRow(e){if(this.checkedRows){const t=this.checkedRows.indexOf(e);t>-1&&this.checkedRows.splice(t,1)}}}class Et{constructor(e=[]){this.allRootNodes=e}checkRow(e,t){this.setCheckedRecursive(e,t),this.autoCheckParent(e.parent)}checkAll(e=this.allRootNodes){for(const s of e)this.uncheckRecursive(s);const t=new Set;for(const s of e)s.parent&&t.add(s.parent);t.forEach(s=>this.autoCheckParent(s))}getCheckedRows(){const e=[];return this.addSelectedRecursive(this.allRootNodes,e),e}isRowChecked(e){return e.checked?"full":this.hasMixedDescendants(e)?"semi":"none"}hasMixedDescendants(e){let t=!1,s=!1;const o=i=>{for(const r of i??[])if(r.checked?t=!0:s=!0,t&&s||o(r.children))return!0;return!1};return o(e.children)}setCheckedRecursive(e,t){if(e.checked=t,e.children)for(const s of e.children)this.setCheckedRecursive(s,t)}setCheckedRows(e){this.addCheckedRows(e)}addCheckedRows(e){for(const t of e)t.checked=!0}autoCheckParent(e){if(e){const t=this.areAllChildrenChecked(e),s=this.areAllChildrenUnchecked(e);t?e.checked=!0:e.checked=!1,this.autoCheckParent(e.parent)}}areAllChildrenChecked(e){var t,s;if((t=e.children)!=null&&t.length){for(const o of e.children)if(!o.checked||(s=o.children)!=null&&s.length&&!this.areAllChildrenChecked(o))return!1}return!0}areAllChildrenUnchecked(e){var t,s;if((t=e.children)!=null&&t.length){for(const o of e.children)if(o.checked||(s=o.children)!=null&&s.length&&!this.areAllChildrenUnchecked(o))return!1}return!0}uncheckRecursive(e){if(e.checked=!1,e.children)for(const t of e.children)this.uncheckRecursive(t)}addSelectedRecursive(e,t){for(const s of e)s.checked&&t.push(s),s.children&&this.addSelectedRecursive(s.children,t)}}class dc{constructor(e){this.bodyAreaModel=e}getCheckedRows(){var e;return((e=this.bodyAreaModel.rowSelectionModel)==null?void 0:e.getCheckedRows())??[]}setCheckedRows(e){var t;(t=this.bodyAreaModel.rowSelectionModel)==null||t.setCheckedRows(e)}addCheckedRows(e){var t;(t=this.bodyAreaModel.rowSelectionModel)==null||t.addCheckedRows(e)}checkRow(e,t){const s=this.bodyAreaModel.rowSelectionModel;if(s instanceof Et){this.getTopTreeRows().forEach(o=>s.checkRow(o,t));return}this.checkAll(t?this.getBodyRows():[])}isRowChecked(e){const t=this.bodyAreaModel.rowSelectionModel;if(t instanceof Et){const a=this.getTopTreeRows().map(c=>t.isRowChecked(c));return!a.length||a.every(c=>c==="none")?"none":a.every(c=>c==="full")?"full":"semi"}const s=this.getCheckedRows(),o=this.bodyAreaModel.getRowCount();if(!s.length||!o)return"none";if(s.length<o)return"semi";const i=this.cache;if(i&&i.checkedRows===s&&i.checkedCount===s.length&&i.rowCount===o)return i.state;const r=new Set(s);let l="full";for(let a=0;a<o;a++)if(!r.has(this.bodyAreaModel.getRowByIndex(a))){l="semi";break}return this.cache={checkedRows:s,checkedCount:s.length,rowCount:o,state:l},l}checkAll(e){const t=this.bodyAreaModel.rowSelectionModel;if(!t)return;if(!e.length){t.setCheckedRows([]);return}const s=new Set(t.getCheckedRows());e.forEach(o=>s.add(o)),t.setCheckedRows(Array.from(s))}getTopTreeRows(){const e=this.bodyAreaModel;return typeof e.getDisplayedRootRows=="function"?e.getDisplayedRootRows():this.getBodyRows().filter(t=>!t.parent)}getBodyRows(){const e=this.bodyAreaModel.getRowCount(),t=new Array(e);for(let s=0;s<e;s++)t[s]=this.bodyAreaModel.getRowByIndex(s);return t}}function ss(n){return n!=null&&n.length&&O(n[0])?1:0}class T{constructor(e=100,t="px"){this.value=e,this.unit=t}}const Nt=()=>!0,tn=()=>!1,Mt=new WeakSet,Is=new WeakMap;function sn(n,e){e?Mt.delete(n):Mt.add(n),on(n)}function po(n,e){e?Is.set(n,e):Is.delete(n),on(n)}function Lo(n){var e;return Is.has(n)?!Mt.has(n):!Mt.has(n)&&((e=n.isVisible)==null?void 0:e.call(n))!==!1}function on(n){const e=Is.get(n),t=!Mt.has(n);e?n.isVisible=()=>!Mt.has(n)&&e():n.isVisible=t?Nt:tn}const Bs=class Bs{constructor(e,t,s,o=0,i=0,r=!1,l=new Le,a=[],c=[],h=-1,d=0,u=400,f=()=>{}){var p,m,b,y;this.headerAreaModel=e,this.bodyAreaModel=t,this.footerAreaModel=s,this.fixedLeftColumnCount=o,this.fixedRightColumnCount=i,this.rowCheckboxVisible=r,this.defaultRowHeights=l,this.columnDefs=a,this.columnSizes=c,this.overridingColumnWidth=h,this.columnCount=d,this.parentSize=u,this.getSelectionModel=f,this.rowCount=0,this.contentHeightInPx=0,this.contentWidthInPx=0,this.padding=new Ts(0,0,0,0),this.xPositions=[],this.headerVisible=!0,this.footerVisible=!0,e.areaIdent="header",t.areaIdent="body",s.areaIdent="footer",this.columnCount||((p=this.columnDefs)!=null&&p.length?this.columnCount=this.columnDefs.length:(m=this.columnSizes)!=null&&m.length&&(this.columnCount=(b=this.columnSizes)==null?void 0:b.length));const g=(y=this.columnDefs)==null?void 0:y[ss(this.columnDefs)];be(g)&&!t.rowSelectionModel&&(t.rowSelectionModel=new en),be(g)&&!e.rowSelectionModel&&(e.rowSelectionModel=new dc(t))}init(){this.recalcSize(this.parentSize),this.overridingColumnWidth===-1&&this.calcXPositions(),this.headerAreaModel&&this.headerAreaModel.init(),this.bodyAreaModel&&this.bodyAreaModel.init(),this.footerAreaModel&&this.footerAreaModel.init()}setParentWidth(e){this.parentSize=e}getColumnCount(){return this.columnCount}setColumnWidth(e,t){var s,o;if(t=Math.max(0,t),this.overridingColumnWidth!==-1&&(this.overridingColumnWidth=t),e>-1&&e<((s=this.columnSizes)==null?void 0:s.length)){this.columnSizes[e]=t;const i=(o=this.columnDefs)==null?void 0:o[e];i&&(i.width=new T(t,"px"))}this.overridingColumnWidth===-1&&this.calcXPositions(),this.recalcContentWidthInPx()}getColumnWidth(e){var s;const t=this.getColumnDef(e);return t&&t.isVisible&&!t.isVisible()?0:this.overridingColumnWidth!==-1?this.overridingColumnWidth:e>-1&&e<((s=this.columnSizes)==null?void 0:s.length)?this.columnSizes[e]:0}getXPosByColumnIndex(e){return e===0?0:this.overridingColumnWidth>-1?this.overridingColumnWidth*e:this.xPositions[e]}recalcSize(e){e>0&&(this.parentSize=e),this.recalcColumnWidths(e),this.recalcHeightAndPadding()}recalcHeightAndPadding(){const e=this.getAreaModel("body");this.rowCount=e.getRowCount(),this.contentHeightInPx=this.getAreaHeight("body"),this.recalcContentWidthInPx(),this.recalcPadding()}recalcPadding(){const e=this.getSideAreaWidth("west"),t=this.getSideAreaWidth("east"),s=this.headerVisible?this.getAreaHeight("header"):0,o=this.footerVisible?this.getAreaHeight("footer"):0;this.padding=new Ts(s,t,o,e)}getPadding(){return this.padding}getContentHeightInPixel(){return this.contentHeightInPx}getContentWidthInPixel(){return this.contentWidthInPx}getRowHeight(e,t){return this.getAreaModel(e).getRowHeight(t)}getModel(e){return this.getAreaModel(e)}getAreaHeight(e){var r;const t=this.getModel(e),s=t.getRowCount();if(!(s>0))return 0;const o=(r=t.getConstantRowHeight)==null?void 0:r.call(t);if(o!==void 0&&o>0)return s*o;let i=0;for(let l=0;l<s;l++)i=i+t.getRowHeight(l);return i>0?i:s*(this.defaultRowHeights[e]||0)}getSideAreaWidth(e){const[t,s]=this.getSideStartAndEndColumnIndex(e);let o=0;for(let i=t;i<=s;i++)o=o+this.getColumnWidth(i);return o}getSideStartAndEndColumnIndex(e){const t=this.getFixedLeftColumnCount(),s=this.getFixedRightColumnCount();let o=0,i=this.columnCount-1;return e==="west"?i=t-1:e==="east"?o=this.columnCount-s:(o=t,i=this.columnCount-s-1),[o,i]}getColumnDef(e){if(e<this.columnDefs.length)return this.columnDefs[e]}getFixedLeftColumnCount(){return this.fixedLeftColumnCount}getFixedRightColumnCount(){return this.fixedRightColumnCount}getAreaModel(e){if(e==="header")return this.headerAreaModel;if(e==="body")return this.bodyAreaModel;if(e==="footer")return this.footerAreaModel;throw new Error("Wrong ident.")}getBodyModel(){return this.bodyAreaModel}isFooterVisibe(){var e;return this.footerVisible&&(((e=this.footerAreaModel)==null?void 0:e.getRowCount())??0)>0}isHeaderVisibe(){var e;return this.headerVisible&&(((e=this.headerAreaModel)==null?void 0:e.getRowCount())??0)>0}setHeaderVisible(e){this.headerVisible=e,this.recalcPadding()}setFooterVisible(e){this.footerVisible=e,this.recalcPadding()}setColumnVisible(e,t){var i;const s=this.findColumnDef(e);if(!s)return!1;sn(s,t);const o=s;return typeof o.visible=="boolean"&&(o.visible=t),(i=this.columnDefs)!=null&&i.some(r=>{var l;return((l=r.width)==null?void 0:l.unit)==="weight"})&&this.recalcColumnWidths(this.parentSize),this.recalcContentWidthInPx(),this.recalcPadding(),this.calcXPositions(),!0}isColumnVisible(e){var s;const t=this.findColumnDef(e);return t?((s=t.isVisible)==null?void 0:s.call(t))!==!1:typeof e=="number"&&e>=0&&e<this.getColumnCount()}isRowCheckboxVisible(){return this.rowCheckboxVisible}externalFilterChanged(e){this.getAreaModel("body").externalFilterChanged(e)}doSort(e){return this.getAreaModel("body").doSort(e)}sort(e){return this.getAreaModel("body").sort(e)}getColumnDefs(){return this.columnDefs}getColumnProperty(e){var t,s;return((s=(t=this.columnDefs)==null?void 0:t[e])==null?void 0:s.property)??""}getBodyRowByIndex(e){return this.getBodyModel().getRowByIndex(e)}isSortable(e){var t;if(this.columnDefs&&e<this.columnDefs.length){const s=(t=this.columnDefs[e])==null?void 0:t.sortable;if(typeof s=="function")return s()}return!1}changeColumnOrder(e,t){var s,o,i;this.arrayMove(this.columnDefs,e,t),this.arrayMove(this.columnSizes,e,t),(s=this.headerAreaModel)==null||s.changeColumnOrder(e,t),(o=this.bodyAreaModel)==null||o.changeColumnOrder(e,t),(i=this.footerAreaModel)==null||i.changeColumnOrder(e,t),this.calcXPositions()}recalcColumnWidths(e){var t,s,o;if(!((t=this.columnDefs)!=null&&t.length)&&!((s=this.columnSizes)!=null&&s.length)&&(this.columnSizes=new Array(this.getColumnCount()).fill(this.overridingColumnWidth>-1?this.overridingColumnWidth:Bs.DEFAULT_COLUMN_WIDTH)),(o=this.columnDefs)!=null&&o.length){const i=this.columnDefs.filter(h=>{var d;return((d=h.width)==null?void 0:d.unit)==="weight"});this.columnSizes=this.columnDefs.map(h=>{if(h.width.unit==="%"&&e){let d=Math.floor(h.width.value*e/100);if(h.minWidth){const u=this.sizeToPixel(h.minWidth,e);d=Math.max(u,d)}if(h.maxWidth){const u=this.sizeToPixel(h.maxWidth,e);d=Math.min(u,d)}return d}else if(h.width.unit==="px"&&e)return h.width.value;return 0});const r=h=>{var d;return((d=h.isVisible)==null?void 0:d.call(h))!==!1},l=this.columnSizes.reduce((h,d,u)=>r(this.columnDefs[u])?h+d:h,0),a=e-l,c=i.filter(r);if(a>0&&c.length){const h=c.map(d=>d.width.value).reduce((d,u)=>d+u);for(let d=0;d<this.columnDefs.length;d++){const u=this.columnDefs[d];u.width.unit==="weight"&&r(u)&&(this.columnSizes[d]=u.width.value*a/h)}}}}sizeToPixel(e,t){return e.unit==="px"?e.value:e.unit==="%"?Math.floor(e.value*t/100):-1}findColumnDef(e){const t=this.columnDefs??[];if(typeof e=="number")return e>=0?t[e]:void 0;if(typeof e=="string"){for(const s of t)if(s.property===e)return s;return}return t.indexOf(e)>-1?e:void 0}arrayMove(e,t,s){const o=e.splice(t,1)[0];return e.splice(s,0,o),e}recalcContentWidthInPx(){this.contentWidthInPx=this.getSideAreaWidth("center")}calcXPositions(){const e=this.getColumnCount();this.xPositions=new Array(e+1),this.xPositions[0]=0;for(let t=0;t<e;t++)this.xPositions[t+1]=this.getColumnWidth(t)+this.xPositions[t]}setTableScope(e){this.tableScope=e}getTableScope(){return this.tableScope}};Bs.DEFAULT_COLUMN_WIDTH=100;let Ke=Bs;class ee{constructor(e,t,s){this.header=e,this.body=t,this.footer=s}}class we{constructor(e,t,s=new T(100,"px"),o=new ee,i=new ee,r,l,a,c,h,d,u,f,g,p,m=()=>this.visible){this.property=e,this.headerLabel=t,this.width=s,this.classes=o,this.rendererMap=i,this.sortable=a,this.sortComparator=c,this.sortState=h,this.sortStatesOrder=d,this.sortIconVisible=u,this.editable=f,this.getEditRenderer=g,this.editInputPipe=p,this.isVisible=m,this.visible=!0,this.minWidth=r??new T(0,"px"),this.maxWidth=l??new T(1e5,"px")}static bodyRenderer(e){return new ee(void 0,e,void 0)}static create(e){const t=new ee(e.headerRenderer,e.bodyRenderer,e.footerRenderer),s=new ee(e.headerClasses,e.bodyClasses,e.footerClasses),o=e.sortIconVisible??e.sortable,i=e.editable??$r,r=e.isVisible??e.isVisible??Nt,l=new we(e.property??"",e.headerLabel??"",e.width??new T(100,"px"),s,t,e.minWidth,e.maxWidth,e.sortable,e.sortComparator,e.sortState,e.sortStatesOrder,o,i,e.getEditRenderer,e.editInputPipe,r);return e.formula!==void 0&&e.formula!==null?(l.formula=e.formula,l.valueGetter=yi(e.formula,e.formulaOptions)):e.valueGetter&&(l.valueGetter=e.valueGetter),e.valueSetter&&(l.valueSetter=e.valueSetter),e.showValuesAs&&(l.showValuesAs=e.showValuesAs),e.rowDrag!==void 0&&(l.rowDrag=e.rowDrag),e.validate&&(l.validate=e.validate),e.editor&&(l.editor=e.editor),e.emptyValue!==void 0&&(l.emptyValue=e.emptyValue),e.cellFormulas!==void 0&&(l.cellFormulas=e.cellFormulas),l}}class ae{constructor(e="body"){this.areaIdent=e,this.rowSelectionModel=void 0}sort(e){}getRowCount(){return 0}getValueAt(e,t){return""}getTextValueAt(e,t){return""}getCellRenderer(e,t){}getRowHeight(e){return 0}getColspanAt(e,t){return 0}getCustomClassesAt(e,t){return[]}getCustomStyleAt(e,t){}getRowspanAt(e,t){return 0}getRowByIndex(e){}isRowCheckable(e){return!1}isRowChecked(e){}setRowChecked(e,t){}getTooltipAt(e,t){return""}getMaxColspan(){return 0}getMaxRowspan(){return 0}getYPosByRowIndex(e){return 0}init(){}externalFilterChanged(e){}isFilterable(){return!1}doSort(e){return!1}isEditable(e,t){return!1}setValue(e,t,s){return!1}isSelectable(e,t){return!1}changeColumnOrder(e,t){}}class rn{constructor(e){this.columnDef=e,this.type="RowNumberCellRenderer"}render(e,t,s,o,i,r,l){const a=this.columnDef.getRowNumberText(t,i),c=l.createElement("div");l.addClass(c,"ge-table-label-div");const h=l.createElement("div");l.addClass(h,"ge-table-label"),l.setAttribute(h,"data-row-index",`${t}`),l.setAttribute(h,"data-col-index",`${s}`),l.setAttribute(h,"data-area",o),l.appendChild(h,l.createText(a)),l.appendChild(c,h),l.appendChild(e,c)}}class Oo{constructor(){this.mode="display",this.format=uc,this.headerLabel="#",this.exported=!1,this.minWidthInPx=36}}function uc(n){return String(n)}class fs{constructor(e={}){this.type="RowNumberColumnDef",this.property="RowNumberColumn",this.maxWidth=new T(400,"px"),this.classes=new ee(["ge-table-row-number-header","ge-table-text-align-right"],["ge-table-row-number","ge-table-text-align-right"],["ge-table-row-number-footer"]),this.isVisible=Nt,this.options={...new Oo,...e},this.headerLabel=this.options.headerLabel,this.width=new T(this.options.minWidthInPx,"px"),this.minWidth=new T(this.options.minWidthInPx,"px"),this.rendererMap=new ee(void 0,new rn(this),void 0)}getRowNumber(e,t){var s;if(this.options.mode==="original"){const o=(s=t.getPhysicalRowIndex)==null?void 0:s.call(t,e);if(o!==void 0)return o+1;const i=this.getOriginalPosition(t.getRowByIndex(e),t);if(i!==void 0)return i+1}return e+1}getRowNumberText(e,t){return this.options.format(this.getRowNumber(e,t))}getWidestText(e){var s,o;let t=e.getRowCount();return this.options.mode==="original"&&this.hasAllRows(e)?t=((s=e.getUnfilteredRowCount)==null?void 0:s.call(e))??e.getAllRows().length:this.options.mode==="original"&&"getPhysicalRowIndex"in e&&(t=((o=e.getUnfilteredRowCount)==null?void 0:o.call(e))??t),this.options.format(Math.max(1,t))}hasDefaultFormat(){return this.options.format===new Oo().format}hasAllRows(e){return typeof e.getAllRows=="function"}getOriginalPosition(e,t){if(!this.hasAllRows(t))return;const s=t.getAllRows();if(!Array.isArray(s))return;let o=this.originalIndex;(!o||o.rows!==s||o.length!==s.length)&&(o=this.buildOriginalIndex(s));const i=o.index.get(e);if(i!==void 0&&s[i]===e)return i;if(i!==void 0||!o.missRebuilt){o=this.buildOriginalIndex(s),o.missRebuilt=!0;const r=o.index.get(e);return r!==void 0&&s[r]===e?r:void 0}}buildOriginalIndex(e){const t=new Map;for(let s=0;s<e.length;s++)t.has(e[s])||t.set(e[s],s);return this.originalIndex={rows:e,length:e.length,index:t,missRebuilt:!1},this.originalIndex}}class nn{render(e,t,s,o,i,r,l){if(i.isEditable(t,s)){l.addClass(e,"ge-table-row-input-div");const a=r!==void 0?r:i.getValueAt(t,s),c=l.createElement("input");l.setAttribute(c,"type","text"),l.setAttribute(c,"autofocus",""),l.setAttribute(c,"data-listen","change"),l.setAttribute(c,"data-area",o),l.setAttribute(c,"data-row-index",String(t)),l.setAttribute(c,"data-col-index",String(s)),l.setAttribute(c,"data-input-type","text"),l.addClass(c,"ge-table-cell-editor-input"),c.value=a==null?"":String(a),c.defaultValue=c.value,c.addEventListener("focus",()=>c.setSelectionRange(0,c.value.length),{once:!0}),e.textContent="",l.appendChild(e,c)}}}class Qs{constructor(e=new Me("❯","",["gt-table-icon-expanded"]),t=new Me("❯","transform: rotate(180deg) translate(-100%, -100%); transform-origin: 0 0;",["ge-table-icon-collapsed"])){this.iconExpanded=e,this.iconCollapsed=t}}const Si=(n,e)=>new nn;class je{constructor(){this.overflowX="auto",this.overflowY="auto",this.horizontalBorderVisible=!0,this.verticalBorderVisible=!0,this.footerSeparatorBorderVisible=!0,this.headerSeparatorBorderVisible=!0,this.fixedEastSeparatorBorderVisible=!0,this.fixedWestSeparatorBorderVisible=!0,this.tableTopBorderVisible=!0,this.tableBottomBorderVisible=!0,this.hoverRowVisible=!0,this.hoverColumnVisible=!0,this.columnsResizable=!0,this.columnsDraggable=!0,this.columnResizeHandleWidthInPx=4,this.defaultRowHeights={header:34,body:34,footer:34},this.footerVerticalSeparator=!1,this.headerToggleExpandCollapseIcons=!1,this.headerVerticalSeparator=!1,this.treeOptions=new ni,this.headerGroupOptions=new Qs,this.showCheckboxWihoutExtraColumn=!1,this.externalFilterFunction=void 0,this.sortedOptions=new li,this.sortOrder=["asc","desc"],this.shortcutActionsDisabled=!1,this.resizeEventDebounceDelay=500,this.getEditRenderer=Si,this.getSelectionModel=void 0,this.getFocusModel=void 0,this.ariaLabel=void 0,this.ariaLabelledBy=void 0,this.ariaDescribedBy=void 0,this.ariaTexts=void 0,this.overlayOptions=void 0,this.rowDragOptions=void 0,this.fillHandle=void 0,this.masterDetail=void 0,this.batchEdit=void 0,this.editing=void 0,this.clipboard=void 0,this.undo=void 0,this.cellFormulas=void 0,this.spreadsheet=void 0,this.direction=void 0}}class pe{constructor(e="none",t="single"){this.selectionType=e,this.selectionMode=t,this.ranges=[],this.negativeRanges=[],this.allSelected=!1,this.silent=!1,this.listenerArr=[]}getEventSelectionChangedListeners(){return this.listenerArr}addEventSelectionChangedListener(e){this.listenerArr.includes(e)||this.listenerArr.push(e)}removeEventSelectionChangedListener(e){const t=this.listenerArr.indexOf(e,0);t>-1&&this.listenerArr.splice(t,1)}fireChangeEvent(){this.silent||this.listenerArr.forEach(e=>e.onSelectionChanged(this))}firstClick(e,t){this.selectionType==="row"?this.addRange(M.singleRow(e)):this.selectionType==="column"?this.addRange(M.singleColumn(t)):(this.selectionType==="cell"||this.selectionType==="range")&&this.addRange(M.singleCell(e,t))}createSnapshot(){return{ranges:[...this.ranges],negativeRanges:[...this.negativeRanges],allSelected:this.allSelected}}restoreSnapshot(e){this.ranges=[...e.ranges],this.negativeRanges=[...e.negativeRanges],this.allSelected=e.allSelected,this.fireChangeEvent()}adjustForRowChanges(e){if(e.isEmpty())return!1;const t=pe.shiftRanges(this.ranges,e);return pe.shiftRanges(this.negativeRanges,e),t}static shiftRanges(e,t){let s=!1;const o=[];for(const i of e){const r=Math.min(i.r1,i.r2),l=Math.max(i.r1,i.r2);if(r===0&&l>=Number.MAX_SAFE_INTEGER){o.push(i);continue}const a=l>=Number.MAX_SAFE_INTEGER?[[t.mapIndexOrNext(r),Number.MAX_SAFE_INTEGER]]:t.mapRange(r,l),c=a.reduce((f,[g,p])=>f+(p>=Number.MAX_SAFE_INTEGER?0:p-g+1),0);if(l<Number.MAX_SAFE_INTEGER&&c<l-r+1&&(s=!0),!a.length)continue;const h=i.r1>i.r2,[d,...u]=a;i.r1=h?d[1]:d[0],i.r2=h?d[0]:d[1],o.push(i);for(const[f,g]of u)o.push(new M(f,i.c1,g,i.c2,i.gammaRange))}e.length=0;for(const i of o)e.push(i);return s}getSelectionCount(e,t){let s=0;for(const o of this.ranges)o.isInRange(e,t)&&s++;return this.allSelected&&s++,this.isInNegativeRange(e,t)&&(s=0),s}isInNegativeRange(e,t){for(const s of this.negativeRanges)if(s.isInRange(e,t))return!0;return!1}getRanges(){return this.ranges}clear(){this.ranges=[],this.negativeRanges=[],this.allSelected=!1,this.fireChangeEvent()}hasSelection(){return this.allSelected||!!this.ranges.length}hasNoSelection(){return!this.hasSelection()}getMergedRowIndices(e){const t=e===void 0?void 0:e-1,s=[...this.ranges];this.allSelected&&t!==void 0&&s.push(new M(0,0,t,Number.MAX_SAFE_INTEGER));const o=new Set;for(const i of s){const r=Math.max(i.r1,0),l=t===void 0?i.r2:Math.min(i.r2,t);if(t===void 0&&!(l<Number.MAX_SAFE_INTEGER))continue;const a=this.negativeRanges.filter(c=>pe.intersects(c,i));for(let c=r;c<=l;c++)!o.has(c)&&(!a.length||!pe.coversColumns(a,c,i.c1,i.c2))&&o.add(c)}return Array.from(o).sort((i,r)=>i-r)}selectAll(){this.selectionType!=="none"&&(this.allSelected=!0,this.negativeRanges=[],this.fireChangeEvent())}isAllSelected(){return this.allSelected}addSelection(e){this.addRange(e)}removeSelection(e){if(this.selectionType==="none")return;let t=e;this.selectionType==="row"?t=new M(e.r1,0,e.r2,Number.MAX_SAFE_INTEGER):this.selectionType==="column"&&(t=new M(0,e.c1,Number.MAX_SAFE_INTEGER,e.c2)),this.negativeRanges.push(t),this.ranges=this.ranges.filter(s=>!this.isCoveredByNegativeRanges(s)),this.fireChangeEvent()}togglePoint(e,t){this.getSelectionCount(e,t)>0?this.removeSelection(M.singleCell(e,t)):this.reselectPoint(e,t)?this.fireChangeEvent():this.addSelection(M.singleCell(e,t))}isSelected(e,t){return this.getSelectionCount(e,t)>0}addRange(e){this.selectionType!=="none"&&(this.allSelected=!1,this.selectionMode==="single"&&(this.ranges=[],this.negativeRanges=[]),this.adjustRangeToSelectionType(e),this.liftNegativeRanges(e),this.ranges.push(e),this.fireChangeEvent())}adjustRangeToSelectionType(e){return this.selectionType==="row"?(e.c1=0,e.c2=Number.MAX_SAFE_INTEGER):this.selectionType==="column"?(e.r1=0,e.r2=Number.MAX_SAFE_INTEGER):this.selectionType==="cell"?(e.r2=e.r1,e.c2=e.c1):this.selectionType,e}reselectPoint(e,t){return this.selectionType==="none"||!this.isInNegativeRange(e,t)||!this.allSelected&&!this.ranges.some(s=>s.isInRange(e,t))?!1:(this.liftNegativeRanges(this.adjustRangeToSelectionType(M.singleCell(e,t))),!0)}liftNegativeRanges(e){if(!this.negativeRanges.length)return;const t=[];for(const s of this.negativeRanges){const o=Math.max(s.r1,e.r1),i=Math.min(s.r2,e.r2),r=Math.max(s.c1,e.c1),l=Math.min(s.c2,e.c2);if(o>i||r>l){t.push(s);continue}s.r1<o&&t.push(new M(s.r1,s.c1,o-1,s.c2,s.gammaRange)),i<s.r2&&t.push(new M(i+1,s.c1,s.r2,s.c2,s.gammaRange)),s.c1<r&&t.push(new M(o,s.c1,i,r-1,s.gammaRange)),l<s.c2&&t.push(new M(o,l+1,i,s.c2,s.gammaRange))}this.negativeRanges=t}isCoveredByNegativeRanges(e){let t=[e];for(const s of this.negativeRanges)if(t=t.flatMap(o=>pe.difference(o,s)),!t.length)return!0;return!1}static difference(e,t){const s=Math.max(e.r1,t.r1),o=Math.min(e.r2,t.r2),i=Math.max(e.c1,t.c1),r=Math.min(e.c2,t.c2);if(s>o||i>r)return[e];const l=[];return e.r1<s&&l.push(new M(e.r1,e.c1,s-1,e.c2)),o<e.r2&&l.push(new M(o+1,e.c1,e.r2,e.c2)),e.c1<i&&l.push(new M(s,e.c1,o,i-1)),r<e.c2&&l.push(new M(s,r+1,o,e.c2)),l}static intersects(e,t){return Math.max(e.r1,t.r1)<=Math.min(e.r2,t.r2)&&Math.max(e.c1,t.c1)<=Math.min(e.c2,t.c2)}static coversColumns(e,t,s,o){const i=e.filter(l=>l.r1<=t&&t<=l.r2&&l.c1<=l.c2).sort((l,a)=>l.c1-a.c1);let r=s;for(const l of i){if(l.c1>r)return!1;if(l.c2>=r&&(r=l.c2+1),r>o)return!0}return r>o}}class xi{constructor(e="none"){this.selectionType=e,this.rowIndex=-1,this.columnIndex=-1,this.changed=!1,this.listenerArr=[]}getEventFocusChangedListeners(){return this.listenerArr}addEventFocusChangedListener(e){this.listenerArr.includes(e)||this.listenerArr.push(e)}removeEventFocusChangedListener(e){const t=this.listenerArr.indexOf(e,0);t>-1&&this.listenerArr.splice(t,1)}fireChangeEvent(){this.listenerArr.forEach(e=>e.onFocusChanged(this))}clearChanged(){this.changed=!1}hasChanged(){return this.changed}clear(){this.rowIndex=-1,this.columnIndex=-1,this.fireChangeEvent()}setFocus(e,t){(this.rowIndex!==e||this.columnIndex!==t)&&(this.rowIndex=e,this.columnIndex=t,this.changed=!0,this.fireChangeEvent())}adjustForRowChanges(e){if(this.rowIndex<0||e.isEmpty())return;const t=e.mapIndex(this.rowIndex);if(t>=0){this.rowIndex=t;return}this.rowIndex=e.mapIndexOrNext(this.rowIndex),this.changed=!0,this.fireChangeEvent()}hasFocus(e,t){return this.rowIndex===e&&this.columnIndex===t}getFocus(){return[this.rowIndex,this.columnIndex]}}function fc(n){var e,t;try{const o=new Intl.NumberFormat(n).formatToParts(12345.6);return{decimal:((e=o.find(i=>i.type==="decimal"))==null?void 0:e.value)??".",group:((t=o.find(i=>i.type==="group"))==null?void 0:t.value)??","}}catch{return{decimal:".",group:","}}}const gc=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");let mo;function ln(n){var e;if(!mo){let t=[];try{t=((e=Intl.supportedValuesOf)==null?void 0:e.call(Intl,"currency"))??[]}catch{t=[]}mo=new Set(t.length?t:["EUR","USD","GBP","CHF","JPY","CNY","CAD","AUD","SEK","NOK","DKK","PLN","CZK"])}return mo.has(n)}function qi(n){return n.replace(new RegExp("^\\p{Sc}\\s*","u"),"").replace(/^([A-Z]{3})\s+/u,(e,t)=>ln(t)?"":e)}function an(n,e){let t=n.trim().replace(/[   ]/g," ").replace(/−/g,"-");if(!t)return;let s=!1;if(/^\(.*\)$/.test(t)&&(s=!0,t=t.slice(1,-1).trim(),/^[-+]/.test(t)))return;let o=!1;t=qi(t),t=t.replace(/\s*%$/u,()=>(o=!0,"")),t=t.replace(new RegExp("\\s*\\p{Sc}$","u"),"").replace(/\s+([A-Z]{3})$/u,(c,h)=>ln(h)?"":c),(t.startsWith("-")||t.startsWith("+"))&&(s=s!==t.startsWith("-"),t=qi(t.slice(1).trim()));const{decimal:i,group:r}=fc(e),l=r.trim()===""?" ":r;if(t=t.replace(new RegExp(`[${gc(l)}](?=\\d{3}(\\D|$))`,"g"),""),i!=="."){if(t.includes(".")&&!/[eE]/.test(t))return;t=t.replace(i,".")}if(!/^(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/.test(t))return;let a=Number(t);return o&&(a/=100),s?-a:a}function pc(n){return e=>typeof e!="string"?e:e.trim()===""?"":an(e,n)??e}function mc(n){try{return new Intl.DateTimeFormat(n).formatToParts(new Date(2026,10,23)).filter(e=>e.type==="day"||e.type==="month"||e.type==="year").map(e=>e.type)}catch{return["month","day","year"]}}function cn(n,e){const t=n.trim(),s=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?$/.exec(t);if(s)return Zi(+s[1],+s[2],+s[3],+(s[4]??0),+(s[5]??0),+(s[6]??0));const o=/^(\d{1,4})([./-])(\d{1,2})\2(\d{1,4})(?:,? (\d{1,2}):(\d{2})(?::(\d{2}))?)?$/.exec(t);if(!o)return;const i=mc(e),r=[o[1],o[3],o[4]],l={};for(let c=0;c<3;c++){const h=i[c],d=r[c];if(h==="year"?d.length!==2&&d.length!==4:d.length>2)return;l[h]=+d}let a=l.year;return a<100&&(a+=2e3),Zi(a,l.month,l.day,+(o[5]??0),+(o[6]??0),+(o[7]??0))}function Zi(n,e,t,s,o,i){const r=new Date(n,e-1,t,s,o,i);return r.getFullYear()===n&&r.getMonth()===e-1&&r.getDate()===t?r:void 0}function bc(n){return e=>typeof e!="string"?e:e.trim()===""?"":cn(e,n)??e}const wc=["true","yes","1","x","wahr","ja"],yc=["false","no","0","falsch","nein"],Cc=n=>{if(typeof n!="string")return n;const e=n.trim().toLowerCase();return e===""?"":wc.includes(e)?!0:yc.includes(e)?!1:n};function vi(n){return e=>{if(typeof e!="string"||e.startsWith("=")||e.startsWith("'="))return e;if(e.startsWith("'"))return e.slice(1);const t=e.trim();if(t==="")return"";const s=t.toUpperCase();if(s==="TRUE")return!0;if(s==="FALSE")return!1;const o=an(t,n);return o!==void 0?o:cn(t,n)??e}}class Ri extends Q{constructor(){super(...arguments),this.columnLetterRows=1}isColumnLetterRow(e){return e<this.columnLetterRows}setColumns(e){this.arr.length=0,this.arr.push(e.map(t=>t.headerLabel)),this.filteredArr=[...this.arr],this.columnDefs=e,this.cellRenderers=e.map(t=>{var s;return(s=t.rendererMap)==null?void 0:s[this.areaIdent]})}}class Ai extends Ke{constructor(e,t,s,o,i,r,l=vi()){super(e,t,new ae("footer"),s?1:0,0,!1,new Le(i,i,i),o),this.sheetBody=t,this.rowNumberColumn=s,this.columnWidth=r,this.inputPipe=l}setDataColumns(e,t=[]){const s=hn(e,this.columnWidth,this.rowNumberColumn,t,this.inputPipe);this.columnDefs=s,this.columnCount=s.length,this.columnSizes=[],this.headerAreaModel.setColumns(s),this.sheetBody.setColumnDefs(s),this.init()}getDataColumnWidths(){const e=this.rowNumberColumn?1:0;return Array.from({length:this.getColumnCount()-e},(t,s)=>this.getColumnWidth(s+e))}}function hn(n,e,t,s=[],o){const i=Array.from({length:n},(r,l)=>we.create({editInputPipe:o,property:Ne(l),headerLabel:Ne(l),width:new T(s[l]??e,"px"),minWidth:new T(20,"px"),maxWidth:new T(2e3,"px")}));return t?[t,...i]:i}class Sc{static create(e={}){const t=e.data??[],s=Math.max(e.rowCount??100,t.length),o=Math.max(e.columnCount??26,t.reduce((m,b)=>Math.max(m,(b==null?void 0:b.length)??0),0)),i=e.rowHeight??30,r=e.columnWidth??100,l=e.rowNumbers===!1?void 0:new fs({mode:"original"}),a=vi(e.locale),c=hn(o,r,l,[],a),h=new Ri("header",[c.map(m=>m.headerLabel)],i,c),d=new Pe("body",t,s,o,i,c,l?1:0),u=new Ai(h,d,l,c,i,r,a),f=new pe("range","multi"),g=new xi("cell");g.setFocus(0,l?1:0);const p={...new je,getSelectionModel:()=>f,getFocusModel:()=>g,spreadsheet:!0,...e.functions?{cellFormulas:{functions:e.functions}}:{},hoverRowVisible:!1,hoverColumnVisible:!1,...e.tableOptions};return{tableModel:u,tableOptions:p}}}function eo(n){return n instanceof Ai}class No{constructor(e=-1,t=-1){this.rowIndex=e,this.columnIndex=t}}class Xe{constructor(e,t,s){this.cells=e,this.changes=t,this.source=s}static createForChanges(e,t){const s=e.filter(o=>o.rowIndex>-1).map(o=>new No(o.rowIndex,o.columnIndex));return new Xe(s,e,t)}static createSingle(e,t){return new Xe([new No(e,t)])}}class me{static create(e){const t=new me;if(e)for(const s of Object.keys(e)){const o=e[s];typeof o=="function"&&(t[s]=o)}return t}sorted(e,t){return t==="asc"?`Sorted by ${e}, ascending`:t==="desc"?`Sorted by ${e}, descending`:`Sorting of ${e} removed`}filtered(e){return e===0?"No rows":e===1?"1 row":`${e} rows`}copied(e){return e===1?"1 cell copied":`${e} cells copied`}allSelected(){return"All cells selected"}selectionCleared(){return"Selection cleared"}selectRow(e){return`Select row ${e}`}selectAllRows(){return"Select all rows"}expandGroup(e){return e?`Expand group ${e}`:"Expand group"}collapseGroup(e){return e?`Collapse group ${e}`:"Collapse group"}rowDragStarted(e){return e===1?"Dragging 1 row. Press Escape to cancel.":`Dragging ${e} rows. Press Escape to cancel.`}rowMoved(e,t){return`Row moved to position ${e} of ${t}`}rowMoveNotPossible(){return"Rows cannot be moved while the table is sorted or filtered"}rowDragCancelled(){return"Drag cancelled"}cellsFilled(e){return e===1?"1 cell filled":`${e} cells filled`}detailExpanded(){return"Details expanded"}detailCollapsed(){return"Details collapsed"}fillTooLarge(e){return`Too many cells to fill (at most ${e})`}pendingChanges(e){return e===0?"No unsaved changes":e===1?"1 change not saved":`${e} changes not saved`}changesCommitted(e){return e===1?"1 change saved":`${e} changes saved`}changesDiscarded(){return"Changes discarded"}commitBlocked(e){return e===1?"1 invalid value – nothing saved":`${e} invalid values – nothing saved`}invalidValue(e){return e?`Invalid value: ${e}`:"Invalid value"}editingStarted(e){return e?`Editing ${e}`:"Editing"}readOnlyCell(){return"Read only"}cellsCleared(e){return e===1?"1 cell cleared":`${e} cells cleared`}clearTooLarge(e){return`Too many cells to clear (at most ${e})`}rangeSelected(e,t){const s=e===1?"1 row":`${e} rows`,o=t===1?"1 column":`${t} columns`;return`${s}, ${o} selected`}rowSelected(e){return e===1?"Row selected":`${e} rows selected`}columnSelected(e){return e===1?"Column selected":`${e} columns selected`}gridEditingHint(){return"Type to edit a cell, Enter to edit or commit, Escape to cancel. Tab in the last column leaves the table."}cellsPasted(e,t){const s=e===1?"1 cell pasted":`${e} cells pasted`;return t>0?`${s}, ${t} skipped`:s}pasteTooLarge(e){return`Too many cells to paste (at most ${e})`}copyTooLarge(e){return`Too many cells to copy (at most ${e})`}cutMarked(e){return`${e===1?"1 cell":`${e} cells`} cut, paste to move them`}copiedLastRangeOnly(){return"Only the last selected range was copied"}undone(e,t){return`Undo ${e}, ${t===1?"1 cell":`${t} cells`}`}redone(e,t){return`Redo ${e}, ${t===1?"1 cell":`${t} cells`}`}nothingToUndo(){return"Nothing to undo"}nothingToRedo(){return"Nothing to redo"}undoSkipped(e){return`${e===1?"1 cell":`${e} cells`} skipped`}undoHistoryCleared(e){return`This change cannot be undone (more than ${e} cells)`}formulaError(e){return`Formula error: ${e}`}functionSuggestions(){return"Functions"}referenceInserted(e){return e}rowsInserted(e){return e===1?"1 row inserted":`${e} rows inserted`}rowsDeleted(e){return e===1?"1 row deleted":`${e} rows deleted`}columnsInserted(e){return e===1?"1 column inserted":`${e} columns inserted`}columnsDeleted(e){return e===1?"1 column deleted":`${e} columns deleted`}}const xc={insertRows:"Insert rows",deleteRows:"Delete rows",insertColumns:"Insert columns",deleteColumns:"Delete columns"};function gt(n,e,t={}){var m,b,y,C,S;const s=n.tableModel,o=s.getBodyModel(),i=e.kind==="insertColumns"||e.kind==="deleteColumns",r=o instanceof Pe?o:void 0,l=o instanceof K||o instanceof Q;if(!(e.count>=1)||!(e.at>=0)||(i?!r||!eo(s):!r&&!l)||n.isBatchEditActive())return!1;const a=i?r.getSheetColumnCount():r?r.getUnfilteredRowCount():Ei(o).length,h=e.kind==="deleteRows"||e.kind==="deleteColumns"?Math.min(e.count,a-e.at):e.count;if(e.at>a||h<1||(m=n.cellEditorService)!=null&&m.isOpen()&&!n.cellEditorService.commit("none"))return!1;const d={...e,count:h},u=n.tableSheet;u==null||u.rowCount();const f=u?u.engine.adjustForStructureChange(d):[],g=vc(n,d,t.rows),p=[];if(u){const A=u.rowsArray();for(const{row:x,col:R,input:L}of f){const v=A?A[x]:r==null?void 0:r.getRowArray(x),D=u.inputAt(x,R);if(v&&typeof v=="object"){const P=d.kind==="insertColumns"?R>=d.at+h?R-h:R:d.kind==="deleteColumns"&&R>=d.at?R+h:R;g.inputs.push({row:v,col:P,old:D})}u.writeInput(x,R,L);const k=u.modelColumn(R);p.push({row:v,rowIndex:u.displayRow(x),columnIndex:k,property:((b=s.getColumnDef(k))==null?void 0:b.property)??"",oldValue:D,newValue:L})}u.recalculate()}return n.refreshAfterStructureChange(i),t.record!==!1&&((y=n.undoService)==null||y.addStep(new Ec(d,g))),n.announce(Ac(n,d)),(S=(C=n.getEventListener()).onModelChanged)==null||S.call(C,Xe.createForChanges(p,t.source??"structure")),!0}function vc(n,e,t){const s=n.tableModel,o=s.getBodyModel(),{at:i,count:r}=e,l={inputs:[]};if(o instanceof Pe){if(e.kind==="insertRows")o.insertRows(i,r);else if(e.kind==="deleteRows")l.sheetRows=o.deleteRows(i,r);else if(eo(s)){const c=s.getDataColumnWidths();l.widths=[...c],e.kind==="insertColumns"?(o.insertColumns(i,r),c.splice(i,0,...new Array(r).fill(NaN))):(l.sheetColumns=o.deleteColumns(i,r),c.splice(i,r)),s.setDataColumns(o.getSheetColumnCount(),c.map(h=>Number.isNaN(h)?void 0:h))}return l}const a=Ei(o);if(e.kind==="insertRows"){const c=t??Array.from({length:r},(h,d)=>Rc(n,i+d));for(let h=0;h<c.length;h++)a.splice(i+h,0,c[h]);l.rows=c}else l.rows=a.splice(i,r);return dn(o,a),l}function Ei(n){return n instanceof K?n.getAllRows():n.arr}function dn(n,e){n instanceof K?n.setRows(e):n instanceof Q&&(n.filteredArr=[...e])}function Rc(n,e){if(n.tableModel.getBodyModel()instanceof Q)return new Array(n.tableModel.getColumnCount()).fill("");const s=n.getClipboardService().options.createRow;return s?s(e):{}}function Ac(n,e){const t=n.ariaTexts,s=new me;switch(e.kind){case"insertRows":return(t.rowsInserted??s.rowsInserted).call(t,e.count);case"deleteRows":return(t.rowsDeleted??s.rowsDeleted).call(t,e.count);case"insertColumns":return(t.columnsInserted??s.columnsInserted).call(t,e.count);default:return(t.columnsDeleted??s.columnsDeleted).call(t,e.count)}}class Ec{constructor(e,t){var s,o;this.edit=e,this.delta=t,this.source="structure",this.label=xc[e.kind],this.cellCount=e.count+t.inputs.length+(((s=t.sheetRows)==null?void 0:s.reduce((i,[,r])=>i+r.length,0))??0)+(((o=t.sheetColumns)==null?void 0:o.reduce((i,[,r])=>i+r.length,0))??0)}undo(e){var a,c,h,d,u;const t=e.tableModel,s=t.getBodyModel(),{at:o,count:i,kind:r}=this.edit,l=this.delta;if(s instanceof Pe)r==="insertRows"?s.deleteRows(o,i):r==="deleteRows"?s.restoreRows(o,i,l.sheetRows):eo(t)&&(r==="insertColumns"?s.deleteColumns(o,i):s.restoreColumns(o,i,l.sheetColumns),t.setDataColumns(s.getSheetColumnCount(),l.widths));else{const f=Ei(s);if(r==="insertRows")f.splice(o,i);else for(let g=0;g<(((a=l.rows)==null?void 0:a.length)??0);g++)f.splice(o+g,0,l.rows[g]);dn(s,f)}for(const{row:f,col:g,old:p}of l.inputs)(c=e.tableSheet)==null||c.writeInput(f,g,p);return(h=e.tableSheet)==null||h.recalculate(),e.refreshAfterStructureChange(r==="insertColumns"||r==="deleteColumns"),(u=(d=e.getEventListener()).onModelChanged)==null||u.call(d,Xe.createForChanges([],"undo")),{applied:i,skipped:0}}redo(e){return gt(e,this.edit,{record:!1,rows:this.edit.kind==="insertRows"?this.delta.rows:void 0,source:"redo"}),{applied:this.edit.count,skipped:0}}}class un{constructor(e){this.tableScope=e}updateCells(e,t=!1){this.tableScope.updateCells(e,t)}externalFilterChanged(){this.tableScope.externalFilterChanged()}scrollToPixel(e=0,t=0){this.tableScope.scrollToPixel(e,t)}getDirection(){return this.tableScope.direction}scrollToIndex(e=0,t=0){this.tableScope.scrollToIndex(e,t)}setHeaderVisible(e=!0){this.tableScope.setHeaderVisible(e)}setColumnVisible(e,t=!0){return this.tableScope.setColumnVisible(e,t)}isColumnVisible(e){var i;const t=this.tableScope.tableModel;if(t.isColumnVisible)return t.isColumnVisible(e);const s=t.getColumnDefs()??[],o=typeof e=="number"?s[e]:typeof e=="string"?s.filter(r=>r.property===e)[0]:e;return o?((i=o.isVisible)==null?void 0:i.call(o))!==!1:typeof e=="number"&&e>=0&&e<t.getColumnCount()}isHeaderVisible(){return this.tableScope.tableModel.isHeaderVisibe()}setFooterVisible(e=!0){this.tableScope.setFooterVisible(e)}isFooterVisible(){return this.tableScope.tableModel.isFooterVisibe()}repaint(){this.tableScope.invalidateAggregates(),this.tableScope.repaint()}destroy(){this.tableScope.destroy()}repaintHard(e){this.tableScope.invalidateAggregates(),this.tableScope.repaintHard(e)}recalcColumnWidths(e){this.tableScope.recalcColumnWidths(e)}clearSelection(){this.tableScope.clearSelection(!0)}setSelectionModel(e,t=!0){this.tableScope.setSelectionModel(e,t)}triggerAction(e){return this.tableScope.onActionTriggered(e)}getShortcutActionMapping(){return this.tableScope.shortcutService.getShortcutActionMapping()}copyToClipboard(){return this.tableScope.copyService.copyToClipboard(this.tableScope.tableModel,this.tableScope.selectionModel(),this.tableScope.focusModel()).then(e=>(this.tableScope.announceCopied(e),e))}announce(e){this.tableScope.announce(e)}showLoadingOverlay(e){this.tableScope.showLoadingOverlay(e)}showNoRowsOverlay(e){this.tableScope.showNoRowsOverlay(e)}hideOverlay(){this.tableScope.hideOverlay()}getOverlayState(){return this.tableScope.getOverlayState()}getState(e){return this.tableScope.stateService.getState(e)}applyState(e,t){this.tableScope.stateService.applyState(e,t)}resetState(){this.tableScope.stateService.resetState()}setCustomState(e){this.tableScope.stateService.setCustomState(e)}setHeaderGroupCollapsed(e,t=!0){return this.tableScope.setHeaderGroupCollapsed(e,t)}getHeaderFocus(){return this.tableScope.getHeaderFocus()}downloadExcel(e="table.xlsx",t="",s={}){var f;const o=[],i=this.tableScope.tableModel,r=[];for(let g=0;g<i.getColumnCount();g++){const p=i.getColumnDef(g);((f=p==null?void 0:p.isVisible)==null?void 0:f.call(p))!==!1&&(O(p)&&!p.options.exported||r.push(g))}const l=i.getBodyModel(),a=l instanceof Pe?l.getContentExtent():void 0;if(a){const g=this.tableScope.getFirstDataColumnIndex();for(let p=r.length-1;p>=0;p--)r[p]>=g&&r[p]>a[1]&&r.splice(p,1)}const c=s.cellFormulas?this.getExcelFormulaOffset(r,a==null?void 0:a[1]):void 0,h=["header","body","footer"];for(const g of h){const p=i.getAreaModel(g),m=g==="body"&&a?a[0]+1:(p==null?void 0:p.getRowCount())??0;for(let b=0;b<m;b++)g==="header"&&Qi(p,b)||o.push(r.map(y=>c&&g==="body"?this.getExcelFormulaCell(p,b,y,c)??this.getExportValue(i,g,p,b,y):this.getExportValue(i,g,p,b,y)))}const d=this.tableScope.isRtl()?{rightToLeft:!0}:void 0,u=Object.keys(s).length?{...s,...d}:d;return Promise.resolve(u?this.tableScope.excelService.downloadExcel(o,e,t,u):this.tableScope.excelService.downloadExcel(o,e,t))}getExcelFormulaOffset(e,t=Number.MAX_SAFE_INTEGER){var f;const s=this.tableScope,o=s.tableSheet;if(!o)return;const i=g=>{console.warn(`GuiExpert Table – downloadExcel: values instead of formulas (${g}).`)};if(!s.excelService.supportsFormulas)return i("the Excel service writes no formulas");const r=s.tableModel.getBodyModel(),l=r.getRowCount();if(l!==(((f=r.getUnfilteredRowCount)==null?void 0:f.call(r))??l))return i("a filter hides rows");for(let g=0;g<l;g++)if(o.physicalRow(g)!==g)return i("the rows are sorted");const a=e.map(g=>o.engineColumn(g)),c=a.findIndex(g=>g!==void 0);let h=0;for(let g=0;g<e.length;g++){const p=a[g];if(p!==void 0){if(p!==h||g!==c+h)return i("a data column is hidden or moved");h++}}for(let g=0;g<s.tableModel.getColumnCount();g++)if(o.engineColumn(g)!==void 0&&!e.includes(g)&&g<=t)return i("a data column is hidden");const d=s.tableModel.getAreaModel("header");let u=0;for(let g=0;g<((d==null?void 0:d.getRowCount())??0);g++)Qi(d,g)||u++;return u+l>ie||Math.max(0,c)+h>q?i("the sheet is larger than an Excel sheet"):{dRow:u,dCol:Math.max(0,c),rows:l,cols:h,sheet:o}}getExcelFormulaCell(e,t,s,o){var l;const i=(l=e.getInputValueAt)==null?void 0:l.call(e,t,s);if(!o.sheet.isFormulaInput(s,i))return;const r=cc(i,o);return r===void 0?void 0:{formula:r,value:e.getValueAt(t,s)}}getExportValue(e,t,s,o,i){const r=e.getColumnDef(i);if(O(r)&&t!=="header")return t!=="body"?"":r.hasDefaultFormat()?r.getRowNumber(o,s):r.getRowNumberText(o,s);const l=s.getValueAt(o,i);if(t!=="header"&&typeof l=="number"&&this.tableScope.excelService.supportsNumberFormats){const a=js(r)?r.pivot.value.showValuesAs:t==="body"?r==null?void 0:r.showValuesAs:void 0,c=_a(a);if(c)return{value:l,numberFormat:c}}return l}getColumnIndex(e){var s,o,i;const t=((o=(s=this.tableScope.tableModel).getColumnDefs)==null?void 0:o.call(s))??[];for(let r=0;r<t.length;r++)if(((i=t[r])==null?void 0:i.property)===e)return r;return-1}getTableScope(){return this.tableScope}getSelectionModel(){return this.tableScope.selectionModel()}getSelectionAggregates(){return new Es().aggregate(this.tableScope.tableModel,this.getSelectionModel())}autoResizeColumns(e=!0){this.tableScope.autoResizeColumns(e)}recalcWrappers(){this.tableScope.recalcWrappers()}setColumnWidth(e,t){this.tableScope.setColumnWidth(e,t)}getTableModel(){return this.tableScope.tableModel}getBodyModel(){return this.tableScope.tableModel.getBodyModel()}setRows(e){var s;const t=this.getBodyModel();t instanceof K?(t.setRows(e),(s=this.tableScope.batchEditService)==null||s.pruneOrphans(),this.tableScope.invalidateRowLayout()):console.warn("setRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ",typeof t,t)}appendRows(e,t){return this.tableScope.appendRows(e,t)}rowsAppended(e,t){return this.tableScope.notifyRowsAppended(e,t)}addRows(e){const t=this.getBodyModel();if(t instanceof K){const s=t;let o=s.getAllRows();s.setRows([...o,...e])}else console.warn("addRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ",typeof t,t)}addRowsAt(e,t){const s=this.getBodyModel();if(s instanceof K){const o=s;let i=o.getAllRows();o.setRows([...i.slice(0,t),...e,...i.slice(t)])}else console.warn("addRowsAt<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ",typeof s,s)}removeRows(e,t=(s,o)=>s===o){const s=this.getBodyModel();if(s instanceof K){const o=s,i=o.getAllRows().filter(r=>!e.some(l=>t(r,l)));o.setRows(i)}else console.warn("removeRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ",typeof s,s)}findRows(e,t=(s,o)=>s===o){const s=this.getBodyModel();return s instanceof K?s.getAllRows().filter(i=>e.some(r=>t(i,r))):(console.warn("findRows<T>(rows: T[], predicate: (a: T, b: T) => boolean) only works with AreaModelObjectArray<T>, but this body area model is ",typeof s,s),[])}findRowFromFilteredRowsByAllCriteria(e,t){const s=this.getBodyModel();if(s instanceof K)return s.getFilteredRows().find(i=>t(e,i));console.warn("findRowFromFilteredRowsByAllCriteria(...) only works with AreaModelObjectArray<T>, but this body area model is ",typeof s,s)}findRowFromAllRowsByAllCriteria(e,t){const s=this.getBodyModel();if(s instanceof K)return s.getAllRows().find(i=>t(e,i));console.warn("findRowFromAllRowsByAllCriteria(...) only works with AreaModelObjectArray<T>, but this body area model is ",typeof s,s)}updateRows(e,t=(s,o)=>s===o){const s=this.getBodyModel();if(s instanceof K){let i=s.getAllRows();for(const r of i)for(const l of e)if(t(r,l))for(const a of Object.keys(l))r[a]=l[a]}else console.warn("updateRows<T>(rows: T[], predicate: (a: T, b: T) => boolean) only works with AreaModelObjectArray<T>, but this body area model is ",typeof s,s)}sortByColumn(e,t){return this.tableScope.sortByColumn(e,t)}reSort(){this.tableScope.reSort()}expandAll(){this.tableScope.toggleExpandCollapseAll(!0)}collapseAll(){this.tableScope.toggleExpandCollapseAll(!1)}setRowExpanded(e,t){const s=this.tableScope.tableModel.getBodyModel().getRowByIndex(e);return U(s)?this.tableScope.setTreeRowExpanded(s,t):!1}setRowGroupBy(e){return this.tableScope.setRowGroupBy(e)}getRowGroupBy(){const e=this.tableScope.tableModel.getBodyModel();return ne(e)?e.getGroupBy():void 0}setPivotConfig(e,t){return this.tableScope.setPivotConfig(e,t)}getPivotConfig(){const e=this.tableScope.tableModel;return vs(e)?e.getPivotConfig():void 0}getRowValue(e,t){const s=this.tableScope.tableModel.getBodyModel();if(typeof s.getRowValue=="function")return s.getRowValue(e,t);const o=U(e)?e.data:e;if(o==null)return;let i=o;for(const r of t.split(".")){if(i==null)return;i=i[r]}return i}setShowValuesAs(e,t){const s=(this.tableScope.tableModel.getColumnDefs()??[]).filter(o=>o.property===e);return!s.length||t!==void 0&&!Ft(t)?!1:(s.forEach(o=>o.showValuesAs=t),this.repaint(),!0)}getShowValuesAs(e){var t,s;return(s=(t=this.tableScope.tableModel.getColumnDefs())==null?void 0:t.find(o=>o.property===e))==null?void 0:s.showValuesAs}setColumnFormula(e,t,s){const o=(this.tableScope.tableModel.getColumnDefs()??[]).filter(l=>l.property===e);if(!o.length)return new I("#NAME?",`No column "${e}"`);const i=wi(t,s),r=yi(i);return o.forEach(l=>{l.formula=i.source,l.valueGetter=r}),this.repaint(),i.error}sort(e){this.tableScope.sort(e)}moveRows(e,t){const s=this.tableScope.rowDragService;if(!s)return!1;const o=Array.isArray(e)?e:[e];let i;if(typeof t=="number"){const r=this.tableScope.tableModel.getBodyModel().getRowCount();i=t>=r?{rowIndex:r-1,position:"after"}:{rowIndex:Math.max(0,t),position:"before"}}else i=t;return s.moveRows(o,i,!0)>-1}isRowDragging(){var e;return!!((e=this.tableScope.rowDragService)!=null&&e.isDragging())}cancelRowDrag(){var e;(e=this.tableScope.rowDragService)==null||e.cancel()}applyCellChanges(e,t="api",s={}){return this.tableScope.applyCellChanges(e,t,s)}fillRange(e,t,s,o="auto"){return this.tableScope.fillRange(e,t,s,o)}isFilling(){var e;return!!((e=this.tableScope.fillHandleService)!=null&&e.isFilling())}cancelFill(){var e;(e=this.tableScope.fillHandleService)==null||e.cancel()}subscribe(e){return this.tableScope.subscribe(e)}startEditing(e,t,s){var i;const o=typeof t=="number"?t:this.getColumnIndex(t);return o<0?!1:s!==void 0&&((i=this.tableScope.cellEditorService)!=null&&i.handlesColumn(o))?this.tableScope.cellEditorService.start(e,o,{mode:"enter",typedText:s}):this.tableScope.startEditing(e,o,"edit","end")}stopEditing(e=!1){const t=this.tableScope.cellEditorService;if(t!=null&&t.isOpen())return e?(t.cancel(),!0):t.commit("none");const s=this.tableScope.getInCellEditorCell();if(s){const o=this.tableScope.hostElement.querySelector(".ge-table-cell-editor-input, .ge-table-cell-editor-select");e||!o?this.tableScope.cancelEditing(o??void 0):this.tableScope.updateModelValueAfterEdit("body",s[0],s[1],o.value)}return!this.tableScope.isEditing()}isEditing(){return this.tableScope.isEditing()}getEditingCell(){var e;return((e=this.tableScope.cellEditorService)==null?void 0:e.getCell())??this.tableScope.getInCellEditorCell()}clearCells(e){return this.tableScope.clearCells(e)}copySelection(){return this.tableScope.getClipboardService().writeSelection(!1)}cutSelection(){return this.tableScope.getClipboardService().writeSelection(!0)}pasteText(e,t){return this.tableScope.getClipboardService().paste(e,void 0,t)}getSelectionAsText(){return this.tableScope.getClipboardService().getSelectionAsText()}cancelCut(){var e;(e=this.tableScope.clipboardService)==null||e.cancelCut()}undo(){var e;return!!((e=this.tableScope.undoService)!=null&&e.undo())}redo(){var e;return!!((e=this.tableScope.undoService)!=null&&e.redo())}canUndo(){var e;return!!((e=this.tableScope.undoService)!=null&&e.canUndo())}canRedo(){var e;return!!((e=this.tableScope.undoService)!=null&&e.canRedo())}clearUndoHistory(){var e;(e=this.tableScope.undoService)==null||e.clear()}getUndoState(){var e;return(e=this.tableScope.undoService)==null?void 0:e.getState()}batchUndoable(e,t){const s=this.tableScope.undoService;return s?s.batch(e,t):t()}hasCellFormulas(){return!!this.tableScope.tableSheet}getCellAddress(e,t){var s;return(s=this.tableScope.tableSheet)==null?void 0:s.address(e,this.toColumnIndex(t))}getCellByAddress(e){var t;return(t=this.tableScope.tableSheet)==null?void 0:t.cellOfAddress(e)}getCellInput(e,t){const s=this.toColumnIndex(t),o=this.tableScope.tableModel.getBodyModel();if(!(e<0||e>=o.getRowCount()||s<0))return this.tableScope.getCellInput(e,s)}getCellValue(e,t){const s=this.toColumnIndex(t),o=this.tableScope.tableModel.getBodyModel();if(!(e<0||e>=o.getRowCount()||s<0))return o.getValueAt(e,s)}setCellInput(e,t,s){return this.tableScope.applyCellChanges([{rowIndex:e,column:t,value:s}],"api").length>0}evaluateFormula(e){var t;return(t=this.tableScope.tableSheet)==null?void 0:t.evaluate(e)}getSheetValue(e){const t=this.tableScope.tableSheet;if(!t)return;const s=Ue(e);return s?t.cellValue(s.row,s.col):void 0}recalculate(){const e=this.tableScope.tableSheet;e&&(e.recalculate(),this.tableScope.invalidateAggregates(),this.tableScope.repaint())}getPrecedents(e,t){var s;return((s=this.tableScope.tableSheet)==null?void 0:s.precedents(e,this.toColumnIndex(t)))??[]}getDependents(e,t){var s;return((s=this.tableScope.tableSheet)==null?void 0:s.dependents(e,this.toColumnIndex(t)))??[]}getSheetEngine(){var e;return(e=this.tableScope.tableSheet)==null?void 0:e.engine}getActiveCell(){return this.tableScope.getActiveBodyCell()}goToAddress(e){const t=this.tableScope.tableSheet,s=e.trim().split(":");if(!t||s.length>2)return!1;const o=s.map(a=>t.cellOfAddress(a));if(o.some(a=>!a||a[0]<0))return!1;const[i,r]=[o[0],o[o.length-1]],l=new M(Math.min(i[0],r[0]),Math.min(i[1],r[1]),Math.max(i[0],r[0]),Math.max(i[1],r[1]));return this.tableScope.selectBodyRange(l),this.tableScope.ensureRowIsVisible(l.r1),this.tableScope.ensureColumnIsVisible(l.c1),!0}insertRows(e,t=1){return gt(this.tableScope,{kind:"insertRows",at:e,count:t})}deleteRows(e,t=1){return gt(this.tableScope,{kind:"deleteRows",at:e,count:t})}insertColumns(e,t=1){return gt(this.tableScope,{kind:"insertColumns",at:e,count:t})}deleteColumns(e,t=1){return gt(this.tableScope,{kind:"deleteColumns",at:e,count:t})}getSheetData(){const e=this.tableScope.tableModel.getBodyModel();return e instanceof Pe?e.getSheetData():void 0}toColumnIndex(e){return typeof e=="number"?e:this.getColumnIndex(e)}setDetailExpanded(e,t){return this.tableScope.setDetailExpanded(e,t,"api")}toggleDetail(e){return this.tableScope.toggleDetail(e,"api")}isDetailExpanded(e){var t;return!!((t=this.tableScope.masterDetailService)!=null&&t.isExpanded(e))}getExpandedDetailRows(){var e;return((e=this.tableScope.masterDetailService)==null?void 0:e.getExpandedRows())??[]}expandAllDetails(){var e;return((e=this.tableScope.masterDetailService)==null?void 0:e.expandAll())??0}collapseAllDetails(){var e;return((e=this.tableScope.masterDetailService)==null?void 0:e.collapseAll())??0}refreshDetail(e){var t;return!!((t=this.tableScope.masterDetailService)!=null&&t.refresh(e))}getDetailElement(e){var t;return(t=this.tableScope.masterDetailService)==null?void 0:t.getDetailElement(e)}startBatchEdit(){var t;const e=!!((t=this.tableScope.batchEditService)!=null&&t.start());return e&&this.tableScope.repaint(),e}isBatchEditing(){var e;return!!((e=this.tableScope.batchEditService)!=null&&e.isActive())}hasPendingChanges(){var e,t;return(e=this.tableScope.batchEditService)==null||e.pruneOrphans(),!!((t=this.tableScope.batchEditService)!=null&&t.hasPending())}getPendingChanges(){var e;return((e=this.tableScope.batchEditService)==null?void 0:e.getPendingChanges())??[]}commitBatchEdit(){var e;return!!((e=this.tableScope.batchEditService)!=null&&e.commit())}cancelBatchEdit(){var e;(e=this.tableScope.batchEditService)==null||e.cancel()}ensureRowIsVisible(e){return this.tableScope.ensureRowIsVisible(e)}ensureColumnIsVisible(e){return this.tableScope.ensureColumnIsVisible(e)}getDisplayedRowCount(){return this.tableScope.getDisplayedRowCount()}getFirstVisibleRowIndex(){return this.tableScope.getFirstVisibleRowIndex()}getFirstFullVisibleRowIndex(){return this.tableScope.getFirstFullVisibleRowIndex()}getLastVisibleRowIndex(){return this.tableScope.getLastVisibleRowIndex()}getLastFullVisibleRowIndex(){return this.tableScope.getLastFullVisibleRowIndex()}setLoggingActive(e){this.tableScope.loggingActive=e}isLoggingActive(){return this.tableScope.loggingActive}}function Qi(n,e){var t;return!!((t=n==null?void 0:n.isColumnLetterRow)!=null&&t.call(n,e))}class Ee{constructor(e=0,t=0,s=0,o=0,i){this.left=e,this.width=t,this.height=s,this.top=o,this.index=i}}const qt=class qt{constructor(e){this.prefix=e}static createPrefix(e){const t=(e??"").trim();return t?`ge-${t.replace(/\s+/g,"_")}`:(qt.counter++,`ge-t${qt.counter}`)}cell(e,t,s){return`${this.prefix}-${e}-r${t}-c${s}`}rowGroup(e,t){return`${this.prefix}-rg-${e}-${t}`}detailRowGroup(){return`${this.prefix}-rg-detail`}liveRegion(){return`${this.prefix}-live`}};qt.counter=0;let os=qt;class to{constructor(){this.loadingText="Loading…",this.noRowsText="No rows to show",this.noMatchesText="No matching rows",this.autoNoRows=!0,this.blockInteractionWhileLoading=!0,this.loadingDelayInMs=0,this.getOverlayElement=void 0}static create(e){const t=new to;if(e)for(const s of Object.keys(e))e[s]!==void 0&&(t[s]=e[s]);return t}}function Po(n){return n.manual?n.manual:!n.autoNoRows||n.rowCount!==0?"none":(n.unfilteredRowCount??0)>0?"noMatches":"noRows"}const er={none:"",loading:"ge-table-overlay-loading",noRows:"ge-table-overlay-no-rows",noMatches:"ge-table-overlay-no-matches"};class fn{constructor(e,t,s,o=()=>{}){this.dom=t,this.requestUpdate=o,this.shownKind="none",this.shownText="",this.shownBlocking=!1,this.bounds="",this.destroyed=!1,this.options=to.create(s),this.element=t.applyStylePosistionAbsolute(t.createDivWithClass("ge-table-overlay",e)),t.setAriaHidden(this.element),t.applyDisplayNoneStyle(this.element),this.contentElement=t.createDivWithClass("ge-table-overlay-content",this.element)}showLoading(e){var o;if(this.destroyed)return;const t=((o=this.manual)==null?void 0:o.kind)==="loading";this.manual={kind:"loading",text:e};const s=this.options.loadingDelayInMs;!t&&s>0&&!this.delayTimeout&&(this.delayTimeout=setTimeout(()=>{this.delayTimeout=void 0,this.requestUpdate()},s)),this.requestUpdate()}showNoRows(e){this.destroyed||(this.clearDelay(),this.manual={kind:"noRows",text:e},this.requestUpdate())}hide(){this.destroyed||!this.manual||(this.clearDelay(),this.manual=void 0,this.requestUpdate())}getState(){return this.shownKind}isBlocking(){return this.shownBlocking}isEventBlocked(e){const t=e.target;return this.shownBlocking&&t instanceof Node&&this.element.contains(t)}update(e,t){var a;if(this.destroyed)return;const s=this.options.autoNoRows,o=this.delayTimeout?Po({rowCount:e,unfilteredRowCount:t,autoNoRows:s}):Po({manual:(a=this.manual)==null?void 0:a.kind,rowCount:e,unfilteredRowCount:t,autoNoRows:s}),i=this.getText(o),r=o==="loading"&&this.options.blockInteractionWhileLoading;if(o===this.shownKind&&i===this.shownText&&r===this.shownBlocking)return;const l=this.shownKind;return this.render(o,i,r),{previous:l,kind:o,text:i}}setBounds(e,t,s,o){const i=`${e},${t},${s},${o}`;this.destroyed||i===this.bounds||(this.bounds=i,this.dom.applyStyle(this.element,{left:`${e}px`,top:`${t}px`,width:`${Math.max(0,s)}px`,height:`${Math.max(0,o)}px`}))}destroy(){this.destroyed||(this.destroyed=!0,this.clearDelay(),this.contentElement.replaceChildren(),this.element.remove(),this.manual=void 0,this.shownKind="none",this.shownBlocking=!1)}getText(e){var s,o;const t=this.options;switch(e){case"loading":return((s=this.manual)==null?void 0:s.text)??t.loadingText;case"noRows":return(((o=this.manual)==null?void 0:o.kind)==="noRows"?this.manual.text:void 0)??t.noRowsText;case"noMatches":return t.noMatchesText;default:return""}}render(e,t,s){const o=this.dom,i=this.element;if(this.shownKind!=="none"&&o.removeClass(er[this.shownKind],i),this.contentElement.replaceChildren(),e==="none")o.removeClass("ge-table-overlay-visible",i),o.applyDisplayNoneStyle(i);else{o.addClass(`ge-table-overlay-visible ${er[e]}`,i),o.setStyle(i,"display","flex");const r=this.getOwnElement(e,t);if(r)o.domService.appendChild(this.contentElement,r);else{e==="loading"&&o.createDivWithClass("ge-table-spinner",this.contentElement);const l=o.createDivWithClass("ge-table-overlay-text",this.contentElement);l.textContent=t}}s?o.addClass("ge-table-overlay-blocking",i):o.removeClass("ge-table-overlay-blocking",i),this.shownKind=e,this.shownText=t,this.shownBlocking=s}getOwnElement(e,t){var s,o;try{return(o=(s=this.options).getOverlayElement)==null?void 0:o.call(s,e,t)}catch(i){console.error("TableOverlay: getOverlayElement failed, the built-in content is shown",i);return}}clearDelay(){this.delayTimeout&&(clearTimeout(this.delayTimeout),this.delayTimeout=void 0)}}function gn(n,e){var s,o,i;if(n==="rtl")return"rtl";if(n!=="auto"||!e)return"ltr";if(e.isConnected&&typeof getComputedStyle=="function"){const r=getComputedStyle(e).direction;if(r==="rtl"||r==="ltr")return r}return((i=(o=(s=e.closest)==null?void 0:s.call(e,"[dir]"))==null?void 0:o.getAttribute("dir"))==null?void 0:i.toLowerCase())==="rtl"?"rtl":"ltr"}function pn(n,e){const t=n.scrollLeft;return e?Math.max(0,-t):t}function mn(n,e,t){n.scrollLeft=t?-e:e}function Mi(n,e){return e&&n!==0?-n:n}function bn(n,e,t){if(!e)return!1;const s=n.scrollWidth-n.clientWidth;return s<=0?!1:t?e>0?n.scrollLeft<0:n.scrollLeft>-s+1:e>0?n.scrollLeft+n.clientWidth<n.scrollWidth-1:n.scrollLeft>0}function wn(n,e,t,s){return s?e+t-n:n-e}function yn(n){return n.split(" ").map(e=>e==="left"?"right":e==="right"?"left":e).join(" ")}const $s=class $s{constructor(e,t,s,o){this.hostElement=e,this.tableModel=t,this.dom=s,this.tableOptions=o,this.scrollTop=0,this.horizontalScrollBarHeight=0,this.verticalScrollBarWidth=0,this.areaBodyWestGeo=new Ee,this.areaBodyCenterGeo=new Ee,this.areaBodyEastGeo=new Ee,this.hostAttributesBefore=new Map;const i=this.hostElement;i.innerText="",this.direction=gn(o==null?void 0:o.direction,i),this.dom.setDirection(this.direction),this.dom.setAttribute(i,"tabindex","0"),this.ariaIds=new os(os.createPrefix(i.id)),this.initHostAria(),this.setHostAriaAttribute("dir",this.direction),this.dom.setStyle(this.dom.addClass("ge-table",i),"position","relative"),this.hoverRow=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-hover-row",i)),this.hoverColumn=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-hover-column",i)),this.draggingColumn=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-dragging-column",i)),this.areaHeaderWest=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-header ge-table-header-west",i,"header","west"))),this.areaHeaderCenter=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-header ge-table-header-center",i,"header","center"))),this.areaHeaderEast=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-header ge-table-header-east",i,"header","east"))),this.areaBodyWest=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-body ge-table-body-west",i,"body","west"))),this.areaBodyEast=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-body ge-table-body-east",i,"body","east"))),this.areaFooterWest=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-footer ge-table-footer-west",i,"footer","west"))),this.areaFooterCenter=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-footer ge-table-footer-center",i,"footer","center"))),this.areaFooterEast=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-footer ge-table-footer-east",i,"footer","east"))),this.scrollViewport=s.applyStyleOverflowAuto(this.tableOptions.overflowX??"auto",this.tableOptions.overflowY??"auto",s.applyStyleNoPadding(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-scroll-viewport",i,"body","center")))),this.contentWrapperDiv=s.applyStyleNoPadding(s.applyStylePosistionRelative(s.createDivWithClass("ge-table-scroll-content-wrapper",this.scrollViewport))),this.contentDiv=s.applyStyleNoPadding(s.applyStylePosistionRelative(s.createDivWithClass("ge-table-scroll-content",this.contentWrapperDiv))),s.applyStyle(this.contentDiv,{position:"sticky",top:"0",left:"0"}),this.areaBodyCenter=s.appendRelativeChildDiv(s.createDivWithClass("ge-table-body-center",this.contentDiv));const r=(a,c)=>a?s.applyStylePosistionAbsolute(s.createDivWithClass(c,i)):void 0;this.borderHeaderBottom=r(o==null?void 0:o.headerSeparatorBorderVisible,"ge-table-header-border"),this.borderFixedWest=r(o==null?void 0:o.fixedWestSeparatorBorderVisible,"ge-table-west-fixed-column-border"),this.borderFixedEast=r(o==null?void 0:o.fixedEastSeparatorBorderVisible,"ge-table-east-fixed-column-border"),this.borderFooterTop=r(o==null?void 0:o.footerSeparatorBorderVisible,"ge-table-footer-border"),[this.hoverRow,this.hoverColumn,this.draggingColumn,this.borderHeaderBottom,this.borderFixedWest,this.borderFixedEast,this.borderFooterTop].forEach(a=>{a&&s.setAriaHidden(a)}),o!=null&&o.shortcutActionsDisabled||s.setAttribute(this.scrollViewport,"tabindex","-1"),[this.areaHeaderWest,this.areaHeaderCenter,this.areaHeaderEast,this.areaBodyWest,this.areaBodyEast,this.areaFooterWest,this.areaFooterCenter,this.areaFooterEast,this.areaBodyCenter].forEach(a=>s.setAttribute(a.parent,"role","presentation")),s.setAttribute(this.contentWrapperDiv,"role","presentation"),s.setAttribute(this.contentDiv,"role","presentation");const l=[];for(const a of["header","body","footer"])for(const c of["west","center","east"]){const h=this.ariaIds.rowGroup(a,c),d=this.getAreaChild(a,c);s.setAttribute(d,"id",h),s.setAttribute(d,"role","presentation"),l.push(h)}this.setHostAriaAttribute("aria-owns",l.join(" ")),this.tableOverlay=new fn(i,s,o==null?void 0:o.overlayOptions,()=>this.updateOverlay())}isRtl(){return this.direction==="rtl"}getViewportScrollLeft(){return pn(this.scrollViewport,this.isRtl())}setViewportScrollLeft(e){mn(this.scrollViewport,e,this.isRtl())}clientXToHostX(e){const t=this.hostElement,s=t.getBoundingClientRect();return wn(e,s.left+t.clientLeft,t.clientWidth,this.isRtl())}updateOverlay(){}setHostAriaAttribute(e,t){const s=this.hostElement;this.hostAttributesBefore.has(e)||this.hostAttributesBefore.set(e,s.getAttribute(e)),t===void 0?s.hasAttribute(e)&&this.dom.removeAttribute(s,e):s.getAttribute(e)!==t&&this.dom.setAttribute(s,e,t)}restoreHostAriaAttribute(e){const t=this.hostAttributesBefore.get(e)??null;t===null?this.hostElement.hasAttribute(e)&&this.dom.removeAttribute(this.hostElement,e):this.hostElement.getAttribute(e)!==t&&this.dom.setAttribute(this.hostElement,e,t)}removeHostAria(){this.hostAttributesBefore.forEach((e,t)=>{e===null?this.dom.removeAttribute(this.hostElement,t):this.dom.setAttribute(this.hostElement,t,e)}),this.hostAttributesBefore.clear()}initHostAria(){const e=this.tableOptions,t=Z(this.tableModel.getAreaModel("body"));this.setHostAriaAttribute("role",t?"treegrid":"grid"),e!=null&&e.ariaLabelledBy?this.setHostAriaAttribute("aria-labelledby",e.ariaLabelledBy):e!=null&&e.ariaLabel&&this.setHostAriaAttribute("aria-label",e.ariaLabel),e!=null&&e.ariaDescribedBy&&this.setHostAriaAttribute("aria-describedby",e.ariaDescribedBy)}getAreaChild(e,t){return{"header-west":this.areaHeaderWest,"header-center":this.areaHeaderCenter,"header-east":this.areaHeaderEast,"body-west":this.areaBodyWest,"body-center":this.areaBodyCenter,"body-east":this.areaBodyEast,"footer-west":this.areaFooterWest,"footer-center":this.areaFooterCenter,"footer-east":this.areaFooterEast}[`${e}-${t}`].child}adjustContainersAndRows(){this.layoutContainers(),this.adjustAfterScrolling()}layoutContainers(){const e=this.tableModel.getPadding(),t=this.hostElement.clientWidth,s=this.hostElement.clientHeight;this.dom.applyStyle(this.scrollViewport,{width:`${t-e.left}px`,height:`${s-e.top}px`,top:`${e.top}px`,left:`${e.left}px`}),this.horizontalScrollBarHeight=this.measureHorizontalScrollBarHeight(),this.verticalScrollBarWidth=this.measureVerticalScrollBarWidth();const o=this.getLayoutWidth(),i=this.getLayoutHeight();this.scrollTop=this.scrollViewport.scrollTop,this.dom.applyStyle(this.contentDiv,{width:`${this.scrollViewport.clientWidth}px`,height:`${this.scrollViewport.clientHeight}px`}),this.areaBodyWestGeo.width=e.left,this.areaBodyWestGeo.height=i-e.top-e.bottom,this.areaBodyWestGeo.top=e.top,this.areaBodyWestGeo.left=0,this.dom.applyStyleInPx(this.areaBodyWest.parent,this.areaBodyWestGeo),this.borderFixedWest&&this.tableModel.getFixedLeftColumnCount()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFixedWest,{width:"1px",height:`${this.areaBodyWestGeo.height}px`,top:`${this.areaBodyWestGeo.top}px`,left:`${this.areaBodyWestGeo.width}px`})):this.borderFixedWest&&this.dom.applyDisplayNoneStyle(this.borderFixedWest),this.areaBodyEastGeo.width=e.right,this.areaBodyEastGeo.height=i-e.top-e.bottom,this.areaBodyEastGeo.top=e.top,this.areaBodyEastGeo.left=o-e.right,this.dom.applyStyleInPx(this.areaBodyEast.parent,this.areaBodyEastGeo),this.borderFixedEast&&this.tableModel.getFixedRightColumnCount()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFixedEast,{width:"1px",height:`${this.areaBodyEastGeo.height}px`,top:`${this.areaBodyEastGeo.top}px`,left:`${this.areaBodyEastGeo.left}px`})):this.borderFixedEast&&this.dom.applyDisplayNoneStyle(this.borderFixedEast),this.areaBodyCenterGeo.width=o-e.left-e.right,this.areaBodyCenterGeo.height=i-e.top-e.bottom,this.areaBodyCenterGeo.top=0,this.areaBodyCenterGeo.left=0,this.dom.applyStyleInPx(this.areaBodyCenter.parent,this.areaBodyCenterGeo),this.dom.applyStyle(this.areaHeaderCenter.parent,{width:`${o-e.left-e.right}px`,height:`${e.top}px`,top:"0",left:`${e.left}px`}),this.dom.applyStyle(this.areaHeaderWest.parent,{width:`${e.left}px`,height:`${e.top}px`,top:"0",left:"0"}),this.dom.applyStyle(this.areaHeaderEast.parent,{width:`${e.right}px`,height:`${e.top}px`,top:"0",left:`${o-e.right}px`}),this.borderHeaderBottom&&this.tableModel.isHeaderVisibe()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderHeaderBottom,{width:`${o}px`,height:"1px",top:`${e.top}px`,left:"0px"})):this.borderHeaderBottom&&this.dom.applyDisplayNoneStyle(this.borderHeaderBottom),this.dom.applyStyle(this.areaFooterWest.parent,{width:`${e.left}px`,height:`${e.bottom}px`,top:`${i-e.bottom}px`,left:"0"}),this.dom.applyStyle(this.areaFooterCenter.parent,{width:`${o-e.left-e.right}px`,height:`${e.bottom}px`,top:`${i-e.bottom}px`,left:`${e.left}px`}),this.dom.applyStyle(this.areaFooterEast.parent,{width:`${e.right}px`,height:`${e.bottom}px`,top:`${i-e.bottom}px`,left:`${o-e.right}px`}),this.borderFooterTop&&this.tableModel.isFooterVisibe()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFooterTop,{width:`${o}px`,height:"1px",top:`${i-e.bottom}px`,left:"0px"})):this.borderFooterTop&&this.dom.applyDisplayNoneStyle(this.borderFooterTop),this.tableOverlay.setBounds(0,e.top,Math.min(o,e.left+this.scrollViewport.clientWidth),i-e.top-e.bottom),this.adjustDetailLayerBounds(0,e.top,Math.min(o,e.left+this.scrollViewport.clientWidth),Math.max(0,Math.min(i-e.top-e.bottom,this.scrollViewport.clientHeight)))}getLayoutHeight(){return Math.max(0,this.hostElement.clientHeight-this.horizontalScrollBarHeight)}getLayoutWidth(){return Math.max(0,this.hostElement.clientWidth-this.verticalScrollBarWidth)}measureHorizontalScrollBarHeight(){const e=this.scrollViewport;return Math.max(0,e.offsetHeight-e.clientHeight)}measureVerticalScrollBarWidth(){const e=this.scrollViewport;return Math.max(0,e.offsetWidth-e.clientWidth)}adjustDetailLayerBounds(e,t,s,o){}adjustAfterScrolling(){}getBodyContentHeight(){return this.tableModel.getContentHeightInPixel()}resetSizeOfWrapperDiv(){const e=`${this.tableModel.getContentWidthInPixel()}px`,t=this.getBodyContentHeight()+1,s=`${Math.min(t,$s.maxScrollHeightInPx)}px`;this.dom.setStyle(this.contentWrapperDiv,"width",e),this.dom.setStyle(this.contentWrapperDiv,"height",s)}};$s.maxScrollHeightInPx=8e6;let is=$s;class Cn{constructor(e,t){this.tableModel=e,this.areaModel=t,this.colAndRowspanRanges=void 0,this.rowCountAtInit=-1}init(){if(this.rowCountAtInit=this.areaModel.getRowCount(),this.areaModel.getMaxColspan()<2&&this.areaModel.getMaxRowspan()<2){this.colAndRowspanRanges=void 0;return}this.colAndRowspanRanges=[];const e=this.areaModel.getRowCount();for(let t=0;t<e;t++)this.scanRow(t,this.colAndRowspanRanges)}scanRow(e,t){const s=this.tableModel.getColumnCount();for(let o=0;o<s;o++){let i=this.areaModel.getColspanAt(e,o),r=this.areaModel.getRowspanAt(e,o);if(i>1||r>1){i===0&&(i=1),r===0&&(r=1);const l="gammaCells"in this.areaModel;t.push(new M(e,o,e+r-1,o+i-1,l))}}}updateForInsertedRows(e){var s;if(this.rowCountAtInit<0||(s=this.colAndRowspanRanges)!=null&&s.length)return!1;const t=[];if(this.areaModel.getMaxColspan()>=2||this.areaModel.getMaxRowspan()>=2)for(let o=0;o<e.length;o++)this.scanRow(e[o],t);return this.colAndRowspanRanges=t.length?t:this.colAndRowspanRanges,this.rowCountAtInit=this.areaModel.getRowCount(),!0}initIfRowCountChanged(){return this.areaModel.getRowCount()===this.rowCountAtInit?!1:(this.init(),!0)}getRanges(){return this.colAndRowspanRanges?this.colAndRowspanRanges:[]}isInRange(e,t){if(this.colAndRowspanRanges){for(const s of this.colAndRowspanRanges)if(s.isInRange(e,t))return!0}return!1}}class bt{constructor(e,t,s,o){this.headerRowCount=e,this.bodyRowCount=t,this.footerRowCount=s,this.colIndexMap=o}static create(e){var a,c,h;const t=e.isHeaderVisibe()?Math.max(0,((a=e.getAreaModel("header"))==null?void 0:a.getRowCount())??0):0,s=e.isFooterVisibe()?Math.max(0,((c=e.getAreaModel("footer"))==null?void 0:c.getRowCount())??0):0,o=((h=e.getAreaModel("body"))==null?void 0:h.getRowCount())??0,i=e.getColumnCount(),r=new Array(Math.max(0,i));let l=0;for(let d=0;d<i;d++)r[d]=e.getColumnWidth(d)>0?++l:0;return new bt(t,o,s,r)}get rowCount(){return this.bodyRowCount<0?-1:this.headerRowCount+this.bodyRowCount+this.footerRowCount}get colCount(){let e=0;for(const t of this.colIndexMap)t>0&&e++;return e}rowIndex(e,t){return e==="header"?t+1:e==="body"?this.headerRowCount+t+1:this.headerRowCount+Math.max(0,this.bodyRowCount)+t+1}colIndex(e){return this.colIndexMap[e]??0}colSpan(e,t){let s=0;for(let o=e;o<e+t;o++)(this.colIndexMap[o]??0)>0&&s++;return Math.max(1,s)}}class Sn{constructor(){this.positions=new WeakMap,this.sizes=new WeakMap}get(e,t){const s=e.getRowByIndex(t);if(!s)return;const o=e.getFilteredFlattenRows();o!==this.displayedRows&&(this.displayedRows=o,this.positions=new WeakMap,this.sizes=new WeakMap);const i=s.parent??e;let r=this.positions.get(i);if(!r){const a=s.parent?e.getDisplayedChildren(s.parent):e.getDisplayedRootRows();r=new Map,a.forEach((c,h)=>r.set(c,h+1)),this.positions.set(i,r),this.sizes.set(i,a.length)}const l=e.hasDisplayedChildren(s);return{level:(s.deep??0)+1,setSize:Math.max(1,this.sizes.get(i)??1),posInSet:r.get(s)??1,expanded:l?!!s.expanded:void 0}}}class xn{constructor(){this.rowCount=0,this.heightOf=()=>0,this.extraIndices=new Int32Array(0),this.extraHeights=new Float64Array(0),this.extraPrefix=new Float64Array(1)}setRows(e,t,s){if(this.rowCount=Math.max(0,Math.floor(e)||0),this.heightOf=t,this.constantHeight=s!==void 0&&s>0?s:void 0,this.prefix=void 0,this.extraIndices.length&&this.extraIndices[this.extraIndices.length-1]>=this.rowCount){const o=[],i=[];this.extraIndices.forEach((r,l)=>{r<this.rowCount&&(o.push(r),i.push(this.extraHeights[l]))}),this.setExtras(o,i)}}setExtras(e,t){const s=new Map;for(let i=0;i<e.length;i++){const r=e[i],l=t[i];r>=0&&r<this.rowCount&&l>0&&s.set(r,(s.get(r)??0)+l)}const o=Int32Array.from(s.keys()).sort();this.extraIndices=o,this.extraHeights=Float64Array.from(o,i=>s.get(i)),this.rebuildExtraPrefix()}setExtraHeight(e,t){const s=this.findExtra(e);return s<0||!(t>0)||this.extraHeights[s]===t?!1:(this.extraHeights[s]=t,this.rebuildExtraPrefix(),!0)}setExtra(e,t){if(!(e>=0&&e<this.rowCount))return!1;const s=this.findExtra(e);if(s>=0){if(t>0)return this.setExtraHeight(e,t);const l=Array.from(this.extraIndices),a=Array.from(this.extraHeights);return l.splice(s,1),a.splice(s,1),this.extraIndices=Int32Array.from(l),this.extraHeights=Float64Array.from(a),this.rebuildExtraPrefix(),!0}if(!(t>0))return!1;const o=this.countExtrasBelow(e),i=Array.from(this.extraIndices),r=Array.from(this.extraHeights);return i.splice(o,0,e),r.splice(o,0,t),this.extraIndices=Int32Array.from(i),this.extraHeights=Float64Array.from(r),this.rebuildExtraPrefix(),!0}getRowCount(){return this.rowCount}getExtraCount(){return this.extraIndices.length}hasPrefixSums(){return!!this.prefix}getRowHeight(e){if(this.constantHeight!==void 0)return this.constantHeight;const t=this.ensurePrefix();return e>=0&&e<this.rowCount?t[e+1]-t[e]:0}getExtraHeight(e){const t=this.findExtra(e);return t<0?0:this.extraHeights[t]}getExtraBefore(e){return this.extraPrefix[this.countExtrasBelow(e)]}getExtraTotal(){return this.extraPrefix[this.extraIndices.length]}getTop(e){const t=Math.min(Math.max(0,Math.floor(e)||0),this.rowCount);return this.getBaseTop(t)+this.extraPrefix[this.countExtrasBelow(t)]}getTotalHeight(){return this.getTop(this.rowCount)}findIndexAt(e){const t=this.rowCount;if(t<1)return-1;if(!(e>0))return 0;const s=this.constantHeight;if(s!==void 0&&!this.extraIndices.length){let r=Math.min(t-1,Math.floor(e/s));for(;r>0&&r*s>e;)r--;for(;r<t-1&&(r+1)*s<=e;)r++;return r}let o=0,i=t-1;for(;o<i;){const r=o+i>>>1;this.getTop(r+1)>e?i=r:o=r+1}return o}getBaseTop(e){return this.constantHeight!==void 0?e*this.constantHeight:this.ensurePrefix()[e]}ensurePrefix(){if(!this.prefix){const e=this.rowCount,t=new Float64Array(e+1);let s=0;for(let o=0;o<e;o++)s+=this.heightOf(o)||0,t[o+1]=s;this.prefix=t}return this.prefix}rebuildExtraPrefix(){const e=this.extraIndices.length,t=new Float64Array(e+1);for(let s=0;s<e;s++)t[s+1]=t[s]+this.extraHeights[s];this.extraPrefix=t}countExtrasBelow(e){const t=this.extraIndices;let s=0,o=t.length;for(;s<o;){const i=s+o>>>1;t[i]<e?s=i+1:o=i}return s}findExtra(e){const t=this.countExtrasBelow(e);return t<this.extraIndices.length&&this.extraIndices[t]===e?t:-1}}class vn extends is{constructor(e,t,s,o){var r,l,a,c,h;if(super(e,t,s,o),this.firstVisibleRowIndex=-1,this.lastVisibleRowIndex=-1,this.firstFullVisibleRowIndex=-1,this.lastFullVisibleRowIndex=-1,this.displayedRowCount=0,this.pixelLimitForFullVisible=5,this.loggingActive=!1,this.dragging=!1,this.editing=!1,this.storedColumnWidths=[],this.scrollLeft=0,this.scrollViewportLeft=0,this.scrollFactorY=0,this.scrollFactorX=0,this.cleanupFunctions={header:[],body:[],footer:[]},this.tree=!1,this.colAndRowspanModels=new ee,this.draggingTargetColumnIndex=-1,this.contentScrollTop=0,this.renderedScrollTop=Number.NaN,this.renderedBodyRows={count:0,first:0,offset:0,last:-1,atEnd:!0},this.renderedScrollLeft=Number.NaN,this.removables=[],this.treeAriaInfo=new Sn,this.ariaSelectionKind="none",this.renderedSpanCells=new Set,this.bodyRowLayout=new xn,this.bodyRowLayoutDirty=!0,this.adjustingRowNumberWidth=!1,this.adjustingRelativeWidths=!1,this.relativeWidthsBase=-1,this.rowNumberRemeasureScheduled=!1,this.ariaTexts=me.create(o==null?void 0:o.ariaTexts),(l=(r=this.tableModel).getSelectionModel)!=null&&l.call(r))this.getSelectionModel=()=>this.tableModel.getSelectionModel();else if((a=this.tableOptions)!=null&&a.getSelectionModel)this.getSelectionModel=this.tableOptions.getSelectionModel;else{const d=(c=this.tableOptions)!=null&&c.spreadsheet?new pe("range","multi"):new pe;this.getSelectionModel=()=>d}if((h=this.tableOptions)!=null&&h.getFocusModel)this.getFocusModel=this.tableOptions.getFocusModel;else{const d=new xi("cell");this.getFocusModel=()=>d}Z(t.getAreaModel("body"))&&(this.tree=!0),["header","body","footer"].forEach(d=>{var u;this.colAndRowspanModels[d]=new Cn(t,t.getAreaModel(d)),(u=this.colAndRowspanModels[d])==null||u.init()})}getDomService(){return this.dom}getBodyViewport(){const e=this.hostElement,t=e.getBoundingClientRect();return{top:t.top+e.clientTop+this.tableModel.getPadding().top,height:this.areaBodyCenterGeo.height,left:t.left+e.clientLeft,width:this.scrollViewport.clientWidth,contentScrollTop:this.contentScrollTop}}getBodyCellRectInHost(e,t){const s=this.tableModel,o=s.getBodyModel(),i=s.getPadding(),r=this.getLayoutWidth(),l=this.getLayoutHeight(),a=i.top+this.getBodyRowTop(e)-this.contentScrollTop,c=this.getColumnLeftInHost(t,s.getXPosByColumnIndex(t)),h=s.getColumnCount(),d=s.getFixedLeftColumnCount(),u=s.getFixedRightColumnCount();let f=i.left,g=r-i.right;return t<d?(f=0,g=i.left):u>0&&t>=h-u&&(f=r-i.right,g=r),{left:c,top:a,width:s.getColumnWidth(t),height:o.getRowHeight(e),clipLeft:f,clipRight:g,clipTop:i.top,clipBottom:l-i.bottom}}getBodyCellAtHostPoint(e,t){const s=this.tableModel,i=s.getBodyModel().getRowCount(),r=s.getColumnCount();if(i<1||r<1)return[-1,-1];const l=s.getPadding(),a=this.getLayoutWidth(),c=this.getLayoutHeight()-l.top-l.bottom,h=Math.min(Math.max(t-l.top,0),Math.max(0,c-1))+this.contentScrollTop,d=this.getBodyRowIndexAtY(h),u=s.getFixedLeftColumnCount(),f=s.getFixedRightColumnCount();let g,p,m;if(u>0&&e<l.left)[g,p,m]=[0,u-1,e];else if(f>0&&e>=a-l.right){const y=r-f;[g,p,m]=[y,r-1,e-(a-l.right)+s.getXPosByColumnIndex(y)]}else{const y=a-l.right,C=Math.min(Math.max(e,l.left),Math.max(l.left,y-1));[g,p,m]=[u,r-f-1,C+this.getContentScrollLeft()]}let b=p;for(let y=g;y<=p;y++)if(m<s.getXPosByColumnIndex(y)+s.getColumnWidth(y)){b=y;break}return[d,Math.min(r-1,Math.max(g,b))]}getBodyRowLayout(){var o,i;const e=this.tableModel.getBodyModel(),t=e.getRowCount(),s=this.bodyRowLayout;if(this.bodyRowLayoutDirty||this.bodyRowLayoutModel!==e||s.getRowCount()!==t){this.bodyRowLayoutDirty=!1,this.bodyRowLayoutModel=e;const r=this.tableModel;s.setRows(t,a=>r.getRowHeight("body",a),(o=e.getConstantRowHeight)==null?void 0:o.call(e));const l=(i=this.masterDetailService)==null?void 0:i.computeExtras();s.setExtras((l==null?void 0:l.rowIndices)??[],(l==null?void 0:l.heights)??[])}return s}invalidateRowLayout(){this.bodyRowLayoutDirty=!0}setBodyRowExtra(e,t){const s=this.tableModel.getBodyModel();return this.bodyRowLayoutDirty||this.bodyRowLayoutModel!==s||this.bodyRowLayout.getRowCount()!==s.getRowCount()?!1:(this.bodyRowLayout.setExtra(e,t),!0)}hasBodyRowExtras(){var e;return!!((e=this.masterDetailService)!=null&&e.hasExpanded())&&this.getBodyRowLayout().getExtraCount()>0}getBodyRowTop(e){return this.getBodyRowLayout().getTop(e)}getBodyRowIndexAtY(e){return this.getBodyRowLayout().findIndexAt(e)}getScrollerToContentRatioY(){if(!this.isScrollHeightCapped())return 1;const e=this.getContentScrollRangeY(),t=this.getScrollerRangeY();return e>0&&t>0?t/e:1}isEditing(){var e;return this.editing||!!((e=this.cellEditorService)!=null&&e.isOpen())}getInCellEditorCell(){return this.editing&&this.editorRenderer&&(this.editorRendererRow??-1)>=0?[this.editorRendererRow,this.editorRendererColumn]:void 0}setEditorDraft(e,t,s){if(this.editing&&this.editorRendererRow===e&&this.editorRendererColumn===t){let o=null,i=null;try{o=s.selectionStart,i=s.selectionEnd}catch{}this.editorDraft={rowIndex:e,columnIndex:t,value:s.value,start:o,end:i}}}shiftEditorRow(e){if(this.editing&&this.editorRenderer&&(this.editorRendererRow??-1)>=0){const t=e.mapIndex(this.editorRendererRow);if(t<0){this.resetEditorRenderer();return}this.editorRendererRow=t}if(this.editorDraft){const t=e.mapIndex(this.editorDraft.rowIndex);this.editorDraft=t<0?void 0:{...this.editorDraft,rowIndex:t}}}resetEditorRenderer(){this.editorRenderer=void 0,this.editorRendererRow=-1,this.editorRendererColumn=-1,this.editing=!1,this.editorDraft=void 0}clearSelection(e=!1){if(this.getSelectionModel){const t=this.getSelectionModel();t==null||t.clear(),e&&this.repaint()}}initRenderEditor(e,t){var o;let s=(o=this.tableModel.getColumnDef(t))==null?void 0:o.getEditRenderer;if(s||(s=this.tableOptions.getEditRenderer),s)if(this.editorRenderer=s(e,t),this.editorRenderer){this.editorRendererRow=e,this.editorRendererColumn=t,this.editing=!0,this.repaint();const i=this.hostElement.querySelector("input.ge-table-cell-editor-input");i&&i.focus()}else this.resetEditorRenderer()}repaint(){this.adjustAfterScrolling()}invalidateAggregates(e){var t,s;e||this.invalidateRowLayout();for(const o of["header","body","footer"])(s=(t=this.tableModel.getAreaModel(o))==null?void 0:t.invalidateDerivedValues)==null||s.call(t,e)}repaintHard(e){var t;for(const s of["header","body","footer"])(t=this.colAndRowspanModels[s])==null||t.initIfRowCountChanged();this.tableModel.recalcHeightAndPadding(),this.invalidateRowLayout(),this.resetSizeOfWrapperDiv(),this.layoutContainers(),e&&this.setContentScrollPosition(e.px,e.py),this.adjustAfterScrolling()}rememberRenderedBodyRows(){const e=this.tableModel.getBodyModel().getRowCount();if(e<=0){this.renderedBodyRows={count:Math.max(0,e),first:0,offset:0,last:-1,atEnd:!0};return}const t=this.contentScrollTop,s=this.getBodyRowIndexAtY(t),o=this.getBodyRowIndexAtY(t+Math.max(0,this.areaBodyCenterGeo.height-1)),i=this.getContentScrollRangeY(),r=Math.max(1,this.tableModel.getRowHeight("body",e-1)/2);this.renderedBodyRows={count:e,first:s,offset:t-this.getBodyRowTop(s),last:o,atEnd:i<=0||t>=i-r}}updateRowCountWithoutRender(e){for(const s of["header","body","footer"]){const o=this.colAndRowspanModels[s];if(o==null||o.initIfRowCountChanged(),o!=null&&o.getRanges().length)return!1}const t=this.scrollViewport.clientWidth;return this.tableModel.recalcHeightAndPadding(),this.invalidateRowLayout(),this.resetSizeOfWrapperDiv(),this.layoutContainers(),this.scrollViewport.clientWidth!==t?!1:(this.setContentScrollPosition(void 0,e),this.renderedScrollTop=this.scrollViewport.scrollTop,this.scrollTop=this.scrollViewport.scrollTop,this.renderedBodyRows={...this.renderedBodyRows,count:this.tableModel.getBodyModel().getRowCount(),atEnd:!1},this.setHostAttribute("aria-rowcount",`${bt.create(this.tableModel).rowCount}`),!0)}setContentScrollPosition(e,t){const s=this.scrollViewport,o={};if(e!==void 0&&(o.left=Mi(e,this.isRtl())),t===void 0)return e!==void 0&&s.scrollTo(o),!1;const i=this.getContentScrollRangeY(),r=this.getScrollerRangeY();if(i>0&&r>0){const l=Math.min(i,Math.max(0,t));return o.top=l/i*r,s.scrollTo(o),this.pendingContentScroll={scrollTop:s.scrollTop,contentTop:l},!0}return o.top=t,s.scrollTo(o),!1}onViewportScroll(){this.scrollViewport.scrollTop===this.renderedScrollTop&&this.getViewportScrollLeft()===this.renderedScrollLeft||this.adjustAfterScrolling()}recalcColumnWidths(e){const t=this.getAvailableColumnWidth(e);t>0&&this.setParentWidth(t),this.tableModel.init(),this.repaintHard()}setParentWidth(e){this.relativeWidthsBase=e,this.tableModel.setParentWidth(e)}hasRelativeColumnWidths(){var e,t,s;return!!((s=(t=(e=this.tableModel).getColumnDefs)==null?void 0:t.call(e))!=null&&s.some(o=>{var i,r;return((i=o.width)==null?void 0:i.unit)==="weight"||((r=o.width)==null?void 0:r.unit)==="%"}))}layoutContainers(){super.layoutContainers(),this.adjustRelativeColumnWidthsToScrollBar()}adjustRelativeColumnWidthsToScrollBar(){if(this.adjustingRelativeWidths||!this.hasRelativeColumnWidths())return;const e=this.getAvailableColumnWidth();if(!(e<=0||e===this.relativeWidthsBase)){this.adjustingRelativeWidths=!0;try{this.setParentWidth(e),this.tableModel.init(),this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.layoutContainers()}finally{this.adjustingRelativeWidths=!1}}}getAvailableColumnWidth(e=this.hostElement.clientWidth){const t=Math.max(0,this.scrollViewport.offsetWidth-this.scrollViewport.clientWidth);return Math.max(0,e-this.tableModel.getPadding().left-t)}adjustAfterScrolling(){var i,r,l,a;if(!this.adjustingRowNumberWidth&&this.adjustRowNumberColumnWidth()){this.adjustingRowNumberWidth=!0;try{if((l=(r=(i=this.tableModel).getColumnDefs)==null?void 0:r.call(i))!=null&&l.some(c=>{var h,d;return((h=c.width)==null?void 0:h.unit)==="weight"||((d=c.width)==null?void 0:d.unit)==="%"})){this.tableModel.recalcPadding();const c=this.getAvailableColumnWidth();c>0&&(this.setParentWidth(c),this.tableModel.init())}this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()}finally{this.adjustingRowNumberWidth=!1}return}for(const c of this.removables)c.remove();if(this.hideHoverRow(),this.hideHoverColumn(),this.scrollTop=this.scrollViewport.scrollTop,this.scrollLeft=this.getViewportScrollLeft(),this.scrollViewportLeft=this.scrollLeft,this.scrollFactorY=this.scrollTop/(this.scrollViewport.scrollHeight-this.scrollViewport.clientHeight),this.scrollFactorX=this.scrollLeft/(this.scrollViewport.scrollWidth-this.scrollViewport.clientWidth),isNaN(this.scrollFactorY)&&(this.scrollFactorY=0),this.pendingContentScroll){const c=this.getContentScrollRangeY();Math.abs(this.scrollTop-this.pendingContentScroll.scrollTop)<=1&&c>0?this.scrollFactorY=Math.min(1,Math.max(0,this.pendingContentScroll.contentTop/c)):this.pendingContentScroll=void 0}isNaN(this.scrollFactorX)&&(this.scrollFactorX=0);const e=this.hostElement.clientWidth,t=this.hostElement.clientHeight,s=this.areaBodyWest.child.clientWidth,o=this.areaHeaderCenter.child.clientHeight;this.areaHeightsOfRenderPass={body:this.areaBodyCenter.child.clientHeight,footer:this.areaFooterCenter.child.clientHeight,header:o},this.ariaGridInfo=bt.create(this.tableModel),this.ariaSelectionKind=this.getAriaSelectionKind(),this.ariaFocusedCell=void 0,this.renderedSpanCells.clear();try{this.adjustBody(),this.adjustArea("footer"),this.adjustArea("header")}finally{this.areaHeightsOfRenderPass=void 0}this.updateHostAria(),this.tableOptions.tableTopBorderVisible&&this.removables.push(this.dom.addHorizontalBorder(new Ee(0,e,1,0),this.hostElement,"ge-table-border")),this.tableOptions.tableBottomBorderVisible&&this.removables.push(this.dom.addHorizontalBorder(new Ee(0,e,1,t-1),this.hostElement,"ge-table-border")),this.tableModel.getFixedLeftColumnCount()>0&&this.tableOptions.fixedWestSeparatorBorderVisible!==!1&&this.removables.push(this.dom.addVerticalBorder(new Ee(s,1,t,0),this.hostElement,"ge-table-body-west-vertical-border")),this.tableModel.isHeaderVisibe()&&this.tableOptions.headerSeparatorBorderVisible!==!1&&this.removables.push(this.dom.addHorizontalBorder(new Ee(0,e,1,o),this.hostElement,"ge-table-body-west-vertical-border")),this.updateOverlay(),(a=this.rowNumberWidth)!=null&&a.approximate&&!this.rowNumberRemeasureScheduled&&this.findRowNumberLabel()&&(this.rowNumberRemeasureScheduled=!0,requestAnimationFrame(()=>{this.hostElement.isConnected&&this.repaint()})),this.rememberRenderedBodyRows(),this.afterRenderPass(),this.renderedScrollTop=this.scrollTop,this.renderedScrollLeft=this.scrollLeft}afterRenderPass(){}updateOverlay(){var r;const e=this.tableOverlay;if(!e)return;const t=this.tableModel.getBodyModel(),s=t.getRowCount(),o=s===0?(r=t.getUnfilteredRowCount)==null?void 0:r.call(t):void 0,i=e.update(s,o);i&&this.onOverlayChanged(i)}onOverlayChanged(e){}checkForScrollPosSaving(){this.afterRenderPass()}updateCells(e,t=!1){const s=this.tableModel.getBodyModel(),o=s.getRowCount(),i=this.tableSheet,r=()=>e.forEach(c=>{i&&c.area==="body"&&i.isFormulaInput(c.columnIndex,c.value)?this.setRawValue(c.rowIndex,c.columnIndex,c.value):this.tableModel.getAreaModel(c.area).setValue(c.rowIndex,c.columnIndex,c.value),!t&&!(i&&c.area==="body")&&this.rerenderCellContent(c)}),l=ne(s)?s.batch(r):(r(),!1),a=this.tableSheet?e.filter(c=>c.area==="body"):[];if(a.length&&(this.tableSheet.cellsWritten(a.map(c=>({row:void 0,rowIndex:c.rowIndex,columnIndex:c.columnIndex,property:"",oldValue:void 0,newValue:c.value}))),t=!0),l){this.invalidateAggregates(),this.repaintHard();return}if(e.length){const c=e[0].area;this.invalidateAggregates(e.every(h=>h.area===c)?{area:c,rowIndices:e.map(h=>h.rowIndex)}:void 0)}e.length&&s.getRowCount()!==o?this.repaintHard():t?this.repaint():e.length&&(this.rerenderDerivedFooterCells(e),this.rerenderGroupRowCells(),this.rerenderCalculatedCells())}setRawValue(e,t,s){const o=this.tableModel.getBodyModel(),i=this.tableModel.getColumnDef(t),r=i==null?void 0:i.editInputPipe;if(!i||!r||Object.isFrozen(i))return o.setValue(e,t,s);i.editInputPipe=void 0;try{return o.setValue(e,t,s)}finally{i.editInputPipe=r}}rerenderCalculatedCells(){var o;const e=this.tableModel.getBodyModel();if(!((o=e.hasDerivedColumns)!=null&&o.call(e)))return;const t=new Map;this.hostElement.querySelectorAll('div.ge-table-col-div[data-area="body"][data-row-index][data-col-index]').forEach(i=>{var a,c;const r=Number(i.getAttribute("data-row-index")),l=Number(i.getAttribute("data-col-index"));if(!t.has(l)){const h=(a=this.tableModel.getColumnDef(l))==null?void 0:a.property;t.set(l,h!==void 0&&!!((c=e.isDerivedProperty)!=null&&c.call(e,h)))}t.get(l)&&this.rerenderCellContent({area:"body",rowIndex:r,columnIndex:l,value:e.getValueAt(r,l)??""})})}rerenderGroupRowCells(){const e=this.tableModel.getBodyModel();if(!ne(e))return;this.hostElement.querySelectorAll('div.ge-table-col-div[data-area="body"][data-row-index][data-col-index]').forEach(s=>{const o=Number(s.getAttribute("data-row-index")),i=Number(s.getAttribute("data-col-index"));!e.isGroupRowIndex(o)||!e.getCellRenderer(o,i)||this.rerenderCellContent({area:"body",rowIndex:o,columnIndex:i,value:e.getValueAt(o,i)})})}rerenderDerivedFooterCells(e){const t=this.tableModel.getAreaModel("footer");if(!(t!=null&&t.invalidateDerivedValues)||e.every(o=>o.area==="footer"))return;this.hostElement.querySelectorAll('div.ge-table-col-div[data-area="footer"][data-row-index][data-col-index]').forEach(o=>{const i=Number(o.getAttribute("data-row-index")),r=Number(o.getAttribute("data-col-index"));this.rerenderCellContent({area:"footer",rowIndex:i,columnIndex:r,value:t.getValueAt(i,r)})})}rerenderCellContent({area:e,rowIndex:t,columnIndex:s,value:o,cssClasses:i}){const r=this.tableModel.getAreaModel(e),l='div[data-col-index="'+s+'"][data-row-index="'+t+'"][data-area="'+e+'"]',a=this.hostElement.querySelector(l);if(a){let c;const h=e==="body"&&this.editorRenderer&&this.editorRendererRow===t&&this.editorRendererColumn===s;let d;if(h?d=this.editorRenderer:d=r.getCellRenderer(t,s),a.innerText="",this.applyCssClasses(a,i),d)c=d.render(a,t,s,e,r,o,this.dom.domService),c&&this.cleanupFunctions[e].push(c);else{const g=`${o}`;this.dom.addLabelDiv(a,g,!1,t,s,e)}const u=r.getCustomClassesAt(t,s);u.length&&this.dom.addClasses(u,a);const f=r.getCustomStyleAt(t,s);if(f)for(const g in f)this.dom.domService.setStyle(a,g,f[g])}}getFirstVisibleRowIndex(){return this.firstVisibleRowIndex}getLastVisibleRowIndex(){return this.lastVisibleRowIndex}getFirstFullVisibleRowIndex(){return this.firstFullVisibleRowIndex}getLastFullVisibleRowIndex(){return this.lastFullVisibleRowIndex}getDisplayedRowCount(){return this.displayedRowCount}storeColumnWidths(){const e=this.tableModel.getColumnDefs();e!=null&&e.length&&(this.storedColumnWidths=e.map((t,s)=>this.tableModel.getColumnWidth(s)))}getAreaAndSideIdentByAttr(e){if(e){const t=this.getStringByAttr(e,"data-area"),s=this.getStringByAttr(e,"data-side");if(s&&t)return[t,s]}return[void 0,void 0]}getArea(e,t){if(e==="header"){if(t==="west")return this.areaHeaderWest;if(t==="center")return this.areaHeaderCenter;if(t==="east")return this.areaHeaderEast}else if(e==="body"){if(t==="west")return this.areaBodyWest;if(t==="center")return this.areaBodyCenter;if(t==="east")return this.areaBodyEast}else if(e==="footer"){if(t==="west")return this.areaFooterWest;if(t==="center")return this.areaFooterCenter;if(t==="east")return this.areaFooterEast}throw Error(`Wrong area identifier: row:${e}, col:${t}`)}snapToDevicePixel(e){const t=typeof window<"u"&&window.devicePixelRatio||1;return Math.round(e*t)/t}isScrollHeightCapped(){return this.getBodyContentHeight()+1>is.maxScrollHeightInPx}adjustDetailLayerBounds(e,t,s,o){var i;(i=this.masterDetailService)==null||i.setBounds(e,t,s,o)}getBodyContentHeight(){var t;const e=this.tableModel.getContentHeightInPixel();return(t=this.masterDetailService)!=null&&t.hasExpanded()?e+this.getBodyRowLayout().getExtraTotal():e}getContentScrollRangeY(){return this.getBodyContentHeight()-this.areaBodyCenterGeo.height}getScrollerRangeY(){return this.scrollViewport.scrollHeight-this.scrollViewport.clientHeight}onWheel(e){if(e.ctrlKey||!this.isScrollHeightCapped())return;const t=this.getContentScrollRangeY(),s=this.getScrollerRangeY();if(t<=0||s<=0)return;const o=s/t,i=e.deltaMode===1?16:e.deltaMode===2?this.scrollViewport.clientHeight:1;e.preventDefault(),e.deltaY&&(this.scrollViewport.scrollTop+=e.deltaY*i*o),e.deltaX&&(this.scrollViewport.scrollLeft+=e.deltaX*i)}adjustBody(){const e=this.areaBodyCenterGeo.height-this.getBodyContentHeight(),t=this.snapToDevicePixel(this.scrollFactorY*e);this.contentScrollTop=-t,this.adjustArea("body",t)}getNumberByAttr(e,t){var s;if(e){const o=(s=e.closest("["+t+"]"))==null?void 0:s.getAttribute(t);if(o)return Number(o)}return-1}getStringByAttr(e,t){var s;if(e){const o=(s=e.closest("["+t+"]"))==null?void 0:s.getAttribute(t);if(o)return o}return""}adjustArea(e,t=0){var S,A,x,R,L;const s=this.getArea(e,"west"),o=this.getArea(e,"center"),i=this.getArea(e,"east"),r=((S=this.areaHeightsOfRenderPass)==null?void 0:S[e])??o.child.clientHeight;s.child.innerText="",o.child.innerText="",i.child.innerText="";const l=0,a=this.areaBodyCenterGeo.width,c=this.tableModel.getPadding(),h=this.tableModel.getAreaModel(e),d=h.getRowCount();for(;this.cleanupFunctions[e].length;){const v=this.cleanupFunctions[e].shift();v&&v()}if(e==="header"&&!this.tableModel.isHeaderVisibe()||e==="footer"&&!this.tableModel.isFooterVisibe()){this.updateRowGroupRoles(s,o,i);return}let u=t;const f=this.tableModel.getColumnCount(),g=this.tableModel.getFixedRightColumnCount(),p=this.tableModel.getFixedLeftColumnCount();e==="body"&&(this.firstVisibleRowIndex=-1,this.firstFullVisibleRowIndex=-1,this.lastVisibleRowIndex=-1,this.lastFullVisibleRowIndex=-1);let m=0;const b=e==="body"?this.getBodyRowLayout():void 0,y=!!b&&b.getExtraCount()>0,C=[];if(b)(A=this.masterDetailService)==null||A.startRenderPass(),u<0&&d>0&&(m=b.findIndexAt(-u),u=u+b.getTop(m));else{const v=(x=h.getConstantRowHeight)==null?void 0:x.call(h);if(v!==void 0&&v>0&&u<0){for(m=Math.min(d,Math.floor(-u/v));m>0&&u+m*v>0;)m--;u=u+m*v}}for(let v=m;v<d;v++){const D=u,k=v===d-1,P=this.tableModel.getRowHeight(e,v),V=y?b.getExtraHeight(v):0;if(V>0&&D+P+V>0&&C.push(v,D+P,V),D+P>0){e==="body"&&this.firstVisibleRowIndex===-1&&(this.firstVisibleRowIndex=v,this.firstFullVisibleRowIndex=D<-this.pixelLimitForFullVisible?this.firstVisibleRowIndex+1:this.firstVisibleRowIndex);let $={left:l,width:a,height:P,top:D,index:v},j=this.dom.addRowDiv(o,$,v,e,"center");this.applyRowAria(j,e,h,v);const _e=[j],H=p;this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"center",areaModel:h,geo:$,parent:j,rowIndex:v,columnIndexStart:H,columnIndexEnd:f-g-1,verticalFixed:!1,lastRowOfModel:k}),c.left>0&&($={left:l,width:this.areaBodyWestGeo.width,height:P,top:D,index:v},j=this.dom.addRowDiv(s,$,v,e,"west"),this.applyRowAria(j,e,h,v),_e.push(j),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"west",areaModel:h,geo:$,parent:j,rowIndex:v,columnIndexStart:0,columnIndexEnd:H-1,verticalFixed:!0,lastRowOfModel:k})),c.right>0&&($={left:l,width:this.areaBodyEastGeo.width,height:P,top:D,index:v},j=this.dom.addRowDiv(i,$,v,e,"east"),this.applyRowAria(j,e,h,v),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"east",areaModel:h,geo:$,parent:j,rowIndex:v,columnIndexStart:f-g,columnIndexEnd:f-1,verticalFixed:!0,lastRowOfModel:k}));const N=e==="header"&&this.tree&&v===d-1?this.findCellDiv(_e,this.getTreeArrowColumnIndex()):void 0;if(N!=null&&N.parentElement){const ue=this.dom.getInlineStart(N)+16,te=this.dom.applyStyle(this.dom.setAttribute(this.dom.addDiv(N.parentElement,new Ee(ue,20,20,8)),"data-ge-action","toggleExpandCollapseAll"),{cursor:"pointer"}),F=this.tableOptions.treeOptions.arrowExpandCollapseAll;if(F){const Y=this.dom.domService.createText(F.content);this.dom.domService.appendChild(te,Y),F.style&&this.dom.applyStyleString(te,F.style)}}}if(u=u+P+V,u>r){if(e==="body"){const $=u-V;$<=0&&this.firstVisibleRowIndex===-1?this.displayedRowCount=0:(this.lastVisibleRowIndex=v,this.lastFullVisibleRowIndex=r-$<-this.pixelLimitForFullVisible?v-1:v,this.displayedRowCount=this.lastFullVisibleRowIndex-this.firstFullVisibleRowIndex+1)}break}}if(b&&((R=this.masterDetailService)==null||R.layoutVisible(C)),e==="body"&&this.firstVisibleRowIndex>-1&&this.lastVisibleRowIndex===-1&&(this.lastVisibleRowIndex=d-1,this.lastFullVisibleRowIndex=d-1,this.displayedRowCount=this.lastFullVisibleRowIndex-this.firstFullVisibleRowIndex+1),this.loggingActive&&e==="body"&&console.log("render scope: this.firstVisibleRowIndex <- "+this.firstVisibleRowIndex+`
package/index.js CHANGED
@@ -1243,7 +1243,7 @@ class Pn {
1243
1243
  */
1244
1244
  adjustForRowChanges(e) {
1245
1245
  const t = this.startMouseEvent;
1246
- this.mouseDown && t && t.areaIdent === "body" && t.rowIndex >= 0 && (t.rowIndex = Math.max(0, e.mapIndexOrNext(t.rowIndex)));
1246
+ (this.mouseDown || this.pendingDraggingEnd) && t && t.areaIdent === "body" && t.rowIndex >= 0 && (t.rowIndex = Math.max(0, e.mapIndexOrNext(t.rowIndex)));
1247
1247
  }
1248
1248
  onMouseMove(e) {
1249
1249
  var t, s, o, i;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guiexpert/table",
3
- "version": "1.1.108",
3
+ "version": "1.1.109",
4
4
  "license": "MIT",
5
5
  "author": "Dr. Marc Kronberg <info@gui.expert> (https://gui.expert)",
6
6
  "repository": {