@visactor/vtable-plugins 1.22.6-alpha.0 → 1.22.6-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.
@@ -42,8 +42,8 @@ class ExcelEditCellKeyboardPlugin {
42
42
  if (!this.table.editorManager.editingEditor || eventKey !== ExcelEditCellKeyboardResponse.ENTER && eventKey !== ExcelEditCellKeyboardResponse.TAB) {
43
43
  if (!this.table.editorManager.editingEditor && (eventKey === ExcelEditCellKeyboardResponse.DELETE || eventKey === ExcelEditCellKeyboardResponse.BACKSPACE)) {
44
44
  const selectCells = this.table.getSelectedCellInfos();
45
- (null == selectCells ? void 0 : selectCells.length) > 0 && deleteSelectRange(selectCells, this.table),
46
- event.stopPropagation(), event.preventDefault();
45
+ (null == selectCells ? void 0 : selectCells.length) > 0 && document.activeElement === this.table.getElement() && (deleteSelectRange(selectCells, this.table),
46
+ event.stopPropagation(), event.preventDefault());
47
47
  }
48
48
  } else this.table.editorManager.completeEdit(), this.table.getElement().focus(),
49
49
  eventKey === ExcelEditCellKeyboardResponse.ENTER ? this.table.selectCell(col, row + 1) : eventKey === ExcelEditCellKeyboardResponse.TAB && this.table.selectCell(col + 1, row),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/excel-edit-cell-keyboard.ts"],"names":[],"mappings":"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","file":"excel-edit-cell-keyboard.js","sourcesContent":["import type { ListTable, BaseTableAPI, TYPES, pluginsDefinition } from '@visactor/vtable';\nimport { TABLE_EVENT_TYPE } from '@visactor/vtable';\nimport type { TableEvents } from '@visactor/vtable/src/core/TABLE_EVENT_TYPE';\nimport type { EventArg } from './types';\nexport enum ExcelEditCellKeyboardResponse {\n ENTER = 'enter',\n TAB = 'tab',\n ARROW_LEFT = 'arrowLeft',\n ARROW_RIGHT = 'arrowRight',\n ARROW_DOWN = 'arrowDown',\n ARROW_UP = 'arrowUp',\n DELETE = 'delete',\n BACKSPACE = 'backspace'\n}\n//备用 插件配置项 目前感觉都走默认逻辑就行\nexport type IExcelEditCellKeyboardPluginOptions = {\n id?: string;\n responseKeyboard?: ExcelEditCellKeyboardResponse[];\n // 是否响应删除\n // enableDeleteKey?: boolean;\n};\n\nexport class ExcelEditCellKeyboardPlugin implements pluginsDefinition.IVTablePlugin {\n id = `excel-edit-cell-keyboard`;\n name = 'Excel Edit Cell Keyboard';\n runTime = [TABLE_EVENT_TYPE.INITIALIZED];\n table: ListTable;\n pluginOptions: IExcelEditCellKeyboardPluginOptions;\n responseKeyboard: ExcelEditCellKeyboardResponse[];\n constructor(pluginOptions?: IExcelEditCellKeyboardPluginOptions) {\n this.id = pluginOptions?.id ?? this.id;\n this.pluginOptions = pluginOptions;\n this.responseKeyboard = pluginOptions?.responseKeyboard ?? [\n ExcelEditCellKeyboardResponse.ENTER,\n ExcelEditCellKeyboardResponse.TAB,\n ExcelEditCellKeyboardResponse.ARROW_LEFT,\n ExcelEditCellKeyboardResponse.ARROW_RIGHT,\n ExcelEditCellKeyboardResponse.ARROW_DOWN,\n ExcelEditCellKeyboardResponse.ARROW_UP,\n ExcelEditCellKeyboardResponse.DELETE,\n ExcelEditCellKeyboardResponse.BACKSPACE\n ];\n\n this.bindEvent();\n }\n run(...args: [EventArg, TableEvents[keyof TableEvents] | TableEvents[keyof TableEvents][], BaseTableAPI]) {\n const table: BaseTableAPI = args[2];\n this.table = table as ListTable;\n }\n\n bindEvent() {\n //监听document全局的keydown事件 捕获阶段监听 可以及时阻止事件传播和默认行为\n document.addEventListener('keydown', this.handleKeyDown.bind(this), true);\n // this.table.on('selected_cell', () => {\n // this.updateHighlight();\n // });\n\n // this.table.on('selected_clear', () => {\n // this.clearHighlight();\n // });\n\n // this.table.on('mousemove_table', () => {\n // if (this.table.stateManager.select.selecting) {\n // this.updateHighlight();\n // }\n // });\n }\n handleKeyDown(event: KeyboardEvent) {\n if (this.table.editorManager && this.isExcelShortcutKey(event)) {\n const eventKey = event.key.toLowerCase() as ExcelEditCellKeyboardResponse;\n //判断是键盘触发编辑单元格的情况下,那么在编辑状态中切换方向需要选中下一个继续编辑\n if (this.table.editorManager.editingEditor && this.table.editorManager.beginTriggerEditCellMode === 'keydown') {\n const { col, row } = this.table.editorManager.editCell;\n this.table.editorManager.completeEdit();\n this.table.getElement().focus();\n if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {\n //有这些配合键,则不进行选中下一个单元格的行为 执行vtable内部逻辑\n if (eventKey === ExcelEditCellKeyboardResponse.ENTER) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.TAB) {\n this.table.selectCell(col + 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_LEFT) {\n this.table.selectCell(col - 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_RIGHT) {\n this.table.selectCell(col + 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_DOWN) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_UP) {\n this.table.selectCell(col, row - 1);\n }\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n }\n } else {\n const { col, row } = this.table.stateManager.select.cellPos;\n if (\n this.table.editorManager.editingEditor &&\n (eventKey === ExcelEditCellKeyboardResponse.ENTER || eventKey === ExcelEditCellKeyboardResponse.TAB)\n ) {\n this.table.editorManager.completeEdit();\n this.table.getElement().focus();\n if (eventKey === ExcelEditCellKeyboardResponse.ENTER) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.TAB) {\n this.table.selectCell(col + 1, row);\n }\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n } else if (\n !this.table.editorManager.editingEditor &&\n (eventKey === ExcelEditCellKeyboardResponse.DELETE || eventKey === ExcelEditCellKeyboardResponse.BACKSPACE)\n ) {\n //响应删除键,删除\n const selectCells = this.table.getSelectedCellInfos();\n if (selectCells?.length > 0) {\n // 如果选中的是范围,则删除范围内的所有单元格\n deleteSelectRange(selectCells, this.table);\n }\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n }\n }\n }\n }\n // 判断event的keyCode是否是excel的快捷键\n isExcelShortcutKey(event: KeyboardEvent) {\n return this.responseKeyboard.includes(event.key.toLowerCase() as ExcelEditCellKeyboardResponse);\n }\n setResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = responseKeyboard;\n }\n deleteResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = this.responseKeyboard.filter(key => !responseKeyboard.includes(key));\n }\n addResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = [...this.responseKeyboard, ...responseKeyboard];\n }\n release() {\n document.removeEventListener('keydown', this.handleKeyDown, true);\n }\n}\n//将选中单元格的值设置为空\nfunction deleteSelectRange(selectCells: TYPES.CellInfo[][], tableInstance: ListTable) {\n for (let i = 0; i < selectCells.length; i++) {\n for (let j = 0; j < selectCells[i].length; j++) {\n tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, '');\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/excel-edit-cell-keyboard.ts"],"names":[],"mappings":"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","file":"excel-edit-cell-keyboard.js","sourcesContent":["import type { ListTable, BaseTableAPI, TYPES, pluginsDefinition } from '@visactor/vtable';\nimport { TABLE_EVENT_TYPE } from '@visactor/vtable';\nimport type { TableEvents } from '@visactor/vtable/src/core/TABLE_EVENT_TYPE';\nimport type { EventArg } from './types';\nexport enum ExcelEditCellKeyboardResponse {\n ENTER = 'enter',\n TAB = 'tab',\n ARROW_LEFT = 'arrowLeft',\n ARROW_RIGHT = 'arrowRight',\n ARROW_DOWN = 'arrowDown',\n ARROW_UP = 'arrowUp',\n DELETE = 'delete',\n BACKSPACE = 'backspace'\n}\n//备用 插件配置项 目前感觉都走默认逻辑就行\nexport type IExcelEditCellKeyboardPluginOptions = {\n id?: string;\n responseKeyboard?: ExcelEditCellKeyboardResponse[];\n // keyDown_before?: (event: KeyboardEvent) => void;\n // keyDown_after?: (event: KeyboardEvent) => void;\n // 是否响应删除\n // enableDeleteKey?: boolean;\n};\n\nexport class ExcelEditCellKeyboardPlugin implements pluginsDefinition.IVTablePlugin {\n id = `excel-edit-cell-keyboard`;\n name = 'Excel Edit Cell Keyboard';\n runTime = [TABLE_EVENT_TYPE.INITIALIZED];\n table: ListTable;\n pluginOptions: IExcelEditCellKeyboardPluginOptions;\n responseKeyboard: ExcelEditCellKeyboardResponse[];\n constructor(pluginOptions?: IExcelEditCellKeyboardPluginOptions) {\n this.id = pluginOptions?.id ?? this.id;\n this.pluginOptions = pluginOptions;\n this.responseKeyboard = pluginOptions?.responseKeyboard ?? [\n ExcelEditCellKeyboardResponse.ENTER,\n ExcelEditCellKeyboardResponse.TAB,\n ExcelEditCellKeyboardResponse.ARROW_LEFT,\n ExcelEditCellKeyboardResponse.ARROW_RIGHT,\n ExcelEditCellKeyboardResponse.ARROW_DOWN,\n ExcelEditCellKeyboardResponse.ARROW_UP,\n ExcelEditCellKeyboardResponse.DELETE,\n ExcelEditCellKeyboardResponse.BACKSPACE\n ];\n\n this.bindEvent();\n }\n run(...args: [EventArg, TableEvents[keyof TableEvents] | TableEvents[keyof TableEvents][], BaseTableAPI]) {\n const table: BaseTableAPI = args[2];\n this.table = table as ListTable;\n }\n\n bindEvent() {\n //监听document全局的keydown事件 捕获阶段监听 可以及时阻止事件传播和默认行为\n document.addEventListener('keydown', this.handleKeyDown.bind(this), true);\n // this.table.on('selected_cell', () => {\n // this.updateHighlight();\n // });\n\n // this.table.on('selected_clear', () => {\n // this.clearHighlight();\n // });\n\n // this.table.on('mousemove_table', () => {\n // if (this.table.stateManager.select.selecting) {\n // this.updateHighlight();\n // }\n // });\n }\n handleKeyDown(event: KeyboardEvent) {\n // this.pluginOptions?.keyDown_before?.(event);\n if (this.table.editorManager && this.isExcelShortcutKey(event)) {\n const eventKey = event.key.toLowerCase() as ExcelEditCellKeyboardResponse;\n //判断是键盘触发编辑单元格的情况下,那么在编辑状态中切换方向需要选中下一个继续编辑\n if (this.table.editorManager.editingEditor && this.table.editorManager.beginTriggerEditCellMode === 'keydown') {\n const { col, row } = this.table.editorManager.editCell;\n this.table.editorManager.completeEdit();\n this.table.getElement().focus();\n if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {\n //有这些配合键,则不进行选中下一个单元格的行为 执行vtable内部逻辑\n if (eventKey === ExcelEditCellKeyboardResponse.ENTER) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.TAB) {\n this.table.selectCell(col + 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_LEFT) {\n this.table.selectCell(col - 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_RIGHT) {\n this.table.selectCell(col + 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_DOWN) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_UP) {\n this.table.selectCell(col, row - 1);\n }\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n }\n } else {\n const { col, row } = this.table.stateManager.select.cellPos;\n if (\n this.table.editorManager.editingEditor &&\n (eventKey === ExcelEditCellKeyboardResponse.ENTER || eventKey === ExcelEditCellKeyboardResponse.TAB)\n ) {\n this.table.editorManager.completeEdit();\n this.table.getElement().focus();\n if (eventKey === ExcelEditCellKeyboardResponse.ENTER) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.TAB) {\n this.table.selectCell(col + 1, row);\n }\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n } else if (\n !this.table.editorManager.editingEditor &&\n (eventKey === ExcelEditCellKeyboardResponse.DELETE || eventKey === ExcelEditCellKeyboardResponse.BACKSPACE)\n ) {\n //响应删除键,删除\n const selectCells = this.table.getSelectedCellInfos();\n if (selectCells?.length > 0 && document.activeElement === this.table.getElement()) {\n // 如果选中的是范围,则删除范围内的所有单元格\n deleteSelectRange(selectCells, this.table);\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n }\n }\n }\n }\n // this.pluginOptions?.keyDown_after?.apply(this, [event]);\n }\n // 判断event的keyCode是否是excel的快捷键\n isExcelShortcutKey(event: KeyboardEvent) {\n return this.responseKeyboard.includes(event.key.toLowerCase() as ExcelEditCellKeyboardResponse);\n }\n setResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = responseKeyboard;\n }\n deleteResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = this.responseKeyboard.filter(key => !responseKeyboard.includes(key));\n }\n addResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = [...this.responseKeyboard, ...responseKeyboard];\n }\n release() {\n document.removeEventListener('keydown', this.handleKeyDown, true);\n }\n}\n//将选中单元格的值设置为空\nfunction deleteSelectRange(selectCells: TYPES.CellInfo[][], tableInstance: ListTable) {\n for (let i = 0; i < selectCells.length; i++) {\n for (let j = 0; j < selectCells[i].length; j++) {\n tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, '');\n }\n }\n}\n"]}
@@ -1172,11 +1172,11 @@
1172
1172
  else if (!this.table.editorManager.editingEditor &&
1173
1173
  (eventKey === exports.ExcelEditCellKeyboardResponse.DELETE || eventKey === exports.ExcelEditCellKeyboardResponse.BACKSPACE)) {
1174
1174
  const selectCells = this.table.getSelectedCellInfos();
1175
- if (selectCells?.length > 0) {
1175
+ if (selectCells?.length > 0 && document.activeElement === this.table.getElement()) {
1176
1176
  deleteSelectRange(selectCells, this.table);
1177
+ event.stopPropagation();
1178
+ event.preventDefault();
1177
1179
  }
1178
- event.stopPropagation();
1179
- event.preventDefault();
1180
1180
  }
1181
1181
  }
1182
1182
  }
@@ -34,4 +34,4 @@ Object.defineProperty(r,"__esModule",{value:!0}),r.CHAR="-퟿-�𐀀-􏿿",
34
34
  * @license MIT
35
35
  * @copyright Louis-Dominique Dubeau
36
36
  */
37
- function n(e){return e>=65&&e<=90||95===e||e>=97&&e<=122||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}Object.defineProperty(r,"__esModule",{value:!0}),r.NC_NAME_START_CHAR="A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",r.NC_NAME_CHAR="-"+r.NC_NAME_START_CHAR+".0-9·̀-ͯ‿-⁀",r.NC_NAME_START_CHAR_RE=new RegExp("^["+r.NC_NAME_START_CHAR+"]$","u"),r.NC_NAME_CHAR_RE=new RegExp("^["+r.NC_NAME_CHAR+"]$","u"),r.NC_NAME_RE=new RegExp("^["+r.NC_NAME_START_CHAR+"]["+r.NC_NAME_CHAR+"]*$","u"),r.isNCNameStartChar=n,r.isNCNameChar=function(e){return n(e)||45===e||46===e||e>=48&&e<=57||183===e||e>=768&&e<=879||e>=8255&&e<=8256}},{}]},{},[15])(15)}(Ri);var ki,Mi,Ai=l(Ri.exports);class Oi{id="excel-import-plugin";name="ExcelImportPlugin";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED];options;_tableInstance=null;constructor(e){this.options={autoTable:!0,autoColumns:!0,delimiter:",",exportData:!1,batchSize:1e3,enableBatchProcessing:!0,asyncDelay:5,...e},e?.id&&(this.id=e.id)}run(...e){const t=e[2];this._tableInstance=t,this._tableInstance.importFile=()=>{this.import("file")}}release(){this._tableInstance=null}async importFile(){return this.import("file")}async import(e,t,r){const n={...this.options,...r};if("file"===e)return this._importFromFileDialog(n);if("string"==typeof t)return this._importFromString(e,t,n);if(Array.isArray(t)||"object"==typeof t){if("json"!==e)throw new Error("只有JSON格式支持从对象导入");return this._importFromData("json",t,n)}throw new Error("Invalid import source")}async _importFromFileDialog(e){return new Promise(((t,r)=>{if(!this._tableInstance)return void r(new Error("表格实例不存在或已销毁,无法导入数据!"));const n=document.createElement("input");n.type="file",n.style.display="none",document.body.appendChild(n),n.addEventListener("change",(async i=>{try{const s=i.target.files?.[0];if(!s)return document.body.removeChild(n),void r(new Error("未选择文件"));const o=await this._parseFile(s,e);e.autoTable&&this._tableInstance&&(e.autoColumns&&this._tableInstance.updateOption(Object.assign({},this._tableInstance.options,{columns:o.columns})),this._tableInstance.setRecords(o.records)),n.value="",document.body.removeChild(n),t(o)}catch(e){document.body.removeChild(n),r(e)}})),n.click()}))}async _importFromString(e,t,r){let n;switch(e){case"csv":n=await this._parseCSVString(t,r);break;case"json":n=await this._parseJSONString(t,r);break;case"html":n=await this._parseHTMLString(t,r);break;default:throw new Error(`不支持的导入类型: ${e}`)}return r.autoTable&&this._tableInstance&&(r.autoColumns&&this._tableInstance.updateOption({columns:n.columns,plugins:[this]}),this._tableInstance.setRecords(n.records)),n}async _importFromData(e,t,r){let n;if("json"!==e)throw new Error(`不支持的数据类型: ${e}`);return n=await this._parseJSONData(t,r),r.autoTable&&this._tableInstance&&(r.autoColumns&&this._tableInstance.updateOption({columns:n.columns,plugins:[this]}),this._tableInstance.setRecords(n.records)),n}async _parseFile(e,t){const r={...this.options,...t},n=this._getFileExtension(e.name).toLowerCase();switch(n){case"xlsx":case"xls":return await this._parseExcelFile(e,r);case"csv":return await this._parseCsvFile(e,r);case"json":return await this._parseJsonFile(e,r);case"html":case"htm":return await this._parseHtmlFile(e,r);default:throw new Error(`不支持的文件类型: ${n}`)}}_getFileExtension(e){const t=e.split(".");return t.length>1?t[t.length-1]:""}async _parseExcelFile(e,t){const r={...this.options,...t};return await Oi.importExcelToVTableData(e,r)}async _parseCsvFile(e,t){const r={...this.options,...t},n=await e.text();return this._parseCSVString(n,r)}async _parseJsonFile(e,t){const r={...this.options,...t},n=await e.text();return this._parseJSONString(n,r)}async _parseHtmlFile(e,t){const r={...this.options,...t},n=await e.text();return this._parseHTMLString(n,r)}_buildColumnsFromHeaders(e){return 1===e.length?e[0].map(((e,t)=>({field:`col${t}`,title:e||`列${t+1}`,cellType:"text",headerType:"text"}))):Oi.buildColumns(e)}static async importExcelToVTableData(e,t){const r=new Ai.Workbook;await r.xlsx.load(await e.arrayBuffer());const n=r.worksheets[0];if(!n)throw new Error("Excel 文件无有效工作表");const i=t?.headerRowCount??this.detectHeaderRowCount(n),s=[];for(let e=1;e<=i;e++){const t=n.getRow(e);s.push(Array.prototype.slice.call(t.values,1))}const o=Oi.buildColumns(s),a=[],l=[];n.eachRow(((e,t)=>{if(t<=i)return;const r=Array.prototype.slice.call(e.values,1);l.push(r)}));const h=t?.batchSize||1e3;if(!1!==t?.enableBatchProcessing&&l.length>h)for(let e=0;e<l.length;e+=h){const r=l.slice(e,e+h).map((e=>{const t={};return e.forEach(((e,r)=>{t[`col${r}`]=e})),t}));a.push(...r),e+h<l.length&&await new Promise((e=>setTimeout(e,t?.asyncDelay||5)))}else l.forEach((e=>{const t={};e.forEach(((e,r)=>{t[`col${r}`]=e})),a.push(t)}));if(t?.exportData){const e=Oi._generateJavaScriptExport(o,a),t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download="vtable-data.js",document.body.appendChild(n),n.click(),setTimeout((()=>{document.body.removeChild(n),URL.revokeObjectURL(r)}),100)}return{columns:o,records:a}}static detectHeaderRowCount(e){let t=1,r=1;for(;;){const n=e.getRow(t),i=Array.prototype.slice.call(n.values,1);let s=!1;for(let e=1;e<i.length;e++)if(void 0!==i[e]&&""!==i[e]&&i[e]===i[e-1]){s=!0;break}if(!s)break;r++,t++}return r}static buildColumns(e,t=0,r,n=0){const i=e[n],s=[];r=r??i.length;let o=t;for(;o<r;){const t=String(i[o]||`列${o+1}`);let a=1;for(;o+a<r&&i[o+a]===t;)a++;if(n<e.length-1){const r=Oi.buildColumns(e,o,o+a,n+1);1===r.length?s.push(r[0]):s.push({title:t,columns:r,hideColumnsSubHeader:!1})}else s.push({field:`col${o}`,title:t,cellType:"text",headerType:"text"});o+=a}return s}async _parseCSVString(e,t){const r=e.split("\n").filter((e=>e.trim()));if(0===r.length)throw new Error("CSV文件为空");const n=t.delimiter||",",i=e=>e.split(n).map((e=>e.trim().replace(/^"|"$/g,""))),s=r.slice(0,1).map(i),o=r.slice(1),a=this._buildColumnsFromHeaders(s),l=[];return await this._processBatchRecords(o,t,(async e=>{const t=e.map((e=>{const t=i(e),r={};return t.forEach(((e,t)=>{r[`col${t}`]=e||""})),r}));l.push(...t)})),t.exportData&&this._exportToJS(a,l),{columns:a,records:l}}async _parseJSONString(e,t){let r;try{r=JSON.parse(e)}catch(e){throw new Error("JSON文件格式错误")}const n=await this._parseJSONData(r,t);return t.exportData&&this._exportToJS(n.columns,n.records),n}async _parseHTMLString(e,t){const r=(new DOMParser).parseFromString(e,"text/html").querySelector("table");if(!r)throw new Error("HTML文件中未找到表格");const n=Array.from(r.querySelectorAll("tr"));if(0===n.length)throw new Error("表格中没有数据行");const i=n.slice(0,1).map((e=>Array.from(e.querySelectorAll("th, td")).map((e=>e.textContent?.trim()||"")))),s=n.slice(1),o=this._buildColumnsFromHeaders(i),a=[];return await this._processBatchRecords(s,t,(async e=>{const t=e.map((e=>{const t=Array.from(e.querySelectorAll("td")).map((e=>e.textContent?.trim()||"")),r={};return t.forEach(((e,t)=>{r[`col${t}`]=e||""})),r}));a.push(...t)})),t.exportData&&this._exportToJS(o,a),{columns:o,records:a}}async _parseJSONData(e,t){let r;if("object"==typeof e&&!Array.isArray(e)&&e&&"columns"in e&&"records"in e){const n=e,i=[];await this._processBatchRecords(n.records,t,(async e=>{const t=e.map((e=>({...e})));i.push(...t)})),r={columns:n.columns,records:i}}else{if(!(Array.isArray(e)&&e.length>0))throw new Error("不支持的JSON格式");{const n=e[0],i=Object.keys(n).map((e=>({field:e,title:e,cellType:"text",headerType:"text"}))),s=[];await this._processBatchRecords(e,t,(async e=>{const t=e.map((e=>({...e})));s.push(...t)})),r={columns:i,records:s}}}return t.exportData&&this._exportToJS(r.columns,r.records),r}static _generateJavaScriptExport(e,t){const r=(e,t="")=>{if(null==e)return"null";if("string"==typeof e)return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`;if("number"==typeof e||"boolean"==typeof e)return String(e);if(Array.isArray(e)){if(0===e.length)return"[]";return`[${e.map((e=>r(e,t+" "))).join(", ")}]`}if("object"==typeof e){return`{\n${Object.entries(e).map((([e,n])=>`${t} ${e}: ${r(n,t+" ")}`)).join(",\n")}\n${t}}`}return String(e)},n=(e,t=" ")=>{const i=Object.entries(e).map((([e,i])=>{if("columns"===e&&Array.isArray(i)){const r=i.map((e=>n(e,t+" "))).join(",\n");return`${t} ${e}: [\n${r}\n${t} ]`}return`${t} ${e}: ${r(i)}`})).join(",\n");return`${t}{\n${i}\n${t}}`},i=e.map((e=>n(e))).join(",\n"),s=t.map((e=>` {\n${Object.entries(e).map((([e,t])=>` ${e}: ${r(t)}`)).join(",\n")}\n }`)).join(",\n");return`// VTable 数据导出 - JavaScript 对象字面量格式\n// 生成时间: ${(new Date).toLocaleString()}\n\nconst vtableData = {\n columns: [\n${i}\n ],\n records: [\n${s}\n ]\n};\n`}_exportToJS(e,t){const r=Oi._generateJavaScriptExport(e,t),n=new Blob([r],{type:"text/javascript"}),i=URL.createObjectURL(n),s=document.createElement("a");s.href=i,s.download="vtable-data.js",document.body.appendChild(s),s.click(),setTimeout((()=>{document.body.removeChild(s),URL.revokeObjectURL(i)}),100)}async _processBatchRecords(e,t,r){if(!t.enableBatchProcessing||e.length<=(t.batchSize||1e3))return void await r(e,0);const n=t.batchSize||1e3,i=Math.ceil(e.length/n);for(let s=0;s<i;s++){const o=s*n,a=Math.min(o+n,e.length),l=e.slice(o,a);await r(l,s),s<i-1&&await new Promise((e=>setTimeout(e,t.asyncDelay||5)))}}}class Ii{constructor(){}handleCopy(e){e.eventManager.handleCopy(new KeyboardEvent("copy"))}handleCut(e){e.eventManager.handleCut(new KeyboardEvent("cut"))}handlePaste(e){e.eventManager.handlePaste(new KeyboardEvent("paste"))}handleInsertRowAbove(e,t,r=1){if(void 0!==t&&"function"==typeof e.addRecord){const n=Array.from({length:r},((e,t)=>[]));e.addRecords(n,t-1)}}handleInsertRowBelow(e,t,r=1){if(void 0!==t&&"function"==typeof e.addRecord){const n=Array.from({length:r},((e,t)=>[]));e.addRecords(n,t)}}handleInsertColumnLeft(e,t,r=1){if(void 0!==t&&"function"==typeof e.addColumns){const n=[];for(let e=0;e<r;e++)n.push({field:t-e});e.addColumns(n,t,!0)}}handleInsertColumnRight(e,t,r=1){if(void 0!==t&&"function"==typeof e.addColumns){const n=[];for(let e=0;e<r;e++)n.push({field:t+1});e.addColumns(n,t+1,!0)}}handleDeleteRow(e){if("function"==typeof e.deleteRecords){const t=e.stateManager.select.ranges,r=[];for(let e=0;e<t.length;e++){const n=t[e];for(let e=n.start.row;e<=n.end.row;e++)r.includes(e)||r.push(e)}r.sort(((e,t)=>t-e));const n=[];for(let t=0;t<r.length;t++){const i=e.getRecordIndexByCell(0,r[t]);n.push(i)}e.deleteRecords(n)}}handleDeleteColumn(e,t){if(void 0!==t&&"function"==typeof e.deleteColumns){const t=e.stateManager.select.ranges,r=[];for(let e=0;e<t.length;e++){const n=t[e];for(let e=n.start.col;e<=n.end.col;e++)r.includes(e)||r.push(e)}e.deleteColumns(r,!0)}}handleHideColumn(e,t){void 0!==t&&"function"==typeof e.hideColumns&&e.hideColumns([t])}handleSort(e,t){if(void 0!==t&&"function"==typeof e.sort){const r=e.getSortState?e.getSortState():null;let n="asc";r&&r.field===t&&(n="asc"===r.order?"desc":"normal"),e.sort({field:t,order:n})}}handleMergeCells(e){if(1===(e.stateManager.select.ranges?.length??0)&&"function"==typeof e.mergeCells){const{row:t,col:r}=e.stateManager.select.ranges[0].start,{row:n,col:i}=e.stateManager.select.ranges[0].end;if(r===i&&t===n)return;e.mergeCells(Math.min(r,i),Math.min(t,n),Math.max(r,i),Math.max(t,n))}}handleUnmergeCells(e){if(1===(e.stateManager.select.ranges?.length??0)&&"function"==typeof e.unmergeCells){const{row:t,col:r}=e.stateManager.select.ranges[0].start,{row:n,col:i}=e.stateManager.select.ranges[0].end;if(r===i&&t===n)return;e.unmergeCells(Math.min(r,i),Math.min(t,n),Math.max(r,i),Math.max(t,n))}}handleSetProtection(e){}handleFreezeToRow(e,t){void 0!==t&&(e.frozenRowCount=t+1)}handleFreezeToColumn(e,t){void 0!==t&&(e.frozenColCount=t+1)}handleFreezeToRowAndColumn(e,t,r){void 0!==t&&void 0!==r&&(e.frozenRowCount=t+1,e.frozenColCount=r+1)}handleUnfreeze(e){e.frozenRowCount=0,e.frozenColCount=0}release(){}}class Ni{filterFuncRule=[];filterValueRule=[];applyFilter(e,t){const{filters:r}=e;this.filterFuncRule=[],this.filterValueRule=[],r.forEach(((e,t)=>{if(e.enable)if("byValue"===e.type)this.filterValueRule.push({filterKey:String(e.field),filteredValues:e.values});else if("byCondition"===e.type){const t=this.createFilterFunction(e);this.filterFuncRule.push({filterFunc:t,fieldId:String(e.field)})}})),t.updateFilterRules([...this.filterFuncRule,...this.filterValueRule],{clearRowHeightCache:!1})}createFilterFunction(e){const{field:t,operator:r,condition:n}=e;return r&&void 0!==n?e=>{const i=e[t];if(null==i)return!1;switch(r){case"equals":return 0===this.compareValues(i,n);case"notEquals":return 0!==this.compareValues(i,n);case"greaterThan":return this.compareValues(i,n)>0;case"lessThan":return this.compareValues(i,n)<0;case"greaterThanOrEqual":return this.compareValues(i,n)>=0;case"lessThanOrEqual":return this.compareValues(i,n)<=0;case"between":return!Array.isArray(n)||2!==n.length||this.compareValues(i,n[0])>=0&&this.compareValues(i,n[1])<=0;case"notBetween":return!Array.isArray(n)||2!==n.length||(this.compareValues(i,n[0])<0||this.compareValues(i,n[1])>0);case"contains":return String(i).toLowerCase().includes(String(n).toLowerCase());case"notContains":return!String(i).toLowerCase().includes(String(n).toLowerCase());case"startsWith":return String(i).toLowerCase().startsWith(String(n).toLowerCase());case"notStartsWith":return!String(i).toLowerCase().startsWith(String(n).toLowerCase());case"endsWith":return String(i).toLowerCase().endsWith(String(n).toLowerCase());case"notEndsWith":return!String(i).toLowerCase().endsWith(String(n).toLowerCase());case"isChecked":return!0===Boolean(i);case"isUnchecked":return!1===Boolean(i);default:return!0}}:()=>!0}compareValues(e,t){if("number"==typeof e&&"number"==typeof t)return e===t?0:e>t?1:-1;if("boolean"==typeof e&&"boolean"==typeof t)return e===t?0:-1;const r=String(e).toLowerCase(),n=String(t).toLowerCase();return r===n?0:r>n?1:-1}clearAllFilter(e){this.filterFuncRule=[],this.filterValueRule=[],e.updateFilterRules([])}clearFilter(e,t){this.filterValueRule=this.filterValueRule.filter((e=>e.filterKey!==t)),this.filterFuncRule=this.filterFuncRule.filter((e=>e.fieldId!==t)),e.updateFilterRules([...this.filterFuncRule,...this.filterValueRule])}}e.FilterActionType=void 0,(ki=e.FilterActionType||(e.FilterActionType={}))[ki.ADD_FILTER=0]="ADD_FILTER",ki[ki.REMOVE_FILTER=1]="REMOVE_FILTER",ki[ki.UPDATE_FILTER=2]="UPDATE_FILTER",ki[ki.ENABLE_FILTER=3]="ENABLE_FILTER",ki[ki.DISABLE_FILTER=4]="DISABLE_FILTER",ki[ki.CLEAR_ALL_FILTERS=5]="CLEAR_ALL_FILTERS",ki[ki.APPLY_FILTERS=6]="APPLY_FILTERS",e.FilterOperatorCategory=void 0,(Mi=e.FilterOperatorCategory||(e.FilterOperatorCategory={})).ALL="all",Mi.TEXT="text",Mi.NUMBER="number",Mi.COLOR="color",Mi.CHECKBOX="checkbox",Mi.RADIO="radio";class Fi{state;engine;listeners=[];table;constructor(e,t){this.state={filters:new Map},this.engine=t,this.table=e}getFilterState(e){return this.state.filters.get(e)}getActiveFilterFields(){const e=[];return this.state.filters.forEach(((t,r)=>{t.enable&&e.push(r)})),e}getAllFilterStates(){return this.state}reapplyCurrentFilters(){this.getActiveFilterFields().length>0&&this.applyFilters()}dispatch(e){this.state=this.reduce(this.state,e),this.shouldApplyFilter(e)&&this.applyFilters(),this.notifyListeners(e)}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter((t=>t!==e))}}notifyListeners(e){this.listeners.forEach((t=>t(this.state,e)))}reduce(t,r){const{type:n,payload:i}=r,s=new Map(t.filters);switch(n){case e.FilterActionType.ADD_FILTER:s.set(i.field,i);break;case e.FilterActionType.REMOVE_FILTER:s.delete(i.field);break;case e.FilterActionType.UPDATE_FILTER:s.set(i.field,{...s.get(i.field),...i});break;case e.FilterActionType.ENABLE_FILTER:s.set(i.field,{...s.get(i.field),enable:!0});break;case e.FilterActionType.DISABLE_FILTER:s.set(i.field,{...s.get(i.field),enable:!1});break;case e.FilterActionType.CLEAR_ALL_FILTERS:s.clear();break;case e.FilterActionType.APPLY_FILTERS:s.set(i.field,{...s.get(i.field),...i,enable:!0})}return{...t,filters:s}}applyFilters(){this.engine.applyFilter(this.state,this.table)}shouldApplyFilter(t){return[e.FilterActionType.REMOVE_FILTER,e.FilterActionType.ENABLE_FILTER,e.FilterActionType.DISABLE_FILTER,e.FilterActionType.CLEAR_ALL_FILTERS,e.FilterActionType.APPLY_FILTERS].includes(t.type)||t.payload.enable}}const Pi={display:"none",position:"absolute",backgroundColor:"white",border:"1px solid #ccc",boxShadow:"0 4px 8px rgba(0,0,0,0.15)",zIndex:"100"},ji={padding:"10px",display:"block"},Li={padding:"5px"},Di={width:"100%",padding:"8px 10px",border:"1px solid #ccc",borderRadius:"4px",fontSize:"14px",boxSizing:"border-box"},Bi={maxHeight:"200px",overflowY:"auto",marginTop:"10px"},Hi={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 5px"},zi={display:"flex",alignItems:"center",cursor:"pointer",flexGrow:"1",fontWeight:"normal"},Ui={marginRight:"10px"},Vi={color:"#888",fontSize:"12px"},$i={display:"flex",justifyContent:"space-around",borderBottom:"1px solid #e0e0e0"},Wi=e=>({backgroundColor:"transparent",border:"none",flex:"1",padding:"10px 15px",cursor:"pointer",fontSize:"14px",fontWeight:e?"bold":"normal",color:e?"#007bff":"#666",borderBottom:e?"3px solid #007bff":"2px solid transparent"}),qi={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 15px",borderTop:"1px solid #e0e0e0",backgroundColor:"#f8f9fa"},Ki=e=>({padding:"6px 12px",border:"1px solid #ccc",borderRadius:"4px",cursor:"pointer",marginLeft:"5px",backgroundColor:e?"#007bff":"white",color:e?"white":"#333",borderColor:e?"#007bff":"#ccc"}),Yi={color:"#007bff",textDecoration:"none"},Xi={marginBottom:"15px",padding:"10px"},Gi={display:"block",marginBottom:"8px",fontWeight:"bold"},Zi={width:"100%",padding:"8px",marginBottom:"15px",border:"1px solid #ccc",borderRadius:"4px",boxSizing:"border-box"},Ji={display:"flex",alignItems:"center",gap:"8px"},Qi={display:"none",padding:"0 5px"};function es(e,t){Object.entries(t).forEach((([t,r])=>{e.style[t]=r}))}function ts(e,t={},r=[]){const n=document.createElement(e);return Object.entries(t).forEach((([e,t])=>{n.setAttribute(e,t)})),r.forEach((e=>{"string"==typeof e?n.appendChild(document.createTextNode(e)):n.appendChild(e)})),n}class rs{table;filterStateManager;uniqueKeys=new Map;displayToRawValueMap=new Map;selectedField;valueFilterOptionList=new Map;filterByValuePanel;filterByValueSearchInput;selectAllCheckbox;filterItemsContainer;constructor(e,t){this.table=e,this.filterStateManager=t,this.filterStateManager.subscribe((e=>{const t=e.filters.get(this.selectedField);t&&"byValue"===t.type&&this.updateUI(t)}))}updateUI(e){this.syncCheckboxesWithFilterState(e),this.syncSelectAllWithFilterState(e)}setSelectedField(e){this.selectedField=e,this.collectUniqueColumnValues(e)}collectUniqueColumnValues(e){const t=this.filterStateManager.getFilterState(e)?.enable,r=new Map,n=new Map,i=new Map;let s=-1;for(let t=0;t<this.table.colCount;t++){for(let r=this.table.columnHeaderLevelCount;r<this.table.rowCount;r++)if(!this.table.internalProps.layoutMap.isHeader(t,r)){const n=this.table.internalProps.layoutMap.getBody(t,r);if(n&&n.field===e){s=t;break}}if(-1!==s)break}if(t){const t=this.table.internalProps.records,o=t.length;for(let a=0;a<o;a++){let o,l;if(-1!==s){const r=this.table.columnHeaderLevelCount+a;o=t[a][e];const n=this.table.internalProps.layoutMap.getBody(s,r);l=n&&"fieldFormat"in n&&n.fieldFormat&&"function"==typeof n.fieldFormat?n.fieldFormat({[e]:o}):o}null!=o&&(r.set(l,(r.get(l)||0)+1),n.set(o,l),i.set(l,o))}}else{const t=this.table.internalProps.dataSource.length;for(let o=0;o<t;o++){let t,a;if(-1!==s){const e=this.table.columnHeaderLevelCount+o;e<this.table.rowCount&&(t=this.table.getCellOriginValue(s,e),a=this.table.getCellValue(s,e))}else t=this.table.getFieldData(String(e),-1!==s?s:0,this.table.columnHeaderLevelCount+o),a=t;null!=t&&(r.set(a,(r.get(a)||0)+1),n.set(t,a),i.set(a,t))}}this.displayToRawValueMap.set(e,i);const o=Array.from(r.entries()).map((([e,t])=>({value:e,count:t,rawValue:i.get(e)})));this.uniqueKeys.set(e,o)}onValueSelect(t,r,n){const i=this.displayToRawValueMap.get(t),s=i?i.get(r):r,o=this.filterStateManager.getFilterState(t);if(o){const r=n?[...o.values||[],s]:(o.values||[]).filter((e=>e!==s));this.filterStateManager.dispatch({type:e.FilterActionType.UPDATE_FILTER,payload:{field:t,values:r}})}else this.filterStateManager.dispatch({type:e.FilterActionType.ADD_FILTER,payload:{field:t,type:"byValue",values:[s]}})}toggleSelectAll(t,r){const n=this.filterStateManager.getFilterState(t),i=r&&this.uniqueKeys.get(t)?.map((e=>e.rawValue))||[];if(n){const n=r?i:[];this.filterStateManager.dispatch({type:e.FilterActionType.UPDATE_FILTER,payload:{field:t,values:n}})}else this.filterStateManager.dispatch({type:e.FilterActionType.ADD_FILTER,payload:{field:t,type:"byValue",values:i,enable:!0}})}onSearch(e,t){const r=t.toUpperCase().split(" ").filter((e=>e)),n=this.valueFilterOptionList.get(e);for(const e of n){const t=e.id.toUpperCase()||"",n=r.some((e=>t.includes(e)));e.itemContainer.style.display=0===r.length||n?"flex":"none"}}initFilterStateFromTableData(t){const r=this.filterStateManager.getFilterState(t),n=new Set,i=this.displayToRawValueMap.get(t);let s=-1;for(let e=0;e<this.table.colCount;e++){for(let r=this.table.columnHeaderLevelCount;r<this.table.rowCount;r++)if(!this.table.internalProps.layoutMap.isHeader(e,r)){const n=this.table.internalProps.layoutMap.getBody(e,r);if(n&&n.field===t){s=e;break}}if(-1!==s)break}const o=this.table.internalProps.dataSource.length;for(let e=0;e<o;e++){let r,o;if(-1!==s){const t=this.table.columnHeaderLevelCount+e;t<this.table.rowCount&&(r=this.table.getCellValue(s,t),o=i?i.get(r):r)}else r=this.table.getFieldData(String(t),-1!==s?s:0,this.table.columnHeaderLevelCount+e),o=i?i.get(r):r;null!=o&&n.add(o)}(!r||!function(e,t){if(!p(e)||!p(t))return!1;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}(r.values,Array.from(n)))&&(r?this.filterStateManager.dispatch({type:e.FilterActionType.UPDATE_FILTER,payload:{field:t,type:"byValue",values:Array.from(n)}}):this.filterStateManager.dispatch({type:e.FilterActionType.ADD_FILTER,payload:{field:t,type:"byValue",values:Array.from(n)}}))}syncCheckboxesWithFilterState(e){if(!e)return;const t=e.values||[],r=this.displayToRawValueMap.get(e.field),n=this.valueFilterOptionList.get(e.field);n?.forEach((n=>{const i=n.originalValue,s=r?r.get(i):i;n.checkbox.checked=t.some((e=>e===s));const o=this.uniqueKeys.get(e.field)?.find((e=>String(e.value)===n.id))?.count||0;n.countSpan.textContent=String(o),n.itemContainer.style.display=0===o?"none":"flex"}))}syncSelectAllWithFilterState(e){if(!e||!e.values)return this.selectAllCheckbox.checked=!1,void(this.selectAllCheckbox.indeterminate=!1);const t=this.uniqueKeys.get(e.field)?.length||0;0===t||0===e.values.length?(this.selectAllCheckbox.checked=!1,this.selectAllCheckbox.indeterminate=!1):e.values.length===t?(this.selectAllCheckbox.checked=!0,this.selectAllCheckbox.indeterminate=!1):(this.selectAllCheckbox.checked=!1,this.selectAllCheckbox.indeterminate=!0)}applyFilter(t=this.selectedField){const r=this.filterStateManager.getFilterState(t)?.values||[];r.length>0&&r.length<this.uniqueKeys.get(t)?.length?this.filterStateManager.dispatch({type:e.FilterActionType.APPLY_FILTERS,payload:{field:t,type:"byValue",values:r,enable:!0}}):this.filterStateManager.dispatch({type:e.FilterActionType.REMOVE_FILTER,payload:{field:t}})}clearFilter(t){this.filterStateManager.dispatch({type:e.FilterActionType.REMOVE_FILTER,payload:{field:t}}),this.hide()}render(e){this.filterByValuePanel=document.createElement("div"),es(this.filterByValuePanel,ji);const t=document.createElement("div");es(t,Li),this.filterByValueSearchInput=document.createElement("input"),this.filterByValueSearchInput.type="text",this.filterByValueSearchInput.placeholder="可使用空格分隔多个关键词",es(this.filterByValueSearchInput,Di),t.appendChild(this.filterByValueSearchInput);const r=document.createElement("div");es(r,Bi);const n=document.createElement("div");es(n,Hi);const i=document.createElement("label");es(i,zi),this.selectAllCheckbox=document.createElement("input"),this.selectAllCheckbox.type="checkbox",this.selectAllCheckbox.checked=!0,es(this.selectAllCheckbox,Ui),i.append(this.selectAllCheckbox," 全选"),n.appendChild(i),this.filterItemsContainer=document.createElement("div"),r.append(n,this.filterItemsContainer),this.filterByValuePanel.append(t,r),e.appendChild(this.filterByValuePanel),this.bindEventForFilterByValue()}renderFilterOptions(e){this.filterItemsContainer.innerHTML="",this.valueFilterOptionList.delete(e),this.valueFilterOptionList.set(e,[]);const t=this.filterStateManager.getFilterState(e)?.values||[],r=new Set(t),n=[];this.uniqueKeys.get(e)?.forEach((({value:e,count:t,rawValue:i})=>{const s=document.createElement("div");es(s,Hi);const o=document.createElement("label");es(o,zi);const a=document.createElement("input");a.type="checkbox",a.value=String(e),a.checked=r.has(i),es(a,Ui);const l=document.createElement("span");l.textContent=String(t),es(l,Vi),o.append(a,` ${e}`),s.append(o,l),this.filterItemsContainer.appendChild(s);const h={id:String(e),originalValue:e,itemContainer:s,checkbox:a,countSpan:l};n.push(h)})),this.valueFilterOptionList.set(e,n)}bindEventForFilterByValue(){this.filterByValuePanel.addEventListener("keyup",(e=>{const t=e.target;if(t instanceof HTMLInputElement&&"text"===t.type){const e=t.value;this.onSearch(this.selectedField,e)}})),this.filterByValuePanel.addEventListener("change",(e=>{const t=e.target;if(t instanceof HTMLInputElement&&"checkbox"===t.type)if(t===this.selectAllCheckbox)this.toggleSelectAll(this.selectedField,this.selectAllCheckbox.checked);else{const e=t,r=e.checked,n=this.valueFilterOptionList.get(this.selectedField)?.find((t=>t.id===e.value))?.originalValue;this.onValueSelect(this.selectedField,n,r)}}))}show(){this.initFilterStateFromTableData(this.selectedField),this.renderFilterOptions(this.selectedField),this.filterByValuePanel.style.display="block"}hide(){this.filterByValuePanel.style.display="none"}clearSearchInputValue(){this.filterByValueSearchInput.value=""}}class ns{table;filterStateManager;filterByConditionPanel;selectedField;operatorSelect;valueInput;valueInputMax;categorySelect;currentCategory=e.FilterOperatorCategory.ALL;operators=[{value:"equals",label:"等于",category:e.FilterOperatorCategory.ALL},{value:"notEquals",label:"不等于",category:e.FilterOperatorCategory.ALL},{value:"equals",label:"等于",category:e.FilterOperatorCategory.NUMBER},{value:"notEquals",label:"不等于",category:e.FilterOperatorCategory.NUMBER},{value:"greaterThan",label:"大于",category:e.FilterOperatorCategory.NUMBER},{value:"lessThan",label:"小于",category:e.FilterOperatorCategory.NUMBER},{value:"greaterThanOrEqual",label:"大于等于",category:e.FilterOperatorCategory.NUMBER},{value:"lessThanOrEqual",label:"小于等于",category:e.FilterOperatorCategory.NUMBER},{value:"between",label:"介于",category:e.FilterOperatorCategory.NUMBER},{value:"notBetween",label:"不介于",category:e.FilterOperatorCategory.NUMBER},{value:"equals",label:"等于",category:e.FilterOperatorCategory.TEXT},{value:"notEquals",label:"不等于",category:e.FilterOperatorCategory.TEXT},{value:"contains",label:"包含",category:e.FilterOperatorCategory.TEXT},{value:"notContains",label:"不包含",category:e.FilterOperatorCategory.TEXT},{value:"startsWith",label:"开头是",category:e.FilterOperatorCategory.TEXT},{value:"notStartsWith",label:"开头不是",category:e.FilterOperatorCategory.TEXT},{value:"endsWith",label:"结尾是",category:e.FilterOperatorCategory.TEXT},{value:"notEndsWith",label:"结尾不是",category:e.FilterOperatorCategory.TEXT},{value:"equals",label:"等于",category:e.FilterOperatorCategory.COLOR},{value:"notEquals",label:"不等于",category:e.FilterOperatorCategory.COLOR},{value:"isChecked",label:"已选中",category:e.FilterOperatorCategory.CHECKBOX},{value:"isUnchecked",label:"未选中",category:e.FilterOperatorCategory.CHECKBOX},{value:"isChecked",label:"已选中",category:e.FilterOperatorCategory.RADIO},{value:"isUnchecked",label:"未选中",category:e.FilterOperatorCategory.RADIO}];categories=[{value:e.FilterOperatorCategory.ALL,label:"全部"},{value:e.FilterOperatorCategory.TEXT,label:"文本"},{value:e.FilterOperatorCategory.NUMBER,label:"数值"},{value:e.FilterOperatorCategory.COLOR,label:"颜色"},{value:e.FilterOperatorCategory.CHECKBOX,label:"复选框"},{value:e.FilterOperatorCategory.RADIO,label:"单选框"}];constructor(e,t){this.table=e,this.filterStateManager=t}setSelectedField(e){this.selectedField=e,this.updateOperatorOptions(),this.loadCurrentFilterState()}updateOperatorOptions(){if(!this.operatorSelect)return;let t;if(this.operatorSelect.innerHTML="",this.currentCategory===e.FilterOperatorCategory.ALL){const e=new Map;this.operators.forEach((t=>{e.has(t.value)||e.set(t.value,t)})),t=Array.from(e.values())}else t=this.operators.filter((e=>e.category===this.currentCategory));t.forEach((e=>{const t=document.createElement("option");t.value=e.value,t.textContent=e.label,this.operatorSelect.appendChild(t)}))}handleCategoryChange(){this.categorySelect&&(this.currentCategory=this.categorySelect.value,this.updateOperatorOptions(),this.syncUIState())}loadCurrentFilterState(){const e=this.filterStateManager.getFilterState(this.selectedField);e&&"byCondition"===e.type?(e.operator&&this.operatorSelect&&(this.operatorSelect.value=e.operator),void 0!==e.condition&&this.valueInput&&(Array.isArray(e.condition)?(this.valueInput.value=String(e.condition[0]),this.valueInputMax&&(this.valueInputMax.value=String(e.condition[1]))):(this.valueInput.value=String(e.condition),this.valueInputMax&&(this.valueInputMax.value=""))),this.syncUIState()):this.reset()}reset(){this.operatorSelect&&(this.operatorSelect.selectedIndex=0),this.valueInput&&(this.valueInput.value="",this.valueInput.placeholder="请输入筛选值"),this.valueInputMax&&(this.valueInputMax.value=""),this.currentCategory=e.FilterOperatorCategory.ALL,this.categorySelect&&(this.categorySelect.value=e.FilterOperatorCategory.ALL),this.updateOperatorOptions(),this.syncUIState()}syncUIState(){if(!this.operatorSelect||!this.valueInput)return;const e=this.operatorSelect.value,t=this.valueInput.nextElementSibling;this.isRangeOperator(e)?(this.valueInput.placeholder="最小值",this.valueInputMax&&(this.valueInputMax.style.display="inline-block"),t&&(t.style.display="inline-block")):(this.valueInput.placeholder="请输入筛选值",this.valueInputMax&&(this.valueInputMax.style.display="none"),t&&(t.style.display="none"))}isBooleanOperator(e){return["isChecked","isUnchecked"].includes(e)}isRangeOperator(e){return"between"===e||"notBetween"===e}applyFilter(t=this.selectedField){if(!this.operatorSelect||!this.valueInput)return;const r=this.operatorSelect?.value;let n=this.valueInput?.value;if(this.currentCategory!==e.FilterOperatorCategory.NUMBER||(n=parseFloat(n),!isNaN(n))){if(this.isRangeOperator(r)){const t=n;let r=this.valueInputMax.value.trim();if(this.currentCategory===e.FilterOperatorCategory.NUMBER){const e=parseFloat(r);if(isNaN(e))return;r=e}n=[t,r]}n||!1===n||0===n||this.isBooleanOperator(r)?(this.filterStateManager.dispatch({type:e.FilterActionType.APPLY_FILTERS,payload:{field:t,type:"byCondition",operator:r,condition:n,enable:!0}}),this.hide()):this.clearFilter(t)}}clearFilter(t){this.filterStateManager.dispatch({type:e.FilterActionType.REMOVE_FILTER,payload:{field:t}}),this.hide()}render(e){this.filterByConditionPanel=document.createElement("div"),es(this.filterByConditionPanel,ji);const t=document.createElement("div");es(t,Xi);const r=ts("label",{},["筛选类型:"]);es(r,Gi),this.categorySelect=ts("select"),es(this.categorySelect,Zi),this.categories.forEach((e=>{const t=document.createElement("option");t.value=e.value,t.textContent=e.label,this.categorySelect.appendChild(t)}));const n=ts("label",{},["筛选条件:"]);es(n,Gi),this.operatorSelect=ts("select"),es(this.operatorSelect,Zi);const i=ts("label",{},["筛选值:"]);es(i,Gi);const s=ts("div");es(s,Ji),this.valueInput=ts("input",{type:"text",placeholder:"请输入筛选值"}),es(this.valueInput,Di);const o=ts("span",{},["和"]);es(o,Qi),o.style.display="none",this.valueInputMax=ts("input",{type:"text",placeholder:"最大值"}),es(this.valueInputMax,Di),this.valueInputMax.style.display="none",s.appendChild(this.valueInput),s.appendChild(o),s.appendChild(this.valueInputMax),t.appendChild(r),t.appendChild(this.categorySelect),t.appendChild(n),t.appendChild(this.operatorSelect),t.appendChild(i),t.appendChild(s),this.filterByConditionPanel.appendChild(t),e.appendChild(this.filterByConditionPanel),this.hide(),this.updateOperatorOptions(),this.bindEvents()}bindEvents(){this.valueInput.addEventListener("keypress",(e=>{"Enter"===e.key&&this.applyFilter()})),this.valueInputMax.addEventListener("keypress",(e=>{"Enter"===e.key&&this.applyFilter()})),this.categorySelect.addEventListener("change",(()=>{this.handleCategoryChange()})),this.operatorSelect.addEventListener("change",(()=>{const e=this.operatorSelect.value,t=this.valueInput.nextElementSibling;this.isRangeOperator(e)?(this.valueInput.placeholder="最小值",this.valueInputMax.style.display="inline-block",t.style.display="inline-block"):(this.valueInput.placeholder="请输入筛选值",this.valueInputMax.style.display="none",t.style.display="none")}))}show(){this.filterByConditionPanel&&(this.filterByConditionPanel.style.display="block",this.loadCurrentFilterState())}hide(){this.filterByConditionPanel&&(this.filterByConditionPanel.style.display="none")}}class is{table;filterStateManager;valueFilter=null;conditionFilter=null;activeTab="byValue";isVisible=!1;selectedField=null;filterModes=[];filterMenu;filterMenuWidth;currentCol;currentRow;filterTabByValue;filterTabByCondition;clearFilterOptionLink;cancelFilterButton;applyFilterButton;constructor(e,t){this.table=e,this.filterStateManager=t,this.valueFilter=new rs(this.table,this.filterStateManager),this.conditionFilter=new ns(this.table,this.filterStateManager),this.filterMenuWidth=300}onTabSwitch(e){this.activeTab=e,"byValue"===e?(this.valueFilter.show(),this.conditionFilter.hide()):(this.conditionFilter.show(),this.valueFilter.hide());const t="byValue"===e;es(this.filterTabByValue,Wi(t)),es(this.filterTabByCondition,Wi(!t))}updateSelectedField(e){this.selectedField=e,this.valueFilter&&this.valueFilter.setSelectedField(e),this.conditionFilter&&this.conditionFilter.setSelectedField(e)}applyFilter(e){"byValue"===this.activeTab?this.valueFilter.applyFilter(e):"byCondition"===this.activeTab&&this.conditionFilter.applyFilter(e),this.hide()}clearFilter(e){this.valueFilter&&this.valueFilter.clearFilter(e),this.conditionFilter&&this.conditionFilter.clearFilter(e),this.hide()}render(e){this.filterMenu=document.createElement("div"),es(this.filterMenu,Pi),this.filterMenu.style.width=`${this.filterMenuWidth}px`;const t=document.createElement("div");es(t,$i),this.filterTabByValue=document.createElement("button"),this.filterTabByValue.innerText="按值筛选",es(this.filterTabByValue,Wi(!0)),this.filterTabByCondition=document.createElement("button"),this.filterTabByCondition.innerText="按条件筛选",es(this.filterTabByCondition,Wi(!1)),t.append(this.filterTabByValue,this.filterTabByCondition);const r=document.createElement("div");es(r,qi),this.clearFilterOptionLink=document.createElement("a"),this.clearFilterOptionLink.href="#",this.clearFilterOptionLink.innerText="清除筛选",es(this.clearFilterOptionLink,Yi);const n=document.createElement("div");this.cancelFilterButton=document.createElement("button"),this.cancelFilterButton.innerText="取消",es(this.cancelFilterButton,Ki(!1)),this.applyFilterButton=document.createElement("button"),this.applyFilterButton.innerText="确认",es(this.applyFilterButton,Ki(!0)),n.append(this.cancelFilterButton,this.applyFilterButton),r.append(this.clearFilterOptionLink,n),this.filterMenu.append(t),this.valueFilter.render(this.filterMenu),this.conditionFilter.render(this.filterMenu),this.filterMenu.append(r),e.appendChild(this.filterMenu),this.attachEventListeners()}attachEventListeners(){this.filterTabByValue.addEventListener("click",(()=>{this.onTabSwitch("byValue")})),this.filterTabByCondition.addEventListener("click",(()=>{this.onTabSwitch("byCondition")})),this.cancelFilterButton.addEventListener("click",(()=>this.hide())),this.clearFilterOptionLink.addEventListener("click",(e=>{e.preventDefault(),this.clearFilter(this.selectedField)})),this.applyFilterButton.addEventListener("click",(()=>{this.applyFilter(this.selectedField)})),document.addEventListener("click",(()=>{this.isVisible&&this.hide()})),this.filterMenu.addEventListener("click",(e=>{e.stopPropagation()}))}adjustMenuPosition(e,t,r,n){if("number"==typeof r&&"number"==typeof n)return this.filterMenu.style.display=this.isVisible?"block":"none",this.filterMenu.style.left=`${r}px`,void(this.filterMenu.style.top=`${n}px`);const i="number"==typeof e?e:this.currentCol,s="number"==typeof t?t:this.currentRow;if("number"!=typeof i||"number"!=typeof s)return;this.currentCol=i,this.currentRow=s;let o=0,a=0;const l=this.table.canvas.getBoundingClientRect(),h=this.table.getCellRelativeRect(i,s);h.right<this.filterMenuWidth?(o=h.left+l.left,a=h.bottom+l.top):(o=h.right+l.left-this.filterMenuWidth,a=h.bottom+l.top),this.filterMenu.style.display=this.isVisible?"block":"none",this.filterMenu.style.left=`${o}px`,this.filterMenu.style.top=`${a}px`}show(e,t,r){this.valueFilter.clearSearchInputValue(),this.filterModes=r,this.filterModes.includes("byValue")?this.filterModes.includes("byCondition")||(this.filterTabByCondition.style.display="none",this.onTabSwitch("byValue")):(this.filterTabByValue.style.display="none",this.onTabSwitch("byCondition")),this.adjustMenuPosition(e,t),this.filterMenu.style.display="block";const n=this.table.internalProps.layoutMap.getHeaderField(e,t);this.updateSelectedField(n);const i=this.filterStateManager.getFilterState(n);i&&"byCondition"===i.type?this.onTabSwitch("byCondition"):this.onTabSwitch("byValue"),setTimeout((()=>{this.isVisible=!0}),0)}hide(){this.filterMenu.style.display="none",this.isVisible=!1}}function ss(e,t){let r="";for(let t=e+1;t>0;t=Math.floor((t-1)/26))r=String.fromCharCode((t-1)%26+65)+r;return r+(t+1)}function os(e){if(!e)return[0,0,0];if(e.startsWith("#")){let t=e.substring(1);3===t.length&&(t=t.replace(/(.)/g,"$1$1"));return[parseInt(t.substring(0,2),16),parseInt(t.substring(2,4),16),parseInt(t.substring(4,6),16)]}if(e.startsWith("rgb(")){return e.substring(4,e.length-1).split(",").map(Number)}if(e.startsWith("rgba(")){return e.substring(5,e.length-1).split(",").map(Number)}if(y(hs[e]))return[(t=hs[e])>>16,t>>8&255,255&t,1];if(y(ls[e]))return function(e){return[e>>>24,e>>>16&255,e>>>8&255,255&e]}(ls[e]);var t;throw new Error("Unsupported color format")}function as(e){if(3===e.length&&e.push(1),4!==e.length)throw new Error("Invalid RGBA array");const[t,r,n,i]=e.map(Math.round);return`${Math.round(255*i).toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}const ls={transparent:4294967040},hs={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function cs(e,t){return{name:ds(e.fontFamily)||"Arial",size:e.fontSize||10,bold:us(e.fontWeight),italic:"italic"===e.fontStyle,color:gs("link"===t?e._linkColor:e.color),underline:e.underline}}function us(e){return"number"==typeof e?e>=600:Number(e)>=600||"bold"===e}function ds(e){return e.split(",").map((e=>e.trim()))[0]}function fs(e){return{type:"pattern",pattern:"solid",fgColor:gs(e.bgColor)}}function ps(e){const{borderColor:t,borderLineWidth:r,borderLineDash:n,_strokeArrayWidth:i,_strokeArrayColor:s}=e;if(s||i){const e={};return s&&!s[0]||i&&!i[0]||(e.top={style:ms(i?.[0]??r,n),color:gs(s?.[0]??t)}),s&&!s[1]||i&&!i[1]||(e.right={style:ms(i?.[1]??r,n),color:gs(s?.[1]??t)}),s&&!s[2]||i&&!i[2]||(e.bottom={style:ms(i?.[2]??r,n),color:gs(s?.[2]??t)}),s&&!s[3]||i&&!i[3]||(e.left={style:ms(i?.[3]??r,n),color:gs(s?.[3]??t)}),e}if(0===r)return{};const o={style:ms(r,n),color:gs(t)};return{top:o,left:o,bottom:o,right:o}}function ms(e,t){return t&&t.length?e<=2?"dashed":"mediumDashed":e<=.5?"hair":e<=1?"thin":e<=2?"medium":"thick"}function bs(e,t){return{horizontal:e.textAlign||"left",vertical:e.textBaseline||"middle",wrapText:e.autoWrapText||!1,indent:t||0}}function gs(e){return{argb:as(os(e))}}function ys(e,t,r){let n=0;const i=r.internalProps.layoutMap;if(i.isHeader(e,t)){const r=i.getHeader(e,t);d(r?.hierarchyLevel)&&(n=(r.hierarchyLevel??0)*(i.rowHierarchyIndent??0))}else{const s=r.getBodyColumnDefine(e,t);if(s?.tree){const s=r.dataSource.getIndexKey(r.getRecordShowIndexByCell(e,t));n=Array.isArray(s)&&"none"!==r.getHierarchyState(e,t)?(s.length-1)*(i.hierarchyIndent??0):0}}return n}function vs(e,t){const r=v(e.pagination),n=e.isPivotTable(),i=e.internalProps.layoutMap;let s=e.rowCount-1;return{reset:()=>{n&&t&&r&&(e.internalProps.layoutMap.setPagination(r),e.refreshRowColCount())},handleRowCount:()=>(t&&r&&(n?(e.internalProps.layoutMap.setPagination(void 0),e.refreshRowColCount(),s=e.rowCount-1):s=e.recordsCount*i.bodyRowSpanCount+i.headerLevelCount),s)}}function ws(e){return new Promise((t=>{requestIdleCallback((e=>{t(e)}),e)}))}async function _s(e,t,r=!1){const n=new Ai.Workbook,i=n.addWorksheet("sheet1"),s=!!t?.exportAllData,{handleRowCount:o,reset:a}=vs(e,s),l=o(),h=e.colCount-1;i.properties.defaultRowHeight=40;const c=[],u=[],d=new Set;let f=0;function p(s){return new Promise((async o=>{for(;f<=l&&(!r||s?.timeRemaining()>0);){const r=Math.min(f+100-1,l);for(let s=0;s<=h;s++){const o=e.getColWidth(s);void 0===c[s]&&(c[s]={width:o/6});for(let o=f;o<=r;o++){if(0===s){const t=e.getRowHeight(o);i.getRow(o+1).height=t}await xs(s,o,e,i,n,t);const r=e.getCellRange(s,o);if(r.start.col!==r.end.col||r.start.row!==r.end.row){const e=`${r.start.col},${r.start.row}:${r.end.col},${r.end.row}`;d.has(e)||(d.add(e),u.push(r))}}}f=r+1}if(f>l)o();else{let e;r&&(e=await ws()),await p(e),o()}}))}await new Promise((async e=>{let t;r&&(t=await ws()),await p(t),e()})),i.columns=c,u.forEach((e=>{i.mergeCells(e.start.row+1,e.start.col+1,e.end.row+1,e.end.col+1)}));const m=[];e.frozenRowCount>0&&m.push({state:"frozen",ySplit:e.frozenRowCount,topLeftCell:ss(0,e.frozenRowCount)}),e.frozenColCount>0&&m.push({state:"frozen",xSplit:e.frozenColCount,topLeftCell:ss(e.frozenColCount,0)}),i.views=m,t?.excelJSWorksheetCallback&&t.excelJSWorksheetCallback(i);const b=await n.xlsx.writeBuffer();return a(),b}async function xs(e,t,n,i,s,o){const{layoutMap:a}=n.internalProps,l=n.getCellType(e,t),h=n.getCellRawRecord(e,t);let c=(h&&h.vtableMergeName)??n.getCellValue(e,t,!1);var d;!(d=c)||"object"!=typeof d&&"function"!=typeof d||"function"!=typeof d.then||(c=await c);const f=n.getCellStyle(e,t),m=n.getCellLocation(e,t),b="body"!==m?n.getHeaderDefine(e,t):n.getBodyColumnDefine(e,t);let g,y,v,w;if(("body"!==m||(b?.dragOrder||!!b?.icon||!!b?.tree))&&(g=n.getCellIcons(e,t)),"body"!==m?(y=b?.headerCustomRender,v=b?.headerCustomLayout):(y=b?.customRender||n.customRender,v=b?.customLayout),o?.formatExportOutput){const r={cellType:l,cellValue:c,table:n,col:e,row:t},s=o.formatExportOutput(r);if(void 0!==s){let r=i.getCell(ss(e,t));r.value=s,r.font=cs(f,l),r.fill=fs(f),r.border=ps(f);const a=ys(e,t,n);if(r.alignment=bs(f,Math.ceil(a/r.font.size)),r&&o?.formatExcelJSCell){const i=o.formatExcelJSCell({cellType:l,cellValue:c,table:n,col:e,row:t},r);i&&(r=i)}return r}}if("image"===l||"video"===l||"progressbar"===l||"sparkline"===l||a.isAxisCell(e,t)||!o?.ignoreIcon&&p(g)&&g.length||y||v)if(Es(l,a.isAxisCell(e,t),!!y||!!v,!(o?.ignoreIcon||!p(g)||!g.length),o)){const r=Cs(e,t,n),o=s.addImage({base64:r,extension:"png"});i.addImage(o,{tl:{col:e+1/80,row:t+1/120},br:{col:e+1,row:t+1},editAs:"oneCell"})}else w=i.getCell(ss(e,t));else if("text"===l||"link"===l){let r;if(w=i.getCell(ss(e,t)),"link"===l){const i=b.templateLink;if(i){const s=n.getCellOriginRecord(e,t);if(s&&s.vtableMerge);else{const o=n.getCellOriginValue(e,t),a=Object.assign({__value:c,__dataValue:o},s);if(u(i))r=i(a,e,t,n);else{const e=/\{\s*(\S+?)\s*\}/g;r=i.replace(e,((e,t)=>a[t]))}}}}w.value=function(e,t,r){if("link"===t)return{text:e,hyperlink:r||e,tooltip:e};return e}(c,l,r),w.font=cs(f,l),w.fill=fs(f),w.border=ps(f);const s=ys(e,t,n);w.alignment=bs(f,Math.ceil(s/w.font.size))}else if("chart"===l)if(Es("chart",!1,!1,!1,o)){const o=n.scenegraph.getCell(e,t);r.renderChart(o.firstChild);const a=Cs(e,t,n),l=s.addImage({base64:a,extension:"png"});i.addImage(l,{tl:{col:e+1/80,row:t+1/120},br:{col:e+1,row:t+1},editAs:"oneCell"}),n.scenegraph.updateNextFrame()}else w=i.getCell(ss(e,t));if(w&&o?.formatExcelJSCell){const r=o.formatExcelJSCell({cellType:l,cellValue:c,table:n,col:e,row:t},w);r&&(w=r)}return w}function Cs(e,t,n){let i=n.scenegraph.getCell(e,t),s=!1;"empty"===i.role&&(i=r.updateCell(e,t,n,!0),i.setStage(n.scenegraph.stage),s=!0,i.stage.dirtyBounds.set(-1/0,-1/0,1/0,1/0));const o=i.attribute.stroke;i.attribute.stroke=!1;const a=r.graphicUtil.drawGraphicToCanvas(i,n.scenegraph.stage);return i.attribute.stroke=o,s&&i.parent?.removeChild(i),a.toDataURL()}function Es(e,t,r,n,i){return!i?.skipImageExportCellType||("image"===e||"video"===e||"progressbar"===e||"sparkline"===e||"chart"===e?!i.skipImageExportCellType.includes(e):t?!i.skipImageExportCellType.includes("chart"):r?!i.skipImageExportCellType.includes("custom"):!n||!i.skipImageExportCellType.includes("textWithIcon"))}function Ss(e,t){const r=!!t?.exportAllData,{handleRowCount:n,reset:i}=vs(e,r),s=n(),o=e.colCount-1;let a="";for(let r=0;r<=s;r++){for(let n=0;n<=o;n++){const i=Ts(n,r,e,t);if("undefined"!=typeof Promise&&i instanceof Promise);else{const e=`${void 0===i?"":i}`;/^\[object .*\]$/.exec(e)||(a+=e)}n!==o&&(a+=",")}a+="\r\n"}return i(),a}function Ts(e,t,r,n){const i=r.getCellRawRecord(e,t),s=(i&&i.vtableMergeName)??r.getCellValue(e,t,!1);if(n?.formatExportOutput){const i={cellType:r.getCellType(e,t),cellValue:s,table:r,col:e,row:t},o=n.formatExportOutput(i);if(void 0!==o)return"string"==typeof o?'"'+o+'"':o}const o=r.getCellRange(e,t),a=o.start.col,l=o.start.row;if(a!==e||l!==t)return"";let h=s;return n?.escape?h=function(e){if("string"!=typeof e)return e;let t=e.replace(/"/g,'""');/[,"\r\n]/.test(t)&&(t=`"${t}"`);return t}(h):"string"==typeof h&&(h='"'+h+'"'),h}var Rs={exports:{}};!function(e,t){!function(){function t(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}function r(e,t,r){var n=new XMLHttpRequest;n.open("GET",e),n.responseType="blob",n.onload=function(){l(n.response,t,r)},n.onerror=function(){},n.send()}function n(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function i(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(r){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var s="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof a&&a.global===a?a:void 0,o=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=s.saveAs||("object"!=typeof window||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!o?function(e,t,o){var a=s.URL||s.webkitURL,l=document.createElement("a");t=t||e.name||"download",l.download=t,l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?i(l):n(l.href)?r(e,t,o):i(l,l.target="_blank")):(l.href=a.createObjectURL(e),setTimeout((function(){a.revokeObjectURL(l.href)}),4e4),setTimeout((function(){i(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,s,o){if(s=s||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(t(e,o),s);else if(n(e))r(e,s,o);else{var a=document.createElement("a");a.href=e,a.target="_blank",setTimeout((function(){i(a)}))}}:function(e,t,n,i){if((i=i||open("","_blank"))&&(i.document.title=i.document.body.innerText="downloading..."),"string"==typeof e)return r(e,t,n);var a="application/octet-stream"===e.type,l=/constructor/i.test(s.HTMLElement)||s.safari,h=/CriOS\/[\d]+/.test(navigator.userAgent);if((h||a&&l||o)&&"undefined"!=typeof FileReader){var c=new FileReader;c.onloadend=function(){var e=c.result;e=h?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),i?i.location.href=e:location=e,i=null},c.readAsDataURL(e)}else{var u=s.URL||s.webkitURL,d=u.createObjectURL(e);i?i.location=d:location.href=d,i=null,setTimeout((function(){u.revokeObjectURL(d)}),4e4)}});s.saveAs=l.saveAs=l,e.exports=l}()}(Rs);var ks,Ms,As,Os,Is=Rs.exports;!function(e){e.UP="top",e.RIGHT="right",e.DOWN="bottom",e.LEFT="left"}(ks||(ks={})),function(e){e.COPY="copy",e.SERIES="series"}(Ms||(Ms={})),function(e){e[e.STRING=1]="STRING",e[e.NUMBER=2]="NUMBER",e[e.BOOLEAN=3]="BOOLEAN",e[e.FORCE_STRING=4]="FORCE_STRING"}(As||(As={})),function(e){e.NUMBER="number",e.DATE="date",e.EXTEND_NUMBER="extendNumber",e.CHN_NUMBER="chnNumber",e.CHN_WEEK2="chnWeek2",e.CHN_WEEK3="chnWeek3",e.LOOP_SERIES="loopSeries",e.FORMULA="formula",e.OTHER="other"}(Os||(Os={}));var Ns=function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e},Fs=Qe,Ps=function(){try{var e=Fs(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();var js=function(e,t,r){"__proto__"==t&&Ps?Ps(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r},Ls=js,Ds=Y,Bs=Object.prototype.hasOwnProperty;var Hs=function(e,t,r){var n=e[t];Bs.call(e,t)&&Ds(n,r)&&(void 0!==r||t in e)||Ls(e,t,r)},zs=Hs,Us=js;var Vs=function(e,t,r,n){var i=!r;r||(r={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=n?n(r[a],e[a],a,r,e):void 0;void 0===l&&(l=e[a]),i?Us(r,a,l):zs(r,a,l)}return r},$s=Vs,Ws=mn;var qs=function(e,t){return e&&$s(t,Ws(t),e)};var Ks=Ae,Ys=rn,Xs=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t},Gs=Object.prototype.hasOwnProperty;var Zs=en,Js=function(e){if(!Ks(e))return Xs(e);var t=Ys(e),r=[];for(var n in e)("constructor"!=n||!t&&Gs.call(e,n))&&r.push(n);return r},Qs=un;var eo=function(e){return Qs(e)?Zs(e,!0):Js(e)},to=Vs,ro=eo;var no=function(e,t){return e&&to(t,ro(t),e)},io={exports:{}};!function(e,t){var r=ge,n=t&&!t.nodeType&&t,i=n&&e&&!e.nodeType&&e,s=i&&i.exports===n?r.Buffer:void 0,o=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var r=e.length,n=o?o(r):new e.constructor(r);return e.copy(n),n}}(io,io.exports);var so=io.exports;var oo=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t},ao=Vs,lo=gr;var ho=function(e,t){return ao(e,lo(e),t)},co=nn(Object.getPrototypeOf,Object),uo=ar,fo=co,po=gr,mo=dr,bo=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)uo(t,po(e)),e=fo(e);return t}:mo,go=Vs,yo=bo;var vo=function(e,t){return go(e,yo(e),t)},wo=ur,_o=bo,xo=eo;var Co=function(e){return wo(e,xo,_o)},Eo=Object.prototype.hasOwnProperty;var So=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&Eo.call(e,"index")&&(r.index=e.index,r.input=e.input),r},To=Jt;var Ro=function(e){var t=new e.constructor(e.byteLength);return new To(t).set(new To(e)),t},ko=Ro;var Mo=function(e,t){var r=t?ko(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)},Ao=/\w*$/;var Oo=function(e){var t=new e.constructor(e.source,Ao.exec(e));return t.lastIndex=e.lastIndex,t},Io=ye?ye.prototype:void 0,No=Io?Io.valueOf:void 0;var Fo=Ro;var Po=Ro,jo=Mo,Lo=Oo,Do=function(e){return No?Object(No.call(e)):{}},Bo=function(e,t){var r=t?Fo(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)};var Ho=function(e,t,r){var n=e.constructor;switch(t){case"[object ArrayBuffer]":return Po(e);case"[object Boolean]":case"[object Date]":return new n(+e);case"[object DataView]":return jo(e,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return Bo(e,r);case"[object Map]":case"[object Set]":return new n;case"[object Number]":case"[object String]":return new n(e);case"[object RegExp]":return Lo(e);case"[object Symbol]":return Do(e)}},zo=Ae,Uo=Object.create,Vo=function(){function e(){}return function(t){if(!zo(t))return{};if(Uo)return Uo(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}(),$o=co,Wo=rn;var qo=function(e){return"function"!=typeof e.constructor||Wo(e)?{}:Vo($o(e))},Ko=zn,Yo=vr;var Xo=function(e){return Yo(e)&&"[object Map]"==Ko(e)},Go=Hr,Zo=Ur&&Ur.isMap,Jo=Zo?Go(Zo):Xo,Qo=zn,ea=vr;var ta=function(e){return ea(e)&&"[object Set]"==Qo(e)},ra=Hr,na=Ur&&Ur.isSet,ia=na?ra(na):ta,sa=Vt,oa=Ns,aa=Hs,la=qs,ha=no,ca=so,ua=oo,da=ho,fa=vo,pa=vn,ma=Co,ba=zn,ga=So,ya=Ho,va=qo,wa=lr,_a=Or,xa=Jo,Ca=Ae,Ea=ia,Sa=mn,Ta=eo,Ra="[object Arguments]",ka="[object Function]",Ma="[object Object]",Aa={};Aa[Ra]=Aa["[object Array]"]=Aa["[object ArrayBuffer]"]=Aa["[object DataView]"]=Aa["[object Boolean]"]=Aa["[object Date]"]=Aa["[object Float32Array]"]=Aa["[object Float64Array]"]=Aa["[object Int8Array]"]=Aa["[object Int16Array]"]=Aa["[object Int32Array]"]=Aa["[object Map]"]=Aa["[object Number]"]=Aa[Ma]=Aa["[object RegExp]"]=Aa["[object Set]"]=Aa["[object String]"]=Aa["[object Symbol]"]=Aa["[object Uint8Array]"]=Aa["[object Uint8ClampedArray]"]=Aa["[object Uint16Array]"]=Aa["[object Uint32Array]"]=!0,Aa["[object Error]"]=Aa[ka]=Aa["[object WeakMap]"]=!1;var Oa=function e(t,r,n,i,s,o){var a,l=1&r,h=2&r,c=4&r;if(n&&(a=s?n(t,i,s,o):n(t)),void 0!==a)return a;if(!Ca(t))return t;var u=wa(t);if(u){if(a=ga(t),!l)return ua(t,a)}else{var d=ba(t),f=d==ka||"[object GeneratorFunction]"==d;if(_a(t))return ca(t,l);if(d==Ma||d==Ra||f&&!s){if(a=h||f?{}:va(t),!l)return h?fa(t,ha(a,t)):da(t,la(a,t))}else{if(!Aa[d])return s?t:{};a=ya(t,d,l)}}o||(o=new sa);var p=o.get(t);if(p)return p;o.set(t,a),Ea(t)?t.forEach((function(i){a.add(e(i,r,n,i,t,o))})):xa(t)&&t.forEach((function(i,s){a.set(s,e(i,r,n,s,t,o))}));var m=u?void 0:(c?h?ma:pa:h?Ta:Sa)(t);return oa(m||t,(function(i,s){m&&(i=t[s=i]),aa(a,s,e(i,r,n,s,t,o))})),a},Ia=Oa;var Na=l((function(e){return Ia(e,5)}));const Fa={"零":0,"一":1,"二":2,"三":3,"四":4,"五":5,"六":6,"七":7,"八":8,"九":9},Pa=["零","一","二","三","四","五","六","七","八","九"],ja=["","万","亿","万亿","亿亿"],La=["","十","百","千"],Da={"十":{value:10,secUnit:!1},"百":{value:100,secUnit:!1},"千":{value:1e3,secUnit:!1},"万":{value:1e4,secUnit:!0},"亿":{value:1e8,secUnit:!0}};function Ba(e){if(!e)return 0;let t=0,r=0,n=0,i=!1;const s=e.split("");for(let e=0;e<s.length;e++){const o=Fa[s[e]];if(void 0!==o)n=o,e===s.length-1&&(r+=n);else{const o=Da[s[e]],a=o.value;i=o.secUnit,i?(r=(r+n)*a,t+=r,r=0):r+=n*a,n=0}}return t+r}function Ha(e){let t="",r="",n=0,i=!0;for(;e>0;){const s=e%10;0===s?i||(i=!0,r=Pa[s]+r):(i=!1,t=Pa[s],t+=La[n],r=t+r),n++,e=Math.floor(e/10)}return r}function za(e){let t=0,r="",n="",i=!1;if(0===e)return Pa[0];for(;e>0;){const s=e%1e4;i&&(n=Pa[0]+n),r=Ha(s),r+=0!==s?ja[t]:ja[0],n=r+n,i=s<1e3&&s>0,e=Math.floor(e/1e4),t++}return n}function Ua(e){if(!e)return{isExtendNumber:!1};const t=/0|([1-9]+[0-9]*)/g,r=t.test(e);if(r){const r=e.match(t);if(r&&r.length>0){const t=r[r.length-1],n=e.lastIndexOf(t),i=e.substr(0,n),s=e.substr(n+t.length);return{isExtendNumber:!0,matchTxt:Number(t),beforeTxt:i,afterTxt:s}}return{isExtendNumber:!1}}return{isExtendNumber:r}}function Va(e){let t=!0;const r=e[1]-e[0];for(let n=1;n<e.length;n++)if(e[n]-e[n-1]!==r){t=!1;break}return t}function $a(e,t){const r=[];for(let n=1;n<=t;n++){const t=(n-1)%e.length,i=Na(e[t]);Qa(i),r.push({v:null,t:null,...i})}return r}function Wa(e,t,r,n){n&&e.forEach((e=>{const{v:t,meta:r}=n.toNumber(e.v);e.v=t,e.f=r}));const i=[],s=[];for(let t=0;t<e.length;t++)s.push(Number(e[t]?.v));if(e.length>2&&function(e){let t=!0;const r=e[1]/e[0];for(let n=1;n<e.length;n++)if(e[n]/e[n-1]!==r){t=!1;break}return t}(s))for(let r=1;r<=t;r++){const t=(r-1)%e.length,s=Na(e[t]);Qa(s);const o=Number(e[e.length-1]?.v),a=Number(e[0]?.v),l=o*(Number(e[1]?.v)/a)**r;s&&(s.v=n?n.fromNumber(l,s.f):l,i.push(s))}else{const o=function(e){const t=[];for(let r=1;r<=e;r++)t.push(r);return t}(e.length);for(let a=1;a<=t;a++){const t=(a-1)%e.length,l=Na(e[t]);Qa(l);const h=r===ks.DOWN||r===ks.RIGHT,c=qa(e.length+a,s,o,h);l&&(l.v=n?n.fromNumber(c,l.f):c,i.push(l))}}return i}function qa(e,t,r,n=!0){function i(e){let t=0;for(let r=0;r<e.length;r++)t+=e[r];return t/e.length}const s=i(r),o=i(t);let a,l=0,h=0;for(let e=0;e<r.length;e++)l+=(r[e]-s)*(t[e]-o),h+=(r[e]-s)*(r[e]-s);a=0===h?n?1:-1:l/h;const c=o-a*s;return Math.round(1e5*(c+a*e))/1e5}function Ka(e,t,r){const n=[],i=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=t;s++){const t=(s-1)%e.length,o=Na(e[t]);Qa(o);const a=`${e[e.length-1]?.v??""}`;if(!a)continue;const l=a?.match(i),h=l?.[l.length-1];if(!h)continue;const c=Math.abs(Number(h)+r*s),u=a.lastIndexOf(h),d=a.substr(0,u)+c.toString()+a.substr(u+h.length);o&&(o.v=d,n.push(o))}return n}function Ya(e,t,r,n=0){const i=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=i.length)return[];const s=i[n],o=[];for(let n=1;n<=t;n++){const t=(n-1)%e.length,i=Na(e[t]);Qa(i);let a=0;if(e[e.length-1]?.v===s[0])a=7+r*n;else{const t=`${e[e.length-1]?.v??""}`;if(t){a=Ba(t.substr(t.length-1,1))+r*n}}a<0&&(a=7*Math.ceil(Math.abs(a)/7)+a);const l=a%7;i&&(i.v=s[l],o.push(i))}return o}function Xa(e,t,r){const n=[];for(let i=1;i<=t;i++){const t=(i-1)%e.length,s=Na(e[t]);Qa(s);const o=Ba(`${e[e.length-1]?.v??""}`)+r*i;let a;a=o<=0?"零":za(o),s&&(s.v=a,n.push(s))}return n}const Ga={enWeek1:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],enWeek2:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],enMonth1:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],enMonth2:["January","February","March","April","May","June","July","August","September","October","November","December"],chnMonth1:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],chnMonth2:["正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月"],chHour1:["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],chHour2:["子时","丑时","寅时","卯时","辰时","巳时","午时","未时","申时","酉时","戌时","亥时"],chYear1:["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],chSeason1:["春","夏","秋","冬"],chSeason2:["春季","夏季","秋季","冬季"]};function Za(e){let t="";const r=[];return Object.keys(Ga).forEach((n=>{Ga[n].includes(e)&&(t=n,r.push(...Ga[n]))})),{name:t,series:r}}function Ja(e,t,r,n){const i=n.length,s=[];for(let o=1;o<=t;o++){const t=(o-1)%e.length,a=Na(e[t]);Qa(a);const l=`${e[e.length-1]?.v??""}`;let h=n.indexOf(l)+r*o;h<0&&(h+=Math.abs(r)*i);const c=h%i;a&&(a.v=n[c],s.push(a))}return s}function Qa(e){e&&"custom"in e&&delete e.custom}function el(e,t,r=new Date){const n=e.trim();if("yyyy-MM-dd"===t){const[e,t,r]=n.split("-").map(Number);return new Date(e,t-1,r)}if("yyyy-M-d"===t){const[e,t,r]=n.split("-").map(Number);return new Date(e,t-1,r)}if("yyyy/MM/dd"===t){const[e,t,r]=n.split("/").map(Number);return new Date(e,t-1,r)}if("yyyy/M/d"===t){const[e,t,r]=n.split("/").map(Number);return new Date(e,t-1,r)}if("MM/dd/yyyy"===t){const[e,t,r]=n.split("/").map(Number);return new Date(r,e-1,t)}if("yyyy年M月d日"===t){const e=n.match(/^(\d{4})年(\d{1,2})月(\d{1,2})(日)?$/);if(e)return new Date(Number(e[1]),Number(e[2])-1,Number(e[3]))}const i=new Date(n);return isNaN(i.getTime())?new Date(r):i}function tl(e){return!isNaN(e.getTime())}function rl(e,t){const r=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())-Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor(r/864e5)}class nl{key="date";baseDate=new Date(1900,0,1);dateFormats=[{pattern:/^\d{4}-\d{2}-\d{2}$/,format:"yyyy-MM-dd"},{pattern:/^\d{4}-\d{1,2}-\d{1,2}$/,format:"yyyy-M-d"},{pattern:/^\d{4}\/\d{2}\/\d{2}$/,format:"yyyy/MM/dd"},{pattern:/^\d{4}\/\d{1,2}\/\d{1,2}$/,format:"yyyy/M/d"},{pattern:/^\d{2}\/\d{2}\/\d{4}$/,format:"MM/dd/yyyy"},{pattern:/^\d{4}年\d{1,2}月\d{1,2}(日)?$/,format:"yyyy年M月d日",parser:e=>{const t=e.match(/(\d{4})年(\d{1,2})月(\d{1,2})/);if(!t)throw new Error("无效的中文日期格式");return new Date(+t[1],+t[2]-1,+t[3])}}];detect(e){if(e instanceof Date)return!isNaN(e.getTime());if("string"!=typeof e)return!1;const t=e.trim(),r=this.dateFormats.find((e=>e.pattern.test(t)));if(r)try{return tl(r.parser?r.parser(t):el(t,r.format,new Date))}catch{return!1}return!1}toNumber(e){let t,r;if(e instanceof Date){if(!tl(e))throw new Error("无效的日期对象");t=e,r="yyyy-MM-dd"}else{const n=e.trim(),i=this.dateFormats.find((e=>e.pattern.test(n)));if(!i)throw new Error(`不支持的日期格式: ${n}`);if(t=i.parser?i.parser(n):el(n,i.format,new Date),!tl(t))throw new Error(`无效的日期值: ${n}`);r=i.format}return{v:rl(t,this.baseDate),meta:r}}fromNumber(e,t){const r=function(e,t){const r=new Date(e);return r.setDate(r.getDate()+t),r}(this.baseDate,e);return r.setHours(0,0,0,0),function(e,t){const r=e.getFullYear(),n=e.getMonth()+1,i=e.getDate(),s=e=>e.toString().padStart(2,"0");switch(t){case"yyyy-MM-dd":default:return`${r}-${s(n)}-${s(i)}`;case"yyyy-M-d":return`${r}-${n}-${i}`;case"yyyy/MM/dd":return`${r}/${s(n)}/${s(i)}`;case"yyyy/M/d":return`${r}/${n}/${i}`;case"MM/dd/yyyy":return`${s(n)}/${s(i)}/${r}`;case"yyyy年M月d日":return`${r}年${n}月${i}日`}}(r,t||"yyyy-MM-dd")}}const il=new class{converters=[];register(e){this.converters.push(e)}getConverter(e){return this.converters.find((t=>t.detect(e)))||null}getConverterByKey(e){return this.converters.find((t=>t.key===e))||null}};il.register(new nl);const sl={type:Os.DATE,priority:1100,match:(e,t)=>"string"==typeof e?.v&&il.getConverter(e.v)instanceof nl,isContinue:(e,t)=>e.type===Os.DATE,applyFunctions:{[Ms.SERIES]:(e,t,r)=>{const{data:n}=e,i=il.getConverter(n[0]?.v);return r===ks.LEFT||r===ks.UP?(n.reverse(),Wa(n,t,r,i).reverse()):Wa(n,t,r,i)}}},ol={type:Os.NUMBER,priority:1e3,match:e=>"number"==typeof e?.v||e?.t===As.NUMBER,isContinue:(e,t)=>e.type===Os.NUMBER,applyFunctions:{[Ms.SERIES]:(e,t,r)=>{const{data:n}=e;return r===ks.LEFT||r===ks.UP?(n.reverse(),Wa(n,t,r).reverse()):Wa(n,t,r)}}},al={type:Os.OTHER,priority:0,match:()=>!0,isContinue:(e,t)=>e.type===Os.OTHER},ll={type:Os.EXTEND_NUMBER,priority:900,match:e=>Ua(`${e?.v??""}`||"").isExtendNumber,isContinue:(e,t)=>{if(e.type===Os.EXTEND_NUMBER){const{beforeTxt:r,afterTxt:n}=Ua(`${e.cellData?.v??""}`||""),{beforeTxt:i,afterTxt:s}=Ua(`${t?.v??""}`||"");if(r===i&&n===s)return!0}return!1},applyFunctions:{[Ms.SERIES]:(e,t,r)=>{const{data:n}=e,i=r===ks.UP||r===ks.LEFT;let s;if(1===n.length)return s=i?-1:1,fl(Ka(n,t,s),i);const o=[];for(let e=0;e<n.length;e++){const t=`${n[e]?.v}`;t&&o.push(Number(Ua(t).matchTxt))}return i&&(n.reverse(),o.reverse()),Va(o)?(s=o[1]-o[0],fl(Ka(n,t,s),i)):$a(n,t)}}},hl={type:Os.CHN_NUMBER,priority:830,match:e=>!!function(e){if(!e)return!1;let t=!0;if(e)if(1===e.length)t="日"===e||e in Fa;else{const r=e.split("");for(let e=0;e<r.length;e++)if(!(r[e]in Fa)&&!(r[e]in Da)){t=!1;break}}return t}(`${e?.v??""}`||""),isContinue:(e,t)=>e.type===Os.CHN_NUMBER,applyFunctions:{[Ms.SERIES]:(e,t,r)=>{const{data:n}=e,i=r===ks.LEFT||r===ks.UP;if(1===n.length){let e;return e=i?-1:1,fl(Xa(n,t,e),i)}let s=!1;for(let e=0;e<n.length;e++){const t=n[e]?.v;if("日"===t){s=!0;break}}const o=[];let a=0;for(let e=0;e<n.length;e++){const t=`${n[e]?.v}`;"日"===t?0===e?o.push(0):(a++,o.push(7*a)):s&&Ba(t)>0&&Ba(t)<7?o.push(Ba(t)+7*a):o.push(Ba(t))}if(i&&(n.reverse(),o.reverse()),Va(o)){return fl(Xa(n,t,o[1]-o[0]),i)}return $a(n,t)}}},cl={type:Os.CHN_WEEK2,priority:820,match:e=>!!function(e){let t;return t=2===e.length&&("周一"===e||"周二"===e||"周三"===e||"周四"===e||"周五"===e||"周六"===e||"周日"===e),t}(`${e?.v??""}`||""),isContinue:(e,t)=>e.type===Os.CHN_WEEK2,applyFunctions:{[Ms.SERIES]:(e,t,r)=>{const{data:n}=e,i=r===ks.LEFT||r===ks.UP;if(1===n.length){let e;return e=i?-1:1,fl(Ya(n,t,e,1),i)}const s=[];let o=0;for(let e=0;e<n.length;e++){const t=`${n[e]?.v}`,r=t?.substr(t.length-1,1);"周日"===t?0===e?s.push(0):(o++,s.push(7*o)):s.push(Ba(r)+7*o)}if(i&&(n.reverse(),s.reverse()),Va(s)){return fl(Ya(n,t,s[1]-s[0],1),i)}return $a(n,t)}}},ul={type:Os.CHN_WEEK3,priority:810,match:e=>function(e){let t;return t=3===e.length&&("星期一"===e||"星期二"===e||"星期三"===e||"星期四"===e||"星期五"===e||"星期六"===e||"星期日"===e),t}(`${e?.v??""}`||""),isContinue:(e,t)=>e.type===Os.CHN_WEEK3,applyFunctions:{[Ms.SERIES]:(e,t,r)=>{const{data:n}=e,i=r===ks.LEFT||r===ks.UP;if(1===n.length){let e;return e=i?-1:1,fl(Ya(n,t,e,2),i)}const s=[];let o=0;for(let e=0;e<n.length;e++){const t=`${n[e]?.v}`;if(t){const r=t.substr(t.length-1,1);"星期日"===t?0===e?s.push(0):(o++,s.push(7*o)):s.push(Ba(r)+7*o)}}if(i&&(n.reverse(),s.reverse()),Va(s)){return fl(Ya(n,t,s[1]-s[0],2),i)}return $a(n,t)}}},dl={type:Os.LOOP_SERIES,priority:800,match:e=>function(e){let t=!1;return Object.keys(Ga).forEach((r=>{Ga[r].includes(e)&&(t=!0)})),t}(`${e?.v??""}`||""),isContinue:(e,t)=>e.type===Os.LOOP_SERIES&&Za(`${e.cellData?.v??""}`||"").name===Za(`${t?.v??""}`||"").name,applyFunctions:{[Ms.SERIES]:(e,t,r)=>{const{data:n}=e,i=r===ks.LEFT||r===ks.UP,{series:s}=Za(`${n[0]?.v}`||"");if(1===n.length){let e;return e=i?-1:1,fl(Ja(n,t,e,s),i)}const o=[];let a=0;for(let e=0;e<n.length;e++){const t=`${n[e]?.v}`;t&&(t===s[0]?0===e?o.push(0):(a++,o.push(a*s.length)):o.push(s.indexOf(t)+7*a))}if(i&&(n.reverse(),o.reverse()),Va(o)){return fl(Ja(n,t,o[1]-o[0],s),i)}return $a(n,t)}}};function fl(e,t){return t?e.reverse():e}class pl{_rules=[];constructor(){this._init()}_init(){this._rules=[sl,ol,ll,hl,cl,ul,dl,al].sort(((e,t)=>t.priority-e.priority))}registerRule(e){if(this._rules.find((t=>t.type===e.type)))throw new Error(`Registry rule failed, type '${e.type}' already exist!`);const t=this._rules.findIndex((t=>t.priority<e.priority));this._rules.splice(-1===t?this._rules.length:t,0,e)}getRules(){return this._rules}}function ml(e){const t=Math.min(e.start.col,e.end.col),r=Math.min(e.start.row,e.end.row),n=Math.max(e.start.col,e.end.col),i=Math.max(e.start.row,e.end.row),s=[],o=[];for(let e=t;e<=n;e++)s.push(e);for(let e=r;e<=i;e++)o.push(e);return{cols:s,rows:o}}function bl(e,t,r){return e===ks.DOWN||e===ks.UP?{cols:r.cols,rows:r.rows.filter((e=>!t.rows.includes(e)))}:{cols:r.cols.filter((e=>!t.cols.includes(e))),rows:r.rows}}function gl(e,t,r){const n=e.scenegraph.highPerformanceGetCell(t,r).globalAABBBounds;e.showDropDownMenu(t,r,{content:[{type:"item",text:"复制填充",icon:{width:16,height:16,svg:'<svg t="1756136702877" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1474" width="200" height="200"><path d="M853.333333 981.333333h-384c-72.533333 0-128-55.466667-128-128v-384c0-72.533333 55.466667-128 128-128h384c72.533333 0 128 55.466667 128 128v384c0 72.533333-55.466667 128-128 128z m-384-554.666666c-25.6 0-42.666667 17.066667-42.666666 42.666666v384c0 25.6 17.066667 42.666667 42.666666 42.666667h384c25.6 0 42.666667-17.066667 42.666667-42.666667v-384c0-25.6-17.066667-42.666667-42.666667-42.666666h-384z" p-id="1475"></path><path d="M213.333333 682.666667H170.666667c-72.533333 0-128-55.466667-128-128V170.666667c0-72.533333 55.466667-128 128-128h384c72.533333 0 128 55.466667 128 128v42.666666c0 25.6-17.066667 42.666667-42.666667 42.666667s-42.666667-17.066667-42.666667-42.666667V170.666667c0-25.6-17.066667-42.666667-42.666666-42.666667H170.666667c-25.6 0-42.666667 17.066667-42.666667 42.666667v384c0 25.6 17.066667 42.666667 42.666667 42.666666h42.666666c25.6 0 42.666667 17.066667 42.666667 42.666667s-17.066667 42.666667-42.666667 42.666667z" p-id="1476"></path></svg>'}},{type:"item",text:"序列填充",icon:{width:16,height:16,svg:'<svg t="1756136788547" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2463" width="200" height="200"><path d="M312.832482 65.167035H959.204489c35.706211 0 64.64232 29.473622 64.64232 65.832527 0 36.346107-28.936109 65.832527-64.629522 65.832527H312.819684c-35.693413 0-64.629522-29.473622-64.629522-65.832527 0-36.346107 28.936109-65.832527 64.629522-65.832527z m0 394.982363H959.204489c35.706211 0 64.64232 29.460824 64.64232 65.819729 0 36.358905-28.936109 65.832527-64.629522 65.832527H312.819684c-35.693413 0-64.629522-29.473622-64.629522-65.832527 0-36.346107 28.936109-65.819729 64.629522-65.819729z m0 394.969566H959.204489c35.706211 0 64.64232 29.473622 64.64232 65.819729 0 36.358905-28.936109 65.832527-64.629522 65.832527H312.819684c-35.693413 0-64.629522-29.473622-64.629522-65.832527 0-36.346107 28.936109-65.819729 64.629522-65.819729zM12.286008 69.108796V38.176211c9.892796 0.767876 19.836784 0.767876 29.72958 0A41.823619 41.823619 0 0 0 63.989626 25.672638c4.261709-4.671243 7.358807-10.315128 9.048133-16.458132 0.37114-3.058704 0.37114-6.143004 0-9.214506H114.413451v229.748352H65.93491V69.108796H12.286008z m0 510.176487a130.730805 130.730805 0 0 1 45.240665-49.374395 334.537763 334.537763 0 0 0 40.070304-32.250771 48.47854 48.47854 0 0 0 14.218495-33.581756 37.31875 37.31875 0 0 0-7.755543-24.354451 28.193829 28.193829 0 0 0-23.266628-9.879998 27.643518 27.643518 0 0 0-31.02217 15.139945 78.27211 78.27211 0 0 0-5.170362 28.30901H2.585181a114.311067 114.311067 0 0 1 10.340723-48.056208c12.388392-24.124089 38.086625-37.984242 64.629522-34.887144a79.897447 79.897447 0 0 1 57.539472 20.41269 71.783562 71.783562 0 0 1 21.321343 53.981648 74.637499 74.637499 0 0 1-14.858391 46.072531 152.16733 152.16733 0 0 1-32.967455 29.627197L90.481331 553.625443l-23.266628 17.763521c-4.082538 3.583419-7.563574 7.806734-10.353522 12.51637h99.542262v40.147092H0a110.945213 110.945213 0 0 1 10.340724-45.419837l1.945284 0.665492zM44.600769 948.582211a53.495327 53.495327 0 0 0 4.517668 23.036265 30.279891 30.279891 0 0 0 29.742378 17.110826c7.422797 0.255959 14.717614-2.073264 20.681447-6.578133 6.7829-6.962071 10.315128-16.547717 9.688029-26.325332a30.356678 30.356678 0 0 0-18.096266-30.945383 91.735527 91.735527 0 0 0-32.314761-8.561812V883.440772a83.903197 83.903197 0 0 0 30.382274-4.607253 27.106005 27.106005 0 0 0 14.858391-28.30901 30.612637 30.612637 0 0 0-7.755542-21.730877 27.528337 27.528337 0 0 0-21.321344-8.549014 26.939632 26.939632 0 0 0-23.279425 10.532692 44.063256 44.063256 0 0 0-7.102849 27.643519H2.585181a117.101015 117.101015 0 0 1 5.823056-32.916264 74.381541 74.381541 0 0 1 17.443572-25.019944 60.534186 60.534186 0 0 1 20.681447-12.503572 89.55988 89.55988 0 0 1 29.742378-3.289067A78.540867 78.540867 0 0 1 129.259044 801.79001a57.744238 57.744238 0 0 1 20.041551 46.085328 51.921182 51.921182 0 0 1-12.286008 34.887144c-4.159326 5.170362-9.470465 9.227304-15.511086 11.850879 6.7829 1.510155 12.900309 5.208756 17.45637 10.532692a57.821026 57.821026 0 0 1 17.443572 44.10165 75.136618 75.136618 0 0 1-20.028753 52.010768 76.122059 76.122059 0 0 1-59.471958 22.383571 71.962733 71.962733 0 0 1-64.629522-32.250771A97.52019 97.52019 0 0 1 1.279793 946.611331l43.308178 1.97088z" fill="#515151" p-id="2464"></path></svg>'}}],referencePosition:{rect:{right:n.x2+110,bottom:n.y2}}})}function yl(e){return{getValue:(t,r)=>{const n=e.getCellValue(r,t);return"number"!=typeof n&&isNaN(Number(n))?{v:n||"",t:As.STRING}:{v:n,t:As.NUMBER}},getMaxRows:()=>e.records.length,getMaxColumns:()=>e.columns.length}}class vl{sourceData=[];autoFillService;tableInstance;sourceRange;targetRange;direction;headers;options;constructor(e){this.options=e,this.autoFillService=new pl}setTable(e){this.headers={row:new Set,col:new Set},this.tableInstance=e,e.on(r.TABLE_EVENT_TYPE.DROPDOWN_MENU_CLICK,(e=>{"复制填充"===e.text?this.fillData(Ms.COPY):"序列填充"===e.text&&this.fillData(Ms.SERIES)}));const t=this.tableInstance.getAllRowHeaderCells()[0];t&&t.forEach((e=>{this.headers.col.add(e.col)}));const n=this.tableInstance.getAllColumnHeaderCells()[0];n&&n.forEach((e=>{this.headers.row.add(e.row)}))}handleStartDrag(e){this.sourceRange=ml(e),this.sourceRange.cols=this.sourceRange.cols.filter((e=>!this.headers.col.has(e))),this.sourceRange.rows=this.sourceRange.rows.filter((e=>!this.headers.row.has(e)))}handleEndDrag(e,t){this.direction=t;const r=ml(e);this.targetRange=bl(this.direction,this.sourceRange,r),this.targetRange.cols=this.targetRange.cols.filter((e=>!this.headers.col.has(e))),this.targetRange.rows=this.targetRange.rows.filter((e=>!this.headers.row.has(e))),this.options?.fillMode?this.fillData(this.options.fillMode):gl(this.tableInstance,Math.max(...r.cols),Math.max(...r.rows))}handleDbClick(){if(!this.sourceRange)return;this.direction=ks.DOWN;const e=ml(this._detectFillRange());if(this.targetRange=bl(this.direction,this.sourceRange,e),this.targetRange.cols=this.targetRange.cols.filter((e=>!this.headers.col.has(e))),this.targetRange.rows=this.targetRange.rows.filter((e=>!this.headers.row.has(e))),0===this.targetRange.cols.length||0===this.targetRange.rows.length)return;const t=this.sourceRange.cols[0],r=this.sourceRange.rows[0],n=this.targetRange.cols[this.targetRange.cols.length-1],i=this.targetRange.rows[this.targetRange.rows.length-1],s=this.tableInstance.stateManager;s.updateSelectPos(t,r,!1,!1,!1,!0,!0),s.updateInteractionState(b.grabing),s.updateSelectPos(n,i,!1,!1,!1,!0,!0),s.endSelectCells(!1,!1),s.updateInteractionState(b.default),this.options?.fastFillMode?this.fillData(this.options.fastFillMode):gl(this.tableInstance,n,i)}fillData(e){this.sourceData=this.getSourceData(this.sourceRange,this.direction);const t={source:this.sourceRange,target:this.targetRange};this._fillData(t,this.direction,e)}getSourceData(e,t){const r=this.autoFillService.getRules(),n=[],i=t===ks.DOWN||t===ks.UP;let s,o;i?(s=e.cols,o=e.rows):(s=e.rows,o=e.cols);const a=yl(this.tableInstance);return s.forEach((e=>{const t=this.getEmptySourceDataPiece(),s={type:void 0,cellData:void 0};o.forEach((n=>{let l;l=i?a.getValue(n,e):a.getValue(e,n);const{type:h,isContinue:c}=r.find((e=>e.match(l,null)))||al;if(c(s,l)){const e=t[h],r=e[e.length-1];r.data.push(l),r.index.push(n-o[0])}else{const e=t[h];e?e.push({data:[l],index:[n-o[0]]}):t[h]=[{data:[l],index:[n-o[0]]}]}s.type=h,s.cellData=l})),n.push(t)})),n}getEmptySourceDataPiece(){const e={};return this.autoFillService.getRules().forEach((t=>{e[t.type]=[]})),e}_detectFillRange(){const e={row:Math.min(...this.sourceRange.rows),col:Math.min(...this.sourceRange.cols)},t={row:Math.max(...this.sourceRange.rows),col:Math.max(...this.sourceRange.cols)},r=yl(this.tableInstance),n=r.getMaxRows(),i=r.getMaxColumns();let s=t.row;if(e.col>0&&r.getValue(e.row,e.col-1)?.v){let t=e.row;for(;r.getValue(t,e.col-1)?.v&&t<=n;)t+=1;s=t-1}else if(t.col<i&&r.getValue(t.row,t.col+1)?.v){let i=e.row;for(;r.getValue(i,t.col+1)?.v&&i<=n;)i+=1;s=i-1}for(let n=t.row+1;n<=s;n++)for(let i=e.col;i<=t.col;i++)if(r.getValue(n,i)?.v){s=n-1;break}return{start:{row:e.row,col:e.col},end:{row:s,col:t.col}}}_fillData(e,t,r){const{source:n,target:i}=e;if(!n||!i||null==t)return;const{cols:s,rows:o}=i,{cols:a,rows:l}=n,h=this.sourceData;let c;c=t===ks.DOWN||t===ks.UP?l.length:a.length;const u=[];if(t===ks.DOWN||t===ks.UP){const n=o.length,i=[];s.forEach(((s,o)=>{const a=h[o],l=this.getApplyData(a,c,n,t,r,e);i.push(l)}));for(let e=0;e<i[0].length;e++){const t=[];for(let r=0;r<i.length;r++)t.push(i[r][e]);u.push(t)}}else{const n=s.length;o.forEach(((i,s)=>{const o=h[s],a=this.getApplyData(o,c,n,t,r,e),l=[];for(let e=0;e<a.length;e++)l.push(a[e]);u.push(l)}))}const d=[];o.forEach(((e,t)=>{const r=[];s.forEach(((n,i)=>{const s=function(e,t,r){const n=e.getCellRange(t,r);return n.start.col!==n.end.col||n.start.row!==n.end.row?n:null}(this.tableInstance,n,e);s&&this.tableInstance.unmergeCells(s.start.col,s.start.row,s.end.col,s.end.row),u[t][i]&&r.push(u[t][i]?.v+"")})),d.push(r)}));const f=Math.min(...o),p=Math.min(...s);this.tableInstance.changeCellValues(p,f,d)}getApplyData(e,t,r,n,i,s){const o=[],a=Math.floor(r/t),l=r%t,h=this.autoFillService.getRules(),c={};h.forEach((e=>{c[e.type]=[]})),h.forEach((o=>{const{type:h,applyFunctions:u={}}=o,d=e[h];d&&d.forEach((o=>{const d=function(e,t){let r=0;for(let n=0;n<e.length&&e[n]<t;n++)r++;return r}(o.index,l),f=o.index.length*a+d,p=this.applyFunctions(o,f,n,i,u,e,s),m=function(e,t,r){const n=[],i=Math.floor(t/e),s=t%e;let o=0;if(i>0){for(let t=0;t<i;t++)for(let i=0;i<r.length;i++)n[r[i]+t*e]=o,o++;for(let t=0;t<r.length&&r[t]<s;t++)n[r[t]+e*i]=o,o++}else for(let e=0;e<r.length&&r[e]<s;e++)n[r[e]]=o,o++;return n}(t,r,o.index);c[h].push({data:p,index:m})}))}));for(let e=0;e<r;e++)h.forEach((t=>{const{type:r}=t,n=c[r];for(let t=0;t<n.length;t++)e in n[t].index&&o.push(n[t].data[n[t].index[e]])}));return o}applyFunctions(e,t,r,n,i,s,o){const{data:a}=e,l=r===ks.UP||r===ks.LEFT;if(n===Ms.COPY){const n=i?.[Ms.COPY];return n?n(e,t,r,s,o):(l&&a.reverse(),$a(a,t))}if(n===Ms.SERIES){const n=i?.[Ms.SERIES];return n?n(e,t,r,s):(l&&a.reverse(),i?.[Ms.COPY]?i[Ms.COPY](e,t,r,s,o):$a(a,t))}return[]}}e.AddRowColumnPlugin=class{id="add-row-column";name="Add Row Column";runTime=[r.TABLE_EVENT_TYPE.MOUSEENTER_CELL,r.TABLE_EVENT_TYPE.MOUSELEAVE_CELL,r.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE];pluginOptions;table;hoverCell;hideAllTimeoutId_addColumn;hideAllTimeoutId_addRow;leftDotForAddColumn;rightDotForAddColumn;addIconForAddColumn;addLineForAddColumn;topDotForAddRow;bottomDotForAddRow;addIconForAddRow;addLineForAddRow;constructor(e={addColumnEnable:!0,addRowEnable:!0}){this.id=e.id??this.id,this.pluginOptions=e,this.pluginOptions.addColumnEnable=this.pluginOptions.addColumnEnable??!0,this.pluginOptions.addRowEnable=this.pluginOptions.addRowEnable??!0,this.pluginOptions.addColumnEnable&&(this.initAddColumnDomElement(),this.bindEventForAddColumn()),this.pluginOptions.addRowEnable&&(this.initAddRowDomElement(),this.bindEventForAddRow())}run(...e){const t=e[0],n=e[1],i=e[2];if(this.table=i,n===r.TABLE_EVENT_TYPE.MOUSEENTER_CELL){clearTimeout(this.hideAllTimeoutId_addColumn),clearTimeout(this.hideAllTimeoutId_addRow);const e=i.canvas.getBoundingClientRect(),r=i.getCellAtRelativePosition(t.event.clientX-e.left,t.event.clientY-e.top);this.hoverCell=r;const n=i.getCellRelativeRect(r.col,r.row);if(this.pluginOptions.addColumnEnable){const t=i.isSeriesNumber(r.col,0);this.showDotForAddColumn(e.top-6,n.left+e.left,n.right+e.left,!t)}if(this.pluginOptions.addRowEnable){const t=i.isHeader(r.col,r.row);this.showDotForAddRow(n.top+e.top,e.left-6,n.bottom+e.top,!t,!t)}}else n===r.TABLE_EVENT_TYPE.MOUSELEAVE_CELL||n===r.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE&&(this.pluginOptions.addColumnEnable&&this.delayHideAllForAddColumn(),this.pluginOptions.addRowEnable&&this.delayHideAllForAddRow())}initAddColumnDomElement(){this.leftDotForAddColumn=document.createElement("div"),this.leftDotForAddColumn.style.width="6px",this.leftDotForAddColumn.style.height="6px",this.leftDotForAddColumn.style.backgroundColor="#4A90E2",this.leftDotForAddColumn.style.position="absolute",this.leftDotForAddColumn.style.cursor="pointer",this.leftDotForAddColumn.style.zIndex="1000",this.leftDotForAddColumn.style.borderRadius="50%",this.leftDotForAddColumn.style.border="1px solid white",this.leftDotForAddColumn.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.leftDotForAddColumn),this.rightDotForAddColumn=document.createElement("div"),this.rightDotForAddColumn.style.width="6px",this.rightDotForAddColumn.style.height="6px",this.rightDotForAddColumn.style.backgroundColor="#4A90E2",this.rightDotForAddColumn.style.position="absolute",this.rightDotForAddColumn.style.cursor="pointer",this.rightDotForAddColumn.style.zIndex="1000",this.rightDotForAddColumn.style.borderRadius="50%",this.rightDotForAddColumn.style.border="1px solid white",this.rightDotForAddColumn.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.rightDotForAddColumn),this.addIconForAddColumn=document.createElement("div"),this.addIconForAddColumn.style.width="18px",this.addIconForAddColumn.style.height="18px",this.addIconForAddColumn.style.backgroundColor="#4A90E2",this.addIconForAddColumn.style.position="absolute",this.addIconForAddColumn.style.zIndex="1001",this.addIconForAddColumn.style.display="none",this.addIconForAddColumn.style.borderRadius="50%",this.addIconForAddColumn.style.boxShadow="0 2px 5px rgba(0,0,0,0.2)",this.addIconForAddColumn.style.justifyContent="center",this.addIconForAddColumn.style.alignItems="center",this.addIconForAddColumn.style.border="1px solid white",document.body.appendChild(this.addIconForAddColumn);const e=document.createElement("div");e.textContent="+",e.style.color="white",e.style.fontSize="18px",e.style.fontWeight="bold",e.style.lineHeight="15px",e.style.userSelect="none",e.style.cursor="pointer",e.style.verticalAlign="top",e.style.textAlign="center",this.addIconForAddColumn.appendChild(e),this.addLineForAddColumn=document.createElement("div"),this.addLineForAddColumn.style.width="2px",this.addLineForAddColumn.style.height="10px",this.addLineForAddColumn.style.backgroundColor="#4A90E2",this.addLineForAddColumn.style.position="absolute",this.addLineForAddColumn.style.zIndex="1001",this.addLineForAddColumn.style.display="none",document.body.appendChild(this.addLineForAddColumn)}bindEventForAddColumn(){this.leftDotForAddColumn.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addColumn),this.addIconForAddColumn.style.display="block";const e=this.leftDotForAddColumn.offsetWidth,t=this.leftDotForAddColumn.offsetHeight;this.showAddIconForAddColumn(this.leftDotForAddColumn.offsetLeft+e/2,this.leftDotForAddColumn.offsetTop+t/2,!0),this.showSplitLineForAddColumn(this.leftDotForAddColumn.offsetLeft+e/2-1,this.leftDotForAddColumn.offsetTop+t/2+2,this.table.getDrawRange().height)})),this.rightDotForAddColumn.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addColumn),this.addIconForAddColumn.style.display="block";const e=this.rightDotForAddColumn.offsetWidth,t=this.rightDotForAddColumn.offsetHeight;this.showAddIconForAddColumn(this.rightDotForAddColumn.offsetLeft+e/2,this.rightDotForAddColumn.offsetTop+t/2,!1),this.showSplitLineForAddColumn(this.rightDotForAddColumn.offsetLeft+e/2-1,this.rightDotForAddColumn.offsetTop+t/2+2,this.table.getDrawRange().height)})),this.addIconForAddColumn.addEventListener("mouseleave",(()=>{this.addIconForAddColumn.style.display="none",this.addLineForAddColumn.style.display="none",this.delayHideAllForAddColumn()})),this.addIconForAddColumn.addEventListener("click",(e=>{const t="left"===this.addIconForAddColumn.dataset.addIconType;this.table.options.columns;const r=this.hoverCell.col,n=t?r:r+1;this.pluginOptions.addColumnCallback?this.pluginOptions.addColumnCallback(n,this.table):this.table.addColumns([{field:n,title:`New Column ${r}`,width:100}],n,!0),this.delayHideAllForAddColumn(0)}))}showDotForAddColumn(e,t,r,n=!0,i=!0){const s=this.leftDotForAddColumn.offsetWidth,o=this.leftDotForAddColumn.offsetHeight;this.leftDotForAddColumn.style.left=t-s/2+"px",this.leftDotForAddColumn.style.top=e-o/2+"px",this.rightDotForAddColumn.style.left=r-s/2+"px",this.rightDotForAddColumn.style.top=e-o/2+"px",this.leftDotForAddColumn.style.display=n?"block":"none",this.rightDotForAddColumn.style.display=i?"block":"none"}showAddIconForAddColumn(e,t,r){const n=this.addIconForAddColumn.offsetWidth,i=this.addIconForAddColumn.offsetHeight,s=this.leftDotForAddColumn.offsetHeight;this.addIconForAddColumn.style.left=e-n/2+"px",this.addIconForAddColumn.style.top=t-i/2-s/2+"px",this.addIconForAddColumn.dataset.addIconType=r?"left":"right"}showSplitLineForAddColumn(e,t,r){this.addLineForAddColumn.style.left=`${e}px`,this.addLineForAddColumn.style.top=`${t}px`,this.addLineForAddColumn.style.height=`${r}px`,this.addLineForAddColumn.style.display="block"}delayHideAllForAddColumn(e=1e3){this.hideAllTimeoutId_addColumn=setTimeout((()=>{this.addIconForAddColumn.style.display="none",this.addLineForAddColumn.style.display="none",this.leftDotForAddColumn.style.display="none",this.rightDotForAddColumn.style.display="none"}),e)}initAddRowDomElement(){this.topDotForAddRow=document.createElement("div"),this.topDotForAddRow.style.width="6px",this.topDotForAddRow.style.height="6px",this.topDotForAddRow.style.backgroundColor="#4A90E2",this.topDotForAddRow.style.position="absolute",this.topDotForAddRow.style.cursor="pointer",this.topDotForAddRow.style.zIndex="1000",this.topDotForAddRow.style.borderRadius="50%",this.topDotForAddRow.style.border="1px solid white",this.topDotForAddRow.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.topDotForAddRow),this.bottomDotForAddRow=document.createElement("div"),this.bottomDotForAddRow.style.width="6px",this.bottomDotForAddRow.style.height="6px",this.bottomDotForAddRow.style.backgroundColor="#4A90E2",this.bottomDotForAddRow.style.position="absolute",this.bottomDotForAddRow.style.cursor="pointer",this.bottomDotForAddRow.style.zIndex="1000",this.bottomDotForAddRow.style.borderRadius="50%",this.bottomDotForAddRow.style.border="1px solid white",this.bottomDotForAddRow.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.bottomDotForAddRow),this.addIconForAddRow=document.createElement("div"),this.addIconForAddRow.style.width="18px",this.addIconForAddRow.style.height="18px",this.addIconForAddRow.style.backgroundColor="#4A90E2",this.addIconForAddRow.style.position="absolute",this.addIconForAddRow.style.zIndex="1001",this.addIconForAddRow.style.display="none",this.addIconForAddRow.style.borderRadius="50%",this.addIconForAddRow.style.boxShadow="0 2px 5px rgba(0,0,0,0.2)",this.addIconForAddRow.style.justifyContent="center",this.addIconForAddRow.style.alignItems="center",this.addIconForAddRow.style.border="1px solid white",document.body.appendChild(this.addIconForAddRow);const e=document.createElement("div");e.textContent="+",e.style.color="white",e.style.fontSize="18px",e.style.fontWeight="bold",e.style.lineHeight="15px",e.style.userSelect="none",e.style.cursor="pointer",e.style.verticalAlign="top",e.style.textAlign="center",this.addIconForAddRow.appendChild(e),this.addLineForAddRow=document.createElement("div"),this.addLineForAddRow.style.width="10px",this.addLineForAddRow.style.height="2px",this.addLineForAddRow.style.backgroundColor="#4A90E2",this.addLineForAddRow.style.position="absolute",this.addLineForAddRow.style.zIndex="1001",this.addLineForAddRow.style.display="none",document.body.appendChild(this.addLineForAddRow)}bindEventForAddRow(){this.topDotForAddRow.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addRow),this.addIconForAddRow.style.display="block";const e=this.topDotForAddRow.offsetWidth,t=this.topDotForAddRow.offsetHeight;this.showAddIconForAddRow(this.topDotForAddRow.offsetLeft+e/2,this.topDotForAddRow.offsetTop+t/2,!0),this.showSplitLineForAddRow(this.topDotForAddRow.offsetLeft+e+2,this.topDotForAddRow.offsetTop+t/2-1,this.table.getDrawRange().width)})),this.bottomDotForAddRow.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addRow),this.addIconForAddRow.style.display="block";const e=this.bottomDotForAddRow.offsetWidth,t=this.bottomDotForAddRow.offsetHeight;this.showAddIconForAddRow(this.bottomDotForAddRow.offsetLeft+e/2,this.bottomDotForAddRow.offsetTop+t/2,!1),this.showSplitLineForAddRow(this.bottomDotForAddRow.offsetLeft+e+2,this.bottomDotForAddRow.offsetTop+t/2-1,this.table.getDrawRange().height)})),this.addIconForAddRow.addEventListener("mouseleave",(()=>{this.addIconForAddRow.style.display="none",this.addLineForAddRow.style.display="none",this.delayHideAllForAddRow()})),this.addIconForAddRow.addEventListener("click",(e=>{const t="top"===this.addIconForAddRow.dataset.addIconType,r=this.hoverCell.row,n=t?r:r+1;if(this.pluginOptions.addRowCallback)this.pluginOptions.addRowCallback(n,this.table);else{const e=this.table.getRecordIndexByCell(0,n);this.table.addRecord({},e)}this.delayHideAllForAddRow(0)}))}showDotForAddRow(e,t,r,n=!0,i=!0){const s=this.topDotForAddRow.offsetWidth,o=this.topDotForAddRow.offsetHeight;this.topDotForAddRow.style.left=t-s/2+"px",this.topDotForAddRow.style.top=e-o/2+"px",this.bottomDotForAddRow.style.left=t-s/2+"px",this.bottomDotForAddRow.style.top=r-o/2+"px",this.topDotForAddRow.style.display=n?"block":"none",this.bottomDotForAddRow.style.display=i?"block":"none"}showAddIconForAddRow(e,t,r){const n=this.addIconForAddRow.offsetWidth,i=this.addIconForAddRow.offsetHeight,s=this.topDotForAddRow.offsetWidth;this.addIconForAddRow.style.left=e-n/2-s/2+"px",this.addIconForAddRow.style.top=t-i/2+"px",this.addIconForAddRow.dataset.addIconType=r?"top":"bottom"}showSplitLineForAddRow(e,t,r){this.addLineForAddRow.style.left=`${e}px`,this.addLineForAddRow.style.top=`${t}px`,this.addLineForAddRow.style.width=`${r}px`,this.addLineForAddRow.style.display="block"}delayHideAllForAddRow(e=1e3){this.hideAllTimeoutId_addRow=setTimeout((()=>{this.addIconForAddRow.style.display="none",this.addLineForAddRow.style.display="none",this.topDotForAddRow.style.display="none",this.bottomDotForAddRow.style.display="none"}),e)}release(){this.leftDotForAddColumn.remove(),this.rightDotForAddColumn.remove(),this.addIconForAddColumn.remove(),this.addLineForAddColumn.remove(),this.topDotForAddRow.remove(),this.bottomDotForAddRow.remove(),this.addIconForAddRow.remove(),this.addLineForAddRow.remove()}},e.AutoFillPlugin=class{id="auto-fill";name="Auto Fill";runTime=[r.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE,r.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END,r.TABLE_EVENT_TYPE.DBLCLICK_FILL_HANDLE];table;autoFillManager;constructor(e){this.autoFillManager=new vl(e)}run(...e){if(e[1]===r.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE){const[t,r,n]=e;this.table=n,this.autoFillManager.setTable(this.table),this.autoFillManager.handleStartDrag(this.table?.getSelectedCellRanges()[0])}else if(e[1]===r.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END){const[{direction:t}]=e;this.autoFillManager.handleEndDrag(this.table?.getSelectedCellRanges()[0],t)}else e[1]===r.TABLE_EVENT_TYPE.DBLCLICK_FILL_HANDLE&&this.autoFillManager.handleDbClick()}},e.CarouselAnimationPlugin=class{table;rowCount;colCount;animationDuration;animationDelay;animationEasing;replaceScrollAction;playing;row;col;willUpdateRow=!1;willUpdateCol=!1;customDistRowFunction;customDistColFunction;constructor(e,t){this.table=e,this.rowCount=t?.rowCount??void 0,this.colCount=t?.colCount??void 0,this.animationDuration=t?.animationDuration??500,this.animationDelay=t?.animationDelay??1e3,this.animationEasing=t?.animationEasing??"linear",this.replaceScrollAction=t?.replaceScrollAction??!1,this.customDistColFunction=t.customDistColFunction,this.customDistRowFunction=t.customDistRowFunction,this.reset(),this.init()}init(){this.replaceScrollAction&&(this.table.disableScroll(),this.table.scenegraph.stage.addEventListener("wheel",this.onScrollEnd.bind(this)))}reset(){this.playing=!1,this.row=this.table.frozenRowCount,this.col=this.table.frozenColCount}onScrollEnd(e){this.rowCount?(e.deltaY>0?(this.row+=this.rowCount,this.row=Math.min(this.row,this.table.rowCount-this.table.frozenRowCount)):e.deltaY<0&&(this.row-=this.rowCount,this.row=Math.max(this.row,this.table.frozenRowCount)),this.table.scrollToRow(this.row,{duration:this.animationDuration,easing:this.animationEasing})):this.colCount&&(e.deltaX>0?(this.col+=this.colCount,this.col=Math.min(this.col,this.table.colCount-this.table.frozenColCount)):e.deltaX<0&&(this.col-=this.colCount,this.col=Math.max(this.col,this.table.frozenColCount)),this.table.scrollToCol(this.col,{duration:this.animationDuration,easing:this.animationEasing}))}play(){this.playing=!0,this.rowCount&&!this.willUpdateRow?this.updateRow():this.colCount&&!this.willUpdateCol&&this.updateCol()}pause(){this.playing=!1}updateRow(){if(!this.playing||this.table.isReleased)return;let e=!0;const t=this.customDistRowFunction&&this.customDistRowFunction(this.row,this.table);t?(this.row=t.distRow,e=t.animation??!0):s(this.row)&&this.table.scenegraph.proxy.screenTopRow!==this.row?(this.row=this.table.frozenRowCount,e=!1):s(this.row)||this.table.scenegraph.proxy.screenTopRow===Math.floor(this.row)?this.row+=this.rowCount:(this.row=this.table.frozenRowCount,e=!1),this.table.scrollToRow(this.row,e?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateRow=!0,setTimeout((()=>{this.willUpdateRow=!1,this.updateRow()}),this.animationDuration+this.animationDelay)}updateCol(){if(!this.playing||this.table.isReleased)return;let e=!0;const t=this.customDistColFunction&&this.customDistColFunction(this.col,this.table);t?(this.col=t.distCol,e=t.animation??!0):s(this.col)&&this.table.scenegraph.proxy.screenLeftCol!==this.col?(this.col=this.table.frozenColCount,e=!1):s(this.col)||this.table.scenegraph.proxy.screenLeftCol===Math.floor(this.col)?this.col+=this.colCount:(this.col=this.table.frozenColCount,e=!1),this.table.scrollToCol(this.col,e?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateCol=!0,setTimeout((()=>{this.willUpdateCol=!1,this.updateCol()}),this.animationDuration+this.animationDelay)}},e.ColumnSeriesPlugin=class{id="column-series";name="Column Series";runTime=[r.TABLE_EVENT_TYPE.BEFORE_INIT,r.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];pluginOptions;table;columns=[];constructor(e){this.id=e.id??this.id,this.pluginOptions=Object.assign({columnCount:100},e)}run(...e){if(e[1]===r.TABLE_EVENT_TYPE.BEFORE_INIT){const t=e[0],r=e[2];this.table=r;const n=t.options;this.columns=this.generateColumns(this.pluginOptions.columnCount),n.columns=this.columns}else if(e[1]===r.TABLE_EVENT_TYPE.BEFORE_KEYDOWN){const t=e[0].event;this.pluginOptions.autoExtendColumnTriggerKeys?.includes(t.key)&&this.table.stateManager.select.cellPos.col===this.table.colCount-1&&this.table.addColumns([this.generateColumn(this.table.colCount-1)])}}generateColumns(e){const t=[];for(let r=0;r<e;r++)t.push(this.generateColumn(r));return t}generateColumn(e){return{title:this.pluginOptions.generateColumnTitle?this.pluginOptions.generateColumnTitle(e):this.generateColumnField(e)}}generateColumnField(e){if(e<26)return String.fromCharCode(65+e);const t=[];for(e++;e>0;)e--,t.unshift(String.fromCharCode(65+e%26)),e=Math.floor(e/26);return t.join("")}resetColumnCount(e){this.pluginOptions.columnCount=e,this.columns=this.generateColumns(e),this.table.updateColumns(this.columns)}},e.ConditionFilter=ns,e.ContextMenuPlugin=class{id="context-menu";name="Context Menu";runTime=[r.TABLE_EVENT_TYPE.CONTEXTMENU_CELL,r.TABLE_EVENT_TYPE.PLUGIN_EVENT];pluginOptions;table;menuManager;menuHandler;constructor(e={}){this.id=e.id??this.id,this.pluginOptions=e,this.menuManager=new F,this.menuHandler=new Ii,this.initDefaultMenuItems()}initDefaultMenuItems(){this.pluginOptions.columnSeriesNumberMenuItems||(this.pluginOptions.columnSeriesNumberMenuItems=B),this.pluginOptions.rowSeriesNumberMenuItems||(this.pluginOptions.rowSeriesNumberMenuItems=H),this.pluginOptions.cornerSeriesNumberMenuItems||(this.pluginOptions.cornerSeriesNumberMenuItems=z),this.pluginOptions.headerCellMenuItems||(this.pluginOptions.headerCellMenuItems=D),this.pluginOptions.bodyCellMenuItems||(this.pluginOptions.bodyCellMenuItems=L)}handleContextMenuCell=(e,t)=>{const{col:r,row:n}=e,i=e.event.clientX,s=e.event.clientY,o=t.isSeriesNumber(r,n);let a=[];if(a=t.isHeader(r,n)?o?this.pluginOptions.columnSeriesNumberMenuItems||[]:this.pluginOptions.headerCellMenuItems||[]:o?this.pluginOptions.rowSeriesNumberMenuItems||[]:this.pluginOptions.bodyCellMenuItems||[],a.length>0){const e=t.getCellRange(r,n);a=e.start.col!==e.end.col||e.start.row!==e.end.row?a.filter((e=>"string"==typeof e||"merge_cells"!==e.menuKey)):a.filter((e=>"string"==typeof e||"unmerge_cells"!==e.menuKey)),this.pluginOptions.beforeShowAdjustMenuItems&&(a=this.pluginOptions.beforeShowAdjustMenuItems(a,t,r,n)),this.showContextMenu(a,i,s,r,n)}};handlePluginEvent=(e,t)=>{const{eventType:r,rowIndex:n,colIndex:i,isCorner:s}=e.pluginEventInfo,o=e.plugin,a=e.event.clientX,l=e.event.clientY;if("table-series-number"===o.id&&"rightclick"===r){let e=[];s?e=this.pluginOptions.cornerSeriesNumberMenuItems||[]:void 0!==n?e=this.pluginOptions.rowSeriesNumberMenuItems||[]:void 0!==i&&(e=this.pluginOptions.columnSeriesNumberMenuItems||[]),this.pluginOptions.beforeShowAdjustMenuItems&&(e=this.pluginOptions.beforeShowAdjustMenuItems(e,t,i,n)),this.showContextMenu(e,a,l,i,n)}};run(...e){const t=e[0],n=e[1],i=e[2];this.table=i,t.event.preventDefault(),n===r.TABLE_EVENT_TYPE.CONTEXTMENU_CELL?this.handleContextMenuCell(t,i):n===r.TABLE_EVENT_TYPE.PLUGIN_EVENT&&this.handlePluginEvent(t,i)}handleMenuClickCallback=(e,t)=>{"function"==typeof this.pluginOptions.menuClickCallback?this.pluginOptions.menuClickCallback(e,t):this.handleMenuClick(e,t)};showContextMenu(e,t,r,n,i){this.menuManager.showMenu(e,t,r,{rowIndex:i,colIndex:n},this.table),this.menuManager.setClickCallback(this.handleMenuClickCallback)}handleMenuClick(t,r){const{menuKey:n,rowIndex:i,colIndex:s,inputValue:o=1}=t;if("object"==typeof this.pluginOptions.menuClickCallback&&this.pluginOptions.menuClickCallback[n])this.pluginOptions.menuClickCallback[n](t,r);else switch(n){case e.MenuKey.COPY:this.menuHandler.handleCopy(r);break;case e.MenuKey.CUT:this.menuHandler.handleCut(r);break;case e.MenuKey.PASTE:this.menuHandler.handlePaste(r);break;case e.MenuKey.INSERT_ROW_ABOVE:this.menuHandler.handleInsertRowAbove(r,i,o);break;case e.MenuKey.INSERT_ROW_BELOW:this.menuHandler.handleInsertRowBelow(r,i,o);break;case e.MenuKey.INSERT_COLUMN_LEFT:this.menuHandler.handleInsertColumnLeft(r,s,o);break;case e.MenuKey.INSERT_COLUMN_RIGHT:this.menuHandler.handleInsertColumnRight(r,s,o);break;case e.MenuKey.DELETE_ROW:this.menuHandler.handleDeleteRow(r);break;case e.MenuKey.DELETE_COLUMN:this.menuHandler.handleDeleteColumn(r,s);break;case e.MenuKey.HIDE_COLUMN:this.menuHandler.handleHideColumn(r,s);break;case e.MenuKey.SORT:this.menuHandler.handleSort(r,s);break;case e.MenuKey.MERGE_CELLS:this.menuHandler.handleMergeCells(r);break;case e.MenuKey.UNMERGE_CELLS:this.menuHandler.handleUnmergeCells(r);break;case e.MenuKey.FREEZE_TO_THIS_ROW:this.menuHandler.handleFreezeToRow(r,i);break;case e.MenuKey.FREEZE_TO_THIS_COLUMN:this.menuHandler.handleFreezeToColumn(r,s);break;case e.MenuKey.FREEZE_TO_THIS_ROW_AND_COLUMN:this.menuHandler.handleFreezeToRowAndColumn(r,i,s);break;case e.MenuKey.UNFREEZE:this.menuHandler.handleUnfreeze(r)}}release(){this.menuManager&&(this.menuManager.release(),this.menuManager=null),this.menuHandler&&(this.menuHandler.release(),this.menuHandler=null)}},e.DEFAULT_BODY_MENU_ITEMS=L,e.DEFAULT_COLUMN_SERIES_MENU_ITEMS=B,e.DEFAULT_CORNER_SERIES_MENU_ITEMS=z,e.DEFAULT_HEADER_MENU_ITEMS=D,e.DEFAULT_ROW_SERIES_MENU_ITEMS=H,e.ExcelEditCellKeyboardPlugin=class{id="excel-edit-cell-keyboard";name="Excel Edit Cell Keyboard";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED];table;pluginOptions;responseKeyboard;constructor(t){this.id=t?.id??this.id,this.pluginOptions=t,this.responseKeyboard=t?.responseKeyboard??[e.ExcelEditCellKeyboardResponse.ENTER,e.ExcelEditCellKeyboardResponse.TAB,e.ExcelEditCellKeyboardResponse.ARROW_LEFT,e.ExcelEditCellKeyboardResponse.ARROW_RIGHT,e.ExcelEditCellKeyboardResponse.ARROW_DOWN,e.ExcelEditCellKeyboardResponse.ARROW_UP,e.ExcelEditCellKeyboardResponse.DELETE,e.ExcelEditCellKeyboardResponse.BACKSPACE],this.bindEvent()}run(...e){const t=e[2];this.table=t}bindEvent(){document.addEventListener("keydown",this.handleKeyDown.bind(this),!0)}handleKeyDown(t){if(this.table.editorManager&&this.isExcelShortcutKey(t)){const r=t.key.toLowerCase();if(this.table.editorManager.editingEditor&&"keydown"===this.table.editorManager.beginTriggerEditCellMode){const{col:n,row:i}=this.table.editorManager.editCell;this.table.editorManager.completeEdit(),this.table.getElement().focus(),t.shiftKey||t.ctrlKey||t.metaKey||(r===e.ExcelEditCellKeyboardResponse.ENTER?this.table.selectCell(n,i+1):r===e.ExcelEditCellKeyboardResponse.TAB?this.table.selectCell(n+1,i):r===e.ExcelEditCellKeyboardResponse.ARROW_LEFT?this.table.selectCell(n-1,i):r===e.ExcelEditCellKeyboardResponse.ARROW_RIGHT?this.table.selectCell(n+1,i):r===e.ExcelEditCellKeyboardResponse.ARROW_DOWN?this.table.selectCell(n,i+1):r===e.ExcelEditCellKeyboardResponse.ARROW_UP&&this.table.selectCell(n,i-1),t.stopPropagation(),t.preventDefault())}else{const{col:n,row:i}=this.table.stateManager.select.cellPos;if(!this.table.editorManager.editingEditor||r!==e.ExcelEditCellKeyboardResponse.ENTER&&r!==e.ExcelEditCellKeyboardResponse.TAB){if(!this.table.editorManager.editingEditor&&(r===e.ExcelEditCellKeyboardResponse.DELETE||r===e.ExcelEditCellKeyboardResponse.BACKSPACE)){const e=this.table.getSelectedCellInfos();e?.length>0&&function(e,t){for(let r=0;r<e.length;r++)for(let n=0;n<e[r].length;n++)t.changeCellValue(e[r][n].col,e[r][n].row,"")}(e,this.table),t.stopPropagation(),t.preventDefault()}}else this.table.editorManager.completeEdit(),this.table.getElement().focus(),r===e.ExcelEditCellKeyboardResponse.ENTER?this.table.selectCell(n,i+1):r===e.ExcelEditCellKeyboardResponse.TAB&&this.table.selectCell(n+1,i),t.stopPropagation(),t.preventDefault()}}}isExcelShortcutKey(e){return this.responseKeyboard.includes(e.key.toLowerCase())}setResponseKeyboard(e){this.responseKeyboard=e}deleteResponseKeyboard(e){this.responseKeyboard=this.responseKeyboard.filter((t=>!e.includes(t)))}addResponseKeyboard(e){this.responseKeyboard=[...this.responseKeyboard,...e]}release(){document.removeEventListener("keydown",this.handleKeyDown,!0)}},e.ExcelImportPlugin=Oi,e.ExportGanttPlugin=class{id="gantt-export-helper";name="Gantt Export Helper";_gantt=null;run(...e){const t=e[0];t&&(this._gantt=t)}async exportToImage(e={}){if(!this._gantt)return;const{fileName:r="gantt-export",type:n="png",quality:i=1,backgroundColor:s="#ffffff",scale:o=window.devicePixelRatio||1,download:a=!0}=e;try{const{tempContainer:e,clonedGantt:l}=await this.createFullSizeContainer(o);try{await new Promise((e=>t.vglobal.getRequestAnimationFrame()(e)));const e=(l.taskListTableInstance.getAllColsWidth()+l.getAllDateColsWidth())*o,h=l.getAllRowsHeight()*o,c=document.createElement("canvas");c.width=e,c.height=h;const u=c.getContext("2d");u.fillStyle=s,u.fillRect(0,0,e,h),l.taskListTableInstance?.canvas&&u.drawImage(l.taskListTableInstance.canvas,0,0,l.taskListTableInstance.getAllColsWidth()*o,h);const d=3*o,f=l.taskListTableInstance.getAllColsWidth()*o;u.fillStyle="rgb(225, 228, 232)",u.fillRect(f-d/2,0,d,h);const p=4*o,m=l.canvas.width-p;return l.canvas&&u.drawImage(l.canvas,p,0,m,l.canvas.height,(l.taskListTableInstance.getAllColsWidth()+1.5)*o,0,(l.getAllDateColsWidth()-1.5)*o,h),this.finalizeExport(c,r,n,i,a)}finally{e.remove(),l.release()}}catch(e){throw new Error(`甘特图导出失败: ${e instanceof Error?e.message:"未知错误"}`)}}async exportToBase64(e={}){return this.exportToImage({...e,download:!1})}async createFullSizeContainer(e){if(!this._gantt)throw new Error("ExportGanttPlugin: Gantt instance not available to create container.");const t=document.createElement("div");t.style.position="fixed",t.style.left="-9999px",t.style.overflow="hidden",t.style.width=`${window.innerWidth+100}px`,t.style.height=`${window.innerHeight+100}px`,document.body.appendChild(t);const r=document.createElement("div"),n=this._gantt.taskListTableInstance.getAllColsWidth()+this._gantt.getAllDateColsWidth(),i=this._gantt.getAllRowsHeight();r.style.width=`${n}px`,r.style.height=`${i}px`,t.appendChild(r);try{let n;try{if(n=(await import("@visactor/vtable-gantt")).Gantt,!n)throw new Error("Gantt class not found in @visactor/vtable-gantt")}catch(e){throw new Error("导出甘特图需要安装并正确加载 @visactor/vtable-gantt 依赖\n请执行: npm install @visactor/vtable-gantt")}const i=new n(r,{...this._gantt.options,records:this._gantt.records,taskListTable:{...this._gantt.options.taskListTable,tableWidth:void 0,minTableWidth:void 0,maxTableWidth:void 0},plugins:[]});return i.setPixelRatio(e),i.scenegraph?.ganttGroup&&i.scenegraph.ganttGroup.setAttribute("clip",!1),i.taskListTableInstance?.scenegraph?.tableGroup&&i.taskListTableInstance.scenegraph.tableGroup.setAttribute("clip",!1),i.scenegraph.stage.render(),{tempContainer:t,clonedGantt:i}}catch(e){throw t&&t.parentNode&&t.remove(),new Error("导出甘特图需要安装 @visactor/vtable-gantt 依赖")}}finalizeExport(e,t,r,n,i=!0){const s=e.toDataURL(`image/${r}`,n);if(i){const e=document.createElement("a");e.download=`${t}.${r}`,e.href=s,document.body.appendChild(e),e.click(),document.body.removeChild(e)}return s}release(){this._gantt=null}},e.FilterEngine=Ni,e.FilterPlugin=class{id="filter";name="Filter";runTime=[r.TABLE_EVENT_TYPE.BEFORE_INIT,r.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION,r.TABLE_EVENT_TYPE.ICON_CLICK,r.TABLE_EVENT_TYPE.SCROLL];pluginOptions;table;columns;filterEngine;filterStateManager;filterToolbar;constructor(e){this.id=e?.id??this.id,this.pluginOptions=e,this.pluginOptions.filterIcon=e.filterIcon??{name:"filter-icon",type:"svg",width:12,height:12,positionType:r.TYPES.IconPosition.right,cursor:"pointer",svg:'<svg t="1752821809070" class="icon" viewBox="0 0 1664 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="12092" width="200" height="200"><path d="M89.6 179.2A89.6 89.6 0 0 1 89.6 0h1408a89.6 89.6 0 0 1 0 179.2H89.6z m256 384a89.6 89.6 0 0 1 0-179.2h896a89.6 89.6 0 0 1 0 179.2h-896z m256 384a89.6 89.6 0 0 1 0-179.2h384a89.6 89.6 0 0 1 0 179.2h-384z" fill="#93a2b9" p-id="12093"></path></svg>'},this.pluginOptions.filteringIcon=e.filteringIcon??{name:"filtering-icon",type:"svg",width:12,height:12,positionType:r.TYPES.IconPosition.right,cursor:"pointer",svg:'<svg t="1752821771292" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="11926" width="200" height="200"><path d="M971.614323 53.05548L655.77935 412.054233C635.196622 435.434613 623.906096 465.509377 623.906096 496.583302v495.384307c0 28.975686-35.570152 43.063864-55.353551 21.781723l-159.865852-171.256294c-5.495389-5.895053-8.59279-13.688514-8.592789-21.781722V496.583302c0-31.073925-11.290526-61.148688-31.873254-84.429153L52.385677 53.05548C34.200936 32.472751 48.888611 0 76.365554 0h871.268892c27.476943 0 42.164618 32.472751 23.979877 53.05548z" fill="#416eff" p-id="11927"></path></svg>'},this.pluginOptions.filterModes&&this.pluginOptions.filterModes.length||(this.pluginOptions.filterModes=["byValue","byCondition"])}run(...t){const n=t[0],i=t[1],s=t[2];if(this.table=s,i===r.TABLE_EVENT_TYPE.BEFORE_INIT)this.filterEngine=new Ni,this.filterStateManager=new Fi(this.table,this.filterEngine),this.filterToolbar=new is(this.table,this.filterStateManager),this.columns=n.options.columns,this.filterToolbar.render(document.body),this.updateFilterIcons(this.columns),this.filterStateManager.subscribe(((t,r)=>{r?.type!==e.FilterActionType.ADD_FILTER&&(this.updateFilterIcons(this.columns),this.table.updateColumns(this.columns,{clearRowHeightCache:!1}))}));else if(i===r.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION)this.pluginOptions={...this.pluginOptions,...n.options.plugins.find((e=>e.id===this.id)).pluginOptions},this.columns=n.options.columns,this.handleOptionUpdate(n.options);else if(i===r.TABLE_EVENT_TYPE.ICON_CLICK&&"filter-icon"===n.name||"filtering-icon"===n.name){if(3===n.event?.which||2===n.event?.button||2==(2&n.event?.buttons))return;const e=n.col,t=n.row;this.filterToolbar.isVisible?this.filterToolbar.hide():this.filterToolbar.show(e,t,this.pluginOptions.filterModes)}else i===r.TABLE_EVENT_TYPE.SCROLL&&"horizontal"===n.scrollDirection&&this.filterToolbar.adjustMenuPosition()}update(){this.filterStateManager&&this.reapplyActiveFilters()}handleOptionUpdate(e){const t=this.filterStateManager?this.filterStateManager.getActiveFilterFields():[];this.filterStateManager&&t.length>0&&this.validateFilterStatesAfterUpdate(e,t),this.updateFilterIcons(e.columns)}reapplyActiveFilters(){this.filterStateManager.reapplyCurrentFilters()}validateFilterStatesAfterUpdate(t,r){const n=t.columns,i=[];r.forEach((e=>{const t=n.find((t=>t.field===e));t&&this.shouldEnableFilterForColumn(e,t)||i.push(e)})),i.forEach((t=>{this.filterStateManager.dispatch({type:e.FilterActionType.REMOVE_FILTER,payload:{field:t}})}))}updateFilterIcons(e=[]){const t=this.pluginOptions.filterIcon,r=this.pluginOptions.filteringIcon,n=(e,t)=>e===t||e&&t&&"object"==typeof e&&"object"==typeof t&&e.name===t.name;e.forEach((e=>{const i=this.shouldEnableFilterForColumn(e.field,e),s=!!this.filterStateManager.getFilterState(e.field)?.enable;let o=(e=>e?Array.isArray(e)?e:[e]:[])(e.headerIcon);var a;i?s?o.some((e=>n(e,r)))||(o=o.filter((e=>!n(e,t))),o.push(r)):o.some((e=>n(e,t)))||(o=o.filter((e=>!n(e,r))),o.push(t)):o=o.filter((e=>!n(e,t))),e.headerIcon=0===(a=o).length?void 0:1===a.length?a[0]:a}))}shouldEnableFilterForColumn(e,t){if(!t.title)return!1;const r=t;return void 0!==r.filter?!!r.filter:this.pluginOptions.enableFilter?this.pluginOptions.enableFilter(e,t):void 0===this.pluginOptions.defaultEnabled||this.pluginOptions.defaultEnabled}getFilterState(){if(!this.filterStateManager)return null;const e=this.filterStateManager.getAllFilterStates(),t={};return e.filters.forEach(((e,r)=>{t[r]={enable:e.enable,field:e.field,type:e.type,values:e.values,operator:e.operator,condition:e.condition}})),{filters:t}}setFilterState(t){this.filterStateManager&&(this.filterStateManager.dispatch({type:e.FilterActionType.CLEAR_ALL_FILTERS,payload:{}}),t&&t.filters&&Object.entries(t.filters).forEach((([,t])=>{t.enable&&this.filterStateManager.dispatch({type:e.FilterActionType.ADD_FILTER,payload:{field:t.field,type:t.type,values:t.values,operator:t.operator,condition:t.condition,enable:!0}})})))}release(){this.table=null,this.filterEngine=null,this.filterStateManager=null,this.filterToolbar=null}},e.FilterStateManager=Fi,e.FilterToolbar=is,e.FocusHighlightPlugin=class{id="focus-highlight";name="Focus Highlight";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED,r.TABLE_EVENT_TYPE.SELECTED_CELL,r.TABLE_EVENT_TYPE.SELECTED_CLEAR];table;range;pluginOptions;constructor(e={fill:"#000",opacity:.5,highlightRange:void 0}){this.id=e.id??this.id,this.pluginOptions=Object.assign({fill:"#000",opacity:.5},e)}run(...e){if(this.table||(this.table=e[2]),e[1]===r.TABLE_EVENT_TYPE.INITIALIZED)this.pluginOptions.highlightRange&&this.setFocusHighlightRange(this.pluginOptions.highlightRange);else if(e[1]===r.TABLE_EVENT_TYPE.SELECTED_CELL){const e=this.table.stateManager.select.cellPos;if(this.table.isHeader(e.col,e.row))this.setFocusHighlightRange(void 0);else{const e=this.table.stateManager.select.ranges,t=0,r=this.table.colCount-1,n=Math.min(e[0].start.row,e[0].end.row),i=Math.max(e[0].start.row,e[0].end.row);this.setFocusHighlightRange({start:{col:t,row:n},end:{col:r,row:i}})}}else e[1]===r.TABLE_EVENT_TYPE.SELECTED_CLEAR&&this.setFocusHighlightRange(void 0)}setFocusHighlightRange(e,t=!1){let r;e&&"start"in e&&"end"in e?r=e:e&&(r={start:e,end:e}),o(this.range,r)&&!t||(this.range=r,e?this.updateCellGroupShadow():this.deleteAllCellGroupShadow(),this.table.scenegraph.updateNextFrame())}deleteAllCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup)}updateCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup,this.range)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.range,this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup,this.range)}updateCellGroupShadowInContainer(e,r){let n;r&&"start"in r&&"end"in r?n=r:r&&(n={start:r,end:r}),e.forEachChildrenSkipChild((e=>{const r=e;"column"===r.role&&r.forEachChildrenSkipChild((e=>{const r=e;if("cell"!==r.role)return;r.attachShadow(r.shadowRoot);const i=r.shadowRoot;if(n){if(_(n,r.col,r.row))i.removeAllChild();else if(!i.firstChild){const e=t.createRect({x:0,y:0,width:r.attribute.width,height:r.attribute.height,fill:this.pluginOptions.fill,opacity:this.pluginOptions.opacity});e.name="shadow-rect",i.appendChild(e)}}else i.removeAllChild()}))}))}update(){this.setFocusHighlightRange(this.range,!0)}},e.HeaderHighlightPlugin=class{table;options;colHeaderRange;rowHeaderRange;constructor(e,t){this.table=e,this.options=t,this.registerStyle(),this.bindEvent()}registerStyle(){this.table.registerCustomCellStyle("col-highlight",{bgColor:this.options?.colHighlightBGColor??"#82b2f5",color:this.options?.colHighlightColor??"#FFF"}),this.table.registerCustomCellStyle("row-highlight",{bgColor:this.options?.rowHighlightBGColor??"#82b2f5",color:this.options?.rowHighlightColor??"#FFF"})}bindEvent(){this.table.on("selected_cell",(()=>{this.updateHighlight()})),this.table.on("selected_clear",(()=>{this.clearHighlight()})),this.table.on("mousemove_table",(()=>{this.table.stateManager.select.selecting&&this.updateHighlight()}))}clearHighlight(){this.colHeaderRange&&this.table.arrangeCustomCellStyle({range:this.colHeaderRange},void 0),this.rowHeaderRange&&this.table.arrangeCustomCellStyle({range:this.rowHeaderRange},void 0),this.colHeaderRange=void 0,this.rowHeaderRange=void 0}updateHighlight(){if(!1===this.options?.colHighlight&&!1===this.options?.rowHighlight)return;const e=this.table.getSelectedCellRanges();if(0===e.length)return void this.clearHighlight();const t=e[0],r=[t.start.row,t.end.row];r.sort(((e,t)=>e-t));const n=[t.start.col,t.end.col];let i,s;n.sort(((e,t)=>e-t)),this.table.isPivotTable()?(i={start:{col:n[0],row:0},end:{col:n[1],row:this.table.columnHeaderLevelCount-1}},s={start:{col:0,row:r[0]},end:{col:this.table.rowHeaderLevelCount-1,row:r[1]}}):this.table.internalProps.transpose?s={start:{col:0,row:r[0]},end:{col:this.table.rowHeaderLevelCount-1,row:r[1]}}:(i={start:{col:n[0],row:0},end:{col:n[1],row:this.table.columnHeaderLevelCount-1}},this.table.internalProps.rowSeriesNumber&&(s={start:{col:0,row:r[0]},end:{col:0,row:r[1]}})),!1===this.options?.colHighlight||x(this.colHeaderRange,i)||(this.colHeaderRange&&this.table.arrangeCustomCellStyle({range:this.colHeaderRange},void 0),i&&this.table.arrangeCustomCellStyle({range:i},"col-highlight"),this.colHeaderRange=i),!1===this.options?.rowHighlight||x(this.rowHeaderRange,s)||(this.rowHeaderRange&&this.table.arrangeCustomCellStyle({range:this.rowHeaderRange},void 0),s&&this.table.arrangeCustomCellStyle({range:s},"row-highlight"),this.rowHeaderRange=s)}},e.HighlightHeaderWhenSelectCellPlugin=class{id="highlight-header-when-select-cell";name="Highlight Header When Select Cell";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED,r.TABLE_EVENT_TYPE.SELECTED_CLEAR,r.TABLE_EVENT_TYPE.SELECTED_CELL,r.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE];table;pluginOptions;colHeaderRanges=[];rowHeaderRanges=[];constructor(e){this.id=e?.id??this.id,this.pluginOptions=e}run(...e){const t=e[1],n=e[2];this.table=n,t===r.TABLE_EVENT_TYPE.SELECTED_CLEAR?this.clearHighlight():t===r.TABLE_EVENT_TYPE.SELECTED_CELL||t===r.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE?this.updateHighlight():t===r.TABLE_EVENT_TYPE.INITIALIZED&&this.registerStyle()}registerStyle(){this.table.registerCustomCellStyle("col-highlight",{bgColor:this.pluginOptions?.colHighlightBGColor??"#82b2f5",color:this.pluginOptions?.colHighlightColor??"#FFF"}),this.table.registerCustomCellStyle("row-highlight",{bgColor:this.pluginOptions?.rowHighlightBGColor??"#82b2f5",color:this.pluginOptions?.rowHighlightColor??"yellow"})}clearHighlight(){this.colHeaderRanges&&this.colHeaderRanges.forEach((e=>{this.table.arrangeCustomCellStyle({range:e},void 0)})),this.rowHeaderRanges&&this.rowHeaderRanges.forEach((e=>{this.table.arrangeCustomCellStyle({range:e},void 0)})),this.colHeaderRanges=[],this.rowHeaderRanges=[]}updateHighlight(){if(!1===this.pluginOptions?.colHighlight&&!1===this.pluginOptions?.rowHighlight)return;const e=this.table.getSelectedCellRanges();e.length<2&&this.clearHighlight();for(let t=0;t<e.length;t++){const r=e[t],n=[r.start.row,r.end.row];n.sort(((e,t)=>e-t));const i=[r.start.col,r.end.col];let s,o;i.sort(((e,t)=>e-t)),this.table.isPivotTable()?(s={start:{col:i[0],row:0},end:{col:i[1],row:this.table.columnHeaderLevelCount-1}},o={start:{col:0,row:n[0]},end:{col:this.table.rowHeaderLevelCount-1,row:n[1]}}):this.table.internalProps.transpose?o={start:{col:0,row:n[0]},end:{col:this.table.rowHeaderLevelCount-1,row:n[1]}}:(s={start:{col:i[0],row:0},end:{col:i[1],row:this.table.columnHeaderLevelCount-1}},this.table.internalProps.rowSeriesNumber&&(o={start:{col:0,row:n[0]},end:{col:0,row:n[1]}})),!1===this.pluginOptions?.colHighlight||this.colHeaderRanges.find((e=>C(e,s)))||(s&&this.table.arrangeCustomCellStyle({range:s},"col-highlight"),this.colHeaderRanges.push(s)),!1===this.pluginOptions?.rowHighlight||this.rowHeaderRanges.find((e=>C(e,o)))||(o&&this.table.arrangeCustomCellStyle({range:o},"row-highlight"),this.rowHeaderRanges.push(o))}}update(){this.registerStyle(),this.updateHighlight()}release(){this.rowHeaderRanges=[],this.colHeaderRanges=[]}},e.InvertHighlightPlugin=class{table;range;_fill;_opacity;constructor(e,t){this.table=e,this._fill=t?.fill??"#000",this._opacity=t?.opacity??.5}setInvertHighlightRange(e){o(this.range,e)||(this.range=e,e?this.updateCellGroupShadow():this.deleteAllCellGroupShadow(),this.table.scenegraph.updateNextFrame())}deleteAllCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup)}updateCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup,this.range)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.range,this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup,this.range)}updateCellGroupShadowInContainer(e,r){e.forEachChildrenSkipChild((e=>{const n=e;"column"===n.role&&n.forEachChildrenSkipChild((e=>{const n=e;if("cell"!==n.role)return;n.attachShadow(n.shadowRoot);const i=n.shadowRoot;if(r){if(_(r,n.col,n.row))i.removeAllChild();else if(!i.firstChild){const e=t.createRect({x:0,y:0,width:n.attribute.width,height:n.attribute.height,fill:this._fill,opacity:this._opacity});e.name="shadow-rect",i.appendChild(e)}}else i.removeAllChild()}))}))}},e.MENU_CONTAINER_CLASS=S,e.MENU_ITEM_CLASS=T,e.MENU_ITEM_DISABLED_CLASS=R,e.MENU_ITEM_SEPARATOR_CLASS=k,e.MENU_ITEM_SUBMENU_CLASS=M,e.MENU_STYLES=A,e.MasterDetailPlugin=class{id="Master Detail Plugin";name="Master Detail Plugin";runTime=[i.TABLE_EVENT_TYPE.BEFORE_INIT,i.TABLE_EVENT_TYPE.INITIALIZED,i.TABLE_EVENT_TYPE.SORT_CLICK,i.TABLE_EVENT_TYPE.AFTER_SORT,i.TABLE_EVENT_TYPE.AFTER_UPDATE_CELL_CONTENT_WIDTH,i.TABLE_EVENT_TYPE.AFTER_UPDATE_SELECT_BORDER_HEIGHT];pluginOptions;table;configManager;eventManager;subTableManager;tableAPIExtensions;resizeObserver;checkboxCascadeCleanup;constructor(e={}){this.pluginOptions=e}run(...e){const t=e[0],r=e[1],n=e[2];if(r===i.TABLE_EVENT_TYPE.BEFORE_INIT)this.table=n,this.initializeManagers(),this.configManager.injectMasterDetailOptions(t.options);else if(r===i.TABLE_EVENT_TYPE.INITIALIZED)this.setupMasterDetailFeatures();else{if(r===i.TABLE_EVENT_TYPE.SORT_CLICK)return this.eventManager.executeMasterDetailBeforeSort(),!0;r===i.TABLE_EVENT_TYPE.AFTER_SORT?this.eventManager.executeMasterDetailAfterSort():r===i.TABLE_EVENT_TYPE.AFTER_UPDATE_CELL_CONTENT_WIDTH?this.eventManager.handleAfterUpdateCellContentWidth(t):r===i.TABLE_EVENT_TYPE.AFTER_UPDATE_SELECT_BORDER_HEIGHT&&this.eventManager.handleAfterUpdateSelectBorderHeight(t)}}initializeManagers(){this.configManager=new wi(this.pluginOptions,this.table),this.eventManager=new _i(this.table);const e=this.pluginOptions.enableCheckboxCascade??!0;this.subTableManager=new xi(this.table,e),this.configManager.setRowExpandedChecker((e=>this.eventManager.isRowExpanded(e))),this.configManager.setExpandRowCallback((e=>this.expandRow(e))),this.eventManager.setCallbacks({onUpdateSubTablePositions:()=>this.subTableManager.recalculateAllSubTablePositions(),onUpdateSubTablePositionsForRow:()=>this.subTableManager.updateSubTablePositionsForRowResize(),onExpandRow:(e,t)=>this.expandRow(e,t),onCollapseRow:(e,t)=>this.collapseRow(e,t),onCollapseRowToNoRealRecordIndex:e=>this.collapseRowToNoRealRecordIndex(e),onToggleRowExpand:(e,t)=>this.toggleRowExpand(e,t),getOriginalRowHeight:e=>bi(this.table,e)}),this.subTableManager.setCallbacks({getDetailConfigForRecord:(e,t)=>this.configManager.getDetailConfigForRecord(e,t)}),this.subTableManager.setAutoHeightCallback(((e,t)=>{this.handleAutoHeightUpdate(e,t)}))}setupMasterDetailFeatures(){this.initInternalProps(),this.eventManager.bindEventHandlers(),this.setupUnifiedSelectionManagement(),this.extendTableAPI(),this.initCheckboxCascade()}mainTableClickHandler;setupUnifiedSelectionManagement(){this.mainTableClickHandler=()=>{this.clearAllSubTableVisibleSelections()},this.table.on("click_cell",this.mainTableClickHandler)}initCheckboxCascade(){(this.pluginOptions.enableCheckboxCascade??!0)&&(this.checkboxCascadeCleanup=Ei(this.table,this.eventManager))}initInternalProps(){const e=pi(this.table);e.expandedRecordIndices=[],e.subTableInstances=new Map,e.originalRowHeights=new Map,e.subTableCheckboxStates=new Map}extendTableAPI(){this.tableAPIExtensions=new Ci(this.table,this.configManager,this.eventManager,{addUnderlineToCell:e=>this.addUnderlineToCell(e),updateOriginalHeightsAfterAdaptive:e=>this.updateOriginalHeightsAfterAdaptive(e),collapseRowToNoRealRecordIndex:e=>this.collapseRowToNoRealRecordIndex(e),expandRow:e=>this.expandRow(e),restoreExpandedStatesAfter:()=>this.restoreExpandedStatesAfter(),collapseRow:e=>this.collapseRow(e),updateSubTablePositions:()=>this.subTableManager.recalculateAllSubTablePositions(),updateRowHeightForExpand:(e,t)=>this.updateRowHeightForExpand(e,t)}),this.tableAPIExtensions.extendTableAPI()}updateOriginalHeightsAfterAdaptive(e){const t=pi(this.table);for(const[r,n]of e){const e=r-this.table.columnHeaderLevelCount;t.originalRowHeights&&t.originalRowHeights.set(e,n.baseHeight)}}restoreExpandedStatesAfter(){const e=pi(this.table);if(!e.expandedRecordIndices||0===e.expandedRecordIndices.length)return;this.table.dataSource._currentPagerIndexedData&&e.expandedRecordIndices.forEach((e=>{try{const t=this.table.getBodyRowIndexByRecordIndex(e);if(t>=0){const e=t+this.table.columnHeaderLevelCount;this.expandRow(e)}}catch(e){}}))}expandRow(e,t){const r=e-this.table.columnHeaderLevelCount,n=pi(this.table);if(this.eventManager.isRowExpanded(e))return;const i=this.table.getRecordIndexByCell(0,e);if(null==i)return;var s,o;n.expandedRecordIndices&&(s=n.expandedRecordIndices,o=i,s.some((e=>di(e,o)))||n.expandedRecordIndices.push(i)),this.eventManager.addExpandedRow(e);const a=this.table.getRowHeight(e);n.originalRowHeights&&(this.table.scenegraph.getCell(t,e),n.originalRowHeights.set(r,a));const l=mi(this.table,r),h=this.configManager.getDetailConfigForRecord(l,r),c=h?.style?.height||300,u=Array.isArray(l.children)?l.children:[],d="auto"===c?300:"number"==typeof c?c:300;this.updateRowHeightForExpand(e,d),this.table.scenegraph.updateContainerHeight(e,d),n._heightResizedRowMap.add(e),this.subTableManager.renderSubTable(r,u,((e,t)=>this.configManager.getDetailConfigForRecord(e,t))),e!==this.table.rowCount-1&&this.drawUnderlineForRow(e),this.refreshRowIcon(e,t),"adaptive"===this.table.heightMode&&this.table.scenegraph.dealHeightMode(),this.updateFrozenColumnShadowHeight()}handleAutoHeightUpdate(e,t){try{const r=e+this.table.columnHeaderLevelCount,n=this.table.getRowHeight(r),i=pi(this.table),s=i.originalRowHeights?.get(e)||0,o=t-(n-s);this.updateRowHeightForExpand(r,o),this.table.scenegraph.updateContainerHeight(r,o)}catch(e){}}collapseRow(e,t){const r=e-this.table.columnHeaderLevelCount,n=pi(this.table);if(!this.eventManager.isRowExpanded(e))return;const i=this.table.getRecordIndexByCell(0,e);if(null==i)return;if(this.subTableManager.removeSubTable(r),n.expandedRecordIndices){const e=(s=n.expandedRecordIndices,o=i,s.findIndex((e=>di(e,o))));e>-1&&n.expandedRecordIndices.splice(e,1)}var s,o;this.eventManager.removeExpandedRow(e);const a=this.table.getRowHeight(e)-bi(this.table,r);this.updateRowHeightForExpand(e,-a),n._heightResizedRowMap.delete(e),this.table.scenegraph.updateContainerHeight(e,-a),n.originalRowHeights&&n.originalRowHeights.delete(r),e!==this.table.rowCount-1&&this.removeUnderlineFromRow(e),this.refreshRowIcon(e,t),"adaptive"===this.table.heightMode&&this.table.scenegraph.dealHeightMode(),this.updateFrozenColumnShadowHeight()}collapseRowToNoRealRecordIndex(e){const t=e-this.table.columnHeaderLevelCount,r=pi(this.table);if(!this.eventManager.isRowExpanded(e))return;this.subTableManager.removeSubTable(t),this.eventManager.removeExpandedRow(e);const n=this.table.getRowHeight(e)-bi(this.table,t);this.updateRowHeightForExpand(e,-n),r._heightResizedRowMap.delete(e),this.table.scenegraph.updateContainerHeight(e,-n),r.originalRowHeights&&r.originalRowHeights.delete(t),e!==this.table.rowCount-1&&this.removeUnderlineFromRow(e),this.refreshRowIcon(e),"adaptive"===this.table.heightMode&&this.table.scenegraph.dealHeightMode(),this.updateFrozenColumnShadowHeight()}toggleRowExpand(e,t){this.eventManager.isRowExpanded(e)?this.collapseRow(e,t):this.expandRow(e,t)}updateRowHeightForExpand(e,t){this.table._setRowHeight(e,this.table.getRowHeight(e)+t,!0);const r=e+1;let n=0;n=e<this.table.frozenRowCount?this.table.frozenRowCount-1:e>=this.table.rowCount-this.table.bottomFrozenRowCount?this.table.rowCount-1:Math.min(this.table.scenegraph.proxy.rowEnd,this.table.rowCount-this.table.bottomFrozenRowCount-1);for(let e=0;e<this.table.colCount;e++)for(let i=r;i<=n;i++){const r=this.table.scenegraph.highPerformanceGetCell(e,i);"cell"===r.role&&r.setAttribute("y",r.attribute.y+t)}}drawUnderlineForRow(e){if(!this.table.scenegraph)return;const t=this.getRowCells(e);0!==t.length&&(t.forEach(((e,t)=>{e&&e.attribute&&this.addUnderlineToCell(e)})),this.table.scenegraph.updateNextFrame())}getRowCells(e){const t=[];for(let r=0;r<this.table.colCount;r++){const n=this.table.scenegraph.getCell(r,e);n&&"cell"===n.role&&t.push(n)}return t}addUnderlineToCell(e){const t=e.attribute,r=t.strokeArrayWidth||(t.lineWidth?[t.lineWidth,t.lineWidth,t.lineWidth,t.lineWidth]:[1,1,1,1]),n=t.strokeArrayColor||(t.stroke?[t.stroke,t.stroke,t.stroke,t.stroke]:["transparent","transparent","transparent","transparent"]);e._hasUnderline||(e._originalStrokeArrayWidth=[...r],e._originalStrokeArrayColor=[...n],e._hasUnderline=!0);const i=e._originalStrokeArrayWidth||r,s=e._originalStrokeArrayColor||n,o=[...i],a=[...s],l=2*(.75*(i[2]||1)+.75*(i[0]||1));if(o[2]=l,"transparent"!==s[2]&&s[2])a[2]=s[2];else{const e=this.table.theme;a[2]=e?.bodyStyle?.borderColor||"#e1e4e8"}e.setAttributes({strokeArrayWidth:o,strokeArrayColor:a,stroke:!0})}removeUnderlineFromRow(e){this.getRowCells(e).forEach(((e,t)=>{e&&e._hasUnderline&&this.removeUnderlineFromCell(e)})),this.table.scenegraph.updateNextFrame()}removeUnderlineFromCell(e){e._hasUnderline&&(e._originalStrokeArrayWidth&&e._originalStrokeArrayColor&&(e.setAttributes({strokeArrayWidth:e._originalStrokeArrayWidth,strokeArrayColor:e._originalStrokeArrayColor}),delete e._originalStrokeArrayWidth,delete e._originalStrokeArrayColor),e._hasUnderline=!1)}refreshRowIcon(e,t){let r;if("number"==typeof t)r=t;else{r=!!this.table.options.rowSeriesNumber?1:0}const n=this.table.getCellOriginRecord(r,e);if(n&&"object"==typeof n){const t=n,s=i.TYPES.HierarchyState,o=this.eventManager.isRowExpanded(e);t.hierarchyState=o?s.expand:s.collapse,this.table.scenegraph.updateHierarchyIcon(r,e)}}setRecordChildren(e,t,r){const n=this.table.getRecordIndexByCell(t,r);if(null==n)return;const i="number"==typeof n?n:n[0],s=this.table.dataSource.get(i);s&&(s.children=e,this.expandRow(r,t),this.table.scenegraph.updateCellContent(t,r))}release(){const e=pi(this.table);e&&(e._isReleasing=!0);try{if(this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0),this.checkboxCascadeCleanup){try{this.checkboxCascadeCleanup()}catch(e){}this.checkboxCascadeCleanup=void 0}if(this.eventManager)try{this.eventManager.cleanup()}catch(e){}if(this.subTableManager)try{this.subTableManager.cleanup()}catch(e){}if(this.configManager)try{this.configManager.release()}catch(e){}if(this.cleanupMasterDetailFeatures(),this.table&&e)try{e.expandedRecordIndices?.splice(0),e.subTableInstances?.clear(),e.originalRowHeights?.clear(),e.subTableCheckboxStates?.clear(),e._heightResizedRowMap?.clear()}catch(e){}}catch(e){}finally{try{this.configManager=null,this.eventManager=null,this.subTableManager=null,this.tableAPIExtensions=null,this.table=null,this.pluginOptions=null}catch(e){}}}clearAllSubTableVisibleSelections(){const e=pi(this.table);e.subTableInstances?.forEach((e=>{e&&"function"==typeof e.clearSelected&&e.clearSelected()}))}getAllSubTableInstances(){return this.subTableManager.getAllSubTableInstances()}getSubTableByRowIndex(e){const t=e-this.table.columnHeaderLevelCount;return this.subTableManager.getSubTableInstance(t)}getSubTableByBodyRowIndex(e){return this.subTableManager.getSubTableInstance(e)}filterSubTables(e){const t=[],r=this.subTableManager.getAllSubTableInstances();if(!r)return t;for(const[n,i]of r)try{e(n,i,mi(this.table,n))&&t.push({bodyRowIndex:n,subTable:i})}catch(e){}return t}updateFrozenColumnShadowHeight(){try{const e=this.table.frozenColCount;e>0&&this.table.scenegraph.component.setFrozenColumnShadow(e-1)}catch(e){}}cleanupMasterDetailFeatures(){this.mainTableClickHandler&&(this.table.off("click_cell",this.mainTableClickHandler),this.mainTableClickHandler=void 0),this.tableAPIExtensions&&(this.tableAPIExtensions.cleanup(),this.tableAPIExtensions=void 0)}},e.MenuManager=F,e.PasteAddRowColumnPlugin=class{id="paste-add-row-column";name="Paste Add row";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED,r.TABLE_EVENT_TYPE.PASTED_DATA];table;pluginOptions;pastedData;constructor(e){this.pluginOptions=e,this.id=e?.id??this.id}run(...e){const t=e[1],n=e[2];this.table=n,t===r.TABLE_EVENT_TYPE.PASTED_DATA&&(this.pastedData=e[0],this.handlePaste())}handlePaste(){const{pasteData:e,row:t,col:r}=this.pastedData,n=this.table.rowCount,i=this.table.colCount,s=t+e.length-n,o=r+(e[0]?.length||0)-i;if(s>0)for(let e=0;e<s;e++)this.pluginOptions?.addRowCallback?this.pluginOptions.addRowCallback(n+e,this.table):this.table.addRecord([]);if(o>0)for(let e=0;e<o;e++){const t=i+e;this.pluginOptions?.addColumnCallback?this.pluginOptions.addColumnCallback(t,this.table):this.table.addColumns([{field:`field_${t}`,title:`New Column ${t}`,width:100}])}this.table.changeCellValues(r,t,e,!0)}release(){this.table.internalProps.handler.clear()}},e.RotateTablePlugin=class{id="rotate-table";name="Rotate Table";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED];table;matrix;vglobal_mapToCanvasPoint;constructor(e){this.id=e?.id??this.id}run(...e){const t=e[2];this.table=t,this.table.rotate90WithTransform=V.bind(this.table),this.table.cancelTransform=$.bind(this.table)}release(){}},e.RowSeriesPlugin=class{id="row-series";name="Row Series";runTime=[r.TABLE_EVENT_TYPE.BEFORE_INIT,r.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];pluginOptions;table;constructor(e){this.id=e.id??this.id,this.pluginOptions=Object.assign({rowCount:100},e)}run(...e){if(e[1]===r.TABLE_EVENT_TYPE.BEFORE_INIT){const t=e[0],r=e[2];this.table=r;const n=t.options,i=n.records??[];for(let e=i.length;e<this.pluginOptions.rowCount;e++)i.push(this.pluginOptions.fillRowRecord?this.pluginOptions.fillRowRecord(e):{});n.records=i,this.pluginOptions.rowSeriesNumber?(n.rowSeriesNumber=this.pluginOptions.rowSeriesNumber,this.pluginOptions.rowSeriesNumber.width||(n.rowSeriesNumber.width="auto")):n.rowSeriesNumber||(n.rowSeriesNumber={width:"auto"})}else if(e[1]===r.TABLE_EVENT_TYPE.BEFORE_KEYDOWN){const t=e[0].event;this.pluginOptions.autoExtendRowTriggerKeys?.includes(t.key)&&this.table.stateManager.select.cellPos.row===this.table.rowCount-1&&this.table.addRecord(this.pluginOptions.fillRowRecord?this.pluginOptions.fillRowRecord(this.table.rowCount-this.table.columnHeaderLevelCount):{})}}},e.TableCarouselAnimationPlugin=class{id="table-carousel-animation";name="Table Carousel Animation";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED];table;rowCount;colCount;animationDuration;animationDelay;animationEasing;playing;row;col;willUpdateRow=!1;willUpdateCol=!1;autoPlay;autoPlayDelay;customDistRowFunction;customDistColFunction;constructor(e={}){this.id=e.id??this.id,this.rowCount=e?.rowCount??void 0,this.colCount=e?.colCount??void 0,this.animationDuration=e?.animationDuration??500,this.animationDelay=e?.animationDelay??1e3,this.animationEasing=e?.animationEasing??"linear",this.autoPlay=e?.autoPlay??!1,this.autoPlayDelay=e?.autoPlayDelay??0,this.customDistColFunction=e.customDistColFunction,this.customDistRowFunction=e.customDistRowFunction}run(...e){this.table||(this.table=e[2]),this.reset(),this.autoPlay&&setTimeout((()=>{this.play()}),this.autoPlayDelay)}reset(){this.playing=!1,this.row=this.table.frozenRowCount,this.col=this.table.frozenColCount}play(){if(!this.table)throw new Error("table is not initialized");this.playing=!0,this.rowCount&&!this.willUpdateRow?this.updateRow():this.colCount&&!this.willUpdateCol&&this.updateCol()}pause(){this.playing=!1}updateRow(){if(!this.playing||this.table.isReleased)return;let e=!0;const t=Math.max(this.table.scenegraph.proxy.screenTopRow,this.table.frozenRowCount),r=this.customDistRowFunction&&this.customDistRowFunction(this.row,this.table);r?(this.row=r.distRow,e=r.animation??!0):U(this.row)&&t!==this.row?(this.row=this.table.frozenRowCount,e=!1):U(this.row)||t===Math.floor(this.row)?this.row+=this.rowCount:(this.row=this.table.frozenRowCount,e=!1),this.table.scrollToRow(this.row,e?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateRow=!0,setTimeout((()=>{this.willUpdateRow=!1,this.updateRow()}),this.animationDuration+this.animationDelay)}updateCol(){if(!this.playing||this.table.isReleased)return;let e=!0;const t=this.customDistColFunction&&this.customDistColFunction(this.col,this.table);t?(this.col=t.distCol,e=t.animation??!0):U(this.col)&&this.table.scenegraph.proxy.screenLeftCol!==this.col?(this.col=this.table.frozenColCount,e=!1):U(this.col)||this.table.scenegraph.proxy.screenLeftCol===Math.floor(this.col)?this.col+=this.colCount:(this.col=this.table.frozenColCount,e=!1),this.table.scrollToCol(this.col,e?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateCol=!0,setTimeout((()=>{this.willUpdateCol=!1,this.updateCol()}),this.animationDuration+this.animationDelay)}release(){}},e.TableExportPlugin=class{id="table-export-plugin";name="TableExport";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED];table;pluginOptions;constructor(e){this.pluginOptions=Object.assign({exportOnIdle:!1,exportExcelOptions:{downloadFile:!0,fileName:"export"},exportCsvOptions:{downloadFile:!0,fileName:"export"}},e)}run(...e){e[1]===r.TABLE_EVENT_TYPE.INITIALIZED&&(e[0],this.table=e[2],this.table.exportToCsv=()=>{const e=this.pluginOptions.exportCsvOptions;return e.downloadFile?async function(e,t){const r=new Blob([`\ufeff${e}`],{type:"text/csv;charset=utf-8"});await Is.saveAs(r,`${t}.csv`)}(Ss(this.table,e),e.fileName||"export"):Ss(this.table,e)},this.table.exportToExcel=async()=>{const e=this.pluginOptions.exportExcelOptions;return e.downloadFile?await async function(e,t){const r=new Blob([e],{type:"application/octet-stream"});await Is.saveAs(r,`${t}.xlsx`)}(await _s(this.table,e,this.pluginOptions.exportOnIdle),e.fileName||"export"):_s(this.table,e,this.pluginOptions.exportOnIdle)})}release(){this.table&&(delete this.table.exportToCsv,delete this.table.exportToExcel,this.table=null)}},e.TableSeriesNumber=class{id="table-series-number";name="Table Series Number";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED,r.TABLE_EVENT_TYPE.BEFORE_INIT,r.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION,r.TABLE_EVENT_TYPE.UPDATED];pluginOptions;table;seriesNumberComponent;componentLayoutLayer;lastCurrentRow=0;lastCurrentCol=0;startRowIndex=0;scrollTimer;constructor(e){this.pluginOptions=e,this.seriesNumberComponent=new t.TableSeriesNumber({rowCount:e.rowCount,colCount:e.colCount,rowSeriesNumberWidth:e.rowSeriesNumberWidth,colSeriesNumberHeight:e.colSeriesNumberHeight,rowSeriesNumberGenerate:e.rowSeriesNumberGenerate,colSeriesNumberGenerate:e.colSeriesNumberGenerate,rowSeriesNumberCellStyle:Object.assign({text:{fontSize:14,fill:"#7A7A7A",pickable:!1,textAlign:"left",textBaseline:"middle",padding:[2,4,2,4]},borderLine:{stroke:"#D9D9D9",lineWidth:1,pickable:!1},bgColor:"#F9F9F9",states:{hover:{fill:"#c8daf6",opacity:.7},select:{fill:"#c8daf6",opacity:1}}},e.rowSeriesNumberCellStyle),colSeriesNumberCellStyle:Object.assign({text:{fontSize:14,fill:"#7A7A7A",pickable:!1,textAlign:"left",textBaseline:"middle",padding:[2,4,2,4]},borderLine:{stroke:"#D9D9D9",lineWidth:1,pickable:!1},bgColor:"#F9F9F9",states:{hover:{fill:"#c8daf6",opacity:.7},select:{fill:"#c8daf6",opacity:1}}},e.colSeriesNumberCellStyle),cornerCellStyle:Object.assign({borderLine:{stroke:"#D9D9D9",lineWidth:1,pickable:!1},bgColor:"#F9F9F9",states:{hover:{fill:"#98C8A5",opacity:.7},select:{fill:"#98C8A5",opacity:1}}},e.cornerCellStyle),checkMoveColumnOrder:e=>!!this.pluginOptions.dragOrder?.enableDragColumnOrder&&this.table.isColumnSelected(e),checkMoveRowOrder:e=>!!this.pluginOptions.dragOrder?.enableDragRowOrder&&this.table.isRowSelected(e)}),this.listenComponentEvents()}run(...e){const t=e[1];if(t===r.TABLE_EVENT_TYPE.BEFORE_INIT||t===r.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION){const t=e[0],r=e[2];this.table=r;const n=t.options,i=n.records??[];i.length<this.pluginOptions.rowCount&&(i.length=this.pluginOptions.rowCount),n.records=i,n.columns||(n.columns=[]);for(let e=n.columns.length;e<this.pluginOptions.colCount;e++){const t={field:e,key:e,title:""};n.columns.push(t)}const s=this.seriesNumberComponent.rowSeriesNumberWidth,o=this.seriesNumberComponent.colSeriesNumberHeight;n.contentOffsetX=s,n.contentOffsetY=o}else if(t===r.TABLE_EVENT_TYPE.INITIALIZED||t===r.TABLE_EVENT_TYPE.UPDATED){this.table=e[2],this.table.options.customConfig||(this.table.options.customConfig={}),this.table.options.customConfig.cancelSelectCellHook=e=>!e.target.isDescendantsOf(this.seriesNumberComponent),this.seriesNumberComponent.setAttributes({rowCount:this.table.rowCount,colCount:this.table.colCount,frozenRowCount:this.table.frozenRowCount,frozenColCount:this.table.frozenColCount,rightFrozenColCount:this.table.rightFrozenColCount,bottomFrozenRowCount:this.table.bottomFrozenRowCount});const t=this.table.scenegraph.stage.createLayer();t.appendChild(this.seriesNumberComponent),t.setAttributes({pickable:!1}),this.componentLayoutLayer=t,this.syncRowHeightToComponent(),this.syncColWidthToComponent(),this.listenTableEvents()}}handleScroll=()=>{this.scrollTimer&&(clearTimeout(this.scrollTimer),this.scrollTimer=null),this.scrollTimer=setTimeout((()=>{this.scrollTimer=null,this.syncScrollToComponent()}),10)};handleAfterSort=()=>{this.syncScrollToComponent()};handleSelectedChanged=e=>{this.seriesNumberComponent.removeAllSelectedIndexs();const t=this.table.stateManager.select.ranges,r=[],n=[];for(const e of t){const{row:t,col:i}=e.start,{row:s,col:o}=e.end;r.push({startIndex:Math.min(t,s),endIndex:Math.max(t,s)}),n.push({startIndex:Math.min(i,o),endIndex:Math.max(i,o)})}this.seriesNumberComponent.addRowSelectedRanges(r),this.seriesNumberComponent.addColSelectedRanges(n),this.table.stateManager.select.isSelectAll&&this.seriesNumberComponent.addCornderSelected(),this.seriesNumberComponent.renderSelectedIndexsState()};handleResizeColumnEnd=e=>{this.seriesNumberComponent.setAttribute("hover",!0)};handleResizeRowEnd=e=>{this.seriesNumberComponent.setAttribute("hover",!0)};handleChangeHeaderPosition=e=>{this.syncColWidthToComponent()};listenTableEvents(){this.table.on(r.TABLE_EVENT_TYPE.SCROLL,this.handleScroll),this.table.on(r.TABLE_EVENT_TYPE.AFTER_SORT,this.handleAfterSort),this.table.on(r.TABLE_EVENT_TYPE.SELECTED_CHANGED,this.handleSelectedChanged),this.table.on(r.TABLE_EVENT_TYPE.RESIZE_COLUMN_END,this.handleResizeColumnEnd),this.table.on(r.TABLE_EVENT_TYPE.RESIZE_ROW_END,this.handleResizeRowEnd),this.table.on(r.TABLE_EVENT_TYPE.CHANGE_HEADER_POSITION,this.handleChangeHeaderPosition)}handleSeriesNumberCellRightClick=e=>{const{seriesNumberCell:t,event:n,isDragSelect:i}=e.detail,s=t.name.includes("row"),o=t.name.includes("col");if(s){const e=t.id;this.table.stateManager.select.ranges.some((t=>t.start.row<=e&&e<=t.end.row&&0===t.start.col&&t.end.col===this.table.colCount-1))||this.table.selectCells([{start:{row:e,col:0},end:{row:e,col:this.table.colCount-1}}]),this.table.fireListeners(r.TABLE_EVENT_TYPE.PLUGIN_EVENT,{plugin:this,event:n,pluginEventInfo:{eventType:"rightclick",rowIndex:e}})}else if(o){const e=t.id;this.table.stateManager.select.ranges.some((t=>t.start.col<=e&&e<=t.end.col&&0===t.start.row&&t.end.row===this.table.rowCount-1))||this.table.selectCells([{start:{row:0,col:e},end:{row:this.table.rowCount-1,col:e}}]),this.table.fireListeners(r.TABLE_EVENT_TYPE.PLUGIN_EVENT,{plugin:this,event:n,pluginEventInfo:{eventType:"rightclick",colIndex:e}})}else this.table.selectCells([{start:{row:0,col:0},end:{row:this.table.rowCount-1,col:this.table.colCount-1}}]),this.table.fireListeners(r.TABLE_EVENT_TYPE.PLUGIN_EVENT,{plugin:this,event:n,pluginEventInfo:{eventType:"rightclick",isCorner:!0}})};handleSeriesNumberCellHover=e=>{this.table.scenegraph.renderSceneGraph()};handleSeriesNumberCellUnHover=e=>{this.table.scenegraph.renderSceneGraph()};handleSeriesNumberCellClick=e=>{const{seriesNumberCell:t,event:r,isDragSelect:n}=e.detail,i=this.table.options.keyboardOptions?.ctrlMultiSelect??!0,s=this.table.options.keyboardOptions?.shiftMultiSelect??!0,o=(r.nativeEvent.ctrlKey||r.nativeEvent.metaKey)&&i,a=r.nativeEvent.shiftKey&&s,l=t.name.includes("row"),h=t.name.includes("col");if(l){this.table.stateManager.setSelectInline("row");const e=t.id;n?this.table.dragSelectRow(e,o):this.table.startDragSelectRow(e,o,a)}else if(h){this.table.stateManager.setSelectInline("col");const e=t.id;n?this.table.dragSelectCol(e,o):this.table.startDragSelectCol(e,o,a)}else this.table.eventManager.deelTableSelectAll()};handleSeriesNumberCellClickUp=e=>{this.table.stateManager.setSelectInline(!1),this.table.endDragSelect()};handleRowSeriesNumberWidthChange=e=>{const t=this.seriesNumberComponent.rowSeriesNumberWidth,r=this.seriesNumberComponent.colSeriesNumberHeight;this.table.setContentInsetXY(t,r)};handleResizeColWidthStart=e=>{this.seriesNumberComponent.setAttribute("hover",!1);const{colIndex:t,event:n}=e.detail;this.table.stateManager.updateInteractionState(r.TYPES.InteractionState.grabing),this.table.stateManager.startResizeCol(t,n.viewport.x,n.viewport.y)};handleResizeRowHeightStart=e=>{this.seriesNumberComponent.setAttribute("hover",!1);const{rowIndex:t,event:n}=e.detail;this.table.stateManager.updateInteractionState(r.TYPES.InteractionState.grabing),this.table.stateManager.startResizeRow(t,n.viewport.x,n.viewport.y)};handleDragColumOrderStart=e=>{const{colIndex:t,event:n}=e.detail;this.table.stateManager.updateInteractionState(r.TYPES.InteractionState.grabing),this.table.stateManager.startMoveCol(t,0,n.viewport.x,n.viewport.y,n.nativeEvent,"column")};handleDragRowOrderStart=e=>{const{rowIndex:t,event:n}=e.detail;this.table.stateManager.updateInteractionState(r.TYPES.InteractionState.grabing),this.table.stateManager.startMoveCol(0,t,n.viewport.x,n.viewport.y,n.nativeEvent,"row")};listenComponentEvents(){this.seriesNumberComponent.on(t.SeriesNumberEvent.seriesNumberCellRightClick,this.handleSeriesNumberCellRightClick),this.seriesNumberComponent.on(t.SeriesNumberEvent.seriesNumberCellHover,this.handleSeriesNumberCellHover),this.seriesNumberComponent.on(t.SeriesNumberEvent.seriesNumberCellUnHover,this.handleSeriesNumberCellUnHover),this.seriesNumberComponent.on(t.SeriesNumberEvent.seriesNumberCellClick,this.handleSeriesNumberCellClick),this.seriesNumberComponent.on(t.SeriesNumberEvent.seriesNumberCellClickUp,this.handleSeriesNumberCellClickUp),this.seriesNumberComponent.on(t.SeriesNumberEvent.rowSeriesNumberWidthChange,this.handleRowSeriesNumberWidthChange),this.seriesNumberComponent.on(t.SeriesNumberEvent.resizeColWidthStart,this.handleResizeColWidthStart),this.seriesNumberComponent.on(t.SeriesNumberEvent.resizeRowHeightStart,this.handleResizeRowHeightStart),this.pluginOptions.dragOrder?.enableDragColumnOrder&&this.seriesNumberComponent.on(t.SeriesNumberEvent.dragColumnOrderStart,this.handleDragColumOrderStart),this.pluginOptions.dragOrder?.enableDragRowOrder&&this.seriesNumberComponent.on(t.SeriesNumberEvent.dragRowOrderStart,this.handleDragRowOrderStart)}release(){this.componentLayoutLayer&&(this.table.scenegraph.stage.removeLayer(this.componentLayoutLayer._uid),this.componentLayoutLayer=null),this.scrollTimer&&(clearTimeout(this.scrollTimer),this.scrollTimer=null),this.table&&(this.table.off(r.TABLE_EVENT_TYPE.SCROLL,this.handleScroll),this.table.off(r.TABLE_EVENT_TYPE.AFTER_SORT,this.handleAfterSort),this.table.off(r.TABLE_EVENT_TYPE.SELECTED_CHANGED,this.handleSelectedChanged),this.table.off(r.TABLE_EVENT_TYPE.RESIZE_COLUMN_END,this.handleResizeColumnEnd),this.table.off(r.TABLE_EVENT_TYPE.RESIZE_ROW_END,this.handleResizeRowEnd)),this.seriesNumberComponent&&(this.seriesNumberComponent.off(t.SeriesNumberEvent.seriesNumberCellRightClick,this.handleSeriesNumberCellRightClick),this.seriesNumberComponent.off(t.SeriesNumberEvent.seriesNumberCellHover,this.handleSeriesNumberCellHover),this.seriesNumberComponent.off(t.SeriesNumberEvent.seriesNumberCellUnHover,this.handleSeriesNumberCellUnHover),this.seriesNumberComponent.off(t.SeriesNumberEvent.seriesNumberCellClick,this.handleSeriesNumberCellClick),this.seriesNumberComponent.off(t.SeriesNumberEvent.seriesNumberCellClickUp,this.handleSeriesNumberCellClickUp),this.seriesNumberComponent.off(t.SeriesNumberEvent.rowSeriesNumberWidthChange,this.handleRowSeriesNumberWidthChange),this.seriesNumberComponent.off(t.SeriesNumberEvent.resizeColWidthStart,this.handleResizeColWidthStart),this.seriesNumberComponent.off(t.SeriesNumberEvent.resizeRowHeightStart,this.handleResizeRowHeightStart),this.seriesNumberComponent.release?.(),this.seriesNumberComponent=null)}syncRowHeightToComponent(){const{rowStart:e,rowEnd:t}=this.table.getBodyVisibleRowRange(),r=Math.max(e-2,this.table.frozenRowCount),n=Math.min(t+2,this.table.rowCount-1);this.table.frozenRowCount!==this.seriesNumberComponent.getAttributes().frozenRowCount&&this.seriesNumberComponent.setAttributes({frozenRowCount:this.table.frozenRowCount}),this.seriesNumberComponent.recreateCellsToRowSeriesNumberGroup(r,n);for(let e=0;e<this.table.frozenRowCount;e++){const t=this.table.scenegraph.getCell(0,e).getAttributes();this.seriesNumberComponent.setRowSeriesNumberCellAttributes(e,{y:t.y,height:t.height})}for(let e=r;e<=n;e++){const t=this.table.scenegraph.getCell(0,e).getAttributes();this.seriesNumberComponent.setRowSeriesNumberCellAttributes(e,{y:t.y,height:t.height})}}syncColWidthToComponent(){const{colStart:e,colEnd:t}=this.table.getBodyVisibleColRange(),r=e,n=Math.min(t,this.table.scenegraph.proxy.colEnd);this.table.frozenColCount!==this.seriesNumberComponent.getAttributes().frozenColCount&&this.seriesNumberComponent.setAttributes({frozenColCount:this.table.frozenColCount}),this.seriesNumberComponent.recreateCellsToColSeriesNumberGroup(r,n);for(let e=0;e<this.table.frozenColCount;e++){const t=this.table.scenegraph.getColGroup(e).getAttributes();this.seriesNumberComponent.setColSeriesNumberCellAttributes(e,{x:t.x,width:t.width})}for(let e=r;e<=n;e++){const t=this.table.scenegraph.getColGroup(e).getAttributes();this.seriesNumberComponent.setColSeriesNumberCellAttributes(e,{x:t.x,width:t.width})}}syncScrollToComponent(){this.syncRowHeightToComponent(),this.syncColWidthToComponent();const e=this.table.scenegraph.bodyGroup.getAttributes().y,t=this.table.scenegraph.bodyGroup.getAttributes().x;this.seriesNumberComponent.setRowSeriesNumberGroupAttributes({y:e+this.seriesNumberComponent.colSeriesNumberHeight}),this.seriesNumberComponent.setColSeriesNumberGroupAttributes({x:t+this.seriesNumberComponent.rowSeriesNumberWidth})}},e.ValueFilter=rs,e.WpsFillHandlePlugin=class{id="wps-fill-handle";name="WPS Fill Handle";runTime=[r.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE,r.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END];table;pluginOptions;beforeDragMinCol=0;beforeDragMinRow=0;beforeDragMaxCol=0;beforeDragMaxRow=0;constructor(e){this.id=e?.id??this.id,this.pluginOptions=e}run(...e){if(e[1]===r.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE){e[0];const t=e[2];this.table=t;const r=this.table?.getSelectedCellRanges()[0];if(!r)return;this.beforeDragMaxCol=Math.max(r.start.col,r.end.col),this.beforeDragMinCol=Math.min(r.start.col,r.end.col),this.beforeDragMaxRow=Math.max(r.start.row,r.end.row),this.beforeDragMinRow=Math.min(r.start.row,r.end.row)}else if(e[1]===r.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END){const t=e[0].direction;let r,n;const i=this.table?.getSelectedCellRanges()[0];if(!i)return;"bottom"===t?(r=this.beforeDragMaxCol,n=i.end.row):"right"===t?(r=i.end.col,n=this.beforeDragMaxRow):"top"===t?(r=this.beforeDragMaxCol,n=i.end.row):"left"===t&&(r=i.end.col,n=this.beforeDragMaxRow);const s=this.table?.records,o=this.table?.getAllColumnHeaderCells()||[];let a=[];o?.length&&(a=o[o.length-1]);const l=ui(s,a,{startRow:this.beforeDragMinRow-o.length,startCol:this.beforeDragMinCol,endRow:this.beforeDragMaxRow-o.length,endCol:this.beforeDragMaxCol},{row:n-o.length,col:r});this.table?.setRecords(l)}}handleKeyDown(){if(this.table.editorManager){const e=this.table?.getSelectedCellRanges()[0];if(!e)return;this.beforeDragMaxCol=Math.max(e.start.col,e.end.col),this.beforeDragMinCol=Math.min(e.start.col,e.end.col),this.beforeDragMaxRow=Math.max(e.start.row,e.end.row),this.beforeDragMinRow=Math.min(e.start.row,e.end.row)}}release(){this.beforeDragMinCol=0,this.beforeDragMinRow=0,this.beforeDragMaxCol=0,this.beforeDragMaxRow=0}},e.applyStyles=I,e.cancelTransform=$,e.createElement=O,e.createIcon=N,e.createNumberInputItem=function(e,t=1,r,n){const i=O("div");if(I(i,A.inputContainer),r){const e=N(r);i.appendChild(e)}const s=O("label");s.textContent=e,I(s,A.inputLabel),i.appendChild(s);const o=O("input");o.type="number",o.min="1",o.value=t.toString(),I(o,A.inputField),i.appendChild(o);const a=O("div");return a.appendChild(i),a},e.rotate90WithTransform=V}));
37
+ function n(e){return e>=65&&e<=90||95===e||e>=97&&e<=122||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}Object.defineProperty(r,"__esModule",{value:!0}),r.NC_NAME_START_CHAR="A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",r.NC_NAME_CHAR="-"+r.NC_NAME_START_CHAR+".0-9·̀-ͯ‿-⁀",r.NC_NAME_START_CHAR_RE=new RegExp("^["+r.NC_NAME_START_CHAR+"]$","u"),r.NC_NAME_CHAR_RE=new RegExp("^["+r.NC_NAME_CHAR+"]$","u"),r.NC_NAME_RE=new RegExp("^["+r.NC_NAME_START_CHAR+"]["+r.NC_NAME_CHAR+"]*$","u"),r.isNCNameStartChar=n,r.isNCNameChar=function(e){return n(e)||45===e||46===e||e>=48&&e<=57||183===e||e>=768&&e<=879||e>=8255&&e<=8256}},{}]},{},[15])(15)}(Ri);var ki,Mi,Ai=l(Ri.exports);class Oi{id="excel-import-plugin";name="ExcelImportPlugin";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED];options;_tableInstance=null;constructor(e){this.options={autoTable:!0,autoColumns:!0,delimiter:",",exportData:!1,batchSize:1e3,enableBatchProcessing:!0,asyncDelay:5,...e},e?.id&&(this.id=e.id)}run(...e){const t=e[2];this._tableInstance=t,this._tableInstance.importFile=()=>{this.import("file")}}release(){this._tableInstance=null}async importFile(){return this.import("file")}async import(e,t,r){const n={...this.options,...r};if("file"===e)return this._importFromFileDialog(n);if("string"==typeof t)return this._importFromString(e,t,n);if(Array.isArray(t)||"object"==typeof t){if("json"!==e)throw new Error("只有JSON格式支持从对象导入");return this._importFromData("json",t,n)}throw new Error("Invalid import source")}async _importFromFileDialog(e){return new Promise(((t,r)=>{if(!this._tableInstance)return void r(new Error("表格实例不存在或已销毁,无法导入数据!"));const n=document.createElement("input");n.type="file",n.style.display="none",document.body.appendChild(n),n.addEventListener("change",(async i=>{try{const s=i.target.files?.[0];if(!s)return document.body.removeChild(n),void r(new Error("未选择文件"));const o=await this._parseFile(s,e);e.autoTable&&this._tableInstance&&(e.autoColumns&&this._tableInstance.updateOption(Object.assign({},this._tableInstance.options,{columns:o.columns})),this._tableInstance.setRecords(o.records)),n.value="",document.body.removeChild(n),t(o)}catch(e){document.body.removeChild(n),r(e)}})),n.click()}))}async _importFromString(e,t,r){let n;switch(e){case"csv":n=await this._parseCSVString(t,r);break;case"json":n=await this._parseJSONString(t,r);break;case"html":n=await this._parseHTMLString(t,r);break;default:throw new Error(`不支持的导入类型: ${e}`)}return r.autoTable&&this._tableInstance&&(r.autoColumns&&this._tableInstance.updateOption({columns:n.columns,plugins:[this]}),this._tableInstance.setRecords(n.records)),n}async _importFromData(e,t,r){let n;if("json"!==e)throw new Error(`不支持的数据类型: ${e}`);return n=await this._parseJSONData(t,r),r.autoTable&&this._tableInstance&&(r.autoColumns&&this._tableInstance.updateOption({columns:n.columns,plugins:[this]}),this._tableInstance.setRecords(n.records)),n}async _parseFile(e,t){const r={...this.options,...t},n=this._getFileExtension(e.name).toLowerCase();switch(n){case"xlsx":case"xls":return await this._parseExcelFile(e,r);case"csv":return await this._parseCsvFile(e,r);case"json":return await this._parseJsonFile(e,r);case"html":case"htm":return await this._parseHtmlFile(e,r);default:throw new Error(`不支持的文件类型: ${n}`)}}_getFileExtension(e){const t=e.split(".");return t.length>1?t[t.length-1]:""}async _parseExcelFile(e,t){const r={...this.options,...t};return await Oi.importExcelToVTableData(e,r)}async _parseCsvFile(e,t){const r={...this.options,...t},n=await e.text();return this._parseCSVString(n,r)}async _parseJsonFile(e,t){const r={...this.options,...t},n=await e.text();return this._parseJSONString(n,r)}async _parseHtmlFile(e,t){const r={...this.options,...t},n=await e.text();return this._parseHTMLString(n,r)}_buildColumnsFromHeaders(e){return 1===e.length?e[0].map(((e,t)=>({field:`col${t}`,title:e||`列${t+1}`,cellType:"text",headerType:"text"}))):Oi.buildColumns(e)}static async importExcelToVTableData(e,t){const r=new Ai.Workbook;await r.xlsx.load(await e.arrayBuffer());const n=r.worksheets[0];if(!n)throw new Error("Excel 文件无有效工作表");const i=t?.headerRowCount??this.detectHeaderRowCount(n),s=[];for(let e=1;e<=i;e++){const t=n.getRow(e);s.push(Array.prototype.slice.call(t.values,1))}const o=Oi.buildColumns(s),a=[],l=[];n.eachRow(((e,t)=>{if(t<=i)return;const r=Array.prototype.slice.call(e.values,1);l.push(r)}));const h=t?.batchSize||1e3;if(!1!==t?.enableBatchProcessing&&l.length>h)for(let e=0;e<l.length;e+=h){const r=l.slice(e,e+h).map((e=>{const t={};return e.forEach(((e,r)=>{t[`col${r}`]=e})),t}));a.push(...r),e+h<l.length&&await new Promise((e=>setTimeout(e,t?.asyncDelay||5)))}else l.forEach((e=>{const t={};e.forEach(((e,r)=>{t[`col${r}`]=e})),a.push(t)}));if(t?.exportData){const e=Oi._generateJavaScriptExport(o,a),t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download="vtable-data.js",document.body.appendChild(n),n.click(),setTimeout((()=>{document.body.removeChild(n),URL.revokeObjectURL(r)}),100)}return{columns:o,records:a}}static detectHeaderRowCount(e){let t=1,r=1;for(;;){const n=e.getRow(t),i=Array.prototype.slice.call(n.values,1);let s=!1;for(let e=1;e<i.length;e++)if(void 0!==i[e]&&""!==i[e]&&i[e]===i[e-1]){s=!0;break}if(!s)break;r++,t++}return r}static buildColumns(e,t=0,r,n=0){const i=e[n],s=[];r=r??i.length;let o=t;for(;o<r;){const t=String(i[o]||`列${o+1}`);let a=1;for(;o+a<r&&i[o+a]===t;)a++;if(n<e.length-1){const r=Oi.buildColumns(e,o,o+a,n+1);1===r.length?s.push(r[0]):s.push({title:t,columns:r,hideColumnsSubHeader:!1})}else s.push({field:`col${o}`,title:t,cellType:"text",headerType:"text"});o+=a}return s}async _parseCSVString(e,t){const r=e.split("\n").filter((e=>e.trim()));if(0===r.length)throw new Error("CSV文件为空");const n=t.delimiter||",",i=e=>e.split(n).map((e=>e.trim().replace(/^"|"$/g,""))),s=r.slice(0,1).map(i),o=r.slice(1),a=this._buildColumnsFromHeaders(s),l=[];return await this._processBatchRecords(o,t,(async e=>{const t=e.map((e=>{const t=i(e),r={};return t.forEach(((e,t)=>{r[`col${t}`]=e||""})),r}));l.push(...t)})),t.exportData&&this._exportToJS(a,l),{columns:a,records:l}}async _parseJSONString(e,t){let r;try{r=JSON.parse(e)}catch(e){throw new Error("JSON文件格式错误")}const n=await this._parseJSONData(r,t);return t.exportData&&this._exportToJS(n.columns,n.records),n}async _parseHTMLString(e,t){const r=(new DOMParser).parseFromString(e,"text/html").querySelector("table");if(!r)throw new Error("HTML文件中未找到表格");const n=Array.from(r.querySelectorAll("tr"));if(0===n.length)throw new Error("表格中没有数据行");const i=n.slice(0,1).map((e=>Array.from(e.querySelectorAll("th, td")).map((e=>e.textContent?.trim()||"")))),s=n.slice(1),o=this._buildColumnsFromHeaders(i),a=[];return await this._processBatchRecords(s,t,(async e=>{const t=e.map((e=>{const t=Array.from(e.querySelectorAll("td")).map((e=>e.textContent?.trim()||"")),r={};return t.forEach(((e,t)=>{r[`col${t}`]=e||""})),r}));a.push(...t)})),t.exportData&&this._exportToJS(o,a),{columns:o,records:a}}async _parseJSONData(e,t){let r;if("object"==typeof e&&!Array.isArray(e)&&e&&"columns"in e&&"records"in e){const n=e,i=[];await this._processBatchRecords(n.records,t,(async e=>{const t=e.map((e=>({...e})));i.push(...t)})),r={columns:n.columns,records:i}}else{if(!(Array.isArray(e)&&e.length>0))throw new Error("不支持的JSON格式");{const n=e[0],i=Object.keys(n).map((e=>({field:e,title:e,cellType:"text",headerType:"text"}))),s=[];await this._processBatchRecords(e,t,(async e=>{const t=e.map((e=>({...e})));s.push(...t)})),r={columns:i,records:s}}}return t.exportData&&this._exportToJS(r.columns,r.records),r}static _generateJavaScriptExport(e,t){const r=(e,t="")=>{if(null==e)return"null";if("string"==typeof e)return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`;if("number"==typeof e||"boolean"==typeof e)return String(e);if(Array.isArray(e)){if(0===e.length)return"[]";return`[${e.map((e=>r(e,t+" "))).join(", ")}]`}if("object"==typeof e){return`{\n${Object.entries(e).map((([e,n])=>`${t} ${e}: ${r(n,t+" ")}`)).join(",\n")}\n${t}}`}return String(e)},n=(e,t=" ")=>{const i=Object.entries(e).map((([e,i])=>{if("columns"===e&&Array.isArray(i)){const r=i.map((e=>n(e,t+" "))).join(",\n");return`${t} ${e}: [\n${r}\n${t} ]`}return`${t} ${e}: ${r(i)}`})).join(",\n");return`${t}{\n${i}\n${t}}`},i=e.map((e=>n(e))).join(",\n"),s=t.map((e=>` {\n${Object.entries(e).map((([e,t])=>` ${e}: ${r(t)}`)).join(",\n")}\n }`)).join(",\n");return`// VTable 数据导出 - JavaScript 对象字面量格式\n// 生成时间: ${(new Date).toLocaleString()}\n\nconst vtableData = {\n columns: [\n${i}\n ],\n records: [\n${s}\n ]\n};\n`}_exportToJS(e,t){const r=Oi._generateJavaScriptExport(e,t),n=new Blob([r],{type:"text/javascript"}),i=URL.createObjectURL(n),s=document.createElement("a");s.href=i,s.download="vtable-data.js",document.body.appendChild(s),s.click(),setTimeout((()=>{document.body.removeChild(s),URL.revokeObjectURL(i)}),100)}async _processBatchRecords(e,t,r){if(!t.enableBatchProcessing||e.length<=(t.batchSize||1e3))return void await r(e,0);const n=t.batchSize||1e3,i=Math.ceil(e.length/n);for(let s=0;s<i;s++){const o=s*n,a=Math.min(o+n,e.length),l=e.slice(o,a);await r(l,s),s<i-1&&await new Promise((e=>setTimeout(e,t.asyncDelay||5)))}}}class Ii{constructor(){}handleCopy(e){e.eventManager.handleCopy(new KeyboardEvent("copy"))}handleCut(e){e.eventManager.handleCut(new KeyboardEvent("cut"))}handlePaste(e){e.eventManager.handlePaste(new KeyboardEvent("paste"))}handleInsertRowAbove(e,t,r=1){if(void 0!==t&&"function"==typeof e.addRecord){const n=Array.from({length:r},((e,t)=>[]));e.addRecords(n,t-1)}}handleInsertRowBelow(e,t,r=1){if(void 0!==t&&"function"==typeof e.addRecord){const n=Array.from({length:r},((e,t)=>[]));e.addRecords(n,t)}}handleInsertColumnLeft(e,t,r=1){if(void 0!==t&&"function"==typeof e.addColumns){const n=[];for(let e=0;e<r;e++)n.push({field:t-e});e.addColumns(n,t,!0)}}handleInsertColumnRight(e,t,r=1){if(void 0!==t&&"function"==typeof e.addColumns){const n=[];for(let e=0;e<r;e++)n.push({field:t+1});e.addColumns(n,t+1,!0)}}handleDeleteRow(e){if("function"==typeof e.deleteRecords){const t=e.stateManager.select.ranges,r=[];for(let e=0;e<t.length;e++){const n=t[e];for(let e=n.start.row;e<=n.end.row;e++)r.includes(e)||r.push(e)}r.sort(((e,t)=>t-e));const n=[];for(let t=0;t<r.length;t++){const i=e.getRecordIndexByCell(0,r[t]);n.push(i)}e.deleteRecords(n)}}handleDeleteColumn(e,t){if(void 0!==t&&"function"==typeof e.deleteColumns){const t=e.stateManager.select.ranges,r=[];for(let e=0;e<t.length;e++){const n=t[e];for(let e=n.start.col;e<=n.end.col;e++)r.includes(e)||r.push(e)}e.deleteColumns(r,!0)}}handleHideColumn(e,t){void 0!==t&&"function"==typeof e.hideColumns&&e.hideColumns([t])}handleSort(e,t){if(void 0!==t&&"function"==typeof e.sort){const r=e.getSortState?e.getSortState():null;let n="asc";r&&r.field===t&&(n="asc"===r.order?"desc":"normal"),e.sort({field:t,order:n})}}handleMergeCells(e){if(1===(e.stateManager.select.ranges?.length??0)&&"function"==typeof e.mergeCells){const{row:t,col:r}=e.stateManager.select.ranges[0].start,{row:n,col:i}=e.stateManager.select.ranges[0].end;if(r===i&&t===n)return;e.mergeCells(Math.min(r,i),Math.min(t,n),Math.max(r,i),Math.max(t,n))}}handleUnmergeCells(e){if(1===(e.stateManager.select.ranges?.length??0)&&"function"==typeof e.unmergeCells){const{row:t,col:r}=e.stateManager.select.ranges[0].start,{row:n,col:i}=e.stateManager.select.ranges[0].end;if(r===i&&t===n)return;e.unmergeCells(Math.min(r,i),Math.min(t,n),Math.max(r,i),Math.max(t,n))}}handleSetProtection(e){}handleFreezeToRow(e,t){void 0!==t&&(e.frozenRowCount=t+1)}handleFreezeToColumn(e,t){void 0!==t&&(e.frozenColCount=t+1)}handleFreezeToRowAndColumn(e,t,r){void 0!==t&&void 0!==r&&(e.frozenRowCount=t+1,e.frozenColCount=r+1)}handleUnfreeze(e){e.frozenRowCount=0,e.frozenColCount=0}release(){}}class Ni{filterFuncRule=[];filterValueRule=[];applyFilter(e,t){const{filters:r}=e;this.filterFuncRule=[],this.filterValueRule=[],r.forEach(((e,t)=>{if(e.enable)if("byValue"===e.type)this.filterValueRule.push({filterKey:String(e.field),filteredValues:e.values});else if("byCondition"===e.type){const t=this.createFilterFunction(e);this.filterFuncRule.push({filterFunc:t,fieldId:String(e.field)})}})),t.updateFilterRules([...this.filterFuncRule,...this.filterValueRule],{clearRowHeightCache:!1})}createFilterFunction(e){const{field:t,operator:r,condition:n}=e;return r&&void 0!==n?e=>{const i=e[t];if(null==i)return!1;switch(r){case"equals":return 0===this.compareValues(i,n);case"notEquals":return 0!==this.compareValues(i,n);case"greaterThan":return this.compareValues(i,n)>0;case"lessThan":return this.compareValues(i,n)<0;case"greaterThanOrEqual":return this.compareValues(i,n)>=0;case"lessThanOrEqual":return this.compareValues(i,n)<=0;case"between":return!Array.isArray(n)||2!==n.length||this.compareValues(i,n[0])>=0&&this.compareValues(i,n[1])<=0;case"notBetween":return!Array.isArray(n)||2!==n.length||(this.compareValues(i,n[0])<0||this.compareValues(i,n[1])>0);case"contains":return String(i).toLowerCase().includes(String(n).toLowerCase());case"notContains":return!String(i).toLowerCase().includes(String(n).toLowerCase());case"startsWith":return String(i).toLowerCase().startsWith(String(n).toLowerCase());case"notStartsWith":return!String(i).toLowerCase().startsWith(String(n).toLowerCase());case"endsWith":return String(i).toLowerCase().endsWith(String(n).toLowerCase());case"notEndsWith":return!String(i).toLowerCase().endsWith(String(n).toLowerCase());case"isChecked":return!0===Boolean(i);case"isUnchecked":return!1===Boolean(i);default:return!0}}:()=>!0}compareValues(e,t){if("number"==typeof e&&"number"==typeof t)return e===t?0:e>t?1:-1;if("boolean"==typeof e&&"boolean"==typeof t)return e===t?0:-1;const r=String(e).toLowerCase(),n=String(t).toLowerCase();return r===n?0:r>n?1:-1}clearAllFilter(e){this.filterFuncRule=[],this.filterValueRule=[],e.updateFilterRules([])}clearFilter(e,t){this.filterValueRule=this.filterValueRule.filter((e=>e.filterKey!==t)),this.filterFuncRule=this.filterFuncRule.filter((e=>e.fieldId!==t)),e.updateFilterRules([...this.filterFuncRule,...this.filterValueRule])}}e.FilterActionType=void 0,(ki=e.FilterActionType||(e.FilterActionType={}))[ki.ADD_FILTER=0]="ADD_FILTER",ki[ki.REMOVE_FILTER=1]="REMOVE_FILTER",ki[ki.UPDATE_FILTER=2]="UPDATE_FILTER",ki[ki.ENABLE_FILTER=3]="ENABLE_FILTER",ki[ki.DISABLE_FILTER=4]="DISABLE_FILTER",ki[ki.CLEAR_ALL_FILTERS=5]="CLEAR_ALL_FILTERS",ki[ki.APPLY_FILTERS=6]="APPLY_FILTERS",e.FilterOperatorCategory=void 0,(Mi=e.FilterOperatorCategory||(e.FilterOperatorCategory={})).ALL="all",Mi.TEXT="text",Mi.NUMBER="number",Mi.COLOR="color",Mi.CHECKBOX="checkbox",Mi.RADIO="radio";class Fi{state;engine;listeners=[];table;constructor(e,t){this.state={filters:new Map},this.engine=t,this.table=e}getFilterState(e){return this.state.filters.get(e)}getActiveFilterFields(){const e=[];return this.state.filters.forEach(((t,r)=>{t.enable&&e.push(r)})),e}getAllFilterStates(){return this.state}reapplyCurrentFilters(){this.getActiveFilterFields().length>0&&this.applyFilters()}dispatch(e){this.state=this.reduce(this.state,e),this.shouldApplyFilter(e)&&this.applyFilters(),this.notifyListeners(e)}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter((t=>t!==e))}}notifyListeners(e){this.listeners.forEach((t=>t(this.state,e)))}reduce(t,r){const{type:n,payload:i}=r,s=new Map(t.filters);switch(n){case e.FilterActionType.ADD_FILTER:s.set(i.field,i);break;case e.FilterActionType.REMOVE_FILTER:s.delete(i.field);break;case e.FilterActionType.UPDATE_FILTER:s.set(i.field,{...s.get(i.field),...i});break;case e.FilterActionType.ENABLE_FILTER:s.set(i.field,{...s.get(i.field),enable:!0});break;case e.FilterActionType.DISABLE_FILTER:s.set(i.field,{...s.get(i.field),enable:!1});break;case e.FilterActionType.CLEAR_ALL_FILTERS:s.clear();break;case e.FilterActionType.APPLY_FILTERS:s.set(i.field,{...s.get(i.field),...i,enable:!0})}return{...t,filters:s}}applyFilters(){this.engine.applyFilter(this.state,this.table)}shouldApplyFilter(t){return[e.FilterActionType.REMOVE_FILTER,e.FilterActionType.ENABLE_FILTER,e.FilterActionType.DISABLE_FILTER,e.FilterActionType.CLEAR_ALL_FILTERS,e.FilterActionType.APPLY_FILTERS].includes(t.type)||t.payload.enable}}const Pi={display:"none",position:"absolute",backgroundColor:"white",border:"1px solid #ccc",boxShadow:"0 4px 8px rgba(0,0,0,0.15)",zIndex:"100"},ji={padding:"10px",display:"block"},Li={padding:"5px"},Di={width:"100%",padding:"8px 10px",border:"1px solid #ccc",borderRadius:"4px",fontSize:"14px",boxSizing:"border-box"},Bi={maxHeight:"200px",overflowY:"auto",marginTop:"10px"},Hi={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 5px"},zi={display:"flex",alignItems:"center",cursor:"pointer",flexGrow:"1",fontWeight:"normal"},Ui={marginRight:"10px"},Vi={color:"#888",fontSize:"12px"},$i={display:"flex",justifyContent:"space-around",borderBottom:"1px solid #e0e0e0"},Wi=e=>({backgroundColor:"transparent",border:"none",flex:"1",padding:"10px 15px",cursor:"pointer",fontSize:"14px",fontWeight:e?"bold":"normal",color:e?"#007bff":"#666",borderBottom:e?"3px solid #007bff":"2px solid transparent"}),qi={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 15px",borderTop:"1px solid #e0e0e0",backgroundColor:"#f8f9fa"},Ki=e=>({padding:"6px 12px",border:"1px solid #ccc",borderRadius:"4px",cursor:"pointer",marginLeft:"5px",backgroundColor:e?"#007bff":"white",color:e?"white":"#333",borderColor:e?"#007bff":"#ccc"}),Yi={color:"#007bff",textDecoration:"none"},Xi={marginBottom:"15px",padding:"10px"},Gi={display:"block",marginBottom:"8px",fontWeight:"bold"},Zi={width:"100%",padding:"8px",marginBottom:"15px",border:"1px solid #ccc",borderRadius:"4px",boxSizing:"border-box"},Ji={display:"flex",alignItems:"center",gap:"8px"},Qi={display:"none",padding:"0 5px"};function es(e,t){Object.entries(t).forEach((([t,r])=>{e.style[t]=r}))}function ts(e,t={},r=[]){const n=document.createElement(e);return Object.entries(t).forEach((([e,t])=>{n.setAttribute(e,t)})),r.forEach((e=>{"string"==typeof e?n.appendChild(document.createTextNode(e)):n.appendChild(e)})),n}class rs{table;filterStateManager;uniqueKeys=new Map;displayToRawValueMap=new Map;selectedField;valueFilterOptionList=new Map;filterByValuePanel;filterByValueSearchInput;selectAllCheckbox;filterItemsContainer;constructor(e,t){this.table=e,this.filterStateManager=t,this.filterStateManager.subscribe((e=>{const t=e.filters.get(this.selectedField);t&&"byValue"===t.type&&this.updateUI(t)}))}updateUI(e){this.syncCheckboxesWithFilterState(e),this.syncSelectAllWithFilterState(e)}setSelectedField(e){this.selectedField=e,this.collectUniqueColumnValues(e)}collectUniqueColumnValues(e){const t=this.filterStateManager.getFilterState(e)?.enable,r=new Map,n=new Map,i=new Map;let s=-1;for(let t=0;t<this.table.colCount;t++){for(let r=this.table.columnHeaderLevelCount;r<this.table.rowCount;r++)if(!this.table.internalProps.layoutMap.isHeader(t,r)){const n=this.table.internalProps.layoutMap.getBody(t,r);if(n&&n.field===e){s=t;break}}if(-1!==s)break}if(t){const t=this.table.internalProps.records,o=t.length;for(let a=0;a<o;a++){let o,l;if(-1!==s){const r=this.table.columnHeaderLevelCount+a;o=t[a][e];const n=this.table.internalProps.layoutMap.getBody(s,r);l=n&&"fieldFormat"in n&&n.fieldFormat&&"function"==typeof n.fieldFormat?n.fieldFormat({[e]:o}):o}null!=o&&(r.set(l,(r.get(l)||0)+1),n.set(o,l),i.set(l,o))}}else{const t=this.table.internalProps.dataSource.length;for(let o=0;o<t;o++){let t,a;if(-1!==s){const e=this.table.columnHeaderLevelCount+o;e<this.table.rowCount&&(t=this.table.getCellOriginValue(s,e),a=this.table.getCellValue(s,e))}else t=this.table.getFieldData(String(e),-1!==s?s:0,this.table.columnHeaderLevelCount+o),a=t;null!=t&&(r.set(a,(r.get(a)||0)+1),n.set(t,a),i.set(a,t))}}this.displayToRawValueMap.set(e,i);const o=Array.from(r.entries()).map((([e,t])=>({value:e,count:t,rawValue:i.get(e)})));this.uniqueKeys.set(e,o)}onValueSelect(t,r,n){const i=this.displayToRawValueMap.get(t),s=i?i.get(r):r,o=this.filterStateManager.getFilterState(t);if(o){const r=n?[...o.values||[],s]:(o.values||[]).filter((e=>e!==s));this.filterStateManager.dispatch({type:e.FilterActionType.UPDATE_FILTER,payload:{field:t,values:r}})}else this.filterStateManager.dispatch({type:e.FilterActionType.ADD_FILTER,payload:{field:t,type:"byValue",values:[s]}})}toggleSelectAll(t,r){const n=this.filterStateManager.getFilterState(t),i=r&&this.uniqueKeys.get(t)?.map((e=>e.rawValue))||[];if(n){const n=r?i:[];this.filterStateManager.dispatch({type:e.FilterActionType.UPDATE_FILTER,payload:{field:t,values:n}})}else this.filterStateManager.dispatch({type:e.FilterActionType.ADD_FILTER,payload:{field:t,type:"byValue",values:i,enable:!0}})}onSearch(e,t){const r=t.toUpperCase().split(" ").filter((e=>e)),n=this.valueFilterOptionList.get(e);for(const e of n){const t=e.id.toUpperCase()||"",n=r.some((e=>t.includes(e)));e.itemContainer.style.display=0===r.length||n?"flex":"none"}}initFilterStateFromTableData(t){const r=this.filterStateManager.getFilterState(t),n=new Set,i=this.displayToRawValueMap.get(t);let s=-1;for(let e=0;e<this.table.colCount;e++){for(let r=this.table.columnHeaderLevelCount;r<this.table.rowCount;r++)if(!this.table.internalProps.layoutMap.isHeader(e,r)){const n=this.table.internalProps.layoutMap.getBody(e,r);if(n&&n.field===t){s=e;break}}if(-1!==s)break}const o=this.table.internalProps.dataSource.length;for(let e=0;e<o;e++){let r,o;if(-1!==s){const t=this.table.columnHeaderLevelCount+e;t<this.table.rowCount&&(r=this.table.getCellValue(s,t),o=i?i.get(r):r)}else r=this.table.getFieldData(String(t),-1!==s?s:0,this.table.columnHeaderLevelCount+e),o=i?i.get(r):r;null!=o&&n.add(o)}(!r||!function(e,t){if(!p(e)||!p(t))return!1;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}(r.values,Array.from(n)))&&(r?this.filterStateManager.dispatch({type:e.FilterActionType.UPDATE_FILTER,payload:{field:t,type:"byValue",values:Array.from(n)}}):this.filterStateManager.dispatch({type:e.FilterActionType.ADD_FILTER,payload:{field:t,type:"byValue",values:Array.from(n)}}))}syncCheckboxesWithFilterState(e){if(!e)return;const t=e.values||[],r=this.displayToRawValueMap.get(e.field),n=this.valueFilterOptionList.get(e.field);n?.forEach((n=>{const i=n.originalValue,s=r?r.get(i):i;n.checkbox.checked=t.some((e=>e===s));const o=this.uniqueKeys.get(e.field)?.find((e=>String(e.value)===n.id))?.count||0;n.countSpan.textContent=String(o),n.itemContainer.style.display=0===o?"none":"flex"}))}syncSelectAllWithFilterState(e){if(!e||!e.values)return this.selectAllCheckbox.checked=!1,void(this.selectAllCheckbox.indeterminate=!1);const t=this.uniqueKeys.get(e.field)?.length||0;0===t||0===e.values.length?(this.selectAllCheckbox.checked=!1,this.selectAllCheckbox.indeterminate=!1):e.values.length===t?(this.selectAllCheckbox.checked=!0,this.selectAllCheckbox.indeterminate=!1):(this.selectAllCheckbox.checked=!1,this.selectAllCheckbox.indeterminate=!0)}applyFilter(t=this.selectedField){const r=this.filterStateManager.getFilterState(t)?.values||[];r.length>0&&r.length<this.uniqueKeys.get(t)?.length?this.filterStateManager.dispatch({type:e.FilterActionType.APPLY_FILTERS,payload:{field:t,type:"byValue",values:r,enable:!0}}):this.filterStateManager.dispatch({type:e.FilterActionType.REMOVE_FILTER,payload:{field:t}})}clearFilter(t){this.filterStateManager.dispatch({type:e.FilterActionType.REMOVE_FILTER,payload:{field:t}}),this.hide()}render(e){this.filterByValuePanel=document.createElement("div"),es(this.filterByValuePanel,ji);const t=document.createElement("div");es(t,Li),this.filterByValueSearchInput=document.createElement("input"),this.filterByValueSearchInput.type="text",this.filterByValueSearchInput.placeholder="可使用空格分隔多个关键词",es(this.filterByValueSearchInput,Di),t.appendChild(this.filterByValueSearchInput);const r=document.createElement("div");es(r,Bi);const n=document.createElement("div");es(n,Hi);const i=document.createElement("label");es(i,zi),this.selectAllCheckbox=document.createElement("input"),this.selectAllCheckbox.type="checkbox",this.selectAllCheckbox.checked=!0,es(this.selectAllCheckbox,Ui),i.append(this.selectAllCheckbox," 全选"),n.appendChild(i),this.filterItemsContainer=document.createElement("div"),r.append(n,this.filterItemsContainer),this.filterByValuePanel.append(t,r),e.appendChild(this.filterByValuePanel),this.bindEventForFilterByValue()}renderFilterOptions(e){this.filterItemsContainer.innerHTML="",this.valueFilterOptionList.delete(e),this.valueFilterOptionList.set(e,[]);const t=this.filterStateManager.getFilterState(e)?.values||[],r=new Set(t),n=[];this.uniqueKeys.get(e)?.forEach((({value:e,count:t,rawValue:i})=>{const s=document.createElement("div");es(s,Hi);const o=document.createElement("label");es(o,zi);const a=document.createElement("input");a.type="checkbox",a.value=String(e),a.checked=r.has(i),es(a,Ui);const l=document.createElement("span");l.textContent=String(t),es(l,Vi),o.append(a,` ${e}`),s.append(o,l),this.filterItemsContainer.appendChild(s);const h={id:String(e),originalValue:e,itemContainer:s,checkbox:a,countSpan:l};n.push(h)})),this.valueFilterOptionList.set(e,n)}bindEventForFilterByValue(){this.filterByValuePanel.addEventListener("keyup",(e=>{const t=e.target;if(t instanceof HTMLInputElement&&"text"===t.type){const e=t.value;this.onSearch(this.selectedField,e)}})),this.filterByValuePanel.addEventListener("change",(e=>{const t=e.target;if(t instanceof HTMLInputElement&&"checkbox"===t.type)if(t===this.selectAllCheckbox)this.toggleSelectAll(this.selectedField,this.selectAllCheckbox.checked);else{const e=t,r=e.checked,n=this.valueFilterOptionList.get(this.selectedField)?.find((t=>t.id===e.value))?.originalValue;this.onValueSelect(this.selectedField,n,r)}}))}show(){this.initFilterStateFromTableData(this.selectedField),this.renderFilterOptions(this.selectedField),this.filterByValuePanel.style.display="block"}hide(){this.filterByValuePanel.style.display="none"}clearSearchInputValue(){this.filterByValueSearchInput.value=""}}class ns{table;filterStateManager;filterByConditionPanel;selectedField;operatorSelect;valueInput;valueInputMax;categorySelect;currentCategory=e.FilterOperatorCategory.ALL;operators=[{value:"equals",label:"等于",category:e.FilterOperatorCategory.ALL},{value:"notEquals",label:"不等于",category:e.FilterOperatorCategory.ALL},{value:"equals",label:"等于",category:e.FilterOperatorCategory.NUMBER},{value:"notEquals",label:"不等于",category:e.FilterOperatorCategory.NUMBER},{value:"greaterThan",label:"大于",category:e.FilterOperatorCategory.NUMBER},{value:"lessThan",label:"小于",category:e.FilterOperatorCategory.NUMBER},{value:"greaterThanOrEqual",label:"大于等于",category:e.FilterOperatorCategory.NUMBER},{value:"lessThanOrEqual",label:"小于等于",category:e.FilterOperatorCategory.NUMBER},{value:"between",label:"介于",category:e.FilterOperatorCategory.NUMBER},{value:"notBetween",label:"不介于",category:e.FilterOperatorCategory.NUMBER},{value:"equals",label:"等于",category:e.FilterOperatorCategory.TEXT},{value:"notEquals",label:"不等于",category:e.FilterOperatorCategory.TEXT},{value:"contains",label:"包含",category:e.FilterOperatorCategory.TEXT},{value:"notContains",label:"不包含",category:e.FilterOperatorCategory.TEXT},{value:"startsWith",label:"开头是",category:e.FilterOperatorCategory.TEXT},{value:"notStartsWith",label:"开头不是",category:e.FilterOperatorCategory.TEXT},{value:"endsWith",label:"结尾是",category:e.FilterOperatorCategory.TEXT},{value:"notEndsWith",label:"结尾不是",category:e.FilterOperatorCategory.TEXT},{value:"equals",label:"等于",category:e.FilterOperatorCategory.COLOR},{value:"notEquals",label:"不等于",category:e.FilterOperatorCategory.COLOR},{value:"isChecked",label:"已选中",category:e.FilterOperatorCategory.CHECKBOX},{value:"isUnchecked",label:"未选中",category:e.FilterOperatorCategory.CHECKBOX},{value:"isChecked",label:"已选中",category:e.FilterOperatorCategory.RADIO},{value:"isUnchecked",label:"未选中",category:e.FilterOperatorCategory.RADIO}];categories=[{value:e.FilterOperatorCategory.ALL,label:"全部"},{value:e.FilterOperatorCategory.TEXT,label:"文本"},{value:e.FilterOperatorCategory.NUMBER,label:"数值"},{value:e.FilterOperatorCategory.COLOR,label:"颜色"},{value:e.FilterOperatorCategory.CHECKBOX,label:"复选框"},{value:e.FilterOperatorCategory.RADIO,label:"单选框"}];constructor(e,t){this.table=e,this.filterStateManager=t}setSelectedField(e){this.selectedField=e,this.updateOperatorOptions(),this.loadCurrentFilterState()}updateOperatorOptions(){if(!this.operatorSelect)return;let t;if(this.operatorSelect.innerHTML="",this.currentCategory===e.FilterOperatorCategory.ALL){const e=new Map;this.operators.forEach((t=>{e.has(t.value)||e.set(t.value,t)})),t=Array.from(e.values())}else t=this.operators.filter((e=>e.category===this.currentCategory));t.forEach((e=>{const t=document.createElement("option");t.value=e.value,t.textContent=e.label,this.operatorSelect.appendChild(t)}))}handleCategoryChange(){this.categorySelect&&(this.currentCategory=this.categorySelect.value,this.updateOperatorOptions(),this.syncUIState())}loadCurrentFilterState(){const e=this.filterStateManager.getFilterState(this.selectedField);e&&"byCondition"===e.type?(e.operator&&this.operatorSelect&&(this.operatorSelect.value=e.operator),void 0!==e.condition&&this.valueInput&&(Array.isArray(e.condition)?(this.valueInput.value=String(e.condition[0]),this.valueInputMax&&(this.valueInputMax.value=String(e.condition[1]))):(this.valueInput.value=String(e.condition),this.valueInputMax&&(this.valueInputMax.value=""))),this.syncUIState()):this.reset()}reset(){this.operatorSelect&&(this.operatorSelect.selectedIndex=0),this.valueInput&&(this.valueInput.value="",this.valueInput.placeholder="请输入筛选值"),this.valueInputMax&&(this.valueInputMax.value=""),this.currentCategory=e.FilterOperatorCategory.ALL,this.categorySelect&&(this.categorySelect.value=e.FilterOperatorCategory.ALL),this.updateOperatorOptions(),this.syncUIState()}syncUIState(){if(!this.operatorSelect||!this.valueInput)return;const e=this.operatorSelect.value,t=this.valueInput.nextElementSibling;this.isRangeOperator(e)?(this.valueInput.placeholder="最小值",this.valueInputMax&&(this.valueInputMax.style.display="inline-block"),t&&(t.style.display="inline-block")):(this.valueInput.placeholder="请输入筛选值",this.valueInputMax&&(this.valueInputMax.style.display="none"),t&&(t.style.display="none"))}isBooleanOperator(e){return["isChecked","isUnchecked"].includes(e)}isRangeOperator(e){return"between"===e||"notBetween"===e}applyFilter(t=this.selectedField){if(!this.operatorSelect||!this.valueInput)return;const r=this.operatorSelect?.value;let n=this.valueInput?.value;if(this.currentCategory!==e.FilterOperatorCategory.NUMBER||(n=parseFloat(n),!isNaN(n))){if(this.isRangeOperator(r)){const t=n;let r=this.valueInputMax.value.trim();if(this.currentCategory===e.FilterOperatorCategory.NUMBER){const e=parseFloat(r);if(isNaN(e))return;r=e}n=[t,r]}n||!1===n||0===n||this.isBooleanOperator(r)?(this.filterStateManager.dispatch({type:e.FilterActionType.APPLY_FILTERS,payload:{field:t,type:"byCondition",operator:r,condition:n,enable:!0}}),this.hide()):this.clearFilter(t)}}clearFilter(t){this.filterStateManager.dispatch({type:e.FilterActionType.REMOVE_FILTER,payload:{field:t}}),this.hide()}render(e){this.filterByConditionPanel=document.createElement("div"),es(this.filterByConditionPanel,ji);const t=document.createElement("div");es(t,Xi);const r=ts("label",{},["筛选类型:"]);es(r,Gi),this.categorySelect=ts("select"),es(this.categorySelect,Zi),this.categories.forEach((e=>{const t=document.createElement("option");t.value=e.value,t.textContent=e.label,this.categorySelect.appendChild(t)}));const n=ts("label",{},["筛选条件:"]);es(n,Gi),this.operatorSelect=ts("select"),es(this.operatorSelect,Zi);const i=ts("label",{},["筛选值:"]);es(i,Gi);const s=ts("div");es(s,Ji),this.valueInput=ts("input",{type:"text",placeholder:"请输入筛选值"}),es(this.valueInput,Di);const o=ts("span",{},["和"]);es(o,Qi),o.style.display="none",this.valueInputMax=ts("input",{type:"text",placeholder:"最大值"}),es(this.valueInputMax,Di),this.valueInputMax.style.display="none",s.appendChild(this.valueInput),s.appendChild(o),s.appendChild(this.valueInputMax),t.appendChild(r),t.appendChild(this.categorySelect),t.appendChild(n),t.appendChild(this.operatorSelect),t.appendChild(i),t.appendChild(s),this.filterByConditionPanel.appendChild(t),e.appendChild(this.filterByConditionPanel),this.hide(),this.updateOperatorOptions(),this.bindEvents()}bindEvents(){this.valueInput.addEventListener("keypress",(e=>{"Enter"===e.key&&this.applyFilter()})),this.valueInputMax.addEventListener("keypress",(e=>{"Enter"===e.key&&this.applyFilter()})),this.categorySelect.addEventListener("change",(()=>{this.handleCategoryChange()})),this.operatorSelect.addEventListener("change",(()=>{const e=this.operatorSelect.value,t=this.valueInput.nextElementSibling;this.isRangeOperator(e)?(this.valueInput.placeholder="最小值",this.valueInputMax.style.display="inline-block",t.style.display="inline-block"):(this.valueInput.placeholder="请输入筛选值",this.valueInputMax.style.display="none",t.style.display="none")}))}show(){this.filterByConditionPanel&&(this.filterByConditionPanel.style.display="block",this.loadCurrentFilterState())}hide(){this.filterByConditionPanel&&(this.filterByConditionPanel.style.display="none")}}class is{table;filterStateManager;valueFilter=null;conditionFilter=null;activeTab="byValue";isVisible=!1;selectedField=null;filterModes=[];filterMenu;filterMenuWidth;currentCol;currentRow;filterTabByValue;filterTabByCondition;clearFilterOptionLink;cancelFilterButton;applyFilterButton;constructor(e,t){this.table=e,this.filterStateManager=t,this.valueFilter=new rs(this.table,this.filterStateManager),this.conditionFilter=new ns(this.table,this.filterStateManager),this.filterMenuWidth=300}onTabSwitch(e){this.activeTab=e,"byValue"===e?(this.valueFilter.show(),this.conditionFilter.hide()):(this.conditionFilter.show(),this.valueFilter.hide());const t="byValue"===e;es(this.filterTabByValue,Wi(t)),es(this.filterTabByCondition,Wi(!t))}updateSelectedField(e){this.selectedField=e,this.valueFilter&&this.valueFilter.setSelectedField(e),this.conditionFilter&&this.conditionFilter.setSelectedField(e)}applyFilter(e){"byValue"===this.activeTab?this.valueFilter.applyFilter(e):"byCondition"===this.activeTab&&this.conditionFilter.applyFilter(e),this.hide()}clearFilter(e){this.valueFilter&&this.valueFilter.clearFilter(e),this.conditionFilter&&this.conditionFilter.clearFilter(e),this.hide()}render(e){this.filterMenu=document.createElement("div"),es(this.filterMenu,Pi),this.filterMenu.style.width=`${this.filterMenuWidth}px`;const t=document.createElement("div");es(t,$i),this.filterTabByValue=document.createElement("button"),this.filterTabByValue.innerText="按值筛选",es(this.filterTabByValue,Wi(!0)),this.filterTabByCondition=document.createElement("button"),this.filterTabByCondition.innerText="按条件筛选",es(this.filterTabByCondition,Wi(!1)),t.append(this.filterTabByValue,this.filterTabByCondition);const r=document.createElement("div");es(r,qi),this.clearFilterOptionLink=document.createElement("a"),this.clearFilterOptionLink.href="#",this.clearFilterOptionLink.innerText="清除筛选",es(this.clearFilterOptionLink,Yi);const n=document.createElement("div");this.cancelFilterButton=document.createElement("button"),this.cancelFilterButton.innerText="取消",es(this.cancelFilterButton,Ki(!1)),this.applyFilterButton=document.createElement("button"),this.applyFilterButton.innerText="确认",es(this.applyFilterButton,Ki(!0)),n.append(this.cancelFilterButton,this.applyFilterButton),r.append(this.clearFilterOptionLink,n),this.filterMenu.append(t),this.valueFilter.render(this.filterMenu),this.conditionFilter.render(this.filterMenu),this.filterMenu.append(r),e.appendChild(this.filterMenu),this.attachEventListeners()}attachEventListeners(){this.filterTabByValue.addEventListener("click",(()=>{this.onTabSwitch("byValue")})),this.filterTabByCondition.addEventListener("click",(()=>{this.onTabSwitch("byCondition")})),this.cancelFilterButton.addEventListener("click",(()=>this.hide())),this.clearFilterOptionLink.addEventListener("click",(e=>{e.preventDefault(),this.clearFilter(this.selectedField)})),this.applyFilterButton.addEventListener("click",(()=>{this.applyFilter(this.selectedField)})),document.addEventListener("click",(()=>{this.isVisible&&this.hide()})),this.filterMenu.addEventListener("click",(e=>{e.stopPropagation()}))}adjustMenuPosition(e,t,r,n){if("number"==typeof r&&"number"==typeof n)return this.filterMenu.style.display=this.isVisible?"block":"none",this.filterMenu.style.left=`${r}px`,void(this.filterMenu.style.top=`${n}px`);const i="number"==typeof e?e:this.currentCol,s="number"==typeof t?t:this.currentRow;if("number"!=typeof i||"number"!=typeof s)return;this.currentCol=i,this.currentRow=s;let o=0,a=0;const l=this.table.canvas.getBoundingClientRect(),h=this.table.getCellRelativeRect(i,s);h.right<this.filterMenuWidth?(o=h.left+l.left,a=h.bottom+l.top):(o=h.right+l.left-this.filterMenuWidth,a=h.bottom+l.top),this.filterMenu.style.display=this.isVisible?"block":"none",this.filterMenu.style.left=`${o}px`,this.filterMenu.style.top=`${a}px`}show(e,t,r){this.valueFilter.clearSearchInputValue(),this.filterModes=r,this.filterModes.includes("byValue")?this.filterModes.includes("byCondition")||(this.filterTabByCondition.style.display="none",this.onTabSwitch("byValue")):(this.filterTabByValue.style.display="none",this.onTabSwitch("byCondition")),this.adjustMenuPosition(e,t),this.filterMenu.style.display="block";const n=this.table.internalProps.layoutMap.getHeaderField(e,t);this.updateSelectedField(n);const i=this.filterStateManager.getFilterState(n);i&&"byCondition"===i.type?this.onTabSwitch("byCondition"):this.onTabSwitch("byValue"),setTimeout((()=>{this.isVisible=!0}),0)}hide(){this.filterMenu.style.display="none",this.isVisible=!1}}function ss(e,t){let r="";for(let t=e+1;t>0;t=Math.floor((t-1)/26))r=String.fromCharCode((t-1)%26+65)+r;return r+(t+1)}function os(e){if(!e)return[0,0,0];if(e.startsWith("#")){let t=e.substring(1);3===t.length&&(t=t.replace(/(.)/g,"$1$1"));return[parseInt(t.substring(0,2),16),parseInt(t.substring(2,4),16),parseInt(t.substring(4,6),16)]}if(e.startsWith("rgb(")){return e.substring(4,e.length-1).split(",").map(Number)}if(e.startsWith("rgba(")){return e.substring(5,e.length-1).split(",").map(Number)}if(y(hs[e]))return[(t=hs[e])>>16,t>>8&255,255&t,1];if(y(ls[e]))return function(e){return[e>>>24,e>>>16&255,e>>>8&255,255&e]}(ls[e]);var t;throw new Error("Unsupported color format")}function as(e){if(3===e.length&&e.push(1),4!==e.length)throw new Error("Invalid RGBA array");const[t,r,n,i]=e.map(Math.round);return`${Math.round(255*i).toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}const ls={transparent:4294967040},hs={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function cs(e,t){return{name:ds(e.fontFamily)||"Arial",size:e.fontSize||10,bold:us(e.fontWeight),italic:"italic"===e.fontStyle,color:gs("link"===t?e._linkColor:e.color),underline:e.underline}}function us(e){return"number"==typeof e?e>=600:Number(e)>=600||"bold"===e}function ds(e){return e.split(",").map((e=>e.trim()))[0]}function fs(e){return{type:"pattern",pattern:"solid",fgColor:gs(e.bgColor)}}function ps(e){const{borderColor:t,borderLineWidth:r,borderLineDash:n,_strokeArrayWidth:i,_strokeArrayColor:s}=e;if(s||i){const e={};return s&&!s[0]||i&&!i[0]||(e.top={style:ms(i?.[0]??r,n),color:gs(s?.[0]??t)}),s&&!s[1]||i&&!i[1]||(e.right={style:ms(i?.[1]??r,n),color:gs(s?.[1]??t)}),s&&!s[2]||i&&!i[2]||(e.bottom={style:ms(i?.[2]??r,n),color:gs(s?.[2]??t)}),s&&!s[3]||i&&!i[3]||(e.left={style:ms(i?.[3]??r,n),color:gs(s?.[3]??t)}),e}if(0===r)return{};const o={style:ms(r,n),color:gs(t)};return{top:o,left:o,bottom:o,right:o}}function ms(e,t){return t&&t.length?e<=2?"dashed":"mediumDashed":e<=.5?"hair":e<=1?"thin":e<=2?"medium":"thick"}function bs(e,t){return{horizontal:e.textAlign||"left",vertical:e.textBaseline||"middle",wrapText:e.autoWrapText||!1,indent:t||0}}function gs(e){return{argb:as(os(e))}}function ys(e,t,r){let n=0;const i=r.internalProps.layoutMap;if(i.isHeader(e,t)){const r=i.getHeader(e,t);d(r?.hierarchyLevel)&&(n=(r.hierarchyLevel??0)*(i.rowHierarchyIndent??0))}else{const s=r.getBodyColumnDefine(e,t);if(s?.tree){const s=r.dataSource.getIndexKey(r.getRecordShowIndexByCell(e,t));n=Array.isArray(s)&&"none"!==r.getHierarchyState(e,t)?(s.length-1)*(i.hierarchyIndent??0):0}}return n}function vs(e,t){const r=v(e.pagination),n=e.isPivotTable(),i=e.internalProps.layoutMap;let s=e.rowCount-1;return{reset:()=>{n&&t&&r&&(e.internalProps.layoutMap.setPagination(r),e.refreshRowColCount())},handleRowCount:()=>(t&&r&&(n?(e.internalProps.layoutMap.setPagination(void 0),e.refreshRowColCount(),s=e.rowCount-1):s=e.recordsCount*i.bodyRowSpanCount+i.headerLevelCount),s)}}function ws(e){return new Promise((t=>{requestIdleCallback((e=>{t(e)}),e)}))}async function _s(e,t,r=!1){const n=new Ai.Workbook,i=n.addWorksheet("sheet1"),s=!!t?.exportAllData,{handleRowCount:o,reset:a}=vs(e,s),l=o(),h=e.colCount-1;i.properties.defaultRowHeight=40;const c=[],u=[],d=new Set;let f=0;function p(s){return new Promise((async o=>{for(;f<=l&&(!r||s?.timeRemaining()>0);){const r=Math.min(f+100-1,l);for(let s=0;s<=h;s++){const o=e.getColWidth(s);void 0===c[s]&&(c[s]={width:o/6});for(let o=f;o<=r;o++){if(0===s){const t=e.getRowHeight(o);i.getRow(o+1).height=t}await xs(s,o,e,i,n,t);const r=e.getCellRange(s,o);if(r.start.col!==r.end.col||r.start.row!==r.end.row){const e=`${r.start.col},${r.start.row}:${r.end.col},${r.end.row}`;d.has(e)||(d.add(e),u.push(r))}}}f=r+1}if(f>l)o();else{let e;r&&(e=await ws()),await p(e),o()}}))}await new Promise((async e=>{let t;r&&(t=await ws()),await p(t),e()})),i.columns=c,u.forEach((e=>{i.mergeCells(e.start.row+1,e.start.col+1,e.end.row+1,e.end.col+1)}));const m=[];e.frozenRowCount>0&&m.push({state:"frozen",ySplit:e.frozenRowCount,topLeftCell:ss(0,e.frozenRowCount)}),e.frozenColCount>0&&m.push({state:"frozen",xSplit:e.frozenColCount,topLeftCell:ss(e.frozenColCount,0)}),i.views=m,t?.excelJSWorksheetCallback&&t.excelJSWorksheetCallback(i);const b=await n.xlsx.writeBuffer();return a(),b}async function xs(e,t,n,i,s,o){const{layoutMap:a}=n.internalProps,l=n.getCellType(e,t),h=n.getCellRawRecord(e,t);let c=(h&&h.vtableMergeName)??n.getCellValue(e,t,!1);var d;!(d=c)||"object"!=typeof d&&"function"!=typeof d||"function"!=typeof d.then||(c=await c);const f=n.getCellStyle(e,t),m=n.getCellLocation(e,t),b="body"!==m?n.getHeaderDefine(e,t):n.getBodyColumnDefine(e,t);let g,y,v,w;if(("body"!==m||(b?.dragOrder||!!b?.icon||!!b?.tree))&&(g=n.getCellIcons(e,t)),"body"!==m?(y=b?.headerCustomRender,v=b?.headerCustomLayout):(y=b?.customRender||n.customRender,v=b?.customLayout),o?.formatExportOutput){const r={cellType:l,cellValue:c,table:n,col:e,row:t},s=o.formatExportOutput(r);if(void 0!==s){let r=i.getCell(ss(e,t));r.value=s,r.font=cs(f,l),r.fill=fs(f),r.border=ps(f);const a=ys(e,t,n);if(r.alignment=bs(f,Math.ceil(a/r.font.size)),r&&o?.formatExcelJSCell){const i=o.formatExcelJSCell({cellType:l,cellValue:c,table:n,col:e,row:t},r);i&&(r=i)}return r}}if("image"===l||"video"===l||"progressbar"===l||"sparkline"===l||a.isAxisCell(e,t)||!o?.ignoreIcon&&p(g)&&g.length||y||v)if(Es(l,a.isAxisCell(e,t),!!y||!!v,!(o?.ignoreIcon||!p(g)||!g.length),o)){const r=Cs(e,t,n),o=s.addImage({base64:r,extension:"png"});i.addImage(o,{tl:{col:e+1/80,row:t+1/120},br:{col:e+1,row:t+1},editAs:"oneCell"})}else w=i.getCell(ss(e,t));else if("text"===l||"link"===l){let r;if(w=i.getCell(ss(e,t)),"link"===l){const i=b.templateLink;if(i){const s=n.getCellOriginRecord(e,t);if(s&&s.vtableMerge);else{const o=n.getCellOriginValue(e,t),a=Object.assign({__value:c,__dataValue:o},s);if(u(i))r=i(a,e,t,n);else{const e=/\{\s*(\S+?)\s*\}/g;r=i.replace(e,((e,t)=>a[t]))}}}}w.value=function(e,t,r){if("link"===t)return{text:e,hyperlink:r||e,tooltip:e};return e}(c,l,r),w.font=cs(f,l),w.fill=fs(f),w.border=ps(f);const s=ys(e,t,n);w.alignment=bs(f,Math.ceil(s/w.font.size))}else if("chart"===l)if(Es("chart",!1,!1,!1,o)){const o=n.scenegraph.getCell(e,t);r.renderChart(o.firstChild);const a=Cs(e,t,n),l=s.addImage({base64:a,extension:"png"});i.addImage(l,{tl:{col:e+1/80,row:t+1/120},br:{col:e+1,row:t+1},editAs:"oneCell"}),n.scenegraph.updateNextFrame()}else w=i.getCell(ss(e,t));if(w&&o?.formatExcelJSCell){const r=o.formatExcelJSCell({cellType:l,cellValue:c,table:n,col:e,row:t},w);r&&(w=r)}return w}function Cs(e,t,n){let i=n.scenegraph.getCell(e,t),s=!1;"empty"===i.role&&(i=r.updateCell(e,t,n,!0),i.setStage(n.scenegraph.stage),s=!0,i.stage.dirtyBounds.set(-1/0,-1/0,1/0,1/0));const o=i.attribute.stroke;i.attribute.stroke=!1;const a=r.graphicUtil.drawGraphicToCanvas(i,n.scenegraph.stage);return i.attribute.stroke=o,s&&i.parent?.removeChild(i),a.toDataURL()}function Es(e,t,r,n,i){return!i?.skipImageExportCellType||("image"===e||"video"===e||"progressbar"===e||"sparkline"===e||"chart"===e?!i.skipImageExportCellType.includes(e):t?!i.skipImageExportCellType.includes("chart"):r?!i.skipImageExportCellType.includes("custom"):!n||!i.skipImageExportCellType.includes("textWithIcon"))}function Ss(e,t){const r=!!t?.exportAllData,{handleRowCount:n,reset:i}=vs(e,r),s=n(),o=e.colCount-1;let a="";for(let r=0;r<=s;r++){for(let n=0;n<=o;n++){const i=Ts(n,r,e,t);if("undefined"!=typeof Promise&&i instanceof Promise);else{const e=`${void 0===i?"":i}`;/^\[object .*\]$/.exec(e)||(a+=e)}n!==o&&(a+=",")}a+="\r\n"}return i(),a}function Ts(e,t,r,n){const i=r.getCellRawRecord(e,t),s=(i&&i.vtableMergeName)??r.getCellValue(e,t,!1);if(n?.formatExportOutput){const i={cellType:r.getCellType(e,t),cellValue:s,table:r,col:e,row:t},o=n.formatExportOutput(i);if(void 0!==o)return"string"==typeof o?'"'+o+'"':o}const o=r.getCellRange(e,t),a=o.start.col,l=o.start.row;if(a!==e||l!==t)return"";let h=s;return n?.escape?h=function(e){if("string"!=typeof e)return e;let t=e.replace(/"/g,'""');/[,"\r\n]/.test(t)&&(t=`"${t}"`);return t}(h):"string"==typeof h&&(h='"'+h+'"'),h}var Rs={exports:{}};!function(e,t){!function(){function t(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}function r(e,t,r){var n=new XMLHttpRequest;n.open("GET",e),n.responseType="blob",n.onload=function(){l(n.response,t,r)},n.onerror=function(){},n.send()}function n(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function i(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(r){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var s="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof a&&a.global===a?a:void 0,o=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=s.saveAs||("object"!=typeof window||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!o?function(e,t,o){var a=s.URL||s.webkitURL,l=document.createElement("a");t=t||e.name||"download",l.download=t,l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?i(l):n(l.href)?r(e,t,o):i(l,l.target="_blank")):(l.href=a.createObjectURL(e),setTimeout((function(){a.revokeObjectURL(l.href)}),4e4),setTimeout((function(){i(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,s,o){if(s=s||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(t(e,o),s);else if(n(e))r(e,s,o);else{var a=document.createElement("a");a.href=e,a.target="_blank",setTimeout((function(){i(a)}))}}:function(e,t,n,i){if((i=i||open("","_blank"))&&(i.document.title=i.document.body.innerText="downloading..."),"string"==typeof e)return r(e,t,n);var a="application/octet-stream"===e.type,l=/constructor/i.test(s.HTMLElement)||s.safari,h=/CriOS\/[\d]+/.test(navigator.userAgent);if((h||a&&l||o)&&"undefined"!=typeof FileReader){var c=new FileReader;c.onloadend=function(){var e=c.result;e=h?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),i?i.location.href=e:location=e,i=null},c.readAsDataURL(e)}else{var u=s.URL||s.webkitURL,d=u.createObjectURL(e);i?i.location=d:location.href=d,i=null,setTimeout((function(){u.revokeObjectURL(d)}),4e4)}});s.saveAs=l.saveAs=l,e.exports=l}()}(Rs);var ks,Ms,As,Os,Is=Rs.exports;!function(e){e.UP="top",e.RIGHT="right",e.DOWN="bottom",e.LEFT="left"}(ks||(ks={})),function(e){e.COPY="copy",e.SERIES="series"}(Ms||(Ms={})),function(e){e[e.STRING=1]="STRING",e[e.NUMBER=2]="NUMBER",e[e.BOOLEAN=3]="BOOLEAN",e[e.FORCE_STRING=4]="FORCE_STRING"}(As||(As={})),function(e){e.NUMBER="number",e.DATE="date",e.EXTEND_NUMBER="extendNumber",e.CHN_NUMBER="chnNumber",e.CHN_WEEK2="chnWeek2",e.CHN_WEEK3="chnWeek3",e.LOOP_SERIES="loopSeries",e.FORMULA="formula",e.OTHER="other"}(Os||(Os={}));var Ns=function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e},Fs=Qe,Ps=function(){try{var e=Fs(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();var js=function(e,t,r){"__proto__"==t&&Ps?Ps(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r},Ls=js,Ds=Y,Bs=Object.prototype.hasOwnProperty;var Hs=function(e,t,r){var n=e[t];Bs.call(e,t)&&Ds(n,r)&&(void 0!==r||t in e)||Ls(e,t,r)},zs=Hs,Us=js;var Vs=function(e,t,r,n){var i=!r;r||(r={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=n?n(r[a],e[a],a,r,e):void 0;void 0===l&&(l=e[a]),i?Us(r,a,l):zs(r,a,l)}return r},$s=Vs,Ws=mn;var qs=function(e,t){return e&&$s(t,Ws(t),e)};var Ks=Ae,Ys=rn,Xs=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t},Gs=Object.prototype.hasOwnProperty;var Zs=en,Js=function(e){if(!Ks(e))return Xs(e);var t=Ys(e),r=[];for(var n in e)("constructor"!=n||!t&&Gs.call(e,n))&&r.push(n);return r},Qs=un;var eo=function(e){return Qs(e)?Zs(e,!0):Js(e)},to=Vs,ro=eo;var no=function(e,t){return e&&to(t,ro(t),e)},io={exports:{}};!function(e,t){var r=ge,n=t&&!t.nodeType&&t,i=n&&e&&!e.nodeType&&e,s=i&&i.exports===n?r.Buffer:void 0,o=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var r=e.length,n=o?o(r):new e.constructor(r);return e.copy(n),n}}(io,io.exports);var so=io.exports;var oo=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t},ao=Vs,lo=gr;var ho=function(e,t){return ao(e,lo(e),t)},co=nn(Object.getPrototypeOf,Object),uo=ar,fo=co,po=gr,mo=dr,bo=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)uo(t,po(e)),e=fo(e);return t}:mo,go=Vs,yo=bo;var vo=function(e,t){return go(e,yo(e),t)},wo=ur,_o=bo,xo=eo;var Co=function(e){return wo(e,xo,_o)},Eo=Object.prototype.hasOwnProperty;var So=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&Eo.call(e,"index")&&(r.index=e.index,r.input=e.input),r},To=Jt;var Ro=function(e){var t=new e.constructor(e.byteLength);return new To(t).set(new To(e)),t},ko=Ro;var Mo=function(e,t){var r=t?ko(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)},Ao=/\w*$/;var Oo=function(e){var t=new e.constructor(e.source,Ao.exec(e));return t.lastIndex=e.lastIndex,t},Io=ye?ye.prototype:void 0,No=Io?Io.valueOf:void 0;var Fo=Ro;var Po=Ro,jo=Mo,Lo=Oo,Do=function(e){return No?Object(No.call(e)):{}},Bo=function(e,t){var r=t?Fo(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)};var Ho=function(e,t,r){var n=e.constructor;switch(t){case"[object ArrayBuffer]":return Po(e);case"[object Boolean]":case"[object Date]":return new n(+e);case"[object DataView]":return jo(e,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return Bo(e,r);case"[object Map]":case"[object Set]":return new n;case"[object Number]":case"[object String]":return new n(e);case"[object RegExp]":return Lo(e);case"[object Symbol]":return Do(e)}},zo=Ae,Uo=Object.create,Vo=function(){function e(){}return function(t){if(!zo(t))return{};if(Uo)return Uo(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}(),$o=co,Wo=rn;var qo=function(e){return"function"!=typeof e.constructor||Wo(e)?{}:Vo($o(e))},Ko=zn,Yo=vr;var Xo=function(e){return Yo(e)&&"[object Map]"==Ko(e)},Go=Hr,Zo=Ur&&Ur.isMap,Jo=Zo?Go(Zo):Xo,Qo=zn,ea=vr;var ta=function(e){return ea(e)&&"[object Set]"==Qo(e)},ra=Hr,na=Ur&&Ur.isSet,ia=na?ra(na):ta,sa=Vt,oa=Ns,aa=Hs,la=qs,ha=no,ca=so,ua=oo,da=ho,fa=vo,pa=vn,ma=Co,ba=zn,ga=So,ya=Ho,va=qo,wa=lr,_a=Or,xa=Jo,Ca=Ae,Ea=ia,Sa=mn,Ta=eo,Ra="[object Arguments]",ka="[object Function]",Ma="[object Object]",Aa={};Aa[Ra]=Aa["[object Array]"]=Aa["[object ArrayBuffer]"]=Aa["[object DataView]"]=Aa["[object Boolean]"]=Aa["[object Date]"]=Aa["[object Float32Array]"]=Aa["[object Float64Array]"]=Aa["[object Int8Array]"]=Aa["[object Int16Array]"]=Aa["[object Int32Array]"]=Aa["[object Map]"]=Aa["[object Number]"]=Aa[Ma]=Aa["[object RegExp]"]=Aa["[object Set]"]=Aa["[object String]"]=Aa["[object Symbol]"]=Aa["[object Uint8Array]"]=Aa["[object Uint8ClampedArray]"]=Aa["[object Uint16Array]"]=Aa["[object Uint32Array]"]=!0,Aa["[object Error]"]=Aa[ka]=Aa["[object WeakMap]"]=!1;var Oa=function e(t,r,n,i,s,o){var a,l=1&r,h=2&r,c=4&r;if(n&&(a=s?n(t,i,s,o):n(t)),void 0!==a)return a;if(!Ca(t))return t;var u=wa(t);if(u){if(a=ga(t),!l)return ua(t,a)}else{var d=ba(t),f=d==ka||"[object GeneratorFunction]"==d;if(_a(t))return ca(t,l);if(d==Ma||d==Ra||f&&!s){if(a=h||f?{}:va(t),!l)return h?fa(t,ha(a,t)):da(t,la(a,t))}else{if(!Aa[d])return s?t:{};a=ya(t,d,l)}}o||(o=new sa);var p=o.get(t);if(p)return p;o.set(t,a),Ea(t)?t.forEach((function(i){a.add(e(i,r,n,i,t,o))})):xa(t)&&t.forEach((function(i,s){a.set(s,e(i,r,n,s,t,o))}));var m=u?void 0:(c?h?ma:pa:h?Ta:Sa)(t);return oa(m||t,(function(i,s){m&&(i=t[s=i]),aa(a,s,e(i,r,n,s,t,o))})),a},Ia=Oa;var Na=l((function(e){return Ia(e,5)}));const Fa={"零":0,"一":1,"二":2,"三":3,"四":4,"五":5,"六":6,"七":7,"八":8,"九":9},Pa=["零","一","二","三","四","五","六","七","八","九"],ja=["","万","亿","万亿","亿亿"],La=["","十","百","千"],Da={"十":{value:10,secUnit:!1},"百":{value:100,secUnit:!1},"千":{value:1e3,secUnit:!1},"万":{value:1e4,secUnit:!0},"亿":{value:1e8,secUnit:!0}};function Ba(e){if(!e)return 0;let t=0,r=0,n=0,i=!1;const s=e.split("");for(let e=0;e<s.length;e++){const o=Fa[s[e]];if(void 0!==o)n=o,e===s.length-1&&(r+=n);else{const o=Da[s[e]],a=o.value;i=o.secUnit,i?(r=(r+n)*a,t+=r,r=0):r+=n*a,n=0}}return t+r}function Ha(e){let t="",r="",n=0,i=!0;for(;e>0;){const s=e%10;0===s?i||(i=!0,r=Pa[s]+r):(i=!1,t=Pa[s],t+=La[n],r=t+r),n++,e=Math.floor(e/10)}return r}function za(e){let t=0,r="",n="",i=!1;if(0===e)return Pa[0];for(;e>0;){const s=e%1e4;i&&(n=Pa[0]+n),r=Ha(s),r+=0!==s?ja[t]:ja[0],n=r+n,i=s<1e3&&s>0,e=Math.floor(e/1e4),t++}return n}function Ua(e){if(!e)return{isExtendNumber:!1};const t=/0|([1-9]+[0-9]*)/g,r=t.test(e);if(r){const r=e.match(t);if(r&&r.length>0){const t=r[r.length-1],n=e.lastIndexOf(t),i=e.substr(0,n),s=e.substr(n+t.length);return{isExtendNumber:!0,matchTxt:Number(t),beforeTxt:i,afterTxt:s}}return{isExtendNumber:!1}}return{isExtendNumber:r}}function Va(e){let t=!0;const r=e[1]-e[0];for(let n=1;n<e.length;n++)if(e[n]-e[n-1]!==r){t=!1;break}return t}function $a(e,t){const r=[];for(let n=1;n<=t;n++){const t=(n-1)%e.length,i=Na(e[t]);Qa(i),r.push({v:null,t:null,...i})}return r}function Wa(e,t,r,n){n&&e.forEach((e=>{const{v:t,meta:r}=n.toNumber(e.v);e.v=t,e.f=r}));const i=[],s=[];for(let t=0;t<e.length;t++)s.push(Number(e[t]?.v));if(e.length>2&&function(e){let t=!0;const r=e[1]/e[0];for(let n=1;n<e.length;n++)if(e[n]/e[n-1]!==r){t=!1;break}return t}(s))for(let r=1;r<=t;r++){const t=(r-1)%e.length,s=Na(e[t]);Qa(s);const o=Number(e[e.length-1]?.v),a=Number(e[0]?.v),l=o*(Number(e[1]?.v)/a)**r;s&&(s.v=n?n.fromNumber(l,s.f):l,i.push(s))}else{const o=function(e){const t=[];for(let r=1;r<=e;r++)t.push(r);return t}(e.length);for(let a=1;a<=t;a++){const t=(a-1)%e.length,l=Na(e[t]);Qa(l);const h=r===ks.DOWN||r===ks.RIGHT,c=qa(e.length+a,s,o,h);l&&(l.v=n?n.fromNumber(c,l.f):c,i.push(l))}}return i}function qa(e,t,r,n=!0){function i(e){let t=0;for(let r=0;r<e.length;r++)t+=e[r];return t/e.length}const s=i(r),o=i(t);let a,l=0,h=0;for(let e=0;e<r.length;e++)l+=(r[e]-s)*(t[e]-o),h+=(r[e]-s)*(r[e]-s);a=0===h?n?1:-1:l/h;const c=o-a*s;return Math.round(1e5*(c+a*e))/1e5}function Ka(e,t,r){const n=[],i=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=t;s++){const t=(s-1)%e.length,o=Na(e[t]);Qa(o);const a=`${e[e.length-1]?.v??""}`;if(!a)continue;const l=a?.match(i),h=l?.[l.length-1];if(!h)continue;const c=Math.abs(Number(h)+r*s),u=a.lastIndexOf(h),d=a.substr(0,u)+c.toString()+a.substr(u+h.length);o&&(o.v=d,n.push(o))}return n}function Ya(e,t,r,n=0){const i=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=i.length)return[];const s=i[n],o=[];for(let n=1;n<=t;n++){const t=(n-1)%e.length,i=Na(e[t]);Qa(i);let a=0;if(e[e.length-1]?.v===s[0])a=7+r*n;else{const t=`${e[e.length-1]?.v??""}`;if(t){a=Ba(t.substr(t.length-1,1))+r*n}}a<0&&(a=7*Math.ceil(Math.abs(a)/7)+a);const l=a%7;i&&(i.v=s[l],o.push(i))}return o}function Xa(e,t,r){const n=[];for(let i=1;i<=t;i++){const t=(i-1)%e.length,s=Na(e[t]);Qa(s);const o=Ba(`${e[e.length-1]?.v??""}`)+r*i;let a;a=o<=0?"零":za(o),s&&(s.v=a,n.push(s))}return n}const Ga={enWeek1:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],enWeek2:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],enMonth1:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],enMonth2:["January","February","March","April","May","June","July","August","September","October","November","December"],chnMonth1:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],chnMonth2:["正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月"],chHour1:["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],chHour2:["子时","丑时","寅时","卯时","辰时","巳时","午时","未时","申时","酉时","戌时","亥时"],chYear1:["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],chSeason1:["春","夏","秋","冬"],chSeason2:["春季","夏季","秋季","冬季"]};function Za(e){let t="";const r=[];return Object.keys(Ga).forEach((n=>{Ga[n].includes(e)&&(t=n,r.push(...Ga[n]))})),{name:t,series:r}}function Ja(e,t,r,n){const i=n.length,s=[];for(let o=1;o<=t;o++){const t=(o-1)%e.length,a=Na(e[t]);Qa(a);const l=`${e[e.length-1]?.v??""}`;let h=n.indexOf(l)+r*o;h<0&&(h+=Math.abs(r)*i);const c=h%i;a&&(a.v=n[c],s.push(a))}return s}function Qa(e){e&&"custom"in e&&delete e.custom}function el(e,t,r=new Date){const n=e.trim();if("yyyy-MM-dd"===t){const[e,t,r]=n.split("-").map(Number);return new Date(e,t-1,r)}if("yyyy-M-d"===t){const[e,t,r]=n.split("-").map(Number);return new Date(e,t-1,r)}if("yyyy/MM/dd"===t){const[e,t,r]=n.split("/").map(Number);return new Date(e,t-1,r)}if("yyyy/M/d"===t){const[e,t,r]=n.split("/").map(Number);return new Date(e,t-1,r)}if("MM/dd/yyyy"===t){const[e,t,r]=n.split("/").map(Number);return new Date(r,e-1,t)}if("yyyy年M月d日"===t){const e=n.match(/^(\d{4})年(\d{1,2})月(\d{1,2})(日)?$/);if(e)return new Date(Number(e[1]),Number(e[2])-1,Number(e[3]))}const i=new Date(n);return isNaN(i.getTime())?new Date(r):i}function tl(e){return!isNaN(e.getTime())}function rl(e,t){const r=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())-Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor(r/864e5)}class nl{key="date";baseDate=new Date(1900,0,1);dateFormats=[{pattern:/^\d{4}-\d{2}-\d{2}$/,format:"yyyy-MM-dd"},{pattern:/^\d{4}-\d{1,2}-\d{1,2}$/,format:"yyyy-M-d"},{pattern:/^\d{4}\/\d{2}\/\d{2}$/,format:"yyyy/MM/dd"},{pattern:/^\d{4}\/\d{1,2}\/\d{1,2}$/,format:"yyyy/M/d"},{pattern:/^\d{2}\/\d{2}\/\d{4}$/,format:"MM/dd/yyyy"},{pattern:/^\d{4}年\d{1,2}月\d{1,2}(日)?$/,format:"yyyy年M月d日",parser:e=>{const t=e.match(/(\d{4})年(\d{1,2})月(\d{1,2})/);if(!t)throw new Error("无效的中文日期格式");return new Date(+t[1],+t[2]-1,+t[3])}}];detect(e){if(e instanceof Date)return!isNaN(e.getTime());if("string"!=typeof e)return!1;const t=e.trim(),r=this.dateFormats.find((e=>e.pattern.test(t)));if(r)try{return tl(r.parser?r.parser(t):el(t,r.format,new Date))}catch{return!1}return!1}toNumber(e){let t,r;if(e instanceof Date){if(!tl(e))throw new Error("无效的日期对象");t=e,r="yyyy-MM-dd"}else{const n=e.trim(),i=this.dateFormats.find((e=>e.pattern.test(n)));if(!i)throw new Error(`不支持的日期格式: ${n}`);if(t=i.parser?i.parser(n):el(n,i.format,new Date),!tl(t))throw new Error(`无效的日期值: ${n}`);r=i.format}return{v:rl(t,this.baseDate),meta:r}}fromNumber(e,t){const r=function(e,t){const r=new Date(e);return r.setDate(r.getDate()+t),r}(this.baseDate,e);return r.setHours(0,0,0,0),function(e,t){const r=e.getFullYear(),n=e.getMonth()+1,i=e.getDate(),s=e=>e.toString().padStart(2,"0");switch(t){case"yyyy-MM-dd":default:return`${r}-${s(n)}-${s(i)}`;case"yyyy-M-d":return`${r}-${n}-${i}`;case"yyyy/MM/dd":return`${r}/${s(n)}/${s(i)}`;case"yyyy/M/d":return`${r}/${n}/${i}`;case"MM/dd/yyyy":return`${s(n)}/${s(i)}/${r}`;case"yyyy年M月d日":return`${r}年${n}月${i}日`}}(r,t||"yyyy-MM-dd")}}const il=new class{converters=[];register(e){this.converters.push(e)}getConverter(e){return this.converters.find((t=>t.detect(e)))||null}getConverterByKey(e){return this.converters.find((t=>t.key===e))||null}};il.register(new nl);const sl={type:Os.DATE,priority:1100,match:(e,t)=>"string"==typeof e?.v&&il.getConverter(e.v)instanceof nl,isContinue:(e,t)=>e.type===Os.DATE,applyFunctions:{[Ms.SERIES]:(e,t,r)=>{const{data:n}=e,i=il.getConverter(n[0]?.v);return r===ks.LEFT||r===ks.UP?(n.reverse(),Wa(n,t,r,i).reverse()):Wa(n,t,r,i)}}},ol={type:Os.NUMBER,priority:1e3,match:e=>"number"==typeof e?.v||e?.t===As.NUMBER,isContinue:(e,t)=>e.type===Os.NUMBER,applyFunctions:{[Ms.SERIES]:(e,t,r)=>{const{data:n}=e;return r===ks.LEFT||r===ks.UP?(n.reverse(),Wa(n,t,r).reverse()):Wa(n,t,r)}}},al={type:Os.OTHER,priority:0,match:()=>!0,isContinue:(e,t)=>e.type===Os.OTHER},ll={type:Os.EXTEND_NUMBER,priority:900,match:e=>Ua(`${e?.v??""}`||"").isExtendNumber,isContinue:(e,t)=>{if(e.type===Os.EXTEND_NUMBER){const{beforeTxt:r,afterTxt:n}=Ua(`${e.cellData?.v??""}`||""),{beforeTxt:i,afterTxt:s}=Ua(`${t?.v??""}`||"");if(r===i&&n===s)return!0}return!1},applyFunctions:{[Ms.SERIES]:(e,t,r)=>{const{data:n}=e,i=r===ks.UP||r===ks.LEFT;let s;if(1===n.length)return s=i?-1:1,fl(Ka(n,t,s),i);const o=[];for(let e=0;e<n.length;e++){const t=`${n[e]?.v}`;t&&o.push(Number(Ua(t).matchTxt))}return i&&(n.reverse(),o.reverse()),Va(o)?(s=o[1]-o[0],fl(Ka(n,t,s),i)):$a(n,t)}}},hl={type:Os.CHN_NUMBER,priority:830,match:e=>!!function(e){if(!e)return!1;let t=!0;if(e)if(1===e.length)t="日"===e||e in Fa;else{const r=e.split("");for(let e=0;e<r.length;e++)if(!(r[e]in Fa)&&!(r[e]in Da)){t=!1;break}}return t}(`${e?.v??""}`||""),isContinue:(e,t)=>e.type===Os.CHN_NUMBER,applyFunctions:{[Ms.SERIES]:(e,t,r)=>{const{data:n}=e,i=r===ks.LEFT||r===ks.UP;if(1===n.length){let e;return e=i?-1:1,fl(Xa(n,t,e),i)}let s=!1;for(let e=0;e<n.length;e++){const t=n[e]?.v;if("日"===t){s=!0;break}}const o=[];let a=0;for(let e=0;e<n.length;e++){const t=`${n[e]?.v}`;"日"===t?0===e?o.push(0):(a++,o.push(7*a)):s&&Ba(t)>0&&Ba(t)<7?o.push(Ba(t)+7*a):o.push(Ba(t))}if(i&&(n.reverse(),o.reverse()),Va(o)){return fl(Xa(n,t,o[1]-o[0]),i)}return $a(n,t)}}},cl={type:Os.CHN_WEEK2,priority:820,match:e=>!!function(e){let t;return t=2===e.length&&("周一"===e||"周二"===e||"周三"===e||"周四"===e||"周五"===e||"周六"===e||"周日"===e),t}(`${e?.v??""}`||""),isContinue:(e,t)=>e.type===Os.CHN_WEEK2,applyFunctions:{[Ms.SERIES]:(e,t,r)=>{const{data:n}=e,i=r===ks.LEFT||r===ks.UP;if(1===n.length){let e;return e=i?-1:1,fl(Ya(n,t,e,1),i)}const s=[];let o=0;for(let e=0;e<n.length;e++){const t=`${n[e]?.v}`,r=t?.substr(t.length-1,1);"周日"===t?0===e?s.push(0):(o++,s.push(7*o)):s.push(Ba(r)+7*o)}if(i&&(n.reverse(),s.reverse()),Va(s)){return fl(Ya(n,t,s[1]-s[0],1),i)}return $a(n,t)}}},ul={type:Os.CHN_WEEK3,priority:810,match:e=>function(e){let t;return t=3===e.length&&("星期一"===e||"星期二"===e||"星期三"===e||"星期四"===e||"星期五"===e||"星期六"===e||"星期日"===e),t}(`${e?.v??""}`||""),isContinue:(e,t)=>e.type===Os.CHN_WEEK3,applyFunctions:{[Ms.SERIES]:(e,t,r)=>{const{data:n}=e,i=r===ks.LEFT||r===ks.UP;if(1===n.length){let e;return e=i?-1:1,fl(Ya(n,t,e,2),i)}const s=[];let o=0;for(let e=0;e<n.length;e++){const t=`${n[e]?.v}`;if(t){const r=t.substr(t.length-1,1);"星期日"===t?0===e?s.push(0):(o++,s.push(7*o)):s.push(Ba(r)+7*o)}}if(i&&(n.reverse(),s.reverse()),Va(s)){return fl(Ya(n,t,s[1]-s[0],2),i)}return $a(n,t)}}},dl={type:Os.LOOP_SERIES,priority:800,match:e=>function(e){let t=!1;return Object.keys(Ga).forEach((r=>{Ga[r].includes(e)&&(t=!0)})),t}(`${e?.v??""}`||""),isContinue:(e,t)=>e.type===Os.LOOP_SERIES&&Za(`${e.cellData?.v??""}`||"").name===Za(`${t?.v??""}`||"").name,applyFunctions:{[Ms.SERIES]:(e,t,r)=>{const{data:n}=e,i=r===ks.LEFT||r===ks.UP,{series:s}=Za(`${n[0]?.v}`||"");if(1===n.length){let e;return e=i?-1:1,fl(Ja(n,t,e,s),i)}const o=[];let a=0;for(let e=0;e<n.length;e++){const t=`${n[e]?.v}`;t&&(t===s[0]?0===e?o.push(0):(a++,o.push(a*s.length)):o.push(s.indexOf(t)+7*a))}if(i&&(n.reverse(),o.reverse()),Va(o)){return fl(Ja(n,t,o[1]-o[0],s),i)}return $a(n,t)}}};function fl(e,t){return t?e.reverse():e}class pl{_rules=[];constructor(){this._init()}_init(){this._rules=[sl,ol,ll,hl,cl,ul,dl,al].sort(((e,t)=>t.priority-e.priority))}registerRule(e){if(this._rules.find((t=>t.type===e.type)))throw new Error(`Registry rule failed, type '${e.type}' already exist!`);const t=this._rules.findIndex((t=>t.priority<e.priority));this._rules.splice(-1===t?this._rules.length:t,0,e)}getRules(){return this._rules}}function ml(e){const t=Math.min(e.start.col,e.end.col),r=Math.min(e.start.row,e.end.row),n=Math.max(e.start.col,e.end.col),i=Math.max(e.start.row,e.end.row),s=[],o=[];for(let e=t;e<=n;e++)s.push(e);for(let e=r;e<=i;e++)o.push(e);return{cols:s,rows:o}}function bl(e,t,r){return e===ks.DOWN||e===ks.UP?{cols:r.cols,rows:r.rows.filter((e=>!t.rows.includes(e)))}:{cols:r.cols.filter((e=>!t.cols.includes(e))),rows:r.rows}}function gl(e,t,r){const n=e.scenegraph.highPerformanceGetCell(t,r).globalAABBBounds;e.showDropDownMenu(t,r,{content:[{type:"item",text:"复制填充",icon:{width:16,height:16,svg:'<svg t="1756136702877" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1474" width="200" height="200"><path d="M853.333333 981.333333h-384c-72.533333 0-128-55.466667-128-128v-384c0-72.533333 55.466667-128 128-128h384c72.533333 0 128 55.466667 128 128v384c0 72.533333-55.466667 128-128 128z m-384-554.666666c-25.6 0-42.666667 17.066667-42.666666 42.666666v384c0 25.6 17.066667 42.666667 42.666666 42.666667h384c25.6 0 42.666667-17.066667 42.666667-42.666667v-384c0-25.6-17.066667-42.666667-42.666667-42.666666h-384z" p-id="1475"></path><path d="M213.333333 682.666667H170.666667c-72.533333 0-128-55.466667-128-128V170.666667c0-72.533333 55.466667-128 128-128h384c72.533333 0 128 55.466667 128 128v42.666666c0 25.6-17.066667 42.666667-42.666667 42.666667s-42.666667-17.066667-42.666667-42.666667V170.666667c0-25.6-17.066667-42.666667-42.666666-42.666667H170.666667c-25.6 0-42.666667 17.066667-42.666667 42.666667v384c0 25.6 17.066667 42.666667 42.666667 42.666666h42.666666c25.6 0 42.666667 17.066667 42.666667 42.666667s-17.066667 42.666667-42.666667 42.666667z" p-id="1476"></path></svg>'}},{type:"item",text:"序列填充",icon:{width:16,height:16,svg:'<svg t="1756136788547" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2463" width="200" height="200"><path d="M312.832482 65.167035H959.204489c35.706211 0 64.64232 29.473622 64.64232 65.832527 0 36.346107-28.936109 65.832527-64.629522 65.832527H312.819684c-35.693413 0-64.629522-29.473622-64.629522-65.832527 0-36.346107 28.936109-65.832527 64.629522-65.832527z m0 394.982363H959.204489c35.706211 0 64.64232 29.460824 64.64232 65.819729 0 36.358905-28.936109 65.832527-64.629522 65.832527H312.819684c-35.693413 0-64.629522-29.473622-64.629522-65.832527 0-36.346107 28.936109-65.819729 64.629522-65.819729z m0 394.969566H959.204489c35.706211 0 64.64232 29.473622 64.64232 65.819729 0 36.358905-28.936109 65.832527-64.629522 65.832527H312.819684c-35.693413 0-64.629522-29.473622-64.629522-65.832527 0-36.346107 28.936109-65.819729 64.629522-65.819729zM12.286008 69.108796V38.176211c9.892796 0.767876 19.836784 0.767876 29.72958 0A41.823619 41.823619 0 0 0 63.989626 25.672638c4.261709-4.671243 7.358807-10.315128 9.048133-16.458132 0.37114-3.058704 0.37114-6.143004 0-9.214506H114.413451v229.748352H65.93491V69.108796H12.286008z m0 510.176487a130.730805 130.730805 0 0 1 45.240665-49.374395 334.537763 334.537763 0 0 0 40.070304-32.250771 48.47854 48.47854 0 0 0 14.218495-33.581756 37.31875 37.31875 0 0 0-7.755543-24.354451 28.193829 28.193829 0 0 0-23.266628-9.879998 27.643518 27.643518 0 0 0-31.02217 15.139945 78.27211 78.27211 0 0 0-5.170362 28.30901H2.585181a114.311067 114.311067 0 0 1 10.340723-48.056208c12.388392-24.124089 38.086625-37.984242 64.629522-34.887144a79.897447 79.897447 0 0 1 57.539472 20.41269 71.783562 71.783562 0 0 1 21.321343 53.981648 74.637499 74.637499 0 0 1-14.858391 46.072531 152.16733 152.16733 0 0 1-32.967455 29.627197L90.481331 553.625443l-23.266628 17.763521c-4.082538 3.583419-7.563574 7.806734-10.353522 12.51637h99.542262v40.147092H0a110.945213 110.945213 0 0 1 10.340724-45.419837l1.945284 0.665492zM44.600769 948.582211a53.495327 53.495327 0 0 0 4.517668 23.036265 30.279891 30.279891 0 0 0 29.742378 17.110826c7.422797 0.255959 14.717614-2.073264 20.681447-6.578133 6.7829-6.962071 10.315128-16.547717 9.688029-26.325332a30.356678 30.356678 0 0 0-18.096266-30.945383 91.735527 91.735527 0 0 0-32.314761-8.561812V883.440772a83.903197 83.903197 0 0 0 30.382274-4.607253 27.106005 27.106005 0 0 0 14.858391-28.30901 30.612637 30.612637 0 0 0-7.755542-21.730877 27.528337 27.528337 0 0 0-21.321344-8.549014 26.939632 26.939632 0 0 0-23.279425 10.532692 44.063256 44.063256 0 0 0-7.102849 27.643519H2.585181a117.101015 117.101015 0 0 1 5.823056-32.916264 74.381541 74.381541 0 0 1 17.443572-25.019944 60.534186 60.534186 0 0 1 20.681447-12.503572 89.55988 89.55988 0 0 1 29.742378-3.289067A78.540867 78.540867 0 0 1 129.259044 801.79001a57.744238 57.744238 0 0 1 20.041551 46.085328 51.921182 51.921182 0 0 1-12.286008 34.887144c-4.159326 5.170362-9.470465 9.227304-15.511086 11.850879 6.7829 1.510155 12.900309 5.208756 17.45637 10.532692a57.821026 57.821026 0 0 1 17.443572 44.10165 75.136618 75.136618 0 0 1-20.028753 52.010768 76.122059 76.122059 0 0 1-59.471958 22.383571 71.962733 71.962733 0 0 1-64.629522-32.250771A97.52019 97.52019 0 0 1 1.279793 946.611331l43.308178 1.97088z" fill="#515151" p-id="2464"></path></svg>'}}],referencePosition:{rect:{right:n.x2+110,bottom:n.y2}}})}function yl(e){return{getValue:(t,r)=>{const n=e.getCellValue(r,t);return"number"!=typeof n&&isNaN(Number(n))?{v:n||"",t:As.STRING}:{v:n,t:As.NUMBER}},getMaxRows:()=>e.records.length,getMaxColumns:()=>e.columns.length}}class vl{sourceData=[];autoFillService;tableInstance;sourceRange;targetRange;direction;headers;options;constructor(e){this.options=e,this.autoFillService=new pl}setTable(e){this.headers={row:new Set,col:new Set},this.tableInstance=e,e.on(r.TABLE_EVENT_TYPE.DROPDOWN_MENU_CLICK,(e=>{"复制填充"===e.text?this.fillData(Ms.COPY):"序列填充"===e.text&&this.fillData(Ms.SERIES)}));const t=this.tableInstance.getAllRowHeaderCells()[0];t&&t.forEach((e=>{this.headers.col.add(e.col)}));const n=this.tableInstance.getAllColumnHeaderCells()[0];n&&n.forEach((e=>{this.headers.row.add(e.row)}))}handleStartDrag(e){this.sourceRange=ml(e),this.sourceRange.cols=this.sourceRange.cols.filter((e=>!this.headers.col.has(e))),this.sourceRange.rows=this.sourceRange.rows.filter((e=>!this.headers.row.has(e)))}handleEndDrag(e,t){this.direction=t;const r=ml(e);this.targetRange=bl(this.direction,this.sourceRange,r),this.targetRange.cols=this.targetRange.cols.filter((e=>!this.headers.col.has(e))),this.targetRange.rows=this.targetRange.rows.filter((e=>!this.headers.row.has(e))),this.options?.fillMode?this.fillData(this.options.fillMode):gl(this.tableInstance,Math.max(...r.cols),Math.max(...r.rows))}handleDbClick(){if(!this.sourceRange)return;this.direction=ks.DOWN;const e=ml(this._detectFillRange());if(this.targetRange=bl(this.direction,this.sourceRange,e),this.targetRange.cols=this.targetRange.cols.filter((e=>!this.headers.col.has(e))),this.targetRange.rows=this.targetRange.rows.filter((e=>!this.headers.row.has(e))),0===this.targetRange.cols.length||0===this.targetRange.rows.length)return;const t=this.sourceRange.cols[0],r=this.sourceRange.rows[0],n=this.targetRange.cols[this.targetRange.cols.length-1],i=this.targetRange.rows[this.targetRange.rows.length-1],s=this.tableInstance.stateManager;s.updateSelectPos(t,r,!1,!1,!1,!0,!0),s.updateInteractionState(b.grabing),s.updateSelectPos(n,i,!1,!1,!1,!0,!0),s.endSelectCells(!1,!1),s.updateInteractionState(b.default),this.options?.fastFillMode?this.fillData(this.options.fastFillMode):gl(this.tableInstance,n,i)}fillData(e){this.sourceData=this.getSourceData(this.sourceRange,this.direction);const t={source:this.sourceRange,target:this.targetRange};this._fillData(t,this.direction,e)}getSourceData(e,t){const r=this.autoFillService.getRules(),n=[],i=t===ks.DOWN||t===ks.UP;let s,o;i?(s=e.cols,o=e.rows):(s=e.rows,o=e.cols);const a=yl(this.tableInstance);return s.forEach((e=>{const t=this.getEmptySourceDataPiece(),s={type:void 0,cellData:void 0};o.forEach((n=>{let l;l=i?a.getValue(n,e):a.getValue(e,n);const{type:h,isContinue:c}=r.find((e=>e.match(l,null)))||al;if(c(s,l)){const e=t[h],r=e[e.length-1];r.data.push(l),r.index.push(n-o[0])}else{const e=t[h];e?e.push({data:[l],index:[n-o[0]]}):t[h]=[{data:[l],index:[n-o[0]]}]}s.type=h,s.cellData=l})),n.push(t)})),n}getEmptySourceDataPiece(){const e={};return this.autoFillService.getRules().forEach((t=>{e[t.type]=[]})),e}_detectFillRange(){const e={row:Math.min(...this.sourceRange.rows),col:Math.min(...this.sourceRange.cols)},t={row:Math.max(...this.sourceRange.rows),col:Math.max(...this.sourceRange.cols)},r=yl(this.tableInstance),n=r.getMaxRows(),i=r.getMaxColumns();let s=t.row;if(e.col>0&&r.getValue(e.row,e.col-1)?.v){let t=e.row;for(;r.getValue(t,e.col-1)?.v&&t<=n;)t+=1;s=t-1}else if(t.col<i&&r.getValue(t.row,t.col+1)?.v){let i=e.row;for(;r.getValue(i,t.col+1)?.v&&i<=n;)i+=1;s=i-1}for(let n=t.row+1;n<=s;n++)for(let i=e.col;i<=t.col;i++)if(r.getValue(n,i)?.v){s=n-1;break}return{start:{row:e.row,col:e.col},end:{row:s,col:t.col}}}_fillData(e,t,r){const{source:n,target:i}=e;if(!n||!i||null==t)return;const{cols:s,rows:o}=i,{cols:a,rows:l}=n,h=this.sourceData;let c;c=t===ks.DOWN||t===ks.UP?l.length:a.length;const u=[];if(t===ks.DOWN||t===ks.UP){const n=o.length,i=[];s.forEach(((s,o)=>{const a=h[o],l=this.getApplyData(a,c,n,t,r,e);i.push(l)}));for(let e=0;e<i[0].length;e++){const t=[];for(let r=0;r<i.length;r++)t.push(i[r][e]);u.push(t)}}else{const n=s.length;o.forEach(((i,s)=>{const o=h[s],a=this.getApplyData(o,c,n,t,r,e),l=[];for(let e=0;e<a.length;e++)l.push(a[e]);u.push(l)}))}const d=[];o.forEach(((e,t)=>{const r=[];s.forEach(((n,i)=>{const s=function(e,t,r){const n=e.getCellRange(t,r);return n.start.col!==n.end.col||n.start.row!==n.end.row?n:null}(this.tableInstance,n,e);s&&this.tableInstance.unmergeCells(s.start.col,s.start.row,s.end.col,s.end.row),u[t][i]&&r.push(u[t][i]?.v+"")})),d.push(r)}));const f=Math.min(...o),p=Math.min(...s);this.tableInstance.changeCellValues(p,f,d)}getApplyData(e,t,r,n,i,s){const o=[],a=Math.floor(r/t),l=r%t,h=this.autoFillService.getRules(),c={};h.forEach((e=>{c[e.type]=[]})),h.forEach((o=>{const{type:h,applyFunctions:u={}}=o,d=e[h];d&&d.forEach((o=>{const d=function(e,t){let r=0;for(let n=0;n<e.length&&e[n]<t;n++)r++;return r}(o.index,l),f=o.index.length*a+d,p=this.applyFunctions(o,f,n,i,u,e,s),m=function(e,t,r){const n=[],i=Math.floor(t/e),s=t%e;let o=0;if(i>0){for(let t=0;t<i;t++)for(let i=0;i<r.length;i++)n[r[i]+t*e]=o,o++;for(let t=0;t<r.length&&r[t]<s;t++)n[r[t]+e*i]=o,o++}else for(let e=0;e<r.length&&r[e]<s;e++)n[r[e]]=o,o++;return n}(t,r,o.index);c[h].push({data:p,index:m})}))}));for(let e=0;e<r;e++)h.forEach((t=>{const{type:r}=t,n=c[r];for(let t=0;t<n.length;t++)e in n[t].index&&o.push(n[t].data[n[t].index[e]])}));return o}applyFunctions(e,t,r,n,i,s,o){const{data:a}=e,l=r===ks.UP||r===ks.LEFT;if(n===Ms.COPY){const n=i?.[Ms.COPY];return n?n(e,t,r,s,o):(l&&a.reverse(),$a(a,t))}if(n===Ms.SERIES){const n=i?.[Ms.SERIES];return n?n(e,t,r,s):(l&&a.reverse(),i?.[Ms.COPY]?i[Ms.COPY](e,t,r,s,o):$a(a,t))}return[]}}e.AddRowColumnPlugin=class{id="add-row-column";name="Add Row Column";runTime=[r.TABLE_EVENT_TYPE.MOUSEENTER_CELL,r.TABLE_EVENT_TYPE.MOUSELEAVE_CELL,r.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE];pluginOptions;table;hoverCell;hideAllTimeoutId_addColumn;hideAllTimeoutId_addRow;leftDotForAddColumn;rightDotForAddColumn;addIconForAddColumn;addLineForAddColumn;topDotForAddRow;bottomDotForAddRow;addIconForAddRow;addLineForAddRow;constructor(e={addColumnEnable:!0,addRowEnable:!0}){this.id=e.id??this.id,this.pluginOptions=e,this.pluginOptions.addColumnEnable=this.pluginOptions.addColumnEnable??!0,this.pluginOptions.addRowEnable=this.pluginOptions.addRowEnable??!0,this.pluginOptions.addColumnEnable&&(this.initAddColumnDomElement(),this.bindEventForAddColumn()),this.pluginOptions.addRowEnable&&(this.initAddRowDomElement(),this.bindEventForAddRow())}run(...e){const t=e[0],n=e[1],i=e[2];if(this.table=i,n===r.TABLE_EVENT_TYPE.MOUSEENTER_CELL){clearTimeout(this.hideAllTimeoutId_addColumn),clearTimeout(this.hideAllTimeoutId_addRow);const e=i.canvas.getBoundingClientRect(),r=i.getCellAtRelativePosition(t.event.clientX-e.left,t.event.clientY-e.top);this.hoverCell=r;const n=i.getCellRelativeRect(r.col,r.row);if(this.pluginOptions.addColumnEnable){const t=i.isSeriesNumber(r.col,0);this.showDotForAddColumn(e.top-6,n.left+e.left,n.right+e.left,!t)}if(this.pluginOptions.addRowEnable){const t=i.isHeader(r.col,r.row);this.showDotForAddRow(n.top+e.top,e.left-6,n.bottom+e.top,!t,!t)}}else n===r.TABLE_EVENT_TYPE.MOUSELEAVE_CELL||n===r.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE&&(this.pluginOptions.addColumnEnable&&this.delayHideAllForAddColumn(),this.pluginOptions.addRowEnable&&this.delayHideAllForAddRow())}initAddColumnDomElement(){this.leftDotForAddColumn=document.createElement("div"),this.leftDotForAddColumn.style.width="6px",this.leftDotForAddColumn.style.height="6px",this.leftDotForAddColumn.style.backgroundColor="#4A90E2",this.leftDotForAddColumn.style.position="absolute",this.leftDotForAddColumn.style.cursor="pointer",this.leftDotForAddColumn.style.zIndex="1000",this.leftDotForAddColumn.style.borderRadius="50%",this.leftDotForAddColumn.style.border="1px solid white",this.leftDotForAddColumn.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.leftDotForAddColumn),this.rightDotForAddColumn=document.createElement("div"),this.rightDotForAddColumn.style.width="6px",this.rightDotForAddColumn.style.height="6px",this.rightDotForAddColumn.style.backgroundColor="#4A90E2",this.rightDotForAddColumn.style.position="absolute",this.rightDotForAddColumn.style.cursor="pointer",this.rightDotForAddColumn.style.zIndex="1000",this.rightDotForAddColumn.style.borderRadius="50%",this.rightDotForAddColumn.style.border="1px solid white",this.rightDotForAddColumn.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.rightDotForAddColumn),this.addIconForAddColumn=document.createElement("div"),this.addIconForAddColumn.style.width="18px",this.addIconForAddColumn.style.height="18px",this.addIconForAddColumn.style.backgroundColor="#4A90E2",this.addIconForAddColumn.style.position="absolute",this.addIconForAddColumn.style.zIndex="1001",this.addIconForAddColumn.style.display="none",this.addIconForAddColumn.style.borderRadius="50%",this.addIconForAddColumn.style.boxShadow="0 2px 5px rgba(0,0,0,0.2)",this.addIconForAddColumn.style.justifyContent="center",this.addIconForAddColumn.style.alignItems="center",this.addIconForAddColumn.style.border="1px solid white",document.body.appendChild(this.addIconForAddColumn);const e=document.createElement("div");e.textContent="+",e.style.color="white",e.style.fontSize="18px",e.style.fontWeight="bold",e.style.lineHeight="15px",e.style.userSelect="none",e.style.cursor="pointer",e.style.verticalAlign="top",e.style.textAlign="center",this.addIconForAddColumn.appendChild(e),this.addLineForAddColumn=document.createElement("div"),this.addLineForAddColumn.style.width="2px",this.addLineForAddColumn.style.height="10px",this.addLineForAddColumn.style.backgroundColor="#4A90E2",this.addLineForAddColumn.style.position="absolute",this.addLineForAddColumn.style.zIndex="1001",this.addLineForAddColumn.style.display="none",document.body.appendChild(this.addLineForAddColumn)}bindEventForAddColumn(){this.leftDotForAddColumn.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addColumn),this.addIconForAddColumn.style.display="block";const e=this.leftDotForAddColumn.offsetWidth,t=this.leftDotForAddColumn.offsetHeight;this.showAddIconForAddColumn(this.leftDotForAddColumn.offsetLeft+e/2,this.leftDotForAddColumn.offsetTop+t/2,!0),this.showSplitLineForAddColumn(this.leftDotForAddColumn.offsetLeft+e/2-1,this.leftDotForAddColumn.offsetTop+t/2+2,this.table.getDrawRange().height)})),this.rightDotForAddColumn.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addColumn),this.addIconForAddColumn.style.display="block";const e=this.rightDotForAddColumn.offsetWidth,t=this.rightDotForAddColumn.offsetHeight;this.showAddIconForAddColumn(this.rightDotForAddColumn.offsetLeft+e/2,this.rightDotForAddColumn.offsetTop+t/2,!1),this.showSplitLineForAddColumn(this.rightDotForAddColumn.offsetLeft+e/2-1,this.rightDotForAddColumn.offsetTop+t/2+2,this.table.getDrawRange().height)})),this.addIconForAddColumn.addEventListener("mouseleave",(()=>{this.addIconForAddColumn.style.display="none",this.addLineForAddColumn.style.display="none",this.delayHideAllForAddColumn()})),this.addIconForAddColumn.addEventListener("click",(e=>{const t="left"===this.addIconForAddColumn.dataset.addIconType;this.table.options.columns;const r=this.hoverCell.col,n=t?r:r+1;this.pluginOptions.addColumnCallback?this.pluginOptions.addColumnCallback(n,this.table):this.table.addColumns([{field:n,title:`New Column ${r}`,width:100}],n,!0),this.delayHideAllForAddColumn(0)}))}showDotForAddColumn(e,t,r,n=!0,i=!0){const s=this.leftDotForAddColumn.offsetWidth,o=this.leftDotForAddColumn.offsetHeight;this.leftDotForAddColumn.style.left=t-s/2+"px",this.leftDotForAddColumn.style.top=e-o/2+"px",this.rightDotForAddColumn.style.left=r-s/2+"px",this.rightDotForAddColumn.style.top=e-o/2+"px",this.leftDotForAddColumn.style.display=n?"block":"none",this.rightDotForAddColumn.style.display=i?"block":"none"}showAddIconForAddColumn(e,t,r){const n=this.addIconForAddColumn.offsetWidth,i=this.addIconForAddColumn.offsetHeight,s=this.leftDotForAddColumn.offsetHeight;this.addIconForAddColumn.style.left=e-n/2+"px",this.addIconForAddColumn.style.top=t-i/2-s/2+"px",this.addIconForAddColumn.dataset.addIconType=r?"left":"right"}showSplitLineForAddColumn(e,t,r){this.addLineForAddColumn.style.left=`${e}px`,this.addLineForAddColumn.style.top=`${t}px`,this.addLineForAddColumn.style.height=`${r}px`,this.addLineForAddColumn.style.display="block"}delayHideAllForAddColumn(e=1e3){this.hideAllTimeoutId_addColumn=setTimeout((()=>{this.addIconForAddColumn.style.display="none",this.addLineForAddColumn.style.display="none",this.leftDotForAddColumn.style.display="none",this.rightDotForAddColumn.style.display="none"}),e)}initAddRowDomElement(){this.topDotForAddRow=document.createElement("div"),this.topDotForAddRow.style.width="6px",this.topDotForAddRow.style.height="6px",this.topDotForAddRow.style.backgroundColor="#4A90E2",this.topDotForAddRow.style.position="absolute",this.topDotForAddRow.style.cursor="pointer",this.topDotForAddRow.style.zIndex="1000",this.topDotForAddRow.style.borderRadius="50%",this.topDotForAddRow.style.border="1px solid white",this.topDotForAddRow.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.topDotForAddRow),this.bottomDotForAddRow=document.createElement("div"),this.bottomDotForAddRow.style.width="6px",this.bottomDotForAddRow.style.height="6px",this.bottomDotForAddRow.style.backgroundColor="#4A90E2",this.bottomDotForAddRow.style.position="absolute",this.bottomDotForAddRow.style.cursor="pointer",this.bottomDotForAddRow.style.zIndex="1000",this.bottomDotForAddRow.style.borderRadius="50%",this.bottomDotForAddRow.style.border="1px solid white",this.bottomDotForAddRow.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.bottomDotForAddRow),this.addIconForAddRow=document.createElement("div"),this.addIconForAddRow.style.width="18px",this.addIconForAddRow.style.height="18px",this.addIconForAddRow.style.backgroundColor="#4A90E2",this.addIconForAddRow.style.position="absolute",this.addIconForAddRow.style.zIndex="1001",this.addIconForAddRow.style.display="none",this.addIconForAddRow.style.borderRadius="50%",this.addIconForAddRow.style.boxShadow="0 2px 5px rgba(0,0,0,0.2)",this.addIconForAddRow.style.justifyContent="center",this.addIconForAddRow.style.alignItems="center",this.addIconForAddRow.style.border="1px solid white",document.body.appendChild(this.addIconForAddRow);const e=document.createElement("div");e.textContent="+",e.style.color="white",e.style.fontSize="18px",e.style.fontWeight="bold",e.style.lineHeight="15px",e.style.userSelect="none",e.style.cursor="pointer",e.style.verticalAlign="top",e.style.textAlign="center",this.addIconForAddRow.appendChild(e),this.addLineForAddRow=document.createElement("div"),this.addLineForAddRow.style.width="10px",this.addLineForAddRow.style.height="2px",this.addLineForAddRow.style.backgroundColor="#4A90E2",this.addLineForAddRow.style.position="absolute",this.addLineForAddRow.style.zIndex="1001",this.addLineForAddRow.style.display="none",document.body.appendChild(this.addLineForAddRow)}bindEventForAddRow(){this.topDotForAddRow.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addRow),this.addIconForAddRow.style.display="block";const e=this.topDotForAddRow.offsetWidth,t=this.topDotForAddRow.offsetHeight;this.showAddIconForAddRow(this.topDotForAddRow.offsetLeft+e/2,this.topDotForAddRow.offsetTop+t/2,!0),this.showSplitLineForAddRow(this.topDotForAddRow.offsetLeft+e+2,this.topDotForAddRow.offsetTop+t/2-1,this.table.getDrawRange().width)})),this.bottomDotForAddRow.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addRow),this.addIconForAddRow.style.display="block";const e=this.bottomDotForAddRow.offsetWidth,t=this.bottomDotForAddRow.offsetHeight;this.showAddIconForAddRow(this.bottomDotForAddRow.offsetLeft+e/2,this.bottomDotForAddRow.offsetTop+t/2,!1),this.showSplitLineForAddRow(this.bottomDotForAddRow.offsetLeft+e+2,this.bottomDotForAddRow.offsetTop+t/2-1,this.table.getDrawRange().height)})),this.addIconForAddRow.addEventListener("mouseleave",(()=>{this.addIconForAddRow.style.display="none",this.addLineForAddRow.style.display="none",this.delayHideAllForAddRow()})),this.addIconForAddRow.addEventListener("click",(e=>{const t="top"===this.addIconForAddRow.dataset.addIconType,r=this.hoverCell.row,n=t?r:r+1;if(this.pluginOptions.addRowCallback)this.pluginOptions.addRowCallback(n,this.table);else{const e=this.table.getRecordIndexByCell(0,n);this.table.addRecord({},e)}this.delayHideAllForAddRow(0)}))}showDotForAddRow(e,t,r,n=!0,i=!0){const s=this.topDotForAddRow.offsetWidth,o=this.topDotForAddRow.offsetHeight;this.topDotForAddRow.style.left=t-s/2+"px",this.topDotForAddRow.style.top=e-o/2+"px",this.bottomDotForAddRow.style.left=t-s/2+"px",this.bottomDotForAddRow.style.top=r-o/2+"px",this.topDotForAddRow.style.display=n?"block":"none",this.bottomDotForAddRow.style.display=i?"block":"none"}showAddIconForAddRow(e,t,r){const n=this.addIconForAddRow.offsetWidth,i=this.addIconForAddRow.offsetHeight,s=this.topDotForAddRow.offsetWidth;this.addIconForAddRow.style.left=e-n/2-s/2+"px",this.addIconForAddRow.style.top=t-i/2+"px",this.addIconForAddRow.dataset.addIconType=r?"top":"bottom"}showSplitLineForAddRow(e,t,r){this.addLineForAddRow.style.left=`${e}px`,this.addLineForAddRow.style.top=`${t}px`,this.addLineForAddRow.style.width=`${r}px`,this.addLineForAddRow.style.display="block"}delayHideAllForAddRow(e=1e3){this.hideAllTimeoutId_addRow=setTimeout((()=>{this.addIconForAddRow.style.display="none",this.addLineForAddRow.style.display="none",this.topDotForAddRow.style.display="none",this.bottomDotForAddRow.style.display="none"}),e)}release(){this.leftDotForAddColumn.remove(),this.rightDotForAddColumn.remove(),this.addIconForAddColumn.remove(),this.addLineForAddColumn.remove(),this.topDotForAddRow.remove(),this.bottomDotForAddRow.remove(),this.addIconForAddRow.remove(),this.addLineForAddRow.remove()}},e.AutoFillPlugin=class{id="auto-fill";name="Auto Fill";runTime=[r.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE,r.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END,r.TABLE_EVENT_TYPE.DBLCLICK_FILL_HANDLE];table;autoFillManager;constructor(e){this.autoFillManager=new vl(e)}run(...e){if(e[1]===r.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE){const[t,r,n]=e;this.table=n,this.autoFillManager.setTable(this.table),this.autoFillManager.handleStartDrag(this.table?.getSelectedCellRanges()[0])}else if(e[1]===r.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END){const[{direction:t}]=e;this.autoFillManager.handleEndDrag(this.table?.getSelectedCellRanges()[0],t)}else e[1]===r.TABLE_EVENT_TYPE.DBLCLICK_FILL_HANDLE&&this.autoFillManager.handleDbClick()}},e.CarouselAnimationPlugin=class{table;rowCount;colCount;animationDuration;animationDelay;animationEasing;replaceScrollAction;playing;row;col;willUpdateRow=!1;willUpdateCol=!1;customDistRowFunction;customDistColFunction;constructor(e,t){this.table=e,this.rowCount=t?.rowCount??void 0,this.colCount=t?.colCount??void 0,this.animationDuration=t?.animationDuration??500,this.animationDelay=t?.animationDelay??1e3,this.animationEasing=t?.animationEasing??"linear",this.replaceScrollAction=t?.replaceScrollAction??!1,this.customDistColFunction=t.customDistColFunction,this.customDistRowFunction=t.customDistRowFunction,this.reset(),this.init()}init(){this.replaceScrollAction&&(this.table.disableScroll(),this.table.scenegraph.stage.addEventListener("wheel",this.onScrollEnd.bind(this)))}reset(){this.playing=!1,this.row=this.table.frozenRowCount,this.col=this.table.frozenColCount}onScrollEnd(e){this.rowCount?(e.deltaY>0?(this.row+=this.rowCount,this.row=Math.min(this.row,this.table.rowCount-this.table.frozenRowCount)):e.deltaY<0&&(this.row-=this.rowCount,this.row=Math.max(this.row,this.table.frozenRowCount)),this.table.scrollToRow(this.row,{duration:this.animationDuration,easing:this.animationEasing})):this.colCount&&(e.deltaX>0?(this.col+=this.colCount,this.col=Math.min(this.col,this.table.colCount-this.table.frozenColCount)):e.deltaX<0&&(this.col-=this.colCount,this.col=Math.max(this.col,this.table.frozenColCount)),this.table.scrollToCol(this.col,{duration:this.animationDuration,easing:this.animationEasing}))}play(){this.playing=!0,this.rowCount&&!this.willUpdateRow?this.updateRow():this.colCount&&!this.willUpdateCol&&this.updateCol()}pause(){this.playing=!1}updateRow(){if(!this.playing||this.table.isReleased)return;let e=!0;const t=this.customDistRowFunction&&this.customDistRowFunction(this.row,this.table);t?(this.row=t.distRow,e=t.animation??!0):s(this.row)&&this.table.scenegraph.proxy.screenTopRow!==this.row?(this.row=this.table.frozenRowCount,e=!1):s(this.row)||this.table.scenegraph.proxy.screenTopRow===Math.floor(this.row)?this.row+=this.rowCount:(this.row=this.table.frozenRowCount,e=!1),this.table.scrollToRow(this.row,e?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateRow=!0,setTimeout((()=>{this.willUpdateRow=!1,this.updateRow()}),this.animationDuration+this.animationDelay)}updateCol(){if(!this.playing||this.table.isReleased)return;let e=!0;const t=this.customDistColFunction&&this.customDistColFunction(this.col,this.table);t?(this.col=t.distCol,e=t.animation??!0):s(this.col)&&this.table.scenegraph.proxy.screenLeftCol!==this.col?(this.col=this.table.frozenColCount,e=!1):s(this.col)||this.table.scenegraph.proxy.screenLeftCol===Math.floor(this.col)?this.col+=this.colCount:(this.col=this.table.frozenColCount,e=!1),this.table.scrollToCol(this.col,e?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateCol=!0,setTimeout((()=>{this.willUpdateCol=!1,this.updateCol()}),this.animationDuration+this.animationDelay)}},e.ColumnSeriesPlugin=class{id="column-series";name="Column Series";runTime=[r.TABLE_EVENT_TYPE.BEFORE_INIT,r.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];pluginOptions;table;columns=[];constructor(e){this.id=e.id??this.id,this.pluginOptions=Object.assign({columnCount:100},e)}run(...e){if(e[1]===r.TABLE_EVENT_TYPE.BEFORE_INIT){const t=e[0],r=e[2];this.table=r;const n=t.options;this.columns=this.generateColumns(this.pluginOptions.columnCount),n.columns=this.columns}else if(e[1]===r.TABLE_EVENT_TYPE.BEFORE_KEYDOWN){const t=e[0].event;this.pluginOptions.autoExtendColumnTriggerKeys?.includes(t.key)&&this.table.stateManager.select.cellPos.col===this.table.colCount-1&&this.table.addColumns([this.generateColumn(this.table.colCount-1)])}}generateColumns(e){const t=[];for(let r=0;r<e;r++)t.push(this.generateColumn(r));return t}generateColumn(e){return{title:this.pluginOptions.generateColumnTitle?this.pluginOptions.generateColumnTitle(e):this.generateColumnField(e)}}generateColumnField(e){if(e<26)return String.fromCharCode(65+e);const t=[];for(e++;e>0;)e--,t.unshift(String.fromCharCode(65+e%26)),e=Math.floor(e/26);return t.join("")}resetColumnCount(e){this.pluginOptions.columnCount=e,this.columns=this.generateColumns(e),this.table.updateColumns(this.columns)}},e.ConditionFilter=ns,e.ContextMenuPlugin=class{id="context-menu";name="Context Menu";runTime=[r.TABLE_EVENT_TYPE.CONTEXTMENU_CELL,r.TABLE_EVENT_TYPE.PLUGIN_EVENT];pluginOptions;table;menuManager;menuHandler;constructor(e={}){this.id=e.id??this.id,this.pluginOptions=e,this.menuManager=new F,this.menuHandler=new Ii,this.initDefaultMenuItems()}initDefaultMenuItems(){this.pluginOptions.columnSeriesNumberMenuItems||(this.pluginOptions.columnSeriesNumberMenuItems=B),this.pluginOptions.rowSeriesNumberMenuItems||(this.pluginOptions.rowSeriesNumberMenuItems=H),this.pluginOptions.cornerSeriesNumberMenuItems||(this.pluginOptions.cornerSeriesNumberMenuItems=z),this.pluginOptions.headerCellMenuItems||(this.pluginOptions.headerCellMenuItems=D),this.pluginOptions.bodyCellMenuItems||(this.pluginOptions.bodyCellMenuItems=L)}handleContextMenuCell=(e,t)=>{const{col:r,row:n}=e,i=e.event.clientX,s=e.event.clientY,o=t.isSeriesNumber(r,n);let a=[];if(a=t.isHeader(r,n)?o?this.pluginOptions.columnSeriesNumberMenuItems||[]:this.pluginOptions.headerCellMenuItems||[]:o?this.pluginOptions.rowSeriesNumberMenuItems||[]:this.pluginOptions.bodyCellMenuItems||[],a.length>0){const e=t.getCellRange(r,n);a=e.start.col!==e.end.col||e.start.row!==e.end.row?a.filter((e=>"string"==typeof e||"merge_cells"!==e.menuKey)):a.filter((e=>"string"==typeof e||"unmerge_cells"!==e.menuKey)),this.pluginOptions.beforeShowAdjustMenuItems&&(a=this.pluginOptions.beforeShowAdjustMenuItems(a,t,r,n)),this.showContextMenu(a,i,s,r,n)}};handlePluginEvent=(e,t)=>{const{eventType:r,rowIndex:n,colIndex:i,isCorner:s}=e.pluginEventInfo,o=e.plugin,a=e.event.clientX,l=e.event.clientY;if("table-series-number"===o.id&&"rightclick"===r){let e=[];s?e=this.pluginOptions.cornerSeriesNumberMenuItems||[]:void 0!==n?e=this.pluginOptions.rowSeriesNumberMenuItems||[]:void 0!==i&&(e=this.pluginOptions.columnSeriesNumberMenuItems||[]),this.pluginOptions.beforeShowAdjustMenuItems&&(e=this.pluginOptions.beforeShowAdjustMenuItems(e,t,i,n)),this.showContextMenu(e,a,l,i,n)}};run(...e){const t=e[0],n=e[1],i=e[2];this.table=i,t.event.preventDefault(),n===r.TABLE_EVENT_TYPE.CONTEXTMENU_CELL?this.handleContextMenuCell(t,i):n===r.TABLE_EVENT_TYPE.PLUGIN_EVENT&&this.handlePluginEvent(t,i)}handleMenuClickCallback=(e,t)=>{"function"==typeof this.pluginOptions.menuClickCallback?this.pluginOptions.menuClickCallback(e,t):this.handleMenuClick(e,t)};showContextMenu(e,t,r,n,i){this.menuManager.showMenu(e,t,r,{rowIndex:i,colIndex:n},this.table),this.menuManager.setClickCallback(this.handleMenuClickCallback)}handleMenuClick(t,r){const{menuKey:n,rowIndex:i,colIndex:s,inputValue:o=1}=t;if("object"==typeof this.pluginOptions.menuClickCallback&&this.pluginOptions.menuClickCallback[n])this.pluginOptions.menuClickCallback[n](t,r);else switch(n){case e.MenuKey.COPY:this.menuHandler.handleCopy(r);break;case e.MenuKey.CUT:this.menuHandler.handleCut(r);break;case e.MenuKey.PASTE:this.menuHandler.handlePaste(r);break;case e.MenuKey.INSERT_ROW_ABOVE:this.menuHandler.handleInsertRowAbove(r,i,o);break;case e.MenuKey.INSERT_ROW_BELOW:this.menuHandler.handleInsertRowBelow(r,i,o);break;case e.MenuKey.INSERT_COLUMN_LEFT:this.menuHandler.handleInsertColumnLeft(r,s,o);break;case e.MenuKey.INSERT_COLUMN_RIGHT:this.menuHandler.handleInsertColumnRight(r,s,o);break;case e.MenuKey.DELETE_ROW:this.menuHandler.handleDeleteRow(r);break;case e.MenuKey.DELETE_COLUMN:this.menuHandler.handleDeleteColumn(r,s);break;case e.MenuKey.HIDE_COLUMN:this.menuHandler.handleHideColumn(r,s);break;case e.MenuKey.SORT:this.menuHandler.handleSort(r,s);break;case e.MenuKey.MERGE_CELLS:this.menuHandler.handleMergeCells(r);break;case e.MenuKey.UNMERGE_CELLS:this.menuHandler.handleUnmergeCells(r);break;case e.MenuKey.FREEZE_TO_THIS_ROW:this.menuHandler.handleFreezeToRow(r,i);break;case e.MenuKey.FREEZE_TO_THIS_COLUMN:this.menuHandler.handleFreezeToColumn(r,s);break;case e.MenuKey.FREEZE_TO_THIS_ROW_AND_COLUMN:this.menuHandler.handleFreezeToRowAndColumn(r,i,s);break;case e.MenuKey.UNFREEZE:this.menuHandler.handleUnfreeze(r)}}release(){this.menuManager&&(this.menuManager.release(),this.menuManager=null),this.menuHandler&&(this.menuHandler.release(),this.menuHandler=null)}},e.DEFAULT_BODY_MENU_ITEMS=L,e.DEFAULT_COLUMN_SERIES_MENU_ITEMS=B,e.DEFAULT_CORNER_SERIES_MENU_ITEMS=z,e.DEFAULT_HEADER_MENU_ITEMS=D,e.DEFAULT_ROW_SERIES_MENU_ITEMS=H,e.ExcelEditCellKeyboardPlugin=class{id="excel-edit-cell-keyboard";name="Excel Edit Cell Keyboard";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED];table;pluginOptions;responseKeyboard;constructor(t){this.id=t?.id??this.id,this.pluginOptions=t,this.responseKeyboard=t?.responseKeyboard??[e.ExcelEditCellKeyboardResponse.ENTER,e.ExcelEditCellKeyboardResponse.TAB,e.ExcelEditCellKeyboardResponse.ARROW_LEFT,e.ExcelEditCellKeyboardResponse.ARROW_RIGHT,e.ExcelEditCellKeyboardResponse.ARROW_DOWN,e.ExcelEditCellKeyboardResponse.ARROW_UP,e.ExcelEditCellKeyboardResponse.DELETE,e.ExcelEditCellKeyboardResponse.BACKSPACE],this.bindEvent()}run(...e){const t=e[2];this.table=t}bindEvent(){document.addEventListener("keydown",this.handleKeyDown.bind(this),!0)}handleKeyDown(t){if(this.table.editorManager&&this.isExcelShortcutKey(t)){const r=t.key.toLowerCase();if(this.table.editorManager.editingEditor&&"keydown"===this.table.editorManager.beginTriggerEditCellMode){const{col:n,row:i}=this.table.editorManager.editCell;this.table.editorManager.completeEdit(),this.table.getElement().focus(),t.shiftKey||t.ctrlKey||t.metaKey||(r===e.ExcelEditCellKeyboardResponse.ENTER?this.table.selectCell(n,i+1):r===e.ExcelEditCellKeyboardResponse.TAB?this.table.selectCell(n+1,i):r===e.ExcelEditCellKeyboardResponse.ARROW_LEFT?this.table.selectCell(n-1,i):r===e.ExcelEditCellKeyboardResponse.ARROW_RIGHT?this.table.selectCell(n+1,i):r===e.ExcelEditCellKeyboardResponse.ARROW_DOWN?this.table.selectCell(n,i+1):r===e.ExcelEditCellKeyboardResponse.ARROW_UP&&this.table.selectCell(n,i-1),t.stopPropagation(),t.preventDefault())}else{const{col:n,row:i}=this.table.stateManager.select.cellPos;if(!this.table.editorManager.editingEditor||r!==e.ExcelEditCellKeyboardResponse.ENTER&&r!==e.ExcelEditCellKeyboardResponse.TAB){if(!this.table.editorManager.editingEditor&&(r===e.ExcelEditCellKeyboardResponse.DELETE||r===e.ExcelEditCellKeyboardResponse.BACKSPACE)){const e=this.table.getSelectedCellInfos();e?.length>0&&document.activeElement===this.table.getElement()&&(!function(e,t){for(let r=0;r<e.length;r++)for(let n=0;n<e[r].length;n++)t.changeCellValue(e[r][n].col,e[r][n].row,"")}(e,this.table),t.stopPropagation(),t.preventDefault())}}else this.table.editorManager.completeEdit(),this.table.getElement().focus(),r===e.ExcelEditCellKeyboardResponse.ENTER?this.table.selectCell(n,i+1):r===e.ExcelEditCellKeyboardResponse.TAB&&this.table.selectCell(n+1,i),t.stopPropagation(),t.preventDefault()}}}isExcelShortcutKey(e){return this.responseKeyboard.includes(e.key.toLowerCase())}setResponseKeyboard(e){this.responseKeyboard=e}deleteResponseKeyboard(e){this.responseKeyboard=this.responseKeyboard.filter((t=>!e.includes(t)))}addResponseKeyboard(e){this.responseKeyboard=[...this.responseKeyboard,...e]}release(){document.removeEventListener("keydown",this.handleKeyDown,!0)}},e.ExcelImportPlugin=Oi,e.ExportGanttPlugin=class{id="gantt-export-helper";name="Gantt Export Helper";_gantt=null;run(...e){const t=e[0];t&&(this._gantt=t)}async exportToImage(e={}){if(!this._gantt)return;const{fileName:r="gantt-export",type:n="png",quality:i=1,backgroundColor:s="#ffffff",scale:o=window.devicePixelRatio||1,download:a=!0}=e;try{const{tempContainer:e,clonedGantt:l}=await this.createFullSizeContainer(o);try{await new Promise((e=>t.vglobal.getRequestAnimationFrame()(e)));const e=(l.taskListTableInstance.getAllColsWidth()+l.getAllDateColsWidth())*o,h=l.getAllRowsHeight()*o,c=document.createElement("canvas");c.width=e,c.height=h;const u=c.getContext("2d");u.fillStyle=s,u.fillRect(0,0,e,h),l.taskListTableInstance?.canvas&&u.drawImage(l.taskListTableInstance.canvas,0,0,l.taskListTableInstance.getAllColsWidth()*o,h);const d=3*o,f=l.taskListTableInstance.getAllColsWidth()*o;u.fillStyle="rgb(225, 228, 232)",u.fillRect(f-d/2,0,d,h);const p=4*o,m=l.canvas.width-p;return l.canvas&&u.drawImage(l.canvas,p,0,m,l.canvas.height,(l.taskListTableInstance.getAllColsWidth()+1.5)*o,0,(l.getAllDateColsWidth()-1.5)*o,h),this.finalizeExport(c,r,n,i,a)}finally{e.remove(),l.release()}}catch(e){throw new Error(`甘特图导出失败: ${e instanceof Error?e.message:"未知错误"}`)}}async exportToBase64(e={}){return this.exportToImage({...e,download:!1})}async createFullSizeContainer(e){if(!this._gantt)throw new Error("ExportGanttPlugin: Gantt instance not available to create container.");const t=document.createElement("div");t.style.position="fixed",t.style.left="-9999px",t.style.overflow="hidden",t.style.width=`${window.innerWidth+100}px`,t.style.height=`${window.innerHeight+100}px`,document.body.appendChild(t);const r=document.createElement("div"),n=this._gantt.taskListTableInstance.getAllColsWidth()+this._gantt.getAllDateColsWidth(),i=this._gantt.getAllRowsHeight();r.style.width=`${n}px`,r.style.height=`${i}px`,t.appendChild(r);try{let n;try{if(n=(await import("@visactor/vtable-gantt")).Gantt,!n)throw new Error("Gantt class not found in @visactor/vtable-gantt")}catch(e){throw new Error("导出甘特图需要安装并正确加载 @visactor/vtable-gantt 依赖\n请执行: npm install @visactor/vtable-gantt")}const i=new n(r,{...this._gantt.options,records:this._gantt.records,taskListTable:{...this._gantt.options.taskListTable,tableWidth:void 0,minTableWidth:void 0,maxTableWidth:void 0},plugins:[]});return i.setPixelRatio(e),i.scenegraph?.ganttGroup&&i.scenegraph.ganttGroup.setAttribute("clip",!1),i.taskListTableInstance?.scenegraph?.tableGroup&&i.taskListTableInstance.scenegraph.tableGroup.setAttribute("clip",!1),i.scenegraph.stage.render(),{tempContainer:t,clonedGantt:i}}catch(e){throw t&&t.parentNode&&t.remove(),new Error("导出甘特图需要安装 @visactor/vtable-gantt 依赖")}}finalizeExport(e,t,r,n,i=!0){const s=e.toDataURL(`image/${r}`,n);if(i){const e=document.createElement("a");e.download=`${t}.${r}`,e.href=s,document.body.appendChild(e),e.click(),document.body.removeChild(e)}return s}release(){this._gantt=null}},e.FilterEngine=Ni,e.FilterPlugin=class{id="filter";name="Filter";runTime=[r.TABLE_EVENT_TYPE.BEFORE_INIT,r.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION,r.TABLE_EVENT_TYPE.ICON_CLICK,r.TABLE_EVENT_TYPE.SCROLL];pluginOptions;table;columns;filterEngine;filterStateManager;filterToolbar;constructor(e){this.id=e?.id??this.id,this.pluginOptions=e,this.pluginOptions.filterIcon=e.filterIcon??{name:"filter-icon",type:"svg",width:12,height:12,positionType:r.TYPES.IconPosition.right,cursor:"pointer",svg:'<svg t="1752821809070" class="icon" viewBox="0 0 1664 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="12092" width="200" height="200"><path d="M89.6 179.2A89.6 89.6 0 0 1 89.6 0h1408a89.6 89.6 0 0 1 0 179.2H89.6z m256 384a89.6 89.6 0 0 1 0-179.2h896a89.6 89.6 0 0 1 0 179.2h-896z m256 384a89.6 89.6 0 0 1 0-179.2h384a89.6 89.6 0 0 1 0 179.2h-384z" fill="#93a2b9" p-id="12093"></path></svg>'},this.pluginOptions.filteringIcon=e.filteringIcon??{name:"filtering-icon",type:"svg",width:12,height:12,positionType:r.TYPES.IconPosition.right,cursor:"pointer",svg:'<svg t="1752821771292" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="11926" width="200" height="200"><path d="M971.614323 53.05548L655.77935 412.054233C635.196622 435.434613 623.906096 465.509377 623.906096 496.583302v495.384307c0 28.975686-35.570152 43.063864-55.353551 21.781723l-159.865852-171.256294c-5.495389-5.895053-8.59279-13.688514-8.592789-21.781722V496.583302c0-31.073925-11.290526-61.148688-31.873254-84.429153L52.385677 53.05548C34.200936 32.472751 48.888611 0 76.365554 0h871.268892c27.476943 0 42.164618 32.472751 23.979877 53.05548z" fill="#416eff" p-id="11927"></path></svg>'},this.pluginOptions.filterModes&&this.pluginOptions.filterModes.length||(this.pluginOptions.filterModes=["byValue","byCondition"])}run(...t){const n=t[0],i=t[1],s=t[2];if(this.table=s,i===r.TABLE_EVENT_TYPE.BEFORE_INIT)this.filterEngine=new Ni,this.filterStateManager=new Fi(this.table,this.filterEngine),this.filterToolbar=new is(this.table,this.filterStateManager),this.columns=n.options.columns,this.filterToolbar.render(document.body),this.updateFilterIcons(this.columns),this.filterStateManager.subscribe(((t,r)=>{r?.type!==e.FilterActionType.ADD_FILTER&&(this.updateFilterIcons(this.columns),this.table.updateColumns(this.columns,{clearRowHeightCache:!1}))}));else if(i===r.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION)this.pluginOptions={...this.pluginOptions,...n.options.plugins.find((e=>e.id===this.id)).pluginOptions},this.columns=n.options.columns,this.handleOptionUpdate(n.options);else if(i===r.TABLE_EVENT_TYPE.ICON_CLICK&&"filter-icon"===n.name||"filtering-icon"===n.name){if(3===n.event?.which||2===n.event?.button||2==(2&n.event?.buttons))return;const e=n.col,t=n.row;this.filterToolbar.isVisible?this.filterToolbar.hide():this.filterToolbar.show(e,t,this.pluginOptions.filterModes)}else i===r.TABLE_EVENT_TYPE.SCROLL&&"horizontal"===n.scrollDirection&&this.filterToolbar.adjustMenuPosition()}update(){this.filterStateManager&&this.reapplyActiveFilters()}handleOptionUpdate(e){const t=this.filterStateManager?this.filterStateManager.getActiveFilterFields():[];this.filterStateManager&&t.length>0&&this.validateFilterStatesAfterUpdate(e,t),this.updateFilterIcons(e.columns)}reapplyActiveFilters(){this.filterStateManager.reapplyCurrentFilters()}validateFilterStatesAfterUpdate(t,r){const n=t.columns,i=[];r.forEach((e=>{const t=n.find((t=>t.field===e));t&&this.shouldEnableFilterForColumn(e,t)||i.push(e)})),i.forEach((t=>{this.filterStateManager.dispatch({type:e.FilterActionType.REMOVE_FILTER,payload:{field:t}})}))}updateFilterIcons(e=[]){const t=this.pluginOptions.filterIcon,r=this.pluginOptions.filteringIcon,n=(e,t)=>e===t||e&&t&&"object"==typeof e&&"object"==typeof t&&e.name===t.name;e.forEach((e=>{const i=this.shouldEnableFilterForColumn(e.field,e),s=!!this.filterStateManager.getFilterState(e.field)?.enable;let o=(e=>e?Array.isArray(e)?e:[e]:[])(e.headerIcon);var a;i?s?o.some((e=>n(e,r)))||(o=o.filter((e=>!n(e,t))),o.push(r)):o.some((e=>n(e,t)))||(o=o.filter((e=>!n(e,r))),o.push(t)):o=o.filter((e=>!n(e,t))),e.headerIcon=0===(a=o).length?void 0:1===a.length?a[0]:a}))}shouldEnableFilterForColumn(e,t){if(!t.title)return!1;const r=t;return void 0!==r.filter?!!r.filter:this.pluginOptions.enableFilter?this.pluginOptions.enableFilter(e,t):void 0===this.pluginOptions.defaultEnabled||this.pluginOptions.defaultEnabled}getFilterState(){if(!this.filterStateManager)return null;const e=this.filterStateManager.getAllFilterStates(),t={};return e.filters.forEach(((e,r)=>{t[r]={enable:e.enable,field:e.field,type:e.type,values:e.values,operator:e.operator,condition:e.condition}})),{filters:t}}setFilterState(t){this.filterStateManager&&(this.filterStateManager.dispatch({type:e.FilterActionType.CLEAR_ALL_FILTERS,payload:{}}),t&&t.filters&&Object.entries(t.filters).forEach((([,t])=>{t.enable&&this.filterStateManager.dispatch({type:e.FilterActionType.ADD_FILTER,payload:{field:t.field,type:t.type,values:t.values,operator:t.operator,condition:t.condition,enable:!0}})})))}release(){this.table=null,this.filterEngine=null,this.filterStateManager=null,this.filterToolbar=null}},e.FilterStateManager=Fi,e.FilterToolbar=is,e.FocusHighlightPlugin=class{id="focus-highlight";name="Focus Highlight";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED,r.TABLE_EVENT_TYPE.SELECTED_CELL,r.TABLE_EVENT_TYPE.SELECTED_CLEAR];table;range;pluginOptions;constructor(e={fill:"#000",opacity:.5,highlightRange:void 0}){this.id=e.id??this.id,this.pluginOptions=Object.assign({fill:"#000",opacity:.5},e)}run(...e){if(this.table||(this.table=e[2]),e[1]===r.TABLE_EVENT_TYPE.INITIALIZED)this.pluginOptions.highlightRange&&this.setFocusHighlightRange(this.pluginOptions.highlightRange);else if(e[1]===r.TABLE_EVENT_TYPE.SELECTED_CELL){const e=this.table.stateManager.select.cellPos;if(this.table.isHeader(e.col,e.row))this.setFocusHighlightRange(void 0);else{const e=this.table.stateManager.select.ranges,t=0,r=this.table.colCount-1,n=Math.min(e[0].start.row,e[0].end.row),i=Math.max(e[0].start.row,e[0].end.row);this.setFocusHighlightRange({start:{col:t,row:n},end:{col:r,row:i}})}}else e[1]===r.TABLE_EVENT_TYPE.SELECTED_CLEAR&&this.setFocusHighlightRange(void 0)}setFocusHighlightRange(e,t=!1){let r;e&&"start"in e&&"end"in e?r=e:e&&(r={start:e,end:e}),o(this.range,r)&&!t||(this.range=r,e?this.updateCellGroupShadow():this.deleteAllCellGroupShadow(),this.table.scenegraph.updateNextFrame())}deleteAllCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup)}updateCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup,this.range)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.range,this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup,this.range)}updateCellGroupShadowInContainer(e,r){let n;r&&"start"in r&&"end"in r?n=r:r&&(n={start:r,end:r}),e.forEachChildrenSkipChild((e=>{const r=e;"column"===r.role&&r.forEachChildrenSkipChild((e=>{const r=e;if("cell"!==r.role)return;r.attachShadow(r.shadowRoot);const i=r.shadowRoot;if(n){if(_(n,r.col,r.row))i.removeAllChild();else if(!i.firstChild){const e=t.createRect({x:0,y:0,width:r.attribute.width,height:r.attribute.height,fill:this.pluginOptions.fill,opacity:this.pluginOptions.opacity});e.name="shadow-rect",i.appendChild(e)}}else i.removeAllChild()}))}))}update(){this.setFocusHighlightRange(this.range,!0)}},e.HeaderHighlightPlugin=class{table;options;colHeaderRange;rowHeaderRange;constructor(e,t){this.table=e,this.options=t,this.registerStyle(),this.bindEvent()}registerStyle(){this.table.registerCustomCellStyle("col-highlight",{bgColor:this.options?.colHighlightBGColor??"#82b2f5",color:this.options?.colHighlightColor??"#FFF"}),this.table.registerCustomCellStyle("row-highlight",{bgColor:this.options?.rowHighlightBGColor??"#82b2f5",color:this.options?.rowHighlightColor??"#FFF"})}bindEvent(){this.table.on("selected_cell",(()=>{this.updateHighlight()})),this.table.on("selected_clear",(()=>{this.clearHighlight()})),this.table.on("mousemove_table",(()=>{this.table.stateManager.select.selecting&&this.updateHighlight()}))}clearHighlight(){this.colHeaderRange&&this.table.arrangeCustomCellStyle({range:this.colHeaderRange},void 0),this.rowHeaderRange&&this.table.arrangeCustomCellStyle({range:this.rowHeaderRange},void 0),this.colHeaderRange=void 0,this.rowHeaderRange=void 0}updateHighlight(){if(!1===this.options?.colHighlight&&!1===this.options?.rowHighlight)return;const e=this.table.getSelectedCellRanges();if(0===e.length)return void this.clearHighlight();const t=e[0],r=[t.start.row,t.end.row];r.sort(((e,t)=>e-t));const n=[t.start.col,t.end.col];let i,s;n.sort(((e,t)=>e-t)),this.table.isPivotTable()?(i={start:{col:n[0],row:0},end:{col:n[1],row:this.table.columnHeaderLevelCount-1}},s={start:{col:0,row:r[0]},end:{col:this.table.rowHeaderLevelCount-1,row:r[1]}}):this.table.internalProps.transpose?s={start:{col:0,row:r[0]},end:{col:this.table.rowHeaderLevelCount-1,row:r[1]}}:(i={start:{col:n[0],row:0},end:{col:n[1],row:this.table.columnHeaderLevelCount-1}},this.table.internalProps.rowSeriesNumber&&(s={start:{col:0,row:r[0]},end:{col:0,row:r[1]}})),!1===this.options?.colHighlight||x(this.colHeaderRange,i)||(this.colHeaderRange&&this.table.arrangeCustomCellStyle({range:this.colHeaderRange},void 0),i&&this.table.arrangeCustomCellStyle({range:i},"col-highlight"),this.colHeaderRange=i),!1===this.options?.rowHighlight||x(this.rowHeaderRange,s)||(this.rowHeaderRange&&this.table.arrangeCustomCellStyle({range:this.rowHeaderRange},void 0),s&&this.table.arrangeCustomCellStyle({range:s},"row-highlight"),this.rowHeaderRange=s)}},e.HighlightHeaderWhenSelectCellPlugin=class{id="highlight-header-when-select-cell";name="Highlight Header When Select Cell";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED,r.TABLE_EVENT_TYPE.SELECTED_CLEAR,r.TABLE_EVENT_TYPE.SELECTED_CELL,r.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE];table;pluginOptions;colHeaderRanges=[];rowHeaderRanges=[];constructor(e){this.id=e?.id??this.id,this.pluginOptions=e}run(...e){const t=e[1],n=e[2];this.table=n,t===r.TABLE_EVENT_TYPE.SELECTED_CLEAR?this.clearHighlight():t===r.TABLE_EVENT_TYPE.SELECTED_CELL||t===r.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE?this.updateHighlight():t===r.TABLE_EVENT_TYPE.INITIALIZED&&this.registerStyle()}registerStyle(){this.table.registerCustomCellStyle("col-highlight",{bgColor:this.pluginOptions?.colHighlightBGColor??"#82b2f5",color:this.pluginOptions?.colHighlightColor??"#FFF"}),this.table.registerCustomCellStyle("row-highlight",{bgColor:this.pluginOptions?.rowHighlightBGColor??"#82b2f5",color:this.pluginOptions?.rowHighlightColor??"yellow"})}clearHighlight(){this.colHeaderRanges&&this.colHeaderRanges.forEach((e=>{this.table.arrangeCustomCellStyle({range:e},void 0)})),this.rowHeaderRanges&&this.rowHeaderRanges.forEach((e=>{this.table.arrangeCustomCellStyle({range:e},void 0)})),this.colHeaderRanges=[],this.rowHeaderRanges=[]}updateHighlight(){if(!1===this.pluginOptions?.colHighlight&&!1===this.pluginOptions?.rowHighlight)return;const e=this.table.getSelectedCellRanges();e.length<2&&this.clearHighlight();for(let t=0;t<e.length;t++){const r=e[t],n=[r.start.row,r.end.row];n.sort(((e,t)=>e-t));const i=[r.start.col,r.end.col];let s,o;i.sort(((e,t)=>e-t)),this.table.isPivotTable()?(s={start:{col:i[0],row:0},end:{col:i[1],row:this.table.columnHeaderLevelCount-1}},o={start:{col:0,row:n[0]},end:{col:this.table.rowHeaderLevelCount-1,row:n[1]}}):this.table.internalProps.transpose?o={start:{col:0,row:n[0]},end:{col:this.table.rowHeaderLevelCount-1,row:n[1]}}:(s={start:{col:i[0],row:0},end:{col:i[1],row:this.table.columnHeaderLevelCount-1}},this.table.internalProps.rowSeriesNumber&&(o={start:{col:0,row:n[0]},end:{col:0,row:n[1]}})),!1===this.pluginOptions?.colHighlight||this.colHeaderRanges.find((e=>C(e,s)))||(s&&this.table.arrangeCustomCellStyle({range:s},"col-highlight"),this.colHeaderRanges.push(s)),!1===this.pluginOptions?.rowHighlight||this.rowHeaderRanges.find((e=>C(e,o)))||(o&&this.table.arrangeCustomCellStyle({range:o},"row-highlight"),this.rowHeaderRanges.push(o))}}update(){this.registerStyle(),this.updateHighlight()}release(){this.rowHeaderRanges=[],this.colHeaderRanges=[]}},e.InvertHighlightPlugin=class{table;range;_fill;_opacity;constructor(e,t){this.table=e,this._fill=t?.fill??"#000",this._opacity=t?.opacity??.5}setInvertHighlightRange(e){o(this.range,e)||(this.range=e,e?this.updateCellGroupShadow():this.deleteAllCellGroupShadow(),this.table.scenegraph.updateNextFrame())}deleteAllCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup)}updateCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup,this.range)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.range,this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup,this.range)}updateCellGroupShadowInContainer(e,r){e.forEachChildrenSkipChild((e=>{const n=e;"column"===n.role&&n.forEachChildrenSkipChild((e=>{const n=e;if("cell"!==n.role)return;n.attachShadow(n.shadowRoot);const i=n.shadowRoot;if(r){if(_(r,n.col,n.row))i.removeAllChild();else if(!i.firstChild){const e=t.createRect({x:0,y:0,width:n.attribute.width,height:n.attribute.height,fill:this._fill,opacity:this._opacity});e.name="shadow-rect",i.appendChild(e)}}else i.removeAllChild()}))}))}},e.MENU_CONTAINER_CLASS=S,e.MENU_ITEM_CLASS=T,e.MENU_ITEM_DISABLED_CLASS=R,e.MENU_ITEM_SEPARATOR_CLASS=k,e.MENU_ITEM_SUBMENU_CLASS=M,e.MENU_STYLES=A,e.MasterDetailPlugin=class{id="Master Detail Plugin";name="Master Detail Plugin";runTime=[i.TABLE_EVENT_TYPE.BEFORE_INIT,i.TABLE_EVENT_TYPE.INITIALIZED,i.TABLE_EVENT_TYPE.SORT_CLICK,i.TABLE_EVENT_TYPE.AFTER_SORT,i.TABLE_EVENT_TYPE.AFTER_UPDATE_CELL_CONTENT_WIDTH,i.TABLE_EVENT_TYPE.AFTER_UPDATE_SELECT_BORDER_HEIGHT];pluginOptions;table;configManager;eventManager;subTableManager;tableAPIExtensions;resizeObserver;checkboxCascadeCleanup;constructor(e={}){this.pluginOptions=e}run(...e){const t=e[0],r=e[1],n=e[2];if(r===i.TABLE_EVENT_TYPE.BEFORE_INIT)this.table=n,this.initializeManagers(),this.configManager.injectMasterDetailOptions(t.options);else if(r===i.TABLE_EVENT_TYPE.INITIALIZED)this.setupMasterDetailFeatures();else{if(r===i.TABLE_EVENT_TYPE.SORT_CLICK)return this.eventManager.executeMasterDetailBeforeSort(),!0;r===i.TABLE_EVENT_TYPE.AFTER_SORT?this.eventManager.executeMasterDetailAfterSort():r===i.TABLE_EVENT_TYPE.AFTER_UPDATE_CELL_CONTENT_WIDTH?this.eventManager.handleAfterUpdateCellContentWidth(t):r===i.TABLE_EVENT_TYPE.AFTER_UPDATE_SELECT_BORDER_HEIGHT&&this.eventManager.handleAfterUpdateSelectBorderHeight(t)}}initializeManagers(){this.configManager=new wi(this.pluginOptions,this.table),this.eventManager=new _i(this.table);const e=this.pluginOptions.enableCheckboxCascade??!0;this.subTableManager=new xi(this.table,e),this.configManager.setRowExpandedChecker((e=>this.eventManager.isRowExpanded(e))),this.configManager.setExpandRowCallback((e=>this.expandRow(e))),this.eventManager.setCallbacks({onUpdateSubTablePositions:()=>this.subTableManager.recalculateAllSubTablePositions(),onUpdateSubTablePositionsForRow:()=>this.subTableManager.updateSubTablePositionsForRowResize(),onExpandRow:(e,t)=>this.expandRow(e,t),onCollapseRow:(e,t)=>this.collapseRow(e,t),onCollapseRowToNoRealRecordIndex:e=>this.collapseRowToNoRealRecordIndex(e),onToggleRowExpand:(e,t)=>this.toggleRowExpand(e,t),getOriginalRowHeight:e=>bi(this.table,e)}),this.subTableManager.setCallbacks({getDetailConfigForRecord:(e,t)=>this.configManager.getDetailConfigForRecord(e,t)}),this.subTableManager.setAutoHeightCallback(((e,t)=>{this.handleAutoHeightUpdate(e,t)}))}setupMasterDetailFeatures(){this.initInternalProps(),this.eventManager.bindEventHandlers(),this.setupUnifiedSelectionManagement(),this.extendTableAPI(),this.initCheckboxCascade()}mainTableClickHandler;setupUnifiedSelectionManagement(){this.mainTableClickHandler=()=>{this.clearAllSubTableVisibleSelections()},this.table.on("click_cell",this.mainTableClickHandler)}initCheckboxCascade(){(this.pluginOptions.enableCheckboxCascade??!0)&&(this.checkboxCascadeCleanup=Ei(this.table,this.eventManager))}initInternalProps(){const e=pi(this.table);e.expandedRecordIndices=[],e.subTableInstances=new Map,e.originalRowHeights=new Map,e.subTableCheckboxStates=new Map}extendTableAPI(){this.tableAPIExtensions=new Ci(this.table,this.configManager,this.eventManager,{addUnderlineToCell:e=>this.addUnderlineToCell(e),updateOriginalHeightsAfterAdaptive:e=>this.updateOriginalHeightsAfterAdaptive(e),collapseRowToNoRealRecordIndex:e=>this.collapseRowToNoRealRecordIndex(e),expandRow:e=>this.expandRow(e),restoreExpandedStatesAfter:()=>this.restoreExpandedStatesAfter(),collapseRow:e=>this.collapseRow(e),updateSubTablePositions:()=>this.subTableManager.recalculateAllSubTablePositions(),updateRowHeightForExpand:(e,t)=>this.updateRowHeightForExpand(e,t)}),this.tableAPIExtensions.extendTableAPI()}updateOriginalHeightsAfterAdaptive(e){const t=pi(this.table);for(const[r,n]of e){const e=r-this.table.columnHeaderLevelCount;t.originalRowHeights&&t.originalRowHeights.set(e,n.baseHeight)}}restoreExpandedStatesAfter(){const e=pi(this.table);if(!e.expandedRecordIndices||0===e.expandedRecordIndices.length)return;this.table.dataSource._currentPagerIndexedData&&e.expandedRecordIndices.forEach((e=>{try{const t=this.table.getBodyRowIndexByRecordIndex(e);if(t>=0){const e=t+this.table.columnHeaderLevelCount;this.expandRow(e)}}catch(e){}}))}expandRow(e,t){const r=e-this.table.columnHeaderLevelCount,n=pi(this.table);if(this.eventManager.isRowExpanded(e))return;const i=this.table.getRecordIndexByCell(0,e);if(null==i)return;var s,o;n.expandedRecordIndices&&(s=n.expandedRecordIndices,o=i,s.some((e=>di(e,o)))||n.expandedRecordIndices.push(i)),this.eventManager.addExpandedRow(e);const a=this.table.getRowHeight(e);n.originalRowHeights&&(this.table.scenegraph.getCell(t,e),n.originalRowHeights.set(r,a));const l=mi(this.table,r),h=this.configManager.getDetailConfigForRecord(l,r),c=h?.style?.height||300,u=Array.isArray(l.children)?l.children:[],d="auto"===c?300:"number"==typeof c?c:300;this.updateRowHeightForExpand(e,d),this.table.scenegraph.updateContainerHeight(e,d),n._heightResizedRowMap.add(e),this.subTableManager.renderSubTable(r,u,((e,t)=>this.configManager.getDetailConfigForRecord(e,t))),e!==this.table.rowCount-1&&this.drawUnderlineForRow(e),this.refreshRowIcon(e,t),"adaptive"===this.table.heightMode&&this.table.scenegraph.dealHeightMode(),this.updateFrozenColumnShadowHeight()}handleAutoHeightUpdate(e,t){try{const r=e+this.table.columnHeaderLevelCount,n=this.table.getRowHeight(r),i=pi(this.table),s=i.originalRowHeights?.get(e)||0,o=t-(n-s);this.updateRowHeightForExpand(r,o),this.table.scenegraph.updateContainerHeight(r,o)}catch(e){}}collapseRow(e,t){const r=e-this.table.columnHeaderLevelCount,n=pi(this.table);if(!this.eventManager.isRowExpanded(e))return;const i=this.table.getRecordIndexByCell(0,e);if(null==i)return;if(this.subTableManager.removeSubTable(r),n.expandedRecordIndices){const e=(s=n.expandedRecordIndices,o=i,s.findIndex((e=>di(e,o))));e>-1&&n.expandedRecordIndices.splice(e,1)}var s,o;this.eventManager.removeExpandedRow(e);const a=this.table.getRowHeight(e)-bi(this.table,r);this.updateRowHeightForExpand(e,-a),n._heightResizedRowMap.delete(e),this.table.scenegraph.updateContainerHeight(e,-a),n.originalRowHeights&&n.originalRowHeights.delete(r),e!==this.table.rowCount-1&&this.removeUnderlineFromRow(e),this.refreshRowIcon(e,t),"adaptive"===this.table.heightMode&&this.table.scenegraph.dealHeightMode(),this.updateFrozenColumnShadowHeight()}collapseRowToNoRealRecordIndex(e){const t=e-this.table.columnHeaderLevelCount,r=pi(this.table);if(!this.eventManager.isRowExpanded(e))return;this.subTableManager.removeSubTable(t),this.eventManager.removeExpandedRow(e);const n=this.table.getRowHeight(e)-bi(this.table,t);this.updateRowHeightForExpand(e,-n),r._heightResizedRowMap.delete(e),this.table.scenegraph.updateContainerHeight(e,-n),r.originalRowHeights&&r.originalRowHeights.delete(t),e!==this.table.rowCount-1&&this.removeUnderlineFromRow(e),this.refreshRowIcon(e),"adaptive"===this.table.heightMode&&this.table.scenegraph.dealHeightMode(),this.updateFrozenColumnShadowHeight()}toggleRowExpand(e,t){this.eventManager.isRowExpanded(e)?this.collapseRow(e,t):this.expandRow(e,t)}updateRowHeightForExpand(e,t){this.table._setRowHeight(e,this.table.getRowHeight(e)+t,!0);const r=e+1;let n=0;n=e<this.table.frozenRowCount?this.table.frozenRowCount-1:e>=this.table.rowCount-this.table.bottomFrozenRowCount?this.table.rowCount-1:Math.min(this.table.scenegraph.proxy.rowEnd,this.table.rowCount-this.table.bottomFrozenRowCount-1);for(let e=0;e<this.table.colCount;e++)for(let i=r;i<=n;i++){const r=this.table.scenegraph.highPerformanceGetCell(e,i);"cell"===r.role&&r.setAttribute("y",r.attribute.y+t)}}drawUnderlineForRow(e){if(!this.table.scenegraph)return;const t=this.getRowCells(e);0!==t.length&&(t.forEach(((e,t)=>{e&&e.attribute&&this.addUnderlineToCell(e)})),this.table.scenegraph.updateNextFrame())}getRowCells(e){const t=[];for(let r=0;r<this.table.colCount;r++){const n=this.table.scenegraph.getCell(r,e);n&&"cell"===n.role&&t.push(n)}return t}addUnderlineToCell(e){const t=e.attribute,r=t.strokeArrayWidth||(t.lineWidth?[t.lineWidth,t.lineWidth,t.lineWidth,t.lineWidth]:[1,1,1,1]),n=t.strokeArrayColor||(t.stroke?[t.stroke,t.stroke,t.stroke,t.stroke]:["transparent","transparent","transparent","transparent"]);e._hasUnderline||(e._originalStrokeArrayWidth=[...r],e._originalStrokeArrayColor=[...n],e._hasUnderline=!0);const i=e._originalStrokeArrayWidth||r,s=e._originalStrokeArrayColor||n,o=[...i],a=[...s],l=2*(.75*(i[2]||1)+.75*(i[0]||1));if(o[2]=l,"transparent"!==s[2]&&s[2])a[2]=s[2];else{const e=this.table.theme;a[2]=e?.bodyStyle?.borderColor||"#e1e4e8"}e.setAttributes({strokeArrayWidth:o,strokeArrayColor:a,stroke:!0})}removeUnderlineFromRow(e){this.getRowCells(e).forEach(((e,t)=>{e&&e._hasUnderline&&this.removeUnderlineFromCell(e)})),this.table.scenegraph.updateNextFrame()}removeUnderlineFromCell(e){e._hasUnderline&&(e._originalStrokeArrayWidth&&e._originalStrokeArrayColor&&(e.setAttributes({strokeArrayWidth:e._originalStrokeArrayWidth,strokeArrayColor:e._originalStrokeArrayColor}),delete e._originalStrokeArrayWidth,delete e._originalStrokeArrayColor),e._hasUnderline=!1)}refreshRowIcon(e,t){let r;if("number"==typeof t)r=t;else{r=!!this.table.options.rowSeriesNumber?1:0}const n=this.table.getCellOriginRecord(r,e);if(n&&"object"==typeof n){const t=n,s=i.TYPES.HierarchyState,o=this.eventManager.isRowExpanded(e);t.hierarchyState=o?s.expand:s.collapse,this.table.scenegraph.updateHierarchyIcon(r,e)}}setRecordChildren(e,t,r){const n=this.table.getRecordIndexByCell(t,r);if(null==n)return;const i="number"==typeof n?n:n[0],s=this.table.dataSource.get(i);s&&(s.children=e,this.expandRow(r,t),this.table.scenegraph.updateCellContent(t,r))}release(){const e=pi(this.table);e&&(e._isReleasing=!0);try{if(this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0),this.checkboxCascadeCleanup){try{this.checkboxCascadeCleanup()}catch(e){}this.checkboxCascadeCleanup=void 0}if(this.eventManager)try{this.eventManager.cleanup()}catch(e){}if(this.subTableManager)try{this.subTableManager.cleanup()}catch(e){}if(this.configManager)try{this.configManager.release()}catch(e){}if(this.cleanupMasterDetailFeatures(),this.table&&e)try{e.expandedRecordIndices?.splice(0),e.subTableInstances?.clear(),e.originalRowHeights?.clear(),e.subTableCheckboxStates?.clear(),e._heightResizedRowMap?.clear()}catch(e){}}catch(e){}finally{try{this.configManager=null,this.eventManager=null,this.subTableManager=null,this.tableAPIExtensions=null,this.table=null,this.pluginOptions=null}catch(e){}}}clearAllSubTableVisibleSelections(){const e=pi(this.table);e.subTableInstances?.forEach((e=>{e&&"function"==typeof e.clearSelected&&e.clearSelected()}))}getAllSubTableInstances(){return this.subTableManager.getAllSubTableInstances()}getSubTableByRowIndex(e){const t=e-this.table.columnHeaderLevelCount;return this.subTableManager.getSubTableInstance(t)}getSubTableByBodyRowIndex(e){return this.subTableManager.getSubTableInstance(e)}filterSubTables(e){const t=[],r=this.subTableManager.getAllSubTableInstances();if(!r)return t;for(const[n,i]of r)try{e(n,i,mi(this.table,n))&&t.push({bodyRowIndex:n,subTable:i})}catch(e){}return t}updateFrozenColumnShadowHeight(){try{const e=this.table.frozenColCount;e>0&&this.table.scenegraph.component.setFrozenColumnShadow(e-1)}catch(e){}}cleanupMasterDetailFeatures(){this.mainTableClickHandler&&(this.table.off("click_cell",this.mainTableClickHandler),this.mainTableClickHandler=void 0),this.tableAPIExtensions&&(this.tableAPIExtensions.cleanup(),this.tableAPIExtensions=void 0)}},e.MenuManager=F,e.PasteAddRowColumnPlugin=class{id="paste-add-row-column";name="Paste Add row";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED,r.TABLE_EVENT_TYPE.PASTED_DATA];table;pluginOptions;pastedData;constructor(e){this.pluginOptions=e,this.id=e?.id??this.id}run(...e){const t=e[1],n=e[2];this.table=n,t===r.TABLE_EVENT_TYPE.PASTED_DATA&&(this.pastedData=e[0],this.handlePaste())}handlePaste(){const{pasteData:e,row:t,col:r}=this.pastedData,n=this.table.rowCount,i=this.table.colCount,s=t+e.length-n,o=r+(e[0]?.length||0)-i;if(s>0)for(let e=0;e<s;e++)this.pluginOptions?.addRowCallback?this.pluginOptions.addRowCallback(n+e,this.table):this.table.addRecord([]);if(o>0)for(let e=0;e<o;e++){const t=i+e;this.pluginOptions?.addColumnCallback?this.pluginOptions.addColumnCallback(t,this.table):this.table.addColumns([{field:`field_${t}`,title:`New Column ${t}`,width:100}])}this.table.changeCellValues(r,t,e,!0)}release(){this.table.internalProps.handler.clear()}},e.RotateTablePlugin=class{id="rotate-table";name="Rotate Table";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED];table;matrix;vglobal_mapToCanvasPoint;constructor(e){this.id=e?.id??this.id}run(...e){const t=e[2];this.table=t,this.table.rotate90WithTransform=V.bind(this.table),this.table.cancelTransform=$.bind(this.table)}release(){}},e.RowSeriesPlugin=class{id="row-series";name="Row Series";runTime=[r.TABLE_EVENT_TYPE.BEFORE_INIT,r.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];pluginOptions;table;constructor(e){this.id=e.id??this.id,this.pluginOptions=Object.assign({rowCount:100},e)}run(...e){if(e[1]===r.TABLE_EVENT_TYPE.BEFORE_INIT){const t=e[0],r=e[2];this.table=r;const n=t.options,i=n.records??[];for(let e=i.length;e<this.pluginOptions.rowCount;e++)i.push(this.pluginOptions.fillRowRecord?this.pluginOptions.fillRowRecord(e):{});n.records=i,this.pluginOptions.rowSeriesNumber?(n.rowSeriesNumber=this.pluginOptions.rowSeriesNumber,this.pluginOptions.rowSeriesNumber.width||(n.rowSeriesNumber.width="auto")):n.rowSeriesNumber||(n.rowSeriesNumber={width:"auto"})}else if(e[1]===r.TABLE_EVENT_TYPE.BEFORE_KEYDOWN){const t=e[0].event;this.pluginOptions.autoExtendRowTriggerKeys?.includes(t.key)&&this.table.stateManager.select.cellPos.row===this.table.rowCount-1&&this.table.addRecord(this.pluginOptions.fillRowRecord?this.pluginOptions.fillRowRecord(this.table.rowCount-this.table.columnHeaderLevelCount):{})}}},e.TableCarouselAnimationPlugin=class{id="table-carousel-animation";name="Table Carousel Animation";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED];table;rowCount;colCount;animationDuration;animationDelay;animationEasing;playing;row;col;willUpdateRow=!1;willUpdateCol=!1;autoPlay;autoPlayDelay;customDistRowFunction;customDistColFunction;constructor(e={}){this.id=e.id??this.id,this.rowCount=e?.rowCount??void 0,this.colCount=e?.colCount??void 0,this.animationDuration=e?.animationDuration??500,this.animationDelay=e?.animationDelay??1e3,this.animationEasing=e?.animationEasing??"linear",this.autoPlay=e?.autoPlay??!1,this.autoPlayDelay=e?.autoPlayDelay??0,this.customDistColFunction=e.customDistColFunction,this.customDistRowFunction=e.customDistRowFunction}run(...e){this.table||(this.table=e[2]),this.reset(),this.autoPlay&&setTimeout((()=>{this.play()}),this.autoPlayDelay)}reset(){this.playing=!1,this.row=this.table.frozenRowCount,this.col=this.table.frozenColCount}play(){if(!this.table)throw new Error("table is not initialized");this.playing=!0,this.rowCount&&!this.willUpdateRow?this.updateRow():this.colCount&&!this.willUpdateCol&&this.updateCol()}pause(){this.playing=!1}updateRow(){if(!this.playing||this.table.isReleased)return;let e=!0;const t=Math.max(this.table.scenegraph.proxy.screenTopRow,this.table.frozenRowCount),r=this.customDistRowFunction&&this.customDistRowFunction(this.row,this.table);r?(this.row=r.distRow,e=r.animation??!0):U(this.row)&&t!==this.row?(this.row=this.table.frozenRowCount,e=!1):U(this.row)||t===Math.floor(this.row)?this.row+=this.rowCount:(this.row=this.table.frozenRowCount,e=!1),this.table.scrollToRow(this.row,e?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateRow=!0,setTimeout((()=>{this.willUpdateRow=!1,this.updateRow()}),this.animationDuration+this.animationDelay)}updateCol(){if(!this.playing||this.table.isReleased)return;let e=!0;const t=this.customDistColFunction&&this.customDistColFunction(this.col,this.table);t?(this.col=t.distCol,e=t.animation??!0):U(this.col)&&this.table.scenegraph.proxy.screenLeftCol!==this.col?(this.col=this.table.frozenColCount,e=!1):U(this.col)||this.table.scenegraph.proxy.screenLeftCol===Math.floor(this.col)?this.col+=this.colCount:(this.col=this.table.frozenColCount,e=!1),this.table.scrollToCol(this.col,e?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateCol=!0,setTimeout((()=>{this.willUpdateCol=!1,this.updateCol()}),this.animationDuration+this.animationDelay)}release(){}},e.TableExportPlugin=class{id="table-export-plugin";name="TableExport";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED];table;pluginOptions;constructor(e){this.pluginOptions=Object.assign({exportOnIdle:!1,exportExcelOptions:{downloadFile:!0,fileName:"export"},exportCsvOptions:{downloadFile:!0,fileName:"export"}},e)}run(...e){e[1]===r.TABLE_EVENT_TYPE.INITIALIZED&&(e[0],this.table=e[2],this.table.exportToCsv=()=>{const e=this.pluginOptions.exportCsvOptions;return e.downloadFile?async function(e,t){const r=new Blob([`\ufeff${e}`],{type:"text/csv;charset=utf-8"});await Is.saveAs(r,`${t}.csv`)}(Ss(this.table,e),e.fileName||"export"):Ss(this.table,e)},this.table.exportToExcel=async()=>{const e=this.pluginOptions.exportExcelOptions;return e.downloadFile?await async function(e,t){const r=new Blob([e],{type:"application/octet-stream"});await Is.saveAs(r,`${t}.xlsx`)}(await _s(this.table,e,this.pluginOptions.exportOnIdle),e.fileName||"export"):_s(this.table,e,this.pluginOptions.exportOnIdle)})}release(){this.table&&(delete this.table.exportToCsv,delete this.table.exportToExcel,this.table=null)}},e.TableSeriesNumber=class{id="table-series-number";name="Table Series Number";runTime=[r.TABLE_EVENT_TYPE.INITIALIZED,r.TABLE_EVENT_TYPE.BEFORE_INIT,r.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION,r.TABLE_EVENT_TYPE.UPDATED];pluginOptions;table;seriesNumberComponent;componentLayoutLayer;lastCurrentRow=0;lastCurrentCol=0;startRowIndex=0;scrollTimer;constructor(e){this.pluginOptions=e,this.seriesNumberComponent=new t.TableSeriesNumber({rowCount:e.rowCount,colCount:e.colCount,rowSeriesNumberWidth:e.rowSeriesNumberWidth,colSeriesNumberHeight:e.colSeriesNumberHeight,rowSeriesNumberGenerate:e.rowSeriesNumberGenerate,colSeriesNumberGenerate:e.colSeriesNumberGenerate,rowSeriesNumberCellStyle:Object.assign({text:{fontSize:14,fill:"#7A7A7A",pickable:!1,textAlign:"left",textBaseline:"middle",padding:[2,4,2,4]},borderLine:{stroke:"#D9D9D9",lineWidth:1,pickable:!1},bgColor:"#F9F9F9",states:{hover:{fill:"#c8daf6",opacity:.7},select:{fill:"#c8daf6",opacity:1}}},e.rowSeriesNumberCellStyle),colSeriesNumberCellStyle:Object.assign({text:{fontSize:14,fill:"#7A7A7A",pickable:!1,textAlign:"left",textBaseline:"middle",padding:[2,4,2,4]},borderLine:{stroke:"#D9D9D9",lineWidth:1,pickable:!1},bgColor:"#F9F9F9",states:{hover:{fill:"#c8daf6",opacity:.7},select:{fill:"#c8daf6",opacity:1}}},e.colSeriesNumberCellStyle),cornerCellStyle:Object.assign({borderLine:{stroke:"#D9D9D9",lineWidth:1,pickable:!1},bgColor:"#F9F9F9",states:{hover:{fill:"#98C8A5",opacity:.7},select:{fill:"#98C8A5",opacity:1}}},e.cornerCellStyle),checkMoveColumnOrder:e=>!!this.pluginOptions.dragOrder?.enableDragColumnOrder&&this.table.isColumnSelected(e),checkMoveRowOrder:e=>!!this.pluginOptions.dragOrder?.enableDragRowOrder&&this.table.isRowSelected(e)}),this.listenComponentEvents()}run(...e){const t=e[1];if(t===r.TABLE_EVENT_TYPE.BEFORE_INIT||t===r.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION){const t=e[0],r=e[2];this.table=r;const n=t.options,i=n.records??[];i.length<this.pluginOptions.rowCount&&(i.length=this.pluginOptions.rowCount),n.records=i,n.columns||(n.columns=[]);for(let e=n.columns.length;e<this.pluginOptions.colCount;e++){const t={field:e,key:e,title:""};n.columns.push(t)}const s=this.seriesNumberComponent.rowSeriesNumberWidth,o=this.seriesNumberComponent.colSeriesNumberHeight;n.contentOffsetX=s,n.contentOffsetY=o}else if(t===r.TABLE_EVENT_TYPE.INITIALIZED||t===r.TABLE_EVENT_TYPE.UPDATED){this.table=e[2],this.table.options.customConfig||(this.table.options.customConfig={}),this.table.options.customConfig.cancelSelectCellHook=e=>!e.target.isDescendantsOf(this.seriesNumberComponent),this.seriesNumberComponent.setAttributes({rowCount:this.table.rowCount,colCount:this.table.colCount,frozenRowCount:this.table.frozenRowCount,frozenColCount:this.table.frozenColCount,rightFrozenColCount:this.table.rightFrozenColCount,bottomFrozenRowCount:this.table.bottomFrozenRowCount});const t=this.table.scenegraph.stage.createLayer();t.appendChild(this.seriesNumberComponent),t.setAttributes({pickable:!1}),this.componentLayoutLayer=t,this.syncRowHeightToComponent(),this.syncColWidthToComponent(),this.listenTableEvents()}}handleScroll=()=>{this.scrollTimer&&(clearTimeout(this.scrollTimer),this.scrollTimer=null),this.scrollTimer=setTimeout((()=>{this.scrollTimer=null,this.syncScrollToComponent()}),10)};handleAfterSort=()=>{this.syncScrollToComponent()};handleSelectedChanged=e=>{this.seriesNumberComponent.removeAllSelectedIndexs();const t=this.table.stateManager.select.ranges,r=[],n=[];for(const e of t){const{row:t,col:i}=e.start,{row:s,col:o}=e.end;r.push({startIndex:Math.min(t,s),endIndex:Math.max(t,s)}),n.push({startIndex:Math.min(i,o),endIndex:Math.max(i,o)})}this.seriesNumberComponent.addRowSelectedRanges(r),this.seriesNumberComponent.addColSelectedRanges(n),this.table.stateManager.select.isSelectAll&&this.seriesNumberComponent.addCornderSelected(),this.seriesNumberComponent.renderSelectedIndexsState()};handleResizeColumnEnd=e=>{this.seriesNumberComponent.setAttribute("hover",!0)};handleResizeRowEnd=e=>{this.seriesNumberComponent.setAttribute("hover",!0)};handleChangeHeaderPosition=e=>{this.syncColWidthToComponent()};listenTableEvents(){this.table.on(r.TABLE_EVENT_TYPE.SCROLL,this.handleScroll),this.table.on(r.TABLE_EVENT_TYPE.AFTER_SORT,this.handleAfterSort),this.table.on(r.TABLE_EVENT_TYPE.SELECTED_CHANGED,this.handleSelectedChanged),this.table.on(r.TABLE_EVENT_TYPE.RESIZE_COLUMN_END,this.handleResizeColumnEnd),this.table.on(r.TABLE_EVENT_TYPE.RESIZE_ROW_END,this.handleResizeRowEnd),this.table.on(r.TABLE_EVENT_TYPE.CHANGE_HEADER_POSITION,this.handleChangeHeaderPosition)}handleSeriesNumberCellRightClick=e=>{const{seriesNumberCell:t,event:n,isDragSelect:i}=e.detail,s=t.name.includes("row"),o=t.name.includes("col");if(s){const e=t.id;this.table.stateManager.select.ranges.some((t=>t.start.row<=e&&e<=t.end.row&&0===t.start.col&&t.end.col===this.table.colCount-1))||this.table.selectCells([{start:{row:e,col:0},end:{row:e,col:this.table.colCount-1}}]),this.table.fireListeners(r.TABLE_EVENT_TYPE.PLUGIN_EVENT,{plugin:this,event:n,pluginEventInfo:{eventType:"rightclick",rowIndex:e}})}else if(o){const e=t.id;this.table.stateManager.select.ranges.some((t=>t.start.col<=e&&e<=t.end.col&&0===t.start.row&&t.end.row===this.table.rowCount-1))||this.table.selectCells([{start:{row:0,col:e},end:{row:this.table.rowCount-1,col:e}}]),this.table.fireListeners(r.TABLE_EVENT_TYPE.PLUGIN_EVENT,{plugin:this,event:n,pluginEventInfo:{eventType:"rightclick",colIndex:e}})}else this.table.selectCells([{start:{row:0,col:0},end:{row:this.table.rowCount-1,col:this.table.colCount-1}}]),this.table.fireListeners(r.TABLE_EVENT_TYPE.PLUGIN_EVENT,{plugin:this,event:n,pluginEventInfo:{eventType:"rightclick",isCorner:!0}})};handleSeriesNumberCellHover=e=>{this.table.scenegraph.renderSceneGraph()};handleSeriesNumberCellUnHover=e=>{this.table.scenegraph.renderSceneGraph()};handleSeriesNumberCellClick=e=>{const{seriesNumberCell:t,event:r,isDragSelect:n}=e.detail,i=this.table.options.keyboardOptions?.ctrlMultiSelect??!0,s=this.table.options.keyboardOptions?.shiftMultiSelect??!0,o=(r.nativeEvent.ctrlKey||r.nativeEvent.metaKey)&&i,a=r.nativeEvent.shiftKey&&s,l=t.name.includes("row"),h=t.name.includes("col");if(l){this.table.stateManager.setSelectInline("row");const e=t.id;n?this.table.dragSelectRow(e,o):this.table.startDragSelectRow(e,o,a)}else if(h){this.table.stateManager.setSelectInline("col");const e=t.id;n?this.table.dragSelectCol(e,o):this.table.startDragSelectCol(e,o,a)}else this.table.eventManager.deelTableSelectAll()};handleSeriesNumberCellClickUp=e=>{this.table.stateManager.setSelectInline(!1),this.table.endDragSelect()};handleRowSeriesNumberWidthChange=e=>{const t=this.seriesNumberComponent.rowSeriesNumberWidth,r=this.seriesNumberComponent.colSeriesNumberHeight;this.table.setContentInsetXY(t,r)};handleResizeColWidthStart=e=>{this.seriesNumberComponent.setAttribute("hover",!1);const{colIndex:t,event:n}=e.detail;this.table.stateManager.updateInteractionState(r.TYPES.InteractionState.grabing),this.table.stateManager.startResizeCol(t,n.viewport.x,n.viewport.y)};handleResizeRowHeightStart=e=>{this.seriesNumberComponent.setAttribute("hover",!1);const{rowIndex:t,event:n}=e.detail;this.table.stateManager.updateInteractionState(r.TYPES.InteractionState.grabing),this.table.stateManager.startResizeRow(t,n.viewport.x,n.viewport.y)};handleDragColumOrderStart=e=>{const{colIndex:t,event:n}=e.detail;this.table.stateManager.updateInteractionState(r.TYPES.InteractionState.grabing),this.table.stateManager.startMoveCol(t,0,n.viewport.x,n.viewport.y,n.nativeEvent,"column")};handleDragRowOrderStart=e=>{const{rowIndex:t,event:n}=e.detail;this.table.stateManager.updateInteractionState(r.TYPES.InteractionState.grabing),this.table.stateManager.startMoveCol(0,t,n.viewport.x,n.viewport.y,n.nativeEvent,"row")};listenComponentEvents(){this.seriesNumberComponent.on(t.SeriesNumberEvent.seriesNumberCellRightClick,this.handleSeriesNumberCellRightClick),this.seriesNumberComponent.on(t.SeriesNumberEvent.seriesNumberCellHover,this.handleSeriesNumberCellHover),this.seriesNumberComponent.on(t.SeriesNumberEvent.seriesNumberCellUnHover,this.handleSeriesNumberCellUnHover),this.seriesNumberComponent.on(t.SeriesNumberEvent.seriesNumberCellClick,this.handleSeriesNumberCellClick),this.seriesNumberComponent.on(t.SeriesNumberEvent.seriesNumberCellClickUp,this.handleSeriesNumberCellClickUp),this.seriesNumberComponent.on(t.SeriesNumberEvent.rowSeriesNumberWidthChange,this.handleRowSeriesNumberWidthChange),this.seriesNumberComponent.on(t.SeriesNumberEvent.resizeColWidthStart,this.handleResizeColWidthStart),this.seriesNumberComponent.on(t.SeriesNumberEvent.resizeRowHeightStart,this.handleResizeRowHeightStart),this.pluginOptions.dragOrder?.enableDragColumnOrder&&this.seriesNumberComponent.on(t.SeriesNumberEvent.dragColumnOrderStart,this.handleDragColumOrderStart),this.pluginOptions.dragOrder?.enableDragRowOrder&&this.seriesNumberComponent.on(t.SeriesNumberEvent.dragRowOrderStart,this.handleDragRowOrderStart)}release(){this.componentLayoutLayer&&(this.table.scenegraph.stage.removeLayer(this.componentLayoutLayer._uid),this.componentLayoutLayer=null),this.scrollTimer&&(clearTimeout(this.scrollTimer),this.scrollTimer=null),this.table&&(this.table.off(r.TABLE_EVENT_TYPE.SCROLL,this.handleScroll),this.table.off(r.TABLE_EVENT_TYPE.AFTER_SORT,this.handleAfterSort),this.table.off(r.TABLE_EVENT_TYPE.SELECTED_CHANGED,this.handleSelectedChanged),this.table.off(r.TABLE_EVENT_TYPE.RESIZE_COLUMN_END,this.handleResizeColumnEnd),this.table.off(r.TABLE_EVENT_TYPE.RESIZE_ROW_END,this.handleResizeRowEnd)),this.seriesNumberComponent&&(this.seriesNumberComponent.off(t.SeriesNumberEvent.seriesNumberCellRightClick,this.handleSeriesNumberCellRightClick),this.seriesNumberComponent.off(t.SeriesNumberEvent.seriesNumberCellHover,this.handleSeriesNumberCellHover),this.seriesNumberComponent.off(t.SeriesNumberEvent.seriesNumberCellUnHover,this.handleSeriesNumberCellUnHover),this.seriesNumberComponent.off(t.SeriesNumberEvent.seriesNumberCellClick,this.handleSeriesNumberCellClick),this.seriesNumberComponent.off(t.SeriesNumberEvent.seriesNumberCellClickUp,this.handleSeriesNumberCellClickUp),this.seriesNumberComponent.off(t.SeriesNumberEvent.rowSeriesNumberWidthChange,this.handleRowSeriesNumberWidthChange),this.seriesNumberComponent.off(t.SeriesNumberEvent.resizeColWidthStart,this.handleResizeColWidthStart),this.seriesNumberComponent.off(t.SeriesNumberEvent.resizeRowHeightStart,this.handleResizeRowHeightStart),this.seriesNumberComponent.release?.(),this.seriesNumberComponent=null)}syncRowHeightToComponent(){const{rowStart:e,rowEnd:t}=this.table.getBodyVisibleRowRange(),r=Math.max(e-2,this.table.frozenRowCount),n=Math.min(t+2,this.table.rowCount-1);this.table.frozenRowCount!==this.seriesNumberComponent.getAttributes().frozenRowCount&&this.seriesNumberComponent.setAttributes({frozenRowCount:this.table.frozenRowCount}),this.seriesNumberComponent.recreateCellsToRowSeriesNumberGroup(r,n);for(let e=0;e<this.table.frozenRowCount;e++){const t=this.table.scenegraph.getCell(0,e).getAttributes();this.seriesNumberComponent.setRowSeriesNumberCellAttributes(e,{y:t.y,height:t.height})}for(let e=r;e<=n;e++){const t=this.table.scenegraph.getCell(0,e).getAttributes();this.seriesNumberComponent.setRowSeriesNumberCellAttributes(e,{y:t.y,height:t.height})}}syncColWidthToComponent(){const{colStart:e,colEnd:t}=this.table.getBodyVisibleColRange(),r=e,n=Math.min(t,this.table.scenegraph.proxy.colEnd);this.table.frozenColCount!==this.seriesNumberComponent.getAttributes().frozenColCount&&this.seriesNumberComponent.setAttributes({frozenColCount:this.table.frozenColCount}),this.seriesNumberComponent.recreateCellsToColSeriesNumberGroup(r,n);for(let e=0;e<this.table.frozenColCount;e++){const t=this.table.scenegraph.getColGroup(e).getAttributes();this.seriesNumberComponent.setColSeriesNumberCellAttributes(e,{x:t.x,width:t.width})}for(let e=r;e<=n;e++){const t=this.table.scenegraph.getColGroup(e).getAttributes();this.seriesNumberComponent.setColSeriesNumberCellAttributes(e,{x:t.x,width:t.width})}}syncScrollToComponent(){this.syncRowHeightToComponent(),this.syncColWidthToComponent();const e=this.table.scenegraph.bodyGroup.getAttributes().y,t=this.table.scenegraph.bodyGroup.getAttributes().x;this.seriesNumberComponent.setRowSeriesNumberGroupAttributes({y:e+this.seriesNumberComponent.colSeriesNumberHeight}),this.seriesNumberComponent.setColSeriesNumberGroupAttributes({x:t+this.seriesNumberComponent.rowSeriesNumberWidth})}},e.ValueFilter=rs,e.WpsFillHandlePlugin=class{id="wps-fill-handle";name="WPS Fill Handle";runTime=[r.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE,r.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END];table;pluginOptions;beforeDragMinCol=0;beforeDragMinRow=0;beforeDragMaxCol=0;beforeDragMaxRow=0;constructor(e){this.id=e?.id??this.id,this.pluginOptions=e}run(...e){if(e[1]===r.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE){e[0];const t=e[2];this.table=t;const r=this.table?.getSelectedCellRanges()[0];if(!r)return;this.beforeDragMaxCol=Math.max(r.start.col,r.end.col),this.beforeDragMinCol=Math.min(r.start.col,r.end.col),this.beforeDragMaxRow=Math.max(r.start.row,r.end.row),this.beforeDragMinRow=Math.min(r.start.row,r.end.row)}else if(e[1]===r.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END){const t=e[0].direction;let r,n;const i=this.table?.getSelectedCellRanges()[0];if(!i)return;"bottom"===t?(r=this.beforeDragMaxCol,n=i.end.row):"right"===t?(r=i.end.col,n=this.beforeDragMaxRow):"top"===t?(r=this.beforeDragMaxCol,n=i.end.row):"left"===t&&(r=i.end.col,n=this.beforeDragMaxRow);const s=this.table?.records,o=this.table?.getAllColumnHeaderCells()||[];let a=[];o?.length&&(a=o[o.length-1]);const l=ui(s,a,{startRow:this.beforeDragMinRow-o.length,startCol:this.beforeDragMinCol,endRow:this.beforeDragMaxRow-o.length,endCol:this.beforeDragMaxCol},{row:n-o.length,col:r});this.table?.setRecords(l)}}handleKeyDown(){if(this.table.editorManager){const e=this.table?.getSelectedCellRanges()[0];if(!e)return;this.beforeDragMaxCol=Math.max(e.start.col,e.end.col),this.beforeDragMinCol=Math.min(e.start.col,e.end.col),this.beforeDragMaxRow=Math.max(e.start.row,e.end.row),this.beforeDragMinRow=Math.min(e.start.row,e.end.row)}}release(){this.beforeDragMinCol=0,this.beforeDragMinRow=0,this.beforeDragMaxCol=0,this.beforeDragMaxRow=0}},e.applyStyles=I,e.cancelTransform=$,e.createElement=O,e.createIcon=N,e.createNumberInputItem=function(e,t=1,r,n){const i=O("div");if(I(i,A.inputContainer),r){const e=N(r);i.appendChild(e)}const s=O("label");s.textContent=e,I(s,A.inputLabel),i.appendChild(s);const o=O("input");o.type="number",o.min="1",o.value=t.toString(),I(o,A.inputField),i.appendChild(o);const a=O("div");return a.appendChild(i),a},e.rotate90WithTransform=V}));
@@ -36,8 +36,8 @@ export class ExcelEditCellKeyboardPlugin {
36
36
  if (!this.table.editorManager.editingEditor || eventKey !== ExcelEditCellKeyboardResponse.ENTER && eventKey !== ExcelEditCellKeyboardResponse.TAB) {
37
37
  if (!this.table.editorManager.editingEditor && (eventKey === ExcelEditCellKeyboardResponse.DELETE || eventKey === ExcelEditCellKeyboardResponse.BACKSPACE)) {
38
38
  const selectCells = this.table.getSelectedCellInfos();
39
- (null == selectCells ? void 0 : selectCells.length) > 0 && deleteSelectRange(selectCells, this.table),
40
- event.stopPropagation(), event.preventDefault();
39
+ (null == selectCells ? void 0 : selectCells.length) > 0 && document.activeElement === this.table.getElement() && (deleteSelectRange(selectCells, this.table),
40
+ event.stopPropagation(), event.preventDefault());
41
41
  }
42
42
  } else this.table.editorManager.completeEdit(), this.table.getElement().focus(),
43
43
  eventKey === ExcelEditCellKeyboardResponse.ENTER ? this.table.selectCell(col, row + 1) : eventKey === ExcelEditCellKeyboardResponse.TAB && this.table.selectCell(col + 1, row),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/excel-edit-cell-keyboard.ts"],"names":[],"mappings":"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","file":"excel-edit-cell-keyboard.js","sourcesContent":["import type { ListTable, BaseTableAPI, TYPES, pluginsDefinition } from '@visactor/vtable';\nimport { TABLE_EVENT_TYPE } from '@visactor/vtable';\nimport type { TableEvents } from '@visactor/vtable/src/core/TABLE_EVENT_TYPE';\nimport type { EventArg } from './types';\nexport enum ExcelEditCellKeyboardResponse {\n ENTER = 'enter',\n TAB = 'tab',\n ARROW_LEFT = 'arrowLeft',\n ARROW_RIGHT = 'arrowRight',\n ARROW_DOWN = 'arrowDown',\n ARROW_UP = 'arrowUp',\n DELETE = 'delete',\n BACKSPACE = 'backspace'\n}\n//备用 插件配置项 目前感觉都走默认逻辑就行\nexport type IExcelEditCellKeyboardPluginOptions = {\n id?: string;\n responseKeyboard?: ExcelEditCellKeyboardResponse[];\n // 是否响应删除\n // enableDeleteKey?: boolean;\n};\n\nexport class ExcelEditCellKeyboardPlugin implements pluginsDefinition.IVTablePlugin {\n id = `excel-edit-cell-keyboard`;\n name = 'Excel Edit Cell Keyboard';\n runTime = [TABLE_EVENT_TYPE.INITIALIZED];\n table: ListTable;\n pluginOptions: IExcelEditCellKeyboardPluginOptions;\n responseKeyboard: ExcelEditCellKeyboardResponse[];\n constructor(pluginOptions?: IExcelEditCellKeyboardPluginOptions) {\n this.id = pluginOptions?.id ?? this.id;\n this.pluginOptions = pluginOptions;\n this.responseKeyboard = pluginOptions?.responseKeyboard ?? [\n ExcelEditCellKeyboardResponse.ENTER,\n ExcelEditCellKeyboardResponse.TAB,\n ExcelEditCellKeyboardResponse.ARROW_LEFT,\n ExcelEditCellKeyboardResponse.ARROW_RIGHT,\n ExcelEditCellKeyboardResponse.ARROW_DOWN,\n ExcelEditCellKeyboardResponse.ARROW_UP,\n ExcelEditCellKeyboardResponse.DELETE,\n ExcelEditCellKeyboardResponse.BACKSPACE\n ];\n\n this.bindEvent();\n }\n run(...args: [EventArg, TableEvents[keyof TableEvents] | TableEvents[keyof TableEvents][], BaseTableAPI]) {\n const table: BaseTableAPI = args[2];\n this.table = table as ListTable;\n }\n\n bindEvent() {\n //监听document全局的keydown事件 捕获阶段监听 可以及时阻止事件传播和默认行为\n document.addEventListener('keydown', this.handleKeyDown.bind(this), true);\n // this.table.on('selected_cell', () => {\n // this.updateHighlight();\n // });\n\n // this.table.on('selected_clear', () => {\n // this.clearHighlight();\n // });\n\n // this.table.on('mousemove_table', () => {\n // if (this.table.stateManager.select.selecting) {\n // this.updateHighlight();\n // }\n // });\n }\n handleKeyDown(event: KeyboardEvent) {\n if (this.table.editorManager && this.isExcelShortcutKey(event)) {\n const eventKey = event.key.toLowerCase() as ExcelEditCellKeyboardResponse;\n //判断是键盘触发编辑单元格的情况下,那么在编辑状态中切换方向需要选中下一个继续编辑\n if (this.table.editorManager.editingEditor && this.table.editorManager.beginTriggerEditCellMode === 'keydown') {\n const { col, row } = this.table.editorManager.editCell;\n this.table.editorManager.completeEdit();\n this.table.getElement().focus();\n if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {\n //有这些配合键,则不进行选中下一个单元格的行为 执行vtable内部逻辑\n if (eventKey === ExcelEditCellKeyboardResponse.ENTER) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.TAB) {\n this.table.selectCell(col + 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_LEFT) {\n this.table.selectCell(col - 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_RIGHT) {\n this.table.selectCell(col + 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_DOWN) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_UP) {\n this.table.selectCell(col, row - 1);\n }\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n }\n } else {\n const { col, row } = this.table.stateManager.select.cellPos;\n if (\n this.table.editorManager.editingEditor &&\n (eventKey === ExcelEditCellKeyboardResponse.ENTER || eventKey === ExcelEditCellKeyboardResponse.TAB)\n ) {\n this.table.editorManager.completeEdit();\n this.table.getElement().focus();\n if (eventKey === ExcelEditCellKeyboardResponse.ENTER) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.TAB) {\n this.table.selectCell(col + 1, row);\n }\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n } else if (\n !this.table.editorManager.editingEditor &&\n (eventKey === ExcelEditCellKeyboardResponse.DELETE || eventKey === ExcelEditCellKeyboardResponse.BACKSPACE)\n ) {\n //响应删除键,删除\n const selectCells = this.table.getSelectedCellInfos();\n if (selectCells?.length > 0) {\n // 如果选中的是范围,则删除范围内的所有单元格\n deleteSelectRange(selectCells, this.table);\n }\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n }\n }\n }\n }\n // 判断event的keyCode是否是excel的快捷键\n isExcelShortcutKey(event: KeyboardEvent) {\n return this.responseKeyboard.includes(event.key.toLowerCase() as ExcelEditCellKeyboardResponse);\n }\n setResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = responseKeyboard;\n }\n deleteResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = this.responseKeyboard.filter(key => !responseKeyboard.includes(key));\n }\n addResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = [...this.responseKeyboard, ...responseKeyboard];\n }\n release() {\n document.removeEventListener('keydown', this.handleKeyDown, true);\n }\n}\n//将选中单元格的值设置为空\nfunction deleteSelectRange(selectCells: TYPES.CellInfo[][], tableInstance: ListTable) {\n for (let i = 0; i < selectCells.length; i++) {\n for (let j = 0; j < selectCells[i].length; j++) {\n tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, '');\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/excel-edit-cell-keyboard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,MAAM,CAAN,IAAY,6BASX;AATD,WAAY,6BAA6B;IACvC,gDAAe,CAAA;IACf,4CAAW,CAAA;IACX,yDAAwB,CAAA;IACxB,2DAA0B,CAAA;IAC1B,yDAAwB,CAAA;IACxB,qDAAoB,CAAA;IACpB,kDAAiB,CAAA;IACjB,wDAAuB,CAAA;AACzB,CAAC,EATW,6BAA6B,KAA7B,6BAA6B,QASxC;AAWD,MAAM,OAAO,2BAA2B;IAOtC,YAAY,aAAmD;;QAN/D,OAAE,GAAG,0BAA0B,CAAC;QAChC,SAAI,GAAG,0BAA0B,CAAC;QAClC,YAAO,GAAG,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAKvC,IAAI,CAAC,EAAE,GAAG,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,EAAE,mCAAI,IAAI,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,gBAAgB,GAAG,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,gBAAgB,mCAAI;YACzD,6BAA6B,CAAC,KAAK;YACnC,6BAA6B,CAAC,GAAG;YACjC,6BAA6B,CAAC,UAAU;YACxC,6BAA6B,CAAC,WAAW;YACzC,6BAA6B,CAAC,UAAU;YACxC,6BAA6B,CAAC,QAAQ;YACtC,6BAA6B,CAAC,MAAM;YACpC,6BAA6B,CAAC,SAAS;SACxC,CAAC;QAEF,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IACD,GAAG,CAAC,GAAG,IAAiG;QACtG,MAAM,KAAK,GAAiB,IAAI,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,KAAkB,CAAC;IAClC,CAAC;IAED,SAAS;QAEP,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAc5E,CAAC;IACD,aAAa,CAAC,KAAoB;QAEhC,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE;YAC9D,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,WAAW,EAAmC,CAAC;YAE1E,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,wBAAwB,KAAK,SAAS,EAAE;gBAC7G,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC;gBACvD,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;gBACxC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC;gBAChC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;oBAEvD,IAAI,QAAQ,KAAK,6BAA6B,CAAC,KAAK,EAAE;wBACpD,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;qBACrC;yBAAM,IAAI,QAAQ,KAAK,6BAA6B,CAAC,GAAG,EAAE;wBACzD,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;qBACrC;yBAAM,IAAI,QAAQ,KAAK,6BAA6B,CAAC,UAAU,EAAE;wBAChE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;qBACrC;yBAAM,IAAI,QAAQ,KAAK,6BAA6B,CAAC,WAAW,EAAE;wBACjE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;qBACrC;yBAAM,IAAI,QAAQ,KAAK,6BAA6B,CAAC,UAAU,EAAE;wBAChE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;qBACrC;yBAAM,IAAI,QAAQ,KAAK,6BAA6B,CAAC,QAAQ,EAAE;wBAC9D,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;qBACrC;oBAED,KAAK,CAAC,eAAe,EAAE,CAAC;oBACxB,KAAK,CAAC,cAAc,EAAE,CAAC;iBACxB;aACF;iBAAM;gBACL,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC;gBAC5D,IACE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa;oBACtC,CAAC,QAAQ,KAAK,6BAA6B,CAAC,KAAK,IAAI,QAAQ,KAAK,6BAA6B,CAAC,GAAG,CAAC,EACpG;oBACA,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;oBACxC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC;oBAChC,IAAI,QAAQ,KAAK,6BAA6B,CAAC,KAAK,EAAE;wBACpD,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;qBACrC;yBAAM,IAAI,QAAQ,KAAK,6BAA6B,CAAC,GAAG,EAAE;wBACzD,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;qBACrC;oBAED,KAAK,CAAC,eAAe,EAAE,CAAC;oBACxB,KAAK,CAAC,cAAc,EAAE,CAAC;iBACxB;qBAAM,IACL,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa;oBACvC,CAAC,QAAQ,KAAK,6BAA6B,CAAC,MAAM,IAAI,QAAQ,KAAK,6BAA6B,CAAC,SAAS,CAAC,EAC3G;oBAEA,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC;oBACtD,IAAI,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,IAAG,CAAC,IAAI,QAAQ,CAAC,aAAa,KAAK,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE;wBAEjF,iBAAiB,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;wBAE3C,KAAK,CAAC,eAAe,EAAE,CAAC;wBACxB,KAAK,CAAC,cAAc,EAAE,CAAC;qBACxB;iBACF;aACF;SACF;IAEH,CAAC;IAED,kBAAkB,CAAC,KAAoB;QACrC,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAmC,CAAC,CAAC;IAClG,CAAC;IACD,mBAAmB,CAAC,gBAAiD;QACnE,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC;IACD,sBAAsB,CAAC,gBAAiD;QACtE,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/F,CAAC;IACD,mBAAmB,CAAC,gBAAiD;QACnE,IAAI,CAAC,gBAAgB,GAAG,CAAC,GAAG,IAAI,CAAC,gBAAgB,EAAE,GAAG,gBAAgB,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO;QACL,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC;CACF;AAED,SAAS,iBAAiB,CAAC,WAA+B,EAAE,aAAwB;IAClF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC9C,aAAa,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;SACjF;KACF;AACH,CAAC","file":"excel-edit-cell-keyboard.js","sourcesContent":["import type { ListTable, BaseTableAPI, TYPES, pluginsDefinition } from '@visactor/vtable';\nimport { TABLE_EVENT_TYPE } from '@visactor/vtable';\nimport type { TableEvents } from '@visactor/vtable/src/core/TABLE_EVENT_TYPE';\nimport type { EventArg } from './types';\nexport enum ExcelEditCellKeyboardResponse {\n ENTER = 'enter',\n TAB = 'tab',\n ARROW_LEFT = 'arrowLeft',\n ARROW_RIGHT = 'arrowRight',\n ARROW_DOWN = 'arrowDown',\n ARROW_UP = 'arrowUp',\n DELETE = 'delete',\n BACKSPACE = 'backspace'\n}\n//备用 插件配置项 目前感觉都走默认逻辑就行\nexport type IExcelEditCellKeyboardPluginOptions = {\n id?: string;\n responseKeyboard?: ExcelEditCellKeyboardResponse[];\n // keyDown_before?: (event: KeyboardEvent) => void;\n // keyDown_after?: (event: KeyboardEvent) => void;\n // 是否响应删除\n // enableDeleteKey?: boolean;\n};\n\nexport class ExcelEditCellKeyboardPlugin implements pluginsDefinition.IVTablePlugin {\n id = `excel-edit-cell-keyboard`;\n name = 'Excel Edit Cell Keyboard';\n runTime = [TABLE_EVENT_TYPE.INITIALIZED];\n table: ListTable;\n pluginOptions: IExcelEditCellKeyboardPluginOptions;\n responseKeyboard: ExcelEditCellKeyboardResponse[];\n constructor(pluginOptions?: IExcelEditCellKeyboardPluginOptions) {\n this.id = pluginOptions?.id ?? this.id;\n this.pluginOptions = pluginOptions;\n this.responseKeyboard = pluginOptions?.responseKeyboard ?? [\n ExcelEditCellKeyboardResponse.ENTER,\n ExcelEditCellKeyboardResponse.TAB,\n ExcelEditCellKeyboardResponse.ARROW_LEFT,\n ExcelEditCellKeyboardResponse.ARROW_RIGHT,\n ExcelEditCellKeyboardResponse.ARROW_DOWN,\n ExcelEditCellKeyboardResponse.ARROW_UP,\n ExcelEditCellKeyboardResponse.DELETE,\n ExcelEditCellKeyboardResponse.BACKSPACE\n ];\n\n this.bindEvent();\n }\n run(...args: [EventArg, TableEvents[keyof TableEvents] | TableEvents[keyof TableEvents][], BaseTableAPI]) {\n const table: BaseTableAPI = args[2];\n this.table = table as ListTable;\n }\n\n bindEvent() {\n //监听document全局的keydown事件 捕获阶段监听 可以及时阻止事件传播和默认行为\n document.addEventListener('keydown', this.handleKeyDown.bind(this), true);\n // this.table.on('selected_cell', () => {\n // this.updateHighlight();\n // });\n\n // this.table.on('selected_clear', () => {\n // this.clearHighlight();\n // });\n\n // this.table.on('mousemove_table', () => {\n // if (this.table.stateManager.select.selecting) {\n // this.updateHighlight();\n // }\n // });\n }\n handleKeyDown(event: KeyboardEvent) {\n // this.pluginOptions?.keyDown_before?.(event);\n if (this.table.editorManager && this.isExcelShortcutKey(event)) {\n const eventKey = event.key.toLowerCase() as ExcelEditCellKeyboardResponse;\n //判断是键盘触发编辑单元格的情况下,那么在编辑状态中切换方向需要选中下一个继续编辑\n if (this.table.editorManager.editingEditor && this.table.editorManager.beginTriggerEditCellMode === 'keydown') {\n const { col, row } = this.table.editorManager.editCell;\n this.table.editorManager.completeEdit();\n this.table.getElement().focus();\n if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {\n //有这些配合键,则不进行选中下一个单元格的行为 执行vtable内部逻辑\n if (eventKey === ExcelEditCellKeyboardResponse.ENTER) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.TAB) {\n this.table.selectCell(col + 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_LEFT) {\n this.table.selectCell(col - 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_RIGHT) {\n this.table.selectCell(col + 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_DOWN) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_UP) {\n this.table.selectCell(col, row - 1);\n }\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n }\n } else {\n const { col, row } = this.table.stateManager.select.cellPos;\n if (\n this.table.editorManager.editingEditor &&\n (eventKey === ExcelEditCellKeyboardResponse.ENTER || eventKey === ExcelEditCellKeyboardResponse.TAB)\n ) {\n this.table.editorManager.completeEdit();\n this.table.getElement().focus();\n if (eventKey === ExcelEditCellKeyboardResponse.ENTER) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.TAB) {\n this.table.selectCell(col + 1, row);\n }\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n } else if (\n !this.table.editorManager.editingEditor &&\n (eventKey === ExcelEditCellKeyboardResponse.DELETE || eventKey === ExcelEditCellKeyboardResponse.BACKSPACE)\n ) {\n //响应删除键,删除\n const selectCells = this.table.getSelectedCellInfos();\n if (selectCells?.length > 0 && document.activeElement === this.table.getElement()) {\n // 如果选中的是范围,则删除范围内的所有单元格\n deleteSelectRange(selectCells, this.table);\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n }\n }\n }\n }\n // this.pluginOptions?.keyDown_after?.apply(this, [event]);\n }\n // 判断event的keyCode是否是excel的快捷键\n isExcelShortcutKey(event: KeyboardEvent) {\n return this.responseKeyboard.includes(event.key.toLowerCase() as ExcelEditCellKeyboardResponse);\n }\n setResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = responseKeyboard;\n }\n deleteResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = this.responseKeyboard.filter(key => !responseKeyboard.includes(key));\n }\n addResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = [...this.responseKeyboard, ...responseKeyboard];\n }\n release() {\n document.removeEventListener('keydown', this.handleKeyDown, true);\n }\n}\n//将选中单元格的值设置为空\nfunction deleteSelectRange(selectCells: TYPES.CellInfo[][], tableInstance: ListTable) {\n for (let i = 0; i < selectCells.length; i++) {\n for (let j = 0; j < selectCells[i].length; j++) {\n tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, '');\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vtable-plugins",
3
- "version": "1.22.6-alpha.0",
3
+ "version": "1.22.6-alpha.2",
4
4
  "description": "The search util of VTable",
5
5
  "author": {
6
6
  "name": "VisActor",
@@ -42,8 +42,8 @@
42
42
  "@types/file-saver": "2.0.7"
43
43
  },
44
44
  "peerDependencies": {
45
- "@visactor/vtable-gantt": "1.22.6-alpha.0",
46
- "@visactor/vtable": "1.22.6-alpha.0"
45
+ "@visactor/vtable": "1.22.6-alpha.2",
46
+ "@visactor/vtable-gantt": "1.22.6-alpha.2"
47
47
  },
48
48
  "peerDependenciesMeta": {
49
49
  "@visactor/vtable-gantt": {
@@ -53,9 +53,9 @@
53
53
  "devDependencies": {
54
54
  "cross-env": "^7.0.3",
55
55
  "increase-memory-limit": "^1.0.7",
56
- "@visactor/vtable": "1.22.6-alpha.0",
57
- "@visactor/vtable-editors": "1.22.6-alpha.0",
58
- "@visactor/vtable-gantt": "1.22.6-alpha.0",
56
+ "@visactor/vtable": "1.22.6-alpha.2",
57
+ "@visactor/vtable-editors": "1.22.6-alpha.2",
58
+ "@visactor/vtable-gantt": "1.22.6-alpha.2",
59
59
  "@visactor/vchart": "2.0.8-alpha.5",
60
60
  "@rushstack/eslint-patch": "~1.1.4",
61
61
  "react": "^18.0.0",
@@ -99,8 +99,8 @@
99
99
  "rollup-plugin-node-resolve": "5.2.0",
100
100
  "@types/lodash": "4.14.182",
101
101
  "@internal/bundler": "0.0.1",
102
- "@internal/ts-config": "0.0.1",
103
- "@internal/eslint-config": "0.0.1"
102
+ "@internal/eslint-config": "0.0.1",
103
+ "@internal/ts-config": "0.0.1"
104
104
  },
105
105
  "scripts": {
106
106
  "demo": "vite ./demo",