@visactor/vtable 0.9.2-alpha.1 → 0.9.2-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/core/BaseTable.js +5 -2
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +5 -4
- package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
- package/dist/vtable.js +16 -6
- package/dist/vtable.min.js +1 -1
- package/es/core/BaseTable.js +5 -2
- package/es/core/BaseTable.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +5 -4
- package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
- package/package.json +1 -1
package/dist/vtable.min.js
CHANGED
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */function oS(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s}const sS=oh();class aS extends Ah{type="chart";chartInstance;activeChartInstance;active;cacheCanvas;constructor(t){super(t),this.numberType=sS,t.chartInstance?this.chartInstance=t.chartInstance:(t.canvas.getContext("2d"),t.chartInstance=this.chartInstance=new t.ClassType(t.spec,{renderCanvas:t.canvas,mode:"desktop-browser",canvasControled:!1,viewBox:t.viewBox,interactive:!1,animation:!1}),this.chartInstance.renderSync())}activate(t){this.active=!0;const{x1:e,y1:i,x2:n,y2:r}=this.attribute.viewBox,o=t.scenegraph.tableGroup.globalAABBBounds,s=new pe;s.x1=o.x1+t.getFrozenColsWidth(),s.x2=o.x2-t.getRightFrozenColsWidth(),s.y1=o.y1+t.getFrozenRowsHeight(),s.y2=o.y2-t.getBottomFrozenRowsHeight();const a=s.intersect({x1:e-t.scrollLeft,x2:n-t.scrollLeft,y1:i-t.scrollTop,y2:r-t.scrollTop});this.activeChartInstance=new this.attribute.ClassType(this.attribute.spec,{renderCanvas:this.attribute.canvas,mode:"desktop-browser",canvasControled:!1,viewBox:{x1:e-t.scrollLeft,x2:n-t.scrollLeft,y1:i-t.scrollTop,y2:r-t.scrollTop},animation:!1,interactive:!0,beforeRender:t=>{const e=t.window.getContext();e.inuse=!0,e.clearMatrix(),e.setTransformForCurrent(!0),e.beginPath(),e.rect(a.x1,a.y1,a.x2-a.x1,a.y2-a.y1),e.clip()},afterRender(t){t.window.getContext().inuse=!1}}),this.activeChartInstance.renderSync(),t.internalProps.layoutMap?.updateDataStateToActiveChartInstance?.(this.activeChartInstance),this.activeChartInstance.on("click",(e=>{console.log("click captured",e),aS.temp&&t.scenegraph.updateChartState(e?.datum)})),this.activeChartInstance.on("brushEnd",(e=>{console.log("brushEnd captured",e),t.scenegraph.updateChartState(e?.value?.inBrushData),aS.temp=0,setTimeout((()=>{aS.temp=1}),0)})),t._bindChartEvent?.(this.activeChartInstance),console.log("active")}static temp=1;deactivate(){this.active=!1,this.activeChartInstance.release(),this.activeChartInstance=null,console.log("deactivate")}updateData(t){this.attribute.data=t}}const lS=Symbol.for("ChartRender");let hS=class{type;numberType=sS;drawShape(t,e,i,n,r,o,s,a){const l=Za(t,o?.theme).group,{dataId:h,data:c,viewBox:d}=t.attribute,{width:u=l.width,height:p=l.height}=t.attribute,{chartInstance:f,active:g,cacheCanvas:y,activeChartInstance:m}=t;if(!g&&y)e.drawImage(y,i,n,u,p);else if(m)m.updateDataSync("data",c??[]);else{const{axes:e}=t.attribute;e.forEach(((t,e)=>{if("linear"===t.type){f._chart._components[e]._domain={min:t.range?.min??0,max:t.range?.max??0}}else if("band"===t.type){const i=f._chart._components[e];i._spec.domain=t.domain.slice(0),i.updateScaleDomain()}})),f.updateViewBox({x1:d.x1-t.getRootNode().table.scrollLeft,x2:d.x2-t.getRootNode().table.scrollLeft,y1:d.y1-t.getRootNode().table.scrollTop,y2:d.y2-t.getRootNode().table.scrollTop}),f.updateDataSync(h,c??[]);const i=f.getStage();t.cacheCanvas=i.toCanvas()}}draw(t,e,i,n){const{context:r}=i;if(!r)return;const{clip:o}=t.attribute;o?r.save():r.highPerformanceSave(),r.transformFromMatrix(t.transMatrix,!0),r.beginPath(),n.skipDraw?this.drawShape(t,r,0,0,i,n,(()=>!1),(()=>!1)):this.drawShape(t,r,0,0,i);const s=Za(t,n?.theme).group,{scrollX:a=s.scrollX,scrollY:l=s.scrollY}=t.attribute;let h;(a||l)&&r.translate(a,l),n&&n.drawingCb&&(h=n.drawingCb()),h&&h.then?h.then((()=>{o?r.restore():r.highPerformanceRestore()})):o?r.restore():r.highPerformanceRestore()}};hS=oS([sr()],hS);let cS=class{time=Vo.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,d){const{shape:u}=t.attribute;if("circle"===u){const{width:r=l.width,height:o=l.height}=t.attribute;e.beginPath(),e.arc(i+r/2,n+o/2,Math.min(r,o)/2,0,2*Math.PI),e.closePath(),e.save(),e.clip()}}};cS=oS([sr()],cS);let dS=class{time=Vo.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,d){const{shape:u}=t.attribute;"circle"===u&&e.restore()}};function uS(t,e,n){const{highlightScope:r,disableHeader:o,cellPos:s}=t.hover;if(!t.table.isHeader(e,n)||!o){if(r===i.single&&s.col===e&&s.row===n)return"cellBgColor";if(r===i.column&&s.col===e)return"inlineColumnBgColor";if(r===i.row&&s.row===n)return"inlineRowBgColor";if(r===i.cross){if(s.col===e&&s.row===n)return"cellBgColor";if(s.col===e)return"inlineColumnBgColor";if(s.row===n)return"inlineRowBgColor"}}}dS=oS([sr()],dS);let pS=class{time=Vo.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,d){const{stroke:u=l.stroke,strokeArrayWidth:p=l.strokeArrayWidth,strokeArrayColor:f=l.strokeArrayColor}=t.attribute;u&&(Array.isArray(p)||Array.isArray(f))&&(d.doStroke=!1)}};pS=oS([sr()],pS);let fS=class{time=Vo.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c){const{width:d=l.width,height:u=l.height,stroke:p=l.stroke,strokeArrayColor:f=l.strokeArrayColor,strokeArrayWidth:g=l.strokeArrayWidth,lineWidth:y=l.lineWidth,strokeColor:m=l.stroke}=t.attribute;p&&(Array.isArray(g)||0!==y)&&(Array.isArray(f)||Array.isArray(g))&&(("number"==typeof y&&1&y||Array.isArray(g)&&g.some((t=>1&t)))&&(i=Math.floor(i)+.5,n=Math.floor(n)+.5),gS(t,e,i,n,l,p,g||y,f||m,Math.ceil(d),Math.ceil(u)))}};function gS(t,e,i,n,r,o,s,a,l,h,c,d){const u=function(t){if(!Array.isArray(t))return{isSplitDraw:!1,width:t};let e;for(let i=0;i<t.length;i++){const n=t[i];if(n)if(e){if(n!==e)return{isSplitDraw:!0}}else e=n}return{isSplitDraw:!1,width:e}}(s),p=!Array.isArray(s),f=!Array.isArray(o),g=Array.isArray(d),y=Array.isArray(a)||u.isSplitDraw;e.setStrokeStyle(t,t.attribute,i,n,r);let m=!1;e.getLineDash().length&&(m=!0),e.beginPath(),e.moveTo(i,n),(f||o[0])&&(p||s[0])?(g&&Array.isArray(d[0])?(e.moveTo(i+l*d[0][0],n),e.lineTo(i+l*(d[0][1]-d[0][0]),n),e.moveTo(i+l,n)):(e.moveTo(i,n),e.lineTo(i+l,n)),!y&&!m||a&&!a[0]||(a&&(e.strokeStyle=a[0]),p||(e.lineWidth=s[0]),e.lineDashOffset=e.currentMatrix.e/e.currentMatrix.a,e.stroke(),e.beginPath(),e.moveTo(i+l,n))):e.moveTo(i+l,n),(f||o[1])&&(p||s[1])?(g&&Array.isArray(d[1])?(e.moveTo(i+l,n+h*d[1][0]),e.lineTo(i+l,n+h*(d[1][1]-d[1][0])),e.moveTo(i+l,n+h)):(e.moveTo(i+l,n),e.lineTo(i+l,n+h)),!y&&!m||a&&!a[1]||(a&&(e.strokeStyle=a[1]),p||(e.lineWidth=s[1]),e.lineDashOffset=e.currentMatrix.f/e.currentMatrix.d,e.stroke(),e.beginPath(),e.moveTo(i+l,n+h))):e.moveTo(i+l,n+h),(f||o[2])&&(p||s[2])?(g&&Array.isArray(d[2])?(e.moveTo(i+l*d[2][0],n+h),e.lineTo(i+l*(d[2][1]-d[2][0]),n+h),e.moveTo(i,n+h)):(e.moveTo(i,n+h),e.lineTo(i+l,n+h)),!y&&!m||a&&!a[2]||(a&&(e.strokeStyle=a[2]),p||(e.lineWidth=s[2]),e.lineDashOffset=e.currentMatrix.e/e.currentMatrix.a,e.stroke(),e.beginPath(),e.moveTo(i,n+h))):e.moveTo(i,n+h),(f||o[3])&&(p||s[3])?(g&&Array.isArray(d[3])?(e.moveTo(i,n+h*d[3][0]),e.lineTo(i,n+h*(d[3][1]-d[3][0])),e.moveTo(i,n)):(e.moveTo(i,n),e.lineTo(i,n+h)),!y&&!m||a&&!a[3]||(a&&(e.strokeStyle=a[3]),p||(e.lineWidth=s[3]),e.lineDashOffset=e.currentMatrix.f/e.currentMatrix.d,e.stroke(),e.beginPath(),e.moveTo(i,n))):e.moveTo(i,n),y||m||(!p&&u.width&&(e.lineWidth=u.width),e.stroke())}fS=oS([sr()],fS);let yS=class{time=Vo.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,d){const{lineDash:u=l.lineDash,stroke:p=l.stroke,strokeArrayColor:f=l.strokeArrayColor,strokeArrayWidth:g=l.strokeArrayWidth}=t.attribute;p&&Array.isArray(u)&&u.length&&!Array.isArray(f)&&!Array.isArray(g)&&(d.doStroke=!1)}};yS=oS([sr()],yS);let mS=class{time=Vo.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c){const{lineDash:d=l.lineDash,stroke:u=l.stroke,strokeArrayColor:p=l.strokeArrayColor,strokeArrayWidth:f=l.strokeArrayWidth,lineWidth:g=l.lineWidth}=t.attribute;if(!u||!Array.isArray(d)||!d.length||Array.isArray(p)||Array.isArray(f))return;let{width:y=l.width,height:m=l.height}=t.attribute;y=Math.ceil(y),m=Math.ceil(m),1&g&&(i=Math.floor(i)+.5,n=Math.floor(n)+.5),e.setStrokeStyle(t,t.attribute,i,n,l),e.beginPath(),e.moveTo(i,n),e.lineTo(i+y,n),e.lineDashOffset=e.currentMatrix.e/e.currentMatrix.a,e.stroke(),e.beginPath(),e.moveTo(i+y,n),e.lineTo(i+y,n+m),e.lineDashOffset=e.currentMatrix.f/e.currentMatrix.d,e.stroke(),e.beginPath(),e.moveTo(i,n+m),e.lineTo(i+y,n+m),e.lineDashOffset=e.currentMatrix.e/e.currentMatrix.a,e.stroke(),e.beginPath(),e.moveTo(i,n),e.lineTo(i,n+m),e.lineDashOffset=e.currentMatrix.f/e.currentMatrix.d,e.stroke()}};mS=oS([sr()],mS);let bS=class{time=Vo.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,d){const{lineWidth:u=l.lineWidth,stroke:p=l.stroke,lineDash:f=l.lineDash,strokeArrayWidth:g=l.strokeArrayWidth,strokeArrayColor:y=l.strokeArrayColor}=t.attribute;p&&Array.isArray(f)&&!f.length&&!Array.isArray(y)&&!Array.isArray(g)&&1&u&&(d.doStroke=!1)}};bS=oS([sr()],bS);let vS=class{time=Vo.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c){const{lineWidth:d=l.lineWidth,stroke:u=l.stroke,lineDash:p=l.lineDash,strokeArrayWidth:f=l.strokeArrayWidth,strokeArrayColor:g=l.strokeArrayColor}=t.attribute;let{width:y=l.width,height:m=l.height}=t.attribute;if(y=Math.ceil(y),m=Math.ceil(m),u&&Array.isArray(p)&&!p.length&&!Array.isArray(g)&&!Array.isArray(f)&&1&d){if("cell"===t.role){const e=t.stage.table;let i=t.col,n=t.row;const r=_w(e,i,n);r&&(i=r.end.col,n=r.end.row),(e&&i===e.colCount-1||e&&i===e.frozenColCount-1&&e.scrollLeft)&&(y-=1),(e&&n===e.rowCount-1||e&&n===e.frozenRowCount-1&&e.scrollTop)&&(m-=1)}e.beginPath(),i=Math.floor(i)+.5,n=Math.floor(n)+.5,e.rect(i,n,y,m),e.setStrokeStyle(t,t.attribute,i,n,l),e.stroke()}}};vS=oS([sr()],vS);let wS=class{time=Vo.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,d){if("cell"===t.role){const e=function(t,e){let i;if("cell"===t.role&&"number"==typeof t.mergeCol&&"number"==typeof t.mergeRow)for(let n=t.col;n<=t.mergeCol;n++)for(let r=t.row;r<=t.mergeRow;r++){const t=uS(e.stateManeger,n,r);!t||i&&"cellBgColor"!==t||(i=t)}else"cell"===t.role&&(i=uS(e.stateManeger,t.col,t.row));if(!i)return;return OC(i,e.isHeader(t.col,t.row)?e.theme.headerStyle?.hover:e.theme.bodyStyle?.hover,t.col,t.row,e)}(t,t.stage.table);e&&(t.oldColor=t.attribute.fill,t.attribute.fill=e)}}};wS=oS([sr()],wS);let CS=class{time=Vo.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c){"oldColor"in t&&(t.attribute.fill=t.oldColor,delete t.oldColor)}};CS=oS([sr()],CS);let xS=class{time=Vo.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,d){const{stroke:u=l.stroke,strokeArrayWidth:p=l.strokeArrayWidth,strokeArrayColor:f=l.strokeArrayColor}=t.attribute;u&&(Array.isArray(u)||Array.isArray(p)||Array.isArray(f))&&(d.doStroke=!1)}};xS=oS([sr()],xS);let _S=class{time=Vo.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c){const{width:d=l.width,height:u=l.height,stroke:p=l.stroke,strokeArrayColor:f=l.strokeArrayColor,strokeArrayWidth:g=l.strokeArrayWidth,lineWidth:y=l.lineWidth,strokeColor:m=l.stroke}=t.attribute;p&&(Array.isArray(g)||0!==y)&&(Array.isArray(p)||Array.isArray(f)||Array.isArray(g))&&(("number"==typeof y&&1&y||Array.isArray(g)&&g.some((t=>1&t)))&&(i=Math.floor(i)+.5,n=Math.floor(n)+.5),gS(t,e,i,n,l,p,g||y,f||m,Math.ceil(d),Math.ceil(u)))}};_S=oS([sr()],_S);var SS=new er(((t,e,i,n)=>{i(vp)?n(vp).to(xS).inSingletonScope():(t(xS).toSelf().inSingletonScope(),t(gp).toService(xS)),i(wp)?n(wp).to(_S).inSingletonScope():(t(_S).toSelf().inSingletonScope(),t(gp).toService(_S)),t(fS).toSelf().inSingletonScope(),t(Af).toService(fS),t(pS).toSelf().inSingletonScope(),t(Af).toService(pS),t(hS).toSelf().inSingletonScope(),t(lS).to(hS),t(hf).to(hS),t(cS).toSelf().inSingletonScope(),t(qp).toService(cS),t(dS).toSelf().inSingletonScope(),t(qp).toService(dS),t(yS).toSelf().inSingletonScope(),t(Af).toService(yS),t(mS).toSelf().inSingletonScope(),t(Af).toService(mS),t(bS).toSelf().inSingletonScope(),t(Af).toService(bS),t(vS).toSelf().inSingletonScope(),t(Af).toService(vS),t(wS).toSelf().inSingletonScope(),t(Af).toService(wS),t(CS).toSelf().inSingletonScope(),t(Af).toService(CS)}));function AS(t,e,i,n){e=e??0,i=i??t.colCount-1,0===e&&i===t.colCount-1&&t._clearColRangeWidthsMap();const r=[];if(n)for(let e=0;e<t.colCount;e++)r.push(t.getColWidth(e));for(let n=e;n<=i;n++){let e;if(!t.internalProps.transpose&&"only-header"===t.internalProps.layoutMap.columnWidths?.[n]?.columnWidthComputeMode&&"showHeader"in t.internalProps.layoutMap){const i=t.internalProps.layoutMap.showHeader;t.internalProps.layoutMap.showHeader=!0,e=TS(n,0,t.internalProps.layoutMap.headerLevelCount,t,!1),t.internalProps.layoutMap.showHeader=i}else e=t.internalProps.transpose||"only-body"!==t.internalProps.layoutMap.columnWidths?.[n]?.columnWidthComputeMode?TS(n,0,t.rowCount-1,t,!1):TS(n,t.internalProps.layoutMap.getBodyRange().start.row,t.internalProps.layoutMap.getBodyRange().end.row,t,!1);t._setColContentWidth(n,e);t.getColWidth(n)!==e&&t._clearColRangeWidthsMap(n),t.setColWidth(n,e,!1,!0)}if("adaptive"===t.widthMode){t._clearColRangeWidthsMap();const e=t.tableNoFrameWidth;let i=0;for(let e=0;e<t.colCount;e++)i+=t.getColWidth(e);const n=e/i;for(let i=0;i<t.colCount;i++){let r;r=i===t.colCount-1?e-t.getColsWidth(0,t.colCount-2):Math.round(t.getColWidth(i)*n),t.setColWidth(i,r,!1,!0)}}else if(t.autoFillWidth){t._clearColRangeWidthsMap();const e=t.tableNoFrameWidth;let i=0,n=0;for(let e=0;e<t.colCount;e++){const r=t.getColWidth(e);e<t.frozenColCount&&(n+=r),i+=r}if(i<e&&i-n>0){const r=(e-n)/(i-n);for(let e=t.frozenColCount;e<t.colCount;e++)t.setColWidth(e,t.getColWidth(e)*r,!1,!0)}}if(n)for(let e=0;e<t.colCount;e++){const i=t.getColWidth(e);i!==r[e]&&t.scenegraph.updateColWidth(e,i-r[e])}}function TS(t,e,i,n,o){const{layoutMap:s,transpose:a}=n.internalProps,{width:l}=s?.getColumnWidthDefined(t)??{};if(a){if("standard"===n.widthMode){if(n.isRowHeader(t,0)||n.isCornerHeader(t,0))return Array.isArray(n.defaultHeaderColWidth)?n.defaultHeaderColWidth[t]??n.defaultColWidth:n.defaultHeaderColWidth;if("auto"!==l)return"string"==typeof l?CC(l,n.internalProps.calcWidthContext):l||n.defaultColWidth}else if("adaptive"===n.widthMode&&0===t&&"auto"!==l&&s?.showHeader){if("string"==typeof l)return CC(l,n.internalProps.calcWidthContext);if(l)return l}}else if("auto"!==l&&"autoWidth"!==n.widthMode&&!o)return"string"==typeof l?CC(l,n.internalProps.calcWidthContext):l||n.getColWidth(t);return function(t,e,i,n,o,s){let a=0,l=1;n-i>5e3&&(l=Math.ceil((n-i)/5e3));if(s.isPivotChart()&&e>=s.rowHeaderLevelCount){if(s.internalProps.layoutMap.indicatorsAsCol)return s.defaultColWidth;{const t=s.internalProps.layoutMap.getOptimunWidthForChart(e);if(t>0)return t}}for(let o=i;o<=n;o+=l){const i=BS(e,o,s);if("number"==typeof i){a=Math.max(i,a);continue}const n=t;if("number"==typeof n&&"standard"===s.widthMode){a=Math.max(n,a);continue}const l=s.isHeader(e,o)?s._getHeaderLayoutMap(e,o)?.headerType:s.getBodyColumnType(e,o);if("text"!==l&&"link"!==l&&"progressbar"!==l){a=Math.max(a,s.getColWidth(e)||0);continue}let h=0;const c=s.internalProps.layoutMap;if(c.isHeader(e,o)){const t=c.getHeader(e,o);if("only-body"===t?.define?.columnWidthComputeMode)continue;t?.hierarchyLevel&&(h=(t.hierarchyLevel??0)*(c.rowHierarchyIndent??0))}else{const t=s.getBodyColumnDefine(e,o);if(t?.tree){const t=s.dataSource.getIndexKey(s.getRecordIndexByRow(e,o));h=Array.isArray(t)&&s.getHierarchyState(e,o)!==r.none?(t.length-1)*(c.hierarchyIndent??0):0}}const d=MS(e,o,s);a=Math.max(d+h,a)}const h=s.getMinColWidth(e),c=s.getMaxColWidth(e);if(a<h)return h;if(a>c)return c;return a}(l,t,e,i,0,n)}function BS(t,e,i){const n=i.getCustomRender(t,e),r=i.getCustomLayout(t,e);if(n||r){let o=1,s=0;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);o=n.end.col-n.start.col+1}const a={col:t,row:e,dataValue:i.getCellOriginValue(t,e),value:i.getCellValue(t,e)||"",rect:RS(t,e,i),table:i};if(r){const t=r(a);t.rootContainer.isRoot=!0;s=t.rootContainer.getContentSize().width??0}else if("function"==typeof n){const t=n(a);s=t?.expectedWidth??0}else s=n?.expectedWidth??0;return s/o}}function MS(t,e,i){let n=0;const r=i.getCellValue(t,e),o=i._getCellStyle(t,e);let s=0;const l=i.getBodyColumnDefine(t,e);if("body"!==i.getCellType(t,e)||(!!l?.icon||!!l?.tree)){const n=i.getCellIcons(t,e);n?.forEach((t=>{t.positionType!==a.absoluteRight&&(s+=(t.width??0)+(t.marginLeft??0)+(t.marginRight??0))}))}let h=1;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);h=n.end.col-n.start.col+1}const c=Gw(OC("padding",o,t,e,i)),d=c[1]+c[3],u=OC("fontSize",o,t,e,i),p=OC("fontFamily",o,t,e,i),f=T(r).split("\n")||[];return f.length>=1?f.forEach((t=>{const e=i.measureText(t.slice(0,i.options.maxCharactersNumber||200),{fontSize:u,fontFamily:p}).width;n=Math.max((e+d+4+s)/h,n)})):n=Math.max((d+4+s)/h,n),!1!==i.internalProps.limitMaxAutoWidth&&(n=Math.min("number"==typeof i.internalProps.limitMaxAutoWidth?i.internalProps.limitMaxAutoWidth:450,n)),n}function RS(t,e,i){return{left:0,top:0,right:i.getColWidth(t),bottom:i.getRowHeight(e),width:i.getColWidth(t),height:i.getRowHeight(e)}}const PS=new bx({autoWrapText:!0}),ES=new Cd({width:0,height:0,textConfig:[]});function HS(t,e,i){const n="undefined"!=typeof window?window.performance.now():0;if("autoHeight"===t.heightMode){if(e=e??0,i=i??t.rowCount-1,0===e&&i===t.rowCount-1)t._clearRowRangeHeightsMap();else for(let n=e;n<=i;n++)t._clearRowRangeHeightsMap(n);for(let i=e;i<t.columnHeaderLevelCount;i++){const e=kS(i,0,t.colCount-1,t);t.setRowHeight(i,e)}if(i<t.columnHeaderLevelCount)return;if(t.internalProps.transpose||t.isPivotTable()&&t.internalProps.layoutMap.indicatorsAsCol||!LS(t))if((t.internalProps.transpose||t.isPivotTable()&&!t.internalProps.layoutMap.indicatorsAsCol)&&LS(t))for(let n=Math.max(e,t.columnHeaderLevelCount);n<=i;n++){t._clearRowRangeHeightsMap(n);const e=kS(n,0,t.rowHeaderLevelCount,t);t.setRowHeight(n,e)}else for(let n=Math.max(e,t.columnHeaderLevelCount);n<=i;n++){t._clearRowRangeHeightsMap(n);const e=kS(n,0,t.colCount-1,t);t.setRowHeight(n,e)}else{!function(t,e,i,n){for(let r=e;r<=i;r++)n.setRowHeight(r,t)}(kS(t.columnHeaderLevelCount,0,t.colCount-1,t),t.columnHeaderLevelCount,t.rowCount-1,t)}}else if("adaptive"===t.heightMode){t._clearRowRangeHeightsMap();const e=t.tableNoFrameHeight-t.getFrozenRowsHeight()-t.getBottomFrozenRowsHeight();let i=0;for(let e=t.frozenRowCount;e<t.rowCount-t.bottomFrozenRowCount;e++)i+=t.getRowHeight(e);const n=e/i;for(let i=t.frozenRowCount;i<t.rowCount-t.bottomFrozenRowCount;i++){let r;r=i===t.rowCount-t.bottomFrozenRowCount-1?e-t.getRowsHeight(t.frozenRowCount,t.rowCount-t.bottomFrozenRowCount-2):Math.round(t.getRowHeight(i)*n),t.setRowHeight(i,r,!1)}}console.log("computeRowsHeight time:",("undefined"!=typeof window?window.performance.now():0)-n)}function kS(t,e,i,n){let r=0;for(let o=e;o<=i;o++){const e=IS(o,t,n);if("number"==typeof e){r=Math.max(e,r);continue}const i=OS(o,t,n);r=Math.max(i,r)}return r}function LS(t){const{layoutMap:e}=t.internalProps,i=t.columnHeaderLevelCount;for(let n=0;n<t.colCount;n++){const r=e.isHeader(n,i),o=r?e.getHeader(n,i):e.getBody(n,i);if("function"==typeof o.style||"function"==typeof o.icon||"function"==typeof o.headerIcon||(r?o.define?.headerCustomRender:o.define?.customRender)||(r?"function"==typeof o.define?.headerIcon:"function"==typeof o.define?.icon))return!1;const s=t._getCellStyle(n,i);if("function"==typeof s.padding||"function"==typeof s.fontSize||"function"==typeof s.lineHeight||!0===s.autoWrapText)return!1}return!0}function IS(t,e,i){const n=i.getCustomRender(t,e),r=i.getCustomLayout(t,e);if(n||r){let o=1,s=0;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);o=n.end.col-n.start.col+1}const a={col:t,row:e,dataValue:i.getCellOriginValue(t,e),value:i.getCellValue(t,e)||"",rect:RS(t,e,i),table:i};if(r){const t=r(a);t.rootContainer.isRoot=!0;s=t.rootContainer.getContentSize().height??0}else if("function"==typeof n){const t=n(a);s=t?.expectedHeight??0}else s=n?.expectedHeight??0;return s/o}}function OS(t,e,i){let n=0;const r=i.getCellValue(t,e),o=i._getCellStyle(t,e);let s=0,l=0;const h=[];let c=0;const d=[];let u=0;const p=i.getBodyColumnDefine(t,e);if("body"!==i.getCellType(t,e)||(!!p?.icon||!!p?.tree)){const n=i.getCellIcons(t,e);n?.forEach((t=>{t.positionType!==a.absoluteRight&&t.positionType!==a.inlineFront&&t.positionType!==a.inlineEnd?(l+=(t.width??0)+(t.marginLeft??0)+(t.marginRight??0),s=Math.max(s,t.height??0)):t.positionType===a.inlineFront?(h.push(t),c=Math.max(c,(t.height??0)+(t.marginLeft??0)+(t.marginRight??0))):t.positionType===a.inlineEnd&&(d.push(t),u=Math.max(u,(t.height??0)+(t.marginLeft??0)+(t.marginRight??0)))}))}let f=1;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);f=n.end.row-n.start.row+1}const g=Gw(OC("padding",o,t,e,i)),y=OC("fontSize",o,t,e,i),m=OC("fontStyle",o,t,e,i),b=OC("fontWeight",o,t,e,i),v=OC("lineHeight",o,t,e,i)??y,w=OC("fontFamily",o,t,e,i),C=OC("autoWrapText",o,t,e,i),x=T(r).split("\n")||[];if(h.length||d.length){const e=Object.assign({text:r?.toString(),fontFamily:w,fontSize:y,fontStyle:m,fontWeight:b,lineHeight:v});e.textBaseline="middle";const o=[...h.map((t=>xx(t))),e,...d.map((t=>xx(t)))];ES.setAttributes({width:i.getColWidth(t)-(g[1]+g[3])-l,height:0,textConfig:o}),n=ES.AABBBounds.height()}else if(C){const e=i.getColWidth(t)-(g[1]+g[3])-l;PS.setAttributes({maxLineWidth:e,text:x,fontSize:y,fontStyle:m,fontWeight:b,fontFamily:w}),n=PS.AABBBounds.height()}else n=x.length*v;return(Math.max(n,s)+g[0]+g[2])/f}const DS=new xw({});DS.role="empty";const FS={},WS={};function zS(t,e,i,n,r,o,s,a,l,h,c,d,u,p,f){const g=it(WS,FS)[c],y=DC("padding",p._getCellStyle(r,o),r,o,p);A(y)&&(l=y),t||((t=new xw({x:i,y:n,width:s,height:a,lineWidth:f?.group?.lineWidth??void 0,fill:f?.group?.fill??void 0,stroke:f?.group?.stroke??void 0,strokeArrayWidth:f?.group?.strokeArrayWidth??void 0,strokeArrayColor:f?.group?.strokeArrayColor??void 0,cursor:f?.group?.cursor??void 0,lineCap:"square",clip:!0})).role="cell",t.col=r,t.row=o,e.addChild(t)),t.AABBBounds.width();const m=new aS({stroke:!1,x:l[3],y:l[0],canvas:p.canvas,spec:d,ClassType:g,width:s-l[3]-l[1],height:a-l[2]-l[0],chartInstance:u,dataId:"data",data:p.getCellValue(r,o),cellPadding:l,viewBox:{x1:Math.ceil(t.globalAABBBounds.x1+l[3]+p.scrollLeft),x2:Math.ceil(t.globalAABBBounds.x1+s-l[1]+p.scrollLeft),y1:Math.ceil(t.globalAABBBounds.y1+l[0]+p.scrollTop),y2:Math.ceil(t.globalAABBBounds.y1+a-l[2]+p.scrollTop)},axes:p.internalProps.layoutMap.getChartAxes(r,o)});return t.appendChild(m),p.internalProps.layoutMap.setChartInstance(r,o,m.chartInstance),t}function jS(t,e,i,n,r,o,s,l,h,c,d,u,p,f,g,y){const m=t._getCellStyle(r,o),b=DC("padding",m,r,o,t);A(b)&&(c=b),y?.text?.textAlign&&(d=y?.text?.textAlign),y?.text?.textBaseline&&(u=y?.text?.textBaseline);const v="auto"===s,C=m.autoWrapText??t.internalProps.autoWrapText,x=m.lineClamp,_=new xw({x:i,y:n,width:l,height:h,lineWidth:y?.group?.lineWidth??void 0,fill:y?.group?.fill??void 0,stroke:y?.group?.stroke??void 0,strokeArrayWidth:y?.group?.strokeArrayWidth??void 0,strokeArrayColor:y?.group?.strokeArrayColor??void 0,cursor:y?.group?.cursor??void 0,lineCap:"square",clip:!0});if(_.role="cell",_.col=r,_.row=o,e.addChild(_),f&&_.appendChild(f),g){const e=t.getCellValue(r,o);let i;if(p&&(i=t.getCellIcons(r,o)),function(t,e,i,n,r,o,s,l,h,c,d,u,p,f){const g=[],y=[],m=[],b=[],v=[],C=[],x=[],_=[];let S,A,T=0,B=0,M=0,R=0,P=0,E=0;if(Array.isArray(e)&&0!==e.length){let H;if(e.forEach((t=>{switch(t.positionType){case a.left:g.push(t);break;case a.right:y.push(t);break;case a.contentLeft:m.push(t);break;case a.contentRight:b.push(t);break;case a.absoluteRight:_.push(t);break;case a.inlineFront:v.push(t);break;case a.inlineEnd:C.push(t)}})),g.forEach((e=>{const i=Cx(e,void 0,t.col,t.row,p);i.role="icon-left",i.name=e.name,i.setAttribute("x",T+(i.attribute.marginLeft??0)),T+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),B=Math.max(B,i.AABBBounds.height()),t.appendChild(i)})),y.forEach((e=>{const i=Cx(e,void 0,t.col,t.row,p);i.role="icon-right",i.name=e.name,i.setAttribute("x",M+(i.attribute.marginLeft??0)),M+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),R=Math.max(R,i.AABBBounds.height()),t.appendChild(i)})),x.forEach((e=>{const i=Cx(e,void 0,t.col,t.row,p);i.role="icon-absolute-left",i.name=e.name,i.setAttribute("x",P+(i.attribute.marginLeft??0)),P+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),t.appendChild(i)})),_.forEach((e=>{const i=Cx(e,void 0,t.col,t.row,p);i.role="icon-absolute-right",i.name=e.name,i.setAttribute("x",E+(i.attribute.marginLeft??0)),E+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),t.appendChild(i)})),0===v.length&&0===C.length){const t=w(i).replace(/\r?\n/g,"\n").replace(/\r/g,"\n").split("\n"),e={text:1!==t.length||s?t:t[0],maxLineWidth:r?1/0:h-(n[1]+n[3])-T-M,textBaseline:"top",heightLimit:o?-1:c-(n[0]+n[2]),pickable:!1,autoWrapText:s,lineClamp:l},a=new bx(f.text?Object.assign({},f.text,e):e);a.name="text",H=a}else{const e=Object.assign({text:i?.toString()},t.parent?.theme?.userTheme?.text||{});f.text&&Object.assign(e,f.text),e.textBaseline="middle";const s=[...v.map((t=>xx(t))),e,...C.map((t=>xx(t)))];s[0].textAlign=d;const a=new Cd({width:r?0:h-(n[1]+n[3])-T-M,height:o?0:c-(n[0]+n[2]),textConfig:s,verticalDirection:o?"top":u});a.name="text",H=a,a.bindIconEvent()}if(0!==m.length||0!==b.length){const e=new vx({x:0,y:0,fill:!1,stroke:!1});e.name="content",e.setCellContentOption({autoWidth:r,autoHeight:o,cellWidth:h-(n[1]+n[3])-T-M,cellHeight:c-(n[0]+n[2]),align:d,baseline:u}),m.forEach((i=>{const n=Cx(i,void 0,t.col,t.row,p);n.role="icon-content-left",n.name=i.name,e.addLeftOccupyingIcon(n)})),b.forEach((i=>{const n=Cx(i,void 0,t.col,t.row,p);n.role="icon-content-right",n.name=i.name,e.addRightOccupyingIcon(n)})),e.addContent(H),t.appendChild(e),e.layout(),S=e.AABBBounds.width(),A=e.AABBBounds.height()}else t.firstChild?t.insertBefore(H,t.firstChild):t.appendChild(H),S=H.AABBBounds.width(),A=H.AABBBounds.height()}else{const e=w(i).replace(/\r?\n/g,"\n").replace(/\r/g,"\n").split("\n"),a=wx(t.col,t.row,p),d={text:1!==e.length||s?e:e[0],maxLineWidth:r?1/0:h-(n[1]+n[3]+a),textBaseline:"top",autoWrapText:s,lineClamp:l,heightLimit:o?-1:c-(n[0]+n[2]),pickable:!1,dx:a},u=new bx(f.text?Object.assign({},f.text,d):d);u.name="text",t.appendChild(u),S=u.AABBBounds.width(),A=u.AABBBounds.height()}const H=r?T+S+M:h-(n[1]+n[3]),k=o?Math.max(B,A,R):c-(n[0]+n[2]);t.forEachChildren((t=>{"icon-left"===t.role?t.setAttribute("x",t.attribute.x+n[3]):"icon-right"===t.role?t.setAttribute("x",t.attribute.x+H-M+n[3]):"icon-absolute-right"===t.role?t.setAttribute("x",t.attribute.x+H-E+n[3]+n[1]):"content"!==t.name&&"text"!==t.name||("center"===d&&"richtext"!==t.type?t.setAttribute("x",n[3]+T+(H-T-M)/2):"right"===d&&"richtext"!==t.type?t.setAttribute("x",n[3]+H-M):t.setAttribute("x",n[3]+T))})),t.forEachChildren((t=>{"middle"===u?t.setAttribute("y",n[0]+(k-t.AABBBounds.height())/2):"bottom"===u?t.setAttribute("y",n[0]+k-t.AABBBounds.height()):t.setAttribute("y",n[0])})),t.setAttributes({width:H+n[1]+n[3],height:k+n[0]+n[2]})}(_,i,e,c,v,!1,C,"number"==typeof x?x:void 0,l,h,d,u,t,y),y?._vtable?.marked){const t=au({x:_.attribute.width,y:0,startAngle:Math.PI/2,endAngle:Math.PI,outerRadius:6,fill:"#3073F2",pickable:!1});t.name="mark",_.appendChild(t)}}return f&&_.setAttributes({width:Math.max(_.attribute.width,f.attribute.width),height:Math.max(_.attribute.height,f.attribute.height)}),_}const NS=kC();function GS(t,e,i){t.then((()=>{i(),e.scenegraph.updateNextFrame()})).catch((t=>{console.error(t)}))}function KS(t){return Ut(t)||t.angle&&(t.angle=ge(t.angle)),t}function US(t={}){return Ut(t.style)||(t.style=KS(t.style)),Ut(t.state)||Object.keys(t.state).forEach((e=>{Ut(t.state[e])||(t.state[e]=KS(t.state[e]))})),t}function VS(t){return Ut(t)?null:(Object.keys(t).forEach((e=>{Ut(t[e])||(t[e]=KS(t[e]))})),t)}const $S={left:{textAlign:"center",textBaseline:"bottom"},right:{textAlign:"center",textBaseline:"bottom"},radius:{},angle:{}},XS=14,YS=4,qS={domainLine:{visible:!0,style:{lineWidth:1,stroke:"#D9DDE4",strokeOpacity:1}},grid:{visible:!0,style:{lineWidth:1,stroke:"#EBEDF2",strokeOpacity:1,lineDash:[]}},subGrid:{visible:!1,style:{lineWidth:1,stroke:"#EBEDF2",strokeOpacity:1,lineDash:[4,4]}},tick:{visible:!0,tickSize:YS,style:{lineWidth:1,stroke:"#D9DDE4",strokeOpacity:1}},subTick:{visible:!1,tickSize:YS/2,style:{lineWidth:1,stroke:"#D9DDE4",strokeOpacity:1}},label:{visible:!0,space:0,style:{fontSize:XS,fill:"#89909D",fontWeight:"normal",fillOpacity:1}},title:{space:10,style:{fontSize:XS,fill:"#333333",fontWeight:"normal",fillOpacity:1}}};function ZS(t){return"bottom"===t||"top"===t}class JS{_scale;_scales;bandPadding;paddingInner;paddingOuter;constructor(){this._scale=new JC,this._scales=[this._scale]}valueToPosition(t){return this._scale.scale(t)}getPosition(t){let e=0,i=this._scale;if(1===this._scales.length||1===t.length)e=this.valueToPosition(t[0]);else{const n=Math.min(t.length,this._scales.length);for(let i=0;i<n;i++)e+=this._scales[i].scale(t[i]);i=this._scales[n-1]}return{position:e,bandScale:i}}calcScales(t,e){const{bandPadding:i,paddingInner:n,paddingOuter:r}=this,o=Ot(i),s=Ot(n),a=Ot(r);for(let l=0;l<this._scales.length;l++){const h=o?i[l]:i,c=s?n[l]:n,d=a?r[l]:r;this._scales[l].paddingInner(c??h??t,!0).paddingOuter(d??h??e)}}dataToPosition(t,e={}){if(0===t.length||0===this._scales.length)return 0;const{position:i,bandScale:n}=this.getPosition(t);return i+n.bandwidth()*(e.bandPosition??.5)}updateScaleDomain(t){for(let e=0;e<this._scales.length;e++)this._scales[e].domain(t)}updateRange(t){const[e,i]=this._scale.range();t[0]===e&&t[1]===i||this._scale.range(t)}}for(let t=0;t<256;t++)t.toString(16);class QS{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const e=this._partials;let i=0;for(let n=0;n<this._n&&n<32;n++){const r=e[n],o=t+r,s=Math.abs(t)<Math.abs(r)?t-(o-r):r-(o-t);s&&(e[i++]=s),t=o}return e[i]=t,this._n=i+1,this}valueOf(){const t=this._partials;let e,i,n,r=this._n,o=0;if(r>0){for(o=t[--r];r>0&&(e=o,i=t[--r],o=e+i,n=i-(o-e),!n););r>0&&(n<0&&t[r-1]<0||n>0&&t[r-1]>0)&&(i=2*n,e=o+i,i==e-o&&(o=e))}return o}}function tA(t){return Array.from(function*(t){for(const e of t)yield*e}(t))}var eA=1e-6,iA=1e-12,nA=Math.PI,rA=nA/2,oA=nA/4,sA=2*nA,aA=180/nA,lA=nA/180,hA=Math.abs,cA=Math.atan,dA=Math.atan2,uA=Math.cos,pA=Math.exp,fA=Math.log,gA=Math.sin,yA=Math.sign||function(t){return t>0?1:t<0?-1:0},mA=Math.sqrt,bA=Math.tan;function vA(t){return t>1?rA:t<-1?-rA:Math.asin(t)}function wA(){}function CA(t,e){t&&_A.hasOwnProperty(t.type)&&_A[t.type](t,e)}var xA={Feature:function(t,e){CA(t.geometry,e)},FeatureCollection:function(t,e){for(var i=t.features,n=-1,r=i.length;++n<r;)CA(i[n].geometry,e)}},_A={Sphere:function(t,e){e.sphere()},Point:function(t,e){t=t.coordinates,e.point(t[0],t[1],t[2])},MultiPoint:function(t,e){for(var i=t.coordinates,n=-1,r=i.length;++n<r;)t=i[n],e.point(t[0],t[1],t[2])},LineString:function(t,e){SA(t.coordinates,e,0)},MultiLineString:function(t,e){for(var i=t.coordinates,n=-1,r=i.length;++n<r;)SA(i[n],e,0)},Polygon:function(t,e){AA(t.coordinates,e)},MultiPolygon:function(t,e){for(var i=t.coordinates,n=-1,r=i.length;++n<r;)AA(i[n],e)},GeometryCollection:function(t,e){for(var i=t.geometries,n=-1,r=i.length;++n<r;)CA(i[n],e)}};function SA(t,e,i){var n,r=-1,o=t.length-i;for(e.lineStart();++r<o;)n=t[r],e.point(n[0],n[1],n[2]);e.lineEnd()}function AA(t,e){var i=-1,n=t.length;for(e.polygonStart();++i<n;)SA(t[i],e,1);e.polygonEnd()}function TA(t,e){t&&xA.hasOwnProperty(t.type)?xA[t.type](t,e):CA(t,e)}function BA(t){return[dA(t[1],t[0]),vA(t[2])]}function MA(t){var e=t[0],i=t[1],n=uA(i);return[n*uA(e),n*gA(e),gA(i)]}function RA(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function PA(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function EA(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function HA(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function kA(t){var e=mA(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function LA(t,e){function i(i,n){return i=t(i,n),e(i[0],i[1])}return t.invert&&e.invert&&(i.invert=function(i,n){return(i=e.invert(i,n))&&t.invert(i[0],i[1])}),i}function IA(t,e){return hA(t)>nA&&(t-=Math.round(t/sA)*sA),[t,e]}function OA(t,e,i){return(t%=sA)?e||i?LA(FA(t),WA(e,i)):FA(t):e||i?WA(e,i):IA}function DA(t){return function(e,i){return hA(e+=t)>nA&&(e-=Math.round(e/sA)*sA),[e,i]}}function FA(t){var e=DA(t);return e.invert=DA(-t),e}function WA(t,e){var i=uA(t),n=gA(t),r=uA(e),o=gA(e);function s(t,e){var s=uA(e),a=uA(t)*s,l=gA(t)*s,h=gA(e),c=h*i+a*n;return[dA(l*r-c*o,a*i-h*n),vA(c*r+l*o)]}return s.invert=function(t,e){var s=uA(e),a=uA(t)*s,l=gA(t)*s,h=gA(e),c=h*r-l*o;return[dA(l*r+h*o,a*i+c*n),vA(c*i-a*n)]},s}function zA(t,e){(e=MA(e))[0]-=t,kA(e);var i,n=(i=-e[1])>1?0:i<-1?nA:Math.acos(i);return((-e[2]<0?-n:n)+sA-eA)%sA}function jA(){var t,e=[];return{point:function(e,i,n){t.push([e,i,n])},lineStart:function(){e.push(t=[])},lineEnd:wA,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var i=e;return e=[],t=null,i}}}function NA(t,e){return hA(t[0]-e[0])<eA&&hA(t[1]-e[1])<eA}function GA(t,e,i,n){this.x=t,this.z=e,this.o=i,this.e=n,this.v=!1,this.n=this.p=null}function KA(t,e,i,n,r){var o,s,a=[],l=[];if(t.forEach((function(t){if(!((e=t.length-1)<=0)){var e,i,n=t[0],s=t[e];if(NA(n,s)){if(!n[2]&&!s[2]){for(r.lineStart(),o=0;o<e;++o)r.point((n=t[o])[0],n[1]);return void r.lineEnd()}s[0]+=2*eA}a.push(i=new GA(n,t,null,!0)),l.push(i.o=new GA(n,null,i,!1)),a.push(i=new GA(s,t,null,!1)),l.push(i.o=new GA(s,null,i,!0))}})),a.length){for(l.sort(e),UA(a),UA(l),o=0,s=l.length;o<s;++o)l[o].e=i=!i;for(var h,c,d=a[0];;){for(var u=d,p=!0;u.v;)if((u=u.n)===d)return;h=u.z,r.lineStart();do{if(u.v=u.o.v=!0,u.e){if(p)for(o=0,s=h.length;o<s;++o)r.point((c=h[o])[0],c[1]);else n(u.x,u.n.x,1,r);u=u.n}else{if(p)for(h=u.p.z,o=h.length-1;o>=0;--o)r.point((c=h[o])[0],c[1]);else n(u.x,u.p.x,-1,r);u=u.p}h=(u=u.o).z,p=!p}while(!u.v);r.lineEnd()}}}function UA(t){if(e=t.length){for(var e,i,n=0,r=t[0];++n<e;)r.n=i=t[n],i.p=r,r=i;r.n=i=t[0],i.p=r}}function VA(t){return hA(t[0])<=nA?t[0]:yA(t[0])*((hA(t[0])+nA)%sA-nA)}function $A(t,e,i,n){return function(r){var o,s,a,l=e(r),h=jA(),c=e(h),d=!1,u={point:p,lineStart:g,lineEnd:y,polygonStart:function(){u.point=m,u.lineStart=b,u.lineEnd=v,s=[],o=[]},polygonEnd:function(){u.point=p,u.lineStart=g,u.lineEnd=y,s=tA(s);var t=function(t,e){var i=VA(e),n=e[1],r=gA(n),o=[gA(i),-uA(i),0],s=0,a=0,l=new QS;1===r?n=rA+eA:-1===r&&(n=-rA-eA);for(var h=0,c=t.length;h<c;++h)if(u=(d=t[h]).length)for(var d,u,p=d[u-1],f=VA(p),g=p[1]/2+oA,y=gA(g),m=uA(g),b=0;b<u;++b,f=w,y=x,m=_,p=v){var v=d[b],w=VA(v),C=v[1]/2+oA,x=gA(C),_=uA(C),S=w-f,A=S>=0?1:-1,T=A*S,B=T>nA,M=y*x;if(l.add(dA(M*A*gA(T),m*_+M*uA(T))),s+=B?S+A*sA:S,B^f>=i^w>=i){var R=PA(MA(p),MA(v));kA(R);var P=PA(o,R);kA(P);var E=(B^S>=0?-1:1)*vA(P[2]);(n>E||n===E&&(R[0]||R[1]))&&(a+=B^S>=0?1:-1)}}return(s<-eA||s<eA&&l<-iA)^1&a}(o,n);s.length?(d||(r.polygonStart(),d=!0),KA(s,YA,t,i,r)):t&&(d||(r.polygonStart(),d=!0),r.lineStart(),i(null,null,1,r),r.lineEnd()),d&&(r.polygonEnd(),d=!1),s=o=null},sphere:function(){r.polygonStart(),r.lineStart(),i(null,null,1,r),r.lineEnd(),r.polygonEnd()}};function p(e,i){t(e,i)&&r.point(e,i)}function f(t,e){l.point(t,e)}function g(){u.point=f,l.lineStart()}function y(){u.point=p,l.lineEnd()}function m(t,e){a.push([t,e]),c.point(t,e)}function b(){c.lineStart(),a=[]}function v(){m(a[0][0],a[0][1]),c.lineEnd();var t,e,i,n,l=c.clean(),u=h.result(),p=u.length;if(a.pop(),o.push(a),a=null,p)if(1&l){if((e=(i=u[0]).length-1)>0){for(d||(r.polygonStart(),d=!0),r.lineStart(),t=0;t<e;++t)r.point((n=i[t])[0],n[1]);r.lineEnd()}}else p>1&&2&l&&u.push(u.pop().concat(u.shift())),s.push(u.filter(XA))}return u}}function XA(t){return t.length>1}function YA(t,e){return((t=t.x)[0]<0?t[1]-rA-eA:rA-t[1])-((e=e.x)[0]<0?e[1]-rA-eA:rA-e[1])}IA.invert=IA;var qA=$A((function(){return!0}),(function(t){var e,i=NaN,n=NaN,r=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,s){var a=o>0?nA:-nA,l=hA(o-i);hA(l-nA)<eA?(t.point(i,n=(n+s)/2>0?rA:-rA),t.point(r,n),t.lineEnd(),t.lineStart(),t.point(a,n),t.point(o,n),e=0):r!==a&&l>=nA&&(hA(i-r)<eA&&(i-=r*eA),hA(o-a)<eA&&(o-=a*eA),n=function(t,e,i,n){var r,o,s=gA(t-i);return hA(s)>eA?cA((gA(e)*(o=uA(n))*gA(i)-gA(n)*(r=uA(e))*gA(t))/(r*o*s)):(e+n)/2}(i,n,o,s),t.point(r,n),t.lineEnd(),t.lineStart(),t.point(a,n),e=0),t.point(i=o,n=s),r=a},lineEnd:function(){t.lineEnd(),i=n=NaN},clean:function(){return 2-e}}}),(function(t,e,i,n){var r;if(null==t)r=i*rA,n.point(-nA,r),n.point(0,r),n.point(nA,r),n.point(nA,0),n.point(nA,-r),n.point(0,-r),n.point(-nA,-r),n.point(-nA,0),n.point(-nA,r);else if(hA(t[0]-e[0])>eA){var o=t[0]<e[0]?nA:-nA;r=i*o/2,n.point(-o,r),n.point(0,r),n.point(o,r)}else n.point(e[0],e[1])}),[-nA,-rA]);function ZA(t){var e=uA(t),i=6*lA,n=e>0,r=hA(e)>eA;function o(t,i){return uA(t)*uA(i)>e}function s(t,i,n){var r=[1,0,0],o=PA(MA(t),MA(i)),s=RA(o,o),a=o[0],l=s-a*a;if(!l)return!n&&t;var h=e*s/l,c=-e*a/l,d=PA(r,o),u=HA(r,h);EA(u,HA(o,c));var p=d,f=RA(u,p),g=RA(p,p),y=f*f-g*(RA(u,u)-1);if(!(y<0)){var m=mA(y),b=HA(p,(-f-m)/g);if(EA(b,u),b=BA(b),!n)return b;var v,w=t[0],C=i[0],x=t[1],_=i[1];C<w&&(v=w,w=C,C=v);var S=C-w,A=hA(S-nA)<eA;if(!A&&_<x&&(v=x,x=_,_=v),A||S<eA?A?x+_>0^b[1]<(hA(b[0]-w)<eA?x:_):x<=b[1]&&b[1]<=_:S>nA^(w<=b[0]&&b[0]<=C)){var T=HA(p,(-f+m)/g);return EA(T,u),[b,BA(T)]}}}function a(e,i){var r=n?t:nA-t,o=0;return e<-r?o|=1:e>r&&(o|=2),i<-r?o|=4:i>r&&(o|=8),o}return $A(o,(function(t){var e,i,l,h,c;return{lineStart:function(){h=l=!1,c=1},point:function(d,u){var p,f=[d,u],g=o(d,u),y=n?g?0:a(d,u):g?a(d+(d<0?nA:-nA),u):0;if(!e&&(h=l=g)&&t.lineStart(),g!==l&&(!(p=s(e,f))||NA(e,p)||NA(f,p))&&(f[2]=1),g!==l)c=0,g?(t.lineStart(),p=s(f,e),t.point(p[0],p[1])):(p=s(e,f),t.point(p[0],p[1],2),t.lineEnd()),e=p;else if(r&&e&&n^g){var m;y&i||!(m=s(f,e,!0))||(c=0,n?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1],3)))}!g||e&&NA(e,f)||t.point(f[0],f[1]),e=f,l=g,i=y},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return c|(h&&l)<<1}}}),(function(e,n,r,o){!function(t,e,i,n,r,o){if(i){var s=uA(e),a=gA(e),l=n*i;null==r?(r=e+n*sA,o=e-l/2):(r=zA(s,r),o=zA(s,o),(n>0?r<o:r>o)&&(r+=n*sA));for(var h,c=r;n>0?c>o:c<o;c-=l)h=BA([s,-a*uA(c),-a*gA(c)]),t.point(h[0],h[1])}}(o,t,i,r,e,n)}),n?[0,-t]:[-nA,t-nA])}var JA=1e9,QA=-JA;function tT(t,e,i,n){function r(r,o){return t<=r&&r<=i&&e<=o&&o<=n}function o(r,o,a,h){var c=0,d=0;if(null==r||(c=s(r,a))!==(d=s(o,a))||l(r,o)<0^a>0)do{h.point(0===c||3===c?t:i,c>1?n:e)}while((c=(c+a+4)%4)!==d);else h.point(o[0],o[1])}function s(n,r){return hA(n[0]-t)<eA?r>0?0:3:hA(n[0]-i)<eA?r>0?2:1:hA(n[1]-e)<eA?r>0?1:0:r>0?3:2}function a(t,e){return l(t.x,e.x)}function l(t,e){var i=s(t,1),n=s(e,1);return i!==n?i-n:0===i?e[1]-t[1]:1===i?t[0]-e[0]:2===i?t[1]-e[1]:e[0]-t[0]}return function(s){var l,h,c,d,u,p,f,g,y,m,b,v=s,w=jA(),C={point:x,lineStart:function(){C.point=_,h&&h.push(c=[]);m=!0,y=!1,f=g=NaN},lineEnd:function(){l&&(_(d,u),p&&y&&w.rejoin(),l.push(w.result()));C.point=x,y&&v.lineEnd()},polygonStart:function(){v=w,l=[],h=[],b=!0},polygonEnd:function(){var e=function(){for(var e=0,i=0,r=h.length;i<r;++i)for(var o,s,a=h[i],l=1,c=a.length,d=a[0],u=d[0],p=d[1];l<c;++l)o=u,s=p,u=(d=a[l])[0],p=d[1],s<=n?p>n&&(u-o)*(n-s)>(p-s)*(t-o)&&++e:p<=n&&(u-o)*(n-s)<(p-s)*(t-o)&&--e;return e}(),i=b&&e,r=(l=tA(l)).length;(i||r)&&(s.polygonStart(),i&&(s.lineStart(),o(null,null,1,s),s.lineEnd()),r&&KA(l,a,e,o,s),s.polygonEnd());v=s,l=h=c=null}};function x(t,e){r(t,e)&&v.point(t,e)}function _(o,s){var a=r(o,s);if(h&&c.push([o,s]),m)d=o,u=s,p=a,m=!1,a&&(v.lineStart(),v.point(o,s));else if(a&&y)v.point(o,s);else{var l=[f=Math.max(QA,Math.min(JA,f)),g=Math.max(QA,Math.min(JA,g))],w=[o=Math.max(QA,Math.min(JA,o)),s=Math.max(QA,Math.min(JA,s))];!function(t,e,i,n,r,o){var s,a=t[0],l=t[1],h=0,c=1,d=e[0]-a,u=e[1]-l;if(s=i-a,d||!(s>0)){if(s/=d,d<0){if(s<h)return;s<c&&(c=s)}else if(d>0){if(s>c)return;s>h&&(h=s)}if(s=r-a,d||!(s<0)){if(s/=d,d<0){if(s>c)return;s>h&&(h=s)}else if(d>0){if(s<h)return;s<c&&(c=s)}if(s=n-l,u||!(s>0)){if(s/=u,u<0){if(s<h)return;s<c&&(c=s)}else if(u>0){if(s>c)return;s>h&&(h=s)}if(s=o-l,u||!(s<0)){if(s/=u,u<0){if(s>c)return;s>h&&(h=s)}else if(u>0){if(s<h)return;s<c&&(c=s)}return h>0&&(t[0]=a+h*d,t[1]=l+h*u),c<1&&(e[0]=a+c*d,e[1]=l+c*u),!0}}}}}(l,w,t,e,i,n)?a&&(v.lineStart(),v.point(o,s),b=!1):(y||(v.lineStart(),v.point(l[0],l[1])),v.point(w[0],w[1]),a||v.lineEnd(),b=!1)}f=o,g=s,y=a}return C}}var eT,iT,nT,rT,oT=t=>t,sT=new QS,aT=new QS,lT={point:wA,lineStart:wA,lineEnd:wA,polygonStart:function(){lT.lineStart=hT,lT.lineEnd=uT},polygonEnd:function(){lT.lineStart=lT.lineEnd=lT.point=wA,sT.add(hA(aT)),aT=new QS},result:function(){var t=sT/2;return sT=new QS,t}};function hT(){lT.point=cT}function cT(t,e){lT.point=dT,eT=nT=t,iT=rT=e}function dT(t,e){aT.add(rT*t-nT*e),nT=t,rT=e}function uT(){dT(eT,iT)}var pT=lT,fT=1/0,gT=fT,yT=-fT,mT=yT,bT={point:function(t,e){t<fT&&(fT=t);t>yT&&(yT=t);e<gT&&(gT=e);e>mT&&(mT=e)},lineStart:wA,lineEnd:wA,polygonStart:wA,polygonEnd:wA,result:function(){var t=[[fT,gT],[yT,mT]];return yT=mT=-(gT=fT=1/0),t}};var vT,wT,CT,xT,_T=bT,ST=0,AT=0,TT=0,BT=0,MT=0,RT=0,PT=0,ET=0,HT=0,kT={point:LT,lineStart:IT,lineEnd:FT,polygonStart:function(){kT.lineStart=WT,kT.lineEnd=zT},polygonEnd:function(){kT.point=LT,kT.lineStart=IT,kT.lineEnd=FT},result:function(){var t=HT?[PT/HT,ET/HT]:RT?[BT/RT,MT/RT]:TT?[ST/TT,AT/TT]:[NaN,NaN];return ST=AT=TT=BT=MT=RT=PT=ET=HT=0,t}};function LT(t,e){ST+=t,AT+=e,++TT}function IT(){kT.point=OT}function OT(t,e){kT.point=DT,LT(CT=t,xT=e)}function DT(t,e){var i=t-CT,n=e-xT,r=mA(i*i+n*n);BT+=r*(CT+t)/2,MT+=r*(xT+e)/2,RT+=r,LT(CT=t,xT=e)}function FT(){kT.point=LT}function WT(){kT.point=jT}function zT(){NT(vT,wT)}function jT(t,e){kT.point=NT,LT(vT=CT=t,wT=xT=e)}function NT(t,e){var i=t-CT,n=e-xT,r=mA(i*i+n*n);BT+=r*(CT+t)/2,MT+=r*(xT+e)/2,RT+=r,PT+=(r=xT*t-CT*e)*(CT+t),ET+=r*(xT+e),HT+=3*r,LT(CT=t,xT=e)}var GT=kT;function KT(t){this._context=t}KT.prototype={_radius:4.5,pointRadius:function(t){return this._radius=t,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._context.closePath(),this._point=NaN},point:function(t,e){switch(this._point){case 0:this._context.moveTo(t,e),this._point=1;break;case 1:this._context.lineTo(t,e);break;default:this._context.moveTo(t+this._radius,e),this._context.arc(t,e,this._radius,0,sA)}},result:wA};var UT,VT,$T,XT,YT,qT=new QS,ZT={point:wA,lineStart:function(){ZT.point=JT},lineEnd:function(){UT&&QT(VT,$T),ZT.point=wA},polygonStart:function(){UT=!0},polygonEnd:function(){UT=null},result:function(){var t=+qT;return qT=new QS,t}};function JT(t,e){ZT.point=QT,VT=XT=t,$T=YT=e}function QT(t,e){XT-=t,YT-=e,qT.add(mA(XT*XT+YT*YT)),XT=t,YT=e}var tB=ZT;let eB,iB,nB,rB;class oB{constructor(t){this._append=null==t?sB:function(t){const e=Math.floor(t);if(!(e>=0))throw new RangeError(`invalid digits: ${t}`);if(e>15)return sB;if(e!==eB){const t=10**e;eB=e,iB=function(e){let i=1;this._+=e[0];for(const n=e.length;i<n;++i)this._+=Math.round(arguments[i]*t)/t+e[i]}}return iB}(t),this._radius=4.5,this._=""}pointRadius(t){return this._radius=+t,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){0===this._line&&(this._+="Z"),this._point=NaN}point(t,e){switch(this._point){case 0:this._append`M${t},${e}`,this._point=1;break;case 1:this._append`L${t},${e}`;break;default:if(this._append`M${t},${e}`,this._radius!==nB||this._append!==iB){const t=this._radius,e=this._;this._="",this._append`m0,${t}a${t},${t} 0 1,1 0,${-2*t}a${t},${t} 0 1,1 0,${2*t}z`,nB=t,iB=this._append,rB=this._,this._=e}this._+=rB}}result(){const t=this._;return this._="",t.length?t:null}}function sB(t){let e=1;this._+=t[0];for(const i=t.length;e<i;++e)this._+=arguments[e]+t[e]}function aB(t){return function(e){var i=new lB;for(var n in t)i[n]=t[n];return i.stream=e,i}}function lB(){}function hB(t,e,i){var n=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=n&&t.clipExtent(null),TA(i,t.stream(_T)),e(_T.result()),null!=n&&t.clipExtent(n),t}function cB(t,e,i){return hB(t,(function(i){var n=e[1][0]-e[0][0],r=e[1][1]-e[0][1],o=Math.min(n/(i[1][0]-i[0][0]),r/(i[1][1]-i[0][1])),s=+e[0][0]+(n-o*(i[1][0]+i[0][0]))/2,a=+e[0][1]+(r-o*(i[1][1]+i[0][1]))/2;t.scale(150*o).translate([s,a])}),i)}lB.prototype={constructor:lB,point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var dB=16,uB=uA(30*lA);function pB(t,e){return+e?function(t,e){function i(n,r,o,s,a,l,h,c,d,u,p,f,g,y){var m=h-n,b=c-r,v=m*m+b*b;if(v>4*e&&g--){var w=s+u,C=a+p,x=l+f,_=mA(w*w+C*C+x*x),S=vA(x/=_),A=hA(hA(x)-1)<eA||hA(o-d)<eA?(o+d)/2:dA(C,w),T=t(A,S),B=T[0],M=T[1],R=B-n,P=M-r,E=b*R-m*P;(E*E/v>e||hA((m*R+b*P)/v-.5)>.3||s*u+a*p+l*f<uB)&&(i(n,r,o,s,a,l,B,M,A,w/=_,C/=_,x,g,y),y.point(B,M),i(B,M,A,w,C,x,h,c,d,u,p,f,g,y))}}return function(e){var n,r,o,s,a,l,h,c,d,u,p,f,g={point:y,lineStart:m,lineEnd:v,polygonStart:function(){e.polygonStart(),g.lineStart=w},polygonEnd:function(){e.polygonEnd(),g.lineStart=m}};function y(i,n){i=t(i,n),e.point(i[0],i[1])}function m(){c=NaN,g.point=b,e.lineStart()}function b(n,r){var o=MA([n,r]),s=t(n,r);i(c,d,h,u,p,f,c=s[0],d=s[1],h=n,u=o[0],p=o[1],f=o[2],dB,e),e.point(c,d)}function v(){g.point=y,e.lineEnd()}function w(){m(),g.point=C,g.lineEnd=x}function C(t,e){b(n=t,e),r=c,o=d,s=u,a=p,l=f,g.point=b}function x(){i(c,d,h,u,p,f,r,o,n,s,a,l,dB,e),g.lineEnd=v,v()}return g}}(t,e):function(t){return aB({point:function(e,i){e=t(e,i),this.stream.point(e[0],e[1])}})}(t)}var fB=aB({point:function(t,e){this.stream.point(t*lA,e*lA)}});function gB(t,e,i,n,r,o){if(!o)return function(t,e,i,n,r){function o(o,s){return[e+t*(o*=n),i-t*(s*=r)]}return o.invert=function(o,s){return[(o-e)/t*n,(i-s)/t*r]},o}(t,e,i,n,r);var s=uA(o),a=gA(o),l=s*t,h=a*t,c=s/t,d=a/t,u=(a*i-s*e)/t,p=(a*e+s*i)/t;function f(t,o){return[l*(t*=n)-h*(o*=r)+e,i-h*t-l*o]}return f.invert=function(t,e){return[n*(c*t-d*e+u),r*(p-d*t-c*e)]},f}function yB(t){return function(t){var e,i,n,r,o,s,a,l,h,c,d=150,u=480,p=250,f=0,g=0,y=0,m=0,b=0,v=0,w=1,C=1,x=null,_=qA,S=null,A=oT,T=.5;function B(t){return l(t[0]*lA,t[1]*lA)}function M(t){return(t=l.invert(t[0],t[1]))&&[t[0]*aA,t[1]*aA]}function R(){var t=gB(d,0,0,w,C,v).apply(null,e(f,g)),n=gB(d,u-t[0],p-t[1],w,C,v);return i=OA(y,m,b),a=LA(e,n),l=LA(i,a),s=pB(a,T),P()}function P(){return h=c=null,B}return B.stream=function(t){return h&&c===t?h:h=fB(function(t){return aB({point:function(e,i){var n=t(e,i);return this.stream.point(n[0],n[1])}})}(i)(_(s(A(c=t)))))},B.preclip=function(t){return arguments.length?(_=t,x=void 0,P()):_},B.postclip=function(t){return arguments.length?(A=t,S=n=r=o=null,P()):A},B.clipAngle=function(t){return arguments.length?(_=+t?ZA(x=t*lA):(x=null,qA),P()):x*aA},B.clipExtent=function(t){return arguments.length?(A=null==t?(S=n=r=o=null,oT):tT(S=+t[0][0],n=+t[0][1],r=+t[1][0],o=+t[1][1]),P()):null==S?null:[[S,n],[r,o]]},B.scale=function(t){return arguments.length?(d=+t,R()):d},B.translate=function(t){return arguments.length?(u=+t[0],p=+t[1],R()):[u,p]},B.center=function(t){return arguments.length?(f=t[0]%360*lA,g=t[1]%360*lA,R()):[f*aA,g*aA]},B.rotate=function(t){return arguments.length?(y=t[0]%360*lA,m=t[1]%360*lA,b=t.length>2?t[2]%360*lA:0,R()):[y*aA,m*aA,b*aA]},B.angle=function(t){return arguments.length?(v=t%360*lA,R()):v*aA},B.reflectX=function(t){return arguments.length?(w=t?-1:1,R()):w<0},B.reflectY=function(t){return arguments.length?(C=t?-1:1,R()):C<0},B.precision=function(t){return arguments.length?(s=pB(a,T=t*t),P()):mA(T)},B.fitExtent=function(t,e){return cB(B,t,e)},B.fitSize=function(t,e){return function(t,e,i){return cB(t,[[0,0],e],i)}(B,t,e)},B.fitWidth=function(t,e){return function(t,e,i){return hB(t,(function(i){var n=+e,r=n/(i[1][0]-i[0][0]),o=(n-r*(i[1][0]+i[0][0]))/2,s=-r*i[0][1];t.scale(150*r).translate([o,s])}),i)}(B,t,e)},B.fitHeight=function(t,e){return function(t,e,i){return hB(t,(function(i){var n=+e,r=n/(i[1][1]-i[0][1]),o=-r*i[0][0],s=(n-r*(i[1][1]+i[0][1]))/2;t.scale(150*r).translate([o,s])}),i)}(B,t,e)},function(){return e=t.apply(this,arguments),B.invert=e.invert&&M,R()}}((function(){return t}))()}function mB(t,e){return[t,fA(bA((rA+e)/2))]}mB.invert=function(t,e){return[t,2*cA(pA(e))-rA]},function(t){var e,i,n,r=yB(t),o=r.center,s=r.scale,a=r.translate,l=r.clipExtent,h=null;function c(){var o=nA*s(),a=r(function(t){function e(e){return(e=t(e[0]*lA,e[1]*lA))[0]*=aA,e[1]*=aA,e}return t=OA(t[0]*lA,t[1]*lA,t.length>2?t[2]*lA:0),e.invert=function(e){return(e=t.invert(e[0]*lA,e[1]*lA))[0]*=aA,e[1]*=aA,e},e}(r.rotate()).invert([0,0]));return l(null==h?[[a[0]-o,a[1]-o],[a[0]+o,a[1]+o]]:t===mB?[[Math.max(a[0]-o,h),e],[Math.min(a[0]+o,i),n]]:[[h,Math.max(a[1]-o,e)],[i,Math.min(a[1]+o,n)]])}return r.scale=function(t){return arguments.length?(s(t),c()):s()},r.translate=function(t){return arguments.length?(a(t),c()):a()},r.center=function(t){return arguments.length?(o(t),c()):o()},r.clipExtent=function(t){return arguments.length?(null==t?h=e=i=n=null:(h=+t[0][0],e=+t[0][1],i=+t[1][0],n=+t[1][1]),c()):null==h?null:[[h,e],[i,n]]},c()}(mB).scale(961/sA).translate([0,0]).center([0,0]).scale(63781);var bB=Object.prototype.hasOwnProperty;function vB(t,e,i,n,r,o){3===arguments.length&&(n=o=Array,r=null);for(var s=new n(t=1<<Math.max(4,Math.ceil(Math.log(t)/Math.LN2))),a=new o(t),l=t-1,h=0;h<t;++h)s[h]=r;return{set:function(n,o){for(var h=e(n)&l,c=s[h],d=0;c!=r;){if(i(c,n))return a[h]=o;if(++d>=t)throw new Error("full hashmap");c=s[h=h+1&l]}return s[h]=n,a[h]=o,o},maybeSet:function(n,o){for(var h=e(n)&l,c=s[h],d=0;c!=r;){if(i(c,n))return a[h];if(++d>=t)throw new Error("full hashmap");c=s[h=h+1&l]}return s[h]=n,a[h]=o,o},get:function(n,o){for(var h=e(n)&l,c=s[h],d=0;c!=r;){if(i(c,n))return a[h];if(++d>=t)break;c=s[h=h+1&l]}return o},keys:function(){for(var t=[],e=0,i=s.length;e<i;++e){var n=s[e];n!=r&&t.push(n)}return t}}}function wB(t,e){return t[0]===e[0]&&t[1]===e[1]}var CB=new ArrayBuffer(16),xB=new Float64Array(CB),_B=new Uint32Array(CB);function SB(t){xB[0]=t[0],xB[1]=t[1];var e=_B[0]^_B[1];return 2147483647&(e=e<<5^e>>7^_B[2]^_B[3])}function AB(t){var e,i,n,r,o=t.coordinates,s=t.lines,a=t.rings,l=function(){for(var t=vB(1.4*o.length,C,x,Int32Array,-1,Int32Array),e=new Int32Array(o.length),i=0,n=o.length;i<n;++i)e[i]=t.maybeSet(i,i);return e}(),h=new Int32Array(o.length),c=new Int32Array(o.length),d=new Int32Array(o.length),u=new Int8Array(o.length),p=0;for(e=0,i=o.length;e<i;++e)h[e]=c[e]=d[e]=-1;for(e=0,i=s.length;e<i;++e){var f=s[e],g=f[0],y=f[1];for(n=l[g],r=l[++g],++p,u[n]=1;++g<=y;)w(e,n,n=r,r=l[g]);++p,u[r]=1}for(e=0,i=o.length;e<i;++e)h[e]=-1;for(e=0,i=a.length;e<i;++e){var m=a[e],b=m[0]+1,v=m[1];for(w(e,l[v-1],n=l[b-1],r=l[b]);++b<=v;)w(e,n,n=r,r=l[b])}function w(t,e,i,n){if(h[i]!==t){h[i]=t;var r=c[i];if(r>=0){var o=d[i];r===e&&o===n||r===n&&o===e||(++p,u[i]=1)}else c[i]=e,d[i]=n}}function C(t){return SB(o[t])}function x(t,e){return wB(o[t],o[e])}h=c=d=null;var _,S=function(t,e,i,n,r){3===arguments.length&&(n=Array,r=null);for(var o=new n(t=1<<Math.max(4,Math.ceil(Math.log(t)/Math.LN2))),s=t-1,a=0;a<t;++a)o[a]=r;return{add:function(n){for(var a=e(n)&s,l=o[a],h=0;l!=r;){if(i(l,n))return!0;if(++h>=t)throw new Error("full hashset");l=o[a=a+1&s]}return o[a]=n,!0},has:function(n){for(var a=e(n)&s,l=o[a],h=0;l!=r;){if(i(l,n))return!0;if(++h>=t)break;l=o[a=a+1&s]}return!1},values:function(){for(var t=[],e=0,i=o.length;e<i;++e){var n=o[e];n!=r&&t.push(n)}return t}}}(1.4*p,SB,wB);for(e=0,i=o.length;e<i;++e)u[_=l[e]]&&S.add(o[_]);return S}function TB(t,e,i,n){BB(t,e,i),BB(t,e,e+n),BB(t,e+n,i)}function BB(t,e,i){for(var n,r=e+(i---e>>1);e<r;++e,--i)n=t[e],t[e]=t[i],t[i]=n}function MB(t){var e,i,n={};for(e in t)n[e]=null==(i=t[e])?{type:null}:("FeatureCollection"===i.type?RB:"Feature"===i.type?PB:EB)(i);return n}function RB(t){var e={type:"GeometryCollection",geometries:t.features.map(PB)};return null!=t.bbox&&(e.bbox=t.bbox),e}function PB(t){var e,i=EB(t.geometry);for(e in null!=t.id&&(i.id=t.id),null!=t.bbox&&(i.bbox=t.bbox),t.properties){i.properties=t.properties;break}return i}function EB(t){if(null==t)return{type:null};var e="GeometryCollection"===t.type?{type:"GeometryCollection",geometries:t.geometries.map(EB)}:"Point"===t.type||"MultiPoint"===t.type?{type:t.type,coordinates:t.coordinates}:{type:t.type,arcs:t.coordinates};return null!=t.bbox&&(e.bbox=t.bbox),e}function HB(t){var e,i=t[0],n=t[1];return n<i&&(e=i,i=n,n=e),i+31*n}function kB(t,e){var i,n=t[0],r=t[1],o=e[0],s=e[1];return r<n&&(i=n,n=r,r=i),s<o&&(i=o,o=s,s=i),n===o&&r===s}var LB=Object.freeze({__proto__:null,topology:function(t,e){var i=function(t){var e=1/0,i=1/0,n=-1/0,r=-1/0;function o(t){null!=t&&bB.call(s,t.type)&&s[t.type](t)}var s={GeometryCollection:function(t){t.geometries.forEach(o)},Point:function(t){a(t.coordinates)},MultiPoint:function(t){t.coordinates.forEach(a)},LineString:function(t){l(t.arcs)},MultiLineString:function(t){t.arcs.forEach(l)},Polygon:function(t){t.arcs.forEach(l)},MultiPolygon:function(t){t.arcs.forEach(h)}};function a(t){var o=t[0],s=t[1];o<e&&(e=o),o>n&&(n=o),s<i&&(i=s),s>r&&(r=s)}function l(t){t.forEach(a)}function h(t){t.forEach(l)}for(var c in t)o(t[c]);return n>=e&&r>=i?[e,i,n,r]:void 0}(t=MB(t)),n=e>0&&i&&function(t,e,i){var n=e[0],r=e[1],o=e[2],s=e[3],a=o-n?(i-1)/(o-n):1,l=s-r?(i-1)/(s-r):1;function h(t){return[Math.round((t[0]-n)*a),Math.round((t[1]-r)*l)]}function c(t,e){for(var i,o,s,h,c,d=-1,u=0,p=t.length,f=new Array(p);++d<p;)i=t[d],h=Math.round((i[0]-n)*a),c=Math.round((i[1]-r)*l),h===o&&c===s||(f[u++]=[o=h,s=c]);for(f.length=u;u<e;)u=f.push([f[0][0],f[0][1]]);return f}function d(t){return c(t,2)}function u(t){return c(t,4)}function p(t){return t.map(u)}function f(t){null!=t&&bB.call(g,t.type)&&g[t.type](t)}var g={GeometryCollection:function(t){t.geometries.forEach(f)},Point:function(t){t.coordinates=h(t.coordinates)},MultiPoint:function(t){t.coordinates=t.coordinates.map(h)},LineString:function(t){t.arcs=d(t.arcs)},MultiLineString:function(t){t.arcs=t.arcs.map(d)},Polygon:function(t){t.arcs=p(t.arcs)},MultiPolygon:function(t){t.arcs=t.arcs.map(p)}};for(var y in t)f(t[y]);return{scale:[1/a,1/l],translate:[n,r]}}(t,i,e),r=function(t){var e,i,n,r,o=t.coordinates,s=t.lines,a=t.rings,l=s.length+a.length;for(delete t.lines,delete t.rings,n=0,r=s.length;n<r;++n)for(e=s[n];e=e.next;)++l;for(n=0,r=a.length;n<r;++n)for(i=a[n];i=i.next;)++l;var h=vB(2*l*1.4,SB,wB),c=t.arcs=[];for(n=0,r=s.length;n<r;++n){e=s[n];do{d(e)}while(e=e.next)}for(n=0,r=a.length;n<r;++n)if((i=a[n]).next)do{d(i)}while(i=i.next);else u(i);function d(t){var e,i,n,r,s,a,l,d;if(n=h.get(e=o[t[0]]))for(l=0,d=n.length;l<d;++l)if(p(r=n[l],t))return t[0]=r[0],void(t[1]=r[1]);if(s=h.get(i=o[t[1]]))for(l=0,d=s.length;l<d;++l)if(f(a=s[l],t))return t[1]=a[0],void(t[0]=a[1]);n?n.push(t):h.set(e,[t]),s?s.push(t):h.set(i,[t]),c.push(t)}function u(t){var e,i,n,r,s;if(i=h.get(o[t[0]]))for(r=0,s=i.length;r<s;++r){if(g(n=i[r],t))return t[0]=n[0],void(t[1]=n[1]);if(y(n,t))return t[0]=n[1],void(t[1]=n[0])}if(i=h.get(e=o[t[0]+m(t)]))for(r=0,s=i.length;r<s;++r){if(g(n=i[r],t))return t[0]=n[0],void(t[1]=n[1]);if(y(n,t))return t[0]=n[1],void(t[1]=n[0])}i?i.push(t):h.set(e,[t]),c.push(t)}function p(t,e){var i=t[0],n=e[0],r=t[1];if(i-r!=n-e[1])return!1;for(;i<=r;++i,++n)if(!wB(o[i],o[n]))return!1;return!0}function f(t,e){var i=t[0],n=e[0],r=t[1],s=e[1];if(i-r!=n-s)return!1;for(;i<=r;++i,--s)if(!wB(o[i],o[s]))return!1;return!0}function g(t,e){var i=t[0],n=e[0],r=t[1]-i;if(r!==e[1]-n)return!1;for(var s=m(t),a=m(e),l=0;l<r;++l)if(!wB(o[i+(l+s)%r],o[n+(l+a)%r]))return!1;return!0}function y(t,e){var i=t[0],n=e[0],r=t[1],s=e[1],a=r-i;if(a!==s-n)return!1;for(var l=m(t),h=a-m(e),c=0;c<a;++c)if(!wB(o[i+(c+l)%a],o[s-(c+h)%a]))return!1;return!0}function m(t){for(var e=t[0],i=t[1],n=e,r=n,s=o[n];++n<i;){var a=o[n];(a[0]<s[0]||a[0]===s[0]&&a[1]<s[1])&&(r=n,s=a)}return r-e}return t}(function(t){var e,i,n,r=AB(t),o=t.coordinates,s=t.lines,a=t.rings;for(i=0,n=s.length;i<n;++i)for(var l=s[i],h=l[0],c=l[1];++h<c;)r.has(o[h])&&(e={0:h,1:l[1]},l[1]=h,l=l.next=e);for(i=0,n=a.length;i<n;++i)for(var d=a[i],u=d[0],p=u,f=d[1],g=r.has(o[u]);++p<f;)r.has(o[p])&&(g?(e={0:p,1:d[1]},d[1]=p,d=d.next=e):(TB(o,u,f,f-p),o[f]=o[u],g=!0,p=u));return t}(function(t){var e=-1,i=[],n=[],r=[];function o(t){t&&bB.call(s,t.type)&&s[t.type](t)}var s={GeometryCollection:function(t){t.geometries.forEach(o)},LineString:function(t){t.arcs=a(t.arcs)},MultiLineString:function(t){t.arcs=t.arcs.map(a)},Polygon:function(t){t.arcs=t.arcs.map(l)},MultiPolygon:function(t){t.arcs=t.arcs.map(h)}};function a(t){for(var n=0,o=t.length;n<o;++n)r[++e]=t[n];var s={0:e-o+1,1:e};return i.push(s),s}function l(t){for(var i=0,o=t.length;i<o;++i)r[++e]=t[i];var s={0:e-o+1,1:e};return n.push(s),s}function h(t){return t.map(l)}for(var c in t)o(t[c]);return{type:"Topology",coordinates:r,lines:i,rings:n,objects:t}}(t))),o=r.coordinates,s=vB(1.4*r.arcs.length,HB,kB);function a(t){t&&bB.call(l,t.type)&&l[t.type](t)}t=r.objects,r.bbox=i,r.arcs=r.arcs.map((function(t,e){return s.set(t,e),o.slice(t[0],t[1]+1)})),delete r.coordinates,o=null;var l={GeometryCollection:function(t){t.geometries.forEach(a)},LineString:function(t){t.arcs=h(t.arcs)},MultiLineString:function(t){t.arcs=t.arcs.map(h)},Polygon:function(t){t.arcs=t.arcs.map(h)},MultiPolygon:function(t){t.arcs=t.arcs.map(c)}};function h(t){var e=[];do{var i=s.get(t);e.push(t[0]<t[1]?i:~i)}while(t=t.next);return e}function c(t){return t.map(h)}for(var d in t)a(t[d]);return n&&(r.transform=n,r.arcs=function(t){for(var e=-1,i=t.length;++e<i;){for(var n,r,o=t[e],s=0,a=1,l=o.length,h=o[0],c=h[0],d=h[1];++s<l;)n=(h=o[s])[0],r=h[1],n===c&&r===d||(o[a++]=[n-c,r-d],c=n,d=r);1===a&&(o[a++]=[0,0]),o.length=a}return t}(r.arcs)),r}}),IB=Bt(LB);function OB(t){return t}function DB(t){if(null==t)return OB;var e,i,n=t.scale[0],r=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,a){a||(e=i=0);var l=2,h=t.length,c=new Array(h);for(c[0]=(e+=t[0])*n+o,c[1]=(i+=t[1])*r+s;l<h;)c[l]=t[l],++l;return c}}function FB(t){var e,i=DB(t.transform),n=1/0,r=n,o=-n,s=-n;function a(t){(t=i(t))[0]<n&&(n=t[0]),t[0]>o&&(o=t[0]),t[1]<r&&(r=t[1]),t[1]>s&&(s=t[1])}function l(t){switch(t.type){case"GeometryCollection":t.geometries.forEach(l);break;case"Point":a(t.coordinates);break;case"MultiPoint":t.coordinates.forEach(a)}}for(e in t.arcs.forEach((function(t){for(var e,a=-1,l=t.length;++a<l;)(e=i(t[a],a))[0]<n&&(n=e[0]),e[0]>o&&(o=e[0]),e[1]<r&&(r=e[1]),e[1]>s&&(s=e[1])})),t.objects)l(t.objects[e]);return[n,r,o,s]}function WB(t,e){var i=e.id,n=e.bbox,r=null==e.properties?{}:e.properties,o=zB(t,e);return null==i&&null==n?{type:"Feature",properties:r,geometry:o}:null==n?{type:"Feature",id:i,properties:r,geometry:o}:{type:"Feature",id:i,bbox:n,properties:r,geometry:o}}function zB(t,e){var i=DB(t.transform),n=t.arcs;function r(t,e){e.length&&e.pop();for(var r=n[t<0?~t:t],o=0,s=r.length;o<s;++o)e.push(i(r[o],o));t<0&&function(t,e){for(var i,n=t.length,r=n-e;r<--n;)i=t[r],t[r++]=t[n],t[n]=i}(e,s)}function o(t){return i(t)}function s(t){for(var e=[],i=0,n=t.length;i<n;++i)r(t[i],e);return e.length<2&&e.push(e[0]),e}function a(t){for(var e=s(t);e.length<4;)e.push(e[0]);return e}function l(t){return t.map(a)}return function t(e){var i,n=e.type;switch(n){case"GeometryCollection":return{type:n,geometries:e.geometries.map(t)};case"Point":i=o(e.coordinates);break;case"MultiPoint":i=e.coordinates.map(o);break;case"LineString":i=s(e.arcs);break;case"MultiLineString":i=e.arcs.map(s);break;case"Polygon":i=l(e.arcs);break;case"MultiPolygon":i=e.arcs.map(l);break;default:return null}return{type:n,coordinates:i}}(e)}function jB(t,e){var i={},n={},r={},o=[],s=-1;function a(t,e){for(var n in t){var r=t[n];delete e[r.start],delete r.start,delete r.end,r.forEach((function(t){i[t<0?~t:t]=1})),o.push(r)}}return e.forEach((function(i,n){var r,o=t.arcs[i<0?~i:i];o.length<3&&!o[1][0]&&!o[1][1]&&(r=e[++s],e[s]=i,e[n]=r)})),e.forEach((function(e){var i,o,s=function(e){var i,n=t.arcs[e<0?~e:e],r=n[0];t.transform?(i=[0,0],n.forEach((function(t){i[0]+=t[0],i[1]+=t[1]}))):i=n[n.length-1];return e<0?[i,r]:[r,i]}(e),a=s[0],l=s[1];if(i=r[a])if(delete r[i.end],i.push(e),i.end=l,o=n[l]){delete n[o.start];var h=o===i?i:i.concat(o);n[h.start=i.start]=r[h.end=o.end]=h}else n[i.start]=r[i.end]=i;else if(i=n[l])if(delete n[i.start],i.unshift(e),i.start=a,o=r[a]){delete r[o.end];var c=o===i?i:o.concat(i);n[c.start=o.start]=r[c.end=i.end]=c}else n[i.start]=r[i.end]=i;else n[(i=[e]).start=a]=r[i.end=l]=i})),a(r,n),a(n,r),e.forEach((function(t){i[t<0?~t:t]||o.push([t])})),o}function NB(t,e,i){var n,r,o;if(arguments.length>1)n=function(t,e,i){var n,r=[],o=[];function s(t){var e=t<0?~t:t;(o[e]||(o[e]=[])).push({i:t,g:n})}function a(t){t.forEach(s)}function l(t){t.forEach(a)}function h(t){t.forEach(l)}function c(t){switch(n=t,t.type){case"GeometryCollection":t.geometries.forEach(c);break;case"LineString":a(t.arcs);break;case"MultiLineString":case"Polygon":l(t.arcs);break;case"MultiPolygon":h(t.arcs)}}return c(e),o.forEach(null==i?function(t){r.push(t[0].i)}:function(t){i(t[0].g,t[t.length-1].g)&&r.push(t[0].i)}),r}(0,e,i);else for(r=0,n=new Array(o=t.arcs.length);r<o;++r)n[r]=r;return{type:"MultiLineString",arcs:jB(t,n)}}function GB(t,e){var i={},n=[],r=[];function o(t){t.forEach((function(e){e.forEach((function(e){(i[e=e<0?~e:e]||(i[e]=[])).push(t)}))})),n.push(t)}function s(e){return function(t){for(var e,i=-1,n=t.length,r=t[n-1],o=0;++i<n;)e=r,r=t[i],o+=e[0]*r[1]-e[1]*r[0];return Math.abs(o)}(zB(t,{type:"Polygon",arcs:[e]}).coordinates[0])}return e.forEach((function t(e){switch(e.type){case"GeometryCollection":e.geometries.forEach(t);break;case"Polygon":o(e.arcs);break;case"MultiPolygon":e.arcs.forEach(o)}})),n.forEach((function(t){if(!t._){var e=[],n=[t];for(t._=1,r.push(e);t=n.pop();)e.push(t),t.forEach((function(t){t.forEach((function(t){i[t<0?~t:t].forEach((function(t){t._||(t._=1,n.push(t))}))}))}))}})),n.forEach((function(t){delete t._})),{type:"MultiPolygon",arcs:r.map((function(e){var n,r=[];if(e.forEach((function(t){t.forEach((function(t){t.forEach((function(t){i[t<0?~t:t].length<2&&r.push(t)}))}))})),(n=(r=jB(t,r)).length)>1)for(var o,a,l=1,h=s(r[0]);l<n;++l)(o=s(r[l]))>h&&(a=r[0],r[0]=r[l],r[l]=a,h=o);return r})).filter((function(t){return t.length>0}))}}function KB(t,e){for(var i=0,n=t.length;i<n;){var r=i+n>>>1;t[r]<e?i=r+1:n=r}return i}function UB(t){if(null==t)return OB;var e,i,n=t.scale[0],r=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,a){a||(e=i=0);var l=2,h=t.length,c=new Array(h),d=Math.round((t[0]-o)/n),u=Math.round((t[1]-s)/r);for(c[0]=d-e,e=d,c[1]=u-i,i=u;l<h;)c[l]=t[l],++l;return c}}var VB=Object.freeze({__proto__:null,bbox:FB,feature:function(t,e){return"string"==typeof e&&(e=t.objects[e]),"GeometryCollection"===e.type?{type:"FeatureCollection",features:e.geometries.map((function(e){return WB(t,e)}))}:WB(t,e)},merge:function(t){return zB(t,GB.apply(this,arguments))},mergeArcs:GB,mesh:function(t){return zB(t,NB.apply(this,arguments))},meshArcs:NB,neighbors:function(t){var e={},i=t.map((function(){return[]}));function n(t,i){t.forEach((function(t){t<0&&(t=~t);var n=e[t];n?n.push(i):e[t]=[i]}))}function r(t,e){t.forEach((function(t){n(t,e)}))}var o={LineString:n,MultiLineString:r,Polygon:r,MultiPolygon:function(t,e){t.forEach((function(t){r(t,e)}))}};for(var s in t.forEach((function t(e,i){"GeometryCollection"===e.type?e.geometries.forEach((function(e){t(e,i)})):e.type in o&&o[e.type](e.arcs,i)})),e)for(var a=e[s],l=a.length,h=0;h<l;++h)for(var c=h+1;c<l;++c){var d,u=a[h],p=a[c];(d=i[u])[s=KB(d,p)]!==p&&d.splice(s,0,p),(d=i[p])[s=KB(d,u)]!==u&&d.splice(s,0,u)}return i},quantize:function(t,e){if(t.transform)throw new Error("already quantized");if(e&&e.scale)a=t.bbox;else{if(!((i=Math.floor(e))>=2))throw new Error("n must be ≥2");var i,n=(a=t.bbox||FB(t))[0],r=a[1],o=a[2],s=a[3];e={scale:[o-n?(o-n)/(i-1):1,s-r?(s-r)/(i-1):1],translate:[n,r]}}var a,l,h=UB(e),c=t.objects,d={};function u(t){return h(t)}function p(t){var e;switch(t.type){case"GeometryCollection":e={type:"GeometryCollection",geometries:t.geometries.map(p)};break;case"Point":e={type:"Point",coordinates:u(t.coordinates)};break;case"MultiPoint":e={type:"MultiPoint",coordinates:t.coordinates.map(u)};break;default:return t}return null!=t.id&&(e.id=t.id),null!=t.bbox&&(e.bbox=t.bbox),null!=t.properties&&(e.properties=t.properties),e}for(l in c)d[l]=p(c[l]);return{type:"Topology",bbox:a,transform:e,objects:d,arcs:t.arcs.map((function(t){var e,i=0,n=1,r=t.length,o=new Array(r);for(o[0]=h(t[0],0);++i<r;)((e=h(t[i],i))[0]||e[1])&&(o[n++]=e);return 1===n&&(o[n++]=[0,0]),o.length=n,o}))}},transform:DB,untransform:UB}),$B=Bt(VB);IB.topology,$B.merge;var XB=function(t,e){this.p1=t,this.p2=e};XB.prototype.rise=function(){return this.p2[1]-this.p1[1]},XB.prototype.run=function(){return this.p2[0]-this.p1[0]},XB.prototype.slope=function(){return this.rise()/this.run()},XB.prototype.yIntercept=function(){return this.p1[1]-this.p1[0]*this.slope(this.p1,this.p2)},XB.prototype.isVertical=function(){return!isFinite(this.slope())},XB.prototype.isHorizontal=function(){return this.p1[1]==this.p2[1]},XB.prototype._perpendicularDistanceHorizontal=function(t){return Math.abs(this.p1[1]-t[1])},XB.prototype._perpendicularDistanceVertical=function(t){return Math.abs(this.p1[0]-t[0])},XB.prototype._perpendicularDistanceHasSlope=function(t){var e=this.slope(),i=this.yIntercept();return Math.abs(e*t[0]-t[1]+i)/Math.sqrt(Math.pow(e,2)+1)},XB.prototype.perpendicularDistance=function(t){return this.isVertical()?this._perpendicularDistanceVertical(t):this.isHorizontal()?this._perpendicularDistanceHorizontal(t):this._perpendicularDistanceHasSlope(t)};var YB,qB=XB,ZB=function(t,e){for(var i=0,n=0,r=1;r<=t.length-2;r++){var o=new qB(t[0],t[t.length-1]).perpendicularDistance(t[r]);o>i&&(n=r,i=o)}if(i>e)var s=ZB(t.slice(0,n),e),a=ZB(t.slice(n,t.length),e),l=s.concat(a);else l=t.length>1?[t[0],t[t.length-1]]:[t[0]];return l},JB=ZB;!function(t){var e=JB;function i(e,i){var n=e.geometry,r=n.type;if("LineString"===r)n.coordinates=t.exports.simplify(n.coordinates,i);else if("Polygon"===r||"MultiLineString"===r)for(var o=0;o<n.coordinates.length;o++)n.coordinates[o]=t.exports.simplify(n.coordinates[o],i);else if("MultiPolygon"===r)for(var s=0;s<n.coordinates.length;s++)for(var a=0;a<n.coordinates[s].length;a++)n.coordinates[s][a]=t.exports.simplify(n.coordinates[s][a],i);return e}t.exports=function(t,e,n){return n||(t=JSON.parse(JSON.stringify(t))),t.features?function(t,e){for(var n=0;n<t.features.length;n++)t.features[n]=i(t.features[n],e);return t}(t,e):t.type&&"Feature"===t.type?i(t,e):new Error("FeatureCollection or individual Feature required")},t.exports.simplify=function(t,i){return e(t,i)}}({exports:{}}),function(t){t.DSV="dsv",t.TREE="tree",t.GEO="geo",t.BYTE="bytejson",t.HEX="hex",t.GRAPH="graph",t.TABLE="table",t.GEO_GRATICULE="geo-graticule"}(YB||(YB={}));const QB=(t,e)=>{var i,n;if(!(null==e?void 0:e.fields))return t;if(0===t.length)return t;const r=e.fields,o=t[0],s={},a=[];for(const e in r)if(Object.prototype.hasOwnProperty.call(r,e)){const l=r[e];if(!l.type){let n=o;e in o||(n=null!==(i=t.find((t=>e in t)))&&void 0!==i?i:o),l.type="number"==typeof n[e]?"linear":"ordinal"}let h;if("number"==typeof l.sortIndex&&(h={key:e,type:l.type,index:l.sortIndex,sortIndex:{},sortIndexCount:0,sortReverse:!0===l.sortReverse},a.push(h)),(null===(n=l.domain)||void 0===n?void 0:n.length)>0)if("ordinal"===l.type){l._domainCache={},s[e]=l;const t={};l.domain.forEach(((e,i)=>{t[e]=i,l._domainCache[e]=i})),h&&(h.sortIndex=t,h.sortIndexCount=l.domain.length)}else l.domain.length>=2&&(s[e]=l)}return Object.keys(s).length>0&&(t=t.filter((t=>{for(const e in s){const i=s[e];if("ordinal"===i.type){if(!(t[e]in i._domainCache))return!1}else if(i.domain[0]>t[e]||i.domain[1]<t[e])return!1}return!0}))),a.sort(((t,e)=>t.index-e.index)),t.sort(((t,e)=>function(t,e,i){for(let n=0;n<i.length;n++){const r=i[n];let o=0;if("ordinal"===r.type?(void 0===r.sortIndex[t[r.key]]&&(r.sortIndex[t[r.key]]=r.sortIndexCount++),void 0===r.sortIndex[e[r.key]]&&(r.sortIndex[e[r.key]]=r.sortIndexCount++),o=r.sortIndex[t[r.key]]-r.sortIndex[e[r.key]]):"linear"===r.type&&(o=t[r.key]-e[r.key]),r.sortReverse&&(o=-o),0!==o)return o}return 0}(t,e,a))),t};var tM={
|
|
16
16
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
17
|
-
read:function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1<<a)-1,h=l>>1,c=-7,d=i?r-1:0,u=i?-1:1,p=t[e+d];for(d+=u,o=p&(1<<-c)-1,p>>=-c,c+=a;c>0;o=256*o+t[e+d],d+=u,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+t[e+d],d+=u,c-=8);if(0===o)o=1-h;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=h}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,i,n,r,o){var s,a,l,h=8*o-r-1,c=(1<<h)-1,d=c>>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+d>=1?u/l:u*Math.pow(2,1-d))*l>=2&&(s++,l/=2),s+d>=c?(a=0,s=c):s+d>=1?(a=(e*l-1)*Math.pow(2,r),s+=d):(a=e*Math.pow(2,d-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s<<r|a,h+=r;h>0;t[i+p]=255&s,p+=f,s/=256,h-=8);t[i+p-f]|=128*g}},eM=tM;function iM(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}iM.Varint=0,iM.Fixed64=1,iM.Bytes=2,iM.Fixed32=5;var nM=4294967296,rM=1/nM,oM="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function sM(t){return t.type===iM.Bytes?t.readVarint()+t.pos:t.pos+1}function aM(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function lM(t,e,i){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(n);for(var r=i.pos-1;r>=t;r--)i.buf[r+n]=i.buf[r]}function hM(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function cM(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function dM(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function uM(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function pM(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function fM(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function gM(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function yM(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function mM(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function bM(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function vM(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function wM(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}iM.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){var n=this.readVarint(),r=n>>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=bM(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=wM(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=bM(this.buf,this.pos)+bM(this.buf,this.pos+4)*nM;return this.pos+=8,t},readSFixed64:function(){var t=bM(this.buf,this.pos)+wM(this.buf,this.pos+4)*nM;return this.pos+=8,t},readFloat:function(){var t=eM.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=eM.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i<128?e:(e|=(127&(i=n[this.pos++]))<<7,i<128?e:(e|=(127&(i=n[this.pos++]))<<14,i<128?e:(e|=(127&(i=n[this.pos++]))<<21,i<128?e:function(t,e,i){var n,r,o=i.buf;if(r=o[i.pos++],n=(112&r)>>4,r<128)return aM(t,n,e);if(r=o[i.pos++],n|=(127&r)<<3,r<128)return aM(t,n,e);if(r=o[i.pos++],n|=(127&r)<<10,r<128)return aM(t,n,e);if(r=o[i.pos++],n|=(127&r)<<17,r<128)return aM(t,n,e);if(r=o[i.pos++],n|=(127&r)<<24,r<128)return aM(t,n,e);if(r=o[i.pos++],n|=(1&r)<<31,r<128)return aM(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&oM?function(t,e,i){return oM.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){var n="",r=e;for(;r<i;){var o,s,a,l=t[r],h=null,c=l>239?4:l>223?3:l>191?2:1;if(r+c>i)break;1===c?l<128&&(h=l):2===c?128==(192&(o=t[r+1]))&&(h=(31&l)<<6|63&o)<=127&&(h=null):3===c?(o=t[r+1],s=t[r+2],128==(192&o)&&128==(192&s)&&((h=(15&l)<<12|(63&o)<<6|63&s)<=2047||h>=55296&&h<=57343)&&(h=null)):4===c&&(o=t[r+1],s=t[r+2],a=t[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&((h=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||h>=1114112)&&(h=null)),null===h?(h=65533,c=1):h>65535&&(h-=65536,n+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),n+=String.fromCharCode(h),r+=c}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==iM.Bytes)return t.push(this.readVarint(e));var i=sM(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==iM.Bytes)return t.push(this.readSVarint());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==iM.Bytes)return t.push(this.readBoolean());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==iM.Bytes)return t.push(this.readFloat());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==iM.Bytes)return t.push(this.readDouble());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==iM.Bytes)return t.push(this.readFixed32());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==iM.Bytes)return t.push(this.readSFixed32());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==iM.Bytes)return t.push(this.readFixed64());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==iM.Bytes)return t.push(this.readSFixed64());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===iM.Varint)for(;this.buf[this.pos++]>127;);else if(e===iM.Bytes)this.pos=this.readVarint()+this.pos;else if(e===iM.Fixed32)this.pos+=4;else{if(e!==iM.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),vM(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),vM(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),vM(this.buf,-1&t,this.pos),vM(this.buf,Math.floor(t*rM),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),vM(this.buf,-1&t,this.pos),vM(this.buf,Math.floor(t*rM),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var i,n;t>=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0));if(t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos]=127&t}(i,0,e),function(t,e){var i=(7&t)<<4;if(e.buf[e.pos++]|=i|((t>>>=3)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;e.buf[e.pos++]=127&t}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var n,r,o=0;o<e.length;o++){if((n=e.charCodeAt(o))>55295&&n<57344){if(!r){n>56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n<56320){t[i++]=239,t[i++]=191,t[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(t[i++]=239,t[i++]=191,t[i++]=189,r=null);n<128?t[i++]=n:(n<2048?t[i++]=n>>6|192:(n<65536?t[i++]=n>>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&lM(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),eM.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),eM.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var n=this.pos-i;n>=128&&lM(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,iM.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,hM,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,cM,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,pM,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,dM,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,uM,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,fM,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,gM,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,yM,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,mM,e)},writeBytesField:function(t,e){this.writeTag(t,iM.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,iM.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,iM.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,iM.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,iM.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,iM.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,iM.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,iM.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,iM.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,iM.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},function(t,e){let i,n,r=3,o=4.5;function s(t){return t&&("function"==typeof o&&n.pointRadius(+o.apply(this,arguments)),TA(t,i(n))),n.result()}s.area=function(t){return TA(t,i(pT)),pT.result()},s.measure=function(t){return TA(t,i(tB)),tB.result()},s.bounds=function(t){return TA(t,i(_T)),_T.result()},s.centroid=function(t){return TA(t,i(GT)),GT.result()},s.projection=function(e){return arguments.length?(i=null==e?(t=null,oT):(t=e).stream,s):t},s.context=function(t){return arguments.length?(n=null==t?(e=null,new oB(r)):new KT(e=t),"function"!=typeof o&&n.pointRadius(o),s):e},s.pointRadius=function(t){return arguments.length?(o="function"==typeof t?t:(n.pointRadius(+t),+t),s):o},s.digits=function(t){if(!arguments.length)return r;if(null==t)r=null;else{const e=Math.floor(t);if(!(e>=0))throw new RangeError(`invalid digits: ${t}`);r=e}return null===e&&(n=new oB(r)),s},s.projection(t).digits(r).context(e)}();let CM=0;function xM(){return CM>1e8&&(CM=0),(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"dataset")+"_"+CM++}class _M{constructor(t){let e;this.options=t,this.isDataSet=!0,this.transformMap={},this.parserMap={},this.dataViewMap={},this.target=new Rt,this._callMap=new Map,e=(null==t?void 0:t.name)?t.name:xM("dataset"),this.name=e}getDataView(t){return this.dataViewMap[t]}setDataView(t,e){if(this.dataViewMap[t])throw new Error(`Error: dataView ${t} 之前已存在,请重新命名`);this.dataViewMap[t]=e}removeDataView(t){this.dataViewMap[t]=null,delete this.dataViewMap[t]}registerParser(t,e){this.parserMap[t]&&console.warn(`Warn: transform ${t} 之前已注册,执行覆盖逻辑`),this.parserMap[t]=e}removeParser(t){this.parserMap[t]=null,delete this.parserMap[t]}getParser(t){return this.parserMap[t]||this.parserMap.default}registerTransform(t,e){this.transformMap[t]&&console.warn(`Warn: transform ${t} 之前已注册,执行覆盖逻辑`),this.transformMap[t]=e}removeTransform(t){this.transformMap[t]=null,delete this.transformMap[t]}getTransform(t){return this.transformMap[t]}multipleDataViewAddListener(t,e,i){let n=this._callMap.get(i);n||(n=()=>{t.some((t=>t.isRunning))||i()}),t.forEach((t=>{t.target.addListener(e,n)})),this._callMap.set(i,n)}multipleDataViewRemoveListener(t,e,i){const n=this._callMap.get(i);n&&t.forEach((t=>{t.target.removeListener(e,n)})),this._callMap.delete(i)}destroy(){this.transformMap=null,this.parserMap=null,this.dataViewMap=null,this._callMap=null,this.target.removeAllListeners()}}const SM="_data-view-diff-rank";class AM{constructor(t,e){var i=this;let n;this.dataSet=t,this.options=e,this.isDataView=!0,this.target=new Rt,this.parseOption=null,this.transformsArr=[],this.isRunning=!1,this.rawData={},this.history=!1,this.historyData=[],this.parserData={},this.latestData={},this._fields=null,this._diffData=!1,this._diffKeys=null,this._diffMap=new Map,this._diffRank=0,this.reRunAllTransform=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{pushHistory:!0,emitMessage:!0};return i.isRunning=!0,i.resetTransformData(),i.transformsArr.forEach((e=>{i.executeTransform(e,Object.assign(Object.assign({},t),{emitMessage:!1})),i.isLastTransform(e)&&i.diffLastData()})),i.isRunning=!1,!1!==(null==t?void 0:t.emitMessage)&&i.target.emit("change",[]),i},this.markRunning=()=>{this.isRunning=!0,this.target.emit("markRunning",[])},n=(null==e?void 0:e.name)?e.name:xM("dataview"),this.name=n,(null==e?void 0:e.history)&&(this.history=e.history),this.dataSet.setDataView(n,this),(null==e?void 0:e.fields)&&(this.dataSet.registerTransform("fields",QB),this.transform({type:"fields",options:{fields:e.fields}},!1))}parse(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.isRunning=!0,i&&this.target.emit("beforeParse",[]);const n=this.cloneParseData(t,e);if(e){this.parseOption=e,e=jr(e);const t=this.dataSet.getParser(e.type||"bytejson")(n,e.options,this);this.rawData=n,this.parserData=t,this.history&&this.historyData.push(n,t),this.latestData=t}else this.parserData=n,this.rawData=n,this.history&&this.historyData.push(n),this.latestData=n;return this.isRunning=!1,i&&this.target.emit("afterParse",[]),this}transform(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.isRunning=!0,t&&t.type){if("fields"===t.type){this._fields=t.options.fields;const e=this.transformsArr.findIndex((e=>e.type===t.type));e>=0&&this.transformsArr.splice(e,1)}if(this.transformsArr.push(t),e){const e=this.isLastTransform(t);t=jr(t),this.executeTransform(t),e&&this.diffLastData()}}return this.sortTransform(),this.isRunning=!1,this}isLastTransform(t){return this.transformsArr[this.transformsArr.length-1]===t}sortTransform(){this.transformsArr.sort(((t,e)=>{var i,n;return(null!==(i=t.level)&&void 0!==i?i:0)-(null!==(n=e.level)&&void 0!==n?n:0)}))}executeTransform(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{pushHistory:!0,emitMessage:!0};const{pushHistory:i,emitMessage:n}=e,r=this.dataSet.getTransform(t.type)(this.latestData,t.options);this.history&&!1!==i&&this.historyData.push(r),this.latestData=r,!1!==n&&this.target.emit("change",[])}resetTransformData(){this.latestData=this.parserData,this.history&&(this.historyData.length=0,this.historyData.push(this.rawData,this.parserData))}enableDiff(t){this._diffData=!0,this._diffKeys=t}disableDiff(){this._diffData=!1,this.resetDiff()}resetDiff(){this._diffMap=new Map,this._diffRank=0}diffLastData(){var t;if(!this._diffData)return;if(!this.latestData.forEach)return;if(!(null===(t=this._diffKeys)||void 0===t?void 0:t.length))return;const e=this._diffRank+1;if(0===this._diffRank)this.latestData.forEach((t=>{t[SM]=e,this._diffMap.set(this._diffKeys.reduce(((e,i)=>e+t[i]),""),t)})),this.latestDataAUD={add:Array.from(this.latestData),del:[],update:[]};else{let t;this.latestDataAUD={add:[],del:[],update:[]},this.latestData.forEach((i=>{i[SM]=e,t=this._diffKeys.reduce(((t,e)=>t+i[e]),""),this._diffMap.get(t)?this.latestDataAUD.update.push(i):this.latestDataAUD.add.push(i),this._diffMap.set(t,i)})),this._diffMap.forEach(((t,i)=>{t[SM]<e&&(this.latestDataAUD.del.push(t),this._diffMap.delete(i))}))}this._diffRank=e}cloneParseData(t,e){let i=!0;return(t instanceof AM||!1===(null==e?void 0:e.clone))&&(i=!1),i?t:jr(t)}parseNewData(t,e){this.parse(t,e||this.parseOption),this.reRunAllTransform()}updateRawData(t,e){const i=this.cloneParseData(t,e);this.rawData=i,this.parserData=i,this.latestData=i,this.reRunAllTransform()}getFields(){var t;return this._fields?this._fields:"dataview"===(null===(t=this.parseOption)||void 0===t?void 0:t.type)&&1===this.rawData.length&&this.rawData[0].getFields?this.rawData[0].getFields():null}destroy(){this.dataSet.removeDataView(this.name),this.resetDiff(),this.latestData=null,this.rawData=null,this.parserData=null,this.transformsArr=null,this.target=null}}const TM=(t,e,i)=>new Me({defaultFontParams:{fontFamily:"PingFang SC,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol",fontSize:14},getTextBounds:i?void 0:vu,specialCharSet:"-/: .,@%'\"~"+Me.ALPHABET_CHAR_SET+Me.ALPHABET_CHAR_SET.toUpperCase(),...e??{}},t),BM=(t,e)=>{const i=t.map(((t,i)=>({index:i,value:t,label:e.labelFormatter?e.labelFormatter(t):`${t}`})));return i},MM=(t,e,i=0)=>{const n=new fe(t).expand(i/2),r=new fe(e).expand(i/2);return n.intersects(r)},RM=(t,e)=>{let i=0;t.x2<e.x1?i=e.x1-t.x2:e.x2<t.x1&&(i=t.x1-e.x2);let n=0;return t.y2<e.y1?n=e.y1-t.y2:e.y2<t.y1&&(n=t.y1-e.y2),[i,n]};function PM(t,e,i){return i>Math.max(e.x1-t.x2,t.x1-e.x2,e.y1-t.y2,t.y1-e.y2)}function EM(t,e){for(let i,n=1,r=t.length,o=t[0];n<r;o=i,++n)if(i=t[n],PM(o.AABBBounds,i.AABBBounds,e))return!0;return!1}const HM=(t,e,i)=>{const{labelStyle:n,axisOrientType:r,labelFlush:o,labelFormatter:s,startAngle:a=0}=i,l=n.angle??0,h=["bottom","top"].includes(r),c=["left","right"].includes(r);let d=a;h?d=0:c&&(d=(t=>zt(t)?ge(t):null)(-90));const u=TM(n),p=e.map(((i,r)=>{const a=s?s(i):`${i}`,{width:p,height:f}=u.quickMeasure(a),g=Math.max(p,12),y=Math.max(f,12),m=t.scale(i);let b,v,w=Math.cos(d)*m,C=-Math.sin(d)*m;b=o&&h&&0===r?"left":o&&h&&r===e.length-1?"right":n.textAlign??"center","right"===b?w-=g:"center"===b&&(w-=g/2),v=o&&c&&0===r?"top":o&&c&&r===e.length-1?"bottom":n.textBaseline??"middle","bottom"===v?C-=y:"middle"===v&&(C-=y/2);return(new fe).set(w,C,w+g,C+y).rotate(l,w+g/2,C+y/2)}));return p},kM=(t,e,i)=>{const{labelStyle:n,getRadius:r,axisSpec:o,labelFormatter:s}=i,a=r?.(),l=n.angle??0,h=LM(o),c=TM(n),d=e.map((e=>{const i=s?s(e):`${e}`,{width:n,height:r}=c.quickMeasure(i),o=Math.max(n,12),d=Math.max(r,12),u=t.scale(e);let p=0,f=0;const g=function(t){let e="center",i="middle";t=function(t){for(;t<0;)t+=2*Math.PI;for(;t>=2*Math.PI;)t-=2*Math.PI;return t}(t),e=t>=Math.PI*(5/3)||t<=Math.PI*(1/3)?"left":t>=Math.PI*(2/3)&&t<=Math.PI*(4/3)?"right":"center";i=t>=Math.PI*(7/6)&&t<=Math.PI*(11/6)?"bottom":t>=Math.PI*(1/6)&&t<=Math.PI*(5/6)?"top":"middle";return{align:e,baseline:i}}(u),{x:y,y:m}=function(t,e,i){return{x:t.x+e*Math.cos(i),y:t.y+e*Math.sin(i)}}({x:0,y:0},a+h,u);p=y+("right"===g.align?-o:"center"===g.align?-o/2:0),f=m+("bottom"===g.baseline?-d:"middle"===g.baseline?-d/2:0);return(new fe).set(p,f,p+o,f+d).rotate(l,p+o/2,f+d/2)}));return d};function LM(t){let e=0;return Vt(t,"tick.visible")&&(e+=Vt(t,"tick.tickSize")),Vt(t,"label.visible")&&(e+=Vt(t,"label.space")),e}const IM={parity:function(t){return t.filter(((t,e)=>e%2==0))},greedy:function(t,e){let i;return t.filter(((t,n)=>(!n||!PM(i.AABBBounds,t.AABBBounds,e))&&(i=t,!0)))}},OM=(t,e,i,n,r,o)=>{let s=o,a=0,l=0,h=0,c=-1,d=Number.MAX_VALUE;do{let o=!0;s++;let u=0;do{u+s<t.length&&MM(e[u],e[u+s],i)&&(o=!1),u+=s}while(o&&u<t.length);if(o){if(!n){h=s;break}{const n=t.length-1;a=0;do{if(u-=s,u!==n&&!MM(e[u],e[n],i))break;a++}while(u>0);if(u===n){h=s,l=a;break}{const i=Math.floor(t.length/s)-a+1;if(i<c)break;{c=i;const t=r?0:1,o=RM(e[u],e[n])[t],p=u-s>=0?RM(e[u-s],e[u])[t]:o,f=Math.abs(o-p);f<d&&(d=f,h=s,l=a)}}}}}while(s<=t.length);return{step:h,delCount:l}},DM=(t,e,i,n)=>{let r=n;do{let n=!0;r++;let o=0;do{o+r<t.length&&MM(e[o],e[o+r],i)&&(n=!1),o+=r}while(n&&o<t.length);if(n)break}while(r<=t.length);let o=0;if(t.length>2){let i=t.length-t.length%r;for(i>=t.length&&(i-=r);i>0&&MM(e[0],e[i]);)o++,i-=r}return{step:r,delCount:o}},FM=(t,e)=>{if(GC(t.type))return((t,e)=>{if(!GC(t.type))return BM(t.domain(),e);const{tickCount:i,forceTickCount:n,tickStep:r}=e;let o;if(o=kt(r)?t.stepTicks(r):kt(n)?t.forceTicks(n):t.ticks(i??5),"cartesian"===e.coordinateType||"polar"===e.coordinateType&&"radius"===e.axisOrientType){const{labelGap:i=4,labelFlush:n}=e;let r=HM(t,o,e).map(((t,e)=>({AABBBounds:t,value:o[e]})));for(;r.length>=3&&EM(r,i);)r=IM.parity(r);const s=r.map((t=>t.value));s.length<3&&n&&(s.length>1&&s.pop(),ee(s)!==ee(o)&&s.push(ee(o))),o=s}return BM(o,e)})(t,e);if(function(t){switch(t){case NC.Ordinal:case NC.Point:case NC.Band:return!0;default:return!1}}(t.type)){if("cartesian"===e.coordinateType)return((t,e)=>{const{tickCount:i,forceTickCount:n,tickStep:r,labelGap:o=4,axisOrientType:s}=e,a=["bottom","top"].includes(s);let l;if(kt(r))l=t.stepTicks(r);else if(kt(n))l=t.forceTicks(n);else if(kt(i))l=t.ticks(i);else{const i=t.domain(),n=t.range(),r=HM(t,i,e),s=r.map((t=>a?t.width():t.height())),h=Math.min(...n),c=(Math.max(...n)-h)/i.length,d=OM(i,r,o,e.labelLastVisible,a,Math.floor(Math.min(...s)/c));l=t.stepTicks(d.step),e.labelLastVisible&&(l=l.slice(0,l.length-d.delCount),l.push(i[i.length-1]))}return BM(l,e)})(t,e);if("polar"===e.coordinateType&&"angle"===e.axisOrientType)return((t,e)=>{const{tickCount:i,forceTickCount:n,tickStep:r,getRadius:o,axisSpec:s,labelGap:a=0}=e,l=o?.();if(!l)return BM(t.domain(),e);let h;if(kt(r))h=t.stepTicks(r);else if(kt(n))h=t.forceTicks(n);else if(kt(i))h=t.ticks(i);else{const i=t.domain(),n=t.range(),r=LM(s),o=kM(t,i,e),c=Math.min(...n),d=Math.max(...n),u=Math.abs(d-c)*(l+r)/i.length,{step:p,delCount:f}=DM(i,o,a,Math.floor(o.reduce(((t,e)=>Math.min(t,e.width(),e.height())),Number.MAX_VALUE)/u));h=t.stepTicks(p),h=h.slice(0,h.length-f)}return BM(h,e)})(t,e)}return BM(t.domain(),e)},WM=Math.sqrt(50),zM=Math.sqrt(10),jM=Math.sqrt(2);class NM{_extend={};_scale;_scales;nice;zero;domain;expand;forceTickCount;tickCount;niceType;constructor(){this._scale=new lx,this._scales=[this._scale]}setExtraAttrFromSpec(t,e,i,n){this.nice=t,this.zero=e,this.domain=i,this.expand=n}transformScaleDomain(){this.setScaleNice()}setScaleNice(){let t=this.forceTickCount??this.tickCount??10;"accurateFirst"===this.niceType&&(t=Math.max(10,t)),Ht(this.domain?.min)&&Ht(this.domain?.max)?this.nice&&this._scale.nice(t):kt(this.domain?.min)&&Ht(this.domain?.max)?this.nice&&this._scale.niceMax(t):Ht(this.domain?.min)&&kt(this.domain?.max)&&this.nice&&this._scale.niceMin(t)}dataToPosition(t){return this.valueToPosition(t[0])}valueToPosition(t){return this._scale.scale(t)}computeLinearDomain(t){const e=[];return t.forEach((t=>{const{min:i,max:n}=t;e[0]=void 0===e[0]?i:Math.min(e[0],i),e[1]=void 0===e[1]?n:Math.max(e[1],n)})),this.expandDomain(e),this.includeZero(e),this.setDomainMinMax(e),e}expandDomain(t){if(!this.expand)return;const e=t[0],i=t[t.length-1];kt(this.expand.min)&&(t[0]=e-(i-e)*this.expand.min),kt(this.expand.max)&&(t[t.length-1]=i+(i-e)*this.expand.max)}niceDomain(t){if(Math.abs(function(t){if(t&&Ot(t))return t.reduce(((t,e)=>Math.min(t,e)),1/0)}(t)-function(t){if(t&&Ot(t))return t.reduce(((t,e)=>Math.max(t,e)),-1/0)}(t))<=1e-12){let e=t[0];const i=e>=0?1:-1;if(e=Math.abs(e),e<1)t[0]=0,t[1]=1;else{let i=e/5;const n=Math.floor(Math.log(i)/Math.LN10),r=i/Math.pow(10,n);i=(r>=WM?10:r>=zM?5:r>=jM?2:1)*Math.pow(10,n),t[0]=0,t[1]=10*i}i<0&&(t.reverse(),t[0]*=-1,t[1]*=-1)}return t}niceMinMax(){if(this.nice){let t=this.forceTickCount??this.tickCount??10;"accurateFirst"===this.niceType&&(t=Math.max(10,t)),Ht(this.domain?.min)&&Ht(this.domain?.max)?this._scale.nice(t):kt(this.domain?.min)&&Ht(this.domain?.max)?this._scale.niceMax(t):Ht(this.domain?.min)&&kt(this.domain?.max)&&this._scale.niceMin(t)}}includeZero(t){this.zero&&(t[0]=Math.min(t[0],0),t[t.length-1]=Math.max(t[t.length-1],0))}setExtendDomain(t,e){if(void 0===e)return void delete this._extend[t];this._extend[t]=e;const i=this._scale.domain();this.extendDomain(i),this.includeZero(i),this.setDomainMinMax(i),this.niceDomain(i),this._scale.domain(i,this.nice),this.niceMinMax()}extendDomain(t){let e;const i=t.length-1,n=t[0]-t[i]>0,r=n?i:0,o=n?0:i;for(const i in this._extend)e=this._extend[i],e>t[o]&&(t[o]=e),e<t[r]&&(t[r]=e)}setDomainMinMax(t){if(!this.domain)return;const{min:e,max:i}=this.domain;kt(e)&&(t[0]=e),kt(i)&&(t[1]=i)}setZero(t){this.zero!==t&&(this.zero=t,this.updateScaleDomain())}updateScaleDomain(){const t=this.computeDomain([this.domain]);this.updateScaleDomainByModel(t)}computeDomain(t){return this.computeLinearDomain(t)}updateScaleDomainByModel(t){t=t??this._scale.domain(),this.extendDomain(t),this.includeZero(t),this.setDomainMinMax(t),this.niceDomain(t),this._scale.domain(t,this.nice),this.niceMinMax()}updateRange(t){const[e,i]=this._scale.range();t[0]===e&&t[1]===i||this._scale.range(t)}}function GM(t,e){const i=e.option;Ut(t)||i?.label?.flush&&function(t,e){const{width:i,height:n}=e.getLayoutRect(),r=ZS(e.orient),o=t[0],s=ee(t);if(r){const t=0,e=i,n=o.AABBBounds.x1,r=s.AABBBounds.x2;n<t&&o.setAttributes({x:t,textAlign:"left"}),r>e&&s.setAttributes({x:e,textAlign:"right"})}else{const t=n,e=0,i=o.AABBBounds.y2,r=s.AABBBounds.y1;i>t&&o.setAttributes({y:t,textBaseline:"bottom"}),r<e&&s.setAttributes({y:e,textBaseline:"top"})}}(t,e)}const KM=t=>t;class UM{width;height;table;option;orient;visible;type;inverse;data;tickData;scale;component;constructor(t,e,i,n){this.table=n,this.width=e,this.height=i,this.option=Zt({},t,qS),this.orient=t.orient??"left",this.visible=t.visible??!0,this.type=t.type??"band",this.inverse="inverse"in t&&!!t.inverse,"band"===t.type&&(this.data=t.data),this.initScale(),this.initData(),this.createComponent(),this.initEvent()}initScale(){const t=this.option;"band"===this.type?(this.scale=new JS,this.scale.bandPadding=t.bandPadding,this.scale.paddingInner=t.paddingInner,this.scale.paddingOuter=t.paddingOuter,this.scale.calcScales(.1,.3),this.scale.updateScaleDomain(this.data),this.updateScaleRange()):"linear"!==this.type&&"time"!==this.type||(this.scale=new NM,this.scale.setExtraAttrFromSpec(t.nice,t.zero,t.range,t.expand),this.scale.transformScaleDomain(),this.scale.updateScaleDomain(),this.updateScaleRange())}initData(){!function(t,e,i){t.getParser(e)||t.registerParser(e,i)}(this.table.dataSet,"scale",KM),function(t,e,i){t.getTransform(e)||t.registerTransform(e,i)}(this.table.dataSet,"ticks",FM);const t=this.option.label||{},e=this.option.tick||{},i=new AM(this.table.dataSet).parse(this.scale._scale,{type:"scale"}).transform({type:"ticks",options:{tickCount:e.tickCount,forceTickCount:e.forceTickCount,tickStep:e.tickStep,axisOrientType:this.orient,coordinateType:"cartesian",labelStyle:t.style,labelFormatter:t.formatMethod,labelLastVisible:t.lastVisible,labelFlush:t.flush}},!1);this.tickData=i,this.computeData()}computeData(){this.tickData.reRunAllTransform()}initEvent(){}createComponent(){const t=function(t){const e=t;let i,n=e.title?.angle??0;return"left"!==e.orient&&"right"!==e.orient||e.title?.autoRotate&&Ht(e.title.angle)&&(n="left"===e.orient?-90:90,i=$S[e.orient]),{select:e.select,hover:e.hover,line:(r=e.domainLine,US(r),US(r.startSymbol),US(r.endSymbol),r),label:{visible:e.label.visible,space:e.label.space,inside:e.label.inside,style:KS(e.label.style),formatMethod:e.label.formatMethod?(t,i,n)=>e.label.formatMethod(i.rawValue,i):null,state:VS(e.label.state)},tick:{visible:e.tick.visible,length:e.tick.tickSize,inside:e.tick.inside,alignWithLabel:e.tick.alignWithLabel,style:KS(e.tick.style),state:VS(e.tick.state)},subTick:{visible:e.subTick.visible,length:e.subTick.tickSize,inside:e.subTick.inside,count:e.subTick.tickCount,style:KS(e.subTick.style),state:VS(e.subTick.state)},grid:{type:"line",visible:e.grid.visible,alternateColor:e.grid.alternateColor,alignWithLabel:e.grid.alignWithLabel,style:KS(e.grid.style)},subGrid:{type:"line",visible:e.subGrid.visible,alternateColor:e.subGrid.alternateColor,style:KS(e.subGrid.style)},title:{visible:e.title.visible,position:e.title.position,space:e.title.space,autoRotate:!1,angle:n?ge(n):null,textStyle:Zt({},i,KS(e.title.style)),padding:e.title.padding,shape:{visible:e.title.shape?.visible,space:e.title.shape?.space,style:KS(e.title.shape?.style)},background:{visible:e.title.background?.visible,style:KS(e.title.background?.style)},state:{text:VS(e.title.state),shape:VS(e.title.shape?.state),background:VS(e.title.background?.state)}},panel:{visible:e.background?.visible,style:KS(e.background?.style),state:VS(e.background?.state)}};var r}(this.option),e=this.getUpdateAttribute();e.verticalFactor="top"===this.orient||"right"===this.orient?-1:1,this.component=new L_(Zt({},t,e)),this.component.setAttributes(this.setLayoutStartPosition({x:0,y:0}))}overlap(){!function(t,e){const i=t.find((t=>"axis-label-container-layer-0"===t.name),!0),n=t.find((t=>"axis-label-container-layer-1"===t.name),!0);GM(i?i.getChildren():[],e),GM(n?n.getChildren():[],e)}(this.component,this)}getLayoutRect(){return{width:this.width,height:this.height}}getUpdateAttribute(){const t=this.table.tableNoFrameHeight,e=this.table.tableNoFrameWidth,{width:i,height:n}=this.getLayoutRect(),r=ZS(this.orient),o="left"===(s=this.orient)||"right"===s;var s;let a={x:0,y:0},l=0,h=0;r?(a={x:i,y:0},l=t,h=i):o&&(a={x:0,y:n},l=e,h=n);return{start:{x:0,y:0},end:a,grid:{type:"line",length:l,visible:this.option.grid.visible},title:{text:this.option.title.text,maxWidth:this._getTitleLimit(r)},items:this.getLabelItems(h)}}getLabelItems(t){return[this.tickData.latestData.map((e=>({id:e.value,label:e.value,value:0===t?0:this.scale.dataToPosition([e.value])/t,rawValue:e.value}))).filter((t=>t.value>=0&&t.value<=1))]}updateScaleRange(){const{width:t,height:e}=this.getLayoutRect();let i=[0,0];ZS(this.orient)?zt(t)&&(i=[0,t]):zt(e)&&(i=[e,0]),this.scale.updateRange(i)}setLayoutStartPosition(t){let{x:e,y:i}=t;return zt(e)&&(e+=Number("left"===this.orient)*this.getLayoutRect().width),zt(i)&&(i+=Number("top"===this.orient)*this.getLayoutRect().height),{x:e,y:i}}_getTitleLimit(t){if(this.option.title.visible&&Ht(this.option.title.style?.maxLineWidth)){const e=this.option.title.style?.angle||0;if(t){const t=this.getLayoutRect().width,i=Math.abs(Math.cos(e));return i<1e-6?1/0:t/i}const i=this.getLayoutRect().height,n=Math.abs(Math.sin(e));return n<1e-6?1/0:i/n}return null}getScale(){return this.scale._scale}getDomainSpec(){return this.scale.domain}}function VM(t,e,i,n,r,o,s,a,l,h,c,d,u,p,f,g,y,m){let b;if("text"===t||"link"===t){if("link"===t){const o=i.getCellValue(n,r),s=i._getCellStyle(n,r);"link"===t&&("templateLink"in e&&e.templateLink||!("linkDetect"in e)||!e.linkDetect||De.test(o))&&(m?(m.text.fill=OC("linkColor",s,n,r,i),m.group.cursor="pointer"):m={text:{fill:OC("linkColor",s,n,r,i)},group:{cursor:"pointer"}})}if(s){const t=i.getCellOriginValue(n,r),e=s(i,t);e&&(m?m.group.fill=e:m={group:{fill:e}})}let v,w,C,x=!0;if("body"!==i.getCellType(n,r)?(w=e?.headerCustomRender,C=e?.headerCustomLayout):(w=e?.customRender||i.customRender,C=e?.customLayout),C||w){const t=Sx(C,w,n,r,i.getColWidth(n),i.getRowHeight(r),!1,"autoHeight"===i.heightMode,i);v=t.elementsGroup,x=t.renderDefault}b=jS(i,h,0,c,n,r,o,a,l,d,u,p,f,v,x,m),g&&(b.mergeCol=y.end.col,b.mergeRow=y.end.row);const _=i.internalProps.layoutMap.getAxisConfigInPivotChart(n,r);if(_){const t=new UM(_,b.attribute.width,b.attribute.height,i);b.clear(),b.appendChild(t.component),t.overlap()}else i.internalProps.layoutMap.isEmpty(n,r)&&b.clear()}else if("image"===t)b=function(t,e,i,n,r,o,s,a,l,h,c,d,u,p){const f=DC("padding",u._getCellStyle(n,r),n,r,u);A(f)&&(h=f),p?.text?.textAlign&&(c=p?.text?.textAlign),p?.text?.textBaseline&&(d=p?.text?.textBaseline);const g=new xw({x:e,y:i,width:o,height:s,lineWidth:p?.group?.lineWidth??void 0,fill:p?.group?.fill??void 0,stroke:p?.group?.stroke??void 0,strokeArrayWidth:p?.group?.strokeArrayWidth??void 0,strokeArrayColor:p?.group?.strokeArrayColor??void 0,cursor:p?.group?.cursor??void 0,lineCap:"square",clip:!0});g.role="cell",g.col=n,g.row=r,t.addChild(g);const y=u.getCellValue(n,r),m=gu({x:h[3],y:h[0],width:o-h[1]-h[3],height:s-h[0]-h[2],image:y??FC.damage_pic.svg,cursor:"pointer"});return m.name="image",m.keepAspectRatio=a,m.successCallback=a||l?()=>{const t=m.resources.get(m.attribute.image).data;if(l&&WC(n,r,t.width,t.height,u.scenegraph,h),a){const{width:e,height:i}=LC(t.width,t.height,g.attribute.width-h[1]-h[3],g.attribute.height-h[0]-h[2]),n=IC(0,0,g.attribute.width,g.attribute.height,e,i,c,d,h);m.setAttributes({x:n.x,y:n.y,width:e,height:i})}u.scenegraph.updateNextFrame()}:()=>{zC(g,n,r,u)},m.failCallback=()=>{const t=kC();m.image=t.damage_pic.svg},g.appendChild(m),g}(h,0,c,n,r,i.getColWidth(n),i.getRowHeight(r),e.keepAspectRatio,e.imageAutoSizing,d,u,p,i,m);else if("video"===t)b=function(t,e,i,n,r,o,s,a,l,h,c,d,u,p){const f=DC("padding",u._getCellStyle(n,r),n,r,u);A(f)&&(h=f),p?.text?.textAlign&&(c=p?.text?.textAlign),p?.text?.textBaseline&&(d=p?.text?.textBaseline);const g=new xw({x:e,y:i,width:o,height:s,lineWidth:p?.group?.lineWidth??void 0,fill:p?.group?.fill??void 0,stroke:p?.group?.stroke??void 0,strokeArrayWidth:p?.group?.strokeArrayWidth??void 0,strokeArrayColor:p?.group?.strokeArrayColor??void 0,cursor:p?.group?.cursor??void 0,lineCap:"square",clip:!0});g.role="cell",g.col=n,g.row=r,t.addChild(g);const y=u.getCellValue(n,r),m=document.createElement("video");m.addEventListener("loadeddata",(()=>{l&&WC(n,r,m.videoWidth,m.videoHeight,u.scenegraph,h);const t=g.attribute.width,e=g.attribute.height;if(a){const{width:i,height:n}=LC(m.videoWidth,m.videoHeight,t-h[1]-h[3],e-h[0]-h[2]),r=IC(0,0,t,e,i,n,c,d,h);b.setAttributes({width:i,height:n,x:r.x,y:r.y})}else b.setAttributes({x:h[3],y:h[0],width:t-h[1]-h[3],height:e-h[2]-h[0]});const i=Math.floor(Math.min(t-h[1]-h[3],e-h[2]-h[0])/2),o=0+(t>b.attribute.width?b.attribute.x-0+b.attribute.width/2:t/2),s=0+(e>b.attribute.height?b.attribute.y-0+b.attribute.height/2:e/2),p=new px({x:o-i/2,y:s-i/2,width:i,height:i,image:NS.play.svg,cursor:NS.play.cursor});p.name="play-icon",g.appendChild(p),u.scenegraph.updateNextFrame()})),m.onerror=()=>{b.image=NS.damage_pic.svg},m.src=y,m.setAttribute("preload","auto");const b=gu({x:h[3],y:h[0],width:o-h[1]-h[3],height:s-h[2]-h[0],image:m,cursor:"pointer"});return b.name="image",g.appendChild(b),g}(h,0,c,n,r,i.getColWidth(n),i.getRowHeight(r),e.keepAspectRatio,e.imageAutoSizing,d,u,p,i,m);else if("chart"===t){const t=i.internalProps.layoutMap.getChartInstance(n,r);b=zS(null,h,0,c,n,r,i.getColWidth(n),i.getRowHeight(r),d,i.getCellValue(n,r),e.chartType,i.isPivotChart()?i.internalProps.layoutMap.getChartSpec(n,r):e.chartSpec,t,i,m)}else if("progressbar"===t){const t=i._getCellStyle(n,r),s=i.getCellValue(n,r),f=i.getCellOriginValue(n,r);b=jS(i,h,0,c,n,r,o,a,l,d,u,p,!1,null,!0,m);const g=jC(e,t,o,s,f,n,r,0,i);b.insertBefore(g,b.firstChild)}else"sparkline"===t&&(b=dx(null,h,0,c,n,r,a,l,d,i,m));return b}function $M(t,e,i,n){const r=i.scenegraph.highPerformanceGetCell(t,e,!0),o=i.isHeader(t,e)?i._getHeaderLayoutMap(t,e).headerType:i.getBodyColumnType(t,e),s=i.getCellType(t,e),a="body"!==s?i.getHeaderDefine(t,e):i.getBodyColumnDefine(t,e);let l,h,c;if(("body"!==s||a?.mergeCell)&&(h=i.getCellRange(t,e),l=h.start.col!==h.end.col||h.start.row!==h.end.row),!l||t===h.start.col&&e===h.start.row){const d="body"!==s||(!!a?.icon||!!a?.tree),u=RC(i._getCellStyle(t,e),i,t,e,OC).theme,p=u._vtable.padding,f=u._vtable.textAlign,g=u._vtable.textBaseline;let y,m,b;i.internalProps?.dataConfig?.mappingRules&&"body"===s&&i.internalProps?.dataConfig?.mappingRules?.forEach(((t,e)=>{t.bgColor&&(y=t.bgColor.mapping)})),"body"!==s?(a?.headerCustomRender,a?.headerCustomLayout):(a?.customRender||i.customRender,a?.customLayout),h?(m=i.getColsWidth(h.start.col,h.end.col),b=i.getRowsHeight(h.start.row,h.end.row)):(m=i.getColWidth(t),b=i.getRowHeight(e));const v=i.getCellValue(t,e);st(v)?(r.removeAllChild(),GS(v,i,XM.bind(null,o,a,i,t,e,y,m,b,r,p,f,g,d,l,h,n,u))):c=XM(o,a,i,t,e,y,m,b,r,p,f,g,d,l,h,n,u)}else c=new xw({x:0,y:n?0:r.attribute.y,width:0,height:0,visible:!1,pickable:!1}),c.role="shadow-cell",c.col=t,c.row=e,c.mergeCol=h.start.col,c.mergeRow=h.start.row,n||(r.parent.insertAfter(c,r),r.parent.removeChild(r));return c}function XM(t,e,i,n,r,o,s,a,l,h,c,d,u,p,f,g,y){const m=VM(t,e,i,n,r,i.getColWidth(n),o,s,a,g?i.scenegraph.getColGroup(n):l.parent,g?0:l.attribute.y,h,c,d,u,p,f,y);return g||(l.parent.insertAfter(m,l),l.parent.removeChild(l),i.scenegraph?.proxy.cellCache.get(n)&&i.scenegraph?.proxy.cellCache.set(n,m)),m}function YM(t,e,i,n,r,o,s,a,l,h){let c,d,u,p,f=0;a.internalProps?.dataConfig?.mappingRules&&"body"===l&&a.internalProps?.dataConfig?.mappingRules?.forEach(((t,e)=>{t.bgColor&&(p=t.bgColor.mapping)}));let g=0;t.colHeight&&(g=t.colHeight);for(let y=n;y<=r;y++){const n=y,r="body"!==l?a.getHeaderDefine(e,n):a.getBodyColumnDefine(e,n),m="body"!==l||(!!r?.icon||!!r?.tree),b=RC(a._getCellStyle(e,n),a,e,n,OC).theme;b.group.width=i,b.group.height=Array.isArray(s)?s[n]:s,b._vtable.padding&&(c=b._vtable.padding),b.text.textAlign&&(d=b.text.textAlign),b.text.textBaseline&&(u=b.text.textBaseline);let v=i,w=a.getRowHeight(n);const C=(a.isHeader(e,n)?a._getHeaderLayoutMap(e,n).headerType:a.getBodyColumnType(e,n))||"text";let x,_,S;if(("body"!==l||r?.mergeCell)&&(_=a.getCellRange(e,n),S=_.start.col!==_.end.col||_.start.row!==_.end.row,S&&(v=0,w=0,x=o.get(`${_.start.col},${_.start.row};${_.end.col},${_.end.row}`),!x))){for(let t=_.start.col;t<=_.end.col;t++)v+=a.getColWidth(t);for(let t=_.start.row;t<=_.end.row;t++)w+=a.getRowHeight(t);o.set(`${_.start.col},${_.start.row};${_.end.col},${_.end.row}`,{x:0,y:g,cellWidth:v,cellHeight:w})}if(x){const i=x.cellHeight/(_.end.row-_.start.row+1),r=new xw({x:0,y:g,width:0,height:i,visible:!1,pickable:!1});r.role="shadow-cell",r.col=e,r.row=n,r.mergeCol=_.start.col,r.mergeRow=_.start.row,t.addChild(r),t.updateColumnRowNumber(n),t.updateColumnHeight(i),_=a.getCellRange(e,n),g+=i,f=Math.max(f,x.cellWidth)}else{const o=a.getCellValue(e,n);if(st(o)){GS(o,a,VM.bind(null,C,r,a,e,n,i,p,v,w,t,g,c,d,u,m,S,_,b)),t.updateColumnRowNumber(n);const s=S?a.getRowHeight(n)/(_.end.row-_.start.row+1):a.getRowHeight(n);t.updateColumnHeight(s),g+=s}else{const o=VM(C,r,a,e,n,i,p,v,w,t,g,c,d,u,m,S,_,b);t.updateColumnRowNumber(n);const s=S?o.attribute.height/(_.end.row-_.start.row+1):o.attribute.height;t.updateColumnHeight(s),g+=s}}if(h&&n>h)break}return t.setAttribute("width",i),{width:i,height:g}}function qM(t,e,i,n,r,o,s,a,l,h){if(n>r||o>s)return;const{layoutMap:c,defaultRowHeight:d,defaultHeaderRowHeight:u,defaultColWidth:p}=l.internalProps;let f=0,g=0;for(let c=n;c<=r;c++){const n=c,r=l.getColWidth(n),p=new xw({x:e+f,y:i,width:r,height:0,clip:!1,pickable:!1});p.role="column",p.col=c,t.addChild(p);const{width:y,height:m}=YM(p,n,r,o,s,l.scenegraph.mergeMap,"columnHeader"===a?u??d:d,l,a,h);f+=y,g=Math.max(g,m)}t.setAttribute("width",f),t.setAttribute("height",g)}async function ZM(t,e,i,n){"left"===e&&n.colEnd+t>n.bodyRightCol?t=n.bodyRightCol-n.colEnd:"right"===e&&n.colStart-t<n.bodyLeftCol&&(t=n.colStart-n.bodyLeftCol);const r=n.table.scenegraph.bodyGroup;if(t<n.colEnd-n.colStart){const o="left"===e?n.colStart:n.colEnd-t+1,s="left"===e?n.colStart+t-1:n.colEnd,a="left"===e?n.colEnd+1:n.colStart-t,l="left"===e?n.colEnd+t:n.colStart-1;AS(n.table,a,l);for(let t=o;t<=s;t++)if("left"===e){const t=r.firstChild;JM(t,r.lastChild.col+1,r.lastChild.attribute.x+r.lastChild.attribute.width),r.appendChild(t)}else{const t=r.lastChild;JM(t,r.firstChild.col-1,r.firstChild.attribute.x-n.table.getColWidth(r.firstChild.col-1)),r.insertBefore(t,r.firstChild)}const h=Math.max(n.bodyLeftCol,i-1*n.screenColCount),c=Math.min(n.bodyRightCol,i+2*n.screenColCount);for(let t=h;t<=c;t++){QM(n.table.scenegraph.getColGroup(t),n)}n.colStart="left"===e?n.colStart+t:n.colStart-t,n.colEnd="left"===e?n.colEnd+t:n.colEnd-t,n.currentCol="left"===e?n.currentCol+t:n.currentCol-t,n.totalCol="left"===e?n.totalCol+t:n.totalCol-t,n.referenceCol=n.colStart+Math.floor((n.colEnd-n.colStart)/2),n.colUpdatePos=a,n.colUpdateDirection=e,n.table.scenegraph.stage.render(),await n.progress()}else{const o="left"===e?n.colStart+t:n.colStart-t,s="left"===e?n.colEnd+t:n.colEnd-t;AS(n.table,o,s);const a=n.table.getColsWidth(n.bodyLeftCol,o-1);console.log("distStartColY",n.bodyLeftCol,o-1,a),r.forEachChildren(((i,r)=>{"group"===i.type&&JM(i,"left"===e?i.col+t:i.col-t,0===r?a:i._prev.attribute.x+n.table.getColWidth(i._prev.col))}));const l=Math.max(n.bodyLeftCol,i-1*n.screenRowCount),h=Math.min(n.bodyRightCol,i+2*n.screenRowCount);for(let t=l;t<=h;t++){QM(n.table.scenegraph.getColGroup(t),n)}const c=n.table.scenegraph.getCell(i,0);c.AABBBounds.width(),console.log("leftCell",c.col,c.globalAABBBounds,c),n.colStart=o,n.colEnd=s,n.currentCol="left"===e?n.currentCol+t:n.currentCol-t,n.totalCol="left"===e?n.totalCol+t:n.totalCol-t,n.referenceCol=n.colStart+Math.floor((n.colEnd-n.colStart)/2),n.colUpdatePos=n.colStart,n.colUpdateDirection=s>n.bodyRightCol-(n.colEnd-n.colStart+1)?"right":"left",await n.progress()}}function JM(t,e,i){t.col=e,t.forEachChildren((t=>{t.col=e,t.needUpdate=!0})),t.setAttribute("x",i),t.needUpdate=!0}function QM(t,e){let i=t.firstChild;for(;i;){i=e.updateCellGroupContent(i)._next}t.needUpdate=!1}function tR(t,e,i,n,r,o="up"){if("up"===o)for(let o=t;o<=e;o++)for(let t=i;t<=n;t++){const e=r.scenegraph.getCell(o,t);if(!e.row)continue;let i;i=e._prev?(e._prev?.attribute.y??0)+(e._prev?.attribute.height??0):r.getRowsHeight(r.columnHeaderLevelCount,e.row-1),e.setAttribute("y",i)}else for(let o=t;o<=e;o++)for(let t=n;t>=i;t--){const e=r.scenegraph.getCell(o,t);if(!e.row)continue;let i;e._next?i=(e._next?.attribute.y??0)-(e.attribute.height??0):(i=r.getRowsHeight(r.columnHeaderLevelCount,e.row)-(e.attribute.height??0),console.log("估计位置",r.getRowsHeight(r.columnHeaderLevelCount,e.row))),e.setAttribute("y",i)}}async function eR(t,e,i,n){if("up"===e&&n.rowEnd+t>n.bodyBottomRow?t=n.bodyBottomRow-n.rowEnd:"down"===e&&n.rowStart-t<n.bodyTopRow&&(t=n.rowStart-n.bodyTopRow),t<n.rowEnd-n.rowStart){const r="up"===e?n.rowStart:n.rowEnd-t+1,o="up"===e?n.rowStart+t-1:n.rowEnd;for(let t=n.bodyLeftCol;t<=n.bodyRightCol;t++){const i=n.table.scenegraph.getColGroup(t);for(let t=r;t<=o;t++)if("up"===e){const t=i.firstChild;n.updateCellGroupPosition(t,i.lastChild.row+1,i.lastChild.attribute.y+i.lastChild.attribute.height),i.appendChild(t)}else{const t=i.lastChild;n.updateCellGroupPosition(t,i.firstChild.row-1,i.firstChild.attribute.y-t.attribute.height),i.insertBefore(t,i.firstChild)}}const s="up"===e?n.rowEnd+1:n.rowStart-t,a="up"===e?n.rowEnd+t:n.rowStart-1,l=Math.max(n.bodyTopRow,i-1*n.screenRowCount),h=Math.min(n.bodyBottomRow,i+2*n.screenRowCount);"autoHeight"===n.table.heightMode&&HS(n.table,l,h);for(let t=n.bodyLeftCol;t<=n.bodyRightCol;t++)for(let e=l;e<=h;e++){const i=n.highPerformanceGetCell(t,e,s,a);n.updateCellGroupContent(i)}"autoHeight"===n.table.heightMode&&tR(n.bodyLeftCol,n.bodyRightCol,l,h,n.table,e),n.rowStart="up"===e?n.rowStart+t:n.rowStart-t,n.rowEnd="up"===e?n.rowEnd+t:n.rowEnd-t,n.currentRow="up"===e?n.currentRow+t:n.currentRow-t,n.totalRow="up"===e?n.totalRow+t:n.totalRow-t,n.referenceRow=n.rowStart+Math.floor((n.rowEnd-n.rowStart)/2),n.rowUpdatePos=s,n.rowUpdateDirection=e,console.log("move end proxy",n.rowStart,n.rowEnd),console.log("move end cell",n.table.scenegraph.bodyGroup.firstChild.firstChild.row,n.table.scenegraph.bodyGroup.firstChild.lastChild.row),await n.progress()}else{const r="up"===e?n.rowStart+t:n.rowStart-t,o="up"===e?n.rowEnd+t:n.rowEnd-t,s=n.table.getRowsHeight(n.bodyTopRow,r-1);for(let i=n.bodyLeftCol;i<=n.bodyRightCol;i++){const r=n.table.scenegraph.getColGroup(i);r?.forEachChildren(((i,r)=>{n.updateCellGroupPosition(i,"up"===e?i.row+t:i.row-t,0===r?s:i._prev.attribute.y+i._prev.attribute.height)}))}let a,l;"autoHeight"===n.table.heightMode?(a=r,l=o):(a=Math.max(n.bodyTopRow,i-1*n.screenRowCount),l=Math.min(n.bodyBottomRow,i+2*n.screenRowCount)),console.log("更新同步范围",a,l),"autoHeight"===n.table.heightMode&&HS(n.table,a,l);for(let t=n.bodyLeftCol;t<=n.bodyRightCol;t++)for(let e=a;e<=l;e++){const i=n.highPerformanceGetCell(t,e,r,o);n.updateCellGroupContent(i)}console.log("updateAutoRow",o>n.bodyBottomRow-(n.rowEnd-n.rowStart+1)?"down":"up"),"autoHeight"===n.table.heightMode&&tR(n.bodyLeftCol,n.bodyRightCol,a,l,n.table,o>n.bodyBottomRow-(n.rowEnd-n.rowStart+1)?"down":"up"),n.rowStart=r,n.rowEnd=o,n.currentRow="up"===e?n.currentRow+t:n.currentRow-t,n.totalRow="up"===e?n.totalRow+t:n.totalRow-t,n.referenceRow=n.rowStart+Math.floor((n.rowEnd-n.rowStart)/2),n.rowUpdatePos=n.rowStart,n.rowUpdateDirection=o>n.bodyBottomRow-(n.rowEnd-n.rowStart+1)?"down":"up",console.log("move total end proxy",n.rowStart,n.rowEnd),console.log("move total end cell",n.table.scenegraph.bodyGroup.firstChild.firstChild.row,n.table.scenegraph.bodyGroup.firstChild.lastChild.row),"autoHeight"!==n.table.heightMode&&await n.progress()}}class iR{table;mode="column";rowLimit=1e3;currentRow=0;totalRow;yLimitTop;yLimitBottom;rowStart=0;rowEnd=0;referenceRow=0;bodyTopRow;bodyBottomRow;screenRowCount;firstScreenRowLimit;taskRowCount;rowUpdatePos;rowUpdateDirection;screenTopRow=0;colLimit=1e3;bodyLeftCol;bodyRightCol;totalCol;colStart;colEnd;taskColCount;xLimitLeft;xLimitRight;screenColCount;firstScreenColLimit;colUpdatePos;currentCol;referenceCol;screenLeftCol=0;colUpdateDirection;cellCache=new Map;constructor(t){this.table=t,this.table.internalProps.transpose?this.mode="row":this.table.isPivotTable()&&(this.mode="pivot"),this.table.options.maintainedDataCount&&(this.rowLimit=this.table.options.maintainedDataCount)}setParamsForColumn(){this.bodyLeftCol=this.table.rowHeaderLevelCount,this.bodyRightCol=this.table.colCount-1-this.table.rightFrozenColCount;const t=Math.min(this.colLimit,this.bodyRightCol-this.bodyLeftCol+1);this.totalCol=this.bodyLeftCol+t-1,this.colStart=this.bodyLeftCol;const e=this.table.defaultColWidth;this.taskColCount=1*Math.ceil(this.table.tableNoFrameWidth/e);const i=e*t,n=e*(this.bodyRightCol-this.bodyLeftCol+1);this.xLimitLeft=i/2,this.xLimitRight=n-i/2;const r=5*this.table.tableNoFrameWidth;this.screenColCount=Math.ceil(this.table.tableNoFrameWidth/e),this.firstScreenColLimit=this.bodyLeftCol+Math.ceil(r/e),this.colUpdatePos=this.bodyRightCol}setParamsForRow(){this.bodyTopRow=this.table.columnHeaderLevelCount,this.bodyBottomRow=this.table.rowCount-1-this.table.bottomFrozenRowCount;const t=Math.min(this.rowLimit,this.bodyBottomRow-this.bodyTopRow+1);this.totalRow=this.bodyTopRow+t-1,this.rowStart=this.bodyTopRow;const e=this.table.defaultRowHeight;this.taskRowCount=1*Math.ceil(this.table.tableNoFrameHeight/e);const i=e*t,n=e*(this.bodyBottomRow-this.bodyTopRow+1);this.yLimitTop=i/2,this.yLimitBottom=n-i/2;const r=5*this.table.tableNoFrameHeight;this.screenRowCount=Math.ceil(this.table.tableNoFrameHeight/e),this.firstScreenRowLimit=this.bodyTopRow+Math.ceil(r/e),this.rowUpdatePos=this.bodyBottomRow}async createGroupForFirstScreen(t,e,i,n,r,o,s,a){await async function(t,e,i,n,r,o,s,a,l){l.setParamsForRow(),l.setParamsForColumn(),l.table.internalProps._colWidthsMap.clear(),l.table._clearColRangeWidthsMap(),AS(l.table,0,Math.min(l.firstScreenColLimit,l.table.colCount-1)),l.table.internalProps._rowHeightsMap.clear(),l.table._clearRowRangeHeightsMap(),HS(l.table,0,Math.min(l.firstScreenRowLimit,l.table.rowCount-1)),l.table.rightFrozenColCount>0&&l.table.colCount-1>l.firstScreenColLimit&&AS(l.table,l.table.colCount-1-l.table.rightFrozenColCount+1,l.table.colCount-1),l.table.bottomFrozenRowCount>0&&l.table.rowCount-1>l.firstScreenRowLimit&&AS(l.table,l.table.rowCount-1-l.table.bottomFrozenRowCount+1,l.table.rowCount-1),l.table.scenegraph.colHeaderGroup.setAttribute("x",l.table.getFrozenColsWidth()),l.table.scenegraph.rowHeaderGroup.setAttribute("y",l.table.getFrozenRowsHeight()),l.table.scenegraph.bottomFrozenGroup.setAttribute("x",l.table.getFrozenColsWidth()),l.table.scenegraph.rightFrozenGroup.setAttribute("y",l.table.getFrozenRowsHeight()),l.table.scenegraph.bodyGroup.setAttributes({x:l.table.getFrozenColsWidth(),y:l.table.getFrozenRowsHeight()}),qM(t,s,a,0,l.table.rowHeaderLevelCount-1,0,l.table.columnHeaderLevelCount-1,"cornerHeader",l.table),qM(e,s,a,l.table.rowHeaderLevelCount,Math.min(l.firstScreenColLimit,l.table.colCount-1-l.table.rightFrozenColCount),0,l.table.columnHeaderLevelCount-1,"columnHeader",l.table),qM(i,s,a,0,l.table.rowHeaderLevelCount-1,l.table.columnHeaderLevelCount,Math.min(l.firstScreenRowLimit,l.table.rowCount-1-l.table.bottomFrozenRowCount),"rowHeader",l.table),l.table.bottomFrozenRowCount>0&&qM(r,s,a,l.table.rowHeaderLevelCount,Math.min(l.firstScreenColLimit,l.table.colCount-1-l.table.rightFrozenColCount),l.table.rowCount-1-l.table.bottomFrozenRowCount+1,l.table.rowCount-1,"body",l.table),l.table.rightFrozenColCount>0&&qM(n,s,a,l.table.colCount-1-l.table.rightFrozenColCount+1,l.table.colCount-1,l.table.columnHeaderLevelCount,Math.min(l.firstScreenRowLimit,l.table.rowCount-1-l.table.bottomFrozenRowCount),"body",l.table),qM(o,s,a,l.table.rowHeaderLevelCount,Math.min(l.firstScreenColLimit,l.table.colCount-1-l.table.rightFrozenColCount),l.table.columnHeaderLevelCount,Math.min(l.firstScreenRowLimit,l.table.rowCount-1-l.table.bottomFrozenRowCount),"body",l.table),o.firstChild?(l.currentRow=o.firstChild?.rowNumber??l.totalRow,l.rowEnd=l.currentRow,l.rowUpdatePos=l.rowEnd,l.referenceRow=l.rowStart+Math.floor((l.rowEnd-l.rowStart)/2),l.currentCol=o.lastChild?.col??l.totalCol,l.colEnd=l.currentCol,l.colUpdatePos=l.colEnd,l.referenceCol=l.colStart+Math.floor((l.colEnd-l.colStart)/2),await l.progress()):(l.currentRow=l.totalRow,l.rowEnd=l.currentRow,l.rowUpdatePos=l.rowEnd,l.referenceRow=l.rowStart+Math.floor((l.rowEnd-l.rowStart)/2),l.currentCol=l.totalCol,l.colEnd=l.currentCol,l.colUpdatePos=l.colEnd,l.referenceCol=l.colStart+Math.floor((l.colEnd-l.colStart)/2))}(t,e,i,n,r,o,s,a,this)}async createColGroupForFirstScreen(t,e,i,n,r){this.setParamsForRow(),this.setParamsForColumn(),HS(r,this.table.columnHeaderLevelCount,Math.min(this.firstScreenRowLimit,r.rowCount-1)),qM(t,i,n,0,r.rowHeaderLevelCount-1,r.columnHeaderLevelCount,r.rowCount-1,"rowHeader",r,this.firstScreenRowLimit),qM(e,i,n,r.rowHeaderLevelCount,r.colCount-1,r.columnHeaderLevelCount,r.rowCount-1,"body",r,this.firstScreenRowLimit),e.firstChild?(this.currentRow=e.firstChild?.rowNumber??this.totalRow,this.rowEnd=this.currentRow,this.rowUpdatePos=this.rowEnd,this.referenceRow=Math.floor((this.rowEnd-this.rowStart)/2),await this.progress()):(this.currentRow=this.totalRow,this.rowEnd=this.currentRow,this.rowUpdatePos=this.rowEnd,this.referenceRow=Math.floor((this.rowEnd-this.rowStart)/2))}async progress(){return new Promise(((t,e)=>{setTimeout((async()=>{this.colUpdatePos<this.colEnd?(await this.updateColCellGroupsAsync(),await this.progress()):this.rowUpdatePos<this.rowEnd?(await this.updateRowCellGroupsAsync(),await this.progress()):this.currentCol<this.totalCol?(await this.createCol(),await this.progress()):this.currentRow<this.totalRow&&(await this.createRow(),await this.progress()),t()}),0)}))}async createRow(){this.taskRowCount&&(console.log("createRow",this.currentRow,this.currentRow+this.taskRowCount),this.createRowCellGroup(this.taskRowCount))}async createCol(){this.taskColCount&&(console.log("createCol",this.currentCol,this.currentCol+this.taskColCount),this.createColGroup(this.taskRowCount))}createRowCellGroup(t){const e=Math.min(this.totalRow,this.currentRow+t);if(HS(this.table,this.currentRow+1,e),this.table.rowHeaderLevelCount){let t=0;for(let i=0;i<this.table.rowHeaderLevelCount;i++){const n=this.table.scenegraph.getColGroup(i),r="rowHeader",{height:o}=YM(n,i,n.attribute.width,this.currentRow+1,e,this.table.scenegraph.mergeMap,this.table.internalProps.defaultRowHeight,this.table,r);t=Math.max(t,o),this.table.scenegraph.rowHeaderGroup.setAttribute("height",t)}}if(this.table.rightFrozenColCount){let t=0;for(let i=this.table.colCount-this.table.rightFrozenColCount;i<this.table.colCount;i++){const n=this.table.scenegraph.getColGroup(i),r="rowHeader",{height:o}=YM(n,i,n.attribute.width,this.currentRow+1,e,this.table.scenegraph.mergeMap,this.table.internalProps.defaultRowHeight,this.table,r);t=Math.max(t,o),this.table.scenegraph.rightFrozenGroup.setAttribute("height",t)}}let i=0;for(let t=this.bodyLeftCol;t<=this.bodyRightCol;t++){const n=this.table.scenegraph.getColGroup(t),r="body",{height:o}=YM(n,t,n.attribute.width,this.currentRow+1,e,this.table.scenegraph.mergeMap,this.table.internalProps.defaultRowHeight,this.table,r);i=Math.max(i,o)}this.table.scenegraph.bodyGroup.setAttribute("height",i),this.currentRow=e,this.rowEnd=e,this.rowUpdatePos=this.rowEnd,this.referenceRow=this.rowStart+Math.floor((e-this.rowStart)/2),this.table.scenegraph.updateContainer(),this.table.scenegraph.updateBorderSizeAndPosition()}createColGroup(t){const e=Math.min(this.totalCol,this.currentCol+t);AS(this.table,this.currentCol+1,e);const i=this.table.scenegraph.bodyGroup.lastChild instanceof xw?this.table.scenegraph.bodyGroup.lastChild:this.table.scenegraph.bodyGroup.lastChild._prev,n=i.attribute.x+i.attribute.width,r=i.attribute.y;qM(this.table.scenegraph.bodyGroup,n,r,this.currentCol+1,e,this.rowStart,this.rowEnd,"body",this.table),this.currentCol=e,this.colEnd=e,this.colUpdatePos=this.colEnd,this.referenceCol=this.colStart+Math.floor((e-this.colStart)/2),console.log("async",this.referenceCol,this.colStart,this.colEnd),this.table.scenegraph.updateContainer(),this.table.scenegraph.updateBorderSizeAndPosition()}async setY(t){t<this.yLimitTop&&this.rowStart===this.bodyTopRow||t>this.yLimitBottom&&this.rowEnd===this.bodyBottomRow?this.table.scenegraph.setBodyAndRowHeaderY(-t):this.dynamicSetY(t)}async setX(t){t<this.xLimitLeft&&this.colStart===this.bodyLeftCol||t>this.xLimitRight&&this.colEnd===this.bodyRightCol?this.table.scenegraph.setBodyAndColHeaderX(-t):this.dynamicSetX(t)}async dynamicSetY(t){!async function(t,e){const i=e.table.getTargetRowAt(t+e.table.scenegraph.colHeaderGroup.attribute.height);if(!i)return;const n=i.row;e.screenTopRow=n;const r=n-e.referenceRow;r>0?(eR(r,"up",n,e),e.updateBody(t)):r<0?(eR(-r,"down",n,e),e.updateBody(t)):e.updateBody(t),e.table.scenegraph.updateNextFrame()}(t,this)}async dynamicSetX(t){!async function(t,e){const i=e.table.getTargetColAt(t+e.table.scenegraph.rowHeaderGroup.attribute.width);if(!i)return;e.screenLeftCol=i.col;const n=e.screenLeftCol-e.referenceCol;n>0?(e.table.scenegraph.setBodyAndColHeaderX(-t),await ZM(n,"left",e.screenLeftCol,e)):n<0?(e.table.scenegraph.setBodyAndColHeaderX(-t),await ZM(-n,"right",e.screenLeftCol,e)):e.table.scenegraph.setBodyAndColHeaderX(-t),e.table.scenegraph.updateNextFrame()}(t,this)}updateBody(t){this.table.scenegraph.setBodyAndRowHeaderY(-t)}async updateRowCellGroupsAsync(){this.updateCellGroups(this.taskRowCount)}updateCellGroups(t){const e=Math.min(this.bodyBottomRow,this.rowUpdatePos+t);"autoHeight"===this.table.heightMode&&HS(this.table,this.rowUpdatePos,e);for(let t=this.bodyLeftCol;t<=this.bodyRightCol;t++)for(let i=this.rowUpdatePos;i<=e;i++){const e=this.highPerformanceGetCell(t,i);this.updateCellGroupContent(e)}"autoHeight"===this.table.heightMode&&tR(this.bodyLeftCol,this.bodyRightCol,this.rowUpdatePos,e,this.table,this.rowUpdateDirection),this.rowUpdatePos=e+1}async updateColCellGroupsAsync(){this.updateColGroups(this.taskRowCount)}updateColGroups(t){const e=Math.min(this.bodyRightCol,this.colUpdatePos+t);for(let t=this.colUpdatePos;t<=e;t++){const e=this.table.scenegraph.getColGroup(t);if(e){let t=e.firstChild;for(;t;){t=this.updateCellGroupContent(t)._next}e.needUpdate=!1}}this.colUpdatePos=e+1}updateCellGroupPosition(t,e,i){t.row=e,t.setAttribute("y",i),t.needUpdate=!0,t.needUpdateForAutoRowHeight=!0}updateCellGroupContent(t){if(!t.needUpdate)return t;const e=this.table.scenegraph.updateCellContent(t.col,t.row);return t.needUpdate=!1,e||t}async sortCell(){for(let t=this.bodyLeftCol;t<=this.bodyRightCol;t++)for(let e=this.rowStart;e<=this.rowEnd;e++){this.highPerformanceGetCell(t,e).needUpdate=!0}let t,e;"autoHeight"===this.table.heightMode?(t=this.rowStart,e=this.rowEnd):(t=Math.max(this.bodyTopRow,this.screenTopRow-2*this.screenRowCount),e=Math.min(this.bodyBottomRow,this.screenTopRow+3*this.screenRowCount)),console.log("sort更新同步范围",t,e),"autoHeight"===this.table.heightMode&&HS(this.table,t,e);for(let i=this.bodyLeftCol;i<=this.bodyRightCol;i++)for(let n=t;n<=e;n++){const t=this.highPerformanceGetCell(i,n);this.updateCellGroupContent(t)}if(console.log("updateAutoRow",this.rowEnd>this.bodyBottomRow-(this.rowEnd-this.rowStart+1)?"down":"up"),"autoHeight"===this.table.heightMode&&tR(this.bodyLeftCol,this.bodyRightCol,t,e,this.table,this.rowEnd>this.bodyBottomRow-(this.rowEnd-this.rowStart+1)?"down":"up"),this.rowUpdatePos=this.rowStart,this.rowUpdateDirection=this.rowEnd>this.bodyBottomRow-(this.rowEnd-this.rowStart+1)?"down":"up",this.rowEnd===this.table.scenegraph.proxy.bodyBottomRow&&this.rowStart===this.table.scenegraph.proxy.bodyTopRow);else if(this.rowEnd===this.table.scenegraph.proxy.bodyBottomRow){const t=this.table.getAllRowsHeight()-this.table.scenegraph.height;this.updateBody(t)}else this.rowStart===this.table.scenegraph.proxy.bodyTopRow&&this.updateBody(0);"autoHeight"!==this.table.heightMode&&await this.progress()}highPerformanceGetCell(t,e,i=this.rowStart,n=this.rowEnd,r){if(e<i||e>n)return DS;if(e<this.rowStart||e>this.rowEnd||t<this.colStart||t>this.colEnd)return DS;if(this.cellCache.get(t)){const i=this.cellCache.get(t);if((i._next||i._prev)&&Math.abs(i.row-e)<e){let n=nR(i,e);return n||(n=this.table.scenegraph.getCell(t,e,r)),n.row&&this.cellCache.set(t,n),n}const n=this.table.scenegraph.getCell(t,e,r);return n.row&&this.cellCache.set(t,n),n}const o=this.table.scenegraph.getCell(t,e,r);return o.row&&this.cellCache.set(t,o),o}}function nR(t,e){return t?t.row===e?t:t.row>e?nR(t._prev,e):nR(t._next,e):null}function rR(t,e,i){const[n,r,o,s]=e.split("-"),a=parseInt(n,10),l=parseInt(r,10),h=parseInt(o,10),c=parseInt(s,10);let d;for(let t=a;t<=h;t++)for(let e=l;e<=c;e++){const n=i.highPerformanceGetCell(t,e);if("cell"!==n.role)continue;n.AABBBounds.width();const r=n.globalAABBBounds;d?d.union(r):d=r}d?t.rect.setAttributes({x:d.x1-i.tableGroup.attribute.x,y:d.y1-i.tableGroup.attribute.y,width:d.width(),height:d.height(),visible:!0}):t.rect.setAttributes({visible:!1});const u=a===i.table.frozenColCount,p=l===i.table.frozenRowCount;u&&t.rect.attribute.stroke[3]||p&&t.rect.attribute.stroke[0]?(u&&i.tableGroup.insertAfter(t.rect,"columnHeader"===t.role?i.cornerHeaderGroup:i.rowHeaderGroup),p&&i.tableGroup.insertAfter(t.rect,"rowHeader"===t.role?i.cornerHeaderGroup:i.colHeaderGroup),t.rect.attribute.x<i.rowHeaderGroup.attribute.width&&i.table.scrollLeft>0&&("body"===t.role||"columnHeader"===t.role)&&t.rect.setAttributes({x:t.rect.attribute.x+(i.rowHeaderGroup.attribute.width-t.rect.attribute.x),width:t.rect.attribute.width-(i.rowHeaderGroup.attribute.width-t.rect.attribute.x)}),t.rect.attribute.y<i.colHeaderGroup.attribute.height&&i.table.scrollTop>0&&("body"===t.role||"rowHeader"===t.role)&&t.rect.setAttributes({y:t.rect.attribute.y+(i.colHeaderGroup.attribute.height-t.rect.attribute.y),height:t.rect.attribute.height-(i.colHeaderGroup.attribute.height-t.rect.attribute.y)})):i.tableGroup.insertAfter(t.rect,"body"===t.role?i.bodyGroup:"columnHeader"===t.role?i.colHeaderGroup:"rowHeader"===t.role?i.rowHeaderGroup:i.cornerHeaderGroup)}function oR(t,e,i){const n=i.scenegraph,r=sR(t.map((t=>t.row))).sort(((t,e)=>t-e)),o=sR(e.map((t=>t.row))).sort(((t,e)=>t-e));r.forEach((t=>{!function(t,e){for(let i=0;i<e.table.colCount;i++){const n=e.getColGroup(i,!1);let r;n.forEachChildren((e=>e.row===t&&(r=e,!0))),r&&n.removeChild(r)}}(t,n)})),r.length&&function(t){for(let e=0;e<t.table.colCount;e++){const i=t.getColGroup(e,!0),n=t.getColGroup(e,!1);let r=i.firstChild?.row;i.forEachChildren((t=>{t.row=r,r++})),r=n.firstChild?.row,n.forEachChildren((t=>{t.row=r,r++}))}}(n),o.forEach((t=>{!function(t,e){for(let i=0;i<e.table.colCount;i++){const n=$M(i,t,e.table,!0);if(!n)continue;const r=e.getColGroup(i);if(r.firstChild&&t<r.firstChild.row)r.insertBefore(n,r.firstChild);else if(r.lastChild&&t>r.lastChild.row)r.appendChild(n);else{let e;r.forEachChildren((i=>i.row===t&&(e=i,!0))),e!==n&&r.insertBefore(n,e)}let o=r.firstChild?.row;r.forEachChildren((t=>{t.row=o,o++}))}}(t,n)})),function(t){let e=0;for(let i=0;i<t.table.colCount;i++){const n=t.getColGroup(i,!0),r=t.getColGroup(i,!1);let o=n.firstChild?.row,s=0;o=r.firstChild?.row,s=0,r.forEachChildren((t=>{t.row=o,o++,"cell"===t.role&&(t.setAttribute("y",s),s+=t.attribute.height)})),e=s}t.updateContainerHeight(t.table.frozenRowCount,e-t.bodyGroup.attribute.height)}(n)}function sR(t){const e=[];for(let i=0;i<t.length;i++)-1===e.indexOf(t[i])&&e.push(t[i]);return e}new Ah({});const aR=[];function lR(t){aR.forEach((e=>{t.scenegraph.getCell(e.col,e.row).forEachChildren((t=>{t.setAttributes({dy:0,dx:0})}))})),aR.length=0;const{scrollTop:e,scrollLeft:i,frozenRowCount:n,frozenColCount:r}=t,o=t.getFrozenRowsHeight(),s=t.getFrozenColsWidth(),{row:a}=t.getRowAt(e+o+1),{col:l}=t.getColAt(i+s+1),h=t.getAllRowsHeight()>t.tableNoFrameHeight?t.getRowAt(e+t.tableNoFrameHeight-1).row:t.rowCount-1,c=t.getAllColsWidth()>t.tableNoFrameWidth?t.getColAt(i+t.tableNoFrameWidth-1).col:t.colCount-1;for(let e=0;e<n;e++)for(let i=l;i<=c;i++)if(t._getCellStyle(i,e)?.textStick){cR(t.scenegraph.getCell(i,e),s+t.tableX,t.tableNoFrameWidth),aR.push({col:i,row:e})}if(-1!==a){for(let e=a;e<=h;e++)for(let i=0;i<r;i++)if(t._getCellStyle(i,e)?.textStick&&"tree"!==t.internalProps.layoutMap.rowHierarchyType){hR(t.scenegraph.getCell(i,e),o+t.tableY,t.tableNoFrameHeight),aR.push({col:i,row:e})}for(let e=a;e<=h;e++)for(let i=l;i<=c;i++)if(t._getCellStyle(i,e)?.textStick){const n=t.scenegraph.getCell(i,e);hR(n,o+t.tableY,t.tableNoFrameHeight),cR(n,s+t.tableX,t.tableNoFrameWidth),aR.push({col:i,row:e})}}}function hR(t,e,i){const n=t.getChildByName("text",!0);if(!n)return;n.AABBBounds.width();const r=n.globalAABBBounds.y1,o=n.globalAABBBounds.y2;if(r<e){const i=r-e;t.forEachChildren((t=>{t.setAttribute("dy",2-i)}))}else if(o>i){const e=o-i;t.forEachChildren((t=>{t.setAttribute("dy",-e)}))}}function cR(t,e,i){const n=t.getChildByName("text",!0);if(!n)return;n.AABBBounds.width();const r=n.globalAABBBounds.x1,o=n.globalAABBBounds.x2;if(r<e){const i=r-e;t.forEachChildren((t=>{t.setAttribute("dx",2-i)}))}else if(o>i){const e=o-i;t.forEachChildren((t=>{t.setAttribute("dx",-e)}))}}function dR(t){for(let e=t.proxy.colStart;e<=t.proxy.colEnd;e++){t.getColGroup(e).getChildren().forEach((t=>{t.children.forEach((t=>{"chart"===t.type&&(t.cacheCanvas=null,t.addUpdateBoundTag())}))}))}}function uR(t){const e=t.bodyGroup.firstChild instanceof xw?t.bodyGroup.firstChild:null;e&&(t.rowHeaderGroup.appendChild(e),t.rowHeaderGroup.setAttribute("width",t.rowHeaderGroup.attribute.width+e.attribute.width),t.bodyGroup.setAttribute("width",t.bodyGroup.attribute.width-e.attribute.width))}function pR(t){const e=t.colHeaderGroup.firstChild instanceof xw?t.colHeaderGroup.firstChild:null;e&&(t.cornerHeaderGroup.appendChild(e),t.cornerHeaderGroup.setAttribute("width",t.cornerHeaderGroup.attribute.width+e.attribute.width),t.colHeaderGroup.setAttribute("width",t.colHeaderGroup.attribute.width-e.attribute.width))}function fR(t){const e=t.rowHeaderGroup.lastChild instanceof xw?t.rowHeaderGroup.lastChild:t.rowHeaderGroup.lastChild?._prev;e&&(t.bodyGroup.firstChild?t.bodyGroup.insertBefore(e,t.bodyGroup.firstChild):t.bodyGroup.appendChild(e),t.bodyGroup.setAttribute("width",t.bodyGroup.attribute.width+e.attribute.width),t.rowHeaderGroup.setAttribute("width",t.rowHeaderGroup.attribute.width-e.attribute.width))}function gR(t){const e=t.cornerHeaderGroup.lastChild instanceof xw?t.cornerHeaderGroup.lastChild:t.cornerHeaderGroup.lastChild?._prev;e&&(t.colHeaderGroup.firstChild?t.colHeaderGroup.insertBefore(e,t.colHeaderGroup.firstChild):t.bodyGroup.appendChild(e),t.colHeaderGroup.setAttribute("width",t.colHeaderGroup.attribute.width+e.attribute.width),t.cornerHeaderGroup.setAttribute("width",t.cornerHeaderGroup.attribute.width-e.attribute.width))}na.load(SS);class yR{proxy;tableGroup;colHeaderGroup;cornerHeaderGroup;rowHeaderGroup;bodyGroup;rightFrozenGroup;bottomFrozenGroup;rightTopCellGroup;leftBottomCellGroup;rightBottomCellGroup;componentGroup;selectedRangeComponents;selectingRangeComponents;lastSelectId;component;stage;table;isPivot;transpose;hasFrozen;frozenColCount;frozenRowCount;rightFrozenColCount;bottomFrozenRowCount;clear;mergeMap;constructor(t){this.table=t,this.hasFrozen=!1,this.clear=!0,this.mergeMap=new Map,this.stage=function(t){return new ww(t)}({canvas:t.canvas,width:t.canvas.width,height:t.canvas.height,disableDirtyBounds:!1,background:t.theme.underlayBackgroundColor,dpr:t.internalProps.pixelRatio}),this.stage.defaultLayer.setTheme({group:{boundsPadding:0,strokeBoundsBuffer:0,lineJoin:"round"}}),this.initSceneGraph(),this.stage.defaultLayer.add(this.tableGroup),this.stage.table=this.table,this.createComponent()}get width(){return this.tableGroup.attribute?.width??0}get height(){return this.tableGroup.attribute?.height??0}get x(){return this.tableGroup.attribute?.x??0}get y(){return this.tableGroup.attribute?.y??0}get bodyRowStart(){return this.transpose||this.isPivot?this.table.columnHeaderLevelCount:this.proxy.rowStart??0}get bodyRowEnd(){return this.transpose||this.isPivot?this.table.rowCount-1:this.proxy.rowEnd??0}initSceneGraph(){this.isPivot=this.table.isPivotTable(),this.transpose=this.table.options.transpose;const t=this.table.tableNoFrameWidth,e=this.table.tableNoFrameHeight;this.tableGroup=new xw({x:0,y:0,width:t,height:e,clip:!0,pickable:!1}),this.tableGroup.role="table";const i=new xw({x:0,y:0,width:0,height:0,clip:!1,pickable:!1});i.role="col-header",this.colHeaderGroup=i;const n=new xw({x:0,y:0,width:0,height:0,clip:!1,pickable:!1});n.role="corner-header",this.cornerHeaderGroup=n;const r=new xw({x:0,y:0,width:0,height:0,clip:!1,pickable:!1});r.role="row-header",this.rowHeaderGroup=r;const o=new xw({x:0,y:0,width:t,height:0,clip:!1,pickable:!1});o.role="body",this.bodyGroup=o;const s=new xw({x:0,y:0,width:t,height:0,clip:!1,pickable:!1});s.role="right-frozen",this.rightFrozenGroup=s;const a=new xw({x:0,y:0,width:t,height:0,clip:!1,pickable:!1});a.role="bottom-frozen",this.bottomFrozenGroup=a;const l=new xw({x:0,y:0,width:0,height:0,clip:!1,pickable:!1,childrenPickable:!0});l.role="component",this.componentGroup=l;const h=new xw({x:0,y:0,width:0,height:0,visible:!1,pickable:!0,fill:this.table.theme.cornerHeaderStyle.bgColor,stroke:this.table.theme.cornerHeaderStyle.borderColor,lineWidth:this.table.theme.cornerHeaderStyle.borderLineWidth});h.role="corner-frozen",this.rightTopCellGroup=h;const c=new xw({x:0,y:0,width:0,height:0,visible:!1,pickable:!0,fill:this.table.theme.cornerHeaderStyle.bgColor,stroke:this.table.theme.cornerHeaderStyle.borderColor,lineWidth:this.table.theme.cornerHeaderStyle.borderLineWidth});c.role="corner-frozen",this.leftBottomCellGroup=c;const d=new xw({x:0,y:0,width:0,height:0,visible:!1,pickable:!0,fill:this.table.theme.cornerHeaderStyle.bgColor,stroke:this.table.theme.cornerHeaderStyle.borderColor,lineWidth:this.table.theme.cornerHeaderStyle.borderLineWidth});d.role="corner-frozen",this.rightBottomCellGroup=d,this.tableGroup.addChild(o),this.tableGroup.addChild(s),this.tableGroup.addChild(a),this.tableGroup.addChild(r),this.tableGroup.addChild(i),this.tableGroup.addChild(d),this.tableGroup.addChild(h),this.tableGroup.addChild(c),this.tableGroup.addChild(n),this.tableGroup.addChild(l)}clearCells(){this.clear=!0,this.hasFrozen=!1,this.mergeMap.clear(),this.colHeaderGroup.clear(),this.rowHeaderGroup.clear(),this.cornerHeaderGroup.clear(),this.bodyGroup.clear(),this.colHeaderGroup.setAttributes({x:0,y:0,width:0,height:0}),this.rowHeaderGroup.setAttributes({x:0,y:0,width:0,height:0}),this.cornerHeaderGroup.setAttributes({x:0,y:0,width:0,height:0}),this.bodyGroup.setAttributes({x:0,y:0,width:0,height:0}),this.rightFrozenGroup.setAttributes({x:0,y:0,width:0,height:0}),this.bottomFrozenGroup.setAttributes({x:0,y:0,width:0,height:0}),this.rightTopCellGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.leftBottomCellGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.rightTopCellGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.tableGroup.setAttributes({x:this.table.tableX,y:this.table.tableY,width:0,height:0}),this.tableGroup.border&&(this.tableGroup.parent.removeChild(this.tableGroup.border),delete this.tableGroup.border)}createComponent(){this.component=new tS(this.table),this.component.addToGroup(this.componentGroup),this.selectedRangeComponents=new Map,this.selectingRangeComponents=new Map}createSceneGraph(){this.clear=!1,this.frozenColCount=this.table.rowHeaderLevelCount,this.frozenRowCount=this.table.columnHeaderLevelCount,this.proxy=new iR(this.table),eS(this.tableGroup,this.table.theme.frameStyle,this.tableGroup.role,void 0,!0),this.proxy.createGroupForFirstScreen(this.cornerHeaderGroup,this.colHeaderGroup,this.rowHeaderGroup,this.rightFrozenGroup,this.bottomFrozenGroup,this.bodyGroup,0,0),this.afterScenegraphCreated()}renderSceneGraph(){this.stage.render()}getCellOld(t,e){let i;if(i=this.hasFrozen&&t<this.table.frozenColCount&&e<this.table.frozenRowCount?this.cornerHeaderGroup.getChildAt(t)?.getChildAt(e):e<this.table.frozenRowCount?this.colHeaderGroup.getChildAt(this.hasFrozen?t-this.table.frozenColCount:t)?.getChildAt(e):t<this.table.frozenColCount?this.rowHeaderGroup.getChildAt(t)?.getChildAt(e-this.table.frozenRowCount):this.bodyGroup.getChildAt(t-this.table.frozenColCount)?.getChildAt(e-this.table.frozenRowCount),i&&"shadow-cell"===i.role){const n=this.table.getCellRange(t,e);i=this.getCell(n.start.col,n.start.row)}return i||void 0}getColGroupOld(t,e=!1){let i;return i=t<this.frozenColCount&&e?this.cornerHeaderGroup.getChildAt(t):t<this.frozenColCount?this.rowHeaderGroup.getChildAt(t):e?this.rowHeaderGroup.getChildAt(t-this.frozenColCount):this.bodyGroup.getChildAt(t-this.frozenColCount),i||void 0}getCell(t,e,i){let n;if(n=this.table.rightFrozenColCount>0&&t>this.table.colCount-1-this.table.rightFrozenColCount?this.rightFrozenGroup.getColGroup(t)?.getRowGroup(e):this.table.bottomFrozenRowCount>0&&e>this.table.rowCount-1-this.table.bottomFrozenRowCount?this.bottomFrozenGroup.getColGroup(t)?.getRowGroup(e):this.getColGroup(t,e<this.frozenRowCount)?.getRowGroup(e),n&&"shadow-cell"===n.role&&!i){const i=this.table.getCellRange(t,e);n=this.getCell(i.start.col,i.start.row)}return n||DS}highPerformanceGetCell(t,e,i){return this.table.isHeader(t,e)?this.getCell(t,e,i):this.proxy.highPerformanceGetCell(t,e,0,this.table.rowCount-1,i)}getColGroup(t,e=!1){let i;return i=t<this.frozenColCount&&e?this.cornerHeaderGroup.getColGroup(t):t<this.frozenColCount?this.rowHeaderGroup.getColGroup(t):e?this.colHeaderGroup.getColGroup(t):this.table.rightFrozenColCount>0&&t>this.table.colCount-1-this.table.rightFrozenColCount?this.rightFrozenGroup.getColGroup(t):this.bodyGroup.getColGroup(t),i||void 0}getCellSize(t,e){const i=this.getCell(t,e),n=_w(this.table,t,e);let r=i.attribute.width,o=i.attribute.height;return n&&(r/=n.end.col-n.start.col+1,o/=n.end.row-n.start.row+1),{width:r,height:o}}updateNextFrame(){this.resetAllSelectComponent(),this.stage.renderNextFrame()}resetAllSelectComponent(){var t;(t=this).selectingRangeComponents.forEach(((e,i)=>{rR(e,i,t)})),t.selectedRangeComponents.forEach(((e,i)=>{rR(e,i,t)}))}hideHoverIcon(t,e){if(-1===t||-1===e)return;bR(this,this.getCell(t,e),"mouseenter_cell")}showHoverIcon(t,e){if(-1===t||-1===e)return;mR(this,this.getCell(t,e),"mouseenter_cell")}hideClickIcon(t,e){if(-1===t||-1===e)return;bR(this,this.getCell(t,e),"click_cell")}showClickIcon(t,e){if(-1===t||-1===e)return;mR(this,this.getCell(t,e),"click_cell")}deactivateChart(t,e){if(-1===t||-1===e)return;const i=this.getCell(t,e);i?.firstChild?.deactivate?.()}activateChart(t,e){if(-1===t||-1===e)return;const i=this.getCell(t,e);i?.firstChild?.activate?.(this.table)}removeInteractionBorder(t,e){const i=this.getCell(t,e);i.setAttribute("highlightStroke",void 0),i.setAttribute("highlightStrokeArrayWidth",void 0),i.setAttribute("highlightStrokeArrayColor",void 0)}createCellSelectBorder(t,e,i,n,r,o,s){!function(t,e,i,n,r,o,s,a){const l=Math.min(e,n),h=Math.min(i,r),c=Math.max(e,n),d=Math.max(i,r);let u;for(let e=l;e<=c;e++)for(let i=h;i<=d;i++){const n=t.highPerformanceGetCell(e,i);if("shadow-cell"===n.role)continue;n.AABBBounds.width();const r=n.globalAABBBounds;u?u.union(r):u=r}const p=t.table.theme,f=p.selectionStyle?.cellBorderColor,g=p.selectionStyle?.cellBorderLineWidth,y=uu({pickable:!1,fill:p.selectionStyle?.cellBgColor??"rgba(0, 0, 255,0.1)",lineWidth:g,stroke:a.map((t=>!!t&&f)),x:u.x1-t.tableGroup.attribute.x,y:u.y1-t.tableGroup.attribute.y,width:u.width(),height:u.height(),visible:!0});t.lastSelectId=s,t.selectingRangeComponents.set(`${l}-${h}-${c}-${d}-${s}`,{rect:y,role:o}),t.tableGroup.insertAfter(y,"body"===o?t.bodyGroup:"columnHeader"===o?t.colHeaderGroup:"rowHeader"===o?t.rowHeaderGroup:t.cornerHeaderGroup)}(this,t,e,i,n,r,o,s)}moveSelectingRangeComponentsToSelectedRangeComponents(){var t;(t=this).selectingRangeComponents.forEach(((e,i)=>{t.selectedRangeComponents.get(i)&&t.selectedRangeComponents.get(i).rect.delete(),t.selectedRangeComponents.set(i,e)})),t.selectingRangeComponents=new Map,t.updateNextFrame()}deleteLastSelectedRangeComponents(){var t;(t=this).selectedRangeComponents.forEach(((e,i)=>{i.split("-")[4]===t.lastSelectId&&(e.rect.delete(),t.selectedRangeComponents.delete(i))}))}deleteAllSelectBorder(){var t;(t=this).selectedRangeComponents.forEach(((t,e)=>{t.rect.delete()})),t.selectedRangeComponents=new Map}updateCellSelectBorder(t,e,i,n){!function(t,e,i,n,r){let o=Math.min(n,e),s=Math.min(r,i),a=Math.max(n,e),l=Math.max(r,i);const h=()=>{let e=!1;for(let i=o;i<=a;i++){if(i===o)for(let n=s;n<=l;n++){const r=_w(t.table,i,n);if(r&&r.start.col<o){o=r.start.col,e=!0;break}}if(!e&&i===a)for(let n=s;n<=l;n++){const r=_w(t.table,i,n);if(r&&r.end.col>a){a=r.end.col,e=!0;break}}if(e)break}if(!e)for(let i=s;i<=l;i++){if(i===s)for(let n=o;n<=a;n++){const r=_w(t.table,n,i);if(r&&r.start.row<s){s=r.start.row,e=!0;break}}if(!e&&i===l)for(let n=o;n<=a;n++){const r=_w(t.table,n,i);if(r&&r.end.row>l){l=r.end.row,e=!0;break}}if(e)break}e&&h()};h(),t.selectingRangeComponents.forEach(((t,e)=>{t.rect.delete()})),t.selectingRangeComponents=new Map;let c=!1,d=!1,u=!1,p=!1;if(o<=t.table.frozenColCount-1&&s<=t.table.frozenRowCount-1&&(p=!0),o<=t.table.frozenColCount-1&&l>=t.table.frozenRowCount&&(c=!0),s<=t.table.frozenRowCount-1&&a>=t.table.frozenColCount&&(d=!0),a>=t.table.frozenColCount&&l>=t.table.frozenRowCount&&(u=!0),p){const e=Math.min(a,t.table.frozenColCount-1),i=Math.min(l,t.table.frozenRowCount-1),n=[!0,!d,!c,!0];t.createCellSelectBorder(o,s,e,i,"cornerHeader",`${o}${s}${a}${l}`,n)}if(d){const e=Math.max(o,t.table.frozenColCount),i=Math.min(l,t.table.frozenRowCount-1),n=[!0,!0,!u,!p];t.createCellSelectBorder(e,s,a,i,"columnHeader",`${o}${s}${a}${l}`,n)}if(c){const e=Math.max(s,t.table.frozenRowCount),i=Math.min(a,t.table.frozenColCount-1),n=[!p,!u,!0,!0];t.createCellSelectBorder(o,e,i,l,"rowHeader",`${o}${s}${a}${l}`,n)}if(u){const e=Math.max(o,t.table.frozenColCount),i=Math.max(s,t.table.frozenRowCount),n=[!d,!0,!0,!c];t.createCellSelectBorder(e,i,a,l,"body",`${o}${s}${a}${l}`,n)}}(this,t,e,i,n)}getIcon(t,e,i,n){let r;return this.getCell(t,e).forEachChildren((t=>{"icon"===t.role&&t.containsPoint(i,n,Wo.GLOBAL)&&(r=t)})),r}setIconHoverStyle(t,e,i,n){if(t.attribute.backgroundColor){let e=t.parent.getChildByName("icon-back");e?e.setAttributes({x:(t.attribute.x??0)+(t.attribute.dx??0)+(t.AABBBounds.width()-t.backgroundWidth)/2,y:(t.attribute.y??0)+(t.AABBBounds.height()-t.backgroundHeight)/2,width:t.backgroundWidth,height:t.backgroundHeight,fill:t.attribute.backgroundColor,cornerRadius:5,visible:!0}):(e=uu({x:(t.attribute.x??0)+(t.attribute.dx??0)+(t.AABBBounds.width()-t.backgroundWidth)/2,y:(t.attribute.y??0)+(t.AABBBounds.height()-t.backgroundHeight)/2,width:t.backgroundWidth,height:t.backgroundHeight,fill:t.attribute.backgroundColor,cornerRadius:5,pickable:!1,visible:!0}),e.name="icon-back"),t.parent.insertBefore(e,t)}if(t.attribute.hoverImage&&t.attribute.image!==t.attribute.hoverImage&&(t.image=t.attribute.hoverImage),t.tooltip){const{x1:n,x2:r,y1:o,y2:s}=t.globalAABBBounds,a={content:t.tooltip.title,referencePosition:{rect:{left:n-this.table.tableX,right:r-this.table.tableX,top:o-this.table.tableY,bottom:s-this.table.tableY,width:t.globalAABBBounds.width(),height:t.globalAABBBounds.height()},placement:t.tooltip.placement},style:Object.assign({},this.table.internalProps.theme?.tooltipStyle,t.tooltip?.style)};this.table.internalProps.tooltipHandler.isBinded(a)||this.table.showTooltip(e,i,a)}}setIconNormalStyle(t,e,i){const n=t.parent.getChildByName("icon-back");n&&n.setAttribute("visible",!1),t.attribute.hoverImage&&t.attribute.image!==t.attribute.originImage&&(t.image=t.attribute.originImage)}updateColWidth(t,e){!function(t,e,i){const n="autoHeight"===t.table.heightMode;let r=!1;const o=t.getColGroup(e,!0),s=o?.attribute.width;if(o?.setAttribute("width",s+i),o?.forEachChildren(((o,a)=>{if(Bx(t,o,e,o.row,s,i,t.table.columnHeaderLevelCount,n)){const e=_w(t.table,o.col,o.row);if(e&&e.end.row-e.start.row)for(let i=e.start.row;i<=e.end.row;i++)Mx(t,i);else Mx(t,o.row);r=!0}})),r){let e=0;for(let i=0;i<t.table.colCount;i++){const n=t.getColGroup(i,!0);let r=0;n.forEachChildren((t=>{"cell"===t.role&&(t.setAttribute("y",r),r+=t.attribute.height)})),e=r}t.updateContainerHeight(0,e-t.colHeaderGroup.attribute.height)}r=!1;const a=t.getColGroup(e),l=a.attribute.width;if(a?.setAttribute("width",l+i),a?.forEachChildren(((e,o)=>{if(Bx(t,e,e.col,e.row,l,i,t.table.rowHeaderLevelCount,n)){const i=_w(t.table,e.col,e.row);if(i&&i.end.row-i.start.row)for(let e=i.start.row;e<=i.end.row;e++)Mx(t,e);else Mx(t,e.row);r=!0}})),r){let e=0;for(let i=0;i<t.table.colCount;i++){const n=t.getColGroup(i,!1);let r=0;n.forEachChildren((t=>{"cell"===t.role&&(t.setAttribute("y",r),r+=t.attribute.height)})),e=r}t.updateContainerHeight(t.table.frozenRowCount,e-t.bodyGroup.attribute.height)}e<t.frozenColCount?(t.cornerHeaderGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)})),t.rowHeaderGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)}))):(t.colHeaderGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)})),t.bodyGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)}))),t.table.setColWidth(e,a.attribute.width,!0)}(this,t,e),this.updateContainer()}updateChartSize(t){!function(t,e){for(let i=e;i<=t.proxy.colEnd;i++)t.getColGroup(i).getChildren().forEach((e=>{const i=t.table.getColWidth(e.col),n=t.table.getRowHeight(e.row);e.children.forEach((r=>{"chart"===r.type&&(r.cacheCanvas=null,r.setAttribute("width",Math.ceil(i-r.attribute.cellPadding[3]-r.attribute.cellPadding[1])),r.setAttribute("height",Math.ceil(n-r.attribute.cellPadding[0]-r.attribute.cellPadding[2])),r.setAttribute("viewBox",{x1:Math.ceil(e.globalAABBBounds.x1+r.attribute.cellPadding[3]+t.table.scrollLeft),x2:Math.ceil(e.globalAABBBounds.x1+i-r.attribute.cellPadding[1]+t.table.scrollLeft),y1:Math.ceil(e.globalAABBBounds.y1+r.attribute.cellPadding[0]+t.table.scrollTop),y2:Math.ceil(e.globalAABBBounds.y1+n-r.attribute.cellPadding[2]+t.table.scrollTop)}))}))}))}(this,t)}updateChartState(t){this.table.isPivotChart()&&function(t,e){const i=t.table;if(i.isPivotChart()){const n=i._selectedDataItemsInChart.length;if((null===e||0===e?.length||0===Object.keys(e).length)&&0===n)return;if(i._selectedDataItemsInChart=[],Array.isArray(e))e.forEach((t=>{if(t&&0!==t.key&&Object.keys(t).length>0){const e={};for(const i in t)i.startsWith("VGRAMMAR_")||i.startsWith("__VCHART")||(e[i]=t[i]);i._selectedDataItemsInChart.push(e)}}));else if(e&&0!==e.key&&Object.keys(e).length>0){const t={};for(const i in e)i.startsWith("VGRAMMAR_")||i.startsWith("__VCHART")||(t[i]=e[i]);i._selectedDataItemsInChart.push(t)}if(0===i._selectedDataItemsInChart.length&&0===n)return;i.internalProps.layoutMap.updateDataStateToChartInstance(),dR(t)}}(this,t)}updateAutoColWidth(t){const e=this.table.getColWidth(t),i=TS(t,0,this.table.rowCount-1,this.table,!0);i!==e&&this.updateColWidth(t,i-e)}recalculateColWidths(){AS(this.table,0,this.table.colCount-1,!0)}recalculateRowHeights(){HS(this.table,0,this.table.rowCount-1)}resize(){this.recalculateColWidths(),"autoHeight"===this.table.heightMode&&this.recalculateRowHeights(),this.dealWidthMode(),this.dealHeightMode(),this.dealFrozen(),this.updateTableSize(),this.updateBorderSizeAndPosition(),this.component.updateScrollBar(),this.updateNextFrame()}updateTableSize(){this.tableGroup.setAttributes({width:Math.min(this.table.tableNoFrameWidth,Math.max(this.colHeaderGroup.attribute.width,this.bodyGroup.attribute.width,0)+Math.max(this.cornerHeaderGroup.attribute.width,this.rowHeaderGroup.attribute.width,0)+this.rightBottomCellGroup.attribute.width),height:Math.min(this.table.tableNoFrameHeight,(this.colHeaderGroup.attribute.height??0)+(this.bodyGroup.attribute.height??0)+this.bottomFrozenGroup.attribute.height)}),this.tableGroup.border&&this.tableGroup.border.setAttributes({width:this.tableGroup.attribute.width+this.tableGroup.border.attribute.lineWidth,height:this.tableGroup.attribute.height+this.tableGroup.border.attribute.lineWidth}),this.table.bottomFrozenRowCount>0&&(this.bottomFrozenGroup.setAttribute("y",this.tableGroup.attribute.height-this.bottomFrozenGroup.attribute.height),this.leftBottomCellGroup.setAttributes({visible:!0,y:this.tableGroup.attribute.height-this.bottomFrozenGroup.attribute.height,height:this.bottomFrozenGroup.attribute.height,width:this.table.getFrozenColsWidth()}),this.rightBottomCellGroup.setAttributes({visible:!0,y:this.tableGroup.attribute.height-this.bottomFrozenGroup.attribute.height,height:this.bottomFrozenGroup.attribute.height})),this.table.rightFrozenColCount>0&&(this.rightFrozenGroup.setAttribute("x",this.tableGroup.attribute.width-this.rightFrozenGroup.attribute.width),this.rightTopCellGroup.setAttributes({visible:!0,x:this.tableGroup.attribute.width-this.rightFrozenGroup.attribute.width,width:this.rightFrozenGroup.attribute.width,height:this.table.getFrozenRowsHeight()}),this.rightBottomCellGroup.setAttributes({visible:!0,x:this.tableGroup.attribute.width-this.rightFrozenGroup.attribute.width,width:this.rightFrozenGroup.attribute.width}))}updateRowHeight(t,e){!function(t,e,i){for(let n=0;n<t.table.colCount;n++){const r=t.getCell(n,e),o=_w(t.table,n,e);o&&o.start.col!==n||(Tx(t,r,n,e,r.attribute.height,i,t.table.isHeader(n,e)),t.updateCellContentWhileResize(n,e))}let n=0,r=0;e<t.table.columnHeaderLevelCount?(t.colHeaderGroup.setAttribute("height",t.colHeaderGroup.attribute.height+i),t.rowHeaderGroup.setAttribute("y",t.colHeaderGroup.attribute.y+i),t.bodyGroup.setAttribute("y",t.bodyGroup.attribute.y+i),n=e+1,r=t.table.columnHeaderLevelCount-1):(n=e+1,r=t.bodyRowEnd);for(let e=n;e<=r;e++)for(let n=0;n<t.table.colCount;n++){const r=t.getCell(n,e),o=_w(t.table,n,e);(!o||o.start.col===n&&o.start.row===e)&&r.setAttribute("y",r.attribute.y+i)}t.table.setRowHeight(e,t.table.getRowHeight(e)+i,!0)}(this,t,e),this.updateContainerHeight(t,e)}updateContainerWidth(t,e){t<this.frozenColCount?(this.rowHeaderGroup.setDeltaWidth(e),this.cornerHeaderGroup.setDeltaWidth(e),this.colHeaderGroup.setDeltaX(e),this.bodyGroup.setDeltaX(e)):(this.colHeaderGroup.setDeltaWidth(e),this.bodyGroup.setDeltaWidth(e)),this.updateTableSize(),this.component.updateScrollBar(),this.updateNextFrame()}updateContainerHeight(t,e){t<this.frozenRowCount?(this.colHeaderGroup.setDeltaHeight(e),this.cornerHeaderGroup.setDeltaHeight(e),this.rowHeaderGroup.setDeltaY(e),this.bodyGroup.setDeltaY(e)):(this.rowHeaderGroup.setDeltaHeight(e),this.bodyGroup.setDeltaHeight(e)),this.updateTableSize(),this.component.updateScrollBar(),this.updateNextFrame()}setColWidth(t,e){const i=this.table.getColWidth(t);i!==e&&this.updateColWidth(t,e-i)}setRowHeight(t,e){const i=this.table.getRowHeight(t);this.updateRowHeight(t,e-i)}setX(t){this.table.scenegraph.proxy.setX(-t)}setY(t){this.table.scenegraph.proxy.setY(-t)}setBodyAndRowHeaderY(t){this.colHeaderGroup.attribute.height+t!==this.bodyGroup.attribute.y&&(this.bodyGroup.setAttribute("y",this.colHeaderGroup.attribute.height+t),this.rowHeaderGroup.setAttribute("y",this.colHeaderGroup.attribute.height+t),this.table.rightFrozenColCount>0&&this.rightFrozenGroup.setAttribute("y",this.colHeaderGroup.attribute.height+t),this.updateNextFrame())}setBodyAndColHeaderX(t){this.rowHeaderGroup.attribute.width+t!==this.bodyGroup.attribute.x&&(this.bodyGroup.setAttribute("x",this.rowHeaderGroup.attribute.width+t),this.colHeaderGroup.setAttribute("x",this.rowHeaderGroup.attribute.width+t),this.table.bottomFrozenRowCount>0&&this.bottomFrozenGroup.setAttribute("x",this.rowHeaderGroup.attribute.width+t),this.updateNextFrame())}afterScenegraphCreated(){this.dealWidthMode(),this.dealHeightMode(),this.dealFrozen(),this.createFrameBorder(),this.updateBorderSizeAndPosition(),this.component.updateScrollBar(),lR(this.table),this.updateNextFrame()}dealWidthMode(){const t=this.table;if("adaptive"===t.widthMode){const e=t.tableNoFrameWidth;let i=0;for(let e=0;e<t.colCount;e++)i+=t.getColWidth(e);const n=e/i;for(let i=0;i<t.colCount;i++){let r;r=i===t.colCount-1?e-t.getColsWidth(0,t.colCount-2):Math.round(t.getColWidth(i)*n),this.setColWidth(i,r)}}else if(t.autoFillWidth){const e=t.tableNoFrameWidth;let i=0,n=0;for(let e=0;e<t.colCount;e++){const r=t.getColWidth(e);e<t.frozenColCount&&(n+=r),i+=r}if(i<e&&i-n>0){const r=(e-n)/(i-n);for(let e=t.frozenColCount;e<t.colCount;e++)this.setColWidth(e,t.getColWidth(e)*r)}}let e=0;this.bodyGroup.forEachChildrenSkipChild((t=>{e+=t.attribute.width})),this.bodyGroup.setAttribute("width",e);let i=0;this.colHeaderGroup.forEachChildrenSkipChild((t=>{i+=t.attribute.width})),this.colHeaderGroup.setAttribute("width",i);let n=0;this.rowHeaderGroup.forEachChildrenSkipChild((t=>{n+=t.attribute.width})),this.rowHeaderGroup.setAttribute("width",n);let r=0;this.cornerHeaderGroup.forEachChildrenSkipChild((t=>{r+=t.attribute.width})),this.cornerHeaderGroup.setAttribute("width",r),this.colHeaderGroup.setAttribute("x",this.cornerHeaderGroup.attribute.width),this.rowHeaderGroup.setAttribute("y",this.colHeaderGroup.attribute.height),this.bodyGroup.setAttributes({x:this.rowHeaderGroup.attribute.width,y:this.colHeaderGroup.attribute.height})}dealHeightMode(){const t=this.table;if("adaptive"===t.heightMode){t._clearRowRangeHeightsMap();const e=t.tableNoFrameHeight-t.getFrozenRowsHeight()-t.getBottomFrozenRowsHeight();let i=0;for(let e=t.frozenRowCount;e<t.rowCount-t.bottomFrozenRowCount;e++)i+=t.getRowHeight(e);const n=e/i;for(let i=t.frozenRowCount;i<t.rowCount-t.bottomFrozenRowCount;i++){let r;r=i===t.rowCount-t.bottomFrozenRowCount-1?e-t.getRowsHeight(t.frozenRowCount,t.rowCount-t.bottomFrozenRowCount-2):Math.round(t.getRowHeight(i)*n),this.setRowHeight(i,r)}}}dealFrozen(){!function(t){if(t.table.frozenColCount>t.table.rowHeaderLevelCount){t.rowHeaderGroup.setAttribute("height",t.bodyGroup.attribute.height),t.rowHeaderGroup.setAttribute("y",t.bodyGroup.attribute.y),t.cornerHeaderGroup.setAttribute("height",t.colHeaderGroup.attribute.height);for(let e=0;e<t.table.frozenColCount-t.table.rowHeaderLevelCount;e++)uR(t),pR(t)}else if(t.table.frozenColCount<t.table.rowHeaderLevelCount)for(let e=0;e<t.table.rowHeaderLevelCount-t.table.frozenColCount;e++)fR(t),gR(t);t.bodyGroup.setAttribute("x",t.rowHeaderGroup.attribute.width),t.colHeaderGroup.setAttribute("x",t.cornerHeaderGroup.attribute.width),t.updateContainer(),t.updateBorderSizeAndPosition(),t.isPivot||t.transpose||t.component.setFrozenColumnShadow(t.table.frozenColCount-1),t.hasFrozen=!0,t.frozenColCount=t.table.frozenColCount,t.frozenRowCount=t.colHeaderGroup.firstChild?.childrenCount??0}(this)}resetFrozen(){!function(t){if(t.frozenColCount>t.table.rowHeaderLevelCount)for(let e=0;e<t.frozenColCount-t.table.rowHeaderLevelCount;e++)fR(t),gR(t);else if(t.frozenColCount<t.table.rowHeaderLevelCount){t.rowHeaderGroup.setAttribute("height",t.bodyGroup.attribute.height),t.rowHeaderGroup.setAttribute("y",t.bodyGroup.attribute.y),t.cornerHeaderGroup.setAttribute("height",t.colHeaderGroup.attribute.height);for(let e=0;e<t.table.rowHeaderLevelCount-t.frozenColCount;e++)uR(t),pR(t)}t.bodyGroup.setAttribute("x",t.rowHeaderGroup.attribute.width),t.colHeaderGroup.setAttribute("x",t.cornerHeaderGroup.attribute.width),t.updateContainer(),t.updateBorderSizeAndPosition(),t.isPivot||t.transpose||t.component.setFrozenColumnShadow(t.table.frozenColCount-1),t.hasFrozen=!0,t.frozenColCount=t.table.rowHeaderLevelCount,t.frozenRowCount=t.colHeaderGroup.firstChild?.childrenCount??0}(this)}updateCellLayoutWidthCertainWidth(t,e,i){const n=t.attribute.width;let r=!1;return t.forEachChildren(((t,o)=>{o+=e;const s=_w(this.table,i,o);s?t=this.getCell(s.start.col,s.start.row):t.setAttribute("width",n);const a=Gw(OC("padding",this.table._getCellStyle(i,o),i,o,this.table)),l=t.getChildByName("text");let h=0,c=0;if(l)h=l.AABBBounds.height()+(a[0]+a[2]),l.setAttribute("maxLineWidth",n-(a[1]+a[3])),c=l.AABBBounds.height()+(a[0]+a[2]);else{const e=t.getChildAt(1);h=e.AABBBounds.height()+(a[0]+a[2]),e._cellWidth=n-(a[1]+a[3]),e.layout(),c=e.AABBBounds.height()+(a[0]+a[2])}const d=this.table.getRowHeight(o);t.attribute.height!==c&&(t.setAttribute("height",c),(d===h||c>d)&&(r=!0))})),r}updateHeaderPosition(t,e,i,n){!function(t,e,i,n,r){const o=r.scenegraph,s=r.getCellType(i,n),a="columnHeader"===s?"column":"rowHeader"===s?"row":void 0;let l=0,h=0,c=0,d=0,u=0,p=0,f=0,g=0;if("column"===a){const o=_w(r,t,e),s=_w(r,i,n);o&&s?(l=o.start.col,c=o.end.col,u=s.start.col,f=s.end.col):(l=t,c=t,u=i,f=i),h=e,d=r.rowCount-1,p=n,g=r.rowCount-1}else if("row"===a){const o=_w(r,t,e),s=_w(r,i,n);o&&s?(h=o.start.row,d=o.end.row,p=s.start.row,g=s.end.row):(h=e,d=e,p=n,g=n),l=t,c=r.colCount-1,u=i,f=r.colCount-1}const y=Math.min(l,u),m=Math.max(c,f),b=Math.min(h,p),v=Math.max(d,g);for(let t=y;t<=m;t++){const e=r.scenegraph.getColGroup(t,!0),i=r.scenegraph.getColGroup(t);e&&e.setAttribute("width",r.getColWidth(t)),i&&i.setAttribute("width",r.getColWidth(t))}o.updateContainer();for(let t=y;t<=m;t++){const e=r.scenegraph.getColGroup(t);e?.setAttribute("chartInstance",void 0);for(let e=b;e<=v;e++)o.updateCellContent(t,e)}}(t,e,i,n,this.table)}updateContainer(){let t=0;this.cornerHeaderGroup.forEachChildrenSkipChild(((e,i)=>{e.setAttribute("x",t),t+=e.attribute.width}));let e=0;this.rowHeaderGroup.forEachChildrenSkipChild(((t,i)=>{t.setAttribute("x",e),e+=t.attribute.width}));let i=0;this.colHeaderGroup.forEachChildrenSkipChild(((t,e)=>{t.setAttribute("x",i),i+=t.attribute.width}));let n=0;this.bodyGroup.forEachChildrenSkipChild(((t,e)=>{t.setAttribute("x",n),n+=t.attribute.width})),this.cornerHeaderGroup.setDeltaWidth(t-this.cornerHeaderGroup.attribute.width),this.colHeaderGroup.setDeltaWidth(i-this.colHeaderGroup.attribute.width),this.rowHeaderGroup.setDeltaWidth(e-this.rowHeaderGroup.attribute.width),this.bodyGroup.setDeltaWidth(n-this.bodyGroup.attribute.width),this.colHeaderGroup.setAttribute("x",this.cornerHeaderGroup.attribute.width),this.bodyGroup.setAttribute("x",this.rowHeaderGroup.attribute.width),this.updateTableSize();const r=this.table.stateManeger.scroll.horizontalBarPos,o=this.table.stateManeger.scroll.verticalBarPos;this.component.updateScrollBar(),this.table.stateManeger.setScrollLeft(r),this.table.stateManeger.setScrollTop(o),this.updateNextFrame()}updateCellContentWhileResize(t,e){const i=this.table.getBodyColumnType(t,e),n=this.getCell(t,e);"image"!==i&&"video"!==i||zC(n,t,e,this.table)}createFrameBorder(){this.updateTableSize();const t=!this.isPivot;eS(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,this.bodyGroup.role,t?[!0,!0,!0,!1]:void 0),eS(this.rowHeaderGroup,this.isPivot?this.table.theme.rowHeaderStyle.frameStyle:this.table.theme.bodyStyle.frameStyle,this.rowHeaderGroup.role,t?[!0,!1,!0,!0]:void 0),eS(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,this.colHeaderGroup.role,t?[!0,!0,!0,!1]:void 0),eS(this.cornerHeaderGroup,this.isPivot?this.table.theme.cornerHeaderStyle.frameStyle:this.table.theme.headerStyle.frameStyle,this.cornerHeaderGroup.role,t?[!0,!1,!0,!0]:void 0),eS(this.tableGroup,this.table.theme.frameStyle,this.tableGroup.role,void 0)}getResizeColAt(t,e,i,n=8){if(i){if(t<i.globalAABBBounds.x1+n)return{col:i.col-1,row:i.row,x:i.globalAABBBounds.x1};if(i.globalAABBBounds.x2-n<t)return{col:i.col,row:i.row,x:i.globalAABBBounds.x2}}else;return{col:-1,row:-1}}updateIcon(t,e){Cx(e,t),t.name=e.name,this.updateNextFrame()}updateFrozen(){this.clear||(this.resetFrozen(),this.dealFrozen(),this.component.updateScrollBar())}updateBorderSizeAndPosition(){this.bodyGroup.border&&(this.bodyGroup.appendChild(this.bodyGroup.border),rS(this.bodyGroup),0===this.rowHeaderGroup.attribute.width?iS(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,[!0,!0,!0,!0]):iS(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,[!0,!0,!0,!1])),this.colHeaderGroup.border&&(this.colHeaderGroup.appendChild(this.colHeaderGroup.border),rS(this.colHeaderGroup),0===this.cornerHeaderGroup.attribute.width?iS(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,[!0,!0,!0,!0]):iS(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,[!0,!0,!0,!1])),this.rowHeaderGroup.border&&(this.rowHeaderGroup.appendChild(this.rowHeaderGroup.border),rS(this.rowHeaderGroup)),this.cornerHeaderGroup.border&&(this.cornerHeaderGroup.appendChild(this.cornerHeaderGroup.border),rS(this.cornerHeaderGroup))}updateSortIcon(t,e,i,n,r,o,s){const a=this.table.internalProps.headerHelper.getSortIcon(n,this.table,t,e);if(i&&this.updateIcon(i,a),s!==i){const t=this.table.internalProps.headerHelper.getSortIcon("normal",this.table,r,o);if(s)this.updateIcon(s,t);else{let e;this.getCell(r,o).forEachChildren((t=>"sort"===t.attribute.funcType&&(e=t,!0))),e&&this.updateIcon(e,t)}}}updateFrozenIcon(t,e){const i=Math.max(t,e);this.colHeaderGroup.forEachChildrenSkipChild((t=>!(t.col<=i)||(t.forEachChildren((t=>{t.forEachChildren((e=>{if("frozen"===e.attribute.funcType){const i=this.table.internalProps.headerHelper.getFrozenIcon(t.col,t.row);return this.updateIcon(e,i),!0}return!1}))})),!1))),this.cornerHeaderGroup.forEachChildrenSkipChild((t=>!(t.col<=i)||(t.forEachChildren((t=>{t.forEachChildren((e=>{if("frozen"===e.attribute.funcType){const i=this.table.internalProps.headerHelper.getFrozenIcon(t.col,t.row);return this.updateIcon(e,i),!0}return!1}))})),!1)))}sortCell(){this.isPivot||(this.transpose?setTimeout((()=>{this.clearCells(),this.createSceneGraph()}),10):this.proxy.sortCell())}getCellOverflowText(t,e){const i=this.getCell(t,e).getChildByName("text",!0);if(i){const t=Ot(i.attribute.text)?i.attribute.text.join(""):i.attribute.text;let e="";if(It(i.cache.clipedText)?e=i.cache.clipedText:i.cache.layoutData.lines.forEach((t=>{e+=t.str})),e!==t)return t}return null}updateDrill(t,e,i,n,r){this.component.drillIcon.update(t,e,i,n,r,this)}updateCellContent(t,e){if(!this.clear)return $M(t,e,this.table)}setPixelRatio(t){this.stage.disableDirtyBounds(),this.stage.window.setDpr(t),this.stage.render(),this.stage.enableDirtyBounds()}updateHierarchyIcon(t,e){const i=this.getCell(t,e);let n;n=this.table.isHeader(t,e)?this.table.internalProps.headerHelper.getHierarchyIcon(i.col,i.row):this.table.internalProps.bodyHelper.getHierarchyIcon(i.col,i.row),this.findAndUpdateIcon(i,[l.collapse,l.expand],n)}updateRow(t,e){oR(t,e,this.table),this.recalculateColWidths(),"autoHeight"===this.table.heightMode&&this.recalculateRowHeights(),this.table.stateManeger.checkFrozen(),this.updateNextFrame()}findAndUpdateIcon(t,e,i){t.forEachChildren((t=>{if("group"===t.type)this.findAndUpdateIcon(t,e,i);else if(-1!==e.indexOf(t.attribute.funcType))return this.updateIcon(t,i),!0;return!1}))}}function mR(t,e,i){e.forEachChildren((e=>{"group"===e.type?mR(t,e,i):e.attribute.visibleTime===i&&(e.attribute.visible=!0,t.updateNextFrame())}))}function bR(t,e,i){e.forEachChildren((e=>{"group"===e.type?bR(t,e,i):e.attribute.visibleTime===i&&(e.attribute.visible=!1,t.updateNextFrame())}))}function vR(t,e,i){const n=t.getCell(e,i);if("shadow-cell"===n.role){t.getCell(n.mergeCol,n.mergeRow).addUpdateBoundTag()}else n.addUpdateBoundTag()}function wR(t,e,i,n,r){const o=t.table;for(let i=0;i<o.columnHeaderLevelCount;i++)vR(t,e,i);const s=t.getColGroup(e);return s?.addUpdateBoundTag(),!0}function CR(t,e,i,n,r,o){const s=t.table;for(let i=0;i<s.columnHeaderLevelCount;i++)vR(t,e,i);const a=t.getColGroup(e);return a?.addUpdateBoundTag(),!0}function xR(t,e,i,n,r){const o=t.table;for(let e=0;e<o.colCount;e++)vR(t,e,i);return!0}function _R(t,e,i,n,r,o){const s=t.table;for(let e=0;e<s.colCount;e++)vR(t,e,i);return!0}function SR(t,e,n){const{table:r}=t,{scenegraph:o}=r,{highlightScope:s,singleStyle:a,disableHeader:l,cellPos:h,cellPosContainHeader:c}=t.hover,d=h.col,u=h.row;if(s===i.none||l&&(c.col!==e||c.row!==n)){const t=c.col,i=c.row;o.hideHoverIcon(t,i),o.showHoverIcon(e,n),c.col=e,c.row=n}if((l&&r.isHeader(e,n)||s===i.none)&&(e=-1,n=-1),d===e&&u===n)return;o.deactivateChart(d,u),o.activateChart(e,n);let p=!1;const{ranges:f,highlightScope:g}=t.select;if(-1!==d&&-1!==u&&(p=function(t,e,n,r,o,s,a){let l=!1;s===i.single?l=!!function(t,e,i,n,r){return vR(t,e,i),!0}(t,e,n)||l:s===i.row?l=!!xR(t,0,n)||l:s===i.column?l=!!wR(t,e)||l:s===i.cross&&(l=!!xR(t,0,n)||l,l=!!wR(t,e)||l);return l}(o,d,u,0,0,s),l||o.hideHoverIcon(d,u)),-1===e||-1===n)return h.col=-1,h.row=-1,void(p&&t.table.scenegraph.updateNextFrame());s===i.single?p=!!function(t,e,i,n,r){return vR(t,e,i),!0}(o,e,n)||p:s===i.row?p=!!_R(o,0,n)||p:s===i.column?p=!!CR(o,e)||p:s===i.cross&&(p=!!_R(o,0,n)||p,p=!!CR(o,e)||p),s===i.none||l||o.showHoverIcon(e,n),h.col=e,h.row=n,p&&t.table.scenegraph.updateNextFrame()}function AR(t,e,i){let n,r=null,o=!1;if(Array.isArray(i.sortState))for(let s=0;s<i.sortState.length&&(n=i.sortState[s],n&&(r=i._getHeaderCellBySortState(n)),r&&(o=TR(t,e,r.col,r.row,i)),!o);s++);else n=i.sortState,n&&(r=i._getHeaderCellBySortState(n)),r&&(o=TR(t,e,r.col,r.row,i));const s=i.getHeaderDefine(t,e);n&&o&&s?.sort?n.order="asc"===n.order?"desc":"desc"===n.order?"normal":"asc":s?.sort?n={fieldKey:i.getHeaderFieldKey(t,e),field:i.getHeaderField(t,e),order:"asc"}:o&&s?.showSort||(n={fieldKey:i.getHeaderFieldKey(t,e),field:i.getHeaderField(t,e),order:"normal"}),i.sortState=n,i.stateManeger.setSortState(n),s?.sort&&function(t,e,i){let n;n=t.fieldKey?e.internalProps.layoutMap.headerObjects.find((e=>e&&e.fieldKey===t.fieldKey)):e.internalProps.layoutMap.headerObjects.find((e=>e&&e.field===t.field));if(!n)return;const{field:r}=n;if(null===r)return;"function"==typeof i.sort?e.dataSource.sort(r,t.order||"asc",i.sort):e.dataSource.sort(r,t.order||"asc",M)}(n,i,s),i.scenegraph.sortCell(),i.stateManeger.updateSelectPos(-1,-1),i.fireListeners(yt.SORT_CLICK,n)}function TR(t,e,i,n,r){return r._getLayoutCellId(t,e)===r._getLayoutCellId(i,n)}const BR=it(yt,{PIVOT_SORT_CLICK:"pivot_sort_click",DRILLMENU_CLICK:"drillmenu_click"}),MR=it(yt,{VCHART_EVENT_TYPE:"vchart_event_type"});function RR(t){if(!("canMoveHeaderPosition"in t.table.internalProps.layoutMap))return;setTimeout((()=>{t.columnMove.moving=!1}),0);t.table.moveHeaderPosition({col:t.columnMove.colSource,row:t.columnMove.rowSource},{col:t.columnMove.colTarget,row:t.columnMove.rowTarget})&&(!function(t,e,i,n,r){const o=Math.min(t,i),s=Math.max(t,i),a=Math.min(e,n),l=Math.max(e,n);for(let t=o;t<=s;t++)r._clearColRangeWidthsMap(t);for(let t=a;t<=l;t++)r._clearRowRangeHeightsMap(t)}(t.columnMove.colSource,t.columnMove.rowSource,t.columnMove.colTarget,t.columnMove.rowTarget,t.table),t.table.clearCellStyleCache(),t.table.scenegraph.updateHeaderPosition(t.columnMove.colSource,t.columnMove.rowSource,t.columnMove.colTarget,t.columnMove.rowTarget)),t.updateCursor(),t.table.scenegraph.component.hideMoveCol(),t.table.scenegraph.updateNextFrame()}function PR(t){if(!t)return;const e=t.role?.startsWith("icon")?t:"richtext"===t.type?t._currentHoverIcon:void 0;return e?"richtext"===t.type?{icon:e,position:{left:t.globalAABBBounds.x1+e.globalAABBBounds.x1,right:t.globalAABBBounds.x1+e.globalAABBBounds.x2,top:t.globalAABBBounds.y1+e.globalAABBBounds.y1,bottom:t.globalAABBBounds.y1+e.globalAABBBounds.y2,width:e.globalAABBBounds.x2-e.globalAABBBounds.x1,height:e.globalAABBBounds.y2-e.globalAABBBounds.y1},type:"richtext-icon"}:{icon:e,position:{left:e.globalAABBBounds.x1,right:e.globalAABBBounds.x2,top:e.globalAABBBounds.y1,bottom:e.globalAABBBounds.y2,width:e.globalAABBBounds.x2-e.globalAABBBounds.x1,height:e.globalAABBBounds.y2-e.globalAABBBounds.y1},type:"icon"}:void 0}class ER{table;interactionState;select;hover;hoverIcon;residentHoverIcon;columnResize;columnMove;menu;sort;frozen;scroll;tablePosition;drill;sparkLine;_clearVerticalScrollBar;_clearHorizontalScrollBar;constructor(t){this.table=t,this.initState(),this.setHoverState(),this.setSelectState(),this.setFrozenState(),this.updateVerticalScrollBar=this.updateVerticalScrollBar.bind(this),this.updateHorizontalScrollBar=this.updateHorizontalScrollBar.bind(this)}initState(){this.interactionState=e.default,this.select={highlightScope:i.single,ranges:[],cellPos:{col:-1,row:-1},selecting:!1},this.hover={highlightScope:i.single,cellPos:{col:-1,row:-1}},this.hoverIcon={col:-1,row:-1,icon:null},this.columnResize={col:-1,x:0,resizing:!1},this.columnMove={colSource:-1,colTarget:-1,rowSource:-1,rowTarget:-1,x:0,y:0,moving:!1},this.menu={x:-1,y:-1,isShow:!1,itemList:[],bounds:new pe,highlightIndex:-1,dropDownMenuHighlight:[]},this.sort={col:-1,row:-1,order:"normal"},this.frozen={col:-1},this.scroll={horizontalBarPos:0,verticalBarPos:0},this.tablePosition={absoluteX:0,absoluteY:0},this.drill={col:-1,row:-1},this.sparkLine={col:-1,row:-1}}setHoverState(){const{highlightMode:t,disableHover:e,disableHeaderHover:n}=this.table.options.hover??{highlightMode:"cell"};e?this.hover.highlightScope=i.none:"cross"===t?this.hover.highlightScope=i.cross:"row"===t?this.hover.highlightScope=i.row:"column"===t?this.hover.highlightScope=i.column:"cell"===t&&(this.hover.highlightScope=i.single),this.hover.singleStyle=!e,this.hover.disableHeader=n,(this.hover.highlightScope===i.none||n)&&(this.hover.cellPosContainHeader={col:-1,row:-1})}setSelectState(){const{disableSelect:t,disableHeaderSelect:e}=this.table.options?.select??{disableSelect:!1,disableHeaderSelect:!1};this.select.highlightScope=t?i.none:i.single,this.select.singleStyle=!t,this.select.disableHeader=e}isSelected(t,e){let i=!1;return this.select.ranges.forEach((n=>{at(n,t,e)&&(i=!0)})),i}setSortState(t){this.sort.field=t.field,this.sort.fieldKey=t.fieldKey,this.sort.order=t.order}setFrozenState(){this.frozen.col=this.table.frozenColCount-1}updateInteractionState(t){this.interactionState!==t&&(this.interactionState=t)}updateHoverhighlightScope(t){this.hover.highlightScope!==t&&(this.hover.highlightScope=t)}updateHoverPos(t,e){SR(this,t,e)}updateSelectPos(t,i,n=!1,r=!1,o=!1){-1!==i&&-1!==i&&(this.select.selecting=!0),function(t,i,n,r,o,s){const{table:a,interactionState:l}=t,{scenegraph:h}=a,{highlightScope:c,disableHeader:d,cellPos:u}=t.select;if((d&&a.isHeader(i,n)||"none"===c)&&(i=-1,n=-1),u.col!==i||u.row!==n){if(-1!==i&&-1!==n&&t.select.ranges.length>0)if(l===e.grabing){const e=t.select.ranges[t.select.ranges.length-1];i>e.start.col&&i>e.end.col&&a._makeVisibleCell(i+1,n),n>e.start.row&&n>e.end.row&&a._makeVisibleCell(i,n+1),i<e.start.col&&i<e.end.col&&a._makeVisibleCell(i-1,n),n<e.start.row&&n<e.end.row&&a._makeVisibleCell(i,n-1)}else a._makeVisibleCell(i,n);if(s){t.select.ranges=[],h.deleteAllSelectBorder(),t.select.ranges.push({start:{col:0,row:0},end:{col:a.colCount-1,row:a.rowCount-1}});const e=t.select.ranges[t.select.ranges.length-1];h.updateCellSelectBorder(e.start.col,e.start.row,e.end.col,e.end.row)}else if(-1===u.col||-1===u.row||-1!==i&&-1!==n){if(l===e.default){const e=t.select.ranges[t.select.ranges.length-1];if(r&&e){if(a.isColumnHeader(i,n)){const t=Math.min(e.start.col,e.end.col,i),r=Math.max(e.start.col,e.end.col,i),o=Math.min(e.start.row,e.end.row,n),s=a.rowCount-1;e.start={col:t,row:o},e.end={col:r,row:s}}else if(a.isRowHeader(i,n)){const t=Math.min(e.start.col,e.end.col,i),r=a.colCount-1,o=Math.min(e.start.row,e.end.row,n),s=Math.max(e.start.row,e.end.row,n);e.start={col:t,row:o},e.end={col:r,row:s}}else e.end={col:i,row:n};h.deleteLastSelectedRangeComponents(),h.updateCellSelectBorder(e.start.col,e.start.row,e.end.col,e.end.row)}else{-1===u.col||-1===u.row||o||(t.select.ranges=[],h.deleteAllSelectBorder()),a.isColumnHeader(i,n)?t.select.ranges.push({start:{col:i,row:n},end:{col:i,row:a.rowCount-1}}):a.isRowHeader(i,n)?t.select.ranges.push({start:{col:i,row:n},end:{col:a.colCount-1,row:n}}):t.select.ranges.push({start:{col:i,row:n},end:{col:i,row:n}}),u.col=i,u.row=n;const e=t.select.ranges[t.select.ranges.length-1];h.updateCellSelectBorder(e.start.col,e.start.row,e.end.col,e.end.row)}}else if(l===e.grabing){-1===u.col&&(u.col=i),-1===u.row&&(u.row=n);const e=t.select.ranges[t.select.ranges.length-1];e.end={col:i,row:n},u.col=i,u.row=n,h.updateCellSelectBorder(e.start.col,e.start.row,i,n)}}else u.col=-1,u.row=-1,t.select.ranges=[],h.deleteAllSelectBorder();h.updateNextFrame()}}(this,t,i,n,r,o)}checkCellRangeInSelect(t,e){return function(t,e,i,n){for(let n=0;n<i.length;n++)if(ht(i[n],{start:t,end:e}))return!0;return!1}(t,e,this.select.ranges,this.select.highlightScope)}updateHoverIcon(t,e,i,n,r){if(i===this.residentHoverIcon?.icon)return;const o=PR(i);if(o)if("richtext-icon"===o.type){const i=o.icon;if(this.hoverIcon.icon&&this.hoverIcon.icon!==this.residentHoverIcon?.icon&&(this.table.scenegraph.setIconNormalStyle(this.hoverIcon.icon,this.hoverIcon.col,this.hoverIcon.row),this.hoverIcon.col=-1,this.hoverIcon.col=-1,this.hoverIcon.icon=null,this.table.scenegraph.updateNextFrame()),i.attribute.tooltip){const n={content:i.attribute.tooltip.title,referencePosition:{rect:o.position,placement:i.attribute.tooltip.placement},style:Object.assign({},this.table.internalProps.theme?.tooltipStyle,i.tooltip?.style)};this.table.internalProps.tooltipHandler.isBinded(n)||this.table.showTooltip(t,e,n)}}else{const i=o.icon;i!==this.hoverIcon.icon&&(this.hoverIcon.icon&&this.hoverIcon.icon!==this.residentHoverIcon?.icon&&this.table.scenegraph.setIconNormalStyle(this.hoverIcon.icon,this.hoverIcon.col,this.hoverIcon.row),this.hoverIcon.col=t,this.hoverIcon.col=e,this.hoverIcon.icon=i,this.table.scenegraph.setIconHoverStyle(i,t,e,n),this.table.scenegraph.updateNextFrame())}else this.hoverIcon.icon&&this.hoverIcon.icon!==this.residentHoverIcon?.icon&&(this.table.scenegraph.setIconNormalStyle(this.hoverIcon.icon,this.hoverIcon.col,this.hoverIcon.row),this.hoverIcon.col=-1,this.hoverIcon.col=-1,this.hoverIcon.icon=null,this.table.scenegraph.updateNextFrame())}isResizeCol(){return this.columnResize.resizing}isSelecting(){return this.select.selecting}endSelectCells(){if(this.select.selecting=!1,0===this.select.ranges.length)return;this.table.scenegraph.moveSelectingRangeComponentsToSelectedRangeComponents();const t=this.select.ranges[this.select.ranges.length-1].end.col,e=this.select.ranges[this.select.ranges.length-1].end.row;this.table.fireListeners(yt.SELECTED_CELL,{ranges:this.select.ranges,col:t,row:e})}endResizeCol(){setTimeout((()=>{this.columnResize.resizing=!1}),0),this.table.scenegraph.updateChartSize(this.columnResize.col),this.checkFrozen(),this.table.scenegraph.component.hideResizeCol(),this.table.scenegraph.updateNextFrame()}startResizeCol(t,e,i){this.columnResize.resizing=!0,this.columnResize.col=t,this.columnResize.x=e,this.table.scenegraph.component.showResizeCol(t,i),this.table.stateManeger.updateSelectPos(-1,-1),this.table.scenegraph.updateNextFrame()}updateResizeCol(t,e){t=Math.ceil(t),e=Math.ceil(e);let i=t-this.columnResize.x;if(Math.abs(i)<1)return;let n=this.table.colWidthsMap.get(this.columnResize.col);"number"==typeof n||(n=this.table.getColWidth(this.columnResize.col));let r=n;r+=i;const o=this.table.getMinColWidth(this.columnResize.col),s=this.table.getMaxColWidth(this.columnResize.col);if(r<o||r>s){if(n===o||n===s)return;i=n-o>s-n?s-n:o-n}i=Math.ceil(i),this.table.scenegraph.updateColWidth(this.columnResize.col,i),"adaptive"===this.table.widthMode&&this.columnResize.col<this.table.colCount-1&&this.table.scenegraph.updateColWidth(this.columnResize.col+1,-i),this.columnResize.x=t,this.table.scenegraph.component.updateResizeCol(this.columnResize.col,e),this.columnResize.col<this.table.frozenColCount&&!this.table.isPivotTable()&&!this.table.transpose&&this.table.scenegraph.component.setFrozenColumnShadow(this.table.frozenColCount-1),this.table.scenegraph.updateNextFrame()}startMoveCol(t,e,i,n){!function(t,e,i,n,r){if(!("canMoveHeaderPosition"in r.table.internalProps.layoutMap))return;r.columnMove.moving=!0,r.columnMove.colSource=t,r.columnMove.rowSource=e,r.columnMove.x=i-r.table.tableX,r.columnMove.y=n-r.table.tableY;const o=r.table.getCellType(t,e),s="columnHeader"===o?r.columnMove.x:"rowHeader"===o?r.columnMove.y:0;r.table.scenegraph.component.showMoveCol(t,e,s),r.table.stateManeger.updateSelectPos(-1,-1),r.table.scenegraph.updateNextFrame()}(t,e,i,n,this)}updateMoveCol(t,e,i,n){!function(t,e,i,n,r){if(!("canMoveHeaderPosition"in r.table.internalProps.layoutMap))return;const o=function(t,e,i){const n=i.getCellRange(t.col,t.row);if(i.isColumnHeader(t.col,t.row)){const r=i.getCellRange(e.col,n.start.row);e.row>=i.columnHeaderLevelCount&&(e.row=i.columnHeaderLevelCount-1),e.col>=t.col?e.col=r.end.col:e.col=r.start.col}else if(i.isRowHeader(t.col,t.row)){const r=i.getCellRange(n.start.col,e.row);e.col>=i.rowHeaderLevelCount&&(e.col=i.rowHeaderLevelCount-1);const o=i.internalProps.layoutMap;if("tree"===o.rowHierarchyType){const n=o.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths,r=o.getCellHeaderPathsWidthTreeNode(e.col,e.row).rowHeaderPaths;if(n.length<=r.length){const o=r[n.length-1];o&&(e.row>=t.row?e.row=o.startInTotal+o.size-1+i.columnHeaderLevelCount:e.row=o.startInTotal+i.columnHeaderLevelCount)}}else e.row>=t.row?e.row=r.end.row:e.row=r.start.row}return e}({col:r.columnMove.colSource,row:r.columnMove.rowSource},{col:t,row:e},r.table);let s,a,l,h;r.columnMove.x=i-r.table.tableX,r.columnMove.y=n-r.table.tableY,r.columnMove.colTarget=o.col,r.columnMove.rowTarget=o.row,r.table.internalProps.layoutMap.canMoveHeaderPosition({col:r.columnMove.colSource,row:r.columnMove.rowSource},{col:r.columnMove.colTarget,row:r.columnMove.rowTarget})?r.updateCursor("grabbing"):r.updateCursor("not-allowed");const c=r.table.getCellType(t,e);"columnHeader"===c?(a=r.columnMove.x,s=r.columnMove.colTarget>=r.columnMove.colSource?r.table.getColsWidth(0,r.columnMove.colTarget):r.table.getColsWidth(0,r.columnMove.colTarget-1)):"rowHeader"===c&&(h=r.columnMove.y,l=r.columnMove.rowTarget>=r.columnMove.rowSource?r.table.getRowsHeight(0,r.columnMove.rowTarget):r.table.getRowsHeight(0,r.columnMove.rowTarget-1)),r.table.scenegraph.component.updateMoveCol(a,s,h,l),r.table.scenegraph.updateNextFrame()}(t,e,i,n,this)}isMoveCol(){return this.columnMove.moving}endMoveCol(){RR(this)}checkFrozen(){if(this.table.options.frozenColCount){if(this.table.tableNoFrameWidth-this.table.getColsWidth(0,this.table.options.frozenColCount-1)<=120)return this.table._setFrozenColCount(0),this.setFrozenCol(-1),!1;if(this.table.frozenColCount!==this.table.options.frozenColCount)return this.table._setFrozenColCount(this.table.options.frozenColCount),this.setFrozenCol(this.table.options.frozenColCount),!1}return!0}setFrozenCol(t){t!==this.frozen.col?(this.frozen.col=t,this.table.scenegraph.updateFrozen(),this.table.scenegraph.updateFrozenIcon(0,this.table.colCount-1)):this.table.scenegraph.updateFrozenIcon(0,this.table.colCount-1)}updateVerticalScrollBar(t){const e=this.table.getAllRowsHeight();this.scroll.verticalBarPos=Math.ceil(t*(e-this.table.scenegraph.height)),this.table.scenegraph.setY(-this.scroll.verticalBarPos),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(yt.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}updateHorizontalScrollBar(t){const e=this.table.getAllColsWidth();this.scroll.horizontalBarPos=Math.ceil(t*(e-this.table.scenegraph.width)),this.table.scenegraph.setX(-this.scroll.horizontalBarPos),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(yt.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}setScrollTop(t){const e=this.table.getAllRowsHeight();t=Math.max(0,Math.min(t,e-this.table.scenegraph.height)),t=Math.ceil(t),this.scroll.verticalBarPos=t,this.table.scenegraph.setY(-t),this.table.scenegraph.component.updateVerticalScrollBarPos(t/(e-this.table.scenegraph.height)),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(yt.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}setScrollLeft(t){const e=this.table.getAllColsWidth(),i=this.table.getFrozenColsWidth();t=Math.max(0,Math.min(t,e-this.table.scenegraph.width)),t=Math.ceil(t),this.scroll.horizontalBarPos=t,this.table.scenegraph.setX(-t),this.table.scenegraph.component.updateHorizontalScrollBarPos(t/(e-i)),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(yt.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}hideVerticalScrollBar(){this.table.scenegraph.component.hideVerticalScrollBar()}showVerticalScrollBar(t){this.table.scenegraph.component.showVerticalScrollBar(),t&&(clearTimeout(this._clearVerticalScrollBar),this._clearVerticalScrollBar=setTimeout((()=>{this.table.scenegraph.component.hideVerticalScrollBar()}),1e3))}hideHorizontalScrollBar(){this.table.scenegraph.component.hideHorizontalScrollBar()}showHorizontalScrollBar(t){this.table.scenegraph.component.showHorizontalScrollBar(),t&&(clearTimeout(this._clearHorizontalScrollBar),this._clearHorizontalScrollBar=setTimeout((()=>{this.table.scenegraph.component.hideHorizontalScrollBar()}),1e3))}triggerContextMenu(t,e,i,n){this.menu.isShow&&this.menu.x===i&&this.menu.y===n?this.hideMenu():this.showContextMenu(t,e,i,n)}showContextMenu(t,e,i,n){this.table.internalProps.menu?.contextMenuItems&&("html"===this.table.internalProps.menu.renderMode?this.menu.isShow=!0:(this.menu.isShow=!0,this.menu.x=i,this.menu.y=n,this.table.scenegraph.component.menu.attach(i,n,t,e,X_.contextmenu)),this.table.fireListeners(yt.SHOW_MENU,{x:i,y:n,col:t,row:e,type:"contextmenu"}))}triggerDropDownMenu(t,e,i,n){this.table.fireListeners(yt.DROPDOWN_ICON_CLICK,{col:t,row:e}),this.menu.isShow?this.hideMenu():this.showDropDownMenu(t,e,i,n)}showDropDownMenu(t,e,i,n){"html"===this.table.internalProps.menu.renderMode?this.menu.isShow=!0:(this.menu.isShow=!0,this.table.scenegraph.component.menu.attach(i,n,t,e,X_.dropDown),this.menu.bounds=this.table.scenegraph.component.menu.bounds),this.table.fireListeners(yt.SHOW_MENU,{x:i,y:n,col:t,row:e,type:"dropDown"}),this.residentHoverIcon&&this.table.scenegraph.setIconNormalStyle(this.residentHoverIcon.icon,this.residentHoverIcon.col,this.residentHoverIcon.row);const r=this.table.scenegraph.getCell(t,e);let o;r.forEachChildren((t=>t.attribute.funcType===l.dropDown&&(o=t,!0))),o&&(this.residentHoverIcon={col:t,row:e,icon:o},this.table.scenegraph.setIconHoverStyle(this.residentHoverIcon.icon,this.residentHoverIcon.col,this.residentHoverIcon.row,r),o.oldVisibleTime=o.attribute.visibleTime,o.setAttribute("visibleTime","always"),o.setAttribute("visible",!0))}hideMenu(){this.table.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),this.table.fireListeners(yt.HIDE_MENU,null),this.menu.isShow=!1,this.table.scenegraph.component.menu.detach(),this.residentHoverIcon&&(this.table.scenegraph.setIconNormalStyle(this.residentHoverIcon.icon,this.residentHoverIcon.col,this.residentHoverIcon.row),this.residentHoverIcon.icon.setAttribute("visibleTime",this.residentHoverIcon.icon.oldVisibleTime),this.residentHoverIcon.icon.setAttribute("visible","always"===this.residentHoverIcon.icon.attribute.visibleTime),this.residentHoverIcon=null)}setDropDownMenuHighlight(t){this.menu.dropDownMenuHighlight=t;for(let e=0;e<t.length;e++){const{col:i,row:n}=t[e];this.table.scenegraph.updateCellContent(i,n)}}dropDownMenuIsHighlight(t,e,i){const n=this.menu.dropDownMenuHighlight;if(Array.isArray(n))for(let r=0;r<n.length;r++){const o=n[r];let{col:s,row:a}=o;const{field:l,menuKey:h}=o;if("number"!=typeof s||"number"!=typeof a)if(this.table.isPivotTable()&&(Array.isArray(l),1)){const t=this.table.internalProps.layoutMap.getPivotCellAdress(l);if(!t)continue;s=t.col,a=t.row}else{const t=this.table.internalProps.layoutMap.getHeaderCellAddressByField(l);if(!t)continue;s=t.col,a=t.row}if(A(s)&&A(a)&&this.table.isCellRangeEqual(t,e,s,a)){const n=this.table._getHeaderLayoutMap(s??t,a??e).dropDownMenu||this.table.globalDropDownMenu;if(n)for(let t=0;t<n.length;t++){const e=n[t];if(u(e)&&(e.menuKey||e.text)===(h||"")&&t===i)return!0;if(f(e)&&e===h&&t===i)return!0}}}return!1}triggerSort(t,e,i){if(this.table.isPivotTable()){const i=this.table.getPivotSortState(t,e);return void this.table.fireListeners(BR.PIVOT_SORT_CLICK,{col:t,row:e,order:i||"normal",dimensionInfo:this.table.internalProps.layoutMap.getPivotDimensionInfo(t,e),cellType:this.table.getCellType(t,e)})}const n=this.sort.col,r=this.sort.row;AR(t,e,this.table),this.sort.col=t,this.sort.row=e,this.table.scenegraph.updateSortIcon(this.sort.col,this.sort.row,i,this.sort.order,n,r,this.sort.icon),this.sort.icon=i}updateSortState(t){if(t.field===this.sort.field&&t.order===this.sort.order)return;const e=this.sort.col,i=this.sort.row,n="asc"===this.sort.order?"sort_downward":"desc"===this.sort.order?"sort_upward":"sort_normal";this.setSortState(t);const r=this.table.internalProps.layoutMap.getHeaderCellAddressByField(t.field);this.sort.col=r.col,this.sort.row=r.row;const o=this.table.scenegraph.getCell(this.sort.col,this.sort.row).getChildByName(n,!0);this.table.scenegraph.sortCell(),this.table.scenegraph.updateSortIcon(this.sort.col,this.sort.row,o,this.sort.order,e,i,this.sort.icon)}triggerFreeze(t,e,i){this.table.isPivotTable()||this.table.transpose||(!function(t,e,i){i.frozenColCount>0?t!==i.frozenColCount-1?i.setFrozenColCount(t+1):i.setFrozenColCount(0):i.setFrozenColCount(t+1)}(t,0,this.table),this.frozen.icon=i)}updateCursor(t="default"){this.table.getElement().style.cursor=t}updateDrillState(t,e,i,n,r,o){this.drill.dimensionKey=t,this.drill.dimensionTitle=e,this.drill.drillDown=i,this.drill.drillUp=n,this.drill.col=r,this.drill.row=o,function(t,e,i,n,r){const o=r.getCellType(t,e);let s=0,a=0,l=!1;"columnHeader"===o?(s=r.getColsWidth(0,r.rowHeaderLevelCount-1)-(0===r.frozenColCount?r.scrollLeft:0),a=r.getRowsHeight(0,e-1)+r.getRowHeight(e)/2,l=!0):"rowHeader"===o&&(a=r.getRowsHeight(0,r.columnHeaderLevelCount-1),s=r.getColsWidth(0,t-1)+r.getColWidth(t)/2,l=!0),r.scenegraph.updateDrill(l,s,a,i,n)}(r,o,i,n,this.table)}updateSparklineHoverPose(t,e,i,n){-1!==this.sparkLine.col&&-1!==this.sparkLine.row&&function(t,e,i){const n=i.scenegraph.getCell(t,e).getChildByName("sparkline"),r=n?.getChildByName("highlight-line"),o=n?.getChildByName("highlight-symbol");r&&r.setAttributes({visible:!1,pickable:!1}),o&&o.setAttributes({visible:!1,pickable:!1}),i.scenegraph.updateNextFrame()}(this.sparkLine.col,this.sparkLine.row,this.table),-1!==t&&-1!==e&&function(t,e,i,n,r){const o=r.scenegraph.getCell(t,e).getChildByName("sparkline"),s=o?.getChildByName("sparkline-line"),a=o?.getChildByName("sparkline-symbol-group");if(!s)return;const l=s.bandwidth,h=s.min,c=s.max,d=s.attribute.points;let u;i-=o.globalAABBBounds.x1,o.globalAABBBounds.y1;for(let t=0;t<d.length;t++){const{x:e,y:n,defined:r,rawData:p}=d[t];if(Math.abs(i-e)<l/2&&(u={point:d[t],points:d,pointsBandWidth:l,pointData:p},r)){const t=o.getChildByName("highlight-line");if(t)t.setAttributes({x:e,visible:!0,pickable:!0});else{const t=cu({x:e,y:0,points:[{x:0,y:c},{x:0,y:h}],lineWidth:s.hover.strokeWidth,stroke:s.hover.stroke});t.name="highlight-line",o.addChild(t)}const i=o.getChildByName("highlight-symbol");if(i)i.setAttributes({x:e,y:n,visible:!0,pickable:!0});else{const t=fu({x:e,y:n,stroke:a.hover.stroke,lineWidth:a.hover.strokeWidth,fill:a.hover.fill,size:2*a.hover.size,symbolType:"circle"});t.name="highlight-symbol",o.addChild(t)}break}}if(r.scenegraph.updateNextFrame(),u){const i={col:t,row:e,field:r.getHeaderField(t,e),value:r.getCellValue(t,e),dataValue:r.getCellOriginValue(t,e),cellHeaderPaths:r.internalProps.layoutMap.getCellHeaderPaths(t,e),caption:r.getBodyColumnDefine(t,e).caption,cellRange:r.getCellRelativeRect(t,e),sparkline:{pointData:u.pointData},scaleRatio:r.canvas.getBoundingClientRect().width/r.canvas.offsetWidth};r.fireListeners(yt.MOUSEOVER_CHART_SYMBOL,i)}}(t,e,i,0,this.table),this.sparkLine.col=t,this.sparkLine.row=e}}function HR(t){const e={abstractPos:{x:t.x,y:t.y}},i=function(t){for(;t&&t.parent;){if("cell"===t.role)return t;t=t.parent}return null}(t.target);return i&&(e.eventArgs={col:i.col,row:i.row,event:t,targetCell:i,target:t.target}),e}function kR(t,e){let{deltaX:i,deltaY:n}=t;t.shiftKey&&t.deltaY&&(i=n,n=0);const[r,o]=function(t,e,i){const n=2,r=Math.abs(t/e),o=r<=1/n?0:t,s=r>n?0:e;return[Math.ceil(o*i.horizontal),Math.ceil(s*i.vertical)]}(i,n,{horizontal:1,vertical:1});r&&(e.setScrollLeft(e.scroll.horizontalBarPos+r),e.showHorizontalScrollBar(!0)),o&&(e.setScrollTop(e.scroll.verticalBarPos+o),e.showVerticalScrollBar(!0)),t.cancelable&&(0!==n&&LR(n,e)||0!==i&&IR(i,e))&&t.preventDefault()}function LR(t,e){return!function(t,e){const i=e.table.getAllRowsHeight()-e.table.scenegraph.height;return 0!==i&&t<=0&&e.scroll.verticalBarPos<1}(t,e)&&!function(t,e){const i=e.table.getAllRowsHeight()-e.table.scenegraph.height;return 0!==i&&t>=0&&Math.abs(e.scroll.verticalBarPos-i)<1}(t,e)}function IR(t,e){return!function(t,e){const i=e.table.getAllColsWidth()-e.table.scenegraph.width;return 0!==i&&t<=0&&e.scroll.horizontalBarPos<1}(t,e)&&!function(t,e){const i=e.table.getAllColsWidth()-e.table.scenegraph.width;return 0!==i&&t>=0&&Math.abs(e.scroll.horizontalBarPos-i)<1}(t,e)}function OR(t){const e=t.table,i=e.stateManeger,n=e.scenegraph;t.touchMovePoints=[],e.scenegraph.tableGroup.addEventListener("touchstart",(e=>{e.target.isChildOf(n.component.vScrollBar)||e.target.isChildOf(n.component.vScrollBar)||(t.isTouchdown=!0,t.touchMovePoints.push({x:e.page.x,y:e.page.y,timestamp:Date.now()}))})),window.addEventListener("touchmove",(e=>{if(t.touchMove&&e.preventDefault(),!t.isTouchdown||!DR(e))return;t.touchMovePoints.length>4&&t.touchMovePoints.shift(),t.touchMovePoints.push({x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY,timestamp:Date.now()});const n=-t.touchMovePoints[t.touchMovePoints.length-1].x+t.touchMovePoints[t.touchMovePoints.length-2].x,r=-t.touchMovePoints[t.touchMovePoints.length-1].y+t.touchMovePoints[t.touchMovePoints.length-2].y;kR({deltaX:n,deltaY:r},i),e.cancelable&&(0!==r&&LR(r,i)||0!==n&&IR(n,i))&&e.preventDefault()}),{passive:!1}),window.addEventListener("touchend",(e=>{if(t.touchEnd=!0,t.touchMove=!1,t.isTouchdown&&DR(e)){if(t.touchMovePoints?.length){t.touchMovePoints.length>4&&t.touchMovePoints.shift(),t.touchMovePoints.push({x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY,timestamp:Date.now()});const n=t.touchMovePoints[0],r=t.touchMovePoints[t.touchMovePoints?.length-1];!function(t,e,i){let n=Date.now();const r=.95,o=()=>{const s=Date.now(),a=s-n;let l=!0;const h=Math.pow(r,a/16),c=h*t,d=h*e;let u=0,p=0;Math.abs(c)>.05&&(l=!1,u=(t+c)/2*a),Math.abs(d)>.05&&(l=!1,p=(e+d)/2*a),kR({deltaX:-u,deltaY:-p},i),l||(n=s,t=c,e=d,requestAnimationFrame(o))};requestAnimationFrame(o)}((r.x-n.x)/(r.timestamp-n.timestamp),(r.y-n.y)/(r.timestamp-n.timestamp),i)}t.isTouchdown=!1,t.touchMovePoints=[]}})),window.addEventListener("touchcancel",(e=>{t.touchEnd=!0,t.touchMove=!1,t.isTouchdown&&(t.isTouchdown=!1,t.touchMovePoints=[])}))}function DR(t){return!!t.changedTouches}class FR{table;isTouchdown;touchMovePoints;touchSetTimeout;touchEnd;touchMove;constructor(t){this.table=t,this.bindOuterEvent(),setTimeout((()=>{this.bindSelfEvent()}),0)}bindOuterEvent(){!function(t){const i=t.table,n=i.stateManeger;i.scenegraph.tableGroup.addEventListener("pointermove",(r=>{t.touchSetTimeout&&(clearTimeout(t.touchSetTimeout),t.touchSetTimeout=void 0);const o=HR(r);if(n.interactionState!==e.scrolling)if(n.interactionState!==e.grabing){if(t.checkColumnResize(o)?n.updateCursor("col-resize"):n.updateCursor(),i.hasListeners(yt.MOUSELEAVE_CELL)){const t=o?.eventArgs?.target;"cell"!==t?.role||-1===i.stateManeger.hover.cellPos.col||-1===i.stateManeger.hover.cellPos.row||t.col===i.stateManeger.hover.cellPos.col&&t.row===i.stateManeger.hover.cellPos.row||i.fireListeners(yt.MOUSELEAVE_CELL,{col:i.stateManeger.hover.cellPos.col,row:i.stateManeger.hover.cellPos.row,cellRange:i.getCellRangeRelativeRect({col:i.stateManeger.hover.cellPos.col,row:i.stateManeger.hover.cellPos.row}),scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth,event:r.nativeEvent})}if(i.hasListeners(yt.MOUSEENTER_CELL)){const t=o?.eventArgs?.target;"cell"===t?.role&&kt(t.col)&&kt(t.row)&&(t.col!==i.stateManeger.hover.cellPos.col||t.row!==i.stateManeger.hover.cellPos.row)&&i.fireListeners(yt.MOUSEENTER_CELL,{col:t.col,row:t.row,cellRange:i.getCellRangeRelativeRect({col:t.col,row:t.row}),scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth,event:r.nativeEvent})}if(t.dealIconHover(o),t.dealTableHover(o),o.eventArgs&&i.hasListeners(yt.MOUSEMOVE_CELL)){let t,e;if(o.eventArgs?.target){const i=PR(o.eventArgs?.target);i&&(t=i.icon,e=i.position)}i.fireListeners(yt.MOUSEMOVE_CELL,{col:o.eventArgs.col,row:o.eventArgs.row,x:o.abstractPos.x,y:o.abstractPos.y,event:r.nativeEvent,targetIcon:t?{name:t.name,position:e,funcType:t.attribute.funcType}:void 0})}}else n.isResizeCol()?(t.dealColumnResize(o),o.eventArgs&&i.hasListeners(yt.RESIZE_COLUMN)&&i.fireListeners(yt.RESIZE_COLUMN,{col:i.stateManeger.columnResize.col,colWidth:i.getColWidth(i.stateManeger.columnResize.col)})):n.isMoveCol()?t.dealColumnMover(o):t.dealTableSelect(o)})),i.scenegraph.tableGroup.addEventListener("pointerout",(e=>{const i=HR(e),n=i?.eventArgs?.target;"table"===n?.role&&t.dealTableHover()})),i.scenegraph.tableGroup.addEventListener("pointerover",(t=>{const e=HR(t),n=e?.eventArgs?.target;if(i.hasListeners(yt.MOUSEOVER_CHART_SYMBOL)&&"symbol"===n.type){const e=t.composedPath().find((t=>"cell"===t.roll));if(e){const{col:n,row:r}=e,o={col:n,row:r,field:i.getHeaderField(n,r),value:i.getCellValue(n,r),dataValue:i.getCellOriginValue(n,r),cellHeaderPaths:i.internalProps.layoutMap.getCellHeaderPaths(n,r),caption:i.getBodyColumnDefine(n,r).caption,cellRange:i.getCellRelativeRect(n,r),event:t.nativeEvent,sparkline:{pointData:void 0},scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth};i.fireListeners(yt.MOUSEOVER_CHART_SYMBOL,o)}}})),i.scenegraph.tableGroup.addEventListener("pointerleave",(r=>{n.updateInteractionState(e.default),t.dealTableHover(),n.updateCursor();const o=r.target;o&&!o.isDescendantsOf(i.scenegraph.tableGroup)&&i.fireListeners(yt.MOUSELEAVE_TABLE,{col:-1,row:-1,event:r.nativeEvent})})),i.scenegraph.tableGroup.addEventListener("pointerupoutside",(i=>{console.log("pointerupoutside"),n.updateInteractionState(e.default),t.dealTableHover(),t.dealTableSelect()})),i.scenegraph.tableGroup.addEventListener("pointerdown",(r=>{if(0!==r.button)return;const o=HR(r);if(n.interactionState===e.default){if(i.isPivotChart()&&"chart"!==o?.eventArgs?.target.type&&i.scenegraph.updateChartState(null),n.menu.isShow&&o.eventArgs&&o.eventArgs.target!==n.residentHoverIcon?.icon&&n.hideMenu(),!(o?.eventArgs?.target?.role?.startsWith("icon")?o.eventArgs.target:void 0))if("touch"===r.pointerType)t.touchEnd=!1,t.touchSetTimeout=setTimeout((()=>{t.isTouchdown=!1,t.touchMove=!0,(!t.touchEnd&&t.checkColumnResize(o,!0)||!t.touchEnd&&t.chechColumnMover(o)||t.dealTableSelect(o)&&!t.touchEnd)&&n.updateInteractionState(e.grabing)}),500);else{if(t.checkColumnResize(o,!0))return i.scenegraph.updateChartState(null),void n.updateInteractionState(e.grabing);if(t.chechColumnMover(o))return void n.updateInteractionState(e.grabing);t.dealTableSelect(o)&&n.updateInteractionState(e.grabing)}if(i.hasListeners(yt.MOUSEDOWN_CELL)){const t=HR(r);t.eventArgs&&i.fireListeners(yt.MOUSEDOWN_CELL,{col:t.eventArgs.col,row:t.eventArgs.row,event:r.nativeEvent})}}})),i.scenegraph.tableGroup.addEventListener("pointerup",(t=>{if(0===t.button){if("grabing"===n.interactionState){if(n.updateInteractionState(e.default),n.isResizeCol()){if(i.stateManeger.endResizeCol(),i.hasListeners(yt.RESIZE_COLUMN_END)){const t=[];for(let e=0;e<i.colCount;e++)t.push(i.getColWidth(e));i.fireListeners(yt.RESIZE_COLUMN_END,{col:i.stateManeger.columnResize.col,columns:t})}}else if(n.isMoveCol()){i.stateManeger.endMoveCol();const e=HR(t);e.eventArgs&&i.hasListeners(yt.CHANGE_HEADER_POSITION)&&i.fireListeners(yt.CHANGE_HEADER_POSITION,{target:{col:e.eventArgs.col,row:e.eventArgs.row},source:{col:i.stateManeger.columnMove.colSource,row:i.stateManeger.columnMove.colSource}})}else if(n.isSelecting()){i.stateManeger.endSelectCells();const e=HR(t);if(e.eventArgs&&i.hasListeners(yt.DRAG_SELECT_END)){const n={event:t.nativeEvent,cells:[],col:e.eventArgs.target.col,row:e.eventArgs.target.row,scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth};n.cells=i.getSelectedCellInfos(),i.fireListeners(yt.DRAG_SELECT_END,n)}}}else n.interactionState===e.scrolling&&n.updateInteractionState(e.default);if(i.hasListeners(yt.MOUSEUP_CELL)){const e=HR(t);e.eventArgs&&i.fireListeners(yt.MOUSEUP_CELL,{col:e.eventArgs.col,row:e.eventArgs.row,event:t.nativeEvent})}}})),i.scenegraph.tableGroup.addEventListener("rightdown",(t=>{const e=HR(t);if(e.eventArgs){n.triggerContextMenu(e.eventArgs.col,e.eventArgs.row,e.abstractPos.x,e.abstractPos.y);const{col:r,row:o}=e.eventArgs;if(i.hasListeners(yt.CONTEXTMENU_CELL)){const n=i.getCellInfo(r,o);let s,a;if(e.eventArgs?.target){const t=PR(e.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...n,event:t.nativeEvent,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};!function(t,e,i){for(let n=0;n<t.length;n++){const r=t[n];if(r.start.col<=e&&e<=r.end.col&&r.start.row<=i&&i<=r.end.row||r.end.col<=e&&e<=r.start.col&&r.end.row<=i&&i<=r.start.row)return!0}return!1}(i.stateManeger.select.ranges,r,o)?l.cells=[[n]]:l.cells=i.getSelectedCellInfos(),i.fireListeners(yt.CONTEXTMENU_CELL,l)}}})),i.scenegraph.tableGroup.addEventListener("click",(e=>{if(console.log("click",e.clone()),i.stateManeger.columnResize.resizing||i.stateManeger.columnMove.moving)return;const n=HR(e);if(t.dealIconClick(e,n),!n?.eventArgs)return;const{col:r,row:o}=n.eventArgs;if(i.hasListeners(yt.CLICK_CELL)){const t=i.getCellInfo(r,o);let s,a;if(n.eventArgs?.target){const t=PR(n.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...t,event:e.nativeEvent,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};i.fireListeners(yt.CLICK_CELL,l)}})),i.scenegraph.stage.addEventListener("click",(r=>{console.log("stage click");const o=r.target;o&&!o.isDescendantsOf(i.scenegraph.tableGroup)&&o!==i.scenegraph.tableGroup&&(console.log("pointerup outside table"),n.updateInteractionState(e.default),t.dealTableHover(),t.dealTableSelect(),n.updateCursor(),i.scenegraph.updateChartState(null))})),i.scenegraph.tableGroup.addEventListener("dblclick",(t=>{const e=HR(t),n=e.eventArgs.targetCell.globalAABBBounds,{col:r,row:o}=e.eventArgs,s=i.getCellValue(r,o);if(i.internalProps.focusControl.setFocusRect(new Re(n.x1+i.scrollLeft,n.y1+i.scrollTop,n.x2-n.x1,n.y2-n.y1),s),i.hasListeners(yt.DBLCLICK_CELL)){const n=i.getCellInfo(r,o);let s,a;if(e.eventArgs?.target){const t=PR(e.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...n,event:t.nativeEvent,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};i.fireListeners(yt.DBLCLICK_CELL,l)}}))}(this),function(t){const e=t.table,i=e.stateManeger,n=e.internalProps.handler;n.on(e.getElement(),"blur",(e=>{console.log("blur"),t.dealTableHover()})),n.on(e.getElement(),"wheel",(t=>{kR(t,i)})),n.on(e.getElement(),"keydown",(i=>{if(e.keyboardOptions?.selectAllOnCtrlA&&"a"===i.key&&(i.ctrlKey||i.metaKey)&&(i.preventDefault(),t.deelTableSelectAll()),e.hasListeners(yt.KEYDOWN)){const t={keyCode:i.keyCode??i.which,code:i.code,event:i,cells:e.getSelectedCellInfos(),scaleRatio:e.canvas.getBoundingClientRect().width/e.canvas.offsetWidth};e.fireListeners(yt.KEYDOWN,t)}})),n.on(e.getElement(),"copy",(t=>{if(e.keyboardOptions?.copySelected){const i=e.getCopyValue();kt(i)&&(t.preventDefault(),ct?window.clipboardData.setData("Text",i):t.clipboardData.setData("text/plain",i))}})),n.on(e.getElement(),"contextmenu",(t=>{t.preventDefault()})),n.on(e.getParentElement(),"resize",(()=>{e.resize()}))}(this),function(t){const i=t.table,n=i.stateManeger,r=i.scenegraph;r.component.vScrollBar.addEventListener("pointerover",(t=>{n.showVerticalScrollBar()})),r.component.hScrollBar.addEventListener("pointerover",(t=>{n.showHorizontalScrollBar()})),r.component.vScrollBar.addEventListener("pointerout",(t=>{n.interactionState!==e.scrolling&&n.hideVerticalScrollBar()})),r.component.hScrollBar.addEventListener("pointerout",(t=>{n.interactionState!==e.scrolling&&n.hideHorizontalScrollBar()})),r.component.vScrollBar._slider.addEventListener("pointerdown",(()=>{n.interactionState!==e.scrolling&&n.updateInteractionState(e.scrolling)})),r.component.vScrollBar.addEventListener("pointerup",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)})),r.component.vScrollBar.addEventListener("pointerupoutside",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)})),r.component.hScrollBar._slider.addEventListener("pointerdown",(()=>{n.interactionState!==e.scrolling&&n.updateInteractionState(e.scrolling)})),r.component.hScrollBar.addEventListener("pointerup",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)})),r.component.hScrollBar.addEventListener("pointerupoutside",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)}));const o=x(n.updateVerticalScrollBar,20),s=x(n.updateHorizontalScrollBar,20);r.component.vScrollBar.addEventListener("scroll",(t=>{const e=t.detail.value[0]/(1-t.detail.value[1]+t.detail.value[0]);o(e,t)})),r.component.hScrollBar.addEventListener("scroll",(t=>{const e=t.detail.value[0]/(1-t.detail.value[1]+t.detail.value[0]);s(e)}))}(this),OR(this)}bindSelfEvent(){const t=this.table.stateManeger;var e;this.table.listen(yt.ICON_CLICK,(e=>{const{col:i,row:n,x:r,y:o,funcType:s,icon:a}=e;var h;s===l.dropDown?t.triggerDropDownMenu(i,n,r,o):s===l.sort?t.triggerSort(i,n,a):s===l.frozen?t.triggerFreeze(i,n,a):s===l.drillDown?(h=this.table).fireListeners(BR.DRILLMENU_CLICK,h.stateManeger.drill):s!==l.collapse&&s!==l.expand||this.table.toggleHierarchyState(i,n)})),this.table.listen(yt.DROPDOWNMENU_CLICK,(()=>{t.hideMenu()})),function(t){const e=t.internalProps.layoutMap.headerObjects,i=t.internalProps.layoutMap.columnObjects;for(let t=0;t<e.length;t++){const i=e[t];if(i&&i.style?.textStick)return console.log("checkHaveTextStick",!0),!0}for(let t=0;t<i.length;t++){const e=i[t];if(e&&e.style?.textStick)return console.log("checkHaveTextStick",!0),!0}return console.log("checkHaveTextStick",!1),!1}(this.table)&&this.table.listen(yt.SCROLL,(t=>{lR(this.table)})),e=this.table,"browser"===vt.mode&&e.listen(yt.CLICK_CELL,(t=>{const{col:i,row:n}=t;let r;r=e.internalProps.layoutMap.isHeader(i,n)?e.isPivotTable()?e._getHeaderLayoutMap(i,n).headerType:e.getHeaderDefine(i,n).headerType:e.getBodyColumnType(i,n);const o=e.isHeader(i,n)?e.getHeaderDefine(i,n):e.getBodyColumnDefine(i,n),s=e.getCellValue(i,n),a=e.getCellOriginValue(i,n);if("link"===o.columnType){if(!1===o.linkJump)return;const t=o.templateLink,r=!1!==o.linkDetect;let l;if(t){const r=e.getCellOriginRecord(i,n),o=Object.assign({__value:s,__dataValue:a},r),h=/\{\s*(\S+?)\s*\}/g;l=t.replace(h,((t,e)=>o[e]))}else if(r){if(!De.test(s))return;l=s}else l=s;window.open(l)}else if("image"===r){const t=document.createElement("div");t.style.width="100%",t.style.height="100%",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.backgroundColor="rgba(30, 30, 30, 0.4)",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden",t.style.zIndex="9999",t.addEventListener("click",(e=>{e.target===t&&document.body.removeChild(t)}));const e=new Image;e.src=s,e.style.maxWidth="80%",e.style.maxHeight="80%",t.appendChild(e),document.body.appendChild(t)}else if("video"===r){const t=document.createElement("div");t.style.width="100%",t.style.height="100%",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.backgroundColor="rgba(30, 30, 30, 0.4)",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden",t.style.zIndex="9999",t.addEventListener("click",(e=>{e.target===t&&document.body.removeChild(t)}));const e=document.createElement("video");e.src=s,e.style.maxWidth="80%",e.style.maxHeight="80%",e.setAttribute("preload","auto"),e.setAttribute("controls","true"),t.appendChild(e),document.body.appendChild(t)}})),this.table.listen(yt.DBLCLICK_CELL,(t=>{this.table._canResizeColumn(t.col,t.row)&&this.table.scenegraph.updateAutoColWidth(t.col)})),this.table.isPivotTable()&&function(t){t.listen(yt.MOUSEENTER_CELL,(e=>{const{col:i,row:n}=e;if(-1===i||-1===n)return;const r=t.internalProps.layoutMap.getHeaderDimension(i,n);r?.drillDown||r?.drillUp?t.stateManeger.updateDrillState(r.dimensionKey,r.dimensionTitle,r.drillDown,r.drillUp,i,n):t.stateManeger.updateDrillState(void 0,void 0,!1,!1,-1,-1)}))}(this.table),function(t){let e=!1;e=t.isPivotTable()?t.internalProps.layoutMap.indicatorsDefine.some((t=>"string"!=typeof t&&"sparkline"===t.columnType)):t.internalProps.layoutMap.columnObjects.some((t=>"sparkline"===t.columnType));e&&(t.listen(yt.MOUSEMOVE_CELL,(e=>{const{col:i,row:n,x:r,y:o}=e;"sparkline"!==t.getBodyColumnType(i,n)&&t.stateManeger.updateSparklineHoverPose(-1,-1,0,0),t.stateManeger.updateSparklineHoverPose(i,n,r,o)})),t.listen(yt.MOUSELEAVE_TABLE,(e=>{t.stateManeger.updateSparklineHoverPose(-1,-1,0,0)})))}(this.table),function(t){t.isPivotChart()&&t.scenegraph.tableGroup.addEventListener("click",(e=>{if("axis-label"===e.target.name){const i=HR(e),{col:n,row:r}=i.eventArgs,o=t.internalProps.layoutMap;let s,a;o.indicatorsAsCol?(s=o.getDimensionKeyInChartSpec(o.rowHeaderLevelCount,r)[0],a=o.getCellHeaderPaths(o.rowHeaderLevelCount-2,r).rowHeaderPaths):(s=o.getDimensionKeyInChartSpec(n,o.columnHeaderLevelCount)[0],a=o.getCellHeaderPaths(n,o.columnHeaderLevelCount-1).colHeaderPaths);const l=a.map((t=>({key:t.dimensionKey,value:t.value}))).filter((t=>t.key));if(l.push({key:s,value:e.target.attribute.text}),t._selectedDimensionInChart.length&&function(t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(t[i].key!==e[i].key||t[i].value!==e[i].value)return!1;return!0}(t._selectedDimensionInChart,l))return;t._selectedDimensionInChart=l,o.updateDataStateToChartInstance(),dR(t.scenegraph),t.scenegraph.updateNextFrame()}else t._selectedDimensionInChart&&(t._selectedDimensionInChart.length=0,t.internalProps.layoutMap.updateDataStateToChartInstance(),dR(t.scenegraph),t.scenegraph.updateNextFrame())}))}(this.table)}dealTableHover(t){if(!t)return void this.table.stateManeger.updateHoverPos(-1,-1);const{eventArgs:e}=t;e?this.table.stateManeger.updateHoverPos(e.col,e.row):this.table.stateManeger.updateHoverPos(-1,-1)}dealIconHover(t){const{eventArgs:e}=t;e?this.table.stateManeger.updateHoverIcon(e.col,e.row,e.target,e.targetCell,e.event):this.table.stateManeger.updateHoverIcon(-1,-1,void 0,void 0)}dealMenuHover(t){}dealTableSelect(t){if(!t)return this.table.stateManeger.updateSelectPos(-1,-1),!1;const{eventArgs:e}=t;return!!e&&(this.table.isPivotChart()||"chart"===t?.eventArgs?.target.type||this.table.stateManeger.updateHoverPos(-1,-1),!this.table.isPivotChart()||"axis-label"!==t?.eventArgs?.target.name&&"chart"!==t?.eventArgs?.target.type?(this.table.stateManeger.updateSelectPos(e.col,e.row,e.event.shiftKey,e.event.ctrlKey||e.event.metaKey),!0):(this.table.stateManeger.updateSelectPos(-1,-1),!1))}deelTableSelectAll(){this.table.stateManeger.updateSelectPos(-1,-1,!1,!1,!0)}dealMenuSelect(t){}checkColumnResize(t,e){const{eventArgs:i}=t;if(i){const n=this.table.scenegraph.getResizeColAt(t.abstractPos.x,t.abstractPos.y,i.targetCell);if(this.table._canResizeColumn(n.col,n.row)&&n.col>=0)return e&&this.table.stateManeger.startResizeCol(n.col,t.abstractPos.x,t.abstractPos.y),!0}return!1}dealColumnResize(t){this.table.stateManeger.updateResizeCol(t.abstractPos.x,t.abstractPos.y)}chechColumnMover(t){const{eventArgs:e}=t;return!!(e&&this.table.isHeader(e.col,e.row)&&function(t,e,i){for(let n=0;n<i.length;n++)if(at(i[n],t,e))return!0;return!1}(e.col,e.row,this.table.stateManeger.select.ranges)&&this.table._canDragHeaderPosition(e.col,e.row))&&(this.table.stateManeger.startMoveCol(e.col,e.row,t.abstractPos.x,t.abstractPos.y),!0)}dealColumnMover(t){const{eventArgs:e}=t;this.table.stateManeger.updateMoveCol(e.col,e.row,t.abstractPos.x,t.abstractPos.y)}startColumnResize(t){}dealIconClick(t,e){const{eventArgs:i}=e,{target:n,event:r,col:o,row:s}=i||{target:t.target,event:t,col:-1,row:-1},a=n;if(a.role&&a.role.startsWith("icon-"))return this.table.fireListeners(yt.ICON_CLICK,{name:a.name,x:(a.globalAABBBounds.x1+a.globalAABBBounds.x2)/2,y:a.globalAABBBounds.y2,col:o,row:s,funcType:a.attribute.funcType,icon:a}),!0;if(n instanceof Cd){const t=n.pickIcon(r.global);if(t)return this.table.fireListeners(yt.ICON_CLICK,{name:t.attribute.id,x:t.globalX+t.globalAABBBounds.width()/2,y:t.globalY+t.AABBBounds.height(),col:o,row:s,funcType:t.attribute.funcType,icon:t}),!0}return!1}}let WR;const zR=t=>{const e=t.value;return Number(e)>80?"#20a8d8":Number(e)>50?"#4dbd74":Number(e)>20?"#ffc107":"#f86c6b"};class jR extends O{_showBar;_barColor;_barBgColor;_barPositiveColor;_barNegativeColor;_barAxisColor;_barHeight;_barBottom;_barPadding;_showBarMark;_barMarkPositiveColor;_barMarkNegativeColor;_barMarkWidth;_barMarkPosition;_barRightToLeft;static get DEFAULT(){return WR||(WR=new jR)}constructor(t={},e={}){super(t,e),this._showBar=t.showBar??!0,this._barColor=t.barColor??zR,this._barPositiveColor=t.barPositiveColor??"#4dbd74",this._barNegativeColor=t.barNegativeColor??"#f86c6b",this._barAxisColor=t.barAxisColor??"black",this._barBgColor=t.barBgColor,this._barHeight=t.barHeight??3,this._barHeight=t.barHeight??3,this._barBottom=t.barBottom??0,this._barPadding=t.barPadding??[1,1,1,1],this._showBarMark=t.showBarMark??!1,this._barMarkPositiveColor=t.barMarkPositiveColor??"#4dbd74",this._barMarkNegativeColor=t.barMarkNegativeColor??"#f86c6b",this._barMarkWidth=t.barMarkWidth??2,this._barMarkPosition=t.barMarkPosition??"right",this._barRightToLeft=t.barRightToLeft??!1}get showBar(){return this._showBar}set showBar(t){this._showBar=t}get barColor(){return this._barColor}set barColor(t){this._barColor=t}get barBgColor(){return this._barBgColor}set barBgColor(t){this._barBgColor=t}get barHeight(){return this._barHeight}set barHeight(t){this._barHeight=t}get barBottom(){return this._barBottom}set barBottom(t){this._barBottom=t}get barPositiveColor(){return this._barPositiveColor}set barPositiveColor(t){this._barPositiveColor=t}get barNegativeColor(){return this._barNegativeColor}set barNegativeColor(t){this._barNegativeColor=t}get barAxisColor(){return this._barAxisColor}set barAxisColor(t){this._barAxisColor=t}get barPadding(){return this._barPadding}set barPadding(t){this._barPadding=t}get showBarMark(){return this._showBarMark}set showBarMark(t){this._showBarMark=t}get barMarkPositiveColor(){return this._barMarkPositiveColor}set barMarkPositiveColor(t){this._barMarkPositiveColor=t}get barMarkNegativeColor(){return this._barMarkNegativeColor}set barMarkNegativeColor(t){this._barMarkNegativeColor=t}get barMarkWidth(){return this._barMarkWidth}set barMarkWidth(t){this._barMarkWidth=t}get barMarkPosition(){return this._barMarkPosition}set barMarkPosition(t){this._barMarkPosition=t}get barRightToLeft(){return this._barRightToLeft}set barRightToLeft(t){this._barRightToLeft=t}clone(){return new jR(this,null)}}const NR=["type","content","font","color","width","height","marginRight","marginLeft","src","svg","name","path","positionType","tooltip","hover","cursor","shape","interactive"];class GR{expandIcon;collapseIcon;_table;constructor(t){this._table=t;const e=kC();this.expandIcon=e[h.expandIconName],this.collapseIcon=e[h.collapseIconName]}getIcons(t,e,i,n,r){const o=[],{icon:s}=this._table.getBodyColumnDefine(t,e);if(s){let r;if("function"==typeof s){r=s({col:t,row:e,value:i,dataValue:n,table:this._table})}else r=s;const a=kC(),l=t=>{let e;e="string"==typeof t?a[t]:t,e&&o.push(e)};Array.isArray(r)?r.forEach(((t,e)=>{l(t)})):l(r)}const a=this.getHierarchyIcon(t,e);return a&&o.push(a),r&&o.forEach(((i,n)=>{(i.content||i.src)&&(o[n]=this.getCellIconFromRecordValue(i,t,e))})),o}getStyleClass(t){switch(t){case"text":case"link":return F;case"image":case"video":return D;case"chart":case"sparkline":return O;case"progressbar":return jR}}getCellIconFromRecordValue(t,e,i){if(Array.isArray(t))return t.map((t=>this.getCellIconFromRecordValue(t,e,i)));if(!dt.isObject(t)||"function"==typeof t)return this._table.getFieldData(t,e,i);const n={},r=t;return NR.forEach((t=>{if(void 0!==r[t]){const o=this._table.getFieldData(r[t],e,i);null!=o?n[t]=o:this._table._hasField(r[t],e,i)||(n[t]=r[t])}})),n}getHierarchyIcon(t,e){const i=this._table.getHierarchyState(t,e);return i===r.expand?this.expandIcon:i===r.collapse?this.collapseIcon:void 0}}function KR(t,e){const i=document.createElement(t);return e&&i.classList.add(...e),i}!function(){const t=document.createElement("style");t.id="vtable-menu-styleSheet",t.textContent="\n@keyframes vtable__menu-element--shown-animation {\n\t0% {\n\t\topacity: 0;\n\t}\n\t100% {\n\t\topacity: 1;\n\t}\n}\n.vtable__menu-element {\n\tposition: absolute;\n\tbox-sizing: border-box;\n\tborder-radius: 4px;\n\tbackground-color: #fff;\n\tpadding: 6px 0;\n\t/* pointer-events: none; */\n\tuser-select: none;\n\tcolor: #000;\n\tmax-width: 300px;\n\tz-index: 99999;\n\tborder: #CCC 0.5px solid;\n\tcursor: default;\n\twidth: max-content;\n\tbox-shadow: 0px 8px 16px rgba(27, 31, 35, 0.12);\n}\n.vtable__menu-element--hidden {\n\topacity: 0;\n\t/* transform: translate(-50%, -50%); */\n\ttransition: opacity 75ms linear;\n\tz-index: -9999;\n}\n.vtable__menu-element--shown {\n\topacity: 1;\n\t/* transform: translate(-50%, -50%); */\n\tanimation: vtable__menu-element--shown-animation 150ms ease-out;\n}\n.vtable__menu-element__content {\n\tfont-family: Roboto;\n\tfont-size: 12px;\n\toverflow: hidden;\n\tdisplay: inline-block;\n\t/* height: 100%; */\n\tline-height: 30px;\n}\n.vtable__menu-element__item {\n\theight: 32px;\n\tpadding: 0px 12px;\n\tcursor: pointer;\n\tposition: relative;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: flex-start;\n}\n.vtable__menu-element__item:hover {\n\tbackground-color: rgba(27, 31, 35, 0.06);\n}\n.vtable__menu-element__icon{\n\t/* vertical-align: top; */\n\tdisplay: flex;\n\t/* line-height: 30px; */\n\tmargin-right: 6px;\n}\n.vtable__menu-element__no-event {\n\tpointer-events: none;\n}\n.vtable__menu-element--select {\n\tcolor: #2E68CF;\n}.vtable__menu-element--normal {\n\tcolor: rgba(20, 20, 20, 0.9);;\n}\n.vtable__menu-element__split {\n\theight: 0px;\n\tborder: 1px solid rgb(209, 213, 218);\n\tmargin: 5px 0;\n}\n.vtable__menu-element__title {\n\tcolor: rgb(149, 149, 149);\n}\n.vtable__menu-element__arrow {\n\tposition: absolute;\n\tright: 3px;\n\tfont-weight: bold;\n\tmargin-top: 1px;\n}\n.vtable__menu-element__item-text {\n\tmargin-right: 15px;\n}\n",document.body.appendChild(t)}();const UR="vtable__menu-element",VR=`${UR}__item`,$R=`${UR}__content`,XR=`${UR}--hidden`,YR=`${UR}--shown`,qR=`${UR}--normal`,ZR=`${UR}--select`,JR=`${UR}__icon`,QR=`${UR}__split`,tP=`${UR}__title`,eP=`${UR}__arrow`,iP=`${UR}__no-event`,nP=`${UR}__item-text`;function rP(){return KR("div",[UR,XR])}function oP(t,e,i,n,r,o){const s=t.getCellRange(n,r);for(let n=0;n<e.length;n++){const r=e[n];let{col:o,row:a}=r;const{field:l,menuKey:h}=r;if("number"!=typeof o||"number"!=typeof a)if(t.isPivotTable()&&(Array.isArray(l),1)){const e=t.internalProps.layoutMap.getPivotCellAdress(l);if(!e)continue;o=e.col,a=e.row}else{const e=t.internalProps.layoutMap.getHeaderCellAddressByField(l);if(!e)continue;o=e.col,a=e.row}if(A(o)&&A(a)&&at(s,o,a)&&i===h)return!0}return!1}class sP{_handler;_rootElement;_secondElement;_menuInstanceInfo;_showChildrenIndex;_mouseEnterSecondElement;constructor(t){this._handler=new xt,this._rootElement=rP(),this._secondElement=rP(),this._secondElement.sub=!0,this._showChildrenIndex=-1,this._rootElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._rootElement?.addEventListener("touchend",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(XR))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n),h=t._dropDownMenuIsHighlight(i,n,r);t.fireListeners(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(XR))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n),h=t._dropDownMenuIsHighlight(i,n,r);t.fireListeners(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("mousemove",(e=>{if(this._rootElement.classList.contains(XR))return;e.stopPropagation();const{hasChildren:i,dropDownIndex:n,col:r,row:o,sub:s}=e.target;if(i){this._showChildrenIndex=n;const i=this._secondElement;i?.classList.remove(XR),i?.classList.add(YR),i.innerHTML="";const s=this._menuInstanceInfo.content[n]?.children;for(let e=0;e<s.length;e++){const n=s[e],a=aP(n,!!t.stateManeger.menu.dropDownMenuHighlight&&oP(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof n?n?.menuKey||n?.text:n,r,o));a.col=r,a.row=o,a.dropDownIndex=e,"string"==typeof n?(a.text=n,a.menuKey=n):"object"==typeof n&&(a.text=n.text,a.menuKey=n.menuKey||n.text),a.sub=!0,a.sub=!0,i.appendChild(a)}const a=e.target.getBoundingClientRect();this._bindSecondElement(t,r,o,a.right,a.top)}else if(i&&this._showChildrenIndex===n){const t=this._secondElement;t?.classList.remove(XR),t?.classList.add(YR)}else!s&&this._secondElement?.classList.contains(YR)&&setTimeout((()=>{if(!0!==this._mouseEnterSecondElement){this._showChildrenIndex=-1;const t=this._secondElement;t?.classList.remove(YR),t?.classList.add(XR)}}),300)})),this._secondElement?.addEventListener("mousemove",(t=>{this._rootElement.classList.contains(XR)||t.stopPropagation()})),this._secondElement?.addEventListener("mouseenter",(t=>{this._mouseEnterSecondElement=!0})),this._secondElement?.addEventListener("mouseleave",(t=>{this._mouseEnterSecondElement=!1})),this._secondElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._secondElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._secondElement.classList.contains(XR))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n);let h=!1;this._menuInstanceInfo.content.forEach(((e,r)=>{if("object"==typeof e&&e.children&&e.children.length)for(let r=0;r<e.children.length;r++){const s=e.children[r];if(oP(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof s?s?.menuKey:s,i,n)&&o===("object"==typeof s?s?.menuKey:s))return void(h=!0)}})),t.fireListeners(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,cellHeaderPaths:t.isPivotTable()?t.getCellHeaderPaths(i,n):void 0,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()}))}get rootElement(){return this._rootElement}dispose(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler.dispose(),delete this._rootElement}bindToCell(t,e,i,n){const r=this._rootElement,o=this._secondElement;if(this._menuInstanceInfo=n,r?.classList.remove(YR),r?.classList.add(XR),o?.classList.remove(YR),o?.classList.add(XR),this._canBindToCell(t,e,i)){if(r.innerHTML="",Array.isArray(n.content)){const o=n.content;for(let n=0;n<o?.length;n++){const s=o[n];let a=!!t.stateManeger.menu.dropDownMenuHighlight&&oP(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof s?s?.menuKey||s?.text:s,e,i);if(t.stateManeger.menu.dropDownMenuHighlight&&"object"==typeof s&&Array.isArray(s.children)&&s.children.length)for(let n=0;n<s.children.length;n++){const r=s.children[n];if(oP(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof r?r?.menuKey||r?.text:r,e,i)){a=!0;break}}const l=aP(s,a);l.col=e,l.row=i,l.dropDownIndex=n,"string"==typeof s?(l.text=s,l.menuKey=s):"object"==typeof s&&(l.text=s.text,l.menuKey=s.menuKey||s.text,s.children?.length&&(l.hasChildren=!0)),r.appendChild(l)}}if(this._bindToCell(t,e,i,n.position,n.referencePosition))return r?.classList.add(YR),r?.classList.remove(XR),!0}else this.unbindFromCell();return!1}unbindFromCell(){const t=this._rootElement,e=this._secondElement;this._menuInstanceInfo=void 0,t?.parentElement&&(t.classList.remove(YR),t.classList.add(XR)),e?.parentElement&&(e.classList.remove(YR),e.classList.add(XR))}_canBindToCell(t,e,i){const n=t.getCellRangeRelativeRect({col:e,row:i}),r=t.getElement(),{top:o,bottom:s,left:a,right:l}=n,{frozenRowCount:h,frozenColCount:c}=t;if(i>=h&&h>0){if(s<t.getCellRangeRelativeRect({col:e,row:h-1}).bottom)return!1}else if(s<0)return!1;if(e>=c&&c>0){if(l<t.getCellRangeRelativeRect({col:c-1,row:i}).right)return!1}else if(l<0)return!1;const{offsetHeight:d,offsetWidth:u}=r;return!(d<o)&&!(u<a)}_bindToCell(t,e,i,n,r){const o=this._rootElement,s=t.getElement(),{width:a,height:l}=t.internalProps.element.getBoundingClientRect();if(o){o.parentElement!==s&&s.appendChild(o),o.style.left="0px";const e=.8*a;o.style.maxWidth=`${e}px`;const i=o.clientWidth,h=o.clientHeight;let c,d;return n?(c=n.x+t.tableX,d=n.y+t.tableY):r&&(c=r.rect.right-i+t.tableX,d=r.rect.bottom+t.tableY),d+h>l&&(d=l-h,c+=i-2),d<0&&(d/=2),o.style.top=`${d}px`,c<0?c=0:c+i>a&&(c=a-i),o.style.left=`${c}px`,!0}return!1}_bindSecondElement(t,e,i,n,r){const o=this._secondElement,s=this._rootElement,a=t.getElement(),{width:l,left:h,top:c}=t.internalProps.element.getBoundingClientRect(),{x:d,y:u,width:p}=s.getBoundingClientRect();if(o){o.parentElement!==a&&a.appendChild(o),o.style.left="0px";const t=.8*l;o.style.maxWidth=`${t}px`;const e=o.clientWidth,i=r-4-c,s=n-h;o.style.top=`${i}px`;let d=s;return d+e>l?d=d-e-p:d+=4,o.style.left=`${d}px`,!0}return!1}pointInMenuElement(t,e){const i=this._rootElement,{x:n,y:r,width:o,height:s}=i.getBoundingClientRect();if(t>n-5&&t<n+o+5&&e>r-5&&e<r+s+5)return!0;if(this._secondElement){const{x:n,y:r,width:o,height:s}=i.getBoundingClientRect();if(t>n-5&&t<n+o+5&&e>r-5&&e<r+s+5)return!0}return!1}}function aP(t,e){const i=KR("div",[VR,e?ZR:qR]);if("string"==typeof t){const e=KR("span",[$R,iP,nP]);e.innerHTML=t,i.appendChild(e)}else if("object"==typeof t){const n=t.type??"item";if("split"===n)return i?.classList.add(QR),i;if(t?.icon?.svg)if(De.test(t.icon.svg)){const e=new Image;t.icon.width?e.style.width=t.icon.width.toString()+"px":e.style.width="16px",t.icon.height?e.style.height=t.icon.height.toString()+"px":e.style.height="16px",e.src=t.icon.svg,i.appendChild(e)}else{const n=KR("span",[JR,iP]);n.innerHTML=e&&t.selectedIcon&&t.selectedIcon.svg?t.selectedIcon.svg:t.icon.svg,t.icon.width&&n.children[0].setAttribute("width",t.icon.width.toString()),t.icon.height&&n.children[0].setAttribute("height",t.icon.height.toString()),i.appendChild(n)}const r=KR("span",[$R,iP,nP]);if(r.innerHTML=t.text,i.appendChild(r),"title"===n)i?.classList.add(iP,tP);else if(t?.children?.length){const t=KR("span",[$R,iP,eP]);t.innerHTML=e?'<svg width="8" height="12" viewBox="0 0 10 17" fill="none" xmlns="http://www.w3.org/2000/svg" style="vertical-align: baseline"><path d="M1.78186 16.7729L0.300378 15.2915L6.8189 8.77295L0.300377 2.25443L1.78186 0.77295L9.78186 8.77295L1.78186 16.7729Z" fill="#2E68CF" fill-opacity="0.65"></path></svg>':'<svg width="8" height="12" viewBox="0 0 10 17" fill="none" xmlns="http://www.w3.org/2000/svg" style="vertical-align: baseline"><path d="M1.78186 16.7729L0.300378 15.2915L6.8189 8.77295L0.300377 2.25443L1.78186 0.77295L9.78186 8.77295L1.78186 16.7729Z" fill="#141414" fill-opacity="0.65"></path></svg>',i.appendChild(t)}}return i}let lP;class hP extends j{static get DEFAULT(){return lP||(lP=new hP)}constructor(t={},e={}){super(t,e),this.textAlign=(t.textAlign??e?.textAlign)||"center"}clone(){return new hP(this)}}class cP{normalIcon;upIcon;downIcon;freezeIcon;frozenIcon;frozenCurrentIcon;dropDownAbsoluteIcon;expandIcon;collapseIcon;_table;constructor(t){this._table=t;const e=kC();this.freezeIcon=e[h.freezeIconName],this.frozenIcon=e[h.frozenIconName],this.frozenCurrentIcon=e[h.frozenCurrentIconName],this.normalIcon=e[h.normalIconName],this.upIcon=e[h.upwardIconName],this.downIcon=e[h.downwardIconName],this.dropDownAbsoluteIcon=e[h.dropdownIconName],this.expandIcon=e[h.expandIconName],this.collapseIcon=e[h.collapseIconName]}getIcons(t,e){const i=[];if(this._table.isPivotTable()){const{showSort:n}=this._table.internalProps.layoutMap.getHeader(t,e);if(n){const n=this._table.getPivotSortState(t,e),r="asc"===n?this.downIcon:"desc"===n?this.upIcon:this.normalIcon;r&&i.push(r)}}else{const n=this._table.sortState;let r;r=void 0;const o=this._table.getCellRange(t,e);if(n)if(Array.isArray(n))for(let t=0;t<n.length;t++){const e=n[t],i=this._table._getHeaderCellBySortState(e);if(i&&at(o,i.col,i.row)){({order:r}=e);break}}else{const t=this._table._getHeaderCellBySortState(n);t&&at(o,t.col,t.row)&&({order:r}=n)}const s=this.getSortIcon(r,this._table,t,e);s&&i.push(s)}if(this._table.showFrozenIcon&&t<this._table.allowFrozenColCount){const n=this.getFrozenIcon(t,e);n&&i.push(n)}if(this.checkDropDownIcon(this._table,t,e)){const t=this.dropDownAbsoluteIcon;i.push(t)}const n=this.getDropDownStateIcons(this._table,t,e);n.length&&i.push(...n);const{captionIcon:r,headerIcon:o}=this._table._getHeaderLayoutMap(t,e);r&&i.push(r);const s=this.getHierarchyIcon(t,e);if(s&&i.push(s),o){let n;if("function"==typeof o){n=o({col:t,row:e,value:this._table.getCellValue(t,e),dataValue:this._table.getCellOriginValue(t,e),table:this._table})}else n=o;const r=kC(),s=t=>{let e;e="string"==typeof t?r[t]:t,e&&i.push(e)};Array.isArray(n)?n.forEach(((t,e)=>{s(t)})):s(n)}return i}getFrozenIcon(t,e){if(this._table.isPivotTable()||this._table.transpose)return null;const i=this._table.getHeaderDefine(t,e);if(i.columns&&i.columns.length>0)return null;let n=this.freezeIcon;return this._table.options.frozenColCount-1>t?n=this.frozenIcon:this._table.options.frozenColCount-1===t&&(n=this.frozenCurrentIcon),n}getSortIcon(t,e,i,n){const r="asc"===t?this.downIcon:"desc"===t?this.upIcon:this.normalIcon,o=e.getHeaderDefine(i,n);return!o||!o.showSort&&!o.sort||o.columns&&o.columns.length>0?null:r}getDropDownStateIcons(t,e,i){const n=t.getHeaderDefine(e,i),r=t._getHeaderLayoutMap(e,i),{dropDownMenu:o}=r,s=[];if(Array.isArray(o)&&o.length||Array.isArray(t.globalDropDownMenu)&&t.globalDropDownMenu.length&&!n?.columns?.length){const n=o||t.globalDropDownMenu;let r=-1,h=-1;for(let o=0;o<n.length;o++){const s=n[o];if("object"==typeof s&&s.children&&s.children.length)for(let n=0;n<s.children.length;n++){const a=s.children[n];if(t.stateManeger.menu?.dropDownMenuHighlight&&oP(t,t.stateManeger.menu?.dropDownMenuHighlight,"object"==typeof a?a?.menuKey:a,e,i)){r=o,h=n;break}}if(t._dropDownMenuIsHighlight(e,i,o)){r=o;break}}if(-1!==r){let e;e=-1!==h?(o||t.globalDropDownMenu)[r].children[h]:(o||t.globalDropDownMenu)[r],e.stateIcon&&(e.stateIcon.svg?s.push({type:"svg",name:e.stateIcon.src||e.stateIcon.svg,width:e.stateIcon.width||22,height:e.stateIcon.height||22,svg:e.stateIcon.svg,positionType:a.right,marginRight:0,funcType:l.dropDownState,interactive:!1}):e.stateIcon.src&&s.push({type:"image",name:e.stateIcon.src||e.stateIcon.svg,width:e.stateIcon.width||22,height:e.stateIcon.height||22,src:e.stateIcon.src,positionType:a.right,marginRight:0,funcType:l.dropDownState,interactive:!1}))}}return s}getDropDownIconRect(t,e,i){const n=this.downIcon.hover?.width??this.downIcon?.width??0,r=this.downIcon.hover?.height??this.downIcon?.height??0,o=t.right-2-n,s=t.right-2;let a;a="middle"===i?t.top+t.height/2-n/2:"top"===i?t.top+e/2:"bottom"===i?t.bottom-2*e:t.top;return{left:o,right:s,top:a,bottom:r+a,width:n,height:r}}getHierarchyIcon(t,e){const{hierarchyState:i}=this._table._getHeaderLayoutMap(t,e);if(i){if(i===r.expand)return this.expandIcon;if(i===r.collapse)return this.collapseIcon}}checkDropDownIcon(t,e,i){if(t.isPivotTable()){const n=t._getHeaderLayoutMap(e,i);if(Array.isArray(n.dropDownMenu)&&n.dropDownMenu.length)return!0}else{const n=t.getHeaderDefine(e,i);if(Array.isArray(n.dropDownMenu)&&n.dropDownMenu.length||(!Array.isArray(n.dropDownMenu)||0!==n.dropDownMenu.length)&&Array.isArray(t.globalDropDownMenu)&&t.globalDropDownMenu.length&&!n?.columns?.length)return!0}return!1}getStyleClass(t){switch(t){case"text":case"link":return G;case"image":case"video":return hP}}}class dP{_table;_tooltipElement;constructor(t){this._table=t}dispose(){this.unbindTooltipElement(),this._tooltipElement&&this._tooltipElement.dispose?.(),this._tooltipElement=void 0}_getTooltipElement(){return this._tooltipElement||(this._tooltipElement=this.createTooltipElementInternal()),this._tooltipElement}bindTooltipElement(t,e,i,n){return this._getTooltipElement().bindToCell(this._table,t,e,i,n)}moveTooltipElement(t,e,i,n){this._getTooltipElement().move(this._table,t,e,i,n)}unbindTooltipElement(){this._getTooltipElement().unbindFromCell()}locateTooltipElement(t,e,i,n,r){this._getTooltipElement()._locate(this._table,t,e,i,n,r)}}!function(){const t=document.createElement("style");t.id="vtable-tooltip-styleSheet",t.textContent="\n@keyframes vtable__bubble-tooltip-element--shown-animation {\n\t0% {\n\t\topacity: 0;\n\t}\n\t100% {\n\t\topacity: 1;\n\t}\n}\n.vtable__bubble-tooltip-element {\n\tposition: absolute;\n\t\n\tpointer-events: none;\n\tuser-select: none;\n\tmax-width: 300px;\n\tz-index: 99999;\n\n\tbackground: #FFFFFF;\n border: 1px solid #E6E8ED;\n box-sizing: border-box;\n border-radius: 4px;\n box-shadow: 0px 2px 4px rgb(27 31 35 / 8%);\n color: #141414;\n font-size: 13px;\n}\n.vtable__bubble-tooltip-element--hidden {\n\topacity: 0;\n\t/* transform: translate(-50%, -50%); */\n\ttransition: opacity 75ms linear;\n}\n.vtable__bubble-tooltip-element--shown {\n\topacity: 1;\n\t/* transform: translate(-50%, -50%); */\n\tanimation: vtable__bubble-tooltip-element--shown-animation 150ms ease-out;\n}\n.vtable__bubble-tooltip-element__content {\n\t/* font-size: .75rem; */\n\tpadding: 6px 8px;\n\tmin-height: 1em;\n\tline-height: 1.5;\n\twidth: 100%;\n\tdisplay: block;\n\twhite-space: pre-wrap;\n\tmargin: 0;\n\tbox-sizing: border-box;\n\toverflow: hidden;\n\tword-wrap: break-word;\n\tposition: relative;\n\tbackground-color: #FFF;\n\tz-index: 2;\n\tborder-radius: 4px\n}\n.vtable__bubble-tooltip-element__triangle {\n\t/* font-size: .75rem; */\n\tposition: absolute;\n\twidth: 10px;\n\theight: 10px;\n\tdisplay: block;\n\ttransform: rotate(45deg);\n transform-origin: 50% 50% 0;\n\tz-index: 1;\n\tbackground-color: #FFF;\n\tborder: 1px solid #E6E8ED;\n}\n",document.body.appendChild(t)}();const uP="vtable__bubble-tooltip-element",pP=`${uP}__content`,fP=`${uP}__triangle`,gP=`${uP}--hidden`,yP=`${uP}--shown`;class mP{_handler;_rootElement;_messageElement;_triangleElement;constructor(){this._handler=new xt;const t=this._rootElement=KR("div",[uP,gP]),e=KR("span",[pP]),i=KR("span",[fP]);t.appendChild(i),t.appendChild(e),this._messageElement=t.querySelector(`.${pP}`)||void 0,this._triangleElement=t.querySelector(`.${fP}`)||void 0}bindToCell(t,e,i,n,r){const o=this._rootElement,s=this._messageElement,a=this._triangleElement;if(o?.classList.remove(yP),o?.classList.add(gP),this._canBindToCell(t,e,i)){s.setAttribute("style",""),a.setAttribute("style",""),n?.className&&o.classList.add(n.className),n?.style?.bgColor&&(s.style.backgroundColor=n?.style?.bgColor),n?.style?.bgColor&&(a.style.backgroundColor=n?.style?.bgColor),a.style.display=!0===n?.style?.arrowMark?"block":"none",n?.style?.font&&(s.style.font=n?.style?.font),n?.style?.color&&(s.style.color=n?.style?.color),n?.style?.padding&&(s.style.padding=`${n?.style?.padding.join("px ")}px`),s&&(s.textContent=n?.content);if(this._bindToCell(t,e,i,n?.position,n?.referencePosition,r,n?.style?.arrowMark))return o?.classList.add(yP),o?.classList.remove(gP),!0}else this.unbindFromCell();return!1}dispose(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler?.dispose?.(),delete this._rootElement,delete this._messageElement}move(t,e,i,n,r){const o=this._rootElement;this._canBindToCell(t,e,i)?(this._bindToCell(t,e,i,n?.position,n?.referencePosition,r),o?.classList.add(yP),o?.classList.remove(gP)):this.unbindFromCell()}unbindFromCell(){const t=this._rootElement;t?.parentElement&&(t.classList.remove(yP),t.classList.add(gP))}_canBindToCell(t,e,i){const n=t.getCellRangeRelativeRect({col:e,row:i}),r=t.getElement(),{bottom:o,left:s,right:a}=n,{frozenRowCount:l,frozenColCount:h}=t;if(i>=l&&l>0){if(o<t.getCellRangeRelativeRect({col:e,row:l-1}).bottom)return!1}else if(o<0)return!1;if(e>=h&&h>0){if(a<t.getCellRangeRelativeRect({col:h-1,row:i}).right)return!1}else if(s<0)return!1;const{offsetHeight:c,offsetWidth:d}=r;return!(c<o)&&!(d<s)}_bindToCell(t,e,i,n,r,o,s){const a=this._rootElement,l=t.getCellRangeRelativeRect({col:e,row:i}),h=t.getElement(),c=t.internalProps.element.offsetWidth,{width:d}=l;if(a){let l,u;a.parentElement!==h&&h.appendChild(a),a.style.left="0px";const p=Math.min(.8*c,4*d);a.style.maxWidth=`${p}px`;const f=a.clientWidth,g=a.clientHeight;if(!n&&!r)return!1;{const a=this.getComputedPosition(t,e,i,n,r,o,s);u=a.x,l=a.y}a.style.left=`${u}px`,a.style.top=`${l}px`,B()&&(a.style.fontSize="11px");const{x1:y,x2:m,y1:b,y2:v}=t.stateManeger.menu.bounds,w=u,C=w+f,x=l,_=w+g;return!(t.stateManeger.menu.isShow&&y<C&&m>w&&v>x&&b<_)}return!1}getComputedPosition(t,e,i,r,o,s,a){const l=this._rootElement,h=t.getCellRangeRelativeRect({col:e,row:i}),{width:c,height:d}=t.internalProps.element.getBoundingClientRect(),{width:u}=h;let p,f;const g=Math.min(.8*c,4*u);l.style.maxWidth=`${g}px`;const y=l.clientWidth,m=l.clientHeight,b=a?6:0;if(r)f=r.x,p=r.y+b,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.top="-5px";else if(o){let e=o.placement??n.bottom;const i=o.rect.left+o.rect.width/2+t.tableX,r=o.rect.top+o.rect.height/2+t.tableY,a=o.rect.top+t.tableY,l=o.rect.bottom+t.tableY,h=o.rect.left+t.tableX,u=o.rect.right+t.tableX;let g=0;const v=()=>{g++,g>=4||(this.removeStyleFromTriangle(),e===n.top?(f=i-y/2,p=a-m-b,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.bottom="-5px",s&&p<0&&(e=n.right,v())):e===n.bottom?(f=i-y/2,p=l+b,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.top="-5px",s&&p+m>d&&(e=n.left,v())):e===n.left?(p=r-m/2,f=h-y-b,this._triangleElement.style.top="50%",this._triangleElement.style.marginTop="-5px",this._triangleElement.style.right="-5px",s&&f<0&&(e=n.top,v())):e===n.right&&(p=r-m/2,f=u+b,this._triangleElement.style.top="50%",this._triangleElement.style.marginTop="-5px",this._triangleElement.style.left="-5px",s&&f+y>c&&(e=n.bottom,v())))};v()}return s&&(f<0?f=0:f+l.offsetWidth>c&&(f=c-l.offsetWidth)),{x:f,y:p}}removeStyleFromTriangle(){this._triangleElement.style.left="",this._triangleElement.style.right="",this._triangleElement.style.top="",this._triangleElement.style.bottom="",this._triangleElement.style.marginLeft="",this._triangleElement.style.marginTop=""}_locate(t,e,i,n,r,o){const s=this.getComputedPosition(t,e,i,n,r,o),a=s.x,l=s.y;this._rootElement.style.left=`${a}px`,this._rootElement.style.top=`${l}px`}}class bP extends dP{createTooltipElementInternal(){return new mP}}const vP={"bubble-tooltip":function(t){return new bP(t)}};class wP{_table;_tooltipInstances;_attachInfo;confine;constructor(t,e){this._table=t,this._tooltipInstances={},this._bindTableEvent(t),this.confine=e}dispose(){const t=this._tooltipInstances;for(const e in t)t[e]?.dispose?.();delete this._tooltipInstances,this._attachInfo=null}_bindToCell(t,e,i){const n=this._attachInfo,r=this._getTooltipInstanceInfo(t,e);if(!n||r&&n.instance===r||(n.instance?.unbindTooltipElement(),this._attachInfo=null),!r)return;if(r&&r.bindTooltipElement(t,e,i,this.confine)){const n=this._table.getCellRange(t,e);this._attachInfo={range:n,instance:r,tooltipOptions:i}}}_move(t,e,i){const n=this._attachInfo;if(!n||!at(n.range,t,e))return;const{instance:r}=n;r?.moveTooltipElement(t,e,i,this.confine)}moveToPosition(t,e,i,n){const r=this._attachInfo;if(!r||!at(r.range,t,e))return;const{instance:o}=r;this._attachInfo.tooltipOptions.position=i,this._attachInfo.tooltipOptions.referencePosition=n,o?.locateTooltipElement(t,e,i,n,this.confine)}_unbindFromCell(){const t=this._attachInfo;if(!t)return;const{instance:e}=t;e?.unbindTooltipElement(),this._attachInfo=null}_isBindCell(t,e){const i=this._attachInfo;return!!i&&at(i.range,t,e)}_bindTableEvent(t){t.listen(yt.MOUSEENTER_CELL,(e=>{if(B())return;const{x1:i,x2:r,y1:o,y2:s}=t.stateManeger.menu.bounds;if(t.stateManeger.menu.isShow&&"number"==typeof e.x&&"number"==typeof e.y&&e.x>i&&e.x<r&&e.y>o&&e.y<s)return;const{col:a,row:l}=e;if((!e.related||!this._isBindCell(a,l))&&t.internalProps.tooltip?.isShowOverflowTextTooltip){const i=t.getCellOverflowText(a,l),r=t.getHeaderDescription(a,l),o=t.getCellRangeRelativeRect({col:a,row:l});let s;i&&(s={content:r?`${r}\n ${i}`:i,referencePosition:{placement:n.bottom,rect:o},style:{arrowMark:!1}}),r&&(s={content:r,referencePosition:{placement:n.bottom,rect:o},style:{arrowMark:!1}}),s&&this._bindToCell(e.col,e.row,s)}})),t.listen(yt.MOUSEMOVE_CELL,(e=>{if(!B()){if(this._attachInfo?.tooltipOptions?.referencePosition){const i=this._attachInfo.tooltipOptions.referencePosition,{event:n}=e,{left:r,right:o,top:s,bottom:a}=i.rect,l=t._getMouseAbstractPoint(n,!1);l&&l.x>=r-5&&l.x<=o+5&&l.y>=s-5&&l.y<=a+5||this._unbindFromCell()}this._attachInfo&&t.stateManeger.menu.isShow&&this._bindToCell(e.col,e.row)}})),t.listen(yt.MOUSELEAVE_CELL,(t=>{t.related&&this._isBindCell(t.related.col,t.related.row)||this._unbindFromCell()})),t.listen(yt.SELECTED_CELL,(t=>{this._isBindCell(t.col,t.row)&&this._unbindFromCell()})),t.listen(yt.SCROLL,(e=>{const i=this._attachInfo;if(i?.tooltipOptions&&i?.range?.start){const{col:e,row:n}=i.range.start,r=t.getCellRangeRelativeRect({col:e,row:n});i.tooltipOptions.referencePosition.rect=r,this._move(i.range.start.col,i.range.start.row,i.tooltipOptions)}}))}_getTooltipInstanceInfo(t,e){const i=this._table,n=this._tooltipInstances,r="bubble-tooltip";return n&&n[r]||n&&(n[r]=vP[r](i))}isBinded(t){return JSON.stringify(t)===JSON.stringify(this._attachInfo?.tooltipOptions)}}class CP{_table;_menuElement;constructor(t){this._table=t}dispose(){this.unbindMenuElement(),this._menuElement&&this._menuElement.dispose(),this._menuElement=void 0}_getMenuElement(){return this._menuElement||(this._menuElement=this.createMenuElementInternal()),this._menuElement}bindMenuElement(t,e,i){return this._getMenuElement().bindToCell(this._table,t,e,i)}unbindMenuElement(){this._getMenuElement().unbindFromCell()}pointInMenuElement(t,e){return this._getMenuElement().pointInMenuElement(t,e)}}const xP="vtable__menu-element",_P=`${xP}--hidden`,SP=`${xP}--shown`;class AP{_handler;_rootElement;_menuInstanceInfo;constructor(t){this._handler=new xt,this._rootElement=KR("div",[xP,_P]),this._rootElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._rootElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(_P))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n),h=t._dropDownMenuIsHighlight(i,n,r);t.fireListeners(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("mousemove",(t=>{this._rootElement.classList.contains(_P)||t.stopPropagation()}))}get rootElement(){return this._rootElement}dispose(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler.dispose(),delete this._rootElement}bindToCell(t,e,i,n){const r=this._rootElement;if(this._menuInstanceInfo=n,r?.classList.remove(SP),r?.classList.add(_P),this._canBindToCell(t,e,i)){r.innerHTML="",r.appendChild(n.content);if(this._bindCell(t,e,i,n.position,n.referencePosition))return r?.classList.add(SP),r?.classList.remove(_P),!0}else this.unbindFromCell();return!1}unbindFromCell(){const t=this._rootElement;this._menuInstanceInfo=void 0,t?.parentElement&&(t.classList.remove(SP),t.classList.add(_P))}_canBindToCell(t,e,i){const n=t.getCellRangeRelativeRect({col:e,row:i}),r=t.getElement(),{top:o,bottom:s,left:a,right:l}=n,{frozenRowCount:h,frozenColCount:c}=t;if(i>=h&&h>0){if(s<t.getCellRangeRelativeRect({col:e,row:h-1}).bottom)return!1}else if(s<0)return!1;if(e>=c&&c>0){if(l<t.getCellRangeRelativeRect({col:c-1,row:i}).right)return!1}else if(l<0)return!1;const{offsetHeight:d,offsetWidth:u}=r;return!(d<o)&&!(u<a)}_bindCell(t,e,i,n,r){const o=this._rootElement,s=t.getElement(),{width:a,height:l}=t.internalProps.element.getBoundingClientRect();if(o){o.parentElement!==s&&s.appendChild(o),o.style.left="0px";const t=.8*a;o.style.maxWidth=`${t}px`;const e=o.clientWidth,i=o.clientHeight;let h,c;return n&&(h=n.x,c=n.y),r&&(h=r.rect.right-e,c=r.rect.bottom),c+i>l&&(c=l-i,h+=e-2),c<0&&(c/=2),o.style.top=`${c}px`,h<0?h=0:h+e>a&&(h=a-e),o.style.left=`${h}px`,!0}return!1}pointInMenuElement(t,e){const i=this._rootElement,{x:n,y:r,width:o,height:s}=i.getBoundingClientRect();return t>n-5&&t<n+o+5&&e>r-5&&e<r+s+5}}class TP extends CP{createMenuElementInternal(){return new sP(this._table)}}let BP=class extends CP{createMenuElementInternal(){return new AP(this._table)}};const MP={"dropdown-menu":function(t){return new TP(t)},"context-menu":function(t){return new TP(t)},container:t=>new BP(t)};class RP{_table;_menuInstances;_attachInfo;constructor(t){this._table=t,this._menuInstances={},this._bindTableEvent(t)}dispose(){const t=this._menuInstances;for(const e in t)t[e].dispose();delete this._menuInstances,this._attachInfo=null}_bindToCell(t,e,i,n){const r=this._attachInfo,o=this._getMenuInstanceInfo(t,e,i,n);if(!r||o&&r.instance===o.instance||(r.instance?.unbindMenuElement(),this._attachInfo=null),!o)return;const{instance:s,info:a}=o;if(s&&s.bindMenuElement(t,e,a)){const i=this._table.getCellRange(t,e);this._attachInfo={range:i,instance:s}}}_unbindFromCell(){const t=this._attachInfo;if(!t)return;const{instance:e}=t;e?.unbindMenuElement(),this._attachInfo=null}_isBindToCell(t,e){const i=this._attachInfo;return!!i&&at(i.range,t,e)}pointInMenuElement(t,e){if(!this._attachInfo)return!1;const i=this._attachInfo,{instance:n}=i;return n.pointInMenuElement(t,e)}_bindTableEvent(t){t.listen(yt.DROPDOWN_ICON_CLICK,(t=>{this._attachInfo&&this._isBindToCell(t.col,t.row)?this._unbindFromCell():this._bindToCell(t.col,t.row,"dropdown-menu")})),t.listen(yt.DROPDOWN_MENU_CLEAR,(t=>{this._unbindFromCell()})),t.listen(yt.CONTEXTMENU_CELL,(e=>{if("html"===t.internalProps.menu?.renderMode){const i=t._getMouseAbstractPoint(e.event,!1);let n=null;i&&"function"==typeof t.internalProps.menu?.contextMenuItems?n=t.internalProps.menu.contextMenuItems(t.getHeaderField(e.col,e.row),e.row):i&&Array.isArray(t.internalProps.menu?.contextMenuItems)&&(n=t.internalProps.menu?.contextMenuItems),this._bindToCell(e.col,e.row,"context-menu",{content:n,position:{x:i.x,y:i.y}})}}))}_getMenuInstanceInfo(t,e,i,n){const r=this._table,o=this._menuInstances,s=function(t,e,i,n,r){const{lineHeight:o,textBaseline:s,textStick:a}=t._getCellStyle(e,i);let l=t.getCellRangeRelativeRect(t.getCellRange(e,i));a&&(l=t.getVisibleCellRangeRelativeRect({col:e,row:i}));let{left:h,right:c,bottom:d,top:u,width:p,height:f}=l;if(t.isHeader(e,i)&&({left:h,right:c,bottom:d,top:u,width:p,height:f}=t.internalProps.headerHelper.getDropDownIconRect(l,o,s||"middle")),r?.content)return{type:n,position:r.position,referencePosition:r.referencePosition??{rect:{left:h,right:c,top:u,bottom:d,width:p,height:f}},content:r.content};if("dropdown-menu"===n){const{dropDownMenu:r=t.globalDropDownMenu,pivotInfo:o}=t._getHeaderLayoutMap(e,i);return{type:n,referencePosition:{rect:{left:h,right:c,top:u,bottom:d,width:p,height:f}},content:r,pivotInfo:o}}return null}(r,t,e,i,n);if(!s)return null;return{instance:o&&o[i]||o&&(o[i]=MP[i](r)),type:i,info:s}}}class PP extends EventTarget{_table;_input;constructor(t,e){if(super(),this._table=t,"node"===vt.mode)return;const i=document.createElement("div");i.style.opacity="0",i.dataset.vtable="vtable",i.style.pointerEvents="none",i.classList.add("input-container");const n=this._input=document.createElement("input");i.appendChild(n),n.classList.add("table-focus-control"),n.dataset.vtable="vtable",n.readOnly=!0,e.appendChild(i)}focus(){this._input.focus({preventScroll:!0})}setFocusRect(t,e){const i=this._input;i.value=e,i.select();const n=t.top-this._table.scrollTop,r=t.left-this._table.scrollLeft;i.style.top=`${n.toFixed()}px`,i.style.left=`${r.toFixed()}px`,i.style.width=`${t.width.toFixed()}px`,i.style.height=`${t.height.toFixed()}px`}get input(){return this._input}dispose(){}}let EP=1;V?EP=1:(EP=Math.ceil(window.devicePixelRatio||1),EP>1&&EP%2!=0&&(EP+=1));const HP={orient:"bottom",position:"middle",padding:30,title:{visible:!1,padding:0,textStyle:{fontSize:14,fill:"#000000",fontWeight:"normal"},space:12},item:{visible:!0,spaceCol:10,spaceRow:10,padding:2,background:{state:{selectedHover:{fill:"gray",fillOpacity:.7},unSelectedHover:{fill:"gray",fillOpacity:.2}}},shape:{space:4,state:{unSelected:{fillOpacity:.5}}},label:{space:4,style:{fill:"#89909D",fontSize:14},state:{unSelected:{fillOpacity:.5}}}},allowAllCanceled:!1,visible:!0};function kP(t,e){const{title:i={},item:n={},pager:r={},background:o={},type:s,id:a,visible:l,orient:h,position:c,data:d,filter:u,regionId:p,regionIndex:f,seriesIndex:g,seriesId:y,padding:m,...b}=Zt({},HP,t),v=b;return i.visible&&(v.title=function(t){const e={...t};return Ut(t.style)||(e.textStyle=KS(t.style)),Ut(t.textStyle)||Zt(e.textStyle,KS(t.textStyle)),t.shape?.style&&KS(e.shape.style),t.background?.style&&KS(e.background.style),e}(i)),Ut(n.focusIconStyle)||KS(n.focusIconStyle),US(n.shape),US(n.label),US(n.value),US(n.background),xC(n.maxWidth)&&(n.maxWidth=Number(n.maxWidth.substring(0,n.maxWidth.length-1))*e.width/100),xC(n.width)&&(n.width=Number(n.width.substring(0,n.width.length-1))*e.width/100),xC(n.height)&&(n.height=Number(n.height.substring(0,n.height.length-1))*e.width/100),v.item=n,Ut(r.textStyle)||KS(r.textStyle),US(r.handler),v.pager=r,o.visible&&!Ut(o.style)&&(Zt(v,o.style),kt(o.padding)&&(v.padding=o.padding)),v}class LP{table;option;orient;visible;position;selectedData;legendComponent;constructor(t,e){this.table=e,this.option=$t(t),this.orient=t.orient??"left",this.visible=t.visible??!0,this.position=t.position??"middle",this.selectedData=t.defaultSelected??[],this.createComponent(),this.initEvent()}createComponent(){const t=this.getLegendAttributes({width:this.table.tableNoFrameWidth,height:this.table.tableNoFrameHeight}),e=new V_(Zt({},t,{defaultSelected:this.selectedData}));e.name="legend",this.legendComponent=e,this.table.scenegraph.stage.defaultLayer.appendChild(e);let i=isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,n=isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0;const r=this.table.tableNoFrameWidth,o=this.table.tableNoFrameHeight,s=Gw(t.padding??this.option.padding??10);let a=0,l=0;"left"===this.orient?(a=s[3],l=0,i+=s[1]+s[3]):"top"===this.orient?(a=0,l=s[0],n+=s[0]+s[2]):"right"===this.orient?(a=r-i-s[1],l=0,i+=s[1]+s[3]):"bottom"===this.orient&&(a=0,l=o-n-s[2],n+=s[0]+s[2]);const h="bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",c=this.position;let d=0,u=0;"horizontal"===h?d="middle"===c?(r-i)/2:"end"===c?r-i-s[1]:s[3]:u="middle"===c?(o-n)/2:"end"===c?o-n-s[2]:s[0],this.legendComponent.setAttributes({dx:d,dy:u,x:a,y:l}),"left"===this.orient?(this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(i),this.table.tableX=Math.ceil(i)):"top"===this.orient?(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(n),this.table.tableY=Math.ceil(n)):"right"===this.orient?this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(i):"bottom"===this.orient&&(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(n))}getLegendAttributes(t){return{layout:"bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",items:this.getLegendItems(),maxWidth:t.width,maxHeight:t.height,...kP(this.option,t)}}getLegendItems(){return this.option.data}initEvent(){this.legendComponent&&(this.legendComponent.addEventListener(j_.legendItemClick,(t=>{const e=Vt(t,"detail.currentSelected");this.table.scenegraph.updateNextFrame(),this.table.fireListeners(yt.LEGEND_ITEM_CLICK,{model:this,value:e,event:t})})),this.legendComponent.addEventListener(j_.legendItemHover,(t=>{const e=Vt(t,"detail");this.table.scenegraph.updateNextFrame(),this.table.fireListeners(yt.LEGEND_ITEM_HOVER,{model:this,value:e,event:t})})),this.legendComponent.addEventListener(j_.legendItemUnHover,(t=>{const e=Vt(t,"detail");this.table.scenegraph.updateNextFrame(),this.table.fireListeners(yt.LEGEND_ITEM_UNHOVER,{model:this,value:e,event:t})})))}getLegendBounds(){return{width:isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,height:isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0}}dispose(){this.legendComponent=null}}class IP{table;_titleOption;_titleComponent;_cacheAttrs;constructor(t,e){this.table=e,this._titleOption=t,this._titleComponent=this._createOrUpdateTitleComponent(this._getTitleAttrs())}_createOrUpdateTitleComponent(t){if(this._titleComponent)te(t,this._cacheAttrs)||this._titleComponent.setAttributes(t);else{const e=new $_(t);e.name="title",this.table.scenegraph.stage.defaultLayer.appendChild(e),this._titleComponent=e}let e=isFinite(this._titleComponent.AABBBounds.width())?this._titleComponent.AABBBounds.width():0;const i=isFinite(this._titleComponent.AABBBounds.height())?this._titleComponent.AABBBounds.height():0,n=(this.table.tableNoFrameWidth,this.table.tableNoFrameHeight,Gw(t.padding??this._titleOption.padding??10));return"left"===this._titleOption.orient?n[3]:"top"===this._titleOption.orient?n[0]:"right"===this._titleOption.orient?(n[1],e+=n[1]+n[3]):"bottom"===this._titleOption.orient&&n[2],"left"===this._titleOption.orient?(this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e),this.table.tableX=Math.ceil(e)):"top"===this._titleOption.orient?(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i),this.table.tableY=Math.ceil(i)):"right"===this._titleOption.orient?this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e):"bottom"===this._titleOption.orient&&(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i)),this._cacheAttrs=t,"right"!==this._titleOption.orient&&"bottom"!==this._titleOption.orient||this._titleComponent.setAttributes({x:this._titleOption.x??"right"===this._titleOption.orient?this.table.tableX+this.table.tableNoFrameWidth:this.table.tableX,y:this._titleOption.y??"bottom"===this._titleOption.orient?this.table.tableY+this.table.tableNoFrameHeight:this.table.tableY}),this._titleComponent}dispose(){this._titleComponent=null}_getTitleAttrs(){const t=Gw(this._titleOption.padding??10),e=this._titleOption.width??this.table.tableNoFrameWidth-t[1]-t[3];return{text:this._titleOption.text??"",subtext:this._titleOption.subtext??"",x:this._titleOption.x??"right"===this._titleOption.orient?this.table.tableX+this.table.tableNoFrameWidth:this.table.tableX,y:this._titleOption.y??"bottom"===this._titleOption.orient?this.table.tableY+this.table.tableNoFrameHeight:this.table.tableY,width:e,height:this._titleOption.height,minWidth:this._titleOption.minWidth,maxWidth:this._titleOption.maxWidth,minHeight:this._titleOption.minHeight,maxHeight:this._titleOption.maxHeight,padding:this._titleOption.padding,align:this._titleOption.align??"left",verticalAlign:this._titleOption.verticalAlign??"top",textStyle:{width:e,...this._titleOption.textStyle},subtextStyle:{width:e,...this._titleOption.subtextStyle}}}}const{toBoxArray:OP}=ft,{isTouchEvent:DP}=pt,FP=/^\$(\d+)\$(\d+)$/;!function(){const t=document.createElement("style");t.id="vtable-style-styleSheet",t.textContent="\n.vtable .input-container {\n\tposition: absolute;\n\ttop:0px;\n}\n.vtable .table-scrollable {\n\tposition: absolute;\n\toverflow: scroll;\n}\n.vtable .table-scrollable::-webkit-scrollbar-button{\n\tbackground-color: transparent;\n}\n.vtable .table-scrollable::-webkit-scrollbar-track-piece{\n\tbackground-color: transparent;\n}\n.vtable .table-scrollable::-webkit-scrollbar-corner {\n\tbackground-color: transparent;\n}\n.vtable .table-scrollable::-webkit-scrollbar-thumb {\n\tborder-radius : 4px;\n\tbackground-color : rgba(100, 100, 100, .5);\n}\n\n.vtable .table-scroll-end-point {\n\topacity: 0;\n\tposition: relative;\n}\n.vtable {\n\t/* 设置overflow: auto 应该是为了滚动条的某个问题 但设置了auto之后 dom的下拉菜单只能显示在vtable节点中 超出会截断;现在去掉auto 暂时滚动条的问题没有发现 */\n\t/* overflow: auto; */\n\tposition: relative;\n\twidth: 100%;\n\theight: 100%;\n\ttext-align: left;\n -webkit-font-smoothing:auto;\n}\n.vtable > canvas {\n\tposition: absolute;\n\twidth: 0;\n\theight: 0;\n}\n.vtable .table-focus-control {\n\tposition: relative !important;\n\twidth: 1px;\n\theight: 1px;\n\topacity: 0;\n\tpadding: 0;\n\tmargin: 0;\n\tbox-sizing: border-box;\n\tpointer-events: none;\n\tmax-width: 500px;\n\tmax-height: 500px;\n\tfloat: none !important;\n}\n.vtable input.table-focus-control::-ms-clear {\n\tvisibility: hidden;\n}\n.vtable input.table-focus-control.composition {\n\topacity: 1;\n\tmax-width: none;\n\tmax-height: none;\n}\n",document.body.appendChild(t)}();const WP={};class zP extends E{internalProps;showFrozenIcon=!0;showSort=!0;padding;globalDropDownMenu;tableNoFrameWidth;tableNoFrameHeight;tableX;tableY;_widthMode;_heightMode;_autoFillWidth;customRender;canvasWidth;canvasHeight;dataSet;scenegraph;stateManeger;eventManeger;_pixelRatio;bottomFrozenRowCount=0;rightFrozenColCount=0;static get EVENT_TYPE(){return yt}options;version="0.9.2-alpha.1";pagerConf;id=`VTable${Date.now()}`;headerStyleCache;bodyStyleCache;constructor(t={}){super();const{frozenColCount:e=0,defaultRowHeight:i=40,defaultHeaderRowHeight:n,defaultColWidth:r=80,defaultHeaderColWidth:o,widthMode:s="standard",heightMode:a="standard",autoFillWidth:l=!1,keyboardOptions:h,parentElement:c,columnResizeMode:d,dragHeaderMode:u,showFrozenIcon:p,allowFrozenColCount:f,padding:g,hover:y,menu:m,select:b,customRender:v,pixelRatio:w=EP}=t;this.options=t,this._widthMode=s,this._heightMode=a,this._autoFillWidth=l,this.customRender=v,this.padding={top:0,right:0,left:0,bottom:0},g&&("number"==typeof g?(this.padding.top=g,this.padding.left=g,this.padding.bottom=g,this.padding.right=g):(g.top&&(this.padding.top=g.top),g.bottom&&(this.padding.bottom=g.bottom),g.left&&(this.padding.left=g.left),g.right&&(this.padding.right=g.right))),this.tableNoFrameWidth=0,this.tableNoFrameHeight=0;const C=this.internalProps={};void 0!==p&&(this.showFrozenIcon=p),"number"==typeof f&&f<=0&&(this.showFrozenIcon=!1),C.handler=new xt,C.element=function(t){const e=document.createElement("div");e.setAttribute("tabindex","0"),e.classList.add("vtable"),e.style.outline="none",e.style.margin=`${t.top}px ${t.right}px ${t.bottom}px ${t.left}px`;const i=(e.offsetWidth||e.parentElement?.offsetWidth||1)-1,n=(e.offsetHeight||e.parentElement?.offsetHeight||1)-1;return e.style.width=i&&i-t.left-t.right+"px"||"0px",e.style.height=n&&n-t.top-t.bottom+"px"||"0px",e}(this.padding),C.focusControl=new PP(this,C.element),C.pixelRatio=w,C.canvas=document.createElement("canvas"),C.element.appendChild(C.canvas),C.context=C.canvas.getContext("2d"),C.frozenColCount=e,C.defaultRowHeight=i,C.defaultHeaderRowHeight=n??i,C.defaultColWidth=r,C.defaultHeaderColWidth=o??r,C.keyboardOptions=h,C.columnResizeMode=d,C.dragHeaderMode=u,C._rowHeightsMap=new St,C._rowRangeHeightsMap=new Map,C._colRangeWidthsMap=new Map,this.colWidthsMap=new St,this.colContentWidthsMap=new St,this.colWidthsLimit={},C.calcWidthContext={_:C,get full(){return this._.canvas.width/(this._.context.pixelRatio??window.devicePixelRatio)}},C.cellTextOverflows={},C.focusedTable=!1,C.theme=Qe.of(t.theme??Qe.DEFAULT),c?(c.innerHTML="",c.appendChild(C.element),this._updateSize()):this._updateSize(),this.options=t,C.theme=Qe.of(t.theme??Qe.DEFAULT),C.bodyHelper=new GR(this),C.headerHelper=new cP(this),C.autoWrapText=t.autoWrapText,C.allowFrozenColCount=t.allowFrozenColCount??C.colCount,C.limitMaxAutoWidth=t.limitMaxAutoWidth??450,this.dataSet=new _M,this.scenegraph=new yR(this),this.stateManeger=new ER(this),this.eventManeger=new FR(this),t.legends&&(C.legends=new LP(t.legends,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),t.title&&(C.title=new IP(t.title,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),C.tooltip=Object.assign({renderMode:"html",isShowOverflowTextTooltip:!1,confine:!0},t.tooltip),"html"===C.tooltip.renderMode&&(C.tooltipHandler=new wP(this,C.tooltip.confine)),C.menu=Object.assign({renderMode:"html"},t.menu),Array.isArray(t.menu?.dropDownMenuHighlight)&&this.setDropDownMenuHighlight(t.menu?.dropDownMenuHighlight),Array.isArray(t.menu?.defaultHeaderMenuItems)&&(this.globalDropDownMenu=t.menu.defaultHeaderMenuItems),"html"===C.menu.renderMode&&(C.menuHandler=new RP(this)),this.headerStyleCache=new Map,this.bodyStyleCache=new Map}throttleInvalidate=function(t,e){let i=null;return function(...n){i||(i=setTimeout((()=>{t.apply(this,n),i=null}),e))}}(this.invalidate.bind(this),200);getParentElement(){return this.options.parentElement}getElement(){return this.internalProps.element}get canvas(){return this.internalProps.canvas}resize(){this._updateSize(),this.scenegraph.resize()}get rowCount(){return this.internalProps.rowCount}set rowCount(t){this.internalProps.rowCount=t}get colCount(){return this.internalProps.colCount??0}set colCount(t){this.internalProps.colCount=t}get frozenColCount(){return this.internalProps.frozenColCount??0}set frozenColCount(t){t>=this.colCount&&(t=0),this.internalProps.frozenColCount=t,this.options.frozenColCount=t,this.tableNoFrameWidth-this.getColsWidth(0,t-1)<=120&&(this.internalProps.frozenColCount=0),this.stateManeger.setFrozenCol(this.internalProps.frozenColCount)}setFrozenColCount(t){t>=this.colCount&&(t=0),this.internalProps.frozenColCount=t,this.options.frozenColCount=t,this.tableNoFrameWidth-this.getColsWidth(0,t-1)<=120&&(this.internalProps.frozenColCount=0),this.stateManeger.setFrozenCol(this.internalProps.frozenColCount)}_setFrozenColCount(t){t>=this.colCount&&(t=0),this.internalProps.frozenColCount=t}_resetFrozenColCount(){this.options.frozenColCount&&(this.tableNoFrameWidth-this.getColsWidth(0,this.options.frozenColCount-1)<=120?this._setFrozenColCount(0):this.frozenColCount!==this.options.frozenColCount&&this._setFrozenColCount(this.options.frozenColCount))}get frozenRowCount(){return this.internalProps.frozenRowCount??0}set frozenRowCount(t){this.internalProps.frozenRowCount=t}get defaultRowHeight(){return this.internalProps.defaultRowHeight}set defaultRowHeight(t){this.internalProps.defaultRowHeight=t,this.options.defaultRowHeight=t}get defaultHeaderRowHeight(){return this.internalProps.defaultHeaderRowHeight}set defaultHeaderRowHeight(t){this.internalProps.defaultHeaderRowHeight=t,this.options.defaultHeaderRowHeight=t}get defaultColWidth(){return this.internalProps.defaultColWidth}set defaultColWidth(t){this.internalProps.defaultColWidth=t,this.options.defaultColWidth=t}get defaultHeaderColWidth(){return this.internalProps.defaultHeaderColWidth}set defaultHeaderColWidth(t){this.internalProps.defaultHeaderColWidth=t,this.options.defaultHeaderColWidth=t}get colWidthsMap(){return this.internalProps._colWidthsMap}set colWidthsMap(t){this.internalProps._colWidthsMap=t}get colContentWidthsMap(){return this.internalProps._colContentWidthsMap}set colContentWidthsMap(t){this.internalProps._colContentWidthsMap=t}get _colRangeWidthsMap(){return this.internalProps._colRangeWidthsMap}set _colRangeWidthsMap(t){this.internalProps._colRangeWidthsMap=t}get _rowRangeHeightsMap(){return this.internalProps._rowRangeHeightsMap}set _rowRangeHeightsMap(t){this.internalProps._rowRangeHeightsMap=t}get rowHeightsMap(){return this.internalProps._rowHeightsMap}set rowHeightsMap(t){this.internalProps._rowHeightsMap=t}get colWidthsLimit(){return this.internalProps._colWidthsLimit}set colWidthsLimit(t){this.internalProps._colWidthsLimit=t}get keyboardOptions(){return this.internalProps.keyboardOptions??null}set keyboardOptions(t){this.internalProps.keyboardOptions=t??void 0}get widthMode(){return this._widthMode}set widthMode(t){t!==this._widthMode&&(this._widthMode=t)}get heightMode(){return this._heightMode}set heightMode(t){t!==this._heightMode&&(this._heightMode=t)}get autoFillWidth(){return this._autoFillWidth}set autoFillWidth(t){t!==this._autoFillWidth&&(this._autoFillWidth=t)}_colWidthDefineToPxWidth(t){return MC(t)?TC(this,this._calculateAutoColWidthExpr()):TC(this,t)}_calculateAutoColWidthExpr(){const t=this.internalProps.calcWidthContext.full;let e=0;const i=[];let n=0;const r=[];for(let o=0;o<this.internalProps.colCount;o++){const s=this.getColWidthDefine(o),a=this._getColWidthLimits(o);if(MC(s))a&&(r.push(a),a.min&&(e+=a.min)),n++;else{let t=s;if(a){const i=TC(this,t),n=BC(a,i);i!==n&&(t=`${n}px`),e+=n}i.push(t)}if(e>t)return"0px"}if(r.length&&i.length){const e=(t-TC(this,`calc(${i.map((t=>"number"==typeof t?`${t}px`:t)).join(" + ")})`))/n;if(r.forEach((t=>{t.min&&e<t.min?(i.push(t.minDef),n--):t.max&&t.max<e&&(i.push(t.maxDef),n--)})),n<=0)return`${e}px`}if(i.length){const t=[];let e=0;return i.forEach((i=>{"number"==typeof i?e+=i:t.push(i)})),t.push(`${e}px`),`calc((100% - (${t.join(" + ")})) / ${n})`}return 100/n+"%"}_getColWidthLimits(t){const e=this.colWidthsLimit[t];if(!e)return null;const i={};return e.min&&(i.min=TC(this,e.min),i.minDef=e.min),e.max&&(i.max=TC(this,e.max),i.maxDef=e.max),i}_adjustColWidth(t,e){const i=this._getColWidthLimits(t);return Math.max(BC(i,e),0)}setPixelRatio(t){this.internalProps.pixelRatio=t,this.scenegraph.setPixelRatio(t)}_updateSize(){const{padding:t}=this;let e=0,i=0;if("browser"===vt.mode){const n=this.getElement(),r=n.parentElement?.offsetWidth??0,o=n.parentElement?.offsetHeight??0;n.style.width=r&&r-t.left-t.right+"px"||"0px",n.style.height=o&&o-t.top-t.bottom+"px"||"0px";const{canvas:s}=this.internalProps;e=s.parentElement?.offsetWidth??0,i=s.parentElement?.offsetHeight??0,this?.scenegraph?.stage?this.scenegraph.stage.window.resize(e,i):(s.style.width="",s.style.height="",s.width=e,s.height=i,s.style.width=`${e}px`,s.style.height=`${i}px`)}else"node"===vt.mode&&(e=this.canvasWidth-1,i=this.canvasHeight-1);const n=Math.floor(e-U(this.getTheme().scrollStyle)),r=Math.floor(i-U(this.getTheme().scrollStyle));if(this.internalProps.theme?.frameStyle){const t=OP(this.internalProps.theme.frameStyle?.borderLineWidth??[null]),e=OP(this.internalProps.theme.frameStyle?.shadowBlur??[0]);this.tableX=(t[3]??0)+(e[3]??0),this.tableY=(t[0]??0)+(e[0]??0),this.tableNoFrameWidth=n-((t[1]??0)+(e[1]??0))-((t[3]??0)+(e[3]??0)),this.tableNoFrameHeight=r-((t[0]??0)+(e[0]??0))-((t[2]??0)+(e[2]??0))}}get rowHierarchyType(){return"grid"}setColWidths(t){t.forEach(((t,e)=>this.setColWidth(e,t)))}getColsWidth(t,e){e=Math.min(e,this.colCount-1);const i=this._colRangeWidthsMap.get(`$${t}$${e}`);if(null!=i)return i;const n=this._colRangeWidthsMap.get(`$${t}$${e-1}`);if(null!=n){const i=this.colWidthsMap.get(e);let r;r=i?"adaptive"===this.widthMode||this.transpose?Number(i):this._adjustColWidth(e,this._colWidthDefineToPxWidth(i)):this.isRowHeader(e,0)||this.isCornerHeader(e,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[e]??this.internalProps.defaultColWidth:this.defaultHeaderColWidth:this.internalProps.defaultColWidth;const o=n+r;return t>=0&&e>=0&&!Number.isNaN(o)&&this._colRangeWidthsMap.set(`$${t}$${e}`,Math.round(o)),Math.round(o)}let r=0;for(let i=t;i<=e;i++)r+=this.isRowHeader(i,0)||this.isCornerHeader(i,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[i]??this.internalProps.defaultColWidth:this.defaultHeaderColWidth:this.internalProps.defaultColWidth;this.colWidthsMap.each(t,e,((t,e)=>{r+=("adaptive"===this.widthMode||this.transpose?Number(t):this._adjustColWidth(e,this._colWidthDefineToPxWidth(t)))-(this.isRowHeader(e,0)||this.isCornerHeader(e,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[e]??this.internalProps.defaultColWidth:this.defaultHeaderColWidth:this.internalProps.defaultColWidth)}));for(let i=t;i<=e;i++){if(this.colWidthsMap.has(i))continue;const t=this._adjustColWidth(i,this.internalProps.defaultColWidth);t!==this.internalProps.defaultColWidth&&(r+=t-this.internalProps.defaultColWidth)}return t>=0&&e>=0&&this._colRangeWidthsMap.set(`$${t}$${e}`,Math.round(r)),Math.round(r)}getRowHeight(t){return this.rowHeightsMap.get(t)?this.rowHeightsMap.get(t):this.isColumnHeader(0,t)||this.isCornerHeader(0,t)||this.isBottomFrozenRow(this.rowHeaderLevelCount,t)?Array.isArray(this.defaultHeaderRowHeight)?this.defaultHeaderRowHeight[t]??this.internalProps.defaultRowHeight:this.defaultHeaderRowHeight:this.internalProps.defaultRowHeight}setRowHeight(t,e,i){this.rowHeightsMap.put(t,Math.round(e)),i&&this._clearRowRangeHeightsMap(t)}fillRowsHeight(t,e,i){for(let n=t;n<=e;n++)this.rowHeightsMap.put(n,Math.round(i)),this._rowRangeHeightsMap.set(`$0$${n}`,Math.round((this._rowRangeHeightsMap.get("$0$"+(n-1))??0)+i))}getRowsHeight(t,e){const i=this._rowRangeHeightsMap.get(`$${t}$${e}`);if(null!=i)return i;const n=this._rowRangeHeightsMap.get(`$${t}$${e-1}`);if(null!=n){const i=Math.round(n+(this.rowHeightsMap.get(e)??(this.isColumnHeader(0,e)||this.isCornerHeader(0,e)?Array.isArray(this.defaultHeaderRowHeight)?this.defaultHeaderRowHeight[e]??this.internalProps.defaultRowHeight:this.defaultHeaderRowHeight:this.internalProps.defaultRowHeight)));return t>=0&&e>=0&&this._rowRangeHeightsMap.set(`$${t}$${e}`,Math.round(i)),i}let r=0;for(let i=t;i<=e;i++)r+=this.getRowHeight(i);return t>=0&&e>=0&&r>0&&this._rowRangeHeightsMap.set(`$${t}$${e}`,Math.round(r)),Math.round(r)}getColWidthDefine(t){const e=this.colWidthsMap.get(t);return"number"==typeof e&&e<=0?0:e||(this.isRowHeader(t,0)||this.isCornerHeader(t,0)||this.isRightFrozenColumn(t,this.columnHeaderLevelCount)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[t]??this.defaultColWidth:this.defaultHeaderColWidth:this.defaultColWidth)}getColWidth(t){const e=this.getColWidthDefine(t);return"adaptive"===this.widthMode&&"number"==typeof e||this.transpose&&"number"==typeof e?this._colWidthDefineToPxWidth(e):this._adjustColWidth(t,this._colWidthDefineToPxWidth(e))}setColWidth(t,e,i,n){this.colWidthsMap.put(t,"number"==typeof e?Math.round(e):e),i&&this._clearColRangeWidthsMap(t),n||this.stateManeger.checkFrozen()}_clearColRangeWidthsMap(t){if("number"!=typeof t)this._colRangeWidthsMap.clear();else{const e=this._colRangeWidthsMap.keys();for(const i of e){const e=FP.exec(i);if(e){const n=Number(e[1]),r=Number(e[2]);t>=n&&t<=r&&this._colRangeWidthsMap.delete(i)}}}}_clearRowRangeHeightsMap(t){if("number"!=typeof t)this._rowRangeHeightsMap.clear();else{const e=this._rowRangeHeightsMap.keys();for(const i of e){const e=FP.exec(i);if(e){const n=Number(e[1]),r=Number(e[2]);t>=n&&t<=r&&this._rowRangeHeightsMap.delete(i)}}}}_getColContentWidth(t){return Number(this.colContentWidthsMap.get(t))}_setColContentWidth(t,e){this.colContentWidthsMap.put(t,e)}getAllRowsHeight(){if(this.internalProps.rowCount<=0)return 0;return this.getRowsHeight(0,this.internalProps.rowCount-1)}getAllColsWidth(){if(this.internalProps.colCount<=0)return 0;return this.getColsWidth(0,this.internalProps.colCount-1)}getMaxColWidth(t){const e=this.colWidthsLimit[t];let i=(e&&e.max)??1/0;return"string"==typeof i&&(i=TC(this,i)),i}setMaxColWidth(t,e){(this.colWidthsLimit[t]||(this.colWidthsLimit[t]={})).max=e}getMinColWidth(t){const e=this.colWidthsLimit[t];let i=(e&&e.min)??0;return"string"==typeof i&&(i=TC(this,i)),i}setMinColWidth(t,e){(this.colWidthsLimit[t]||(this.colWidthsLimit[t]={})).min=e}getCellRect(t,e){const i=this.isFrozenCell(t,e);let n=this.getColsWidth(0,t-1)||0;const r=this.getColWidth(t);i&&i.col&&(n+=this.scrollLeft);let o=this.getRowsHeight(0,e-1);const s=this.getRowHeight(e);return i&&i.row&&(o+=this.scrollTop),new Re(Math.round(n),Math.round(o),Math.round(r),Math.round(s))}getMergeCellRect(t,e){const i=this.getCellRange(t,e),n=this.getColsWidth(0,i.start.col-1)||0,r=this.getColsWidth(i.start.col,i.end.col),o=this.getRowsHeight(0,i.start.row-1)||0,s=this.getRowsHeight(i.start.row,i.end.row);return new Re(Math.round(n),Math.round(o),Math.round(r),Math.round(s))}getCellRelativeRect(t,e){return this._toRelativeRect(this.getCellRect(t,e))}getCellRangeRelativeRect(t){if(t.start)return this._toRelativeRect(this.getCellsRect(t.start.col,t.start.row,t.end.col,t.end.row));const e=this.getCellRange(t.col,t.row);return this._toRelativeRect(this.getCellsRect(e.start.col,e.start.row,e.end.col,e.end.row))}getVisibleCellRangeRelativeRect(t){let e;return e=t.start?t:this.getCellRange(t.col,t.row),this._getVisiableRect(this.getCellRangeRelativeRect(t),e)}_getVisiableRect(t,e){const i=e.start.col>=this.frozenColCount?Math.max(t.left,this.frozenColCount>=1?this.getColsWidth(0,this.frozenColCount-1):0):t.left,n=Math.min(t.right,this.tableNoFrameWidth),r=t.copy();r.left=i,r.right=n;const o=e.start.row>=this.frozenRowCount?Math.max(t.top,this.frozenRowCount>=1?this.getRowsHeight(0,this.frozenRowCount-1):0):t.top,s=Math.min(t.bottom,this.tableNoFrameHeight);return r.top=o,r.bottom=s,r}getCellsRect(t,e,i,n){const r=this.isFrozenCell(t,e),o=this.isFrozenCell(i,n);let s=this.getColsWidth(0,t-1)||0,a=this.getColsWidth(t,i);if(r&&r.col){const e=this.scrollLeft;s+=e,o&&o.col||(a-=e,a=Math.max(a,this.getColsWidth(t,this.frozenColCount-1)))}let l=this.getRowsHeight(0,e-1),h=this.getRowsHeight(e,n);if(r&&r.row){const t=this.scrollTop;l+=t,o&&o.row||(h-=t,h=Math.max(h,this.getRowsHeight(e,this.frozenRowCount-1)))}return new Re(Math.round(s),Math.round(l),Math.round(a),Math.round(h))}getCellsRectWidth(t,e,i,n){const r=this.isFrozenCell(t,e),o=this.isFrozenCell(i,n);let s=this.getColsWidth(t,i);if(r&&r.col){const e=this.scrollLeft;o&&o.col||(s-=e,s=Math.max(s,this.getColsWidth(t,this.frozenColCount-1)))}return s}getCellRangeRect(t){if(t.start)return this.getCellsRect(t.start.col,t.start.row,t.end.col,t.end.row);const e=this.getCellRange(t.col,t.row);return this.getCellsRect(e.start.col,e.start.row,e.end.col,e.end.row)}getCellRangeRectWidth(t){if(t.start)return this.getCellsRectWidth(t.start.col,t.start.row,t.end.col,t.end.row);const e=this.getCellRange(t.col,t.row);return this.getCellsRectWidth(e.start.col,e.start.row,e.end.col,e.end.row)}isFrozenCell(t,e){const{frozenRowCount:i,frozenColCount:n}=this.internalProps,r=i>0&&e<i||this.isBottomFrozenRow(t,e),o=n>0&&t<n||this.isRightFrozenColumn(t,e);return r||o?{row:r,col:o}:null}getRowAt(t){const e=function(t,e){if(!t.internalProps.frozenRowCount)return null;let{scrollTop:i}=t;const n=t.internalProps.frozenRowCount;for(let r=0;r<n;r++){const n=t.getRowHeight(r),o=i+n;if(o>e)return{top:i,row:r,bottom:o,height:n};i=o}return null}(this,t);if(e)return e;let i=this.getTargetRowAt(t);return i||(i={top:-1,row:-1,bottom:-1,height:-1}),i}getColAt(t){const e=function(t,e){if(!t.internalProps.frozenColCount)return null;let{scrollLeft:i}=t;const n=t.internalProps.frozenColCount;for(let r=0;r<n;r++){const n=t.getColWidth(r),o=i+n;if(o>e)return{left:i,col:r,right:o,width:n};i=o}return null}(this,t);if(e)return e;let i=this.getTargetColAt(t);return i||(i={left:-1,col:-1,right:-1,width:1}),i}getCellAt(t,e){const i=this.getRowAt(e),{row:n,top:r,bottom:o,height:s}=i,a=this.getColAt(t),{col:l,left:h,right:c,width:d}=a;return{row:n,col:l,rect:{left:h,right:c,top:r,bottom:o,width:d,height:s}}}_checkRowCol(t,e){return t>=0&&t<this.colCount&&e>=0&&e<this.rowCount}_makeVisibleCell(t,e){if(this._checkRowCol(t,e)){const i=this.isFrozenCell(t,e);if(i&&i.col&&i.row)return;const n=this.getCellRect(t,e),r=function(t){let e=0;t.internalProps.frozenColCount>0&&(e=t.getFrozenColsWidth());let i=0;return t.internalProps.frozenRowCount>0&&(i=t.getFrozenRowsHeight()),new Re(t.scrollLeft+e,t.scrollTop+i,t.tableNoFrameWidth-e,t.tableNoFrameHeight-i)}(this);if(r.contains(n))return;i&&i.col||this.getColsWidth(0,this.frozenColCount-1)+n.width>this.canvas.width||(n.left<r.left?this.scrollLeft-=r.left-n.left:r.right<n.right&&(this.scrollLeft-=r.right-n.right)),i&&i.row||this.getRowsHeight(0,this.frozenRowCount-1)+n.height>this.canvas.height||(n.top<r.top?this.scrollTop-=r.top-n.top:r.bottom<n.bottom&&(this.scrollTop-=r.bottom-n.bottom))}}invalidate(){this.scenegraph.renderSceneGraph()}_toRelativeRect(t){const e=t.copy(),i=this.getVisibleRect();return e.offsetLeft(-i.left),e.offsetTop(-i.top),e}getVisibleRect(){const{scrollTop:t,scrollLeft:e}=this,i=this.tableNoFrameWidth,n=this.tableNoFrameHeight;return new Re(e,t,i,n)}get visibleRowCount(){const{frozenRowCount:t}=this,e=this.getVisibleRect(),i=t>0?e.top+this.getRowsHeight(0,t-1):e.top,n=this.getTargetRowAt(i);if(!n)return 0;const r=Math.max(n.top>=i?n.row:n.row+1,t);let o=this.getRowsHeight(0,r-1),s=0;const{rowCount:a}=this;for(let t=r;t<a;t++){const i=o+this.getRowHeight(t);if(e.bottom<i)break;s++,o=i}return s}get visibleColCount(){const{frozenColCount:t}=this,e=this.getVisibleRect(),i=t>0?e.left+this.getColsWidth(0,t-1):e.left,n=this.getTargetColAt(i);if(!n)return 0;const r=Math.max(n.left>=i?n.col:n.col+1,t);let o=this.getColsWidth(0,r-1),s=0;const{colCount:a}=this;for(let t=r;t<a;t++){const i=o+this.getColWidth(t);if(e.right<i)break;s++,o=i}return s}get scrollTop(){return this.stateManeger.scroll.verticalBarPos}set scrollTop(t){this.stateManeger.setScrollTop(t)}get scrollLeft(){return this.stateManeger.scroll.horizontalBarPos}set scrollLeft(t){this.stateManeger.setScrollLeft(t)}getScrollLeft(){return this.scrollLeft}getScrollTop(){return this.scrollTop}setScrollLeft(t){this.scrollLeft=Math.ceil(t)}setScrollTop(t){this.scrollTop=Math.ceil(t)}getCellOverflowText(t,e){return this.scenegraph.getCellOverflowText(t,e)}addDisposable(t){if(!t||!t.dispose||"function"!=typeof t.dispose)throw new Error("not disposable!");(this.internalProps.disposables=this.internalProps.disposables||[]).push(t)}dispose(){const t=this.internalProps;t.tooltipHandler?.dispose?.(),t.menuHandler?.dispose?.(),EC.clearAll(),super.dispose?.(),t.handler?.dispose?.(),t.focusControl?.dispose?.(),t.disposables&&(t.disposables.forEach((t=>t?.dispose?.())),t.disposables=null),this.scenegraph.stage.release();const{parentElement:e}=t.element;e&&e.removeChild(t.element)}fireListeners(t,e){return super.fireListeners(t,e)}updateOption(t){this.options=t;const{frozenColCount:e=0,defaultRowHeight:i=40,defaultHeaderRowHeight:n,defaultColWidth:r=80,defaultHeaderColWidth:o=80,keyboardOptions:s,columnResizeMode:a,dragHeaderMode:l,showFrozenIcon:h,allowFrozenColCount:c,padding:d,hover:u,menu:p,select:f,pixelRatio:g,widthMode:y,heightMode:m,autoFillWidth:b,customRender:v}=t;g&&g!==this.internalProps.pixelRatio&&(this.internalProps.pixelRatio=g),d&&("number"==typeof d?(this.padding.top=d,this.padding.left=d,this.padding.bottom=d,this.padding.right=d):(d.top&&(this.padding.top=d.top),d.bottom&&(this.padding.bottom=d.bottom),d.left&&(this.padding.left=d.left),d.right&&(this.padding.right=d.right))),this.showFrozenIcon="boolean"!=typeof h||h,"number"==typeof c&&c<=0&&(this.showFrozenIcon=!1),this.widthMode=y??"standard",this.heightMode=m??"standard",this.autoFillWidth=b??!1,this.customRender=v;const w=this.internalProps;"node"!==vt.mode&&function(t,e){t.style.margin=`${e.top}px ${e.right}px ${e.bottom}px ${e.left}px`;const i=(t.offsetWidth||t.parentElement?.offsetWidth||1)-1,n=(t.offsetHeight||t.parentElement?.offsetHeight||1)-1;t.style.width=i&&i-e.left-e.right+"px"||"0px",t.style.height=n&&n-e.top-e.bottom+"px"||"0px"}(w.element,this.padding),w.frozenColCount=e,w.defaultRowHeight=i,w.defaultHeaderRowHeight=n??i,w.defaultColWidth=r,w.defaultHeaderColWidth=o??r,w.keyboardOptions=s,w.columnResizeMode=a,w.dragHeaderMode=l,w.cellTextOverflows={},w._rowHeightsMap=new St,w._rowRangeHeightsMap=new Map,w._colRangeWidthsMap=new Map,this.colWidthsMap=new St,this.colContentWidthsMap=new St,this.colWidthsLimit={},w.theme=Qe.of(t.theme??Qe.DEFAULT),w.autoWrapText=t.autoWrapText,w.allowFrozenColCount=t.allowFrozenColCount??w.colCount,w.limitMaxAutoWidth=t.limitMaxAutoWidth??450,this.dataSet=new _M,this.scenegraph.clearCells(),this.stateManeger.initState(),t.legends&&(w.legends=new LP(t.legends,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),t.title&&(w.title=new IP(t.title,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),w.tooltip=Object.assign({renderMode:"html",isShowOverflowTextTooltip:!1,confine:!0},t.tooltip),"html"!==w.tooltip.renderMode||w.tooltipHandler||(w.tooltipHandler=new wP(this,w.tooltip.confine)),w.menu=Object.assign({renderMode:"html"},t.menu),"html"!==w.menu.renderMode||w.menuHandler||(w.menuHandler=new RP(this)),this.headerStyleCache=new Map,this.bodyStyleCache=new Map}getFrozenRowsHeight(){return this.getRowsHeight(0,this.frozenRowCount-1)}getFrozenColsWidth(){return this.getColsWidth(0,this.frozenColCount-1)}getBottomFrozenRowsHeight(){if(this.bottomFrozenRowCount>0){return this.getRowsHeight(this.rowCount-this.bottomFrozenRowCount,this.rowCount-1)}return 0}getRightFrozenColsWidth(){if(this.rightFrozenColCount>0){return this.getColsWidth(this.colCount-this.rightFrozenColCount,this.colCount-1)}return 0}getDrawRange(){const t=Math.min(this.tableNoFrameWidth,this.getAllColsWidth()),e=Math.min(this.tableNoFrameHeight,this.getAllRowsHeight());return new Re(this.tableX,this.tableY,t,e)}_getMouseAbstractPoint(t,e=!0){const i=this;let n;if(!t)return null;n=DP(t)?t.changedTouches[0]:t;const r=n.clientX||n.pageX+window.scrollX,o=n.clientY||n.pageY+window.scrollY,s=i.internalProps.canvas.getBoundingClientRect();if(s.right<=r)return null;if(s.bottom<=o)return null;const a=s.width,l=a/(this.canvas.offsetWidth||a),h=s.height,c=h/(this.canvas.offsetHeight||h);return{x:(r-s.left)/l+(e?i.scrollLeft:0)-i.tableX,y:(o-s.top)/c+(e?i.scrollTop:0)-i.tableY}}_getCellEventArgsSet(t){const e=this._getMouseAbstractPoint(t);if(!e)return{};const i=this.getCellAt(e.x,e.y);if(i.col<0||i.row<0)return{abstractPos:e,cell:i};return{abstractPos:e,cell:i,eventArgs:{col:i.col,row:i.row,event:t,rect:i.rect}}}getTheme(){return this.internalProps.theme}getTargetColAt(t){if(0===t)return{left:0,col:0,right:0,width:0};const e=(e,i)=>{let n=i-this.getColWidth(e);const{colCount:r}=this.internalProps;for(let i=e;i<r;i++){const e=this.getColWidth(i),r=n+e;if(Math.round(n)<=Math.round(t)&&Math.round(t)<Math.round(r))return{left:n,col:i,right:r,width:e};n=r}return null},i=this.computeTargetColByX(t),n=this.getColsWidth(0,i);return t>=n?e(i,n):((e,i)=>{let n=i;for(let i=e;i>=0;i--){const e=this.getColWidth(i),r=n-e;if(Math.round(r)<=Math.round(t)&&Math.round(t)<Math.round(n))return{left:r,col:i,right:n,width:e};n=r}return null})(i,n)}getTargetRowAt(t){if(0===t)return{top:0,row:0,bottom:0,height:0};const e=(e,i)=>{let n=i-this.getRowHeight(e);const{rowCount:r}=this.internalProps;for(let i=e;i<r;i++){const e=this.getRowHeight(i),r=n+e;if(Math.round(n)<=Math.round(t)&&Math.round(t)<Math.round(r))return{top:n,row:i,bottom:r,height:e};n=r}return null},i=this.computeTargetRowByY(t),n=this.getRowsHeight(0,i);return t>=n?e(i,n):((e,i)=>{let n=i;for(let i=e;i>=0;i--){const e=this.getRowHeight(i),r=n-e;if(Math.round(r)<=Math.round(t)&&Math.round(t)<Math.round(n))return{top:r,row:i,bottom:n,height:e};n=r}return null})(i,n)}computeTargetRowByY(t){if(this._rowRangeHeightsMap.get("$0$"+(this.rowCount-1))){let e=0,i=this.rowCount-1;for(;i-e>1;){const n=Math.floor((e+i)/2);if(t<this._rowRangeHeightsMap.get(`$0$${n}`))i=n;else{if(!(t>this._rowRangeHeightsMap.get(`$0$${n}`)))return n;e=n}}return i}return Math.min(Math.ceil(t/this.internalProps.defaultRowHeight),this.rowCount-1)}computeTargetColByX(t){if(this._colRangeWidthsMap.get("$0$"+(this.colCount-1))){let e=0,i=this.colCount-1;for(;i-e>1;){const n=Math.floor((e+i)/2);if(t<this._colRangeWidthsMap.get(`$0$${n}`))i=n;else{if(!(t>this._colRangeWidthsMap.get(`$0$${n}`)))return n;e=n}}return i}return Math.min(Math.ceil(t/this.internalProps.defaultColWidth),this.colCount-1)}clearSelected(){this.stateManeger.updateSelectPos(-1,-1)}selectCell(t,e){this.stateManeger.updateSelectPos(t,e),this.stateManeger.endSelectCells()}updatePager(t){this.pagerConf&&("number"==typeof t.currentPage&&t.currentPage>=0&&(this.pagerConf.currentPage=t.currentPage),t.perPageCount&&(this.pagerConf.perPageCount=t.perPageCount||this.pagerConf.perPageCount),this.scenegraph.clearCells(),this.dataSource.updatePager(this.pagerConf),this.refreshRowColCount(),this.scenegraph.createSceneGraph(),this.invalidate())}get allowFrozenColCount(){return this.internalProps.allowFrozenColCount}get rowHeaderLevelCount(){return this.internalProps.layoutMap.rowHeaderLevelCount}get columnHeaderLevelCount(){return this.internalProps.layoutMap.columnHeaderLevelCount}get records(){return this.internalProps.records||null}get dataSource(){return this.internalProps.dataSource}set dataSource(t){this.scenegraph.clearCells(),AC(this,t),this.refreshRowColCount(),this.scenegraph.createSceneGraph(),this.invalidate()}get autoWrapText(){return this.internalProps.autoWrapText}set autoWrapText(t){this.internalProps.autoWrapText!==t&&(this.internalProps.autoWrapText=t,this.options.autoWrapText=t,this.internalProps.layoutMap&&(this.refreshHeader(),this.invalidate()))}get theme(){return this.internalProps.theme}set theme(t){const e=Qe.of(t);this.internalProps.theme=e||Qe.DEFAULT,this.options.theme=t,this.resize()}getBodyField(t,e){return this.internalProps.layoutMap.getBody(t,e).field}getBodyColumnDefine(t,e){const i=this.internalProps.layoutMap.getBody(t,e);return i?.define}getBodyColumnType(t,e){return this.internalProps.layoutMap.getBody(t,e).columnType}getHeaderField(t,e){return this.internalProps.layoutMap.getHeaderField(t,e)}getHeaderFieldKey(t,e){return this.internalProps.layoutMap.getHeaderFieldKey(t,e)}getHeaderDefine(t,e){const i=this.internalProps.layoutMap.getHeader(t,e);return i?.define}getCellType(t,e){return this.internalProps.layoutMap.getCellType(t,e)}getCellHeaderPaths(t,e){return this.internalProps.layoutMap.getCellHeaderPaths(t,e)}getHeadersDefine(t,e){const i=[];for(;;){const n=this.getHeaderDefine(t,e);if(!n||!n.field&&!n.columns)break;i.push(n),e++}return i}_getHeaderLayoutMap(t,e){return this.internalProps.layoutMap.getHeader(t,e)}_getBodyLayoutMap(t,e){return this.internalProps.layoutMap.getBody(t,e)}getContext(){return this.internalProps.context}getRecordByRowCol(t,e){if(!this.internalProps.layoutMap.isHeader(t,e))return this.internalProps.dataSource?.get(this.getRecordIndexByRow(t,e))}getRecordStartRowByRecordIndex(t){return this.internalProps.layoutMap.getRecordStartRowByRecordIndex(t)}_getHeaderCellBySortState(t){const{layoutMap:e}=this.internalProps;let i;if(i=t.fieldKey?e.headerObjects.find((e=>e&&e.fieldKey===t.fieldKey)):e.headerObjects.find((e=>e&&e.field===t.field)),i){return e.getHeaderCellAdress(i.id)}}getCellRange(t,e){return this.internalProps.layoutMap.getCellRange(t,e)}isCellRangeEqual(t,e,i,n){return this.internalProps.layoutMap.isCellRangeEqual(t,e,i,n)}_getLayoutCellId(t,e){return this.internalProps.layoutMap.getCellId(t,e)}getHeaderDescription(t,e){const i=this._getHeaderLayoutMap(t,e),n=i?.define,r=n?.description??i?.description;if("function"==typeof r){return r({col:t,row:e,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e)})}return r}setRecords(t,e){const i="undefined"!=typeof window?window.performance.now():0;if(this.scenegraph.clearCells(),void 0!==e&&(this.sortState=e,this.stateManeger.setSortState(this.sortState)),t){if(SC(this,t),this.sortState){let t,e,i;if(Array.isArray(this.sortState)?0!==this.sortState.length&&({order:t,field:e,fieldKey:i}=this.sortState?.[0]):({order:t,field:e,fieldKey:i}=this.sortState),t&&e&&"normal"!==t){const n=this._getSortFuncFromHeaderOption(void 0,e,i);let r;r=i?this.internalProps.layoutMap.headerObjects.find((t=>t&&t.fieldKey===i)):this.internalProps.layoutMap.headerObjects.find((t=>t&&t.field===e)),r?.define?.sort&&this.dataSource.sort(r.field,t,n??M)}}this.refreshRowColCount()}else SC(this,t);this.scenegraph.createSceneGraph(),this.invalidate(),console.log("setRecords cost time:",("undefined"!=typeof window?window.performance.now():0)-i)}setRecord(t,e,i){const n=this.getRecordIndexByRow(e,i);this.dataSource.setRecord(t,n)}setDropDownMenuHighlight(t){this.stateManeger.setDropDownMenuHighlight(t)}_dropDownMenuIsHighlight(t,e,i){return this.stateManeger.dropDownMenuIsHighlight(t,e,i)}isHeader(t,e){return this.internalProps.layoutMap&&this.internalProps.layoutMap.isHeader(t,e)}isColumnHeader(t,e){return this.internalProps.layoutMap?.isColumnHeader(t,e)}isRowHeader(t,e){return this.internalProps.layoutMap?.isRowHeader(t,e)}isCornerHeader(t,e){return this.internalProps.layoutMap?.isCornerHeader(t,e)}isRightFrozenColumn(t,e){return this.internalProps.layoutMap?.isRightFrozenColumn(t,e)}isBottomFrozenRow(t,e){return this.internalProps.layoutMap?.isBottomFrozenRow(t,e)}getCellInfo(t,e){const i=this.isHeader(t,e)?this.getHeaderDefine(t,e):this.getBodyColumnDefine(t,e);return{col:t,row:e,field:this.getHeaderField(t,e),cellHeaderPaths:this.internalProps.layoutMap.getCellHeaderPaths(t,e),caption:i.caption,columnType:i.columnType?"string"==typeof i.columnType?i.columnType:"progressbar":"text",originData:this.getCellOriginRecord(t,e),cellRange:this.getCellRangeRelativeRect({col:t,row:e}),value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellType:this.getCellType(t,e),scaleRatio:this.canvas.getBoundingClientRect().width/this.canvas.offsetWidth}}_hasField(t,e,i){if(null==t)return!1;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return!1;const r=n.getRecordIndexByRow(e,i);return n.internalProps.dataSource.hasField(r,t)}_getCellStyle(t,e){const{layoutMap:i}=this.internalProps;if(i.isHeader(t,e)){let n=this.headerStyleCache.get(`${t}-${e}`);if(n)return n;const r=i.getHeader(t,e);if(!r||r.isEmpty)return WP;const o=this.internalProps.headerHelper.getStyleClass(r.headerType),{style:s}=r;return n=K(s,i.isColumnHeader(t,e)?this.theme.headerStyle:i.isRowHeader(t,e)?this.theme.rowHeaderStyle:this.theme.cornerHeaderStyle,{col:t,row:e,table:this,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellHeaderPaths:this.getCellHeaderPaths(t,e)},o,this.options.autoWrapText),this.headerStyleCache.set(`${t}-${e}`,n),n}let n;n=this.isListTable()&&!this.transpose||this.isPivotTable()&&this.internalProps.layoutMap.indicatorsAsCol?t:e;let r=this.bodyStyleCache.get(n);if(r)return r;const o=i.getBody(t,e),s=this.internalProps.bodyHelper.getStyleClass(o.columnType),a=o?.style;return r=W(a,this.theme.bodyStyle,{col:t,row:e,table:this,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellHeaderPaths:this.getCellHeaderPaths(t,e)},s,this.options.autoWrapText),this.bodyStyleCache.set(n,r),r}clearCellStyleCache(){this.headerStyleCache.clear()}_canResizeColumn(t,e){if(!(t>=0&&e>=0))return!1;if(this.isCellRangeEqual(t,e,t+1,e))return!1;if("none"===this.internalProps.columnResizeMode)return!1;if("header"===this.internalProps.columnResizeMode){if(!this.isHeader(t,e))return!1}else if("body"===this.internalProps.columnResizeMode&&this.isHeader(t,e))return!1;const i=this.colWidthsLimit[t];return!(i&&i.min&&i.max)||i.max!==i.min}_canDragHeaderPosition(t,e){if(this.isHeader(t,e)&&this.stateManeger.isSelected(t,e)){const i=this.stateManeger.select.ranges[0];if(this.isColumnHeader(t,e)){if(i.end.row!==this.rowCount-1)return!1}else{if(!this.isRowHeader(t,e))return!1;if(i.end.col!==this.colCount-1)return!1}const n=this.getHeaderDefine(t,e);if(void 0===n.dragHeader){if("all"===this.internalProps.dragHeaderMode)return!0;if("column"===this.internalProps.dragHeaderMode){if(this.isColumnHeader(t,e))return!0}else if("row"===this.internalProps.dragHeaderMode&&this.isRowHeader(t,e))return!0;return!1}return n.dragHeader}return!1}getCellIcons(t,e){let i;if(this.isHeader(t,e))i=this.internalProps.headerHelper.getIcons(t,e);else{const n=this.getCellValue(t,e),r=this.getCellOriginValue(t,e),o=this.internalProps.context;i=this.internalProps.bodyHelper.getIcons(t,e,n,r,o)}return i}showDropDownMenu(t,e,i){let n="dropdown-menu";i&&(n=Array.isArray(i.content)?"dropdown-menu":"container"),"html"===this.internalProps.menu.renderMode&&(this.stateManeger.menu.isShow=!0,this.internalProps.menuHandler._bindToCell(t,e,n,i))}showTooltip(t,e,i){"html"===this.internalProps.tooltip.renderMode&&this.internalProps.tooltipHandler._bindToCell(t,e,i)}getCellStyle(t,e){const i=this._getCellStyle(t,e),n=RC(i,this,t,e,OC).theme,{autoWrapText:r,lineClamp:o,textOverflow:s}=i;return{textAlign:n.text.textAlign,textBaseline:n.text.textBaseline,bgColor:Et(n.group.fill)?OC("bgColor",i,t,e,this):n.group.fill,color:Et(n.text.fill)?OC("color",i,t,e,this):n.text.fill,fontFamily:n.text.fontFamily,fontSize:n.text.fontSize,fontWeight:n.text.fontWeight,fontVariant:n.text.fontVariant,fontStyle:n.text.fontStyle,lineHeight:n.text.lineHeight,autoWrapText:r??!1,lineClamp:o??"auto",textOverflow:s,borderColor:Et(n.group.stroke)?OC("borderColor",i,t,e,this):n.group.stroke,borderLineWidth:n.group.lineWidth,borderLineDash:n.group.lineDash,underline:!!n.text.underline,lineThrough:!!n.text.lineThrough,padding:n._vtable.padding,underlineWidth:n.text.underline,lineThroughLineWidth:n.text.lineThrough}}getAllBodyCells(t,e){const i=this.rowHeaderLevelCount,n=this.columnHeaderLevelCount,r=this.colCount-1,o=this.rowCount-1;return Array(Math.min(e??2e3,o-n+1,this.rowCount)).fill(0).map(((e,o)=>Array(Math.min(t??2e3,r-i+1,this.colCount)).fill(0).map(((t,e)=>this.getCellInfo(e+i,o+n)))))}getAllCells(t,e){const i=0,n=0,r=this.colCount-1,o=this.rowCount-1;return Array(Math.min(e??2e3,o-n+1,this.rowCount)).fill(0).map(((e,o)=>Array(Math.min(t??2e3,r-i+1,this.colCount)).fill(0).map(((t,e)=>this.getCellInfo(e+i,o+n)))))}getAllColumnHeaderCells(){const t=this.rowHeaderLevelCount,e=0,i=this.colCount-1,n=this.columnHeaderLevelCount-1;return Array(n-e+1).fill(0).map(((n,r)=>Array(i-t+1).fill(0).map(((i,n)=>this.getCellInfo(n+t,r+e)))))}getAllRowHeaderCells(){const t=0,e=this.columnHeaderLevelCount,i=this.rowHeaderLevelCount-1,n=this.rowCount-1;return Array(n-e+1).fill(0).map(((n,r)=>Array(i-t+1).fill(0).map(((i,n)=>this.getCellInfo(n+t,r+e)))))}scrollToCell(t){const e=this.getDrawRange();if(A(t.col)&&t.col>=this.frozenColCount){const i=this.getFrozenColsWidth(),n=this.getColsWidth(0,t.col-1);this.scrollLeft=Math.min(n-i,this.getAllColsWidth()-e.width)}if(A(t.row)&&t.row>=this.frozenRowCount){const i=this.getFrozenRowsHeight(),n=this.getRowsHeight(0,t.row-1);this.scrollTop=Math.min(n-i,this.getAllRowsHeight()-e.height)}this.invalidate()}getCopyValue(){const t=this.stateManeger.select.ranges;let e=Math.min(t[0].start.col,t[0].end.col),i=Math.max(t[0].start.col,t[0].end.col),n=Math.min(t[0].start.row,t[0].end.row),r=Math.max(t[0].start.row,t[0].end.row);t.forEach((t=>{e=Math.min(e,t.start.col,t.end.col),i=Math.max(i,t.start.col,t.end.col),n=Math.min(n,t.start.row,t.end.row),r=Math.max(r,t.start.row,t.end.row)}));const o=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.row,t.end.row),r=Math.max(t.start.row,t.end.row);n<=e&&r>=e&&(i=!0)})),i},s=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.col,t.end.col),r=Math.max(t.start.col,t.end.col);n<=e&&r>=e&&(i=!0)})),i},a=(e,i)=>{let n;return t.forEach((t=>{const r=Math.min(t.start.row,t.end.row),o=Math.max(t.start.row,t.end.row),s=Math.min(t.start.col,t.end.col),a=Math.max(t.start.col,t.end.col);s<=e&&a>=e&&r<=i&&o>=i&&(n=t)})),n},l=(t,e,i)=>{const n=this.getCellRange(t,e);let r=n.start.col,o=n.start.row;if(i){const t=Math.min(i.start.col,i.end.col),e=Math.min(i.start.row,i.end.row);r=Math.max(t,n.start.col),o=Math.max(e,n.start.row)}if(r!==t||o!==e)return"";return this.getCellValue(t,e)};let h="";for(let t=n;t<=r;t++){if(o(t)){for(let n=e;n<=i;n++){if(s(n)){const e=a(n,t);if(e){const r=l(n,t,e);if("undefined"!=typeof Promise&&r instanceof Promise);else{const t=`${r}`;/^\[object .*\]$/.exec(t)||(h+=t)}(n<e.end.col||n<i)&&(h+="\t")}else h+="\t"}}h+="\n"}}return h}getSelectedCellInfos(){const t=this.stateManeger.select.ranges;let e=Math.min(t[0].start.col,t[0].end.col),i=Math.max(t[0].start.col,t[0].end.col),n=Math.min(t[0].start.row,t[0].end.row),r=Math.max(t[0].start.row,t[0].end.row);t.forEach((t=>{e=Math.min(e,t.start.col,t.end.col),i=Math.max(i,t.start.col,t.end.col),n=Math.min(n,t.start.row,t.end.row),r=Math.max(r,t.start.row,t.end.row)}));const o=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.row,t.end.row),r=Math.max(t.start.row,t.end.row);n<=e&&r>=e&&(i=!0)})),i},s=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.col,t.end.col),r=Math.max(t.start.col,t.end.col);n<=e&&r>=e&&(i=!0)})),i},a=(e,i)=>{let n;return t.forEach((t=>{const r=Math.min(t.start.row,t.end.row),o=Math.max(t.start.row,t.end.row),s=Math.min(t.start.col,t.end.col),a=Math.max(t.start.col,t.end.col);s<=e&&a>=e&&r<=i&&o>=i&&(n=t)})),n},l=[];for(let t=n;t<=r;t++){if(o(t)){const n=[];for(let r=e;r<=i;r++){if(s(r)){if(a(r,t)){const e=this.getCellInfo(r,t);n.push(e)}}}l.push(n)}}return l}measureText(t,e){return yx.measureText(t,e)}measureTextBounds(t){const e=new bx(t);return{width:e.AABBBounds.width(),height:e.AABBBounds.height()}}getCustomRender(t,e){let i;if("body"!==this.getCellType(t,e)){const n=this.getHeaderDefine(t,e);i=n?.headerCustomRender}else{const n=this.getBodyColumnDefine(t,e);i=n?.customRender||this.customRender}return i}getCustomLayout(t,e){let i;if("body"!==this.getCellType(t,e)){const n=this.getHeaderDefine(t,e);i=n?.headerCustomLayout}else{const n=this.getBodyColumnDefine(t,e);i=n?.customLayout}return i}}var jP=Object.freeze({__proto__:null,BaseTable:zP});function NP(t,e,i){const n=t[e];return t[e]=i,n}function GP(t){for(const e in t)delete t[e]}function KP(){GP(Ie),GP(PC),GP(FS)}var UP=Object.freeze({__proto__:null,chartType:function(t,e){return null!=e?NP(FS,t,e):FS[t]},clearAll:KP,icon:function(t,e){return null!=e?NP(PC,t,e):PC[t]},theme:function(t,e){return null!=e?NP(Ie,t,e):Ie[t]}});var VP=Object.freeze({__proto__:null,dateFormat:function(t,e,i,n,r){null==i&&(i=!1),null==n&&(n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),null==r&&(r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]);const o=i?"UTC":"",s=function(t){return`0${t}`.substring(0,2)};return function(i){const a=new Date(Date.parse(i[t]));return e.replace(/%(.)/g,(function(t,e){switch(e){case"y":return a[`get${o}FullYear`]();case"m":return s(a[`get${o}Month`]()+1);case"n":return n[a[`get${o}Month`]()];case"d":return s(a[`get${o}Date`]());case"w":return r[a[`get${o}Day`]()];case"x":return a[`get${o}Day`]();case"H":return s(a[`get${o}Hours`]());case"M":return s(a[`get${o}Minutes`]());case"S":return s(a[`get${o}Seconds`]());default:return`%${e}`}}))}},numberFormat:function(t){return t=Object.assign({},{digitsAfterDecimal:2,scaler:1,thousandsSep:",",decimalSep:".",prefix:"",suffix:""},t),function(e){if(isNaN(e)||!isFinite(e))return"";const i=function(t,e,i){const n=(t+="").split(".");let r=n[0];const o=n.length>1?i+n[1]:"";return r=function(t,e){return t.replace(/\d+/,(function(t){return t.replace(/(\d)(?=(\d{3})+$)/g,(function(t){return`${t}${e}`}))}))}(r,e),r+o}((t.scaler*e).toFixed(t.digitsAfterDecimal),t.thousandsSep,t.decimalSep);return`${t.prefix}${i}${t.suffix}`}}});let $P=0;class XP{_headerObjects;_headerObjectMap;_headerCellIds;_columns;bodyRowCount=1;hierarchyIndent;_transpose=!1;_showHeader=!0;_recordsCount=0;_table;_cellRangeMap;constructor(t,e,i,n){this._cellRangeMap=new Map,this._showHeader=i,this._table=t,this._columns=[],this._headerCellIds=[],this.hierarchyIndent=n??20,this._headerObjects=this._addHeaders(0,e,[]),this._headerObjectMap=this._headerObjects.reduce(((t,e)=>(t[e.id]=e,t)),{})}get transpose(){return this._transpose}set transpose(t){this._transpose=t}get showHeader(){return this._showHeader}set showHeader(t){this._showHeader=t}isHeader(t,e){return!!(this.transpose&&t<this.headerLevelCount)||!this.transpose&&e<this.headerLevelCount}getCellType(t,e){return this.isHeader(t,e)?this.transpose?"rowHeader":"columnHeader":"body"}isColumnHeader(t,e){return!this.transpose&&e<this.headerLevelCount}isRightFrozenColumn(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.columnHeaderLevelCount&&e<this.rowCount-this.bottomFrozenRowCount}isBottomFrozenRow(t,e){return t>=this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount&&t<this.colCount-this.rightFrozenColCount}isCornerHeader(t,e){return!1}isRowHeader(t,e){return!!(this.transpose&&t<this.headerLevelCount)}getColumnHeaderRange(){return this.transpose?{start:{col:0,row:0},end:{col:this._headerCellIds.length-1,row:(this.rowCount??0)-1}}:{start:{col:0,row:0},end:{col:(this.colCount??0)-1,row:this._headerCellIds.length-1}}}getRowHeaderRange(){return this.transpose?{start:{col:0,row:0},end:{col:this._headerCellIds.length-1,row:(this.rowCount??0)-1}}:{start:{col:0,row:0},end:{col:(this.colCount??0)-1,row:this._headerCellIds.length-1}}}getCornerHeaderRange(){}getBodyRange(){return this.transpose?{start:{col:this.headerLevelCount,row:0},end:{col:(this.colCount??0)-1,row:(this.rowCount??0)-1}}:{start:{col:0,row:this.headerLevelCount},end:{col:(this.colCount??0)-1,row:(this.rowCount??0)-1}}}get headerLevelCount(){return this.showHeader?this._headerCellIds.length:0}get columnHeaderLevelCount(){return this.transpose?0:this.headerLevelCount}get rowHeaderLevelCount(){return this.transpose?this.headerLevelCount:0}get bottomFrozenRowCount(){return 0}get rightFrozenColCount(){return 0}get colCount(){return this.transpose?this.headerLevelCount+this.recordsCount:this._columns.length}get rowCount(){return this.transpose?this._columns.length:this.headerLevelCount+this.recordsCount}get recordsCount(){return this._recordsCount}set recordsCount(t){this._recordsCount=t}get headerObjects(){return this._headerObjects}get columnObjects(){return this._columns}get columnWidths(){return this._columns}getColumnWidthDefined(t){if(this.transpose){let t,e,i,n=0;return this.columnObjects.forEach(((r,o)=>{"number"==typeof r.width?n=Math.max(r.width,n):"auto"===r.width&&(i=!0),"number"==typeof r.minWidth&&(e=Math.max(r.minWidth,e)),"number"==typeof r.maxWidth&&(t=Math.max(r.maxWidth,t))})),n=n>0?n:i?"auto":void 0,{width:n,minWidth:e,maxWidth:t}}return this._columns[t]}getCellId(t,e){return this.transpose?this.headerLevelCount<=t?this._columns[e]?.id:this._headerCellIds[t]?.[e]:this.headerLevelCount<=e?this._columns[t]?.id:this._headerCellIds[e]?.[t]}getHeader(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]}getHeaderFieldKey(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.fieldKey||(this.transpose?this._columns[e]?.fieldKey:this._columns[t]?.fieldKey)}getHeaderField(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.field||(this.transpose?this._columns[e]&&this._columns[e].field:this._columns[t]&&this._columns[t].field)}getHeaderCellAdress(t){for(let e=0;e<this._headerCellIds.length;e++){const i=this._headerCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return this.transpose?{col:e,row:n}:{col:n,row:e}}}getHeaderCellAddressByField(t){const e=this.headerObjects.find((e=>e&&e.field===t));return this.getHeaderCellAdress(e.id)}getBody(t,e){return this.transpose?this._columns[e]:this._columns[t]}getBodyLayoutRangeById(t){if(this.transpose){for(let e=0;e<(this.rowCount??0);e++)if(t===this._columns[e].id)return{start:{col:0,row:e},end:{col:0,row:e}}}else for(let e=0;e<(this.colCount??0);e++)if(t===this._columns[e].id)return{start:{col:e,row:0},end:{col:e,row:0}};throw new Error(`can not found body layout @id=${t}`)}getBodyCellValue(t,e){if(this.isHeader(t,e))return null;const{field:i,fieldFormat:n}=this.getBody(t,e);return this._table.getFieldData(n||i,t,e)}getCellRange(t,e){if(-1===t||-1===e)return{start:{col:t,row:e},end:{col:t,row:e}};if(this._cellRangeMap.has(`$${t}$${e}`))return this._cellRangeMap.get(`$${t}$${e}`);let i={start:{col:t,row:e},end:{col:t,row:e}};if(this.transpose)i=this.getCellRangeTranspose(t,e);else if(this.headerLevelCount<=e){if(this.headerLevelCount<=e&&this.columnObjects[t]?.define?.mergeCell){const n=this.getBodyCellValue(t,e);for(let r=e-1;r>=this.headerLevelCount&&n===this.getBodyCellValue(t,r);r--)i.start.row=r;for(let r=e+1;r<this.rowCount&&n===this.getBodyCellValue(t,r);r++)i.end.row=r}}else{const n=this.getCellId(t,e);for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getCellId(r,e);r++)i.end.col=r;for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<this.headerLevelCount&&n===this.getCellId(t,r);r++)i.end.row=r}return this._cellRangeMap.set(`$${t}$${e}`,i),i}getCellRangeTranspose(t,e){const i={start:{col:t,row:e},end:{col:t,row:e}};if(this.headerLevelCount<=t||-1===t&&-1===e){if(this.headerLevelCount<=t&&this.columnObjects[e]?.define?.mergeCell){const n=this.getBodyCellValue(t,e);for(let r=t-1;r>=this.headerLevelCount&&n===this.getBodyCellValue(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getBodyCellValue(r,e);r++)i.end.col=r}return i}const n=this.getCellId(t,e);for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<(this.rowCount??0)&&n===this.getCellId(t,r);r++)i.end.row=r;for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<this.headerLevelCount&&n===this.getCellId(r,e);r++)i.end.col=r;return i}isCellRangeEqual(t,e,i,n){const r=this.getCellRange(t,e),o=this.getCellRange(i,n);return r.start.col===o.start.col&&r.end.col===o.end.col&&r.start.row===o.start.row&&r.end.row===o.end.row}getRecordIndexByRow(t,e){return this.transpose?t<this.headerLevelCount?-1:t-this.headerLevelCount:e<this.headerLevelCount?-1:e-this.headerLevelCount}getRecordStartRowByRecordIndex(t){return this.headerLevelCount+t}_addHeaders(t,e,i,n){const r=[],o=this._newRow(t,n);return e.forEach((e=>{const s=this._columns.length,a=$P++,{captionIcon:l}=e,h={id:a,caption:e.caption,captionIcon:l,headerIcon:e.headerIcon,field:e.field,fieldKey:e?.fieldKey,fieldFormat:e.fieldFormat,style:e.headerStyle,headerType:e.headerType??"text",dropDownMenu:e.dropDownMenu,define:e,columnWidthComputeMode:e.columnWidthComputeMode};r[a]=h;for(let e=t-1;e>=0;e--)this._headerCellIds[e][s]=i[e];if(o[s]=n?this._headerCellIds[t-1][s]:a,e.columns)this._addHeaders(t+1,e.columns,[...i,a],e.hideColumnsSubHeader).forEach((t=>r.push(t)));else{const i=e;this._columns.push({id:$P++,field:i.field,fieldKey:i.fieldKey,fieldFormat:i.fieldFormat,width:i.width,minWidth:i.minWidth,maxWidth:i.maxWidth,icon:i.icon,columnType:i.columnType??"text",chartType:"chartType"in i?i.chartType:null,chartSpec:"chartSpec"in i?i.chartSpec:null,sparklineSpec:"sparklineSpec"in i?i.sparklineSpec:We,style:i.style,define:i,columnWidthComputeMode:i.columnWidthComputeMode,disableColumnResize:i?.disableColumnResize});for(let e=t+1;e<this._headerCellIds.length;e++)this._headerCellIds[e][s]=a}})),r}_newRow(t,e=!1){if(this._headerCellIds[t]){const e=this._headerCellIds[t-1];if(e.length>this._headerCellIds[t].length)for(let i=this._headerCellIds[t].length;i<e.length;i++)this._headerCellIds[t][i]=e[i];return this._headerCellIds[t]}if(e)return[];const i=this._headerCellIds[t]=[];if(!this._columns.length)return i;const n=this._headerCellIds[t-1];for(let t=0;t<n.length;t++)i[t]=n[t];return i}getCellHeaderPaths(t,e){let i=[],n=[];return this.transpose?n=[{field:this._columns[e].field}]:i=[{field:this._columns[t].field}],{colHeaderPaths:i,rowHeaderPaths:n}}getParentCellId(t,e){if(0!==e)return this.isColumnHeader(t,e)?this.getCellId(t,e-1):this.isRowHeader(t,e)?this.getCellId(t-1,e):void 0}canMoveHeaderPosition(t,e){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){return this.getParentCellId(t.col,i.start.row)===this.getParentCellId(e.col,i.start.row)}if(this.isRowHeader(t.col,t.row)){return this.getParentCellId(i.start.col,t.row)===this.getParentCellId(i.start.col,e.row)}return!1}moveHeaderPosition(t,e){if(this.canMoveHeaderPosition(t,e)){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){const n=i.end.col-i.start.col+1;let r;const o=this.getCellRange(e.col,i.start.row);if(r=e.col>=t.col?o.end.col-n+1:o.start.col,r===i.start.col)return null;for(let t=0;t<this._headerCellIds.length;t++){const e=this._headerCellIds[t].splice(i.start.col,n);e.unshift(r,0),Array.prototype.splice.apply(this._headerCellIds[t],e)}const s=this._columns.splice(i.start.col,n);return s.unshift(r,0),Array.prototype.splice.apply(this._columns,s),this._cellRangeMap=new Map,{sourceIndex:i.start.col,targetIndex:r,moveSize:n,moveType:"column"}}if(this.isRowHeader(t.col,t.row)){const n=i.end.row-i.start.row+1;let r;const o=this.getCellRange(i.start.col,e.row);if(r=e.row>=t.row?o.end.row-n+1:o.start.row,r===i.start.row)return null;for(let t=0;t<this._headerCellIds.length;t++){const e=this._headerCellIds[t].splice(i.start.row,n);e.unshift(r,0),Array.prototype.splice.apply(this._headerCellIds[t],e)}const s=this._columns.splice(i.start.row,n);return s.unshift(r,0),Array.prototype.splice.apply(this._columns,s),this._cellRangeMap=new Map,{sourceIndex:i.start.row,targetIndex:r,moveSize:n,moveType:"row"}}}return null}toggleHierarchyState(t){const e=t.add.map((t=>({col:0,row:this._table.frozenRowCount+t}))),i=t.remove.map((t=>({col:0,row:this._table.frozenRowCount+t})));return{addCellPositions:e,removeCellPositions:i}}setChartInstance(t,e,i){(this.transpose?this._columns[e]:this._columns[t]).chartInstance=i}getChartInstance(t,e){return(this.transpose?this._columns[e]:this._columns[t]).chartInstance}getAxisConfigInPivotChart(t,e){}isEmpty(t,e){return!1}getChartAxes(t,e){return[]}}class YP{sizeIncludeParent=!1;rowExpandLevel;hierarchyType;tree={id:0,dimensionKey:"",value:"",children:[],level:-1,startIndex:0,size:0,startInTotal:0,hierarchyState:void 0};totalLevel=0;dimensionKeys=new St;constructor(t,e="grid",i=void 0){this.sizeIncludeParent=null!=i,this.rowExpandLevel=i,this.hierarchyType=e,this.reset(t)}reset(t,e=!1){this.dimensionKeys=new St,this.tree.children=t,this.setTreeNode(this.tree,0,this.tree),this.totalLevel=this.dimensionKeys.count()}setTreeNode(t,e,i){t.startIndex=e,t.startInTotal=(i.startInTotal??0)+t.startIndex,(t.dimensionKey??t.indicatorKey)&&(!this.dimensionKeys.contain(t.indicatorKey?Fe:t.dimensionKey)&&this.dimensionKeys.put(t.level,t.indicatorKey?Fe:t.dimensionKey),t.id||(t.id=++qP));let n=t.dimensionKey&&this.sizeIncludeParent?1:0;return"grid"===this.hierarchyType?t.children?t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)})):n=1:t.hierarchyState===r.expand&&t.children?t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)})):t.hierarchyState===r.collapse&&t.children?t.children.forEach((e=>{e.level=(t.level??0)+1,this.setTreeNode(e,n,t)})):!t.hierarchyState&&t.level+1<this.rowExpandLevel&&t.children?(t.hierarchyState=r.expand,t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)}))):t.children?(t.hierarchyState=r.collapse,t.children.forEach((e=>{e.level=(t.level??0)+1,this.setTreeNode(e,n,t)}))):(t.hierarchyState=r.none,n=1),t.size=n,n}getTreePath(t,e=30){const i=[];return this.searchPath(t,this.tree,i,e),i.shift(),i}searchPath(t,e,i,n){if(!e)return!1;if(t<e.startIndex||t>=e.startIndex+e.size)return!1;if(i.push(e),!e.children||0===e.children.length)return!0;if(e.level>=n)return!0;const r=t-e.startIndex;return e.children.some((t=>this.searchPath(r,t,i,n))),!0}movePosition(t,e,i){let n,r,o;const s=(a,l)=>{if((void 0===r||void 0===o)&&(a.level===t&&(a.startInTotal===e&&(r=l),a.startInTotal<=i&&i<=a.startInTotal+a.size-1&&(o=l)),a.children&&a.level<t)){n=a;for(let t=0;t<a.children.length;t++)(e>=a.children[t].startInTotal&&e<=a.children[t].startInTotal+a.children[t].size||i>=a.children[t].startInTotal&&i<=a.children[t].startInTotal+a.children[t].size)&&s(a.children[t],t)}};s(this.tree,0);const a=n.children.splice(r,1);a.unshift(o,0),Array.prototype.splice.apply(n.children,a)}}let qP=0,ZP=0;class JP{_showHeader=!0;rowDimensionTree;columnDimensionTree;rowTree;columnTree;cornerHeaderObjs;columnHeaderObjs=[];rowHeaderObjs=[];_cornerHeaderCellIds=[];_columnHeaderCellIds=[];_rowHeaderCellIds=[];_columnWidths=[];rowsDefine;columnsDefine;indicatorsDefine;columnPaths=[];_headerObjects=[];_headerObjectMap={};_indicators=[];indicatorTitle;indicatorsAsCol=!0;hideIndicatorName=!1;_showRowHeader=!0;_showColumnHeader=!0;_rowHeaderTitle;_columnHeaderTitle;cornerSetting;_indicatorShowType="column";rowHierarchyType;rowExpandLevel;rowHierarchyIndent;rowDimensionKeys=[];colDimensionKeys=[];indicatorKeys=[];indicatorDimensionKey=Fe;_cellRangeMap;_CellHeaderPathMap;_table;constructor(t){if(this._table=t,this._cellRangeMap=new Map,this._CellHeaderPathMap=new Map,this.rowTree=t.options.rowTree,this.columnTree=t.options.columnTree,this.rowsDefine=t.options.rows??[],this.columnsDefine=t.options.columns??[],this.indicatorsDefine=t.options.indicators??[],this.indicatorTitle=t.options.indicatorTitle,this.hideIndicatorName=t.options.hideIndicatorName??!1,this.showRowHeader=t.options.showRowHeader??!0,this.showColumnHeader=t.options.showColumnHeader??!0,this.rowHeaderTitle=t.options.rowHeaderTitle,this.columnHeaderTitle=t.options.columnHeaderTitle,this.rowHierarchyType=t.options.rowHierarchyType??"grid",this.rowExpandLevel=t.options.rowExpandLevel??1,this.rowHierarchyIndent=t.options.rowHierarchyIndent??20,this.cornerSetting=t.options.corner??{titleOnDimension:"column"},this.indicatorsDefine?.forEach((t=>{"string"==typeof t?this.indicatorKeys.push(t):this.indicatorKeys.push(t.indicatorKey)})),this.columnDimensionTree=new YP(this.columnTree??[]),this.rowDimensionTree=new YP(this.rowTree??[],this.rowHierarchyType,"tree"===this.rowHierarchyType?this.rowExpandLevel:void 0),this.colDimensionKeys=this.columnDimensionTree.dimensionKeys.valueArr(),this.rowDimensionKeys=this.rowDimensionTree.dimensionKeys.valueArr(),this.cornerHeaderObjs="column"===this.cornerSetting.titleOnDimension?this._addCornerHeaders(this.columnHeaderTitle?[""].concat(this.colDimensionKeys):this.colDimensionKeys):"row"===this.cornerSetting.titleOnDimension?this._addCornerHeaders(this.rowHeaderTitle?[""].concat(this.rowDimensionKeys):this.rowDimensionKeys):this._addCornerHeaders(null),this.columnDimensionTree.tree.children&&(this.columnHeaderObjs=this._addHeaders(this._columnHeaderCellIds,0,this.columnDimensionTree.tree.children,[]),this.columnHeaderTitle)){const t=++qP,e=Array(this.colCount-this.rowHeaderLevelCount).fill(t);this._columnHeaderCellIds.unshift(e);const i={id:t,caption:"string"==typeof this.columnHeaderTitle.title?this.columnHeaderTitle.title:this.columnsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),""),field:void 0,headerType:this.columnHeaderTitle.headerType??"text",style:this.columnHeaderTitle.headerStyle,define:{id:t}};this.columnHeaderObjs.push(i),this._headerObjects[t]=i}if(ZP=0,this.rowDimensionTree.tree.children&&(this.rowHeaderObjs="tree"===this.rowHierarchyType?this._addHeadersForTreeMode(this._rowHeaderCellIds,0,this.rowDimensionTree.tree.children,[],this.rowDimensionTree.totalLevel,!0):this._addHeaders(this._rowHeaderCellIds,0,this.rowDimensionTree.tree.children,[])),this.rowHeaderTitle){const t=++qP,e=Array(this.rowCount-this.columnHeaderLevelCount).fill(t);this._rowHeaderCellIds.unshift(e);const i={id:t,caption:"string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),""),field:void 0,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{id:t}};this.rowHeaderObjs.push(i),this._headerObjects[t]=i}ZP=0,this.indicatorsAsCol=!A(this.rowDimensionKeys.find((t=>t===this.indicatorDimensionKey))),this._rowHeaderCellIds=C(this._rowHeaderCellIds),this._headerObjectMap=this._headerObjects.reduce(((t,e)=>(t[e.id]=e,t)),{}),this.indicatorsAsCol&&!this.hideIndicatorName?this._indicatorShowType="column":this.indicatorsAsCol||this.hideIndicatorName?this._indicatorShowType="none":this._indicatorShowType="row",this.setColumnWidths()}_addHeaders(t,e,i,n){const r=[];return t[e]||function(e){const i=t[e]=[];if(0===ZP)return i;const n=t[e-1];for(let t=0;t<n?.length;t++)i[t]=n[t]}(e),i.forEach((i=>{const o=i.id,s=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey)),a=this.indicatorsDefine?.find((t=>"string"!=typeof t&&(i.indicatorKey?t.indicatorKey===i.indicatorKey:t.caption===i.value))),l={id:o,caption:i.value??a.caption,field:i.dimensionKey,style:"function"==typeof(a??s)?.headerStyle?(a??s)?.headerStyle:Object.assign({},(a??s)?.headerStyle),headerType:a?.headerType??s?.headerType??"text",headerIcon:a?.headerIcon??s?.headerIcon,define:Object.assign({},i,a??s),fieldFormat:a?.headerFormat??s?.headerFormat,dropDownMenu:a?.dropDownMenu??s?.dropDownMenu,pivotInfo:{value:i.value,dimensionKey:i.dimensionKey,isPivotCorner:!1},width:s?.width,minWidth:s?.minWidth,maxWidth:s?.maxWidth,showSort:a?.showSort??s?.showSort,description:s?.description};a?(a.customRender&&(i.customRender=a.customRender),A(this._indicators.find((t=>t.indicatorKey===a.indicatorKey)))||this._indicators.push({id:++qP,indicatorKey:a.indicatorKey,field:a.indicatorKey,fieldFormat:a?.format,columnType:a?.columnType??"text",chartType:"chartType"in a?a.chartType:null,chartSpec:"chartSpec"in a?a.chartSpec:null,sparklineSpec:"sparklineSpec"in a?a.sparklineSpec:null,style:a?.style,icon:a?.icon,define:Object.assign({},i,a,{dragHeader:s?.dragHeader}),width:a?.width,minWidth:a?.minWidth,maxWidth:a?.maxWidth,disableColumnResize:a?.disableColumnResize})):i.indicatorKey&&(A(this._indicators.find((t=>t.indicatorKey===i.indicatorKey)))||this._indicators.push({id:++qP,indicatorKey:i.indicatorKey,field:i.indicatorKey,columnType:"text",define:Object.assign({},i)})),r[o]=l,this._headerObjects[o]=l,t[e][ZP]=o;for(let i=e-1;i>=0;i--)t[i][ZP]=n[i];if(i.children)this._addHeaders(t,e+1,i.children??[],[...n,o]).forEach((t=>r.push(t)));else{for(let i=e+1;i<t.length;i++)t[i][ZP]=o;ZP++}})),r}_addHeadersForTreeMode(t,e,i,n,o,s){const a=[];return t[e]||function(e){const i=t[e]=[];if(0===ZP)return i;const n=t[e-1];for(let t=0;t<n?.length;t++)i[t]=n[t]}(e),i.forEach((i=>{const l=i.id,h=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey)),c={id:l,caption:i.value,field:i.dimensionKey,style:i.level+1===o||"function"==typeof h?.headerStyle?h?.headerStyle:Object.assign({},h?.headerStyle,{textAlign:"left"}),headerType:h?.headerType??"text",headerIcon:h?.headerIcon,define:Object.assign(i,{linkJump:h?.linkJump,linkDetect:h?.linkDetect,templateLink:h?.templateLink,keepAspectRatio:h?.keepAspectRatio??!1,imageAutoSizing:h?.imageAutoSizing,headerCustomRender:h?.headerCustomRender,headerCustomLayout:h?.headerCustomLayout,dragHeader:h?.dragHeader}),fieldFormat:h?.headerFormat,dropDownMenu:h?.dropDownMenu,pivotInfo:{value:i.value,dimensionKey:i.dimensionKey,isPivotCorner:!1},hierarchyLevel:i.level,dimensionTotalLevel:o,hierarchyState:i.level+1===o?void 0:i.hierarchyState,width:h?.width,minWidth:h?.minWidth,maxWidth:h?.maxWidth};a[l]=c,this._headerObjects[l]=c,t[e][ZP]=l;for(let i=e-1;i>=0;i--)t[i][ZP]=n[i];if(i.hierarchyState===r.expand&&i.children)s&&ZP++,this._addHeadersForTreeMode(t,e,i.children??[],[...n,l],o,s&&i.hierarchyState===r.expand).forEach((t=>a.push(t)));else{s&&ZP++;for(let i=e+1;i<t.length;i++)t[i][ZP]=l}})),a}_addCornerHeaders(t){const e=[];if(t)t.forEach(((t,i)=>{const n=++qP,r=this.rowsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t))??this.columnsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t)),o={id:n,caption:t===this.indicatorDimensionKey?this.indicatorTitle:r?.dimensionTitle??"",field:"维度名称",style:this.cornerSetting.headerStyle,headerType:this.cornerSetting.headerType??"text",define:{dimensionKey:"维度名称",id:n,value:t},dropDownMenu:r?.cornerDropDownMenu,pivotInfo:{value:r?.dimensionTitle??"",dimensionKey:t,isPivotCorner:!0},description:r?.cornerDescription};if(e[n]=o,this._headerObjects[n]=o,"column"===this.cornerSetting.titleOnDimension){this._cornerHeaderCellIds[i]||(this._cornerHeaderCellIds[i]=[]);for(let t=0;t<this.rowHeaderLevelCount;t++)this._cornerHeaderCellIds[i][t]=n}else if("row"===this.cornerSetting.titleOnDimension)for(let t=0;t<this.columnHeaderLevelCount;t++)this._cornerHeaderCellIds[t]||(this._cornerHeaderCellIds[t]=[]),this._cornerHeaderCellIds[t][i]=n}));else{const t=++qP,i={id:t,caption:"",field:"维度名称",style:this.cornerSetting.headerStyle,headerType:this.cornerSetting.headerType??"text",define:{dimensionKey:"维度名称",id:t,value:""}};e[t]=i,this._headerObjects[t]=i;for(let e=0;e<this.columnHeaderLevelCount;e++)for(let i=0;i<this.rowHeaderLevelCount;i++)this._cornerHeaderCellIds[e]||(this._cornerHeaderCellIds[e]=[]),this._cornerHeaderCellIds[e][i]=t}return e}setColumnWidths(){const t=new Array(this.colCount).fill(void 0);if(this.showHeader&&this.showRowHeader&&(this.rowHeaderTitle&&(t[0]={}),this.rowDimensionKeys.forEach(((e,i)=>{const n=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===e));n&&(t[i+(this.rowHeaderTitle?1:0)]={width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth})}))),this.indicatorsAsCol)for(let e=this.rowHeaderLevelCount;e<this.colCount;e++){const i=this.getBody(e,this.columnHeaderLevelCount);t[e]={width:i?.width,minWidth:i?.minWidth,maxWidth:i?.maxWidth}}else{let e,i,n,r=0;this._indicators.forEach(((t,o)=>{"number"==typeof t.width?r=Math.max(t.width,r):"auto"===t.width&&(n=!0),"number"==typeof t.minWidth&&(i=Math.max(t.minWidth,i)),"number"==typeof t.maxWidth&&(e=Math.max(t.maxWidth,e))})),r=r>0?r:n?"auto":void 0,t.fill({width:r,minWidth:i,maxWidth:e},this.rowHeaderLevelCount,this.colCount)}this._columnWidths=t}get columnWidths(){return this._columnWidths}getColumnWidthDefined(t){return this._columnWidths[t]}get showHeader(){return this._showHeader}set showHeader(t){this._showHeader=t}get showColumnHeader(){return this._showColumnHeader}set showColumnHeader(t){this._showColumnHeader=t}get showRowHeader(){return this._showRowHeader}set showRowHeader(t){this._showRowHeader=t}get columnHeaderTitle(){return this._columnHeaderTitle}set columnHeaderTitle(t){this._columnHeaderTitle=t}get rowHeaderTitle(){return this._rowHeaderTitle}set rowHeaderTitle(t){this._rowHeaderTitle=t}getHeaderFieldKey(t,e){}getCellType(t,e){return this.isCornerHeader(t,e)?"cornerHeader":this.isColumnHeader(t,e)?"columnHeader":this.isRowHeader(t,e)?"rowHeader":"body"}isHeader(t,e){return t<this.rowHeaderLevelCount||(e<this.columnHeaderLevelCount||(t>=this.colCount-this.rightFrozenColCount||e>=this.rowCount-this.bottomFrozenRowCount))}isCornerHeader(t,e){return t<this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isColumnHeader(t,e){return t>=this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isRowHeader(t,e){return t<this.rowHeaderLevelCount&&e>=this.columnHeaderLevelCount}isRightFrozenColumn(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.columnHeaderLevelCount&&e<this.rowCount-this.bottomFrozenRowCount}isBottomFrozenRow(t,e){return t>=this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount&&t<this.colCount-this.rightFrozenColCount}getColumnHeaderRange(){return{start:{col:this.rowHeaderLevelCount,row:0},end:{col:this.colCount-1,row:this.columnHeaderLevelCount-1}}}getRowHeaderRange(){return{start:{col:0,row:this.columnHeaderLevelCount},end:{col:this.rowHeaderLevelCount-1,row:this.rowCount-1}}}getCornerHeaderRange(){return{start:{col:0,row:0},end:{col:this.rowHeaderLevelCount-1,row:this.columnHeaderLevelCount-1}}}getBodyRange(){return{start:{col:this.rowHeaderLevelCount,row:this.columnHeaderLevelCount},end:{col:this.colCount-1,row:this.rowCount-1}}}resetCellIds(){}get headerLevelCount(){return this.columnHeaderLevelCount}get columnHeaderLevelCount(){if(this.showHeader&&this.showColumnHeader){let t=this.indicatorsAsCol&&this.hideIndicatorName&&this.colDimensionKeys[this.colDimensionKeys.length-1]===this.indicatorDimensionKey?this.columnDimensionTree.totalLevel-1:this.columnDimensionTree.totalLevel;return this.columnHeaderTitle&&(t+=1),t}return 0}get rowHeaderLevelCount(){if(this.showHeader&&this.showRowHeader){if("tree"===this.rowHierarchyType)return this.rowHeaderTitle?2:1;let t=this.indicatorsAsCol?this.rowDimensionTree.totalLevel:this.hideIndicatorName&&this.rowDimensionKeys[this.rowDimensionKeys.length-1]===this.indicatorDimensionKey?this.rowDimensionTree.totalLevel-1:this.rowDimensionTree.totalLevel;return this.rowHeaderTitle&&(t+=1),t}return 0}get colCount(){return this.columnDimensionTree.tree.size+this.rowHeaderLevelCount+this.rightFrozenColCount}get rowCount(){return this.rowDimensionTree.tree.size+this.columnHeaderLevelCount+this.bottomFrozenRowCount}get bodyRowCount(){return this.rowDimensionTree.tree.size}get bottomFrozenRowCount(){return this.showHeader&&this.showColumnHeader?this.indicatorsAsCol&&!this.hideIndicatorName?this.indicatorsDefine.find((t=>t?.multiIndicator))?1:0:this.getDimension(this.colDimensionKeys[this.colDimensionKeys.length-1],"column")?.multiDimension?1:0:0}get rightFrozenColCount(){return this.showHeader&&this.showColumnHeader?this.indicatorsAsCol||this.hideIndicatorName?this.getDimension(this.rowDimensionKeys[this.rowDimensionKeys.length-1],"row")?.multiDimension?1:0:this.indicatorsDefine.find((t=>t?.multiIndicator))?1:0:0}get headerObjects(){return this._headerObjects}get columnObjects(){return this._indicators}getCellId(t,e){if(e>=0&&t>=0){if(this.isCornerHeader(t,e))return this._cornerHeaderCellIds[e][t];if(this.isColumnHeader(t,e))return this._columnHeaderCellIds[e][t-this.rowHeaderLevelCount];if(this.isRowHeader(t,e))return this._rowHeaderCellIds[e-this.columnHeaderLevelCount]?.[t];if(this.isRightFrozenColumn(t,e))return this._rowHeaderCellIds[e-this.columnHeaderLevelCount][this.rowHeaderLevelCount-1];if(this.isBottomFrozenRow(t,e))return this._columnHeaderCellIds[this.columnHeaderLevelCount-1]?.[t-this.rowHeaderLevelCount]}}getHeader(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]}getHeaderField(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.field||this.getBody(t,e)?.field}getHeaderCellAdress(t){for(let e=0;e<this._columnHeaderCellIds.length;e++){const i=this._columnHeaderCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return{col:n+this._table.frozenColCount,row:e}}for(let e=0;e<this._rowHeaderCellIds.length;e++){const i=this._rowHeaderCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return{col:n,row:e+this._table.frozenRowCount}}for(let e=0;e<this._cornerHeaderCellIds.length;e++){const i=this._cornerHeaderCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return{col:n,row:e}}}getHeaderCellAddressByField(t){const e=this.headerObjects.find((e=>e&&e.field===t));return this.getHeaderCellAdress(e.id)}getBody(t,e){const i=this.getCellHeaderPaths(t,e);if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicators.find((e=>e.indicatorKey===t))??this._indicators[0]??{id:"",field:void 0,indicatorKey:void 0,columnType:void 0,define:void 0}}const n=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicators.find((t=>t.indicatorKey===n))??this._indicators[0]??{id:"",field:void 0,indicatorKey:void 0,columnType:void 0,define:void 0}}getBodyLayoutRangeById(t){for(let e=0;e<(this.colCount??0);e++)if(t===this.columnObjects[e].id)return{start:{col:e,row:0},end:{col:e,row:0}};throw new Error(`can not found body layout @id=${t}`)}getCellRange(t,e){if(-1===t||-1===e)return{start:{col:t,row:e},end:{col:t,row:e}};if(this._cellRangeMap.has(`${t}-${e}`))return this._cellRangeMap.get(`${t}-${e}`);const i={start:{col:t,row:e},end:{col:t,row:e}};if(this.isHeader(t,e)&&-1!==t&&-1!==e){const n=this.getCellId(t,e);for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getCellId(r,e);r++)i.end.col=r;for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<(this.rowCount??0)&&n===this.getCellId(t,r);r++)i.end.row=r}return this._cellRangeMap.set(`${t}-${e}`,i),i}isCellRangeEqual(t,e,i,n){const r=this.getCellRange(t,e),o=this.getCellRange(i,n);return r.start.col===o.start.col&&r.end.col===o.end.col&&r.start.row===o.start.row&&r.end.row===o.end.row}getRecordIndexByRow(t){return t<this.columnHeaderLevelCount||t>=this.rowCount-this.bottomFrozenRowCount?-1:t-this.columnHeaderLevelCount}getRecordIndexByCol(t){return t<this.rowHeaderLevelCount||t>=this.colCount-this.rightFrozenColCount?-1:t-this.rowHeaderLevelCount}getRecordStartRowByRecordIndex(t){return this.columnHeaderLevelCount+t}getCellHeaderPathsWidthTreeNode(t,e){if(this._CellHeaderPathMap.has(`${t}-${e}`))return this._CellHeaderPathMap.get(`${t}-${e}`);const i=this.getRecordIndexByCol(t),n=this.getRecordIndexByRow(e);let r,o;if(t>=0&&(r=this.columnDimensionTree.getTreePath(i,this.showHeader&&this.showColumnHeader?e-(this.columnHeaderTitle?1:0):this.columnDimensionTree.totalLevel)),e>=0)if("tree"===this.rowHierarchyType)if(t>=this.rowHeaderLevelCount)o=this.rowDimensionTree.getTreePath(n,t+this.rowDimensionTree.totalLevel);else{const i=this.getHeader(t,e);o=this.rowDimensionTree.getTreePath(n,t+i.hierarchyLevel)}else o=this.rowDimensionTree.getTreePath(n,this.showHeader&&this.showRowHeader?t-(this.rowHeaderTitle?1:0):this.rowDimensionTree.totalLevel);const s={colHeaderPaths:r,rowHeaderPaths:o};return this._CellHeaderPathMap.set(`${t}-${e}`,s),s}getCellHeaderPaths(t,e){const i=this.getCellHeaderPathsWidthTreeNode(t,e),n={colHeaderPaths:[],rowHeaderPaths:[]};return i.colHeaderPaths.forEach((t=>{const e={};e.dimensionKey=t.dimensionKey,e.indicatorKey=t.indicatorKey,e.value=t.value??this.getIndicatorInfoByIndicatorKey(t.indicatorKey)?.caption??"",n.colHeaderPaths.push(e)})),i.rowHeaderPaths.forEach((t=>{const e={};e.dimensionKey=t.dimensionKey,e.indicatorKey=t.indicatorKey,e.value=t.value??this.getIndicatorInfoByIndicatorKey(t.indicatorKey)?.caption??"",n.rowHeaderPaths.push(e)})),n}getIndicatorInfoByIndicatorKey(t){const e=this.indicatorsDefine?.find((e=>"string"!=typeof e&&(!!t&&e.indicatorKey===t)));return e}getHeaderDimension(t,e){if(this.isHeader(t,e)){const i=this.getHeader(t,e);return this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))}}isColumnIndicatorHeader(t,e){return"column"===this._indicatorShowType&&e===this.columnHeaderLevelCount-1&&t>=this.rowHeaderLevelCount}isRowIndicatorHeader(t,e){return"row"===this._indicatorShowType&&t===this.rowHeaderLevelCount-1&&e>=this.columnHeaderLevelCount}isIndicatorHeader(t,e){return this.isColumnIndicatorHeader(t,e)||this.isRowIndicatorHeader(t,e)}toggleHierarchyState(t,e){const i=this._rowHeaderCellIds.slice(0),n=i.map((t=>this.getHeaderCellAdress(t[0]))),o=this.getHeader(t,e);if(o.define.hierarchyState=o.define.hierarchyState===r.collapse?r.expand:r.collapse,this.rowDimensionTree.reset(this.rowDimensionTree.tree.children,!0),this._rowHeaderCellIds=[],this.rowHeaderObjs=this._addHeadersForTreeMode(this._rowHeaderCellIds,0,this.rowDimensionTree.tree.children,[],this.rowDimensionTree.totalLevel,!0),this.rowHeaderTitle){const t=++qP,e=Array(this.rowCount-this.columnHeaderLevelCount).fill(t);this._rowHeaderCellIds.unshift(e);const i={id:t,caption:"string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),""),field:void 0,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{field:"",headerType:"text",columnType:"text"}};this.rowHeaderObjs.push(i),this._headerObjects[t]=i}return ZP=0,this._rowHeaderCellIds=C(this._rowHeaderCellIds),this._headerObjectMap=this._headerObjects.reduce(((t,e)=>(t[e.id]=e,t)),{}),this._CellHeaderPathMap=new Map,function(t,e,i,n){const r=t.map((t=>t[0])),o=e.map((t=>t[0])),s=[],a=[];for(let t=0;t<r.length;t++)o.includes(r[t])||a.push(i[t]);for(let t=0;t<o.length;t++)r.includes(o[t])||s.push(n.getHeaderCellAdress(o[t]));return{addCellPositions:s,removeCellPositions:a}}(i,this._rowHeaderCellIds,n,this)}isHeaderForColWidth(t,e){return this.isHeader(t,e)}getHeaderForColWidth(t,e){return this.getHeader(t,e)}getPivotCellAdress(t){if(!Array.isArray(t))return;let e,i,n=this.rowTree,r=this.columnTree;for(let o=0;o<t.length;o++){const s=t[o];if((s.isPivotCorner||!s.value)&&o===t.length-1){if("row"===this?.cornerSetting?.titleOnDimension){let t=0;return"grid"===this.rowHierarchyType&&(t=this.rowDimensionKeys.indexOf(s.dimensionKey)),-1===t?void 0:{col:this.rowHeaderTitle?t+1:t,row:0}}const t=this.colDimensionKeys.indexOf(s.dimensionKey);return-1===t?void 0:{col:0,row:this.columnHeaderTitle?t+1:t}}let a=!1;for(let t=0;t<r.length;t++){const e=r[t];if((A(s.dimensionKey)&&e.dimensionKey===s.dimensionKey||A(s.indicatorKey)&&e.indicatorKey===s.indicatorKey)&&e.value===s.value){r=e.children,i=e,a=!0;break}}if(!a)for(let t=0;t<n.length;t++){const i=n[t];if((A(s.dimensionKey)&&i.dimensionKey===s.dimensionKey||A(s.indicatorKey)&&i.indicatorKey===s.indicatorKey)&&i.value===s.value){n=i.children,e=i;break}}}let o=0,s=0;if(e){s=this.columnHeaderLevelCount;const{startInTotal:t,level:i}=e;return s+=t,o="grid"===this.rowHierarchyType?this.rowHeaderTitle?i+1:i:0,{col:o,row:s}}if(i){o=this.rowHeaderLevelCount;const{startInTotal:t,level:e}=i;return o+=t,s=this.columnHeaderTitle?e+1:e,{col:o,row:s}}}getPivotDimensionInfo(t,e){const{colHeaderPaths:i,rowHeaderPaths:n}=this.getCellHeaderPaths(t,e),r=[];return i.length?i.forEach(((t,e)=>{r.push({dimensionKey:t.dimensionKey,value:t.value,isPivotCorner:!1,indicatorKey:t.indicatorKey})})):n.length?n.forEach(((t,e)=>{r.push({dimensionKey:t.dimensionKey,value:t.value,isPivotCorner:!1,indicatorKey:t.indicatorKey})})):this.isCornerHeader(t,e)&&("row"===this?.cornerSetting?.titleOnDimension?r.push({dimensionKey:this.rowDimensionKeys[this.rowHeaderTitle?t-1:t],isPivotCorner:!0}):r.push({dimensionKey:this.colDimensionKeys[this.columnHeaderTitle?e-1:e],isPivotCorner:!0})),r}getIndicatorKey(t,e){return this.getBody(t,e)?.indicatorKey}getParentCellId(t,e){if(0!==e)return this.isColumnHeader(t,e)?this.getCellId(t,e-1):this.isRowHeader(t,e)?this.getCellId(t-1,e):void 0}canMoveHeaderPosition(t,e){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){return this.getParentCellId(t.col,i.start.row)===this.getParentCellId(e.col,i.start.row)}if(this.isRowHeader(t.col,t.row)){if("tree"!==this.rowHierarchyType){return this.getParentCellId(i.start.col,t.row)===this.getParentCellId(i.start.col,e.row)}{const i=v(this.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths),n=v(this.getCellHeaderPathsWidthTreeNode(e.col,e.row).rowHeaderPaths);if(i.pop(),n.pop(),i.length<=n.length)return i.length!==n.length||!i.find(((t,e)=>t.dimensionKey!==n[e].dimensionKey||t.value!==n[e].value))}}return!1}moveHeaderPosition(t,e){if(this.canMoveHeaderPosition(t,e)&&!this.isCellRangeEqual(t.col,t.row,e.col,e.row)){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){const n=i.end.col-i.start.col+1;let r;const o=this.getCellRange(e.col,i.start.row);if(r=e.col>=t.col?o.end.col-n+1:o.start.col,r===i.end.col)return null;for(let t=0;t<this._columnHeaderCellIds.length;t++){const e=this._columnHeaderCellIds[t].splice(i.start.col-this.rowHeaderLevelCount,n);e.unshift(r-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this._columnHeaderCellIds[t],e)}const s=this._columnWidths.splice(i.start.col,n);return s.unshift(r,0),Array.prototype.splice.apply(this._columnWidths,s),this.columnDimensionTree.movePosition(t.row,i.start.col-this.rowHeaderLevelCount,r-this.rowHeaderLevelCount),this.columnDimensionTree.reset(this.columnDimensionTree.tree.children,!0),this._CellHeaderPathMap=new Map,this._cellRangeMap=new Map,{sourceIndex:i.start.col,targetIndex:r,moveSize:n,moveType:"column"}}if(this.isRowHeader(t.col,t.row)){let n;const r=this.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths,o=this.getCellHeaderPathsWidthTreeNode(e.col,e.row).rowHeaderPaths,s=r[r.length-1],a=o[r.length-1],l=s.size;if(n=e.row>=t.row?a.startInTotal+a.size-l:a.startInTotal,n===t.row||n===i.end.row)return null;const h=this._rowHeaderCellIds.splice(i.start.row-this.columnHeaderLevelCount,l);return h.unshift(n,0),Array.prototype.splice.apply(this._rowHeaderCellIds,h),this.rowDimensionTree.movePosition(this.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths.length-1,i.start.row-this.columnHeaderLevelCount,n+(e.row>t.row?s.size-1:0)),this.rowDimensionTree.reset(this.rowDimensionTree.tree.children,!0),this._CellHeaderPathMap=new Map,this._cellRangeMap=new Map,{sourceIndex:i.start.row,targetIndex:n+this.columnHeaderLevelCount,moveSize:l,moveType:"row"}}}return null}getCellAdressByHeaderPath(t){let e,i;if(Array.isArray(t)){if(t.length>this.rowDimensionKeys.length+this.colDimensionKeys.length)return;e=t.filter((t=>this.colDimensionKeys.indexOf(t.dimensionKey)>=0)),i=t.filter((t=>this.rowDimensionKeys.indexOf(t.dimensionKey)>=0))}else e=t.colHeaderPaths,i=t.rowHeaderPaths;if(!Array.isArray(e)&&!Array.isArray(i))return;e?.sort(((t,e)=>this.colDimensionKeys.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.colDimensionKeys.indexOf(e.dimensionKey??this.indicatorDimensionKey))),i?.sort(((t,e)=>this.rowDimensionKeys.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.rowDimensionKeys.indexOf(e.dimensionKey??this.indicatorDimensionKey)));let n,r,o,s,a=!1;e?.length>=1&&i?.length>=1&&(a=!0);let l,h,c=this.rowTree,d=this.columnTree;if(e)for(let t=0;t<e.length;t++){const i=e[t];for(let t=0;t<d.length;t++){const e=d[t];if(!A(i.indicatorKey)&&e.dimensionKey===i.dimensionKey&&e.value===i.value||A(i.indicatorKey)&&e.indicatorKey===i.indicatorKey){d=e.children,a&&!d?h=e:a||(h=e);break}}}if(i)for(let t=0;t<i.length;t++){const e=i[t];for(let t=0;t<c.length;t++){const i=c[t];if((!A(e.indicatorKey)&&i.dimensionKey===e.dimensionKey&&i.value===e.value||A(e.indicatorKey)&&i.indicatorKey===e.indicatorKey)&&i.value===e.value){c=i.children,a&&!c?l=i:a||(l=i);break}}}if(!a||l&&h){if(l){r=this.columnHeaderLevelCount;const{startInTotal:t,level:e}=l;r+=t,o="grid"===this.rowHierarchyType?this.rowHeaderTitle?e+1:e:0}if(h){n=this.rowHeaderLevelCount;const{startInTotal:t,level:e}=h;n+=t,s=this.columnHeaderTitle?e+1:e}return A(n)||A(r)?{col:n??o,row:r??s}:void 0}}setChartInstance(t,e,i){const n=this.getCellHeaderPaths(t,e);let r;if(this.indicatorsAsCol){const t=n.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicators.find((e=>e.indicatorKey===t))}else{const t=n.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicators.find((e=>e.indicatorKey===t))}r&&(r.chartInstance=i)}getChartInstance(t,e){const i=this.getCellHeaderPaths(t,e);let n;if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicators.find((e=>e.indicatorKey===t))}else{const t=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicators.find((e=>e.indicatorKey===t))}return n?.chartInstance}getDimension(t,e){return"column"===e?this.columnsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t)):"row"===e?this.rowsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t)):void 0}getAxisConfigInPivotChart(t,e){}isEmpty(t,e){return!1}getChartAxes(t,e){return[]}}const QP={isEmpty:!0,id:void 0,field:void 0,headerType:void 0,define:void 0};class tE{_headerObjects=[];_headerObjectMap={};_indicatorObjects=[];_columnWidths=[];rowTree;columnTree;rowsDefine;columnsDefine;indicatorsDefine;indicatorKeys;_showRowHeader=!0;_showColumnHeader=!0;_rowHeaderTitle;_columnHeaderTitle;_indicatorShowType="column";indicatorsAsCol=!0;hideIndicatorName=!1;indicatorDimensionKey=Fe;indicatorTitle;rowKeysPath;colKeysPath;convertColKeys;rows;columns;rowShowAttrs;colShowAttrs;tree;dataset;dataConfig;_rowCount;_colCount;_bodyRowCount;cornerSetting;_table;hasTwoIndicatorAxes;constructor(t,e){this._table=t,this.rowTree=t.options.rowTree,this.columnTree=t.options.columnTree,this.rowsDefine=t.options.rows??[],this.columnsDefine=t.options.columns??[],this.indicatorsDefine=t.options.indicators??[],this.indicatorTitle=t.options.indicatorTitle,this.dataset=e,this.dataConfig=e.dataConfig,this.indicatorKeys=e.indicatorKeys,this.indicatorsAsCol=t.options.indicatorsAsCol??!0,this.hideIndicatorName=t.options.hideIndicatorName??!1,this.showRowHeader=t.options.showRowHeader??!0,this.showColumnHeader=t.options.showColumnHeader??!0,this.rowHeaderTitle=t.options.rowHeaderTitle,this.columnHeaderTitle=t.options.columnHeaderTitle,this.cornerSetting=t.options.corner??{titleOnDimension:"column"},this.columns=e.columns,this.rows=e.rows,this.rowKeysPath=e.rowKeysPath,this.colKeysPath=e.colKeysPath,this.tree=e.tree,this.initState(),this.convertColKeys=C(this.colKeysPath)}initState(){if(this.indicatorsAsCol&&!this.hideIndicatorName?this._indicatorShowType="column":this.indicatorsAsCol||this.hideIndicatorName?this._indicatorShowType="none":this._indicatorShowType="row",this.colShowAttrs="column"===this._indicatorShowType?this.columns.concat(this.indicatorDimensionKey):Array.from(this.columns),this.rowShowAttrs="row"===this._indicatorShowType?this.rows.concat(this.indicatorDimensionKey):Array.from(this.rows),this._bodyRowCount=this.rowKeysPath.length*(this.indicatorsAsCol?1:this.indicatorKeys.length),this.initHeaderObjects(),this.initIndicatorObjects(),this.rowHeaderTitle){const t="rowHeaderTitle",e="string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),"");this._headerObjectMap[e]={id:e,caption:e,field:t,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{}},this._headerObjectMap[t]={id:t,caption:"",field:t,headerType:this.cornerSetting.headerType??"text",style:this.cornerSetting.headerStyle,define:{}},this._headerObjects.push(this._headerObjectMap[e]),this._headerObjects.push(this._headerObjectMap[t]),this.rowShowAttrs.unshift(t),this.rowKeysPath.forEach(((t,i)=>{t.unshift(e)}))}if(this.columnHeaderTitle){const t="columnHeaderTitleCell",e="string"==typeof this.columnHeaderTitle.title?this.columnHeaderTitle.title:this.columnsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),"");this._headerObjectMap[e]={id:e,caption:e,field:t,headerType:this.columnHeaderTitle.headerType??"text",style:this.columnHeaderTitle.headerStyle,define:{}},this._headerObjectMap[t]={id:t,caption:"",field:t,headerType:this.cornerSetting.headerType??"text",style:this.cornerSetting.headerStyle,define:{}},this._headerObjects.push(this._headerObjectMap[e]),this._headerObjects.push(this._headerObjectMap[t]),this.colShowAttrs.unshift(t),this.colKeysPath.forEach(((t,i)=>{t.unshift(e)}))}if(this._table.isPivotChart())if(this.hasTwoIndicatorAxes=this._indicatorObjects.some((t=>!!(t.chartSpec&&t.chartSpec.series&&t.chartSpec.series.length>1))),this.indicatorsAsCol){const t="rowHeaderEmpty";this._headerObjectMap[t]={id:t,caption:"",field:t,headerType:this.cornerSetting.headerType??"text",style:this.cornerSetting.headerStyle,define:{}},this._headerObjects.push(this._headerObjectMap[t]),this.rowShowAttrs.push(t),this.hasTwoIndicatorAxes||this.colShowAttrs.pop()}else{const t=this._table.pivotChartAxes.find((t=>"left"===t.orient));!1===t?.visible&&this.rowShowAttrs.pop()}this._colCount=(0===this.colKeysPath.length?1:this.colKeysPath.length)*(this.indicatorsAsCol?this.indicatorKeys.length:1)+this.rowHeaderLevelCount+this.rightFrozenColCount,this._rowCount=(0===this.rowKeysPath.length?1:this.rowKeysPath.length)*(this.indicatorsAsCol?1:this.indicatorKeys.length)+this.columnHeaderLevelCount+this.bottomFrozenRowCount,this.setColumnWidths()}setColumnWidths(){const t=new Array(this.colCount).fill(void 0);if(this.showRowHeader&&(this.rowHeaderTitle&&(t[0]={}),this.rowShowAttrs.forEach(((e,i)=>{const n=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===e));n&&(t[i+(this.rowHeaderTitle?1:0)]={width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth})}))),this.indicatorsAsCol)for(let e=this.rowHeaderLevelCount;e<this.colCount;e++){const i=this.getBody(e,this.columnHeaderLevelCount);t[e]={width:i?.width,minWidth:i?.minWidth,maxWidth:i?.maxWidth}}else{let e,i,n,r=0;this._indicatorObjects.forEach(((t,o)=>{"number"==typeof t.width?r=Math.max(t.width,r):"auto"===t.width&&(n=!0),"number"==typeof t.minWidth&&(i=Math.max(t.minWidth,i)),"number"==typeof t.maxWidth&&(e=Math.max(t.maxWidth,e))})),r=r>0?r:n?"auto":void 0,t.fill({width:r,minWidth:i,maxWidth:e},this.rowHeaderLevelCount,this.colCount)}this._columnWidths=t}get columnWidths(){return this._columnWidths}getColumnWidthDefined(t){return this._columnWidths[t]}getDimensionInfo(t){return this.rowsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t))??this.columnsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t))}getIndicatorInfo(t,e=""){const i=this.indicatorsDefine?.find((i=>"string"!=typeof i&&(t?i.indicatorKey===t:!!e&&i.caption===e)));return i}getColKeysPath(){return this.colKeysPath}getRowKeysPath(){return this.rowKeysPath}initHeaderObjects(){for(let t=0,e=this.rowKeysPath.length;t<=e-1;t++){const e=this.rowKeysPath[t];for(let t=0,i=e.length;t<=i-1;t++)if(!this._headerObjectMap[e[t]]){const i=e[t].split(this.dataset.stringJoinChar),n=this.getDimensionInfo(this.rows[i.length-1]);this._headerObjectMap[e[t]]={id:e[t],field:n?.dimensionKey??this.rows[i.length-1],caption:i[i.length-1],style:n?.headerStyle,define:{field:n?.dimensionKey??this.rows[i.length-1],headerType:n?.headerType??"text",columnType:"text"},fieldFormat:n?.headerFormat,dropDownMenu:n?.dropDownMenu,headerType:n?.headerType??"text",width:n?.width},this._headerObjects.push(this._headerObjectMap[e[t]])}}for(let t=0,e=this.colKeysPath.length;t<=e-1;t++){const e=this.colKeysPath[t];for(let t=0,i=e.length;t<=i-1;t++)if(!this._headerObjectMap[e[t]]){const i=e[t].split(this.dataset.stringJoinChar),n=this.getDimensionInfo(this.columns[i.length-1]);this._headerObjectMap[e[t]]={id:e[t],field:n?.dimensionKey??this.columns[i.length-1],caption:i[i.length-1],style:n?.headerStyle,define:{field:n?.dimensionKey??this.columns[i.length-1],headerType:n?.headerType??"text",columnType:"text"},fieldFormat:n?.headerFormat,dropDownMenu:n?.dropDownMenu,headerType:n?.headerType??"text",width:n?.width},this._headerObjects.push(this._headerObjectMap[e[t]])}}let t;this.indicatorsDefine.forEach((t=>{const e="string"==typeof t?t:t.indicatorKey,i="string"==typeof t?void 0:t;this._headerObjectMap[e]||(this._headerObjectMap[e]={id:e,field:this.indicatorDimensionKey,caption:i.caption??e,style:i?.headerStyle,define:{field:this.indicatorDimensionKey,headerType:i?.headerType??"text",columnType:"text"},dropDownMenu:i?.dropDownMenu,headerType:i?.headerType??"text",width:i?.width},this._headerObjects.push(this._headerObjectMap[e]))})),"column"===this.cornerSetting.titleOnDimension?t=this.colShowAttrs:"row"===this.cornerSetting.titleOnDimension&&(t=this.rowShowAttrs),t.forEach((t=>{if(!this._headerObjectMap[t]){const e=this.getDimensionInfo(t);this._headerObjectMap[t]={id:t,field:t,caption:t===this.indicatorDimensionKey?this.indicatorTitle:e?.dimensionTitle??t,style:this.cornerSetting?.headerStyle,define:{field:t,headerType:this.cornerSetting?.headerType??"text",columnType:"text"},dropDownMenu:e?.dropDownMenu,headerType:this.cornerSetting?.headerType??"text",width:e?.width},this._headerObjects.push(this._headerObjectMap[t])}}))}initIndicatorObjects(){this.indicatorKeys.forEach((t=>{const e=this.indicatorsDefine?.find((e=>"string"!=typeof e&&e.indicatorKey===t));this._indicatorObjects.push({id:t,indicatorKey:t,field:t,define:Object.assign({field:t,headerType:"text",columnType:e?.columnType??"text"},e),fieldFormat:e?.format,columnType:e?.columnType??"text",chartType:e&&("chartType"in e?e.chartType:null),chartSpec:e&&("chartSpec"in e?e.chartSpec:null),sparklineSpec:"sparklineSpec"in e?e.sparklineSpec:null,style:e?.style,icon:e?.icon,width:e?.width,minWidth:e?.minWidth,maxWidth:e?.maxWidth,disableColumnResize:e?.disableColumnResize})}))}get showColumnHeader(){return this._showColumnHeader}set showColumnHeader(t){this._showColumnHeader=t}get showRowHeader(){return this._showRowHeader}set showRowHeader(t){this._showRowHeader=t}get columnHeaderTitle(){return this._columnHeaderTitle}set columnHeaderTitle(t){this._columnHeaderTitle=t}get rowHeaderTitle(){return this._rowHeaderTitle}set rowHeaderTitle(t){this._rowHeaderTitle=t}getCellType(t,e){return this.isCornerHeader(t,e)?"cornerHeader":this.isColumnHeader(t,e)?"columnHeader":this.isRowHeader(t,e)?"rowHeader":"body"}isHeader(t,e){return t<this.rowHeaderLevelCount||(e<this.columnHeaderLevelCount||(t>=this.colCount-this.rightFrozenColCount||e>=this.rowCount-this.bottomFrozenRowCount))}isCornerHeader(t,e){return t<this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isColumnHeader(t,e){return t>=this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isRightFrozenColumn(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.columnHeaderLevelCount&&e<this.rowCount-this.bottomFrozenRowCount}isBottomFrozenRow(t,e){return t>=this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount&&t<this.colCount-this.rightFrozenColCount}isRowHeader(t,e){return t<this.rowHeaderLevelCount&&e>=this.columnHeaderLevelCount}isColumnIndicatorHeader(t,e){return"column"===this._indicatorShowType&&e===this.columnHeaderLevelCount-1&&t>=this.rowHeaderLevelCount}isRowIndicatorHeader(t,e){return"row"===this._indicatorShowType&&t===this.rowHeaderLevelCount-1&&e>=this.columnHeaderLevelCount}isIndicatorHeader(t,e){return this.isColumnIndicatorHeader(t,e)||this.isRowIndicatorHeader(t,e)}getColumnHeaderRange(){return{start:{col:this.rowHeaderLevelCount,row:0},end:{col:this.colCount-1,row:this.columnHeaderLevelCount-1}}}getRowHeaderRange(){return{start:{col:0,row:this.columnHeaderLevelCount},end:{col:this.rowHeaderLevelCount-1,row:this.rowCount-1}}}getCornerHeaderRange(){return{start:{col:0,row:0},end:{col:this.rowHeaderLevelCount-1,row:this.columnHeaderLevelCount-1}}}getBodyRange(){return{start:{col:this.rowHeaderLevelCount,row:this.columnHeaderLevelCount},end:{col:this.colCount-1,row:this.rowCount-1}}}resetCellIds(){}get headerLevelCount(){return this.columnHeaderLevelCount}get columnHeaderLevelCount(){const t=this.colShowAttrs.length;if(this.showColumnHeader){return this.indicatorsAsCol&&this.hideIndicatorName&&this.colShowAttrs[this.colShowAttrs.length-1]===this.indicatorDimensionKey?t-1:t}return 0}get rowHeaderLevelCount(){const t=this.rowShowAttrs.length;if(this.showRowHeader){return this.indicatorsAsCol?t:this.hideIndicatorName&&this.rowShowAttrs[this.rowShowAttrs.length-1]===this.indicatorDimensionKey?t-1:t}return 0}get colCount(){return this._colCount}get rowCount(){return this._rowCount}get bodyRowCount(){return this._bodyRowCount}get bottomFrozenRowCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"bottom"===t.orient));return!1===t?.visible?0:(this.indicatorsAsCol,1)}get rightFrozenColCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"right"===t.orient));return!1===t?.visible||this.indicatorsAsCol?0:this.hasTwoIndicatorAxes?1:0}get leftAxesCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"left"===t.orient));return!1===t?.visible?0:(this.indicatorsAsCol,1)}get topAxesCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"top"===t.orient));return!1===t?.visible?0:this.indicatorsAsCol&&this.hasTwoIndicatorAxes?1:0}get rightAxesCount(){return this.rightFrozenColCount}get bottomAxesCount(){return this.bottomFrozenRowCount}get headerObjects(){return this._headerObjects}get columnObjects(){return this._indicatorObjects}getCellId(t,e){if(t<this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount||e<this.columnHeaderLevelCount&&t>=this.colCount-this.rightFrozenColCount)return 0;if(e>=0&&t>=0)if(this.isCornerHeader(t,e)){if("column"===this.cornerSetting.titleOnDimension)return this.colShowAttrs[e];if("row"===this.cornerSetting.titleOnDimension)return this.rowShowAttrs[t]}else{if(this.isColumnHeader(t,e))return e<this.columns.length+(this.columnHeaderTitle?1:0)?this.convertColKeys[e][this.indicatorsAsCol?Math.floor((t-this.rowHeaderLevelCount)/this.indicatorKeys.length):t-this.rowHeaderLevelCount]:this.indicatorKeys[(t-this.rowHeaderLevelCount)%this.indicatorKeys.length];if(this.isRowHeader(t,e))return t<this.rows.length+(this.rowHeaderTitle?1:0)?this.rowKeysPath[this.indicatorsAsCol?e-this.columnHeaderLevelCount:Math.floor((e-this.columnHeaderLevelCount)/this.indicatorKeys.length)][t]:this.indicatorKeys[(e-this.columnHeaderLevelCount)%this.indicatorKeys.length];if(this.isRightFrozenColumn(t,e))return this.indicatorsAsCol?this.rowKeysPath[e-this.columnHeaderLevelCount][this.rowHeaderLevelCount-1]:this.indicatorKeys[(e-this.columnHeaderLevelCount)%this.indicatorKeys.length];if(this.isBottomFrozenRow(t,e))return this.indicatorsAsCol?this.indicatorKeys[(t-this.rowHeaderLevelCount)%this.indicatorKeys.length]:this.convertColKeys[this.columnHeaderLevelCount-1][Math.floor((t-this.rowHeaderLevelCount)/this.indicatorKeys.length)]}return 0}getIndicatorKey(t,e){if(this.isHeader(t,e))return"";if(this.indicatorsAsCol){const e=t-this.rowHeaderLevelCount;return this.indicatorKeys[e%this.indicatorKeys.length]}const i=e-this.columnHeaderLevelCount;return this.indicatorKeys[i%this.indicatorKeys.length]}getHeader(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]??QP}getHeaderField(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.field||this.getBody(t,e)?.field}getHeaderFieldKey(t,e){}getHeaderCellAdress(t){}getHeaderCellAddressByField(t){throw new Error(`Method not implemented.${t}`)}getBody(t,e){const i=this.getCellHeaderPaths(t,e);if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicatorObjects.find((e=>e.indicatorKey===t))??this._indicatorObjects[0]??{id:"",field:void 0,indicatorKey:void 0,columnType:void 0,define:void 0}}const n=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicatorObjects.find((t=>t.indicatorKey===n))??this._indicatorObjects[0]??{id:"",field:void 0,indicatorKey:void 0,columnType:void 0,define:void 0}}getBodyLayoutRangeById(t){for(let e=0;e<(this.colCount??0);e++)if(t===this.columnObjects[e].id)return{start:{col:e,row:0},end:{col:e,row:0}};throw new Error(`can not found body layout @id=${t}`)}getCellRange(t,e){const i={start:{col:t,row:e},end:{col:t,row:e}};if(!this.isHeader(t,e)||-1===t||-1===e||this.isIndicatorHeader(t,e))return i;const n=this.getCellId(t,e);for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getCellId(r,e);r++)i.end.col=r;for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<(this.rowCount??0)&&n===this.getCellId(t,r);r++)i.end.row=r;return i}isCellRangeEqual(t,e,i,n){const r=this.getCellRange(t,e),o=this.getCellRange(i,n);return r.start.col===o.start.col&&r.end.col===o.end.col&&r.start.row===o.start.row&&r.end.row===o.end.row}getRecordIndexByRow(t){return t<this.columnHeaderLevelCount?-1:this.indicatorsAsCol?t-this.columnHeaderLevelCount:Math.floor((t-this.columnHeaderLevelCount)/this.indicatorKeys.length)}getRecordIndexByCol(t){return t<this.rowHeaderLevelCount?-1:this.indicatorsAsCol?Math.floor((t-this.rowHeaderLevelCount)/this.indicatorKeys.length):t-this.rowHeaderLevelCount}getRecordStartRowByRecordIndex(t){return this.columnHeaderLevelCount+t}getCellHeaderPaths(t,e){const i=this.getRecordIndexByCol(t),n=this.getRecordIndexByRow(e);let r,o,s,a;return i>=0&&(r=this.colKeysPath[i],s=r?.[r.length-1]?.split(this.dataset.stringJoinChar),e<this.columns.length-1&&(s=s.slice(0,e+1))),n>=0&&(o=this.rowKeysPath[n],a=o?.[o.length-1]?.split(this.dataset.stringJoinChar),t<this.rows.length-1&&(a=a.slice(0,t+1))),s&&this.indicatorsAsCol&&t>=this.rowHeaderLevelCount?s.push(this.indicatorKeys[(t-this.rowHeaderLevelCount)%this.indicatorKeys.length]):a&&e>=this.columnHeaderLevelCount&&a.push(this.indicatorKeys[(e-this.columnHeaderLevelCount)%this.indicatorKeys.length]),{colHeaderPaths:s?.map(((t,e)=>{const i=this._indicatorObjects.find((e=>e.indicatorKey===t));return{dimensionKey:i?void 0:this.colShowAttrs[e],indicatorKey:i?t:void 0,value:i?i.define.caption:t}}))??[],rowHeaderPaths:a?.map(((t,e)=>{const i=this._indicatorObjects.find((e=>e.indicatorKey===t));return{dimensionKey:i?void 0:this.rowShowAttrs[e],indicatorKey:i?t:void 0,value:i?i.define.caption:t}}))??[]}}getCellAdressByHeaderPath(t){let e,i;if(Array.isArray(t)){if(t.length>this.rowShowAttrs.length+this.colShowAttrs.length)return;e=t.filter((t=>this.colShowAttrs.indexOf(t.dimensionKey)>=0)),i=t.filter((t=>this.rowShowAttrs.indexOf(t.dimensionKey)>=0))}else e=t.colHeaderPaths,i=t.rowHeaderPaths;if(!Array.isArray(e)&&!Array.isArray(i))return;e?.sort(((t,e)=>this.colShowAttrs.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.colShowAttrs.indexOf(e.dimensionKey??this.indicatorDimensionKey))),i?.sort(((t,e)=>this.rowShowAttrs.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.rowShowAttrs.indexOf(e.dimensionKey??this.indicatorDimensionKey))),e?.length>=1&&i?.length;let n,r=0,o=0,s=this.rowTree,a=this.columnTree;if(e)for(let t=0;t<e.length;t++){const i=e[t];if(i.indicatorKey){n=i.indicatorKey;break}for(let t=0;t<a.length;t++){const e=a[t];if(!A(i.indicatorKey)&&e.dimensionKey===i.dimensionKey&&e.value===i.value){a=e.children,a&&0!==a.length&&!a?.[0]?.indicatorKey||(r+=t);break}r+=e.children?.[0]?.indicatorKey?0:e.children?.length??0}}if(i)for(let t=0;t<i.length;t++){const e=i[t];if(e.indicatorKey){n=e.indicatorKey;break}for(let t=0;t<s.length;t++){const i=s[t];if(!A(e.indicatorKey)&&i.dimensionKey===e.dimensionKey&&i.value===e.value){s=i.children,s&&0!==s.length&&!s?.[0]?.indicatorKey||(o+=t);break}o+=i.children?.[0]?.indicatorKey?0:i.children?.length??0}}return r=(this.indicatorsAsCol?r*this.indicatorKeys.length+this.indicatorKeys.indexOf(n):r)+this.rowHeaderLevelCount,o=(this.indicatorsAsCol?o:o*this.indicatorKeys.length+this.indicatorKeys.indexOf(n))+this.columnHeaderLevelCount,A(r)||A(o)?{col:r??undefined,row:o??undefined}:void 0}getHeaderDimension(t,e){if(this.isHeader(t,e)){const i=this.getHeader(t,e);return this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))}}updateDataset(t){this.dataset=t,this.dataConfig=t.dataConfig,this.rowKeysPath=t.rowKeysPath,this.colKeysPath=t.colKeysPath,this.tree=t.tree,this._indicatorObjects=[],this._headerObjects=[],this._headerObjectMap={},this.initState(),this.convertColKeys=C(this.colKeysPath)}isHeaderForColWidth(t,e){return this.isHeader(t,e)}getHeaderForColWidth(t,e){return this.getHeader(t,e)}setChartInstance(t,e,i){const n=this.getCellHeaderPaths(t,e);let r;if(this.indicatorsAsCol){const t=n.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicatorObjects.find((e=>e.indicatorKey===t))}else{const t=n.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicatorObjects.find((e=>e.indicatorKey===t))}r&&(r.chartInstance=i)}getChartInstance(t,e){const i=this.getCellHeaderPaths(t,e);let n;if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicatorObjects.find((e=>e.indicatorKey===t))}else{const t=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicatorObjects.find((e=>e.indicatorKey===t))}return n?.chartInstance}_generateChartState(){return{vtable_selected:{filter:t=>{if(this._table._selectedDataItemsInChart.length>=1){return!!this._table._selectedDataItemsInChart.find((e=>{for(const i in e)if(e[i]!==t[i])return!1;return!0}))}if(this._table._selectedDimensionInChart.length){return!!this._table._selectedDimensionInChart.every((e=>t[e.key]===e.value))}return!1}},vtable_selected_reverse:{filter:t=>{if(this._table._selectedDataItemsInChart.length>=1){return!this._table._selectedDataItemsInChart.find((e=>{for(const i in e)if(e[i]!==t[i])return!1;return!0}))}if(this._table._selectedDimensionInChart.length){return!this._table._selectedDimensionInChart.every((e=>t[e.key]===e.value))}return!1}}}}updateDataStateToChartInstance(t){t||(t=this._table._getActiveChartInstance());const e=this._generateChartState();this._indicatorObjects.forEach((t=>{t.chartInstance.updateState(e)})),t?.updateState(e)}updateDataStateToActiveChartInstance(t){t||(t=this._table._getActiveChartInstance());const e=this._generateChartState();t?.updateState(e)}getOptimunWidthForChart(t){const e=this.getCellHeaderPaths(t,this.columnHeaderLevelCount).colHeaderPaths;let i;for(const t in this.dataset.collectValuesBy)if("xField"===this.dataset.collectValuesBy[t].type&&!this.dataset.collectValuesBy[t].range){i=this.dataset.collectedValues[t][e.map((t=>t.value)).join(this.dataset.stringJoinChar)];break}return 50*(i?.size??0)}getIndicatorKeyInChartSpec(t,e){const i=this.getRawChartSpec(t,e),n=[];return i?(!1===this.indicatorsAsCol?i.series?i.series.forEach((t=>{const e=t.yField;n.push(e)})):n.push(i.yField):i.series?i.series.forEach((t=>{const e=t.xField;n.push(e)})):n.push(i.xField),n):null}getDimensionKeyInChartSpec(t,e){const i=this.getRawChartSpec(t,e),n=[];return i?(!1===this.indicatorsAsCol?n.push(i.xField):n.push(i.yField),n):null}getAxisConfigInPivotChart(t,e){return function(t,e,i){if(i._table.isPivotChart())if(i.indicatorsAsCol){if(i.hasTwoIndicatorAxes&&e===i.columnHeaderLevelCount-1&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){const e=i.getIndicatorKeyInChartSpec(t,i.columnHeaderLevelCount-1)[1];if(!e)return;const n=i.dataset.collectedValues[e+"_align"]?i.dataset.collectedValues[e+"_align"]:i.dataset.collectedValues[e],r=i.getRecordIndexByCol(t),o=n[i.getColKeysPath()[r][i.columnHeaderLevelCount-1-i.topAxesCount]],s=i._table.pivotChartAxes.find((t=>"top"===t.orient));if(!1===s?.visible)return;return Zt({},s,{orient:"top",type:"linear",range:o,label:{flush:!0},title:{visible:!1}})}if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){const n=i.getIndicatorKeyInChartSpec(t,e),r=n[0],o=i.dataset.collectedValues[r+"_align"]?i.dataset.collectedValues[r+"_align"]:i.dataset.collectedValues[r],s=i.getRecordIndexByCol(t),a=o[i.getColKeysPath()[s][i.columnHeaderLevelCount-1-i.topAxesCount]];let l=null;n.forEach((t=>{const e=i.getIndicatorInfo(t);e&&(l=e)}));const h=i._table.pivotChartAxes.find((t=>"bottom"===t.orient));if(!1===h?.visible)return;return Zt({},h,{orient:"bottom",type:"linear",range:a,label:{flush:!0},title:{text:l?.caption,autoRotate:!0}})}if(t===i.rowHeaderLevelCount-1&&e>=i.rowHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){const t=i.getDimensionKeyInChartSpec(i.rowHeaderLevelCount,e)[0],n=i.dataset.collectedValues[t],r=i.getRecordIndexByRow(e),o=i.getRowKeysPath()[r],s=n[o[o.length-1]],a=i._table.pivotChartAxes.find((t=>"left"===t.orient));if(!1===a?.visible)return;return Zt({},a,{orient:"left",type:"band",data:Array.from(s).reverse(),title:{visible:!1}})}}else{if(t===i.rowHeaderLevelCount-1&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){const n=i.getIndicatorKeyInChartSpec(t,e),r=n[0],o=i.dataset.collectedValues[r+"_align"]?i.dataset.collectedValues[r+"_align"]:i.dataset.collectedValues[r],s=i.getRecordIndexByRow(e),a=o[i.getRowKeysPath()[s][i.rowHeaderLevelCount-1-i.leftAxesCount]];let l=null;n.forEach((t=>{const e=i.getIndicatorInfo(t);e&&(l=e)}));const h=i._table.pivotChartAxes.find((t=>"left"===t.orient));if(!1===h?.visible)return;return Zt({},h,{orient:"left",type:"linear",range:a,label:{flush:!0},title:{text:l?.caption,autoRotate:!0}})}if(t===i.colCount-i.rightFrozenColCount&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){const t=i.getIndicatorKeyInChartSpec(i.rowHeaderLevelCount-1,e)[1];if(!t)return;const n=i.dataset.collectedValues[t+"_align"]?i.dataset.collectedValues[t+"_align"]:i.dataset.collectedValues[t],r=i.getRecordIndexByRow(e),o=n[i.getRowKeysPath()[r][i.rowHeaderLevelCount-1-i.leftAxesCount]],s=i._table.pivotChartAxes.find((t=>"right"===t.orient));if(!1===s?.visible)return;return Zt({},s,{orient:"right",type:"linear",range:o,label:{flush:!0},title:{visible:!1}})}if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){const e=i.getDimensionKeyInChartSpec(t,i.columnHeaderLevelCount)[0],n=i.dataset.collectedValues[e],r=i.getRecordIndexByCol(t),o=i.getColKeysPath()[r],s=n[o[o.length-1]],a=i._table.pivotChartAxes.find((t=>"bottom"===t.orient));if(!1===a?.visible)return;return Zt({},a,{orient:"bottom",type:"band",data:Array.from(s),title:{visible:!1}})}}}(t,e,this)}getRawChartSpec(t,e){return function(t,e,i){const n=i.getCellHeaderPaths(t,e);let r;if(i.indicatorsAsCol){const t=n.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=i.columnObjects.find((e=>e.indicatorKey===t))}else{const t=n.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=i.columnObjects.find((e=>e.indicatorKey===t))}const o=r?.chartSpec;return o}(t,e,this)}getChartSpec(t,e){return function(t,e,i){let n=i.getRawChartSpec(t,e);return n?(n=$t(n),n.axes=i.getChartAxes(t,e),n.padding=0,n):null}(t,e,this)}getChartAxes(t,e){return function(t,e,i){const n=[];if(i.indicatorsAsCol){const r=i.getIndicatorKeyInChartSpec(t,e),o=i.getRecordIndexByCol(t);r.forEach(((t,e)=>{const r=(i.dataset.collectedValues[t+"_align"]?i.dataset.collectedValues[t+"_align"]:i.dataset.collectedValues[t])[i.getColKeysPath()[o][i.columnHeaderLevelCount-1-i.topAxesCount]],s=i._table.pivotChartAxes.find((t=>t.orient===(0===e?"bottom":"top")));n.push(Zt({},s,{type:"linear",orient:0===e?"bottom":"top",label:{visible:!1},title:{visible:!1},range:r,seriesIndex:e}))}));const s=i.getDimensionKeyInChartSpec(i.rowHeaderLevelCount,t)[0],a=i.dataset.collectedValues[s],l=i.getRecordIndexByRow(e),h=i.getRowKeysPath()[l],c=a[h[h.length-1]],d=i._table.pivotChartAxes.find((t=>"left"===t.orient));n.push(Zt({},d,{type:"band",orient:"left",label:{visible:!1,space:0},domainLine:{visible:!1},tick:{visible:!1},subTick:{visible:!1},title:{visible:!1},width:-1,domain:Array.from(c)}))}else{const r=i.getIndicatorKeyInChartSpec(t,e),o=i.getRecordIndexByRow(e);r.forEach(((t,e)=>{const r=(i.dataset.collectedValues[t+"_align"]?i.dataset.collectedValues[t+"_align"]:i.dataset.collectedValues[t])[i.getRowKeysPath()[o][i.rowHeaderLevelCount-1-i.leftAxesCount]],s=i._table.pivotChartAxes.find((t=>t.orient===(0===e?"left":"right")));n.push(Zt({},s,{type:"linear",orient:0===e?"left":"right",label:{visible:!1},title:{visible:!1},range:r,seriesIndex:e}))}));const s=i.getDimensionKeyInChartSpec(t,i.columnHeaderLevelCount)[0],a=i.dataset.collectedValues[s],l=i.getRecordIndexByCol(t),h=i.getColKeysPath()[l],c=a[h[h.length-1]],d=i._table.pivotChartAxes.find((t=>"bottom"===t.orient));n.push(Zt({},d,{type:"band",orient:"bottom",visible:!0,label:{visible:!1,space:0},domainLine:{visible:!1},tick:{visible:!1},subTick:{visible:!1},title:{visible:!1},height:-1,domain:Array.from(c)}))}return n}(t,e,this)}isEmpty(t,e){return!!this._table.isPivotChart()&&(t>this.colCount-this.rightFrozenColCount-1||e>this.rowCount-this.bottomFrozenRowCount-1||!(!this.hasTwoIndicatorAxes||!this.indicatorsAsCol||e!==this.columnHeaderLevelCount-1))}}class eE{dataConfig;records;tree={};colFlatKeys={};rowFlatKeys={};stringJoinChar=String.fromCharCode(0);rowsIsTotal=[];colsIsTotal=[];colGrandTotalLabel;colSubTotalLabel;rowGrandTotalLabel;rowSubTotalLabel;constructor(t,e){if(this.dataConfig=t,e){this.records=e;const t="undefined"!=typeof window?window.performance.now():0;this.setRecords(e);const i="undefined"!=typeof window?window.performance.now():0;console.log("processRecords:",i-t)}delete this.rowFlatKeys,delete this.colFlatKeys}setRecords(t){this.processRecords()}processRecords(){for(let t=0,e=this.records.length;t<e;t++){const e=this.records[t];this.processRecord(e)}}processRecord(t){const e=[],i=[];for(let e=0,n=this.dataConfig.rows.length;e<n;e++){const n=this.dataConfig.rows[e];void 0!==t[n]&&n!==this.dataConfig.indicatorDimensionKey&&i.push(t[n])}for(let i=0,n=this.dataConfig.columns.length;i<n;i++){const n=this.dataConfig.columns[i];void 0!==t[n]&&n!==this.dataConfig.indicatorDimensionKey&&e.push(t[n])}this.dataConfig.indicators.forEach((n=>{const r=t[n];void 0!==r&&(this.dataConfig.indicatorsAsCol?e.push(n):i.push(n));const o=i.join(this.stringJoinChar),s=e.join(this.stringJoinChar);0!==i.length&&(this.rowFlatKeys[o]||(this.rowFlatKeys[o]=1)),0!==e.length&&(this.colFlatKeys[s]||(this.colFlatKeys[s]=1)),0===e.length&&0===i.length||(this.tree[o]||(this.tree[o]={}),void 0!==r&&(this.tree[o][s]={value:r,record:t},this.dataConfig.indicatorsAsCol?e.pop():i.pop()))}))}getTreeNode(t=[],e=[],i){let n,r;if("string"==typeof t)n=t;else{let e=!1;t.map(((n,r)=>{n===i&&(t.splice(r,1),e=!0)})),e&&t.push(i),n=t.join(this.stringJoinChar)}if("string"==typeof e)r=e;else{let t=!1;e.map(((n,r)=>{n===i&&(e.splice(r,1),t=!0)})),t&&e.push(i),r=e.join(this.stringJoinChar)}return this.tree?.[n]?.[r]??void 0}}class iE{className="Aggregator";isRecord=!0;records=[];type;field;formatFun;_formatedValue;constructor(t,e,i){this.field=t,this.formatFun=e,this.isRecord=i??this.isRecord}formatValue(){return this._formatedValue||(this.formatFun?this._formatedValue=this.formatFun(this.value()):this._formatedValue=this.value()),this._formatedValue}reset(){this.records=[]}}class nE extends iE{type=o.RECORD;isRecord=!0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t))}value(){return this.records}reset(){this.records=[]}}class rE extends iE{type=o.SUM;sum=0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.sum+=t.value():isNaN(parseFloat(t[this.field]))||(this.sum+=parseFloat(t[this.field]))}value(){return this.sum}reset(){this.records=[],this.sum=0}}class oE extends iE{type=o.COUNT;count=0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.count+=t.value():this.count++}value(){return this.count}reset(){this.records=[],this.count=0}}class sE extends iE{type=o.AVG;sum=0;count=0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className&&t.type===o.AVG?(this.sum+=t.sum,this.count+=t.count):isNaN(parseFloat(t[this.field]))||(this.sum+=parseFloat(t[this.field]),this.count++)}value(){return this.sum/this.count}reset(){this.records=[],this.sum=0,this.count=0}}class aE extends iE{type=o.MAX;max=Number.MIN_SAFE_INTEGER;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.max=t.max>this.max?t.max:this.max:"number"==typeof t?this.max=t>this.max?t:this.max:"number"==typeof t[this.field]?this.max=t[this.field]>this.max?t[this.field]:this.max:isNaN(t[this.field])||(this.max=parseFloat(t[this.field])>this.max?parseFloat(t[this.field]):this.max)}value(){return this.max}reset(){this.records=[],this.max=Number.MIN_SAFE_INTEGER}}class lE extends iE{type=o.MIN;min=Number.MAX_SAFE_INTEGER;isRecord=!1;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.min=t.min<this.min?t.min:this.min:"number"==typeof t?this.min=t<this.min?t:this.min:"number"==typeof t[this.field]&&(this.min=t[this.field]<this.min?t[this.field]:this.min)}value(){return this.min}reset(){this.records=[],this.min=Number.MAX_SAFE_INTEGER}}function hE(t,e){return t&&e?t.toString().localeCompare(e.toString(),"zh"):t?1:-1}function cE(t,e){const i=/(\d+)|(\D+)/g,n=/\d/,r=/^0/;let o,s,a,l,h=0,c=0;if(null!==e&&null===t)return-1;if(null!==t&&null===e)return 1;if("number"==typeof t&&isNaN(t))return-1;if("number"==typeof e&&isNaN(e))return 1;if(h=+t,c=+e,h<c)return-1;if(h>c)return 1;if("number"==typeof t&&"number"!=typeof e)return-1;if("number"==typeof e&&"number"!=typeof t)return 1;if("number"==typeof t&&"number"==typeof e)return 0;if(isNaN(c)&&!isNaN(h))return-1;if(isNaN(h)&&!isNaN(c))return 1;if(o=String(t),a=String(e),o===a)return 0;if(!n.test(o)||!n.test(a))return o>a?1:-1;for(o=o.match(i),a=a.match(i);o.length&&a.length;)if(s=o.shift(),l=a.shift(),s!==l)return n.test(s)&&n.test(l)?s.replace(r,".0")-l.replace(r,".0"):s>l?1:-1;return o.length-a.length}function dE(t){return 2===t.length&&zt(t[0])&&zt(t[1])&&t[1]>=t[0]}function uE(t){const e=t[1]-t[0],i=t[1]*t[0]<0;let n=t[0]<=0?0-t[0]:0,r=t[1]>0?t[1]-0:0;return 0===e?t[0]<0?(n=1,r=0):t[0]>0&&(n=0,r=1):(n/=e,r/=e),{total:e,negative:n,positive:r,includeZero:i,domain:t,extendable_min:!0,extendable_max:!0}}function pE(t,e){const{positive:i,negative:n,extendable_min:r,extendable_max:o,domain:s}=t,{positive:a,negative:l,extendable_min:h,extendable_max:c,domain:d}=e;if(a>0){if(!h)return!1;let t=n/i;o&&(t=n/Math.max(i,a),s[1]=-s[0]/t),d[0]=-d[1]*t}else if(l>0){if(!c)return!1;let t=i/n;r&&(t=i/Math.max(n,n),s[0]=-s[1]/t),d[1]=-d[0]*t}return!0}function fE(t,e){const{extendable_min:i,extendable_max:n,domain:r}=t,{positive:o,negative:s,domain:a}=e;return(0!==o||0!==s)&&(!(o>0&&!n)&&(!(s>0&&!i)&&(r[0]=a[0],r[1]=a[1],!0)))}function gE(t,e){const{positive:i,negative:n,extendable_max:r,domain:o}=t,{positive:s,negative:a,extendable_min:l,domain:h}=e;if(r&&l){const t=Math.max(n,a)/Math.max(i,s);o[1]=-o[0]/t,h[0]=-h[1]*t}else if(l){const t=n/i;h[0]=-h[1]*t}else{if(!r)return!1;{const t=a/s;o[1]=-o[0]/t}}return!0}function yE(t,e){const{extendable_min:i,domain:n}=t,{extendable_max:r,domain:o}=e;return!(!i||!r)&&(n[0]=-n[1],o[1]=-o[0],!0)}function mE(t,e){const i=[t.min,t.max],n=[e.min,e.max];if(!dE(i)||!dE(n))return;const r=uE(i),o=uE(n),{positive:s,negative:a,extendable_min:l,extendable_max:h,includeZero:c}=r,{positive:d,negative:u,extendable_min:p,extendable_max:f,includeZero:g}=o;if(0===s&&0===a){if(!fE(r,o))return}else if(0===d&&0===u){if(!fE(o,r))return}else if(c||g)if(c&&!g){if(!pE(r,o))return}else if(g&&!c){if(!pE(o,r))return}else{if(a===u)return;if(a>u){if(!gE(r,o))return}else if(!gE(o,r))return}else{if(0===a&&0===d){if(!yE(r,o))return}else if(0===u&&0===s&&!yE(o,r))return;if(0===a&&0===u)if(0===i[0]&&n[0]>0){if(!p)return;n[0]=0}else{if(!(0===n[0]&&i[0]>0))return;if(!l)return;i[0]=0}if(0===s&&0===d)if(0===i[1]&&n[1]>0){if(!f)return;n[1]=0}else{if(!(0===n[1]&&i[1]>0))return;if(!h)return;i[1]=0}}return{range1:i,range2:n}}class bE{dataConfig;records;tree={};colFlatKeys={};rowFlatKeys={};colKeys=[];rowKeys=[];rowKeysPath;colKeysPath;rowOrder="key_a_to_z";colOrder="key_a_to_z";sorted=!1;sortRules;filterRules;aggregationRules;derivedFieldRules;mappingRules;totals;indicatorStatistics=[];aggregators={};stringJoinChar=String.fromCharCode(0);rowsIsTotal=[];colsIsTotal=[];colGrandTotalLabel;colSubTotalLabel;rowGrandTotalLabel;rowSubTotalLabel;collectValuesBy;collectedValues={};rows;columns;indicatorKeys;constructor(t,e,i,n,r,o,s){this.registerAggregators(),this.dataConfig=t,this.sortRules=this.dataConfig?.sortRules,this.aggregationRules=this.dataConfig?.aggregationRules,this.derivedFieldRules=this.dataConfig?.derivedFieldRules,this.mappingRules=this.dataConfig?.mappingRules,this.totals=this.dataConfig?.totals,this.rows=e,this.columns=i,this.indicatorKeys=n,this.colGrandTotalLabel=this.totals?.column?.grandTotalLabel??"总计",this.colSubTotalLabel=this.totals?.column?.subTotalLabel??"小计",this.rowGrandTotalLabel=this.totals?.row?.grandTotalLabel??"总计",this.rowSubTotalLabel=this.totals?.row?.subTotalLabel??"小计",this.collectValuesBy=this.dataConfig?.collectValuesBy??{230417170554008:{by:["230417171050031","230417171050028"]}},this.rowsIsTotal=new Array(this.rows.length).fill(!1),this.colsIsTotal=new Array(this.columns.length).fill(!1);for(let t=0,e=this.totals?.row?.subTotalsDimensions?.length;t<e;t++){const e=this.totals.row.subTotalsDimensions[t],i=this.rows.indexOf(e);this.rowsIsTotal[i]=!0}for(let t=0,e=this.totals?.column?.subTotalsDimensions?.length;t<e;t++){const e=this.totals.column.subTotalsDimensions[t],i=this.columns.indexOf(e);this.colsIsTotal[i]=!0}if(r){this.records=r;const t="undefined"!=typeof window?window.performance.now():0;this.setRecords(r),this.processCollectedValuesWithSumBy();const e="undefined"!=typeof window?window.performance.now():0;console.log("processRecords:",e-t);const i="undefined"!=typeof window?window.performance.now():0;this.totalStatistics();const n="undefined"!=typeof window?window.performance.now():0;console.log("totalStatistics:",n-i);const a="undefined"!=typeof window?window.performance.now():0;this.sortKeys();const l="undefined"!=typeof window?window.performance.now():0;console.log("sortKeys:",l-a);const h="undefined"!=typeof window?window.performance.now():0;this.rowKeysPath=s?this.TreeToArr2(s):this.TreeToArr(this.ArrToTree(this.rowKeys,this.rowsIsTotal,this?.totals?.row?.showGrandTotals||0===this.columns.length,this.rowGrandTotalLabel,this.rowSubTotalLabel)),this.colKeysPath=o?this.TreeToArr2(o):this.TreeToArr(this.ArrToTree(this.colKeys,this.colsIsTotal,this.totals?.column?.showGrandTotals||0===this.rows.length,this.colGrandTotalLabel,this.colSubTotalLabel));const c="undefined"!=typeof window?window.performance.now():0;console.log("TreeToArr:",c-h),this.dataConfig.isPivotChart&&this.dealWithZeroAlign()}}registerAggregator(t,e){this.aggregators[t]=e}registerAggregators(){this.registerAggregator(o.RECORD,nE),this.registerAggregator(o.SUM,rE),this.registerAggregator(o.COUNT,oE),this.registerAggregator(o.MAX,aE),this.registerAggregator(o.MIN,lE),this.registerAggregator(o.AVG,sE)}setRecords(t){this.processRecords()}processCollectedValuesWithSumBy(){for(const t in this.collectedValues)if(this.collectValuesBy[t]?.sumBy)for(const e in this.collectedValues[t]){const i=Object.values(this.collectedValues[t][e]).reduce(((t,e)=>e.value()>t?e.value():t),Number.MIN_SAFE_INTEGER),n=Object.values(this.collectedValues[t][e]).reduce(((t,e)=>e.value()<t?e.value():t),Number.MAX_SAFE_INTEGER);this.collectedValues[t][e]={},this.collectedValues[t][e].max=i,this.collectedValues[t][e].min=n}}processRecords(){let t=!1;this.dataConfig?.filterRules?.length>=1&&(t=!0);for(let e=0,i=this.records.length;e<i;e++){const i=this.records[e];t&&!this.filterRecord(i)||this.processRecord(i)}this.rowFlatKeys={},this.colFlatKeys={}}filterRecord(t){let e=!0;for(let i=0;i<this.dataConfig.filterRules.length;i++){const n=this.dataConfig?.filterRules[i];if(n.filterKey){const i=t[n.filterKey];if(-1===n.filteredValues.indexOf(i)){e=!1;break}}else if(!n.filterFunc?.(t)){e=!1;break}}return e}processRecord(t){this.derivedFieldRules?.forEach(((e,i)=>{t[e.fieldName]=e.derivedFunc(t)}));const e=[],i=[];for(let e=0,n=this.rows.length;e<n;e++){const n=this.rows[e];i.push(t[n])}for(let i=0,n=this.columns.length;i<n;i++){const n=this.columns[i];e.push(t[n])}for(const e in this.collectValuesBy)if(t[e]){this.collectedValues[e]||(this.collectedValues[e]={});const i=this.collectValuesBy[e].by.map((e=>t[e])).join(this.stringJoinChar);if(this.collectedValues[e][i]||(this.collectValuesBy[e].sumBy?this.collectedValues[e][i]={}:this.collectValuesBy[e].range?this.collectedValues[e][i]={min:Number.MAX_SAFE_INTEGER,max:Number.MIN_SAFE_INTEGER}:this.collectedValues[e][i]=new Set),this.collectValuesBy[e].sumBy){const n=this.collectValuesBy[e].sumBy.map((e=>t[e])).join(this.stringJoinChar);this.collectedValues[e][i][n]||(this.collectedValues[e][i][n]=new this.aggregators[o.SUM](e)),this.collectedValues[e][i][n].push(t)}else if(this.collectValuesBy[e].range){const n=this.collectedValues[e][i];n.max=Math.max(t[e],n.max),n.min=Math.min(t[e],n.min)}else{this.collectedValues[e][i].add(t[e])}}const n=i.join(this.stringJoinChar),r=e.join(this.stringJoinChar);if(0!==i.length&&(this.rowFlatKeys[n]||(this.rowKeys.push(i),this.rowFlatKeys[n]=1)),0!==e.length&&(this.colFlatKeys[r]||(this.colKeys.push(e),this.colFlatKeys[r]=1)),0!==e.length||0!==i.length){this.tree[n]||(this.tree[n]={}),this.tree[n]?.[r]||(this.tree[n][r]=[]);for(let e=0;e<this.indicatorKeys.length;e++){const i=this.getAggregatorRule(this.indicatorKeys[e]);if(this.tree[n]?.[r]?.[e]||(this.tree[n][r][e]=new this.aggregators[i?.aggregationType??o.SUM](i?.field??this.indicatorKeys[e],i?.formatFun)),i?.field)if("string"==typeof i?.field)A(t[i?.field])&&this.tree[n]?.[r]?.[e].push(t);else{const o=i?.field.find((e=>t[e]));o&&this.tree[n]?.[r]?.[e].push(t)}else A(t[this.indicatorKeys[e]])&&this.tree[n]?.[r]?.[e].push(t)}}if(this.mappingRules)for(let e=0;e<this.indicatorKeys.length;e++){if(!this.indicatorStatistics[e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.indicatorStatistics[e]={max:new this.aggregators[o.MAX](this.indicatorKeys[e]),min:new this.aggregators[o.MIN](this.indicatorKeys[e]),total:new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}}this.indicatorStatistics[e].max.push(this.tree[n]?.[r]?.[e].value()),this.indicatorStatistics[e].min.push(this.tree[n]?.[r]?.[e].value()),this.indicatorStatistics[e].total.push(t)}}updateSortRules(t){this.sorted=!1,this.sortRules=t,this.sortKeys(),this.rowKeysPath=this.TreeToArr(this.ArrToTree(this.rowKeys,this.rowsIsTotal,this?.totals?.row?.showGrandTotals||0===this.columns.length,this.rowGrandTotalLabel,this.rowSubTotalLabel)),this.colKeysPath=this.TreeToArr(this.ArrToTree(this.colKeys,this.colsIsTotal,this.totals?.column?.showGrandTotals||0===this.rows.length,this.colGrandTotalLabel,this.colSubTotalLabel))}updateFilterRules(t,e=!1){if(this.filterRules=t,e)this.tree={};else for(const t in this.tree)for(const e in this.tree[t])for(let i=0;i<this.tree[t][e].length;i++)this.tree[t][e][i].reset();this.collectedValues={},this.processRecords(),this.processCollectedValuesWithSumBy()}getAggregatorRule(t){return this.aggregationRules?.find(((e,i)=>t===e.indicatorKey))}getAggregator(t=[],e=[],i){const n=this.indicatorKeys.indexOf(i);let r,o,s;return o="string"==typeof t?t:t.join(this.stringJoinChar),s="string"==typeof e?e:e.join(this.stringJoinChar),0===t.length&&0===e.length||(r=this.tree[o]?.[s]?.[n]),r||{className:"",push(){},value:()=>null,formatValue:()=>"",reset(){}}}sortKeys(){const t=this;if(!this.sorted){this.sorted=!0;const e=function(e,i){return t.getAggregator(e,i,"").value()};switch(this.rowOrder){case"value_a_to_z":this.rowKeys.sort((function(t,i){return cE(e(t,[]),e(i,[]))}));break;case"value_z_to_a":this.rowKeys.sort((function(t,i){return-cE(e(t,[]),e(i,[]))}));break;default:this.rowKeys.sort(this.arrSort(this.rows,!0))}switch(this.colOrder){case"value_a_to_z":this.colKeys.sort((function(t,i){return cE(e([],t),e([],i))}));break;case"value_z_to_a":this.colKeys.sort((function(t,i){return-cE(e([],t),e([],i))}));break;default:const t=this.arrSort(this.columns,!1);this.colKeys.sort(t)}}}arrSort(t,e){let i;const n=this,r=function(r){const o=[];for(let r=0,s=t.length;r<s;r++){i=t[r];let s=!1;if(n.sortRules)for(let t=0,a=n.sortRules.length;t<a;t++)n.sortRules[t].sortField===i&&(s=!0,o.push({field:i,fieldIndex:r,sortRule:n.sortRules[t],func:n.getSort(n.sortRules[t],e)}));s||o.push({field:i,fieldIndex:r,func:cE})}return o}.call(this);return function(i,o){let a,l;for(let h=0;h<r.length;h++){if(l=r[h],l.sortRule?.sortByIndicator){let r=i,s=o;l.fieldIndex<t.length-1&&(r=i.slice(0,l.fieldIndex+1),r.push(e?n.totals?.row?.subTotalLabel:n.totals?.column?.subTotalLabel),s=o.slice(0,l.fieldIndex+1),s.push(e?n.totals?.row?.subTotalLabel:n.totals?.column?.subTotalLabel)),a=l.func(r,s)}else a=l.func(i[l.fieldIndex],o[l.fieldIndex]);if(0!==a)return a*(l.sortRule?.sortType===s.DESC?-1:1)}return 0}}getSort(t,e){const i=this;return t.sortByIndicator?(n,r)=>{const o=function(e,n){return e.length<i.rows.length&&e[e.length-1]!==i.rowSubTotalLabel&&e[e.length-1]!==i.rowGrandTotalLabel&&e.push(i.rowSubTotalLabel),n.length<i.columns.length&&n[n.length-1]!==i.colSubTotalLabel&&n[n.length-1]!==i.colGrandTotalLabel&&n.push(i.colSubTotalLabel),i.getAggregator(e,n,t.sortByIndicator).value()};return e?cE(o(n,t.query),o(r,t.query)):cE(o(t.query,n),o(t.query,r))}:t.sortBy?function(t){let e;const i={},n={};for(let r=0;r<t.length;r++)e=t[r],i[e]=r,"string"==typeof e&&(n[e.toLowerCase()]=r);return function(t,e){return null!==i[t]&&void 0!==i[t]&&null!==i[e]&&void 0!==i[e]?i[t]-i[e]:null!==i[t]&&void 0!==i[t]?-1:null!==i[e]&&void 0!==i[e]?1:null!==n[t]&&void 0!==i[t]&&null!==n[e]&&void 0!==i[e]?n[t]-n[e]:null===n[t]||void 0===i[t]||null===n[e]||void 0===i[e]?0:null!==n[t]&&void 0!==i[t]?-1:null!==n[e]&&void 0!==i[e]?1:cE(t,e)}}(t.sortBy):t.sortType?hE:t.sortFunc?t.sortFunc:cE}totalStatistics(){const t=this;if(t?.totals?.column?.showSubTotals&&t?.totals?.column?.subTotalsDimensions?.length>=1||t?.totals?.row?.showSubTotals&&t?.totals?.row?.subTotalsDimensions?.length>=1||t?.totals?.column?.showGrandTotals||t?.totals?.row?.showGrandTotals||0===t.rows.length||0===t.columns.length){const e=[],i=(e,i)=>{const n=i.split(this.stringJoinChar);for(let r=0,s=t.totals?.column?.subTotalsDimensions?.length;r<s;r++){const s=t.totals.column.subTotalsDimensions[r],a=t.columns.indexOf(s);if(a>=0){const r=n.slice(0,a+1);r.push(t.totals?.column?.subTotalLabel??"小计");const s=r.join(this.stringJoinChar);this.tree[e][s]||(this.tree[e][s]=[]);for(let n=0;n<this.indicatorKeys.length;n++){if(!this.tree[e][s][n]){const t=this.getAggregatorRule(this.indicatorKeys[n]);this.tree[e][s][n]=new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[n],t?.formatFun)}this.tree[e][s][n].push(t.tree[e]?.[i]?.[n])}}}if(t.totals?.column?.showGrandTotals||0===this.rows.length){const n=t.colGrandTotalLabel;this.tree[e][n]||(this.tree[e][n]=[]);for(let r=0;r<this.indicatorKeys.length;r++){if(!this.tree[e][n][r]){const t=this.getAggregatorRule(this.indicatorKeys[r]);this.tree[e][n][r]=new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[r],t?.formatFun)}this.tree[e][n][r].push(t.tree[e]?.[i]?.[r])}}};Object.keys(t.tree).forEach((n=>{const r=n.split(this.stringJoinChar);Object.keys(t.tree[n]).forEach((s=>{for(let i=0,a=t.totals?.row?.subTotalsDimensions?.length;i<a;i++){const a=t.totals.row.subTotalsDimensions[i],l=t.rows.indexOf(a);if(l>=0){const i=r.slice(0,l+1);i.push(t.totals?.row?.subTotalLabel??"小计");const a=i.join(this.stringJoinChar);if(this.tree[a]||(this.tree[a]={},e.push(a)),!this.tree[a][s]){this.tree[a][s]=[];for(let e=0;e<this.indicatorKeys.length;e++){if(!this.tree[a][s][e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.tree[a][s][e]=new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}this.tree[a][s][e].push(t.tree[n]?.[s]?.[e])}}}}if(t.totals?.row?.showGrandTotals||0===this.columns.length){const i=t.rowGrandTotalLabel;this.tree[i]||(this.tree[i]={},e.push(i)),this.tree[i][s]||(this.tree[i][s]=[]);for(let e=0;e<this.indicatorKeys.length;e++){if(!this.tree[i][s][e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.tree[i][s][e]=new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}this.tree[i][s][e].push(t.tree[n]?.[s]?.[e])}}i(n,s)}))})),e.forEach((e=>{Object.keys(t.tree[e]).forEach((t=>{i(e,t)}))}))}}ArrToTree(t,e,i,n,r){const o=[],s=this.stringJoinChar,a=new Map;if(t.forEach((t=>function(t){const i=[];let n;t.forEach(((l,h)=>{i.push(l);const c=i.join(s);let d=a.get(c);if(!d){if(d={id:c,children:[]},e[h]){let e=d.children;for(let i=h;i<t.length-1;i++){const t={id:`${c}${s}${r}`,children:[]};e.push(t),e=t.children}}a.set(c,d),n?e[h-1]?n.children.splice(n.children.length-1,0,d):n.children.push(d):o.push(d)}n=d}))}(t))),i){const t={id:n,children:[]};let i=t.children;for(let t=1;t<e.length;t++){const t={id:n,children:[]};i.push(t),i=t.children}o.push(t)}return o}TreeToArr(t){const e=[];function i(t,n){n.push(t.id),t.children.length>0?t.children?.forEach((t=>i(t,[...n]))):e.push(n)}return t.forEach((t=>i(t,[]))),e}TreeToArr2(t){const e=[];function i(t,n){n.push(n.length>0?[n[n.length-1],t.value].join(String.fromCharCode(0)):t.value),t.children?.length>0&&!t.children[0].indicatorKey?t.children?.forEach((t=>i(t,[...n]))):e.push(n)}return t.forEach((t=>i(t,[]))),e}dealWithZeroAlign(){const t=[];for(let e=0;e<this.aggregationRules.length;e++){const i=this.aggregationRules[e];Ot(i.field)&&2===i.field.length&&t.push(i.field)}t.forEach((t=>{const e=t[0],i=t[1],n=this.collectedValues[e],r=this.collectedValues[i];this.collectedValues[e+"_align"]={},this.collectedValues[i+"_align"]={};for(const t in n){const o=n[t],s=r[t],a=mE(o,s);if(a){const{range1:n,range2:r}=a;this.collectedValues[e+"_align"][t]={min:n[0],max:n[1]},this.collectedValues[i+"_align"][t]={min:r[0],max:r[1]}}else this.collectedValues[e+"_align"][t]={min:o.min,max:o.max},this.collectedValues[i+"_align"][t]={min:s.min,max:s.max}}}))}}class vE{type;id;x=0;y=0;width=0;height=0;marginLeft;marginRight;marginTop;marginBottom;layoutWidth;layoutHeight;dx=0;dy=0;background;constructor(t){this.id=t.id,this.marginLeft=t.marginLeft??0,this.marginRight=t.marginRight??0,this.marginTop=t.marginTop??0,this.marginBottom=t.marginBottom??0,this.background=t.background||void 0}getSize(t){this.initLayoutSize()}initLayoutSize(){this.layoutWidth=this.width+this.marginLeft+this.marginRight,this.layoutHeight=this.height+this.marginTop+this.marginBottom,this.background&&(this.layoutWidth+=2*(this.background.expandX||0),this.layoutHeight+=2*(this.background.expandY||0)),this.dx=this.marginLeft,this.dy=this.marginTop}}const wE={row:{x:"x",y:"y",width:"width",height:"height",layoutWidth:"layoutWidth",layoutHeight:"layoutHeight",widthLimit:"widthLimit",heightLimit:"heightLimit",parentX:"parentX",parentY:"parentY",dx:"dx",dy:"dy"},column:{x:"y",y:"x",width:"height",height:"width",layoutWidth:"layoutHeight",layoutHeight:"layoutWidth",widthLimit:"heightLimit",heightLimit:"widthLimit",parentX:"parentY",parentY:"parentX",dx:"dy",dy:"dx"}};class CE{width=0;height=0;y=0;x=0;children=[];addAble=!0;widthLimit=0;heightLimit=0;direction;directionKey;offsetX=0;justifyContent;alignItems;constructor(t,e,i,n){this.direction=e,this.directionKey=wE[this.direction],this.justifyContent=i,this.alignItems=n,this[this.directionKey.widthLimit]=t}add(t){t[this.directionKey.x]=this[this.directionKey.width],this[this.directionKey.width]+=t[this.directionKey.layoutWidth],this.children.push(t),this.updateHeight(t)}canAdd(t){return!(this[this.directionKey.width]+t[this.directionKey.layoutWidth]>this[this.directionKey.widthLimit])}updateHeight(t){t[this.directionKey.layoutHeight]>this[this.directionKey.height]&&(this[this.directionKey.height]=t[this.directionKey.layoutHeight])}lineFinish(){this.updateXAlign()}updateXAlign(){const t=this[this.directionKey.widthLimit]-this[this.directionKey.width];"center"===this.justifyContent?this.offsetX=t/2:"start"===this.justifyContent?this.offsetX=0:this.offsetX=t}getOffsetY(t){switch(this.alignItems){case"start":default:return 0;case"center":return(this[this.directionKey.height]-t[this.directionKey.layoutHeight])/2;case"end":return this[this.directionKey.height]-t[this.directionKey.layoutHeight]}}getContentSize(){const t={width:0,height:0};for(let e=0;e<this.children.length;e++){const i=this.children[e];let n;n="container"===i.type?i.getContentSize():{width:i.layoutWidth,height:i.layoutHeight},t[this.directionKey.height]<n[this.directionKey.height]&&(t[this.directionKey.height]=n[this.directionKey.height]),t[this.directionKey.width]+=n[this.directionKey.width]}return t}getElements(t={parentX:0,parentY:0},e=!1,i=!1){const n=[];for(let r=0;r<this.children.length;r++){const o=this.children[r];if("container"===o.type||"group-element"===o.type){const r=o.getElements({[this.directionKey.parentX]:this.offsetX+this[this.directionKey.x]+t.parentX,[this.directionKey.parentY]:this.getOffsetY(o)+this[this.directionKey.y]+t.parentY},e,i);n.push(...r)}else{if("icon"===o.type&&("mouseenter_cell"===o.cache?.visibleTime&&!e||"click_cell"===o.cache?.visibleTime&&!i))continue;o[this.directionKey.x]+=this.offsetX+this[this.directionKey.x]+t.parentX,o[this.directionKey.y]+=this.getOffsetY(o)+this[this.directionKey.y]+t.parentY,n.push(o)}}return n}}class xE extends vE{type="rect";lineWidth;cornerRadius;radius;fill;stroke;constructor(t){super(t),this.width=t.width,this.height=t.height,this.lineWidth=t.lineWidth||0,this.cornerRadius=t.cornerRadius||0,this.radius=this.cornerRadius,this.fill=t.fill||"#777",this.stroke=t.stroke||void 0,this.initLayoutSize()}}var _E=Object.freeze({__proto__:null,Circle:class extends vE{type="circle";radius;radian;lineWidth;fill;stroke;constructor(t){super(t),this.radius=t.radius,this.radian=t.radian,this.lineWidth=t.lineWidth,this.fill=t.fill,this.stroke=t.stroke,this.width=2*this.radius,this.height=2*this.radius,this.initLayoutSize(),this.dx+=this.radius,this.dy+=this.radius}},Container:class extends vE{type="container";_widthObj;_heightObj;needCalcSize=!1;direction;justifyContent;alignItems;alignContent;lines=[];currentLine;currentLineY=0;table;directionKey;showBounds;offsetY=0;isRoot;constructor(t){super(t),this.direction=t.direction||"row",this.justifyContent=t.justifyContent||"start",this.alignItems=t.alignItems||"start",this.alignContent=t.alignContent||"start",g(t.width)?this.width=t.width:(this._widthObj=t.width,this.needCalcSize=!0),g(t.height)?this.height=t.height:(this._heightObj=t.height,this.needCalcSize=!0),this.directionKey=wE[this.direction],this.showBounds=t.showBounds||!1,this.initLayoutSize()}add(t){if(this.needCalcSize)throw new Error("Need to specify a parent element before adding a child element when use percent size!");"container"===t.type&&t.calcSize(this.width,this.height),this.currentLine&&this.currentLine.canAdd(t)?this.currentLine.add(t):(this.currentLine&&(this.currentLine.addAble=!1,this.currentLineY+=this.currentLine[this.directionKey.height],this.currentLine.lineFinish()),this.currentLine=new CE(this[this.directionKey.width],this.direction,this.justifyContent,this.alignItems),this.currentLine[this.directionKey.y]=this.currentLineY,this.currentLine.add(t),this.lines.push(this.currentLine))}updateYAlign(){const t=this[this.directionKey.height]-this.currentLineY;"center"===this.alignContent?this.offsetY=t/2:"start"===this.alignContent?this.offsetY=0:this.offsetY=t}getSize(){const t={width:0,height:0};this.currentLine&&this.currentLine.addAble?t[this.directionKey.height]=this.currentLineY+this.currentLine[this.directionKey.height]:t[this.directionKey.height]=this.currentLineY;for(let e=0;e<this.lines.length;e++){const i=this.lines[e];t[this.directionKey.width]<i[this.directionKey.width]&&(t[this.directionKey.width]=i[this.directionKey.width])}return t}getContentSize(){const t={width:0,height:0},e={width:!0,height:!0};this.isRoot||this._heightObj||(e.height=!1,t.height=this.height),this.isRoot||this._widthObj||(e.width=!1,t.width=this.width);for(let i=0;i<this.lines.length;i++){const n=this.lines[i].getContentSize();e[this.directionKey.width]&&t[this.directionKey.width]<n[this.directionKey.width]&&(t[this.directionKey.width]=n[this.directionKey.width]),e[this.directionKey.height]&&(t[this.directionKey.height]+=n[this.directionKey.height])}return t}calcSize(t,e){this._heightObj&&(this.height=e*this._heightObj.percent/100+this._heightObj.delta,this.needCalcSize=!1,this.initLayoutSize()),this._widthObj&&(this.width=t*this._widthObj.percent/100+this._widthObj.delta,this.needCalcSize=!1,this.initLayoutSize())}getElements(t={parentX:0,parentY:0},e=!1,i=!1){this.currentLine&&this.currentLine.addAble&&(this.currentLine.addAble=!1,this.currentLineY+=this.currentLine[this.directionKey.height],this.currentLine.lineFinish()),this.updateYAlign();const n=[];if(this.background&&this.background.fill){const e=new xE({width:this.width,height:this.height,stroke:this.background.stroke??!1,fill:this.background.fill,cornerRadius:this.background.cornerRadius??0,lineWidth:this.background.lineWidth??1});e.x+=this.x+t.parentX,e.y+=this.y+t.parentY,n.push(e)}if(this.showBounds){const e=new xE({width:this.width,height:this.height,cornerRadius:0,stroke:"red",fill:"rgba(255, 0, 0, 0.2)",lineWidth:4});e.x+=this.x+t.parentX,e.y+=this.y+t.parentY,n.push(e)}for(let r=0;r<this.lines.length;r++){const o=this.lines[r];o[this.directionKey.y]+=this.offsetY;const s=o.getElements({[this.directionKey.parentX]:this.x+t.parentX,[this.directionKey.parentY]:this.y+t.parentY},e,i);n.push(...s)}return n}},GroupElement:class extends vE{type="group-element";direction;alignItems;width=0;height=0;children=[];directionKey;constructor(t){super(t),this.direction=t.direction||"row",this.alignItems=t.alignItems||"start",this.directionKey=wE[this.direction]}add(t){t.x=this.width,this.width+=t.layoutWidth,this.children.push(t),this.updateHeight(t),this.initLayoutSize()}updateHeight(t){t.layoutHeight>this.height&&(this.height=t.layoutHeight)}getOffsetY(t){switch(this.alignItems){case"start":default:return 0;case"center":return(this[this.directionKey.height]-t[this.directionKey.layoutHeight])/2;case"end":return this[this.directionKey.height]-t[this.directionKey.layoutHeight]}}getElements(t={parentX:0,parentY:0},e=!1,i=!1){const n=[];for(let r=0;r<this.children.length;r++){const o=this.children[r];"icon"===o.type&&("mouseenter_cell"===o.cache?.visibleTime&&!e||"click_cell"===o.cache?.visibleTime&&!i)||(o[this.directionKey.x]+=this[this.directionKey.dx]+this[this.directionKey.x]+t.parentX,o[this.directionKey.y]+=this.getOffsetY(o)+this[this.directionKey.dy]+this[this.directionKey.y]+t.parentY,n.push(o))}return n}},Icon:class extends vE{type="icon";svg;iconName;cursor;cache;constructor(t){if(super(t),this.iconName=t.iconName,f(this.iconName)){const t=kC()[this.iconName];t&&(this.cache=t,this.width=t.width,this.height=t.height,this.svg=t.svg,this.cursor=t.cursor)}this.width=t.width??this.width,this.height=t.height??this.height,this.svg=t.svg??this.svg,this.initLayoutSize()}},Image:class extends vE{type="image";src;cursor;cache;shape;constructor(t){super(t),this.width=t.width??this.width,this.height=t.height??this.height,this.src=t.src??this.src,this.shape=t.shape??this.shape,this.initLayoutSize()}},Rect:xE,Sector:class extends vE{type="arc";radius;startDegree=0;endDegree=360;clockWise=!0;lineWidth;fill;stroke;constructor(t){super(t),this.radius=t.radius,this.startDegree=t.startDegree,this.endDegree=t.endDegree,this.clockWise=t.clockWise,this.lineWidth=t.lineWidth,this.fill=t.fill,this.stroke=t.stroke,this.width=2*this.radius,this.height=2*this.radius,this.initLayoutSize(),this.dx+=this.radius,this.dy+=this.radius}},Text:class extends vE{type="text";text;fontSize;fontFamily;fill;textBaseline="top";textAlign="left";constructor(t){super(t),this.text=t.text,this.fontSize=t.fontSize||12,this.fontFamily=t.fontFamily||"sans-serif",this.fill=t.fill||"black"}getSize(t){const{width:e,height:i}=t.measureText(this.text,{fontSize:this.fontSize,fontFamily:this.fontFamily});this.width=e,this.height=i,this.initLayoutSize(),this.background&&(this.dx+=this.background.expandX||0,this.dy+=this.background.expandY||0)}},percentCalc:function(t,e=0){return{percent:t,delta:e}}});t.CustomLayout=_E,t.DataStatistics=VP,t.ListTable=class extends zP{showHeader=!0;constructor(t={}){super(t);const e=this.internalProps;this.pagerConf=t.pagerConf,e.sortState=t.sortState,e.columns=t.columns?v(t.columns):t.header?v(t.header):[],this.showHeader=t.showHeader??!0,this.transpose=t.transpose??!1,this.refreshHeader(),t.dataSource?AC(this,t.dataSource):t.records?this.setRecords(t.records,e.sortState):this.setRecords([])}isListTable(){return!0}isPivotTable(){return!1}isPivotChart(){return!1}get sortState(){return this.internalProps.sortState}set sortState(t){this.internalProps.sortState=t}get columns(){return this.internalProps.columns}set columns(t){this.internalProps.columns=t,this.options.columns=t,this.refreshHeader(),setTimeout((()=>{this.invalidate()}),0)}get header(){return this.internalProps.columns}set header(t){this.internalProps.columns=t,this.options.header=t,this.refreshHeader(),setTimeout((()=>{this.invalidate()}),0)}get transpose(){return this.internalProps.transpose??!1}set transpose(t){this.internalProps.transpose!==t&&(this.internalProps.transpose=t,this.options.transpose=t,this.internalProps.layoutMap&&(this.internalProps.layoutMap.transpose=t,this.refreshRowColCount(),this._resetFrozenColCount(),this.invalidate()))}getCellValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{caption:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}const{field:n,fieldFormat:r}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(r||n,t,e)}getCellOriginValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{caption:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}const{field:n}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(n,t,e)}getRecordIndexByRow(t,e){const{layoutMap:i}=this.internalProps;return i.getRecordIndexByRow(t,e)}getCellOriginRecord(t,e){const i=this,n=i.getRecordIndexByRow(t,e);if(n>-1)return i.dataSource.get(n)}_canResizeColumn(t,e){const i=super._canResizeColumn(t,e);if(i&&!this.transpose){const e=this.internalProps.layoutMap.getBody(t,this.columnHeaderLevelCount);if(e?.disableColumnResize)return!1}return i}updateOption(t,e=!1){const i=this.internalProps;return super.updateOption(t),this.pagerConf=t.pagerConf,this.showHeader=t.showHeader??!0,i.columns=t.columns?v(t.columns):t.header?v(t.header):[],this.transpose=t.transpose??!1,this.refreshHeader(),i.disposables&&(i.disposables.forEach((t=>t?.dispose?.())),i.disposables=null),this._updateSize(),t.dataSource?AC(this,t.dataSource):t.records?this.setRecords(t.records,t.sortState):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.invalidate()),new Promise((t=>{setTimeout(t,0)}))}refreshHeader(){const t=this,e=t.internalProps,i=t.transpose,n=t.showHeader;e.headerEvents&&e.headerEvents.forEach((e=>t.unlisten(e)));const r=e.layoutMap=new XP(this,e.columns??[],n,t.options.hierarchyIndent);if(r.transpose=i,!i)for(let e=0;e<r.columnWidths.length;e++){const{width:i,minWidth:n,maxWidth:o}=r.columnWidths?.[e]??{};i&&("string"==typeof i&&"auto"!==i||"number"==typeof i&&i>0)&&t.setColWidth(e,i),n&&("number"==typeof n&&n>0||"string"==typeof n)&&t.setMinColWidth(e,n),o&&("number"==typeof o&&o>0||"string"==typeof o)&&t.setMaxColWidth(e,o)}this.refreshRowColCount()}refreshRowColCount(){const t=this,{layoutMap:e}=t.internalProps;e&&(e.recordsCount=t.internalProps.dataSource?.length??0,t.transpose?(t.rowCount=e.rowCount??0,t.colCount=(t.internalProps.dataSource?.length??0)*e.bodyRowCount+e.headerLevelCount,t.frozenRowCount=0,t.frozenColCount=e.headerLevelCount):(t.colCount=e.colCount??0,t.rowCount=(t.internalProps.dataSource?.length??0)*e.bodyRowCount+e.headerLevelCount,t.frozenColCount=t.options.frozenColCount??0,t.frozenRowCount=e.headerLevelCount))}getFieldData(t,e,i){if(null===t)return null;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return null;const r=n.getRecordIndexByRow(e,i);return n.internalProps.dataSource.getField(r,t)}moveHeaderPosition(t,e){const i=this.internalProps.layoutMap.moveHeaderPosition(t,e);if(i){if("column"===i.moveType){if(this.colWidthsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize),!this.transpose){this.colWidthsLimit={};for(let t=0;t<this.internalProps.layoutMap.columnWidths.length;t++){const{minWidth:e,maxWidth:i}=this.internalProps.layoutMap.columnWidths?.[t]??{};e&&("number"==typeof e&&e>0||"string"==typeof e)&&this.setMinColWidth(t,e),i&&("number"==typeof i&&i>0||"string"==typeof i)&&this.setMaxColWidth(t,i)}}const t=Math.min(i.sourceIndex,i.targetIndex),e=Math.max(i.sourceIndex,i.targetIndex);for(let i=t;i<=e;i++)this._clearColRangeWidthsMap(i)}else{const t=Math.min(i.sourceIndex,i.targetIndex),e=Math.max(i.sourceIndex,i.targetIndex);for(let i=t;i<=e;i++)this._clearRowRangeHeightsMap(i)}return!0}return!1}getCellAddress(t,e){let i;for(let e=0;e<this.records.length;e++){const n=this.records[e];if("function"==typeof t)t(n)&&(i=e);else{let r=!0;for(const e in t)if(n[e]!==t[e]){r=!1;break}r&&(i=e)}if(A(i))break}const n=this.getCellRangeByField(e,i);if(n)return{row:n.start.row,col:n.start.col}}getCellRangeByField(t,e){const{layoutMap:i}=this.internalProps,n=i.columnObjects.find((e=>e.field===t));if(n){const t=i.getBodyLayoutRangeById(n.id);let r;return A(e)&&(r=i.getRecordStartRowByRecordIndex(e)),this.transpose?{start:{row:t.start.row,col:A(r)?r+t.start.col:void 0},end:{row:t.end.row,col:A(r)?r+t.end.col:void 0}}:{start:{col:t.start.col,row:A(r)?r+t.start.row:void 0},end:{col:t.end.col,row:A(r)?r+t.end.row:void 0}}}return null}getHierarchyState(t,e){if(!this.getBodyColumnDefine(t,e).tree)return r.none;const i=this.getRecordIndexByRow(t,e);return this.dataSource.getHierarchyState(i)}toggleHierarchyState(t,e){const i=this.getHierarchyState(t,e);i===r.expand?this.fireListeners(yt.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.collapse}):i===r.collapse&&this.fireListeners(yt.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.expand,originData:this.getCellOriginRecord(t,e)});const n=this.getRecordIndexByRow(t,e),o=this.dataSource.toggleHierarchyState(n),s=this.internalProps.layoutMap.toggleHierarchyState(o);this.refreshRowColCount(),this.clearCellStyleCache(),this.scenegraph.updateHierarchyIcon(t,e),this.scenegraph.updateRow(s.removeCellPositions,s.addCellPositions)}hasHierarchyTreeHeader(){return(this.options.columns??this.options.header)?.some(((t,e)=>t.tree))}getMenuInfo(t,e,i){return{field:this.getHeaderField(t,e),value:this.getCellValue(t,e),cellType:this.getCellType(t,e)}}_getSortFuncFromHeaderOption(t,e,i){if(t||(t=this.internalProps.columns),e&&t&&t.length>0)for(let n=0;n<t.length;n++){const r=t[n];if((i&&i===r.fieldKey||!i&&r.field===e)&&r.sort&&"function"==typeof r.sort)return r.sort;if(r.columns){const t=this._getSortFuncFromHeaderOption(r.columns,e,i);if(t)return t}}}updateSortState(t){if(t)this.internalProps.sortState=t;else if(this.internalProps.sortState)if(Array.isArray(this.internalProps.sortState))for(let t=0;t<this.internalProps.sortState.length;t++){this.internalProps.sortState[t].order="normal"}else this.internalProps.sortState.order="normal";let e,i,n;if(Array.isArray(this.internalProps.sortState)?({order:e,field:i,fieldKey:n}=this.internalProps.sortState?.[0]):({order:e,field:i,fieldKey:n}=this.internalProps.sortState),i){const t=this._getSortFuncFromHeaderOption(this.internalProps.columns,i,n);let r;r=n?this.internalProps.layoutMap.headerObjects.find((t=>t&&t.fieldKey===n)):this.internalProps.layoutMap.headerObjects.find((t=>t&&t.field===i)),r?.define?.sort&&(this.dataSource.sort(r.field,e,t),this.scenegraph.sortCell())}this.stateManeger.updateSortState(t)}},t.PivotChart=class extends zP{pivotSortState;dataset;_selectedDataItemsInChart=[];_selectedDimensionInChart=[];_chartEventMap={};_axes;constructor(t){if(super(t),t.layout&&Object.assign(t,t.layout),this.setCustomStateNameToSpec(),this.internalProps.dataConfig={isPivotChart:!0},this.internalProps.enableDataAnalysis=!0,this._axes=Ot(t.axes)?t.axes:[],this.internalProps.enableDataAnalysis&&(t.rows||t.columns)){const e=t.rows.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),i=t.columns.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),n=t.indicators?.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[])??[];this.internalProps.dataConfig.collectValuesBy=this._generateCollectValuesConfig(i,e),this.internalProps.dataConfig.aggregationRules=this._generateAggregationRules(),this.dataset=new bE(this.internalProps.dataConfig,e,i,n,t.records,t.columnTree,t.rowTree)}this.refreshHeader(),t.dataSource?AC(this,t.dataSource):t.records?this.setRecords(t.records,this.internalProps.sortState):this.setRecords([])}static get EVENT_TYPE(){return MR}get pivotChartAxes(){return this._axes}isListTable(){return!1}isPivotTable(){return!0}isPivotChart(){return!0}_canResizeColumn(t,e){const i=super._canResizeColumn(t,e);if(i&&!this.internalProps.layoutMap.indicatorsAsCol){const e=this.internalProps.layoutMap.getBody(t,this.columnHeaderLevelCount);if(e?.disableColumnResize)return!1}return i}updateOption(t,e=!1){const i=this.internalProps;if(super.updateOption(t),this.setCustomStateNameToSpec(),i.dataConfig={},this.internalProps.enableDataAnalysis=!0,this.internalProps.enableDataAnalysis&&(t.rows||t.columns)){const e=t.rows.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),i=t.columns.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),n=t.indicators.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[]);this.internalProps.dataConfig.collectValuesBy=this._generateCollectValuesConfig(i,e),this.internalProps.dataConfig.aggregationRules=this._generateAggregationRules(),this.dataset=new bE(this.internalProps.dataConfig,e,i,n,t.records??this.internalProps.records,t.columnTree,t.rowTree)}return this.refreshHeader(),i.disposables&&(i.disposables.forEach((t=>t?.dispose?.())),i.disposables=null),this._updateSize(),t.dataSource?AC(this,t.dataSource):t.records?this.setRecords(t.records,void 0):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.invalidate()),new Promise((t=>{setTimeout(t,0)}))}refreshHeader(){const t=this.internalProps;t.headerEvents&&t.headerEvents.forEach((t=>this.unlisten(t))),this.internalProps.enableDataAnalysis&&(t.layoutMap=new tE(this,this.dataset));for(let e=0;e<t.layoutMap.columnWidths.length;e++){const{width:i,minWidth:n,maxWidth:r}=t.layoutMap.columnWidths?.[e]??{};i&&("string"==typeof i&&"auto"!==i||"number"==typeof i&&i>0)&&this.setColWidth(e,i),n&&("number"==typeof n&&n>0||"string"==typeof n)&&this.setMinColWidth(e,n),r&&("number"==typeof r&&r>0||"string"==typeof r)&&this.setMaxColWidth(e,r)}this.refreshRowColCount()}refreshRowColCount(){const t=this,{layoutMap:e}=t.internalProps;e&&(t.colCount=e.colCount??0,t.rowCount=e.rowCount??0,t.frozenColCount=e.rowHeaderLevelCount,t.frozenRowCount=e.headerLevelCount,t.bottomFrozenRowCount=e?.bottomFrozenRowCount??0,t.rightFrozenColCount=e?.rightFrozenColCount??0)}_getSortFuncFromHeaderOption(t,e,i){}syncHierarchyState(t,e){t.value===e.value&&t.dimensionKey===e.dimensionKey&&(e.hierarchyState=e.hierarchyState??(e?.children?t.hierarchyState:void 0),e?.children?.forEach(((e,i)=>{t?.children?.[i]&&e&&this.syncHierarchyState(t.children[i],e)})))}getRecordIndexByRow(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByRow(t)}getRecordIndexByCol(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByCol(t)}getFieldData(t,e,i){if(null==t)return null;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return null;const r=this.getRecordIndexByRow(i),o=this.getRecordIndexByCol(e),s=n.dataSource?.getField(r,o);if("string"!=typeof t){return Mw({dataValue:s,...n.internalProps.layoutMap.getCellHeaderPaths(e,i)},t,gt)}return s}getCellValue(t,e){if(this.internalProps.layoutMap.isHeader(t,e)){const{caption:i,fieldFormat:n}=this.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n(i):i}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.value?r.value():void 0}const{field:i,fieldFormat:n}=this.internalProps.layoutMap.getBody(t,e);return this.getFieldData(n||i,t,e)}getCellOriginValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{caption:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.value?r.value():void 0}const{field:n}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(n,t,e)}getCellOriginRecord(t,e){if(!this.internalProps.layoutMap.isHeader(t,e)&&this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[];return this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e)).records}}updateSortRules(t){this.internalProps.dataConfig.sortRules=t,this.dataset.updateSortRules(t),this.internalProps.layoutMap.updateDataset(this.dataset),this.invalidate()}updatePivotSortState(t){for(let e=0;e<t.length;e++){const{dimensions:i,order:n}=t[e],r=this.internalProps.layoutMap.getPivotCellAdress(i);r&&this.pivotSortState.push({col:r.col,row:r.row,order:n})}}getPivotSortState(t,e){if(!this.pivotSortState)return;const i=this.getCellRange(t,e);for(let t=0;t<this.pivotSortState.length;t++){const{col:e,row:n,order:r}=this.pivotSortState[t];if(at(i,e,n))return r}}moveHeaderPosition(t,e){const i=this.internalProps.layoutMap.moveHeaderPosition(t,e);if(i){if("column"===i.moveType){if(this.options.records?.[0]?.constructor===Array)for(let t=0;t<this.records.length;t++){const e=this.records[t].splice(i.sourceIndex-this.rowHeaderLevelCount,i.moveSize);e.unshift(i.targetIndex-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this.records[t],e)}this.colWidthsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize);for(let t=0;t<this.internalProps.layoutMap.columnWidths.length;t++){const{minWidth:e,maxWidth:i}=this.internalProps.layoutMap.columnWidths?.[t]??{};e&&("number"==typeof e&&e>0||"string"==typeof e)&&this.setMinColWidth(t,e),i&&("number"==typeof i&&i>0||"string"==typeof i)&&this.setMaxColWidth(t,i)}}else if("row"===i.moveType){if(this.options.records?.[0]?.constructor===Array){const t=this.records.splice(i.sourceIndex-this.columnHeaderLevelCount,i.moveSize);t.unshift(i.targetIndex-this.columnHeaderLevelCount,0),Array.prototype.splice.apply(this.records,t)}this.rowHeightsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize)}return!0}return!1}toggleHierarchyState(t,e){const i=this.getHierarchyState(t,e);i===r.expand?this.fireListeners(MR.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.collapse}):i===r.collapse&&this.fireListeners(MR.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.expand,originData:this.getCellOriginRecord(t,e)});const n=this.internalProps.layoutMap.toggleHierarchyState(t,e);this.refreshRowColCount(),this.clearCellStyleCache(),this.scenegraph.updateHierarchyIcon(t,e),this.scenegraph.updateRow(n.removeCellPositions,n.addCellPositions)}getHeaderCellAddressByPath(t){return this.internalProps.layoutMap.getPivotCellAdress(t)}getCellAddressByHeaderPaths(t){return this.internalProps.layoutMap.getCellAdressByHeaderPath(t)}getHeaderPathByXY(t){let e;e=t?this.getCellAt(t.x+this.getFrozenColsWidth()+this.scrollLeft+1,t.y+this.getFrozenRowsHeight()+this.scrollTop+1):this.getCellAt(this.getFrozenColsWidth()+this.scrollLeft+1,this.getFrozenRowsHeight()+this.scrollTop+1);return this.internalProps.layoutMap.getCellHeaderPaths(e.col,e.row)}getHierarchyState(t,e){return this._getHeaderLayoutMap(t,e)?.hierarchyState}hasHierarchyTreeHeader(){return"tree"===this.internalProps.layoutMap.rowHierarchyType}getMenuInfo(t,e,i){const n=this.internalProps.layoutMap.getPivotDimensionInfo(t,e);return{dimensionKey:n[n.length-1].dimensionKey,value:this.getCellValue(t,e),cellType:this.getCellType(t,e),isPivotCorner:this.isCornerHeader(t,e)}}_generateCollectValuesConfig(t,e){const i=this.options,n={};for(let r=0,o=i.indicators.length;r<o;r++)if("string"!=typeof i.indicators[r]&&i.indicators[r].chartSpec)if(!1===i.indicatorsAsCol){const o=i.indicators[r];if(n[o.indicatorKey]={by:e,range:!0,sumBy:!1!==o.chartSpec?.stack&&t.concat(o.chartSpec?.xField)},o.chartSpec.series)o.chartSpec.series.forEach((i=>{const r="string"==typeof i.xField?i.xField:i.xField[0];n[r]={by:t,type:"horizontal"!==i.direction?"xField":void 0,range:"horizontal"===i.direction};const o=i.yField;n[o]={by:e,range:"horizontal"!==i.direction,sumBy:!1!==i.stack&&t.concat(r)}}));else{const s="string"==typeof o.chartSpec.xField?o.chartSpec.xField:o.chartSpec.xField[0];n[s]={by:t,type:"horizontal"!==o.chartSpec.direction?"xField":void 0,range:"horizontal"===o.chartSpec.direction};const a=o.chartSpec.yField;n[a]={by:e,range:"horizontal"!==i.indicators[r].chartSpec.direction,sumBy:!1!==o.chartSpec.stack&&t.concat(s)}}}else{const o=i.indicators[r];if(n[o.indicatorKey]={by:t,range:!0,sumBy:!1!==o.chartSpec?.stack&&e.concat(o.chartSpec?.yField)},o.chartSpec.series)o.chartSpec.series.forEach((i=>{const r="string"==typeof i.yField?i.yField:i.yField[0];n[r]={by:e,type:"horizontal"===i.direction?"yField":void 0,range:"horizontal"!==i.direction};const o=i.xField;n[o]={by:t,range:"horizontal"===i.direction,sumBy:!1!==i.stack&&e.concat(r)}}));else{const s="string"==typeof o.chartSpec.yField?o.chartSpec.yField:o.chartSpec.yField[0];n[s]={by:e,type:"horizontal"===o.chartSpec.direction?"yField":void 0,range:"horizontal"!==o.chartSpec.direction};const a=o.chartSpec.xField;n[a]={by:t,range:"horizontal"===i.indicators[r].chartSpec.direction,sumBy:!1!==o.chartSpec.stack&&e.concat(s)}}}return n}_generateAggregationRules(){const t=[];return this.options.indicators.forEach((e=>{if("string"==typeof e)t.push({indicatorKey:e,field:e,aggregationType:o.RECORD});else if(e.chartSpec?.series){const i=[];e.chartSpec?.series.forEach((t=>{const e=!1===this.options.indicatorsAsCol?t.yField:t.xField;-1===i.indexOf(e)&&i.push(e)})),t.push({indicatorKey:e.indicatorKey,field:i,aggregationType:o.RECORD})}else t.push({indicatorKey:e.indicatorKey,field:e.indicatorKey,aggregationType:o.RECORD})})),t}setCustomStateNameToSpec(){const t=t=>{t.bar?.state?.selected&&(t.bar.state.vtable_selected=t.bar.state.selected,t.bar.state.vtable_selected_reverse=t.bar.state.selected_reverse,delete t.bar.state.selected,delete t.bar.state.selected_reverse),t.point?.state?.selected&&(t.point.state.vtable_selected=t.point.state.selected,t.point.state.vtable_selected_reverse=t.point.state.selected_reverse,delete t.point.state.selected,delete t.point.state.selected_reverse),t.line?.state?.selected&&(t.line.state.vtable_selected=t.line.state.selected,t.line.state.vtable_selected_reverse=t.line.state.selected_reverse,delete t.line.state.selected,delete t.line.state.selected_reverse),t.area?.state?.selected&&(t.area.state.vtable_selected=t.area.state.selected,t.area.state.vtable_selected_reverse=t.area.state.selected_reverse,delete t.area.state.selected,delete t.area.state.selected_reverse)};this.options.indicators.forEach((e=>{if(e.chartSpec){const i=e.chartSpec;i.series?i.series.forEach((e=>{t(e)})):t(i)}}))}_getActiveChartInstance(){const t=this.scenegraph.getCell(this.stateManeger.hover?.cellPos?.col,this.stateManeger.hover?.cellPos?.row);return"chart"===t?.getChildren()?.[0]?.type?t.getChildren()[0].activeChartInstance:null}listenChart(t,e){this._chartEventMap[t]=e}unlistenChart(t){delete this._chartEventMap[t]}_bindChartEvent(t){if(t)for(const e in this._chartEventMap)t.on(e,this._chartEventMap[e])}updateFilterRules(t){this.internalProps.dataConfig.filterRules=t,this.dataset.updateFilterRules(t),dR(this.scenegraph),function(t){for(let e=t.proxy.colStart;e<=t.proxy.colEnd;e++)t.getColGroup(e).getChildren().forEach((e=>{const i=e.col,n=e.row;e.children.forEach((e=>{"chart"===e.type&&(e.updateData(t.table.getCellValue(i,n)),e.addUpdateBoundTag())}))}))}(this.scenegraph),this.invalidate()}setLegendSelected(t){this.internalProps.legends.legendComponent.setSelected(t)}getChartDatumPosition(t,e){const i=this.getCellAddressByHeaderPaths(e),n=this.getCellRelativeRect(i.col,i.row);console.log(n);const r=this.scenegraph.getCell(i.col,i.row);let o;const s=r?.getChildren()?.[0];if(s.attribute.chartInstance){const e=s.attribute.chartInstance,{dataId:i,data:n,viewBox:r,axes:a}=s.attribute;a.forEach(((t,i)=>{if("linear"===t.type){e._chart._components[i]._domain={min:t.range?.min??0,max:t.range?.max??0}}else if("band"===t.type){const n=e._chart._components[i];n._spec.domain=t.domain.slice(0),n.updateScaleDomain()}})),e.updateViewBox({x1:r.x1-s.getRootNode().table.scrollLeft,x2:r.x2-s.getRootNode().table.scrollLeft,y1:r.y1-s.getRootNode().table.scrollTop,y2:r.y2-s.getRootNode().table.scrollTop}),e.updateDataSync(i,n),o=e.convertDatumToPosition(t),this.invalidate()}return o?{x:Math.round(o.x+n.bounds.x1),y:Math.round(o.y+n.bounds.y1)}:null}},t.PivotTable=class extends zP{pivotSortState;dataset;flatDataToObjects;constructor(t){if(super(t),t.layout&&Object.assign(t,t.layout),this.internalProps.dataConfig=t.dataConfig,this.internalProps.enableDataAnalysis=t.enableDataAnalysis,this.internalProps.enableDataAnalysis&&(t.rows||t.columns)){const e=t.rows.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),i=t.columns.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),n=t.indicators?.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[])??[];this.dataset=new bE(this.internalProps.dataConfig,e,i,n,t.records)}this.refreshHeader(),this.pivotSortState=[],t.pivotSortState&&this.updatePivotSortState(t.pivotSortState),t.dataSource?AC(this,t.dataSource):t.records?this.setRecords(t.records,this.internalProps.sortState):this.setRecords([])}static get EVENT_TYPE(){return BR}isListTable(){return!1}isPivotTable(){return!0}isPivotChart(){return!1}_canResizeColumn(t,e){const i=super._canResizeColumn(t,e);if(i&&!this.internalProps.layoutMap.indicatorsAsCol){const e=this.internalProps.layoutMap.getBody(t,this.columnHeaderLevelCount);if(e?.disableColumnResize)return!1}return i}updateOption(t,e=!1){const i=this.internalProps;if(super.updateOption(t),i.dataConfig=t.dataConfig,i.enableDataAnalysis=t.enableDataAnalysis,"tree"===t?.rowHierarchyType&&"tree"===this.internalProps.layoutMap.rowHierarchyType&&this.internalProps.layoutMap.rowExpandLevel===t?.rowExpandLevel){const t=this.internalProps.layoutMap.rowDimensionTree.tree.children;this.internalProps.layoutMap.rowTree.forEach(((e,i)=>{this.syncHierarchyState(t[i],e)}))}if(this.internalProps.enableDataAnalysis&&(t.rows||t.columns)){const e=t.rows.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),n=t.columns.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),r=t.indicators.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[]);this.dataset=new bE(i.dataConfig,e,n,r,t.records)}return this.refreshHeader(),i.disposables&&(i.disposables.forEach((t=>t?.dispose?.())),i.disposables=null),this._updateSize(),t.dataSource?AC(this,t.dataSource):t.records?this.setRecords(t.records,void 0):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.invalidate()),this.pivotSortState=[],t.pivotSortState&&this.updatePivotSortState(t.pivotSortState),new Promise((t=>{setTimeout(t,0)}))}refreshHeader(){const t=this.internalProps;t.headerEvents&&t.headerEvents.forEach((t=>this.unlisten(t)));const e=this.options.records??this.internalProps.records;this.options.enableDataAnalysis?t.layoutMap=new tE(this,this.dataset):(Array.isArray(this.options.columnTree)||Array.isArray(this.options.rowTree))&&(t.layoutMap=new JP(this),e?.[0]?.constructor!==Array&&(this.flatDataToObjects=new eE({rows:t.layoutMap.rowDimensionKeys,columns:t.layoutMap.colDimensionKeys,indicators:t.layoutMap.indicatorKeys,indicatorsAsCol:t.layoutMap.indicatorsAsCol,indicatorDimensionKey:t.layoutMap.indicatorDimensionKey},e)));for(let e=0;e<t.layoutMap.columnWidths.length;e++){const{width:i,minWidth:n,maxWidth:r}=t.layoutMap.columnWidths?.[e]??{};i&&("string"==typeof i&&"auto"!==i||"number"==typeof i&&i>0)&&this.setColWidth(e,i),n&&("number"==typeof n&&n>0||"string"==typeof n)&&this.setMinColWidth(e,n),r&&("number"==typeof r&&r>0||"string"==typeof r)&&this.setMaxColWidth(e,r)}this.refreshRowColCount()}refreshRowColCount(){const t=this,{layoutMap:e}=t.internalProps;e&&(t.colCount=e.colCount??0,t.rowCount=e.rowCount??0,t.frozenColCount=e.rowHeaderLevelCount,t.frozenRowCount=e.headerLevelCount,t.bottomFrozenRowCount=e?.bottomFrozenRowCount??0,t.rightFrozenColCount=e?.rightFrozenColCount??0)}_getSortFuncFromHeaderOption(t,e,i){}get rowHierarchyType(){return this.internalProps.layoutMap.rowHierarchyType}syncHierarchyState(t,e){t.value===e.value&&t.dimensionKey===e.dimensionKey&&(e.hierarchyState=e.hierarchyState??(e?.children?t.hierarchyState:void 0),e?.children?.forEach(((e,i)=>{t?.children?.[i]&&e&&this.syncHierarchyState(t.children[i],e)})))}getRecordIndexByRow(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByRow(t)}getRecordIndexByCol(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByCol(t)}getFieldData(t,e,i){if(null==t)return null;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return null;const r=this.getRecordIndexByRow(i),o=this.getRecordIndexByCol(e),s=n.dataSource?.getField(r,o);if("string"!=typeof t){return Mw({dataValue:s,...n.internalProps.layoutMap.getCellHeaderPaths(e,i)},t,gt)}return s}getCellValue(t,e){if(this.internalProps.layoutMap.isHeader(t,e)){const{caption:i,fieldFormat:n}=this.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n(i):i}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.formatValue?r.formatValue():""}if(this.flatDataToObjects){const i=this.internalProps.layoutMap.getCellHeaderPaths(t,e),n=i.colHeaderPaths.map((t=>t.indicatorKey??t.value)),r=i.rowHeaderPaths.map((t=>t.indicatorKey??t.value)),o=this.flatDataToObjects.getTreeNode(r,n,this.internalProps.layoutMap.getBody(t,e).indicatorKey),{fieldFormat:s}=this.internalProps.layoutMap.getBody(t,e);return"function"==typeof s?s(o?.record):o?.value??""}const{field:i,fieldFormat:n}=this.internalProps.layoutMap.getBody(t,e);return this.getFieldData(n||i,t,e)}getCellOriginValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{caption:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.value?r.value():void 0}if(this.flatDataToObjects){const i=this.internalProps.layoutMap.getCellHeaderPaths(t,e),n=i.colHeaderPaths.map((t=>t.indicatorKey??t.value)),r=i.rowHeaderPaths.map((t=>t.indicatorKey??t.value)),o=this.flatDataToObjects.getTreeNode(r,n,this.internalProps.layoutMap.getBody(t,e).indicatorKey);return o?.value}const{field:n}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(n,t,e)}getCellOriginRecord(t,e){if(!this.internalProps.layoutMap.isHeader(t,e)){if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[];return this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e)).records}if(this.flatDataToObjects){const i=this.internalProps.layoutMap.getCellHeaderPaths(t,e),n=i.colHeaderPaths.map((t=>t.indicatorKey??t.value)),r=i.rowHeaderPaths.map((t=>t.indicatorKey??t.value)),o=this.flatDataToObjects.getTreeNode(r,n,this.internalProps.layoutMap.getBody(t,e).indicatorKey);return o?.record}}}updateSortRules(t){this.internalProps.dataConfig.sortRules=t,this.dataset.updateSortRules(t),this.internalProps.layoutMap.updateDataset(this.dataset),this.invalidate()}updatePivotSortState(t){for(let e=0;e<t.length;e++){const{dimensions:i,order:n}=t[e],r=this.internalProps.layoutMap.getPivotCellAdress(i);r&&this.pivotSortState.push({col:r.col,row:r.row,order:n})}}getPivotSortState(t,e){if(!this.pivotSortState)return;const i=this.getCellRange(t,e);for(let t=0;t<this.pivotSortState.length;t++){const{col:e,row:n,order:r}=this.pivotSortState[t];if(at(i,e,n))return r}}moveHeaderPosition(t,e){const i=this.internalProps.layoutMap.moveHeaderPosition(t,e);if(i){if("column"===i.moveType){if(this.options.records?.[0]?.constructor===Array)for(let t=0;t<this.records.length;t++){const e=this.records[t].splice(i.sourceIndex-this.rowHeaderLevelCount,i.moveSize);e.unshift(i.targetIndex-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this.records[t],e)}this.colWidthsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize);for(let t=0;t<this.internalProps.layoutMap.columnWidths.length;t++){const{minWidth:e,maxWidth:i}=this.internalProps.layoutMap.columnWidths?.[t]??{};e&&("number"==typeof e&&e>0||"string"==typeof e)&&this.setMinColWidth(t,e),i&&("number"==typeof i&&i>0||"string"==typeof i)&&this.setMaxColWidth(t,i)}}else if("row"===i.moveType){if(this.options.records?.[0]?.constructor===Array){const t=this.records.splice(i.sourceIndex-this.columnHeaderLevelCount,i.moveSize);t.unshift(i.targetIndex-this.columnHeaderLevelCount,0),Array.prototype.splice.apply(this.records,t)}this.rowHeightsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize)}return!0}return!1}toggleHierarchyState(t,e){const i=this.getHierarchyState(t,e);i===r.expand?this.fireListeners(BR.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.collapse}):i===r.collapse&&this.fireListeners(BR.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.expand,originData:this.getCellOriginRecord(t,e)});const n=this.internalProps.layoutMap.toggleHierarchyState(t,e);this.refreshRowColCount(),this.clearCellStyleCache(),this.scenegraph.updateHierarchyIcon(t,e),this.scenegraph.updateRow(n.removeCellPositions,n.addCellPositions)}getHeaderCellAddressByPath(t){return this.internalProps.layoutMap.getPivotCellAdress(t)}getCellAddressByHeaderPaths(t){return this.internalProps.layoutMap.getCellAdressByHeaderPath(t)}getHeaderPathByXY(t){let e;e=t?this.getCellAt(t.x+this.getFrozenColsWidth()+this.scrollLeft+1,t.y+this.getFrozenRowsHeight()+this.scrollTop+1):this.getCellAt(this.getFrozenColsWidth()+this.scrollLeft+1,this.getFrozenRowsHeight()+this.scrollTop+1);return this.internalProps.layoutMap.getCellHeaderPaths(e.col,e.row)}getHierarchyState(t,e){return this._getHeaderLayoutMap(t,e)?.hierarchyState}hasHierarchyTreeHeader(){return"tree"===this.internalProps.layoutMap.rowHierarchyType}getMenuInfo(t,e,i){const n=this.internalProps.layoutMap.getPivotDimensionInfo(t,e);return{dimensionKey:n[n.length-1].dimensionKey,value:this.getCellValue(t,e),cellType:this.getCellType(t,e),isPivotCorner:this.isCornerHeader(t,e)}}},t.TYPES=c,t.clearGlobal=function(){KP()},t.core=jP,t.data=Hw,t.getIcons=function(){return kC()},t.register=UP,t.themes=ti,t.version="0.9.2-alpha.1"}));
|
|
17
|
+
read:function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1<<a)-1,h=l>>1,c=-7,d=i?r-1:0,u=i?-1:1,p=t[e+d];for(d+=u,o=p&(1<<-c)-1,p>>=-c,c+=a;c>0;o=256*o+t[e+d],d+=u,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+t[e+d],d+=u,c-=8);if(0===o)o=1-h;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=h}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,i,n,r,o){var s,a,l,h=8*o-r-1,c=(1<<h)-1,d=c>>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+d>=1?u/l:u*Math.pow(2,1-d))*l>=2&&(s++,l/=2),s+d>=c?(a=0,s=c):s+d>=1?(a=(e*l-1)*Math.pow(2,r),s+=d):(a=e*Math.pow(2,d-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s<<r|a,h+=r;h>0;t[i+p]=255&s,p+=f,s/=256,h-=8);t[i+p-f]|=128*g}},eM=tM;function iM(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}iM.Varint=0,iM.Fixed64=1,iM.Bytes=2,iM.Fixed32=5;var nM=4294967296,rM=1/nM,oM="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function sM(t){return t.type===iM.Bytes?t.readVarint()+t.pos:t.pos+1}function aM(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function lM(t,e,i){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(n);for(var r=i.pos-1;r>=t;r--)i.buf[r+n]=i.buf[r]}function hM(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function cM(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function dM(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function uM(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function pM(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function fM(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function gM(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function yM(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function mM(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function bM(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function vM(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function wM(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}iM.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){var n=this.readVarint(),r=n>>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=bM(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=wM(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=bM(this.buf,this.pos)+bM(this.buf,this.pos+4)*nM;return this.pos+=8,t},readSFixed64:function(){var t=bM(this.buf,this.pos)+wM(this.buf,this.pos+4)*nM;return this.pos+=8,t},readFloat:function(){var t=eM.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=eM.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i<128?e:(e|=(127&(i=n[this.pos++]))<<7,i<128?e:(e|=(127&(i=n[this.pos++]))<<14,i<128?e:(e|=(127&(i=n[this.pos++]))<<21,i<128?e:function(t,e,i){var n,r,o=i.buf;if(r=o[i.pos++],n=(112&r)>>4,r<128)return aM(t,n,e);if(r=o[i.pos++],n|=(127&r)<<3,r<128)return aM(t,n,e);if(r=o[i.pos++],n|=(127&r)<<10,r<128)return aM(t,n,e);if(r=o[i.pos++],n|=(127&r)<<17,r<128)return aM(t,n,e);if(r=o[i.pos++],n|=(127&r)<<24,r<128)return aM(t,n,e);if(r=o[i.pos++],n|=(1&r)<<31,r<128)return aM(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&oM?function(t,e,i){return oM.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){var n="",r=e;for(;r<i;){var o,s,a,l=t[r],h=null,c=l>239?4:l>223?3:l>191?2:1;if(r+c>i)break;1===c?l<128&&(h=l):2===c?128==(192&(o=t[r+1]))&&(h=(31&l)<<6|63&o)<=127&&(h=null):3===c?(o=t[r+1],s=t[r+2],128==(192&o)&&128==(192&s)&&((h=(15&l)<<12|(63&o)<<6|63&s)<=2047||h>=55296&&h<=57343)&&(h=null)):4===c&&(o=t[r+1],s=t[r+2],a=t[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&((h=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||h>=1114112)&&(h=null)),null===h?(h=65533,c=1):h>65535&&(h-=65536,n+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),n+=String.fromCharCode(h),r+=c}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==iM.Bytes)return t.push(this.readVarint(e));var i=sM(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==iM.Bytes)return t.push(this.readSVarint());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==iM.Bytes)return t.push(this.readBoolean());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==iM.Bytes)return t.push(this.readFloat());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==iM.Bytes)return t.push(this.readDouble());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==iM.Bytes)return t.push(this.readFixed32());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==iM.Bytes)return t.push(this.readSFixed32());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==iM.Bytes)return t.push(this.readFixed64());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==iM.Bytes)return t.push(this.readSFixed64());var e=sM(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===iM.Varint)for(;this.buf[this.pos++]>127;);else if(e===iM.Bytes)this.pos=this.readVarint()+this.pos;else if(e===iM.Fixed32)this.pos+=4;else{if(e!==iM.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),vM(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),vM(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),vM(this.buf,-1&t,this.pos),vM(this.buf,Math.floor(t*rM),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),vM(this.buf,-1&t,this.pos),vM(this.buf,Math.floor(t*rM),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var i,n;t>=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0));if(t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos]=127&t}(i,0,e),function(t,e){var i=(7&t)<<4;if(e.buf[e.pos++]|=i|((t>>>=3)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;e.buf[e.pos++]=127&t}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var n,r,o=0;o<e.length;o++){if((n=e.charCodeAt(o))>55295&&n<57344){if(!r){n>56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n<56320){t[i++]=239,t[i++]=191,t[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(t[i++]=239,t[i++]=191,t[i++]=189,r=null);n<128?t[i++]=n:(n<2048?t[i++]=n>>6|192:(n<65536?t[i++]=n>>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&lM(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),eM.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),eM.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var n=this.pos-i;n>=128&&lM(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,iM.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,hM,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,cM,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,pM,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,dM,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,uM,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,fM,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,gM,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,yM,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,mM,e)},writeBytesField:function(t,e){this.writeTag(t,iM.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,iM.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,iM.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,iM.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,iM.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,iM.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,iM.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,iM.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,iM.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,iM.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},function(t,e){let i,n,r=3,o=4.5;function s(t){return t&&("function"==typeof o&&n.pointRadius(+o.apply(this,arguments)),TA(t,i(n))),n.result()}s.area=function(t){return TA(t,i(pT)),pT.result()},s.measure=function(t){return TA(t,i(tB)),tB.result()},s.bounds=function(t){return TA(t,i(_T)),_T.result()},s.centroid=function(t){return TA(t,i(GT)),GT.result()},s.projection=function(e){return arguments.length?(i=null==e?(t=null,oT):(t=e).stream,s):t},s.context=function(t){return arguments.length?(n=null==t?(e=null,new oB(r)):new KT(e=t),"function"!=typeof o&&n.pointRadius(o),s):e},s.pointRadius=function(t){return arguments.length?(o="function"==typeof t?t:(n.pointRadius(+t),+t),s):o},s.digits=function(t){if(!arguments.length)return r;if(null==t)r=null;else{const e=Math.floor(t);if(!(e>=0))throw new RangeError(`invalid digits: ${t}`);r=e}return null===e&&(n=new oB(r)),s},s.projection(t).digits(r).context(e)}();let CM=0;function xM(){return CM>1e8&&(CM=0),(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"dataset")+"_"+CM++}class _M{constructor(t){let e;this.options=t,this.isDataSet=!0,this.transformMap={},this.parserMap={},this.dataViewMap={},this.target=new Rt,this._callMap=new Map,e=(null==t?void 0:t.name)?t.name:xM("dataset"),this.name=e}getDataView(t){return this.dataViewMap[t]}setDataView(t,e){if(this.dataViewMap[t])throw new Error(`Error: dataView ${t} 之前已存在,请重新命名`);this.dataViewMap[t]=e}removeDataView(t){this.dataViewMap[t]=null,delete this.dataViewMap[t]}registerParser(t,e){this.parserMap[t]&&console.warn(`Warn: transform ${t} 之前已注册,执行覆盖逻辑`),this.parserMap[t]=e}removeParser(t){this.parserMap[t]=null,delete this.parserMap[t]}getParser(t){return this.parserMap[t]||this.parserMap.default}registerTransform(t,e){this.transformMap[t]&&console.warn(`Warn: transform ${t} 之前已注册,执行覆盖逻辑`),this.transformMap[t]=e}removeTransform(t){this.transformMap[t]=null,delete this.transformMap[t]}getTransform(t){return this.transformMap[t]}multipleDataViewAddListener(t,e,i){let n=this._callMap.get(i);n||(n=()=>{t.some((t=>t.isRunning))||i()}),t.forEach((t=>{t.target.addListener(e,n)})),this._callMap.set(i,n)}multipleDataViewRemoveListener(t,e,i){const n=this._callMap.get(i);n&&t.forEach((t=>{t.target.removeListener(e,n)})),this._callMap.delete(i)}destroy(){this.transformMap=null,this.parserMap=null,this.dataViewMap=null,this._callMap=null,this.target.removeAllListeners()}}const SM="_data-view-diff-rank";class AM{constructor(t,e){var i=this;let n;this.dataSet=t,this.options=e,this.isDataView=!0,this.target=new Rt,this.parseOption=null,this.transformsArr=[],this.isRunning=!1,this.rawData={},this.history=!1,this.historyData=[],this.parserData={},this.latestData={},this._fields=null,this._diffData=!1,this._diffKeys=null,this._diffMap=new Map,this._diffRank=0,this.reRunAllTransform=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{pushHistory:!0,emitMessage:!0};return i.isRunning=!0,i.resetTransformData(),i.transformsArr.forEach((e=>{i.executeTransform(e,Object.assign(Object.assign({},t),{emitMessage:!1})),i.isLastTransform(e)&&i.diffLastData()})),i.isRunning=!1,!1!==(null==t?void 0:t.emitMessage)&&i.target.emit("change",[]),i},this.markRunning=()=>{this.isRunning=!0,this.target.emit("markRunning",[])},n=(null==e?void 0:e.name)?e.name:xM("dataview"),this.name=n,(null==e?void 0:e.history)&&(this.history=e.history),this.dataSet.setDataView(n,this),(null==e?void 0:e.fields)&&(this.dataSet.registerTransform("fields",QB),this.transform({type:"fields",options:{fields:e.fields}},!1))}parse(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.isRunning=!0,i&&this.target.emit("beforeParse",[]);const n=this.cloneParseData(t,e);if(e){this.parseOption=e,e=jr(e);const t=this.dataSet.getParser(e.type||"bytejson")(n,e.options,this);this.rawData=n,this.parserData=t,this.history&&this.historyData.push(n,t),this.latestData=t}else this.parserData=n,this.rawData=n,this.history&&this.historyData.push(n),this.latestData=n;return this.isRunning=!1,i&&this.target.emit("afterParse",[]),this}transform(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.isRunning=!0,t&&t.type){if("fields"===t.type){this._fields=t.options.fields;const e=this.transformsArr.findIndex((e=>e.type===t.type));e>=0&&this.transformsArr.splice(e,1)}if(this.transformsArr.push(t),e){const e=this.isLastTransform(t);t=jr(t),this.executeTransform(t),e&&this.diffLastData()}}return this.sortTransform(),this.isRunning=!1,this}isLastTransform(t){return this.transformsArr[this.transformsArr.length-1]===t}sortTransform(){this.transformsArr.sort(((t,e)=>{var i,n;return(null!==(i=t.level)&&void 0!==i?i:0)-(null!==(n=e.level)&&void 0!==n?n:0)}))}executeTransform(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{pushHistory:!0,emitMessage:!0};const{pushHistory:i,emitMessage:n}=e,r=this.dataSet.getTransform(t.type)(this.latestData,t.options);this.history&&!1!==i&&this.historyData.push(r),this.latestData=r,!1!==n&&this.target.emit("change",[])}resetTransformData(){this.latestData=this.parserData,this.history&&(this.historyData.length=0,this.historyData.push(this.rawData,this.parserData))}enableDiff(t){this._diffData=!0,this._diffKeys=t}disableDiff(){this._diffData=!1,this.resetDiff()}resetDiff(){this._diffMap=new Map,this._diffRank=0}diffLastData(){var t;if(!this._diffData)return;if(!this.latestData.forEach)return;if(!(null===(t=this._diffKeys)||void 0===t?void 0:t.length))return;const e=this._diffRank+1;if(0===this._diffRank)this.latestData.forEach((t=>{t[SM]=e,this._diffMap.set(this._diffKeys.reduce(((e,i)=>e+t[i]),""),t)})),this.latestDataAUD={add:Array.from(this.latestData),del:[],update:[]};else{let t;this.latestDataAUD={add:[],del:[],update:[]},this.latestData.forEach((i=>{i[SM]=e,t=this._diffKeys.reduce(((t,e)=>t+i[e]),""),this._diffMap.get(t)?this.latestDataAUD.update.push(i):this.latestDataAUD.add.push(i),this._diffMap.set(t,i)})),this._diffMap.forEach(((t,i)=>{t[SM]<e&&(this.latestDataAUD.del.push(t),this._diffMap.delete(i))}))}this._diffRank=e}cloneParseData(t,e){let i=!0;return(t instanceof AM||!1===(null==e?void 0:e.clone))&&(i=!1),i?t:jr(t)}parseNewData(t,e){this.parse(t,e||this.parseOption),this.reRunAllTransform()}updateRawData(t,e){const i=this.cloneParseData(t,e);this.rawData=i,this.parserData=i,this.latestData=i,this.reRunAllTransform()}getFields(){var t;return this._fields?this._fields:"dataview"===(null===(t=this.parseOption)||void 0===t?void 0:t.type)&&1===this.rawData.length&&this.rawData[0].getFields?this.rawData[0].getFields():null}destroy(){this.dataSet.removeDataView(this.name),this.resetDiff(),this.latestData=null,this.rawData=null,this.parserData=null,this.transformsArr=null,this.target=null}}const TM=(t,e,i)=>new Me({defaultFontParams:{fontFamily:"PingFang SC,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol",fontSize:14},getTextBounds:i?void 0:vu,specialCharSet:"-/: .,@%'\"~"+Me.ALPHABET_CHAR_SET+Me.ALPHABET_CHAR_SET.toUpperCase(),...e??{}},t),BM=(t,e)=>{const i=t.map(((t,i)=>({index:i,value:t,label:e.labelFormatter?e.labelFormatter(t):`${t}`})));return i},MM=(t,e,i=0)=>{const n=new fe(t).expand(i/2),r=new fe(e).expand(i/2);return n.intersects(r)},RM=(t,e)=>{let i=0;t.x2<e.x1?i=e.x1-t.x2:e.x2<t.x1&&(i=t.x1-e.x2);let n=0;return t.y2<e.y1?n=e.y1-t.y2:e.y2<t.y1&&(n=t.y1-e.y2),[i,n]};function PM(t,e,i){return i>Math.max(e.x1-t.x2,t.x1-e.x2,e.y1-t.y2,t.y1-e.y2)}function EM(t,e){for(let i,n=1,r=t.length,o=t[0];n<r;o=i,++n)if(i=t[n],PM(o.AABBBounds,i.AABBBounds,e))return!0;return!1}const HM=(t,e,i)=>{const{labelStyle:n,axisOrientType:r,labelFlush:o,labelFormatter:s,startAngle:a=0}=i,l=n.angle??0,h=["bottom","top"].includes(r),c=["left","right"].includes(r);let d=a;h?d=0:c&&(d=(t=>zt(t)?ge(t):null)(-90));const u=TM(n),p=e.map(((i,r)=>{const a=s?s(i):`${i}`,{width:p,height:f}=u.quickMeasure(a),g=Math.max(p,12),y=Math.max(f,12),m=t.scale(i);let b,v,w=Math.cos(d)*m,C=-Math.sin(d)*m;b=o&&h&&0===r?"left":o&&h&&r===e.length-1?"right":n.textAlign??"center","right"===b?w-=g:"center"===b&&(w-=g/2),v=o&&c&&0===r?"top":o&&c&&r===e.length-1?"bottom":n.textBaseline??"middle","bottom"===v?C-=y:"middle"===v&&(C-=y/2);return(new fe).set(w,C,w+g,C+y).rotate(l,w+g/2,C+y/2)}));return p},kM=(t,e,i)=>{const{labelStyle:n,getRadius:r,axisSpec:o,labelFormatter:s}=i,a=r?.(),l=n.angle??0,h=LM(o),c=TM(n),d=e.map((e=>{const i=s?s(e):`${e}`,{width:n,height:r}=c.quickMeasure(i),o=Math.max(n,12),d=Math.max(r,12),u=t.scale(e);let p=0,f=0;const g=function(t){let e="center",i="middle";t=function(t){for(;t<0;)t+=2*Math.PI;for(;t>=2*Math.PI;)t-=2*Math.PI;return t}(t),e=t>=Math.PI*(5/3)||t<=Math.PI*(1/3)?"left":t>=Math.PI*(2/3)&&t<=Math.PI*(4/3)?"right":"center";i=t>=Math.PI*(7/6)&&t<=Math.PI*(11/6)?"bottom":t>=Math.PI*(1/6)&&t<=Math.PI*(5/6)?"top":"middle";return{align:e,baseline:i}}(u),{x:y,y:m}=function(t,e,i){return{x:t.x+e*Math.cos(i),y:t.y+e*Math.sin(i)}}({x:0,y:0},a+h,u);p=y+("right"===g.align?-o:"center"===g.align?-o/2:0),f=m+("bottom"===g.baseline?-d:"middle"===g.baseline?-d/2:0);return(new fe).set(p,f,p+o,f+d).rotate(l,p+o/2,f+d/2)}));return d};function LM(t){let e=0;return Vt(t,"tick.visible")&&(e+=Vt(t,"tick.tickSize")),Vt(t,"label.visible")&&(e+=Vt(t,"label.space")),e}const IM={parity:function(t){return t.filter(((t,e)=>e%2==0))},greedy:function(t,e){let i;return t.filter(((t,n)=>(!n||!PM(i.AABBBounds,t.AABBBounds,e))&&(i=t,!0)))}},OM=(t,e,i,n,r,o)=>{let s=o,a=0,l=0,h=0,c=-1,d=Number.MAX_VALUE;do{let o=!0;s++;let u=0;do{u+s<t.length&&MM(e[u],e[u+s],i)&&(o=!1),u+=s}while(o&&u<t.length);if(o){if(!n){h=s;break}{const n=t.length-1;a=0;do{if(u-=s,u!==n&&!MM(e[u],e[n],i))break;a++}while(u>0);if(u===n){h=s,l=a;break}{const i=Math.floor(t.length/s)-a+1;if(i<c)break;{c=i;const t=r?0:1,o=RM(e[u],e[n])[t],p=u-s>=0?RM(e[u-s],e[u])[t]:o,f=Math.abs(o-p);f<d&&(d=f,h=s,l=a)}}}}}while(s<=t.length);return{step:h,delCount:l}},DM=(t,e,i,n)=>{let r=n;do{let n=!0;r++;let o=0;do{o+r<t.length&&MM(e[o],e[o+r],i)&&(n=!1),o+=r}while(n&&o<t.length);if(n)break}while(r<=t.length);let o=0;if(t.length>2){let i=t.length-t.length%r;for(i>=t.length&&(i-=r);i>0&&MM(e[0],e[i]);)o++,i-=r}return{step:r,delCount:o}},FM=(t,e)=>{if(GC(t.type))return((t,e)=>{if(!GC(t.type))return BM(t.domain(),e);const{tickCount:i,forceTickCount:n,tickStep:r}=e;let o;if(o=kt(r)?t.stepTicks(r):kt(n)?t.forceTicks(n):t.ticks(i??5),"cartesian"===e.coordinateType||"polar"===e.coordinateType&&"radius"===e.axisOrientType){const{labelGap:i=4,labelFlush:n}=e;let r=HM(t,o,e).map(((t,e)=>({AABBBounds:t,value:o[e]})));for(;r.length>=3&&EM(r,i);)r=IM.parity(r);const s=r.map((t=>t.value));s.length<3&&n&&(s.length>1&&s.pop(),ee(s)!==ee(o)&&s.push(ee(o))),o=s}return BM(o,e)})(t,e);if(function(t){switch(t){case NC.Ordinal:case NC.Point:case NC.Band:return!0;default:return!1}}(t.type)){if("cartesian"===e.coordinateType)return((t,e)=>{const{tickCount:i,forceTickCount:n,tickStep:r,labelGap:o=4,axisOrientType:s}=e,a=["bottom","top"].includes(s);let l;if(kt(r))l=t.stepTicks(r);else if(kt(n))l=t.forceTicks(n);else if(kt(i))l=t.ticks(i);else{const i=t.domain(),n=t.range(),r=HM(t,i,e),s=r.map((t=>a?t.width():t.height())),h=Math.min(...n),c=(Math.max(...n)-h)/i.length,d=OM(i,r,o,e.labelLastVisible,a,Math.floor(Math.min(...s)/c));l=t.stepTicks(d.step),e.labelLastVisible&&(l=l.slice(0,l.length-d.delCount),l.push(i[i.length-1]))}return BM(l,e)})(t,e);if("polar"===e.coordinateType&&"angle"===e.axisOrientType)return((t,e)=>{const{tickCount:i,forceTickCount:n,tickStep:r,getRadius:o,axisSpec:s,labelGap:a=0}=e,l=o?.();if(!l)return BM(t.domain(),e);let h;if(kt(r))h=t.stepTicks(r);else if(kt(n))h=t.forceTicks(n);else if(kt(i))h=t.ticks(i);else{const i=t.domain(),n=t.range(),r=LM(s),o=kM(t,i,e),c=Math.min(...n),d=Math.max(...n),u=Math.abs(d-c)*(l+r)/i.length,{step:p,delCount:f}=DM(i,o,a,Math.floor(o.reduce(((t,e)=>Math.min(t,e.width(),e.height())),Number.MAX_VALUE)/u));h=t.stepTicks(p),h=h.slice(0,h.length-f)}return BM(h,e)})(t,e)}return BM(t.domain(),e)},WM=Math.sqrt(50),zM=Math.sqrt(10),jM=Math.sqrt(2);class NM{_extend={};_scale;_scales;nice;zero;domain;expand;forceTickCount;tickCount;niceType;constructor(){this._scale=new lx,this._scales=[this._scale]}setExtraAttrFromSpec(t,e,i,n){this.nice=t,this.zero=e,this.domain=i,this.expand=n}transformScaleDomain(){this.setScaleNice()}setScaleNice(){let t=this.forceTickCount??this.tickCount??10;"accurateFirst"===this.niceType&&(t=Math.max(10,t)),Ht(this.domain?.min)&&Ht(this.domain?.max)?this.nice&&this._scale.nice(t):kt(this.domain?.min)&&Ht(this.domain?.max)?this.nice&&this._scale.niceMax(t):Ht(this.domain?.min)&&kt(this.domain?.max)&&this.nice&&this._scale.niceMin(t)}dataToPosition(t){return this.valueToPosition(t[0])}valueToPosition(t){return this._scale.scale(t)}computeLinearDomain(t){const e=[];return t.forEach((t=>{const{min:i,max:n}=t;e[0]=void 0===e[0]?i:Math.min(e[0],i),e[1]=void 0===e[1]?n:Math.max(e[1],n)})),this.expandDomain(e),this.includeZero(e),this.setDomainMinMax(e),e}expandDomain(t){if(!this.expand)return;const e=t[0],i=t[t.length-1];kt(this.expand.min)&&(t[0]=e-(i-e)*this.expand.min),kt(this.expand.max)&&(t[t.length-1]=i+(i-e)*this.expand.max)}niceDomain(t){if(Math.abs(function(t){if(t&&Ot(t))return t.reduce(((t,e)=>Math.min(t,e)),1/0)}(t)-function(t){if(t&&Ot(t))return t.reduce(((t,e)=>Math.max(t,e)),-1/0)}(t))<=1e-12){let e=t[0];const i=e>=0?1:-1;if(e=Math.abs(e),e<1)t[0]=0,t[1]=1;else{let i=e/5;const n=Math.floor(Math.log(i)/Math.LN10),r=i/Math.pow(10,n);i=(r>=WM?10:r>=zM?5:r>=jM?2:1)*Math.pow(10,n),t[0]=0,t[1]=10*i}i<0&&(t.reverse(),t[0]*=-1,t[1]*=-1)}return t}niceMinMax(){if(this.nice){let t=this.forceTickCount??this.tickCount??10;"accurateFirst"===this.niceType&&(t=Math.max(10,t)),Ht(this.domain?.min)&&Ht(this.domain?.max)?this._scale.nice(t):kt(this.domain?.min)&&Ht(this.domain?.max)?this._scale.niceMax(t):Ht(this.domain?.min)&&kt(this.domain?.max)&&this._scale.niceMin(t)}}includeZero(t){this.zero&&(t[0]=Math.min(t[0],0),t[t.length-1]=Math.max(t[t.length-1],0))}setExtendDomain(t,e){if(void 0===e)return void delete this._extend[t];this._extend[t]=e;const i=this._scale.domain();this.extendDomain(i),this.includeZero(i),this.setDomainMinMax(i),this.niceDomain(i),this._scale.domain(i,this.nice),this.niceMinMax()}extendDomain(t){let e;const i=t.length-1,n=t[0]-t[i]>0,r=n?i:0,o=n?0:i;for(const i in this._extend)e=this._extend[i],e>t[o]&&(t[o]=e),e<t[r]&&(t[r]=e)}setDomainMinMax(t){if(!this.domain)return;const{min:e,max:i}=this.domain;kt(e)&&(t[0]=e),kt(i)&&(t[1]=i)}setZero(t){this.zero!==t&&(this.zero=t,this.updateScaleDomain())}updateScaleDomain(){const t=this.computeDomain([this.domain]);this.updateScaleDomainByModel(t)}computeDomain(t){return this.computeLinearDomain(t)}updateScaleDomainByModel(t){t=t??this._scale.domain(),this.extendDomain(t),this.includeZero(t),this.setDomainMinMax(t),this.niceDomain(t),this._scale.domain(t,this.nice),this.niceMinMax()}updateRange(t){const[e,i]=this._scale.range();t[0]===e&&t[1]===i||this._scale.range(t)}}function GM(t,e){const i=e.option;Ut(t)||i?.label?.flush&&function(t,e){const{width:i,height:n}=e.getLayoutRect(),r=ZS(e.orient),o=t[0],s=ee(t);if(r){const t=0,e=i,n=o.AABBBounds.x1,r=s.AABBBounds.x2;n<t&&o.setAttributes({x:t,textAlign:"left"}),r>e&&s.setAttributes({x:e,textAlign:"right"})}else{const t=n,e=0,i=o.AABBBounds.y2,r=s.AABBBounds.y1;i>t&&o.setAttributes({y:t,textBaseline:"bottom"}),r<e&&s.setAttributes({y:e,textBaseline:"top"})}}(t,e)}const KM=t=>t;class UM{width;height;table;option;orient;visible;type;inverse;data;tickData;scale;component;constructor(t,e,i,n){this.table=n,this.width=e,this.height=i,this.option=Zt({},t,qS),this.orient=t.orient??"left",this.visible=t.visible??!0,this.type=t.type??"band",this.inverse="inverse"in t&&!!t.inverse,"band"===t.type&&(this.data=t.data),this.initScale(),this.initData(),this.createComponent(),this.initEvent()}initScale(){const t=this.option;"band"===this.type?(this.scale=new JS,this.scale.bandPadding=t.bandPadding,this.scale.paddingInner=t.paddingInner,this.scale.paddingOuter=t.paddingOuter,this.scale.calcScales(.1,.3),this.scale.updateScaleDomain(this.data),this.updateScaleRange()):"linear"!==this.type&&"time"!==this.type||(this.scale=new NM,this.scale.setExtraAttrFromSpec(t.nice,t.zero,t.range,t.expand),this.scale.transformScaleDomain(),this.scale.updateScaleDomain(),this.updateScaleRange())}initData(){!function(t,e,i){t.getParser(e)||t.registerParser(e,i)}(this.table.dataSet,"scale",KM),function(t,e,i){t.getTransform(e)||t.registerTransform(e,i)}(this.table.dataSet,"ticks",FM);const t=this.option.label||{},e=this.option.tick||{},i=new AM(this.table.dataSet).parse(this.scale._scale,{type:"scale"}).transform({type:"ticks",options:{tickCount:e.tickCount,forceTickCount:e.forceTickCount,tickStep:e.tickStep,axisOrientType:this.orient,coordinateType:"cartesian",labelStyle:t.style,labelFormatter:t.formatMethod,labelLastVisible:t.lastVisible,labelFlush:t.flush}},!1);this.tickData=i,this.computeData()}computeData(){this.tickData.reRunAllTransform()}initEvent(){}createComponent(){const t=function(t){const e=t;let i,n=e.title?.angle??0;return"left"!==e.orient&&"right"!==e.orient||e.title?.autoRotate&&Ht(e.title.angle)&&(n="left"===e.orient?-90:90,i=$S[e.orient]),{select:e.select,hover:e.hover,line:(r=e.domainLine,US(r),US(r.startSymbol),US(r.endSymbol),r),label:{visible:e.label.visible,space:e.label.space,inside:e.label.inside,style:KS(e.label.style),formatMethod:e.label.formatMethod?(t,i,n)=>e.label.formatMethod(i.rawValue,i):null,state:VS(e.label.state)},tick:{visible:e.tick.visible,length:e.tick.tickSize,inside:e.tick.inside,alignWithLabel:e.tick.alignWithLabel,style:KS(e.tick.style),state:VS(e.tick.state)},subTick:{visible:e.subTick.visible,length:e.subTick.tickSize,inside:e.subTick.inside,count:e.subTick.tickCount,style:KS(e.subTick.style),state:VS(e.subTick.state)},grid:{type:"line",visible:e.grid.visible,alternateColor:e.grid.alternateColor,alignWithLabel:e.grid.alignWithLabel,style:KS(e.grid.style)},subGrid:{type:"line",visible:e.subGrid.visible,alternateColor:e.subGrid.alternateColor,style:KS(e.subGrid.style)},title:{visible:e.title.visible,position:e.title.position,space:e.title.space,autoRotate:!1,angle:n?ge(n):null,textStyle:Zt({},i,KS(e.title.style)),padding:e.title.padding,shape:{visible:e.title.shape?.visible,space:e.title.shape?.space,style:KS(e.title.shape?.style)},background:{visible:e.title.background?.visible,style:KS(e.title.background?.style)},state:{text:VS(e.title.state),shape:VS(e.title.shape?.state),background:VS(e.title.background?.state)}},panel:{visible:e.background?.visible,style:KS(e.background?.style),state:VS(e.background?.state)}};var r}(this.option),e=this.getUpdateAttribute();e.verticalFactor="top"===this.orient||"right"===this.orient?-1:1,this.component=new L_(Zt({},t,e)),this.component.setAttributes(this.setLayoutStartPosition({x:0,y:0}))}overlap(){!function(t,e){const i=t.find((t=>"axis-label-container-layer-0"===t.name),!0),n=t.find((t=>"axis-label-container-layer-1"===t.name),!0);GM(i?i.getChildren():[],e),GM(n?n.getChildren():[],e)}(this.component,this)}getLayoutRect(){return{width:this.width,height:this.height}}getUpdateAttribute(){const t=this.table.tableNoFrameHeight,e=this.table.tableNoFrameWidth,{width:i,height:n}=this.getLayoutRect(),r=ZS(this.orient),o="left"===(s=this.orient)||"right"===s;var s;let a={x:0,y:0},l=0,h=0;r?(a={x:i,y:0},l=t,h=i):o&&(a={x:0,y:n},l=e,h=n);return{start:{x:0,y:0},end:a,grid:{type:"line",length:l,visible:this.option.grid.visible},title:{text:this.option.title.text,maxWidth:this._getTitleLimit(r)},items:this.getLabelItems(h)}}getLabelItems(t){return[this.tickData.latestData.map((e=>({id:e.value,label:e.value,value:0===t?0:this.scale.dataToPosition([e.value])/t,rawValue:e.value}))).filter((t=>t.value>=0&&t.value<=1))]}updateScaleRange(){const{width:t,height:e}=this.getLayoutRect();let i=[0,0];ZS(this.orient)?zt(t)&&(i=[0,t]):zt(e)&&(i=[e,0]),this.scale.updateRange(i)}setLayoutStartPosition(t){let{x:e,y:i}=t;return zt(e)&&(e+=Number("left"===this.orient)*this.getLayoutRect().width),zt(i)&&(i+=Number("top"===this.orient)*this.getLayoutRect().height),{x:e,y:i}}_getTitleLimit(t){if(this.option.title.visible&&Ht(this.option.title.style?.maxLineWidth)){const e=this.option.title.style?.angle||0;if(t){const t=this.getLayoutRect().width,i=Math.abs(Math.cos(e));return i<1e-6?1/0:t/i}const i=this.getLayoutRect().height,n=Math.abs(Math.sin(e));return n<1e-6?1/0:i/n}return null}getScale(){return this.scale._scale}getDomainSpec(){return this.scale.domain}}function VM(t,e,i,n,r,o,s,a,l,h,c,d,u,p,f,g,y,m){let b;if("text"===t||"link"===t){if("link"===t){const o=i.getCellValue(n,r),s=i._getCellStyle(n,r);"link"===t&&("templateLink"in e&&e.templateLink||!("linkDetect"in e)||!e.linkDetect||De.test(o))&&(m?(m.text.fill=OC("linkColor",s,n,r,i),m.group.cursor="pointer"):m={text:{fill:OC("linkColor",s,n,r,i)},group:{cursor:"pointer"}})}if(s){const t=i.getCellOriginValue(n,r),e=s(i,t);e&&(m?m.group.fill=e:m={group:{fill:e}})}let v,w,C,x=!0;if("body"!==i.getCellType(n,r)?(w=e?.headerCustomRender,C=e?.headerCustomLayout):(w=e?.customRender||i.customRender,C=e?.customLayout),C||w){const t=Sx(C,w,n,r,i.getColWidth(n),i.getRowHeight(r),!1,"autoHeight"===i.heightMode,i);v=t.elementsGroup,x=t.renderDefault}b=jS(i,h,0,c,n,r,o,a,l,d,u,p,f,v,x,m),g&&(b.mergeCol=y.end.col,b.mergeRow=y.end.row);const _=i.internalProps.layoutMap.getAxisConfigInPivotChart(n,r);if(_){const t=new UM(_,b.attribute.width,b.attribute.height,i);b.clear(),b.appendChild(t.component),t.overlap()}else i.internalProps.layoutMap.isEmpty(n,r)&&b.clear()}else if("image"===t)b=function(t,e,i,n,r,o,s,a,l,h,c,d,u,p){const f=DC("padding",u._getCellStyle(n,r),n,r,u);A(f)&&(h=f),p?.text?.textAlign&&(c=p?.text?.textAlign),p?.text?.textBaseline&&(d=p?.text?.textBaseline);const g=new xw({x:e,y:i,width:o,height:s,lineWidth:p?.group?.lineWidth??void 0,fill:p?.group?.fill??void 0,stroke:p?.group?.stroke??void 0,strokeArrayWidth:p?.group?.strokeArrayWidth??void 0,strokeArrayColor:p?.group?.strokeArrayColor??void 0,cursor:p?.group?.cursor??void 0,lineCap:"square",clip:!0});g.role="cell",g.col=n,g.row=r,t.addChild(g);const y=u.getCellValue(n,r),m=gu({x:h[3],y:h[0],width:o-h[1]-h[3],height:s-h[0]-h[2],image:y??FC.damage_pic.svg,cursor:"pointer"});return m.name="image",m.keepAspectRatio=a,m.successCallback=a||l?()=>{const t=m.resources.get(m.attribute.image).data;if(l&&WC(n,r,t.width,t.height,u.scenegraph,h),a){const{width:e,height:i}=LC(t.width,t.height,g.attribute.width-h[1]-h[3],g.attribute.height-h[0]-h[2]),n=IC(0,0,g.attribute.width,g.attribute.height,e,i,c,d,h);m.setAttributes({x:n.x,y:n.y,width:e,height:i})}u.scenegraph.updateNextFrame()}:()=>{zC(g,n,r,u)},m.failCallback=()=>{const t=kC();m.image=t.damage_pic.svg},g.appendChild(m),g}(h,0,c,n,r,i.getColWidth(n),i.getRowHeight(r),e.keepAspectRatio,e.imageAutoSizing,d,u,p,i,m);else if("video"===t)b=function(t,e,i,n,r,o,s,a,l,h,c,d,u,p){const f=DC("padding",u._getCellStyle(n,r),n,r,u);A(f)&&(h=f),p?.text?.textAlign&&(c=p?.text?.textAlign),p?.text?.textBaseline&&(d=p?.text?.textBaseline);const g=new xw({x:e,y:i,width:o,height:s,lineWidth:p?.group?.lineWidth??void 0,fill:p?.group?.fill??void 0,stroke:p?.group?.stroke??void 0,strokeArrayWidth:p?.group?.strokeArrayWidth??void 0,strokeArrayColor:p?.group?.strokeArrayColor??void 0,cursor:p?.group?.cursor??void 0,lineCap:"square",clip:!0});g.role="cell",g.col=n,g.row=r,t.addChild(g);const y=u.getCellValue(n,r),m=document.createElement("video");m.addEventListener("loadeddata",(()=>{l&&WC(n,r,m.videoWidth,m.videoHeight,u.scenegraph,h);const t=g.attribute.width,e=g.attribute.height;if(a){const{width:i,height:n}=LC(m.videoWidth,m.videoHeight,t-h[1]-h[3],e-h[0]-h[2]),r=IC(0,0,t,e,i,n,c,d,h);b.setAttributes({width:i,height:n,x:r.x,y:r.y})}else b.setAttributes({x:h[3],y:h[0],width:t-h[1]-h[3],height:e-h[2]-h[0]});const i=Math.floor(Math.min(t-h[1]-h[3],e-h[2]-h[0])/2),o=0+(t>b.attribute.width?b.attribute.x-0+b.attribute.width/2:t/2),s=0+(e>b.attribute.height?b.attribute.y-0+b.attribute.height/2:e/2),p=new px({x:o-i/2,y:s-i/2,width:i,height:i,image:NS.play.svg,cursor:NS.play.cursor});p.name="play-icon",g.appendChild(p),u.scenegraph.updateNextFrame()})),m.onerror=()=>{b.image=NS.damage_pic.svg},m.src=y,m.setAttribute("preload","auto");const b=gu({x:h[3],y:h[0],width:o-h[1]-h[3],height:s-h[2]-h[0],image:m,cursor:"pointer"});return b.name="image",g.appendChild(b),g}(h,0,c,n,r,i.getColWidth(n),i.getRowHeight(r),e.keepAspectRatio,e.imageAutoSizing,d,u,p,i,m);else if("chart"===t){const t=i.internalProps.layoutMap.getChartInstance(n,r);b=zS(null,h,0,c,n,r,i.getColWidth(n),i.getRowHeight(r),d,i.getCellValue(n,r),e.chartType,i.isPivotChart()?i.internalProps.layoutMap.getChartSpec(n,r):e.chartSpec,t,i,m)}else if("progressbar"===t){const t=i._getCellStyle(n,r),s=i.getCellValue(n,r),f=i.getCellOriginValue(n,r);b=jS(i,h,0,c,n,r,o,a,l,d,u,p,!1,null,!0,m);const g=jC(e,t,o,s,f,n,r,0,i);b.insertBefore(g,b.firstChild)}else"sparkline"===t&&(b=dx(null,h,0,c,n,r,a,l,d,i,m));return b}function $M(t,e,i,n){const r=i.scenegraph.highPerformanceGetCell(t,e,!0),o=i.isHeader(t,e)?i._getHeaderLayoutMap(t,e).headerType:i.getBodyColumnType(t,e),s=i.getCellType(t,e),a="body"!==s?i.getHeaderDefine(t,e):i.getBodyColumnDefine(t,e);let l,h,c;if(("body"!==s||a?.mergeCell)&&(h=i.getCellRange(t,e),l=h.start.col!==h.end.col||h.start.row!==h.end.row),!l||t===h.start.col&&e===h.start.row){const d="body"!==s||(!!a?.icon||!!a?.tree),u=RC(i._getCellStyle(t,e),i,t,e,OC).theme,p=u._vtable.padding,f=u._vtable.textAlign,g=u._vtable.textBaseline;let y,m,b;i.internalProps?.dataConfig?.mappingRules&&"body"===s&&i.internalProps?.dataConfig?.mappingRules?.forEach(((t,e)=>{t.bgColor&&(y=t.bgColor.mapping)})),"body"!==s?(a?.headerCustomRender,a?.headerCustomLayout):(a?.customRender||i.customRender,a?.customLayout),h?(m=i.getColsWidth(h.start.col,h.end.col),b=i.getRowsHeight(h.start.row,h.end.row)):(m=i.getColWidth(t),b=i.getRowHeight(e));const v=i.getCellValue(t,e);st(v)?(r.removeAllChild(),GS(v,i,XM.bind(null,o,a,i,t,e,y,m,b,r,p,f,g,d,l,h,n,u))):c=XM(o,a,i,t,e,y,m,b,r,p,f,g,d,l,h,n,u)}else c=new xw({x:0,y:n?0:r.attribute.y,width:0,height:0,visible:!1,pickable:!1}),c.role="shadow-cell",c.col=t,c.row=e,c.mergeCol=h.start.col,c.mergeRow=h.start.row,n||(r.parent.insertAfter(c,r),r.parent.removeChild(r));return c}function XM(t,e,i,n,r,o,s,a,l,h,c,d,u,p,f,g,y){const m=VM(t,e,i,n,r,i.getColWidth(n),o,s,a,g?i.scenegraph.getColGroup(n):l.parent,g?0:l.attribute.y,h,c,d,u,p,f,y);return g||(l.parent.insertAfter(m,l),l.parent.removeChild(l),i.scenegraph?.proxy.cellCache.get(n)&&i.scenegraph?.proxy.cellCache.set(n,m)),m}function YM(t,e,i,n,r,o,s,a,l,h){let c,d,u,p,f=0;a.internalProps?.dataConfig?.mappingRules&&"body"===l&&a.internalProps?.dataConfig?.mappingRules?.forEach(((t,e)=>{t.bgColor&&(p=t.bgColor.mapping)}));let g=0;t.colHeight&&(g=t.colHeight);for(let y=n;y<=r;y++){const n=y,r="body"!==l?a.getHeaderDefine(e,n):a.getBodyColumnDefine(e,n),m="body"!==l||(!!r?.icon||!!r?.tree),b=RC(a._getCellStyle(e,n),a,e,n,OC).theme;b.group.width=i,b.group.height=Array.isArray(s)?s[n]:s,b._vtable.padding&&(c=b._vtable.padding),b.text.textAlign&&(d=b.text.textAlign),b.text.textBaseline&&(u=b.text.textBaseline);let v=i,w=a.getRowHeight(n);const C=(a.isHeader(e,n)?a._getHeaderLayoutMap(e,n).headerType:a.getBodyColumnType(e,n))||"text";let x,_,S;if(("body"!==l||r?.mergeCell)&&(_=a.getCellRange(e,n),S=_.start.col!==_.end.col||_.start.row!==_.end.row,S&&(v=0,w=0,x=o.get(`${_.start.col},${_.start.row};${_.end.col},${_.end.row}`),!x))){for(let t=_.start.col;t<=_.end.col;t++)v+=a.getColWidth(t);for(let t=_.start.row;t<=_.end.row;t++)w+=a.getRowHeight(t);o.set(`${_.start.col},${_.start.row};${_.end.col},${_.end.row}`,{x:0,y:g,cellWidth:v,cellHeight:w})}if(x){const i=x.cellHeight/(_.end.row-_.start.row+1),r=new xw({x:0,y:g,width:0,height:i,visible:!1,pickable:!1});r.role="shadow-cell",r.col=e,r.row=n,r.mergeCol=_.start.col,r.mergeRow=_.start.row,t.addChild(r),t.updateColumnRowNumber(n),t.updateColumnHeight(i),_=a.getCellRange(e,n),g+=i,f=Math.max(f,x.cellWidth)}else{const o=a.getCellValue(e,n);if(st(o)){GS(o,a,VM.bind(null,C,r,a,e,n,i,p,v,w,t,g,c,d,u,m,S,_,b)),t.updateColumnRowNumber(n);const s=S?a.getRowHeight(n)/(_.end.row-_.start.row+1):a.getRowHeight(n);t.updateColumnHeight(s),g+=s}else{const o=VM(C,r,a,e,n,i,p,v,w,t,g,c,d,u,m,S,_,b);t.updateColumnRowNumber(n);const s=S?o.attribute.height/(_.end.row-_.start.row+1):o.attribute.height;t.updateColumnHeight(s),g+=s}}if(h&&n>h)break}return t.setAttribute("width",i),{width:i,height:g}}function qM(t,e,i,n,r,o,s,a,l,h){if(n>r||o>s)return;const{layoutMap:c,defaultRowHeight:d,defaultHeaderRowHeight:u,defaultColWidth:p}=l.internalProps;let f=0,g=0;for(let c=n;c<=r;c++){const n=c,r=l.getColWidth(n),p=new xw({x:e+f,y:i,width:r,height:0,clip:!1,pickable:!1});p.role="column",p.col=c,t.addChild(p);const{width:y,height:m}=YM(p,n,r,o,s,l.scenegraph.mergeMap,"columnHeader"===a?u??d:d,l,a,h);f+=y,g=Math.max(g,m)}t.setAttribute("width",f),t.setAttribute("height",g)}async function ZM(t,e,i,n){"left"===e&&n.colEnd+t>n.bodyRightCol?t=n.bodyRightCol-n.colEnd:"right"===e&&n.colStart-t<n.bodyLeftCol&&(t=n.colStart-n.bodyLeftCol);const r=n.table.scenegraph.bodyGroup;if(t<n.colEnd-n.colStart){const o="left"===e?n.colStart:n.colEnd-t+1,s="left"===e?n.colStart+t-1:n.colEnd,a="left"===e?n.colEnd+1:n.colStart-t,l="left"===e?n.colEnd+t:n.colStart-1;AS(n.table,a,l);for(let t=o;t<=s;t++)if("left"===e){const t=r.firstChild;JM(t,r.lastChild.col+1,r.lastChild.attribute.x+r.lastChild.attribute.width),r.appendChild(t)}else{const t=r.lastChild;JM(t,r.firstChild.col-1,r.firstChild.attribute.x-n.table.getColWidth(r.firstChild.col-1)),r.insertBefore(t,r.firstChild)}const h=Math.max(n.bodyLeftCol,i-1*n.screenColCount),c=Math.min(n.bodyRightCol,i+2*n.screenColCount);for(let t=h;t<=c;t++){QM(n.table.scenegraph.getColGroup(t),n)}n.colStart="left"===e?n.colStart+t:n.colStart-t,n.colEnd="left"===e?n.colEnd+t:n.colEnd-t,n.currentCol="left"===e?n.currentCol+t:n.currentCol-t,n.totalCol="left"===e?n.totalCol+t:n.totalCol-t,n.referenceCol=n.colStart+Math.floor((n.colEnd-n.colStart)/2),n.colUpdatePos=a,n.colUpdateDirection=e,n.table.scenegraph.stage.render(),await n.progress()}else{const o="left"===e?n.colStart+t:n.colStart-t,s="left"===e?n.colEnd+t:n.colEnd-t;AS(n.table,o,s);const a=n.table.getColsWidth(n.bodyLeftCol,o-1);console.log("distStartColY",n.bodyLeftCol,o-1,a),r.forEachChildren(((i,r)=>{"group"===i.type&&JM(i,"left"===e?i.col+t:i.col-t,0===r?a:i._prev.attribute.x+n.table.getColWidth(i._prev.col))}));const l=Math.max(n.bodyLeftCol,i-1*n.screenRowCount),h=Math.min(n.bodyRightCol,i+2*n.screenRowCount);for(let t=l;t<=h;t++){QM(n.table.scenegraph.getColGroup(t),n)}const c=n.table.scenegraph.getCell(i,0);c.AABBBounds.width(),console.log("leftCell",c.col,c.globalAABBBounds,c),n.colStart=o,n.colEnd=s,n.currentCol="left"===e?n.currentCol+t:n.currentCol-t,n.totalCol="left"===e?n.totalCol+t:n.totalCol-t,n.referenceCol=n.colStart+Math.floor((n.colEnd-n.colStart)/2),n.colUpdatePos=n.colStart,n.colUpdateDirection=s>n.bodyRightCol-(n.colEnd-n.colStart+1)?"right":"left",await n.progress()}}function JM(t,e,i){t.col=e,t.forEachChildren((t=>{t.col=e,t.needUpdate=!0})),t.setAttribute("x",i),t.needUpdate=!0}function QM(t,e){let i=t.firstChild;for(;i;){i=e.updateCellGroupContent(i)._next}t.needUpdate=!1}function tR(t,e,i,n,r,o="up"){if("up"===o)for(let o=t;o<=e;o++)for(let t=i;t<=n;t++){const e=r.scenegraph.getCell(o,t);if(!e.row)continue;let i;i=e._prev?(e._prev?.attribute.y??0)+(e._prev?.attribute.height??0):r.getRowsHeight(r.columnHeaderLevelCount,e.row-1),e.setAttribute("y",i)}else for(let o=t;o<=e;o++)for(let t=n;t>=i;t--){const e=r.scenegraph.getCell(o,t);if(!e.row)continue;let i;e._next?i=(e._next?.attribute.y??0)-(e.attribute.height??0):(i=r.getRowsHeight(r.columnHeaderLevelCount,e.row)-(e.attribute.height??0),console.log("估计位置",r.getRowsHeight(r.columnHeaderLevelCount,e.row))),e.setAttribute("y",i)}}async function eR(t,e,i,n){if("up"===e&&n.rowEnd+t>n.bodyBottomRow?t=n.bodyBottomRow-n.rowEnd:"down"===e&&n.rowStart-t<n.bodyTopRow&&(t=n.rowStart-n.bodyTopRow),t<n.rowEnd-n.rowStart){const r="up"===e?n.rowStart:n.rowEnd-t+1,o="up"===e?n.rowStart+t-1:n.rowEnd;for(let t=n.bodyLeftCol;t<=n.bodyRightCol;t++){const i=n.table.scenegraph.getColGroup(t);for(let t=r;t<=o;t++)if("up"===e){const t=i.firstChild;n.updateCellGroupPosition(t,i.lastChild.row+1,i.lastChild.attribute.y+i.lastChild.attribute.height),i.appendChild(t)}else{const t=i.lastChild;n.updateCellGroupPosition(t,i.firstChild.row-1,i.firstChild.attribute.y-t.attribute.height),i.insertBefore(t,i.firstChild)}}const s="up"===e?n.rowEnd+1:n.rowStart-t,a="up"===e?n.rowEnd+t:n.rowStart-1,l=Math.max(n.bodyTopRow,i-1*n.screenRowCount),h=Math.min(n.bodyBottomRow,i+2*n.screenRowCount);"autoHeight"===n.table.heightMode&&HS(n.table,l,h);for(let t=n.bodyLeftCol;t<=n.bodyRightCol;t++)for(let e=l;e<=h;e++){const i=n.highPerformanceGetCell(t,e,s,a);n.updateCellGroupContent(i)}"autoHeight"===n.table.heightMode&&tR(n.bodyLeftCol,n.bodyRightCol,l,h,n.table,e),n.rowStart="up"===e?n.rowStart+t:n.rowStart-t,n.rowEnd="up"===e?n.rowEnd+t:n.rowEnd-t,n.currentRow="up"===e?n.currentRow+t:n.currentRow-t,n.totalRow="up"===e?n.totalRow+t:n.totalRow-t,n.referenceRow=n.rowStart+Math.floor((n.rowEnd-n.rowStart)/2),n.rowUpdatePos=s,n.rowUpdateDirection=e,console.log("move end proxy",n.rowStart,n.rowEnd),console.log("move end cell",n.table.scenegraph.bodyGroup.firstChild.firstChild.row,n.table.scenegraph.bodyGroup.firstChild.lastChild.row),n.table.scenegraph.updateNextFrame(),await n.progress()}else{const r="up"===e?n.rowStart+t:n.rowStart-t,o="up"===e?n.rowEnd+t:n.rowEnd-t,s=n.table.getRowsHeight(n.bodyTopRow,r-1);for(let i=n.bodyLeftCol;i<=n.bodyRightCol;i++){const r=n.table.scenegraph.getColGroup(i);r?.forEachChildren(((i,r)=>{n.updateCellGroupPosition(i,"up"===e?i.row+t:i.row-t,0===r?s:i._prev.attribute.y+i._prev.attribute.height)}))}let a,l;"autoHeight"===n.table.heightMode?(a=r,l=o):(a=Math.max(n.bodyTopRow,i-1*n.screenRowCount),l=Math.min(n.bodyBottomRow,i+2*n.screenRowCount)),console.log("更新同步范围",a,l),"autoHeight"===n.table.heightMode&&HS(n.table,a,l),n.rowStart=r,n.rowEnd=o;for(let t=n.bodyLeftCol;t<=n.bodyRightCol;t++)for(let e=a;e<=l;e++){const i=n.highPerformanceGetCell(t,e,r,o);n.updateCellGroupContent(i)}console.log("updateAutoRow",o>n.bodyBottomRow-(n.rowEnd-n.rowStart+1)?"down":"up"),"autoHeight"===n.table.heightMode&&tR(n.bodyLeftCol,n.bodyRightCol,a,l,n.table,o>n.bodyBottomRow-(n.rowEnd-n.rowStart+1)?"down":"up"),n.currentRow="up"===e?n.currentRow+t:n.currentRow-t,n.totalRow="up"===e?n.totalRow+t:n.totalRow-t,n.referenceRow=n.rowStart+Math.floor((n.rowEnd-n.rowStart)/2),n.rowUpdatePos=n.rowStart,n.rowUpdateDirection=o>n.bodyBottomRow-(n.rowEnd-n.rowStart+1)?"down":"up",console.log("move total end proxy",n.rowStart,n.rowEnd),console.log("move total end cell",n.table.scenegraph.bodyGroup.firstChild.firstChild.row,n.table.scenegraph.bodyGroup.firstChild.lastChild.row),n.table.scenegraph.updateNextFrame(),"autoHeight"!==n.table.heightMode&&await n.progress()}}class iR{table;mode="column";rowLimit=1e3;currentRow=0;totalRow;yLimitTop;yLimitBottom;rowStart=0;rowEnd=0;referenceRow=0;bodyTopRow;bodyBottomRow;screenRowCount;firstScreenRowLimit;taskRowCount;rowUpdatePos;rowUpdateDirection;screenTopRow=0;colLimit=1e3;bodyLeftCol;bodyRightCol;totalCol;colStart;colEnd;taskColCount;xLimitLeft;xLimitRight;screenColCount;firstScreenColLimit;colUpdatePos;currentCol;referenceCol;screenLeftCol=0;colUpdateDirection;cellCache=new Map;constructor(t){this.table=t,this.table.internalProps.transpose?this.mode="row":this.table.isPivotTable()&&(this.mode="pivot"),this.table.options.maintainedDataCount&&(this.rowLimit=this.table.options.maintainedDataCount)}setParamsForColumn(){this.bodyLeftCol=this.table.rowHeaderLevelCount,this.bodyRightCol=this.table.colCount-1-this.table.rightFrozenColCount;const t=Math.min(this.colLimit,this.bodyRightCol-this.bodyLeftCol+1);this.totalCol=this.bodyLeftCol+t-1,this.colStart=this.bodyLeftCol;const e=this.table.defaultColWidth;this.taskColCount=1*Math.ceil(this.table.tableNoFrameWidth/e);const i=e*t,n=e*(this.bodyRightCol-this.bodyLeftCol+1);this.xLimitLeft=i/2,this.xLimitRight=n-i/2;const r=5*this.table.tableNoFrameWidth;this.screenColCount=Math.ceil(this.table.tableNoFrameWidth/e),this.firstScreenColLimit=this.bodyLeftCol+Math.ceil(r/e),this.colUpdatePos=this.bodyRightCol}setParamsForRow(){this.bodyTopRow=this.table.columnHeaderLevelCount,this.bodyBottomRow=this.table.rowCount-1-this.table.bottomFrozenRowCount;const t=Math.min(this.rowLimit,this.bodyBottomRow-this.bodyTopRow+1);this.totalRow=this.bodyTopRow+t-1,this.rowStart=this.bodyTopRow;const e=this.table.defaultRowHeight;this.taskRowCount=1*Math.ceil(this.table.tableNoFrameHeight/e);const i=e*t,n=e*(this.bodyBottomRow-this.bodyTopRow+1);this.yLimitTop=i/2,this.yLimitBottom=n-i/2;const r=5*this.table.tableNoFrameHeight;this.screenRowCount=Math.ceil(this.table.tableNoFrameHeight/e),this.firstScreenRowLimit=this.bodyTopRow+Math.ceil(r/e),this.rowUpdatePos=this.bodyBottomRow}async createGroupForFirstScreen(t,e,i,n,r,o,s,a){await async function(t,e,i,n,r,o,s,a,l){l.setParamsForRow(),l.setParamsForColumn(),l.table.internalProps._colWidthsMap.clear(),l.table._clearColRangeWidthsMap(),AS(l.table,0,Math.min(l.firstScreenColLimit,l.table.colCount-1)),l.table.internalProps._rowHeightsMap.clear(),l.table._clearRowRangeHeightsMap(),HS(l.table,0,Math.min(l.firstScreenRowLimit,l.table.rowCount-1)),l.table.rightFrozenColCount>0&&l.table.colCount-1>l.firstScreenColLimit&&AS(l.table,l.table.colCount-1-l.table.rightFrozenColCount+1,l.table.colCount-1),l.table.bottomFrozenRowCount>0&&l.table.rowCount-1>l.firstScreenRowLimit&&AS(l.table,l.table.rowCount-1-l.table.bottomFrozenRowCount+1,l.table.rowCount-1),l.table.scenegraph.colHeaderGroup.setAttribute("x",l.table.getFrozenColsWidth()),l.table.scenegraph.rowHeaderGroup.setAttribute("y",l.table.getFrozenRowsHeight()),l.table.scenegraph.bottomFrozenGroup.setAttribute("x",l.table.getFrozenColsWidth()),l.table.scenegraph.rightFrozenGroup.setAttribute("y",l.table.getFrozenRowsHeight()),l.table.scenegraph.bodyGroup.setAttributes({x:l.table.getFrozenColsWidth(),y:l.table.getFrozenRowsHeight()}),qM(t,s,a,0,l.table.rowHeaderLevelCount-1,0,l.table.columnHeaderLevelCount-1,"cornerHeader",l.table),qM(e,s,a,l.table.rowHeaderLevelCount,Math.min(l.firstScreenColLimit,l.table.colCount-1-l.table.rightFrozenColCount),0,l.table.columnHeaderLevelCount-1,"columnHeader",l.table),qM(i,s,a,0,l.table.rowHeaderLevelCount-1,l.table.columnHeaderLevelCount,Math.min(l.firstScreenRowLimit,l.table.rowCount-1-l.table.bottomFrozenRowCount),"rowHeader",l.table),l.table.bottomFrozenRowCount>0&&qM(r,s,a,l.table.rowHeaderLevelCount,Math.min(l.firstScreenColLimit,l.table.colCount-1-l.table.rightFrozenColCount),l.table.rowCount-1-l.table.bottomFrozenRowCount+1,l.table.rowCount-1,"body",l.table),l.table.rightFrozenColCount>0&&qM(n,s,a,l.table.colCount-1-l.table.rightFrozenColCount+1,l.table.colCount-1,l.table.columnHeaderLevelCount,Math.min(l.firstScreenRowLimit,l.table.rowCount-1-l.table.bottomFrozenRowCount),"body",l.table),qM(o,s,a,l.table.rowHeaderLevelCount,Math.min(l.firstScreenColLimit,l.table.colCount-1-l.table.rightFrozenColCount),l.table.columnHeaderLevelCount,Math.min(l.firstScreenRowLimit,l.table.rowCount-1-l.table.bottomFrozenRowCount),"body",l.table),o.firstChild?(l.currentRow=o.firstChild?.rowNumber??l.totalRow,l.rowEnd=l.currentRow,l.rowUpdatePos=l.rowEnd,l.referenceRow=l.rowStart+Math.floor((l.rowEnd-l.rowStart)/2),l.currentCol=o.lastChild?.col??l.totalCol,l.colEnd=l.currentCol,l.colUpdatePos=l.colEnd,l.referenceCol=l.colStart+Math.floor((l.colEnd-l.colStart)/2),await l.progress()):(l.currentRow=l.totalRow,l.rowEnd=l.currentRow,l.rowUpdatePos=l.rowEnd,l.referenceRow=l.rowStart+Math.floor((l.rowEnd-l.rowStart)/2),l.currentCol=l.totalCol,l.colEnd=l.currentCol,l.colUpdatePos=l.colEnd,l.referenceCol=l.colStart+Math.floor((l.colEnd-l.colStart)/2))}(t,e,i,n,r,o,s,a,this)}async createColGroupForFirstScreen(t,e,i,n,r){this.setParamsForRow(),this.setParamsForColumn(),HS(r,this.table.columnHeaderLevelCount,Math.min(this.firstScreenRowLimit,r.rowCount-1)),qM(t,i,n,0,r.rowHeaderLevelCount-1,r.columnHeaderLevelCount,r.rowCount-1,"rowHeader",r,this.firstScreenRowLimit),qM(e,i,n,r.rowHeaderLevelCount,r.colCount-1,r.columnHeaderLevelCount,r.rowCount-1,"body",r,this.firstScreenRowLimit),e.firstChild?(this.currentRow=e.firstChild?.rowNumber??this.totalRow,this.rowEnd=this.currentRow,this.rowUpdatePos=this.rowEnd,this.referenceRow=Math.floor((this.rowEnd-this.rowStart)/2),await this.progress()):(this.currentRow=this.totalRow,this.rowEnd=this.currentRow,this.rowUpdatePos=this.rowEnd,this.referenceRow=Math.floor((this.rowEnd-this.rowStart)/2))}async progress(){return new Promise(((t,e)=>{setTimeout((async()=>{this.colUpdatePos<this.colEnd?(await this.updateColCellGroupsAsync(),await this.progress()):this.rowUpdatePos<this.rowEnd?(await this.updateRowCellGroupsAsync(),await this.progress()):this.currentCol<this.totalCol?(await this.createCol(),await this.progress()):this.currentRow<this.totalRow&&(await this.createRow(),await this.progress()),t()}),0)}))}async createRow(){this.taskRowCount&&(console.log("createRow",this.currentRow,this.currentRow+this.taskRowCount),this.createRowCellGroup(this.taskRowCount))}async createCol(){this.taskColCount&&(console.log("createCol",this.currentCol,this.currentCol+this.taskColCount),this.createColGroup(this.taskRowCount))}createRowCellGroup(t){const e=Math.min(this.totalRow,this.currentRow+t);if(HS(this.table,this.currentRow+1,e),this.table.rowHeaderLevelCount){let t=0;for(let i=0;i<this.table.rowHeaderLevelCount;i++){const n=this.table.scenegraph.getColGroup(i),r="rowHeader",{height:o}=YM(n,i,n.attribute.width,this.currentRow+1,e,this.table.scenegraph.mergeMap,this.table.internalProps.defaultRowHeight,this.table,r);t=Math.max(t,o),this.table.scenegraph.rowHeaderGroup.setAttribute("height",t)}}if(this.table.rightFrozenColCount){let t=0;for(let i=this.table.colCount-this.table.rightFrozenColCount;i<this.table.colCount;i++){const n=this.table.scenegraph.getColGroup(i),r="rowHeader",{height:o}=YM(n,i,n.attribute.width,this.currentRow+1,e,this.table.scenegraph.mergeMap,this.table.internalProps.defaultRowHeight,this.table,r);t=Math.max(t,o),this.table.scenegraph.rightFrozenGroup.setAttribute("height",t)}}let i=0;for(let t=this.bodyLeftCol;t<=this.bodyRightCol;t++){const n=this.table.scenegraph.getColGroup(t),r="body",{height:o}=YM(n,t,n.attribute.width,this.currentRow+1,e,this.table.scenegraph.mergeMap,this.table.internalProps.defaultRowHeight,this.table,r);i=Math.max(i,o)}this.table.scenegraph.bodyGroup.setAttribute("height",i),this.currentRow=e,this.rowEnd=e,this.rowUpdatePos=this.rowEnd,this.referenceRow=this.rowStart+Math.floor((e-this.rowStart)/2),this.table.scenegraph.updateContainer(),this.table.scenegraph.updateBorderSizeAndPosition()}createColGroup(t){const e=Math.min(this.totalCol,this.currentCol+t);AS(this.table,this.currentCol+1,e);const i=this.table.scenegraph.bodyGroup.lastChild instanceof xw?this.table.scenegraph.bodyGroup.lastChild:this.table.scenegraph.bodyGroup.lastChild._prev,n=i.attribute.x+i.attribute.width,r=i.attribute.y;qM(this.table.scenegraph.bodyGroup,n,r,this.currentCol+1,e,this.rowStart,this.rowEnd,"body",this.table),this.currentCol=e,this.colEnd=e,this.colUpdatePos=this.colEnd,this.referenceCol=this.colStart+Math.floor((e-this.colStart)/2),console.log("async",this.referenceCol,this.colStart,this.colEnd),this.table.scenegraph.updateContainer(),this.table.scenegraph.updateBorderSizeAndPosition()}async setY(t){t<this.yLimitTop&&this.rowStart===this.bodyTopRow||t>this.yLimitBottom&&this.rowEnd===this.bodyBottomRow?this.table.scenegraph.setBodyAndRowHeaderY(-t):this.dynamicSetY(t)}async setX(t){t<this.xLimitLeft&&this.colStart===this.bodyLeftCol||t>this.xLimitRight&&this.colEnd===this.bodyRightCol?this.table.scenegraph.setBodyAndColHeaderX(-t):this.dynamicSetX(t)}async dynamicSetY(t){!async function(t,e){const i=e.table.getTargetRowAt(t+e.table.scenegraph.colHeaderGroup.attribute.height);if(!i)return;const n=i.row;e.screenTopRow=n;const r=n-e.referenceRow;r>0?(eR(r,"up",n,e),e.updateBody(t)):r<0?(eR(-r,"down",n,e),e.updateBody(t)):e.updateBody(t),e.table.scenegraph.updateNextFrame()}(t,this)}async dynamicSetX(t){!async function(t,e){const i=e.table.getTargetColAt(t+e.table.scenegraph.rowHeaderGroup.attribute.width);if(!i)return;e.screenLeftCol=i.col;const n=e.screenLeftCol-e.referenceCol;n>0?(e.table.scenegraph.setBodyAndColHeaderX(-t),await ZM(n,"left",e.screenLeftCol,e)):n<0?(e.table.scenegraph.setBodyAndColHeaderX(-t),await ZM(-n,"right",e.screenLeftCol,e)):e.table.scenegraph.setBodyAndColHeaderX(-t),e.table.scenegraph.updateNextFrame()}(t,this)}updateBody(t){this.table.scenegraph.setBodyAndRowHeaderY(-t)}async updateRowCellGroupsAsync(){this.updateCellGroups(this.taskRowCount)}updateCellGroups(t){const e=Math.min(this.bodyBottomRow,this.rowUpdatePos+t);"autoHeight"===this.table.heightMode&&HS(this.table,this.rowUpdatePos,e);for(let t=this.bodyLeftCol;t<=this.bodyRightCol;t++)for(let i=this.rowUpdatePos;i<=e;i++){const e=this.highPerformanceGetCell(t,i);this.updateCellGroupContent(e)}"autoHeight"===this.table.heightMode&&tR(this.bodyLeftCol,this.bodyRightCol,this.rowUpdatePos,e,this.table,this.rowUpdateDirection),this.rowUpdatePos=e+1}async updateColCellGroupsAsync(){this.updateColGroups(this.taskRowCount)}updateColGroups(t){const e=Math.min(this.bodyRightCol,this.colUpdatePos+t);for(let t=this.colUpdatePos;t<=e;t++){const e=this.table.scenegraph.getColGroup(t);if(e){let t=e.firstChild;for(;t;){t=this.updateCellGroupContent(t)._next}e.needUpdate=!1}}this.colUpdatePos=e+1}updateCellGroupPosition(t,e,i){t.row=e,t.setAttribute("y",i),t.needUpdate=!0,t.needUpdateForAutoRowHeight=!0}updateCellGroupContent(t){if(!t.needUpdate)return t;const e=this.table.scenegraph.updateCellContent(t.col,t.row);return t.needUpdate=!1,e||t}async sortCell(){for(let t=this.bodyLeftCol;t<=this.bodyRightCol;t++)for(let e=this.rowStart;e<=this.rowEnd;e++){this.highPerformanceGetCell(t,e).needUpdate=!0}let t,e;"autoHeight"===this.table.heightMode?(t=this.rowStart,e=this.rowEnd):(t=Math.max(this.bodyTopRow,this.screenTopRow-2*this.screenRowCount),e=Math.min(this.bodyBottomRow,this.screenTopRow+3*this.screenRowCount)),console.log("sort更新同步范围",t,e),"autoHeight"===this.table.heightMode&&HS(this.table,t,e);for(let i=this.bodyLeftCol;i<=this.bodyRightCol;i++)for(let n=t;n<=e;n++){const t=this.highPerformanceGetCell(i,n);this.updateCellGroupContent(t)}if(console.log("updateAutoRow",this.rowEnd>this.bodyBottomRow-(this.rowEnd-this.rowStart+1)?"down":"up"),"autoHeight"===this.table.heightMode&&tR(this.bodyLeftCol,this.bodyRightCol,t,e,this.table,this.rowEnd>this.bodyBottomRow-(this.rowEnd-this.rowStart+1)?"down":"up"),this.rowUpdatePos=this.rowStart,this.rowUpdateDirection=this.rowEnd>this.bodyBottomRow-(this.rowEnd-this.rowStart+1)?"down":"up",this.rowEnd===this.table.scenegraph.proxy.bodyBottomRow&&this.rowStart===this.table.scenegraph.proxy.bodyTopRow);else if(this.rowEnd===this.table.scenegraph.proxy.bodyBottomRow){const t=this.table.getAllRowsHeight()-this.table.scenegraph.height;this.updateBody(t)}else this.rowStart===this.table.scenegraph.proxy.bodyTopRow&&this.updateBody(0);"autoHeight"!==this.table.heightMode&&await this.progress()}highPerformanceGetCell(t,e,i=this.rowStart,n=this.rowEnd,r){if(e<i||e>n)return DS;if(e<this.rowStart||e>this.rowEnd||t<this.colStart||t>this.colEnd)return DS;if(this.cellCache.get(t)){const i=this.cellCache.get(t);if((i._next||i._prev)&&Math.abs(i.row-e)<e){let n=nR(i,e);return n||(n=this.table.scenegraph.getCell(t,e,r)),n.row&&this.cellCache.set(t,n),n}const n=this.table.scenegraph.getCell(t,e,r);return n.row&&this.cellCache.set(t,n),n}const o=this.table.scenegraph.getCell(t,e,r);return o.row&&this.cellCache.set(t,o),o}}function nR(t,e){return t?t.row===e?t:t.row>e?nR(t._prev,e):nR(t._next,e):null}function rR(t,e,i){const[n,r,o,s]=e.split("-"),a=parseInt(n,10),l=parseInt(r,10),h=parseInt(o,10),c=parseInt(s,10);let d;for(let t=a;t<=h;t++)for(let e=l;e<=c;e++){const n=i.highPerformanceGetCell(t,e);if("cell"!==n.role)continue;n.AABBBounds.width();const r=n.globalAABBBounds;d?d.union(r):d=r}d?t.rect.setAttributes({x:d.x1-i.tableGroup.attribute.x,y:d.y1-i.tableGroup.attribute.y,width:d.width(),height:d.height(),visible:!0}):t.rect.setAttributes({visible:!1});const u=a===i.table.frozenColCount,p=l===i.table.frozenRowCount;u&&t.rect.attribute.stroke[3]||p&&t.rect.attribute.stroke[0]?(u&&i.tableGroup.insertAfter(t.rect,"columnHeader"===t.role?i.cornerHeaderGroup:i.rowHeaderGroup),p&&i.tableGroup.insertAfter(t.rect,"rowHeader"===t.role?i.cornerHeaderGroup:i.colHeaderGroup),t.rect.attribute.x<i.rowHeaderGroup.attribute.width&&i.table.scrollLeft>0&&("body"===t.role||"columnHeader"===t.role)&&t.rect.setAttributes({x:t.rect.attribute.x+(i.rowHeaderGroup.attribute.width-t.rect.attribute.x),width:t.rect.attribute.width-(i.rowHeaderGroup.attribute.width-t.rect.attribute.x)}),t.rect.attribute.y<i.colHeaderGroup.attribute.height&&i.table.scrollTop>0&&("body"===t.role||"rowHeader"===t.role)&&t.rect.setAttributes({y:t.rect.attribute.y+(i.colHeaderGroup.attribute.height-t.rect.attribute.y),height:t.rect.attribute.height-(i.colHeaderGroup.attribute.height-t.rect.attribute.y)})):i.tableGroup.insertAfter(t.rect,"body"===t.role?i.bodyGroup:"columnHeader"===t.role?i.colHeaderGroup:"rowHeader"===t.role?i.rowHeaderGroup:i.cornerHeaderGroup)}function oR(t,e,i){const n=i.scenegraph,r=sR(t.map((t=>t.row))).sort(((t,e)=>t-e)),o=sR(e.map((t=>t.row))).sort(((t,e)=>t-e));r.forEach((t=>{!function(t,e){for(let i=0;i<e.table.colCount;i++){const n=e.getColGroup(i,!1);let r;n.forEachChildren((e=>e.row===t&&(r=e,!0))),r&&n.removeChild(r)}}(t,n)})),r.length&&function(t){for(let e=0;e<t.table.colCount;e++){const i=t.getColGroup(e,!0),n=t.getColGroup(e,!1);let r=i.firstChild?.row;i.forEachChildren((t=>{t.row=r,r++})),r=n.firstChild?.row,n.forEachChildren((t=>{t.row=r,r++}))}}(n),o.forEach((t=>{!function(t,e){for(let i=0;i<e.table.colCount;i++){const n=$M(i,t,e.table,!0);if(!n)continue;const r=e.getColGroup(i);if(r.firstChild&&t<r.firstChild.row)r.insertBefore(n,r.firstChild);else if(r.lastChild&&t>r.lastChild.row)r.appendChild(n);else{let e;r.forEachChildren((i=>i.row===t&&(e=i,!0))),e!==n&&r.insertBefore(n,e)}let o=r.firstChild?.row;r.forEachChildren((t=>{t.row=o,o++}))}}(t,n)})),function(t){let e=0;for(let i=0;i<t.table.colCount;i++){const n=t.getColGroup(i,!0),r=t.getColGroup(i,!1);let o=n.firstChild?.row,s=0;o=r.firstChild?.row,s=0,r.forEachChildren((t=>{t.row=o,o++,"cell"===t.role&&(t.setAttribute("y",s),s+=t.attribute.height)})),e=s}t.updateContainerHeight(t.table.frozenRowCount,e-t.bodyGroup.attribute.height)}(n)}function sR(t){const e=[];for(let i=0;i<t.length;i++)-1===e.indexOf(t[i])&&e.push(t[i]);return e}new Ah({});const aR=[];function lR(t){aR.forEach((e=>{t.scenegraph.getCell(e.col,e.row).forEachChildren((t=>{t.setAttributes({dy:0,dx:0})}))})),aR.length=0;const{scrollTop:e,scrollLeft:i,frozenRowCount:n,frozenColCount:r}=t,o=t.getFrozenRowsHeight(),s=t.getFrozenColsWidth(),{row:a}=t.getRowAt(e+o+1),{col:l}=t.getColAt(i+s+1),h=t.getAllRowsHeight()>t.tableNoFrameHeight?t.getRowAt(e+t.tableNoFrameHeight-1).row:t.rowCount-1,c=t.getAllColsWidth()>t.tableNoFrameWidth?t.getColAt(i+t.tableNoFrameWidth-1).col:t.colCount-1;for(let e=0;e<n;e++)for(let i=l;i<=c;i++)if(t._getCellStyle(i,e)?.textStick){cR(t.scenegraph.getCell(i,e),s+t.tableX,t.tableNoFrameWidth),aR.push({col:i,row:e})}if(-1!==a){for(let e=a;e<=h;e++)for(let i=0;i<r;i++)if(t._getCellStyle(i,e)?.textStick&&"tree"!==t.internalProps.layoutMap.rowHierarchyType){hR(t.scenegraph.getCell(i,e),o+t.tableY,t.tableNoFrameHeight),aR.push({col:i,row:e})}for(let e=a;e<=h;e++)for(let i=l;i<=c;i++)if(t._getCellStyle(i,e)?.textStick){const n=t.scenegraph.getCell(i,e);hR(n,o+t.tableY,t.tableNoFrameHeight),cR(n,s+t.tableX,t.tableNoFrameWidth),aR.push({col:i,row:e})}}}function hR(t,e,i){const n=t.getChildByName("text",!0);if(!n)return;n.AABBBounds.width();const r=n.globalAABBBounds.y1,o=n.globalAABBBounds.y2;if(r<e){const i=r-e;t.forEachChildren((t=>{t.setAttribute("dy",2-i)}))}else if(o>i){const e=o-i;t.forEachChildren((t=>{t.setAttribute("dy",-e)}))}}function cR(t,e,i){const n=t.getChildByName("text",!0);if(!n)return;n.AABBBounds.width();const r=n.globalAABBBounds.x1,o=n.globalAABBBounds.x2;if(r<e){const i=r-e;t.forEachChildren((t=>{t.setAttribute("dx",2-i)}))}else if(o>i){const e=o-i;t.forEachChildren((t=>{t.setAttribute("dx",-e)}))}}function dR(t){for(let e=t.proxy.colStart;e<=t.proxy.colEnd;e++){t.getColGroup(e).getChildren().forEach((t=>{t.children.forEach((t=>{"chart"===t.type&&(t.cacheCanvas=null,t.addUpdateBoundTag())}))}))}}function uR(t){const e=t.bodyGroup.firstChild instanceof xw?t.bodyGroup.firstChild:null;e&&(t.rowHeaderGroup.appendChild(e),t.rowHeaderGroup.setAttribute("width",t.rowHeaderGroup.attribute.width+e.attribute.width),t.bodyGroup.setAttribute("width",t.bodyGroup.attribute.width-e.attribute.width))}function pR(t){const e=t.colHeaderGroup.firstChild instanceof xw?t.colHeaderGroup.firstChild:null;e&&(t.cornerHeaderGroup.appendChild(e),t.cornerHeaderGroup.setAttribute("width",t.cornerHeaderGroup.attribute.width+e.attribute.width),t.colHeaderGroup.setAttribute("width",t.colHeaderGroup.attribute.width-e.attribute.width))}function fR(t){const e=t.rowHeaderGroup.lastChild instanceof xw?t.rowHeaderGroup.lastChild:t.rowHeaderGroup.lastChild?._prev;e&&(t.bodyGroup.firstChild?t.bodyGroup.insertBefore(e,t.bodyGroup.firstChild):t.bodyGroup.appendChild(e),t.bodyGroup.setAttribute("width",t.bodyGroup.attribute.width+e.attribute.width),t.rowHeaderGroup.setAttribute("width",t.rowHeaderGroup.attribute.width-e.attribute.width))}function gR(t){const e=t.cornerHeaderGroup.lastChild instanceof xw?t.cornerHeaderGroup.lastChild:t.cornerHeaderGroup.lastChild?._prev;e&&(t.colHeaderGroup.firstChild?t.colHeaderGroup.insertBefore(e,t.colHeaderGroup.firstChild):t.bodyGroup.appendChild(e),t.colHeaderGroup.setAttribute("width",t.colHeaderGroup.attribute.width+e.attribute.width),t.cornerHeaderGroup.setAttribute("width",t.cornerHeaderGroup.attribute.width-e.attribute.width))}na.load(SS);class yR{proxy;tableGroup;colHeaderGroup;cornerHeaderGroup;rowHeaderGroup;bodyGroup;rightFrozenGroup;bottomFrozenGroup;rightTopCellGroup;leftBottomCellGroup;rightBottomCellGroup;componentGroup;selectedRangeComponents;selectingRangeComponents;lastSelectId;component;stage;table;isPivot;transpose;hasFrozen;frozenColCount;frozenRowCount;rightFrozenColCount;bottomFrozenRowCount;clear;mergeMap;constructor(t){this.table=t,this.hasFrozen=!1,this.clear=!0,this.mergeMap=new Map,this.stage=function(t){return new ww(t)}({canvas:t.canvas,width:t.canvas.width,height:t.canvas.height,disableDirtyBounds:!1,background:t.theme.underlayBackgroundColor,dpr:t.internalProps.pixelRatio}),this.stage.defaultLayer.setTheme({group:{boundsPadding:0,strokeBoundsBuffer:0,lineJoin:"round"}}),this.initSceneGraph(),this.stage.defaultLayer.add(this.tableGroup),this.stage.table=this.table,this.createComponent()}get width(){return this.tableGroup.attribute?.width??0}get height(){return this.tableGroup.attribute?.height??0}get x(){return this.tableGroup.attribute?.x??0}get y(){return this.tableGroup.attribute?.y??0}get bodyRowStart(){return this.transpose||this.isPivot?this.table.columnHeaderLevelCount:this.proxy.rowStart??0}get bodyRowEnd(){return this.transpose||this.isPivot?this.table.rowCount-1:this.proxy.rowEnd??0}initSceneGraph(){this.isPivot=this.table.isPivotTable(),this.transpose=this.table.options.transpose;const t=this.table.tableNoFrameWidth,e=this.table.tableNoFrameHeight;this.tableGroup=new xw({x:0,y:0,width:t,height:e,clip:!0,pickable:!1}),this.tableGroup.role="table";const i=new xw({x:0,y:0,width:0,height:0,clip:!1,pickable:!1});i.role="col-header",this.colHeaderGroup=i;const n=new xw({x:0,y:0,width:0,height:0,clip:!1,pickable:!1});n.role="corner-header",this.cornerHeaderGroup=n;const r=new xw({x:0,y:0,width:0,height:0,clip:!1,pickable:!1});r.role="row-header",this.rowHeaderGroup=r;const o=new xw({x:0,y:0,width:t,height:0,clip:!1,pickable:!1});o.role="body",this.bodyGroup=o;const s=new xw({x:0,y:0,width:t,height:0,clip:!1,pickable:!1});s.role="right-frozen",this.rightFrozenGroup=s;const a=new xw({x:0,y:0,width:t,height:0,clip:!1,pickable:!1});a.role="bottom-frozen",this.bottomFrozenGroup=a;const l=new xw({x:0,y:0,width:0,height:0,clip:!1,pickable:!1,childrenPickable:!0});l.role="component",this.componentGroup=l;const h=new xw({x:0,y:0,width:0,height:0,visible:!1,pickable:!0,fill:this.table.theme.cornerHeaderStyle.bgColor,stroke:this.table.theme.cornerHeaderStyle.borderColor,lineWidth:this.table.theme.cornerHeaderStyle.borderLineWidth});h.role="corner-frozen",this.rightTopCellGroup=h;const c=new xw({x:0,y:0,width:0,height:0,visible:!1,pickable:!0,fill:this.table.theme.cornerHeaderStyle.bgColor,stroke:this.table.theme.cornerHeaderStyle.borderColor,lineWidth:this.table.theme.cornerHeaderStyle.borderLineWidth});c.role="corner-frozen",this.leftBottomCellGroup=c;const d=new xw({x:0,y:0,width:0,height:0,visible:!1,pickable:!0,fill:this.table.theme.cornerHeaderStyle.bgColor,stroke:this.table.theme.cornerHeaderStyle.borderColor,lineWidth:this.table.theme.cornerHeaderStyle.borderLineWidth});d.role="corner-frozen",this.rightBottomCellGroup=d,this.tableGroup.addChild(o),this.tableGroup.addChild(s),this.tableGroup.addChild(a),this.tableGroup.addChild(r),this.tableGroup.addChild(i),this.tableGroup.addChild(d),this.tableGroup.addChild(h),this.tableGroup.addChild(c),this.tableGroup.addChild(n),this.tableGroup.addChild(l)}clearCells(){this.clear=!0,this.hasFrozen=!1,this.mergeMap.clear(),this.colHeaderGroup.clear(),this.rowHeaderGroup.clear(),this.cornerHeaderGroup.clear(),this.bodyGroup.clear(),this.colHeaderGroup.setAttributes({x:0,y:0,width:0,height:0}),this.rowHeaderGroup.setAttributes({x:0,y:0,width:0,height:0}),this.cornerHeaderGroup.setAttributes({x:0,y:0,width:0,height:0}),this.bodyGroup.setAttributes({x:0,y:0,width:0,height:0}),this.rightFrozenGroup.setAttributes({x:0,y:0,width:0,height:0}),this.bottomFrozenGroup.setAttributes({x:0,y:0,width:0,height:0}),this.rightTopCellGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.leftBottomCellGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.rightTopCellGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.tableGroup.setAttributes({x:this.table.tableX,y:this.table.tableY,width:0,height:0}),this.tableGroup.border&&(this.tableGroup.parent.removeChild(this.tableGroup.border),delete this.tableGroup.border)}createComponent(){this.component=new tS(this.table),this.component.addToGroup(this.componentGroup),this.selectedRangeComponents=new Map,this.selectingRangeComponents=new Map}createSceneGraph(){this.clear=!1,this.frozenColCount=this.table.rowHeaderLevelCount,this.frozenRowCount=this.table.columnHeaderLevelCount,this.proxy=new iR(this.table),eS(this.tableGroup,this.table.theme.frameStyle,this.tableGroup.role,void 0,!0),this.proxy.createGroupForFirstScreen(this.cornerHeaderGroup,this.colHeaderGroup,this.rowHeaderGroup,this.rightFrozenGroup,this.bottomFrozenGroup,this.bodyGroup,0,0),this.afterScenegraphCreated()}renderSceneGraph(){this.stage.render()}getCellOld(t,e){let i;if(i=this.hasFrozen&&t<this.table.frozenColCount&&e<this.table.frozenRowCount?this.cornerHeaderGroup.getChildAt(t)?.getChildAt(e):e<this.table.frozenRowCount?this.colHeaderGroup.getChildAt(this.hasFrozen?t-this.table.frozenColCount:t)?.getChildAt(e):t<this.table.frozenColCount?this.rowHeaderGroup.getChildAt(t)?.getChildAt(e-this.table.frozenRowCount):this.bodyGroup.getChildAt(t-this.table.frozenColCount)?.getChildAt(e-this.table.frozenRowCount),i&&"shadow-cell"===i.role){const n=this.table.getCellRange(t,e);i=this.getCell(n.start.col,n.start.row)}return i||void 0}getColGroupOld(t,e=!1){let i;return i=t<this.frozenColCount&&e?this.cornerHeaderGroup.getChildAt(t):t<this.frozenColCount?this.rowHeaderGroup.getChildAt(t):e?this.rowHeaderGroup.getChildAt(t-this.frozenColCount):this.bodyGroup.getChildAt(t-this.frozenColCount),i||void 0}getCell(t,e,i){let n;if(n=this.table.rightFrozenColCount>0&&t>this.table.colCount-1-this.table.rightFrozenColCount?this.rightFrozenGroup.getColGroup(t)?.getRowGroup(e):this.table.bottomFrozenRowCount>0&&e>this.table.rowCount-1-this.table.bottomFrozenRowCount?this.bottomFrozenGroup.getColGroup(t)?.getRowGroup(e):this.getColGroup(t,e<this.frozenRowCount)?.getRowGroup(e),n&&"shadow-cell"===n.role&&!i){const i=this.table.getCellRange(t,e);n=this.getCell(i.start.col,i.start.row)}return n||DS}highPerformanceGetCell(t,e,i){return this.table.isHeader(t,e)?this.getCell(t,e,i):this.proxy.highPerformanceGetCell(t,e,0,this.table.rowCount-1,i)}getColGroup(t,e=!1){let i;return i=t<this.frozenColCount&&e?this.cornerHeaderGroup.getColGroup(t):t<this.frozenColCount?this.rowHeaderGroup.getColGroup(t):e?this.colHeaderGroup.getColGroup(t):this.table.rightFrozenColCount>0&&t>this.table.colCount-1-this.table.rightFrozenColCount?this.rightFrozenGroup.getColGroup(t):this.bodyGroup.getColGroup(t),i||void 0}getCellSize(t,e){const i=this.getCell(t,e),n=_w(this.table,t,e);let r=i.attribute.width,o=i.attribute.height;return n&&(r/=n.end.col-n.start.col+1,o/=n.end.row-n.start.row+1),{width:r,height:o}}updateNextFrame(){this.resetAllSelectComponent(),this.stage.renderNextFrame()}resetAllSelectComponent(){var t;(t=this).selectingRangeComponents.forEach(((e,i)=>{rR(e,i,t)})),t.selectedRangeComponents.forEach(((e,i)=>{rR(e,i,t)}))}hideHoverIcon(t,e){if(-1===t||-1===e)return;bR(this,this.getCell(t,e),"mouseenter_cell")}showHoverIcon(t,e){if(-1===t||-1===e)return;mR(this,this.getCell(t,e),"mouseenter_cell")}hideClickIcon(t,e){if(-1===t||-1===e)return;bR(this,this.getCell(t,e),"click_cell")}showClickIcon(t,e){if(-1===t||-1===e)return;mR(this,this.getCell(t,e),"click_cell")}deactivateChart(t,e){if(-1===t||-1===e)return;const i=this.getCell(t,e);i?.firstChild?.deactivate?.()}activateChart(t,e){if(-1===t||-1===e)return;const i=this.getCell(t,e);i?.firstChild?.activate?.(this.table)}removeInteractionBorder(t,e){const i=this.getCell(t,e);i.setAttribute("highlightStroke",void 0),i.setAttribute("highlightStrokeArrayWidth",void 0),i.setAttribute("highlightStrokeArrayColor",void 0)}createCellSelectBorder(t,e,i,n,r,o,s){!function(t,e,i,n,r,o,s,a){const l=Math.min(e,n),h=Math.min(i,r),c=Math.max(e,n),d=Math.max(i,r);let u;for(let e=l;e<=c;e++)for(let i=h;i<=d;i++){const n=t.highPerformanceGetCell(e,i);if("shadow-cell"===n.role)continue;n.AABBBounds.width();const r=n.globalAABBBounds;u?u.union(r):u=r}const p=t.table.theme,f=p.selectionStyle?.cellBorderColor,g=p.selectionStyle?.cellBorderLineWidth,y=uu({pickable:!1,fill:p.selectionStyle?.cellBgColor??"rgba(0, 0, 255,0.1)",lineWidth:g,stroke:a.map((t=>!!t&&f)),x:u.x1-t.tableGroup.attribute.x,y:u.y1-t.tableGroup.attribute.y,width:u.width(),height:u.height(),visible:!0});t.lastSelectId=s,t.selectingRangeComponents.set(`${l}-${h}-${c}-${d}-${s}`,{rect:y,role:o}),t.tableGroup.insertAfter(y,"body"===o?t.bodyGroup:"columnHeader"===o?t.colHeaderGroup:"rowHeader"===o?t.rowHeaderGroup:t.cornerHeaderGroup)}(this,t,e,i,n,r,o,s)}moveSelectingRangeComponentsToSelectedRangeComponents(){var t;(t=this).selectingRangeComponents.forEach(((e,i)=>{t.selectedRangeComponents.get(i)&&t.selectedRangeComponents.get(i).rect.delete(),t.selectedRangeComponents.set(i,e)})),t.selectingRangeComponents=new Map,t.updateNextFrame()}deleteLastSelectedRangeComponents(){var t;(t=this).selectedRangeComponents.forEach(((e,i)=>{i.split("-")[4]===t.lastSelectId&&(e.rect.delete(),t.selectedRangeComponents.delete(i))}))}deleteAllSelectBorder(){var t;(t=this).selectedRangeComponents.forEach(((t,e)=>{t.rect.delete()})),t.selectedRangeComponents=new Map}updateCellSelectBorder(t,e,i,n){!function(t,e,i,n,r){let o=Math.min(n,e),s=Math.min(r,i),a=Math.max(n,e),l=Math.max(r,i);const h=()=>{let e=!1;for(let i=o;i<=a;i++){if(i===o)for(let n=s;n<=l;n++){const r=_w(t.table,i,n);if(r&&r.start.col<o){o=r.start.col,e=!0;break}}if(!e&&i===a)for(let n=s;n<=l;n++){const r=_w(t.table,i,n);if(r&&r.end.col>a){a=r.end.col,e=!0;break}}if(e)break}if(!e)for(let i=s;i<=l;i++){if(i===s)for(let n=o;n<=a;n++){const r=_w(t.table,n,i);if(r&&r.start.row<s){s=r.start.row,e=!0;break}}if(!e&&i===l)for(let n=o;n<=a;n++){const r=_w(t.table,n,i);if(r&&r.end.row>l){l=r.end.row,e=!0;break}}if(e)break}e&&h()};h(),t.selectingRangeComponents.forEach(((t,e)=>{t.rect.delete()})),t.selectingRangeComponents=new Map;let c=!1,d=!1,u=!1,p=!1;if(o<=t.table.frozenColCount-1&&s<=t.table.frozenRowCount-1&&(p=!0),o<=t.table.frozenColCount-1&&l>=t.table.frozenRowCount&&(c=!0),s<=t.table.frozenRowCount-1&&a>=t.table.frozenColCount&&(d=!0),a>=t.table.frozenColCount&&l>=t.table.frozenRowCount&&(u=!0),p){const e=Math.min(a,t.table.frozenColCount-1),i=Math.min(l,t.table.frozenRowCount-1),n=[!0,!d,!c,!0];t.createCellSelectBorder(o,s,e,i,"cornerHeader",`${o}${s}${a}${l}`,n)}if(d){const e=Math.max(o,t.table.frozenColCount),i=Math.min(l,t.table.frozenRowCount-1),n=[!0,!0,!u,!p];t.createCellSelectBorder(e,s,a,i,"columnHeader",`${o}${s}${a}${l}`,n)}if(c){const e=Math.max(s,t.table.frozenRowCount),i=Math.min(a,t.table.frozenColCount-1),n=[!p,!u,!0,!0];t.createCellSelectBorder(o,e,i,l,"rowHeader",`${o}${s}${a}${l}`,n)}if(u){const e=Math.max(o,t.table.frozenColCount),i=Math.max(s,t.table.frozenRowCount),n=[!d,!0,!0,!c];t.createCellSelectBorder(e,i,a,l,"body",`${o}${s}${a}${l}`,n)}}(this,t,e,i,n)}getIcon(t,e,i,n){let r;return this.getCell(t,e).forEachChildren((t=>{"icon"===t.role&&t.containsPoint(i,n,Wo.GLOBAL)&&(r=t)})),r}setIconHoverStyle(t,e,i,n){if(t.attribute.backgroundColor){let e=t.parent.getChildByName("icon-back");e?e.setAttributes({x:(t.attribute.x??0)+(t.attribute.dx??0)+(t.AABBBounds.width()-t.backgroundWidth)/2,y:(t.attribute.y??0)+(t.AABBBounds.height()-t.backgroundHeight)/2,width:t.backgroundWidth,height:t.backgroundHeight,fill:t.attribute.backgroundColor,cornerRadius:5,visible:!0}):(e=uu({x:(t.attribute.x??0)+(t.attribute.dx??0)+(t.AABBBounds.width()-t.backgroundWidth)/2,y:(t.attribute.y??0)+(t.AABBBounds.height()-t.backgroundHeight)/2,width:t.backgroundWidth,height:t.backgroundHeight,fill:t.attribute.backgroundColor,cornerRadius:5,pickable:!1,visible:!0}),e.name="icon-back"),t.parent.insertBefore(e,t)}if(t.attribute.hoverImage&&t.attribute.image!==t.attribute.hoverImage&&(t.image=t.attribute.hoverImage),t.tooltip){const{x1:n,x2:r,y1:o,y2:s}=t.globalAABBBounds,a={content:t.tooltip.title,referencePosition:{rect:{left:n-this.table.tableX,right:r-this.table.tableX,top:o-this.table.tableY,bottom:s-this.table.tableY,width:t.globalAABBBounds.width(),height:t.globalAABBBounds.height()},placement:t.tooltip.placement},style:Object.assign({},this.table.internalProps.theme?.tooltipStyle,t.tooltip?.style)};this.table.internalProps.tooltipHandler.isBinded(a)||this.table.showTooltip(e,i,a)}}setIconNormalStyle(t,e,i){const n=t.parent.getChildByName("icon-back");n&&n.setAttribute("visible",!1),t.attribute.hoverImage&&t.attribute.image!==t.attribute.originImage&&(t.image=t.attribute.originImage)}updateColWidth(t,e){!function(t,e,i){const n="autoHeight"===t.table.heightMode;let r=!1;const o=t.getColGroup(e,!0),s=o?.attribute.width;if(o?.setAttribute("width",s+i),o?.forEachChildren(((o,a)=>{if(Bx(t,o,e,o.row,s,i,t.table.columnHeaderLevelCount,n)){const e=_w(t.table,o.col,o.row);if(e&&e.end.row-e.start.row)for(let i=e.start.row;i<=e.end.row;i++)Mx(t,i);else Mx(t,o.row);r=!0}})),r){let e=0;for(let i=0;i<t.table.colCount;i++){const n=t.getColGroup(i,!0);let r=0;n.forEachChildren((t=>{"cell"===t.role&&(t.setAttribute("y",r),r+=t.attribute.height)})),e=r}t.updateContainerHeight(0,e-t.colHeaderGroup.attribute.height)}r=!1;const a=t.getColGroup(e),l=a.attribute.width;if(a?.setAttribute("width",l+i),a?.forEachChildren(((e,o)=>{if(Bx(t,e,e.col,e.row,l,i,t.table.rowHeaderLevelCount,n)){const i=_w(t.table,e.col,e.row);if(i&&i.end.row-i.start.row)for(let e=i.start.row;e<=i.end.row;e++)Mx(t,e);else Mx(t,e.row);r=!0}})),r){let e=0;for(let i=0;i<t.table.colCount;i++){const n=t.getColGroup(i,!1);let r=0;n.forEachChildren((t=>{"cell"===t.role&&(t.setAttribute("y",r),r+=t.attribute.height)})),e=r}t.updateContainerHeight(t.table.frozenRowCount,e-t.bodyGroup.attribute.height)}e<t.frozenColCount?(t.cornerHeaderGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)})),t.rowHeaderGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)}))):(t.colHeaderGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)})),t.bodyGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)}))),t.table.setColWidth(e,a.attribute.width,!0)}(this,t,e),this.updateContainer()}updateChartSize(t){!function(t,e){for(let i=e;i<=t.proxy.colEnd;i++)t.getColGroup(i).getChildren().forEach((e=>{const i=t.table.getColWidth(e.col),n=t.table.getRowHeight(e.row);e.children.forEach((r=>{"chart"===r.type&&(r.cacheCanvas=null,r.setAttribute("width",Math.ceil(i-r.attribute.cellPadding[3]-r.attribute.cellPadding[1])),r.setAttribute("height",Math.ceil(n-r.attribute.cellPadding[0]-r.attribute.cellPadding[2])),r.setAttribute("viewBox",{x1:Math.ceil(e.globalAABBBounds.x1+r.attribute.cellPadding[3]+t.table.scrollLeft),x2:Math.ceil(e.globalAABBBounds.x1+i-r.attribute.cellPadding[1]+t.table.scrollLeft),y1:Math.ceil(e.globalAABBBounds.y1+r.attribute.cellPadding[0]+t.table.scrollTop),y2:Math.ceil(e.globalAABBBounds.y1+n-r.attribute.cellPadding[2]+t.table.scrollTop)}))}))}))}(this,t)}updateChartState(t){this.table.isPivotChart()&&function(t,e){const i=t.table;if(i.isPivotChart()){const n=i._selectedDataItemsInChart.length;if((null===e||0===e?.length||0===Object.keys(e).length)&&0===n)return;if(i._selectedDataItemsInChart=[],Array.isArray(e))e.forEach((t=>{if(t&&0!==t.key&&Object.keys(t).length>0){const e={};for(const i in t)i.startsWith("VGRAMMAR_")||i.startsWith("__VCHART")||(e[i]=t[i]);i._selectedDataItemsInChart.push(e)}}));else if(e&&0!==e.key&&Object.keys(e).length>0){const t={};for(const i in e)i.startsWith("VGRAMMAR_")||i.startsWith("__VCHART")||(t[i]=e[i]);i._selectedDataItemsInChart.push(t)}if(0===i._selectedDataItemsInChart.length&&0===n)return;i.internalProps.layoutMap.updateDataStateToChartInstance(),dR(t)}}(this,t)}updateAutoColWidth(t){const e=this.table.getColWidth(t),i=TS(t,0,this.table.rowCount-1,this.table,!0);i!==e&&this.updateColWidth(t,i-e)}recalculateColWidths(){AS(this.table,0,this.table.colCount-1,!0)}recalculateRowHeights(){HS(this.table,0,this.table.rowCount-1)}resize(){this.recalculateColWidths(),"autoHeight"===this.table.heightMode&&this.recalculateRowHeights(),this.dealWidthMode(),this.dealHeightMode(),this.dealFrozen(),this.updateTableSize(),this.updateBorderSizeAndPosition(),this.component.updateScrollBar(),this.updateNextFrame()}updateTableSize(){this.tableGroup.setAttributes({width:Math.min(this.table.tableNoFrameWidth,Math.max(this.colHeaderGroup.attribute.width,this.bodyGroup.attribute.width,0)+Math.max(this.cornerHeaderGroup.attribute.width,this.rowHeaderGroup.attribute.width,0)+this.rightBottomCellGroup.attribute.width),height:Math.min(this.table.tableNoFrameHeight,(this.colHeaderGroup.attribute.height??0)+(this.bodyGroup.attribute.height??0)+this.bottomFrozenGroup.attribute.height)}),this.tableGroup.border&&this.tableGroup.border.setAttributes({width:this.tableGroup.attribute.width+this.tableGroup.border.attribute.lineWidth,height:this.tableGroup.attribute.height+this.tableGroup.border.attribute.lineWidth}),this.table.bottomFrozenRowCount>0&&(this.bottomFrozenGroup.setAttribute("y",this.tableGroup.attribute.height-this.bottomFrozenGroup.attribute.height),this.leftBottomCellGroup.setAttributes({visible:!0,y:this.tableGroup.attribute.height-this.bottomFrozenGroup.attribute.height,height:this.bottomFrozenGroup.attribute.height,width:this.table.getFrozenColsWidth()}),this.rightBottomCellGroup.setAttributes({visible:!0,y:this.tableGroup.attribute.height-this.bottomFrozenGroup.attribute.height,height:this.bottomFrozenGroup.attribute.height})),this.table.rightFrozenColCount>0&&(this.rightFrozenGroup.setAttribute("x",this.tableGroup.attribute.width-this.rightFrozenGroup.attribute.width),this.rightTopCellGroup.setAttributes({visible:!0,x:this.tableGroup.attribute.width-this.rightFrozenGroup.attribute.width,width:this.rightFrozenGroup.attribute.width,height:this.table.getFrozenRowsHeight()}),this.rightBottomCellGroup.setAttributes({visible:!0,x:this.tableGroup.attribute.width-this.rightFrozenGroup.attribute.width,width:this.rightFrozenGroup.attribute.width}))}updateRowHeight(t,e){!function(t,e,i){for(let n=0;n<t.table.colCount;n++){const r=t.getCell(n,e),o=_w(t.table,n,e);o&&o.start.col!==n||(Tx(t,r,n,e,r.attribute.height,i,t.table.isHeader(n,e)),t.updateCellContentWhileResize(n,e))}let n=0,r=0;e<t.table.columnHeaderLevelCount?(t.colHeaderGroup.setAttribute("height",t.colHeaderGroup.attribute.height+i),t.rowHeaderGroup.setAttribute("y",t.colHeaderGroup.attribute.y+i),t.bodyGroup.setAttribute("y",t.bodyGroup.attribute.y+i),n=e+1,r=t.table.columnHeaderLevelCount-1):(n=e+1,r=t.bodyRowEnd);for(let e=n;e<=r;e++)for(let n=0;n<t.table.colCount;n++){const r=t.getCell(n,e),o=_w(t.table,n,e);(!o||o.start.col===n&&o.start.row===e)&&r.setAttribute("y",r.attribute.y+i)}t.table.setRowHeight(e,t.table.getRowHeight(e)+i,!0)}(this,t,e),this.updateContainerHeight(t,e)}updateContainerWidth(t,e){t<this.frozenColCount?(this.rowHeaderGroup.setDeltaWidth(e),this.cornerHeaderGroup.setDeltaWidth(e),this.colHeaderGroup.setDeltaX(e),this.bodyGroup.setDeltaX(e)):(this.colHeaderGroup.setDeltaWidth(e),this.bodyGroup.setDeltaWidth(e)),this.updateTableSize(),this.component.updateScrollBar(),this.updateNextFrame()}updateContainerHeight(t,e){t<this.frozenRowCount?(this.colHeaderGroup.setDeltaHeight(e),this.cornerHeaderGroup.setDeltaHeight(e),this.rowHeaderGroup.setDeltaY(e),this.bodyGroup.setDeltaY(e)):(this.rowHeaderGroup.setDeltaHeight(e),this.bodyGroup.setDeltaHeight(e)),this.updateTableSize(),this.component.updateScrollBar(),this.updateNextFrame()}setColWidth(t,e){const i=this.table.getColWidth(t);i!==e&&this.updateColWidth(t,e-i)}setRowHeight(t,e){const i=this.table.getRowHeight(t);this.updateRowHeight(t,e-i)}setX(t){this.table.scenegraph.proxy.setX(-t)}setY(t){this.table.scenegraph.proxy.setY(-t)}setBodyAndRowHeaderY(t){this.colHeaderGroup.attribute.height+t!==this.bodyGroup.attribute.y&&(this.bodyGroup.setAttribute("y",this.colHeaderGroup.attribute.height+t),this.rowHeaderGroup.setAttribute("y",this.colHeaderGroup.attribute.height+t),this.table.rightFrozenColCount>0&&this.rightFrozenGroup.setAttribute("y",this.colHeaderGroup.attribute.height+t),this.updateNextFrame())}setBodyAndColHeaderX(t){this.rowHeaderGroup.attribute.width+t!==this.bodyGroup.attribute.x&&(this.bodyGroup.setAttribute("x",this.rowHeaderGroup.attribute.width+t),this.colHeaderGroup.setAttribute("x",this.rowHeaderGroup.attribute.width+t),this.table.bottomFrozenRowCount>0&&this.bottomFrozenGroup.setAttribute("x",this.rowHeaderGroup.attribute.width+t),this.updateNextFrame())}afterScenegraphCreated(){this.dealWidthMode(),this.dealHeightMode(),this.dealFrozen(),this.createFrameBorder(),this.updateBorderSizeAndPosition(),this.component.updateScrollBar(),lR(this.table),this.updateNextFrame()}dealWidthMode(){const t=this.table;if("adaptive"===t.widthMode){const e=t.tableNoFrameWidth;let i=0;for(let e=0;e<t.colCount;e++)i+=t.getColWidth(e);const n=e/i;for(let i=0;i<t.colCount;i++){let r;r=i===t.colCount-1?e-t.getColsWidth(0,t.colCount-2):Math.round(t.getColWidth(i)*n),this.setColWidth(i,r)}}else if(t.autoFillWidth){const e=t.tableNoFrameWidth;let i=0,n=0;for(let e=0;e<t.colCount;e++){const r=t.getColWidth(e);e<t.frozenColCount&&(n+=r),i+=r}if(i<e&&i-n>0){const r=(e-n)/(i-n);for(let e=t.frozenColCount;e<t.colCount;e++)this.setColWidth(e,t.getColWidth(e)*r)}}let e=0;this.bodyGroup.forEachChildrenSkipChild((t=>{e+=t.attribute.width})),this.bodyGroup.setAttribute("width",e);let i=0;this.colHeaderGroup.forEachChildrenSkipChild((t=>{i+=t.attribute.width})),this.colHeaderGroup.setAttribute("width",i);let n=0;this.rowHeaderGroup.forEachChildrenSkipChild((t=>{n+=t.attribute.width})),this.rowHeaderGroup.setAttribute("width",n);let r=0;this.cornerHeaderGroup.forEachChildrenSkipChild((t=>{r+=t.attribute.width})),this.cornerHeaderGroup.setAttribute("width",r),this.colHeaderGroup.setAttribute("x",this.cornerHeaderGroup.attribute.width),this.rowHeaderGroup.setAttribute("y",this.colHeaderGroup.attribute.height),this.bodyGroup.setAttributes({x:this.rowHeaderGroup.attribute.width,y:this.colHeaderGroup.attribute.height})}dealHeightMode(){const t=this.table;if("adaptive"===t.heightMode){t._clearRowRangeHeightsMap();const e=t.tableNoFrameHeight-t.getFrozenRowsHeight()-t.getBottomFrozenRowsHeight();let i=0;for(let e=t.frozenRowCount;e<t.rowCount-t.bottomFrozenRowCount;e++)i+=t.getRowHeight(e);const n=e/i;for(let i=t.frozenRowCount;i<t.rowCount-t.bottomFrozenRowCount;i++){let r;r=i===t.rowCount-t.bottomFrozenRowCount-1?e-t.getRowsHeight(t.frozenRowCount,t.rowCount-t.bottomFrozenRowCount-2):Math.round(t.getRowHeight(i)*n),this.setRowHeight(i,r)}}}dealFrozen(){!function(t){if(t.table.frozenColCount>t.table.rowHeaderLevelCount){t.rowHeaderGroup.setAttribute("height",t.bodyGroup.attribute.height),t.rowHeaderGroup.setAttribute("y",t.bodyGroup.attribute.y),t.cornerHeaderGroup.setAttribute("height",t.colHeaderGroup.attribute.height);for(let e=0;e<t.table.frozenColCount-t.table.rowHeaderLevelCount;e++)uR(t),pR(t)}else if(t.table.frozenColCount<t.table.rowHeaderLevelCount)for(let e=0;e<t.table.rowHeaderLevelCount-t.table.frozenColCount;e++)fR(t),gR(t);t.bodyGroup.setAttribute("x",t.rowHeaderGroup.attribute.width),t.colHeaderGroup.setAttribute("x",t.cornerHeaderGroup.attribute.width),t.updateContainer(),t.updateBorderSizeAndPosition(),t.isPivot||t.transpose||t.component.setFrozenColumnShadow(t.table.frozenColCount-1),t.hasFrozen=!0,t.frozenColCount=t.table.frozenColCount,t.frozenRowCount=t.colHeaderGroup.firstChild?.childrenCount??0}(this)}resetFrozen(){!function(t){if(t.frozenColCount>t.table.rowHeaderLevelCount)for(let e=0;e<t.frozenColCount-t.table.rowHeaderLevelCount;e++)fR(t),gR(t);else if(t.frozenColCount<t.table.rowHeaderLevelCount){t.rowHeaderGroup.setAttribute("height",t.bodyGroup.attribute.height),t.rowHeaderGroup.setAttribute("y",t.bodyGroup.attribute.y),t.cornerHeaderGroup.setAttribute("height",t.colHeaderGroup.attribute.height);for(let e=0;e<t.table.rowHeaderLevelCount-t.frozenColCount;e++)uR(t),pR(t)}t.bodyGroup.setAttribute("x",t.rowHeaderGroup.attribute.width),t.colHeaderGroup.setAttribute("x",t.cornerHeaderGroup.attribute.width),t.updateContainer(),t.updateBorderSizeAndPosition(),t.isPivot||t.transpose||t.component.setFrozenColumnShadow(t.table.frozenColCount-1),t.hasFrozen=!0,t.frozenColCount=t.table.rowHeaderLevelCount,t.frozenRowCount=t.colHeaderGroup.firstChild?.childrenCount??0}(this)}updateCellLayoutWidthCertainWidth(t,e,i){const n=t.attribute.width;let r=!1;return t.forEachChildren(((t,o)=>{o+=e;const s=_w(this.table,i,o);s?t=this.getCell(s.start.col,s.start.row):t.setAttribute("width",n);const a=Gw(OC("padding",this.table._getCellStyle(i,o),i,o,this.table)),l=t.getChildByName("text");let h=0,c=0;if(l)h=l.AABBBounds.height()+(a[0]+a[2]),l.setAttribute("maxLineWidth",n-(a[1]+a[3])),c=l.AABBBounds.height()+(a[0]+a[2]);else{const e=t.getChildAt(1);h=e.AABBBounds.height()+(a[0]+a[2]),e._cellWidth=n-(a[1]+a[3]),e.layout(),c=e.AABBBounds.height()+(a[0]+a[2])}const d=this.table.getRowHeight(o);t.attribute.height!==c&&(t.setAttribute("height",c),(d===h||c>d)&&(r=!0))})),r}updateHeaderPosition(t,e,i,n){!function(t,e,i,n,r){const o=r.scenegraph,s=r.getCellType(i,n),a="columnHeader"===s?"column":"rowHeader"===s?"row":void 0;let l=0,h=0,c=0,d=0,u=0,p=0,f=0,g=0;if("column"===a){const o=_w(r,t,e),s=_w(r,i,n);o&&s?(l=o.start.col,c=o.end.col,u=s.start.col,f=s.end.col):(l=t,c=t,u=i,f=i),h=e,d=r.rowCount-1,p=n,g=r.rowCount-1}else if("row"===a){const o=_w(r,t,e),s=_w(r,i,n);o&&s?(h=o.start.row,d=o.end.row,p=s.start.row,g=s.end.row):(h=e,d=e,p=n,g=n),l=t,c=r.colCount-1,u=i,f=r.colCount-1}const y=Math.min(l,u),m=Math.max(c,f),b=Math.min(h,p),v=Math.max(d,g);for(let t=y;t<=m;t++){const e=r.scenegraph.getColGroup(t,!0),i=r.scenegraph.getColGroup(t);e&&e.setAttribute("width",r.getColWidth(t)),i&&i.setAttribute("width",r.getColWidth(t))}o.updateContainer();for(let t=y;t<=m;t++){const e=r.scenegraph.getColGroup(t);e?.setAttribute("chartInstance",void 0);for(let e=b;e<=v;e++)o.updateCellContent(t,e)}}(t,e,i,n,this.table)}updateContainer(){let t=0;this.cornerHeaderGroup.forEachChildrenSkipChild(((e,i)=>{e.setAttribute("x",t),t+=e.attribute.width}));let e=0;this.rowHeaderGroup.forEachChildrenSkipChild(((t,i)=>{t.setAttribute("x",e),e+=t.attribute.width}));let i=0;this.colHeaderGroup.forEachChildrenSkipChild(((t,e)=>{t.setAttribute("x",i),i+=t.attribute.width}));let n=0;this.bodyGroup.forEachChildrenSkipChild(((t,e)=>{t.setAttribute("x",n),n+=t.attribute.width})),this.cornerHeaderGroup.setDeltaWidth(t-this.cornerHeaderGroup.attribute.width),this.colHeaderGroup.setDeltaWidth(i-this.colHeaderGroup.attribute.width),this.rowHeaderGroup.setDeltaWidth(e-this.rowHeaderGroup.attribute.width),this.bodyGroup.setDeltaWidth(n-this.bodyGroup.attribute.width),this.colHeaderGroup.setAttribute("x",this.cornerHeaderGroup.attribute.width),this.bodyGroup.setAttribute("x",this.rowHeaderGroup.attribute.width),this.updateTableSize();const r=this.table.stateManeger.scroll.horizontalBarPos,o=this.table.stateManeger.scroll.verticalBarPos;this.component.updateScrollBar(),this.table.stateManeger.setScrollLeft(r),this.table.stateManeger.setScrollTop(o),this.updateNextFrame()}updateCellContentWhileResize(t,e){const i=this.table.getBodyColumnType(t,e),n=this.getCell(t,e);"image"!==i&&"video"!==i||zC(n,t,e,this.table)}createFrameBorder(){this.updateTableSize();const t=!this.isPivot;eS(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,this.bodyGroup.role,t?[!0,!0,!0,!1]:void 0),eS(this.rowHeaderGroup,this.isPivot?this.table.theme.rowHeaderStyle.frameStyle:this.table.theme.bodyStyle.frameStyle,this.rowHeaderGroup.role,t?[!0,!1,!0,!0]:void 0),eS(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,this.colHeaderGroup.role,t?[!0,!0,!0,!1]:void 0),eS(this.cornerHeaderGroup,this.isPivot?this.table.theme.cornerHeaderStyle.frameStyle:this.table.theme.headerStyle.frameStyle,this.cornerHeaderGroup.role,t?[!0,!1,!0,!0]:void 0),eS(this.tableGroup,this.table.theme.frameStyle,this.tableGroup.role,void 0)}getResizeColAt(t,e,i,n=8){if(i){if(t<i.globalAABBBounds.x1+n)return{col:i.col-1,row:i.row,x:i.globalAABBBounds.x1};if(i.globalAABBBounds.x2-n<t)return{col:i.col,row:i.row,x:i.globalAABBBounds.x2}}else;return{col:-1,row:-1}}updateIcon(t,e){Cx(e,t),t.name=e.name,this.updateNextFrame()}updateFrozen(){this.clear||(this.resetFrozen(),this.dealFrozen(),this.component.updateScrollBar())}updateBorderSizeAndPosition(){this.bodyGroup.border&&(this.bodyGroup.appendChild(this.bodyGroup.border),rS(this.bodyGroup),0===this.rowHeaderGroup.attribute.width?iS(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,[!0,!0,!0,!0]):iS(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,[!0,!0,!0,!1])),this.colHeaderGroup.border&&(this.colHeaderGroup.appendChild(this.colHeaderGroup.border),rS(this.colHeaderGroup),0===this.cornerHeaderGroup.attribute.width?iS(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,[!0,!0,!0,!0]):iS(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,[!0,!0,!0,!1])),this.rowHeaderGroup.border&&(this.rowHeaderGroup.appendChild(this.rowHeaderGroup.border),rS(this.rowHeaderGroup)),this.cornerHeaderGroup.border&&(this.cornerHeaderGroup.appendChild(this.cornerHeaderGroup.border),rS(this.cornerHeaderGroup))}updateSortIcon(t,e,i,n,r,o,s){const a=this.table.internalProps.headerHelper.getSortIcon(n,this.table,t,e);if(i&&this.updateIcon(i,a),s!==i){const t=this.table.internalProps.headerHelper.getSortIcon("normal",this.table,r,o);if(s)this.updateIcon(s,t);else{let e;this.getCell(r,o).forEachChildren((t=>"sort"===t.attribute.funcType&&(e=t,!0))),e&&this.updateIcon(e,t)}}}updateFrozenIcon(t,e){const i=Math.max(t,e);this.colHeaderGroup.forEachChildrenSkipChild((t=>!(t.col<=i)||(t.forEachChildren((t=>{t.forEachChildren((e=>{if("frozen"===e.attribute.funcType){const i=this.table.internalProps.headerHelper.getFrozenIcon(t.col,t.row);return this.updateIcon(e,i),!0}return!1}))})),!1))),this.cornerHeaderGroup.forEachChildrenSkipChild((t=>!(t.col<=i)||(t.forEachChildren((t=>{t.forEachChildren((e=>{if("frozen"===e.attribute.funcType){const i=this.table.internalProps.headerHelper.getFrozenIcon(t.col,t.row);return this.updateIcon(e,i),!0}return!1}))})),!1)))}sortCell(){this.isPivot||(this.transpose?setTimeout((()=>{this.clearCells(),this.createSceneGraph()}),10):this.proxy.sortCell())}getCellOverflowText(t,e){const i=this.getCell(t,e).getChildByName("text",!0);if(i){const t=Ot(i.attribute.text)?i.attribute.text.join(""):i.attribute.text;let e="";if(It(i.cache.clipedText)?e=i.cache.clipedText:i.cache.layoutData.lines.forEach((t=>{e+=t.str})),e!==t)return t}return null}updateDrill(t,e,i,n,r){this.component.drillIcon.update(t,e,i,n,r,this)}updateCellContent(t,e){if(!this.clear)return $M(t,e,this.table)}setPixelRatio(t){this.stage.disableDirtyBounds(),this.stage.window.setDpr(t),this.stage.render(),this.stage.enableDirtyBounds()}updateHierarchyIcon(t,e){const i=this.getCell(t,e);let n;n=this.table.isHeader(t,e)?this.table.internalProps.headerHelper.getHierarchyIcon(i.col,i.row):this.table.internalProps.bodyHelper.getHierarchyIcon(i.col,i.row),this.findAndUpdateIcon(i,[l.collapse,l.expand],n)}updateRow(t,e){oR(t,e,this.table),this.recalculateColWidths(),"autoHeight"===this.table.heightMode&&this.recalculateRowHeights(),this.table.stateManeger.checkFrozen(),this.updateNextFrame()}findAndUpdateIcon(t,e,i){t.forEachChildren((t=>{if("group"===t.type)this.findAndUpdateIcon(t,e,i);else if(-1!==e.indexOf(t.attribute.funcType))return this.updateIcon(t,i),!0;return!1}))}}function mR(t,e,i){e.forEachChildren((e=>{"group"===e.type?mR(t,e,i):e.attribute.visibleTime===i&&(e.attribute.visible=!0,t.updateNextFrame())}))}function bR(t,e,i){e.forEachChildren((e=>{"group"===e.type?bR(t,e,i):e.attribute.visibleTime===i&&(e.attribute.visible=!1,t.updateNextFrame())}))}function vR(t,e,i){const n=t.getCell(e,i);if("shadow-cell"===n.role){t.getCell(n.mergeCol,n.mergeRow).addUpdateBoundTag()}else n.addUpdateBoundTag()}function wR(t,e,i,n,r){const o=t.table;for(let i=0;i<o.columnHeaderLevelCount;i++)vR(t,e,i);const s=t.getColGroup(e);return s?.addUpdateBoundTag(),!0}function CR(t,e,i,n,r,o){const s=t.table;for(let i=0;i<s.columnHeaderLevelCount;i++)vR(t,e,i);const a=t.getColGroup(e);return a?.addUpdateBoundTag(),!0}function xR(t,e,i,n,r){const o=t.table;for(let e=0;e<o.colCount;e++)vR(t,e,i);return!0}function _R(t,e,i,n,r,o){const s=t.table;for(let e=0;e<s.colCount;e++)vR(t,e,i);return!0}function SR(t,e,n){const{table:r}=t,{scenegraph:o}=r,{highlightScope:s,singleStyle:a,disableHeader:l,cellPos:h,cellPosContainHeader:c}=t.hover,d=h.col,u=h.row;if(s===i.none||l&&(c.col!==e||c.row!==n)){const t=c.col,i=c.row;o.hideHoverIcon(t,i),o.showHoverIcon(e,n),c.col=e,c.row=n}if((l&&r.isHeader(e,n)||s===i.none)&&(e=-1,n=-1),d===e&&u===n)return;o.deactivateChart(d,u),o.activateChart(e,n);let p=!1;const{ranges:f,highlightScope:g}=t.select;if(-1!==d&&-1!==u&&(p=function(t,e,n,r,o,s,a){let l=!1;s===i.single?l=!!function(t,e,i,n,r){return vR(t,e,i),!0}(t,e,n)||l:s===i.row?l=!!xR(t,0,n)||l:s===i.column?l=!!wR(t,e)||l:s===i.cross&&(l=!!xR(t,0,n)||l,l=!!wR(t,e)||l);return l}(o,d,u,0,0,s),l||o.hideHoverIcon(d,u)),-1===e||-1===n)return h.col=-1,h.row=-1,void(p&&t.table.scenegraph.updateNextFrame());s===i.single?p=!!function(t,e,i,n,r){return vR(t,e,i),!0}(o,e,n)||p:s===i.row?p=!!_R(o,0,n)||p:s===i.column?p=!!CR(o,e)||p:s===i.cross&&(p=!!_R(o,0,n)||p,p=!!CR(o,e)||p),s===i.none||l||o.showHoverIcon(e,n),h.col=e,h.row=n,p&&t.table.scenegraph.updateNextFrame()}function AR(t,e,i){let n,r=null,o=!1;if(Array.isArray(i.sortState))for(let s=0;s<i.sortState.length&&(n=i.sortState[s],n&&(r=i._getHeaderCellBySortState(n)),r&&(o=TR(t,e,r.col,r.row,i)),!o);s++);else n=i.sortState,n&&(r=i._getHeaderCellBySortState(n)),r&&(o=TR(t,e,r.col,r.row,i));const s=i.getHeaderDefine(t,e);n&&o&&s?.sort?n.order="asc"===n.order?"desc":"desc"===n.order?"normal":"asc":s?.sort?n={fieldKey:i.getHeaderFieldKey(t,e),field:i.getHeaderField(t,e),order:"asc"}:o&&s?.showSort||(n={fieldKey:i.getHeaderFieldKey(t,e),field:i.getHeaderField(t,e),order:"normal"}),i.sortState=n,i.stateManeger.setSortState(n),s?.sort&&function(t,e,i){let n;n=t.fieldKey?e.internalProps.layoutMap.headerObjects.find((e=>e&&e.fieldKey===t.fieldKey)):e.internalProps.layoutMap.headerObjects.find((e=>e&&e.field===t.field));if(!n)return;const{field:r}=n;if(null===r)return;"function"==typeof i.sort?e.dataSource.sort(r,t.order||"asc",i.sort):e.dataSource.sort(r,t.order||"asc",M)}(n,i,s),i.scenegraph.sortCell(),i.stateManeger.updateSelectPos(-1,-1),i.fireListeners(yt.SORT_CLICK,n)}function TR(t,e,i,n,r){return r._getLayoutCellId(t,e)===r._getLayoutCellId(i,n)}const BR=it(yt,{PIVOT_SORT_CLICK:"pivot_sort_click",DRILLMENU_CLICK:"drillmenu_click"}),MR=it(yt,{VCHART_EVENT_TYPE:"vchart_event_type"});function RR(t){if(!("canMoveHeaderPosition"in t.table.internalProps.layoutMap))return;setTimeout((()=>{t.columnMove.moving=!1}),0);t.table.moveHeaderPosition({col:t.columnMove.colSource,row:t.columnMove.rowSource},{col:t.columnMove.colTarget,row:t.columnMove.rowTarget})&&(!function(t,e,i,n,r){const o=Math.min(t,i),s=Math.max(t,i),a=Math.min(e,n),l=Math.max(e,n);for(let t=o;t<=s;t++)r._clearColRangeWidthsMap(t);for(let t=a;t<=l;t++)r._clearRowRangeHeightsMap(t)}(t.columnMove.colSource,t.columnMove.rowSource,t.columnMove.colTarget,t.columnMove.rowTarget,t.table),t.table.clearCellStyleCache(),t.table.scenegraph.updateHeaderPosition(t.columnMove.colSource,t.columnMove.rowSource,t.columnMove.colTarget,t.columnMove.rowTarget)),t.updateCursor(),t.table.scenegraph.component.hideMoveCol(),t.table.scenegraph.updateNextFrame()}function PR(t){if(!t)return;const e=t.role?.startsWith("icon")?t:"richtext"===t.type?t._currentHoverIcon:void 0;return e?"richtext"===t.type?{icon:e,position:{left:t.globalAABBBounds.x1+e.globalAABBBounds.x1,right:t.globalAABBBounds.x1+e.globalAABBBounds.x2,top:t.globalAABBBounds.y1+e.globalAABBBounds.y1,bottom:t.globalAABBBounds.y1+e.globalAABBBounds.y2,width:e.globalAABBBounds.x2-e.globalAABBBounds.x1,height:e.globalAABBBounds.y2-e.globalAABBBounds.y1},type:"richtext-icon"}:{icon:e,position:{left:e.globalAABBBounds.x1,right:e.globalAABBBounds.x2,top:e.globalAABBBounds.y1,bottom:e.globalAABBBounds.y2,width:e.globalAABBBounds.x2-e.globalAABBBounds.x1,height:e.globalAABBBounds.y2-e.globalAABBBounds.y1},type:"icon"}:void 0}class ER{table;interactionState;select;hover;hoverIcon;residentHoverIcon;columnResize;columnMove;menu;sort;frozen;scroll;tablePosition;drill;sparkLine;_clearVerticalScrollBar;_clearHorizontalScrollBar;constructor(t){this.table=t,this.initState(),this.setHoverState(),this.setSelectState(),this.setFrozenState(),this.updateVerticalScrollBar=this.updateVerticalScrollBar.bind(this),this.updateHorizontalScrollBar=this.updateHorizontalScrollBar.bind(this)}initState(){this.interactionState=e.default,this.select={highlightScope:i.single,ranges:[],cellPos:{col:-1,row:-1},selecting:!1},this.hover={highlightScope:i.single,cellPos:{col:-1,row:-1}},this.hoverIcon={col:-1,row:-1,icon:null},this.columnResize={col:-1,x:0,resizing:!1},this.columnMove={colSource:-1,colTarget:-1,rowSource:-1,rowTarget:-1,x:0,y:0,moving:!1},this.menu={x:-1,y:-1,isShow:!1,itemList:[],bounds:new pe,highlightIndex:-1,dropDownMenuHighlight:[]},this.sort={col:-1,row:-1,order:"normal"},this.frozen={col:-1},this.scroll={horizontalBarPos:0,verticalBarPos:0},this.tablePosition={absoluteX:0,absoluteY:0},this.drill={col:-1,row:-1},this.sparkLine={col:-1,row:-1}}setHoverState(){const{highlightMode:t,disableHover:e,disableHeaderHover:n}=this.table.options.hover??{highlightMode:"cell"};e?this.hover.highlightScope=i.none:"cross"===t?this.hover.highlightScope=i.cross:"row"===t?this.hover.highlightScope=i.row:"column"===t?this.hover.highlightScope=i.column:"cell"===t&&(this.hover.highlightScope=i.single),this.hover.singleStyle=!e,this.hover.disableHeader=n,(this.hover.highlightScope===i.none||n)&&(this.hover.cellPosContainHeader={col:-1,row:-1})}setSelectState(){const{disableSelect:t,disableHeaderSelect:e}=this.table.options?.select??{disableSelect:!1,disableHeaderSelect:!1};this.select.highlightScope=t?i.none:i.single,this.select.singleStyle=!t,this.select.disableHeader=e}isSelected(t,e){let i=!1;return this.select.ranges.forEach((n=>{at(n,t,e)&&(i=!0)})),i}setSortState(t){this.sort.field=t.field,this.sort.fieldKey=t.fieldKey,this.sort.order=t.order}setFrozenState(){this.frozen.col=this.table.frozenColCount-1}updateInteractionState(t){this.interactionState!==t&&(this.interactionState=t)}updateHoverhighlightScope(t){this.hover.highlightScope!==t&&(this.hover.highlightScope=t)}updateHoverPos(t,e){SR(this,t,e)}updateSelectPos(t,i,n=!1,r=!1,o=!1){-1!==i&&-1!==i&&(this.select.selecting=!0),function(t,i,n,r,o,s){const{table:a,interactionState:l}=t,{scenegraph:h}=a,{highlightScope:c,disableHeader:d,cellPos:u}=t.select;if((d&&a.isHeader(i,n)||"none"===c)&&(i=-1,n=-1),u.col!==i||u.row!==n){if(-1!==i&&-1!==n&&t.select.ranges.length>0)if(l===e.grabing){const e=t.select.ranges[t.select.ranges.length-1];i>e.start.col&&i>e.end.col&&a._makeVisibleCell(i+1,n),n>e.start.row&&n>e.end.row&&a._makeVisibleCell(i,n+1),i<e.start.col&&i<e.end.col&&a._makeVisibleCell(i-1,n),n<e.start.row&&n<e.end.row&&a._makeVisibleCell(i,n-1)}else a._makeVisibleCell(i,n);if(s){t.select.ranges=[],h.deleteAllSelectBorder(),t.select.ranges.push({start:{col:0,row:0},end:{col:a.colCount-1,row:a.rowCount-1}});const e=t.select.ranges[t.select.ranges.length-1];h.updateCellSelectBorder(e.start.col,e.start.row,e.end.col,e.end.row)}else if(-1===u.col||-1===u.row||-1!==i&&-1!==n){if(l===e.default){const e=t.select.ranges[t.select.ranges.length-1];if(r&&e){if(a.isColumnHeader(i,n)){const t=Math.min(e.start.col,e.end.col,i),r=Math.max(e.start.col,e.end.col,i),o=Math.min(e.start.row,e.end.row,n),s=a.rowCount-1;e.start={col:t,row:o},e.end={col:r,row:s}}else if(a.isRowHeader(i,n)){const t=Math.min(e.start.col,e.end.col,i),r=a.colCount-1,o=Math.min(e.start.row,e.end.row,n),s=Math.max(e.start.row,e.end.row,n);e.start={col:t,row:o},e.end={col:r,row:s}}else e.end={col:i,row:n};h.deleteLastSelectedRangeComponents(),h.updateCellSelectBorder(e.start.col,e.start.row,e.end.col,e.end.row)}else{-1===u.col||-1===u.row||o||(t.select.ranges=[],h.deleteAllSelectBorder()),a.isColumnHeader(i,n)?t.select.ranges.push({start:{col:i,row:n},end:{col:i,row:a.rowCount-1}}):a.isRowHeader(i,n)?t.select.ranges.push({start:{col:i,row:n},end:{col:a.colCount-1,row:n}}):t.select.ranges.push({start:{col:i,row:n},end:{col:i,row:n}}),u.col=i,u.row=n;const e=t.select.ranges[t.select.ranges.length-1];h.updateCellSelectBorder(e.start.col,e.start.row,e.end.col,e.end.row)}}else if(l===e.grabing){-1===u.col&&(u.col=i),-1===u.row&&(u.row=n);const e=t.select.ranges[t.select.ranges.length-1];e.end={col:i,row:n},u.col=i,u.row=n,h.updateCellSelectBorder(e.start.col,e.start.row,i,n)}}else u.col=-1,u.row=-1,t.select.ranges=[],h.deleteAllSelectBorder();h.updateNextFrame()}}(this,t,i,n,r,o)}checkCellRangeInSelect(t,e){return function(t,e,i,n){for(let n=0;n<i.length;n++)if(ht(i[n],{start:t,end:e}))return!0;return!1}(t,e,this.select.ranges,this.select.highlightScope)}updateHoverIcon(t,e,i,n,r){if(i===this.residentHoverIcon?.icon)return;const o=PR(i);if(o)if("richtext-icon"===o.type){const i=o.icon;if(this.hoverIcon.icon&&this.hoverIcon.icon!==this.residentHoverIcon?.icon&&(this.table.scenegraph.setIconNormalStyle(this.hoverIcon.icon,this.hoverIcon.col,this.hoverIcon.row),this.hoverIcon.col=-1,this.hoverIcon.col=-1,this.hoverIcon.icon=null,this.table.scenegraph.updateNextFrame()),i.attribute.tooltip){const n={content:i.attribute.tooltip.title,referencePosition:{rect:o.position,placement:i.attribute.tooltip.placement},style:Object.assign({},this.table.internalProps.theme?.tooltipStyle,i.tooltip?.style)};this.table.internalProps.tooltipHandler.isBinded(n)||this.table.showTooltip(t,e,n)}}else{const i=o.icon;i!==this.hoverIcon.icon&&(this.hoverIcon.icon&&this.hoverIcon.icon!==this.residentHoverIcon?.icon&&this.table.scenegraph.setIconNormalStyle(this.hoverIcon.icon,this.hoverIcon.col,this.hoverIcon.row),this.hoverIcon.col=t,this.hoverIcon.col=e,this.hoverIcon.icon=i,this.table.scenegraph.setIconHoverStyle(i,t,e,n),this.table.scenegraph.updateNextFrame())}else this.hoverIcon.icon&&this.hoverIcon.icon!==this.residentHoverIcon?.icon&&(this.table.scenegraph.setIconNormalStyle(this.hoverIcon.icon,this.hoverIcon.col,this.hoverIcon.row),this.hoverIcon.col=-1,this.hoverIcon.col=-1,this.hoverIcon.icon=null,this.table.scenegraph.updateNextFrame())}isResizeCol(){return this.columnResize.resizing}isSelecting(){return this.select.selecting}endSelectCells(){if(this.select.selecting=!1,0===this.select.ranges.length)return;this.table.scenegraph.moveSelectingRangeComponentsToSelectedRangeComponents();const t=this.select.ranges[this.select.ranges.length-1].end.col,e=this.select.ranges[this.select.ranges.length-1].end.row;this.table.fireListeners(yt.SELECTED_CELL,{ranges:this.select.ranges,col:t,row:e})}endResizeCol(){setTimeout((()=>{this.columnResize.resizing=!1}),0),this.table.scenegraph.updateChartSize(this.columnResize.col),this.checkFrozen(),this.table.scenegraph.component.hideResizeCol(),this.table.scenegraph.updateNextFrame()}startResizeCol(t,e,i){this.columnResize.resizing=!0,this.columnResize.col=t,this.columnResize.x=e,this.table.scenegraph.component.showResizeCol(t,i),this.table.stateManeger.updateSelectPos(-1,-1),this.table.scenegraph.updateNextFrame()}updateResizeCol(t,e){t=Math.ceil(t),e=Math.ceil(e);let i=t-this.columnResize.x;if(Math.abs(i)<1)return;let n=this.table.colWidthsMap.get(this.columnResize.col);"number"==typeof n||(n=this.table.getColWidth(this.columnResize.col));let r=n;r+=i;const o=this.table.getMinColWidth(this.columnResize.col),s=this.table.getMaxColWidth(this.columnResize.col);if(r<o||r>s){if(n===o||n===s)return;i=n-o>s-n?s-n:o-n}i=Math.ceil(i),this.table.scenegraph.updateColWidth(this.columnResize.col,i),"adaptive"===this.table.widthMode&&this.columnResize.col<this.table.colCount-1&&this.table.scenegraph.updateColWidth(this.columnResize.col+1,-i),this.columnResize.x=t,this.table.scenegraph.component.updateResizeCol(this.columnResize.col,e),this.columnResize.col<this.table.frozenColCount&&!this.table.isPivotTable()&&!this.table.transpose&&this.table.scenegraph.component.setFrozenColumnShadow(this.table.frozenColCount-1),this.table.scenegraph.updateNextFrame()}startMoveCol(t,e,i,n){!function(t,e,i,n,r){if(!("canMoveHeaderPosition"in r.table.internalProps.layoutMap))return;r.columnMove.moving=!0,r.columnMove.colSource=t,r.columnMove.rowSource=e,r.columnMove.x=i-r.table.tableX,r.columnMove.y=n-r.table.tableY;const o=r.table.getCellType(t,e),s="columnHeader"===o?r.columnMove.x:"rowHeader"===o?r.columnMove.y:0;r.table.scenegraph.component.showMoveCol(t,e,s),r.table.stateManeger.updateSelectPos(-1,-1),r.table.scenegraph.updateNextFrame()}(t,e,i,n,this)}updateMoveCol(t,e,i,n){!function(t,e,i,n,r){if(!("canMoveHeaderPosition"in r.table.internalProps.layoutMap))return;const o=function(t,e,i){const n=i.getCellRange(t.col,t.row);if(i.isColumnHeader(t.col,t.row)){const r=i.getCellRange(e.col,n.start.row);e.row>=i.columnHeaderLevelCount&&(e.row=i.columnHeaderLevelCount-1),e.col>=t.col?e.col=r.end.col:e.col=r.start.col}else if(i.isRowHeader(t.col,t.row)){const r=i.getCellRange(n.start.col,e.row);e.col>=i.rowHeaderLevelCount&&(e.col=i.rowHeaderLevelCount-1);const o=i.internalProps.layoutMap;if("tree"===o.rowHierarchyType){const n=o.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths,r=o.getCellHeaderPathsWidthTreeNode(e.col,e.row).rowHeaderPaths;if(n.length<=r.length){const o=r[n.length-1];o&&(e.row>=t.row?e.row=o.startInTotal+o.size-1+i.columnHeaderLevelCount:e.row=o.startInTotal+i.columnHeaderLevelCount)}}else e.row>=t.row?e.row=r.end.row:e.row=r.start.row}return e}({col:r.columnMove.colSource,row:r.columnMove.rowSource},{col:t,row:e},r.table);let s,a,l,h;r.columnMove.x=i-r.table.tableX,r.columnMove.y=n-r.table.tableY,r.columnMove.colTarget=o.col,r.columnMove.rowTarget=o.row,r.table.internalProps.layoutMap.canMoveHeaderPosition({col:r.columnMove.colSource,row:r.columnMove.rowSource},{col:r.columnMove.colTarget,row:r.columnMove.rowTarget})?r.updateCursor("grabbing"):r.updateCursor("not-allowed");const c=r.table.getCellType(t,e);"columnHeader"===c?(a=r.columnMove.x,s=r.columnMove.colTarget>=r.columnMove.colSource?r.table.getColsWidth(0,r.columnMove.colTarget):r.table.getColsWidth(0,r.columnMove.colTarget-1)):"rowHeader"===c&&(h=r.columnMove.y,l=r.columnMove.rowTarget>=r.columnMove.rowSource?r.table.getRowsHeight(0,r.columnMove.rowTarget):r.table.getRowsHeight(0,r.columnMove.rowTarget-1)),r.table.scenegraph.component.updateMoveCol(a,s,h,l),r.table.scenegraph.updateNextFrame()}(t,e,i,n,this)}isMoveCol(){return this.columnMove.moving}endMoveCol(){RR(this)}checkFrozen(){if(this.table.options.frozenColCount){if(this.table.tableNoFrameWidth-this.table.getColsWidth(0,this.table.options.frozenColCount-1)<=120)return this.table._setFrozenColCount(0),this.setFrozenCol(-1),!1;if(this.table.frozenColCount!==this.table.options.frozenColCount)return this.table._setFrozenColCount(this.table.options.frozenColCount),this.setFrozenCol(this.table.options.frozenColCount),!1}return!0}setFrozenCol(t){t!==this.frozen.col?(this.frozen.col=t,this.table.scenegraph.updateFrozen(),this.table.scenegraph.updateFrozenIcon(0,this.table.colCount-1)):this.table.scenegraph.updateFrozenIcon(0,this.table.colCount-1)}updateVerticalScrollBar(t){const e=this.table.getAllRowsHeight();this.scroll.verticalBarPos=Math.ceil(t*(e-this.table.scenegraph.height)),this.table.scenegraph.setY(-this.scroll.verticalBarPos),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(yt.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}updateHorizontalScrollBar(t){const e=this.table.getAllColsWidth();this.scroll.horizontalBarPos=Math.ceil(t*(e-this.table.scenegraph.width)),this.table.scenegraph.setX(-this.scroll.horizontalBarPos),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(yt.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}setScrollTop(t){const e=this.table.getAllRowsHeight();t=Math.max(0,Math.min(t,e-this.table.scenegraph.height)),t=Math.ceil(t),this.scroll.verticalBarPos=t,this.table.scenegraph.setY(-t),this.table.scenegraph.component.updateVerticalScrollBarPos(t/(e-this.table.scenegraph.height)),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(yt.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}setScrollLeft(t){const e=this.table.getAllColsWidth(),i=this.table.getFrozenColsWidth();t=Math.max(0,Math.min(t,e-this.table.scenegraph.width)),t=Math.ceil(t),this.scroll.horizontalBarPos=t,this.table.scenegraph.setX(-t),this.table.scenegraph.component.updateHorizontalScrollBarPos(t/(e-i)),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(yt.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}hideVerticalScrollBar(){this.table.scenegraph.component.hideVerticalScrollBar()}showVerticalScrollBar(t){this.table.scenegraph.component.showVerticalScrollBar(),t&&(clearTimeout(this._clearVerticalScrollBar),this._clearVerticalScrollBar=setTimeout((()=>{this.table.scenegraph.component.hideVerticalScrollBar()}),1e3))}hideHorizontalScrollBar(){this.table.scenegraph.component.hideHorizontalScrollBar()}showHorizontalScrollBar(t){this.table.scenegraph.component.showHorizontalScrollBar(),t&&(clearTimeout(this._clearHorizontalScrollBar),this._clearHorizontalScrollBar=setTimeout((()=>{this.table.scenegraph.component.hideHorizontalScrollBar()}),1e3))}triggerContextMenu(t,e,i,n){this.menu.isShow&&this.menu.x===i&&this.menu.y===n?this.hideMenu():this.showContextMenu(t,e,i,n)}showContextMenu(t,e,i,n){this.table.internalProps.menu?.contextMenuItems&&("html"===this.table.internalProps.menu.renderMode?this.menu.isShow=!0:(this.menu.isShow=!0,this.menu.x=i,this.menu.y=n,this.table.scenegraph.component.menu.attach(i,n,t,e,X_.contextmenu)),this.table.fireListeners(yt.SHOW_MENU,{x:i,y:n,col:t,row:e,type:"contextmenu"}))}triggerDropDownMenu(t,e,i,n){this.table.fireListeners(yt.DROPDOWN_ICON_CLICK,{col:t,row:e}),this.menu.isShow?this.hideMenu():this.showDropDownMenu(t,e,i,n)}showDropDownMenu(t,e,i,n){"html"===this.table.internalProps.menu.renderMode?this.menu.isShow=!0:(this.menu.isShow=!0,this.table.scenegraph.component.menu.attach(i,n,t,e,X_.dropDown),this.menu.bounds=this.table.scenegraph.component.menu.bounds),this.table.fireListeners(yt.SHOW_MENU,{x:i,y:n,col:t,row:e,type:"dropDown"}),this.residentHoverIcon&&this.table.scenegraph.setIconNormalStyle(this.residentHoverIcon.icon,this.residentHoverIcon.col,this.residentHoverIcon.row);const r=this.table.scenegraph.getCell(t,e);let o;r.forEachChildren((t=>t.attribute.funcType===l.dropDown&&(o=t,!0))),o&&(this.residentHoverIcon={col:t,row:e,icon:o},this.table.scenegraph.setIconHoverStyle(this.residentHoverIcon.icon,this.residentHoverIcon.col,this.residentHoverIcon.row,r),o.oldVisibleTime=o.attribute.visibleTime,o.setAttribute("visibleTime","always"),o.setAttribute("visible",!0))}hideMenu(){this.table.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),this.table.fireListeners(yt.HIDE_MENU,null),this.menu.isShow=!1,this.table.scenegraph.component.menu.detach(),this.residentHoverIcon&&(this.table.scenegraph.setIconNormalStyle(this.residentHoverIcon.icon,this.residentHoverIcon.col,this.residentHoverIcon.row),this.residentHoverIcon.icon.setAttribute("visibleTime",this.residentHoverIcon.icon.oldVisibleTime),this.residentHoverIcon.icon.setAttribute("visible","always"===this.residentHoverIcon.icon.attribute.visibleTime),this.residentHoverIcon=null)}setDropDownMenuHighlight(t){this.menu.dropDownMenuHighlight=t;for(let e=0;e<t.length;e++){const{col:i,row:n}=t[e];this.table.scenegraph.updateCellContent(i,n)}}dropDownMenuIsHighlight(t,e,i){const n=this.menu.dropDownMenuHighlight;if(Array.isArray(n))for(let r=0;r<n.length;r++){const o=n[r];let{col:s,row:a}=o;const{field:l,menuKey:h}=o;if("number"!=typeof s||"number"!=typeof a)if(this.table.isPivotTable()&&(Array.isArray(l),1)){const t=this.table.internalProps.layoutMap.getPivotCellAdress(l);if(!t)continue;s=t.col,a=t.row}else{const t=this.table.internalProps.layoutMap.getHeaderCellAddressByField(l);if(!t)continue;s=t.col,a=t.row}if(A(s)&&A(a)&&this.table.isCellRangeEqual(t,e,s,a)){const n=this.table._getHeaderLayoutMap(s??t,a??e).dropDownMenu||this.table.globalDropDownMenu;if(n)for(let t=0;t<n.length;t++){const e=n[t];if(u(e)&&(e.menuKey||e.text)===(h||"")&&t===i)return!0;if(f(e)&&e===h&&t===i)return!0}}}return!1}triggerSort(t,e,i){if(this.table.isPivotTable()){const i=this.table.getPivotSortState(t,e);return void this.table.fireListeners(BR.PIVOT_SORT_CLICK,{col:t,row:e,order:i||"normal",dimensionInfo:this.table.internalProps.layoutMap.getPivotDimensionInfo(t,e),cellType:this.table.getCellType(t,e)})}const n=this.sort.col,r=this.sort.row;AR(t,e,this.table),this.sort.col=t,this.sort.row=e,this.table.scenegraph.updateSortIcon(this.sort.col,this.sort.row,i,this.sort.order,n,r,this.sort.icon),this.sort.icon=i}updateSortState(t){if(t.field===this.sort.field&&t.order===this.sort.order)return;const e=this.sort.col,i=this.sort.row,n="asc"===this.sort.order?"sort_downward":"desc"===this.sort.order?"sort_upward":"sort_normal";this.setSortState(t);const r=this.table.internalProps.layoutMap.getHeaderCellAddressByField(t.field);this.sort.col=r.col,this.sort.row=r.row;const o=this.table.scenegraph.getCell(this.sort.col,this.sort.row).getChildByName(n,!0);this.table.scenegraph.sortCell(),this.table.scenegraph.updateSortIcon(this.sort.col,this.sort.row,o,this.sort.order,e,i,this.sort.icon)}triggerFreeze(t,e,i){this.table.isPivotTable()||this.table.transpose||(!function(t,e,i){i.frozenColCount>0?t!==i.frozenColCount-1?i.setFrozenColCount(t+1):i.setFrozenColCount(0):i.setFrozenColCount(t+1)}(t,0,this.table),this.frozen.icon=i)}updateCursor(t="default"){this.table.getElement().style.cursor=t}updateDrillState(t,e,i,n,r,o){this.drill.dimensionKey=t,this.drill.dimensionTitle=e,this.drill.drillDown=i,this.drill.drillUp=n,this.drill.col=r,this.drill.row=o,function(t,e,i,n,r){const o=r.getCellType(t,e);let s=0,a=0,l=!1;"columnHeader"===o?(s=r.getColsWidth(0,r.rowHeaderLevelCount-1)-(0===r.frozenColCount?r.scrollLeft:0),a=r.getRowsHeight(0,e-1)+r.getRowHeight(e)/2,l=!0):"rowHeader"===o&&(a=r.getRowsHeight(0,r.columnHeaderLevelCount-1),s=r.getColsWidth(0,t-1)+r.getColWidth(t)/2,l=!0),r.scenegraph.updateDrill(l,s,a,i,n)}(r,o,i,n,this.table)}updateSparklineHoverPose(t,e,i,n){-1!==this.sparkLine.col&&-1!==this.sparkLine.row&&function(t,e,i){const n=i.scenegraph.getCell(t,e).getChildByName("sparkline"),r=n?.getChildByName("highlight-line"),o=n?.getChildByName("highlight-symbol");r&&r.setAttributes({visible:!1,pickable:!1}),o&&o.setAttributes({visible:!1,pickable:!1}),i.scenegraph.updateNextFrame()}(this.sparkLine.col,this.sparkLine.row,this.table),-1!==t&&-1!==e&&function(t,e,i,n,r){const o=r.scenegraph.getCell(t,e).getChildByName("sparkline"),s=o?.getChildByName("sparkline-line"),a=o?.getChildByName("sparkline-symbol-group");if(!s)return;const l=s.bandwidth,h=s.min,c=s.max,d=s.attribute.points;let u;i-=o.globalAABBBounds.x1,o.globalAABBBounds.y1;for(let t=0;t<d.length;t++){const{x:e,y:n,defined:r,rawData:p}=d[t];if(Math.abs(i-e)<l/2&&(u={point:d[t],points:d,pointsBandWidth:l,pointData:p},r)){const t=o.getChildByName("highlight-line");if(t)t.setAttributes({x:e,visible:!0,pickable:!0});else{const t=cu({x:e,y:0,points:[{x:0,y:c},{x:0,y:h}],lineWidth:s.hover.strokeWidth,stroke:s.hover.stroke});t.name="highlight-line",o.addChild(t)}const i=o.getChildByName("highlight-symbol");if(i)i.setAttributes({x:e,y:n,visible:!0,pickable:!0});else{const t=fu({x:e,y:n,stroke:a.hover.stroke,lineWidth:a.hover.strokeWidth,fill:a.hover.fill,size:2*a.hover.size,symbolType:"circle"});t.name="highlight-symbol",o.addChild(t)}break}}if(r.scenegraph.updateNextFrame(),u){const i={col:t,row:e,field:r.getHeaderField(t,e),value:r.getCellValue(t,e),dataValue:r.getCellOriginValue(t,e),cellHeaderPaths:r.internalProps.layoutMap.getCellHeaderPaths(t,e),caption:r.getBodyColumnDefine(t,e).caption,cellRange:r.getCellRelativeRect(t,e),sparkline:{pointData:u.pointData},scaleRatio:r.canvas.getBoundingClientRect().width/r.canvas.offsetWidth};r.fireListeners(yt.MOUSEOVER_CHART_SYMBOL,i)}}(t,e,i,0,this.table),this.sparkLine.col=t,this.sparkLine.row=e}}function HR(t){const e={abstractPos:{x:t.x,y:t.y}},i=function(t){for(;t&&t.parent;){if("cell"===t.role)return t;t=t.parent}return null}(t.target);return i&&(e.eventArgs={col:i.col,row:i.row,event:t,targetCell:i,target:t.target}),e}function kR(t,e){let{deltaX:i,deltaY:n}=t;t.shiftKey&&t.deltaY&&(i=n,n=0);const[r,o]=function(t,e,i){const n=2,r=Math.abs(t/e),o=r<=1/n?0:t,s=r>n?0:e;return[Math.ceil(o*i.horizontal),Math.ceil(s*i.vertical)]}(i,n,{horizontal:1,vertical:1});r&&(e.setScrollLeft(e.scroll.horizontalBarPos+r),e.showHorizontalScrollBar(!0)),o&&(e.setScrollTop(e.scroll.verticalBarPos+o),e.showVerticalScrollBar(!0)),t.cancelable&&(0!==n&&LR(n,e)||0!==i&&IR(i,e))&&t.preventDefault()}function LR(t,e){return!function(t,e){const i=e.table.getAllRowsHeight()-e.table.scenegraph.height;return 0!==i&&t<=0&&e.scroll.verticalBarPos<1}(t,e)&&!function(t,e){const i=e.table.getAllRowsHeight()-e.table.scenegraph.height;return 0!==i&&t>=0&&Math.abs(e.scroll.verticalBarPos-i)<1}(t,e)}function IR(t,e){return!function(t,e){const i=e.table.getAllColsWidth()-e.table.scenegraph.width;return 0!==i&&t<=0&&e.scroll.horizontalBarPos<1}(t,e)&&!function(t,e){const i=e.table.getAllColsWidth()-e.table.scenegraph.width;return 0!==i&&t>=0&&Math.abs(e.scroll.horizontalBarPos-i)<1}(t,e)}function OR(t){const e=t.table,i=e.stateManeger,n=e.scenegraph;t.touchMovePoints=[],e.scenegraph.tableGroup.addEventListener("touchstart",(e=>{e.target.isChildOf(n.component.vScrollBar)||e.target.isChildOf(n.component.vScrollBar)||(t.isTouchdown=!0,t.touchMovePoints.push({x:e.page.x,y:e.page.y,timestamp:Date.now()}))})),window.addEventListener("touchmove",(e=>{if(t.touchMove&&e.preventDefault(),!t.isTouchdown||!DR(e))return;t.touchMovePoints.length>4&&t.touchMovePoints.shift(),t.touchMovePoints.push({x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY,timestamp:Date.now()});const n=-t.touchMovePoints[t.touchMovePoints.length-1].x+t.touchMovePoints[t.touchMovePoints.length-2].x,r=-t.touchMovePoints[t.touchMovePoints.length-1].y+t.touchMovePoints[t.touchMovePoints.length-2].y;kR({deltaX:n,deltaY:r},i),e.cancelable&&(0!==r&&LR(r,i)||0!==n&&IR(n,i))&&e.preventDefault()}),{passive:!1}),window.addEventListener("touchend",(e=>{if(t.touchEnd=!0,t.touchMove=!1,t.isTouchdown&&DR(e)){if(t.touchMovePoints?.length){t.touchMovePoints.length>4&&t.touchMovePoints.shift(),t.touchMovePoints.push({x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY,timestamp:Date.now()});const n=t.touchMovePoints[0],r=t.touchMovePoints[t.touchMovePoints?.length-1];!function(t,e,i){let n=Date.now();const r=.95,o=()=>{const s=Date.now(),a=s-n;let l=!0;const h=Math.pow(r,a/16),c=h*t,d=h*e;let u=0,p=0;Math.abs(c)>.05&&(l=!1,u=(t+c)/2*a),Math.abs(d)>.05&&(l=!1,p=(e+d)/2*a),kR({deltaX:-u,deltaY:-p},i),l||(n=s,t=c,e=d,requestAnimationFrame(o))};requestAnimationFrame(o)}((r.x-n.x)/(r.timestamp-n.timestamp),(r.y-n.y)/(r.timestamp-n.timestamp),i)}t.isTouchdown=!1,t.touchMovePoints=[]}})),window.addEventListener("touchcancel",(e=>{t.touchEnd=!0,t.touchMove=!1,t.isTouchdown&&(t.isTouchdown=!1,t.touchMovePoints=[])}))}function DR(t){return!!t.changedTouches}class FR{table;isTouchdown;touchMovePoints;touchSetTimeout;touchEnd;touchMove;constructor(t){this.table=t,this.bindOuterEvent(),setTimeout((()=>{this.bindSelfEvent()}),0)}bindOuterEvent(){!function(t){const i=t.table,n=i.stateManeger;i.scenegraph.tableGroup.addEventListener("pointermove",(r=>{t.touchSetTimeout&&(clearTimeout(t.touchSetTimeout),t.touchSetTimeout=void 0);const o=HR(r);if(n.interactionState!==e.scrolling)if(n.interactionState!==e.grabing){if(t.checkColumnResize(o)?n.updateCursor("col-resize"):n.updateCursor(),i.hasListeners(yt.MOUSELEAVE_CELL)){const t=o?.eventArgs?.target;"cell"!==t?.role||-1===i.stateManeger.hover.cellPos.col||-1===i.stateManeger.hover.cellPos.row||t.col===i.stateManeger.hover.cellPos.col&&t.row===i.stateManeger.hover.cellPos.row||i.fireListeners(yt.MOUSELEAVE_CELL,{col:i.stateManeger.hover.cellPos.col,row:i.stateManeger.hover.cellPos.row,cellRange:i.getCellRangeRelativeRect({col:i.stateManeger.hover.cellPos.col,row:i.stateManeger.hover.cellPos.row}),scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth,event:r.nativeEvent})}if(i.hasListeners(yt.MOUSEENTER_CELL)){const t=o?.eventArgs?.target;"cell"===t?.role&&kt(t.col)&&kt(t.row)&&(t.col!==i.stateManeger.hover.cellPos.col||t.row!==i.stateManeger.hover.cellPos.row)&&i.fireListeners(yt.MOUSEENTER_CELL,{col:t.col,row:t.row,cellRange:i.getCellRangeRelativeRect({col:t.col,row:t.row}),scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth,event:r.nativeEvent})}if(t.dealIconHover(o),t.dealTableHover(o),o.eventArgs&&i.hasListeners(yt.MOUSEMOVE_CELL)){let t,e;if(o.eventArgs?.target){const i=PR(o.eventArgs?.target);i&&(t=i.icon,e=i.position)}i.fireListeners(yt.MOUSEMOVE_CELL,{col:o.eventArgs.col,row:o.eventArgs.row,x:o.abstractPos.x,y:o.abstractPos.y,event:r.nativeEvent,targetIcon:t?{name:t.name,position:e,funcType:t.attribute.funcType}:void 0})}}else n.isResizeCol()?(t.dealColumnResize(o),o.eventArgs&&i.hasListeners(yt.RESIZE_COLUMN)&&i.fireListeners(yt.RESIZE_COLUMN,{col:i.stateManeger.columnResize.col,colWidth:i.getColWidth(i.stateManeger.columnResize.col)})):n.isMoveCol()?t.dealColumnMover(o):t.dealTableSelect(o)})),i.scenegraph.tableGroup.addEventListener("pointerout",(e=>{const i=HR(e),n=i?.eventArgs?.target;"table"===n?.role&&t.dealTableHover()})),i.scenegraph.tableGroup.addEventListener("pointerover",(t=>{const e=HR(t),n=e?.eventArgs?.target;if(i.hasListeners(yt.MOUSEOVER_CHART_SYMBOL)&&"symbol"===n.type){const e=t.composedPath().find((t=>"cell"===t.roll));if(e){const{col:n,row:r}=e,o={col:n,row:r,field:i.getHeaderField(n,r),value:i.getCellValue(n,r),dataValue:i.getCellOriginValue(n,r),cellHeaderPaths:i.internalProps.layoutMap.getCellHeaderPaths(n,r),caption:i.getBodyColumnDefine(n,r).caption,cellRange:i.getCellRelativeRect(n,r),event:t.nativeEvent,sparkline:{pointData:void 0},scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth};i.fireListeners(yt.MOUSEOVER_CHART_SYMBOL,o)}}})),i.scenegraph.tableGroup.addEventListener("pointerleave",(r=>{n.updateInteractionState(e.default),t.dealTableHover(),n.updateCursor();const o=r.target;o&&!o.isDescendantsOf(i.scenegraph.tableGroup)&&i.fireListeners(yt.MOUSELEAVE_TABLE,{col:-1,row:-1,event:r.nativeEvent})})),i.scenegraph.tableGroup.addEventListener("pointerupoutside",(i=>{console.log("pointerupoutside"),n.updateInteractionState(e.default),t.dealTableHover(),t.dealTableSelect()})),i.scenegraph.tableGroup.addEventListener("pointerdown",(r=>{if(0!==r.button)return;const o=HR(r);if(n.interactionState===e.default){if(i.isPivotChart()&&"chart"!==o?.eventArgs?.target.type&&i.scenegraph.updateChartState(null),n.menu.isShow&&o.eventArgs&&o.eventArgs.target!==n.residentHoverIcon?.icon&&n.hideMenu(),!(o?.eventArgs?.target?.role?.startsWith("icon")?o.eventArgs.target:void 0))if("touch"===r.pointerType)t.touchEnd=!1,t.touchSetTimeout=setTimeout((()=>{t.isTouchdown=!1,t.touchMove=!0,(!t.touchEnd&&t.checkColumnResize(o,!0)||!t.touchEnd&&t.chechColumnMover(o)||t.dealTableSelect(o)&&!t.touchEnd)&&n.updateInteractionState(e.grabing)}),500);else{if(t.checkColumnResize(o,!0))return i.scenegraph.updateChartState(null),void n.updateInteractionState(e.grabing);if(t.chechColumnMover(o))return void n.updateInteractionState(e.grabing);t.dealTableSelect(o)&&n.updateInteractionState(e.grabing)}if(i.hasListeners(yt.MOUSEDOWN_CELL)){const t=HR(r);t.eventArgs&&i.fireListeners(yt.MOUSEDOWN_CELL,{col:t.eventArgs.col,row:t.eventArgs.row,event:r.nativeEvent})}}})),i.scenegraph.tableGroup.addEventListener("pointerup",(t=>{if(0===t.button){if("grabing"===n.interactionState){if(n.updateInteractionState(e.default),n.isResizeCol()){if(i.stateManeger.endResizeCol(),i.hasListeners(yt.RESIZE_COLUMN_END)){const t=[];for(let e=0;e<i.colCount;e++)t.push(i.getColWidth(e));i.fireListeners(yt.RESIZE_COLUMN_END,{col:i.stateManeger.columnResize.col,columns:t})}}else if(n.isMoveCol()){i.stateManeger.endMoveCol();const e=HR(t);e.eventArgs&&i.hasListeners(yt.CHANGE_HEADER_POSITION)&&i.fireListeners(yt.CHANGE_HEADER_POSITION,{target:{col:e.eventArgs.col,row:e.eventArgs.row},source:{col:i.stateManeger.columnMove.colSource,row:i.stateManeger.columnMove.colSource}})}else if(n.isSelecting()){i.stateManeger.endSelectCells();const e=HR(t);if(e.eventArgs&&i.hasListeners(yt.DRAG_SELECT_END)){const n={event:t.nativeEvent,cells:[],col:e.eventArgs.target.col,row:e.eventArgs.target.row,scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth};n.cells=i.getSelectedCellInfos(),i.fireListeners(yt.DRAG_SELECT_END,n)}}}else n.interactionState===e.scrolling&&n.updateInteractionState(e.default);if(i.hasListeners(yt.MOUSEUP_CELL)){const e=HR(t);e.eventArgs&&i.fireListeners(yt.MOUSEUP_CELL,{col:e.eventArgs.col,row:e.eventArgs.row,event:t.nativeEvent})}}})),i.scenegraph.tableGroup.addEventListener("rightdown",(t=>{const e=HR(t);if(e.eventArgs){n.triggerContextMenu(e.eventArgs.col,e.eventArgs.row,e.abstractPos.x,e.abstractPos.y);const{col:r,row:o}=e.eventArgs;if(i.hasListeners(yt.CONTEXTMENU_CELL)){const n=i.getCellInfo(r,o);let s,a;if(e.eventArgs?.target){const t=PR(e.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...n,event:t.nativeEvent,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};!function(t,e,i){for(let n=0;n<t.length;n++){const r=t[n];if(r.start.col<=e&&e<=r.end.col&&r.start.row<=i&&i<=r.end.row||r.end.col<=e&&e<=r.start.col&&r.end.row<=i&&i<=r.start.row)return!0}return!1}(i.stateManeger.select.ranges,r,o)?l.cells=[[n]]:l.cells=i.getSelectedCellInfos(),i.fireListeners(yt.CONTEXTMENU_CELL,l)}}})),i.scenegraph.tableGroup.addEventListener("click",(e=>{if(console.log("click",e.clone()),i.stateManeger.columnResize.resizing||i.stateManeger.columnMove.moving)return;const n=HR(e);if(t.dealIconClick(e,n),!n?.eventArgs)return;const{col:r,row:o}=n.eventArgs;if(i.hasListeners(yt.CLICK_CELL)){const t=i.getCellInfo(r,o);let s,a;if(n.eventArgs?.target){const t=PR(n.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...t,event:e.nativeEvent,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};i.fireListeners(yt.CLICK_CELL,l)}})),i.scenegraph.stage.addEventListener("click",(r=>{console.log("stage click");const o=r.target;o&&!o.isDescendantsOf(i.scenegraph.tableGroup)&&o!==i.scenegraph.tableGroup&&(console.log("pointerup outside table"),n.updateInteractionState(e.default),t.dealTableHover(),t.dealTableSelect(),n.updateCursor(),i.scenegraph.updateChartState(null))})),i.scenegraph.tableGroup.addEventListener("dblclick",(t=>{const e=HR(t),n=e.eventArgs.targetCell.globalAABBBounds,{col:r,row:o}=e.eventArgs,s=i.getCellValue(r,o);if(i.internalProps.focusControl.setFocusRect(new Re(n.x1+i.scrollLeft,n.y1+i.scrollTop,n.x2-n.x1,n.y2-n.y1),s),i.hasListeners(yt.DBLCLICK_CELL)){const n=i.getCellInfo(r,o);let s,a;if(e.eventArgs?.target){const t=PR(e.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...n,event:t.nativeEvent,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};i.fireListeners(yt.DBLCLICK_CELL,l)}}))}(this),function(t){const e=t.table,i=e.stateManeger,n=e.internalProps.handler;n.on(e.getElement(),"blur",(e=>{console.log("blur"),t.dealTableHover()})),n.on(e.getElement(),"wheel",(t=>{kR(t,i)})),n.on(e.getElement(),"keydown",(i=>{if(e.keyboardOptions?.selectAllOnCtrlA&&"a"===i.key&&(i.ctrlKey||i.metaKey)&&(i.preventDefault(),t.deelTableSelectAll()),e.hasListeners(yt.KEYDOWN)){const t={keyCode:i.keyCode??i.which,code:i.code,event:i,cells:e.getSelectedCellInfos(),scaleRatio:e.canvas.getBoundingClientRect().width/e.canvas.offsetWidth};e.fireListeners(yt.KEYDOWN,t)}})),n.on(e.getElement(),"copy",(t=>{if(e.keyboardOptions?.copySelected){const i=e.getCopyValue();kt(i)&&(t.preventDefault(),ct?window.clipboardData.setData("Text",i):t.clipboardData.setData("text/plain",i))}})),n.on(e.getElement(),"contextmenu",(t=>{t.preventDefault()})),n.on(e.getParentElement(),"resize",(()=>{e.resize()}))}(this),function(t){const i=t.table,n=i.stateManeger,r=i.scenegraph;r.component.vScrollBar.addEventListener("pointerover",(t=>{n.showVerticalScrollBar()})),r.component.hScrollBar.addEventListener("pointerover",(t=>{n.showHorizontalScrollBar()})),r.component.vScrollBar.addEventListener("pointerout",(t=>{n.interactionState!==e.scrolling&&n.hideVerticalScrollBar()})),r.component.hScrollBar.addEventListener("pointerout",(t=>{n.interactionState!==e.scrolling&&n.hideHorizontalScrollBar()})),r.component.vScrollBar._slider.addEventListener("pointerdown",(()=>{n.interactionState!==e.scrolling&&n.updateInteractionState(e.scrolling)})),r.component.vScrollBar.addEventListener("pointerup",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)})),r.component.vScrollBar.addEventListener("pointerupoutside",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)})),r.component.hScrollBar._slider.addEventListener("pointerdown",(()=>{n.interactionState!==e.scrolling&&n.updateInteractionState(e.scrolling)})),r.component.hScrollBar.addEventListener("pointerup",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)})),r.component.hScrollBar.addEventListener("pointerupoutside",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)}));const o=x(n.updateVerticalScrollBar,20),s=x(n.updateHorizontalScrollBar,20);r.component.vScrollBar.addEventListener("scroll",(t=>{const e=t.detail.value[0]/(1-t.detail.value[1]+t.detail.value[0]);o(e,t)})),r.component.hScrollBar.addEventListener("scroll",(t=>{const e=t.detail.value[0]/(1-t.detail.value[1]+t.detail.value[0]);s(e)}))}(this),OR(this)}bindSelfEvent(){const t=this.table.stateManeger;var e;this.table.listen(yt.ICON_CLICK,(e=>{const{col:i,row:n,x:r,y:o,funcType:s,icon:a}=e;var h;s===l.dropDown?t.triggerDropDownMenu(i,n,r,o):s===l.sort?t.triggerSort(i,n,a):s===l.frozen?t.triggerFreeze(i,n,a):s===l.drillDown?(h=this.table).fireListeners(BR.DRILLMENU_CLICK,h.stateManeger.drill):s!==l.collapse&&s!==l.expand||this.table.toggleHierarchyState(i,n)})),this.table.listen(yt.DROPDOWNMENU_CLICK,(()=>{t.hideMenu()})),function(t){const e=t.internalProps.layoutMap.headerObjects,i=t.internalProps.layoutMap.columnObjects;for(let t=0;t<e.length;t++){const i=e[t];if(i&&i.style?.textStick)return console.log("checkHaveTextStick",!0),!0}for(let t=0;t<i.length;t++){const e=i[t];if(e&&e.style?.textStick)return console.log("checkHaveTextStick",!0),!0}return console.log("checkHaveTextStick",!1),!1}(this.table)&&this.table.listen(yt.SCROLL,(t=>{lR(this.table)})),e=this.table,"browser"===vt.mode&&e.listen(yt.CLICK_CELL,(t=>{const{col:i,row:n}=t;let r;r=e.internalProps.layoutMap.isHeader(i,n)?e.isPivotTable()?e._getHeaderLayoutMap(i,n).headerType:e.getHeaderDefine(i,n).headerType:e.getBodyColumnType(i,n);const o=e.isHeader(i,n)?e.getHeaderDefine(i,n):e.getBodyColumnDefine(i,n),s=e.getCellValue(i,n),a=e.getCellOriginValue(i,n);if("link"===o.columnType){if(!1===o.linkJump)return;const t=o.templateLink,r=!1!==o.linkDetect;let l;if(t){const r=e.getCellOriginRecord(i,n),o=Object.assign({__value:s,__dataValue:a},r),h=/\{\s*(\S+?)\s*\}/g;l=t.replace(h,((t,e)=>o[e]))}else if(r){if(!De.test(s))return;l=s}else l=s;window.open(l)}else if("image"===r){const t=document.createElement("div");t.style.width="100%",t.style.height="100%",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.backgroundColor="rgba(30, 30, 30, 0.4)",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden",t.style.zIndex="9999",t.addEventListener("click",(e=>{e.target===t&&document.body.removeChild(t)}));const e=new Image;e.src=s,e.style.maxWidth="80%",e.style.maxHeight="80%",t.appendChild(e),document.body.appendChild(t)}else if("video"===r){const t=document.createElement("div");t.style.width="100%",t.style.height="100%",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.backgroundColor="rgba(30, 30, 30, 0.4)",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden",t.style.zIndex="9999",t.addEventListener("click",(e=>{e.target===t&&document.body.removeChild(t)}));const e=document.createElement("video");e.src=s,e.style.maxWidth="80%",e.style.maxHeight="80%",e.setAttribute("preload","auto"),e.setAttribute("controls","true"),t.appendChild(e),document.body.appendChild(t)}})),this.table.listen(yt.DBLCLICK_CELL,(t=>{this.table._canResizeColumn(t.col,t.row)&&this.table.scenegraph.updateAutoColWidth(t.col)})),this.table.isPivotTable()&&function(t){t.listen(yt.MOUSEENTER_CELL,(e=>{const{col:i,row:n}=e;if(-1===i||-1===n)return;const r=t.internalProps.layoutMap.getHeaderDimension(i,n);r?.drillDown||r?.drillUp?t.stateManeger.updateDrillState(r.dimensionKey,r.dimensionTitle,r.drillDown,r.drillUp,i,n):t.stateManeger.updateDrillState(void 0,void 0,!1,!1,-1,-1)}))}(this.table),function(t){let e=!1;e=t.isPivotTable()?t.internalProps.layoutMap.indicatorsDefine.some((t=>"string"!=typeof t&&"sparkline"===t.columnType)):t.internalProps.layoutMap.columnObjects.some((t=>"sparkline"===t.columnType));e&&(t.listen(yt.MOUSEMOVE_CELL,(e=>{const{col:i,row:n,x:r,y:o}=e;"sparkline"!==t.getBodyColumnType(i,n)&&t.stateManeger.updateSparklineHoverPose(-1,-1,0,0),t.stateManeger.updateSparklineHoverPose(i,n,r,o)})),t.listen(yt.MOUSELEAVE_TABLE,(e=>{t.stateManeger.updateSparklineHoverPose(-1,-1,0,0)})))}(this.table),function(t){t.isPivotChart()&&t.scenegraph.tableGroup.addEventListener("click",(e=>{if("axis-label"===e.target.name){const i=HR(e),{col:n,row:r}=i.eventArgs,o=t.internalProps.layoutMap;let s,a;o.indicatorsAsCol?(s=o.getDimensionKeyInChartSpec(o.rowHeaderLevelCount,r)[0],a=o.getCellHeaderPaths(o.rowHeaderLevelCount-2,r).rowHeaderPaths):(s=o.getDimensionKeyInChartSpec(n,o.columnHeaderLevelCount)[0],a=o.getCellHeaderPaths(n,o.columnHeaderLevelCount-1).colHeaderPaths);const l=a.map((t=>({key:t.dimensionKey,value:t.value}))).filter((t=>t.key));if(l.push({key:s,value:e.target.attribute.text}),t._selectedDimensionInChart.length&&function(t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(t[i].key!==e[i].key||t[i].value!==e[i].value)return!1;return!0}(t._selectedDimensionInChart,l))return;t._selectedDimensionInChart=l,o.updateDataStateToChartInstance(),dR(t.scenegraph),t.scenegraph.updateNextFrame()}else t._selectedDimensionInChart&&(t._selectedDimensionInChart.length=0,t.internalProps.layoutMap.updateDataStateToChartInstance(),dR(t.scenegraph),t.scenegraph.updateNextFrame())}))}(this.table)}dealTableHover(t){if(!t)return void this.table.stateManeger.updateHoverPos(-1,-1);const{eventArgs:e}=t;e?this.table.stateManeger.updateHoverPos(e.col,e.row):this.table.stateManeger.updateHoverPos(-1,-1)}dealIconHover(t){const{eventArgs:e}=t;e?this.table.stateManeger.updateHoverIcon(e.col,e.row,e.target,e.targetCell,e.event):this.table.stateManeger.updateHoverIcon(-1,-1,void 0,void 0)}dealMenuHover(t){}dealTableSelect(t){if(!t)return this.table.stateManeger.updateSelectPos(-1,-1),!1;const{eventArgs:e}=t;return!!e&&(this.table.isPivotChart()||"chart"===t?.eventArgs?.target.type||this.table.stateManeger.updateHoverPos(-1,-1),!this.table.isPivotChart()||"axis-label"!==t?.eventArgs?.target.name&&"chart"!==t?.eventArgs?.target.type?(this.table.stateManeger.updateSelectPos(e.col,e.row,e.event.shiftKey,e.event.ctrlKey||e.event.metaKey),!0):(this.table.stateManeger.updateSelectPos(-1,-1),!1))}deelTableSelectAll(){this.table.stateManeger.updateSelectPos(-1,-1,!1,!1,!0)}dealMenuSelect(t){}checkColumnResize(t,e){const{eventArgs:i}=t;if(i){const n=this.table.scenegraph.getResizeColAt(t.abstractPos.x,t.abstractPos.y,i.targetCell);if(this.table._canResizeColumn(n.col,n.row)&&n.col>=0)return e&&this.table.stateManeger.startResizeCol(n.col,t.abstractPos.x,t.abstractPos.y),!0}return!1}dealColumnResize(t){this.table.stateManeger.updateResizeCol(t.abstractPos.x,t.abstractPos.y)}chechColumnMover(t){const{eventArgs:e}=t;return!!(e&&this.table.isHeader(e.col,e.row)&&function(t,e,i){for(let n=0;n<i.length;n++)if(at(i[n],t,e))return!0;return!1}(e.col,e.row,this.table.stateManeger.select.ranges)&&this.table._canDragHeaderPosition(e.col,e.row))&&(this.table.stateManeger.startMoveCol(e.col,e.row,t.abstractPos.x,t.abstractPos.y),!0)}dealColumnMover(t){const{eventArgs:e}=t;this.table.stateManeger.updateMoveCol(e.col,e.row,t.abstractPos.x,t.abstractPos.y)}startColumnResize(t){}dealIconClick(t,e){const{eventArgs:i}=e,{target:n,event:r,col:o,row:s}=i||{target:t.target,event:t,col:-1,row:-1},a=n;if(a.role&&a.role.startsWith("icon-"))return this.table.fireListeners(yt.ICON_CLICK,{name:a.name,x:(a.globalAABBBounds.x1+a.globalAABBBounds.x2)/2,y:a.globalAABBBounds.y2,col:o,row:s,funcType:a.attribute.funcType,icon:a}),!0;if(n instanceof Cd){const t=n.pickIcon(r.global);if(t)return this.table.fireListeners(yt.ICON_CLICK,{name:t.attribute.id,x:t.globalX+t.globalAABBBounds.width()/2,y:t.globalY+t.AABBBounds.height(),col:o,row:s,funcType:t.attribute.funcType,icon:t}),!0}return!1}}let WR;const zR=t=>{const e=t.value;return Number(e)>80?"#20a8d8":Number(e)>50?"#4dbd74":Number(e)>20?"#ffc107":"#f86c6b"};class jR extends O{_showBar;_barColor;_barBgColor;_barPositiveColor;_barNegativeColor;_barAxisColor;_barHeight;_barBottom;_barPadding;_showBarMark;_barMarkPositiveColor;_barMarkNegativeColor;_barMarkWidth;_barMarkPosition;_barRightToLeft;static get DEFAULT(){return WR||(WR=new jR)}constructor(t={},e={}){super(t,e),this._showBar=t.showBar??!0,this._barColor=t.barColor??zR,this._barPositiveColor=t.barPositiveColor??"#4dbd74",this._barNegativeColor=t.barNegativeColor??"#f86c6b",this._barAxisColor=t.barAxisColor??"black",this._barBgColor=t.barBgColor,this._barHeight=t.barHeight??3,this._barHeight=t.barHeight??3,this._barBottom=t.barBottom??0,this._barPadding=t.barPadding??[1,1,1,1],this._showBarMark=t.showBarMark??!1,this._barMarkPositiveColor=t.barMarkPositiveColor??"#4dbd74",this._barMarkNegativeColor=t.barMarkNegativeColor??"#f86c6b",this._barMarkWidth=t.barMarkWidth??2,this._barMarkPosition=t.barMarkPosition??"right",this._barRightToLeft=t.barRightToLeft??!1}get showBar(){return this._showBar}set showBar(t){this._showBar=t}get barColor(){return this._barColor}set barColor(t){this._barColor=t}get barBgColor(){return this._barBgColor}set barBgColor(t){this._barBgColor=t}get barHeight(){return this._barHeight}set barHeight(t){this._barHeight=t}get barBottom(){return this._barBottom}set barBottom(t){this._barBottom=t}get barPositiveColor(){return this._barPositiveColor}set barPositiveColor(t){this._barPositiveColor=t}get barNegativeColor(){return this._barNegativeColor}set barNegativeColor(t){this._barNegativeColor=t}get barAxisColor(){return this._barAxisColor}set barAxisColor(t){this._barAxisColor=t}get barPadding(){return this._barPadding}set barPadding(t){this._barPadding=t}get showBarMark(){return this._showBarMark}set showBarMark(t){this._showBarMark=t}get barMarkPositiveColor(){return this._barMarkPositiveColor}set barMarkPositiveColor(t){this._barMarkPositiveColor=t}get barMarkNegativeColor(){return this._barMarkNegativeColor}set barMarkNegativeColor(t){this._barMarkNegativeColor=t}get barMarkWidth(){return this._barMarkWidth}set barMarkWidth(t){this._barMarkWidth=t}get barMarkPosition(){return this._barMarkPosition}set barMarkPosition(t){this._barMarkPosition=t}get barRightToLeft(){return this._barRightToLeft}set barRightToLeft(t){this._barRightToLeft=t}clone(){return new jR(this,null)}}const NR=["type","content","font","color","width","height","marginRight","marginLeft","src","svg","name","path","positionType","tooltip","hover","cursor","shape","interactive"];class GR{expandIcon;collapseIcon;_table;constructor(t){this._table=t;const e=kC();this.expandIcon=e[h.expandIconName],this.collapseIcon=e[h.collapseIconName]}getIcons(t,e,i,n,r){const o=[],{icon:s}=this._table.getBodyColumnDefine(t,e);if(s){let r;if("function"==typeof s){r=s({col:t,row:e,value:i,dataValue:n,table:this._table})}else r=s;const a=kC(),l=t=>{let e;e="string"==typeof t?a[t]:t,e&&o.push(e)};Array.isArray(r)?r.forEach(((t,e)=>{l(t)})):l(r)}const a=this.getHierarchyIcon(t,e);return a&&o.push(a),r&&o.forEach(((i,n)=>{(i.content||i.src)&&(o[n]=this.getCellIconFromRecordValue(i,t,e))})),o}getStyleClass(t){switch(t){case"text":case"link":return F;case"image":case"video":return D;case"chart":case"sparkline":return O;case"progressbar":return jR}}getCellIconFromRecordValue(t,e,i){if(Array.isArray(t))return t.map((t=>this.getCellIconFromRecordValue(t,e,i)));if(!dt.isObject(t)||"function"==typeof t)return this._table.getFieldData(t,e,i);const n={},r=t;return NR.forEach((t=>{if(void 0!==r[t]){const o=this._table.getFieldData(r[t],e,i);null!=o?n[t]=o:this._table._hasField(r[t],e,i)||(n[t]=r[t])}})),n}getHierarchyIcon(t,e){const i=this._table.getHierarchyState(t,e);return i===r.expand?this.expandIcon:i===r.collapse?this.collapseIcon:void 0}}function KR(t,e){const i=document.createElement(t);return e&&i.classList.add(...e),i}!function(){const t=document.createElement("style");t.id="vtable-menu-styleSheet",t.textContent="\n@keyframes vtable__menu-element--shown-animation {\n\t0% {\n\t\topacity: 0;\n\t}\n\t100% {\n\t\topacity: 1;\n\t}\n}\n.vtable__menu-element {\n\tposition: absolute;\n\tbox-sizing: border-box;\n\tborder-radius: 4px;\n\tbackground-color: #fff;\n\tpadding: 6px 0;\n\t/* pointer-events: none; */\n\tuser-select: none;\n\tcolor: #000;\n\tmax-width: 300px;\n\tz-index: 99999;\n\tborder: #CCC 0.5px solid;\n\tcursor: default;\n\twidth: max-content;\n\tbox-shadow: 0px 8px 16px rgba(27, 31, 35, 0.12);\n}\n.vtable__menu-element--hidden {\n\topacity: 0;\n\t/* transform: translate(-50%, -50%); */\n\ttransition: opacity 75ms linear;\n\tz-index: -9999;\n}\n.vtable__menu-element--shown {\n\topacity: 1;\n\t/* transform: translate(-50%, -50%); */\n\tanimation: vtable__menu-element--shown-animation 150ms ease-out;\n}\n.vtable__menu-element__content {\n\tfont-family: Roboto;\n\tfont-size: 12px;\n\toverflow: hidden;\n\tdisplay: inline-block;\n\t/* height: 100%; */\n\tline-height: 30px;\n}\n.vtable__menu-element__item {\n\theight: 32px;\n\tpadding: 0px 12px;\n\tcursor: pointer;\n\tposition: relative;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: flex-start;\n}\n.vtable__menu-element__item:hover {\n\tbackground-color: rgba(27, 31, 35, 0.06);\n}\n.vtable__menu-element__icon{\n\t/* vertical-align: top; */\n\tdisplay: flex;\n\t/* line-height: 30px; */\n\tmargin-right: 6px;\n}\n.vtable__menu-element__no-event {\n\tpointer-events: none;\n}\n.vtable__menu-element--select {\n\tcolor: #2E68CF;\n}.vtable__menu-element--normal {\n\tcolor: rgba(20, 20, 20, 0.9);;\n}\n.vtable__menu-element__split {\n\theight: 0px;\n\tborder: 1px solid rgb(209, 213, 218);\n\tmargin: 5px 0;\n}\n.vtable__menu-element__title {\n\tcolor: rgb(149, 149, 149);\n}\n.vtable__menu-element__arrow {\n\tposition: absolute;\n\tright: 3px;\n\tfont-weight: bold;\n\tmargin-top: 1px;\n}\n.vtable__menu-element__item-text {\n\tmargin-right: 15px;\n}\n",document.body.appendChild(t)}();const UR="vtable__menu-element",VR=`${UR}__item`,$R=`${UR}__content`,XR=`${UR}--hidden`,YR=`${UR}--shown`,qR=`${UR}--normal`,ZR=`${UR}--select`,JR=`${UR}__icon`,QR=`${UR}__split`,tP=`${UR}__title`,eP=`${UR}__arrow`,iP=`${UR}__no-event`,nP=`${UR}__item-text`;function rP(){return KR("div",[UR,XR])}function oP(t,e,i,n,r,o){const s=t.getCellRange(n,r);for(let n=0;n<e.length;n++){const r=e[n];let{col:o,row:a}=r;const{field:l,menuKey:h}=r;if("number"!=typeof o||"number"!=typeof a)if(t.isPivotTable()&&(Array.isArray(l),1)){const e=t.internalProps.layoutMap.getPivotCellAdress(l);if(!e)continue;o=e.col,a=e.row}else{const e=t.internalProps.layoutMap.getHeaderCellAddressByField(l);if(!e)continue;o=e.col,a=e.row}if(A(o)&&A(a)&&at(s,o,a)&&i===h)return!0}return!1}class sP{_handler;_rootElement;_secondElement;_menuInstanceInfo;_showChildrenIndex;_mouseEnterSecondElement;constructor(t){this._handler=new xt,this._rootElement=rP(),this._secondElement=rP(),this._secondElement.sub=!0,this._showChildrenIndex=-1,this._rootElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._rootElement?.addEventListener("touchend",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(XR))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n),h=t._dropDownMenuIsHighlight(i,n,r);t.fireListeners(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(XR))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n),h=t._dropDownMenuIsHighlight(i,n,r);t.fireListeners(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("mousemove",(e=>{if(this._rootElement.classList.contains(XR))return;e.stopPropagation();const{hasChildren:i,dropDownIndex:n,col:r,row:o,sub:s}=e.target;if(i){this._showChildrenIndex=n;const i=this._secondElement;i?.classList.remove(XR),i?.classList.add(YR),i.innerHTML="";const s=this._menuInstanceInfo.content[n]?.children;for(let e=0;e<s.length;e++){const n=s[e],a=aP(n,!!t.stateManeger.menu.dropDownMenuHighlight&&oP(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof n?n?.menuKey||n?.text:n,r,o));a.col=r,a.row=o,a.dropDownIndex=e,"string"==typeof n?(a.text=n,a.menuKey=n):"object"==typeof n&&(a.text=n.text,a.menuKey=n.menuKey||n.text),a.sub=!0,a.sub=!0,i.appendChild(a)}const a=e.target.getBoundingClientRect();this._bindSecondElement(t,r,o,a.right,a.top)}else if(i&&this._showChildrenIndex===n){const t=this._secondElement;t?.classList.remove(XR),t?.classList.add(YR)}else!s&&this._secondElement?.classList.contains(YR)&&setTimeout((()=>{if(!0!==this._mouseEnterSecondElement){this._showChildrenIndex=-1;const t=this._secondElement;t?.classList.remove(YR),t?.classList.add(XR)}}),300)})),this._secondElement?.addEventListener("mousemove",(t=>{this._rootElement.classList.contains(XR)||t.stopPropagation()})),this._secondElement?.addEventListener("mouseenter",(t=>{this._mouseEnterSecondElement=!0})),this._secondElement?.addEventListener("mouseleave",(t=>{this._mouseEnterSecondElement=!1})),this._secondElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._secondElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._secondElement.classList.contains(XR))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n);let h=!1;this._menuInstanceInfo.content.forEach(((e,r)=>{if("object"==typeof e&&e.children&&e.children.length)for(let r=0;r<e.children.length;r++){const s=e.children[r];if(oP(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof s?s?.menuKey:s,i,n)&&o===("object"==typeof s?s?.menuKey:s))return void(h=!0)}})),t.fireListeners(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,cellHeaderPaths:t.isPivotTable()?t.getCellHeaderPaths(i,n):void 0,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()}))}get rootElement(){return this._rootElement}dispose(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler.dispose(),delete this._rootElement}bindToCell(t,e,i,n){const r=this._rootElement,o=this._secondElement;if(this._menuInstanceInfo=n,r?.classList.remove(YR),r?.classList.add(XR),o?.classList.remove(YR),o?.classList.add(XR),this._canBindToCell(t,e,i)){if(r.innerHTML="",Array.isArray(n.content)){const o=n.content;for(let n=0;n<o?.length;n++){const s=o[n];let a=!!t.stateManeger.menu.dropDownMenuHighlight&&oP(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof s?s?.menuKey||s?.text:s,e,i);if(t.stateManeger.menu.dropDownMenuHighlight&&"object"==typeof s&&Array.isArray(s.children)&&s.children.length)for(let n=0;n<s.children.length;n++){const r=s.children[n];if(oP(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof r?r?.menuKey||r?.text:r,e,i)){a=!0;break}}const l=aP(s,a);l.col=e,l.row=i,l.dropDownIndex=n,"string"==typeof s?(l.text=s,l.menuKey=s):"object"==typeof s&&(l.text=s.text,l.menuKey=s.menuKey||s.text,s.children?.length&&(l.hasChildren=!0)),r.appendChild(l)}}if(this._bindToCell(t,e,i,n.position,n.referencePosition))return r?.classList.add(YR),r?.classList.remove(XR),!0}else this.unbindFromCell();return!1}unbindFromCell(){const t=this._rootElement,e=this._secondElement;this._menuInstanceInfo=void 0,t?.parentElement&&(t.classList.remove(YR),t.classList.add(XR)),e?.parentElement&&(e.classList.remove(YR),e.classList.add(XR))}_canBindToCell(t,e,i){const n=t.getCellRangeRelativeRect({col:e,row:i}),r=t.getElement(),{top:o,bottom:s,left:a,right:l}=n,{frozenRowCount:h,frozenColCount:c}=t;if(i>=h&&h>0){if(s<t.getCellRangeRelativeRect({col:e,row:h-1}).bottom)return!1}else if(s<0)return!1;if(e>=c&&c>0){if(l<t.getCellRangeRelativeRect({col:c-1,row:i}).right)return!1}else if(l<0)return!1;const{offsetHeight:d,offsetWidth:u}=r;return!(d<o)&&!(u<a)}_bindToCell(t,e,i,n,r){const o=this._rootElement,s=t.getElement(),{width:a,height:l}=t.internalProps.element.getBoundingClientRect();if(o){o.parentElement!==s&&s.appendChild(o),o.style.left="0px";const e=.8*a;o.style.maxWidth=`${e}px`;const i=o.clientWidth,h=o.clientHeight;let c,d;return n?(c=n.x+t.tableX,d=n.y+t.tableY):r&&(c=r.rect.right-i+t.tableX,d=r.rect.bottom+t.tableY),d+h>l&&(d=l-h,c+=i-2),d<0&&(d/=2),o.style.top=`${d}px`,c<0?c=0:c+i>a&&(c=a-i),o.style.left=`${c}px`,!0}return!1}_bindSecondElement(t,e,i,n,r){const o=this._secondElement,s=this._rootElement,a=t.getElement(),{width:l,left:h,top:c}=t.internalProps.element.getBoundingClientRect(),{x:d,y:u,width:p}=s.getBoundingClientRect();if(o){o.parentElement!==a&&a.appendChild(o),o.style.left="0px";const t=.8*l;o.style.maxWidth=`${t}px`;const e=o.clientWidth,i=r-4-c,s=n-h;o.style.top=`${i}px`;let d=s;return d+e>l?d=d-e-p:d+=4,o.style.left=`${d}px`,!0}return!1}pointInMenuElement(t,e){const i=this._rootElement,{x:n,y:r,width:o,height:s}=i.getBoundingClientRect();if(t>n-5&&t<n+o+5&&e>r-5&&e<r+s+5)return!0;if(this._secondElement){const{x:n,y:r,width:o,height:s}=i.getBoundingClientRect();if(t>n-5&&t<n+o+5&&e>r-5&&e<r+s+5)return!0}return!1}}function aP(t,e){const i=KR("div",[VR,e?ZR:qR]);if("string"==typeof t){const e=KR("span",[$R,iP,nP]);e.innerHTML=t,i.appendChild(e)}else if("object"==typeof t){const n=t.type??"item";if("split"===n)return i?.classList.add(QR),i;if(t?.icon?.svg)if(De.test(t.icon.svg)){const e=new Image;t.icon.width?e.style.width=t.icon.width.toString()+"px":e.style.width="16px",t.icon.height?e.style.height=t.icon.height.toString()+"px":e.style.height="16px",e.src=t.icon.svg,i.appendChild(e)}else{const n=KR("span",[JR,iP]);n.innerHTML=e&&t.selectedIcon&&t.selectedIcon.svg?t.selectedIcon.svg:t.icon.svg,t.icon.width&&n.children[0].setAttribute("width",t.icon.width.toString()),t.icon.height&&n.children[0].setAttribute("height",t.icon.height.toString()),i.appendChild(n)}const r=KR("span",[$R,iP,nP]);if(r.innerHTML=t.text,i.appendChild(r),"title"===n)i?.classList.add(iP,tP);else if(t?.children?.length){const t=KR("span",[$R,iP,eP]);t.innerHTML=e?'<svg width="8" height="12" viewBox="0 0 10 17" fill="none" xmlns="http://www.w3.org/2000/svg" style="vertical-align: baseline"><path d="M1.78186 16.7729L0.300378 15.2915L6.8189 8.77295L0.300377 2.25443L1.78186 0.77295L9.78186 8.77295L1.78186 16.7729Z" fill="#2E68CF" fill-opacity="0.65"></path></svg>':'<svg width="8" height="12" viewBox="0 0 10 17" fill="none" xmlns="http://www.w3.org/2000/svg" style="vertical-align: baseline"><path d="M1.78186 16.7729L0.300378 15.2915L6.8189 8.77295L0.300377 2.25443L1.78186 0.77295L9.78186 8.77295L1.78186 16.7729Z" fill="#141414" fill-opacity="0.65"></path></svg>',i.appendChild(t)}}return i}let lP;class hP extends j{static get DEFAULT(){return lP||(lP=new hP)}constructor(t={},e={}){super(t,e),this.textAlign=(t.textAlign??e?.textAlign)||"center"}clone(){return new hP(this)}}class cP{normalIcon;upIcon;downIcon;freezeIcon;frozenIcon;frozenCurrentIcon;dropDownAbsoluteIcon;expandIcon;collapseIcon;_table;constructor(t){this._table=t;const e=kC();this.freezeIcon=e[h.freezeIconName],this.frozenIcon=e[h.frozenIconName],this.frozenCurrentIcon=e[h.frozenCurrentIconName],this.normalIcon=e[h.normalIconName],this.upIcon=e[h.upwardIconName],this.downIcon=e[h.downwardIconName],this.dropDownAbsoluteIcon=e[h.dropdownIconName],this.expandIcon=e[h.expandIconName],this.collapseIcon=e[h.collapseIconName]}getIcons(t,e){const i=[];if(this._table.isPivotTable()){const{showSort:n}=this._table.internalProps.layoutMap.getHeader(t,e);if(n){const n=this._table.getPivotSortState(t,e),r="asc"===n?this.downIcon:"desc"===n?this.upIcon:this.normalIcon;r&&i.push(r)}}else{const n=this._table.sortState;let r;r=void 0;const o=this._table.getCellRange(t,e);if(n)if(Array.isArray(n))for(let t=0;t<n.length;t++){const e=n[t],i=this._table._getHeaderCellBySortState(e);if(i&&at(o,i.col,i.row)){({order:r}=e);break}}else{const t=this._table._getHeaderCellBySortState(n);t&&at(o,t.col,t.row)&&({order:r}=n)}const s=this.getSortIcon(r,this._table,t,e);s&&i.push(s)}if(this._table.showFrozenIcon&&t<this._table.allowFrozenColCount){const n=this.getFrozenIcon(t,e);n&&i.push(n)}if(this.checkDropDownIcon(this._table,t,e)){const t=this.dropDownAbsoluteIcon;i.push(t)}const n=this.getDropDownStateIcons(this._table,t,e);n.length&&i.push(...n);const{captionIcon:r,headerIcon:o}=this._table._getHeaderLayoutMap(t,e);r&&i.push(r);const s=this.getHierarchyIcon(t,e);if(s&&i.push(s),o){let n;if("function"==typeof o){n=o({col:t,row:e,value:this._table.getCellValue(t,e),dataValue:this._table.getCellOriginValue(t,e),table:this._table})}else n=o;const r=kC(),s=t=>{let e;e="string"==typeof t?r[t]:t,e&&i.push(e)};Array.isArray(n)?n.forEach(((t,e)=>{s(t)})):s(n)}return i}getFrozenIcon(t,e){if(this._table.isPivotTable()||this._table.transpose)return null;const i=this._table.getHeaderDefine(t,e);if(i.columns&&i.columns.length>0)return null;let n=this.freezeIcon;return this._table.options.frozenColCount-1>t?n=this.frozenIcon:this._table.options.frozenColCount-1===t&&(n=this.frozenCurrentIcon),n}getSortIcon(t,e,i,n){const r="asc"===t?this.downIcon:"desc"===t?this.upIcon:this.normalIcon,o=e.getHeaderDefine(i,n);return!o||!o.showSort&&!o.sort||o.columns&&o.columns.length>0?null:r}getDropDownStateIcons(t,e,i){const n=t.getHeaderDefine(e,i),r=t._getHeaderLayoutMap(e,i),{dropDownMenu:o}=r,s=[];if(Array.isArray(o)&&o.length||Array.isArray(t.globalDropDownMenu)&&t.globalDropDownMenu.length&&!n?.columns?.length){const n=o||t.globalDropDownMenu;let r=-1,h=-1;for(let o=0;o<n.length;o++){const s=n[o];if("object"==typeof s&&s.children&&s.children.length)for(let n=0;n<s.children.length;n++){const a=s.children[n];if(t.stateManeger.menu?.dropDownMenuHighlight&&oP(t,t.stateManeger.menu?.dropDownMenuHighlight,"object"==typeof a?a?.menuKey:a,e,i)){r=o,h=n;break}}if(t._dropDownMenuIsHighlight(e,i,o)){r=o;break}}if(-1!==r){let e;e=-1!==h?(o||t.globalDropDownMenu)[r].children[h]:(o||t.globalDropDownMenu)[r],e.stateIcon&&(e.stateIcon.svg?s.push({type:"svg",name:e.stateIcon.src||e.stateIcon.svg,width:e.stateIcon.width||22,height:e.stateIcon.height||22,svg:e.stateIcon.svg,positionType:a.right,marginRight:0,funcType:l.dropDownState,interactive:!1}):e.stateIcon.src&&s.push({type:"image",name:e.stateIcon.src||e.stateIcon.svg,width:e.stateIcon.width||22,height:e.stateIcon.height||22,src:e.stateIcon.src,positionType:a.right,marginRight:0,funcType:l.dropDownState,interactive:!1}))}}return s}getDropDownIconRect(t,e,i){const n=this.downIcon.hover?.width??this.downIcon?.width??0,r=this.downIcon.hover?.height??this.downIcon?.height??0,o=t.right-2-n,s=t.right-2;let a;a="middle"===i?t.top+t.height/2-n/2:"top"===i?t.top+e/2:"bottom"===i?t.bottom-2*e:t.top;return{left:o,right:s,top:a,bottom:r+a,width:n,height:r}}getHierarchyIcon(t,e){const{hierarchyState:i}=this._table._getHeaderLayoutMap(t,e);if(i){if(i===r.expand)return this.expandIcon;if(i===r.collapse)return this.collapseIcon}}checkDropDownIcon(t,e,i){if(t.isPivotTable()){const n=t._getHeaderLayoutMap(e,i);if(Array.isArray(n.dropDownMenu)&&n.dropDownMenu.length)return!0}else{const n=t.getHeaderDefine(e,i);if(Array.isArray(n.dropDownMenu)&&n.dropDownMenu.length||(!Array.isArray(n.dropDownMenu)||0!==n.dropDownMenu.length)&&Array.isArray(t.globalDropDownMenu)&&t.globalDropDownMenu.length&&!n?.columns?.length)return!0}return!1}getStyleClass(t){switch(t){case"text":case"link":return G;case"image":case"video":return hP}}}class dP{_table;_tooltipElement;constructor(t){this._table=t}dispose(){this.unbindTooltipElement(),this._tooltipElement&&this._tooltipElement.dispose?.(),this._tooltipElement=void 0}_getTooltipElement(){return this._tooltipElement||(this._tooltipElement=this.createTooltipElementInternal()),this._tooltipElement}bindTooltipElement(t,e,i,n){return this._getTooltipElement().bindToCell(this._table,t,e,i,n)}moveTooltipElement(t,e,i,n){this._getTooltipElement().move(this._table,t,e,i,n)}unbindTooltipElement(){this._getTooltipElement().unbindFromCell()}locateTooltipElement(t,e,i,n,r){this._getTooltipElement()._locate(this._table,t,e,i,n,r)}}!function(){const t=document.createElement("style");t.id="vtable-tooltip-styleSheet",t.textContent="\n@keyframes vtable__bubble-tooltip-element--shown-animation {\n\t0% {\n\t\topacity: 0;\n\t}\n\t100% {\n\t\topacity: 1;\n\t}\n}\n.vtable__bubble-tooltip-element {\n\tposition: absolute;\n\t\n\tpointer-events: none;\n\tuser-select: none;\n\tmax-width: 300px;\n\tz-index: 99999;\n\n\tbackground: #FFFFFF;\n border: 1px solid #E6E8ED;\n box-sizing: border-box;\n border-radius: 4px;\n box-shadow: 0px 2px 4px rgb(27 31 35 / 8%);\n color: #141414;\n font-size: 13px;\n}\n.vtable__bubble-tooltip-element--hidden {\n\topacity: 0;\n\t/* transform: translate(-50%, -50%); */\n\ttransition: opacity 75ms linear;\n}\n.vtable__bubble-tooltip-element--shown {\n\topacity: 1;\n\t/* transform: translate(-50%, -50%); */\n\tanimation: vtable__bubble-tooltip-element--shown-animation 150ms ease-out;\n}\n.vtable__bubble-tooltip-element__content {\n\t/* font-size: .75rem; */\n\tpadding: 6px 8px;\n\tmin-height: 1em;\n\tline-height: 1.5;\n\twidth: 100%;\n\tdisplay: block;\n\twhite-space: pre-wrap;\n\tmargin: 0;\n\tbox-sizing: border-box;\n\toverflow: hidden;\n\tword-wrap: break-word;\n\tposition: relative;\n\tbackground-color: #FFF;\n\tz-index: 2;\n\tborder-radius: 4px\n}\n.vtable__bubble-tooltip-element__triangle {\n\t/* font-size: .75rem; */\n\tposition: absolute;\n\twidth: 10px;\n\theight: 10px;\n\tdisplay: block;\n\ttransform: rotate(45deg);\n transform-origin: 50% 50% 0;\n\tz-index: 1;\n\tbackground-color: #FFF;\n\tborder: 1px solid #E6E8ED;\n}\n",document.body.appendChild(t)}();const uP="vtable__bubble-tooltip-element",pP=`${uP}__content`,fP=`${uP}__triangle`,gP=`${uP}--hidden`,yP=`${uP}--shown`;class mP{_handler;_rootElement;_messageElement;_triangleElement;constructor(){this._handler=new xt;const t=this._rootElement=KR("div",[uP,gP]),e=KR("span",[pP]),i=KR("span",[fP]);t.appendChild(i),t.appendChild(e),this._messageElement=t.querySelector(`.${pP}`)||void 0,this._triangleElement=t.querySelector(`.${fP}`)||void 0}bindToCell(t,e,i,n,r){const o=this._rootElement,s=this._messageElement,a=this._triangleElement;if(o?.classList.remove(yP),o?.classList.add(gP),this._canBindToCell(t,e,i)){s.setAttribute("style",""),a.setAttribute("style",""),n?.className&&o.classList.add(n.className),n?.style?.bgColor&&(s.style.backgroundColor=n?.style?.bgColor),n?.style?.bgColor&&(a.style.backgroundColor=n?.style?.bgColor),a.style.display=!0===n?.style?.arrowMark?"block":"none",n?.style?.font&&(s.style.font=n?.style?.font),n?.style?.color&&(s.style.color=n?.style?.color),n?.style?.padding&&(s.style.padding=`${n?.style?.padding.join("px ")}px`),s&&(s.textContent=n?.content);if(this._bindToCell(t,e,i,n?.position,n?.referencePosition,r,n?.style?.arrowMark))return o?.classList.add(yP),o?.classList.remove(gP),!0}else this.unbindFromCell();return!1}dispose(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler?.dispose?.(),delete this._rootElement,delete this._messageElement}move(t,e,i,n,r){const o=this._rootElement;this._canBindToCell(t,e,i)?(this._bindToCell(t,e,i,n?.position,n?.referencePosition,r),o?.classList.add(yP),o?.classList.remove(gP)):this.unbindFromCell()}unbindFromCell(){const t=this._rootElement;t?.parentElement&&(t.classList.remove(yP),t.classList.add(gP))}_canBindToCell(t,e,i){const n=t.getCellRangeRelativeRect({col:e,row:i}),r=t.getElement(),{bottom:o,left:s,right:a}=n,{frozenRowCount:l,frozenColCount:h}=t;if(i>=l&&l>0){if(o<t.getCellRangeRelativeRect({col:e,row:l-1}).bottom)return!1}else if(o<0)return!1;if(e>=h&&h>0){if(a<t.getCellRangeRelativeRect({col:h-1,row:i}).right)return!1}else if(s<0)return!1;const{offsetHeight:c,offsetWidth:d}=r;return!(c<o)&&!(d<s)}_bindToCell(t,e,i,n,r,o,s){const a=this._rootElement,l=t.getCellRangeRelativeRect({col:e,row:i}),h=t.getElement(),c=t.internalProps.element.offsetWidth,{width:d}=l;if(a){let l,u;a.parentElement!==h&&h.appendChild(a),a.style.left="0px";const p=Math.min(.8*c,4*d);a.style.maxWidth=`${p}px`;const f=a.clientWidth,g=a.clientHeight;if(!n&&!r)return!1;{const a=this.getComputedPosition(t,e,i,n,r,o,s);u=a.x,l=a.y}a.style.left=`${u}px`,a.style.top=`${l}px`,B()&&(a.style.fontSize="11px");const{x1:y,x2:m,y1:b,y2:v}=t.stateManeger.menu.bounds,w=u,C=w+f,x=l,_=w+g;return!(t.stateManeger.menu.isShow&&y<C&&m>w&&v>x&&b<_)}return!1}getComputedPosition(t,e,i,r,o,s,a){const l=this._rootElement,h=t.getCellRangeRelativeRect({col:e,row:i}),{width:c,height:d}=t.internalProps.element.getBoundingClientRect(),{width:u}=h;let p,f;const g=Math.min(.8*c,4*u);l.style.maxWidth=`${g}px`;const y=l.clientWidth,m=l.clientHeight,b=a?6:0;if(r)f=r.x,p=r.y+b,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.top="-5px";else if(o){let e=o.placement??n.bottom;const i=o.rect.left+o.rect.width/2+t.tableX,r=o.rect.top+o.rect.height/2+t.tableY,a=o.rect.top+t.tableY,l=o.rect.bottom+t.tableY,h=o.rect.left+t.tableX,u=o.rect.right+t.tableX;let g=0;const v=()=>{g++,g>=4||(this.removeStyleFromTriangle(),e===n.top?(f=i-y/2,p=a-m-b,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.bottom="-5px",s&&p<0&&(e=n.right,v())):e===n.bottom?(f=i-y/2,p=l+b,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.top="-5px",s&&p+m>d&&(e=n.left,v())):e===n.left?(p=r-m/2,f=h-y-b,this._triangleElement.style.top="50%",this._triangleElement.style.marginTop="-5px",this._triangleElement.style.right="-5px",s&&f<0&&(e=n.top,v())):e===n.right&&(p=r-m/2,f=u+b,this._triangleElement.style.top="50%",this._triangleElement.style.marginTop="-5px",this._triangleElement.style.left="-5px",s&&f+y>c&&(e=n.bottom,v())))};v()}return s&&(f<0?f=0:f+l.offsetWidth>c&&(f=c-l.offsetWidth)),{x:f,y:p}}removeStyleFromTriangle(){this._triangleElement.style.left="",this._triangleElement.style.right="",this._triangleElement.style.top="",this._triangleElement.style.bottom="",this._triangleElement.style.marginLeft="",this._triangleElement.style.marginTop=""}_locate(t,e,i,n,r,o){const s=this.getComputedPosition(t,e,i,n,r,o),a=s.x,l=s.y;this._rootElement.style.left=`${a}px`,this._rootElement.style.top=`${l}px`}}class bP extends dP{createTooltipElementInternal(){return new mP}}const vP={"bubble-tooltip":function(t){return new bP(t)}};class wP{_table;_tooltipInstances;_attachInfo;confine;constructor(t,e){this._table=t,this._tooltipInstances={},this._bindTableEvent(t),this.confine=e}dispose(){const t=this._tooltipInstances;for(const e in t)t[e]?.dispose?.();delete this._tooltipInstances,this._attachInfo=null}_bindToCell(t,e,i){const n=this._attachInfo,r=this._getTooltipInstanceInfo(t,e);if(!n||r&&n.instance===r||(n.instance?.unbindTooltipElement(),this._attachInfo=null),!r)return;if(r&&r.bindTooltipElement(t,e,i,this.confine)){const n=this._table.getCellRange(t,e);this._attachInfo={range:n,instance:r,tooltipOptions:i}}}_move(t,e,i){const n=this._attachInfo;if(!n||!at(n.range,t,e))return;const{instance:r}=n;r?.moveTooltipElement(t,e,i,this.confine)}moveToPosition(t,e,i,n){const r=this._attachInfo;if(!r||!at(r.range,t,e))return;const{instance:o}=r;this._attachInfo.tooltipOptions.position=i,this._attachInfo.tooltipOptions.referencePosition=n,o?.locateTooltipElement(t,e,i,n,this.confine)}_unbindFromCell(){const t=this._attachInfo;if(!t)return;const{instance:e}=t;e?.unbindTooltipElement(),this._attachInfo=null}_isBindCell(t,e){const i=this._attachInfo;return!!i&&at(i.range,t,e)}_bindTableEvent(t){t.listen(yt.MOUSEENTER_CELL,(e=>{if(B())return;const{x1:i,x2:r,y1:o,y2:s}=t.stateManeger.menu.bounds;if(t.stateManeger.menu.isShow&&"number"==typeof e.x&&"number"==typeof e.y&&e.x>i&&e.x<r&&e.y>o&&e.y<s)return;const{col:a,row:l}=e;if((!e.related||!this._isBindCell(a,l))&&t.internalProps.tooltip?.isShowOverflowTextTooltip){const i=t.getCellOverflowText(a,l),r=t.getHeaderDescription(a,l),o=t.getCellRangeRelativeRect({col:a,row:l});let s;i&&(s={content:r?`${r}\n ${i}`:i,referencePosition:{placement:n.bottom,rect:o},style:{arrowMark:!1}}),r&&(s={content:r,referencePosition:{placement:n.bottom,rect:o},style:{arrowMark:!1}}),s&&this._bindToCell(e.col,e.row,s)}})),t.listen(yt.MOUSEMOVE_CELL,(e=>{if(!B()){if(this._attachInfo?.tooltipOptions?.referencePosition){const i=this._attachInfo.tooltipOptions.referencePosition,{event:n}=e,{left:r,right:o,top:s,bottom:a}=i.rect,l=t._getMouseAbstractPoint(n,!1);l&&l.x>=r-5&&l.x<=o+5&&l.y>=s-5&&l.y<=a+5||this._unbindFromCell()}this._attachInfo&&t.stateManeger.menu.isShow&&this._bindToCell(e.col,e.row)}})),t.listen(yt.MOUSELEAVE_CELL,(t=>{t.related&&this._isBindCell(t.related.col,t.related.row)||this._unbindFromCell()})),t.listen(yt.SELECTED_CELL,(t=>{this._isBindCell(t.col,t.row)&&this._unbindFromCell()})),t.listen(yt.SCROLL,(e=>{const i=this._attachInfo;if(i?.tooltipOptions&&i?.range?.start){const{col:e,row:n}=i.range.start,r=t.getCellRangeRelativeRect({col:e,row:n});i.tooltipOptions.referencePosition.rect=r,this._move(i.range.start.col,i.range.start.row,i.tooltipOptions)}}))}_getTooltipInstanceInfo(t,e){const i=this._table,n=this._tooltipInstances,r="bubble-tooltip";return n&&n[r]||n&&(n[r]=vP[r](i))}isBinded(t){return JSON.stringify(t)===JSON.stringify(this._attachInfo?.tooltipOptions)}}class CP{_table;_menuElement;constructor(t){this._table=t}dispose(){this.unbindMenuElement(),this._menuElement&&this._menuElement.dispose(),this._menuElement=void 0}_getMenuElement(){return this._menuElement||(this._menuElement=this.createMenuElementInternal()),this._menuElement}bindMenuElement(t,e,i){return this._getMenuElement().bindToCell(this._table,t,e,i)}unbindMenuElement(){this._getMenuElement().unbindFromCell()}pointInMenuElement(t,e){return this._getMenuElement().pointInMenuElement(t,e)}}const xP="vtable__menu-element",_P=`${xP}--hidden`,SP=`${xP}--shown`;class AP{_handler;_rootElement;_menuInstanceInfo;constructor(t){this._handler=new xt,this._rootElement=KR("div",[xP,_P]),this._rootElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._rootElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(_P))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n),h=t._dropDownMenuIsHighlight(i,n,r);t.fireListeners(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("mousemove",(t=>{this._rootElement.classList.contains(_P)||t.stopPropagation()}))}get rootElement(){return this._rootElement}dispose(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler.dispose(),delete this._rootElement}bindToCell(t,e,i,n){const r=this._rootElement;if(this._menuInstanceInfo=n,r?.classList.remove(SP),r?.classList.add(_P),this._canBindToCell(t,e,i)){r.innerHTML="",r.appendChild(n.content);if(this._bindCell(t,e,i,n.position,n.referencePosition))return r?.classList.add(SP),r?.classList.remove(_P),!0}else this.unbindFromCell();return!1}unbindFromCell(){const t=this._rootElement;this._menuInstanceInfo=void 0,t?.parentElement&&(t.classList.remove(SP),t.classList.add(_P))}_canBindToCell(t,e,i){const n=t.getCellRangeRelativeRect({col:e,row:i}),r=t.getElement(),{top:o,bottom:s,left:a,right:l}=n,{frozenRowCount:h,frozenColCount:c}=t;if(i>=h&&h>0){if(s<t.getCellRangeRelativeRect({col:e,row:h-1}).bottom)return!1}else if(s<0)return!1;if(e>=c&&c>0){if(l<t.getCellRangeRelativeRect({col:c-1,row:i}).right)return!1}else if(l<0)return!1;const{offsetHeight:d,offsetWidth:u}=r;return!(d<o)&&!(u<a)}_bindCell(t,e,i,n,r){const o=this._rootElement,s=t.getElement(),{width:a,height:l}=t.internalProps.element.getBoundingClientRect();if(o){o.parentElement!==s&&s.appendChild(o),o.style.left="0px";const t=.8*a;o.style.maxWidth=`${t}px`;const e=o.clientWidth,i=o.clientHeight;let h,c;return n&&(h=n.x,c=n.y),r&&(h=r.rect.right-e,c=r.rect.bottom),c+i>l&&(c=l-i,h+=e-2),c<0&&(c/=2),o.style.top=`${c}px`,h<0?h=0:h+e>a&&(h=a-e),o.style.left=`${h}px`,!0}return!1}pointInMenuElement(t,e){const i=this._rootElement,{x:n,y:r,width:o,height:s}=i.getBoundingClientRect();return t>n-5&&t<n+o+5&&e>r-5&&e<r+s+5}}class TP extends CP{createMenuElementInternal(){return new sP(this._table)}}let BP=class extends CP{createMenuElementInternal(){return new AP(this._table)}};const MP={"dropdown-menu":function(t){return new TP(t)},"context-menu":function(t){return new TP(t)},container:t=>new BP(t)};class RP{_table;_menuInstances;_attachInfo;constructor(t){this._table=t,this._menuInstances={},this._bindTableEvent(t)}dispose(){const t=this._menuInstances;for(const e in t)t[e].dispose();delete this._menuInstances,this._attachInfo=null}_bindToCell(t,e,i,n){const r=this._attachInfo,o=this._getMenuInstanceInfo(t,e,i,n);if(!r||o&&r.instance===o.instance||(r.instance?.unbindMenuElement(),this._attachInfo=null),!o)return;const{instance:s,info:a}=o;if(s&&s.bindMenuElement(t,e,a)){const i=this._table.getCellRange(t,e);this._attachInfo={range:i,instance:s}}}_unbindFromCell(){const t=this._attachInfo;if(!t)return;const{instance:e}=t;e?.unbindMenuElement(),this._attachInfo=null}_isBindToCell(t,e){const i=this._attachInfo;return!!i&&at(i.range,t,e)}pointInMenuElement(t,e){if(!this._attachInfo)return!1;const i=this._attachInfo,{instance:n}=i;return n.pointInMenuElement(t,e)}_bindTableEvent(t){t.listen(yt.DROPDOWN_ICON_CLICK,(t=>{this._attachInfo&&this._isBindToCell(t.col,t.row)?this._unbindFromCell():this._bindToCell(t.col,t.row,"dropdown-menu")})),t.listen(yt.DROPDOWN_MENU_CLEAR,(t=>{this._unbindFromCell()})),t.listen(yt.CONTEXTMENU_CELL,(e=>{if("html"===t.internalProps.menu?.renderMode){const i=t._getMouseAbstractPoint(e.event,!1);let n=null;i&&"function"==typeof t.internalProps.menu?.contextMenuItems?n=t.internalProps.menu.contextMenuItems(t.getHeaderField(e.col,e.row),e.row):i&&Array.isArray(t.internalProps.menu?.contextMenuItems)&&(n=t.internalProps.menu?.contextMenuItems),this._bindToCell(e.col,e.row,"context-menu",{content:n,position:{x:i.x,y:i.y}})}}))}_getMenuInstanceInfo(t,e,i,n){const r=this._table,o=this._menuInstances,s=function(t,e,i,n,r){const{lineHeight:o,textBaseline:s,textStick:a}=t._getCellStyle(e,i);let l=t.getCellRangeRelativeRect(t.getCellRange(e,i));a&&(l=t.getVisibleCellRangeRelativeRect({col:e,row:i}));let{left:h,right:c,bottom:d,top:u,width:p,height:f}=l;if(t.isHeader(e,i)&&({left:h,right:c,bottom:d,top:u,width:p,height:f}=t.internalProps.headerHelper.getDropDownIconRect(l,o,s||"middle")),r?.content)return{type:n,position:r.position,referencePosition:r.referencePosition??{rect:{left:h,right:c,top:u,bottom:d,width:p,height:f}},content:r.content};if("dropdown-menu"===n){const{dropDownMenu:r=t.globalDropDownMenu,pivotInfo:o}=t._getHeaderLayoutMap(e,i);return{type:n,referencePosition:{rect:{left:h,right:c,top:u,bottom:d,width:p,height:f}},content:r,pivotInfo:o}}return null}(r,t,e,i,n);if(!s)return null;return{instance:o&&o[i]||o&&(o[i]=MP[i](r)),type:i,info:s}}}class PP extends EventTarget{_table;_input;constructor(t,e){if(super(),this._table=t,"node"===vt.mode)return;const i=document.createElement("div");i.style.opacity="0",i.dataset.vtable="vtable",i.style.pointerEvents="none",i.classList.add("input-container");const n=this._input=document.createElement("input");i.appendChild(n),n.classList.add("table-focus-control"),n.dataset.vtable="vtable",n.readOnly=!0,e.appendChild(i)}focus(){this._input.focus({preventScroll:!0})}setFocusRect(t,e){const i=this._input;i.value=e,i.select();const n=t.top-this._table.scrollTop,r=t.left-this._table.scrollLeft;i.style.top=`${n.toFixed()}px`,i.style.left=`${r.toFixed()}px`,i.style.width=`${t.width.toFixed()}px`,i.style.height=`${t.height.toFixed()}px`}get input(){return this._input}dispose(){}}let EP=1;V?EP=1:(EP=Math.ceil(window.devicePixelRatio||1),EP>1&&EP%2!=0&&(EP+=1));const HP={orient:"bottom",position:"middle",padding:30,title:{visible:!1,padding:0,textStyle:{fontSize:14,fill:"#000000",fontWeight:"normal"},space:12},item:{visible:!0,spaceCol:10,spaceRow:10,padding:2,background:{state:{selectedHover:{fill:"gray",fillOpacity:.7},unSelectedHover:{fill:"gray",fillOpacity:.2}}},shape:{space:4,state:{unSelected:{fillOpacity:.5}}},label:{space:4,style:{fill:"#89909D",fontSize:14},state:{unSelected:{fillOpacity:.5}}}},allowAllCanceled:!1,visible:!0};function kP(t,e){const{title:i={},item:n={},pager:r={},background:o={},type:s,id:a,visible:l,orient:h,position:c,data:d,filter:u,regionId:p,regionIndex:f,seriesIndex:g,seriesId:y,padding:m,...b}=Zt({},HP,t),v=b;return i.visible&&(v.title=function(t){const e={...t};return Ut(t.style)||(e.textStyle=KS(t.style)),Ut(t.textStyle)||Zt(e.textStyle,KS(t.textStyle)),t.shape?.style&&KS(e.shape.style),t.background?.style&&KS(e.background.style),e}(i)),Ut(n.focusIconStyle)||KS(n.focusIconStyle),US(n.shape),US(n.label),US(n.value),US(n.background),xC(n.maxWidth)&&(n.maxWidth=Number(n.maxWidth.substring(0,n.maxWidth.length-1))*e.width/100),xC(n.width)&&(n.width=Number(n.width.substring(0,n.width.length-1))*e.width/100),xC(n.height)&&(n.height=Number(n.height.substring(0,n.height.length-1))*e.width/100),v.item=n,Ut(r.textStyle)||KS(r.textStyle),US(r.handler),v.pager=r,o.visible&&!Ut(o.style)&&(Zt(v,o.style),kt(o.padding)&&(v.padding=o.padding)),v}class LP{table;option;orient;visible;position;selectedData;legendComponent;constructor(t,e){this.table=e,this.option=$t(t),this.orient=t.orient??"left",this.visible=t.visible??!0,this.position=t.position??"middle",this.selectedData=t.defaultSelected??[],this.createComponent(),this.initEvent()}createComponent(){const t=this.getLegendAttributes({width:this.table.tableNoFrameWidth,height:this.table.tableNoFrameHeight}),e=new V_(Zt({},t,{defaultSelected:this.selectedData}));e.name="legend",this.legendComponent=e,this.table.scenegraph.stage.defaultLayer.appendChild(e);let i=isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,n=isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0;const r=this.table.tableNoFrameWidth,o=this.table.tableNoFrameHeight,s=Gw(t.padding??this.option.padding??10);let a=0,l=0;"left"===this.orient?(a=s[3],l=0,i+=s[1]+s[3]):"top"===this.orient?(a=0,l=s[0],n+=s[0]+s[2]):"right"===this.orient?(a=r-i-s[1],l=0,i+=s[1]+s[3]):"bottom"===this.orient&&(a=0,l=o-n-s[2],n+=s[0]+s[2]);const h="bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",c=this.position;let d=0,u=0;"horizontal"===h?d="middle"===c?(r-i)/2:"end"===c?r-i-s[1]:s[3]:u="middle"===c?(o-n)/2:"end"===c?o-n-s[2]:s[0],this.legendComponent.setAttributes({dx:d,dy:u,x:a,y:l}),"left"===this.orient?(this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(i),this.table.tableX=Math.ceil(i)):"top"===this.orient?(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(n),this.table.tableY=Math.ceil(n)):"right"===this.orient?this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(i):"bottom"===this.orient&&(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(n))}getLegendAttributes(t){return{layout:"bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",items:this.getLegendItems(),maxWidth:t.width,maxHeight:t.height,...kP(this.option,t)}}getLegendItems(){return this.option.data}initEvent(){this.legendComponent&&(this.legendComponent.addEventListener(j_.legendItemClick,(t=>{const e=Vt(t,"detail.currentSelected");this.table.scenegraph.updateNextFrame(),this.table.fireListeners(yt.LEGEND_ITEM_CLICK,{model:this,value:e,event:t})})),this.legendComponent.addEventListener(j_.legendItemHover,(t=>{const e=Vt(t,"detail");this.table.scenegraph.updateNextFrame(),this.table.fireListeners(yt.LEGEND_ITEM_HOVER,{model:this,value:e,event:t})})),this.legendComponent.addEventListener(j_.legendItemUnHover,(t=>{const e=Vt(t,"detail");this.table.scenegraph.updateNextFrame(),this.table.fireListeners(yt.LEGEND_ITEM_UNHOVER,{model:this,value:e,event:t})})))}getLegendBounds(){return{width:isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,height:isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0}}dispose(){this.legendComponent=null}}class IP{table;_titleOption;_titleComponent;_cacheAttrs;constructor(t,e){this.table=e,this._titleOption=t,this._titleComponent=this._createOrUpdateTitleComponent(this._getTitleAttrs())}_createOrUpdateTitleComponent(t){if(this._titleComponent)te(t,this._cacheAttrs)||this._titleComponent.setAttributes(t);else{const e=new $_(t);e.name="title",this.table.scenegraph.stage.defaultLayer.appendChild(e),this._titleComponent=e}let e=isFinite(this._titleComponent.AABBBounds.width())?this._titleComponent.AABBBounds.width():0;const i=isFinite(this._titleComponent.AABBBounds.height())?this._titleComponent.AABBBounds.height():0,n=(this.table.tableNoFrameWidth,this.table.tableNoFrameHeight,Gw(t.padding??this._titleOption.padding??10));return"left"===this._titleOption.orient?n[3]:"top"===this._titleOption.orient?n[0]:"right"===this._titleOption.orient?(n[1],e+=n[1]+n[3]):"bottom"===this._titleOption.orient&&n[2],"left"===this._titleOption.orient?(this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e),this.table.tableX=Math.ceil(e)):"top"===this._titleOption.orient?(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i),this.table.tableY=Math.ceil(i)):"right"===this._titleOption.orient?this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e):"bottom"===this._titleOption.orient&&(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i)),this._cacheAttrs=t,"right"!==this._titleOption.orient&&"bottom"!==this._titleOption.orient||this._titleComponent.setAttributes({x:this._titleOption.x??"right"===this._titleOption.orient?this.table.tableX+this.table.tableNoFrameWidth:this.table.tableX,y:this._titleOption.y??"bottom"===this._titleOption.orient?this.table.tableY+this.table.tableNoFrameHeight:this.table.tableY}),this._titleComponent}dispose(){this._titleComponent=null}_getTitleAttrs(){const t=Gw(this._titleOption.padding??10),e=this._titleOption.width??this.table.tableNoFrameWidth-t[1]-t[3];return{text:this._titleOption.text??"",subtext:this._titleOption.subtext??"",x:this._titleOption.x??"right"===this._titleOption.orient?this.table.tableX+this.table.tableNoFrameWidth:this.table.tableX,y:this._titleOption.y??"bottom"===this._titleOption.orient?this.table.tableY+this.table.tableNoFrameHeight:this.table.tableY,width:e,height:this._titleOption.height,minWidth:this._titleOption.minWidth,maxWidth:this._titleOption.maxWidth,minHeight:this._titleOption.minHeight,maxHeight:this._titleOption.maxHeight,padding:this._titleOption.padding,align:this._titleOption.align??"left",verticalAlign:this._titleOption.verticalAlign??"top",textStyle:{width:e,...this._titleOption.textStyle},subtextStyle:{width:e,...this._titleOption.subtextStyle}}}}const{toBoxArray:OP}=ft,{isTouchEvent:DP}=pt,FP=/^\$(\d+)\$(\d+)$/;!function(){const t=document.createElement("style");t.id="vtable-style-styleSheet",t.textContent="\n.vtable .input-container {\n\tposition: absolute;\n\ttop:0px;\n}\n.vtable .table-scrollable {\n\tposition: absolute;\n\toverflow: scroll;\n}\n.vtable .table-scrollable::-webkit-scrollbar-button{\n\tbackground-color: transparent;\n}\n.vtable .table-scrollable::-webkit-scrollbar-track-piece{\n\tbackground-color: transparent;\n}\n.vtable .table-scrollable::-webkit-scrollbar-corner {\n\tbackground-color: transparent;\n}\n.vtable .table-scrollable::-webkit-scrollbar-thumb {\n\tborder-radius : 4px;\n\tbackground-color : rgba(100, 100, 100, .5);\n}\n\n.vtable .table-scroll-end-point {\n\topacity: 0;\n\tposition: relative;\n}\n.vtable {\n\t/* 设置overflow: auto 应该是为了滚动条的某个问题 但设置了auto之后 dom的下拉菜单只能显示在vtable节点中 超出会截断;现在去掉auto 暂时滚动条的问题没有发现 */\n\t/* overflow: auto; */\n\tposition: relative;\n\twidth: 100%;\n\theight: 100%;\n\ttext-align: left;\n -webkit-font-smoothing:auto;\n}\n.vtable > canvas {\n\tposition: absolute;\n\twidth: 0;\n\theight: 0;\n}\n.vtable .table-focus-control {\n\tposition: relative !important;\n\twidth: 1px;\n\theight: 1px;\n\topacity: 0;\n\tpadding: 0;\n\tmargin: 0;\n\tbox-sizing: border-box;\n\tpointer-events: none;\n\tmax-width: 500px;\n\tmax-height: 500px;\n\tfloat: none !important;\n}\n.vtable input.table-focus-control::-ms-clear {\n\tvisibility: hidden;\n}\n.vtable input.table-focus-control.composition {\n\topacity: 1;\n\tmax-width: none;\n\tmax-height: none;\n}\n",document.body.appendChild(t)}();const WP={};class zP extends E{internalProps;showFrozenIcon=!0;showSort=!0;padding;globalDropDownMenu;tableNoFrameWidth;tableNoFrameHeight;tableX;tableY;_widthMode;_heightMode;_autoFillWidth;customRender;canvasWidth;canvasHeight;dataSet;scenegraph;stateManeger;eventManeger;_pixelRatio;bottomFrozenRowCount=0;rightFrozenColCount=0;static get EVENT_TYPE(){return yt}options;version="0.9.2-alpha.2";pagerConf;id=`VTable${Date.now()}`;headerStyleCache;bodyStyleCache;constructor(t={}){super();const{frozenColCount:e=0,defaultRowHeight:i=40,defaultHeaderRowHeight:n,defaultColWidth:r=80,defaultHeaderColWidth:o,widthMode:s="standard",heightMode:a="standard",autoFillWidth:l=!1,keyboardOptions:h,parentElement:c,columnResizeMode:d,dragHeaderMode:u,showFrozenIcon:p,allowFrozenColCount:f,padding:g,hover:y,menu:m,select:b,customRender:v,pixelRatio:w=EP}=t;this.options=t,this._widthMode=s,this._heightMode=a,this._autoFillWidth=l,this.customRender=v,this.padding={top:0,right:0,left:0,bottom:0},g&&("number"==typeof g?(this.padding.top=g,this.padding.left=g,this.padding.bottom=g,this.padding.right=g):(g.top&&(this.padding.top=g.top),g.bottom&&(this.padding.bottom=g.bottom),g.left&&(this.padding.left=g.left),g.right&&(this.padding.right=g.right))),this.tableNoFrameWidth=0,this.tableNoFrameHeight=0;const C=this.internalProps={};void 0!==p&&(this.showFrozenIcon=p),"number"==typeof f&&f<=0&&(this.showFrozenIcon=!1),C.handler=new xt,C.element=function(t){const e=document.createElement("div");e.setAttribute("tabindex","0"),e.classList.add("vtable"),e.style.outline="none",e.style.margin=`${t.top}px ${t.right}px ${t.bottom}px ${t.left}px`;const i=(e.offsetWidth||e.parentElement?.offsetWidth||1)-1,n=(e.offsetHeight||e.parentElement?.offsetHeight||1)-1;return e.style.width=i&&i-t.left-t.right+"px"||"0px",e.style.height=n&&n-t.top-t.bottom+"px"||"0px",e}(this.padding),C.focusControl=new PP(this,C.element),C.pixelRatio=w,C.canvas=document.createElement("canvas"),C.element.appendChild(C.canvas),C.context=C.canvas.getContext("2d"),C.frozenColCount=e,C.defaultRowHeight=i,C.defaultHeaderRowHeight=n??i,C.defaultColWidth=r,C.defaultHeaderColWidth=o??r,C.keyboardOptions=h,C.columnResizeMode=d,C.dragHeaderMode=u,C._rowHeightsMap=new St,C._rowRangeHeightsMap=new Map,C._colRangeWidthsMap=new Map,this.colWidthsMap=new St,this.colContentWidthsMap=new St,this.colWidthsLimit={},C.calcWidthContext={_:C,get full(){return this._.canvas.width/(this._.context.pixelRatio??window.devicePixelRatio)}},C.cellTextOverflows={},C.focusedTable=!1,C.theme=Qe.of(t.theme??Qe.DEFAULT),c?(c.innerHTML="",c.appendChild(C.element),this._updateSize()):this._updateSize(),this.options=t,C.theme=Qe.of(t.theme??Qe.DEFAULT),C.bodyHelper=new GR(this),C.headerHelper=new cP(this),C.autoWrapText=t.autoWrapText,C.allowFrozenColCount=t.allowFrozenColCount??C.colCount,C.limitMaxAutoWidth=t.limitMaxAutoWidth??450,this.dataSet=new _M,this.scenegraph=new yR(this),this.stateManeger=new ER(this),this.eventManeger=new FR(this),t.legends&&(C.legends=new LP(t.legends,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),t.title&&(C.title=new IP(t.title,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),C.tooltip=Object.assign({renderMode:"html",isShowOverflowTextTooltip:!1,confine:!0},t.tooltip),"html"===C.tooltip.renderMode&&(C.tooltipHandler=new wP(this,C.tooltip.confine)),C.menu=Object.assign({renderMode:"html"},t.menu),Array.isArray(t.menu?.dropDownMenuHighlight)&&this.setDropDownMenuHighlight(t.menu?.dropDownMenuHighlight),Array.isArray(t.menu?.defaultHeaderMenuItems)&&(this.globalDropDownMenu=t.menu.defaultHeaderMenuItems),"html"===C.menu.renderMode&&(C.menuHandler=new RP(this)),this.headerStyleCache=new Map,this.bodyStyleCache=new Map}throttleInvalidate=function(t,e){let i=null;return function(...n){i||(i=setTimeout((()=>{t.apply(this,n),i=null}),e))}}(this.invalidate.bind(this),200);getParentElement(){return this.options.parentElement}getElement(){return this.internalProps.element}get canvas(){return this.internalProps.canvas}resize(){this._updateSize(),this.scenegraph.resize()}get rowCount(){return this.internalProps.rowCount}set rowCount(t){this.internalProps.rowCount=t}get colCount(){return this.internalProps.colCount??0}set colCount(t){this.internalProps.colCount=t}get frozenColCount(){return this.internalProps.frozenColCount??0}set frozenColCount(t){t>=this.colCount&&(t=0),this.internalProps.frozenColCount=t,this.options.frozenColCount=t,this.tableNoFrameWidth-this.getColsWidth(0,t-1)<=120&&(this.internalProps.frozenColCount=0),this.stateManeger.setFrozenCol(this.internalProps.frozenColCount)}setFrozenColCount(t){t>=this.colCount&&(t=0),this.internalProps.frozenColCount=t,this.options.frozenColCount=t,this.tableNoFrameWidth-this.getColsWidth(0,t-1)<=120&&(this.internalProps.frozenColCount=0),this.stateManeger.setFrozenCol(this.internalProps.frozenColCount)}_setFrozenColCount(t){t>=this.colCount&&(t=0),this.internalProps.frozenColCount=t}_resetFrozenColCount(){this.options.frozenColCount&&(this.tableNoFrameWidth-this.getColsWidth(0,this.options.frozenColCount-1)<=120?this._setFrozenColCount(0):this.frozenColCount!==this.options.frozenColCount&&this._setFrozenColCount(this.options.frozenColCount))}get frozenRowCount(){return this.internalProps.frozenRowCount??0}set frozenRowCount(t){this.internalProps.frozenRowCount=t}get defaultRowHeight(){return this.internalProps.defaultRowHeight}set defaultRowHeight(t){this.internalProps.defaultRowHeight=t,this.options.defaultRowHeight=t}get defaultHeaderRowHeight(){return this.internalProps.defaultHeaderRowHeight}set defaultHeaderRowHeight(t){this.internalProps.defaultHeaderRowHeight=t,this.options.defaultHeaderRowHeight=t}get defaultColWidth(){return this.internalProps.defaultColWidth}set defaultColWidth(t){this.internalProps.defaultColWidth=t,this.options.defaultColWidth=t}get defaultHeaderColWidth(){return this.internalProps.defaultHeaderColWidth}set defaultHeaderColWidth(t){this.internalProps.defaultHeaderColWidth=t,this.options.defaultHeaderColWidth=t}get colWidthsMap(){return this.internalProps._colWidthsMap}set colWidthsMap(t){this.internalProps._colWidthsMap=t}get colContentWidthsMap(){return this.internalProps._colContentWidthsMap}set colContentWidthsMap(t){this.internalProps._colContentWidthsMap=t}get _colRangeWidthsMap(){return this.internalProps._colRangeWidthsMap}set _colRangeWidthsMap(t){this.internalProps._colRangeWidthsMap=t}get _rowRangeHeightsMap(){return this.internalProps._rowRangeHeightsMap}set _rowRangeHeightsMap(t){this.internalProps._rowRangeHeightsMap=t}get rowHeightsMap(){return this.internalProps._rowHeightsMap}set rowHeightsMap(t){this.internalProps._rowHeightsMap=t}get colWidthsLimit(){return this.internalProps._colWidthsLimit}set colWidthsLimit(t){this.internalProps._colWidthsLimit=t}get keyboardOptions(){return this.internalProps.keyboardOptions??null}set keyboardOptions(t){this.internalProps.keyboardOptions=t??void 0}get widthMode(){return this._widthMode}set widthMode(t){t!==this._widthMode&&(this._widthMode=t)}get heightMode(){return this._heightMode}set heightMode(t){t!==this._heightMode&&(this._heightMode=t)}get autoFillWidth(){return this._autoFillWidth}set autoFillWidth(t){t!==this._autoFillWidth&&(this._autoFillWidth=t)}_colWidthDefineToPxWidth(t){return MC(t)?TC(this,this._calculateAutoColWidthExpr()):TC(this,t)}_calculateAutoColWidthExpr(){const t=this.internalProps.calcWidthContext.full;let e=0;const i=[];let n=0;const r=[];for(let o=0;o<this.internalProps.colCount;o++){const s=this.getColWidthDefine(o),a=this._getColWidthLimits(o);if(MC(s))a&&(r.push(a),a.min&&(e+=a.min)),n++;else{let t=s;if(a){const i=TC(this,t),n=BC(a,i);i!==n&&(t=`${n}px`),e+=n}i.push(t)}if(e>t)return"0px"}if(r.length&&i.length){const e=(t-TC(this,`calc(${i.map((t=>"number"==typeof t?`${t}px`:t)).join(" + ")})`))/n;if(r.forEach((t=>{t.min&&e<t.min?(i.push(t.minDef),n--):t.max&&t.max<e&&(i.push(t.maxDef),n--)})),n<=0)return`${e}px`}if(i.length){const t=[];let e=0;return i.forEach((i=>{"number"==typeof i?e+=i:t.push(i)})),t.push(`${e}px`),`calc((100% - (${t.join(" + ")})) / ${n})`}return 100/n+"%"}_getColWidthLimits(t){const e=this.colWidthsLimit[t];if(!e)return null;const i={};return e.min&&(i.min=TC(this,e.min),i.minDef=e.min),e.max&&(i.max=TC(this,e.max),i.maxDef=e.max),i}_adjustColWidth(t,e){const i=this._getColWidthLimits(t);return Math.max(BC(i,e),0)}setPixelRatio(t){this.internalProps.pixelRatio=t,this.scenegraph.setPixelRatio(t)}_updateSize(){const{padding:t}=this;let e=0,i=0;if("browser"===vt.mode){const n=this.getElement(),r=n.parentElement?.offsetWidth??0,o=n.parentElement?.offsetHeight??0;n.style.width=r&&r-t.left-t.right+"px"||"0px",n.style.height=o&&o-t.top-t.bottom+"px"||"0px";const{canvas:s}=this.internalProps;e=s.parentElement?.offsetWidth??0,i=s.parentElement?.offsetHeight??0,this?.scenegraph?.stage?this.scenegraph.stage.window.resize(e,i):(s.style.width="",s.style.height="",s.width=e,s.height=i,s.style.width=`${e}px`,s.style.height=`${i}px`)}else"node"===vt.mode&&(e=this.canvasWidth-1,i=this.canvasHeight-1);const n=Math.floor(e-U(this.getTheme().scrollStyle)),r=Math.floor(i-U(this.getTheme().scrollStyle));if(this.internalProps.theme?.frameStyle){const t=OP(this.internalProps.theme.frameStyle?.borderLineWidth??[null]),e=OP(this.internalProps.theme.frameStyle?.shadowBlur??[0]);this.tableX=(t[3]??0)+(e[3]??0),this.tableY=(t[0]??0)+(e[0]??0),this.tableNoFrameWidth=n-((t[1]??0)+(e[1]??0))-((t[3]??0)+(e[3]??0)),this.tableNoFrameHeight=r-((t[0]??0)+(e[0]??0))-((t[2]??0)+(e[2]??0))}}get rowHierarchyType(){return"grid"}setColWidths(t){t.forEach(((t,e)=>this.setColWidth(e,t)))}getColsWidth(t,e){e=Math.min(e,this.colCount-1);const i=this._colRangeWidthsMap.get(`$${t}$${e}`);if(null!=i)return i;const n=this._colRangeWidthsMap.get(`$${t}$${e-1}`);if(null!=n){const i=this.colWidthsMap.get(e);let r;r=i?"adaptive"===this.widthMode||this.transpose?Number(i):this._adjustColWidth(e,this._colWidthDefineToPxWidth(i)):this.isRowHeader(e,0)||this.isCornerHeader(e,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[e]??this.internalProps.defaultColWidth:this.defaultHeaderColWidth:this.internalProps.defaultColWidth;const o=n+r;return t>=0&&e>=0&&!Number.isNaN(o)&&this._colRangeWidthsMap.set(`$${t}$${e}`,Math.round(o)),Math.round(o)}let r=0;for(let i=t;i<=e;i++)r+=this.isRowHeader(i,0)||this.isCornerHeader(i,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[i]??this.internalProps.defaultColWidth:this.defaultHeaderColWidth:this.internalProps.defaultColWidth;this.colWidthsMap.each(t,e,((t,e)=>{r+=("adaptive"===this.widthMode||this.transpose?Number(t):this._adjustColWidth(e,this._colWidthDefineToPxWidth(t)))-(this.isRowHeader(e,0)||this.isCornerHeader(e,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[e]??this.internalProps.defaultColWidth:this.defaultHeaderColWidth:this.internalProps.defaultColWidth)}));for(let i=t;i<=e;i++){if(this.colWidthsMap.has(i))continue;const t=this._adjustColWidth(i,this.internalProps.defaultColWidth);t!==this.internalProps.defaultColWidth&&(r+=t-this.internalProps.defaultColWidth)}return t>=0&&e>=0&&this._colRangeWidthsMap.set(`$${t}$${e}`,Math.round(r)),Math.round(r)}getRowHeight(t){return this.rowHeightsMap.get(t)?this.rowHeightsMap.get(t):this.isColumnHeader(0,t)||this.isCornerHeader(0,t)||this.isBottomFrozenRow(this.rowHeaderLevelCount,t)?Array.isArray(this.defaultHeaderRowHeight)?this.defaultHeaderRowHeight[t]??this.internalProps.defaultRowHeight:this.defaultHeaderRowHeight:this.internalProps.defaultRowHeight}setRowHeight(t,e,i){this.rowHeightsMap.put(t,Math.round(e)),i&&this._clearRowRangeHeightsMap(t)}fillRowsHeight(t,e,i){for(let n=t;n<=e;n++)this.rowHeightsMap.put(n,Math.round(i)),this._rowRangeHeightsMap.set(`$0$${n}`,Math.round((this._rowRangeHeightsMap.get("$0$"+(n-1))??0)+i))}getRowsHeight(t,e){const i=this._rowRangeHeightsMap.get(`$${t}$${e}`);if(null!=i)return i;const n=this._rowRangeHeightsMap.get(`$${t}$${e-1}`);if(null!=n){const i=Math.round(n+(this.rowHeightsMap.get(e)??(this.isColumnHeader(0,e)||this.isCornerHeader(0,e)?Array.isArray(this.defaultHeaderRowHeight)?this.defaultHeaderRowHeight[e]??this.internalProps.defaultRowHeight:this.defaultHeaderRowHeight:this.internalProps.defaultRowHeight)));return t>=0&&e>=0&&this._rowRangeHeightsMap.set(`$${t}$${e}`,Math.round(i)),i}let r=0;if("autoHeight"!==this.heightMode&&this.internalProps.layoutMap&&e>=this.columnHeaderLevelCount){for(let e=t;e<this.columnHeaderLevelCount;e++)r+=this.getRowHeight(e);r+=this.defaultRowHeight*(e-Math.max(this.columnHeaderLevelCount,t)+1)}else for(let i=t;i<=e;i++)r+=this.getRowHeight(i);return t>=0&&e>=0&&r>0&&this._rowRangeHeightsMap.set(`$${t}$${e}`,Math.round(r)),Math.round(r)}getColWidthDefine(t){const e=this.colWidthsMap.get(t);return"number"==typeof e&&e<=0?0:e||(this.isRowHeader(t,0)||this.isCornerHeader(t,0)||this.isRightFrozenColumn(t,this.columnHeaderLevelCount)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[t]??this.defaultColWidth:this.defaultHeaderColWidth:this.defaultColWidth)}getColWidth(t){const e=this.getColWidthDefine(t);return"adaptive"===this.widthMode&&"number"==typeof e||this.transpose&&"number"==typeof e?this._colWidthDefineToPxWidth(e):this._adjustColWidth(t,this._colWidthDefineToPxWidth(e))}setColWidth(t,e,i,n){this.colWidthsMap.put(t,"number"==typeof e?Math.round(e):e),i&&this._clearColRangeWidthsMap(t),n||this.stateManeger.checkFrozen()}_clearColRangeWidthsMap(t){if("number"!=typeof t)this._colRangeWidthsMap.clear();else{const e=this._colRangeWidthsMap.keys();for(const i of e){const e=FP.exec(i);if(e){const n=Number(e[1]),r=Number(e[2]);t>=n&&t<=r&&this._colRangeWidthsMap.delete(i)}}}}_clearRowRangeHeightsMap(t){if("number"!=typeof t)this._rowRangeHeightsMap.clear();else{const e=this._rowRangeHeightsMap.keys();for(const i of e){const e=FP.exec(i);if(e){const n=Number(e[1]),r=Number(e[2]);t>=n&&t<=r&&this._rowRangeHeightsMap.delete(i)}}}}_getColContentWidth(t){return Number(this.colContentWidthsMap.get(t))}_setColContentWidth(t,e){this.colContentWidthsMap.put(t,e)}getAllRowsHeight(){if(this.internalProps.rowCount<=0)return 0;return this.getRowsHeight(0,this.internalProps.rowCount-1)}getAllColsWidth(){if(this.internalProps.colCount<=0)return 0;return this.getColsWidth(0,this.internalProps.colCount-1)}getMaxColWidth(t){const e=this.colWidthsLimit[t];let i=(e&&e.max)??1/0;return"string"==typeof i&&(i=TC(this,i)),i}setMaxColWidth(t,e){(this.colWidthsLimit[t]||(this.colWidthsLimit[t]={})).max=e}getMinColWidth(t){const e=this.colWidthsLimit[t];let i=(e&&e.min)??0;return"string"==typeof i&&(i=TC(this,i)),i}setMinColWidth(t,e){(this.colWidthsLimit[t]||(this.colWidthsLimit[t]={})).min=e}getCellRect(t,e){const i=this.isFrozenCell(t,e);let n=this.getColsWidth(0,t-1)||0;const r=this.getColWidth(t);i&&i.col&&(n+=this.scrollLeft);let o=this.getRowsHeight(0,e-1);const s=this.getRowHeight(e);return i&&i.row&&(o+=this.scrollTop),new Re(Math.round(n),Math.round(o),Math.round(r),Math.round(s))}getMergeCellRect(t,e){const i=this.getCellRange(t,e),n=this.getColsWidth(0,i.start.col-1)||0,r=this.getColsWidth(i.start.col,i.end.col),o=this.getRowsHeight(0,i.start.row-1)||0,s=this.getRowsHeight(i.start.row,i.end.row);return new Re(Math.round(n),Math.round(o),Math.round(r),Math.round(s))}getCellRelativeRect(t,e){return this._toRelativeRect(this.getCellRect(t,e))}getCellRangeRelativeRect(t){if(t.start)return this._toRelativeRect(this.getCellsRect(t.start.col,t.start.row,t.end.col,t.end.row));const e=this.getCellRange(t.col,t.row);return this._toRelativeRect(this.getCellsRect(e.start.col,e.start.row,e.end.col,e.end.row))}getVisibleCellRangeRelativeRect(t){let e;return e=t.start?t:this.getCellRange(t.col,t.row),this._getVisiableRect(this.getCellRangeRelativeRect(t),e)}_getVisiableRect(t,e){const i=e.start.col>=this.frozenColCount?Math.max(t.left,this.frozenColCount>=1?this.getColsWidth(0,this.frozenColCount-1):0):t.left,n=Math.min(t.right,this.tableNoFrameWidth),r=t.copy();r.left=i,r.right=n;const o=e.start.row>=this.frozenRowCount?Math.max(t.top,this.frozenRowCount>=1?this.getRowsHeight(0,this.frozenRowCount-1):0):t.top,s=Math.min(t.bottom,this.tableNoFrameHeight);return r.top=o,r.bottom=s,r}getCellsRect(t,e,i,n){const r=this.isFrozenCell(t,e),o=this.isFrozenCell(i,n);let s=this.getColsWidth(0,t-1)||0,a=this.getColsWidth(t,i);if(r&&r.col){const e=this.scrollLeft;s+=e,o&&o.col||(a-=e,a=Math.max(a,this.getColsWidth(t,this.frozenColCount-1)))}let l=this.getRowsHeight(0,e-1),h=this.getRowsHeight(e,n);if(r&&r.row){const t=this.scrollTop;l+=t,o&&o.row||(h-=t,h=Math.max(h,this.getRowsHeight(e,this.frozenRowCount-1)))}return new Re(Math.round(s),Math.round(l),Math.round(a),Math.round(h))}getCellsRectWidth(t,e,i,n){const r=this.isFrozenCell(t,e),o=this.isFrozenCell(i,n);let s=this.getColsWidth(t,i);if(r&&r.col){const e=this.scrollLeft;o&&o.col||(s-=e,s=Math.max(s,this.getColsWidth(t,this.frozenColCount-1)))}return s}getCellRangeRect(t){if(t.start)return this.getCellsRect(t.start.col,t.start.row,t.end.col,t.end.row);const e=this.getCellRange(t.col,t.row);return this.getCellsRect(e.start.col,e.start.row,e.end.col,e.end.row)}getCellRangeRectWidth(t){if(t.start)return this.getCellsRectWidth(t.start.col,t.start.row,t.end.col,t.end.row);const e=this.getCellRange(t.col,t.row);return this.getCellsRectWidth(e.start.col,e.start.row,e.end.col,e.end.row)}isFrozenCell(t,e){const{frozenRowCount:i,frozenColCount:n}=this.internalProps,r=i>0&&e<i||this.isBottomFrozenRow(t,e),o=n>0&&t<n||this.isRightFrozenColumn(t,e);return r||o?{row:r,col:o}:null}getRowAt(t){const e=function(t,e){if(!t.internalProps.frozenRowCount)return null;let{scrollTop:i}=t;const n=t.internalProps.frozenRowCount;for(let r=0;r<n;r++){const n=t.getRowHeight(r),o=i+n;if(o>e)return{top:i,row:r,bottom:o,height:n};i=o}return null}(this,t);if(e)return e;let i=this.getTargetRowAt(t);return i||(i={top:-1,row:-1,bottom:-1,height:-1}),i}getColAt(t){const e=function(t,e){if(!t.internalProps.frozenColCount)return null;let{scrollLeft:i}=t;const n=t.internalProps.frozenColCount;for(let r=0;r<n;r++){const n=t.getColWidth(r),o=i+n;if(o>e)return{left:i,col:r,right:o,width:n};i=o}return null}(this,t);if(e)return e;let i=this.getTargetColAt(t);return i||(i={left:-1,col:-1,right:-1,width:1}),i}getCellAt(t,e){const i=this.getRowAt(e),{row:n,top:r,bottom:o,height:s}=i,a=this.getColAt(t),{col:l,left:h,right:c,width:d}=a;return{row:n,col:l,rect:{left:h,right:c,top:r,bottom:o,width:d,height:s}}}_checkRowCol(t,e){return t>=0&&t<this.colCount&&e>=0&&e<this.rowCount}_makeVisibleCell(t,e){if(this._checkRowCol(t,e)){const i=this.isFrozenCell(t,e);if(i&&i.col&&i.row)return;const n=this.getCellRect(t,e),r=function(t){let e=0;t.internalProps.frozenColCount>0&&(e=t.getFrozenColsWidth());let i=0;return t.internalProps.frozenRowCount>0&&(i=t.getFrozenRowsHeight()),new Re(t.scrollLeft+e,t.scrollTop+i,t.tableNoFrameWidth-e,t.tableNoFrameHeight-i)}(this);if(r.contains(n))return;i&&i.col||this.getColsWidth(0,this.frozenColCount-1)+n.width>this.canvas.width||(n.left<r.left?this.scrollLeft-=r.left-n.left:r.right<n.right&&(this.scrollLeft-=r.right-n.right)),i&&i.row||this.getRowsHeight(0,this.frozenRowCount-1)+n.height>this.canvas.height||(n.top<r.top?this.scrollTop-=r.top-n.top:r.bottom<n.bottom&&(this.scrollTop-=r.bottom-n.bottom))}}invalidate(){this.scenegraph.renderSceneGraph()}_toRelativeRect(t){const e=t.copy(),i=this.getVisibleRect();return e.offsetLeft(-i.left),e.offsetTop(-i.top),e}getVisibleRect(){const{scrollTop:t,scrollLeft:e}=this,i=this.tableNoFrameWidth,n=this.tableNoFrameHeight;return new Re(e,t,i,n)}get visibleRowCount(){const{frozenRowCount:t}=this,e=this.getVisibleRect(),i=t>0?e.top+this.getRowsHeight(0,t-1):e.top,n=this.getTargetRowAt(i);if(!n)return 0;const r=Math.max(n.top>=i?n.row:n.row+1,t);let o=this.getRowsHeight(0,r-1),s=0;const{rowCount:a}=this;for(let t=r;t<a;t++){const i=o+this.getRowHeight(t);if(e.bottom<i)break;s++,o=i}return s}get visibleColCount(){const{frozenColCount:t}=this,e=this.getVisibleRect(),i=t>0?e.left+this.getColsWidth(0,t-1):e.left,n=this.getTargetColAt(i);if(!n)return 0;const r=Math.max(n.left>=i?n.col:n.col+1,t);let o=this.getColsWidth(0,r-1),s=0;const{colCount:a}=this;for(let t=r;t<a;t++){const i=o+this.getColWidth(t);if(e.right<i)break;s++,o=i}return s}get scrollTop(){return this.stateManeger.scroll.verticalBarPos}set scrollTop(t){this.stateManeger.setScrollTop(t)}get scrollLeft(){return this.stateManeger.scroll.horizontalBarPos}set scrollLeft(t){this.stateManeger.setScrollLeft(t)}getScrollLeft(){return this.scrollLeft}getScrollTop(){return this.scrollTop}setScrollLeft(t){this.scrollLeft=Math.ceil(t)}setScrollTop(t){this.scrollTop=Math.ceil(t)}getCellOverflowText(t,e){return this.scenegraph.getCellOverflowText(t,e)}addDisposable(t){if(!t||!t.dispose||"function"!=typeof t.dispose)throw new Error("not disposable!");(this.internalProps.disposables=this.internalProps.disposables||[]).push(t)}dispose(){const t=this.internalProps;t.tooltipHandler?.dispose?.(),t.menuHandler?.dispose?.(),EC.clearAll(),super.dispose?.(),t.handler?.dispose?.(),t.focusControl?.dispose?.(),t.disposables&&(t.disposables.forEach((t=>t?.dispose?.())),t.disposables=null),this.scenegraph.stage.release();const{parentElement:e}=t.element;e&&e.removeChild(t.element)}fireListeners(t,e){return super.fireListeners(t,e)}updateOption(t){this.options=t;const{frozenColCount:e=0,defaultRowHeight:i=40,defaultHeaderRowHeight:n,defaultColWidth:r=80,defaultHeaderColWidth:o=80,keyboardOptions:s,columnResizeMode:a,dragHeaderMode:l,showFrozenIcon:h,allowFrozenColCount:c,padding:d,hover:u,menu:p,select:f,pixelRatio:g,widthMode:y,heightMode:m,autoFillWidth:b,customRender:v}=t;g&&g!==this.internalProps.pixelRatio&&(this.internalProps.pixelRatio=g),d&&("number"==typeof d?(this.padding.top=d,this.padding.left=d,this.padding.bottom=d,this.padding.right=d):(d.top&&(this.padding.top=d.top),d.bottom&&(this.padding.bottom=d.bottom),d.left&&(this.padding.left=d.left),d.right&&(this.padding.right=d.right))),this.showFrozenIcon="boolean"!=typeof h||h,"number"==typeof c&&c<=0&&(this.showFrozenIcon=!1),this.widthMode=y??"standard",this.heightMode=m??"standard",this.autoFillWidth=b??!1,this.customRender=v;const w=this.internalProps;"node"!==vt.mode&&function(t,e){t.style.margin=`${e.top}px ${e.right}px ${e.bottom}px ${e.left}px`;const i=(t.offsetWidth||t.parentElement?.offsetWidth||1)-1,n=(t.offsetHeight||t.parentElement?.offsetHeight||1)-1;t.style.width=i&&i-e.left-e.right+"px"||"0px",t.style.height=n&&n-e.top-e.bottom+"px"||"0px"}(w.element,this.padding),w.frozenColCount=e,w.defaultRowHeight=i,w.defaultHeaderRowHeight=n??i,w.defaultColWidth=r,w.defaultHeaderColWidth=o??r,w.keyboardOptions=s,w.columnResizeMode=a,w.dragHeaderMode=l,w.cellTextOverflows={},w._rowHeightsMap=new St,w._rowRangeHeightsMap=new Map,w._colRangeWidthsMap=new Map,this.colWidthsMap=new St,this.colContentWidthsMap=new St,this.colWidthsLimit={},w.theme=Qe.of(t.theme??Qe.DEFAULT),w.autoWrapText=t.autoWrapText,w.allowFrozenColCount=t.allowFrozenColCount??w.colCount,w.limitMaxAutoWidth=t.limitMaxAutoWidth??450,this.dataSet=new _M,this.scenegraph.clearCells(),this.stateManeger.initState(),t.legends&&(w.legends=new LP(t.legends,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),t.title&&(w.title=new IP(t.title,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),w.tooltip=Object.assign({renderMode:"html",isShowOverflowTextTooltip:!1,confine:!0},t.tooltip),"html"!==w.tooltip.renderMode||w.tooltipHandler||(w.tooltipHandler=new wP(this,w.tooltip.confine)),w.menu=Object.assign({renderMode:"html"},t.menu),"html"!==w.menu.renderMode||w.menuHandler||(w.menuHandler=new RP(this)),this.headerStyleCache=new Map,this.bodyStyleCache=new Map}getFrozenRowsHeight(){return this.getRowsHeight(0,this.frozenRowCount-1)}getFrozenColsWidth(){return this.getColsWidth(0,this.frozenColCount-1)}getBottomFrozenRowsHeight(){if(this.bottomFrozenRowCount>0){return this.getRowsHeight(this.rowCount-this.bottomFrozenRowCount,this.rowCount-1)}return 0}getRightFrozenColsWidth(){if(this.rightFrozenColCount>0){return this.getColsWidth(this.colCount-this.rightFrozenColCount,this.colCount-1)}return 0}getDrawRange(){const t=Math.min(this.tableNoFrameWidth,this.getAllColsWidth()),e=Math.min(this.tableNoFrameHeight,this.getAllRowsHeight());return new Re(this.tableX,this.tableY,t,e)}_getMouseAbstractPoint(t,e=!0){const i=this;let n;if(!t)return null;n=DP(t)?t.changedTouches[0]:t;const r=n.clientX||n.pageX+window.scrollX,o=n.clientY||n.pageY+window.scrollY,s=i.internalProps.canvas.getBoundingClientRect();if(s.right<=r)return null;if(s.bottom<=o)return null;const a=s.width,l=a/(this.canvas.offsetWidth||a),h=s.height,c=h/(this.canvas.offsetHeight||h);return{x:(r-s.left)/l+(e?i.scrollLeft:0)-i.tableX,y:(o-s.top)/c+(e?i.scrollTop:0)-i.tableY}}_getCellEventArgsSet(t){const e=this._getMouseAbstractPoint(t);if(!e)return{};const i=this.getCellAt(e.x,e.y);if(i.col<0||i.row<0)return{abstractPos:e,cell:i};return{abstractPos:e,cell:i,eventArgs:{col:i.col,row:i.row,event:t,rect:i.rect}}}getTheme(){return this.internalProps.theme}getTargetColAt(t){if(0===t)return{left:0,col:0,right:0,width:0};const e=(e,i)=>{let n=i-this.getColWidth(e);const{colCount:r}=this.internalProps;for(let i=e;i<r;i++){const e=this.getColWidth(i),r=n+e;if(Math.round(n)<=Math.round(t)&&Math.round(t)<Math.round(r))return{left:n,col:i,right:r,width:e};n=r}return null},i=this.computeTargetColByX(t),n=this.getColsWidth(0,i);return t>=n?e(i,n):((e,i)=>{let n=i;for(let i=e;i>=0;i--){const e=this.getColWidth(i),r=n-e;if(Math.round(r)<=Math.round(t)&&Math.round(t)<Math.round(n))return{left:r,col:i,right:n,width:e};n=r}return null})(i,n)}getTargetRowAt(t){if(0===t)return{top:0,row:0,bottom:0,height:0};const e=(e,i)=>{let n=i-this.getRowHeight(e);const{rowCount:r}=this.internalProps;for(let i=e;i<r;i++){const e=this.getRowHeight(i),r=n+e;if(Math.round(n)<=Math.round(t)&&Math.round(t)<Math.round(r))return{top:n,row:i,bottom:r,height:e};n=r}return null},i=this.computeTargetRowByY(t),n=this.getRowsHeight(0,i);return t>=n?e(i,n):((e,i)=>{let n=i;for(let i=e;i>=0;i--){const e=this.getRowHeight(i),r=n-e;if(Math.round(r)<=Math.round(t)&&Math.round(t)<Math.round(n))return{top:r,row:i,bottom:n,height:e};n=r}return null})(i,n)}computeTargetRowByY(t){if(this._rowRangeHeightsMap.get("$0$"+(this.rowCount-1))){let e=0,i=this.rowCount-1;for(;i-e>1;){const n=Math.floor((e+i)/2);if(t<this._rowRangeHeightsMap.get(`$0$${n}`))i=n;else{if(!(t>this._rowRangeHeightsMap.get(`$0$${n}`)))return n;e=n}}return i}return Math.min(Math.ceil(t/this.internalProps.defaultRowHeight),this.rowCount-1)}computeTargetColByX(t){if(this._colRangeWidthsMap.get("$0$"+(this.colCount-1))){let e=0,i=this.colCount-1;for(;i-e>1;){const n=Math.floor((e+i)/2);if(t<this._colRangeWidthsMap.get(`$0$${n}`))i=n;else{if(!(t>this._colRangeWidthsMap.get(`$0$${n}`)))return n;e=n}}return i}return Math.min(Math.ceil(t/this.internalProps.defaultColWidth),this.colCount-1)}clearSelected(){this.stateManeger.updateSelectPos(-1,-1)}selectCell(t,e){this.stateManeger.updateSelectPos(t,e),this.stateManeger.endSelectCells()}updatePager(t){this.pagerConf&&("number"==typeof t.currentPage&&t.currentPage>=0&&(this.pagerConf.currentPage=t.currentPage),t.perPageCount&&(this.pagerConf.perPageCount=t.perPageCount||this.pagerConf.perPageCount),this.scenegraph.clearCells(),this.dataSource.updatePager(this.pagerConf),this.refreshRowColCount(),this.scenegraph.createSceneGraph(),this.invalidate())}get allowFrozenColCount(){return this.internalProps.allowFrozenColCount}get rowHeaderLevelCount(){return this.internalProps.layoutMap.rowHeaderLevelCount}get columnHeaderLevelCount(){return this.internalProps.layoutMap.columnHeaderLevelCount}get records(){return this.internalProps.records||null}get dataSource(){return this.internalProps.dataSource}set dataSource(t){this.scenegraph.clearCells(),AC(this,t),this.refreshRowColCount(),this.scenegraph.createSceneGraph(),this.invalidate()}get autoWrapText(){return this.internalProps.autoWrapText}set autoWrapText(t){this.internalProps.autoWrapText!==t&&(this.internalProps.autoWrapText=t,this.options.autoWrapText=t,this.internalProps.layoutMap&&(this.refreshHeader(),this.invalidate()))}get theme(){return this.internalProps.theme}set theme(t){const e=Qe.of(t);this.internalProps.theme=e||Qe.DEFAULT,this.options.theme=t,this.resize()}getBodyField(t,e){return this.internalProps.layoutMap.getBody(t,e).field}getBodyColumnDefine(t,e){const i=this.internalProps.layoutMap.getBody(t,e);return i?.define}getBodyColumnType(t,e){return this.internalProps.layoutMap.getBody(t,e).columnType}getHeaderField(t,e){return this.internalProps.layoutMap.getHeaderField(t,e)}getHeaderFieldKey(t,e){return this.internalProps.layoutMap.getHeaderFieldKey(t,e)}getHeaderDefine(t,e){const i=this.internalProps.layoutMap.getHeader(t,e);return i?.define}getCellType(t,e){return this.internalProps.layoutMap.getCellType(t,e)}getCellHeaderPaths(t,e){return this.internalProps.layoutMap.getCellHeaderPaths(t,e)}getHeadersDefine(t,e){const i=[];for(;;){const n=this.getHeaderDefine(t,e);if(!n||!n.field&&!n.columns)break;i.push(n),e++}return i}_getHeaderLayoutMap(t,e){return this.internalProps.layoutMap.getHeader(t,e)}_getBodyLayoutMap(t,e){return this.internalProps.layoutMap.getBody(t,e)}getContext(){return this.internalProps.context}getRecordByRowCol(t,e){if(!this.internalProps.layoutMap.isHeader(t,e))return this.internalProps.dataSource?.get(this.getRecordIndexByRow(t,e))}getRecordStartRowByRecordIndex(t){return this.internalProps.layoutMap.getRecordStartRowByRecordIndex(t)}_getHeaderCellBySortState(t){const{layoutMap:e}=this.internalProps;let i;if(i=t.fieldKey?e.headerObjects.find((e=>e&&e.fieldKey===t.fieldKey)):e.headerObjects.find((e=>e&&e.field===t.field)),i){return e.getHeaderCellAdress(i.id)}}getCellRange(t,e){return this.internalProps.layoutMap.getCellRange(t,e)}isCellRangeEqual(t,e,i,n){return this.internalProps.layoutMap.isCellRangeEqual(t,e,i,n)}_getLayoutCellId(t,e){return this.internalProps.layoutMap.getCellId(t,e)}getHeaderDescription(t,e){const i=this._getHeaderLayoutMap(t,e),n=i?.define,r=n?.description??i?.description;if("function"==typeof r){return r({col:t,row:e,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e)})}return r}setRecords(t,e){const i="undefined"!=typeof window?window.performance.now():0;if(this.scenegraph.clearCells(),void 0!==e&&(this.sortState=e,this.stateManeger.setSortState(this.sortState)),t){if(SC(this,t),this.sortState){let t,e,i;if(Array.isArray(this.sortState)?0!==this.sortState.length&&({order:t,field:e,fieldKey:i}=this.sortState?.[0]):({order:t,field:e,fieldKey:i}=this.sortState),t&&e&&"normal"!==t){const n=this._getSortFuncFromHeaderOption(void 0,e,i);let r;r=i?this.internalProps.layoutMap.headerObjects.find((t=>t&&t.fieldKey===i)):this.internalProps.layoutMap.headerObjects.find((t=>t&&t.field===e)),r?.define?.sort&&this.dataSource.sort(r.field,t,n??M)}}this.refreshRowColCount()}else SC(this,t);this.scenegraph.createSceneGraph(),this.invalidate(),console.log("setRecords cost time:",("undefined"!=typeof window?window.performance.now():0)-i)}setRecord(t,e,i){const n=this.getRecordIndexByRow(e,i);this.dataSource.setRecord(t,n)}setDropDownMenuHighlight(t){this.stateManeger.setDropDownMenuHighlight(t)}_dropDownMenuIsHighlight(t,e,i){return this.stateManeger.dropDownMenuIsHighlight(t,e,i)}isHeader(t,e){return this.internalProps.layoutMap&&this.internalProps.layoutMap.isHeader(t,e)}isColumnHeader(t,e){return this.internalProps.layoutMap?.isColumnHeader(t,e)}isRowHeader(t,e){return this.internalProps.layoutMap?.isRowHeader(t,e)}isCornerHeader(t,e){return this.internalProps.layoutMap?.isCornerHeader(t,e)}isRightFrozenColumn(t,e){return this.internalProps.layoutMap?.isRightFrozenColumn(t,e)}isBottomFrozenRow(t,e){return this.internalProps.layoutMap?.isBottomFrozenRow(t,e)}getCellInfo(t,e){const i=this.isHeader(t,e)?this.getHeaderDefine(t,e):this.getBodyColumnDefine(t,e);return{col:t,row:e,field:this.getHeaderField(t,e),cellHeaderPaths:this.internalProps.layoutMap.getCellHeaderPaths(t,e),caption:i.caption,columnType:i.columnType?"string"==typeof i.columnType?i.columnType:"progressbar":"text",originData:this.getCellOriginRecord(t,e),cellRange:this.getCellRangeRelativeRect({col:t,row:e}),value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellType:this.getCellType(t,e),scaleRatio:this.canvas.getBoundingClientRect().width/this.canvas.offsetWidth}}_hasField(t,e,i){if(null==t)return!1;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return!1;const r=n.getRecordIndexByRow(e,i);return n.internalProps.dataSource.hasField(r,t)}_getCellStyle(t,e){const{layoutMap:i}=this.internalProps;if(i.isHeader(t,e)){let n=this.headerStyleCache.get(`${t}-${e}`);if(n)return n;const r=i.getHeader(t,e);if(!r||r.isEmpty)return WP;const o=this.internalProps.headerHelper.getStyleClass(r.headerType),{style:s}=r;return n=K(s,i.isColumnHeader(t,e)?this.theme.headerStyle:i.isRowHeader(t,e)?this.theme.rowHeaderStyle:this.theme.cornerHeaderStyle,{col:t,row:e,table:this,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellHeaderPaths:this.getCellHeaderPaths(t,e)},o,this.options.autoWrapText),this.headerStyleCache.set(`${t}-${e}`,n),n}let n;n=this.isListTable()&&!this.transpose||this.isPivotTable()&&this.internalProps.layoutMap.indicatorsAsCol?t:e;let r=this.bodyStyleCache.get(n);if(r)return r;const o=i.getBody(t,e),s=this.internalProps.bodyHelper.getStyleClass(o.columnType),a=o?.style;return r=W(a,this.theme.bodyStyle,{col:t,row:e,table:this,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellHeaderPaths:this.getCellHeaderPaths(t,e)},s,this.options.autoWrapText),this.bodyStyleCache.set(n,r),r}clearCellStyleCache(){this.headerStyleCache.clear()}_canResizeColumn(t,e){if(!(t>=0&&e>=0))return!1;if(this.isCellRangeEqual(t,e,t+1,e))return!1;if("none"===this.internalProps.columnResizeMode)return!1;if("header"===this.internalProps.columnResizeMode){if(!this.isHeader(t,e))return!1}else if("body"===this.internalProps.columnResizeMode&&this.isHeader(t,e))return!1;const i=this.colWidthsLimit[t];return!(i&&i.min&&i.max)||i.max!==i.min}_canDragHeaderPosition(t,e){if(this.isHeader(t,e)&&this.stateManeger.isSelected(t,e)){const i=this.stateManeger.select.ranges[0];if(this.isColumnHeader(t,e)){if(i.end.row!==this.rowCount-1)return!1}else{if(!this.isRowHeader(t,e))return!1;if(i.end.col!==this.colCount-1)return!1}const n=this.getHeaderDefine(t,e);if(void 0===n.dragHeader){if("all"===this.internalProps.dragHeaderMode)return!0;if("column"===this.internalProps.dragHeaderMode){if(this.isColumnHeader(t,e))return!0}else if("row"===this.internalProps.dragHeaderMode&&this.isRowHeader(t,e))return!0;return!1}return n.dragHeader}return!1}getCellIcons(t,e){let i;if(this.isHeader(t,e))i=this.internalProps.headerHelper.getIcons(t,e);else{const n=this.getCellValue(t,e),r=this.getCellOriginValue(t,e),o=this.internalProps.context;i=this.internalProps.bodyHelper.getIcons(t,e,n,r,o)}return i}showDropDownMenu(t,e,i){let n="dropdown-menu";i&&(n=Array.isArray(i.content)?"dropdown-menu":"container"),"html"===this.internalProps.menu.renderMode&&(this.stateManeger.menu.isShow=!0,this.internalProps.menuHandler._bindToCell(t,e,n,i))}showTooltip(t,e,i){"html"===this.internalProps.tooltip.renderMode&&this.internalProps.tooltipHandler._bindToCell(t,e,i)}getCellStyle(t,e){const i=this._getCellStyle(t,e),n=RC(i,this,t,e,OC).theme,{autoWrapText:r,lineClamp:o,textOverflow:s}=i;return{textAlign:n.text.textAlign,textBaseline:n.text.textBaseline,bgColor:Et(n.group.fill)?OC("bgColor",i,t,e,this):n.group.fill,color:Et(n.text.fill)?OC("color",i,t,e,this):n.text.fill,fontFamily:n.text.fontFamily,fontSize:n.text.fontSize,fontWeight:n.text.fontWeight,fontVariant:n.text.fontVariant,fontStyle:n.text.fontStyle,lineHeight:n.text.lineHeight,autoWrapText:r??!1,lineClamp:o??"auto",textOverflow:s,borderColor:Et(n.group.stroke)?OC("borderColor",i,t,e,this):n.group.stroke,borderLineWidth:n.group.lineWidth,borderLineDash:n.group.lineDash,underline:!!n.text.underline,lineThrough:!!n.text.lineThrough,padding:n._vtable.padding,underlineWidth:n.text.underline,lineThroughLineWidth:n.text.lineThrough}}getAllBodyCells(t,e){const i=this.rowHeaderLevelCount,n=this.columnHeaderLevelCount,r=this.colCount-1,o=this.rowCount-1;return Array(Math.min(e??2e3,o-n+1,this.rowCount)).fill(0).map(((e,o)=>Array(Math.min(t??2e3,r-i+1,this.colCount)).fill(0).map(((t,e)=>this.getCellInfo(e+i,o+n)))))}getAllCells(t,e){const i=0,n=0,r=this.colCount-1,o=this.rowCount-1;return Array(Math.min(e??2e3,o-n+1,this.rowCount)).fill(0).map(((e,o)=>Array(Math.min(t??2e3,r-i+1,this.colCount)).fill(0).map(((t,e)=>this.getCellInfo(e+i,o+n)))))}getAllColumnHeaderCells(){const t=this.rowHeaderLevelCount,e=0,i=this.colCount-1,n=this.columnHeaderLevelCount-1;return Array(n-e+1).fill(0).map(((n,r)=>Array(i-t+1).fill(0).map(((i,n)=>this.getCellInfo(n+t,r+e)))))}getAllRowHeaderCells(){const t=0,e=this.columnHeaderLevelCount,i=this.rowHeaderLevelCount-1,n=this.rowCount-1;return Array(n-e+1).fill(0).map(((n,r)=>Array(i-t+1).fill(0).map(((i,n)=>this.getCellInfo(n+t,r+e)))))}scrollToCell(t){const e=this.getDrawRange();if(A(t.col)&&t.col>=this.frozenColCount){const i=this.getFrozenColsWidth(),n=this.getColsWidth(0,t.col-1);this.scrollLeft=Math.min(n-i,this.getAllColsWidth()-e.width)}if(A(t.row)&&t.row>=this.frozenRowCount){const i=this.getFrozenRowsHeight(),n=this.getRowsHeight(0,t.row-1);this.scrollTop=Math.min(n-i,this.getAllRowsHeight()-e.height)}this.invalidate()}getCopyValue(){const t=this.stateManeger.select.ranges;let e=Math.min(t[0].start.col,t[0].end.col),i=Math.max(t[0].start.col,t[0].end.col),n=Math.min(t[0].start.row,t[0].end.row),r=Math.max(t[0].start.row,t[0].end.row);t.forEach((t=>{e=Math.min(e,t.start.col,t.end.col),i=Math.max(i,t.start.col,t.end.col),n=Math.min(n,t.start.row,t.end.row),r=Math.max(r,t.start.row,t.end.row)}));const o=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.row,t.end.row),r=Math.max(t.start.row,t.end.row);n<=e&&r>=e&&(i=!0)})),i},s=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.col,t.end.col),r=Math.max(t.start.col,t.end.col);n<=e&&r>=e&&(i=!0)})),i},a=(e,i)=>{let n;return t.forEach((t=>{const r=Math.min(t.start.row,t.end.row),o=Math.max(t.start.row,t.end.row),s=Math.min(t.start.col,t.end.col),a=Math.max(t.start.col,t.end.col);s<=e&&a>=e&&r<=i&&o>=i&&(n=t)})),n},l=(t,e,i)=>{const n=this.getCellRange(t,e);let r=n.start.col,o=n.start.row;if(i){const t=Math.min(i.start.col,i.end.col),e=Math.min(i.start.row,i.end.row);r=Math.max(t,n.start.col),o=Math.max(e,n.start.row)}if(r!==t||o!==e)return"";return this.getCellValue(t,e)};let h="";for(let t=n;t<=r;t++){if(o(t)){for(let n=e;n<=i;n++){if(s(n)){const e=a(n,t);if(e){const r=l(n,t,e);if("undefined"!=typeof Promise&&r instanceof Promise);else{const t=`${r}`;/^\[object .*\]$/.exec(t)||(h+=t)}(n<e.end.col||n<i)&&(h+="\t")}else h+="\t"}}h+="\n"}}return h}getSelectedCellInfos(){const t=this.stateManeger.select.ranges;let e=Math.min(t[0].start.col,t[0].end.col),i=Math.max(t[0].start.col,t[0].end.col),n=Math.min(t[0].start.row,t[0].end.row),r=Math.max(t[0].start.row,t[0].end.row);t.forEach((t=>{e=Math.min(e,t.start.col,t.end.col),i=Math.max(i,t.start.col,t.end.col),n=Math.min(n,t.start.row,t.end.row),r=Math.max(r,t.start.row,t.end.row)}));const o=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.row,t.end.row),r=Math.max(t.start.row,t.end.row);n<=e&&r>=e&&(i=!0)})),i},s=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.col,t.end.col),r=Math.max(t.start.col,t.end.col);n<=e&&r>=e&&(i=!0)})),i},a=(e,i)=>{let n;return t.forEach((t=>{const r=Math.min(t.start.row,t.end.row),o=Math.max(t.start.row,t.end.row),s=Math.min(t.start.col,t.end.col),a=Math.max(t.start.col,t.end.col);s<=e&&a>=e&&r<=i&&o>=i&&(n=t)})),n},l=[];for(let t=n;t<=r;t++){if(o(t)){const n=[];for(let r=e;r<=i;r++){if(s(r)){if(a(r,t)){const e=this.getCellInfo(r,t);n.push(e)}}}l.push(n)}}return l}measureText(t,e){return yx.measureText(t,e)}measureTextBounds(t){const e=new bx(t);return{width:e.AABBBounds.width(),height:e.AABBBounds.height()}}getCustomRender(t,e){let i;if("body"!==this.getCellType(t,e)){const n=this.getHeaderDefine(t,e);i=n?.headerCustomRender}else{const n=this.getBodyColumnDefine(t,e);i=n?.customRender||this.customRender}return i}getCustomLayout(t,e){let i;if("body"!==this.getCellType(t,e)){const n=this.getHeaderDefine(t,e);i=n?.headerCustomLayout}else{const n=this.getBodyColumnDefine(t,e);i=n?.customLayout}return i}}var jP=Object.freeze({__proto__:null,BaseTable:zP});function NP(t,e,i){const n=t[e];return t[e]=i,n}function GP(t){for(const e in t)delete t[e]}function KP(){GP(Ie),GP(PC),GP(FS)}var UP=Object.freeze({__proto__:null,chartType:function(t,e){return null!=e?NP(FS,t,e):FS[t]},clearAll:KP,icon:function(t,e){return null!=e?NP(PC,t,e):PC[t]},theme:function(t,e){return null!=e?NP(Ie,t,e):Ie[t]}});var VP=Object.freeze({__proto__:null,dateFormat:function(t,e,i,n,r){null==i&&(i=!1),null==n&&(n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),null==r&&(r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]);const o=i?"UTC":"",s=function(t){return`0${t}`.substring(0,2)};return function(i){const a=new Date(Date.parse(i[t]));return e.replace(/%(.)/g,(function(t,e){switch(e){case"y":return a[`get${o}FullYear`]();case"m":return s(a[`get${o}Month`]()+1);case"n":return n[a[`get${o}Month`]()];case"d":return s(a[`get${o}Date`]());case"w":return r[a[`get${o}Day`]()];case"x":return a[`get${o}Day`]();case"H":return s(a[`get${o}Hours`]());case"M":return s(a[`get${o}Minutes`]());case"S":return s(a[`get${o}Seconds`]());default:return`%${e}`}}))}},numberFormat:function(t){return t=Object.assign({},{digitsAfterDecimal:2,scaler:1,thousandsSep:",",decimalSep:".",prefix:"",suffix:""},t),function(e){if(isNaN(e)||!isFinite(e))return"";const i=function(t,e,i){const n=(t+="").split(".");let r=n[0];const o=n.length>1?i+n[1]:"";return r=function(t,e){return t.replace(/\d+/,(function(t){return t.replace(/(\d)(?=(\d{3})+$)/g,(function(t){return`${t}${e}`}))}))}(r,e),r+o}((t.scaler*e).toFixed(t.digitsAfterDecimal),t.thousandsSep,t.decimalSep);return`${t.prefix}${i}${t.suffix}`}}});let $P=0;class XP{_headerObjects;_headerObjectMap;_headerCellIds;_columns;bodyRowCount=1;hierarchyIndent;_transpose=!1;_showHeader=!0;_recordsCount=0;_table;_cellRangeMap;constructor(t,e,i,n){this._cellRangeMap=new Map,this._showHeader=i,this._table=t,this._columns=[],this._headerCellIds=[],this.hierarchyIndent=n??20,this._headerObjects=this._addHeaders(0,e,[]),this._headerObjectMap=this._headerObjects.reduce(((t,e)=>(t[e.id]=e,t)),{})}get transpose(){return this._transpose}set transpose(t){this._transpose=t}get showHeader(){return this._showHeader}set showHeader(t){this._showHeader=t}isHeader(t,e){return!!(this.transpose&&t<this.headerLevelCount)||!this.transpose&&e<this.headerLevelCount}getCellType(t,e){return this.isHeader(t,e)?this.transpose?"rowHeader":"columnHeader":"body"}isColumnHeader(t,e){return!this.transpose&&e<this.headerLevelCount}isRightFrozenColumn(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.columnHeaderLevelCount&&e<this.rowCount-this.bottomFrozenRowCount}isBottomFrozenRow(t,e){return t>=this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount&&t<this.colCount-this.rightFrozenColCount}isCornerHeader(t,e){return!1}isRowHeader(t,e){return!!(this.transpose&&t<this.headerLevelCount)}getColumnHeaderRange(){return this.transpose?{start:{col:0,row:0},end:{col:this._headerCellIds.length-1,row:(this.rowCount??0)-1}}:{start:{col:0,row:0},end:{col:(this.colCount??0)-1,row:this._headerCellIds.length-1}}}getRowHeaderRange(){return this.transpose?{start:{col:0,row:0},end:{col:this._headerCellIds.length-1,row:(this.rowCount??0)-1}}:{start:{col:0,row:0},end:{col:(this.colCount??0)-1,row:this._headerCellIds.length-1}}}getCornerHeaderRange(){}getBodyRange(){return this.transpose?{start:{col:this.headerLevelCount,row:0},end:{col:(this.colCount??0)-1,row:(this.rowCount??0)-1}}:{start:{col:0,row:this.headerLevelCount},end:{col:(this.colCount??0)-1,row:(this.rowCount??0)-1}}}get headerLevelCount(){return this.showHeader?this._headerCellIds.length:0}get columnHeaderLevelCount(){return this.transpose?0:this.headerLevelCount}get rowHeaderLevelCount(){return this.transpose?this.headerLevelCount:0}get bottomFrozenRowCount(){return 0}get rightFrozenColCount(){return 0}get colCount(){return this.transpose?this.headerLevelCount+this.recordsCount:this._columns.length}get rowCount(){return this.transpose?this._columns.length:this.headerLevelCount+this.recordsCount}get recordsCount(){return this._recordsCount}set recordsCount(t){this._recordsCount=t}get headerObjects(){return this._headerObjects}get columnObjects(){return this._columns}get columnWidths(){return this._columns}getColumnWidthDefined(t){if(this.transpose){let t,e,i,n=0;return this.columnObjects.forEach(((r,o)=>{"number"==typeof r.width?n=Math.max(r.width,n):"auto"===r.width&&(i=!0),"number"==typeof r.minWidth&&(e=Math.max(r.minWidth,e)),"number"==typeof r.maxWidth&&(t=Math.max(r.maxWidth,t))})),n=n>0?n:i?"auto":void 0,{width:n,minWidth:e,maxWidth:t}}return this._columns[t]}getCellId(t,e){return this.transpose?this.headerLevelCount<=t?this._columns[e]?.id:this._headerCellIds[t]?.[e]:this.headerLevelCount<=e?this._columns[t]?.id:this._headerCellIds[e]?.[t]}getHeader(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]}getHeaderFieldKey(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.fieldKey||(this.transpose?this._columns[e]?.fieldKey:this._columns[t]?.fieldKey)}getHeaderField(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.field||(this.transpose?this._columns[e]&&this._columns[e].field:this._columns[t]&&this._columns[t].field)}getHeaderCellAdress(t){for(let e=0;e<this._headerCellIds.length;e++){const i=this._headerCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return this.transpose?{col:e,row:n}:{col:n,row:e}}}getHeaderCellAddressByField(t){const e=this.headerObjects.find((e=>e&&e.field===t));return this.getHeaderCellAdress(e.id)}getBody(t,e){return this.transpose?this._columns[e]:this._columns[t]}getBodyLayoutRangeById(t){if(this.transpose){for(let e=0;e<(this.rowCount??0);e++)if(t===this._columns[e].id)return{start:{col:0,row:e},end:{col:0,row:e}}}else for(let e=0;e<(this.colCount??0);e++)if(t===this._columns[e].id)return{start:{col:e,row:0},end:{col:e,row:0}};throw new Error(`can not found body layout @id=${t}`)}getBodyCellValue(t,e){if(this.isHeader(t,e))return null;const{field:i,fieldFormat:n}=this.getBody(t,e);return this._table.getFieldData(n||i,t,e)}getCellRange(t,e){if(-1===t||-1===e)return{start:{col:t,row:e},end:{col:t,row:e}};if(this._cellRangeMap.has(`$${t}$${e}`))return this._cellRangeMap.get(`$${t}$${e}`);let i={start:{col:t,row:e},end:{col:t,row:e}};if(this.transpose)i=this.getCellRangeTranspose(t,e);else if(this.headerLevelCount<=e){if(this.headerLevelCount<=e&&this.columnObjects[t]?.define?.mergeCell){const n=this.getBodyCellValue(t,e);for(let r=e-1;r>=this.headerLevelCount&&n===this.getBodyCellValue(t,r);r--)i.start.row=r;for(let r=e+1;r<this.rowCount&&n===this.getBodyCellValue(t,r);r++)i.end.row=r}}else{const n=this.getCellId(t,e);for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getCellId(r,e);r++)i.end.col=r;for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<this.headerLevelCount&&n===this.getCellId(t,r);r++)i.end.row=r}return this._cellRangeMap.set(`$${t}$${e}`,i),i}getCellRangeTranspose(t,e){const i={start:{col:t,row:e},end:{col:t,row:e}};if(this.headerLevelCount<=t||-1===t&&-1===e){if(this.headerLevelCount<=t&&this.columnObjects[e]?.define?.mergeCell){const n=this.getBodyCellValue(t,e);for(let r=t-1;r>=this.headerLevelCount&&n===this.getBodyCellValue(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getBodyCellValue(r,e);r++)i.end.col=r}return i}const n=this.getCellId(t,e);for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<(this.rowCount??0)&&n===this.getCellId(t,r);r++)i.end.row=r;for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<this.headerLevelCount&&n===this.getCellId(r,e);r++)i.end.col=r;return i}isCellRangeEqual(t,e,i,n){const r=this.getCellRange(t,e),o=this.getCellRange(i,n);return r.start.col===o.start.col&&r.end.col===o.end.col&&r.start.row===o.start.row&&r.end.row===o.end.row}getRecordIndexByRow(t,e){return this.transpose?t<this.headerLevelCount?-1:t-this.headerLevelCount:e<this.headerLevelCount?-1:e-this.headerLevelCount}getRecordStartRowByRecordIndex(t){return this.headerLevelCount+t}_addHeaders(t,e,i,n){const r=[],o=this._newRow(t,n);return e.forEach((e=>{const s=this._columns.length,a=$P++,{captionIcon:l}=e,h={id:a,caption:e.caption,captionIcon:l,headerIcon:e.headerIcon,field:e.field,fieldKey:e?.fieldKey,fieldFormat:e.fieldFormat,style:e.headerStyle,headerType:e.headerType??"text",dropDownMenu:e.dropDownMenu,define:e,columnWidthComputeMode:e.columnWidthComputeMode};r[a]=h;for(let e=t-1;e>=0;e--)this._headerCellIds[e][s]=i[e];if(o[s]=n?this._headerCellIds[t-1][s]:a,e.columns)this._addHeaders(t+1,e.columns,[...i,a],e.hideColumnsSubHeader).forEach((t=>r.push(t)));else{const i=e;this._columns.push({id:$P++,field:i.field,fieldKey:i.fieldKey,fieldFormat:i.fieldFormat,width:i.width,minWidth:i.minWidth,maxWidth:i.maxWidth,icon:i.icon,columnType:i.columnType??"text",chartType:"chartType"in i?i.chartType:null,chartSpec:"chartSpec"in i?i.chartSpec:null,sparklineSpec:"sparklineSpec"in i?i.sparklineSpec:We,style:i.style,define:i,columnWidthComputeMode:i.columnWidthComputeMode,disableColumnResize:i?.disableColumnResize});for(let e=t+1;e<this._headerCellIds.length;e++)this._headerCellIds[e][s]=a}})),r}_newRow(t,e=!1){if(this._headerCellIds[t]){const e=this._headerCellIds[t-1];if(e.length>this._headerCellIds[t].length)for(let i=this._headerCellIds[t].length;i<e.length;i++)this._headerCellIds[t][i]=e[i];return this._headerCellIds[t]}if(e)return[];const i=this._headerCellIds[t]=[];if(!this._columns.length)return i;const n=this._headerCellIds[t-1];for(let t=0;t<n.length;t++)i[t]=n[t];return i}getCellHeaderPaths(t,e){let i=[],n=[];return this.transpose?n=[{field:this._columns[e].field}]:i=[{field:this._columns[t].field}],{colHeaderPaths:i,rowHeaderPaths:n}}getParentCellId(t,e){if(0!==e)return this.isColumnHeader(t,e)?this.getCellId(t,e-1):this.isRowHeader(t,e)?this.getCellId(t-1,e):void 0}canMoveHeaderPosition(t,e){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){return this.getParentCellId(t.col,i.start.row)===this.getParentCellId(e.col,i.start.row)}if(this.isRowHeader(t.col,t.row)){return this.getParentCellId(i.start.col,t.row)===this.getParentCellId(i.start.col,e.row)}return!1}moveHeaderPosition(t,e){if(this.canMoveHeaderPosition(t,e)){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){const n=i.end.col-i.start.col+1;let r;const o=this.getCellRange(e.col,i.start.row);if(r=e.col>=t.col?o.end.col-n+1:o.start.col,r===i.start.col)return null;for(let t=0;t<this._headerCellIds.length;t++){const e=this._headerCellIds[t].splice(i.start.col,n);e.unshift(r,0),Array.prototype.splice.apply(this._headerCellIds[t],e)}const s=this._columns.splice(i.start.col,n);return s.unshift(r,0),Array.prototype.splice.apply(this._columns,s),this._cellRangeMap=new Map,{sourceIndex:i.start.col,targetIndex:r,moveSize:n,moveType:"column"}}if(this.isRowHeader(t.col,t.row)){const n=i.end.row-i.start.row+1;let r;const o=this.getCellRange(i.start.col,e.row);if(r=e.row>=t.row?o.end.row-n+1:o.start.row,r===i.start.row)return null;for(let t=0;t<this._headerCellIds.length;t++){const e=this._headerCellIds[t].splice(i.start.row,n);e.unshift(r,0),Array.prototype.splice.apply(this._headerCellIds[t],e)}const s=this._columns.splice(i.start.row,n);return s.unshift(r,0),Array.prototype.splice.apply(this._columns,s),this._cellRangeMap=new Map,{sourceIndex:i.start.row,targetIndex:r,moveSize:n,moveType:"row"}}}return null}toggleHierarchyState(t){const e=t.add.map((t=>({col:0,row:this._table.frozenRowCount+t}))),i=t.remove.map((t=>({col:0,row:this._table.frozenRowCount+t})));return{addCellPositions:e,removeCellPositions:i}}setChartInstance(t,e,i){(this.transpose?this._columns[e]:this._columns[t]).chartInstance=i}getChartInstance(t,e){return(this.transpose?this._columns[e]:this._columns[t]).chartInstance}getAxisConfigInPivotChart(t,e){}isEmpty(t,e){return!1}getChartAxes(t,e){return[]}}class YP{sizeIncludeParent=!1;rowExpandLevel;hierarchyType;tree={id:0,dimensionKey:"",value:"",children:[],level:-1,startIndex:0,size:0,startInTotal:0,hierarchyState:void 0};totalLevel=0;dimensionKeys=new St;constructor(t,e="grid",i=void 0){this.sizeIncludeParent=null!=i,this.rowExpandLevel=i,this.hierarchyType=e,this.reset(t)}reset(t,e=!1){this.dimensionKeys=new St,this.tree.children=t,this.setTreeNode(this.tree,0,this.tree),this.totalLevel=this.dimensionKeys.count()}setTreeNode(t,e,i){t.startIndex=e,t.startInTotal=(i.startInTotal??0)+t.startIndex,(t.dimensionKey??t.indicatorKey)&&(!this.dimensionKeys.contain(t.indicatorKey?Fe:t.dimensionKey)&&this.dimensionKeys.put(t.level,t.indicatorKey?Fe:t.dimensionKey),t.id||(t.id=++qP));let n=t.dimensionKey&&this.sizeIncludeParent?1:0;return"grid"===this.hierarchyType?t.children?t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)})):n=1:t.hierarchyState===r.expand&&t.children?t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)})):t.hierarchyState===r.collapse&&t.children?t.children.forEach((e=>{e.level=(t.level??0)+1,this.setTreeNode(e,n,t)})):!t.hierarchyState&&t.level+1<this.rowExpandLevel&&t.children?(t.hierarchyState=r.expand,t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)}))):t.children?(t.hierarchyState=r.collapse,t.children.forEach((e=>{e.level=(t.level??0)+1,this.setTreeNode(e,n,t)}))):(t.hierarchyState=r.none,n=1),t.size=n,n}getTreePath(t,e=30){const i=[];return this.searchPath(t,this.tree,i,e),i.shift(),i}searchPath(t,e,i,n){if(!e)return!1;if(t<e.startIndex||t>=e.startIndex+e.size)return!1;if(i.push(e),!e.children||0===e.children.length)return!0;if(e.level>=n)return!0;const r=t-e.startIndex;return e.children.some((t=>this.searchPath(r,t,i,n))),!0}movePosition(t,e,i){let n,r,o;const s=(a,l)=>{if((void 0===r||void 0===o)&&(a.level===t&&(a.startInTotal===e&&(r=l),a.startInTotal<=i&&i<=a.startInTotal+a.size-1&&(o=l)),a.children&&a.level<t)){n=a;for(let t=0;t<a.children.length;t++)(e>=a.children[t].startInTotal&&e<=a.children[t].startInTotal+a.children[t].size||i>=a.children[t].startInTotal&&i<=a.children[t].startInTotal+a.children[t].size)&&s(a.children[t],t)}};s(this.tree,0);const a=n.children.splice(r,1);a.unshift(o,0),Array.prototype.splice.apply(n.children,a)}}let qP=0,ZP=0;class JP{_showHeader=!0;rowDimensionTree;columnDimensionTree;rowTree;columnTree;cornerHeaderObjs;columnHeaderObjs=[];rowHeaderObjs=[];_cornerHeaderCellIds=[];_columnHeaderCellIds=[];_rowHeaderCellIds=[];_columnWidths=[];rowsDefine;columnsDefine;indicatorsDefine;columnPaths=[];_headerObjects=[];_headerObjectMap={};_indicators=[];indicatorTitle;indicatorsAsCol=!0;hideIndicatorName=!1;_showRowHeader=!0;_showColumnHeader=!0;_rowHeaderTitle;_columnHeaderTitle;cornerSetting;_indicatorShowType="column";rowHierarchyType;rowExpandLevel;rowHierarchyIndent;rowDimensionKeys=[];colDimensionKeys=[];indicatorKeys=[];indicatorDimensionKey=Fe;_cellRangeMap;_CellHeaderPathMap;_table;constructor(t){if(this._table=t,this._cellRangeMap=new Map,this._CellHeaderPathMap=new Map,this.rowTree=t.options.rowTree,this.columnTree=t.options.columnTree,this.rowsDefine=t.options.rows??[],this.columnsDefine=t.options.columns??[],this.indicatorsDefine=t.options.indicators??[],this.indicatorTitle=t.options.indicatorTitle,this.hideIndicatorName=t.options.hideIndicatorName??!1,this.showRowHeader=t.options.showRowHeader??!0,this.showColumnHeader=t.options.showColumnHeader??!0,this.rowHeaderTitle=t.options.rowHeaderTitle,this.columnHeaderTitle=t.options.columnHeaderTitle,this.rowHierarchyType=t.options.rowHierarchyType??"grid",this.rowExpandLevel=t.options.rowExpandLevel??1,this.rowHierarchyIndent=t.options.rowHierarchyIndent??20,this.cornerSetting=t.options.corner??{titleOnDimension:"column"},this.indicatorsDefine?.forEach((t=>{"string"==typeof t?this.indicatorKeys.push(t):this.indicatorKeys.push(t.indicatorKey)})),this.columnDimensionTree=new YP(this.columnTree??[]),this.rowDimensionTree=new YP(this.rowTree??[],this.rowHierarchyType,"tree"===this.rowHierarchyType?this.rowExpandLevel:void 0),this.colDimensionKeys=this.columnDimensionTree.dimensionKeys.valueArr(),this.rowDimensionKeys=this.rowDimensionTree.dimensionKeys.valueArr(),this.cornerHeaderObjs="column"===this.cornerSetting.titleOnDimension?this._addCornerHeaders(this.columnHeaderTitle?[""].concat(this.colDimensionKeys):this.colDimensionKeys):"row"===this.cornerSetting.titleOnDimension?this._addCornerHeaders(this.rowHeaderTitle?[""].concat(this.rowDimensionKeys):this.rowDimensionKeys):this._addCornerHeaders(null),this.columnDimensionTree.tree.children&&(this.columnHeaderObjs=this._addHeaders(this._columnHeaderCellIds,0,this.columnDimensionTree.tree.children,[]),this.columnHeaderTitle)){const t=++qP,e=Array(this.colCount-this.rowHeaderLevelCount).fill(t);this._columnHeaderCellIds.unshift(e);const i={id:t,caption:"string"==typeof this.columnHeaderTitle.title?this.columnHeaderTitle.title:this.columnsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),""),field:void 0,headerType:this.columnHeaderTitle.headerType??"text",style:this.columnHeaderTitle.headerStyle,define:{id:t}};this.columnHeaderObjs.push(i),this._headerObjects[t]=i}if(ZP=0,this.rowDimensionTree.tree.children&&(this.rowHeaderObjs="tree"===this.rowHierarchyType?this._addHeadersForTreeMode(this._rowHeaderCellIds,0,this.rowDimensionTree.tree.children,[],this.rowDimensionTree.totalLevel,!0):this._addHeaders(this._rowHeaderCellIds,0,this.rowDimensionTree.tree.children,[])),this.rowHeaderTitle){const t=++qP,e=Array(this.rowCount-this.columnHeaderLevelCount).fill(t);this._rowHeaderCellIds.unshift(e);const i={id:t,caption:"string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),""),field:void 0,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{id:t}};this.rowHeaderObjs.push(i),this._headerObjects[t]=i}ZP=0,this.indicatorsAsCol=!A(this.rowDimensionKeys.find((t=>t===this.indicatorDimensionKey))),this._rowHeaderCellIds=C(this._rowHeaderCellIds),this._headerObjectMap=this._headerObjects.reduce(((t,e)=>(t[e.id]=e,t)),{}),this.indicatorsAsCol&&!this.hideIndicatorName?this._indicatorShowType="column":this.indicatorsAsCol||this.hideIndicatorName?this._indicatorShowType="none":this._indicatorShowType="row",this.setColumnWidths()}_addHeaders(t,e,i,n){const r=[];return t[e]||function(e){const i=t[e]=[];if(0===ZP)return i;const n=t[e-1];for(let t=0;t<n?.length;t++)i[t]=n[t]}(e),i.forEach((i=>{const o=i.id,s=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey)),a=this.indicatorsDefine?.find((t=>"string"!=typeof t&&(i.indicatorKey?t.indicatorKey===i.indicatorKey:t.caption===i.value))),l={id:o,caption:i.value??a.caption,field:i.dimensionKey,style:"function"==typeof(a??s)?.headerStyle?(a??s)?.headerStyle:Object.assign({},(a??s)?.headerStyle),headerType:a?.headerType??s?.headerType??"text",headerIcon:a?.headerIcon??s?.headerIcon,define:Object.assign({},i,a??s),fieldFormat:a?.headerFormat??s?.headerFormat,dropDownMenu:a?.dropDownMenu??s?.dropDownMenu,pivotInfo:{value:i.value,dimensionKey:i.dimensionKey,isPivotCorner:!1},width:s?.width,minWidth:s?.minWidth,maxWidth:s?.maxWidth,showSort:a?.showSort??s?.showSort,description:s?.description};a?(a.customRender&&(i.customRender=a.customRender),A(this._indicators.find((t=>t.indicatorKey===a.indicatorKey)))||this._indicators.push({id:++qP,indicatorKey:a.indicatorKey,field:a.indicatorKey,fieldFormat:a?.format,columnType:a?.columnType??"text",chartType:"chartType"in a?a.chartType:null,chartSpec:"chartSpec"in a?a.chartSpec:null,sparklineSpec:"sparklineSpec"in a?a.sparklineSpec:null,style:a?.style,icon:a?.icon,define:Object.assign({},i,a,{dragHeader:s?.dragHeader}),width:a?.width,minWidth:a?.minWidth,maxWidth:a?.maxWidth,disableColumnResize:a?.disableColumnResize})):i.indicatorKey&&(A(this._indicators.find((t=>t.indicatorKey===i.indicatorKey)))||this._indicators.push({id:++qP,indicatorKey:i.indicatorKey,field:i.indicatorKey,columnType:"text",define:Object.assign({},i)})),r[o]=l,this._headerObjects[o]=l,t[e][ZP]=o;for(let i=e-1;i>=0;i--)t[i][ZP]=n[i];if(i.children)this._addHeaders(t,e+1,i.children??[],[...n,o]).forEach((t=>r.push(t)));else{for(let i=e+1;i<t.length;i++)t[i][ZP]=o;ZP++}})),r}_addHeadersForTreeMode(t,e,i,n,o,s){const a=[];return t[e]||function(e){const i=t[e]=[];if(0===ZP)return i;const n=t[e-1];for(let t=0;t<n?.length;t++)i[t]=n[t]}(e),i.forEach((i=>{const l=i.id,h=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey)),c={id:l,caption:i.value,field:i.dimensionKey,style:i.level+1===o||"function"==typeof h?.headerStyle?h?.headerStyle:Object.assign({},h?.headerStyle,{textAlign:"left"}),headerType:h?.headerType??"text",headerIcon:h?.headerIcon,define:Object.assign(i,{linkJump:h?.linkJump,linkDetect:h?.linkDetect,templateLink:h?.templateLink,keepAspectRatio:h?.keepAspectRatio??!1,imageAutoSizing:h?.imageAutoSizing,headerCustomRender:h?.headerCustomRender,headerCustomLayout:h?.headerCustomLayout,dragHeader:h?.dragHeader}),fieldFormat:h?.headerFormat,dropDownMenu:h?.dropDownMenu,pivotInfo:{value:i.value,dimensionKey:i.dimensionKey,isPivotCorner:!1},hierarchyLevel:i.level,dimensionTotalLevel:o,hierarchyState:i.level+1===o?void 0:i.hierarchyState,width:h?.width,minWidth:h?.minWidth,maxWidth:h?.maxWidth};a[l]=c,this._headerObjects[l]=c,t[e][ZP]=l;for(let i=e-1;i>=0;i--)t[i][ZP]=n[i];if(i.hierarchyState===r.expand&&i.children)s&&ZP++,this._addHeadersForTreeMode(t,e,i.children??[],[...n,l],o,s&&i.hierarchyState===r.expand).forEach((t=>a.push(t)));else{s&&ZP++;for(let i=e+1;i<t.length;i++)t[i][ZP]=l}})),a}_addCornerHeaders(t){const e=[];if(t)t.forEach(((t,i)=>{const n=++qP,r=this.rowsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t))??this.columnsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t)),o={id:n,caption:t===this.indicatorDimensionKey?this.indicatorTitle:r?.dimensionTitle??"",field:"维度名称",style:this.cornerSetting.headerStyle,headerType:this.cornerSetting.headerType??"text",define:{dimensionKey:"维度名称",id:n,value:t},dropDownMenu:r?.cornerDropDownMenu,pivotInfo:{value:r?.dimensionTitle??"",dimensionKey:t,isPivotCorner:!0},description:r?.cornerDescription};if(e[n]=o,this._headerObjects[n]=o,"column"===this.cornerSetting.titleOnDimension){this._cornerHeaderCellIds[i]||(this._cornerHeaderCellIds[i]=[]);for(let t=0;t<this.rowHeaderLevelCount;t++)this._cornerHeaderCellIds[i][t]=n}else if("row"===this.cornerSetting.titleOnDimension)for(let t=0;t<this.columnHeaderLevelCount;t++)this._cornerHeaderCellIds[t]||(this._cornerHeaderCellIds[t]=[]),this._cornerHeaderCellIds[t][i]=n}));else{const t=++qP,i={id:t,caption:"",field:"维度名称",style:this.cornerSetting.headerStyle,headerType:this.cornerSetting.headerType??"text",define:{dimensionKey:"维度名称",id:t,value:""}};e[t]=i,this._headerObjects[t]=i;for(let e=0;e<this.columnHeaderLevelCount;e++)for(let i=0;i<this.rowHeaderLevelCount;i++)this._cornerHeaderCellIds[e]||(this._cornerHeaderCellIds[e]=[]),this._cornerHeaderCellIds[e][i]=t}return e}setColumnWidths(){const t=new Array(this.colCount).fill(void 0);if(this.showHeader&&this.showRowHeader&&(this.rowHeaderTitle&&(t[0]={}),this.rowDimensionKeys.forEach(((e,i)=>{const n=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===e));n&&(t[i+(this.rowHeaderTitle?1:0)]={width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth})}))),this.indicatorsAsCol)for(let e=this.rowHeaderLevelCount;e<this.colCount;e++){const i=this.getBody(e,this.columnHeaderLevelCount);t[e]={width:i?.width,minWidth:i?.minWidth,maxWidth:i?.maxWidth}}else{let e,i,n,r=0;this._indicators.forEach(((t,o)=>{"number"==typeof t.width?r=Math.max(t.width,r):"auto"===t.width&&(n=!0),"number"==typeof t.minWidth&&(i=Math.max(t.minWidth,i)),"number"==typeof t.maxWidth&&(e=Math.max(t.maxWidth,e))})),r=r>0?r:n?"auto":void 0,t.fill({width:r,minWidth:i,maxWidth:e},this.rowHeaderLevelCount,this.colCount)}this._columnWidths=t}get columnWidths(){return this._columnWidths}getColumnWidthDefined(t){return this._columnWidths[t]}get showHeader(){return this._showHeader}set showHeader(t){this._showHeader=t}get showColumnHeader(){return this._showColumnHeader}set showColumnHeader(t){this._showColumnHeader=t}get showRowHeader(){return this._showRowHeader}set showRowHeader(t){this._showRowHeader=t}get columnHeaderTitle(){return this._columnHeaderTitle}set columnHeaderTitle(t){this._columnHeaderTitle=t}get rowHeaderTitle(){return this._rowHeaderTitle}set rowHeaderTitle(t){this._rowHeaderTitle=t}getHeaderFieldKey(t,e){}getCellType(t,e){return this.isCornerHeader(t,e)?"cornerHeader":this.isColumnHeader(t,e)?"columnHeader":this.isRowHeader(t,e)?"rowHeader":"body"}isHeader(t,e){return t<this.rowHeaderLevelCount||(e<this.columnHeaderLevelCount||(t>=this.colCount-this.rightFrozenColCount||e>=this.rowCount-this.bottomFrozenRowCount))}isCornerHeader(t,e){return t<this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isColumnHeader(t,e){return t>=this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isRowHeader(t,e){return t<this.rowHeaderLevelCount&&e>=this.columnHeaderLevelCount}isRightFrozenColumn(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.columnHeaderLevelCount&&e<this.rowCount-this.bottomFrozenRowCount}isBottomFrozenRow(t,e){return t>=this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount&&t<this.colCount-this.rightFrozenColCount}getColumnHeaderRange(){return{start:{col:this.rowHeaderLevelCount,row:0},end:{col:this.colCount-1,row:this.columnHeaderLevelCount-1}}}getRowHeaderRange(){return{start:{col:0,row:this.columnHeaderLevelCount},end:{col:this.rowHeaderLevelCount-1,row:this.rowCount-1}}}getCornerHeaderRange(){return{start:{col:0,row:0},end:{col:this.rowHeaderLevelCount-1,row:this.columnHeaderLevelCount-1}}}getBodyRange(){return{start:{col:this.rowHeaderLevelCount,row:this.columnHeaderLevelCount},end:{col:this.colCount-1,row:this.rowCount-1}}}resetCellIds(){}get headerLevelCount(){return this.columnHeaderLevelCount}get columnHeaderLevelCount(){if(this.showHeader&&this.showColumnHeader){let t=this.indicatorsAsCol&&this.hideIndicatorName&&this.colDimensionKeys[this.colDimensionKeys.length-1]===this.indicatorDimensionKey?this.columnDimensionTree.totalLevel-1:this.columnDimensionTree.totalLevel;return this.columnHeaderTitle&&(t+=1),t}return 0}get rowHeaderLevelCount(){if(this.showHeader&&this.showRowHeader){if("tree"===this.rowHierarchyType)return this.rowHeaderTitle?2:1;let t=this.indicatorsAsCol?this.rowDimensionTree.totalLevel:this.hideIndicatorName&&this.rowDimensionKeys[this.rowDimensionKeys.length-1]===this.indicatorDimensionKey?this.rowDimensionTree.totalLevel-1:this.rowDimensionTree.totalLevel;return this.rowHeaderTitle&&(t+=1),t}return 0}get colCount(){return this.columnDimensionTree.tree.size+this.rowHeaderLevelCount+this.rightFrozenColCount}get rowCount(){return this.rowDimensionTree.tree.size+this.columnHeaderLevelCount+this.bottomFrozenRowCount}get bodyRowCount(){return this.rowDimensionTree.tree.size}get bottomFrozenRowCount(){return this.showHeader&&this.showColumnHeader?this.indicatorsAsCol&&!this.hideIndicatorName?this.indicatorsDefine.find((t=>t?.multiIndicator))?1:0:this.getDimension(this.colDimensionKeys[this.colDimensionKeys.length-1],"column")?.multiDimension?1:0:0}get rightFrozenColCount(){return this.showHeader&&this.showColumnHeader?this.indicatorsAsCol||this.hideIndicatorName?this.getDimension(this.rowDimensionKeys[this.rowDimensionKeys.length-1],"row")?.multiDimension?1:0:this.indicatorsDefine.find((t=>t?.multiIndicator))?1:0:0}get headerObjects(){return this._headerObjects}get columnObjects(){return this._indicators}getCellId(t,e){if(e>=0&&t>=0){if(this.isCornerHeader(t,e))return this._cornerHeaderCellIds[e][t];if(this.isColumnHeader(t,e))return this._columnHeaderCellIds[e][t-this.rowHeaderLevelCount];if(this.isRowHeader(t,e))return this._rowHeaderCellIds[e-this.columnHeaderLevelCount]?.[t];if(this.isRightFrozenColumn(t,e))return this._rowHeaderCellIds[e-this.columnHeaderLevelCount][this.rowHeaderLevelCount-1];if(this.isBottomFrozenRow(t,e))return this._columnHeaderCellIds[this.columnHeaderLevelCount-1]?.[t-this.rowHeaderLevelCount]}}getHeader(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]}getHeaderField(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.field||this.getBody(t,e)?.field}getHeaderCellAdress(t){for(let e=0;e<this._columnHeaderCellIds.length;e++){const i=this._columnHeaderCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return{col:n+this._table.frozenColCount,row:e}}for(let e=0;e<this._rowHeaderCellIds.length;e++){const i=this._rowHeaderCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return{col:n,row:e+this._table.frozenRowCount}}for(let e=0;e<this._cornerHeaderCellIds.length;e++){const i=this._cornerHeaderCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return{col:n,row:e}}}getHeaderCellAddressByField(t){const e=this.headerObjects.find((e=>e&&e.field===t));return this.getHeaderCellAdress(e.id)}getBody(t,e){const i=this.getCellHeaderPaths(t,e);if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicators.find((e=>e.indicatorKey===t))??this._indicators[0]??{id:"",field:void 0,indicatorKey:void 0,columnType:void 0,define:void 0}}const n=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicators.find((t=>t.indicatorKey===n))??this._indicators[0]??{id:"",field:void 0,indicatorKey:void 0,columnType:void 0,define:void 0}}getBodyLayoutRangeById(t){for(let e=0;e<(this.colCount??0);e++)if(t===this.columnObjects[e].id)return{start:{col:e,row:0},end:{col:e,row:0}};throw new Error(`can not found body layout @id=${t}`)}getCellRange(t,e){if(-1===t||-1===e)return{start:{col:t,row:e},end:{col:t,row:e}};if(this._cellRangeMap.has(`${t}-${e}`))return this._cellRangeMap.get(`${t}-${e}`);const i={start:{col:t,row:e},end:{col:t,row:e}};if(this.isHeader(t,e)&&-1!==t&&-1!==e){const n=this.getCellId(t,e);for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getCellId(r,e);r++)i.end.col=r;for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<(this.rowCount??0)&&n===this.getCellId(t,r);r++)i.end.row=r}return this._cellRangeMap.set(`${t}-${e}`,i),i}isCellRangeEqual(t,e,i,n){const r=this.getCellRange(t,e),o=this.getCellRange(i,n);return r.start.col===o.start.col&&r.end.col===o.end.col&&r.start.row===o.start.row&&r.end.row===o.end.row}getRecordIndexByRow(t){return t<this.columnHeaderLevelCount||t>=this.rowCount-this.bottomFrozenRowCount?-1:t-this.columnHeaderLevelCount}getRecordIndexByCol(t){return t<this.rowHeaderLevelCount||t>=this.colCount-this.rightFrozenColCount?-1:t-this.rowHeaderLevelCount}getRecordStartRowByRecordIndex(t){return this.columnHeaderLevelCount+t}getCellHeaderPathsWidthTreeNode(t,e){if(this._CellHeaderPathMap.has(`${t}-${e}`))return this._CellHeaderPathMap.get(`${t}-${e}`);const i=this.getRecordIndexByCol(t),n=this.getRecordIndexByRow(e);let r,o;if(t>=0&&(r=this.columnDimensionTree.getTreePath(i,this.showHeader&&this.showColumnHeader?e-(this.columnHeaderTitle?1:0):this.columnDimensionTree.totalLevel)),e>=0)if("tree"===this.rowHierarchyType)if(t>=this.rowHeaderLevelCount)o=this.rowDimensionTree.getTreePath(n,t+this.rowDimensionTree.totalLevel);else{const i=this.getHeader(t,e);o=this.rowDimensionTree.getTreePath(n,t+i.hierarchyLevel)}else o=this.rowDimensionTree.getTreePath(n,this.showHeader&&this.showRowHeader?t-(this.rowHeaderTitle?1:0):this.rowDimensionTree.totalLevel);const s={colHeaderPaths:r,rowHeaderPaths:o};return this._CellHeaderPathMap.set(`${t}-${e}`,s),s}getCellHeaderPaths(t,e){const i=this.getCellHeaderPathsWidthTreeNode(t,e),n={colHeaderPaths:[],rowHeaderPaths:[]};return i.colHeaderPaths.forEach((t=>{const e={};e.dimensionKey=t.dimensionKey,e.indicatorKey=t.indicatorKey,e.value=t.value??this.getIndicatorInfoByIndicatorKey(t.indicatorKey)?.caption??"",n.colHeaderPaths.push(e)})),i.rowHeaderPaths.forEach((t=>{const e={};e.dimensionKey=t.dimensionKey,e.indicatorKey=t.indicatorKey,e.value=t.value??this.getIndicatorInfoByIndicatorKey(t.indicatorKey)?.caption??"",n.rowHeaderPaths.push(e)})),n}getIndicatorInfoByIndicatorKey(t){const e=this.indicatorsDefine?.find((e=>"string"!=typeof e&&(!!t&&e.indicatorKey===t)));return e}getHeaderDimension(t,e){if(this.isHeader(t,e)){const i=this.getHeader(t,e);return this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))}}isColumnIndicatorHeader(t,e){return"column"===this._indicatorShowType&&e===this.columnHeaderLevelCount-1&&t>=this.rowHeaderLevelCount}isRowIndicatorHeader(t,e){return"row"===this._indicatorShowType&&t===this.rowHeaderLevelCount-1&&e>=this.columnHeaderLevelCount}isIndicatorHeader(t,e){return this.isColumnIndicatorHeader(t,e)||this.isRowIndicatorHeader(t,e)}toggleHierarchyState(t,e){const i=this._rowHeaderCellIds.slice(0),n=i.map((t=>this.getHeaderCellAdress(t[0]))),o=this.getHeader(t,e);if(o.define.hierarchyState=o.define.hierarchyState===r.collapse?r.expand:r.collapse,this.rowDimensionTree.reset(this.rowDimensionTree.tree.children,!0),this._rowHeaderCellIds=[],this.rowHeaderObjs=this._addHeadersForTreeMode(this._rowHeaderCellIds,0,this.rowDimensionTree.tree.children,[],this.rowDimensionTree.totalLevel,!0),this.rowHeaderTitle){const t=++qP,e=Array(this.rowCount-this.columnHeaderLevelCount).fill(t);this._rowHeaderCellIds.unshift(e);const i={id:t,caption:"string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),""),field:void 0,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{field:"",headerType:"text",columnType:"text"}};this.rowHeaderObjs.push(i),this._headerObjects[t]=i}return ZP=0,this._rowHeaderCellIds=C(this._rowHeaderCellIds),this._headerObjectMap=this._headerObjects.reduce(((t,e)=>(t[e.id]=e,t)),{}),this._CellHeaderPathMap=new Map,function(t,e,i,n){const r=t.map((t=>t[0])),o=e.map((t=>t[0])),s=[],a=[];for(let t=0;t<r.length;t++)o.includes(r[t])||a.push(i[t]);for(let t=0;t<o.length;t++)r.includes(o[t])||s.push(n.getHeaderCellAdress(o[t]));return{addCellPositions:s,removeCellPositions:a}}(i,this._rowHeaderCellIds,n,this)}isHeaderForColWidth(t,e){return this.isHeader(t,e)}getHeaderForColWidth(t,e){return this.getHeader(t,e)}getPivotCellAdress(t){if(!Array.isArray(t))return;let e,i,n=this.rowTree,r=this.columnTree;for(let o=0;o<t.length;o++){const s=t[o];if((s.isPivotCorner||!s.value)&&o===t.length-1){if("row"===this?.cornerSetting?.titleOnDimension){let t=0;return"grid"===this.rowHierarchyType&&(t=this.rowDimensionKeys.indexOf(s.dimensionKey)),-1===t?void 0:{col:this.rowHeaderTitle?t+1:t,row:0}}const t=this.colDimensionKeys.indexOf(s.dimensionKey);return-1===t?void 0:{col:0,row:this.columnHeaderTitle?t+1:t}}let a=!1;for(let t=0;t<r.length;t++){const e=r[t];if((A(s.dimensionKey)&&e.dimensionKey===s.dimensionKey||A(s.indicatorKey)&&e.indicatorKey===s.indicatorKey)&&e.value===s.value){r=e.children,i=e,a=!0;break}}if(!a)for(let t=0;t<n.length;t++){const i=n[t];if((A(s.dimensionKey)&&i.dimensionKey===s.dimensionKey||A(s.indicatorKey)&&i.indicatorKey===s.indicatorKey)&&i.value===s.value){n=i.children,e=i;break}}}let o=0,s=0;if(e){s=this.columnHeaderLevelCount;const{startInTotal:t,level:i}=e;return s+=t,o="grid"===this.rowHierarchyType?this.rowHeaderTitle?i+1:i:0,{col:o,row:s}}if(i){o=this.rowHeaderLevelCount;const{startInTotal:t,level:e}=i;return o+=t,s=this.columnHeaderTitle?e+1:e,{col:o,row:s}}}getPivotDimensionInfo(t,e){const{colHeaderPaths:i,rowHeaderPaths:n}=this.getCellHeaderPaths(t,e),r=[];return i.length?i.forEach(((t,e)=>{r.push({dimensionKey:t.dimensionKey,value:t.value,isPivotCorner:!1,indicatorKey:t.indicatorKey})})):n.length?n.forEach(((t,e)=>{r.push({dimensionKey:t.dimensionKey,value:t.value,isPivotCorner:!1,indicatorKey:t.indicatorKey})})):this.isCornerHeader(t,e)&&("row"===this?.cornerSetting?.titleOnDimension?r.push({dimensionKey:this.rowDimensionKeys[this.rowHeaderTitle?t-1:t],isPivotCorner:!0}):r.push({dimensionKey:this.colDimensionKeys[this.columnHeaderTitle?e-1:e],isPivotCorner:!0})),r}getIndicatorKey(t,e){return this.getBody(t,e)?.indicatorKey}getParentCellId(t,e){if(0!==e)return this.isColumnHeader(t,e)?this.getCellId(t,e-1):this.isRowHeader(t,e)?this.getCellId(t-1,e):void 0}canMoveHeaderPosition(t,e){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){return this.getParentCellId(t.col,i.start.row)===this.getParentCellId(e.col,i.start.row)}if(this.isRowHeader(t.col,t.row)){if("tree"!==this.rowHierarchyType){return this.getParentCellId(i.start.col,t.row)===this.getParentCellId(i.start.col,e.row)}{const i=v(this.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths),n=v(this.getCellHeaderPathsWidthTreeNode(e.col,e.row).rowHeaderPaths);if(i.pop(),n.pop(),i.length<=n.length)return i.length!==n.length||!i.find(((t,e)=>t.dimensionKey!==n[e].dimensionKey||t.value!==n[e].value))}}return!1}moveHeaderPosition(t,e){if(this.canMoveHeaderPosition(t,e)&&!this.isCellRangeEqual(t.col,t.row,e.col,e.row)){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){const n=i.end.col-i.start.col+1;let r;const o=this.getCellRange(e.col,i.start.row);if(r=e.col>=t.col?o.end.col-n+1:o.start.col,r===i.end.col)return null;for(let t=0;t<this._columnHeaderCellIds.length;t++){const e=this._columnHeaderCellIds[t].splice(i.start.col-this.rowHeaderLevelCount,n);e.unshift(r-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this._columnHeaderCellIds[t],e)}const s=this._columnWidths.splice(i.start.col,n);return s.unshift(r,0),Array.prototype.splice.apply(this._columnWidths,s),this.columnDimensionTree.movePosition(t.row,i.start.col-this.rowHeaderLevelCount,r-this.rowHeaderLevelCount),this.columnDimensionTree.reset(this.columnDimensionTree.tree.children,!0),this._CellHeaderPathMap=new Map,this._cellRangeMap=new Map,{sourceIndex:i.start.col,targetIndex:r,moveSize:n,moveType:"column"}}if(this.isRowHeader(t.col,t.row)){let n;const r=this.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths,o=this.getCellHeaderPathsWidthTreeNode(e.col,e.row).rowHeaderPaths,s=r[r.length-1],a=o[r.length-1],l=s.size;if(n=e.row>=t.row?a.startInTotal+a.size-l:a.startInTotal,n===t.row||n===i.end.row)return null;const h=this._rowHeaderCellIds.splice(i.start.row-this.columnHeaderLevelCount,l);return h.unshift(n,0),Array.prototype.splice.apply(this._rowHeaderCellIds,h),this.rowDimensionTree.movePosition(this.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths.length-1,i.start.row-this.columnHeaderLevelCount,n+(e.row>t.row?s.size-1:0)),this.rowDimensionTree.reset(this.rowDimensionTree.tree.children,!0),this._CellHeaderPathMap=new Map,this._cellRangeMap=new Map,{sourceIndex:i.start.row,targetIndex:n+this.columnHeaderLevelCount,moveSize:l,moveType:"row"}}}return null}getCellAdressByHeaderPath(t){let e,i;if(Array.isArray(t)){if(t.length>this.rowDimensionKeys.length+this.colDimensionKeys.length)return;e=t.filter((t=>this.colDimensionKeys.indexOf(t.dimensionKey)>=0)),i=t.filter((t=>this.rowDimensionKeys.indexOf(t.dimensionKey)>=0))}else e=t.colHeaderPaths,i=t.rowHeaderPaths;if(!Array.isArray(e)&&!Array.isArray(i))return;e?.sort(((t,e)=>this.colDimensionKeys.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.colDimensionKeys.indexOf(e.dimensionKey??this.indicatorDimensionKey))),i?.sort(((t,e)=>this.rowDimensionKeys.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.rowDimensionKeys.indexOf(e.dimensionKey??this.indicatorDimensionKey)));let n,r,o,s,a=!1;e?.length>=1&&i?.length>=1&&(a=!0);let l,h,c=this.rowTree,d=this.columnTree;if(e)for(let t=0;t<e.length;t++){const i=e[t];for(let t=0;t<d.length;t++){const e=d[t];if(!A(i.indicatorKey)&&e.dimensionKey===i.dimensionKey&&e.value===i.value||A(i.indicatorKey)&&e.indicatorKey===i.indicatorKey){d=e.children,a&&!d?h=e:a||(h=e);break}}}if(i)for(let t=0;t<i.length;t++){const e=i[t];for(let t=0;t<c.length;t++){const i=c[t];if((!A(e.indicatorKey)&&i.dimensionKey===e.dimensionKey&&i.value===e.value||A(e.indicatorKey)&&i.indicatorKey===e.indicatorKey)&&i.value===e.value){c=i.children,a&&!c?l=i:a||(l=i);break}}}if(!a||l&&h){if(l){r=this.columnHeaderLevelCount;const{startInTotal:t,level:e}=l;r+=t,o="grid"===this.rowHierarchyType?this.rowHeaderTitle?e+1:e:0}if(h){n=this.rowHeaderLevelCount;const{startInTotal:t,level:e}=h;n+=t,s=this.columnHeaderTitle?e+1:e}return A(n)||A(r)?{col:n??o,row:r??s}:void 0}}setChartInstance(t,e,i){const n=this.getCellHeaderPaths(t,e);let r;if(this.indicatorsAsCol){const t=n.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicators.find((e=>e.indicatorKey===t))}else{const t=n.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicators.find((e=>e.indicatorKey===t))}r&&(r.chartInstance=i)}getChartInstance(t,e){const i=this.getCellHeaderPaths(t,e);let n;if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicators.find((e=>e.indicatorKey===t))}else{const t=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicators.find((e=>e.indicatorKey===t))}return n?.chartInstance}getDimension(t,e){return"column"===e?this.columnsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t)):"row"===e?this.rowsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t)):void 0}getAxisConfigInPivotChart(t,e){}isEmpty(t,e){return!1}getChartAxes(t,e){return[]}}const QP={isEmpty:!0,id:void 0,field:void 0,headerType:void 0,define:void 0};class tE{_headerObjects=[];_headerObjectMap={};_indicatorObjects=[];_columnWidths=[];rowTree;columnTree;rowsDefine;columnsDefine;indicatorsDefine;indicatorKeys;_showRowHeader=!0;_showColumnHeader=!0;_rowHeaderTitle;_columnHeaderTitle;_indicatorShowType="column";indicatorsAsCol=!0;hideIndicatorName=!1;indicatorDimensionKey=Fe;indicatorTitle;rowKeysPath;colKeysPath;convertColKeys;rows;columns;rowShowAttrs;colShowAttrs;tree;dataset;dataConfig;_rowCount;_colCount;_bodyRowCount;cornerSetting;_table;hasTwoIndicatorAxes;constructor(t,e){this._table=t,this.rowTree=t.options.rowTree,this.columnTree=t.options.columnTree,this.rowsDefine=t.options.rows??[],this.columnsDefine=t.options.columns??[],this.indicatorsDefine=t.options.indicators??[],this.indicatorTitle=t.options.indicatorTitle,this.dataset=e,this.dataConfig=e.dataConfig,this.indicatorKeys=e.indicatorKeys,this.indicatorsAsCol=t.options.indicatorsAsCol??!0,this.hideIndicatorName=t.options.hideIndicatorName??!1,this.showRowHeader=t.options.showRowHeader??!0,this.showColumnHeader=t.options.showColumnHeader??!0,this.rowHeaderTitle=t.options.rowHeaderTitle,this.columnHeaderTitle=t.options.columnHeaderTitle,this.cornerSetting=t.options.corner??{titleOnDimension:"column"},this.columns=e.columns,this.rows=e.rows,this.rowKeysPath=e.rowKeysPath,this.colKeysPath=e.colKeysPath,this.tree=e.tree,this.initState(),this.convertColKeys=C(this.colKeysPath)}initState(){if(this.indicatorsAsCol&&!this.hideIndicatorName?this._indicatorShowType="column":this.indicatorsAsCol||this.hideIndicatorName?this._indicatorShowType="none":this._indicatorShowType="row",this.colShowAttrs="column"===this._indicatorShowType?this.columns.concat(this.indicatorDimensionKey):Array.from(this.columns),this.rowShowAttrs="row"===this._indicatorShowType?this.rows.concat(this.indicatorDimensionKey):Array.from(this.rows),this._bodyRowCount=this.rowKeysPath.length*(this.indicatorsAsCol?1:this.indicatorKeys.length),this.initHeaderObjects(),this.initIndicatorObjects(),this.rowHeaderTitle){const t="rowHeaderTitle",e="string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),"");this._headerObjectMap[e]={id:e,caption:e,field:t,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{}},this._headerObjectMap[t]={id:t,caption:"",field:t,headerType:this.cornerSetting.headerType??"text",style:this.cornerSetting.headerStyle,define:{}},this._headerObjects.push(this._headerObjectMap[e]),this._headerObjects.push(this._headerObjectMap[t]),this.rowShowAttrs.unshift(t),this.rowKeysPath.forEach(((t,i)=>{t.unshift(e)}))}if(this.columnHeaderTitle){const t="columnHeaderTitleCell",e="string"==typeof this.columnHeaderTitle.title?this.columnHeaderTitle.title:this.columnsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),"");this._headerObjectMap[e]={id:e,caption:e,field:t,headerType:this.columnHeaderTitle.headerType??"text",style:this.columnHeaderTitle.headerStyle,define:{}},this._headerObjectMap[t]={id:t,caption:"",field:t,headerType:this.cornerSetting.headerType??"text",style:this.cornerSetting.headerStyle,define:{}},this._headerObjects.push(this._headerObjectMap[e]),this._headerObjects.push(this._headerObjectMap[t]),this.colShowAttrs.unshift(t),this.colKeysPath.forEach(((t,i)=>{t.unshift(e)}))}if(this._table.isPivotChart())if(this.hasTwoIndicatorAxes=this._indicatorObjects.some((t=>!!(t.chartSpec&&t.chartSpec.series&&t.chartSpec.series.length>1))),this.indicatorsAsCol){const t="rowHeaderEmpty";this._headerObjectMap[t]={id:t,caption:"",field:t,headerType:this.cornerSetting.headerType??"text",style:this.cornerSetting.headerStyle,define:{}},this._headerObjects.push(this._headerObjectMap[t]),this.rowShowAttrs.push(t),this.hasTwoIndicatorAxes||this.colShowAttrs.pop()}else{const t=this._table.pivotChartAxes.find((t=>"left"===t.orient));!1===t?.visible&&this.rowShowAttrs.pop()}this._colCount=(0===this.colKeysPath.length?1:this.colKeysPath.length)*(this.indicatorsAsCol?this.indicatorKeys.length:1)+this.rowHeaderLevelCount+this.rightFrozenColCount,this._rowCount=(0===this.rowKeysPath.length?1:this.rowKeysPath.length)*(this.indicatorsAsCol?1:this.indicatorKeys.length)+this.columnHeaderLevelCount+this.bottomFrozenRowCount,this.setColumnWidths()}setColumnWidths(){const t=new Array(this.colCount).fill(void 0);if(this.showRowHeader&&(this.rowHeaderTitle&&(t[0]={}),this.rowShowAttrs.forEach(((e,i)=>{const n=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===e));n&&(t[i+(this.rowHeaderTitle?1:0)]={width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth})}))),this.indicatorsAsCol)for(let e=this.rowHeaderLevelCount;e<this.colCount;e++){const i=this.getBody(e,this.columnHeaderLevelCount);t[e]={width:i?.width,minWidth:i?.minWidth,maxWidth:i?.maxWidth}}else{let e,i,n,r=0;this._indicatorObjects.forEach(((t,o)=>{"number"==typeof t.width?r=Math.max(t.width,r):"auto"===t.width&&(n=!0),"number"==typeof t.minWidth&&(i=Math.max(t.minWidth,i)),"number"==typeof t.maxWidth&&(e=Math.max(t.maxWidth,e))})),r=r>0?r:n?"auto":void 0,t.fill({width:r,minWidth:i,maxWidth:e},this.rowHeaderLevelCount,this.colCount)}this._columnWidths=t}get columnWidths(){return this._columnWidths}getColumnWidthDefined(t){return this._columnWidths[t]}getDimensionInfo(t){return this.rowsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t))??this.columnsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t))}getIndicatorInfo(t,e=""){const i=this.indicatorsDefine?.find((i=>"string"!=typeof i&&(t?i.indicatorKey===t:!!e&&i.caption===e)));return i}getColKeysPath(){return this.colKeysPath}getRowKeysPath(){return this.rowKeysPath}initHeaderObjects(){for(let t=0,e=this.rowKeysPath.length;t<=e-1;t++){const e=this.rowKeysPath[t];for(let t=0,i=e.length;t<=i-1;t++)if(!this._headerObjectMap[e[t]]){const i=e[t].split(this.dataset.stringJoinChar),n=this.getDimensionInfo(this.rows[i.length-1]);this._headerObjectMap[e[t]]={id:e[t],field:n?.dimensionKey??this.rows[i.length-1],caption:i[i.length-1],style:n?.headerStyle,define:{field:n?.dimensionKey??this.rows[i.length-1],headerType:n?.headerType??"text",columnType:"text"},fieldFormat:n?.headerFormat,dropDownMenu:n?.dropDownMenu,headerType:n?.headerType??"text",width:n?.width},this._headerObjects.push(this._headerObjectMap[e[t]])}}for(let t=0,e=this.colKeysPath.length;t<=e-1;t++){const e=this.colKeysPath[t];for(let t=0,i=e.length;t<=i-1;t++)if(!this._headerObjectMap[e[t]]){const i=e[t].split(this.dataset.stringJoinChar),n=this.getDimensionInfo(this.columns[i.length-1]);this._headerObjectMap[e[t]]={id:e[t],field:n?.dimensionKey??this.columns[i.length-1],caption:i[i.length-1],style:n?.headerStyle,define:{field:n?.dimensionKey??this.columns[i.length-1],headerType:n?.headerType??"text",columnType:"text"},fieldFormat:n?.headerFormat,dropDownMenu:n?.dropDownMenu,headerType:n?.headerType??"text",width:n?.width},this._headerObjects.push(this._headerObjectMap[e[t]])}}let t;this.indicatorsDefine.forEach((t=>{const e="string"==typeof t?t:t.indicatorKey,i="string"==typeof t?void 0:t;this._headerObjectMap[e]||(this._headerObjectMap[e]={id:e,field:this.indicatorDimensionKey,caption:i.caption??e,style:i?.headerStyle,define:{field:this.indicatorDimensionKey,headerType:i?.headerType??"text",columnType:"text"},dropDownMenu:i?.dropDownMenu,headerType:i?.headerType??"text",width:i?.width},this._headerObjects.push(this._headerObjectMap[e]))})),"column"===this.cornerSetting.titleOnDimension?t=this.colShowAttrs:"row"===this.cornerSetting.titleOnDimension&&(t=this.rowShowAttrs),t.forEach((t=>{if(!this._headerObjectMap[t]){const e=this.getDimensionInfo(t);this._headerObjectMap[t]={id:t,field:t,caption:t===this.indicatorDimensionKey?this.indicatorTitle:e?.dimensionTitle??t,style:this.cornerSetting?.headerStyle,define:{field:t,headerType:this.cornerSetting?.headerType??"text",columnType:"text"},dropDownMenu:e?.dropDownMenu,headerType:this.cornerSetting?.headerType??"text",width:e?.width},this._headerObjects.push(this._headerObjectMap[t])}}))}initIndicatorObjects(){this.indicatorKeys.forEach((t=>{const e=this.indicatorsDefine?.find((e=>"string"!=typeof e&&e.indicatorKey===t));this._indicatorObjects.push({id:t,indicatorKey:t,field:t,define:Object.assign({field:t,headerType:"text",columnType:e?.columnType??"text"},e),fieldFormat:e?.format,columnType:e?.columnType??"text",chartType:e&&("chartType"in e?e.chartType:null),chartSpec:e&&("chartSpec"in e?e.chartSpec:null),sparklineSpec:"sparklineSpec"in e?e.sparklineSpec:null,style:e?.style,icon:e?.icon,width:e?.width,minWidth:e?.minWidth,maxWidth:e?.maxWidth,disableColumnResize:e?.disableColumnResize})}))}get showColumnHeader(){return this._showColumnHeader}set showColumnHeader(t){this._showColumnHeader=t}get showRowHeader(){return this._showRowHeader}set showRowHeader(t){this._showRowHeader=t}get columnHeaderTitle(){return this._columnHeaderTitle}set columnHeaderTitle(t){this._columnHeaderTitle=t}get rowHeaderTitle(){return this._rowHeaderTitle}set rowHeaderTitle(t){this._rowHeaderTitle=t}getCellType(t,e){return this.isCornerHeader(t,e)?"cornerHeader":this.isColumnHeader(t,e)?"columnHeader":this.isRowHeader(t,e)?"rowHeader":"body"}isHeader(t,e){return t<this.rowHeaderLevelCount||(e<this.columnHeaderLevelCount||(t>=this.colCount-this.rightFrozenColCount||e>=this.rowCount-this.bottomFrozenRowCount))}isCornerHeader(t,e){return t<this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isColumnHeader(t,e){return t>=this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isRightFrozenColumn(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.columnHeaderLevelCount&&e<this.rowCount-this.bottomFrozenRowCount}isBottomFrozenRow(t,e){return t>=this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount&&t<this.colCount-this.rightFrozenColCount}isRowHeader(t,e){return t<this.rowHeaderLevelCount&&e>=this.columnHeaderLevelCount}isColumnIndicatorHeader(t,e){return"column"===this._indicatorShowType&&e===this.columnHeaderLevelCount-1&&t>=this.rowHeaderLevelCount}isRowIndicatorHeader(t,e){return"row"===this._indicatorShowType&&t===this.rowHeaderLevelCount-1&&e>=this.columnHeaderLevelCount}isIndicatorHeader(t,e){return this.isColumnIndicatorHeader(t,e)||this.isRowIndicatorHeader(t,e)}getColumnHeaderRange(){return{start:{col:this.rowHeaderLevelCount,row:0},end:{col:this.colCount-1,row:this.columnHeaderLevelCount-1}}}getRowHeaderRange(){return{start:{col:0,row:this.columnHeaderLevelCount},end:{col:this.rowHeaderLevelCount-1,row:this.rowCount-1}}}getCornerHeaderRange(){return{start:{col:0,row:0},end:{col:this.rowHeaderLevelCount-1,row:this.columnHeaderLevelCount-1}}}getBodyRange(){return{start:{col:this.rowHeaderLevelCount,row:this.columnHeaderLevelCount},end:{col:this.colCount-1,row:this.rowCount-1}}}resetCellIds(){}get headerLevelCount(){return this.columnHeaderLevelCount}get columnHeaderLevelCount(){const t=this.colShowAttrs.length;if(this.showColumnHeader){return this.indicatorsAsCol&&this.hideIndicatorName&&this.colShowAttrs[this.colShowAttrs.length-1]===this.indicatorDimensionKey?t-1:t}return 0}get rowHeaderLevelCount(){const t=this.rowShowAttrs.length;if(this.showRowHeader){return this.indicatorsAsCol?t:this.hideIndicatorName&&this.rowShowAttrs[this.rowShowAttrs.length-1]===this.indicatorDimensionKey?t-1:t}return 0}get colCount(){return this._colCount}get rowCount(){return this._rowCount}get bodyRowCount(){return this._bodyRowCount}get bottomFrozenRowCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"bottom"===t.orient));return!1===t?.visible?0:(this.indicatorsAsCol,1)}get rightFrozenColCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"right"===t.orient));return!1===t?.visible||this.indicatorsAsCol?0:this.hasTwoIndicatorAxes?1:0}get leftAxesCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"left"===t.orient));return!1===t?.visible?0:(this.indicatorsAsCol,1)}get topAxesCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"top"===t.orient));return!1===t?.visible?0:this.indicatorsAsCol&&this.hasTwoIndicatorAxes?1:0}get rightAxesCount(){return this.rightFrozenColCount}get bottomAxesCount(){return this.bottomFrozenRowCount}get headerObjects(){return this._headerObjects}get columnObjects(){return this._indicatorObjects}getCellId(t,e){if(t<this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount||e<this.columnHeaderLevelCount&&t>=this.colCount-this.rightFrozenColCount)return 0;if(e>=0&&t>=0)if(this.isCornerHeader(t,e)){if("column"===this.cornerSetting.titleOnDimension)return this.colShowAttrs[e];if("row"===this.cornerSetting.titleOnDimension)return this.rowShowAttrs[t]}else{if(this.isColumnHeader(t,e))return e<this.columns.length+(this.columnHeaderTitle?1:0)?this.convertColKeys[e][this.indicatorsAsCol?Math.floor((t-this.rowHeaderLevelCount)/this.indicatorKeys.length):t-this.rowHeaderLevelCount]:this.indicatorKeys[(t-this.rowHeaderLevelCount)%this.indicatorKeys.length];if(this.isRowHeader(t,e))return t<this.rows.length+(this.rowHeaderTitle?1:0)?this.rowKeysPath[this.indicatorsAsCol?e-this.columnHeaderLevelCount:Math.floor((e-this.columnHeaderLevelCount)/this.indicatorKeys.length)][t]:this.indicatorKeys[(e-this.columnHeaderLevelCount)%this.indicatorKeys.length];if(this.isRightFrozenColumn(t,e))return this.indicatorsAsCol?this.rowKeysPath[e-this.columnHeaderLevelCount][this.rowHeaderLevelCount-1]:this.indicatorKeys[(e-this.columnHeaderLevelCount)%this.indicatorKeys.length];if(this.isBottomFrozenRow(t,e))return this.indicatorsAsCol?this.indicatorKeys[(t-this.rowHeaderLevelCount)%this.indicatorKeys.length]:this.convertColKeys[this.columnHeaderLevelCount-1][Math.floor((t-this.rowHeaderLevelCount)/this.indicatorKeys.length)]}return 0}getIndicatorKey(t,e){if(this.isHeader(t,e))return"";if(this.indicatorsAsCol){const e=t-this.rowHeaderLevelCount;return this.indicatorKeys[e%this.indicatorKeys.length]}const i=e-this.columnHeaderLevelCount;return this.indicatorKeys[i%this.indicatorKeys.length]}getHeader(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]??QP}getHeaderField(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.field||this.getBody(t,e)?.field}getHeaderFieldKey(t,e){}getHeaderCellAdress(t){}getHeaderCellAddressByField(t){throw new Error(`Method not implemented.${t}`)}getBody(t,e){const i=this.getCellHeaderPaths(t,e);if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicatorObjects.find((e=>e.indicatorKey===t))??this._indicatorObjects[0]??{id:"",field:void 0,indicatorKey:void 0,columnType:void 0,define:void 0}}const n=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicatorObjects.find((t=>t.indicatorKey===n))??this._indicatorObjects[0]??{id:"",field:void 0,indicatorKey:void 0,columnType:void 0,define:void 0}}getBodyLayoutRangeById(t){for(let e=0;e<(this.colCount??0);e++)if(t===this.columnObjects[e].id)return{start:{col:e,row:0},end:{col:e,row:0}};throw new Error(`can not found body layout @id=${t}`)}getCellRange(t,e){const i={start:{col:t,row:e},end:{col:t,row:e}};if(!this.isHeader(t,e)||-1===t||-1===e||this.isIndicatorHeader(t,e))return i;const n=this.getCellId(t,e);for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getCellId(r,e);r++)i.end.col=r;for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<(this.rowCount??0)&&n===this.getCellId(t,r);r++)i.end.row=r;return i}isCellRangeEqual(t,e,i,n){const r=this.getCellRange(t,e),o=this.getCellRange(i,n);return r.start.col===o.start.col&&r.end.col===o.end.col&&r.start.row===o.start.row&&r.end.row===o.end.row}getRecordIndexByRow(t){return t<this.columnHeaderLevelCount?-1:this.indicatorsAsCol?t-this.columnHeaderLevelCount:Math.floor((t-this.columnHeaderLevelCount)/this.indicatorKeys.length)}getRecordIndexByCol(t){return t<this.rowHeaderLevelCount?-1:this.indicatorsAsCol?Math.floor((t-this.rowHeaderLevelCount)/this.indicatorKeys.length):t-this.rowHeaderLevelCount}getRecordStartRowByRecordIndex(t){return this.columnHeaderLevelCount+t}getCellHeaderPaths(t,e){const i=this.getRecordIndexByCol(t),n=this.getRecordIndexByRow(e);let r,o,s,a;return i>=0&&(r=this.colKeysPath[i],s=r?.[r.length-1]?.split(this.dataset.stringJoinChar),e<this.columns.length-1&&(s=s.slice(0,e+1))),n>=0&&(o=this.rowKeysPath[n],a=o?.[o.length-1]?.split(this.dataset.stringJoinChar),t<this.rows.length-1&&(a=a.slice(0,t+1))),s&&this.indicatorsAsCol&&t>=this.rowHeaderLevelCount?s.push(this.indicatorKeys[(t-this.rowHeaderLevelCount)%this.indicatorKeys.length]):a&&e>=this.columnHeaderLevelCount&&a.push(this.indicatorKeys[(e-this.columnHeaderLevelCount)%this.indicatorKeys.length]),{colHeaderPaths:s?.map(((t,e)=>{const i=this._indicatorObjects.find((e=>e.indicatorKey===t));return{dimensionKey:i?void 0:this.colShowAttrs[e],indicatorKey:i?t:void 0,value:i?i.define.caption:t}}))??[],rowHeaderPaths:a?.map(((t,e)=>{const i=this._indicatorObjects.find((e=>e.indicatorKey===t));return{dimensionKey:i?void 0:this.rowShowAttrs[e],indicatorKey:i?t:void 0,value:i?i.define.caption:t}}))??[]}}getCellAdressByHeaderPath(t){let e,i;if(Array.isArray(t)){if(t.length>this.rowShowAttrs.length+this.colShowAttrs.length)return;e=t.filter((t=>this.colShowAttrs.indexOf(t.dimensionKey)>=0)),i=t.filter((t=>this.rowShowAttrs.indexOf(t.dimensionKey)>=0))}else e=t.colHeaderPaths,i=t.rowHeaderPaths;if(!Array.isArray(e)&&!Array.isArray(i))return;e?.sort(((t,e)=>this.colShowAttrs.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.colShowAttrs.indexOf(e.dimensionKey??this.indicatorDimensionKey))),i?.sort(((t,e)=>this.rowShowAttrs.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.rowShowAttrs.indexOf(e.dimensionKey??this.indicatorDimensionKey))),e?.length>=1&&i?.length;let n,r=0,o=0,s=this.rowTree,a=this.columnTree;if(e)for(let t=0;t<e.length;t++){const i=e[t];if(i.indicatorKey){n=i.indicatorKey;break}for(let t=0;t<a.length;t++){const e=a[t];if(!A(i.indicatorKey)&&e.dimensionKey===i.dimensionKey&&e.value===i.value){a=e.children,a&&0!==a.length&&!a?.[0]?.indicatorKey||(r+=t);break}r+=e.children?.[0]?.indicatorKey?0:e.children?.length??0}}if(i)for(let t=0;t<i.length;t++){const e=i[t];if(e.indicatorKey){n=e.indicatorKey;break}for(let t=0;t<s.length;t++){const i=s[t];if(!A(e.indicatorKey)&&i.dimensionKey===e.dimensionKey&&i.value===e.value){s=i.children,s&&0!==s.length&&!s?.[0]?.indicatorKey||(o+=t);break}o+=i.children?.[0]?.indicatorKey?0:i.children?.length??0}}return r=(this.indicatorsAsCol?r*this.indicatorKeys.length+this.indicatorKeys.indexOf(n):r)+this.rowHeaderLevelCount,o=(this.indicatorsAsCol?o:o*this.indicatorKeys.length+this.indicatorKeys.indexOf(n))+this.columnHeaderLevelCount,A(r)||A(o)?{col:r??undefined,row:o??undefined}:void 0}getHeaderDimension(t,e){if(this.isHeader(t,e)){const i=this.getHeader(t,e);return this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))}}updateDataset(t){this.dataset=t,this.dataConfig=t.dataConfig,this.rowKeysPath=t.rowKeysPath,this.colKeysPath=t.colKeysPath,this.tree=t.tree,this._indicatorObjects=[],this._headerObjects=[],this._headerObjectMap={},this.initState(),this.convertColKeys=C(this.colKeysPath)}isHeaderForColWidth(t,e){return this.isHeader(t,e)}getHeaderForColWidth(t,e){return this.getHeader(t,e)}setChartInstance(t,e,i){const n=this.getCellHeaderPaths(t,e);let r;if(this.indicatorsAsCol){const t=n.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicatorObjects.find((e=>e.indicatorKey===t))}else{const t=n.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicatorObjects.find((e=>e.indicatorKey===t))}r&&(r.chartInstance=i)}getChartInstance(t,e){const i=this.getCellHeaderPaths(t,e);let n;if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicatorObjects.find((e=>e.indicatorKey===t))}else{const t=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicatorObjects.find((e=>e.indicatorKey===t))}return n?.chartInstance}_generateChartState(){return{vtable_selected:{filter:t=>{if(this._table._selectedDataItemsInChart.length>=1){return!!this._table._selectedDataItemsInChart.find((e=>{for(const i in e)if(e[i]!==t[i])return!1;return!0}))}if(this._table._selectedDimensionInChart.length){return!!this._table._selectedDimensionInChart.every((e=>t[e.key]===e.value))}return!1}},vtable_selected_reverse:{filter:t=>{if(this._table._selectedDataItemsInChart.length>=1){return!this._table._selectedDataItemsInChart.find((e=>{for(const i in e)if(e[i]!==t[i])return!1;return!0}))}if(this._table._selectedDimensionInChart.length){return!this._table._selectedDimensionInChart.every((e=>t[e.key]===e.value))}return!1}}}}updateDataStateToChartInstance(t){t||(t=this._table._getActiveChartInstance());const e=this._generateChartState();this._indicatorObjects.forEach((t=>{t.chartInstance.updateState(e)})),t?.updateState(e)}updateDataStateToActiveChartInstance(t){t||(t=this._table._getActiveChartInstance());const e=this._generateChartState();t?.updateState(e)}getOptimunWidthForChart(t){const e=this.getCellHeaderPaths(t,this.columnHeaderLevelCount).colHeaderPaths;let i;for(const t in this.dataset.collectValuesBy)if("xField"===this.dataset.collectValuesBy[t].type&&!this.dataset.collectValuesBy[t].range){i=this.dataset.collectedValues[t][e.map((t=>t.value)).join(this.dataset.stringJoinChar)];break}return 50*(i?.size??0)}getIndicatorKeyInChartSpec(t,e){const i=this.getRawChartSpec(t,e),n=[];return i?(!1===this.indicatorsAsCol?i.series?i.series.forEach((t=>{const e=t.yField;n.push(e)})):n.push(i.yField):i.series?i.series.forEach((t=>{const e=t.xField;n.push(e)})):n.push(i.xField),n):null}getDimensionKeyInChartSpec(t,e){const i=this.getRawChartSpec(t,e),n=[];return i?(!1===this.indicatorsAsCol?n.push(i.xField):n.push(i.yField),n):null}getAxisConfigInPivotChart(t,e){return function(t,e,i){if(i._table.isPivotChart())if(i.indicatorsAsCol){if(i.hasTwoIndicatorAxes&&e===i.columnHeaderLevelCount-1&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){const e=i.getIndicatorKeyInChartSpec(t,i.columnHeaderLevelCount-1)[1];if(!e)return;const n=i.dataset.collectedValues[e+"_align"]?i.dataset.collectedValues[e+"_align"]:i.dataset.collectedValues[e],r=i.getRecordIndexByCol(t),o=n[i.getColKeysPath()[r][i.columnHeaderLevelCount-1-i.topAxesCount]],s=i._table.pivotChartAxes.find((t=>"top"===t.orient));if(!1===s?.visible)return;return Zt({},s,{orient:"top",type:"linear",range:o,label:{flush:!0},title:{visible:!1}})}if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){const n=i.getIndicatorKeyInChartSpec(t,e),r=n[0],o=i.dataset.collectedValues[r+"_align"]?i.dataset.collectedValues[r+"_align"]:i.dataset.collectedValues[r],s=i.getRecordIndexByCol(t),a=o[i.getColKeysPath()[s][i.columnHeaderLevelCount-1-i.topAxesCount]];let l=null;n.forEach((t=>{const e=i.getIndicatorInfo(t);e&&(l=e)}));const h=i._table.pivotChartAxes.find((t=>"bottom"===t.orient));if(!1===h?.visible)return;return Zt({},h,{orient:"bottom",type:"linear",range:a,label:{flush:!0},title:{text:l?.caption,autoRotate:!0}})}if(t===i.rowHeaderLevelCount-1&&e>=i.rowHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){const t=i.getDimensionKeyInChartSpec(i.rowHeaderLevelCount,e)[0],n=i.dataset.collectedValues[t],r=i.getRecordIndexByRow(e),o=i.getRowKeysPath()[r],s=n[o[o.length-1]],a=i._table.pivotChartAxes.find((t=>"left"===t.orient));if(!1===a?.visible)return;return Zt({},a,{orient:"left",type:"band",data:Array.from(s).reverse(),title:{visible:!1}})}}else{if(t===i.rowHeaderLevelCount-1&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){const n=i.getIndicatorKeyInChartSpec(t,e),r=n[0],o=i.dataset.collectedValues[r+"_align"]?i.dataset.collectedValues[r+"_align"]:i.dataset.collectedValues[r],s=i.getRecordIndexByRow(e),a=o[i.getRowKeysPath()[s][i.rowHeaderLevelCount-1-i.leftAxesCount]];let l=null;n.forEach((t=>{const e=i.getIndicatorInfo(t);e&&(l=e)}));const h=i._table.pivotChartAxes.find((t=>"left"===t.orient));if(!1===h?.visible)return;return Zt({},h,{orient:"left",type:"linear",range:a,label:{flush:!0},title:{text:l?.caption,autoRotate:!0}})}if(t===i.colCount-i.rightFrozenColCount&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){const t=i.getIndicatorKeyInChartSpec(i.rowHeaderLevelCount-1,e)[1];if(!t)return;const n=i.dataset.collectedValues[t+"_align"]?i.dataset.collectedValues[t+"_align"]:i.dataset.collectedValues[t],r=i.getRecordIndexByRow(e),o=n[i.getRowKeysPath()[r][i.rowHeaderLevelCount-1-i.leftAxesCount]],s=i._table.pivotChartAxes.find((t=>"right"===t.orient));if(!1===s?.visible)return;return Zt({},s,{orient:"right",type:"linear",range:o,label:{flush:!0},title:{visible:!1}})}if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){const e=i.getDimensionKeyInChartSpec(t,i.columnHeaderLevelCount)[0],n=i.dataset.collectedValues[e],r=i.getRecordIndexByCol(t),o=i.getColKeysPath()[r],s=n[o[o.length-1]],a=i._table.pivotChartAxes.find((t=>"bottom"===t.orient));if(!1===a?.visible)return;return Zt({},a,{orient:"bottom",type:"band",data:Array.from(s),title:{visible:!1}})}}}(t,e,this)}getRawChartSpec(t,e){return function(t,e,i){const n=i.getCellHeaderPaths(t,e);let r;if(i.indicatorsAsCol){const t=n.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=i.columnObjects.find((e=>e.indicatorKey===t))}else{const t=n.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=i.columnObjects.find((e=>e.indicatorKey===t))}const o=r?.chartSpec;return o}(t,e,this)}getChartSpec(t,e){return function(t,e,i){let n=i.getRawChartSpec(t,e);return n?(n=$t(n),n.axes=i.getChartAxes(t,e),n.padding=0,n):null}(t,e,this)}getChartAxes(t,e){return function(t,e,i){const n=[];if(i.indicatorsAsCol){const r=i.getIndicatorKeyInChartSpec(t,e),o=i.getRecordIndexByCol(t);r.forEach(((t,e)=>{const r=(i.dataset.collectedValues[t+"_align"]?i.dataset.collectedValues[t+"_align"]:i.dataset.collectedValues[t])[i.getColKeysPath()[o][i.columnHeaderLevelCount-1-i.topAxesCount]],s=i._table.pivotChartAxes.find((t=>t.orient===(0===e?"bottom":"top")));n.push(Zt({},s,{type:"linear",orient:0===e?"bottom":"top",label:{visible:!1},title:{visible:!1},range:r,seriesIndex:e}))}));const s=i.getDimensionKeyInChartSpec(i.rowHeaderLevelCount,t)[0],a=i.dataset.collectedValues[s],l=i.getRecordIndexByRow(e),h=i.getRowKeysPath()[l],c=a[h[h.length-1]],d=i._table.pivotChartAxes.find((t=>"left"===t.orient));n.push(Zt({},d,{type:"band",orient:"left",label:{visible:!1,space:0},domainLine:{visible:!1},tick:{visible:!1},subTick:{visible:!1},title:{visible:!1},width:-1,domain:Array.from(c)}))}else{const r=i.getIndicatorKeyInChartSpec(t,e),o=i.getRecordIndexByRow(e);r.forEach(((t,e)=>{const r=(i.dataset.collectedValues[t+"_align"]?i.dataset.collectedValues[t+"_align"]:i.dataset.collectedValues[t])[i.getRowKeysPath()[o][i.rowHeaderLevelCount-1-i.leftAxesCount]],s=i._table.pivotChartAxes.find((t=>t.orient===(0===e?"left":"right")));n.push(Zt({},s,{type:"linear",orient:0===e?"left":"right",label:{visible:!1},title:{visible:!1},range:r,seriesIndex:e}))}));const s=i.getDimensionKeyInChartSpec(t,i.columnHeaderLevelCount)[0],a=i.dataset.collectedValues[s],l=i.getRecordIndexByCol(t),h=i.getColKeysPath()[l],c=a[h[h.length-1]],d=i._table.pivotChartAxes.find((t=>"bottom"===t.orient));n.push(Zt({},d,{type:"band",orient:"bottom",visible:!0,label:{visible:!1,space:0},domainLine:{visible:!1},tick:{visible:!1},subTick:{visible:!1},title:{visible:!1},height:-1,domain:Array.from(c)}))}return n}(t,e,this)}isEmpty(t,e){return!!this._table.isPivotChart()&&(t>this.colCount-this.rightFrozenColCount-1||e>this.rowCount-this.bottomFrozenRowCount-1||!(!this.hasTwoIndicatorAxes||!this.indicatorsAsCol||e!==this.columnHeaderLevelCount-1))}}class eE{dataConfig;records;tree={};colFlatKeys={};rowFlatKeys={};stringJoinChar=String.fromCharCode(0);rowsIsTotal=[];colsIsTotal=[];colGrandTotalLabel;colSubTotalLabel;rowGrandTotalLabel;rowSubTotalLabel;constructor(t,e){if(this.dataConfig=t,e){this.records=e;const t="undefined"!=typeof window?window.performance.now():0;this.setRecords(e);const i="undefined"!=typeof window?window.performance.now():0;console.log("processRecords:",i-t)}delete this.rowFlatKeys,delete this.colFlatKeys}setRecords(t){this.processRecords()}processRecords(){for(let t=0,e=this.records.length;t<e;t++){const e=this.records[t];this.processRecord(e)}}processRecord(t){const e=[],i=[];for(let e=0,n=this.dataConfig.rows.length;e<n;e++){const n=this.dataConfig.rows[e];void 0!==t[n]&&n!==this.dataConfig.indicatorDimensionKey&&i.push(t[n])}for(let i=0,n=this.dataConfig.columns.length;i<n;i++){const n=this.dataConfig.columns[i];void 0!==t[n]&&n!==this.dataConfig.indicatorDimensionKey&&e.push(t[n])}this.dataConfig.indicators.forEach((n=>{const r=t[n];void 0!==r&&(this.dataConfig.indicatorsAsCol?e.push(n):i.push(n));const o=i.join(this.stringJoinChar),s=e.join(this.stringJoinChar);0!==i.length&&(this.rowFlatKeys[o]||(this.rowFlatKeys[o]=1)),0!==e.length&&(this.colFlatKeys[s]||(this.colFlatKeys[s]=1)),0===e.length&&0===i.length||(this.tree[o]||(this.tree[o]={}),void 0!==r&&(this.tree[o][s]={value:r,record:t},this.dataConfig.indicatorsAsCol?e.pop():i.pop()))}))}getTreeNode(t=[],e=[],i){let n,r;if("string"==typeof t)n=t;else{let e=!1;t.map(((n,r)=>{n===i&&(t.splice(r,1),e=!0)})),e&&t.push(i),n=t.join(this.stringJoinChar)}if("string"==typeof e)r=e;else{let t=!1;e.map(((n,r)=>{n===i&&(e.splice(r,1),t=!0)})),t&&e.push(i),r=e.join(this.stringJoinChar)}return this.tree?.[n]?.[r]??void 0}}class iE{className="Aggregator";isRecord=!0;records=[];type;field;formatFun;_formatedValue;constructor(t,e,i){this.field=t,this.formatFun=e,this.isRecord=i??this.isRecord}formatValue(){return this._formatedValue||(this.formatFun?this._formatedValue=this.formatFun(this.value()):this._formatedValue=this.value()),this._formatedValue}reset(){this.records=[]}}class nE extends iE{type=o.RECORD;isRecord=!0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t))}value(){return this.records}reset(){this.records=[]}}class rE extends iE{type=o.SUM;sum=0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.sum+=t.value():isNaN(parseFloat(t[this.field]))||(this.sum+=parseFloat(t[this.field]))}value(){return this.sum}reset(){this.records=[],this.sum=0}}class oE extends iE{type=o.COUNT;count=0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.count+=t.value():this.count++}value(){return this.count}reset(){this.records=[],this.count=0}}class sE extends iE{type=o.AVG;sum=0;count=0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className&&t.type===o.AVG?(this.sum+=t.sum,this.count+=t.count):isNaN(parseFloat(t[this.field]))||(this.sum+=parseFloat(t[this.field]),this.count++)}value(){return this.sum/this.count}reset(){this.records=[],this.sum=0,this.count=0}}class aE extends iE{type=o.MAX;max=Number.MIN_SAFE_INTEGER;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.max=t.max>this.max?t.max:this.max:"number"==typeof t?this.max=t>this.max?t:this.max:"number"==typeof t[this.field]?this.max=t[this.field]>this.max?t[this.field]:this.max:isNaN(t[this.field])||(this.max=parseFloat(t[this.field])>this.max?parseFloat(t[this.field]):this.max)}value(){return this.max}reset(){this.records=[],this.max=Number.MIN_SAFE_INTEGER}}class lE extends iE{type=o.MIN;min=Number.MAX_SAFE_INTEGER;isRecord=!1;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.min=t.min<this.min?t.min:this.min:"number"==typeof t?this.min=t<this.min?t:this.min:"number"==typeof t[this.field]&&(this.min=t[this.field]<this.min?t[this.field]:this.min)}value(){return this.min}reset(){this.records=[],this.min=Number.MAX_SAFE_INTEGER}}function hE(t,e){return t&&e?t.toString().localeCompare(e.toString(),"zh"):t?1:-1}function cE(t,e){const i=/(\d+)|(\D+)/g,n=/\d/,r=/^0/;let o,s,a,l,h=0,c=0;if(null!==e&&null===t)return-1;if(null!==t&&null===e)return 1;if("number"==typeof t&&isNaN(t))return-1;if("number"==typeof e&&isNaN(e))return 1;if(h=+t,c=+e,h<c)return-1;if(h>c)return 1;if("number"==typeof t&&"number"!=typeof e)return-1;if("number"==typeof e&&"number"!=typeof t)return 1;if("number"==typeof t&&"number"==typeof e)return 0;if(isNaN(c)&&!isNaN(h))return-1;if(isNaN(h)&&!isNaN(c))return 1;if(o=String(t),a=String(e),o===a)return 0;if(!n.test(o)||!n.test(a))return o>a?1:-1;for(o=o.match(i),a=a.match(i);o.length&&a.length;)if(s=o.shift(),l=a.shift(),s!==l)return n.test(s)&&n.test(l)?s.replace(r,".0")-l.replace(r,".0"):s>l?1:-1;return o.length-a.length}function dE(t){return 2===t.length&&zt(t[0])&&zt(t[1])&&t[1]>=t[0]}function uE(t){const e=t[1]-t[0],i=t[1]*t[0]<0;let n=t[0]<=0?0-t[0]:0,r=t[1]>0?t[1]-0:0;return 0===e?t[0]<0?(n=1,r=0):t[0]>0&&(n=0,r=1):(n/=e,r/=e),{total:e,negative:n,positive:r,includeZero:i,domain:t,extendable_min:!0,extendable_max:!0}}function pE(t,e){const{positive:i,negative:n,extendable_min:r,extendable_max:o,domain:s}=t,{positive:a,negative:l,extendable_min:h,extendable_max:c,domain:d}=e;if(a>0){if(!h)return!1;let t=n/i;o&&(t=n/Math.max(i,a),s[1]=-s[0]/t),d[0]=-d[1]*t}else if(l>0){if(!c)return!1;let t=i/n;r&&(t=i/Math.max(n,n),s[0]=-s[1]/t),d[1]=-d[0]*t}return!0}function fE(t,e){const{extendable_min:i,extendable_max:n,domain:r}=t,{positive:o,negative:s,domain:a}=e;return(0!==o||0!==s)&&(!(o>0&&!n)&&(!(s>0&&!i)&&(r[0]=a[0],r[1]=a[1],!0)))}function gE(t,e){const{positive:i,negative:n,extendable_max:r,domain:o}=t,{positive:s,negative:a,extendable_min:l,domain:h}=e;if(r&&l){const t=Math.max(n,a)/Math.max(i,s);o[1]=-o[0]/t,h[0]=-h[1]*t}else if(l){const t=n/i;h[0]=-h[1]*t}else{if(!r)return!1;{const t=a/s;o[1]=-o[0]/t}}return!0}function yE(t,e){const{extendable_min:i,domain:n}=t,{extendable_max:r,domain:o}=e;return!(!i||!r)&&(n[0]=-n[1],o[1]=-o[0],!0)}function mE(t,e){const i=[t.min,t.max],n=[e.min,e.max];if(!dE(i)||!dE(n))return;const r=uE(i),o=uE(n),{positive:s,negative:a,extendable_min:l,extendable_max:h,includeZero:c}=r,{positive:d,negative:u,extendable_min:p,extendable_max:f,includeZero:g}=o;if(0===s&&0===a){if(!fE(r,o))return}else if(0===d&&0===u){if(!fE(o,r))return}else if(c||g)if(c&&!g){if(!pE(r,o))return}else if(g&&!c){if(!pE(o,r))return}else{if(a===u)return;if(a>u){if(!gE(r,o))return}else if(!gE(o,r))return}else{if(0===a&&0===d){if(!yE(r,o))return}else if(0===u&&0===s&&!yE(o,r))return;if(0===a&&0===u)if(0===i[0]&&n[0]>0){if(!p)return;n[0]=0}else{if(!(0===n[0]&&i[0]>0))return;if(!l)return;i[0]=0}if(0===s&&0===d)if(0===i[1]&&n[1]>0){if(!f)return;n[1]=0}else{if(!(0===n[1]&&i[1]>0))return;if(!h)return;i[1]=0}}return{range1:i,range2:n}}class bE{dataConfig;records;tree={};colFlatKeys={};rowFlatKeys={};colKeys=[];rowKeys=[];rowKeysPath;colKeysPath;rowOrder="key_a_to_z";colOrder="key_a_to_z";sorted=!1;sortRules;filterRules;aggregationRules;derivedFieldRules;mappingRules;totals;indicatorStatistics=[];aggregators={};stringJoinChar=String.fromCharCode(0);rowsIsTotal=[];colsIsTotal=[];colGrandTotalLabel;colSubTotalLabel;rowGrandTotalLabel;rowSubTotalLabel;collectValuesBy;collectedValues={};rows;columns;indicatorKeys;constructor(t,e,i,n,r,o,s){this.registerAggregators(),this.dataConfig=t,this.sortRules=this.dataConfig?.sortRules,this.aggregationRules=this.dataConfig?.aggregationRules,this.derivedFieldRules=this.dataConfig?.derivedFieldRules,this.mappingRules=this.dataConfig?.mappingRules,this.totals=this.dataConfig?.totals,this.rows=e,this.columns=i,this.indicatorKeys=n,this.colGrandTotalLabel=this.totals?.column?.grandTotalLabel??"总计",this.colSubTotalLabel=this.totals?.column?.subTotalLabel??"小计",this.rowGrandTotalLabel=this.totals?.row?.grandTotalLabel??"总计",this.rowSubTotalLabel=this.totals?.row?.subTotalLabel??"小计",this.collectValuesBy=this.dataConfig?.collectValuesBy??{230417170554008:{by:["230417171050031","230417171050028"]}},this.rowsIsTotal=new Array(this.rows.length).fill(!1),this.colsIsTotal=new Array(this.columns.length).fill(!1);for(let t=0,e=this.totals?.row?.subTotalsDimensions?.length;t<e;t++){const e=this.totals.row.subTotalsDimensions[t],i=this.rows.indexOf(e);this.rowsIsTotal[i]=!0}for(let t=0,e=this.totals?.column?.subTotalsDimensions?.length;t<e;t++){const e=this.totals.column.subTotalsDimensions[t],i=this.columns.indexOf(e);this.colsIsTotal[i]=!0}if(r){this.records=r;const t="undefined"!=typeof window?window.performance.now():0;this.setRecords(r),this.processCollectedValuesWithSumBy();const e="undefined"!=typeof window?window.performance.now():0;console.log("processRecords:",e-t);const i="undefined"!=typeof window?window.performance.now():0;this.totalStatistics();const n="undefined"!=typeof window?window.performance.now():0;console.log("totalStatistics:",n-i);const a="undefined"!=typeof window?window.performance.now():0;this.sortKeys();const l="undefined"!=typeof window?window.performance.now():0;console.log("sortKeys:",l-a);const h="undefined"!=typeof window?window.performance.now():0;this.rowKeysPath=s?this.TreeToArr2(s):this.TreeToArr(this.ArrToTree(this.rowKeys,this.rowsIsTotal,this?.totals?.row?.showGrandTotals||0===this.columns.length,this.rowGrandTotalLabel,this.rowSubTotalLabel)),this.colKeysPath=o?this.TreeToArr2(o):this.TreeToArr(this.ArrToTree(this.colKeys,this.colsIsTotal,this.totals?.column?.showGrandTotals||0===this.rows.length,this.colGrandTotalLabel,this.colSubTotalLabel));const c="undefined"!=typeof window?window.performance.now():0;console.log("TreeToArr:",c-h),this.dataConfig.isPivotChart&&this.dealWithZeroAlign()}}registerAggregator(t,e){this.aggregators[t]=e}registerAggregators(){this.registerAggregator(o.RECORD,nE),this.registerAggregator(o.SUM,rE),this.registerAggregator(o.COUNT,oE),this.registerAggregator(o.MAX,aE),this.registerAggregator(o.MIN,lE),this.registerAggregator(o.AVG,sE)}setRecords(t){this.processRecords()}processCollectedValuesWithSumBy(){for(const t in this.collectedValues)if(this.collectValuesBy[t]?.sumBy)for(const e in this.collectedValues[t]){const i=Object.values(this.collectedValues[t][e]).reduce(((t,e)=>e.value()>t?e.value():t),Number.MIN_SAFE_INTEGER),n=Object.values(this.collectedValues[t][e]).reduce(((t,e)=>e.value()<t?e.value():t),Number.MAX_SAFE_INTEGER);this.collectedValues[t][e]={},this.collectedValues[t][e].max=i,this.collectedValues[t][e].min=n}}processRecords(){let t=!1;this.dataConfig?.filterRules?.length>=1&&(t=!0);for(let e=0,i=this.records.length;e<i;e++){const i=this.records[e];t&&!this.filterRecord(i)||this.processRecord(i)}this.rowFlatKeys={},this.colFlatKeys={}}filterRecord(t){let e=!0;for(let i=0;i<this.dataConfig.filterRules.length;i++){const n=this.dataConfig?.filterRules[i];if(n.filterKey){const i=t[n.filterKey];if(-1===n.filteredValues.indexOf(i)){e=!1;break}}else if(!n.filterFunc?.(t)){e=!1;break}}return e}processRecord(t){this.derivedFieldRules?.forEach(((e,i)=>{t[e.fieldName]=e.derivedFunc(t)}));const e=[],i=[];for(let e=0,n=this.rows.length;e<n;e++){const n=this.rows[e];i.push(t[n])}for(let i=0,n=this.columns.length;i<n;i++){const n=this.columns[i];e.push(t[n])}for(const e in this.collectValuesBy)if(t[e]){this.collectedValues[e]||(this.collectedValues[e]={});const i=this.collectValuesBy[e].by.map((e=>t[e])).join(this.stringJoinChar);if(this.collectedValues[e][i]||(this.collectValuesBy[e].sumBy?this.collectedValues[e][i]={}:this.collectValuesBy[e].range?this.collectedValues[e][i]={min:Number.MAX_SAFE_INTEGER,max:Number.MIN_SAFE_INTEGER}:this.collectedValues[e][i]=new Set),this.collectValuesBy[e].sumBy){const n=this.collectValuesBy[e].sumBy.map((e=>t[e])).join(this.stringJoinChar);this.collectedValues[e][i][n]||(this.collectedValues[e][i][n]=new this.aggregators[o.SUM](e)),this.collectedValues[e][i][n].push(t)}else if(this.collectValuesBy[e].range){const n=this.collectedValues[e][i];n.max=Math.max(t[e],n.max),n.min=Math.min(t[e],n.min)}else{this.collectedValues[e][i].add(t[e])}}const n=i.join(this.stringJoinChar),r=e.join(this.stringJoinChar);if(0!==i.length&&(this.rowFlatKeys[n]||(this.rowKeys.push(i),this.rowFlatKeys[n]=1)),0!==e.length&&(this.colFlatKeys[r]||(this.colKeys.push(e),this.colFlatKeys[r]=1)),0!==e.length||0!==i.length){this.tree[n]||(this.tree[n]={}),this.tree[n]?.[r]||(this.tree[n][r]=[]);for(let e=0;e<this.indicatorKeys.length;e++){const i=this.getAggregatorRule(this.indicatorKeys[e]);if(this.tree[n]?.[r]?.[e]||(this.tree[n][r][e]=new this.aggregators[i?.aggregationType??o.SUM](i?.field??this.indicatorKeys[e],i?.formatFun)),i?.field)if("string"==typeof i?.field)A(t[i?.field])&&this.tree[n]?.[r]?.[e].push(t);else{const o=i?.field.find((e=>t[e]));o&&this.tree[n]?.[r]?.[e].push(t)}else A(t[this.indicatorKeys[e]])&&this.tree[n]?.[r]?.[e].push(t)}}if(this.mappingRules)for(let e=0;e<this.indicatorKeys.length;e++){if(!this.indicatorStatistics[e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.indicatorStatistics[e]={max:new this.aggregators[o.MAX](this.indicatorKeys[e]),min:new this.aggregators[o.MIN](this.indicatorKeys[e]),total:new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}}this.indicatorStatistics[e].max.push(this.tree[n]?.[r]?.[e].value()),this.indicatorStatistics[e].min.push(this.tree[n]?.[r]?.[e].value()),this.indicatorStatistics[e].total.push(t)}}updateSortRules(t){this.sorted=!1,this.sortRules=t,this.sortKeys(),this.rowKeysPath=this.TreeToArr(this.ArrToTree(this.rowKeys,this.rowsIsTotal,this?.totals?.row?.showGrandTotals||0===this.columns.length,this.rowGrandTotalLabel,this.rowSubTotalLabel)),this.colKeysPath=this.TreeToArr(this.ArrToTree(this.colKeys,this.colsIsTotal,this.totals?.column?.showGrandTotals||0===this.rows.length,this.colGrandTotalLabel,this.colSubTotalLabel))}updateFilterRules(t,e=!1){if(this.filterRules=t,e)this.tree={};else for(const t in this.tree)for(const e in this.tree[t])for(let i=0;i<this.tree[t][e].length;i++)this.tree[t][e][i].reset();this.collectedValues={},this.processRecords(),this.processCollectedValuesWithSumBy()}getAggregatorRule(t){return this.aggregationRules?.find(((e,i)=>t===e.indicatorKey))}getAggregator(t=[],e=[],i){const n=this.indicatorKeys.indexOf(i);let r,o,s;return o="string"==typeof t?t:t.join(this.stringJoinChar),s="string"==typeof e?e:e.join(this.stringJoinChar),0===t.length&&0===e.length||(r=this.tree[o]?.[s]?.[n]),r||{className:"",push(){},value:()=>null,formatValue:()=>"",reset(){}}}sortKeys(){const t=this;if(!this.sorted){this.sorted=!0;const e=function(e,i){return t.getAggregator(e,i,"").value()};switch(this.rowOrder){case"value_a_to_z":this.rowKeys.sort((function(t,i){return cE(e(t,[]),e(i,[]))}));break;case"value_z_to_a":this.rowKeys.sort((function(t,i){return-cE(e(t,[]),e(i,[]))}));break;default:this.rowKeys.sort(this.arrSort(this.rows,!0))}switch(this.colOrder){case"value_a_to_z":this.colKeys.sort((function(t,i){return cE(e([],t),e([],i))}));break;case"value_z_to_a":this.colKeys.sort((function(t,i){return-cE(e([],t),e([],i))}));break;default:const t=this.arrSort(this.columns,!1);this.colKeys.sort(t)}}}arrSort(t,e){let i;const n=this,r=function(r){const o=[];for(let r=0,s=t.length;r<s;r++){i=t[r];let s=!1;if(n.sortRules)for(let t=0,a=n.sortRules.length;t<a;t++)n.sortRules[t].sortField===i&&(s=!0,o.push({field:i,fieldIndex:r,sortRule:n.sortRules[t],func:n.getSort(n.sortRules[t],e)}));s||o.push({field:i,fieldIndex:r,func:cE})}return o}.call(this);return function(i,o){let a,l;for(let h=0;h<r.length;h++){if(l=r[h],l.sortRule?.sortByIndicator){let r=i,s=o;l.fieldIndex<t.length-1&&(r=i.slice(0,l.fieldIndex+1),r.push(e?n.totals?.row?.subTotalLabel:n.totals?.column?.subTotalLabel),s=o.slice(0,l.fieldIndex+1),s.push(e?n.totals?.row?.subTotalLabel:n.totals?.column?.subTotalLabel)),a=l.func(r,s)}else a=l.func(i[l.fieldIndex],o[l.fieldIndex]);if(0!==a)return a*(l.sortRule?.sortType===s.DESC?-1:1)}return 0}}getSort(t,e){const i=this;return t.sortByIndicator?(n,r)=>{const o=function(e,n){return e.length<i.rows.length&&e[e.length-1]!==i.rowSubTotalLabel&&e[e.length-1]!==i.rowGrandTotalLabel&&e.push(i.rowSubTotalLabel),n.length<i.columns.length&&n[n.length-1]!==i.colSubTotalLabel&&n[n.length-1]!==i.colGrandTotalLabel&&n.push(i.colSubTotalLabel),i.getAggregator(e,n,t.sortByIndicator).value()};return e?cE(o(n,t.query),o(r,t.query)):cE(o(t.query,n),o(t.query,r))}:t.sortBy?function(t){let e;const i={},n={};for(let r=0;r<t.length;r++)e=t[r],i[e]=r,"string"==typeof e&&(n[e.toLowerCase()]=r);return function(t,e){return null!==i[t]&&void 0!==i[t]&&null!==i[e]&&void 0!==i[e]?i[t]-i[e]:null!==i[t]&&void 0!==i[t]?-1:null!==i[e]&&void 0!==i[e]?1:null!==n[t]&&void 0!==i[t]&&null!==n[e]&&void 0!==i[e]?n[t]-n[e]:null===n[t]||void 0===i[t]||null===n[e]||void 0===i[e]?0:null!==n[t]&&void 0!==i[t]?-1:null!==n[e]&&void 0!==i[e]?1:cE(t,e)}}(t.sortBy):t.sortType?hE:t.sortFunc?t.sortFunc:cE}totalStatistics(){const t=this;if(t?.totals?.column?.showSubTotals&&t?.totals?.column?.subTotalsDimensions?.length>=1||t?.totals?.row?.showSubTotals&&t?.totals?.row?.subTotalsDimensions?.length>=1||t?.totals?.column?.showGrandTotals||t?.totals?.row?.showGrandTotals||0===t.rows.length||0===t.columns.length){const e=[],i=(e,i)=>{const n=i.split(this.stringJoinChar);for(let r=0,s=t.totals?.column?.subTotalsDimensions?.length;r<s;r++){const s=t.totals.column.subTotalsDimensions[r],a=t.columns.indexOf(s);if(a>=0){const r=n.slice(0,a+1);r.push(t.totals?.column?.subTotalLabel??"小计");const s=r.join(this.stringJoinChar);this.tree[e][s]||(this.tree[e][s]=[]);for(let n=0;n<this.indicatorKeys.length;n++){if(!this.tree[e][s][n]){const t=this.getAggregatorRule(this.indicatorKeys[n]);this.tree[e][s][n]=new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[n],t?.formatFun)}this.tree[e][s][n].push(t.tree[e]?.[i]?.[n])}}}if(t.totals?.column?.showGrandTotals||0===this.rows.length){const n=t.colGrandTotalLabel;this.tree[e][n]||(this.tree[e][n]=[]);for(let r=0;r<this.indicatorKeys.length;r++){if(!this.tree[e][n][r]){const t=this.getAggregatorRule(this.indicatorKeys[r]);this.tree[e][n][r]=new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[r],t?.formatFun)}this.tree[e][n][r].push(t.tree[e]?.[i]?.[r])}}};Object.keys(t.tree).forEach((n=>{const r=n.split(this.stringJoinChar);Object.keys(t.tree[n]).forEach((s=>{for(let i=0,a=t.totals?.row?.subTotalsDimensions?.length;i<a;i++){const a=t.totals.row.subTotalsDimensions[i],l=t.rows.indexOf(a);if(l>=0){const i=r.slice(0,l+1);i.push(t.totals?.row?.subTotalLabel??"小计");const a=i.join(this.stringJoinChar);if(this.tree[a]||(this.tree[a]={},e.push(a)),!this.tree[a][s]){this.tree[a][s]=[];for(let e=0;e<this.indicatorKeys.length;e++){if(!this.tree[a][s][e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.tree[a][s][e]=new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}this.tree[a][s][e].push(t.tree[n]?.[s]?.[e])}}}}if(t.totals?.row?.showGrandTotals||0===this.columns.length){const i=t.rowGrandTotalLabel;this.tree[i]||(this.tree[i]={},e.push(i)),this.tree[i][s]||(this.tree[i][s]=[]);for(let e=0;e<this.indicatorKeys.length;e++){if(!this.tree[i][s][e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.tree[i][s][e]=new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}this.tree[i][s][e].push(t.tree[n]?.[s]?.[e])}}i(n,s)}))})),e.forEach((e=>{Object.keys(t.tree[e]).forEach((t=>{i(e,t)}))}))}}ArrToTree(t,e,i,n,r){const o=[],s=this.stringJoinChar,a=new Map;if(t.forEach((t=>function(t){const i=[];let n;t.forEach(((l,h)=>{i.push(l);const c=i.join(s);let d=a.get(c);if(!d){if(d={id:c,children:[]},e[h]){let e=d.children;for(let i=h;i<t.length-1;i++){const t={id:`${c}${s}${r}`,children:[]};e.push(t),e=t.children}}a.set(c,d),n?e[h-1]?n.children.splice(n.children.length-1,0,d):n.children.push(d):o.push(d)}n=d}))}(t))),i){const t={id:n,children:[]};let i=t.children;for(let t=1;t<e.length;t++){const t={id:n,children:[]};i.push(t),i=t.children}o.push(t)}return o}TreeToArr(t){const e=[];function i(t,n){n.push(t.id),t.children.length>0?t.children?.forEach((t=>i(t,[...n]))):e.push(n)}return t.forEach((t=>i(t,[]))),e}TreeToArr2(t){const e=[];function i(t,n){n.push(n.length>0?[n[n.length-1],t.value].join(String.fromCharCode(0)):t.value),t.children?.length>0&&!t.children[0].indicatorKey?t.children?.forEach((t=>i(t,[...n]))):e.push(n)}return t.forEach((t=>i(t,[]))),e}dealWithZeroAlign(){const t=[];for(let e=0;e<this.aggregationRules.length;e++){const i=this.aggregationRules[e];Ot(i.field)&&2===i.field.length&&t.push(i.field)}t.forEach((t=>{const e=t[0],i=t[1],n=this.collectedValues[e],r=this.collectedValues[i];this.collectedValues[e+"_align"]={},this.collectedValues[i+"_align"]={};for(const t in n){const o=n[t],s=r[t],a=mE(o,s);if(a){const{range1:n,range2:r}=a;this.collectedValues[e+"_align"][t]={min:n[0],max:n[1]},this.collectedValues[i+"_align"][t]={min:r[0],max:r[1]}}else this.collectedValues[e+"_align"][t]={min:o.min,max:o.max},this.collectedValues[i+"_align"][t]={min:s.min,max:s.max}}}))}}class vE{type;id;x=0;y=0;width=0;height=0;marginLeft;marginRight;marginTop;marginBottom;layoutWidth;layoutHeight;dx=0;dy=0;background;constructor(t){this.id=t.id,this.marginLeft=t.marginLeft??0,this.marginRight=t.marginRight??0,this.marginTop=t.marginTop??0,this.marginBottom=t.marginBottom??0,this.background=t.background||void 0}getSize(t){this.initLayoutSize()}initLayoutSize(){this.layoutWidth=this.width+this.marginLeft+this.marginRight,this.layoutHeight=this.height+this.marginTop+this.marginBottom,this.background&&(this.layoutWidth+=2*(this.background.expandX||0),this.layoutHeight+=2*(this.background.expandY||0)),this.dx=this.marginLeft,this.dy=this.marginTop}}const wE={row:{x:"x",y:"y",width:"width",height:"height",layoutWidth:"layoutWidth",layoutHeight:"layoutHeight",widthLimit:"widthLimit",heightLimit:"heightLimit",parentX:"parentX",parentY:"parentY",dx:"dx",dy:"dy"},column:{x:"y",y:"x",width:"height",height:"width",layoutWidth:"layoutHeight",layoutHeight:"layoutWidth",widthLimit:"heightLimit",heightLimit:"widthLimit",parentX:"parentY",parentY:"parentX",dx:"dy",dy:"dx"}};class CE{width=0;height=0;y=0;x=0;children=[];addAble=!0;widthLimit=0;heightLimit=0;direction;directionKey;offsetX=0;justifyContent;alignItems;constructor(t,e,i,n){this.direction=e,this.directionKey=wE[this.direction],this.justifyContent=i,this.alignItems=n,this[this.directionKey.widthLimit]=t}add(t){t[this.directionKey.x]=this[this.directionKey.width],this[this.directionKey.width]+=t[this.directionKey.layoutWidth],this.children.push(t),this.updateHeight(t)}canAdd(t){return!(this[this.directionKey.width]+t[this.directionKey.layoutWidth]>this[this.directionKey.widthLimit])}updateHeight(t){t[this.directionKey.layoutHeight]>this[this.directionKey.height]&&(this[this.directionKey.height]=t[this.directionKey.layoutHeight])}lineFinish(){this.updateXAlign()}updateXAlign(){const t=this[this.directionKey.widthLimit]-this[this.directionKey.width];"center"===this.justifyContent?this.offsetX=t/2:"start"===this.justifyContent?this.offsetX=0:this.offsetX=t}getOffsetY(t){switch(this.alignItems){case"start":default:return 0;case"center":return(this[this.directionKey.height]-t[this.directionKey.layoutHeight])/2;case"end":return this[this.directionKey.height]-t[this.directionKey.layoutHeight]}}getContentSize(){const t={width:0,height:0};for(let e=0;e<this.children.length;e++){const i=this.children[e];let n;n="container"===i.type?i.getContentSize():{width:i.layoutWidth,height:i.layoutHeight},t[this.directionKey.height]<n[this.directionKey.height]&&(t[this.directionKey.height]=n[this.directionKey.height]),t[this.directionKey.width]+=n[this.directionKey.width]}return t}getElements(t={parentX:0,parentY:0},e=!1,i=!1){const n=[];for(let r=0;r<this.children.length;r++){const o=this.children[r];if("container"===o.type||"group-element"===o.type){const r=o.getElements({[this.directionKey.parentX]:this.offsetX+this[this.directionKey.x]+t.parentX,[this.directionKey.parentY]:this.getOffsetY(o)+this[this.directionKey.y]+t.parentY},e,i);n.push(...r)}else{if("icon"===o.type&&("mouseenter_cell"===o.cache?.visibleTime&&!e||"click_cell"===o.cache?.visibleTime&&!i))continue;o[this.directionKey.x]+=this.offsetX+this[this.directionKey.x]+t.parentX,o[this.directionKey.y]+=this.getOffsetY(o)+this[this.directionKey.y]+t.parentY,n.push(o)}}return n}}class xE extends vE{type="rect";lineWidth;cornerRadius;radius;fill;stroke;constructor(t){super(t),this.width=t.width,this.height=t.height,this.lineWidth=t.lineWidth||0,this.cornerRadius=t.cornerRadius||0,this.radius=this.cornerRadius,this.fill=t.fill||"#777",this.stroke=t.stroke||void 0,this.initLayoutSize()}}var _E=Object.freeze({__proto__:null,Circle:class extends vE{type="circle";radius;radian;lineWidth;fill;stroke;constructor(t){super(t),this.radius=t.radius,this.radian=t.radian,this.lineWidth=t.lineWidth,this.fill=t.fill,this.stroke=t.stroke,this.width=2*this.radius,this.height=2*this.radius,this.initLayoutSize(),this.dx+=this.radius,this.dy+=this.radius}},Container:class extends vE{type="container";_widthObj;_heightObj;needCalcSize=!1;direction;justifyContent;alignItems;alignContent;lines=[];currentLine;currentLineY=0;table;directionKey;showBounds;offsetY=0;isRoot;constructor(t){super(t),this.direction=t.direction||"row",this.justifyContent=t.justifyContent||"start",this.alignItems=t.alignItems||"start",this.alignContent=t.alignContent||"start",g(t.width)?this.width=t.width:(this._widthObj=t.width,this.needCalcSize=!0),g(t.height)?this.height=t.height:(this._heightObj=t.height,this.needCalcSize=!0),this.directionKey=wE[this.direction],this.showBounds=t.showBounds||!1,this.initLayoutSize()}add(t){if(this.needCalcSize)throw new Error("Need to specify a parent element before adding a child element when use percent size!");"container"===t.type&&t.calcSize(this.width,this.height),this.currentLine&&this.currentLine.canAdd(t)?this.currentLine.add(t):(this.currentLine&&(this.currentLine.addAble=!1,this.currentLineY+=this.currentLine[this.directionKey.height],this.currentLine.lineFinish()),this.currentLine=new CE(this[this.directionKey.width],this.direction,this.justifyContent,this.alignItems),this.currentLine[this.directionKey.y]=this.currentLineY,this.currentLine.add(t),this.lines.push(this.currentLine))}updateYAlign(){const t=this[this.directionKey.height]-this.currentLineY;"center"===this.alignContent?this.offsetY=t/2:"start"===this.alignContent?this.offsetY=0:this.offsetY=t}getSize(){const t={width:0,height:0};this.currentLine&&this.currentLine.addAble?t[this.directionKey.height]=this.currentLineY+this.currentLine[this.directionKey.height]:t[this.directionKey.height]=this.currentLineY;for(let e=0;e<this.lines.length;e++){const i=this.lines[e];t[this.directionKey.width]<i[this.directionKey.width]&&(t[this.directionKey.width]=i[this.directionKey.width])}return t}getContentSize(){const t={width:0,height:0},e={width:!0,height:!0};this.isRoot||this._heightObj||(e.height=!1,t.height=this.height),this.isRoot||this._widthObj||(e.width=!1,t.width=this.width);for(let i=0;i<this.lines.length;i++){const n=this.lines[i].getContentSize();e[this.directionKey.width]&&t[this.directionKey.width]<n[this.directionKey.width]&&(t[this.directionKey.width]=n[this.directionKey.width]),e[this.directionKey.height]&&(t[this.directionKey.height]+=n[this.directionKey.height])}return t}calcSize(t,e){this._heightObj&&(this.height=e*this._heightObj.percent/100+this._heightObj.delta,this.needCalcSize=!1,this.initLayoutSize()),this._widthObj&&(this.width=t*this._widthObj.percent/100+this._widthObj.delta,this.needCalcSize=!1,this.initLayoutSize())}getElements(t={parentX:0,parentY:0},e=!1,i=!1){this.currentLine&&this.currentLine.addAble&&(this.currentLine.addAble=!1,this.currentLineY+=this.currentLine[this.directionKey.height],this.currentLine.lineFinish()),this.updateYAlign();const n=[];if(this.background&&this.background.fill){const e=new xE({width:this.width,height:this.height,stroke:this.background.stroke??!1,fill:this.background.fill,cornerRadius:this.background.cornerRadius??0,lineWidth:this.background.lineWidth??1});e.x+=this.x+t.parentX,e.y+=this.y+t.parentY,n.push(e)}if(this.showBounds){const e=new xE({width:this.width,height:this.height,cornerRadius:0,stroke:"red",fill:"rgba(255, 0, 0, 0.2)",lineWidth:4});e.x+=this.x+t.parentX,e.y+=this.y+t.parentY,n.push(e)}for(let r=0;r<this.lines.length;r++){const o=this.lines[r];o[this.directionKey.y]+=this.offsetY;const s=o.getElements({[this.directionKey.parentX]:this.x+t.parentX,[this.directionKey.parentY]:this.y+t.parentY},e,i);n.push(...s)}return n}},GroupElement:class extends vE{type="group-element";direction;alignItems;width=0;height=0;children=[];directionKey;constructor(t){super(t),this.direction=t.direction||"row",this.alignItems=t.alignItems||"start",this.directionKey=wE[this.direction]}add(t){t.x=this.width,this.width+=t.layoutWidth,this.children.push(t),this.updateHeight(t),this.initLayoutSize()}updateHeight(t){t.layoutHeight>this.height&&(this.height=t.layoutHeight)}getOffsetY(t){switch(this.alignItems){case"start":default:return 0;case"center":return(this[this.directionKey.height]-t[this.directionKey.layoutHeight])/2;case"end":return this[this.directionKey.height]-t[this.directionKey.layoutHeight]}}getElements(t={parentX:0,parentY:0},e=!1,i=!1){const n=[];for(let r=0;r<this.children.length;r++){const o=this.children[r];"icon"===o.type&&("mouseenter_cell"===o.cache?.visibleTime&&!e||"click_cell"===o.cache?.visibleTime&&!i)||(o[this.directionKey.x]+=this[this.directionKey.dx]+this[this.directionKey.x]+t.parentX,o[this.directionKey.y]+=this.getOffsetY(o)+this[this.directionKey.dy]+this[this.directionKey.y]+t.parentY,n.push(o))}return n}},Icon:class extends vE{type="icon";svg;iconName;cursor;cache;constructor(t){if(super(t),this.iconName=t.iconName,f(this.iconName)){const t=kC()[this.iconName];t&&(this.cache=t,this.width=t.width,this.height=t.height,this.svg=t.svg,this.cursor=t.cursor)}this.width=t.width??this.width,this.height=t.height??this.height,this.svg=t.svg??this.svg,this.initLayoutSize()}},Image:class extends vE{type="image";src;cursor;cache;shape;constructor(t){super(t),this.width=t.width??this.width,this.height=t.height??this.height,this.src=t.src??this.src,this.shape=t.shape??this.shape,this.initLayoutSize()}},Rect:xE,Sector:class extends vE{type="arc";radius;startDegree=0;endDegree=360;clockWise=!0;lineWidth;fill;stroke;constructor(t){super(t),this.radius=t.radius,this.startDegree=t.startDegree,this.endDegree=t.endDegree,this.clockWise=t.clockWise,this.lineWidth=t.lineWidth,this.fill=t.fill,this.stroke=t.stroke,this.width=2*this.radius,this.height=2*this.radius,this.initLayoutSize(),this.dx+=this.radius,this.dy+=this.radius}},Text:class extends vE{type="text";text;fontSize;fontFamily;fill;textBaseline="top";textAlign="left";constructor(t){super(t),this.text=t.text,this.fontSize=t.fontSize||12,this.fontFamily=t.fontFamily||"sans-serif",this.fill=t.fill||"black"}getSize(t){const{width:e,height:i}=t.measureText(this.text,{fontSize:this.fontSize,fontFamily:this.fontFamily});this.width=e,this.height=i,this.initLayoutSize(),this.background&&(this.dx+=this.background.expandX||0,this.dy+=this.background.expandY||0)}},percentCalc:function(t,e=0){return{percent:t,delta:e}}});t.CustomLayout=_E,t.DataStatistics=VP,t.ListTable=class extends zP{showHeader=!0;constructor(t={}){super(t);const e=this.internalProps;this.pagerConf=t.pagerConf,e.sortState=t.sortState,e.columns=t.columns?v(t.columns):t.header?v(t.header):[],this.showHeader=t.showHeader??!0,this.transpose=t.transpose??!1,this.refreshHeader(),t.dataSource?AC(this,t.dataSource):t.records?this.setRecords(t.records,e.sortState):this.setRecords([])}isListTable(){return!0}isPivotTable(){return!1}isPivotChart(){return!1}get sortState(){return this.internalProps.sortState}set sortState(t){this.internalProps.sortState=t}get columns(){return this.internalProps.columns}set columns(t){this.internalProps.columns=t,this.options.columns=t,this.refreshHeader(),setTimeout((()=>{this.invalidate()}),0)}get header(){return this.internalProps.columns}set header(t){this.internalProps.columns=t,this.options.header=t,this.refreshHeader(),setTimeout((()=>{this.invalidate()}),0)}get transpose(){return this.internalProps.transpose??!1}set transpose(t){this.internalProps.transpose!==t&&(this.internalProps.transpose=t,this.options.transpose=t,this.internalProps.layoutMap&&(this.internalProps.layoutMap.transpose=t,this.refreshRowColCount(),this._resetFrozenColCount(),this.invalidate()))}getCellValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{caption:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}const{field:n,fieldFormat:r}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(r||n,t,e)}getCellOriginValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{caption:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}const{field:n}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(n,t,e)}getRecordIndexByRow(t,e){const{layoutMap:i}=this.internalProps;return i.getRecordIndexByRow(t,e)}getCellOriginRecord(t,e){const i=this,n=i.getRecordIndexByRow(t,e);if(n>-1)return i.dataSource.get(n)}_canResizeColumn(t,e){const i=super._canResizeColumn(t,e);if(i&&!this.transpose){const e=this.internalProps.layoutMap.getBody(t,this.columnHeaderLevelCount);if(e?.disableColumnResize)return!1}return i}updateOption(t,e=!1){const i=this.internalProps;return super.updateOption(t),this.pagerConf=t.pagerConf,this.showHeader=t.showHeader??!0,i.columns=t.columns?v(t.columns):t.header?v(t.header):[],this.transpose=t.transpose??!1,this.refreshHeader(),i.disposables&&(i.disposables.forEach((t=>t?.dispose?.())),i.disposables=null),this._updateSize(),t.dataSource?AC(this,t.dataSource):t.records?this.setRecords(t.records,t.sortState):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.invalidate()),new Promise((t=>{setTimeout(t,0)}))}refreshHeader(){const t=this,e=t.internalProps,i=t.transpose,n=t.showHeader;e.headerEvents&&e.headerEvents.forEach((e=>t.unlisten(e)));const r=e.layoutMap=new XP(this,e.columns??[],n,t.options.hierarchyIndent);if(r.transpose=i,!i)for(let e=0;e<r.columnWidths.length;e++){const{width:i,minWidth:n,maxWidth:o}=r.columnWidths?.[e]??{};i&&("string"==typeof i&&"auto"!==i||"number"==typeof i&&i>0)&&t.setColWidth(e,i),n&&("number"==typeof n&&n>0||"string"==typeof n)&&t.setMinColWidth(e,n),o&&("number"==typeof o&&o>0||"string"==typeof o)&&t.setMaxColWidth(e,o)}this.refreshRowColCount()}refreshRowColCount(){const t=this,{layoutMap:e}=t.internalProps;e&&(e.recordsCount=t.internalProps.dataSource?.length??0,t.transpose?(t.rowCount=e.rowCount??0,t.colCount=(t.internalProps.dataSource?.length??0)*e.bodyRowCount+e.headerLevelCount,t.frozenRowCount=0,t.frozenColCount=e.headerLevelCount):(t.colCount=e.colCount??0,t.rowCount=(t.internalProps.dataSource?.length??0)*e.bodyRowCount+e.headerLevelCount,t.frozenColCount=t.options.frozenColCount??0,t.frozenRowCount=e.headerLevelCount))}getFieldData(t,e,i){if(null===t)return null;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return null;const r=n.getRecordIndexByRow(e,i);return n.internalProps.dataSource.getField(r,t)}moveHeaderPosition(t,e){const i=this.internalProps.layoutMap.moveHeaderPosition(t,e);if(i){if("column"===i.moveType){if(this.colWidthsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize),!this.transpose){this.colWidthsLimit={};for(let t=0;t<this.internalProps.layoutMap.columnWidths.length;t++){const{minWidth:e,maxWidth:i}=this.internalProps.layoutMap.columnWidths?.[t]??{};e&&("number"==typeof e&&e>0||"string"==typeof e)&&this.setMinColWidth(t,e),i&&("number"==typeof i&&i>0||"string"==typeof i)&&this.setMaxColWidth(t,i)}}const t=Math.min(i.sourceIndex,i.targetIndex),e=Math.max(i.sourceIndex,i.targetIndex);for(let i=t;i<=e;i++)this._clearColRangeWidthsMap(i)}else{const t=Math.min(i.sourceIndex,i.targetIndex),e=Math.max(i.sourceIndex,i.targetIndex);for(let i=t;i<=e;i++)this._clearRowRangeHeightsMap(i)}return!0}return!1}getCellAddress(t,e){let i;for(let e=0;e<this.records.length;e++){const n=this.records[e];if("function"==typeof t)t(n)&&(i=e);else{let r=!0;for(const e in t)if(n[e]!==t[e]){r=!1;break}r&&(i=e)}if(A(i))break}const n=this.getCellRangeByField(e,i);if(n)return{row:n.start.row,col:n.start.col}}getCellRangeByField(t,e){const{layoutMap:i}=this.internalProps,n=i.columnObjects.find((e=>e.field===t));if(n){const t=i.getBodyLayoutRangeById(n.id);let r;return A(e)&&(r=i.getRecordStartRowByRecordIndex(e)),this.transpose?{start:{row:t.start.row,col:A(r)?r+t.start.col:void 0},end:{row:t.end.row,col:A(r)?r+t.end.col:void 0}}:{start:{col:t.start.col,row:A(r)?r+t.start.row:void 0},end:{col:t.end.col,row:A(r)?r+t.end.row:void 0}}}return null}getHierarchyState(t,e){if(!this.getBodyColumnDefine(t,e).tree)return r.none;const i=this.getRecordIndexByRow(t,e);return this.dataSource.getHierarchyState(i)}toggleHierarchyState(t,e){const i=this.getHierarchyState(t,e);i===r.expand?this.fireListeners(yt.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.collapse}):i===r.collapse&&this.fireListeners(yt.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.expand,originData:this.getCellOriginRecord(t,e)});const n=this.getRecordIndexByRow(t,e),o=this.dataSource.toggleHierarchyState(n),s=this.internalProps.layoutMap.toggleHierarchyState(o);this.refreshRowColCount(),this.clearCellStyleCache(),this.scenegraph.updateHierarchyIcon(t,e),this.scenegraph.updateRow(s.removeCellPositions,s.addCellPositions)}hasHierarchyTreeHeader(){return(this.options.columns??this.options.header)?.some(((t,e)=>t.tree))}getMenuInfo(t,e,i){return{field:this.getHeaderField(t,e),value:this.getCellValue(t,e),cellType:this.getCellType(t,e)}}_getSortFuncFromHeaderOption(t,e,i){if(t||(t=this.internalProps.columns),e&&t&&t.length>0)for(let n=0;n<t.length;n++){const r=t[n];if((i&&i===r.fieldKey||!i&&r.field===e)&&r.sort&&"function"==typeof r.sort)return r.sort;if(r.columns){const t=this._getSortFuncFromHeaderOption(r.columns,e,i);if(t)return t}}}updateSortState(t){if(t)this.internalProps.sortState=t;else if(this.internalProps.sortState)if(Array.isArray(this.internalProps.sortState))for(let t=0;t<this.internalProps.sortState.length;t++){this.internalProps.sortState[t].order="normal"}else this.internalProps.sortState.order="normal";let e,i,n;if(Array.isArray(this.internalProps.sortState)?({order:e,field:i,fieldKey:n}=this.internalProps.sortState?.[0]):({order:e,field:i,fieldKey:n}=this.internalProps.sortState),i){const t=this._getSortFuncFromHeaderOption(this.internalProps.columns,i,n);let r;r=n?this.internalProps.layoutMap.headerObjects.find((t=>t&&t.fieldKey===n)):this.internalProps.layoutMap.headerObjects.find((t=>t&&t.field===i)),r?.define?.sort&&(this.dataSource.sort(r.field,e,t),this.scenegraph.sortCell())}this.stateManeger.updateSortState(t)}},t.PivotChart=class extends zP{pivotSortState;dataset;_selectedDataItemsInChart=[];_selectedDimensionInChart=[];_chartEventMap={};_axes;constructor(t){if(super(t),t.layout&&Object.assign(t,t.layout),this.setCustomStateNameToSpec(),this.internalProps.dataConfig={isPivotChart:!0},this.internalProps.enableDataAnalysis=!0,this._axes=Ot(t.axes)?t.axes:[],this.internalProps.enableDataAnalysis&&(t.rows||t.columns)){const e=t.rows.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),i=t.columns.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),n=t.indicators?.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[])??[];this.internalProps.dataConfig.collectValuesBy=this._generateCollectValuesConfig(i,e),this.internalProps.dataConfig.aggregationRules=this._generateAggregationRules(),this.dataset=new bE(this.internalProps.dataConfig,e,i,n,t.records,t.columnTree,t.rowTree)}this.refreshHeader(),t.dataSource?AC(this,t.dataSource):t.records?this.setRecords(t.records,this.internalProps.sortState):this.setRecords([])}static get EVENT_TYPE(){return MR}get pivotChartAxes(){return this._axes}isListTable(){return!1}isPivotTable(){return!0}isPivotChart(){return!0}_canResizeColumn(t,e){const i=super._canResizeColumn(t,e);if(i&&!this.internalProps.layoutMap.indicatorsAsCol){const e=this.internalProps.layoutMap.getBody(t,this.columnHeaderLevelCount);if(e?.disableColumnResize)return!1}return i}updateOption(t,e=!1){const i=this.internalProps;if(super.updateOption(t),this.setCustomStateNameToSpec(),i.dataConfig={},this.internalProps.enableDataAnalysis=!0,this.internalProps.enableDataAnalysis&&(t.rows||t.columns)){const e=t.rows.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),i=t.columns.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),n=t.indicators.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[]);this.internalProps.dataConfig.collectValuesBy=this._generateCollectValuesConfig(i,e),this.internalProps.dataConfig.aggregationRules=this._generateAggregationRules(),this.dataset=new bE(this.internalProps.dataConfig,e,i,n,t.records??this.internalProps.records,t.columnTree,t.rowTree)}return this.refreshHeader(),i.disposables&&(i.disposables.forEach((t=>t?.dispose?.())),i.disposables=null),this._updateSize(),t.dataSource?AC(this,t.dataSource):t.records?this.setRecords(t.records,void 0):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.invalidate()),new Promise((t=>{setTimeout(t,0)}))}refreshHeader(){const t=this.internalProps;t.headerEvents&&t.headerEvents.forEach((t=>this.unlisten(t))),this.internalProps.enableDataAnalysis&&(t.layoutMap=new tE(this,this.dataset));for(let e=0;e<t.layoutMap.columnWidths.length;e++){const{width:i,minWidth:n,maxWidth:r}=t.layoutMap.columnWidths?.[e]??{};i&&("string"==typeof i&&"auto"!==i||"number"==typeof i&&i>0)&&this.setColWidth(e,i),n&&("number"==typeof n&&n>0||"string"==typeof n)&&this.setMinColWidth(e,n),r&&("number"==typeof r&&r>0||"string"==typeof r)&&this.setMaxColWidth(e,r)}this.refreshRowColCount()}refreshRowColCount(){const t=this,{layoutMap:e}=t.internalProps;e&&(t.colCount=e.colCount??0,t.rowCount=e.rowCount??0,t.frozenColCount=e.rowHeaderLevelCount,t.frozenRowCount=e.headerLevelCount,t.bottomFrozenRowCount=e?.bottomFrozenRowCount??0,t.rightFrozenColCount=e?.rightFrozenColCount??0)}_getSortFuncFromHeaderOption(t,e,i){}syncHierarchyState(t,e){t.value===e.value&&t.dimensionKey===e.dimensionKey&&(e.hierarchyState=e.hierarchyState??(e?.children?t.hierarchyState:void 0),e?.children?.forEach(((e,i)=>{t?.children?.[i]&&e&&this.syncHierarchyState(t.children[i],e)})))}getRecordIndexByRow(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByRow(t)}getRecordIndexByCol(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByCol(t)}getFieldData(t,e,i){if(null==t)return null;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return null;const r=this.getRecordIndexByRow(i),o=this.getRecordIndexByCol(e),s=n.dataSource?.getField(r,o);if("string"!=typeof t){return Mw({dataValue:s,...n.internalProps.layoutMap.getCellHeaderPaths(e,i)},t,gt)}return s}getCellValue(t,e){if(this.internalProps.layoutMap.isHeader(t,e)){const{caption:i,fieldFormat:n}=this.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n(i):i}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.value?r.value():void 0}const{field:i,fieldFormat:n}=this.internalProps.layoutMap.getBody(t,e);return this.getFieldData(n||i,t,e)}getCellOriginValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{caption:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.value?r.value():void 0}const{field:n}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(n,t,e)}getCellOriginRecord(t,e){if(!this.internalProps.layoutMap.isHeader(t,e)&&this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[];return this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e)).records}}updateSortRules(t){this.internalProps.dataConfig.sortRules=t,this.dataset.updateSortRules(t),this.internalProps.layoutMap.updateDataset(this.dataset),this.invalidate()}updatePivotSortState(t){for(let e=0;e<t.length;e++){const{dimensions:i,order:n}=t[e],r=this.internalProps.layoutMap.getPivotCellAdress(i);r&&this.pivotSortState.push({col:r.col,row:r.row,order:n})}}getPivotSortState(t,e){if(!this.pivotSortState)return;const i=this.getCellRange(t,e);for(let t=0;t<this.pivotSortState.length;t++){const{col:e,row:n,order:r}=this.pivotSortState[t];if(at(i,e,n))return r}}moveHeaderPosition(t,e){const i=this.internalProps.layoutMap.moveHeaderPosition(t,e);if(i){if("column"===i.moveType){if(this.options.records?.[0]?.constructor===Array)for(let t=0;t<this.records.length;t++){const e=this.records[t].splice(i.sourceIndex-this.rowHeaderLevelCount,i.moveSize);e.unshift(i.targetIndex-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this.records[t],e)}this.colWidthsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize);for(let t=0;t<this.internalProps.layoutMap.columnWidths.length;t++){const{minWidth:e,maxWidth:i}=this.internalProps.layoutMap.columnWidths?.[t]??{};e&&("number"==typeof e&&e>0||"string"==typeof e)&&this.setMinColWidth(t,e),i&&("number"==typeof i&&i>0||"string"==typeof i)&&this.setMaxColWidth(t,i)}}else if("row"===i.moveType){if(this.options.records?.[0]?.constructor===Array){const t=this.records.splice(i.sourceIndex-this.columnHeaderLevelCount,i.moveSize);t.unshift(i.targetIndex-this.columnHeaderLevelCount,0),Array.prototype.splice.apply(this.records,t)}this.rowHeightsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize)}return!0}return!1}toggleHierarchyState(t,e){const i=this.getHierarchyState(t,e);i===r.expand?this.fireListeners(MR.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.collapse}):i===r.collapse&&this.fireListeners(MR.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.expand,originData:this.getCellOriginRecord(t,e)});const n=this.internalProps.layoutMap.toggleHierarchyState(t,e);this.refreshRowColCount(),this.clearCellStyleCache(),this.scenegraph.updateHierarchyIcon(t,e),this.scenegraph.updateRow(n.removeCellPositions,n.addCellPositions)}getHeaderCellAddressByPath(t){return this.internalProps.layoutMap.getPivotCellAdress(t)}getCellAddressByHeaderPaths(t){return this.internalProps.layoutMap.getCellAdressByHeaderPath(t)}getHeaderPathByXY(t){let e;e=t?this.getCellAt(t.x+this.getFrozenColsWidth()+this.scrollLeft+1,t.y+this.getFrozenRowsHeight()+this.scrollTop+1):this.getCellAt(this.getFrozenColsWidth()+this.scrollLeft+1,this.getFrozenRowsHeight()+this.scrollTop+1);return this.internalProps.layoutMap.getCellHeaderPaths(e.col,e.row)}getHierarchyState(t,e){return this._getHeaderLayoutMap(t,e)?.hierarchyState}hasHierarchyTreeHeader(){return"tree"===this.internalProps.layoutMap.rowHierarchyType}getMenuInfo(t,e,i){const n=this.internalProps.layoutMap.getPivotDimensionInfo(t,e);return{dimensionKey:n[n.length-1].dimensionKey,value:this.getCellValue(t,e),cellType:this.getCellType(t,e),isPivotCorner:this.isCornerHeader(t,e)}}_generateCollectValuesConfig(t,e){const i=this.options,n={};for(let r=0,o=i.indicators.length;r<o;r++)if("string"!=typeof i.indicators[r]&&i.indicators[r].chartSpec)if(!1===i.indicatorsAsCol){const o=i.indicators[r];if(n[o.indicatorKey]={by:e,range:!0,sumBy:!1!==o.chartSpec?.stack&&t.concat(o.chartSpec?.xField)},o.chartSpec.series)o.chartSpec.series.forEach((i=>{const r="string"==typeof i.xField?i.xField:i.xField[0];n[r]={by:t,type:"horizontal"!==i.direction?"xField":void 0,range:"horizontal"===i.direction};const o=i.yField;n[o]={by:e,range:"horizontal"!==i.direction,sumBy:!1!==i.stack&&t.concat(r)}}));else{const s="string"==typeof o.chartSpec.xField?o.chartSpec.xField:o.chartSpec.xField[0];n[s]={by:t,type:"horizontal"!==o.chartSpec.direction?"xField":void 0,range:"horizontal"===o.chartSpec.direction};const a=o.chartSpec.yField;n[a]={by:e,range:"horizontal"!==i.indicators[r].chartSpec.direction,sumBy:!1!==o.chartSpec.stack&&t.concat(s)}}}else{const o=i.indicators[r];if(n[o.indicatorKey]={by:t,range:!0,sumBy:!1!==o.chartSpec?.stack&&e.concat(o.chartSpec?.yField)},o.chartSpec.series)o.chartSpec.series.forEach((i=>{const r="string"==typeof i.yField?i.yField:i.yField[0];n[r]={by:e,type:"horizontal"===i.direction?"yField":void 0,range:"horizontal"!==i.direction};const o=i.xField;n[o]={by:t,range:"horizontal"===i.direction,sumBy:!1!==i.stack&&e.concat(r)}}));else{const s="string"==typeof o.chartSpec.yField?o.chartSpec.yField:o.chartSpec.yField[0];n[s]={by:e,type:"horizontal"===o.chartSpec.direction?"yField":void 0,range:"horizontal"!==o.chartSpec.direction};const a=o.chartSpec.xField;n[a]={by:t,range:"horizontal"===i.indicators[r].chartSpec.direction,sumBy:!1!==o.chartSpec.stack&&e.concat(s)}}}return n}_generateAggregationRules(){const t=[];return this.options.indicators.forEach((e=>{if("string"==typeof e)t.push({indicatorKey:e,field:e,aggregationType:o.RECORD});else if(e.chartSpec?.series){const i=[];e.chartSpec?.series.forEach((t=>{const e=!1===this.options.indicatorsAsCol?t.yField:t.xField;-1===i.indexOf(e)&&i.push(e)})),t.push({indicatorKey:e.indicatorKey,field:i,aggregationType:o.RECORD})}else t.push({indicatorKey:e.indicatorKey,field:e.indicatorKey,aggregationType:o.RECORD})})),t}setCustomStateNameToSpec(){const t=t=>{t.bar?.state?.selected&&(t.bar.state.vtable_selected=t.bar.state.selected,t.bar.state.vtable_selected_reverse=t.bar.state.selected_reverse,delete t.bar.state.selected,delete t.bar.state.selected_reverse),t.point?.state?.selected&&(t.point.state.vtable_selected=t.point.state.selected,t.point.state.vtable_selected_reverse=t.point.state.selected_reverse,delete t.point.state.selected,delete t.point.state.selected_reverse),t.line?.state?.selected&&(t.line.state.vtable_selected=t.line.state.selected,t.line.state.vtable_selected_reverse=t.line.state.selected_reverse,delete t.line.state.selected,delete t.line.state.selected_reverse),t.area?.state?.selected&&(t.area.state.vtable_selected=t.area.state.selected,t.area.state.vtable_selected_reverse=t.area.state.selected_reverse,delete t.area.state.selected,delete t.area.state.selected_reverse)};this.options.indicators.forEach((e=>{if(e.chartSpec){const i=e.chartSpec;i.series?i.series.forEach((e=>{t(e)})):t(i)}}))}_getActiveChartInstance(){const t=this.scenegraph.getCell(this.stateManeger.hover?.cellPos?.col,this.stateManeger.hover?.cellPos?.row);return"chart"===t?.getChildren()?.[0]?.type?t.getChildren()[0].activeChartInstance:null}listenChart(t,e){this._chartEventMap[t]=e}unlistenChart(t){delete this._chartEventMap[t]}_bindChartEvent(t){if(t)for(const e in this._chartEventMap)t.on(e,this._chartEventMap[e])}updateFilterRules(t){this.internalProps.dataConfig.filterRules=t,this.dataset.updateFilterRules(t),dR(this.scenegraph),function(t){for(let e=t.proxy.colStart;e<=t.proxy.colEnd;e++)t.getColGroup(e).getChildren().forEach((e=>{const i=e.col,n=e.row;e.children.forEach((e=>{"chart"===e.type&&(e.updateData(t.table.getCellValue(i,n)),e.addUpdateBoundTag())}))}))}(this.scenegraph),this.invalidate()}setLegendSelected(t){this.internalProps.legends.legendComponent.setSelected(t)}getChartDatumPosition(t,e){const i=this.getCellAddressByHeaderPaths(e),n=this.getCellRelativeRect(i.col,i.row);console.log(n);const r=this.scenegraph.getCell(i.col,i.row);let o;const s=r?.getChildren()?.[0];if(s.attribute.chartInstance){const e=s.attribute.chartInstance,{dataId:i,data:n,viewBox:r,axes:a}=s.attribute;a.forEach(((t,i)=>{if("linear"===t.type){e._chart._components[i]._domain={min:t.range?.min??0,max:t.range?.max??0}}else if("band"===t.type){const n=e._chart._components[i];n._spec.domain=t.domain.slice(0),n.updateScaleDomain()}})),e.updateViewBox({x1:r.x1-s.getRootNode().table.scrollLeft,x2:r.x2-s.getRootNode().table.scrollLeft,y1:r.y1-s.getRootNode().table.scrollTop,y2:r.y2-s.getRootNode().table.scrollTop}),e.updateDataSync(i,n),o=e.convertDatumToPosition(t),this.invalidate()}return o?{x:Math.round(o.x+n.bounds.x1),y:Math.round(o.y+n.bounds.y1)}:null}},t.PivotTable=class extends zP{pivotSortState;dataset;flatDataToObjects;constructor(t){if(super(t),t.layout&&Object.assign(t,t.layout),this.internalProps.dataConfig=t.dataConfig,this.internalProps.enableDataAnalysis=t.enableDataAnalysis,this.internalProps.enableDataAnalysis&&(t.rows||t.columns)){const e=t.rows.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),i=t.columns.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),n=t.indicators?.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[])??[];this.dataset=new bE(this.internalProps.dataConfig,e,i,n,t.records)}this.refreshHeader(),this.pivotSortState=[],t.pivotSortState&&this.updatePivotSortState(t.pivotSortState),t.dataSource?AC(this,t.dataSource):t.records?this.setRecords(t.records,this.internalProps.sortState):this.setRecords([])}static get EVENT_TYPE(){return BR}isListTable(){return!1}isPivotTable(){return!0}isPivotChart(){return!1}_canResizeColumn(t,e){const i=super._canResizeColumn(t,e);if(i&&!this.internalProps.layoutMap.indicatorsAsCol){const e=this.internalProps.layoutMap.getBody(t,this.columnHeaderLevelCount);if(e?.disableColumnResize)return!1}return i}updateOption(t,e=!1){const i=this.internalProps;if(super.updateOption(t),i.dataConfig=t.dataConfig,i.enableDataAnalysis=t.enableDataAnalysis,"tree"===t?.rowHierarchyType&&"tree"===this.internalProps.layoutMap.rowHierarchyType&&this.internalProps.layoutMap.rowExpandLevel===t?.rowExpandLevel){const t=this.internalProps.layoutMap.rowDimensionTree.tree.children;this.internalProps.layoutMap.rowTree.forEach(((e,i)=>{this.syncHierarchyState(t[i],e)}))}if(this.internalProps.enableDataAnalysis&&(t.rows||t.columns)){const e=t.rows.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),n=t.columns.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),r=t.indicators.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[]);this.dataset=new bE(i.dataConfig,e,n,r,t.records)}return this.refreshHeader(),i.disposables&&(i.disposables.forEach((t=>t?.dispose?.())),i.disposables=null),this._updateSize(),t.dataSource?AC(this,t.dataSource):t.records?this.setRecords(t.records,void 0):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.invalidate()),this.pivotSortState=[],t.pivotSortState&&this.updatePivotSortState(t.pivotSortState),new Promise((t=>{setTimeout(t,0)}))}refreshHeader(){const t=this.internalProps;t.headerEvents&&t.headerEvents.forEach((t=>this.unlisten(t)));const e=this.options.records??this.internalProps.records;this.options.enableDataAnalysis?t.layoutMap=new tE(this,this.dataset):(Array.isArray(this.options.columnTree)||Array.isArray(this.options.rowTree))&&(t.layoutMap=new JP(this),e?.[0]?.constructor!==Array&&(this.flatDataToObjects=new eE({rows:t.layoutMap.rowDimensionKeys,columns:t.layoutMap.colDimensionKeys,indicators:t.layoutMap.indicatorKeys,indicatorsAsCol:t.layoutMap.indicatorsAsCol,indicatorDimensionKey:t.layoutMap.indicatorDimensionKey},e)));for(let e=0;e<t.layoutMap.columnWidths.length;e++){const{width:i,minWidth:n,maxWidth:r}=t.layoutMap.columnWidths?.[e]??{};i&&("string"==typeof i&&"auto"!==i||"number"==typeof i&&i>0)&&this.setColWidth(e,i),n&&("number"==typeof n&&n>0||"string"==typeof n)&&this.setMinColWidth(e,n),r&&("number"==typeof r&&r>0||"string"==typeof r)&&this.setMaxColWidth(e,r)}this.refreshRowColCount()}refreshRowColCount(){const t=this,{layoutMap:e}=t.internalProps;e&&(t.colCount=e.colCount??0,t.rowCount=e.rowCount??0,t.frozenColCount=e.rowHeaderLevelCount,t.frozenRowCount=e.headerLevelCount,t.bottomFrozenRowCount=e?.bottomFrozenRowCount??0,t.rightFrozenColCount=e?.rightFrozenColCount??0)}_getSortFuncFromHeaderOption(t,e,i){}get rowHierarchyType(){return this.internalProps.layoutMap.rowHierarchyType}syncHierarchyState(t,e){t.value===e.value&&t.dimensionKey===e.dimensionKey&&(e.hierarchyState=e.hierarchyState??(e?.children?t.hierarchyState:void 0),e?.children?.forEach(((e,i)=>{t?.children?.[i]&&e&&this.syncHierarchyState(t.children[i],e)})))}getRecordIndexByRow(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByRow(t)}getRecordIndexByCol(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByCol(t)}getFieldData(t,e,i){if(null==t)return null;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return null;const r=this.getRecordIndexByRow(i),o=this.getRecordIndexByCol(e),s=n.dataSource?.getField(r,o);if("string"!=typeof t){return Mw({dataValue:s,...n.internalProps.layoutMap.getCellHeaderPaths(e,i)},t,gt)}return s}getCellValue(t,e){if(this.internalProps.layoutMap.isHeader(t,e)){const{caption:i,fieldFormat:n}=this.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n(i):i}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.formatValue?r.formatValue():""}if(this.flatDataToObjects){const i=this.internalProps.layoutMap.getCellHeaderPaths(t,e),n=i.colHeaderPaths.map((t=>t.indicatorKey??t.value)),r=i.rowHeaderPaths.map((t=>t.indicatorKey??t.value)),o=this.flatDataToObjects.getTreeNode(r,n,this.internalProps.layoutMap.getBody(t,e).indicatorKey),{fieldFormat:s}=this.internalProps.layoutMap.getBody(t,e);return"function"==typeof s?s(o?.record):o?.value??""}const{field:i,fieldFormat:n}=this.internalProps.layoutMap.getBody(t,e);return this.getFieldData(n||i,t,e)}getCellOriginValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{caption:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.value?r.value():void 0}if(this.flatDataToObjects){const i=this.internalProps.layoutMap.getCellHeaderPaths(t,e),n=i.colHeaderPaths.map((t=>t.indicatorKey??t.value)),r=i.rowHeaderPaths.map((t=>t.indicatorKey??t.value)),o=this.flatDataToObjects.getTreeNode(r,n,this.internalProps.layoutMap.getBody(t,e).indicatorKey);return o?.value}const{field:n}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(n,t,e)}getCellOriginRecord(t,e){if(!this.internalProps.layoutMap.isHeader(t,e)){if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[];return this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e)).records}if(this.flatDataToObjects){const i=this.internalProps.layoutMap.getCellHeaderPaths(t,e),n=i.colHeaderPaths.map((t=>t.indicatorKey??t.value)),r=i.rowHeaderPaths.map((t=>t.indicatorKey??t.value)),o=this.flatDataToObjects.getTreeNode(r,n,this.internalProps.layoutMap.getBody(t,e).indicatorKey);return o?.record}}}updateSortRules(t){this.internalProps.dataConfig.sortRules=t,this.dataset.updateSortRules(t),this.internalProps.layoutMap.updateDataset(this.dataset),this.invalidate()}updatePivotSortState(t){for(let e=0;e<t.length;e++){const{dimensions:i,order:n}=t[e],r=this.internalProps.layoutMap.getPivotCellAdress(i);r&&this.pivotSortState.push({col:r.col,row:r.row,order:n})}}getPivotSortState(t,e){if(!this.pivotSortState)return;const i=this.getCellRange(t,e);for(let t=0;t<this.pivotSortState.length;t++){const{col:e,row:n,order:r}=this.pivotSortState[t];if(at(i,e,n))return r}}moveHeaderPosition(t,e){const i=this.internalProps.layoutMap.moveHeaderPosition(t,e);if(i){if("column"===i.moveType){if(this.options.records?.[0]?.constructor===Array)for(let t=0;t<this.records.length;t++){const e=this.records[t].splice(i.sourceIndex-this.rowHeaderLevelCount,i.moveSize);e.unshift(i.targetIndex-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this.records[t],e)}this.colWidthsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize);for(let t=0;t<this.internalProps.layoutMap.columnWidths.length;t++){const{minWidth:e,maxWidth:i}=this.internalProps.layoutMap.columnWidths?.[t]??{};e&&("number"==typeof e&&e>0||"string"==typeof e)&&this.setMinColWidth(t,e),i&&("number"==typeof i&&i>0||"string"==typeof i)&&this.setMaxColWidth(t,i)}}else if("row"===i.moveType){if(this.options.records?.[0]?.constructor===Array){const t=this.records.splice(i.sourceIndex-this.columnHeaderLevelCount,i.moveSize);t.unshift(i.targetIndex-this.columnHeaderLevelCount,0),Array.prototype.splice.apply(this.records,t)}this.rowHeightsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize)}return!0}return!1}toggleHierarchyState(t,e){const i=this.getHierarchyState(t,e);i===r.expand?this.fireListeners(BR.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.collapse}):i===r.collapse&&this.fireListeners(BR.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.expand,originData:this.getCellOriginRecord(t,e)});const n=this.internalProps.layoutMap.toggleHierarchyState(t,e);this.refreshRowColCount(),this.clearCellStyleCache(),this.scenegraph.updateHierarchyIcon(t,e),this.scenegraph.updateRow(n.removeCellPositions,n.addCellPositions)}getHeaderCellAddressByPath(t){return this.internalProps.layoutMap.getPivotCellAdress(t)}getCellAddressByHeaderPaths(t){return this.internalProps.layoutMap.getCellAdressByHeaderPath(t)}getHeaderPathByXY(t){let e;e=t?this.getCellAt(t.x+this.getFrozenColsWidth()+this.scrollLeft+1,t.y+this.getFrozenRowsHeight()+this.scrollTop+1):this.getCellAt(this.getFrozenColsWidth()+this.scrollLeft+1,this.getFrozenRowsHeight()+this.scrollTop+1);return this.internalProps.layoutMap.getCellHeaderPaths(e.col,e.row)}getHierarchyState(t,e){return this._getHeaderLayoutMap(t,e)?.hierarchyState}hasHierarchyTreeHeader(){return"tree"===this.internalProps.layoutMap.rowHierarchyType}getMenuInfo(t,e,i){const n=this.internalProps.layoutMap.getPivotDimensionInfo(t,e);return{dimensionKey:n[n.length-1].dimensionKey,value:this.getCellValue(t,e),cellType:this.getCellType(t,e),isPivotCorner:this.isCornerHeader(t,e)}}},t.TYPES=c,t.clearGlobal=function(){KP()},t.core=jP,t.data=Hw,t.getIcons=function(){return kC()},t.register=UP,t.themes=ti,t.version="0.9.2-alpha.2"}));
|