@visactor/vtable-plugins 1.20.0-alpha.3 → 1.20.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/add-row-column.js +8 -7
- package/cjs/add-row-column.js.map +1 -1
- package/cjs/contextmenu/styles.js +2 -1
- package/cjs/filter/filter.js +1 -2
- package/cjs/table-export/excel/index.js +1 -0
- package/cjs/table-export/excel/style.js +0 -1
- package/dist/vtable-plugins.js +4 -6
- package/dist/vtable-plugins.min.js +1 -1
- package/es/add-row-column.js +8 -7
- package/es/add-row-column.js.map +1 -1
- package/es/contextmenu/styles.js +2 -1
- package/es/filter/filter.js +1 -2
- package/es/table-export/excel/index.js +2 -1
- package/es/table-export/excel/style.js +1 -2
- package/package.json +8 -8
|
@@ -88,4 +88,4 @@ var EK=d,AK=wq,kK=kX,RK=function(t){if(!(this instanceof RK))return new RK(t);"o
|
|
|
88
88
|
* Copyright (c) 2011-2017 KARASZI Istvan <github@spam.raszi.hu>
|
|
89
89
|
*
|
|
90
90
|
* MIT Licensed
|
|
91
|
-
*/!function(t){const e=n,i=p,s=h,o=r,a={fs:e.constants,os:i.constants},l="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",u=/XXXXXX/,c=3,d=(a.O_CREAT||a.fs.O_CREAT)|(a.O_EXCL||a.fs.O_EXCL)|(a.O_RDWR||a.fs.O_RDWR),f="win32"===i.platform(),m=a.EBADF||a.os.errno.EBADF,g=a.ENOENT||a.os.errno.ENOENT,y=[],b=e.rmdirSync.bind(e);let v=!1;function _(t,r){return e.rm(t,{recursive:!0},r)}function w(t){return e.rmSync(t,{recursive:!0})}function x(t,r){const n=N(t,r),s=n[0],o=n[1];!function(t,r){!function(t,r){e.realpath(t&&t.tmpdir||i.tmpdir(),r)}(t,(function(e,n){if(e)return r(e);t.tmpdir=n;try{I(t)}catch(e){return r(e)}P("dir",t.dir,n,(function(e,i){if(e)return r(e);t.dir=O(i)?"":i,P("template",t.template,n,(function(e,n){if(e)return r(e);t.template=n,r(null,t)}))}))}))}(s,(function(t,r){if(t)return o(t);let n=r.tries;!function t(){try{const i=M(r);e.stat(i,(function(e){if(!e)return n-- >0?t():o(new Error("Could not get a unique tmp filename, max tries reached "+i));o(null,i)}))}catch(t){o(t)}}()}))}function S(t){const r=function(t){const e=t.tmpdir=D(t);I(t);const r=B("dir",t.dir,e);return t.dir=O(r)?"":r,t.template=B("template",t.template,e),t}(N(t)[0]);let n=r.tries;do{const t=M(r);try{e.statSync(t)}catch(e){return t}}while(n-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function C(t,r){const n=function(t){if(t&&!L(t))return r(t);r()};0<=t[0]?e.close(t[0],(function(){e.unlink(t[1],n)})):e.unlink(t[1],n)}function T(t){let r=null;try{0<=t[0]&&e.closeSync(t[0])}catch(t){if(!function(t){return F(t,-m,"EBADF")}(t)&&!L(t))throw t}finally{try{e.unlinkSync(t[1])}catch(t){L(t)||(r=t)}}if(null!==r)throw r}function E(t,e,r,n){const i=k(T,[e,t],n),s=k(C,[e,t],n,i);return r.keep||y.unshift(i),n?i:s}function A(t,r,n){const i=r.unsafeCleanup?_:e.rmdir.bind(e),s=k(r.unsafeCleanup?w:b,t,n),o=k(i,t,n,s);return r.keep||y.unshift(s),n?s:o}function k(t,e,r,n){let i=!1;return function s(o){if(!i){const a=n||s,l=y.indexOf(a);return l>=0&&y.splice(l,1),i=!0,r||t===b||t===w?t(e):t(e,o||function(){})}}}function R(t){let e=[],r=null;try{r=o.randomBytes(t)}catch(e){r=o.pseudoRandomBytes(t)}for(let n=0;n<t;n++)e.push(l[r[n]%l.length]);return e.join("")}function O(t){return void 0===t}function N(t,e){if("function"==typeof t)return[{},t];if(O(t))return[{},e];const r={};for(const e of Object.getOwnPropertyNames(t))r[e]=t[e];return[r,e]}function M(t){const e=t.tmpdir;if(!O(t.name))return s.join(e,t.dir,t.name);if(!O(t.template))return s.join(e,t.dir,t.template).replace(u,R(6));const r=[t.prefix?t.prefix:"tmp","-",process.pid,"-",R(12),t.postfix?"-"+t.postfix:""].join("");return s.join(e,t.dir,r)}function I(t){if(!O(t.name)){const e=t.name;if(s.isAbsolute(e))throw new Error(`name option must not contain an absolute path, found "${e}".`);const r=s.basename(e);if(".."===r||"."===r||r!==e)throw new Error(`name option must not contain a path, found "${e}".`)}if(!O(t.template)&&!t.template.match(u))throw new Error(`Invalid template, found "${t.template}".`);if(!O(t.tries)&&isNaN(t.tries)||t.tries<0)throw new Error(`Invalid tries, found "${t.tries}".`);t.tries=O(t.name)?t.tries||c:1,t.keep=!!t.keep,t.detachDescriptor=!!t.detachDescriptor,t.discardDescriptor=!!t.discardDescriptor,t.unsafeCleanup=!!t.unsafeCleanup,t.prefix=O(t.prefix)?"":t.prefix,t.postfix=O(t.postfix)?"":t.postfix}function P(t,r,n,i){if(O(r))return i(null);!function(t,r,n){const i=s.isAbsolute(t)?t:s.join(r,t);e.stat(i,(function(t){t?e.realpath(s.dirname(i),(function(t,e){if(t)return n(t);n(null,s.join(e,s.basename(i)))})):e.realpath(s,n)}))}(r,n,(function(e,r){if(e)return i(e);const o=s.relative(n,r);if(!r.startsWith(n))return i(new Error(`${t} option must be relative to "${n}", found "${o}".`));i(null,o)}))}function B(t,r,n){if(O(r))return;const i=function(t,r){const n=s.isAbsolute(t)?t:s.join(r,t);try{return e.statSync(n),e.realpathSync(n)}catch(t){const r=e.realpathSync(s.dirname(n));return s.join(r,s.basename(n))}}(r,n),o=s.relative(n,i);if(!i.startsWith(n))throw new Error(`${t} option must be relative to "${n}", found "${o}".`);return o}function L(t){return F(t,-g,"ENOENT")}function F(t,e,r){return f?t.code===r:t.code===r&&t.errno===e}function D(t){return e.realpathSync(t&&t.tmpdir||i.tmpdir())}process.addListener("exit",(function(){if(v)for(;y.length;)try{y[0]()}catch(t){}})),Object.defineProperty(t.exports,"tmpdir",{enumerable:!0,configurable:!1,get:function(){return D()}}),t.exports.dir=function(t,r){const n=N(t,r),i=n[0],s=n[1];x(i,(function(t,r){if(t)return s(t);e.mkdir(r,i.mode||448,(function(t){if(t)return s(t);s(null,r,A(r,i,!1))}))}))},t.exports.dirSync=function(t){const r=N(t)[0],n=S(r);return e.mkdirSync(n,r.mode||448),{name:n,removeCallback:A(n,r,!0)}},t.exports.file=function(t,r){const n=N(t,r),i=n[0],s=n[1];x(i,(function(t,r){if(t)return s(t);e.open(r,d,i.mode||384,(function(t,n){if(t)return s(t);if(i.discardDescriptor)return e.close(n,(function(t){return s(t,r,void 0,E(r,-1,i,!1))}));{const t=i.discardDescriptor||i.detachDescriptor;s(null,r,n,E(r,t?-1:n,i,!1))}}))}))},t.exports.fileSync=function(t){const r=N(t)[0],n=r.discardDescriptor||r.detachDescriptor,i=S(r);let s=e.openSync(i,d,r.mode||384);return r.discardDescriptor&&(e.closeSync(s),s=void 0),{name:i,fd:s,removeCallback:E(i,n?-1:s,r,!0)}},t.exports.tmpName=x,t.exports.tmpNameSync=S,t.exports.setGracefulCleanup=function(){v=!0}}(g2);var y2=g2.exports;function b2(t,e){return new Promise((r=>{let n=!1;const i=()=>{n||(n=!0,t.removeListener(e,i),r())};t.addListener(e,i)}))}const{EventEmitter:v2}=s,_2=AE,w2=hg,x2=cT,S2=dg,C2=fg,T2=Pg,E2=Dg;let A2=class extends v2{constructor({workbook:t,id:e,iterator:r,options:n}){super(),this.workbook=t,this.id=e,this.iterator=r,this.options=n||{},this.name=`Sheet${this.id}`,this._columns=null,this._keys={},this._dimensions=new C2}destroy(){throw new Error("Invalid Operation: destroy")}get dimensions(){return this._dimensions}get columns(){return this._columns}getColumn(t){if("string"==typeof t){const e=this._keys[t];if(e)return e;t=S2.l2n(t)}if(this._columns||(this._columns=[]),t>this._columns.length){let e=this._columns.length+1;for(;e<=t;)this._columns.push(new E2(this,e++))}return this._columns[t-1]}getColumnKey(t){return this._keys[t]}setColumnKey(t,e){this._keys[t]=e}deleteColumnKey(t){delete this._keys[t]}eachColumnKey(t){w2.each(this._keys,t)}async read(){try{for await(const t of this.parse())for(const{eventType:e,value:r}of t)this.emit(e,r);this.emit("finished")}catch(t){this.emit("error",t)}}async*[Symbol.asyncIterator](){for await(const t of this.parse())for(const{eventType:e,value:r}of t)"row"===e&&(yield r)}async*parse(){const{iterator:t,options:e}=this;let r=!1,n=!1,i=null;if("emit"===e.worksheets)r=!0;switch(e.hyperlinks){case"emit":n=!0;break;case"cache":this.hyperlinks=i={}}if(!r&&!n&&!i)return;const{sharedStrings:s,styles:o,properties:a}=this.workbook;let l=!1,h=!1,u=!1,c=null,d=null,p=null,f=null;for await(const e of _2(t)){const t=[];for(const{eventType:m,value:g}of e)if("opentag"===m){const e=g;if(r)switch(e.name){case"cols":l=!0,c=[];break;case"sheetData":h=!0;break;case"col":l&&c.push({min:parseInt(e.attributes.min,10),max:parseInt(e.attributes.max,10),width:parseFloat(e.attributes.width),styleId:parseInt(e.attributes.style||"0",10)});break;case"row":if(h){const t=parseInt(e.attributes.r,10);if(d=new T2(this,t),e.attributes.ht&&(d.height=parseFloat(e.attributes.ht)),e.attributes.s){const t=parseInt(e.attributes.s,10),r=o.getStyleModel(t);r&&(d.style=r)}}break;case"c":d&&(p={ref:e.attributes.r,s:parseInt(e.attributes.s,10),t:e.attributes.t});break;case"f":p&&(f=p.f={text:""});break;case"v":case"is":case"t":p&&(f=p.v={text:""})}if(n||i)switch(e.name){case"hyperlinks":u=!0;break;case"hyperlink":if(u){const r={ref:e.attributes.ref,rId:e.attributes["r:id"]};n?t.push({eventType:"hyperlink",value:r}):i[r.ref]=r}}}else if("text"===m)r&&f&&(f.text+=g);else if("closetag"===m){const e=g;if(r)switch(e.name){case"cols":l=!1,this._columns=E2.fromModel(c);break;case"sheetData":h=!1;break;case"row":this._dimensions.expandRow(d),t.push({eventType:"row",value:d}),d=null;break;case"c":if(d&&p){const t=S2.decodeAddress(p.ref),e=d.getCell(t.col);if(p.s){const t=o.getStyleModel(p.s);t&&(e.style=t)}if(p.f){const t={formula:p.f.text};p.v&&("str"===p.t?t.result=x2.xmlDecode(p.v.text):t.result=parseFloat(p.v.text)),e.value=t}else if(p.v)switch(p.t){case"s":{const t=parseInt(p.v.text,10);e.value=s?s[t]:{sharedString:t};break}case"inlineStr":case"str":e.value=x2.xmlDecode(p.v.text);break;case"e":e.value={error:p.v.text};break;case"b":e.value=0!==parseInt(p.v.text,10);break;default:x2.isDateFmt(e.numFmt)?e.value=x2.excelToDate(parseFloat(p.v.text),a.model&&a.model.date1904):e.value=parseFloat(p.v.text)}if(i){const t=i[p.ref];t&&(e.text=e.value,e.value=void 0,e.hyperlink=t)}p=null}}if((n||i)&&"hyperlinks"===e.name)u=!1}t.length>0&&(yield t)}}};var k2=A2;const{EventEmitter:R2}=s,O2=AE,N2=mg,M2=CR;var I2=class extends R2{constructor({workbook:t,id:e,iterator:r,options:n}){super(),this.workbook=t,this.id=e,this.iterator=r,this.options=n}get count(){return this.hyperlinks&&this.hyperlinks.length||0}each(t){return this.hyperlinks.forEach(t)}async read(){const{iterator:t,options:e}=this;let r=!1,n=null;switch(e.hyperlinks){case"emit":r=!0;break;case"cache":this.hyperlinks=n={}}if(r||n)try{for await(const e of O2(t))for(const{eventType:t,value:i}of e)if("opentag"===t){const t=i;if("Relationship"===t.name){const e=t.attributes.Id;if(t.attributes.Type===M2.Hyperlink){const i={type:N2.RelationshipType.Styles,rId:e,target:t.attributes.Target,targetMode:t.attributes.TargetMode};r?this.emit("hyperlink",i):n[i.rId]=i}}}this.emit("finished")}catch(t){this.emit("error",t)}else this.emit("finished")}};const P2=n,{EventEmitter:B2}=s,{PassThrough:L2,Readable:F2}=aT,D2=i,j2=HZ,z2=y2,U2=async function*(t){const e=[];let r;t.on("data",(t=>e.push(t)));const n=new Promise((t=>r=t));let i=!1;t.on("end",(()=>{i=!0,r()}));let s=!1;for(t.on("error",(t=>{s=t,r()}));!i||e.length>0;){if(0===e.length)t.resume(),await Promise.race([b2(t,"data"),n]);else{t.pause();const r=e.shift();yield r}if(s)throw s}r()},H2=AE,W2=JA,$2=SR,V2=Bk,G2=k2,X2=I2;z2.setGracefulCleanup();class Y2 extends B2{constructor(t,e={}){super(),this.input=t,this.options={worksheets:"emit",sharedStrings:"cache",hyperlinks:"ignore",styles:"ignore",entries:"ignore",...e},this.styles=new W2,this.styles.init()}_getStream(t){if(t instanceof D2.Readable||t instanceof F2)return t;if("string"==typeof t)return P2.createReadStream(t);throw new Error(`Could not recognise input: ${t}`)}async read(t,e){try{for await(const{eventType:r,value:n}of this.parse(t,e))switch(r){case"shared-strings":case"hyperlinks":this.emit(r,n);break;case"worksheet":this.emit(r,n),await n.read()}this.emit("end"),this.emit("finished")}catch(t){this.emit("error",t)}}async*[Symbol.asyncIterator](){for await(const{eventType:t,value:e}of this.parse())"worksheet"===t&&(yield e)}async*parse(t,e){e&&(this.options=e);const r=this.stream=this._getStream(t||this.input),n=j2.Parse({forceStream:!0});r.pipe(n);const i=[];for await(const t of U2(n)){let e,r;switch(t.path){case"_rels/.rels":break;case"xl/_rels/workbook.xml.rels":await this._parseRels(t);break;case"xl/workbook.xml":await this._parseWorkbook(t);break;case"xl/sharedStrings.xml":yield*this._parseSharedStrings(t);break;case"xl/styles.xml":await this._parseStyles(t);break;default:t.path.match(/xl\/worksheets\/sheet\d+[.]xml/)?(e=t.path.match(/xl\/worksheets\/sheet(\d+)[.]xml/),r=e[1],this.sharedStrings&&this.workbookRels?yield*this._parseWorksheet(U2(t),r):await new Promise(((e,n)=>{z2.file(((s,o,a,l)=>{if(s)return n(s);i.push({sheetNo:r,path:o,tempFileCleanupCallback:l});const h=P2.createWriteStream(o);return h.on("error",n),t.pipe(h),h.on("finish",(()=>e()))}))}))):t.path.match(/xl\/worksheets\/_rels\/sheet\d+[.]xml.rels/)&&(e=t.path.match(/xl\/worksheets\/_rels\/sheet(\d+)[.]xml.rels/),r=e[1],yield*this._parseHyperlinks(U2(t),r))}t.autodrain()}for(const{sheetNo:t,path:e,tempFileCleanupCallback:r}of i){let n=P2.createReadStream(e);n[Symbol.asyncIterator]||(n=n.pipe(new L2)),yield*this._parseWorksheet(n,t),r()}}_emitEntry(t){"emit"===this.options.entries&&this.emit("entry",t)}async _parseRels(t){const e=new V2;this.workbookRels=await e.parseStream(U2(t))}async _parseWorkbook(t){this._emitEntry({type:"workbook"});const e=new $2;await e.parseStream(U2(t)),this.properties=e.map.workbookPr,this.model=e.model}async*_parseSharedStrings(t){switch(this._emitEntry({type:"shared-strings"}),this.options.sharedStrings){case"cache":this.sharedStrings=[];break;case"emit":break;default:return}let e=null,r=[],n=0,i=null;for await(const s of H2(U2(t)))for(const{eventType:t,value:o}of s)if("opentag"===t){const t=o;switch(t.name){case"b":i=i||{},i.bold=!0;break;case"charset":i=i||{},i.charset=parseInt(t.attributes.charset,10);break;case"color":i=i||{},i.color={},t.attributes.rgb&&(i.color.argb=t.attributes.argb),t.attributes.val&&(i.color.argb=t.attributes.val),t.attributes.theme&&(i.color.theme=t.attributes.theme);break;case"family":i=i||{},i.family=parseInt(t.attributes.val,10);break;case"i":i=i||{},i.italic=!0;break;case"outline":i=i||{},i.outline=!0;break;case"rFont":i=i||{},i.name=t.value;break;case"si":i=null,r=[],e=null;break;case"sz":i=i||{},i.size=parseInt(t.attributes.val,10);break;case"strike":break;case"t":e=null;break;case"u":i=i||{},i.underline=!0;break;case"vertAlign":i=i||{},i.vertAlign=t.attributes.val}}else if("text"===t)e=e?e+o:o;else if("closetag"===t){switch(o.name){case"r":r.push({font:i,text:e}),i=null,e=null;break;case"si":"cache"===this.options.sharedStrings?this.sharedStrings.push(r.length?{richText:r}:e):"emit"===this.options.sharedStrings&&(yield{index:n++,text:r.length?{richText:r}:e}),r=[],i=null,e=null}}}async _parseStyles(t){this._emitEntry({type:"styles"}),"cache"===this.options.styles&&(this.styles=new W2,await this.styles.parseStream(U2(t)))}*_parseWorksheet(t,e){this._emitEntry({type:"worksheet",id:e});const r=new G2({workbook:this,id:e,iterator:t,options:this.options}),n=(this.workbookRels||[]).find((t=>t.Target===`worksheets/sheet${e}.xml`)),i=n&&(this.model.sheets||[]).find((t=>t.rId===n.Id));i&&(r.id=i.id,r.name=i.name,r.state=i.state),"emit"===this.options.worksheets&&(yield{eventType:"worksheet",value:r})}*_parseHyperlinks(t,e){this._emitEntry({type:"hyperlinks",id:e});const r=new X2({workbook:this,id:e,iterator:t,options:this.options});"emit"===this.options.hyperlinks&&(yield{eventType:"hyperlinks",value:r})}}Y2.Options={worksheets:["emit","ignore"],sharedStrings:["cache","emit","ignore"],hyperlinks:["cache","emit","ignore"],styles:["cache","ignore"],entries:["emit","ignore"]};const q2={Workbook:rj,ModelContainer:ij,stream:{xlsx:{WorkbookWriter:UZ,WorkbookReader:Y2}}};Object.assign(q2,mg);var K2=q2;if(parseInt(process.versions.node.split(".")[0],10)<10)throw new Error("For node versions older than 10, please use the ES5 Import: https://github.com/exceljs/exceljs#es5-imports");var Z2,Q2,J2=pt(K2);class t3{id="excel-import-plugin";name="ExcelImportPlugin";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED];options;_tableInstance=null;constructor(t){this.options={autoTable:!0,autoColumns:!0,delimiter:",",exportData:!1,batchSize:1e3,enableBatchProcessing:!0,asyncDelay:5,...t},t?.id&&(this.id=t.id)}run(...t){const e=t[2];this._tableInstance=e,this._tableInstance.importFile=()=>{this.import("file")}}release(){this._tableInstance=null}async importFile(){return this.import("file")}async import(t,e,r){const n={...this.options,...r};if("file"===t)return this._importFromFileDialog(n);if("string"==typeof e)return this._importFromString(t,e,n);if(Array.isArray(e)||"object"==typeof e){if("json"!==t)throw new Error("只有JSON格式支持从对象导入");return this._importFromData("json",e,n)}throw new Error("Invalid import source")}async _importFromFileDialog(t){return new Promise(((e,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,t);t.autoTable&&this._tableInstance&&(t.autoColumns&&this._tableInstance.updateOption(Object.assign({},this._tableInstance.options,{columns:o.columns})),this._tableInstance.setRecords(o.records)),n.value="",document.body.removeChild(n),e(o)}catch(t){document.body.removeChild(n),r(t)}})),n.click()}))}async _importFromString(t,e,r){let n;switch(t){case"csv":n=await this._parseCSVString(e,r);break;case"json":n=await this._parseJSONString(e,r);break;case"html":n=await this._parseHTMLString(e,r);break;default:throw new Error(`不支持的导入类型: ${t}`)}return r.autoTable&&this._tableInstance&&(r.autoColumns&&this._tableInstance.updateOption({columns:n.columns,plugins:[this]}),this._tableInstance.setRecords(n.records)),n}async _importFromData(t,e,r){let n;if("json"!==t)throw new Error(`不支持的数据类型: ${t}`);return n=await this._parseJSONData(e,r),r.autoTable&&this._tableInstance&&(r.autoColumns&&this._tableInstance.updateOption({columns:n.columns,plugins:[this]}),this._tableInstance.setRecords(n.records)),n}async _parseFile(t,e){const r={...this.options,...e},n=this._getFileExtension(t.name).toLowerCase();switch(n){case"xlsx":case"xls":return await this._parseExcelFile(t,r);case"csv":return await this._parseCsvFile(t,r);case"json":return await this._parseJsonFile(t,r);case"html":case"htm":return await this._parseHtmlFile(t,r);default:throw new Error(`不支持的文件类型: ${n}`)}}_getFileExtension(t){const e=t.split(".");return e.length>1?e[e.length-1]:""}async _parseExcelFile(t,e){const r={...this.options,...e};return await t3.importExcelToVTableData(t,r)}async _parseCsvFile(t,e){const r={...this.options,...e},n=await t.text();return this._parseCSVString(n,r)}async _parseJsonFile(t,e){const r={...this.options,...e},n=await t.text();return this._parseJSONString(n,r)}async _parseHtmlFile(t,e){const r={...this.options,...e},n=await t.text();return this._parseHTMLString(n,r)}_buildColumnsFromHeaders(t){return 1===t.length?t[0].map(((t,e)=>({field:`col${e}`,title:t||`列${e+1}`,cellType:"text",headerType:"text"}))):t3.buildColumns(t)}static async importExcelToVTableData(t,e){const r=new J2.Workbook;await r.xlsx.load(await t.arrayBuffer());const n=r.worksheets[0];if(!n)throw new Error("Excel 文件无有效工作表");const i=e?.headerRowCount??this.detectHeaderRowCount(n),s=[];for(let t=1;t<=i;t++){const e=n.getRow(t);s.push(Array.prototype.slice.call(e.values,1))}const o=t3.buildColumns(s),a=[],l=[];n.eachRow(((t,e)=>{if(e<=i)return;const r=Array.prototype.slice.call(t.values,1);l.push(r)}));const h=e?.batchSize||1e3;if(!1!==e?.enableBatchProcessing&&l.length>h)for(let t=0;t<l.length;t+=h){const r=l.slice(t,t+h).map((t=>{const e={};return t.forEach(((t,r)=>{e[`col${r}`]=t})),e}));a.push(...r),t+h<l.length&&await new Promise((t=>setTimeout(t,e?.asyncDelay||5)))}else l.forEach((t=>{const e={};t.forEach(((t,r)=>{e[`col${r}`]=t})),a.push(e)}));if(e?.exportData){const t=t3._generateJavaScriptExport(o,a),e=new Blob([t],{type:"text/javascript"}),r=URL.createObjectURL(e),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(t){let e=1,r=1;for(;;){const n=t.getRow(e),i=Array.prototype.slice.call(n.values,1);let s=!1;for(let t=1;t<i.length;t++)if(void 0!==i[t]&&""!==i[t]&&i[t]===i[t-1]){s=!0;break}if(!s)break;r++,e++}return r}static buildColumns(t,e=0,r,n=0){const i=t[n],s=[];r=r??i.length;let o=e;for(;o<r;){const e=String(i[o]||`列${o+1}`);let a=1;for(;o+a<r&&i[o+a]===e;)a++;if(n<t.length-1){const r=t3.buildColumns(t,o,o+a,n+1);1===r.length?s.push(r[0]):s.push({title:e,columns:r,hideColumnsSubHeader:!1})}else s.push({field:`col${o}`,title:e,cellType:"text",headerType:"text"});o+=a}return s}async _parseCSVString(t,e){const r=t.split("\n").filter((t=>t.trim()));if(0===r.length)throw new Error("CSV文件为空");const n=e.delimiter||",",i=t=>t.split(n).map((t=>t.trim().replace(/^"|"$/g,""))),s=r.slice(0,1).map(i),o=r.slice(1),a=this._buildColumnsFromHeaders(s),l=[];return await this._processBatchRecords(o,e,(async t=>{const e=t.map((t=>{const e=i(t),r={};return e.forEach(((t,e)=>{r[`col${e}`]=t||""})),r}));l.push(...e)})),e.exportData&&this._exportToJS(a,l),{columns:a,records:l}}async _parseJSONString(t,e){let r;try{r=JSON.parse(t)}catch(t){throw new Error("JSON文件格式错误")}const n=await this._parseJSONData(r,e);return e.exportData&&this._exportToJS(n.columns,n.records),n}async _parseHTMLString(t,e){const r=(new DOMParser).parseFromString(t,"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((t=>Array.from(t.querySelectorAll("th, td")).map((t=>t.textContent?.trim()||"")))),s=n.slice(1),o=this._buildColumnsFromHeaders(i),a=[];return await this._processBatchRecords(s,e,(async t=>{const e=t.map((t=>{const e=Array.from(t.querySelectorAll("td")).map((t=>t.textContent?.trim()||"")),r={};return e.forEach(((t,e)=>{r[`col${e}`]=t||""})),r}));a.push(...e)})),e.exportData&&this._exportToJS(o,a),{columns:o,records:a}}async _parseJSONData(t,e){let r;if("object"==typeof t&&!Array.isArray(t)&&t&&"columns"in t&&"records"in t){const n=t,i=[];await this._processBatchRecords(n.records,e,(async t=>{const e=t.map((t=>({...t})));i.push(...e)})),r={columns:n.columns,records:i}}else{if(!(Array.isArray(t)&&t.length>0))throw new Error("不支持的JSON格式");{const n=t[0],i=Object.keys(n).map((t=>({field:t,title:t,cellType:"text",headerType:"text"}))),s=[];await this._processBatchRecords(t,e,(async t=>{const e=t.map((t=>({...t})));s.push(...e)})),r={columns:i,records:s}}}return e.exportData&&this._exportToJS(r.columns,r.records),r}static _generateJavaScriptExport(t,e){const r=(t,e="")=>{if(null==t)return"null";if("string"==typeof t)return`'${t.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`;if("number"==typeof t||"boolean"==typeof t)return String(t);if(Array.isArray(t)){if(0===t.length)return"[]";return`[${t.map((t=>r(t,e+" "))).join(", ")}]`}if("object"==typeof t){const n=Object.entries(t).map((([t,n])=>`${e} ${t}: ${r(n,e+" ")}`)).join(",\n");return`{\n${n}\n${e}}`}return String(t)},n=(t,e=" ")=>{const i=Object.entries(t).map((([t,i])=>{if("columns"===t&&Array.isArray(i)){const r=i.map((t=>n(t,e+" "))).join(",\n");return`${e} ${t}: [\n${r}\n${e} ]`}return`${e} ${t}: ${r(i)}`})).join(",\n");return`${e}{\n${i}\n${e}}`},i=t.map((t=>n(t))).join(",\n"),s=e.map((t=>{const e=Object.entries(t).map((([t,e])=>` ${t}: ${r(e)}`)).join(",\n");return` {\n${e}\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(t,e){const r=t3._generateJavaScriptExport(t,e),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(t,e,r){if(!e.enableBatchProcessing||t.length<=(e.batchSize||1e3))return void await r(t,0);const n=e.batchSize||1e3,i=Math.ceil(t.length/n);for(let s=0;s<i;s++){const o=s*n,a=Math.min(o+n,t.length),l=t.slice(o,a);await r(l,s),s<i-1&&await new Promise((t=>setTimeout(t,e.asyncDelay||5)))}}}class e3{constructor(){}handleCopy(t){t.eventManager.handleCopy(new KeyboardEvent("copy"))}handleCut(t){t.eventManager.handleCut(new KeyboardEvent("cut"))}handlePaste(t){t.eventManager.handlePaste(new KeyboardEvent("paste"))}handleInsertRowAbove(t,e,r=1){if(void 0!==e&&"function"==typeof t.addRecord)for(let n=0;n<r;n++)t.addRecord([],e-1)}handleInsertRowBelow(t,e,r=1){if(void 0!==e&&"function"==typeof t.addRecord)for(let n=0;n<r;n++)t.addRecord([],e+n)}handleInsertColumnLeft(t,e,r=1){if(void 0!==e&&"function"==typeof t.addColumn)for(let n=0;n<r;n++)t.addColumn({field:e},e,!0)}handleInsertColumnRight(t,e,r=1){if(void 0!==e&&"function"==typeof t.addColumn)for(let n=0;n<r;n++)t.addColumn({field:e+1},e+1,!0)}handleDeleteRow(t,e){if(void 0!==e&&"function"==typeof t.deleteRecords){const e=t.stateManager.select.ranges,r=[];for(let t=0;t<e.length;t++){const n=e[t];for(let t=n.start.row;t<=n.end.row;t++)r.includes(t)||r.push(t)}r.sort(((t,e)=>e-t));for(let e=0;e<r.length;e++){const n=t.getRecordIndexByCell(0,r[e]);t.deleteRecords([n])}}}handleDeleteColumn(t,e){if(void 0!==e&&"function"==typeof t.deleteColumn){const e=t.stateManager.select.ranges,r=[];for(let t=0;t<e.length;t++){const n=e[t];for(let t=n.start.col;t<=n.end.col;t++)r.includes(t)||r.push(t)}r.sort(((t,e)=>e-t));for(let e=0;e<r.length;e++)t.deleteColumn(r[e])}}handleHideColumn(t,e){void 0!==e&&"function"==typeof t.hideColumns&&t.hideColumns([e])}handleSort(t,e){if(void 0!==e&&"function"==typeof t.sort){const r=t.getSortState?t.getSortState():null;let n="asc";r&&r.field===e&&(n="asc"===r.order?"desc":"normal"),t.sort({field:e,order:n})}}handleMergeCells(t){if(1===(t.stateManager.select.ranges?.length??0)&&"function"==typeof t.mergeCells){const{row:e,col:r}=t.stateManager.select.ranges[0].start,{row:n,col:i}=t.stateManager.select.ranges[0].end;if(r===i&&e===n)return;t.mergeCells(Math.min(r,i),Math.min(e,n),Math.max(r,i),Math.max(e,n))}}handleUnmergeCells(t){if(1===(t.stateManager.select.ranges?.length??0)&&"function"==typeof t.unmergeCells){const{row:e,col:r}=t.stateManager.select.ranges[0].start,{row:n,col:i}=t.stateManager.select.ranges[0].end;if(r===i&&e===n)return;t.unmergeCells(Math.min(r,i),Math.min(e,n),Math.max(r,i),Math.max(e,n))}}handleSetProtection(t){}handleFreezeToRow(t,e){void 0!==e&&(t.frozenRowCount=e+1)}handleFreezeToColumn(t,e){void 0!==e&&(t.frozenColCount=e+1)}handleFreezeToRowAndColumn(t,e,r){void 0!==e&&void 0!==r&&(t.frozenRowCount=e+1,t.frozenColCount=r+1)}handleUnfreeze(t){t.frozenRowCount=0,t.frozenColCount=0}release(){}}class r3{filterFuncRule=[];filterValueRule=[];applyFilter(t,e){const{filters:r}=t;this.filterFuncRule=[],this.filterValueRule=[],r.forEach(((t,e)=>{if(t.enable)if("byValue"===t.type)this.filterValueRule.push({filterKey:String(t.field),filteredValues:t.values});else if("byCondition"===t.type){const e=this.createFilterFunction(t);this.filterFuncRule.push({filterFunc:e,fieldId:String(t.field)})}})),e.updateFilterRules([...this.filterFuncRule,...this.filterValueRule])}createFilterFunction(t){const{field:e,operator:r,condition:n}=t;return r&&void 0!==n?t=>{const i=t[e];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(t,e){if("number"==typeof t&&"number"==typeof e)return t===e?0:t>e?1:-1;if("boolean"==typeof t&&"boolean"==typeof e)return t===e?0:-1;const r=String(t).toLowerCase(),n=String(e).toLowerCase();return r===n?0:r>n?1:-1}clearAllFilter(t){this.filterFuncRule=[],this.filterValueRule=[],t.updateFilterRules([])}clearFilter(t,e){this.filterValueRule=this.filterValueRule.filter((t=>t.filterKey!==e)),this.filterFuncRule=this.filterFuncRule.filter((t=>t.fieldId!==e)),t.updateFilterRules([...this.filterFuncRule,...this.filterValueRule])}}t.FilterActionType=void 0,(Z2=t.FilterActionType||(t.FilterActionType={}))[Z2.ADD_FILTER=0]="ADD_FILTER",Z2[Z2.REMOVE_FILTER=1]="REMOVE_FILTER",Z2[Z2.UPDATE_FILTER=2]="UPDATE_FILTER",Z2[Z2.ENABLE_FILTER=3]="ENABLE_FILTER",Z2[Z2.DISABLE_FILTER=4]="DISABLE_FILTER",Z2[Z2.CLEAR_ALL_FILTERS=5]="CLEAR_ALL_FILTERS",Z2[Z2.APPLY_FILTERS=6]="APPLY_FILTERS",t.FilterOperatorCategory=void 0,(Q2=t.FilterOperatorCategory||(t.FilterOperatorCategory={})).ALL="all",Q2.TEXT="text",Q2.NUMBER="number",Q2.COLOR="color",Q2.CHECKBOX="checkbox",Q2.RADIO="radio";class n3{state;engine;listeners=[];table;constructor(t,e){this.state={filters:new Map},this.engine=e,this.table=t}getFilterState(t){return this.state.filters.get(t)}getActiveFilterFields(){const t=[];return this.state.filters.forEach(((e,r)=>{e.enable&&t.push(r)})),t}getAllFilterStates(){return this.state}reapplyCurrentFilters(){this.getActiveFilterFields().length>0&&this.applyFilters()}dispatch(t){this.state=this.reduce(this.state,t),this.shouldApplyFilter(t)&&this.applyFilters(),this.notifyListeners()}subscribe(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter((e=>e!==t))}}notifyListeners(){this.listeners.forEach((t=>t(this.state)))}reduce(e,r){const{type:n,payload:i}=r,s=new Map(e.filters);switch(n){case t.FilterActionType.ADD_FILTER:s.set(i.field,i);break;case t.FilterActionType.REMOVE_FILTER:s.delete(i.field);break;case t.FilterActionType.UPDATE_FILTER:s.set(i.field,{...s.get(i.field),...i});break;case t.FilterActionType.ENABLE_FILTER:s.set(i.field,{...s.get(i.field),enable:!0});break;case t.FilterActionType.DISABLE_FILTER:s.set(i.field,{...s.get(i.field),enable:!1});break;case t.FilterActionType.CLEAR_ALL_FILTERS:s.clear();break;case t.FilterActionType.APPLY_FILTERS:s.set(i.field,{...s.get(i.field),...i,enable:!0})}return{...e,filters:s}}applyFilters(){this.engine.applyFilter(this.state,this.table),this.updateColumnIcons()}updateColumnIcons(){const t=this.table.columns;if(!t)return;const e=this.table.pluginManager.getPluginByName("Filter");if(!e||!e.pluginOptions)return;const r=e.pluginOptions.filterIcon,n=e.pluginOptions.filteringIcon;t.forEach(((t,i)=>{const s=t.field,o=this.state.filters.get(s);!e.shouldEnableFilterForColumn||e.shouldEnableFilterForColumn(i,t)?o&&o.enable?t.headerIcon=n:t.headerIcon=r:t.headerIcon!==r&&t.headerIcon!==n||delete t.headerIcon})),this.table.updateColumns(t)}shouldApplyFilter(e){return[t.FilterActionType.REMOVE_FILTER,t.FilterActionType.ENABLE_FILTER,t.FilterActionType.DISABLE_FILTER,t.FilterActionType.CLEAR_ALL_FILTERS,t.FilterActionType.APPLY_FILTERS].includes(e.type)||e.payload.enable}}const i3={display:"none",position:"absolute",backgroundColor:"white",border:"1px solid #ccc",boxShadow:"0 4px 8px rgba(0,0,0,0.15)",zIndex:"100"},s3={padding:"10px",display:"block"},o3={padding:"5px"},a3={width:"100%",padding:"8px 10px",border:"1px solid #ccc",borderRadius:"4px",fontSize:"14px",boxSizing:"border-box"},l3={maxHeight:"200px",overflowY:"auto",marginTop:"10px"},h3={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 5px"},u3={display:"flex",alignItems:"center",cursor:"pointer",flexGrow:"1",fontWeight:"normal"},c3={marginRight:"10px"},d3={color:"#888",fontSize:"12px"},p3={display:"flex",justifyContent:"space-around",borderBottom:"1px solid #e0e0e0"},f3=t=>({backgroundColor:"transparent",border:"none",flex:"1",padding:"10px 15px",cursor:"pointer",fontSize:"14px",fontWeight:t?"bold":"normal",color:t?"#007bff":"#666",borderBottom:t?"3px solid #007bff":"2px solid transparent"}),m3={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 15px",borderTop:"1px solid #e0e0e0",backgroundColor:"#f8f9fa"},g3=t=>({padding:"6px 12px",border:"1px solid #ccc",borderRadius:"4px",cursor:"pointer",marginLeft:"5px",backgroundColor:t?"#007bff":"white",color:t?"white":"#333",borderColor:t?"#007bff":"#ccc"}),y3={color:"#007bff",textDecoration:"none"},b3={marginBottom:"15px",padding:"10px"},v3={display:"block",marginBottom:"8px",fontWeight:"bold"},_3={width:"100%",padding:"8px",marginBottom:"15px",border:"1px solid #ccc",borderRadius:"4px",boxSizing:"border-box"},w3={display:"flex",alignItems:"center",gap:"8px"},x3={display:"none",padding:"0 5px"};function S3(t,e){Object.entries(e).forEach((([e,r])=>{t.style[e]=r}))}function C3(t,e={},r=[]){const n=document.createElement(t);return Object.entries(e).forEach((([t,e])=>{n.setAttribute(t,e)})),r.forEach((t=>{"string"==typeof t?n.appendChild(document.createTextNode(t)):n.appendChild(t)})),n}class T3{table;filterStateManager;uniqueKeys=new Map;displayToRawValueMap=new Map;selectedField;valueFilterOptionList=new Map;filterByValuePanel;filterByValueSearchInput;selectAllCheckbox;filterItemsContainer;constructor(t,e){this.table=t,this.filterStateManager=e,this.filterStateManager.subscribe((t=>{const e=t.filters.get(this.selectedField);e&&"byValue"===e.type&&this.updateUI(e)}))}updateUI(t){this.syncCheckboxesWithFilterState(t),this.syncSelectAllWithFilterState(t)}setSelectedField(t){this.selectedField=t,this.collectUniqueColumnValues(t)}collectUniqueColumnValues(t){const e=this.filterStateManager.getFilterState(t)?.enable,r=new Map,n=new Map,i=new Map;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}if(e){const e=this.table.internalProps.records,o=e.length;for(let a=0;a<o;a++){let o,l;if(-1!==s){const r=this.table.columnHeaderLevelCount+a;o=e[a][t];const n=this.table.internalProps.layoutMap.getBody(s,r);l=n&&"fieldFormat"in n&&n.fieldFormat&&"function"==typeof n.fieldFormat?n.fieldFormat({[t]:o}):o}null!=o&&(r.set(l,(r.get(l)||0)+1),n.set(o,l),i.set(l,o))}}else{const e=this.table.internalProps.dataSource.length;for(let o=0;o<e;o++){let e,a;if(-1!==s){const t=this.table.columnHeaderLevelCount+o;t<this.table.rowCount&&(e=this.table.getCellOriginValue(s,t),a=this.table.getCellValue(s,t))}else e=this.table.getFieldData(String(t),-1!==s?s:0,this.table.columnHeaderLevelCount+o),a=e;null!=e&&(r.set(a,(r.get(a)||0)+1),n.set(e,a),i.set(a,e))}}this.displayToRawValueMap.set(t,i);const o=Array.from(r.entries()).map((([t,e])=>({value:t,count:e,rawValue:i.get(t)})));this.uniqueKeys.set(t,o)}onValueSelect(e,r,n){const i=this.displayToRawValueMap.get(e),s=i?i.get(r):r,o=this.filterStateManager.getFilterState(e);if(o){const r=n?[...o.values||[],s]:(o.values||[]).filter((t=>t!==s));this.filterStateManager.dispatch({type:t.FilterActionType.UPDATE_FILTER,payload:{field:e,values:r}})}else this.filterStateManager.dispatch({type:t.FilterActionType.ADD_FILTER,payload:{field:e,type:"byValue",values:[s]}})}toggleSelectAll(e,r){const n=this.filterStateManager.getFilterState(e),i=r&&this.uniqueKeys.get(e)?.map((t=>t.rawValue))||[];if(n){const n=r?i:[];this.filterStateManager.dispatch({type:t.FilterActionType.UPDATE_FILTER,payload:{field:e,values:n}})}else this.filterStateManager.dispatch({type:t.FilterActionType.ADD_FILTER,payload:{field:e,type:"byValue",values:i,enable:!0}})}onSearch(t,e){const r=e.toUpperCase().split(" ").filter((t=>t)),n=this.valueFilterOptionList.get(t);for(const t of n){const e=t.id.toUpperCase()||"",n=r.some((t=>e.includes(t)));t.itemContainer.style.display=0===r.length||n?"flex":"none"}}initFilterStateFromTableData(e){const r=this.filterStateManager.getFilterState(e),n=new Set,i=this.displayToRawValueMap.get(e);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}const o=this.table.internalProps.dataSource.length;for(let t=0;t<o;t++){let r,o;if(-1!==s){const e=this.table.columnHeaderLevelCount+t;e<this.table.rowCount&&(r=this.table.getCellValue(s,e),o=i?i.get(r):r)}else r=this.table.getFieldData(String(e),-1!==s?s:0,this.table.columnHeaderLevelCount+t),o=i?i.get(r):r;null!=o&&n.add(o)}const a=!r||!function(t,e){if(!Nu(t)||!Nu(e))return!1;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}(r.values,Array.from(n));a&&(r?this.filterStateManager.dispatch({type:t.FilterActionType.UPDATE_FILTER,payload:{field:e,type:"byValue",values:Array.from(n)}}):this.filterStateManager.dispatch({type:t.FilterActionType.ADD_FILTER,payload:{field:e,type:"byValue",values:Array.from(n)}}))}syncCheckboxesWithFilterState(t){if(!t)return;const e=t.values||[],r=this.displayToRawValueMap.get(t.field),n=this.valueFilterOptionList.get(t.field);n?.forEach((n=>{const i=n.originalValue,s=r?r.get(i):i;n.checkbox.checked=e.some((t=>t===s));const o=this.uniqueKeys.get(t.field)?.find((t=>String(t.value)===n.id))?.count||0;n.countSpan.textContent=String(o),n.itemContainer.style.display=0===o?"none":"flex"}))}syncSelectAllWithFilterState(t){if(!t||!t.values)return this.selectAllCheckbox.checked=!1,void(this.selectAllCheckbox.indeterminate=!1);const e=this.uniqueKeys.get(t.field)?.length||0;0===e||0===t.values.length?(this.selectAllCheckbox.checked=!1,this.selectAllCheckbox.indeterminate=!1):t.values.length===e?(this.selectAllCheckbox.checked=!0,this.selectAllCheckbox.indeterminate=!1):(this.selectAllCheckbox.checked=!1,this.selectAllCheckbox.indeterminate=!0)}applyFilter(e=this.selectedField){const r=this.filterStateManager.getFilterState(e)?.values||[];r.length>0&&r.length<this.uniqueKeys.get(e)?.length?this.filterStateManager.dispatch({type:t.FilterActionType.APPLY_FILTERS,payload:{field:e,type:"byValue",values:r,enable:!0}}):this.filterStateManager.dispatch({type:t.FilterActionType.REMOVE_FILTER,payload:{field:e}})}clearFilter(e){this.filterStateManager.dispatch({type:t.FilterActionType.REMOVE_FILTER,payload:{field:e}}),this.hide()}render(t){this.filterByValuePanel=document.createElement("div"),S3(this.filterByValuePanel,s3);const e=document.createElement("div");S3(e,o3),this.filterByValueSearchInput=document.createElement("input"),this.filterByValueSearchInput.type="text",this.filterByValueSearchInput.placeholder="可使用空格分隔多个关键词",S3(this.filterByValueSearchInput,a3),e.appendChild(this.filterByValueSearchInput);const r=document.createElement("div");S3(r,l3);const n=document.createElement("div");S3(n,h3);const i=document.createElement("label");S3(i,u3),this.selectAllCheckbox=document.createElement("input"),this.selectAllCheckbox.type="checkbox",this.selectAllCheckbox.checked=!0,S3(this.selectAllCheckbox,c3),i.append(this.selectAllCheckbox," 全选"),n.appendChild(i),this.filterItemsContainer=document.createElement("div"),r.append(n,this.filterItemsContainer),this.filterByValuePanel.append(e,r),t.appendChild(this.filterByValuePanel),this.bindEventForFilterByValue()}renderFilterOptions(t){this.filterItemsContainer.innerHTML="",this.valueFilterOptionList.delete(t),this.valueFilterOptionList.set(t,[]);const e=this.filterStateManager.getFilterState(t)?.values||[],r=new Set(e),n=[];this.uniqueKeys.get(t)?.forEach((({value:t,count:e,rawValue:i})=>{const s=document.createElement("div");S3(s,h3);const o=document.createElement("label");S3(o,u3);const a=document.createElement("input");a.type="checkbox",a.value=String(t),a.checked=r.has(i),S3(a,c3);const l=document.createElement("span");l.textContent=String(e),S3(l,d3),o.append(a,` ${t}`),s.append(o,l),this.filterItemsContainer.appendChild(s);const h={id:String(t),originalValue:t,itemContainer:s,checkbox:a,countSpan:l};n.push(h)})),this.valueFilterOptionList.set(t,n)}bindEventForFilterByValue(){this.filterByValuePanel.addEventListener("keyup",(t=>{const e=t.target;if(e instanceof HTMLInputElement&&"text"===e.type){const t=e.value;this.onSearch(this.selectedField,t)}})),this.filterByValuePanel.addEventListener("change",(t=>{const e=t.target;if(e instanceof HTMLInputElement&&"checkbox"===e.type)if(e===this.selectAllCheckbox)this.toggleSelectAll(this.selectedField,this.selectAllCheckbox.checked);else{const t=e,r=t.checked,n=this.valueFilterOptionList.get(this.selectedField)?.find((e=>e.id===t.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"}}class E3{table;filterStateManager;filterByConditionPanel;selectedField;operatorSelect;valueInput;valueInputMax;categorySelect;currentCategory=t.FilterOperatorCategory.ALL;operators=[{value:"equals",label:"等于",category:t.FilterOperatorCategory.ALL},{value:"notEquals",label:"不等于",category:t.FilterOperatorCategory.ALL},{value:"equals",label:"等于",category:t.FilterOperatorCategory.NUMBER},{value:"notEquals",label:"不等于",category:t.FilterOperatorCategory.NUMBER},{value:"greaterThan",label:"大于",category:t.FilterOperatorCategory.NUMBER},{value:"lessThan",label:"小于",category:t.FilterOperatorCategory.NUMBER},{value:"greaterThanOrEqual",label:"大于等于",category:t.FilterOperatorCategory.NUMBER},{value:"lessThanOrEqual",label:"小于等于",category:t.FilterOperatorCategory.NUMBER},{value:"between",label:"介于",category:t.FilterOperatorCategory.NUMBER},{value:"notBetween",label:"不介于",category:t.FilterOperatorCategory.NUMBER},{value:"equals",label:"等于",category:t.FilterOperatorCategory.TEXT},{value:"notEquals",label:"不等于",category:t.FilterOperatorCategory.TEXT},{value:"contains",label:"包含",category:t.FilterOperatorCategory.TEXT},{value:"notContains",label:"不包含",category:t.FilterOperatorCategory.TEXT},{value:"startsWith",label:"开头是",category:t.FilterOperatorCategory.TEXT},{value:"notStartsWith",label:"开头不是",category:t.FilterOperatorCategory.TEXT},{value:"endsWith",label:"结尾是",category:t.FilterOperatorCategory.TEXT},{value:"notEndsWith",label:"结尾不是",category:t.FilterOperatorCategory.TEXT},{value:"equals",label:"等于",category:t.FilterOperatorCategory.COLOR},{value:"notEquals",label:"不等于",category:t.FilterOperatorCategory.COLOR},{value:"isChecked",label:"已选中",category:t.FilterOperatorCategory.CHECKBOX},{value:"isUnchecked",label:"未选中",category:t.FilterOperatorCategory.CHECKBOX},{value:"isChecked",label:"已选中",category:t.FilterOperatorCategory.RADIO},{value:"isUnchecked",label:"未选中",category:t.FilterOperatorCategory.RADIO}];categories=[{value:t.FilterOperatorCategory.ALL,label:"全部"},{value:t.FilterOperatorCategory.TEXT,label:"文本"},{value:t.FilterOperatorCategory.NUMBER,label:"数值"},{value:t.FilterOperatorCategory.COLOR,label:"颜色"},{value:t.FilterOperatorCategory.CHECKBOX,label:"复选框"},{value:t.FilterOperatorCategory.RADIO,label:"单选框"}];constructor(t,e){this.table=t,this.filterStateManager=e}setSelectedField(t){this.selectedField=t,this.updateOperatorOptions(),this.loadCurrentFilterState()}updateOperatorOptions(){if(!this.operatorSelect)return;let e;if(this.operatorSelect.innerHTML="",this.currentCategory===t.FilterOperatorCategory.ALL){const t=new Map;this.operators.forEach((e=>{t.has(e.value)||t.set(e.value,e)})),e=Array.from(t.values())}else e=this.operators.filter((t=>t.category===this.currentCategory));e.forEach((t=>{const e=document.createElement("option");e.value=t.value,e.textContent=t.label,this.operatorSelect.appendChild(e)}))}handleCategoryChange(){this.categorySelect&&(this.currentCategory=this.categorySelect.value,this.updateOperatorOptions(),this.syncUIState())}loadCurrentFilterState(){const t=this.filterStateManager.getFilterState(this.selectedField);t&&"byCondition"===t.type?(t.operator&&this.operatorSelect&&(this.operatorSelect.value=t.operator),void 0!==t.condition&&this.valueInput&&(Array.isArray(t.condition)?(this.valueInput.value=String(t.condition[0]),this.valueInputMax&&(this.valueInputMax.value=String(t.condition[1]))):(this.valueInput.value=String(t.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=t.FilterOperatorCategory.ALL,this.categorySelect&&(this.categorySelect.value=t.FilterOperatorCategory.ALL),this.updateOperatorOptions(),this.syncUIState()}syncUIState(){if(!this.operatorSelect||!this.valueInput)return;const t=this.operatorSelect.value,e=this.valueInput.nextElementSibling;this.isRangeOperator(t)?(this.valueInput.placeholder="最小值",this.valueInputMax&&(this.valueInputMax.style.display="inline-block"),e&&(e.style.display="inline-block")):(this.valueInput.placeholder="请输入筛选值",this.valueInputMax&&(this.valueInputMax.style.display="none"),e&&(e.style.display="none"))}isBooleanOperator(t){return["isChecked","isUnchecked"].includes(t)}isRangeOperator(t){return"between"===t||"notBetween"===t}applyFilter(e=this.selectedField){if(!this.operatorSelect||!this.valueInput)return;const r=this.operatorSelect?.value;let n=this.valueInput?.value;if(this.currentCategory!==t.FilterOperatorCategory.NUMBER||(n=parseFloat(n),!isNaN(n))){if(this.isRangeOperator(r)){const e=n;let r=this.valueInputMax.value.trim();if(this.currentCategory===t.FilterOperatorCategory.NUMBER){const t=parseFloat(r);if(isNaN(t))return;r=t}n=[e,r]}n||!1===n||0===n||this.isBooleanOperator(r)?(this.filterStateManager.dispatch({type:t.FilterActionType.APPLY_FILTERS,payload:{field:e,type:"byCondition",operator:r,condition:n,enable:!0}}),this.hide()):this.clearFilter(e)}}clearFilter(e){this.filterStateManager.dispatch({type:t.FilterActionType.REMOVE_FILTER,payload:{field:e}}),this.hide()}render(t){this.filterByConditionPanel=document.createElement("div"),S3(this.filterByConditionPanel,s3);const e=document.createElement("div");S3(e,b3);const r=C3("label",{},["筛选类型:"]);S3(r,v3),this.categorySelect=C3("select"),S3(this.categorySelect,_3),this.categories.forEach((t=>{const e=document.createElement("option");e.value=t.value,e.textContent=t.label,this.categorySelect.appendChild(e)}));const n=C3("label",{},["筛选条件:"]);S3(n,v3),this.operatorSelect=C3("select"),S3(this.operatorSelect,_3);const i=C3("label",{},["筛选值:"]);S3(i,v3);const s=C3("div");S3(s,w3),this.valueInput=C3("input",{type:"text",placeholder:"请输入筛选值"}),S3(this.valueInput,a3);const o=C3("span",{},["和"]);S3(o,x3),o.style.display="none",this.valueInputMax=C3("input",{type:"text",placeholder:"最大值"}),S3(this.valueInputMax,a3),this.valueInputMax.style.display="none",s.appendChild(this.valueInput),s.appendChild(o),s.appendChild(this.valueInputMax),e.appendChild(r),e.appendChild(this.categorySelect),e.appendChild(n),e.appendChild(this.operatorSelect),e.appendChild(i),e.appendChild(s),this.filterByConditionPanel.appendChild(e),t.appendChild(this.filterByConditionPanel),this.hide(),this.updateOperatorOptions(),this.bindEvents()}bindEvents(){this.valueInput.addEventListener("keypress",(t=>{"Enter"===t.key&&this.applyFilter()})),this.valueInputMax.addEventListener("keypress",(t=>{"Enter"===t.key&&this.applyFilter()})),this.categorySelect.addEventListener("change",(()=>{this.handleCategoryChange()})),this.operatorSelect.addEventListener("change",(()=>{const t=this.operatorSelect.value,e=this.valueInput.nextElementSibling;this.isRangeOperator(t)?(this.valueInput.placeholder="最小值",this.valueInputMax.style.display="inline-block",e.style.display="inline-block"):(this.valueInput.placeholder="请输入筛选值",this.valueInputMax.style.display="none",e.style.display="none")}))}show(){this.filterByConditionPanel&&(this.filterByConditionPanel.style.display="block",this.loadCurrentFilterState())}hide(){this.filterByConditionPanel&&(this.filterByConditionPanel.style.display="none")}}class A3{table;filterStateManager;valueFilter=null;conditionFilter=null;activeTab="byValue";isVisible=!1;selectedField=null;filterModes=[];filterMenu;filterMenuWidth;filterTabByValue;filterTabByCondition;clearFilterOptionLink;cancelFilterButton;applyFilterButton;constructor(t,e){this.table=t,this.filterStateManager=e,this.valueFilter=new T3(this.table,this.filterStateManager),this.conditionFilter=new E3(this.table,this.filterStateManager),this.filterMenuWidth=300}onTabSwitch(t){this.activeTab=t,"byValue"===t?(this.valueFilter.show(),this.conditionFilter.hide()):(this.conditionFilter.show(),this.valueFilter.hide());const e="byValue"===t;S3(this.filterTabByValue,f3(e)),S3(this.filterTabByCondition,f3(!e))}updateSelectedField(t){this.selectedField=t,this.valueFilter&&this.valueFilter.setSelectedField(t),this.conditionFilter&&this.conditionFilter.setSelectedField(t)}applyFilter(t){"byValue"===this.activeTab?this.valueFilter.applyFilter(t):"byCondition"===this.activeTab&&this.conditionFilter.applyFilter(t),this.hide()}clearFilter(t){this.valueFilter&&this.valueFilter.clearFilter(t),this.conditionFilter&&this.conditionFilter.clearFilter(t),this.hide()}render(t){this.filterMenu=document.createElement("div"),S3(this.filterMenu,i3),this.filterMenu.style.width=`${this.filterMenuWidth}px`;const e=document.createElement("div");S3(e,p3),this.filterTabByValue=document.createElement("button"),this.filterTabByValue.innerText="按值筛选",S3(this.filterTabByValue,f3(!0)),this.filterTabByCondition=document.createElement("button"),this.filterTabByCondition.innerText="按条件筛选",S3(this.filterTabByCondition,f3(!1)),e.append(this.filterTabByValue,this.filterTabByCondition);const r=document.createElement("div");S3(r,m3),this.clearFilterOptionLink=document.createElement("a"),this.clearFilterOptionLink.href="#",this.clearFilterOptionLink.innerText="清除筛选",S3(this.clearFilterOptionLink,y3);const n=document.createElement("div");this.cancelFilterButton=document.createElement("button"),this.cancelFilterButton.innerText="取消",S3(this.cancelFilterButton,g3(!1)),this.applyFilterButton=document.createElement("button"),this.applyFilterButton.innerText="确认",S3(this.applyFilterButton,g3(!0)),n.append(this.cancelFilterButton,this.applyFilterButton),r.append(this.clearFilterOptionLink,n),this.filterMenu.append(e),this.valueFilter.render(this.filterMenu),this.conditionFilter.render(this.filterMenu),this.filterMenu.append(r),t.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",(t=>{t.preventDefault(),this.clearFilter(this.selectedField)})),this.applyFilterButton.addEventListener("click",(()=>{this.applyFilter(this.selectedField)})),document.addEventListener("click",(()=>{this.isVisible&&this.hide()})),this.filterMenu.addEventListener("click",(t=>{t.stopPropagation()}))}show(t,e,r){this.filterModes=r,this.filterModes.includes("byValue")?this.filterModes.includes("byCondition")||(this.filterTabByCondition.style.display="none",setTimeout((()=>this.onTabSwitch("byValue")),0)):(this.filterTabByValue.style.display="none",setTimeout((()=>this.onTabSwitch("byCondition")),0));let n=0,i=0;const s=this.table.canvas.getBoundingClientRect(),o=this.table.getMergeCellRect(t,e);o.right<this.filterMenuWidth?(n=o.left+s.left,i=o.bottom+s.top):(n=o.right+s.left-this.filterMenuWidth,i=o.bottom+s.top),this.filterMenu.style.display="block",this.filterMenu.style.left=`${n}px`,this.filterMenu.style.top=`${i}px`;const a=this.table.internalProps.layoutMap.getHeaderField(t,e);this.updateSelectedField(a);const l=this.filterStateManager.getFilterState(a);l&&"byCondition"===l.type?this.onTabSwitch("byCondition"):this.onTabSwitch("byValue"),setTimeout((()=>{this.isVisible=!0}),0)}hide(){this.filterMenu.style.display="none",this.isVisible=!1}}function k3(t,e){let r="";for(let e=t+1;e>0;e=Math.floor((e-1)/26))r=String.fromCharCode((e-1)%26+65)+r;return r+(e+1)}function R3(t){if(!t)return[0,0,0];if(t.startsWith("#")){let e=t.substring(1);3===e.length&&(e=e.replace(/(.)/g,"$1$1"));return[parseInt(e.substring(0,2),16),parseInt(e.substring(2,4),16),parseInt(e.substring(4,6),16)]}if(t.startsWith("rgb(")){return t.substring(4,t.length-1).split(",").map(Number)}if(t.startsWith("rgba(")){return t.substring(5,t.length-1).split(",").map(Number)}if(Bu(M3[t]))return[(e=M3[t])>>16,e>>8&255,255&e,1];if(Bu(N3[t]))return function(t){return[t>>>24,t>>>16&255,t>>>8&255,255&t]}(N3[t]);var e;throw new Error("Unsupported color format")}function O3(t){if(3===t.length&&t.push(1),4!==t.length)throw new Error("Invalid RGBA array");const[e,r,n,i]=t.map(Math.round);return`${Math.round(255*i).toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}const N3={transparent:4294967040},M3={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 I3(t,e){return{name:B3(t.fontFamily)||"Arial",size:t.fontSize||10,bold:P3(t.fontWeight),italic:"italic"===t.fontStyle,color:z3("link"===e?t._linkColor:t.color),underline:t.underline}}function P3(t){return"number"==typeof t?t>=600:Number(t)>=600||"bold"===t}function B3(t){return t.split(",").map((t=>t.trim()))[0]}function L3(t){return{type:"pattern",pattern:"solid",fgColor:z3(t.bgColor)}}function F3(t){const{borderColor:e,borderLineWidth:r,borderLineDash:n,_strokeArrayWidth:i,_strokeArrayColor:s}=t;if(s||i){const t={};return s&&!s[0]||i&&!i[0]||(t.top={style:D3(i?.[0]??r,n),color:z3(s?.[0]??e)}),s&&!s[1]||i&&!i[1]||(t.right={style:D3(i?.[1]??r,n),color:z3(s?.[1]??e)}),s&&!s[2]||i&&!i[2]||(t.bottom={style:D3(i?.[2]??r,n),color:z3(s?.[2]??e)}),s&&!s[3]||i&&!i[3]||(t.left={style:D3(i?.[3]??r,n),color:z3(s?.[3]??e)}),t}if(0===r)return{};const o={style:D3(r,n),color:z3(e)};return{top:o,left:o,bottom:o,right:o}}function D3(t,e){return e&&e.length?t<=2?"dashed":"mediumDashed":t<=.5?"hair":t<=1?"thin":t<=2?"medium":"thick"}function j3(t,e){return{horizontal:t.textAlign||"left",vertical:t.textBaseline||"middle",wrapText:t.autoWrapText||!1,indent:e||0}}function z3(t){return{argb:O3(R3(t))}}function U3(t,e,r){let n=0;const i=r.internalProps.layoutMap;if(i.isHeader(t,e)){const r=i.getHeader(t,e);Ru(r?.hierarchyLevel)&&(n=(r.hierarchyLevel??0)*(i.rowHierarchyIndent??0))}else{const s=r.getBodyColumnDefine(t,e);if(s?.tree){const s=r.dataSource.getIndexKey(r.getRecordShowIndexByCell(t,e));n=Array.isArray(s)&&"none"!==r.getHierarchyState(t,e)?(s.length-1)*(i.hierarchyIndent??0):0}}return n}function H3(t,e){const r=Lu(t.pagination),n=t.isPivotTable(),i=t.internalProps.layoutMap;let s=t.rowCount-1;return{reset:()=>{n&&e&&r&&(t.internalProps.layoutMap.setPagination(r),t.refreshRowColCount())},handleRowCount:()=>(e&&r&&(n?(t.internalProps.layoutMap.setPagination(void 0),t.refreshRowColCount(),s=t.rowCount-1):s=t.recordsCount*i.bodyRowSpanCount+i.headerLevelCount),s)}}function W3(t){return new Promise((e=>{requestIdleCallback((t=>{e(t)}),t)}))}async function $3(t,e,r=!1){const n=new J2.Workbook,i=n.addWorksheet("sheet1"),s=!!e?.exportAllData,{handleRowCount:o,reset:a}=H3(t,s),l=o(),h=t.colCount-1;i.properties.defaultRowHeight=40;const u=[],c=[],d=new Set;let p=0;function f(s){return new Promise((async o=>{for(;p<=l&&(!r||s?.timeRemaining()>0);){const r=Math.min(p+100-1,l);for(let s=0;s<=h;s++){const o=t.getColWidth(s);void 0===u[s]&&(u[s]={width:o/6});for(let o=p;o<=r;o++){if(0===s){const e=t.getRowHeight(o);i.getRow(o+1).height=e}await V3(s,o,t,i,n,e);const r=t.getCellRange(s,o);if(r.start.col!==r.end.col||r.start.row!==r.end.row){const t=`${r.start.col},${r.start.row}:${r.end.col},${r.end.row}`;d.has(t)||(d.add(t),c.push(r))}}}p=r+1}if(p>l)o();else{let t;r&&(t=await W3()),await f(t),o()}}))}await new Promise((async t=>{let e;r&&(e=await W3()),await f(e),t()})),i.columns=u,c.forEach((t=>{i.mergeCells(t.start.row+1,t.start.col+1,t.end.row+1,t.end.col+1)}));const m=[];t.frozenRowCount>0&&m.push({state:"frozen",ySplit:t.frozenRowCount,topLeftCell:k3(0,t.frozenRowCount)}),t.frozenColCount>0&&m.push({state:"frozen",xSplit:t.frozenColCount,topLeftCell:k3(t.frozenColCount,0)}),i.views=m,e?.excelJSWorksheetCallback&&e.excelJSWorksheetCallback(i);const g=await n.xlsx.writeBuffer();return a(),g}async function V3(t,r,n,i,s,o){const{layoutMap:a}=n.internalProps,l=n.getCellType(t,r),h=n.getCellRawRecord(t,r);let u=(h&&h.vtableMergeName)??n.getCellValue(t,r,!1);var c;!(c=u)||"object"!=typeof c&&"function"!=typeof c||"function"!=typeof c.then||(u=await u);const d=n.getCellStyle(t,r),p=n.getCellLocation(t,r),f="body"!==p?n.getHeaderDefine(t,r):n.getBodyColumnDefine(t,r);let m,g,y,b;if(("body"!==p||(f?.dragOrder||!!f?.icon||!!f?.tree))&&(m=n.getCellIcons(t,r)),"body"!==p?(g=f?.headerCustomRender,y=f?.headerCustomLayout):(g=f?.customRender||n.customRender,y=f?.customLayout),o?.formatExportOutput){const e={cellType:l,cellValue:u,table:n,col:t,row:r},s=o.formatExportOutput(e);if(void 0!==s){let e=i.getCell(k3(t,r));e.value=s,e.font=I3(d,l),e.fill=L3(d),e.border=F3(d);const a=U3(t,r,n);if(e.alignment=j3(d,Math.ceil(a/e.font.size)),e&&o?.formatExcelJSCell){const i=o.formatExcelJSCell({cellType:l,cellValue:u,table:n,col:t,row:r},e);i&&(e=i)}return e}}if("image"===l||"video"===l||"progressbar"===l||"sparkline"===l||a.isAxisCell(t,r)||!o?.ignoreIcon&&Nu(m)&&m.length||g||y)if(X3(l,a.isAxisCell(t,r),!!g||!!y,!(o?.ignoreIcon||!Nu(m)||!m.length),o)){const e=G3(t,r,n),o=s.addImage({base64:e,extension:"png"});i.addImage(o,{tl:{col:t+1/80,row:r+1/120},br:{col:t+1,row:r+1},editAs:"oneCell"})}else b=i.getCell(k3(t,r));else if("text"===l||"link"===l){let e;if(b=i.getCell(k3(t,r)),"link"===l){const i=f.templateLink;if(i){const s=n.getCellOriginRecord(t,r);if(s&&s.vtableMerge);else{const o=n.getCellOriginValue(t,r),a=Object.assign({__value:u,__dataValue:o},s);if(ku(i))e=i(a,t,r,n);else{const t=/\{\s*(\S+?)\s*\}/g;e=i.replace(t,((t,e)=>a[e]))}}}}b.value=function(t,e,r){if("link"===e)return{text:t,hyperlink:r||t,tooltip:t};return t}(u,l,e),b.font=I3(d,l),b.fill=L3(d),b.border=F3(d);const s=U3(t,r,n);b.alignment=j3(d,Math.ceil(s/b.font.size))}else if("chart"===l)if(X3("chart",!1,!1,!1,o)){const o=n.scenegraph.getCell(t,r);e.renderChart(o.firstChild);const a=G3(t,r,n),l=s.addImage({base64:a,extension:"png"});i.addImage(l,{tl:{col:t+1/80,row:r+1/120},br:{col:t+1,row:r+1},editAs:"oneCell"}),n.scenegraph.updateNextFrame()}else b=i.getCell(k3(t,r));if(b&&o?.formatExcelJSCell){const e=o.formatExcelJSCell({cellType:l,cellValue:u,table:n,col:t,row:r},b);e&&(b=e)}return b}function G3(t,r,n){let i=n.scenegraph.getCell(t,r),s=!1;"empty"===i.role&&(i=e.updateCell(t,r,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=e.graphicUtil.drawGraphicToCanvas(i,n.scenegraph.stage);return i.attribute.stroke=o,s&&i.parent?.removeChild(i),a.toDataURL()}function X3(t,e,r,n,i){return!i?.skipImageExportCellType||("image"===t||"video"===t||"progressbar"===t||"sparkline"===t||"chart"===t?!i.skipImageExportCellType.includes(t):e?!i.skipImageExportCellType.includes("chart"):r?!i.skipImageExportCellType.includes("custom"):!n||!i.skipImageExportCellType.includes("textWithIcon"))}function Y3(t,e){const r=!!e?.exportAllData,{handleRowCount:n,reset:i}=H3(t,r),s=n(),o=t.colCount-1;let a="";for(let r=0;r<=s;r++){for(let n=0;n<=o;n++){const i=q3(n,r,t,e);if("undefined"!=typeof Promise&&i instanceof Promise);else{const t=`${void 0===i?"":i}`;/^\[object .*\]$/.exec(t)||(a+=t)}a+=","}a+="\r\n"}return i(),a}function q3(t,e,r,n){const i=r.getCellRawRecord(t,e),s=(i&&i.vtableMergeName)??r.getCellValue(t,e,!1);if(n?.formatExportOutput){const i={cellType:r.getCellType(t,e),cellValue:s,table:r,col:t,row:e},o=n.formatExportOutput(i);if(void 0!==o)return"string"==typeof o?'"'+o+'"':o}const o=r.getCellRange(t,e),a=o.start.col,l=o.start.row;if(a!==t||l!==e)return"";let h=s;return n?.escape?h=function(t){if("string"!=typeof t)return t;let e=t.replace(/"/g,'""');/[,"\r\n]/.test(e)&&(e=`"${e}"`);return e}(h):"string"==typeof h&&(h='"'+h+'"'),h}var K3={exports:{}};!function(t,e){!function(){function e(t,e){return void 0===e?e={autoBom:!1}:"object"!=typeof e&&(e={autoBom:!e}),e.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob(["\ufeff",t],{type:t.type}):t}function r(t,e,r){var n=new XMLHttpRequest;n.open("GET",t),n.responseType="blob",n.onload=function(){a(n.response,e,r)},n.onerror=function(){},n.send()}function n(t){var e=new XMLHttpRequest;e.open("HEAD",t,!1);try{e.send()}catch(t){}return 200<=e.status&&299>=e.status}function i(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(r){var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(e)}}var s="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof dt&&dt.global===dt?dt:void 0,o=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),a=s.saveAs||("object"!=typeof window||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!o?function(t,e,o){var a=s.URL||s.webkitURL,l=document.createElement("a");e=e||t.name||"download",l.download=e,l.rel="noopener","string"==typeof t?(l.href=t,l.origin===location.origin?i(l):n(l.href)?r(t,e,o):i(l,l.target="_blank")):(l.href=a.createObjectURL(t),setTimeout((function(){a.revokeObjectURL(l.href)}),4e4),setTimeout((function(){i(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(t,s,o){if(s=s||t.name||"download","string"!=typeof t)navigator.msSaveOrOpenBlob(e(t,o),s);else if(n(t))r(t,s,o);else{var a=document.createElement("a");a.href=t,a.target="_blank",setTimeout((function(){i(a)}))}}:function(t,e,n,i){if((i=i||open("","_blank"))&&(i.document.title=i.document.body.innerText="downloading..."),"string"==typeof t)return r(t,e,n);var a="application/octet-stream"===t.type,l=/constructor/i.test(s.HTMLElement)||s.safari,h=/CriOS\/[\d]+/.test(navigator.userAgent);if((h||a&&l||o)&&"undefined"!=typeof FileReader){var u=new FileReader;u.onloadend=function(){var t=u.result;t=h?t:t.replace(/^data:[^;]*;/,"data:attachment/file;"),i?i.location.href=t:location=t,i=null},u.readAsDataURL(t)}else{var c=s.URL||s.webkitURL,d=c.createObjectURL(t);i?i.location=d:location.href=d,i=null,setTimeout((function(){c.revokeObjectURL(d)}),4e4)}});s.saveAs=a.saveAs=a,t.exports=a}()}(K3);var Z3,Q3,J3,t5,e5=K3.exports;!function(t){t.UP="top",t.RIGHT="right",t.DOWN="bottom",t.LEFT="left"}(Z3||(Z3={})),function(t){t.COPY="copy",t.SERIES="series"}(Q3||(Q3={})),function(t){t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING"}(J3||(J3={})),function(t){t.NUMBER="number",t.DATE="date",t.EXTEND_NUMBER="extendNumber",t.CHN_NUMBER="chnNumber",t.CHN_WEEK2="chnWeek2",t.CHN_WEEK3="chnWeek3",t.LOOP_SERIES="loopSeries",t.FORMULA="formula",t.OTHER="other"}(t5||(t5={}));var r5=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t},n5=Md,i5=function(){try{var t=n5(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),s5=i5;var o5=function(t,e,r){"__proto__"==e&&s5?s5(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r},a5=o5,l5=xc,h5=Object.prototype.hasOwnProperty;var u5=function(t,e,r){var n=t[e];h5.call(t,e)&&l5(n,r)&&(void 0!==r||e in t)||a5(t,e,r)},c5=u5,d5=o5;var p5=function(t,e,r,n){var i=!r;r||(r={});for(var s=-1,o=e.length;++s<o;){var a=e[s],l=n?n(r[a],t[a],a,r,t):void 0;void 0===l&&(l=t[a]),i?d5(r,a,l):c5(r,a,l)}return r},f5=p5,m5=lm;var g5=function(t,e){return t&&f5(e,m5(e),t)};var y5=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e},b5=ld,v5=qf,_5=y5,w5=Object.prototype.hasOwnProperty;var x5=function(t){if(!b5(t))return _5(t);var e=v5(t),r=[];for(var n in t)("constructor"!=n||!e&&w5.call(t,n))&&r.push(n);return r},S5=Xf,C5=x5,T5=im;var E5=function(t){return T5(t)?S5(t,!0):C5(t)},A5=p5,k5=E5;var R5=function(t,e){return t&&A5(e,k5(e),t)},O5={exports:{}};!function(t,e){var r=qc,n=e&&!e.nodeType&&e,i=n&&t&&!t.nodeType&&t,s=i&&i.exports===n?r.Buffer:void 0,o=s?s.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=o?o(r):new t.constructor(r);return t.copy(n),n}}(O5,O5.exports);var N5=O5.exports;var M5=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e},I5=p5,P5=uf;var B5=function(t,e){return I5(t,P5(t),e)},L5=Kf(Object.getPrototypeOf,Object),F5=Zp,D5=L5,j5=uf,z5=nf,U5=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)F5(e,j5(t)),t=D5(t);return e}:z5,H5=p5,W5=U5;var $5=function(t,e){return H5(t,W5(t),e)},V5=ef,G5=U5,X5=E5;var Y5=function(t){return V5(t,X5,G5)},q5=Object.prototype.hasOwnProperty;var K5=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&q5.call(t,"index")&&(r.index=t.index,r.input=t.input),r},Z5=zp;var Q5=function(t){var e=new t.constructor(t.byteLength);return new Z5(e).set(new Z5(t)),e},J5=Q5;var t6=function(t,e){var r=e?J5(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)},e6=/\w*$/;var r6=function(t){var e=new t.constructor(t.source,e6.exec(t));return e.lastIndex=t.lastIndex,e},n6=Kc?Kc.prototype:void 0,i6=n6?n6.valueOf:void 0;var s6=function(t){return i6?Object(i6.call(t)):{}},o6=Q5;var a6=function(t,e){var r=e?o6(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)},l6=Q5,h6=t6,u6=r6,c6=s6,d6=a6;var p6=function(t,e,r){var n=t.constructor;switch(e){case"[object ArrayBuffer]":return l6(t);case"[object Boolean]":case"[object Date]":return new n(+t);case"[object DataView]":return h6(t,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 d6(t,r);case"[object Map]":case"[object Set]":return new n;case"[object Number]":case"[object String]":return new n(t);case"[object RegExp]":return u6(t);case"[object Symbol]":return c6(t)}},f6=ld,m6=Object.create,g6=function(){function t(){}return function(e){if(!f6(e))return{};if(m6)return m6(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),y6=g6,b6=L5,v6=qf;var _6=function(t){return"function"!=typeof t.constructor||v6(t)?{}:y6(b6(t))},w6=Pm,x6=df;var S6=function(t){return x6(t)&&"[object Map]"==w6(t)},C6=If,T6=Bf&&Bf.isMap,E6=T6?C6(T6):S6,A6=Pm,k6=df;var R6=function(t){return k6(t)&&"[object Set]"==A6(t)},O6=If,N6=Bf&&Bf.isSet,M6=N6?O6(N6):R6,I6=Rp,P6=r5,B6=u5,L6=g5,F6=R5,D6=N5,j6=M5,z6=B5,U6=$5,H6=dm,W6=Y5,$6=Pm,V6=K5,G6=p6,X6=_6,Y6=Qp,q6=Cf,K6=E6,Z6=ld,Q6=M6,J6=lm,t4=E5,e4="[object Arguments]",r4="[object Function]",n4="[object Object]",i4={};i4[e4]=i4["[object Array]"]=i4["[object ArrayBuffer]"]=i4["[object DataView]"]=i4["[object Boolean]"]=i4["[object Date]"]=i4["[object Float32Array]"]=i4["[object Float64Array]"]=i4["[object Int8Array]"]=i4["[object Int16Array]"]=i4["[object Int32Array]"]=i4["[object Map]"]=i4["[object Number]"]=i4[n4]=i4["[object RegExp]"]=i4["[object Set]"]=i4["[object String]"]=i4["[object Symbol]"]=i4["[object Uint8Array]"]=i4["[object Uint8ClampedArray]"]=i4["[object Uint16Array]"]=i4["[object Uint32Array]"]=!0,i4["[object Error]"]=i4[r4]=i4["[object WeakMap]"]=!1;var s4=function t(e,r,n,i,s,o){var a,l=1&r,h=2&r,u=4&r;if(n&&(a=s?n(e,i,s,o):n(e)),void 0!==a)return a;if(!Z6(e))return e;var c=Y6(e);if(c){if(a=V6(e),!l)return j6(e,a)}else{var d=$6(e),p=d==r4||"[object GeneratorFunction]"==d;if(q6(e))return D6(e,l);if(d==n4||d==e4||p&&!s){if(a=h||p?{}:X6(e),!l)return h?U6(e,F6(a,e)):z6(e,L6(a,e))}else{if(!i4[d])return s?e:{};a=G6(e,d,l)}}o||(o=new I6);var f=o.get(e);if(f)return f;o.set(e,a),Q6(e)?e.forEach((function(i){a.add(t(i,r,n,i,e,o))})):K6(e)&&e.forEach((function(i,s){a.set(s,t(i,r,n,s,e,o))}));var m=c?void 0:(u?h?W6:H6:h?t4:J6)(e);return P6(m||e,(function(i,s){m&&(i=e[s=i]),B6(a,s,t(i,r,n,s,e,o))})),a},o4=s4;var a4=pt((function(t){return o4(t,5)}));const l4={"零":0,"一":1,"二":2,"三":3,"四":4,"五":5,"六":6,"七":7,"八":8,"九":9},h4=["零","一","二","三","四","五","六","七","八","九"],u4=["","万","亿","万亿","亿亿"],c4=["","十","百","千"],d4={"十":{value:10,secUnit:!1},"百":{value:100,secUnit:!1},"千":{value:1e3,secUnit:!1},"万":{value:1e4,secUnit:!0},"亿":{value:1e8,secUnit:!0}};function p4(t){if(!t)return 0;let e=0,r=0,n=0,i=!1;const s=t.split("");for(let t=0;t<s.length;t++){const o=l4[s[t]];if(void 0!==o)n=o,t===s.length-1&&(r+=n);else{const o=d4[s[t]],a=o.value;i=o.secUnit,i?(r=(r+n)*a,e+=r,r=0):r+=n*a,n=0}}return e+r}function f4(t){let e="",r="",n=0,i=!0;for(;t>0;){const s=t%10;0===s?i||(i=!0,r=h4[s]+r):(i=!1,e=h4[s],e+=c4[n],r=e+r),n++,t=Math.floor(t/10)}return r}function m4(t){let e=0,r="",n="",i=!1;if(0===t)return h4[0];for(;t>0;){const s=t%1e4;i&&(n=h4[0]+n),r=f4(s),r+=0!==s?u4[e]:u4[0],n=r+n,i=s<1e3&&s>0,t=Math.floor(t/1e4),e++}return n}function g4(t){if(!t)return{isExtendNumber:!1};const e=/0|([1-9]+[0-9]*)/g,r=e.test(t);if(r){const r=t.match(e);if(r&&r.length>0){const e=r[r.length-1],n=t.lastIndexOf(e),i=t.substr(0,n),s=t.substr(n+e.length);return{isExtendNumber:!0,matchTxt:Number(e),beforeTxt:i,afterTxt:s}}return{isExtendNumber:!1}}return{isExtendNumber:r}}function y4(t){let e=!0;const r=t[1]-t[0];for(let n=1;n<t.length;n++)if(t[n]-t[n-1]!==r){e=!1;break}return e}function b4(t,e){const r=[];for(let n=1;n<=e;n++){const e=(n-1)%t.length,i=a4(t[e]);A4(i),r.push({v:null,t:null,...i})}return r}function v4(t,e,r,n){n&&t.forEach((t=>{const{v:e,meta:r}=n.toNumber(t.v);t.v=e,t.f=r}));const i=[],s=[];for(let e=0;e<t.length;e++)s.push(Number(t[e]?.v));if(t.length>2&&function(t){let e=!0;const r=t[1]/t[0];for(let n=1;n<t.length;n++)if(t[n]/t[n-1]!==r){e=!1;break}return e}(s))for(let r=1;r<=e;r++){const e=(r-1)%t.length,s=a4(t[e]);A4(s);const o=Number(t[t.length-1]?.v)*(Number(t[1]?.v)/Number(t[0]?.v))**r;s&&(s.v=n?n.fromNumber(o,s.f):o,i.push(s))}else{const o=function(t){const e=[];for(let r=1;r<=t;r++)e.push(r);return e}(t.length);for(let a=1;a<=e;a++){const e=(a-1)%t.length,l=a4(t[e]);A4(l);const h=r===Z3.DOWN||r===Z3.RIGHT,u=_4(t.length+a,s,o,h);l&&(l.v=n?n.fromNumber(u,l.f):u,i.push(l))}}return i}function _4(t,e,r,n=!0){function i(t){let e=0;for(let r=0;r<t.length;r++)e+=t[r];return e/t.length}const s=i(r),o=i(e);let a,l=0,h=0;for(let t=0;t<r.length;t++)l+=(r[t]-s)*(e[t]-o),h+=(r[t]-s)*(r[t]-s);a=0===h?n?1:-1:l/h;const u=o-a*s;return Math.round(1e5*(u+a*t))/1e5}function w4(t,e,r){const n=[],i=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=e;s++){const e=(s-1)%t.length,o=a4(t[e]);A4(o);const a=`${t[t.length-1]?.v}`;if(!a)continue;const l=a?.match(i),h=l?.[l.length-1];if(!h)continue;const u=Math.abs(Number(h)+r*s),c=a.lastIndexOf(h),d=a.substr(0,c)+u.toString()+a.substr(c+h.length);o&&(o.v=d,n.push(o))}return n}function x4(t,e,r,n=0){const i=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=i.length)return[];const s=i[n],o=[];for(let n=1;n<=e;n++){const e=(n-1)%t.length,i=a4(t[e]);A4(i);let a=0;if(t[t.length-1]?.v===s[0])a=7+r*n;else{const e=`${t[t.length-1]?.v}`;if(e){a=p4(e.substr(e.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 S4(t,e,r){const n=[];for(let i=1;i<=e;i++){const e=(i-1)%t.length,s=a4(t[e]);A4(s);const o=p4(`${t[t.length-1]?.v}`)+r*i;let a;a=o<=0?"零":m4(o),s&&(s.v=a,n.push(s))}return n}const C4={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 T4(t){let e="";const r=[];return Object.keys(C4).forEach((n=>{C4[n].includes(t)&&(e=n,r.push(...C4[n]))})),{name:e,series:r}}function E4(t,e,r,n){const i=n.length,s=[];for(let o=1;o<=e;o++){const e=(o-1)%t.length,a=a4(t[e]);A4(a);const l=`${t[t.length-1]?.v}`;let h=n.indexOf(l)+r*o;h<0&&(h+=Math.abs(r)*i);const u=h%i;a&&(a.v=n[u],s.push(a))}return s}function A4(t){t&&"custom"in t&&delete t.custom}function k4(t,e,r=new Date){const n=t.trim();if("yyyy-MM-dd"===e){const[t,e,r]=n.split("-").map(Number);return new Date(t,e-1,r)}if("yyyy-M-d"===e){const[t,e,r]=n.split("-").map(Number);return new Date(t,e-1,r)}if("yyyy/MM/dd"===e){const[t,e,r]=n.split("/").map(Number);return new Date(t,e-1,r)}if("yyyy/M/d"===e){const[t,e,r]=n.split("/").map(Number);return new Date(t,e-1,r)}if("MM/dd/yyyy"===e){const[t,e,r]=n.split("/").map(Number);return new Date(r,t-1,e)}if("yyyy年M月d日"===e){const t=n.match(/^(\d{4})年(\d{1,2})月(\d{1,2})(日)?$/);if(t)return new Date(Number(t[1]),Number(t[2])-1,Number(t[3]))}const i=new Date(n);return isNaN(i.getTime())?new Date(r):i}function R4(t){return!isNaN(t.getTime())}function O4(t,e){const r=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())-Date.UTC(e.getFullYear(),e.getMonth(),e.getDate());return Math.floor(r/864e5)}class N4{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:t=>{const e=t.match(/(\d{4})年(\d{1,2})月(\d{1,2})/);if(!e)throw new Error("无效的中文日期格式");return new Date(+e[1],+e[2]-1,+e[3])}}];detect(t){if(t instanceof Date)return!isNaN(t.getTime());if("string"!=typeof t)return!1;const e=t.trim(),r=this.dateFormats.find((t=>t.pattern.test(e)));if(r)try{return R4(r.parser?r.parser(e):k4(e,r.format,new Date))}catch{return!1}return!1}toNumber(t){let e,r;if(t instanceof Date){if(!R4(t))throw new Error("无效的日期对象");e=t,r="yyyy-MM-dd"}else{const n=t.trim(),i=this.dateFormats.find((t=>t.pattern.test(n)));if(!i)throw new Error(`不支持的日期格式: ${n}`);if(e=i.parser?i.parser(n):k4(n,i.format,new Date),!R4(e))throw new Error(`无效的日期值: ${n}`);r=i.format}return{v:O4(e,this.baseDate),meta:r}}fromNumber(t,e){const r=function(t,e){const r=new Date(t);return r.setDate(r.getDate()+e),r}(this.baseDate,t);return r.setHours(0,0,0,0),function(t,e){const r=t.getFullYear(),n=t.getMonth()+1,i=t.getDate(),s=t=>t.toString().padStart(2,"0");switch(e){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,e||"yyyy-MM-dd")}}const M4=new class{converters=[];register(t){this.converters.push(t)}getConverter(t){return this.converters.find((e=>e.detect(t)))||null}getConverterByKey(t){return this.converters.find((e=>e.key===t))||null}};M4.register(new N4);const I4={type:t5.DATE,priority:1100,match:(t,e)=>"string"==typeof t?.v&&M4.getConverter(t.v)instanceof N4,isContinue:(t,e)=>t.type===t5.DATE,applyFunctions:{[Q3.SERIES]:(t,e,r)=>{const{data:n}=t,i=M4.getConverter(n[0]?.v);return r===Z3.LEFT||r===Z3.UP?(n.reverse(),v4(n,e,r,i).reverse()):v4(n,e,r,i)}}},P4={type:t5.NUMBER,priority:1e3,match:t=>"number"==typeof t?.v||t?.t===J3.NUMBER,isContinue:(t,e)=>t.type===t5.NUMBER,applyFunctions:{[Q3.SERIES]:(t,e,r)=>{const{data:n}=t;return r===Z3.LEFT||r===Z3.UP?(n.reverse(),v4(n,e,r).reverse()):v4(n,e,r)}}},B4={type:t5.OTHER,priority:0,match:()=>!0,isContinue:(t,e)=>t.type===t5.OTHER},L4={type:t5.EXTEND_NUMBER,priority:900,match:t=>g4(`${t?.v}`||"").isExtendNumber,isContinue:(t,e)=>{if(t.type===t5.EXTEND_NUMBER){const{beforeTxt:r,afterTxt:n}=g4(`${t.cellData?.v}`||""),{beforeTxt:i,afterTxt:s}=g4(`${e?.v}`||"");if(r===i&&n===s)return!0}return!1},applyFunctions:{[Q3.SERIES]:(t,e,r)=>{const{data:n}=t,i=r===Z3.UP||r===Z3.LEFT;let s;if(1===n.length)return s=i?-1:1,U4(w4(n,e,s),i);const o=[];for(let t=0;t<n.length;t++){const e=`${n[t]?.v}`;e&&o.push(Number(g4(e).matchTxt))}return i&&(n.reverse(),o.reverse()),y4(o)?(s=o[1]-o[0],U4(w4(n,e,s),i)):b4(n,e)}}},F4={type:t5.CHN_NUMBER,priority:830,match:t=>!!function(t){if(!t)return!1;let e=!0;if(t)if(1===t.length)e="日"===t||t in l4;else{const r=t.split("");for(let t=0;t<r.length;t++)if(!(r[t]in l4)&&!(r[t]in d4)){e=!1;break}}return e}(`${t?.v}`||""),isContinue:(t,e)=>t.type===t5.CHN_NUMBER,applyFunctions:{[Q3.SERIES]:(t,e,r)=>{const{data:n}=t,i=r===Z3.LEFT||r===Z3.UP;if(1===n.length){let t;return t=i?-1:1,U4(S4(n,e,t),i)}let s=!1;for(let t=0;t<n.length;t++){const e=n[t]?.v;if("日"===e){s=!0;break}}const o=[];let a=0;for(let t=0;t<n.length;t++){const e=`${n[t]?.v}`;"日"===e?0===t?o.push(0):(a++,o.push(7*a)):s&&p4(e)>0&&p4(e)<7?o.push(p4(e)+7*a):o.push(p4(e))}if(i&&(n.reverse(),o.reverse()),y4(o)){return U4(S4(n,e,o[1]-o[0]),i)}return b4(n,e)}}},D4={type:t5.CHN_WEEK2,priority:820,match:t=>!!function(t){let e;return e=2===t.length&&("周一"===t||"周二"===t||"周三"===t||"周四"===t||"周五"===t||"周六"===t||"周日"===t),e}(`${t?.v}`||""),isContinue:(t,e)=>t.type===t5.CHN_WEEK2,applyFunctions:{[Q3.SERIES]:(t,e,r)=>{const{data:n}=t,i=r===Z3.LEFT||r===Z3.UP;if(1===n.length){let t;return t=i?-1:1,U4(x4(n,e,t,1),i)}const s=[];let o=0;for(let t=0;t<n.length;t++){const e=`${n[t]?.v}`,r=e?.substr(e.length-1,1);"周日"===e?0===t?s.push(0):(o++,s.push(7*o)):s.push(p4(r)+7*o)}if(i&&(n.reverse(),s.reverse()),y4(s)){return U4(x4(n,e,s[1]-s[0],1),i)}return b4(n,e)}}},j4={type:t5.CHN_WEEK3,priority:810,match:t=>function(t){let e;return e=3===t.length&&("星期一"===t||"星期二"===t||"星期三"===t||"星期四"===t||"星期五"===t||"星期六"===t||"星期日"===t),e}(`${t?.v}`||""),isContinue:(t,e)=>t.type===t5.CHN_WEEK3,applyFunctions:{[Q3.SERIES]:(t,e,r)=>{const{data:n}=t,i=r===Z3.LEFT||r===Z3.UP;if(1===n.length){let t;return t=i?-1:1,U4(x4(n,e,t,2),i)}const s=[];let o=0;for(let t=0;t<n.length;t++){const e=`${n[t]?.v}`;if(e){const r=e.substr(e.length-1,1);"星期日"===e?0===t?s.push(0):(o++,s.push(7*o)):s.push(p4(r)+7*o)}}if(i&&(n.reverse(),s.reverse()),y4(s)){return U4(x4(n,e,s[1]-s[0],2),i)}return b4(n,e)}}},z4={type:t5.LOOP_SERIES,priority:800,match:t=>function(t){let e=!1;return Object.keys(C4).forEach((r=>{C4[r].includes(t)&&(e=!0)})),e}(`${t?.v}`||""),isContinue:(t,e)=>t.type===t5.LOOP_SERIES&&T4(`${t.cellData?.v}`||"").name===T4(`${e?.v}`||"").name,applyFunctions:{[Q3.SERIES]:(t,e,r)=>{const{data:n}=t,i=r===Z3.LEFT||r===Z3.UP,{series:s}=T4(`${n[0]?.v}`||"");if(1===n.length){let t;return t=i?-1:1,U4(E4(n,e,t,s),i)}const o=[];let a=0;for(let t=0;t<n.length;t++){const e=`${n[t]?.v}`;e&&(e===s[0]?0===t?o.push(0):(a++,o.push(a*s.length)):o.push(s.indexOf(e)+7*a))}if(i&&(n.reverse(),o.reverse()),y4(o)){return U4(E4(n,e,o[1]-o[0],s),i)}return b4(n,e)}}};function U4(t,e){return e?t.reverse():t}class H4{_rules=[];constructor(){this._init()}_init(){this._rules=[I4,P4,L4,F4,D4,j4,z4,B4].sort(((t,e)=>e.priority-t.priority))}registerRule(t){if(this._rules.find((e=>e.type===t.type)))throw new Error(`Registry rule failed, type '${t.type}' already exist!`);const e=this._rules.findIndex((e=>e.priority<t.priority));this._rules.splice(-1===e?this._rules.length:e,0,t)}getRules(){return this._rules}}function W4(t){const e=Math.min(t.start.col,t.end.col),r=Math.min(t.start.row,t.end.row),n=Math.max(t.start.col,t.end.col),i=Math.max(t.start.row,t.end.row),s=[],o=[];for(let t=e;t<=n;t++)s.push(t);for(let t=r;t<=i;t++)o.push(t);return{cols:s,rows:o}}function $4(t,e,r){return t===Z3.DOWN||t===Z3.UP?{cols:r.cols,rows:r.rows.filter((t=>!e.rows.includes(t)))}:{cols:r.cols.filter((t=>!e.cols.includes(t))),rows:r.rows}}function V4(t,e,r){const n=t.scenegraph.highPerformanceGetCell(e,r).globalAABBBounds;t.showDropDownMenu(e,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 G4(t){return{getValue:(e,r)=>{const n=t.getCellValue(r,e);return"number"!=typeof n&&isNaN(Number(n))?{v:n||"",t:J3.STRING}:{v:n,t:J3.NUMBER}},getMaxRows:()=>t.records.length,getMaxColumns:()=>t.columns.length}}class X4{sourceData=[];autoFillService;tableInstance;sourceRange;targetRange;direction;headers;options;constructor(t){this.options=t,this.autoFillService=new H4}setTable(t){this.headers={row:new Set,col:new Set},this.tableInstance=t,t.on(m.TABLE_EVENT_TYPE.DROPDOWN_MENU_CLICK,(t=>{"复制填充"===t.text?this.fillData(Q3.COPY):"序列填充"===t.text&&this.fillData(Q3.SERIES)}));const e=this.tableInstance.getAllRowHeaderCells()[0];e&&e.forEach((t=>{this.headers.col.add(t.col)}));const r=this.tableInstance.getAllColumnHeaderCells()[0];r&&r.forEach((t=>{this.headers.row.add(t.row)}))}handleStartDrag(t){this.sourceRange=W4(t),this.sourceRange.cols=this.sourceRange.cols.filter((t=>!this.headers.col.has(t))),this.sourceRange.rows=this.sourceRange.rows.filter((t=>!this.headers.row.has(t)))}handleEndDrag(t,e){this.direction=e;const r=W4(t);this.targetRange=$4(this.direction,this.sourceRange,r),this.targetRange.cols=this.targetRange.cols.filter((t=>!this.headers.col.has(t))),this.targetRange.rows=this.targetRange.rows.filter((t=>!this.headers.row.has(t))),this.options?.fillMode?this.fillData(this.options.fillMode):V4(this.tableInstance,Math.max(...r.cols),Math.max(...r.rows))}handleDbClick(){if(!this.sourceRange)return;this.direction=Z3.DOWN;const t=W4(this._detectFillRange());if(this.targetRange=$4(this.direction,this.sourceRange,t),this.targetRange.cols=this.targetRange.cols.filter((t=>!this.headers.col.has(t))),this.targetRange.rows=this.targetRange.rows.filter((t=>!this.headers.row.has(t))),0===this.targetRange.cols.length||0===this.targetRange.rows.length)return;const e=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(e,r,!1,!1,!1,!0,!0),s.updateInteractionState(Iu.grabing),s.updateSelectPos(n,i,!1,!1,!1,!0,!0),s.endSelectCells(!1,!1),s.updateInteractionState(Iu.default),this.options?.fastFillMode?this.fillData(this.options.fastFillMode):V4(this.tableInstance,n,i)}fillData(t){this.sourceData=this.getSourceData(this.sourceRange,this.direction);const e={source:this.sourceRange,target:this.targetRange};this._fillData(e,this.direction,t)}getSourceData(t,e){const r=this.autoFillService.getRules(),n=[],i=e===Z3.DOWN||e===Z3.UP;let s,o;i?(s=t.cols,o=t.rows):(s=t.rows,o=t.cols);const a=G4(this.tableInstance);return s.forEach((t=>{const e=this.getEmptySourceDataPiece(),s={type:void 0,cellData:void 0};o.forEach((n=>{let l;l=i?a.getValue(n,t):a.getValue(t,n);const{type:h,isContinue:u}=r.find((t=>t.match(l,null)))||B4;if(u(s,l)){const t=e[h],r=t[t.length-1];r.data.push(l),r.index.push(n-o[0])}else{const t=e[h];t?t.push({data:[l],index:[n-o[0]]}):e[h]=[{data:[l],index:[n-o[0]]}]}s.type=h,s.cellData=l})),n.push(e)})),n}getEmptySourceDataPiece(){const t={};return this.autoFillService.getRules().forEach((e=>{t[e.type]=[]})),t}_detectFillRange(){const t={row:Math.min(...this.sourceRange.rows),col:Math.min(...this.sourceRange.cols)},e={row:Math.max(...this.sourceRange.rows),col:Math.max(...this.sourceRange.cols)},r=G4(this.tableInstance),n=r.getMaxRows(),i=r.getMaxColumns();let s=e.row;if(t.col>0&&r.getValue(t.row,t.col-1)?.v){let e=t.row;for(;r.getValue(e,t.col-1)?.v&&e<=n;)e+=1;s=e-1}else if(e.col<i&&r.getValue(e.row,e.col+1)?.v){let i=t.row;for(;r.getValue(i,e.col+1)?.v&&i<=n;)i+=1;s=i-1}for(let n=e.row+1;n<=s;n++)for(let i=t.col;i<=e.col;i++)if(r.getValue(n,i)?.v){s=n-1;break}return{start:{row:t.row,col:t.col},end:{row:s,col:e.col}}}_fillData(t,e,r){const{source:n,target:i}=t;if(!n||!i||null==e)return;const{cols:s,rows:o}=i,{cols:a,rows:l}=n,h=this.sourceData;let u;u=e===Z3.DOWN||e===Z3.UP?l.length:a.length;const c=[];if(e===Z3.DOWN||e===Z3.UP){const n=o.length,i=[];s.forEach(((s,o)=>{const a=h[o],l=this.getApplyData(a,u,n,e,r,t);i.push(l)}));for(let t=0;t<i[0].length;t++){const e=[];for(let r=0;r<i.length;r++)e.push({s:null,...i[r][t]});c.push(e)}}else{const n=s.length;o.forEach(((i,s)=>{const o=h[s],a=this.getApplyData(o,u,n,e,r,t),l=[];for(let t=0;t<a.length;t++)l.push({s:null,...a[t]});c.push(l)}))}const d=[];o.forEach(((t,e)=>{const r=[];s.forEach(((n,i)=>{const s=function(t,e,r){const n=t.getCellRange(e,r);return n.start.col!==n.end.col||n.start.row!==n.end.row?n:null}(this.tableInstance,n,t);s&&this.tableInstance.unmergeCells(s.start.col,s.start.row,s.end.col,s.end.row),c[e][i]&&r.push(c[e][i].v+"")})),d.push(r)}));const p=Math.min(...o),f=Math.min(...s);this.tableInstance.changeCellValues(f,p,d)}getApplyData(t,e,r,n,i,s){const o=[],a=Math.floor(r/e),l=r%e,h=this.autoFillService.getRules(),u={};h.forEach((t=>{u[t.type]=[]})),h.forEach((o=>{const{type:h,applyFunctions:c={}}=o,d=t[h];d&&d.forEach((o=>{const d=function(t,e){let r=0;for(let n=0;n<t.length&&t[n]<e;n++)r++;return r}(o.index,l),p=o.index.length*a+d,f=this.applyFunctions(o,p,n,i,c,t,s),m=function(t,e,r){const n=[],i=Math.floor(e/t),s=e%t;let o=0;if(i>0){for(let e=0;e<i;e++)for(let i=0;i<r.length;i++)n[r[i]+e*t]=o,o++;for(let e=0;e<r.length&&r[e]<s;e++)n[r[e]+t*i]=o,o++}else for(let t=0;t<r.length&&r[t]<s;t++)n[r[t]]=o,o++;return n}(e,r,o.index);u[h].push({data:f,index:m})}))}));for(let t=0;t<r;t++)h.forEach((e=>{const{type:r}=e,n=u[r];for(let e=0;e<n.length;e++)t in n[e].index&&o.push(n[e].data[n[e].index[t]])}));return o}applyFunctions(t,e,r,n,i,s,o){const{data:a}=t,l=r===Z3.UP||r===Z3.LEFT;if(n===Q3.COPY){const n=i?.[Q3.COPY];return n?n(t,e,r,s,o):(l&&a.reverse(),b4(a,e))}if(n===Q3.SERIES){const n=i?.[Q3.SERIES];return n?n(t,e,r,s):(l&&a.reverse(),i?.[Q3.COPY]?i[Q3.COPY](t,e,r,s,o):b4(a,e))}}}t.AddRowColumnPlugin=class{id="add-row-column";name="Add Row Column";runTime=[m.TABLE_EVENT_TYPE.MOUSEENTER_CELL,m.TABLE_EVENT_TYPE.MOUSELEAVE_CELL,m.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE];pluginOptions;table;hoverCell;hideAllTimeoutId_addColumn;hideAllTimeoutId_addRow;leftDotForAddColumn;rightDotForAddColumn;addIconForAddColumn;addLineForAddColumn;topDotForAddRow;bottomDotForAddRow;addIconForAddRow;addLineForAddRow;constructor(t={addColumnEnable:!0,addRowEnable:!0}){this.id=t.id??this.id,this.pluginOptions=t,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(...t){const e=t[0],r=t[1],n=t[2];if(this.table=n,r===m.TABLE_EVENT_TYPE.MOUSEENTER_CELL){clearTimeout(this.hideAllTimeoutId_addColumn),clearTimeout(this.hideAllTimeoutId_addRow);const t=n.canvas.getBoundingClientRect(),r=n.getCellAtRelativePosition(e.event.clientX-t.left,e.event.clientY-t.top);this.hoverCell=r;const i=n.getCellRelativeRect(r.col,r.row);if(this.pluginOptions.addColumnEnable){const e=n.isSeriesNumber(r.col,0);this.showDotForAddColumn(t.top-6,i.left+t.left,i.right+t.left,!e)}if(this.pluginOptions.addRowEnable){const e=n.isHeader(r.col,r.row);this.showDotForAddRow(i.top+t.top,t.left-6,i.bottom+t.top,!e,!e)}}else r===m.TABLE_EVENT_TYPE.MOUSELEAVE_CELL||r===m.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.display="flex",this.addIconForAddColumn.style.justifyContent="center",this.addIconForAddColumn.style.alignItems="center",this.addIconForAddColumn.style.border="1px solid white",document.body.appendChild(this.addIconForAddColumn);const t=document.createElement("div");t.textContent="+",t.style.color="white",t.style.fontSize="18px",t.style.fontWeight="bold",t.style.lineHeight="15px",t.style.userSelect="none",t.style.cursor="pointer",t.style.verticalAlign="top",t.style.textAlign="center",this.addIconForAddColumn.appendChild(t),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 t=this.leftDotForAddColumn.offsetWidth,e=this.leftDotForAddColumn.offsetHeight;this.showAddIconForAddColumn(this.leftDotForAddColumn.offsetLeft+t/2,this.leftDotForAddColumn.offsetTop+e/2,!0),this.showSplitLineForAddColumn(this.leftDotForAddColumn.offsetLeft+t/2-1,this.leftDotForAddColumn.offsetTop+e/2+2,this.table.getDrawRange().height)})),this.rightDotForAddColumn.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addColumn),this.addIconForAddColumn.style.display="block";const t=this.rightDotForAddColumn.offsetWidth,e=this.rightDotForAddColumn.offsetHeight;this.showAddIconForAddColumn(this.rightDotForAddColumn.offsetLeft+t/2,this.rightDotForAddColumn.offsetTop+e/2,!1),this.showSplitLineForAddColumn(this.rightDotForAddColumn.offsetLeft+t/2-1,this.rightDotForAddColumn.offsetTop+e/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",(t=>{const e="left"===this.addIconForAddColumn.dataset.addIconType,r=this.table.options.columns,n=this.hoverCell.col,i=e?n:n+1;this.pluginOptions.addColumnCallback?this.pluginOptions.addColumnCallback(i,this.table):(r.splice(i,0,{field:"",title:`New Column ${n}`,width:100}),this.table.updateColumns(r)),this.delayHideAllForAddColumn(0)}))}showDotForAddColumn(t,e,r,n=!0,i=!0){const s=this.leftDotForAddColumn.offsetWidth,o=this.leftDotForAddColumn.offsetHeight;this.leftDotForAddColumn.style.left=e-s/2+"px",this.leftDotForAddColumn.style.top=t-o/2+"px",this.rightDotForAddColumn.style.left=r-s/2+"px",this.rightDotForAddColumn.style.top=t-o/2+"px",this.leftDotForAddColumn.style.display=n?"block":"none",this.rightDotForAddColumn.style.display=i?"block":"none"}showAddIconForAddColumn(t,e,r){const n=this.addIconForAddColumn.offsetWidth,i=this.addIconForAddColumn.offsetHeight,s=this.leftDotForAddColumn.offsetHeight;this.addIconForAddColumn.style.left=t-n/2+"px",this.addIconForAddColumn.style.top=e-i/2-s/2+"px",this.addIconForAddColumn.dataset.addIconType=r?"left":"right"}showSplitLineForAddColumn(t,e,r){this.addLineForAddColumn.style.left=`${t}px`,this.addLineForAddColumn.style.top=`${e}px`,this.addLineForAddColumn.style.height=`${r}px`,this.addLineForAddColumn.style.display="block"}delayHideAllForAddColumn(t=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"}),t)}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 t=document.createElement("div");t.textContent="+",t.style.color="white",t.style.fontSize="18px",t.style.fontWeight="bold",t.style.lineHeight="15px",t.style.userSelect="none",t.style.cursor="pointer",t.style.verticalAlign="top",t.style.textAlign="center",this.addIconForAddRow.appendChild(t),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 t=this.topDotForAddRow.offsetWidth,e=this.topDotForAddRow.offsetHeight;this.showAddIconForAddRow(this.topDotForAddRow.offsetLeft+t/2,this.topDotForAddRow.offsetTop+e/2,!0),this.showSplitLineForAddRow(this.topDotForAddRow.offsetLeft+t+2,this.topDotForAddRow.offsetTop+e/2-1,this.table.getDrawRange().width)})),this.bottomDotForAddRow.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addRow),this.addIconForAddRow.style.display="block";const t=this.bottomDotForAddRow.offsetWidth,e=this.bottomDotForAddRow.offsetHeight;this.showAddIconForAddRow(this.bottomDotForAddRow.offsetLeft+t/2,this.bottomDotForAddRow.offsetTop+e/2,!1),this.showSplitLineForAddRow(this.bottomDotForAddRow.offsetLeft+t+2,this.bottomDotForAddRow.offsetTop+e/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",(t=>{const e="top"===this.addIconForAddRow.dataset.addIconType,r=this.hoverCell.row,n=e?r:r+1;if(this.pluginOptions.addRowCallback)this.pluginOptions.addRowCallback(n,this.table);else{const t=this.table.getRecordIndexByCell(0,n);this.table.addRecord({},t)}this.delayHideAllForAddRow(0)}))}showDotForAddRow(t,e,r,n=!0,i=!0){const s=this.topDotForAddRow.offsetWidth,o=this.topDotForAddRow.offsetHeight;this.topDotForAddRow.style.left=e-s/2+"px",this.topDotForAddRow.style.top=t-o/2+"px",this.bottomDotForAddRow.style.left=e-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(t,e,r){const n=this.addIconForAddRow.offsetWidth,i=this.addIconForAddRow.offsetHeight,s=this.topDotForAddRow.offsetWidth;this.addIconForAddRow.style.left=t-n/2-s/2+"px",this.addIconForAddRow.style.top=e-i/2+"px",this.addIconForAddRow.dataset.addIconType=r?"top":"bottom"}showSplitLineForAddRow(t,e,r){this.addLineForAddRow.style.left=`${t}px`,this.addLineForAddRow.style.top=`${e}px`,this.addLineForAddRow.style.width=`${r}px`,this.addLineForAddRow.style.display="block"}delayHideAllForAddRow(t=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"}),t)}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()}},t.AutoFillPlugin=class{id="auto-fill";name="Auto Fill";runTime=[m.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE,m.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END,m.TABLE_EVENT_TYPE.DBLCLICK_FILL_HANDLE];table;autoFillManager;constructor(t){this.autoFillManager=new X4(t)}run(...t){if(t[1]===m.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE){const[e,r,n]=t;this.table=n,this.autoFillManager.setTable(this.table),this.autoFillManager.handleStartDrag(this.table?.getSelectedCellRanges()[0])}else if(t[1]===m.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END){const[{direction:e}]=t;this.autoFillManager.handleEndDrag(this.table?.getSelectedCellRanges()[0],e)}else t[1]===m.TABLE_EVENT_TYPE.DBLCLICK_FILL_HANDLE&&this.autoFillManager.handleDbClick()}},t.CarouselAnimationPlugin=class{table;rowCount;colCount;animationDuration;animationDelay;animationEasing;replaceScrollAction;playing;row;col;willUpdateRow=!1;willUpdateCol=!1;customDistRowFunction;customDistColFunction;constructor(t,e){this.table=t,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.replaceScrollAction=e?.replaceScrollAction??!1,this.customDistColFunction=e.customDistColFunction,this.customDistRowFunction=e.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(t){this.rowCount?(t.deltaY>0?(this.row+=this.rowCount,this.row=Math.min(this.row,this.table.rowCount-this.table.frozenRowCount)):t.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&&(t.deltaX>0?(this.col+=this.colCount,this.col=Math.min(this.col,this.table.colCount-this.table.frozenColCount)):t.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 t=!0;const e=this.customDistRowFunction&&this.customDistRowFunction(this.row,this.table);e?(this.row=e.distRow,t=e.animation??!0):g(this.row)&&this.table.scenegraph.proxy.screenTopRow!==this.row?(this.row=this.table.frozenRowCount,t=!1):g(this.row)||this.table.scenegraph.proxy.screenTopRow===Math.floor(this.row)?this.row+=this.rowCount:(this.row=this.table.frozenRowCount,t=!1),this.table.scrollToRow(this.row,t?{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 t=!0;const e=this.customDistColFunction&&this.customDistColFunction(this.col,this.table);e?(this.col=e.distCol,t=e.animation??!0):g(this.col)&&this.table.scenegraph.proxy.screenLeftCol!==this.col?(this.col=this.table.frozenColCount,t=!1):g(this.col)||this.table.scenegraph.proxy.screenLeftCol===Math.floor(this.col)?this.col+=this.colCount:(this.col=this.table.frozenColCount,t=!1),this.table.scrollToCol(this.col,t?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateCol=!0,setTimeout((()=>{this.willUpdateCol=!1,this.updateCol()}),this.animationDuration+this.animationDelay)}},t.ColumnSeriesPlugin=class{id="column-series";name="Column Series";runTime=[m.TABLE_EVENT_TYPE.BEFORE_INIT,m.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];pluginOptions;table;columns=[];constructor(t){this.id=t.id??this.id,this.pluginOptions=Object.assign({columnCount:100},t)}run(...t){if(t[1]===m.TABLE_EVENT_TYPE.BEFORE_INIT){const e=t[0],r=t[2];this.table=r;const n=e.options;this.columns=this.generateColumns(this.pluginOptions.columnCount),n.columns=this.columns}else if(t[1]===m.TABLE_EVENT_TYPE.BEFORE_KEYDOWN){const e=t[0].event;this.pluginOptions.autoExtendColumnTriggerKeys?.includes(e.key)&&this.table.stateManager.select.cellPos.col===this.table.colCount-1&&this.table.addColumn(this.generateColumn(this.table.colCount-1))}}generateColumns(t){const e=[];for(let r=0;r<t;r++)e.push(this.generateColumn(r));return e}generateColumn(t){return{title:this.pluginOptions.generateColumnTitle?this.pluginOptions.generateColumnTitle(t):this.generateColumnField(t)}}generateColumnField(t){if(t<26)return String.fromCharCode(65+t);const e=[];for(t++;t>0;)t--,e.unshift(String.fromCharCode(65+t%26)),t=Math.floor(t/26);return e.join("")}resetColumnCount(t){this.pluginOptions.columnCount=t,this.columns=this.generateColumns(t),this.table.updateColumns(this.columns)}},t.ConditionFilter=E3,t.ContextMenuPlugin=class{id="context-menu";name="Context Menu";runTime=[m.TABLE_EVENT_TYPE.CONTEXTMENU_CELL,m.TABLE_EVENT_TYPE.PLUGIN_EVENT];pluginOptions;table;menuManager;menuHandler;constructor(t={}){this.id=t.id??this.id,this.pluginOptions=t,this.menuManager=new Ku,this.menuHandler=new e3,this.initDefaultMenuItems()}initDefaultMenuItems(){this.pluginOptions.columnSeriesNumberMenuItems||(this.pluginOptions.columnSeriesNumberMenuItems=ec),this.pluginOptions.rowSeriesNumberMenuItems||(this.pluginOptions.rowSeriesNumberMenuItems=rc),this.pluginOptions.cornerSeriesNumberMenuItems||(this.pluginOptions.cornerSeriesNumberMenuItems=nc),this.pluginOptions.headerCellMenuItems||(this.pluginOptions.headerCellMenuItems=tc),this.pluginOptions.bodyCellMenuItems||(this.pluginOptions.bodyCellMenuItems=Ju)}handleContextMenuCell=(t,e)=>{const{col:r,row:n}=t,i=t.event.clientX,s=t.event.clientY,o=e.isSeriesNumber(r,n);let a=[];if(a=e.isHeader(r,n)?o?this.pluginOptions.columnSeriesNumberMenuItems||[]:this.pluginOptions.headerCellMenuItems||[]:o?this.pluginOptions.rowSeriesNumberMenuItems||[]:this.pluginOptions.bodyCellMenuItems||[],a.length>0){const t=e.getCellRange(r,n);a=t.start.col!==t.end.col||t.start.row!==t.end.row?a.filter((t=>"string"==typeof t||"merge_cells"!==t.menuKey)):a.filter((t=>"string"==typeof t||"unmerge_cells"!==t.menuKey)),this.pluginOptions.beforeShowAdjustMenuItems&&(a=this.pluginOptions.beforeShowAdjustMenuItems(a,e,r,n)),this.showContextMenu(a,i,s,r,n)}};handlePluginEvent=(t,e)=>{const{eventType:r,rowIndex:n,colIndex:i,isCorner:s}=t.pluginEventInfo,o=t.plugin,a=t.event.clientX,l=t.event.clientY;if("table-series-number"===o.id&&"rightclick"===r){let t=[];s?t=this.pluginOptions.cornerSeriesNumberMenuItems||[]:void 0!==n?t=this.pluginOptions.rowSeriesNumberMenuItems||[]:void 0!==i&&(t=this.pluginOptions.columnSeriesNumberMenuItems||[]),this.pluginOptions.beforeShowAdjustMenuItems&&(t=this.pluginOptions.beforeShowAdjustMenuItems(t,e,i,n)),this.showContextMenu(t,a,l,i,n)}};run(...t){const e=t[0],r=t[1],n=t[2];this.table=n,e.event.preventDefault(),r===m.TABLE_EVENT_TYPE.CONTEXTMENU_CELL?this.handleContextMenuCell(e,n):r===m.TABLE_EVENT_TYPE.PLUGIN_EVENT&&this.handlePluginEvent(e,n)}handleMenuClickCallback=(t,e)=>{"function"==typeof this.pluginOptions.menuClickCallback?this.pluginOptions.menuClickCallback(t,e):this.handleMenuClick(t,e)};showContextMenu(t,e,r,n,i){this.menuManager.showMenu(t,e,r,{rowIndex:i,colIndex:n},this.table),this.menuManager.setClickCallback(this.handleMenuClickCallback)}handleMenuClick(e,r){const{menuKey:n,rowIndex:i,colIndex:s,inputValue:o=1}=e;if("object"==typeof this.pluginOptions.menuClickCallback&&this.pluginOptions.menuClickCallback[n])this.pluginOptions.menuClickCallback[n](e,r);else switch(n){case t.MenuKey.COPY:this.menuHandler.handleCopy(r);break;case t.MenuKey.CUT:this.menuHandler.handleCut(r);break;case t.MenuKey.PASTE:this.menuHandler.handlePaste(r);break;case t.MenuKey.INSERT_ROW_ABOVE:this.menuHandler.handleInsertRowAbove(r,i,o);break;case t.MenuKey.INSERT_ROW_BELOW:this.menuHandler.handleInsertRowBelow(r,i,o);break;case t.MenuKey.INSERT_COLUMN_LEFT:this.menuHandler.handleInsertColumnLeft(r,s,o);break;case t.MenuKey.INSERT_COLUMN_RIGHT:this.menuHandler.handleInsertColumnRight(r,s,o);break;case t.MenuKey.DELETE_ROW:this.menuHandler.handleDeleteRow(r,i);break;case t.MenuKey.DELETE_COLUMN:this.menuHandler.handleDeleteColumn(r,s);break;case t.MenuKey.HIDE_COLUMN:this.menuHandler.handleHideColumn(r,s);break;case t.MenuKey.SORT:this.menuHandler.handleSort(r,s);break;case t.MenuKey.MERGE_CELLS:this.menuHandler.handleMergeCells(r);break;case t.MenuKey.UNMERGE_CELLS:this.menuHandler.handleUnmergeCells(r);break;case t.MenuKey.FREEZE_TO_THIS_ROW:this.menuHandler.handleFreezeToRow(r,i);break;case t.MenuKey.FREEZE_TO_THIS_COLUMN:this.menuHandler.handleFreezeToColumn(r,s);break;case t.MenuKey.FREEZE_TO_THIS_ROW_AND_COLUMN:this.menuHandler.handleFreezeToRowAndColumn(r,i,s);break;case t.MenuKey.UNFREEZE:this.menuHandler.handleUnfreeze(r)}}release(){this.menuManager&&(this.menuManager.release(),this.menuManager=null),this.menuHandler&&(this.menuHandler.release(),this.menuHandler=null)}},t.DEFAULT_BODY_MENU_ITEMS=Ju,t.DEFAULT_COLUMN_SERIES_MENU_ITEMS=ec,t.DEFAULT_CORNER_SERIES_MENU_ITEMS=nc,t.DEFAULT_HEADER_MENU_ITEMS=tc,t.DEFAULT_ROW_SERIES_MENU_ITEMS=rc,t.ExcelEditCellKeyboardPlugin=class{id="excel-edit-cell-keyboard";name="Excel Edit Cell Keyboard";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED];table;pluginOptions;constructor(t){this.id=t?.id??this.id,this.pluginOptions=t,this.bindEvent()}run(...t){const e=t[2];this.table=e}bindEvent(){document.addEventListener("keydown",this.handleKeyDown.bind(this),!0)}handleKeyDown(t){if(this.table.editorManager)if("keydown"===this.table.editorManager.beginTriggerEditCellMode){if(this.table.editorManager.editingEditor&&this.isExcelShortcutKey(t)){const{col:e,row:r}=this.table.editorManager.editCell;this.table.editorManager.completeEdit(),this.table.getElement().focus(),t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key?this.table.selectCell(e,r+1):"Tab"===t.key?this.table.selectCell(e+1,r):"ArrowLeft"===t.key?this.table.selectCell(e-1,r):"ArrowRight"===t.key?this.table.selectCell(e+1,r):"ArrowDown"===t.key?this.table.selectCell(e,r+1):"ArrowUp"===t.key&&this.table.selectCell(e,r-1),t.stopPropagation(),t.preventDefault())}}else{const{col:e,row:r}=this.table.stateManager.select.cellPos;if(!this.table.editorManager.editingEditor||"Enter"!==t.key&&"Tab"!==t.key){if("Delete"===t.key){const e=this.table.getSelectedCellInfos();e?.length>0&&function(t,e){for(let r=0;r<t.length;r++)for(let n=0;n<t[r].length;n++)e.changeCellValue(t[r][n].col,t[r][n].row,"")}(e,this.table),t.stopPropagation(),t.preventDefault()}}else this.table.editorManager.completeEdit(),this.table.getElement().focus(),"Enter"===t.key?this.table.selectCell(e,r+1):"Tab"===t.key&&this.table.selectCell(e+1,r),t.stopPropagation(),t.preventDefault()}}isExcelShortcutKey(t){return"Enter"===t.key||"Tab"===t.key||"ArrowLeft"===t.key||"ArrowRight"===t.key||"ArrowDown"===t.key||"ArrowUp"===t.key}release(){document.removeEventListener("keydown",this.handleKeyDown,!0)}},t.ExcelImportPlugin=t3,t.ExportGanttPlugin=class{id="gantt-export-helper";name="Gantt Export Helper";_gantt=null;constructor(){ac()}run(...t){const e=t[0];e&&(this._gantt=e)}async exportToImage(t={}){if(!ac())return;if(!this._gantt)return;const{fileName:e="gantt-export",type:r="png",quality:n=1,backgroundColor:i="#ffffff",scale:s=window.devicePixelRatio||1,download:o=!0}=t;try{const{tempContainer:t,clonedGantt:a}=this.createFullSizeContainer(s);try{await new Promise((t=>requestAnimationFrame(t)));const t=(a.taskListTableInstance.getAllColsWidth()+a.getAllDateColsWidth())*s,l=a.getAllRowsHeight()*s,h=document.createElement("canvas");h.width=t,h.height=l;const u=h.getContext("2d");u.fillStyle=i,u.fillRect(0,0,t,l),a.taskListTableInstance?.canvas&&u.drawImage(a.taskListTableInstance.canvas,0,0,a.taskListTableInstance.getAllColsWidth()*s,l);const c=3*s,d=a.taskListTableInstance.getAllColsWidth()*s;u.fillStyle="rgb(225, 228, 232)",u.fillRect(d-c/2,0,c,l);const p=4*s,f=a.canvas.width-p;return a.canvas&&u.drawImage(a.canvas,p,0,f,a.canvas.height,(a.taskListTableInstance.getAllColsWidth()+1.5)*s,0,(a.getAllDateColsWidth()-1.5)*s,l),this.finalizeExport(h,e,r,n,o)}finally{t.remove(),a.release()}}catch(t){throw new Error(`甘特图导出失败: ${t instanceof Error?t.message:"未知错误"}`)}}async exportToBase64(t={}){return this.exportToImage({...t,download:!1})}async createFullSizeContainer(t){if(!this._gantt)throw new Error("ExportGanttPlugin: Gantt instance not available to create container.");const e=document.createElement("div");e.style.position="fixed",e.style.left="-9999px",e.style.overflow="hidden",e.style.width=`${window.innerWidth+100}px`,e.style.height=`${window.innerHeight+100}px`,document.body.appendChild(e);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`,e.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(t){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(t),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:e,clonedGantt:i}}catch(t){throw e&&e.parentNode&&e.remove(),new Error("导出甘特图需要安装 @visactor/vtable-gantt 依赖")}}finalizeExport(t,e,r,n,i=!0){const s=t.toDataURL(`image/${r}`,n);if(i){const t=document.createElement("a");t.download=`${e}.${r}`,t.href=s,document.body.appendChild(t),t.click(),document.body.removeChild(t)}return s}release(){this._gantt=null}},t.FilterEngine=r3,t.FilterPlugin=class{id="filter";name="Filter";runTime=[m.TABLE_EVENT_TYPE.BEFORE_INIT,m.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION,m.TABLE_EVENT_TYPE.ICON_CLICK];pluginOptions;table;filterEngine;filterStateManager;filterToolbar;constructor(t){this.id=t?.id??this.id,this.pluginOptions=t,this.pluginOptions.filterIcon=t.filterIcon??{name:"filter-icon",type:"svg",width:20,height:20,marginRight:6,positionType:m.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="#333333" p-id="12093"></path></svg>'},this.pluginOptions.filteringIcon=t.filteringIcon??{name:"filtering-icon",type:"svg",width:20,height:20,marginRight:6,positionType:m.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" p-id="11927"></path></svg>'},this.pluginOptions.filterModes&&this.pluginOptions.filterModes.length||(this.pluginOptions.filterModes=["byValue","byCondition"])}run(...t){const e=t[0],r=t[1],n=t[2];if(this.table=n,r===m.TABLE_EVENT_TYPE.BEFORE_INIT)this.filterEngine=new r3,this.filterStateManager=new n3(this.table,this.filterEngine),this.filterToolbar=new A3(this.table,this.filterStateManager),this.filterToolbar.render(document.body),this.updateFilterIcons(e.options);else if(r===m.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION)this.pluginOptions={...this.pluginOptions,...e.options.plugins.find((t=>t.id===this.id)).pluginOptions},this.handleOptionUpdate(e.options);else if(r===m.TABLE_EVENT_TYPE.ICON_CLICK&&"filter-icon"===e.name||"filtering-icon"===e.name){if(3===e.event?.which||2===e.event?.button||2==(2&e.event?.buttons))return;const t=e.col,r=e.row;this.filterToolbar.isVisible?this.filterToolbar.hide():this.filterToolbar.show(t,r,this.pluginOptions.filterModes)}}update(){this.filterStateManager&&this.reapplyActiveFilters()}handleOptionUpdate(t){const e=this.filterStateManager?this.filterStateManager.getActiveFilterFields():[];this.filterStateManager&&e.length>0&&this.validateFilterStatesAfterUpdate(t,e),this.updateFilterIcons(t)}reapplyActiveFilters(){this.filterStateManager.reapplyCurrentFilters()}validateFilterStatesAfterUpdate(e,r){const n=e.columns,i=[];r.forEach((t=>{const e=n.find((e=>e.field===t));e&&this.shouldEnableFilterForColumn(t,e)||i.push(t)})),i.forEach((e=>{this.filterStateManager.dispatch({type:t.FilterActionType.REMOVE_FILTER,payload:{field:e}})}))}updateFilterIcons(t){t.columns.forEach((t=>{this.shouldEnableFilterForColumn(t.field,t)?t.headerIcon=this.pluginOptions.filterIcon:delete t.headerIcon}))}shouldEnableFilterForColumn(t,e){if(!e.title)return!1;const r=e;return void 0!==r.filter?!!r.filter:this.pluginOptions.enableFilter?this.pluginOptions.enableFilter(t,e):void 0===this.pluginOptions.defaultEnabled||this.pluginOptions.defaultEnabled}getFilterState(){if(!this.filterStateManager)return null;const t=this.filterStateManager.getAllFilterStates(),e={};return t.filters.forEach(((t,r)=>{e[r]={enable:t.enable,field:t.field,type:t.type,values:t.values,operator:t.operator,condition:t.condition}})),{filters:e}}setFilterState(e){this.filterStateManager&&e&&e.filters&&(this.filterStateManager.dispatch({type:t.FilterActionType.CLEAR_ALL_FILTERS,payload:{}}),this.table.columns,Object.entries(e.filters).forEach((([,e])=>{e.enable&&this.filterStateManager.dispatch({type:t.FilterActionType.ADD_FILTER,payload:{field:e.field,type:e.type,values:e.values,operator:e.operator,condition:e.condition,enable:!0}})})))}release(){this.table=null,this.filterEngine=null,this.filterStateManager=null,this.filterToolbar=null}},t.FilterStateManager=n3,t.FilterToolbar=A3,t.FocusHighlightPlugin=class{id="focus-highlight";name="Focus Highlight";runTime=[e.TABLE_EVENT_TYPE.INITIALIZED,e.TABLE_EVENT_TYPE.SELECTED_CELL,e.TABLE_EVENT_TYPE.SELECTED_CLEAR];table;range;pluginOptions;constructor(t={fill:"#000",opacity:.5,highlightRange:void 0}){this.id=t.id??this.id,this.pluginOptions=Object.assign({fill:"#000",opacity:.5},t)}run(...t){if(this.table||(this.table=t[2]),t[1]===e.TABLE_EVENT_TYPE.INITIALIZED)this.pluginOptions.highlightRange&&this.setFocusHighlightRange(this.pluginOptions.highlightRange);else if(t[1]===e.TABLE_EVENT_TYPE.SELECTED_CELL){const t=this.table.stateManager.select.cellPos;if(this.table.isHeader(t.col,t.row))this.setFocusHighlightRange(void 0);else{const t=this.table.stateManager.select.ranges,e=0,r=this.table.colCount-1,n=Math.min(t[0].start.row,t[0].end.row),i=Math.max(t[0].start.row,t[0].end.row);this.setFocusHighlightRange({start:{col:e,row:n},end:{col:r,row:i}})}}else t[1]===e.TABLE_EVENT_TYPE.SELECTED_CLEAR&&this.setFocusHighlightRange(void 0)}setFocusHighlightRange(t,e=!1){let r;t&&"start"in t&&"end"in t?r=t:t&&(r={start:t,end:t}),Tu(this.range,r)&&!e||(this.range=r,t?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(t,e){let r;e&&"start"in e&&"end"in e?r=e:e&&(r={start:e,end:e}),t.forEachChildrenSkipChild((t=>{const e=t;"column"===e.role&&e.forEachChildrenSkipChild((t=>{const e=t;if("cell"!==e.role)return;e.attachShadow(e.shadowRoot);const n=e.shadowRoot;if(r){if(Du(r,e.col,e.row))n.removeAllChild();else if(!n.firstChild){const t=ha({x:0,y:0,width:e.attribute.width,height:e.attribute.height,fill:this.pluginOptions.fill,opacity:this.pluginOptions.opacity});t.name="shadow-rect",n.appendChild(t)}}else n.removeAllChild()}))}))}update(){this.setFocusHighlightRange(this.range,!0)}},t.HeaderHighlightPlugin=class{table;options;colHeaderRange;rowHeaderRange;constructor(t,e){this.table=t,this.options=e,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,!0),this.rowHeaderRange&&this.table.arrangeCustomCellStyle({range:this.rowHeaderRange},void 0,!0),this.colHeaderRange=void 0,this.rowHeaderRange=void 0}updateHighlight(){if(!1===this.options?.colHighlight&&!1===this.options?.rowHighlight)return;const t=this.table.getSelectedCellRanges();if(0===t.length)return void this.clearHighlight();const e=t[0],r=[e.start.row,e.end.row];r.sort(((t,e)=>t-e));const n=[e.start.col,e.end.col];let i,s;n.sort(((t,e)=>t-e)),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||ju(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||ju(this.rowHeaderRange,s)||(this.rowHeaderRange&&this.table.arrangeCustomCellStyle({range:this.rowHeaderRange},void 0),s&&this.table.arrangeCustomCellStyle({range:s},"row-highlight"),this.rowHeaderRange=s)}},t.HighlightHeaderWhenSelectCellPlugin=class{id="highlight-header-when-select-cell";name="Highlight Header When Select Cell";runTime=[e.TABLE_EVENT_TYPE.INITIALIZED,e.TABLE_EVENT_TYPE.SELECTED_CLEAR,e.TABLE_EVENT_TYPE.SELECTED_CELL,e.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE];table;pluginOptions;colHeaderRanges=[];rowHeaderRanges=[];constructor(t){this.id=t.id??this.id,this.pluginOptions=t}run(...t){const r=t[1],n=t[2];this.table=n,r===e.TABLE_EVENT_TYPE.SELECTED_CLEAR?this.clearHighlight():r===e.TABLE_EVENT_TYPE.SELECTED_CELL||r===e.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE?this.updateHighlight():r===e.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((t=>{this.table.arrangeCustomCellStyle({range:t},void 0)})),this.rowHeaderRanges&&this.rowHeaderRanges.forEach((t=>{this.table.arrangeCustomCellStyle({range:t},void 0)})),this.colHeaderRanges=[],this.rowHeaderRanges=[]}updateHighlight(){if(!1===this.pluginOptions?.colHighlight&&!1===this.pluginOptions?.rowHighlight)return;const t=this.table.getSelectedCellRanges();t.length<2&&this.clearHighlight();for(let e=0;e<t.length;e++){const r=t[e],n=[r.start.row,r.end.row];n.sort(((t,e)=>t-e));const i=[r.start.col,r.end.col];let s,o;i.sort(((t,e)=>t-e)),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((t=>zu(t,s)))||(s&&this.table.arrangeCustomCellStyle({range:s},"col-highlight"),this.colHeaderRanges.push(s)),!1===this.pluginOptions?.rowHighlight||this.rowHeaderRanges.find((t=>zu(t,o)))||(o&&this.table.arrangeCustomCellStyle({range:o},"row-highlight"),this.rowHeaderRanges.push(o))}}update(){this.registerStyle(),this.updateHighlight()}release(){this.rowHeaderRanges=[],this.colHeaderRanges=[]}},t.InvertHighlightPlugin=class{table;range;_fill;_opacity;constructor(t,e){this.table=t,this._fill=e?.fill??"#000",this._opacity=e?.opacity??.5}setInvertHighlightRange(t){Tu(this.range,t)||(this.range=t,t?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(t,e){t.forEachChildrenSkipChild((t=>{const r=t;"column"===r.role&&r.forEachChildrenSkipChild((t=>{const r=t;if("cell"!==r.role)return;r.attachShadow(r.shadowRoot);const n=r.shadowRoot;if(e){if(Du(e,r.col,r.row))n.removeAllChild();else if(!n.firstChild){const t=ha({x:0,y:0,width:r.attribute.width,height:r.attribute.height,fill:this._fill,opacity:this._opacity});t.name="shadow-rect",n.appendChild(t)}}else n.removeAllChild()}))}))}},t.MENU_CONTAINER_CLASS=Uu,t.MENU_ITEM_CLASS=Hu,t.MENU_ITEM_DISABLED_CLASS=Wu,t.MENU_ITEM_SEPARATOR_CLASS=$u,t.MENU_ITEM_SUBMENU_CLASS=Vu,t.MENU_STYLES=Gu,t.MenuManager=Ku,t.PasteAddRowColumnPlugin=class{id="paste-add-row-column";name="Paste Add row";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED,m.TABLE_EVENT_TYPE.PASTED_DATA];table;pluginOptions;pastedData;constructor(t){this.pluginOptions=t,this.id=t?.id??this.id}run(...t){const e=t[1],r=t[2];this.table=r,e===m.TABLE_EVENT_TYPE.PASTED_DATA&&(this.pastedData=t[0],this.handlePaste())}handlePaste(){const{pasteData:t,row:e,col:r}=this.pastedData,n=this.table.rowCount,i=this.table.colCount,s=e+t.length-n,o=r+(t[0]?.length||0)-i;if(s>0)for(let t=0;t<s;t++)this.pluginOptions?.addRowCallback?this.pluginOptions.addRowCallback(n+t,this.table):this.table.addRecord([]);if(o>0)for(let t=0;t<o;t++){const e=i+t;this.pluginOptions?.addColumnCallback?this.pluginOptions.addColumnCallback(e,this.table):this.table.addColumn({field:`field_${e}`,title:`New Column ${e}`,width:100})}this.table.changeCellValues(r,e,t,!0)}release(){this.table.internalProps.handler.clear()}},t.RotateTablePlugin=class{id="rotate-table";name="Rotate Table";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED];table;matrix;vglobal_mapToCanvasPoint;constructor(t){this.id=t?.id??this.id}run(...t){const e=t[2];this.table=e,this.table.rotate90WithTransform=sc.bind(this.table),this.table.cancelTransform=oc.bind(this.table)}release(){}},t.RowSeriesPlugin=class{id="row-series";name="Row Series";runTime=[e.TABLE_EVENT_TYPE.BEFORE_INIT,e.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];pluginOptions;table;constructor(t){this.id=t.id??this.id,this.pluginOptions=Object.assign({rowCount:100},t)}run(...t){if(t[1]===e.TABLE_EVENT_TYPE.BEFORE_INIT){const e=t[0],r=t[2];this.table=r;const n=e.options,i=n.records??[];for(let t=i.length;t<this.pluginOptions.rowCount;t++)i.push(this.pluginOptions.fillRowRecord?this.pluginOptions.fillRowRecord(t):{});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(t[1]===e.TABLE_EVENT_TYPE.BEFORE_KEYDOWN){const e=t[0].event;this.pluginOptions.autoExtendRowTriggerKeys?.includes(e.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):{})}}},t.TableCarouselAnimationPlugin=class{id="table-carousel-animation";name="Table Carousel Animation";runTime=[e.TABLE_EVENT_TYPE.INITIALIZED];table;rowCount;colCount;animationDuration;animationDelay;animationEasing;playing;row;col;willUpdateRow=!1;willUpdateCol=!1;autoPlay;autoPlayDelay;customDistRowFunction;customDistColFunction;constructor(t={}){this.id=t.id??this.id,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.autoPlay=t?.autoPlay??!1,this.autoPlayDelay=t?.autoPlayDelay??0,this.customDistColFunction=t.customDistColFunction,this.customDistRowFunction=t.customDistRowFunction}run(...t){this.table||(this.table=t[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 t=!0;const e=this.customDistRowFunction&&this.customDistRowFunction(this.row,this.table);e?(this.row=e.distRow,t=e.animation??!0):ic(this.row)&&this.table.scenegraph.proxy.screenTopRow!==this.row?(this.row=this.table.frozenRowCount,t=!1):ic(this.row)||this.table.scenegraph.proxy.screenTopRow===Math.floor(this.row)?this.row+=this.rowCount:(this.row=this.table.frozenRowCount,t=!1),this.table.scrollToRow(this.row,t?{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 t=!0;const e=this.customDistColFunction&&this.customDistColFunction(this.col,this.table);e?(this.col=e.distCol,t=e.animation??!0):ic(this.col)&&this.table.scenegraph.proxy.screenLeftCol!==this.col?(this.col=this.table.frozenColCount,t=!1):ic(this.col)||this.table.scenegraph.proxy.screenLeftCol===Math.floor(this.col)?this.col+=this.colCount:(this.col=this.table.frozenColCount,t=!1),this.table.scrollToCol(this.col,t?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateCol=!0,setTimeout((()=>{this.willUpdateCol=!1,this.updateCol()}),this.animationDuration+this.animationDelay)}release(){}},t.TableExportPlugin=class{id="table-export-plugin";name="TableExport";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED];table;pluginOptions;constructor(t){this.pluginOptions=Object.assign({exportOnIdle:!1,exportExcelOptions:{downloadFile:!0,fileName:"export"},exportCsvOptions:{downloadFile:!0,fileName:"export"}},t)}run(...t){t[1]===m.TABLE_EVENT_TYPE.INITIALIZED&&(t[0],this.table=t[2],this.table.exportToCsv=()=>{const t=this.pluginOptions.exportCsvOptions;return t.downloadFile?async function(t,e){const r=new Blob([`\ufeff${t}`],{type:"text/csv;charset=utf-8"});await e5.saveAs(r,`${e}.csv`)}(Y3(this.table,t),t.fileName||"export"):Y3(this.table,t)},this.table.exportToExcel=async()=>{const t=this.pluginOptions.exportExcelOptions;return t.downloadFile?await async function(t,e){const r=new Blob([t],{type:"application/octet-stream"});await e5.saveAs(r,`${e}.xlsx`)}(await $3(this.table,t,this.pluginOptions.exportOnIdle),t.fileName||"export"):$3(this.table,t,this.pluginOptions.exportOnIdle)})}release(){this.table&&(delete this.table.exportToCsv,delete this.table.exportToExcel,this.table=null)}},t.TableSeriesNumber=class{id="table-series-number";name="Table Series Number";runTime=[e.TABLE_EVENT_TYPE.INITIALIZED,e.TABLE_EVENT_TYPE.BEFORE_INIT,e.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION,e.TABLE_EVENT_TYPE.UPDATED];pluginOptions;table;seriesNumberComponent;componentLayoutLayer;lastCurrentRow=0;lastCurrentCol=0;startRowIndex=0;scrollTimer;constructor(t){this.pluginOptions=t,this.seriesNumberComponent=new Cu({rowCount:t.rowCount,colCount:t.colCount,rowSeriesNumberWidth:t.rowSeriesNumberWidth,colSeriesNumberHeight:t.colSeriesNumberHeight,rowSeriesNumberGenerate:t.rowSeriesNumberGenerate,colSeriesNumberGenerate:t.colSeriesNumberGenerate,rowSeriesNumberCellStyle:t.rowSeriesNumberCellStyle,colSeriesNumberCellStyle:t.colSeriesNumberCellStyle,cornerCellStyle:t.cornerCellStyle}),this.listenComponentEvents()}run(...t){const r=t[1];if(r===e.TABLE_EVENT_TYPE.BEFORE_INIT||r===e.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION){const e=t[0],r=t[2];this.table=r;const n=e.options,i=n.records??[];i.length<this.pluginOptions.rowCount&&(i.length=this.pluginOptions.rowCount),n.records=i,n.columns||(n.columns=[]);for(let t=n.columns.length;t<this.pluginOptions.colCount;t++){const e={field:t,title:""};n.columns.push(e)}const s=this.seriesNumberComponent.rowSeriesNumberWidth,o=this.seriesNumberComponent.colSeriesNumberHeight;n.contentOffsetX=s,n.contentOffsetY=o}else if(r===e.TABLE_EVENT_TYPE.INITIALIZED||r===e.TABLE_EVENT_TYPE.UPDATED){this.table=t[2],this.table.options.customConfig||(this.table.options.customConfig={}),this.table.options.customConfig.cancelSelectCellHook=t=>{if(t.target.isDescendantsOf(this.seriesNumberComponent))return!1},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 e=this.table.scenegraph.stage.createLayer();e.appendChild(this.seriesNumberComponent),e.setAttributes({pickable:!1}),this.componentLayoutLayer=e,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=t=>{this.seriesNumberComponent.removeAllSelectedIndexs();const e=this.table.stateManager.select.ranges,r=[],n=[];for(const t of e){const{row:e,col:i}=t.start,{row:s,col:o}=t.end;r.push({startIndex:Math.min(e,s),endIndex:Math.max(e,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=t=>{this.seriesNumberComponent.setAttribute("hover",!0)};handleResizeRowEnd=t=>{this.seriesNumberComponent.setAttribute("hover",!0)};listenTableEvents(){this.table.on(e.TABLE_EVENT_TYPE.SCROLL,this.handleScroll),this.table.on(e.TABLE_EVENT_TYPE.AFTER_SORT,this.handleAfterSort),this.table.on(e.TABLE_EVENT_TYPE.SELECTED_CHANGED,this.handleSelectedChanged),this.table.on(e.TABLE_EVENT_TYPE.RESIZE_COLUMN_END,this.handleResizeColumnEnd),this.table.on(e.TABLE_EVENT_TYPE.RESIZE_ROW_END,this.handleResizeRowEnd)}handleSeriesNumberCellRightClick=t=>{const{seriesNumberCell:r,event:n,isDragSelect:i}=t.detail,s=r.name.includes("row"),o=r.name.includes("col");if(s){const t=r.id,i=this.table.stateManager.select.ranges.some((e=>e.start.row<=t&&t<=e.end.row&&0===e.start.col&&e.end.col===this.table.colCount-1));i||this.table.selectCells([{start:{row:t,col:0},end:{row:t,col:this.table.colCount-1}}]),this.table.fireListeners(e.TABLE_EVENT_TYPE.PLUGIN_EVENT,{plugin:this,event:n,pluginEventInfo:{eventType:"rightclick",rowIndex:t}})}else if(o){const t=r.id,i=this.table.stateManager.select.ranges.some((e=>e.start.col<=t&&t<=e.end.col&&0===e.start.row&&e.end.row===this.table.rowCount-1));i||this.table.selectCells([{start:{row:0,col:t},end:{row:this.table.rowCount-1,col:t}}]),this.table.fireListeners(e.TABLE_EVENT_TYPE.PLUGIN_EVENT,{plugin:this,event:n,pluginEventInfo:{eventType:"rightclick",colIndex:t}})}else this.table.selectCells([{start:{row:0,col:0},end:{row:this.table.rowCount-1,col:this.table.colCount-1}}]),this.table.fireListeners(e.TABLE_EVENT_TYPE.PLUGIN_EVENT,{plugin:this,event:n,pluginEventInfo:{eventType:"rightclick",isCorner:!0}})};handleSeriesNumberCellHover=t=>{this.table.scenegraph.renderSceneGraph()};handleSeriesNumberCellUnHover=t=>{this.table.scenegraph.renderSceneGraph()};handleSeriesNumberCellClick=t=>{const{seriesNumberCell:e,event:r,isDragSelect:n}=t.detail,i=r.nativeEvent.ctrlKey||r.nativeEvent.metaKey,s=r.nativeEvent.shiftKey,o=e.name.includes("row"),a=e.name.includes("col");if(o){this.table.stateManager.setSelectInline("row");const t=e.id;n?this.table.dragSelectRow(t,i):this.table.startDragSelectRow(t,i,s)}else if(a){this.table.stateManager.setSelectInline("col");const t=e.id;n?this.table.dragSelectCol(t,i):this.table.startDragSelectCol(t,i,s)}else this.table.eventManager.deelTableSelectAll()};handleSeriesNumberCellClickUp=t=>{this.table.stateManager.setSelectInline(!1),this.table.endDragSelect()};handleRowSeriesNumberWidthChange=t=>{const e=this.seriesNumberComponent.rowSeriesNumberWidth,r=this.seriesNumberComponent.colSeriesNumberHeight;this.table.setContentInsetXY(e,r)};handleResizeColWidthStart=t=>{this.seriesNumberComponent.setAttribute("hover",!1);const{colIndex:r,event:n}=t.detail;this.table.stateManager.updateInteractionState(e.TYPES.InteractionState.grabing),this.table.stateManager.startResizeCol(r,n.viewport.x,n.viewport.y)};handleResizeRowHeightStart=t=>{this.seriesNumberComponent.setAttribute("hover",!1);const{rowIndex:r,event:n}=t.detail;this.table.stateManager.updateInteractionState(e.TYPES.InteractionState.grabing),this.table.stateManager.startResizeRow(r,n.viewport.x,n.viewport.y)};listenComponentEvents(){this.seriesNumberComponent.on(xu.seriesNumberCellRightClick,this.handleSeriesNumberCellRightClick),this.seriesNumberComponent.on(xu.seriesNumberCellHover,this.handleSeriesNumberCellHover),this.seriesNumberComponent.on(xu.seriesNumberCellUnHover,this.handleSeriesNumberCellUnHover),this.seriesNumberComponent.on(xu.seriesNumberCellClick,this.handleSeriesNumberCellClick),this.seriesNumberComponent.on(xu.seriesNumberCellClickUp,this.handleSeriesNumberCellClickUp),this.seriesNumberComponent.on(xu.rowSeriesNumberWidthChange,this.handleRowSeriesNumberWidthChange),this.seriesNumberComponent.on(xu.resizeColWidthStart,this.handleResizeColWidthStart),this.seriesNumberComponent.on(xu.resizeRowHeightStart,this.handleResizeRowHeightStart)}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(e.TABLE_EVENT_TYPE.SCROLL,this.handleScroll),this.table.off(e.TABLE_EVENT_TYPE.AFTER_SORT,this.handleAfterSort),this.table.off(e.TABLE_EVENT_TYPE.SELECTED_CHANGED,this.handleSelectedChanged),this.table.off(e.TABLE_EVENT_TYPE.RESIZE_COLUMN_END,this.handleResizeColumnEnd),this.table.off(e.TABLE_EVENT_TYPE.RESIZE_ROW_END,this.handleResizeRowEnd)),this.seriesNumberComponent&&(this.seriesNumberComponent.off(xu.seriesNumberCellRightClick,this.handleSeriesNumberCellRightClick),this.seriesNumberComponent.off(xu.seriesNumberCellHover,this.handleSeriesNumberCellHover),this.seriesNumberComponent.off(xu.seriesNumberCellUnHover,this.handleSeriesNumberCellUnHover),this.seriesNumberComponent.off(xu.seriesNumberCellClick,this.handleSeriesNumberCellClick),this.seriesNumberComponent.off(xu.seriesNumberCellClickUp,this.handleSeriesNumberCellClickUp),this.seriesNumberComponent.off(xu.rowSeriesNumberWidthChange,this.handleRowSeriesNumberWidthChange),this.seriesNumberComponent.off(xu.resizeColWidthStart,this.handleResizeColWidthStart),this.seriesNumberComponent.off(xu.resizeRowHeightStart,this.handleResizeRowHeightStart),this.seriesNumberComponent.release?.(),this.seriesNumberComponent=null)}syncRowHeightToComponent(){const{rowStart:t,rowEnd:e}=this.table.getBodyVisibleRowRange(),r=Math.max(t-2,this.table.frozenRowCount),n=Math.min(e+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 t=0;t<this.table.frozenRowCount;t++){const e=this.table.scenegraph.getCell(0,t).getAttributes();this.seriesNumberComponent.setRowSeriesNumberCellAttributes(t,{y:e.y,height:e.height})}for(let t=r;t<=n;t++){const e=this.table.scenegraph.getCell(0,t).getAttributes();this.seriesNumberComponent.setRowSeriesNumberCellAttributes(t,{y:e.y,height:e.height})}}syncColWidthToComponent(){const{colStart:t,colEnd:e}=this.table.getBodyVisibleColRange(),r=t,n=Math.min(e,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 t=0;t<this.table.frozenColCount;t++){const e=this.table.scenegraph.getColGroup(t).getAttributes();this.seriesNumberComponent.setColSeriesNumberCellAttributes(t,{x:e.x,width:e.width})}for(let t=r;t<=n;t++){const e=this.table.scenegraph.getColGroup(t).getAttributes();this.seriesNumberComponent.setColSeriesNumberCellAttributes(t,{x:e.x,width:e.width})}}syncScrollToComponent(){this.syncRowHeightToComponent(),this.syncColWidthToComponent();const t=this.table.scenegraph.bodyGroup.getAttributes().y,e=this.table.scenegraph.bodyGroup.getAttributes().x;this.seriesNumberComponent.setRowSeriesNumberGroupAttributes({y:t+this.seriesNumberComponent.colSeriesNumberHeight}),this.seriesNumberComponent.setColSeriesNumberGroupAttributes({x:e+this.seriesNumberComponent.rowSeriesNumberWidth})}},t.ValueFilter=T3,t.WpsFillHandlePlugin=class{id="wps-fill-handle";name="WPS Fill Handle";runTime=[m.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE,m.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END];table;pluginOptions;beforeDragMinCol=0;beforeDragMinRow=0;beforeDragMaxCol=0;beforeDragMaxRow=0;constructor(t){this.id=t?.id??this.id,this.pluginOptions=t}run(...t){if(t[1]===m.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE){t[0];const e=t[2];this.table=e;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(t[1]===m.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END){const e=t[0].direction;let r,n;const i=this.table?.getSelectedCellRanges()[0];if(!i)return;"bottom"===e?(r=this.beforeDragMaxCol,n=i.end.row):"right"===e?(r=i.end.col,n=this.beforeDragMaxRow):"top"===e?(r=this.beforeDragMaxCol,n=i.end.row):"left"===e&&(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=sg(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 t=this.table?.getSelectedCellRanges()[0];if(!t)return;this.beforeDragMaxCol=Math.max(t.start.col,t.end.col),this.beforeDragMinCol=Math.min(t.start.col,t.end.col),this.beforeDragMaxRow=Math.max(t.start.row,t.end.row),this.beforeDragMinRow=Math.min(t.start.row,t.end.row)}}release(){this.beforeDragMinCol=0,this.beforeDragMinRow=0,this.beforeDragMaxCol=0,this.beforeDragMaxRow=0}},t.applyStyles=Yu,t.cancelTransform=oc,t.createElement=Xu,t.createIcon=qu,t.createNumberInputItem=function(t,e=1,r,n){const i=Xu("div");if(Yu(i,Gu.inputContainer),r){const t=qu(r);i.appendChild(t)}const s=Xu("label");s.textContent=t,Yu(s,Gu.inputLabel),i.appendChild(s);const o=Xu("input");o.type="number",o.min="1",o.value=e.toString(),Yu(o,Gu.inputField),i.appendChild(o);const a=Xu("div");return a.appendChild(i),a},t.rotate90WithTransform=sc}));
|
|
91
|
+
*/!function(t){const e=n,i=p,s=h,o=r,a={fs:e.constants,os:i.constants},l="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",u=/XXXXXX/,c=3,d=(a.O_CREAT||a.fs.O_CREAT)|(a.O_EXCL||a.fs.O_EXCL)|(a.O_RDWR||a.fs.O_RDWR),f="win32"===i.platform(),m=a.EBADF||a.os.errno.EBADF,g=a.ENOENT||a.os.errno.ENOENT,y=[],b=e.rmdirSync.bind(e);let v=!1;function _(t,r){return e.rm(t,{recursive:!0},r)}function w(t){return e.rmSync(t,{recursive:!0})}function x(t,r){const n=N(t,r),s=n[0],o=n[1];!function(t,r){!function(t,r){e.realpath(t&&t.tmpdir||i.tmpdir(),r)}(t,(function(e,n){if(e)return r(e);t.tmpdir=n;try{I(t)}catch(e){return r(e)}P("dir",t.dir,n,(function(e,i){if(e)return r(e);t.dir=O(i)?"":i,P("template",t.template,n,(function(e,n){if(e)return r(e);t.template=n,r(null,t)}))}))}))}(s,(function(t,r){if(t)return o(t);let n=r.tries;!function t(){try{const i=M(r);e.stat(i,(function(e){if(!e)return n-- >0?t():o(new Error("Could not get a unique tmp filename, max tries reached "+i));o(null,i)}))}catch(t){o(t)}}()}))}function S(t){const r=function(t){const e=t.tmpdir=D(t);I(t);const r=B("dir",t.dir,e);return t.dir=O(r)?"":r,t.template=B("template",t.template,e),t}(N(t)[0]);let n=r.tries;do{const t=M(r);try{e.statSync(t)}catch(e){return t}}while(n-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function C(t,r){const n=function(t){if(t&&!L(t))return r(t);r()};0<=t[0]?e.close(t[0],(function(){e.unlink(t[1],n)})):e.unlink(t[1],n)}function T(t){let r=null;try{0<=t[0]&&e.closeSync(t[0])}catch(t){if(!function(t){return F(t,-m,"EBADF")}(t)&&!L(t))throw t}finally{try{e.unlinkSync(t[1])}catch(t){L(t)||(r=t)}}if(null!==r)throw r}function E(t,e,r,n){const i=k(T,[e,t],n),s=k(C,[e,t],n,i);return r.keep||y.unshift(i),n?i:s}function A(t,r,n){const i=r.unsafeCleanup?_:e.rmdir.bind(e),s=k(r.unsafeCleanup?w:b,t,n),o=k(i,t,n,s);return r.keep||y.unshift(s),n?s:o}function k(t,e,r,n){let i=!1;return function s(o){if(!i){const a=n||s,l=y.indexOf(a);return l>=0&&y.splice(l,1),i=!0,r||t===b||t===w?t(e):t(e,o||function(){})}}}function R(t){let e=[],r=null;try{r=o.randomBytes(t)}catch(e){r=o.pseudoRandomBytes(t)}for(let n=0;n<t;n++)e.push(l[r[n]%l.length]);return e.join("")}function O(t){return void 0===t}function N(t,e){if("function"==typeof t)return[{},t];if(O(t))return[{},e];const r={};for(const e of Object.getOwnPropertyNames(t))r[e]=t[e];return[r,e]}function M(t){const e=t.tmpdir;if(!O(t.name))return s.join(e,t.dir,t.name);if(!O(t.template))return s.join(e,t.dir,t.template).replace(u,R(6));const r=[t.prefix?t.prefix:"tmp","-",process.pid,"-",R(12),t.postfix?"-"+t.postfix:""].join("");return s.join(e,t.dir,r)}function I(t){if(!O(t.name)){const e=t.name;if(s.isAbsolute(e))throw new Error(`name option must not contain an absolute path, found "${e}".`);const r=s.basename(e);if(".."===r||"."===r||r!==e)throw new Error(`name option must not contain a path, found "${e}".`)}if(!O(t.template)&&!t.template.match(u))throw new Error(`Invalid template, found "${t.template}".`);if(!O(t.tries)&&isNaN(t.tries)||t.tries<0)throw new Error(`Invalid tries, found "${t.tries}".`);t.tries=O(t.name)?t.tries||c:1,t.keep=!!t.keep,t.detachDescriptor=!!t.detachDescriptor,t.discardDescriptor=!!t.discardDescriptor,t.unsafeCleanup=!!t.unsafeCleanup,t.prefix=O(t.prefix)?"":t.prefix,t.postfix=O(t.postfix)?"":t.postfix}function P(t,r,n,i){if(O(r))return i(null);!function(t,r,n){const i=s.isAbsolute(t)?t:s.join(r,t);e.stat(i,(function(t){t?e.realpath(s.dirname(i),(function(t,e){if(t)return n(t);n(null,s.join(e,s.basename(i)))})):e.realpath(s,n)}))}(r,n,(function(e,r){if(e)return i(e);const o=s.relative(n,r);if(!r.startsWith(n))return i(new Error(`${t} option must be relative to "${n}", found "${o}".`));i(null,o)}))}function B(t,r,n){if(O(r))return;const i=function(t,r){const n=s.isAbsolute(t)?t:s.join(r,t);try{return e.statSync(n),e.realpathSync(n)}catch(t){const r=e.realpathSync(s.dirname(n));return s.join(r,s.basename(n))}}(r,n),o=s.relative(n,i);if(!i.startsWith(n))throw new Error(`${t} option must be relative to "${n}", found "${o}".`);return o}function L(t){return F(t,-g,"ENOENT")}function F(t,e,r){return f?t.code===r:t.code===r&&t.errno===e}function D(t){return e.realpathSync(t&&t.tmpdir||i.tmpdir())}process.addListener("exit",(function(){if(v)for(;y.length;)try{y[0]()}catch(t){}})),Object.defineProperty(t.exports,"tmpdir",{enumerable:!0,configurable:!1,get:function(){return D()}}),t.exports.dir=function(t,r){const n=N(t,r),i=n[0],s=n[1];x(i,(function(t,r){if(t)return s(t);e.mkdir(r,i.mode||448,(function(t){if(t)return s(t);s(null,r,A(r,i,!1))}))}))},t.exports.dirSync=function(t){const r=N(t)[0],n=S(r);return e.mkdirSync(n,r.mode||448),{name:n,removeCallback:A(n,r,!0)}},t.exports.file=function(t,r){const n=N(t,r),i=n[0],s=n[1];x(i,(function(t,r){if(t)return s(t);e.open(r,d,i.mode||384,(function(t,n){if(t)return s(t);if(i.discardDescriptor)return e.close(n,(function(t){return s(t,r,void 0,E(r,-1,i,!1))}));{const t=i.discardDescriptor||i.detachDescriptor;s(null,r,n,E(r,t?-1:n,i,!1))}}))}))},t.exports.fileSync=function(t){const r=N(t)[0],n=r.discardDescriptor||r.detachDescriptor,i=S(r);let s=e.openSync(i,d,r.mode||384);return r.discardDescriptor&&(e.closeSync(s),s=void 0),{name:i,fd:s,removeCallback:E(i,n?-1:s,r,!0)}},t.exports.tmpName=x,t.exports.tmpNameSync=S,t.exports.setGracefulCleanup=function(){v=!0}}(g2);var y2=g2.exports;function b2(t,e){return new Promise((r=>{let n=!1;const i=()=>{n||(n=!0,t.removeListener(e,i),r())};t.addListener(e,i)}))}const{EventEmitter:v2}=s,_2=AE,w2=hg,x2=cT,S2=dg,C2=fg,T2=Pg,E2=Dg;let A2=class extends v2{constructor({workbook:t,id:e,iterator:r,options:n}){super(),this.workbook=t,this.id=e,this.iterator=r,this.options=n||{},this.name=`Sheet${this.id}`,this._columns=null,this._keys={},this._dimensions=new C2}destroy(){throw new Error("Invalid Operation: destroy")}get dimensions(){return this._dimensions}get columns(){return this._columns}getColumn(t){if("string"==typeof t){const e=this._keys[t];if(e)return e;t=S2.l2n(t)}if(this._columns||(this._columns=[]),t>this._columns.length){let e=this._columns.length+1;for(;e<=t;)this._columns.push(new E2(this,e++))}return this._columns[t-1]}getColumnKey(t){return this._keys[t]}setColumnKey(t,e){this._keys[t]=e}deleteColumnKey(t){delete this._keys[t]}eachColumnKey(t){w2.each(this._keys,t)}async read(){try{for await(const t of this.parse())for(const{eventType:e,value:r}of t)this.emit(e,r);this.emit("finished")}catch(t){this.emit("error",t)}}async*[Symbol.asyncIterator](){for await(const t of this.parse())for(const{eventType:e,value:r}of t)"row"===e&&(yield r)}async*parse(){const{iterator:t,options:e}=this;let r=!1,n=!1,i=null;if("emit"===e.worksheets)r=!0;switch(e.hyperlinks){case"emit":n=!0;break;case"cache":this.hyperlinks=i={}}if(!r&&!n&&!i)return;const{sharedStrings:s,styles:o,properties:a}=this.workbook;let l=!1,h=!1,u=!1,c=null,d=null,p=null,f=null;for await(const e of _2(t)){const t=[];for(const{eventType:m,value:g}of e)if("opentag"===m){const e=g;if(r)switch(e.name){case"cols":l=!0,c=[];break;case"sheetData":h=!0;break;case"col":l&&c.push({min:parseInt(e.attributes.min,10),max:parseInt(e.attributes.max,10),width:parseFloat(e.attributes.width),styleId:parseInt(e.attributes.style||"0",10)});break;case"row":if(h){const t=parseInt(e.attributes.r,10);if(d=new T2(this,t),e.attributes.ht&&(d.height=parseFloat(e.attributes.ht)),e.attributes.s){const t=parseInt(e.attributes.s,10),r=o.getStyleModel(t);r&&(d.style=r)}}break;case"c":d&&(p={ref:e.attributes.r,s:parseInt(e.attributes.s,10),t:e.attributes.t});break;case"f":p&&(f=p.f={text:""});break;case"v":case"is":case"t":p&&(f=p.v={text:""})}if(n||i)switch(e.name){case"hyperlinks":u=!0;break;case"hyperlink":if(u){const r={ref:e.attributes.ref,rId:e.attributes["r:id"]};n?t.push({eventType:"hyperlink",value:r}):i[r.ref]=r}}}else if("text"===m)r&&f&&(f.text+=g);else if("closetag"===m){const e=g;if(r)switch(e.name){case"cols":l=!1,this._columns=E2.fromModel(c);break;case"sheetData":h=!1;break;case"row":this._dimensions.expandRow(d),t.push({eventType:"row",value:d}),d=null;break;case"c":if(d&&p){const t=S2.decodeAddress(p.ref),e=d.getCell(t.col);if(p.s){const t=o.getStyleModel(p.s);t&&(e.style=t)}if(p.f){const t={formula:p.f.text};p.v&&("str"===p.t?t.result=x2.xmlDecode(p.v.text):t.result=parseFloat(p.v.text)),e.value=t}else if(p.v)switch(p.t){case"s":{const t=parseInt(p.v.text,10);e.value=s?s[t]:{sharedString:t};break}case"inlineStr":case"str":e.value=x2.xmlDecode(p.v.text);break;case"e":e.value={error:p.v.text};break;case"b":e.value=0!==parseInt(p.v.text,10);break;default:x2.isDateFmt(e.numFmt)?e.value=x2.excelToDate(parseFloat(p.v.text),a.model&&a.model.date1904):e.value=parseFloat(p.v.text)}if(i){const t=i[p.ref];t&&(e.text=e.value,e.value=void 0,e.hyperlink=t)}p=null}}if((n||i)&&"hyperlinks"===e.name)u=!1}t.length>0&&(yield t)}}};var k2=A2;const{EventEmitter:R2}=s,O2=AE,N2=mg,M2=CR;var I2=class extends R2{constructor({workbook:t,id:e,iterator:r,options:n}){super(),this.workbook=t,this.id=e,this.iterator=r,this.options=n}get count(){return this.hyperlinks&&this.hyperlinks.length||0}each(t){return this.hyperlinks.forEach(t)}async read(){const{iterator:t,options:e}=this;let r=!1,n=null;switch(e.hyperlinks){case"emit":r=!0;break;case"cache":this.hyperlinks=n={}}if(r||n)try{for await(const e of O2(t))for(const{eventType:t,value:i}of e)if("opentag"===t){const t=i;if("Relationship"===t.name){const e=t.attributes.Id;if(t.attributes.Type===M2.Hyperlink){const i={type:N2.RelationshipType.Styles,rId:e,target:t.attributes.Target,targetMode:t.attributes.TargetMode};r?this.emit("hyperlink",i):n[i.rId]=i}}}this.emit("finished")}catch(t){this.emit("error",t)}else this.emit("finished")}};const P2=n,{EventEmitter:B2}=s,{PassThrough:L2,Readable:F2}=aT,D2=i,j2=HZ,z2=y2,U2=async function*(t){const e=[];let r;t.on("data",(t=>e.push(t)));const n=new Promise((t=>r=t));let i=!1;t.on("end",(()=>{i=!0,r()}));let s=!1;for(t.on("error",(t=>{s=t,r()}));!i||e.length>0;){if(0===e.length)t.resume(),await Promise.race([b2(t,"data"),n]);else{t.pause();const r=e.shift();yield r}if(s)throw s}r()},H2=AE,W2=JA,$2=SR,V2=Bk,G2=k2,X2=I2;z2.setGracefulCleanup();class Y2 extends B2{constructor(t,e={}){super(),this.input=t,this.options={worksheets:"emit",sharedStrings:"cache",hyperlinks:"ignore",styles:"ignore",entries:"ignore",...e},this.styles=new W2,this.styles.init()}_getStream(t){if(t instanceof D2.Readable||t instanceof F2)return t;if("string"==typeof t)return P2.createReadStream(t);throw new Error(`Could not recognise input: ${t}`)}async read(t,e){try{for await(const{eventType:r,value:n}of this.parse(t,e))switch(r){case"shared-strings":case"hyperlinks":this.emit(r,n);break;case"worksheet":this.emit(r,n),await n.read()}this.emit("end"),this.emit("finished")}catch(t){this.emit("error",t)}}async*[Symbol.asyncIterator](){for await(const{eventType:t,value:e}of this.parse())"worksheet"===t&&(yield e)}async*parse(t,e){e&&(this.options=e);const r=this.stream=this._getStream(t||this.input),n=j2.Parse({forceStream:!0});r.pipe(n);const i=[];for await(const t of U2(n)){let e,r;switch(t.path){case"_rels/.rels":break;case"xl/_rels/workbook.xml.rels":await this._parseRels(t);break;case"xl/workbook.xml":await this._parseWorkbook(t);break;case"xl/sharedStrings.xml":yield*this._parseSharedStrings(t);break;case"xl/styles.xml":await this._parseStyles(t);break;default:t.path.match(/xl\/worksheets\/sheet\d+[.]xml/)?(e=t.path.match(/xl\/worksheets\/sheet(\d+)[.]xml/),r=e[1],this.sharedStrings&&this.workbookRels?yield*this._parseWorksheet(U2(t),r):await new Promise(((e,n)=>{z2.file(((s,o,a,l)=>{if(s)return n(s);i.push({sheetNo:r,path:o,tempFileCleanupCallback:l});const h=P2.createWriteStream(o);return h.on("error",n),t.pipe(h),h.on("finish",(()=>e()))}))}))):t.path.match(/xl\/worksheets\/_rels\/sheet\d+[.]xml.rels/)&&(e=t.path.match(/xl\/worksheets\/_rels\/sheet(\d+)[.]xml.rels/),r=e[1],yield*this._parseHyperlinks(U2(t),r))}t.autodrain()}for(const{sheetNo:t,path:e,tempFileCleanupCallback:r}of i){let n=P2.createReadStream(e);n[Symbol.asyncIterator]||(n=n.pipe(new L2)),yield*this._parseWorksheet(n,t),r()}}_emitEntry(t){"emit"===this.options.entries&&this.emit("entry",t)}async _parseRels(t){const e=new V2;this.workbookRels=await e.parseStream(U2(t))}async _parseWorkbook(t){this._emitEntry({type:"workbook"});const e=new $2;await e.parseStream(U2(t)),this.properties=e.map.workbookPr,this.model=e.model}async*_parseSharedStrings(t){switch(this._emitEntry({type:"shared-strings"}),this.options.sharedStrings){case"cache":this.sharedStrings=[];break;case"emit":break;default:return}let e=null,r=[],n=0,i=null;for await(const s of H2(U2(t)))for(const{eventType:t,value:o}of s)if("opentag"===t){const t=o;switch(t.name){case"b":i=i||{},i.bold=!0;break;case"charset":i=i||{},i.charset=parseInt(t.attributes.charset,10);break;case"color":i=i||{},i.color={},t.attributes.rgb&&(i.color.argb=t.attributes.argb),t.attributes.val&&(i.color.argb=t.attributes.val),t.attributes.theme&&(i.color.theme=t.attributes.theme);break;case"family":i=i||{},i.family=parseInt(t.attributes.val,10);break;case"i":i=i||{},i.italic=!0;break;case"outline":i=i||{},i.outline=!0;break;case"rFont":i=i||{},i.name=t.value;break;case"si":i=null,r=[],e=null;break;case"sz":i=i||{},i.size=parseInt(t.attributes.val,10);break;case"strike":break;case"t":e=null;break;case"u":i=i||{},i.underline=!0;break;case"vertAlign":i=i||{},i.vertAlign=t.attributes.val}}else if("text"===t)e=e?e+o:o;else if("closetag"===t){switch(o.name){case"r":r.push({font:i,text:e}),i=null,e=null;break;case"si":"cache"===this.options.sharedStrings?this.sharedStrings.push(r.length?{richText:r}:e):"emit"===this.options.sharedStrings&&(yield{index:n++,text:r.length?{richText:r}:e}),r=[],i=null,e=null}}}async _parseStyles(t){this._emitEntry({type:"styles"}),"cache"===this.options.styles&&(this.styles=new W2,await this.styles.parseStream(U2(t)))}*_parseWorksheet(t,e){this._emitEntry({type:"worksheet",id:e});const r=new G2({workbook:this,id:e,iterator:t,options:this.options}),n=(this.workbookRels||[]).find((t=>t.Target===`worksheets/sheet${e}.xml`)),i=n&&(this.model.sheets||[]).find((t=>t.rId===n.Id));i&&(r.id=i.id,r.name=i.name,r.state=i.state),"emit"===this.options.worksheets&&(yield{eventType:"worksheet",value:r})}*_parseHyperlinks(t,e){this._emitEntry({type:"hyperlinks",id:e});const r=new X2({workbook:this,id:e,iterator:t,options:this.options});"emit"===this.options.hyperlinks&&(yield{eventType:"hyperlinks",value:r})}}Y2.Options={worksheets:["emit","ignore"],sharedStrings:["cache","emit","ignore"],hyperlinks:["cache","emit","ignore"],styles:["cache","ignore"],entries:["emit","ignore"]};const q2={Workbook:rj,ModelContainer:ij,stream:{xlsx:{WorkbookWriter:UZ,WorkbookReader:Y2}}};Object.assign(q2,mg);var K2=q2;if(parseInt(process.versions.node.split(".")[0],10)<10)throw new Error("For node versions older than 10, please use the ES5 Import: https://github.com/exceljs/exceljs#es5-imports");var Z2,Q2,J2=pt(K2);class t3{id="excel-import-plugin";name="ExcelImportPlugin";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED];options;_tableInstance=null;constructor(t){this.options={autoTable:!0,autoColumns:!0,delimiter:",",exportData:!1,batchSize:1e3,enableBatchProcessing:!0,asyncDelay:5,...t},t?.id&&(this.id=t.id)}run(...t){const e=t[2];this._tableInstance=e,this._tableInstance.importFile=()=>{this.import("file")}}release(){this._tableInstance=null}async importFile(){return this.import("file")}async import(t,e,r){const n={...this.options,...r};if("file"===t)return this._importFromFileDialog(n);if("string"==typeof e)return this._importFromString(t,e,n);if(Array.isArray(e)||"object"==typeof e){if("json"!==t)throw new Error("只有JSON格式支持从对象导入");return this._importFromData("json",e,n)}throw new Error("Invalid import source")}async _importFromFileDialog(t){return new Promise(((e,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,t);t.autoTable&&this._tableInstance&&(t.autoColumns&&this._tableInstance.updateOption(Object.assign({},this._tableInstance.options,{columns:o.columns})),this._tableInstance.setRecords(o.records)),n.value="",document.body.removeChild(n),e(o)}catch(t){document.body.removeChild(n),r(t)}})),n.click()}))}async _importFromString(t,e,r){let n;switch(t){case"csv":n=await this._parseCSVString(e,r);break;case"json":n=await this._parseJSONString(e,r);break;case"html":n=await this._parseHTMLString(e,r);break;default:throw new Error(`不支持的导入类型: ${t}`)}return r.autoTable&&this._tableInstance&&(r.autoColumns&&this._tableInstance.updateOption({columns:n.columns,plugins:[this]}),this._tableInstance.setRecords(n.records)),n}async _importFromData(t,e,r){let n;if("json"!==t)throw new Error(`不支持的数据类型: ${t}`);return n=await this._parseJSONData(e,r),r.autoTable&&this._tableInstance&&(r.autoColumns&&this._tableInstance.updateOption({columns:n.columns,plugins:[this]}),this._tableInstance.setRecords(n.records)),n}async _parseFile(t,e){const r={...this.options,...e},n=this._getFileExtension(t.name).toLowerCase();switch(n){case"xlsx":case"xls":return await this._parseExcelFile(t,r);case"csv":return await this._parseCsvFile(t,r);case"json":return await this._parseJsonFile(t,r);case"html":case"htm":return await this._parseHtmlFile(t,r);default:throw new Error(`不支持的文件类型: ${n}`)}}_getFileExtension(t){const e=t.split(".");return e.length>1?e[e.length-1]:""}async _parseExcelFile(t,e){const r={...this.options,...e};return await t3.importExcelToVTableData(t,r)}async _parseCsvFile(t,e){const r={...this.options,...e},n=await t.text();return this._parseCSVString(n,r)}async _parseJsonFile(t,e){const r={...this.options,...e},n=await t.text();return this._parseJSONString(n,r)}async _parseHtmlFile(t,e){const r={...this.options,...e},n=await t.text();return this._parseHTMLString(n,r)}_buildColumnsFromHeaders(t){return 1===t.length?t[0].map(((t,e)=>({field:`col${e}`,title:t||`列${e+1}`,cellType:"text",headerType:"text"}))):t3.buildColumns(t)}static async importExcelToVTableData(t,e){const r=new J2.Workbook;await r.xlsx.load(await t.arrayBuffer());const n=r.worksheets[0];if(!n)throw new Error("Excel 文件无有效工作表");const i=e?.headerRowCount??this.detectHeaderRowCount(n),s=[];for(let t=1;t<=i;t++){const e=n.getRow(t);s.push(Array.prototype.slice.call(e.values,1))}const o=t3.buildColumns(s),a=[],l=[];n.eachRow(((t,e)=>{if(e<=i)return;const r=Array.prototype.slice.call(t.values,1);l.push(r)}));const h=e?.batchSize||1e3;if(!1!==e?.enableBatchProcessing&&l.length>h)for(let t=0;t<l.length;t+=h){const r=l.slice(t,t+h).map((t=>{const e={};return t.forEach(((t,r)=>{e[`col${r}`]=t})),e}));a.push(...r),t+h<l.length&&await new Promise((t=>setTimeout(t,e?.asyncDelay||5)))}else l.forEach((t=>{const e={};t.forEach(((t,r)=>{e[`col${r}`]=t})),a.push(e)}));if(e?.exportData){const t=t3._generateJavaScriptExport(o,a),e=new Blob([t],{type:"text/javascript"}),r=URL.createObjectURL(e),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(t){let e=1,r=1;for(;;){const n=t.getRow(e),i=Array.prototype.slice.call(n.values,1);let s=!1;for(let t=1;t<i.length;t++)if(void 0!==i[t]&&""!==i[t]&&i[t]===i[t-1]){s=!0;break}if(!s)break;r++,e++}return r}static buildColumns(t,e=0,r,n=0){const i=t[n],s=[];r=r??i.length;let o=e;for(;o<r;){const e=String(i[o]||`列${o+1}`);let a=1;for(;o+a<r&&i[o+a]===e;)a++;if(n<t.length-1){const r=t3.buildColumns(t,o,o+a,n+1);1===r.length?s.push(r[0]):s.push({title:e,columns:r,hideColumnsSubHeader:!1})}else s.push({field:`col${o}`,title:e,cellType:"text",headerType:"text"});o+=a}return s}async _parseCSVString(t,e){const r=t.split("\n").filter((t=>t.trim()));if(0===r.length)throw new Error("CSV文件为空");const n=e.delimiter||",",i=t=>t.split(n).map((t=>t.trim().replace(/^"|"$/g,""))),s=r.slice(0,1).map(i),o=r.slice(1),a=this._buildColumnsFromHeaders(s),l=[];return await this._processBatchRecords(o,e,(async t=>{const e=t.map((t=>{const e=i(t),r={};return e.forEach(((t,e)=>{r[`col${e}`]=t||""})),r}));l.push(...e)})),e.exportData&&this._exportToJS(a,l),{columns:a,records:l}}async _parseJSONString(t,e){let r;try{r=JSON.parse(t)}catch(t){throw new Error("JSON文件格式错误")}const n=await this._parseJSONData(r,e);return e.exportData&&this._exportToJS(n.columns,n.records),n}async _parseHTMLString(t,e){const r=(new DOMParser).parseFromString(t,"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((t=>Array.from(t.querySelectorAll("th, td")).map((t=>t.textContent?.trim()||"")))),s=n.slice(1),o=this._buildColumnsFromHeaders(i),a=[];return await this._processBatchRecords(s,e,(async t=>{const e=t.map((t=>{const e=Array.from(t.querySelectorAll("td")).map((t=>t.textContent?.trim()||"")),r={};return e.forEach(((t,e)=>{r[`col${e}`]=t||""})),r}));a.push(...e)})),e.exportData&&this._exportToJS(o,a),{columns:o,records:a}}async _parseJSONData(t,e){let r;if("object"==typeof t&&!Array.isArray(t)&&t&&"columns"in t&&"records"in t){const n=t,i=[];await this._processBatchRecords(n.records,e,(async t=>{const e=t.map((t=>({...t})));i.push(...e)})),r={columns:n.columns,records:i}}else{if(!(Array.isArray(t)&&t.length>0))throw new Error("不支持的JSON格式");{const n=t[0],i=Object.keys(n).map((t=>({field:t,title:t,cellType:"text",headerType:"text"}))),s=[];await this._processBatchRecords(t,e,(async t=>{const e=t.map((t=>({...t})));s.push(...e)})),r={columns:i,records:s}}}return e.exportData&&this._exportToJS(r.columns,r.records),r}static _generateJavaScriptExport(t,e){const r=(t,e="")=>{if(null==t)return"null";if("string"==typeof t)return`'${t.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`;if("number"==typeof t||"boolean"==typeof t)return String(t);if(Array.isArray(t)){if(0===t.length)return"[]";return`[${t.map((t=>r(t,e+" "))).join(", ")}]`}if("object"==typeof t){const n=Object.entries(t).map((([t,n])=>`${e} ${t}: ${r(n,e+" ")}`)).join(",\n");return`{\n${n}\n${e}}`}return String(t)},n=(t,e=" ")=>{const i=Object.entries(t).map((([t,i])=>{if("columns"===t&&Array.isArray(i)){const r=i.map((t=>n(t,e+" "))).join(",\n");return`${e} ${t}: [\n${r}\n${e} ]`}return`${e} ${t}: ${r(i)}`})).join(",\n");return`${e}{\n${i}\n${e}}`},i=t.map((t=>n(t))).join(",\n"),s=e.map((t=>{const e=Object.entries(t).map((([t,e])=>` ${t}: ${r(e)}`)).join(",\n");return` {\n${e}\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(t,e){const r=t3._generateJavaScriptExport(t,e),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(t,e,r){if(!e.enableBatchProcessing||t.length<=(e.batchSize||1e3))return void await r(t,0);const n=e.batchSize||1e3,i=Math.ceil(t.length/n);for(let s=0;s<i;s++){const o=s*n,a=Math.min(o+n,t.length),l=t.slice(o,a);await r(l,s),s<i-1&&await new Promise((t=>setTimeout(t,e.asyncDelay||5)))}}}class e3{constructor(){}handleCopy(t){t.eventManager.handleCopy(new KeyboardEvent("copy"))}handleCut(t){t.eventManager.handleCut(new KeyboardEvent("cut"))}handlePaste(t){t.eventManager.handlePaste(new KeyboardEvent("paste"))}handleInsertRowAbove(t,e,r=1){if(void 0!==e&&"function"==typeof t.addRecord)for(let n=0;n<r;n++)t.addRecord([],e-1)}handleInsertRowBelow(t,e,r=1){if(void 0!==e&&"function"==typeof t.addRecord)for(let n=0;n<r;n++)t.addRecord([],e+n)}handleInsertColumnLeft(t,e,r=1){if(void 0!==e&&"function"==typeof t.addColumn)for(let n=0;n<r;n++)t.addColumn({field:e},e,!0)}handleInsertColumnRight(t,e,r=1){if(void 0!==e&&"function"==typeof t.addColumn)for(let n=0;n<r;n++)t.addColumn({field:e+1},e+1,!0)}handleDeleteRow(t,e){if(void 0!==e&&"function"==typeof t.deleteRecords){const e=t.stateManager.select.ranges,r=[];for(let t=0;t<e.length;t++){const n=e[t];for(let t=n.start.row;t<=n.end.row;t++)r.includes(t)||r.push(t)}r.sort(((t,e)=>e-t));for(let e=0;e<r.length;e++){const n=t.getRecordIndexByCell(0,r[e]);t.deleteRecords([n])}}}handleDeleteColumn(t,e){if(void 0!==e&&"function"==typeof t.deleteColumn){const e=t.stateManager.select.ranges,r=[];for(let t=0;t<e.length;t++){const n=e[t];for(let t=n.start.col;t<=n.end.col;t++)r.includes(t)||r.push(t)}r.sort(((t,e)=>e-t));for(let e=0;e<r.length;e++)t.deleteColumn(r[e])}}handleHideColumn(t,e){void 0!==e&&"function"==typeof t.hideColumns&&t.hideColumns([e])}handleSort(t,e){if(void 0!==e&&"function"==typeof t.sort){const r=t.getSortState?t.getSortState():null;let n="asc";r&&r.field===e&&(n="asc"===r.order?"desc":"normal"),t.sort({field:e,order:n})}}handleMergeCells(t){if(1===(t.stateManager.select.ranges?.length??0)&&"function"==typeof t.mergeCells){const{row:e,col:r}=t.stateManager.select.ranges[0].start,{row:n,col:i}=t.stateManager.select.ranges[0].end;if(r===i&&e===n)return;t.mergeCells(Math.min(r,i),Math.min(e,n),Math.max(r,i),Math.max(e,n))}}handleUnmergeCells(t){if(1===(t.stateManager.select.ranges?.length??0)&&"function"==typeof t.unmergeCells){const{row:e,col:r}=t.stateManager.select.ranges[0].start,{row:n,col:i}=t.stateManager.select.ranges[0].end;if(r===i&&e===n)return;t.unmergeCells(Math.min(r,i),Math.min(e,n),Math.max(r,i),Math.max(e,n))}}handleSetProtection(t){}handleFreezeToRow(t,e){void 0!==e&&(t.frozenRowCount=e+1)}handleFreezeToColumn(t,e){void 0!==e&&(t.frozenColCount=e+1)}handleFreezeToRowAndColumn(t,e,r){void 0!==e&&void 0!==r&&(t.frozenRowCount=e+1,t.frozenColCount=r+1)}handleUnfreeze(t){t.frozenRowCount=0,t.frozenColCount=0}release(){}}class r3{filterFuncRule=[];filterValueRule=[];applyFilter(t,e){const{filters:r}=t;this.filterFuncRule=[],this.filterValueRule=[],r.forEach(((t,e)=>{if(t.enable)if("byValue"===t.type)this.filterValueRule.push({filterKey:String(t.field),filteredValues:t.values});else if("byCondition"===t.type){const e=this.createFilterFunction(t);this.filterFuncRule.push({filterFunc:e,fieldId:String(t.field)})}})),e.updateFilterRules([...this.filterFuncRule,...this.filterValueRule])}createFilterFunction(t){const{field:e,operator:r,condition:n}=t;return r&&void 0!==n?t=>{const i=t[e];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(t,e){if("number"==typeof t&&"number"==typeof e)return t===e?0:t>e?1:-1;if("boolean"==typeof t&&"boolean"==typeof e)return t===e?0:-1;const r=String(t).toLowerCase(),n=String(e).toLowerCase();return r===n?0:r>n?1:-1}clearAllFilter(t){this.filterFuncRule=[],this.filterValueRule=[],t.updateFilterRules([])}clearFilter(t,e){this.filterValueRule=this.filterValueRule.filter((t=>t.filterKey!==e)),this.filterFuncRule=this.filterFuncRule.filter((t=>t.fieldId!==e)),t.updateFilterRules([...this.filterFuncRule,...this.filterValueRule])}}t.FilterActionType=void 0,(Z2=t.FilterActionType||(t.FilterActionType={}))[Z2.ADD_FILTER=0]="ADD_FILTER",Z2[Z2.REMOVE_FILTER=1]="REMOVE_FILTER",Z2[Z2.UPDATE_FILTER=2]="UPDATE_FILTER",Z2[Z2.ENABLE_FILTER=3]="ENABLE_FILTER",Z2[Z2.DISABLE_FILTER=4]="DISABLE_FILTER",Z2[Z2.CLEAR_ALL_FILTERS=5]="CLEAR_ALL_FILTERS",Z2[Z2.APPLY_FILTERS=6]="APPLY_FILTERS",t.FilterOperatorCategory=void 0,(Q2=t.FilterOperatorCategory||(t.FilterOperatorCategory={})).ALL="all",Q2.TEXT="text",Q2.NUMBER="number",Q2.COLOR="color",Q2.CHECKBOX="checkbox",Q2.RADIO="radio";class n3{state;engine;listeners=[];table;constructor(t,e){this.state={filters:new Map},this.engine=e,this.table=t}getFilterState(t){return this.state.filters.get(t)}getActiveFilterFields(){const t=[];return this.state.filters.forEach(((e,r)=>{e.enable&&t.push(r)})),t}getAllFilterStates(){return this.state}reapplyCurrentFilters(){this.getActiveFilterFields().length>0&&this.applyFilters()}dispatch(t){this.state=this.reduce(this.state,t),this.shouldApplyFilter(t)&&this.applyFilters(),this.notifyListeners()}subscribe(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter((e=>e!==t))}}notifyListeners(){this.listeners.forEach((t=>t(this.state)))}reduce(e,r){const{type:n,payload:i}=r,s=new Map(e.filters);switch(n){case t.FilterActionType.ADD_FILTER:s.set(i.field,i);break;case t.FilterActionType.REMOVE_FILTER:s.delete(i.field);break;case t.FilterActionType.UPDATE_FILTER:s.set(i.field,{...s.get(i.field),...i});break;case t.FilterActionType.ENABLE_FILTER:s.set(i.field,{...s.get(i.field),enable:!0});break;case t.FilterActionType.DISABLE_FILTER:s.set(i.field,{...s.get(i.field),enable:!1});break;case t.FilterActionType.CLEAR_ALL_FILTERS:s.clear();break;case t.FilterActionType.APPLY_FILTERS:s.set(i.field,{...s.get(i.field),...i,enable:!0})}return{...e,filters:s}}applyFilters(){this.engine.applyFilter(this.state,this.table),this.updateColumnIcons()}updateColumnIcons(){const t=this.table.columns;if(!t)return;const e=this.table.pluginManager.getPluginByName("Filter");if(!e||!e.pluginOptions)return;const r=e.pluginOptions.filterIcon,n=e.pluginOptions.filteringIcon;t.forEach(((t,i)=>{const s=t.field,o=this.state.filters.get(s);!e.shouldEnableFilterForColumn||e.shouldEnableFilterForColumn(i,t)?o&&o.enable?t.headerIcon=n:t.headerIcon=r:t.headerIcon!==r&&t.headerIcon!==n||delete t.headerIcon})),this.table.updateColumns(t)}shouldApplyFilter(e){return[t.FilterActionType.REMOVE_FILTER,t.FilterActionType.ENABLE_FILTER,t.FilterActionType.DISABLE_FILTER,t.FilterActionType.CLEAR_ALL_FILTERS,t.FilterActionType.APPLY_FILTERS].includes(e.type)||e.payload.enable}}const i3={display:"none",position:"absolute",backgroundColor:"white",border:"1px solid #ccc",boxShadow:"0 4px 8px rgba(0,0,0,0.15)",zIndex:"100"},s3={padding:"10px",display:"block"},o3={padding:"5px"},a3={width:"100%",padding:"8px 10px",border:"1px solid #ccc",borderRadius:"4px",fontSize:"14px",boxSizing:"border-box"},l3={maxHeight:"200px",overflowY:"auto",marginTop:"10px"},h3={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 5px"},u3={display:"flex",alignItems:"center",cursor:"pointer",flexGrow:"1",fontWeight:"normal"},c3={marginRight:"10px"},d3={color:"#888",fontSize:"12px"},p3={display:"flex",justifyContent:"space-around",borderBottom:"1px solid #e0e0e0"},f3=t=>({backgroundColor:"transparent",border:"none",flex:"1",padding:"10px 15px",cursor:"pointer",fontSize:"14px",fontWeight:t?"bold":"normal",color:t?"#007bff":"#666",borderBottom:t?"3px solid #007bff":"2px solid transparent"}),m3={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 15px",borderTop:"1px solid #e0e0e0",backgroundColor:"#f8f9fa"},g3=t=>({padding:"6px 12px",border:"1px solid #ccc",borderRadius:"4px",cursor:"pointer",marginLeft:"5px",backgroundColor:t?"#007bff":"white",color:t?"white":"#333",borderColor:t?"#007bff":"#ccc"}),y3={color:"#007bff",textDecoration:"none"},b3={marginBottom:"15px",padding:"10px"},v3={display:"block",marginBottom:"8px",fontWeight:"bold"},_3={width:"100%",padding:"8px",marginBottom:"15px",border:"1px solid #ccc",borderRadius:"4px",boxSizing:"border-box"},w3={display:"flex",alignItems:"center",gap:"8px"},x3={display:"none",padding:"0 5px"};function S3(t,e){Object.entries(e).forEach((([e,r])=>{t.style[e]=r}))}function C3(t,e={},r=[]){const n=document.createElement(t);return Object.entries(e).forEach((([t,e])=>{n.setAttribute(t,e)})),r.forEach((t=>{"string"==typeof t?n.appendChild(document.createTextNode(t)):n.appendChild(t)})),n}class T3{table;filterStateManager;uniqueKeys=new Map;displayToRawValueMap=new Map;selectedField;valueFilterOptionList=new Map;filterByValuePanel;filterByValueSearchInput;selectAllCheckbox;filterItemsContainer;constructor(t,e){this.table=t,this.filterStateManager=e,this.filterStateManager.subscribe((t=>{const e=t.filters.get(this.selectedField);e&&"byValue"===e.type&&this.updateUI(e)}))}updateUI(t){this.syncCheckboxesWithFilterState(t),this.syncSelectAllWithFilterState(t)}setSelectedField(t){this.selectedField=t,this.collectUniqueColumnValues(t)}collectUniqueColumnValues(t){const e=this.filterStateManager.getFilterState(t)?.enable,r=new Map,n=new Map,i=new Map;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}if(e){const e=this.table.internalProps.records,o=e.length;for(let a=0;a<o;a++){let o,l;if(-1!==s){const r=this.table.columnHeaderLevelCount+a;o=e[a][t];const n=this.table.internalProps.layoutMap.getBody(s,r);l=n&&"fieldFormat"in n&&n.fieldFormat&&"function"==typeof n.fieldFormat?n.fieldFormat({[t]:o}):o}null!=o&&(r.set(l,(r.get(l)||0)+1),n.set(o,l),i.set(l,o))}}else{const e=this.table.internalProps.dataSource.length;for(let o=0;o<e;o++){let e,a;if(-1!==s){const t=this.table.columnHeaderLevelCount+o;t<this.table.rowCount&&(e=this.table.getCellOriginValue(s,t),a=this.table.getCellValue(s,t))}else e=this.table.getFieldData(String(t),-1!==s?s:0,this.table.columnHeaderLevelCount+o),a=e;null!=e&&(r.set(a,(r.get(a)||0)+1),n.set(e,a),i.set(a,e))}}this.displayToRawValueMap.set(t,i);const o=Array.from(r.entries()).map((([t,e])=>({value:t,count:e,rawValue:i.get(t)})));this.uniqueKeys.set(t,o)}onValueSelect(e,r,n){const i=this.displayToRawValueMap.get(e),s=i?i.get(r):r,o=this.filterStateManager.getFilterState(e);if(o){const r=n?[...o.values||[],s]:(o.values||[]).filter((t=>t!==s));this.filterStateManager.dispatch({type:t.FilterActionType.UPDATE_FILTER,payload:{field:e,values:r}})}else this.filterStateManager.dispatch({type:t.FilterActionType.ADD_FILTER,payload:{field:e,type:"byValue",values:[s]}})}toggleSelectAll(e,r){const n=this.filterStateManager.getFilterState(e),i=r&&this.uniqueKeys.get(e)?.map((t=>t.rawValue))||[];if(n){const n=r?i:[];this.filterStateManager.dispatch({type:t.FilterActionType.UPDATE_FILTER,payload:{field:e,values:n}})}else this.filterStateManager.dispatch({type:t.FilterActionType.ADD_FILTER,payload:{field:e,type:"byValue",values:i,enable:!0}})}onSearch(t,e){const r=e.toUpperCase().split(" ").filter((t=>t)),n=this.valueFilterOptionList.get(t);for(const t of n){const e=t.id.toUpperCase()||"",n=r.some((t=>e.includes(t)));t.itemContainer.style.display=0===r.length||n?"flex":"none"}}initFilterStateFromTableData(e){const r=this.filterStateManager.getFilterState(e),n=new Set,i=this.displayToRawValueMap.get(e);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}const o=this.table.internalProps.dataSource.length;for(let t=0;t<o;t++){let r,o;if(-1!==s){const e=this.table.columnHeaderLevelCount+t;e<this.table.rowCount&&(r=this.table.getCellValue(s,e),o=i?i.get(r):r)}else r=this.table.getFieldData(String(e),-1!==s?s:0,this.table.columnHeaderLevelCount+t),o=i?i.get(r):r;null!=o&&n.add(o)}const a=!r||!function(t,e){if(!Nu(t)||!Nu(e))return!1;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}(r.values,Array.from(n));a&&(r?this.filterStateManager.dispatch({type:t.FilterActionType.UPDATE_FILTER,payload:{field:e,type:"byValue",values:Array.from(n)}}):this.filterStateManager.dispatch({type:t.FilterActionType.ADD_FILTER,payload:{field:e,type:"byValue",values:Array.from(n)}}))}syncCheckboxesWithFilterState(t){if(!t)return;const e=t.values||[],r=this.displayToRawValueMap.get(t.field),n=this.valueFilterOptionList.get(t.field);n?.forEach((n=>{const i=n.originalValue,s=r?r.get(i):i;n.checkbox.checked=e.some((t=>t===s));const o=this.uniqueKeys.get(t.field)?.find((t=>String(t.value)===n.id))?.count||0;n.countSpan.textContent=String(o),n.itemContainer.style.display=0===o?"none":"flex"}))}syncSelectAllWithFilterState(t){if(!t||!t.values)return this.selectAllCheckbox.checked=!1,void(this.selectAllCheckbox.indeterminate=!1);const e=this.uniqueKeys.get(t.field)?.length||0;0===e||0===t.values.length?(this.selectAllCheckbox.checked=!1,this.selectAllCheckbox.indeterminate=!1):t.values.length===e?(this.selectAllCheckbox.checked=!0,this.selectAllCheckbox.indeterminate=!1):(this.selectAllCheckbox.checked=!1,this.selectAllCheckbox.indeterminate=!0)}applyFilter(e=this.selectedField){const r=this.filterStateManager.getFilterState(e)?.values||[];r.length>0&&r.length<this.uniqueKeys.get(e)?.length?this.filterStateManager.dispatch({type:t.FilterActionType.APPLY_FILTERS,payload:{field:e,type:"byValue",values:r,enable:!0}}):this.filterStateManager.dispatch({type:t.FilterActionType.REMOVE_FILTER,payload:{field:e}})}clearFilter(e){this.filterStateManager.dispatch({type:t.FilterActionType.REMOVE_FILTER,payload:{field:e}}),this.hide()}render(t){this.filterByValuePanel=document.createElement("div"),S3(this.filterByValuePanel,s3);const e=document.createElement("div");S3(e,o3),this.filterByValueSearchInput=document.createElement("input"),this.filterByValueSearchInput.type="text",this.filterByValueSearchInput.placeholder="可使用空格分隔多个关键词",S3(this.filterByValueSearchInput,a3),e.appendChild(this.filterByValueSearchInput);const r=document.createElement("div");S3(r,l3);const n=document.createElement("div");S3(n,h3);const i=document.createElement("label");S3(i,u3),this.selectAllCheckbox=document.createElement("input"),this.selectAllCheckbox.type="checkbox",this.selectAllCheckbox.checked=!0,S3(this.selectAllCheckbox,c3),i.append(this.selectAllCheckbox," 全选"),n.appendChild(i),this.filterItemsContainer=document.createElement("div"),r.append(n,this.filterItemsContainer),this.filterByValuePanel.append(e,r),t.appendChild(this.filterByValuePanel),this.bindEventForFilterByValue()}renderFilterOptions(t){this.filterItemsContainer.innerHTML="",this.valueFilterOptionList.delete(t),this.valueFilterOptionList.set(t,[]);const e=this.filterStateManager.getFilterState(t)?.values||[],r=new Set(e),n=[];this.uniqueKeys.get(t)?.forEach((({value:t,count:e,rawValue:i})=>{const s=document.createElement("div");S3(s,h3);const o=document.createElement("label");S3(o,u3);const a=document.createElement("input");a.type="checkbox",a.value=String(t),a.checked=r.has(i),S3(a,c3);const l=document.createElement("span");l.textContent=String(e),S3(l,d3),o.append(a,` ${t}`),s.append(o,l),this.filterItemsContainer.appendChild(s);const h={id:String(t),originalValue:t,itemContainer:s,checkbox:a,countSpan:l};n.push(h)})),this.valueFilterOptionList.set(t,n)}bindEventForFilterByValue(){this.filterByValuePanel.addEventListener("keyup",(t=>{const e=t.target;if(e instanceof HTMLInputElement&&"text"===e.type){const t=e.value;this.onSearch(this.selectedField,t)}})),this.filterByValuePanel.addEventListener("change",(t=>{const e=t.target;if(e instanceof HTMLInputElement&&"checkbox"===e.type)if(e===this.selectAllCheckbox)this.toggleSelectAll(this.selectedField,this.selectAllCheckbox.checked);else{const t=e,r=t.checked,n=this.valueFilterOptionList.get(this.selectedField)?.find((e=>e.id===t.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"}}class E3{table;filterStateManager;filterByConditionPanel;selectedField;operatorSelect;valueInput;valueInputMax;categorySelect;currentCategory=t.FilterOperatorCategory.ALL;operators=[{value:"equals",label:"等于",category:t.FilterOperatorCategory.ALL},{value:"notEquals",label:"不等于",category:t.FilterOperatorCategory.ALL},{value:"equals",label:"等于",category:t.FilterOperatorCategory.NUMBER},{value:"notEquals",label:"不等于",category:t.FilterOperatorCategory.NUMBER},{value:"greaterThan",label:"大于",category:t.FilterOperatorCategory.NUMBER},{value:"lessThan",label:"小于",category:t.FilterOperatorCategory.NUMBER},{value:"greaterThanOrEqual",label:"大于等于",category:t.FilterOperatorCategory.NUMBER},{value:"lessThanOrEqual",label:"小于等于",category:t.FilterOperatorCategory.NUMBER},{value:"between",label:"介于",category:t.FilterOperatorCategory.NUMBER},{value:"notBetween",label:"不介于",category:t.FilterOperatorCategory.NUMBER},{value:"equals",label:"等于",category:t.FilterOperatorCategory.TEXT},{value:"notEquals",label:"不等于",category:t.FilterOperatorCategory.TEXT},{value:"contains",label:"包含",category:t.FilterOperatorCategory.TEXT},{value:"notContains",label:"不包含",category:t.FilterOperatorCategory.TEXT},{value:"startsWith",label:"开头是",category:t.FilterOperatorCategory.TEXT},{value:"notStartsWith",label:"开头不是",category:t.FilterOperatorCategory.TEXT},{value:"endsWith",label:"结尾是",category:t.FilterOperatorCategory.TEXT},{value:"notEndsWith",label:"结尾不是",category:t.FilterOperatorCategory.TEXT},{value:"equals",label:"等于",category:t.FilterOperatorCategory.COLOR},{value:"notEquals",label:"不等于",category:t.FilterOperatorCategory.COLOR},{value:"isChecked",label:"已选中",category:t.FilterOperatorCategory.CHECKBOX},{value:"isUnchecked",label:"未选中",category:t.FilterOperatorCategory.CHECKBOX},{value:"isChecked",label:"已选中",category:t.FilterOperatorCategory.RADIO},{value:"isUnchecked",label:"未选中",category:t.FilterOperatorCategory.RADIO}];categories=[{value:t.FilterOperatorCategory.ALL,label:"全部"},{value:t.FilterOperatorCategory.TEXT,label:"文本"},{value:t.FilterOperatorCategory.NUMBER,label:"数值"},{value:t.FilterOperatorCategory.COLOR,label:"颜色"},{value:t.FilterOperatorCategory.CHECKBOX,label:"复选框"},{value:t.FilterOperatorCategory.RADIO,label:"单选框"}];constructor(t,e){this.table=t,this.filterStateManager=e}setSelectedField(t){this.selectedField=t,this.updateOperatorOptions(),this.loadCurrentFilterState()}updateOperatorOptions(){if(!this.operatorSelect)return;let e;if(this.operatorSelect.innerHTML="",this.currentCategory===t.FilterOperatorCategory.ALL){const t=new Map;this.operators.forEach((e=>{t.has(e.value)||t.set(e.value,e)})),e=Array.from(t.values())}else e=this.operators.filter((t=>t.category===this.currentCategory));e.forEach((t=>{const e=document.createElement("option");e.value=t.value,e.textContent=t.label,this.operatorSelect.appendChild(e)}))}handleCategoryChange(){this.categorySelect&&(this.currentCategory=this.categorySelect.value,this.updateOperatorOptions(),this.syncUIState())}loadCurrentFilterState(){const t=this.filterStateManager.getFilterState(this.selectedField);t&&"byCondition"===t.type?(t.operator&&this.operatorSelect&&(this.operatorSelect.value=t.operator),void 0!==t.condition&&this.valueInput&&(Array.isArray(t.condition)?(this.valueInput.value=String(t.condition[0]),this.valueInputMax&&(this.valueInputMax.value=String(t.condition[1]))):(this.valueInput.value=String(t.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=t.FilterOperatorCategory.ALL,this.categorySelect&&(this.categorySelect.value=t.FilterOperatorCategory.ALL),this.updateOperatorOptions(),this.syncUIState()}syncUIState(){if(!this.operatorSelect||!this.valueInput)return;const t=this.operatorSelect.value,e=this.valueInput.nextElementSibling;this.isRangeOperator(t)?(this.valueInput.placeholder="最小值",this.valueInputMax&&(this.valueInputMax.style.display="inline-block"),e&&(e.style.display="inline-block")):(this.valueInput.placeholder="请输入筛选值",this.valueInputMax&&(this.valueInputMax.style.display="none"),e&&(e.style.display="none"))}isBooleanOperator(t){return["isChecked","isUnchecked"].includes(t)}isRangeOperator(t){return"between"===t||"notBetween"===t}applyFilter(e=this.selectedField){if(!this.operatorSelect||!this.valueInput)return;const r=this.operatorSelect?.value;let n=this.valueInput?.value;if(this.currentCategory!==t.FilterOperatorCategory.NUMBER||(n=parseFloat(n),!isNaN(n))){if(this.isRangeOperator(r)){const e=n;let r=this.valueInputMax.value.trim();if(this.currentCategory===t.FilterOperatorCategory.NUMBER){const t=parseFloat(r);if(isNaN(t))return;r=t}n=[e,r]}n||!1===n||0===n||this.isBooleanOperator(r)?(this.filterStateManager.dispatch({type:t.FilterActionType.APPLY_FILTERS,payload:{field:e,type:"byCondition",operator:r,condition:n,enable:!0}}),this.hide()):this.clearFilter(e)}}clearFilter(e){this.filterStateManager.dispatch({type:t.FilterActionType.REMOVE_FILTER,payload:{field:e}}),this.hide()}render(t){this.filterByConditionPanel=document.createElement("div"),S3(this.filterByConditionPanel,s3);const e=document.createElement("div");S3(e,b3);const r=C3("label",{},["筛选类型:"]);S3(r,v3),this.categorySelect=C3("select"),S3(this.categorySelect,_3),this.categories.forEach((t=>{const e=document.createElement("option");e.value=t.value,e.textContent=t.label,this.categorySelect.appendChild(e)}));const n=C3("label",{},["筛选条件:"]);S3(n,v3),this.operatorSelect=C3("select"),S3(this.operatorSelect,_3);const i=C3("label",{},["筛选值:"]);S3(i,v3);const s=C3("div");S3(s,w3),this.valueInput=C3("input",{type:"text",placeholder:"请输入筛选值"}),S3(this.valueInput,a3);const o=C3("span",{},["和"]);S3(o,x3),o.style.display="none",this.valueInputMax=C3("input",{type:"text",placeholder:"最大值"}),S3(this.valueInputMax,a3),this.valueInputMax.style.display="none",s.appendChild(this.valueInput),s.appendChild(o),s.appendChild(this.valueInputMax),e.appendChild(r),e.appendChild(this.categorySelect),e.appendChild(n),e.appendChild(this.operatorSelect),e.appendChild(i),e.appendChild(s),this.filterByConditionPanel.appendChild(e),t.appendChild(this.filterByConditionPanel),this.hide(),this.updateOperatorOptions(),this.bindEvents()}bindEvents(){this.valueInput.addEventListener("keypress",(t=>{"Enter"===t.key&&this.applyFilter()})),this.valueInputMax.addEventListener("keypress",(t=>{"Enter"===t.key&&this.applyFilter()})),this.categorySelect.addEventListener("change",(()=>{this.handleCategoryChange()})),this.operatorSelect.addEventListener("change",(()=>{const t=this.operatorSelect.value,e=this.valueInput.nextElementSibling;this.isRangeOperator(t)?(this.valueInput.placeholder="最小值",this.valueInputMax.style.display="inline-block",e.style.display="inline-block"):(this.valueInput.placeholder="请输入筛选值",this.valueInputMax.style.display="none",e.style.display="none")}))}show(){this.filterByConditionPanel&&(this.filterByConditionPanel.style.display="block",this.loadCurrentFilterState())}hide(){this.filterByConditionPanel&&(this.filterByConditionPanel.style.display="none")}}class A3{table;filterStateManager;valueFilter=null;conditionFilter=null;activeTab="byValue";isVisible=!1;selectedField=null;filterModes=[];filterMenu;filterMenuWidth;filterTabByValue;filterTabByCondition;clearFilterOptionLink;cancelFilterButton;applyFilterButton;constructor(t,e){this.table=t,this.filterStateManager=e,this.valueFilter=new T3(this.table,this.filterStateManager),this.conditionFilter=new E3(this.table,this.filterStateManager),this.filterMenuWidth=300}onTabSwitch(t){this.activeTab=t,"byValue"===t?(this.valueFilter.show(),this.conditionFilter.hide()):(this.conditionFilter.show(),this.valueFilter.hide());const e="byValue"===t;S3(this.filterTabByValue,f3(e)),S3(this.filterTabByCondition,f3(!e))}updateSelectedField(t){this.selectedField=t,this.valueFilter&&this.valueFilter.setSelectedField(t),this.conditionFilter&&this.conditionFilter.setSelectedField(t)}applyFilter(t){"byValue"===this.activeTab?this.valueFilter.applyFilter(t):"byCondition"===this.activeTab&&this.conditionFilter.applyFilter(t),this.hide()}clearFilter(t){this.valueFilter&&this.valueFilter.clearFilter(t),this.conditionFilter&&this.conditionFilter.clearFilter(t),this.hide()}render(t){this.filterMenu=document.createElement("div"),S3(this.filterMenu,i3),this.filterMenu.style.width=`${this.filterMenuWidth}px`;const e=document.createElement("div");S3(e,p3),this.filterTabByValue=document.createElement("button"),this.filterTabByValue.innerText="按值筛选",S3(this.filterTabByValue,f3(!0)),this.filterTabByCondition=document.createElement("button"),this.filterTabByCondition.innerText="按条件筛选",S3(this.filterTabByCondition,f3(!1)),e.append(this.filterTabByValue,this.filterTabByCondition);const r=document.createElement("div");S3(r,m3),this.clearFilterOptionLink=document.createElement("a"),this.clearFilterOptionLink.href="#",this.clearFilterOptionLink.innerText="清除筛选",S3(this.clearFilterOptionLink,y3);const n=document.createElement("div");this.cancelFilterButton=document.createElement("button"),this.cancelFilterButton.innerText="取消",S3(this.cancelFilterButton,g3(!1)),this.applyFilterButton=document.createElement("button"),this.applyFilterButton.innerText="确认",S3(this.applyFilterButton,g3(!0)),n.append(this.cancelFilterButton,this.applyFilterButton),r.append(this.clearFilterOptionLink,n),this.filterMenu.append(e),this.valueFilter.render(this.filterMenu),this.conditionFilter.render(this.filterMenu),this.filterMenu.append(r),t.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",(t=>{t.preventDefault(),this.clearFilter(this.selectedField)})),this.applyFilterButton.addEventListener("click",(()=>{this.applyFilter(this.selectedField)})),document.addEventListener("click",(()=>{this.isVisible&&this.hide()})),this.filterMenu.addEventListener("click",(t=>{t.stopPropagation()}))}show(t,e,r){this.filterModes=r,this.filterModes.includes("byValue")?this.filterModes.includes("byCondition")||(this.filterTabByCondition.style.display="none",setTimeout((()=>this.onTabSwitch("byValue")),0)):(this.filterTabByValue.style.display="none",setTimeout((()=>this.onTabSwitch("byCondition")),0));let n=0,i=0;const s=this.table.canvas.getBoundingClientRect(),o=this.table.getMergeCellRect(t,e);o.right<this.filterMenuWidth?(n=o.left+s.left,i=o.bottom+s.top):(n=o.right+s.left-this.filterMenuWidth,i=o.bottom+s.top),this.filterMenu.style.display="block",this.filterMenu.style.left=`${n}px`,this.filterMenu.style.top=`${i}px`;const a=this.table.internalProps.layoutMap.getHeaderField(t,e);this.updateSelectedField(a);const l=this.filterStateManager.getFilterState(a);l&&"byCondition"===l.type?this.onTabSwitch("byCondition"):this.onTabSwitch("byValue"),setTimeout((()=>{this.isVisible=!0}),0)}hide(){this.filterMenu.style.display="none",this.isVisible=!1}}function k3(t,e){let r="";for(let e=t+1;e>0;e=Math.floor((e-1)/26))r=String.fromCharCode((e-1)%26+65)+r;return r+(e+1)}function R3(t){if(!t)return[0,0,0];if(t.startsWith("#")){let e=t.substring(1);3===e.length&&(e=e.replace(/(.)/g,"$1$1"));return[parseInt(e.substring(0,2),16),parseInt(e.substring(2,4),16),parseInt(e.substring(4,6),16)]}if(t.startsWith("rgb(")){return t.substring(4,t.length-1).split(",").map(Number)}if(t.startsWith("rgba(")){return t.substring(5,t.length-1).split(",").map(Number)}if(Bu(M3[t]))return[(e=M3[t])>>16,e>>8&255,255&e,1];if(Bu(N3[t]))return function(t){return[t>>>24,t>>>16&255,t>>>8&255,255&t]}(N3[t]);var e;throw new Error("Unsupported color format")}function O3(t){if(3===t.length&&t.push(1),4!==t.length)throw new Error("Invalid RGBA array");const[e,r,n,i]=t.map(Math.round);return`${Math.round(255*i).toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}const N3={transparent:4294967040},M3={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 I3(t,e){return{name:B3(t.fontFamily)||"Arial",size:t.fontSize||10,bold:P3(t.fontWeight),italic:"italic"===t.fontStyle,color:z3("link"===e?t._linkColor:t.color),underline:t.underline}}function P3(t){return"number"==typeof t?t>=600:Number(t)>=600||"bold"===t}function B3(t){return t.split(",").map((t=>t.trim()))[0]}function L3(t){return{type:"pattern",pattern:"solid",fgColor:z3(t.bgColor)}}function F3(t){const{borderColor:e,borderLineWidth:r,borderLineDash:n,_strokeArrayWidth:i,_strokeArrayColor:s}=t;if(s||i){const t={};return s&&!s[0]||i&&!i[0]||(t.top={style:D3(i?.[0]??r,n),color:z3(s?.[0]??e)}),s&&!s[1]||i&&!i[1]||(t.right={style:D3(i?.[1]??r,n),color:z3(s?.[1]??e)}),s&&!s[2]||i&&!i[2]||(t.bottom={style:D3(i?.[2]??r,n),color:z3(s?.[2]??e)}),s&&!s[3]||i&&!i[3]||(t.left={style:D3(i?.[3]??r,n),color:z3(s?.[3]??e)}),t}if(0===r)return{};const o={style:D3(r,n),color:z3(e)};return{top:o,left:o,bottom:o,right:o}}function D3(t,e){return e&&e.length?t<=2?"dashed":"mediumDashed":t<=.5?"hair":t<=1?"thin":t<=2?"medium":"thick"}function j3(t,e){return{horizontal:t.textAlign||"left",vertical:t.textBaseline||"middle",wrapText:t.autoWrapText||!1,indent:e||0}}function z3(t){return{argb:O3(R3(t))}}function U3(t,e,r){let n=0;const i=r.internalProps.layoutMap;if(i.isHeader(t,e)){const r=i.getHeader(t,e);Ru(r?.hierarchyLevel)&&(n=(r.hierarchyLevel??0)*(i.rowHierarchyIndent??0))}else{const s=r.getBodyColumnDefine(t,e);if(s?.tree){const s=r.dataSource.getIndexKey(r.getRecordShowIndexByCell(t,e));n=Array.isArray(s)&&"none"!==r.getHierarchyState(t,e)?(s.length-1)*(i.hierarchyIndent??0):0}}return n}function H3(t,e){const r=Lu(t.pagination),n=t.isPivotTable(),i=t.internalProps.layoutMap;let s=t.rowCount-1;return{reset:()=>{n&&e&&r&&(t.internalProps.layoutMap.setPagination(r),t.refreshRowColCount())},handleRowCount:()=>(e&&r&&(n?(t.internalProps.layoutMap.setPagination(void 0),t.refreshRowColCount(),s=t.rowCount-1):s=t.recordsCount*i.bodyRowSpanCount+i.headerLevelCount),s)}}function W3(t){return new Promise((e=>{requestIdleCallback((t=>{e(t)}),t)}))}async function $3(t,e,r=!1){const n=new J2.Workbook,i=n.addWorksheet("sheet1"),s=!!e?.exportAllData,{handleRowCount:o,reset:a}=H3(t,s),l=o(),h=t.colCount-1;i.properties.defaultRowHeight=40;const u=[],c=[],d=new Set;let p=0;function f(s){return new Promise((async o=>{for(;p<=l&&(!r||s?.timeRemaining()>0);){const r=Math.min(p+100-1,l);for(let s=0;s<=h;s++){const o=t.getColWidth(s);void 0===u[s]&&(u[s]={width:o/6});for(let o=p;o<=r;o++){if(0===s){const e=t.getRowHeight(o);i.getRow(o+1).height=e}await V3(s,o,t,i,n,e);const r=t.getCellRange(s,o);if(r.start.col!==r.end.col||r.start.row!==r.end.row){const t=`${r.start.col},${r.start.row}:${r.end.col},${r.end.row}`;d.has(t)||(d.add(t),c.push(r))}}}p=r+1}if(p>l)o();else{let t;r&&(t=await W3()),await f(t),o()}}))}await new Promise((async t=>{let e;r&&(e=await W3()),await f(e),t()})),i.columns=u,c.forEach((t=>{i.mergeCells(t.start.row+1,t.start.col+1,t.end.row+1,t.end.col+1)}));const m=[];t.frozenRowCount>0&&m.push({state:"frozen",ySplit:t.frozenRowCount,topLeftCell:k3(0,t.frozenRowCount)}),t.frozenColCount>0&&m.push({state:"frozen",xSplit:t.frozenColCount,topLeftCell:k3(t.frozenColCount,0)}),i.views=m,e?.excelJSWorksheetCallback&&e.excelJSWorksheetCallback(i);const g=await n.xlsx.writeBuffer();return a(),g}async function V3(t,r,n,i,s,o){const{layoutMap:a}=n.internalProps,l=n.getCellType(t,r),h=n.getCellRawRecord(t,r);let u=(h&&h.vtableMergeName)??n.getCellValue(t,r,!1);var c;!(c=u)||"object"!=typeof c&&"function"!=typeof c||"function"!=typeof c.then||(u=await u);const d=n.getCellStyle(t,r),p=n.getCellLocation(t,r),f="body"!==p?n.getHeaderDefine(t,r):n.getBodyColumnDefine(t,r);let m,g,y,b;if(("body"!==p||(f?.dragOrder||!!f?.icon||!!f?.tree))&&(m=n.getCellIcons(t,r)),"body"!==p?(g=f?.headerCustomRender,y=f?.headerCustomLayout):(g=f?.customRender||n.customRender,y=f?.customLayout),o?.formatExportOutput){const e={cellType:l,cellValue:u,table:n,col:t,row:r},s=o.formatExportOutput(e);if(void 0!==s){let e=i.getCell(k3(t,r));e.value=s,e.font=I3(d,l),e.fill=L3(d),e.border=F3(d);const a=U3(t,r,n);if(e.alignment=j3(d,Math.ceil(a/e.font.size)),e&&o?.formatExcelJSCell){const i=o.formatExcelJSCell({cellType:l,cellValue:u,table:n,col:t,row:r},e);i&&(e=i)}return e}}if("image"===l||"video"===l||"progressbar"===l||"sparkline"===l||a.isAxisCell(t,r)||!o?.ignoreIcon&&Nu(m)&&m.length||g||y)if(X3(l,a.isAxisCell(t,r),!!g||!!y,!(o?.ignoreIcon||!Nu(m)||!m.length),o)){const e=G3(t,r,n),o=s.addImage({base64:e,extension:"png"});i.addImage(o,{tl:{col:t+1/80,row:r+1/120},br:{col:t+1,row:r+1},editAs:"oneCell"})}else b=i.getCell(k3(t,r));else if("text"===l||"link"===l){let e;if(b=i.getCell(k3(t,r)),"link"===l){const i=f.templateLink;if(i){const s=n.getCellOriginRecord(t,r);if(s&&s.vtableMerge);else{const o=n.getCellOriginValue(t,r),a=Object.assign({__value:u,__dataValue:o},s);if(ku(i))e=i(a,t,r,n);else{const t=/\{\s*(\S+?)\s*\}/g;e=i.replace(t,((t,e)=>a[e]))}}}}b.value=function(t,e,r){if("link"===e)return{text:t,hyperlink:r||t,tooltip:t};return t}(u,l,e),b.font=I3(d,l),b.fill=L3(d),b.border=F3(d);const s=U3(t,r,n);b.alignment=j3(d,Math.ceil(s/b.font.size))}else if("chart"===l)if(X3("chart",!1,!1,!1,o)){const o=n.scenegraph.getCell(t,r);e.renderChart(o.firstChild);const a=G3(t,r,n),l=s.addImage({base64:a,extension:"png"});i.addImage(l,{tl:{col:t+1/80,row:r+1/120},br:{col:t+1,row:r+1},editAs:"oneCell"}),n.scenegraph.updateNextFrame()}else b=i.getCell(k3(t,r));if(b&&o?.formatExcelJSCell){const e=o.formatExcelJSCell({cellType:l,cellValue:u,table:n,col:t,row:r},b);e&&(b=e)}return b}function G3(t,r,n){let i=n.scenegraph.getCell(t,r),s=!1;"empty"===i.role&&(i=e.updateCell(t,r,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=e.graphicUtil.drawGraphicToCanvas(i,n.scenegraph.stage);return i.attribute.stroke=o,s&&i.parent?.removeChild(i),a.toDataURL()}function X3(t,e,r,n,i){return!i?.skipImageExportCellType||("image"===t||"video"===t||"progressbar"===t||"sparkline"===t||"chart"===t?!i.skipImageExportCellType.includes(t):e?!i.skipImageExportCellType.includes("chart"):r?!i.skipImageExportCellType.includes("custom"):!n||!i.skipImageExportCellType.includes("textWithIcon"))}function Y3(t,e){const r=!!e?.exportAllData,{handleRowCount:n,reset:i}=H3(t,r),s=n(),o=t.colCount-1;let a="";for(let r=0;r<=s;r++){for(let n=0;n<=o;n++){const i=q3(n,r,t,e);if("undefined"!=typeof Promise&&i instanceof Promise);else{const t=`${void 0===i?"":i}`;/^\[object .*\]$/.exec(t)||(a+=t)}a+=","}a+="\r\n"}return i(),a}function q3(t,e,r,n){const i=r.getCellRawRecord(t,e),s=(i&&i.vtableMergeName)??r.getCellValue(t,e,!1);if(n?.formatExportOutput){const i={cellType:r.getCellType(t,e),cellValue:s,table:r,col:t,row:e},o=n.formatExportOutput(i);if(void 0!==o)return"string"==typeof o?'"'+o+'"':o}const o=r.getCellRange(t,e),a=o.start.col,l=o.start.row;if(a!==t||l!==e)return"";let h=s;return n?.escape?h=function(t){if("string"!=typeof t)return t;let e=t.replace(/"/g,'""');/[,"\r\n]/.test(e)&&(e=`"${e}"`);return e}(h):"string"==typeof h&&(h='"'+h+'"'),h}var K3={exports:{}};!function(t,e){!function(){function e(t,e){return void 0===e?e={autoBom:!1}:"object"!=typeof e&&(e={autoBom:!e}),e.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob(["\ufeff",t],{type:t.type}):t}function r(t,e,r){var n=new XMLHttpRequest;n.open("GET",t),n.responseType="blob",n.onload=function(){a(n.response,e,r)},n.onerror=function(){},n.send()}function n(t){var e=new XMLHttpRequest;e.open("HEAD",t,!1);try{e.send()}catch(t){}return 200<=e.status&&299>=e.status}function i(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(r){var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(e)}}var s="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof dt&&dt.global===dt?dt:void 0,o=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),a=s.saveAs||("object"!=typeof window||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!o?function(t,e,o){var a=s.URL||s.webkitURL,l=document.createElement("a");e=e||t.name||"download",l.download=e,l.rel="noopener","string"==typeof t?(l.href=t,l.origin===location.origin?i(l):n(l.href)?r(t,e,o):i(l,l.target="_blank")):(l.href=a.createObjectURL(t),setTimeout((function(){a.revokeObjectURL(l.href)}),4e4),setTimeout((function(){i(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(t,s,o){if(s=s||t.name||"download","string"!=typeof t)navigator.msSaveOrOpenBlob(e(t,o),s);else if(n(t))r(t,s,o);else{var a=document.createElement("a");a.href=t,a.target="_blank",setTimeout((function(){i(a)}))}}:function(t,e,n,i){if((i=i||open("","_blank"))&&(i.document.title=i.document.body.innerText="downloading..."),"string"==typeof t)return r(t,e,n);var a="application/octet-stream"===t.type,l=/constructor/i.test(s.HTMLElement)||s.safari,h=/CriOS\/[\d]+/.test(navigator.userAgent);if((h||a&&l||o)&&"undefined"!=typeof FileReader){var u=new FileReader;u.onloadend=function(){var t=u.result;t=h?t:t.replace(/^data:[^;]*;/,"data:attachment/file;"),i?i.location.href=t:location=t,i=null},u.readAsDataURL(t)}else{var c=s.URL||s.webkitURL,d=c.createObjectURL(t);i?i.location=d:location.href=d,i=null,setTimeout((function(){c.revokeObjectURL(d)}),4e4)}});s.saveAs=a.saveAs=a,t.exports=a}()}(K3);var Z3,Q3,J3,t5,e5=K3.exports;!function(t){t.UP="top",t.RIGHT="right",t.DOWN="bottom",t.LEFT="left"}(Z3||(Z3={})),function(t){t.COPY="copy",t.SERIES="series"}(Q3||(Q3={})),function(t){t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING"}(J3||(J3={})),function(t){t.NUMBER="number",t.DATE="date",t.EXTEND_NUMBER="extendNumber",t.CHN_NUMBER="chnNumber",t.CHN_WEEK2="chnWeek2",t.CHN_WEEK3="chnWeek3",t.LOOP_SERIES="loopSeries",t.FORMULA="formula",t.OTHER="other"}(t5||(t5={}));var r5=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t},n5=Md,i5=function(){try{var t=n5(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),s5=i5;var o5=function(t,e,r){"__proto__"==e&&s5?s5(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r},a5=o5,l5=xc,h5=Object.prototype.hasOwnProperty;var u5=function(t,e,r){var n=t[e];h5.call(t,e)&&l5(n,r)&&(void 0!==r||e in t)||a5(t,e,r)},c5=u5,d5=o5;var p5=function(t,e,r,n){var i=!r;r||(r={});for(var s=-1,o=e.length;++s<o;){var a=e[s],l=n?n(r[a],t[a],a,r,t):void 0;void 0===l&&(l=t[a]),i?d5(r,a,l):c5(r,a,l)}return r},f5=p5,m5=lm;var g5=function(t,e){return t&&f5(e,m5(e),t)};var y5=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e},b5=ld,v5=qf,_5=y5,w5=Object.prototype.hasOwnProperty;var x5=function(t){if(!b5(t))return _5(t);var e=v5(t),r=[];for(var n in t)("constructor"!=n||!e&&w5.call(t,n))&&r.push(n);return r},S5=Xf,C5=x5,T5=im;var E5=function(t){return T5(t)?S5(t,!0):C5(t)},A5=p5,k5=E5;var R5=function(t,e){return t&&A5(e,k5(e),t)},O5={exports:{}};!function(t,e){var r=qc,n=e&&!e.nodeType&&e,i=n&&t&&!t.nodeType&&t,s=i&&i.exports===n?r.Buffer:void 0,o=s?s.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=o?o(r):new t.constructor(r);return t.copy(n),n}}(O5,O5.exports);var N5=O5.exports;var M5=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e},I5=p5,P5=uf;var B5=function(t,e){return I5(t,P5(t),e)},L5=Kf(Object.getPrototypeOf,Object),F5=Zp,D5=L5,j5=uf,z5=nf,U5=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)F5(e,j5(t)),t=D5(t);return e}:z5,H5=p5,W5=U5;var $5=function(t,e){return H5(t,W5(t),e)},V5=ef,G5=U5,X5=E5;var Y5=function(t){return V5(t,X5,G5)},q5=Object.prototype.hasOwnProperty;var K5=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&q5.call(t,"index")&&(r.index=t.index,r.input=t.input),r},Z5=zp;var Q5=function(t){var e=new t.constructor(t.byteLength);return new Z5(e).set(new Z5(t)),e},J5=Q5;var t6=function(t,e){var r=e?J5(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)},e6=/\w*$/;var r6=function(t){var e=new t.constructor(t.source,e6.exec(t));return e.lastIndex=t.lastIndex,e},n6=Kc?Kc.prototype:void 0,i6=n6?n6.valueOf:void 0;var s6=function(t){return i6?Object(i6.call(t)):{}},o6=Q5;var a6=function(t,e){var r=e?o6(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)},l6=Q5,h6=t6,u6=r6,c6=s6,d6=a6;var p6=function(t,e,r){var n=t.constructor;switch(e){case"[object ArrayBuffer]":return l6(t);case"[object Boolean]":case"[object Date]":return new n(+t);case"[object DataView]":return h6(t,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 d6(t,r);case"[object Map]":case"[object Set]":return new n;case"[object Number]":case"[object String]":return new n(t);case"[object RegExp]":return u6(t);case"[object Symbol]":return c6(t)}},f6=ld,m6=Object.create,g6=function(){function t(){}return function(e){if(!f6(e))return{};if(m6)return m6(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),y6=g6,b6=L5,v6=qf;var _6=function(t){return"function"!=typeof t.constructor||v6(t)?{}:y6(b6(t))},w6=Pm,x6=df;var S6=function(t){return x6(t)&&"[object Map]"==w6(t)},C6=If,T6=Bf&&Bf.isMap,E6=T6?C6(T6):S6,A6=Pm,k6=df;var R6=function(t){return k6(t)&&"[object Set]"==A6(t)},O6=If,N6=Bf&&Bf.isSet,M6=N6?O6(N6):R6,I6=Rp,P6=r5,B6=u5,L6=g5,F6=R5,D6=N5,j6=M5,z6=B5,U6=$5,H6=dm,W6=Y5,$6=Pm,V6=K5,G6=p6,X6=_6,Y6=Qp,q6=Cf,K6=E6,Z6=ld,Q6=M6,J6=lm,t4=E5,e4="[object Arguments]",r4="[object Function]",n4="[object Object]",i4={};i4[e4]=i4["[object Array]"]=i4["[object ArrayBuffer]"]=i4["[object DataView]"]=i4["[object Boolean]"]=i4["[object Date]"]=i4["[object Float32Array]"]=i4["[object Float64Array]"]=i4["[object Int8Array]"]=i4["[object Int16Array]"]=i4["[object Int32Array]"]=i4["[object Map]"]=i4["[object Number]"]=i4[n4]=i4["[object RegExp]"]=i4["[object Set]"]=i4["[object String]"]=i4["[object Symbol]"]=i4["[object Uint8Array]"]=i4["[object Uint8ClampedArray]"]=i4["[object Uint16Array]"]=i4["[object Uint32Array]"]=!0,i4["[object Error]"]=i4[r4]=i4["[object WeakMap]"]=!1;var s4=function t(e,r,n,i,s,o){var a,l=1&r,h=2&r,u=4&r;if(n&&(a=s?n(e,i,s,o):n(e)),void 0!==a)return a;if(!Z6(e))return e;var c=Y6(e);if(c){if(a=V6(e),!l)return j6(e,a)}else{var d=$6(e),p=d==r4||"[object GeneratorFunction]"==d;if(q6(e))return D6(e,l);if(d==n4||d==e4||p&&!s){if(a=h||p?{}:X6(e),!l)return h?U6(e,F6(a,e)):z6(e,L6(a,e))}else{if(!i4[d])return s?e:{};a=G6(e,d,l)}}o||(o=new I6);var f=o.get(e);if(f)return f;o.set(e,a),Q6(e)?e.forEach((function(i){a.add(t(i,r,n,i,e,o))})):K6(e)&&e.forEach((function(i,s){a.set(s,t(i,r,n,s,e,o))}));var m=c?void 0:(u?h?W6:H6:h?t4:J6)(e);return P6(m||e,(function(i,s){m&&(i=e[s=i]),B6(a,s,t(i,r,n,s,e,o))})),a},o4=s4;var a4=pt((function(t){return o4(t,5)}));const l4={"零":0,"一":1,"二":2,"三":3,"四":4,"五":5,"六":6,"七":7,"八":8,"九":9},h4=["零","一","二","三","四","五","六","七","八","九"],u4=["","万","亿","万亿","亿亿"],c4=["","十","百","千"],d4={"十":{value:10,secUnit:!1},"百":{value:100,secUnit:!1},"千":{value:1e3,secUnit:!1},"万":{value:1e4,secUnit:!0},"亿":{value:1e8,secUnit:!0}};function p4(t){if(!t)return 0;let e=0,r=0,n=0,i=!1;const s=t.split("");for(let t=0;t<s.length;t++){const o=l4[s[t]];if(void 0!==o)n=o,t===s.length-1&&(r+=n);else{const o=d4[s[t]],a=o.value;i=o.secUnit,i?(r=(r+n)*a,e+=r,r=0):r+=n*a,n=0}}return e+r}function f4(t){let e="",r="",n=0,i=!0;for(;t>0;){const s=t%10;0===s?i||(i=!0,r=h4[s]+r):(i=!1,e=h4[s],e+=c4[n],r=e+r),n++,t=Math.floor(t/10)}return r}function m4(t){let e=0,r="",n="",i=!1;if(0===t)return h4[0];for(;t>0;){const s=t%1e4;i&&(n=h4[0]+n),r=f4(s),r+=0!==s?u4[e]:u4[0],n=r+n,i=s<1e3&&s>0,t=Math.floor(t/1e4),e++}return n}function g4(t){if(!t)return{isExtendNumber:!1};const e=/0|([1-9]+[0-9]*)/g,r=e.test(t);if(r){const r=t.match(e);if(r&&r.length>0){const e=r[r.length-1],n=t.lastIndexOf(e),i=t.substr(0,n),s=t.substr(n+e.length);return{isExtendNumber:!0,matchTxt:Number(e),beforeTxt:i,afterTxt:s}}return{isExtendNumber:!1}}return{isExtendNumber:r}}function y4(t){let e=!0;const r=t[1]-t[0];for(let n=1;n<t.length;n++)if(t[n]-t[n-1]!==r){e=!1;break}return e}function b4(t,e){const r=[];for(let n=1;n<=e;n++){const e=(n-1)%t.length,i=a4(t[e]);A4(i),r.push({v:null,t:null,...i})}return r}function v4(t,e,r,n){n&&t.forEach((t=>{const{v:e,meta:r}=n.toNumber(t.v);t.v=e,t.f=r}));const i=[],s=[];for(let e=0;e<t.length;e++)s.push(Number(t[e]?.v));if(t.length>2&&function(t){let e=!0;const r=t[1]/t[0];for(let n=1;n<t.length;n++)if(t[n]/t[n-1]!==r){e=!1;break}return e}(s))for(let r=1;r<=e;r++){const e=(r-1)%t.length,s=a4(t[e]);A4(s);const o=Number(t[t.length-1]?.v)*(Number(t[1]?.v)/Number(t[0]?.v))**r;s&&(s.v=n?n.fromNumber(o,s.f):o,i.push(s))}else{const o=function(t){const e=[];for(let r=1;r<=t;r++)e.push(r);return e}(t.length);for(let a=1;a<=e;a++){const e=(a-1)%t.length,l=a4(t[e]);A4(l);const h=r===Z3.DOWN||r===Z3.RIGHT,u=_4(t.length+a,s,o,h);l&&(l.v=n?n.fromNumber(u,l.f):u,i.push(l))}}return i}function _4(t,e,r,n=!0){function i(t){let e=0;for(let r=0;r<t.length;r++)e+=t[r];return e/t.length}const s=i(r),o=i(e);let a,l=0,h=0;for(let t=0;t<r.length;t++)l+=(r[t]-s)*(e[t]-o),h+=(r[t]-s)*(r[t]-s);a=0===h?n?1:-1:l/h;const u=o-a*s;return Math.round(1e5*(u+a*t))/1e5}function w4(t,e,r){const n=[],i=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=e;s++){const e=(s-1)%t.length,o=a4(t[e]);A4(o);const a=`${t[t.length-1]?.v}`;if(!a)continue;const l=a?.match(i),h=l?.[l.length-1];if(!h)continue;const u=Math.abs(Number(h)+r*s),c=a.lastIndexOf(h),d=a.substr(0,c)+u.toString()+a.substr(c+h.length);o&&(o.v=d,n.push(o))}return n}function x4(t,e,r,n=0){const i=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=i.length)return[];const s=i[n],o=[];for(let n=1;n<=e;n++){const e=(n-1)%t.length,i=a4(t[e]);A4(i);let a=0;if(t[t.length-1]?.v===s[0])a=7+r*n;else{const e=`${t[t.length-1]?.v}`;if(e){a=p4(e.substr(e.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 S4(t,e,r){const n=[];for(let i=1;i<=e;i++){const e=(i-1)%t.length,s=a4(t[e]);A4(s);const o=p4(`${t[t.length-1]?.v}`)+r*i;let a;a=o<=0?"零":m4(o),s&&(s.v=a,n.push(s))}return n}const C4={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 T4(t){let e="";const r=[];return Object.keys(C4).forEach((n=>{C4[n].includes(t)&&(e=n,r.push(...C4[n]))})),{name:e,series:r}}function E4(t,e,r,n){const i=n.length,s=[];for(let o=1;o<=e;o++){const e=(o-1)%t.length,a=a4(t[e]);A4(a);const l=`${t[t.length-1]?.v}`;let h=n.indexOf(l)+r*o;h<0&&(h+=Math.abs(r)*i);const u=h%i;a&&(a.v=n[u],s.push(a))}return s}function A4(t){t&&"custom"in t&&delete t.custom}function k4(t,e,r=new Date){const n=t.trim();if("yyyy-MM-dd"===e){const[t,e,r]=n.split("-").map(Number);return new Date(t,e-1,r)}if("yyyy-M-d"===e){const[t,e,r]=n.split("-").map(Number);return new Date(t,e-1,r)}if("yyyy/MM/dd"===e){const[t,e,r]=n.split("/").map(Number);return new Date(t,e-1,r)}if("yyyy/M/d"===e){const[t,e,r]=n.split("/").map(Number);return new Date(t,e-1,r)}if("MM/dd/yyyy"===e){const[t,e,r]=n.split("/").map(Number);return new Date(r,t-1,e)}if("yyyy年M月d日"===e){const t=n.match(/^(\d{4})年(\d{1,2})月(\d{1,2})(日)?$/);if(t)return new Date(Number(t[1]),Number(t[2])-1,Number(t[3]))}const i=new Date(n);return isNaN(i.getTime())?new Date(r):i}function R4(t){return!isNaN(t.getTime())}function O4(t,e){const r=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())-Date.UTC(e.getFullYear(),e.getMonth(),e.getDate());return Math.floor(r/864e5)}class N4{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:t=>{const e=t.match(/(\d{4})年(\d{1,2})月(\d{1,2})/);if(!e)throw new Error("无效的中文日期格式");return new Date(+e[1],+e[2]-1,+e[3])}}];detect(t){if(t instanceof Date)return!isNaN(t.getTime());if("string"!=typeof t)return!1;const e=t.trim(),r=this.dateFormats.find((t=>t.pattern.test(e)));if(r)try{return R4(r.parser?r.parser(e):k4(e,r.format,new Date))}catch{return!1}return!1}toNumber(t){let e,r;if(t instanceof Date){if(!R4(t))throw new Error("无效的日期对象");e=t,r="yyyy-MM-dd"}else{const n=t.trim(),i=this.dateFormats.find((t=>t.pattern.test(n)));if(!i)throw new Error(`不支持的日期格式: ${n}`);if(e=i.parser?i.parser(n):k4(n,i.format,new Date),!R4(e))throw new Error(`无效的日期值: ${n}`);r=i.format}return{v:O4(e,this.baseDate),meta:r}}fromNumber(t,e){const r=function(t,e){const r=new Date(t);return r.setDate(r.getDate()+e),r}(this.baseDate,t);return r.setHours(0,0,0,0),function(t,e){const r=t.getFullYear(),n=t.getMonth()+1,i=t.getDate(),s=t=>t.toString().padStart(2,"0");switch(e){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,e||"yyyy-MM-dd")}}const M4=new class{converters=[];register(t){this.converters.push(t)}getConverter(t){return this.converters.find((e=>e.detect(t)))||null}getConverterByKey(t){return this.converters.find((e=>e.key===t))||null}};M4.register(new N4);const I4={type:t5.DATE,priority:1100,match:(t,e)=>"string"==typeof t?.v&&M4.getConverter(t.v)instanceof N4,isContinue:(t,e)=>t.type===t5.DATE,applyFunctions:{[Q3.SERIES]:(t,e,r)=>{const{data:n}=t,i=M4.getConverter(n[0]?.v);return r===Z3.LEFT||r===Z3.UP?(n.reverse(),v4(n,e,r,i).reverse()):v4(n,e,r,i)}}},P4={type:t5.NUMBER,priority:1e3,match:t=>"number"==typeof t?.v||t?.t===J3.NUMBER,isContinue:(t,e)=>t.type===t5.NUMBER,applyFunctions:{[Q3.SERIES]:(t,e,r)=>{const{data:n}=t;return r===Z3.LEFT||r===Z3.UP?(n.reverse(),v4(n,e,r).reverse()):v4(n,e,r)}}},B4={type:t5.OTHER,priority:0,match:()=>!0,isContinue:(t,e)=>t.type===t5.OTHER},L4={type:t5.EXTEND_NUMBER,priority:900,match:t=>g4(`${t?.v}`||"").isExtendNumber,isContinue:(t,e)=>{if(t.type===t5.EXTEND_NUMBER){const{beforeTxt:r,afterTxt:n}=g4(`${t.cellData?.v}`||""),{beforeTxt:i,afterTxt:s}=g4(`${e?.v}`||"");if(r===i&&n===s)return!0}return!1},applyFunctions:{[Q3.SERIES]:(t,e,r)=>{const{data:n}=t,i=r===Z3.UP||r===Z3.LEFT;let s;if(1===n.length)return s=i?-1:1,U4(w4(n,e,s),i);const o=[];for(let t=0;t<n.length;t++){const e=`${n[t]?.v}`;e&&o.push(Number(g4(e).matchTxt))}return i&&(n.reverse(),o.reverse()),y4(o)?(s=o[1]-o[0],U4(w4(n,e,s),i)):b4(n,e)}}},F4={type:t5.CHN_NUMBER,priority:830,match:t=>!!function(t){if(!t)return!1;let e=!0;if(t)if(1===t.length)e="日"===t||t in l4;else{const r=t.split("");for(let t=0;t<r.length;t++)if(!(r[t]in l4)&&!(r[t]in d4)){e=!1;break}}return e}(`${t?.v}`||""),isContinue:(t,e)=>t.type===t5.CHN_NUMBER,applyFunctions:{[Q3.SERIES]:(t,e,r)=>{const{data:n}=t,i=r===Z3.LEFT||r===Z3.UP;if(1===n.length){let t;return t=i?-1:1,U4(S4(n,e,t),i)}let s=!1;for(let t=0;t<n.length;t++){const e=n[t]?.v;if("日"===e){s=!0;break}}const o=[];let a=0;for(let t=0;t<n.length;t++){const e=`${n[t]?.v}`;"日"===e?0===t?o.push(0):(a++,o.push(7*a)):s&&p4(e)>0&&p4(e)<7?o.push(p4(e)+7*a):o.push(p4(e))}if(i&&(n.reverse(),o.reverse()),y4(o)){return U4(S4(n,e,o[1]-o[0]),i)}return b4(n,e)}}},D4={type:t5.CHN_WEEK2,priority:820,match:t=>!!function(t){let e;return e=2===t.length&&("周一"===t||"周二"===t||"周三"===t||"周四"===t||"周五"===t||"周六"===t||"周日"===t),e}(`${t?.v}`||""),isContinue:(t,e)=>t.type===t5.CHN_WEEK2,applyFunctions:{[Q3.SERIES]:(t,e,r)=>{const{data:n}=t,i=r===Z3.LEFT||r===Z3.UP;if(1===n.length){let t;return t=i?-1:1,U4(x4(n,e,t,1),i)}const s=[];let o=0;for(let t=0;t<n.length;t++){const e=`${n[t]?.v}`,r=e?.substr(e.length-1,1);"周日"===e?0===t?s.push(0):(o++,s.push(7*o)):s.push(p4(r)+7*o)}if(i&&(n.reverse(),s.reverse()),y4(s)){return U4(x4(n,e,s[1]-s[0],1),i)}return b4(n,e)}}},j4={type:t5.CHN_WEEK3,priority:810,match:t=>function(t){let e;return e=3===t.length&&("星期一"===t||"星期二"===t||"星期三"===t||"星期四"===t||"星期五"===t||"星期六"===t||"星期日"===t),e}(`${t?.v}`||""),isContinue:(t,e)=>t.type===t5.CHN_WEEK3,applyFunctions:{[Q3.SERIES]:(t,e,r)=>{const{data:n}=t,i=r===Z3.LEFT||r===Z3.UP;if(1===n.length){let t;return t=i?-1:1,U4(x4(n,e,t,2),i)}const s=[];let o=0;for(let t=0;t<n.length;t++){const e=`${n[t]?.v}`;if(e){const r=e.substr(e.length-1,1);"星期日"===e?0===t?s.push(0):(o++,s.push(7*o)):s.push(p4(r)+7*o)}}if(i&&(n.reverse(),s.reverse()),y4(s)){return U4(x4(n,e,s[1]-s[0],2),i)}return b4(n,e)}}},z4={type:t5.LOOP_SERIES,priority:800,match:t=>function(t){let e=!1;return Object.keys(C4).forEach((r=>{C4[r].includes(t)&&(e=!0)})),e}(`${t?.v}`||""),isContinue:(t,e)=>t.type===t5.LOOP_SERIES&&T4(`${t.cellData?.v}`||"").name===T4(`${e?.v}`||"").name,applyFunctions:{[Q3.SERIES]:(t,e,r)=>{const{data:n}=t,i=r===Z3.LEFT||r===Z3.UP,{series:s}=T4(`${n[0]?.v}`||"");if(1===n.length){let t;return t=i?-1:1,U4(E4(n,e,t,s),i)}const o=[];let a=0;for(let t=0;t<n.length;t++){const e=`${n[t]?.v}`;e&&(e===s[0]?0===t?o.push(0):(a++,o.push(a*s.length)):o.push(s.indexOf(e)+7*a))}if(i&&(n.reverse(),o.reverse()),y4(o)){return U4(E4(n,e,o[1]-o[0],s),i)}return b4(n,e)}}};function U4(t,e){return e?t.reverse():t}class H4{_rules=[];constructor(){this._init()}_init(){this._rules=[I4,P4,L4,F4,D4,j4,z4,B4].sort(((t,e)=>e.priority-t.priority))}registerRule(t){if(this._rules.find((e=>e.type===t.type)))throw new Error(`Registry rule failed, type '${t.type}' already exist!`);const e=this._rules.findIndex((e=>e.priority<t.priority));this._rules.splice(-1===e?this._rules.length:e,0,t)}getRules(){return this._rules}}function W4(t){const e=Math.min(t.start.col,t.end.col),r=Math.min(t.start.row,t.end.row),n=Math.max(t.start.col,t.end.col),i=Math.max(t.start.row,t.end.row),s=[],o=[];for(let t=e;t<=n;t++)s.push(t);for(let t=r;t<=i;t++)o.push(t);return{cols:s,rows:o}}function $4(t,e,r){return t===Z3.DOWN||t===Z3.UP?{cols:r.cols,rows:r.rows.filter((t=>!e.rows.includes(t)))}:{cols:r.cols.filter((t=>!e.cols.includes(t))),rows:r.rows}}function V4(t,e,r){const n=t.scenegraph.highPerformanceGetCell(e,r).globalAABBBounds;t.showDropDownMenu(e,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 G4(t){return{getValue:(e,r)=>{const n=t.getCellValue(r,e);return"number"!=typeof n&&isNaN(Number(n))?{v:n||"",t:J3.STRING}:{v:n,t:J3.NUMBER}},getMaxRows:()=>t.records.length,getMaxColumns:()=>t.columns.length}}class X4{sourceData=[];autoFillService;tableInstance;sourceRange;targetRange;direction;headers;options;constructor(t){this.options=t,this.autoFillService=new H4}setTable(t){this.headers={row:new Set,col:new Set},this.tableInstance=t,t.on(m.TABLE_EVENT_TYPE.DROPDOWN_MENU_CLICK,(t=>{"复制填充"===t.text?this.fillData(Q3.COPY):"序列填充"===t.text&&this.fillData(Q3.SERIES)}));const e=this.tableInstance.getAllRowHeaderCells()[0];e&&e.forEach((t=>{this.headers.col.add(t.col)}));const r=this.tableInstance.getAllColumnHeaderCells()[0];r&&r.forEach((t=>{this.headers.row.add(t.row)}))}handleStartDrag(t){this.sourceRange=W4(t),this.sourceRange.cols=this.sourceRange.cols.filter((t=>!this.headers.col.has(t))),this.sourceRange.rows=this.sourceRange.rows.filter((t=>!this.headers.row.has(t)))}handleEndDrag(t,e){this.direction=e;const r=W4(t);this.targetRange=$4(this.direction,this.sourceRange,r),this.targetRange.cols=this.targetRange.cols.filter((t=>!this.headers.col.has(t))),this.targetRange.rows=this.targetRange.rows.filter((t=>!this.headers.row.has(t))),this.options?.fillMode?this.fillData(this.options.fillMode):V4(this.tableInstance,Math.max(...r.cols),Math.max(...r.rows))}handleDbClick(){if(!this.sourceRange)return;this.direction=Z3.DOWN;const t=W4(this._detectFillRange());if(this.targetRange=$4(this.direction,this.sourceRange,t),this.targetRange.cols=this.targetRange.cols.filter((t=>!this.headers.col.has(t))),this.targetRange.rows=this.targetRange.rows.filter((t=>!this.headers.row.has(t))),0===this.targetRange.cols.length||0===this.targetRange.rows.length)return;const e=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(e,r,!1,!1,!1,!0,!0),s.updateInteractionState(Iu.grabing),s.updateSelectPos(n,i,!1,!1,!1,!0,!0),s.endSelectCells(!1,!1),s.updateInteractionState(Iu.default),this.options?.fastFillMode?this.fillData(this.options.fastFillMode):V4(this.tableInstance,n,i)}fillData(t){this.sourceData=this.getSourceData(this.sourceRange,this.direction);const e={source:this.sourceRange,target:this.targetRange};this._fillData(e,this.direction,t)}getSourceData(t,e){const r=this.autoFillService.getRules(),n=[],i=e===Z3.DOWN||e===Z3.UP;let s,o;i?(s=t.cols,o=t.rows):(s=t.rows,o=t.cols);const a=G4(this.tableInstance);return s.forEach((t=>{const e=this.getEmptySourceDataPiece(),s={type:void 0,cellData:void 0};o.forEach((n=>{let l;l=i?a.getValue(n,t):a.getValue(t,n);const{type:h,isContinue:u}=r.find((t=>t.match(l,null)))||B4;if(u(s,l)){const t=e[h],r=t[t.length-1];r.data.push(l),r.index.push(n-o[0])}else{const t=e[h];t?t.push({data:[l],index:[n-o[0]]}):e[h]=[{data:[l],index:[n-o[0]]}]}s.type=h,s.cellData=l})),n.push(e)})),n}getEmptySourceDataPiece(){const t={};return this.autoFillService.getRules().forEach((e=>{t[e.type]=[]})),t}_detectFillRange(){const t={row:Math.min(...this.sourceRange.rows),col:Math.min(...this.sourceRange.cols)},e={row:Math.max(...this.sourceRange.rows),col:Math.max(...this.sourceRange.cols)},r=G4(this.tableInstance),n=r.getMaxRows(),i=r.getMaxColumns();let s=e.row;if(t.col>0&&r.getValue(t.row,t.col-1)?.v){let e=t.row;for(;r.getValue(e,t.col-1)?.v&&e<=n;)e+=1;s=e-1}else if(e.col<i&&r.getValue(e.row,e.col+1)?.v){let i=t.row;for(;r.getValue(i,e.col+1)?.v&&i<=n;)i+=1;s=i-1}for(let n=e.row+1;n<=s;n++)for(let i=t.col;i<=e.col;i++)if(r.getValue(n,i)?.v){s=n-1;break}return{start:{row:t.row,col:t.col},end:{row:s,col:e.col}}}_fillData(t,e,r){const{source:n,target:i}=t;if(!n||!i||null==e)return;const{cols:s,rows:o}=i,{cols:a,rows:l}=n,h=this.sourceData;let u;u=e===Z3.DOWN||e===Z3.UP?l.length:a.length;const c=[];if(e===Z3.DOWN||e===Z3.UP){const n=o.length,i=[];s.forEach(((s,o)=>{const a=h[o],l=this.getApplyData(a,u,n,e,r,t);i.push(l)}));for(let t=0;t<i[0].length;t++){const e=[];for(let r=0;r<i.length;r++)e.push({s:null,...i[r][t]});c.push(e)}}else{const n=s.length;o.forEach(((i,s)=>{const o=h[s],a=this.getApplyData(o,u,n,e,r,t),l=[];for(let t=0;t<a.length;t++)l.push({s:null,...a[t]});c.push(l)}))}const d=[];o.forEach(((t,e)=>{const r=[];s.forEach(((n,i)=>{const s=function(t,e,r){const n=t.getCellRange(e,r);return n.start.col!==n.end.col||n.start.row!==n.end.row?n:null}(this.tableInstance,n,t);s&&this.tableInstance.unmergeCells(s.start.col,s.start.row,s.end.col,s.end.row),c[e][i]&&r.push(c[e][i].v+"")})),d.push(r)}));const p=Math.min(...o),f=Math.min(...s);this.tableInstance.changeCellValues(f,p,d)}getApplyData(t,e,r,n,i,s){const o=[],a=Math.floor(r/e),l=r%e,h=this.autoFillService.getRules(),u={};h.forEach((t=>{u[t.type]=[]})),h.forEach((o=>{const{type:h,applyFunctions:c={}}=o,d=t[h];d&&d.forEach((o=>{const d=function(t,e){let r=0;for(let n=0;n<t.length&&t[n]<e;n++)r++;return r}(o.index,l),p=o.index.length*a+d,f=this.applyFunctions(o,p,n,i,c,t,s),m=function(t,e,r){const n=[],i=Math.floor(e/t),s=e%t;let o=0;if(i>0){for(let e=0;e<i;e++)for(let i=0;i<r.length;i++)n[r[i]+e*t]=o,o++;for(let e=0;e<r.length&&r[e]<s;e++)n[r[e]+t*i]=o,o++}else for(let t=0;t<r.length&&r[t]<s;t++)n[r[t]]=o,o++;return n}(e,r,o.index);u[h].push({data:f,index:m})}))}));for(let t=0;t<r;t++)h.forEach((e=>{const{type:r}=e,n=u[r];for(let e=0;e<n.length;e++)t in n[e].index&&o.push(n[e].data[n[e].index[t]])}));return o}applyFunctions(t,e,r,n,i,s,o){const{data:a}=t,l=r===Z3.UP||r===Z3.LEFT;if(n===Q3.COPY){const n=i?.[Q3.COPY];return n?n(t,e,r,s,o):(l&&a.reverse(),b4(a,e))}if(n===Q3.SERIES){const n=i?.[Q3.SERIES];return n?n(t,e,r,s):(l&&a.reverse(),i?.[Q3.COPY]?i[Q3.COPY](t,e,r,s,o):b4(a,e))}}}t.AddRowColumnPlugin=class{id="add-row-column";name="Add Row Column";runTime=[m.TABLE_EVENT_TYPE.MOUSEENTER_CELL,m.TABLE_EVENT_TYPE.MOUSELEAVE_CELL,m.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE];pluginOptions;table;hoverCell;hideAllTimeoutId_addColumn;hideAllTimeoutId_addRow;leftDotForAddColumn;rightDotForAddColumn;addIconForAddColumn;addLineForAddColumn;topDotForAddRow;bottomDotForAddRow;addIconForAddRow;addLineForAddRow;constructor(t={addColumnEnable:!0,addRowEnable:!0}){this.id=t.id??this.id,this.pluginOptions=t,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(...t){const e=t[0],r=t[1],n=t[2];if(this.table=n,r===m.TABLE_EVENT_TYPE.MOUSEENTER_CELL){clearTimeout(this.hideAllTimeoutId_addColumn),clearTimeout(this.hideAllTimeoutId_addRow);const t=n.canvas.getBoundingClientRect(),r=n.getCellAtRelativePosition(e.event.clientX-t.left,e.event.clientY-t.top);this.hoverCell=r;const i=n.getCellRelativeRect(r.col,r.row);if(this.pluginOptions.addColumnEnable){const e=n.isSeriesNumber(r.col,0);this.showDotForAddColumn(t.top-6,i.left+t.left,i.right+t.left,!e)}if(this.pluginOptions.addRowEnable){const e=n.isHeader(r.col,r.row);this.showDotForAddRow(i.top+t.top,t.left-6,i.bottom+t.top,!e,!e)}}else r===m.TABLE_EVENT_TYPE.MOUSELEAVE_CELL||r===m.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 t=document.createElement("div");t.textContent="+",t.style.color="white",t.style.fontSize="18px",t.style.fontWeight="bold",t.style.lineHeight="15px",t.style.userSelect="none",t.style.cursor="pointer",t.style.verticalAlign="top",t.style.textAlign="center",this.addIconForAddColumn.appendChild(t),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 t=this.leftDotForAddColumn.offsetWidth,e=this.leftDotForAddColumn.offsetHeight;this.showAddIconForAddColumn(this.leftDotForAddColumn.offsetLeft+t/2,this.leftDotForAddColumn.offsetTop+e/2,!0),this.showSplitLineForAddColumn(this.leftDotForAddColumn.offsetLeft+t/2-1,this.leftDotForAddColumn.offsetTop+e/2+2,this.table.getDrawRange().height)})),this.rightDotForAddColumn.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addColumn),this.addIconForAddColumn.style.display="block";const t=this.rightDotForAddColumn.offsetWidth,e=this.rightDotForAddColumn.offsetHeight;this.showAddIconForAddColumn(this.rightDotForAddColumn.offsetLeft+t/2,this.rightDotForAddColumn.offsetTop+e/2,!1),this.showSplitLineForAddColumn(this.rightDotForAddColumn.offsetLeft+t/2-1,this.rightDotForAddColumn.offsetTop+e/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",(t=>{const e="left"===this.addIconForAddColumn.dataset.addIconType;this.table.options.columns;const r=this.hoverCell.col,n=e?r:r+1;this.pluginOptions.addColumnCallback?this.pluginOptions.addColumnCallback(n,this.table):this.table.addColumn({field:n,title:`New Column ${r}`,width:100},n,!0),this.delayHideAllForAddColumn(0)}))}showDotForAddColumn(t,e,r,n=!0,i=!0){const s=this.leftDotForAddColumn.offsetWidth,o=this.leftDotForAddColumn.offsetHeight;this.leftDotForAddColumn.style.left=e-s/2+"px",this.leftDotForAddColumn.style.top=t-o/2+"px",this.rightDotForAddColumn.style.left=r-s/2+"px",this.rightDotForAddColumn.style.top=t-o/2+"px",this.leftDotForAddColumn.style.display=n?"block":"none",this.rightDotForAddColumn.style.display=i?"block":"none"}showAddIconForAddColumn(t,e,r){const n=this.addIconForAddColumn.offsetWidth,i=this.addIconForAddColumn.offsetHeight,s=this.leftDotForAddColumn.offsetHeight;this.addIconForAddColumn.style.left=t-n/2+"px",this.addIconForAddColumn.style.top=e-i/2-s/2+"px",this.addIconForAddColumn.dataset.addIconType=r?"left":"right"}showSplitLineForAddColumn(t,e,r){this.addLineForAddColumn.style.left=`${t}px`,this.addLineForAddColumn.style.top=`${e}px`,this.addLineForAddColumn.style.height=`${r}px`,this.addLineForAddColumn.style.display="block"}delayHideAllForAddColumn(t=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"}),t)}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 t=document.createElement("div");t.textContent="+",t.style.color="white",t.style.fontSize="18px",t.style.fontWeight="bold",t.style.lineHeight="15px",t.style.userSelect="none",t.style.cursor="pointer",t.style.verticalAlign="top",t.style.textAlign="center",this.addIconForAddRow.appendChild(t),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 t=this.topDotForAddRow.offsetWidth,e=this.topDotForAddRow.offsetHeight;this.showAddIconForAddRow(this.topDotForAddRow.offsetLeft+t/2,this.topDotForAddRow.offsetTop+e/2,!0),this.showSplitLineForAddRow(this.topDotForAddRow.offsetLeft+t+2,this.topDotForAddRow.offsetTop+e/2-1,this.table.getDrawRange().width)})),this.bottomDotForAddRow.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addRow),this.addIconForAddRow.style.display="block";const t=this.bottomDotForAddRow.offsetWidth,e=this.bottomDotForAddRow.offsetHeight;this.showAddIconForAddRow(this.bottomDotForAddRow.offsetLeft+t/2,this.bottomDotForAddRow.offsetTop+e/2,!1),this.showSplitLineForAddRow(this.bottomDotForAddRow.offsetLeft+t+2,this.bottomDotForAddRow.offsetTop+e/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",(t=>{const e="top"===this.addIconForAddRow.dataset.addIconType,r=this.hoverCell.row,n=e?r:r+1;if(this.pluginOptions.addRowCallback)this.pluginOptions.addRowCallback(n,this.table);else{const t=this.table.getRecordIndexByCell(0,n);this.table.addRecord({},t)}this.delayHideAllForAddRow(0)}))}showDotForAddRow(t,e,r,n=!0,i=!0){const s=this.topDotForAddRow.offsetWidth,o=this.topDotForAddRow.offsetHeight;this.topDotForAddRow.style.left=e-s/2+"px",this.topDotForAddRow.style.top=t-o/2+"px",this.bottomDotForAddRow.style.left=e-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(t,e,r){const n=this.addIconForAddRow.offsetWidth,i=this.addIconForAddRow.offsetHeight,s=this.topDotForAddRow.offsetWidth;this.addIconForAddRow.style.left=t-n/2-s/2+"px",this.addIconForAddRow.style.top=e-i/2+"px",this.addIconForAddRow.dataset.addIconType=r?"top":"bottom"}showSplitLineForAddRow(t,e,r){this.addLineForAddRow.style.left=`${t}px`,this.addLineForAddRow.style.top=`${e}px`,this.addLineForAddRow.style.width=`${r}px`,this.addLineForAddRow.style.display="block"}delayHideAllForAddRow(t=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"}),t)}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()}},t.AutoFillPlugin=class{id="auto-fill";name="Auto Fill";runTime=[m.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE,m.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END,m.TABLE_EVENT_TYPE.DBLCLICK_FILL_HANDLE];table;autoFillManager;constructor(t){this.autoFillManager=new X4(t)}run(...t){if(t[1]===m.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE){const[e,r,n]=t;this.table=n,this.autoFillManager.setTable(this.table),this.autoFillManager.handleStartDrag(this.table?.getSelectedCellRanges()[0])}else if(t[1]===m.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END){const[{direction:e}]=t;this.autoFillManager.handleEndDrag(this.table?.getSelectedCellRanges()[0],e)}else t[1]===m.TABLE_EVENT_TYPE.DBLCLICK_FILL_HANDLE&&this.autoFillManager.handleDbClick()}},t.CarouselAnimationPlugin=class{table;rowCount;colCount;animationDuration;animationDelay;animationEasing;replaceScrollAction;playing;row;col;willUpdateRow=!1;willUpdateCol=!1;customDistRowFunction;customDistColFunction;constructor(t,e){this.table=t,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.replaceScrollAction=e?.replaceScrollAction??!1,this.customDistColFunction=e.customDistColFunction,this.customDistRowFunction=e.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(t){this.rowCount?(t.deltaY>0?(this.row+=this.rowCount,this.row=Math.min(this.row,this.table.rowCount-this.table.frozenRowCount)):t.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&&(t.deltaX>0?(this.col+=this.colCount,this.col=Math.min(this.col,this.table.colCount-this.table.frozenColCount)):t.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 t=!0;const e=this.customDistRowFunction&&this.customDistRowFunction(this.row,this.table);e?(this.row=e.distRow,t=e.animation??!0):g(this.row)&&this.table.scenegraph.proxy.screenTopRow!==this.row?(this.row=this.table.frozenRowCount,t=!1):g(this.row)||this.table.scenegraph.proxy.screenTopRow===Math.floor(this.row)?this.row+=this.rowCount:(this.row=this.table.frozenRowCount,t=!1),this.table.scrollToRow(this.row,t?{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 t=!0;const e=this.customDistColFunction&&this.customDistColFunction(this.col,this.table);e?(this.col=e.distCol,t=e.animation??!0):g(this.col)&&this.table.scenegraph.proxy.screenLeftCol!==this.col?(this.col=this.table.frozenColCount,t=!1):g(this.col)||this.table.scenegraph.proxy.screenLeftCol===Math.floor(this.col)?this.col+=this.colCount:(this.col=this.table.frozenColCount,t=!1),this.table.scrollToCol(this.col,t?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateCol=!0,setTimeout((()=>{this.willUpdateCol=!1,this.updateCol()}),this.animationDuration+this.animationDelay)}},t.ColumnSeriesPlugin=class{id="column-series";name="Column Series";runTime=[m.TABLE_EVENT_TYPE.BEFORE_INIT,m.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];pluginOptions;table;columns=[];constructor(t){this.id=t.id??this.id,this.pluginOptions=Object.assign({columnCount:100},t)}run(...t){if(t[1]===m.TABLE_EVENT_TYPE.BEFORE_INIT){const e=t[0],r=t[2];this.table=r;const n=e.options;this.columns=this.generateColumns(this.pluginOptions.columnCount),n.columns=this.columns}else if(t[1]===m.TABLE_EVENT_TYPE.BEFORE_KEYDOWN){const e=t[0].event;this.pluginOptions.autoExtendColumnTriggerKeys?.includes(e.key)&&this.table.stateManager.select.cellPos.col===this.table.colCount-1&&this.table.addColumn(this.generateColumn(this.table.colCount-1))}}generateColumns(t){const e=[];for(let r=0;r<t;r++)e.push(this.generateColumn(r));return e}generateColumn(t){return{title:this.pluginOptions.generateColumnTitle?this.pluginOptions.generateColumnTitle(t):this.generateColumnField(t)}}generateColumnField(t){if(t<26)return String.fromCharCode(65+t);const e=[];for(t++;t>0;)t--,e.unshift(String.fromCharCode(65+t%26)),t=Math.floor(t/26);return e.join("")}resetColumnCount(t){this.pluginOptions.columnCount=t,this.columns=this.generateColumns(t),this.table.updateColumns(this.columns)}},t.ConditionFilter=E3,t.ContextMenuPlugin=class{id="context-menu";name="Context Menu";runTime=[m.TABLE_EVENT_TYPE.CONTEXTMENU_CELL,m.TABLE_EVENT_TYPE.PLUGIN_EVENT];pluginOptions;table;menuManager;menuHandler;constructor(t={}){this.id=t.id??this.id,this.pluginOptions=t,this.menuManager=new Ku,this.menuHandler=new e3,this.initDefaultMenuItems()}initDefaultMenuItems(){this.pluginOptions.columnSeriesNumberMenuItems||(this.pluginOptions.columnSeriesNumberMenuItems=ec),this.pluginOptions.rowSeriesNumberMenuItems||(this.pluginOptions.rowSeriesNumberMenuItems=rc),this.pluginOptions.cornerSeriesNumberMenuItems||(this.pluginOptions.cornerSeriesNumberMenuItems=nc),this.pluginOptions.headerCellMenuItems||(this.pluginOptions.headerCellMenuItems=tc),this.pluginOptions.bodyCellMenuItems||(this.pluginOptions.bodyCellMenuItems=Ju)}handleContextMenuCell=(t,e)=>{const{col:r,row:n}=t,i=t.event.clientX,s=t.event.clientY,o=e.isSeriesNumber(r,n);let a=[];if(a=e.isHeader(r,n)?o?this.pluginOptions.columnSeriesNumberMenuItems||[]:this.pluginOptions.headerCellMenuItems||[]:o?this.pluginOptions.rowSeriesNumberMenuItems||[]:this.pluginOptions.bodyCellMenuItems||[],a.length>0){const t=e.getCellRange(r,n);a=t.start.col!==t.end.col||t.start.row!==t.end.row?a.filter((t=>"string"==typeof t||"merge_cells"!==t.menuKey)):a.filter((t=>"string"==typeof t||"unmerge_cells"!==t.menuKey)),this.pluginOptions.beforeShowAdjustMenuItems&&(a=this.pluginOptions.beforeShowAdjustMenuItems(a,e,r,n)),this.showContextMenu(a,i,s,r,n)}};handlePluginEvent=(t,e)=>{const{eventType:r,rowIndex:n,colIndex:i,isCorner:s}=t.pluginEventInfo,o=t.plugin,a=t.event.clientX,l=t.event.clientY;if("table-series-number"===o.id&&"rightclick"===r){let t=[];s?t=this.pluginOptions.cornerSeriesNumberMenuItems||[]:void 0!==n?t=this.pluginOptions.rowSeriesNumberMenuItems||[]:void 0!==i&&(t=this.pluginOptions.columnSeriesNumberMenuItems||[]),this.pluginOptions.beforeShowAdjustMenuItems&&(t=this.pluginOptions.beforeShowAdjustMenuItems(t,e,i,n)),this.showContextMenu(t,a,l,i,n)}};run(...t){const e=t[0],r=t[1],n=t[2];this.table=n,e.event.preventDefault(),r===m.TABLE_EVENT_TYPE.CONTEXTMENU_CELL?this.handleContextMenuCell(e,n):r===m.TABLE_EVENT_TYPE.PLUGIN_EVENT&&this.handlePluginEvent(e,n)}handleMenuClickCallback=(t,e)=>{"function"==typeof this.pluginOptions.menuClickCallback?this.pluginOptions.menuClickCallback(t,e):this.handleMenuClick(t,e)};showContextMenu(t,e,r,n,i){this.menuManager.showMenu(t,e,r,{rowIndex:i,colIndex:n},this.table),this.menuManager.setClickCallback(this.handleMenuClickCallback)}handleMenuClick(e,r){const{menuKey:n,rowIndex:i,colIndex:s,inputValue:o=1}=e;if("object"==typeof this.pluginOptions.menuClickCallback&&this.pluginOptions.menuClickCallback[n])this.pluginOptions.menuClickCallback[n](e,r);else switch(n){case t.MenuKey.COPY:this.menuHandler.handleCopy(r);break;case t.MenuKey.CUT:this.menuHandler.handleCut(r);break;case t.MenuKey.PASTE:this.menuHandler.handlePaste(r);break;case t.MenuKey.INSERT_ROW_ABOVE:this.menuHandler.handleInsertRowAbove(r,i,o);break;case t.MenuKey.INSERT_ROW_BELOW:this.menuHandler.handleInsertRowBelow(r,i,o);break;case t.MenuKey.INSERT_COLUMN_LEFT:this.menuHandler.handleInsertColumnLeft(r,s,o);break;case t.MenuKey.INSERT_COLUMN_RIGHT:this.menuHandler.handleInsertColumnRight(r,s,o);break;case t.MenuKey.DELETE_ROW:this.menuHandler.handleDeleteRow(r,i);break;case t.MenuKey.DELETE_COLUMN:this.menuHandler.handleDeleteColumn(r,s);break;case t.MenuKey.HIDE_COLUMN:this.menuHandler.handleHideColumn(r,s);break;case t.MenuKey.SORT:this.menuHandler.handleSort(r,s);break;case t.MenuKey.MERGE_CELLS:this.menuHandler.handleMergeCells(r);break;case t.MenuKey.UNMERGE_CELLS:this.menuHandler.handleUnmergeCells(r);break;case t.MenuKey.FREEZE_TO_THIS_ROW:this.menuHandler.handleFreezeToRow(r,i);break;case t.MenuKey.FREEZE_TO_THIS_COLUMN:this.menuHandler.handleFreezeToColumn(r,s);break;case t.MenuKey.FREEZE_TO_THIS_ROW_AND_COLUMN:this.menuHandler.handleFreezeToRowAndColumn(r,i,s);break;case t.MenuKey.UNFREEZE:this.menuHandler.handleUnfreeze(r)}}release(){this.menuManager&&(this.menuManager.release(),this.menuManager=null),this.menuHandler&&(this.menuHandler.release(),this.menuHandler=null)}},t.DEFAULT_BODY_MENU_ITEMS=Ju,t.DEFAULT_COLUMN_SERIES_MENU_ITEMS=ec,t.DEFAULT_CORNER_SERIES_MENU_ITEMS=nc,t.DEFAULT_HEADER_MENU_ITEMS=tc,t.DEFAULT_ROW_SERIES_MENU_ITEMS=rc,t.ExcelEditCellKeyboardPlugin=class{id="excel-edit-cell-keyboard";name="Excel Edit Cell Keyboard";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED];table;pluginOptions;constructor(t){this.id=t?.id??this.id,this.pluginOptions=t,this.bindEvent()}run(...t){const e=t[2];this.table=e}bindEvent(){document.addEventListener("keydown",this.handleKeyDown.bind(this),!0)}handleKeyDown(t){if(this.table.editorManager)if("keydown"===this.table.editorManager.beginTriggerEditCellMode){if(this.table.editorManager.editingEditor&&this.isExcelShortcutKey(t)){const{col:e,row:r}=this.table.editorManager.editCell;this.table.editorManager.completeEdit(),this.table.getElement().focus(),t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key?this.table.selectCell(e,r+1):"Tab"===t.key?this.table.selectCell(e+1,r):"ArrowLeft"===t.key?this.table.selectCell(e-1,r):"ArrowRight"===t.key?this.table.selectCell(e+1,r):"ArrowDown"===t.key?this.table.selectCell(e,r+1):"ArrowUp"===t.key&&this.table.selectCell(e,r-1),t.stopPropagation(),t.preventDefault())}}else{const{col:e,row:r}=this.table.stateManager.select.cellPos;if(!this.table.editorManager.editingEditor||"Enter"!==t.key&&"Tab"!==t.key){if("Delete"===t.key){const e=this.table.getSelectedCellInfos();e?.length>0&&function(t,e){for(let r=0;r<t.length;r++)for(let n=0;n<t[r].length;n++)e.changeCellValue(t[r][n].col,t[r][n].row,"")}(e,this.table),t.stopPropagation(),t.preventDefault()}}else this.table.editorManager.completeEdit(),this.table.getElement().focus(),"Enter"===t.key?this.table.selectCell(e,r+1):"Tab"===t.key&&this.table.selectCell(e+1,r),t.stopPropagation(),t.preventDefault()}}isExcelShortcutKey(t){return"Enter"===t.key||"Tab"===t.key||"ArrowLeft"===t.key||"ArrowRight"===t.key||"ArrowDown"===t.key||"ArrowUp"===t.key}release(){document.removeEventListener("keydown",this.handleKeyDown,!0)}},t.ExcelImportPlugin=t3,t.ExportGanttPlugin=class{id="gantt-export-helper";name="Gantt Export Helper";_gantt=null;constructor(){ac()}run(...t){const e=t[0];e&&(this._gantt=e)}async exportToImage(t={}){if(!ac())return;if(!this._gantt)return;const{fileName:e="gantt-export",type:r="png",quality:n=1,backgroundColor:i="#ffffff",scale:s=window.devicePixelRatio||1,download:o=!0}=t;try{const{tempContainer:t,clonedGantt:a}=this.createFullSizeContainer(s);try{await new Promise((t=>requestAnimationFrame(t)));const t=(a.taskListTableInstance.getAllColsWidth()+a.getAllDateColsWidth())*s,l=a.getAllRowsHeight()*s,h=document.createElement("canvas");h.width=t,h.height=l;const u=h.getContext("2d");u.fillStyle=i,u.fillRect(0,0,t,l),a.taskListTableInstance?.canvas&&u.drawImage(a.taskListTableInstance.canvas,0,0,a.taskListTableInstance.getAllColsWidth()*s,l);const c=3*s,d=a.taskListTableInstance.getAllColsWidth()*s;u.fillStyle="rgb(225, 228, 232)",u.fillRect(d-c/2,0,c,l);const p=4*s,f=a.canvas.width-p;return a.canvas&&u.drawImage(a.canvas,p,0,f,a.canvas.height,(a.taskListTableInstance.getAllColsWidth()+1.5)*s,0,(a.getAllDateColsWidth()-1.5)*s,l),this.finalizeExport(h,e,r,n,o)}finally{t.remove(),a.release()}}catch(t){throw new Error(`甘特图导出失败: ${t instanceof Error?t.message:"未知错误"}`)}}async exportToBase64(t={}){return this.exportToImage({...t,download:!1})}async createFullSizeContainer(t){if(!this._gantt)throw new Error("ExportGanttPlugin: Gantt instance not available to create container.");const e=document.createElement("div");e.style.position="fixed",e.style.left="-9999px",e.style.overflow="hidden",e.style.width=`${window.innerWidth+100}px`,e.style.height=`${window.innerHeight+100}px`,document.body.appendChild(e);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`,e.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(t){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(t),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:e,clonedGantt:i}}catch(t){throw e&&e.parentNode&&e.remove(),new Error("导出甘特图需要安装 @visactor/vtable-gantt 依赖")}}finalizeExport(t,e,r,n,i=!0){const s=t.toDataURL(`image/${r}`,n);if(i){const t=document.createElement("a");t.download=`${e}.${r}`,t.href=s,document.body.appendChild(t),t.click(),document.body.removeChild(t)}return s}release(){this._gantt=null}},t.FilterEngine=r3,t.FilterPlugin=class{id="filter";name="Filter";runTime=[m.TABLE_EVENT_TYPE.BEFORE_INIT,m.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION,m.TABLE_EVENT_TYPE.ICON_CLICK];pluginOptions;table;filterEngine;filterStateManager;filterToolbar;constructor(t){this.id=t?.id??this.id,this.pluginOptions=t,this.pluginOptions.filterIcon=t.filterIcon??{name:"filter-icon",type:"svg",width:20,height:20,marginRight:6,positionType:m.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="#333333" p-id="12093"></path></svg>'},this.pluginOptions.filteringIcon=t.filteringIcon??{name:"filtering-icon",type:"svg",width:20,height:20,marginRight:6,positionType:m.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" p-id="11927"></path></svg>'},this.pluginOptions.filterModes&&this.pluginOptions.filterModes.length||(this.pluginOptions.filterModes=["byValue","byCondition"])}run(...t){const e=t[0],r=t[1],n=t[2];if(this.table=n,r===m.TABLE_EVENT_TYPE.BEFORE_INIT)this.filterEngine=new r3,this.filterStateManager=new n3(this.table,this.filterEngine),this.filterToolbar=new A3(this.table,this.filterStateManager),this.filterToolbar.render(document.body),this.updateFilterIcons(e.options);else if(r===m.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION)this.pluginOptions={...this.pluginOptions,...e.options.plugins.find((t=>t.id===this.id)).pluginOptions},this.handleOptionUpdate(e.options);else if(r===m.TABLE_EVENT_TYPE.ICON_CLICK&&"filter-icon"===e.name||"filtering-icon"===e.name){if(3===e.event?.which||2===e.event?.button||2==(2&e.event?.buttons))return;const t=e.col,r=e.row;this.filterToolbar.isVisible?this.filterToolbar.hide():this.filterToolbar.show(t,r,this.pluginOptions.filterModes)}}update(){this.filterStateManager&&this.reapplyActiveFilters()}handleOptionUpdate(t){const e=this.filterStateManager?this.filterStateManager.getActiveFilterFields():[];this.filterStateManager&&e.length>0&&this.validateFilterStatesAfterUpdate(t,e),this.updateFilterIcons(t)}reapplyActiveFilters(){this.filterStateManager.reapplyCurrentFilters()}validateFilterStatesAfterUpdate(e,r){const n=e.columns,i=[];r.forEach((t=>{const e=n.find((e=>e.field===t));e&&this.shouldEnableFilterForColumn(t,e)||i.push(t)})),i.forEach((e=>{this.filterStateManager.dispatch({type:t.FilterActionType.REMOVE_FILTER,payload:{field:e}})}))}updateFilterIcons(t){t.columns.forEach((t=>{this.shouldEnableFilterForColumn(t.field,t)?t.headerIcon=this.pluginOptions.filterIcon:delete t.headerIcon}))}shouldEnableFilterForColumn(t,e){if(!e.title)return!1;const r=e;return void 0!==r.filter?!!r.filter:this.pluginOptions.enableFilter?this.pluginOptions.enableFilter(t,e):void 0===this.pluginOptions.defaultEnabled||this.pluginOptions.defaultEnabled}getFilterState(){if(!this.filterStateManager)return null;const t=this.filterStateManager.getAllFilterStates(),e={};return t.filters.forEach(((t,r)=>{e[r]={enable:t.enable,field:t.field,type:t.type,values:t.values,operator:t.operator,condition:t.condition}})),{filters:e}}setFilterState(e){this.filterStateManager&&e&&e.filters&&(this.filterStateManager.dispatch({type:t.FilterActionType.CLEAR_ALL_FILTERS,payload:{}}),this.table.columns,Object.entries(e.filters).forEach((([,e])=>{e.enable&&this.filterStateManager.dispatch({type:t.FilterActionType.ADD_FILTER,payload:{field:e.field,type:e.type,values:e.values,operator:e.operator,condition:e.condition,enable:!0}})})))}release(){this.table=null,this.filterEngine=null,this.filterStateManager=null,this.filterToolbar=null}},t.FilterStateManager=n3,t.FilterToolbar=A3,t.FocusHighlightPlugin=class{id="focus-highlight";name="Focus Highlight";runTime=[e.TABLE_EVENT_TYPE.INITIALIZED,e.TABLE_EVENT_TYPE.SELECTED_CELL,e.TABLE_EVENT_TYPE.SELECTED_CLEAR];table;range;pluginOptions;constructor(t={fill:"#000",opacity:.5,highlightRange:void 0}){this.id=t.id??this.id,this.pluginOptions=Object.assign({fill:"#000",opacity:.5},t)}run(...t){if(this.table||(this.table=t[2]),t[1]===e.TABLE_EVENT_TYPE.INITIALIZED)this.pluginOptions.highlightRange&&this.setFocusHighlightRange(this.pluginOptions.highlightRange);else if(t[1]===e.TABLE_EVENT_TYPE.SELECTED_CELL){const t=this.table.stateManager.select.cellPos;if(this.table.isHeader(t.col,t.row))this.setFocusHighlightRange(void 0);else{const t=this.table.stateManager.select.ranges,e=0,r=this.table.colCount-1,n=Math.min(t[0].start.row,t[0].end.row),i=Math.max(t[0].start.row,t[0].end.row);this.setFocusHighlightRange({start:{col:e,row:n},end:{col:r,row:i}})}}else t[1]===e.TABLE_EVENT_TYPE.SELECTED_CLEAR&&this.setFocusHighlightRange(void 0)}setFocusHighlightRange(t,e=!1){let r;t&&"start"in t&&"end"in t?r=t:t&&(r={start:t,end:t}),Tu(this.range,r)&&!e||(this.range=r,t?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(t,e){let r;e&&"start"in e&&"end"in e?r=e:e&&(r={start:e,end:e}),t.forEachChildrenSkipChild((t=>{const e=t;"column"===e.role&&e.forEachChildrenSkipChild((t=>{const e=t;if("cell"!==e.role)return;e.attachShadow(e.shadowRoot);const n=e.shadowRoot;if(r){if(Du(r,e.col,e.row))n.removeAllChild();else if(!n.firstChild){const t=ha({x:0,y:0,width:e.attribute.width,height:e.attribute.height,fill:this.pluginOptions.fill,opacity:this.pluginOptions.opacity});t.name="shadow-rect",n.appendChild(t)}}else n.removeAllChild()}))}))}update(){this.setFocusHighlightRange(this.range,!0)}},t.HeaderHighlightPlugin=class{table;options;colHeaderRange;rowHeaderRange;constructor(t,e){this.table=t,this.options=e,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,!0),this.rowHeaderRange&&this.table.arrangeCustomCellStyle({range:this.rowHeaderRange},void 0,!0),this.colHeaderRange=void 0,this.rowHeaderRange=void 0}updateHighlight(){if(!1===this.options?.colHighlight&&!1===this.options?.rowHighlight)return;const t=this.table.getSelectedCellRanges();if(0===t.length)return void this.clearHighlight();const e=t[0],r=[e.start.row,e.end.row];r.sort(((t,e)=>t-e));const n=[e.start.col,e.end.col];let i,s;n.sort(((t,e)=>t-e)),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||ju(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||ju(this.rowHeaderRange,s)||(this.rowHeaderRange&&this.table.arrangeCustomCellStyle({range:this.rowHeaderRange},void 0),s&&this.table.arrangeCustomCellStyle({range:s},"row-highlight"),this.rowHeaderRange=s)}},t.HighlightHeaderWhenSelectCellPlugin=class{id="highlight-header-when-select-cell";name="Highlight Header When Select Cell";runTime=[e.TABLE_EVENT_TYPE.INITIALIZED,e.TABLE_EVENT_TYPE.SELECTED_CLEAR,e.TABLE_EVENT_TYPE.SELECTED_CELL,e.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE];table;pluginOptions;colHeaderRanges=[];rowHeaderRanges=[];constructor(t){this.id=t.id??this.id,this.pluginOptions=t}run(...t){const r=t[1],n=t[2];this.table=n,r===e.TABLE_EVENT_TYPE.SELECTED_CLEAR?this.clearHighlight():r===e.TABLE_EVENT_TYPE.SELECTED_CELL||r===e.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE?this.updateHighlight():r===e.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((t=>{this.table.arrangeCustomCellStyle({range:t},void 0)})),this.rowHeaderRanges&&this.rowHeaderRanges.forEach((t=>{this.table.arrangeCustomCellStyle({range:t},void 0)})),this.colHeaderRanges=[],this.rowHeaderRanges=[]}updateHighlight(){if(!1===this.pluginOptions?.colHighlight&&!1===this.pluginOptions?.rowHighlight)return;const t=this.table.getSelectedCellRanges();t.length<2&&this.clearHighlight();for(let e=0;e<t.length;e++){const r=t[e],n=[r.start.row,r.end.row];n.sort(((t,e)=>t-e));const i=[r.start.col,r.end.col];let s,o;i.sort(((t,e)=>t-e)),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((t=>zu(t,s)))||(s&&this.table.arrangeCustomCellStyle({range:s},"col-highlight"),this.colHeaderRanges.push(s)),!1===this.pluginOptions?.rowHighlight||this.rowHeaderRanges.find((t=>zu(t,o)))||(o&&this.table.arrangeCustomCellStyle({range:o},"row-highlight"),this.rowHeaderRanges.push(o))}}update(){this.registerStyle(),this.updateHighlight()}release(){this.rowHeaderRanges=[],this.colHeaderRanges=[]}},t.InvertHighlightPlugin=class{table;range;_fill;_opacity;constructor(t,e){this.table=t,this._fill=e?.fill??"#000",this._opacity=e?.opacity??.5}setInvertHighlightRange(t){Tu(this.range,t)||(this.range=t,t?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(t,e){t.forEachChildrenSkipChild((t=>{const r=t;"column"===r.role&&r.forEachChildrenSkipChild((t=>{const r=t;if("cell"!==r.role)return;r.attachShadow(r.shadowRoot);const n=r.shadowRoot;if(e){if(Du(e,r.col,r.row))n.removeAllChild();else if(!n.firstChild){const t=ha({x:0,y:0,width:r.attribute.width,height:r.attribute.height,fill:this._fill,opacity:this._opacity});t.name="shadow-rect",n.appendChild(t)}}else n.removeAllChild()}))}))}},t.MENU_CONTAINER_CLASS=Uu,t.MENU_ITEM_CLASS=Hu,t.MENU_ITEM_DISABLED_CLASS=Wu,t.MENU_ITEM_SEPARATOR_CLASS=$u,t.MENU_ITEM_SUBMENU_CLASS=Vu,t.MENU_STYLES=Gu,t.MenuManager=Ku,t.PasteAddRowColumnPlugin=class{id="paste-add-row-column";name="Paste Add row";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED,m.TABLE_EVENT_TYPE.PASTED_DATA];table;pluginOptions;pastedData;constructor(t){this.pluginOptions=t,this.id=t?.id??this.id}run(...t){const e=t[1],r=t[2];this.table=r,e===m.TABLE_EVENT_TYPE.PASTED_DATA&&(this.pastedData=t[0],this.handlePaste())}handlePaste(){const{pasteData:t,row:e,col:r}=this.pastedData,n=this.table.rowCount,i=this.table.colCount,s=e+t.length-n,o=r+(t[0]?.length||0)-i;if(s>0)for(let t=0;t<s;t++)this.pluginOptions?.addRowCallback?this.pluginOptions.addRowCallback(n+t,this.table):this.table.addRecord([]);if(o>0)for(let t=0;t<o;t++){const e=i+t;this.pluginOptions?.addColumnCallback?this.pluginOptions.addColumnCallback(e,this.table):this.table.addColumn({field:`field_${e}`,title:`New Column ${e}`,width:100})}this.table.changeCellValues(r,e,t,!0)}release(){this.table.internalProps.handler.clear()}},t.RotateTablePlugin=class{id="rotate-table";name="Rotate Table";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED];table;matrix;vglobal_mapToCanvasPoint;constructor(t){this.id=t?.id??this.id}run(...t){const e=t[2];this.table=e,this.table.rotate90WithTransform=sc.bind(this.table),this.table.cancelTransform=oc.bind(this.table)}release(){}},t.RowSeriesPlugin=class{id="row-series";name="Row Series";runTime=[e.TABLE_EVENT_TYPE.BEFORE_INIT,e.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];pluginOptions;table;constructor(t){this.id=t.id??this.id,this.pluginOptions=Object.assign({rowCount:100},t)}run(...t){if(t[1]===e.TABLE_EVENT_TYPE.BEFORE_INIT){const e=t[0],r=t[2];this.table=r;const n=e.options,i=n.records??[];for(let t=i.length;t<this.pluginOptions.rowCount;t++)i.push(this.pluginOptions.fillRowRecord?this.pluginOptions.fillRowRecord(t):{});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(t[1]===e.TABLE_EVENT_TYPE.BEFORE_KEYDOWN){const e=t[0].event;this.pluginOptions.autoExtendRowTriggerKeys?.includes(e.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):{})}}},t.TableCarouselAnimationPlugin=class{id="table-carousel-animation";name="Table Carousel Animation";runTime=[e.TABLE_EVENT_TYPE.INITIALIZED];table;rowCount;colCount;animationDuration;animationDelay;animationEasing;playing;row;col;willUpdateRow=!1;willUpdateCol=!1;autoPlay;autoPlayDelay;customDistRowFunction;customDistColFunction;constructor(t={}){this.id=t.id??this.id,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.autoPlay=t?.autoPlay??!1,this.autoPlayDelay=t?.autoPlayDelay??0,this.customDistColFunction=t.customDistColFunction,this.customDistRowFunction=t.customDistRowFunction}run(...t){this.table||(this.table=t[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 t=!0;const e=this.customDistRowFunction&&this.customDistRowFunction(this.row,this.table);e?(this.row=e.distRow,t=e.animation??!0):ic(this.row)&&this.table.scenegraph.proxy.screenTopRow!==this.row?(this.row=this.table.frozenRowCount,t=!1):ic(this.row)||this.table.scenegraph.proxy.screenTopRow===Math.floor(this.row)?this.row+=this.rowCount:(this.row=this.table.frozenRowCount,t=!1),this.table.scrollToRow(this.row,t?{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 t=!0;const e=this.customDistColFunction&&this.customDistColFunction(this.col,this.table);e?(this.col=e.distCol,t=e.animation??!0):ic(this.col)&&this.table.scenegraph.proxy.screenLeftCol!==this.col?(this.col=this.table.frozenColCount,t=!1):ic(this.col)||this.table.scenegraph.proxy.screenLeftCol===Math.floor(this.col)?this.col+=this.colCount:(this.col=this.table.frozenColCount,t=!1),this.table.scrollToCol(this.col,t?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateCol=!0,setTimeout((()=>{this.willUpdateCol=!1,this.updateCol()}),this.animationDuration+this.animationDelay)}release(){}},t.TableExportPlugin=class{id="table-export-plugin";name="TableExport";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED];table;pluginOptions;constructor(t){this.pluginOptions=Object.assign({exportOnIdle:!1,exportExcelOptions:{downloadFile:!0,fileName:"export"},exportCsvOptions:{downloadFile:!0,fileName:"export"}},t)}run(...t){t[1]===m.TABLE_EVENT_TYPE.INITIALIZED&&(t[0],this.table=t[2],this.table.exportToCsv=()=>{const t=this.pluginOptions.exportCsvOptions;return t.downloadFile?async function(t,e){const r=new Blob([`\ufeff${t}`],{type:"text/csv;charset=utf-8"});await e5.saveAs(r,`${e}.csv`)}(Y3(this.table,t),t.fileName||"export"):Y3(this.table,t)},this.table.exportToExcel=async()=>{const t=this.pluginOptions.exportExcelOptions;return t.downloadFile?await async function(t,e){const r=new Blob([t],{type:"application/octet-stream"});await e5.saveAs(r,`${e}.xlsx`)}(await $3(this.table,t,this.pluginOptions.exportOnIdle),t.fileName||"export"):$3(this.table,t,this.pluginOptions.exportOnIdle)})}release(){this.table&&(delete this.table.exportToCsv,delete this.table.exportToExcel,this.table=null)}},t.TableSeriesNumber=class{id="table-series-number";name="Table Series Number";runTime=[e.TABLE_EVENT_TYPE.INITIALIZED,e.TABLE_EVENT_TYPE.BEFORE_INIT,e.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION,e.TABLE_EVENT_TYPE.UPDATED];pluginOptions;table;seriesNumberComponent;componentLayoutLayer;lastCurrentRow=0;lastCurrentCol=0;startRowIndex=0;scrollTimer;constructor(t){this.pluginOptions=t,this.seriesNumberComponent=new Cu({rowCount:t.rowCount,colCount:t.colCount,rowSeriesNumberWidth:t.rowSeriesNumberWidth,colSeriesNumberHeight:t.colSeriesNumberHeight,rowSeriesNumberGenerate:t.rowSeriesNumberGenerate,colSeriesNumberGenerate:t.colSeriesNumberGenerate,rowSeriesNumberCellStyle:t.rowSeriesNumberCellStyle,colSeriesNumberCellStyle:t.colSeriesNumberCellStyle,cornerCellStyle:t.cornerCellStyle}),this.listenComponentEvents()}run(...t){const r=t[1];if(r===e.TABLE_EVENT_TYPE.BEFORE_INIT||r===e.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION){const e=t[0],r=t[2];this.table=r;const n=e.options,i=n.records??[];i.length<this.pluginOptions.rowCount&&(i.length=this.pluginOptions.rowCount),n.records=i,n.columns||(n.columns=[]);for(let t=n.columns.length;t<this.pluginOptions.colCount;t++){const e={field:t,title:""};n.columns.push(e)}const s=this.seriesNumberComponent.rowSeriesNumberWidth,o=this.seriesNumberComponent.colSeriesNumberHeight;n.contentOffsetX=s,n.contentOffsetY=o}else if(r===e.TABLE_EVENT_TYPE.INITIALIZED||r===e.TABLE_EVENT_TYPE.UPDATED){this.table=t[2],this.table.options.customConfig||(this.table.options.customConfig={}),this.table.options.customConfig.cancelSelectCellHook=t=>{if(t.target.isDescendantsOf(this.seriesNumberComponent))return!1},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 e=this.table.scenegraph.stage.createLayer();e.appendChild(this.seriesNumberComponent),e.setAttributes({pickable:!1}),this.componentLayoutLayer=e,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=t=>{this.seriesNumberComponent.removeAllSelectedIndexs();const e=this.table.stateManager.select.ranges,r=[],n=[];for(const t of e){const{row:e,col:i}=t.start,{row:s,col:o}=t.end;r.push({startIndex:Math.min(e,s),endIndex:Math.max(e,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=t=>{this.seriesNumberComponent.setAttribute("hover",!0)};handleResizeRowEnd=t=>{this.seriesNumberComponent.setAttribute("hover",!0)};listenTableEvents(){this.table.on(e.TABLE_EVENT_TYPE.SCROLL,this.handleScroll),this.table.on(e.TABLE_EVENT_TYPE.AFTER_SORT,this.handleAfterSort),this.table.on(e.TABLE_EVENT_TYPE.SELECTED_CHANGED,this.handleSelectedChanged),this.table.on(e.TABLE_EVENT_TYPE.RESIZE_COLUMN_END,this.handleResizeColumnEnd),this.table.on(e.TABLE_EVENT_TYPE.RESIZE_ROW_END,this.handleResizeRowEnd)}handleSeriesNumberCellRightClick=t=>{const{seriesNumberCell:r,event:n,isDragSelect:i}=t.detail,s=r.name.includes("row"),o=r.name.includes("col");if(s){const t=r.id,i=this.table.stateManager.select.ranges.some((e=>e.start.row<=t&&t<=e.end.row&&0===e.start.col&&e.end.col===this.table.colCount-1));i||this.table.selectCells([{start:{row:t,col:0},end:{row:t,col:this.table.colCount-1}}]),this.table.fireListeners(e.TABLE_EVENT_TYPE.PLUGIN_EVENT,{plugin:this,event:n,pluginEventInfo:{eventType:"rightclick",rowIndex:t}})}else if(o){const t=r.id,i=this.table.stateManager.select.ranges.some((e=>e.start.col<=t&&t<=e.end.col&&0===e.start.row&&e.end.row===this.table.rowCount-1));i||this.table.selectCells([{start:{row:0,col:t},end:{row:this.table.rowCount-1,col:t}}]),this.table.fireListeners(e.TABLE_EVENT_TYPE.PLUGIN_EVENT,{plugin:this,event:n,pluginEventInfo:{eventType:"rightclick",colIndex:t}})}else this.table.selectCells([{start:{row:0,col:0},end:{row:this.table.rowCount-1,col:this.table.colCount-1}}]),this.table.fireListeners(e.TABLE_EVENT_TYPE.PLUGIN_EVENT,{plugin:this,event:n,pluginEventInfo:{eventType:"rightclick",isCorner:!0}})};handleSeriesNumberCellHover=t=>{this.table.scenegraph.renderSceneGraph()};handleSeriesNumberCellUnHover=t=>{this.table.scenegraph.renderSceneGraph()};handleSeriesNumberCellClick=t=>{const{seriesNumberCell:e,event:r,isDragSelect:n}=t.detail,i=r.nativeEvent.ctrlKey||r.nativeEvent.metaKey,s=r.nativeEvent.shiftKey,o=e.name.includes("row"),a=e.name.includes("col");if(o){this.table.stateManager.setSelectInline("row");const t=e.id;n?this.table.dragSelectRow(t,i):this.table.startDragSelectRow(t,i,s)}else if(a){this.table.stateManager.setSelectInline("col");const t=e.id;n?this.table.dragSelectCol(t,i):this.table.startDragSelectCol(t,i,s)}else this.table.eventManager.deelTableSelectAll()};handleSeriesNumberCellClickUp=t=>{this.table.stateManager.setSelectInline(!1),this.table.endDragSelect()};handleRowSeriesNumberWidthChange=t=>{const e=this.seriesNumberComponent.rowSeriesNumberWidth,r=this.seriesNumberComponent.colSeriesNumberHeight;this.table.setContentInsetXY(e,r)};handleResizeColWidthStart=t=>{this.seriesNumberComponent.setAttribute("hover",!1);const{colIndex:r,event:n}=t.detail;this.table.stateManager.updateInteractionState(e.TYPES.InteractionState.grabing),this.table.stateManager.startResizeCol(r,n.viewport.x,n.viewport.y)};handleResizeRowHeightStart=t=>{this.seriesNumberComponent.setAttribute("hover",!1);const{rowIndex:r,event:n}=t.detail;this.table.stateManager.updateInteractionState(e.TYPES.InteractionState.grabing),this.table.stateManager.startResizeRow(r,n.viewport.x,n.viewport.y)};listenComponentEvents(){this.seriesNumberComponent.on(xu.seriesNumberCellRightClick,this.handleSeriesNumberCellRightClick),this.seriesNumberComponent.on(xu.seriesNumberCellHover,this.handleSeriesNumberCellHover),this.seriesNumberComponent.on(xu.seriesNumberCellUnHover,this.handleSeriesNumberCellUnHover),this.seriesNumberComponent.on(xu.seriesNumberCellClick,this.handleSeriesNumberCellClick),this.seriesNumberComponent.on(xu.seriesNumberCellClickUp,this.handleSeriesNumberCellClickUp),this.seriesNumberComponent.on(xu.rowSeriesNumberWidthChange,this.handleRowSeriesNumberWidthChange),this.seriesNumberComponent.on(xu.resizeColWidthStart,this.handleResizeColWidthStart),this.seriesNumberComponent.on(xu.resizeRowHeightStart,this.handleResizeRowHeightStart)}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(e.TABLE_EVENT_TYPE.SCROLL,this.handleScroll),this.table.off(e.TABLE_EVENT_TYPE.AFTER_SORT,this.handleAfterSort),this.table.off(e.TABLE_EVENT_TYPE.SELECTED_CHANGED,this.handleSelectedChanged),this.table.off(e.TABLE_EVENT_TYPE.RESIZE_COLUMN_END,this.handleResizeColumnEnd),this.table.off(e.TABLE_EVENT_TYPE.RESIZE_ROW_END,this.handleResizeRowEnd)),this.seriesNumberComponent&&(this.seriesNumberComponent.off(xu.seriesNumberCellRightClick,this.handleSeriesNumberCellRightClick),this.seriesNumberComponent.off(xu.seriesNumberCellHover,this.handleSeriesNumberCellHover),this.seriesNumberComponent.off(xu.seriesNumberCellUnHover,this.handleSeriesNumberCellUnHover),this.seriesNumberComponent.off(xu.seriesNumberCellClick,this.handleSeriesNumberCellClick),this.seriesNumberComponent.off(xu.seriesNumberCellClickUp,this.handleSeriesNumberCellClickUp),this.seriesNumberComponent.off(xu.rowSeriesNumberWidthChange,this.handleRowSeriesNumberWidthChange),this.seriesNumberComponent.off(xu.resizeColWidthStart,this.handleResizeColWidthStart),this.seriesNumberComponent.off(xu.resizeRowHeightStart,this.handleResizeRowHeightStart),this.seriesNumberComponent.release?.(),this.seriesNumberComponent=null)}syncRowHeightToComponent(){const{rowStart:t,rowEnd:e}=this.table.getBodyVisibleRowRange(),r=Math.max(t-2,this.table.frozenRowCount),n=Math.min(e+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 t=0;t<this.table.frozenRowCount;t++){const e=this.table.scenegraph.getCell(0,t).getAttributes();this.seriesNumberComponent.setRowSeriesNumberCellAttributes(t,{y:e.y,height:e.height})}for(let t=r;t<=n;t++){const e=this.table.scenegraph.getCell(0,t).getAttributes();this.seriesNumberComponent.setRowSeriesNumberCellAttributes(t,{y:e.y,height:e.height})}}syncColWidthToComponent(){const{colStart:t,colEnd:e}=this.table.getBodyVisibleColRange(),r=t,n=Math.min(e,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 t=0;t<this.table.frozenColCount;t++){const e=this.table.scenegraph.getColGroup(t).getAttributes();this.seriesNumberComponent.setColSeriesNumberCellAttributes(t,{x:e.x,width:e.width})}for(let t=r;t<=n;t++){const e=this.table.scenegraph.getColGroup(t).getAttributes();this.seriesNumberComponent.setColSeriesNumberCellAttributes(t,{x:e.x,width:e.width})}}syncScrollToComponent(){this.syncRowHeightToComponent(),this.syncColWidthToComponent();const t=this.table.scenegraph.bodyGroup.getAttributes().y,e=this.table.scenegraph.bodyGroup.getAttributes().x;this.seriesNumberComponent.setRowSeriesNumberGroupAttributes({y:t+this.seriesNumberComponent.colSeriesNumberHeight}),this.seriesNumberComponent.setColSeriesNumberGroupAttributes({x:e+this.seriesNumberComponent.rowSeriesNumberWidth})}},t.ValueFilter=T3,t.WpsFillHandlePlugin=class{id="wps-fill-handle";name="WPS Fill Handle";runTime=[m.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE,m.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END];table;pluginOptions;beforeDragMinCol=0;beforeDragMinRow=0;beforeDragMaxCol=0;beforeDragMaxRow=0;constructor(t){this.id=t?.id??this.id,this.pluginOptions=t}run(...t){if(t[1]===m.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE){t[0];const e=t[2];this.table=e;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(t[1]===m.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END){const e=t[0].direction;let r,n;const i=this.table?.getSelectedCellRanges()[0];if(!i)return;"bottom"===e?(r=this.beforeDragMaxCol,n=i.end.row):"right"===e?(r=i.end.col,n=this.beforeDragMaxRow):"top"===e?(r=this.beforeDragMaxCol,n=i.end.row):"left"===e&&(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=sg(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 t=this.table?.getSelectedCellRanges()[0];if(!t)return;this.beforeDragMaxCol=Math.max(t.start.col,t.end.col),this.beforeDragMinCol=Math.min(t.start.col,t.end.col),this.beforeDragMaxRow=Math.max(t.start.row,t.end.row),this.beforeDragMinRow=Math.min(t.start.row,t.end.row)}}release(){this.beforeDragMinCol=0,this.beforeDragMinRow=0,this.beforeDragMaxCol=0,this.beforeDragMaxRow=0}},t.applyStyles=Yu,t.cancelTransform=oc,t.createElement=Xu,t.createIcon=qu,t.createNumberInputItem=function(t,e=1,r,n){const i=Xu("div");if(Yu(i,Gu.inputContainer),r){const t=qu(r);i.appendChild(t)}const s=Xu("label");s.textContent=t,Yu(s,Gu.inputLabel),i.appendChild(s);const o=Xu("input");o.type="number",o.min="1",o.value=e.toString(),Yu(o,Gu.inputField),i.appendChild(o);const a=Xu("div");return a.appendChild(i),a},t.rotate90WithTransform=sc}));
|