@cj-tech-master/excelts 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/browser/modules/excel/anchor.js +10 -4
  2. package/dist/browser/modules/excel/stream/workbook-writer.browser.d.ts +13 -0
  3. package/dist/browser/modules/excel/stream/workbook-writer.browser.js +32 -1
  4. package/dist/browser/modules/excel/stream/worksheet-writer.d.ts +56 -2
  5. package/dist/browser/modules/excel/stream/worksheet-writer.js +90 -3
  6. package/dist/browser/modules/excel/utils/drawing-utils.d.ts +77 -0
  7. package/dist/browser/modules/excel/utils/drawing-utils.js +113 -0
  8. package/dist/browser/modules/excel/worksheet.js +1 -1
  9. package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.d.ts +0 -1
  10. package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +43 -64
  11. package/dist/browser/modules/excel/xlsx/xlsx.browser.js +2 -19
  12. package/dist/cjs/modules/excel/anchor.js +10 -4
  13. package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +31 -0
  14. package/dist/cjs/modules/excel/stream/worksheet-writer.js +89 -2
  15. package/dist/cjs/modules/excel/utils/drawing-utils.js +118 -0
  16. package/dist/cjs/modules/excel/worksheet.js +1 -1
  17. package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +42 -63
  18. package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +2 -19
  19. package/dist/esm/modules/excel/anchor.js +10 -4
  20. package/dist/esm/modules/excel/stream/workbook-writer.browser.js +32 -1
  21. package/dist/esm/modules/excel/stream/worksheet-writer.js +90 -3
  22. package/dist/esm/modules/excel/utils/drawing-utils.js +113 -0
  23. package/dist/esm/modules/excel/worksheet.js +1 -1
  24. package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +43 -64
  25. package/dist/esm/modules/excel/xlsx/xlsx.browser.js +2 -19
  26. package/dist/iife/excelts.iife.js +237 -73
  27. package/dist/iife/excelts.iife.js.map +1 -1
  28. package/dist/iife/excelts.iife.min.js +34 -34
  29. package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +13 -0
  30. package/dist/types/modules/excel/stream/worksheet-writer.d.ts +56 -2
  31. package/dist/types/modules/excel/utils/drawing-utils.d.ts +77 -0
  32. package/dist/types/modules/excel/xlsx/xform/sheet/worksheet-xform.d.ts +0 -1
  33. package/package.json +1 -1
@@ -1,34 +1,34 @@
1
1
  /*!
2
- * @cj-tech-master/excelts v6.0.0
2
+ * @cj-tech-master/excelts v6.1.0
3
3
  * TypeScript Excel Workbook Manager - Read and Write xlsx and csv Files.
4
4
  * (c) 2026 cjnoname
5
5
  * Released under the MIT License
6
6
  */
7
- var ExcelTS=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=class extends Error{constructor(e,t){super(e,t),this.name=`BaseError`,Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,message:this.message,stack:this.stack,cause:this.cause instanceof Error?o(this.cause):this.cause}}},n=class extends t{constructor(e){super(`The operation was aborted`,e===void 0?void 0:{cause:e}),this.name=`AbortError`,this.code=`ABORT_ERR`}};function r(e){return e instanceof n?e:new n(e)}function i(e){return!!e&&typeof e==`object`&&e.name===`AbortError`}function a(e){return e instanceof Error?e:Error(String(e))}function o(e){return e instanceof t?e.toJSON():{name:e.name,message:e.message,stack:e.stack,cause:e.cause instanceof Error?o(e.cause):e.cause}}function s(e){let t=[e],n=e.cause;for(;n instanceof Error;)t.push(n),n=n.cause;return t}function c(e){let t=e;for(;t.cause instanceof Error;)t=t.cause;return t}var l=class extends t{constructor(e,t){super(e,t),this.name=`ExcelError`}};function u(e){return e instanceof l}var d=class extends l{constructor(...e){super(...e),this.name=`WorksheetNameError`}},f=class extends l{constructor(e,t,n){super(t?`Invalid address "${e}": ${t}`:`Invalid address: ${e}`,n),this.address=e,this.name=`InvalidAddressError`}},p=class extends l{constructor(e,t,n){super(t?`Column ${e} is out of bounds: ${t}`:`Column ${e} is out of bounds. Excel supports columns from 1 to 16384`,n),this.column=e,this.name=`ColumnOutOfBoundsError`}},m=class extends l{constructor(e,t,n){super(t?`Row ${e} is out of bounds: ${t}`:`Row ${e} is out of bounds`,n),this.row=e,this.name=`RowOutOfBoundsError`}},h=class extends l{constructor(e,t){super(e??`Cannot merge already merged cells`,t),this.name=`MergeConflictError`}},g=class extends l{constructor(e,t,n){super(t??`Cannot process value of type: ${e}`,n),this.valueType=e,this.name=`InvalidValueTypeError`}},_=class extends l{constructor(e,t,n){super(t??`Unexpected XML content in ${e}`,n),this.context=e,this.name=`XmlParseError`}},v=class extends l{constructor(e,t,n){super(t?`${e}: ${t}`:`${e} is not supported`,n),this.operation=e,this.reason=t,this.name=`ExcelNotSupportedError`}},y=class extends l{constructor(e,t,n,r){super(n?`Failed to ${t} Excel file "${e}": ${n}`:`Failed to ${t} Excel file "${e}"`,r),this.path=e,this.operation=t,this.name=`ExcelFileError`}},b=class extends l{constructor(e,t,n){super(`Cannot ${e}: ${t}`,n),this.operation=e,this.state=t,this.name=`ExcelStreamStateError`}},ee=class extends l{constructor(e,t,n,r){super(`Failed to download from "${e}": HTTP ${t} ${n}`,r),this.url=e,this.status=t,this.statusText=n,this.name=`ExcelDownloadError`}},x=class extends l{constructor(...e){super(...e),this.name=`PivotTableError`}},te=class extends l{constructor(...e){super(...e),this.name=`TableError`}},ne=class extends l{constructor(...e){super(...e),this.name=`ImageError`}},re=class extends l{constructor(e,t,n){super(`Max ${e} count (${t}) exceeded`,n),this.itemType=e,this.maxItems=t,this.name=`MaxItemsExceededError`}};let ie=/^[A-Z]+\d+$/,S={_dictionary:`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``),_l2nFill:0,_l2n:{},_n2l:[],_level(e){return e<=26?1:e<=676?2:3},_fill(e){let t,n,r,i,a,o=1;if(e>=4)throw new p(e,`Excel supports columns from 1 to 16384`);if(this._l2nFill<1&&e>=1){for(;o<=26;)t=this._dictionary[o-1],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=1}if(this._l2nFill<2&&e>=2){for(o=27;o<=702;)n=o-27,r=n%26,i=Math.floor(n/26),t=this._dictionary[i]+this._dictionary[r],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=2}if(this._l2nFill<3&&e>=3){for(o=703;o<=16384;)n=o-703,r=n%26,i=Math.floor(n/26)%26,a=Math.floor(n/676),t=this._dictionary[a]+this._dictionary[i]+this._dictionary[r],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=3}},l2n(e){if(this._l2n[e]||this._fill(e.length),!this._l2n[e])throw new p(e,`Invalid column letter: ${e}`);return this._l2n[e]},n2l(e){if(e<1||e>16384)throw new p(e);return this._n2l[e]||this._fill(this._level(e)),this._n2l[e]},_hash:{},validateAddress(e){if(!ie.test(e))throw new f(e);return!0},decodeAddress(e){if(!e||typeof e!=`string`)throw Error(`Invalid Address: ${e}`);let t=e.length<5&&this._hash[e];if(t)return t;let n=!1,r=``,i=0,a=!1,o=``,s=0;for(let t=0,c;t<e.length;t++)if(c=e.charCodeAt(t),!a&&c>=65&&c<=90)n=!0,r+=e[t],i=i*26+c-64;else if(c>=48&&c<=57)a=!0,o+=e[t],s=s*10+c-48;else if(a&&n&&c!==36)break;if(!n)i=void 0;else if(i>16384)throw new p(r,`Invalid column letter: ${r}`);a||(s=void 0),e=r+o;let c={address:e,col:i,row:s,$col$row:`$${r}$${o}`};return i<=100&&s<=100&&(this._hash[e]=c,this._hash[c.$col$row]=c),c},getAddress(e,t){if(t){let n=this.n2l(t)+e;return this.decodeAddress(n)}return this.decodeAddress(e)},decode(e){if(!e||typeof e!=`string`)throw Error(`Invalid Address: ${e}`);let t=e.split(`:`);if(t.length===2){let e=this.decodeAddress(t[0]),n=this.decodeAddress(t[1]),r={top:Math.min(e.row,n.row),left:Math.min(e.col,n.col),bottom:Math.max(e.row,n.row),right:Math.max(e.col,n.col),tl:``,br:``,dimensions:``};return r.tl=this.n2l(r.left)+r.top,r.br=this.n2l(r.right)+r.bottom,r.dimensions=`${r.tl}:${r.br}`,r}return this.decodeAddress(e)},decodeEx(e){if(!e||typeof e!=`string`)throw Error(`Invalid Address: ${e}`);let t=e.match(/^(?:(?:(?:'((?:[^']|'')+?)')|([^'^ !]+?))!)?(.*)$/),n=t[1]||t[2],r=t[3],i=r.split(`:`);if(i.length>1){let e=this.decodeAddress(i[0]),t=this.decodeAddress(i[1]),r=Math.min(e.row,t.row),a=Math.min(e.col,t.col),o=Math.max(e.row,t.row),s=Math.max(e.col,t.col),c=this.n2l(a)+r,l=this.n2l(s)+o;return{top:r,left:a,bottom:o,right:s,sheetName:n,tl:{address:c,col:a,row:r,$col$row:`$${this.n2l(a)}$${r}`,sheetName:n},br:{address:l,col:s,row:o,$col$row:`$${this.n2l(s)}$${o}`,sheetName:n},dimensions:`${c}:${l}`}}if(r.indexOf(`#`)===0)return n?{sheetName:n,error:r}:{error:r};let a=this.decodeAddress(r);return n?{sheetName:n,...a}:a},encodeAddress(e,t){return S.n2l(t)+e},encode(...e){switch(e.length){case 2:return S.encodeAddress(e[0],e[1]);case 4:return`${S.encodeAddress(e[0],e[1])}:${S.encodeAddress(e[2],e[3])}`;default:throw new f(String(e.length),`Can only encode with 2 or 4 arguments`)}},inRange(e,t){let[n,r,,i,a]=e,[o,s]=t;return o>=n&&o<=i&&s>=r&&s<=a}};var C=class e{constructor(...e){this.model={top:0,left:0,bottom:0,right:0},this.decode(e)}setTLBR(e,t,n,r,i){if(typeof e==`string`&&typeof t==`string`){let r=S.decodeAddress(e),i=S.decodeAddress(t);this.model={top:Math.min(r.row,i.row),left:Math.min(r.col,i.col),bottom:Math.max(r.row,i.row),right:Math.max(r.col,i.col),sheetName:typeof n==`string`?n:void 0}}else typeof e==`number`&&typeof t==`number`&&typeof n==`number`&&typeof r==`number`&&(this.model={top:Math.min(e,n),left:Math.min(t,r),bottom:Math.max(e,n),right:Math.max(t,r),sheetName:i})}decode(t){switch(t.length){case 5:typeof t[0]==`number`&&typeof t[1]==`number`&&typeof t[2]==`number`&&typeof t[3]==`number`&&typeof t[4]==`string`&&this.setTLBR(t[0],t[1],t[2],t[3],t[4]);break;case 4:typeof t[0]==`number`&&typeof t[1]==`number`&&typeof t[2]==`number`&&typeof t[3]==`number`&&this.setTLBR(t[0],t[1],t[2],t[3]);break;case 3:typeof t[0]==`string`&&typeof t[1]==`string`&&typeof t[2]==`string`&&this.setTLBR(t[0],t[1],t[2]);break;case 2:typeof t[0]==`string`&&typeof t[1]==`string`&&this.setTLBR(t[0],t[1]);break;case 1:{let n=t[0];if(n instanceof e)this.model={top:n.model.top,left:n.model.left,bottom:n.model.bottom,right:n.model.right,sheetName:n.sheetName};else if(Array.isArray(n))this.decode(n);else if(typeof n==`object`&&`top`in n&&`left`in n&&`bottom`in n&&`right`in n)this.model={top:n.top,left:n.left,bottom:n.bottom,right:n.right,sheetName:n.sheetName};else if(typeof n==`string`){let e=S.decodeEx(n);`top`in e?this.model={top:e.top,left:e.left,bottom:e.bottom,right:e.right,sheetName:e.sheetName}:`row`in e&&(this.model={top:e.row,left:e.col,bottom:e.row,right:e.col,sheetName:e.sheetName})}break}case 0:this.model={top:0,left:0,bottom:0,right:0};break;default:throw new l(`Invalid number of arguments to _getDimensions() - ${t.length}`)}}get top(){return this.model.top||1}set top(e){this.model.top=e}get left(){return this.model.left||1}set left(e){this.model.left=e}get bottom(){return this.model.bottom||1}set bottom(e){this.model.bottom=e}get right(){return this.model.right||1}set right(e){this.model.right=e}get sheetName(){return this.model.sheetName}set sheetName(e){this.model.sheetName=e}get _serialisedSheetName(){let{sheetName:e}=this.model;return e?/^[a-zA-Z0-9]*$/.test(e)?`${e}!`:`'${e}'!`:``}expand(e,t,n,r){(!this.model.top||e<this.top)&&(this.top=e),(!this.model.left||t<this.left)&&(this.left=t),(!this.model.bottom||n>this.bottom)&&(this.bottom=n),(!this.model.right||r>this.right)&&(this.right=r)}expandRow(e){if(e){let{dimensions:t,number:n}=e;t&&this.expand(n,t.min,n,t.max)}}expandToAddress(e){let t=S.decodeEx(e);`row`in t&&`col`in t&&this.expand(t.row,t.col,t.row,t.col)}get tl(){return S.n2l(this.left)+this.top}get $t$l(){return`$${S.n2l(this.left)}$${this.top}`}get br(){return S.n2l(this.right)+this.bottom}get $b$r(){return`$${S.n2l(this.right)}$${this.bottom}`}get range(){return`${this._serialisedSheetName+this.tl}:${this.br}`}get $range(){return`${this._serialisedSheetName+this.$t$l}:${this.$b$r}`}get shortRange(){return this.count>1?this.range:this._serialisedSheetName+this.tl}get $shortRange(){return this.count>1?this.$range:this._serialisedSheetName+this.$t$l}get count(){return(1+this.bottom-this.top)*(1+this.right-this.left)}toString(){return this.range}intersects(e){return!(e.sheetName&&this.sheetName&&e.sheetName!==this.sheetName||e.bottom<this.top||e.top>this.bottom||e.right<this.left||e.left>this.right)}contains(e){let t=S.decodeEx(e);return`row`in t&&`col`in t?this.containsEx(t):!1}containsEx(e){return e.sheetName&&this.sheetName&&e.sheetName!==this.sheetName?!1:e.row>=this.top&&e.row<=this.bottom&&e.col>=this.left&&e.col<=this.right}forEachAddress(e){for(let t=this.left;t<=this.right;t++)for(let n=this.top;n<=this.bottom;n++)e(S.encodeAddress(n,t),n,t)}};let ae=function(e){return e[e.Null=0]=`Null`,e[e.Merge=1]=`Merge`,e[e.Number=2]=`Number`,e[e.String=3]=`String`,e[e.Date=4]=`Date`,e[e.Hyperlink=5]=`Hyperlink`,e[e.Formula=6]=`Formula`,e[e.SharedString=7]=`SharedString`,e[e.RichText=8]=`RichText`,e[e.Boolean=9]=`Boolean`,e[e.Error=10]=`Error`,e[e.JSON=11]=`JSON`,e[e.Checkbox=12]=`Checkbox`,e}({}),oe=function(e){return e[e.None=0]=`None`,e[e.Master=1]=`Master`,e[e.Shared=2]=`Shared`,e}({}),se=function(e){return e[e.None=0]=`None`,e[e.OfficeDocument=1]=`OfficeDocument`,e[e.Worksheet=2]=`Worksheet`,e[e.CalcChain=3]=`CalcChain`,e[e.SharedStrings=4]=`SharedStrings`,e[e.Styles=5]=`Styles`,e[e.Theme=6]=`Theme`,e[e.Hyperlink=7]=`Hyperlink`,e}({}),ce=function(e){return e[e.Xlsx=1]=`Xlsx`,e}({}),le=function(e){return e[e.LeftToRight=1]=`LeftToRight`,e[e.RightToLeft=2]=`RightToLeft`,e}({}),ue={NotApplicable:`#N/A`,Ref:`#REF!`,Name:`#NAME?`,DivZero:`#DIV/0!`,Null:`#NULL!`,Value:`#VALUE!`,Num:`#NUM!`},w={ValueType:ae,FormulaType:oe,RelationshipType:se,DocumentType:ce,ReadingOrder:le,ErrorValue:ue},de={'"':`&quot;`,"&":`&amp;`,"<":`&lt;`,">":`&gt;`},fe=/["&<>]/g;function pe(e,t){if(e===t)return!0;if(e==null||t==null)return e===t;let n=typeof e;if(n!==typeof t||n!==`object`)return!1;let r=Array.isArray(e);if(r!==Array.isArray(t))return!1;if(r){let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!pe(e[r],t[r]))return!1;return!0}let i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return!1;for(let n=0,r=i.length;n<r;n++){let r=i[n];if(!Object.prototype.hasOwnProperty.call(t,r)||!pe(e[r],t[r]))return!1}return!0}function me(e){return e.replace(fe,e=>de[e])}function he(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ge(...e){let t=e[0]||{},n=e.length;for(let r=1;r<n;r++){let n=e[r];if(n)if(Array.isArray(n))for(let e=0,r=n.length;e<r;e++){let r=n[e];if(r===void 0)continue;let i=t[e];Array.isArray(r)?t[e]=ge(Array.isArray(i)?i:[],r):he(r)?t[e]=ge(he(i)?i:{},r):t[e]=r}else{let e=Object.keys(n);for(let r=0,i=e.length;r<i;r++){let i=e[r];if(i===`__proto__`||i===`constructor`||i===`prototype`)continue;let a=n[i];if(a===void 0)continue;let o=t[i];Array.isArray(a)?t[i]=ge(Array.isArray(o)?o:[],a):he(a)?t[i]=ge(he(o)?o:{},a):t[i]=a}}}return t}var _e=class e{static{this.DEFAULT_CONFIGS={note:{margins:{insetmode:`auto`,inset:[.13,.13,.25,.25]},protection:{locked:`True`,lockText:`True`},editAs:`absolute`},type:`note`}}constructor(e){this.note=e}get model(){let t;switch(typeof this.note){case`string`:t={type:`note`,note:{texts:[{text:this.note}]}};break;default:t={type:`note`,note:this.note??{}};break}return ge({},e.DEFAULT_CONFIGS,t)}set model(e){let{note:t}=e,{texts:n}=t;n&&n.length===1&&Object.keys(n[0]).length===1?this.note=n[0].text:this.note=t}static fromModel(t){let n=new e;return n.model=t,n}};let ve=/(([a-z_\-0-9]*)!)?([a-z0-9_$]{2,})([(])?/gi,ye=/^([$])?([a-z]+)([$])?([1-9][0-9]*)$/i;function be(e,t,n){let r=S.decode(t),i=S.decode(n);return e.replace(ve,(e,t,n,a,o)=>{if(o)return e;let s=ye.exec(a);if(s){let n=s[1],a=s[2].toUpperCase(),o=s[3],c=s[4];if(a.length>3||a.length===3&&a>`XFD`)return e;let l=S.l2n(a),u=parseInt(c,10);return n||(l+=i.col-r.col),o||(u+=i.row-r.row),(t??``)+(n??``)+S.n2l(l)+(o??``)+u}return e})}let xe=e=>!!e&&(typeof e!=`object`||Object.keys(e).length>0);var T=class e{static{this.Types=w.ValueType}constructor(t,n,r){if(!t||!n)throw new l(`A Cell needs a Row`);this._row=t,this._column=n,S.validateAddress(r),this._address=r,this._value=Fe.create(e.Types.Null,this),this.style=this._mergeStyle(t.style,n.style,{}),this._mergeCount=0}get worksheet(){return this._row.worksheet}get workbook(){return this._row.worksheet.workbook}destroy(){this.style=void 0,this._value=void 0,this._row=void 0,this._column=void 0,this._address=void 0}get numFmt(){return this.style.numFmt}set numFmt(e){this.style.numFmt=e}get font(){return this.style.font}set font(e){this.style.font=e}get alignment(){return this.style.alignment}set alignment(e){this.style.alignment=e}get border(){return this.style.border}set border(e){this.style.border=e}get fill(){return this.style.fill}set fill(e){this.style.fill=e}get protection(){return this.style.protection}set protection(e){this.style.protection=e}_mergeStyle(e,t,n){let r=e&&e.numFmt||t&&t.numFmt;r&&(n.numFmt=r);let i=e&&xe(e.font)&&e.font||t&&xe(t.font)&&t.font;i&&(n.font=i);let a=e&&xe(e.alignment)&&e.alignment||t&&xe(t.alignment)&&t.alignment;a&&(n.alignment=a);let o=e&&xe(e.border)&&e.border||t&&xe(t.border)&&t.border;o&&(n.border=o);let s=e&&xe(e.fill)&&e.fill||t&&xe(t.fill)&&t.fill;s&&(n.fill=s);let c=e&&xe(e.protection)&&e.protection||t&&xe(t.protection)&&t.protection;return c&&(n.protection=c),n}get address(){return this._address}get row(){return this._row.number}get col(){return this._column.number}get $col$row(){return`$${this._column.letter}$${this.row}`}get type(){return this._value.type}get effectiveType(){return this._value.effectiveType}toCsvString(){return this._value.toCsvString()}addMergeRef(){this._mergeCount++}releaseMergeRef(){this._mergeCount--}get isMerged(){return this._mergeCount>0||this.type===e.Types.Merge}merge(t,n){this._value.release(),this._value=Fe.create(e.Types.Merge,this,t),n||(this.style=t.style)}unmerge(){this.type===e.Types.Merge&&(this._value.release(),this._value=Fe.create(e.Types.Null,this),this.style=this._mergeStyle(this._row.style,this._column.style,{...this.style}))}isMergedTo(t){return this._value.type===e.Types.Merge&&this._value.isMergedTo?this._value.isMergedTo(t):!1}get master(){return this.type===e.Types.Merge?this._value.master:this}get isHyperlink(){return this._value.type===e.Types.Hyperlink}get hyperlink(){return this._value.hyperlink}get value(){return this._value.value}set value(t){if(this.type===e.Types.Merge){this._value.master.value=t;return}this._value.release(),this._value=Fe.create(Fe.getType(t),this,t)}get note(){if(this._comment)return this._comment.note}set note(e){this._comment=new _e(e)}get comment(){return this._comment}set comment(e){e===void 0?this._comment=void 0:e instanceof _e?this._comment=e:this._comment=new _e(e)}get text(){return this._value.toString()}get html(){return me(this.text)}toString(){return this.text}_upgradeToHyperlink(t){this.type===e.Types.String&&(this._value=Fe.create(e.Types.Hyperlink,this,{text:String(this._value.value),hyperlink:t}))}get formula(){return this._value.formula}get result(){return this._value.result}get formulaType(){return this._value.formulaType??w.FormulaType.None}get fullAddress(){let{worksheet:e}=this._row;return{sheetName:e.name,address:this.address,row:this.row,col:this.col}}get name(){return this.names[0]}set name(e){this.names=[e]}get names(){return this.workbook.definedNames.getNamesEx(this.fullAddress)}set names(e){let{definedNames:t}=this.workbook;t.removeAllNames(this.fullAddress),e.forEach(e=>{t.addEx(this.fullAddress,e)})}addName(e){this.workbook.definedNames.addEx(this.fullAddress,e)}removeName(e){this.workbook.definedNames.removeEx(this.fullAddress,e)}removeAllNames(){this.workbook.definedNames.removeAllNames(this.fullAddress)}get _dataValidations(){return this.worksheet.dataValidations}get dataValidation(){return this._dataValidations.find(this.address)}set dataValidation(e){this._dataValidations.add(this.address,e)}get model(){let{model:e}=this._value;return e.style=this.style,this._comment&&(e.comment=this._comment.model),e}set model(e){if(this._value.release(),this._value=Fe.create(e.type,this),this._value.model=e,e.comment)switch(e.comment.type){case`note`:this._comment=_e.fromModel(e.comment);break}e.style?this.style=e.style:this.style={}}},Se=class{constructor(e){this.model={address:e.address,type:T.Types.Null}}get value(){return null}set value(e){}get type(){return T.Types.Null}get effectiveType(){return T.Types.Null}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return``}release(){}toString(){return``}},Ce=class{constructor(e,t){this.model={address:e.address,type:T.Types.Number,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return T.Types.Number}get effectiveType(){return T.Types.Number}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}},we=class{constructor(e,t){this.model={address:e.address,type:T.Types.String,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return T.Types.String}get effectiveType(){return T.Types.String}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return`"${this.model.value.replace(/"/g,`""`)}"`}release(){}toString(){return this.model.value}},Te=class{constructor(e,t){this.model={address:e.address,type:T.Types.String,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}toString(){return this.model.value.richText.map(e=>e.text).join(``)}get type(){return T.Types.RichText}get effectiveType(){return T.Types.RichText}get address(){return this.model.address}set address(e){this.model.address=e}get text(){return this.toString()}toCsvString(){return`"${this.text.replace(/"/g,`""`)}"`}release(){}},Ee=class{constructor(e,t){this.model={address:e.address,type:T.Types.Date,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return T.Types.Date}get effectiveType(){return T.Types.Date}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value.toISOString()}release(){}toString(){return this.model.value.toString()}},De=class{constructor(e,t){this.model={address:e.address,type:T.Types.Hyperlink,text:t?t.text:void 0,hyperlink:t?t.hyperlink:void 0},t&&t.tooltip&&(this.model.tooltip=t.tooltip)}get value(){return{text:this.model.text??``,hyperlink:this.model.hyperlink??``,tooltip:this.model.tooltip}}set value(e){this.model.text=e.text,this.model.hyperlink=e.hyperlink,e.tooltip&&(this.model.tooltip=e.tooltip)}get text(){return this.model.text}set text(e){this.model.text=e}get hyperlink(){return this.model.hyperlink}set hyperlink(e){this.model.hyperlink=e}get type(){return T.Types.Hyperlink}get effectiveType(){return T.Types.Hyperlink}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.hyperlink??``}release(){}toString(){return this.model.text??``}},Oe=class{constructor(e,t){this.model={address:e.address,type:T.Types.Merge,master:t?t.address:void 0},this._master=t,t&&t.addMergeRef()}get value(){return this._master.value}set value(e){e instanceof T?(this._master&&this._master.releaseMergeRef(),e.addMergeRef(),this._master=e):this._master.value=e}isMergedTo(e){return e===this._master}get master(){return this._master}get type(){return T.Types.Merge}get effectiveType(){return this._master.effectiveType}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return``}release(){this._master.releaseMergeRef()}toString(){return this.value==null?``:this.value.toString()}},ke=class{constructor(e,t){this.cell=e,this.model={address:e.address,type:T.Types.Formula,shareType:t?t.shareType:void 0,ref:t?t.ref:void 0,formula:t?t.formula:void 0,sharedFormula:t?t.sharedFormula:void 0,result:t?t.result:void 0}}_copyModel(e){let t={};return e.formula&&(t.formula=e.formula),e.result!==void 0&&(t.result=e.result),e.ref&&(t.ref=e.ref),e.shareType&&(t.shareType=e.shareType),e.sharedFormula&&(t.sharedFormula=e.sharedFormula),t}get value(){return this._copyModel(this.model)}set value(e){e.formula&&(this.model.formula=e.formula),e.result!==void 0&&(this.model.result=e.result),e.ref&&(this.model.ref=e.ref),e.shareType&&(this.model.shareType=e.shareType),e.sharedFormula&&(this.model.sharedFormula=e.sharedFormula)}validate(e){switch(Fe.getType(e)){case T.Types.Null:case T.Types.String:case T.Types.Number:case T.Types.Date:break;case T.Types.Hyperlink:case T.Types.Formula:default:throw new g(String(Fe.getType(e)),`Cannot process that type of result value`)}}get dependencies(){return{ranges:this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g),cells:this.formula.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g,``).match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g)}}get formula(){return this.model.formula||this._getTranslatedFormula()||``}set formula(e){this.model.formula=e}get formulaType(){return this.model.formula?w.FormulaType.Master:this.model.sharedFormula?w.FormulaType.Shared:w.FormulaType.None}get result(){return this.model.result}set result(e){this.model.result=e}get type(){return T.Types.Formula}get effectiveType(){let e=this.model.result;return e==null?w.ValueType.Null:typeof e==`string`?w.ValueType.String:typeof e==`number`?w.ValueType.Number:e instanceof Date?w.ValueType.Date:typeof e==`object`&&`error`in e?w.ValueType.Error:w.ValueType.Null}get address(){return this.model.address}set address(e){this.model.address=e}_getTranslatedFormula(){if(!this._translatedFormula&&this.model.sharedFormula){let{worksheet:e}=this.cell,t=e.findCell(this.model.sharedFormula);this._translatedFormula=t&&t.formula?be(t.formula,t.address,this.model.address):void 0}return this._translatedFormula}toCsvString(){return`${this.model.result??``}`}release(){}toString(){return this.model.result?this.model.result.toString():``}},Ae=class{constructor(e,t){this.model={address:e.address,type:T.Types.SharedString,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return T.Types.SharedString}get effectiveType(){return T.Types.SharedString}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}},je=class{constructor(e,t){this.model={address:e.address,type:T.Types.Boolean,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return T.Types.Boolean}get effectiveType(){return T.Types.Boolean}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value?1:0}release(){}toString(){return this.model.value.toString()}},Me=class{constructor(e,t){this.model={address:e.address,type:T.Types.Checkbox,value:t.checkbox}}get value(){return{checkbox:this.model.value}}set value(e){this.model.value=e.checkbox}get type(){return T.Types.Checkbox}get effectiveType(){return T.Types.Boolean}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value?1:0}release(){}toString(){return this.model.value.toString()}},Ne=class{constructor(e,t){this.model={address:e.address,type:T.Types.Error,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return T.Types.Error}get effectiveType(){return T.Types.Error}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.toString()}release(){}toString(){return this.model.value.error.toString()}},Pe=class{constructor(e,t){this.model={address:e.address,type:T.Types.String,value:JSON.stringify(t),rawValue:t}}get value(){return this.model.rawValue}set value(e){this.model.rawValue=e,this.model.value=JSON.stringify(e)}get type(){return T.Types.String}get effectiveType(){return T.Types.String}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value}release(){}toString(){return this.model.value}};let Fe={getType(e){if(e==null)return T.Types.Null;if(typeof e==`string`)return T.Types.String;if(typeof e==`number`)return T.Types.Number;if(typeof e==`boolean`)return T.Types.Boolean;if(e instanceof Date)return T.Types.Date;if(typeof e==`object`){if(`checkbox`in e&&typeof e.checkbox==`boolean`)return T.Types.Checkbox;if(`text`in e&&e.text&&`hyperlink`in e&&e.hyperlink)return T.Types.Hyperlink;if(`formula`in e&&e.formula||`sharedFormula`in e&&e.sharedFormula)return T.Types.Formula;if(`richText`in e&&e.richText)return T.Types.RichText;if(`sharedString`in e&&e.sharedString)return T.Types.SharedString;if(`error`in e&&e.error)return T.Types.Error}return T.Types.JSON},types:[{t:T.Types.Null,f:Se},{t:T.Types.Number,f:Ce},{t:T.Types.String,f:we},{t:T.Types.Date,f:Ee},{t:T.Types.Hyperlink,f:De},{t:T.Types.Formula,f:ke},{t:T.Types.Merge,f:Oe},{t:T.Types.JSON,f:Pe},{t:T.Types.SharedString,f:Ae},{t:T.Types.RichText,f:Te},{t:T.Types.Boolean,f:je},{t:T.Types.Error,f:Ne},{t:T.Types.Checkbox,f:Me}].reduce((e,t)=>(e[t.t]=t.f,e),[]),create(e,t,n){let r=this.types[e];if(!r)throw new g(String(e),`Could not create Value`);return new r(t,n)}},Ie=(e,t)=>({...e,...t.reduce((t,n)=>(e[n]&&(t[n]={...e[n]}),t),{})}),Le=(e,t,n,r=[])=>{e[n]&&(t[n]=Ie(e[n],r))},Re=e=>Object.keys(e).length===0,ze=e=>{if(!e)return e;if(Re(e))return{};let t={...e};return Le(e,t,`font`,[`color`]),Le(e,t,`alignment`),Le(e,t,`protection`),e.border&&(Le(e,t,`border`),Le(e.border,t.border,`top`,[`color`]),Le(e.border,t.border,`left`,[`color`]),Le(e.border,t.border,`bottom`,[`color`]),Le(e.border,t.border,`right`,[`color`]),Le(e.border,t.border,`diagonal`,[`color`])),e.fill&&(Le(e,t,`fill`,[`fgColor`,`bgColor`,`center`]),e.fill.stops&&(t.fill.stops=e.fill.stops.map(e=>Ie(e,[`color`])))),t};var Be=class{constructor(e,t){this._worksheet=e,this._number=t,this._cells=[],this.style={},this.outlineLevel=0}get number(){return this._number}get worksheet(){return this._worksheet}commit(){this._worksheet._commitRow(this)}destroy(){this._worksheet=void 0,this._cells=void 0,this.style=void 0}findCell(e){return this._cells[e-1]}getCellEx(e){let t=this._cells[e.col-1];if(!t){let n=this._worksheet.getColumn(e.col);t=new T(this,n,e.address),this._cells[e.col-1]=t}return t}getCell(e){let t;if(typeof e==`string`){let n=this._worksheet.getColumnKey(e);t=n?n.number:S.l2n(e)}else t=e;return this._cells[t-1]||this.getCellEx({address:S.encodeAddress(this._number,t),row:this._number,col:t})}splice(e,t,...n){let r=e+t,i=n.length-t,a=this._cells.length,o,s,c;if(i<0)for(o=e+n.length;o<=a;o++)c=this._cells[o-1],s=this._cells[o-i-1],s?(c=this.getCell(o),c.value=s.value,c.style=ze(s.style)??{},c.comment=s.comment):c&&(c.value=null,c.style={},c.comment=void 0);else if(i>0)for(o=a;o>=r;o--)s=this._cells[o-1],s?(c=this.getCell(o+i),c.value=s.value,c.style=ze(s.style)??{},c.comment=s.comment):this._cells[o+i-1]=void 0;for(o=0;o<n.length;o++)c=this.getCell(e+o),c.value=n[o],c.style={},c.comment=void 0}eachCell(e,t){let n=null,r;if(typeof e==`function`?r=e:(n=e,r=t),n&&n.includeEmpty){let e=this._cells.length;for(let t=1;t<=e;t++)r(this.getCell(t),t)}else this._cells.forEach((e,t)=>{e&&e.type!==w.ValueType.Null&&r(e,t+1)})}addPageBreak(e,t){let n=this._worksheet,r=Math.max(0,(e??0)-1)||0,i=Math.max(0,(t??0)-1)||16838,a={id:this._number,max:i,man:1};r&&(a.min=r),n.rowBreaks.push(a)}get values(){let e=[];return this._cells.forEach(t=>{t&&t.type!==w.ValueType.Null&&(e[t.col]=t.value)}),e}set values(e){if(this._cells=[],e)if(e instanceof Array){let t=0;Object.prototype.hasOwnProperty.call(e,`0`)&&(t=1),e.forEach((e,n)=>{e!==void 0&&(this.getCellEx({address:S.encodeAddress(this._number,n+t),row:this._number,col:n+t}).value=e)})}else this._worksheet.eachColumnKey((t,n)=>{e[n]!==void 0&&(this.getCellEx({address:S.encodeAddress(this._number,t.number),row:this._number,col:t.number}).value=e[n])})}getValues(){let e=[];return this._cells.forEach(t=>{t&&t.type!==w.ValueType.Null&&(e[t.col-1]=t.value)}),e}valuesToString(e=`,`){return this.getValues().join(e)}get hasValues(){return this._cells.some(e=>e&&e.type!==w.ValueType.Null)}get cellCount(){return this._cells.length}get actualCellCount(){let e=0;return this.eachCell(()=>{e++}),e}get dimensions(){let e=0,t=0;return this._cells.forEach(n=>{n&&n.type!==w.ValueType.Null&&((!e||e>n.col)&&(e=n.col),t<n.col&&(t=n.col))}),e>0?{min:e,max:t}:null}_applyStyle(e,t){this.style[e]=t,this._cells.forEach(n=>{n&&(n.style[e]=t)})}get numFmt(){return this.style.numFmt}set numFmt(e){e!==void 0&&this._applyStyle(`numFmt`,e)}get font(){return this.style.font}set font(e){e!==void 0&&this._applyStyle(`font`,e)}get alignment(){return this.style.alignment}set alignment(e){e!==void 0&&this._applyStyle(`alignment`,e)}get protection(){return this.style.protection}set protection(e){e!==void 0&&this._applyStyle(`protection`,e)}get border(){return this.style.border}set border(e){e!==void 0&&this._applyStyle(`border`,e)}get fill(){return this.style.fill}set fill(e){e!==void 0&&this._applyStyle(`fill`,e)}get hidden(){return!!this._hidden}set hidden(e){this._hidden=e}get outlineLevel(){return this._outlineLevel??0}set outlineLevel(e){this._outlineLevel=e}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=(this._worksheet.properties.outlineLevelRow??0))}get model(){let e=[],t=0,n=0;return this._cells.forEach(r=>{if(r){let i=r.model;i&&((!t||t>r.col)&&(t=r.col),n<r.col&&(n=r.col),e.push(i))}}),this.height!=null||e.length?{cells:e,number:this.number,min:t,max:n,height:this.height,customHeight:this.customHeight,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel,collapsed:this.collapsed,dyDescent:this.dyDescent}:null}set model(e){if(e.number!==this._number)throw new l(`Invalid row number in model`);this._cells=[];let t;e.cells.forEach(e=>{switch(e.type){case T.Types.Merge:break;default:{let n;if(e.address)n=S.decodeAddress(e.address);else if(t){let{row:e}=t,r=t.col+1;n={row:e,col:r,address:S.encodeAddress(e,r),$col$row:`$${S.n2l(r)}$${e}`}}if(t=n,!n)break;let r=this.getCellEx(n);r.model=e;break}}}),e.height==null?delete this.height:this.height=e.height,e.customHeight==null?delete this.customHeight:this.customHeight=e.customHeight,this.hidden=e.hidden,this.outlineLevel=e.outlineLevel??0,this.dyDescent=e.dyDescent,this.style=e.style?structuredClone(e.style):{}}},Ve=class e{constructor(e,t,n){this._worksheet=e,this._number=t,n!==!1&&(this.defn=n)}get number(){return this._number}get worksheet(){return this._worksheet}get letter(){return S.n2l(this._number)}get isCustomWidth(){return this.width!==void 0&&this.width!==9}get defn(){return{header:this._header,key:this.key,width:this.width,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel,bestFit:this.bestFit}}set defn(e){e?(this.key=e.key,this.width=e.width===void 0?9:e.width,this.outlineLevel=e.outlineLevel,e.style?this.style=e.style:this.style={},this.header=e.header,this._hidden=!!e.hidden,this.bestFit=e.bestFit):(delete this._header,delete this._key,delete this.width,this.style={},this.outlineLevel=0,delete this.bestFit)}get headers(){return Array.isArray(this._header)?this._header:this._header===void 0?[]:[this._header]}get header(){return this._header}set header(e){e===void 0?this._header=void 0:(this._header=e,this.headers.forEach((e,t)=>{this._worksheet.getCell(t+1,this.number).value=e}))}get key(){return this._key}set key(e){(this._key&&this._worksheet.getColumnKey(this._key))===this&&this._worksheet.deleteColumnKey(this._key),this._key=e,e&&this._worksheet.setColumnKey(e,this)}get hidden(){return!!this._hidden}set hidden(e){this._hidden=e}get outlineLevel(){return this._outlineLevel??0}set outlineLevel(e){this._outlineLevel=e}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=(this._worksheet.properties.outlineLevelCol??0))}toString(){return JSON.stringify({key:this.key,width:this.width,headers:this.headers.length?this.headers:void 0})}equivalentTo(e){return this.width===e.width&&this.hidden===e.hidden&&this.outlineLevel===e.outlineLevel&&pe(this.style,e.style)}equivalentToModel(e){return this.width===e.width&&this.hidden===e.hidden&&this.outlineLevel===e.outlineLevel&&this.bestFit===e.bestFit&&pe(this.style,e.style)}get isDefault(){if(this.isCustomWidth||this.hidden||this.outlineLevel||this.bestFit)return!1;let e=this.style;return!(e&&(e.font||e.numFmt||e.alignment||e.border||e.fill||e.protection))}get headerCount(){return this.headers.length}eachCell(e,t){let n=this.number,r,i;typeof e==`function`?(r={},i=e):(r=e,i=t),this._worksheet.eachRow(r,(e,t)=>{i(e.getCell(n),t)})}get values(){let e=[];return this.eachCell((t,n)=>{t&&t.type!==w.ValueType.Null&&(e[n]=t.value)}),e}set values(e){if(!e)return;let t=this.number,n=0;Object.prototype.hasOwnProperty.call(e,`0`)&&(n=1),e.forEach((e,r)=>{this._worksheet.getCell(r+n,t).value=e})}addPageBreak(e,t){let n=this._worksheet,r=Math.max(0,(e??0)-1)||0,i=Math.max(0,(t??0)-1)||1048575,a={id:this._number,max:i,man:1};r&&(a.min=r),n.colBreaks.push(a)}get numFmt(){return this.style.numFmt}set numFmt(e){this.style.numFmt=e,this.eachCell(t=>{t.numFmt=e})}get font(){return this.style.font}set font(e){this.style.font=e,this.eachCell(t=>{t.font=e})}get alignment(){return this.style.alignment}set alignment(e){this.style.alignment=e,this.eachCell(t=>{t.alignment=e})}get protection(){return this.style.protection}set protection(e){this.style.protection=e,this.eachCell(t=>{t.protection=e})}get border(){return this.style.border}set border(e){this.style.border=e,this.eachCell(t=>{t.border=e})}get fill(){return this.style.fill}set fill(e){this.style.fill=e,this.eachCell(t=>{t.fill=e})}static toModel(e){let t=[],n=null;return e.forEach((e,r)=>{e.isDefault?n&&=null:!n||!e.equivalentToModel(n)?(n={min:r+1,max:r+1,width:e.width===void 0?9:e.width,style:e.style,isCustomWidth:e.isCustomWidth,hidden:e.hidden,outlineLevel:e.outlineLevel,collapsed:e.collapsed,bestFit:e.bestFit},t.push(n)):n.max=r+1}),t.length?t:void 0}static fromModel(t,n){let r=t,i=Array.isArray(t)?t:n??[];i??=[];let a=[],o=1,s=0;for(i=i.sort((e,t)=>e.min-t.min);s<i.length;){let t=i[s++];for(;o<t.min;)a.push(new e(r,o++));for(;o<=t.max;)a.push(new e(r,o++,t))}return a}};function He(e){return typeof e==`object`&&`nativeCol`in e&&`nativeRow`in e&&`nativeColOff`in e&&`nativeRowOff`in e}function Ue(e){return typeof e==`object`&&`col`in e&&`row`in e}var We=class e{constructor(e,t,n=0){if(this.worksheet=e,!t)this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0;else if(typeof t==`string`){let e=S.decodeAddress(t);this.nativeCol=e.col+n,this.nativeColOff=0,this.nativeRow=e.row+n,this.nativeRowOff=0}else He(t)?(this.nativeCol=t.nativeCol??0,this.nativeColOff=t.nativeColOff??0,this.nativeRow=t.nativeRow??0,this.nativeRowOff=t.nativeRowOff??0):Ue(t)?(this.col=t.col+n,this.row=t.row+n):(this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0)}static asInstance(t){return t==null?null:t instanceof e?t:new e(void 0,t)}get col(){return this.nativeCol+Math.min(this.colWidth-1,this.nativeColOff)/this.colWidth}set col(e){this.nativeCol=Math.floor(e),this.nativeColOff=Math.floor((e-this.nativeCol)*this.colWidth)}get row(){return this.nativeRow+Math.min(this.rowHeight-1,this.nativeRowOff)/this.rowHeight}set row(e){this.nativeRow=Math.floor(e),this.nativeRowOff=Math.floor((e-this.nativeRow)*this.rowHeight)}get colWidth(){return this.worksheet&&this.worksheet.getColumn(this.nativeCol+1)&&this.worksheet.getColumn(this.nativeCol+1).isCustomWidth?Math.floor(this.worksheet.getColumn(this.nativeCol+1).width*1e4):64e4}get rowHeight(){let e=this.worksheet?.getRow(this.nativeRow+1)?.height;return e?Math.floor(e*1e4):18e4}get model(){return{nativeCol:this.nativeCol,nativeColOff:this.nativeColOff,nativeRow:this.nativeRow,nativeRowOff:this.nativeRowOff}}set model(e){this.nativeCol=e.nativeCol,this.nativeColOff=e.nativeColOff,this.nativeRow=e.nativeRow,this.nativeRowOff=e.nativeRowOff}clone(t){return new e(t??this.worksheet,this.model)}},Ge=class e{constructor(e,t){this.worksheet=e,t&&(this.model=t)}get model(){switch(this.type){case`background`:return{type:this.type,imageId:this.imageId??``};case`image`:{let e=this.range;if(!e)throw new ne(`Image has no range`);return{type:this.type,imageId:this.imageId??``,hyperlinks:e.hyperlinks,range:{tl:e.tl.model,br:e.br?.model,ext:e.ext,editAs:e.editAs}}}default:throw new ne(`Invalid Image Type`)}}set model({type:e,imageId:t,range:n,hyperlinks:r}){if(this.type=e,this.imageId=t,e===`image`)if(typeof n==`string`){let e=S.decode(n);`top`in e&&(this.range={tl:new We(this.worksheet,{col:e.left,row:e.top},-1),br:new We(this.worksheet,{col:e.right,row:e.bottom},0),editAs:`oneCell`})}else n&&(this.range={tl:new We(this.worksheet,n.tl,0),br:n.br?new We(this.worksheet,n.br,0):void 0,ext:n.ext,editAs:n.editAs,hyperlinks:r||(`hyperlinks`in n?n.hyperlinks:void 0)})}clone(t){let n=t??this.worksheet,r=new e(n);return r.type=this.type,r.imageId=this.imageId,this.range&&(r.range={tl:this.range.tl.clone(n),br:this.range.br?this.range.br.clone(n):void 0,ext:this.range.ext?{...this.range.ext}:void 0,editAs:this.range.editAs,hyperlinks:this.range.hyperlinks?{...this.range.hyperlinks}:void 0}),r}};let Ke=/^[A-Za-z]{1,3}\d+$/,qe=/^[Rr]\d+[Cc]\d+$/,Je=new Set([`C`,`c`,`R`,`r`]),Ye=/\s/g,Xe=/[^\p{L}\p{N}_.]/gu,Ze=/^[\p{L}_\\]/u;function Qe(e){let t=e.replace(Ye,`_`),n=!1;return t.startsWith(`\\`)&&(n=!0,t=t.slice(1)),t=t.replace(Xe,``),n&&(t=`\\${t}`),t.length>0&&!Ze.test(t)&&(t=`_${t}`),t.length===0?`_Table`:(t.length===1&&Je.has(t)&&(t=`_${t}`),(Ke.test(t)||qe.test(t))&&(t=`_${t}`),t.length>255&&(t=t.slice(0,255)),t)}var $e=class{constructor(e,t,n){this.table=e,this.column=t,this.index=n}_set(e,t){this.table.cacheState(),this.column[e]=t}get name(){return this.column.name}set name(e){this._set(`name`,e)}get filterButton(){return this.column.filterButton}set filterButton(e){this.column.filterButton=e}get style(){return this.column.style}set style(e){this.column.style=e}get totalsRowLabel(){return this.column.totalsRowLabel}set totalsRowLabel(e){this._set(`totalsRowLabel`,e)}get totalsRowFunction(){return this.column.totalsRowFunction}set totalsRowFunction(e){this._set(`totalsRowFunction`,e)}get totalsRowResult(){return this.column.totalsRowResult}set totalsRowResult(e){this._set(`totalsRowResult`,e)}get totalsRowFormula(){return this.column.totalsRowFormula}set totalsRowFormula(e){this._set(`totalsRowFormula`,e)}},et=class e{constructor(e,t){if(this.worksheet=e,t){if(this.table=t,Array.isArray(t.rows)&&t.rows.length===0&&t.tableRef){let n=S.decode(t.tableRef);if(`dimensions`in n){let r=n.top+(t.headerRow===!1?0:1),i=n.bottom-(t.totalsRow===!0?1:0);if(i>=r)for(let a=r;a<=i;a++){let r=e.getRow(a),i=[];for(let e=n.left;e<=n.right;e++)i.push(r.getCell(e).value);t.rows.push(i)}}}this.validate(),this.store()}}static{this.SUBTOTAL_FUNCTIONS={average:101,countNums:102,count:103,max:104,min:105,stdDev:106,var:107,sum:109}}getFormula(t){if(t.totalsRowFunction===`none`)return null;if(t.totalsRowFunction===`custom`)return t.totalsRowFormula??null;let n=t.totalsRowFunction?e.SUBTOTAL_FUNCTIONS[t.totalsRowFunction]:void 0;if(n!==void 0)return`SUBTOTAL(${n},${this.table.name}[${t.name}])`;throw new te(`Invalid Totals Row Function: ${t.totalsRowFunction}`)}get width(){return this.table.columns.length}get height(){return this.table.rows.length}get filterHeight(){return this.height+(this.table.headerRow?1:0)}get tableHeight(){return this.filterHeight+(this.table.totalsRow?1:0)}validate(){let{table:e}=this,t=(e,t,n)=>{e[t]===void 0&&(e[t]=n)};t(e,`headerRow`,!0),t(e,`totalsRow`,!1),t(e,`style`,{});let n=e.style;t(n,`theme`,`TableStyleMedium2`),t(n,`showFirstColumn`,!1),t(n,`showLastColumn`,!1),t(n,`showRowStripes`,!1),t(n,`showColumnStripes`,!1),e.name&&=Qe(e.name),e.displayName&&=Qe(e.displayName);let r=(e,t)=>{if(!e)throw new te(t)};r(!!e.name,`Table must have a name`),r(!!e.ref,`Table must have ref`),r(!!e.columns,`Table must have column definitions`),r(!!e.rows,`Table must have row definitions`),e.tl=S.decodeAddress(e.ref);let{row:i,col:a}=e.tl;r(i>0,`Table must be on valid row`),r(a>0,`Table must be on valid col`);let{width:o,tableHeight:s}=this;e.autoFilterRef=S.encode(i,a,i,a+o-1),e.tableRef=S.encode(i,a,i+s-1,a+o-1),e.columns.forEach((e,n)=>{r(!!e.name,`Column ${n} must have a name`),n===0?t(e,`totalsRowLabel`,`Total`):(t(e,`totalsRowFunction`,`none`),e.totalsRowFormula=this.getFormula(e)??void 0)})}store(){let e=(e,t)=>{t&&Object.assign(e.style,t)},{worksheet:t,table:n}=this,{row:r,col:i}=n.tl,a=0;if(n.headerRow){let o=t.getRow(r+ a++);n.columns.forEach((t,n)=>{let{style:r,name:a}=t,s=o.getCell(i+n);s.value=a,e(s,r)})}if(n.rows.forEach(o=>{let s=t.getRow(r+ a++);o.forEach((t,r)=>{let a=s.getCell(i+r);if(typeof t==`object`&&t&&`formula`in t&&typeof t.formula==`string`){let e=t,r=n.qualifyImplicitStructuredReferences===!0;a.value={...e,formula:r?e.formula.replace(/(^|[^A-Za-z0-9_])\[@\[?([^\[\]]+?)\]?\]/g,`$1${n.name}[[#This Row],[$2]]`):e.formula}}else a.value=t;e(a,n.columns[r]?.style)})}),n.totalsRow){let o=t.getRow(r+ a++);n.columns.forEach((t,n)=>{let r=o.getCell(i+n);if(n===0)r.value=t.totalsRowLabel;else{let e=this.getFormula(t);e?r.value={formula:e,result:t.totalsRowResult}:r.value=null}e(r,t.style)})}}load(e){let{table:t}=this,{row:n,col:r}=t.tl,i=0;if(t.headerRow){let a=e.getRow(n+ i++);t.columns.forEach((e,t)=>{let n=a.getCell(r+t);n.value=e.name})}if(t.rows.forEach(t=>{let a=e.getRow(n+ i++);t.forEach((e,t)=>{let n=a.getCell(r+t);n.value=e})}),t.totalsRow){let a=e.getRow(n+ i++);t.columns.forEach((e,t)=>{let n=a.getCell(r+t);if(t===0)n.value=e.totalsRowLabel;else{let t=this.getFormula(e);t&&(n.value={formula:t,result:e.totalsRowResult})}})}}get model(){return this.table}set model(e){this.table=e}cacheState(){this._cache||={ref:this.ref,width:this.width,tableHeight:this.tableHeight}}commit(){if(!this._cache)return;this.validate();let e=S.decodeAddress(this._cache.ref);if(this.ref!==this._cache.ref)for(let t=0;t<this._cache.tableHeight;t++){let n=this.worksheet.getRow(e.row+t);for(let t=0;t<this._cache.width;t++){let r=n.getCell(e.col+t);r.value=null}}else{for(let t=this.tableHeight;t<this._cache.tableHeight;t++){let n=this.worksheet.getRow(e.row+t);for(let t=0;t<this._cache.width;t++){let r=n.getCell(e.col+t);r.value=null}}for(let t=0;t<this.tableHeight;t++){let n=this.worksheet.getRow(e.row+t);for(let t=this.width;t<this._cache.width;t++){let r=n.getCell(e.col+t);r.value=null}}}this.store(),this._cache=void 0}addRow(e,t,n){this.cacheState(),t===void 0?this.table.rows.push(e):this.table.rows.splice(t,0,e),n?.commit!==!1&&this.commit()}removeRows(e,t=1,n){this.cacheState(),this.table.rows.splice(e,t),n?.commit!==!1&&this.commit()}getColumn(e){let t=this.table.columns[e];return new $e(this,t,e)}addColumn(e,t,n){this.cacheState(),n===void 0?(this.table.columns.push(e),this.table.rows.forEach((e,n)=>{e.push(t[n])})):(this.table.columns.splice(n,0,e),this.table.rows.forEach((e,r)=>{e.splice(n,0,t[r])}))}removeColumns(e,t=1){this.cacheState(),this.table.columns.splice(e,t),this.table.rows.forEach(n=>{n.splice(e,t)})}_assign(e,t,n){this.cacheState(),e[t]=n}get ref(){return this.table.ref}set ref(e){this._assign(this.table,`ref`,e)}get name(){return this.table.name}set name(e){this.cacheState(),this.table.name=Qe(e)}get displayName(){return this.table.displayName||this.table.name}set displayName(e){this.cacheState(),this.table.displayName=Qe(e)}get headerRow(){return this.table.headerRow}set headerRow(e){this._assign(this.table,`headerRow`,e)}get totalsRow(){return this.table.totalsRow}set totalsRow(e){this._assign(this.table,`totalsRow`,e)}_ensureStyle(){return this.table.style||(this.table.style={}),this.table.style}get theme(){return this.table.style?.theme}set theme(e){this._ensureStyle().theme=e}get showFirstColumn(){return this.table.style?.showFirstColumn}set showFirstColumn(e){this._ensureStyle().showFirstColumn=e}get showLastColumn(){return this.table.style?.showLastColumn}set showLastColumn(e){this._ensureStyle().showLastColumn=e}get showRowStripes(){return this.table.style?.showRowStripes}set showRowStripes(e){this._ensureStyle().showRowStripes=e}get showColumnStripes(){return this.table.style?.showColumnStripes}set showColumnStripes(e){this._ensureStyle().showColumnStripes=e}},tt=class{constructor(e){this.model=e||{}}add(e,t){return this.model[e]=t}find(e){let t=this.model[e];if(t!==void 0)return t;let n;for(let t of Object.keys(this.model)){if(!t.startsWith(`range:`))continue;n||=S.decodeAddress(e);let r=t.slice(6),i=S.decodeEx(r);if(!(`dimensions`in i))continue;let{tl:a,br:o}=i,s=typeof a==`string`?S.decodeAddress(a):a,c=typeof o==`string`?S.decodeAddress(o):o;if(n.row>=s.row&&n.row<=c.row&&n.col>=s.col&&n.col<=c.col)return this.model[t]}}remove(e){this.model[e]=void 0}};let nt=9525,rt=12700,it=142875,at=28575,ot=276225,st=190500;var ct=class e{constructor(e,t,n){this.worksheet=e;let{tl:r,br:i}=this._parseRange(t),a=1025+(e.formControls?.length??0),o;n?.link&&(o=this._toAbsoluteRef(n.link)),this.model={shapeId:a,ctrlPropId:0,tl:r,br:i,link:o,checked:n?.checked?`Checked`:`Unchecked`,text:n?.text??``,noThreeD:n?.noThreeD??!0,print:n?.print??!1}}get checked(){return this.model.checked===`Checked`}set checked(e){this.model.checked=e?`Checked`:`Unchecked`}get link(){return this.model.link}set link(e){this.model.link=e?this._toAbsoluteRef(e):void 0}get text(){return this.model.text}set text(e){this.model.text=e}_toAbsoluteRef(e){if(e.includes(`$`))return e;let t=S.decodeAddress(e);return`$${S.n2l(t.col)}$${t.row}`}_parseRange(e){let t,n;if(typeof e==`string`)if(e.includes(`:`)){let r=S.decode(e);if(`top`in r)if(r.left===r.right&&r.top===r.bottom){let e=r.left-1,i=r.top-1;t={col:e,colOff:it,row:i,rowOff:at},n={col:e+2,colOff:ot,row:i+1,rowOff:st}}else t={col:r.left-1,colOff:it,row:r.top-1,rowOff:at},n={col:r.right-1,colOff:ot,row:r.bottom-1,rowOff:st};else t={col:r.col-1,colOff:it,row:r.row-1,rowOff:at},n={col:r.col+1,colOff:ot,row:r.row,rowOff:st}}else{let r=S.decodeAddress(e);t={col:r.col-1,colOff:it,row:r.row-1,rowOff:at},n={col:r.col+1,colOff:ot,row:r.row,rowOff:st}}else if(`startCol`in e)t={col:e.startCol,colOff:e.startColOff??it,row:e.startRow,rowOff:e.startRowOff??at},n={col:e.endCol,colOff:e.endColOff??ot,row:e.endRow,rowOff:e.endRowOff??st};else{if(typeof e.tl==`string`){let n=S.decodeAddress(e.tl);t={col:n.col-1,colOff:it,row:n.row-1,rowOff:at}}else t={col:e.tl.col,colOff:e.tl.colOff??it,row:e.tl.row,rowOff:e.tl.rowOff??at};if(e.br)if(typeof e.br==`string`){let t=S.decodeAddress(e.br);n={col:t.col-1,colOff:ot,row:t.row-1,rowOff:st}}else n={col:e.br.col,colOff:e.br.colOff??ot,row:e.br.row,rowOff:e.br.rowOff??st};else n={col:t.col+2,colOff:ot,row:t.row+1,rowOff:st}}return{tl:t,br:n}}getVmlAnchor(){return e.getVmlAnchor(this.model)}getVmlStyle(){return e.getVmlStyle(this.model)}getVmlCheckedValue(){return e.getVmlCheckedValue(this.model)}static getVmlAnchor(e){let{tl:t,br:n}=e,r=Math.round(t.colOff/nt),i=Math.round(t.rowOff/nt),a=Math.round(n.colOff/nt),o=Math.round(n.rowOff/nt);return`${t.col}, ${r}, ${t.row}, ${i}, ${n.col}, ${a}, ${n.row}, ${o}`}static getVmlStyle(e){return`position:absolute;margin-left:${Math.round(e.tl.colOff/rt)}pt;margin-top:${Math.round(e.tl.rowOff/rt)}pt;width:96pt;height:18pt;z-index:1;visibility:visible`}static getVmlCheckedValue(e){switch(e.checked){case`Checked`:return 1;case`Mixed`:return 2;default:return 0}}};function lt(){return typeof process<`u`&&!!process.versions?.node}function ut(e){if(lt())return Buffer.from(e,`base64`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function dt(e,t){return 25569+e.getTime()/(24*3600*1e3)-(t?1462:0)}function ft(e,t){let n=Math.round((e-25569+(t?1462:0))*24*3600*1e3);return new Date(n)}function pt(e){return new Date(e.endsWith(`Z`)?e:e+`Z`)}let mt=/_x([0-9A-Fa-f]{4})_/g;function ht(e){return e.replace(mt,(e,t)=>String.fromCharCode(parseInt(t,16)))}function gt(e){return e.replace(mt,`_x005F_x$1_`)}let _t=/[\t\n\r]/g,vt={" ":`_x0009_`,"\n":`_x000A_`,"\r":`_x000D_`};function yt(e){let t=e.replace(mt,`_x005F_x$1_`);return t=t.replace(_t,e=>vt[e]),t}let bt={lt:`<`,gt:`>`,amp:`&`,quot:`"`,apos:`'`};function xt(e){return e.indexOf(`&`)===-1?e:e.replace(/&(#\d+|#x[0-9A-Fa-f]+|\w+);/g,(e,t)=>{if(t[0]===`#`){let n=t[1]===`x`?parseInt(t.slice(2),16):parseInt(t.slice(1));return Number.isNaN(n)?e:String.fromCodePoint(n)}return bt[t]||e})}let St=/[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/;function E(e){let t=St.exec(e);if(!t)return e;let n=[],r=0;for(let i=t.index;i<e.length;i++){let t=e.charCodeAt(i),a;switch(t){case 34:a=`&quot;`;break;case 38:a=`&amp;`;break;case 39:a=`&apos;`;break;case 60:a=`&lt;`;break;case 62:a=`&gt;`;break;case 127:a=``;break;default:if(t<=31&&(t<=8||t>=11&&t!==13)){a=``;break}continue}r!==i&&n.push(e.substring(r,i)),r=i+1,a&&n.push(a)}return r<e.length&&n.push(e.substring(r)),n.join(``)}function Ct(e){let t=typeof e==`number`?e:parseInt(e,10);return Number.isNaN(t)?0:t}function wt(e){let t=[],n=``,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];o===`"`&&!i?(r=!r,n+=o):o===`[`&&!r?(i=!0,n+=o):o===`]`&&!r?(i=!1,n+=o):o===`;`&&!r&&!i?(t.push(n),n=``):n+=o}return t.push(n),t}let Tt=/[ymdhMsb]/,Et=/\[[^\]]*\]|"[^"]*"/g;function Dt(e){if(!e)return!1;let t=wt(e)[0].replace(Et,``);return t.indexOf(`@`)>-1?!1:Tt.test(t)}function D(e){return e===!0||e===`true`||e===1||e===`1`}function*Ot(e,t,n=1){let r=n>0?(e,t)=>e<t:(e,t)=>e>t;for(let i=e;r(i,t);i+=n)yield i}function kt(e){let t=Array.from(e);return t.length<=1?t:t.every(e=>Number.isFinite(e))?t.sort((e,t)=>e-t):t.every(e=>e instanceof Date)?t.sort((e,t)=>e.getTime()-t.getTime()):t.sort((e,t)=>{let n=At(e),r=At(t);return n===r?n===0?e-t:n===1?e.getTime()-t.getTime():String(e).localeCompare(String(t)):n-r})}function At(e){return Number.isFinite(e)?0:e instanceof Date?1:2}let jt=new TextDecoder(`utf-8`),Mt,Nt=!1;function Pt(){if(!Nt){Nt=!0;try{Mt=new TextDecoder(`latin1`)}catch{Mt=void 0}}return Mt}function Ft(e){return typeof e==`string`?e:jt.decode(e)}function It(e){if(lt())return Buffer.from(e).toString(`base64`);if(Pt())try{return btoa(Mt.decode(e))}catch{}let t=32768,n=[];for(let r=0;r<e.length;r+=t)n.push(String.fromCharCode.apply(null,e.subarray(r,r+t)));return btoa(n.join(``))}function Lt(e){let t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>8&255}return t}let Rt=new TextEncoder,zt=new TextDecoder(`utf-8`,{ignoreBOM:!0}),Bt=new Map;function Vt(e){let t=(e??`utf-8`).trim().toLowerCase();return t===``||t===`utf8`||t===`utf-8`?`utf-8`:t===`utf16le`||t===`utf-16le`||t===`ucs2`||t===`ucs-2`?`utf-16le`:t===`binary`?`latin1`:t}function Ht(e){let t=Vt(e);if(t===`utf-8`)return zt;let n=Bt.get(t);return n||(n=Ut(t),Bt.set(t,n)),n}function Ut(e,t){try{return new TextDecoder(e,t)}catch(t){throw TypeError(`Unsupported text encoding: ${e}`,{cause:t})}}function Wt(e){let t=Vt(e);switch(t){case`hex`:return new Gt;case`base64`:return new Yt(!1);case`base64url`:return new Yt(!0);case`ascii`:return new Xt;default:return Ut(t,{ignoreBOM:!0})}}var Gt=class{decode(e){let t=``;for(let n=0;n<e.length;n++)t+=Kt[e[n]];return t}};let Kt=(()=>{let e=Array(256);for(let t=0;t<256;t++)e[t]=t.toString(16).padStart(2,`0`);return e})(),qt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Jt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`;var Yt=class{constructor(e){this._remainder=null,this._chars=e?Jt:qt}decode(e,t){let n;if(this._remainder){let t=new Uint8Array(this._remainder.length+e.length);t.set(this._remainder),t.set(e,this._remainder.length),n=t}else n=e;if(t?.stream??!1){let e=n.length%3,t=n.length-e;return this._remainder=e>0?n.slice(t):null,t>0?this._encodeBytes(n,t):``}return this._remainder=null,n.length>0?this._encodeBytes(n,n.length):``}_encodeBytes(e,t){let n=this._chars,r=n===Jt,i=``,a=0;for(;a+2<t;a+=3){let t=e[a],r=e[a+1],o=e[a+2];i+=n[t>>>2]+n[(t&3)<<4|r>>>4]+n[(r&15)<<2|o>>>6]+n[o&63]}let o=t-a;if(o===1){let t=e[a];i+=n[t>>>2]+n[(t&3)<<4],r||(i+=`==`)}else if(o===2){let t=e[a],o=e[a+1];i+=n[t>>>2]+n[(t&3)<<4|o>>>4]+n[(o&15)<<2],r||(i+=`=`)}return i}},Xt=class{decode(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]&127);return t}};function Zt(e){let t=``;for(let n=0;n<e.length;n++)t+=Kt[e[n]];return t}function Qt(e,t){let n=t?Jt:qt,r=``,i=0;for(;i+2<e.length;i+=3){let t=e[i],a=e[i+1],o=e[i+2];r+=n[t>>>2]+n[(t&3)<<4|a>>>4]+n[(a&15)<<2|o>>>6]+n[o&63]}let a=e.length-i;if(a===1){let a=e[i];r+=n[a>>>2]+n[(a&3)<<4],t||(r+=`==`)}else if(a===2){let a=e[i],o=e[i+1];r+=n[a>>>2]+n[(a&3)<<4|o>>>4]+n[(o&15)<<2],t||(r+=`=`)}return r}function $t(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]&127);return t}function en(e,t){let n=Vt(t);switch(n){case`hex`:return Zt(e);case`base64`:return Qt(e,!1);case`base64url`:return Qt(e,!0);case`ascii`:return $t(e);default:return Ht(n).decode(e)}}function tn(e){return Rt.encode(e)}function nn(e,t){return Ht(t).decode(e)}function O(e,t){let n=e.length;if(n===0)return new Uint8Array;if(n===1){let t=e[0];return t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}if(t===void 0){let r=0;for(let t=0;t<n;t++)r+=e[t].length;t=r}let r=new Uint8Array(t),i=0;for(let t=0;t<n;t++){let n=e[t];r.set(n,i),i+=n.length}return r}function rn(e){if(e instanceof Uint8Array)return e;if(typeof e==`string`)return Rt.encode(e);if(e instanceof ArrayBuffer||Array.isArray(e))return new Uint8Array(e);throw TypeError(`Expected Uint8Array, got ${typeof e}`)}function an(e){let t=globalThis.Buffer;return t?t.from(e.buffer,e.byteOffset,e.byteLength):e}function on(e){let t=new Uint8Array(4);return t[0]=e&255,t[1]=e>>8&255,t[2]=e>>16&255,t[3]=e>>24&255,t}let sn={async hash(e,...t){let n=O(t),r=await crypto.subtle.digest(e,new Uint8Array(n));return new Uint8Array(r)},async convertPasswordToHash(e,t,n,r){let i=Lt(e),a=ut(n),o=await this.hash(t,a,i);for(let e=0;e<r;e++)o=await this.hash(t,o,on(e));return It(o)},randomBytes(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}};var cn=class{constructor(e){this.code=e}toString(){return`#${this.code}`}};let ln={sum:`Sum`,count:`Count`,average:`Average`,max:`Max`,min:`Min`,product:`Product`,countNums:`Count Numbers`,stdDev:`StdDev`,stdDevP:`StdDevP`,var:`Var`,varP:`VarP`},un=new Set(Object.keys(ln));function dn(e){let t=e.model;if(t.headerRow===!1)throw new x(`Cannot create pivot table from a table without headers. Set headerRow: true on the table.`);if(!t.rows||t.rows.length===0)throw new x(`Cannot create pivot table from an empty table. Add data rows to the table.`);let n=t.columns.map(e=>e.name),r=new Set;for(let e of n){if(r.has(e))throw new x(`Duplicate column name "${e}" found in table. Pivot tables require unique column names.`);r.add(e)}let i=[void 0,...n],a=t.rows.map(e=>[void 0,...e]),o=t.tl;if(!o)throw Error(`Table "${t.name}" is missing top-left cell address (tl)`);let s=o.row,c=o.col,l=s+t.rows.length,u=c+n.length-1,d=S.encode(s,c,l,u);return{name:e.worksheet.name,tableName:t.name,getRow(e){if(e===1)return{values:i};let t=e-2;return t>=0&&t<a.length?{values:a[t]}:{values:[]}},getColumn(e){if(e<1||e>n.length)return{values:[]};let r=[];r[1]=n[e-1];for(let n=0;n<t.rows.length;n++)r[n+2]=t.rows[n][e-1];return{values:r}},getSheetValues(){let e=[];e[1]=i;for(let t=0;t<a.length;t++)e[t+2]=a[t];return e},dimensions:{shortRange:d}}}function fn(e){if(e.sourceSheet&&e.sourceTable)throw new x(`Cannot specify both sourceSheet and sourceTable. Choose one.`);if(e.sourceTable)return dn(e.sourceTable);if(!e.sourceSheet)throw Error(`Either sourceSheet or sourceTable must be provided.`);return e.sourceSheet}function pn(e){return typeof e==`string`?e:e.name}function mn(e){return typeof e==`string`?void 0:e.metric}function hn(e,t){let n=fn(t);gn(t,n);let{rows:r}=t,i=t.columns??[],a=t.pages??[],o=t.values.map(pn),s=t.metric??`sum`,c=t.values.map(e=>mn(e)??s),l=vn(n,[...r,...i,...a],o),u={};for(let e=0;e<l.length;e++)u[l[e].name]=e;let d=(e,t)=>{let n=u[e];if(n===void 0)throw Error(`${t} field "${e}" not found in cache fields`);return n},f=r.map(e=>d(e,`Row`)),p=i.map(e=>d(e,`Column`)),m=o.map(e=>d(e,`Value`)),h=a.map(e=>d(e,`Page`)),g=e.workbook.pivotTables.map(e=>e.tableNumber).filter(e=>Number.isFinite(e)),_=g.length>0?g.reduce((e,t)=>e>t?e:t,-1/0)+1:1,v=e.workbook.pivotTables.map(e=>parseInt(e.cacheId,10)).filter(e=>Number.isFinite(e)),y=v.length>0?v.reduce((e,t)=>e>t?e:t,-1/0)+1:10+_-1;return{source:n,rows:f,columns:p,values:m,pages:h,metric:s,valueMetrics:c,cacheFields:l,cacheId:String(y),applyWidthHeightFormats:t.applyWidthHeightFormats??`1`,tableNumber:_}}function gn(e,t){let n=e.columns??[],r=e.pages??[],i=e.values.map(pn),a=t.getRow(1).values.slice(1);for(let e=0;e<a.length;e++){let n=a[e];if(n==null||n===``||typeof n==`string`&&n.trim()===``)throw Error(`Empty or missing header name at column ${e+1} in ${t.name}. Pivot tables require all columns to have non-empty headers.`)}let o=new Set;for(let e of a){let n=String(e);if(o.has(n))throw Error(`Duplicate header name "${n}" found in ${t.name}. Pivot tables require unique column names.`);o.add(n)}let s=new Set(a.map(String)),c=e=>{if(!s.has(e))throw new x(`The header name "${e}" was not found in ${t.name}.`)};for(let t of e.rows)c(t);for(let e of n)c(e);for(let e of i)c(e);for(let e of r)c(e);let l=new Map,u=[{name:`rows`,fields:e.rows},{name:`columns`,fields:n},{name:`pages`,fields:r}];for(let e of u)for(let t of e.fields){let n=l.get(t);if(n===e.name)throw Error(`Duplicate field "${t}" in ${e.name}. Each field can only appear once per axis area.`);if(n)throw Error(`Field "${t}" cannot appear in both ${n} and ${e.name}. Each field can only be assigned to one axis area.`);l.set(t,e.name)}if(!e.rows.length)throw new x(`No pivot table rows specified.`);if(e.values.length<1)throw new x(`Must have at least one value.`);if(e.metric!==void 0&&!un.has(e.metric))throw Error(`Invalid metric "${e.metric}". Must be one of: ${[...un].join(`, `)}.`);for(let t of e.values){let e=mn(t);if(e!==void 0&&!un.has(e))throw Error(`Invalid metric "${e}" on value field "${pn(t)}". Must be one of: ${[...un].join(`, `)}.`)}let d=new Set;for(let e of i){if(d.has(e))throw Error(`Duplicate value field "${e}". Each value field name must be unique.`);d.add(e)}}function _n(e){if(e==null)return null;if(typeof e!=`object`||e instanceof Date||e instanceof cn)return e;let t=e;if(typeof t.error==`string`){let e=t.error;return new cn(e.startsWith(`#`)?e.slice(1):e)}if(`formula`in t||`sharedFormula`in t){let e=t.result;return e==null?null:_n(e)}return Array.isArray(t.richText)?t.richText.map(e=>e.text??``).join(``):typeof t.text==`string`&&typeof t.hyperlink==`string`?t.text:typeof t.checkbox==`boolean`?t.checkbox:String(e)}function vn(e,t,n){let r=e.getRow(1).values,i=new Set(t),a=new Set(n),o=t=>{let n=e.getColumn(t).values,r=new Set,i=new Map,a=!1;for(let e=2;e<n.length;e++){let t=_n(n[e]);t===null||typeof t==`number`&&isNaN(t)?a=!0:t instanceof cn?i.has(t.code)||(i.set(t.code,t),r.add(t)):r.add(t)}let o=kt(r);return a&&o.push(null),o},s=t=>{let n=e.getColumn(t).values,r=1/0,i=-1/0,a=!1,o=!0;for(let e=2;e<n.length;e++){let t=_n(n[e]);typeof t==`number`&&!isNaN(t)&&(a=!0,t<r&&(r=t),t>i&&(i=t),Number.isInteger(t)||(o=!1))}return a?{minValue:r,maxValue:i,allInteger:o}:null},c=[];for(let e of Ot(1,r.length)){let t=r[e],n=String(t);if(i.has(n))c.push({name:n,sharedItems:o(e)});else if(a.has(n)){let t=s(e);c.push({name:n,sharedItems:null,containsNumber:t?`1`:void 0,minValue:t?.minValue,maxValue:t?.maxValue,containsInteger:t?.allInteger?`1`:void 0})}else c.push({name:n,sharedItems:null})}return c}function yn(e,t,n,r,i){let a=i(e,t)?.style?.border,o=r-t+1,s=n-e+1,c=Array(o),l=Array(o),u=Array(s),d=Array(s),f=!1;for(let o=t;o<=r;o++){let r=o-t,s=i(e,o)?.style?.border;c[r]=s?.top||a?.top,n===e?l[r]=s?.bottom||a?.bottom:l[r]=i(n,o)?.style?.border?.bottom||a?.bottom,(c[r]||l[r])&&(f=!0)}for(let o=e;o<=n;o++){let n=o-e,s=i(o,t)?.style?.border;u[n]=s?.left||a?.left,r===t?d[n]=s?.right||a?.right:d[n]=i(o,r)?.style?.border?.right||a?.right,(u[n]||d[n])&&(f=!0)}let p=a?.diagonal,m=a?.color;if(!(!f&&!p))return{topEdges:c,bottomEdges:l,leftEdges:u,rightEdges:d,diagonal:p,color:m}}function bn(e,t,n,r,i,a){let{topEdges:o,bottomEdges:s,leftEdges:c,rightEdges:l,diagonal:u,color:d}=i,f=a(e,t).style;for(let i=e;i<=n;i++)for(let p=t;p<=r;p++){let m=a(i,p),h=ze(f)||{},g={},_=!1;i===e&&o[p-t]&&(g.top=o[p-t],_=!0),i===n&&s[p-t]&&(g.bottom=s[p-t],_=!0),p===t&&c[i-e]&&(g.left=c[i-e],_=!0),p===r&&l[i-e]&&(g.right=l[i-e],_=!0),u&&(g.diagonal=u,_=!0),_?(d&&(g.color=d),h.border=g):delete h.border,m.style=h}}function xn(e,t){let n=Math.round(e).toString();for(;n.length<t;)n=`0`+n;return n}function Sn(e){if(e.length<=3)return e;let t=e.length%3,n=e.substring(0,t);for(let r=t;r<e.length;r+=3)n+=(n.length>0?`,`:``)+e.substring(r,r+3);return n}function Cn(e,t){let n=10**t;return Math.round(e*n)/n}function wn(e){let t=e.replace(/_./g,` `);return t=t.replace(/\*./g,``),t}function Tn(e){return/^General$/i.test(e.trim())}function En(e){let t=e.replace(/\[[^\]]*\]/g,``);return/[ymdhs]/i.test(t)&&!/^[#0.,E%$\s()\-+]+$/i.test(t)}let Dn=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],On=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],kn=[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],An=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],jn=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`];function Mn(e,t){let n=Math.round(e*86400)%86400,r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60,o=ft(e,!1),s=o.getUTCFullYear(),c=o.getUTCMonth(),l=o.getUTCDate(),u=o.getUTCDay(),d=e*86400-Math.floor(e*86400),f=/AM\/PM|A\/P/i.test(t),p=r>=12,m=r%12||12,h=t.replace(/\[(Red|Green|Blue|Yellow|Magenta|Cyan|White|Black|Color\d+)\]/gi,``);h=wn(h);let g=h.match(/ss\.(0+)/i),_=``;if(g){let e=g[1].length;_=Math.round(d*10**e).toString().padStart(e,`0`),h=h.replace(/ss\.0+/gi,`\0SF\0`)}h=h.replace(/yyyy/gi,`\0Y4\0`),h=h.replace(/yy/gi,`\0Y2\0`),h=h.replace(/mmmmm/gi,`\0MN5\0`),h=h.replace(/mmmm/gi,`\0MN4\0`),h=h.replace(/mmm/gi,`\0MN3\0`),h=h.replace(/dddd/gi,`\0DN4\0`),h=h.replace(/ddd/gi,`\0DN3\0`),h=h.replace(/dd/gi,`\0D2\0`),h=h.replace(/\bd\b/gi,`\0D1\0`),h=h.replace(/hh/gi,`\0H2\0`),h=h.replace(/\bh\b/gi,`\0H1\0`),h=h.replace(/ss/gi,`\0S2\0`),h=h.replace(/\bs\b/gi,`\0S1\0`),h=/\x00H[12]\x00.*mm|mm.*\x00S[12]\x00/i.test(h)?h.replace(/mm/gi,`\0MI2\0`):h.replace(/mm/gi,`\0M2\0`),h=h.replace(/\bm\b/gi,`\0M1\0`),h=h.replace(/AM\/PM/gi,`\0AMPM\0`),h=h.replace(/A\/P/gi,`\0AP\0`);let v=f?m:r;return h=h.replace(/\x00Y4\x00/g,s.toString()).replace(/\x00Y2\x00/g,(s%100).toString().padStart(2,`0`)).replace(/\x00MN5\x00/g,kn[c]).replace(/\x00MN4\x00/g,On[c]).replace(/\x00MN3\x00/g,Dn[c]).replace(/\x00M2\x00/g,(c+1).toString().padStart(2,`0`)).replace(/\x00M1\x00/g,(c+1).toString()).replace(/\x00DN4\x00/g,jn[u]).replace(/\x00DN3\x00/g,An[u]).replace(/\x00D2\x00/g,l.toString().padStart(2,`0`)).replace(/\x00D1\x00/g,l.toString()).replace(/\x00H2\x00/g,v.toString().padStart(2,`0`)).replace(/\x00H1\x00/g,v.toString()).replace(/\x00MI2\x00/g,i.toString().padStart(2,`0`)).replace(/\x00S2\x00/g,a.toString().padStart(2,`0`)).replace(/\x00S1\x00/g,a.toString()).replace(/\x00SF\x00/g,a.toString().padStart(2,`0`)+`.`+_).replace(/\x00AMPM\x00/g,p?`PM`:`AM`).replace(/\x00AP\x00/g,p?`P`:`A`),h=h.replace(/\\/g,``),h}function Nn(e){return typeof e==`boolean`?e?`TRUE`:`FALSE`:typeof e==`string`?e:Number.isInteger(e)?e.toString():e.toPrecision(11).replace(/\.?0+$/,``).replace(/\.?0+e/,`e`)}function Pn(e,t){let n=(t.match(/%/g)??[]).length;return zn(e*100**n,t.replace(/%/g,``)||`0`)+`%`.repeat(n)}function Fn(e,t){let n=e<0?`-`:``,r=Math.abs(e);if(r===0){let e=t.match(/\.([0#]+)E/i),n=e?e[1].length:2;return`0.`+`0`.repeat(n)+`E+00`}let i=t.match(/\.([0#]+)E/i),a=i?i[1].length:2,o=t.includes(`E+`),s=Math.floor(Math.log10(r)),c=Cn(r/10**s,a).toFixed(a),l=s>=0?o?`+`:``:`-`,u=xn(Math.abs(s),2);return n+c+`E`+l+u}function In(e,t){let n=e<0?-1:1,r=Math.abs(e),i=Math.floor(r);if(r-=i,r<1e-10)return[n*i,0,1];let a=0,o=1,s=1,c=0,l=Math.floor(r),u=l,d=1;for(;c<t&&(l=Math.floor(r),u=l*o+a,d=l*c+s,!(r-l<1e-10));)r=1/(r-l),a=o,o=u,s=c,c=d;return d>t&&(d=c,u=o),[n*i,n*u,d]}function Ln(e,t){let n=e<0?`-`:``,r=Math.abs(e),i=t.match(/\?+\s*\/\s*(\d+)/);if(i){let e=parseInt(i[1],10),a=Math.floor(r),o=r-a,s=Math.round(o*e);return t.includes(`#`)||t.includes(`0`)?s===0?n+a.toString():n+(a>0?a+` `:``)+s+`/`+e:n+(a*e+s)+`/`+e}let a=t.match(/\/\s*(\?+)/),[o,s,c]=In(r,10**(a?a[1].length:2)-1);return t.includes(`#`)&&o!==0?s===0?n+Math.abs(o).toString():n+Math.abs(o)+` `+Math.abs(s)+`/`+c:s===0?o===0?`0`:n+Math.abs(o).toString():n+(Math.abs(o)*c+Math.abs(s))+`/`+c}function Rn(e,t){let n=Math.round(e*86400),r=Math.floor(n/60),i=Math.floor(r/60),a=n%60,o=r%60,s=i,c=t;return/\[h+\]/i.test(c)&&(c=c.replace(/\[h+\]/gi,s.toString())),/\[m+\]/i.test(c)&&(c=c.replace(/\[m+\]/gi,r.toString())),/\[s+\]/i.test(c)&&(c=c.replace(/\[s+\]/gi,n.toString())),c=c.replace(/mm/gi,o.toString().padStart(2,`0`)),c=c.replace(/ss/gi,a.toString().padStart(2,`0`)),c}function zn(e,t){let n=Math.abs(e),r=e<0?`-`:``,i=0,a=t;for(;a.endsWith(`,`);)i++,a=a.slice(0,-1);let o=n/1e3**i,s=a.indexOf(`.`),c=a,l=``;s!==-1&&(c=a.substring(0,s),l=a.substring(s+1));let u=l.replace(/[^0#?]/g,``).length,[d,f=``]=Cn(o,u).toString().split(`.`),p=/[0#?][^0#?,.\s][0#?]/.test(c),m;if(p){let e=c.replace(/[^0#?]/g,``).length,t=d;t.length<e&&(t=`0`.repeat(e-t.length)+t),m=``;let n=t.length-e;for(let e=0;e<c.length;e++){let r=c[e];r===`0`||r===`#`||r===`?`?n<t.length&&(m+=t[n],n++):r!==`,`&&(m+=r)}}else{m=d,c.includes(`,`)&&(m=Sn(d));let e=(c.match(/0/g)??[]).length;m.length<e&&(m=`0`.repeat(e-m.length)+m)}let h=``;return u>0&&(h=`.`+(f+`0`.repeat(u)).substring(0,u)),r+m+h}function Bn(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`"`){for(n++;n<e.length&&e[n]!==`"`;)t+=e[n],n++;n++}else e[n]===`\\`&&n+1<e.length?(n++,t+=e[n],n++):(t+=e[n],n++);return t}function Vn(e,t){let n=t.match(/\[(=|>|<|>=|<=|<>)(-?\d+(?:\.\d*)?)\]/);if(!n)return!1;let r=n[1],i=parseFloat(n[2]);switch(r){case`=`:return e===i;case`>`:return e>i;case`<`:return e<i;case`>=`:return e>=i;case`<=`:return e<=i;case`<>`:return e!==i;default:return!1}}function Hn(e,t){if(typeof t==`string`){let n=wt(e);return n.length>=4&&n[3]?Bn(n[3]).replace(/@/g,t):t}if(typeof t==`boolean`)return t?`TRUE`:`FALSE`;let n=wt(e),r=/\[(=|>|<|>=|<=|<>)-?\d+(?:\.\d*)?\]/;if((n[0]&&r.test(n[0])||n[1]&&r.test(n[1]))&&n.length>=2){for(let e=0;e<Math.min(n.length,2);e++){let r=n[e].match(/\[(=|>|<|>=|<=|<>)-?\d+(?:\.\d*)?\]/);if(r&&Vn(t,r[0]))return n[e]}return n[n.length>2?2:1]}return n.length===1?n[0]:n.length===2?t>=0?n[0]:n[1]:t>0?n[0]:t<0?n[1]:n[2]||n[0]}function Un(e,t){let n=wt(e);return n.length>=2&&n[1]===t}function Wn(e,t){if(t==null)return``;if(Tn(e))return Nn(t);if(typeof t==`string`)return Hn(e,t);if(typeof t==`boolean`)return t?`TRUE`:`FALSE`;let n=t,r=Hn(e,n);n<0&&Un(e,r)&&(n=Math.abs(n));let i=r.replace(/\[(Red|Green|Blue|Yellow|Magenta|Cyan|White|Black|Color\d+)\]/gi,``);if(i=i.replace(/\[(>|<|>=|<=|=|<>)-?\d+(\.\d+)?\]/g,``),i=i.replace(/\[\$[^\]]*\]/g,``),i=wn(i),i=Bn(i),/\[[hms]+\]/i.test(i))return Rn(n,i);if(En(i))return Mn(n,i);if(i.includes(`%`))return Pn(n,i);if(/E[+-]?/i.test(i))return Fn(n,i);if(/\?+\s*\/\s*[\d?]+/.test(i))return Ln(n,i);if(i.includes(`(`)&&i.includes(`)`)&&n<0){let e=i.replace(/\(|\)/g,``);return`(`+zn(-n,e)+`)`}if(i===`@`)return n.toString();let a=``,o=``,s=i.match(/^([^#0?.,]+)/);s&&(a=s[1],i=i.substring(s[0].length));let c=i.match(/([^#0?.,]+)$/);c&&!c[1].includes(`%`)&&(o=c[1],i=i.substring(0,i.length-c[0].length));let l=zn(n,i);return a+l+o}function Gn(e){let t=e.replace(/"[^"]*"/g,``);if(/\[[hms]\]/i.test(t))return!1;let n=t.replace(/\[[^\]]*\]/g,``),r=/[hs]/i.test(n)||/AM\/PM|A\/P/i.test(n);return/[yd]/i.test(n)||/m/i.test(n)&&!r?!1:r}function Kn(e){let t=e.replace(/"[^"]*"/g,``);if(/\[[hms]\]/i.test(t))return!1;let n=t.replace(/\[[^\]]*\]/g,``);return!!(/[yd]/i.test(n)||/m/i.test(n)&&!(/[hs]/i.test(n)||/AM\/PM|A\/P/i.test(n)))}function qn(e,t,n){if(e instanceof Date){let r=dt(e);return Gn(t)?(r%=1,r<0&&(r+=1),Wn(t,r)):Wn(n&&Kn(t)?n:t,r)}return Wn(t,e)}function Jn(e){return S.l2n(e.toUpperCase())-1}function Yn(e){return S.n2l(e+1)}function Xn(e){return parseInt(e,10)-1}function Zn(e){return String(e+1)}function Qn(e){let t=S.decodeAddress(e.toUpperCase());return{c:t.col-1,r:t.row-1}}function $n(e){return S.encodeAddress(e.r+1,e.c+1)}function er(e){let t=e.indexOf(`:`);if(t===-1){let t=Qn(e);return{s:t,e:{...t}}}return{s:Qn(e.slice(0,t)),e:Qn(e.slice(t+1))}}function tr(e,t){if(t===void 0){let t=e;return tr(t.s,t.e)}let n=$n(e),r=$n(t);return n===r?n:`${n}:${r}`}var nr=class{constructor(e){this._workbook=e.workbook,this.id=e.id??0,this.orderNo=e.orderNo??0,this.name=e.name||`sheet${this.id}`,this.state=e.state??`visible`,this._rows=[],this._columns=[],this._keys={},this._merges={},this.rowBreaks=[],this.colBreaks=[],this.properties={defaultRowHeight:15,outlineLevelCol:0,outlineLevelRow:0,...e.properties},this.pageSetup={margins:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},orientation:`portrait`,horizontalDpi:void 0,verticalDpi:void 0,fitToPage:!!(e.pageSetup&&(e.pageSetup.fitToWidth||e.pageSetup.fitToHeight)&&!e.pageSetup.scale),pageOrder:`downThenOver`,blackAndWhite:!1,draft:!1,cellComments:`None`,errors:`displayed`,scale:100,fitToWidth:1,fitToHeight:1,paperSize:void 0,showRowColHeaders:!1,showGridLines:!1,firstPageNumber:void 0,horizontalCentered:!1,verticalCentered:!1,rowBreaks:null,colBreaks:null,...e.pageSetup},this.headerFooter={differentFirst:!1,differentOddEven:!1,oddHeader:null,oddFooter:null,evenHeader:null,evenFooter:null,firstHeader:null,firstFooter:null,...e.headerFooter},this.dataValidations=new tt,this.views=e.views??[],this.autoFilter=e.autoFilter??null,this._media=[],this.sheetProtection=null,this.tables={},this.pivotTables=[],this.conditionalFormattings=[],this.formControls=[]}get name(){return this._name}set name(e){if(e===void 0&&(e=`sheet${this.id}`),this._name!==e){if(typeof e!=`string`)throw new d(`The name has to be a string.`);if(e===``)throw new d(`The name can't be empty.`);if(e===`History`)throw new d(`The name "History" is protected. Please use a different name.`);if(/[*?:/\\[\]]/.test(e))throw new d(`Worksheet name ${e} cannot include any of the following characters: * ? : \\ / [ ]`);if(/(^')|('$)/.test(e))throw new d(`The first or last character of worksheet name cannot be a single quotation mark: ${e}`);if(e&&e.length>31&&(e=e.substring(0,31)),this._workbook.worksheets.find(t=>t&&t.name.toLowerCase()===e.toLowerCase()))throw new d(`Worksheet name already exists: ${e}`);this._name=e}}get workbook(){return this._workbook}destroy(){this._workbook.removeWorksheetEx(this)}get dimensions(){let e=new C;return this._rows.forEach(t=>{if(t){let n=t.dimensions;n&&e.expand(t.number,n.min,t.number,n.max)}}),e}get columns(){return this._columns}set columns(e){this._headerRowCount=e.reduce((e,t)=>{let n=Array.isArray(t.header)?t.header.length:t.header?1:0;return Math.max(e,n)},0);let t=1,n=this._columns=[];e.forEach(e=>{let r=new Ve(this,t++,!1);n.push(r),r.defn=e})}getColumnKey(e){return this._keys[e]}setColumnKey(e,t){this._keys[e]=t}deleteColumnKey(e){delete this._keys[e]}eachColumnKey(e){Object.keys(this._keys).forEach(t=>e(this._keys[t],t))}getColumn(e){let t;if(typeof e==`string`){let n=this._keys[e];if(n)return n;t=S.l2n(e)}else t=e;if(t>this._columns.length){let e=this._columns.length+1;for(;e<=t;)this._columns.push(new Ve(this,e++))}return this._columns[t-1]}spliceColumns(e,t,...n){for(let e of Object.values(this._merges))for(let t=e.top;t<=e.bottom;t++)for(let n=e.left;n<=e.right;n++){let e=this.findCell(t,n);e&&e.type===w.ValueType.Merge&&e.unmerge()}let r=this._rows.length;if(n.length>0)for(let i=0;i<r;i++){let r=n.map(e=>e[i]??null);this.getRow(i+1).splice(e,t,...r)}else this._rows.forEach(n=>{n&&n.splice(e,t)});let i=n.length-t,a=e+t,o=this._columns.length;if(i<0)for(let t=e+n.length;t<=o;t++)this.getColumn(t).defn=this.getColumn(t-i).defn;else if(i>0)for(let e=o;e>=a;e--)this.getColumn(e+i).defn=this.getColumn(e).defn;for(let t=e;t<e+n.length;t++)this.getColumn(t).defn=void 0;if(this.workbook.definedNames.spliceColumns(this.name,e,t,n.length),i!==0){for(let t of this._media)if(t.type===`image`&&t.range){let{tl:n,br:r}=t.range;n&&n.nativeCol>=e-1&&(n.nativeCol=Math.max(0,n.nativeCol+i)),r&&r.nativeCol>=e-1&&(r.nativeCol=Math.max(0,r.nativeCol+i))}}this._spliceMerges(`col`,e,t,n.length)}get lastColumn(){return this.getColumn(this.columnCount)}get columnCount(){let e=0;return this.eachRow(t=>{e=Math.max(e,t.cellCount)}),e}get actualColumnCount(){let e=[],t=0;return this.eachRow(n=>{n.eachCell(({col:n})=>{e[n]||(e[n]=!0,t++)})}),t}_commitRow(e){}get _lastRowNumber(){let e=this._rows,t=e.length;for(;t>0&&e[t-1]===void 0;)t--;return t}get _nextRow(){return this._lastRowNumber+1}get lastRow(){if(this._rows.length)return this._rows[this._rows.length-1]}findRow(e){return this._rows[e-1]}findRows(e,t){return this._rows.slice(e-1,e-1+t)}get rowCount(){return this._lastRowNumber}get actualRowCount(){let e=0;return this.eachRow(()=>{e++}),e}getRow(e){let t=this._rows[e-1];return t||=this._rows[e-1]=new Be(this,e),t}getRows(e,t){if(t<1)return;let n=[];for(let r=e;r<e+t;r++)n.push(this.getRow(r));return n}addRow(e,t=`n`){let n=this._nextRow,r=this.getRow(n);return r.values=e,this._setStyleOption(n,t[0]===`i`?t:`n`),r}addRows(e,t=`n`){let n=[];return e.forEach(e=>{n.push(this.addRow(e,t))}),n}insertRow(e,t,n=`n`){return this.spliceRows(e,0,t),this._setStyleOption(e,n),this.getRow(e)}insertRows(e,t,n=`n`){if(this.spliceRows(e,0,...t),n!==`n`)for(let r=0;r<t.length;r++)n[0]===`o`&&this.findRow(t.length+e+r)!==void 0?this._copyStyle(t.length+e+r,e+r,n[1]===`+`):n[0]===`i`&&this.findRow(e-1)!==void 0&&this._copyStyle(e-1,e+r,n[1]===`+`);return this.getRows(e,t.length)}_setStyleOption(e,t=`n`){t[0]===`o`&&this.findRow(e+1)!==void 0?this._copyStyle(e+1,e,t[1]===`+`):t[0]===`i`&&this.findRow(e-1)!==void 0&&this._copyStyle(e-1,e,t[1]===`+`)}_copyStyle(e,t,n=!1){let r=this.getRow(e),i=this.getRow(t);i.style=ze(r.style)??{},r.eachCell({includeEmpty:n},(e,t)=>{i.getCell(t).style=ze(e.style)??{}}),i.height=r.height}duplicateRow(e,t,n=!1){let r=this._rows[e-1],i=Array.from({length:t}).fill(r.values),a=[];for(let t of Object.values(this._merges))t.top===e&&t.bottom===e&&a.push(t);let o=[],s=e-1;for(let e of this._media)e.type===`image`&&e.range&&e.range.tl.nativeRow===s&&o.push(e);this.spliceRows(e+1,n?0:t,...i);for(let n=0;n<t;n++){let t=this._rows[e+n];t.style=ze(r.style)??{},t.height=r.height,r.eachCell({includeEmpty:!0},(e,n)=>{t.getCell(n).style=ze(e.style)??{}})}if(a.length>0)for(let r=0;r<t;r++){let t=e+1+r;if(!n){let e=[];for(let[n,r]of Object.entries(this._merges))r.top<=t&&r.bottom>=t&&e.push(n);for(let t of e)this._unMergeMaster(this.getCell(t))}for(let e of a)this.mergeCellsWithoutStyle(t,e.left,t,e.right)}if(!n){let n=e,r=e+t-1;this._media=this._media.filter(e=>{if(e.type===`image`&&e.range){let t=e.range.tl.nativeRow;return t<n||t>r}return!0})}for(let e=0;e<t;e++){let t=e+1;for(let e of o){let n=e.clone();if(n.range.tl.nativeRow=s+t,n.range.br){let r=e.range.br.nativeRow-s;n.range.br.nativeRow=s+t+r}this._media.push(n)}}}spliceRows(e,t,...n){for(let e of Object.values(this._merges))for(let t=e.top;t<=e.bottom;t++)for(let n=e.left;n<=e.right;n++){let e=this.findCell(t,n);e&&e.type===w.ValueType.Merge&&e.unmerge()}let r=e+t,i=n.length,a=i-t,o=this._rows.length,s,c;if(a<0)for(e===o&&(this._rows[o-1]=void 0),s=r;s<=o;s++)if(c=this._rows[s-1],c){let e=this.getRow(s+a);e.values=c.values,e.style=ze(c.style)??{},e.height=c.height,c.eachCell({includeEmpty:!0},(t,n)=>{e.getCell(n).style=ze(t.style)??{}}),this._rows[s-1]=void 0}else this._rows[s+a-1]=void 0;else if(a>0)for(s=o;s>=r;s--)if(c=this._rows[s-1],c){let e=this.getRow(s+a);e.values=c.values,e.style=ze(c.style)??{},e.height=c.height,c.eachCell({includeEmpty:!0},(t,n)=>{e.getCell(n).style=ze(t.style)??{}})}else this._rows[s+a-1]=void 0;for(s=0;s<i;s++){let t=this.getRow(e+s);t.style={},t.values=n[s]}if(this.workbook.definedNames.spliceRows(this.name,e,t,i),a!==0){for(let t of this._media)if(t.type===`image`&&t.range){let{tl:n,br:r}=t.range;n&&n.nativeRow>=e-1&&(n.nativeRow=Math.max(0,n.nativeRow+a)),r&&r.nativeRow>=e-1&&(r.nativeRow=Math.max(0,r.nativeRow+a))}}this._spliceMerges(`row`,e,t,i)}eachRow(e,t){let n,r;if(typeof e==`function`?r=e:(n=e,r=t),n&&n.includeEmpty){let e=this._rows.length;for(let t=1;t<=e;t++)r(this.getRow(t),t)}else this._rows.forEach(e=>{e&&e.hasValues&&r(e,e.number)})}getSheetValues(){let e=[];return this._rows.forEach(t=>{t&&(e[t.number]=t.values)}),e}findCell(e,t){let n=S.getAddress(e,t),r=this._rows[n.row-1];return r?r.findCell(n.col):void 0}getCell(e,t){let n=S.getAddress(e,t);return this.getRow(n.row).getCellEx(n)}mergeCells(...e){let t=new C(e);this._mergeCellsInternal(t)}mergeCellsWithoutStyle(...e){let t=new C(e);this._mergeCellsInternal(t,!0)}_mergeCellsInternal(e,t){Object.values(this._merges).forEach(t=>{if(t.intersects(e))throw new h});let{top:n,left:r,bottom:i,right:a}=e,o=t?void 0:yn(n,r,i,a,(e,t)=>this.findCell(e,t)),s=this.getCell(e.top,e.left);for(let e=n;e<=i;e++)for(let i=r;i<=a;i++)(e>n||i>r)&&this.getCell(e,i).merge(s,t);o&&bn(n,r,i,a,o,(e,t)=>this.getCell(e,t)),this._merges[s.address]=e}_unMergeMaster(e){let t=this._merges[e.address];if(t){for(let e=t.top;e<=t.bottom;e++)for(let n=t.left;n<=t.right;n++)this.getCell(e,n).unmerge();delete this._merges[e.address]}}_spliceMerges(e,t,n,r){let i=r-n;if(i===0&&n===0)return;let a=t+n,o=e===`row`,s={};for(let e of Object.values(this._merges)){let{top:r,left:c,bottom:l,right:u}=e.model,d=o?r:c,f=o?l:u;if(i<=0&&n>0){let n=a-1;if(d>n){let e=o?new C(r+i,c,l+i,u):new C(r,c+i,l,u+i);s[S.encodeAddress(e.top,e.left)]=e}else if(f<t)s[S.encodeAddress(r,c)]=e;else if(!(d>=t&&f<=n)){let e=r,n=c,a=l,d=u;o?(e=r<t?r:t,a=Math.max(e,l+i)):(n=c<t?c:t,d=Math.max(n,u+i));let f=new C(e,n,a,d);e===a&&n===d||(s[S.encodeAddress(f.top,f.left)]=f)}}else if(d>=a){let e=o?new C(r+i,c,l+i,u):new C(r,c+i,l,u+i);s[S.encodeAddress(e.top,e.left)]=e}else f<a||(o?e.model.bottom=l+i:e.model.right=u+i),s[S.encodeAddress(r,c)]=e}this._merges=s;for(let e of Object.values(s)){let t=this.getCell(e.top,e.left);for(let n=e.top;n<=e.bottom;n++)for(let r=e.left;r<=e.right;r++)(n>e.top||r>e.left)&&this.getCell(n,r).merge(t,!0)}}get hasMerges(){return Object.values(this._merges).some(Boolean)}unMergeCells(...e){let t=new C(e);for(let e=t.top;e<=t.bottom;e++)for(let n=t.left;n<=t.right;n++){let t=this.findCell(e,n);t&&(t.type===w.ValueType.Merge?this._unMergeMaster(t.master):this._merges[t.address]&&this._unMergeMaster(t))}}fillFormula(e,t,n,r=`shared`){let{top:i,left:a,bottom:o,right:s}=S.decode(e),c=s-a+1,l=S.encodeAddress(i,a),u=r===`shared`,d;d=typeof n==`function`?n:Array.isArray(n)?Array.isArray(n[0])?(e,t)=>n[e-i][t-a]:(e,t)=>n[(e-i)*c+(t-a)]:()=>void 0;let f=!0;for(let n=i;n<=o;n++)for(let i=a;i<=s;i++)if(f){let a=this.getCell(n,i);a.value={shareType:r,formula:t,ref:e,result:d(n,i)},f=!1}else this.getCell(n,i).value=u?{sharedFormula:l,result:d(n,i)}:d(n,i)}addImage(e,t){let n={type:`image`,imageId:String(e),range:t};this._media.push(new Ge(this,n))}getImages(){return this._media.filter(e=>e.type===`image`)}addBackgroundImage(e){let t={type:`background`,imageId:String(e)};this._media.push(new Ge(this,t))}getBackgroundImageId(){let e=this._media.find(e=>e.type===`background`);return e&&e.imageId}addFormCheckbox(e,t){let n=new ct(this,e,t);return this.formControls.push(n),n}getFormCheckboxes(){return this.formControls}async protect(e,t){this.sheetProtection={sheet:!0},t&&`spinCount`in t&&(t.spinCount=Number.isFinite(t.spinCount)?Math.round(Math.max(0,t.spinCount)):1e5),e&&(this.sheetProtection.algorithmName=`SHA-512`,this.sheetProtection.saltValue=It(sn.randomBytes(16)),this.sheetProtection.spinCount=t&&`spinCount`in t?t.spinCount:1e5,this.sheetProtection.hashValue=await sn.convertPasswordToHash(e,`SHA-512`,this.sheetProtection.saltValue,this.sheetProtection.spinCount)),t&&(this.sheetProtection=Object.assign(this.sheetProtection,t),!e&&`spinCount`in t&&delete this.sheetProtection.spinCount)}unprotect(){this.sheetProtection=null}addTable(e){let t=new et(this,e);return this.tables[t.name]=t,t}getTable(e){return this.tables[e]}removeTable(e){delete this.tables[e]}getTables(){return Object.values(this.tables)}addPivotTable(e){let t=hn(this,e);return this.pivotTables.push(t),this.workbook.pivotTables.push(t),t}addConditionalFormatting(e){this.conditionalFormattings.push(e)}removeConditionalFormatting(e){typeof e==`number`?this.conditionalFormattings.splice(e,1):e instanceof Function?this.conditionalFormattings=this.conditionalFormattings.filter(e):this.conditionalFormattings=[]}get model(){let e={id:this.id,name:this.name,dataValidations:this.dataValidations.model,properties:this.properties,state:this.state,pageSetup:this.pageSetup,headerFooter:this.headerFooter,rowBreaks:this.rowBreaks,colBreaks:this.colBreaks,views:this.views,autoFilter:this.autoFilter,media:this._media.map(e=>e.model),sheetProtection:this.sheetProtection,tables:Object.values(this.tables).map(e=>e.model),pivotTables:this.pivotTables,conditionalFormattings:this.conditionalFormattings,formControls:this.formControls.map(e=>e.model),drawing:this._drawing};e.cols=Ve.toModel(this.columns);let t=e.rows=[],n=e.dimensions=new C;return this._rows.forEach(e=>{let r=e&&e.model;r&&(n.expand(r.number,r.min,r.number,r.max),t.push(r))}),e.mergeCells=Object.values(this._merges).map(e=>e.range),e}_parseRows(e){this._rows=[],e.rows&&e.rows.forEach(e=>{let t=new Be(this,e.number);this._rows[t.number-1]=t,t.model=e})}_parseMergeCells(e){e.mergeCells&&e.mergeCells.forEach(e=>{this.mergeCellsWithoutStyle(e)})}set model(e){this.name=e.name,this.state=e.state,this._columns=Ve.fromModel(this,e.cols??[]),this._parseRows(e),this._parseMergeCells(e),this.dataValidations=new tt(e.dataValidations),this.properties=e.properties,this.pageSetup=e.pageSetup,this.headerFooter=e.headerFooter,this.rowBreaks=e.rowBreaks??[],this.colBreaks=e.colBreaks??[],this.views=e.views,this.autoFilter=e.autoFilter,this._media=e.media.map(e=>new Ge(this,e)),this.sheetProtection=e.sheetProtection,this.tables=e.tables.reduce((e,t)=>{let n=new et(this,t);return n.model=t,e[t.name]=n,e},{}),this.pivotTables=e.pivotTables,this.conditionalFormattings=e.conditionalFormattings,this.formControls=[],this._drawing=e.drawing}toJSON(e){let t=e||{},n=1,r=this.rowCount,i=1,a=this.columnCount;if(t.range!==void 0){if(typeof t.range==`number`)n=t.range+1;else if(typeof t.range==`string`){let e=er(t.range);n=e.s.r+1,r=e.e.r+1,i=e.s.c+1,a=e.e.c+1}}if(r<n||a<i)return[];let o=t.header;if(o===1){let e=[],o=t.blankRows!==!1;for(let s=n;s<=r;s++){let n=[],r=!0;for(let e=i;e<=a;e++){let a=this.getCell(s,e),o=t.raw===!1?ir(a,t.dateFormat).trim():a.value;o!=null&&o!==``?(n[e-i]=o,r=!1):t.defaultValue===void 0?n[e-i]=null:n[e-i]=t.defaultValue}(!r||o)&&e.push(n)}return e}if(o===`A`){let e=[],o=t.blankRows===!0;for(let s=n;s<=r;s++){let n={},r=!0;for(let e=i;e<=a;e++){let i=this.getCell(s,e),a=t.raw===!1?ir(i,t.dateFormat).trim():i.value,o=Yn(e-1);a!=null&&a!==``?(n[o]=a,r=!1):t.defaultValue!==void 0&&(n[o]=t.defaultValue)}(!r||o)&&e.push(n)}return e}if(Array.isArray(o)){let e=[],s=t.blankRows===!0;for(let c=n;c<=r;c++){let n={},r=!0;for(let e=i;e<=a;e++){let a=e-i,s=o[a]??`__EMPTY_${a}`,l=this.getCell(c,e),u=t.raw===!1?ir(l,t.dateFormat).trim():l.value;u!=null&&u!==``?(n[s]=u,r=!1):t.defaultValue!==void 0&&(n[s]=t.defaultValue)}(!r||s)&&e.push(n)}return e}let s=[],c={};for(let e=i;e<=a;e++){let t=this.getCell(n,e).value,r=t==null?`__EMPTY_${e-i}`:String(t);c[r]===void 0?c[r]=0:(c[r]++,r=`${r}_${c[r]}`),s.push(r)}let l=[],u=n+1,d=t.blankRows===!0;for(let e=u;e<=r;e++){let n={},r=!0;for(let o=i;o<=a;o++){let a=this.getCell(e,o),c=t.raw===!1?ir(a,t.dateFormat).trim():a.value,l=s[o-i];c!=null&&c!==``?(n[l]=c,r=!1):t.defaultValue!==void 0&&(n[l]=t.defaultValue)}(!r||d)&&l.push(n)}return l}addJSON(e,t){if(e.length===0)return this;let n=t||{},r=1,i=1;if(n.origin!==void 0){let e=rr(n.origin,this.rowCount);r=e.row,i=e.col}let a=new Set;e.forEach(e=>Object.keys(e).forEach(e=>a.add(e)));let o=n.header?[...n.header]:[...a];n.header&&a.forEach(e=>{o.includes(e)||o.push(e)});let s=r;n.skipHeader||(o.forEach((e,t)=>{this.getCell(s,i+t).value=e}),s++);for(let t of e)o.forEach((e,r)=>{let a=t[e];a===null&&n.nullError?this.getCell(s,i+r).value={error:`#NULL!`}:a!=null&&(this.getCell(s,i+r).value=a)}),s++;return this}toAOA(){let e=[];return this.eachRow({includeEmpty:!0},(t,n)=>{let r=[];t.eachCell({includeEmpty:!0},(e,t)=>{r[t-1]=e.value}),e[n-1]=r}),e}addAOA(e,t){if(e.length===0)return this;let n=1,r=1;if(t?.origin!==void 0){let e=rr(t.origin,this.rowCount);n=e.row,r=e.col}return e.forEach((e,t)=>{e&&e.forEach((e,i)=>{e!=null&&(this.getCell(n+t,r+i).value=e)})}),this}};function rr(e,t){if(typeof e==`string`){let t=Qn(e);return{row:t.r+1,col:t.c+1}}return typeof e==`number`?e===-1?{row:t+1,col:1}:{row:e+1,col:1}:{row:e.r+1,col:e.c+1}}function ir(e,t){let n=e.value,r=e.numFmt,i=typeof r==`string`?r:r?.formatCode??`General`;if(n==null)return``;if(n instanceof Date||typeof n==`number`||typeof n==`boolean`||typeof n==`string`)return qn(n,i,t);if(typeof n==`object`&&`formula`in n){let e=n.result;if(e==null)return``;if(e instanceof Date||typeof e==`number`||typeof e==`boolean`||typeof e==`string`)return qn(e,i,t)}return e.text}function ar(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>ar(e));let t={};for(let n of Object.keys(e))n!==`__proto__`&&n!==`constructor`&&n!==`prototype`&&(t[n]=ar(e[n]));return t}var or=class{constructor(e){this.template=e,this.sheets=new Map}addCell(e){this.addCellEx(S.decodeEx(e))}getCell(e){return this.findCellEx(S.decodeEx(e),!0)}findCell(e){return this.findCellEx(S.decodeEx(e),!1)}findCellAt(e,t,n){let r=this.sheets.get(e),i=r&&r[t];return i&&i[n]}addCellEx(e){if(e.top!==void 0)for(let t=e.top;t<=e.bottom;t++)for(let n=e.left;n<=e.right;n++)this.getCellAt(e.sheetName,t,n);else this.findCellEx(e,!0)}getCellEx(e){return this.findCellEx(e,!0)}findCellEx(e,t){let n=this.findSheet(e,t),r=this.findSheetRow(n,e,t);return this.findRowCell(r,e,t)}getCellAt(e,t,n){let r=this.sheets.get(e);r||(r=[],this.sheets.set(e,r));let i=t>>>0,a=n>>>0,o=r[i]||(r[i]=[]);return o[a]||(o[a]={sheetName:e,address:S.n2l(n)+t,row:t,col:n})}removeCellEx(e){let t=this.findSheet(e,!1);if(!t)return;let n=this.findSheetRow(t,e,!1);n&&delete n[e.col>>>0]}forEachInSheet(e,t){let n=this.sheets.get(e);n&&n.forEach((e,n)=>{e&&e.forEach((e,r)=>{e&&t(e,n,r)})})}forEach(e){for(let t of this.sheets.keys())this.forEachInSheet(t,e)}map(e){let t=[];return this.forEach(n=>{t.push(e(n))}),t}findSheet(e,t){let n=e.sheetName;if(this.sheets.has(n))return this.sheets.get(n);if(t){let e=[];return this.sheets.set(n,e),e}}findSheetRow(e,t,n){let r=t.row>>>0;if(e&&e[r])return e[r];if(n)return e[r]=[]}findRowCell(e,t,n){let r=t.col>>>0;if(e&&e[r])return e[r];if(n)return e[r]=this.template?{...t,...ar(this.template)}:t}spliceRows(e,t,n,r){let i=this.sheets.get(e);if(i){let e=[];for(let t=0;t<r;t++)e.push([]);i.splice(t,n,...e)}}spliceColumns(e,t,n,r){let i=this.sheets.get(e);if(i){let e=[];for(let t=0;t<r;t++)e.push(null);i.forEach(r=>{r.splice(t,n,...e)})}}};let sr=/[$](\w+)[$](\d+)(:[$](\w+)[$](\d+))?/;var cr=class{constructor(){this.matrixMap={}}getMatrix(e){return this.matrixMap[e]||(this.matrixMap[e]=new or)}add(e,t){let n=S.decodeEx(e);`error`in n||this.addEx(n,t)}addEx(e,t){let n=this.getMatrix(t);if(`top`in e)for(let t=e.left;t<=e.right;t++)for(let r=e.top;r<=e.bottom;r++){let i={sheetName:e.sheetName,address:S.n2l(t)+r,row:r,col:t};n.addCellEx(i)}else n.addCellEx(e)}remove(e,t){let n=S.decodeEx(e);`error`in n||this.removeEx(n,t)}removeEx(e,t){let n=this.getMatrix(t);if(`top`in e)for(let t=e.left;t<=e.right;t++)for(let r=e.top;r<=e.bottom;r++)n.removeCellEx({sheetName:e.sheetName,address:S.n2l(t)+r,row:r,col:t});else n.removeCellEx(e)}removeAllNames(e){Object.values(this.matrixMap).forEach(t=>{if(`top`in e)for(let n=e.left;n<=e.right;n++)for(let r=e.top;r<=e.bottom;r++)t.removeCellEx({sheetName:e.sheetName,address:S.n2l(n)+r,row:r,col:n});else t.removeCellEx(e)})}forEach(e){Object.entries(this.matrixMap).forEach(([t,n])=>{n.forEach(n=>{e(t,n)})})}getNames(e){let t=S.decodeEx(e);return`error`in t||`top`in t?[]:this.getNamesEx(t)}getNamesEx(e){return Object.entries(this.matrixMap).map(([t,n])=>n.findCellEx(e,!1)&&t).filter(e=>!!e)}_explore(e,t){t.mark=!1;let n=t.sheetName,r=new C(t.row,t.col,t.row,t.col,n),i,a,o=(t,r)=>e.findCellAt(n,t,r);function s(e,n){let i=o(e,t.col);return!i||!i.mark?!1:(r[n]=e,i.mark=!1,!0)}for(a=t.row-1;s(a,`top`);a--);for(a=t.row+1;s(a,`bottom`);a++);function c(e,t){let n=[];for(a=r.top;a<=r.bottom;a++){let t=o(a,e);if(t&&t.mark)n.push(t);else return!1}r[t]=e;for(let e=0;e<n.length;e++)n[e].mark=!1;return!0}for(i=t.col-1;c(i,`left`);i--);for(i=t.col+1;c(i,`right`);i++);return r}getRanges(e,t){return t||=this.matrixMap[e],t?(t.forEach(e=>{e.mark=!0}),{name:e,ranges:t.map(e=>e.mark&&this._explore(t,e)).filter(e=>!!e).map(e=>e.$shortRange)}):{name:e,ranges:[]}}normaliseMatrix(e,t){e.forEachInSheet(t,(e,t,n)=>{e&&(e.row!==t||e.col!==n)&&(e.row=t,e.col=n,e.address=S.n2l(n)+t)})}spliceRows(e,t,n,r){Object.values(this.matrixMap).forEach(i=>{i.spliceRows(e,t,n,r),this.normaliseMatrix(i,e)})}spliceColumns(e,t,n,r){Object.values(this.matrixMap).forEach(i=>{i.spliceColumns(e,t,n,r),this.normaliseMatrix(i,e)})}get model(){return Object.entries(this.matrixMap).map(([e,t])=>this.getRanges(e,t)).filter(e=>e.ranges.length)}set model(e){let t=this.matrixMap={};e.forEach(e=>{let n=t[e.name]=new or;e.ranges.forEach(e=>{sr.test(e.split(`!`).pop()??``)&&n.addCell(e)})})}};let lr=1e4;function ur(e,t,n){e.push(` ${t}="${E(n.toString())}"`)}function dr(e,t){if(t){let n=[];for(let e in t){if(!Object.prototype.hasOwnProperty.call(t,e))continue;let r=t[e];r!==void 0&&ur(n,e,r)}e.push(n.join(``))}}var k=class{constructor(){this._xml=[],this._chunks=[],this._stack=[],this._rollbacks=[],this.leaf=!1,this.open=!1}_consolidate(){this._rollbacks.length>0||this._xml.length>=lr&&(this._chunks.push(this._xml.join(``)),this._xml.length=0)}get tos(){return this._stack.length?this._stack[this._stack.length-1]:void 0}get cursor(){return this._chunks.length*lr+this._xml.length}openXml(e){let t=this._xml;t.push(`<?xml`),dr(t,e),t.push(`?>
8
- `)}openNode(e,t){let n=this.tos,r=this._xml;n&&this.open&&r.push(`>`),this._stack.push(e),r.push(`<`),r.push(e),dr(r,t),this.leaf=!0,this.open=!0}addAttribute(e,t){if(!this.open)throw new b(`write attributes`,`node is not open`);t!==void 0&&ur(this._xml,e,t)}addAttributes(e){if(!this.open)throw new b(`write attributes`,`node is not open`);dr(this._xml,e)}writeText(e){let t=this._xml;this.open&&=(t.push(`>`),!1),this.leaf=!1,t.push(E(e.toString()))}writeXml(e){this.open&&=(this._xml.push(`>`),!1),this.leaf=!1,this._xml.push(e)}closeNode(){let e=this._stack.pop(),t=this._xml;this.leaf?t.push(`/>`):(t.push(`</`),t.push(e),t.push(`>`)),this.open=!1,this.leaf=!1,this._consolidate()}leafNode(e,t,n){this.openNode(e,t),n!==void 0&&this.writeText(n),this.closeNode()}closeAll(){for(;this._stack.length;)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf??!1,open:this.open??!1,chunksLength:this._chunks.length}),this.cursor}commit(){this._rollbacks.pop()}rollback(){let e=this._rollbacks.pop();this._xml.length>e.xml&&(this._xml.length=e.xml),this._stack.length>e.stack&&(this._stack.length=e.stack),this._chunks.length>e.chunksLength&&(this._chunks.length=e.chunksLength),this.leaf=e.leaf,this.open=e.open}get xml(){return this.closeAll(),this._chunks.length===0?this._xml.join(``):(this._xml.length>0&&this._chunks.push(this._xml.join(``)),this._chunks.join(``))}static{this.StdDocAttributes={version:`1.0`,encoding:`UTF-8`,standalone:`yes`}}};let fr=(()=>{let e=Array(128);for(let t=0;t<128;t++)e[t]=String.fromCharCode(t);return e})();function A(e){return e<128?fr[e]:String.fromCodePoint(e)}let pr=(()=>{let e=new Uint8Array(128);for(let t=97;t<=122;t++)e[t]=1;for(let t=65;t<=90;t++)e[t]=1;return e[95]=1,e[58]=1,e})(),mr=(()=>{let e=new Uint8Array(128);for(let t=97;t<=122;t++)e[t]=1;for(let t=65;t<=90;t++)e[t]=1;for(let t=48;t<=57;t++)e[t]=1;return e[95]=1,e[58]=1,e[45]=1,e[46]=1,e})();function hr(e){return e===32||e===10||e===13||e===9}function gr(e){return e===34||e===39}function _r(e){return e<128?pr[e]===1:e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e===8204||e===8205||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function vr(e){return e<128?mr[e]===1:e===183||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=768&&e<=879||e>=880&&e<=893||e>=895&&e<=8191||e===8204||e===8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function yr(e){return e>=32&&e<=55295||e===10||e===13||e===9||e>=57344&&e<=65533||e>=65536&&e<=1114111}let br={amp:`&`,gt:`>`,lt:`<`,quot:`"`,apos:`'`};var xr=class{constructor(e){this.state=0,this.chunk=``,this.i=0,this.prevI=0,this.text=``,this.name=``,this.q=null,this.tags=[],this.tag=null,this.attribList=[],this.entity=``,this.entityReturnState=0,this.openWakaBang=``,this.sawRoot=!1,this.closedRoot=!1,this._closed=!1,this.reportedTextBeforeRoot=!1,this.reportedTextAfterRoot=!1,this.line=1,this.column=0,this.positionAtNewLine=0,this.chunkPosition=0,this.ENTITIES={...br},this.trackPosition=e?.position!==!1,this.fileName=e?.fileName,this.fragment=e?.fragment??!1,this._init()}get closed(){return this._closed}get position(){return this.chunkPosition+this.i}_init(){this.state=(this.fragment,0),this.text=``,this.name=``,this.q=null,this.tags=[],this.tag=null,this.attribList=[],this.entity=``,this.openWakaBang=``,this.sawRoot=this.fragment,this.closedRoot=this.fragment,this.reportedTextBeforeRoot=this.fragment,this.reportedTextAfterRoot=this.fragment,this.carriedFromPrevious=void 0,this._closed=!1,this.line=1,this.column=0,this.positionAtNewLine=0,this.chunkPosition=0,this.chunk=``,this.i=0,this.prevI=0}on(e,t){switch(e){case`text`:this.textHandler=t;break;case`opentag`:this.openTagHandler=t;break;case`closetag`:this.closeTagHandler=t;break;case`error`:this.errorHandler=t;break}}off(e){switch(e){case`text`:this.textHandler=void 0;break;case`opentag`:this.openTagHandler=void 0;break;case`closetag`:this.closeTagHandler=void 0;break;case`error`:this.errorHandler=void 0;break}}makeError(e){let t=this.fileName??``;return this.trackPosition&&(t.length>0&&(t+=`:`),t+=`${this.line}:${this.column}`),t.length>0&&(t+=`: `),Error(t+e)}fail(e){let t=this.makeError(e);if(this.errorHandler)this.errorHandler(t);else throw t;return this}write(e){if(this._closed)return this.fail(`cannot write after close`);let t=!1;e===null&&(t=!0,e=``),this.carriedFromPrevious!==void 0&&(e=this.carriedFromPrevious+e,this.carriedFromPrevious=void 0);let n=e.length;if(!t&&n>0){let t=e.charCodeAt(n-1);(t===13||t>=55296&&t<=56319)&&(this.carriedFromPrevious=e[n-1],n--,e=e.slice(0,n))}for(this.chunk=e,this.i=0;this.i<n;)this.processState();return this.chunkPosition+=n,t?this.end():this}close(){return this.write(null)}getCode(){let{chunk:e,i:t}=this;if(this.prevI=t,this.i=t+1,t>=e.length)return-1;let n=e.charCodeAt(t);if(n<10||n>13&&n<55296)return this.trackPosition&&this.column++,n;if(n>=55296&&n<=56319){let r=e.charCodeAt(t+1);if(r>=56320&&r<=57343)return this.i=t+2,this.trackPosition&&this.column++,65536+((n-55296)*1024+(r-56320))}return n===13?(e.charCodeAt(t+1)===10&&(this.i=t+2),this.trackPosition&&(this.line++,this.column=0,this.positionAtNewLine=this.position),10):(n===10&&this.trackPosition?(this.line++,this.column=0,this.positionAtNewLine=this.position):this.trackPosition&&this.column++,n)}unget(){this.i=this.prevI,this.trackPosition&&this.column--}processState(){switch(this.state){case 0:this.sText();break;case 1:this.sOpenWaka();break;case 2:this.sOpenWakaBang();break;case 3:this.sOpenTag();break;case 4:this.sOpenTagSlash();break;case 5:this.sAttrib();break;case 6:this.sAttribName();break;case 7:this.sAttribNameSawWhite();break;case 8:this.sAttribValue();break;case 9:this.sAttribValueQuoted();break;case 10:this.sAttribValueClosed();break;case 11:this.sCloseTag();break;case 12:this.sCloseTagSawWhite();break;case 13:this.sComment();break;case 14:this.sCommentEnding();break;case 15:this.sCommentEnded();break;case 16:this.sCData();break;case 17:this.sCDataEnding();break;case 18:this.sCDataEnding2();break;case 19:this.sPI();break;case 20:this.sPIEnding();break;case 21:this.sDoctype();break;case 22:this.sDoctypeQuote();break;case 23:this.sDoctypeDTD();break;case 24:this.sDoctypeDTDQuoted();break;case 25:this.sEntity();break}}sText(){this.tags.length===0?this.handleTextOutsideRoot():this.handleTextInRoot()}handleTextInRoot(){let{chunk:e}=this,{i:t}=this,n=this.textHandler;for(;;){let r=this.getCode();if(r===-1){n&&t<this.i&&(this.text+=e.slice(t,this.i));return}if(r===60){if(n){let r=e.slice(t,this.prevI);this.text.length>0?(n(this.text+r),this.text=``):r.length>0&&n(r)}this.state=1;return}if(r===38){n&&(this.text+=e.slice(t,this.prevI)),this.state=25,this.entityReturnState=0,this.entity=``;return}r===10&&(n&&(this.text+=e.slice(t,this.prevI)+`
7
+ var ExcelTS=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=class extends Error{constructor(e,t){super(e,t),this.name=`BaseError`,Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,message:this.message,stack:this.stack,cause:this.cause instanceof Error?o(this.cause):this.cause}}},n=class extends t{constructor(e){super(`The operation was aborted`,e===void 0?void 0:{cause:e}),this.name=`AbortError`,this.code=`ABORT_ERR`}};function r(e){return e instanceof n?e:new n(e)}function i(e){return!!e&&typeof e==`object`&&e.name===`AbortError`}function a(e){return e instanceof Error?e:Error(String(e))}function o(e){return e instanceof t?e.toJSON():{name:e.name,message:e.message,stack:e.stack,cause:e.cause instanceof Error?o(e.cause):e.cause}}function s(e){let t=[e],n=e.cause;for(;n instanceof Error;)t.push(n),n=n.cause;return t}function c(e){let t=e;for(;t.cause instanceof Error;)t=t.cause;return t}var l=class extends t{constructor(e,t){super(e,t),this.name=`ExcelError`}};function u(e){return e instanceof l}var d=class extends l{constructor(...e){super(...e),this.name=`WorksheetNameError`}},f=class extends l{constructor(e,t,n){super(t?`Invalid address "${e}": ${t}`:`Invalid address: ${e}`,n),this.address=e,this.name=`InvalidAddressError`}},p=class extends l{constructor(e,t,n){super(t?`Column ${e} is out of bounds: ${t}`:`Column ${e} is out of bounds. Excel supports columns from 1 to 16384`,n),this.column=e,this.name=`ColumnOutOfBoundsError`}},m=class extends l{constructor(e,t,n){super(t?`Row ${e} is out of bounds: ${t}`:`Row ${e} is out of bounds`,n),this.row=e,this.name=`RowOutOfBoundsError`}},h=class extends l{constructor(e,t){super(e??`Cannot merge already merged cells`,t),this.name=`MergeConflictError`}},g=class extends l{constructor(e,t,n){super(t??`Cannot process value of type: ${e}`,n),this.valueType=e,this.name=`InvalidValueTypeError`}},_=class extends l{constructor(e,t,n){super(t??`Unexpected XML content in ${e}`,n),this.context=e,this.name=`XmlParseError`}},v=class extends l{constructor(e,t,n){super(t?`${e}: ${t}`:`${e} is not supported`,n),this.operation=e,this.reason=t,this.name=`ExcelNotSupportedError`}},y=class extends l{constructor(e,t,n,r){super(n?`Failed to ${t} Excel file "${e}": ${n}`:`Failed to ${t} Excel file "${e}"`,r),this.path=e,this.operation=t,this.name=`ExcelFileError`}},b=class extends l{constructor(e,t,n){super(`Cannot ${e}: ${t}`,n),this.operation=e,this.state=t,this.name=`ExcelStreamStateError`}},ee=class extends l{constructor(e,t,n,r){super(`Failed to download from "${e}": HTTP ${t} ${n}`,r),this.url=e,this.status=t,this.statusText=n,this.name=`ExcelDownloadError`}},x=class extends l{constructor(...e){super(...e),this.name=`PivotTableError`}},te=class extends l{constructor(...e){super(...e),this.name=`TableError`}},ne=class extends l{constructor(...e){super(...e),this.name=`ImageError`}},re=class extends l{constructor(e,t,n){super(`Max ${e} count (${t}) exceeded`,n),this.itemType=e,this.maxItems=t,this.name=`MaxItemsExceededError`}};let ie=/^[A-Z]+\d+$/,S={_dictionary:`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``),_l2nFill:0,_l2n:{},_n2l:[],_level(e){return e<=26?1:e<=676?2:3},_fill(e){let t,n,r,i,a,o=1;if(e>=4)throw new p(e,`Excel supports columns from 1 to 16384`);if(this._l2nFill<1&&e>=1){for(;o<=26;)t=this._dictionary[o-1],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=1}if(this._l2nFill<2&&e>=2){for(o=27;o<=702;)n=o-27,r=n%26,i=Math.floor(n/26),t=this._dictionary[i]+this._dictionary[r],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=2}if(this._l2nFill<3&&e>=3){for(o=703;o<=16384;)n=o-703,r=n%26,i=Math.floor(n/26)%26,a=Math.floor(n/676),t=this._dictionary[a]+this._dictionary[i]+this._dictionary[r],this._n2l[o]=t,this._l2n[t]=o,o++;this._l2nFill=3}},l2n(e){if(this._l2n[e]||this._fill(e.length),!this._l2n[e])throw new p(e,`Invalid column letter: ${e}`);return this._l2n[e]},n2l(e){if(e<1||e>16384)throw new p(e);return this._n2l[e]||this._fill(this._level(e)),this._n2l[e]},_hash:{},validateAddress(e){if(!ie.test(e))throw new f(e);return!0},decodeAddress(e){if(!e||typeof e!=`string`)throw Error(`Invalid Address: ${e}`);let t=e.length<5&&this._hash[e];if(t)return t;let n=!1,r=``,i=0,a=!1,o=``,s=0;for(let t=0,c;t<e.length;t++)if(c=e.charCodeAt(t),!a&&c>=65&&c<=90)n=!0,r+=e[t],i=i*26+c-64;else if(c>=48&&c<=57)a=!0,o+=e[t],s=s*10+c-48;else if(a&&n&&c!==36)break;if(!n)i=void 0;else if(i>16384)throw new p(r,`Invalid column letter: ${r}`);a||(s=void 0),e=r+o;let c={address:e,col:i,row:s,$col$row:`$${r}$${o}`};return i<=100&&s<=100&&(this._hash[e]=c,this._hash[c.$col$row]=c),c},getAddress(e,t){if(t){let n=this.n2l(t)+e;return this.decodeAddress(n)}return this.decodeAddress(e)},decode(e){if(!e||typeof e!=`string`)throw Error(`Invalid Address: ${e}`);let t=e.split(`:`);if(t.length===2){let e=this.decodeAddress(t[0]),n=this.decodeAddress(t[1]),r={top:Math.min(e.row,n.row),left:Math.min(e.col,n.col),bottom:Math.max(e.row,n.row),right:Math.max(e.col,n.col),tl:``,br:``,dimensions:``};return r.tl=this.n2l(r.left)+r.top,r.br=this.n2l(r.right)+r.bottom,r.dimensions=`${r.tl}:${r.br}`,r}return this.decodeAddress(e)},decodeEx(e){if(!e||typeof e!=`string`)throw Error(`Invalid Address: ${e}`);let t=e.match(/^(?:(?:(?:'((?:[^']|'')+?)')|([^'^ !]+?))!)?(.*)$/),n=t[1]||t[2],r=t[3],i=r.split(`:`);if(i.length>1){let e=this.decodeAddress(i[0]),t=this.decodeAddress(i[1]),r=Math.min(e.row,t.row),a=Math.min(e.col,t.col),o=Math.max(e.row,t.row),s=Math.max(e.col,t.col),c=this.n2l(a)+r,l=this.n2l(s)+o;return{top:r,left:a,bottom:o,right:s,sheetName:n,tl:{address:c,col:a,row:r,$col$row:`$${this.n2l(a)}$${r}`,sheetName:n},br:{address:l,col:s,row:o,$col$row:`$${this.n2l(s)}$${o}`,sheetName:n},dimensions:`${c}:${l}`}}if(r.indexOf(`#`)===0)return n?{sheetName:n,error:r}:{error:r};let a=this.decodeAddress(r);return n?{sheetName:n,...a}:a},encodeAddress(e,t){return S.n2l(t)+e},encode(...e){switch(e.length){case 2:return S.encodeAddress(e[0],e[1]);case 4:return`${S.encodeAddress(e[0],e[1])}:${S.encodeAddress(e[2],e[3])}`;default:throw new f(String(e.length),`Can only encode with 2 or 4 arguments`)}},inRange(e,t){let[n,r,,i,a]=e,[o,s]=t;return o>=n&&o<=i&&s>=r&&s<=a}};var C=class e{constructor(...e){this.model={top:0,left:0,bottom:0,right:0},this.decode(e)}setTLBR(e,t,n,r,i){if(typeof e==`string`&&typeof t==`string`){let r=S.decodeAddress(e),i=S.decodeAddress(t);this.model={top:Math.min(r.row,i.row),left:Math.min(r.col,i.col),bottom:Math.max(r.row,i.row),right:Math.max(r.col,i.col),sheetName:typeof n==`string`?n:void 0}}else typeof e==`number`&&typeof t==`number`&&typeof n==`number`&&typeof r==`number`&&(this.model={top:Math.min(e,n),left:Math.min(t,r),bottom:Math.max(e,n),right:Math.max(t,r),sheetName:i})}decode(t){switch(t.length){case 5:typeof t[0]==`number`&&typeof t[1]==`number`&&typeof t[2]==`number`&&typeof t[3]==`number`&&typeof t[4]==`string`&&this.setTLBR(t[0],t[1],t[2],t[3],t[4]);break;case 4:typeof t[0]==`number`&&typeof t[1]==`number`&&typeof t[2]==`number`&&typeof t[3]==`number`&&this.setTLBR(t[0],t[1],t[2],t[3]);break;case 3:typeof t[0]==`string`&&typeof t[1]==`string`&&typeof t[2]==`string`&&this.setTLBR(t[0],t[1],t[2]);break;case 2:typeof t[0]==`string`&&typeof t[1]==`string`&&this.setTLBR(t[0],t[1]);break;case 1:{let n=t[0];if(n instanceof e)this.model={top:n.model.top,left:n.model.left,bottom:n.model.bottom,right:n.model.right,sheetName:n.sheetName};else if(Array.isArray(n))this.decode(n);else if(typeof n==`object`&&`top`in n&&`left`in n&&`bottom`in n&&`right`in n)this.model={top:n.top,left:n.left,bottom:n.bottom,right:n.right,sheetName:n.sheetName};else if(typeof n==`string`){let e=S.decodeEx(n);`top`in e?this.model={top:e.top,left:e.left,bottom:e.bottom,right:e.right,sheetName:e.sheetName}:`row`in e&&(this.model={top:e.row,left:e.col,bottom:e.row,right:e.col,sheetName:e.sheetName})}break}case 0:this.model={top:0,left:0,bottom:0,right:0};break;default:throw new l(`Invalid number of arguments to _getDimensions() - ${t.length}`)}}get top(){return this.model.top||1}set top(e){this.model.top=e}get left(){return this.model.left||1}set left(e){this.model.left=e}get bottom(){return this.model.bottom||1}set bottom(e){this.model.bottom=e}get right(){return this.model.right||1}set right(e){this.model.right=e}get sheetName(){return this.model.sheetName}set sheetName(e){this.model.sheetName=e}get _serialisedSheetName(){let{sheetName:e}=this.model;return e?/^[a-zA-Z0-9]*$/.test(e)?`${e}!`:`'${e}'!`:``}expand(e,t,n,r){(!this.model.top||e<this.top)&&(this.top=e),(!this.model.left||t<this.left)&&(this.left=t),(!this.model.bottom||n>this.bottom)&&(this.bottom=n),(!this.model.right||r>this.right)&&(this.right=r)}expandRow(e){if(e){let{dimensions:t,number:n}=e;t&&this.expand(n,t.min,n,t.max)}}expandToAddress(e){let t=S.decodeEx(e);`row`in t&&`col`in t&&this.expand(t.row,t.col,t.row,t.col)}get tl(){return S.n2l(this.left)+this.top}get $t$l(){return`$${S.n2l(this.left)}$${this.top}`}get br(){return S.n2l(this.right)+this.bottom}get $b$r(){return`$${S.n2l(this.right)}$${this.bottom}`}get range(){return`${this._serialisedSheetName+this.tl}:${this.br}`}get $range(){return`${this._serialisedSheetName+this.$t$l}:${this.$b$r}`}get shortRange(){return this.count>1?this.range:this._serialisedSheetName+this.tl}get $shortRange(){return this.count>1?this.$range:this._serialisedSheetName+this.$t$l}get count(){return(1+this.bottom-this.top)*(1+this.right-this.left)}toString(){return this.range}intersects(e){return!(e.sheetName&&this.sheetName&&e.sheetName!==this.sheetName||e.bottom<this.top||e.top>this.bottom||e.right<this.left||e.left>this.right)}contains(e){let t=S.decodeEx(e);return`row`in t&&`col`in t?this.containsEx(t):!1}containsEx(e){return e.sheetName&&this.sheetName&&e.sheetName!==this.sheetName?!1:e.row>=this.top&&e.row<=this.bottom&&e.col>=this.left&&e.col<=this.right}forEachAddress(e){for(let t=this.left;t<=this.right;t++)for(let n=this.top;n<=this.bottom;n++)e(S.encodeAddress(n,t),n,t)}};let ae=function(e){return e[e.Null=0]=`Null`,e[e.Merge=1]=`Merge`,e[e.Number=2]=`Number`,e[e.String=3]=`String`,e[e.Date=4]=`Date`,e[e.Hyperlink=5]=`Hyperlink`,e[e.Formula=6]=`Formula`,e[e.SharedString=7]=`SharedString`,e[e.RichText=8]=`RichText`,e[e.Boolean=9]=`Boolean`,e[e.Error=10]=`Error`,e[e.JSON=11]=`JSON`,e[e.Checkbox=12]=`Checkbox`,e}({}),oe=function(e){return e[e.None=0]=`None`,e[e.Master=1]=`Master`,e[e.Shared=2]=`Shared`,e}({}),se=function(e){return e[e.None=0]=`None`,e[e.OfficeDocument=1]=`OfficeDocument`,e[e.Worksheet=2]=`Worksheet`,e[e.CalcChain=3]=`CalcChain`,e[e.SharedStrings=4]=`SharedStrings`,e[e.Styles=5]=`Styles`,e[e.Theme=6]=`Theme`,e[e.Hyperlink=7]=`Hyperlink`,e}({}),ce=function(e){return e[e.Xlsx=1]=`Xlsx`,e}({}),le=function(e){return e[e.LeftToRight=1]=`LeftToRight`,e[e.RightToLeft=2]=`RightToLeft`,e}({}),w={NotApplicable:`#N/A`,Ref:`#REF!`,Name:`#NAME?`,DivZero:`#DIV/0!`,Null:`#NULL!`,Value:`#VALUE!`,Num:`#NUM!`},T={ValueType:ae,FormulaType:oe,RelationshipType:se,DocumentType:ce,ReadingOrder:le,ErrorValue:w},ue={'"':`&quot;`,"&":`&amp;`,"<":`&lt;`,">":`&gt;`},de=/["&<>]/g;function fe(e,t){if(e===t)return!0;if(e==null||t==null)return e===t;let n=typeof e;if(n!==typeof t||n!==`object`)return!1;let r=Array.isArray(e);if(r!==Array.isArray(t))return!1;if(r){let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!fe(e[r],t[r]))return!1;return!0}let i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return!1;for(let n=0,r=i.length;n<r;n++){let r=i[n];if(!Object.prototype.hasOwnProperty.call(t,r)||!fe(e[r],t[r]))return!1}return!0}function pe(e){return e.replace(de,e=>ue[e])}function me(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function he(...e){let t=e[0]||{},n=e.length;for(let r=1;r<n;r++){let n=e[r];if(n)if(Array.isArray(n))for(let e=0,r=n.length;e<r;e++){let r=n[e];if(r===void 0)continue;let i=t[e];Array.isArray(r)?t[e]=he(Array.isArray(i)?i:[],r):me(r)?t[e]=he(me(i)?i:{},r):t[e]=r}else{let e=Object.keys(n);for(let r=0,i=e.length;r<i;r++){let i=e[r];if(i===`__proto__`||i===`constructor`||i===`prototype`)continue;let a=n[i];if(a===void 0)continue;let o=t[i];Array.isArray(a)?t[i]=he(Array.isArray(o)?o:[],a):me(a)?t[i]=he(me(o)?o:{},a):t[i]=a}}}return t}var ge=class e{static{this.DEFAULT_CONFIGS={note:{margins:{insetmode:`auto`,inset:[.13,.13,.25,.25]},protection:{locked:`True`,lockText:`True`},editAs:`absolute`},type:`note`}}constructor(e){this.note=e}get model(){let t;switch(typeof this.note){case`string`:t={type:`note`,note:{texts:[{text:this.note}]}};break;default:t={type:`note`,note:this.note??{}};break}return he({},e.DEFAULT_CONFIGS,t)}set model(e){let{note:t}=e,{texts:n}=t;n&&n.length===1&&Object.keys(n[0]).length===1?this.note=n[0].text:this.note=t}static fromModel(t){let n=new e;return n.model=t,n}};let _e=/(([a-z_\-0-9]*)!)?([a-z0-9_$]{2,})([(])?/gi,ve=/^([$])?([a-z]+)([$])?([1-9][0-9]*)$/i;function ye(e,t,n){let r=S.decode(t),i=S.decode(n);return e.replace(_e,(e,t,n,a,o)=>{if(o)return e;let s=ve.exec(a);if(s){let n=s[1],a=s[2].toUpperCase(),o=s[3],c=s[4];if(a.length>3||a.length===3&&a>`XFD`)return e;let l=S.l2n(a),u=parseInt(c,10);return n||(l+=i.col-r.col),o||(u+=i.row-r.row),(t??``)+(n??``)+S.n2l(l)+(o??``)+u}return e})}let be=e=>!!e&&(typeof e!=`object`||Object.keys(e).length>0);var E=class e{static{this.Types=T.ValueType}constructor(t,n,r){if(!t||!n)throw new l(`A Cell needs a Row`);this._row=t,this._column=n,S.validateAddress(r),this._address=r,this._value=Pe.create(e.Types.Null,this),this.style=this._mergeStyle(t.style,n.style,{}),this._mergeCount=0}get worksheet(){return this._row.worksheet}get workbook(){return this._row.worksheet.workbook}destroy(){this.style=void 0,this._value=void 0,this._row=void 0,this._column=void 0,this._address=void 0}get numFmt(){return this.style.numFmt}set numFmt(e){this.style.numFmt=e}get font(){return this.style.font}set font(e){this.style.font=e}get alignment(){return this.style.alignment}set alignment(e){this.style.alignment=e}get border(){return this.style.border}set border(e){this.style.border=e}get fill(){return this.style.fill}set fill(e){this.style.fill=e}get protection(){return this.style.protection}set protection(e){this.style.protection=e}_mergeStyle(e,t,n){let r=e&&e.numFmt||t&&t.numFmt;r&&(n.numFmt=r);let i=e&&be(e.font)&&e.font||t&&be(t.font)&&t.font;i&&(n.font=i);let a=e&&be(e.alignment)&&e.alignment||t&&be(t.alignment)&&t.alignment;a&&(n.alignment=a);let o=e&&be(e.border)&&e.border||t&&be(t.border)&&t.border;o&&(n.border=o);let s=e&&be(e.fill)&&e.fill||t&&be(t.fill)&&t.fill;s&&(n.fill=s);let c=e&&be(e.protection)&&e.protection||t&&be(t.protection)&&t.protection;return c&&(n.protection=c),n}get address(){return this._address}get row(){return this._row.number}get col(){return this._column.number}get $col$row(){return`$${this._column.letter}$${this.row}`}get type(){return this._value.type}get effectiveType(){return this._value.effectiveType}toCsvString(){return this._value.toCsvString()}addMergeRef(){this._mergeCount++}releaseMergeRef(){this._mergeCount--}get isMerged(){return this._mergeCount>0||this.type===e.Types.Merge}merge(t,n){this._value.release(),this._value=Pe.create(e.Types.Merge,this,t),n||(this.style=t.style)}unmerge(){this.type===e.Types.Merge&&(this._value.release(),this._value=Pe.create(e.Types.Null,this),this.style=this._mergeStyle(this._row.style,this._column.style,{...this.style}))}isMergedTo(t){return this._value.type===e.Types.Merge&&this._value.isMergedTo?this._value.isMergedTo(t):!1}get master(){return this.type===e.Types.Merge?this._value.master:this}get isHyperlink(){return this._value.type===e.Types.Hyperlink}get hyperlink(){return this._value.hyperlink}get value(){return this._value.value}set value(t){if(this.type===e.Types.Merge){this._value.master.value=t;return}this._value.release(),this._value=Pe.create(Pe.getType(t),this,t)}get note(){if(this._comment)return this._comment.note}set note(e){this._comment=new ge(e)}get comment(){return this._comment}set comment(e){e===void 0?this._comment=void 0:e instanceof ge?this._comment=e:this._comment=new ge(e)}get text(){return this._value.toString()}get html(){return pe(this.text)}toString(){return this.text}_upgradeToHyperlink(t){this.type===e.Types.String&&(this._value=Pe.create(e.Types.Hyperlink,this,{text:String(this._value.value),hyperlink:t}))}get formula(){return this._value.formula}get result(){return this._value.result}get formulaType(){return this._value.formulaType??T.FormulaType.None}get fullAddress(){let{worksheet:e}=this._row;return{sheetName:e.name,address:this.address,row:this.row,col:this.col}}get name(){return this.names[0]}set name(e){this.names=[e]}get names(){return this.workbook.definedNames.getNamesEx(this.fullAddress)}set names(e){let{definedNames:t}=this.workbook;t.removeAllNames(this.fullAddress),e.forEach(e=>{t.addEx(this.fullAddress,e)})}addName(e){this.workbook.definedNames.addEx(this.fullAddress,e)}removeName(e){this.workbook.definedNames.removeEx(this.fullAddress,e)}removeAllNames(){this.workbook.definedNames.removeAllNames(this.fullAddress)}get _dataValidations(){return this.worksheet.dataValidations}get dataValidation(){return this._dataValidations.find(this.address)}set dataValidation(e){this._dataValidations.add(this.address,e)}get model(){let{model:e}=this._value;return e.style=this.style,this._comment&&(e.comment=this._comment.model),e}set model(e){if(this._value.release(),this._value=Pe.create(e.type,this),this._value.model=e,e.comment)switch(e.comment.type){case`note`:this._comment=ge.fromModel(e.comment);break}e.style?this.style=e.style:this.style={}}},xe=class{constructor(e){this.model={address:e.address,type:E.Types.Null}}get value(){return null}set value(e){}get type(){return E.Types.Null}get effectiveType(){return E.Types.Null}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return``}release(){}toString(){return``}},Se=class{constructor(e,t){this.model={address:e.address,type:E.Types.Number,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return E.Types.Number}get effectiveType(){return E.Types.Number}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}},Ce=class{constructor(e,t){this.model={address:e.address,type:E.Types.String,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return E.Types.String}get effectiveType(){return E.Types.String}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return`"${this.model.value.replace(/"/g,`""`)}"`}release(){}toString(){return this.model.value}},we=class{constructor(e,t){this.model={address:e.address,type:E.Types.String,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}toString(){return this.model.value.richText.map(e=>e.text).join(``)}get type(){return E.Types.RichText}get effectiveType(){return E.Types.RichText}get address(){return this.model.address}set address(e){this.model.address=e}get text(){return this.toString()}toCsvString(){return`"${this.text.replace(/"/g,`""`)}"`}release(){}},Te=class{constructor(e,t){this.model={address:e.address,type:E.Types.Date,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return E.Types.Date}get effectiveType(){return E.Types.Date}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value.toISOString()}release(){}toString(){return this.model.value.toString()}},Ee=class{constructor(e,t){this.model={address:e.address,type:E.Types.Hyperlink,text:t?t.text:void 0,hyperlink:t?t.hyperlink:void 0},t&&t.tooltip&&(this.model.tooltip=t.tooltip)}get value(){return{text:this.model.text??``,hyperlink:this.model.hyperlink??``,tooltip:this.model.tooltip}}set value(e){this.model.text=e.text,this.model.hyperlink=e.hyperlink,e.tooltip&&(this.model.tooltip=e.tooltip)}get text(){return this.model.text}set text(e){this.model.text=e}get hyperlink(){return this.model.hyperlink}set hyperlink(e){this.model.hyperlink=e}get type(){return E.Types.Hyperlink}get effectiveType(){return E.Types.Hyperlink}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.hyperlink??``}release(){}toString(){return this.model.text??``}},De=class{constructor(e,t){this.model={address:e.address,type:E.Types.Merge,master:t?t.address:void 0},this._master=t,t&&t.addMergeRef()}get value(){return this._master.value}set value(e){e instanceof E?(this._master&&this._master.releaseMergeRef(),e.addMergeRef(),this._master=e):this._master.value=e}isMergedTo(e){return e===this._master}get master(){return this._master}get type(){return E.Types.Merge}get effectiveType(){return this._master.effectiveType}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return``}release(){this._master.releaseMergeRef()}toString(){return this.value==null?``:this.value.toString()}},Oe=class{constructor(e,t){this.cell=e,this.model={address:e.address,type:E.Types.Formula,shareType:t?t.shareType:void 0,ref:t?t.ref:void 0,formula:t?t.formula:void 0,sharedFormula:t?t.sharedFormula:void 0,result:t?t.result:void 0}}_copyModel(e){let t={};return e.formula&&(t.formula=e.formula),e.result!==void 0&&(t.result=e.result),e.ref&&(t.ref=e.ref),e.shareType&&(t.shareType=e.shareType),e.sharedFormula&&(t.sharedFormula=e.sharedFormula),t}get value(){return this._copyModel(this.model)}set value(e){e.formula&&(this.model.formula=e.formula),e.result!==void 0&&(this.model.result=e.result),e.ref&&(this.model.ref=e.ref),e.shareType&&(this.model.shareType=e.shareType),e.sharedFormula&&(this.model.sharedFormula=e.sharedFormula)}validate(e){switch(Pe.getType(e)){case E.Types.Null:case E.Types.String:case E.Types.Number:case E.Types.Date:break;case E.Types.Hyperlink:case E.Types.Formula:default:throw new g(String(Pe.getType(e)),`Cannot process that type of result value`)}}get dependencies(){return{ranges:this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g),cells:this.formula.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g,``).match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g)}}get formula(){return this.model.formula||this._getTranslatedFormula()||``}set formula(e){this.model.formula=e}get formulaType(){return this.model.formula?T.FormulaType.Master:this.model.sharedFormula?T.FormulaType.Shared:T.FormulaType.None}get result(){return this.model.result}set result(e){this.model.result=e}get type(){return E.Types.Formula}get effectiveType(){let e=this.model.result;return e==null?T.ValueType.Null:typeof e==`string`?T.ValueType.String:typeof e==`number`?T.ValueType.Number:e instanceof Date?T.ValueType.Date:typeof e==`object`&&`error`in e?T.ValueType.Error:T.ValueType.Null}get address(){return this.model.address}set address(e){this.model.address=e}_getTranslatedFormula(){if(!this._translatedFormula&&this.model.sharedFormula){let{worksheet:e}=this.cell,t=e.findCell(this.model.sharedFormula);this._translatedFormula=t&&t.formula?ye(t.formula,t.address,this.model.address):void 0}return this._translatedFormula}toCsvString(){return`${this.model.result??``}`}release(){}toString(){return this.model.result?this.model.result.toString():``}},ke=class{constructor(e,t){this.model={address:e.address,type:E.Types.SharedString,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return E.Types.SharedString}get effectiveType(){return E.Types.SharedString}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}},Ae=class{constructor(e,t){this.model={address:e.address,type:E.Types.Boolean,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return E.Types.Boolean}get effectiveType(){return E.Types.Boolean}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value?1:0}release(){}toString(){return this.model.value.toString()}},je=class{constructor(e,t){this.model={address:e.address,type:E.Types.Checkbox,value:t.checkbox}}get value(){return{checkbox:this.model.value}}set value(e){this.model.value=e.checkbox}get type(){return E.Types.Checkbox}get effectiveType(){return E.Types.Boolean}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value?1:0}release(){}toString(){return this.model.value.toString()}},Me=class{constructor(e,t){this.model={address:e.address,type:E.Types.Error,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return E.Types.Error}get effectiveType(){return E.Types.Error}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.toString()}release(){}toString(){return this.model.value.error.toString()}},Ne=class{constructor(e,t){this.model={address:e.address,type:E.Types.String,value:JSON.stringify(t),rawValue:t}}get value(){return this.model.rawValue}set value(e){this.model.rawValue=e,this.model.value=JSON.stringify(e)}get type(){return E.Types.String}get effectiveType(){return E.Types.String}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return this.model.value}release(){}toString(){return this.model.value}};let Pe={getType(e){if(e==null)return E.Types.Null;if(typeof e==`string`)return E.Types.String;if(typeof e==`number`)return E.Types.Number;if(typeof e==`boolean`)return E.Types.Boolean;if(e instanceof Date)return E.Types.Date;if(typeof e==`object`){if(`checkbox`in e&&typeof e.checkbox==`boolean`)return E.Types.Checkbox;if(`text`in e&&e.text&&`hyperlink`in e&&e.hyperlink)return E.Types.Hyperlink;if(`formula`in e&&e.formula||`sharedFormula`in e&&e.sharedFormula)return E.Types.Formula;if(`richText`in e&&e.richText)return E.Types.RichText;if(`sharedString`in e&&e.sharedString)return E.Types.SharedString;if(`error`in e&&e.error)return E.Types.Error}return E.Types.JSON},types:[{t:E.Types.Null,f:xe},{t:E.Types.Number,f:Se},{t:E.Types.String,f:Ce},{t:E.Types.Date,f:Te},{t:E.Types.Hyperlink,f:Ee},{t:E.Types.Formula,f:Oe},{t:E.Types.Merge,f:De},{t:E.Types.JSON,f:Ne},{t:E.Types.SharedString,f:ke},{t:E.Types.RichText,f:we},{t:E.Types.Boolean,f:Ae},{t:E.Types.Error,f:Me},{t:E.Types.Checkbox,f:je}].reduce((e,t)=>(e[t.t]=t.f,e),[]),create(e,t,n){let r=this.types[e];if(!r)throw new g(String(e),`Could not create Value`);return new r(t,n)}},Fe=(e,t)=>({...e,...t.reduce((t,n)=>(e[n]&&(t[n]={...e[n]}),t),{})}),Ie=(e,t,n,r=[])=>{e[n]&&(t[n]=Fe(e[n],r))},Le=e=>Object.keys(e).length===0,Re=e=>{if(!e)return e;if(Le(e))return{};let t={...e};return Ie(e,t,`font`,[`color`]),Ie(e,t,`alignment`),Ie(e,t,`protection`),e.border&&(Ie(e,t,`border`),Ie(e.border,t.border,`top`,[`color`]),Ie(e.border,t.border,`left`,[`color`]),Ie(e.border,t.border,`bottom`,[`color`]),Ie(e.border,t.border,`right`,[`color`]),Ie(e.border,t.border,`diagonal`,[`color`])),e.fill&&(Ie(e,t,`fill`,[`fgColor`,`bgColor`,`center`]),e.fill.stops&&(t.fill.stops=e.fill.stops.map(e=>Fe(e,[`color`])))),t};var ze=class{constructor(e,t){this._worksheet=e,this._number=t,this._cells=[],this.style={},this.outlineLevel=0}get number(){return this._number}get worksheet(){return this._worksheet}commit(){this._worksheet._commitRow(this)}destroy(){this._worksheet=void 0,this._cells=void 0,this.style=void 0}findCell(e){return this._cells[e-1]}getCellEx(e){let t=this._cells[e.col-1];if(!t){let n=this._worksheet.getColumn(e.col);t=new E(this,n,e.address),this._cells[e.col-1]=t}return t}getCell(e){let t;if(typeof e==`string`){let n=this._worksheet.getColumnKey(e);t=n?n.number:S.l2n(e)}else t=e;return this._cells[t-1]||this.getCellEx({address:S.encodeAddress(this._number,t),row:this._number,col:t})}splice(e,t,...n){let r=e+t,i=n.length-t,a=this._cells.length,o,s,c;if(i<0)for(o=e+n.length;o<=a;o++)c=this._cells[o-1],s=this._cells[o-i-1],s?(c=this.getCell(o),c.value=s.value,c.style=Re(s.style)??{},c.comment=s.comment):c&&(c.value=null,c.style={},c.comment=void 0);else if(i>0)for(o=a;o>=r;o--)s=this._cells[o-1],s?(c=this.getCell(o+i),c.value=s.value,c.style=Re(s.style)??{},c.comment=s.comment):this._cells[o+i-1]=void 0;for(o=0;o<n.length;o++)c=this.getCell(e+o),c.value=n[o],c.style={},c.comment=void 0}eachCell(e,t){let n=null,r;if(typeof e==`function`?r=e:(n=e,r=t),n&&n.includeEmpty){let e=this._cells.length;for(let t=1;t<=e;t++)r(this.getCell(t),t)}else this._cells.forEach((e,t)=>{e&&e.type!==T.ValueType.Null&&r(e,t+1)})}addPageBreak(e,t){let n=this._worksheet,r=Math.max(0,(e??0)-1)||0,i=Math.max(0,(t??0)-1)||16838,a={id:this._number,max:i,man:1};r&&(a.min=r),n.rowBreaks.push(a)}get values(){let e=[];return this._cells.forEach(t=>{t&&t.type!==T.ValueType.Null&&(e[t.col]=t.value)}),e}set values(e){if(this._cells=[],e)if(e instanceof Array){let t=0;Object.prototype.hasOwnProperty.call(e,`0`)&&(t=1),e.forEach((e,n)=>{e!==void 0&&(this.getCellEx({address:S.encodeAddress(this._number,n+t),row:this._number,col:n+t}).value=e)})}else this._worksheet.eachColumnKey((t,n)=>{e[n]!==void 0&&(this.getCellEx({address:S.encodeAddress(this._number,t.number),row:this._number,col:t.number}).value=e[n])})}getValues(){let e=[];return this._cells.forEach(t=>{t&&t.type!==T.ValueType.Null&&(e[t.col-1]=t.value)}),e}valuesToString(e=`,`){return this.getValues().join(e)}get hasValues(){return this._cells.some(e=>e&&e.type!==T.ValueType.Null)}get cellCount(){return this._cells.length}get actualCellCount(){let e=0;return this.eachCell(()=>{e++}),e}get dimensions(){let e=0,t=0;return this._cells.forEach(n=>{n&&n.type!==T.ValueType.Null&&((!e||e>n.col)&&(e=n.col),t<n.col&&(t=n.col))}),e>0?{min:e,max:t}:null}_applyStyle(e,t){this.style[e]=t,this._cells.forEach(n=>{n&&(n.style[e]=t)})}get numFmt(){return this.style.numFmt}set numFmt(e){e!==void 0&&this._applyStyle(`numFmt`,e)}get font(){return this.style.font}set font(e){e!==void 0&&this._applyStyle(`font`,e)}get alignment(){return this.style.alignment}set alignment(e){e!==void 0&&this._applyStyle(`alignment`,e)}get protection(){return this.style.protection}set protection(e){e!==void 0&&this._applyStyle(`protection`,e)}get border(){return this.style.border}set border(e){e!==void 0&&this._applyStyle(`border`,e)}get fill(){return this.style.fill}set fill(e){e!==void 0&&this._applyStyle(`fill`,e)}get hidden(){return!!this._hidden}set hidden(e){this._hidden=e}get outlineLevel(){return this._outlineLevel??0}set outlineLevel(e){this._outlineLevel=e}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=(this._worksheet.properties.outlineLevelRow??0))}get model(){let e=[],t=0,n=0;return this._cells.forEach(r=>{if(r){let i=r.model;i&&((!t||t>r.col)&&(t=r.col),n<r.col&&(n=r.col),e.push(i))}}),this.height!=null||e.length?{cells:e,number:this.number,min:t,max:n,height:this.height,customHeight:this.customHeight,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel,collapsed:this.collapsed,dyDescent:this.dyDescent}:null}set model(e){if(e.number!==this._number)throw new l(`Invalid row number in model`);this._cells=[];let t;e.cells.forEach(e=>{switch(e.type){case E.Types.Merge:break;default:{let n;if(e.address)n=S.decodeAddress(e.address);else if(t){let{row:e}=t,r=t.col+1;n={row:e,col:r,address:S.encodeAddress(e,r),$col$row:`$${S.n2l(r)}$${e}`}}if(t=n,!n)break;let r=this.getCellEx(n);r.model=e;break}}}),e.height==null?delete this.height:this.height=e.height,e.customHeight==null?delete this.customHeight:this.customHeight=e.customHeight,this.hidden=e.hidden,this.outlineLevel=e.outlineLevel??0,this.dyDescent=e.dyDescent,this.style=e.style?structuredClone(e.style):{}}},Be=class e{constructor(e,t,n){this._worksheet=e,this._number=t,n!==!1&&(this.defn=n)}get number(){return this._number}get worksheet(){return this._worksheet}get letter(){return S.n2l(this._number)}get isCustomWidth(){return this.width!==void 0&&this.width!==9}get defn(){return{header:this._header,key:this.key,width:this.width,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel,bestFit:this.bestFit}}set defn(e){e?(this.key=e.key,this.width=e.width===void 0?9:e.width,this.outlineLevel=e.outlineLevel,e.style?this.style=e.style:this.style={},this.header=e.header,this._hidden=!!e.hidden,this.bestFit=e.bestFit):(delete this._header,delete this._key,delete this.width,this.style={},this.outlineLevel=0,delete this.bestFit)}get headers(){return Array.isArray(this._header)?this._header:this._header===void 0?[]:[this._header]}get header(){return this._header}set header(e){e===void 0?this._header=void 0:(this._header=e,this.headers.forEach((e,t)=>{this._worksheet.getCell(t+1,this.number).value=e}))}get key(){return this._key}set key(e){(this._key&&this._worksheet.getColumnKey(this._key))===this&&this._worksheet.deleteColumnKey(this._key),this._key=e,e&&this._worksheet.setColumnKey(e,this)}get hidden(){return!!this._hidden}set hidden(e){this._hidden=e}get outlineLevel(){return this._outlineLevel??0}set outlineLevel(e){this._outlineLevel=e}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=(this._worksheet.properties.outlineLevelCol??0))}toString(){return JSON.stringify({key:this.key,width:this.width,headers:this.headers.length?this.headers:void 0})}equivalentTo(e){return this.width===e.width&&this.hidden===e.hidden&&this.outlineLevel===e.outlineLevel&&fe(this.style,e.style)}equivalentToModel(e){return this.width===e.width&&this.hidden===e.hidden&&this.outlineLevel===e.outlineLevel&&this.bestFit===e.bestFit&&fe(this.style,e.style)}get isDefault(){if(this.isCustomWidth||this.hidden||this.outlineLevel||this.bestFit)return!1;let e=this.style;return!(e&&(e.font||e.numFmt||e.alignment||e.border||e.fill||e.protection))}get headerCount(){return this.headers.length}eachCell(e,t){let n=this.number,r,i;typeof e==`function`?(r={},i=e):(r=e,i=t),this._worksheet.eachRow(r,(e,t)=>{i(e.getCell(n),t)})}get values(){let e=[];return this.eachCell((t,n)=>{t&&t.type!==T.ValueType.Null&&(e[n]=t.value)}),e}set values(e){if(!e)return;let t=this.number,n=0;Object.prototype.hasOwnProperty.call(e,`0`)&&(n=1),e.forEach((e,r)=>{this._worksheet.getCell(r+n,t).value=e})}addPageBreak(e,t){let n=this._worksheet,r=Math.max(0,(e??0)-1)||0,i=Math.max(0,(t??0)-1)||1048575,a={id:this._number,max:i,man:1};r&&(a.min=r),n.colBreaks.push(a)}get numFmt(){return this.style.numFmt}set numFmt(e){this.style.numFmt=e,this.eachCell(t=>{t.numFmt=e})}get font(){return this.style.font}set font(e){this.style.font=e,this.eachCell(t=>{t.font=e})}get alignment(){return this.style.alignment}set alignment(e){this.style.alignment=e,this.eachCell(t=>{t.alignment=e})}get protection(){return this.style.protection}set protection(e){this.style.protection=e,this.eachCell(t=>{t.protection=e})}get border(){return this.style.border}set border(e){this.style.border=e,this.eachCell(t=>{t.border=e})}get fill(){return this.style.fill}set fill(e){this.style.fill=e,this.eachCell(t=>{t.fill=e})}static toModel(e){let t=[],n=null;return e.forEach((e,r)=>{e.isDefault?n&&=null:!n||!e.equivalentToModel(n)?(n={min:r+1,max:r+1,width:e.width===void 0?9:e.width,style:e.style,isCustomWidth:e.isCustomWidth,hidden:e.hidden,outlineLevel:e.outlineLevel,collapsed:e.collapsed,bestFit:e.bestFit},t.push(n)):n.max=r+1}),t.length?t:void 0}static fromModel(t,n){let r=t,i=Array.isArray(t)?t:n??[];i??=[];let a=[],o=1,s=0;for(i=i.sort((e,t)=>e.min-t.min);s<i.length;){let t=i[s++];for(;o<t.min;)a.push(new e(r,o++));for(;o<=t.max;)a.push(new e(r,o++,t))}return a}};function Ve(e){return typeof e==`object`&&`nativeCol`in e&&`nativeRow`in e&&`nativeColOff`in e&&`nativeRowOff`in e}function He(e){return typeof e==`object`&&`col`in e&&`row`in e}var Ue=class e{constructor(e,t,n=0){if(this.worksheet=e,!t)this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0;else if(typeof t==`string`){let e=S.decodeAddress(t);this.nativeCol=e.col+n,this.nativeColOff=0,this.nativeRow=e.row+n,this.nativeRowOff=0}else Ve(t)?(this.nativeCol=t.nativeCol??0,this.nativeColOff=t.nativeColOff??0,this.nativeRow=t.nativeRow??0,this.nativeRowOff=t.nativeRowOff??0):He(t)?(this.col=t.col+n,this.row=t.row+n):(this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0)}static asInstance(t){return t==null?null:t instanceof e?t:new e(void 0,t)}get col(){return this.nativeColOff===0?this.nativeCol:this.nativeCol+Math.min(this.colWidth-1,this.nativeColOff)/this.colWidth}set col(e){this.nativeCol=Math.floor(e);let t=e-this.nativeCol;this.nativeColOff=t===0?0:Math.floor(t*this.colWidth)}get row(){return this.nativeRowOff===0?this.nativeRow:this.nativeRow+Math.min(this.rowHeight-1,this.nativeRowOff)/this.rowHeight}set row(e){this.nativeRow=Math.floor(e);let t=e-this.nativeRow;this.nativeRowOff=t===0?0:Math.floor(t*this.rowHeight)}get colWidth(){return this.worksheet&&this.worksheet.getColumn(this.nativeCol+1)&&this.worksheet.getColumn(this.nativeCol+1).isCustomWidth?Math.floor(this.worksheet.getColumn(this.nativeCol+1).width*1e4):64e4}get rowHeight(){let e=this.worksheet?.getRow(this.nativeRow+1)?.height;return e?Math.floor(e*1e4):18e4}get model(){return{nativeCol:this.nativeCol,nativeColOff:this.nativeColOff,nativeRow:this.nativeRow,nativeRowOff:this.nativeRowOff}}set model(e){this.nativeCol=e.nativeCol,this.nativeColOff=e.nativeColOff,this.nativeRow=e.nativeRow,this.nativeRowOff=e.nativeRowOff}clone(t){return new e(t??this.worksheet,this.model)}},We=class e{constructor(e,t){this.worksheet=e,t&&(this.model=t)}get model(){switch(this.type){case`background`:return{type:this.type,imageId:this.imageId??``};case`image`:{let e=this.range;if(!e)throw new ne(`Image has no range`);return{type:this.type,imageId:this.imageId??``,hyperlinks:e.hyperlinks,range:{tl:e.tl.model,br:e.br?.model,ext:e.ext,editAs:e.editAs}}}default:throw new ne(`Invalid Image Type`)}}set model({type:e,imageId:t,range:n,hyperlinks:r}){if(this.type=e,this.imageId=t,e===`image`)if(typeof n==`string`){let e=S.decode(n);`top`in e&&(this.range={tl:new Ue(this.worksheet,{col:e.left,row:e.top},-1),br:new Ue(this.worksheet,{col:e.right,row:e.bottom},0),editAs:`oneCell`})}else n&&(this.range={tl:new Ue(this.worksheet,n.tl,0),br:n.br?new Ue(this.worksheet,n.br,0):void 0,ext:n.ext,editAs:n.editAs,hyperlinks:r||(`hyperlinks`in n?n.hyperlinks:void 0)})}clone(t){let n=t??this.worksheet,r=new e(n);return r.type=this.type,r.imageId=this.imageId,this.range&&(r.range={tl:this.range.tl.clone(n),br:this.range.br?this.range.br.clone(n):void 0,ext:this.range.ext?{...this.range.ext}:void 0,editAs:this.range.editAs,hyperlinks:this.range.hyperlinks?{...this.range.hyperlinks}:void 0}),r}};let Ge=/^[A-Za-z]{1,3}\d+$/,Ke=/^[Rr]\d+[Cc]\d+$/,qe=new Set([`C`,`c`,`R`,`r`]),Je=/\s/g,Ye=/[^\p{L}\p{N}_.]/gu,Xe=/^[\p{L}_\\]/u;function Ze(e){let t=e.replace(Je,`_`),n=!1;return t.startsWith(`\\`)&&(n=!0,t=t.slice(1)),t=t.replace(Ye,``),n&&(t=`\\${t}`),t.length>0&&!Xe.test(t)&&(t=`_${t}`),t.length===0?`_Table`:(t.length===1&&qe.has(t)&&(t=`_${t}`),(Ge.test(t)||Ke.test(t))&&(t=`_${t}`),t.length>255&&(t=t.slice(0,255)),t)}var Qe=class{constructor(e,t,n){this.table=e,this.column=t,this.index=n}_set(e,t){this.table.cacheState(),this.column[e]=t}get name(){return this.column.name}set name(e){this._set(`name`,e)}get filterButton(){return this.column.filterButton}set filterButton(e){this.column.filterButton=e}get style(){return this.column.style}set style(e){this.column.style=e}get totalsRowLabel(){return this.column.totalsRowLabel}set totalsRowLabel(e){this._set(`totalsRowLabel`,e)}get totalsRowFunction(){return this.column.totalsRowFunction}set totalsRowFunction(e){this._set(`totalsRowFunction`,e)}get totalsRowResult(){return this.column.totalsRowResult}set totalsRowResult(e){this._set(`totalsRowResult`,e)}get totalsRowFormula(){return this.column.totalsRowFormula}set totalsRowFormula(e){this._set(`totalsRowFormula`,e)}},$e=class e{constructor(e,t){if(this.worksheet=e,t){if(this.table=t,Array.isArray(t.rows)&&t.rows.length===0&&t.tableRef){let n=S.decode(t.tableRef);if(`dimensions`in n){let r=n.top+(t.headerRow===!1?0:1),i=n.bottom-(t.totalsRow===!0?1:0);if(i>=r)for(let a=r;a<=i;a++){let r=e.getRow(a),i=[];for(let e=n.left;e<=n.right;e++)i.push(r.getCell(e).value);t.rows.push(i)}}}this.validate(),this.store()}}static{this.SUBTOTAL_FUNCTIONS={average:101,countNums:102,count:103,max:104,min:105,stdDev:106,var:107,sum:109}}getFormula(t){if(t.totalsRowFunction===`none`)return null;if(t.totalsRowFunction===`custom`)return t.totalsRowFormula??null;let n=t.totalsRowFunction?e.SUBTOTAL_FUNCTIONS[t.totalsRowFunction]:void 0;if(n!==void 0)return`SUBTOTAL(${n},${this.table.name}[${t.name}])`;throw new te(`Invalid Totals Row Function: ${t.totalsRowFunction}`)}get width(){return this.table.columns.length}get height(){return this.table.rows.length}get filterHeight(){return this.height+(this.table.headerRow?1:0)}get tableHeight(){return this.filterHeight+(this.table.totalsRow?1:0)}validate(){let{table:e}=this,t=(e,t,n)=>{e[t]===void 0&&(e[t]=n)};t(e,`headerRow`,!0),t(e,`totalsRow`,!1),t(e,`style`,{});let n=e.style;t(n,`theme`,`TableStyleMedium2`),t(n,`showFirstColumn`,!1),t(n,`showLastColumn`,!1),t(n,`showRowStripes`,!1),t(n,`showColumnStripes`,!1),e.name&&=Ze(e.name),e.displayName&&=Ze(e.displayName);let r=(e,t)=>{if(!e)throw new te(t)};r(!!e.name,`Table must have a name`),r(!!e.ref,`Table must have ref`),r(!!e.columns,`Table must have column definitions`),r(!!e.rows,`Table must have row definitions`),e.tl=S.decodeAddress(e.ref);let{row:i,col:a}=e.tl;r(i>0,`Table must be on valid row`),r(a>0,`Table must be on valid col`);let{width:o,tableHeight:s}=this;e.autoFilterRef=S.encode(i,a,i,a+o-1),e.tableRef=S.encode(i,a,i+s-1,a+o-1),e.columns.forEach((e,n)=>{r(!!e.name,`Column ${n} must have a name`),n===0?t(e,`totalsRowLabel`,`Total`):(t(e,`totalsRowFunction`,`none`),e.totalsRowFormula=this.getFormula(e)??void 0)})}store(){let e=(e,t)=>{t&&Object.assign(e.style,t)},{worksheet:t,table:n}=this,{row:r,col:i}=n.tl,a=0;if(n.headerRow){let o=t.getRow(r+ a++);n.columns.forEach((t,n)=>{let{style:r,name:a}=t,s=o.getCell(i+n);s.value=a,e(s,r)})}if(n.rows.forEach(o=>{let s=t.getRow(r+ a++);o.forEach((t,r)=>{let a=s.getCell(i+r);if(typeof t==`object`&&t&&`formula`in t&&typeof t.formula==`string`){let e=t,r=n.qualifyImplicitStructuredReferences===!0;a.value={...e,formula:r?e.formula.replace(/(^|[^A-Za-z0-9_])\[@\[?([^\[\]]+?)\]?\]/g,`$1${n.name}[[#This Row],[$2]]`):e.formula}}else a.value=t;e(a,n.columns[r]?.style)})}),n.totalsRow){let o=t.getRow(r+ a++);n.columns.forEach((t,n)=>{let r=o.getCell(i+n);if(n===0)r.value=t.totalsRowLabel;else{let e=this.getFormula(t);e?r.value={formula:e,result:t.totalsRowResult}:r.value=null}e(r,t.style)})}}load(e){let{table:t}=this,{row:n,col:r}=t.tl,i=0;if(t.headerRow){let a=e.getRow(n+ i++);t.columns.forEach((e,t)=>{let n=a.getCell(r+t);n.value=e.name})}if(t.rows.forEach(t=>{let a=e.getRow(n+ i++);t.forEach((e,t)=>{let n=a.getCell(r+t);n.value=e})}),t.totalsRow){let a=e.getRow(n+ i++);t.columns.forEach((e,t)=>{let n=a.getCell(r+t);if(t===0)n.value=e.totalsRowLabel;else{let t=this.getFormula(e);t&&(n.value={formula:t,result:e.totalsRowResult})}})}}get model(){return this.table}set model(e){this.table=e}cacheState(){this._cache||={ref:this.ref,width:this.width,tableHeight:this.tableHeight}}commit(){if(!this._cache)return;this.validate();let e=S.decodeAddress(this._cache.ref);if(this.ref!==this._cache.ref)for(let t=0;t<this._cache.tableHeight;t++){let n=this.worksheet.getRow(e.row+t);for(let t=0;t<this._cache.width;t++){let r=n.getCell(e.col+t);r.value=null}}else{for(let t=this.tableHeight;t<this._cache.tableHeight;t++){let n=this.worksheet.getRow(e.row+t);for(let t=0;t<this._cache.width;t++){let r=n.getCell(e.col+t);r.value=null}}for(let t=0;t<this.tableHeight;t++){let n=this.worksheet.getRow(e.row+t);for(let t=this.width;t<this._cache.width;t++){let r=n.getCell(e.col+t);r.value=null}}}this.store(),this._cache=void 0}addRow(e,t,n){this.cacheState(),t===void 0?this.table.rows.push(e):this.table.rows.splice(t,0,e),n?.commit!==!1&&this.commit()}removeRows(e,t=1,n){this.cacheState(),this.table.rows.splice(e,t),n?.commit!==!1&&this.commit()}getColumn(e){let t=this.table.columns[e];return new Qe(this,t,e)}addColumn(e,t,n){this.cacheState(),n===void 0?(this.table.columns.push(e),this.table.rows.forEach((e,n)=>{e.push(t[n])})):(this.table.columns.splice(n,0,e),this.table.rows.forEach((e,r)=>{e.splice(n,0,t[r])}))}removeColumns(e,t=1){this.cacheState(),this.table.columns.splice(e,t),this.table.rows.forEach(n=>{n.splice(e,t)})}_assign(e,t,n){this.cacheState(),e[t]=n}get ref(){return this.table.ref}set ref(e){this._assign(this.table,`ref`,e)}get name(){return this.table.name}set name(e){this.cacheState(),this.table.name=Ze(e)}get displayName(){return this.table.displayName||this.table.name}set displayName(e){this.cacheState(),this.table.displayName=Ze(e)}get headerRow(){return this.table.headerRow}set headerRow(e){this._assign(this.table,`headerRow`,e)}get totalsRow(){return this.table.totalsRow}set totalsRow(e){this._assign(this.table,`totalsRow`,e)}_ensureStyle(){return this.table.style||(this.table.style={}),this.table.style}get theme(){return this.table.style?.theme}set theme(e){this._ensureStyle().theme=e}get showFirstColumn(){return this.table.style?.showFirstColumn}set showFirstColumn(e){this._ensureStyle().showFirstColumn=e}get showLastColumn(){return this.table.style?.showLastColumn}set showLastColumn(e){this._ensureStyle().showLastColumn=e}get showRowStripes(){return this.table.style?.showRowStripes}set showRowStripes(e){this._ensureStyle().showRowStripes=e}get showColumnStripes(){return this.table.style?.showColumnStripes}set showColumnStripes(e){this._ensureStyle().showColumnStripes=e}},et=class{constructor(e){this.model=e||{}}add(e,t){return this.model[e]=t}find(e){let t=this.model[e];if(t!==void 0)return t;let n;for(let t of Object.keys(this.model)){if(!t.startsWith(`range:`))continue;n||=S.decodeAddress(e);let r=t.slice(6),i=S.decodeEx(r);if(!(`dimensions`in i))continue;let{tl:a,br:o}=i,s=typeof a==`string`?S.decodeAddress(a):a,c=typeof o==`string`?S.decodeAddress(o):o;if(n.row>=s.row&&n.row<=c.row&&n.col>=s.col&&n.col<=c.col)return this.model[t]}}remove(e){this.model[e]=void 0}};let tt=9525,nt=12700,rt=142875,it=28575,at=276225,ot=190500;var st=class e{constructor(e,t,n){this.worksheet=e;let{tl:r,br:i}=this._parseRange(t),a=1025+(e.formControls?.length??0),o;n?.link&&(o=this._toAbsoluteRef(n.link)),this.model={shapeId:a,ctrlPropId:0,tl:r,br:i,link:o,checked:n?.checked?`Checked`:`Unchecked`,text:n?.text??``,noThreeD:n?.noThreeD??!0,print:n?.print??!1}}get checked(){return this.model.checked===`Checked`}set checked(e){this.model.checked=e?`Checked`:`Unchecked`}get link(){return this.model.link}set link(e){this.model.link=e?this._toAbsoluteRef(e):void 0}get text(){return this.model.text}set text(e){this.model.text=e}_toAbsoluteRef(e){if(e.includes(`$`))return e;let t=S.decodeAddress(e);return`$${S.n2l(t.col)}$${t.row}`}_parseRange(e){let t,n;if(typeof e==`string`)if(e.includes(`:`)){let r=S.decode(e);if(`top`in r)if(r.left===r.right&&r.top===r.bottom){let e=r.left-1,i=r.top-1;t={col:e,colOff:rt,row:i,rowOff:it},n={col:e+2,colOff:at,row:i+1,rowOff:ot}}else t={col:r.left-1,colOff:rt,row:r.top-1,rowOff:it},n={col:r.right-1,colOff:at,row:r.bottom-1,rowOff:ot};else t={col:r.col-1,colOff:rt,row:r.row-1,rowOff:it},n={col:r.col+1,colOff:at,row:r.row,rowOff:ot}}else{let r=S.decodeAddress(e);t={col:r.col-1,colOff:rt,row:r.row-1,rowOff:it},n={col:r.col+1,colOff:at,row:r.row,rowOff:ot}}else if(`startCol`in e)t={col:e.startCol,colOff:e.startColOff??rt,row:e.startRow,rowOff:e.startRowOff??it},n={col:e.endCol,colOff:e.endColOff??at,row:e.endRow,rowOff:e.endRowOff??ot};else{if(typeof e.tl==`string`){let n=S.decodeAddress(e.tl);t={col:n.col-1,colOff:rt,row:n.row-1,rowOff:it}}else t={col:e.tl.col,colOff:e.tl.colOff??rt,row:e.tl.row,rowOff:e.tl.rowOff??it};if(e.br)if(typeof e.br==`string`){let t=S.decodeAddress(e.br);n={col:t.col-1,colOff:at,row:t.row-1,rowOff:ot}}else n={col:e.br.col,colOff:e.br.colOff??at,row:e.br.row,rowOff:e.br.rowOff??ot};else n={col:t.col+2,colOff:at,row:t.row+1,rowOff:ot}}return{tl:t,br:n}}getVmlAnchor(){return e.getVmlAnchor(this.model)}getVmlStyle(){return e.getVmlStyle(this.model)}getVmlCheckedValue(){return e.getVmlCheckedValue(this.model)}static getVmlAnchor(e){let{tl:t,br:n}=e,r=Math.round(t.colOff/tt),i=Math.round(t.rowOff/tt),a=Math.round(n.colOff/tt),o=Math.round(n.rowOff/tt);return`${t.col}, ${r}, ${t.row}, ${i}, ${n.col}, ${a}, ${n.row}, ${o}`}static getVmlStyle(e){return`position:absolute;margin-left:${Math.round(e.tl.colOff/nt)}pt;margin-top:${Math.round(e.tl.rowOff/nt)}pt;width:96pt;height:18pt;z-index:1;visibility:visible`}static getVmlCheckedValue(e){switch(e.checked){case`Checked`:return 1;case`Mixed`:return 2;default:return 0}}};function ct(){return typeof process<`u`&&!!process.versions?.node}function lt(e){if(ct())return Buffer.from(e,`base64`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function ut(e,t){return 25569+e.getTime()/(24*3600*1e3)-(t?1462:0)}function dt(e,t){let n=Math.round((e-25569+(t?1462:0))*24*3600*1e3);return new Date(n)}function ft(e){return new Date(e.endsWith(`Z`)?e:e+`Z`)}let pt=/_x([0-9A-Fa-f]{4})_/g;function mt(e){return e.replace(pt,(e,t)=>String.fromCharCode(parseInt(t,16)))}function ht(e){return e.replace(pt,`_x005F_x$1_`)}let gt=/[\t\n\r]/g,_t={" ":`_x0009_`,"\n":`_x000A_`,"\r":`_x000D_`};function vt(e){let t=e.replace(pt,`_x005F_x$1_`);return t=t.replace(gt,e=>_t[e]),t}let yt={lt:`<`,gt:`>`,amp:`&`,quot:`"`,apos:`'`};function bt(e){return e.indexOf(`&`)===-1?e:e.replace(/&(#\d+|#x[0-9A-Fa-f]+|\w+);/g,(e,t)=>{if(t[0]===`#`){let n=t[1]===`x`?parseInt(t.slice(2),16):parseInt(t.slice(1));return Number.isNaN(n)?e:String.fromCodePoint(n)}return yt[t]||e})}let xt=/[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/;function D(e){let t=xt.exec(e);if(!t)return e;let n=[],r=0;for(let i=t.index;i<e.length;i++){let t=e.charCodeAt(i),a;switch(t){case 34:a=`&quot;`;break;case 38:a=`&amp;`;break;case 39:a=`&apos;`;break;case 60:a=`&lt;`;break;case 62:a=`&gt;`;break;case 127:a=``;break;default:if(t<=31&&(t<=8||t>=11&&t!==13)){a=``;break}continue}r!==i&&n.push(e.substring(r,i)),r=i+1,a&&n.push(a)}return r<e.length&&n.push(e.substring(r)),n.join(``)}function St(e){let t=typeof e==`number`?e:parseInt(e,10);return Number.isNaN(t)?0:t}function Ct(e){let t=[],n=``,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];o===`"`&&!i?(r=!r,n+=o):o===`[`&&!r?(i=!0,n+=o):o===`]`&&!r?(i=!1,n+=o):o===`;`&&!r&&!i?(t.push(n),n=``):n+=o}return t.push(n),t}let wt=/[ymdhMsb]/,Tt=/\[[^\]]*\]|"[^"]*"/g;function Et(e){if(!e)return!1;let t=Ct(e)[0].replace(Tt,``);return t.indexOf(`@`)>-1?!1:wt.test(t)}function Dt(e){return e===!0||e===`true`||e===1||e===`1`}function*Ot(e,t,n=1){let r=n>0?(e,t)=>e<t:(e,t)=>e>t;for(let i=e;r(i,t);i+=n)yield i}function kt(e){let t=Array.from(e);return t.length<=1?t:t.every(e=>Number.isFinite(e))?t.sort((e,t)=>e-t):t.every(e=>e instanceof Date)?t.sort((e,t)=>e.getTime()-t.getTime()):t.sort((e,t)=>{let n=At(e),r=At(t);return n===r?n===0?e-t:n===1?e.getTime()-t.getTime():String(e).localeCompare(String(t)):n-r})}function At(e){return Number.isFinite(e)?0:e instanceof Date?1:2}let jt=new TextDecoder(`utf-8`),Mt,Nt=!1;function Pt(){if(!Nt){Nt=!0;try{Mt=new TextDecoder(`latin1`)}catch{Mt=void 0}}return Mt}function Ft(e){return typeof e==`string`?e:jt.decode(e)}function It(e){if(ct())return Buffer.from(e).toString(`base64`);if(Pt())try{return btoa(Mt.decode(e))}catch{}let t=32768,n=[];for(let r=0;r<e.length;r+=t)n.push(String.fromCharCode.apply(null,e.subarray(r,r+t)));return btoa(n.join(``))}function Lt(e){let t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>8&255}return t}let Rt=new TextEncoder,zt=new TextDecoder(`utf-8`,{ignoreBOM:!0}),Bt=new Map;function Vt(e){let t=(e??`utf-8`).trim().toLowerCase();return t===``||t===`utf8`||t===`utf-8`?`utf-8`:t===`utf16le`||t===`utf-16le`||t===`ucs2`||t===`ucs-2`?`utf-16le`:t===`binary`?`latin1`:t}function Ht(e){let t=Vt(e);if(t===`utf-8`)return zt;let n=Bt.get(t);return n||(n=Ut(t),Bt.set(t,n)),n}function Ut(e,t){try{return new TextDecoder(e,t)}catch(t){throw TypeError(`Unsupported text encoding: ${e}`,{cause:t})}}function Wt(e){let t=Vt(e);switch(t){case`hex`:return new Gt;case`base64`:return new Yt(!1);case`base64url`:return new Yt(!0);case`ascii`:return new Xt;default:return Ut(t,{ignoreBOM:!0})}}var Gt=class{decode(e){let t=``;for(let n=0;n<e.length;n++)t+=Kt[e[n]];return t}};let Kt=(()=>{let e=Array(256);for(let t=0;t<256;t++)e[t]=t.toString(16).padStart(2,`0`);return e})(),qt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Jt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`;var Yt=class{constructor(e){this._remainder=null,this._chars=e?Jt:qt}decode(e,t){let n;if(this._remainder){let t=new Uint8Array(this._remainder.length+e.length);t.set(this._remainder),t.set(e,this._remainder.length),n=t}else n=e;if(t?.stream??!1){let e=n.length%3,t=n.length-e;return this._remainder=e>0?n.slice(t):null,t>0?this._encodeBytes(n,t):``}return this._remainder=null,n.length>0?this._encodeBytes(n,n.length):``}_encodeBytes(e,t){let n=this._chars,r=n===Jt,i=``,a=0;for(;a+2<t;a+=3){let t=e[a],r=e[a+1],o=e[a+2];i+=n[t>>>2]+n[(t&3)<<4|r>>>4]+n[(r&15)<<2|o>>>6]+n[o&63]}let o=t-a;if(o===1){let t=e[a];i+=n[t>>>2]+n[(t&3)<<4],r||(i+=`==`)}else if(o===2){let t=e[a],o=e[a+1];i+=n[t>>>2]+n[(t&3)<<4|o>>>4]+n[(o&15)<<2],r||(i+=`=`)}return i}},Xt=class{decode(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]&127);return t}};function Zt(e){let t=``;for(let n=0;n<e.length;n++)t+=Kt[e[n]];return t}function Qt(e,t){let n=t?Jt:qt,r=``,i=0;for(;i+2<e.length;i+=3){let t=e[i],a=e[i+1],o=e[i+2];r+=n[t>>>2]+n[(t&3)<<4|a>>>4]+n[(a&15)<<2|o>>>6]+n[o&63]}let a=e.length-i;if(a===1){let a=e[i];r+=n[a>>>2]+n[(a&3)<<4],t||(r+=`==`)}else if(a===2){let a=e[i],o=e[i+1];r+=n[a>>>2]+n[(a&3)<<4|o>>>4]+n[(o&15)<<2],t||(r+=`=`)}return r}function $t(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]&127);return t}function en(e,t){let n=Vt(t);switch(n){case`hex`:return Zt(e);case`base64`:return Qt(e,!1);case`base64url`:return Qt(e,!0);case`ascii`:return $t(e);default:return Ht(n).decode(e)}}function tn(e){return Rt.encode(e)}function nn(e,t){return Ht(t).decode(e)}function O(e,t){let n=e.length;if(n===0)return new Uint8Array;if(n===1){let t=e[0];return t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}if(t===void 0){let r=0;for(let t=0;t<n;t++)r+=e[t].length;t=r}let r=new Uint8Array(t),i=0;for(let t=0;t<n;t++){let n=e[t];r.set(n,i),i+=n.length}return r}function rn(e){if(e instanceof Uint8Array)return e;if(typeof e==`string`)return Rt.encode(e);if(e instanceof ArrayBuffer||Array.isArray(e))return new Uint8Array(e);throw TypeError(`Expected Uint8Array, got ${typeof e}`)}function an(e){let t=globalThis.Buffer;return t?t.from(e.buffer,e.byteOffset,e.byteLength):e}function on(e){let t=new Uint8Array(4);return t[0]=e&255,t[1]=e>>8&255,t[2]=e>>16&255,t[3]=e>>24&255,t}let sn={async hash(e,...t){let n=O(t),r=await crypto.subtle.digest(e,new Uint8Array(n));return new Uint8Array(r)},async convertPasswordToHash(e,t,n,r){let i=Lt(e),a=lt(n),o=await this.hash(t,a,i);for(let e=0;e<r;e++)o=await this.hash(t,o,on(e));return It(o)},randomBytes(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}};var cn=class{constructor(e){this.code=e}toString(){return`#${this.code}`}};let ln={sum:`Sum`,count:`Count`,average:`Average`,max:`Max`,min:`Min`,product:`Product`,countNums:`Count Numbers`,stdDev:`StdDev`,stdDevP:`StdDevP`,var:`Var`,varP:`VarP`},un=new Set(Object.keys(ln));function dn(e){let t=e.model;if(t.headerRow===!1)throw new x(`Cannot create pivot table from a table without headers. Set headerRow: true on the table.`);if(!t.rows||t.rows.length===0)throw new x(`Cannot create pivot table from an empty table. Add data rows to the table.`);let n=t.columns.map(e=>e.name),r=new Set;for(let e of n){if(r.has(e))throw new x(`Duplicate column name "${e}" found in table. Pivot tables require unique column names.`);r.add(e)}let i=[void 0,...n],a=t.rows.map(e=>[void 0,...e]),o=t.tl;if(!o)throw Error(`Table "${t.name}" is missing top-left cell address (tl)`);let s=o.row,c=o.col,l=s+t.rows.length,u=c+n.length-1,d=S.encode(s,c,l,u);return{name:e.worksheet.name,tableName:t.name,getRow(e){if(e===1)return{values:i};let t=e-2;return t>=0&&t<a.length?{values:a[t]}:{values:[]}},getColumn(e){if(e<1||e>n.length)return{values:[]};let r=[];r[1]=n[e-1];for(let n=0;n<t.rows.length;n++)r[n+2]=t.rows[n][e-1];return{values:r}},getSheetValues(){let e=[];e[1]=i;for(let t=0;t<a.length;t++)e[t+2]=a[t];return e},dimensions:{shortRange:d}}}function fn(e){if(e.sourceSheet&&e.sourceTable)throw new x(`Cannot specify both sourceSheet and sourceTable. Choose one.`);if(e.sourceTable)return dn(e.sourceTable);if(!e.sourceSheet)throw Error(`Either sourceSheet or sourceTable must be provided.`);return e.sourceSheet}function pn(e){return typeof e==`string`?e:e.name}function mn(e){return typeof e==`string`?void 0:e.metric}function hn(e,t){let n=fn(t);gn(t,n);let{rows:r}=t,i=t.columns??[],a=t.pages??[],o=t.values.map(pn),s=t.metric??`sum`,c=t.values.map(e=>mn(e)??s),l=vn(n,[...r,...i,...a],o),u={};for(let e=0;e<l.length;e++)u[l[e].name]=e;let d=(e,t)=>{let n=u[e];if(n===void 0)throw Error(`${t} field "${e}" not found in cache fields`);return n},f=r.map(e=>d(e,`Row`)),p=i.map(e=>d(e,`Column`)),m=o.map(e=>d(e,`Value`)),h=a.map(e=>d(e,`Page`)),g=e.workbook.pivotTables.map(e=>e.tableNumber).filter(e=>Number.isFinite(e)),_=g.length>0?g.reduce((e,t)=>e>t?e:t,-1/0)+1:1,v=e.workbook.pivotTables.map(e=>parseInt(e.cacheId,10)).filter(e=>Number.isFinite(e)),y=v.length>0?v.reduce((e,t)=>e>t?e:t,-1/0)+1:10+_-1;return{source:n,rows:f,columns:p,values:m,pages:h,metric:s,valueMetrics:c,cacheFields:l,cacheId:String(y),applyWidthHeightFormats:t.applyWidthHeightFormats??`1`,tableNumber:_}}function gn(e,t){let n=e.columns??[],r=e.pages??[],i=e.values.map(pn),a=t.getRow(1).values.slice(1);for(let e=0;e<a.length;e++){let n=a[e];if(n==null||n===``||typeof n==`string`&&n.trim()===``)throw Error(`Empty or missing header name at column ${e+1} in ${t.name}. Pivot tables require all columns to have non-empty headers.`)}let o=new Set;for(let e of a){let n=String(e);if(o.has(n))throw Error(`Duplicate header name "${n}" found in ${t.name}. Pivot tables require unique column names.`);o.add(n)}let s=new Set(a.map(String)),c=e=>{if(!s.has(e))throw new x(`The header name "${e}" was not found in ${t.name}.`)};for(let t of e.rows)c(t);for(let e of n)c(e);for(let e of i)c(e);for(let e of r)c(e);let l=new Map,u=[{name:`rows`,fields:e.rows},{name:`columns`,fields:n},{name:`pages`,fields:r}];for(let e of u)for(let t of e.fields){let n=l.get(t);if(n===e.name)throw Error(`Duplicate field "${t}" in ${e.name}. Each field can only appear once per axis area.`);if(n)throw Error(`Field "${t}" cannot appear in both ${n} and ${e.name}. Each field can only be assigned to one axis area.`);l.set(t,e.name)}if(!e.rows.length)throw new x(`No pivot table rows specified.`);if(e.values.length<1)throw new x(`Must have at least one value.`);if(e.metric!==void 0&&!un.has(e.metric))throw Error(`Invalid metric "${e.metric}". Must be one of: ${[...un].join(`, `)}.`);for(let t of e.values){let e=mn(t);if(e!==void 0&&!un.has(e))throw Error(`Invalid metric "${e}" on value field "${pn(t)}". Must be one of: ${[...un].join(`, `)}.`)}let d=new Set;for(let e of i){if(d.has(e))throw Error(`Duplicate value field "${e}". Each value field name must be unique.`);d.add(e)}}function _n(e){if(e==null)return null;if(typeof e!=`object`||e instanceof Date||e instanceof cn)return e;let t=e;if(typeof t.error==`string`){let e=t.error;return new cn(e.startsWith(`#`)?e.slice(1):e)}if(`formula`in t||`sharedFormula`in t){let e=t.result;return e==null?null:_n(e)}return Array.isArray(t.richText)?t.richText.map(e=>e.text??``).join(``):typeof t.text==`string`&&typeof t.hyperlink==`string`?t.text:typeof t.checkbox==`boolean`?t.checkbox:String(e)}function vn(e,t,n){let r=e.getRow(1).values,i=new Set(t),a=new Set(n),o=t=>{let n=e.getColumn(t).values,r=new Set,i=new Map,a=!1;for(let e=2;e<n.length;e++){let t=_n(n[e]);t===null||typeof t==`number`&&isNaN(t)?a=!0:t instanceof cn?i.has(t.code)||(i.set(t.code,t),r.add(t)):r.add(t)}let o=kt(r);return a&&o.push(null),o},s=t=>{let n=e.getColumn(t).values,r=1/0,i=-1/0,a=!1,o=!0;for(let e=2;e<n.length;e++){let t=_n(n[e]);typeof t==`number`&&!isNaN(t)&&(a=!0,t<r&&(r=t),t>i&&(i=t),Number.isInteger(t)||(o=!1))}return a?{minValue:r,maxValue:i,allInteger:o}:null},c=[];for(let e of Ot(1,r.length)){let t=r[e],n=String(t);if(i.has(n))c.push({name:n,sharedItems:o(e)});else if(a.has(n)){let t=s(e);c.push({name:n,sharedItems:null,containsNumber:t?`1`:void 0,minValue:t?.minValue,maxValue:t?.maxValue,containsInteger:t?.allInteger?`1`:void 0})}else c.push({name:n,sharedItems:null})}return c}function yn(e,t,n,r,i){let a=i(e,t)?.style?.border,o=r-t+1,s=n-e+1,c=Array(o),l=Array(o),u=Array(s),d=Array(s),f=!1;for(let o=t;o<=r;o++){let r=o-t,s=i(e,o)?.style?.border;c[r]=s?.top||a?.top,n===e?l[r]=s?.bottom||a?.bottom:l[r]=i(n,o)?.style?.border?.bottom||a?.bottom,(c[r]||l[r])&&(f=!0)}for(let o=e;o<=n;o++){let n=o-e,s=i(o,t)?.style?.border;u[n]=s?.left||a?.left,r===t?d[n]=s?.right||a?.right:d[n]=i(o,r)?.style?.border?.right||a?.right,(u[n]||d[n])&&(f=!0)}let p=a?.diagonal,m=a?.color;if(!(!f&&!p))return{topEdges:c,bottomEdges:l,leftEdges:u,rightEdges:d,diagonal:p,color:m}}function bn(e,t,n,r,i,a){let{topEdges:o,bottomEdges:s,leftEdges:c,rightEdges:l,diagonal:u,color:d}=i,f=a(e,t).style;for(let i=e;i<=n;i++)for(let p=t;p<=r;p++){let m=a(i,p),h=Re(f)||{},g={},_=!1;i===e&&o[p-t]&&(g.top=o[p-t],_=!0),i===n&&s[p-t]&&(g.bottom=s[p-t],_=!0),p===t&&c[i-e]&&(g.left=c[i-e],_=!0),p===r&&l[i-e]&&(g.right=l[i-e],_=!0),u&&(g.diagonal=u,_=!0),_?(d&&(g.color=d),h.border=g):delete h.border,m.style=h}}function xn(e,t){let n=Math.round(e).toString();for(;n.length<t;)n=`0`+n;return n}function Sn(e){if(e.length<=3)return e;let t=e.length%3,n=e.substring(0,t);for(let r=t;r<e.length;r+=3)n+=(n.length>0?`,`:``)+e.substring(r,r+3);return n}function Cn(e,t){let n=10**t;return Math.round(e*n)/n}function wn(e){let t=e.replace(/_./g,` `);return t=t.replace(/\*./g,``),t}function Tn(e){return/^General$/i.test(e.trim())}function En(e){let t=e.replace(/\[[^\]]*\]/g,``);return/[ymdhs]/i.test(t)&&!/^[#0.,E%$\s()\-+]+$/i.test(t)}let Dn=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],On=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],kn=[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],An=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],jn=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`];function Mn(e,t){let n=Math.round(e*86400)%86400,r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60,o=dt(e,!1),s=o.getUTCFullYear(),c=o.getUTCMonth(),l=o.getUTCDate(),u=o.getUTCDay(),d=e*86400-Math.floor(e*86400),f=/AM\/PM|A\/P/i.test(t),p=r>=12,m=r%12||12,h=t.replace(/\[(Red|Green|Blue|Yellow|Magenta|Cyan|White|Black|Color\d+)\]/gi,``);h=wn(h);let g=h.match(/ss\.(0+)/i),_=``;if(g){let e=g[1].length;_=Math.round(d*10**e).toString().padStart(e,`0`),h=h.replace(/ss\.0+/gi,`\0SF\0`)}h=h.replace(/yyyy/gi,`\0Y4\0`),h=h.replace(/yy/gi,`\0Y2\0`),h=h.replace(/mmmmm/gi,`\0MN5\0`),h=h.replace(/mmmm/gi,`\0MN4\0`),h=h.replace(/mmm/gi,`\0MN3\0`),h=h.replace(/dddd/gi,`\0DN4\0`),h=h.replace(/ddd/gi,`\0DN3\0`),h=h.replace(/dd/gi,`\0D2\0`),h=h.replace(/\bd\b/gi,`\0D1\0`),h=h.replace(/hh/gi,`\0H2\0`),h=h.replace(/\bh\b/gi,`\0H1\0`),h=h.replace(/ss/gi,`\0S2\0`),h=h.replace(/\bs\b/gi,`\0S1\0`),h=/\x00H[12]\x00.*mm|mm.*\x00S[12]\x00/i.test(h)?h.replace(/mm/gi,`\0MI2\0`):h.replace(/mm/gi,`\0M2\0`),h=h.replace(/\bm\b/gi,`\0M1\0`),h=h.replace(/AM\/PM/gi,`\0AMPM\0`),h=h.replace(/A\/P/gi,`\0AP\0`);let v=f?m:r;return h=h.replace(/\x00Y4\x00/g,s.toString()).replace(/\x00Y2\x00/g,(s%100).toString().padStart(2,`0`)).replace(/\x00MN5\x00/g,kn[c]).replace(/\x00MN4\x00/g,On[c]).replace(/\x00MN3\x00/g,Dn[c]).replace(/\x00M2\x00/g,(c+1).toString().padStart(2,`0`)).replace(/\x00M1\x00/g,(c+1).toString()).replace(/\x00DN4\x00/g,jn[u]).replace(/\x00DN3\x00/g,An[u]).replace(/\x00D2\x00/g,l.toString().padStart(2,`0`)).replace(/\x00D1\x00/g,l.toString()).replace(/\x00H2\x00/g,v.toString().padStart(2,`0`)).replace(/\x00H1\x00/g,v.toString()).replace(/\x00MI2\x00/g,i.toString().padStart(2,`0`)).replace(/\x00S2\x00/g,a.toString().padStart(2,`0`)).replace(/\x00S1\x00/g,a.toString()).replace(/\x00SF\x00/g,a.toString().padStart(2,`0`)+`.`+_).replace(/\x00AMPM\x00/g,p?`PM`:`AM`).replace(/\x00AP\x00/g,p?`P`:`A`),h=h.replace(/\\/g,``),h}function Nn(e){return typeof e==`boolean`?e?`TRUE`:`FALSE`:typeof e==`string`?e:Number.isInteger(e)?e.toString():e.toPrecision(11).replace(/\.?0+$/,``).replace(/\.?0+e/,`e`)}function Pn(e,t){let n=(t.match(/%/g)??[]).length;return zn(e*100**n,t.replace(/%/g,``)||`0`)+`%`.repeat(n)}function Fn(e,t){let n=e<0?`-`:``,r=Math.abs(e);if(r===0){let e=t.match(/\.([0#]+)E/i),n=e?e[1].length:2;return`0.`+`0`.repeat(n)+`E+00`}let i=t.match(/\.([0#]+)E/i),a=i?i[1].length:2,o=t.includes(`E+`),s=Math.floor(Math.log10(r)),c=Cn(r/10**s,a).toFixed(a),l=s>=0?o?`+`:``:`-`,u=xn(Math.abs(s),2);return n+c+`E`+l+u}function In(e,t){let n=e<0?-1:1,r=Math.abs(e),i=Math.floor(r);if(r-=i,r<1e-10)return[n*i,0,1];let a=0,o=1,s=1,c=0,l=Math.floor(r),u=l,d=1;for(;c<t&&(l=Math.floor(r),u=l*o+a,d=l*c+s,!(r-l<1e-10));)r=1/(r-l),a=o,o=u,s=c,c=d;return d>t&&(d=c,u=o),[n*i,n*u,d]}function Ln(e,t){let n=e<0?`-`:``,r=Math.abs(e),i=t.match(/\?+\s*\/\s*(\d+)/);if(i){let e=parseInt(i[1],10),a=Math.floor(r),o=r-a,s=Math.round(o*e);return t.includes(`#`)||t.includes(`0`)?s===0?n+a.toString():n+(a>0?a+` `:``)+s+`/`+e:n+(a*e+s)+`/`+e}let a=t.match(/\/\s*(\?+)/),[o,s,c]=In(r,10**(a?a[1].length:2)-1);return t.includes(`#`)&&o!==0?s===0?n+Math.abs(o).toString():n+Math.abs(o)+` `+Math.abs(s)+`/`+c:s===0?o===0?`0`:n+Math.abs(o).toString():n+(Math.abs(o)*c+Math.abs(s))+`/`+c}function Rn(e,t){let n=Math.round(e*86400),r=Math.floor(n/60),i=Math.floor(r/60),a=n%60,o=r%60,s=i,c=t;return/\[h+\]/i.test(c)&&(c=c.replace(/\[h+\]/gi,s.toString())),/\[m+\]/i.test(c)&&(c=c.replace(/\[m+\]/gi,r.toString())),/\[s+\]/i.test(c)&&(c=c.replace(/\[s+\]/gi,n.toString())),c=c.replace(/mm/gi,o.toString().padStart(2,`0`)),c=c.replace(/ss/gi,a.toString().padStart(2,`0`)),c}function zn(e,t){let n=Math.abs(e),r=e<0?`-`:``,i=0,a=t;for(;a.endsWith(`,`);)i++,a=a.slice(0,-1);let o=n/1e3**i,s=a.indexOf(`.`),c=a,l=``;s!==-1&&(c=a.substring(0,s),l=a.substring(s+1));let u=l.replace(/[^0#?]/g,``).length,[d,f=``]=Cn(o,u).toString().split(`.`),p=/[0#?][^0#?,.\s][0#?]/.test(c),m;if(p){let e=c.replace(/[^0#?]/g,``).length,t=d;t.length<e&&(t=`0`.repeat(e-t.length)+t),m=``;let n=t.length-e;for(let e=0;e<c.length;e++){let r=c[e];r===`0`||r===`#`||r===`?`?n<t.length&&(m+=t[n],n++):r!==`,`&&(m+=r)}}else{m=d,c.includes(`,`)&&(m=Sn(d));let e=(c.match(/0/g)??[]).length;m.length<e&&(m=`0`.repeat(e-m.length)+m)}let h=``;return u>0&&(h=`.`+(f+`0`.repeat(u)).substring(0,u)),r+m+h}function Bn(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`"`){for(n++;n<e.length&&e[n]!==`"`;)t+=e[n],n++;n++}else e[n]===`\\`&&n+1<e.length?(n++,t+=e[n],n++):(t+=e[n],n++);return t}function Vn(e,t){let n=t.match(/\[(=|>|<|>=|<=|<>)(-?\d+(?:\.\d*)?)\]/);if(!n)return!1;let r=n[1],i=parseFloat(n[2]);switch(r){case`=`:return e===i;case`>`:return e>i;case`<`:return e<i;case`>=`:return e>=i;case`<=`:return e<=i;case`<>`:return e!==i;default:return!1}}function Hn(e,t){if(typeof t==`string`){let n=Ct(e);return n.length>=4&&n[3]?Bn(n[3]).replace(/@/g,t):t}if(typeof t==`boolean`)return t?`TRUE`:`FALSE`;let n=Ct(e),r=/\[(=|>|<|>=|<=|<>)-?\d+(?:\.\d*)?\]/;if((n[0]&&r.test(n[0])||n[1]&&r.test(n[1]))&&n.length>=2){for(let e=0;e<Math.min(n.length,2);e++){let r=n[e].match(/\[(=|>|<|>=|<=|<>)-?\d+(?:\.\d*)?\]/);if(r&&Vn(t,r[0]))return n[e]}return n[n.length>2?2:1]}return n.length===1?n[0]:n.length===2?t>=0?n[0]:n[1]:t>0?n[0]:t<0?n[1]:n[2]||n[0]}function Un(e,t){let n=Ct(e);return n.length>=2&&n[1]===t}function Wn(e,t){if(t==null)return``;if(Tn(e))return Nn(t);if(typeof t==`string`)return Hn(e,t);if(typeof t==`boolean`)return t?`TRUE`:`FALSE`;let n=t,r=Hn(e,n);n<0&&Un(e,r)&&(n=Math.abs(n));let i=r.replace(/\[(Red|Green|Blue|Yellow|Magenta|Cyan|White|Black|Color\d+)\]/gi,``);if(i=i.replace(/\[(>|<|>=|<=|=|<>)-?\d+(\.\d+)?\]/g,``),i=i.replace(/\[\$[^\]]*\]/g,``),i=wn(i),i=Bn(i),/\[[hms]+\]/i.test(i))return Rn(n,i);if(En(i))return Mn(n,i);if(i.includes(`%`))return Pn(n,i);if(/E[+-]?/i.test(i))return Fn(n,i);if(/\?+\s*\/\s*[\d?]+/.test(i))return Ln(n,i);if(i.includes(`(`)&&i.includes(`)`)&&n<0){let e=i.replace(/\(|\)/g,``);return`(`+zn(-n,e)+`)`}if(i===`@`)return n.toString();let a=``,o=``,s=i.match(/^([^#0?.,]+)/);s&&(a=s[1],i=i.substring(s[0].length));let c=i.match(/([^#0?.,]+)$/);c&&!c[1].includes(`%`)&&(o=c[1],i=i.substring(0,i.length-c[0].length));let l=zn(n,i);return a+l+o}function Gn(e){let t=e.replace(/"[^"]*"/g,``);if(/\[[hms]\]/i.test(t))return!1;let n=t.replace(/\[[^\]]*\]/g,``),r=/[hs]/i.test(n)||/AM\/PM|A\/P/i.test(n);return/[yd]/i.test(n)||/m/i.test(n)&&!r?!1:r}function Kn(e){let t=e.replace(/"[^"]*"/g,``);if(/\[[hms]\]/i.test(t))return!1;let n=t.replace(/\[[^\]]*\]/g,``);return!!(/[yd]/i.test(n)||/m/i.test(n)&&!(/[hs]/i.test(n)||/AM\/PM|A\/P/i.test(n)))}function qn(e,t,n){if(e instanceof Date){let r=ut(e);return Gn(t)?(r%=1,r<0&&(r+=1),Wn(t,r)):Wn(n&&Kn(t)?n:t,r)}return Wn(t,e)}function Jn(e){return S.l2n(e.toUpperCase())-1}function Yn(e){return S.n2l(e+1)}function Xn(e){return parseInt(e,10)-1}function Zn(e){return String(e+1)}function Qn(e){let t=S.decodeAddress(e.toUpperCase());return{c:t.col-1,r:t.row-1}}function $n(e){return S.encodeAddress(e.r+1,e.c+1)}function er(e){let t=e.indexOf(`:`);if(t===-1){let t=Qn(e);return{s:t,e:{...t}}}return{s:Qn(e.slice(0,t)),e:Qn(e.slice(t+1))}}function tr(e,t){if(t===void 0){let t=e;return tr(t.s,t.e)}let n=$n(e),r=$n(t);return n===r?n:`${n}:${r}`}var nr=class{constructor(e){this._workbook=e.workbook,this.id=e.id??0,this.orderNo=e.orderNo??0,this.name=e.name||`sheet${this.id}`,this.state=e.state??`visible`,this._rows=[],this._columns=[],this._keys={},this._merges={},this.rowBreaks=[],this.colBreaks=[],this.properties={defaultRowHeight:15,outlineLevelCol:0,outlineLevelRow:0,...e.properties},this.pageSetup={margins:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},orientation:`portrait`,horizontalDpi:void 0,verticalDpi:void 0,fitToPage:!!(e.pageSetup&&(e.pageSetup.fitToWidth||e.pageSetup.fitToHeight)&&!e.pageSetup.scale),pageOrder:`downThenOver`,blackAndWhite:!1,draft:!1,cellComments:`None`,errors:`displayed`,scale:100,fitToWidth:1,fitToHeight:1,paperSize:void 0,showRowColHeaders:!1,showGridLines:!1,firstPageNumber:void 0,horizontalCentered:!1,verticalCentered:!1,rowBreaks:null,colBreaks:null,...e.pageSetup},this.headerFooter={differentFirst:!1,differentOddEven:!1,oddHeader:null,oddFooter:null,evenHeader:null,evenFooter:null,firstHeader:null,firstFooter:null,...e.headerFooter},this.dataValidations=new et,this.views=e.views??[],this.autoFilter=e.autoFilter??null,this._media=[],this.sheetProtection=null,this.tables={},this.pivotTables=[],this.conditionalFormattings=[],this.formControls=[]}get name(){return this._name}set name(e){if(e===void 0&&(e=`sheet${this.id}`),this._name!==e){if(typeof e!=`string`)throw new d(`The name has to be a string.`);if(e===``)throw new d(`The name can't be empty.`);if(e===`History`)throw new d(`The name "History" is protected. Please use a different name.`);if(/[*?:/\\[\]]/.test(e))throw new d(`Worksheet name ${e} cannot include any of the following characters: * ? : \\ / [ ]`);if(/(^')|('$)/.test(e))throw new d(`The first or last character of worksheet name cannot be a single quotation mark: ${e}`);if(e&&e.length>31&&(e=e.substring(0,31)),this._workbook.worksheets.find(t=>t&&t.name.toLowerCase()===e.toLowerCase()))throw new d(`Worksheet name already exists: ${e}`);this._name=e}}get workbook(){return this._workbook}destroy(){this._workbook.removeWorksheetEx(this)}get dimensions(){let e=new C;return this._rows.forEach(t=>{if(t){let n=t.dimensions;n&&e.expand(t.number,n.min,t.number,n.max)}}),e}get columns(){return this._columns}set columns(e){this._headerRowCount=e.reduce((e,t)=>{let n=Array.isArray(t.header)?t.header.length:t.header?1:0;return Math.max(e,n)},0);let t=1,n=this._columns=[];e.forEach(e=>{let r=new Be(this,t++,!1);n.push(r),r.defn=e})}getColumnKey(e){return this._keys[e]}setColumnKey(e,t){this._keys[e]=t}deleteColumnKey(e){delete this._keys[e]}eachColumnKey(e){Object.keys(this._keys).forEach(t=>e(this._keys[t],t))}getColumn(e){let t;if(typeof e==`string`){let n=this._keys[e];if(n)return n;t=S.l2n(e)}else t=e;if(t>this._columns.length){let e=this._columns.length+1;for(;e<=t;)this._columns.push(new Be(this,e++))}return this._columns[t-1]}spliceColumns(e,t,...n){for(let e of Object.values(this._merges))for(let t=e.top;t<=e.bottom;t++)for(let n=e.left;n<=e.right;n++){let e=this.findCell(t,n);e&&e.type===T.ValueType.Merge&&e.unmerge()}let r=this._rows.length;if(n.length>0)for(let i=0;i<r;i++){let r=n.map(e=>e[i]??null);this.getRow(i+1).splice(e,t,...r)}else this._rows.forEach(n=>{n&&n.splice(e,t)});let i=n.length-t,a=e+t,o=this._columns.length;if(i<0)for(let t=e+n.length;t<=o;t++)this.getColumn(t).defn=this.getColumn(t-i).defn;else if(i>0)for(let e=o;e>=a;e--)this.getColumn(e+i).defn=this.getColumn(e).defn;for(let t=e;t<e+n.length;t++)this.getColumn(t).defn=void 0;if(this.workbook.definedNames.spliceColumns(this.name,e,t,n.length),i!==0){for(let t of this._media)if(t.type===`image`&&t.range){let{tl:n,br:r}=t.range;n&&n.nativeCol>=e-1&&(n.nativeCol=Math.max(0,n.nativeCol+i)),r&&r.nativeCol>=e-1&&(r.nativeCol=Math.max(0,r.nativeCol+i))}}this._spliceMerges(`col`,e,t,n.length)}get lastColumn(){return this.getColumn(this.columnCount)}get columnCount(){let e=0;return this.eachRow(t=>{e=Math.max(e,t.cellCount)}),e}get actualColumnCount(){let e=[],t=0;return this.eachRow(n=>{n.eachCell(({col:n})=>{e[n]||(e[n]=!0,t++)})}),t}_commitRow(e){}get _lastRowNumber(){let e=this._rows,t=e.length;for(;t>0&&e[t-1]===void 0;)t--;return t}get _nextRow(){return this._lastRowNumber+1}get lastRow(){if(this._rows.length)return this._rows[this._rows.length-1]}findRow(e){return this._rows[e-1]}findRows(e,t){return this._rows.slice(e-1,e-1+t)}get rowCount(){return this._lastRowNumber}get actualRowCount(){let e=0;return this.eachRow(()=>{e++}),e}getRow(e){let t=this._rows[e-1];return t||=this._rows[e-1]=new ze(this,e),t}getRows(e,t){if(t<1)return;let n=[];for(let r=e;r<e+t;r++)n.push(this.getRow(r));return n}addRow(e,t=`n`){let n=this._nextRow,r=this.getRow(n);return r.values=e,this._setStyleOption(n,t[0]===`i`?t:`n`),r}addRows(e,t=`n`){let n=[];return e.forEach(e=>{n.push(this.addRow(e,t))}),n}insertRow(e,t,n=`n`){return this.spliceRows(e,0,t),this._setStyleOption(e,n),this.getRow(e)}insertRows(e,t,n=`n`){if(this.spliceRows(e,0,...t),n!==`n`)for(let r=0;r<t.length;r++)n[0]===`o`&&this.findRow(t.length+e+r)!==void 0?this._copyStyle(t.length+e+r,e+r,n[1]===`+`):n[0]===`i`&&this.findRow(e-1)!==void 0&&this._copyStyle(e-1,e+r,n[1]===`+`);return this.getRows(e,t.length)}_setStyleOption(e,t=`n`){t[0]===`o`&&this.findRow(e+1)!==void 0?this._copyStyle(e+1,e,t[1]===`+`):t[0]===`i`&&this.findRow(e-1)!==void 0&&this._copyStyle(e-1,e,t[1]===`+`)}_copyStyle(e,t,n=!1){let r=this.getRow(e),i=this.getRow(t);i.style=Re(r.style)??{},r.eachCell({includeEmpty:n},(e,t)=>{i.getCell(t).style=Re(e.style)??{}}),i.height=r.height}duplicateRow(e,t,n=!1){let r=this.getRow(e),i=Array.from({length:t}).fill(r.values),a=[];for(let t of Object.values(this._merges))t.top===e&&t.bottom===e&&a.push(t);let o=[],s=e-1;for(let e of this._media)e.type===`image`&&e.range&&e.range.tl.nativeRow===s&&o.push(e);this.spliceRows(e+1,n?0:t,...i);for(let n=0;n<t;n++){let t=this._rows[e+n];t.style=Re(r.style)??{},t.height=r.height,r.eachCell({includeEmpty:!0},(e,n)=>{t.getCell(n).style=Re(e.style)??{}})}if(a.length>0)for(let r=0;r<t;r++){let t=e+1+r;if(!n){let e=[];for(let[n,r]of Object.entries(this._merges))r.top<=t&&r.bottom>=t&&e.push(n);for(let t of e)this._unMergeMaster(this.getCell(t))}for(let e of a)this.mergeCellsWithoutStyle(t,e.left,t,e.right)}if(!n){let n=e,r=e+t-1;this._media=this._media.filter(e=>{if(e.type===`image`&&e.range){let t=e.range.tl.nativeRow;return t<n||t>r}return!0})}for(let e=0;e<t;e++){let t=e+1;for(let e of o){let n=e.clone();if(n.range.tl.nativeRow=s+t,n.range.br){let r=e.range.br.nativeRow-s;n.range.br.nativeRow=s+t+r}this._media.push(n)}}}spliceRows(e,t,...n){for(let e of Object.values(this._merges))for(let t=e.top;t<=e.bottom;t++)for(let n=e.left;n<=e.right;n++){let e=this.findCell(t,n);e&&e.type===T.ValueType.Merge&&e.unmerge()}let r=e+t,i=n.length,a=i-t,o=this._rows.length,s,c;if(a<0)for(e===o&&(this._rows[o-1]=void 0),s=r;s<=o;s++)if(c=this._rows[s-1],c){let e=this.getRow(s+a);e.values=c.values,e.style=Re(c.style)??{},e.height=c.height,c.eachCell({includeEmpty:!0},(t,n)=>{e.getCell(n).style=Re(t.style)??{}}),this._rows[s-1]=void 0}else this._rows[s+a-1]=void 0;else if(a>0)for(s=o;s>=r;s--)if(c=this._rows[s-1],c){let e=this.getRow(s+a);e.values=c.values,e.style=Re(c.style)??{},e.height=c.height,c.eachCell({includeEmpty:!0},(t,n)=>{e.getCell(n).style=Re(t.style)??{}})}else this._rows[s+a-1]=void 0;for(s=0;s<i;s++){let t=this.getRow(e+s);t.style={},t.values=n[s]}if(this.workbook.definedNames.spliceRows(this.name,e,t,i),a!==0){for(let t of this._media)if(t.type===`image`&&t.range){let{tl:n,br:r}=t.range;n&&n.nativeRow>=e-1&&(n.nativeRow=Math.max(0,n.nativeRow+a)),r&&r.nativeRow>=e-1&&(r.nativeRow=Math.max(0,r.nativeRow+a))}}this._spliceMerges(`row`,e,t,i)}eachRow(e,t){let n,r;if(typeof e==`function`?r=e:(n=e,r=t),n&&n.includeEmpty){let e=this._rows.length;for(let t=1;t<=e;t++)r(this.getRow(t),t)}else this._rows.forEach(e=>{e&&e.hasValues&&r(e,e.number)})}getSheetValues(){let e=[];return this._rows.forEach(t=>{t&&(e[t.number]=t.values)}),e}findCell(e,t){let n=S.getAddress(e,t),r=this._rows[n.row-1];return r?r.findCell(n.col):void 0}getCell(e,t){let n=S.getAddress(e,t);return this.getRow(n.row).getCellEx(n)}mergeCells(...e){let t=new C(e);this._mergeCellsInternal(t)}mergeCellsWithoutStyle(...e){let t=new C(e);this._mergeCellsInternal(t,!0)}_mergeCellsInternal(e,t){Object.values(this._merges).forEach(t=>{if(t.intersects(e))throw new h});let{top:n,left:r,bottom:i,right:a}=e,o=t?void 0:yn(n,r,i,a,(e,t)=>this.findCell(e,t)),s=this.getCell(e.top,e.left);for(let e=n;e<=i;e++)for(let i=r;i<=a;i++)(e>n||i>r)&&this.getCell(e,i).merge(s,t);o&&bn(n,r,i,a,o,(e,t)=>this.getCell(e,t)),this._merges[s.address]=e}_unMergeMaster(e){let t=this._merges[e.address];if(t){for(let e=t.top;e<=t.bottom;e++)for(let n=t.left;n<=t.right;n++)this.getCell(e,n).unmerge();delete this._merges[e.address]}}_spliceMerges(e,t,n,r){let i=r-n;if(i===0&&n===0)return;let a=t+n,o=e===`row`,s={};for(let e of Object.values(this._merges)){let{top:r,left:c,bottom:l,right:u}=e.model,d=o?r:c,f=o?l:u;if(i<=0&&n>0){let n=a-1;if(d>n){let e=o?new C(r+i,c,l+i,u):new C(r,c+i,l,u+i);s[S.encodeAddress(e.top,e.left)]=e}else if(f<t)s[S.encodeAddress(r,c)]=e;else if(!(d>=t&&f<=n)){let e=r,n=c,a=l,d=u;o?(e=r<t?r:t,a=Math.max(e,l+i)):(n=c<t?c:t,d=Math.max(n,u+i));let f=new C(e,n,a,d);e===a&&n===d||(s[S.encodeAddress(f.top,f.left)]=f)}}else if(d>=a){let e=o?new C(r+i,c,l+i,u):new C(r,c+i,l,u+i);s[S.encodeAddress(e.top,e.left)]=e}else f<a||(o?e.model.bottom=l+i:e.model.right=u+i),s[S.encodeAddress(r,c)]=e}this._merges=s;for(let e of Object.values(s)){let t=this.getCell(e.top,e.left);for(let n=e.top;n<=e.bottom;n++)for(let r=e.left;r<=e.right;r++)(n>e.top||r>e.left)&&this.getCell(n,r).merge(t,!0)}}get hasMerges(){return Object.values(this._merges).some(Boolean)}unMergeCells(...e){let t=new C(e);for(let e=t.top;e<=t.bottom;e++)for(let n=t.left;n<=t.right;n++){let t=this.findCell(e,n);t&&(t.type===T.ValueType.Merge?this._unMergeMaster(t.master):this._merges[t.address]&&this._unMergeMaster(t))}}fillFormula(e,t,n,r=`shared`){let{top:i,left:a,bottom:o,right:s}=S.decode(e),c=s-a+1,l=S.encodeAddress(i,a),u=r===`shared`,d;d=typeof n==`function`?n:Array.isArray(n)?Array.isArray(n[0])?(e,t)=>n[e-i][t-a]:(e,t)=>n[(e-i)*c+(t-a)]:()=>void 0;let f=!0;for(let n=i;n<=o;n++)for(let i=a;i<=s;i++)if(f){let a=this.getCell(n,i);a.value={shareType:r,formula:t,ref:e,result:d(n,i)},f=!1}else this.getCell(n,i).value=u?{sharedFormula:l,result:d(n,i)}:d(n,i)}addImage(e,t){let n={type:`image`,imageId:String(e),range:t};this._media.push(new We(this,n))}getImages(){return this._media.filter(e=>e.type===`image`)}addBackgroundImage(e){let t={type:`background`,imageId:String(e)};this._media.push(new We(this,t))}getBackgroundImageId(){let e=this._media.find(e=>e.type===`background`);return e&&e.imageId}addFormCheckbox(e,t){let n=new st(this,e,t);return this.formControls.push(n),n}getFormCheckboxes(){return this.formControls}async protect(e,t){this.sheetProtection={sheet:!0},t&&`spinCount`in t&&(t.spinCount=Number.isFinite(t.spinCount)?Math.round(Math.max(0,t.spinCount)):1e5),e&&(this.sheetProtection.algorithmName=`SHA-512`,this.sheetProtection.saltValue=It(sn.randomBytes(16)),this.sheetProtection.spinCount=t&&`spinCount`in t?t.spinCount:1e5,this.sheetProtection.hashValue=await sn.convertPasswordToHash(e,`SHA-512`,this.sheetProtection.saltValue,this.sheetProtection.spinCount)),t&&(this.sheetProtection=Object.assign(this.sheetProtection,t),!e&&`spinCount`in t&&delete this.sheetProtection.spinCount)}unprotect(){this.sheetProtection=null}addTable(e){let t=new $e(this,e);return this.tables[t.name]=t,t}getTable(e){return this.tables[e]}removeTable(e){delete this.tables[e]}getTables(){return Object.values(this.tables)}addPivotTable(e){let t=hn(this,e);return this.pivotTables.push(t),this.workbook.pivotTables.push(t),t}addConditionalFormatting(e){this.conditionalFormattings.push(e)}removeConditionalFormatting(e){typeof e==`number`?this.conditionalFormattings.splice(e,1):e instanceof Function?this.conditionalFormattings=this.conditionalFormattings.filter(e):this.conditionalFormattings=[]}get model(){let e={id:this.id,name:this.name,dataValidations:this.dataValidations.model,properties:this.properties,state:this.state,pageSetup:this.pageSetup,headerFooter:this.headerFooter,rowBreaks:this.rowBreaks,colBreaks:this.colBreaks,views:this.views,autoFilter:this.autoFilter,media:this._media.map(e=>e.model),sheetProtection:this.sheetProtection,tables:Object.values(this.tables).map(e=>e.model),pivotTables:this.pivotTables,conditionalFormattings:this.conditionalFormattings,formControls:this.formControls.map(e=>e.model),drawing:this._drawing};e.cols=Be.toModel(this.columns);let t=e.rows=[],n=e.dimensions=new C;return this._rows.forEach(e=>{let r=e&&e.model;r&&(n.expand(r.number,r.min,r.number,r.max),t.push(r))}),e.mergeCells=Object.values(this._merges).map(e=>e.range),e}_parseRows(e){this._rows=[],e.rows&&e.rows.forEach(e=>{let t=new ze(this,e.number);this._rows[t.number-1]=t,t.model=e})}_parseMergeCells(e){e.mergeCells&&e.mergeCells.forEach(e=>{this.mergeCellsWithoutStyle(e)})}set model(e){this.name=e.name,this.state=e.state,this._columns=Be.fromModel(this,e.cols??[]),this._parseRows(e),this._parseMergeCells(e),this.dataValidations=new et(e.dataValidations),this.properties=e.properties,this.pageSetup=e.pageSetup,this.headerFooter=e.headerFooter,this.rowBreaks=e.rowBreaks??[],this.colBreaks=e.colBreaks??[],this.views=e.views,this.autoFilter=e.autoFilter,this._media=e.media.map(e=>new We(this,e)),this.sheetProtection=e.sheetProtection,this.tables=e.tables.reduce((e,t)=>{let n=new $e(this,t);return n.model=t,e[t.name]=n,e},{}),this.pivotTables=e.pivotTables,this.conditionalFormattings=e.conditionalFormattings,this.formControls=[],this._drawing=e.drawing}toJSON(e){let t=e||{},n=1,r=this.rowCount,i=1,a=this.columnCount;if(t.range!==void 0){if(typeof t.range==`number`)n=t.range+1;else if(typeof t.range==`string`){let e=er(t.range);n=e.s.r+1,r=e.e.r+1,i=e.s.c+1,a=e.e.c+1}}if(r<n||a<i)return[];let o=t.header;if(o===1){let e=[],o=t.blankRows!==!1;for(let s=n;s<=r;s++){let n=[],r=!0;for(let e=i;e<=a;e++){let a=this.getCell(s,e),o=t.raw===!1?ir(a,t.dateFormat).trim():a.value;o!=null&&o!==``?(n[e-i]=o,r=!1):t.defaultValue===void 0?n[e-i]=null:n[e-i]=t.defaultValue}(!r||o)&&e.push(n)}return e}if(o===`A`){let e=[],o=t.blankRows===!0;for(let s=n;s<=r;s++){let n={},r=!0;for(let e=i;e<=a;e++){let i=this.getCell(s,e),a=t.raw===!1?ir(i,t.dateFormat).trim():i.value,o=Yn(e-1);a!=null&&a!==``?(n[o]=a,r=!1):t.defaultValue!==void 0&&(n[o]=t.defaultValue)}(!r||o)&&e.push(n)}return e}if(Array.isArray(o)){let e=[],s=t.blankRows===!0;for(let c=n;c<=r;c++){let n={},r=!0;for(let e=i;e<=a;e++){let a=e-i,s=o[a]??`__EMPTY_${a}`,l=this.getCell(c,e),u=t.raw===!1?ir(l,t.dateFormat).trim():l.value;u!=null&&u!==``?(n[s]=u,r=!1):t.defaultValue!==void 0&&(n[s]=t.defaultValue)}(!r||s)&&e.push(n)}return e}let s=[],c={};for(let e=i;e<=a;e++){let t=this.getCell(n,e).value,r=t==null?`__EMPTY_${e-i}`:String(t);c[r]===void 0?c[r]=0:(c[r]++,r=`${r}_${c[r]}`),s.push(r)}let l=[],u=n+1,d=t.blankRows===!0;for(let e=u;e<=r;e++){let n={},r=!0;for(let o=i;o<=a;o++){let a=this.getCell(e,o),c=t.raw===!1?ir(a,t.dateFormat).trim():a.value,l=s[o-i];c!=null&&c!==``?(n[l]=c,r=!1):t.defaultValue!==void 0&&(n[l]=t.defaultValue)}(!r||d)&&l.push(n)}return l}addJSON(e,t){if(e.length===0)return this;let n=t||{},r=1,i=1;if(n.origin!==void 0){let e=rr(n.origin,this.rowCount);r=e.row,i=e.col}let a=new Set;e.forEach(e=>Object.keys(e).forEach(e=>a.add(e)));let o=n.header?[...n.header]:[...a];n.header&&a.forEach(e=>{o.includes(e)||o.push(e)});let s=r;n.skipHeader||(o.forEach((e,t)=>{this.getCell(s,i+t).value=e}),s++);for(let t of e)o.forEach((e,r)=>{let a=t[e];a===null&&n.nullError?this.getCell(s,i+r).value={error:`#NULL!`}:a!=null&&(this.getCell(s,i+r).value=a)}),s++;return this}toAOA(){let e=[];return this.eachRow({includeEmpty:!0},(t,n)=>{let r=[];t.eachCell({includeEmpty:!0},(e,t)=>{r[t-1]=e.value}),e[n-1]=r}),e}addAOA(e,t){if(e.length===0)return this;let n=1,r=1;if(t?.origin!==void 0){let e=rr(t.origin,this.rowCount);n=e.row,r=e.col}return e.forEach((e,t)=>{e&&e.forEach((e,i)=>{e!=null&&(this.getCell(n+t,r+i).value=e)})}),this}};function rr(e,t){if(typeof e==`string`){let t=Qn(e);return{row:t.r+1,col:t.c+1}}return typeof e==`number`?e===-1?{row:t+1,col:1}:{row:e+1,col:1}:{row:e.r+1,col:e.c+1}}function ir(e,t){let n=e.value,r=e.numFmt,i=typeof r==`string`?r:r?.formatCode??`General`;if(n==null)return``;if(n instanceof Date||typeof n==`number`||typeof n==`boolean`||typeof n==`string`)return qn(n,i,t);if(typeof n==`object`&&`formula`in n){let e=n.result;if(e==null)return``;if(e instanceof Date||typeof e==`number`||typeof e==`boolean`||typeof e==`string`)return qn(e,i,t)}return e.text}function ar(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>ar(e));let t={};for(let n of Object.keys(e))n!==`__proto__`&&n!==`constructor`&&n!==`prototype`&&(t[n]=ar(e[n]));return t}var or=class{constructor(e){this.template=e,this.sheets=new Map}addCell(e){this.addCellEx(S.decodeEx(e))}getCell(e){return this.findCellEx(S.decodeEx(e),!0)}findCell(e){return this.findCellEx(S.decodeEx(e),!1)}findCellAt(e,t,n){let r=this.sheets.get(e),i=r&&r[t];return i&&i[n]}addCellEx(e){if(e.top!==void 0)for(let t=e.top;t<=e.bottom;t++)for(let n=e.left;n<=e.right;n++)this.getCellAt(e.sheetName,t,n);else this.findCellEx(e,!0)}getCellEx(e){return this.findCellEx(e,!0)}findCellEx(e,t){let n=this.findSheet(e,t),r=this.findSheetRow(n,e,t);return this.findRowCell(r,e,t)}getCellAt(e,t,n){let r=this.sheets.get(e);r||(r=[],this.sheets.set(e,r));let i=t>>>0,a=n>>>0,o=r[i]||(r[i]=[]);return o[a]||(o[a]={sheetName:e,address:S.n2l(n)+t,row:t,col:n})}removeCellEx(e){let t=this.findSheet(e,!1);if(!t)return;let n=this.findSheetRow(t,e,!1);n&&delete n[e.col>>>0]}forEachInSheet(e,t){let n=this.sheets.get(e);n&&n.forEach((e,n)=>{e&&e.forEach((e,r)=>{e&&t(e,n,r)})})}forEach(e){for(let t of this.sheets.keys())this.forEachInSheet(t,e)}map(e){let t=[];return this.forEach(n=>{t.push(e(n))}),t}findSheet(e,t){let n=e.sheetName;if(this.sheets.has(n))return this.sheets.get(n);if(t){let e=[];return this.sheets.set(n,e),e}}findSheetRow(e,t,n){let r=t.row>>>0;if(e&&e[r])return e[r];if(n)return e[r]=[]}findRowCell(e,t,n){let r=t.col>>>0;if(e&&e[r])return e[r];if(n)return e[r]=this.template?{...t,...ar(this.template)}:t}spliceRows(e,t,n,r){let i=this.sheets.get(e);if(i){let e=[];for(let t=0;t<r;t++)e.push([]);i.splice(t,n,...e)}}spliceColumns(e,t,n,r){let i=this.sheets.get(e);if(i){let e=[];for(let t=0;t<r;t++)e.push(null);i.forEach(r=>{r.splice(t,n,...e)})}}};let sr=/[$](\w+)[$](\d+)(:[$](\w+)[$](\d+))?/;var cr=class{constructor(){this.matrixMap={}}getMatrix(e){return this.matrixMap[e]||(this.matrixMap[e]=new or)}add(e,t){let n=S.decodeEx(e);`error`in n||this.addEx(n,t)}addEx(e,t){let n=this.getMatrix(t);if(`top`in e)for(let t=e.left;t<=e.right;t++)for(let r=e.top;r<=e.bottom;r++){let i={sheetName:e.sheetName,address:S.n2l(t)+r,row:r,col:t};n.addCellEx(i)}else n.addCellEx(e)}remove(e,t){let n=S.decodeEx(e);`error`in n||this.removeEx(n,t)}removeEx(e,t){let n=this.getMatrix(t);if(`top`in e)for(let t=e.left;t<=e.right;t++)for(let r=e.top;r<=e.bottom;r++)n.removeCellEx({sheetName:e.sheetName,address:S.n2l(t)+r,row:r,col:t});else n.removeCellEx(e)}removeAllNames(e){Object.values(this.matrixMap).forEach(t=>{if(`top`in e)for(let n=e.left;n<=e.right;n++)for(let r=e.top;r<=e.bottom;r++)t.removeCellEx({sheetName:e.sheetName,address:S.n2l(n)+r,row:r,col:n});else t.removeCellEx(e)})}forEach(e){Object.entries(this.matrixMap).forEach(([t,n])=>{n.forEach(n=>{e(t,n)})})}getNames(e){let t=S.decodeEx(e);return`error`in t||`top`in t?[]:this.getNamesEx(t)}getNamesEx(e){return Object.entries(this.matrixMap).map(([t,n])=>n.findCellEx(e,!1)&&t).filter(e=>!!e)}_explore(e,t){t.mark=!1;let n=t.sheetName,r=new C(t.row,t.col,t.row,t.col,n),i,a,o=(t,r)=>e.findCellAt(n,t,r);function s(e,n){let i=o(e,t.col);return!i||!i.mark?!1:(r[n]=e,i.mark=!1,!0)}for(a=t.row-1;s(a,`top`);a--);for(a=t.row+1;s(a,`bottom`);a++);function c(e,t){let n=[];for(a=r.top;a<=r.bottom;a++){let t=o(a,e);if(t&&t.mark)n.push(t);else return!1}r[t]=e;for(let e=0;e<n.length;e++)n[e].mark=!1;return!0}for(i=t.col-1;c(i,`left`);i--);for(i=t.col+1;c(i,`right`);i++);return r}getRanges(e,t){return t||=this.matrixMap[e],t?(t.forEach(e=>{e.mark=!0}),{name:e,ranges:t.map(e=>e.mark&&this._explore(t,e)).filter(e=>!!e).map(e=>e.$shortRange)}):{name:e,ranges:[]}}normaliseMatrix(e,t){e.forEachInSheet(t,(e,t,n)=>{e&&(e.row!==t||e.col!==n)&&(e.row=t,e.col=n,e.address=S.n2l(n)+t)})}spliceRows(e,t,n,r){Object.values(this.matrixMap).forEach(i=>{i.spliceRows(e,t,n,r),this.normaliseMatrix(i,e)})}spliceColumns(e,t,n,r){Object.values(this.matrixMap).forEach(i=>{i.spliceColumns(e,t,n,r),this.normaliseMatrix(i,e)})}get model(){return Object.entries(this.matrixMap).map(([e,t])=>this.getRanges(e,t)).filter(e=>e.ranges.length)}set model(e){let t=this.matrixMap={};e.forEach(e=>{let n=t[e.name]=new or;e.ranges.forEach(e=>{sr.test(e.split(`!`).pop()??``)&&n.addCell(e)})})}};let lr=1e4;function ur(e,t,n){e.push(` ${t}="${D(n.toString())}"`)}function dr(e,t){if(t){let n=[];for(let e in t){if(!Object.prototype.hasOwnProperty.call(t,e))continue;let r=t[e];r!==void 0&&ur(n,e,r)}e.push(n.join(``))}}var k=class{constructor(){this._xml=[],this._chunks=[],this._stack=[],this._rollbacks=[],this.leaf=!1,this.open=!1}_consolidate(){this._rollbacks.length>0||this._xml.length>=lr&&(this._chunks.push(this._xml.join(``)),this._xml.length=0)}get tos(){return this._stack.length?this._stack[this._stack.length-1]:void 0}get cursor(){return this._chunks.length*lr+this._xml.length}openXml(e){let t=this._xml;t.push(`<?xml`),dr(t,e),t.push(`?>
8
+ `)}openNode(e,t){let n=this.tos,r=this._xml;n&&this.open&&r.push(`>`),this._stack.push(e),r.push(`<`),r.push(e),dr(r,t),this.leaf=!0,this.open=!0}addAttribute(e,t){if(!this.open)throw new b(`write attributes`,`node is not open`);t!==void 0&&ur(this._xml,e,t)}addAttributes(e){if(!this.open)throw new b(`write attributes`,`node is not open`);dr(this._xml,e)}writeText(e){let t=this._xml;this.open&&=(t.push(`>`),!1),this.leaf=!1,t.push(D(e.toString()))}writeXml(e){this.open&&=(this._xml.push(`>`),!1),this.leaf=!1,this._xml.push(e)}closeNode(){let e=this._stack.pop(),t=this._xml;this.leaf?t.push(`/>`):(t.push(`</`),t.push(e),t.push(`>`)),this.open=!1,this.leaf=!1,this._consolidate()}leafNode(e,t,n){this.openNode(e,t),n!==void 0&&this.writeText(n),this.closeNode()}closeAll(){for(;this._stack.length;)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf??!1,open:this.open??!1,chunksLength:this._chunks.length}),this.cursor}commit(){this._rollbacks.pop()}rollback(){let e=this._rollbacks.pop();this._xml.length>e.xml&&(this._xml.length=e.xml),this._stack.length>e.stack&&(this._stack.length=e.stack),this._chunks.length>e.chunksLength&&(this._chunks.length=e.chunksLength),this.leaf=e.leaf,this.open=e.open}get xml(){return this.closeAll(),this._chunks.length===0?this._xml.join(``):(this._xml.length>0&&this._chunks.push(this._xml.join(``)),this._chunks.join(``))}static{this.StdDocAttributes={version:`1.0`,encoding:`UTF-8`,standalone:`yes`}}};let fr=(()=>{let e=Array(128);for(let t=0;t<128;t++)e[t]=String.fromCharCode(t);return e})();function A(e){return e<128?fr[e]:String.fromCodePoint(e)}let pr=(()=>{let e=new Uint8Array(128);for(let t=97;t<=122;t++)e[t]=1;for(let t=65;t<=90;t++)e[t]=1;return e[95]=1,e[58]=1,e})(),mr=(()=>{let e=new Uint8Array(128);for(let t=97;t<=122;t++)e[t]=1;for(let t=65;t<=90;t++)e[t]=1;for(let t=48;t<=57;t++)e[t]=1;return e[95]=1,e[58]=1,e[45]=1,e[46]=1,e})();function hr(e){return e===32||e===10||e===13||e===9}function gr(e){return e===34||e===39}function _r(e){return e<128?pr[e]===1:e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e===8204||e===8205||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function vr(e){return e<128?mr[e]===1:e===183||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=768&&e<=879||e>=880&&e<=893||e>=895&&e<=8191||e===8204||e===8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function yr(e){return e>=32&&e<=55295||e===10||e===13||e===9||e>=57344&&e<=65533||e>=65536&&e<=1114111}let br={amp:`&`,gt:`>`,lt:`<`,quot:`"`,apos:`'`};var xr=class{constructor(e){this.state=0,this.chunk=``,this.i=0,this.prevI=0,this.text=``,this.name=``,this.q=null,this.tags=[],this.tag=null,this.attribList=[],this.entity=``,this.entityReturnState=0,this.openWakaBang=``,this.sawRoot=!1,this.closedRoot=!1,this._closed=!1,this.reportedTextBeforeRoot=!1,this.reportedTextAfterRoot=!1,this.line=1,this.column=0,this.positionAtNewLine=0,this.chunkPosition=0,this.ENTITIES={...br},this.trackPosition=e?.position!==!1,this.fileName=e?.fileName,this.fragment=e?.fragment??!1,this._init()}get closed(){return this._closed}get position(){return this.chunkPosition+this.i}_init(){this.state=(this.fragment,0),this.text=``,this.name=``,this.q=null,this.tags=[],this.tag=null,this.attribList=[],this.entity=``,this.openWakaBang=``,this.sawRoot=this.fragment,this.closedRoot=this.fragment,this.reportedTextBeforeRoot=this.fragment,this.reportedTextAfterRoot=this.fragment,this.carriedFromPrevious=void 0,this._closed=!1,this.line=1,this.column=0,this.positionAtNewLine=0,this.chunkPosition=0,this.chunk=``,this.i=0,this.prevI=0}on(e,t){switch(e){case`text`:this.textHandler=t;break;case`opentag`:this.openTagHandler=t;break;case`closetag`:this.closeTagHandler=t;break;case`error`:this.errorHandler=t;break}}off(e){switch(e){case`text`:this.textHandler=void 0;break;case`opentag`:this.openTagHandler=void 0;break;case`closetag`:this.closeTagHandler=void 0;break;case`error`:this.errorHandler=void 0;break}}makeError(e){let t=this.fileName??``;return this.trackPosition&&(t.length>0&&(t+=`:`),t+=`${this.line}:${this.column}`),t.length>0&&(t+=`: `),Error(t+e)}fail(e){let t=this.makeError(e);if(this.errorHandler)this.errorHandler(t);else throw t;return this}write(e){if(this._closed)return this.fail(`cannot write after close`);let t=!1;e===null&&(t=!0,e=``),this.carriedFromPrevious!==void 0&&(e=this.carriedFromPrevious+e,this.carriedFromPrevious=void 0);let n=e.length;if(!t&&n>0){let t=e.charCodeAt(n-1);(t===13||t>=55296&&t<=56319)&&(this.carriedFromPrevious=e[n-1],n--,e=e.slice(0,n))}for(this.chunk=e,this.i=0;this.i<n;)this.processState();return this.chunkPosition+=n,t?this.end():this}close(){return this.write(null)}getCode(){let{chunk:e,i:t}=this;if(this.prevI=t,this.i=t+1,t>=e.length)return-1;let n=e.charCodeAt(t);if(n<10||n>13&&n<55296)return this.trackPosition&&this.column++,n;if(n>=55296&&n<=56319){let r=e.charCodeAt(t+1);if(r>=56320&&r<=57343)return this.i=t+2,this.trackPosition&&this.column++,65536+((n-55296)*1024+(r-56320))}return n===13?(e.charCodeAt(t+1)===10&&(this.i=t+2),this.trackPosition&&(this.line++,this.column=0,this.positionAtNewLine=this.position),10):(n===10&&this.trackPosition?(this.line++,this.column=0,this.positionAtNewLine=this.position):this.trackPosition&&this.column++,n)}unget(){this.i=this.prevI,this.trackPosition&&this.column--}processState(){switch(this.state){case 0:this.sText();break;case 1:this.sOpenWaka();break;case 2:this.sOpenWakaBang();break;case 3:this.sOpenTag();break;case 4:this.sOpenTagSlash();break;case 5:this.sAttrib();break;case 6:this.sAttribName();break;case 7:this.sAttribNameSawWhite();break;case 8:this.sAttribValue();break;case 9:this.sAttribValueQuoted();break;case 10:this.sAttribValueClosed();break;case 11:this.sCloseTag();break;case 12:this.sCloseTagSawWhite();break;case 13:this.sComment();break;case 14:this.sCommentEnding();break;case 15:this.sCommentEnded();break;case 16:this.sCData();break;case 17:this.sCDataEnding();break;case 18:this.sCDataEnding2();break;case 19:this.sPI();break;case 20:this.sPIEnding();break;case 21:this.sDoctype();break;case 22:this.sDoctypeQuote();break;case 23:this.sDoctypeDTD();break;case 24:this.sDoctypeDTDQuoted();break;case 25:this.sEntity();break}}sText(){this.tags.length===0?this.handleTextOutsideRoot():this.handleTextInRoot()}handleTextInRoot(){let{chunk:e}=this,{i:t}=this,n=this.textHandler;for(;;){let r=this.getCode();if(r===-1){n&&t<this.i&&(this.text+=e.slice(t,this.i));return}if(r===60){if(n){let r=e.slice(t,this.prevI);this.text.length>0?(n(this.text+r),this.text=``):r.length>0&&n(r)}this.state=1;return}if(r===38){n&&(this.text+=e.slice(t,this.prevI)),this.state=25,this.entityReturnState=0,this.entity=``;return}r===10&&(n&&(this.text+=e.slice(t,this.prevI)+`
9
9
  `),t=this.i)}}handleTextOutsideRoot(){let{chunk:e}=this,{i:t}=this,n=this.textHandler,r=!1;for(;;){let i=this.getCode();if(i===-1){n&&t<this.i&&(this.text+=e.slice(t,this.i));break}if(i===60){if(n){let r=e.slice(t,this.prevI);this.text.length>0?(n(this.text+r),this.text=``):r.length>0&&n(r)}this.state=1;break}if(i===38){n&&(this.text+=e.slice(t,this.prevI)),this.state=25,this.entityReturnState=0,this.entity=``,r=!0;break}i===10?(n&&(this.text+=e.slice(t,this.prevI)+`
10
- `),t=this.i):hr(i)||(r=!0)}r&&(!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail(`text data outside of root node.`),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail(`text data outside of root node.`),this.reportedTextAfterRoot=!0))}sOpenWaka(){let e=this.getCode();if(_r(e)){this.state=3,this.name=A(e);return}switch(e){case 47:this.state=11,this.name=``;break;case 33:this.state=2,this.openWakaBang=``;break;case 63:this.state=19,this.text=``;break;default:this.fail(`unexpected character in tag`),this.state=0}}sOpenWakaBang(){let e=this.getCode();switch(this.openWakaBang+=A(e),this.openWakaBang){case`[CDATA[`:this.state=16,this.text=``,this.openWakaBang=``;break;case`--`:this.state=13,this.text=``,this.openWakaBang=``;break;case`DOCTYPE`:this.state=21,this.text=``,this.openWakaBang=``;break;default:this.openWakaBang.length>=7&&(this.fail(`incorrect syntax`),this.state=0)}}sOpenTag(){let e=this.getCode();if(e!==-1){if(vr(e)){this.name+=A(e);return}this.tag={name:this.name,attributes:Object.create(null),isSelfClosing:!1},this.attribList=[],this.sawRoot=!0,e===62?this.openTag():e===47?this.state=4:(hr(e)||this.fail(`unexpected character in tag`),this.state=5)}}sOpenTagSlash(){this.getCode()===62?this.openSelfClosingTag():(this.fail(`expected >`),this.state=5)}sAttrib(){let e=this.skipSpaces();e!==-1&&(_r(e)?(this.name=A(e),this.state=6):e===62?this.openTag():e===47?this.state=4:this.fail(`unexpected character in attribute`))}sAttribName(){let e=this.getCode();if(e!==-1){if(vr(e)){this.name+=A(e);return}e===61?this.state=8:hr(e)?this.state=7:e===62?(this.fail(`attribute without value`),this.attribList.push({name:this.name,value:this.name}),this.name=``,this.openTag()):this.fail(`unexpected character in attribute name`)}}sAttribNameSawWhite(){let e=this.skipSpaces();e!==-1&&(e===61?this.state=8:(this.fail(`attribute without value`),this.name=``,this.text=``,e===62?this.openTag():_r(e)?(this.name=A(e),this.state=6):(this.fail(`unexpected character`),this.state=5)))}sAttribValue(){let e=this.skipSpaces();e!==-1&&(gr(e)?(this.q=e,this.text=``,this.state=9):(this.fail(`unquoted attribute value`),this.state=0))}sAttribValueQuoted(){let{q:e,chunk:t}=this,{i:n}=this;for(;;){let r=this.getCode();if(r===-1){this.text+=t.slice(n,this.i);return}if(r===e){this.attribList.push({name:this.name,value:this.text+t.slice(n,this.prevI)}),this.name=``,this.text=``,this.q=null,this.state=10;return}if(r===38){this.text+=t.slice(n,this.prevI),this.state=25,this.entityReturnState=9,this.entity=``;return}if((r===10||r===9)&&(this.text+=t.slice(n,this.prevI)+` `,n=this.i),r===60){this.text+=t.slice(n,this.prevI),this.fail(`< not allowed in attribute value`);return}}}sAttribValueClosed(){let e=this.getCode();e!==-1&&(hr(e)?this.state=5:e===62?this.openTag():e===47?this.state=4:_r(e)?(this.fail(`no whitespace between attributes`),this.name=A(e),this.state=6):this.fail(`unexpected character after attribute`))}sCloseTag(){let e=this.getCode();e!==-1&&(vr(e)?this.name+=A(e):e===62?this.closeTag():hr(e)?this.state=12:this.fail(`unexpected character in close tag`))}sCloseTagSawWhite(){let e=this.skipSpaces();e!==-1&&(e===62?this.closeTag():this.fail(`unexpected character in close tag`))}sComment(){let e=this.getCode();e!==-1&&(e===45?this.state=14:this.text+=A(e))}sCommentEnding(){let e=this.getCode();e===45?this.state=15:(this.text+=`-`+A(e),this.state=13)}sCommentEnded(){let e=this.getCode();e===62?(this.text=``,this.state=0):e===45?this.text+=`-`:(this.fail(`malformed comment`),this.text+=`--`+A(e),this.state=13)}sCData(){let e=this.getCode();e!==-1&&(e===93?this.state=17:this.text+=A(e))}sCDataEnding(){let e=this.getCode();e===93?this.state=18:(this.text+=`]`+A(e),this.state=16)}sCDataEnding2(){let e=this.getCode();e===62?(this.textHandler&&this.text.length>0&&this.textHandler(this.text),this.text=``,this.state=0):e===93?this.text+=`]`:(this.text+=`]]`+A(e),this.state=16)}sPI(){let e=this.getCode();e!==-1&&(e===63?this.state=20:this.text+=A(e))}sPIEnding(){let e=this.getCode();e===62?(this.text=``,this.state=0):e===63?this.text+=`?`:(this.text+=`?`+A(e),this.state=19)}sDoctype(){let e=this.getCode();e!==-1&&(e===62?(this.text=``,this.state=0):gr(e)?(this.q=e,this.state=22):e===91?this.state=23:this.text+=A(e))}sDoctypeQuote(){let e=this.getCode();e!==-1&&(e===this.q?(this.q=null,this.state=21):this.text+=A(e))}sDoctypeDTD(){let e=this.getCode();e!==-1&&(e===93?this.state=21:gr(e)&&(this.q=e,this.state=24))}sDoctypeDTDQuoted(){let e=this.getCode();e!==-1&&e===this.q&&(this.q=null,this.state=23)}sEntity(){let e=this.getCode();if(e!==-1)if(e===59){let e=this.entity,t;e===``?(this.fail(`empty entity`),t=`&;`):t=this.parseEntity(e),this.text+=t,this.state=this.entityReturnState,this.entity=``}else vr(e)||e===35?this.entity+=A(e):(this.fail(`invalid entity character`),this.text+=`&`+this.entity+A(e),this.state=this.entityReturnState,this.entity=``)}parseEntity(e){if(e[0]!==`#`){let t=this.ENTITIES[e];return t===void 0?(this.fail(`undefined entity: `+e),`&`+e+`;`):t}let t;return t=e[1]===`x`||e[1]===`X`?parseInt(e.slice(2),16):parseInt(e.slice(1),10),isNaN(t)||!yr(t)?(this.fail(`invalid character entity`),`&`+e+`;`):String.fromCodePoint(t)}skipSpaces(){for(;;){let e=this.getCode();if(e===-1||!hr(e))return e}}openTag(){let e=this.tag;e.isSelfClosing=!1;for(let{name:t,value:n}of this.attribList)e.attributes[t]=n;this.attribList=[],this.openTagHandler?.(e),this.tags.push(e),this.name=``,this.state=0}openSelfClosingTag(){let e=this.tag;e.isSelfClosing=!0;for(let{name:t,value:n}of this.attribList)e.attributes[t]=n;this.attribList=[],this.openTagHandler?.(e),this.closeTagHandler?.(e),this.tags.length===0&&(this.closedRoot=!0),this.name=``,this.state=0}closeTag(){let{tags:e,name:t}=this;if(this.state=0,this.name=``,t===``){this.fail(`empty close tag`),this.text+=`</>`;return}let n=!1;for(let r=e.length-1;r>=0;r--)if(e[r].name===t){for(;e.length>r;){let t=e.pop();this.closeTagHandler?.(t),e.length>r&&this.fail(`unclosed tag: `+t.name)}n=!0;break}n||(this.fail(`unmatched close tag: `+t),this.text+=`</`+t+`>`),e.length===0&&(this.closedRoot=!0)}end(){for(this.sawRoot||this.fail(`document must contain a root element`);this.tags.length>0;){let e=this.tags.pop();this.fail(`unclosed tag: `+e.name)}return this.text.length>0&&this.textHandler&&(this.textHandler(this.text),this.text=``),this._closed=!0,this._init(),this}};async function*Sr(e){let t=new xr({xmlns:!1,position:!0}),n;t.on(`error`,e=>{n=e});let r=[];t.on(`opentag`,e=>r.push({eventType:`opentag`,value:e})),t.on(`text`,e=>r.push({eventType:`text`,value:e})),t.on(`closetag`,e=>r.push({eventType:`closetag`,value:e}));for await(let i of e){let e=Ft(i);if(t.write(e),n)throw n;yield r,r=[]}if(t.close(),n)throw n;r.length>0&&(yield r)}let Cr=new Set([`ep`,`cp`,`dc`,`dcterms`,`dcmitype`,`vt`]);function wr(e,t){for(let e in t)if(e.length>6&&e.startsWith(`xmlns:`)){let n=e.slice(6);if(t[e]===`http://schemas.openxmlformats.org/spreadsheetml/2006/main`)return n;if(Cr.has(n))return null}let n=e.indexOf(`:`);return n!==-1&&Cr.has(e.slice(0,n))?null:void 0}function Tr(e,t){let n=e.indexOf(`:`);if(n===-1)return e;let r=e.slice(0,n);return r===t||Cr.has(r)?e.slice(n+1):e}var j=class e{prepare(e,t){}render(e,t){}parseOpen(e){}parseText(e){}parseClose(e){return!1}reconcile(e,t){}reset(){this.model=void 0,this.map&&Object.values(this.map).forEach(t=>{t instanceof e?t.reset():t.xform&&t.xform.reset()})}mergeModel(e){this.model=Object.assign(this.model||{},e)}async parse(e){let t=!1,n,r=0,i=null;for await(let a of e)if(!t){for(let{eventType:e,value:o}of a)if(e===`opentag`){if(r===1){this.parseOpen(o);continue}if(r===0){let e=wr(o.name,o.attributes);if(e===void 0){r=1,this.parseOpen(o);continue}r=2,i=e}o.name=Tr(o.name,i),this.parseOpen(o)}else if(e===`text`)this.parseText(o);else if(e===`closetag`){if(r===1){if(!this.parseClose(o.name)){t=!0,n=this.model;break}continue}if(!this.parseClose(Tr(o.name,i))){t=!0,n=this.model;break}}}return t?n:this.model}async parseStream(e){return this.parse(Sr(e))}get xml(){return this.toXml(this.model)}toXml(e){let t=new k;return this.render(t,e),t.xml}static toAttribute(e,t,n=!1){if(e===void 0){if(n)return t}else if(n||e!==t)return e.toString()}static toStringAttribute(t,n,r=!1){return e.toAttribute(t,n,r)}static toStringValue(e,t){return e===void 0?t:e}static toBoolAttribute(e,t,n=!1){if(e===void 0){if(n)return t}else if(n||e!==t)return e?`1`:`0`}static toBoolValue(e,t){return e===void 0?t:e===`1`}static toIntAttribute(t,n,r=!1){return e.toAttribute(t,n,r)}static toIntValue(e,t){return e===void 0?t:parseInt(e,10)}static toFloatAttribute(t,n,r=!1){return e.toAttribute(t,n,r)}static toFloatValue(e,t){return e===void 0?t:parseFloat(e)}};function Er(e,t){e.openNode(t.tag,t.$),t.c&&t.c.forEach(t=>{Er(e,t)}),t.t&&e.writeText(t.t),e.closeNode()}var Dr=class extends j{constructor(e){super(),this._model=e}render(e){if(!this._xml){let e=new k;Er(e,this._model),this._xml=e.xml}e.writeXml(this._xml)}parseOpen(){return!0}parseText(){}parseClose(e){switch(e){case this._model.tag:return!1;default:return!0}}},M=class extends j{constructor(e){super(),this.tag=e.tag,this.always=!!e.always,this.count=e.count,this.empty=e.empty,this.$count=e.$count??`count`,this.$=e.$,this.childXform=e.childXform,this.maxItems=e.maxItems}prepare(e,t){let{childXform:n}=this;e&&e.forEach((e,r)=>{t.index=r,n.prepare(e,t)})}render(e,t){if(this.always||t&&t.length){e.openNode(this.tag,this.$),this.count&&e.addAttribute(this.$count,t?.length??0);let{childXform:n}=this;(t??[]).forEach((t,r)=>{n.render(e,t,r)}),e.closeNode()}else this.empty&&e.leafNode(this.tag)}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.model=[],!0):this.childXform.parseOpen(e)?(this.parser=this.childXform,!0):!1}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)&&(this.model.push(this.parser.model),this.parser=void 0,this.maxItems&&this.model.length>this.maxItems))throw new re(this.childXform.tag,this.maxItems);return!0}return!1}reconcile(e,t){if(e){let{childXform:n}=this;e.forEach(e=>{n.reconcile(e,t)})}}reset(){super.reset(),this.childXform&&this.childXform.reset()}},N=class extends j{constructor(e){super(),this.name=e??`color`}get tag(){return this.name}render(e,t){return t?(e.openNode(this.name),t.argb?e.addAttribute(`rgb`,t.argb):t.theme===void 0?t.indexed===void 0?e.addAttribute(`auto`,`1`):e.addAttribute(`indexed`,t.indexed):(e.addAttribute(`theme`,t.theme),t.tint!==void 0&&e.addAttribute(`tint`,t.tint)),e.closeNode(),!0):!1}parseOpen(e){return e.name===this.name?(e.attributes.rgb?this.model={argb:e.attributes.rgb}:e.attributes.theme?(this.model={theme:parseInt(e.attributes.theme,10)},e.attributes.tint&&(this.model.tint=parseFloat(e.attributes.tint))):e.attributes.indexed?this.model={indexed:parseInt(e.attributes.indexed,10)}:this.model=void 0,!0):!1}parseText(){}parseClose(){return!1}},Or=class extends j{constructor(e){super(),this.tag=e.tag,this.attr=e.attr}render(e,t){t&&(e.openNode(this.tag),e.closeNode())}parseOpen(e){e.name===this.tag&&(this.model=!0)}parseText(){}parseClose(){return!1}},kr=class extends j{constructor(e){super(),this.tag=e.tag,this.attr=e.attr,this.attrs=e.attrs,this.zero=e.zero,this.text=[]}render(e,t){(t||this.zero)&&(e.openNode(this.tag),this.attrs&&e.addAttributes(this.attrs),this.attr?e.addAttribute(this.attr,t):e.writeText(t),e.closeNode())}parseOpen(e){return e.name===this.tag?(this.attr?this.model=parseInt(e.attributes[this.attr],10):this.text=[],!0):!1}parseText(e){this.attr||this.text.push(e)}parseClose(){return this.attr||(this.model=parseInt(this.text.join(``)||`0`,10)),!1}},P=class extends j{constructor(e){super(),this.tag=e.tag,this.attr=e.attr,this.attrs=e.attrs,this.text=[]}render(e,t){t!==void 0&&(e.openNode(this.tag),this.attrs&&e.addAttributes(this.attrs),this.attr?e.addAttribute(this.attr,t):e.writeText(t),e.closeNode())}parseOpen(e){e.name===this.tag&&(this.attr?this.model=e.attributes[this.attr]:this.text=[])}parseText(e){this.attr||this.text.push(e)}parseClose(){return this.attr||(this.model=this.text.join(``)),!1}},Ar=class e extends j{static{this.Attributes={single:{},double:{val:`double`},singleAccounting:{val:`singleAccounting`},doubleAccounting:{val:`doubleAccounting`}}}constructor(e){super(),this.model=e}get tag(){return`u`}render(t,n){if(n||=this.model,n===!0)t.leafNode(`u`);else{let r=e.Attributes[n];r&&t.leafNode(`u`,r)}}parseOpen(e){e.name===`u`&&(this.model=e.attributes.val||!0)}parseText(){}parseClose(){return!1}},jr=class e extends j{constructor(t){super(),this.options=t||e.OPTIONS;let n=[{tag:`b`,prop:`bold`,xform:new Or({tag:`b`,attr:`val`})},{tag:`i`,prop:`italic`,xform:new Or({tag:`i`,attr:`val`})},{tag:`u`,prop:`underline`,xform:new Ar},{tag:`strike`,prop:`strike`,xform:new Or({tag:`strike`,attr:`val`})},{tag:`condense`,prop:`condense`,xform:new Or({tag:`condense`,attr:`val`})},{tag:`extend`,prop:`extend`,xform:new Or({tag:`extend`,attr:`val`})},{tag:`outline`,prop:`outline`,xform:new Or({tag:`outline`,attr:`val`})},{tag:`shadow`,prop:`shadow`,xform:new Or({tag:`shadow`,attr:`val`})},{tag:`sz`,prop:`size`,xform:new kr({tag:`sz`,attr:`val`})},{tag:`color`,prop:`color`,xform:new N},{tag:this.options.fontNameTag,prop:`name`,xform:new P({tag:this.options.fontNameTag,attr:`val`})},{tag:`family`,prop:`family`,xform:new kr({tag:`family`,attr:`val`})},{tag:`scheme`,prop:`scheme`,xform:new P({tag:`scheme`,attr:`val`})},{tag:`charset`,prop:`charset`,xform:new kr({tag:`charset`,attr:`val`})},{tag:`vertAlign`,prop:`vertAlign`,xform:new P({tag:`vertAlign`,attr:`val`})}];this.map=Object.fromEntries(n.map(e=>[e.tag,{prop:e.prop,xform:e.xform}])),this.renderOrder=n.map(e=>e.tag)}get tag(){return this.options.tagName}render(e,t){let{map:n,renderOrder:r}=this;e.openNode(this.options.tagName),r.forEach(r=>{n[r].xform.render(e,t[n[r].prop])}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;if(this.map[e.name])return this.parser=this.map[e.name].xform,this.parser.parseOpen(e);switch(e.name){case this.options.tagName:return this.model={},!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser&&!this.parser.parseClose(e)){let t=this.map[e];return this.parser.model&&(this.model[t.prop]=this.parser.model),this.parser=void 0,!0}switch(e){case this.options.tagName:return!1;default:return!0}}static{this.OPTIONS={tagName:`font`,fontNameTag:`name`}}},Mr=class extends j{constructor(){super(),this.map={color:new N}}get tag(){return`stop`}render(e,t){e.openNode(`stop`),e.addAttribute(`position`,t.position),this.map.color.render(e,t.color),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`stop`:return this.model={position:parseFloat(e.attributes.position)},!0;case`color`:return this.parser=this.map.color,this.parser.parseOpen(e),!0;default:return!1}}parseText(){}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.model.color=this.parser.model,this.parser=void 0),!0):!1}},Nr=class extends j{constructor(){super(),this.map={fgColor:new N(`fgColor`),bgColor:new N(`bgColor`)}}get name(){return`pattern`}get tag(){return`patternFill`}render(e,t){e.openNode(`patternFill`),e.addAttribute(`patternType`,t.pattern),t.fgColor&&this.map.fgColor.render(e,t.fgColor),t.bgColor&&this.map.bgColor.render(e,t.bgColor),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`patternFill`:return this.model={type:`pattern`,pattern:e.attributes.patternType},!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser.model&&(this.model[e]=this.parser.model),this.parser=void 0),!0):!1}},Pr=class extends j{constructor(){super(),this.map={stop:new Mr}}get name(){return`gradient`}get tag(){return`gradientFill`}render(e,t){switch(e.openNode(`gradientFill`),t.gradient){case`angle`:e.addAttribute(`degree`,t.degree);break;case`path`:e.addAttribute(`type`,`path`),t.center.left&&(e.addAttribute(`left`,t.center.left),t.center.right===void 0&&e.addAttribute(`right`,t.center.left)),t.center.right&&e.addAttribute(`right`,t.center.right),t.center.top&&(e.addAttribute(`top`,t.center.top),t.center.bottom===void 0&&e.addAttribute(`bottom`,t.center.top)),t.center.bottom&&e.addAttribute(`bottom`,t.center.bottom);break;default:break}let n=this.map.stop;t.stops.forEach(t=>{n.render(e,t)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`gradientFill`:{let t=this.model={stops:[]};return e.attributes.degree?(t.gradient=`angle`,t.degree=parseInt(e.attributes.degree,10)):e.attributes.type===`path`&&(t.gradient=`path`,t.center={left:e.attributes.left?parseFloat(e.attributes.left):0,top:e.attributes.top?parseFloat(e.attributes.top):0},e.attributes.right!==e.attributes.left&&(t.center.right=e.attributes.right?parseFloat(e.attributes.right):0),e.attributes.bottom!==e.attributes.top&&(t.center.bottom=e.attributes.bottom?parseFloat(e.attributes.bottom):0)),!0}case`stop`:return this.parser=this.map.stop,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.model.stops.push(this.parser.model),this.parser=void 0),!0):!1}},Fr=class e extends j{constructor(){super(),this.map={patternFill:new Nr,gradientFill:new Pr}}get tag(){return`fill`}render(e,t){switch(e.addRollback(),e.openNode(`fill`),t.type){case`pattern`:this.map.patternFill.render(e,t);break;case`gradient`:this.map.gradientFill.render(e,t);break;default:e.rollback();return}e.closeNode(),e.commit()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`fill`:return this.model={},!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.model=this.parser.model,this.model.type=this.parser.name,this.parser=void 0),!0):!1}validStyle(t){return e.validPatternValues[t]}static{this.validPatternValues=[`none`,`solid`,`darkVertical`,`darkGray`,`mediumGray`,`lightGray`,`gray125`,`gray0625`,`darkHorizontal`,`darkVertical`,`darkDown`,`darkUp`,`darkGrid`,`darkTrellis`,`lightHorizontal`,`lightVertical`,`lightDown`,`lightUp`,`lightGrid`,`lightTrellis`,`lightGrid`].reduce((e,t)=>(e[t]=!0,e),{})}static{this.StopXform=Mr}static{this.PatternFillXform=Nr}static{this.GradientFillXform=Pr}},Ir=class e extends j{constructor(e){super(),this.name=e,this.map={color:new N}}get tag(){return this.name}render(e,t,n){let r=t&&t.color||n||this.defaultColor;e.openNode(this.name),t&&t.style&&(e.addAttribute(`style`,t.style),r&&this.map.color.render(e,r)),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.name:{let{style:t}=e.attributes;return t?this.model={style:t}:this.model=void 0,!0}case`color`:return this.parser=this.map.color,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser=void 0),!0):(e===this.name&&this.map.color.model&&(this.model||={},this.model.color=this.map.color.model),!1)}validStyle(t){return e.validStyleValues[t]}static{this.validStyleValues=[`thin`,`dashed`,`dotted`,`dashDot`,`hair`,`dashDotDot`,`slantDashDot`,`mediumDashed`,`mediumDashDotDot`,`mediumDashDot`,`medium`,`double`,`thick`].reduce((e,t)=>(e[t]=!0,e),{})}},Lr=class extends j{constructor(){super(),this.map={top:new Ir(`top`),left:new Ir(`left`),bottom:new Ir(`bottom`),right:new Ir(`right`),diagonal:new Ir(`diagonal`)}}render(e,t){let{color:n}=t;e.openNode(`border`),t.diagonal&&t.diagonal.style&&(t.diagonal.up&&e.addAttribute(`diagonalUp`,`1`),t.diagonal.down&&e.addAttribute(`diagonalDown`,`1`));let r=(r,i)=>{let a=r;a&&!a.color&&t.color&&(a={...a,color:t.color}),i.render(e,a,n)};r(t.left,this.map.left),r(t.right,this.map.right),r(t.top,this.map.top),r(t.bottom,this.map.bottom),r(t.diagonal,this.map.diagonal),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`border`:return this.reset(),this.diagonalUp=D(e.attributes.diagonalUp),this.diagonalDown=D(e.attributes.diagonalDown),!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;if(e===`border`){let e=this.model={},t=(t,n,r)=>{n&&(r&&Object.assign(n,r),e[t]=n)};t(`left`,this.map.left.model),t(`right`,this.map.right.model),t(`top`,this.map.top.model),t(`bottom`,this.map.bottom.model),t(`diagonal`,this.map.diagonal.model,{up:this.diagonalUp,down:this.diagonalDown})}return!1}};let Rr={0:{f:`General`},1:{f:`0`},2:{f:`0.00`},3:{f:`#,##0`},4:{f:`#,##0.00`},9:{f:`0%`},10:{f:`0.00%`},11:{f:`0.00E+00`},12:{f:`# ?/?`},13:{f:`# ??/??`},14:{f:`mm-dd-yy`},15:{f:`d-mmm-yy`},16:{f:`d-mmm`},17:{f:`mmm-yy`},18:{f:`h:mm AM/PM`},19:{f:`h:mm:ss AM/PM`},20:{f:`h:mm`},21:{f:`h:mm:ss`},22:{f:`m/d/yy "h":mm`},27:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},28:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},29:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},30:{"zh-tw":`m/d/yy `,"zh-cn":`m-d-yy`,"ja-jp":`m/d/yy`,"ko-kr":`mm-dd-yy`},31:{"zh-tw":`yyyy"年"m"月"d"日"`,"zh-cn":`yyyy"年"m"月"d"日"`,"ja-jp":`yyyy"年"m"月"d"日"`,"ko-kr":`yyyy"년" mm"월" dd"일"`},32:{"zh-tw":`hh"時"mm"分"`,"zh-cn":`h"时"mm"分"`,"ja-jp":`h"時"mm"分"`,"ko-kr":`h"시" mm"분"`},33:{"zh-tw":`hh"時"mm"分"ss"秒"`,"zh-cn":`h"时"mm"分"ss"秒"`,"ja-jp":`h"時"mm"分"ss"秒"`,"ko-kr":`h"시" mm"분" ss"초"`},34:{"zh-tw":`上午/下午 hh"時"mm"分"`,"zh-cn":`上午/下午 h"时"mm"分"`,"ja-jp":`yyyy"年"m"月"`,"ko-kr":`yyyy-mm-dd`},35:{"zh-tw":`上午/下午 hh"時"mm"分"ss"秒"`,"zh-cn":`上午/下午 h"时"mm"分"ss"秒"`,"ja-jp":`m"月"d"日"`,"ko-kr":`yyyy-mm-dd`},36:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},37:{f:`#,##0 ;(#,##0)`},38:{f:`#,##0 ;[Red](#,##0)`},39:{f:`#,##0.00 ;(#,##0.00)`},40:{f:`#,##0.00 ;[Red](#,##0.00)`},45:{f:`mm:ss`},46:{f:`[h]:mm:ss`},47:{f:`mmss.0`},48:{f:`##0.0E+0`},49:{f:`@`},50:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},51:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},52:{"zh-tw":`上午/下午 hh"時"mm"分"`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`yyyy"年"m"月"`,"ko-kr":`yyyy-mm-dd`},53:{"zh-tw":`上午/下午 hh"時"mm"分"ss"秒"`,"zh-cn":`m"月"d"日"`,"ja-jp":`m"月"d"日"`,"ko-kr":`yyyy-mm-dd`},54:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},55:{"zh-tw":`上午/下午 hh"時"mm"分"`,"zh-cn":`上午/下午 h"时"mm"分"`,"ja-jp":`yyyy"年"m"月"`,"ko-kr":`yyyy-mm-dd`},56:{"zh-tw":`上午/下午 hh"時"mm"分"ss"秒"`,"zh-cn":`上午/下午 h"时"mm"分"ss"秒"`,"ja-jp":`m"月"d"日"`,"ko-kr":`yyyy-mm-dd`},57:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},58:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},59:{"th-th":`t0`},60:{"th-th":`t0.00`},61:{"th-th":`t#,##0`},62:{"th-th":`t#,##0.00`},67:{"th-th":`t0%`},68:{"th-th":`t0.00%`},69:{"th-th":`t# ?/?`},70:{"th-th":`t# ??/??`},81:{"th-th":`d/m/bb`}};function zr(){let e={};return Object.entries(Rr).forEach(([t,n])=>{n.f&&(e[n.f]=parseInt(t,10))}),e}let Br=null;function Vr(){return Br||=zr(),Br}var Hr=class extends j{constructor(e,t){super(),this.id=e,this.formatCode=t}get tag(){return`numFmt`}render(e,t){e.leafNode(`numFmt`,{numFmtId:t.id,formatCode:t.formatCode})}parseOpen(e){switch(e.name){case`numFmt`:return this.model={id:parseInt(e.attributes.numFmtId,10),formatCode:e.attributes.formatCode.replace(/[\\](.)/g,`$1`)},!0;default:return!1}}parseText(){}parseClose(){return!1}static getDefaultFmtId(e){return Vr()[e]}static getDefaultFmtCode(e){return Rr[e]&&Rr[e].f}};let Ur={ReadingOrder:{LeftToRight:1,RightToLeft:2}},Wr={horizontalValues:[`left`,`center`,`right`,`fill`,`centerContinuous`,`distributed`,`justify`].reduce((e,t)=>(e[t]=!0,e),{}),horizontal(e){return this.horizontalValues[e]?e:void 0},verticalValues:[`top`,`middle`,`bottom`,`distributed`,`justify`].reduce((e,t)=>(e[t]=!0,e),{}),vertical(e){return e===`middle`?`center`:this.verticalValues[e]?e:void 0},wrapText(e){return e?!0:void 0},shrinkToFit(e){return e?!0:void 0},textRotation(e){switch(e){case`vertical`:return e;default:{let t=Ct(e);return t!==void 0&&t>=-90&&t<=90?t:void 0}}},indent(e){let t=Ct(e);return Math.max(0,t)},readingOrder(e){switch(e){case`ltr`:return Ur.ReadingOrder.LeftToRight;case`rtl`:return Ur.ReadingOrder.RightToLeft;default:return}}},Gr={toXml(e){let t=Wr.textRotation(e);if(t){if(t===`vertical`)return 255;let e=Math.round(t);if(e>=0&&e<=90)return e;if(e<0&&e>=-90)return 90-e}},toModel(e){let t=Ct(e);if(t!==void 0){if(t===255)return`vertical`;if(t>=0&&t<=90)return t;if(t>90&&t<=180)return 90-t}}};var Kr=class extends j{get tag(){return`alignment`}render(e,t){e.addRollback(),e.openNode(`alignment`);let n=!1;function r(t,r){r&&(e.addAttribute(t,r),n=!0)}r(`horizontal`,Wr.horizontal(t.horizontal)),r(`vertical`,Wr.vertical(t.vertical)),r(`wrapText`,Wr.wrapText(t.wrapText)?`1`:!1),r(`shrinkToFit`,Wr.shrinkToFit(t.shrinkToFit)?`1`:!1),r(`indent`,Wr.indent(t.indent)),r(`textRotation`,Gr.toXml(t.textRotation)),r(`readingOrder`,Wr.readingOrder(t.readingOrder)),e.closeNode(),n?e.commit():e.rollback()}parseOpen(e){let t={},n=!1;function r(e,r,i){e&&(t[r]=i,n=!0)}r(e.attributes.horizontal,`horizontal`,e.attributes.horizontal),r(e.attributes.vertical,`vertical`,e.attributes.vertical===`center`?`middle`:e.attributes.vertical),r(e.attributes.wrapText,`wrapText`,D(e.attributes.wrapText)),r(e.attributes.shrinkToFit,`shrinkToFit`,D(e.attributes.shrinkToFit)),r(e.attributes.indent,`indent`,parseInt(e.attributes.indent,10)),r(e.attributes.textRotation,`textRotation`,Gr.toModel(e.attributes.textRotation)),r(e.attributes.readingOrder,`readingOrder`,e.attributes.readingOrder===`2`?`rtl`:`ltr`),this.model=n?t:null}parseText(){}parseClose(){return!1}};let qr={boolean(e,t){return e===void 0?t:e}};var Jr=class extends j{get tag(){return`protection`}render(e,t){e.addRollback(),e.openNode(`protection`);let n=!1;function r(t,r){r!==void 0&&(e.addAttribute(t,r),n=!0)}r(`locked`,qr.boolean(t.locked,!0)?void 0:`0`),r(`hidden`,qr.boolean(t.hidden,!1)?`1`:void 0),e.closeNode(),n?e.commit():e.rollback()}parseOpen(e){let t={locked:e.attributes.locked!==`0`,hidden:e.attributes.hidden===`1`};this.model=!t.locked||t.hidden?t:null}parseText(){}parseClose(){return!1}},Yr=class extends j{constructor(e){super(),this.xfId=!!(e&&e.xfId),this.map={alignment:new Kr,protection:new Jr}}get tag(){return`xf`}render(e,t){e.openNode(`xf`,{numFmtId:t.numFmtId??0,fontId:t.fontId??0,fillId:t.fillId??0,borderId:t.borderId??0}),this.xfId&&e.addAttribute(`xfId`,t.xfId??0),(t.applyNumberFormat||t.numFmtId)&&e.addAttribute(`applyNumberFormat`,`1`),(t.applyFont||t.fontId)&&e.addAttribute(`applyFont`,`1`),(t.applyFill||t.fillId)&&e.addAttribute(`applyFill`,`1`),(t.applyBorder||t.borderId)&&e.addAttribute(`applyBorder`,`1`),(t.applyAlignment||t.alignment)&&e.addAttribute(`applyAlignment`,`1`),(t.applyProtection||t.protection)&&e.addAttribute(`applyProtection`,`1`),t.pivotButton&&e.addAttribute(`pivotButton`,`1`),t.alignment&&this.map.alignment.render(e,t.alignment),t.protection&&this.map.protection.render(e,t.protection),t.checkbox&&t.xfComplementIndex!==void 0&&(e.openNode(`extLst`),e.openNode(`ext`,{"xmlns:xfpb":`http://schemas.microsoft.com/office/spreadsheetml/2022/featurepropertybag`,uri:`{C7286773-470A-42A8-94C5-96B5CB345126}`}),e.leafNode(`xfpb:xfComplement`,{i:t.xfComplementIndex}),e.closeNode(),e.closeNode()),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`xf`:this.model={numFmtId:parseInt(e.attributes.numFmtId,10),fontId:parseInt(e.attributes.fontId,10),fillId:parseInt(e.attributes.fillId,10),borderId:parseInt(e.attributes.borderId,10)},this.xfId&&(this.model.xfId=parseInt(e.attributes.xfId,10)),e.attributes.pivotButton===`1`&&(this.model.pivotButton=!0);for(let t of[`applyNumberFormat`,`applyFont`,`applyFill`,`applyBorder`,`applyAlignment`,`applyProtection`])e.attributes[t]===`1`&&(this.model[t]=!0);return!0;case`alignment`:return this.parser=this.map.alignment,this.parser.parseOpen(e),!0;case`protection`:return this.parser=this.map.protection,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.map.protection===this.parser?this.model.protection=this.parser.model:this.model.alignment=this.parser.model,this.parser=void 0),!0):e!==`xf`}},Xr=class extends j{constructor(){super(),this.map={alignment:new Kr,border:new Lr,fill:new Fr,font:new jr,numFmt:new Hr,protection:new Jr}}get tag(){return`dxf`}render(e,t){if(e.openNode(this.tag),t.font&&this.map.font.render(e,t.font),t.numFmt&&t.numFmtId){let n={id:t.numFmtId,formatCode:t.numFmt};this.map.numFmt.render(e,n)}t.fill&&this.map.fill.render(e,t.fill),t.alignment&&this.map.alignment.render(e,t.alignment),t.border&&this.map.border.render(e,t.border),t.protection&&this.map.protection.render(e,t.protection),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:return this.reset(),!0;default:return this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e),!0}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser=void 0),!0):e===this.tag?(this.model={alignment:this.map.alignment.model,border:this.map.border.model,fill:this.map.fill.model,font:this.map.font.model,numFmt:this.map.numFmt.model,protection:this.map.protection.model},!1):!0}},Zr=class e extends j{constructor(t){super(),this.map={numFmts:new M({tag:`numFmts`,count:!0,childXform:new Hr}),fonts:new M({tag:`fonts`,count:!0,childXform:new jr,$:{"x14ac:knownFonts":1}}),fills:new M({tag:`fills`,count:!0,childXform:new Fr}),borders:new M({tag:`borders`,count:!0,childXform:new Lr}),cellStyleXfs:new M({tag:`cellStyleXfs`,count:!0,childXform:new Yr}),cellXfs:new M({tag:`cellXfs`,count:!0,childXform:new Yr({xfId:!0})}),dxfs:new M({tag:`dxfs`,always:!0,count:!0,childXform:new Xr}),numFmt:new Hr,font:new jr,fill:new Fr,border:new Lr,style:new Yr({xfId:!0}),cellStyles:e.STATIC_XFORMS.cellStyles,tableStyles:e.STATIC_XFORMS.tableStyles,extLst:e.STATIC_XFORMS.extLst},t&&this.init()}initIndex(){this.index={style:{},numFmt:{},numFmtNextId:164,font:{},border:{},fill:{}}}init(){this.model={styles:[],numFmts:[],fonts:[],borders:[],fills:[],dxfs:[]},this.initIndex(),this._addBorder({}),this._addStyle({numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}),this._addFill({type:`pattern`,pattern:`none`}),this._addFill({type:`pattern`,pattern:`gray125`}),this.weakMap=new WeakMap,this._hasCheckboxes=!1}setDefaultFont(e){this.defaultFont=e}render(t,n){let r=n||this.model;t.openXml(k.StdDocAttributes),t.openNode(`styleSheet`,e.STYLESHEET_ATTRIBUTES),this.index?(r.numFmts&&r.numFmts.length&&(t.openNode(`numFmts`,{count:r.numFmts.length}),r.numFmts.forEach(e=>{t.writeXml(e)}),t.closeNode()),r.fonts.length||this._addFont(this.defaultFont||{size:11,color:{theme:1},name:`Calibri`,family:2,scheme:`minor`}),t.openNode(`fonts`,{count:r.fonts.length,"x14ac:knownFonts":1}),r.fonts.forEach(e=>{t.writeXml(e)}),t.closeNode(),t.openNode(`fills`,{count:r.fills.length}),r.fills.forEach(e=>{t.writeXml(e)}),t.closeNode(),t.openNode(`borders`,{count:r.borders.length}),r.borders.forEach(e=>{t.writeXml(e)}),t.closeNode(),this.map.cellStyleXfs.render(t,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),t.openNode(`cellXfs`,{count:r.styles.length}),r.styles.forEach(e=>{t.writeXml(e)}),t.closeNode()):(this.map.numFmts.render(t,r.numFmts),this.map.fonts.render(t,r.fonts),this.map.fills.render(t,r.fills),this.map.borders.render(t,r.borders),this.map.cellStyleXfs.render(t,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),this.map.cellXfs.render(t,r.styles)),e.STATIC_XFORMS.cellStyles.render(t),this.map.dxfs.render(t,r.dxfs),e.STATIC_XFORMS.tableStyles.render(t),e.STATIC_XFORMS.extLst.render(t),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`styleSheet`:return this.initIndex(),!0;default:return this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e),!0}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`styleSheet`:{this.model={};let e=(e,t)=>{t.model&&t.model.length&&(this.model[e]=t.model)};if(e(`numFmts`,this.map.numFmts),e(`fonts`,this.map.fonts),e(`fills`,this.map.fills),e(`borders`,this.map.borders),e(`styles`,this.map.cellXfs),e(`dxfs`,this.map.dxfs),this.map.fonts.model&&this.map.fonts.model.length>0&&(this.defaultFont=this.map.fonts.model[0]),this.index={model:[],numFmt:{}},this.model.numFmts){let e=this.index.numFmt;this.model.numFmts.forEach(t=>{e[t.id]=t.formatCode})}return!1}default:return!0}}addStyleModel(e,t){if(!e)return 0;this.model.fonts.length||this._addFont(this.defaultFont||{size:11,color:{theme:1},name:`Calibri`,family:2,scheme:`minor`});let n=t||w.ValueType.Number;if(n!==w.ValueType.Checkbox&&this.weakMap&&this.weakMap.has(e))return this.weakMap.get(e);let r={};if(e.numFmt)r.numFmtId=this._addNumFmtStr(e.numFmt);else switch(n){case w.ValueType.Number:r.numFmtId=this._addNumFmtStr(`General`);break;case w.ValueType.Date:r.numFmtId=this._addNumFmtStr(`mm-dd-yy`);break;default:break}e.font&&(r.fontId=this._addFont(e.font)),e.border&&(r.borderId=this._addBorder(e.border)),e.fill&&(r.fillId=this._addFill(e.fill)),e.alignment&&(r.alignment=e.alignment),e.protection&&(r.protection=e.protection);for(let t of[`pivotButton`,`applyNumberFormat`,`applyFont`,`applyFill`,`applyBorder`,`applyAlignment`,`applyProtection`])e[t]&&(r[t]=!0);n===w.ValueType.Checkbox&&(this._hasCheckboxes=!0,r.alignment=r.alignment||{},r.checkbox=!0,r.xfComplementIndex=0);let i=this._addStyle(r);return n!==w.ValueType.Checkbox&&this.weakMap&&this.weakMap.set(e,i),i}getStyleModel(e){let t=this.model.styles[e];if(!t)return null;let n=this.index.model[e];if(n)return n;if(n=this.index.model[e]={},t.numFmtId){let e=this.index.numFmt[t.numFmtId]||Hr.getDefaultFmtCode(t.numFmtId);e&&(n.numFmt=e)}function r(e,t,r){if(r||r===0){let i=t[r];i&&(n[e]=i)}}r(`font`,this.model.fonts,t.fontId),r(`border`,this.model.borders,t.borderId),r(`fill`,this.model.fills,t.fillId),t.alignment&&(n.alignment=t.alignment),t.protection&&(n.protection=t.protection);for(let e of[`pivotButton`,`applyNumberFormat`,`applyFont`,`applyFill`,`applyBorder`,`applyAlignment`,`applyProtection`])t[e]&&(n[e]=!0);return n}addDxfStyle(e){return e.numFmt&&(e.numFmtId=this._addNumFmtStr(e.numFmt)),this.model.dxfs.push(e),this.model.dxfs.length-1}getDxfStyle(e){return this.model.dxfs[e]}get hasCheckboxes(){return!!this._hasCheckboxes}_addStyle(e){let t=this.map.style.toXml(e),n=this.index.style[t];return n===void 0&&(n=this.index.style[t]=this.model.styles.length,this.model.styles.push(t)),n}_addNumFmtStr(e){let t=Hr.getDefaultFmtId(e);if(t!==void 0||(t=this.index.numFmt[e],t!==void 0))return t;t=this.index.numFmt[e]=164+this.model.numFmts.length;let n=this.map.numFmt.toXml({id:t,formatCode:e});return this.model.numFmts.push(n),t}_addFont(e){let t=this.map.font.toXml(e),n=this.index.font[t];return n===void 0&&(n=this.index.font[t]=this.model.fonts.length,this.model.fonts.push(t)),n}_addBorder(e){let t=this.map.border.toXml(e),n=this.index.border[t];return n===void 0&&(n=this.index.border[t]=this.model.borders.length,this.model.borders.push(t)),n}_addFill(e){let t=this.map.fill.toXml(e),n=this.index.fill[t];return n===void 0&&(n=this.index.fill[t]=this.model.fills.length,this.model.fills.push(t)),n}static{this.STYLESHEET_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`,"mc:Ignorable":`x14ac x16r2`,"xmlns:x14ac":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac`,"xmlns:x16r2":`http://schemas.microsoft.com/office/spreadsheetml/2015/02/main`}}static{this.STATIC_XFORMS={cellStyles:new Dr({tag:`cellStyles`,$:{count:1},c:[{tag:`cellStyle`,$:{name:`Normal`,xfId:0,builtinId:0}}]}),dxfs:new Dr({tag:`dxfs`,$:{count:0}}),tableStyles:new Dr({tag:`tableStyles`,$:{count:0,defaultTableStyle:`TableStyleMedium2`,defaultPivotStyle:`PivotStyleLight16`}}),extLst:new Dr({tag:`extLst`,c:[{tag:`ext`,$:{uri:`{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}`,"xmlns:x14":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`},c:[{tag:`x14:slicerStyles`,$:{defaultSlicerStyle:`SlicerStyleLight1`}}]},{tag:`ext`,$:{uri:`{9260A510-F301-46a8-8635-F512D64BE5F5}`,"xmlns:x15":`http://schemas.microsoft.com/office/spreadsheetml/2010/11/main`},c:[{tag:`x15:timelineStyles`,$:{defaultTimelineStyle:`TimeSlicerStyleLight1`}}]}]})}}};Zr.Mock=class extends Zr{constructor(){super(),this.model={styles:[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}],numFmts:[],fonts:[{size:11,color:{theme:1},name:`Calibri`,family:2,scheme:`minor`}],borders:[{}],fills:[{type:`pattern`,pattern:`none`},{type:`pattern`,pattern:`gray125`}]}}parseStream(e){return e.autodrain(),Promise.resolve()}addStyleModel(e,t){switch(t){case w.ValueType.Checkbox:throw new v(`Checkbox cells`,`require styles to be enabled (useStyles: true)`);case w.ValueType.Date:return this.dateStyleId;default:return 0}}get hasCheckboxes(){return!1}get dateStyleId(){if(!this._dateStyleId){let e={numFmtId:Hr.getDefaultFmtId(`mm-dd-yy`)};this._dateStyleId=this.model.styles.length,this.model.styles.push(e)}return this._dateStyleId}getStyleModel(){return{}}};var Qr=class extends j{constructor(e){super(),this.tag=e.tag,this.attr=e.attr,this.attrs=e.attrs,this.text=[],this._format=e.format||function(e){try{return Number.isNaN(e.getTime())?``:e.toISOString()}catch{return``}},this._parse=e.parse||function(e){return new Date(e)}}render(e,t){t&&(e.openNode(this.tag),this.attrs&&e.addAttributes(this.attrs),this.attr?e.addAttribute(this.attr,this._format(t)):e.writeText(this._format(t)),e.closeNode())}parseOpen(e){e.name===this.tag&&(this.attr?this.model=this._parse(e.attributes[this.attr]):this.text=[])}parseText(e){this.attr||this.text.push(e)}parseClose(){return this.attr||(this.model=this._parse(this.text.join(``))),!1}};let F={creator:`dc:creator`,title:`dc:title`,subject:`dc:subject`,description:`dc:description`,identifier:`dc:identifier`,language:`dc:language`,keywords:`cp:keywords`,category:`cp:category`,lastModifiedBy:`cp:lastModifiedBy`,lastPrinted:`cp:lastPrinted`,revision:`cp:revision`,version:`cp:version`,contentStatus:`cp:contentStatus`,contentType:`cp:contentType`,created:`dcterms:created`,modified:`dcterms:modified`};var $r=class e extends j{constructor(){super(),this.map={creator:new P({tag:F.creator}),title:new P({tag:F.title}),subject:new P({tag:F.subject}),description:new P({tag:F.description}),identifier:new P({tag:F.identifier}),language:new P({tag:F.language}),keywords:new P({tag:F.keywords}),category:new P({tag:F.category}),lastModifiedBy:new P({tag:F.lastModifiedBy}),lastPrinted:new Qr({tag:F.lastPrinted,format:e.DateFormat}),revision:new kr({tag:F.revision}),version:new P({tag:F.version}),contentStatus:new P({tag:F.contentStatus}),contentType:new P({tag:F.contentType}),created:new Qr({tag:F.created,attrs:e.DateAttrs,format:e.DateFormat}),modified:new Qr({tag:F.modified,attrs:e.DateAttrs,format:e.DateFormat})}}render(t,n){t.openXml(k.StdDocAttributes),t.openNode(`cp:coreProperties`,e.CORE_PROPERTY_ATTRIBUTES);for(let e of Object.keys(F))this.map[e].render(t,n[e]);t.closeNode()}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):(e.name!==`coreProperties`&&(this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e)),!0)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;if(e===`coreProperties`){this.model={};for(let e of Object.keys(F)){let t=this.map[e].model;t!==void 0&&t!==``&&(this.model[e]=t)}return!1}return!0}static{this.DateFormat=function(e){return e.toISOString().replace(/[.]\d{3}/,``)}}static{this.DateAttrs={"xsi:type":`dcterms:W3CDTF`}}static{this.CORE_PROPERTY_ATTRIBUTES={"xmlns:cp":`http://schemas.openxmlformats.org/package/2006/metadata/core-properties`,"xmlns:dc":`http://purl.org/dc/elements/1.1/`,"xmlns:dcterms":`http://purl.org/dc/terms/`,"xmlns:dcmitype":`http://purl.org/dc/dcmitype/`,"xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`}}},ei=class extends j{get tag(){return`t`}render(e,t){e.openNode(`t`),/^\s|\n|\s$/.test(t)&&e.addAttribute(`xml:space`,`preserve`),e.writeText(gt(t)),e.closeNode()}parseOpen(e){return e.name===`t`?(this._text=[],this.model=``,!0):!1}parseText(e){this._text.push(e),this.model=ht(this._text.join(``))}parseClose(){return!1}},ti=class e extends j{constructor(e){super(),this.model=e}get tag(){return`r`}get textXform(){return this._textXform||=new ei}get fontXform(){return this._fontXform||=new jr(e.FONT_OPTIONS)}render(e,t){let n=t||this.model;e.openNode(`r`),n.font&&this.fontXform.render(e,n.font),this.textXform.render(e,n.text),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`r`:return this.model={},!0;case`t`:return this.parser=this.textXform,this.parser.parseOpen(e),!0;case`rPr`:return this.parser=this.fontXform,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){switch(e){case`r`:return!1;case`t`:return this.model.text=this.parser.model,this.parser=void 0,!0;case`rPr`:return this.model.font=this.parser.model,this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(e),!0}}static{this.FONT_OPTIONS={tagName:`rPr`,fontNameTag:`rFont`}}},ni=class extends j{constructor(){super(),this.map={r:new ti,t:new ei}}get tag(){return`rPh`}render(e,t){if(e.openNode(this.tag,{sb:t.sb??0,eb:t.eb??0}),t&&Object.prototype.hasOwnProperty.call(t,`richText`)&&t.richText){let{r:n}=this.map;t.richText.forEach(t=>{n.render(e,t)})}else t&&this.map.t.render(e,t.text);e.closeNode()}parseOpen(e){let{name:t}=e;return this.parser?(this.parser.parseOpen(e),!0):t===this.tag?(this.model={sb:parseInt(e.attributes.sb,10),eb:parseInt(e.attributes.eb,10)},!0):(this.parser=this.map[t],this.parser?(this.parser.parseOpen(e),!0):!1)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)){switch(e){case`r`:{let e=this.model.richText;e||=this.model.richText=[],e.push(this.parser.model);break}case`t`:this.model.text=this.parser.model;break;default:break}this.parser=void 0}return!0}switch(e){case this.tag:return!1;default:return!0}}},ri=class extends j{constructor(e){super(),this.model=e,this.map={r:new ti,t:new ei,rPh:new ni}}get tag(){return`si`}render(e,t){e.openNode(this.tag),t&&typeof t==`object`&&Object.prototype.hasOwnProperty.call(t,`richText`)&&t.richText?t.richText.length?t.richText.forEach(t=>{this.map.r.render(e,t)}):this.map.t.render(e,``):t!=null&&this.map.t.render(e,t),e.closeNode()}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.model={},!0):(this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)){switch(e){case`r`:{let e=this.model.richText;e||=this.model.richText=[],e.push(this.parser.model);break}case`t`:this.model=this.parser.model;break;default:break}this.parser=void 0}return!0}switch(e){case this.tag:return!1;default:return!0}}},ii=class extends j{constructor(e){super(),this.model=e||{values:[],count:0},this.hash=Object.create(null),this.rich=Object.create(null)}get sharedStringXform(){return this._sharedStringXform||=new ri}get values(){return this.model.values}get uniqueCount(){return this.model.values.length}get count(){return this.model.count}getString(e){return this.model.values[e]}add(e){return e.richText?this.addRichText(e):this.addText(e)}addText(e){let t=this.hash[e];return t===void 0&&(t=this.hash[e]=this.model.values.length,this.model.values.push(e)),this.model.count++,t}addRichText(e){let t=this.sharedStringXform.toXml(e),n=this.rich[t];return n===void 0&&(n=this.rich[t]=this.model.values.length,this.model.values.push(e)),this.model.count++,n}render(e,t){let n=t||this._values;e.openXml(k.StdDocAttributes),e.openNode(`sst`,{xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,count:n.count,uniqueCount:n.values.length});let r=this.sharedStringXform;n.values.forEach(t=>{r.render(e,t)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`sst`:return!0;case`si`:return this.parser=this.sharedStringXform,this.parser.parseOpen(e),!0;default:throw new _(`sharedStrings`,`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.values.push(this.parser.model),this.model.count++,this.parser=void 0),!0;switch(e){case`sst`:return!1;default:throw new _(`sharedStrings`,`Unexpected xml node in parseClose: ${e}`)}}},ai=class extends j{render(e,t){e.leafNode(`Relationship`,t)}parseOpen(e){switch(e.name){case`Relationship`:return this.model=e.attributes,!0;default:return!1}}parseText(){}parseClose(){return!1}},I=class e extends j{constructor(){super(),this.map={Relationship:new ai}}render(t,n){let r=n||this._values;t.openXml(k.StdDocAttributes),t.openNode(`Relationships`,e.RELATIONSHIPS_ATTRIBUTES),r.forEach(e=>{this.map.Relationship.render(t,e)}),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`Relationships`:return this.model=[],!0;default:if(this.parser=this.map[e.name],this.parser)return this.parser.parseOpen(e),!0;throw new _(`Relationships`,`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.push(this.parser.model),this.parser=void 0),!0;switch(e){case`Relationships`:return!1;default:throw new _(`Relationships`,`Unexpected xml node in parseClose: ${e}`)}}static{this.RELATIONSHIPS_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/package/2006/relationships`}}};let L={contentTypes:`[Content_Types].xml`,rootRels:`_rels/.rels`,docPropsApp:`docProps/app.xml`,docPropsCore:`docProps/core.xml`,xlWorkbook:`xl/workbook.xml`,xlWorkbookRels:`xl/_rels/workbook.xml.rels`,xlSharedStrings:`xl/sharedStrings.xml`,xlStyles:`xl/styles.xml`,xlTheme1:`xl/theme/theme1.xml`,xlFeaturePropertyBag:`xl/featurePropertyBag/featurePropertyBag.xml`},oi=/^xl\/worksheets\/sheet(\d+)[.]xml$/,si=/^xl\/worksheets\/_rels\/sheet(\d+)[.]xml[.]rels$/,ci=/^xl\/theme\/[a-zA-Z0-9]+[.]xml$/,li=/^xl\/media\/([a-zA-Z0-9]+[.][a-zA-Z0-9]{3,4})$/,ui=/^xl\/drawings\/(drawing\d+)[.]xml$/,di=/^xl\/drawings\/_rels\/(drawing\d+)[.]xml[.]rels$/,fi=/^xl\/drawings\/(vmlDrawing\d+)[.]vml$/,pi=/^xl\/comments(\d+)[.]xml$/,mi=/^xl\/tables\/(table\d+)[.]xml$/,hi=/^xl\/pivotTables\/(pivotTable\d+)[.]xml$/,gi=/^xl\/pivotTables\/_rels\/(pivotTable\d+)[.]xml[.]rels$/,_i=/^xl\/pivotCache\/(pivotCacheDefinition\d+)[.]xml$/,vi=/^xl\/pivotCache\/_rels\/(pivotCacheDefinition\d+)[.]xml[.]rels$/,yi=/^xl\/pivotCache\/(pivotCacheRecords\d+)[.]xml$/;function bi(e){return e.startsWith(`/`)?e.slice(1):e}function xi(e){let t=oi.exec(e);if(t)return parseInt(t[1],10)}function Si(e){let t=si.exec(e);if(t)return parseInt(t[1],10)}function Ci(e){return e.startsWith(`xl/media/`)}function wi(e){let t=li.exec(e);return t?t[1]:void 0}function Ti(e){return ci.test(e)}function Ei(e){let t=/^xl\/theme\/([a-zA-Z0-9]+)[.]xml$/.exec(e);return t?t[1]:void 0}function Di(e){return Ci(e)||Ti(e)}function Oi(e){let t=ui.exec(e);return t?t[1]:void 0}function ki(e){let t=di.exec(e);return t?t[1]:void 0}function Ai(e){let t=fi.exec(e);return t?t[1]:void 0}function ji(e){let t=pi.exec(e);return t?t[1]:void 0}function Mi(e){let t=mi.exec(e);return t?t[1]:void 0}function Ni(e){let t=hi.exec(e);return t?t[1]:void 0}function Pi(e){let t=gi.exec(e);return t?t[1]:void 0}function Fi(e){let t=_i.exec(e);return t?t[1]:void 0}function Ii(e){let t=vi.exec(e);return t?t[1]:void 0}function Li(e){let t=yi.exec(e);return t?t[1]:void 0}function R(e){return e.startsWith(`/`)?e:`/${e}`}function Ri(e){return`xl/theme/${e}.xml`}function zi(e){return`xl/media/${e}`}function Bi(e){return`xl/worksheets/sheet${e}.xml`}function Vi(e){return`xl/worksheets/_rels/sheet${e}.xml.rels`}function Hi(e){return`worksheets/sheet${e}.xml`}function Ui(e){return`xl/comments${e}.xml`}function Wi(e){return`xl/${e}.xml`}function Gi(e){return`xl/drawings/vmlDrawing${e}.vml`}function Ki(e){return`xl/tables/${e}`}function qi(e){return`xl/drawings/${e}.xml`}function Ji(e){return`xl/drawings/_rels/${e}.xml.rels`}function Yi(e){return`xl/pivotCache/pivotCacheDefinition${e}.xml`}function Xi(e){return`xl/pivotCache/_rels/pivotCacheDefinition${e}.xml.rels`}function Zi(e){return`xl/pivotCache/pivotCacheRecords${e}.xml`}function Qi(e){return`pivotCacheRecords${e}.xml`}function $i(e){return`xl/pivotTables/pivotTable${e}.xml`}function ea(e){return`xl/pivotTables/_rels/pivotTable${e}.xml.rels`}function ta(e){return`../pivotCache/pivotCacheDefinition${e}.xml`}let na={workbookStyles:`styles.xml`,workbookSharedStrings:`sharedStrings.xml`,workbookTheme1:`theme/theme1.xml`,workbookFeaturePropertyBag:`featurePropertyBag/featurePropertyBag.xml`};function ra(e){return`pivotCache/pivotCacheDefinition${e}.xml`}function ia(e){return`../comments${e}.xml`}function aa(e){return`../drawings/vmlDrawing${e}.vml`}function oa(e){return`../drawings/${e}.xml`}function sa(e){return`../drawings/${e}.vml`}function ca(e){return`../${e}.xml`}function la(e){return`../pivotTables/pivotTable${e}.xml`}function ua(e){return`../pivotTables/${e}.xml`}function da(e){return`../tables/${e}`}function fa(e){return`../tables/${e}.xml`}function pa(e){return`../media/${e}`}function ma(e){return`xl/ctrlProps/ctrlProp${e}.xml`}function ha(e){return`../ctrlProps/ctrlProp${e}.xml`}var ga=class e extends j{render(t,n){t.openXml(k.StdDocAttributes),t.openNode(`Types`,e.PROPERTY_ATTRIBUTES);let r={};if((n.media??[]).forEach(e=>{if(e.type===`image`){let n=e.extension;r[n]||(r[n]=!0,t.leafNode(`Default`,{Extension:n,ContentType:`image/${n}`}))}}),t.leafNode(`Default`,{Extension:`rels`,ContentType:`application/vnd.openxmlformats-package.relationships+xml`}),t.leafNode(`Default`,{Extension:`xml`,ContentType:`application/xml`}),t.leafNode(`Override`,{PartName:R(L.xlWorkbook),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml`}),n.worksheets.forEach(e=>{t.leafNode(`Override`,{PartName:R(Bi(e.fileIndex)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml`})}),(n.pivotTables??[]).length){let e=new Set;(n.pivotTables??[]).forEach(n=>{let r=n.tableNumber,i=n.cacheId;e.has(i)||(e.add(i),t.leafNode(`Override`,{PartName:R(Yi(r)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml`}),(!n.isLoaded||n.cacheRecords)&&t.leafNode(`Override`,{PartName:R(Zi(r)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml`})),t.leafNode(`Override`,{PartName:R($i(r)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml`})})}t.leafNode(`Override`,{PartName:R(L.xlTheme1),ContentType:`application/vnd.openxmlformats-officedocument.theme+xml`}),t.leafNode(`Override`,{PartName:R(L.xlStyles),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml`}),n.hasCheckboxes&&t.leafNode(`Override`,{PartName:R(L.xlFeaturePropertyBag),ContentType:`application/vnd.ms-excel.featurepropertybag+xml`}),n.sharedStrings&&n.sharedStrings.count&&t.leafNode(`Override`,{PartName:R(L.xlSharedStrings),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml`}),n.tables&&n.tables.forEach(e=>{t.leafNode(`Override`,{PartName:R(Ki(e.target)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml`})}),n.drawings&&n.drawings.forEach(e=>{t.leafNode(`Override`,{PartName:R(qi(e.name)),ContentType:`application/vnd.openxmlformats-officedocument.drawing+xml`})});let i=n.commentRefs&&n.commentRefs.length>0,a=n.formControlRefs&&n.formControlRefs.length>0;if((i||a)&&t.leafNode(`Default`,{Extension:`vml`,ContentType:`application/vnd.openxmlformats-officedocument.vmlDrawing`}),i&&n.commentRefs.forEach(({commentName:e})=>{t.leafNode(`Override`,{PartName:R(Wi(e)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml`})}),a)for(let e of n.formControlRefs)t.leafNode(`Override`,{PartName:R(ma(e)),ContentType:`application/vnd.ms-excel.controlproperties+xml`});if(n.passthroughContentTypes)for(let{partName:e,contentType:r}of n.passthroughContentTypes)t.leafNode(`Override`,{PartName:R(e),ContentType:r});t.leafNode(`Override`,{PartName:R(L.docPropsCore),ContentType:`application/vnd.openxmlformats-package.core-properties+xml`}),t.leafNode(`Override`,{PartName:R(L.docPropsApp),ContentType:`application/vnd.openxmlformats-officedocument.extended-properties+xml`}),t.closeNode()}parseOpen(){return!1}parseText(){}parseClose(){return!1}static{this.PROPERTY_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/package/2006/content-types`}}},_a=class extends j{render(e,t){e.openNode(`HeadingPairs`),e.openNode(`vt:vector`,{size:2,baseType:`variant`}),e.openNode(`vt:variant`),e.leafNode(`vt:lpstr`,void 0,`Worksheets`),e.closeNode(),e.openNode(`vt:variant`),e.leafNode(`vt:i4`,void 0,t.length),e.closeNode(),e.closeNode(),e.closeNode()}parseOpen(e){return e.name===`HeadingPairs`}parseText(){}parseClose(e){return e!==`HeadingPairs`}},va=class extends j{render(e,t){e.openNode(`TitlesOfParts`),e.openNode(`vt:vector`,{size:t.length,baseType:`lpstr`}),t.forEach(t=>{e.leafNode(`vt:lpstr`,void 0,t.name)}),e.closeNode(),e.closeNode()}parseOpen(e){return e.name===`TitlesOfParts`}parseText(){}parseClose(e){return e!==`TitlesOfParts`}},ya=class e extends j{constructor(){super(),this.map={Company:new P({tag:`Company`}),Manager:new P({tag:`Manager`}),HeadingPairs:new _a,TitlesOfParts:new va}}render(t,n){t.openXml(k.StdDocAttributes),t.openNode(`Properties`,e.PROPERTY_ATTRIBUTES),t.leafNode(`Application`,void 0,`Microsoft Excel`),t.leafNode(`DocSecurity`,void 0,`0`),t.leafNode(`ScaleCrop`,void 0,`false`),this.map.HeadingPairs.render(t,n.worksheets),this.map.TitlesOfParts.render(t,n.worksheets),this.map.Company.render(t,n.company??``),this.map.Manager.render(t,n.manager),t.leafNode(`LinksUpToDate`,void 0,`false`),t.leafNode(`SharedDoc`,void 0,`false`),t.leafNode(`HyperlinksChanged`,void 0,`false`),t.leafNode(`AppVersion`,void 0,`16.0300`),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`Properties`:return!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`Properties`:return this.model={worksheets:this.map.TitlesOfParts.model,company:this.map.Company.model,manager:this.map.Manager.model},!1;default:return!0}}static{this.DateFormat=function(e){return e.toISOString().replace(/[.]\d{3,6}/,``)}}static{this.DateAttrs={"xsi:type":`dcterms:W3CDTF`}}static{this.PROPERTY_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/officeDocument/2006/extended-properties`,"xmlns:vt":`http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes`}}},ba=class extends j{constructor(){super(),this._parsedText=[]}render(e,t){e.openNode(`definedName`,{name:t.name,localSheetId:t.localSheetId}),e.writeText(t.ranges.join(`,`)),e.closeNode()}parseOpen(e){switch(e.name){case`definedName`:return this._parsedName=e.attributes.name,this._parsedLocalSheetId=e.attributes.localSheetId,this._parsedText=[],!0;default:return!1}}parseText(e){this._parsedText.push(e)}parseClose(){return this.model={name:this._parsedName,ranges:Ta(this._parsedText.join(``))},this._parsedLocalSheetId!==void 0&&(this.model.localSheetId=parseInt(this._parsedLocalSheetId,10)),!1}};let xa=/^[$]?[A-Za-z]{1,3}[$]?\d+(:[$]?[A-Za-z]{1,3}[$]?\d+)?$/,Sa=/^[$]?\d+:[$]?\d+$/,Ca=/^[$]?[A-Za-z]{1,3}:[$]?[A-Za-z]{1,3}$/;function wa(e){if(e.startsWith(`{`)||e.endsWith(`}`))return!1;let t=e.split(`!`).pop()??``;if(!xa.test(t)&&!Sa.test(t)&&!Ca.test(t))return!1;try{let t=S.decodeEx(e);return`row`in t&&typeof t.row==`number`||`top`in t&&typeof t.top==`number`||`left`in t&&typeof t.left==`number`}catch{return!1}}function Ta(e){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`))return[];let n=[],r=!1,i=``;return e.split(`,`).forEach(e=>{if(!e)return;let t=(e.match(/'/g)??[]).length;if(!t){r?i+=`${e},`:wa(e)&&n.push(e);return}let a=t%2==0;!r&&a&&wa(e)?n.push(e):r&&!a?(r=!1,wa(i+e)&&n.push(i+e),i=``):(r=!0,i+=`${e},`)}),n}let Ea=new Set([`visible`,`hidden`,`veryHidden`]);function Da(e){let t=e||`visible`;return Ea.has(t)?t:`visible`}var Oa=class extends j{render(e,t){e.leafNode(`sheet`,{name:t.name,sheetId:t.id,state:t.state===`visible`?void 0:t.state,"r:id":t.rId})}parseOpen(e){return e.name===`sheet`?(this.model={name:xt(e.attributes.name),id:parseInt(e.attributes.sheetId,10),state:Da(e.attributes.state),rId:e.attributes[`r:id`]},!0):!1}parseText(){}parseClose(){return!1}},ka=class extends j{render(e,t){let n={xWindow:t.x??0,yWindow:t.y??0,windowWidth:t.width??12e3,windowHeight:t.height??24e3,firstSheet:t.firstSheet,activeTab:t.activeTab};t.visibility&&t.visibility!==`visible`&&(n.visibility=t.visibility),e.leafNode(`workbookView`,n)}parseOpen(e){if(e.name===`workbookView`){let t=this.model={},n=function(e,n,r){t[e]=n===void 0?r:n},r=function(e,n,r){let i=n===void 0?r:parseInt(n,10);i!==void 0&&(t[e]=i)};return r(`x`,e.attributes.xWindow,0),r(`y`,e.attributes.yWindow,0),r(`width`,e.attributes.windowWidth,25e3),r(`height`,e.attributes.windowHeight,1e4),n(`visibility`,e.attributes.visibility,`visible`),r(`activeTab`,e.attributes.activeTab,void 0),r(`firstSheet`,e.attributes.firstSheet,void 0),!0}return!1}parseText(){}parseClose(){return!1}},Aa=class extends j{render(e,t){e.leafNode(`workbookPr`,{date1904:t.date1904?1:void 0,filterPrivacy:1})}parseOpen(e){return e.name===`workbookPr`?(this.model={date1904:e.attributes.date1904===`1`},!0):!1}parseText(){}parseClose(){return!1}},ja=class extends j{render(e,t){e.leafNode(`calcPr`,{calcId:171027,fullCalcOnLoad:t.fullCalcOnLoad?1:void 0})}parseOpen(e){return e.name===`calcPr`?(this.model={},!0):!1}parseText(){}parseClose(){return!1}},Ma=class extends j{render(e,t){e.leafNode(`pivotCache`,{cacheId:t.cacheId,"r:id":t.rId})}parseOpen(e){return e.name===`pivotCache`?(this.model={cacheId:e.attributes.cacheId,rId:e.attributes[`r:id`]},!0):!1}parseText(){}parseClose(){return!1}},Na=class e extends j{constructor(){super(),this.map={fileVersion:e.STATIC_XFORMS.fileVersion,workbookPr:new Aa,bookViews:new M({tag:`bookViews`,count:!1,childXform:new ka}),sheets:new M({tag:`sheets`,count:!1,childXform:new Oa}),definedNames:new M({tag:`definedNames`,count:!1,childXform:new ba}),calcPr:new ja,pivotCaches:new M({tag:`pivotCaches`,count:!1,childXform:new Ma})}}prepare(e){e.sheets=e.worksheets;let t=[],n=0;e.sheets.forEach(e=>{if(e.pageSetup&&e.pageSetup.printArea&&e.pageSetup.printArea.split(`&&`).forEach(r=>{let i=r.split(`:`),a=i[0],o=i[1]??a,s={name:`_xlnm.Print_Area`,ranges:[`'${e.name}'!$${a}:$${o}`],localSheetId:n};t.push(s)}),e.pageSetup&&(e.pageSetup.printTitlesRow||e.pageSetup.printTitlesColumn)){let r=[];if(e.pageSetup.printTitlesColumn){let t=e.pageSetup.printTitlesColumn.split(`:`),n=t[0],i=t[1]??n;r.push(`'${e.name}'!$${n}:$${i}`)}if(e.pageSetup.printTitlesRow){let t=e.pageSetup.printTitlesRow.split(`:`),n=t[0],i=t[1]??n;r.push(`'${e.name}'!$${n}:$${i}`)}let i={name:`_xlnm.Print_Titles`,ranges:r,localSheetId:n};t.push(i)}n++}),t.length&&(e.definedNames=e.definedNames.concat(t)),(e.media??[]).forEach((e,t)=>{e.name=e.type+(t+1)})}render(t,n){t.openXml(k.StdDocAttributes),t.openNode(`workbook`,e.WORKBOOK_ATTRIBUTES),this.map.fileVersion.render(t),this.map.workbookPr.render(t,n.properties),this.map.bookViews.render(t,n.views),this.map.sheets.render(t,n.sheets),this.map.definedNames.render(t,n.definedNames),this.map.calcPr.render(t,n.calcProperties);let r=n.pivotTables??[],i=new Set,a=r.filter(e=>i.has(e.cacheId)?!1:(i.add(e.cacheId),!0));this.map.pivotCaches.render(t,a),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`workbook`:return!0;default:return this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e),!0}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`workbook`:return this.model={sheets:this.map.sheets.model,properties:this.map.workbookPr.model||{},views:this.map.bookViews.model,calcProperties:{}},this.map.definedNames.model&&(this.model.definedNames=this.map.definedNames.model),this.map.pivotCaches.model&&this.map.pivotCaches.model.length>0&&(this.model.pivotCaches=this.map.pivotCaches.model),!1;default:return!0}}reconcile(e){let t=(e.workbookRels??[]).reduce((e,t)=>(e[t.Id]=t,e),{}),n=[],r,i=0;(e.sheets??[]).forEach(a=>{let o=t[a.rId];o&&(r=e.worksheetHash[`xl/${o.Target.replace(/^(\s|\/xl\/)+/,``)}`],r&&(r.name=a.name,r.id=a.id,r.state=a.state,n[i++]=r))});let a=[];e.definedNames&&e.definedNames.forEach(e=>{if(e.name===`_xlnm.Print_Area`){if(r=n[e.localSheetId],r&&e.ranges?.length>0){r.pageSetup||={};let t=S.decodeEx(e.ranges[0]);r.pageSetup.printArea=r.pageSetup.printArea?`${r.pageSetup.printArea}&&${t.dimensions}`:t.dimensions}}else if(e.name===`_xlnm.Print_Titles`){if(r=n[e.localSheetId],r&&e.ranges?.length>0){r.pageSetup||={};let t=e.ranges.join(`,`),n=/\$/g,i=t.match(/\$\d+:\$\d+/);if(i&&i.length){let e=i[0];r.pageSetup.printTitlesRow=e.replace(n,``)}let a=t.match(/\$[A-Z]+:\$[A-Z]+/);if(a&&a.length){let e=a[0];r.pageSetup.printTitlesColumn=e.replace(n,``)}}}else a.push(e)}),e.definedNames=a,e.media.forEach((e,t)=>{e.index=t})}static{this.WORKBOOK_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`,"mc:Ignorable":`x15`,"xmlns:x15":`http://schemas.microsoft.com/office/spreadsheetml/2010/11/main`}}static{this.STATIC_XFORMS={fileVersion:new Dr({tag:`fileVersion`,$:{appName:`xl`,lastEdited:5,lowestEdited:5,rupBuild:9303}})}}};let z={OfficeDocument:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument`,Worksheet:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet`,CalcChain:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain`,SharedStrings:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings`,Styles:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles`,Theme:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme`,Hyperlink:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink`,Image:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`,CoreProperties:`http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties`,ExtenderProperties:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties`,Comments:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments`,VmlDrawing:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing`,Table:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/table`,PivotCacheDefinition:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition`,PivotCacheRecords:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords`,PivotTable:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable`,FeaturePropertyBag:`http://schemas.microsoft.com/office/2022/11/relationships/FeaturePropertyBag`,CtrlProp:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp`};var Pa=class{constructor(){this.merges={}}add(e){if(this.merges[e.master])this.merges[e.master].expandToAddress(e.address);else{let t=`${e.master}:${e.address}`;this.merges[e.master]=new C(t)}}get mergeCells(){return Object.values(this.merges).map(e=>e.range)}reconcile(e,t){e.forEach(e=>{let n=S.decode(e);for(let e=n.top;e<=n.bottom;e++){let r=t[e-1];for(let t=n.left;t<=n.right;t++){let i=r.cells[t-1];i?i.type===w.ValueType.Merge&&(i.master=n.tl):r.cells[t]={type:w.ValueType.Null,address:S.encodeAddress(e,t)}}}})}getMasterAddress(e){let t=this.hash[e];return t&&t.tl}};function Fa(e){if(e==null)return w.ValueType.Null;if(e instanceof String||typeof e==`string`)return w.ValueType.String;if(typeof e==`number`)return w.ValueType.Number;if(typeof e==`boolean`)return w.ValueType.Boolean;if(e instanceof Date)return w.ValueType.Date;if(e.text&&e.hyperlink)return w.ValueType.Hyperlink;if(e.formula)return w.ValueType.Formula;if(e.error)return w.ValueType.Error;throw new g(typeof e,`Could not understand type of value`)}function Ia(e){switch(e.type){case w.ValueType.Formula:return Fa(e.result);default:return e.type}}var La=class extends j{constructor(){super(),this.richTextXform=new ti}get tag(){return`c`}prepare(e,t){let n=t.styles.addStyleModel(e.style||{},Ia(e));switch(n&&(e.styleId=n),e.comment&&t.comments.push({...e.comment,ref:e.address}),e.type){case w.ValueType.String:case w.ValueType.RichText:t.sharedStrings&&(e.ssId=t.sharedStrings.add(e.value));break;case w.ValueType.Date:t.date1904&&(e.date1904=!0);break;case w.ValueType.Hyperlink:t.sharedStrings&&e.text!==void 0&&e.text!==null&&(e.ssId=t.sharedStrings.add(e.text)),t.hyperlinks.push({address:e.address,target:e.hyperlink,tooltip:e.tooltip});break;case w.ValueType.Merge:t.merges.add(e);break;case w.ValueType.Formula:if(t.date1904&&(e.date1904=!0),e.shareType===`shared`&&(e.si=t.siFormulae++),e.formula)t.formulae[e.address]=e;else if(e.sharedFormula){let n=t.formulae[e.sharedFormula];if(!n)throw new l(`Shared Formula master must exist above and or left of clone for cell ${e.address}`);n.si===void 0?(n.shareType=`shared`,n.si=t.siFormulae++,n.range=new C(n.address,e.address)):n.range&&n.range.expandToAddress(e.address),e.si=n.si}break;default:break}}renderFormula(e,t){let n=null;switch(t.shareType){case`shared`:n={t:`shared`,ref:t.ref||t.range.range,si:t.si};break;case`array`:n={t:`array`,ref:t.ref};break;default:t.si!==void 0&&(n={t:`shared`,si:t.si});break}switch(Fa(t.result)){case w.ValueType.Null:e.leafNode(`f`,n,t.formula);break;case w.ValueType.String:e.addAttribute(`t`,`str`),e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result);break;case w.ValueType.Number:e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result);break;case w.ValueType.Boolean:e.addAttribute(`t`,`b`),e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result?1:0);break;case w.ValueType.Error:e.addAttribute(`t`,`e`),e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result.error);break;case w.ValueType.Date:e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,dt(t.result,t.date1904));break;default:throw new g(String(Fa(t.result)),`Could not understand type of value`)}}render(e,t){if(!(t.type===w.ValueType.Null&&!t.styleId)){switch(e.openNode(`c`),e.addAttribute(`r`,t.address),t.styleId&&e.addAttribute(`s`,t.styleId),t.type){case w.ValueType.Null:break;case w.ValueType.Number:e.leafNode(`v`,null,t.value);break;case w.ValueType.Boolean:e.addAttribute(`t`,`b`),e.leafNode(`v`,null,t.value?`1`:`0`);break;case w.ValueType.Checkbox:e.addAttribute(`t`,`b`),e.leafNode(`v`,null,t.value?`1`:`0`);break;case w.ValueType.Error:e.addAttribute(`t`,`e`),e.leafNode(`v`,null,t.value.error);break;case w.ValueType.String:case w.ValueType.RichText:t.ssId===void 0?t.value&&t.value.richText?(e.addAttribute(`t`,`inlineStr`),e.openNode(`is`),t.value.richText.forEach(t=>{this.richTextXform.render(e,t)}),e.closeNode(`is`)):(e.addAttribute(`t`,`str`),e.leafNode(`v`,null,t.value)):(e.addAttribute(`t`,`s`),e.leafNode(`v`,null,t.ssId));break;case w.ValueType.Date:e.leafNode(`v`,null,dt(t.value,t.date1904));break;case w.ValueType.Hyperlink:t.ssId===void 0?(e.addAttribute(`t`,`str`),e.leafNode(`v`,null,t.text)):(e.addAttribute(`t`,`s`),e.leafNode(`v`,null,t.ssId));break;case w.ValueType.Formula:this.renderFormula(e,t);break;case w.ValueType.Merge:break;default:break}e.closeNode()}}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`c`:return this.model={address:e.attributes.r},this.t=e.attributes.t,e.attributes.s&&(this.model.styleId=parseInt(e.attributes.s,10)),!0;case`f`:return this.currentNode=`f`,this.model.si=e.attributes.si,this.model.shareType=e.attributes.t,this.model.ref=e.attributes.ref,!0;case`v`:return this.currentNode=`v`,!0;case`t`:return this.currentNode=`t`,!0;case`r`:return this.parser=this.richTextXform,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){if(this.parser){this.parser.parseText(e);return}switch(this.currentNode){case`f`:this.model.formula=this.model.formula?this.model.formula+e:e;break;case`v`:case`t`:this.model.value&&this.model.value.richText?this.model.value.richText.text=this.model.value.richText.text?this.model.value.richText.text+e:e:this.model.value=this.model.value?this.model.value+e:e;break;default:break}}parseClose(e){switch(e){case`c`:{let{model:e}=this;if(e.formula||e.shareType)e.type=w.ValueType.Formula,e.value&&=(this.t===`str`?e.result=xt(e.value):this.t===`b`?e.result=parseInt(e.value,10)!==0:this.t===`e`?e.result={error:e.value}:e.result=parseFloat(e.value),void 0);else if(e.value!==void 0)switch(this.t){case`s`:e.type=w.ValueType.String,e.value=parseInt(e.value,10);break;case`str`:e.type=w.ValueType.String,e.value=xt(e.value);break;case`inlineStr`:e.type=w.ValueType.String,typeof e.value==`string`&&(e.value=ht(e.value));break;case`b`:e.type=w.ValueType.Boolean,e.value=parseInt(e.value,10)!==0;break;case`e`:e.type=w.ValueType.Error,e.value={error:e.value};break;case`d`:e.type=w.ValueType.Date,e.value=new Date(e.value);break;default:e.type=w.ValueType.Number,e.value=parseFloat(e.value);break}else e.styleId?e.type=w.ValueType.Null:e.type=w.ValueType.Merge;return!1}case`f`:case`v`:case`is`:return this.currentNode=void 0,!0;case`t`:return this.parser?(this.parser.parseClose(e),!0):(this.currentNode=void 0,!0);case`r`:return this.model.value=this.model.value||{},this.model.value.richText=this.model.value.richText??[],this.model.value.richText.push(this.parser.model),this.parser=void 0,this.currentNode=void 0,!0;default:return this.parser?(this.parser.parseClose(e),!0):!1}}reconcile(e,t){let n=e.styleId!==void 0&&t.styles&&t.styles.getStyleModel(e.styleId);switch(n&&(e.style=n),e.styleId!==void 0&&(e.styleId=void 0),e.type){case w.ValueType.String:typeof e.value==`number`&&t.sharedStrings&&(e.value=t.sharedStrings.getString(e.value)),e.value.richText&&(e.type=w.ValueType.RichText);break;case w.ValueType.Number:n&&Dt(n.numFmt)&&(e.type=w.ValueType.Date,e.value=ft(e.value,t.date1904));break;case w.ValueType.Formula:e.result!==void 0&&typeof e.result==`number`&&n&&Dt(n.numFmt)&&(e.result=ft(e.result,t.date1904)),e.shareType===`shared`&&(e.ref?t.formulae[e.si]=e.address:(e.sharedFormula=t.formulae[e.si],delete e.shareType),delete e.si);break;default:break}let r=t.hyperlinkMap[e.address];r&&(e.type===w.ValueType.Formula?(e.text=e.result,e.result=void 0):(e.text=e.value,e.value=void 0),e.type=w.ValueType.Hyperlink,e.hyperlink=r);let i=t.commentsMap&&t.commentsMap[e.address];i&&(e.comment=i)}},Ra=class extends j{constructor(e){super(),this.maxItems=e&&e.maxItems,this.map={c:new La}}get tag(){return`row`}reset(){super.reset(),this.numRowsSeen=0,this.lastCellCol=0}prepare(e,t){let n=t.styles.addStyleModel(e.style);n&&(e.styleId=n);let r=this.map.c;e.cells.forEach(e=>{r.prepare(e,t)})}render(e,t,n){if(!t)return;e.openNode(`row`),e.addAttribute(`r`,t.number),t.height!=null&&t.height>0?(e.addAttribute(`ht`,t.height),t.customHeight!==!1&&e.addAttribute(`customHeight`,`1`)):t.height===0&&e.addAttribute(`ht`,1),t.hidden&&e.addAttribute(`hidden`,`1`),t.min>0&&t.max>0&&t.min<=t.max&&e.addAttribute(`spans`,`${t.min}:${t.max}`),t.styleId&&(e.addAttribute(`s`,t.styleId),e.addAttribute(`customFormat`,`1`)),t.dyDescent!==void 0&&e.addAttribute(`x14ac:dyDescent`,t.dyDescent),t.outlineLevel&&e.addAttribute(`outlineLevel`,t.outlineLevel),t.collapsed&&e.addAttribute(`collapsed`,`1`);let r=this.map.c;t.cells.forEach(t=>{r.render(e,t,n)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;if(e.name===`row`){this.numRowsSeen+=1,this.lastCellCol=0;let t=e.attributes.spans?e.attributes.spans.split(`:`).map(e=>parseInt(e,10)):[void 0,void 0],n=this.model={number:e.attributes.r?parseInt(e.attributes.r,10):this.numRowsSeen,min:t[0],max:t[1],cells:[]};return e.attributes.s&&(n.styleId=parseInt(e.attributes.s,10)),D(e.attributes.hidden)&&(n.hidden=!0),D(e.attributes.bestFit)&&(n.bestFit=!0),e.attributes.ht&&(n.height=parseFloat(e.attributes.ht)),D(e.attributes.customHeight)&&(n.customHeight=!0),e.attributes.outlineLevel&&(n.outlineLevel=parseInt(e.attributes.outlineLevel,10)),D(e.attributes.collapsed)&&(n.collapsed=!0),e.attributes[`x14ac:dyDescent`]!==void 0&&(n.dyDescent=parseFloat(e.attributes[`x14ac:dyDescent`])),!0}return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)){let e=this.parser.model;if(e.address?this.lastCellCol=S.decodeAddress(e.address).col:(this.lastCellCol+=1,e.address=S.encodeAddress(this.model.number,this.lastCellCol)),this.model.cells.push(e),this.maxItems&&this.model.cells.length>this.maxItems)throw new re(`column`,this.maxItems);this.parser=void 0}return!0}return!1}reconcile(e,t){e.style=e.styleId===void 0?{}:t.styles.getStyleModel(e.styleId),e.styleId!==void 0&&(e.styleId=void 0);let n=this.map.c;e.cells.forEach(e=>{n.reconcile(e,t)})}},za=class extends j{get tag(){return`col`}prepare(e,t){let n=t.styles.addStyleModel(e.style||{});n&&(e.styleId=n)}render(e,t){e.openNode(`col`),e.addAttribute(`min`,t.min),e.addAttribute(`max`,t.max),t.width&&e.addAttribute(`width`,t.width),t.styleId&&e.addAttribute(`style`,t.styleId),t.hidden&&e.addAttribute(`hidden`,`1`),t.bestFit&&e.addAttribute(`bestFit`,`1`),t.outlineLevel&&e.addAttribute(`outlineLevel`,t.outlineLevel),t.collapsed&&e.addAttribute(`collapsed`,`1`),e.addAttribute(`customWidth`,`1`),e.closeNode()}parseOpen(e){if(e.name===`col`){let t=this.model={min:parseInt(e.attributes.min??`0`,10),max:parseInt(e.attributes.max??`0`,10),width:e.attributes.width===void 0?void 0:parseFloat(e.attributes.width??`0`)};return e.attributes.style&&(t.styleId=parseInt(e.attributes.style,10)),D(e.attributes.hidden)&&(t.hidden=!0),D(e.attributes.bestFit)&&(t.bestFit=!0),e.attributes.outlineLevel&&(t.outlineLevel=parseInt(e.attributes.outlineLevel,10)),D(e.attributes.collapsed)&&(t.collapsed=!0),!0}return!1}parseText(){}parseClose(){return!1}reconcile(e,t){e.styleId!==void 0&&(e.style=t.styles.getStyleModel(e.styleId))}},Ba=class extends j{get tag(){return`dimension`}render(e,t){t&&e.leafNode(`dimension`,{ref:t})}parseOpen(e){return e.name===`dimension`?(this.model=e.attributes.ref,!0):!1}parseText(){}parseClose(){return!1}},Va=class extends j{get tag(){return`hyperlink`}render(e,t){this.isInternalLink(t)?e.leafNode(`hyperlink`,{ref:t.address,"r:id":t.rId,tooltip:t.tooltip,location:t.target}):e.leafNode(`hyperlink`,{ref:t.address,"r:id":t.rId,tooltip:t.tooltip})}parseOpen(e){return e.name===`hyperlink`?(this.model={address:e.attributes.ref,rId:e.attributes[`r:id`],tooltip:e.attributes.tooltip},e.attributes.location&&(this.model.target=e.attributes.location),!0):!1}parseText(){}parseClose(){return!1}isInternalLink(e){return!!(e.target&&/^[^!]+![a-zA-Z]+[\d]+$/.test(e.target))}},Ha=class extends j{get tag(){return`mergeCell`}render(e,t){e.leafNode(`mergeCell`,{ref:t})}parseOpen(e){return e.name===`mergeCell`?(this.model=e.attributes.ref,!0):!1}parseText(){}parseClose(){return!1}};function Ua(e,t,n,r){let i=t[n];i===void 0?r!==void 0&&(e[n]=r):e[n]=i}function Wa(e,t,n,r){let i=t[n];i===void 0?r!==void 0&&(e[n]=r):e[n]=D(i)}function Ga(e){if(!e)return[];let t=[],n={};for(let[r,i]of Object.entries(e))if(i!=null)if(r.startsWith(`range:`)){let e=r.slice(6),{sqref:n,...a}=i;t.push({...a,sqref:e})}else n[r]=i;if(Object.keys(n).length===0)return t;let r=Object.entries(n).map(([e,t])=>({address:e,dataValidation:t,marked:!1})).sort((e,t)=>e.address.localeCompare(t.address)),i=Object.fromEntries(r.map(e=>[e.address,e])),a=(e,t,r)=>{for(let i=0;i<t;i++){let t=S.encodeAddress(e.row+i,r);if(!n[t]||!pe(n[e.address],n[t]))return!1}return!0},o=r.map(e=>{if(!e.marked){let t=S.decodeEx(e.address);if(t.dimensions)return i[t.dimensions].marked=!0,{...e.dataValidation,sqref:e.address};let r=1,o=S.encodeAddress(t.row+r,t.col);for(;n[o]&&pe(e.dataValidation,n[o]);)r++,o=S.encodeAddress(t.row+r,t.col);let s=1;for(;a(t,r,t.col+s);)s++;for(let e=0;e<r;e++)for(let n=0;n<s;n++)o=S.encodeAddress(t.row+e,t.col+n),i[o].marked=!0;if(r>1||s>1){let n=t.row+(r-1),i=t.col+(s-1);return{...e.dataValidation,sqref:`${e.address}:${S.encodeAddress(n,i)}`}}return{...e.dataValidation,sqref:e.address}}return null}).filter(Boolean);return[...t,...o]}var Ka=class extends j{get tag(){return`dataValidations`}render(e,t){let n=Ga(t);n.length&&(e.openNode(`dataValidations`,{count:n.length}),n.forEach(t=>{e.openNode(`dataValidation`),t.type!==`any`&&(e.addAttribute(`type`,t.type),t.operator&&t.type!==`list`&&t.operator!==`between`&&e.addAttribute(`operator`,t.operator),t.allowBlank&&e.addAttribute(`allowBlank`,`1`)),t.showInputMessage&&e.addAttribute(`showInputMessage`,`1`),t.promptTitle&&e.addAttribute(`promptTitle`,t.promptTitle),t.prompt&&e.addAttribute(`prompt`,t.prompt),t.showErrorMessage&&e.addAttribute(`showErrorMessage`,`1`),t.errorStyle&&e.addAttribute(`errorStyle`,t.errorStyle),t.errorTitle&&e.addAttribute(`errorTitle`,t.errorTitle),t.error&&e.addAttribute(`error`,t.error),e.addAttribute(`sqref`,t.sqref),(t.formulae??[]).forEach((n,r)=>{e.openNode(`formula${r+1}`),t.type===`date`?e.writeText(dt(new Date(n))):e.writeText(n),e.closeNode()}),e.closeNode()}),e.closeNode())}parseOpen(e){switch(e.name){case`dataValidations`:return this.model={},!0;case`dataValidation`:{this._address=e.attributes.sqref;let t={type:e.attributes.type??`any`,formulae:[]};switch(e.attributes.type&&Wa(t,e.attributes,`allowBlank`),Wa(t,e.attributes,`showInputMessage`),Wa(t,e.attributes,`showErrorMessage`),t.type){case`any`:case`list`:case`custom`:break;default:Ua(t,e.attributes,`operator`,`between`);break}return Ua(t,e.attributes,`promptTitle`),Ua(t,e.attributes,`prompt`),Ua(t,e.attributes,`errorStyle`),Ua(t,e.attributes,`errorTitle`),Ua(t,e.attributes,`error`),this._dataValidation=t,!0}case`formula1`:case`formula2`:return this._formula=[],!0;default:return!1}}parseText(e){this._formula&&this._formula.push(e)}parseClose(e){switch(e){case`dataValidations`:return!1;case`dataValidation`:return(!this._dataValidation.formulae||!this._dataValidation.formulae.length)&&(delete this._dataValidation.formulae,delete this._dataValidation.operator),this._address.split(/\s+/g).forEach(e=>{e.includes(`:`)?this.model[`range:${e}`]=this._dataValidation:this.model[e]=this._dataValidation}),!0;case`formula1`:case`formula2`:{let e=this._formula.join(``);switch(this._dataValidation.type){case`whole`:case`textLength`:e=parseInt(e,10);break;case`decimal`:e=parseFloat(e);break;case`date`:e=ft(parseFloat(e));break;default:break}return this._dataValidation.formulae.push(e),this._formula=void 0,!0}default:return!0}}},qa=class extends j{get tag(){return`pageSetUpPr`}render(e,t){return t&&t.fitToPage?(e.leafNode(this.tag,{fitToPage:t.fitToPage?`1`:void 0}),!0):!1}parseOpen(e){return e.name===this.tag?(this.model={fitToPage:e.attributes.fitToPage===`1`},!0):!1}parseText(){}parseClose(){return!1}};let Ja=e=>e!==void 0;var Ya=class extends j{get tag(){return`outlinePr`}render(e,t){return t&&(Ja(t.summaryBelow)||Ja(t.summaryRight))?(e.leafNode(this.tag,{summaryBelow:Ja(t.summaryBelow)?Number(t.summaryBelow):void 0,summaryRight:Ja(t.summaryRight)?Number(t.summaryRight):void 0}),!0):!1}parseOpen(e){return e.name===this.tag?(this.model={summaryBelow:Ja(e.attributes.summaryBelow)?!!Number(e.attributes.summaryBelow):void 0,summaryRight:Ja(e.attributes.summaryRight)?!!Number(e.attributes.summaryRight):void 0},!0):!1}parseText(){}parseClose(){return!1}},Xa=class extends j{constructor(){super(),this.map={tabColor:new N(`tabColor`),pageSetUpPr:new qa,outlinePr:new Ya}}get tag(){return`sheetPr`}render(e,t){if(t){e.addRollback(),e.openNode(`sheetPr`);let n=!1;n=this.map.tabColor.render(e,t.tabColor)||n,n=this.map.pageSetUpPr.render(e,t.pageSetup)||n,n=this.map.outlinePr.render(e,t.outlineProperties)||n,n?(e.closeNode(),e.commit()):e.rollback()}}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.reset(),!0):this.map[e.name]?(this.parser=this.map[e.name],this.parser.parseOpen(e),!0):!1}parseText(e){return this.parser?(this.parser.parseText(e),!0):!1}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser=void 0),!0):(this.map.tabColor.model||this.map.pageSetUpPr.model||this.map.outlinePr.model?(this.model={},this.map.tabColor.model&&(this.model.tabColor=this.map.tabColor.model),this.map.pageSetUpPr.model&&(this.model.pageSetup=this.map.pageSetUpPr.model),this.map.outlinePr.model&&(this.model.outlineProperties=this.map.outlinePr.model)):this.model=null,!1)}},Za=class extends j{get tag(){return`sheetFormatPr`}render(e,t){if(t){let n={defaultRowHeight:t.defaultRowHeight,outlineLevelRow:t.outlineLevelRow||void 0,outlineLevelCol:t.outlineLevelCol||void 0,"x14ac:dyDescent":t.dyDescent!==void 0&&t.dyDescent!==0?t.dyDescent:void 0};t.defaultColWidth&&(n.defaultColWidth=t.defaultColWidth),t.customHeight&&(n.customHeight=`1`),Object.values(n).some(e=>e!==void 0)&&e.leafNode(`sheetFormatPr`,n)}}parseOpen(e){return e.name===`sheetFormatPr`?(this.model={defaultRowHeight:parseFloat(e.attributes.defaultRowHeight??`0`),dyDescent:e.attributes[`x14ac:dyDescent`]===void 0?void 0:parseFloat(e.attributes[`x14ac:dyDescent`]),outlineLevelRow:parseInt(e.attributes.outlineLevelRow??`0`,10),outlineLevelCol:parseInt(e.attributes.outlineLevelCol??`0`,10)},e.attributes.defaultColWidth&&(this.model.defaultColWidth=parseFloat(e.attributes.defaultColWidth)),e.attributes.customHeight===`1`&&(this.model.customHeight=!0),!0):!1}parseText(){}parseClose(){return!1}};let Qa={frozen:`frozen`,frozenSplit:`frozen`,split:`split`};var $a=class extends j{get tag(){return`sheetView`}prepare(e){switch(e.state){case`frozen`:case`split`:break;default:e.state=`normal`;break}}render(e,t){let n={};t.tabSelected&&(n.tabSelected=`1`),n.workbookViewId=t.workbookViewId??0,e.openNode(`sheetView`,n);let r=function(t,n,r){r&&e.addAttribute(t,n)};r(`rightToLeft`,`1`,t.rightToLeft===!0),r(`showRuler`,`0`,t.showRuler===!1),r(`showRowColHeaders`,`0`,t.showRowColHeaders===!1),r(`showGridLines`,`0`,t.showGridLines===!1),r(`zoomScale`,t.zoomScale,t.zoomScale!==void 0&&t.zoomScale!==100),r(`zoomScaleNormal`,t.zoomScaleNormal,t.zoomScaleNormal!==void 0&&t.zoomScaleNormal!==100),r(`view`,t.style,t.style);let i,a,o,s;switch(t.state){case`frozen`:a=t.xSplit??0,o=t.ySplit??0,i=t.topLeftCell||S.getAddress(o+1,a+1).address,s=t.xSplit&&t.ySplit&&`bottomRight`||t.xSplit&&`topRight`||`bottomLeft`,e.leafNode(`pane`,{xSplit:t.xSplit||void 0,ySplit:t.ySplit||void 0,topLeftCell:i,activePane:s,state:`frozen`}),e.leafNode(`selection`,{pane:s,activeCell:t.activeCell,sqref:t.activeCell});break;case`split`:t.activePane===`topLeft`&&(t.activePane=void 0),e.leafNode(`pane`,{xSplit:t.xSplit||void 0,ySplit:t.ySplit||void 0,topLeftCell:t.topLeftCell,activePane:t.activePane}),e.leafNode(`selection`,{pane:t.activePane,activeCell:t.activeCell,sqref:t.activeCell});break;case`normal`:t.activeCell&&e.leafNode(`selection`,{activeCell:t.activeCell,sqref:t.activeCell});break;default:break}e.closeNode()}parseOpen(e){switch(e.name){case`sheetView`:return this.sheetView={workbookViewId:parseInt(e.attributes.workbookViewId,10),rightToLeft:e.attributes.rightToLeft===`1`,tabSelected:e.attributes.tabSelected===`1`,showRuler:e.attributes.showRuler!==`0`,showRowColHeaders:e.attributes.showRowColHeaders!==`0`,showGridLines:e.attributes.showGridLines!==`0`,zoomScale:parseInt(e.attributes.zoomScale??`100`,10),zoomScaleNormal:parseInt(e.attributes.zoomScaleNormal??`100`,10),style:e.attributes.view},this.pane=void 0,this.selections={},!0;case`pane`:return this.pane={xSplit:parseInt(e.attributes.xSplit??`0`,10),ySplit:parseInt(e.attributes.ySplit??`0`,10),topLeftCell:e.attributes.topLeftCell,activePane:e.attributes.activePane??`topLeft`,state:e.attributes.state},!0;case`selection`:{let t=e.attributes.pane??`topLeft`;return this.selections[t]={pane:t,activeCell:e.attributes.activeCell},!0}default:return!1}}parseText(){}parseClose(e){let t,n;switch(e){case`sheetView`:return this.sheetView&&this.pane?(t=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,tabSelected:this.sheetView.tabSelected,state:Qa[this.pane.state]??`split`,xSplit:this.pane.xSplit,ySplit:this.pane.ySplit,topLeftCell:this.pane.topLeftCell,showRuler:this.sheetView.showRuler,showRowColHeaders:this.sheetView.showRowColHeaders,showGridLines:this.sheetView.showGridLines,zoomScale:this.sheetView.zoomScale,zoomScaleNormal:this.sheetView.zoomScaleNormal},this.model.state===`split`&&(t.activePane=this.pane.activePane),n=this.selections[this.pane.activePane],n&&n.activeCell&&(t.activeCell=n.activeCell),this.sheetView.style&&(t.style=this.sheetView.style)):(t=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,tabSelected:this.sheetView.tabSelected,state:`normal`,showRuler:this.sheetView.showRuler,showRowColHeaders:this.sheetView.showRowColHeaders,showGridLines:this.sheetView.showGridLines,zoomScale:this.sheetView.zoomScale,zoomScaleNormal:this.sheetView.zoomScaleNormal},n=this.selections.topLeft,n&&n.activeCell&&(t.activeCell=n.activeCell),this.sheetView.style&&(t.style=this.sheetView.style)),!1;default:return!0}}reconcile(){}};function B(e,t){return e?t:void 0}function V(e,t){return e===t?!0:void 0}var eo=class extends j{get tag(){return`sheetProtection`}render(e,t){if(t){let n={sheet:B(t.sheet,`1`),selectLockedCells:t.selectLockedCells===!1?`1`:void 0,selectUnlockedCells:t.selectUnlockedCells===!1?`1`:void 0,formatCells:B(t.formatCells,`0`),formatColumns:B(t.formatColumns,`0`),formatRows:B(t.formatRows,`0`),insertColumns:B(t.insertColumns,`0`),insertRows:B(t.insertRows,`0`),insertHyperlinks:B(t.insertHyperlinks,`0`),deleteColumns:B(t.deleteColumns,`0`),deleteRows:B(t.deleteRows,`0`),sort:B(t.sort,`0`),autoFilter:B(t.autoFilter,`0`),pivotTables:B(t.pivotTables,`0`)};t.sheet&&(n.algorithmName=t.algorithmName,n.hashValue=t.hashValue,n.saltValue=t.saltValue,n.spinCount=t.spinCount,n.objects=B(t.objects===!1,`1`),n.scenarios=B(t.scenarios===!1,`1`)),Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={sheet:V(e.attributes.sheet,`1`),objects:e.attributes.objects===`1`?!1:void 0,scenarios:e.attributes.scenarios===`1`?!1:void 0,selectLockedCells:e.attributes.selectLockedCells===`1`?!1:void 0,selectUnlockedCells:e.attributes.selectUnlockedCells===`1`?!1:void 0,formatCells:V(e.attributes.formatCells,`0`),formatColumns:V(e.attributes.formatColumns,`0`),formatRows:V(e.attributes.formatRows,`0`),insertColumns:V(e.attributes.insertColumns,`0`),insertRows:V(e.attributes.insertRows,`0`),insertHyperlinks:V(e.attributes.insertHyperlinks,`0`),deleteColumns:V(e.attributes.deleteColumns,`0`),deleteRows:V(e.attributes.deleteRows,`0`),sort:V(e.attributes.sort,`0`),autoFilter:V(e.attributes.autoFilter,`0`),pivotTables:V(e.attributes.pivotTables,`0`)},e.attributes.algorithmName&&(this.model.algorithmName=e.attributes.algorithmName,this.model.hashValue=e.attributes.hashValue,this.model.saltValue=e.attributes.saltValue,this.model.spinCount=parseInt(e.attributes.spinCount,10)),!0;default:return!1}}parseText(){}parseClose(){return!1}},to=class extends j{get tag(){return`pageMargins`}render(e,t){if(t){let n={left:t.left,right:t.right,top:t.top,bottom:t.bottom,header:t.header,footer:t.footer};Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={left:parseFloat(e.attributes.left||.7),right:parseFloat(e.attributes.right||.7),top:parseFloat(e.attributes.top||.75),bottom:parseFloat(e.attributes.bottom||.75),header:parseFloat(e.attributes.header||.3),footer:parseFloat(e.attributes.footer||.3)},!0;default:return!1}}parseText(){}parseClose(){return!1}};function no(e){return e?`1`:void 0}function ro(e){switch(e){case`overThenDown`:return e;default:return}}function io(e){switch(e){case`atEnd`:case`asDisplyed`:return e;default:return}}function ao(e){switch(e){case`dash`:case`blank`:case`NA`:return e;default:return}}function oo(e){return e===void 0?void 0:parseInt(e,10)}var so=class extends j{get tag(){return`pageSetup`}_dpiToXml(e){if(e!==void 0&&Number.isFinite(e)&&e!==4294967295)return e}render(e,t){if(t){let n={paperSize:t.paperSize,orientation:t.orientation,horizontalDpi:this._dpiToXml(t.horizontalDpi),verticalDpi:this._dpiToXml(t.verticalDpi),pageOrder:ro(t.pageOrder),blackAndWhite:no(t.blackAndWhite),draft:no(t.draft),cellComments:io(t.cellComments),errors:ao(t.errors),scale:t.scale===100?void 0:t.scale,fitToWidth:t.fitToWidth===1?void 0:t.fitToWidth,fitToHeight:t.fitToHeight===1?void 0:t.fitToHeight,firstPageNumber:t.firstPageNumber,useFirstPageNumber:no(!!t.firstPageNumber),usePrinterDefaults:no(t.usePrinterDefaults),copies:t.copies};Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={paperSize:oo(e.attributes.paperSize),orientation:e.attributes.orientation??`portrait`,horizontalDpi:parseInt(e.attributes.horizontalDpi??`4294967295`,10),verticalDpi:parseInt(e.attributes.verticalDpi??`4294967295`,10),pageOrder:e.attributes.pageOrder??`downThenOver`,blackAndWhite:e.attributes.blackAndWhite===`1`,draft:e.attributes.draft===`1`,cellComments:e.attributes.cellComments??`None`,errors:e.attributes.errors??`displayed`,scale:parseInt(e.attributes.scale??`100`,10),fitToWidth:parseInt(e.attributes.fitToWidth??`1`,10),fitToHeight:parseInt(e.attributes.fitToHeight??`1`,10),firstPageNumber:parseInt(e.attributes.firstPageNumber??`1`,10),useFirstPageNumber:e.attributes.useFirstPageNumber===`1`,usePrinterDefaults:e.attributes.usePrinterDefaults===`1`,copies:parseInt(e.attributes.copies??`1`,10)},!0;default:return!1}}parseText(){}parseClose(){return!1}};function co(e){return e?`1`:void 0}var lo=class extends j{get tag(){return`printOptions`}render(e,t){if(t){let n={headings:co(t.showRowColHeaders),gridLines:co(t.showGridLines),horizontalCentered:co(t.horizontalCentered),verticalCentered:co(t.verticalCentered)};Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={showRowColHeaders:e.attributes.headings===`1`,showGridLines:e.attributes.gridLines===`1`,horizontalCentered:e.attributes.horizontalCentered===`1`,verticalCentered:e.attributes.verticalCentered===`1`},!0;default:return!1}}parseText(){}parseClose(){return!1}},uo=class extends j{get tag(){return`autoFilter`}render(e,t){if(t)if(typeof t==`string`)e.leafNode(`autoFilter`,{ref:t});else{let n=function(e){return typeof e==`string`?e:S.getAddress(e.row,e.col).address},r=n(t.from),i=n(t.to);r&&i&&e.leafNode(`autoFilter`,{ref:`${r}:${i}`})}}parseOpen(e){e.name===`autoFilter`&&(this.model=e.attributes.ref)}},fo=class extends j{get tag(){return`picture`}render(e,t){t&&e.leafNode(this.tag,{"r:id":t.rId})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:id`]},!0;default:return!1}}parseText(){}parseClose(){return!1}},po=class extends j{get tag(){return`drawing`}render(e,t){t&&e.leafNode(this.tag,{"r:id":t.rId})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:id`]},!0;default:return!1}}parseText(){}parseClose(){return!1}},mo=class extends j{get tag(){return`tablePart`}render(e,t){t&&e.leafNode(this.tag,{"r:id":t.rId})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:id`]},!0;default:return!1}}parseText(){}parseClose(){return!1}},ho=class extends j{get tag(){return`brk`}render(e,t){e.leafNode(`brk`,t)}parseOpen(e){if(e.name===`brk`){let{id:t,max:n,man:r,min:i}=e.attributes;return this.model={id:+t,max:+n,man:+r},i!==void 0&&(this.model.min=+i),!0}return!1}parseText(){}parseClose(){return!1}},go=class extends M{constructor(){super({tag:`rowBreaks`,count:!0,childXform:new ho})}render(e,t){if(t&&t.length){e.openNode(this.tag,this.$),e.addAttribute(this.$count,t.length),e.addAttribute(`manualBreakCount`,t.length);let{childXform:n}=this;for(let r of t)n.render(e,r);e.closeNode()}}},_o=class extends M{constructor(){super({tag:`colBreaks`,count:!0,childXform:new ho})}render(e,t){if(t&&t.length){e.openNode(this.tag,this.$),e.addAttribute(this.$count,t.length),e.addAttribute(`manualBreakCount`,t.length);let{childXform:n}=this;for(let r of t)n.render(e,r);e.closeNode()}}},vo=class extends j{get tag(){return`headerFooter`}render(e,t){if(t){e.addRollback();let n=!1;e.openNode(`headerFooter`),t.differentFirst&&(e.addAttribute(`differentFirst`,`1`),n=!0),t.differentOddEven&&(e.addAttribute(`differentOddEven`,`1`),n=!0),t.oddHeader&&typeof t.oddHeader==`string`&&(e.leafNode(`oddHeader`,null,t.oddHeader),n=!0),t.oddFooter&&typeof t.oddFooter==`string`&&(e.leafNode(`oddFooter`,null,t.oddFooter),n=!0),t.evenHeader&&typeof t.evenHeader==`string`&&(e.leafNode(`evenHeader`,null,t.evenHeader),n=!0),t.evenFooter&&typeof t.evenFooter==`string`&&(e.leafNode(`evenFooter`,null,t.evenFooter),n=!0),t.firstHeader&&typeof t.firstHeader==`string`&&(e.leafNode(`firstHeader`,null,t.firstHeader),n=!0),t.firstFooter&&typeof t.firstFooter==`string`&&(e.leafNode(`firstFooter`,null,t.firstFooter),n=!0),n?(e.closeNode(),e.commit()):e.rollback()}}parseOpen(e){switch(e.name){case`headerFooter`:return this.model={},e.attributes.differentFirst&&(this.model.differentFirst=parseInt(e.attributes.differentFirst,0)===1),e.attributes.differentOddEven&&(this.model.differentOddEven=parseInt(e.attributes.differentOddEven,0)===1),!0;case`oddHeader`:return this.currentNode=`oddHeader`,!0;case`oddFooter`:return this.currentNode=`oddFooter`,!0;case`evenHeader`:return this.currentNode=`evenHeader`,!0;case`evenFooter`:return this.currentNode=`evenFooter`,!0;case`firstHeader`:return this.currentNode=`firstHeader`,!0;case`firstFooter`:return this.currentNode=`firstFooter`,!0;default:return!1}}parseText(e){switch(this.currentNode){case`oddHeader`:this.model.oddHeader=(this.model.oddHeader??``)+e;break;case`oddFooter`:this.model.oddFooter=(this.model.oddFooter??``)+e;break;case`evenHeader`:this.model.evenHeader=(this.model.evenHeader??``)+e;break;case`evenFooter`:this.model.evenFooter=(this.model.evenFooter??``)+e;break;case`firstHeader`:this.model.firstHeader=(this.model.firstHeader??``)+e;break;case`firstFooter`:this.model.firstFooter=(this.model.firstFooter??``)+e;break;default:break}}parseClose(){switch(this.currentNode){case`oddHeader`:case`oddFooter`:case`evenHeader`:case`evenFooter`:case`firstHeader`:case`firstFooter`:return this.currentNode=void 0,!0;default:return!1}}},H=class extends j{createNewModel(e){return{}}parseOpen(e){return this.parser=this.parser||this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.model=this.createNewModel(e),!0):!1}parseText(e){this.parser&&this.parser.parseText(e)}onParserClose(e,t){this.model[e]=t.model}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.onParserClose(e,this.parser),this.parser=void 0),!0):e!==this.tag}get tag(){return``}},yo=class extends j{get tag(){return`cfvo`}render(e,t){e.leafNode(this.tag,{type:t.type,val:t.value})}parseOpen(e){this.model={type:e.attributes.type,value:j.toFloatValue(e.attributes.val)}}parseClose(e){return e!==this.tag}},bo=class extends H{constructor(){super(),this.map={cfvo:this.cfvoXform=new yo,color:this.colorXform=new N}}get tag(){return`dataBar`}render(e,t){e.openNode(this.tag),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),this.colorXform.render(e,t.color),e.closeNode()}createNewModel(){return{cfvo:[]}}onParserClose(e,t){switch(e){case`cfvo`:this.model.cfvo.push(t.model);break;case`color`:this.model.color=t.model;break}}},xo=class extends j{get tag(){return`x14:id`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},So=class extends H{constructor(){super(),this.map={"x14:id":this.idXform=new xo}}get tag(){return`ext`}render(e,t){e.openNode(this.tag,{uri:`{B025F937-C7B1-47D3-B67F-A62EFF666E3E}`,"xmlns:x14":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`}),this.idXform.render(e,t.x14Id),e.closeNode()}createNewModel(){return{}}onParserClose(e,t){this.model.x14Id=t.model}},Co=class extends H{constructor(){super(),this.map={ext:new So}}get tag(){return`extLst`}render(e,t){e.openNode(this.tag),this.map.ext.render(e,t),e.closeNode()}createNewModel(){return{}}onParserClose(e,t){Object.assign(this.model,t.model)}},wo=class extends j{get tag(){return`formula`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},To=class extends H{constructor(){super(),this.map={cfvo:this.cfvoXform=new yo,color:this.colorXform=new N}}get tag(){return`colorScale`}render(e,t){e.openNode(this.tag),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),t.color.forEach(t=>{this.colorXform.render(e,t)}),e.closeNode()}createNewModel(e){return{cfvo:[],color:[]}}onParserClose(e,t){this.model[e].push(t.model)}},Eo=class extends H{constructor(){super(),this.map={cfvo:this.cfvoXform=new yo}}get tag(){return`iconSet`}render(e,t){e.openNode(this.tag,{iconSet:j.toStringAttribute(t.iconSet,`3TrafficLights`),reverse:j.toBoolAttribute(t.reverse,!1),showValue:j.toBoolAttribute(t.showValue,!0)}),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),e.closeNode()}createNewModel({attributes:e}){return{iconSet:j.toStringValue(e.iconSet,`3TrafficLights`),reverse:j.toBoolValue(e.reverse),showValue:j.toBoolValue(e.showValue),cfvo:[]}}onParserClose(e,t){this.model[e].push(t.model)}};let Do={"3Triangles":!0,"3Stars":!0,"5Boxes":!0},Oo=e=>{if(e.formulae&&e.formulae[0])return e.formulae[0];let{tl:t}=new C(e.ref);switch(e.operator){case`containsText`:return`NOT(ISERROR(SEARCH("${e.text}",${t})))`;case`containsBlanks`:return`LEN(TRIM(${t}))=0`;case`notContainsBlanks`:return`LEN(TRIM(${t}))>0`;case`containsErrors`:return`ISERROR(${t})`;case`notContainsErrors`:return`NOT(ISERROR(${t}))`;default:return}},ko=e=>{if(e.formulae&&e.formulae[0])return e.formulae[0];let{tl:t}=new C(e.ref);switch(e.timePeriod){case`thisWeek`:return`AND(TODAY()-ROUNDDOWN(${t},0)<=WEEKDAY(TODAY())-1,ROUNDDOWN(${t},0)-TODAY()<=7-WEEKDAY(TODAY()))`;case`lastWeek`:return`AND(TODAY()-ROUNDDOWN(${t},0)>=(WEEKDAY(TODAY())),TODAY()-ROUNDDOWN(${t},0)<(WEEKDAY(TODAY())+7))`;case`nextWeek`:return`AND(ROUNDDOWN(${t},0)-TODAY()>(7-WEEKDAY(TODAY())),ROUNDDOWN(${t},0)-TODAY()<(15-WEEKDAY(TODAY())))`;case`yesterday`:return`FLOOR(${t},1)=TODAY()-1`;case`today`:return`FLOOR(${t},1)=TODAY()`;case`tomorrow`:return`FLOOR(${t},1)=TODAY()+1`;case`last7Days`:return`AND(TODAY()-FLOOR(${t},1)<=6,FLOOR(${t},1)<=TODAY())`;case`lastMonth`:return`AND(MONTH(${t})=MONTH(EDATE(TODAY(),0-1)),YEAR(${t})=YEAR(EDATE(TODAY(),0-1)))`;case`thisMonth`:return`AND(MONTH(${t})=MONTH(TODAY()),YEAR(${t})=YEAR(TODAY()))`;case`nextMonth`:return`AND(MONTH(${t})=MONTH(EDATE(TODAY(),0+1)),YEAR(${t})=YEAR(EDATE(TODAY(),0+1)))`;default:return}},Ao=e=>{let{type:t,operator:n}=e;switch(t){case`containsText`:case`containsBlanks`:case`notContainsBlanks`:case`containsErrors`:case`notContainsErrors`:return{type:`containsText`,operator:t};default:return{type:t,operator:n}}};var jo=class e extends H{constructor(){super(),this.map={dataBar:this.databarXform=new bo,extLst:this.extLstRefXform=new Co,formula:this.formulaXform=new wo,colorScale:this.colorScaleXform=new To,iconSet:this.iconSetXform=new Eo}}get tag(){return`cfRule`}static isPrimitive(e){return!(e.type===`iconSet`&&(e.custom||Do[e.iconSet]))}render(e,t){switch(t.type){case`expression`:this.renderExpression(e,t);break;case`cellIs`:this.renderCellIs(e,t);break;case`top10`:this.renderTop10(e,t);break;case`aboveAverage`:this.renderAboveAverage(e,t);break;case`dataBar`:this.renderDataBar(e,t);break;case`colorScale`:this.renderColorScale(e,t);break;case`iconSet`:this.renderIconSet(e,t);break;case`containsText`:this.renderText(e,t);break;case`timePeriod`:this.renderTimePeriod(e,t);break}}renderExpression(e,t){e.openNode(this.tag,{type:`expression`,dxfId:t.dxfId,priority:t.priority}),this.formulaXform.render(e,t.formulae[0]),e.closeNode()}renderCellIs(e,t){e.openNode(this.tag,{type:`cellIs`,dxfId:t.dxfId,priority:t.priority,operator:t.operator}),t.formulae.forEach(t=>{this.formulaXform.render(e,t)}),e.closeNode()}renderTop10(e,t){e.leafNode(this.tag,{type:`top10`,dxfId:t.dxfId,priority:t.priority,percent:j.toBoolAttribute(t.percent,!1),bottom:j.toBoolAttribute(t.bottom,!1),rank:j.toIntValue(t.rank,10)})}renderAboveAverage(e,t){e.leafNode(this.tag,{type:`aboveAverage`,dxfId:t.dxfId,priority:t.priority,aboveAverage:j.toBoolAttribute(t.aboveAverage,!0)})}renderDataBar(e,t){e.openNode(this.tag,{type:`dataBar`,priority:t.priority}),this.databarXform.render(e,t),this.extLstRefXform.render(e,t),e.closeNode()}renderColorScale(e,t){e.openNode(this.tag,{type:`colorScale`,priority:t.priority}),this.colorScaleXform.render(e,t),e.closeNode()}renderIconSet(t,n){e.isPrimitive(n)&&(t.openNode(this.tag,{type:`iconSet`,priority:n.priority}),this.iconSetXform.render(t,n),t.closeNode())}renderText(e,t){e.openNode(this.tag,{type:t.operator,dxfId:t.dxfId,priority:t.priority,operator:j.toStringAttribute(t.operator,`containsText`)});let n=Oo(t);n&&this.formulaXform.render(e,n),e.closeNode()}renderTimePeriod(e,t){e.openNode(this.tag,{type:`timePeriod`,dxfId:t.dxfId,priority:t.priority,timePeriod:t.timePeriod});let n=ko(t);n&&this.formulaXform.render(e,n),e.closeNode()}createNewModel({attributes:e}){return{...Ao(e),dxfId:j.toIntValue(e.dxfId),priority:j.toIntValue(e.priority),timePeriod:e.timePeriod,percent:j.toBoolValue(e.percent),bottom:j.toBoolValue(e.bottom),rank:j.toIntValue(e.rank),aboveAverage:j.toBoolValue(e.aboveAverage)}}onParserClose(e,t){switch(e){case`dataBar`:case`extLst`:case`colorScale`:case`iconSet`:Object.assign(this.model,t.model);break;case`formula`:this.model.formulae=this.model.formulae??[],this.model.formulae.push(t.model);break}}},Mo=class extends H{constructor(){super(),this.map={cfRule:new jo}}get tag(){return`conditionalFormatting`}render(e,t){t.rules.some(jo.isPrimitive)&&(e.openNode(this.tag,{sqref:t.ref}),t.rules.forEach(n=>{jo.isPrimitive(n)&&(n.ref=t.ref,this.map.cfRule.render(e,n))}),e.closeNode())}createNewModel({attributes:e}){return{ref:e.sqref,rules:[]}}onParserClose(e,t){this.model.rules.push(t.model)}},No=class extends j{constructor(){super(),this.cfXform=new Mo}get tag(){return`conditionalFormatting`}reset(){this.model=[]}prepare(e,t){let n=e.reduce((e,t)=>Math.max(e,...t.rules.map(e=>e.priority??0)),1);e.forEach(e=>{e.rules.forEach(e=>{e.priority||=n++,e.style&&(e.dxfId=t.styles.addDxfStyle(e.style)),e.type===`dataBar`&&((!e.cfvo||e.cfvo.length<2)&&(e.cfvo=[{type:`min`},{type:`max`}]),e.color||={argb:`FF638EC6`})})})}render(e,t){t.forEach(t=>{this.cfXform.render(e,t)})}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`conditionalFormatting`:return this.parser=this.cfXform,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?this.parser.parseClose(e)?!0:(this.model.push(this.parser.model),this.parser=void 0,!1):!1}reconcile(e,t){e.forEach(e=>{e.rules.forEach(e=>{e.dxfId!==void 0&&(e.style=t.styles.getDxfStyle(e.dxfId),delete e.dxfId)})})}},Po=class extends j{get tag(){return`xm:f`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},Fo=class extends H{constructor(){super(),this.map={"xm:f":this.fExtXform=new Po}}get tag(){return`x14:cfvo`}render(e,t){e.openNode(this.tag,{type:t.type}),t.value!==void 0&&this.fExtXform.render(e,t.value),e.closeNode()}createNewModel(e){return{type:e.attributes.type}}onParserClose(e,t){switch(e){case`xm:f`:this.model.value=t.model?parseFloat(t.model):0;break}}},Io=class extends H{constructor(){super(),this.map={"x14:cfvo":this.cfvoXform=new Fo,"x14:borderColor":this.borderColorXform=new N(`x14:borderColor`),"x14:negativeBorderColor":this.negativeBorderColorXform=new N(`x14:negativeBorderColor`),"x14:negativeFillColor":this.negativeFillColorXform=new N(`x14:negativeFillColor`),"x14:axisColor":this.axisColorXform=new N(`x14:axisColor`)}}static isExt(e){return!e.gradient}get tag(){return`x14:dataBar`}render(e,t){e.openNode(this.tag,{minLength:j.toIntAttribute(t.minLength,0,!0),maxLength:j.toIntAttribute(t.maxLength,100,!0),border:j.toBoolAttribute(t.border,!1),gradient:j.toBoolAttribute(t.gradient,!0),negativeBarColorSameAsPositive:j.toBoolAttribute(t.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:j.toBoolAttribute(t.negativeBarBorderColorSameAsPositive,!0),axisPosition:j.toAttribute(t.axisPosition,`auto`),direction:j.toAttribute(t.direction,`leftToRight`)}),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),this.borderColorXform.render(e,t.borderColor),this.negativeBorderColorXform.render(e,t.negativeBorderColor),this.negativeFillColorXform.render(e,t.negativeFillColor),this.axisColorXform.render(e,t.axisColor),e.closeNode()}createNewModel({attributes:e}){return{cfvo:[],minLength:j.toIntValue(e.minLength,0),maxLength:j.toIntValue(e.maxLength,100),border:j.toBoolValue(e.border,!1),gradient:j.toBoolValue(e.gradient,!0),negativeBarColorSameAsPositive:j.toBoolValue(e.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:j.toBoolValue(e.negativeBarBorderColorSameAsPositive,!0),axisPosition:j.toStringValue(e.axisPosition,`auto`),direction:j.toStringValue(e.direction,`leftToRight`)}}onParserClose(e,t){let[,n]=e.split(`:`);switch(n){case`cfvo`:this.model.cfvo.push(t.model);break;default:this.model[n]=t.model;break}}},Lo=class extends j{get tag(){return`x14:cfIcon`}render(e,t){e.leafNode(this.tag,{iconSet:t.iconSet,iconId:t.iconId})}parseOpen({attributes:e}){this.model={iconSet:e.iconSet,iconId:j.toIntValue(e.iconId)}}parseClose(e){return e!==this.tag}},Ro=class extends H{constructor(){super(),this.map={"x14:cfvo":this.cfvoXform=new Fo,"x14:cfIcon":this.cfIconXform=new Lo}}get tag(){return`x14:iconSet`}render(e,t){e.openNode(this.tag,{iconSet:j.toStringAttribute(t.iconSet),reverse:j.toBoolAttribute(t.reverse,!1),showValue:j.toBoolAttribute(t.showValue,!0),custom:j.toBoolAttribute(t.icons,!1)}),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),t.icons&&t.icons.forEach((t,n)=>{t.iconId=n,this.cfIconXform.render(e,t)}),e.closeNode()}createNewModel({attributes:e}){return{cfvo:[],iconSet:j.toStringValue(e.iconSet,`3TrafficLights`),reverse:j.toBoolValue(e.reverse,!1),showValue:j.toBoolValue(e.showValue,!0)}}onParserClose(e,t){let[,n]=e.split(`:`);switch(n){case`cfvo`:this.model.cfvo.push(t.model);break;case`cfIcon`:this.model.icons||(this.model.icons=[]),this.model.icons.push(t.model);break;default:this.model[n]=t.model;break}}};function U(e){return e.toString(16).padStart(2,`0`)}function zo(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=e;return U(t[0])+U(t[1])+U(t[2])+U(t[3])+`-`+U(t[4])+U(t[5])+`-`+U(t[6])+U(t[7])+`-`+U(t[8])+U(t[9])+`-`+U(t[10])+U(t[11])+U(t[12])+U(t[13])+U(t[14])+U(t[15])}function Bo(){let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID();let t=new Uint8Array(16);if(e?.getRandomValues)return e.getRandomValues(t),zo(t);for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return zo(t)}let Vo={"3Triangles":!0,"3Stars":!0,"5Boxes":!0};var Ho=class e extends H{constructor(){super(),this.map={"x14:dataBar":this.databarXform=new Io,"x14:iconSet":this.iconSetXform=new Ro}}get tag(){return`x14:cfRule`}static isExt(e){return e.type===`dataBar`?Io.isExt(e):!!(e.type===`iconSet`&&(e.custom||Vo[e.iconSet]))}prepare(t){e.isExt(t)&&(t.x14Id=`{${Bo()}}`.toUpperCase())}render(t,n){if(e.isExt(n))switch(n.type){case`dataBar`:this.renderDataBar(t,n);break;case`iconSet`:this.renderIconSet(t,n);break}}renderDataBar(e,t){e.openNode(this.tag,{type:`dataBar`,id:t.x14Id}),this.databarXform.render(e,t),e.closeNode()}renderIconSet(e,t){e.openNode(this.tag,{type:`iconSet`,priority:t.priority,id:t.x14Id??`{${Bo()}}`}),this.iconSetXform.render(e,t),e.closeNode()}createNewModel({attributes:e}){return{type:e.type,x14Id:e.id,priority:j.toIntValue(e.priority)}}onParserClose(e,t){Object.assign(this.model,t.model)}},Uo=class extends j{get tag(){return`xm:sqref`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},Wo=class extends H{constructor(){super(),this.map={"xm:sqref":this.sqRef=new Uo,"x14:cfRule":this.cfRule=new Ho}}get tag(){return`x14:conditionalFormatting`}prepare(e){e.rules.forEach(e=>{this.cfRule.prepare(e)})}render(e,t){t.rules.some(Ho.isExt)&&(e.openNode(this.tag,{"xmlns:xm":`http://schemas.microsoft.com/office/excel/2006/main`}),t.rules.filter(Ho.isExt).forEach(t=>this.cfRule.render(e,t)),this.sqRef.render(e,t.ref),e.closeNode())}createNewModel(){return{rules:[]}}onParserClose(e,t){switch(e){case`xm:sqref`:this.model.ref=t.model;break;case`x14:cfRule`:this.model.rules.push(t.model);break}}},Go=class extends H{constructor(){super(),this.map={"x14:conditionalFormatting":this.cfXform=new Wo}}get tag(){return`x14:conditionalFormattings`}hasContent(e){return e.hasExtContent===void 0&&(e.hasExtContent=e.some(e=>e.rules.some(Ho.isExt))),e.hasExtContent}prepare(e){e.forEach(e=>{this.cfXform.prepare(e)})}render(e,t){this.hasContent(t)&&(e.openNode(this.tag),t.forEach(t=>this.cfXform.render(e,t)),e.closeNode())}createNewModel(){return[]}onParserClose(e,t){this.model.push(t.model)}},Ko=class extends H{constructor(){super(),this.map={"x14:conditionalFormattings":this.conditionalFormattings=new Go}}get tag(){return`ext`}hasContent(e){return this.conditionalFormattings.hasContent(e.conditionalFormattings)}prepare(e){this.conditionalFormattings.prepare(e.conditionalFormattings)}render(e,t){e.openNode(`ext`,{uri:`{78C0D931-6437-407d-A8EE-F0AAD7539E65}`,"xmlns:x14":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`}),this.conditionalFormattings.render(e,t.conditionalFormattings),e.closeNode()}createNewModel(){return{}}onParserClose(e,t){this.model[e]=t.model}},qo=class extends H{constructor(){super(),this.map={ext:this.ext=new Ko}}get tag(){return`extLst`}prepare(e,t){this.ext.prepare(e)}hasContent(e){return this.ext.hasContent(e)}render(e,t){this.hasContent(t)&&(e.openNode(`extLst`),this.ext.render(e,t),e.closeNode())}createNewModel(){return{}}onParserClose(e,t){this.model[e]=t.model}};let Jo=(e,t)=>{Object.keys(t).forEach(n=>{let r=e[n],i=t[n];r===void 0&&i!==void 0&&(e[n]=i)})},Yo=(e,t)=>{if(!t||!t.length)return e;if(!e||!e.length)return t;let n={},r={};return e.forEach(e=>{n[e.ref]=e,e.rules.forEach(e=>{let{x14Id:t}=e;t&&(r[t]=e)})}),t.forEach(t=>{t.rules.forEach(i=>{let a=r[i.x14Id];a?Jo(a,i):n[t.ref]?n[t.ref].rules.push(i):e.push({ref:t.ref,rules:[i]})})}),e};var Xo=class e extends j{static{this.WORKSHEET_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`,"xmlns:x14ac":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac`,"mc:Ignorable":`x14ac`}}constructor(e){super();let{maxRows:t,maxCols:n,ignoreNodes:r}=e||{};this.ignoreNodes=r??[],this.map={sheetPr:new Xa,dimension:new Ba,sheetViews:new M({tag:`sheetViews`,count:!1,childXform:new $a}),sheetFormatPr:new Za,cols:new M({tag:`cols`,count:!1,childXform:new za}),sheetData:new M({tag:`sheetData`,count:!1,empty:!0,childXform:new Ra({maxItems:n}),maxItems:t}),autoFilter:new uo,mergeCells:new M({tag:`mergeCells`,count:!0,childXform:new Ha}),rowBreaks:new go,colBreaks:new _o,hyperlinks:new M({tag:`hyperlinks`,count:!1,childXform:new Va}),pageMargins:new to,dataValidations:new Ka,pageSetup:new so,headerFooter:new vo,printOptions:new lo,picture:new fo,drawing:new po,sheetProtection:new eo,tableParts:new M({tag:`tableParts`,count:!0,childXform:new mo}),conditionalFormatting:new No,extLst:new qo}}prepare(e,t){t.merges=new Pa,e.hyperlinks=t.hyperlinks=[],e.comments=t.comments=[],e.formControls&&e.formControls.length>0&&(!e.views||e.views.length===0)&&(e.views=[{workbookViewId:0}]),t.formulae={},t.siFormulae=0,this.map.cols.prepare(e.cols,t),this.map.sheetData.prepare(e.rows,t),this.map.conditionalFormatting.prepare(e.conditionalFormattings,t),e.mergeCells=t.merges.mergeCells;let n=e.rels=[];function r(e){return`rId${e.length+1}`}e.hyperlinks.forEach(e=>{let t=r(n);e.rId=t,n.push({Id:t,Type:z.Hyperlink,Target:e.target,TargetMode:`External`})});let{fileIndex:i}=e;if(e.comments.length>0){let a={Id:r(n),Type:z.Comments,Target:ia(i)};n.push(a);let o={Id:r(n),Type:z.VmlDrawing,Target:aa(i)};n.push(o),e.comments.forEach(e=>{e.refAddress=S.decodeAddress(e.ref)}),t.commentRefs.push({commentName:`comments${i}`,vmlDrawing:`vmlDrawing${i}`})}if(e.drawing&&e.drawing.anchors){let i=e.drawing;i.rId=r(n),i.name||=`drawing${++t.drawingsCount}`;let a=(i.rels??[]).some(e=>e.Target&&e.Target.includes(`/charts/`));i.anchors=[],a||(i.rels=[]),t.drawings.push(i),n.push({Id:i.rId,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,Target:oa(i.name)})}let a=[],o;if(e.media.forEach(i=>{if(i.type===`background`){let a=r(n);o=t.media[i.imageId],n.push({Id:a,Type:z.Image,Target:pa(`${o.name}.${o.extension}`)}),e.background={rId:a},e.image=t.media[i.imageId]}else if(i.type===`image`){let{drawing:s}=e;o=t.media[i.imageId],s||(s=e.drawing={rId:r(n),name:`drawing${++t.drawingsCount}`,anchors:[],rels:[]},t.drawings.push(s),n.push({Id:s.rId,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,Target:oa(s.name)}));let c=this.preImageId===i.imageId?a[i.imageId]:a[s.rels.length];c||(c=r(s.rels),a[s.rels.length]=c,s.rels.push({Id:c,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`,Target:pa(`${o.name}.${o.extension}`)}));let l={picture:{rId:c},range:i.range};if(i.hyperlinks&&i.hyperlinks.hyperlink){let e=r(s.rels);a[s.rels.length]=e,l.picture.hyperlinks={tooltip:i.hyperlinks.tooltip,rId:e},s.rels.push({Id:e,Type:z.Hyperlink,Target:i.hyperlinks.hyperlink,TargetMode:`External`})}this.preImageId=i.imageId,s.anchors.push(l)}}),e.tables.forEach(e=>{let i=r(n);e.rId=i,n.push({Id:i,Type:z.Table,Target:da(e.target)}),e.columns.forEach(e=>{let{style:n}=e;n&&(e.dxfId=t.styles.addDxfStyle(n))})}),(e.pivotTables??[]).forEach(e=>{n.push({Id:r(n),Type:z.PivotTable,Target:la(e.tableNumber)})}),e.formControls&&e.formControls.length>0){let{drawing:a}=e;a||(a=e.drawing={rId:r(n),name:`drawing${++t.drawingsCount}`,anchors:[],rels:[]},t.drawings.push(a),n.push({Id:a.rId,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,Target:oa(a.name)})),e.comments.length===0&&n.push({Id:r(n),Type:z.VmlDrawing,Target:aa(i)});let o=e=>({nativeCol:e.col,nativeColOff:e.colOff,nativeRow:e.row,nativeRowOff:e.rowOff});for(let i of e.formControls){let e=t.formControlRefs.length+1;i.ctrlPropId=e;let s=r(n);i.ctrlPropRelId=s,n.push({Id:s,Type:z.CtrlProp,Target:ha(e)}),t.formControlRefs.push(e);let c=`Check Box ${Math.max(1,i.shapeId-1024)}`;a.anchors.push({range:{editAs:`absolute`,tl:o(i.tl),br:o(i.br)},alternateContent:{requires:`a14`},shape:{cNvPrId:i.shapeId,name:i.name||c,hidden:!0,spid:`_x0000_s${i.shapeId}`,text:i.text}})}}this.map.extLst.prepare(e,t)}render(t,n){t.openXml(k.StdDocAttributes);let r={...e.WORKSHEET_ATTRIBUTES};n.formControls&&n.formControls.length>0&&(r[`xmlns:x14`]=`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`,r[`xmlns:xdr`]=`http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing`,r[`mc:Ignorable`]=`${r[`mc:Ignorable`]} x14`),t.openNode(`worksheet`,r);let i=n.properties?{defaultRowHeight:n.properties.defaultRowHeight,dyDescent:n.properties.dyDescent,outlineLevelCol:n.properties.outlineLevelCol,outlineLevelRow:n.properties.outlineLevelRow,customHeight:n.properties.customHeight}:void 0;n.properties&&n.properties.defaultColWidth&&(i.defaultColWidth=n.properties.defaultColWidth);let a={outlineProperties:n.properties&&n.properties.outlineProperties,tabColor:n.properties&&n.properties.tabColor,pageSetup:n.pageSetup&&n.pageSetup.fitToPage?{fitToPage:n.pageSetup.fitToPage}:void 0},o=n.pageSetup&&n.pageSetup.margins,s={showRowColHeaders:n.pageSetup&&n.pageSetup.showRowColHeaders,showGridLines:n.pageSetup&&n.pageSetup.showGridLines,horizontalCentered:n.pageSetup&&n.pageSetup.horizontalCentered,verticalCentered:n.pageSetup&&n.pageSetup.verticalCentered},c=n.sheetProtection;if(this.map.sheetPr.render(t,a),this.map.dimension.render(t,n.dimensions),this.map.sheetViews.render(t,n.views),this.map.sheetFormatPr.render(t,i),this.map.cols.render(t,n.cols),this.map.sheetData.render(t,n.rows),this.map.sheetProtection.render(t,c),this.map.autoFilter.render(t,n.autoFilter),this.map.mergeCells.render(t,n.mergeCells),this.map.conditionalFormatting.render(t,n.conditionalFormattings),this.map.dataValidations.render(t,n.dataValidations),this.map.hyperlinks.render(t,n.hyperlinks),this.map.printOptions.render(t,s),this.map.pageMargins.render(t,o),this.map.pageSetup.render(t,n.pageSetup),this.map.headerFooter.render(t,n.headerFooter),this.map.rowBreaks.render(t,n.rowBreaks),this.map.colBreaks.render(t,n.colBreaks),this.map.drawing.render(t,n.drawing),this.map.picture.render(t,n.background),n.rels&&n.rels.forEach(e=>{e.Type===z.VmlDrawing&&t.leafNode(`legacyDrawing`,{"r:id":e.Id})}),n.formControls&&n.formControls.length>0){t.openNode(`mc:AlternateContent`),t.openNode(`mc:Choice`,{Requires:`x14`}),t.openNode(`controls`);for(let e of n.formControls){if(!e.ctrlPropRelId)continue;let n=`Check Box ${Math.max(1,e.shapeId-1024)}`;t.openNode(`mc:AlternateContent`),t.openNode(`mc:Choice`,{Requires:`x14`}),t.openNode(`control`,{shapeId:e.shapeId,"r:id":e.ctrlPropRelId,name:e.name||n}),t.openNode(`controlPr`,{locked:0,defaultSize:0,print:e.print?1:0,autoFill:0,autoLine:0,autoPict:0}),t.openNode(`anchor`),t.openNode(`from`),t.leafNode(`xdr:col`,void 0,e.tl.col),t.leafNode(`xdr:colOff`,void 0,e.tl.colOff),t.leafNode(`xdr:row`,void 0,e.tl.row),t.leafNode(`xdr:rowOff`,void 0,e.tl.rowOff),t.closeNode(),t.openNode(`to`),t.leafNode(`xdr:col`,void 0,e.br.col),t.leafNode(`xdr:colOff`,void 0,e.br.colOff),t.leafNode(`xdr:row`,void 0,e.br.row),t.leafNode(`xdr:rowOff`,void 0,e.br.rowOff),t.closeNode(),t.closeNode(),t.closeNode(),t.closeNode(),t.closeNode(),t.leafNode(`mc:Fallback`),t.closeNode()}t.closeNode(),t.closeNode(),t.leafNode(`mc:Fallback`),t.closeNode()}this.map.tableParts.render(t,n.tables),this.map.extLst.render(t,n),t.closeNode()}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===`worksheet`?(Object.values(this.map).forEach(e=>{e.reset()}),!0):(this.map[e.name]&&!this.ignoreNodes.includes(e.name)&&(this.parser=this.map[e.name],this.parser.parseOpen(e)),!0)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`worksheet`:{let e=this.map.sheetFormatPr.model||{};this.map.sheetPr.model&&this.map.sheetPr.model.tabColor&&(e.tabColor=this.map.sheetPr.model.tabColor),this.map.sheetPr.model&&this.map.sheetPr.model.outlineProperties&&(e.outlineProperties=this.map.sheetPr.model.outlineProperties);let t={fitToPage:this.map.sheetPr.model&&this.map.sheetPr.model.pageSetup&&this.map.sheetPr.model.pageSetup.fitToPage||!1,margins:this.map.pageMargins.model},n=Object.assign(t,this.map.pageSetup.model,this.map.printOptions.model),r=Yo(this.map.conditionalFormatting.model,this.map.extLst.model&&this.map.extLst.model[`x14:conditionalFormattings`]);return this.model={dimensions:this.map.dimension.model,cols:this.map.cols.model,rows:this.map.sheetData.model,mergeCells:this.map.mergeCells.model,hyperlinks:this.map.hyperlinks.model,dataValidations:this.map.dataValidations.model,properties:e,views:this.map.sheetViews.model,pageSetup:n,headerFooter:this.map.headerFooter.model,background:this.map.picture.model,drawing:this.map.drawing.model,tables:this.map.tableParts.model,conditionalFormattings:r,rowBreaks:this.map.rowBreaks.model??[],colBreaks:this.map.colBreaks.model??[]},this.map.autoFilter.model&&(this.model.autoFilter=this.map.autoFilter.model),this.map.sheetProtection.model&&(this.model.sheetProtection=this.map.sheetProtection.model),!1}default:return!0}}reconcile(e,t){let n=(e.relationships??[]).reduce((n,r)=>{if(n[r.Id]=r,r.Type===z.Comments&&(e.comments=t.comments[r.Target].comments),r.Type===z.VmlDrawing&&e.comments&&e.comments.length){let n=t.vmlDrawings[r.Target].comments;e.comments.forEach((e,t)=>{e.note=Object.assign({},e.note,n[t])})}return n},{});if(t.commentsMap=(e.comments??[]).reduce((e,t)=>(t.ref&&(e[t.ref]=t),e),{}),t.hyperlinkMap=(e.hyperlinks??[]).reduce((e,t)=>(t.rId&&(e[t.address]=n[t.rId].Target),e),{}),t.formulae={},e.rows=e.rows?.filter(Boolean)??[],e.rows.forEach(e=>{e.cells=e.cells?.filter(Boolean)??[]}),this.map.cols.reconcile(e.cols,t),this.map.sheetData.reconcile(e.rows,t),this.map.conditionalFormatting.reconcile(e.conditionalFormattings,t),e.media=[],e.drawing){let r=n[e.drawing.rId].Target.match(/\/drawings\/([a-zA-Z0-9]+)[.][a-zA-Z]{3,4}$/);if(r){let n=r[1],i=t.drawings[n];i&&(e.drawing={...i,name:n,rels:t.drawingRels?.[n]??i.rels??[]},i.anchors.forEach(t=>{if(t.medium){let n={type:`image`,imageId:t.medium.index,range:t.range,hyperlinks:t.picture.hyperlinks};e.media.push(n)}}))}}let r=e.background&&n[e.background.rId];if(r){let n=r.Target.split(`/media/`)[1],i=t.mediaIndex&&t.mediaIndex[n];i!==void 0&&e.media.push({type:`background`,imageId:i})}e.tables=(e.tables??[]).map(e=>{let r=n[e.rId];return t.tables[r.Target]}),e.pivotTables=[],(e.relationships??[]).forEach(n=>{if(n.Type===z.PivotTable&&t.pivotTables){let r=t.pivotTables[n.Target];r&&e.pivotTables.push(r)}}),delete e.relationships,delete e.hyperlinks,delete e.comments}},Zo=class extends j{render(e){e.openXml({version:`1.0`,encoding:`UTF-8`,standalone:`yes`}),e.openNode(`FeaturePropertyBags`,{xmlns:`http://schemas.microsoft.com/office/spreadsheetml/2022/featurepropertybag`}),e.leafNode(`bag`,{type:`Checkbox`}),e.openNode(`bag`,{type:`XFControls`}),e.leafNode(`bagId`,{k:`CellControl`},`0`),e.closeNode(),e.openNode(`bag`,{type:`XFComplement`}),e.leafNode(`bagId`,{k:`XFControls`},`1`),e.closeNode(),e.openNode(`bag`,{type:`XFComplements`,extRef:`XFComplementsMapperExtRef`}),e.openNode(`a`,{k:`MappedFeaturePropertyBags`}),e.leafNode(`bagId`,{},`2`),e.closeNode(),e.closeNode(),e.closeNode()}parseOpen(){return!1}parseText(){}parseClose(){return!1}},Qo=class extends j{parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset(),this.model={range:{editAs:e.attributes.editAs??`oneCell`}};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}reconcilePicture(e,t){if(e&&e.rId){let n=t.rels[e.rId].Target.match(/.*\/media\/(.+[.][a-zA-Z]{3,4})/);if(n){let e=n[1],r=t.mediaIndex[e];return t.media[r]}}}},$o=class extends j{constructor(e){super(),this.tag=e.tag,this.map={"xdr:col":new kr({tag:`xdr:col`,zero:!0}),"xdr:colOff":new kr({tag:`xdr:colOff`,zero:!0}),"xdr:row":new kr({tag:`xdr:row`,zero:!0}),"xdr:rowOff":new kr({tag:`xdr:rowOff`,zero:!0})},this.model={nativeCol:0,nativeColOff:0,nativeRow:0,nativeRowOff:0}}render(e,t){e.openNode(this.tag),this.map[`xdr:col`].render(e,t.nativeCol),this.map[`xdr:colOff`].render(e,t.nativeColOff),this.map[`xdr:row`].render(e,t.nativeRow),this.map[`xdr:rowOff`].render(e,t.nativeRowOff),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model={nativeCol:this.map[`xdr:col`].model,nativeColOff:this.map[`xdr:colOff`].model,nativeRow:this.map[`xdr:row`].model,nativeRowOff:this.map[`xdr:rowOff`].model},!1;default:return!0}}},es=class extends j{constructor(){super(),this.model={rId:``}}get tag(){return`a:blip`}render(e,t){e.leafNode(this.tag,{"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"r:embed":t.rId,cstate:`print`})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:embed`]},!0;default:return!0}}parseText(){}parseClose(e){switch(e){case this.tag:return!1;default:return!0}}},ts=class extends j{constructor(){super(),this.map={"a:blip":new es}}get tag(){return`xdr:blipFill`}render(e,t){e.openNode(this.tag),this.map[`a:blip`].render(e,t),e.openNode(`a:stretch`),e.leafNode(`a:fillRect`),e.closeNode(),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model=this.map[`a:blip`].model,!1;default:return!0}}},ns=class extends j{constructor(){super(),this.model={}}get tag(){return`a:hlinkClick`}render(e,t){t.hyperlinks&&t.hyperlinks.rId&&e.leafNode(this.tag,{"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"r:id":t.hyperlinks.rId,tooltip:t.hyperlinks.tooltip})}parseOpen(e){switch(e.name){case this.tag:return this.model={hyperlinks:{rId:e.attributes[`r:id`],tooltip:e.attributes.tooltip}},!0;default:return!0}}parseText(){}parseClose(){return!1}},rs=class extends j{get tag(){return`a:extLst`}render(e){e.openNode(this.tag),e.openNode(`a:ext`,{uri:`{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}`}),e.leafNode(`a16:creationId`,{"xmlns:a16":`http://schemas.microsoft.com/office/drawing/2014/main`,id:`{00000000-0008-0000-0000-000002000000}`}),e.closeNode(),e.closeNode()}parseOpen(e){switch(e.name){case this.tag:return!0;default:return!0}}parseText(){}parseClose(e){switch(e){case this.tag:return!1;default:return!0}}},is=class extends j{constructor(){super(),this.map={"a:hlinkClick":new ns,"a:extLst":new rs}}get tag(){return`xdr:cNvPr`}render(e,t){e.openNode(this.tag,{id:t.index,name:`Picture ${t.index}`}),this.map[`a:hlinkClick`].render(e,t),this.map[`a:extLst`].render(e,t),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model=this.map[`a:hlinkClick`].model,!1;default:return!0}}},as=class extends j{get tag(){return`xdr:cNvPicPr`}render(e){e.openNode(this.tag),e.leafNode(`a:picLocks`,{noChangeAspect:`1`}),e.closeNode()}parseOpen(e){switch(e.name){case this.tag:return!0;default:return!0}}parseText(){}parseClose(e){switch(e){case this.tag:return!1;default:return!0}}},os=class extends j{constructor(){super(),this.map={"xdr:cNvPr":new is,"xdr:cNvPicPr":new as}}get tag(){return`xdr:nvPicPr`}render(e,t){e.openNode(this.tag),this.map[`xdr:cNvPr`].render(e,t),this.map[`xdr:cNvPicPr`].render(e,t),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model=this.map[`xdr:cNvPr`].model,!1;default:return!0}}};let ss={tag:`xdr:spPr`,c:[{tag:`a:xfrm`,c:[{tag:`a:off`,$:{x:`0`,y:`0`}},{tag:`a:ext`,$:{cx:`0`,cy:`0`}}]},{tag:`a:prstGeom`,$:{prst:`rect`},c:[{tag:`a:avLst`}]}]};var cs=class extends j{constructor(){super(),this.map={"xdr:nvPicPr":new os,"xdr:blipFill":new ts,"xdr:spPr":new Dr(ss)}}get tag(){return`xdr:pic`}prepare(e,t){e.index=t.index+1}render(e,t){e.openNode(this.tag),this.map[`xdr:nvPicPr`].render(e,t),this.map[`xdr:blipFill`].render(e,t),this.map[`xdr:spPr`].render(e,t),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.mergeModel(this.parser.model),this.parser=void 0),!0;switch(e){case this.tag:return!1;default:return!0}}},ls=class extends j{get tag(){return`xdr:sp`}render(e,t){t&&(e.openNode(this.tag,{macro:``,textlink:``}),e.openNode(`xdr:nvSpPr`),e.openNode(`xdr:cNvPr`,{id:t.cNvPrId,name:t.name,hidden:t.hidden?`1`:void 0}),e.openNode(`a:extLst`),e.openNode(`a:ext`,{uri:`{63B3BB69-23CF-44E3-9099-C40C66FF867C}`}),e.leafNode(`a14:compatExt`,{spid:t.spid,"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`},void 0),e.closeNode(),e.closeNode(),e.closeNode(),e.leafNode(`xdr:cNvSpPr`),e.closeNode(),e.openNode(`xdr:spPr`,{bwMode:`auto`}),e.openNode(`a:xfrm`),e.leafNode(`a:off`,{x:0,y:0}),e.leafNode(`a:ext`,{cx:0,cy:0}),e.closeNode(),e.openNode(`a:prstGeom`,{prst:`rect`}),e.leafNode(`a:avLst`),e.closeNode(),e.leafNode(`a:noFill`),e.openNode(`a:ln`),e.leafNode(`a:noFill`),e.closeNode(),e.openNode(`a:extLst`),e.openNode(`a:ext`,{uri:`{909E8E84-426E-40DD-AFC4-6F175D3DCCD1}`}),e.openNode(`a14:hiddenFill`,{"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`}),e.openNode(`a:solidFill`),e.leafNode(`a:srgbClr`,{val:`F0F0F0`}),e.closeNode(),e.closeNode(),e.closeNode(),e.openNode(`a:ext`,{uri:`{91240B29-F687-4F45-9708-019B960494DF}`}),e.openNode(`a14:hiddenLine`,{w:9525,"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`}),e.openNode(`a:solidFill`),e.leafNode(`a:srgbClr`,{val:`000000`}),e.closeNode(),e.leafNode(`a:miter`,{lim:8e5}),e.leafNode(`a:headEnd`),e.leafNode(`a:tailEnd`),e.closeNode(),e.closeNode(),e.closeNode(),e.closeNode(),e.openNode(`xdr:txBody`),e.leafNode(`a:bodyPr`,{vertOverflow:`clip`,wrap:`square`,lIns:18288,tIns:18288,rIns:0,bIns:18288,anchor:`ctr`,upright:1}),e.leafNode(`a:lstStyle`),e.openNode(`a:p`),e.openNode(`a:pPr`,{algn:`l`,rtl:0}),e.leafNode(`a:defRPr`,{sz:1e3}),e.closeNode(),e.openNode(`a:r`),e.openNode(`a:rPr`,{lang:`en-US`,sz:800,b:0,i:0,u:`none`,strike:`noStrike`,baseline:0}),e.openNode(`a:solidFill`),e.leafNode(`a:srgbClr`,{val:`000000`}),e.closeNode(),e.leafNode(`a:latin`,{typeface:`Tahoma`,pitchFamily:2,charset:0}),e.leafNode(`a:ea`,{typeface:`Tahoma`,pitchFamily:2,charset:0}),e.leafNode(`a:cs`,{typeface:`Tahoma`,pitchFamily:2,charset:0}),e.closeNode(),e.openNode(`a:t`),e.writeText(t.text??``),e.closeNode(),e.closeNode(),e.closeNode(),e.closeNode(),e.closeNode())}},us=class extends Qo{constructor(){super(),this.map={"xdr:from":new $o({tag:`xdr:from`}),"xdr:to":new $o({tag:`xdr:to`}),"xdr:pic":new cs,"xdr:sp":new ls,"xdr:clientData":new Dr({tag:`xdr:clientData`})}}get tag(){return`xdr:twoCellAnchor`}prepare(e,t){e.picture&&this.map[`xdr:pic`].prepare(e.picture,t)}render(e,t){let n=!!t.alternateContent;n&&(e.openNode(`mc:AlternateContent`,{"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`}),e.openNode(`mc:Choice`,{Requires:t.alternateContent?.requires,...t.alternateContent?.requires===`a14`?{"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`}:{}})),e.openNode(this.tag,{editAs:t.range.editAs??`oneCell`}),this.map[`xdr:from`].render(e,t.range.tl),this.map[`xdr:to`].render(e,t.range.br),t.picture?this.map[`xdr:pic`].render(e,t.picture):t.shape&&this.map[`xdr:sp`].render(e,t.shape),this.map[`xdr:clientData`].render(e,{}),e.closeNode(),n&&(e.closeNode(),e.leafNode(`mc:Fallback`),e.closeNode())}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.range.tl=this.map[`xdr:from`].model,this.model.range.br=this.map[`xdr:to`].model,this.model.picture=this.map[`xdr:pic`].model,!1;default:return!0}}reconcile(e,t){e.medium=this.reconcilePicture(e.picture,t)}};let ds=9525;var fs=class extends j{constructor(e){super(),this.tag=e.tag,this.map={},this.model={width:0,height:0}}render(e,t){e.openNode(this.tag);let n=Math.floor(t.width*ds),r=Math.floor(t.height*ds);e.addAttribute(`cx`,n),e.addAttribute(`cy`,r),e.closeNode()}parseOpen(e){return e.name===this.tag?(this.model={width:parseInt(e.attributes.cx??`0`,10)/ds,height:parseInt(e.attributes.cy??`0`,10)/ds},!0):!1}parseText(e){}parseClose(e){return!1}},ps=class extends Qo{constructor(){super(),this.map={"xdr:from":new $o({tag:`xdr:from`}),"xdr:ext":new fs({tag:`xdr:ext`}),"xdr:pic":new cs,"xdr:clientData":new Dr({tag:`xdr:clientData`})}}get tag(){return`xdr:oneCellAnchor`}prepare(e,t){this.map[`xdr:pic`].prepare(e.picture,t)}render(e,t){e.openNode(this.tag,{editAs:t.range.editAs??`oneCell`}),this.map[`xdr:from`].render(e,t.range.tl),this.map[`xdr:ext`].render(e,t.range.ext),this.map[`xdr:pic`].render(e,t.picture),this.map[`xdr:clientData`].render(e,{}),e.closeNode()}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.range.tl=this.map[`xdr:from`].model,this.model.range.ext=this.map[`xdr:ext`].model,this.model.picture=this.map[`xdr:pic`].model,!1;default:return!0}}reconcile(e,t){e.medium=this.reconcilePicture(e.picture,t)}};function ms(e){return(typeof e.range==`string`?S.decode(e.range):e.range).br?`xdr:twoCellAnchor`:`xdr:oneCellAnchor`}var hs=class e extends j{constructor(){super(),this.map={"xdr:twoCellAnchor":new us,"xdr:oneCellAnchor":new ps},this.model={anchors:[]}}prepare(e){e.anchors.forEach((e,t)=>{e.anchorType=ms(e),this.map[e.anchorType].prepare(e,{index:t})})}get tag(){return`xdr:wsDr`}render(t,n){let r=n||this.model;t.openXml(k.StdDocAttributes),t.openNode(this.tag,e.DRAWING_ATTRIBUTES),r.anchors.forEach(e=>{this.map[e.anchorType].render(t,e)}),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset(),this.model={anchors:[]};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.anchors.push(this.parser.model),this.parser=void 0),!0;switch(e){case this.tag:return!1;default:return!0}}reconcile(e,t){e.anchors.forEach(e=>{e.br?this.map[`xdr:twoCellAnchor`].reconcile(e,t):this.map[`xdr:oneCellAnchor`].reconcile(e,t)})}static{this.DRAWING_ATTRIBUTES={"xmlns:xdr":`http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing`,"xmlns:a":`http://schemas.openxmlformats.org/drawingml/2006/main`}}},gs=class extends j{constructor(){super(),this.model={val:``}}get tag(){return`customFilter`}render(e,t){e.leafNode(this.tag,{val:t.val,operator:t.operator})}parseOpen(e){return e.name===this.tag?(this.model={val:e.attributes.val,operator:e.attributes.operator},!0):!1}parseText(){}parseClose(){return!1}},_s=class extends j{constructor(){super(),this.model={val:``}}get tag(){return`filter`}render(e,t){e.leafNode(this.tag,{val:t.val})}parseOpen(e){return e.name===this.tag?(this.model={val:e.attributes.val},!0):!1}parseText(){}parseClose(){return!1}},vs=class extends j{constructor(){super(),this.map={customFilters:new M({tag:`customFilters`,count:!1,empty:!0,childXform:new gs}),filters:new M({tag:`filters`,count:!1,empty:!0,childXform:new _s})},this.model={filterButton:!1}}get tag(){return`filterColumn`}prepare(e,t){e.colId=t.index.toString()}render(e,t){if(t.customFilters){e.openNode(this.tag,{colId:t.colId,hiddenButton:t.filterButton?`0`:`1`}),this.map.customFilters.render(e,t.customFilters),e.closeNode();return}e.leafNode(this.tag,{colId:t.colId,hiddenButton:t.filterButton?`0`:`1`})}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;let{attributes:t}=e;switch(e.name){case this.tag:return this.model={filterButton:t.hiddenButton===`0`},!0;case`dynamicFilter`:return!0;default:if(this.parser=this.map[e.name],this.parser)return this.parseOpen(e),!0;throw new _(`filterColumn`,`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.customFilters=this.map.customFilters.model,!1;default:return!0}}},ys=class extends j{constructor(){super(),this.map={filterColumn:new vs},this.model={autoFilterRef:``,columns:[]}}get tag(){return`autoFilter`}prepare(e){e.columns.forEach((e,t)=>{this.map.filterColumn.prepare(e,{index:t})})}render(e,t){e.openNode(this.tag,{ref:t.autoFilterRef}),t.columns.forEach(t=>{this.map.filterColumn.render(e,t)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:return this.model={autoFilterRef:e.attributes.ref,columns:[]},!0;default:if(this.parser=this.map[e.name],this.parser)return this.parseOpen(e),!0;throw new _(`autoFilter`,`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.columns.push(this.parser.model),this.parser=void 0),!0;switch(e){case this.tag:return!1;default:throw new _(`autoFilter`,`Unexpected xml node in parseClose: ${e}`)}}},bs=class extends j{constructor(){super(),this._childText=``,this.model={name:``}}get tag(){return`tableColumn`}prepare(e,t){e.id=t.index+1}_renderAttributes(e){return{id:e.id.toString(),name:yt(e.name),totalsRowLabel:e.totalsRowLabel?yt(e.totalsRowLabel):void 0,totalsRowFunction:e.totalsRowFunction===`none`?void 0:e.totalsRowFunction,dxfId:e.dxfId}}render(e,t){t.calculatedColumnFormula||t.totalsRowFormula?(e.openNode(this.tag,this._renderAttributes(t)),t.calculatedColumnFormula&&e.leafNode(`calculatedColumnFormula`,void 0,t.calculatedColumnFormula),t.totalsRowFormula&&e.leafNode(`totalsRowFormula`,void 0,t.totalsRowFormula),e.closeNode()):e.leafNode(this.tag,this._renderAttributes(t))}parseOpen(e){if(e.name===this.tag){let{attributes:t}=e;return this.model={name:ht(t.name),totalsRowLabel:t.totalsRowLabel?ht(t.totalsRowLabel):void 0,totalsRowFunction:t.totalsRowFunction,dxfId:t.dxfId},!0}return(e.name===`calculatedColumnFormula`||e.name===`totalsRowFormula`)&&(this._childTag=e.name,this._childText=``),!0}parseText(e){this._childTag&&(this._childText+=e)}parseClose(e){return e===this.tag?!1:(this._childTag&&e===this._childTag&&(this.model[this._childTag]=this._childText,this._childTag=void 0),!0)}},xs=class extends j{constructor(){super(),this.model={theme:null,showFirstColumn:!1,showLastColumn:!1,showRowStripes:!1,showColumnStripes:!1}}get tag(){return`tableStyleInfo`}render(e,t){e.leafNode(this.tag,{name:t.theme?t.theme:void 0,showFirstColumn:t.showFirstColumn?`1`:`0`,showLastColumn:t.showLastColumn?`1`:`0`,showRowStripes:t.showRowStripes?`1`:`0`,showColumnStripes:t.showColumnStripes?`1`:`0`})}parseOpen(e){if(e.name===this.tag){let{attributes:t}=e;return this.model={theme:t.name?t.name:null,showFirstColumn:t.showFirstColumn===`1`,showLastColumn:t.showLastColumn===`1`,showRowStripes:t.showRowStripes===`1`,showColumnStripes:t.showColumnStripes===`1`},!0}return!1}parseText(){}parseClose(){return!1}},Ss=class e extends j{constructor(){super(),this.map={autoFilter:new ys,tableColumns:new M({tag:`tableColumns`,count:!0,empty:!0,childXform:new bs}),tableStyleInfo:new xs},this.model={id:0,name:``,tableRef:``,columns:[]}}prepare(e,t){this.map.autoFilter.prepare(e),this.map.tableColumns.prepare(e.columns,t)}get tag(){return`table`}render(t,n){t.openXml(k.StdDocAttributes),t.openNode(this.tag,{...e.TABLE_ATTRIBUTES,id:n.id,name:n.name,displayName:n.displayName||n.name,ref:n.tableRef,totalsRowCount:n.totalsRow?`1`:void 0,headerRowCount:n.headerRow?void 0:`0`}),this.map.autoFilter.render(t,n),this.map.tableColumns.render(t,n.columns),this.map.tableStyleInfo.render(t,n.style),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;let{name:t,attributes:n}=e;switch(t){case this.tag:this.reset(),this.model={name:n.name,displayName:n.displayName||n.name,tableRef:n.ref,totalsRow:n.totalsRowCount===`1`,headerRow:n.headerRowCount!==`0`};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.columns=this.map.tableColumns.model,this.map.autoFilter.model&&(this.model.autoFilterRef=this.map.autoFilter.model.autoFilterRef,this.map.autoFilter.model.columns.forEach((e,t)=>{this.model.columns[t].filterButton=e.filterButton})),this.model.style=this.map.tableStyleInfo.model,!1;default:return!0}}reconcile(e,t){e.tableRef&&!e.ref&&(e.ref=e.tableRef),e.rows||=[],e.columns.forEach(e=>{e.dxfId!==void 0&&(e.style=t.styles.getDxfStyle(e.dxfId))})}static{this.TABLE_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`}}};function Cs(e){return isNaN(e.getTime())?``:e.toISOString().replace(/\.\d{3}Z$/,``)}function ws(e){let t=E(e.name),n=e.numFmtId??`0`,r=Es(e.extraAttrs),i=e.fieldGroupXml?`\n ${e.fieldGroupXml}`:``;if(e.sharedItems===null){if(e.isLoaded)return i?`<cacheField name="${t}" numFmtId="${n}"${r}>${i}\n </cacheField>`:`<cacheField name="${t}" numFmtId="${n}"${r} />`;let a;return a=e.minValue!==void 0&&e.maxValue!==void 0?` containsSemiMixedTypes="0" containsString="0" containsNumber="1"${e.containsInteger?` containsInteger="1"`:``} minValue="${e.minValue}" maxValue="${e.maxValue}"`:``,`<cacheField name="${t}" numFmtId="${n}"${r}>
10
+ `),t=this.i):hr(i)||(r=!0)}r&&(!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail(`text data outside of root node.`),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail(`text data outside of root node.`),this.reportedTextAfterRoot=!0))}sOpenWaka(){let e=this.getCode();if(_r(e)){this.state=3,this.name=A(e);return}switch(e){case 47:this.state=11,this.name=``;break;case 33:this.state=2,this.openWakaBang=``;break;case 63:this.state=19,this.text=``;break;default:this.fail(`unexpected character in tag`),this.state=0}}sOpenWakaBang(){let e=this.getCode();switch(this.openWakaBang+=A(e),this.openWakaBang){case`[CDATA[`:this.state=16,this.text=``,this.openWakaBang=``;break;case`--`:this.state=13,this.text=``,this.openWakaBang=``;break;case`DOCTYPE`:this.state=21,this.text=``,this.openWakaBang=``;break;default:this.openWakaBang.length>=7&&(this.fail(`incorrect syntax`),this.state=0)}}sOpenTag(){let e=this.getCode();if(e!==-1){if(vr(e)){this.name+=A(e);return}this.tag={name:this.name,attributes:Object.create(null),isSelfClosing:!1},this.attribList=[],this.sawRoot=!0,e===62?this.openTag():e===47?this.state=4:(hr(e)||this.fail(`unexpected character in tag`),this.state=5)}}sOpenTagSlash(){this.getCode()===62?this.openSelfClosingTag():(this.fail(`expected >`),this.state=5)}sAttrib(){let e=this.skipSpaces();e!==-1&&(_r(e)?(this.name=A(e),this.state=6):e===62?this.openTag():e===47?this.state=4:this.fail(`unexpected character in attribute`))}sAttribName(){let e=this.getCode();if(e!==-1){if(vr(e)){this.name+=A(e);return}e===61?this.state=8:hr(e)?this.state=7:e===62?(this.fail(`attribute without value`),this.attribList.push({name:this.name,value:this.name}),this.name=``,this.openTag()):this.fail(`unexpected character in attribute name`)}}sAttribNameSawWhite(){let e=this.skipSpaces();e!==-1&&(e===61?this.state=8:(this.fail(`attribute without value`),this.name=``,this.text=``,e===62?this.openTag():_r(e)?(this.name=A(e),this.state=6):(this.fail(`unexpected character`),this.state=5)))}sAttribValue(){let e=this.skipSpaces();e!==-1&&(gr(e)?(this.q=e,this.text=``,this.state=9):(this.fail(`unquoted attribute value`),this.state=0))}sAttribValueQuoted(){let{q:e,chunk:t}=this,{i:n}=this;for(;;){let r=this.getCode();if(r===-1){this.text+=t.slice(n,this.i);return}if(r===e){this.attribList.push({name:this.name,value:this.text+t.slice(n,this.prevI)}),this.name=``,this.text=``,this.q=null,this.state=10;return}if(r===38){this.text+=t.slice(n,this.prevI),this.state=25,this.entityReturnState=9,this.entity=``;return}if((r===10||r===9)&&(this.text+=t.slice(n,this.prevI)+` `,n=this.i),r===60){this.text+=t.slice(n,this.prevI),this.fail(`< not allowed in attribute value`);return}}}sAttribValueClosed(){let e=this.getCode();e!==-1&&(hr(e)?this.state=5:e===62?this.openTag():e===47?this.state=4:_r(e)?(this.fail(`no whitespace between attributes`),this.name=A(e),this.state=6):this.fail(`unexpected character after attribute`))}sCloseTag(){let e=this.getCode();e!==-1&&(vr(e)?this.name+=A(e):e===62?this.closeTag():hr(e)?this.state=12:this.fail(`unexpected character in close tag`))}sCloseTagSawWhite(){let e=this.skipSpaces();e!==-1&&(e===62?this.closeTag():this.fail(`unexpected character in close tag`))}sComment(){let e=this.getCode();e!==-1&&(e===45?this.state=14:this.text+=A(e))}sCommentEnding(){let e=this.getCode();e===45?this.state=15:(this.text+=`-`+A(e),this.state=13)}sCommentEnded(){let e=this.getCode();e===62?(this.text=``,this.state=0):e===45?this.text+=`-`:(this.fail(`malformed comment`),this.text+=`--`+A(e),this.state=13)}sCData(){let e=this.getCode();e!==-1&&(e===93?this.state=17:this.text+=A(e))}sCDataEnding(){let e=this.getCode();e===93?this.state=18:(this.text+=`]`+A(e),this.state=16)}sCDataEnding2(){let e=this.getCode();e===62?(this.textHandler&&this.text.length>0&&this.textHandler(this.text),this.text=``,this.state=0):e===93?this.text+=`]`:(this.text+=`]]`+A(e),this.state=16)}sPI(){let e=this.getCode();e!==-1&&(e===63?this.state=20:this.text+=A(e))}sPIEnding(){let e=this.getCode();e===62?(this.text=``,this.state=0):e===63?this.text+=`?`:(this.text+=`?`+A(e),this.state=19)}sDoctype(){let e=this.getCode();e!==-1&&(e===62?(this.text=``,this.state=0):gr(e)?(this.q=e,this.state=22):e===91?this.state=23:this.text+=A(e))}sDoctypeQuote(){let e=this.getCode();e!==-1&&(e===this.q?(this.q=null,this.state=21):this.text+=A(e))}sDoctypeDTD(){let e=this.getCode();e!==-1&&(e===93?this.state=21:gr(e)&&(this.q=e,this.state=24))}sDoctypeDTDQuoted(){let e=this.getCode();e!==-1&&e===this.q&&(this.q=null,this.state=23)}sEntity(){let e=this.getCode();if(e!==-1)if(e===59){let e=this.entity,t;e===``?(this.fail(`empty entity`),t=`&;`):t=this.parseEntity(e),this.text+=t,this.state=this.entityReturnState,this.entity=``}else vr(e)||e===35?this.entity+=A(e):(this.fail(`invalid entity character`),this.text+=`&`+this.entity+A(e),this.state=this.entityReturnState,this.entity=``)}parseEntity(e){if(e[0]!==`#`){let t=this.ENTITIES[e];return t===void 0?(this.fail(`undefined entity: `+e),`&`+e+`;`):t}let t;return t=e[1]===`x`||e[1]===`X`?parseInt(e.slice(2),16):parseInt(e.slice(1),10),isNaN(t)||!yr(t)?(this.fail(`invalid character entity`),`&`+e+`;`):String.fromCodePoint(t)}skipSpaces(){for(;;){let e=this.getCode();if(e===-1||!hr(e))return e}}openTag(){let e=this.tag;e.isSelfClosing=!1;for(let{name:t,value:n}of this.attribList)e.attributes[t]=n;this.attribList=[],this.openTagHandler?.(e),this.tags.push(e),this.name=``,this.state=0}openSelfClosingTag(){let e=this.tag;e.isSelfClosing=!0;for(let{name:t,value:n}of this.attribList)e.attributes[t]=n;this.attribList=[],this.openTagHandler?.(e),this.closeTagHandler?.(e),this.tags.length===0&&(this.closedRoot=!0),this.name=``,this.state=0}closeTag(){let{tags:e,name:t}=this;if(this.state=0,this.name=``,t===``){this.fail(`empty close tag`),this.text+=`</>`;return}let n=!1;for(let r=e.length-1;r>=0;r--)if(e[r].name===t){for(;e.length>r;){let t=e.pop();this.closeTagHandler?.(t),e.length>r&&this.fail(`unclosed tag: `+t.name)}n=!0;break}n||(this.fail(`unmatched close tag: `+t),this.text+=`</`+t+`>`),e.length===0&&(this.closedRoot=!0)}end(){for(this.sawRoot||this.fail(`document must contain a root element`);this.tags.length>0;){let e=this.tags.pop();this.fail(`unclosed tag: `+e.name)}return this.text.length>0&&this.textHandler&&(this.textHandler(this.text),this.text=``),this._closed=!0,this._init(),this}};async function*Sr(e){let t=new xr({xmlns:!1,position:!0}),n;t.on(`error`,e=>{n=e});let r=[];t.on(`opentag`,e=>r.push({eventType:`opentag`,value:e})),t.on(`text`,e=>r.push({eventType:`text`,value:e})),t.on(`closetag`,e=>r.push({eventType:`closetag`,value:e}));for await(let i of e){let e=Ft(i);if(t.write(e),n)throw n;yield r,r=[]}if(t.close(),n)throw n;r.length>0&&(yield r)}let Cr=new Set([`ep`,`cp`,`dc`,`dcterms`,`dcmitype`,`vt`]);function wr(e,t){for(let e in t)if(e.length>6&&e.startsWith(`xmlns:`)){let n=e.slice(6);if(t[e]===`http://schemas.openxmlformats.org/spreadsheetml/2006/main`)return n;if(Cr.has(n))return null}let n=e.indexOf(`:`);return n!==-1&&Cr.has(e.slice(0,n))?null:void 0}function Tr(e,t){let n=e.indexOf(`:`);if(n===-1)return e;let r=e.slice(0,n);return r===t||Cr.has(r)?e.slice(n+1):e}var j=class e{prepare(e,t){}render(e,t){}parseOpen(e){}parseText(e){}parseClose(e){return!1}reconcile(e,t){}reset(){this.model=void 0,this.map&&Object.values(this.map).forEach(t=>{t instanceof e?t.reset():t.xform&&t.xform.reset()})}mergeModel(e){this.model=Object.assign(this.model||{},e)}async parse(e){let t=!1,n,r=0,i=null;for await(let a of e)if(!t){for(let{eventType:e,value:o}of a)if(e===`opentag`){if(r===1){this.parseOpen(o);continue}if(r===0){let e=wr(o.name,o.attributes);if(e===void 0){r=1,this.parseOpen(o);continue}r=2,i=e}o.name=Tr(o.name,i),this.parseOpen(o)}else if(e===`text`)this.parseText(o);else if(e===`closetag`){if(r===1){if(!this.parseClose(o.name)){t=!0,n=this.model;break}continue}if(!this.parseClose(Tr(o.name,i))){t=!0,n=this.model;break}}}return t?n:this.model}async parseStream(e){return this.parse(Sr(e))}get xml(){return this.toXml(this.model)}toXml(e){let t=new k;return this.render(t,e),t.xml}static toAttribute(e,t,n=!1){if(e===void 0){if(n)return t}else if(n||e!==t)return e.toString()}static toStringAttribute(t,n,r=!1){return e.toAttribute(t,n,r)}static toStringValue(e,t){return e===void 0?t:e}static toBoolAttribute(e,t,n=!1){if(e===void 0){if(n)return t}else if(n||e!==t)return e?`1`:`0`}static toBoolValue(e,t){return e===void 0?t:e===`1`}static toIntAttribute(t,n,r=!1){return e.toAttribute(t,n,r)}static toIntValue(e,t){return e===void 0?t:parseInt(e,10)}static toFloatAttribute(t,n,r=!1){return e.toAttribute(t,n,r)}static toFloatValue(e,t){return e===void 0?t:parseFloat(e)}};function Er(e,t){e.openNode(t.tag,t.$),t.c&&t.c.forEach(t=>{Er(e,t)}),t.t&&e.writeText(t.t),e.closeNode()}var Dr=class extends j{constructor(e){super(),this._model=e}render(e){if(!this._xml){let e=new k;Er(e,this._model),this._xml=e.xml}e.writeXml(this._xml)}parseOpen(){return!0}parseText(){}parseClose(e){switch(e){case this._model.tag:return!1;default:return!0}}},M=class extends j{constructor(e){super(),this.tag=e.tag,this.always=!!e.always,this.count=e.count,this.empty=e.empty,this.$count=e.$count??`count`,this.$=e.$,this.childXform=e.childXform,this.maxItems=e.maxItems}prepare(e,t){let{childXform:n}=this;e&&e.forEach((e,r)=>{t.index=r,n.prepare(e,t)})}render(e,t){if(this.always||t&&t.length){e.openNode(this.tag,this.$),this.count&&e.addAttribute(this.$count,t?.length??0);let{childXform:n}=this;(t??[]).forEach((t,r)=>{n.render(e,t,r)}),e.closeNode()}else this.empty&&e.leafNode(this.tag)}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.model=[],!0):this.childXform.parseOpen(e)?(this.parser=this.childXform,!0):!1}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)&&(this.model.push(this.parser.model),this.parser=void 0,this.maxItems&&this.model.length>this.maxItems))throw new re(this.childXform.tag,this.maxItems);return!0}return!1}reconcile(e,t){if(e){let{childXform:n}=this;e.forEach(e=>{n.reconcile(e,t)})}}reset(){super.reset(),this.childXform&&this.childXform.reset()}},N=class extends j{constructor(e){super(),this.name=e??`color`}get tag(){return this.name}render(e,t){return t?(e.openNode(this.name),t.argb?e.addAttribute(`rgb`,t.argb):t.theme===void 0?t.indexed===void 0?e.addAttribute(`auto`,`1`):e.addAttribute(`indexed`,t.indexed):(e.addAttribute(`theme`,t.theme),t.tint!==void 0&&e.addAttribute(`tint`,t.tint)),e.closeNode(),!0):!1}parseOpen(e){return e.name===this.name?(e.attributes.rgb?this.model={argb:e.attributes.rgb}:e.attributes.theme?(this.model={theme:parseInt(e.attributes.theme,10)},e.attributes.tint&&(this.model.tint=parseFloat(e.attributes.tint))):e.attributes.indexed?this.model={indexed:parseInt(e.attributes.indexed,10)}:this.model=void 0,!0):!1}parseText(){}parseClose(){return!1}},Or=class extends j{constructor(e){super(),this.tag=e.tag,this.attr=e.attr}render(e,t){t&&(e.openNode(this.tag),e.closeNode())}parseOpen(e){e.name===this.tag&&(this.model=!0)}parseText(){}parseClose(){return!1}},kr=class extends j{constructor(e){super(),this.tag=e.tag,this.attr=e.attr,this.attrs=e.attrs,this.zero=e.zero,this.text=[]}render(e,t){(t||this.zero)&&(e.openNode(this.tag),this.attrs&&e.addAttributes(this.attrs),this.attr?e.addAttribute(this.attr,t):e.writeText(t),e.closeNode())}parseOpen(e){return e.name===this.tag?(this.attr?this.model=parseInt(e.attributes[this.attr],10):this.text=[],!0):!1}parseText(e){this.attr||this.text.push(e)}parseClose(){return this.attr||(this.model=parseInt(this.text.join(``)||`0`,10)),!1}},P=class extends j{constructor(e){super(),this.tag=e.tag,this.attr=e.attr,this.attrs=e.attrs,this.text=[]}render(e,t){t!==void 0&&(e.openNode(this.tag),this.attrs&&e.addAttributes(this.attrs),this.attr?e.addAttribute(this.attr,t):e.writeText(t),e.closeNode())}parseOpen(e){e.name===this.tag&&(this.attr?this.model=e.attributes[this.attr]:this.text=[])}parseText(e){this.attr||this.text.push(e)}parseClose(){return this.attr||(this.model=this.text.join(``)),!1}},Ar=class e extends j{static{this.Attributes={single:{},double:{val:`double`},singleAccounting:{val:`singleAccounting`},doubleAccounting:{val:`doubleAccounting`}}}constructor(e){super(),this.model=e}get tag(){return`u`}render(t,n){if(n||=this.model,n===!0)t.leafNode(`u`);else{let r=e.Attributes[n];r&&t.leafNode(`u`,r)}}parseOpen(e){e.name===`u`&&(this.model=e.attributes.val||!0)}parseText(){}parseClose(){return!1}},jr=class e extends j{constructor(t){super(),this.options=t||e.OPTIONS;let n=[{tag:`b`,prop:`bold`,xform:new Or({tag:`b`,attr:`val`})},{tag:`i`,prop:`italic`,xform:new Or({tag:`i`,attr:`val`})},{tag:`u`,prop:`underline`,xform:new Ar},{tag:`strike`,prop:`strike`,xform:new Or({tag:`strike`,attr:`val`})},{tag:`condense`,prop:`condense`,xform:new Or({tag:`condense`,attr:`val`})},{tag:`extend`,prop:`extend`,xform:new Or({tag:`extend`,attr:`val`})},{tag:`outline`,prop:`outline`,xform:new Or({tag:`outline`,attr:`val`})},{tag:`shadow`,prop:`shadow`,xform:new Or({tag:`shadow`,attr:`val`})},{tag:`sz`,prop:`size`,xform:new kr({tag:`sz`,attr:`val`})},{tag:`color`,prop:`color`,xform:new N},{tag:this.options.fontNameTag,prop:`name`,xform:new P({tag:this.options.fontNameTag,attr:`val`})},{tag:`family`,prop:`family`,xform:new kr({tag:`family`,attr:`val`})},{tag:`scheme`,prop:`scheme`,xform:new P({tag:`scheme`,attr:`val`})},{tag:`charset`,prop:`charset`,xform:new kr({tag:`charset`,attr:`val`})},{tag:`vertAlign`,prop:`vertAlign`,xform:new P({tag:`vertAlign`,attr:`val`})}];this.map=Object.fromEntries(n.map(e=>[e.tag,{prop:e.prop,xform:e.xform}])),this.renderOrder=n.map(e=>e.tag)}get tag(){return this.options.tagName}render(e,t){let{map:n,renderOrder:r}=this;e.openNode(this.options.tagName),r.forEach(r=>{n[r].xform.render(e,t[n[r].prop])}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;if(this.map[e.name])return this.parser=this.map[e.name].xform,this.parser.parseOpen(e);switch(e.name){case this.options.tagName:return this.model={},!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser&&!this.parser.parseClose(e)){let t=this.map[e];return this.parser.model&&(this.model[t.prop]=this.parser.model),this.parser=void 0,!0}switch(e){case this.options.tagName:return!1;default:return!0}}static{this.OPTIONS={tagName:`font`,fontNameTag:`name`}}},Mr=class extends j{constructor(){super(),this.map={color:new N}}get tag(){return`stop`}render(e,t){e.openNode(`stop`),e.addAttribute(`position`,t.position),this.map.color.render(e,t.color),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`stop`:return this.model={position:parseFloat(e.attributes.position)},!0;case`color`:return this.parser=this.map.color,this.parser.parseOpen(e),!0;default:return!1}}parseText(){}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.model.color=this.parser.model,this.parser=void 0),!0):!1}},Nr=class extends j{constructor(){super(),this.map={fgColor:new N(`fgColor`),bgColor:new N(`bgColor`)}}get name(){return`pattern`}get tag(){return`patternFill`}render(e,t){e.openNode(`patternFill`),e.addAttribute(`patternType`,t.pattern),t.fgColor&&this.map.fgColor.render(e,t.fgColor),t.bgColor&&this.map.bgColor.render(e,t.bgColor),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`patternFill`:return this.model={type:`pattern`,pattern:e.attributes.patternType},!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser.model&&(this.model[e]=this.parser.model),this.parser=void 0),!0):!1}},Pr=class extends j{constructor(){super(),this.map={stop:new Mr}}get name(){return`gradient`}get tag(){return`gradientFill`}render(e,t){switch(e.openNode(`gradientFill`),t.gradient){case`angle`:e.addAttribute(`degree`,t.degree);break;case`path`:e.addAttribute(`type`,`path`),t.center.left&&(e.addAttribute(`left`,t.center.left),t.center.right===void 0&&e.addAttribute(`right`,t.center.left)),t.center.right&&e.addAttribute(`right`,t.center.right),t.center.top&&(e.addAttribute(`top`,t.center.top),t.center.bottom===void 0&&e.addAttribute(`bottom`,t.center.top)),t.center.bottom&&e.addAttribute(`bottom`,t.center.bottom);break;default:break}let n=this.map.stop;t.stops.forEach(t=>{n.render(e,t)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`gradientFill`:{let t=this.model={stops:[]};return e.attributes.degree?(t.gradient=`angle`,t.degree=parseInt(e.attributes.degree,10)):e.attributes.type===`path`&&(t.gradient=`path`,t.center={left:e.attributes.left?parseFloat(e.attributes.left):0,top:e.attributes.top?parseFloat(e.attributes.top):0},e.attributes.right!==e.attributes.left&&(t.center.right=e.attributes.right?parseFloat(e.attributes.right):0),e.attributes.bottom!==e.attributes.top&&(t.center.bottom=e.attributes.bottom?parseFloat(e.attributes.bottom):0)),!0}case`stop`:return this.parser=this.map.stop,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.model.stops.push(this.parser.model),this.parser=void 0),!0):!1}},Fr=class e extends j{constructor(){super(),this.map={patternFill:new Nr,gradientFill:new Pr}}get tag(){return`fill`}render(e,t){switch(e.addRollback(),e.openNode(`fill`),t.type){case`pattern`:this.map.patternFill.render(e,t);break;case`gradient`:this.map.gradientFill.render(e,t);break;default:e.rollback();return}e.closeNode(),e.commit()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`fill`:return this.model={},!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.model=this.parser.model,this.model.type=this.parser.name,this.parser=void 0),!0):!1}validStyle(t){return e.validPatternValues[t]}static{this.validPatternValues=[`none`,`solid`,`darkVertical`,`darkGray`,`mediumGray`,`lightGray`,`gray125`,`gray0625`,`darkHorizontal`,`darkVertical`,`darkDown`,`darkUp`,`darkGrid`,`darkTrellis`,`lightHorizontal`,`lightVertical`,`lightDown`,`lightUp`,`lightGrid`,`lightTrellis`,`lightGrid`].reduce((e,t)=>(e[t]=!0,e),{})}static{this.StopXform=Mr}static{this.PatternFillXform=Nr}static{this.GradientFillXform=Pr}},Ir=class e extends j{constructor(e){super(),this.name=e,this.map={color:new N}}get tag(){return this.name}render(e,t,n){let r=t&&t.color||n||this.defaultColor;e.openNode(this.name),t&&t.style&&(e.addAttribute(`style`,t.style),r&&this.map.color.render(e,r)),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.name:{let{style:t}=e.attributes;return t?this.model={style:t}:this.model=void 0,!0}case`color`:return this.parser=this.map.color,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser=void 0),!0):(e===this.name&&this.map.color.model&&(this.model||={},this.model.color=this.map.color.model),!1)}validStyle(t){return e.validStyleValues[t]}static{this.validStyleValues=[`thin`,`dashed`,`dotted`,`dashDot`,`hair`,`dashDotDot`,`slantDashDot`,`mediumDashed`,`mediumDashDotDot`,`mediumDashDot`,`medium`,`double`,`thick`].reduce((e,t)=>(e[t]=!0,e),{})}},Lr=class extends j{constructor(){super(),this.map={top:new Ir(`top`),left:new Ir(`left`),bottom:new Ir(`bottom`),right:new Ir(`right`),diagonal:new Ir(`diagonal`)}}render(e,t){let{color:n}=t;e.openNode(`border`),t.diagonal&&t.diagonal.style&&(t.diagonal.up&&e.addAttribute(`diagonalUp`,`1`),t.diagonal.down&&e.addAttribute(`diagonalDown`,`1`));let r=(r,i)=>{let a=r;a&&!a.color&&t.color&&(a={...a,color:t.color}),i.render(e,a,n)};r(t.left,this.map.left),r(t.right,this.map.right),r(t.top,this.map.top),r(t.bottom,this.map.bottom),r(t.diagonal,this.map.diagonal),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`border`:return this.reset(),this.diagonalUp=Dt(e.attributes.diagonalUp),this.diagonalDown=Dt(e.attributes.diagonalDown),!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;if(e===`border`){let e=this.model={},t=(t,n,r)=>{n&&(r&&Object.assign(n,r),e[t]=n)};t(`left`,this.map.left.model),t(`right`,this.map.right.model),t(`top`,this.map.top.model),t(`bottom`,this.map.bottom.model),t(`diagonal`,this.map.diagonal.model,{up:this.diagonalUp,down:this.diagonalDown})}return!1}};let Rr={0:{f:`General`},1:{f:`0`},2:{f:`0.00`},3:{f:`#,##0`},4:{f:`#,##0.00`},9:{f:`0%`},10:{f:`0.00%`},11:{f:`0.00E+00`},12:{f:`# ?/?`},13:{f:`# ??/??`},14:{f:`mm-dd-yy`},15:{f:`d-mmm-yy`},16:{f:`d-mmm`},17:{f:`mmm-yy`},18:{f:`h:mm AM/PM`},19:{f:`h:mm:ss AM/PM`},20:{f:`h:mm`},21:{f:`h:mm:ss`},22:{f:`m/d/yy "h":mm`},27:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},28:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},29:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},30:{"zh-tw":`m/d/yy `,"zh-cn":`m-d-yy`,"ja-jp":`m/d/yy`,"ko-kr":`mm-dd-yy`},31:{"zh-tw":`yyyy"年"m"月"d"日"`,"zh-cn":`yyyy"年"m"月"d"日"`,"ja-jp":`yyyy"年"m"月"d"日"`,"ko-kr":`yyyy"년" mm"월" dd"일"`},32:{"zh-tw":`hh"時"mm"分"`,"zh-cn":`h"时"mm"分"`,"ja-jp":`h"時"mm"分"`,"ko-kr":`h"시" mm"분"`},33:{"zh-tw":`hh"時"mm"分"ss"秒"`,"zh-cn":`h"时"mm"分"ss"秒"`,"ja-jp":`h"時"mm"分"ss"秒"`,"ko-kr":`h"시" mm"분" ss"초"`},34:{"zh-tw":`上午/下午 hh"時"mm"分"`,"zh-cn":`上午/下午 h"时"mm"分"`,"ja-jp":`yyyy"年"m"月"`,"ko-kr":`yyyy-mm-dd`},35:{"zh-tw":`上午/下午 hh"時"mm"分"ss"秒"`,"zh-cn":`上午/下午 h"时"mm"分"ss"秒"`,"ja-jp":`m"月"d"日"`,"ko-kr":`yyyy-mm-dd`},36:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},37:{f:`#,##0 ;(#,##0)`},38:{f:`#,##0 ;[Red](#,##0)`},39:{f:`#,##0.00 ;(#,##0.00)`},40:{f:`#,##0.00 ;[Red](#,##0.00)`},45:{f:`mm:ss`},46:{f:`[h]:mm:ss`},47:{f:`mmss.0`},48:{f:`##0.0E+0`},49:{f:`@`},50:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},51:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},52:{"zh-tw":`上午/下午 hh"時"mm"分"`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`yyyy"年"m"月"`,"ko-kr":`yyyy-mm-dd`},53:{"zh-tw":`上午/下午 hh"時"mm"分"ss"秒"`,"zh-cn":`m"月"d"日"`,"ja-jp":`m"月"d"日"`,"ko-kr":`yyyy-mm-dd`},54:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},55:{"zh-tw":`上午/下午 hh"時"mm"分"`,"zh-cn":`上午/下午 h"时"mm"分"`,"ja-jp":`yyyy"年"m"月"`,"ko-kr":`yyyy-mm-dd`},56:{"zh-tw":`上午/下午 hh"時"mm"分"ss"秒"`,"zh-cn":`上午/下午 h"时"mm"分"ss"秒"`,"ja-jp":`m"月"d"日"`,"ko-kr":`yyyy-mm-dd`},57:{"zh-tw":`[$-404]e/m/d`,"zh-cn":`yyyy"年"m"月"`,"ja-jp":`[$-411]ge.m.d`,"ko-kr":`yyyy"年" mm"月" dd"日"`},58:{"zh-tw":`[$-404]e"年"m"月"d"日"`,"zh-cn":`m"月"d"日"`,"ja-jp":`[$-411]ggge"年"m"月"d"日"`,"ko-kr":`mm-dd`},59:{"th-th":`t0`},60:{"th-th":`t0.00`},61:{"th-th":`t#,##0`},62:{"th-th":`t#,##0.00`},67:{"th-th":`t0%`},68:{"th-th":`t0.00%`},69:{"th-th":`t# ?/?`},70:{"th-th":`t# ??/??`},81:{"th-th":`d/m/bb`}};function zr(){let e={};return Object.entries(Rr).forEach(([t,n])=>{n.f&&(e[n.f]=parseInt(t,10))}),e}let Br=null;function Vr(){return Br||=zr(),Br}var Hr=class extends j{constructor(e,t){super(),this.id=e,this.formatCode=t}get tag(){return`numFmt`}render(e,t){e.leafNode(`numFmt`,{numFmtId:t.id,formatCode:t.formatCode})}parseOpen(e){switch(e.name){case`numFmt`:return this.model={id:parseInt(e.attributes.numFmtId,10),formatCode:e.attributes.formatCode.replace(/[\\](.)/g,`$1`)},!0;default:return!1}}parseText(){}parseClose(){return!1}static getDefaultFmtId(e){return Vr()[e]}static getDefaultFmtCode(e){return Rr[e]&&Rr[e].f}};let Ur={ReadingOrder:{LeftToRight:1,RightToLeft:2}},Wr={horizontalValues:[`left`,`center`,`right`,`fill`,`centerContinuous`,`distributed`,`justify`].reduce((e,t)=>(e[t]=!0,e),{}),horizontal(e){return this.horizontalValues[e]?e:void 0},verticalValues:[`top`,`middle`,`bottom`,`distributed`,`justify`].reduce((e,t)=>(e[t]=!0,e),{}),vertical(e){return e===`middle`?`center`:this.verticalValues[e]?e:void 0},wrapText(e){return e?!0:void 0},shrinkToFit(e){return e?!0:void 0},textRotation(e){switch(e){case`vertical`:return e;default:{let t=St(e);return t!==void 0&&t>=-90&&t<=90?t:void 0}}},indent(e){let t=St(e);return Math.max(0,t)},readingOrder(e){switch(e){case`ltr`:return Ur.ReadingOrder.LeftToRight;case`rtl`:return Ur.ReadingOrder.RightToLeft;default:return}}},Gr={toXml(e){let t=Wr.textRotation(e);if(t){if(t===`vertical`)return 255;let e=Math.round(t);if(e>=0&&e<=90)return e;if(e<0&&e>=-90)return 90-e}},toModel(e){let t=St(e);if(t!==void 0){if(t===255)return`vertical`;if(t>=0&&t<=90)return t;if(t>90&&t<=180)return 90-t}}};var Kr=class extends j{get tag(){return`alignment`}render(e,t){e.addRollback(),e.openNode(`alignment`);let n=!1;function r(t,r){r&&(e.addAttribute(t,r),n=!0)}r(`horizontal`,Wr.horizontal(t.horizontal)),r(`vertical`,Wr.vertical(t.vertical)),r(`wrapText`,Wr.wrapText(t.wrapText)?`1`:!1),r(`shrinkToFit`,Wr.shrinkToFit(t.shrinkToFit)?`1`:!1),r(`indent`,Wr.indent(t.indent)),r(`textRotation`,Gr.toXml(t.textRotation)),r(`readingOrder`,Wr.readingOrder(t.readingOrder)),e.closeNode(),n?e.commit():e.rollback()}parseOpen(e){let t={},n=!1;function r(e,r,i){e&&(t[r]=i,n=!0)}r(e.attributes.horizontal,`horizontal`,e.attributes.horizontal),r(e.attributes.vertical,`vertical`,e.attributes.vertical===`center`?`middle`:e.attributes.vertical),r(e.attributes.wrapText,`wrapText`,Dt(e.attributes.wrapText)),r(e.attributes.shrinkToFit,`shrinkToFit`,Dt(e.attributes.shrinkToFit)),r(e.attributes.indent,`indent`,parseInt(e.attributes.indent,10)),r(e.attributes.textRotation,`textRotation`,Gr.toModel(e.attributes.textRotation)),r(e.attributes.readingOrder,`readingOrder`,e.attributes.readingOrder===`2`?`rtl`:`ltr`),this.model=n?t:null}parseText(){}parseClose(){return!1}};let qr={boolean(e,t){return e===void 0?t:e}};var Jr=class extends j{get tag(){return`protection`}render(e,t){e.addRollback(),e.openNode(`protection`);let n=!1;function r(t,r){r!==void 0&&(e.addAttribute(t,r),n=!0)}r(`locked`,qr.boolean(t.locked,!0)?void 0:`0`),r(`hidden`,qr.boolean(t.hidden,!1)?`1`:void 0),e.closeNode(),n?e.commit():e.rollback()}parseOpen(e){let t={locked:e.attributes.locked!==`0`,hidden:e.attributes.hidden===`1`};this.model=!t.locked||t.hidden?t:null}parseText(){}parseClose(){return!1}},Yr=class extends j{constructor(e){super(),this.xfId=!!(e&&e.xfId),this.map={alignment:new Kr,protection:new Jr}}get tag(){return`xf`}render(e,t){e.openNode(`xf`,{numFmtId:t.numFmtId??0,fontId:t.fontId??0,fillId:t.fillId??0,borderId:t.borderId??0}),this.xfId&&e.addAttribute(`xfId`,t.xfId??0),(t.applyNumberFormat||t.numFmtId)&&e.addAttribute(`applyNumberFormat`,`1`),(t.applyFont||t.fontId)&&e.addAttribute(`applyFont`,`1`),(t.applyFill||t.fillId)&&e.addAttribute(`applyFill`,`1`),(t.applyBorder||t.borderId)&&e.addAttribute(`applyBorder`,`1`),(t.applyAlignment||t.alignment)&&e.addAttribute(`applyAlignment`,`1`),(t.applyProtection||t.protection)&&e.addAttribute(`applyProtection`,`1`),t.pivotButton&&e.addAttribute(`pivotButton`,`1`),t.alignment&&this.map.alignment.render(e,t.alignment),t.protection&&this.map.protection.render(e,t.protection),t.checkbox&&t.xfComplementIndex!==void 0&&(e.openNode(`extLst`),e.openNode(`ext`,{"xmlns:xfpb":`http://schemas.microsoft.com/office/spreadsheetml/2022/featurepropertybag`,uri:`{C7286773-470A-42A8-94C5-96B5CB345126}`}),e.leafNode(`xfpb:xfComplement`,{i:t.xfComplementIndex}),e.closeNode(),e.closeNode()),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`xf`:this.model={numFmtId:parseInt(e.attributes.numFmtId,10),fontId:parseInt(e.attributes.fontId,10),fillId:parseInt(e.attributes.fillId,10),borderId:parseInt(e.attributes.borderId,10)},this.xfId&&(this.model.xfId=parseInt(e.attributes.xfId,10)),e.attributes.pivotButton===`1`&&(this.model.pivotButton=!0);for(let t of[`applyNumberFormat`,`applyFont`,`applyFill`,`applyBorder`,`applyAlignment`,`applyProtection`])e.attributes[t]===`1`&&(this.model[t]=!0);return!0;case`alignment`:return this.parser=this.map.alignment,this.parser.parseOpen(e),!0;case`protection`:return this.parser=this.map.protection,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.map.protection===this.parser?this.model.protection=this.parser.model:this.model.alignment=this.parser.model,this.parser=void 0),!0):e!==`xf`}},Xr=class extends j{constructor(){super(),this.map={alignment:new Kr,border:new Lr,fill:new Fr,font:new jr,numFmt:new Hr,protection:new Jr}}get tag(){return`dxf`}render(e,t){if(e.openNode(this.tag),t.font&&this.map.font.render(e,t.font),t.numFmt&&t.numFmtId){let n={id:t.numFmtId,formatCode:t.numFmt};this.map.numFmt.render(e,n)}t.fill&&this.map.fill.render(e,t.fill),t.alignment&&this.map.alignment.render(e,t.alignment),t.border&&this.map.border.render(e,t.border),t.protection&&this.map.protection.render(e,t.protection),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:return this.reset(),!0;default:return this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e),!0}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser=void 0),!0):e===this.tag?(this.model={alignment:this.map.alignment.model,border:this.map.border.model,fill:this.map.fill.model,font:this.map.font.model,numFmt:this.map.numFmt.model,protection:this.map.protection.model},!1):!0}},Zr=class e extends j{constructor(t){super(),this.map={numFmts:new M({tag:`numFmts`,count:!0,childXform:new Hr}),fonts:new M({tag:`fonts`,count:!0,childXform:new jr,$:{"x14ac:knownFonts":1}}),fills:new M({tag:`fills`,count:!0,childXform:new Fr}),borders:new M({tag:`borders`,count:!0,childXform:new Lr}),cellStyleXfs:new M({tag:`cellStyleXfs`,count:!0,childXform:new Yr}),cellXfs:new M({tag:`cellXfs`,count:!0,childXform:new Yr({xfId:!0})}),dxfs:new M({tag:`dxfs`,always:!0,count:!0,childXform:new Xr}),numFmt:new Hr,font:new jr,fill:new Fr,border:new Lr,style:new Yr({xfId:!0}),cellStyles:e.STATIC_XFORMS.cellStyles,tableStyles:e.STATIC_XFORMS.tableStyles,extLst:e.STATIC_XFORMS.extLst},t&&this.init()}initIndex(){this.index={style:{},numFmt:{},numFmtNextId:164,font:{},border:{},fill:{}}}init(){this.model={styles:[],numFmts:[],fonts:[],borders:[],fills:[],dxfs:[]},this.initIndex(),this._addBorder({}),this._addStyle({numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}),this._addFill({type:`pattern`,pattern:`none`}),this._addFill({type:`pattern`,pattern:`gray125`}),this.weakMap=new WeakMap,this._hasCheckboxes=!1}setDefaultFont(e){this.defaultFont=e}render(t,n){let r=n||this.model;t.openXml(k.StdDocAttributes),t.openNode(`styleSheet`,e.STYLESHEET_ATTRIBUTES),this.index?(r.numFmts&&r.numFmts.length&&(t.openNode(`numFmts`,{count:r.numFmts.length}),r.numFmts.forEach(e=>{t.writeXml(e)}),t.closeNode()),r.fonts.length||this._addFont(this.defaultFont||{size:11,color:{theme:1},name:`Calibri`,family:2,scheme:`minor`}),t.openNode(`fonts`,{count:r.fonts.length,"x14ac:knownFonts":1}),r.fonts.forEach(e=>{t.writeXml(e)}),t.closeNode(),t.openNode(`fills`,{count:r.fills.length}),r.fills.forEach(e=>{t.writeXml(e)}),t.closeNode(),t.openNode(`borders`,{count:r.borders.length}),r.borders.forEach(e=>{t.writeXml(e)}),t.closeNode(),this.map.cellStyleXfs.render(t,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),t.openNode(`cellXfs`,{count:r.styles.length}),r.styles.forEach(e=>{t.writeXml(e)}),t.closeNode()):(this.map.numFmts.render(t,r.numFmts),this.map.fonts.render(t,r.fonts),this.map.fills.render(t,r.fills),this.map.borders.render(t,r.borders),this.map.cellStyleXfs.render(t,[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}]),this.map.cellXfs.render(t,r.styles)),e.STATIC_XFORMS.cellStyles.render(t),this.map.dxfs.render(t,r.dxfs),e.STATIC_XFORMS.tableStyles.render(t),e.STATIC_XFORMS.extLst.render(t),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`styleSheet`:return this.initIndex(),!0;default:return this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e),!0}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`styleSheet`:{this.model={};let e=(e,t)=>{t.model&&t.model.length&&(this.model[e]=t.model)};if(e(`numFmts`,this.map.numFmts),e(`fonts`,this.map.fonts),e(`fills`,this.map.fills),e(`borders`,this.map.borders),e(`styles`,this.map.cellXfs),e(`dxfs`,this.map.dxfs),this.map.fonts.model&&this.map.fonts.model.length>0&&(this.defaultFont=this.map.fonts.model[0]),this.index={model:[],numFmt:{}},this.model.numFmts){let e=this.index.numFmt;this.model.numFmts.forEach(t=>{e[t.id]=t.formatCode})}return!1}default:return!0}}addStyleModel(e,t){if(!e)return 0;this.model.fonts.length||this._addFont(this.defaultFont||{size:11,color:{theme:1},name:`Calibri`,family:2,scheme:`minor`});let n=t||T.ValueType.Number;if(n!==T.ValueType.Checkbox&&this.weakMap&&this.weakMap.has(e))return this.weakMap.get(e);let r={};if(e.numFmt)r.numFmtId=this._addNumFmtStr(e.numFmt);else switch(n){case T.ValueType.Number:r.numFmtId=this._addNumFmtStr(`General`);break;case T.ValueType.Date:r.numFmtId=this._addNumFmtStr(`mm-dd-yy`);break;default:break}e.font&&(r.fontId=this._addFont(e.font)),e.border&&(r.borderId=this._addBorder(e.border)),e.fill&&(r.fillId=this._addFill(e.fill)),e.alignment&&(r.alignment=e.alignment),e.protection&&(r.protection=e.protection);for(let t of[`pivotButton`,`applyNumberFormat`,`applyFont`,`applyFill`,`applyBorder`,`applyAlignment`,`applyProtection`])e[t]&&(r[t]=!0);n===T.ValueType.Checkbox&&(this._hasCheckboxes=!0,r.alignment=r.alignment||{},r.checkbox=!0,r.xfComplementIndex=0);let i=this._addStyle(r);return n!==T.ValueType.Checkbox&&this.weakMap&&this.weakMap.set(e,i),i}getStyleModel(e){let t=this.model.styles[e];if(!t)return null;let n=this.index.model[e];if(n)return n;if(n=this.index.model[e]={},t.numFmtId){let e=this.index.numFmt[t.numFmtId]||Hr.getDefaultFmtCode(t.numFmtId);e&&(n.numFmt=e)}function r(e,t,r){if(r||r===0){let i=t[r];i&&(n[e]=i)}}r(`font`,this.model.fonts,t.fontId),r(`border`,this.model.borders,t.borderId),r(`fill`,this.model.fills,t.fillId),t.alignment&&(n.alignment=t.alignment),t.protection&&(n.protection=t.protection);for(let e of[`pivotButton`,`applyNumberFormat`,`applyFont`,`applyFill`,`applyBorder`,`applyAlignment`,`applyProtection`])t[e]&&(n[e]=!0);return n}addDxfStyle(e){return e.numFmt&&(e.numFmtId=this._addNumFmtStr(e.numFmt)),this.model.dxfs.push(e),this.model.dxfs.length-1}getDxfStyle(e){return this.model.dxfs[e]}get hasCheckboxes(){return!!this._hasCheckboxes}_addStyle(e){let t=this.map.style.toXml(e),n=this.index.style[t];return n===void 0&&(n=this.index.style[t]=this.model.styles.length,this.model.styles.push(t)),n}_addNumFmtStr(e){let t=Hr.getDefaultFmtId(e);if(t!==void 0||(t=this.index.numFmt[e],t!==void 0))return t;t=this.index.numFmt[e]=164+this.model.numFmts.length;let n=this.map.numFmt.toXml({id:t,formatCode:e});return this.model.numFmts.push(n),t}_addFont(e){let t=this.map.font.toXml(e),n=this.index.font[t];return n===void 0&&(n=this.index.font[t]=this.model.fonts.length,this.model.fonts.push(t)),n}_addBorder(e){let t=this.map.border.toXml(e),n=this.index.border[t];return n===void 0&&(n=this.index.border[t]=this.model.borders.length,this.model.borders.push(t)),n}_addFill(e){let t=this.map.fill.toXml(e),n=this.index.fill[t];return n===void 0&&(n=this.index.fill[t]=this.model.fills.length,this.model.fills.push(t)),n}static{this.STYLESHEET_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`,"mc:Ignorable":`x14ac x16r2`,"xmlns:x14ac":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac`,"xmlns:x16r2":`http://schemas.microsoft.com/office/spreadsheetml/2015/02/main`}}static{this.STATIC_XFORMS={cellStyles:new Dr({tag:`cellStyles`,$:{count:1},c:[{tag:`cellStyle`,$:{name:`Normal`,xfId:0,builtinId:0}}]}),dxfs:new Dr({tag:`dxfs`,$:{count:0}}),tableStyles:new Dr({tag:`tableStyles`,$:{count:0,defaultTableStyle:`TableStyleMedium2`,defaultPivotStyle:`PivotStyleLight16`}}),extLst:new Dr({tag:`extLst`,c:[{tag:`ext`,$:{uri:`{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}`,"xmlns:x14":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`},c:[{tag:`x14:slicerStyles`,$:{defaultSlicerStyle:`SlicerStyleLight1`}}]},{tag:`ext`,$:{uri:`{9260A510-F301-46a8-8635-F512D64BE5F5}`,"xmlns:x15":`http://schemas.microsoft.com/office/spreadsheetml/2010/11/main`},c:[{tag:`x15:timelineStyles`,$:{defaultTimelineStyle:`TimeSlicerStyleLight1`}}]}]})}}};Zr.Mock=class extends Zr{constructor(){super(),this.model={styles:[{numFmtId:0,fontId:0,fillId:0,borderId:0,xfId:0}],numFmts:[],fonts:[{size:11,color:{theme:1},name:`Calibri`,family:2,scheme:`minor`}],borders:[{}],fills:[{type:`pattern`,pattern:`none`},{type:`pattern`,pattern:`gray125`}]}}parseStream(e){return e.autodrain(),Promise.resolve()}addStyleModel(e,t){switch(t){case T.ValueType.Checkbox:throw new v(`Checkbox cells`,`require styles to be enabled (useStyles: true)`);case T.ValueType.Date:return this.dateStyleId;default:return 0}}get hasCheckboxes(){return!1}get dateStyleId(){if(!this._dateStyleId){let e={numFmtId:Hr.getDefaultFmtId(`mm-dd-yy`)};this._dateStyleId=this.model.styles.length,this.model.styles.push(e)}return this._dateStyleId}getStyleModel(){return{}}};var Qr=class extends j{constructor(e){super(),this.tag=e.tag,this.attr=e.attr,this.attrs=e.attrs,this.text=[],this._format=e.format||function(e){try{return Number.isNaN(e.getTime())?``:e.toISOString()}catch{return``}},this._parse=e.parse||function(e){return new Date(e)}}render(e,t){t&&(e.openNode(this.tag),this.attrs&&e.addAttributes(this.attrs),this.attr?e.addAttribute(this.attr,this._format(t)):e.writeText(this._format(t)),e.closeNode())}parseOpen(e){e.name===this.tag&&(this.attr?this.model=this._parse(e.attributes[this.attr]):this.text=[])}parseText(e){this.attr||this.text.push(e)}parseClose(){return this.attr||(this.model=this._parse(this.text.join(``))),!1}};let F={creator:`dc:creator`,title:`dc:title`,subject:`dc:subject`,description:`dc:description`,identifier:`dc:identifier`,language:`dc:language`,keywords:`cp:keywords`,category:`cp:category`,lastModifiedBy:`cp:lastModifiedBy`,lastPrinted:`cp:lastPrinted`,revision:`cp:revision`,version:`cp:version`,contentStatus:`cp:contentStatus`,contentType:`cp:contentType`,created:`dcterms:created`,modified:`dcterms:modified`};var $r=class e extends j{constructor(){super(),this.map={creator:new P({tag:F.creator}),title:new P({tag:F.title}),subject:new P({tag:F.subject}),description:new P({tag:F.description}),identifier:new P({tag:F.identifier}),language:new P({tag:F.language}),keywords:new P({tag:F.keywords}),category:new P({tag:F.category}),lastModifiedBy:new P({tag:F.lastModifiedBy}),lastPrinted:new Qr({tag:F.lastPrinted,format:e.DateFormat}),revision:new kr({tag:F.revision}),version:new P({tag:F.version}),contentStatus:new P({tag:F.contentStatus}),contentType:new P({tag:F.contentType}),created:new Qr({tag:F.created,attrs:e.DateAttrs,format:e.DateFormat}),modified:new Qr({tag:F.modified,attrs:e.DateAttrs,format:e.DateFormat})}}render(t,n){t.openXml(k.StdDocAttributes),t.openNode(`cp:coreProperties`,e.CORE_PROPERTY_ATTRIBUTES);for(let e of Object.keys(F))this.map[e].render(t,n[e]);t.closeNode()}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):(e.name!==`coreProperties`&&(this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e)),!0)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;if(e===`coreProperties`){this.model={};for(let e of Object.keys(F)){let t=this.map[e].model;t!==void 0&&t!==``&&(this.model[e]=t)}return!1}return!0}static{this.DateFormat=function(e){return e.toISOString().replace(/[.]\d{3}/,``)}}static{this.DateAttrs={"xsi:type":`dcterms:W3CDTF`}}static{this.CORE_PROPERTY_ATTRIBUTES={"xmlns:cp":`http://schemas.openxmlformats.org/package/2006/metadata/core-properties`,"xmlns:dc":`http://purl.org/dc/elements/1.1/`,"xmlns:dcterms":`http://purl.org/dc/terms/`,"xmlns:dcmitype":`http://purl.org/dc/dcmitype/`,"xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`}}},ei=class extends j{get tag(){return`t`}render(e,t){e.openNode(`t`),/^\s|\n|\s$/.test(t)&&e.addAttribute(`xml:space`,`preserve`),e.writeText(ht(t)),e.closeNode()}parseOpen(e){return e.name===`t`?(this._text=[],this.model=``,!0):!1}parseText(e){this._text.push(e),this.model=mt(this._text.join(``))}parseClose(){return!1}},ti=class e extends j{constructor(e){super(),this.model=e}get tag(){return`r`}get textXform(){return this._textXform||=new ei}get fontXform(){return this._fontXform||=new jr(e.FONT_OPTIONS)}render(e,t){let n=t||this.model;e.openNode(`r`),n.font&&this.fontXform.render(e,n.font),this.textXform.render(e,n.text),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`r`:return this.model={},!0;case`t`:return this.parser=this.textXform,this.parser.parseOpen(e),!0;case`rPr`:return this.parser=this.fontXform,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){switch(e){case`r`:return!1;case`t`:return this.model.text=this.parser.model,this.parser=void 0,!0;case`rPr`:return this.model.font=this.parser.model,this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(e),!0}}static{this.FONT_OPTIONS={tagName:`rPr`,fontNameTag:`rFont`}}},ni=class extends j{constructor(){super(),this.map={r:new ti,t:new ei}}get tag(){return`rPh`}render(e,t){if(e.openNode(this.tag,{sb:t.sb??0,eb:t.eb??0}),t&&Object.prototype.hasOwnProperty.call(t,`richText`)&&t.richText){let{r:n}=this.map;t.richText.forEach(t=>{n.render(e,t)})}else t&&this.map.t.render(e,t.text);e.closeNode()}parseOpen(e){let{name:t}=e;return this.parser?(this.parser.parseOpen(e),!0):t===this.tag?(this.model={sb:parseInt(e.attributes.sb,10),eb:parseInt(e.attributes.eb,10)},!0):(this.parser=this.map[t],this.parser?(this.parser.parseOpen(e),!0):!1)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)){switch(e){case`r`:{let e=this.model.richText;e||=this.model.richText=[],e.push(this.parser.model);break}case`t`:this.model.text=this.parser.model;break;default:break}this.parser=void 0}return!0}switch(e){case this.tag:return!1;default:return!0}}},ri=class extends j{constructor(e){super(),this.model=e,this.map={r:new ti,t:new ei,rPh:new ni}}get tag(){return`si`}render(e,t){e.openNode(this.tag),t&&typeof t==`object`&&Object.prototype.hasOwnProperty.call(t,`richText`)&&t.richText?t.richText.length?t.richText.forEach(t=>{this.map.r.render(e,t)}):this.map.t.render(e,``):t!=null&&this.map.t.render(e,t),e.closeNode()}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.model={},!0):(this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)){switch(e){case`r`:{let e=this.model.richText;e||=this.model.richText=[],e.push(this.parser.model);break}case`t`:this.model=this.parser.model;break;default:break}this.parser=void 0}return!0}switch(e){case this.tag:return!1;default:return!0}}},ii=class extends j{constructor(e){super(),this.model=e||{values:[],count:0},this.hash=Object.create(null),this.rich=Object.create(null)}get sharedStringXform(){return this._sharedStringXform||=new ri}get values(){return this.model.values}get uniqueCount(){return this.model.values.length}get count(){return this.model.count}getString(e){return this.model.values[e]}add(e){return e.richText?this.addRichText(e):this.addText(e)}addText(e){let t=this.hash[e];return t===void 0&&(t=this.hash[e]=this.model.values.length,this.model.values.push(e)),this.model.count++,t}addRichText(e){let t=this.sharedStringXform.toXml(e),n=this.rich[t];return n===void 0&&(n=this.rich[t]=this.model.values.length,this.model.values.push(e)),this.model.count++,n}render(e,t){let n=t||this._values;e.openXml(k.StdDocAttributes),e.openNode(`sst`,{xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,count:n.count,uniqueCount:n.values.length});let r=this.sharedStringXform;n.values.forEach(t=>{r.render(e,t)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`sst`:return!0;case`si`:return this.parser=this.sharedStringXform,this.parser.parseOpen(e),!0;default:throw new _(`sharedStrings`,`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.values.push(this.parser.model),this.model.count++,this.parser=void 0),!0;switch(e){case`sst`:return!1;default:throw new _(`sharedStrings`,`Unexpected xml node in parseClose: ${e}`)}}},ai=class extends j{render(e,t){e.leafNode(`Relationship`,t)}parseOpen(e){switch(e.name){case`Relationship`:return this.model=e.attributes,!0;default:return!1}}parseText(){}parseClose(){return!1}},I=class e extends j{constructor(){super(),this.map={Relationship:new ai}}render(t,n){let r=n||this._values;t.openXml(k.StdDocAttributes),t.openNode(`Relationships`,e.RELATIONSHIPS_ATTRIBUTES),r.forEach(e=>{this.map.Relationship.render(t,e)}),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`Relationships`:return this.model=[],!0;default:if(this.parser=this.map[e.name],this.parser)return this.parser.parseOpen(e),!0;throw new _(`Relationships`,`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.push(this.parser.model),this.parser=void 0),!0;switch(e){case`Relationships`:return!1;default:throw new _(`Relationships`,`Unexpected xml node in parseClose: ${e}`)}}static{this.RELATIONSHIPS_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/package/2006/relationships`}}};let L={contentTypes:`[Content_Types].xml`,rootRels:`_rels/.rels`,docPropsApp:`docProps/app.xml`,docPropsCore:`docProps/core.xml`,xlWorkbook:`xl/workbook.xml`,xlWorkbookRels:`xl/_rels/workbook.xml.rels`,xlSharedStrings:`xl/sharedStrings.xml`,xlStyles:`xl/styles.xml`,xlTheme1:`xl/theme/theme1.xml`,xlFeaturePropertyBag:`xl/featurePropertyBag/featurePropertyBag.xml`},oi=/^xl\/worksheets\/sheet(\d+)[.]xml$/,si=/^xl\/worksheets\/_rels\/sheet(\d+)[.]xml[.]rels$/,ci=/^xl\/theme\/[a-zA-Z0-9]+[.]xml$/,li=/^xl\/media\/([a-zA-Z0-9]+[.][a-zA-Z0-9]{3,4})$/,ui=/^xl\/drawings\/(drawing\d+)[.]xml$/,di=/^xl\/drawings\/_rels\/(drawing\d+)[.]xml[.]rels$/,fi=/^xl\/drawings\/(vmlDrawing\d+)[.]vml$/,pi=/^xl\/comments(\d+)[.]xml$/,mi=/^xl\/tables\/(table\d+)[.]xml$/,hi=/^xl\/pivotTables\/(pivotTable\d+)[.]xml$/,gi=/^xl\/pivotTables\/_rels\/(pivotTable\d+)[.]xml[.]rels$/,_i=/^xl\/pivotCache\/(pivotCacheDefinition\d+)[.]xml$/,vi=/^xl\/pivotCache\/_rels\/(pivotCacheDefinition\d+)[.]xml[.]rels$/,yi=/^xl\/pivotCache\/(pivotCacheRecords\d+)[.]xml$/;function bi(e){return e.startsWith(`/`)?e.slice(1):e}function xi(e){let t=oi.exec(e);if(t)return parseInt(t[1],10)}function Si(e){let t=si.exec(e);if(t)return parseInt(t[1],10)}function Ci(e){return e.startsWith(`xl/media/`)}function wi(e){let t=li.exec(e);return t?t[1]:void 0}function Ti(e){return ci.test(e)}function Ei(e){let t=/^xl\/theme\/([a-zA-Z0-9]+)[.]xml$/.exec(e);return t?t[1]:void 0}function Di(e){return Ci(e)||Ti(e)}function Oi(e){let t=ui.exec(e);return t?t[1]:void 0}function ki(e){let t=di.exec(e);return t?t[1]:void 0}function Ai(e){let t=fi.exec(e);return t?t[1]:void 0}function ji(e){let t=pi.exec(e);return t?t[1]:void 0}function Mi(e){let t=mi.exec(e);return t?t[1]:void 0}function Ni(e){let t=hi.exec(e);return t?t[1]:void 0}function Pi(e){let t=gi.exec(e);return t?t[1]:void 0}function Fi(e){let t=_i.exec(e);return t?t[1]:void 0}function Ii(e){let t=vi.exec(e);return t?t[1]:void 0}function Li(e){let t=yi.exec(e);return t?t[1]:void 0}function R(e){return e.startsWith(`/`)?e:`/${e}`}function Ri(e){return`xl/theme/${e}.xml`}function zi(e){return`xl/media/${e}`}function Bi(e){return`xl/worksheets/sheet${e}.xml`}function Vi(e){return`xl/worksheets/_rels/sheet${e}.xml.rels`}function Hi(e){return`worksheets/sheet${e}.xml`}function Ui(e){return`xl/comments${e}.xml`}function Wi(e){return`xl/${e}.xml`}function Gi(e){return`xl/drawings/vmlDrawing${e}.vml`}function Ki(e){return`xl/tables/${e}`}function qi(e){return`xl/drawings/${e}.xml`}function Ji(e){return`xl/drawings/_rels/${e}.xml.rels`}function Yi(e){return`xl/pivotCache/pivotCacheDefinition${e}.xml`}function Xi(e){return`xl/pivotCache/_rels/pivotCacheDefinition${e}.xml.rels`}function Zi(e){return`xl/pivotCache/pivotCacheRecords${e}.xml`}function Qi(e){return`pivotCacheRecords${e}.xml`}function $i(e){return`xl/pivotTables/pivotTable${e}.xml`}function ea(e){return`xl/pivotTables/_rels/pivotTable${e}.xml.rels`}function ta(e){return`../pivotCache/pivotCacheDefinition${e}.xml`}let na={workbookStyles:`styles.xml`,workbookSharedStrings:`sharedStrings.xml`,workbookTheme1:`theme/theme1.xml`,workbookFeaturePropertyBag:`featurePropertyBag/featurePropertyBag.xml`};function ra(e){return`pivotCache/pivotCacheDefinition${e}.xml`}function ia(e){return`../comments${e}.xml`}function aa(e){return`../drawings/vmlDrawing${e}.vml`}function oa(e){return`../drawings/${e}.xml`}function sa(e){return`../drawings/${e}.vml`}function ca(e){return`../${e}.xml`}function la(e){return`../pivotTables/pivotTable${e}.xml`}function ua(e){return`../pivotTables/${e}.xml`}function da(e){return`../tables/${e}`}function fa(e){return`../tables/${e}.xml`}function pa(e){return`../media/${e}`}function ma(e){return`xl/ctrlProps/ctrlProp${e}.xml`}function ha(e){return`../ctrlProps/ctrlProp${e}.xml`}var ga=class e extends j{render(t,n){t.openXml(k.StdDocAttributes),t.openNode(`Types`,e.PROPERTY_ATTRIBUTES);let r={};if((n.media??[]).forEach(e=>{if(e.type===`image`){let n=e.extension;r[n]||(r[n]=!0,t.leafNode(`Default`,{Extension:n,ContentType:`image/${n}`}))}}),t.leafNode(`Default`,{Extension:`rels`,ContentType:`application/vnd.openxmlformats-package.relationships+xml`}),t.leafNode(`Default`,{Extension:`xml`,ContentType:`application/xml`}),t.leafNode(`Override`,{PartName:R(L.xlWorkbook),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml`}),n.worksheets.forEach(e=>{t.leafNode(`Override`,{PartName:R(Bi(e.fileIndex)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml`})}),(n.pivotTables??[]).length){let e=new Set;(n.pivotTables??[]).forEach(n=>{let r=n.tableNumber,i=n.cacheId;e.has(i)||(e.add(i),t.leafNode(`Override`,{PartName:R(Yi(r)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml`}),(!n.isLoaded||n.cacheRecords)&&t.leafNode(`Override`,{PartName:R(Zi(r)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml`})),t.leafNode(`Override`,{PartName:R($i(r)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml`})})}t.leafNode(`Override`,{PartName:R(L.xlTheme1),ContentType:`application/vnd.openxmlformats-officedocument.theme+xml`}),t.leafNode(`Override`,{PartName:R(L.xlStyles),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml`}),n.hasCheckboxes&&t.leafNode(`Override`,{PartName:R(L.xlFeaturePropertyBag),ContentType:`application/vnd.ms-excel.featurepropertybag+xml`}),n.sharedStrings&&n.sharedStrings.count&&t.leafNode(`Override`,{PartName:R(L.xlSharedStrings),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml`}),n.tables&&n.tables.forEach(e=>{t.leafNode(`Override`,{PartName:R(Ki(e.target)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml`})}),n.drawings&&n.drawings.forEach(e=>{t.leafNode(`Override`,{PartName:R(qi(e.name)),ContentType:`application/vnd.openxmlformats-officedocument.drawing+xml`})});let i=n.commentRefs&&n.commentRefs.length>0,a=n.formControlRefs&&n.formControlRefs.length>0;if((i||a)&&t.leafNode(`Default`,{Extension:`vml`,ContentType:`application/vnd.openxmlformats-officedocument.vmlDrawing`}),i&&n.commentRefs.forEach(({commentName:e})=>{t.leafNode(`Override`,{PartName:R(Wi(e)),ContentType:`application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml`})}),a)for(let e of n.formControlRefs)t.leafNode(`Override`,{PartName:R(ma(e)),ContentType:`application/vnd.ms-excel.controlproperties+xml`});if(n.passthroughContentTypes)for(let{partName:e,contentType:r}of n.passthroughContentTypes)t.leafNode(`Override`,{PartName:R(e),ContentType:r});t.leafNode(`Override`,{PartName:R(L.docPropsCore),ContentType:`application/vnd.openxmlformats-package.core-properties+xml`}),t.leafNode(`Override`,{PartName:R(L.docPropsApp),ContentType:`application/vnd.openxmlformats-officedocument.extended-properties+xml`}),t.closeNode()}parseOpen(){return!1}parseText(){}parseClose(){return!1}static{this.PROPERTY_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/package/2006/content-types`}}},_a=class extends j{render(e,t){e.openNode(`HeadingPairs`),e.openNode(`vt:vector`,{size:2,baseType:`variant`}),e.openNode(`vt:variant`),e.leafNode(`vt:lpstr`,void 0,`Worksheets`),e.closeNode(),e.openNode(`vt:variant`),e.leafNode(`vt:i4`,void 0,t.length),e.closeNode(),e.closeNode(),e.closeNode()}parseOpen(e){return e.name===`HeadingPairs`}parseText(){}parseClose(e){return e!==`HeadingPairs`}},va=class extends j{render(e,t){e.openNode(`TitlesOfParts`),e.openNode(`vt:vector`,{size:t.length,baseType:`lpstr`}),t.forEach(t=>{e.leafNode(`vt:lpstr`,void 0,t.name)}),e.closeNode(),e.closeNode()}parseOpen(e){return e.name===`TitlesOfParts`}parseText(){}parseClose(e){return e!==`TitlesOfParts`}},ya=class e extends j{constructor(){super(),this.map={Company:new P({tag:`Company`}),Manager:new P({tag:`Manager`}),HeadingPairs:new _a,TitlesOfParts:new va}}render(t,n){t.openXml(k.StdDocAttributes),t.openNode(`Properties`,e.PROPERTY_ATTRIBUTES),t.leafNode(`Application`,void 0,`Microsoft Excel`),t.leafNode(`DocSecurity`,void 0,`0`),t.leafNode(`ScaleCrop`,void 0,`false`),this.map.HeadingPairs.render(t,n.worksheets),this.map.TitlesOfParts.render(t,n.worksheets),this.map.Company.render(t,n.company??``),this.map.Manager.render(t,n.manager),t.leafNode(`LinksUpToDate`,void 0,`false`),t.leafNode(`SharedDoc`,void 0,`false`),t.leafNode(`HyperlinksChanged`,void 0,`false`),t.leafNode(`AppVersion`,void 0,`16.0300`),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`Properties`:return!0;default:return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`Properties`:return this.model={worksheets:this.map.TitlesOfParts.model,company:this.map.Company.model,manager:this.map.Manager.model},!1;default:return!0}}static{this.DateFormat=function(e){return e.toISOString().replace(/[.]\d{3,6}/,``)}}static{this.DateAttrs={"xsi:type":`dcterms:W3CDTF`}}static{this.PROPERTY_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/officeDocument/2006/extended-properties`,"xmlns:vt":`http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes`}}},ba=class extends j{constructor(){super(),this._parsedText=[]}render(e,t){e.openNode(`definedName`,{name:t.name,localSheetId:t.localSheetId}),e.writeText(t.ranges.join(`,`)),e.closeNode()}parseOpen(e){switch(e.name){case`definedName`:return this._parsedName=e.attributes.name,this._parsedLocalSheetId=e.attributes.localSheetId,this._parsedText=[],!0;default:return!1}}parseText(e){this._parsedText.push(e)}parseClose(){return this.model={name:this._parsedName,ranges:Ta(this._parsedText.join(``))},this._parsedLocalSheetId!==void 0&&(this.model.localSheetId=parseInt(this._parsedLocalSheetId,10)),!1}};let xa=/^[$]?[A-Za-z]{1,3}[$]?\d+(:[$]?[A-Za-z]{1,3}[$]?\d+)?$/,Sa=/^[$]?\d+:[$]?\d+$/,Ca=/^[$]?[A-Za-z]{1,3}:[$]?[A-Za-z]{1,3}$/;function wa(e){if(e.startsWith(`{`)||e.endsWith(`}`))return!1;let t=e.split(`!`).pop()??``;if(!xa.test(t)&&!Sa.test(t)&&!Ca.test(t))return!1;try{let t=S.decodeEx(e);return`row`in t&&typeof t.row==`number`||`top`in t&&typeof t.top==`number`||`left`in t&&typeof t.left==`number`}catch{return!1}}function Ta(e){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`))return[];let n=[],r=!1,i=``;return e.split(`,`).forEach(e=>{if(!e)return;let t=(e.match(/'/g)??[]).length;if(!t){r?i+=`${e},`:wa(e)&&n.push(e);return}let a=t%2==0;!r&&a&&wa(e)?n.push(e):r&&!a?(r=!1,wa(i+e)&&n.push(i+e),i=``):(r=!0,i+=`${e},`)}),n}let Ea=new Set([`visible`,`hidden`,`veryHidden`]);function Da(e){let t=e||`visible`;return Ea.has(t)?t:`visible`}var Oa=class extends j{render(e,t){e.leafNode(`sheet`,{name:t.name,sheetId:t.id,state:t.state===`visible`?void 0:t.state,"r:id":t.rId})}parseOpen(e){return e.name===`sheet`?(this.model={name:bt(e.attributes.name),id:parseInt(e.attributes.sheetId,10),state:Da(e.attributes.state),rId:e.attributes[`r:id`]},!0):!1}parseText(){}parseClose(){return!1}},ka=class extends j{render(e,t){let n={xWindow:t.x??0,yWindow:t.y??0,windowWidth:t.width??12e3,windowHeight:t.height??24e3,firstSheet:t.firstSheet,activeTab:t.activeTab};t.visibility&&t.visibility!==`visible`&&(n.visibility=t.visibility),e.leafNode(`workbookView`,n)}parseOpen(e){if(e.name===`workbookView`){let t=this.model={},n=function(e,n,r){t[e]=n===void 0?r:n},r=function(e,n,r){let i=n===void 0?r:parseInt(n,10);i!==void 0&&(t[e]=i)};return r(`x`,e.attributes.xWindow,0),r(`y`,e.attributes.yWindow,0),r(`width`,e.attributes.windowWidth,25e3),r(`height`,e.attributes.windowHeight,1e4),n(`visibility`,e.attributes.visibility,`visible`),r(`activeTab`,e.attributes.activeTab,void 0),r(`firstSheet`,e.attributes.firstSheet,void 0),!0}return!1}parseText(){}parseClose(){return!1}},Aa=class extends j{render(e,t){e.leafNode(`workbookPr`,{date1904:t.date1904?1:void 0,filterPrivacy:1})}parseOpen(e){return e.name===`workbookPr`?(this.model={date1904:e.attributes.date1904===`1`},!0):!1}parseText(){}parseClose(){return!1}},ja=class extends j{render(e,t){e.leafNode(`calcPr`,{calcId:171027,fullCalcOnLoad:t.fullCalcOnLoad?1:void 0})}parseOpen(e){return e.name===`calcPr`?(this.model={},!0):!1}parseText(){}parseClose(){return!1}},Ma=class extends j{render(e,t){e.leafNode(`pivotCache`,{cacheId:t.cacheId,"r:id":t.rId})}parseOpen(e){return e.name===`pivotCache`?(this.model={cacheId:e.attributes.cacheId,rId:e.attributes[`r:id`]},!0):!1}parseText(){}parseClose(){return!1}},Na=class e extends j{constructor(){super(),this.map={fileVersion:e.STATIC_XFORMS.fileVersion,workbookPr:new Aa,bookViews:new M({tag:`bookViews`,count:!1,childXform:new ka}),sheets:new M({tag:`sheets`,count:!1,childXform:new Oa}),definedNames:new M({tag:`definedNames`,count:!1,childXform:new ba}),calcPr:new ja,pivotCaches:new M({tag:`pivotCaches`,count:!1,childXform:new Ma})}}prepare(e){e.sheets=e.worksheets;let t=[],n=0;e.sheets.forEach(e=>{if(e.pageSetup&&e.pageSetup.printArea&&e.pageSetup.printArea.split(`&&`).forEach(r=>{let i=r.split(`:`),a=i[0],o=i[1]??a,s={name:`_xlnm.Print_Area`,ranges:[`'${e.name}'!$${a}:$${o}`],localSheetId:n};t.push(s)}),e.pageSetup&&(e.pageSetup.printTitlesRow||e.pageSetup.printTitlesColumn)){let r=[];if(e.pageSetup.printTitlesColumn){let t=e.pageSetup.printTitlesColumn.split(`:`),n=t[0],i=t[1]??n;r.push(`'${e.name}'!$${n}:$${i}`)}if(e.pageSetup.printTitlesRow){let t=e.pageSetup.printTitlesRow.split(`:`),n=t[0],i=t[1]??n;r.push(`'${e.name}'!$${n}:$${i}`)}let i={name:`_xlnm.Print_Titles`,ranges:r,localSheetId:n};t.push(i)}n++}),t.length&&(e.definedNames=e.definedNames.concat(t)),(e.media??[]).forEach((e,t)=>{e.name=e.type+(t+1)})}render(t,n){t.openXml(k.StdDocAttributes),t.openNode(`workbook`,e.WORKBOOK_ATTRIBUTES),this.map.fileVersion.render(t),this.map.workbookPr.render(t,n.properties),this.map.bookViews.render(t,n.views),this.map.sheets.render(t,n.sheets),this.map.definedNames.render(t,n.definedNames),this.map.calcPr.render(t,n.calcProperties);let r=n.pivotTables??[],i=new Set,a=r.filter(e=>i.has(e.cacheId)?!1:(i.add(e.cacheId),!0));this.map.pivotCaches.render(t,a),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`workbook`:return!0;default:return this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e),!0}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`workbook`:return this.model={sheets:this.map.sheets.model,properties:this.map.workbookPr.model||{},views:this.map.bookViews.model,calcProperties:{}},this.map.definedNames.model&&(this.model.definedNames=this.map.definedNames.model),this.map.pivotCaches.model&&this.map.pivotCaches.model.length>0&&(this.model.pivotCaches=this.map.pivotCaches.model),!1;default:return!0}}reconcile(e){let t=(e.workbookRels??[]).reduce((e,t)=>(e[t.Id]=t,e),{}),n=[],r,i=0;(e.sheets??[]).forEach(a=>{let o=t[a.rId];o&&(r=e.worksheetHash[`xl/${o.Target.replace(/^(\s|\/xl\/)+/,``)}`],r&&(r.name=a.name,r.id=a.id,r.state=a.state,n[i++]=r))});let a=[];e.definedNames&&e.definedNames.forEach(e=>{if(e.name===`_xlnm.Print_Area`){if(r=n[e.localSheetId],r&&e.ranges?.length>0){r.pageSetup||={};let t=S.decodeEx(e.ranges[0]);r.pageSetup.printArea=r.pageSetup.printArea?`${r.pageSetup.printArea}&&${t.dimensions}`:t.dimensions}}else if(e.name===`_xlnm.Print_Titles`){if(r=n[e.localSheetId],r&&e.ranges?.length>0){r.pageSetup||={};let t=e.ranges.join(`,`),n=/\$/g,i=t.match(/\$\d+:\$\d+/);if(i&&i.length){let e=i[0];r.pageSetup.printTitlesRow=e.replace(n,``)}let a=t.match(/\$[A-Z]+:\$[A-Z]+/);if(a&&a.length){let e=a[0];r.pageSetup.printTitlesColumn=e.replace(n,``)}}}else a.push(e)}),e.definedNames=a,e.media.forEach((e,t)=>{e.index=t})}static{this.WORKBOOK_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`,"mc:Ignorable":`x15`,"xmlns:x15":`http://schemas.microsoft.com/office/spreadsheetml/2010/11/main`}}static{this.STATIC_XFORMS={fileVersion:new Dr({tag:`fileVersion`,$:{appName:`xl`,lastEdited:5,lowestEdited:5,rupBuild:9303}})}}};let z={OfficeDocument:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument`,Worksheet:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet`,CalcChain:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain`,SharedStrings:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings`,Styles:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles`,Theme:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme`,Hyperlink:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink`,Image:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`,CoreProperties:`http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties`,ExtenderProperties:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties`,Comments:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments`,VmlDrawing:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing`,Table:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/table`,PivotCacheDefinition:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition`,PivotCacheRecords:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords`,PivotTable:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable`,FeaturePropertyBag:`http://schemas.microsoft.com/office/2022/11/relationships/FeaturePropertyBag`,CtrlProp:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp`};var Pa=class{constructor(){this.merges={}}add(e){if(this.merges[e.master])this.merges[e.master].expandToAddress(e.address);else{let t=`${e.master}:${e.address}`;this.merges[e.master]=new C(t)}}get mergeCells(){return Object.values(this.merges).map(e=>e.range)}reconcile(e,t){e.forEach(e=>{let n=S.decode(e);for(let e=n.top;e<=n.bottom;e++){let r=t[e-1];for(let t=n.left;t<=n.right;t++){let i=r.cells[t-1];i?i.type===T.ValueType.Merge&&(i.master=n.tl):r.cells[t]={type:T.ValueType.Null,address:S.encodeAddress(e,t)}}}})}getMasterAddress(e){let t=this.hash[e];return t&&t.tl}};function Fa(e){if(e==null)return T.ValueType.Null;if(e instanceof String||typeof e==`string`)return T.ValueType.String;if(typeof e==`number`)return T.ValueType.Number;if(typeof e==`boolean`)return T.ValueType.Boolean;if(e instanceof Date)return T.ValueType.Date;if(e.text&&e.hyperlink)return T.ValueType.Hyperlink;if(e.formula)return T.ValueType.Formula;if(e.error)return T.ValueType.Error;throw new g(typeof e,`Could not understand type of value`)}function Ia(e){switch(e.type){case T.ValueType.Formula:return Fa(e.result);default:return e.type}}var La=class extends j{constructor(){super(),this.richTextXform=new ti}get tag(){return`c`}prepare(e,t){let n=t.styles.addStyleModel(e.style||{},Ia(e));switch(n&&(e.styleId=n),e.comment&&t.comments.push({...e.comment,ref:e.address}),e.type){case T.ValueType.String:case T.ValueType.RichText:t.sharedStrings&&(e.ssId=t.sharedStrings.add(e.value));break;case T.ValueType.Date:t.date1904&&(e.date1904=!0);break;case T.ValueType.Hyperlink:t.sharedStrings&&e.text!==void 0&&e.text!==null&&(e.ssId=t.sharedStrings.add(e.text)),t.hyperlinks.push({address:e.address,target:e.hyperlink,tooltip:e.tooltip});break;case T.ValueType.Merge:t.merges.add(e);break;case T.ValueType.Formula:if(t.date1904&&(e.date1904=!0),e.shareType===`shared`&&(e.si=t.siFormulae++),e.formula)t.formulae[e.address]=e;else if(e.sharedFormula){let n=t.formulae[e.sharedFormula];if(!n)throw new l(`Shared Formula master must exist above and or left of clone for cell ${e.address}`);n.si===void 0?(n.shareType=`shared`,n.si=t.siFormulae++,n.range=new C(n.address,e.address)):n.range&&n.range.expandToAddress(e.address),e.si=n.si}break;default:break}}renderFormula(e,t){let n=null;switch(t.shareType){case`shared`:n={t:`shared`,ref:t.ref||t.range.range,si:t.si};break;case`array`:n={t:`array`,ref:t.ref};break;default:t.si!==void 0&&(n={t:`shared`,si:t.si});break}switch(Fa(t.result)){case T.ValueType.Null:e.leafNode(`f`,n,t.formula);break;case T.ValueType.String:e.addAttribute(`t`,`str`),e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result);break;case T.ValueType.Number:e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result);break;case T.ValueType.Boolean:e.addAttribute(`t`,`b`),e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result?1:0);break;case T.ValueType.Error:e.addAttribute(`t`,`e`),e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,t.result.error);break;case T.ValueType.Date:e.leafNode(`f`,n,t.formula),e.leafNode(`v`,null,ut(t.result,t.date1904));break;default:throw new g(String(Fa(t.result)),`Could not understand type of value`)}}render(e,t){if(!(t.type===T.ValueType.Null&&!t.styleId)){switch(e.openNode(`c`),e.addAttribute(`r`,t.address),t.styleId&&e.addAttribute(`s`,t.styleId),t.type){case T.ValueType.Null:break;case T.ValueType.Number:e.leafNode(`v`,null,t.value);break;case T.ValueType.Boolean:e.addAttribute(`t`,`b`),e.leafNode(`v`,null,t.value?`1`:`0`);break;case T.ValueType.Checkbox:e.addAttribute(`t`,`b`),e.leafNode(`v`,null,t.value?`1`:`0`);break;case T.ValueType.Error:e.addAttribute(`t`,`e`),e.leafNode(`v`,null,t.value.error);break;case T.ValueType.String:case T.ValueType.RichText:t.ssId===void 0?t.value&&t.value.richText?(e.addAttribute(`t`,`inlineStr`),e.openNode(`is`),t.value.richText.forEach(t=>{this.richTextXform.render(e,t)}),e.closeNode(`is`)):(e.addAttribute(`t`,`str`),e.leafNode(`v`,null,t.value)):(e.addAttribute(`t`,`s`),e.leafNode(`v`,null,t.ssId));break;case T.ValueType.Date:e.leafNode(`v`,null,ut(t.value,t.date1904));break;case T.ValueType.Hyperlink:t.ssId===void 0?(e.addAttribute(`t`,`str`),e.leafNode(`v`,null,t.text)):(e.addAttribute(`t`,`s`),e.leafNode(`v`,null,t.ssId));break;case T.ValueType.Formula:this.renderFormula(e,t);break;case T.ValueType.Merge:break;default:break}e.closeNode()}}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`c`:return this.model={address:e.attributes.r},this.t=e.attributes.t,e.attributes.s&&(this.model.styleId=parseInt(e.attributes.s,10)),!0;case`f`:return this.currentNode=`f`,this.model.si=e.attributes.si,this.model.shareType=e.attributes.t,this.model.ref=e.attributes.ref,!0;case`v`:return this.currentNode=`v`,!0;case`t`:return this.currentNode=`t`,!0;case`r`:return this.parser=this.richTextXform,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){if(this.parser){this.parser.parseText(e);return}switch(this.currentNode){case`f`:this.model.formula=this.model.formula?this.model.formula+e:e;break;case`v`:case`t`:this.model.value&&this.model.value.richText?this.model.value.richText.text=this.model.value.richText.text?this.model.value.richText.text+e:e:this.model.value=this.model.value?this.model.value+e:e;break;default:break}}parseClose(e){switch(e){case`c`:{let{model:e}=this;if(e.formula||e.shareType)e.type=T.ValueType.Formula,e.value&&=(this.t===`str`?e.result=bt(e.value):this.t===`b`?e.result=parseInt(e.value,10)!==0:this.t===`e`?e.result={error:e.value}:e.result=parseFloat(e.value),void 0);else if(e.value!==void 0)switch(this.t){case`s`:e.type=T.ValueType.String,e.value=parseInt(e.value,10);break;case`str`:e.type=T.ValueType.String,e.value=bt(e.value);break;case`inlineStr`:e.type=T.ValueType.String,typeof e.value==`string`&&(e.value=mt(e.value));break;case`b`:e.type=T.ValueType.Boolean,e.value=parseInt(e.value,10)!==0;break;case`e`:e.type=T.ValueType.Error,e.value={error:e.value};break;case`d`:e.type=T.ValueType.Date,e.value=new Date(e.value);break;default:e.type=T.ValueType.Number,e.value=parseFloat(e.value);break}else e.styleId?e.type=T.ValueType.Null:e.type=T.ValueType.Merge;return!1}case`f`:case`v`:case`is`:return this.currentNode=void 0,!0;case`t`:return this.parser?(this.parser.parseClose(e),!0):(this.currentNode=void 0,!0);case`r`:return this.model.value=this.model.value||{},this.model.value.richText=this.model.value.richText??[],this.model.value.richText.push(this.parser.model),this.parser=void 0,this.currentNode=void 0,!0;default:return this.parser?(this.parser.parseClose(e),!0):!1}}reconcile(e,t){let n=e.styleId!==void 0&&t.styles&&t.styles.getStyleModel(e.styleId);switch(n&&(e.style=n),e.styleId!==void 0&&(e.styleId=void 0),e.type){case T.ValueType.String:typeof e.value==`number`&&t.sharedStrings&&(e.value=t.sharedStrings.getString(e.value)),e.value.richText&&(e.type=T.ValueType.RichText);break;case T.ValueType.Number:n&&Et(n.numFmt)&&(e.type=T.ValueType.Date,e.value=dt(e.value,t.date1904));break;case T.ValueType.Formula:e.result!==void 0&&typeof e.result==`number`&&n&&Et(n.numFmt)&&(e.result=dt(e.result,t.date1904)),e.shareType===`shared`&&(e.ref?t.formulae[e.si]=e.address:(e.sharedFormula=t.formulae[e.si],delete e.shareType),delete e.si);break;default:break}let r=t.hyperlinkMap[e.address];r&&(e.type===T.ValueType.Formula?(e.text=e.result,e.result=void 0):(e.text=e.value,e.value=void 0),e.type=T.ValueType.Hyperlink,e.hyperlink=r);let i=t.commentsMap&&t.commentsMap[e.address];i&&(e.comment=i)}},Ra=class extends j{constructor(e){super(),this.maxItems=e&&e.maxItems,this.map={c:new La}}get tag(){return`row`}reset(){super.reset(),this.numRowsSeen=0,this.lastCellCol=0}prepare(e,t){let n=t.styles.addStyleModel(e.style);n&&(e.styleId=n);let r=this.map.c;e.cells.forEach(e=>{r.prepare(e,t)})}render(e,t,n){if(!t)return;e.openNode(`row`),e.addAttribute(`r`,t.number),t.height!=null&&t.height>0?(e.addAttribute(`ht`,t.height),t.customHeight!==!1&&e.addAttribute(`customHeight`,`1`)):t.height===0&&e.addAttribute(`ht`,1),t.hidden&&e.addAttribute(`hidden`,`1`),t.min>0&&t.max>0&&t.min<=t.max&&e.addAttribute(`spans`,`${t.min}:${t.max}`),t.styleId&&(e.addAttribute(`s`,t.styleId),e.addAttribute(`customFormat`,`1`)),t.dyDescent!==void 0&&e.addAttribute(`x14ac:dyDescent`,t.dyDescent),t.outlineLevel&&e.addAttribute(`outlineLevel`,t.outlineLevel),t.collapsed&&e.addAttribute(`collapsed`,`1`);let r=this.map.c;t.cells.forEach(t=>{r.render(e,t,n)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;if(e.name===`row`){this.numRowsSeen+=1,this.lastCellCol=0;let t=e.attributes.spans?e.attributes.spans.split(`:`).map(e=>parseInt(e,10)):[void 0,void 0],n=this.model={number:e.attributes.r?parseInt(e.attributes.r,10):this.numRowsSeen,min:t[0],max:t[1],cells:[]};return e.attributes.s&&(n.styleId=parseInt(e.attributes.s,10)),Dt(e.attributes.hidden)&&(n.hidden=!0),Dt(e.attributes.bestFit)&&(n.bestFit=!0),e.attributes.ht&&(n.height=parseFloat(e.attributes.ht)),Dt(e.attributes.customHeight)&&(n.customHeight=!0),e.attributes.outlineLevel&&(n.outlineLevel=parseInt(e.attributes.outlineLevel,10)),Dt(e.attributes.collapsed)&&(n.collapsed=!0),e.attributes[`x14ac:dyDescent`]!==void 0&&(n.dyDescent=parseFloat(e.attributes[`x14ac:dyDescent`])),!0}return this.parser=this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):!1}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser){if(!this.parser.parseClose(e)){let e=this.parser.model;if(e.address?this.lastCellCol=S.decodeAddress(e.address).col:(this.lastCellCol+=1,e.address=S.encodeAddress(this.model.number,this.lastCellCol)),this.model.cells.push(e),this.maxItems&&this.model.cells.length>this.maxItems)throw new re(`column`,this.maxItems);this.parser=void 0}return!0}return!1}reconcile(e,t){e.style=e.styleId===void 0?{}:t.styles.getStyleModel(e.styleId),e.styleId!==void 0&&(e.styleId=void 0);let n=this.map.c;e.cells.forEach(e=>{n.reconcile(e,t)})}},za=class extends j{get tag(){return`col`}prepare(e,t){let n=t.styles.addStyleModel(e.style||{});n&&(e.styleId=n)}render(e,t){e.openNode(`col`),e.addAttribute(`min`,t.min),e.addAttribute(`max`,t.max),t.width&&e.addAttribute(`width`,t.width),t.styleId&&e.addAttribute(`style`,t.styleId),t.hidden&&e.addAttribute(`hidden`,`1`),t.bestFit&&e.addAttribute(`bestFit`,`1`),t.outlineLevel&&e.addAttribute(`outlineLevel`,t.outlineLevel),t.collapsed&&e.addAttribute(`collapsed`,`1`),e.addAttribute(`customWidth`,`1`),e.closeNode()}parseOpen(e){if(e.name===`col`){let t=this.model={min:parseInt(e.attributes.min??`0`,10),max:parseInt(e.attributes.max??`0`,10),width:e.attributes.width===void 0?void 0:parseFloat(e.attributes.width??`0`)};return e.attributes.style&&(t.styleId=parseInt(e.attributes.style,10)),Dt(e.attributes.hidden)&&(t.hidden=!0),Dt(e.attributes.bestFit)&&(t.bestFit=!0),e.attributes.outlineLevel&&(t.outlineLevel=parseInt(e.attributes.outlineLevel,10)),Dt(e.attributes.collapsed)&&(t.collapsed=!0),!0}return!1}parseText(){}parseClose(){return!1}reconcile(e,t){e.styleId!==void 0&&(e.style=t.styles.getStyleModel(e.styleId))}},Ba=class extends j{get tag(){return`dimension`}render(e,t){t&&e.leafNode(`dimension`,{ref:t})}parseOpen(e){return e.name===`dimension`?(this.model=e.attributes.ref,!0):!1}parseText(){}parseClose(){return!1}},Va=class extends j{get tag(){return`hyperlink`}render(e,t){this.isInternalLink(t)?e.leafNode(`hyperlink`,{ref:t.address,"r:id":t.rId,tooltip:t.tooltip,location:t.target}):e.leafNode(`hyperlink`,{ref:t.address,"r:id":t.rId,tooltip:t.tooltip})}parseOpen(e){return e.name===`hyperlink`?(this.model={address:e.attributes.ref,rId:e.attributes[`r:id`],tooltip:e.attributes.tooltip},e.attributes.location&&(this.model.target=e.attributes.location),!0):!1}parseText(){}parseClose(){return!1}isInternalLink(e){return!!(e.target&&/^[^!]+![a-zA-Z]+[\d]+$/.test(e.target))}},Ha=class extends j{get tag(){return`mergeCell`}render(e,t){e.leafNode(`mergeCell`,{ref:t})}parseOpen(e){return e.name===`mergeCell`?(this.model=e.attributes.ref,!0):!1}parseText(){}parseClose(){return!1}};function Ua(e,t,n,r){let i=t[n];i===void 0?r!==void 0&&(e[n]=r):e[n]=i}function Wa(e,t,n,r){let i=t[n];i===void 0?r!==void 0&&(e[n]=r):e[n]=Dt(i)}function Ga(e){if(!e)return[];let t=[],n={};for(let[r,i]of Object.entries(e))if(i!=null)if(r.startsWith(`range:`)){let e=r.slice(6),{sqref:n,...a}=i;t.push({...a,sqref:e})}else n[r]=i;if(Object.keys(n).length===0)return t;let r=Object.entries(n).map(([e,t])=>({address:e,dataValidation:t,marked:!1})).sort((e,t)=>e.address.localeCompare(t.address)),i=Object.fromEntries(r.map(e=>[e.address,e])),a=(e,t,r)=>{for(let i=0;i<t;i++){let t=S.encodeAddress(e.row+i,r);if(!n[t]||!fe(n[e.address],n[t]))return!1}return!0},o=r.map(e=>{if(!e.marked){let t=S.decodeEx(e.address);if(t.dimensions)return i[t.dimensions].marked=!0,{...e.dataValidation,sqref:e.address};let r=1,o=S.encodeAddress(t.row+r,t.col);for(;n[o]&&fe(e.dataValidation,n[o]);)r++,o=S.encodeAddress(t.row+r,t.col);let s=1;for(;a(t,r,t.col+s);)s++;for(let e=0;e<r;e++)for(let n=0;n<s;n++)o=S.encodeAddress(t.row+e,t.col+n),i[o].marked=!0;if(r>1||s>1){let n=t.row+(r-1),i=t.col+(s-1);return{...e.dataValidation,sqref:`${e.address}:${S.encodeAddress(n,i)}`}}return{...e.dataValidation,sqref:e.address}}return null}).filter(Boolean);return[...t,...o]}var Ka=class extends j{get tag(){return`dataValidations`}render(e,t){let n=Ga(t);n.length&&(e.openNode(`dataValidations`,{count:n.length}),n.forEach(t=>{e.openNode(`dataValidation`),t.type!==`any`&&(e.addAttribute(`type`,t.type),t.operator&&t.type!==`list`&&t.operator!==`between`&&e.addAttribute(`operator`,t.operator),t.allowBlank&&e.addAttribute(`allowBlank`,`1`)),t.showInputMessage&&e.addAttribute(`showInputMessage`,`1`),t.promptTitle&&e.addAttribute(`promptTitle`,t.promptTitle),t.prompt&&e.addAttribute(`prompt`,t.prompt),t.showErrorMessage&&e.addAttribute(`showErrorMessage`,`1`),t.errorStyle&&e.addAttribute(`errorStyle`,t.errorStyle),t.errorTitle&&e.addAttribute(`errorTitle`,t.errorTitle),t.error&&e.addAttribute(`error`,t.error),e.addAttribute(`sqref`,t.sqref),(t.formulae??[]).forEach((n,r)=>{e.openNode(`formula${r+1}`),t.type===`date`?e.writeText(ut(new Date(n))):e.writeText(n),e.closeNode()}),e.closeNode()}),e.closeNode())}parseOpen(e){switch(e.name){case`dataValidations`:return this.model={},!0;case`dataValidation`:{this._address=e.attributes.sqref;let t={type:e.attributes.type??`any`,formulae:[]};switch(e.attributes.type&&Wa(t,e.attributes,`allowBlank`),Wa(t,e.attributes,`showInputMessage`),Wa(t,e.attributes,`showErrorMessage`),t.type){case`any`:case`list`:case`custom`:break;default:Ua(t,e.attributes,`operator`,`between`);break}return Ua(t,e.attributes,`promptTitle`),Ua(t,e.attributes,`prompt`),Ua(t,e.attributes,`errorStyle`),Ua(t,e.attributes,`errorTitle`),Ua(t,e.attributes,`error`),this._dataValidation=t,!0}case`formula1`:case`formula2`:return this._formula=[],!0;default:return!1}}parseText(e){this._formula&&this._formula.push(e)}parseClose(e){switch(e){case`dataValidations`:return!1;case`dataValidation`:return(!this._dataValidation.formulae||!this._dataValidation.formulae.length)&&(delete this._dataValidation.formulae,delete this._dataValidation.operator),this._address.split(/\s+/g).forEach(e=>{e.includes(`:`)?this.model[`range:${e}`]=this._dataValidation:this.model[e]=this._dataValidation}),!0;case`formula1`:case`formula2`:{let e=this._formula.join(``);switch(this._dataValidation.type){case`whole`:case`textLength`:e=parseInt(e,10);break;case`decimal`:e=parseFloat(e);break;case`date`:e=dt(parseFloat(e));break;default:break}return this._dataValidation.formulae.push(e),this._formula=void 0,!0}default:return!0}}},qa=class extends j{get tag(){return`pageSetUpPr`}render(e,t){return t&&t.fitToPage?(e.leafNode(this.tag,{fitToPage:t.fitToPage?`1`:void 0}),!0):!1}parseOpen(e){return e.name===this.tag?(this.model={fitToPage:e.attributes.fitToPage===`1`},!0):!1}parseText(){}parseClose(){return!1}};let Ja=e=>e!==void 0;var Ya=class extends j{get tag(){return`outlinePr`}render(e,t){return t&&(Ja(t.summaryBelow)||Ja(t.summaryRight))?(e.leafNode(this.tag,{summaryBelow:Ja(t.summaryBelow)?Number(t.summaryBelow):void 0,summaryRight:Ja(t.summaryRight)?Number(t.summaryRight):void 0}),!0):!1}parseOpen(e){return e.name===this.tag?(this.model={summaryBelow:Ja(e.attributes.summaryBelow)?!!Number(e.attributes.summaryBelow):void 0,summaryRight:Ja(e.attributes.summaryRight)?!!Number(e.attributes.summaryRight):void 0},!0):!1}parseText(){}parseClose(){return!1}},Xa=class extends j{constructor(){super(),this.map={tabColor:new N(`tabColor`),pageSetUpPr:new qa,outlinePr:new Ya}}get tag(){return`sheetPr`}render(e,t){if(t){e.addRollback(),e.openNode(`sheetPr`);let n=!1;n=this.map.tabColor.render(e,t.tabColor)||n,n=this.map.pageSetUpPr.render(e,t.pageSetup)||n,n=this.map.outlinePr.render(e,t.outlineProperties)||n,n?(e.closeNode(),e.commit()):e.rollback()}}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.reset(),!0):this.map[e.name]?(this.parser=this.map[e.name],this.parser.parseOpen(e),!0):!1}parseText(e){return this.parser?(this.parser.parseText(e),!0):!1}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.parser=void 0),!0):(this.map.tabColor.model||this.map.pageSetUpPr.model||this.map.outlinePr.model?(this.model={},this.map.tabColor.model&&(this.model.tabColor=this.map.tabColor.model),this.map.pageSetUpPr.model&&(this.model.pageSetup=this.map.pageSetUpPr.model),this.map.outlinePr.model&&(this.model.outlineProperties=this.map.outlinePr.model)):this.model=null,!1)}},Za=class extends j{get tag(){return`sheetFormatPr`}render(e,t){if(t){let n={defaultRowHeight:t.defaultRowHeight,outlineLevelRow:t.outlineLevelRow||void 0,outlineLevelCol:t.outlineLevelCol||void 0,"x14ac:dyDescent":t.dyDescent!==void 0&&t.dyDescent!==0?t.dyDescent:void 0};t.defaultColWidth&&(n.defaultColWidth=t.defaultColWidth),t.customHeight&&(n.customHeight=`1`),Object.values(n).some(e=>e!==void 0)&&e.leafNode(`sheetFormatPr`,n)}}parseOpen(e){return e.name===`sheetFormatPr`?(this.model={defaultRowHeight:parseFloat(e.attributes.defaultRowHeight??`0`),dyDescent:e.attributes[`x14ac:dyDescent`]===void 0?void 0:parseFloat(e.attributes[`x14ac:dyDescent`]),outlineLevelRow:parseInt(e.attributes.outlineLevelRow??`0`,10),outlineLevelCol:parseInt(e.attributes.outlineLevelCol??`0`,10)},e.attributes.defaultColWidth&&(this.model.defaultColWidth=parseFloat(e.attributes.defaultColWidth)),e.attributes.customHeight===`1`&&(this.model.customHeight=!0),!0):!1}parseText(){}parseClose(){return!1}};let Qa={frozen:`frozen`,frozenSplit:`frozen`,split:`split`};var $a=class extends j{get tag(){return`sheetView`}prepare(e){switch(e.state){case`frozen`:case`split`:break;default:e.state=`normal`;break}}render(e,t){let n={};t.tabSelected&&(n.tabSelected=`1`),n.workbookViewId=t.workbookViewId??0,e.openNode(`sheetView`,n);let r=function(t,n,r){r&&e.addAttribute(t,n)};r(`rightToLeft`,`1`,t.rightToLeft===!0),r(`showRuler`,`0`,t.showRuler===!1),r(`showRowColHeaders`,`0`,t.showRowColHeaders===!1),r(`showGridLines`,`0`,t.showGridLines===!1),r(`zoomScale`,t.zoomScale,t.zoomScale!==void 0&&t.zoomScale!==100),r(`zoomScaleNormal`,t.zoomScaleNormal,t.zoomScaleNormal!==void 0&&t.zoomScaleNormal!==100),r(`view`,t.style,t.style);let i,a,o,s;switch(t.state){case`frozen`:a=t.xSplit??0,o=t.ySplit??0,i=t.topLeftCell||S.getAddress(o+1,a+1).address,s=t.xSplit&&t.ySplit&&`bottomRight`||t.xSplit&&`topRight`||`bottomLeft`,e.leafNode(`pane`,{xSplit:t.xSplit||void 0,ySplit:t.ySplit||void 0,topLeftCell:i,activePane:s,state:`frozen`}),e.leafNode(`selection`,{pane:s,activeCell:t.activeCell,sqref:t.activeCell});break;case`split`:t.activePane===`topLeft`&&(t.activePane=void 0),e.leafNode(`pane`,{xSplit:t.xSplit||void 0,ySplit:t.ySplit||void 0,topLeftCell:t.topLeftCell,activePane:t.activePane}),e.leafNode(`selection`,{pane:t.activePane,activeCell:t.activeCell,sqref:t.activeCell});break;case`normal`:t.activeCell&&e.leafNode(`selection`,{activeCell:t.activeCell,sqref:t.activeCell});break;default:break}e.closeNode()}parseOpen(e){switch(e.name){case`sheetView`:return this.sheetView={workbookViewId:parseInt(e.attributes.workbookViewId,10),rightToLeft:e.attributes.rightToLeft===`1`,tabSelected:e.attributes.tabSelected===`1`,showRuler:e.attributes.showRuler!==`0`,showRowColHeaders:e.attributes.showRowColHeaders!==`0`,showGridLines:e.attributes.showGridLines!==`0`,zoomScale:parseInt(e.attributes.zoomScale??`100`,10),zoomScaleNormal:parseInt(e.attributes.zoomScaleNormal??`100`,10),style:e.attributes.view},this.pane=void 0,this.selections={},!0;case`pane`:return this.pane={xSplit:parseInt(e.attributes.xSplit??`0`,10),ySplit:parseInt(e.attributes.ySplit??`0`,10),topLeftCell:e.attributes.topLeftCell,activePane:e.attributes.activePane??`topLeft`,state:e.attributes.state},!0;case`selection`:{let t=e.attributes.pane??`topLeft`;return this.selections[t]={pane:t,activeCell:e.attributes.activeCell},!0}default:return!1}}parseText(){}parseClose(e){let t,n;switch(e){case`sheetView`:return this.sheetView&&this.pane?(t=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,tabSelected:this.sheetView.tabSelected,state:Qa[this.pane.state]??`split`,xSplit:this.pane.xSplit,ySplit:this.pane.ySplit,topLeftCell:this.pane.topLeftCell,showRuler:this.sheetView.showRuler,showRowColHeaders:this.sheetView.showRowColHeaders,showGridLines:this.sheetView.showGridLines,zoomScale:this.sheetView.zoomScale,zoomScaleNormal:this.sheetView.zoomScaleNormal},this.model.state===`split`&&(t.activePane=this.pane.activePane),n=this.selections[this.pane.activePane],n&&n.activeCell&&(t.activeCell=n.activeCell),this.sheetView.style&&(t.style=this.sheetView.style)):(t=this.model={workbookViewId:this.sheetView.workbookViewId,rightToLeft:this.sheetView.rightToLeft,tabSelected:this.sheetView.tabSelected,state:`normal`,showRuler:this.sheetView.showRuler,showRowColHeaders:this.sheetView.showRowColHeaders,showGridLines:this.sheetView.showGridLines,zoomScale:this.sheetView.zoomScale,zoomScaleNormal:this.sheetView.zoomScaleNormal},n=this.selections.topLeft,n&&n.activeCell&&(t.activeCell=n.activeCell),this.sheetView.style&&(t.style=this.sheetView.style)),!1;default:return!0}}reconcile(){}};function B(e,t){return e?t:void 0}function V(e,t){return e===t?!0:void 0}var eo=class extends j{get tag(){return`sheetProtection`}render(e,t){if(t){let n={sheet:B(t.sheet,`1`),selectLockedCells:t.selectLockedCells===!1?`1`:void 0,selectUnlockedCells:t.selectUnlockedCells===!1?`1`:void 0,formatCells:B(t.formatCells,`0`),formatColumns:B(t.formatColumns,`0`),formatRows:B(t.formatRows,`0`),insertColumns:B(t.insertColumns,`0`),insertRows:B(t.insertRows,`0`),insertHyperlinks:B(t.insertHyperlinks,`0`),deleteColumns:B(t.deleteColumns,`0`),deleteRows:B(t.deleteRows,`0`),sort:B(t.sort,`0`),autoFilter:B(t.autoFilter,`0`),pivotTables:B(t.pivotTables,`0`)};t.sheet&&(n.algorithmName=t.algorithmName,n.hashValue=t.hashValue,n.saltValue=t.saltValue,n.spinCount=t.spinCount,n.objects=B(t.objects===!1,`1`),n.scenarios=B(t.scenarios===!1,`1`)),Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={sheet:V(e.attributes.sheet,`1`),objects:e.attributes.objects===`1`?!1:void 0,scenarios:e.attributes.scenarios===`1`?!1:void 0,selectLockedCells:e.attributes.selectLockedCells===`1`?!1:void 0,selectUnlockedCells:e.attributes.selectUnlockedCells===`1`?!1:void 0,formatCells:V(e.attributes.formatCells,`0`),formatColumns:V(e.attributes.formatColumns,`0`),formatRows:V(e.attributes.formatRows,`0`),insertColumns:V(e.attributes.insertColumns,`0`),insertRows:V(e.attributes.insertRows,`0`),insertHyperlinks:V(e.attributes.insertHyperlinks,`0`),deleteColumns:V(e.attributes.deleteColumns,`0`),deleteRows:V(e.attributes.deleteRows,`0`),sort:V(e.attributes.sort,`0`),autoFilter:V(e.attributes.autoFilter,`0`),pivotTables:V(e.attributes.pivotTables,`0`)},e.attributes.algorithmName&&(this.model.algorithmName=e.attributes.algorithmName,this.model.hashValue=e.attributes.hashValue,this.model.saltValue=e.attributes.saltValue,this.model.spinCount=parseInt(e.attributes.spinCount,10)),!0;default:return!1}}parseText(){}parseClose(){return!1}},to=class extends j{get tag(){return`pageMargins`}render(e,t){if(t){let n={left:t.left,right:t.right,top:t.top,bottom:t.bottom,header:t.header,footer:t.footer};Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={left:parseFloat(e.attributes.left||.7),right:parseFloat(e.attributes.right||.7),top:parseFloat(e.attributes.top||.75),bottom:parseFloat(e.attributes.bottom||.75),header:parseFloat(e.attributes.header||.3),footer:parseFloat(e.attributes.footer||.3)},!0;default:return!1}}parseText(){}parseClose(){return!1}};function no(e){return e?`1`:void 0}function ro(e){switch(e){case`overThenDown`:return e;default:return}}function io(e){switch(e){case`atEnd`:case`asDisplyed`:return e;default:return}}function ao(e){switch(e){case`dash`:case`blank`:case`NA`:return e;default:return}}function oo(e){return e===void 0?void 0:parseInt(e,10)}var so=class extends j{get tag(){return`pageSetup`}_dpiToXml(e){if(e!==void 0&&Number.isFinite(e)&&e!==4294967295)return e}render(e,t){if(t){let n={paperSize:t.paperSize,orientation:t.orientation,horizontalDpi:this._dpiToXml(t.horizontalDpi),verticalDpi:this._dpiToXml(t.verticalDpi),pageOrder:ro(t.pageOrder),blackAndWhite:no(t.blackAndWhite),draft:no(t.draft),cellComments:io(t.cellComments),errors:ao(t.errors),scale:t.scale===100?void 0:t.scale,fitToWidth:t.fitToWidth===1?void 0:t.fitToWidth,fitToHeight:t.fitToHeight===1?void 0:t.fitToHeight,firstPageNumber:t.firstPageNumber,useFirstPageNumber:no(!!t.firstPageNumber),usePrinterDefaults:no(t.usePrinterDefaults),copies:t.copies};Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={paperSize:oo(e.attributes.paperSize),orientation:e.attributes.orientation??`portrait`,horizontalDpi:parseInt(e.attributes.horizontalDpi??`4294967295`,10),verticalDpi:parseInt(e.attributes.verticalDpi??`4294967295`,10),pageOrder:e.attributes.pageOrder??`downThenOver`,blackAndWhite:e.attributes.blackAndWhite===`1`,draft:e.attributes.draft===`1`,cellComments:e.attributes.cellComments??`None`,errors:e.attributes.errors??`displayed`,scale:parseInt(e.attributes.scale??`100`,10),fitToWidth:parseInt(e.attributes.fitToWidth??`1`,10),fitToHeight:parseInt(e.attributes.fitToHeight??`1`,10),firstPageNumber:parseInt(e.attributes.firstPageNumber??`1`,10),useFirstPageNumber:e.attributes.useFirstPageNumber===`1`,usePrinterDefaults:e.attributes.usePrinterDefaults===`1`,copies:parseInt(e.attributes.copies??`1`,10)},!0;default:return!1}}parseText(){}parseClose(){return!1}};function co(e){return e?`1`:void 0}var lo=class extends j{get tag(){return`printOptions`}render(e,t){if(t){let n={headings:co(t.showRowColHeaders),gridLines:co(t.showGridLines),horizontalCentered:co(t.horizontalCentered),verticalCentered:co(t.verticalCentered)};Object.values(n).some(e=>e!==void 0)&&e.leafNode(this.tag,n)}}parseOpen(e){switch(e.name){case this.tag:return this.model={showRowColHeaders:e.attributes.headings===`1`,showGridLines:e.attributes.gridLines===`1`,horizontalCentered:e.attributes.horizontalCentered===`1`,verticalCentered:e.attributes.verticalCentered===`1`},!0;default:return!1}}parseText(){}parseClose(){return!1}},uo=class extends j{get tag(){return`autoFilter`}render(e,t){if(t)if(typeof t==`string`)e.leafNode(`autoFilter`,{ref:t});else{let n=function(e){return typeof e==`string`?e:S.getAddress(e.row,e.col).address},r=n(t.from),i=n(t.to);r&&i&&e.leafNode(`autoFilter`,{ref:`${r}:${i}`})}}parseOpen(e){e.name===`autoFilter`&&(this.model=e.attributes.ref)}},fo=class extends j{get tag(){return`picture`}render(e,t){t&&e.leafNode(this.tag,{"r:id":t.rId})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:id`]},!0;default:return!1}}parseText(){}parseClose(){return!1}},po=class extends j{get tag(){return`drawing`}render(e,t){t&&e.leafNode(this.tag,{"r:id":t.rId})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:id`]},!0;default:return!1}}parseText(){}parseClose(){return!1}},mo=class extends j{get tag(){return`tablePart`}render(e,t){t&&e.leafNode(this.tag,{"r:id":t.rId})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:id`]},!0;default:return!1}}parseText(){}parseClose(){return!1}},ho=class extends j{get tag(){return`brk`}render(e,t){e.leafNode(`brk`,t)}parseOpen(e){if(e.name===`brk`){let{id:t,max:n,man:r,min:i}=e.attributes;return this.model={id:+t,max:+n,man:+r},i!==void 0&&(this.model.min=+i),!0}return!1}parseText(){}parseClose(){return!1}},go=class extends M{constructor(){super({tag:`rowBreaks`,count:!0,childXform:new ho})}render(e,t){if(t&&t.length){e.openNode(this.tag,this.$),e.addAttribute(this.$count,t.length),e.addAttribute(`manualBreakCount`,t.length);let{childXform:n}=this;for(let r of t)n.render(e,r);e.closeNode()}}},_o=class extends M{constructor(){super({tag:`colBreaks`,count:!0,childXform:new ho})}render(e,t){if(t&&t.length){e.openNode(this.tag,this.$),e.addAttribute(this.$count,t.length),e.addAttribute(`manualBreakCount`,t.length);let{childXform:n}=this;for(let r of t)n.render(e,r);e.closeNode()}}},vo=class extends j{get tag(){return`headerFooter`}render(e,t){if(t){e.addRollback();let n=!1;e.openNode(`headerFooter`),t.differentFirst&&(e.addAttribute(`differentFirst`,`1`),n=!0),t.differentOddEven&&(e.addAttribute(`differentOddEven`,`1`),n=!0),t.oddHeader&&typeof t.oddHeader==`string`&&(e.leafNode(`oddHeader`,null,t.oddHeader),n=!0),t.oddFooter&&typeof t.oddFooter==`string`&&(e.leafNode(`oddFooter`,null,t.oddFooter),n=!0),t.evenHeader&&typeof t.evenHeader==`string`&&(e.leafNode(`evenHeader`,null,t.evenHeader),n=!0),t.evenFooter&&typeof t.evenFooter==`string`&&(e.leafNode(`evenFooter`,null,t.evenFooter),n=!0),t.firstHeader&&typeof t.firstHeader==`string`&&(e.leafNode(`firstHeader`,null,t.firstHeader),n=!0),t.firstFooter&&typeof t.firstFooter==`string`&&(e.leafNode(`firstFooter`,null,t.firstFooter),n=!0),n?(e.closeNode(),e.commit()):e.rollback()}}parseOpen(e){switch(e.name){case`headerFooter`:return this.model={},e.attributes.differentFirst&&(this.model.differentFirst=parseInt(e.attributes.differentFirst,0)===1),e.attributes.differentOddEven&&(this.model.differentOddEven=parseInt(e.attributes.differentOddEven,0)===1),!0;case`oddHeader`:return this.currentNode=`oddHeader`,!0;case`oddFooter`:return this.currentNode=`oddFooter`,!0;case`evenHeader`:return this.currentNode=`evenHeader`,!0;case`evenFooter`:return this.currentNode=`evenFooter`,!0;case`firstHeader`:return this.currentNode=`firstHeader`,!0;case`firstFooter`:return this.currentNode=`firstFooter`,!0;default:return!1}}parseText(e){switch(this.currentNode){case`oddHeader`:this.model.oddHeader=(this.model.oddHeader??``)+e;break;case`oddFooter`:this.model.oddFooter=(this.model.oddFooter??``)+e;break;case`evenHeader`:this.model.evenHeader=(this.model.evenHeader??``)+e;break;case`evenFooter`:this.model.evenFooter=(this.model.evenFooter??``)+e;break;case`firstHeader`:this.model.firstHeader=(this.model.firstHeader??``)+e;break;case`firstFooter`:this.model.firstFooter=(this.model.firstFooter??``)+e;break;default:break}}parseClose(){switch(this.currentNode){case`oddHeader`:case`oddFooter`:case`evenHeader`:case`evenFooter`:case`firstHeader`:case`firstFooter`:return this.currentNode=void 0,!0;default:return!1}}},H=class extends j{createNewModel(e){return{}}parseOpen(e){return this.parser=this.parser||this.map[e.name],this.parser?(this.parser.parseOpen(e),!0):e.name===this.tag?(this.model=this.createNewModel(e),!0):!1}parseText(e){this.parser&&this.parser.parseText(e)}onParserClose(e,t){this.model[e]=t.model}parseClose(e){return this.parser?(this.parser.parseClose(e)||(this.onParserClose(e,this.parser),this.parser=void 0),!0):e!==this.tag}get tag(){return``}},yo=class extends j{get tag(){return`cfvo`}render(e,t){e.leafNode(this.tag,{type:t.type,val:t.value})}parseOpen(e){this.model={type:e.attributes.type,value:j.toFloatValue(e.attributes.val)}}parseClose(e){return e!==this.tag}},bo=class extends H{constructor(){super(),this.map={cfvo:this.cfvoXform=new yo,color:this.colorXform=new N}}get tag(){return`dataBar`}render(e,t){e.openNode(this.tag),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),this.colorXform.render(e,t.color),e.closeNode()}createNewModel(){return{cfvo:[]}}onParserClose(e,t){switch(e){case`cfvo`:this.model.cfvo.push(t.model);break;case`color`:this.model.color=t.model;break}}},xo=class extends j{get tag(){return`x14:id`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},So=class extends H{constructor(){super(),this.map={"x14:id":this.idXform=new xo}}get tag(){return`ext`}render(e,t){e.openNode(this.tag,{uri:`{B025F937-C7B1-47D3-B67F-A62EFF666E3E}`,"xmlns:x14":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`}),this.idXform.render(e,t.x14Id),e.closeNode()}createNewModel(){return{}}onParserClose(e,t){this.model.x14Id=t.model}},Co=class extends H{constructor(){super(),this.map={ext:new So}}get tag(){return`extLst`}render(e,t){e.openNode(this.tag),this.map.ext.render(e,t),e.closeNode()}createNewModel(){return{}}onParserClose(e,t){Object.assign(this.model,t.model)}},wo=class extends j{get tag(){return`formula`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},To=class extends H{constructor(){super(),this.map={cfvo:this.cfvoXform=new yo,color:this.colorXform=new N}}get tag(){return`colorScale`}render(e,t){e.openNode(this.tag),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),t.color.forEach(t=>{this.colorXform.render(e,t)}),e.closeNode()}createNewModel(e){return{cfvo:[],color:[]}}onParserClose(e,t){this.model[e].push(t.model)}},Eo=class extends H{constructor(){super(),this.map={cfvo:this.cfvoXform=new yo}}get tag(){return`iconSet`}render(e,t){e.openNode(this.tag,{iconSet:j.toStringAttribute(t.iconSet,`3TrafficLights`),reverse:j.toBoolAttribute(t.reverse,!1),showValue:j.toBoolAttribute(t.showValue,!0)}),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),e.closeNode()}createNewModel({attributes:e}){return{iconSet:j.toStringValue(e.iconSet,`3TrafficLights`),reverse:j.toBoolValue(e.reverse),showValue:j.toBoolValue(e.showValue),cfvo:[]}}onParserClose(e,t){this.model[e].push(t.model)}};let Do={"3Triangles":!0,"3Stars":!0,"5Boxes":!0},Oo=e=>{if(e.formulae&&e.formulae[0])return e.formulae[0];let{tl:t}=new C(e.ref);switch(e.operator){case`containsText`:return`NOT(ISERROR(SEARCH("${e.text}",${t})))`;case`containsBlanks`:return`LEN(TRIM(${t}))=0`;case`notContainsBlanks`:return`LEN(TRIM(${t}))>0`;case`containsErrors`:return`ISERROR(${t})`;case`notContainsErrors`:return`NOT(ISERROR(${t}))`;default:return}},ko=e=>{if(e.formulae&&e.formulae[0])return e.formulae[0];let{tl:t}=new C(e.ref);switch(e.timePeriod){case`thisWeek`:return`AND(TODAY()-ROUNDDOWN(${t},0)<=WEEKDAY(TODAY())-1,ROUNDDOWN(${t},0)-TODAY()<=7-WEEKDAY(TODAY()))`;case`lastWeek`:return`AND(TODAY()-ROUNDDOWN(${t},0)>=(WEEKDAY(TODAY())),TODAY()-ROUNDDOWN(${t},0)<(WEEKDAY(TODAY())+7))`;case`nextWeek`:return`AND(ROUNDDOWN(${t},0)-TODAY()>(7-WEEKDAY(TODAY())),ROUNDDOWN(${t},0)-TODAY()<(15-WEEKDAY(TODAY())))`;case`yesterday`:return`FLOOR(${t},1)=TODAY()-1`;case`today`:return`FLOOR(${t},1)=TODAY()`;case`tomorrow`:return`FLOOR(${t},1)=TODAY()+1`;case`last7Days`:return`AND(TODAY()-FLOOR(${t},1)<=6,FLOOR(${t},1)<=TODAY())`;case`lastMonth`:return`AND(MONTH(${t})=MONTH(EDATE(TODAY(),0-1)),YEAR(${t})=YEAR(EDATE(TODAY(),0-1)))`;case`thisMonth`:return`AND(MONTH(${t})=MONTH(TODAY()),YEAR(${t})=YEAR(TODAY()))`;case`nextMonth`:return`AND(MONTH(${t})=MONTH(EDATE(TODAY(),0+1)),YEAR(${t})=YEAR(EDATE(TODAY(),0+1)))`;default:return}},Ao=e=>{let{type:t,operator:n}=e;switch(t){case`containsText`:case`containsBlanks`:case`notContainsBlanks`:case`containsErrors`:case`notContainsErrors`:return{type:`containsText`,operator:t};default:return{type:t,operator:n}}};var jo=class e extends H{constructor(){super(),this.map={dataBar:this.databarXform=new bo,extLst:this.extLstRefXform=new Co,formula:this.formulaXform=new wo,colorScale:this.colorScaleXform=new To,iconSet:this.iconSetXform=new Eo}}get tag(){return`cfRule`}static isPrimitive(e){return!(e.type===`iconSet`&&(e.custom||Do[e.iconSet]))}render(e,t){switch(t.type){case`expression`:this.renderExpression(e,t);break;case`cellIs`:this.renderCellIs(e,t);break;case`top10`:this.renderTop10(e,t);break;case`aboveAverage`:this.renderAboveAverage(e,t);break;case`dataBar`:this.renderDataBar(e,t);break;case`colorScale`:this.renderColorScale(e,t);break;case`iconSet`:this.renderIconSet(e,t);break;case`containsText`:this.renderText(e,t);break;case`timePeriod`:this.renderTimePeriod(e,t);break}}renderExpression(e,t){e.openNode(this.tag,{type:`expression`,dxfId:t.dxfId,priority:t.priority}),this.formulaXform.render(e,t.formulae[0]),e.closeNode()}renderCellIs(e,t){e.openNode(this.tag,{type:`cellIs`,dxfId:t.dxfId,priority:t.priority,operator:t.operator}),t.formulae.forEach(t=>{this.formulaXform.render(e,t)}),e.closeNode()}renderTop10(e,t){e.leafNode(this.tag,{type:`top10`,dxfId:t.dxfId,priority:t.priority,percent:j.toBoolAttribute(t.percent,!1),bottom:j.toBoolAttribute(t.bottom,!1),rank:j.toIntValue(t.rank,10)})}renderAboveAverage(e,t){e.leafNode(this.tag,{type:`aboveAverage`,dxfId:t.dxfId,priority:t.priority,aboveAverage:j.toBoolAttribute(t.aboveAverage,!0)})}renderDataBar(e,t){e.openNode(this.tag,{type:`dataBar`,priority:t.priority}),this.databarXform.render(e,t),this.extLstRefXform.render(e,t),e.closeNode()}renderColorScale(e,t){e.openNode(this.tag,{type:`colorScale`,priority:t.priority}),this.colorScaleXform.render(e,t),e.closeNode()}renderIconSet(t,n){e.isPrimitive(n)&&(t.openNode(this.tag,{type:`iconSet`,priority:n.priority}),this.iconSetXform.render(t,n),t.closeNode())}renderText(e,t){e.openNode(this.tag,{type:t.operator,dxfId:t.dxfId,priority:t.priority,operator:j.toStringAttribute(t.operator,`containsText`)});let n=Oo(t);n&&this.formulaXform.render(e,n),e.closeNode()}renderTimePeriod(e,t){e.openNode(this.tag,{type:`timePeriod`,dxfId:t.dxfId,priority:t.priority,timePeriod:t.timePeriod});let n=ko(t);n&&this.formulaXform.render(e,n),e.closeNode()}createNewModel({attributes:e}){return{...Ao(e),dxfId:j.toIntValue(e.dxfId),priority:j.toIntValue(e.priority),timePeriod:e.timePeriod,percent:j.toBoolValue(e.percent),bottom:j.toBoolValue(e.bottom),rank:j.toIntValue(e.rank),aboveAverage:j.toBoolValue(e.aboveAverage)}}onParserClose(e,t){switch(e){case`dataBar`:case`extLst`:case`colorScale`:case`iconSet`:Object.assign(this.model,t.model);break;case`formula`:this.model.formulae=this.model.formulae??[],this.model.formulae.push(t.model);break}}},Mo=class extends H{constructor(){super(),this.map={cfRule:new jo}}get tag(){return`conditionalFormatting`}render(e,t){t.rules.some(jo.isPrimitive)&&(e.openNode(this.tag,{sqref:t.ref}),t.rules.forEach(n=>{jo.isPrimitive(n)&&(n.ref=t.ref,this.map.cfRule.render(e,n))}),e.closeNode())}createNewModel({attributes:e}){return{ref:e.sqref,rules:[]}}onParserClose(e,t){this.model.rules.push(t.model)}},No=class extends j{constructor(){super(),this.cfXform=new Mo}get tag(){return`conditionalFormatting`}reset(){this.model=[]}prepare(e,t){let n=e.reduce((e,t)=>Math.max(e,...t.rules.map(e=>e.priority??0)),1);e.forEach(e=>{e.rules.forEach(e=>{e.priority||=n++,e.style&&(e.dxfId=t.styles.addDxfStyle(e.style)),e.type===`dataBar`&&((!e.cfvo||e.cfvo.length<2)&&(e.cfvo=[{type:`min`},{type:`max`}]),e.color||={argb:`FF638EC6`})})})}render(e,t){t.forEach(t=>{this.cfXform.render(e,t)})}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`conditionalFormatting`:return this.parser=this.cfXform,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){return this.parser?this.parser.parseClose(e)?!0:(this.model.push(this.parser.model),this.parser=void 0,!1):!1}reconcile(e,t){e.forEach(e=>{e.rules.forEach(e=>{e.dxfId!==void 0&&(e.style=t.styles.getDxfStyle(e.dxfId),delete e.dxfId)})})}},Po=class extends j{get tag(){return`xm:f`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},Fo=class extends H{constructor(){super(),this.map={"xm:f":this.fExtXform=new Po}}get tag(){return`x14:cfvo`}render(e,t){e.openNode(this.tag,{type:t.type}),t.value!==void 0&&this.fExtXform.render(e,t.value),e.closeNode()}createNewModel(e){return{type:e.attributes.type}}onParserClose(e,t){switch(e){case`xm:f`:this.model.value=t.model?parseFloat(t.model):0;break}}},Io=class extends H{constructor(){super(),this.map={"x14:cfvo":this.cfvoXform=new Fo,"x14:borderColor":this.borderColorXform=new N(`x14:borderColor`),"x14:negativeBorderColor":this.negativeBorderColorXform=new N(`x14:negativeBorderColor`),"x14:negativeFillColor":this.negativeFillColorXform=new N(`x14:negativeFillColor`),"x14:axisColor":this.axisColorXform=new N(`x14:axisColor`)}}static isExt(e){return!e.gradient}get tag(){return`x14:dataBar`}render(e,t){e.openNode(this.tag,{minLength:j.toIntAttribute(t.minLength,0,!0),maxLength:j.toIntAttribute(t.maxLength,100,!0),border:j.toBoolAttribute(t.border,!1),gradient:j.toBoolAttribute(t.gradient,!0),negativeBarColorSameAsPositive:j.toBoolAttribute(t.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:j.toBoolAttribute(t.negativeBarBorderColorSameAsPositive,!0),axisPosition:j.toAttribute(t.axisPosition,`auto`),direction:j.toAttribute(t.direction,`leftToRight`)}),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),this.borderColorXform.render(e,t.borderColor),this.negativeBorderColorXform.render(e,t.negativeBorderColor),this.negativeFillColorXform.render(e,t.negativeFillColor),this.axisColorXform.render(e,t.axisColor),e.closeNode()}createNewModel({attributes:e}){return{cfvo:[],minLength:j.toIntValue(e.minLength,0),maxLength:j.toIntValue(e.maxLength,100),border:j.toBoolValue(e.border,!1),gradient:j.toBoolValue(e.gradient,!0),negativeBarColorSameAsPositive:j.toBoolValue(e.negativeBarColorSameAsPositive,!0),negativeBarBorderColorSameAsPositive:j.toBoolValue(e.negativeBarBorderColorSameAsPositive,!0),axisPosition:j.toStringValue(e.axisPosition,`auto`),direction:j.toStringValue(e.direction,`leftToRight`)}}onParserClose(e,t){let[,n]=e.split(`:`);switch(n){case`cfvo`:this.model.cfvo.push(t.model);break;default:this.model[n]=t.model;break}}},Lo=class extends j{get tag(){return`x14:cfIcon`}render(e,t){e.leafNode(this.tag,{iconSet:t.iconSet,iconId:t.iconId})}parseOpen({attributes:e}){this.model={iconSet:e.iconSet,iconId:j.toIntValue(e.iconId)}}parseClose(e){return e!==this.tag}},Ro=class extends H{constructor(){super(),this.map={"x14:cfvo":this.cfvoXform=new Fo,"x14:cfIcon":this.cfIconXform=new Lo}}get tag(){return`x14:iconSet`}render(e,t){e.openNode(this.tag,{iconSet:j.toStringAttribute(t.iconSet),reverse:j.toBoolAttribute(t.reverse,!1),showValue:j.toBoolAttribute(t.showValue,!0),custom:j.toBoolAttribute(t.icons,!1)}),t.cfvo.forEach(t=>{this.cfvoXform.render(e,t)}),t.icons&&t.icons.forEach((t,n)=>{t.iconId=n,this.cfIconXform.render(e,t)}),e.closeNode()}createNewModel({attributes:e}){return{cfvo:[],iconSet:j.toStringValue(e.iconSet,`3TrafficLights`),reverse:j.toBoolValue(e.reverse,!1),showValue:j.toBoolValue(e.showValue,!0)}}onParserClose(e,t){let[,n]=e.split(`:`);switch(n){case`cfvo`:this.model.cfvo.push(t.model);break;case`cfIcon`:this.model.icons||(this.model.icons=[]),this.model.icons.push(t.model);break;default:this.model[n]=t.model;break}}};function U(e){return e.toString(16).padStart(2,`0`)}function zo(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=e;return U(t[0])+U(t[1])+U(t[2])+U(t[3])+`-`+U(t[4])+U(t[5])+`-`+U(t[6])+U(t[7])+`-`+U(t[8])+U(t[9])+`-`+U(t[10])+U(t[11])+U(t[12])+U(t[13])+U(t[14])+U(t[15])}function Bo(){let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID();let t=new Uint8Array(16);if(e?.getRandomValues)return e.getRandomValues(t),zo(t);for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return zo(t)}let Vo={"3Triangles":!0,"3Stars":!0,"5Boxes":!0};var Ho=class e extends H{constructor(){super(),this.map={"x14:dataBar":this.databarXform=new Io,"x14:iconSet":this.iconSetXform=new Ro}}get tag(){return`x14:cfRule`}static isExt(e){return e.type===`dataBar`?Io.isExt(e):!!(e.type===`iconSet`&&(e.custom||Vo[e.iconSet]))}prepare(t){e.isExt(t)&&(t.x14Id=`{${Bo()}}`.toUpperCase())}render(t,n){if(e.isExt(n))switch(n.type){case`dataBar`:this.renderDataBar(t,n);break;case`iconSet`:this.renderIconSet(t,n);break}}renderDataBar(e,t){e.openNode(this.tag,{type:`dataBar`,id:t.x14Id}),this.databarXform.render(e,t),e.closeNode()}renderIconSet(e,t){e.openNode(this.tag,{type:`iconSet`,priority:t.priority,id:t.x14Id??`{${Bo()}}`}),this.iconSetXform.render(e,t),e.closeNode()}createNewModel({attributes:e}){return{type:e.type,x14Id:e.id,priority:j.toIntValue(e.priority)}}onParserClose(e,t){Object.assign(this.model,t.model)}},Uo=class extends j{get tag(){return`xm:sqref`}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(){this.model=``}parseText(e){this.model+=e}parseClose(e){return e!==this.tag}},Wo=class extends H{constructor(){super(),this.map={"xm:sqref":this.sqRef=new Uo,"x14:cfRule":this.cfRule=new Ho}}get tag(){return`x14:conditionalFormatting`}prepare(e){e.rules.forEach(e=>{this.cfRule.prepare(e)})}render(e,t){t.rules.some(Ho.isExt)&&(e.openNode(this.tag,{"xmlns:xm":`http://schemas.microsoft.com/office/excel/2006/main`}),t.rules.filter(Ho.isExt).forEach(t=>this.cfRule.render(e,t)),this.sqRef.render(e,t.ref),e.closeNode())}createNewModel(){return{rules:[]}}onParserClose(e,t){switch(e){case`xm:sqref`:this.model.ref=t.model;break;case`x14:cfRule`:this.model.rules.push(t.model);break}}},Go=class extends H{constructor(){super(),this.map={"x14:conditionalFormatting":this.cfXform=new Wo}}get tag(){return`x14:conditionalFormattings`}hasContent(e){return e.hasExtContent===void 0&&(e.hasExtContent=e.some(e=>e.rules.some(Ho.isExt))),e.hasExtContent}prepare(e){e.forEach(e=>{this.cfXform.prepare(e)})}render(e,t){this.hasContent(t)&&(e.openNode(this.tag),t.forEach(t=>this.cfXform.render(e,t)),e.closeNode())}createNewModel(){return[]}onParserClose(e,t){this.model.push(t.model)}},Ko=class extends H{constructor(){super(),this.map={"x14:conditionalFormattings":this.conditionalFormattings=new Go}}get tag(){return`ext`}hasContent(e){return this.conditionalFormattings.hasContent(e.conditionalFormattings)}prepare(e){this.conditionalFormattings.prepare(e.conditionalFormattings)}render(e,t){e.openNode(`ext`,{uri:`{78C0D931-6437-407d-A8EE-F0AAD7539E65}`,"xmlns:x14":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`}),this.conditionalFormattings.render(e,t.conditionalFormattings),e.closeNode()}createNewModel(){return{}}onParserClose(e,t){this.model[e]=t.model}},qo=class extends H{constructor(){super(),this.map={ext:this.ext=new Ko}}get tag(){return`extLst`}prepare(e,t){this.ext.prepare(e)}hasContent(e){return this.ext.hasContent(e)}render(e,t){this.hasContent(t)&&(e.openNode(`extLst`),this.ext.render(e,t),e.closeNode())}createNewModel(){return{}}onParserClose(e,t){this.model[e]=t.model}};function Jo(e){return pa(e.name&&e.extension&&e.name.endsWith(`.${e.extension}`)?e.name:`${e.name}.${e.extension}`)}function Yo(e,t,n){let r=[],i=[...t],a={};for(let t of e){let e=String(t.imageId),o=n.getBookImage(t.imageId);if(!o)continue;let s=a[e];s||(s=n.nextRId(i),a[e]=s,i.push({Id:s,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`,Target:Jo(o)}));let c={picture:{rId:s},range:t.range};if(t.hyperlinks&&t.hyperlinks.hyperlink){let e=n.nextRId(i);c.picture.hyperlinks={tooltip:t.hyperlinks.tooltip,rId:e},i.push({Id:e,Type:z.Hyperlink,Target:t.hyperlinks.hyperlink,TargetMode:`External`})}r.push(c)}return{anchors:r,rels:i}}function Xo(e){return e.filter(e=>e==null?!1:e.range?.br&&e.shape?!0:!(!e.range?.br&&!e.picture||e.range?.br&&!e.picture&&!e.shape))}let Zo=(e,t)=>{Object.keys(t).forEach(n=>{let r=e[n],i=t[n];r===void 0&&i!==void 0&&(e[n]=i)})},Qo=(e,t)=>{if(!t||!t.length)return e;if(!e||!e.length)return t;let n={},r={};return e.forEach(e=>{n[e.ref]=e,e.rules.forEach(e=>{let{x14Id:t}=e;t&&(r[t]=e)})}),t.forEach(t=>{t.rules.forEach(i=>{let a=r[i.x14Id];a?Zo(a,i):n[t.ref]?n[t.ref].rules.push(i):e.push({ref:t.ref,rules:[i]})})}),e};var $o=class e extends j{static{this.WORKSHEET_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`,"xmlns:x14ac":`http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac`,"mc:Ignorable":`x14ac`}}constructor(e){super();let{maxRows:t,maxCols:n,ignoreNodes:r}=e||{};this.ignoreNodes=r??[],this.map={sheetPr:new Xa,dimension:new Ba,sheetViews:new M({tag:`sheetViews`,count:!1,childXform:new $a}),sheetFormatPr:new Za,cols:new M({tag:`cols`,count:!1,childXform:new za}),sheetData:new M({tag:`sheetData`,count:!1,empty:!0,childXform:new Ra({maxItems:n}),maxItems:t}),autoFilter:new uo,mergeCells:new M({tag:`mergeCells`,count:!0,childXform:new Ha}),rowBreaks:new go,colBreaks:new _o,hyperlinks:new M({tag:`hyperlinks`,count:!1,childXform:new Va}),pageMargins:new to,dataValidations:new Ka,pageSetup:new so,headerFooter:new vo,printOptions:new lo,picture:new fo,drawing:new po,sheetProtection:new eo,tableParts:new M({tag:`tableParts`,count:!0,childXform:new mo}),conditionalFormatting:new No,extLst:new qo}}prepare(e,t){t.merges=new Pa,e.hyperlinks=t.hyperlinks=[],e.comments=t.comments=[],e.formControls&&e.formControls.length>0&&(!e.views||e.views.length===0)&&(e.views=[{workbookViewId:0}]),t.formulae={},t.siFormulae=0,this.map.cols.prepare(e.cols,t),this.map.sheetData.prepare(e.rows,t),this.map.conditionalFormatting.prepare(e.conditionalFormattings,t),e.mergeCells=t.merges.mergeCells;let n=e.rels=[];function r(e){return`rId${e.length+1}`}e.hyperlinks.forEach(e=>{let t=r(n);e.rId=t,n.push({Id:t,Type:z.Hyperlink,Target:e.target,TargetMode:`External`})});let{fileIndex:i}=e;if(e.comments.length>0){let a={Id:r(n),Type:z.Comments,Target:ia(i)};n.push(a);let o={Id:r(n),Type:z.VmlDrawing,Target:aa(i)};n.push(o),e.comments.forEach(e=>{e.refAddress=S.decodeAddress(e.ref)}),t.commentRefs.push({commentName:`comments${i}`,vmlDrawing:`vmlDrawing${i}`})}if(e.drawing&&e.drawing.anchors){let i=e.drawing;i.rId=r(n),i.name||=`drawing${++t.drawingsCount}`;let a=(i.rels??[]).some(e=>e.Target&&e.Target.includes(`/charts/`));i.anchors=[],a||(i.rels=[]),t.drawings.push(i),n.push({Id:i.rId,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,Target:oa(i.name)})}let a=[],o=[];if(e.media.forEach(e=>{e.type===`background`?a.push(e):e.type===`image`&&o.push(e)}),a.forEach(i=>{let a=r(n),o=t.media[i.imageId];n.push({Id:a,Type:z.Image,Target:Jo(o)}),e.background={rId:a},e.image=t.media[i.imageId]}),o.length>0){let{drawing:i}=e;i||(i=e.drawing={rId:r(n),name:`drawing${++t.drawingsCount}`,anchors:[],rels:[]},t.drawings.push(i),n.push({Id:i.rId,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,Target:oa(i.name)}));let a=Yo(o,i.rels,{getBookImage:e=>t.media[e],nextRId:e=>r(e)});i.anchors.push(...a.anchors),i.rels=a.rels}if(e.tables.forEach(e=>{let i=r(n);e.rId=i,n.push({Id:i,Type:z.Table,Target:da(e.target)}),e.columns.forEach(e=>{let{style:n}=e;n&&(e.dxfId=t.styles.addDxfStyle(n))})}),(e.pivotTables??[]).forEach(e=>{n.push({Id:r(n),Type:z.PivotTable,Target:la(e.tableNumber)})}),e.formControls&&e.formControls.length>0){let{drawing:a}=e;a||(a=e.drawing={rId:r(n),name:`drawing${++t.drawingsCount}`,anchors:[],rels:[]},t.drawings.push(a),n.push({Id:a.rId,Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,Target:oa(a.name)})),e.comments.length===0&&n.push({Id:r(n),Type:z.VmlDrawing,Target:aa(i)});let o=e=>({nativeCol:e.col,nativeColOff:e.colOff,nativeRow:e.row,nativeRowOff:e.rowOff});for(let i of e.formControls){let e=t.formControlRefs.length+1;i.ctrlPropId=e;let s=r(n);i.ctrlPropRelId=s,n.push({Id:s,Type:z.CtrlProp,Target:ha(e)}),t.formControlRefs.push(e);let c=`Check Box ${Math.max(1,i.shapeId-1024)}`;a.anchors.push({range:{editAs:`absolute`,tl:o(i.tl),br:o(i.br)},alternateContent:{requires:`a14`},shape:{cNvPrId:i.shapeId,name:i.name||c,hidden:!0,spid:`_x0000_s${i.shapeId}`,text:i.text}})}}this.map.extLst.prepare(e,t)}render(t,n){t.openXml(k.StdDocAttributes);let r={...e.WORKSHEET_ATTRIBUTES};n.formControls&&n.formControls.length>0&&(r[`xmlns:x14`]=`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`,r[`xmlns:xdr`]=`http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing`,r[`mc:Ignorable`]=`${r[`mc:Ignorable`]} x14`),t.openNode(`worksheet`,r);let i=n.properties?{defaultRowHeight:n.properties.defaultRowHeight,dyDescent:n.properties.dyDescent,outlineLevelCol:n.properties.outlineLevelCol,outlineLevelRow:n.properties.outlineLevelRow,customHeight:n.properties.customHeight}:void 0;n.properties&&n.properties.defaultColWidth&&(i.defaultColWidth=n.properties.defaultColWidth);let a={outlineProperties:n.properties&&n.properties.outlineProperties,tabColor:n.properties&&n.properties.tabColor,pageSetup:n.pageSetup&&n.pageSetup.fitToPage?{fitToPage:n.pageSetup.fitToPage}:void 0},o=n.pageSetup&&n.pageSetup.margins,s={showRowColHeaders:n.pageSetup&&n.pageSetup.showRowColHeaders,showGridLines:n.pageSetup&&n.pageSetup.showGridLines,horizontalCentered:n.pageSetup&&n.pageSetup.horizontalCentered,verticalCentered:n.pageSetup&&n.pageSetup.verticalCentered},c=n.sheetProtection;if(this.map.sheetPr.render(t,a),this.map.dimension.render(t,n.dimensions),this.map.sheetViews.render(t,n.views),this.map.sheetFormatPr.render(t,i),this.map.cols.render(t,n.cols),this.map.sheetData.render(t,n.rows),this.map.sheetProtection.render(t,c),this.map.autoFilter.render(t,n.autoFilter),this.map.mergeCells.render(t,n.mergeCells),this.map.conditionalFormatting.render(t,n.conditionalFormattings),this.map.dataValidations.render(t,n.dataValidations),this.map.hyperlinks.render(t,n.hyperlinks),this.map.printOptions.render(t,s),this.map.pageMargins.render(t,o),this.map.pageSetup.render(t,n.pageSetup),this.map.headerFooter.render(t,n.headerFooter),this.map.rowBreaks.render(t,n.rowBreaks),this.map.colBreaks.render(t,n.colBreaks),this.map.drawing.render(t,n.drawing),this.map.picture.render(t,n.background),n.rels&&n.rels.forEach(e=>{e.Type===z.VmlDrawing&&t.leafNode(`legacyDrawing`,{"r:id":e.Id})}),n.formControls&&n.formControls.length>0){t.openNode(`mc:AlternateContent`),t.openNode(`mc:Choice`,{Requires:`x14`}),t.openNode(`controls`);for(let e of n.formControls){if(!e.ctrlPropRelId)continue;let n=`Check Box ${Math.max(1,e.shapeId-1024)}`;t.openNode(`mc:AlternateContent`),t.openNode(`mc:Choice`,{Requires:`x14`}),t.openNode(`control`,{shapeId:e.shapeId,"r:id":e.ctrlPropRelId,name:e.name||n}),t.openNode(`controlPr`,{locked:0,defaultSize:0,print:e.print?1:0,autoFill:0,autoLine:0,autoPict:0}),t.openNode(`anchor`),t.openNode(`from`),t.leafNode(`xdr:col`,void 0,e.tl.col),t.leafNode(`xdr:colOff`,void 0,e.tl.colOff),t.leafNode(`xdr:row`,void 0,e.tl.row),t.leafNode(`xdr:rowOff`,void 0,e.tl.rowOff),t.closeNode(),t.openNode(`to`),t.leafNode(`xdr:col`,void 0,e.br.col),t.leafNode(`xdr:colOff`,void 0,e.br.colOff),t.leafNode(`xdr:row`,void 0,e.br.row),t.leafNode(`xdr:rowOff`,void 0,e.br.rowOff),t.closeNode(),t.closeNode(),t.closeNode(),t.closeNode(),t.closeNode(),t.leafNode(`mc:Fallback`),t.closeNode()}t.closeNode(),t.closeNode(),t.leafNode(`mc:Fallback`),t.closeNode()}this.map.tableParts.render(t,n.tables),this.map.extLst.render(t,n),t.closeNode()}parseOpen(e){return this.parser?(this.parser.parseOpen(e),!0):e.name===`worksheet`?(Object.values(this.map).forEach(e=>{e.reset()}),!0):(this.map[e.name]&&!this.ignoreNodes.includes(e.name)&&(this.parser=this.map[e.name],this.parser.parseOpen(e)),!0)}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case`worksheet`:{let e=this.map.sheetFormatPr.model||{};this.map.sheetPr.model&&this.map.sheetPr.model.tabColor&&(e.tabColor=this.map.sheetPr.model.tabColor),this.map.sheetPr.model&&this.map.sheetPr.model.outlineProperties&&(e.outlineProperties=this.map.sheetPr.model.outlineProperties);let t={fitToPage:this.map.sheetPr.model&&this.map.sheetPr.model.pageSetup&&this.map.sheetPr.model.pageSetup.fitToPage||!1,margins:this.map.pageMargins.model},n=Object.assign(t,this.map.pageSetup.model,this.map.printOptions.model),r=Qo(this.map.conditionalFormatting.model,this.map.extLst.model&&this.map.extLst.model[`x14:conditionalFormattings`]);return this.model={dimensions:this.map.dimension.model,cols:this.map.cols.model,rows:this.map.sheetData.model,mergeCells:this.map.mergeCells.model,hyperlinks:this.map.hyperlinks.model,dataValidations:this.map.dataValidations.model,properties:e,views:this.map.sheetViews.model,pageSetup:n,headerFooter:this.map.headerFooter.model,background:this.map.picture.model,drawing:this.map.drawing.model,tables:this.map.tableParts.model,conditionalFormattings:r,rowBreaks:this.map.rowBreaks.model??[],colBreaks:this.map.colBreaks.model??[]},this.map.autoFilter.model&&(this.model.autoFilter=this.map.autoFilter.model),this.map.sheetProtection.model&&(this.model.sheetProtection=this.map.sheetProtection.model),!1}default:return!0}}reconcile(e,t){let n=(e.relationships??[]).reduce((n,r)=>{if(n[r.Id]=r,r.Type===z.Comments&&(e.comments=t.comments[r.Target].comments),r.Type===z.VmlDrawing&&e.comments&&e.comments.length){let n=t.vmlDrawings[r.Target].comments;e.comments.forEach((e,t)=>{e.note=Object.assign({},e.note,n[t])})}return n},{});if(t.commentsMap=(e.comments??[]).reduce((e,t)=>(t.ref&&(e[t.ref]=t),e),{}),t.hyperlinkMap=(e.hyperlinks??[]).reduce((e,t)=>(t.rId&&(e[t.address]=n[t.rId].Target),e),{}),t.formulae={},e.rows=e.rows?.filter(Boolean)??[],e.rows.forEach(e=>{e.cells=e.cells?.filter(Boolean)??[]}),this.map.cols.reconcile(e.cols,t),this.map.sheetData.reconcile(e.rows,t),this.map.conditionalFormatting.reconcile(e.conditionalFormattings,t),e.media=[],e.drawing){let r=n[e.drawing.rId].Target.match(/\/drawings\/([a-zA-Z0-9]+)[.][a-zA-Z]{3,4}$/);if(r){let n=r[1],i=t.drawings[n];i&&(e.drawing={...i,name:n,rels:t.drawingRels?.[n]??i.rels??[]},i.anchors.forEach(t=>{if(t.medium){let n={type:`image`,imageId:t.medium.index,range:t.range,hyperlinks:t.picture.hyperlinks};e.media.push(n)}}))}}let r=e.background&&n[e.background.rId];if(r){let n=r.Target.split(`/media/`)[1],i=t.mediaIndex&&t.mediaIndex[n];i!==void 0&&e.media.push({type:`background`,imageId:i})}e.tables=(e.tables??[]).map(e=>{let r=n[e.rId];return t.tables[r.Target]}),e.pivotTables=[],(e.relationships??[]).forEach(n=>{if(n.Type===z.PivotTable&&t.pivotTables){let r=t.pivotTables[n.Target];r&&e.pivotTables.push(r)}}),delete e.relationships,delete e.hyperlinks,delete e.comments}},es=class extends j{render(e){e.openXml({version:`1.0`,encoding:`UTF-8`,standalone:`yes`}),e.openNode(`FeaturePropertyBags`,{xmlns:`http://schemas.microsoft.com/office/spreadsheetml/2022/featurepropertybag`}),e.leafNode(`bag`,{type:`Checkbox`}),e.openNode(`bag`,{type:`XFControls`}),e.leafNode(`bagId`,{k:`CellControl`},`0`),e.closeNode(),e.openNode(`bag`,{type:`XFComplement`}),e.leafNode(`bagId`,{k:`XFControls`},`1`),e.closeNode(),e.openNode(`bag`,{type:`XFComplements`,extRef:`XFComplementsMapperExtRef`}),e.openNode(`a`,{k:`MappedFeaturePropertyBags`}),e.leafNode(`bagId`,{},`2`),e.closeNode(),e.closeNode(),e.closeNode()}parseOpen(){return!1}parseText(){}parseClose(){return!1}},ts=class extends j{parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset(),this.model={range:{editAs:e.attributes.editAs??`oneCell`}};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}reconcilePicture(e,t){if(e&&e.rId){let n=t.rels[e.rId].Target.match(/.*\/media\/(.+[.][a-zA-Z]{3,4})/);if(n){let e=n[1],r=t.mediaIndex[e];return t.media[r]}}}},ns=class extends j{constructor(e){super(),this.tag=e.tag,this.map={"xdr:col":new kr({tag:`xdr:col`,zero:!0}),"xdr:colOff":new kr({tag:`xdr:colOff`,zero:!0}),"xdr:row":new kr({tag:`xdr:row`,zero:!0}),"xdr:rowOff":new kr({tag:`xdr:rowOff`,zero:!0})},this.model={nativeCol:0,nativeColOff:0,nativeRow:0,nativeRowOff:0}}render(e,t){e.openNode(this.tag),this.map[`xdr:col`].render(e,t.nativeCol),this.map[`xdr:colOff`].render(e,t.nativeColOff),this.map[`xdr:row`].render(e,t.nativeRow),this.map[`xdr:rowOff`].render(e,t.nativeRowOff),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model={nativeCol:this.map[`xdr:col`].model,nativeColOff:this.map[`xdr:colOff`].model,nativeRow:this.map[`xdr:row`].model,nativeRowOff:this.map[`xdr:rowOff`].model},!1;default:return!0}}},rs=class extends j{constructor(){super(),this.model={rId:``}}get tag(){return`a:blip`}render(e,t){e.leafNode(this.tag,{"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"r:embed":t.rId,cstate:`print`})}parseOpen(e){switch(e.name){case this.tag:return this.model={rId:e.attributes[`r:embed`]},!0;default:return!0}}parseText(){}parseClose(e){switch(e){case this.tag:return!1;default:return!0}}},is=class extends j{constructor(){super(),this.map={"a:blip":new rs}}get tag(){return`xdr:blipFill`}render(e,t){e.openNode(this.tag),this.map[`a:blip`].render(e,t),e.openNode(`a:stretch`),e.leafNode(`a:fillRect`),e.closeNode(),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model=this.map[`a:blip`].model,!1;default:return!0}}},as=class extends j{constructor(){super(),this.model={}}get tag(){return`a:hlinkClick`}render(e,t){t.hyperlinks&&t.hyperlinks.rId&&e.leafNode(this.tag,{"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"r:id":t.hyperlinks.rId,tooltip:t.hyperlinks.tooltip})}parseOpen(e){switch(e.name){case this.tag:return this.model={hyperlinks:{rId:e.attributes[`r:id`],tooltip:e.attributes.tooltip}},!0;default:return!0}}parseText(){}parseClose(){return!1}},os=class extends j{get tag(){return`a:extLst`}render(e){e.openNode(this.tag),e.openNode(`a:ext`,{uri:`{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}`}),e.leafNode(`a16:creationId`,{"xmlns:a16":`http://schemas.microsoft.com/office/drawing/2014/main`,id:`{00000000-0008-0000-0000-000002000000}`}),e.closeNode(),e.closeNode()}parseOpen(e){switch(e.name){case this.tag:return!0;default:return!0}}parseText(){}parseClose(e){switch(e){case this.tag:return!1;default:return!0}}},ss=class extends j{constructor(){super(),this.map={"a:hlinkClick":new as,"a:extLst":new os}}get tag(){return`xdr:cNvPr`}render(e,t){e.openNode(this.tag,{id:t.index,name:`Picture ${t.index}`}),this.map[`a:hlinkClick`].render(e,t),this.map[`a:extLst`].render(e,t),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model=this.map[`a:hlinkClick`].model,!1;default:return!0}}},cs=class extends j{get tag(){return`xdr:cNvPicPr`}render(e){e.openNode(this.tag),e.leafNode(`a:picLocks`,{noChangeAspect:`1`}),e.closeNode()}parseOpen(e){switch(e.name){case this.tag:return!0;default:return!0}}parseText(){}parseClose(e){switch(e){case this.tag:return!1;default:return!0}}},ls=class extends j{constructor(){super(),this.map={"xdr:cNvPr":new ss,"xdr:cNvPicPr":new cs}}get tag(){return`xdr:nvPicPr`}render(e,t){e.openNode(this.tag),this.map[`xdr:cNvPr`].render(e,t),this.map[`xdr:cNvPicPr`].render(e,t),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model=this.map[`xdr:cNvPr`].model,!1;default:return!0}}};let us={tag:`xdr:spPr`,c:[{tag:`a:xfrm`,c:[{tag:`a:off`,$:{x:`0`,y:`0`}},{tag:`a:ext`,$:{cx:`0`,cy:`0`}}]},{tag:`a:prstGeom`,$:{prst:`rect`},c:[{tag:`a:avLst`}]}]};var ds=class extends j{constructor(){super(),this.map={"xdr:nvPicPr":new ls,"xdr:blipFill":new is,"xdr:spPr":new Dr(us)}}get tag(){return`xdr:pic`}prepare(e,t){e.index=t.index+1}render(e,t){e.openNode(this.tag),this.map[`xdr:nvPicPr`].render(e,t),this.map[`xdr:blipFill`].render(e,t),this.map[`xdr:spPr`].render(e,t),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset();break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.mergeModel(this.parser.model),this.parser=void 0),!0;switch(e){case this.tag:return!1;default:return!0}}},fs=class extends j{get tag(){return`xdr:sp`}render(e,t){t&&(e.openNode(this.tag,{macro:``,textlink:``}),e.openNode(`xdr:nvSpPr`),e.openNode(`xdr:cNvPr`,{id:t.cNvPrId,name:t.name,hidden:t.hidden?`1`:void 0}),e.openNode(`a:extLst`),e.openNode(`a:ext`,{uri:`{63B3BB69-23CF-44E3-9099-C40C66FF867C}`}),e.leafNode(`a14:compatExt`,{spid:t.spid,"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`},void 0),e.closeNode(),e.closeNode(),e.closeNode(),e.leafNode(`xdr:cNvSpPr`),e.closeNode(),e.openNode(`xdr:spPr`,{bwMode:`auto`}),e.openNode(`a:xfrm`),e.leafNode(`a:off`,{x:0,y:0}),e.leafNode(`a:ext`,{cx:0,cy:0}),e.closeNode(),e.openNode(`a:prstGeom`,{prst:`rect`}),e.leafNode(`a:avLst`),e.closeNode(),e.leafNode(`a:noFill`),e.openNode(`a:ln`),e.leafNode(`a:noFill`),e.closeNode(),e.openNode(`a:extLst`),e.openNode(`a:ext`,{uri:`{909E8E84-426E-40DD-AFC4-6F175D3DCCD1}`}),e.openNode(`a14:hiddenFill`,{"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`}),e.openNode(`a:solidFill`),e.leafNode(`a:srgbClr`,{val:`F0F0F0`}),e.closeNode(),e.closeNode(),e.closeNode(),e.openNode(`a:ext`,{uri:`{91240B29-F687-4F45-9708-019B960494DF}`}),e.openNode(`a14:hiddenLine`,{w:9525,"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`}),e.openNode(`a:solidFill`),e.leafNode(`a:srgbClr`,{val:`000000`}),e.closeNode(),e.leafNode(`a:miter`,{lim:8e5}),e.leafNode(`a:headEnd`),e.leafNode(`a:tailEnd`),e.closeNode(),e.closeNode(),e.closeNode(),e.closeNode(),e.openNode(`xdr:txBody`),e.leafNode(`a:bodyPr`,{vertOverflow:`clip`,wrap:`square`,lIns:18288,tIns:18288,rIns:0,bIns:18288,anchor:`ctr`,upright:1}),e.leafNode(`a:lstStyle`),e.openNode(`a:p`),e.openNode(`a:pPr`,{algn:`l`,rtl:0}),e.leafNode(`a:defRPr`,{sz:1e3}),e.closeNode(),e.openNode(`a:r`),e.openNode(`a:rPr`,{lang:`en-US`,sz:800,b:0,i:0,u:`none`,strike:`noStrike`,baseline:0}),e.openNode(`a:solidFill`),e.leafNode(`a:srgbClr`,{val:`000000`}),e.closeNode(),e.leafNode(`a:latin`,{typeface:`Tahoma`,pitchFamily:2,charset:0}),e.leafNode(`a:ea`,{typeface:`Tahoma`,pitchFamily:2,charset:0}),e.leafNode(`a:cs`,{typeface:`Tahoma`,pitchFamily:2,charset:0}),e.closeNode(),e.openNode(`a:t`),e.writeText(t.text??``),e.closeNode(),e.closeNode(),e.closeNode(),e.closeNode(),e.closeNode())}},ps=class extends ts{constructor(){super(),this.map={"xdr:from":new ns({tag:`xdr:from`}),"xdr:to":new ns({tag:`xdr:to`}),"xdr:pic":new ds,"xdr:sp":new fs,"xdr:clientData":new Dr({tag:`xdr:clientData`})}}get tag(){return`xdr:twoCellAnchor`}prepare(e,t){e.picture&&this.map[`xdr:pic`].prepare(e.picture,t)}render(e,t){let n=!!t.alternateContent;n&&(e.openNode(`mc:AlternateContent`,{"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`}),e.openNode(`mc:Choice`,{Requires:t.alternateContent?.requires,...t.alternateContent?.requires===`a14`?{"xmlns:a14":`http://schemas.microsoft.com/office/drawing/2010/main`}:{}})),e.openNode(this.tag,{editAs:t.range.editAs??`oneCell`}),this.map[`xdr:from`].render(e,t.range.tl),this.map[`xdr:to`].render(e,t.range.br),t.picture?this.map[`xdr:pic`].render(e,t.picture):t.shape&&this.map[`xdr:sp`].render(e,t.shape),this.map[`xdr:clientData`].render(e,{}),e.closeNode(),n&&(e.closeNode(),e.leafNode(`mc:Fallback`),e.closeNode())}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.range.tl=this.map[`xdr:from`].model,this.model.range.br=this.map[`xdr:to`].model,this.model.picture=this.map[`xdr:pic`].model,!1;default:return!0}}reconcile(e,t){e.medium=this.reconcilePicture(e.picture,t)}};let ms=9525;var hs=class extends j{constructor(e){super(),this.tag=e.tag,this.map={},this.model={width:0,height:0}}render(e,t){e.openNode(this.tag);let n=Math.floor(t.width*ms),r=Math.floor(t.height*ms);e.addAttribute(`cx`,n),e.addAttribute(`cy`,r),e.closeNode()}parseOpen(e){return e.name===this.tag?(this.model={width:parseInt(e.attributes.cx??`0`,10)/ms,height:parseInt(e.attributes.cy??`0`,10)/ms},!0):!1}parseText(e){}parseClose(e){return!1}},gs=class extends ts{constructor(){super(),this.map={"xdr:from":new ns({tag:`xdr:from`}),"xdr:ext":new hs({tag:`xdr:ext`}),"xdr:pic":new ds,"xdr:clientData":new Dr({tag:`xdr:clientData`})}}get tag(){return`xdr:oneCellAnchor`}prepare(e,t){this.map[`xdr:pic`].prepare(e.picture,t)}render(e,t){e.openNode(this.tag,{editAs:t.range.editAs??`oneCell`}),this.map[`xdr:from`].render(e,t.range.tl),this.map[`xdr:ext`].render(e,t.range.ext),this.map[`xdr:pic`].render(e,t.picture),this.map[`xdr:clientData`].render(e,{}),e.closeNode()}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.range.tl=this.map[`xdr:from`].model,this.model.range.ext=this.map[`xdr:ext`].model,this.model.picture=this.map[`xdr:pic`].model,!1;default:return!0}}reconcile(e,t){e.medium=this.reconcilePicture(e.picture,t)}};function _s(e){return(typeof e.range==`string`?S.decode(e.range):e.range).br?`xdr:twoCellAnchor`:`xdr:oneCellAnchor`}var vs=class e extends j{constructor(){super(),this.map={"xdr:twoCellAnchor":new ps,"xdr:oneCellAnchor":new gs},this.model={anchors:[]}}prepare(e){e.anchors.forEach((e,t)=>{e.anchorType=_s(e),this.map[e.anchorType].prepare(e,{index:t})})}get tag(){return`xdr:wsDr`}render(t,n){let r=n||this.model;t.openXml(k.StdDocAttributes),t.openNode(this.tag,e.DRAWING_ATTRIBUTES),r.anchors.forEach(e=>{this.map[e.anchorType].render(t,e)}),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset(),this.model={anchors:[]};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.anchors.push(this.parser.model),this.parser=void 0),!0;switch(e){case this.tag:return!1;default:return!0}}reconcile(e,t){e.anchors.forEach(e=>{e.br?this.map[`xdr:twoCellAnchor`].reconcile(e,t):this.map[`xdr:oneCellAnchor`].reconcile(e,t)})}static{this.DRAWING_ATTRIBUTES={"xmlns:xdr":`http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing`,"xmlns:a":`http://schemas.openxmlformats.org/drawingml/2006/main`}}},ys=class extends j{constructor(){super(),this.model={val:``}}get tag(){return`customFilter`}render(e,t){e.leafNode(this.tag,{val:t.val,operator:t.operator})}parseOpen(e){return e.name===this.tag?(this.model={val:e.attributes.val,operator:e.attributes.operator},!0):!1}parseText(){}parseClose(){return!1}},bs=class extends j{constructor(){super(),this.model={val:``}}get tag(){return`filter`}render(e,t){e.leafNode(this.tag,{val:t.val})}parseOpen(e){return e.name===this.tag?(this.model={val:e.attributes.val},!0):!1}parseText(){}parseClose(){return!1}},xs=class extends j{constructor(){super(),this.map={customFilters:new M({tag:`customFilters`,count:!1,empty:!0,childXform:new ys}),filters:new M({tag:`filters`,count:!1,empty:!0,childXform:new bs})},this.model={filterButton:!1}}get tag(){return`filterColumn`}prepare(e,t){e.colId=t.index.toString()}render(e,t){if(t.customFilters){e.openNode(this.tag,{colId:t.colId,hiddenButton:t.filterButton?`0`:`1`}),this.map.customFilters.render(e,t.customFilters),e.closeNode();return}e.leafNode(this.tag,{colId:t.colId,hiddenButton:t.filterButton?`0`:`1`})}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;let{attributes:t}=e;switch(e.name){case this.tag:return this.model={filterButton:t.hiddenButton===`0`},!0;case`dynamicFilter`:return!0;default:if(this.parser=this.map[e.name],this.parser)return this.parseOpen(e),!0;throw new _(`filterColumn`,`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(){}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.customFilters=this.map.customFilters.model,!1;default:return!0}}},Ss=class extends j{constructor(){super(),this.map={filterColumn:new xs},this.model={autoFilterRef:``,columns:[]}}get tag(){return`autoFilter`}prepare(e){e.columns.forEach((e,t)=>{this.map.filterColumn.prepare(e,{index:t})})}render(e,t){e.openNode(this.tag,{ref:t.autoFilterRef}),t.columns.forEach(t=>{this.map.filterColumn.render(e,t)}),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:return this.model={autoFilterRef:e.attributes.ref,columns:[]},!0;default:if(this.parser=this.map[e.name],this.parser)return this.parseOpen(e),!0;throw new _(`autoFilter`,`Unexpected xml node in parseOpen: ${JSON.stringify(e)}`)}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.columns.push(this.parser.model),this.parser=void 0),!0;switch(e){case this.tag:return!1;default:throw new _(`autoFilter`,`Unexpected xml node in parseClose: ${e}`)}}},Cs=class extends j{constructor(){super(),this._childText=``,this.model={name:``}}get tag(){return`tableColumn`}prepare(e,t){e.id=t.index+1}_renderAttributes(e){return{id:e.id.toString(),name:vt(e.name),totalsRowLabel:e.totalsRowLabel?vt(e.totalsRowLabel):void 0,totalsRowFunction:e.totalsRowFunction===`none`?void 0:e.totalsRowFunction,dxfId:e.dxfId}}render(e,t){t.calculatedColumnFormula||t.totalsRowFormula?(e.openNode(this.tag,this._renderAttributes(t)),t.calculatedColumnFormula&&e.leafNode(`calculatedColumnFormula`,void 0,t.calculatedColumnFormula),t.totalsRowFormula&&e.leafNode(`totalsRowFormula`,void 0,t.totalsRowFormula),e.closeNode()):e.leafNode(this.tag,this._renderAttributes(t))}parseOpen(e){if(e.name===this.tag){let{attributes:t}=e;return this.model={name:mt(t.name),totalsRowLabel:t.totalsRowLabel?mt(t.totalsRowLabel):void 0,totalsRowFunction:t.totalsRowFunction,dxfId:t.dxfId},!0}return(e.name===`calculatedColumnFormula`||e.name===`totalsRowFormula`)&&(this._childTag=e.name,this._childText=``),!0}parseText(e){this._childTag&&(this._childText+=e)}parseClose(e){return e===this.tag?!1:(this._childTag&&e===this._childTag&&(this.model[this._childTag]=this._childText,this._childTag=void 0),!0)}},ws=class extends j{constructor(){super(),this.model={theme:null,showFirstColumn:!1,showLastColumn:!1,showRowStripes:!1,showColumnStripes:!1}}get tag(){return`tableStyleInfo`}render(e,t){e.leafNode(this.tag,{name:t.theme?t.theme:void 0,showFirstColumn:t.showFirstColumn?`1`:`0`,showLastColumn:t.showLastColumn?`1`:`0`,showRowStripes:t.showRowStripes?`1`:`0`,showColumnStripes:t.showColumnStripes?`1`:`0`})}parseOpen(e){if(e.name===this.tag){let{attributes:t}=e;return this.model={theme:t.name?t.name:null,showFirstColumn:t.showFirstColumn===`1`,showLastColumn:t.showLastColumn===`1`,showRowStripes:t.showRowStripes===`1`,showColumnStripes:t.showColumnStripes===`1`},!0}return!1}parseText(){}parseClose(){return!1}},Ts=class e extends j{constructor(){super(),this.map={autoFilter:new Ss,tableColumns:new M({tag:`tableColumns`,count:!0,empty:!0,childXform:new Cs}),tableStyleInfo:new ws},this.model={id:0,name:``,tableRef:``,columns:[]}}prepare(e,t){this.map.autoFilter.prepare(e),this.map.tableColumns.prepare(e.columns,t)}get tag(){return`table`}render(t,n){t.openXml(k.StdDocAttributes),t.openNode(this.tag,{...e.TABLE_ATTRIBUTES,id:n.id,name:n.name,displayName:n.displayName||n.name,ref:n.tableRef,totalsRowCount:n.totalsRow?`1`:void 0,headerRowCount:n.headerRow?void 0:`0`}),this.map.autoFilter.render(t,n),this.map.tableColumns.render(t,n.columns),this.map.tableStyleInfo.render(t,n.style),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;let{name:t,attributes:n}=e;switch(t){case this.tag:this.reset(),this.model={name:n.name,displayName:n.displayName||n.name,tableRef:n.ref,totalsRow:n.totalsRowCount===`1`,headerRow:n.headerRowCount!==`0`};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.columns=this.map.tableColumns.model,this.map.autoFilter.model&&(this.model.autoFilterRef=this.map.autoFilter.model.autoFilterRef,this.map.autoFilter.model.columns.forEach((e,t)=>{this.model.columns[t].filterButton=e.filterButton})),this.model.style=this.map.tableStyleInfo.model,!1;default:return!0}}reconcile(e,t){e.tableRef&&!e.ref&&(e.ref=e.tableRef),e.rows||=[],e.columns.forEach(e=>{e.dxfId!==void 0&&(e.style=t.styles.getDxfStyle(e.dxfId))})}static{this.TABLE_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`}}};function Es(e){return isNaN(e.getTime())?``:e.toISOString().replace(/\.\d{3}Z$/,``)}function Ds(e){let t=D(e.name),n=e.numFmtId??`0`,r=ks(e.extraAttrs),i=e.fieldGroupXml?`\n ${e.fieldGroupXml}`:``;if(e.sharedItems===null){if(e.isLoaded)return i?`<cacheField name="${t}" numFmtId="${n}"${r}>${i}\n </cacheField>`:`<cacheField name="${t}" numFmtId="${n}"${r} />`;let a;return a=e.minValue!==void 0&&e.maxValue!==void 0?` containsSemiMixedTypes="0" containsString="0" containsNumber="1"${e.containsInteger?` containsInteger="1"`:``} minValue="${e.minValue}" maxValue="${e.maxValue}"`:``,`<cacheField name="${t}" numFmtId="${n}"${r}>
11
11
  <sharedItems${a} />${i}
12
12
  </cacheField>`}if(e.isLoaded&&e.sharedItems.length===0)return`<cacheField name="${t}" numFmtId="${n}"${r}>
13
- <sharedItems${Ds(e)} />${i}
14
- </cacheField>`;if(e.isLoaded){let a=Ts(e.sharedItems);return`<cacheField name="${t}" numFmtId="${n}"${r}>
15
- <sharedItems${Ds(e)} count="${e.sharedItems.length}">
13
+ <sharedItems${As(e)} />${i}
14
+ </cacheField>`;if(e.isLoaded){let a=Os(e.sharedItems);return`<cacheField name="${t}" numFmtId="${n}"${r}>
15
+ <sharedItems${As(e)} count="${e.sharedItems.length}">
16
16
  ${a}
17
17
  </sharedItems>${i}
18
- </cacheField>`}let a=!1,o=!1,s=!1,c=!1,l=!1,u=!1,d=!0,f=1/0,p=-1/0;for(let t of e.sharedItems)t===null?l=!0:t instanceof cn?u=!0:typeof t==`string`?a=!0:typeof t==`number`?Number.isFinite(t)?(o=!0,t<f&&(f=t),t>p&&(p=t),Number.isInteger(t)||(d=!1)):l=!0:typeof t==`boolean`?s=!0:t instanceof Date&&(c=!0);let m=[];a||(m.push(`containsSemiMixedTypes="0"`),m.push(`containsString="0"`)),(a?1:0)+(o?1:0)+(s?1:0)+(c?1:0)+(u?1:0)>1&&m.push(`containsMixedTypes="1"`),o&&(m.push(`containsNumber="1"`),d&&m.push(`containsInteger="1"`),m.push(`minValue="${f}"`),m.push(`maxValue="${p}"`)),c&&m.push(`containsDate="1"`),l&&m.push(`containsBlank="1"`);let h=Ts(e.sharedItems);return`<cacheField name="${t}" numFmtId="${n}"${r}>
18
+ </cacheField>`}let a=!1,o=!1,s=!1,c=!1,l=!1,u=!1,d=!0,f=1/0,p=-1/0;for(let t of e.sharedItems)t===null?l=!0:t instanceof cn?u=!0:typeof t==`string`?a=!0:typeof t==`number`?Number.isFinite(t)?(o=!0,t<f&&(f=t),t>p&&(p=t),Number.isInteger(t)||(d=!1)):l=!0:typeof t==`boolean`?s=!0:t instanceof Date&&(c=!0);let m=[];a||(m.push(`containsSemiMixedTypes="0"`),m.push(`containsString="0"`)),(a?1:0)+(o?1:0)+(s?1:0)+(c?1:0)+(u?1:0)>1&&m.push(`containsMixedTypes="1"`),o&&(m.push(`containsNumber="1"`),d&&m.push(`containsInteger="1"`),m.push(`minValue="${f}"`),m.push(`maxValue="${p}"`)),c&&m.push(`containsDate="1"`),l&&m.push(`containsBlank="1"`);let h=Os(e.sharedItems);return`<cacheField name="${t}" numFmtId="${n}"${r}>
19
19
  <sharedItems${m.length>0?` ${m.join(` `)}`:``} count="${e.sharedItems.length}">
20
20
  ${h}
21
21
  </sharedItems>${i}
22
- </cacheField>`}function Ts(e){let t=[];for(let n of e)n===null?t.push(`<m />`):n instanceof cn?t.push(`<e v="${E(n.code)}" />`):typeof n==`number`?Number.isFinite(n)?t.push(`<n v="${n}" />`):t.push(`<m />`):typeof n==`boolean`?t.push(`<b v="${n?`1`:`0`}" />`):n instanceof Date?t.push(`<d v="${Cs(n)}" />`):t.push(`<s v="${E(n)}" />`);return t.join(``)}function Es(e){return e?Object.entries(e).map(([e,t])=>` ${e}="${E(t)}"`).join(``):``}function Ds(e){let t=[];return e.containsSemiMixedTypes!==void 0&&t.push(`containsSemiMixedTypes="${e.containsSemiMixedTypes}"`),e.containsNonDate!==void 0&&t.push(`containsNonDate="${e.containsNonDate}"`),e.containsString!==void 0&&t.push(`containsString="${e.containsString}"`),e.containsBlank!==void 0&&t.push(`containsBlank="${e.containsBlank}"`),e.containsMixedTypes!==void 0&&t.push(`containsMixedTypes="${e.containsMixedTypes}"`),e.containsNumber!==void 0&&t.push(`containsNumber="${e.containsNumber}"`),e.containsInteger!==void 0&&t.push(`containsInteger="${e.containsInteger}"`),e.minValue!==void 0&&t.push(`minValue="${e.minValue}"`),e.maxValue!==void 0&&t.push(`maxValue="${e.maxValue}"`),e.containsDate!==void 0&&t.push(`containsDate="${e.containsDate}"`),t.length>0?` ${t.join(` `)}`:``}let Os=new Set([`xmlns`,`xmlns:r`,`count`]);var ks=class e extends j{constructor(){super(),this.model=null,this.currentRecord=null}get tag(){return`pivotCacheRecords`}reset(){this.model=null,this.currentRecord=null}render(e,t){`isLoaded`in t&&t.isLoaded||!(`source`in t)?this.renderLoaded(e,t):this.renderNew(e,t)}renderNew(t,n){let{source:r,cacheFields:i}=n,a=r.getSheetValues().slice(2).filter(Array.isArray);t.openXml(k.StdDocAttributes),t.openNode(this.tag,{...e.PIVOT_CACHE_RECORDS_ATTRIBUTES,count:a.length}),t.writeXml(this.renderTableNew(a,i)),t.closeNode()}renderLoaded(t,n){t.openXml(k.StdDocAttributes);let r={xmlns:e.PIVOT_CACHE_RECORDS_ATTRIBUTES.xmlns,"xmlns:r":e.PIVOT_CACHE_RECORDS_ATTRIBUTES[`xmlns:r`]};if(n.extraRootAttrs)for(let[e,t]of Object.entries(n.extraRootAttrs))r[e]=t;else r[`xmlns:mc`]=e.PIVOT_CACHE_RECORDS_ATTRIBUTES[`xmlns:mc`],r[`mc:Ignorable`]=e.PIVOT_CACHE_RECORDS_ATTRIBUTES[`mc:Ignorable`],r[`xmlns:xr`]=e.PIVOT_CACHE_RECORDS_ATTRIBUTES[`xmlns:xr`];r.count=n.records.length,t.openNode(this.tag,r);for(let e of n.records){t.writeXml(`
22
+ </cacheField>`}function Os(e){let t=[];for(let n of e)n===null?t.push(`<m />`):n instanceof cn?t.push(`<e v="${D(n.code)}" />`):typeof n==`number`?Number.isFinite(n)?t.push(`<n v="${n}" />`):t.push(`<m />`):typeof n==`boolean`?t.push(`<b v="${n?`1`:`0`}" />`):n instanceof Date?t.push(`<d v="${Es(n)}" />`):t.push(`<s v="${D(n)}" />`);return t.join(``)}function ks(e){return e?Object.entries(e).map(([e,t])=>` ${e}="${D(t)}"`).join(``):``}function As(e){let t=[];return e.containsSemiMixedTypes!==void 0&&t.push(`containsSemiMixedTypes="${e.containsSemiMixedTypes}"`),e.containsNonDate!==void 0&&t.push(`containsNonDate="${e.containsNonDate}"`),e.containsString!==void 0&&t.push(`containsString="${e.containsString}"`),e.containsBlank!==void 0&&t.push(`containsBlank="${e.containsBlank}"`),e.containsMixedTypes!==void 0&&t.push(`containsMixedTypes="${e.containsMixedTypes}"`),e.containsNumber!==void 0&&t.push(`containsNumber="${e.containsNumber}"`),e.containsInteger!==void 0&&t.push(`containsInteger="${e.containsInteger}"`),e.minValue!==void 0&&t.push(`minValue="${e.minValue}"`),e.maxValue!==void 0&&t.push(`maxValue="${e.maxValue}"`),e.containsDate!==void 0&&t.push(`containsDate="${e.containsDate}"`),t.length>0?` ${t.join(` `)}`:``}let js=new Set([`xmlns`,`xmlns:r`,`count`]);var Ms=class e extends j{constructor(){super(),this.model=null,this.currentRecord=null}get tag(){return`pivotCacheRecords`}reset(){this.model=null,this.currentRecord=null}render(e,t){`isLoaded`in t&&t.isLoaded||!(`source`in t)?this.renderLoaded(e,t):this.renderNew(e,t)}renderNew(t,n){let{source:r,cacheFields:i}=n,a=r.getSheetValues().slice(2).filter(Array.isArray);t.openXml(k.StdDocAttributes),t.openNode(this.tag,{...e.PIVOT_CACHE_RECORDS_ATTRIBUTES,count:a.length}),t.writeXml(this.renderTableNew(a,i)),t.closeNode()}renderLoaded(t,n){t.openXml(k.StdDocAttributes);let r={xmlns:e.PIVOT_CACHE_RECORDS_ATTRIBUTES.xmlns,"xmlns:r":e.PIVOT_CACHE_RECORDS_ATTRIBUTES[`xmlns:r`]};if(n.extraRootAttrs)for(let[e,t]of Object.entries(n.extraRootAttrs))r[e]=t;else r[`xmlns:mc`]=e.PIVOT_CACHE_RECORDS_ATTRIBUTES[`xmlns:mc`],r[`mc:Ignorable`]=e.PIVOT_CACHE_RECORDS_ATTRIBUTES[`mc:Ignorable`],r[`xmlns:xr`]=e.PIVOT_CACHE_RECORDS_ATTRIBUTES[`xmlns:xr`];r.count=n.records.length,t.openNode(this.tag,r);for(let e of n.records){t.writeXml(`
23
23
  <r>`);for(let n of e)t.writeXml(`
24
24
  `),t.writeXml(this.renderRecordValue(n));t.writeXml(`
25
- </r>`)}t.closeNode()}renderRecordValue(e){switch(e.type){case`x`:return`<x v="${e.value}" />`;case`n`:return Number.isFinite(e.value)?`<n v="${e.value}" />`:`<m />`;case`s`:return`<s v="${E(e.value)}" />`;case`b`:return`<b v="${e.value?`1`:`0`}" />`;case`m`:return`<m />`;case`d`:return`<d v="${Cs(e.value)}" />`;case`e`:return`<e v="${E(e.value)}" />`;default:{let t=e;throw Error(`Unhandled record value type: ${t.type}`)}}}renderTableNew(e,t){let n=[];for(let r of e){let e=r.slice(1);n.push(`
25
+ </r>`)}t.closeNode()}renderRecordValue(e){switch(e.type){case`x`:return`<x v="${e.value}" />`;case`n`:return Number.isFinite(e.value)?`<n v="${e.value}" />`:`<m />`;case`s`:return`<s v="${D(e.value)}" />`;case`b`:return`<b v="${e.value?`1`:`0`}" />`;case`m`:return`<m />`;case`d`:return`<d v="${Es(e.value)}" />`;case`e`:return`<e v="${D(e.value)}" />`;default:{let t=e;throw Error(`Unhandled record value type: ${t.type}`)}}}renderTableNew(e,t){let n=[];for(let r of e){let e=r.slice(1);n.push(`
26
26
  <r>`);let i=Math.min(e.length,t.length);for(let r=0;r<i;r++)n.push(`
27
27
  `),n.push(this.renderCellNew(e[r],t[r].sharedItems));for(let e=i;e<t.length;e++)n.push(`
28
28
  <m />`);n.push(`
29
- </r>`)}return n.join(``)}renderCellNew(e,t){if(e==null||typeof e==`number`&&!Number.isFinite(e)){if(t===null)return`<m />`;let e=t.indexOf(null);return e>=0?`<x v="${e}" />`:`<m />`}if(t===null)return e instanceof cn?`<e v="${E(e.code)}" />`:typeof e==`boolean`?`<b v="${e?`1`:`0`}" />`:e instanceof Date?`<d v="${Cs(e)}" />`:Number.isFinite(e)?`<n v="${e}" />`:`<s v="${E(String(e))}" />`;let n=As(t,e);if(n<0)throw new x(`${JSON.stringify(e)} not in sharedItems ${JSON.stringify(t)}`);return`<x v="${n}" />`}parseOpen(e){let{name:t,attributes:n}=e;switch(t){case this.tag:{this.reset();let e={};for(let[t,r]of Object.entries(n))Os.has(t)||(e[t]=String(r));this.model={records:[],count:parseInt(n.count??`0`,10),isLoaded:!0,extraRootAttrs:Object.keys(e).length>0?e:void 0};break}case`r`:this.currentRecord=[];break;case`x`:this.currentRecord&&this.currentRecord.push({type:`x`,value:parseInt(n.v??`0`,10)});break;case`n`:this.currentRecord&&(n.v===void 0||n.v===``?this.currentRecord.push({type:`m`}):this.currentRecord.push({type:`n`,value:parseFloat(n.v)}));break;case`s`:this.currentRecord&&this.currentRecord.push({type:`s`,value:n.v??``});break;case`b`:this.currentRecord&&this.currentRecord.push({type:`b`,value:n.v===`1`});break;case`m`:this.currentRecord&&this.currentRecord.push({type:`m`});break;case`d`:if(this.currentRecord)if(!n.v)this.currentRecord.push({type:`m`});else{let e=pt(n.v);isNaN(e.getTime())?this.currentRecord.push({type:`m`}):this.currentRecord.push({type:`d`,value:e})}break;case`e`:this.currentRecord&&this.currentRecord.push({type:`e`,value:n.v??``});break}return!0}parseText(e){}parseClose(e){switch(e){case this.tag:return!1;case`r`:this.model&&this.currentRecord&&(this.model.records.push(this.currentRecord),this.currentRecord=null);break}return!0}static{this.PIVOT_CACHE_RECORDS_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`,"mc:Ignorable":`xr`,"xmlns:xr":`http://schemas.microsoft.com/office/spreadsheetml/2014/revision`}}};function As(e,t){if(t instanceof Date){let n=t.getTime();for(let t=0;t<e.length;t++){let r=e[t];if(r instanceof Date&&r.getTime()===n)return t}return-1}if(t instanceof cn){for(let n=0;n<e.length;n++){let r=e[n];if(r instanceof cn&&r.code===t.code)return n}return-1}return e.indexOf(t)}var js=class{constructor(e){this.active=!1,this.depth=0,this.buffer=[],this.lastOpenIndex=-1,this.rootTag=e}start(e){this.active=!0,this.depth=0;let t=Ms(e);this.buffer=[`<${this.rootTag}${t?` `+t:``}>`]}startAs(e,t){this.rootTag=e,this.start(t)}reset(){this.active=!1,this.depth=0,this.buffer.length=0,this.lastOpenIndex=-1}feedOpen(e,t){let n=Ms(t);this.buffer.push(`<${e}${n?` `+n:``}>`),this.depth++,this.lastOpenIndex=this.buffer.length-1}feedText(e){this.buffer.push(E(e)),this.lastOpenIndex=-1}feedClose(e){if(e===this.rootTag&&this.depth===0)return this.buffer.push(`</${e}>`),this.active=!1,this.lastOpenIndex=-1,!0;if(this.depth>0&&this.depth--,this.lastOpenIndex>=0&&this.lastOpenIndex===this.buffer.length-1){let e=this.buffer[this.lastOpenIndex];return this.buffer[this.lastOpenIndex]=e.slice(0,-1)+` />`,this.lastOpenIndex=-1,!1}return this.lastOpenIndex=-1,this.buffer.push(`</${e}>`),!1}get result(){return this.buffer.join(``)}};function Ms(e){if(!e)return``;let t=Object.entries(e);return t.length===0?``:t.filter(([,e])=>e!=null).map(([e,t])=>`${e}="${E(String(t))}"`).join(` `)}let Ns=new Set([`name`,`numFmtId`]);var Ps=class extends j{constructor(){super(),this.inSharedItems=!1,this.fieldGroupCollector=new js(`fieldGroup`),this.model=null}get tag(){return`cacheField`}reset(){this.model=null,this.inSharedItems=!1,this.fieldGroupCollector.reset()}parseOpen(e){let{name:t,attributes:n}=e;if(this.fieldGroupCollector.active)return this.fieldGroupCollector.feedOpen(t,n),!0;switch(t){case`cacheField`:{let e={};for(let[t,r]of Object.entries(n))Ns.has(t)||(e[t]=String(r));this.model={name:n.name??``,sharedItems:null,numFmtId:n.numFmtId,isLoaded:!0,extraAttrs:Object.keys(e).length>0?e:void 0};break}case`fieldGroup`:this.model&&this.fieldGroupCollector.start(n);break;case`sharedItems`:if(this.inSharedItems=!0,this.model){if(n.containsNumber!==void 0&&(this.model.containsNumber=n.containsNumber),n.containsInteger!==void 0&&(this.model.containsInteger=n.containsInteger),n.minValue!==void 0){let e=parseFloat(n.minValue);Number.isFinite(e)&&(this.model.minValue=e)}if(n.maxValue!==void 0){let e=parseFloat(n.maxValue);Number.isFinite(e)&&(this.model.maxValue=e)}n.containsSemiMixedTypes!==void 0&&(this.model.containsSemiMixedTypes=n.containsSemiMixedTypes),n.containsNonDate!==void 0&&(this.model.containsNonDate=n.containsNonDate),n.containsString!==void 0&&(this.model.containsString=n.containsString),n.containsBlank!==void 0&&(this.model.containsBlank=n.containsBlank),n.containsDate!==void 0&&(this.model.containsDate=n.containsDate),n.containsMixedTypes!==void 0&&(this.model.containsMixedTypes=n.containsMixedTypes),this.model.sharedItems=[]}break;case`s`:case`n`:case`b`:case`e`:case`m`:case`d`:this.inSharedItems&&this.model&&this.model.sharedItems!==null&&this.model.sharedItems.push(Fs(t,n));break}return!0}parseText(e){this.fieldGroupCollector.active&&this.fieldGroupCollector.feedText(e)}parseClose(e){if(this.fieldGroupCollector.active)return this.fieldGroupCollector.feedClose(e)&&(this.model&&(this.model.fieldGroupXml=this.fieldGroupCollector.result),this.fieldGroupCollector.reset()),!0;switch(e){case`cacheField`:return!1;case`sharedItems`:this.inSharedItems=!1;break}return!0}};function Fs(e,t){switch(e){case`s`:return t.v??``;case`n`:return t.v===void 0||t.v===``?null:parseFloat(t.v);case`b`:return t.v===`1`;case`e`:return new cn(t.v??``);case`m`:return null;case`d`:{if(!t.v)return null;let e=pt(t.v);return isNaN(e.getTime())?null:e}default:return null}}let Is=new Set([`xmlns`,`xmlns:r`,`r:id`,`refreshOnLoad`,`createdVersion`,`refreshedVersion`,`minRefreshableVersion`,`recordCount`,`backgroundQuery`,`supportSubquery`,`supportAdvancedDrill`]);var Ls=class e extends j{constructor(){super(),this.currentCacheField=null,this.inCacheFields=!1,this.inCacheSource=!1,this.extLstCollector=new js(`extLst`),this.unknownCollector=new js(``),this.unknownElementsXmlParts=[],this.cacheSourceChildCollector=new js(``),this.cacheSourceXmlParts=[],this.model=null}get tag(){return`pivotCacheDefinition`}reset(){this.model=null,this.currentCacheField=null,this.inCacheFields=!1,this.inCacheSource=!1,this.extLstCollector.reset(),this.unknownCollector.reset(),this.unknownElementsXmlParts=[],this.cacheSourceChildCollector.reset(),this.cacheSourceXmlParts=[]}render(e,t){`isLoaded`in t&&t.isLoaded||!(`source`in t)?this.renderLoaded(e,t):this.renderNew(e,t)}renderNew(t,n){let{source:r,cacheFields:i}=n,a=r.getSheetValues().slice(2).filter(Array.isArray).length;t.openXml(k.StdDocAttributes),t.openNode(this.tag,{...e.PIVOT_CACHE_DEFINITION_ATTRIBUTES,"r:id":`rId1`,refreshOnLoad:`1`,createdVersion:`8`,refreshedVersion:`8`,minRefreshableVersion:`3`,recordCount:a}),t.openNode(`cacheSource`,{type:`worksheet`});let o=r.tableName?{name:r.tableName}:{ref:r.dimensions.shortRange,sheet:r.name};t.leafNode(`worksheetSource`,o),t.closeNode(),t.openNode(`cacheFields`,{count:i.length}),t.writeXml(e.renderCacheFieldsXml(i)),t.closeNode(),t.closeNode()}renderLoaded(t,n){let{cacheFields:r,sourceRef:i,sourceSheet:a,sourceTableName:o,recordCount:s}=n;t.openXml(k.StdDocAttributes);let c={...e.PIVOT_CACHE_DEFINITION_ATTRIBUTES,"r:id":n.rId??`rId1`};if(n.refreshOnLoad&&(c.refreshOnLoad=n.refreshOnLoad),c.createdVersion=n.createdVersion??`8`,c.refreshedVersion=n.refreshedVersion??`8`,c.minRefreshableVersion=n.minRefreshableVersion??`3`,s!==void 0&&(c.recordCount=s),n.backgroundQuery&&(c.backgroundQuery=n.backgroundQuery),n.supportSubquery&&(c.supportSubquery=n.supportSubquery),n.supportAdvancedDrill&&(c.supportAdvancedDrill=n.supportAdvancedDrill),n.extraRootAttrs)for(let[e,t]of Object.entries(n.extraRootAttrs))c[e]=t;if(t.openNode(this.tag,c),t.openNode(`cacheSource`,{type:n.cacheSourceType??`worksheet`}),!n.cacheSourceType||n.cacheSourceType===`worksheet`){let e=o?{name:o}:{ref:i,sheet:a};n.worksheetSourceRId&&(e[`r:id`]=n.worksheetSourceRId),Object.values(e).some(e=>e!==void 0)&&t.leafNode(`worksheetSource`,e)}n.cacheSourceXml&&t.writeXml(n.cacheSourceXml),t.closeNode(),t.openNode(`cacheFields`,{count:r.length}),t.writeXml(e.renderCacheFieldsXml(r)),t.closeNode(),n.unknownElementsXml&&t.writeXml(n.unknownElementsXml),n.extLstXml&&t.writeXml(n.extLstXml),t.closeNode()}parseOpen(e){let{name:t,attributes:n}=e;if(this.extLstCollector.active)return this.extLstCollector.feedOpen(t,n),!0;if(this.unknownCollector.active)return this.unknownCollector.feedOpen(t,n),!0;if(this.cacheSourceChildCollector.active)return this.cacheSourceChildCollector.feedOpen(t,n),!0;if(this.currentCacheField)return this.currentCacheField.parseOpen(e),!0;switch(t){case this.tag:{this.reset();let e={};for(let[t,r]of Object.entries(n))Is.has(t)||(e[t]=String(r));this.model={cacheFields:[],rId:n[`r:id`],refreshOnLoad:n.refreshOnLoad,createdVersion:n.createdVersion,refreshedVersion:n.refreshedVersion,minRefreshableVersion:n.minRefreshableVersion,recordCount:n.recordCount?parseInt(n.recordCount,10):void 0,backgroundQuery:n.backgroundQuery,supportSubquery:n.supportSubquery,supportAdvancedDrill:n.supportAdvancedDrill,extraRootAttrs:Object.keys(e).length>0?e:void 0,isLoaded:!0};break}case`cacheSource`:this.inCacheSource=!0,this.model&&(this.model.cacheSourceType=n.type);break;case`worksheetSource`:this.inCacheSource&&this.model&&(this.model.sourceRef=n.ref,this.model.sourceSheet=n.sheet,this.model.sourceTableName=n.name,n[`r:id`]&&(this.model.worksheetSourceRId=n[`r:id`]));break;case`cacheFields`:this.inCacheFields=!0;break;case`cacheField`:this.inCacheFields&&(this.currentCacheField=new Ps,this.currentCacheField.parseOpen(e));break;case`extLst`:this.model&&this.extLstCollector.start(n);break;default:if(this.inCacheSource&&this.model){this.cacheSourceChildCollector.startAs(t,n);break}this.model&&this.unknownCollector.startAs(t,n);break}return!0}parseText(e){if(this.extLstCollector.active){this.extLstCollector.feedText(e);return}if(this.unknownCollector.active){this.unknownCollector.feedText(e);return}if(this.cacheSourceChildCollector.active){this.cacheSourceChildCollector.feedText(e);return}this.currentCacheField&&this.currentCacheField.parseText(e)}parseClose(e){if(this.extLstCollector.active)return this.extLstCollector.feedClose(e)&&(this.model&&(this.model.extLstXml=this.extLstCollector.result),this.extLstCollector.reset()),!0;if(this.unknownCollector.active)return this.unknownCollector.feedClose(e)&&(this.unknownElementsXmlParts.push(this.unknownCollector.result),this.unknownCollector.reset()),!0;if(this.cacheSourceChildCollector.active)return this.cacheSourceChildCollector.feedClose(e)&&(this.cacheSourceXmlParts.push(this.cacheSourceChildCollector.result),this.cacheSourceChildCollector.reset()),!0;if(this.currentCacheField)return this.currentCacheField.parseClose(e)||(this.model&&this.currentCacheField.model&&this.model.cacheFields.push(this.currentCacheField.model),this.currentCacheField=null),!0;switch(e){case this.tag:return this.model&&this.unknownElementsXmlParts.length>0&&(this.model.unknownElementsXml=this.unknownElementsXmlParts.join(``)),!1;case`cacheSource`:this.inCacheSource=!1,this.model&&this.cacheSourceXmlParts.length>0&&(this.model.cacheSourceXml=this.cacheSourceXmlParts.join(``));break;case`cacheFields`:this.inCacheFields=!1;break}return!0}static renderCacheFieldsXml(e){return`
30
- `+e.map(e=>ws(e)).join(`
31
- `)}static{this.PIVOT_CACHE_DEFINITION_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`}}};let Rs=`PivotStyleLight16`,zs=new Set([`axisRow`,`axisCol`,`axisPage`,`axisValues`]),Bs=[`x`,`t`,`h`,`sd`,`f`,`m`,`c`,`d`];function Vs(){return{currentSection:null,inPivotArea:!1,inAutoSortScope:!1}}let Hs=new Set([`axis`,`dataField`,`compact`,`outline`,`showAll`,`defaultSubtotal`,`numFmtId`,`sortType`,`subtotalTop`,`insertBlankRow`,`multipleItemSelectionAllowed`]);var Us=class e extends j{constructor(){super(),this.state=Vs(),this.currentPivotField=null,this.currentRowItem=null,this.currentColItem=null,this.currentChartFormat=null,this.pivotAreaXmlBuffer=[],this.autoSortScopeXmlBuffer=[],this.extLstCollector=new js(`extLst`),this.formatsCollector=new js(`formats`),this.conditionalFormatsCollector=new js(`conditionalFormats`),this.filtersCollector=new js(`filters`),this.unknownCollector=new js(``),this.unknownElementsXmlParts=[],this.model=null}get tag(){return`pivotTableDefinition`}reset(){this.model=null,this.state=Vs(),this.currentPivotField=null,this.currentRowItem=null,this.currentColItem=null,this.currentChartFormat=null,this.pivotAreaXmlBuffer=[],this.autoSortScopeXmlBuffer=[],this.extLstCollector.reset(),this.formatsCollector.reset(),this.conditionalFormatsCollector.reset(),this.filtersCollector.reset(),this.unknownCollector.reset(),this.unknownElementsXmlParts=[]}render(e,t){`isLoaded`in t&&t.isLoaded?this.renderLoaded(e,t):this.renderNew(e,t)}renderNew(t,n){let{rows:r,columns:i,values:a,pages:o=[],cacheFields:s,cacheId:c,tableNumber:l,applyWidthHeightFormats:u}=n,d=i.length===0&&a.length>1,f=o.length,p=f>0?f+1:0,m=r.length,h=3+p,g=h+1,_=m+(d?a.length:1),v=`A${h}:${S.n2l(_)}${g}`;t.openXml(k.StdDocAttributes),t.openNode(this.tag,{...e.PIVOT_TABLE_ATTRIBUTES,name:`PivotTable${l}`,cacheId:c,applyNumberFormats:`0`,applyBorderFormats:`0`,applyFontFormats:`0`,applyPatternFormats:`0`,applyAlignmentFormats:`0`,applyWidthHeightFormats:u,dataCaption:`Values`,updatedVersion:`8`,minRefreshableVersion:`3`,useAutoFormatting:`1`,itemPrintTitles:`1`,createdVersion:`8`,indent:`0`,compact:`0`,compactData:`0`,multipleFieldFilters:`0`});let y={ref:v,firstHeaderRow:1,firstDataRow:1,firstDataCol:m};f>0&&(y.rowPageCount=f,y.colPageCount=1),t.leafNode(`location`,y),Ks(t,n),t.openNode(`rowFields`,{count:r.length});for(let e of r)t.leafNode(`field`,{x:e});if(t.closeNode(),t.openNode(`rowItems`,{count:1}),t.openNode(`i`,{t:`grand`}),t.leafNode(`x`),t.closeNode(),t.closeNode(),i.length>0){let e=a.length>1?i.length+1:i.length;t.openNode(`colFields`,{count:e});for(let e of i)t.leafNode(`field`,{x:e});a.length>1&&t.leafNode(`field`,{x:-2}),t.closeNode()}else d&&(t.openNode(`colFields`,{count:1}),t.leafNode(`field`,{x:-2}),t.closeNode());if(d){t.openNode(`colItems`,{count:a.length+1});for(let e=0;e<a.length;e++)t.openNode(`i`),t.leafNode(`x`,e===0?void 0:{v:e}),t.closeNode();t.openNode(`i`,{t:`grand`}),t.leafNode(`x`),t.closeNode(),t.closeNode()}else t.openNode(`colItems`,{count:1}),t.leafNode(`i`),t.closeNode();if(f>0){t.openNode(`pageFields`,{count:f});for(let e of o)t.leafNode(`pageField`,{fld:e,hier:-1});t.closeNode()}Gs(t,s,a,n.valueMetrics),t.leafNode(`pivotTableStyleInfo`,{name:Rs,showRowHeaders:`1`,showColHeaders:`1`,showRowStripes:`0`,showColStripes:`0`,showLastColumn:`1`}),t.writeXml(e.EXTLST_XML),t.closeNode()}renderLoaded(t,n){let r=this.buildLoadedRootAttributes(n);if(t.openXml(k.StdDocAttributes),t.openNode(this.tag,r),n.location){let e={ref:n.location.ref,firstHeaderRow:n.location.firstHeaderRow,firstDataRow:n.location.firstDataRow,firstDataCol:n.location.firstDataCol};n.location.rowPageCount!==void 0&&(e.rowPageCount=n.location.rowPageCount),n.location.colPageCount!==void 0&&(e.colPageCount=n.location.colPageCount),t.leafNode(`location`,e)}if(n.pivotFields.length>0){t.openNode(`pivotFields`,{count:n.pivotFields.length});for(let e of n.pivotFields)this.renderPivotFieldLoaded(t,e);t.closeNode()}if(n.rowFields.length>0){t.openNode(`rowFields`,{count:n.rowFields.length});for(let e of n.rowFields)t.leafNode(`field`,{x:e});t.closeNode()}if(n.rowItems&&n.rowItems.length>0){t.openNode(`rowItems`,{count:n.rowItems.length});for(let e of n.rowItems)this.renderRowColItem(t,e);t.closeNode()}else n.hasRowItems&&t.writeXml(`<rowItems count="1"><i t="grand"><x/></i></rowItems>`);if(n.hasColFields||n.colFields.length>0)if(n.colFields.length===0&&n.dataFields.length<=1)t.leafNode(`colFields`,{count:0});else{let e=n.colFields.length===0?1:n.colFields.length;if(t.openNode(`colFields`,{count:e}),n.colFields.length===0)t.leafNode(`field`,{x:-2});else for(let e of n.colFields)t.leafNode(`field`,{x:e});t.closeNode()}if(n.colItems&&n.colItems.length>0){t.openNode(`colItems`,{count:n.colItems.length});for(let e of n.colItems)this.renderRowColItem(t,e);t.closeNode()}else n.hasColItems&&t.writeXml(`<colItems count="1"><i t="grand"><x/></i></colItems>`);if(n.pageFields&&n.pageFields.length>0){t.openNode(`pageFields`,{count:n.pageFields.length});for(let e of n.pageFields){let n={fld:e.fld};e.item!==void 0&&(n.item=e.item),e.hier!==void 0&&(n.hier=e.hier),e.name!==void 0&&(n.name=e.name),t.leafNode(`pageField`,n)}t.closeNode()}if(n.dataFields.length>0){t.openNode(`dataFields`,{count:n.dataFields.length});for(let e of n.dataFields){let n={name:e.name,fld:e.fld};e.baseField!==void 0&&(n.baseField=e.baseField),e.baseItem!==void 0&&(n.baseItem=e.baseItem),e.subtotal!==void 0&&e.subtotal!==`sum`&&(n.subtotal=e.subtotal),e.numFmtId!==void 0&&(n.numFmtId=e.numFmtId),t.leafNode(`dataField`,n)}t.closeNode()}n.formatsXml&&t.writeXml(n.formatsXml),n.conditionalFormatsXml&&t.writeXml(n.conditionalFormatsXml),n.chartFormats&&n.chartFormats.length>0&&this.renderChartFormats(t,n.chartFormats);let i=n.styleInfo;t.leafNode(`pivotTableStyleInfo`,{name:i?.name??n.styleName??Rs,showRowHeaders:i?.showRowHeaders??`1`,showColHeaders:i?.showColHeaders??`1`,showRowStripes:i?.showRowStripes??`0`,showColStripes:i?.showColStripes??`0`,showLastColumn:i?.showLastColumn??`1`}),n.filtersXml&&t.writeXml(n.filtersXml),n.unknownElementsXml&&t.writeXml(n.unknownElementsXml);let a=n.extLstXml??(n.isLoaded?``:e.EXTLST_XML);a&&t.writeXml(a),t.closeNode()}buildLoadedRootAttributes(t){let n={...e.PIVOT_TABLE_ATTRIBUTES,name:t.name??`PivotTable1`,cacheId:String(t.cacheId),applyNumberFormats:t.applyNumberFormats??`0`,applyBorderFormats:t.applyBorderFormats??`0`,applyFontFormats:t.applyFontFormats??`0`,applyPatternFormats:t.applyPatternFormats??`0`,applyAlignmentFormats:t.applyAlignmentFormats??`0`,applyWidthHeightFormats:t.applyWidthHeightFormats??`0`,dataCaption:t.dataCaption??`Values`,updatedVersion:t.updatedVersion??`8`,minRefreshableVersion:t.minRefreshableVersion??`3`};return t.useAutoFormatting!==void 0&&(n.useAutoFormatting=t.useAutoFormatting),t.itemPrintTitles!==void 0&&(n.itemPrintTitles=t.itemPrintTitles),t.multipleFieldFilters!==void 0&&(n.multipleFieldFilters=t.multipleFieldFilters),n.createdVersion=t.createdVersion??`8`,t.indent!==void 0&&(n.indent=String(t.indent)),t.uid&&(n[`xmlns:xr`]=`http://schemas.microsoft.com/office/spreadsheetml/2014/revision`,n[`xr:uid`]=t.uid),t.outline&&(n.outline=`1`),t.outlineData&&(n.outlineData=`1`),t.chartFormat!==void 0&&(n.chartFormat=String(t.chartFormat)),t.colGrandTotals!==void 0&&(n.colGrandTotals=t.colGrandTotals),t.rowGrandTotals!==void 0&&(n.rowGrandTotals=t.rowGrandTotals),t.showError!==void 0&&(n.showError=t.showError),t.errorCaption!==void 0&&(n.errorCaption=t.errorCaption),t.showMissing!==void 0&&(n.showMissing=t.showMissing),t.missingCaption!==void 0&&(n.missingCaption=t.missingCaption),t.grandTotalCaption!==void 0&&(n.grandTotalCaption=t.grandTotalCaption),t.compact===!1&&(n.compact=`0`),t.compactData===!1&&(n.compactData=`0`),n}renderChartFormats(e,t){e.openNode(`chartFormats`,{count:t.length});for(let n of t)e.openNode(`chartFormat`,{chart:n.chart,format:n.format,series:n.series===!0?`1`:n.series===!1?`0`:void 0}),n.pivotAreaXml?e.writeXml(n.pivotAreaXml):e.writeXml(`<pivotArea type="data" outline="0" fieldPosition="0"><references count="1"><reference field="4294967294" count="1" selected="0"><x v="0"/></reference></references></pivotArea>`),e.closeNode();e.closeNode()}renderRowColItem(e,t){let n={};if(t.t!==void 0&&(n.t=t.t),t.r!==void 0&&(n.r=t.r),t.i!==void 0&&(n.i=t.i),t.x.length>0){e.openNode(`i`,n);for(let n of t.x)n.v===0?e.leafNode(`x`):e.leafNode(`x`,{v:n.v});e.closeNode()}else e.leafNode(`i`,n)}renderPivotFieldLoaded(e,t){let n={};if(t.axis&&(n.axis=t.axis),t.dataField&&(n.dataField=`1`),t.numFmtId!==void 0&&(n.numFmtId=String(t.numFmtId)),t.sortType&&(n.sortType=t.sortType),t.compact===!1&&(n.compact=`0`),t.outline===!1&&(n.outline=`0`),n.showAll=t.showAll?`1`:`0`,t.defaultSubtotal===!1&&(n.defaultSubtotal=`0`),t.subtotalTop===!1&&(n.subtotalTop=`0`),t.insertBlankRow===!0&&(n.insertBlankRow=`1`),t.multipleItemSelectionAllowed===!0&&(n.multipleItemSelectionAllowed=`1`),t.extraAttrs)for(let[e,r]of Object.entries(t.extraAttrs))n[e]=r;if(t.items!==void 0&&t.items.length>0||t.autoSortScopeXml!==void 0){if(e.openNode(`pivotField`,n),t.items!==void 0&&t.items.length>0){e.openNode(`items`,{count:t.items.length});for(let n of t.items){let t={};for(let e of Bs)n[e]!==void 0&&(t[e]=n[e]);e.leafNode(`item`,t)}e.closeNode()}t.autoSortScopeXml&&e.writeXml(t.autoSortScopeXml),e.closeNode()}else e.leafNode(`pivotField`,n)}parseOpen(e){let{name:t,attributes:n}=e;if(this.extLstCollector.active)return this.extLstCollector.feedOpen(t,n),!0;if(this.formatsCollector.active)return this.formatsCollector.feedOpen(t,n),!0;if(this.conditionalFormatsCollector.active)return this.conditionalFormatsCollector.feedOpen(t,n),!0;if(this.filtersCollector.active)return this.filtersCollector.feedOpen(t,n),!0;if(this.unknownCollector.active)return this.unknownCollector.feedOpen(t,n),!0;switch(t){case this.tag:this.reset(),this.model={name:n.name,cacheId:parseInt(n.cacheId??`0`,10),uid:n[`xr:uid`],pivotFields:[],rowFields:[],colFields:[],pageFields:[],dataFields:[],applyNumberFormats:n.applyNumberFormats,applyBorderFormats:n.applyBorderFormats,applyFontFormats:n.applyFontFormats,applyPatternFormats:n.applyPatternFormats,applyAlignmentFormats:n.applyAlignmentFormats,applyWidthHeightFormats:n.applyWidthHeightFormats,dataCaption:n.dataCaption,updatedVersion:n.updatedVersion,minRefreshableVersion:n.minRefreshableVersion,createdVersion:n.createdVersion,useAutoFormatting:n.useAutoFormatting,itemPrintTitles:n.itemPrintTitles,indent:n.indent===void 0?void 0:parseInt(n.indent,10),compact:n.compact!==`0`,compactData:n.compactData!==`0`,multipleFieldFilters:n.multipleFieldFilters,outline:n.outline===`1`,outlineData:n.outlineData===`1`,chartFormat:n.chartFormat===void 0?void 0:parseInt(n.chartFormat,10),colGrandTotals:n.colGrandTotals,rowGrandTotals:n.rowGrandTotals,showError:n.showError,errorCaption:n.errorCaption,showMissing:n.showMissing,missingCaption:n.missingCaption,grandTotalCaption:n.grandTotalCaption,rowItems:[],colItems:[],chartFormats:[],isLoaded:!0};break;case`location`:this.model&&(this.model.location={ref:n.ref,firstHeaderRow:n.firstHeaderRow===void 0?void 0:parseInt(n.firstHeaderRow,10),firstDataRow:n.firstDataRow===void 0?void 0:parseInt(n.firstDataRow,10),firstDataCol:n.firstDataCol===void 0?void 0:parseInt(n.firstDataCol,10),rowPageCount:n.rowPageCount===void 0?void 0:parseInt(n.rowPageCount,10),colPageCount:n.colPageCount===void 0?void 0:parseInt(n.colPageCount,10)});break;case`pivotFields`:this.state.currentSection=`pivotFields`;break;case`pivotField`:if(this.state.currentSection===`pivotFields`){let e={};for(let[t,r]of Object.entries(n))Hs.has(t)||(e[t]=String(r));this.currentPivotField={axis:zs.has(n.axis)?n.axis:void 0,dataField:n.dataField===`1`,items:[],compact:n.compact!==`0`,outline:n.outline!==`0`,showAll:n.showAll!==`0`,defaultSubtotal:n.defaultSubtotal!==`0`,numFmtId:n.numFmtId===void 0?void 0:parseInt(n.numFmtId,10),sortType:n.sortType,subtotalTop:n.subtotalTop===void 0?void 0:n.subtotalTop===`1`,insertBlankRow:n.insertBlankRow===`1`?!0:void 0,multipleItemSelectionAllowed:n.multipleItemSelectionAllowed===`1`?!0:void 0,extraAttrs:Object.keys(e).length>0?e:void 0}}break;case`items`:break;case`item`:if(this.currentPivotField){let e={};n.x!==void 0&&(e.x=parseInt(n.x,10));for(let t of Bs)t!==`x`&&n[t]!==void 0&&(e[t]=n[t]);this.currentPivotField.items.push(e)}break;case`autoSortScope`:this.currentPivotField&&(this.state.inAutoSortScope=!0,this.autoSortScopeXmlBuffer=[`<autoSortScope>`]);break;case`rowFields`:this.state.currentSection=`rowFields`;break;case`colFields`:this.state.currentSection=`colFields`,this.model&&(this.model.hasColFields=!0);break;case`dataFields`:this.state.currentSection=`dataFields`;break;case`pageFields`:this.state.currentSection=`pageFields`;break;case`pageField`:this.state.currentSection===`pageFields`&&this.model&&this.model.pageFields.push({fld:parseInt(n.fld??`0`,10),item:n.item===void 0?void 0:parseInt(n.item,10),hier:n.hier===void 0?void 0:parseInt(n.hier,10),name:n.name});break;case`rowItems`:this.state.currentSection=`rowItems`,this.model&&(this.model.hasRowItems=!0);break;case`colItems`:this.state.currentSection=`colItems`,this.model&&(this.model.hasColItems=!0);break;case`i`:if(this.model){let e=this.state.currentSection===`rowItems`||this.state.currentSection===`colItems`?Ws(n):null;this.state.currentSection===`rowItems`?this.currentRowItem=e:this.state.currentSection===`colItems`&&(this.currentColItem=e)}break;case`x`:if(this.state.inPivotArea){let e=Ms(n);this.state.inAutoSortScope?this.autoSortScopeXmlBuffer.push(e?`<x ${e}/>`:`<x/>`):this.pivotAreaXmlBuffer.push(e?`<x ${e}/>`:`<x/>`)}else this.currentRowItem?this.currentRowItem.x.push({v:parseInt(n.v??`0`,10)}):this.currentColItem&&this.currentColItem.x.push({v:parseInt(n.v??`0`,10)});break;case`chartFormats`:this.state.currentSection=`chartFormats`;break;case`chartFormat`:this.state.currentSection===`chartFormats`&&this.model&&(this.currentChartFormat={chart:parseInt(n.chart??`0`,10),format:parseInt(n.format??`0`,10),series:n.series===void 0?void 0:n.series===`1`});break;case`pivotArea`:if(this.currentChartFormat){this.state.inPivotArea=!0;let e=Ms(n);this.pivotAreaXmlBuffer=[e?`<pivotArea ${e}>`:`<pivotArea>`]}else if(this.state.inAutoSortScope){this.state.inPivotArea=!0;let e=Ms(n);this.autoSortScopeXmlBuffer.push(e?`<pivotArea ${e}>`:`<pivotArea>`)}break;case`references`:case`reference`:if(this.state.inPivotArea){let e=Ms(n);this.state.inAutoSortScope?this.autoSortScopeXmlBuffer.push(`<${t}${e?` `+e:``}>`):this.pivotAreaXmlBuffer.push(`<${t}${e?` `+e:``}>`)}break;case`field`:if(this.model){let e=parseInt(n.x??`0`,10);this.state.currentSection===`rowFields`?this.model.rowFields.push(e):this.state.currentSection===`colFields`&&this.model.colFields.push(e)}break;case`dataField`:this.state.currentSection===`dataFields`&&this.model&&this.model.dataFields.push({name:n.name??``,fld:parseInt(n.fld??`0`,10),baseField:n.baseField===void 0?void 0:parseInt(n.baseField,10),baseItem:n.baseItem===void 0?void 0:parseInt(n.baseItem,10),subtotal:un.has(n.subtotal)?n.subtotal:void 0,numFmtId:n.numFmtId===void 0?void 0:parseInt(n.numFmtId,10)});break;case`pivotTableStyleInfo`:this.model&&(this.model.styleName=n.name,this.model.styleInfo={name:n.name,showRowHeaders:n.showRowHeaders,showColHeaders:n.showColHeaders,showRowStripes:n.showRowStripes,showColStripes:n.showColStripes,showLastColumn:n.showLastColumn});break;case`extLst`:this.model&&this.extLstCollector.start(n);break;case`formats`:this.model&&this.formatsCollector.start(n);break;case`conditionalFormats`:this.model&&this.conditionalFormatsCollector.start(n);break;case`filters`:this.model&&this.filtersCollector.start(n);break;default:this.model&&this.state.currentSection===null&&!this.state.inPivotArea&&!this.state.inAutoSortScope&&this.unknownCollector.startAs(t,n);break}return!0}parseText(e){this.extLstCollector.active?this.extLstCollector.feedText(e):this.formatsCollector.active?this.formatsCollector.feedText(e):this.conditionalFormatsCollector.active?this.conditionalFormatsCollector.feedText(e):this.filtersCollector.active?this.filtersCollector.feedText(e):this.unknownCollector.active&&this.unknownCollector.feedText(e)}tryCloseCollector(e,t,n){e.feedClose(t)&&(this.model&&(this.model[n]=e.result),e.reset())}parseClose(e){if(this.extLstCollector.active)return this.tryCloseCollector(this.extLstCollector,e,`extLstXml`),!0;if(this.formatsCollector.active)return this.tryCloseCollector(this.formatsCollector,e,`formatsXml`),!0;if(this.conditionalFormatsCollector.active)return this.tryCloseCollector(this.conditionalFormatsCollector,e,`conditionalFormatsXml`),!0;if(this.filtersCollector.active)return this.tryCloseCollector(this.filtersCollector,e,`filtersXml`),!0;if(this.unknownCollector.active)return this.unknownCollector.feedClose(e)&&(this.unknownElementsXmlParts.push(this.unknownCollector.result),this.unknownCollector.reset()),!0;if(this.state.inPivotArea)return e===`pivotArea`?(this.state.inAutoSortScope?this.autoSortScopeXmlBuffer.push(`</pivotArea>`):(this.pivotAreaXmlBuffer.push(`</pivotArea>`),this.currentChartFormat&&(this.currentChartFormat.pivotAreaXml=this.pivotAreaXmlBuffer.join(``)),this.pivotAreaXmlBuffer=[]),this.state.inPivotArea=!1,!0):((e===`references`||e===`reference`)&&(this.state.inAutoSortScope?this.autoSortScopeXmlBuffer.push(`</${e}>`):this.pivotAreaXmlBuffer.push(`</${e}>`)),!0);switch(e){case this.tag:return this.model&&this.unknownElementsXmlParts.length>0&&(this.model.unknownElementsXml=this.unknownElementsXmlParts.join(``)),!1;case`pivotFields`:case`rowFields`:case`colFields`:case`dataFields`:case`pageFields`:case`rowItems`:case`colItems`:case`chartFormats`:this.state.currentSection=null;break;case`pivotField`:this.currentPivotField&&this.model&&(this.model.pivotFields.push(this.currentPivotField),this.currentPivotField=null);break;case`items`:break;case`autoSortScope`:this.state.inAutoSortScope&&this.currentPivotField&&(this.autoSortScopeXmlBuffer.push(`</autoSortScope>`),this.currentPivotField.autoSortScopeXml=this.autoSortScopeXmlBuffer.join(``),this.autoSortScopeXmlBuffer=[],this.state.inAutoSortScope=!1);break;case`i`:this.currentRowItem&&this.model?(this.model.rowItems?.push(this.currentRowItem),this.currentRowItem=null):this.currentColItem&&this.model&&(this.model.colItems?.push(this.currentColItem),this.currentColItem=null);break;case`chartFormat`:this.currentChartFormat&&this.model&&(this.model.chartFormats?.push(this.currentChartFormat),this.currentChartFormat=null);break}return!0}static{this.PIVOT_TABLE_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`}}static{this.EXTLST_XML=`<extLst><ext uri="{962EF5D1-5CA2-4c93-8EF4-DBF5C05439D2}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"><x14:pivotTableDefinition hideValuesRow="1" xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main"/></ext><ext uri="{747A6164-185A-40DC-8AA5-F01512510D54}" xmlns:xpdl="http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout"><xpdl:pivotTableDefinition16 EnabledSubtotalsDefault="0" SubtotalsOnTopDefault="0"/></ext></extLst>`}};function Ws(e){return{t:e.t,r:e.r===void 0?void 0:parseInt(e.r,10),i:e.i===void 0?void 0:parseInt(e.i,10),x:[]}}function Gs(e,t,n,r){e.openNode(`dataFields`,{count:n.length});for(let i=0;i<n.length;i++){let a=n[i],o=r[i]??`sum`,s=ln[o],c=t[a];if(!c)throw Error(`Value field index ${a} is out of bounds (cacheFields has ${t.length} entries)`);let l={name:`${s} of ${c.name}`,fld:a,baseField:0,baseItem:0};o!==`sum`&&(l.subtotal=o),e.leafNode(`dataField`,l)}e.closeNode()}function Ks(e,t){let n=new Set(t.rows),r=new Set(t.columns),i=new Set(t.values),a=new Set(t.pages??[]);e.openNode(`pivotFields`,{count:t.cacheFields.length});for(let o=0;o<t.cacheFields.length;o++){let s=t.cacheFields[o];qs(e,n.has(o),r.has(o),i.has(o),a.has(o),s.sharedItems)}e.closeNode()}function qs(e,t,n,r,i,a){if(t||n||i){if(!a)throw Error(`sharedItems is required for axis field (row/column/page)`);let i={axis:t?`axisRow`:n?`axisCol`:`axisPage`};r&&(i.dataField=`1`),i.compact=`0`,i.outline=`0`,i.showAll=`0`,e.openNode(`pivotField`,i),e.openNode(`items`,{count:a.length+1});for(let t=0;t<a.length;t++)e.leafNode(`item`,{x:t});e.leafNode(`item`,{t:`default`}),e.closeNode(),e.closeNode();return}let o={};r&&(o.dataField=`1`),o.compact=`0`,o.outline=`0`,o.showAll=`0`,o.defaultSubtotal=`0`,e.leafNode(`pivotField`,o)}var Js=class extends j{constructor(e){super(),this.model=e||{type:`note`,note:{texts:[]},ref:``}}get tag(){return`r`}get richTextXform(){return this._richTextXform||=new ti,this._richTextXform}render(e,t){let n=t||this.model;e.openNode(`comment`,{ref:n.ref,authorId:0}),e.openNode(`text`),n&&n.note&&n.note.texts&&n.note.texts.forEach(t=>{this.richTextXform.render(e,t)}),e.closeNode(),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`comment`:return this.model={type:`note`,note:{texts:[]},...e.attributes},!0;case`r`:return this.parser=this.richTextXform,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){switch(e){case`comment`:return!1;case`r`:return this.model.note.texts.push(this.parser.model),this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(e),!0}}},Ys=class e extends j{constructor(){super(),this.map={comment:new Js},this.model={comments:[]}}render(t,n){let r=n||this.model;t.openXml(k.StdDocAttributes),t.openNode(`comments`,e.COMMENTS_ATTRIBUTES),t.openNode(`authors`),t.leafNode(`author`,null,`Author`),t.closeNode(),t.openNode(`commentList`),r.comments.forEach(e=>{this.map.comment.render(t,e)}),t.closeNode(),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`commentList`:return this.model={comments:[]},!0;case`comment`:return this.parser=this.map.comment,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){switch(e){case`commentList`:return!1;case`comment`:return this.model.comments.push(this.parser.model),this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(e),!0}}static{this.COMMENTS_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`}}},Xs=class extends j{constructor(){super(),this.model={}}get tag(){return`v:textbox`}conversionUnit(e,t,n){return`${(parseFloat(e.toString())*t).toFixed(2)}${n}`}reverseConversionUnit(e){return(e??``).split(`,`).map(e=>Number(parseFloat(this.conversionUnit(parseFloat(e),.1,``)).toFixed(2)))}render(e,t){let n={style:`mso-direction-alt:auto`};if(t&&t.note){let{inset:e}=t.note&&t.note.margins||{};Array.isArray(e)&&(e=e.map(e=>this.conversionUnit(e,10,`mm`)).join(`,`)),e&&(n.inset=e)}e.openNode(`v:textbox`,n),e.leafNode(`div`,{style:`text-align:left`}),e.closeNode()}parseOpen(e){switch(e.name){case this.tag:return this.model={inset:this.reverseConversionUnit(e.attributes.inset)},!0;default:return!0}}parseText(){}parseClose(e){switch(e){case this.tag:return!1;default:return!0}}},Zs=class extends j{constructor(){super(),this.text=``}get tag(){return`x:Anchor`}getAnchorRect(e){let t=Math.floor(e.left),n=Math.floor((e.left-t)*68),r=Math.floor(e.top),i=Math.floor((e.top-r)*18),a=Math.floor(e.right),o=Math.floor((e.right-a)*68),s=Math.floor(e.bottom);return[t,n,r,i,a,o,s,Math.floor((e.bottom-s)*18)]}getDefaultRect(e){let t=e.col,n=Math.max(e.row-2,0);return[t,6,n,14,t+2,2,n+4,16]}render(e,t){let n=t.anchor?this.getAnchorRect(t.anchor):this.getDefaultRect(t.refAddress);e.leafNode(`x:Anchor`,null,n.join(`, `))}parseOpen(e){switch(e.name){case this.tag:return this.text=``,!0;default:return!1}}parseText(e){this.text=e}parseClose(){return!1}},Qs=class extends j{constructor(e){super(),this._model=e||{},this.text=``}get tag(){return this._model?.tag??``}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(e){switch(e.name){case this.tag:return this.text=``,!0;default:return!1}}parseText(e){this.text=e}parseClose(){return!1}},$s=class extends j{constructor(e){super(),this._model=e||{},this.model={}}get tag(){return this._model?.tag??``}render(e,t,n){(n&&t===n[2]||n&&this.tag===`x:SizeWithCells`&&t===n[1])&&e.leafNode(this.tag)}parseOpen(e){switch(e.name){case this.tag:return this.model={},this.model[this.tag]=!0,!0;default:return!1}}parseText(){}parseClose(){return!1}};let ec=[`twoCells`,`oneCells`,`absolute`];var tc=class extends j{constructor(){super(),this.map={"x:Anchor":new Zs,"x:Locked":new Qs({tag:`x:Locked`}),"x:LockText":new Qs({tag:`x:LockText`}),"x:SizeWithCells":new $s({tag:`x:SizeWithCells`}),"x:MoveWithCells":new $s({tag:`x:MoveWithCells`})},this.model={anchor:[],protection:{},editAs:``}}get tag(){return`x:ClientData`}render(e,t){let{protection:n,editAs:r}=t.note;e.openNode(this.tag,{ObjectType:`Note`}),this.map[`x:MoveWithCells`].render(e,r,ec),this.map[`x:SizeWithCells`].render(e,r,ec),this.map[`x:Anchor`].render(e,t),this.map[`x:Locked`].render(e,n.locked),e.leafNode(`x:AutoFill`,null,`False`),this.map[`x:LockText`].render(e,n.lockText),e.leafNode(`x:Row`,null,t.refAddress.row-1),e.leafNode(`x:Column`,null,t.refAddress.col-1),e.closeNode()}parseOpen(e){switch(e.name){case this.tag:this.reset(),this.model={anchor:[],protection:{},editAs:``};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.normalizeModel(),!1;default:return!0}}normalizeModel(){let e=Object.assign({},this.map[`x:MoveWithCells`].model,this.map[`x:SizeWithCells`].model),t=Object.keys(e).length;this.model.editAs=ec[t],this.model.anchor=this.map[`x:Anchor`].text,this.model.protection.locked=this.map[`x:Locked`].text,this.model.protection.lockText=this.map[`x:LockText`].text}},nc=class e extends j{constructor(){super(),this.map={"v:textbox":new Xs,"x:ClientData":new tc}}get tag(){return`v:shape`}render(t,n,r){t.openNode(`v:shape`,e.V_SHAPE_ATTRIBUTES(n,r??0)),t.leafNode(`v:fill`,{color2:`infoBackground [80]`}),t.leafNode(`v:shadow`,{color:`none [81]`,obscured:`t`}),t.leafNode(`v:path`,{"o:connecttype":`none`}),this.map[`v:textbox`].render(t,n),this.map[`x:ClientData`].render(t,n),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset(),this.model={margins:{insetmode:e.attributes[`o:insetmode`]},anchor:``,editAs:``,protection:{}};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.margins.inset=this.map[`v:textbox`].model&&this.map[`v:textbox`].model.inset,this.model.protection=this.map[`x:ClientData`].model&&this.map[`x:ClientData`].model.protection,this.model.anchor=this.map[`x:ClientData`].model&&this.map[`x:ClientData`].model.anchor,this.model.editAs=this.map[`x:ClientData`].model&&this.map[`x:ClientData`].model.editAs,!1;default:return!0}}static{this.V_SHAPE_ATTRIBUTES=(e,t)=>({id:`_x0000_s${1025+t}`,type:`#_x0000_t202`,style:`position:absolute; margin-left:105.3pt;margin-top:10.5pt;width:97.8pt;height:59.1pt;z-index:1;visibility:hidden`,fillcolor:`infoBackground [80]`,strokecolor:`none [81]`,"o:insetmode":e.note.margins&&e.note.margins.insetmode})}},rc=class e extends j{constructor(){super(),this.map={"v:shape":new nc},this.model={comments:[],formControls:[]}}get tag(){return`xml`}render(t,n){let r=n||this.model,i=r.comments,a=r.formControls,o=i&&i.length>0,s=a&&a.length>0;if(t.openXml(k.StdDocAttributes),t.openNode(this.tag,e.DRAWING_ATTRIBUTES),t.openNode(`o:shapelayout`,{"v:ext":`edit`}),t.leafNode(`o:idmap`,{"v:ext":`edit`,data:1}),t.closeNode(),o&&(t.openNode(`v:shapetype`,{id:`_x0000_t202`,coordsize:`21600,21600`,"o:spt":202,path:`m,l,21600r21600,l21600,xe`}),t.leafNode(`v:stroke`,{joinstyle:`miter`}),t.leafNode(`v:path`,{gradientshapeok:`t`,"o:connecttype":`rect`}),t.closeNode()),s&&(t.openNode(`v:shapetype`,{id:`_x0000_t201`,coordsize:`21600,21600`,"o:spt":`201`,path:`m,l,21600r21600,l21600,xe`}),t.leafNode(`v:stroke`,{joinstyle:`miter`}),t.leafNode(`v:path`,{shadowok:`f`,"o:extrusionok":`f`,strokeok:`f`,fillok:`f`,"o:connecttype":`rect`}),t.leafNode(`o:lock`,{"v:ext":`edit`,shapetype:`t`}),t.closeNode()),o)for(let e=0;e<i.length;e++)this.map[`v:shape`].render(t,i[e],e);if(s)for(let e of a)this._renderCheckboxShape(t,e);t.closeNode()}_renderCheckboxShape(e,t){let n={id:`_x0000_s${t.shapeId}`,type:`#_x0000_t201`,style:ct.getVmlStyle(t),"o:insetmode":`auto`,fillcolor:`buttonFace [67]`,strokecolor:`windowText [64]`,"o:preferrelative":`t`,filled:`f`,stroked:`f`};e.openNode(`v:shape`,n),e.leafNode(`v:fill`,{"o:detectmouseclick":`t`}),e.leafNode(`o:lock`,{"v:ext":`edit`,text:`t`}),t.text&&(e.openNode(`v:textbox`,{style:`mso-direction-alt:auto`,"o:singleclick":`t`}),e.openNode(`div`,{style:`text-align:left`}),e.openNode(`font`,{face:`Tahoma`,size:`160`,color:`auto`}),e.writeText(t.text),e.closeNode(),e.closeNode(),e.closeNode()),e.openNode(`x:ClientData`,{ObjectType:`Checkbox`}),e.leafNode(`x:MoveWithCells`),e.leafNode(`x:SizeWithCells`),e.openNode(`x:Anchor`),e.writeText(ct.getVmlAnchor(t)),e.closeNode(),e.leafNode(`x:Locked`,void 0,`False`),e.leafNode(`x:LockText`,void 0,`True`),e.leafNode(`x:PrintObject`,void 0,t.print?`True`:`False`),e.leafNode(`x:AutoFill`,void 0,`False`),e.leafNode(`x:AutoLine`,void 0,`False`),e.leafNode(`x:TextHAlign`,void 0,`Left`),e.leafNode(`x:TextVAlign`,void 0,`Center`),t.link&&e.leafNode(`x:FmlaLink`,void 0,t.link),t.noThreeD&&e.leafNode(`x:NoThreeD`),e.leafNode(`x:Checked`,void 0,String(ct.getVmlCheckedValue(t))),e.leafNode(`x:Row`,void 0,String(t.tl.row)),e.leafNode(`x:Column`,void 0,String(t.tl.col)),e.closeNode(),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset(),this.model={comments:[],formControls:[]};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.comments.push(this.parser.model),this.parser=void 0),!0;switch(e){case this.tag:return!1;default:return!0}}static{this.DRAWING_ATTRIBUTES={"xmlns:v":`urn:schemas-microsoft-com:vml`,"xmlns:o":`urn:schemas-microsoft-com:office:office`,"xmlns:x":`urn:schemas-microsoft-com:office:excel`}}},ic=class extends j{_checkedToXmlValue(e){switch(e){case`Checked`:return`1`;case`Mixed`:return`2`;default:return`0`}}get tag(){return`formControlPr`}render(e,t){let n=t||this.model,r={xmlns:`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`,objectType:`CheckBox`,checked:this._checkedToXmlValue(n.checked),lockText:`1`};n.link&&(r.fmlaLink=n.link),n.noThreeD&&(r.noThreeD=`1`),e.openXml({version:`1.0`,encoding:`UTF-8`,standalone:`yes`}),e.leafNode(this.tag,r)}toXml(e){let t=new k;return this.render(t,e),t.xml}parseOpen(){return!0}parseText(){}parseClose(){return!1}};let ac=e=>Array.isArray(e);var W=class e{constructor(){this.__excelts_stream=!0,this._listeners=new Map,this._maxListeners=e.defaultMaxListeners}static{this.defaultMaxListeners=10}addListener(e,t){return this.on(e,t)}_listenerCount(e){return e?ac(e)?e.length:1:0}_hasListeners(e){return this._listenerCount(this._listeners.get(e))>0}on(e,t){e!==`newListener`&&this._hasListeners(`newListener`)&&this.emit(`newListener`,e,t);let n=this._listeners.get(e);if(this._maxListeners>0){let t=this._listenerCount(n);t>=this._maxListeners&&console?.warn?.(`MaxListenersExceededWarning: Possible EventEmitter memory leak detected. ${t+1} ${String(e)} listeners added. Use emitter.setMaxListeners() to increase limit`)}return n?ac(n)?n.push(t):this._listeners.set(e,[n,t]):this._listeners.set(e,t),this}prependListener(e,t){e!==`newListener`&&this._hasListeners(`newListener`)&&this.emit(`newListener`,e,t);let n=this._listeners.get(e);return n?ac(n)?n.unshift(t):this._listeners.set(e,[t,n]):this._listeners.set(e,t),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return n.listener=t,this.on(e,n)}prependOnceListener(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return n.listener=t,this.prependListener(e,n)}removeListener(e,t){return this.off(e,t)}off(e,t){let n=this._listeners.get(e);if(!n)return this;if(!ac(n))return(n===t||n.listener===t)&&(this._listeners.delete(e),e!==`removeListener`&&this._hasListeners(`removeListener`)&&this.emit(`removeListener`,e,t)),this;let r=n;if(r.length===0)return this._listeners.delete(e),this;let i=r.lastIndexOf(t);if(i!==-1)r.splice(i,1);else for(let e=r.length-1;e>=0;e--)if(r[e].listener===t){r.splice(e,1);break}return r.length===0?this._listeners.delete(e):r.length===1&&this._listeners.set(e,r[0]),e!==`removeListener`&&this._hasListeners(`removeListener`)&&this.emit(`removeListener`,e,t),this}emit(e,...t){let n=this._listeners.get(e);if(!n){if(e===`error`){let e=t[0];if(e instanceof Error)throw e;let n=`Unhandled error.${e===void 0?` (undefined)`:` (${e})`}`;throw Error(n)}return!1}if(!ac(n))return n.apply(this,t),!0;let r=n,i=r.length;if(i===0){if(e===`error`){let e=t[0];if(e instanceof Error)throw e;let n=`Unhandled error.${e===void 0?` (undefined)`:` (${e})`}`;throw Error(n)}return!1}if(i===1)return r[0].apply(this,t),!0;let a=r.slice();for(let e=0;e<a.length;e++)a[e].apply(this,t);return!0}removeAllListeners(e){if(e!==void 0){if(e!==`removeListener`&&this._hasListeners(`removeListener`)){let t=this._listeners.get(e);if(t){let n=ac(t)?t.slice():[t];this._listeners.delete(e);for(let t of n){let n=t.listener??t;this.emit(`removeListener`,e,n)}return this}}this._listeners.delete(e)}else{if(this._hasListeners(`removeListener`)){let e=[...this._listeners.keys()];for(let t of e)if(t!==`removeListener`){let e=this._listeners.get(t);if(e){let n=ac(e)?e.slice():[e];this._listeners.delete(t);for(let e of n){let n=e.listener??e;this.emit(`removeListener`,t,n)}}}}this._listeners.clear()}return this}listenerCount(e){return this._listenerCount(this._listeners.get(e))}listeners(e){let t=this._listeners.get(e);return t?(ac(t)?t:[t]).map(e=>e.listener??e):[]}rawListeners(e){let t=this._listeners.get(e);return t?ac(t)?t.slice():[t]:[]}eventNames(){return[...this._listeners.keys()]}setMaxListeners(e){return this._maxListeners=e,this}getMaxListeners(){return this._maxListeners}};W.prototype.addListener=W.prototype.on,W.prototype.removeListener=W.prototype.off;let oc=new TextEncoder;var sc=class{constructor(e){this._buf=new Uint8Array(e&&e.size||16384),this._inPos=0,this._buffer=void 0}get length(){return this._inPos}get capacity(){return this._buf.length}get buffer(){return this._buf}toBuffer(){return this._buffer||=this._buf.slice(0,this._inPos),this._buffer}reset(e){e??=0,this._buffer=void 0,this._inPos=e}_grow(e){let t=this._buf.length*2;for(;t<e;)t*=2;let n=new Uint8Array(t);n.set(this._buf),this._buf=n}addText(e){this._buffer=void 0;let t=oc.encode(e),n=this._inPos+t.length;n>this._buf.length-4&&this._grow(n),this._buf.set(t,this._inPos),this._inPos+=t.length}addStringBuf(e){e.length&&(this._buffer=void 0,this.length+e.length>this.capacity&&this._grow(this.length+e.length),this._buf.set(e._buf.subarray(0,e.length),this._inPos),this._inPos+=e.length)}},cc=class{constructor(e){this._data=e}get length(){return this.toBuffer().length}copy(e,t,n,r){let i=this.toBuffer(),a=Math.min(r,i.length-n);return e.set(i.subarray(n,n+a),t),a}toBuffer(){return this._buffer||=new TextEncoder().encode(this._data),this._buffer}},lc=class{constructor(e){this._data=e}get length(){return this._data.length}copy(e,t,n,r){let i=this.toBuffer(),a=Math.min(r,i.length-n);return e.set(i.subarray(n,n+a),t),a}toBuffer(){return this._data.toBuffer()}},uc=class{constructor(e){this._data=e}get length(){return this._data.length}copy(e,t,n,r){let i=Math.min(r,this._data.length-n);return e.set(this._data.subarray(n,n+i),t),i}toBuffer(){return this._data}},dc=class{constructor(e){this.size=e,this.buffer=new Uint8Array(e),this.iRead=0,this.iWrite=0}toBuffer(){return this.iRead===0&&this.iWrite===this.size?this.buffer:this.buffer.subarray(this.iRead,this.iWrite)}get length(){return this.iWrite-this.iRead}get eod(){return this.iRead===this.iWrite}get full(){return this.iWrite===this.size}read(e){if(e===0)return null;if(e===void 0||e>=this.length){let e=this.toBuffer();return this.iRead=this.iWrite,e}let t=this.buffer.subarray(this.iRead,this.iRead+e);return this.iRead+=e,t}write(e,t,n){let r=Math.min(n,this.size-this.iWrite);return e.copy(this.buffer,this.iWrite,t,r),this.iWrite+=r,r}};let fc=()=>{};var pc=class extends W{constructor(e){super(),this._writableStreamWriter=null,this._asyncWriteQueue=Promise.resolve(),this.bufSize=e?.bufSize||1024*1024,this.buffers=[],this.batch=e?.batch??!1,this.corked=!1,this.paused=!1,this.encoding=null,this.pipes=[],this._ended=!1}get writable(){return!this._ended}toBuffer(){switch(this.buffers.length){case 0:return null;case 1:return this.buffers[0].toBuffer();default:{let e=this.buffers.reduce((e,t)=>e+t.length,0),t=new Uint8Array(e),n=0;for(let e of this.buffers){let r=e.toBuffer();t.set(r,n),n+=r.length}return t}}}_getWritableBuffer(){if(this.buffers.length){let e=this.buffers[this.buffers.length-1];if(!e.full)return e}let e=new dc(this.bufSize);return this.buffers.push(e),e}async _pipeChunk(e){let t=this.pipes.map(t=>new Promise(n=>{t.write(e.toBuffer(),()=>n())}));await Promise.all(t)}_writeToBuffers(e){let t=0,n=e.length;for(;t<n;){let r=this._getWritableBuffer();t+=r.write(e,t,n-t)}}async write(e,t,n){typeof t==`function`&&(n=t),n||=fc;let r;if(e instanceof sc||e&&e.constructor?.name===`StringBuf`)r=new lc(e);else if(e instanceof Uint8Array)r=new uc(e);else if(ArrayBuffer.isView(e))r=new uc(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));else if(e instanceof ArrayBuffer)r=new uc(new Uint8Array(e));else if(typeof e==`string`)r=new cc(e);else throw new g(typeof e,`Chunk must be one of type String, Uint8Array, ArrayBuffer or StringBuf.`);if(this.pipes.length)if(this.batch)for(this._writeToBuffers(r);!this.corked&&this.buffers.length>1;){let e=this.buffers.shift();await this._pipeChunk(new uc(e.toBuffer()))}else this.corked?(this._writeToBuffers(r),queueMicrotask(()=>n())):(await this._pipeChunk(r),n());else{let e=r.toBuffer(),t=!1;!this.paused&&this.listenerCount(`data`)>0&&(this.emit(`data`,e),t=!0),this._writableStreamWriter&&(this._asyncWriteQueue=this._asyncWriteQueue.then(()=>this._writableStreamWriter.write(e)),t=!0),t||(this._writeToBuffers(r),this.emit(`readable`))}return!0}cork(){this.corked=!0}_flush(){this.pipes.length&&(async()=>{for(;this.buffers.length;){let e=this.buffers.shift();await this._pipeChunk(new uc(e.toBuffer()))}})().catch(e=>this.emit(`error`,e))}uncork(){this.corked=!1,this._flush()}end(e,t,n){let r=e=>{if(e){n?.(e);return}this._ended=!0,this._flush(),this.pipes.forEach(e=>{typeof e.end==`function`&&e.end()}),this._writableStreamWriter?this._asyncWriteQueue.then(()=>this._writableStreamWriter.close()).then(()=>{this.emit(`finish`)}).catch(e=>{this.emit(`error`,e)}):this.emit(`finish`)};e?this.write(e,t,r):r()}read(e){if(e){let t=[],n=e;for(;n&&this.buffers.length&&!this.buffers[0].eod;){let e=this.buffers[0],r=e.read(n);r&&(n-=r.length,t.push(r)),e.eod&&e.full&&this.buffers.shift()}return an(mc(t))}let t=this.buffers.map(e=>e.toBuffer()).filter(Boolean);return this.buffers=[],an(mc(t))}readString(e){let t=e??this.encoding??`utf-8`,n=this.read();return Ht(t).decode(n)}setEncoding(e){this.encoding=e}pause(){this.paused=!0}resume(){this.paused=!1}isPaused(){return this.paused}pipe(e){return this.pipes.push(e),!this.paused&&this.buffers.length&&this.end(),e}pipeTo(e){this._writableStreamWriter=e.getWriter()}unpipe(e){this.pipes=this.pipes.filter(t=>t!==e)}unshift(){throw new v(`unshift`,`Not implemented`)}wrap(){throw new v(`wrap`,`Not implemented`)}push(e){return e!==null&&this.write(e),!0}};function mc(e){if(e.length===0)return new Uint8Array;if(e.length===1)return e[0];let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}let hc=null;function gc(){if(hc)return hc;let e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}return hc=e,e}function _c(e,t){let n=gc();for(let r=0;r<t.length;r++)e=n[(e^t[r])&255]^e>>>8;return e}function vc(e){return(e^4294967295)>>>0}function yc(e){return vc(_c(4294967295,e))}function bc(e,t){return(gc()[(e^t)&255]^e>>>8)>>>0}let xc=(()=>{let e=new Uint8Array(288);for(let t=0;t<=143;t++)e[t]=8;for(let t=144;t<=255;t++)e[t]=9;for(let t=256;t<=279;t++)e[t]=7;for(let t=280;t<=287;t++)e[t]=8;return e})(),Sc=new Uint8Array(32).fill(5),Cc=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],wc=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Tc=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],Ec=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Dc=[[1,0,0],[2,1,0],[3,2,0],[4,3,0],[6,4,1],[8,5,1],[12,6,2],[16,7,2],[24,8,3],[32,9,3],[48,10,4],[64,11,4],[96,12,5],[128,13,5],[192,14,6],[256,15,6],[384,16,7],[512,17,7],[768,18,8],[1024,19,8],[1536,20,9],[2048,21,9],[3072,22,10],[4096,23,10],[6144,24,11],[8192,25,11],[12288,26,12],[16384,27,12],[24576,28,13],[32768,29,13]],Oc=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function kc(e,t){let n=new Uint16Array(16);for(let r=0;r<t;r++)e[r]>0&&n[e[r]]++;let r=new Uint16Array(16),i=0;for(let e=1;e<=15;e++)i=i+n[e-1]<<1,r[e]=i;let a={};for(let n=0;n<t;n++){let t=e[n];if(t===0)continue;i=r[t]++;let o=a;for(let e=t-1;e>=0;e--)i>>e&1?(o.right||={},o=o.right):(o.left||={},o=o.left);o.symbol=n}return a}var Ac=class{constructor(e){this.data=e,this.pos=0,this.bitBuf=0,this.bitCount=0}readBits(e){for(;this.bitCount<e;){if(this.pos>=this.data.length)throw Error(`Unexpected end of DEFLATE data`);this.bitBuf|=this.data[this.pos++]<<this.bitCount,this.bitCount+=8}let t=this.bitBuf&(1<<e)-1;return this.bitBuf>>=e,this.bitCount-=e,t}decodeSymbol(e){let t=e;for(;t.symbol===void 0;)if(t=this.readBits(1)===0?t.left:t.right,!t)throw Error(`Invalid Huffman code`);return t.symbol}alignToByte(){this.bitBuf=0,this.bitCount=0}readByte(){if(this.pos>=this.data.length)throw Error(`Unexpected end of data`);return this.data[this.pos++]}readUint16(){return this.readByte()|this.readByte()<<8}};function jc(e){let t=new Ac(e),n=[],r=!1;for(;!r;){r=t.readBits(1)===1;let e=t.readBits(2);if(e===0){t.alignToByte();let e=t.readUint16();if((e^t.readUint16())!==65535)throw Error(`Invalid stored block length`);for(let r=0;r<e;r++)n.push(t.readByte())}else if(e===1||e===2){let r,i;if(e===1)r=kc(xc,288),i=kc(Sc,32);else{let e=t.readBits(5)+257,n=t.readBits(5)+1,a=t.readBits(4)+4,o=new Uint8Array(19);for(let e=0;e<a;e++)o[Oc[e]]=t.readBits(3);let s=kc(o,19),c=new Uint8Array(e+n),l=0;for(;l<e+n;){let e=t.decodeSymbol(s);if(e<16)c[l++]=e;else if(e===16){let e=t.readBits(2)+3,n=c[l-1];for(let t=0;t<e;t++)c[l++]=n}else if(e===17){let e=t.readBits(3)+3;for(let t=0;t<e;t++)c[l++]=0}else if(e===18){let e=t.readBits(7)+11;for(let t=0;t<e;t++)c[l++]=0}}r=kc(c.subarray(0,e),e),i=kc(c.subarray(e),n)}for(;;){let e=t.decodeSymbol(r);if(e<256)n.push(e);else if(e===256)break;else{let r=e-257,a=Cc[r]+t.readBits(wc[r]),o=t.decodeSymbol(i),s=Tc[o]+t.readBits(Ec[o]),c=n.length-s;for(let e=0;e<a;e++)n.push(n[c+e])}}}else throw Error(`Invalid DEFLATE block type: `+e)}return new Uint8Array(n)}function Mc(e){let t=65535,n=Math.ceil(e.length/t)||1,r=n*5+e.length,i=new Uint8Array(r),a=0,o=0;for(let r=0;r<n;r++){let s=r===n-1,c=Math.min(t,e.length-o);i[a++]=s?1:0,i[a++]=c&255,i[a++]=c>>8&255,i[a++]=~c&255,i[a++]=~c>>8&255,i.set(e.subarray(o,o+c),a),a+=c,o+=c}return i.subarray(0,a)}function Nc(e){if(e.length===0)return new Uint8Array([3,0]);if(e.length<100)return Mc(e);let t=new Pc;t.writeBits(1,1),t.writeBits(1,2);let n=new Map,r=0;for(;r<e.length;){let i=0,a=0;if(r+2<e.length){let t=e[r]<<16|e[r+1]<<8|e[r+2],o=n.get(t);if(o!==void 0&&r-o<=32768){let t=r-o,n=0,s=Math.min(258,e.length-r);for(;n<s&&e[o+n]===e[r+n];)n++;n>=3&&(i=n,a=t)}n.set(t,r)}i>=3?(Lc(t,i),Rc(t,a),r+=i):(Ic(t,e[r]),r++)}return Ic(t,256),t.finish()}var Pc=class{constructor(){this.chunks=[],this.buffer=[],this.bitBuf=0,this.bitCount=0}writeBits(e,t){for(this.bitBuf|=e<<this.bitCount,this.bitCount+=t;this.bitCount>=8;)this.buffer.push(this.bitBuf&255),this.bitBuf>>=8,this.bitCount-=8,this.buffer.length>=65536&&(this.chunks.push(new Uint8Array(this.buffer)),this.buffer=[])}writeBitsReverse(e,t){let n=0;for(let r=0;r<t;r++)n=n<<1|e>>r&1;this.writeBits(n,t)}finish(){return this.bitCount>0&&this.buffer.push(this.bitBuf&255),this.chunks.length===0?new Uint8Array(this.buffer):(this.chunks.push(new Uint8Array(this.buffer)),O(this.chunks))}flushBytes(){if(this.chunks.length===0&&this.buffer.length===0)return new Uint8Array;let e;return this.chunks.length===0?e=new Uint8Array(this.buffer):(this.chunks.push(new Uint8Array(this.buffer)),e=O(this.chunks),this.chunks=[]),this.buffer=[],e}};let Fc=(()=>{let e=[];for(let t=0;t<=287;t++){let n,r;t<=143?(n=48+t,r=8):t<=255?(n=400+(t-144),r=9):t<=279?(n=t-256,r=7):(n=192+(t-280),r=8),e[t]=[n,r]}return e})();function Ic(e,t){let[n,r]=Fc[t];e.writeBitsReverse(n,r)}function Lc(e,t){let n,r,i;if(t<=10)n=257+t-3,r=0,i=0;else if(t<=18){let e=t-11;n=265+Math.floor(e/2),r=1,i=e%2}else if(t<=34){let e=t-19;n=269+Math.floor(e/4),r=2,i=e%4}else if(t<=66){let e=t-35;n=273+Math.floor(e/8),r=3,i=e%8}else if(t<=130){let e=t-67;n=277+Math.floor(e/16),r=4,i=e%16}else if(t<=257){let e=t-131;n=281+Math.floor(e/32),r=5,i=e%32}else n=285,r=0,i=0;Ic(e,n),r>0&&e.writeBits(i,r)}function Rc(e,t){let n=0,r=0,i=1;for(let e=0;e<Dc.length;e++){let[a,o,s]=Dc[e];if(t<=a){n=o,r=s;break}i=a+1}let a=t-i;e.writeBitsReverse(n,5),r>0&&e.writeBits(a,r)}let zc=32768;var Bc=class{constructor(){this._output=new Pc,this._hashTable=new Map,this._window=new Uint8Array(zc),this._windowLen=0,this._totalIn=0}write(e){if(e.length===0)return new Uint8Array;let t=this._output;t.writeBits(0,1),t.writeBits(1,2);let n=this._window,r=this._windowLen,i=this._hashTable,a=this._totalIn;for(let o=0;o<e.length;){let s=0,c=0;if(o+2<e.length){let t=e[o]<<16|e[o+1]<<8|e[o+2],l=i.get(t);if(l!==void 0){let t=a+o-l;if(t>0&&t<=zc){let i=((r-t)%zc+zc)%zc,a=Math.min(258,e.length-o),l=0;for(;l<a&&n[(i+l)%zc]===e[o+l];)l++;l>=3&&(s=l,c=t)}}i.set(t,a+o)}if(s>=3){Lc(t,s),Rc(t,c);for(let t=0;t<s;t++)n[r%zc]=e[o+t],r++;o+=s}else Ic(t,e[o]),n[r%zc]=e[o],r++,o++}return Ic(t,256),this._windowLen=r,this._totalIn=a+e.length,t.flushBytes()}finish(){let e=this._output;return e.writeBits(1,1),e.writeBits(1,2),Ic(e,256),e.finish()}};let G=new Uint8Array;function Vc(e,t,n=0){let r=e.length,i=t.length;if(i===0)return 0;if(i>r)return-1;let a=n|0;if(a<0&&(a=0),a>r-i)return-1;if(i===1)return e.indexOf(t[0],a);if(i===2){let n=t[0],i=t[1],o=r-2,s=e.indexOf(n,a);for(;s!==-1&&s<=o;){if(e[s+1]===i)return s;s=e.indexOf(n,s+1)}return-1}if(i===3){let n=t[0],i=t[1],o=t[2],s=r-3,c=e.indexOf(n,a);for(;c!==-1&&c<=s;){if(e[c+1]===i&&e[c+2]===o)return c;c=e.indexOf(n,c+1)}return-1}if(i===4){let n=t[0],i=t[1],o=t[2],s=t[3],c=r-4,l=e.indexOf(n,a);for(;l!==-1&&l<=c;){if(e[l+1]===i&&e[l+2]===o&&e[l+3]===s)return l;l=e.indexOf(n,l+1)}return-1}outer:for(let n=a;n<=r-i;n++){for(let r=0;r<i;r++)if(e[n+r]!==t[r])continue outer;return n}return-1}var Hc=class{_activeChunkCount(){return this._chunks.length-this._chunkHead}_headChunk(){return this._chunks[this._chunkHead]}_compactConsumedChunks(){if(this._chunkHead!==0){if(this._chunkHead>=this._chunks.length){this._chunks=[],this._chunkHead=0;return}this._chunkHead>32&&this._chunkHead*2>=this._chunks.length&&(this._chunks=this._chunks.slice(this._chunkHead),this._chunkHead=0)}}_dropHeadChunk(){this._chunkHead++,this._headOffset=0,this._compactConsumedChunks()}constructor(e){this._chunks=[],this._chunkHead=0,this._headOffset=0,this._length=0,this._cachedView=null,this._cachedLength=0,e&&e.length>0&&this.reset(e)}get length(){return this._length}isEmpty(){return this.length===0}view(){if(this._length===0)return G;if(this._activeChunkCount()===1)return this._headChunk().subarray(this._headOffset,this._headOffset+this._length);if(this._cachedView&&this._cachedLength===this._length)return this._cachedView;let e=new Uint8Array(this._length),t=0;for(let n=this._chunkHead;n<this._chunks.length;n++){let r=this._chunks[n],i=n===this._chunkHead?this._headOffset:0,a=n===this._chunks.length-1?i+(this._length-t):r.length;if(e.set(r.subarray(i,a),t),t+=a-i,t>=e.length)break}return this._cachedView=e,this._cachedLength=this._length,e}reset(e){if(this._cachedView=null,this._cachedLength=0,this._chunks=[],this._chunkHead=0,this._headOffset=0,this._length=0,!e||e.length===0)return;let t=new Uint8Array(e.length);t.set(e),this._chunks=[t],this._chunkHead=0,this._headOffset=0,this._length=t.length}append(e){e.length!==0&&(this._cachedView=null,this._cachedLength=0,this._chunks.push(e),this._length+=e.length)}read(e){if(e<=0)return G;if(e>this._length)throw RangeError(`ByteQueue: read beyond available data`);if(this._cachedView=null,this._cachedLength=0,this._activeChunkCount()===1){let t=this._headChunk(),n=this._headOffset,r=n+e,i=t.subarray(n,r);return this._headOffset=r,this._length-=e,this._length===0?(this._chunks=[],this._chunkHead=0,this._headOffset=0):this._headOffset>=t.length&&this._dropHeadChunk(),i}let t=new Uint8Array(e),n=0,r=e;for(;r>0;){let e=this._headChunk(),i=this._headOffset,a=e.length-i,o=Math.min(a,r);t.set(e.subarray(i,i+o),n),n+=o,r-=o,this._headOffset+=o,this._length-=o,this._headOffset>=e.length&&this._dropHeadChunk()}return this._length===0&&(this._chunks=[],this._chunkHead=0,this._headOffset=0),t}peekChunks(e){if(e<=0)return[];if(e>this._length)throw RangeError(`ByteQueue: peek beyond available data`);if(this._activeChunkCount()===1){let t=this._headChunk(),n=this._headOffset;return[t.subarray(n,n+e)]}let t=[],n=e;for(let e=this._chunkHead;e<this._chunks.length&&n>0;e++){let r=this._chunks[e],i=e===this._chunkHead?this._headOffset:0,a=r.length-i;if(a<=0)continue;let o=Math.min(a,n);t.push(r.subarray(i,i+o)),n-=o}return t}discard(e){if(e<=0)return;if(e>=this._length){this._chunks=[],this._chunkHead=0,this._headOffset=0,this._length=0,this._cachedView=null,this._cachedLength=0;return}this._cachedView=null,this._cachedLength=0;let t=e;for(;t>0;){let e=this._headChunk(),n=this._headOffset,r=e.length-n,i=Math.min(r,t);this._headOffset+=i,this._length-=i,t-=i,this._headOffset>=e.length&&this._dropHeadChunk()}this._length===0&&(this._chunks=[],this._chunkHead=0,this._headOffset=0)}indexOfPattern(e,t=0){let n=e.length;if(n===0)return 0;let r=this._length;if(n>r)return-1;let i=t|0;if(i<0&&(i=0),i>r-n)return-1;if(this._activeChunkCount()===1){let t=this._headChunk(),a=this._headOffset,o=t.subarray(a,a+r);return n===1?o.indexOf(e[0],i):Vc(o,e,i)}if(n>4)return Vc(this.view(),e,i);let a=e[0],o=n>=2?e[1]:0,s=n>=3?e[2]:0,c=n>=4?e[3]:0,l=this._chunks,u=this._chunkHead,d=(e,t)=>{let n=e,r=t;for(;n<l.length;){let e=l[n];if(r<e.length)return e[r]|0;r-=e.length,n++}return null},f=0;for(let e=u;e<l.length;e++){let t=l[e],p=e===u?this._headOffset:0,m=t.length-p;if(m<=0)continue;let h=f,g=h+m,_=i<=h?p:i>=g?t.length:p+(i-h);if(_>t.length-1){f+=m;continue}let v=t.length-1,y=t.indexOf(a,_);for(;y!==-1&&y<=v;){let i=h+(y-p);if(i>r-n)return-1;if(n===1)return i;if(y+n<=t.length){if(t[y+1]!==o){y=t.indexOf(a,y+1);continue}if(n===2)return i;if(t[y+2]!==s){y=t.indexOf(a,y+1);continue}if(n===3)return i;if(t[y+3]!==c){y=t.indexOf(a,y+1);continue}return i}let l=d(e,y+1);if(l===null||l!==o){y=t.indexOf(a,y+1);continue}if(n===2)return i;let u=d(e,y+2);if(u===null||u!==s){y=t.indexOf(a,y+1);continue}if(n===3)return i;let f=d(e,y+3);if(f===null||f!==c){y=t.indexOf(a,y+1);continue}return i}f+=m}return-1}peekUint32LE(e){let t=e|0;if(t<0||t+4>this._length)return null;let n=this._chunks,r=t;for(let e=this._chunkHead;e<n.length;e++){let t=n[e],i=e===this._chunkHead?this._headOffset:0,a=t.length-i;if(r<a){let a=i+r;if(a+4<=t.length){let e=t[a]|0,n=t[a+1]|0,r=t[a+2]|0,i=t[a+3]|0;return(e|n<<8|r<<16|i<<24)>>>0}let o=t[a]|0,s=0,c=0,l=0,u=e,d=a+1;for(let e=1;e<4;e++)for(;u<n.length;){let t=n[u];if(d<t.length){let n=t[d]|0;e===1?s=n:e===2?c=n:l=n,d++;break}u++,d=0}return(o|s<<8|c<<16|l<<24)>>>0}r-=a}return null}peekByte(e){let t=e|0;if(t<0||t>=this._length)throw RangeError(`ByteQueue: peek beyond available data`);let n=t;for(let e=this._chunkHead;e<this._chunks.length;e++){let t=this._chunks[e],r=e===this._chunkHead?this._headOffset:0,i=t.length-r;if(n<i)return t[r+n]|0;n-=i}throw RangeError(`ByteQueue: peek beyond available data`)}};function Uc(){try{return typeof CompressionStream>`u`?!1:(new CompressionStream(`deflate-raw`),!0)}catch{return!1}}function Wc(){try{return typeof DecompressionStream>`u`?!1:(new DecompressionStream(`deflate-raw`),!0)}catch{return!1}}let Gc=null,Kc=null;function qc(){return typeof CompressionStream>`u`?!1:(Gc===null&&(Gc=Uc()),Gc)}function Jc(){return typeof DecompressionStream>`u`?!1:(Kc===null&&(Kc=Wc()),Kc)}function Yc(){return qc()&&Jc()}async function Xc(e){let t=new Hc;for(;;){let{done:n,value:r}=await e.read();if(n)break;t.append(r)}return t.read(t.length)}async function Zc(e,t){let n=t.writable.getWriter(),r=t.readable.getReader();try{let t=Xc(r);return await n.write(e),await n.close(),await t}finally{try{n.releaseLock()}catch{}try{r.releaseLock()}catch{}}}async function Qc(e){return Zc(e,new DecompressionStream(`deflate-raw`))}let $c={};function el(e,t){let n=`${e}:${t}`;return()=>{let r=e===`compression`?typeof CompressionStream<`u`?CompressionStream:void 0:typeof DecompressionStream<`u`?DecompressionStream:void 0;if(!r)return!1;let i=$c[n];if(i!=null)return i;try{new r(t),$c[n]=!0}catch{$c[n]=!1}return $c[n]}}el(`compression`,`gzip`),el(`decompression`,`gzip`),el(`compression`,`deflate`),el(`decompression`,`deflate`),new Uint8Array([120,1]),new Uint8Array([120,1]),new Uint8Array([120,94]),new Uint8Array([120,94]),new Uint8Array([120,94]),new Uint8Array([120,94]),new Uint8Array([120,156]),new Uint8Array([120,218]),new Uint8Array([120,218]),new Uint8Array([120,218]);var tl=class extends t{constructor(e,t){super(e,t),this.name=`ArchiveError`}},nl=class extends tl{constructor(e,t,n){super(`CRC32 mismatch for "${e}": expected 0x${t.toString(16).padStart(8,`0`)}, got 0x${n.toString(16).padStart(8,`0`)}`),this.path=e,this.expected=t,this.actual=n,this.name=`Crc32MismatchError`}},rl=class extends tl{constructor(e,t,n,r){let i=r===`too-many-bytes`?`Entry "${e}" produced more bytes than declared: expected ${t}, got at least ${n}`:`Entry "${e}" produced fewer bytes than declared: expected ${t}, got ${n}`;super(i),this.path=e,this.expected=t,this.actual=n,this.reason=r,this.name=`EntrySizeMismatchError`}isZipBomb(){return this.reason===`too-many-bytes`}isCorruption(){return this.reason===`too-few-bytes`}},il=class extends tl{constructor(e,t){super(t?`Failed to decrypt "${e}": ${t}`:`Failed to decrypt "${e}": incorrect password or corrupted data`),this.name=`DecryptionError`}},al=class extends tl{constructor(e){super(`File "${e}" is encrypted. Please provide a password to extract.`),this.name=`PasswordRequiredError`}},ol=class extends tl{constructor(e){super(`Unsupported compression method: ${e}`),this.name=`UnsupportedCompressionError`}};let sl={maxWorkers:typeof navigator<`u`&&navigator.hardwareConcurrency||4,minWorkers:0,idleTimeout:3e4,useTransferables:!0,workerUrl:void 0};function cl(e){let t=e?.maxWorkers??sl.maxWorkers,n=e?.minWorkers??sl.minWorkers,r=Math.min(n,t);return{maxWorkers:Math.max(1,t),minWorkers:Math.max(0,r),idleTimeout:Math.max(0,e?.idleTimeout??sl.idleTimeout),useTransferables:e?.useTransferables??sl.useTransferables,workerUrl:e?.workerUrl}}let ll={high:3,normal:2,low:1};function ul(e){return e?ll[e]??ll.normal:ll.normal}function dl(){return typeof Worker<`u`&&typeof Blob<`u`}function fl(){return`
29
+ </r>`)}return n.join(``)}renderCellNew(e,t){if(e==null||typeof e==`number`&&!Number.isFinite(e)){if(t===null)return`<m />`;let e=t.indexOf(null);return e>=0?`<x v="${e}" />`:`<m />`}if(t===null)return e instanceof cn?`<e v="${D(e.code)}" />`:typeof e==`boolean`?`<b v="${e?`1`:`0`}" />`:e instanceof Date?`<d v="${Es(e)}" />`:Number.isFinite(e)?`<n v="${e}" />`:`<s v="${D(String(e))}" />`;let n=Ns(t,e);if(n<0)throw new x(`${JSON.stringify(e)} not in sharedItems ${JSON.stringify(t)}`);return`<x v="${n}" />`}parseOpen(e){let{name:t,attributes:n}=e;switch(t){case this.tag:{this.reset();let e={};for(let[t,r]of Object.entries(n))js.has(t)||(e[t]=String(r));this.model={records:[],count:parseInt(n.count??`0`,10),isLoaded:!0,extraRootAttrs:Object.keys(e).length>0?e:void 0};break}case`r`:this.currentRecord=[];break;case`x`:this.currentRecord&&this.currentRecord.push({type:`x`,value:parseInt(n.v??`0`,10)});break;case`n`:this.currentRecord&&(n.v===void 0||n.v===``?this.currentRecord.push({type:`m`}):this.currentRecord.push({type:`n`,value:parseFloat(n.v)}));break;case`s`:this.currentRecord&&this.currentRecord.push({type:`s`,value:n.v??``});break;case`b`:this.currentRecord&&this.currentRecord.push({type:`b`,value:n.v===`1`});break;case`m`:this.currentRecord&&this.currentRecord.push({type:`m`});break;case`d`:if(this.currentRecord)if(!n.v)this.currentRecord.push({type:`m`});else{let e=ft(n.v);isNaN(e.getTime())?this.currentRecord.push({type:`m`}):this.currentRecord.push({type:`d`,value:e})}break;case`e`:this.currentRecord&&this.currentRecord.push({type:`e`,value:n.v??``});break}return!0}parseText(e){}parseClose(e){switch(e){case this.tag:return!1;case`r`:this.model&&this.currentRecord&&(this.model.records.push(this.currentRecord),this.currentRecord=null);break}return!0}static{this.PIVOT_CACHE_RECORDS_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,"xmlns:mc":`http://schemas.openxmlformats.org/markup-compatibility/2006`,"mc:Ignorable":`xr`,"xmlns:xr":`http://schemas.microsoft.com/office/spreadsheetml/2014/revision`}}};function Ns(e,t){if(t instanceof Date){let n=t.getTime();for(let t=0;t<e.length;t++){let r=e[t];if(r instanceof Date&&r.getTime()===n)return t}return-1}if(t instanceof cn){for(let n=0;n<e.length;n++){let r=e[n];if(r instanceof cn&&r.code===t.code)return n}return-1}return e.indexOf(t)}var Ps=class{constructor(e){this.active=!1,this.depth=0,this.buffer=[],this.lastOpenIndex=-1,this.rootTag=e}start(e){this.active=!0,this.depth=0;let t=Fs(e);this.buffer=[`<${this.rootTag}${t?` `+t:``}>`]}startAs(e,t){this.rootTag=e,this.start(t)}reset(){this.active=!1,this.depth=0,this.buffer.length=0,this.lastOpenIndex=-1}feedOpen(e,t){let n=Fs(t);this.buffer.push(`<${e}${n?` `+n:``}>`),this.depth++,this.lastOpenIndex=this.buffer.length-1}feedText(e){this.buffer.push(D(e)),this.lastOpenIndex=-1}feedClose(e){if(e===this.rootTag&&this.depth===0)return this.buffer.push(`</${e}>`),this.active=!1,this.lastOpenIndex=-1,!0;if(this.depth>0&&this.depth--,this.lastOpenIndex>=0&&this.lastOpenIndex===this.buffer.length-1){let e=this.buffer[this.lastOpenIndex];return this.buffer[this.lastOpenIndex]=e.slice(0,-1)+` />`,this.lastOpenIndex=-1,!1}return this.lastOpenIndex=-1,this.buffer.push(`</${e}>`),!1}get result(){return this.buffer.join(``)}};function Fs(e){if(!e)return``;let t=Object.entries(e);return t.length===0?``:t.filter(([,e])=>e!=null).map(([e,t])=>`${e}="${D(String(t))}"`).join(` `)}let Is=new Set([`name`,`numFmtId`]);var Ls=class extends j{constructor(){super(),this.inSharedItems=!1,this.fieldGroupCollector=new Ps(`fieldGroup`),this.model=null}get tag(){return`cacheField`}reset(){this.model=null,this.inSharedItems=!1,this.fieldGroupCollector.reset()}parseOpen(e){let{name:t,attributes:n}=e;if(this.fieldGroupCollector.active)return this.fieldGroupCollector.feedOpen(t,n),!0;switch(t){case`cacheField`:{let e={};for(let[t,r]of Object.entries(n))Is.has(t)||(e[t]=String(r));this.model={name:n.name??``,sharedItems:null,numFmtId:n.numFmtId,isLoaded:!0,extraAttrs:Object.keys(e).length>0?e:void 0};break}case`fieldGroup`:this.model&&this.fieldGroupCollector.start(n);break;case`sharedItems`:if(this.inSharedItems=!0,this.model){if(n.containsNumber!==void 0&&(this.model.containsNumber=n.containsNumber),n.containsInteger!==void 0&&(this.model.containsInteger=n.containsInteger),n.minValue!==void 0){let e=parseFloat(n.minValue);Number.isFinite(e)&&(this.model.minValue=e)}if(n.maxValue!==void 0){let e=parseFloat(n.maxValue);Number.isFinite(e)&&(this.model.maxValue=e)}n.containsSemiMixedTypes!==void 0&&(this.model.containsSemiMixedTypes=n.containsSemiMixedTypes),n.containsNonDate!==void 0&&(this.model.containsNonDate=n.containsNonDate),n.containsString!==void 0&&(this.model.containsString=n.containsString),n.containsBlank!==void 0&&(this.model.containsBlank=n.containsBlank),n.containsDate!==void 0&&(this.model.containsDate=n.containsDate),n.containsMixedTypes!==void 0&&(this.model.containsMixedTypes=n.containsMixedTypes),this.model.sharedItems=[]}break;case`s`:case`n`:case`b`:case`e`:case`m`:case`d`:this.inSharedItems&&this.model&&this.model.sharedItems!==null&&this.model.sharedItems.push(Rs(t,n));break}return!0}parseText(e){this.fieldGroupCollector.active&&this.fieldGroupCollector.feedText(e)}parseClose(e){if(this.fieldGroupCollector.active)return this.fieldGroupCollector.feedClose(e)&&(this.model&&(this.model.fieldGroupXml=this.fieldGroupCollector.result),this.fieldGroupCollector.reset()),!0;switch(e){case`cacheField`:return!1;case`sharedItems`:this.inSharedItems=!1;break}return!0}};function Rs(e,t){switch(e){case`s`:return t.v??``;case`n`:return t.v===void 0||t.v===``?null:parseFloat(t.v);case`b`:return t.v===`1`;case`e`:return new cn(t.v??``);case`m`:return null;case`d`:{if(!t.v)return null;let e=ft(t.v);return isNaN(e.getTime())?null:e}default:return null}}let zs=new Set([`xmlns`,`xmlns:r`,`r:id`,`refreshOnLoad`,`createdVersion`,`refreshedVersion`,`minRefreshableVersion`,`recordCount`,`backgroundQuery`,`supportSubquery`,`supportAdvancedDrill`]);var Bs=class e extends j{constructor(){super(),this.currentCacheField=null,this.inCacheFields=!1,this.inCacheSource=!1,this.extLstCollector=new Ps(`extLst`),this.unknownCollector=new Ps(``),this.unknownElementsXmlParts=[],this.cacheSourceChildCollector=new Ps(``),this.cacheSourceXmlParts=[],this.model=null}get tag(){return`pivotCacheDefinition`}reset(){this.model=null,this.currentCacheField=null,this.inCacheFields=!1,this.inCacheSource=!1,this.extLstCollector.reset(),this.unknownCollector.reset(),this.unknownElementsXmlParts=[],this.cacheSourceChildCollector.reset(),this.cacheSourceXmlParts=[]}render(e,t){`isLoaded`in t&&t.isLoaded||!(`source`in t)?this.renderLoaded(e,t):this.renderNew(e,t)}renderNew(t,n){let{source:r,cacheFields:i}=n,a=r.getSheetValues().slice(2).filter(Array.isArray).length;t.openXml(k.StdDocAttributes),t.openNode(this.tag,{...e.PIVOT_CACHE_DEFINITION_ATTRIBUTES,"r:id":`rId1`,refreshOnLoad:`1`,createdVersion:`8`,refreshedVersion:`8`,minRefreshableVersion:`3`,recordCount:a}),t.openNode(`cacheSource`,{type:`worksheet`});let o=r.tableName?{name:r.tableName}:{ref:r.dimensions.shortRange,sheet:r.name};t.leafNode(`worksheetSource`,o),t.closeNode(),t.openNode(`cacheFields`,{count:i.length}),t.writeXml(e.renderCacheFieldsXml(i)),t.closeNode(),t.closeNode()}renderLoaded(t,n){let{cacheFields:r,sourceRef:i,sourceSheet:a,sourceTableName:o,recordCount:s}=n;t.openXml(k.StdDocAttributes);let c={...e.PIVOT_CACHE_DEFINITION_ATTRIBUTES,"r:id":n.rId??`rId1`};if(n.refreshOnLoad&&(c.refreshOnLoad=n.refreshOnLoad),c.createdVersion=n.createdVersion??`8`,c.refreshedVersion=n.refreshedVersion??`8`,c.minRefreshableVersion=n.minRefreshableVersion??`3`,s!==void 0&&(c.recordCount=s),n.backgroundQuery&&(c.backgroundQuery=n.backgroundQuery),n.supportSubquery&&(c.supportSubquery=n.supportSubquery),n.supportAdvancedDrill&&(c.supportAdvancedDrill=n.supportAdvancedDrill),n.extraRootAttrs)for(let[e,t]of Object.entries(n.extraRootAttrs))c[e]=t;if(t.openNode(this.tag,c),t.openNode(`cacheSource`,{type:n.cacheSourceType??`worksheet`}),!n.cacheSourceType||n.cacheSourceType===`worksheet`){let e=o?{name:o}:{ref:i,sheet:a};n.worksheetSourceRId&&(e[`r:id`]=n.worksheetSourceRId),Object.values(e).some(e=>e!==void 0)&&t.leafNode(`worksheetSource`,e)}n.cacheSourceXml&&t.writeXml(n.cacheSourceXml),t.closeNode(),t.openNode(`cacheFields`,{count:r.length}),t.writeXml(e.renderCacheFieldsXml(r)),t.closeNode(),n.unknownElementsXml&&t.writeXml(n.unknownElementsXml),n.extLstXml&&t.writeXml(n.extLstXml),t.closeNode()}parseOpen(e){let{name:t,attributes:n}=e;if(this.extLstCollector.active)return this.extLstCollector.feedOpen(t,n),!0;if(this.unknownCollector.active)return this.unknownCollector.feedOpen(t,n),!0;if(this.cacheSourceChildCollector.active)return this.cacheSourceChildCollector.feedOpen(t,n),!0;if(this.currentCacheField)return this.currentCacheField.parseOpen(e),!0;switch(t){case this.tag:{this.reset();let e={};for(let[t,r]of Object.entries(n))zs.has(t)||(e[t]=String(r));this.model={cacheFields:[],rId:n[`r:id`],refreshOnLoad:n.refreshOnLoad,createdVersion:n.createdVersion,refreshedVersion:n.refreshedVersion,minRefreshableVersion:n.minRefreshableVersion,recordCount:n.recordCount?parseInt(n.recordCount,10):void 0,backgroundQuery:n.backgroundQuery,supportSubquery:n.supportSubquery,supportAdvancedDrill:n.supportAdvancedDrill,extraRootAttrs:Object.keys(e).length>0?e:void 0,isLoaded:!0};break}case`cacheSource`:this.inCacheSource=!0,this.model&&(this.model.cacheSourceType=n.type);break;case`worksheetSource`:this.inCacheSource&&this.model&&(this.model.sourceRef=n.ref,this.model.sourceSheet=n.sheet,this.model.sourceTableName=n.name,n[`r:id`]&&(this.model.worksheetSourceRId=n[`r:id`]));break;case`cacheFields`:this.inCacheFields=!0;break;case`cacheField`:this.inCacheFields&&(this.currentCacheField=new Ls,this.currentCacheField.parseOpen(e));break;case`extLst`:this.model&&this.extLstCollector.start(n);break;default:if(this.inCacheSource&&this.model){this.cacheSourceChildCollector.startAs(t,n);break}this.model&&this.unknownCollector.startAs(t,n);break}return!0}parseText(e){if(this.extLstCollector.active){this.extLstCollector.feedText(e);return}if(this.unknownCollector.active){this.unknownCollector.feedText(e);return}if(this.cacheSourceChildCollector.active){this.cacheSourceChildCollector.feedText(e);return}this.currentCacheField&&this.currentCacheField.parseText(e)}parseClose(e){if(this.extLstCollector.active)return this.extLstCollector.feedClose(e)&&(this.model&&(this.model.extLstXml=this.extLstCollector.result),this.extLstCollector.reset()),!0;if(this.unknownCollector.active)return this.unknownCollector.feedClose(e)&&(this.unknownElementsXmlParts.push(this.unknownCollector.result),this.unknownCollector.reset()),!0;if(this.cacheSourceChildCollector.active)return this.cacheSourceChildCollector.feedClose(e)&&(this.cacheSourceXmlParts.push(this.cacheSourceChildCollector.result),this.cacheSourceChildCollector.reset()),!0;if(this.currentCacheField)return this.currentCacheField.parseClose(e)||(this.model&&this.currentCacheField.model&&this.model.cacheFields.push(this.currentCacheField.model),this.currentCacheField=null),!0;switch(e){case this.tag:return this.model&&this.unknownElementsXmlParts.length>0&&(this.model.unknownElementsXml=this.unknownElementsXmlParts.join(``)),!1;case`cacheSource`:this.inCacheSource=!1,this.model&&this.cacheSourceXmlParts.length>0&&(this.model.cacheSourceXml=this.cacheSourceXmlParts.join(``));break;case`cacheFields`:this.inCacheFields=!1;break}return!0}static renderCacheFieldsXml(e){return`
30
+ `+e.map(e=>Ds(e)).join(`
31
+ `)}static{this.PIVOT_CACHE_DEFINITION_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,"xmlns:r":`http://schemas.openxmlformats.org/officeDocument/2006/relationships`}}};let Vs=`PivotStyleLight16`,Hs=new Set([`axisRow`,`axisCol`,`axisPage`,`axisValues`]),Us=[`x`,`t`,`h`,`sd`,`f`,`m`,`c`,`d`];function Ws(){return{currentSection:null,inPivotArea:!1,inAutoSortScope:!1}}let Gs=new Set([`axis`,`dataField`,`compact`,`outline`,`showAll`,`defaultSubtotal`,`numFmtId`,`sortType`,`subtotalTop`,`insertBlankRow`,`multipleItemSelectionAllowed`]);var Ks=class e extends j{constructor(){super(),this.state=Ws(),this.currentPivotField=null,this.currentRowItem=null,this.currentColItem=null,this.currentChartFormat=null,this.pivotAreaXmlBuffer=[],this.autoSortScopeXmlBuffer=[],this.extLstCollector=new Ps(`extLst`),this.formatsCollector=new Ps(`formats`),this.conditionalFormatsCollector=new Ps(`conditionalFormats`),this.filtersCollector=new Ps(`filters`),this.unknownCollector=new Ps(``),this.unknownElementsXmlParts=[],this.model=null}get tag(){return`pivotTableDefinition`}reset(){this.model=null,this.state=Ws(),this.currentPivotField=null,this.currentRowItem=null,this.currentColItem=null,this.currentChartFormat=null,this.pivotAreaXmlBuffer=[],this.autoSortScopeXmlBuffer=[],this.extLstCollector.reset(),this.formatsCollector.reset(),this.conditionalFormatsCollector.reset(),this.filtersCollector.reset(),this.unknownCollector.reset(),this.unknownElementsXmlParts=[]}render(e,t){`isLoaded`in t&&t.isLoaded?this.renderLoaded(e,t):this.renderNew(e,t)}renderNew(t,n){let{rows:r,columns:i,values:a,pages:o=[],cacheFields:s,cacheId:c,tableNumber:l,applyWidthHeightFormats:u}=n,d=i.length===0&&a.length>1,f=o.length,p=f>0?f+1:0,m=r.length,h=3+p,g=h+1,_=m+(d?a.length:1),v=`A${h}:${S.n2l(_)}${g}`;t.openXml(k.StdDocAttributes),t.openNode(this.tag,{...e.PIVOT_TABLE_ATTRIBUTES,name:`PivotTable${l}`,cacheId:c,applyNumberFormats:`0`,applyBorderFormats:`0`,applyFontFormats:`0`,applyPatternFormats:`0`,applyAlignmentFormats:`0`,applyWidthHeightFormats:u,dataCaption:`Values`,updatedVersion:`8`,minRefreshableVersion:`3`,useAutoFormatting:`1`,itemPrintTitles:`1`,createdVersion:`8`,indent:`0`,compact:`0`,compactData:`0`,multipleFieldFilters:`0`});let y={ref:v,firstHeaderRow:1,firstDataRow:1,firstDataCol:m};f>0&&(y.rowPageCount=f,y.colPageCount=1),t.leafNode(`location`,y),Ys(t,n),t.openNode(`rowFields`,{count:r.length});for(let e of r)t.leafNode(`field`,{x:e});if(t.closeNode(),t.openNode(`rowItems`,{count:1}),t.openNode(`i`,{t:`grand`}),t.leafNode(`x`),t.closeNode(),t.closeNode(),i.length>0){let e=a.length>1?i.length+1:i.length;t.openNode(`colFields`,{count:e});for(let e of i)t.leafNode(`field`,{x:e});a.length>1&&t.leafNode(`field`,{x:-2}),t.closeNode()}else d&&(t.openNode(`colFields`,{count:1}),t.leafNode(`field`,{x:-2}),t.closeNode());if(d){t.openNode(`colItems`,{count:a.length+1});for(let e=0;e<a.length;e++)t.openNode(`i`),t.leafNode(`x`,e===0?void 0:{v:e}),t.closeNode();t.openNode(`i`,{t:`grand`}),t.leafNode(`x`),t.closeNode(),t.closeNode()}else t.openNode(`colItems`,{count:1}),t.leafNode(`i`),t.closeNode();if(f>0){t.openNode(`pageFields`,{count:f});for(let e of o)t.leafNode(`pageField`,{fld:e,hier:-1});t.closeNode()}Js(t,s,a,n.valueMetrics),t.leafNode(`pivotTableStyleInfo`,{name:Vs,showRowHeaders:`1`,showColHeaders:`1`,showRowStripes:`0`,showColStripes:`0`,showLastColumn:`1`}),t.writeXml(e.EXTLST_XML),t.closeNode()}renderLoaded(t,n){let r=this.buildLoadedRootAttributes(n);if(t.openXml(k.StdDocAttributes),t.openNode(this.tag,r),n.location){let e={ref:n.location.ref,firstHeaderRow:n.location.firstHeaderRow,firstDataRow:n.location.firstDataRow,firstDataCol:n.location.firstDataCol};n.location.rowPageCount!==void 0&&(e.rowPageCount=n.location.rowPageCount),n.location.colPageCount!==void 0&&(e.colPageCount=n.location.colPageCount),t.leafNode(`location`,e)}if(n.pivotFields.length>0){t.openNode(`pivotFields`,{count:n.pivotFields.length});for(let e of n.pivotFields)this.renderPivotFieldLoaded(t,e);t.closeNode()}if(n.rowFields.length>0){t.openNode(`rowFields`,{count:n.rowFields.length});for(let e of n.rowFields)t.leafNode(`field`,{x:e});t.closeNode()}if(n.rowItems&&n.rowItems.length>0){t.openNode(`rowItems`,{count:n.rowItems.length});for(let e of n.rowItems)this.renderRowColItem(t,e);t.closeNode()}else n.hasRowItems&&t.writeXml(`<rowItems count="1"><i t="grand"><x/></i></rowItems>`);if(n.hasColFields||n.colFields.length>0)if(n.colFields.length===0&&n.dataFields.length<=1)t.leafNode(`colFields`,{count:0});else{let e=n.colFields.length===0?1:n.colFields.length;if(t.openNode(`colFields`,{count:e}),n.colFields.length===0)t.leafNode(`field`,{x:-2});else for(let e of n.colFields)t.leafNode(`field`,{x:e});t.closeNode()}if(n.colItems&&n.colItems.length>0){t.openNode(`colItems`,{count:n.colItems.length});for(let e of n.colItems)this.renderRowColItem(t,e);t.closeNode()}else n.hasColItems&&t.writeXml(`<colItems count="1"><i t="grand"><x/></i></colItems>`);if(n.pageFields&&n.pageFields.length>0){t.openNode(`pageFields`,{count:n.pageFields.length});for(let e of n.pageFields){let n={fld:e.fld};e.item!==void 0&&(n.item=e.item),e.hier!==void 0&&(n.hier=e.hier),e.name!==void 0&&(n.name=e.name),t.leafNode(`pageField`,n)}t.closeNode()}if(n.dataFields.length>0){t.openNode(`dataFields`,{count:n.dataFields.length});for(let e of n.dataFields){let n={name:e.name,fld:e.fld};e.baseField!==void 0&&(n.baseField=e.baseField),e.baseItem!==void 0&&(n.baseItem=e.baseItem),e.subtotal!==void 0&&e.subtotal!==`sum`&&(n.subtotal=e.subtotal),e.numFmtId!==void 0&&(n.numFmtId=e.numFmtId),t.leafNode(`dataField`,n)}t.closeNode()}n.formatsXml&&t.writeXml(n.formatsXml),n.conditionalFormatsXml&&t.writeXml(n.conditionalFormatsXml),n.chartFormats&&n.chartFormats.length>0&&this.renderChartFormats(t,n.chartFormats);let i=n.styleInfo;t.leafNode(`pivotTableStyleInfo`,{name:i?.name??n.styleName??Vs,showRowHeaders:i?.showRowHeaders??`1`,showColHeaders:i?.showColHeaders??`1`,showRowStripes:i?.showRowStripes??`0`,showColStripes:i?.showColStripes??`0`,showLastColumn:i?.showLastColumn??`1`}),n.filtersXml&&t.writeXml(n.filtersXml),n.unknownElementsXml&&t.writeXml(n.unknownElementsXml);let a=n.extLstXml??(n.isLoaded?``:e.EXTLST_XML);a&&t.writeXml(a),t.closeNode()}buildLoadedRootAttributes(t){let n={...e.PIVOT_TABLE_ATTRIBUTES,name:t.name??`PivotTable1`,cacheId:String(t.cacheId),applyNumberFormats:t.applyNumberFormats??`0`,applyBorderFormats:t.applyBorderFormats??`0`,applyFontFormats:t.applyFontFormats??`0`,applyPatternFormats:t.applyPatternFormats??`0`,applyAlignmentFormats:t.applyAlignmentFormats??`0`,applyWidthHeightFormats:t.applyWidthHeightFormats??`0`,dataCaption:t.dataCaption??`Values`,updatedVersion:t.updatedVersion??`8`,minRefreshableVersion:t.minRefreshableVersion??`3`};return t.useAutoFormatting!==void 0&&(n.useAutoFormatting=t.useAutoFormatting),t.itemPrintTitles!==void 0&&(n.itemPrintTitles=t.itemPrintTitles),t.multipleFieldFilters!==void 0&&(n.multipleFieldFilters=t.multipleFieldFilters),n.createdVersion=t.createdVersion??`8`,t.indent!==void 0&&(n.indent=String(t.indent)),t.uid&&(n[`xmlns:xr`]=`http://schemas.microsoft.com/office/spreadsheetml/2014/revision`,n[`xr:uid`]=t.uid),t.outline&&(n.outline=`1`),t.outlineData&&(n.outlineData=`1`),t.chartFormat!==void 0&&(n.chartFormat=String(t.chartFormat)),t.colGrandTotals!==void 0&&(n.colGrandTotals=t.colGrandTotals),t.rowGrandTotals!==void 0&&(n.rowGrandTotals=t.rowGrandTotals),t.showError!==void 0&&(n.showError=t.showError),t.errorCaption!==void 0&&(n.errorCaption=t.errorCaption),t.showMissing!==void 0&&(n.showMissing=t.showMissing),t.missingCaption!==void 0&&(n.missingCaption=t.missingCaption),t.grandTotalCaption!==void 0&&(n.grandTotalCaption=t.grandTotalCaption),t.compact===!1&&(n.compact=`0`),t.compactData===!1&&(n.compactData=`0`),n}renderChartFormats(e,t){e.openNode(`chartFormats`,{count:t.length});for(let n of t)e.openNode(`chartFormat`,{chart:n.chart,format:n.format,series:n.series===!0?`1`:n.series===!1?`0`:void 0}),n.pivotAreaXml?e.writeXml(n.pivotAreaXml):e.writeXml(`<pivotArea type="data" outline="0" fieldPosition="0"><references count="1"><reference field="4294967294" count="1" selected="0"><x v="0"/></reference></references></pivotArea>`),e.closeNode();e.closeNode()}renderRowColItem(e,t){let n={};if(t.t!==void 0&&(n.t=t.t),t.r!==void 0&&(n.r=t.r),t.i!==void 0&&(n.i=t.i),t.x.length>0){e.openNode(`i`,n);for(let n of t.x)n.v===0?e.leafNode(`x`):e.leafNode(`x`,{v:n.v});e.closeNode()}else e.leafNode(`i`,n)}renderPivotFieldLoaded(e,t){let n={};if(t.axis&&(n.axis=t.axis),t.dataField&&(n.dataField=`1`),t.numFmtId!==void 0&&(n.numFmtId=String(t.numFmtId)),t.sortType&&(n.sortType=t.sortType),t.compact===!1&&(n.compact=`0`),t.outline===!1&&(n.outline=`0`),n.showAll=t.showAll?`1`:`0`,t.defaultSubtotal===!1&&(n.defaultSubtotal=`0`),t.subtotalTop===!1&&(n.subtotalTop=`0`),t.insertBlankRow===!0&&(n.insertBlankRow=`1`),t.multipleItemSelectionAllowed===!0&&(n.multipleItemSelectionAllowed=`1`),t.extraAttrs)for(let[e,r]of Object.entries(t.extraAttrs))n[e]=r;if(t.items!==void 0&&t.items.length>0||t.autoSortScopeXml!==void 0){if(e.openNode(`pivotField`,n),t.items!==void 0&&t.items.length>0){e.openNode(`items`,{count:t.items.length});for(let n of t.items){let t={};for(let e of Us)n[e]!==void 0&&(t[e]=n[e]);e.leafNode(`item`,t)}e.closeNode()}t.autoSortScopeXml&&e.writeXml(t.autoSortScopeXml),e.closeNode()}else e.leafNode(`pivotField`,n)}parseOpen(e){let{name:t,attributes:n}=e;if(this.extLstCollector.active)return this.extLstCollector.feedOpen(t,n),!0;if(this.formatsCollector.active)return this.formatsCollector.feedOpen(t,n),!0;if(this.conditionalFormatsCollector.active)return this.conditionalFormatsCollector.feedOpen(t,n),!0;if(this.filtersCollector.active)return this.filtersCollector.feedOpen(t,n),!0;if(this.unknownCollector.active)return this.unknownCollector.feedOpen(t,n),!0;switch(t){case this.tag:this.reset(),this.model={name:n.name,cacheId:parseInt(n.cacheId??`0`,10),uid:n[`xr:uid`],pivotFields:[],rowFields:[],colFields:[],pageFields:[],dataFields:[],applyNumberFormats:n.applyNumberFormats,applyBorderFormats:n.applyBorderFormats,applyFontFormats:n.applyFontFormats,applyPatternFormats:n.applyPatternFormats,applyAlignmentFormats:n.applyAlignmentFormats,applyWidthHeightFormats:n.applyWidthHeightFormats,dataCaption:n.dataCaption,updatedVersion:n.updatedVersion,minRefreshableVersion:n.minRefreshableVersion,createdVersion:n.createdVersion,useAutoFormatting:n.useAutoFormatting,itemPrintTitles:n.itemPrintTitles,indent:n.indent===void 0?void 0:parseInt(n.indent,10),compact:n.compact!==`0`,compactData:n.compactData!==`0`,multipleFieldFilters:n.multipleFieldFilters,outline:n.outline===`1`,outlineData:n.outlineData===`1`,chartFormat:n.chartFormat===void 0?void 0:parseInt(n.chartFormat,10),colGrandTotals:n.colGrandTotals,rowGrandTotals:n.rowGrandTotals,showError:n.showError,errorCaption:n.errorCaption,showMissing:n.showMissing,missingCaption:n.missingCaption,grandTotalCaption:n.grandTotalCaption,rowItems:[],colItems:[],chartFormats:[],isLoaded:!0};break;case`location`:this.model&&(this.model.location={ref:n.ref,firstHeaderRow:n.firstHeaderRow===void 0?void 0:parseInt(n.firstHeaderRow,10),firstDataRow:n.firstDataRow===void 0?void 0:parseInt(n.firstDataRow,10),firstDataCol:n.firstDataCol===void 0?void 0:parseInt(n.firstDataCol,10),rowPageCount:n.rowPageCount===void 0?void 0:parseInt(n.rowPageCount,10),colPageCount:n.colPageCount===void 0?void 0:parseInt(n.colPageCount,10)});break;case`pivotFields`:this.state.currentSection=`pivotFields`;break;case`pivotField`:if(this.state.currentSection===`pivotFields`){let e={};for(let[t,r]of Object.entries(n))Gs.has(t)||(e[t]=String(r));this.currentPivotField={axis:Hs.has(n.axis)?n.axis:void 0,dataField:n.dataField===`1`,items:[],compact:n.compact!==`0`,outline:n.outline!==`0`,showAll:n.showAll!==`0`,defaultSubtotal:n.defaultSubtotal!==`0`,numFmtId:n.numFmtId===void 0?void 0:parseInt(n.numFmtId,10),sortType:n.sortType,subtotalTop:n.subtotalTop===void 0?void 0:n.subtotalTop===`1`,insertBlankRow:n.insertBlankRow===`1`?!0:void 0,multipleItemSelectionAllowed:n.multipleItemSelectionAllowed===`1`?!0:void 0,extraAttrs:Object.keys(e).length>0?e:void 0}}break;case`items`:break;case`item`:if(this.currentPivotField){let e={};n.x!==void 0&&(e.x=parseInt(n.x,10));for(let t of Us)t!==`x`&&n[t]!==void 0&&(e[t]=n[t]);this.currentPivotField.items.push(e)}break;case`autoSortScope`:this.currentPivotField&&(this.state.inAutoSortScope=!0,this.autoSortScopeXmlBuffer=[`<autoSortScope>`]);break;case`rowFields`:this.state.currentSection=`rowFields`;break;case`colFields`:this.state.currentSection=`colFields`,this.model&&(this.model.hasColFields=!0);break;case`dataFields`:this.state.currentSection=`dataFields`;break;case`pageFields`:this.state.currentSection=`pageFields`;break;case`pageField`:this.state.currentSection===`pageFields`&&this.model&&this.model.pageFields.push({fld:parseInt(n.fld??`0`,10),item:n.item===void 0?void 0:parseInt(n.item,10),hier:n.hier===void 0?void 0:parseInt(n.hier,10),name:n.name});break;case`rowItems`:this.state.currentSection=`rowItems`,this.model&&(this.model.hasRowItems=!0);break;case`colItems`:this.state.currentSection=`colItems`,this.model&&(this.model.hasColItems=!0);break;case`i`:if(this.model){let e=this.state.currentSection===`rowItems`||this.state.currentSection===`colItems`?qs(n):null;this.state.currentSection===`rowItems`?this.currentRowItem=e:this.state.currentSection===`colItems`&&(this.currentColItem=e)}break;case`x`:if(this.state.inPivotArea){let e=Fs(n);this.state.inAutoSortScope?this.autoSortScopeXmlBuffer.push(e?`<x ${e}/>`:`<x/>`):this.pivotAreaXmlBuffer.push(e?`<x ${e}/>`:`<x/>`)}else this.currentRowItem?this.currentRowItem.x.push({v:parseInt(n.v??`0`,10)}):this.currentColItem&&this.currentColItem.x.push({v:parseInt(n.v??`0`,10)});break;case`chartFormats`:this.state.currentSection=`chartFormats`;break;case`chartFormat`:this.state.currentSection===`chartFormats`&&this.model&&(this.currentChartFormat={chart:parseInt(n.chart??`0`,10),format:parseInt(n.format??`0`,10),series:n.series===void 0?void 0:n.series===`1`});break;case`pivotArea`:if(this.currentChartFormat){this.state.inPivotArea=!0;let e=Fs(n);this.pivotAreaXmlBuffer=[e?`<pivotArea ${e}>`:`<pivotArea>`]}else if(this.state.inAutoSortScope){this.state.inPivotArea=!0;let e=Fs(n);this.autoSortScopeXmlBuffer.push(e?`<pivotArea ${e}>`:`<pivotArea>`)}break;case`references`:case`reference`:if(this.state.inPivotArea){let e=Fs(n);this.state.inAutoSortScope?this.autoSortScopeXmlBuffer.push(`<${t}${e?` `+e:``}>`):this.pivotAreaXmlBuffer.push(`<${t}${e?` `+e:``}>`)}break;case`field`:if(this.model){let e=parseInt(n.x??`0`,10);this.state.currentSection===`rowFields`?this.model.rowFields.push(e):this.state.currentSection===`colFields`&&this.model.colFields.push(e)}break;case`dataField`:this.state.currentSection===`dataFields`&&this.model&&this.model.dataFields.push({name:n.name??``,fld:parseInt(n.fld??`0`,10),baseField:n.baseField===void 0?void 0:parseInt(n.baseField,10),baseItem:n.baseItem===void 0?void 0:parseInt(n.baseItem,10),subtotal:un.has(n.subtotal)?n.subtotal:void 0,numFmtId:n.numFmtId===void 0?void 0:parseInt(n.numFmtId,10)});break;case`pivotTableStyleInfo`:this.model&&(this.model.styleName=n.name,this.model.styleInfo={name:n.name,showRowHeaders:n.showRowHeaders,showColHeaders:n.showColHeaders,showRowStripes:n.showRowStripes,showColStripes:n.showColStripes,showLastColumn:n.showLastColumn});break;case`extLst`:this.model&&this.extLstCollector.start(n);break;case`formats`:this.model&&this.formatsCollector.start(n);break;case`conditionalFormats`:this.model&&this.conditionalFormatsCollector.start(n);break;case`filters`:this.model&&this.filtersCollector.start(n);break;default:this.model&&this.state.currentSection===null&&!this.state.inPivotArea&&!this.state.inAutoSortScope&&this.unknownCollector.startAs(t,n);break}return!0}parseText(e){this.extLstCollector.active?this.extLstCollector.feedText(e):this.formatsCollector.active?this.formatsCollector.feedText(e):this.conditionalFormatsCollector.active?this.conditionalFormatsCollector.feedText(e):this.filtersCollector.active?this.filtersCollector.feedText(e):this.unknownCollector.active&&this.unknownCollector.feedText(e)}tryCloseCollector(e,t,n){e.feedClose(t)&&(this.model&&(this.model[n]=e.result),e.reset())}parseClose(e){if(this.extLstCollector.active)return this.tryCloseCollector(this.extLstCollector,e,`extLstXml`),!0;if(this.formatsCollector.active)return this.tryCloseCollector(this.formatsCollector,e,`formatsXml`),!0;if(this.conditionalFormatsCollector.active)return this.tryCloseCollector(this.conditionalFormatsCollector,e,`conditionalFormatsXml`),!0;if(this.filtersCollector.active)return this.tryCloseCollector(this.filtersCollector,e,`filtersXml`),!0;if(this.unknownCollector.active)return this.unknownCollector.feedClose(e)&&(this.unknownElementsXmlParts.push(this.unknownCollector.result),this.unknownCollector.reset()),!0;if(this.state.inPivotArea)return e===`pivotArea`?(this.state.inAutoSortScope?this.autoSortScopeXmlBuffer.push(`</pivotArea>`):(this.pivotAreaXmlBuffer.push(`</pivotArea>`),this.currentChartFormat&&(this.currentChartFormat.pivotAreaXml=this.pivotAreaXmlBuffer.join(``)),this.pivotAreaXmlBuffer=[]),this.state.inPivotArea=!1,!0):((e===`references`||e===`reference`)&&(this.state.inAutoSortScope?this.autoSortScopeXmlBuffer.push(`</${e}>`):this.pivotAreaXmlBuffer.push(`</${e}>`)),!0);switch(e){case this.tag:return this.model&&this.unknownElementsXmlParts.length>0&&(this.model.unknownElementsXml=this.unknownElementsXmlParts.join(``)),!1;case`pivotFields`:case`rowFields`:case`colFields`:case`dataFields`:case`pageFields`:case`rowItems`:case`colItems`:case`chartFormats`:this.state.currentSection=null;break;case`pivotField`:this.currentPivotField&&this.model&&(this.model.pivotFields.push(this.currentPivotField),this.currentPivotField=null);break;case`items`:break;case`autoSortScope`:this.state.inAutoSortScope&&this.currentPivotField&&(this.autoSortScopeXmlBuffer.push(`</autoSortScope>`),this.currentPivotField.autoSortScopeXml=this.autoSortScopeXmlBuffer.join(``),this.autoSortScopeXmlBuffer=[],this.state.inAutoSortScope=!1);break;case`i`:this.currentRowItem&&this.model?(this.model.rowItems?.push(this.currentRowItem),this.currentRowItem=null):this.currentColItem&&this.model&&(this.model.colItems?.push(this.currentColItem),this.currentColItem=null);break;case`chartFormat`:this.currentChartFormat&&this.model&&(this.model.chartFormats?.push(this.currentChartFormat),this.currentChartFormat=null);break}return!0}static{this.PIVOT_TABLE_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`}}static{this.EXTLST_XML=`<extLst><ext uri="{962EF5D1-5CA2-4c93-8EF4-DBF5C05439D2}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"><x14:pivotTableDefinition hideValuesRow="1" xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main"/></ext><ext uri="{747A6164-185A-40DC-8AA5-F01512510D54}" xmlns:xpdl="http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout"><xpdl:pivotTableDefinition16 EnabledSubtotalsDefault="0" SubtotalsOnTopDefault="0"/></ext></extLst>`}};function qs(e){return{t:e.t,r:e.r===void 0?void 0:parseInt(e.r,10),i:e.i===void 0?void 0:parseInt(e.i,10),x:[]}}function Js(e,t,n,r){e.openNode(`dataFields`,{count:n.length});for(let i=0;i<n.length;i++){let a=n[i],o=r[i]??`sum`,s=ln[o],c=t[a];if(!c)throw Error(`Value field index ${a} is out of bounds (cacheFields has ${t.length} entries)`);let l={name:`${s} of ${c.name}`,fld:a,baseField:0,baseItem:0};o!==`sum`&&(l.subtotal=o),e.leafNode(`dataField`,l)}e.closeNode()}function Ys(e,t){let n=new Set(t.rows),r=new Set(t.columns),i=new Set(t.values),a=new Set(t.pages??[]);e.openNode(`pivotFields`,{count:t.cacheFields.length});for(let o=0;o<t.cacheFields.length;o++){let s=t.cacheFields[o];Xs(e,n.has(o),r.has(o),i.has(o),a.has(o),s.sharedItems)}e.closeNode()}function Xs(e,t,n,r,i,a){if(t||n||i){if(!a)throw Error(`sharedItems is required for axis field (row/column/page)`);let i={axis:t?`axisRow`:n?`axisCol`:`axisPage`};r&&(i.dataField=`1`),i.compact=`0`,i.outline=`0`,i.showAll=`0`,e.openNode(`pivotField`,i),e.openNode(`items`,{count:a.length+1});for(let t=0;t<a.length;t++)e.leafNode(`item`,{x:t});e.leafNode(`item`,{t:`default`}),e.closeNode(),e.closeNode();return}let o={};r&&(o.dataField=`1`),o.compact=`0`,o.outline=`0`,o.showAll=`0`,o.defaultSubtotal=`0`,e.leafNode(`pivotField`,o)}var Zs=class extends j{constructor(e){super(),this.model=e||{type:`note`,note:{texts:[]},ref:``}}get tag(){return`r`}get richTextXform(){return this._richTextXform||=new ti,this._richTextXform}render(e,t){let n=t||this.model;e.openNode(`comment`,{ref:n.ref,authorId:0}),e.openNode(`text`),n&&n.note&&n.note.texts&&n.note.texts.forEach(t=>{this.richTextXform.render(e,t)}),e.closeNode(),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`comment`:return this.model={type:`note`,note:{texts:[]},...e.attributes},!0;case`r`:return this.parser=this.richTextXform,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){switch(e){case`comment`:return!1;case`r`:return this.model.note.texts.push(this.parser.model),this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(e),!0}}},Qs=class e extends j{constructor(){super(),this.map={comment:new Zs},this.model={comments:[]}}render(t,n){let r=n||this.model;t.openXml(k.StdDocAttributes),t.openNode(`comments`,e.COMMENTS_ATTRIBUTES),t.openNode(`authors`),t.leafNode(`author`,null,`Author`),t.closeNode(),t.openNode(`commentList`),r.comments.forEach(e=>{this.map.comment.render(t,e)}),t.closeNode(),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case`commentList`:return this.model={comments:[]},!0;case`comment`:return this.parser=this.map.comment,this.parser.parseOpen(e),!0;default:return!1}}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){switch(e){case`commentList`:return!1;case`comment`:return this.model.comments.push(this.parser.model),this.parser=void 0,!0;default:return this.parser&&this.parser.parseClose(e),!0}}static{this.COMMENTS_ATTRIBUTES={xmlns:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`}}},$s=class extends j{constructor(){super(),this.model={}}get tag(){return`v:textbox`}conversionUnit(e,t,n){return`${(parseFloat(e.toString())*t).toFixed(2)}${n}`}reverseConversionUnit(e){return(e??``).split(`,`).map(e=>Number(parseFloat(this.conversionUnit(parseFloat(e),.1,``)).toFixed(2)))}render(e,t){let n={style:`mso-direction-alt:auto`};if(t&&t.note){let{inset:e}=t.note&&t.note.margins||{};Array.isArray(e)&&(e=e.map(e=>this.conversionUnit(e,10,`mm`)).join(`,`)),e&&(n.inset=e)}e.openNode(`v:textbox`,n),e.leafNode(`div`,{style:`text-align:left`}),e.closeNode()}parseOpen(e){switch(e.name){case this.tag:return this.model={inset:this.reverseConversionUnit(e.attributes.inset)},!0;default:return!0}}parseText(){}parseClose(e){switch(e){case this.tag:return!1;default:return!0}}},ec=class extends j{constructor(){super(),this.text=``}get tag(){return`x:Anchor`}getAnchorRect(e){let t=Math.floor(e.left),n=Math.floor((e.left-t)*68),r=Math.floor(e.top),i=Math.floor((e.top-r)*18),a=Math.floor(e.right),o=Math.floor((e.right-a)*68),s=Math.floor(e.bottom);return[t,n,r,i,a,o,s,Math.floor((e.bottom-s)*18)]}getDefaultRect(e){let t=e.col,n=Math.max(e.row-2,0);return[t,6,n,14,t+2,2,n+4,16]}render(e,t){let n=t.anchor?this.getAnchorRect(t.anchor):this.getDefaultRect(t.refAddress);e.leafNode(`x:Anchor`,null,n.join(`, `))}parseOpen(e){switch(e.name){case this.tag:return this.text=``,!0;default:return!1}}parseText(e){this.text=e}parseClose(){return!1}},tc=class extends j{constructor(e){super(),this._model=e||{},this.text=``}get tag(){return this._model?.tag??``}render(e,t){e.leafNode(this.tag,null,t)}parseOpen(e){switch(e.name){case this.tag:return this.text=``,!0;default:return!1}}parseText(e){this.text=e}parseClose(){return!1}},nc=class extends j{constructor(e){super(),this._model=e||{},this.model={}}get tag(){return this._model?.tag??``}render(e,t,n){(n&&t===n[2]||n&&this.tag===`x:SizeWithCells`&&t===n[1])&&e.leafNode(this.tag)}parseOpen(e){switch(e.name){case this.tag:return this.model={},this.model[this.tag]=!0,!0;default:return!1}}parseText(){}parseClose(){return!1}};let rc=[`twoCells`,`oneCells`,`absolute`];var ic=class extends j{constructor(){super(),this.map={"x:Anchor":new ec,"x:Locked":new tc({tag:`x:Locked`}),"x:LockText":new tc({tag:`x:LockText`}),"x:SizeWithCells":new nc({tag:`x:SizeWithCells`}),"x:MoveWithCells":new nc({tag:`x:MoveWithCells`})},this.model={anchor:[],protection:{},editAs:``}}get tag(){return`x:ClientData`}render(e,t){let{protection:n,editAs:r}=t.note;e.openNode(this.tag,{ObjectType:`Note`}),this.map[`x:MoveWithCells`].render(e,r,rc),this.map[`x:SizeWithCells`].render(e,r,rc),this.map[`x:Anchor`].render(e,t),this.map[`x:Locked`].render(e,n.locked),e.leafNode(`x:AutoFill`,null,`False`),this.map[`x:LockText`].render(e,n.lockText),e.leafNode(`x:Row`,null,t.refAddress.row-1),e.leafNode(`x:Column`,null,t.refAddress.col-1),e.closeNode()}parseOpen(e){switch(e.name){case this.tag:this.reset(),this.model={anchor:[],protection:{},editAs:``};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.normalizeModel(),!1;default:return!0}}normalizeModel(){let e=Object.assign({},this.map[`x:MoveWithCells`].model,this.map[`x:SizeWithCells`].model),t=Object.keys(e).length;this.model.editAs=rc[t],this.model.anchor=this.map[`x:Anchor`].text,this.model.protection.locked=this.map[`x:Locked`].text,this.model.protection.lockText=this.map[`x:LockText`].text}},ac=class e extends j{constructor(){super(),this.map={"v:textbox":new $s,"x:ClientData":new ic}}get tag(){return`v:shape`}render(t,n,r){t.openNode(`v:shape`,e.V_SHAPE_ATTRIBUTES(n,r??0)),t.leafNode(`v:fill`,{color2:`infoBackground [80]`}),t.leafNode(`v:shadow`,{color:`none [81]`,obscured:`t`}),t.leafNode(`v:path`,{"o:connecttype":`none`}),this.map[`v:textbox`].render(t,n),this.map[`x:ClientData`].render(t,n),t.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset(),this.model={margins:{insetmode:e.attributes[`o:insetmode`]},anchor:``,editAs:``,protection:{}};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.parser=void 0),!0;switch(e){case this.tag:return this.model.margins.inset=this.map[`v:textbox`].model&&this.map[`v:textbox`].model.inset,this.model.protection=this.map[`x:ClientData`].model&&this.map[`x:ClientData`].model.protection,this.model.anchor=this.map[`x:ClientData`].model&&this.map[`x:ClientData`].model.anchor,this.model.editAs=this.map[`x:ClientData`].model&&this.map[`x:ClientData`].model.editAs,!1;default:return!0}}static{this.V_SHAPE_ATTRIBUTES=(e,t)=>({id:`_x0000_s${1025+t}`,type:`#_x0000_t202`,style:`position:absolute; margin-left:105.3pt;margin-top:10.5pt;width:97.8pt;height:59.1pt;z-index:1;visibility:hidden`,fillcolor:`infoBackground [80]`,strokecolor:`none [81]`,"o:insetmode":e.note.margins&&e.note.margins.insetmode})}},oc=class e extends j{constructor(){super(),this.map={"v:shape":new ac},this.model={comments:[],formControls:[]}}get tag(){return`xml`}render(t,n){let r=n||this.model,i=r.comments,a=r.formControls,o=i&&i.length>0,s=a&&a.length>0;if(t.openXml(k.StdDocAttributes),t.openNode(this.tag,e.DRAWING_ATTRIBUTES),t.openNode(`o:shapelayout`,{"v:ext":`edit`}),t.leafNode(`o:idmap`,{"v:ext":`edit`,data:1}),t.closeNode(),o&&(t.openNode(`v:shapetype`,{id:`_x0000_t202`,coordsize:`21600,21600`,"o:spt":202,path:`m,l,21600r21600,l21600,xe`}),t.leafNode(`v:stroke`,{joinstyle:`miter`}),t.leafNode(`v:path`,{gradientshapeok:`t`,"o:connecttype":`rect`}),t.closeNode()),s&&(t.openNode(`v:shapetype`,{id:`_x0000_t201`,coordsize:`21600,21600`,"o:spt":`201`,path:`m,l,21600r21600,l21600,xe`}),t.leafNode(`v:stroke`,{joinstyle:`miter`}),t.leafNode(`v:path`,{shadowok:`f`,"o:extrusionok":`f`,strokeok:`f`,fillok:`f`,"o:connecttype":`rect`}),t.leafNode(`o:lock`,{"v:ext":`edit`,shapetype:`t`}),t.closeNode()),o)for(let e=0;e<i.length;e++)this.map[`v:shape`].render(t,i[e],e);if(s)for(let e of a)this._renderCheckboxShape(t,e);t.closeNode()}_renderCheckboxShape(e,t){let n={id:`_x0000_s${t.shapeId}`,type:`#_x0000_t201`,style:st.getVmlStyle(t),"o:insetmode":`auto`,fillcolor:`buttonFace [67]`,strokecolor:`windowText [64]`,"o:preferrelative":`t`,filled:`f`,stroked:`f`};e.openNode(`v:shape`,n),e.leafNode(`v:fill`,{"o:detectmouseclick":`t`}),e.leafNode(`o:lock`,{"v:ext":`edit`,text:`t`}),t.text&&(e.openNode(`v:textbox`,{style:`mso-direction-alt:auto`,"o:singleclick":`t`}),e.openNode(`div`,{style:`text-align:left`}),e.openNode(`font`,{face:`Tahoma`,size:`160`,color:`auto`}),e.writeText(t.text),e.closeNode(),e.closeNode(),e.closeNode()),e.openNode(`x:ClientData`,{ObjectType:`Checkbox`}),e.leafNode(`x:MoveWithCells`),e.leafNode(`x:SizeWithCells`),e.openNode(`x:Anchor`),e.writeText(st.getVmlAnchor(t)),e.closeNode(),e.leafNode(`x:Locked`,void 0,`False`),e.leafNode(`x:LockText`,void 0,`True`),e.leafNode(`x:PrintObject`,void 0,t.print?`True`:`False`),e.leafNode(`x:AutoFill`,void 0,`False`),e.leafNode(`x:AutoLine`,void 0,`False`),e.leafNode(`x:TextHAlign`,void 0,`Left`),e.leafNode(`x:TextVAlign`,void 0,`Center`),t.link&&e.leafNode(`x:FmlaLink`,void 0,t.link),t.noThreeD&&e.leafNode(`x:NoThreeD`),e.leafNode(`x:Checked`,void 0,String(st.getVmlCheckedValue(t))),e.leafNode(`x:Row`,void 0,String(t.tl.row)),e.leafNode(`x:Column`,void 0,String(t.tl.col)),e.closeNode(),e.closeNode()}parseOpen(e){if(this.parser)return this.parser.parseOpen(e),!0;switch(e.name){case this.tag:this.reset(),this.model={comments:[],formControls:[]};break;default:this.parser=this.map[e.name],this.parser&&this.parser.parseOpen(e);break}return!0}parseText(e){this.parser&&this.parser.parseText(e)}parseClose(e){if(this.parser)return this.parser.parseClose(e)||(this.model.comments.push(this.parser.model),this.parser=void 0),!0;switch(e){case this.tag:return!1;default:return!0}}static{this.DRAWING_ATTRIBUTES={"xmlns:v":`urn:schemas-microsoft-com:vml`,"xmlns:o":`urn:schemas-microsoft-com:office:office`,"xmlns:x":`urn:schemas-microsoft-com:office:excel`}}},sc=class extends j{_checkedToXmlValue(e){switch(e){case`Checked`:return`1`;case`Mixed`:return`2`;default:return`0`}}get tag(){return`formControlPr`}render(e,t){let n=t||this.model,r={xmlns:`http://schemas.microsoft.com/office/spreadsheetml/2009/9/main`,objectType:`CheckBox`,checked:this._checkedToXmlValue(n.checked),lockText:`1`};n.link&&(r.fmlaLink=n.link),n.noThreeD&&(r.noThreeD=`1`),e.openXml({version:`1.0`,encoding:`UTF-8`,standalone:`yes`}),e.leafNode(this.tag,r)}toXml(e){let t=new k;return this.render(t,e),t.xml}parseOpen(){return!0}parseText(){}parseClose(){return!1}};let cc=e=>Array.isArray(e);var W=class e{constructor(){this.__excelts_stream=!0,this._listeners=new Map,this._maxListeners=e.defaultMaxListeners}static{this.defaultMaxListeners=10}addListener(e,t){return this.on(e,t)}_listenerCount(e){return e?cc(e)?e.length:1:0}_hasListeners(e){return this._listenerCount(this._listeners.get(e))>0}on(e,t){e!==`newListener`&&this._hasListeners(`newListener`)&&this.emit(`newListener`,e,t);let n=this._listeners.get(e);if(this._maxListeners>0){let t=this._listenerCount(n);t>=this._maxListeners&&console?.warn?.(`MaxListenersExceededWarning: Possible EventEmitter memory leak detected. ${t+1} ${String(e)} listeners added. Use emitter.setMaxListeners() to increase limit`)}return n?cc(n)?n.push(t):this._listeners.set(e,[n,t]):this._listeners.set(e,t),this}prependListener(e,t){e!==`newListener`&&this._hasListeners(`newListener`)&&this.emit(`newListener`,e,t);let n=this._listeners.get(e);return n?cc(n)?n.unshift(t):this._listeners.set(e,[t,n]):this._listeners.set(e,t),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return n.listener=t,this.on(e,n)}prependOnceListener(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return n.listener=t,this.prependListener(e,n)}removeListener(e,t){return this.off(e,t)}off(e,t){let n=this._listeners.get(e);if(!n)return this;if(!cc(n))return(n===t||n.listener===t)&&(this._listeners.delete(e),e!==`removeListener`&&this._hasListeners(`removeListener`)&&this.emit(`removeListener`,e,t)),this;let r=n;if(r.length===0)return this._listeners.delete(e),this;let i=r.lastIndexOf(t);if(i!==-1)r.splice(i,1);else for(let e=r.length-1;e>=0;e--)if(r[e].listener===t){r.splice(e,1);break}return r.length===0?this._listeners.delete(e):r.length===1&&this._listeners.set(e,r[0]),e!==`removeListener`&&this._hasListeners(`removeListener`)&&this.emit(`removeListener`,e,t),this}emit(e,...t){let n=this._listeners.get(e);if(!n){if(e===`error`){let e=t[0];if(e instanceof Error)throw e;let n=`Unhandled error.${e===void 0?` (undefined)`:` (${e})`}`;throw Error(n)}return!1}if(!cc(n))return n.apply(this,t),!0;let r=n,i=r.length;if(i===0){if(e===`error`){let e=t[0];if(e instanceof Error)throw e;let n=`Unhandled error.${e===void 0?` (undefined)`:` (${e})`}`;throw Error(n)}return!1}if(i===1)return r[0].apply(this,t),!0;let a=r.slice();for(let e=0;e<a.length;e++)a[e].apply(this,t);return!0}removeAllListeners(e){if(e!==void 0){if(e!==`removeListener`&&this._hasListeners(`removeListener`)){let t=this._listeners.get(e);if(t){let n=cc(t)?t.slice():[t];this._listeners.delete(e);for(let t of n){let n=t.listener??t;this.emit(`removeListener`,e,n)}return this}}this._listeners.delete(e)}else{if(this._hasListeners(`removeListener`)){let e=[...this._listeners.keys()];for(let t of e)if(t!==`removeListener`){let e=this._listeners.get(t);if(e){let n=cc(e)?e.slice():[e];this._listeners.delete(t);for(let e of n){let n=e.listener??e;this.emit(`removeListener`,t,n)}}}}this._listeners.clear()}return this}listenerCount(e){return this._listenerCount(this._listeners.get(e))}listeners(e){let t=this._listeners.get(e);return t?(cc(t)?t:[t]).map(e=>e.listener??e):[]}rawListeners(e){let t=this._listeners.get(e);return t?cc(t)?t.slice():[t]:[]}eventNames(){return[...this._listeners.keys()]}setMaxListeners(e){return this._maxListeners=e,this}getMaxListeners(){return this._maxListeners}};W.prototype.addListener=W.prototype.on,W.prototype.removeListener=W.prototype.off;let lc=new TextEncoder;var uc=class{constructor(e){this._buf=new Uint8Array(e&&e.size||16384),this._inPos=0,this._buffer=void 0}get length(){return this._inPos}get capacity(){return this._buf.length}get buffer(){return this._buf}toBuffer(){return this._buffer||=this._buf.slice(0,this._inPos),this._buffer}reset(e){e??=0,this._buffer=void 0,this._inPos=e}_grow(e){let t=this._buf.length*2;for(;t<e;)t*=2;let n=new Uint8Array(t);n.set(this._buf),this._buf=n}addText(e){this._buffer=void 0;let t=lc.encode(e),n=this._inPos+t.length;n>this._buf.length-4&&this._grow(n),this._buf.set(t,this._inPos),this._inPos+=t.length}addStringBuf(e){e.length&&(this._buffer=void 0,this.length+e.length>this.capacity&&this._grow(this.length+e.length),this._buf.set(e._buf.subarray(0,e.length),this._inPos),this._inPos+=e.length)}},dc=class{constructor(e){this._data=e}get length(){return this.toBuffer().length}copy(e,t,n,r){let i=this.toBuffer(),a=Math.min(r,i.length-n);return e.set(i.subarray(n,n+a),t),a}toBuffer(){return this._buffer||=new TextEncoder().encode(this._data),this._buffer}},fc=class{constructor(e){this._data=e}get length(){return this._data.length}copy(e,t,n,r){let i=this.toBuffer(),a=Math.min(r,i.length-n);return e.set(i.subarray(n,n+a),t),a}toBuffer(){return this._data.toBuffer()}},pc=class{constructor(e){this._data=e}get length(){return this._data.length}copy(e,t,n,r){let i=Math.min(r,this._data.length-n);return e.set(this._data.subarray(n,n+i),t),i}toBuffer(){return this._data}},mc=class{constructor(e){this.size=e,this.buffer=new Uint8Array(e),this.iRead=0,this.iWrite=0}toBuffer(){return this.iRead===0&&this.iWrite===this.size?this.buffer:this.buffer.subarray(this.iRead,this.iWrite)}get length(){return this.iWrite-this.iRead}get eod(){return this.iRead===this.iWrite}get full(){return this.iWrite===this.size}read(e){if(e===0)return null;if(e===void 0||e>=this.length){let e=this.toBuffer();return this.iRead=this.iWrite,e}let t=this.buffer.subarray(this.iRead,this.iRead+e);return this.iRead+=e,t}write(e,t,n){let r=Math.min(n,this.size-this.iWrite);return e.copy(this.buffer,this.iWrite,t,r),this.iWrite+=r,r}};let hc=()=>{};var gc=class extends W{constructor(e){super(),this._writableStreamWriter=null,this._asyncWriteQueue=Promise.resolve(),this.bufSize=e?.bufSize||1024*1024,this.buffers=[],this.batch=e?.batch??!1,this.corked=!1,this.paused=!1,this.encoding=null,this.pipes=[],this._ended=!1}get writable(){return!this._ended}toBuffer(){switch(this.buffers.length){case 0:return null;case 1:return this.buffers[0].toBuffer();default:{let e=this.buffers.reduce((e,t)=>e+t.length,0),t=new Uint8Array(e),n=0;for(let e of this.buffers){let r=e.toBuffer();t.set(r,n),n+=r.length}return t}}}_getWritableBuffer(){if(this.buffers.length){let e=this.buffers[this.buffers.length-1];if(!e.full)return e}let e=new mc(this.bufSize);return this.buffers.push(e),e}async _pipeChunk(e){let t=this.pipes.map(t=>new Promise(n=>{t.write(e.toBuffer(),()=>n())}));await Promise.all(t)}_writeToBuffers(e){let t=0,n=e.length;for(;t<n;){let r=this._getWritableBuffer();t+=r.write(e,t,n-t)}}async write(e,t,n){typeof t==`function`&&(n=t),n||=hc;let r;if(e instanceof uc||e&&e.constructor?.name===`StringBuf`)r=new fc(e);else if(e instanceof Uint8Array)r=new pc(e);else if(ArrayBuffer.isView(e))r=new pc(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));else if(e instanceof ArrayBuffer)r=new pc(new Uint8Array(e));else if(typeof e==`string`)r=new dc(e);else throw new g(typeof e,`Chunk must be one of type String, Uint8Array, ArrayBuffer or StringBuf.`);if(this.pipes.length)if(this.batch)for(this._writeToBuffers(r);!this.corked&&this.buffers.length>1;){let e=this.buffers.shift();await this._pipeChunk(new pc(e.toBuffer()))}else this.corked?(this._writeToBuffers(r),queueMicrotask(()=>n())):(await this._pipeChunk(r),n());else{let e=r.toBuffer(),t=!1;!this.paused&&this.listenerCount(`data`)>0&&(this.emit(`data`,e),t=!0),this._writableStreamWriter&&(this._asyncWriteQueue=this._asyncWriteQueue.then(()=>this._writableStreamWriter.write(e)),t=!0),t||(this._writeToBuffers(r),this.emit(`readable`))}return!0}cork(){this.corked=!0}_flush(){this.pipes.length&&(async()=>{for(;this.buffers.length;){let e=this.buffers.shift();await this._pipeChunk(new pc(e.toBuffer()))}})().catch(e=>this.emit(`error`,e))}uncork(){this.corked=!1,this._flush()}end(e,t,n){let r=e=>{if(e){n?.(e);return}this._ended=!0,this._flush(),this.pipes.forEach(e=>{typeof e.end==`function`&&e.end()}),this._writableStreamWriter?this._asyncWriteQueue.then(()=>this._writableStreamWriter.close()).then(()=>{this.emit(`finish`)}).catch(e=>{this.emit(`error`,e)}):this.emit(`finish`)};e?this.write(e,t,r):r()}read(e){if(e){let t=[],n=e;for(;n&&this.buffers.length&&!this.buffers[0].eod;){let e=this.buffers[0],r=e.read(n);r&&(n-=r.length,t.push(r)),e.eod&&e.full&&this.buffers.shift()}return an(_c(t))}let t=this.buffers.map(e=>e.toBuffer()).filter(Boolean);return this.buffers=[],an(_c(t))}readString(e){let t=e??this.encoding??`utf-8`,n=this.read();return Ht(t).decode(n)}setEncoding(e){this.encoding=e}pause(){this.paused=!0}resume(){this.paused=!1}isPaused(){return this.paused}pipe(e){return this.pipes.push(e),!this.paused&&this.buffers.length&&this.end(),e}pipeTo(e){this._writableStreamWriter=e.getWriter()}unpipe(e){this.pipes=this.pipes.filter(t=>t!==e)}unshift(){throw new v(`unshift`,`Not implemented`)}wrap(){throw new v(`wrap`,`Not implemented`)}push(e){return e!==null&&this.write(e),!0}};function _c(e){if(e.length===0)return new Uint8Array;if(e.length===1)return e[0];let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}let vc=null;function yc(){if(vc)return vc;let e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}return vc=e,e}function bc(e,t){let n=yc();for(let r=0;r<t.length;r++)e=n[(e^t[r])&255]^e>>>8;return e}function xc(e){return(e^4294967295)>>>0}function Sc(e){return xc(bc(4294967295,e))}function Cc(e,t){return(yc()[(e^t)&255]^e>>>8)>>>0}let wc=(()=>{let e=new Uint8Array(288);for(let t=0;t<=143;t++)e[t]=8;for(let t=144;t<=255;t++)e[t]=9;for(let t=256;t<=279;t++)e[t]=7;for(let t=280;t<=287;t++)e[t]=8;return e})(),Tc=new Uint8Array(32).fill(5),Ec=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],Dc=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Oc=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],kc=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Ac=[[1,0,0],[2,1,0],[3,2,0],[4,3,0],[6,4,1],[8,5,1],[12,6,2],[16,7,2],[24,8,3],[32,9,3],[48,10,4],[64,11,4],[96,12,5],[128,13,5],[192,14,6],[256,15,6],[384,16,7],[512,17,7],[768,18,8],[1024,19,8],[1536,20,9],[2048,21,9],[3072,22,10],[4096,23,10],[6144,24,11],[8192,25,11],[12288,26,12],[16384,27,12],[24576,28,13],[32768,29,13]],jc=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function Mc(e,t){let n=new Uint16Array(16);for(let r=0;r<t;r++)e[r]>0&&n[e[r]]++;let r=new Uint16Array(16),i=0;for(let e=1;e<=15;e++)i=i+n[e-1]<<1,r[e]=i;let a={};for(let n=0;n<t;n++){let t=e[n];if(t===0)continue;i=r[t]++;let o=a;for(let e=t-1;e>=0;e--)i>>e&1?(o.right||={},o=o.right):(o.left||={},o=o.left);o.symbol=n}return a}var Nc=class{constructor(e){this.data=e,this.pos=0,this.bitBuf=0,this.bitCount=0}readBits(e){for(;this.bitCount<e;){if(this.pos>=this.data.length)throw Error(`Unexpected end of DEFLATE data`);this.bitBuf|=this.data[this.pos++]<<this.bitCount,this.bitCount+=8}let t=this.bitBuf&(1<<e)-1;return this.bitBuf>>=e,this.bitCount-=e,t}decodeSymbol(e){let t=e;for(;t.symbol===void 0;)if(t=this.readBits(1)===0?t.left:t.right,!t)throw Error(`Invalid Huffman code`);return t.symbol}alignToByte(){this.bitBuf=0,this.bitCount=0}readByte(){if(this.pos>=this.data.length)throw Error(`Unexpected end of data`);return this.data[this.pos++]}readUint16(){return this.readByte()|this.readByte()<<8}};function Pc(e){let t=new Nc(e),n=[],r=!1;for(;!r;){r=t.readBits(1)===1;let e=t.readBits(2);if(e===0){t.alignToByte();let e=t.readUint16();if((e^t.readUint16())!==65535)throw Error(`Invalid stored block length`);for(let r=0;r<e;r++)n.push(t.readByte())}else if(e===1||e===2){let r,i;if(e===1)r=Mc(wc,288),i=Mc(Tc,32);else{let e=t.readBits(5)+257,n=t.readBits(5)+1,a=t.readBits(4)+4,o=new Uint8Array(19);for(let e=0;e<a;e++)o[jc[e]]=t.readBits(3);let s=Mc(o,19),c=new Uint8Array(e+n),l=0;for(;l<e+n;){let e=t.decodeSymbol(s);if(e<16)c[l++]=e;else if(e===16){let e=t.readBits(2)+3,n=c[l-1];for(let t=0;t<e;t++)c[l++]=n}else if(e===17){let e=t.readBits(3)+3;for(let t=0;t<e;t++)c[l++]=0}else if(e===18){let e=t.readBits(7)+11;for(let t=0;t<e;t++)c[l++]=0}}r=Mc(c.subarray(0,e),e),i=Mc(c.subarray(e),n)}for(;;){let e=t.decodeSymbol(r);if(e<256)n.push(e);else if(e===256)break;else{let r=e-257,a=Ec[r]+t.readBits(Dc[r]),o=t.decodeSymbol(i),s=Oc[o]+t.readBits(kc[o]),c=n.length-s;for(let e=0;e<a;e++)n.push(n[c+e])}}}else throw Error(`Invalid DEFLATE block type: `+e)}return new Uint8Array(n)}function Fc(e){let t=65535,n=Math.ceil(e.length/t)||1,r=n*5+e.length,i=new Uint8Array(r),a=0,o=0;for(let r=0;r<n;r++){let s=r===n-1,c=Math.min(t,e.length-o);i[a++]=s?1:0,i[a++]=c&255,i[a++]=c>>8&255,i[a++]=~c&255,i[a++]=~c>>8&255,i.set(e.subarray(o,o+c),a),a+=c,o+=c}return i.subarray(0,a)}function Ic(e){if(e.length===0)return new Uint8Array([3,0]);if(e.length<100)return Fc(e);let t=new Lc;t.writeBits(1,1),t.writeBits(1,2);let n=new Map,r=0;for(;r<e.length;){let i=0,a=0;if(r+2<e.length){let t=e[r]<<16|e[r+1]<<8|e[r+2],o=n.get(t);if(o!==void 0&&r-o<=32768){let t=r-o,n=0,s=Math.min(258,e.length-r);for(;n<s&&e[o+n]===e[r+n];)n++;n>=3&&(i=n,a=t)}n.set(t,r)}i>=3?(Bc(t,i),Vc(t,a),r+=i):(zc(t,e[r]),r++)}return zc(t,256),t.finish()}var Lc=class{constructor(){this.chunks=[],this.buffer=[],this.bitBuf=0,this.bitCount=0}writeBits(e,t){for(this.bitBuf|=e<<this.bitCount,this.bitCount+=t;this.bitCount>=8;)this.buffer.push(this.bitBuf&255),this.bitBuf>>=8,this.bitCount-=8,this.buffer.length>=65536&&(this.chunks.push(new Uint8Array(this.buffer)),this.buffer=[])}writeBitsReverse(e,t){let n=0;for(let r=0;r<t;r++)n=n<<1|e>>r&1;this.writeBits(n,t)}finish(){return this.bitCount>0&&this.buffer.push(this.bitBuf&255),this.chunks.length===0?new Uint8Array(this.buffer):(this.chunks.push(new Uint8Array(this.buffer)),O(this.chunks))}flushBytes(){if(this.chunks.length===0&&this.buffer.length===0)return new Uint8Array;let e;return this.chunks.length===0?e=new Uint8Array(this.buffer):(this.chunks.push(new Uint8Array(this.buffer)),e=O(this.chunks),this.chunks=[]),this.buffer=[],e}};let Rc=(()=>{let e=[];for(let t=0;t<=287;t++){let n,r;t<=143?(n=48+t,r=8):t<=255?(n=400+(t-144),r=9):t<=279?(n=t-256,r=7):(n=192+(t-280),r=8),e[t]=[n,r]}return e})();function zc(e,t){let[n,r]=Rc[t];e.writeBitsReverse(n,r)}function Bc(e,t){let n,r,i;if(t<=10)n=257+t-3,r=0,i=0;else if(t<=18){let e=t-11;n=265+Math.floor(e/2),r=1,i=e%2}else if(t<=34){let e=t-19;n=269+Math.floor(e/4),r=2,i=e%4}else if(t<=66){let e=t-35;n=273+Math.floor(e/8),r=3,i=e%8}else if(t<=130){let e=t-67;n=277+Math.floor(e/16),r=4,i=e%16}else if(t<=257){let e=t-131;n=281+Math.floor(e/32),r=5,i=e%32}else n=285,r=0,i=0;zc(e,n),r>0&&e.writeBits(i,r)}function Vc(e,t){let n=0,r=0,i=1;for(let e=0;e<Ac.length;e++){let[a,o,s]=Ac[e];if(t<=a){n=o,r=s;break}i=a+1}let a=t-i;e.writeBitsReverse(n,5),r>0&&e.writeBits(a,r)}let Hc=32768;var Uc=class{constructor(){this._output=new Lc,this._hashTable=new Map,this._window=new Uint8Array(Hc),this._windowLen=0,this._totalIn=0}write(e){if(e.length===0)return new Uint8Array;let t=this._output;t.writeBits(0,1),t.writeBits(1,2);let n=this._window,r=this._windowLen,i=this._hashTable,a=this._totalIn;for(let o=0;o<e.length;){let s=0,c=0;if(o+2<e.length){let t=e[o]<<16|e[o+1]<<8|e[o+2],l=i.get(t);if(l!==void 0){let t=a+o-l;if(t>0&&t<=Hc){let i=((r-t)%Hc+Hc)%Hc,a=Math.min(258,e.length-o),l=0;for(;l<a&&n[(i+l)%Hc]===e[o+l];)l++;l>=3&&(s=l,c=t)}}i.set(t,a+o)}if(s>=3){Bc(t,s),Vc(t,c);for(let t=0;t<s;t++)n[r%Hc]=e[o+t],r++;o+=s}else zc(t,e[o]),n[r%Hc]=e[o],r++,o++}return zc(t,256),this._windowLen=r,this._totalIn=a+e.length,t.flushBytes()}finish(){let e=this._output;return e.writeBits(1,1),e.writeBits(1,2),zc(e,256),e.finish()}};let G=new Uint8Array;function Wc(e,t,n=0){let r=e.length,i=t.length;if(i===0)return 0;if(i>r)return-1;let a=n|0;if(a<0&&(a=0),a>r-i)return-1;if(i===1)return e.indexOf(t[0],a);if(i===2){let n=t[0],i=t[1],o=r-2,s=e.indexOf(n,a);for(;s!==-1&&s<=o;){if(e[s+1]===i)return s;s=e.indexOf(n,s+1)}return-1}if(i===3){let n=t[0],i=t[1],o=t[2],s=r-3,c=e.indexOf(n,a);for(;c!==-1&&c<=s;){if(e[c+1]===i&&e[c+2]===o)return c;c=e.indexOf(n,c+1)}return-1}if(i===4){let n=t[0],i=t[1],o=t[2],s=t[3],c=r-4,l=e.indexOf(n,a);for(;l!==-1&&l<=c;){if(e[l+1]===i&&e[l+2]===o&&e[l+3]===s)return l;l=e.indexOf(n,l+1)}return-1}outer:for(let n=a;n<=r-i;n++){for(let r=0;r<i;r++)if(e[n+r]!==t[r])continue outer;return n}return-1}var Gc=class{_activeChunkCount(){return this._chunks.length-this._chunkHead}_headChunk(){return this._chunks[this._chunkHead]}_compactConsumedChunks(){if(this._chunkHead!==0){if(this._chunkHead>=this._chunks.length){this._chunks=[],this._chunkHead=0;return}this._chunkHead>32&&this._chunkHead*2>=this._chunks.length&&(this._chunks=this._chunks.slice(this._chunkHead),this._chunkHead=0)}}_dropHeadChunk(){this._chunkHead++,this._headOffset=0,this._compactConsumedChunks()}constructor(e){this._chunks=[],this._chunkHead=0,this._headOffset=0,this._length=0,this._cachedView=null,this._cachedLength=0,e&&e.length>0&&this.reset(e)}get length(){return this._length}isEmpty(){return this.length===0}view(){if(this._length===0)return G;if(this._activeChunkCount()===1)return this._headChunk().subarray(this._headOffset,this._headOffset+this._length);if(this._cachedView&&this._cachedLength===this._length)return this._cachedView;let e=new Uint8Array(this._length),t=0;for(let n=this._chunkHead;n<this._chunks.length;n++){let r=this._chunks[n],i=n===this._chunkHead?this._headOffset:0,a=n===this._chunks.length-1?i+(this._length-t):r.length;if(e.set(r.subarray(i,a),t),t+=a-i,t>=e.length)break}return this._cachedView=e,this._cachedLength=this._length,e}reset(e){if(this._cachedView=null,this._cachedLength=0,this._chunks=[],this._chunkHead=0,this._headOffset=0,this._length=0,!e||e.length===0)return;let t=new Uint8Array(e.length);t.set(e),this._chunks=[t],this._chunkHead=0,this._headOffset=0,this._length=t.length}append(e){e.length!==0&&(this._cachedView=null,this._cachedLength=0,this._chunks.push(e),this._length+=e.length)}read(e){if(e<=0)return G;if(e>this._length)throw RangeError(`ByteQueue: read beyond available data`);if(this._cachedView=null,this._cachedLength=0,this._activeChunkCount()===1){let t=this._headChunk(),n=this._headOffset,r=n+e,i=t.subarray(n,r);return this._headOffset=r,this._length-=e,this._length===0?(this._chunks=[],this._chunkHead=0,this._headOffset=0):this._headOffset>=t.length&&this._dropHeadChunk(),i}let t=new Uint8Array(e),n=0,r=e;for(;r>0;){let e=this._headChunk(),i=this._headOffset,a=e.length-i,o=Math.min(a,r);t.set(e.subarray(i,i+o),n),n+=o,r-=o,this._headOffset+=o,this._length-=o,this._headOffset>=e.length&&this._dropHeadChunk()}return this._length===0&&(this._chunks=[],this._chunkHead=0,this._headOffset=0),t}peekChunks(e){if(e<=0)return[];if(e>this._length)throw RangeError(`ByteQueue: peek beyond available data`);if(this._activeChunkCount()===1){let t=this._headChunk(),n=this._headOffset;return[t.subarray(n,n+e)]}let t=[],n=e;for(let e=this._chunkHead;e<this._chunks.length&&n>0;e++){let r=this._chunks[e],i=e===this._chunkHead?this._headOffset:0,a=r.length-i;if(a<=0)continue;let o=Math.min(a,n);t.push(r.subarray(i,i+o)),n-=o}return t}discard(e){if(e<=0)return;if(e>=this._length){this._chunks=[],this._chunkHead=0,this._headOffset=0,this._length=0,this._cachedView=null,this._cachedLength=0;return}this._cachedView=null,this._cachedLength=0;let t=e;for(;t>0;){let e=this._headChunk(),n=this._headOffset,r=e.length-n,i=Math.min(r,t);this._headOffset+=i,this._length-=i,t-=i,this._headOffset>=e.length&&this._dropHeadChunk()}this._length===0&&(this._chunks=[],this._chunkHead=0,this._headOffset=0)}indexOfPattern(e,t=0){let n=e.length;if(n===0)return 0;let r=this._length;if(n>r)return-1;let i=t|0;if(i<0&&(i=0),i>r-n)return-1;if(this._activeChunkCount()===1){let t=this._headChunk(),a=this._headOffset,o=t.subarray(a,a+r);return n===1?o.indexOf(e[0],i):Wc(o,e,i)}if(n>4)return Wc(this.view(),e,i);let a=e[0],o=n>=2?e[1]:0,s=n>=3?e[2]:0,c=n>=4?e[3]:0,l=this._chunks,u=this._chunkHead,d=(e,t)=>{let n=e,r=t;for(;n<l.length;){let e=l[n];if(r<e.length)return e[r]|0;r-=e.length,n++}return null},f=0;for(let e=u;e<l.length;e++){let t=l[e],p=e===u?this._headOffset:0,m=t.length-p;if(m<=0)continue;let h=f,g=h+m,_=i<=h?p:i>=g?t.length:p+(i-h);if(_>t.length-1){f+=m;continue}let v=t.length-1,y=t.indexOf(a,_);for(;y!==-1&&y<=v;){let i=h+(y-p);if(i>r-n)return-1;if(n===1)return i;if(y+n<=t.length){if(t[y+1]!==o){y=t.indexOf(a,y+1);continue}if(n===2)return i;if(t[y+2]!==s){y=t.indexOf(a,y+1);continue}if(n===3)return i;if(t[y+3]!==c){y=t.indexOf(a,y+1);continue}return i}let l=d(e,y+1);if(l===null||l!==o){y=t.indexOf(a,y+1);continue}if(n===2)return i;let u=d(e,y+2);if(u===null||u!==s){y=t.indexOf(a,y+1);continue}if(n===3)return i;let f=d(e,y+3);if(f===null||f!==c){y=t.indexOf(a,y+1);continue}return i}f+=m}return-1}peekUint32LE(e){let t=e|0;if(t<0||t+4>this._length)return null;let n=this._chunks,r=t;for(let e=this._chunkHead;e<n.length;e++){let t=n[e],i=e===this._chunkHead?this._headOffset:0,a=t.length-i;if(r<a){let a=i+r;if(a+4<=t.length){let e=t[a]|0,n=t[a+1]|0,r=t[a+2]|0,i=t[a+3]|0;return(e|n<<8|r<<16|i<<24)>>>0}let o=t[a]|0,s=0,c=0,l=0,u=e,d=a+1;for(let e=1;e<4;e++)for(;u<n.length;){let t=n[u];if(d<t.length){let n=t[d]|0;e===1?s=n:e===2?c=n:l=n,d++;break}u++,d=0}return(o|s<<8|c<<16|l<<24)>>>0}r-=a}return null}peekByte(e){let t=e|0;if(t<0||t>=this._length)throw RangeError(`ByteQueue: peek beyond available data`);let n=t;for(let e=this._chunkHead;e<this._chunks.length;e++){let t=this._chunks[e],r=e===this._chunkHead?this._headOffset:0,i=t.length-r;if(n<i)return t[r+n]|0;n-=i}throw RangeError(`ByteQueue: peek beyond available data`)}};function Kc(){try{return typeof CompressionStream>`u`?!1:(new CompressionStream(`deflate-raw`),!0)}catch{return!1}}function qc(){try{return typeof DecompressionStream>`u`?!1:(new DecompressionStream(`deflate-raw`),!0)}catch{return!1}}let Jc=null,Yc=null;function Xc(){return typeof CompressionStream>`u`?!1:(Jc===null&&(Jc=Kc()),Jc)}function Zc(){return typeof DecompressionStream>`u`?!1:(Yc===null&&(Yc=qc()),Yc)}function Qc(){return Xc()&&Zc()}async function $c(e){let t=new Gc;for(;;){let{done:n,value:r}=await e.read();if(n)break;t.append(r)}return t.read(t.length)}async function el(e,t){let n=t.writable.getWriter(),r=t.readable.getReader();try{let t=$c(r);return await n.write(e),await n.close(),await t}finally{try{n.releaseLock()}catch{}try{r.releaseLock()}catch{}}}async function tl(e){return el(e,new DecompressionStream(`deflate-raw`))}let nl={};function rl(e,t){let n=`${e}:${t}`;return()=>{let r=e===`compression`?typeof CompressionStream<`u`?CompressionStream:void 0:typeof DecompressionStream<`u`?DecompressionStream:void 0;if(!r)return!1;let i=nl[n];if(i!=null)return i;try{new r(t),nl[n]=!0}catch{nl[n]=!1}return nl[n]}}rl(`compression`,`gzip`),rl(`decompression`,`gzip`),rl(`compression`,`deflate`),rl(`decompression`,`deflate`),new Uint8Array([120,1]),new Uint8Array([120,1]),new Uint8Array([120,94]),new Uint8Array([120,94]),new Uint8Array([120,94]),new Uint8Array([120,94]),new Uint8Array([120,156]),new Uint8Array([120,218]),new Uint8Array([120,218]),new Uint8Array([120,218]);var il=class extends t{constructor(e,t){super(e,t),this.name=`ArchiveError`}},al=class extends il{constructor(e,t,n){super(`CRC32 mismatch for "${e}": expected 0x${t.toString(16).padStart(8,`0`)}, got 0x${n.toString(16).padStart(8,`0`)}`),this.path=e,this.expected=t,this.actual=n,this.name=`Crc32MismatchError`}},ol=class extends il{constructor(e,t,n,r){let i=r===`too-many-bytes`?`Entry "${e}" produced more bytes than declared: expected ${t}, got at least ${n}`:`Entry "${e}" produced fewer bytes than declared: expected ${t}, got ${n}`;super(i),this.path=e,this.expected=t,this.actual=n,this.reason=r,this.name=`EntrySizeMismatchError`}isZipBomb(){return this.reason===`too-many-bytes`}isCorruption(){return this.reason===`too-few-bytes`}},sl=class extends il{constructor(e,t){super(t?`Failed to decrypt "${e}": ${t}`:`Failed to decrypt "${e}": incorrect password or corrupted data`),this.name=`DecryptionError`}},cl=class extends il{constructor(e){super(`File "${e}" is encrypted. Please provide a password to extract.`),this.name=`PasswordRequiredError`}},ll=class extends il{constructor(e){super(`Unsupported compression method: ${e}`),this.name=`UnsupportedCompressionError`}};let ul={maxWorkers:typeof navigator<`u`&&navigator.hardwareConcurrency||4,minWorkers:0,idleTimeout:3e4,useTransferables:!0,workerUrl:void 0};function dl(e){let t=e?.maxWorkers??ul.maxWorkers,n=e?.minWorkers??ul.minWorkers,r=Math.min(n,t);return{maxWorkers:Math.max(1,t),minWorkers:Math.max(0,r),idleTimeout:Math.max(0,e?.idleTimeout??ul.idleTimeout),useTransferables:e?.useTransferables??ul.useTransferables,workerUrl:e?.workerUrl}}let fl={high:3,normal:2,low:1};function pl(e){return e?fl[e]??fl.normal:fl.normal}function ml(){return typeof Worker<`u`&&typeof Blob<`u`}function hl(){return`
32
32
  'use strict';
33
33
 
34
34
  // Check deflate-raw support once at startup
@@ -315,10 +315,10 @@ self.onmessage = async function(event) {
315
315
  }
316
316
  }
317
317
  };
318
- `}let pl=null,ml=0;function hl(){if(pl===null){let e=fl(),t=new Blob([e],{type:`text/javascript`});pl=URL.createObjectURL(t)}return ml++,pl}function gl(){if(pl!==null&&--ml<=0){try{URL.revokeObjectURL(pl)}catch{}pl=null,ml=0}}let _l=new Uint8Array,vl={onData:e=>{},onEnd:()=>{},onError:e=>{}};function yl(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength}function bl(e){return yl(e)?e:e.slice()}var xl=class{_taskQueueSize(){return this._taskQueue.length-this._taskQueueHead}_compactTaskQueueIfNeeded(){this._taskQueueHead>32&&this._taskQueueHead*2>=this._taskQueue.length&&(this._taskQueue.splice(0,this._taskQueueHead),this._taskQueueHead=0)}_dequeueTask(){if(this._taskQueueHead>=this._taskQueue.length)return;let e=this._taskQueue[this._taskQueueHead++];return this._compactTaskQueueIfNeeded(),e}_compactPendingStreamRequestsIfNeeded(){this._pendingStreamRequestHead>32&&this._pendingStreamRequestHead*2>=this._pendingStreamRequests.length&&(this._pendingStreamRequests.splice(0,this._pendingStreamRequestHead),this._pendingStreamRequestHead=0)}_dequeuePendingStreamRequest(){if(this._pendingStreamRequestHead>=this._pendingStreamRequests.length)return;let e=this._pendingStreamRequests[this._pendingStreamRequestHead++];return this._compactPendingStreamRequestsIfNeeded(),e}_waitForStreamSlot(e){return e.slotWaitPromise||=new Promise(t=>{e.resolveSlotWait=()=>{e.slotWaitPromise=null,e.resolveSlotWait=null,t()}}),e.slotWaitPromise}_waitForStreamDrain(e){return e.drainWaitPromise||=new Promise(t=>{e.resolveDrainWait=()=>{e.drainWaitPromise=null,e.resolveDrainWait=null,t()}}),e.drainWaitPromise}_resolveSlotWaiter(e){e.resolveSlotWait?.()}_resolveDrainWaiter(e){e.resolveDrainWait?.()}constructor(e){this._workers=new Map,this._taskQueue=[],this._taskQueueHead=0,this._pendingTasks=new Map,this._nextTaskId=1,this._nextWorkerId=1,this._terminated=!1,this._completedTasks=0,this._failedTasks=0,this._pendingStreamRequests=[],this._pendingStreamRequestHead=0,this._options=cl(e),this._options.workerUrl?(this._workerUrl=this._options.workerUrl,this._useCustomUrl=!0):(this._workerUrl=hl(),this._useCustomUrl=!1);for(let e=0;e<this._options.minWorkers;e++)this._createWorker()}async execute(e,t,n){if(this._terminated)throw Error(`Worker pool has been terminated`);if(!dl())throw Error(`Web Workers are not supported in this environment`);if(n?.signal?.aborted)throw r();let i=this._nextTaskId++,a=n?.priority??`normal`,o=ul(a);return new Promise((r,s)=>{let c={taskId:i,taskType:e,data:t,level:n?.level,priority:a,priorityValue:o,resolve:r,reject:s,signal:n?.signal,allowTransfer:n?.allowTransfer,startTime:performance.now()};n?.signal&&(c.abortHandler=()=>{this._cancelTask(i)},n.signal.addEventListener(`abort`,c.abortHandler,{once:!0})),this._pendingTasks.set(i,c),this._enqueueTask(c),this._processQueue()})}getStats(){let e=this._workers.size,t=0;for(let e of this._workers.values())e.busy&&t++;return{totalWorkers:e,activeWorkers:t,idleWorkers:e-t,pendingTasks:this._taskQueueSize(),completedTasks:this._completedTasks,failedTasks:this._failedTasks}}terminate(){if(this._terminated)return;this._terminated=!0;for(let e of this._workers.values())this._terminateWorker(e);this._workers.clear();let e=Error(`Worker pool terminated`);for(let t of this._pendingTasks.values())this._cleanupTask(t),t.reject(e);this._pendingTasks.clear(),this._taskQueue.length=0,this._taskQueueHead=0,this._pendingStreamRequests.length=0,this._pendingStreamRequestHead=0,this._useCustomUrl||gl()}isTerminated(){return this._terminated}_createWorker(){if(this._terminated||this._workers.size>=this._options.maxWorkers)return null;let e=this._nextWorkerId++,t=new Worker(this._workerUrl),n={id:e,worker:t,busy:!1,currentTaskId:null,idleTimer:null,streamSession:null};return t.onmessage=e=>{this._handleWorkerMessage(n,e.data)},t.onerror=e=>{this._handleWorkerError(n,e)},this._workers.set(e,n),n}_terminateWorker(e){this._clearIdleTimer(e);try{e.worker.postMessage({type:`terminate`})}catch{}try{e.worker.terminate()}catch{}this._workers.delete(e.id)}_clearIdleTimer(e){e.idleTimer!==null&&(clearTimeout(e.idleTimer),e.idleTimer=null)}_findIdleWorker(){for(let e of this._workers.values())if(!e.busy)return e}_enqueueTask(e){let t=this._taskQueue,n=e.priorityValue;this._compactTaskQueueIfNeeded();let r=this._taskQueueHead,i=t.length;for(;r<i;){let e=r+i>>>1;t[e].priorityValue>=n?r=e+1:i=e}t.splice(r,0,e)}_processQueue(){for(;!this._terminated&&this._taskQueueSize()>0;){let e=this._findIdleWorker()??this._createWorker()??void 0;if(!e)return;for(;;){let t=this._dequeueTask();if(!t)return;if(t.signal?.aborted){this._pendingTasks.delete(t.taskId),this._cleanupTask(t),t.reject(r());continue}this._assignTask(e,t);break}}}_assignTask(e,t){this._clearIdleTimer(e),e.busy=!0,e.currentTaskId=t.taskId;let n=this._options.useTransferables&&t.allowTransfer===!0,r=n?bl(t.data):t.data,i={type:`task`,taskId:t.taskId,taskType:t.taskType,data:r,level:t.level};n?e.worker.postMessage(i,[r.buffer]):e.worker.postMessage(i)}_handleWorkerMessage(e,t){if(t.type!==`ready`){if(e.streamSession){let n=e.streamSession;switch(t.type){case`started`:if(t.taskId!==n.taskId)return;n.startReady=!0,n.resolveStart?.(),n.resolveStart=null,n.rejectStart=null;return;case`out`:if(t.taskId!==n.taskId)return;n.onData(t.data);return;case`ack`:if(t.taskId!==n.taskId)return;n.inflightChunkCount>0&&n.inflightChunkCount--,this._resolveSlotWaiter(n),n.inflightChunkCount===0&&n.resolveDrainWait&&this._resolveDrainWaiter(n);return;case`done`:if(t.taskId!==n.taskId)return;n.ended=!0,n.inflightChunkCount=0,n.startReady=!0,n.resolveStart?.(),n.resolveStart=null,n.rejectStart=null,this._resolveSlotWaiter(n),this._resolveDrainWaiter(n),this._completedTasks++,t.duration??performance.now()-n.startTime,n.onEnd(),e.streamSession=null,this._workerBecameIdle(e);return;case`error`:{if(t.taskId!==n.taskId)return;let r=Error(t.error??`Unknown worker error`);n.ended=!0,n.inflightChunkCount=0,n.startReady=!0,n.rejectStart?.(r),n.resolveStart=null,n.rejectStart=null,this._resolveSlotWaiter(n),this._resolveDrainWaiter(n),this._failedTasks++,n.onError(r),e.streamSession=null,this._workerBecameIdle(e);return}default:break}}switch(t.type){case`result`:case`error`:{let n=t.taskId;if(typeof n!=`number`)return;let r=this._pendingTasks.get(n);if(!r){this._workerBecameIdle(e);return}if(this._pendingTasks.delete(n),this._cleanupTask(r),t.type===`result`){this._completedTasks++;let e=t.duration??performance.now()-r.startTime;r.resolve({data:t.data,duration:e})}else this._failedTasks++,r.reject(Error(t.error??`Unknown worker error`));this._workerBecameIdle(e);return}default:return}}}_handleWorkerError(e,t){let n=e.currentTaskId;if(this._terminateWorker(e),n!==null){let e=this._pendingTasks.get(n);e&&(this._pendingTasks.delete(n),this._cleanupTask(e),this._failedTasks++,e.reject(Error(t.message||`Worker error`)))}this._processQueue()}_workerBecameIdle(e){if(e.busy=!1,e.currentTaskId=null,this._pendingStreamRequestHead<this._pendingStreamRequests.length){let t=this._dequeuePendingStreamRequest();if(t){t(e);return}}this._taskQueueSize()>0?this._processQueue():this._workers.size>this._options.minWorkers&&this._options.idleTimeout>0&&(e.idleTimer=setTimeout(()=>{!e.busy&&this._workers.size>this._options.minWorkers&&!this._terminated&&this._terminateWorker(e)},this._options.idleTimeout))}openStream(e,t=vl){if(this._terminated)throw Error(`Worker pool has been terminated`);if(!dl())throw Error(`Web Workers are not supported in this environment`);let n=this._nextTaskId++,r=t.allowTransfer===!0,i=this._options.useTransferables&&r,a=i?bl:e=>e,o=i?(e,t,n)=>{e.postMessage(t,[n.buffer])}:(e,t,n)=>{e.postMessage(t)},s=null,c=null,l=async()=>{if(s)return s;if(c)return c;c=(async()=>{let r=this._findIdleWorker()??this._createWorker()??void 0;return r?(s=r,this._bindStreamSession(s,n,e,t.level,t),this._startStreamSession(s),s):(s=await new Promise(e=>{this._pendingStreamRequests.push(e)}),this._bindStreamSession(s,n,e,t.level,t),this._startStreamSession(s),s)})();try{return await c}finally{c=null}};l();let u=(e,t,n)=>{let r=a(n),i=t.chunkMessage;i.data=r,o(e.worker,i,r)},d=(e,t,n)=>{if(t.inflightChunkCount>=8)return this._waitForStreamSlot(t).then(()=>{t.ended||(t.inflightChunkCount++,u(e,t,n))});t.inflightChunkCount++,u(e,t,n)};return{write:async e=>{if(e.byteLength===0)return;let t=s??await l(),n=t.streamSession;if(!n||n.ended)throw Error(`Streaming session is not active`);n.writeChain=n.writeChain.then(()=>{if(!n.ended)return n.startReady?d(t,n,e):n.startPromise.then(()=>{if(!n.ended)return d(t,n,e)})}),await n.writeChain},end:async()=>{let e=await l(),t=e.streamSession;!t||t.ended||(t.startReady||await t.startPromise,await t.writeChain,t.inflightChunkCount>0&&await this._waitForStreamDrain(t),t.ended=!0,e.worker.postMessage(t.endMessage))},abort:e=>{l().then(t=>{let n=t.streamSession;if(!n)return;let r=n.abortMessage;r.error=e,t.worker.postMessage(r)})}}}_bindStreamSession(e,t,n,r,i){this._clearIdleTimer(e),e.busy=!0,e.currentTaskId=t;let a=null,o=null,s=new Promise((e,t)=>{a=e,o=t}),c=setTimeout(()=>{o?.(Error(`Worker stream start timeout`))},5e3);s.finally(()=>clearTimeout(c)),e.streamSession={taskId:t,taskType:n,startTime:performance.now(),started:!1,startReady:!1,startPromise:s,resolveStart:a,rejectStart:o,level:r,writeChain:Promise.resolve(),inflightChunkCount:0,slotWaitPromise:null,resolveSlotWait:null,drainWaitPromise:null,resolveDrainWait:null,chunkMessage:{type:`chunk`,taskId:t,data:_l},startMessage:{type:`start`,taskId:t,taskType:n,level:r},endMessage:{type:`end`,taskId:t},abortMessage:{type:`abort`,taskId:t,error:void 0},ended:!1,onData:i.onData,onEnd:i.onEnd,onError:i.onError}}_startStreamSession(e){let t=e.streamSession;!t||t.started||(t.started=!0,e.worker.postMessage(t.startMessage))}_cancelTask(e){let t=this._pendingTasks.get(e);if(!t)return;this._pendingTasks.delete(e),this._cleanupTask(t);let n=-1;for(let t=this._taskQueueHead;t<this._taskQueue.length;t++)if(this._taskQueue[t].taskId===e){n=t;break}n>=0&&this._taskQueue.splice(n,1),t.reject(r())}_cleanupTask(e){e.abortHandler&&e.signal&&e.signal.removeEventListener(`abort`,e.abortHandler)}async executeBatch(e){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];t[n]=this.execute(r.taskType,r.data,r.options)}return Promise.all(t)}};let Sl=null;function Cl(e){return(!Sl||Sl.isTerminated())&&(Sl=new xl(e)),Sl}async function wl(e,t){return(await Cl().execute(`inflate`,e,t)).data}let Tl=`ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\xA0`;function El(e){let t=!1;for(let n=0;n<e.length;n++)if(e[n]>=128){t=!0;break}if(!t)return Pl(e);let n=Array(e.length);for(let t=0;t<e.length;t++){let r=e[t];r<128?n[t]=String.fromCharCode(r):n[t]=Tl[r-128]}return n.join(``)}function Dl(e){if(e.length===0)return G;let t=new Uint8Array(e.length),n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r),a=i;if(i>=55296&&i<=56319&&r+1<e.length){let t=e.charCodeAt(r+1);t>=56320&&t<=57343&&(a=(i-55296<<10)+(t-56320)+65536,r++)}if(a<128){t[n++]=a;continue}if(a>65535){t[n++]=63;continue}let o=Ol.get(String.fromCharCode(a));t[n++]=o??63}return n===t.length?t:t.subarray(0,n)}let Ol=(()=>{let e=new Map;for(let t=0;t<128;t++)e.set(Tl[t],128+t);return e})(),kl={name:`utf-8`,encode:tn,decode:nn,useUtf8Flag:!0,useUnicodeExtraFields:!1},Al={name:`cp437`,encode:Dl,decode:El,useUtf8Flag:!1,useUnicodeExtraFields:!0},jl=new WeakMap;function Ml(e){if(!e||e===`utf-8`)return kl;if(e===`cp437`)return Al;let t=e,n=jl.get(t);if(n)return n;let r=t.useUtf8Flag??t.name===`utf-8`,i={...t,useUtf8Flag:r,useUnicodeExtraFields:t.useUnicodeExtraFields??!r};return jl.set(t,i),i}function Nl(e,t){return e?t.encode(e):G}function Pl(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n){let i=e.subarray(r,Math.min(r+n,e.length));t+=String.fromCharCode(...i)}return t}function Fl(e,t,n,r){return e.length===0?``:(t??0)&2048?nn(e):n&&n.version===1&&n.originalCrc32===yc(e)?n.unicodeValue:r?r.decode(e):El(e)}function Il(e,t,n,r){return Fl(e,t,n?.unicodePath,r)}function Ll(e,t,n,r){return Fl(e,t,n?.unicodeComment,r)}function Rl(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer.constructor===ArrayBuffer?e.buffer:e.slice().buffer}function zl(e){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e>>>0,!0),t}function Bl(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(t,!0)}var Vl=class{constructor(e,t=0){this.data=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.offset=t}get position(){return this.offset}set position(e){this.offset=e}get remaining(){return this.data.length-this.offset}readUint8(){let e=this.view.getUint8(this.offset);return this.offset+=1,e}readUint16(){let e=this.view.getUint16(this.offset,!0);return this.offset+=2,e}readUint32(){let e=this.view.getUint32(this.offset,!0);return this.offset+=4,e}readBigUint64(){let e=this.view.getBigUint64(this.offset,!0);return this.offset+=8,e}readBytes(e){let t=this.data.subarray(this.offset,this.offset+e);return this.offset+=e,t}readString(e,t=!0){let n=this.readBytes(e);return t?nn(n):El(n)}skip(e){this.offset+=e}slice(e,t){return this.data.subarray(e,t)}peekUint32(e){return this.view.getUint32(e,!0)}};function Hl(e,t){let n={},r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=0;for(let[a,o]of t){if(e.length>=i+o)switch(o){case 1:n[a]=r.getUint8(i);break;case 2:n[a]=r.getUint16(i,!0);break;case 4:n[a]=r.getUint32(i,!0);break;case 8:{let e=r.getUint32(i,!0);n[a]=r.getUint32(i+4,!0)*4294967296+e;break}default:throw Error(`Unsupported UInt LE size!`)}else n[a]=null;i+=o}return n}function Ul(e,t){return Hl(e,t)}function Wl(e,t){let n=dl();if(t.useWorker===!0)return n;if(t.useWorker===!1)return!1;let r=t.autoWorkerThreshold??1048576;return n&&e.length>=r}function Gl(e,t){if(t?.aborted||i(e))throw r(t?.reason??e)}let Kl={hasNative:Jc,native:Qc,worker:wl,jsFallback:jc};async function ql(e,t,n){let r=e.hasNative(),i=dl(),a=n.useWorker;if(a===!0&&i)try{return await e.worker(t,{level:n.level,signal:n.signal,allowTransfer:n.allowTransfer})}catch(e){Gl(e,n.signal)}return r?e.native(t):a!==!0&&Wl(t,n)?e.worker(t,{level:n.level,signal:n.signal,allowTransfer:n.allowTransfer}):e.jsFallback(t)}async function Jl(e,t={}){return ql(Kl,e,t)}function Yl(e){return jc(e)}new Uint8Array([31,139,8,0,0,0,0,0,0,255]);let Xl=`write after end`;function Zl(e,t,n){let r=a(t);n?n(r):e.emit(`error`,r)}var Ql=class extends W{constructor(...e){super(...e),this.ended=!1,this.destroyed=!1,this.writeChain=Promise.resolve(),this._backend=null}setBackend(e){this._backend=e}write(e,t){if(this.ended)return Zl(this,Error(Xl),t),!1;if(e.byteLength===0)return t&&queueMicrotask(t),!0;let n=this._backend;if(!n)throw Error(`Backend not initialized`);let r=this.writeChain.then(()=>n.write(e));return this.writeChain=r,r.then(()=>{this.destroyed||t?.()}).catch(e=>{this.destroyed||Zl(this,e,t)}),!0}end(e){if(this.ended){e?.();return}this.ended=!0;let t=this._backend;if(!t)throw Error(`Backend not initialized`);this.writeChain.then(()=>t.close()).then(()=>e?.()).catch(t=>Zl(this,t,e))}destroy(e){this.ended=!0,this.destroyed=!0,this._backend?.abort(e),e&&this.emit(`error`,e)}};function $l(e,t){let n=t?new CompressionStream(e):new DecompressionStream(e),r=n.writable.getWriter(),i=n.readable.getReader(),o=new Ql,s=null,c=(async()=>{try{for(;;){let{value:e,done:t}=await i.read();if(t)break;e&&o.emit(`data`,e)}o.emit(`end`)}catch(e){let t=a(e);s=t,o.emit(`error`,t)}})();return o.setBackend({write:e=>r.write(e),close:async()=>{if(await r.close(),await c,s)throw s},abort:e=>{i.cancel(e).catch(()=>{}),r.abort(e).catch(()=>{})}}),o}function eu(e,t,n,r){let i=t??Cl(),a=null,o=null,s=new Promise((e,t)=>{a=e,o=t}),c=new Ql,l=i.openStream(e,{level:n,allowTransfer:r,onData:e=>c.emit(`data`,e),onEnd:()=>{c.emit(`end`),a?.()},onError:e=>{c.emit(`error`,e),o?.(e)}});return c.setBackend({write:e=>l.write(e),close:async()=>{await l.end(),await s},abort:e=>{a?.(),l.abort(e?.message)}}),c}var tu=class extends W{constructor(e){super(),this.process=e,this.chunks=[],this.ended=!1}write(e,t){return this.ended?(Zl(this,Error(Xl),t),!1):e.byteLength===0?(t&&queueMicrotask(t),!0):(this.chunks.push(e),t&&queueMicrotask(t),!0)}end(e){if(this.ended){e?.();return}this.ended=!0;let t=this.chunks.length,n=t===0?G:t===1?this.chunks[0]:O(this.chunks);this.chunks.length=0;try{let t=this.process(n);this.emit(`data`,t),this.emit(`end`),e?.()}catch(t){Zl(this,t,e)}}destroy(e){this.ended=!0,this.chunks.length=0,e&&this.emit(`error`,e)}};function nu(e,t){let n=e===`deflate`?t.level??6:void 0;return t.useWorker&&dl()?eu(e,t.workerPool,n,t.allowTransfer):Yc()?$l(`deflate-raw`,e===`deflate`):new tu(e===`deflate`?Nc:jc)}function ru(e={}){return nu(`deflate`,e)}function iu(e){let t={key0:305419896,key1:591751049,key2:878082192},n=typeof e==`string`?tn(e):e;for(let e=0;e<n.length;e++)au(t,n[e]);return t}function au(e,t){e.key0=bc(e.key0,t),e.key1=e.key1+(e.key0&255)>>>0,e.key1=(Math.imul(e.key1,134775813)>>>0)+1>>>0,e.key2=bc(e.key2,e.key1>>>24&255)}function ou(e){let t=(e.key2|2)>>>0;return Math.imul(t,t^1)>>>8&255}function su(e,t){let n=(t^ou(e))&255;return au(e,n),n}function cu(e,t){let n=(t^ou(e))&255;return au(e,t),n}function lu(e,t,n,r){if(t.length!==12)return!1;let i=new Uint8Array(12);for(let n=0;n<12;n++)i[n]=su(e,t[n]);let a=i[11];return a===(n>>>24&255)||r!==void 0&&a===(r>>>8&255)}function uu(e,t,n){let r=new Uint8Array(12),i=n(11);for(let t=0;t<11;t++)r[t]=cu(e,i[t]);return r[11]=cu(e,t>>>24&255),r}function du(e,t,n,r){if(e.length<12)return null;let i=iu(t);if(!lu(i,e.subarray(0,12),n,r))return null;let a=e.length-12,o=new Uint8Array(a);for(let t=0;t<a;t++)o[t]=su(i,e[12+t]);return o}let fu={128:8,192:12,256:16},pu={128:16,192:24,256:32},mu={128:1,192:2,256:3},hu={1:128,2:192,3:256};function gu(){if(globalThis.crypto?.subtle!==void 0)return globalThis.crypto.subtle;throw Error(`Web Crypto API not available`)}function _u(e){if(globalThis.crypto?.getRandomValues!==void 0)return globalThis.crypto.getRandomValues(e),e;throw Error(`crypto.getRandomValues not available`)}function vu(e){return _u(new Uint8Array(e))}async function yu(e,t,n){let r=gu(),i=typeof e==`string`?tn(e):e,a=pu[n],o=a+32+2,s=await r.importKey(`raw`,Rl(i),`PBKDF2`,!1,[`deriveBits`]),c=await r.deriveBits({name:`PBKDF2`,salt:Rl(t),iterations:1e3,hash:`SHA-1`},s,o*8),l=new Uint8Array(c);return{encryptionKey:l.subarray(0,a),hmacKey:l.subarray(a,a+32),passwordVerify:l.subarray(a+32,a+34)}}async function bu(e,t){let n=gu(),r=await n.importKey(`raw`,Rl(e),{name:`HMAC`,hash:`SHA-1`},!1,[`sign`]),i=await n.sign(`HMAC`,r,Rl(t));return new Uint8Array(i,0,10)}function xu(e){let t=new Uint8Array(16);return new DataView(t.buffer).setUint32(0,e,!0),t}async function Su(e,t,n=!0){let r=gu(),i=await r.importKey(`raw`,Rl(e),{name:`AES-CTR`},!1,[`encrypt`,`decrypt`]),a=xu(1),o=await r.encrypt({name:`AES-CTR`,counter:Rl(a),length:128},i,Rl(t));return new Uint8Array(o)}function Cu(e,t,n){let r=new Uint8Array(11),i=new DataView(r.buffer);return i.setUint16(0,39169,!0),i.setUint16(2,7,!0),i.setUint16(4,e,!0),i.setUint16(6,17729,!0),r[8]=mu[t],i.setUint16(9,n,!0),r}function wu(e,t){let n=fu[t],r=n+2+10;return e.length<r?null:{salt:e.subarray(0,n),storedVerify:e.subarray(n,n+2),ciphertext:e.subarray(n+2,e.length-10),storedHmac:e.subarray(e.length-10)}}function Tu(e,t){return e[0]===t[0]&&e[1]===t[1]}function Eu(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}async function Du(e,t,n){let r=wu(e,n);if(!r)throw Error(`Encrypted data too short`);let{salt:i,storedVerify:a,ciphertext:o,storedHmac:s}=r,c=await yu(t,i,n);if(!Tu(c.passwordVerify,a))throw Error(`Password verification failed`);if(!Eu(await bu(c.hmacKey,o),s))throw Error(`HMAC verification failed`);return Su(c.encryptionKey,o,!1)}async function Ou(e,t,n){let r=fu[n],i=vu(r),a=await yu(t,i,n),o=await Su(a.encryptionKey,e,!0),s=await bu(a.hmacKey,o),c=new Uint8Array(r+2+o.length+10),l=0;return c.set(i,l),l+=r,c.set(a.passwordVerify,l),l+=2,c.set(o,l),l+=o.length,c.set(s,l),c}let ku={"aes-128":128,"aes-192":192,"aes-256":256};function Au(e){return e in ku}function ju(e){return ku[e]}function Mu(e){return!Number.isFinite(e)||e<=0?0:e>=4294967295?4294967295:e>>>0}function Nu(e){return Mu(Math.floor(e.getTime()/1e3))}function Pu(e){if(typeof BigInt!=`function`)throw Error(`NTFS timestamps require BigInt support`);return BigInt(e.getTime())*10000n+116444736000000000n}function Fu(e,t){let n=t?.atime!==void 0,r=t?.ctime!==void 0,i=1;n&&(i|=2),r&&(i|=4);let a=5+(n?4:0)+(r?4:0),o=new Uint8Array(4+a),s=new DataView(o.buffer);s.setUint16(0,21589,!0),s.setUint16(2,a,!0),o[4]=i,s.setUint32(5,Nu(e),!0);let c=9;return n&&(s.setUint32(c,Nu(t.atime),!0),c+=4),r&&s.setUint32(c,Nu(t.ctime),!0),o}function Iu(e,t){if(typeof BigInt!=`function`)throw Error(`NTFS timestamps require BigInt support`);let n=t?.atime??e,r=t?.ctime??e,i=t?.birthTime??e,a=new Uint8Array(44),o=new DataView(a.buffer);o.setUint16(0,10,!0),o.setUint16(2,40,!0),o.setUint32(4,0,!0),o.setUint16(8,1,!0),o.setUint16(10,32,!0);let s=12;return o.setBigUint64(s,Pu(e),!0),s+=8,o.setBigUint64(s,Pu(n),!0),s+=8,o.setBigUint64(s,Pu(r),!0),s+=8,o.setBigUint64(s,Pu(i),!0),a}function Lu(e){return[(e.getHours()&31)<<11|(e.getMinutes()&63)<<5|e.getSeconds()>>1&31,(e.getFullYear()-1980&127)<<9|(e.getMonth()+1&15)<<5|e.getDate()&31]}function Ru(e,t){let n=e&31,r=e>>5&15,i=(e>>9&127)+1980,a=t?(t&31)*2:0,o=t?t>>5&63:0,s=t?t>>11:0;return new Date(Date.UTC(i,r-1,n,s,o,a))}function zu(e,t,n){return n===void 0?Ru(e,t):new Date(n*1e3)}function Bu(e,t,n){if(t===`dos`)return new Uint8Array;let r=[Fu(e,n)];return t===`dos+utc+ntfs`&&r.push(Iu(e,n)),O(r)}function Vu(e){let[t,n]=Lu(e);return{dosTime:t,dosDate:n}}let Hu=67324752,Uu=33639248,Wu=101010256,Gu=134695760,Ku=101075792,qu=117853008,Ju=2048,Yu=61440,Xu=40960,Zu=16384;function Qu(e){return e>>16&65535}function $u(e){return(e&Yu)===Xu}function ed(e){return(e&Yu)===Zu}let td=4294967295;function nd(e,t,n,r){let i=r.versionNeeded??20;return t.setUint32(n+0,Hu,!0),t.setUint16(n+4,i,!0),t.setUint16(n+6,r.flags,!0),t.setUint16(n+8,r.compressionMethod,!0),t.setUint16(n+10,r.dosTime,!0),t.setUint16(n+12,r.dosDate,!0),t.setUint32(n+14,r.crc32,!0),t.setUint32(n+18,r.compressedSize,!0),t.setUint32(n+22,r.uncompressedSize,!0),t.setUint16(n+26,r.fileName.length,!0),t.setUint16(n+28,r.extraField.length,!0),e.set(r.fileName,n+30),r.extraField.length>0&&e.set(r.extraField,n+30+r.fileName.length),30+r.fileName.length+r.extraField.length}function rd(e){let t=new Uint8Array(30+e.fileName.length+e.extraField.length);return nd(t,new DataView(t.buffer,t.byteOffset,t.byteLength),0,e),t}function id(e,t,n,r){let i=r.versionMadeBy??20,a=r.versionNeeded??20,o=r.externalAttributes??0;return t.setUint32(n+0,Uu,!0),t.setUint16(n+4,i,!0),t.setUint16(n+6,a,!0),t.setUint16(n+8,r.flags,!0),t.setUint16(n+10,r.compressionMethod,!0),t.setUint16(n+12,r.dosTime,!0),t.setUint16(n+14,r.dosDate,!0),t.setUint32(n+16,r.crc32,!0),t.setUint32(n+20,r.compressedSize,!0),t.setUint32(n+24,r.uncompressedSize,!0),t.setUint16(n+28,r.fileName.length,!0),t.setUint16(n+30,r.extraField.length,!0),t.setUint16(n+32,r.comment.length,!0),t.setUint16(n+34,0,!0),t.setUint16(n+36,0,!0),t.setUint32(n+38,o,!0),t.setUint32(n+42,r.localHeaderOffset,!0),e.set(r.fileName,n+46),r.extraField.length>0&&e.set(r.extraField,n+46+r.fileName.length),r.comment.length>0&&e.set(r.comment,n+46+r.fileName.length+r.extraField.length),46+r.fileName.length+r.extraField.length+r.comment.length}function ad(e,t,n,r){return t.setUint32(n+0,Wu,!0),t.setUint16(n+4,0,!0),t.setUint16(n+6,0,!0),t.setUint16(n+8,r.entryCount,!0),t.setUint16(n+10,r.entryCount,!0),t.setUint32(n+12,r.centralDirSize,!0),t.setUint32(n+16,r.centralDirOffset,!0),t.setUint16(n+20,r.comment.length,!0),r.comment.length>0&&e.set(r.comment,n+22),22+r.comment.length}function od(e,t,n){let r=new Uint8Array(16),i=new DataView(r.buffer);return i.setUint32(0,Gu,!0),i.setUint32(4,e,!0),i.setUint32(8,t,!0),i.setUint32(12,n,!0),r}function sd(e,t,n){let r=n>>>0,i=Math.floor(n/4294967296)>>>0;e.setUint32(t,r,!0),e.setUint32(t+4,i,!0)}function cd(e,t,n){let r=new Uint8Array(24),i=new DataView(r.buffer,r.byteOffset,r.byteLength);return i.setUint32(0,Gu,!0),i.setUint32(4,e,!0),sd(i,8,t),sd(i,16,n),r}function ld(e){let t=e.uncompressedSize!==void 0,n=e.compressedSize!==void 0,r=e.localHeaderOffset!==void 0,i=e.diskNumberStart!==void 0,a=0;if(t&&(a+=8),n&&(a+=8),r&&(a+=8),i&&(a+=4),a===0)return G;let o=new Uint8Array(4+a),s=new DataView(o.buffer,o.byteOffset,o.byteLength);s.setUint16(0,1,!0),s.setUint16(2,a,!0);let c=4;return t&&(sd(s,c,e.uncompressedSize),c+=8),n&&(sd(s,c,e.compressedSize),c+=8),r&&(sd(s,c,e.localHeaderOffset),c+=8),i&&s.setUint32(c,e.diskNumberStart,!0),o}function ud(e,t){return O([e,t])}function dd(e,t,n,r){let i=r.versionMadeBy??20,a=r.versionNeeded??45,o=r.diskNumber??0,s=r.centralDirectoryDiskNumber??0;return t.setUint32(n+0,Ku,!0),sd(t,n+4,44),t.setUint16(n+12,i,!0),t.setUint16(n+14,a,!0),t.setUint32(n+16,o,!0),t.setUint32(n+20,s,!0),sd(t,n+24,r.entryCountOnDisk),sd(t,n+32,r.entryCountTotal),sd(t,n+40,r.centralDirSize),sd(t,n+48,r.centralDirOffset),56}function fd(e,t,n,r){let i=r.zip64EndOfCentralDirectoryDiskNumber??0,a=r.totalDisks??1;return t.setUint32(n+0,qu,!0),t.setUint32(n+4,i,!0),sd(t,n+8,r.zip64EndOfCentralDirectoryOffset),t.setUint32(n+16,a,!0),20}function pd(e,t,n){let r=tn(n),i=5+r.length,a=new Uint8Array(4+i),o=new DataView(a.buffer,a.byteOffset,a.byteLength);return o.setUint16(0,e,!0),o.setUint16(2,i,!0),a[4]=1,o.setUint32(5,yc(t)>>>0,!0),a.set(r,9),a}function md(e,t){return pd(28789,e,t)}function hd(e,t){return pd(25461,e,t)}let gd=BigInt(2**53-1);function _d(e,t){return e.getBigUint64(t,!0)}function vd(e){return typeof e.getBigUint64==`function`}function yd(e){if(!(e>gd))return Number(e)}function bd(e,t){let n={};if(e.length<4)return n;let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=vd(r),a=0;for(;a+4<=e.length;){let o=r.getUint16(a,!0),s=r.getUint16(a+2,!0),c=a+4,l=c+s;if(l>e.length)break;if(o===1){let e=c;if(t.uncompressedSize===4294967295&&e+8<=l){let i=_d(r,e);n.uncompressedSize64=i,t.uncompressedSize64=i;let a=yd(i);a!==void 0&&(n.uncompressedSize=a,t.uncompressedSize=a),e+=8}if(t.compressedSize===4294967295&&e+8<=l){let i=_d(r,e);n.compressedSize64=i,t.compressedSize64=i;let a=yd(i);a!==void 0&&(n.compressedSize=a,t.compressedSize=a),e+=8}if(t.offsetToLocalFileHeader===4294967295&&e+8<=l){let i=_d(r,e);n.offsetToLocalFileHeader64=i,t.offsetToLocalFileHeader64=i;let a=yd(i);a!==void 0&&(n.offsetToLocalFileHeader=a,t.offsetToLocalFileHeader=a)}}else if(o===21589){if(s>=1){let t=e[c],i=c+1;t&1&&i+4<=l&&(n.mtimeUnixSeconds=r.getUint32(i,!0)>>>0,i+=4),t&2&&i+4<=l&&(n.atimeUnixSeconds=r.getUint32(i,!0)>>>0,i+=4),t&4&&i+4<=l&&(n.ctimeUnixSeconds=r.getUint32(i,!0)>>>0)}}else if(o===10){if(i&&s>=8){let e=c+4;for(;e+4<=l;){let t=r.getUint16(e,!0),i=r.getUint16(e+2,!0),a=e+4,o=a+i;if(o>l)break;t===1&&i>=32&&a+32<=o&&(n.ntfsTimes={mtime:r.getBigUint64(a+0,!0),atime:r.getBigUint64(a+8,!0),ctime:r.getBigUint64(a+16,!0),birthTime:r.getBigUint64(a+24,!0)}),e=o}}}else if(o===39169){if(s>=7){let t=r.getUint16(c,!0),i=r.getUint16(c+2,!0),a=e[c+4],o=r.getUint16(c+5,!0);if(i===17729){let e=hu[a];e&&(t===1||t===2)&&(n.aesInfo={version:t,keyStrength:e,compressionMethod:o})}}}else o===28789?s>=5&&(n.unicodePath={version:e[c],originalCrc32:r.getUint32(c+1,!0),unicodeValue:nn(e.subarray(c+5,l))}):o===25461&&s>=5&&(n.unicodeComment={version:e[c],originalCrc32:r.getUint32(c+1,!0),unicodeValue:nn(e.subarray(c+5,l))});a=l}return n}function xd(e){return e?8:0}function Sd(e,t=!0){let n=0;return t&&(n|=Ju),e&&(n|=8),n}function Cd(e){let t=Ml(e.codec),n=t.encode(e.name),r=Nl(e.comment,t),{dosTime:i,dosDate:a}=Vu(e.modTime),o=e.atime||e.ctime||e.birthTime?{atime:e.atime,ctime:e.ctime,birthTime:e.birthTime}:void 0,s=Bu(e.modTime,e.timestamps,o);return!t.useUtf8Flag&&t.useUnicodeExtraFields&&(e.name&&(s=ud(s,md(n,e.name))),e.comment&&(s=ud(s,hd(r,e.comment)))),{nameBytes:n,commentBytes:r,dosTime:i,dosDate:a,extraField:s,compressionMethod:xd(e.deflate),flags:Sd(e.useDataDescriptor,t.useUtf8Flag)}}function wd(e,t=20){return(e&255)<<8|t&255}function Td(e){switch(e){case`directory`:return Zu;case`symlink`:return Xu;default:return 32768}}function Ed(e){return e>>>0&65535}function Dd(e,t){let n=e.endsWith(`/`)||e.endsWith(`\\`);return t!==void 0&&$u(t)?`symlink`:n?`directory`:`file`}function Od(e){let t=e.kind,n=t===`directory`?16:32,r=(e.msDosAttributes??n)&255,i=e.mode;i!==void 0&&(i&61440||(i=i&4095|Td(t)),i=Ed(i));let a=((i??0)&65535)<<16|r,o=wd(i!==void 0||t===`symlink`?3:0);return{externalAttributes:a>>>0,versionMadeBy:o}}function kd(e){if(e.externalAttributes!==void 0)return{externalAttributes:e.externalAttributes,versionMadeBy:e.versionMadeBy};let t=Od({kind:Dd(e.name,e.mode),mode:e.mode,msDosAttributes:e.msDosAttributes});return{externalAttributes:t.externalAttributes,versionMadeBy:e.versionMadeBy??t.versionMadeBy}}function Ad(e){return e.replace(/\\/g,`/`)}function jd(e){return e.replace(/^\/+/,``)}function Md(e){return e.replace(/^[a-zA-Z]:\/?/,``)}function Nd(e){let t=e.split(`/`),n=[];for(let e of t)if(!(!e||e===`.`)){if(e===`..`){n.length>0?n.pop():n.push(`..`);continue}n.push(e)}return n.join(`/`)}function Pd(e){return e.startsWith(`/`)}function Fd(e){return/^[a-zA-Z]:/.test(e)}function Id(e,t={}){let n=t.mode??`legacy`,r=e;r=Ad(r);let i=Fd(r);if(n===`legacy`)return r=jd(r),t.prependSlash?`/`+r:r;let a=t.stripDrive??!0;if(n===`safe`&&i&&!a)throw Error(`Unsafe ZIP path (drive): ${e}`);a&&(r=Md(r));let o=Pd(r);if(r=jd(r),r=Nd(r),n===`safe`){if(o)throw Error(`Unsafe ZIP path (absolute): ${e}`);if(r===`..`||r.startsWith(`../`))throw Error(`Unsafe ZIP path (traversal): ${e}`)}return t.prependSlash?`/`+r:r}function Ld(e){return Math.log(e)/Math.LN2}function Rd(e,t){let n=0;for(let r=0;r<256;r++){let i=e[r];if(i===0)continue;let a=i/t;n-=a*Ld(a)}return n}function zd(e,t){let n=new Uint32Array(256),r=0,i=0;if(Array.isArray(e))for(let a=0;a<e.length&&!(r>=t);a++){let o=e[a],s=Math.min(o.length,t-r);for(let e=0;e<s;e++){let t=o[e];n[t]===0&&(i+=1),n[t]+=1}r+=s}else for(let a of e){if(r>=t)break;let e=Math.min(a.length,t-r);for(let t=0;t<e;t++){let e=a[t];n[e]===0&&(i+=1),n[e]+=1}r+=e}return{total:r,unique:i,counts:n}}function Bd(e,t={}){let n=t.sampleBytes??65536,r=t.minDecisionBytes??16384,{total:i,unique:a,counts:o}=zd(e,n);return i<r||a<200?!1:Rd(o,i)>=7.95}function Vd(e,t,n,r,i){if(!i)return 0;let a=0;return(e||t>4294967295)&&(a+=8),(e||n>4294967295)&&(a+=8),(e||r>4294967295)&&(a+=8),a>0?4+a:0}function Hd(e){let t=e[0];return t?.fileName===void 0?t?.compressedData===void 0?`central`:`processed`:`input`}function Ud(e,t){let n=t.zip64Mode===!0,r=t.zip64Mode===!1,i=Hd(e),a=0;for(let t=0;t<e.length;t++){let r=e[t],o=i===`input`?r.fileName:r.name,s=r.extraField,c=r.comment,l=i===`processed`?r.compressedData.length:r.compressedSize,u=r.uncompressedSize,d=i===`input`?r.localHeaderOffset:r.offset,f=i===`processed`?void 0:r.zip64,p=n||f===!0||d>4294967295||l>4294967295||u>4294967295;a+=46+o.length+s.length+Vd(n,u,l,d,p)+(c?.length??0)}let o=e.length>65535||t.centralDirOffset>4294967295,s=n||o||a>4294967295;if(r&&s)throw Error(`ZIP64 is required but zip64=false`);let c=s?98+t.zipComment.length:22+t.zipComment.length;return{centralDirSize:a,trailerSize:c,totalSize:a+c,usedZip64:s}}function Wd(e,t){let n=t.zip64Mode===!0,r=Ud(e,{zipComment:t.zipComment,zip64Mode:t.zip64Mode,centralDirOffset:t.centralDirOffset}),i=Hd(e),a=t.offset,o=new DataView(t.out.buffer,t.out.byteOffset,t.out.byteLength);for(let r=0;r<e.length;r++){let s=e[r],c=i===`input`?s.fileName:s.name,l=s.extraField,u=s.comment,d=s.flags,f=i===`input`?s.crc32:s.crc,p=i===`processed`?s.compressedData.length:s.compressedSize,m=s.uncompressedSize,h=s.compressionMethod,g=i===`processed`?s.modTime:s.dosTime,_=i===`processed`?s.modDate:s.dosDate,v=i===`input`?s.localHeaderOffset:s.offset,y=i===`processed`?void 0:s.zip64,b=s.externalAttributes,ee=s.versionMadeBy,x=n||y===!0||v>4294967295||p>4294967295||m>4294967295,te=x?ld({uncompressedSize:n||m>4294967295?m:void 0,compressedSize:n||p>4294967295?p:void 0,localHeaderOffset:n||v>4294967295?v:void 0}):G,ne=x&&te.length>0?ud(l,te):l;a+=id(t.out,o,a,{fileName:c,extraField:ne,comment:u??G,flags:d,compressionMethod:h,dosTime:g,dosDate:_,crc32:f,compressedSize:x?td:p,uncompressedSize:x?td:m,localHeaderOffset:x?td:v,versionMadeBy:ee??20,versionNeeded:x?45:20,externalAttributes:b})}if(r.usedZip64){let n=t.centralDirOffset+r.centralDirSize;a+=dd(t.out,o,a,{entryCountOnDisk:e.length,entryCountTotal:e.length,centralDirSize:r.centralDirSize,centralDirOffset:t.centralDirOffset}),a+=fd(t.out,o,a,{zip64EndOfCentralDirectoryOffset:n,totalDisks:1}),ad(t.out,o,a,{entryCount:65535,centralDirSize:td,centralDirOffset:td,comment:t.zipComment})}else ad(t.out,o,a,{entryCount:e.length,centralDirSize:r.centralDirSize,centralDirOffset:t.centralDirOffset,comment:t.zipComment});return{centralDirSize:r.centralDirSize,trailerSize:r.trailerSize,totalWritten:r.totalSize,usedZip64:r.usedZip64}}let Gd=16*1024;var Kd=class{constructor(e,t){this._deflate=null,this._crc=4294967295,this._uncompressedSize=0,this._compressedSize=0,this._finalized=!1,this._headerEmitted=!1,this._ondata=null,this._onerror=null,this._centralDirEntryInfo=null,this._pendingEnd=!1,this._emittedDataDescriptor=!1,this._localHeader=null,this._zip64Mode=`auto`,this._zip64=!1,this._deflateWanted=null,this._pendingChunks=[],this._sampleLen=0,this._completeResolve=null,this._completeReject=null,this._completePromise=null,this._completeError=null,this._encryptionMethod=`none`,this._zipCryptoState=null,this._aesBuffer=[],this._aesBufferSize=0,this._originalCompressionMethod=0,this._aesExtraField=null,this._dataQueue=[],this._finalQueued=!1,this._pushChain=Promise.resolve(),this._syncDeflater=null,this._syncZlibReady=!1;let n=t?.path?Id(e,t.path):e;this.name=n;let r=t?.modTime??new Date;if(this._modTime=r,this.level=t?.level??6,this._smartStore=t?.smartStore??!0,this._zip64Mode=t?.zip64??`auto`,this._zip64=this._zip64Mode===!0,this._encryptionMethod=t?.encryptionMethod??`none`,this._password=t?.password,this._encryptionMethod!==`none`&&!this._password)throw Error(`Password is required for encryption`);Au(this._encryptionMethod)&&(this._aesKeyStrength=ju(this._encryptionMethod)),this._stringCodec=Ml(t?.encoding);let i=Cd({name:n,comment:t?.comment,modTime:r,atime:t?.atime,ctime:t?.ctime,birthTime:t?.birthTime,timestamps:t?.timestamps??`dos`,useDataDescriptor:!0,deflate:!1,codec:this._stringCodec});this.nameBytes=i.nameBytes,this.commentBytes=i.commentBytes,this.dosTime=i.dosTime,this.dosDate=i.dosDate,this.extraField=i.extraField,this._flags=i.flags,this._compressionMethod=i.compressionMethod;let a=kd({name:n,mode:t?.mode,msDosAttributes:t?.msDosAttributes,externalAttributes:t?.externalAttributes,versionMadeBy:t?.versionMadeBy});if(this._externalAttributes=a.externalAttributes,this._versionMadeBy=a.versionMadeBy,this._encryptionMethod!==`none`&&(this._flags|=1),!this._smartStore){let e=this.level>0;this._deflateWanted=e,this._compressionMethod=this._buildCompressionMethod(e),e&&this._initDeflateStream();return}this.level===0&&(this._deflateWanted=!1,this._compressionMethod=this._buildCompressionMethod(!1))}_buildCompressionMethod(e){return xd(e)}_getAesExtraField(){return this._aesKeyStrength?(this._aesExtraField||=Cu(2,this._aesKeyStrength,this._originalCompressionMethod),this._aesExtraField):G}_initZipCryptoEncryption(){if(this._zipCryptoState||this._encryptionMethod!==`zipcrypto`)return;this._zipCryptoState=iu(this._password);let e=this.dosTime<<16|this.dosDate,t=uu(this._zipCryptoState,e,vu);this._compressedSize+=t.length,this._enqueueData(t,!1)}_zipCryptoEncryptChunk(e){if(!this._zipCryptoState)return e;let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=cu(this._zipCryptoState,e[n]);return t}_initDeflateStream(){this._deflate||(this._deflate=ru({level:this.level}),this._deflate.on(`error`,e=>{this._rejectComplete(e)}),this._deflate.on(`data`,e=>{if(this._aesKeyStrength){this._aesBuffer.push(e),this._aesBufferSize+=e.length;return}if(this._encryptionMethod===`zipcrypto`){this._initZipCryptoEncryption();let t=this._zipCryptoEncryptChunk(e);this._compressedSize+=t.length,this._enqueueData(t,!1);return}this._compressedSize+=e.length,this._enqueueData(e,!1)}),this._deflate.on(`end`,()=>{this._pendingEnd&&!this._emittedDataDescriptor&&(this._emittedDataDescriptor=!0,this._finalizeEncryptionAndEmitDescriptor())}))}_finalizeEncryptionAndEmitDescriptor(){if(this._aesKeyStrength&&this._aesBuffer.length>0){this._finalizeAesEncryption().then(()=>this._emitDataDescriptor()).catch(e=>this._rejectComplete(e));return}this._emitDataDescriptor()}async _finalizeAesEncryption(){if(!this._aesKeyStrength||this._aesBufferSize===0)return;let e;if(this._aesBuffer.length===1)e=this._aesBuffer[0];else{e=new Uint8Array(this._aesBufferSize);let t=0;for(let n=0;n<this._aesBuffer.length;n++){let r=this._aesBuffer[n];e.set(r,t),t+=r.length}}this._aesBuffer.length=0,this._aesBufferSize=0;let t=await Ou(e,this._password,this._aesKeyStrength);this._compressedSize=t.length,this._enqueueData(t,!1)}_buildLocalHeader(){let e=this.extraField,t=this._compressionMethod;return this._aesKeyStrength&&(this._originalCompressionMethod=this._compressionMethod,t=99,e=ud(this.extraField,this._getAesExtraField())),rd({fileName:this.nameBytes,extraField:e,flags:this._flags,compressionMethod:t,dosTime:this.dosTime,dosDate:this.dosDate,crc32:0,compressedSize:0,uncompressedSize:0,versionNeeded:this._zip64?45:20})}_accumulateSampleLen(e){if(this._deflateWanted!==null||e.length===0||this._sampleLen>=Gd)return;let t=Math.min(Gd-this._sampleLen,e.length);t<=0||(this._sampleLen+=t)}_shouldDecide(e){return this._deflateWanted===null?e||this._sampleLen>=Gd:!1}_decideCompressionIfNeeded(e,t,n=!1){if(this._deflateWanted===null){if(e&&this._sampleLen===0){this._deflateWanted=!1,this._sampleLen=0,this._compressionMethod=this._buildCompressionMethod(!1),this._localHeader=null;return}this._deflateWanted=!Bd((function*(e,t){for(let t of e)t.length&&(yield t);t.length&&(yield t)})(this._pendingChunks,t),{sampleBytes:Gd,minDecisionBytes:Gd}),this._sampleLen=0,this._compressionMethod=this._buildCompressionMethod(this._deflateWanted),this._localHeader=null,this._deflateWanted&&(n||this._initDeflateStream())}}_emitHeaderIfNeeded(){this._headerEmitted||=(this._emitHeader(),!0)}async _flushPendingChunks(){if(this._pendingChunks.length!==0){for(let e of this._pendingChunks)await this._writeData(e);this._pendingChunks.length=0}}_enqueueData(e,t){this._ondata?this._ondata(e,t):(this._dataQueue.push(e),t&&(this._finalQueued=!0))}_flushQueue(){if(!this._ondata)return;let e=this._dataQueue.length,t=this._finalQueued?e-1:-1;for(let n=0;n<e;n++)this._ondata(this._dataQueue[n],n===t);this._dataQueue.length=0,this._finalQueued=!1}get ondata(){return this._ondata}set ondata(e){this._ondata=e,this._flushQueue()}get onerror(){return this._onerror}set onerror(e){this._onerror=e,this._completeError&&e(this._completeError)}_resolveComplete(){this._completeResolve&&this._completeResolve()}_rejectComplete(e){this._completeError||(this._completeError=e,this._onerror&&this._onerror(e),this._completeReject&&this._completeReject(e))}_ensureCompletePromise(){return this._completeError?Promise.reject(this._completeError):this._emittedDataDescriptor?Promise.resolve():(this._completePromise||=new Promise((e,t)=>{this._completeResolve=e,this._completeReject=t}),this._completePromise)}_tapCallback(e,t){t&&e.then(()=>t()).catch(e=>t(e))}_writeDataSync(e,t){if(!(e.length===0&&!t)){if(e.length>0&&(this._crc=_c(this._crc,e),this._uncompressedSize+=e.length),this._deflateWanted){if(this._syncDeflater||=new Bc,e.length>0){let t=this._syncDeflater.write(e);t.length>0&&(this._compressedSize+=t.length,this._enqueueData(t,!1))}if(t){let e=this._syncDeflater.finish();e.length>0&&(this._compressedSize+=e.length,this._enqueueData(e,!1)),this._syncDeflater=null}return}if(this._aesKeyStrength){this._aesBuffer.push(e),this._aesBufferSize+=e.length;return}if(this._encryptionMethod===`zipcrypto`){this._initZipCryptoEncryption();let t=this._zipCryptoEncryptChunk(e);this._compressedSize+=t.length,this._enqueueData(t,!1);return}e.length>0&&(this._compressedSize+=e.length,this._enqueueData(e,!1))}}_writeData(e){if(e.length===0)return Promise.resolve();if(this._crc=_c(this._crc,e),this._uncompressedSize+=e.length,this._deflate)return new Promise((t,n)=>{this._deflate.write(e,e=>{e?n(e):t()})});if(this._aesKeyStrength)return this._aesBuffer.push(e),this._aesBufferSize+=e.length,Promise.resolve();if(this._encryptionMethod===`zipcrypto`){this._initZipCryptoEncryption();let t=this._zipCryptoEncryptChunk(e);return this._compressedSize+=t.length,this._enqueueData(t,!1),Promise.resolve()}return this._compressedSize+=e.length,this._enqueueData(e,!1),Promise.resolve()}_endDeflateAndWait(){return new Promise((e,t)=>{let n=this._deflate,r=e=>{a(),t(e)},i=()=>{a(),e()},a=()=>{n.off(`error`,r),n.off(`end`,i)};n.once(`error`,r),n.once(`end`,i),n.end()})}_finalizeAfterWrite(e){this._finalized=!0,this._pendingEnd=!0;let t=this._ensureCompletePromise();return this._deflate?e.then(()=>this._endDeflateAndWait()).then(()=>t):this._aesKeyStrength&&this._aesBufferSize>0?(this._emittedDataDescriptor=!0,this._finalizeAesEncryption().then(()=>this._emitDataDescriptor()).catch(e=>this._rejectComplete(e)),t):(this._emittedDataDescriptor=!0,this._emitDataDescriptor(),t)}_pushUnchained(e,t,n){if(this._finalized){let e=Promise.reject(Error(`Cannot push to finalized ZipDeflateFile`));return this._tapCallback(e,n),e}if(this._deflateWanted===null){if(this._accumulateSampleLen(e),!this._shouldDecide(t)){e.length>0&&this._pendingChunks.push(e);let t=Promise.resolve();return this._tapCallback(t,n),t}this._decideCompressionIfNeeded(t,e),this._emitHeaderIfNeeded();let r=this._pendingChunks.length>0,i=this._flushPendingChunks(),a=i;e.length>0&&(a=r?i.then(()=>this._writeData(e)):this._writeData(e));let o=t?this._finalizeAfterWrite(a):a;return this._tapCallback(o,n),o}this._emitHeaderIfNeeded();let r=this._writeData(e),i=t?this._finalizeAfterWrite(r):r;return this._tapCallback(i,n),i}push(e,t=!1,n){if(!this._deflate&&this._encryptionMethod===`none`){try{this._pushSyncPath(e,t),n?.()}catch(e){return n?.(e instanceof Error?e:Error(String(e))),Promise.reject(e)}return Promise.resolve()}let r=this._pushChain=this._pushChain.then(()=>this._pushUnchained(e,t,n));return r.catch(()=>{}),r}_pushSyncPath(e,t=!1){if(this._finalized)throw Error(`Cannot push to finalized ZipDeflateFile`);if(this._syncZlibReady||=!0,this._deflateWanted===null){if(this._accumulateSampleLen(e),!this._shouldDecide(t)){e.length>0&&this._pendingChunks.push(e);return}this._decideCompressionIfNeeded(t,e,!0),this._emitHeaderIfNeeded();for(let e of this._pendingChunks)this._writeDataSync(e,!1);this._pendingChunks.length=0,e.length>0&&this._writeDataSync(e,t),t&&this._finalizeSyncAfterWrite();return}this._emitHeaderIfNeeded(),this._writeDataSync(e,t),t&&this._finalizeSyncAfterWrite()}_finalizeSyncAfterWrite(){if(this._finalized=!0,this._pendingEnd=!1,this._emittedDataDescriptor=!0,this._aesKeyStrength&&this._aesBufferSize>0)throw Error(`AES encryption is not supported with synchronous push`);if(this._syncDeflater){let e=this._syncDeflater.finish();e.length>0&&(this._compressedSize+=e.length,this._enqueueData(e,!1)),this._syncDeflater=null}this._emitDataDescriptor()}_emitHeader(){this._localHeader||=this._buildLocalHeader(),this._enqueueData(this._localHeader,!1)}_emitDataDescriptor(){let e=vc(this._crc),t=this._compressedSize>4294967295||this._uncompressedSize>4294967295;if(this._zip64Mode===!1&&t){this._rejectComplete(Error(`ZIP64 is required but zip64=false`));return}(this._zip64Mode===!0||t&&!this._zip64)&&(this._zip64=!0);let n=this._zip64?cd(e,this._compressedSize,this._uncompressedSize):od(e,this._compressedSize,this._uncompressedSize),r=this._compressionMethod,i=this.extraField;this._aesKeyStrength&&(r=99,i=ud(this.extraField,this._getAesExtraField())),this._centralDirEntryInfo={name:this.nameBytes,extraField:i,comment:this.commentBytes,flags:this._flags,crc:e,compressedSize:this._compressedSize,uncompressedSize:this._uncompressedSize,compressionMethod:r,dosTime:this.dosTime,dosDate:this.dosDate,offset:-1,zip64:this._zip64,externalAttributes:this._externalAttributes,versionMadeBy:this._versionMadeBy},this._enqueueData(n,!0),this._resolveComplete()}complete(){return this._ensureCompletePromise()}getEntryInfo(){if(!this._centralDirEntryInfo)return null;let e=this.name,t=e.endsWith(`/`)||e.endsWith(`\\`),n=this._centralDirEntryInfo.externalAttributes,r=Qu(n);return{path:e,type:$u(r)?`symlink`:t?`directory`:`file`,compressedSize:this._centralDirEntryInfo.compressedSize,uncompressedSize:this._centralDirEntryInfo.uncompressedSize,compressionMethod:this._centralDirEntryInfo.compressionMethod,crc32:this._centralDirEntryInfo.crc,lastModified:this._modTime,localHeaderOffset:this._centralDirEntryInfo.offset,comment:this._stringCodec.decode(this._centralDirEntryInfo.comment),externalAttributes:n,mode:r,versionMadeBy:this._centralDirEntryInfo.versionMadeBy,extraField:this._centralDirEntryInfo.extraField,isEncrypted:this._encryptionMethod!==`none`,encryptionMethod:this._aesKeyStrength?`aes`:this._encryptionMethod===`zipcrypto`?`zipcrypto`:void 0,aesKeyStrength:this._aesKeyStrength,originalCompressionMethod:this._aesKeyStrength?this._originalCompressionMethod:void 0}}getCentralDirectoryEntryInfo(){return this._centralDirEntryInfo}isComplete(){return this._emittedDataDescriptor&&this._centralDirEntryInfo!==null}abort(e){if(this._completeError)return;let t=r(e);this._finalized=!0,this._pendingEnd=!0,this._rejectComplete(t);try{let e=this._deflate;e&&typeof e.destroy==`function`&&e.destroy(t)}catch{}}},qd=class{constructor(e,t){this.entries=[],this.currentOffset=0,this.ended=!1,this.endPending=!1,this.addedEntryCount=0,this.fileQueue=[],this.fileQueueIndex=0,this.activeFile=null,this.callback=e,this._stringCodec=t?.codec??Ml(t?.encoding),this.zipComment=Nl(t?.comment,this._stringCodec),this.zip64Mode=t?.zip64??`auto`}add(e){if(this.ended)throw Error(`Cannot add files after calling end() `);if(this.zip64Mode===!1&&this.addedEntryCount>=65535)throw Error(`ZIP64 is required but zip64=false`);this.addedEntryCount++,this.fileQueue.push(e),this.activeFile||this._processNextFile()}_processNextFile(){if(this.fileQueueIndex>=this.fileQueue.length){this.activeFile=null,this.fileQueue=[],this.fileQueueIndex=0,this.endPending&&this._finalize();return}let e=this.fileQueue[this.fileQueueIndex++];this.activeFile=e;let t=this.currentOffset;if(e.onerror=e=>{this.ended||(this.ended=!0,this.callback(e,G,!0))},e.ondata=(n,r)=>{if(!this.ended&&(this.currentOffset+=n.length,this.callback(null,n,!1),r)){let n=e.getCentralDirectoryEntryInfo();n&&(n.offset=t,this.entries.push(n)),this._processNextFile()}},typeof e.start==`function`)try{e.start().catch(t=>{let n=a(t);try{e.onerror?.(n)}catch{}})}catch(t){let n=a(t);try{e.onerror?.(n)}catch{}}}_finalize(){if(this.ended)return;this.ended=!0;let e=this.currentOffset,t;try{let n=Ud(this.entries,{zipComment:this.zipComment,zip64Mode:this.zip64Mode,centralDirOffset:e});t=new Uint8Array(n.totalSize),Wd(this.entries,{zipComment:this.zipComment,zip64Mode:this.zip64Mode,centralDirOffset:e,out:t,offset:0})}catch(e){let t=a(e);this.callback(t,G,!0);return}this.callback(null,t,!0)}end(){this.endPending||this.ended||(this.endPending=!0,this.activeFile||this._finalize())}abort(e){if(this.ended)return;let t=r(e);this.ended=!0,this.endPending=!0;try{this.activeFile?.abort(t)}catch{}this.callback(t,G,!0)}};function Jd(e){return e.encoding?Ml(e.encoding):void 0}function Yd(e,t=!1){for(let n=e.length-22;n>=0;n--)if(e[n]===80&&e[n+1]===75&&e[n+2]===5&&e[n+3]===6)if(t){let t=e[n+20]|e[n+21]<<8;if(n+22+t===e.length)return n}else return n;return-1}function Xd(e,t){let n=t-20;return n<0?-1:e[n]===80&&e[n+1]===75&&e[n+2]===6&&e[n+3]===7?n:-1}function Zd(e,t,n=!0,r){let i=new Vl(e,t);i.skip(4);let a=i.readUint16(),o=i.readUint16(),s=i.readUint16(),c=i.readUint16(),l=i.readUint32(),u=i.readUint32(),d=i.readUint16(),f=``;if(d>0){let e=i.readBytes(d);n&&(f=r?r.decode(e):nn(e))}return{eocd:{diskNumber:a,centralDirDisk:o,entriesOnDisk:s,totalEntries:c,centralDirSize:l,centralDirOffset:u},comment:f}}function Qd(e,t){let n=new Vl(e,t);return n.readUint32()===117853008?(n.skip(4),Number(n.readBigUint64())):-1}function $d(e,t){let n=new Vl(e,t);return n.readUint32()===101075792?(n.skip(8),n.skip(2),n.skip(2),n.skip(4),n.skip(4),{entriesOnDisk:n.readBigUint64(),totalEntries:n.readBigUint64(),centralDirSize:n.readBigUint64(),centralDirOffset:n.readBigUint64()}):null}function ef(e,t){e.totalEntries===65535&&(e.totalEntries=Number(t.totalEntries)),e.entriesOnDisk===65535&&(e.entriesOnDisk=Number(t.entriesOnDisk)),e.centralDirSize===4294967295&&(e.centralDirSize=Number(t.centralDirSize)),e.centralDirOffset===4294967295&&(e.centralDirOffset=Number(t.centralDirOffset))}function tf(e,t,n){let r=e.readUint16();e.skip(2);let i=e.readUint16(),a=e.readUint16(),o=e.readUint16(),s=e.readUint16(),c=e.readUint32(),l=e.readUint32(),u=e.readUint32(),d=e.readUint16(),f=e.readUint16(),p=e.readUint16();e.skip(2),e.skip(2);let m=e.readUint32(),h=e.readUint32(),g=d>0?e.readBytes(d):new Uint8Array,_={},v=new Uint8Array;if(f>0){v=e.readBytes(f);let t={compressedSize:l,uncompressedSize:u,offsetToLocalFileHeader:h};_=bd(v,t),l=t.compressedSize,u=t.uncompressedSize,h=t.offsetToLocalFileHeader??h}let y=p>0?e.readBytes(p):new Uint8Array,b=t?Il(g,i,_,n):``,ee=t?Ll(y,i,_,n):``,x=Qu(m),te=r>>8&255,ne=$u(x),re=ed(x)||te===0&&(m&16)!=0||b.endsWith(`/`),ie=(i&1)!=0,S=ne?`symlink`:re?`directory`:`file`,C=_.mtimeUnixSeconds,ae=zu(s,o,C),oe=`none`,se,ce,le;return ie&&(a===99&&_.aesInfo?(oe=`aes`,se=_.aesInfo.version,ce=_.aesInfo.keyStrength,le=_.aesInfo.compressionMethod):oe=`zipcrypto`),{path:b,type:S,compressedSize:l,compressedSize64:_.compressedSize64,uncompressedSize:u,uncompressedSize64:_.uncompressedSize64,compressionMethod:a,crc32:c,lastModified:ae,localHeaderOffset:h,localHeaderOffset64:_.offsetToLocalFileHeader64,comment:ee,externalAttributes:m,mode:x,versionMadeBy:r,extraField:v,isEncrypted:ie,encryptionMethod:oe,aesVersion:se,aesKeyStrength:ce,originalCompressionMethod:le,dosTime:o}}function nf(e,t,n,r={}){let i=r.decodeStrings??!0,a=Jd(r);if(n===0)return[];let o=Array(n),s=new Vl(e,t);for(let e=0;e<n;e++){if(s.readUint32()!==33639248)throw Error(`Invalid Central Directory header signature at entry ${e}`);o[e]=tf(s,i,a)}return o}function rf(e,t={}){let n=t.decodeStrings??!0,r=Jd(t),i=Yd(e);if(i===-1)throw Error(`Invalid ZIP file: End of Central Directory not found`);let{eocd:a,comment:o}=Zd(e,i,n,r),s=Xd(e,i);if(s!==-1){let t=Qd(e,s);if(t>=0){let n=$d(e,t);n&&ef(a,n)}}return{entries:nf(e,a.centralDirOffset,a.totalEntries,t),comment:o}}function af(e){return!!e&&typeof e==`object`&&typeof e.getReader==`function`}function of(e){return!!e&&typeof e==`object`&&typeof e.getWriter==`function`}function sf(e){return!!e&&typeof e==`object`&&!!e.readable&&!!e.writable&&af(e.readable)&&of(e.writable)}async function cf(e,t,n,r=!1,i=!0){let a;if(e.isEncrypted){if(!n)throw new al(e.path);if(e.encryptionMethod===`aes`&&e.aesKeyStrength){let r=await Du(t,n,e.aesKeyStrength);if(!r)throw new il(e.path);a=await uf(r,e.originalCompressionMethod??0,e.path)}else if(e.encryptionMethod===`zipcrypto`){let r=du(t,n,e.crc32,e.dosTime);if(!r)throw new il(e.path);a=await uf(r,e.compressionMethod,e.path)}else throw new il(e.path,`Unsupported encryption method`)}else a=await uf(t,e.compressionMethod,e.path);if(i&&a.length!==e.uncompressedSize){let t=a.length>e.uncompressedSize?`too-many-bytes`:`too-few-bytes`;throw new rl(e.path,e.uncompressedSize,a.length,t)}if(e.encryptionMethod===`zipcrypto`||r&&e.encryptionMethod!==`aes`){let t=yc(a);if(t!==e.crc32)throw new nl(e.path,e.crc32,t)}return a}function lf(e,t,n,r=!0){let i;if(e.isEncrypted){if(!n)throw new al(e.path);if(e.encryptionMethod===`aes`)throw Error(`File "${e.path}" uses AES encryption. Use the async extract() method instead of extractSync().`);if(e.encryptionMethod===`zipcrypto`){let r=du(t,n,e.crc32,e.dosTime);if(!r)throw new il(e.path);i=df(r,e.compressionMethod,e.path);let a=yc(i);if(a!==e.crc32)throw new nl(e.path,e.crc32,a)}else throw new il(e.path,`Unsupported encryption method`)}else i=df(t,e.compressionMethod,e.path);if(r&&i.length!==e.uncompressedSize){let t=i.length>e.uncompressedSize?`too-many-bytes`:`too-few-bytes`;throw new rl(e.path,e.uncompressedSize,i.length,t)}return i}async function uf(e,t,n){if(t===0)return e;if(t===8)return Jl(e);throw new ol(t)}function df(e,t,n){if(t===0)return e;if(t===8)return Yl(e);throw new ol(t)}function ff(e,t){if(e.readUint32()!==67324752)throw Error(`Invalid local file header signature at offset ${t}`);e.skip(2),e.skip(2),e.skip(2),e.skip(2),e.skip(2),e.skip(4),e.skip(4),e.skip(4);let n=e.readUint16(),r=e.readUint16();return e.skip(n),e.skip(r),e.position}function pf(e,t){let n=ff(new Vl(e,t.localHeaderOffset),t.localHeaderOffset);return e.subarray(n,n+t.compressedSize)}let mf=BigInt(2**53-1);function hf(e){if(e.uncompressedSize64!==void 0&&e.uncompressedSize64>mf||e.compressedSize64!==void 0&&e.compressedSize64>mf)throw Error(`File "${e.path}" is too large to extract into memory (ZIP64 size > 2^53-1)`);if(e.localHeaderOffset64!==void 0&&e.localHeaderOffset64>mf)throw Error(`File "${e.path}" has a ZIP64 offset > 2^53-1 and cannot be extracted by the in-memory parser`)}function gf(e,t={}){return rf(e,{decodeStrings:t.decodeStrings,encoding:t.encoding})}async function _f(e,t,n={}){return t.type===`directory`?G:(hf(t),cf(t,pf(e,t),n.password))}function vf(e,t,n={}){return t.type===`directory`?G:(hf(t),lf(t,pf(e,t),n.password))}var yf=class{constructor(e,t={}){this.data=e instanceof ArrayBuffer?new Uint8Array(e):e;let n=gf(this.data,t);this.entries=n.entries,this.archiveComment=n.comment,this.entryMap=new Map(this.entries.map(e=>[e.path,e])),this.password=t.password}setPassword(e){this.password=e}getEntries(){return this.entries}getEntry(e){return this.entryMap.get(e)}getRawCompressedData(e){let t=this.entryMap.get(e);return t?pf(this.data,t):null}getRawEntry(e){let t=this.entryMap.get(e);return t?{info:t,compressedData:pf(this.data,t)}:null}hasEntry(e){return this.entryMap.has(e)}childCount(e){let t=this.entryMap.get(e);if(t&&t.type!==`directory`)return 0;let n=e.endsWith(`/`)?e:e+`/`,r=t?.type===`directory`?t:this.entryMap.get(n),i=(r?.path??n).endsWith(`/`)?r?.path??n:(r?.path??n)+`/`,a=0;for(let e of this.entries)e.path.startsWith(i)&&e.path!==i&&a++;return a}getZipComment(){return this.archiveComment}hasEncryptedEntries(){return this.entries.some(e=>e.isEncrypted)}getEncryptedEntries(){return this.entries.filter(e=>e.isEncrypted)}listFiles(){return this.entries.map(e=>e.path)}async extract(e,t){let n=this.entryMap.get(e);return n?_f(this.data,n,{password:t??this.password}):null}extractSync(e,t){let n=this.entryMap.get(e);return n?vf(this.data,n,{password:t??this.password}):null}async extractAll(e){let t=new Map,n=e??this.password;for(let e of this.entries){let r=await _f(this.data,e,{password:n});t.set(e.path,r)}return t}extractAllSync(e){let t={},n=e??this.password;for(let e of this.entries)t[e.path]=vf(this.data,e,{password:n});return t}async forEach(e,t){let n=t??this.password;for(let t of this.entries){let r=null;if(await e(t,()=>(r||=_f(this.data,t,{password:n}),r))===!1)break}}};function bf(e){return e?16:65536}var xf=class extends t{constructor(e,t){super(e,t),this.name=`StreamError`}},Sf=class extends xf{constructor(e,t,n){super(`Cannot ${e}: ${t}`,n),this.operation=e,this.state=t,this.name=`StreamStateError`}},Cf=class extends xf{constructor(e,t,n){super(`Expected ${e}, got ${t}`,n),this.expectedType=e,this.actualType=t,this.name=`StreamTypeError`}};function wf(e,t){let n=(t??`utf-8`).trim().toLowerCase();switch(n){case``:case`utf8`:case`utf-8`:return Rt.encode(e);case`latin1`:case`binary`:{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}case`ascii`:{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&127;return t}case`hex`:{let t=e.length>>>1,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=parseInt(e.substring(r*2,r*2+2),16);return n}case`base64`:{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}case`base64url`:{let t=e.replace(/-/g,`+`).replace(/_/g,`/`);for(;t.length%4!=0;)t+=`=`;let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}case`utf16le`:case`utf-16le`:case`ucs2`:case`ucs-2`:{let t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>>8&255}return t}default:throw Tf(n)}}function Tf(e){let t=TypeError(`Unknown encoding: ${e}`);return t.code=`ERR_UNKNOWN_ENCODING`,t}var Ef=class{constructor(e){this._items=[],this._index=0,this._front=[],this._byteSize=0,this._objectMode=e}_chunkSize(e){return e instanceof Uint8Array?e.byteLength:1}get length(){return this._front.length+(this._items.length-this._index)}get byteSize(){return this._byteSize}push(e){this._items.push(e),this._objectMode||(this._byteSize+=this._chunkSize(e))}shift(){let e;return this._front.length>0?e=this._front.pop():(e=this._items[this._index++],this._index===this._items.length?(this._items.length=0,this._index=0):this._index>1024&&this._index*2>this._items.length&&(this._items=this._items.slice(this._index),this._index=0)),this._objectMode||(this._byteSize-=this._chunkSize(e)),e}unshift(e){this._index===0?this._front.push(e):(this._index--,this._items[this._index]=e),this._objectMode||(this._byteSize+=this._chunkSize(e))}peek(){let e=this._front.length;return e>0?this._front[e-1]:this._index<this._items.length?this._items[this._index]:null}toArray(){let e=this._front.length,t=this._items.length-this._index,n=Array(e+t);for(let t=0;t<e;t++)n[t]=this._front[e-1-t];for(let r=0;r<t;r++)n[e+r]=this._items[this._index+r];return n}clear(){this._items.length=0,this._index=0,this._front.length=0,this._byteSize=0}consumeBytes(e){if(e===0)return new Uint8Array;let t=this.peek();if(t instanceof Uint8Array&&t.byteLength===e)return this.shift();if(t instanceof Uint8Array&&t.byteLength>e){this._shiftFrontChunk();let n=t.subarray(0,e),r=t.subarray(e);return this.unshift(r),n}let n=new Uint8Array(e),r=0;for(;r<e;){let t=this.shift();if(t instanceof Uint8Array){let i=e-r;t.byteLength<=i?(n.set(t,r),r+=t.byteLength):(n.set(t.subarray(0,i),r),this.unshift(t.subarray(i)),r+=i)}}return n}consumeAll(){let e=this._front.length,t=e+(this._items.length-this._index);if(t===0)return new Uint8Array;if(t===1)return this.shift();let n=this._byteSize,r=new Uint8Array(n),i=0;for(let t=e-1;t>=0;t--){let e=this._front[t];e instanceof Uint8Array&&(r.set(e,i),i+=e.byteLength)}for(let e=this._index;e<this._items.length;e++){let t=this._items[e];t instanceof Uint8Array&&(r.set(t,i),i+=t.byteLength)}return this.clear(),r}_shiftFrontChunk(){return this.shift()}};let Df=(e,t,n)=>{typeof e.off==`function`?e.off(t,n):typeof e.removeListener==`function`&&e.removeListener(t,n)},Of=(e,t,n,r)=>(r?.once?typeof e.once==`function`&&e.once(t,n):typeof e.on==`function`&&e.on(t,n),()=>Df(e,t,n)),kf=()=>{let e=[];return{add:(t,n,r)=>{e.push(Of(t,n,r))},once:(t,n,r)=>{e.push(Of(t,n,r,{once:!0}))},cleanup:()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}};var Af=class{constructor(e){this._source=e,this._destinations=[],this._listeners=new Map,this._sourceOverride=null}setSource(e){this._sourceOverride=e}get _emitSource(){return this._sourceOverride??this._source}pipe(e,t){let n=e,r=n,i=typeof n?.write==`function`,a=typeof n?.end==`function`,o=typeof r?.on==`function`,s=typeof r?.once==`function`,c=typeof r?.off==`function`;if(!i||!a||!s&&!o||!c&&!r?.removeListener)throw new Cf(`Writable`,typeof n);this._destinations.push(n);let l,u=()=>{l&&=(Df(r,`drain`,l),void 0)},d=e=>{if(!n.write(e)&&(this._source.pause(),!l)){l=()=>{u(),this._source.resume()},r.on(`drain`,l);let e=this._listeners.get(n);e&&(e.drain=l)}},f=t?.end===!1?void 0:()=>{n.end()},p=()=>{this.unpipe(n)},m=typeof r.once==`function`?`once`:`on`;return r[m](`close`,p),r[m](`finish`,p),this._listeners.set(n,{data:d,end:f,destClose:p,destFinish:p,eventTarget:r}),this._source.on(`data`,d),f&&this._source.once(`end`,f),r.emit?.(`pipe`,this._emitSource),this._source.resume(),e}unpipe(e){if(e){let t=this._destinations.indexOf(e);t!==-1&&(this._destinations.splice(t,1),this._removeListeners(e),this._destinations.length===0&&this._source.pause())}else{let e=this._destinations.length>0;for(let e of this._destinations)this._removeListeners(e);this._destinations=[],e&&this._source.pause()}}_removeListeners(e){let t=this._listeners.get(e);t&&(this._source.off(`data`,t.data),t.end&&this._source.off(`end`,t.end),t.drain&&Df(t.eventTarget,`drain`,t.drain),t.destClose&&Df(t.eventTarget,`close`,t.destClose),t.destFinish&&Df(t.eventTarget,`finish`,t.destFinish),t.eventTarget.emit?.(`unpipe`,this._emitSource),this._listeners.delete(e))}};let jf=0;function K(e){queueMicrotask(()=>{jf++;try{e()}finally{jf--}})}function Mf(){return jf>0}let Nf=null;function Pf(){return Nf}function Ff(e){Nf=e}function If(e){return en(this,e??`utf-8`)}var q=class e extends W{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.read==`function`&&typeof t.pipe==`function`&&typeof t.on==`function`&&`readableFlowing`in t}constructor(e){super(),this._reader=null,this._reading=!1,this._ended=!1,this._endEmitted=!1,this._destroyed=!1,this._internalDestroy=!1,this._errored=null,this._closed=!1,this._flowing=!1,this._resumeScheduled=!1,this._hasFlowed=!1,this._encoding=null,this._decoder=null,this._didRead=!1,this._pushMode=!1,this._webStreamMode=!1,this._hasReadImpl=!1,this._constructed=!0,this._asyncIterState=null,this.__excelts_stream=!0,this._objectMode=e?.objectMode??!1,this._highWaterMark=e?.highWaterMark??bf(this._objectMode),this._buf=new Ef(this._objectMode),this._pipes=new Af(this),this._autoDestroy=e?.autoDestroy??!0,this._emitClose=e?.emitClose??!0,e?.read?(this._read=e.read.bind(this),this._hasReadImpl=!0,this._pushMode=!0):this._hasSubclassRead()&&(this._hasReadImpl=!0,this._pushMode=!0),e?.destroy&&(this._destroy=e.destroy.bind(this)),e?.construct&&(this._constructFunc=e.construct.bind(this)),e?.stream?(this._stream=e.stream,this._webStreamMode=!0):this._stream=null,e?.encoding&&this.setEncoding(e.encoding),e?.signal&&this._setupAbortSignal(e.signal),this._maybeConstruct()}_maybeConstruct(){(this._constructFunc||this._hasSubclassConstruct())&&(this._constructed=!1,K(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){this.destroy(e);return}this._constructed=!0,this._hasReadImpl&&this._flowing&&!this._ended&&!this._destroyed&&this._callRead(this._highWaterMark)})}))}_hasSubclassConstruct(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}_hasSubclassRead(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_read`))return!0;t=Object.getPrototypeOf(t)}return!1}_setupAbortSignal(e){if(e.aborted){this.destroy(r(e.reason));return}let t=()=>{i(),this.destroy(r(e.reason))},n=()=>{i()},i=()=>{e.removeEventListener(`abort`,t),this.off(`close`,n),this.off(`end`,n),this.off(`error`,n)};e.addEventListener(`abort`,t,{once:!0}),this.on(`close`,n),this.on(`end`,n),this.on(`error`,n)}static from(t,n){if(t&&typeof t.getReader==`function`)return e.fromWeb(t,n);if(typeof Blob<`u`&&t instanceof Blob)return e.fromWeb(t.stream(),n);if(t==null||typeof t!=`object`&&typeof t!=`string`){let e=TypeError(`The "iterable" argument must be an instance of Iterable. Received type ${typeof t} (${String(t)})`);throw e.code=`ERR_INVALID_ARG_TYPE`,e}let r=typeof t[Symbol.iterator]==`function`,i=typeof t[Symbol.asyncIterator]==`function`;if(!r&&!i&&typeof t!=`string`){let e=t?.constructor?.name??`Object`,n=TypeError(`The "iterable" argument must be an instance of Iterable. Received an instance of ${e}`);throw n.code=`ERR_INVALID_ARG_TYPE`,n}let a=new e({...n,objectMode:n?.objectMode??!0}),o=t;return Hf(a,Vf(typeof o==`string`?[o]:o)),a}static isDisturbed(e){return e._didRead||(e._destroyed||e._errored!==null)&&!e._endEmitted}static isReadable(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.read==`function`?t.destroyed||t._destroyed||t.readableEnded||t._endEmitted?!1:t.readable!==!1:null}static fromWeb(t,n){return new e({...n,stream:t})}static toWeb(e){return e._webStream}static wrap(t,n){return new e({objectMode:t.readableObjectMode??t.objectMode??!0,...n,destroy(e,n){typeof t.destroy==`function`&&t.destroy(e??void 0),n(e)}}).wrap(t)}push(e,t){if(this._destroyed)return!1;if(this._pushMode=!0,e!==null&&typeof e==`string`&&!this._objectMode){let n=wf(e,t||`utf8`);n.toString=If,e=n}if(this._ended&&e!==null){let e=Error(`stream.push() after EOF`);return e.code=`ERR_STREAM_PUSH_AFTER_EOF`,K(()=>this.emit(`error`,e)),!1}if(e===null)return this._ended?!1:(this._ended=!0,this._buf.length===0&&K(()=>this._emitEndOnce()),!1);if(!this._objectMode&&(typeof e==`string`?e.length:e?.byteLength??e?.length??0)===0)return!0;if(this._flowing)return this._buf.length>0?(this._buf.push(e),this._objectMode?this._buf.length<this._highWaterMark:this._buf.byteSize<this._highWaterMark):(this._didRead=!0,this.emit(`data`,this._applyEncoding(e)),this._flowing?(this._hasReadImpl&&!this._ended&&K(()=>{this._flowing&&!this._ended&&!this._destroyed&&(this._callRead(this._highWaterMark),this._ended&&this._buf.length===0&&this._emitEndOnce())}),!0):!1);{let t=this._buf.length===0;return this._buf.push(e),t&&K(()=>this.emit(`readable`)),this._objectMode?this._buf.length<this._highWaterMark:this._buf.byteSize<this._highWaterMark}}_emitEndOnce(){if(this._endEmitted||this._destroyed||this._buf.length>0)return;let e=this._flushDecoder();e&&this.emit(`data`,e),this._endEmitted=!0,this.emit(`end`),this._autoDestroy&&this.destroy()}unshift(e,t){if(this._destroyed)return;if(e===null){this._ended||(this._ended=!0,this._buf.length===0&&K(()=>this._emitEndOnce()));return}if(this._endEmitted){let e=Error(`stream.unshift() after end event`);e.code=`ERR_STREAM_UNSHIFT_AFTER_END_EVENT`,K(()=>this.emit(`error`,e));return}if(typeof e==`string`&&!this._objectMode){let n=wf(e,t||`utf8`);n.toString=If,e=n}let n=this._buf.length===0;this._buf.unshift(e),this._flowing?K(()=>{for(;this._buf.length>0&&this._flowing;){let e=this._buf.shift();this._didRead=!0,this.emit(`data`,this._applyEncoding(e))}this._ended&&this._buf.length===0&&this._emitEndOnce()}):n&&K(()=>this.emit(`readable`))}_callRead(e){try{this._read(e)}catch(e){let t=e instanceof Error?e:Error(String(e));this._internalDestroy=!0,this.destroy(t)}}read(e){this._didRead=!0;let t;if(e!=null){if(t=parseInt(e,10),isNaN(t))t=void 0;else if(t<=0){if(t===0&&!this._ended&&!this._destroyed&&this._constructed){let e=this._objectMode?this._buf.length:this._buf.byteSize;(e<this._highWaterMark||e===0)&&this._callRead(this._highWaterMark)}return null}}if(this._buf.length===0)return!this._ended&&!this._destroyed&&this._constructed&&this._callRead(this._highWaterMark),null;if(this._objectMode){let e=this._buf.shift();return this._ended&&this._buf.length===0&&K(()=>this._emitEndOnce()),this._hasReadImpl&&!this._ended&&!this._destroyed&&this._constructed&&this._buf.length<this._highWaterMark&&K(()=>{!this._ended&&!this._destroyed&&this._callRead(this._highWaterMark)}),e}let n;if(t==null)n=this._applyEncoding(this._buf.consumeAll());else if(this._buf.byteSize<t)if(this._ended)n=this._applyEncoding(this._buf.consumeAll());else return this._hasReadImpl&&this._constructed&&this._callRead(Math.max(t,this._highWaterMark)),null;else n=this._applyEncoding(this._buf.consumeBytes(t));return this._hasReadImpl&&!this._ended&&!this._destroyed&&this._buf.byteSize<this._highWaterMark&&K(()=>{!this._ended&&!this._destroyed&&this._callRead(this._highWaterMark)}),this._ended&&this._buf.length===0&&K(()=>this._emitEndOnce()),!this._flowing&&this._buf.length>0&&K(()=>this.emit(`readable`)),n}_flushDecoder(){if(!this._decoder)return null;let e=this._decoder.decode(new Uint8Array,{stream:!1});return this._decoder=null,e||null}setEncoding(e){return this._encoding=e,this._decoder=Wt(e),this}_applyEncoding(e){return this._encoding&&e instanceof Uint8Array?(this._decoder||=Wt(this._encoding),this._decoder.decode(e,{stream:!0})):e}wrap(e){let t=!1;return e.on(`data`,n=>{this.push(n)||(e.pause(),t=!0)}),e.on(`end`,()=>this.push(null)),e.on(`error`,e=>this.destroy(e)),e.on(`close`,()=>this.destroy()),this._hasReadImpl=!0,this._read=()=>{t&&(t=!1,e.resume())},this}pause(){return this._flowing?(this._flowing=!1,this.emit(`pause`)):this._hasFlowed=!0,this}resume(){return this._flowing||(this._flowing=!0,this._hasFlowed=!0,this._resumeScheduled||(this._resumeScheduled=!0,K(()=>{this._resumeScheduled=!1,this.emit(`resume`)}))),this._buf.length>0?K(()=>{for(;this._buf.length>0&&this._flowing;){let e=this._buf.shift();this._didRead=!0,this.emit(`data`,this._applyEncoding(e))}if(this._ended&&this._buf.length===0&&this._emitEndOnce(),this._flowing&&this._buf.length===0&&this._webStreamMode&&!this._pushMode&&!this._ended&&!this._destroyed&&this._startReading(),this._hasReadImpl&&this._flowing&&!this._ended&&!this._destroyed&&this._constructed){let e=this._objectMode?this._buf.length:this._buf.byteSize;(e<this._highWaterMark||e===0)&&this._callRead(this._highWaterMark)}}):this._ended&&this._buf.length===0?K(()=>this._emitEndOnce()):this._webStreamMode&&!this._pushMode?this._startReading():this._hasReadImpl&&K(()=>{this._flowing&&!this._ended&&!this._destroyed&&this._constructed&&(this._callRead(this._highWaterMark),this._ended&&this._buf.length===0&&this._emitEndOnce())}),this}on(e,t){return super.on(e,t),e===`data`?this.resume():e===`readable`&&(this._hasFlowed=!0,this._flowing=!1,(this._buf.length>0||this._ended)&&K(()=>this.emit(`readable`))),this}isPaused(){return this.readableFlowing===!1}pipe(e,t){return this._pipes.pipe(e,t)}unpipe(e){return this._pipes.unpipe(e),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._readableOverride=void 0,this.unpipe(),this._reader){let e=this._reader;this._reader=null,e.cancel().catch(()=>{}).finally(()=>{try{e.releaseLock()}catch{}})}let t=e=>{let t=e||null;t&&(this._errored=t),this._closed=!0;let n=()=>{t&&this.emit(`error`,t),this._emitClose&&this.emit(`close`)},r=this._endEmitted||this._internalDestroy;this._internalDestroy=!1,Mf()&&!this._hasDestroyHook()&&r?n():K(n)};if(this._hasDestroyHook())try{this._destroy(e??null,t)}catch(e){t(e instanceof Error?e:Error(String(e)))}else t(e);return this}_destroy(e,t){t(e)}_undestroy(){this._destroyed=!1,this._closed=!1,this._errored=null}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}get _webStream(){if(this._stream)return this._stream;let e=this,t=!1,n=new ReadableStream({pull(n){return new Promise((r,i)=>{if(t)return r();let a=()=>{if(e._destroyed){if(e._errored){t=!0;try{n.error(e._errored)}catch{}return i(e._errored)}t=!0;try{n.close()}catch{}return r()}let o=e.read();if(o!==null){try{n.enqueue(o)}catch{}return r()}if(e._endEmitted){t=!0;try{n.close()}catch{}return r()}let s=()=>{d(),a()},c=()=>{d(),t=!0;try{n.close()}catch{}r()},l=e=>{d(),t=!0;try{n.error(e)}catch{}i(e)},u=()=>{if(d(),!t){t=!0;try{n.close()}catch{}}r()},d=()=>{e.off(`readable`,s),e.off(`end`,c),e.off(`error`,l),e.off(`close`,u)};e.once(`readable`,s),e.once(`end`,c),e.once(`error`,l),e.once(`close`,u)};a()})},cancel(){e.destroy()}});return this._stream=n,n}get readable(){return this._readableOverride===void 0?!this._destroyed&&!this._endEmitted:this._readableOverride}set readable(e){this._readableOverride=e}get readableEnded(){return this._endEmitted}get readableLength(){return this._objectMode?this._buf.length:this._buf.byteSize}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e}get errored(){return this._errored}get closed(){return this._closed}get readableFlowing(){return this._flowing?!0:this._hasFlowed?!1:null}set readableFlowing(e){e===!0?(this._flowing=!0,this._hasFlowed=!0):e===!1?(this._flowing=!1,this._hasFlowed=!0):(this._flowing=!1,this._hasFlowed=!1)}_setReadableFlowing(e){this.readableFlowing=e}get readableAborted(){return this._readableOverride===!1?!1:(this._destroyed||!!this._errored)&&!this._endEmitted}get readableDidRead(){return this._didRead}get readableEncoding(){return this._encoding}get readableObjectMode(){return this._objectMode}get readableHighWaterMark(){return this._highWaterMark}get readableBuffer(){return this._buf.toArray()}_releaseReader(){if(this._reader){let e=this._reader;this._reader=null;try{e.releaseLock()}catch{}}}async _startReading(){if(!(this._reading||this._destroyed||!this._flowing)){this._reading=!0;try{for(this._reader||=this._stream.getReader();this._flowing&&!this._destroyed&&!this._pushMode;){let{done:e,value:t}=await this._reader.read();if(this._pushMode){this._releaseReader();break}if(e){this._ended=!0,this._buf.length===0&&K(()=>this._emitEndOnce()),this._releaseReader();break}if(t!==void 0){let e=this._buf.length===0;for(this._buf.push(t),e&&K(()=>this.emit(`readable`));this._buf.length>0&&this._flowing;){let e=this._buf.shift();this._didRead=!0,this.emit(`data`,this._applyEncoding(e))}if(!this._flowing)break}}}catch(e){this.emit(`error`,e),this._releaseReader()}finally{this._reading=!1}}}async*[Symbol.asyncIterator](){this._asyncIterState||=this._initAsyncIterState();let e=this._asyncIterState;e.activeCount++;try{for(;;){if(e.streamError)throw e.streamError;if(e.dataQueueIndex<e.dataQueue.length){let t=e.dataQueue[e.dataQueueIndex];e.dataQueue[e.dataQueueIndex]=void 0,e.dataQueueIndex++,e.queuedSize-=this._chunkSizeForBackpressure(t),e.dataQueueIndex>=1024&&e.dataQueueIndex*2>=e.dataQueue.length&&(e.dataQueue.splice(0,e.dataQueueIndex),e.dataQueueIndex=0),this._maybeResumeIterState(e),yield t;continue}if(e.done)break;let t=await new Promise((t,n)=>{e.resolverQueue.push({resolve:t,reject:n})});if(t===null)break;yield t}}finally{e.activeCount--,e.activeCount===0&&this._teardownAsyncIterState(),this._destroyed||this.destroy()}}_chunkSizeForBackpressure(e){return this._objectMode?1:e instanceof Uint8Array?e.byteLength:typeof e==`string`?e.length:1}_maybeResumeIterState(e){e.pausedByIterator&&e.queuedSize<this._highWaterMark&&!e.done&&!this._destroyed&&(e.pausedByIterator=!1,this.resume())}_initAsyncIterState(){let e=this._highWaterMark,t={dataQueue:[],dataQueueIndex:0,queuedSize:0,resolverQueue:[],done:!1,streamError:null,activeCount:0,listenersAttached:!1,pausedByIterator:!1,dataHandler:null,doneHandler:null,errorHandler:null};for(t.dataHandler=n=>{if(t.resolverQueue.length>0){let{resolve:e}=t.resolverQueue.shift();e(n);return}t.dataQueue.push(n),t.queuedSize+=this._chunkSizeForBackpressure(n),!t.pausedByIterator&&t.queuedSize>=e&&(t.pausedByIterator=!0,this.pause())},t.doneHandler=()=>{t.done=!0;for(let{resolve:e}of t.resolverQueue)e(null);t.resolverQueue.length=0},t.errorHandler=e=>{t.done=!0,t.streamError=e;for(let{reject:n}of t.resolverQueue)n(e);t.resolverQueue.length=0};this._buf.length>0;){let e=this._applyEncoding(this._buf.shift());t.dataQueue.push(e),t.queuedSize+=this._chunkSizeForBackpressure(e)}if(this._ended){let e=this._flushDecoder();e&&(t.dataQueue.push(e),t.queuedSize+=this._chunkSizeForBackpressure(e)),t.done=!0}else this.on(`data`,t.dataHandler),this.on(`end`,t.doneHandler),this.on(`error`,t.errorHandler),this.on(`close`,t.doneHandler),t.listenersAttached=!0,this.resume();return t}_teardownAsyncIterState(){let e=this._asyncIterState;e&&(e.listenersAttached&&(this.off(`data`,e.dataHandler),this.off(`end`,e.doneHandler),this.off(`error`,e.errorHandler),this.off(`close`,e.doneHandler)),this._asyncIterState=null)}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this._endEmitted?t():n(Error(`Premature close`))};this._closed?r():this.once(`close`,r)})}iterator(e){if(e?.destroyOnReturn??!0)return this[Symbol.asyncIterator]();let t=this,n=null,r=null,i=!1,a=null,o=()=>{if(!n)return;let e=t.read();if(e!==null){let t=n;n=null,r=null,t({done:!1,value:e})}},s=()=>{o()},c=()=>{if(i=!0,n){let e=n;n=null,r=null,e({done:!0,value:void 0})}},l=e=>{if(i=!0,a=e,r){let t=r;n=null,r=null,t(e)}};t.on(`readable`,s),t.on(`end`,c),t.on(`error`,l);let u=()=>{t.off(`readable`,s),t.off(`end`,c),t.off(`error`,l)};return{next:async()=>{if(a)throw a;let e=t.read();return e===null?i?(u(),{done:!0,value:void 0}):new Promise((e,t)=>{n=e,r=t,o()}):{done:!1,value:e}},return:async e=>(u(),{done:!0,value:e}),throw:async e=>(u(),t.destroy(e),{done:!0,value:void 0}),[Symbol.asyncIterator](){return this}}}map(t,n){let i=n?.signal;Lf(i);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0});return Hf(c,(async function*(e){try{yield*Bf(e,e=>t(e,{signal:s}),a,i)}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{c.destroy(r())},{once:!0}),c}filter(t,n){let i=n?.signal;Lf(i);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0}),l=Symbol(`skip`);return Hf(c,(async function*(e){try{if(a<=1)for await(let n of e)J(i),await t(n,{signal:s})&&(yield n);else for await(let n of Bf(e,async e=>await t(e,{signal:s})?e:l,a,i))n!==l&&(yield n)}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{c.destroy(r())},{once:!0}),c}async forEach(e,t){let n=t?.signal;Lf(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1)for await(let t of this)J(n),await e(t,{signal:a});else for await(let t of Bf(this,async t=>{await e(t,{signal:a})},r,n));}finally{i.abort()}}async toArray(e){let t=e?.signal;Lf(t);let n=[];for await(let e of this)J(t),n.push(e);return n}async some(e,t){let n=t?.signal;Lf(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if(J(n),await e(t,{signal:a}))return this.destroy(),!0}else for await(let t of Bf(this,t=>e(t,{signal:a}),r,n))if(t)return this.destroy(),!0;return!1}finally{i.abort()}}async find(e,t){let n=t?.signal;Lf(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if(J(n),await e(t,{signal:a}))return this.destroy(),t}else for await(let t of Bf(this,async t=>({chunk:t,match:await e(t,{signal:a})}),r,n))if(t.match)return this.destroy(),t.chunk;return}finally{i.abort()}}async every(e,t){let n=t?.signal;Lf(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if(J(n),!await e(t,{signal:a}))return this.destroy(),!1}else for await(let t of Bf(this,t=>e(t,{signal:a}),r,n))if(!t)return this.destroy(),!1;return!0}finally{i.abort()}}flatMap(t,n){let i=n?.signal;Lf(i);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0});return Hf(c,(async function*(e){try{if(a<=1)for await(let n of e){J(i);let e=await t(n,{signal:s});if(e&&typeof e[Symbol.asyncIterator]==`function`)for await(let t of e)yield t;else if(e&&typeof e[Symbol.iterator]==`function`)for(let t of e)yield t}else for await(let n of Bf(e,async e=>{let n=await t(e,{signal:s}),r=[];if(n&&typeof n[Symbol.asyncIterator]==`function`)for await(let e of n)r.push(e);else if(n&&typeof n[Symbol.iterator]==`function`)for(let e of n)r.push(e);return r},a,i))for(let e of n)yield e}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{c.destroy(r())},{once:!0}),c}drop(t,n){let i=n?.signal;Lf(i),Rf(t,`limit`);let a=new e({objectMode:!0});return Hf(a,(async function*(e){let n=0;for await(let r of e)J(i),n>=t&&(yield r),n++})(this)),a.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{a.destroy(r())},{once:!0}),a}take(t,n){let i=n?.signal;Lf(i),Rf(t,`limit`);let a=new e({objectMode:!0});return Hf(a,(async function*(e){let n=0;for await(let r of e){if(J(i),n>=t)break;yield r,n++}})(this)),a.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{a.destroy(r())},{once:!0}),a}async reduce(e,t,n){let r=n?.signal;Lf(r);let i=new AbortController,a=i.signal,o,s=arguments.length>=2,c=!0;try{for await(let n of this){if(J(r),c&&!s){o=n,c=!1;continue}c&&=(o=t,!1),o=await e(o,n,{signal:a})}if(c&&!s)throw TypeError(`Reduce of an empty stream requires an initial value`);return c?t:o}finally{i.abort()}}asIndexedPairs(e){let t=0;return this.map(e=>[t++,e],e)}compose(t,n){if(typeof t==`function`){let n=new e({objectMode:!0});Hf(n,t(this)),n.once(`close`,()=>{this.destroyed||this.destroy()});let r=Pf();return r?r(n):n}let r=t;if(this.pipe(r),r._readable&&r._writable)return r;if(r._readable){let e=Pf();return e?e(r._readable):r._readable}let i=Pf();return i?i(r):r}};q.prototype.addListener=q.prototype.on,q.prototype._read=function(e){let t=Error(`The _read() method is not implemented`);throw t.code=`ERR_METHOD_NOT_IMPLEMENTED`,t};function Lf(e){if(e!==void 0&&!(e instanceof AbortSignal))throw TypeError(`options.signal must be an AbortSignal`)}function J(e){if(e?.aborted)throw r(e.reason)}function Rf(e,t){if(typeof e!=`number`||Number.isNaN(e)||e<0||Math.floor(e)!==e)throw RangeError(`The value of "${t}" must be a non-negative integer. Received ${e}`)}let zf=Symbol(`EOF`);async function*Bf(e,t,n,r){if(n<=1){for await(let n of e)J(r),yield await t(n);return}let i=[],a=null,o=!1,s=e[Symbol.asyncIterator]();async function c(){let e=await s.next();return e.done?(o=!0,zf):(J(r),t(e.value))}function l(){i.push(c().catch(e=>{throw a=e,e}))}try{for(;i.length<n&&!o&&!a;)J(r),l();for(;i.length>0;){J(r);let e=await i.shift();if(a)throw a;e!==zf&&(yield e,!o&&!a&&l())}}finally{o||await s.return?.()}}function Vf(e){return e&&typeof e[Symbol.asyncIterator]==`function`?e:(async function*(){for(let t of e)yield t})()}function Hf(e,t){let n=t[Symbol.asyncIterator](),r=!1,i=!1;e._hasReadImpl=!0,e._read=function(){r||i||(r=!0,(async()=>{try{if(e.destroyed){if(!i){i=!0;let e=n.return?.();e&&typeof e.then==`function`&&e.catch(()=>{})}return}let{value:t,done:r}=await n.next();if(r){i=!0,e.push(null);return}e.push(t)}catch(t){e.destroy(t)}finally{r=!1}})())},e._pushMode=!0}function Uf(e,t,n){return{chunk:typeof e==`function`?void 0:e,encoding:typeof t==`string`?t:void 0,cb:typeof e==`function`?e:typeof t==`function`?t:n}}function Wf(e){return en(this,e??`utf-8`)}var Y=class e extends W{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.write==`function`&&typeof t.end==`function`&&typeof t.on==`function`&&`writableFinished`in t}constructor(e){if(super(),this._stream=null,this._writer=null,this._ended=!1,this._finished=!1,this._syncFinish=!1,this._destroyed=!1,this._errored=null,this._errorEmitted=!1,this._closed=!1,this._writableLength=0,this._needDrain=!1,this._corked=0,this._corkedChunks=[],this._defaultEncoding=`utf8`,this._ownsStream=!1,this._directWrite=!1,this._writeQueue=[],this._writing=!1,this._pendingEnd=null,this._constructed=!0,this._resolvedWritev=null,this.__excelts_stream=!0,this._objectMode=e?.objectMode??!1,this._highWaterMark=e?.highWaterMark??bf(this._objectMode),this._autoDestroy=e?.autoDestroy??!0,this._emitClose=e?.emitClose??!0,this._decodeStrings=e?.decodeStrings??!0,this._defaultEncoding=e?.defaultEncoding??`utf8`,e?.stream)this._stream=e.stream,this._ownsStream=!1,this._directWrite=!1;else{if(e?.write&&(this._writeFunc=e.write.bind(this)),e?.final)this._finalFunc=e.final.bind(this);else{let e=this._getSubclassFinal();e&&(this._finalFunc=e)}if(e?.destroy&&(this._destroy=e.destroy.bind(this)),e?.construct&&(this._constructFunc=e.construct.bind(this)),e?.writev&&(this._writevFunc=e.writev.bind(this)),this._ownsStream=!0,this._writeFunc)this._directWrite=!0,this._stream=null;else{let t=e?.construct||this._hasSubclassConstruct(),n=this._getSubclassWrite();t&&n?(this._writeFunc=n,this._directWrite=!0,this._stream=null):(this._directWrite=!1,this._stream=new WritableStream({write:async e=>{this._write&&await new Promise((t,n)=>{this._write(e,`utf8`,e=>{e?n(e):t()})})},close:async()=>{if(this._finalFunc){let e=await new Promise(e=>{this._finalFunc(t=>{e(t??null)})});if(e){this._errored=e,this._errorEmitted=!0,this.emit(`error`,e),this._autoDestroy&&this.destroy(e);return}}this._finished=!0,this.emit(`finish`),this._autoDestroy&&this.destroy()},abort:e=>{this.emit(`error`,e)}}))}}e?.signal&&this._setupAbortSignal(e.signal),this._resolvedWritev=this._writevFunc??this._getWritevHook(),this._maybeConstruct()}_maybeConstruct(){(this._constructFunc||this._hasSubclassConstruct())&&(this._constructed=!1,K(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){this.destroy(e);return}if(this._constructed=!0,this._directWrite&&this._writeQueue.length>0&&!this._writing)this._writing=!0,this._drainWriteQueue();else if(this._pendingEnd&&!this._writing){let{cb:e}=this._pendingEnd;this._pendingEnd=null,this._doFinish(e)}})}))}_hasSubclassConstruct(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}_getSubclassWrite(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_write`))return t._write.bind(this);t=Object.getPrototypeOf(t)}return null}_getSubclassFinal(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_final`))return t._final.bind(this);t=Object.getPrototypeOf(t)}return null}_getWritevHook(){let t=Object.getPrototypeOf(this);return t._writev&&t._writev!==e.prototype._writev?t._writev.bind(this):null}_setupAbortSignal(e){if(e.aborted){this.destroy(r(e.reason));return}let t=()=>{i(),this.destroy(r(e.reason))},n=()=>{i()},i=()=>{e.removeEventListener(`abort`,t),this.off(`close`,n),this.off(`finish`,n),this.off(`error`,n)};e.addEventListener(`abort`,t,{once:!0}),this.on(`close`,n),this.on(`finish`,n),this.on(`error`,n)}setDefaultEncoding(e){return wf(``,e),this._defaultEncoding=e,this}cork(){this._corked++}uncork(){if(this._corked>0&&this._corked--,this._corked===0){let e=this._corkedChunks;if(this._corkedChunks=[],e.length===0)return;for(let{chunk:t}of e)this._writableLength-=this._getChunkSize(t);let t=this._resolvedWritev;if(t&&e.length>1){let n=e.map(({chunk:e,encoding:t})=>({chunk:e,encoding:t})),r=n.reduce((e,{chunk:t})=>e+this._getChunkSize(t),0);this._writableLength+=r,this._writing=!0;try{t(n,t=>{if(this._writableLength-=r,this._writing=!1,t){this._destroyed||(this._errored=t,this.emit(`error`,t),this._autoDestroy&&this.destroy(t));for(let{callback:n}of e)n?.(t);return}this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,K(()=>this.emit(`drain`)));for(let{callback:t}of e)t?.(null);this._drainWriteQueue()})}catch(t){this._writableLength-=r,this._writing=!1;let n=t instanceof Error?t:Error(String(t));this._destroyed||(this._errored=n,this.emit(`error`,n),this._autoDestroy&&this.destroy(n));for(let{callback:t}of e)t?.(n)}}else for(let{chunk:t,encoding:n,callback:r}of e)this._doWrite(t,n,r)}}write(e,t,n){if(e===null){let e=TypeError(`May not write null values to stream`);throw e.code=`ERR_STREAM_NULL_VALUES`,e}if(this._destroyed||this._ended){let e=this._destroyed&&!this._ended,r=Error(e?`Cannot call write after a stream was destroyed`:`write after end`);r.code=e?`ERR_STREAM_DESTROYED`:`ERR_STREAM_WRITE_AFTER_END`;let i=typeof t==`function`?t:n;return this._errored||=r,i&&K(()=>i(r)),!this._destroyed&&!this._errorEmitted&&(this._errorEmitted=!0,K(()=>this.emit(`error`,r))),!1}let r=typeof t==`string`?t:this._defaultEncoding,i=typeof t==`function`?t:n;if(this._corked>0){let t=this._normalizeWriteChunk(e,r);this._corkedChunks.push({chunk:t.chunk,encoding:t.encoding,callback:i});let n=this._getChunkSize(t.chunk,t.encoding);this._writableLength+=n;let a=this._writableLength<this._highWaterMark;return a||(this._needDrain=!0),a}let a=this._normalizeWriteChunk(e,r),o=this._doWrite(a.chunk,a.encoding,i);return o||(this._needDrain=!0),o}_doWrite(e,t,n){let r=this._getChunkSize(e,t);return this._writableLength+=r,this._directWrite?this._writing||!this._constructed?this._writeQueue.push({chunk:e,chunkSize:r,encoding:t,callback:n}):(this._writing=!0,this._callWriteFunc(e,r,t,n)):this._getWriter().write(e).then(()=>{this._writableLength-=r,this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,K(()=>this.emit(`drain`))),n?.(null)}).catch(e=>{this._writableLength-=r,this._destroyed||(this._errored=e,this._errorEmitted=!0,this.emit(`error`,e),this._autoDestroy&&this.destroy(e)),n?.(e)}),this._writableLength<this._highWaterMark}_callWriteFunc(e,t,n,r){try{let i=this._objectMode?void 0:n,a=!1,o=!0;this._writeFunc(e,i,e=>{if(a){let e=Error(`Callback called multiple times`);e.code=`ERR_MULTIPLE_CALLBACK`,this.destroy(e);return}if(a=!0,e){if(this._writableLength-=t,this._destroyed?r?.(e):(this._errored=e,this._errorEmitted=!0,o?K(()=>{r?.(e),this.emit(`error`,e),this._autoDestroy&&this.destroy(e)}):(r?.(e),this.emit(`error`,e),this._autoDestroy&&this.destroy(e))),this._writing=!1,this._flushWriteQueueOnError(e),this._pendingEnd){let{cb:t}=this._pendingEnd;this._pendingEnd=null,t?.(e)}return}this._writableLength-=t,this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,K(()=>this.emit(`drain`))),r?.(null),this._drainWriteQueue()}),o=!1}catch(e){this._writableLength-=t;let n=e instanceof Error?e:Error(String(e));if(this._destroyed||(this._errored=n,this.emit(`error`,n),this._autoDestroy&&this.destroy(n)),r?.(n),this._writing=!1,this._flushWriteQueueOnError(n),this._pendingEnd){let{cb:e}=this._pendingEnd;this._pendingEnd=null,e?.(n)}}}_drainWriteQueue(){if(this._writeQueue.length===0){if(this._writing=!1,this._pendingEnd){let{cb:e}=this._pendingEnd;this._pendingEnd=null,this._doFinish(e)}return}let e=this._resolvedWritev;if(e&&this._writeQueue.length>1){let t=this._writeQueue;this._writeQueue=[];let n=0,r=Array(t.length);for(let e=0;e<t.length;e++){let i=t[e];r[e]={chunk:i.chunk,encoding:i.encoding},n+=i.chunkSize}try{e(r,e=>{if(e){this._writableLength-=n,this._destroyed||(this._errored=e,this._errorEmitted=!0,this.emit(`error`,e));for(let n of t)n.callback?.(e);this._writing=!1,this._flushWriteQueueOnError(e);return}this._writableLength-=n,this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,K(()=>this.emit(`drain`)));for(let e of t)e.callback?.(null);this._drainWriteQueue()})}catch(e){this._writableLength-=n,this._writing=!1;let r=e instanceof Error?e:Error(String(e));this._destroyed||(this._errored=r,this.emit(`error`,r));for(let e of t)e.callback?.(r)}}else{let e=this._writeQueue.shift();this._callWriteFunc(e.chunk,e.chunkSize,e.encoding,e.callback)}}_flushWriteQueueOnError(e){let t=this._writeQueue;this._writeQueue=[];for(let n of t)this._writableLength-=n.chunkSize,n.callback?.(e)}_doFinish(e){if(this._finalFunc)this._finalFunc(t=>{if(t){this._errorEmitted=!0,this.emit(`error`,t),e&&(this._pendingEnd={cb:e}),this._autoDestroy&&!this._destroyed&&this.destroy(t);return}let n=()=>{if(this._destroyed){e?.();return}this._finished=!0,this.emit(`prefinish`),e?.(),this.emit(`finish`),this._autoDestroy&&this.destroy()};this._syncFinish?(this._syncFinish=!1,n()):K(n)});else{let t=()=>{if(this._destroyed){e?.();return}this._finished=!0,this.emit(`prefinish`),e?.(),this.emit(`finish`),this._autoDestroy&&this.destroy()};Mf()?t():K(t)}}_getChunkSize(e,t){return this._objectMode?1:e instanceof Uint8Array?e.byteLength:typeof e==`string`?Kf(e,t):0}_normalizeWriteChunk(e,t){if(this._objectMode||typeof e!=`string`||!this._decodeStrings)return{chunk:e,encoding:t};let n=wf(e,t);return n.toString=Wf,{chunk:n,encoding:`buffer`}}end(e,t,n){if(this._ended){let{chunk:r,encoding:i,cb:a}=Uf(e,t,n);if(r!==void 0)return this.write(r,i??this._defaultEncoding,e=>{a?.(e??null)}),this;if(this._finished&&a){let e=Error(`Cannot call end after a stream was finished`);e.code=`ERR_STREAM_ALREADY_FINISHED`,K(()=>a(e))}else K(()=>a?.(null));return this}this._ended=!0,this._writableOverride=void 0;let{chunk:r,encoding:i,cb:a}=Uf(e,t,n);if(this._corked>0&&(this._corked=1,this.uncork()),this._directWrite){if(r!==void 0){let e=this._normalizeWriteChunk(r,i??this._defaultEncoding);this._doWrite(e.chunk,e.encoding)}if(this._errored){let e=this._errored;return K(()=>a?.(e)),this}return this._writing||this._writeQueue.length>0?this._pendingEnd={cb:a}:this._doFinish(a),this}return(async()=>{try{let e=this._getWriter();if(r!==void 0){let{chunk:t}=this._normalizeWriteChunk(r,i??this._defaultEncoding);await e.write(t)}if(await e.close(),this._writer===e){this._writer=null;try{e.releaseLock()}catch{}}this._ownsStream||(this._finished=!0,this.emit(`finish`),this._autoDestroy&&this.destroy()),a&&a()}catch(e){this.emit(`error`,e)}})(),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._writableOverride=void 0,e&&!this._errored&&(this._errored=e),this._writeQueue.length>0&&this._flushWriteQueueOnError(e??Error(`Cannot call write after a stream was destroyed`)),this._corkedChunks.length>0){let t=e??Error(`Cannot call write after a stream was destroyed`);for(let e of this._corkedChunks)e.callback?.(t);this._corkedChunks=[]}let t=this._pendingEnd?.cb;if(this._pendingEnd=null,this._writing=!1,this._writer){let t=this._writer;this._writer=null,t.abort(e).catch(()=>{}).finally(()=>{try{t.releaseLock()}catch{}})}let n=e=>{let n=e||null;n&&(this._errored=n),this._closed=!0;let r=()=>{n&&!this._errorEmitted&&(this._errorEmitted=!0,this.emit(`error`,n)),this._emitClose&&this.emit(`close`),t?.(n)};Mf()&&!this._hasDestroyHook()&&this._finished?r():K(r)};if(this._hasDestroyHook())try{this._destroy(e??null,n)}catch(e){n(e instanceof Error?e:Error(String(e)))}else n(e);return this}_destroy(e,t){t(e)}_undestroy(){this._destroyed=!1,this._closed=!1,this._errored=null,this._errorEmitted=!1}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this._finished?t():n(Error(`Premature close`))};this._closed?r():this.once(`close`,r)})}get _webStream(){return this._stream||=new WritableStream({write:e=>new Promise((t,n)=>{let r=this._objectMode?void 0:this._defaultEncoding;this._writeFunc(e,r,e=>{e?n(e):t()})}),close:async()=>{this._finalFunc&&await new Promise((e,t)=>{this._finalFunc(n=>{n?t(n):e()})})},abort:e=>{this.emit(`error`,e)}}),this._stream}get writable(){return this._writableOverride===void 0?!this._destroyed&&!this._ended:this._writableOverride}set writable(e){this._writableOverride=e}get writableEnded(){return this._ended}get writableFinished(){return this._finished}get writableLength(){return this._writableLength}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e}get errored(){return this._errored}get closed(){return this._closed}get writableNeedDrain(){return this._needDrain}get writableCorked(){return this._corked}get writableAborted(){return this._writableOverride===!1?!1:(this._destroyed||!!this._errored)&&!this._finished}get writableObjectMode(){return this._objectMode}get writableHighWaterMark(){return this._highWaterMark}get writableBuffer(){let e=this._corkedChunks.map(e=>e.chunk);for(let t of this._writeQueue)e.push(t.chunk);return e}pipe(){let e=new Sf(`pipe`,`not readable`);e.code=`ERR_STREAM_CANNOT_PIPE`,K(()=>this.emit(`error`,e))}_getWriter(){return this._writer||=this._webStream.getWriter(),this._writer}static isDisturbed(e){return e&&e._readable instanceof q?q.isDisturbed(e._readable):q.isDisturbed(e)}static fromWeb(t,n){return new e({...n,stream:t})}static toWeb(e){return e._webStream}};Y.prototype._writev=null,Y.prototype._write=function(e,t,n){let r=Error(`The _write() method is not implemented`);throw r.code=`ERR_METHOD_NOT_IMPLEMENTED`,r};function Gf(e){return e instanceof Y?e:e?.getWriter?new Y({stream:e}):e}function Kf(e,t){let n=(t??`utf8`).toLowerCase();return n===`ascii`||n===`latin1`||n===`binary`?e.length:n===`utf16le`||n===`utf-16le`||n===`ucs2`?e.length*2:qf(e)}function qf(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<=127?t+=1:r<=2047?t+=2:r>=55296&&r<=56319?(t+=4,n++):t+=3}return t}var Jf=class e extends W{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.read==`function`&&typeof t.pipe==`function`&&typeof t.write==`function`&&typeof t.end==`function`&&typeof t.on==`function`&&`readableFlowing`in t&&`writableFinished`in t}static isDisturbed(e){return e&&e._readable instanceof q?q.isDisturbed(e._readable):q.isDisturbed(e)}static from(t){if(t instanceof e)return t;let n=(e,t)=>{let n=new Y({objectMode:t.readableObjectMode,write(e,n,r){t.push(e),r()},final(e){t.push(null),e()}}),r=Of(e,`error`,e=>{t.emit(`error`,e)});Of(e,`end`,r,{once:!0}),Of(e,`close`,r,{once:!0}),Of(n,`finish`,r,{once:!0}),e.pipe(n)};if(t instanceof Promise){let r=new e({objectMode:!0});return t.then(t=>{n(e.from(t),r)}).catch(e=>{r.destroy(e instanceof Error?e:Error(String(e)))}),r}if(typeof t==`string`){let r=q.from([t]),i=new e({objectMode:!0});return n(r,i),i}if(typeof Blob<`u`&&t instanceof Blob){let r=q.fromWeb(t.stream()),i=new e;return n(r,i),i}if(typeof t==`object`&&t&&`readable`in t&&`writable`in t){let r=t,i=new e({readableObjectMode:r.readable?.readableObjectMode,writableObjectMode:r.writable?.writableObjectMode,write:r.writable?(e,t,n)=>{r.writable.write(e,t,n)}:void 0,final:r.writable?e=>{r.writable.end(e)}:void 0,destroy:(e,t)=>{r.readable&&!r.readable.destroyed&&r.readable.destroy(e??void 0),r.writable&&!r.writable.destroyed&&r.writable.destroy(e??void 0),t(e)}});return r.readable&&n(r.readable,i),i}if(typeof t==`object`&&t&&typeof t.getReader==`function`&&typeof t.cancel==`function`){let r=q.fromWeb(t),i=new e({objectMode:r.readableObjectMode});return n(r,i),i}if(typeof t==`object`&&t&&typeof t.getWriter==`function`&&typeof t.close==`function`){let n=Y.fromWeb(t);return new e({objectMode:n.writableObjectMode,write(e,t,r){n.write(e,t,r)},final(e){n.end(e)},destroy(e,t){n.destroyed||n.destroy(e??void 0),t(e)}})}if(typeof t==`object`&&t&&(Symbol.asyncIterator in t||Symbol.iterator in t)){let r=q.from(t),i=new e({objectMode:r.readableObjectMode});return n(r,i),i}if(t instanceof q){let r=new e({objectMode:t.readableObjectMode});return n(t,r),r}if(t instanceof Y)return new e({objectMode:t.writableObjectMode,write(e,n,r){t.write(e,n,r)},final(e){t.end(e)}});throw new Cf(`Duplex-compatible source`,typeof t)}static fromWeb(t,n){let r=new e(n),i=new q({stream:t.readable,objectMode:r.readableObjectMode}),a=new Y({stream:t.writable,objectMode:r.writableObjectMode});return r._sideForwardingCleanup&&=(r._sideForwardingCleanup(),null),r._readable=i,r._writable=a,r._setupSideForwarding(),r}static toWeb(e){return{readable:q.toWeb(e._readable),writable:Y.toWeb(e._writable)}}_getSubclassHook(t){let n=Object.getPrototypeOf(this);for(;n&&n!==e.prototype&&n!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(n,t)){let e=this[t];return typeof e==`function`?e.bind(this):void 0}n=Object.getPrototypeOf(n)}}constructor(e){super(),this._dataForwardingSetup=!1,this._destroyed=!1,this._errored=null,this._closed=!1,this._sideForwardingCleanup=null,this._constructed=!0,this.__excelts_stream=!0,this.allowHalfOpen=e?.allowHalfOpen??!0,this._emitClose=e?.emitClose??!0,this._autoDestroy=e?.autoDestroy??!0;let t=e?.objectMode??!1,n=e?.readableObjectMode??t,r=e?.writableObjectMode??t,i=e!=null&&Object.prototype.hasOwnProperty.call(e,`highWaterMark`),a=i?e.highWaterMark:e?.readableHighWaterMark,o=i?e.highWaterMark:e?.writableHighWaterMark;e?.destroy&&(this._destroy=e.destroy.bind(this)),e?.construct&&(this._constructFunc=e.construct.bind(this));let s,c,l=this._hasConstructHook(),u=e?.read?e.read.bind(this):this._getSubclassHook(`_read`),d=e?.write?e.write.bind(this):this._getSubclassHook(`_write`),f=e?.writev?e.writev.bind(this):this._getSubclassHook(`_writev`),p=e?.final?e.final.bind(this):this._getSubclassHook(`_final`);this._readable=new q({highWaterMark:a,objectMode:n,read:u,encoding:e?.encoding,emitClose:!1,autoDestroy:!1,construct:l?e=>{s=e}:void 0}),this._writable=new Y({highWaterMark:o,objectMode:r,write:d,writev:f,final:p,decodeStrings:e?.decodeStrings,defaultEncoding:e?.defaultEncoding,emitClose:!1,autoDestroy:!1,construct:l?e=>{c=e}:void 0});let m=()=>{};this._readable.on(`error`,m),this._writable.on(`error`,m),this._setupSideForwarding(),e?.signal&&this._setupAbortSignal(e.signal),l&&(this._constructed=!1,K(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){s?.(e),c?.(e),this.destroy(e);return}this._constructed=!0,s?.(),c?.()})}))}_setupAbortSignal(e){if(e.aborted){this.destroy(r(e.reason));return}let t=()=>{this.destroy(r(e.reason))};e.addEventListener(`abort`,t,{once:!0}),this.once(`close`,()=>{e.removeEventListener(`abort`,t)})}_setupSideForwarding(){this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null),this._readable._pipes?.setSource(this);let e=kf(),t=!1,n=e=>{t||(t=!0,this.emit(`error`,e))},r=!1,i=!1,a=()=>{this._autoDestroy&&r&&i&&!this._destroyed&&this.destroy()};e.once(this._readable,`end`,()=>{this.emit(`end`),r=!0,this.allowHalfOpen||this._writable.end(),a()}),e.add(this._readable,`error`,n);let o=()=>{this.emit(`readable`)};W.prototype.on.call(this._readable,`readable`,o),e.add(this._readable,`pause`,()=>this.emit(`pause`)),e.add(this._readable,`resume`,()=>this.emit(`resume`)),e.add(this._writable,`error`,n),e.once(this._writable,`prefinish`,()=>this.emit(`prefinish`)),e.once(this._writable,`finish`,()=>{this.emit(`finish`),i=!0,a()}),e.add(this._writable,`drain`,()=>this.emit(`drain`)),e.add(this._writable,`pipe`,e=>this.emit(`pipe`,e)),e.add(this._writable,`unpipe`,e=>this.emit(`unpipe`,e)),e.once(this._writable,`finish`,()=>{!this.allowHalfOpen&&!this._readable.readableEnded&&this._readable.push(null)});let s=this._readable.destroy.bind(this._readable);this._readable.destroy=e=>{let t=s(e);return this._destroyed||this.destroy(e),t},this._sideForwardingCleanup=()=>{e.cleanup(),this._readable.off(`readable`,o),this._readable.destroy=s}}on(e,t){return super.on(e,t),e===`data`&&!this._dataForwardingSetup?(this._dataForwardingSetup=!0,this._readable.on(`data`,e=>this.emit(`data`,e))):e===`readable`&&this._readable._setReadableFlowing(!1),this}push(e,t){return this._readable.push(e,t)}unshift(e,t){this._readable.unshift(e,t)}read(e){return this._readable.read(e)}write(e,t,n){let r=typeof t==`string`?t:void 0,i=typeof t==`function`?t:n;return r===void 0?this._writable.write(e,i):this._writable.write(e,r,i)}end(e,t,n){let{chunk:r,encoding:i,cb:a}=Uf(e,t,n);if(this._writable.writableEnded){if(r!==void 0)return this.write(r,i,e=>{a?.(e??null)}),this;if(this.writableFinished&&a){let e=Error(`Cannot call end after a stream was finished`);e.code=`ERR_STREAM_ALREADY_FINISHED`,K(()=>a(e))}else a&&K(()=>a(null));return this}if(a){let e=!1,t=()=>{e||(e=!0,a())};this.once(`finish`,t),this.once(`close`,t)}if(r!==void 0){let e=e=>{e&&!this.destroyed&&this.destroy(e)};i===void 0?this._writable.write(r,e):this._writable.write(r,i,e)}return this._writable.end(),this}cork(){this._writable.cork()}uncork(){this._writable.uncork()}setEncoding(e){return this._readable.setEncoding(e),this}setDefaultEncoding(e){return this._writable.setDefaultEncoding(e),this}pipe(e,t){return this._readable.pipe(e,t),e}unpipe(e){return this._readable.unpipe(e),this}pause(){return this._readable.pause(),this}resume(){return this._readable.resume(),this}isPaused(){return this._readable.isPaused()}destroy(e){if(this._destroyed)return this;this._destroyed=!0,this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null);let t=e=>{let t=e||null;t&&(this._errored=t),this._closed=!0,this._readable.destroy(),this._writable.destroy();let n=()=>{t&&this.emit(`error`,t),this._emitClose&&this.emit(`close`)};Mf()&&!this._hasDestroyHook()&&this.readableEnded&&this.writableFinished?n():K(n)};if(this._hasDestroyHook())try{this._destroy(e??null,t)}catch(e){t(e instanceof Error?e:Error(String(e)))}else t(e);return this}_destroy(e,t){t(e)}_undestroy(){this._readable._undestroy(),this._writable._undestroy(),this._destroyed=!1,this._closed=!1,this._errored=null,this._setupSideForwarding()}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}_hasConstructHook(){if(this._constructFunc)return!0;let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this.writableFinished?t():n(Error(`Premature close`))};this._closed?r():this.once(`close`,r)})}get readable(){return this._readable.readable}set readable(e){this._readable.readable=e}get writable(){return this._writable.writable}set writable(e){this._writable.writable=e}get readableEnded(){return this._readable.readableEnded}get writableEnded(){return this._writable.writableEnded}get writableFinished(){return this._writable.writableFinished}get readableLength(){return this._readable.readableLength}get writableLength(){return this._writable.writableLength}get readableHighWaterMark(){return this._readable.readableHighWaterMark}get writableHighWaterMark(){return this._writable.writableHighWaterMark}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e,this._readable.destroyed=e,this._writable.destroyed=e}get writableCorked(){return this._writable.writableCorked}get writableNeedDrain(){return this._writable.writableNeedDrain}get readableObjectMode(){return this._readable.readableObjectMode}get writableObjectMode(){return this._writable.writableObjectMode}get readableFlowing(){return this._readable.readableFlowing}get readableAborted(){return this._readable.readableAborted}get readableDidRead(){return this._readable.readableDidRead}get readableEncoding(){return this._readable.readableEncoding}get errored(){return this._errored??this._readable.errored??this._writable.errored}get closed(){return this._closed}get readableBuffer(){return this._readable.readableBuffer}get writableBuffer(){return this._writable.writableBuffer}wrap(e){return this._readable.wrap(e),this}iterator(e){return e?.destroyOnReturn===!1?this._readable.iterator(e):this._wrapAsyncIterator(this._readable[Symbol.asyncIterator]())}[Symbol.asyncIterator](){return this._wrapAsyncIterator(this._readable[Symbol.asyncIterator]())}_wrapAsyncIterator(e){let t=this;return{next(){return e.next()},async return(){let n=await e.return?.();return t.destroyed||t.destroy(),n??{value:void 0,done:!0}},async throw(n){let r=await e.throw?.(n);return t.destroyed||t.destroy(n instanceof Error?n:void 0),r??{value:void 0,done:!0}},[Symbol.asyncIterator](){return this}}}map(e,t){return this._readable.map(e,t)}filter(e,t){return this._readable.filter(e,t)}async forEach(e,t){return this._readable.forEach(e,t)}async toArray(e){return this._readable.toArray(e)}async some(e,t){return this._readable.some(e,t)}async find(e,t){return this._readable.find(e,t)}async every(e,t){return this._readable.every(e,t)}flatMap(e,t){return this._readable.flatMap(e,t)}drop(e,t){return this._readable.drop(e,t)}take(e,t){return this._readable.take(e,t)}async reduce(e,t,n){return arguments.length>=2?this._readable.reduce(e,t,n):this._readable.reduce(e)}compose(e,t){return this._readable.compose(e,t)}};Jf.prototype.addListener=Jf.prototype.on,Jf.prototype._writev=null;var Yf=class e extends W{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.read==`function`&&typeof t.pipe==`function`&&typeof t.write==`function`&&typeof t.end==`function`&&typeof t.on==`function`&&typeof t._transform==`function`&&`readableFlowing`in t&&`writableFinished`in t}push(e,t){return this._readable.push(e,t)}constructor(t){super(),this._destroyed=!1,this._closed=!1,this._ended=!1,this._errored=null,this._dataForwardingSetup=!1,this._syncFinal=!1,this._endCalledFromSync=!1,this._endGeneration=0,this._endCallback=null,this._webStream=null,this._sideForwardingCleanup=null,this._afterTransformCallback=null,this.__excelts_stream=!0;let n=t?.objectMode??!1,r=t?.readableObjectMode??n,i=t?.writableObjectMode??n;this.allowHalfOpen=t?.allowHalfOpen??!0,this._emitClose=t?.emitClose??!0,this._autoDestroy=t?.autoDestroy??!0,this._transformImpl=t?.transform,this._flushImpl=t?.flush;let a=t!=null&&Object.prototype.hasOwnProperty.call(t,`highWaterMark`),o=a?t.highWaterMark:t?.readableHighWaterMark,s=a?t.highWaterMark:t?.writableHighWaterMark;t?.destroy&&(this._destroy=t.destroy.bind(this)),t?.construct&&(this._constructFunc=t.construct.bind(this));let c,l,u=this._hasConstructHook();this._readable=new q({highWaterMark:o,objectMode:r,encoding:t?.encoding,emitClose:!1,autoDestroy:!1,construct:u?e=>{c=e}:void 0}),this._readable._hasReadImpl=!0,this._readable._read=()=>{if(this._afterTransformCallback){let e=this._afterTransformCallback;this._afterTransformCallback=null,e(null)}},this._readable._pipes.setSource(this);let d=t?.write?(e,n,r)=>{t.write.call(this,e,n,r)}:(e,t,n)=>{let r=this._readable.readableLength,i=()=>{let e=this._readable.readableLength,t=this._readable.readableHighWaterMark;this._writable.writableEnded||r===e||e<t?n(null):this._afterTransformCallback=n},a=this._runTransformSync(e,t);a===void 0?i():a.then(()=>i(),e=>n(e))},f=t?.final?e=>{t.final.call(this,t=>{if(t){e(t);return}this._readable.push(null),e(null)})}:t=>{typeof this._final==`function`&&this._final!==e.prototype._final?this._final.call(this,e=>{if(e){t(e);return}t(null)}):this._hasSubclassFlush()||this._flushImpl?this._runFlush().then(()=>{this._readable.push(null),t(null)}).catch(e=>t(e)):this._syncFinal?(this._readable.push(null),this._readable._emitEndOnce(),t(null)):K(()=>{this._readable.push(null),t(null)})};this._writable=new Y({highWaterMark:s,objectMode:i,emitClose:!1,autoDestroy:!1,write:d,writev:t?.writev?.bind(this),final:f,decodeStrings:t?.decodeStrings,defaultEncoding:t?.defaultEncoding,construct:u?e=>{l=e}:void 0});let p=()=>{};this._readable.on(`error`,p),this._writable.on(`error`,p),this._setupSideForwarding(),t?.signal&&this._setupAbortSignal(t.signal),u&&K(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){c?.(e),l?.(e),this.destroy(e);return}c?.(),l?.()})})}_setupAbortSignal(e){if(e.aborted){this.destroy(r(e.reason));return}let t=()=>{this.destroy(r(e.reason))};e.addEventListener(`abort`,t,{once:!0}),this.once(`close`,()=>{e.removeEventListener(`abort`,t)})}_setupSideForwarding(){this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null),this._readable._pipes?.setSource(this);let e=kf(),t=!1,n=!1,r=()=>{this._autoDestroy&&t&&n&&!this._destroyed&&this.destroy()};e.once(this._readable,`end`,()=>{this.emit(`end`),t=!0,this.allowHalfOpen||this._writable.end(),r()}),e.add(this._readable,`error`,e=>this._emitErrorOnce(e));let i=()=>{this.emit(`readable`)};W.prototype.on.call(this._readable,`readable`,i),e.add(this._readable,`pause`,()=>this.emit(`pause`)),e.add(this._readable,`resume`,()=>this.emit(`resume`)),e.once(this._writable,`prefinish`,()=>this.emit(`prefinish`)),e.once(this._writable,`finish`,()=>{this.emit(`finish`),n=!0,r()}),e.add(this._writable,`drain`,()=>this.emit(`drain`)),e.add(this._writable,`error`,e=>this._emitErrorOnce(e)),e.once(this._writable,`finish`,()=>{!this.allowHalfOpen&&!this._readable.readableEnded&&this._readable.push(null)}),this._sideForwardingCleanup=()=>{e.cleanup(),this._readable.off(`readable`,i)}}_scheduleEnd(){if(this._destroyed||this._errored||this._writable.writableEnded)return;let t=++this._endGeneration;K(()=>{t===this._endGeneration&&(this._destroyed||this._errored||this._writable.writableEnded||(this._endCalledFromSync&&!this._hasSubclassFlush()&&!this._flushImpl&&!(typeof this._final==`function`&&this._final!==e.prototype._final)&&this._readable._pipes._destinations.length===0&&(this._syncFinal=!0,this._writable._syncFinish=!0),this._writable.end(),this._syncFinal=!1,this._writable._syncFinish=!1))})}_emitErrorOnce(e){if(this._errored)return;let t=e instanceof Error?e:Error(String(e));this._errored=t,this._destroyed||this.destroy(t)}_hasSubclassTransform(){return this._isSubclassTransform===void 0?this._transformImpl?(this._isSubclassTransform=!1,!1):(this._isSubclassTransform=Object.getPrototypeOf(this)._transform!==e.prototype._transform,this._isSubclassTransform):this._isSubclassTransform}_hasSubclassFlush(){if(this._flushImpl)return!1;let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_flush`))return!0;t=Object.getPrototypeOf(t)}return!1}_runTransformSync(e,t){if(this._destroyed||this._errored)return;if(this._hasSubclassTransform()){let n=!0,r=!1,i=null,a,o=!1,s=null,c=null;if(this._transform(e,t,(e,t)=>{if(o){let e=Error(`Callback called multiple times`);e.code=`ERR_MULTIPLE_CALLBACK`,this.destroy(e);return}if(o=!0,n){r=!0,i=e??null,a=t;return}if(e){c?.(e);return}t!==void 0&&this.push(t),s?.()}),n=!1,r){if(i)throw i;a!==void 0&&this.push(a);return}return new Promise((e,t)=>{s=e,c=t})}let n=this._transformImpl;if(!n){let n=!0,r=!1,i=null,a,o=null,s=null;if(this._transform(e,t,(e,t)=>{if(n){r=!0,i=e??null,a=t;return}if(e){s?.(e);return}t!==void 0&&this.push(t),o?.()}),n=!1,r){if(i)throw i;a!==void 0&&this.push(a);return}return new Promise((e,t)=>{o=e,s=t})}let r=!0,i=!1,a=null,o,s=!1,c=null,l=null,u=new Promise((e,t)=>{c=e,l=t});if(n.call(this,e,t,(e,t)=>{if(s){let e=Error(`Callback called multiple times`);e.code=`ERR_MULTIPLE_CALLBACK`,this.destroy(e);return}if(s=!0,r){i=!0,a=e??null,o=t;return}if(e){l?.(e);return}t!==void 0&&this.push(t),c?.()}),r=!1,i){if(a)throw a;o!==void 0&&this.push(o);return}return u}async _runFlush(){if(this._destroyed||this._errored)return;if(this._hasSubclassFlush()){await new Promise((e,t)=>{this._flush((n,r)=>{if(n){t(n);return}r!==void 0&&this.push(r),e()})});return}let e=this._flushImpl;e&&await new Promise((t,n)=>{e.call(this,(e,r)=>{if(e){n(e);return}r!==void 0&&this.push(r),t()})})}on(e,t){return super.on(e,t),e===`data`&&!this._dataForwardingSetup?(this._dataForwardingSetup=!0,this._readable.on(`data`,e=>{this.emit(`data`,e)})):e===`readable`&&this._readable._setReadableFlowing(!1),this}write(e,t,n){let r=typeof t==`string`?t:void 0,i=typeof t==`function`?t:n;if(this._ended){let e=Error(`write after end`);return e.code=`ERR_STREAM_WRITE_AFTER_END`,K(()=>this.emit(`error`,e)),i&&K(()=>i(e)),!1}return r===void 0?this._writable.write(e,i):this._writable.write(e,r,i)}end(e,t,n){if(this._ended){let{chunk:r,encoding:i,cb:a}=Uf(e,t,n);if(r!==void 0)return this.write(r,i,e=>{a?.(e??null)}),this;if(this.writableFinished&&a){let e=Error(`Cannot call end after a stream was finished`);e.code=`ERR_STREAM_ALREADY_FINISHED`,K(()=>a(e))}else a&&K(()=>a(null));return this}let{chunk:r,encoding:i,cb:a}=Uf(e,t,n);if(a&&(this._endCallback=a,this.once(`finish`,()=>{let e=this._endCallback;e&&(this._endCallback=null,e())})),r!==void 0){let e=e=>{e&&!this._destroyed&&this.destroy(e)};i===void 0?this._writable.write(r,e):this._writable.write(r,i,e)}return this._ended=!0,this._endCalledFromSync=!Mf(),this._scheduleEnd(),this}read(e){return this._readable.read(e)}pipe(e,t){return this._readable.pipe(e,t)}unpipe(e){return this._readable.unpipe(e),this}isPaused(){return this._readable.isPaused()}resume(){return this._readable.resume(),this}pause(){return this._readable.pause(),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._endGeneration++,this._afterTransformCallback){let t=this._afterTransformCallback;this._afterTransformCallback=null,t(e??null)}this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null);let t=e=>{let t=e||null;this._readable.destroy(),this._writable.destroy();let n=this._endCallback;this._endCallback=null,this._closed=!0;let r=()=>{n&&n(),t&&this.emit(`error`,t),this._emitClose&&this.emit(`close`)};Mf()&&!this._hasDestroyHook()&&this.readableEnded&&this.writableFinished?r():K(r)};if(this._hasDestroyHook())try{this._destroy(e??null,t)}catch(e){t(e instanceof Error?e:Error(String(e)))}else t(e);return this}_destroy(e,t){t(e)}_undestroy(){this._readable._undestroy(),this._writable._undestroy(),this._destroyed=!1,this._closed=!1,this._errored=null,this._setupSideForwarding()}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}_hasConstructHook(){if(this._constructFunc)return!0;let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this.writableFinished?t():n(Error(`Premature close`))};this.closed?r():this.once(`close`,r)})}_getWebStream(){if(this._webStream)return this._webStream;let e=this[Symbol.asyncIterator]();return this._webStream={readable:new ReadableStream({pull:async t=>{let{done:n,value:r}=await e.next();if(n){t.close();return}t.enqueue(r)},cancel:e=>{this.destroy(e instanceof Error?e:Error(String(e)))}}),writable:new WritableStream({write:e=>new Promise((t,n)=>{this.write(e,e=>{e?n(e):t()})}),close:()=>new Promise(e=>{this.end(()=>e())}),abort:e=>{this.destroy(e instanceof Error?e:Error(String(e)))}})},this._webStream}get readable(){return this._readable.readable}set readable(e){this._readable.readable=e}get writable(){return this._writable.writable}set writable(e){this._writable.writable=e}get readableEnded(){return this._readable.readableEnded}get writableEnded(){return this._ended||this._writable.writableEnded}get writableFinished(){return this._writable.writableFinished}get readableLength(){return this._readable.readableLength}get writableLength(){return this._writable.writableLength}get readableHighWaterMark(){return this._readable.readableHighWaterMark}get writableHighWaterMark(){return this._writable.writableHighWaterMark}get readableObjectMode(){return this._readable.readableObjectMode}get readableFlowing(){return this._readable.readableFlowing}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e,this._readable.destroyed=e,this._writable.destroyed=e}cork(){this._writable.cork()}uncork(){this._writable.uncork()}setEncoding(e){return this._readable.setEncoding(e),this}setDefaultEncoding(e){return this._writable.setDefaultEncoding(e),this}unshift(e,t){this._readable.unshift(e,t)}wrap(e){return this._readable.wrap(e),this}iterator(e){return this._readable.iterator(e)}get writableCorked(){return this._writable.writableCorked}get writableNeedDrain(){return this._writable.writableNeedDrain}get writableObjectMode(){return this._writable.writableObjectMode}get readableAborted(){return this._readable.readableAborted}get readableDidRead(){return this._readable.readableDidRead}get readableEncoding(){return this._readable.readableEncoding}get errored(){return this._errored??this._readable.errored??this._writable.errored}get closed(){return this._closed}get readableBuffer(){return this._readable.readableBuffer}get writableBuffer(){return this._writable.writableBuffer}async*[Symbol.asyncIterator](){yield*this._readable[Symbol.asyncIterator]()}map(e,t){return this._readable.map(e,t)}filter(e,t){return this._readable.filter(e,t)}async forEach(e,t){return this._readable.forEach(e,t)}async toArray(e){return this._readable.toArray(e)}async some(e,t){return this._readable.some(e,t)}async find(e,t){return this._readable.find(e,t)}async every(e,t){return this._readable.every(e,t)}flatMap(e,t){return this._readable.flatMap(e,t)}drop(e,t){return this._readable.drop(e,t)}take(e,t){return this._readable.take(e,t)}async reduce(e,t,n){return arguments.length>=2?this._readable.reduce(e,t,n):this._readable.reduce(e)}compose(e,t){return this._readable.compose(e,t)}static isDisturbed(e){return e&&e._readable instanceof q?q.isDisturbed(e._readable):q.isDisturbed(e)}static from(e){return Jf.from(e)}static fromWeb(t,n){let r=new e(n);r._webStream=t;let i=q.fromWeb(t.readable,{objectMode:n?.objectMode}),a=Y.fromWeb(t.writable,{objectMode:n?.objectMode});return r._sideForwardingCleanup&&=(r._sideForwardingCleanup(),null),r._readable=i,r._writable=a,r._setupSideForwarding(),r}static toWeb(e){return e._getWebStream()}_transform(e,t,n){let r=Error(`The _transform() method is not implemented`);throw r.code=`ERR_METHOD_NOT_IMPLEMENTED`,r}_final(e){typeof this._flush==`function`&&!this.destroyed?this._flush((t,n)=>{if(t){e(t);return}n!=null&&this.push(n),this.push(null),e()}):(this.push(null),e())}};Yf.prototype.addListener=Yf.prototype.on,Yf.prototype._writev=null;var Xf=class extends Yf{constructor(e){super(e)}_transform(e,t,n){n(null,e)}};let Zf=e=>!e||typeof e!=`object`||typeof e.pipe==`function`||typeof e.write==`function`||typeof e.end==`function`||typeof e.getReader==`function`||typeof e.getWriter==`function`?!1:Object.prototype.hasOwnProperty.call(e,`signal`)||Object.prototype.hasOwnProperty.call(e,`end`),Qf=e=>`readableEnded`in e||`readable`in e||typeof e.read==`function`,$f=e=>`writableFinished`in e||`writable`in e||typeof e.write==`function`,ep=e=>{let t=!Qf(e)||!!e.readableEnded,n=!$f(e)||!!e.writableFinished;return t&&n},tp=()=>{let e=Error(`Premature close`);return e.code=`ERR_STREAM_PREMATURE_CLOSE`,e.name=`Error [ERR_STREAM_PREMATURE_CLOSE]`,e},np=(e,t,n)=>{let r=e;if(r.closed||r._closed){t();return}`_emitClose`in r&&`_autoDestroy`in r&&r._emitClose!==!1&&r._autoDestroy!==!1?n.once(e,`close`,()=>t()):t()},rp=e=>e instanceof q||e instanceof Y||e instanceof Yf||e instanceof Jf?e:sf(e)?Yf.fromWeb(e):af(e)?q.fromWeb(e):of(e)?Y.fromWeb(e):e,ip=e=>typeof e==`function`&&!(e instanceof q)&&!(e instanceof Y),ap=(e,t)=>{let n=t(e);return q.from(n)};function op(...e){let t,n={},i,a=e[e.length-1];if(typeof a==`function`){i=a;let r=e[e.length-2];Zf(r)?(n=r,t=e.slice(0,-2)):t=e.slice(0,-1)}else Zf(a)?(n=a,t=e.slice(0,-1)):t=e;let o=new Promise((e,i)=>{if(t.length<2){i(Error(`Pipeline requires at least 2 streams`));return}let a=t.map(rp),o=[],s=[],c=a[0];o.push(c),s.push(c);for(let e=1;e<a.length;e++){let t=a[e];ip(t)?(c=ap(c,t),o.push(c),s[s.length-1]=c):(o.push(t),s.push(t),c=t)}let l=s[0],u=s[s.length-1],d=s.slice(1,-1);for(let e of o)if(e.destroyed&&!ep(e)){i(tp());return}let f=!1,p=kf(),m,h=t=>{if(!f){if(f=!0,m&&n.signal&&n.signal.removeEventListener(`abort`,m),t){let e=()=>{};for(let n of o)typeof n.on==`function`&&n.on(`error`,e),typeof n.destroy==`function`&&!n.destroyed&&n.destroy(t)}p.cleanup(),t?i(t):e()}};if(n.signal){if(n.signal.aborted){h(r(n.signal.reason));return}m=()=>h(r(n.signal.reason)),n.signal.addEventListener(`abort`,m)}c=l;for(let e of d)c.pipe(e),c=e;if(n.end!==!1)c.pipe(u);else{let e=!1,t=!1,n=()=>{t=!1,e&&typeof c.resume==`function`&&(e=!1,c.resume())};p.add(c,`data`,r=>{!u.write(r)&&!t&&(t=!0,!e&&typeof c.pause==`function`&&(e=!0,c.pause()),p.once(u,`drain`,n))}),p.once(c,`end`,()=>{np(c,h,p)})}n.end!==!1&&p.once(u,`finish`,()=>{np(u,h,p)});for(let e of o)p.once(e,`close`,()=>{f||ep(e)||h(tp())});for(let e of o)p.once(e,`error`,e=>h(e))});return i&&o.then(()=>i()).catch(e=>i(e)),o}function sp(e,t,n){let i={},a;typeof t==`function`?a=t:(i=t??{},a=n);let o=new Promise((t,n)=>{let a=rp(e),o=!1,s=kf(),c,l=()=>{s.cleanup(),c&&i.signal&&i.signal.removeEventListener(`abort`,c)},u=e=>{o||(o=!0,l(),e?n(e):t())};if(i.signal){if(i.signal.aborted){u(r(i.signal.reason));return}c=()=>u(r(i.signal.reason)),i.signal.addEventListener(`abort`,c)}let d=a;if(d.destroyed||d._destroyed){if(d.errored||d._errored)u(d.errored??d._errored);else{let e=`readableEnded`in d||`readable`in d||typeof d.read==`function`,t=`writableFinished`in d||`writable`in d||typeof d.write==`function`,n=i.readable!==!1&&e,r=i.writable!==!1&&t,a=!n||!!(d.readableEnded||d._endEmitted),o=!r||!!(d.writableFinished||d._finished);a&&o?u():u(tp())}return}let f=`readableEnded`in a||`readable`in a||typeof a.read==`function`,p=`writableFinished`in a||`writable`in a||typeof a.write==`function`,m=i.readable!==!1&&f,h=i.writable!==!1&&p,g=!m||!!a.readableEnded,_=!h||!!a.writableFinished,v=a,y=`_emitClose`in v&&`_autoDestroy`in v&&v._emitClose!==!1&&v._autoDestroy!==!1&&!v._closed,b=()=>{if(g&&_){if(y)return;u()}};if(g&&_&&(!y||a.closed)){u();return}h&&!_&&s.once(a,`finish`,()=>{_=!0,b()}),m&&!g&&s.once(a,`end`,()=>{g=!0,b()}),i.error!==!1&&s.once(a,`error`,e=>u(e)),s.once(a,`close`,()=>{let e=g||!!a.readableEnded,t=_||!!a.writableFinished;if(e&&t){g=e,_=t,u(a.errored??a._errored??void 0);return}let n=a.errored??a._errored;if(n){u(n);return}let r=Error(`Premature close`);r.code=`ERR_STREAM_PREMATURE_CLOSE`,r.name=`Error [ERR_STREAM_PREMATURE_CLOSE]`,u(r)})});return a&&o.then(()=>a()).catch(e=>a(e)),o}async function*cp(e){let t=e.getReader();try{for(;;){let e=await t.read();if(e.done)return;e.value!==void 0&&e.value!==null&&(yield e.value)}}finally{try{await t.cancel?.()}catch{}try{t.releaseLock?.()}catch{}}}Ff(e=>Jf.from(e));let lp=new Map([[/^xl\/charts\/chart\d+\.xml$/,`application/vnd.openxmlformats-officedocument.drawingml.chart+xml`],[/^xl\/charts\/style\d+\.xml$/,`application/vnd.ms-office.chartstyle+xml`],[/^xl\/charts\/colors\d+\.xml$/,`application/vnd.ms-office.chartcolorstyle+xml`]]),up=[`xl/charts/`];var dp=class e{constructor(){this.files=new Map}static isPassthroughPath(e){return up.some(t=>e.startsWith(t))}static getContentType(e){if(!e.startsWith(`xl/charts/_rels/`)){for(let[t,n]of lp)if(t.test(e))return n}}add(e,t){this.files.set(e,t)}get(e){return this.files.get(e)}has(e){return this.files.has(e)}getPaths(){return[...this.files.keys()]}toRecord(){let e={};for(let[t,n]of this.files)e[t]=n;return e}fromRecord(e){this.files.clear();for(let[t,n]of Object.entries(e))this.files.set(t,n)}getContentTypes(){let t=[];for(let n of this.files.keys()){let r=e.getContentType(n);r&&t.push({partName:n,contentType:r})}return t}writeToZip(e){for(let[t,n]of this.files)e.append(n,{name:t})}clear(){this.files.clear()}get size(){return this.files.size}},fp=class e{static{this.textEncoder=new TextEncoder}constructor(e){this.events=new Map,this.pipedStream=null,this.finalized=!1,this.level=e?.level??6,this.modTime=e?.modTime,this.timestamps=e?.timestamps,this.zip=new qd((e,t,n)=>{if(e){this._emit(`error`,e);return}t&&t.length>0&&(this._emit(`data`,t),this.pipedStream&&this.pipedStream.write(t)),n&&(this.pipedStream&&this.pipedStream.end(),this._emit(`finish`))})}_emit(e,...t){let n=this.events.get(e);if(n)for(let e of n)e(...t)}on(e,t){let n=this.events.get(e)||new Set;return n.add(t),this.events.set(e,n),this}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}off(e,t){let n=this.events.get(e);return n?(n.delete(t),n.size===0&&this.events.delete(e),this):this}pipe(e){this.pipedStream=e}append(t,n){if(this.finalized)throw new b(`append`,`stream already finalized`);let r;r=n.base64?ut(typeof t==`string`?t:String(t)):typeof t==`string`?e.textEncoder.encode(t):t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer?new Uint8Array(t):t;let i=new Kd(n.name,{level:this.level,modTime:this.modTime,timestamps:this.timestamps});this.zip.add(i),i.push(r,!0)}finalize(){this.finalized||(this.finalized=!0,this.zip.end())}},pp=class e{static{this.RelType=z}constructor(e){this.workbook=e}createBinaryStream(e){let t=new Xf;return t.end(e),t}createTextStream(e){let t=new Xf;return t.end(e),t}createStreamBuf(){return new pc}bufferToString(e){return Ft(e)}createZipWriter(e){return new fp(e)}async writeToZip(e,t){let{model:n}=this.workbook;this.prepareModel(n,t),await this.addContentTypes(e,n),await this.addOfficeRels(e,n),await this.addWorkbookRels(e,n),await this.addWorkbook(e,n),await this.addWorksheets(e,n),await this.addSharedStrings(e,n),this.addDrawings(e,n),this.addTables(e,n),this.addPivotTables(e,n),this.addPassthrough(e,n),await Promise.all([this.addThemes(e,n),this.addStyles(e,n)]),await this.addFeaturePropertyBag(e,n),await this.addMedia(e,n),await Promise.all([this.addApp(e,n),this.addCore(e,n)])}async read(e,t){let n=[];return await new Promise((t,r)=>{let i=e=>{n.push(e)},a=()=>{e.off(`data`,i),e.off(`end`,a),e.off(`error`,o),t()},o=t=>{e.off(`data`,i),e.off(`end`,a),e.off(`error`,o),r(t)};e.on(`data`,i),e.on(`end`,a),e.on(`error`,o)}),this.loadBuffer(O(n),t)}async write(e,t){t||={},t.zip=t.zip||{},t.zip.modTime??=this.workbook.modified??this.workbook.created;let n=this.createZipWriter(t.zip);return n.pipe(e),await this.writeToZip(n,t),this._finalize(n)}async load(e,t){let n,r=typeof Buffer<`u`?Buffer.isBuffer(e):!1;if(!e||typeof e==`object`&&!r&&!(e instanceof Uint8Array)&&!(e instanceof ArrayBuffer))throw new y(`<input>`,`read`,`Can't read the data of 'the loaded zip file'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?`);return n=t&&t.base64?ut(e.toString()):e instanceof ArrayBuffer?new Uint8Array(e):e instanceof Uint8Array?e:new Uint8Array(e),this.loadBuffer(n,t)}async loadBuffer(e,t){let n=await new yf(e).extractAll(),r={};for(let[e,t]of n)r[e]=t;return this.loadFromFiles(r,t)}createEmptyModel(){return{worksheets:[],worksheetHash:{},worksheetRels:[],themes:{},media:[],mediaIndex:{},drawings:{},drawingRels:{},rawDrawings:{},comments:{},tables:{},vmlDrawings:{},pivotTables:{},pivotTableRels:{},pivotCacheDefinitions:{},pivotCacheRecords:{},passthrough:{}}}async collectStreamData(e){let t=[];return await new Promise((n,r)=>{e.on(`data`,e=>{typeof e==`string`?t.push(new TextEncoder().encode(e)):e instanceof Uint8Array?t.push(e):t.push(new Uint8Array(e))}),e.on(`end`,()=>n()),e.on(`error`,r)}),O(t)}drawingHasChartReference(e){return e.rels&&e.rels.some(e=>e.Target&&e.Target.includes(`/charts/`))}drawingRelsHasChartReference(e){return Array.isArray(e)&&e.some(e=>typeof e?.Target==`string`&&e.Target.includes(`/charts/`))}async _processKnownEntry(e,t,n,r){let i=xi(n);if(i!==void 0)return await this._processWorksheetEntry(e,t,i,r,n),!0;switch(n){case L.rootRels:return t.globalRels=await this.parseRels(e),!0;case L.xlWorkbook:{let n=await this.parseWorkbook(e);return t.sheets=n.sheets,t.definedNames=n.definedNames,t.views=n.views,t.properties=n.properties,t.calcProperties=n.calcProperties,t.pivotCaches=n.pivotCaches,!0}case L.xlSharedStrings:return t.sharedStrings=new ii,await t.sharedStrings.parseStream(e),!0;case L.xlWorkbookRels:return t.workbookRels=await this.parseRels(e),!0;case L.docPropsApp:{let n=await new ya().parseStream(e);return n&&(t.company=n.company,t.manager=n.manager),!0}case L.docPropsCore:{let n=await new $r().parseStream(e);return Object.assign(t,n),!0}case L.xlStyles:return t.styles=new Zr,await t.styles.parseStream(e),!0;default:return!1}}async loadFromZipEntries(e,t){let n=this.createEmptyModel();for await(let r of e){let e=!1,i=async()=>{e||(e=!0,await r.drain())};if(r.type===`Directory`){await i();continue}let a=bi(r.name),o=r.stream;try{await this._processKnownEntry(o,n,a,t)||await this._processDefaultEntry(o,n,a)||await i()}finally{try{await i()}catch{}}}return this.reconcile(n,t),this.workbook.model=n,this.workbook}async writeBuffer(e){e||={},e.zip=e.zip||{},e.zip.modTime??=this.workbook.modified??this.workbook.created;let t=this.createZipWriter(e.zip),n=this.createStreamBuf();return t.pipe(n),await this.writeToZip(t,e),await this._finalize(t),n.read()||new Uint8Array}async addMedia(e,t){await Promise.all(t.media.map(async t=>{if(t.type!==`image`)throw new ne(`Unsupported media`);let n=zi(`${t.name??`undefined`}.${t.extension}`);if(t.filename){if(this.readFileAsync){let r=await this.readFileAsync(t.filename);return e.append(r,{name:n})}throw new v(`Loading images from filename`,`not supported in this environment`)}if(t.buffer)return e.append(t.buffer,{name:n});if(t.base64){let r=t.base64.substring(t.base64.indexOf(`,`)+1);return e.append(r,{name:n,base64:!0})}throw new ne(`Unsupported media`)}))}parseRels(e){return new I().parseStream(e)}parseWorkbook(e){return new Na().parseStream(e)}parseSharedStrings(e){return new ii().parseStream(e)}reconcile(e,t){let n=new Na,r=new Xo(t),i=new hs,a=new Ss;n.reconcile(e);let o={media:e.media,mediaIndex:e.mediaIndex};if(Object.keys(e.drawings).forEach(t=>{let n=e.drawings[t],r=e.drawingRels[t];r&&(o.rels=r.reduce((e,t)=>(e[t.Id]=t,e),{}),(n.anchors??[]).forEach(e=>{let t=e.picture&&e.picture.hyperlinks;t&&o.rels[t.rId]&&(t.hyperlink=o.rels[t.rId].Target,delete t.rId)}),i.reconcile(n,o))}),e.rawDrawings&&e.drawingRels)for(let t of Object.keys(e.rawDrawings)){let n=e.drawingRels[t];n&&!this.drawingRelsHasChartReference(n)&&delete e.rawDrawings[t]}let s={styles:e.styles};Object.values(e.tables).forEach(e=>{a.reconcile(e,s)}),this._reconcilePivotTables(e);let c={styles:e.styles,sharedStrings:e.sharedStrings,media:e.media,mediaIndex:e.mediaIndex,date1904:e.properties?.date1904,drawings:e.drawings,drawingRels:e.drawingRels,comments:e.comments,tables:e.tables,vmlDrawings:e.vmlDrawings,pivotTables:e.pivotTablesIndexed};e.worksheets.forEach(t=>{t.relationships=e.worksheetRels[t.sheetNo],r.reconcile(t,c)}),delete e.worksheetHash,delete e.worksheetRels,delete e.globalRels,delete e.sharedStrings,delete e.workbookRels,delete e.sheetDefs,e.defaultFont=e.styles?.defaultFont,delete e.styles,delete e.mediaIndex,delete e.drawings,delete e.drawingRels,delete e.vmlDrawings,delete e.pivotTableRels}_reconcilePivotTables(e){let t=e.pivotTables||{};if(typeof t!=`object`||Object.keys(t).length===0){e.pivotTables=[],e.pivotTablesIndexed={};return}let n=this._buildDefinitionToCacheIdMap(e),r=new Map;Object.entries(e.pivotCacheDefinitions||{}).forEach(([t,i])=>{let a=n.get(t);if(a!==void 0){let n=t.replace(`Definition`,`Records`);r.set(a,{definition:i,records:e.pivotCacheRecords?.[n],definitionName:t})}});let i=[],a={};Object.entries(t).forEach(([e,t])=>{let n=this._extractTableNumber(e),o=r.get(t.cacheId),s=this._determineMetric(t.dataFields),c={...t,tableNumber:n,cacheId:String(t.cacheId),cacheDefinition:o?.definition,cacheRecords:o?.records,cacheFields:o?.definition?.cacheFields??[],rows:t.rowFields.filter(e=>e>=0),columns:t.colFields.filter(e=>e>=0&&e!==-2),values:t.dataFields.map(e=>e.fld),pages:t.pageFields.map(e=>e.fld),metric:s,valueMetrics:this._determineValueMetrics(t.dataFields,s),applyWidthHeightFormats:t.applyWidthHeightFormats===`1`?`1`:`0`};i.push(c),a[ua(e)]=c}),i.sort((e,t)=>e.tableNumber-t.tableNumber),e.pivotTables=i,e.pivotTablesIndexed=a}_extractTableNumber(e){let t=e.match(/pivotTable(\d+)/);return t?parseInt(t[1],10):1}_buildCacheIdMap(e){let t=new Map,n=e.pivotCaches??[];for(let e of n)e.cacheId&&e.rId&&t.set(e.rId,parseInt(e.cacheId,10));return t}_buildDefinitionToCacheIdMap(t){let n=new Map,r=this._buildCacheIdMap(t),i=t.workbookRels??[];for(let t of i)if(t.Type===e.RelType.PivotCacheDefinition&&t.Target){let e=t.Target.match(/pivotCacheDefinition(\d+)\.xml/);if(e){let i=`pivotCacheDefinition${e[1]}`,a=r.get(t.Id);a!==void 0&&n.set(i,a)}}return n}_determineMetric(e){return e.length>0&&e[0].subtotal?e[0].subtotal:`sum`}_determineValueMetrics(e,t){return e.map(e=>e.subtotal||t)}async _processWorksheetEntry(e,t,n,r,i){let a=await new Xo(r).parseStream(e);if(!a)throw new _(i,`Failed to parse worksheet`);a.sheetNo=n,t.worksheetHash[i]=a,t.worksheets.push(a)}async _processCommentEntry(e,t,n){let r=await new Ys().parseStream(e);t.comments[ca(n)]=r}async _processTableEntry(e,t,n){let r=await new Ss().parseStream(e);t.tables[fa(n)]=r}async _processWorksheetRelsEntry(e,t,n){let r=await new I().parseStream(e);t.worksheetRels[n]=r}async _processMediaEntry(e,t,n){let r=n.lastIndexOf(`.`);if(r>=1){let i=n.substr(r+1),a=n.substr(0,r);await new Promise((r,o)=>{let s=this.createStreamBuf(),c=()=>{e.off(`error`,u),s.off(`error`,u),s.off(`finish`,l)},l=()=>{c(),t.mediaIndex[n]=t.media.length,t.mediaIndex[a]=t.media.length;let e={type:`image`,name:a,extension:i,buffer:s.read()};t.media.push(e),r()},u=e=>{c(),o(e)};s.once(`finish`,l),e.on(`error`,u),s.on(`error`,u),e.pipe(s)})}}async _processDrawingEntry(e,t,n,r){let i=r??await this.collectStreamData(e),a=new hs,o=this.bufferToString(i),s=await a.parseStream(this.createTextStream(o));t.drawings[n]=s,t.rawDrawings[n]=i}async _processDrawingRelsEntry(e,t,n){let r=await new I().parseStream(e);t.drawingRels[n]=r}async _processVmlDrawingEntry(e,t,n){let r=await new rc().parseStream(e);t.vmlDrawings[sa(n)]=r}async _processThemeEntry(e,t,n){await new Promise((r,i)=>{let a=this.createStreamBuf(),o=()=>{e.off(`error`,c),a.off(`error`,c),a.off(`finish`,s)},s=()=>{o();let e=a.read();t.themes[n]=e?typeof e==`string`?e:this.bufferToString(e):``,r()},c=e=>{o(),i(e)};a.once(`finish`,s),e.on(`error`,c),a.on(`error`,c),e.pipe(a)})}async _processPivotTableEntry(e,t,n){let r=await new Us().parseStream(e);r&&(t.pivotTables[n]=r)}async _processPivotTableRelsEntry(e,t,n){let r=await new I().parseStream(e);t.pivotTableRels[n]=r}async _processPivotCacheDefinitionEntry(e,t,n){let r=await new Ls().parseStream(e);r&&(t.pivotCacheDefinitions[n]=r)}async _processPivotCacheRecordsEntry(e,t,n){let r=await new ks().parseStream(e);r&&(t.pivotCacheRecords[n]=r)}async loadFromFiles(e,t){let n=this.createEmptyModel(),r=Object.keys(e).map(t=>({name:t,dir:t.endsWith(`/`),data:e[t]}));for(let e of r)if(!e.dir){let r=bi(e.name),i=Di(r)?this.createBinaryStream(e.data):this.createTextStream(this.bufferToString(e.data));await this._processKnownEntry(i,n,r,t)||await this._processDefaultEntry(i,n,r,e.data)}return this.reconcile(n,t),this.workbook.model=n,this.workbook}async _processDefaultEntry(e,t,n,r){let i=Si(n);if(i!==void 0)return await this._processWorksheetRelsEntry(e,t,i),!0;let a=wi(n);if(a)return await this._processMediaEntry(e,t,a),!0;let o=Oi(n);if(o)return await this._processDrawingEntry(e,t,o,r),!0;let s=ki(n);if(s)return await this._processDrawingRelsEntry(e,t,s),!0;let c=Ai(n);if(c)return await this._processVmlDrawingEntry(e,t,c),!0;let l=ji(n);if(l)return await this._processCommentEntry(e,t,`comments${l}`),!0;let u=Mi(n);if(u)return await this._processTableEntry(e,t,u),!0;let d=Ei(n);if(d)return await this._processThemeEntry(e,t,d),!0;let f=Ni(n);if(f)return await this._processPivotTableEntry(e,t,f),!0;let p=Pi(n);if(p)return await this._processPivotTableRelsEntry(e,t,p),!0;let m=Fi(n);if(m)return await this._processPivotCacheDefinitionEntry(e,t,m),!0;if(Ii(n))return!0;let h=Li(n);return h?(await this._processPivotCacheRecordsEntry(e,t,h),!0):dp.isPassthroughPath(n)?(r?t.passthrough[n]=r:await this._processPassthroughEntry(e,t,n),!0):!1}async _processPassthroughEntry(e,t,n){let r=await this.collectStreamData(e);t.passthrough[n]=r}async addContentTypes(e,t){let n=new ga().toXml(t);e.append(n,{name:L.contentTypes})}async addApp(e,t){let n=new ya().toXml(t);e.append(n,{name:L.docPropsApp})}async addCore(e,t){let n=new $r;e.append(n.toXml(t),{name:L.docPropsCore})}async addThemes(e,t){let n=t.themes||{theme1:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
319
- <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"> <a:themeElements> <a:clrScheme name="Office"> <a:dk1> <a:sysClr val="windowText" lastClr="000000"/> </a:dk1> <a:lt1> <a:sysClr val="window" lastClr="FFFFFF"/> </a:lt1> <a:dk2> <a:srgbClr val="1F497D"/> </a:dk2> <a:lt2> <a:srgbClr val="EEECE1"/> </a:lt2> <a:accent1> <a:srgbClr val="4F81BD"/> </a:accent1> <a:accent2> <a:srgbClr val="C0504D"/> </a:accent2> <a:accent3> <a:srgbClr val="9BBB59"/> </a:accent3> <a:accent4> <a:srgbClr val="8064A2"/> </a:accent4> <a:accent5> <a:srgbClr val="4BACC6"/> </a:accent5> <a:accent6> <a:srgbClr val="F79646"/> </a:accent6> <a:hlink> <a:srgbClr val="0000FF"/> </a:hlink> <a:folHlink> <a:srgbClr val="800080"/> </a:folHlink> </a:clrScheme> <a:fontScheme name="Office"> <a:majorFont> <a:latin typeface="Cambria"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Times New Roman"/> <a:font script="Hebr" typeface="Times New Roman"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="MoolBoran"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Times New Roman"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:majorFont> <a:minorFont> <a:latin typeface="Calibri"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Arial"/> <a:font script="Hebr" typeface="Arial"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="DaunPenh"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Arial"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:minorFont> </a:fontScheme> <a:fmtScheme name="Office"> <a:fillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="35000"> <a:schemeClr val="phClr"> <a:tint val="37000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="15000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="1"/> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="100000"/> <a:shade val="100000"/> <a:satMod val="130000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:shade val="100000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="0"/> </a:gradFill> </a:fillStyleLst> <a:lnStyleLst> <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"> <a:shade val="95000"/> <a:satMod val="105000"/> </a:schemeClr> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> </a:lnStyleLst> <a:effectStyleLst> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="38000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> <a:scene3d> <a:camera prst="orthographicFront"> <a:rot lat="0" lon="0" rev="0"/> </a:camera> <a:lightRig rig="threePt" dir="t"> <a:rot lat="0" lon="0" rev="1200000"/> </a:lightRig> </a:scene3d> <a:sp3d> <a:bevelT w="63500" h="25400"/> </a:sp3d> </a:effectStyle> </a:effectStyleLst> <a:bgFillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="40000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="40000"> <a:schemeClr val="phClr"> <a:tint val="45000"/> <a:shade val="99000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="20000"/> <a:satMod val="255000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="-80000" r="50000" b="180000"/> </a:path> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="80000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="30000"/> <a:satMod val="200000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="50000" r="50000" b="50000"/> </a:path> </a:gradFill> </a:bgFillStyleLst> </a:fmtScheme> </a:themeElements> <a:objectDefaults> <a:spDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="1"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="3"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="2"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="lt1"/> </a:fontRef> </a:style> </a:spDef> <a:lnDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="2"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="0"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="1"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="tx1"/> </a:fontRef> </a:style> </a:lnDef> </a:objectDefaults> <a:extraClrSchemeLst/> </a:theme>`};Object.keys(n).forEach(t=>{let r=n[t];e.append(r,{name:Ri(t)})})}async addOfficeRels(t,n){let r=new I().toXml([{Id:`rId1`,Type:e.RelType.OfficeDocument,Target:L.xlWorkbook},{Id:`rId2`,Type:e.RelType.CoreProperties,Target:L.docPropsCore},{Id:`rId3`,Type:e.RelType.ExtenderProperties,Target:L.docPropsApp}]);t.append(r,{name:L.rootRels})}async addWorkbookRels(t,n){let r=1,i=[{Id:`rId${r++}`,Type:e.RelType.Styles,Target:na.workbookStyles},{Id:`rId${r++}`,Type:e.RelType.Theme,Target:na.workbookTheme1}];n.sharedStrings.count&&i.push({Id:`rId${r++}`,Type:e.RelType.SharedStrings,Target:na.workbookSharedStrings}),n.hasCheckboxes&&i.push({Id:`rId${r++}`,Type:e.RelType.FeaturePropertyBag,Target:na.workbookFeaturePropertyBag});let a=new Map;(n.pivotTables??[]).forEach(t=>{let n=a.get(t.cacheId);n?t.rId=n:(t.rId=`rId${r++}`,a.set(t.cacheId,t.rId),i.push({Id:t.rId,Type:e.RelType.PivotCacheDefinition,Target:ra(t.tableNumber)}))}),n.worksheets.forEach(t=>{t.rId=`rId${r++}`,i.push({Id:t.rId,Type:e.RelType.Worksheet,Target:Hi(t.fileIndex)})});let o=new I().toXml(i);t.append(o,{name:L.xlWorkbookRels})}async addFeaturePropertyBag(e,t){if(!t.hasCheckboxes)return;let n=new Zo;e.append(n.toXml({}),{name:L.xlFeaturePropertyBag})}async addSharedStrings(e,t){t.sharedStrings&&t.sharedStrings.count&&e.append(t.sharedStrings.xml,{name:L.xlSharedStrings})}async addStyles(e,t){let{xml:n}=t.styles;n&&e.append(n,{name:L.xlStyles})}async addWorkbook(e,t){let n=new Na;e.append(n.toXml(t),{name:L.xlWorkbook})}async addWorksheets(e,t){let n=new Xo,r=new I,i=new Ys,a=new rc,o=new ic;t.worksheets.forEach(t=>{let{fileIndex:s}=t,c=new k;n.render(c,t),e.append(c.xml,{name:Bi(s)}),t.rels&&t.rels.length&&(c=new k,r.render(c,t.rels),e.append(c.xml,{name:Vi(s)})),t.comments.length>0&&(c=new k,i.render(c,t),e.append(c.xml,{name:Ui(s)}));let l=t.comments.length>0,u=t.formControls&&t.formControls.length>0;(l||u)&&(c=new k,a.render(c,{comments:l?t.comments:[],formControls:u?t.formControls:[]}),e.append(c.xml,{name:Gi(s)})),u&&t.formControls.forEach(t=>{let n=o.toXml(t);e.append(n,{name:ma(t.ctrlPropId)})})})}addDrawings(e,t){let n=new hs,r=new I,i=t.rawDrawings||{};t.worksheets.forEach(t=>{let{drawing:a}=t;if(a){if(this.drawingHasChartReference(a)&&i[a.name])e.append(i[a.name],{name:qi(a.name)});else{let t=(a.anchors??[]).filter(e=>e==null?!1:e.range?.br&&e.shape?!0:!(!e.br&&!e.picture||e.br&&!e.picture&&!e.shape)),r=a.anchors?{...a,anchors:t}:a;n.prepare(r);let i=n.toXml(r);e.append(i,{name:qi(a.name)})}let t=r.toXml(a.rels);e.append(t,{name:Ji(a.name)})}})}addTables(e,t){let n=new Ss;t.worksheets.forEach(t=>{let{tables:r}=t;r.forEach(t=>{n.prepare(t,{});let r=n.toXml(t);e.append(r,{name:Ki(t.target)})})})}addPassthrough(e,t){let n=new dp;n.fromRecord(t.passthrough||{}),n.writeToZip(e)}addPivotTables(t,n){if(!n.pivotTables.length)return;let r=new ks,i=new Ls,a=new Us,o=new I,s=new Map;n.pivotTables.forEach(n=>{let c=n.tableNumber,l=n.isLoaded,u=n.cacheId;if(!s.has(u)){if(s.set(u,c),l){if(n.cacheDefinition){let e=i.toXml(n.cacheDefinition);t.append(e,{name:Yi(c)})}if(n.cacheRecords){let e=r.toXml(n.cacheRecords);t.append(e,{name:Zi(c)})}}else{let e=r.toXml(n);t.append(e,{name:Zi(c)}),e=i.toXml(n),t.append(e,{name:Yi(c)})}if(!l||n.cacheRecords){let r=(l?n.cacheDefinition?.rId:void 0)??`rId1`,i=o.toXml([{Id:r,Type:e.RelType.PivotCacheRecords,Target:Qi(c)}]);t.append(i,{name:Xi(c)})}}let d=a.toXml(n);t.append(d,{name:$i(c)});let f=s.get(u);d=o.toXml([{Id:`rId1`,Type:e.RelType.PivotCacheDefinition,Target:ta(f)}]),t.append(d,{name:ea(c)})})}_finalize(e){return new Promise((t,n)=>{e.on(`finish`,()=>{t(this)}),e.on(`error`,n),e.finalize()})}prepareModel(e,t){e.creator=e.creator??`ExcelTS`,e.lastModifiedBy=e.lastModifiedBy??`ExcelTS`,e.created=e.created??new Date,e.modified=e.modified??new Date,e.useSharedStrings=t.useSharedStrings===void 0?!0:t.useSharedStrings,e.useStyles=t.useStyles===void 0?!0:t.useStyles,e.sharedStrings=new ii;let n=e.defaultFont;e.styles=e.useStyles?new Zr(!0):new Zr.Mock,n&&e.styles.setDefaultFont&&e.styles.setDefaultFont(n);let r=new Na,i=new Xo;r.prepare(e);let a={sharedStrings:e.sharedStrings,styles:e.styles,date1904:e.properties?.date1904,drawingsCount:0,media:e.media};a.drawings=e.drawings=[],a.commentRefs=e.commentRefs=[],a.formControlRefs=e.formControlRefs=[];let o=0;e.tables=[],e.worksheets.forEach((t,n)=>{t.fileIndex=n+1,t.tables.forEach(t=>{o++,t.target=`table${o}.xml`,t.id=o,e.tables.push(t)}),i.prepare(t,a)}),e.hasCheckboxes=e.styles.hasCheckboxes;let s=e.passthrough||{},c=new dp;c.fromRecord(s),e.passthroughContentTypes=c.getContentTypes()}},mp=class{constructor(){this._values=[],this._totalRefs=0,this._hash=Object.create(null)}get count(){return this._values.length}get values(){return this._values}get totalRefs(){return this._totalRefs}getString(e){return this._values[e]}add(e){let t=this._hash[e];return t===void 0&&(t=this._hash[e]=this._values.length,this._values.push(e)),this._totalRefs++,t}},hp=class{constructor(e){this.writer=e}push(e){this.writer.addHyperlink(e)}},gp=class{constructor(e){this.id=e.id,this.count=0,this._hyperlinks=[],this._workbook=e.workbook}get stream(){return this._stream||=this._workbook._openStream(Vi(this.id)),this._stream}get length(){return this._hyperlinks.length}each(e){return this._hyperlinks.forEach(e)}get hyperlinksProxy(){return this._hyperlinksProxy||=new hp(this)}addHyperlink(e){let t={Target:e.target,Type:z.Hyperlink,TargetMode:`External`},n=this._writeRelationship(t);this._hyperlinks.push({rId:n,address:e.address})}addMedia(e){return this._writeRelationship(e)}addRelationship(e){return this._writeRelationship(e)}commit(){this.count&&(this._writeClose(),this.stream.end())}_writeOpen(){this.stream.write(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
320
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`)}_writeRelationship(e){this.count||this._writeOpen();let t=`rId${++this.count}`;return e.TargetMode?this.stream.write(`<Relationship Id="${t}" Type="${e.Type}" Target="${E(e.Target)}" TargetMode="${e.TargetMode}"/>`):this.stream.write(`<Relationship Id="${t}" Type="${e.Type}" Target="${e.Target}"/>`),t}_writeClose(){this.stream.write(`</Relationships>`)}},_p=class{constructor(e,t,n){this.id=n.id,this.count=0,this._worksheet=e,this._workbook=n.workbook,this._sheetRelsWriter=t}get commentsStream(){return this._commentsStream||=this._workbook._openStream(Ui(this.id)),this._commentsStream}get vmlStream(){return this._vmlStream||=this._workbook._openStream(Gi(this.id)),this._vmlStream}_addRelationships(){let e={Type:z.Comments,Target:ia(this.id)};this._sheetRelsWriter.addRelationship(e);let t={Type:z.VmlDrawing,Target:aa(this.id)};this.vmlRelId=this._sheetRelsWriter.addRelationship(t)}_addCommentRefs(){this._workbook.commentRefs.push({commentName:`comments${this.id}`,vmlDrawing:`vmlDrawing${this.id}`})}_writeOpen(){this.commentsStream.write(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><authors><author>Author</author></authors><commentList>`),this.vmlStream.write(`<?xml version="1.0" encoding="UTF-8"?><xml xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:x="urn:schemas-microsoft-com:office:excel"><o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="1" /></o:shapelayout><v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe"><v:stroke joinstyle="miter" /><v:path gradientshapeok="t" o:connecttype="rect" /></v:shapetype>`)}_writeComment(e,t){let n=new Js,r=new k;n.render(r,e),this.commentsStream.write(r.xml);let i=new nc,a=new k;i.render(a,e,t),this.vmlStream.write(a.xml)}_writeClose(){this.commentsStream.write(`</commentList></comments>`),this.vmlStream.write(`</xml>`)}addComments(e){e&&e.length&&(this.startedData||=(this._worksheet.comments=[],this._writeOpen(),this._addRelationships(),this._addCommentRefs(),!0),e.forEach(e=>{e.refAddress=S.decodeAddress(e.ref)}),e.forEach(e=>{this._writeComment(e,this.count),this.count+=1}))}commit(){this.count&&(this._writeClose(),this.commentsStream.end(),this.vmlStream.end())}};let X=new sc,Z={dataValidations:new Ka,sheetProperties:new Xa,sheetFormatProperties:new Za,columns:new M({tag:`cols`,count:!1,childXform:new za}),row:new Ra,hyperlinks:new M({tag:`hyperlinks`,count:!1,childXform:new Va}),sheetViews:new M({tag:`sheetViews`,count:!1,childXform:new $a}),sheetProtection:new eo,pageMargins:new to,pageSeteup:new so,autoFilter:new uo,picture:new fo,conditionalFormattings:new No,headerFooter:new vo,rowBreaks:new go,colBreaks:new _o};var vp=class{constructor(e){this.id=e.id,this.name=e.name||`Sheet${this.id}`,this.state=e.state??`visible`,this._rows=[],this._columns=[],this._keys={},this._merges=[],this._merges.add=function(){},this._sheetRelsWriter=new gp(e),this._sheetCommentsWriter=new _p(this,this._sheetRelsWriter,e),this._dimensions=new C,this._rowZero=1,this._rowOffset=0,this.committed=!1,this.dataValidations=new tt,this._formulae={},this._siFormulae=0,this.conditionalFormatting=[],this.rowBreaks=[],this.colBreaks=[],this.properties=Object.assign({},{defaultRowHeight:15,outlineLevelCol:0,outlineLevelRow:0},e.properties),this.headerFooter=Object.assign({},{differentFirst:!1,differentOddEven:!1,oddHeader:null,oddFooter:null,evenHeader:null,evenFooter:null,firstHeader:null,firstFooter:null},e.headerFooter),this.pageSetup=Object.assign({},{margins:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},orientation:`portrait`,horizontalDpi:4294967295,verticalDpi:4294967295,fitToPage:!!(e.pageSetup&&(e.pageSetup.fitToWidth||e.pageSetup.fitToHeight)&&!e.pageSetup.scale),pageOrder:`downThenOver`,blackAndWhite:!1,draft:!1,cellComments:`None`,errors:`displayed`,scale:100,fitToWidth:1,fitToHeight:1,paperSize:void 0,showRowColHeaders:!1,showGridLines:!1,horizontalCentered:!1,verticalCentered:!1,rowBreaks:null,colBreaks:null},e.pageSetup),this.useSharedStrings=e.useSharedStrings??!1,this._workbook=e.workbook,this.hasComments=!1,this._views=e.views??[],this.autoFilter=e.autoFilter??null,this._media=[],this.sheetProtection=null,this._writeOpenWorksheet(),this.startedData=!1}get workbook(){return this._workbook}get stream(){return this._stream||=this._workbook._openStream(Bi(this.id)),this._stream}destroy(){throw new b(`destroy`,`Invalid operation for a streaming writer`)}commit(){if(!this.committed){for(let e=this._rowOffset;e<this._rows.length;e++){let t=this._rows[e];t&&this._writeRow(t)}this._rows=null,this.startedData||this._writeOpenSheetData(),this._writeCloseSheetData(),this._writeSheetProtection(),this._writeAutoFilter(),this._writeMergeCells(),this._writeHyperlinks(),this._writeConditionalFormatting(),this._writeDataValidations(),this._writePageMargins(),this._writePageSetup(),this._writeBackground(),this._writeHeaderFooter(),this._writeRowBreaks(),this._writeColBreaks(),this._writeLegacyData(),this._writeCloseWorksheet(),this.stream.end(),this._sheetCommentsWriter.commit(),this._sheetRelsWriter.commit(),this.committed=!0}}get dimensions(){return this._dimensions}get views(){return this._views}get columns(){return this._columns}set columns(e){this._headerRowCount=e.reduce((e,t)=>{let n=t.header&&1||t.headers&&t.headers.length||0;return Math.max(e,n)},0);let t=1,n=this._columns=[];e.forEach(e=>{let r=new Ve(this,t++,!1);n.push(r),r.defn=e})}getColumnKey(e){return this._keys[e]}setColumnKey(e,t){this._keys[e]=t}deleteColumnKey(e){delete this._keys[e]}eachColumnKey(e){Object.keys(this._keys).forEach(t=>e(this._keys[t],t))}getColumn(e){if(typeof e==`string`){let t=this._keys[e];if(t)return t;e=S.l2n(e)}if(e>this._columns.length){let t=this._columns.length+1;for(;t<=e;)this._columns.push(new Ve(this,t++))}return this._columns[e-1]}get _nextRow(){return this._rowZero+(this._rows.length-this._rowOffset)}eachRow(e,t){let n,r;if(typeof e==`function`?(n=e,r=void 0):(n=t,r=e),r&&r.includeEmpty){let e=this._nextRow;for(let t=this._rowZero;t<e;t++)n(this.getRow(t),t)}else this._rows.forEach(e=>{e&&e.hasValues&&n(e,e.number)})}_commitRow(e){let t=!1,n=this._rows;for(;this._rowOffset<n.length&&!t;){let r=n[this._rowOffset];n[this._rowOffset]=void 0,this._rowOffset++,this._rowZero++,r&&(this._writeRow(r),t=r.number===e.number,this._rowZero=r.number+1),this._rowOffset>1024&&this._rowOffset>n.length>>1&&(n.splice(0,this._rowOffset),this._rowOffset=0)}}get lastRow(){let e=this._rows;for(let t=e.length-1;t>=this._rowOffset;t--){let n=e[t];if(n)return n}}findRow(e){let t=e-this._rowZero+this._rowOffset;return this._rows[t]}getRow(e){let t=e-this._rowZero+this._rowOffset;if(t<this._rowOffset)throw new m(e,`this row has been committed`);let n=this._rows[t];return n||(this._rows[t]=n=new Be(this,e)),n}addRow(e){let t=new Be(this,this._nextRow);return this._rows[t.number-this._rowZero+this._rowOffset]=t,t.values=e,t}findCell(e,t){let n=S.getAddress(e,t),r=this.findRow(n.row);return r?r.findCell(n.col):void 0}getCell(e,t){let n=S.getAddress(e,t);return this.getRow(n.row).getCellEx(n)}mergeCells(...e){let t=new C(e);this._merges.forEach(e=>{if(e.intersects(t))throw new h});let{top:n,left:r,bottom:i,right:a}=t,o=yn(n,r,i,a,(e,t)=>this.findCell(e,t)),s=this.getCell(n,r);for(let e=n;e<=i;e++)for(let t=r;t<=a;t++)(e>n||t>r)&&this.getCell(e,t).merge(s);o&&bn(n,r,i,a,o,(e,t)=>this.getCell(e,t)),this._merges.push(t)}addConditionalFormatting(e){this.conditionalFormatting.push(e)}removeConditionalFormatting(e){typeof e==`number`?this.conditionalFormatting.splice(e,1):e instanceof Function?this.conditionalFormatting=this.conditionalFormatting.filter(e):this.conditionalFormatting=[]}addBackgroundImage(e){this._background={imageId:e}}getBackgroundImageId(){return this._background&&this._background.imageId}async protect(e,t){this.sheetProtection={sheet:!0},t&&`spinCount`in t&&(t.spinCount=Number.isFinite(t.spinCount)?Math.round(Math.max(0,t.spinCount)):1e5),e&&(this.sheetProtection.algorithmName=`SHA-512`,this.sheetProtection.saltValue=It(sn.randomBytes(16)),this.sheetProtection.spinCount=t&&`spinCount`in t?t.spinCount:1e5,this.sheetProtection.hashValue=await sn.convertPasswordToHash(e,`SHA-512`,this.sheetProtection.saltValue,this.sheetProtection.spinCount)),t&&(this.sheetProtection=Object.assign(this.sheetProtection,t),!e&&`spinCount`in t&&delete this.sheetProtection.spinCount)}unprotect(){this.sheetProtection=null}_write(e){X.reset(),X.addText(e),this.stream.write(X)}_writeSheetProperties(e,t,n){let r={outlineProperties:t&&t.outlineProperties,tabColor:t&&t.tabColor,pageSetup:n&&n.fitToPage?{fitToPage:n.fitToPage}:void 0};e.addText(Z.sheetProperties.toXml(r))}_writeSheetFormatProperties(e,t){let n=t?{defaultRowHeight:t.defaultRowHeight,dyDescent:t.dyDescent,outlineLevelCol:t.outlineLevelCol,outlineLevelRow:t.outlineLevelRow}:void 0;t&&t.defaultColWidth&&(n.defaultColWidth=t.defaultColWidth),e.addText(Z.sheetFormatProperties.toXml(n))}_writeOpenWorksheet(){X.reset(),X.addText(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>`),X.addText(`<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">`),this._writeSheetProperties(X,this.properties,this.pageSetup),X.addText(Z.sheetViews.toXml(this.views)),this._writeSheetFormatProperties(X,this.properties),this.stream.write(X)}_writeColumns(){let e=Ve.toModel(this.columns);e&&(Z.columns.prepare(e,{styles:this._workbook.styles}),this.stream.write(Z.columns.toXml(e)))}_writeOpenSheetData(){this._write(`<sheetData>`)}_writeRow(e){if(this.startedData||=(this._writeColumns(),this._writeOpenSheetData(),!0),e.hasValues||e.height!=null){let{model:t}=e,n={styles:this._workbook.styles,sharedStrings:this.useSharedStrings?this._workbook.sharedStrings:void 0,hyperlinks:this._sheetRelsWriter.hyperlinksProxy,merges:this._merges,formulae:this._formulae,siFormulae:this._siFormulae,comments:[]};Z.row.prepare(t,n),this.stream.write(Z.row.toXml(t)),n.comments.length&&(this.hasComments=!0,this._sheetCommentsWriter.addComments(n.comments))}}_writeCloseSheetData(){this._write(`</sheetData>`)}_writeMergeCells(){this._merges.length&&(X.reset(),X.addText(`<mergeCells count="${this._merges.length}">`),this._merges.forEach(e=>{X.addText(`<mergeCell ref="${e}"/>`)}),X.addText(`</mergeCells>`),this.stream.write(X))}_writeHyperlinks(){this.stream.write(Z.hyperlinks.toXml(this._sheetRelsWriter._hyperlinks))}_writeConditionalFormatting(){let e={styles:this._workbook.styles};Z.conditionalFormattings.prepare(this.conditionalFormatting,e),this.stream.write(Z.conditionalFormattings.toXml(this.conditionalFormatting))}_writeRowBreaks(){this.stream.write(Z.rowBreaks.toXml(this.rowBreaks))}_writeColBreaks(){this.stream.write(Z.colBreaks.toXml(this.colBreaks))}_writeDataValidations(){this.stream.write(Z.dataValidations.toXml(this.dataValidations.model))}_writeSheetProtection(){this.stream.write(Z.sheetProtection.toXml(this.sheetProtection))}_writePageMargins(){this.stream.write(Z.pageMargins.toXml(this.pageSetup.margins))}_writePageSetup(){this.stream.write(Z.pageSeteup.toXml(this.pageSetup))}_writeHeaderFooter(){this.stream.write(Z.headerFooter.toXml(this.headerFooter))}_writeAutoFilter(){this.stream.write(Z.autoFilter.toXml(this.autoFilter))}_writeBackground(){if(this._background){if(this._background.imageId!==void 0){let e=this._workbook.getImage(this._background.imageId),t=this._sheetRelsWriter.addMedia({Target:pa(e.name),Type:z.Image});this._background={...this._background,rId:t}}this.stream.write(Z.picture.toXml({rId:this._background.rId}))}}_writeLegacyData(){this.hasComments&&(X.reset(),X.addText(`<legacyDrawing r:id="${this._sheetCommentsWriter.vmlRelId}"/>`),this.stream.write(X))}_writeDimensions(){}_writeCloseWorksheet(){this._write(`</worksheet>`)}};let yp=new Uint8Array,bp=new TextDecoder;var xp=class{constructor(e,t){this.WorksheetWriterClass=t,this.created=e.created||new Date,this.modified=e.modified||this.created,this.creator=e.creator??`ExcelTS`,this.lastModifiedBy=e.lastModifiedBy??`ExcelTS`,this.lastPrinted=e.lastPrinted,this.useSharedStrings=e.useSharedStrings??!1,this.sharedStrings=new mp,this.styles=e.useStyles?new Zr(!0):new Zr.Mock(!0),this._definedNames=new cr,this._worksheets=[],this.views=[],this.zipOptions=e.zip;let n=e.zip?.zlib?.level??e.zip?.compressionOptions?.level??1;this.compressionLevel=Math.max(0,Math.min(9,n)),this.media=[],this.commentRefs=[],this._trueStreaming=e.trueStreaming??!1,this.zip=new qd((e,t,n)=>{e?this.stream.emit(`error`,e):(this.stream.write(t),n&&this.stream.end())}),this.stream=this._createOutputStream(e),this.promise=Promise.resolve()}_createOutputStream(e){return e.stream?Gf(e.stream):new pc}get definedNames(){return this._definedNames}_openStream(e){let t=new pc({bufSize:this._trueStreaming?4096:65536,batch:!this._trueStreaming}),n=new Kd(e,{level:this.compressionLevel});this.zip.add(n);let r=e=>n.push(e);return t.on(`data`,r),t.once(`finish`,()=>{t.removeListener(`data`,r),n.push(yp,!0),t.emit(`zipped`)}),t}_addFile(e,t,n){let r=new Kd(t,{level:this.compressionLevel});this.zip.add(r);let i;i=n?ut(typeof e==`string`?e:bp.decode(e)):typeof e==`string`?tn(e):e,r.push(i,!0)}_commitWorksheets(){let e=this._worksheets.map(e=>e.committed?Promise.resolve():new Promise(t=>{e.stream.once(`zipped`,()=>t()),e.commit()}));return e.length?Promise.all(e).then(()=>{}):Promise.resolve()}async commit(){await this.promise,await this._commitWorksheets(),await this.addMedia(),await Promise.all([this.addThemes(),this.addOfficeRels(),this.addContentTypes(),this.addApp(),this.addCore(),this.addSharedStrings(),this.addStyles(),this.addFeaturePropertyBag(),this.addWorkbookRels()]),await this.addWorkbook(),await this._finalize()}get nextId(){for(let e=1;e<this._worksheets.length;e++)if(!this._worksheets[e])return e;return this._worksheets.length||1}addImage(e){let t=this.media.length,n={...e,type:`image`,name:`image${t}.${e.extension}`};return this.media.push(n),t}getImage(e){return this.media[e]}addWorksheet(e,t){let n=t||{},r=n.useSharedStrings===void 0?this.useSharedStrings:n.useSharedStrings;n.tabColor&&(console.trace(`tabColor option has moved to { properties: tabColor: {...} }`),n.properties={tabColor:n.tabColor,...n.properties});let i=this.nextId;e??=`sheet${i}`;let a=new this.WorksheetWriterClass({id:i,name:e,workbook:this,useSharedStrings:r,properties:n.properties,state:n.state,pageSetup:n.pageSetup,views:n.views,autoFilter:n.autoFilter,headerFooter:n.headerFooter});return this._worksheets[i]=a,a}getWorksheet(e){if(e===void 0)return this._worksheets.find(()=>!0);if(typeof e==`number`)return this._worksheets[e];if(typeof e==`string`)return this._worksheets.find(t=>t?.name===e)}addStyles(){return new Promise(e=>{this._addFile(this.styles.xml,L.xlStyles),e()})}addThemes(){return new Promise(e=>{this._addFile(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
321
- <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"> <a:themeElements> <a:clrScheme name="Office"> <a:dk1> <a:sysClr val="windowText" lastClr="000000"/> </a:dk1> <a:lt1> <a:sysClr val="window" lastClr="FFFFFF"/> </a:lt1> <a:dk2> <a:srgbClr val="1F497D"/> </a:dk2> <a:lt2> <a:srgbClr val="EEECE1"/> </a:lt2> <a:accent1> <a:srgbClr val="4F81BD"/> </a:accent1> <a:accent2> <a:srgbClr val="C0504D"/> </a:accent2> <a:accent3> <a:srgbClr val="9BBB59"/> </a:accent3> <a:accent4> <a:srgbClr val="8064A2"/> </a:accent4> <a:accent5> <a:srgbClr val="4BACC6"/> </a:accent5> <a:accent6> <a:srgbClr val="F79646"/> </a:accent6> <a:hlink> <a:srgbClr val="0000FF"/> </a:hlink> <a:folHlink> <a:srgbClr val="800080"/> </a:folHlink> </a:clrScheme> <a:fontScheme name="Office"> <a:majorFont> <a:latin typeface="Cambria"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Times New Roman"/> <a:font script="Hebr" typeface="Times New Roman"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="MoolBoran"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Times New Roman"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:majorFont> <a:minorFont> <a:latin typeface="Calibri"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Arial"/> <a:font script="Hebr" typeface="Arial"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="DaunPenh"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Arial"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:minorFont> </a:fontScheme> <a:fmtScheme name="Office"> <a:fillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="35000"> <a:schemeClr val="phClr"> <a:tint val="37000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="15000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="1"/> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="100000"/> <a:shade val="100000"/> <a:satMod val="130000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:shade val="100000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="0"/> </a:gradFill> </a:fillStyleLst> <a:lnStyleLst> <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"> <a:shade val="95000"/> <a:satMod val="105000"/> </a:schemeClr> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> </a:lnStyleLst> <a:effectStyleLst> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="38000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> <a:scene3d> <a:camera prst="orthographicFront"> <a:rot lat="0" lon="0" rev="0"/> </a:camera> <a:lightRig rig="threePt" dir="t"> <a:rot lat="0" lon="0" rev="1200000"/> </a:lightRig> </a:scene3d> <a:sp3d> <a:bevelT w="63500" h="25400"/> </a:sp3d> </a:effectStyle> </a:effectStyleLst> <a:bgFillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="40000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="40000"> <a:schemeClr val="phClr"> <a:tint val="45000"/> <a:shade val="99000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="20000"/> <a:satMod val="255000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="-80000" r="50000" b="180000"/> </a:path> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="80000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="30000"/> <a:satMod val="200000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="50000" r="50000" b="50000"/> </a:path> </a:gradFill> </a:bgFillStyleLst> </a:fmtScheme> </a:themeElements> <a:objectDefaults> <a:spDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="1"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="3"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="2"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="lt1"/> </a:fontRef> </a:style> </a:spDef> <a:lnDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="2"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="0"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="1"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="tx1"/> </a:fontRef> </a:style> </a:lnDef> </a:objectDefaults> <a:extraClrSchemeLst/> </a:theme>`,L.xlTheme1),e()})}addOfficeRels(){return new Promise(e=>{let t=new I().toXml([{Id:`rId1`,Type:z.OfficeDocument,Target:L.xlWorkbook},{Id:`rId2`,Type:z.CoreProperties,Target:L.docPropsCore},{Id:`rId3`,Type:z.ExtenderProperties,Target:L.docPropsApp}]);this._addFile(t,L.rootRels),e()})}addContentTypes(){return new Promise(e=>{let t=this._worksheets.filter(Boolean);t.forEach(e=>{e.fileIndex=e.id});let n={worksheets:t,sharedStrings:this.sharedStrings,commentRefs:this.commentRefs,media:this.media,hasCheckboxes:this.styles.hasCheckboxes},r=new ga;this._addFile(r.toXml(n),L.contentTypes),e()})}addMedia(){return Promise.all(this.media.map(async e=>{if(e.type===`image`){let t=zi(e.name);if(e.buffer){this._addFile(e.buffer,t);return}if(e.base64){let n=e.base64.substring(e.base64.indexOf(`,`)+1);this._addFile(n,t,!0);return}if(e.filename)throw new v(`Loading images from filename`,`not supported in browser. Use buffer or base64.`)}throw new ne(`Unsupported media`)}))}addApp(){return new Promise(e=>{let t=new ya;this._addFile(t.toXml({worksheets:this._worksheets.filter(Boolean)}),L.docPropsApp),e()})}addCore(){return new Promise(e=>{let t=new $r;this._addFile(t.toXml(this),L.docPropsCore),e()})}addSharedStrings(){return this.sharedStrings.count?new Promise(e=>{let t=new ii;this._addFile(t.toXml(this.sharedStrings),L.xlSharedStrings),e()}):Promise.resolve()}addFeaturePropertyBag(){if(this.styles.hasCheckboxes){let e=new Zo;this._addFile(e.toXml({}),L.xlFeaturePropertyBag)}return Promise.resolve()}addWorkbookRels(){let e=1,t=[{Id:`rId${e++}`,Type:z.Styles,Target:na.workbookStyles},{Id:`rId${e++}`,Type:z.Theme,Target:na.workbookTheme1}];return this.sharedStrings.count&&t.push({Id:`rId${e++}`,Type:z.SharedStrings,Target:na.workbookSharedStrings}),this.styles.hasCheckboxes&&t.push({Id:`rId${e++}`,Type:z.FeaturePropertyBag,Target:na.workbookFeaturePropertyBag}),this._worksheets.forEach(n=>{n&&(n.rId=`rId${e++}`,t.push({Id:n.rId,Type:z.Worksheet,Target:Hi(n.id)}))}),new Promise(e=>{let n=new I;this._addFile(n.toXml(t),L.xlWorkbookRels),e()})}addWorkbook(){let e={worksheets:this._worksheets.filter(Boolean),definedNames:this._definedNames.model,views:this.views,properties:{},calcProperties:{}};return new Promise(t=>{let n=new Na;n.prepare(e),this._addFile(n.toXml(e),L.xlWorkbook),t()})}_finalize(){return new Promise((e,t)=>{let n=e=>{this.stream.removeListener(`finish`,r),t(e)},r=()=>{this.stream.removeListener(`error`,n),e(this)};this.stream.once(`error`,n),this.stream.once(`finish`,r),this.zip.end()})}},Sp=class extends xp{constructor(e={}){super(e,vp)}},Cp=class{constructor(e){this.searchFrom=0,this.pattern=e,this.overlap=Math.max(0,e.length-1)}find(e){return e.indexOfPattern(this.pattern,this.searchFrom)}onConsume(e){e>0&&(this.searchFrom=Math.max(0,this.searchFrom-e))}onNoMatch(e){this.searchFrom=Math.max(this.searchFrom,Math.max(0,e-this.overlap))}};let wp=[[`version`,4],[`pubKeyLength`,4],[`signatureLength`,4]],Tp=[[`versionsNeededToExtract`,2],[`flags`,2],[`compressionMethod`,2],[`lastModifiedTime`,2],[`lastModifiedDate`,2],[`crc32`,4],[`compressedSize`,4],[`uncompressedSize`,4],[`fileNameLength`,2],[`extraFieldLength`,2]],Ep=[[`dataDescriptorSignature`,4],[`crc32`,4],[`compressedSize`,4],[`uncompressedSize`,4]],Dp=[[`versionMadeBy`,2],[`versionsNeededToExtract`,2],[`flags`,2],[`compressionMethod`,2],[`lastModifiedTime`,2],[`lastModifiedDate`,2],[`crc32`,4],[`compressedSize`,4],[`uncompressedSize`,4],[`fileNameLength`,2],[`extraFieldLength`,2],[`fileCommentLength`,2],[`diskNumber`,2],[`internalFileAttributes`,2],[`externalFileAttributes`,4],[`offsetToLocalFileHeader`,4]],Op=[[`diskNumber`,2],[`diskStart`,2],[`numberOfRecordsOnDisk`,2],[`numberOfRecords`,2],[`sizeOfCentralDirectory`,4],[`offsetToStartOfCentralDirectory`,4],[`commentLength`,2]],kp=zl(Gu);function Ap(e){return((e||0)&Ju)!==0}function jp(e){if(e.length===0)return!1;let t=e.charCodeAt(e.length-1);return t===47||t===92}function Mp(e,t){return t===0&&jp(e)?`Directory`:`File`}function Np(e,t,n){return{path:e,pathBuffer:t,flags:{isUnicode:Ap(n)}}}function Pp(e,t){let n=e.lastModifiedDate||0,r=e.lastModifiedTime||0,i=Ru(n,r),a=t.mtimeUnixSeconds;return a===void 0?i:zu(n,r,a)}let Fp=bd;function Ip(e){return((e||0)&8)!=0}function Lp(e,t){return!Ip(e)||(t||0)>0}async function Rp(e){let t=await e(12),n=t.length>=12?Kp(t):Ul(t,wp),r=n.pubKeyLength||0,i=await e(r+(n.signatureLength||0));return n.publicKey=i.subarray(0,r),n.signature=i.subarray(r),n}async function zp(e){let t=await e(26),n=t.length>=26?qp(t):Ul(t,Tp);return{vars:n,fileNameBuffer:await e(n.fileNameLength||0),extraFieldData:await e(n.extraFieldLength||0)}}async function Bp(e){let t=await e(16);return t.length>=16?Jp(t):Ul(t,Ep)}async function Vp(e){let t=Ul(await e(42),Dp);await e(t.fileNameLength||0),await e(t.extraFieldLength||0),await e(t.fileCommentLength||0)}async function Hp(e){await e(Ul(await e(18),Op).commentLength||0)}function Up(e){switch(e){case Hu:case Uu:case Wu:case Ku:case qu:return!0;default:return!1}}function Wp(e,t){return(e[t]|0|(e[t+1]|0)<<8|(e[t+2]|0)<<16|(e[t+3]|0)<<24)>>>0}function Gp(e,t){return(e[t]|(e[t+1]|0)<<8)>>>0}function Kp(e){return{version:Wp(e,0),pubKeyLength:Wp(e,4),signatureLength:Wp(e,8)}}function qp(e){return{versionsNeededToExtract:Gp(e,0),flags:Gp(e,2),compressionMethod:Gp(e,4),lastModifiedTime:Gp(e,6),lastModifiedDate:Gp(e,8),crc32:Wp(e,10),compressedSize:Wp(e,14),uncompressedSize:Wp(e,18),fileNameLength:Gp(e,22),extraFieldLength:Gp(e,24)}}function Jp(e){return{dataDescriptorSignature:Wp(e,0),crc32:Wp(e,4),compressedSize:Wp(e,8),uncompressedSize:Wp(e,12)}}let Yp=zl(Wu);async function Xp(e,t,n,r,i){for(;;){let a=await t.pull(4);if(a.length===0){n.emitClose();return}let o=Bl(a,0);if(o===875721283){r.crxHeader=await Rp(async e=>t.pull(e)),n.emitCrxHeader(r.crxHeader);continue}if(o===67324752){await i(e,t,n,r);continue}if(o===33639248){r.reachedCD=!0,await Vp(async e=>t.pull(e));continue}if(o===101010256){await Hp(async e=>t.pull(e)),t.setDone(),n.emitClose();return}if(r.reachedCD){await t.pullUntil(Yp,!0),await Hp(async e=>t.pull(e)),t.setDone(),n.emitClose();return}n.emitError(Error(`invalid signature: 0x`+o.toString(16))),n.emitClose();return}}let Zp=256*1024;function Qp(e){let t=e.pipe(new Yf({transform(e,t,n){n()}}));return t.promise=()=>new Promise((e,n)=>{t.on(`finish`,e),t.on(`error`,n)}),t}function $p(e){return new Promise((t,n)=>{let r=[],i=new Yf({transform(e,t,n){r.push(e),n()}});i.on(`finish`,()=>{t(r.length===1?r[0]:O(r))}),i.on(`error`,n),e.on(`error`,n).pipe(i)})}function em(e){let{source:t,dataDescriptorSignature:n}=e,r=e.keepTailBytes??20,i=e.errorMessage??`FILE_ENDED: Data descriptor not found`,a=new Xf({highWaterMark:Zp}),o=!1,s=!1,c=0,l=new Cp(n),u,d=()=>{u&&=(u(),void 0)},f=()=>{s=!1,p()},p=()=>{if(o||s)return;let e=t.getLength();for(e===0&&t.maybeReleaseWriteCallback?.();e>0;){for(;;){let n=l.find(t);if(n===-1)break;let r=n+16;if(r+4<=e){let e=t.peekUint32LE(r),i=t.peekUint32LE(n+8),u=c+n>>>0;if(e!==null&&i!==null&&Up(e)&&i===u){if(n>0)if(t.peekChunks&&t.discard){let e=t.peekChunks(n),r=0;for(let t of e){let e=a.write(t);if(r+=t.length,!e){s=!0,a.once(`drain`,f);break}}if(r>0&&(t.discard(r),c+=r,l.onConsume(r)),s)return}else{let e=a.write(t.read(n));if(c+=n,l.onConsume(n),!e){s=!0,a.once(`drain`,f);return}}o=!0,t.maybeReleaseWriteCallback?.(),d(),a.end();return}l.searchFrom=n+1;continue}l.searchFrom=n;break}l.onNoMatch(e);let n=Math.max(0,e-r);if(n>0){if(t.peekChunks&&t.discard){let i=t.peekChunks(n),o=0;for(let e of i){let t=a.write(e);if(o+=e.length,!t){s=!0,a.once(`drain`,f);break}}o>0&&(t.discard(o),c+=o,e-=o,l.onConsume(o)),e<=r&&t.maybeReleaseWriteCallback?.();return}let i=a.write(t.read(n));c+=n,e-=n,l.onConsume(n),e<=r&&t.maybeReleaseWriteCallback?.(),i||(s=!0,a.once(`drain`,f));return}t.maybeReleaseWriteCallback?.();break}!o&&t.isFinished()&&(o=!0,d(),a.destroy(Error(i)))};return u=t.onDataAvailable(p),queueMicrotask(p),a}async function tm(e,t,n,r,i,a){let o=e.thresholdBytes??5242880;await Xp(e,t,n,i,async(s,c,l,u)=>{await rm(e,t,n,r,i,o,a)})}async function nm(e,t,n,r){let i=r,a=null,o=e=>{a=e};t.once(`error`,o),n.once(`error`,o);let s=!1,c=t,l=null,u=()=>{try{c?.removeListener?.(`drain`,f)}catch{}try{n.removeListener(`__autodrain`,p)}catch{}try{n.removeListener(`close`,m)}catch{}},d=()=>{let e=l;e&&(l=null,u(),e())},f=()=>{d()},p=()=>{d()},m=()=>{d()},h=async()=>{await new Promise(e=>{l=e,typeof c?.once==`function`&&c.once(`drain`,f),n.once(`__autodrain`,p),n.once(`close`,m),(n.__autodraining||n.destroyed)&&d()})},g=async()=>{if(!s){s=!0;try{let e=t;typeof e.unpipe==`function`&&e.unpipe(n)}catch{}try{!n.writableEnded&&!n.destroyed&&n.end()}catch{}try{let e=t;typeof e.destroy==`function`&&e.destroy()}catch{}}};try{for(t.pipe(n);i>0;){if(a)throw a;!s&&(n.__autodraining||n.destroyed)&&await g();let r=Math.min(262144,i),o=await e.pull(r);if(o.length!==r)throw Error(`FILE_ENDED`);i-=o.length,s||t.write(o)||await h()}s||t.end(),await sp(n,{readable:!1})}finally{t.removeListener(`error`,o),n.removeListener(`error`,o)}}async function rm(e,t,n,r,i,a,o){let{vars:s,fileNameBuffer:c,extraFieldData:l}=await zp(async e=>t.pull(e)),u=s;i.crxHeader&&(u.crxHeader=i.crxHeader);let d={uncompressedSize:u.uncompressedSize??0,compressedSize:u.compressedSize??0},f=Fp(l,d);u.uncompressedSize=d.uncompressedSize,u.compressedSize=d.compressedSize;let p=e.encoding?Ml(e.encoding):void 0,m=Il(c,u.flags,f,p),h=new Xf({highWaterMark:Zp}),g=!1;h.autodrain=function(){return g=!0,h.__autodraining=!0,h.emit(`__autodrain`),Qp(h)},h.buffer=function(){return $p(h)},h.path=m,h.props=Np(m,c,u.flags),h.type=Mp(m,u.uncompressedSize??0),e.verbose&&(h.type===`Directory`?console.log(` creating:`,m):h.type===`File`&&(u.compressionMethod===0?console.log(` extracting:`,m):console.log(` inflating:`,m))),u.lastModifiedDateTime=Pp({flags:u.flags,uncompressedSize:u.uncompressedSize??0,lastModifiedDate:u.lastModifiedDate,lastModifiedTime:u.lastModifiedTime},f),h.vars=u,h.extraFields=f,h.__autodraining=g;let _=Lp(u.flags,u.compressedSize);_&&(h.size=u.uncompressedSize??0),e.forceStream?n.pushEntry(h):(n.emitEntry(h),n.pushEntryIfPiped(h)),e.verbose&&console.log({filename:m,vars:u,extraFields:h.extraFields});let v=((u.flags??0)&1)!=0||u.compressionMethod===99,y=u.compressionMethod!==0&&!v&&!g,b=!Ip(u.flags),ee=u.compressedSize??0,x=u.uncompressedSize??0;if(b&&_&&o&&y&&ee<=a&&x<=a){let e=o(await t.pull(ee));h.end(e),await sp(h,{readable:!1});return}let te=y?r():new Xf({highWaterMark:Zp});if(_){if(await nm(t,te,h,u.compressedSize??0),Ip(u.flags)){let e=await Bp(async e=>t.pull(e));h.size||=e.uncompressedSize??0}return}await op(t.streamUntilDataDescriptor(),te,h),h.size=(await Bp(async e=>t.pull(e))).uncompressedSize??0}var im=class extends Jf{constructor(){super({writableHighWaterMark:512*1024,readableHighWaterMark:512*1024,write:(e,t,n)=>{this._doWrite(e,n)},final:e=>{this._closeWriter(()=>{e()})}}),this.reading=!1,this.writeClosed=!1,this._junkError=!1,this._bytesIn=0,this._bytesOut=0,this._readingDone=!1,this._pendingWrites=0,this._writeFinishedPromise=null,this._resolveWriteFinished=null,this.decompressionStream=new DecompressionStream(`deflate-raw`),this.writer=this.decompressionStream.writable.getWriter(),this.reader=this.decompressionStream.readable.getReader(),this._readingDonePromise=new Promise(e=>{this._resolveReadingDone=e}),this._startReading()}_doWrite(e,t){if(this._junkError){t&&t();return}this._bytesIn+=e.length,this._pendingWrites++,this.writer.write(e).then(()=>{this._pendingWrites--,this._pendingWrites===0&&this._resolveWriteFinished&&this._resolveWriteFinished(),t&&t()}).catch(e=>{this._pendingWrites--,this._pendingWrites===0&&this._resolveWriteFinished&&this._resolveWriteFinished();let n=e instanceof Error?e.message:String(e);n.includes(`Junk`)||n.includes(`junk`)?(this._junkError=!0,t&&t()):t?t(e):this.emit(`error`,e)})}async _startReading(){if(!this.reading){this.reading=!0;try{for(;;){let{done:e,value:t}=await this.reader.read();if(e)break;this._bytesOut+=t.length,this.push(t)}}catch(e){let t=e instanceof Error?e.message:String(e);t.includes(`Junk`)||t.includes(`junk`)?this._junkError=!0:this.emit(`error`,e)}finally{this._readingDone=!0,this._resolveReadingDone(),this.push(null)}}}_closeWriter(e){if(this.writeClosed){this._readingDonePromise.then(()=>{e&&e()});return}this.writeClosed=!0,(this._pendingWrites>0?new Promise(e=>{this._writeFinishedPromise=new Promise(e=>{this._resolveWriteFinished=e}),this._writeFinishedPromise.then(e)}):Promise.resolve()).then(()=>this.writer.close()).catch(()=>{}).finally(()=>{this._readingDonePromise.then(()=>{e&&e()})})}destroy(e){return this.writeClosed||this.writer.abort(e??void 0).catch(()=>{}),this.reader.cancel(e??void 0).catch(()=>{}),super.destroy(e??void 0)}};let am=null;function om(e){if(typeof e==`string`&&e.length>0)return e;if(am)return am;let t=new Blob([`
318
+ `}let gl=null,_l=0;function vl(){if(gl===null){let e=hl(),t=new Blob([e],{type:`text/javascript`});gl=URL.createObjectURL(t)}return _l++,gl}function yl(){if(gl!==null&&--_l<=0){try{URL.revokeObjectURL(gl)}catch{}gl=null,_l=0}}let bl=new Uint8Array,xl={onData:e=>{},onEnd:()=>{},onError:e=>{}};function Sl(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength}function Cl(e){return Sl(e)?e:e.slice()}var wl=class{_taskQueueSize(){return this._taskQueue.length-this._taskQueueHead}_compactTaskQueueIfNeeded(){this._taskQueueHead>32&&this._taskQueueHead*2>=this._taskQueue.length&&(this._taskQueue.splice(0,this._taskQueueHead),this._taskQueueHead=0)}_dequeueTask(){if(this._taskQueueHead>=this._taskQueue.length)return;let e=this._taskQueue[this._taskQueueHead++];return this._compactTaskQueueIfNeeded(),e}_compactPendingStreamRequestsIfNeeded(){this._pendingStreamRequestHead>32&&this._pendingStreamRequestHead*2>=this._pendingStreamRequests.length&&(this._pendingStreamRequests.splice(0,this._pendingStreamRequestHead),this._pendingStreamRequestHead=0)}_dequeuePendingStreamRequest(){if(this._pendingStreamRequestHead>=this._pendingStreamRequests.length)return;let e=this._pendingStreamRequests[this._pendingStreamRequestHead++];return this._compactPendingStreamRequestsIfNeeded(),e}_waitForStreamSlot(e){return e.slotWaitPromise||=new Promise(t=>{e.resolveSlotWait=()=>{e.slotWaitPromise=null,e.resolveSlotWait=null,t()}}),e.slotWaitPromise}_waitForStreamDrain(e){return e.drainWaitPromise||=new Promise(t=>{e.resolveDrainWait=()=>{e.drainWaitPromise=null,e.resolveDrainWait=null,t()}}),e.drainWaitPromise}_resolveSlotWaiter(e){e.resolveSlotWait?.()}_resolveDrainWaiter(e){e.resolveDrainWait?.()}constructor(e){this._workers=new Map,this._taskQueue=[],this._taskQueueHead=0,this._pendingTasks=new Map,this._nextTaskId=1,this._nextWorkerId=1,this._terminated=!1,this._completedTasks=0,this._failedTasks=0,this._pendingStreamRequests=[],this._pendingStreamRequestHead=0,this._options=dl(e),this._options.workerUrl?(this._workerUrl=this._options.workerUrl,this._useCustomUrl=!0):(this._workerUrl=vl(),this._useCustomUrl=!1);for(let e=0;e<this._options.minWorkers;e++)this._createWorker()}async execute(e,t,n){if(this._terminated)throw Error(`Worker pool has been terminated`);if(!ml())throw Error(`Web Workers are not supported in this environment`);if(n?.signal?.aborted)throw r();let i=this._nextTaskId++,a=n?.priority??`normal`,o=pl(a);return new Promise((r,s)=>{let c={taskId:i,taskType:e,data:t,level:n?.level,priority:a,priorityValue:o,resolve:r,reject:s,signal:n?.signal,allowTransfer:n?.allowTransfer,startTime:performance.now()};n?.signal&&(c.abortHandler=()=>{this._cancelTask(i)},n.signal.addEventListener(`abort`,c.abortHandler,{once:!0})),this._pendingTasks.set(i,c),this._enqueueTask(c),this._processQueue()})}getStats(){let e=this._workers.size,t=0;for(let e of this._workers.values())e.busy&&t++;return{totalWorkers:e,activeWorkers:t,idleWorkers:e-t,pendingTasks:this._taskQueueSize(),completedTasks:this._completedTasks,failedTasks:this._failedTasks}}terminate(){if(this._terminated)return;this._terminated=!0;for(let e of this._workers.values())this._terminateWorker(e);this._workers.clear();let e=Error(`Worker pool terminated`);for(let t of this._pendingTasks.values())this._cleanupTask(t),t.reject(e);this._pendingTasks.clear(),this._taskQueue.length=0,this._taskQueueHead=0,this._pendingStreamRequests.length=0,this._pendingStreamRequestHead=0,this._useCustomUrl||yl()}isTerminated(){return this._terminated}_createWorker(){if(this._terminated||this._workers.size>=this._options.maxWorkers)return null;let e=this._nextWorkerId++,t=new Worker(this._workerUrl),n={id:e,worker:t,busy:!1,currentTaskId:null,idleTimer:null,streamSession:null};return t.onmessage=e=>{this._handleWorkerMessage(n,e.data)},t.onerror=e=>{this._handleWorkerError(n,e)},this._workers.set(e,n),n}_terminateWorker(e){this._clearIdleTimer(e);try{e.worker.postMessage({type:`terminate`})}catch{}try{e.worker.terminate()}catch{}this._workers.delete(e.id)}_clearIdleTimer(e){e.idleTimer!==null&&(clearTimeout(e.idleTimer),e.idleTimer=null)}_findIdleWorker(){for(let e of this._workers.values())if(!e.busy)return e}_enqueueTask(e){let t=this._taskQueue,n=e.priorityValue;this._compactTaskQueueIfNeeded();let r=this._taskQueueHead,i=t.length;for(;r<i;){let e=r+i>>>1;t[e].priorityValue>=n?r=e+1:i=e}t.splice(r,0,e)}_processQueue(){for(;!this._terminated&&this._taskQueueSize()>0;){let e=this._findIdleWorker()??this._createWorker()??void 0;if(!e)return;for(;;){let t=this._dequeueTask();if(!t)return;if(t.signal?.aborted){this._pendingTasks.delete(t.taskId),this._cleanupTask(t),t.reject(r());continue}this._assignTask(e,t);break}}}_assignTask(e,t){this._clearIdleTimer(e),e.busy=!0,e.currentTaskId=t.taskId;let n=this._options.useTransferables&&t.allowTransfer===!0,r=n?Cl(t.data):t.data,i={type:`task`,taskId:t.taskId,taskType:t.taskType,data:r,level:t.level};n?e.worker.postMessage(i,[r.buffer]):e.worker.postMessage(i)}_handleWorkerMessage(e,t){if(t.type!==`ready`){if(e.streamSession){let n=e.streamSession;switch(t.type){case`started`:if(t.taskId!==n.taskId)return;n.startReady=!0,n.resolveStart?.(),n.resolveStart=null,n.rejectStart=null;return;case`out`:if(t.taskId!==n.taskId)return;n.onData(t.data);return;case`ack`:if(t.taskId!==n.taskId)return;n.inflightChunkCount>0&&n.inflightChunkCount--,this._resolveSlotWaiter(n),n.inflightChunkCount===0&&n.resolveDrainWait&&this._resolveDrainWaiter(n);return;case`done`:if(t.taskId!==n.taskId)return;n.ended=!0,n.inflightChunkCount=0,n.startReady=!0,n.resolveStart?.(),n.resolveStart=null,n.rejectStart=null,this._resolveSlotWaiter(n),this._resolveDrainWaiter(n),this._completedTasks++,t.duration??performance.now()-n.startTime,n.onEnd(),e.streamSession=null,this._workerBecameIdle(e);return;case`error`:{if(t.taskId!==n.taskId)return;let r=Error(t.error??`Unknown worker error`);n.ended=!0,n.inflightChunkCount=0,n.startReady=!0,n.rejectStart?.(r),n.resolveStart=null,n.rejectStart=null,this._resolveSlotWaiter(n),this._resolveDrainWaiter(n),this._failedTasks++,n.onError(r),e.streamSession=null,this._workerBecameIdle(e);return}default:break}}switch(t.type){case`result`:case`error`:{let n=t.taskId;if(typeof n!=`number`)return;let r=this._pendingTasks.get(n);if(!r){this._workerBecameIdle(e);return}if(this._pendingTasks.delete(n),this._cleanupTask(r),t.type===`result`){this._completedTasks++;let e=t.duration??performance.now()-r.startTime;r.resolve({data:t.data,duration:e})}else this._failedTasks++,r.reject(Error(t.error??`Unknown worker error`));this._workerBecameIdle(e);return}default:return}}}_handleWorkerError(e,t){let n=e.currentTaskId;if(this._terminateWorker(e),n!==null){let e=this._pendingTasks.get(n);e&&(this._pendingTasks.delete(n),this._cleanupTask(e),this._failedTasks++,e.reject(Error(t.message||`Worker error`)))}this._processQueue()}_workerBecameIdle(e){if(e.busy=!1,e.currentTaskId=null,this._pendingStreamRequestHead<this._pendingStreamRequests.length){let t=this._dequeuePendingStreamRequest();if(t){t(e);return}}this._taskQueueSize()>0?this._processQueue():this._workers.size>this._options.minWorkers&&this._options.idleTimeout>0&&(e.idleTimer=setTimeout(()=>{!e.busy&&this._workers.size>this._options.minWorkers&&!this._terminated&&this._terminateWorker(e)},this._options.idleTimeout))}openStream(e,t=xl){if(this._terminated)throw Error(`Worker pool has been terminated`);if(!ml())throw Error(`Web Workers are not supported in this environment`);let n=this._nextTaskId++,r=t.allowTransfer===!0,i=this._options.useTransferables&&r,a=i?Cl:e=>e,o=i?(e,t,n)=>{e.postMessage(t,[n.buffer])}:(e,t,n)=>{e.postMessage(t)},s=null,c=null,l=async()=>{if(s)return s;if(c)return c;c=(async()=>{let r=this._findIdleWorker()??this._createWorker()??void 0;return r?(s=r,this._bindStreamSession(s,n,e,t.level,t),this._startStreamSession(s),s):(s=await new Promise(e=>{this._pendingStreamRequests.push(e)}),this._bindStreamSession(s,n,e,t.level,t),this._startStreamSession(s),s)})();try{return await c}finally{c=null}};l();let u=(e,t,n)=>{let r=a(n),i=t.chunkMessage;i.data=r,o(e.worker,i,r)},d=(e,t,n)=>{if(t.inflightChunkCount>=8)return this._waitForStreamSlot(t).then(()=>{t.ended||(t.inflightChunkCount++,u(e,t,n))});t.inflightChunkCount++,u(e,t,n)};return{write:async e=>{if(e.byteLength===0)return;let t=s??await l(),n=t.streamSession;if(!n||n.ended)throw Error(`Streaming session is not active`);n.writeChain=n.writeChain.then(()=>{if(!n.ended)return n.startReady?d(t,n,e):n.startPromise.then(()=>{if(!n.ended)return d(t,n,e)})}),await n.writeChain},end:async()=>{let e=await l(),t=e.streamSession;!t||t.ended||(t.startReady||await t.startPromise,await t.writeChain,t.inflightChunkCount>0&&await this._waitForStreamDrain(t),t.ended=!0,e.worker.postMessage(t.endMessage))},abort:e=>{l().then(t=>{let n=t.streamSession;if(!n)return;let r=n.abortMessage;r.error=e,t.worker.postMessage(r)})}}}_bindStreamSession(e,t,n,r,i){this._clearIdleTimer(e),e.busy=!0,e.currentTaskId=t;let a=null,o=null,s=new Promise((e,t)=>{a=e,o=t}),c=setTimeout(()=>{o?.(Error(`Worker stream start timeout`))},5e3);s.finally(()=>clearTimeout(c)),e.streamSession={taskId:t,taskType:n,startTime:performance.now(),started:!1,startReady:!1,startPromise:s,resolveStart:a,rejectStart:o,level:r,writeChain:Promise.resolve(),inflightChunkCount:0,slotWaitPromise:null,resolveSlotWait:null,drainWaitPromise:null,resolveDrainWait:null,chunkMessage:{type:`chunk`,taskId:t,data:bl},startMessage:{type:`start`,taskId:t,taskType:n,level:r},endMessage:{type:`end`,taskId:t},abortMessage:{type:`abort`,taskId:t,error:void 0},ended:!1,onData:i.onData,onEnd:i.onEnd,onError:i.onError}}_startStreamSession(e){let t=e.streamSession;!t||t.started||(t.started=!0,e.worker.postMessage(t.startMessage))}_cancelTask(e){let t=this._pendingTasks.get(e);if(!t)return;this._pendingTasks.delete(e),this._cleanupTask(t);let n=-1;for(let t=this._taskQueueHead;t<this._taskQueue.length;t++)if(this._taskQueue[t].taskId===e){n=t;break}n>=0&&this._taskQueue.splice(n,1),t.reject(r())}_cleanupTask(e){e.abortHandler&&e.signal&&e.signal.removeEventListener(`abort`,e.abortHandler)}async executeBatch(e){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];t[n]=this.execute(r.taskType,r.data,r.options)}return Promise.all(t)}};let Tl=null;function El(e){return(!Tl||Tl.isTerminated())&&(Tl=new wl(e)),Tl}async function Dl(e,t){return(await El().execute(`inflate`,e,t)).data}let Ol=`ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\xA0`;function kl(e){let t=!1;for(let n=0;n<e.length;n++)if(e[n]>=128){t=!0;break}if(!t)return Ll(e);let n=Array(e.length);for(let t=0;t<e.length;t++){let r=e[t];r<128?n[t]=String.fromCharCode(r):n[t]=Ol[r-128]}return n.join(``)}function Al(e){if(e.length===0)return G;let t=new Uint8Array(e.length),n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r),a=i;if(i>=55296&&i<=56319&&r+1<e.length){let t=e.charCodeAt(r+1);t>=56320&&t<=57343&&(a=(i-55296<<10)+(t-56320)+65536,r++)}if(a<128){t[n++]=a;continue}if(a>65535){t[n++]=63;continue}let o=jl.get(String.fromCharCode(a));t[n++]=o??63}return n===t.length?t:t.subarray(0,n)}let jl=(()=>{let e=new Map;for(let t=0;t<128;t++)e.set(Ol[t],128+t);return e})(),Ml={name:`utf-8`,encode:tn,decode:nn,useUtf8Flag:!0,useUnicodeExtraFields:!1},Nl={name:`cp437`,encode:Al,decode:kl,useUtf8Flag:!1,useUnicodeExtraFields:!0},Pl=new WeakMap;function Fl(e){if(!e||e===`utf-8`)return Ml;if(e===`cp437`)return Nl;let t=e,n=Pl.get(t);if(n)return n;let r=t.useUtf8Flag??t.name===`utf-8`,i={...t,useUtf8Flag:r,useUnicodeExtraFields:t.useUnicodeExtraFields??!r};return Pl.set(t,i),i}function Il(e,t){return e?t.encode(e):G}function Ll(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n){let i=e.subarray(r,Math.min(r+n,e.length));t+=String.fromCharCode(...i)}return t}function Rl(e,t,n,r){return e.length===0?``:(t??0)&2048?nn(e):n&&n.version===1&&n.originalCrc32===Sc(e)?n.unicodeValue:r?r.decode(e):kl(e)}function zl(e,t,n,r){return Rl(e,t,n?.unicodePath,r)}function Bl(e,t,n,r){return Rl(e,t,n?.unicodeComment,r)}function Vl(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer.constructor===ArrayBuffer?e.buffer:e.slice().buffer}function Hl(e){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e>>>0,!0),t}function Ul(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(t,!0)}var Wl=class{constructor(e,t=0){this.data=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.offset=t}get position(){return this.offset}set position(e){this.offset=e}get remaining(){return this.data.length-this.offset}readUint8(){let e=this.view.getUint8(this.offset);return this.offset+=1,e}readUint16(){let e=this.view.getUint16(this.offset,!0);return this.offset+=2,e}readUint32(){let e=this.view.getUint32(this.offset,!0);return this.offset+=4,e}readBigUint64(){let e=this.view.getBigUint64(this.offset,!0);return this.offset+=8,e}readBytes(e){let t=this.data.subarray(this.offset,this.offset+e);return this.offset+=e,t}readString(e,t=!0){let n=this.readBytes(e);return t?nn(n):kl(n)}skip(e){this.offset+=e}slice(e,t){return this.data.subarray(e,t)}peekUint32(e){return this.view.getUint32(e,!0)}};function Gl(e,t){let n={},r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=0;for(let[a,o]of t){if(e.length>=i+o)switch(o){case 1:n[a]=r.getUint8(i);break;case 2:n[a]=r.getUint16(i,!0);break;case 4:n[a]=r.getUint32(i,!0);break;case 8:{let e=r.getUint32(i,!0);n[a]=r.getUint32(i+4,!0)*4294967296+e;break}default:throw Error(`Unsupported UInt LE size!`)}else n[a]=null;i+=o}return n}function Kl(e,t){return Gl(e,t)}function ql(e,t){let n=ml();if(t.useWorker===!0)return n;if(t.useWorker===!1)return!1;let r=t.autoWorkerThreshold??1048576;return n&&e.length>=r}function Jl(e,t){if(t?.aborted||i(e))throw r(t?.reason??e)}let Yl={hasNative:Zc,native:tl,worker:Dl,jsFallback:Pc};async function Xl(e,t,n){let r=e.hasNative(),i=ml(),a=n.useWorker;if(a===!0&&i)try{return await e.worker(t,{level:n.level,signal:n.signal,allowTransfer:n.allowTransfer})}catch(e){Jl(e,n.signal)}return r?e.native(t):a!==!0&&ql(t,n)?e.worker(t,{level:n.level,signal:n.signal,allowTransfer:n.allowTransfer}):e.jsFallback(t)}async function Zl(e,t={}){return Xl(Yl,e,t)}function Ql(e){return Pc(e)}new Uint8Array([31,139,8,0,0,0,0,0,0,255]);let $l=`write after end`;function eu(e,t,n){let r=a(t);n?n(r):e.emit(`error`,r)}var tu=class extends W{constructor(...e){super(...e),this.ended=!1,this.destroyed=!1,this.writeChain=Promise.resolve(),this._backend=null}setBackend(e){this._backend=e}write(e,t){if(this.ended)return eu(this,Error($l),t),!1;if(e.byteLength===0)return t&&queueMicrotask(t),!0;let n=this._backend;if(!n)throw Error(`Backend not initialized`);let r=this.writeChain.then(()=>n.write(e));return this.writeChain=r,r.then(()=>{this.destroyed||t?.()}).catch(e=>{this.destroyed||eu(this,e,t)}),!0}end(e){if(this.ended){e?.();return}this.ended=!0;let t=this._backend;if(!t)throw Error(`Backend not initialized`);this.writeChain.then(()=>t.close()).then(()=>e?.()).catch(t=>eu(this,t,e))}destroy(e){this.ended=!0,this.destroyed=!0,this._backend?.abort(e),e&&this.emit(`error`,e)}};function nu(e,t){let n=t?new CompressionStream(e):new DecompressionStream(e),r=n.writable.getWriter(),i=n.readable.getReader(),o=new tu,s=null,c=(async()=>{try{for(;;){let{value:e,done:t}=await i.read();if(t)break;e&&o.emit(`data`,e)}o.emit(`end`)}catch(e){let t=a(e);s=t,o.emit(`error`,t)}})();return o.setBackend({write:e=>r.write(e),close:async()=>{if(await r.close(),await c,s)throw s},abort:e=>{i.cancel(e).catch(()=>{}),r.abort(e).catch(()=>{})}}),o}function ru(e,t,n,r){let i=t??El(),a=null,o=null,s=new Promise((e,t)=>{a=e,o=t}),c=new tu,l=i.openStream(e,{level:n,allowTransfer:r,onData:e=>c.emit(`data`,e),onEnd:()=>{c.emit(`end`),a?.()},onError:e=>{c.emit(`error`,e),o?.(e)}});return c.setBackend({write:e=>l.write(e),close:async()=>{await l.end(),await s},abort:e=>{a?.(),l.abort(e?.message)}}),c}var iu=class extends W{constructor(e){super(),this.process=e,this.chunks=[],this.ended=!1}write(e,t){return this.ended?(eu(this,Error($l),t),!1):e.byteLength===0?(t&&queueMicrotask(t),!0):(this.chunks.push(e),t&&queueMicrotask(t),!0)}end(e){if(this.ended){e?.();return}this.ended=!0;let t=this.chunks.length,n=t===0?G:t===1?this.chunks[0]:O(this.chunks);this.chunks.length=0;try{let t=this.process(n);this.emit(`data`,t),this.emit(`end`),e?.()}catch(t){eu(this,t,e)}}destroy(e){this.ended=!0,this.chunks.length=0,e&&this.emit(`error`,e)}};function au(e,t){let n=e===`deflate`?t.level??6:void 0;return t.useWorker&&ml()?ru(e,t.workerPool,n,t.allowTransfer):Qc()?nu(`deflate-raw`,e===`deflate`):new iu(e===`deflate`?Ic:Pc)}function ou(e={}){return au(`deflate`,e)}function su(e){let t={key0:305419896,key1:591751049,key2:878082192},n=typeof e==`string`?tn(e):e;for(let e=0;e<n.length;e++)cu(t,n[e]);return t}function cu(e,t){e.key0=Cc(e.key0,t),e.key1=e.key1+(e.key0&255)>>>0,e.key1=(Math.imul(e.key1,134775813)>>>0)+1>>>0,e.key2=Cc(e.key2,e.key1>>>24&255)}function lu(e){let t=(e.key2|2)>>>0;return Math.imul(t,t^1)>>>8&255}function uu(e,t){let n=(t^lu(e))&255;return cu(e,n),n}function du(e,t){let n=(t^lu(e))&255;return cu(e,t),n}function fu(e,t,n,r){if(t.length!==12)return!1;let i=new Uint8Array(12);for(let n=0;n<12;n++)i[n]=uu(e,t[n]);let a=i[11];return a===(n>>>24&255)||r!==void 0&&a===(r>>>8&255)}function pu(e,t,n){let r=new Uint8Array(12),i=n(11);for(let t=0;t<11;t++)r[t]=du(e,i[t]);return r[11]=du(e,t>>>24&255),r}function mu(e,t,n,r){if(e.length<12)return null;let i=su(t);if(!fu(i,e.subarray(0,12),n,r))return null;let a=e.length-12,o=new Uint8Array(a);for(let t=0;t<a;t++)o[t]=uu(i,e[12+t]);return o}let hu={128:8,192:12,256:16},gu={128:16,192:24,256:32},_u={128:1,192:2,256:3},vu={1:128,2:192,3:256};function yu(){if(globalThis.crypto?.subtle!==void 0)return globalThis.crypto.subtle;throw Error(`Web Crypto API not available`)}function bu(e){if(globalThis.crypto?.getRandomValues!==void 0)return globalThis.crypto.getRandomValues(e),e;throw Error(`crypto.getRandomValues not available`)}function xu(e){return bu(new Uint8Array(e))}async function Su(e,t,n){let r=yu(),i=typeof e==`string`?tn(e):e,a=gu[n],o=a+32+2,s=await r.importKey(`raw`,Vl(i),`PBKDF2`,!1,[`deriveBits`]),c=await r.deriveBits({name:`PBKDF2`,salt:Vl(t),iterations:1e3,hash:`SHA-1`},s,o*8),l=new Uint8Array(c);return{encryptionKey:l.subarray(0,a),hmacKey:l.subarray(a,a+32),passwordVerify:l.subarray(a+32,a+34)}}async function Cu(e,t){let n=yu(),r=await n.importKey(`raw`,Vl(e),{name:`HMAC`,hash:`SHA-1`},!1,[`sign`]),i=await n.sign(`HMAC`,r,Vl(t));return new Uint8Array(i,0,10)}function wu(e){let t=new Uint8Array(16);return new DataView(t.buffer).setUint32(0,e,!0),t}async function Tu(e,t,n=!0){let r=yu(),i=await r.importKey(`raw`,Vl(e),{name:`AES-CTR`},!1,[`encrypt`,`decrypt`]),a=wu(1),o=await r.encrypt({name:`AES-CTR`,counter:Vl(a),length:128},i,Vl(t));return new Uint8Array(o)}function Eu(e,t,n){let r=new Uint8Array(11),i=new DataView(r.buffer);return i.setUint16(0,39169,!0),i.setUint16(2,7,!0),i.setUint16(4,e,!0),i.setUint16(6,17729,!0),r[8]=_u[t],i.setUint16(9,n,!0),r}function Du(e,t){let n=hu[t],r=n+2+10;return e.length<r?null:{salt:e.subarray(0,n),storedVerify:e.subarray(n,n+2),ciphertext:e.subarray(n+2,e.length-10),storedHmac:e.subarray(e.length-10)}}function Ou(e,t){return e[0]===t[0]&&e[1]===t[1]}function ku(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}async function Au(e,t,n){let r=Du(e,n);if(!r)throw Error(`Encrypted data too short`);let{salt:i,storedVerify:a,ciphertext:o,storedHmac:s}=r,c=await Su(t,i,n);if(!Ou(c.passwordVerify,a))throw Error(`Password verification failed`);if(!ku(await Cu(c.hmacKey,o),s))throw Error(`HMAC verification failed`);return Tu(c.encryptionKey,o,!1)}async function ju(e,t,n){let r=hu[n],i=xu(r),a=await Su(t,i,n),o=await Tu(a.encryptionKey,e,!0),s=await Cu(a.hmacKey,o),c=new Uint8Array(r+2+o.length+10),l=0;return c.set(i,l),l+=r,c.set(a.passwordVerify,l),l+=2,c.set(o,l),l+=o.length,c.set(s,l),c}let Mu={"aes-128":128,"aes-192":192,"aes-256":256};function Nu(e){return e in Mu}function Pu(e){return Mu[e]}function Fu(e){return!Number.isFinite(e)||e<=0?0:e>=4294967295?4294967295:e>>>0}function Iu(e){return Fu(Math.floor(e.getTime()/1e3))}function Lu(e){if(typeof BigInt!=`function`)throw Error(`NTFS timestamps require BigInt support`);return BigInt(e.getTime())*10000n+116444736000000000n}function Ru(e,t){let n=t?.atime!==void 0,r=t?.ctime!==void 0,i=1;n&&(i|=2),r&&(i|=4);let a=5+(n?4:0)+(r?4:0),o=new Uint8Array(4+a),s=new DataView(o.buffer);s.setUint16(0,21589,!0),s.setUint16(2,a,!0),o[4]=i,s.setUint32(5,Iu(e),!0);let c=9;return n&&(s.setUint32(c,Iu(t.atime),!0),c+=4),r&&s.setUint32(c,Iu(t.ctime),!0),o}function zu(e,t){if(typeof BigInt!=`function`)throw Error(`NTFS timestamps require BigInt support`);let n=t?.atime??e,r=t?.ctime??e,i=t?.birthTime??e,a=new Uint8Array(44),o=new DataView(a.buffer);o.setUint16(0,10,!0),o.setUint16(2,40,!0),o.setUint32(4,0,!0),o.setUint16(8,1,!0),o.setUint16(10,32,!0);let s=12;return o.setBigUint64(s,Lu(e),!0),s+=8,o.setBigUint64(s,Lu(n),!0),s+=8,o.setBigUint64(s,Lu(r),!0),s+=8,o.setBigUint64(s,Lu(i),!0),a}function Bu(e){return[(e.getHours()&31)<<11|(e.getMinutes()&63)<<5|e.getSeconds()>>1&31,(e.getFullYear()-1980&127)<<9|(e.getMonth()+1&15)<<5|e.getDate()&31]}function Vu(e,t){let n=e&31,r=e>>5&15,i=(e>>9&127)+1980,a=t?(t&31)*2:0,o=t?t>>5&63:0,s=t?t>>11:0;return new Date(Date.UTC(i,r-1,n,s,o,a))}function Hu(e,t,n){return n===void 0?Vu(e,t):new Date(n*1e3)}function Uu(e,t,n){if(t===`dos`)return new Uint8Array;let r=[Ru(e,n)];return t===`dos+utc+ntfs`&&r.push(zu(e,n)),O(r)}function Wu(e){let[t,n]=Bu(e);return{dosTime:t,dosDate:n}}let Gu=67324752,Ku=33639248,qu=101010256,Ju=134695760,Yu=101075792,Xu=117853008,Zu=2048,Qu=61440,$u=40960,ed=16384;function td(e){return e>>16&65535}function nd(e){return(e&Qu)===$u}function rd(e){return(e&Qu)===ed}let id=4294967295;function ad(e,t,n,r){let i=r.versionNeeded??20;return t.setUint32(n+0,Gu,!0),t.setUint16(n+4,i,!0),t.setUint16(n+6,r.flags,!0),t.setUint16(n+8,r.compressionMethod,!0),t.setUint16(n+10,r.dosTime,!0),t.setUint16(n+12,r.dosDate,!0),t.setUint32(n+14,r.crc32,!0),t.setUint32(n+18,r.compressedSize,!0),t.setUint32(n+22,r.uncompressedSize,!0),t.setUint16(n+26,r.fileName.length,!0),t.setUint16(n+28,r.extraField.length,!0),e.set(r.fileName,n+30),r.extraField.length>0&&e.set(r.extraField,n+30+r.fileName.length),30+r.fileName.length+r.extraField.length}function od(e){let t=new Uint8Array(30+e.fileName.length+e.extraField.length);return ad(t,new DataView(t.buffer,t.byteOffset,t.byteLength),0,e),t}function sd(e,t,n,r){let i=r.versionMadeBy??20,a=r.versionNeeded??20,o=r.externalAttributes??0;return t.setUint32(n+0,Ku,!0),t.setUint16(n+4,i,!0),t.setUint16(n+6,a,!0),t.setUint16(n+8,r.flags,!0),t.setUint16(n+10,r.compressionMethod,!0),t.setUint16(n+12,r.dosTime,!0),t.setUint16(n+14,r.dosDate,!0),t.setUint32(n+16,r.crc32,!0),t.setUint32(n+20,r.compressedSize,!0),t.setUint32(n+24,r.uncompressedSize,!0),t.setUint16(n+28,r.fileName.length,!0),t.setUint16(n+30,r.extraField.length,!0),t.setUint16(n+32,r.comment.length,!0),t.setUint16(n+34,0,!0),t.setUint16(n+36,0,!0),t.setUint32(n+38,o,!0),t.setUint32(n+42,r.localHeaderOffset,!0),e.set(r.fileName,n+46),r.extraField.length>0&&e.set(r.extraField,n+46+r.fileName.length),r.comment.length>0&&e.set(r.comment,n+46+r.fileName.length+r.extraField.length),46+r.fileName.length+r.extraField.length+r.comment.length}function cd(e,t,n,r){return t.setUint32(n+0,qu,!0),t.setUint16(n+4,0,!0),t.setUint16(n+6,0,!0),t.setUint16(n+8,r.entryCount,!0),t.setUint16(n+10,r.entryCount,!0),t.setUint32(n+12,r.centralDirSize,!0),t.setUint32(n+16,r.centralDirOffset,!0),t.setUint16(n+20,r.comment.length,!0),r.comment.length>0&&e.set(r.comment,n+22),22+r.comment.length}function ld(e,t,n){let r=new Uint8Array(16),i=new DataView(r.buffer);return i.setUint32(0,Ju,!0),i.setUint32(4,e,!0),i.setUint32(8,t,!0),i.setUint32(12,n,!0),r}function ud(e,t,n){let r=n>>>0,i=Math.floor(n/4294967296)>>>0;e.setUint32(t,r,!0),e.setUint32(t+4,i,!0)}function dd(e,t,n){let r=new Uint8Array(24),i=new DataView(r.buffer,r.byteOffset,r.byteLength);return i.setUint32(0,Ju,!0),i.setUint32(4,e,!0),ud(i,8,t),ud(i,16,n),r}function fd(e){let t=e.uncompressedSize!==void 0,n=e.compressedSize!==void 0,r=e.localHeaderOffset!==void 0,i=e.diskNumberStart!==void 0,a=0;if(t&&(a+=8),n&&(a+=8),r&&(a+=8),i&&(a+=4),a===0)return G;let o=new Uint8Array(4+a),s=new DataView(o.buffer,o.byteOffset,o.byteLength);s.setUint16(0,1,!0),s.setUint16(2,a,!0);let c=4;return t&&(ud(s,c,e.uncompressedSize),c+=8),n&&(ud(s,c,e.compressedSize),c+=8),r&&(ud(s,c,e.localHeaderOffset),c+=8),i&&s.setUint32(c,e.diskNumberStart,!0),o}function pd(e,t){return O([e,t])}function md(e,t,n,r){let i=r.versionMadeBy??20,a=r.versionNeeded??45,o=r.diskNumber??0,s=r.centralDirectoryDiskNumber??0;return t.setUint32(n+0,Yu,!0),ud(t,n+4,44),t.setUint16(n+12,i,!0),t.setUint16(n+14,a,!0),t.setUint32(n+16,o,!0),t.setUint32(n+20,s,!0),ud(t,n+24,r.entryCountOnDisk),ud(t,n+32,r.entryCountTotal),ud(t,n+40,r.centralDirSize),ud(t,n+48,r.centralDirOffset),56}function hd(e,t,n,r){let i=r.zip64EndOfCentralDirectoryDiskNumber??0,a=r.totalDisks??1;return t.setUint32(n+0,Xu,!0),t.setUint32(n+4,i,!0),ud(t,n+8,r.zip64EndOfCentralDirectoryOffset),t.setUint32(n+16,a,!0),20}function gd(e,t,n){let r=tn(n),i=5+r.length,a=new Uint8Array(4+i),o=new DataView(a.buffer,a.byteOffset,a.byteLength);return o.setUint16(0,e,!0),o.setUint16(2,i,!0),a[4]=1,o.setUint32(5,Sc(t)>>>0,!0),a.set(r,9),a}function _d(e,t){return gd(28789,e,t)}function vd(e,t){return gd(25461,e,t)}let yd=BigInt(2**53-1);function bd(e,t){return e.getBigUint64(t,!0)}function xd(e){return typeof e.getBigUint64==`function`}function Sd(e){if(!(e>yd))return Number(e)}function Cd(e,t){let n={};if(e.length<4)return n;let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=xd(r),a=0;for(;a+4<=e.length;){let o=r.getUint16(a,!0),s=r.getUint16(a+2,!0),c=a+4,l=c+s;if(l>e.length)break;if(o===1){let e=c;if(t.uncompressedSize===4294967295&&e+8<=l){let i=bd(r,e);n.uncompressedSize64=i,t.uncompressedSize64=i;let a=Sd(i);a!==void 0&&(n.uncompressedSize=a,t.uncompressedSize=a),e+=8}if(t.compressedSize===4294967295&&e+8<=l){let i=bd(r,e);n.compressedSize64=i,t.compressedSize64=i;let a=Sd(i);a!==void 0&&(n.compressedSize=a,t.compressedSize=a),e+=8}if(t.offsetToLocalFileHeader===4294967295&&e+8<=l){let i=bd(r,e);n.offsetToLocalFileHeader64=i,t.offsetToLocalFileHeader64=i;let a=Sd(i);a!==void 0&&(n.offsetToLocalFileHeader=a,t.offsetToLocalFileHeader=a)}}else if(o===21589){if(s>=1){let t=e[c],i=c+1;t&1&&i+4<=l&&(n.mtimeUnixSeconds=r.getUint32(i,!0)>>>0,i+=4),t&2&&i+4<=l&&(n.atimeUnixSeconds=r.getUint32(i,!0)>>>0,i+=4),t&4&&i+4<=l&&(n.ctimeUnixSeconds=r.getUint32(i,!0)>>>0)}}else if(o===10){if(i&&s>=8){let e=c+4;for(;e+4<=l;){let t=r.getUint16(e,!0),i=r.getUint16(e+2,!0),a=e+4,o=a+i;if(o>l)break;t===1&&i>=32&&a+32<=o&&(n.ntfsTimes={mtime:r.getBigUint64(a+0,!0),atime:r.getBigUint64(a+8,!0),ctime:r.getBigUint64(a+16,!0),birthTime:r.getBigUint64(a+24,!0)}),e=o}}}else if(o===39169){if(s>=7){let t=r.getUint16(c,!0),i=r.getUint16(c+2,!0),a=e[c+4],o=r.getUint16(c+5,!0);if(i===17729){let e=vu[a];e&&(t===1||t===2)&&(n.aesInfo={version:t,keyStrength:e,compressionMethod:o})}}}else o===28789?s>=5&&(n.unicodePath={version:e[c],originalCrc32:r.getUint32(c+1,!0),unicodeValue:nn(e.subarray(c+5,l))}):o===25461&&s>=5&&(n.unicodeComment={version:e[c],originalCrc32:r.getUint32(c+1,!0),unicodeValue:nn(e.subarray(c+5,l))});a=l}return n}function wd(e){return e?8:0}function Td(e,t=!0){let n=0;return t&&(n|=Zu),e&&(n|=8),n}function Ed(e){let t=Fl(e.codec),n=t.encode(e.name),r=Il(e.comment,t),{dosTime:i,dosDate:a}=Wu(e.modTime),o=e.atime||e.ctime||e.birthTime?{atime:e.atime,ctime:e.ctime,birthTime:e.birthTime}:void 0,s=Uu(e.modTime,e.timestamps,o);return!t.useUtf8Flag&&t.useUnicodeExtraFields&&(e.name&&(s=pd(s,_d(n,e.name))),e.comment&&(s=pd(s,vd(r,e.comment)))),{nameBytes:n,commentBytes:r,dosTime:i,dosDate:a,extraField:s,compressionMethod:wd(e.deflate),flags:Td(e.useDataDescriptor,t.useUtf8Flag)}}function Dd(e,t=20){return(e&255)<<8|t&255}function Od(e){switch(e){case`directory`:return ed;case`symlink`:return $u;default:return 32768}}function kd(e){return e>>>0&65535}function Ad(e,t){let n=e.endsWith(`/`)||e.endsWith(`\\`);return t!==void 0&&nd(t)?`symlink`:n?`directory`:`file`}function jd(e){let t=e.kind,n=t===`directory`?16:32,r=(e.msDosAttributes??n)&255,i=e.mode;i!==void 0&&(i&61440||(i=i&4095|Od(t)),i=kd(i));let a=((i??0)&65535)<<16|r,o=Dd(i!==void 0||t===`symlink`?3:0);return{externalAttributes:a>>>0,versionMadeBy:o}}function Md(e){if(e.externalAttributes!==void 0)return{externalAttributes:e.externalAttributes,versionMadeBy:e.versionMadeBy};let t=jd({kind:Ad(e.name,e.mode),mode:e.mode,msDosAttributes:e.msDosAttributes});return{externalAttributes:t.externalAttributes,versionMadeBy:e.versionMadeBy??t.versionMadeBy}}function Nd(e){return e.replace(/\\/g,`/`)}function Pd(e){return e.replace(/^\/+/,``)}function Fd(e){return e.replace(/^[a-zA-Z]:\/?/,``)}function Id(e){let t=e.split(`/`),n=[];for(let e of t)if(!(!e||e===`.`)){if(e===`..`){n.length>0?n.pop():n.push(`..`);continue}n.push(e)}return n.join(`/`)}function Ld(e){return e.startsWith(`/`)}function Rd(e){return/^[a-zA-Z]:/.test(e)}function zd(e,t={}){let n=t.mode??`legacy`,r=e;r=Nd(r);let i=Rd(r);if(n===`legacy`)return r=Pd(r),t.prependSlash?`/`+r:r;let a=t.stripDrive??!0;if(n===`safe`&&i&&!a)throw Error(`Unsafe ZIP path (drive): ${e}`);a&&(r=Fd(r));let o=Ld(r);if(r=Pd(r),r=Id(r),n===`safe`){if(o)throw Error(`Unsafe ZIP path (absolute): ${e}`);if(r===`..`||r.startsWith(`../`))throw Error(`Unsafe ZIP path (traversal): ${e}`)}return t.prependSlash?`/`+r:r}function Bd(e){return Math.log(e)/Math.LN2}function Vd(e,t){let n=0;for(let r=0;r<256;r++){let i=e[r];if(i===0)continue;let a=i/t;n-=a*Bd(a)}return n}function Hd(e,t){let n=new Uint32Array(256),r=0,i=0;if(Array.isArray(e))for(let a=0;a<e.length&&!(r>=t);a++){let o=e[a],s=Math.min(o.length,t-r);for(let e=0;e<s;e++){let t=o[e];n[t]===0&&(i+=1),n[t]+=1}r+=s}else for(let a of e){if(r>=t)break;let e=Math.min(a.length,t-r);for(let t=0;t<e;t++){let e=a[t];n[e]===0&&(i+=1),n[e]+=1}r+=e}return{total:r,unique:i,counts:n}}function Ud(e,t={}){let n=t.sampleBytes??65536,r=t.minDecisionBytes??16384,{total:i,unique:a,counts:o}=Hd(e,n);return i<r||a<200?!1:Vd(o,i)>=7.95}function Wd(e,t,n,r,i){if(!i)return 0;let a=0;return(e||t>4294967295)&&(a+=8),(e||n>4294967295)&&(a+=8),(e||r>4294967295)&&(a+=8),a>0?4+a:0}function Gd(e){let t=e[0];return t?.fileName===void 0?t?.compressedData===void 0?`central`:`processed`:`input`}function Kd(e,t){let n=t.zip64Mode===!0,r=t.zip64Mode===!1,i=Gd(e),a=0;for(let t=0;t<e.length;t++){let r=e[t],o=i===`input`?r.fileName:r.name,s=r.extraField,c=r.comment,l=i===`processed`?r.compressedData.length:r.compressedSize,u=r.uncompressedSize,d=i===`input`?r.localHeaderOffset:r.offset,f=i===`processed`?void 0:r.zip64,p=n||f===!0||d>4294967295||l>4294967295||u>4294967295;a+=46+o.length+s.length+Wd(n,u,l,d,p)+(c?.length??0)}let o=e.length>65535||t.centralDirOffset>4294967295,s=n||o||a>4294967295;if(r&&s)throw Error(`ZIP64 is required but zip64=false`);let c=s?98+t.zipComment.length:22+t.zipComment.length;return{centralDirSize:a,trailerSize:c,totalSize:a+c,usedZip64:s}}function qd(e,t){let n=t.zip64Mode===!0,r=Kd(e,{zipComment:t.zipComment,zip64Mode:t.zip64Mode,centralDirOffset:t.centralDirOffset}),i=Gd(e),a=t.offset,o=new DataView(t.out.buffer,t.out.byteOffset,t.out.byteLength);for(let r=0;r<e.length;r++){let s=e[r],c=i===`input`?s.fileName:s.name,l=s.extraField,u=s.comment,d=s.flags,f=i===`input`?s.crc32:s.crc,p=i===`processed`?s.compressedData.length:s.compressedSize,m=s.uncompressedSize,h=s.compressionMethod,g=i===`processed`?s.modTime:s.dosTime,_=i===`processed`?s.modDate:s.dosDate,v=i===`input`?s.localHeaderOffset:s.offset,y=i===`processed`?void 0:s.zip64,b=s.externalAttributes,ee=s.versionMadeBy,x=n||y===!0||v>4294967295||p>4294967295||m>4294967295,te=x?fd({uncompressedSize:n||m>4294967295?m:void 0,compressedSize:n||p>4294967295?p:void 0,localHeaderOffset:n||v>4294967295?v:void 0}):G,ne=x&&te.length>0?pd(l,te):l;a+=sd(t.out,o,a,{fileName:c,extraField:ne,comment:u??G,flags:d,compressionMethod:h,dosTime:g,dosDate:_,crc32:f,compressedSize:x?id:p,uncompressedSize:x?id:m,localHeaderOffset:x?id:v,versionMadeBy:ee??20,versionNeeded:x?45:20,externalAttributes:b})}if(r.usedZip64){let n=t.centralDirOffset+r.centralDirSize;a+=md(t.out,o,a,{entryCountOnDisk:e.length,entryCountTotal:e.length,centralDirSize:r.centralDirSize,centralDirOffset:t.centralDirOffset}),a+=hd(t.out,o,a,{zip64EndOfCentralDirectoryOffset:n,totalDisks:1}),cd(t.out,o,a,{entryCount:65535,centralDirSize:id,centralDirOffset:id,comment:t.zipComment})}else cd(t.out,o,a,{entryCount:e.length,centralDirSize:r.centralDirSize,centralDirOffset:t.centralDirOffset,comment:t.zipComment});return{centralDirSize:r.centralDirSize,trailerSize:r.trailerSize,totalWritten:r.totalSize,usedZip64:r.usedZip64}}let Jd=16*1024;var Yd=class{constructor(e,t){this._deflate=null,this._crc=4294967295,this._uncompressedSize=0,this._compressedSize=0,this._finalized=!1,this._headerEmitted=!1,this._ondata=null,this._onerror=null,this._centralDirEntryInfo=null,this._pendingEnd=!1,this._emittedDataDescriptor=!1,this._localHeader=null,this._zip64Mode=`auto`,this._zip64=!1,this._deflateWanted=null,this._pendingChunks=[],this._sampleLen=0,this._completeResolve=null,this._completeReject=null,this._completePromise=null,this._completeError=null,this._encryptionMethod=`none`,this._zipCryptoState=null,this._aesBuffer=[],this._aesBufferSize=0,this._originalCompressionMethod=0,this._aesExtraField=null,this._dataQueue=[],this._finalQueued=!1,this._pushChain=Promise.resolve(),this._syncDeflater=null,this._syncZlibReady=!1;let n=t?.path?zd(e,t.path):e;this.name=n;let r=t?.modTime??new Date;if(this._modTime=r,this.level=t?.level??6,this._smartStore=t?.smartStore??!0,this._zip64Mode=t?.zip64??`auto`,this._zip64=this._zip64Mode===!0,this._encryptionMethod=t?.encryptionMethod??`none`,this._password=t?.password,this._encryptionMethod!==`none`&&!this._password)throw Error(`Password is required for encryption`);Nu(this._encryptionMethod)&&(this._aesKeyStrength=Pu(this._encryptionMethod)),this._stringCodec=Fl(t?.encoding);let i=Ed({name:n,comment:t?.comment,modTime:r,atime:t?.atime,ctime:t?.ctime,birthTime:t?.birthTime,timestamps:t?.timestamps??`dos`,useDataDescriptor:!0,deflate:!1,codec:this._stringCodec});this.nameBytes=i.nameBytes,this.commentBytes=i.commentBytes,this.dosTime=i.dosTime,this.dosDate=i.dosDate,this.extraField=i.extraField,this._flags=i.flags,this._compressionMethod=i.compressionMethod;let a=Md({name:n,mode:t?.mode,msDosAttributes:t?.msDosAttributes,externalAttributes:t?.externalAttributes,versionMadeBy:t?.versionMadeBy});if(this._externalAttributes=a.externalAttributes,this._versionMadeBy=a.versionMadeBy,this._encryptionMethod!==`none`&&(this._flags|=1),!this._smartStore){let e=this.level>0;this._deflateWanted=e,this._compressionMethod=this._buildCompressionMethod(e),e&&this._initDeflateStream();return}this.level===0&&(this._deflateWanted=!1,this._compressionMethod=this._buildCompressionMethod(!1))}_buildCompressionMethod(e){return wd(e)}_getAesExtraField(){return this._aesKeyStrength?(this._aesExtraField||=Eu(2,this._aesKeyStrength,this._originalCompressionMethod),this._aesExtraField):G}_initZipCryptoEncryption(){if(this._zipCryptoState||this._encryptionMethod!==`zipcrypto`)return;this._zipCryptoState=su(this._password);let e=this.dosTime<<16|this.dosDate,t=pu(this._zipCryptoState,e,xu);this._compressedSize+=t.length,this._enqueueData(t,!1)}_zipCryptoEncryptChunk(e){if(!this._zipCryptoState)return e;let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=du(this._zipCryptoState,e[n]);return t}_initDeflateStream(){this._deflate||(this._deflate=ou({level:this.level}),this._deflate.on(`error`,e=>{this._rejectComplete(e)}),this._deflate.on(`data`,e=>{if(this._aesKeyStrength){this._aesBuffer.push(e),this._aesBufferSize+=e.length;return}if(this._encryptionMethod===`zipcrypto`){this._initZipCryptoEncryption();let t=this._zipCryptoEncryptChunk(e);this._compressedSize+=t.length,this._enqueueData(t,!1);return}this._compressedSize+=e.length,this._enqueueData(e,!1)}),this._deflate.on(`end`,()=>{this._pendingEnd&&!this._emittedDataDescriptor&&(this._emittedDataDescriptor=!0,this._finalizeEncryptionAndEmitDescriptor())}))}_finalizeEncryptionAndEmitDescriptor(){if(this._aesKeyStrength&&this._aesBuffer.length>0){this._finalizeAesEncryption().then(()=>this._emitDataDescriptor()).catch(e=>this._rejectComplete(e));return}this._emitDataDescriptor()}async _finalizeAesEncryption(){if(!this._aesKeyStrength||this._aesBufferSize===0)return;let e;if(this._aesBuffer.length===1)e=this._aesBuffer[0];else{e=new Uint8Array(this._aesBufferSize);let t=0;for(let n=0;n<this._aesBuffer.length;n++){let r=this._aesBuffer[n];e.set(r,t),t+=r.length}}this._aesBuffer.length=0,this._aesBufferSize=0;let t=await ju(e,this._password,this._aesKeyStrength);this._compressedSize=t.length,this._enqueueData(t,!1)}_buildLocalHeader(){let e=this.extraField,t=this._compressionMethod;return this._aesKeyStrength&&(this._originalCompressionMethod=this._compressionMethod,t=99,e=pd(this.extraField,this._getAesExtraField())),od({fileName:this.nameBytes,extraField:e,flags:this._flags,compressionMethod:t,dosTime:this.dosTime,dosDate:this.dosDate,crc32:0,compressedSize:0,uncompressedSize:0,versionNeeded:this._zip64?45:20})}_accumulateSampleLen(e){if(this._deflateWanted!==null||e.length===0||this._sampleLen>=Jd)return;let t=Math.min(Jd-this._sampleLen,e.length);t<=0||(this._sampleLen+=t)}_shouldDecide(e){return this._deflateWanted===null?e||this._sampleLen>=Jd:!1}_decideCompressionIfNeeded(e,t,n=!1){if(this._deflateWanted===null){if(e&&this._sampleLen===0){this._deflateWanted=!1,this._sampleLen=0,this._compressionMethod=this._buildCompressionMethod(!1),this._localHeader=null;return}this._deflateWanted=!Ud((function*(e,t){for(let t of e)t.length&&(yield t);t.length&&(yield t)})(this._pendingChunks,t),{sampleBytes:Jd,minDecisionBytes:Jd}),this._sampleLen=0,this._compressionMethod=this._buildCompressionMethod(this._deflateWanted),this._localHeader=null,this._deflateWanted&&(n||this._initDeflateStream())}}_emitHeaderIfNeeded(){this._headerEmitted||=(this._emitHeader(),!0)}async _flushPendingChunks(){if(this._pendingChunks.length!==0){for(let e of this._pendingChunks)await this._writeData(e);this._pendingChunks.length=0}}_enqueueData(e,t){this._ondata?this._ondata(e,t):(this._dataQueue.push(e),t&&(this._finalQueued=!0))}_flushQueue(){if(!this._ondata)return;let e=this._dataQueue.length,t=this._finalQueued?e-1:-1;for(let n=0;n<e;n++)this._ondata(this._dataQueue[n],n===t);this._dataQueue.length=0,this._finalQueued=!1}get ondata(){return this._ondata}set ondata(e){this._ondata=e,this._flushQueue()}get onerror(){return this._onerror}set onerror(e){this._onerror=e,this._completeError&&e(this._completeError)}_resolveComplete(){this._completeResolve&&this._completeResolve()}_rejectComplete(e){this._completeError||(this._completeError=e,this._onerror&&this._onerror(e),this._completeReject&&this._completeReject(e))}_ensureCompletePromise(){return this._completeError?Promise.reject(this._completeError):this._emittedDataDescriptor?Promise.resolve():(this._completePromise||=new Promise((e,t)=>{this._completeResolve=e,this._completeReject=t}),this._completePromise)}_tapCallback(e,t){t&&e.then(()=>t()).catch(e=>t(e))}_writeDataSync(e,t){if(!(e.length===0&&!t)){if(e.length>0&&(this._crc=bc(this._crc,e),this._uncompressedSize+=e.length),this._deflateWanted){if(this._syncDeflater||=new Uc,e.length>0){let t=this._syncDeflater.write(e);t.length>0&&(this._compressedSize+=t.length,this._enqueueData(t,!1))}if(t){let e=this._syncDeflater.finish();e.length>0&&(this._compressedSize+=e.length,this._enqueueData(e,!1)),this._syncDeflater=null}return}if(this._aesKeyStrength){this._aesBuffer.push(e),this._aesBufferSize+=e.length;return}if(this._encryptionMethod===`zipcrypto`){this._initZipCryptoEncryption();let t=this._zipCryptoEncryptChunk(e);this._compressedSize+=t.length,this._enqueueData(t,!1);return}e.length>0&&(this._compressedSize+=e.length,this._enqueueData(e,!1))}}_writeData(e){if(e.length===0)return Promise.resolve();if(this._crc=bc(this._crc,e),this._uncompressedSize+=e.length,this._deflate)return new Promise((t,n)=>{this._deflate.write(e,e=>{e?n(e):t()})});if(this._aesKeyStrength)return this._aesBuffer.push(e),this._aesBufferSize+=e.length,Promise.resolve();if(this._encryptionMethod===`zipcrypto`){this._initZipCryptoEncryption();let t=this._zipCryptoEncryptChunk(e);return this._compressedSize+=t.length,this._enqueueData(t,!1),Promise.resolve()}return this._compressedSize+=e.length,this._enqueueData(e,!1),Promise.resolve()}_endDeflateAndWait(){return new Promise((e,t)=>{let n=this._deflate,r=e=>{a(),t(e)},i=()=>{a(),e()},a=()=>{n.off(`error`,r),n.off(`end`,i)};n.once(`error`,r),n.once(`end`,i),n.end()})}_finalizeAfterWrite(e){this._finalized=!0,this._pendingEnd=!0;let t=this._ensureCompletePromise();return this._deflate?e.then(()=>this._endDeflateAndWait()).then(()=>t):this._aesKeyStrength&&this._aesBufferSize>0?(this._emittedDataDescriptor=!0,this._finalizeAesEncryption().then(()=>this._emitDataDescriptor()).catch(e=>this._rejectComplete(e)),t):(this._emittedDataDescriptor=!0,this._emitDataDescriptor(),t)}_pushUnchained(e,t,n){if(this._finalized){let e=Promise.reject(Error(`Cannot push to finalized ZipDeflateFile`));return this._tapCallback(e,n),e}if(this._deflateWanted===null){if(this._accumulateSampleLen(e),!this._shouldDecide(t)){e.length>0&&this._pendingChunks.push(e);let t=Promise.resolve();return this._tapCallback(t,n),t}this._decideCompressionIfNeeded(t,e),this._emitHeaderIfNeeded();let r=this._pendingChunks.length>0,i=this._flushPendingChunks(),a=i;e.length>0&&(a=r?i.then(()=>this._writeData(e)):this._writeData(e));let o=t?this._finalizeAfterWrite(a):a;return this._tapCallback(o,n),o}this._emitHeaderIfNeeded();let r=this._writeData(e),i=t?this._finalizeAfterWrite(r):r;return this._tapCallback(i,n),i}push(e,t=!1,n){if(!this._deflate&&this._encryptionMethod===`none`){try{this._pushSyncPath(e,t),n?.()}catch(e){return n?.(e instanceof Error?e:Error(String(e))),Promise.reject(e)}return Promise.resolve()}let r=this._pushChain=this._pushChain.then(()=>this._pushUnchained(e,t,n));return r.catch(()=>{}),r}_pushSyncPath(e,t=!1){if(this._finalized)throw Error(`Cannot push to finalized ZipDeflateFile`);if(this._syncZlibReady||=!0,this._deflateWanted===null){if(this._accumulateSampleLen(e),!this._shouldDecide(t)){e.length>0&&this._pendingChunks.push(e);return}this._decideCompressionIfNeeded(t,e,!0),this._emitHeaderIfNeeded();for(let e of this._pendingChunks)this._writeDataSync(e,!1);this._pendingChunks.length=0,e.length>0&&this._writeDataSync(e,t),t&&this._finalizeSyncAfterWrite();return}this._emitHeaderIfNeeded(),this._writeDataSync(e,t),t&&this._finalizeSyncAfterWrite()}_finalizeSyncAfterWrite(){if(this._finalized=!0,this._pendingEnd=!1,this._emittedDataDescriptor=!0,this._aesKeyStrength&&this._aesBufferSize>0)throw Error(`AES encryption is not supported with synchronous push`);if(this._syncDeflater){let e=this._syncDeflater.finish();e.length>0&&(this._compressedSize+=e.length,this._enqueueData(e,!1)),this._syncDeflater=null}this._emitDataDescriptor()}_emitHeader(){this._localHeader||=this._buildLocalHeader(),this._enqueueData(this._localHeader,!1)}_emitDataDescriptor(){let e=xc(this._crc),t=this._compressedSize>4294967295||this._uncompressedSize>4294967295;if(this._zip64Mode===!1&&t){this._rejectComplete(Error(`ZIP64 is required but zip64=false`));return}(this._zip64Mode===!0||t&&!this._zip64)&&(this._zip64=!0);let n=this._zip64?dd(e,this._compressedSize,this._uncompressedSize):ld(e,this._compressedSize,this._uncompressedSize),r=this._compressionMethod,i=this.extraField;this._aesKeyStrength&&(r=99,i=pd(this.extraField,this._getAesExtraField())),this._centralDirEntryInfo={name:this.nameBytes,extraField:i,comment:this.commentBytes,flags:this._flags,crc:e,compressedSize:this._compressedSize,uncompressedSize:this._uncompressedSize,compressionMethod:r,dosTime:this.dosTime,dosDate:this.dosDate,offset:-1,zip64:this._zip64,externalAttributes:this._externalAttributes,versionMadeBy:this._versionMadeBy},this._enqueueData(n,!0),this._resolveComplete()}complete(){return this._ensureCompletePromise()}getEntryInfo(){if(!this._centralDirEntryInfo)return null;let e=this.name,t=e.endsWith(`/`)||e.endsWith(`\\`),n=this._centralDirEntryInfo.externalAttributes,r=td(n);return{path:e,type:nd(r)?`symlink`:t?`directory`:`file`,compressedSize:this._centralDirEntryInfo.compressedSize,uncompressedSize:this._centralDirEntryInfo.uncompressedSize,compressionMethod:this._centralDirEntryInfo.compressionMethod,crc32:this._centralDirEntryInfo.crc,lastModified:this._modTime,localHeaderOffset:this._centralDirEntryInfo.offset,comment:this._stringCodec.decode(this._centralDirEntryInfo.comment),externalAttributes:n,mode:r,versionMadeBy:this._centralDirEntryInfo.versionMadeBy,extraField:this._centralDirEntryInfo.extraField,isEncrypted:this._encryptionMethod!==`none`,encryptionMethod:this._aesKeyStrength?`aes`:this._encryptionMethod===`zipcrypto`?`zipcrypto`:void 0,aesKeyStrength:this._aesKeyStrength,originalCompressionMethod:this._aesKeyStrength?this._originalCompressionMethod:void 0}}getCentralDirectoryEntryInfo(){return this._centralDirEntryInfo}isComplete(){return this._emittedDataDescriptor&&this._centralDirEntryInfo!==null}abort(e){if(this._completeError)return;let t=r(e);this._finalized=!0,this._pendingEnd=!0,this._rejectComplete(t);try{let e=this._deflate;e&&typeof e.destroy==`function`&&e.destroy(t)}catch{}}},Xd=class{constructor(e,t){this.entries=[],this.currentOffset=0,this.ended=!1,this.endPending=!1,this.addedEntryCount=0,this.fileQueue=[],this.fileQueueIndex=0,this.activeFile=null,this.callback=e,this._stringCodec=t?.codec??Fl(t?.encoding),this.zipComment=Il(t?.comment,this._stringCodec),this.zip64Mode=t?.zip64??`auto`}add(e){if(this.ended)throw Error(`Cannot add files after calling end() `);if(this.zip64Mode===!1&&this.addedEntryCount>=65535)throw Error(`ZIP64 is required but zip64=false`);this.addedEntryCount++,this.fileQueue.push(e),this.activeFile||this._processNextFile()}_processNextFile(){if(this.fileQueueIndex>=this.fileQueue.length){this.activeFile=null,this.fileQueue=[],this.fileQueueIndex=0,this.endPending&&this._finalize();return}let e=this.fileQueue[this.fileQueueIndex++];this.activeFile=e;let t=this.currentOffset;if(e.onerror=e=>{this.ended||(this.ended=!0,this.callback(e,G,!0))},e.ondata=(n,r)=>{if(!this.ended&&(this.currentOffset+=n.length,this.callback(null,n,!1),r)){let n=e.getCentralDirectoryEntryInfo();n&&(n.offset=t,this.entries.push(n)),this._processNextFile()}},typeof e.start==`function`)try{e.start().catch(t=>{let n=a(t);try{e.onerror?.(n)}catch{}})}catch(t){let n=a(t);try{e.onerror?.(n)}catch{}}}_finalize(){if(this.ended)return;this.ended=!0;let e=this.currentOffset,t;try{let n=Kd(this.entries,{zipComment:this.zipComment,zip64Mode:this.zip64Mode,centralDirOffset:e});t=new Uint8Array(n.totalSize),qd(this.entries,{zipComment:this.zipComment,zip64Mode:this.zip64Mode,centralDirOffset:e,out:t,offset:0})}catch(e){let t=a(e);this.callback(t,G,!0);return}this.callback(null,t,!0)}end(){this.endPending||this.ended||(this.endPending=!0,this.activeFile||this._finalize())}abort(e){if(this.ended)return;let t=r(e);this.ended=!0,this.endPending=!0;try{this.activeFile?.abort(t)}catch{}this.callback(t,G,!0)}};function Zd(e){return e.encoding?Fl(e.encoding):void 0}function Qd(e,t=!1){for(let n=e.length-22;n>=0;n--)if(e[n]===80&&e[n+1]===75&&e[n+2]===5&&e[n+3]===6)if(t){let t=e[n+20]|e[n+21]<<8;if(n+22+t===e.length)return n}else return n;return-1}function $d(e,t){let n=t-20;return n<0?-1:e[n]===80&&e[n+1]===75&&e[n+2]===6&&e[n+3]===7?n:-1}function ef(e,t,n=!0,r){let i=new Wl(e,t);i.skip(4);let a=i.readUint16(),o=i.readUint16(),s=i.readUint16(),c=i.readUint16(),l=i.readUint32(),u=i.readUint32(),d=i.readUint16(),f=``;if(d>0){let e=i.readBytes(d);n&&(f=r?r.decode(e):nn(e))}return{eocd:{diskNumber:a,centralDirDisk:o,entriesOnDisk:s,totalEntries:c,centralDirSize:l,centralDirOffset:u},comment:f}}function tf(e,t){let n=new Wl(e,t);return n.readUint32()===117853008?(n.skip(4),Number(n.readBigUint64())):-1}function nf(e,t){let n=new Wl(e,t);return n.readUint32()===101075792?(n.skip(8),n.skip(2),n.skip(2),n.skip(4),n.skip(4),{entriesOnDisk:n.readBigUint64(),totalEntries:n.readBigUint64(),centralDirSize:n.readBigUint64(),centralDirOffset:n.readBigUint64()}):null}function rf(e,t){e.totalEntries===65535&&(e.totalEntries=Number(t.totalEntries)),e.entriesOnDisk===65535&&(e.entriesOnDisk=Number(t.entriesOnDisk)),e.centralDirSize===4294967295&&(e.centralDirSize=Number(t.centralDirSize)),e.centralDirOffset===4294967295&&(e.centralDirOffset=Number(t.centralDirOffset))}function af(e,t,n){let r=e.readUint16();e.skip(2);let i=e.readUint16(),a=e.readUint16(),o=e.readUint16(),s=e.readUint16(),c=e.readUint32(),l=e.readUint32(),u=e.readUint32(),d=e.readUint16(),f=e.readUint16(),p=e.readUint16();e.skip(2),e.skip(2);let m=e.readUint32(),h=e.readUint32(),g=d>0?e.readBytes(d):new Uint8Array,_={},v=new Uint8Array;if(f>0){v=e.readBytes(f);let t={compressedSize:l,uncompressedSize:u,offsetToLocalFileHeader:h};_=Cd(v,t),l=t.compressedSize,u=t.uncompressedSize,h=t.offsetToLocalFileHeader??h}let y=p>0?e.readBytes(p):new Uint8Array,b=t?zl(g,i,_,n):``,ee=t?Bl(y,i,_,n):``,x=td(m),te=r>>8&255,ne=nd(x),re=rd(x)||te===0&&(m&16)!=0||b.endsWith(`/`),ie=(i&1)!=0,S=ne?`symlink`:re?`directory`:`file`,C=_.mtimeUnixSeconds,ae=Hu(s,o,C),oe=`none`,se,ce,le;return ie&&(a===99&&_.aesInfo?(oe=`aes`,se=_.aesInfo.version,ce=_.aesInfo.keyStrength,le=_.aesInfo.compressionMethod):oe=`zipcrypto`),{path:b,type:S,compressedSize:l,compressedSize64:_.compressedSize64,uncompressedSize:u,uncompressedSize64:_.uncompressedSize64,compressionMethod:a,crc32:c,lastModified:ae,localHeaderOffset:h,localHeaderOffset64:_.offsetToLocalFileHeader64,comment:ee,externalAttributes:m,mode:x,versionMadeBy:r,extraField:v,isEncrypted:ie,encryptionMethod:oe,aesVersion:se,aesKeyStrength:ce,originalCompressionMethod:le,dosTime:o}}function of(e,t,n,r={}){let i=r.decodeStrings??!0,a=Zd(r);if(n===0)return[];let o=Array(n),s=new Wl(e,t);for(let e=0;e<n;e++){if(s.readUint32()!==33639248)throw Error(`Invalid Central Directory header signature at entry ${e}`);o[e]=af(s,i,a)}return o}function sf(e,t={}){let n=t.decodeStrings??!0,r=Zd(t),i=Qd(e);if(i===-1)throw Error(`Invalid ZIP file: End of Central Directory not found`);let{eocd:a,comment:o}=ef(e,i,n,r),s=$d(e,i);if(s!==-1){let t=tf(e,s);if(t>=0){let n=nf(e,t);n&&rf(a,n)}}return{entries:of(e,a.centralDirOffset,a.totalEntries,t),comment:o}}function cf(e){return!!e&&typeof e==`object`&&typeof e.getReader==`function`}function lf(e){return!!e&&typeof e==`object`&&typeof e.getWriter==`function`}function uf(e){return!!e&&typeof e==`object`&&!!e.readable&&!!e.writable&&cf(e.readable)&&lf(e.writable)}async function df(e,t,n,r=!1,i=!0){let a;if(e.isEncrypted){if(!n)throw new cl(e.path);if(e.encryptionMethod===`aes`&&e.aesKeyStrength){let r=await Au(t,n,e.aesKeyStrength);if(!r)throw new sl(e.path);a=await pf(r,e.originalCompressionMethod??0,e.path)}else if(e.encryptionMethod===`zipcrypto`){let r=mu(t,n,e.crc32,e.dosTime);if(!r)throw new sl(e.path);a=await pf(r,e.compressionMethod,e.path)}else throw new sl(e.path,`Unsupported encryption method`)}else a=await pf(t,e.compressionMethod,e.path);if(i&&a.length!==e.uncompressedSize){let t=a.length>e.uncompressedSize?`too-many-bytes`:`too-few-bytes`;throw new ol(e.path,e.uncompressedSize,a.length,t)}if(e.encryptionMethod===`zipcrypto`||r&&e.encryptionMethod!==`aes`){let t=Sc(a);if(t!==e.crc32)throw new al(e.path,e.crc32,t)}return a}function ff(e,t,n,r=!0){let i;if(e.isEncrypted){if(!n)throw new cl(e.path);if(e.encryptionMethod===`aes`)throw Error(`File "${e.path}" uses AES encryption. Use the async extract() method instead of extractSync().`);if(e.encryptionMethod===`zipcrypto`){let r=mu(t,n,e.crc32,e.dosTime);if(!r)throw new sl(e.path);i=mf(r,e.compressionMethod,e.path);let a=Sc(i);if(a!==e.crc32)throw new al(e.path,e.crc32,a)}else throw new sl(e.path,`Unsupported encryption method`)}else i=mf(t,e.compressionMethod,e.path);if(r&&i.length!==e.uncompressedSize){let t=i.length>e.uncompressedSize?`too-many-bytes`:`too-few-bytes`;throw new ol(e.path,e.uncompressedSize,i.length,t)}return i}async function pf(e,t,n){if(t===0)return e;if(t===8)return Zl(e);throw new ll(t)}function mf(e,t,n){if(t===0)return e;if(t===8)return Ql(e);throw new ll(t)}function hf(e,t){if(e.readUint32()!==67324752)throw Error(`Invalid local file header signature at offset ${t}`);e.skip(2),e.skip(2),e.skip(2),e.skip(2),e.skip(2),e.skip(4),e.skip(4),e.skip(4);let n=e.readUint16(),r=e.readUint16();return e.skip(n),e.skip(r),e.position}function gf(e,t){let n=hf(new Wl(e,t.localHeaderOffset),t.localHeaderOffset);return e.subarray(n,n+t.compressedSize)}let _f=BigInt(2**53-1);function vf(e){if(e.uncompressedSize64!==void 0&&e.uncompressedSize64>_f||e.compressedSize64!==void 0&&e.compressedSize64>_f)throw Error(`File "${e.path}" is too large to extract into memory (ZIP64 size > 2^53-1)`);if(e.localHeaderOffset64!==void 0&&e.localHeaderOffset64>_f)throw Error(`File "${e.path}" has a ZIP64 offset > 2^53-1 and cannot be extracted by the in-memory parser`)}function yf(e,t={}){return sf(e,{decodeStrings:t.decodeStrings,encoding:t.encoding})}async function bf(e,t,n={}){return t.type===`directory`?G:(vf(t),df(t,gf(e,t),n.password))}function xf(e,t,n={}){return t.type===`directory`?G:(vf(t),ff(t,gf(e,t),n.password))}var Sf=class{constructor(e,t={}){this.data=e instanceof ArrayBuffer?new Uint8Array(e):e;let n=yf(this.data,t);this.entries=n.entries,this.archiveComment=n.comment,this.entryMap=new Map(this.entries.map(e=>[e.path,e])),this.password=t.password}setPassword(e){this.password=e}getEntries(){return this.entries}getEntry(e){return this.entryMap.get(e)}getRawCompressedData(e){let t=this.entryMap.get(e);return t?gf(this.data,t):null}getRawEntry(e){let t=this.entryMap.get(e);return t?{info:t,compressedData:gf(this.data,t)}:null}hasEntry(e){return this.entryMap.has(e)}childCount(e){let t=this.entryMap.get(e);if(t&&t.type!==`directory`)return 0;let n=e.endsWith(`/`)?e:e+`/`,r=t?.type===`directory`?t:this.entryMap.get(n),i=(r?.path??n).endsWith(`/`)?r?.path??n:(r?.path??n)+`/`,a=0;for(let e of this.entries)e.path.startsWith(i)&&e.path!==i&&a++;return a}getZipComment(){return this.archiveComment}hasEncryptedEntries(){return this.entries.some(e=>e.isEncrypted)}getEncryptedEntries(){return this.entries.filter(e=>e.isEncrypted)}listFiles(){return this.entries.map(e=>e.path)}async extract(e,t){let n=this.entryMap.get(e);return n?bf(this.data,n,{password:t??this.password}):null}extractSync(e,t){let n=this.entryMap.get(e);return n?xf(this.data,n,{password:t??this.password}):null}async extractAll(e){let t=new Map,n=e??this.password;for(let e of this.entries){let r=await bf(this.data,e,{password:n});t.set(e.path,r)}return t}extractAllSync(e){let t={},n=e??this.password;for(let e of this.entries)t[e.path]=xf(this.data,e,{password:n});return t}async forEach(e,t){let n=t??this.password;for(let t of this.entries){let r=null;if(await e(t,()=>(r||=bf(this.data,t,{password:n}),r))===!1)break}}};function Cf(e){return e?16:65536}var wf=class extends t{constructor(e,t){super(e,t),this.name=`StreamError`}},Tf=class extends wf{constructor(e,t,n){super(`Cannot ${e}: ${t}`,n),this.operation=e,this.state=t,this.name=`StreamStateError`}},Ef=class extends wf{constructor(e,t,n){super(`Expected ${e}, got ${t}`,n),this.expectedType=e,this.actualType=t,this.name=`StreamTypeError`}};function Df(e,t){let n=(t??`utf-8`).trim().toLowerCase();switch(n){case``:case`utf8`:case`utf-8`:return Rt.encode(e);case`latin1`:case`binary`:{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}case`ascii`:{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&127;return t}case`hex`:{let t=e.length>>>1,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=parseInt(e.substring(r*2,r*2+2),16);return n}case`base64`:{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}case`base64url`:{let t=e.replace(/-/g,`+`).replace(/_/g,`/`);for(;t.length%4!=0;)t+=`=`;let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}case`utf16le`:case`utf-16le`:case`ucs2`:case`ucs-2`:{let t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>>8&255}return t}default:throw Of(n)}}function Of(e){let t=TypeError(`Unknown encoding: ${e}`);return t.code=`ERR_UNKNOWN_ENCODING`,t}var kf=class{constructor(e){this._items=[],this._index=0,this._front=[],this._byteSize=0,this._objectMode=e}_chunkSize(e){return e instanceof Uint8Array?e.byteLength:1}get length(){return this._front.length+(this._items.length-this._index)}get byteSize(){return this._byteSize}push(e){this._items.push(e),this._objectMode||(this._byteSize+=this._chunkSize(e))}shift(){let e;return this._front.length>0?e=this._front.pop():(e=this._items[this._index++],this._index===this._items.length?(this._items.length=0,this._index=0):this._index>1024&&this._index*2>this._items.length&&(this._items=this._items.slice(this._index),this._index=0)),this._objectMode||(this._byteSize-=this._chunkSize(e)),e}unshift(e){this._index===0?this._front.push(e):(this._index--,this._items[this._index]=e),this._objectMode||(this._byteSize+=this._chunkSize(e))}peek(){let e=this._front.length;return e>0?this._front[e-1]:this._index<this._items.length?this._items[this._index]:null}toArray(){let e=this._front.length,t=this._items.length-this._index,n=Array(e+t);for(let t=0;t<e;t++)n[t]=this._front[e-1-t];for(let r=0;r<t;r++)n[e+r]=this._items[this._index+r];return n}clear(){this._items.length=0,this._index=0,this._front.length=0,this._byteSize=0}consumeBytes(e){if(e===0)return new Uint8Array;let t=this.peek();if(t instanceof Uint8Array&&t.byteLength===e)return this.shift();if(t instanceof Uint8Array&&t.byteLength>e){this._shiftFrontChunk();let n=t.subarray(0,e),r=t.subarray(e);return this.unshift(r),n}let n=new Uint8Array(e),r=0;for(;r<e;){let t=this.shift();if(t instanceof Uint8Array){let i=e-r;t.byteLength<=i?(n.set(t,r),r+=t.byteLength):(n.set(t.subarray(0,i),r),this.unshift(t.subarray(i)),r+=i)}}return n}consumeAll(){let e=this._front.length,t=e+(this._items.length-this._index);if(t===0)return new Uint8Array;if(t===1)return this.shift();let n=this._byteSize,r=new Uint8Array(n),i=0;for(let t=e-1;t>=0;t--){let e=this._front[t];e instanceof Uint8Array&&(r.set(e,i),i+=e.byteLength)}for(let e=this._index;e<this._items.length;e++){let t=this._items[e];t instanceof Uint8Array&&(r.set(t,i),i+=t.byteLength)}return this.clear(),r}_shiftFrontChunk(){return this.shift()}};let Af=(e,t,n)=>{typeof e.off==`function`?e.off(t,n):typeof e.removeListener==`function`&&e.removeListener(t,n)},jf=(e,t,n,r)=>(r?.once?typeof e.once==`function`&&e.once(t,n):typeof e.on==`function`&&e.on(t,n),()=>Af(e,t,n)),Mf=()=>{let e=[];return{add:(t,n,r)=>{e.push(jf(t,n,r))},once:(t,n,r)=>{e.push(jf(t,n,r,{once:!0}))},cleanup:()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}};var Nf=class{constructor(e){this._source=e,this._destinations=[],this._listeners=new Map,this._sourceOverride=null}setSource(e){this._sourceOverride=e}get _emitSource(){return this._sourceOverride??this._source}pipe(e,t){let n=e,r=n,i=typeof n?.write==`function`,a=typeof n?.end==`function`,o=typeof r?.on==`function`,s=typeof r?.once==`function`,c=typeof r?.off==`function`;if(!i||!a||!s&&!o||!c&&!r?.removeListener)throw new Ef(`Writable`,typeof n);this._destinations.push(n);let l,u=()=>{l&&=(Af(r,`drain`,l),void 0)},d=e=>{if(!n.write(e)&&(this._source.pause(),!l)){l=()=>{u(),this._source.resume()},r.on(`drain`,l);let e=this._listeners.get(n);e&&(e.drain=l)}},f=t?.end===!1?void 0:()=>{n.end()},p=()=>{this.unpipe(n)},m=typeof r.once==`function`?`once`:`on`;return r[m](`close`,p),r[m](`finish`,p),this._listeners.set(n,{data:d,end:f,destClose:p,destFinish:p,eventTarget:r}),this._source.on(`data`,d),f&&this._source.once(`end`,f),r.emit?.(`pipe`,this._emitSource),this._source.resume(),e}unpipe(e){if(e){let t=this._destinations.indexOf(e);t!==-1&&(this._destinations.splice(t,1),this._removeListeners(e),this._destinations.length===0&&this._source.pause())}else{let e=this._destinations.length>0;for(let e of this._destinations)this._removeListeners(e);this._destinations=[],e&&this._source.pause()}}_removeListeners(e){let t=this._listeners.get(e);t&&(this._source.off(`data`,t.data),t.end&&this._source.off(`end`,t.end),t.drain&&Af(t.eventTarget,`drain`,t.drain),t.destClose&&Af(t.eventTarget,`close`,t.destClose),t.destFinish&&Af(t.eventTarget,`finish`,t.destFinish),t.eventTarget.emit?.(`unpipe`,this._emitSource),this._listeners.delete(e))}};let Pf=0;function K(e){queueMicrotask(()=>{Pf++;try{e()}finally{Pf--}})}function Ff(){return Pf>0}let If=null;function Lf(){return If}function Rf(e){If=e}function zf(e){return en(this,e??`utf-8`)}var q=class e extends W{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.read==`function`&&typeof t.pipe==`function`&&typeof t.on==`function`&&`readableFlowing`in t}constructor(e){super(),this._reader=null,this._reading=!1,this._ended=!1,this._endEmitted=!1,this._destroyed=!1,this._internalDestroy=!1,this._errored=null,this._closed=!1,this._flowing=!1,this._resumeScheduled=!1,this._hasFlowed=!1,this._encoding=null,this._decoder=null,this._didRead=!1,this._pushMode=!1,this._webStreamMode=!1,this._hasReadImpl=!1,this._constructed=!0,this._asyncIterState=null,this.__excelts_stream=!0,this._objectMode=e?.objectMode??!1,this._highWaterMark=e?.highWaterMark??Cf(this._objectMode),this._buf=new kf(this._objectMode),this._pipes=new Nf(this),this._autoDestroy=e?.autoDestroy??!0,this._emitClose=e?.emitClose??!0,e?.read?(this._read=e.read.bind(this),this._hasReadImpl=!0,this._pushMode=!0):this._hasSubclassRead()&&(this._hasReadImpl=!0,this._pushMode=!0),e?.destroy&&(this._destroy=e.destroy.bind(this)),e?.construct&&(this._constructFunc=e.construct.bind(this)),e?.stream?(this._stream=e.stream,this._webStreamMode=!0):this._stream=null,e?.encoding&&this.setEncoding(e.encoding),e?.signal&&this._setupAbortSignal(e.signal),this._maybeConstruct()}_maybeConstruct(){(this._constructFunc||this._hasSubclassConstruct())&&(this._constructed=!1,K(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){this.destroy(e);return}this._constructed=!0,this._hasReadImpl&&this._flowing&&!this._ended&&!this._destroyed&&this._callRead(this._highWaterMark)})}))}_hasSubclassConstruct(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}_hasSubclassRead(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_read`))return!0;t=Object.getPrototypeOf(t)}return!1}_setupAbortSignal(e){if(e.aborted){this.destroy(r(e.reason));return}let t=()=>{i(),this.destroy(r(e.reason))},n=()=>{i()},i=()=>{e.removeEventListener(`abort`,t),this.off(`close`,n),this.off(`end`,n),this.off(`error`,n)};e.addEventListener(`abort`,t,{once:!0}),this.on(`close`,n),this.on(`end`,n),this.on(`error`,n)}static from(t,n){if(t&&typeof t.getReader==`function`)return e.fromWeb(t,n);if(typeof Blob<`u`&&t instanceof Blob)return e.fromWeb(t.stream(),n);if(t==null||typeof t!=`object`&&typeof t!=`string`){let e=TypeError(`The "iterable" argument must be an instance of Iterable. Received type ${typeof t} (${String(t)})`);throw e.code=`ERR_INVALID_ARG_TYPE`,e}let r=typeof t[Symbol.iterator]==`function`,i=typeof t[Symbol.asyncIterator]==`function`;if(!r&&!i&&typeof t!=`string`){let e=t?.constructor?.name??`Object`,n=TypeError(`The "iterable" argument must be an instance of Iterable. Received an instance of ${e}`);throw n.code=`ERR_INVALID_ARG_TYPE`,n}let a=new e({...n,objectMode:n?.objectMode??!0}),o=t;return Gf(a,Wf(typeof o==`string`?[o]:o)),a}static isDisturbed(e){return e._didRead||(e._destroyed||e._errored!==null)&&!e._endEmitted}static isReadable(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.read==`function`?t.destroyed||t._destroyed||t.readableEnded||t._endEmitted?!1:t.readable!==!1:null}static fromWeb(t,n){return new e({...n,stream:t})}static toWeb(e){return e._webStream}static wrap(t,n){return new e({objectMode:t.readableObjectMode??t.objectMode??!0,...n,destroy(e,n){typeof t.destroy==`function`&&t.destroy(e??void 0),n(e)}}).wrap(t)}push(e,t){if(this._destroyed)return!1;if(this._pushMode=!0,e!==null&&typeof e==`string`&&!this._objectMode){let n=Df(e,t||`utf8`);n.toString=zf,e=n}if(this._ended&&e!==null){let e=Error(`stream.push() after EOF`);return e.code=`ERR_STREAM_PUSH_AFTER_EOF`,K(()=>this.emit(`error`,e)),!1}if(e===null)return this._ended?!1:(this._ended=!0,this._buf.length===0&&K(()=>this._emitEndOnce()),!1);if(!this._objectMode&&(typeof e==`string`?e.length:e?.byteLength??e?.length??0)===0)return!0;if(this._flowing)return this._buf.length>0?(this._buf.push(e),this._objectMode?this._buf.length<this._highWaterMark:this._buf.byteSize<this._highWaterMark):(this._didRead=!0,this.emit(`data`,this._applyEncoding(e)),this._flowing?(this._hasReadImpl&&!this._ended&&K(()=>{this._flowing&&!this._ended&&!this._destroyed&&(this._callRead(this._highWaterMark),this._ended&&this._buf.length===0&&this._emitEndOnce())}),!0):!1);{let t=this._buf.length===0;return this._buf.push(e),t&&K(()=>this.emit(`readable`)),this._objectMode?this._buf.length<this._highWaterMark:this._buf.byteSize<this._highWaterMark}}_emitEndOnce(){if(this._endEmitted||this._destroyed||this._buf.length>0)return;let e=this._flushDecoder();e&&this.emit(`data`,e),this._endEmitted=!0,this.emit(`end`),this._autoDestroy&&this.destroy()}unshift(e,t){if(this._destroyed)return;if(e===null){this._ended||(this._ended=!0,this._buf.length===0&&K(()=>this._emitEndOnce()));return}if(this._endEmitted){let e=Error(`stream.unshift() after end event`);e.code=`ERR_STREAM_UNSHIFT_AFTER_END_EVENT`,K(()=>this.emit(`error`,e));return}if(typeof e==`string`&&!this._objectMode){let n=Df(e,t||`utf8`);n.toString=zf,e=n}let n=this._buf.length===0;this._buf.unshift(e),this._flowing?K(()=>{for(;this._buf.length>0&&this._flowing;){let e=this._buf.shift();this._didRead=!0,this.emit(`data`,this._applyEncoding(e))}this._ended&&this._buf.length===0&&this._emitEndOnce()}):n&&K(()=>this.emit(`readable`))}_callRead(e){try{this._read(e)}catch(e){let t=e instanceof Error?e:Error(String(e));this._internalDestroy=!0,this.destroy(t)}}read(e){this._didRead=!0;let t;if(e!=null){if(t=parseInt(e,10),isNaN(t))t=void 0;else if(t<=0){if(t===0&&!this._ended&&!this._destroyed&&this._constructed){let e=this._objectMode?this._buf.length:this._buf.byteSize;(e<this._highWaterMark||e===0)&&this._callRead(this._highWaterMark)}return null}}if(this._buf.length===0)return!this._ended&&!this._destroyed&&this._constructed&&this._callRead(this._highWaterMark),null;if(this._objectMode){let e=this._buf.shift();return this._ended&&this._buf.length===0&&K(()=>this._emitEndOnce()),this._hasReadImpl&&!this._ended&&!this._destroyed&&this._constructed&&this._buf.length<this._highWaterMark&&K(()=>{!this._ended&&!this._destroyed&&this._callRead(this._highWaterMark)}),e}let n;if(t==null)n=this._applyEncoding(this._buf.consumeAll());else if(this._buf.byteSize<t)if(this._ended)n=this._applyEncoding(this._buf.consumeAll());else return this._hasReadImpl&&this._constructed&&this._callRead(Math.max(t,this._highWaterMark)),null;else n=this._applyEncoding(this._buf.consumeBytes(t));return this._hasReadImpl&&!this._ended&&!this._destroyed&&this._buf.byteSize<this._highWaterMark&&K(()=>{!this._ended&&!this._destroyed&&this._callRead(this._highWaterMark)}),this._ended&&this._buf.length===0&&K(()=>this._emitEndOnce()),!this._flowing&&this._buf.length>0&&K(()=>this.emit(`readable`)),n}_flushDecoder(){if(!this._decoder)return null;let e=this._decoder.decode(new Uint8Array,{stream:!1});return this._decoder=null,e||null}setEncoding(e){return this._encoding=e,this._decoder=Wt(e),this}_applyEncoding(e){return this._encoding&&e instanceof Uint8Array?(this._decoder||=Wt(this._encoding),this._decoder.decode(e,{stream:!0})):e}wrap(e){let t=!1;return e.on(`data`,n=>{this.push(n)||(e.pause(),t=!0)}),e.on(`end`,()=>this.push(null)),e.on(`error`,e=>this.destroy(e)),e.on(`close`,()=>this.destroy()),this._hasReadImpl=!0,this._read=()=>{t&&(t=!1,e.resume())},this}pause(){return this._flowing?(this._flowing=!1,this.emit(`pause`)):this._hasFlowed=!0,this}resume(){return this._flowing||(this._flowing=!0,this._hasFlowed=!0,this._resumeScheduled||(this._resumeScheduled=!0,K(()=>{this._resumeScheduled=!1,this.emit(`resume`)}))),this._buf.length>0?K(()=>{for(;this._buf.length>0&&this._flowing;){let e=this._buf.shift();this._didRead=!0,this.emit(`data`,this._applyEncoding(e))}if(this._ended&&this._buf.length===0&&this._emitEndOnce(),this._flowing&&this._buf.length===0&&this._webStreamMode&&!this._pushMode&&!this._ended&&!this._destroyed&&this._startReading(),this._hasReadImpl&&this._flowing&&!this._ended&&!this._destroyed&&this._constructed){let e=this._objectMode?this._buf.length:this._buf.byteSize;(e<this._highWaterMark||e===0)&&this._callRead(this._highWaterMark)}}):this._ended&&this._buf.length===0?K(()=>this._emitEndOnce()):this._webStreamMode&&!this._pushMode?this._startReading():this._hasReadImpl&&K(()=>{this._flowing&&!this._ended&&!this._destroyed&&this._constructed&&(this._callRead(this._highWaterMark),this._ended&&this._buf.length===0&&this._emitEndOnce())}),this}on(e,t){return super.on(e,t),e===`data`?this.resume():e===`readable`&&(this._hasFlowed=!0,this._flowing=!1,(this._buf.length>0||this._ended)&&K(()=>this.emit(`readable`))),this}isPaused(){return this.readableFlowing===!1}pipe(e,t){return this._pipes.pipe(e,t)}unpipe(e){return this._pipes.unpipe(e),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._readableOverride=void 0,this.unpipe(),this._reader){let e=this._reader;this._reader=null,e.cancel().catch(()=>{}).finally(()=>{try{e.releaseLock()}catch{}})}let t=e=>{let t=e||null;t&&(this._errored=t),this._closed=!0;let n=()=>{t&&this.emit(`error`,t),this._emitClose&&this.emit(`close`)},r=this._endEmitted||this._internalDestroy;this._internalDestroy=!1,Ff()&&!this._hasDestroyHook()&&r?n():K(n)};if(this._hasDestroyHook())try{this._destroy(e??null,t)}catch(e){t(e instanceof Error?e:Error(String(e)))}else t(e);return this}_destroy(e,t){t(e)}_undestroy(){this._destroyed=!1,this._closed=!1,this._errored=null}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}get _webStream(){if(this._stream)return this._stream;let e=this,t=!1,n=new ReadableStream({pull(n){return new Promise((r,i)=>{if(t)return r();let a=()=>{if(e._destroyed){if(e._errored){t=!0;try{n.error(e._errored)}catch{}return i(e._errored)}t=!0;try{n.close()}catch{}return r()}let o=e.read();if(o!==null){try{n.enqueue(o)}catch{}return r()}if(e._endEmitted){t=!0;try{n.close()}catch{}return r()}let s=()=>{d(),a()},c=()=>{d(),t=!0;try{n.close()}catch{}r()},l=e=>{d(),t=!0;try{n.error(e)}catch{}i(e)},u=()=>{if(d(),!t){t=!0;try{n.close()}catch{}}r()},d=()=>{e.off(`readable`,s),e.off(`end`,c),e.off(`error`,l),e.off(`close`,u)};e.once(`readable`,s),e.once(`end`,c),e.once(`error`,l),e.once(`close`,u)};a()})},cancel(){e.destroy()}});return this._stream=n,n}get readable(){return this._readableOverride===void 0?!this._destroyed&&!this._endEmitted:this._readableOverride}set readable(e){this._readableOverride=e}get readableEnded(){return this._endEmitted}get readableLength(){return this._objectMode?this._buf.length:this._buf.byteSize}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e}get errored(){return this._errored}get closed(){return this._closed}get readableFlowing(){return this._flowing?!0:this._hasFlowed?!1:null}set readableFlowing(e){e===!0?(this._flowing=!0,this._hasFlowed=!0):e===!1?(this._flowing=!1,this._hasFlowed=!0):(this._flowing=!1,this._hasFlowed=!1)}_setReadableFlowing(e){this.readableFlowing=e}get readableAborted(){return this._readableOverride===!1?!1:(this._destroyed||!!this._errored)&&!this._endEmitted}get readableDidRead(){return this._didRead}get readableEncoding(){return this._encoding}get readableObjectMode(){return this._objectMode}get readableHighWaterMark(){return this._highWaterMark}get readableBuffer(){return this._buf.toArray()}_releaseReader(){if(this._reader){let e=this._reader;this._reader=null;try{e.releaseLock()}catch{}}}async _startReading(){if(!(this._reading||this._destroyed||!this._flowing)){this._reading=!0;try{for(this._reader||=this._stream.getReader();this._flowing&&!this._destroyed&&!this._pushMode;){let{done:e,value:t}=await this._reader.read();if(this._pushMode){this._releaseReader();break}if(e){this._ended=!0,this._buf.length===0&&K(()=>this._emitEndOnce()),this._releaseReader();break}if(t!==void 0){let e=this._buf.length===0;for(this._buf.push(t),e&&K(()=>this.emit(`readable`));this._buf.length>0&&this._flowing;){let e=this._buf.shift();this._didRead=!0,this.emit(`data`,this._applyEncoding(e))}if(!this._flowing)break}}}catch(e){this.emit(`error`,e),this._releaseReader()}finally{this._reading=!1}}}async*[Symbol.asyncIterator](){this._asyncIterState||=this._initAsyncIterState();let e=this._asyncIterState;e.activeCount++;try{for(;;){if(e.streamError)throw e.streamError;if(e.dataQueueIndex<e.dataQueue.length){let t=e.dataQueue[e.dataQueueIndex];e.dataQueue[e.dataQueueIndex]=void 0,e.dataQueueIndex++,e.queuedSize-=this._chunkSizeForBackpressure(t),e.dataQueueIndex>=1024&&e.dataQueueIndex*2>=e.dataQueue.length&&(e.dataQueue.splice(0,e.dataQueueIndex),e.dataQueueIndex=0),this._maybeResumeIterState(e),yield t;continue}if(e.done)break;let t=await new Promise((t,n)=>{e.resolverQueue.push({resolve:t,reject:n})});if(t===null)break;yield t}}finally{e.activeCount--,e.activeCount===0&&this._teardownAsyncIterState(),this._destroyed||this.destroy()}}_chunkSizeForBackpressure(e){return this._objectMode?1:e instanceof Uint8Array?e.byteLength:typeof e==`string`?e.length:1}_maybeResumeIterState(e){e.pausedByIterator&&e.queuedSize<this._highWaterMark&&!e.done&&!this._destroyed&&(e.pausedByIterator=!1,this.resume())}_initAsyncIterState(){let e=this._highWaterMark,t={dataQueue:[],dataQueueIndex:0,queuedSize:0,resolverQueue:[],done:!1,streamError:null,activeCount:0,listenersAttached:!1,pausedByIterator:!1,dataHandler:null,doneHandler:null,errorHandler:null};for(t.dataHandler=n=>{if(t.resolverQueue.length>0){let{resolve:e}=t.resolverQueue.shift();e(n);return}t.dataQueue.push(n),t.queuedSize+=this._chunkSizeForBackpressure(n),!t.pausedByIterator&&t.queuedSize>=e&&(t.pausedByIterator=!0,this.pause())},t.doneHandler=()=>{t.done=!0;for(let{resolve:e}of t.resolverQueue)e(null);t.resolverQueue.length=0},t.errorHandler=e=>{t.done=!0,t.streamError=e;for(let{reject:n}of t.resolverQueue)n(e);t.resolverQueue.length=0};this._buf.length>0;){let e=this._applyEncoding(this._buf.shift());t.dataQueue.push(e),t.queuedSize+=this._chunkSizeForBackpressure(e)}if(this._ended){let e=this._flushDecoder();e&&(t.dataQueue.push(e),t.queuedSize+=this._chunkSizeForBackpressure(e)),t.done=!0}else this.on(`data`,t.dataHandler),this.on(`end`,t.doneHandler),this.on(`error`,t.errorHandler),this.on(`close`,t.doneHandler),t.listenersAttached=!0,this.resume();return t}_teardownAsyncIterState(){let e=this._asyncIterState;e&&(e.listenersAttached&&(this.off(`data`,e.dataHandler),this.off(`end`,e.doneHandler),this.off(`error`,e.errorHandler),this.off(`close`,e.doneHandler)),this._asyncIterState=null)}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this._endEmitted?t():n(Error(`Premature close`))};this._closed?r():this.once(`close`,r)})}iterator(e){if(e?.destroyOnReturn??!0)return this[Symbol.asyncIterator]();let t=this,n=null,r=null,i=!1,a=null,o=()=>{if(!n)return;let e=t.read();if(e!==null){let t=n;n=null,r=null,t({done:!1,value:e})}},s=()=>{o()},c=()=>{if(i=!0,n){let e=n;n=null,r=null,e({done:!0,value:void 0})}},l=e=>{if(i=!0,a=e,r){let t=r;n=null,r=null,t(e)}};t.on(`readable`,s),t.on(`end`,c),t.on(`error`,l);let u=()=>{t.off(`readable`,s),t.off(`end`,c),t.off(`error`,l)};return{next:async()=>{if(a)throw a;let e=t.read();return e===null?i?(u(),{done:!0,value:void 0}):new Promise((e,t)=>{n=e,r=t,o()}):{done:!1,value:e}},return:async e=>(u(),{done:!0,value:e}),throw:async e=>(u(),t.destroy(e),{done:!0,value:void 0}),[Symbol.asyncIterator](){return this}}}map(t,n){let i=n?.signal;Bf(i);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0});return Gf(c,(async function*(e){try{yield*Uf(e,e=>t(e,{signal:s}),a,i)}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{c.destroy(r())},{once:!0}),c}filter(t,n){let i=n?.signal;Bf(i);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0}),l=Symbol(`skip`);return Gf(c,(async function*(e){try{if(a<=1)for await(let n of e)J(i),await t(n,{signal:s})&&(yield n);else for await(let n of Uf(e,async e=>await t(e,{signal:s})?e:l,a,i))n!==l&&(yield n)}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{c.destroy(r())},{once:!0}),c}async forEach(e,t){let n=t?.signal;Bf(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1)for await(let t of this)J(n),await e(t,{signal:a});else for await(let t of Uf(this,async t=>{await e(t,{signal:a})},r,n));}finally{i.abort()}}async toArray(e){let t=e?.signal;Bf(t);let n=[];for await(let e of this)J(t),n.push(e);return n}async some(e,t){let n=t?.signal;Bf(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if(J(n),await e(t,{signal:a}))return this.destroy(),!0}else for await(let t of Uf(this,t=>e(t,{signal:a}),r,n))if(t)return this.destroy(),!0;return!1}finally{i.abort()}}async find(e,t){let n=t?.signal;Bf(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if(J(n),await e(t,{signal:a}))return this.destroy(),t}else for await(let t of Uf(this,async t=>({chunk:t,match:await e(t,{signal:a})}),r,n))if(t.match)return this.destroy(),t.chunk;return}finally{i.abort()}}async every(e,t){let n=t?.signal;Bf(n);let r=t?.concurrency??1,i=new AbortController,a=i.signal;try{if(r<=1){for await(let t of this)if(J(n),!await e(t,{signal:a}))return this.destroy(),!1}else for await(let t of Uf(this,t=>e(t,{signal:a}),r,n))if(!t)return this.destroy(),!1;return!0}finally{i.abort()}}flatMap(t,n){let i=n?.signal;Bf(i);let a=n?.concurrency??1,o=new AbortController,s=o.signal,c=new e({objectMode:!0});return Gf(c,(async function*(e){try{if(a<=1)for await(let n of e){J(i);let e=await t(n,{signal:s});if(e&&typeof e[Symbol.asyncIterator]==`function`)for await(let t of e)yield t;else if(e&&typeof e[Symbol.iterator]==`function`)for(let t of e)yield t}else for await(let n of Uf(e,async e=>{let n=await t(e,{signal:s}),r=[];if(n&&typeof n[Symbol.asyncIterator]==`function`)for await(let e of n)r.push(e);else if(n&&typeof n[Symbol.iterator]==`function`)for(let e of n)r.push(e);return r},a,i))for(let e of n)yield e}finally{o.abort()}})(this)),c.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{c.destroy(r())},{once:!0}),c}drop(t,n){let i=n?.signal;Bf(i),Vf(t,`limit`);let a=new e({objectMode:!0});return Gf(a,(async function*(e){let n=0;for await(let r of e)J(i),n>=t&&(yield r),n++})(this)),a.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{a.destroy(r())},{once:!0}),a}take(t,n){let i=n?.signal;Bf(i),Vf(t,`limit`);let a=new e({objectMode:!0});return Gf(a,(async function*(e){let n=0;for await(let r of e){if(J(i),n>=t)break;yield r,n++}})(this)),a.once(`close`,()=>{this.destroyed||this.destroy()}),i&&i.addEventListener(`abort`,()=>{a.destroy(r())},{once:!0}),a}async reduce(e,t,n){let r=n?.signal;Bf(r);let i=new AbortController,a=i.signal,o,s=arguments.length>=2,c=!0;try{for await(let n of this){if(J(r),c&&!s){o=n,c=!1;continue}c&&=(o=t,!1),o=await e(o,n,{signal:a})}if(c&&!s)throw TypeError(`Reduce of an empty stream requires an initial value`);return c?t:o}finally{i.abort()}}asIndexedPairs(e){let t=0;return this.map(e=>[t++,e],e)}compose(t,n){if(typeof t==`function`){let n=new e({objectMode:!0});Gf(n,t(this)),n.once(`close`,()=>{this.destroyed||this.destroy()});let r=Lf();return r?r(n):n}let r=t;if(this.pipe(r),r._readable&&r._writable)return r;if(r._readable){let e=Lf();return e?e(r._readable):r._readable}let i=Lf();return i?i(r):r}};q.prototype.addListener=q.prototype.on,q.prototype._read=function(e){let t=Error(`The _read() method is not implemented`);throw t.code=`ERR_METHOD_NOT_IMPLEMENTED`,t};function Bf(e){if(e!==void 0&&!(e instanceof AbortSignal))throw TypeError(`options.signal must be an AbortSignal`)}function J(e){if(e?.aborted)throw r(e.reason)}function Vf(e,t){if(typeof e!=`number`||Number.isNaN(e)||e<0||Math.floor(e)!==e)throw RangeError(`The value of "${t}" must be a non-negative integer. Received ${e}`)}let Hf=Symbol(`EOF`);async function*Uf(e,t,n,r){if(n<=1){for await(let n of e)J(r),yield await t(n);return}let i=[],a=null,o=!1,s=e[Symbol.asyncIterator]();async function c(){let e=await s.next();return e.done?(o=!0,Hf):(J(r),t(e.value))}function l(){i.push(c().catch(e=>{throw a=e,e}))}try{for(;i.length<n&&!o&&!a;)J(r),l();for(;i.length>0;){J(r);let e=await i.shift();if(a)throw a;e!==Hf&&(yield e,!o&&!a&&l())}}finally{o||await s.return?.()}}function Wf(e){return e&&typeof e[Symbol.asyncIterator]==`function`?e:(async function*(){for(let t of e)yield t})()}function Gf(e,t){let n=t[Symbol.asyncIterator](),r=!1,i=!1;e._hasReadImpl=!0,e._read=function(){r||i||(r=!0,(async()=>{try{if(e.destroyed){if(!i){i=!0;let e=n.return?.();e&&typeof e.then==`function`&&e.catch(()=>{})}return}let{value:t,done:r}=await n.next();if(r){i=!0,e.push(null);return}e.push(t)}catch(t){e.destroy(t)}finally{r=!1}})())},e._pushMode=!0}function Kf(e,t,n){return{chunk:typeof e==`function`?void 0:e,encoding:typeof t==`string`?t:void 0,cb:typeof e==`function`?e:typeof t==`function`?t:n}}function qf(e){return en(this,e??`utf-8`)}var Y=class e extends W{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.write==`function`&&typeof t.end==`function`&&typeof t.on==`function`&&`writableFinished`in t}constructor(e){if(super(),this._stream=null,this._writer=null,this._ended=!1,this._finished=!1,this._syncFinish=!1,this._destroyed=!1,this._errored=null,this._errorEmitted=!1,this._closed=!1,this._writableLength=0,this._needDrain=!1,this._corked=0,this._corkedChunks=[],this._defaultEncoding=`utf8`,this._ownsStream=!1,this._directWrite=!1,this._writeQueue=[],this._writing=!1,this._pendingEnd=null,this._constructed=!0,this._resolvedWritev=null,this.__excelts_stream=!0,this._objectMode=e?.objectMode??!1,this._highWaterMark=e?.highWaterMark??Cf(this._objectMode),this._autoDestroy=e?.autoDestroy??!0,this._emitClose=e?.emitClose??!0,this._decodeStrings=e?.decodeStrings??!0,this._defaultEncoding=e?.defaultEncoding??`utf8`,e?.stream)this._stream=e.stream,this._ownsStream=!1,this._directWrite=!1;else{if(e?.write&&(this._writeFunc=e.write.bind(this)),e?.final)this._finalFunc=e.final.bind(this);else{let e=this._getSubclassFinal();e&&(this._finalFunc=e)}if(e?.destroy&&(this._destroy=e.destroy.bind(this)),e?.construct&&(this._constructFunc=e.construct.bind(this)),e?.writev&&(this._writevFunc=e.writev.bind(this)),this._ownsStream=!0,this._writeFunc)this._directWrite=!0,this._stream=null;else{let t=e?.construct||this._hasSubclassConstruct(),n=this._getSubclassWrite();t&&n?(this._writeFunc=n,this._directWrite=!0,this._stream=null):(this._directWrite=!1,this._stream=new WritableStream({write:async e=>{this._write&&await new Promise((t,n)=>{this._write(e,`utf8`,e=>{e?n(e):t()})})},close:async()=>{if(this._finalFunc){let e=await new Promise(e=>{this._finalFunc(t=>{e(t??null)})});if(e){this._errored=e,this._errorEmitted=!0,this.emit(`error`,e),this._autoDestroy&&this.destroy(e);return}}this._finished=!0,this.emit(`finish`),this._autoDestroy&&this.destroy()},abort:e=>{this.emit(`error`,e)}}))}}e?.signal&&this._setupAbortSignal(e.signal),this._resolvedWritev=this._writevFunc??this._getWritevHook(),this._maybeConstruct()}_maybeConstruct(){(this._constructFunc||this._hasSubclassConstruct())&&(this._constructed=!1,K(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){this.destroy(e);return}if(this._constructed=!0,this._directWrite&&this._writeQueue.length>0&&!this._writing)this._writing=!0,this._drainWriteQueue();else if(this._pendingEnd&&!this._writing){let{cb:e}=this._pendingEnd;this._pendingEnd=null,this._doFinish(e)}})}))}_hasSubclassConstruct(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}_getSubclassWrite(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_write`))return t._write.bind(this);t=Object.getPrototypeOf(t)}return null}_getSubclassFinal(){let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_final`))return t._final.bind(this);t=Object.getPrototypeOf(t)}return null}_getWritevHook(){let t=Object.getPrototypeOf(this);return t._writev&&t._writev!==e.prototype._writev?t._writev.bind(this):null}_setupAbortSignal(e){if(e.aborted){this.destroy(r(e.reason));return}let t=()=>{i(),this.destroy(r(e.reason))},n=()=>{i()},i=()=>{e.removeEventListener(`abort`,t),this.off(`close`,n),this.off(`finish`,n),this.off(`error`,n)};e.addEventListener(`abort`,t,{once:!0}),this.on(`close`,n),this.on(`finish`,n),this.on(`error`,n)}setDefaultEncoding(e){return Df(``,e),this._defaultEncoding=e,this}cork(){this._corked++}uncork(){if(this._corked>0&&this._corked--,this._corked===0){let e=this._corkedChunks;if(this._corkedChunks=[],e.length===0)return;for(let{chunk:t}of e)this._writableLength-=this._getChunkSize(t);let t=this._resolvedWritev;if(t&&e.length>1){let n=e.map(({chunk:e,encoding:t})=>({chunk:e,encoding:t})),r=n.reduce((e,{chunk:t})=>e+this._getChunkSize(t),0);this._writableLength+=r,this._writing=!0;try{t(n,t=>{if(this._writableLength-=r,this._writing=!1,t){this._destroyed||(this._errored=t,this.emit(`error`,t),this._autoDestroy&&this.destroy(t));for(let{callback:n}of e)n?.(t);return}this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,K(()=>this.emit(`drain`)));for(let{callback:t}of e)t?.(null);this._drainWriteQueue()})}catch(t){this._writableLength-=r,this._writing=!1;let n=t instanceof Error?t:Error(String(t));this._destroyed||(this._errored=n,this.emit(`error`,n),this._autoDestroy&&this.destroy(n));for(let{callback:t}of e)t?.(n)}}else for(let{chunk:t,encoding:n,callback:r}of e)this._doWrite(t,n,r)}}write(e,t,n){if(e===null){let e=TypeError(`May not write null values to stream`);throw e.code=`ERR_STREAM_NULL_VALUES`,e}if(this._destroyed||this._ended){let e=this._destroyed&&!this._ended,r=Error(e?`Cannot call write after a stream was destroyed`:`write after end`);r.code=e?`ERR_STREAM_DESTROYED`:`ERR_STREAM_WRITE_AFTER_END`;let i=typeof t==`function`?t:n;return this._errored||=r,i&&K(()=>i(r)),!this._destroyed&&!this._errorEmitted&&(this._errorEmitted=!0,K(()=>this.emit(`error`,r))),!1}let r=typeof t==`string`?t:this._defaultEncoding,i=typeof t==`function`?t:n;if(this._corked>0){let t=this._normalizeWriteChunk(e,r);this._corkedChunks.push({chunk:t.chunk,encoding:t.encoding,callback:i});let n=this._getChunkSize(t.chunk,t.encoding);this._writableLength+=n;let a=this._writableLength<this._highWaterMark;return a||(this._needDrain=!0),a}let a=this._normalizeWriteChunk(e,r),o=this._doWrite(a.chunk,a.encoding,i);return o||(this._needDrain=!0),o}_doWrite(e,t,n){let r=this._getChunkSize(e,t);return this._writableLength+=r,this._directWrite?this._writing||!this._constructed?this._writeQueue.push({chunk:e,chunkSize:r,encoding:t,callback:n}):(this._writing=!0,this._callWriteFunc(e,r,t,n)):this._getWriter().write(e).then(()=>{this._writableLength-=r,this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,K(()=>this.emit(`drain`))),n?.(null)}).catch(e=>{this._writableLength-=r,this._destroyed||(this._errored=e,this._errorEmitted=!0,this.emit(`error`,e),this._autoDestroy&&this.destroy(e)),n?.(e)}),this._writableLength<this._highWaterMark}_callWriteFunc(e,t,n,r){try{let i=this._objectMode?void 0:n,a=!1,o=!0;this._writeFunc(e,i,e=>{if(a){let e=Error(`Callback called multiple times`);e.code=`ERR_MULTIPLE_CALLBACK`,this.destroy(e);return}if(a=!0,e){if(this._writableLength-=t,this._destroyed?r?.(e):(this._errored=e,this._errorEmitted=!0,o?K(()=>{r?.(e),this.emit(`error`,e),this._autoDestroy&&this.destroy(e)}):(r?.(e),this.emit(`error`,e),this._autoDestroy&&this.destroy(e))),this._writing=!1,this._flushWriteQueueOnError(e),this._pendingEnd){let{cb:t}=this._pendingEnd;this._pendingEnd=null,t?.(e)}return}this._writableLength-=t,this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,K(()=>this.emit(`drain`))),r?.(null),this._drainWriteQueue()}),o=!1}catch(e){this._writableLength-=t;let n=e instanceof Error?e:Error(String(e));if(this._destroyed||(this._errored=n,this.emit(`error`,n),this._autoDestroy&&this.destroy(n)),r?.(n),this._writing=!1,this._flushWriteQueueOnError(n),this._pendingEnd){let{cb:e}=this._pendingEnd;this._pendingEnd=null,e?.(n)}}}_drainWriteQueue(){if(this._writeQueue.length===0){if(this._writing=!1,this._pendingEnd){let{cb:e}=this._pendingEnd;this._pendingEnd=null,this._doFinish(e)}return}let e=this._resolvedWritev;if(e&&this._writeQueue.length>1){let t=this._writeQueue;this._writeQueue=[];let n=0,r=Array(t.length);for(let e=0;e<t.length;e++){let i=t[e];r[e]={chunk:i.chunk,encoding:i.encoding},n+=i.chunkSize}try{e(r,e=>{if(e){this._writableLength-=n,this._destroyed||(this._errored=e,this._errorEmitted=!0,this.emit(`error`,e));for(let n of t)n.callback?.(e);this._writing=!1,this._flushWriteQueueOnError(e);return}this._writableLength-=n,this._needDrain&&this._writableLength<this._highWaterMark&&(this._needDrain=!1,K(()=>this.emit(`drain`)));for(let e of t)e.callback?.(null);this._drainWriteQueue()})}catch(e){this._writableLength-=n,this._writing=!1;let r=e instanceof Error?e:Error(String(e));this._destroyed||(this._errored=r,this.emit(`error`,r));for(let e of t)e.callback?.(r)}}else{let e=this._writeQueue.shift();this._callWriteFunc(e.chunk,e.chunkSize,e.encoding,e.callback)}}_flushWriteQueueOnError(e){let t=this._writeQueue;this._writeQueue=[];for(let n of t)this._writableLength-=n.chunkSize,n.callback?.(e)}_doFinish(e){if(this._finalFunc)this._finalFunc(t=>{if(t){this._errorEmitted=!0,this.emit(`error`,t),e&&(this._pendingEnd={cb:e}),this._autoDestroy&&!this._destroyed&&this.destroy(t);return}let n=()=>{if(this._destroyed){e?.();return}this._finished=!0,this.emit(`prefinish`),e?.(),this.emit(`finish`),this._autoDestroy&&this.destroy()};this._syncFinish?(this._syncFinish=!1,n()):K(n)});else{let t=()=>{if(this._destroyed){e?.();return}this._finished=!0,this.emit(`prefinish`),e?.(),this.emit(`finish`),this._autoDestroy&&this.destroy()};Ff()?t():K(t)}}_getChunkSize(e,t){return this._objectMode?1:e instanceof Uint8Array?e.byteLength:typeof e==`string`?Yf(e,t):0}_normalizeWriteChunk(e,t){if(this._objectMode||typeof e!=`string`||!this._decodeStrings)return{chunk:e,encoding:t};let n=Df(e,t);return n.toString=qf,{chunk:n,encoding:`buffer`}}end(e,t,n){if(this._ended){let{chunk:r,encoding:i,cb:a}=Kf(e,t,n);if(r!==void 0)return this.write(r,i??this._defaultEncoding,e=>{a?.(e??null)}),this;if(this._finished&&a){let e=Error(`Cannot call end after a stream was finished`);e.code=`ERR_STREAM_ALREADY_FINISHED`,K(()=>a(e))}else K(()=>a?.(null));return this}this._ended=!0,this._writableOverride=void 0;let{chunk:r,encoding:i,cb:a}=Kf(e,t,n);if(this._corked>0&&(this._corked=1,this.uncork()),this._directWrite){if(r!==void 0){let e=this._normalizeWriteChunk(r,i??this._defaultEncoding);this._doWrite(e.chunk,e.encoding)}if(this._errored){let e=this._errored;return K(()=>a?.(e)),this}return this._writing||this._writeQueue.length>0?this._pendingEnd={cb:a}:this._doFinish(a),this}return(async()=>{try{let e=this._getWriter();if(r!==void 0){let{chunk:t}=this._normalizeWriteChunk(r,i??this._defaultEncoding);await e.write(t)}if(await e.close(),this._writer===e){this._writer=null;try{e.releaseLock()}catch{}}this._ownsStream||(this._finished=!0,this.emit(`finish`),this._autoDestroy&&this.destroy()),a&&a()}catch(e){this.emit(`error`,e)}})(),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._writableOverride=void 0,e&&!this._errored&&(this._errored=e),this._writeQueue.length>0&&this._flushWriteQueueOnError(e??Error(`Cannot call write after a stream was destroyed`)),this._corkedChunks.length>0){let t=e??Error(`Cannot call write after a stream was destroyed`);for(let e of this._corkedChunks)e.callback?.(t);this._corkedChunks=[]}let t=this._pendingEnd?.cb;if(this._pendingEnd=null,this._writing=!1,this._writer){let t=this._writer;this._writer=null,t.abort(e).catch(()=>{}).finally(()=>{try{t.releaseLock()}catch{}})}let n=e=>{let n=e||null;n&&(this._errored=n),this._closed=!0;let r=()=>{n&&!this._errorEmitted&&(this._errorEmitted=!0,this.emit(`error`,n)),this._emitClose&&this.emit(`close`),t?.(n)};Ff()&&!this._hasDestroyHook()&&this._finished?r():K(r)};if(this._hasDestroyHook())try{this._destroy(e??null,n)}catch(e){n(e instanceof Error?e:Error(String(e)))}else n(e);return this}_destroy(e,t){t(e)}_undestroy(){this._destroyed=!1,this._closed=!1,this._errored=null,this._errorEmitted=!1}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this._finished?t():n(Error(`Premature close`))};this._closed?r():this.once(`close`,r)})}get _webStream(){return this._stream||=new WritableStream({write:e=>new Promise((t,n)=>{let r=this._objectMode?void 0:this._defaultEncoding;this._writeFunc(e,r,e=>{e?n(e):t()})}),close:async()=>{this._finalFunc&&await new Promise((e,t)=>{this._finalFunc(n=>{n?t(n):e()})})},abort:e=>{this.emit(`error`,e)}}),this._stream}get writable(){return this._writableOverride===void 0?!this._destroyed&&!this._ended:this._writableOverride}set writable(e){this._writableOverride=e}get writableEnded(){return this._ended}get writableFinished(){return this._finished}get writableLength(){return this._writableLength}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e}get errored(){return this._errored}get closed(){return this._closed}get writableNeedDrain(){return this._needDrain}get writableCorked(){return this._corked}get writableAborted(){return this._writableOverride===!1?!1:(this._destroyed||!!this._errored)&&!this._finished}get writableObjectMode(){return this._objectMode}get writableHighWaterMark(){return this._highWaterMark}get writableBuffer(){let e=this._corkedChunks.map(e=>e.chunk);for(let t of this._writeQueue)e.push(t.chunk);return e}pipe(){let e=new Tf(`pipe`,`not readable`);e.code=`ERR_STREAM_CANNOT_PIPE`,K(()=>this.emit(`error`,e))}_getWriter(){return this._writer||=this._webStream.getWriter(),this._writer}static isDisturbed(e){return e&&e._readable instanceof q?q.isDisturbed(e._readable):q.isDisturbed(e)}static fromWeb(t,n){return new e({...n,stream:t})}static toWeb(e){return e._webStream}};Y.prototype._writev=null,Y.prototype._write=function(e,t,n){let r=Error(`The _write() method is not implemented`);throw r.code=`ERR_METHOD_NOT_IMPLEMENTED`,r};function Jf(e){return e instanceof Y?e:e?.getWriter?new Y({stream:e}):e}function Yf(e,t){let n=(t??`utf8`).toLowerCase();return n===`ascii`||n===`latin1`||n===`binary`?e.length:n===`utf16le`||n===`utf-16le`||n===`ucs2`?e.length*2:Xf(e)}function Xf(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<=127?t+=1:r<=2047?t+=2:r>=55296&&r<=56319?(t+=4,n++):t+=3}return t}var Zf=class e extends W{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.read==`function`&&typeof t.pipe==`function`&&typeof t.write==`function`&&typeof t.end==`function`&&typeof t.on==`function`&&`readableFlowing`in t&&`writableFinished`in t}static isDisturbed(e){return e&&e._readable instanceof q?q.isDisturbed(e._readable):q.isDisturbed(e)}static from(t){if(t instanceof e)return t;let n=(e,t)=>{let n=new Y({objectMode:t.readableObjectMode,write(e,n,r){t.push(e),r()},final(e){t.push(null),e()}}),r=jf(e,`error`,e=>{t.emit(`error`,e)});jf(e,`end`,r,{once:!0}),jf(e,`close`,r,{once:!0}),jf(n,`finish`,r,{once:!0}),e.pipe(n)};if(t instanceof Promise){let r=new e({objectMode:!0});return t.then(t=>{n(e.from(t),r)}).catch(e=>{r.destroy(e instanceof Error?e:Error(String(e)))}),r}if(typeof t==`string`){let r=q.from([t]),i=new e({objectMode:!0});return n(r,i),i}if(typeof Blob<`u`&&t instanceof Blob){let r=q.fromWeb(t.stream()),i=new e;return n(r,i),i}if(typeof t==`object`&&t&&`readable`in t&&`writable`in t){let r=t,i=new e({readableObjectMode:r.readable?.readableObjectMode,writableObjectMode:r.writable?.writableObjectMode,write:r.writable?(e,t,n)=>{r.writable.write(e,t,n)}:void 0,final:r.writable?e=>{r.writable.end(e)}:void 0,destroy:(e,t)=>{r.readable&&!r.readable.destroyed&&r.readable.destroy(e??void 0),r.writable&&!r.writable.destroyed&&r.writable.destroy(e??void 0),t(e)}});return r.readable&&n(r.readable,i),i}if(typeof t==`object`&&t&&typeof t.getReader==`function`&&typeof t.cancel==`function`){let r=q.fromWeb(t),i=new e({objectMode:r.readableObjectMode});return n(r,i),i}if(typeof t==`object`&&t&&typeof t.getWriter==`function`&&typeof t.close==`function`){let n=Y.fromWeb(t);return new e({objectMode:n.writableObjectMode,write(e,t,r){n.write(e,t,r)},final(e){n.end(e)},destroy(e,t){n.destroyed||n.destroy(e??void 0),t(e)}})}if(typeof t==`object`&&t&&(Symbol.asyncIterator in t||Symbol.iterator in t)){let r=q.from(t),i=new e({objectMode:r.readableObjectMode});return n(r,i),i}if(t instanceof q){let r=new e({objectMode:t.readableObjectMode});return n(t,r),r}if(t instanceof Y)return new e({objectMode:t.writableObjectMode,write(e,n,r){t.write(e,n,r)},final(e){t.end(e)}});throw new Ef(`Duplex-compatible source`,typeof t)}static fromWeb(t,n){let r=new e(n),i=new q({stream:t.readable,objectMode:r.readableObjectMode}),a=new Y({stream:t.writable,objectMode:r.writableObjectMode});return r._sideForwardingCleanup&&=(r._sideForwardingCleanup(),null),r._readable=i,r._writable=a,r._setupSideForwarding(),r}static toWeb(e){return{readable:q.toWeb(e._readable),writable:Y.toWeb(e._writable)}}_getSubclassHook(t){let n=Object.getPrototypeOf(this);for(;n&&n!==e.prototype&&n!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(n,t)){let e=this[t];return typeof e==`function`?e.bind(this):void 0}n=Object.getPrototypeOf(n)}}constructor(e){super(),this._dataForwardingSetup=!1,this._destroyed=!1,this._errored=null,this._closed=!1,this._sideForwardingCleanup=null,this._constructed=!0,this.__excelts_stream=!0,this.allowHalfOpen=e?.allowHalfOpen??!0,this._emitClose=e?.emitClose??!0,this._autoDestroy=e?.autoDestroy??!0;let t=e?.objectMode??!1,n=e?.readableObjectMode??t,r=e?.writableObjectMode??t,i=e!=null&&Object.prototype.hasOwnProperty.call(e,`highWaterMark`),a=i?e.highWaterMark:e?.readableHighWaterMark,o=i?e.highWaterMark:e?.writableHighWaterMark;e?.destroy&&(this._destroy=e.destroy.bind(this)),e?.construct&&(this._constructFunc=e.construct.bind(this));let s,c,l=this._hasConstructHook(),u=e?.read?e.read.bind(this):this._getSubclassHook(`_read`),d=e?.write?e.write.bind(this):this._getSubclassHook(`_write`),f=e?.writev?e.writev.bind(this):this._getSubclassHook(`_writev`),p=e?.final?e.final.bind(this):this._getSubclassHook(`_final`);this._readable=new q({highWaterMark:a,objectMode:n,read:u,encoding:e?.encoding,emitClose:!1,autoDestroy:!1,construct:l?e=>{s=e}:void 0}),this._writable=new Y({highWaterMark:o,objectMode:r,write:d,writev:f,final:p,decodeStrings:e?.decodeStrings,defaultEncoding:e?.defaultEncoding,emitClose:!1,autoDestroy:!1,construct:l?e=>{c=e}:void 0});let m=()=>{};this._readable.on(`error`,m),this._writable.on(`error`,m),this._setupSideForwarding(),e?.signal&&this._setupAbortSignal(e.signal),l&&(this._constructed=!1,K(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){s?.(e),c?.(e),this.destroy(e);return}this._constructed=!0,s?.(),c?.()})}))}_setupAbortSignal(e){if(e.aborted){this.destroy(r(e.reason));return}let t=()=>{this.destroy(r(e.reason))};e.addEventListener(`abort`,t,{once:!0}),this.once(`close`,()=>{e.removeEventListener(`abort`,t)})}_setupSideForwarding(){this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null),this._readable._pipes?.setSource(this);let e=Mf(),t=!1,n=e=>{t||(t=!0,this.emit(`error`,e))},r=!1,i=!1,a=()=>{this._autoDestroy&&r&&i&&!this._destroyed&&this.destroy()};e.once(this._readable,`end`,()=>{this.emit(`end`),r=!0,this.allowHalfOpen||this._writable.end(),a()}),e.add(this._readable,`error`,n);let o=()=>{this.emit(`readable`)};W.prototype.on.call(this._readable,`readable`,o),e.add(this._readable,`pause`,()=>this.emit(`pause`)),e.add(this._readable,`resume`,()=>this.emit(`resume`)),e.add(this._writable,`error`,n),e.once(this._writable,`prefinish`,()=>this.emit(`prefinish`)),e.once(this._writable,`finish`,()=>{this.emit(`finish`),i=!0,a()}),e.add(this._writable,`drain`,()=>this.emit(`drain`)),e.add(this._writable,`pipe`,e=>this.emit(`pipe`,e)),e.add(this._writable,`unpipe`,e=>this.emit(`unpipe`,e)),e.once(this._writable,`finish`,()=>{!this.allowHalfOpen&&!this._readable.readableEnded&&this._readable.push(null)});let s=this._readable.destroy.bind(this._readable);this._readable.destroy=e=>{let t=s(e);return this._destroyed||this.destroy(e),t},this._sideForwardingCleanup=()=>{e.cleanup(),this._readable.off(`readable`,o),this._readable.destroy=s}}on(e,t){return super.on(e,t),e===`data`&&!this._dataForwardingSetup?(this._dataForwardingSetup=!0,this._readable.on(`data`,e=>this.emit(`data`,e))):e===`readable`&&this._readable._setReadableFlowing(!1),this}push(e,t){return this._readable.push(e,t)}unshift(e,t){this._readable.unshift(e,t)}read(e){return this._readable.read(e)}write(e,t,n){let r=typeof t==`string`?t:void 0,i=typeof t==`function`?t:n;return r===void 0?this._writable.write(e,i):this._writable.write(e,r,i)}end(e,t,n){let{chunk:r,encoding:i,cb:a}=Kf(e,t,n);if(this._writable.writableEnded){if(r!==void 0)return this.write(r,i,e=>{a?.(e??null)}),this;if(this.writableFinished&&a){let e=Error(`Cannot call end after a stream was finished`);e.code=`ERR_STREAM_ALREADY_FINISHED`,K(()=>a(e))}else a&&K(()=>a(null));return this}if(a){let e=!1,t=()=>{e||(e=!0,a())};this.once(`finish`,t),this.once(`close`,t)}if(r!==void 0){let e=e=>{e&&!this.destroyed&&this.destroy(e)};i===void 0?this._writable.write(r,e):this._writable.write(r,i,e)}return this._writable.end(),this}cork(){this._writable.cork()}uncork(){this._writable.uncork()}setEncoding(e){return this._readable.setEncoding(e),this}setDefaultEncoding(e){return this._writable.setDefaultEncoding(e),this}pipe(e,t){return this._readable.pipe(e,t),e}unpipe(e){return this._readable.unpipe(e),this}pause(){return this._readable.pause(),this}resume(){return this._readable.resume(),this}isPaused(){return this._readable.isPaused()}destroy(e){if(this._destroyed)return this;this._destroyed=!0,this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null);let t=e=>{let t=e||null;t&&(this._errored=t),this._closed=!0,this._readable.destroy(),this._writable.destroy();let n=()=>{t&&this.emit(`error`,t),this._emitClose&&this.emit(`close`)};Ff()&&!this._hasDestroyHook()&&this.readableEnded&&this.writableFinished?n():K(n)};if(this._hasDestroyHook())try{this._destroy(e??null,t)}catch(e){t(e instanceof Error?e:Error(String(e)))}else t(e);return this}_destroy(e,t){t(e)}_undestroy(){this._readable._undestroy(),this._writable._undestroy(),this._destroyed=!1,this._closed=!1,this._errored=null,this._setupSideForwarding()}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}_hasConstructHook(){if(this._constructFunc)return!0;let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this.writableFinished?t():n(Error(`Premature close`))};this._closed?r():this.once(`close`,r)})}get readable(){return this._readable.readable}set readable(e){this._readable.readable=e}get writable(){return this._writable.writable}set writable(e){this._writable.writable=e}get readableEnded(){return this._readable.readableEnded}get writableEnded(){return this._writable.writableEnded}get writableFinished(){return this._writable.writableFinished}get readableLength(){return this._readable.readableLength}get writableLength(){return this._writable.writableLength}get readableHighWaterMark(){return this._readable.readableHighWaterMark}get writableHighWaterMark(){return this._writable.writableHighWaterMark}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e,this._readable.destroyed=e,this._writable.destroyed=e}get writableCorked(){return this._writable.writableCorked}get writableNeedDrain(){return this._writable.writableNeedDrain}get readableObjectMode(){return this._readable.readableObjectMode}get writableObjectMode(){return this._writable.writableObjectMode}get readableFlowing(){return this._readable.readableFlowing}get readableAborted(){return this._readable.readableAborted}get readableDidRead(){return this._readable.readableDidRead}get readableEncoding(){return this._readable.readableEncoding}get errored(){return this._errored??this._readable.errored??this._writable.errored}get closed(){return this._closed}get readableBuffer(){return this._readable.readableBuffer}get writableBuffer(){return this._writable.writableBuffer}wrap(e){return this._readable.wrap(e),this}iterator(e){return e?.destroyOnReturn===!1?this._readable.iterator(e):this._wrapAsyncIterator(this._readable[Symbol.asyncIterator]())}[Symbol.asyncIterator](){return this._wrapAsyncIterator(this._readable[Symbol.asyncIterator]())}_wrapAsyncIterator(e){let t=this;return{next(){return e.next()},async return(){let n=await e.return?.();return t.destroyed||t.destroy(),n??{value:void 0,done:!0}},async throw(n){let r=await e.throw?.(n);return t.destroyed||t.destroy(n instanceof Error?n:void 0),r??{value:void 0,done:!0}},[Symbol.asyncIterator](){return this}}}map(e,t){return this._readable.map(e,t)}filter(e,t){return this._readable.filter(e,t)}async forEach(e,t){return this._readable.forEach(e,t)}async toArray(e){return this._readable.toArray(e)}async some(e,t){return this._readable.some(e,t)}async find(e,t){return this._readable.find(e,t)}async every(e,t){return this._readable.every(e,t)}flatMap(e,t){return this._readable.flatMap(e,t)}drop(e,t){return this._readable.drop(e,t)}take(e,t){return this._readable.take(e,t)}async reduce(e,t,n){return arguments.length>=2?this._readable.reduce(e,t,n):this._readable.reduce(e)}compose(e,t){return this._readable.compose(e,t)}};Zf.prototype.addListener=Zf.prototype.on,Zf.prototype._writev=null;var Qf=class e extends W{static[Symbol.hasInstance](t){return typeof t!=`object`||!t?!1:Object.prototype.isPrototypeOf.call(e.prototype,t)?!0:t.__excelts_stream===!0&&typeof t.read==`function`&&typeof t.pipe==`function`&&typeof t.write==`function`&&typeof t.end==`function`&&typeof t.on==`function`&&typeof t._transform==`function`&&`readableFlowing`in t&&`writableFinished`in t}push(e,t){return this._readable.push(e,t)}constructor(t){super(),this._destroyed=!1,this._closed=!1,this._ended=!1,this._errored=null,this._dataForwardingSetup=!1,this._syncFinal=!1,this._endCalledFromSync=!1,this._endGeneration=0,this._endCallback=null,this._webStream=null,this._sideForwardingCleanup=null,this._afterTransformCallback=null,this.__excelts_stream=!0;let n=t?.objectMode??!1,r=t?.readableObjectMode??n,i=t?.writableObjectMode??n;this.allowHalfOpen=t?.allowHalfOpen??!0,this._emitClose=t?.emitClose??!0,this._autoDestroy=t?.autoDestroy??!0,this._transformImpl=t?.transform,this._flushImpl=t?.flush;let a=t!=null&&Object.prototype.hasOwnProperty.call(t,`highWaterMark`),o=a?t.highWaterMark:t?.readableHighWaterMark,s=a?t.highWaterMark:t?.writableHighWaterMark;t?.destroy&&(this._destroy=t.destroy.bind(this)),t?.construct&&(this._constructFunc=t.construct.bind(this));let c,l,u=this._hasConstructHook();this._readable=new q({highWaterMark:o,objectMode:r,encoding:t?.encoding,emitClose:!1,autoDestroy:!1,construct:u?e=>{c=e}:void 0}),this._readable._hasReadImpl=!0,this._readable._read=()=>{if(this._afterTransformCallback){let e=this._afterTransformCallback;this._afterTransformCallback=null,e(null)}},this._readable._pipes.setSource(this);let d=t?.write?(e,n,r)=>{t.write.call(this,e,n,r)}:(e,t,n)=>{let r=this._readable.readableLength,i=()=>{let e=this._readable.readableLength,t=this._readable.readableHighWaterMark;this._writable.writableEnded||r===e||e<t?n(null):this._afterTransformCallback=n},a=this._runTransformSync(e,t);a===void 0?i():a.then(()=>i(),e=>n(e))},f=t?.final?e=>{t.final.call(this,t=>{if(t){e(t);return}this._readable.push(null),e(null)})}:t=>{typeof this._final==`function`&&this._final!==e.prototype._final?this._final.call(this,e=>{if(e){t(e);return}t(null)}):this._hasSubclassFlush()||this._flushImpl?this._runFlush().then(()=>{this._readable.push(null),t(null)}).catch(e=>t(e)):this._syncFinal?(this._readable.push(null),this._readable._emitEndOnce(),t(null)):K(()=>{this._readable.push(null),t(null)})};this._writable=new Y({highWaterMark:s,objectMode:i,emitClose:!1,autoDestroy:!1,write:d,writev:t?.writev?.bind(this),final:f,decodeStrings:t?.decodeStrings,defaultEncoding:t?.defaultEncoding,construct:u?e=>{l=e}:void 0});let p=()=>{};this._readable.on(`error`,p),this._writable.on(`error`,p),this._setupSideForwarding(),t?.signal&&this._setupAbortSignal(t.signal),u&&K(()=>{(this._constructFunc??this._construct.bind(this))(e=>{if(e){c?.(e),l?.(e),this.destroy(e);return}c?.(),l?.()})})}_setupAbortSignal(e){if(e.aborted){this.destroy(r(e.reason));return}let t=()=>{this.destroy(r(e.reason))};e.addEventListener(`abort`,t,{once:!0}),this.once(`close`,()=>{e.removeEventListener(`abort`,t)})}_setupSideForwarding(){this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null),this._readable._pipes?.setSource(this);let e=Mf(),t=!1,n=!1,r=()=>{this._autoDestroy&&t&&n&&!this._destroyed&&this.destroy()};e.once(this._readable,`end`,()=>{this.emit(`end`),t=!0,this.allowHalfOpen||this._writable.end(),r()}),e.add(this._readable,`error`,e=>this._emitErrorOnce(e));let i=()=>{this.emit(`readable`)};W.prototype.on.call(this._readable,`readable`,i),e.add(this._readable,`pause`,()=>this.emit(`pause`)),e.add(this._readable,`resume`,()=>this.emit(`resume`)),e.once(this._writable,`prefinish`,()=>this.emit(`prefinish`)),e.once(this._writable,`finish`,()=>{this.emit(`finish`),n=!0,r()}),e.add(this._writable,`drain`,()=>this.emit(`drain`)),e.add(this._writable,`error`,e=>this._emitErrorOnce(e)),e.once(this._writable,`finish`,()=>{!this.allowHalfOpen&&!this._readable.readableEnded&&this._readable.push(null)}),this._sideForwardingCleanup=()=>{e.cleanup(),this._readable.off(`readable`,i)}}_scheduleEnd(){if(this._destroyed||this._errored||this._writable.writableEnded)return;let t=++this._endGeneration;K(()=>{t===this._endGeneration&&(this._destroyed||this._errored||this._writable.writableEnded||(this._endCalledFromSync&&!this._hasSubclassFlush()&&!this._flushImpl&&!(typeof this._final==`function`&&this._final!==e.prototype._final)&&this._readable._pipes._destinations.length===0&&(this._syncFinal=!0,this._writable._syncFinish=!0),this._writable.end(),this._syncFinal=!1,this._writable._syncFinish=!1))})}_emitErrorOnce(e){if(this._errored)return;let t=e instanceof Error?e:Error(String(e));this._errored=t,this._destroyed||this.destroy(t)}_hasSubclassTransform(){return this._isSubclassTransform===void 0?this._transformImpl?(this._isSubclassTransform=!1,!1):(this._isSubclassTransform=Object.getPrototypeOf(this)._transform!==e.prototype._transform,this._isSubclassTransform):this._isSubclassTransform}_hasSubclassFlush(){if(this._flushImpl)return!1;let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_flush`))return!0;t=Object.getPrototypeOf(t)}return!1}_runTransformSync(e,t){if(this._destroyed||this._errored)return;if(this._hasSubclassTransform()){let n=!0,r=!1,i=null,a,o=!1,s=null,c=null;if(this._transform(e,t,(e,t)=>{if(o){let e=Error(`Callback called multiple times`);e.code=`ERR_MULTIPLE_CALLBACK`,this.destroy(e);return}if(o=!0,n){r=!0,i=e??null,a=t;return}if(e){c?.(e);return}t!==void 0&&this.push(t),s?.()}),n=!1,r){if(i)throw i;a!==void 0&&this.push(a);return}return new Promise((e,t)=>{s=e,c=t})}let n=this._transformImpl;if(!n){let n=!0,r=!1,i=null,a,o=null,s=null;if(this._transform(e,t,(e,t)=>{if(n){r=!0,i=e??null,a=t;return}if(e){s?.(e);return}t!==void 0&&this.push(t),o?.()}),n=!1,r){if(i)throw i;a!==void 0&&this.push(a);return}return new Promise((e,t)=>{o=e,s=t})}let r=!0,i=!1,a=null,o,s=!1,c=null,l=null,u=new Promise((e,t)=>{c=e,l=t});if(n.call(this,e,t,(e,t)=>{if(s){let e=Error(`Callback called multiple times`);e.code=`ERR_MULTIPLE_CALLBACK`,this.destroy(e);return}if(s=!0,r){i=!0,a=e??null,o=t;return}if(e){l?.(e);return}t!==void 0&&this.push(t),c?.()}),r=!1,i){if(a)throw a;o!==void 0&&this.push(o);return}return u}async _runFlush(){if(this._destroyed||this._errored)return;if(this._hasSubclassFlush()){await new Promise((e,t)=>{this._flush((n,r)=>{if(n){t(n);return}r!==void 0&&this.push(r),e()})});return}let e=this._flushImpl;e&&await new Promise((t,n)=>{e.call(this,(e,r)=>{if(e){n(e);return}r!==void 0&&this.push(r),t()})})}on(e,t){return super.on(e,t),e===`data`&&!this._dataForwardingSetup?(this._dataForwardingSetup=!0,this._readable.on(`data`,e=>{this.emit(`data`,e)})):e===`readable`&&this._readable._setReadableFlowing(!1),this}write(e,t,n){let r=typeof t==`string`?t:void 0,i=typeof t==`function`?t:n;if(this._ended){let e=Error(`write after end`);return e.code=`ERR_STREAM_WRITE_AFTER_END`,K(()=>this.emit(`error`,e)),i&&K(()=>i(e)),!1}return r===void 0?this._writable.write(e,i):this._writable.write(e,r,i)}end(e,t,n){if(this._ended){let{chunk:r,encoding:i,cb:a}=Kf(e,t,n);if(r!==void 0)return this.write(r,i,e=>{a?.(e??null)}),this;if(this.writableFinished&&a){let e=Error(`Cannot call end after a stream was finished`);e.code=`ERR_STREAM_ALREADY_FINISHED`,K(()=>a(e))}else a&&K(()=>a(null));return this}let{chunk:r,encoding:i,cb:a}=Kf(e,t,n);if(a&&(this._endCallback=a,this.once(`finish`,()=>{let e=this._endCallback;e&&(this._endCallback=null,e())})),r!==void 0){let e=e=>{e&&!this._destroyed&&this.destroy(e)};i===void 0?this._writable.write(r,e):this._writable.write(r,i,e)}return this._ended=!0,this._endCalledFromSync=!Ff(),this._scheduleEnd(),this}read(e){return this._readable.read(e)}pipe(e,t){return this._readable.pipe(e,t)}unpipe(e){return this._readable.unpipe(e),this}isPaused(){return this._readable.isPaused()}resume(){return this._readable.resume(),this}pause(){return this._readable.pause(),this}destroy(e){if(this._destroyed)return this;if(this._destroyed=!0,this._endGeneration++,this._afterTransformCallback){let t=this._afterTransformCallback;this._afterTransformCallback=null,t(e??null)}this._sideForwardingCleanup&&=(this._sideForwardingCleanup(),null);let t=e=>{let t=e||null;this._readable.destroy(),this._writable.destroy();let n=this._endCallback;this._endCallback=null,this._closed=!0;let r=()=>{n&&n(),t&&this.emit(`error`,t),this._emitClose&&this.emit(`close`)};Ff()&&!this._hasDestroyHook()&&this.readableEnded&&this.writableFinished?r():K(r)};if(this._hasDestroyHook())try{this._destroy(e??null,t)}catch(e){t(e instanceof Error?e:Error(String(e)))}else t(e);return this}_destroy(e,t){t(e)}_undestroy(){this._readable._undestroy(),this._writable._undestroy(),this._destroyed=!1,this._closed=!1,this._errored=null,this._setupSideForwarding()}_hasDestroyHook(){return Object.prototype.hasOwnProperty.call(this,`_destroy`)||Object.getPrototypeOf(this)._destroy!==e.prototype._destroy}_hasConstructHook(){if(this._constructFunc)return!0;let t=Object.getPrototypeOf(this);for(;t&&t!==e.prototype&&t!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(t,`_construct`))return!0;t=Object.getPrototypeOf(t)}return!1}[Symbol.dispose](){this._destroyed||this.destroy()}async[Symbol.asyncDispose](){let e=!this._destroyed;return e&&this.destroy(),new Promise((t,n)=>{let r=()=>{e||this.writableFinished?t():n(Error(`Premature close`))};this.closed?r():this.once(`close`,r)})}_getWebStream(){if(this._webStream)return this._webStream;let e=this[Symbol.asyncIterator]();return this._webStream={readable:new ReadableStream({pull:async t=>{let{done:n,value:r}=await e.next();if(n){t.close();return}t.enqueue(r)},cancel:e=>{this.destroy(e instanceof Error?e:Error(String(e)))}}),writable:new WritableStream({write:e=>new Promise((t,n)=>{this.write(e,e=>{e?n(e):t()})}),close:()=>new Promise(e=>{this.end(()=>e())}),abort:e=>{this.destroy(e instanceof Error?e:Error(String(e)))}})},this._webStream}get readable(){return this._readable.readable}set readable(e){this._readable.readable=e}get writable(){return this._writable.writable}set writable(e){this._writable.writable=e}get readableEnded(){return this._readable.readableEnded}get writableEnded(){return this._ended||this._writable.writableEnded}get writableFinished(){return this._writable.writableFinished}get readableLength(){return this._readable.readableLength}get writableLength(){return this._writable.writableLength}get readableHighWaterMark(){return this._readable.readableHighWaterMark}get writableHighWaterMark(){return this._writable.writableHighWaterMark}get readableObjectMode(){return this._readable.readableObjectMode}get readableFlowing(){return this._readable.readableFlowing}get destroyed(){return this._destroyed}set destroyed(e){this._destroyed=e,this._readable.destroyed=e,this._writable.destroyed=e}cork(){this._writable.cork()}uncork(){this._writable.uncork()}setEncoding(e){return this._readable.setEncoding(e),this}setDefaultEncoding(e){return this._writable.setDefaultEncoding(e),this}unshift(e,t){this._readable.unshift(e,t)}wrap(e){return this._readable.wrap(e),this}iterator(e){return this._readable.iterator(e)}get writableCorked(){return this._writable.writableCorked}get writableNeedDrain(){return this._writable.writableNeedDrain}get writableObjectMode(){return this._writable.writableObjectMode}get readableAborted(){return this._readable.readableAborted}get readableDidRead(){return this._readable.readableDidRead}get readableEncoding(){return this._readable.readableEncoding}get errored(){return this._errored??this._readable.errored??this._writable.errored}get closed(){return this._closed}get readableBuffer(){return this._readable.readableBuffer}get writableBuffer(){return this._writable.writableBuffer}async*[Symbol.asyncIterator](){yield*this._readable[Symbol.asyncIterator]()}map(e,t){return this._readable.map(e,t)}filter(e,t){return this._readable.filter(e,t)}async forEach(e,t){return this._readable.forEach(e,t)}async toArray(e){return this._readable.toArray(e)}async some(e,t){return this._readable.some(e,t)}async find(e,t){return this._readable.find(e,t)}async every(e,t){return this._readable.every(e,t)}flatMap(e,t){return this._readable.flatMap(e,t)}drop(e,t){return this._readable.drop(e,t)}take(e,t){return this._readable.take(e,t)}async reduce(e,t,n){return arguments.length>=2?this._readable.reduce(e,t,n):this._readable.reduce(e)}compose(e,t){return this._readable.compose(e,t)}static isDisturbed(e){return e&&e._readable instanceof q?q.isDisturbed(e._readable):q.isDisturbed(e)}static from(e){return Zf.from(e)}static fromWeb(t,n){let r=new e(n);r._webStream=t;let i=q.fromWeb(t.readable,{objectMode:n?.objectMode}),a=Y.fromWeb(t.writable,{objectMode:n?.objectMode});return r._sideForwardingCleanup&&=(r._sideForwardingCleanup(),null),r._readable=i,r._writable=a,r._setupSideForwarding(),r}static toWeb(e){return e._getWebStream()}_transform(e,t,n){let r=Error(`The _transform() method is not implemented`);throw r.code=`ERR_METHOD_NOT_IMPLEMENTED`,r}_final(e){typeof this._flush==`function`&&!this.destroyed?this._flush((t,n)=>{if(t){e(t);return}n!=null&&this.push(n),this.push(null),e()}):(this.push(null),e())}};Qf.prototype.addListener=Qf.prototype.on,Qf.prototype._writev=null;var $f=class extends Qf{constructor(e){super(e)}_transform(e,t,n){n(null,e)}};let ep=e=>!e||typeof e!=`object`||typeof e.pipe==`function`||typeof e.write==`function`||typeof e.end==`function`||typeof e.getReader==`function`||typeof e.getWriter==`function`?!1:Object.prototype.hasOwnProperty.call(e,`signal`)||Object.prototype.hasOwnProperty.call(e,`end`),tp=e=>`readableEnded`in e||`readable`in e||typeof e.read==`function`,np=e=>`writableFinished`in e||`writable`in e||typeof e.write==`function`,rp=e=>{let t=!tp(e)||!!e.readableEnded,n=!np(e)||!!e.writableFinished;return t&&n},ip=()=>{let e=Error(`Premature close`);return e.code=`ERR_STREAM_PREMATURE_CLOSE`,e.name=`Error [ERR_STREAM_PREMATURE_CLOSE]`,e},ap=(e,t,n)=>{let r=e;if(r.closed||r._closed){t();return}`_emitClose`in r&&`_autoDestroy`in r&&r._emitClose!==!1&&r._autoDestroy!==!1?n.once(e,`close`,()=>t()):t()},op=e=>e instanceof q||e instanceof Y||e instanceof Qf||e instanceof Zf?e:uf(e)?Qf.fromWeb(e):cf(e)?q.fromWeb(e):lf(e)?Y.fromWeb(e):e,sp=e=>typeof e==`function`&&!(e instanceof q)&&!(e instanceof Y),cp=(e,t)=>{let n=t(e);return q.from(n)};function lp(...e){let t,n={},i,a=e[e.length-1];if(typeof a==`function`){i=a;let r=e[e.length-2];ep(r)?(n=r,t=e.slice(0,-2)):t=e.slice(0,-1)}else ep(a)?(n=a,t=e.slice(0,-1)):t=e;let o=new Promise((e,i)=>{if(t.length<2){i(Error(`Pipeline requires at least 2 streams`));return}let a=t.map(op),o=[],s=[],c=a[0];o.push(c),s.push(c);for(let e=1;e<a.length;e++){let t=a[e];sp(t)?(c=cp(c,t),o.push(c),s[s.length-1]=c):(o.push(t),s.push(t),c=t)}let l=s[0],u=s[s.length-1],d=s.slice(1,-1);for(let e of o)if(e.destroyed&&!rp(e)){i(ip());return}let f=!1,p=Mf(),m,h=t=>{if(!f){if(f=!0,m&&n.signal&&n.signal.removeEventListener(`abort`,m),t){let e=()=>{};for(let n of o)typeof n.on==`function`&&n.on(`error`,e),typeof n.destroy==`function`&&!n.destroyed&&n.destroy(t)}p.cleanup(),t?i(t):e()}};if(n.signal){if(n.signal.aborted){h(r(n.signal.reason));return}m=()=>h(r(n.signal.reason)),n.signal.addEventListener(`abort`,m)}c=l;for(let e of d)c.pipe(e),c=e;if(n.end!==!1)c.pipe(u);else{let e=!1,t=!1,n=()=>{t=!1,e&&typeof c.resume==`function`&&(e=!1,c.resume())};p.add(c,`data`,r=>{!u.write(r)&&!t&&(t=!0,!e&&typeof c.pause==`function`&&(e=!0,c.pause()),p.once(u,`drain`,n))}),p.once(c,`end`,()=>{ap(c,h,p)})}n.end!==!1&&p.once(u,`finish`,()=>{ap(u,h,p)});for(let e of o)p.once(e,`close`,()=>{f||rp(e)||h(ip())});for(let e of o)p.once(e,`error`,e=>h(e))});return i&&o.then(()=>i()).catch(e=>i(e)),o}function up(e,t,n){let i={},a;typeof t==`function`?a=t:(i=t??{},a=n);let o=new Promise((t,n)=>{let a=op(e),o=!1,s=Mf(),c,l=()=>{s.cleanup(),c&&i.signal&&i.signal.removeEventListener(`abort`,c)},u=e=>{o||(o=!0,l(),e?n(e):t())};if(i.signal){if(i.signal.aborted){u(r(i.signal.reason));return}c=()=>u(r(i.signal.reason)),i.signal.addEventListener(`abort`,c)}let d=a;if(d.destroyed||d._destroyed){if(d.errored||d._errored)u(d.errored??d._errored);else{let e=`readableEnded`in d||`readable`in d||typeof d.read==`function`,t=`writableFinished`in d||`writable`in d||typeof d.write==`function`,n=i.readable!==!1&&e,r=i.writable!==!1&&t,a=!n||!!(d.readableEnded||d._endEmitted),o=!r||!!(d.writableFinished||d._finished);a&&o?u():u(ip())}return}let f=`readableEnded`in a||`readable`in a||typeof a.read==`function`,p=`writableFinished`in a||`writable`in a||typeof a.write==`function`,m=i.readable!==!1&&f,h=i.writable!==!1&&p,g=!m||!!a.readableEnded,_=!h||!!a.writableFinished,v=a,y=`_emitClose`in v&&`_autoDestroy`in v&&v._emitClose!==!1&&v._autoDestroy!==!1&&!v._closed,b=()=>{if(g&&_){if(y)return;u()}};if(g&&_&&(!y||a.closed)){u();return}h&&!_&&s.once(a,`finish`,()=>{_=!0,b()}),m&&!g&&s.once(a,`end`,()=>{g=!0,b()}),i.error!==!1&&s.once(a,`error`,e=>u(e)),s.once(a,`close`,()=>{let e=g||!!a.readableEnded,t=_||!!a.writableFinished;if(e&&t){g=e,_=t,u(a.errored??a._errored??void 0);return}let n=a.errored??a._errored;if(n){u(n);return}let r=Error(`Premature close`);r.code=`ERR_STREAM_PREMATURE_CLOSE`,r.name=`Error [ERR_STREAM_PREMATURE_CLOSE]`,u(r)})});return a&&o.then(()=>a()).catch(e=>a(e)),o}async function*dp(e){let t=e.getReader();try{for(;;){let e=await t.read();if(e.done)return;e.value!==void 0&&e.value!==null&&(yield e.value)}}finally{try{await t.cancel?.()}catch{}try{t.releaseLock?.()}catch{}}}Rf(e=>Zf.from(e));let fp=new Map([[/^xl\/charts\/chart\d+\.xml$/,`application/vnd.openxmlformats-officedocument.drawingml.chart+xml`],[/^xl\/charts\/style\d+\.xml$/,`application/vnd.ms-office.chartstyle+xml`],[/^xl\/charts\/colors\d+\.xml$/,`application/vnd.ms-office.chartcolorstyle+xml`]]),pp=[`xl/charts/`];var mp=class e{constructor(){this.files=new Map}static isPassthroughPath(e){return pp.some(t=>e.startsWith(t))}static getContentType(e){if(!e.startsWith(`xl/charts/_rels/`)){for(let[t,n]of fp)if(t.test(e))return n}}add(e,t){this.files.set(e,t)}get(e){return this.files.get(e)}has(e){return this.files.has(e)}getPaths(){return[...this.files.keys()]}toRecord(){let e={};for(let[t,n]of this.files)e[t]=n;return e}fromRecord(e){this.files.clear();for(let[t,n]of Object.entries(e))this.files.set(t,n)}getContentTypes(){let t=[];for(let n of this.files.keys()){let r=e.getContentType(n);r&&t.push({partName:n,contentType:r})}return t}writeToZip(e){for(let[t,n]of this.files)e.append(n,{name:t})}clear(){this.files.clear()}get size(){return this.files.size}},hp=class e{static{this.textEncoder=new TextEncoder}constructor(e){this.events=new Map,this.pipedStream=null,this.finalized=!1,this.level=e?.level??6,this.modTime=e?.modTime,this.timestamps=e?.timestamps,this.zip=new Xd((e,t,n)=>{if(e){this._emit(`error`,e);return}t&&t.length>0&&(this._emit(`data`,t),this.pipedStream&&this.pipedStream.write(t)),n&&(this.pipedStream&&this.pipedStream.end(),this._emit(`finish`))})}_emit(e,...t){let n=this.events.get(e);if(n)for(let e of n)e(...t)}on(e,t){let n=this.events.get(e)||new Set;return n.add(t),this.events.set(e,n),this}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}off(e,t){let n=this.events.get(e);return n?(n.delete(t),n.size===0&&this.events.delete(e),this):this}pipe(e){this.pipedStream=e}append(t,n){if(this.finalized)throw new b(`append`,`stream already finalized`);let r;r=n.base64?lt(typeof t==`string`?t:String(t)):typeof t==`string`?e.textEncoder.encode(t):t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer?new Uint8Array(t):t;let i=new Yd(n.name,{level:this.level,modTime:this.modTime,timestamps:this.timestamps});this.zip.add(i),i.push(r,!0)}finalize(){this.finalized||(this.finalized=!0,this.zip.end())}},gp=class e{static{this.RelType=z}constructor(e){this.workbook=e}createBinaryStream(e){let t=new $f;return t.end(e),t}createTextStream(e){let t=new $f;return t.end(e),t}createStreamBuf(){return new gc}bufferToString(e){return Ft(e)}createZipWriter(e){return new hp(e)}async writeToZip(e,t){let{model:n}=this.workbook;this.prepareModel(n,t),await this.addContentTypes(e,n),await this.addOfficeRels(e,n),await this.addWorkbookRels(e,n),await this.addWorkbook(e,n),await this.addWorksheets(e,n),await this.addSharedStrings(e,n),this.addDrawings(e,n),this.addTables(e,n),this.addPivotTables(e,n),this.addPassthrough(e,n),await Promise.all([this.addThemes(e,n),this.addStyles(e,n)]),await this.addFeaturePropertyBag(e,n),await this.addMedia(e,n),await Promise.all([this.addApp(e,n),this.addCore(e,n)])}async read(e,t){let n=[];return await new Promise((t,r)=>{let i=e=>{n.push(e)},a=()=>{e.off(`data`,i),e.off(`end`,a),e.off(`error`,o),t()},o=t=>{e.off(`data`,i),e.off(`end`,a),e.off(`error`,o),r(t)};e.on(`data`,i),e.on(`end`,a),e.on(`error`,o)}),this.loadBuffer(O(n),t)}async write(e,t){t||={},t.zip=t.zip||{},t.zip.modTime??=this.workbook.modified??this.workbook.created;let n=this.createZipWriter(t.zip);return n.pipe(e),await this.writeToZip(n,t),this._finalize(n)}async load(e,t){let n,r=typeof Buffer<`u`?Buffer.isBuffer(e):!1;if(!e||typeof e==`object`&&!r&&!(e instanceof Uint8Array)&&!(e instanceof ArrayBuffer))throw new y(`<input>`,`read`,`Can't read the data of 'the loaded zip file'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?`);return n=t&&t.base64?lt(e.toString()):e instanceof ArrayBuffer?new Uint8Array(e):e instanceof Uint8Array?e:new Uint8Array(e),this.loadBuffer(n,t)}async loadBuffer(e,t){let n=await new Sf(e).extractAll(),r={};for(let[e,t]of n)r[e]=t;return this.loadFromFiles(r,t)}createEmptyModel(){return{worksheets:[],worksheetHash:{},worksheetRels:[],themes:{},media:[],mediaIndex:{},drawings:{},drawingRels:{},rawDrawings:{},comments:{},tables:{},vmlDrawings:{},pivotTables:{},pivotTableRels:{},pivotCacheDefinitions:{},pivotCacheRecords:{},passthrough:{}}}async collectStreamData(e){let t=[];return await new Promise((n,r)=>{e.on(`data`,e=>{typeof e==`string`?t.push(new TextEncoder().encode(e)):e instanceof Uint8Array?t.push(e):t.push(new Uint8Array(e))}),e.on(`end`,()=>n()),e.on(`error`,r)}),O(t)}drawingHasChartReference(e){return e.rels&&e.rels.some(e=>e.Target&&e.Target.includes(`/charts/`))}drawingRelsHasChartReference(e){return Array.isArray(e)&&e.some(e=>typeof e?.Target==`string`&&e.Target.includes(`/charts/`))}async _processKnownEntry(e,t,n,r){let i=xi(n);if(i!==void 0)return await this._processWorksheetEntry(e,t,i,r,n),!0;switch(n){case L.rootRels:return t.globalRels=await this.parseRels(e),!0;case L.xlWorkbook:{let n=await this.parseWorkbook(e);return t.sheets=n.sheets,t.definedNames=n.definedNames,t.views=n.views,t.properties=n.properties,t.calcProperties=n.calcProperties,t.pivotCaches=n.pivotCaches,!0}case L.xlSharedStrings:return t.sharedStrings=new ii,await t.sharedStrings.parseStream(e),!0;case L.xlWorkbookRels:return t.workbookRels=await this.parseRels(e),!0;case L.docPropsApp:{let n=await new ya().parseStream(e);return n&&(t.company=n.company,t.manager=n.manager),!0}case L.docPropsCore:{let n=await new $r().parseStream(e);return Object.assign(t,n),!0}case L.xlStyles:return t.styles=new Zr,await t.styles.parseStream(e),!0;default:return!1}}async loadFromZipEntries(e,t){let n=this.createEmptyModel();for await(let r of e){let e=!1,i=async()=>{e||(e=!0,await r.drain())};if(r.type===`Directory`){await i();continue}let a=bi(r.name),o=r.stream;try{await this._processKnownEntry(o,n,a,t)||await this._processDefaultEntry(o,n,a)||await i()}finally{try{await i()}catch{}}}return this.reconcile(n,t),this.workbook.model=n,this.workbook}async writeBuffer(e){e||={},e.zip=e.zip||{},e.zip.modTime??=this.workbook.modified??this.workbook.created;let t=this.createZipWriter(e.zip),n=this.createStreamBuf();return t.pipe(n),await this.writeToZip(t,e),await this._finalize(t),n.read()||new Uint8Array}async addMedia(e,t){await Promise.all(t.media.map(async t=>{if(t.type!==`image`)throw new ne(`Unsupported media`);let n=zi(`${t.name??`undefined`}.${t.extension}`);if(t.filename){if(this.readFileAsync){let r=await this.readFileAsync(t.filename);return e.append(r,{name:n})}throw new v(`Loading images from filename`,`not supported in this environment`)}if(t.buffer)return e.append(t.buffer,{name:n});if(t.base64){let r=t.base64.substring(t.base64.indexOf(`,`)+1);return e.append(r,{name:n,base64:!0})}throw new ne(`Unsupported media`)}))}parseRels(e){return new I().parseStream(e)}parseWorkbook(e){return new Na().parseStream(e)}parseSharedStrings(e){return new ii().parseStream(e)}reconcile(e,t){let n=new Na,r=new $o(t),i=new vs,a=new Ts;n.reconcile(e);let o={media:e.media,mediaIndex:e.mediaIndex};if(Object.keys(e.drawings).forEach(t=>{let n=e.drawings[t],r=e.drawingRels[t];r&&(o.rels=r.reduce((e,t)=>(e[t.Id]=t,e),{}),(n.anchors??[]).forEach(e=>{let t=e.picture&&e.picture.hyperlinks;t&&o.rels[t.rId]&&(t.hyperlink=o.rels[t.rId].Target,delete t.rId)}),i.reconcile(n,o))}),e.rawDrawings&&e.drawingRels)for(let t of Object.keys(e.rawDrawings)){let n=e.drawingRels[t];n&&!this.drawingRelsHasChartReference(n)&&delete e.rawDrawings[t]}let s={styles:e.styles};Object.values(e.tables).forEach(e=>{a.reconcile(e,s)}),this._reconcilePivotTables(e);let c={styles:e.styles,sharedStrings:e.sharedStrings,media:e.media,mediaIndex:e.mediaIndex,date1904:e.properties?.date1904,drawings:e.drawings,drawingRels:e.drawingRels,comments:e.comments,tables:e.tables,vmlDrawings:e.vmlDrawings,pivotTables:e.pivotTablesIndexed};e.worksheets.forEach(t=>{t.relationships=e.worksheetRels[t.sheetNo],r.reconcile(t,c)}),delete e.worksheetHash,delete e.worksheetRels,delete e.globalRels,delete e.sharedStrings,delete e.workbookRels,delete e.sheetDefs,e.defaultFont=e.styles?.defaultFont,delete e.styles,delete e.mediaIndex,delete e.drawings,delete e.drawingRels,delete e.vmlDrawings,delete e.pivotTableRels}_reconcilePivotTables(e){let t=e.pivotTables||{};if(typeof t!=`object`||Object.keys(t).length===0){e.pivotTables=[],e.pivotTablesIndexed={};return}let n=this._buildDefinitionToCacheIdMap(e),r=new Map;Object.entries(e.pivotCacheDefinitions||{}).forEach(([t,i])=>{let a=n.get(t);if(a!==void 0){let n=t.replace(`Definition`,`Records`);r.set(a,{definition:i,records:e.pivotCacheRecords?.[n],definitionName:t})}});let i=[],a={};Object.entries(t).forEach(([e,t])=>{let n=this._extractTableNumber(e),o=r.get(t.cacheId),s=this._determineMetric(t.dataFields),c={...t,tableNumber:n,cacheId:String(t.cacheId),cacheDefinition:o?.definition,cacheRecords:o?.records,cacheFields:o?.definition?.cacheFields??[],rows:t.rowFields.filter(e=>e>=0),columns:t.colFields.filter(e=>e>=0&&e!==-2),values:t.dataFields.map(e=>e.fld),pages:t.pageFields.map(e=>e.fld),metric:s,valueMetrics:this._determineValueMetrics(t.dataFields,s),applyWidthHeightFormats:t.applyWidthHeightFormats===`1`?`1`:`0`};i.push(c),a[ua(e)]=c}),i.sort((e,t)=>e.tableNumber-t.tableNumber),e.pivotTables=i,e.pivotTablesIndexed=a}_extractTableNumber(e){let t=e.match(/pivotTable(\d+)/);return t?parseInt(t[1],10):1}_buildCacheIdMap(e){let t=new Map,n=e.pivotCaches??[];for(let e of n)e.cacheId&&e.rId&&t.set(e.rId,parseInt(e.cacheId,10));return t}_buildDefinitionToCacheIdMap(t){let n=new Map,r=this._buildCacheIdMap(t),i=t.workbookRels??[];for(let t of i)if(t.Type===e.RelType.PivotCacheDefinition&&t.Target){let e=t.Target.match(/pivotCacheDefinition(\d+)\.xml/);if(e){let i=`pivotCacheDefinition${e[1]}`,a=r.get(t.Id);a!==void 0&&n.set(i,a)}}return n}_determineMetric(e){return e.length>0&&e[0].subtotal?e[0].subtotal:`sum`}_determineValueMetrics(e,t){return e.map(e=>e.subtotal||t)}async _processWorksheetEntry(e,t,n,r,i){let a=await new $o(r).parseStream(e);if(!a)throw new _(i,`Failed to parse worksheet`);a.sheetNo=n,t.worksheetHash[i]=a,t.worksheets.push(a)}async _processCommentEntry(e,t,n){let r=await new Qs().parseStream(e);t.comments[ca(n)]=r}async _processTableEntry(e,t,n){let r=await new Ts().parseStream(e);t.tables[fa(n)]=r}async _processWorksheetRelsEntry(e,t,n){let r=await new I().parseStream(e);t.worksheetRels[n]=r}async _processMediaEntry(e,t,n){let r=n.lastIndexOf(`.`);if(r>=1){let i=n.substr(r+1),a=n.substr(0,r);await new Promise((r,o)=>{let s=this.createStreamBuf(),c=()=>{e.off(`error`,u),s.off(`error`,u),s.off(`finish`,l)},l=()=>{c(),t.mediaIndex[n]=t.media.length,t.mediaIndex[a]=t.media.length;let e={type:`image`,name:a,extension:i,buffer:s.read()};t.media.push(e),r()},u=e=>{c(),o(e)};s.once(`finish`,l),e.on(`error`,u),s.on(`error`,u),e.pipe(s)})}}async _processDrawingEntry(e,t,n,r){let i=r??await this.collectStreamData(e),a=new vs,o=this.bufferToString(i),s=await a.parseStream(this.createTextStream(o));t.drawings[n]=s,t.rawDrawings[n]=i}async _processDrawingRelsEntry(e,t,n){let r=await new I().parseStream(e);t.drawingRels[n]=r}async _processVmlDrawingEntry(e,t,n){let r=await new oc().parseStream(e);t.vmlDrawings[sa(n)]=r}async _processThemeEntry(e,t,n){await new Promise((r,i)=>{let a=this.createStreamBuf(),o=()=>{e.off(`error`,c),a.off(`error`,c),a.off(`finish`,s)},s=()=>{o();let e=a.read();t.themes[n]=e?typeof e==`string`?e:this.bufferToString(e):``,r()},c=e=>{o(),i(e)};a.once(`finish`,s),e.on(`error`,c),a.on(`error`,c),e.pipe(a)})}async _processPivotTableEntry(e,t,n){let r=await new Ks().parseStream(e);r&&(t.pivotTables[n]=r)}async _processPivotTableRelsEntry(e,t,n){let r=await new I().parseStream(e);t.pivotTableRels[n]=r}async _processPivotCacheDefinitionEntry(e,t,n){let r=await new Bs().parseStream(e);r&&(t.pivotCacheDefinitions[n]=r)}async _processPivotCacheRecordsEntry(e,t,n){let r=await new Ms().parseStream(e);r&&(t.pivotCacheRecords[n]=r)}async loadFromFiles(e,t){let n=this.createEmptyModel(),r=Object.keys(e).map(t=>({name:t,dir:t.endsWith(`/`),data:e[t]}));for(let e of r)if(!e.dir){let r=bi(e.name),i=Di(r)?this.createBinaryStream(e.data):this.createTextStream(this.bufferToString(e.data));await this._processKnownEntry(i,n,r,t)||await this._processDefaultEntry(i,n,r,e.data)}return this.reconcile(n,t),this.workbook.model=n,this.workbook}async _processDefaultEntry(e,t,n,r){let i=Si(n);if(i!==void 0)return await this._processWorksheetRelsEntry(e,t,i),!0;let a=wi(n);if(a)return await this._processMediaEntry(e,t,a),!0;let o=Oi(n);if(o)return await this._processDrawingEntry(e,t,o,r),!0;let s=ki(n);if(s)return await this._processDrawingRelsEntry(e,t,s),!0;let c=Ai(n);if(c)return await this._processVmlDrawingEntry(e,t,c),!0;let l=ji(n);if(l)return await this._processCommentEntry(e,t,`comments${l}`),!0;let u=Mi(n);if(u)return await this._processTableEntry(e,t,u),!0;let d=Ei(n);if(d)return await this._processThemeEntry(e,t,d),!0;let f=Ni(n);if(f)return await this._processPivotTableEntry(e,t,f),!0;let p=Pi(n);if(p)return await this._processPivotTableRelsEntry(e,t,p),!0;let m=Fi(n);if(m)return await this._processPivotCacheDefinitionEntry(e,t,m),!0;if(Ii(n))return!0;let h=Li(n);return h?(await this._processPivotCacheRecordsEntry(e,t,h),!0):mp.isPassthroughPath(n)?(r?t.passthrough[n]=r:await this._processPassthroughEntry(e,t,n),!0):!1}async _processPassthroughEntry(e,t,n){let r=await this.collectStreamData(e);t.passthrough[n]=r}async addContentTypes(e,t){let n=new ga().toXml(t);e.append(n,{name:L.contentTypes})}async addApp(e,t){let n=new ya().toXml(t);e.append(n,{name:L.docPropsApp})}async addCore(e,t){let n=new $r;e.append(n.toXml(t),{name:L.docPropsCore})}async addThemes(e,t){let n=t.themes||{theme1:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
319
+ <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"> <a:themeElements> <a:clrScheme name="Office"> <a:dk1> <a:sysClr val="windowText" lastClr="000000"/> </a:dk1> <a:lt1> <a:sysClr val="window" lastClr="FFFFFF"/> </a:lt1> <a:dk2> <a:srgbClr val="1F497D"/> </a:dk2> <a:lt2> <a:srgbClr val="EEECE1"/> </a:lt2> <a:accent1> <a:srgbClr val="4F81BD"/> </a:accent1> <a:accent2> <a:srgbClr val="C0504D"/> </a:accent2> <a:accent3> <a:srgbClr val="9BBB59"/> </a:accent3> <a:accent4> <a:srgbClr val="8064A2"/> </a:accent4> <a:accent5> <a:srgbClr val="4BACC6"/> </a:accent5> <a:accent6> <a:srgbClr val="F79646"/> </a:accent6> <a:hlink> <a:srgbClr val="0000FF"/> </a:hlink> <a:folHlink> <a:srgbClr val="800080"/> </a:folHlink> </a:clrScheme> <a:fontScheme name="Office"> <a:majorFont> <a:latin typeface="Cambria"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Times New Roman"/> <a:font script="Hebr" typeface="Times New Roman"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="MoolBoran"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Times New Roman"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:majorFont> <a:minorFont> <a:latin typeface="Calibri"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Arial"/> <a:font script="Hebr" typeface="Arial"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="DaunPenh"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Arial"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:minorFont> </a:fontScheme> <a:fmtScheme name="Office"> <a:fillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="35000"> <a:schemeClr val="phClr"> <a:tint val="37000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="15000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="1"/> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="100000"/> <a:shade val="100000"/> <a:satMod val="130000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:shade val="100000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="0"/> </a:gradFill> </a:fillStyleLst> <a:lnStyleLst> <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"> <a:shade val="95000"/> <a:satMod val="105000"/> </a:schemeClr> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> </a:lnStyleLst> <a:effectStyleLst> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="38000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> <a:scene3d> <a:camera prst="orthographicFront"> <a:rot lat="0" lon="0" rev="0"/> </a:camera> <a:lightRig rig="threePt" dir="t"> <a:rot lat="0" lon="0" rev="1200000"/> </a:lightRig> </a:scene3d> <a:sp3d> <a:bevelT w="63500" h="25400"/> </a:sp3d> </a:effectStyle> </a:effectStyleLst> <a:bgFillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="40000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="40000"> <a:schemeClr val="phClr"> <a:tint val="45000"/> <a:shade val="99000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="20000"/> <a:satMod val="255000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="-80000" r="50000" b="180000"/> </a:path> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="80000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="30000"/> <a:satMod val="200000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="50000" r="50000" b="50000"/> </a:path> </a:gradFill> </a:bgFillStyleLst> </a:fmtScheme> </a:themeElements> <a:objectDefaults> <a:spDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="1"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="3"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="2"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="lt1"/> </a:fontRef> </a:style> </a:spDef> <a:lnDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="2"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="0"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="1"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="tx1"/> </a:fontRef> </a:style> </a:lnDef> </a:objectDefaults> <a:extraClrSchemeLst/> </a:theme>`};Object.keys(n).forEach(t=>{let r=n[t];e.append(r,{name:Ri(t)})})}async addOfficeRels(t,n){let r=new I().toXml([{Id:`rId1`,Type:e.RelType.OfficeDocument,Target:L.xlWorkbook},{Id:`rId2`,Type:e.RelType.CoreProperties,Target:L.docPropsCore},{Id:`rId3`,Type:e.RelType.ExtenderProperties,Target:L.docPropsApp}]);t.append(r,{name:L.rootRels})}async addWorkbookRels(t,n){let r=1,i=[{Id:`rId${r++}`,Type:e.RelType.Styles,Target:na.workbookStyles},{Id:`rId${r++}`,Type:e.RelType.Theme,Target:na.workbookTheme1}];n.sharedStrings.count&&i.push({Id:`rId${r++}`,Type:e.RelType.SharedStrings,Target:na.workbookSharedStrings}),n.hasCheckboxes&&i.push({Id:`rId${r++}`,Type:e.RelType.FeaturePropertyBag,Target:na.workbookFeaturePropertyBag});let a=new Map;(n.pivotTables??[]).forEach(t=>{let n=a.get(t.cacheId);n?t.rId=n:(t.rId=`rId${r++}`,a.set(t.cacheId,t.rId),i.push({Id:t.rId,Type:e.RelType.PivotCacheDefinition,Target:ra(t.tableNumber)}))}),n.worksheets.forEach(t=>{t.rId=`rId${r++}`,i.push({Id:t.rId,Type:e.RelType.Worksheet,Target:Hi(t.fileIndex)})});let o=new I().toXml(i);t.append(o,{name:L.xlWorkbookRels})}async addFeaturePropertyBag(e,t){if(!t.hasCheckboxes)return;let n=new es;e.append(n.toXml({}),{name:L.xlFeaturePropertyBag})}async addSharedStrings(e,t){t.sharedStrings&&t.sharedStrings.count&&e.append(t.sharedStrings.xml,{name:L.xlSharedStrings})}async addStyles(e,t){let{xml:n}=t.styles;n&&e.append(n,{name:L.xlStyles})}async addWorkbook(e,t){let n=new Na;e.append(n.toXml(t),{name:L.xlWorkbook})}async addWorksheets(e,t){let n=new $o,r=new I,i=new Qs,a=new oc,o=new sc;t.worksheets.forEach(t=>{let{fileIndex:s}=t,c=new k;n.render(c,t),e.append(c.xml,{name:Bi(s)}),t.rels&&t.rels.length&&(c=new k,r.render(c,t.rels),e.append(c.xml,{name:Vi(s)})),t.comments.length>0&&(c=new k,i.render(c,t),e.append(c.xml,{name:Ui(s)}));let l=t.comments.length>0,u=t.formControls&&t.formControls.length>0;(l||u)&&(c=new k,a.render(c,{comments:l?t.comments:[],formControls:u?t.formControls:[]}),e.append(c.xml,{name:Gi(s)})),u&&t.formControls.forEach(t=>{let n=o.toXml(t);e.append(n,{name:ma(t.ctrlPropId)})})})}addDrawings(e,t){let n=new vs,r=new I,i=t.rawDrawings||{};t.worksheets.forEach(t=>{let{drawing:a}=t;if(a){if(this.drawingHasChartReference(a)&&i[a.name])e.append(i[a.name],{name:qi(a.name)});else{let t=Xo(a.anchors??[]),r=a.anchors?{...a,anchors:t}:a;n.prepare(r);let i=n.toXml(r);e.append(i,{name:qi(a.name)})}let t=r.toXml(a.rels);e.append(t,{name:Ji(a.name)})}})}addTables(e,t){let n=new Ts;t.worksheets.forEach(t=>{let{tables:r}=t;r.forEach(t=>{n.prepare(t,{});let r=n.toXml(t);e.append(r,{name:Ki(t.target)})})})}addPassthrough(e,t){let n=new mp;n.fromRecord(t.passthrough||{}),n.writeToZip(e)}addPivotTables(t,n){if(!n.pivotTables.length)return;let r=new Ms,i=new Bs,a=new Ks,o=new I,s=new Map;n.pivotTables.forEach(n=>{let c=n.tableNumber,l=n.isLoaded,u=n.cacheId;if(!s.has(u)){if(s.set(u,c),l){if(n.cacheDefinition){let e=i.toXml(n.cacheDefinition);t.append(e,{name:Yi(c)})}if(n.cacheRecords){let e=r.toXml(n.cacheRecords);t.append(e,{name:Zi(c)})}}else{let e=r.toXml(n);t.append(e,{name:Zi(c)}),e=i.toXml(n),t.append(e,{name:Yi(c)})}if(!l||n.cacheRecords){let r=(l?n.cacheDefinition?.rId:void 0)??`rId1`,i=o.toXml([{Id:r,Type:e.RelType.PivotCacheRecords,Target:Qi(c)}]);t.append(i,{name:Xi(c)})}}let d=a.toXml(n);t.append(d,{name:$i(c)});let f=s.get(u);d=o.toXml([{Id:`rId1`,Type:e.RelType.PivotCacheDefinition,Target:ta(f)}]),t.append(d,{name:ea(c)})})}_finalize(e){return new Promise((t,n)=>{e.on(`finish`,()=>{t(this)}),e.on(`error`,n),e.finalize()})}prepareModel(e,t){e.creator=e.creator??`ExcelTS`,e.lastModifiedBy=e.lastModifiedBy??`ExcelTS`,e.created=e.created??new Date,e.modified=e.modified??new Date,e.useSharedStrings=t.useSharedStrings===void 0?!0:t.useSharedStrings,e.useStyles=t.useStyles===void 0?!0:t.useStyles,e.sharedStrings=new ii;let n=e.defaultFont;e.styles=e.useStyles?new Zr(!0):new Zr.Mock,n&&e.styles.setDefaultFont&&e.styles.setDefaultFont(n);let r=new Na,i=new $o;r.prepare(e);let a={sharedStrings:e.sharedStrings,styles:e.styles,date1904:e.properties?.date1904,drawingsCount:0,media:e.media};a.drawings=e.drawings=[],a.commentRefs=e.commentRefs=[],a.formControlRefs=e.formControlRefs=[];let o=0;e.tables=[],e.worksheets.forEach((t,n)=>{t.fileIndex=n+1,t.tables.forEach(t=>{o++,t.target=`table${o}.xml`,t.id=o,e.tables.push(t)}),i.prepare(t,a)}),e.hasCheckboxes=e.styles.hasCheckboxes;let s=e.passthrough||{},c=new mp;c.fromRecord(s),e.passthroughContentTypes=c.getContentTypes()}},_p=class{constructor(){this._values=[],this._totalRefs=0,this._hash=Object.create(null)}get count(){return this._values.length}get values(){return this._values}get totalRefs(){return this._totalRefs}getString(e){return this._values[e]}add(e){let t=this._hash[e];return t===void 0&&(t=this._hash[e]=this._values.length,this._values.push(e)),this._totalRefs++,t}},vp=class{constructor(e){this.writer=e}push(e){this.writer.addHyperlink(e)}},yp=class{constructor(e){this.id=e.id,this.count=0,this._hyperlinks=[],this._workbook=e.workbook}get stream(){return this._stream||=this._workbook._openStream(Vi(this.id)),this._stream}get length(){return this._hyperlinks.length}each(e){return this._hyperlinks.forEach(e)}get hyperlinksProxy(){return this._hyperlinksProxy||=new vp(this)}addHyperlink(e){let t={Target:e.target,Type:z.Hyperlink,TargetMode:`External`},n=this._writeRelationship(t);this._hyperlinks.push({rId:n,address:e.address})}addMedia(e){return this._writeRelationship(e)}addRelationship(e){return this._writeRelationship(e)}commit(){this.count&&(this._writeClose(),this.stream.end())}_writeOpen(){this.stream.write(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
320
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`)}_writeRelationship(e){this.count||this._writeOpen();let t=`rId${++this.count}`;return e.TargetMode?this.stream.write(`<Relationship Id="${t}" Type="${e.Type}" Target="${D(e.Target)}" TargetMode="${e.TargetMode}"/>`):this.stream.write(`<Relationship Id="${t}" Type="${e.Type}" Target="${e.Target}"/>`),t}_writeClose(){this.stream.write(`</Relationships>`)}},bp=class{constructor(e,t,n){this.id=n.id,this.count=0,this._worksheet=e,this._workbook=n.workbook,this._sheetRelsWriter=t}get commentsStream(){return this._commentsStream||=this._workbook._openStream(Ui(this.id)),this._commentsStream}get vmlStream(){return this._vmlStream||=this._workbook._openStream(Gi(this.id)),this._vmlStream}_addRelationships(){let e={Type:z.Comments,Target:ia(this.id)};this._sheetRelsWriter.addRelationship(e);let t={Type:z.VmlDrawing,Target:aa(this.id)};this.vmlRelId=this._sheetRelsWriter.addRelationship(t)}_addCommentRefs(){this._workbook.commentRefs.push({commentName:`comments${this.id}`,vmlDrawing:`vmlDrawing${this.id}`})}_writeOpen(){this.commentsStream.write(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><authors><author>Author</author></authors><commentList>`),this.vmlStream.write(`<?xml version="1.0" encoding="UTF-8"?><xml xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:x="urn:schemas-microsoft-com:office:excel"><o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="1" /></o:shapelayout><v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe"><v:stroke joinstyle="miter" /><v:path gradientshapeok="t" o:connecttype="rect" /></v:shapetype>`)}_writeComment(e,t){let n=new Zs,r=new k;n.render(r,e),this.commentsStream.write(r.xml);let i=new ac,a=new k;i.render(a,e,t),this.vmlStream.write(a.xml)}_writeClose(){this.commentsStream.write(`</commentList></comments>`),this.vmlStream.write(`</xml>`)}addComments(e){e&&e.length&&(this.startedData||=(this._worksheet.comments=[],this._writeOpen(),this._addRelationships(),this._addCommentRefs(),!0),e.forEach(e=>{e.refAddress=S.decodeAddress(e.ref)}),e.forEach(e=>{this._writeComment(e,this.count),this.count+=1}))}commit(){this.count&&(this._writeClose(),this.commentsStream.end(),this.vmlStream.end())}};let X=new uc,Z={dataValidations:new Ka,sheetProperties:new Xa,sheetFormatProperties:new Za,columns:new M({tag:`cols`,count:!1,childXform:new za}),row:new Ra,hyperlinks:new M({tag:`hyperlinks`,count:!1,childXform:new Va}),sheetViews:new M({tag:`sheetViews`,count:!1,childXform:new $a}),sheetProtection:new eo,pageMargins:new to,pageSeteup:new so,autoFilter:new uo,picture:new fo,drawing:new po,conditionalFormattings:new No,headerFooter:new vo,rowBreaks:new go,colBreaks:new _o};var xp=class{constructor(e){this.id=e.id,this.name=e.name||`Sheet${this.id}`,this.state=e.state??`visible`,this._rows=[],this._columns=[],this._keys={},this._merges=[],this._merges.add=function(){},this._sheetRelsWriter=new yp(e),this._sheetCommentsWriter=new bp(this,this._sheetRelsWriter,e),this._dimensions=new C,this._rowZero=1,this._rowOffset=0,this.committed=!1,this.dataValidations=new et,this._formulae={},this._siFormulae=0,this.conditionalFormatting=[],this.rowBreaks=[],this.colBreaks=[],this.properties=Object.assign({},{defaultRowHeight:15,outlineLevelCol:0,outlineLevelRow:0},e.properties),this.headerFooter=Object.assign({},{differentFirst:!1,differentOddEven:!1,oddHeader:null,oddFooter:null,evenHeader:null,evenFooter:null,firstHeader:null,firstFooter:null},e.headerFooter),this.pageSetup=Object.assign({},{margins:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},orientation:`portrait`,horizontalDpi:4294967295,verticalDpi:4294967295,fitToPage:!!(e.pageSetup&&(e.pageSetup.fitToWidth||e.pageSetup.fitToHeight)&&!e.pageSetup.scale),pageOrder:`downThenOver`,blackAndWhite:!1,draft:!1,cellComments:`None`,errors:`displayed`,scale:100,fitToWidth:1,fitToHeight:1,paperSize:void 0,showRowColHeaders:!1,showGridLines:!1,horizontalCentered:!1,verticalCentered:!1,rowBreaks:null,colBreaks:null},e.pageSetup),this.useSharedStrings=e.useSharedStrings??!1,this._workbook=e.workbook,this.hasComments=!1,this._views=e.views??[],this.autoFilter=e.autoFilter??null,this._media=[],this.sheetProtection=null,this._writeOpenWorksheet(),this.startedData=!1}get workbook(){return this._workbook}get stream(){return this._stream||=this._workbook._openStream(Bi(this.id)),this._stream}destroy(){throw new b(`destroy`,`Invalid operation for a streaming writer`)}commit(){if(!this.committed){for(let e=this._rowOffset;e<this._rows.length;e++){let t=this._rows[e];t&&this._writeRow(t)}this._rows=null,this.startedData||this._writeOpenSheetData(),this._writeCloseSheetData(),this._writeSheetProtection(),this._writeAutoFilter(),this._writeMergeCells(),this._writeHyperlinks(),this._writeConditionalFormatting(),this._writeDataValidations(),this._writePageMargins(),this._writePageSetup(),this._writeHeaderFooter(),this._writeRowBreaks(),this._writeColBreaks(),this._writeDrawing(),this._writeBackground(),this._writeLegacyData(),this._writeCloseWorksheet(),this.stream.end(),this._sheetCommentsWriter.commit(),this._sheetRelsWriter.commit(),this.committed=!0}}get dimensions(){return this._dimensions}get views(){return this._views}get columns(){return this._columns}set columns(e){this._headerRowCount=e.reduce((e,t)=>{let n=t.header&&1||t.headers&&t.headers.length||0;return Math.max(e,n)},0);let t=1,n=this._columns=[];e.forEach(e=>{let r=new Be(this,t++,!1);n.push(r),r.defn=e})}getColumnKey(e){return this._keys[e]}setColumnKey(e,t){this._keys[e]=t}deleteColumnKey(e){delete this._keys[e]}eachColumnKey(e){Object.keys(this._keys).forEach(t=>e(this._keys[t],t))}getColumn(e){if(typeof e==`string`){let t=this._keys[e];if(t)return t;e=S.l2n(e)}if(e>this._columns.length){let t=this._columns.length+1;for(;t<=e;)this._columns.push(new Be(this,t++))}return this._columns[e-1]}get _nextRow(){return this._rowZero+(this._rows.length-this._rowOffset)}eachRow(e,t){let n,r;if(typeof e==`function`?(n=e,r=void 0):(n=t,r=e),r&&r.includeEmpty){let e=this._nextRow;for(let t=this._rowZero;t<e;t++)n(this.getRow(t),t)}else this._rows.forEach(e=>{e&&e.hasValues&&n(e,e.number)})}_commitRow(e){let t=!1,n=this._rows;for(;this._rowOffset<n.length&&!t;){let r=n[this._rowOffset];n[this._rowOffset]=void 0,this._rowOffset++,this._rowZero++,r&&(this._writeRow(r),t=r.number===e.number,this._rowZero=r.number+1),this._rowOffset>1024&&this._rowOffset>n.length>>1&&(n.splice(0,this._rowOffset),this._rowOffset=0)}}get lastRow(){let e=this._rows;for(let t=e.length-1;t>=this._rowOffset;t--){let n=e[t];if(n)return n}}findRow(e){let t=e-this._rowZero+this._rowOffset;return this._rows[t]}getRow(e){let t=e-this._rowZero+this._rowOffset;if(t<this._rowOffset)throw new m(e,`this row has been committed`);let n=this._rows[t];return n||(this._rows[t]=n=new ze(this,e)),n}addRow(e){let t=new ze(this,this._nextRow);return this._rows[t.number-this._rowZero+this._rowOffset]=t,t.values=e,t}findCell(e,t){let n=S.getAddress(e,t),r=this.findRow(n.row);return r?r.findCell(n.col):void 0}getCell(e,t){let n=S.getAddress(e,t);return this.getRow(n.row).getCellEx(n)}mergeCells(...e){let t=new C(e);this._merges.forEach(e=>{if(e.intersects(t))throw new h});let{top:n,left:r,bottom:i,right:a}=t,o=yn(n,r,i,a,(e,t)=>this.findCell(e,t)),s=this.getCell(n,r);for(let e=n;e<=i;e++)for(let t=r;t<=a;t++)(e>n||t>r)&&this.getCell(e,t).merge(s);o&&bn(n,r,i,a,o,(e,t)=>this.getCell(e,t)),this._merges.push(t)}addConditionalFormatting(e){this.conditionalFormatting.push(e)}removeConditionalFormatting(e){typeof e==`number`?this.conditionalFormatting.splice(e,1):e instanceof Function?this.conditionalFormatting=this.conditionalFormatting.filter(e):this.conditionalFormatting=[]}addBackgroundImage(e){this._background={imageId:Number(e)}}getBackgroundImageId(){return this._background&&this._background.imageId}addImage(e,t){let n=this._parseImageRange(String(e),t);this._media.push(n)}getImages(){return this._media}_parseImageRange(e,t){if(typeof t==`string`){let n=S.decode(t);if(`top`in n)return{type:`image`,imageId:e,range:{tl:new Ue(this,{col:n.left,row:n.top},-1).model,br:new Ue(this,{col:n.right,row:n.bottom},0).model,editAs:`oneCell`}};throw Error(`Invalid image range: "${t}". Expected a range like "A1:C3".`)}return{type:`image`,imageId:e,range:{tl:new Ue(this,t.tl,0).model,br:t.br?new Ue(this,t.br,0).model:void 0,ext:t.ext,editAs:t.editAs},hyperlinks:t.hyperlinks}}async protect(e,t){this.sheetProtection={sheet:!0},t&&`spinCount`in t&&(t.spinCount=Number.isFinite(t.spinCount)?Math.round(Math.max(0,t.spinCount)):1e5),e&&(this.sheetProtection.algorithmName=`SHA-512`,this.sheetProtection.saltValue=It(sn.randomBytes(16)),this.sheetProtection.spinCount=t&&`spinCount`in t?t.spinCount:1e5,this.sheetProtection.hashValue=await sn.convertPasswordToHash(e,`SHA-512`,this.sheetProtection.saltValue,this.sheetProtection.spinCount)),t&&(this.sheetProtection=Object.assign(this.sheetProtection,t),!e&&`spinCount`in t&&delete this.sheetProtection.spinCount)}unprotect(){this.sheetProtection=null}_write(e){X.reset(),X.addText(e),this.stream.write(X)}_writeSheetProperties(e,t,n){let r={outlineProperties:t&&t.outlineProperties,tabColor:t&&t.tabColor,pageSetup:n&&n.fitToPage?{fitToPage:n.fitToPage}:void 0};e.addText(Z.sheetProperties.toXml(r))}_writeSheetFormatProperties(e,t){let n=t?{defaultRowHeight:t.defaultRowHeight,dyDescent:t.dyDescent,outlineLevelCol:t.outlineLevelCol,outlineLevelRow:t.outlineLevelRow}:void 0;t&&t.defaultColWidth&&(n.defaultColWidth=t.defaultColWidth),e.addText(Z.sheetFormatProperties.toXml(n))}_writeOpenWorksheet(){X.reset(),X.addText(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>`),X.addText(`<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">`),this._writeSheetProperties(X,this.properties,this.pageSetup),X.addText(Z.sheetViews.toXml(this.views)),this._writeSheetFormatProperties(X,this.properties),this.stream.write(X)}_writeColumns(){let e=Be.toModel(this.columns);e&&(Z.columns.prepare(e,{styles:this._workbook.styles}),this.stream.write(Z.columns.toXml(e)))}_writeOpenSheetData(){this._write(`<sheetData>`)}_writeRow(e){if(this.startedData||=(this._writeColumns(),this._writeOpenSheetData(),!0),e.hasValues||e.height!=null){let{model:t}=e,n={styles:this._workbook.styles,sharedStrings:this.useSharedStrings?this._workbook.sharedStrings:void 0,hyperlinks:this._sheetRelsWriter.hyperlinksProxy,merges:this._merges,formulae:this._formulae,siFormulae:this._siFormulae,comments:[]};Z.row.prepare(t,n),this.stream.write(Z.row.toXml(t)),n.comments.length&&(this.hasComments=!0,this._sheetCommentsWriter.addComments(n.comments))}}_writeCloseSheetData(){this._write(`</sheetData>`)}_writeMergeCells(){this._merges.length&&(X.reset(),X.addText(`<mergeCells count="${this._merges.length}">`),this._merges.forEach(e=>{X.addText(`<mergeCell ref="${e}"/>`)}),X.addText(`</mergeCells>`),this.stream.write(X))}_writeHyperlinks(){this.stream.write(Z.hyperlinks.toXml(this._sheetRelsWriter._hyperlinks))}_writeConditionalFormatting(){let e={styles:this._workbook.styles};Z.conditionalFormattings.prepare(this.conditionalFormatting,e),this.stream.write(Z.conditionalFormattings.toXml(this.conditionalFormatting))}_writeRowBreaks(){this.stream.write(Z.rowBreaks.toXml(this.rowBreaks))}_writeColBreaks(){this.stream.write(Z.colBreaks.toXml(this.colBreaks))}_writeDataValidations(){this.stream.write(Z.dataValidations.toXml(this.dataValidations.model))}_writeSheetProtection(){this.stream.write(Z.sheetProtection.toXml(this.sheetProtection))}_writePageMargins(){this.stream.write(Z.pageMargins.toXml(this.pageSetup.margins))}_writePageSetup(){this.stream.write(Z.pageSeteup.toXml(this.pageSetup))}_writeHeaderFooter(){this.stream.write(Z.headerFooter.toXml(this.headerFooter))}_writeAutoFilter(){this.stream.write(Z.autoFilter.toXml(this.autoFilter))}_writeDrawing(){if(this._media.length===0)return;let e=`drawing${this.id}`,t=this._sheetRelsWriter.addRelationship({Type:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,Target:oa(e)}),{anchors:n,rels:r}=Yo(this._media,[],{getBookImage:e=>this._workbook.getImage(Number(e)),nextRId:e=>`rId${e.length+1}`});this._drawing={rId:t,name:e,anchors:n,rels:r},this.stream.write(Z.drawing.toXml({rId:t}))}get drawing(){return this._drawing}_writeBackground(){if(this._background){if(this._background.imageId!==void 0){let e=this._workbook.getImage(this._background.imageId),t=this._sheetRelsWriter.addMedia({Target:pa(e.name),Type:z.Image});this._background={...this._background,rId:t}}this.stream.write(Z.picture.toXml({rId:this._background.rId}))}}_writeLegacyData(){this.hasComments&&(X.reset(),X.addText(`<legacyDrawing r:id="${this._sheetCommentsWriter.vmlRelId}"/>`),this.stream.write(X))}_writeDimensions(){}_writeCloseWorksheet(){this._write(`</worksheet>`)}};let Sp=new Uint8Array,Cp=new TextDecoder;var wp=class{constructor(e,t){this.WorksheetWriterClass=t,this.created=e.created||new Date,this.modified=e.modified||this.created,this.creator=e.creator??`ExcelTS`,this.lastModifiedBy=e.lastModifiedBy??`ExcelTS`,this.lastPrinted=e.lastPrinted,this.useSharedStrings=e.useSharedStrings??!1,this.sharedStrings=new _p,this.styles=e.useStyles?new Zr(!0):new Zr.Mock(!0),this._definedNames=new cr,this._worksheets=[],this.views=[],this.zipOptions=e.zip;let n=e.zip?.zlib?.level??e.zip?.compressionOptions?.level??1;this.compressionLevel=Math.max(0,Math.min(9,n)),this.media=[],this.commentRefs=[],this._trueStreaming=e.trueStreaming??!1,this.zip=new Xd((e,t,n)=>{e?this.stream.emit(`error`,e):(this.stream.write(t),n&&this.stream.end())}),this.stream=this._createOutputStream(e),this.promise=Promise.resolve()}_createOutputStream(e){return e.stream?Jf(e.stream):new gc}get definedNames(){return this._definedNames}_openStream(e){let t=new gc({bufSize:this._trueStreaming?4096:65536,batch:!this._trueStreaming}),n=new Yd(e,{level:this.compressionLevel});this.zip.add(n);let r=e=>n.push(e);return t.on(`data`,r),t.once(`finish`,()=>{t.removeListener(`data`,r),n.push(Sp,!0),t.emit(`zipped`)}),t}_addFile(e,t,n){let r=new Yd(t,{level:this.compressionLevel});this.zip.add(r);let i;i=n?lt(typeof e==`string`?e:Cp.decode(e)):typeof e==`string`?tn(e):e,r.push(i,!0)}_commitWorksheets(){let e=this._worksheets.map(e=>e.committed?Promise.resolve():new Promise(t=>{e.stream.once(`zipped`,()=>t()),e.commit()}));return e.length?Promise.all(e).then(()=>{}):Promise.resolve()}async commit(){await this.promise,await this._commitWorksheets(),await this.addMedia(),this.addDrawings(),await Promise.all([this.addThemes(),this.addOfficeRels(),this.addContentTypes(),this.addApp(),this.addCore(),this.addSharedStrings(),this.addStyles(),this.addFeaturePropertyBag(),this.addWorkbookRels()]),await this.addWorkbook(),await this._finalize()}get nextId(){for(let e=1;e<this._worksheets.length;e++)if(!this._worksheets[e])return e;return this._worksheets.length||1}addImage(e){let t=this.media.length,n={...e,type:`image`,name:`image${t}.${e.extension}`};return this.media.push(n),t}getImage(e){return this.media[e]}addWorksheet(e,t){let n=t||{},r=n.useSharedStrings===void 0?this.useSharedStrings:n.useSharedStrings;n.tabColor&&(console.trace(`tabColor option has moved to { properties: tabColor: {...} }`),n.properties={tabColor:n.tabColor,...n.properties});let i=this.nextId;e??=`sheet${i}`;let a=new this.WorksheetWriterClass({id:i,name:e,workbook:this,useSharedStrings:r,properties:n.properties,state:n.state,pageSetup:n.pageSetup,views:n.views,autoFilter:n.autoFilter,headerFooter:n.headerFooter});return this._worksheets[i]=a,a}getWorksheet(e){if(e===void 0)return this._worksheets.find(()=>!0);if(typeof e==`number`)return this._worksheets[e];if(typeof e==`string`)return this._worksheets.find(t=>t?.name===e)}addStyles(){return new Promise(e=>{this._addFile(this.styles.xml,L.xlStyles),e()})}addThemes(){return new Promise(e=>{this._addFile(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
321
+ <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"> <a:themeElements> <a:clrScheme name="Office"> <a:dk1> <a:sysClr val="windowText" lastClr="000000"/> </a:dk1> <a:lt1> <a:sysClr val="window" lastClr="FFFFFF"/> </a:lt1> <a:dk2> <a:srgbClr val="1F497D"/> </a:dk2> <a:lt2> <a:srgbClr val="EEECE1"/> </a:lt2> <a:accent1> <a:srgbClr val="4F81BD"/> </a:accent1> <a:accent2> <a:srgbClr val="C0504D"/> </a:accent2> <a:accent3> <a:srgbClr val="9BBB59"/> </a:accent3> <a:accent4> <a:srgbClr val="8064A2"/> </a:accent4> <a:accent5> <a:srgbClr val="4BACC6"/> </a:accent5> <a:accent6> <a:srgbClr val="F79646"/> </a:accent6> <a:hlink> <a:srgbClr val="0000FF"/> </a:hlink> <a:folHlink> <a:srgbClr val="800080"/> </a:folHlink> </a:clrScheme> <a:fontScheme name="Office"> <a:majorFont> <a:latin typeface="Cambria"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Times New Roman"/> <a:font script="Hebr" typeface="Times New Roman"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="MoolBoran"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Times New Roman"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:majorFont> <a:minorFont> <a:latin typeface="Calibri"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Arial"/> <a:font script="Hebr" typeface="Arial"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="DaunPenh"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Arial"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:minorFont> </a:fontScheme> <a:fmtScheme name="Office"> <a:fillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="35000"> <a:schemeClr val="phClr"> <a:tint val="37000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="15000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="1"/> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="100000"/> <a:shade val="100000"/> <a:satMod val="130000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:shade val="100000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="0"/> </a:gradFill> </a:fillStyleLst> <a:lnStyleLst> <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"> <a:shade val="95000"/> <a:satMod val="105000"/> </a:schemeClr> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:prstDash val="solid"/> </a:ln> </a:lnStyleLst> <a:effectStyleLst> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="38000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="35000"/> </a:srgbClr> </a:outerShdw> </a:effectLst> <a:scene3d> <a:camera prst="orthographicFront"> <a:rot lat="0" lon="0" rev="0"/> </a:camera> <a:lightRig rig="threePt" dir="t"> <a:rot lat="0" lon="0" rev="1200000"/> </a:lightRig> </a:scene3d> <a:sp3d> <a:bevelT w="63500" h="25400"/> </a:sp3d> </a:effectStyle> </a:effectStyleLst> <a:bgFillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="40000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="40000"> <a:schemeClr val="phClr"> <a:tint val="45000"/> <a:shade val="99000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="20000"/> <a:satMod val="255000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="-80000" r="50000" b="180000"/> </a:path> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="80000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="30000"/> <a:satMod val="200000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:path path="circle"> <a:fillToRect l="50000" t="50000" r="50000" b="50000"/> </a:path> </a:gradFill> </a:bgFillStyleLst> </a:fmtScheme> </a:themeElements> <a:objectDefaults> <a:spDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="1"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="3"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="2"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="lt1"/> </a:fontRef> </a:style> </a:spDef> <a:lnDef> <a:spPr/> <a:bodyPr/> <a:lstStyle/> <a:style> <a:lnRef idx="2"> <a:schemeClr val="accent1"/> </a:lnRef> <a:fillRef idx="0"> <a:schemeClr val="accent1"/> </a:fillRef> <a:effectRef idx="1"> <a:schemeClr val="accent1"/> </a:effectRef> <a:fontRef idx="minor"> <a:schemeClr val="tx1"/> </a:fontRef> </a:style> </a:lnDef> </a:objectDefaults> <a:extraClrSchemeLst/> </a:theme>`,L.xlTheme1),e()})}addOfficeRels(){return new Promise(e=>{let t=new I().toXml([{Id:`rId1`,Type:z.OfficeDocument,Target:L.xlWorkbook},{Id:`rId2`,Type:z.CoreProperties,Target:L.docPropsCore},{Id:`rId3`,Type:z.ExtenderProperties,Target:L.docPropsApp}]);this._addFile(t,L.rootRels),e()})}addContentTypes(){return new Promise(e=>{let t=this._worksheets.filter(Boolean);t.forEach(e=>{e.fileIndex=e.id});let n=t.filter(e=>e.drawing).map(e=>e.drawing),r={worksheets:t,sharedStrings:this.sharedStrings,commentRefs:this.commentRefs,media:this.media,drawings:n,hasCheckboxes:this.styles.hasCheckboxes},i=new ga;this._addFile(i.toXml(r),L.contentTypes),e()})}addMedia(){return Promise.all(this.media.map(async e=>{if(e.type===`image`){let t=zi(e.name);if(e.buffer){this._addFile(e.buffer,t);return}if(e.base64){let n=e.base64.substring(e.base64.indexOf(`,`)+1);this._addFile(n,t,!0);return}if(e.filename)throw new v(`Loading images from filename`,`not supported in browser. Use buffer or base64.`)}throw new ne(`Unsupported media`)}))}addDrawings(){let e=new vs,t=new I;for(let n of this._worksheets){if(!n?.drawing)continue;let{drawing:r}=n,i=Xo(r.anchors),a={...r,anchors:i};e.prepare(a);let o=e.toXml(a);this._addFile(o,qi(r.name));let s=t.toXml(r.rels);this._addFile(s,Ji(r.name))}}addApp(){return new Promise(e=>{let t=new ya;this._addFile(t.toXml({worksheets:this._worksheets.filter(Boolean)}),L.docPropsApp),e()})}addCore(){return new Promise(e=>{let t=new $r;this._addFile(t.toXml(this),L.docPropsCore),e()})}addSharedStrings(){return this.sharedStrings.count?new Promise(e=>{let t=new ii;this._addFile(t.toXml(this.sharedStrings),L.xlSharedStrings),e()}):Promise.resolve()}addFeaturePropertyBag(){if(this.styles.hasCheckboxes){let e=new es;this._addFile(e.toXml({}),L.xlFeaturePropertyBag)}return Promise.resolve()}addWorkbookRels(){let e=1,t=[{Id:`rId${e++}`,Type:z.Styles,Target:na.workbookStyles},{Id:`rId${e++}`,Type:z.Theme,Target:na.workbookTheme1}];return this.sharedStrings.count&&t.push({Id:`rId${e++}`,Type:z.SharedStrings,Target:na.workbookSharedStrings}),this.styles.hasCheckboxes&&t.push({Id:`rId${e++}`,Type:z.FeaturePropertyBag,Target:na.workbookFeaturePropertyBag}),this._worksheets.forEach(n=>{n&&(n.rId=`rId${e++}`,t.push({Id:n.rId,Type:z.Worksheet,Target:Hi(n.id)}))}),new Promise(e=>{let n=new I;this._addFile(n.toXml(t),L.xlWorkbookRels),e()})}addWorkbook(){let e={worksheets:this._worksheets.filter(Boolean),definedNames:this._definedNames.model,views:this.views,properties:{},calcProperties:{}};return new Promise(t=>{let n=new Na;n.prepare(e),this._addFile(n.toXml(e),L.xlWorkbook),t()})}_finalize(){return new Promise((e,t)=>{let n=e=>{this.stream.removeListener(`finish`,r),t(e)},r=()=>{this.stream.removeListener(`error`,n),e(this)};this.stream.once(`error`,n),this.stream.once(`finish`,r),this.zip.end()})}},Tp=class extends wp{constructor(e={}){super(e,xp)}},Ep=class{constructor(e){this.searchFrom=0,this.pattern=e,this.overlap=Math.max(0,e.length-1)}find(e){return e.indexOfPattern(this.pattern,this.searchFrom)}onConsume(e){e>0&&(this.searchFrom=Math.max(0,this.searchFrom-e))}onNoMatch(e){this.searchFrom=Math.max(this.searchFrom,Math.max(0,e-this.overlap))}};let Dp=[[`version`,4],[`pubKeyLength`,4],[`signatureLength`,4]],Op=[[`versionsNeededToExtract`,2],[`flags`,2],[`compressionMethod`,2],[`lastModifiedTime`,2],[`lastModifiedDate`,2],[`crc32`,4],[`compressedSize`,4],[`uncompressedSize`,4],[`fileNameLength`,2],[`extraFieldLength`,2]],kp=[[`dataDescriptorSignature`,4],[`crc32`,4],[`compressedSize`,4],[`uncompressedSize`,4]],Ap=[[`versionMadeBy`,2],[`versionsNeededToExtract`,2],[`flags`,2],[`compressionMethod`,2],[`lastModifiedTime`,2],[`lastModifiedDate`,2],[`crc32`,4],[`compressedSize`,4],[`uncompressedSize`,4],[`fileNameLength`,2],[`extraFieldLength`,2],[`fileCommentLength`,2],[`diskNumber`,2],[`internalFileAttributes`,2],[`externalFileAttributes`,4],[`offsetToLocalFileHeader`,4]],jp=[[`diskNumber`,2],[`diskStart`,2],[`numberOfRecordsOnDisk`,2],[`numberOfRecords`,2],[`sizeOfCentralDirectory`,4],[`offsetToStartOfCentralDirectory`,4],[`commentLength`,2]],Mp=Hl(Ju);function Np(e){return((e||0)&Zu)!==0}function Pp(e){if(e.length===0)return!1;let t=e.charCodeAt(e.length-1);return t===47||t===92}function Fp(e,t){return t===0&&Pp(e)?`Directory`:`File`}function Ip(e,t,n){return{path:e,pathBuffer:t,flags:{isUnicode:Np(n)}}}function Lp(e,t){let n=e.lastModifiedDate||0,r=e.lastModifiedTime||0,i=Vu(n,r),a=t.mtimeUnixSeconds;return a===void 0?i:Hu(n,r,a)}let Rp=Cd;function zp(e){return((e||0)&8)!=0}function Bp(e,t){return!zp(e)||(t||0)>0}async function Vp(e){let t=await e(12),n=t.length>=12?Yp(t):Kl(t,Dp),r=n.pubKeyLength||0,i=await e(r+(n.signatureLength||0));return n.publicKey=i.subarray(0,r),n.signature=i.subarray(r),n}async function Hp(e){let t=await e(26),n=t.length>=26?Xp(t):Kl(t,Op);return{vars:n,fileNameBuffer:await e(n.fileNameLength||0),extraFieldData:await e(n.extraFieldLength||0)}}async function Up(e){let t=await e(16);return t.length>=16?Zp(t):Kl(t,kp)}async function Wp(e){let t=Kl(await e(42),Ap);await e(t.fileNameLength||0),await e(t.extraFieldLength||0),await e(t.fileCommentLength||0)}async function Gp(e){await e(Kl(await e(18),jp).commentLength||0)}function Kp(e){switch(e){case Gu:case Ku:case qu:case Yu:case Xu:return!0;default:return!1}}function qp(e,t){return(e[t]|0|(e[t+1]|0)<<8|(e[t+2]|0)<<16|(e[t+3]|0)<<24)>>>0}function Jp(e,t){return(e[t]|(e[t+1]|0)<<8)>>>0}function Yp(e){return{version:qp(e,0),pubKeyLength:qp(e,4),signatureLength:qp(e,8)}}function Xp(e){return{versionsNeededToExtract:Jp(e,0),flags:Jp(e,2),compressionMethod:Jp(e,4),lastModifiedTime:Jp(e,6),lastModifiedDate:Jp(e,8),crc32:qp(e,10),compressedSize:qp(e,14),uncompressedSize:qp(e,18),fileNameLength:Jp(e,22),extraFieldLength:Jp(e,24)}}function Zp(e){return{dataDescriptorSignature:qp(e,0),crc32:qp(e,4),compressedSize:qp(e,8),uncompressedSize:qp(e,12)}}let Qp=Hl(qu);async function $p(e,t,n,r,i){for(;;){let a=await t.pull(4);if(a.length===0){n.emitClose();return}let o=Ul(a,0);if(o===875721283){r.crxHeader=await Vp(async e=>t.pull(e)),n.emitCrxHeader(r.crxHeader);continue}if(o===67324752){await i(e,t,n,r);continue}if(o===33639248){r.reachedCD=!0,await Wp(async e=>t.pull(e));continue}if(o===101010256){await Gp(async e=>t.pull(e)),t.setDone(),n.emitClose();return}if(r.reachedCD){await t.pullUntil(Qp,!0),await Gp(async e=>t.pull(e)),t.setDone(),n.emitClose();return}n.emitError(Error(`invalid signature: 0x`+o.toString(16))),n.emitClose();return}}let em=256*1024;function tm(e){let t=e.pipe(new Qf({transform(e,t,n){n()}}));return t.promise=()=>new Promise((e,n)=>{t.on(`finish`,e),t.on(`error`,n)}),t}function nm(e){return new Promise((t,n)=>{let r=[],i=new Qf({transform(e,t,n){r.push(e),n()}});i.on(`finish`,()=>{t(r.length===1?r[0]:O(r))}),i.on(`error`,n),e.on(`error`,n).pipe(i)})}function rm(e){let{source:t,dataDescriptorSignature:n}=e,r=e.keepTailBytes??20,i=e.errorMessage??`FILE_ENDED: Data descriptor not found`,a=new $f({highWaterMark:em}),o=!1,s=!1,c=0,l=new Ep(n),u,d=()=>{u&&=(u(),void 0)},f=()=>{s=!1,p()},p=()=>{if(o||s)return;let e=t.getLength();for(e===0&&t.maybeReleaseWriteCallback?.();e>0;){for(;;){let n=l.find(t);if(n===-1)break;let r=n+16;if(r+4<=e){let e=t.peekUint32LE(r),i=t.peekUint32LE(n+8),u=c+n>>>0;if(e!==null&&i!==null&&Kp(e)&&i===u){if(n>0)if(t.peekChunks&&t.discard){let e=t.peekChunks(n),r=0;for(let t of e){let e=a.write(t);if(r+=t.length,!e){s=!0,a.once(`drain`,f);break}}if(r>0&&(t.discard(r),c+=r,l.onConsume(r)),s)return}else{let e=a.write(t.read(n));if(c+=n,l.onConsume(n),!e){s=!0,a.once(`drain`,f);return}}o=!0,t.maybeReleaseWriteCallback?.(),d(),a.end();return}l.searchFrom=n+1;continue}l.searchFrom=n;break}l.onNoMatch(e);let n=Math.max(0,e-r);if(n>0){if(t.peekChunks&&t.discard){let i=t.peekChunks(n),o=0;for(let e of i){let t=a.write(e);if(o+=e.length,!t){s=!0,a.once(`drain`,f);break}}o>0&&(t.discard(o),c+=o,e-=o,l.onConsume(o)),e<=r&&t.maybeReleaseWriteCallback?.();return}let i=a.write(t.read(n));c+=n,e-=n,l.onConsume(n),e<=r&&t.maybeReleaseWriteCallback?.(),i||(s=!0,a.once(`drain`,f));return}t.maybeReleaseWriteCallback?.();break}!o&&t.isFinished()&&(o=!0,d(),a.destroy(Error(i)))};return u=t.onDataAvailable(p),queueMicrotask(p),a}async function im(e,t,n,r,i,a){let o=e.thresholdBytes??5242880;await $p(e,t,n,i,async(s,c,l,u)=>{await om(e,t,n,r,i,o,a)})}async function am(e,t,n,r){let i=r,a=null,o=e=>{a=e};t.once(`error`,o),n.once(`error`,o);let s=!1,c=t,l=null,u=()=>{try{c?.removeListener?.(`drain`,f)}catch{}try{n.removeListener(`__autodrain`,p)}catch{}try{n.removeListener(`close`,m)}catch{}},d=()=>{let e=l;e&&(l=null,u(),e())},f=()=>{d()},p=()=>{d()},m=()=>{d()},h=async()=>{await new Promise(e=>{l=e,typeof c?.once==`function`&&c.once(`drain`,f),n.once(`__autodrain`,p),n.once(`close`,m),(n.__autodraining||n.destroyed)&&d()})},g=async()=>{if(!s){s=!0;try{let e=t;typeof e.unpipe==`function`&&e.unpipe(n)}catch{}try{!n.writableEnded&&!n.destroyed&&n.end()}catch{}try{let e=t;typeof e.destroy==`function`&&e.destroy()}catch{}}};try{for(t.pipe(n);i>0;){if(a)throw a;!s&&(n.__autodraining||n.destroyed)&&await g();let r=Math.min(262144,i),o=await e.pull(r);if(o.length!==r)throw Error(`FILE_ENDED`);i-=o.length,s||t.write(o)||await h()}s||t.end(),await up(n,{readable:!1})}finally{t.removeListener(`error`,o),n.removeListener(`error`,o)}}async function om(e,t,n,r,i,a,o){let{vars:s,fileNameBuffer:c,extraFieldData:l}=await Hp(async e=>t.pull(e)),u=s;i.crxHeader&&(u.crxHeader=i.crxHeader);let d={uncompressedSize:u.uncompressedSize??0,compressedSize:u.compressedSize??0},f=Rp(l,d);u.uncompressedSize=d.uncompressedSize,u.compressedSize=d.compressedSize;let p=e.encoding?Fl(e.encoding):void 0,m=zl(c,u.flags,f,p),h=new $f({highWaterMark:em}),g=!1;h.autodrain=function(){return g=!0,h.__autodraining=!0,h.emit(`__autodrain`),tm(h)},h.buffer=function(){return nm(h)},h.path=m,h.props=Ip(m,c,u.flags),h.type=Fp(m,u.uncompressedSize??0),e.verbose&&(h.type===`Directory`?console.log(` creating:`,m):h.type===`File`&&(u.compressionMethod===0?console.log(` extracting:`,m):console.log(` inflating:`,m))),u.lastModifiedDateTime=Lp({flags:u.flags,uncompressedSize:u.uncompressedSize??0,lastModifiedDate:u.lastModifiedDate,lastModifiedTime:u.lastModifiedTime},f),h.vars=u,h.extraFields=f,h.__autodraining=g;let _=Bp(u.flags,u.compressedSize);_&&(h.size=u.uncompressedSize??0),e.forceStream?n.pushEntry(h):(n.emitEntry(h),n.pushEntryIfPiped(h)),e.verbose&&console.log({filename:m,vars:u,extraFields:h.extraFields});let v=((u.flags??0)&1)!=0||u.compressionMethod===99,y=u.compressionMethod!==0&&!v&&!g,b=!zp(u.flags),ee=u.compressedSize??0,x=u.uncompressedSize??0;if(b&&_&&o&&y&&ee<=a&&x<=a){let e=o(await t.pull(ee));h.end(e),await up(h,{readable:!1});return}let te=y?r():new $f({highWaterMark:em});if(_){if(await am(t,te,h,u.compressedSize??0),zp(u.flags)){let e=await Up(async e=>t.pull(e));h.size||=e.uncompressedSize??0}return}await lp(t.streamUntilDataDescriptor(),te,h),h.size=(await Up(async e=>t.pull(e))).uncompressedSize??0}var sm=class extends Zf{constructor(){super({writableHighWaterMark:512*1024,readableHighWaterMark:512*1024,write:(e,t,n)=>{this._doWrite(e,n)},final:e=>{this._closeWriter(()=>{e()})}}),this.reading=!1,this.writeClosed=!1,this._junkError=!1,this._bytesIn=0,this._bytesOut=0,this._readingDone=!1,this._pendingWrites=0,this._writeFinishedPromise=null,this._resolveWriteFinished=null,this.decompressionStream=new DecompressionStream(`deflate-raw`),this.writer=this.decompressionStream.writable.getWriter(),this.reader=this.decompressionStream.readable.getReader(),this._readingDonePromise=new Promise(e=>{this._resolveReadingDone=e}),this._startReading()}_doWrite(e,t){if(this._junkError){t&&t();return}this._bytesIn+=e.length,this._pendingWrites++,this.writer.write(e).then(()=>{this._pendingWrites--,this._pendingWrites===0&&this._resolveWriteFinished&&this._resolveWriteFinished(),t&&t()}).catch(e=>{this._pendingWrites--,this._pendingWrites===0&&this._resolveWriteFinished&&this._resolveWriteFinished();let n=e instanceof Error?e.message:String(e);n.includes(`Junk`)||n.includes(`junk`)?(this._junkError=!0,t&&t()):t?t(e):this.emit(`error`,e)})}async _startReading(){if(!this.reading){this.reading=!0;try{for(;;){let{done:e,value:t}=await this.reader.read();if(e)break;this._bytesOut+=t.length,this.push(t)}}catch(e){let t=e instanceof Error?e.message:String(e);t.includes(`Junk`)||t.includes(`junk`)?this._junkError=!0:this.emit(`error`,e)}finally{this._readingDone=!0,this._resolveReadingDone(),this.push(null)}}}_closeWriter(e){if(this.writeClosed){this._readingDonePromise.then(()=>{e&&e()});return}this.writeClosed=!0,(this._pendingWrites>0?new Promise(e=>{this._writeFinishedPromise=new Promise(e=>{this._resolveWriteFinished=e}),this._writeFinishedPromise.then(e)}):Promise.resolve()).then(()=>this.writer.close()).catch(()=>{}).finally(()=>{this._readingDonePromise.then(()=>{e&&e()})})}destroy(e){return this.writeClosed||this.writer.abort(e??void 0).catch(()=>{}),this.reader.cancel(e??void 0).catch(()=>{}),super.destroy(e??void 0)}};let cm=null;function lm(e){if(typeof e==`string`&&e.length>0)return e;if(cm)return cm;let t=new Blob([`
322
322
  let ds;
323
323
  let writer;
324
324
  let reader;
@@ -390,37 +390,37 @@ onmessage = async (ev) => {
390
390
  postMessage({ t: 'error', message: m, id: msg && msg.id });
391
391
  }
392
392
  };
393
- `],{type:`text/javascript`});return am=URL.createObjectURL(t),am}var sm=class extends Jf{constructor(e){super({write:(e,t,n)=>{this._doWrite(e,n)},final:e=>{this._doClose(e)}}),this._nextId=1,this._pendingAcks=new Map,this._workerClosed=!1,this._junkError=!1,this._terminated=!1;let t=om(e);this.worker=new Worker(t),this.worker.onmessage=e=>{let t=e.data;if(!(!t||typeof t.t!=`string`)){if(t.t===`data`){let e=t.chunk;this.push(e);return}if(t.t===`end`){this.push(null),this._terminateWorker();return}if(t.t===`aborted`){this._terminateWorker();return}if(t.t===`ack`){let e=t.id,n=this._pendingAcks.get(e);n&&(this._pendingAcks.delete(e),n());return}if(t.t===`error`){let e=typeof t.message==`string`?t.message:`Worker inflate error`;if(e.includes(`Junk`)||e.includes(`junk`)){this._junkError=!0,this.push(null),this._terminateWorker(),this._settlePendingAcks();return}let n=Error(e);this._settlePendingAcks(n),this.emit(`error`,n),this._terminateWorker();return}}},this.worker.onerror=e=>{let t=Error(e.message??`Worker error`);this._settlePendingAcks(t),this.emit(`error`,t),this._terminateWorker()}}_settlePendingAcks(e){if(this._pendingAcks.size!==0){for(let t of this._pendingAcks.values())t(e);this._pendingAcks.clear()}}_terminateWorker(){if(!this._terminated){this._terminated=!0;try{this.worker.terminate()}catch{}}}_doWrite(e,t){if(this._workerClosed||this._junkError){t();return}let n=this._nextId++;this._pendingAcks.set(n,t);let r=e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e:e.slice();this.worker.postMessage({t:`write`,id:n,chunk:r},[r.buffer])}_doClose(e){if(this._workerClosed){e();return}this._workerClosed=!0,this.worker.postMessage({t:`close`}),e()}destroy(e){if(!this._workerClosed){this._workerClosed=!0;try{this.worker.postMessage({t:`abort`})}catch{}}return this._terminateWorker(),super.destroy(e??void 0)}},cm=class extends Jf{constructor(){super({write:(e,t,n)=>{if(this._finished){n(Error(`write after end`));return}this.chunks.push(e),n()},final:e=>{this._decompress(e)}}),this.chunks=[],this._finished=!1}_decompress(e){try{let t=jc(O(this.chunks));this.push(t),this.push(null),this._finished=!0,e()}catch(t){e(a(t))}}destroy(e){return this._finished=!0,this.chunks=[],super.destroy(e??void 0)}};function lm(){return Jc()?new im:new cm}let um=kp;function dm(e){return class extends Jf{constructor(t={}){super({objectMode:!0,write:(e,t,n)=>{this._handleWrite(e,n)},final:e=>{this.finished=!0,this._maybeReleaseWriteCallback(),this._wakeUp(),this.emit(`data-available`),this.emit(`chunk`,!1),this._parsingDone.then(()=>e()).catch(e)}}),this._buffer=new Hc,this.finished=!1,this._driverState={},this._parsingDone=Promise.resolve(),this._opts=t;let n=Math.max(64*1024,t.inputHighWaterMarkBytes??2*1024*1024),r=Math.max(32*1024,t.inputLowWaterMarkBytes??Math.floor(n/4));this._inputHighWaterMarkBytes=n,this._inputLowWaterMarkBytes=Math.min(r,n);let i={pull:e=>this.pull(e),pullUntil:(e,t)=>this.pullUntil(e,t),stream:e=>this.stream(e),streamUntilDataDescriptor:()=>this._streamUntilDataDescriptor(),setDone:()=>{this.push(null)}},a={emitEntry:e=>{this.emit(`entry`,e)},pushEntry:e=>{this.push(e)},pushEntryIfPiped:e=>{},emitCrxHeader:e=>{this.crxHeader=e,this.emit(`crx-header`,e)},emitError:e=>{if(this.__emittedError=e,this._writeCb){let t=this._writeCb;this._writeCb=void 0,t(e)}this.emit(`error`,e)},emitClose:()=>{this.emit(`close`)}};queueMicrotask(()=>{this._parsingDone=tm(this._opts,i,a,()=>{if(this._opts.useWorkerInflate&&typeof Worker<`u`&&Jc())try{return new sm(this._opts.workerInflateUrl)}catch{return e()}return e()},this._driverState),this._parsingDone.catch(e=>{(!this.__emittedError||this.__emittedError!==e)&&(this.__emittedError=e,this.emit(`error`,e)),this.emit(`close`)})})}_handleWrite(e,t){this._buffer.append(e),this._buffer.length>=this._inputHighWaterMarkBytes?this._writeCb=t:t(),this._wakeUp(),this.emit(`data-available`),this.emit(`chunk`)}get buffer(){return this._buffer.view()}set buffer(e){this._buffer.reset(e)}_wakeUp(){if(this._pendingResolve){let e=this._pendingResolve;this._pendingResolve=void 0,this._pendingDataPromise=void 0,e()}}_maybeReleaseWriteCallback(){if(!this._writeCb||this._buffer.length>this._inputLowWaterMarkBytes)return;let e=this._writeCb;this._writeCb=void 0,e()}_waitForData(){return this._pendingDataPromise||=new Promise(e=>{this._pendingResolve=e}),this._pendingDataPromise}async _pullInternal(e){if(e===0)return G;let t=e,n=null,r=null,i=e=>{if(e.length!==0){if(!n){n=e;return}if(!r){r=[n,e];return}r.push(e)}};for(;t>0;){for(;this._buffer.length===0;){if(this.finished)throw Error(`FILE_ENDED`);await this._waitForData()}let e=Math.min(t,this._buffer.length);i(this._buffer.read(e)),t-=e,this._buffer.length===0&&this._maybeReleaseWriteCallback()}return this._maybeReleaseWriteCallback(),n?r?O(r):n:G}async _pullUntilInternal(e,t=!1){let n=null,r=null,i=new Cp(e),a=e.length,o=e=>{if(e.length!==0){if(!n){n=e;return}if(!r){r=[n,e];return}r.push(e)}};for(;;){let e=this._buffer.length,s=i.find(this._buffer);if(s!==-1){this.match=s;let e=s+(t?a:0);return e>0&&(o(this._buffer.read(e)),this._maybeReleaseWriteCallback()),n?r?O(r):n:G}if(i.onNoMatch(e),this.finished)throw Error(`FILE_ENDED`);let c=this._buffer.length-a;c>0&&(o(this._buffer.read(c)),i.onConsume(c),this._maybeReleaseWriteCallback()),await this._waitForData()}}_streamFixedLength(e){let t=new Xf({highWaterMark:Zp}),n=e,r=!1,i=!1,a=()=>{i=!1,o()},o=()=>{if(!r&&!i){for(;n>0&&this._buffer.length>0;){let e=Math.min(n,this._buffer.length),r=this._buffer.read(e);n-=e;let o=t.write(r);if(this._maybeReleaseWriteCallback(),!o){i=!0,t.once(`drain`,a);return}}n===0?(r=!0,this.removeListener(`data-available`,o),t.end()):this.finished&&(r=!0,this.removeListener(`data-available`,o),t.destroy(Error(`FILE_ENDED`)))}};return this.on(`data-available`,o),queueMicrotask(()=>o()),t}_streamUntilPattern(e,t=!1){let n=new Xf({highWaterMark:Zp}),r=!1,i=e.length,a=new Cp(e),o=!1,s=()=>{o=!1,c()},c=()=>{if(!(r||o))for(;!(this._buffer.length<=0);){let e=this._buffer.length,l=a.find(this._buffer);if(l!==-1){this.match=l;let e=t?l+i:l;if(e>0){let t=n.write(this._buffer.read(e));if(a.onConsume(e),this._maybeReleaseWriteCallback(),!t){o=!0,n.once(`drain`,s);return}}r=!0,this.removeListener(`data-available`,c),n.end();return}if(a.onNoMatch(e),this.finished){r=!0,this.removeListener(`data-available`,c),n.destroy(Error(`FILE_ENDED`));return}let u=e-i;if(u<=0){this._buffer.length<=i&&this._maybeReleaseWriteCallback();break}let d=n.write(this._buffer.read(u));if(a.onConsume(u),this._maybeReleaseWriteCallback(),!d){o=!0,n.once(`drain`,s);return}}};return this.on(`data-available`,c),queueMicrotask(()=>c()),n}stream(e,t){return typeof e==`number`?this._streamFixedLength(e):this._streamUntilPattern(e,t??!1)}pull(e,t){if(e===0)return Promise.resolve(G);if(typeof e==`number`){if(this.finished&&this._buffer.length<e)return Promise.reject(Error(`FILE_ENDED`));if(this._buffer.length>=e){let t=this._buffer.read(e);return this._maybeReleaseWriteCallback(),Promise.resolve(t)}return this._pullInternal(e)}return this.finished?Promise.reject(Error(`FILE_ENDED`)):this._pullUntilInternal(e,t??!1)}pullUntil(e,t){return this.pull(e,t)}_streamUntilDataDescriptor(){return em({source:{getLength:()=>this._buffer.length,read:e=>this._buffer.read(e),peekChunks:e=>this._buffer.peekChunks(e),discard:e=>this._buffer.discard(e),indexOfPattern:(e,t)=>this._buffer.indexOfPattern(e,t),peekUint32LE:e=>this._buffer.peekUint32LE(e),isFinished:()=>this.finished,onDataAvailable:e=>(this.on(`data-available`,e),()=>this.removeListener(`data-available`,e)),maybeReleaseWriteCallback:()=>this._maybeReleaseWriteCallback()},dataDescriptorSignature:um})}promise(){return new Promise((e,t)=>{this.on(`finish`,e),this.on(`end`,e),this.on(`error`,t)})}}}let fm=dm(lm);var pm=class extends fm{};function mm(e){return new pm(e)}async function*hm(e){let t=[],n=null,r=e=>{t.push(e),n&&=(n(),null)};e.on(`data`,r);let i=!1,a=()=>{i=!0,n&&=(n(),null)};e.on(`end`,a);let o=!1,s=e=>{o=e,n&&=(n(),null)};e.on(`error`,s);try{for(;!i||t.length>0;)if(t.length===0?(e.resume(),await new Promise(e=>{n=e})):(e.pause(),yield t.shift()),o)throw o}finally{e.removeListener(`data`,r),e.removeListener(`end`,a),e.removeListener(`error`,s)}}var gm=class extends W{constructor({workbook:e,id:t,iterator:n,options:r}){super(),this.workbook=e,this.id=t,this.sheetNo=typeof t==`number`?t:parseInt(String(t),10),this.iterator=n,this.options=r||{},this.name=`Sheet${this.id}`,this._columns=[],this._keys=Object.create(null),this._dimensions=new C}destroy(){throw new b(`destroy`,`Invalid operation for a streaming reader`)}get dimensions(){return this._dimensions}get columns(){return this._columns}getColumn(e){if(typeof e==`string`){let t=this._keys[e];if(t)return t;e=S.l2n(e)}if(e>this._columns.length){let t=this._columns.length+1;for(;t<=e;)this._columns.push(new Ve(this,t++))}return this._columns[e-1]}getColumnKey(e){return this._keys[e]}setColumnKey(e,t){this._keys[e]=t}deleteColumnKey(e){delete this._keys[e]}eachColumnKey(e){let t=this._keys;for(let n in t)e(t[n],n)}async read(){try{for await(let e of this.parse())for(let t=0;t<e.length;t++){let n=e[t];this.emit(n.eventType,n.value)}this.emit(`finished`)}catch(e){this.emit(`error`,e)}}async*[Symbol.asyncIterator](){for await(let e of this.parse())for(let t=0;t<e.length;t++){let n=e[t];n.eventType===`row`&&(yield n.value)}}async*parse(){let{iterator:e,options:t}=this,n=!1,r=!1,i=null;switch(t.worksheets){case`emit`:n=!0;break;case`prep`:break;default:break}switch(t.hyperlinks){case`emit`:r=!0;break;case`cache`:this.hyperlinks=i=Object.create(null);break;default:break}if(!n&&!r&&!i)return;let a=r||i!==null,{sharedStrings:o,styles:s,properties:c}=this.workbook,l=!1,u=!1,d=!1,f=null,p=null,m=null,h=null;for await(let t of Sr(e)){let e=null;for(let g=0;g<t.length;g++){let _=t[g],v=_.eventType,y=_.value;if(v===`opentag`){let t=y;if(n)switch(t.name){case`cols`:l=!0,f=[];break;case`sheetData`:u=!0;break;case`col`:l&&f.push({min:parseInt(t.attributes.min,10),max:parseInt(t.attributes.max,10),width:parseFloat(t.attributes.width),styleId:parseInt(t.attributes.style??`0`,10)});break;case`row`:if(u){let e=parseInt(t.attributes.r,10);if(p=new Be(this,e),t.attributes.ht&&(p.height=parseFloat(t.attributes.ht)),t.attributes.customHeight===`1`&&(p.customHeight=!0),t.attributes.s!==void 0){let e=parseInt(t.attributes.s,10),n=s.getStyleModel(e);n&&(p.style=n)}}break;case`c`:if(p){let e=t.attributes.s;m={ref:t.attributes.r,s:e===void 0?void 0:parseInt(e,10),t:t.attributes.t}}break;case`f`:m&&(h=m.f={text:``});break;case`v`:m&&(h=m.v={text:``});break;case`is`:case`t`:m&&(h=m.v={text:``});break;case`mergeCell`:break;default:break}if(a)switch(t.name){case`hyperlinks`:d=!0;break;case`hyperlink`:if(d){let n={ref:t.attributes.ref,rId:t.attributes[`r:id`]};r?(e||=[]).push({eventType:`hyperlink`,value:n}):i[n.ref]=n}break;default:break}}else if(v===`text`)n&&h&&(h.text+=y);else if(v===`closetag`){let t=y;if(n)switch(t.name){case`cols`:l=!1,this._columns=Ve.fromModel(f);break;case`sheetData`:u=!1;break;case`row`:p&&(this._dimensions.expandRow({number:p.number,dimensions:p.dimensions??void 0}),(e||=[]).push({eventType:`row`,value:p})),p=null;break;case`c`:if(p&&m){let e=S.decodeAddress(m.ref),t=p.getCell(e.col);if(m.s!==void 0){let e=s.getStyleModel(m.s);e&&(t.style=e)}if(m.f){let e={formula:m.f.text};m.v&&(m.t===`str`?e.result=xt(m.v.text):e.result=parseFloat(m.v.text)),t.value=e}else if(m.v)switch(m.t){case`s`:{let e=parseInt(m.v.text,10);o?t.value=o[e]:t.value={sharedString:e};break}case`inlineStr`:t.value=ht(xt(m.v.text));break;case`str`:t.value=xt(m.v.text);break;case`e`:t.value={error:m.v.text};break;case`b`:t.value=parseInt(m.v.text,10)!==0;break;default:{let e=typeof t.numFmt==`string`?t.numFmt:t.numFmt?.formatCode;e&&Dt(e)?t.value=ft(parseFloat(m.v.text),c?.model?.date1904):t.value=parseFloat(m.v.text);break}}if(i){let e=i[m.ref];e&&(t.text=t.value,t.value=void 0,t.hyperlink=e)}m=null,h=null}break;default:break}if(a)switch(t.name){case`hyperlinks`:d=!1;break;default:break}}}e&&e.length>0&&(yield e)}}},_m=class extends W{constructor({workbook:e,id:t,iterator:n,options:r}){super(),this._hyperlinkCount=0,this.workbook=e,this.id=t,this.iterator=n,this.options=r}get count(){return this.hyperlinks?this._hyperlinkCount:0}each(e){let t=this.hyperlinks;if(t)for(let n in t)e(t[n],n)}async read(){let{iterator:e}=this,t=this.options.hyperlinks,n=t===`emit`,r=t===`cache`,i=null;if(r&&(this._hyperlinkCount=0,this.hyperlinks=i=Object.create(null)),!n&&!r){this.emit(`finished`);return}try{for await(let t of Sr(e))for(let{eventType:e,value:r}of t){if(e!==`opentag`)continue;let t=r;if(t.name!==`Relationship`)continue;let a=t.attributes;if(a.Type!==z.Hyperlink)continue;let o={type:w.RelationshipType.Hyperlink,rId:a.Id,target:a.Target,targetMode:a.TargetMode};if(n){this.emit(`hyperlink`,o);continue}let s=o.rId;i&&i[s]===void 0&&(this._hyperlinkCount+=1),i[s]=o}this.emit(`finished`)}catch(e){this.emit(`error`,e)}}},vm=class extends W{getHyperlinkReader(e){return this._hyperlinkReadersBySheetNo?.[String(e)]}getHyperlink(e,t){return this.getHyperlinkReader(e)?.hyperlinks?.[t]}getHyperlinkTarget(e,t){return this.getHyperlink(e,t)?.target}constructor(e,t,n,r){super(),this.input=e,this.WorksheetReaderClass=n,this.HyperlinkReaderClass=r,this.options={worksheets:`emit`,sharedStrings:`cache`,hyperlinks:`ignore`,styles:`ignore`,entries:`ignore`,...t},this.styles=new Zr,this.styles.init()}_getStream(e){if(e instanceof q)return e;if(e&&typeof e==`object`&&typeof e.getReader==`function`){let t=q.fromWeb;if(typeof t==`function`)return t(e);try{return new q({stream:e})}catch{throw new y(`<ReadableStream>`,`read`,`Could not recognise input`)}}let t=e;if(t instanceof ArrayBuffer&&(t=new Uint8Array(t)),t instanceof Uint8Array)return q.from([t]);throw new y(String(e),`read`,`Could not recognise input`)}_cleanupWaitingWorksheets(e){for(let t of e)t&&typeof t.cleanup==`function`&&t.cleanup()}_createWorksheetReader(e){return new this.WorksheetReaderClass({workbook:this,id:e.id,iterator:e.iterator,options:e.options})}_createHyperlinkReader(e){return new this.HyperlinkReaderClass({workbook:this,id:e.id,iterator:e.iterator,options:e.options})}async read(e,t){try{for await(let{eventType:n,value:r}of this.parse(e,t))switch(n){case`shared-strings`:this.emit(n,r);break;case`worksheet`:this.emit(n,r),await r.read();break;case`hyperlinks`:this.emit(n,r);break}this.emit(`end`),this.emit(`finished`)}catch(e){this.emit(`error`,e)}}async*[Symbol.asyncIterator](){for await(let{eventType:e,value:t}of this.parse())e===`worksheet`&&(yield t)}async*parse(e,t){t&&(this.options=t);let n=this.stream=this._getStream(e||this.input),r=[];try{for await(let e of this._parseEntries(n))if(e.eventType===`waiting-worksheet`){let t=await this._storeWaitingWorksheet(e.sheetNo,e.entry);r.push(t)}else yield e;yield*this._processWaitingWorksheets(r)}catch(e){throw this._cleanupWaitingWorksheets(r),e}}_emitEntry(e){this.options.entries===`emit`&&this.emit(`entry`,e)}async _parseRels(e){this.workbookRels=await new I().parseStream(hm(e)),this._workbookRelIdByTarget=Object.create(null);for(let e of this.workbookRels??[])e?.Target&&e?.Id&&(this._workbookRelIdByTarget[e.Target]=e.Id)}async _parseWorkbook(e){this._emitEntry({type:`workbook`});let t=new Na;this.model=await t.parseStream(hm(e)),this.properties=t.map?.workbookPr,this._sheetByRelId=Object.create(null);for(let e of this.model?.sheets??[])this._sheetByRelId[e.rId]=e}async*_parseSharedStrings(e){switch(this._emitEntry({type:`shared-strings`}),this.options.sharedStrings){case`cache`:this.sharedStrings=[];break;case`emit`:break;default:return}let t=null,n=[],r=0,i=null,a=!1;for await(let o of Sr(hm(e)))for(let{eventType:e,value:s}of o)if(e===`opentag`){let e=s;switch(e.name){case`b`:i||={},i.bold=!0;break;case`charset`:i||={},i.charset=parseInt(e.attributes.charset,10);break;case`color`:i||={},i.color={},e.attributes.rgb&&(i.color.argb=e.attributes.rgb),e.attributes.val&&(i.color.argb=e.attributes.val),e.attributes.theme&&(i.color.theme=e.attributes.theme);break;case`family`:i||={},i.family=parseInt(e.attributes.val,10);break;case`i`:i||={},i.italic=!0;break;case`outline`:i||={},i.outline=!0;break;case`rFont`:i||={},i.name=e.attributes.val;break;case`r`:a=!0;break;case`si`:i=null,n=[],t=null,a=!1;break;case`sz`:i||={},i.size=parseInt(e.attributes.val,10);break;case`strike`:i||={},i.strike=!0;break;case`t`:t=null;break;case`u`:i||={},i.underline=!0;break;case`vertAlign`:i||={},i.vertAlign=e.attributes.val;break}}else if(e===`text`)t=t?t+s:s;else if(e===`closetag`)switch(s.name){case`t`:t!=null&&(t=ht(t));break;case`r`:a&&(n.push({font:i,text:t}),i=null,t=null);break;case`si`:this.options.sharedStrings===`cache`?this.sharedStrings.push(n.length?{richText:n}:t??``):this.options.sharedStrings===`emit`&&(yield{index:r++,text:n.length?{richText:n}:t??``}),n=[],i=null,t=null,a=!1;break}}async _parseStyles(e){this._emitEntry({type:`styles`}),this.options.styles===`cache`&&(this.styles=new Zr,await this.styles.parseStream(hm(e)))}*_parseWorksheet(e,t){this._emitEntry({type:`worksheet`,id:t});let n=parseInt(t,10),r=this._createWorksheetReader({id:n,iterator:e,options:this.options});r.sheetNo=n;let i=this._workbookRelIdByTarget?.[Hi(t)],a=i?this._sheetByRelId?.[i]:void 0;a&&(r.id=a.id,r.name=a.name,r.state=a.state),this.options.worksheets===`emit`&&(yield{eventType:`worksheet`,value:r})}async*_parseHyperlinks(e,t){this._emitEntry({type:`hyperlinks`,id:t});let n=this._createHyperlinkReader({id:parseInt(t,10),iterator:e,options:this.options});if(this.options.hyperlinks===`cache`){this._hyperlinkReadersBySheetNo||=Object.create(null),this._hyperlinkReadersBySheetNo[t]=n;let e=n.read;typeof e==`function`&&await e.call(n);return}this.options.hyperlinks===`emit`&&(yield{eventType:`hyperlinks`,value:n})}async*_parseEntries(e){let t=mm({forceStream:!0});e.on(`error`,e=>t.emit(`error`,e)),e.pipe(t);for await(let e of hm(t)){let t,n=bi(e.path);switch(n){case L.rootRels:break;case L.xlWorkbookRels:await this._parseRels(e);break;case L.xlWorkbook:await this._parseWorkbook(e);break;case L.xlSharedStrings:for await(let t of this._parseSharedStrings(e))yield{eventType:`shared-strings`,value:t};break;case L.xlStyles:await this._parseStyles(e);break;default:if(t=xi(n)?.toString(),t)if(this.workbookRels&&this.model&&(this.options.sharedStrings!==`cache`||this.sharedStrings)){yield*this._parseWorksheet(hm(e),t);continue}else{yield{eventType:`waiting-worksheet`,sheetNo:t,entry:e};continue}if(t=Si(n)?.toString(),t){yield*this._parseHyperlinks(hm(e),t);continue}break}e.autodrain()}}},ym=class extends vm{constructor(e,t={}){super(e,t,gm,_m)}async _storeWaitingWorksheet(e,t){let n=[],r=new TextEncoder;for await(let e of hm(t))e instanceof Uint8Array?n.push(e):typeof e==`string`&&n.push(r.encode(e));return{sheetNo:e,data:n}}async*_processWaitingWorksheets(e){for(let t of e){let e=(async function*(){for(let e of t.data)yield e})();yield*this._parseWorksheet(e,t.sheetNo)}}};let Q=Array.from({length:60},(e,t)=>t<10?`0${t}`:`${t}`),$=(e,t)=>(e.charCodeAt(t)-48)*10+e.charCodeAt(t+1)-48|0,bm=(e,t)=>(e.charCodeAt(t)-48)*1e3+(e.charCodeAt(t+1)-48)*100+(e.charCodeAt(t+2)-48)*10+e.charCodeAt(t+3)-48|0,xm=[0,31,29,31,30,31,30,31,31,30,31,30,31];function Sm(e,t,n){if(t<1||t>12||n<1||n>xm[t])return null;let r=new Date(e,t-1,n);return r.getMonth()===t-1?r:null}function Cm(e,t,n,r,i,a){return t<1||t>12||n<1||n>xm[t]||r>23||i>59||a>59?null:new Date(e,t-1,n,r,i,a)}function wm(e){return e.charCodeAt(4)!==45||e.charCodeAt(7)!==45?null:Sm(bm(e,0),$(e,5),$(e,8))}function Tm(e){return e.charCodeAt(4)!==45||e.charCodeAt(7)!==45||e.charCodeAt(10)!==84||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:Cm(bm(e,0),$(e,5),$(e,8),$(e,11),$(e,14),$(e,17))}function Em(e){return e.charCodeAt(4)!==45||e.charCodeAt(7)!==45||e.charCodeAt(10)!==32||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:Cm(bm(e,0),$(e,5),$(e,8),$(e,11),$(e,14),$(e,17))}function Dm(e){if(e.charCodeAt(19)!==90)return null;let t=new Date(e);return isNaN(t.getTime())?null:t}function Om(e){if(e.charCodeAt(19)!==46||e.charCodeAt(23)!==90)return null;let t=new Date(e);return isNaN(t.getTime())?null:t}function km(e){let t=e.charCodeAt(19);if(t!==43&&t!==45)return null;let n=new Date(e);return isNaN(n.getTime())?null:n}function Am(e){if(e.charCodeAt(19)!==46)return null;let t=e.charCodeAt(23);if(t!==43&&t!==45)return null;let n=new Date(e);return isNaN(n.getTime())?null:n}function jm(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t?null:Sm(bm(e,6),$(e,0),$(e,3))}function Mm(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t?null:Sm(bm(e,6),$(e,3),$(e,0))}function Nm(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t||e.charCodeAt(10)!==32||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:Cm(bm(e,6),$(e,0),$(e,3),$(e,11),$(e,14),$(e,17))}function Pm(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t||e.charCodeAt(10)!==32||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:Cm(bm(e,6),$(e,3),$(e,0),$(e,11),$(e,14),$(e,17))}let Fm={"YYYY-MM-DD":wm,"YYYY-MM-DD[T]HH:mm:ss":Tm,"YYYY-MM-DD HH:mm:ss":Em,"YYYY-MM-DD[T]HH:mm:ssZ":e=>e.length===20?Dm(e):e.length===25?km(e):null,"YYYY-MM-DD[T]HH:mm:ss.SSSZ":e=>e.length===24?Om(e):e.length===29?Am(e):null,"MM-DD-YYYY":jm,"MM-DD-YYYY HH:mm:ss":Nm,"MM/DD/YYYY HH:mm:ss":Nm,"DD-MM-YYYY":Mm,"DD-MM-YYYY HH:mm:ss":Pm,"DD/MM/YYYY HH:mm:ss":Pm},Im=[[10,[wm]],[19,[Tm,Em]],[20,[Dm]],[24,[Om]],[25,[km]],[29,[Am]]];var Lm=class e{constructor(e){this.parse=e=>{if(!e)return null;let t=e.trim();if(!t)return null;if(this.single)return this.fn0(t);for(let e=0,n=this.fns.length;e<n;e++){let n=this.fns[e](t);if(n)return n}return null},this.fns=e,this.single=e.length===1,this.fn0=e[0]}static create(t){return new e(t.map(e=>Fm[e]).filter(Boolean))}static iso(){let t=[];for(let[,e]of Im)t.push(...e);return new e(t)}parseAll(e){let t=e.length,n=Array(t),r=this.parse;for(let i=0;i<t;i++)n[i]=r(e[i]);return n}parseValid(e){let t=[],n=this.parse;for(let r=0,i=e.length;r<i;r++){let i=n(e[r]);i&&t.push(i)}return t}};function Rm(e){let t=-e.getTimezoneOffset(),n=t>=0?`+`:`-`,r=Math.abs(t)/60|0,i=Math.abs(t)%60;return`${n}${Q[r]}:${Q[i]}`}var zm=class e{constructor(e){this.format=e=>this.fn(e),this.fn=e}static iso(t=!1){return t?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();if(t!==t)return``;let n=e.getUTCFullYear(),r=e.getUTCMonth()+1,i=e.getUTCDate(),a=e.getUTCHours(),o=e.getUTCMinutes(),s=e.getUTCSeconds(),c=e.getUTCMilliseconds();return`${n}-${Q[r]}-${Q[i]}T${Q[a]}:${Q[o]}:${Q[s]}.${c<10?`00`+c:c<100?`0`+c:c}Z`}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();if(t!==t)return``;let n=e.getFullYear(),r=e.getMonth()+1,i=e.getDate(),a=e.getHours(),o=e.getMinutes(),s=e.getSeconds(),c=e.getMilliseconds();return`${n}-${Q[r]}-${Q[i]}T${Q[a]}:${Q[o]}:${Q[s]}.${c<10?`00`+c:c<100?`0`+c:c}${Rm(e)}`})}static create(t,n){let r=n?.utc??!1;if(t===`YYYY-MM-DD`)return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getUTCFullYear()}-${Q[e.getUTCMonth()+1]}-${Q[e.getUTCDate()]}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getFullYear()}-${Q[e.getMonth()+1]}-${Q[e.getDate()]}`:``});if(t===`YYYY-MM-DD HH:mm:ss`)return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getUTCFullYear()}-${Q[e.getUTCMonth()+1]}-${Q[e.getUTCDate()]} ${Q[e.getUTCHours()]}:${Q[e.getUTCMinutes()]}:${Q[e.getUTCSeconds()]}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getFullYear()}-${Q[e.getMonth()+1]}-${Q[e.getDate()]} ${Q[e.getHours()]}:${Q[e.getMinutes()]}:${Q[e.getSeconds()]}`:``});if(t===`MM-DD-YYYY`||t===`MM/DD/YYYY`){let n=t.charAt(2);return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${Q[e.getUTCMonth()+1]}${n}${Q[e.getUTCDate()]}${n}${e.getUTCFullYear()}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${Q[e.getMonth()+1]}${n}${Q[e.getDate()]}${n}${e.getFullYear()}`:``})}if(t===`DD-MM-YYYY`||t===`DD/MM/YYYY`){let n=t.charAt(2);return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${Q[e.getUTCDate()]}${n}${Q[e.getUTCMonth()+1]}${n}${e.getUTCFullYear()}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${Q[e.getDate()]}${n}${Q[e.getMonth()+1]}${n}${e.getFullYear()}`:``})}return e.createGeneric(t,r)}static createGeneric(t,n){let r=[],i=[],a=0;for(;a<t.length;)if(t[a]===`[`){let e=t.indexOf(`]`,a+1);e===-1?(i.push(t[a]),a++):(r.push(t.slice(a+1,e)),i.push(`\x00${r.length-1}\x00`),a=e+1)}else i.push(t[a]),a++;let o=i.join(``),s=o.includes(`YYYY`),c=o.includes(`SSS`),l=o.includes(`MM`),u=o.includes(`DD`),d=o.includes(`HH`),f=o.includes(`mm`),p=o.includes(`ss`),m=o.includes(`Z`);return new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();if(t!==t)return``;let i=o;if(s&&(i=i.replace(/YYYY/g,String(n?e.getUTCFullYear():e.getFullYear()))),c){let t=n?e.getUTCMilliseconds():e.getMilliseconds();i=i.replace(/SSS/g,t<10?`00${t}`:t<100?`0${t}`:String(t))}return l&&(i=i.replace(/MM/g,Q[n?e.getUTCMonth()+1:e.getMonth()+1])),u&&(i=i.replace(/DD/g,Q[n?e.getUTCDate():e.getDate()])),d&&(i=i.replace(/HH/g,Q[n?e.getUTCHours():e.getHours()])),f&&(i=i.replace(/mm/g,Q[n?e.getUTCMinutes():e.getMinutes()])),p&&(i=i.replace(/ss/g,Q[n?e.getUTCSeconds():e.getSeconds()])),m&&(i=i.replace(/Z/g,n?`Z`:Rm(e))),r.length&&(i=i.replace(/\x00(\d+)\x00/g,(e,t)=>r[+t])),i})}formatAll(e){let t=e.length,n=Array(t),r=this.fn;for(let i=0;i<t;i++)n[i]=r(e[i]);return n}};function Bm(){return Object.keys(Fm)}function Vm(e){if(!Array.isArray(e)||e.length===0)return!1;let t=e[0];return Array.isArray(t)&&t.length===2&&typeof t[0]==`string`}function Hm(e){let t=Object.create(null);for(let[n,r]of e)n!==`__proto__`&&(t[n]=r);return t}function Um(e){return e.map(([,e])=>e)}function Wm(e){return e.map(([e])=>e)}function Gm(e,t){for(let[n,r]of e)if(n===t)return r}function Km(e,t){if(t.length<=10)return t.map(t=>Gm(e,t));let n=Hm(e);return t.map(e=>n[e])}function qm(e,t){return Vm(e)?t?Km(e,t):Um(e):Array.isArray(e)?e:typeof e==`object`&&e?t?t.map(t=>e[t]):Object.values(e):[e]}function Jm(e){return Vm(e)?Wm(e):!Array.isArray(e)&&typeof e==`object`&&e?Object.keys(e):[]}function Ym(e){return Xm(e).headers}function Xm(e){let t=new Map,n=new Set,r=new Set,i=[],a={},o=!1,s=0;for(let t of e)t!=null&&t!==``&&r.add(t);for(let c=0;c<e.length;c++){let l=e[c];if(l==null){i.push(l);continue}if(l===``){let e=`_column_${c}`;for(;n.has(e)||r.has(e);)e=`_column_${c}_${s++}`;n.add(e),i.push(e),a[e]=``,o=!0;continue}if(!n.has(l)){n.add(l),t.set(l,1),i.push(l);continue}let u=t.get(l)??1,d=`${l}_${u}`;for(;n.has(d)||r.has(d);)u++,d=`${l}_${u}`;t.set(l,u+1),n.add(d),i.push(d),a[d]=l,o=!0}return{headers:i,renamedHeaders:o?a:null}}function Zm(e){return!e||e.length===0?null:{keys:e.map(e=>typeof e==`string`?e:e.key),headers:e.map(e=>typeof e==`string`?e:e.header??e.key)}}let Qm=/\S/;function $m(e,t){if(!t)return!1;if(t===`greedy`){for(let t of e)if(Qm.test(t))return!1}else for(let t of e)if(t!==``)return!1;return!0}function eh(e){return $m(e,!0)}var th=class extends t{constructor(...e){super(...e),this.name=`CsvError`}};function nh(e,t,n){let{headers:r,groupColumnsByName:i=!1}=t;if(n!==null&&Array.isArray(r))return null;let a,o;if(typeof r==`function`){if(a=r(e),a.length!==e.length)throw new th(`Header function returned ${a.length} headers but row has ${e.length} columns. The header function must return an array with the same length as the input row.`);o=!0}else if(Array.isArray(r))a=r,o=!1;else if(r===!0)a=e,o=!0;else return null;let{headers:s,renamedHeaders:c}=Xm(a);return{headers:s,originalHeaders:i?a.map(e=>e==null?null:String(e)):null,renamedHeaders:c,skipCurrentRow:o}}function rh(e,t,n){let{columnLess:r,columnMore:i}=n,a=e.length;if(a===t)return{isValid:!0,modified:!1};if(a>t)switch(i){case`error`:return{isValid:!1,errorCode:`TooManyFields`,reason:`expected ${t} columns, got ${a}`,modified:!1};case`truncate`:return e.length=t,{isValid:!0,errorCode:`TooManyFields`,modified:!0};case`keep`:return{isValid:!0,errorCode:`TooManyFields`,modified:!0,extras:e.splice(t)};default:{let e=i;throw Error(`Unknown columnMore strategy: ${e}`)}}switch(r){case`error`:return{isValid:!1,errorCode:`TooFewFields`,reason:`expected ${t} columns, got ${a}`,modified:!1};case`pad`:for(;e.length<t;)e.push(``);return{isValid:!0,errorCode:`TooFewFields`,modified:!0};default:{let e=r;throw Error(`Unknown columnLess strategy: ${e}`)}}}function ih(e){return e?(t,n)=>{try{e(t,n)}catch{}}:null}function ah(e,t){let n=Object.create(null);for(let r=0;r<t.length;r++){let i=t[r];i!=null&&i!==`__proto__`&&(n[i]=e[r]??``)}return n}function oh(e,t,n,r){return r&&n?sh(e,n):ah(e,t)}function sh(e,t){let n=Object.create(null);for(let r=0;r<t.length;r++){let i=t[r];if(i!=null&&i!==`__proto__`){let t=e[r]??``;if(i in n){let e=n[i];Array.isArray(e)?e.push(t):n[i]=[e,t]}else n[i]=t}}return n}function ch(e){return e.filter(e=>e!=null)}function lh(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function uh(e){return e===!1||e===null?{enabled:!1,char:``}:{enabled:!0,char:e??`"`}}function dh(e,t){return e===!1||e===null?{enabled:!1,char:``}:{enabled:!0,char:e??t}}let fh=[`,`,`;`,` `,`|`],ph=new Set([`=`,`+`,`-`,`@`,` `,`\r`,`
394
- `,`=`,`+`,`-`,`@`]);function mh(e){return e.charCodeAt(0)===65279?e.slice(1):e}function hh(e){return e.length>0&&ph.has(e[0])}function gh(e,t=`"`){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i===t){if(n&&e[r+1]===t){r++;continue}n=!n;continue}if(!n){if(i===`\r`)return e[r+1]===`
393
+ `],{type:`text/javascript`});return cm=URL.createObjectURL(t),cm}var um=class extends Zf{constructor(e){super({write:(e,t,n)=>{this._doWrite(e,n)},final:e=>{this._doClose(e)}}),this._nextId=1,this._pendingAcks=new Map,this._workerClosed=!1,this._junkError=!1,this._terminated=!1;let t=lm(e);this.worker=new Worker(t),this.worker.onmessage=e=>{let t=e.data;if(!(!t||typeof t.t!=`string`)){if(t.t===`data`){let e=t.chunk;this.push(e);return}if(t.t===`end`){this.push(null),this._terminateWorker();return}if(t.t===`aborted`){this._terminateWorker();return}if(t.t===`ack`){let e=t.id,n=this._pendingAcks.get(e);n&&(this._pendingAcks.delete(e),n());return}if(t.t===`error`){let e=typeof t.message==`string`?t.message:`Worker inflate error`;if(e.includes(`Junk`)||e.includes(`junk`)){this._junkError=!0,this.push(null),this._terminateWorker(),this._settlePendingAcks();return}let n=Error(e);this._settlePendingAcks(n),this.emit(`error`,n),this._terminateWorker();return}}},this.worker.onerror=e=>{let t=Error(e.message??`Worker error`);this._settlePendingAcks(t),this.emit(`error`,t),this._terminateWorker()}}_settlePendingAcks(e){if(this._pendingAcks.size!==0){for(let t of this._pendingAcks.values())t(e);this._pendingAcks.clear()}}_terminateWorker(){if(!this._terminated){this._terminated=!0;try{this.worker.terminate()}catch{}}}_doWrite(e,t){if(this._workerClosed||this._junkError){t();return}let n=this._nextId++;this._pendingAcks.set(n,t);let r=e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e:e.slice();this.worker.postMessage({t:`write`,id:n,chunk:r},[r.buffer])}_doClose(e){if(this._workerClosed){e();return}this._workerClosed=!0,this.worker.postMessage({t:`close`}),e()}destroy(e){if(!this._workerClosed){this._workerClosed=!0;try{this.worker.postMessage({t:`abort`})}catch{}}return this._terminateWorker(),super.destroy(e??void 0)}},dm=class extends Zf{constructor(){super({write:(e,t,n)=>{if(this._finished){n(Error(`write after end`));return}this.chunks.push(e),n()},final:e=>{this._decompress(e)}}),this.chunks=[],this._finished=!1}_decompress(e){try{let t=Pc(O(this.chunks));this.push(t),this.push(null),this._finished=!0,e()}catch(t){e(a(t))}}destroy(e){return this._finished=!0,this.chunks=[],super.destroy(e??void 0)}};function fm(){return Zc()?new sm:new dm}let pm=Mp;function mm(e){return class extends Zf{constructor(t={}){super({objectMode:!0,write:(e,t,n)=>{this._handleWrite(e,n)},final:e=>{this.finished=!0,this._maybeReleaseWriteCallback(),this._wakeUp(),this.emit(`data-available`),this.emit(`chunk`,!1),this._parsingDone.then(()=>e()).catch(e)}}),this._buffer=new Gc,this.finished=!1,this._driverState={},this._parsingDone=Promise.resolve(),this._opts=t;let n=Math.max(64*1024,t.inputHighWaterMarkBytes??2*1024*1024),r=Math.max(32*1024,t.inputLowWaterMarkBytes??Math.floor(n/4));this._inputHighWaterMarkBytes=n,this._inputLowWaterMarkBytes=Math.min(r,n);let i={pull:e=>this.pull(e),pullUntil:(e,t)=>this.pullUntil(e,t),stream:e=>this.stream(e),streamUntilDataDescriptor:()=>this._streamUntilDataDescriptor(),setDone:()=>{this.push(null)}},a={emitEntry:e=>{this.emit(`entry`,e)},pushEntry:e=>{this.push(e)},pushEntryIfPiped:e=>{},emitCrxHeader:e=>{this.crxHeader=e,this.emit(`crx-header`,e)},emitError:e=>{if(this.__emittedError=e,this._writeCb){let t=this._writeCb;this._writeCb=void 0,t(e)}this.emit(`error`,e)},emitClose:()=>{this.emit(`close`)}};queueMicrotask(()=>{this._parsingDone=im(this._opts,i,a,()=>{if(this._opts.useWorkerInflate&&typeof Worker<`u`&&Zc())try{return new um(this._opts.workerInflateUrl)}catch{return e()}return e()},this._driverState),this._parsingDone.catch(e=>{(!this.__emittedError||this.__emittedError!==e)&&(this.__emittedError=e,this.emit(`error`,e)),this.emit(`close`)})})}_handleWrite(e,t){this._buffer.append(e),this._buffer.length>=this._inputHighWaterMarkBytes?this._writeCb=t:t(),this._wakeUp(),this.emit(`data-available`),this.emit(`chunk`)}get buffer(){return this._buffer.view()}set buffer(e){this._buffer.reset(e)}_wakeUp(){if(this._pendingResolve){let e=this._pendingResolve;this._pendingResolve=void 0,this._pendingDataPromise=void 0,e()}}_maybeReleaseWriteCallback(){if(!this._writeCb||this._buffer.length>this._inputLowWaterMarkBytes)return;let e=this._writeCb;this._writeCb=void 0,e()}_waitForData(){return this._pendingDataPromise||=new Promise(e=>{this._pendingResolve=e}),this._pendingDataPromise}async _pullInternal(e){if(e===0)return G;let t=e,n=null,r=null,i=e=>{if(e.length!==0){if(!n){n=e;return}if(!r){r=[n,e];return}r.push(e)}};for(;t>0;){for(;this._buffer.length===0;){if(this.finished)throw Error(`FILE_ENDED`);await this._waitForData()}let e=Math.min(t,this._buffer.length);i(this._buffer.read(e)),t-=e,this._buffer.length===0&&this._maybeReleaseWriteCallback()}return this._maybeReleaseWriteCallback(),n?r?O(r):n:G}async _pullUntilInternal(e,t=!1){let n=null,r=null,i=new Ep(e),a=e.length,o=e=>{if(e.length!==0){if(!n){n=e;return}if(!r){r=[n,e];return}r.push(e)}};for(;;){let e=this._buffer.length,s=i.find(this._buffer);if(s!==-1){this.match=s;let e=s+(t?a:0);return e>0&&(o(this._buffer.read(e)),this._maybeReleaseWriteCallback()),n?r?O(r):n:G}if(i.onNoMatch(e),this.finished)throw Error(`FILE_ENDED`);let c=this._buffer.length-a;c>0&&(o(this._buffer.read(c)),i.onConsume(c),this._maybeReleaseWriteCallback()),await this._waitForData()}}_streamFixedLength(e){let t=new $f({highWaterMark:em}),n=e,r=!1,i=!1,a=()=>{i=!1,o()},o=()=>{if(!r&&!i){for(;n>0&&this._buffer.length>0;){let e=Math.min(n,this._buffer.length),r=this._buffer.read(e);n-=e;let o=t.write(r);if(this._maybeReleaseWriteCallback(),!o){i=!0,t.once(`drain`,a);return}}n===0?(r=!0,this.removeListener(`data-available`,o),t.end()):this.finished&&(r=!0,this.removeListener(`data-available`,o),t.destroy(Error(`FILE_ENDED`)))}};return this.on(`data-available`,o),queueMicrotask(()=>o()),t}_streamUntilPattern(e,t=!1){let n=new $f({highWaterMark:em}),r=!1,i=e.length,a=new Ep(e),o=!1,s=()=>{o=!1,c()},c=()=>{if(!(r||o))for(;!(this._buffer.length<=0);){let e=this._buffer.length,l=a.find(this._buffer);if(l!==-1){this.match=l;let e=t?l+i:l;if(e>0){let t=n.write(this._buffer.read(e));if(a.onConsume(e),this._maybeReleaseWriteCallback(),!t){o=!0,n.once(`drain`,s);return}}r=!0,this.removeListener(`data-available`,c),n.end();return}if(a.onNoMatch(e),this.finished){r=!0,this.removeListener(`data-available`,c),n.destroy(Error(`FILE_ENDED`));return}let u=e-i;if(u<=0){this._buffer.length<=i&&this._maybeReleaseWriteCallback();break}let d=n.write(this._buffer.read(u));if(a.onConsume(u),this._maybeReleaseWriteCallback(),!d){o=!0,n.once(`drain`,s);return}}};return this.on(`data-available`,c),queueMicrotask(()=>c()),n}stream(e,t){return typeof e==`number`?this._streamFixedLength(e):this._streamUntilPattern(e,t??!1)}pull(e,t){if(e===0)return Promise.resolve(G);if(typeof e==`number`){if(this.finished&&this._buffer.length<e)return Promise.reject(Error(`FILE_ENDED`));if(this._buffer.length>=e){let t=this._buffer.read(e);return this._maybeReleaseWriteCallback(),Promise.resolve(t)}return this._pullInternal(e)}return this.finished?Promise.reject(Error(`FILE_ENDED`)):this._pullUntilInternal(e,t??!1)}pullUntil(e,t){return this.pull(e,t)}_streamUntilDataDescriptor(){return rm({source:{getLength:()=>this._buffer.length,read:e=>this._buffer.read(e),peekChunks:e=>this._buffer.peekChunks(e),discard:e=>this._buffer.discard(e),indexOfPattern:(e,t)=>this._buffer.indexOfPattern(e,t),peekUint32LE:e=>this._buffer.peekUint32LE(e),isFinished:()=>this.finished,onDataAvailable:e=>(this.on(`data-available`,e),()=>this.removeListener(`data-available`,e)),maybeReleaseWriteCallback:()=>this._maybeReleaseWriteCallback()},dataDescriptorSignature:pm})}promise(){return new Promise((e,t)=>{this.on(`finish`,e),this.on(`end`,e),this.on(`error`,t)})}}}let hm=mm(fm);var gm=class extends hm{};function _m(e){return new gm(e)}async function*vm(e){let t=[],n=null,r=e=>{t.push(e),n&&=(n(),null)};e.on(`data`,r);let i=!1,a=()=>{i=!0,n&&=(n(),null)};e.on(`end`,a);let o=!1,s=e=>{o=e,n&&=(n(),null)};e.on(`error`,s);try{for(;!i||t.length>0;)if(t.length===0?(e.resume(),await new Promise(e=>{n=e})):(e.pause(),yield t.shift()),o)throw o}finally{e.removeListener(`data`,r),e.removeListener(`end`,a),e.removeListener(`error`,s)}}var ym=class extends W{constructor({workbook:e,id:t,iterator:n,options:r}){super(),this.workbook=e,this.id=t,this.sheetNo=typeof t==`number`?t:parseInt(String(t),10),this.iterator=n,this.options=r||{},this.name=`Sheet${this.id}`,this._columns=[],this._keys=Object.create(null),this._dimensions=new C}destroy(){throw new b(`destroy`,`Invalid operation for a streaming reader`)}get dimensions(){return this._dimensions}get columns(){return this._columns}getColumn(e){if(typeof e==`string`){let t=this._keys[e];if(t)return t;e=S.l2n(e)}if(e>this._columns.length){let t=this._columns.length+1;for(;t<=e;)this._columns.push(new Be(this,t++))}return this._columns[e-1]}getColumnKey(e){return this._keys[e]}setColumnKey(e,t){this._keys[e]=t}deleteColumnKey(e){delete this._keys[e]}eachColumnKey(e){let t=this._keys;for(let n in t)e(t[n],n)}async read(){try{for await(let e of this.parse())for(let t=0;t<e.length;t++){let n=e[t];this.emit(n.eventType,n.value)}this.emit(`finished`)}catch(e){this.emit(`error`,e)}}async*[Symbol.asyncIterator](){for await(let e of this.parse())for(let t=0;t<e.length;t++){let n=e[t];n.eventType===`row`&&(yield n.value)}}async*parse(){let{iterator:e,options:t}=this,n=!1,r=!1,i=null;switch(t.worksheets){case`emit`:n=!0;break;case`prep`:break;default:break}switch(t.hyperlinks){case`emit`:r=!0;break;case`cache`:this.hyperlinks=i=Object.create(null);break;default:break}if(!n&&!r&&!i)return;let a=r||i!==null,{sharedStrings:o,styles:s,properties:c}=this.workbook,l=!1,u=!1,d=!1,f=null,p=null,m=null,h=null;for await(let t of Sr(e)){let e=null;for(let g=0;g<t.length;g++){let _=t[g],v=_.eventType,y=_.value;if(v===`opentag`){let t=y;if(n)switch(t.name){case`cols`:l=!0,f=[];break;case`sheetData`:u=!0;break;case`col`:l&&f.push({min:parseInt(t.attributes.min,10),max:parseInt(t.attributes.max,10),width:parseFloat(t.attributes.width),styleId:parseInt(t.attributes.style??`0`,10)});break;case`row`:if(u){let e=parseInt(t.attributes.r,10);if(p=new ze(this,e),t.attributes.ht&&(p.height=parseFloat(t.attributes.ht)),t.attributes.customHeight===`1`&&(p.customHeight=!0),t.attributes.s!==void 0){let e=parseInt(t.attributes.s,10),n=s.getStyleModel(e);n&&(p.style=n)}}break;case`c`:if(p){let e=t.attributes.s;m={ref:t.attributes.r,s:e===void 0?void 0:parseInt(e,10),t:t.attributes.t}}break;case`f`:m&&(h=m.f={text:``});break;case`v`:m&&(h=m.v={text:``});break;case`is`:case`t`:m&&(h=m.v={text:``});break;case`mergeCell`:break;default:break}if(a)switch(t.name){case`hyperlinks`:d=!0;break;case`hyperlink`:if(d){let n={ref:t.attributes.ref,rId:t.attributes[`r:id`]};r?(e||=[]).push({eventType:`hyperlink`,value:n}):i[n.ref]=n}break;default:break}}else if(v===`text`)n&&h&&(h.text+=y);else if(v===`closetag`){let t=y;if(n)switch(t.name){case`cols`:l=!1,this._columns=Be.fromModel(f);break;case`sheetData`:u=!1;break;case`row`:p&&(this._dimensions.expandRow({number:p.number,dimensions:p.dimensions??void 0}),(e||=[]).push({eventType:`row`,value:p})),p=null;break;case`c`:if(p&&m){let e=S.decodeAddress(m.ref),t=p.getCell(e.col);if(m.s!==void 0){let e=s.getStyleModel(m.s);e&&(t.style=e)}if(m.f){let e={formula:m.f.text};m.v&&(m.t===`str`?e.result=bt(m.v.text):e.result=parseFloat(m.v.text)),t.value=e}else if(m.v)switch(m.t){case`s`:{let e=parseInt(m.v.text,10);o?t.value=o[e]:t.value={sharedString:e};break}case`inlineStr`:t.value=mt(bt(m.v.text));break;case`str`:t.value=bt(m.v.text);break;case`e`:t.value={error:m.v.text};break;case`b`:t.value=parseInt(m.v.text,10)!==0;break;default:{let e=typeof t.numFmt==`string`?t.numFmt:t.numFmt?.formatCode;e&&Et(e)?t.value=dt(parseFloat(m.v.text),c?.model?.date1904):t.value=parseFloat(m.v.text);break}}if(i){let e=i[m.ref];e&&(t.text=t.value,t.value=void 0,t.hyperlink=e)}m=null,h=null}break;default:break}if(a)switch(t.name){case`hyperlinks`:d=!1;break;default:break}}}e&&e.length>0&&(yield e)}}},bm=class extends W{constructor({workbook:e,id:t,iterator:n,options:r}){super(),this._hyperlinkCount=0,this.workbook=e,this.id=t,this.iterator=n,this.options=r}get count(){return this.hyperlinks?this._hyperlinkCount:0}each(e){let t=this.hyperlinks;if(t)for(let n in t)e(t[n],n)}async read(){let{iterator:e}=this,t=this.options.hyperlinks,n=t===`emit`,r=t===`cache`,i=null;if(r&&(this._hyperlinkCount=0,this.hyperlinks=i=Object.create(null)),!n&&!r){this.emit(`finished`);return}try{for await(let t of Sr(e))for(let{eventType:e,value:r}of t){if(e!==`opentag`)continue;let t=r;if(t.name!==`Relationship`)continue;let a=t.attributes;if(a.Type!==z.Hyperlink)continue;let o={type:T.RelationshipType.Hyperlink,rId:a.Id,target:a.Target,targetMode:a.TargetMode};if(n){this.emit(`hyperlink`,o);continue}let s=o.rId;i&&i[s]===void 0&&(this._hyperlinkCount+=1),i[s]=o}this.emit(`finished`)}catch(e){this.emit(`error`,e)}}},xm=class extends W{getHyperlinkReader(e){return this._hyperlinkReadersBySheetNo?.[String(e)]}getHyperlink(e,t){return this.getHyperlinkReader(e)?.hyperlinks?.[t]}getHyperlinkTarget(e,t){return this.getHyperlink(e,t)?.target}constructor(e,t,n,r){super(),this.input=e,this.WorksheetReaderClass=n,this.HyperlinkReaderClass=r,this.options={worksheets:`emit`,sharedStrings:`cache`,hyperlinks:`ignore`,styles:`ignore`,entries:`ignore`,...t},this.styles=new Zr,this.styles.init()}_getStream(e){if(e instanceof q)return e;if(e&&typeof e==`object`&&typeof e.getReader==`function`){let t=q.fromWeb;if(typeof t==`function`)return t(e);try{return new q({stream:e})}catch{throw new y(`<ReadableStream>`,`read`,`Could not recognise input`)}}let t=e;if(t instanceof ArrayBuffer&&(t=new Uint8Array(t)),t instanceof Uint8Array)return q.from([t]);throw new y(String(e),`read`,`Could not recognise input`)}_cleanupWaitingWorksheets(e){for(let t of e)t&&typeof t.cleanup==`function`&&t.cleanup()}_createWorksheetReader(e){return new this.WorksheetReaderClass({workbook:this,id:e.id,iterator:e.iterator,options:e.options})}_createHyperlinkReader(e){return new this.HyperlinkReaderClass({workbook:this,id:e.id,iterator:e.iterator,options:e.options})}async read(e,t){try{for await(let{eventType:n,value:r}of this.parse(e,t))switch(n){case`shared-strings`:this.emit(n,r);break;case`worksheet`:this.emit(n,r),await r.read();break;case`hyperlinks`:this.emit(n,r);break}this.emit(`end`),this.emit(`finished`)}catch(e){this.emit(`error`,e)}}async*[Symbol.asyncIterator](){for await(let{eventType:e,value:t}of this.parse())e===`worksheet`&&(yield t)}async*parse(e,t){t&&(this.options=t);let n=this.stream=this._getStream(e||this.input),r=[];try{for await(let e of this._parseEntries(n))if(e.eventType===`waiting-worksheet`){let t=await this._storeWaitingWorksheet(e.sheetNo,e.entry);r.push(t)}else yield e;yield*this._processWaitingWorksheets(r)}catch(e){throw this._cleanupWaitingWorksheets(r),e}}_emitEntry(e){this.options.entries===`emit`&&this.emit(`entry`,e)}async _parseRels(e){this.workbookRels=await new I().parseStream(vm(e)),this._workbookRelIdByTarget=Object.create(null);for(let e of this.workbookRels??[])e?.Target&&e?.Id&&(this._workbookRelIdByTarget[e.Target]=e.Id)}async _parseWorkbook(e){this._emitEntry({type:`workbook`});let t=new Na;this.model=await t.parseStream(vm(e)),this.properties=t.map?.workbookPr,this._sheetByRelId=Object.create(null);for(let e of this.model?.sheets??[])this._sheetByRelId[e.rId]=e}async*_parseSharedStrings(e){switch(this._emitEntry({type:`shared-strings`}),this.options.sharedStrings){case`cache`:this.sharedStrings=[];break;case`emit`:break;default:return}let t=null,n=[],r=0,i=null,a=!1;for await(let o of Sr(vm(e)))for(let{eventType:e,value:s}of o)if(e===`opentag`){let e=s;switch(e.name){case`b`:i||={},i.bold=!0;break;case`charset`:i||={},i.charset=parseInt(e.attributes.charset,10);break;case`color`:i||={},i.color={},e.attributes.rgb&&(i.color.argb=e.attributes.rgb),e.attributes.val&&(i.color.argb=e.attributes.val),e.attributes.theme&&(i.color.theme=e.attributes.theme);break;case`family`:i||={},i.family=parseInt(e.attributes.val,10);break;case`i`:i||={},i.italic=!0;break;case`outline`:i||={},i.outline=!0;break;case`rFont`:i||={},i.name=e.attributes.val;break;case`r`:a=!0;break;case`si`:i=null,n=[],t=null,a=!1;break;case`sz`:i||={},i.size=parseInt(e.attributes.val,10);break;case`strike`:i||={},i.strike=!0;break;case`t`:t=null;break;case`u`:i||={},i.underline=!0;break;case`vertAlign`:i||={},i.vertAlign=e.attributes.val;break}}else if(e===`text`)t=t?t+s:s;else if(e===`closetag`)switch(s.name){case`t`:t!=null&&(t=mt(t));break;case`r`:a&&(n.push({font:i,text:t}),i=null,t=null);break;case`si`:this.options.sharedStrings===`cache`?this.sharedStrings.push(n.length?{richText:n}:t??``):this.options.sharedStrings===`emit`&&(yield{index:r++,text:n.length?{richText:n}:t??``}),n=[],i=null,t=null,a=!1;break}}async _parseStyles(e){this._emitEntry({type:`styles`}),this.options.styles===`cache`&&(this.styles=new Zr,await this.styles.parseStream(vm(e)))}*_parseWorksheet(e,t){this._emitEntry({type:`worksheet`,id:t});let n=parseInt(t,10),r=this._createWorksheetReader({id:n,iterator:e,options:this.options});r.sheetNo=n;let i=this._workbookRelIdByTarget?.[Hi(t)],a=i?this._sheetByRelId?.[i]:void 0;a&&(r.id=a.id,r.name=a.name,r.state=a.state),this.options.worksheets===`emit`&&(yield{eventType:`worksheet`,value:r})}async*_parseHyperlinks(e,t){this._emitEntry({type:`hyperlinks`,id:t});let n=this._createHyperlinkReader({id:parseInt(t,10),iterator:e,options:this.options});if(this.options.hyperlinks===`cache`){this._hyperlinkReadersBySheetNo||=Object.create(null),this._hyperlinkReadersBySheetNo[t]=n;let e=n.read;typeof e==`function`&&await e.call(n);return}this.options.hyperlinks===`emit`&&(yield{eventType:`hyperlinks`,value:n})}async*_parseEntries(e){let t=_m({forceStream:!0});e.on(`error`,e=>t.emit(`error`,e)),e.pipe(t);for await(let e of vm(t)){let t,n=bi(e.path);switch(n){case L.rootRels:break;case L.xlWorkbookRels:await this._parseRels(e);break;case L.xlWorkbook:await this._parseWorkbook(e);break;case L.xlSharedStrings:for await(let t of this._parseSharedStrings(e))yield{eventType:`shared-strings`,value:t};break;case L.xlStyles:await this._parseStyles(e);break;default:if(t=xi(n)?.toString(),t)if(this.workbookRels&&this.model&&(this.options.sharedStrings!==`cache`||this.sharedStrings)){yield*this._parseWorksheet(vm(e),t);continue}else{yield{eventType:`waiting-worksheet`,sheetNo:t,entry:e};continue}if(t=Si(n)?.toString(),t){yield*this._parseHyperlinks(vm(e),t);continue}break}e.autodrain()}}},Sm=class extends xm{constructor(e,t={}){super(e,t,ym,bm)}async _storeWaitingWorksheet(e,t){let n=[],r=new TextEncoder;for await(let e of vm(t))e instanceof Uint8Array?n.push(e):typeof e==`string`&&n.push(r.encode(e));return{sheetNo:e,data:n}}async*_processWaitingWorksheets(e){for(let t of e){let e=(async function*(){for(let e of t.data)yield e})();yield*this._parseWorksheet(e,t.sheetNo)}}};let Q=Array.from({length:60},(e,t)=>t<10?`0${t}`:`${t}`),$=(e,t)=>(e.charCodeAt(t)-48)*10+e.charCodeAt(t+1)-48|0,Cm=(e,t)=>(e.charCodeAt(t)-48)*1e3+(e.charCodeAt(t+1)-48)*100+(e.charCodeAt(t+2)-48)*10+e.charCodeAt(t+3)-48|0,wm=[0,31,29,31,30,31,30,31,31,30,31,30,31];function Tm(e,t,n){if(t<1||t>12||n<1||n>wm[t])return null;let r=new Date(e,t-1,n);return r.getMonth()===t-1?r:null}function Em(e,t,n,r,i,a){return t<1||t>12||n<1||n>wm[t]||r>23||i>59||a>59?null:new Date(e,t-1,n,r,i,a)}function Dm(e){return e.charCodeAt(4)!==45||e.charCodeAt(7)!==45?null:Tm(Cm(e,0),$(e,5),$(e,8))}function Om(e){return e.charCodeAt(4)!==45||e.charCodeAt(7)!==45||e.charCodeAt(10)!==84||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:Em(Cm(e,0),$(e,5),$(e,8),$(e,11),$(e,14),$(e,17))}function km(e){return e.charCodeAt(4)!==45||e.charCodeAt(7)!==45||e.charCodeAt(10)!==32||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:Em(Cm(e,0),$(e,5),$(e,8),$(e,11),$(e,14),$(e,17))}function Am(e){if(e.charCodeAt(19)!==90)return null;let t=new Date(e);return isNaN(t.getTime())?null:t}function jm(e){if(e.charCodeAt(19)!==46||e.charCodeAt(23)!==90)return null;let t=new Date(e);return isNaN(t.getTime())?null:t}function Mm(e){let t=e.charCodeAt(19);if(t!==43&&t!==45)return null;let n=new Date(e);return isNaN(n.getTime())?null:n}function Nm(e){if(e.charCodeAt(19)!==46)return null;let t=e.charCodeAt(23);if(t!==43&&t!==45)return null;let n=new Date(e);return isNaN(n.getTime())?null:n}function Pm(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t?null:Tm(Cm(e,6),$(e,0),$(e,3))}function Fm(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t?null:Tm(Cm(e,6),$(e,3),$(e,0))}function Im(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t||e.charCodeAt(10)!==32||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:Em(Cm(e,6),$(e,0),$(e,3),$(e,11),$(e,14),$(e,17))}function Lm(e){let t=e.charCodeAt(2);return t!==45&&t!==47||e.charCodeAt(5)!==t||e.charCodeAt(10)!==32||e.charCodeAt(13)!==58||e.charCodeAt(16)!==58?null:Em(Cm(e,6),$(e,3),$(e,0),$(e,11),$(e,14),$(e,17))}let Rm={"YYYY-MM-DD":Dm,"YYYY-MM-DD[T]HH:mm:ss":Om,"YYYY-MM-DD HH:mm:ss":km,"YYYY-MM-DD[T]HH:mm:ssZ":e=>e.length===20?Am(e):e.length===25?Mm(e):null,"YYYY-MM-DD[T]HH:mm:ss.SSSZ":e=>e.length===24?jm(e):e.length===29?Nm(e):null,"MM-DD-YYYY":Pm,"MM-DD-YYYY HH:mm:ss":Im,"MM/DD/YYYY HH:mm:ss":Im,"DD-MM-YYYY":Fm,"DD-MM-YYYY HH:mm:ss":Lm,"DD/MM/YYYY HH:mm:ss":Lm},zm=[[10,[Dm]],[19,[Om,km]],[20,[Am]],[24,[jm]],[25,[Mm]],[29,[Nm]]];var Bm=class e{constructor(e){this.parse=e=>{if(!e)return null;let t=e.trim();if(!t)return null;if(this.single)return this.fn0(t);for(let e=0,n=this.fns.length;e<n;e++){let n=this.fns[e](t);if(n)return n}return null},this.fns=e,this.single=e.length===1,this.fn0=e[0]}static create(t){return new e(t.map(e=>Rm[e]).filter(Boolean))}static iso(){let t=[];for(let[,e]of zm)t.push(...e);return new e(t)}parseAll(e){let t=e.length,n=Array(t),r=this.parse;for(let i=0;i<t;i++)n[i]=r(e[i]);return n}parseValid(e){let t=[],n=this.parse;for(let r=0,i=e.length;r<i;r++){let i=n(e[r]);i&&t.push(i)}return t}};function Vm(e){let t=-e.getTimezoneOffset(),n=t>=0?`+`:`-`,r=Math.abs(t)/60|0,i=Math.abs(t)%60;return`${n}${Q[r]}:${Q[i]}`}var Hm=class e{constructor(e){this.format=e=>this.fn(e),this.fn=e}static iso(t=!1){return t?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();if(t!==t)return``;let n=e.getUTCFullYear(),r=e.getUTCMonth()+1,i=e.getUTCDate(),a=e.getUTCHours(),o=e.getUTCMinutes(),s=e.getUTCSeconds(),c=e.getUTCMilliseconds();return`${n}-${Q[r]}-${Q[i]}T${Q[a]}:${Q[o]}:${Q[s]}.${c<10?`00`+c:c<100?`0`+c:c}Z`}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();if(t!==t)return``;let n=e.getFullYear(),r=e.getMonth()+1,i=e.getDate(),a=e.getHours(),o=e.getMinutes(),s=e.getSeconds(),c=e.getMilliseconds();return`${n}-${Q[r]}-${Q[i]}T${Q[a]}:${Q[o]}:${Q[s]}.${c<10?`00`+c:c<100?`0`+c:c}${Vm(e)}`})}static create(t,n){let r=n?.utc??!1;if(t===`YYYY-MM-DD`)return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getUTCFullYear()}-${Q[e.getUTCMonth()+1]}-${Q[e.getUTCDate()]}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getFullYear()}-${Q[e.getMonth()+1]}-${Q[e.getDate()]}`:``});if(t===`YYYY-MM-DD HH:mm:ss`)return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getUTCFullYear()}-${Q[e.getUTCMonth()+1]}-${Q[e.getUTCDate()]} ${Q[e.getUTCHours()]}:${Q[e.getUTCMinutes()]}:${Q[e.getUTCSeconds()]}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${e.getFullYear()}-${Q[e.getMonth()+1]}-${Q[e.getDate()]} ${Q[e.getHours()]}:${Q[e.getMinutes()]}:${Q[e.getSeconds()]}`:``});if(t===`MM-DD-YYYY`||t===`MM/DD/YYYY`){let n=t.charAt(2);return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${Q[e.getUTCMonth()+1]}${n}${Q[e.getUTCDate()]}${n}${e.getUTCFullYear()}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${Q[e.getMonth()+1]}${n}${Q[e.getDate()]}${n}${e.getFullYear()}`:``})}if(t===`DD-MM-YYYY`||t===`DD/MM/YYYY`){let n=t.charAt(2);return r?new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${Q[e.getUTCDate()]}${n}${Q[e.getUTCMonth()+1]}${n}${e.getUTCFullYear()}`:``}):new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();return t===t?`${Q[e.getDate()]}${n}${Q[e.getMonth()+1]}${n}${e.getFullYear()}`:``})}return e.createGeneric(t,r)}static createGeneric(t,n){let r=[],i=[],a=0;for(;a<t.length;)if(t[a]===`[`){let e=t.indexOf(`]`,a+1);e===-1?(i.push(t[a]),a++):(r.push(t.slice(a+1,e)),i.push(`\x00${r.length-1}\x00`),a=e+1)}else i.push(t[a]),a++;let o=i.join(``),s=o.includes(`YYYY`),c=o.includes(`SSS`),l=o.includes(`MM`),u=o.includes(`DD`),d=o.includes(`HH`),f=o.includes(`mm`),p=o.includes(`ss`),m=o.includes(`Z`);return new e(e=>{if(!(e instanceof Date))return``;let t=e.getTime();if(t!==t)return``;let i=o;if(s&&(i=i.replace(/YYYY/g,String(n?e.getUTCFullYear():e.getFullYear()))),c){let t=n?e.getUTCMilliseconds():e.getMilliseconds();i=i.replace(/SSS/g,t<10?`00${t}`:t<100?`0${t}`:String(t))}return l&&(i=i.replace(/MM/g,Q[n?e.getUTCMonth()+1:e.getMonth()+1])),u&&(i=i.replace(/DD/g,Q[n?e.getUTCDate():e.getDate()])),d&&(i=i.replace(/HH/g,Q[n?e.getUTCHours():e.getHours()])),f&&(i=i.replace(/mm/g,Q[n?e.getUTCMinutes():e.getMinutes()])),p&&(i=i.replace(/ss/g,Q[n?e.getUTCSeconds():e.getSeconds()])),m&&(i=i.replace(/Z/g,n?`Z`:Vm(e))),r.length&&(i=i.replace(/\x00(\d+)\x00/g,(e,t)=>r[+t])),i})}formatAll(e){let t=e.length,n=Array(t),r=this.fn;for(let i=0;i<t;i++)n[i]=r(e[i]);return n}};function Um(){return Object.keys(Rm)}function Wm(e){if(!Array.isArray(e)||e.length===0)return!1;let t=e[0];return Array.isArray(t)&&t.length===2&&typeof t[0]==`string`}function Gm(e){let t=Object.create(null);for(let[n,r]of e)n!==`__proto__`&&(t[n]=r);return t}function Km(e){return e.map(([,e])=>e)}function qm(e){return e.map(([e])=>e)}function Jm(e,t){for(let[n,r]of e)if(n===t)return r}function Ym(e,t){if(t.length<=10)return t.map(t=>Jm(e,t));let n=Gm(e);return t.map(e=>n[e])}function Xm(e,t){return Wm(e)?t?Ym(e,t):Km(e):Array.isArray(e)?e:typeof e==`object`&&e?t?t.map(t=>e[t]):Object.values(e):[e]}function Zm(e){return Wm(e)?qm(e):!Array.isArray(e)&&typeof e==`object`&&e?Object.keys(e):[]}function Qm(e){return $m(e).headers}function $m(e){let t=new Map,n=new Set,r=new Set,i=[],a={},o=!1,s=0;for(let t of e)t!=null&&t!==``&&r.add(t);for(let c=0;c<e.length;c++){let l=e[c];if(l==null){i.push(l);continue}if(l===``){let e=`_column_${c}`;for(;n.has(e)||r.has(e);)e=`_column_${c}_${s++}`;n.add(e),i.push(e),a[e]=``,o=!0;continue}if(!n.has(l)){n.add(l),t.set(l,1),i.push(l);continue}let u=t.get(l)??1,d=`${l}_${u}`;for(;n.has(d)||r.has(d);)u++,d=`${l}_${u}`;t.set(l,u+1),n.add(d),i.push(d),a[d]=l,o=!0}return{headers:i,renamedHeaders:o?a:null}}function eh(e){return!e||e.length===0?null:{keys:e.map(e=>typeof e==`string`?e:e.key),headers:e.map(e=>typeof e==`string`?e:e.header??e.key)}}let th=/\S/;function nh(e,t){if(!t)return!1;if(t===`greedy`){for(let t of e)if(th.test(t))return!1}else for(let t of e)if(t!==``)return!1;return!0}function rh(e){return nh(e,!0)}var ih=class extends t{constructor(...e){super(...e),this.name=`CsvError`}};function ah(e,t,n){let{headers:r,groupColumnsByName:i=!1}=t;if(n!==null&&Array.isArray(r))return null;let a,o;if(typeof r==`function`){if(a=r(e),a.length!==e.length)throw new ih(`Header function returned ${a.length} headers but row has ${e.length} columns. The header function must return an array with the same length as the input row.`);o=!0}else if(Array.isArray(r))a=r,o=!1;else if(r===!0)a=e,o=!0;else return null;let{headers:s,renamedHeaders:c}=$m(a);return{headers:s,originalHeaders:i?a.map(e=>e==null?null:String(e)):null,renamedHeaders:c,skipCurrentRow:o}}function oh(e,t,n){let{columnLess:r,columnMore:i}=n,a=e.length;if(a===t)return{isValid:!0,modified:!1};if(a>t)switch(i){case`error`:return{isValid:!1,errorCode:`TooManyFields`,reason:`expected ${t} columns, got ${a}`,modified:!1};case`truncate`:return e.length=t,{isValid:!0,errorCode:`TooManyFields`,modified:!0};case`keep`:return{isValid:!0,errorCode:`TooManyFields`,modified:!0,extras:e.splice(t)};default:{let e=i;throw Error(`Unknown columnMore strategy: ${e}`)}}switch(r){case`error`:return{isValid:!1,errorCode:`TooFewFields`,reason:`expected ${t} columns, got ${a}`,modified:!1};case`pad`:for(;e.length<t;)e.push(``);return{isValid:!0,errorCode:`TooFewFields`,modified:!0};default:{let e=r;throw Error(`Unknown columnLess strategy: ${e}`)}}}function sh(e){return e?(t,n)=>{try{e(t,n)}catch{}}:null}function ch(e,t){let n=Object.create(null);for(let r=0;r<t.length;r++){let i=t[r];i!=null&&i!==`__proto__`&&(n[i]=e[r]??``)}return n}function lh(e,t,n,r){return r&&n?uh(e,n):ch(e,t)}function uh(e,t){let n=Object.create(null);for(let r=0;r<t.length;r++){let i=t[r];if(i!=null&&i!==`__proto__`){let t=e[r]??``;if(i in n){let e=n[i];Array.isArray(e)?e.push(t):n[i]=[e,t]}else n[i]=t}}return n}function dh(e){return e.filter(e=>e!=null)}function fh(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ph(e){return e===!1||e===null?{enabled:!1,char:``}:{enabled:!0,char:e??`"`}}function mh(e,t){return e===!1||e===null?{enabled:!1,char:``}:{enabled:!0,char:e??t}}let hh=[`,`,`;`,` `,`|`],gh=new Set([`=`,`+`,`-`,`@`,` `,`\r`,`
394
+ `,`=`,`+`,`-`,`@`]);function _h(e){return e.charCodeAt(0)===65279?e.slice(1):e}function vh(e){return e.length>0&&gh.has(e[0])}function yh(e,t=`"`){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i===t){if(n&&e[r+1]===t){r++;continue}n=!n;continue}if(!n){if(i===`\r`)return e[r+1]===`
395
395
  `?`\r
396
396
  `:`\r`;if(i===`
397
397
  `)return`
398
398
  `}}return`
399
- `}function _h(e,t=`"`,n,r,i){let a=n??fh,o=a[0]??`,`,s=vh(e,10,t,r,i);if(s.length===0)return o;let c=o,l,u;for(let e of a){let{avgFieldCount:n,delta:r}=yh(s,e,t);n<=1.99||(l===void 0||r<l||r===l&&(u===void 0||n>u))&&(l=r,u=n,c=e)}return c}function vh(e,t,n,r,i){let a=[],o=0,s=!1,c=e.length;for(let l=0;l<c&&a.length<t;l++){let t=e[l];if(n&&t===n)s&&e[l+1]===n?l++:s=!s;else if(!s&&(t===`
399
+ `}function bh(e,t=`"`,n,r,i){let a=n??hh,o=a[0]??`,`,s=xh(e,10,t,r,i);if(s.length===0)return o;let c=o,l,u;for(let e of a){let{avgFieldCount:n,delta:r}=Sh(s,e,t);n<=1.99||(l===void 0||r<l||r===l&&(u===void 0||n>u))&&(l=r,u=n,c=e)}return c}function xh(e,t,n,r,i){let a=[],o=0,s=!1,c=e.length;for(let l=0;l<c&&a.length<t;l++){let t=e[l];if(n&&t===n)s&&e[l+1]===n?l++:s=!s;else if(!s&&(t===`
400
400
  `||t===`\r`)){let n=e.slice(o,l);if(!(r&&n.startsWith(r))){let e=n.trim();!(n.length===0||i&&e===``)&&e!==``&&a.push(n)}t===`\r`&&e[l+1]===`
401
- `&&l++,o=l+1}}if(o<c&&a.length<t){let t=e.slice(o);if(!r||!t.startsWith(r)){let e=t.trim();!(t.length===0||i&&e===``)&&e!==``&&a.push(t)}}return a}function yh(e,t,n){if(e.length===0)return{avgFieldCount:0,delta:1/0};let r=0,i=0,a;for(let o of e){let e=bh(o,t,n)+1;if(i+=e,a===void 0){a=e;continue}r+=Math.abs(e-a),a=e}return i/=e.length,{avgFieldCount:i,delta:r}}function bh(e,t,n){let r=0,i=!1,a=e.length,o=t.length;for(let s=0;s<a;s++)n&&e[s]===n?i&&e[s+1]===n?s++:i=!i:i||(o===1?e[s]===t&&r++:e.startsWith(t,s)&&(r++,s+=o-1));return r}let xh=/\r\n|\r|\n/,Sh=null,Ch=null,wh=null;function Th(){return Sh||(Sh=new TextEncoder,Ch=new Uint8Array(4),wh=new Uint8Array(4096)),Sh}function Eh(e){let t=e.length;if(t===0)return 0;if(t===1)return e.charCodeAt(0)<128?1:Th().encodeInto(e,Ch).written;let n=!0;for(let r=0;r<t;r++)if(e.charCodeAt(r)>=128){n=!1;break}if(n)return t;let r=Th();return t*3>wh.length&&(wh=new Uint8Array(t*3)),r.encodeInto(e,wh).written}function Dh(e){let{input:t,options:n,detectedDelimiter:r}=e,{delimiter:i=`,`,delimitersToGuess:a,lineEnding:o=``,quote:s=`"`,escape:c,skipEmptyLines:l=!1,trim:u=!1,ltrim:d=!1,rtrim:f=!1,headers:p=!1,comment:m,maxRows:h,toLine:g,skipLines:_=0,skipRows:v=0,columnMismatch:y,groupColumnsByName:b=!1,fastMode:ee=!1,dynamicTyping:x,castDate:te,beforeFirstChunk:ne,info:re=!1,raw:ie=!1,relaxQuotes:S=!1,skipRecordsWithError:C=!1,skipRecordsWithEmptyValues:ae=!1,onSkip:oe,maxRowBytes:se}=n,ce=y?.less??`error`,le=y?.more??`error`,ue;if(t!==void 0){if(ue=t,ne){let e=ne(ue);if(typeof e==`string`)ue=e;else if(e!=null)throw new th(`beforeFirstChunk must return a string or undefined, got ${typeof e}`)}ue=mh(ue)}let w=l,{enabled:de,char:fe}=uh(s),pe=dh(c,fe),me=pe.enabled?pe.char||fe:``,he;he=r===void 0?i===``&&ue!==void 0?_h(ue,fe||`"`,a,m,w):i===``?`,`:i:r;let ge=o||(ue===void 0?`
402
- `:gh(ue));return{config:{delimiter:he,linebreak:ge,linebreakRegex:ge&&ge!==`
403
- `&&ge!==`\r
404
- `&&ge!==`\r`?ge:xh,quote:fe,escape:me,quoteEnabled:de,trimField:Ah(u,d,f),trimFieldIsIdentity:!u&&!d&&!f,shouldSkipEmpty:w,skipLines:_,skipRows:v,maxRows:h,toLine:g,maxRowBytes:se,comment:m,fastMode:ee,relaxQuotes:S,columnLess:ce,columnMore:le,groupColumnsByName:b,skipRecordsWithError:C,skipRecordsWithEmptyValues:ae,infoOption:re,rawOption:ie,dynamicTyping:x,castDate:te,invokeOnSkip:ih(oe),headers:p},processedInput:ue}}function Oh(e,t){let n=Dh({input:e,options:t});return{config:n.config,processedInput:n.processedInput}}function kh(e){return{delimiter:e.delimiter,quote:e.quote,escape:e.escape,quoteEnabled:e.quoteEnabled,relaxQuotes:e.relaxQuotes}}function Ah(e,t,n){return e||t&&n?e=>e.trim():t?e=>e.trimStart():n?e=>e.trimEnd():e=>e}function jh(e){let t={lineNumber:0,dataRowCount:0,skippedDataRows:0,truncated:!1,headerRow:null,originalHeaders:null,useHeaders:!1,headerRowProcessed:!1,renamedHeadersForMeta:null,currentRowStartLine:e.infoOption?1:0,currentRowStartOffset:0,currentRowQuoted:[],currentRawRow:``},{headers:n,groupColumnsByName:r}=e;if(n===!0)t.useHeaders=!0;else if(Array.isArray(n)){let e=nh([],{headers:n,groupColumnsByName:r},null);e&&(t.headerRow=e.headers,t.originalHeaders=e.originalHeaders,t.renamedHeadersForMeta=e.renamedHeaders),t.useHeaders=!0,t.headerRowProcessed=!0}else typeof n==`function`&&(t.useHeaders=!0);return t}function Mh(e,t,n,r,i){t&&(e.currentRowQuoted=[],e.currentRowStartLine=r,e.currentRowStartOffset=i),n&&(e.currentRawRow=``)}let Nh=Object.freeze(Array(256).fill(!1));function Ph(e){return e<=256?Nh:Array(e).fill(!1)}let Fh=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,Ih=null;function Lh(){return Ih||=Lm.iso(),Ih}function Rh(e){return!e||e.length<10?null:Lh().parse(e)}function zh(e,t){return e?e===!0?!0:Array.isArray(e)&&typeof t==`string`?e.includes(t):!1:!1}function Bh(e,t){return e===t||e===t-32}function Vh(e){let t=e.length;if(t===0)return``;let n=e.charCodeAt(0);if(t===4){if((n===116||n===84)&&Bh(e.charCodeAt(1),114)&&Bh(e.charCodeAt(2),117)&&Bh(e.charCodeAt(3),101))return!0;if((n===110||n===78)&&Bh(e.charCodeAt(1),117)&&Bh(e.charCodeAt(2),108)&&Bh(e.charCodeAt(3),108))return null}else if(t===5&&(n===102||n===70)&&Bh(e.charCodeAt(1),97)&&Bh(e.charCodeAt(2),108)&&Bh(e.charCodeAt(3),115)&&Bh(e.charCodeAt(4),101))return!1;if(n>=48&&n<=57||n===45||n===46||n===73||n===78){if(e.charCodeAt(t-1)<=32)return e;if(e===`Infinity`)return 1/0;if(e===`-Infinity`)return-1/0;if(e===`NaN`)return NaN;if(n===48&&t>1){let t=e.charCodeAt(1);if(t>=48&&t<=57)return e}if(n===45&&t>2&&e.charCodeAt(1)===48){let t=e.charCodeAt(2);if(t>=48&&t<=57)return e}if(Fh.test(e)){let t=Number(e);if(!isNaN(t))return t}}return e}function Hh(e){return typeof e==`function`}function Uh(e,t){return t===!1?e:Hh(t)?t(e):Vh(e)}function Wh(e,t,n,r){if(zh(r,t)){let t=Rh(e);if(t!==null)return t}if(n===!0)return Vh(e);if(n===!1||t===void 0)return e;let i=n[t];return i===void 0?e:Uh(e,i)}function Gh(e,t,n){if(t===!1&&!n)return e;for(let r in e)Object.hasOwn(e,r)&&(e[r]=Wh(e[r],r,t,n));return e}function Kh(e,t,n,r){return n===!1&&!r||n!==!0&&n!==!1&&!t?e:e.map((e,i)=>{let a=t?.[i];return Wh(e,a,n,r)})}function qh(e,t,n){let r=nh(e,{headers:n.headers,groupColumnsByName:n.groupColumnsByName},t.headerRow);return r?(t.headerRow=r.headers,t.originalHeaders=r.originalHeaders,t.renamedHeadersForMeta=r.renamedHeaders,t.headerRowProcessed=!0,r.skipCurrentRow):(t.headerRowProcessed=!0,!1)}function Jh(e,t,n){if(!t.headerRow||t.headerRow.length===0)return null;let r=t.headerRow.length,i=e.length;if(i===r)return null;let a=rh(e,r,{columnLess:n.columnLess,columnMore:n.columnMore});return a.errorCode?{errorCode:a.errorCode,message:a.errorCode===`TooManyFields`?`Too many fields: expected ${r}, found ${i}`:`Too few fields: expected ${r}, found ${i}`,isValid:a.isValid,reason:a.reason,extras:a.extras}:null}function Yh(e,t,n,r){let i={index:t,line:e.currentRowStartLine,offset:e.currentRowStartOffset,quoted:e.currentRowQuoted.slice(0,r)};return n&&(i.raw=e.currentRawRow),i}function Xh(e,t,n){if(t.headerRow){let r=oh(e,t.headerRow,t.originalHeaders,n.groupColumnsByName);return(n.dynamicTyping||n.castDate)&&(r=Gh(r,n.dynamicTyping||!1,n.castDate)),r}let r={};for(let t=0;t<e.length;t++)r[t]=e[t];return r}function Zh(e,t,n,r){return!!(t&&e[0]?.trimStart().startsWith(t)||$m(e,n)||r&&eh(e))}function Qh(e,t,n,r,i){if(t.useHeaders&&!t.headerRowProcessed&&qh(e,t,n))return{stop:!1,skipped:!0};if(t.skippedDataRows<n.skipRows)return t.skippedDataRows++,{stop:!1,skipped:!0};let a=Jh(e,t,n),o;if(a){let t={code:a.errorCode,message:a.message,line:i};if(r.push(t),!a.isValid)return n.skipRecordsWithError?(n.invokeOnSkip?.({code:a.errorCode,message:a.reason||`Column mismatch`,line:i},e),{stop:!1,skipped:!0,row:e,error:{code:a.errorCode,message:a.reason||`Column mismatch`,line:i},reason:a.reason||`Column mismatch`}):{stop:!1,skipped:!0,row:e,error:t,reason:a.reason||`Column mismatch`};o=a.extras}if(n.skipRecordsWithEmptyValues&&eh(e))return{stop:!1,skipped:!0};if(n.maxRows!==void 0&&t.dataRowCount>=n.maxRows)return t.truncated=!0,{stop:!0,skipped:!1};t.dataRowCount++;let s;return n.infoOption&&(s=Yh(t,t.dataRowCount-1,n.rawOption,e.length)),{stop:!1,skipped:!1,row:e,info:s,extras:o}}let $h={delimiter:`,`,quote:`"`,escape:`"`,quoteEnabled:!0,relaxQuotes:!1};function eg(){return{buffer:``,position:0}}function tg(e,t){let n=e.length,r=e.indexOf(`
401
+ `&&l++,o=l+1}}if(o<c&&a.length<t){let t=e.slice(o);if(!r||!t.startsWith(r)){let e=t.trim();!(t.length===0||i&&e===``)&&e!==``&&a.push(t)}}return a}function Sh(e,t,n){if(e.length===0)return{avgFieldCount:0,delta:1/0};let r=0,i=0,a;for(let o of e){let e=Ch(o,t,n)+1;if(i+=e,a===void 0){a=e;continue}r+=Math.abs(e-a),a=e}return i/=e.length,{avgFieldCount:i,delta:r}}function Ch(e,t,n){let r=0,i=!1,a=e.length,o=t.length;for(let s=0;s<a;s++)n&&e[s]===n?i&&e[s+1]===n?s++:i=!i:i||(o===1?e[s]===t&&r++:e.startsWith(t,s)&&(r++,s+=o-1));return r}let wh=/\r\n|\r|\n/,Th=null,Eh=null,Dh=null;function Oh(){return Th||(Th=new TextEncoder,Eh=new Uint8Array(4),Dh=new Uint8Array(4096)),Th}function kh(e){let t=e.length;if(t===0)return 0;if(t===1)return e.charCodeAt(0)<128?1:Oh().encodeInto(e,Eh).written;let n=!0;for(let r=0;r<t;r++)if(e.charCodeAt(r)>=128){n=!1;break}if(n)return t;let r=Oh();return t*3>Dh.length&&(Dh=new Uint8Array(t*3)),r.encodeInto(e,Dh).written}function Ah(e){let{input:t,options:n,detectedDelimiter:r}=e,{delimiter:i=`,`,delimitersToGuess:a,lineEnding:o=``,quote:s=`"`,escape:c,skipEmptyLines:l=!1,trim:u=!1,ltrim:d=!1,rtrim:f=!1,headers:p=!1,comment:m,maxRows:h,toLine:g,skipLines:_=0,skipRows:v=0,columnMismatch:y,groupColumnsByName:b=!1,fastMode:ee=!1,dynamicTyping:x,castDate:te,beforeFirstChunk:ne,info:re=!1,raw:ie=!1,relaxQuotes:S=!1,skipRecordsWithError:C=!1,skipRecordsWithEmptyValues:ae=!1,onSkip:oe,maxRowBytes:se}=n,ce=y?.less??`error`,le=y?.more??`error`,w;if(t!==void 0){if(w=t,ne){let e=ne(w);if(typeof e==`string`)w=e;else if(e!=null)throw new ih(`beforeFirstChunk must return a string or undefined, got ${typeof e}`)}w=_h(w)}let T=l,{enabled:ue,char:de}=ph(s),fe=mh(c,de),pe=fe.enabled?fe.char||de:``,me;me=r===void 0?i===``&&w!==void 0?bh(w,de||`"`,a,m,T):i===``?`,`:i:r;let he=o||(w===void 0?`
402
+ `:yh(w));return{config:{delimiter:me,linebreak:he,linebreakRegex:he&&he!==`
403
+ `&&he!==`\r
404
+ `&&he!==`\r`?he:wh,quote:de,escape:pe,quoteEnabled:ue,trimField:Nh(u,d,f),trimFieldIsIdentity:!u&&!d&&!f,shouldSkipEmpty:T,skipLines:_,skipRows:v,maxRows:h,toLine:g,maxRowBytes:se,comment:m,fastMode:ee,relaxQuotes:S,columnLess:ce,columnMore:le,groupColumnsByName:b,skipRecordsWithError:C,skipRecordsWithEmptyValues:ae,infoOption:re,rawOption:ie,dynamicTyping:x,castDate:te,invokeOnSkip:sh(oe),headers:p},processedInput:w}}function jh(e,t){let n=Ah({input:e,options:t});return{config:n.config,processedInput:n.processedInput}}function Mh(e){return{delimiter:e.delimiter,quote:e.quote,escape:e.escape,quoteEnabled:e.quoteEnabled,relaxQuotes:e.relaxQuotes}}function Nh(e,t,n){return e||t&&n?e=>e.trim():t?e=>e.trimStart():n?e=>e.trimEnd():e=>e}function Ph(e){let t={lineNumber:0,dataRowCount:0,skippedDataRows:0,truncated:!1,headerRow:null,originalHeaders:null,useHeaders:!1,headerRowProcessed:!1,renamedHeadersForMeta:null,currentRowStartLine:e.infoOption?1:0,currentRowStartOffset:0,currentRowQuoted:[],currentRawRow:``},{headers:n,groupColumnsByName:r}=e;if(n===!0)t.useHeaders=!0;else if(Array.isArray(n)){let e=ah([],{headers:n,groupColumnsByName:r},null);e&&(t.headerRow=e.headers,t.originalHeaders=e.originalHeaders,t.renamedHeadersForMeta=e.renamedHeaders),t.useHeaders=!0,t.headerRowProcessed=!0}else typeof n==`function`&&(t.useHeaders=!0);return t}function Fh(e,t,n,r,i){t&&(e.currentRowQuoted=[],e.currentRowStartLine=r,e.currentRowStartOffset=i),n&&(e.currentRawRow=``)}let Ih=Object.freeze(Array(256).fill(!1));function Lh(e){return e<=256?Ih:Array(e).fill(!1)}let Rh=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,zh=null;function Bh(){return zh||=Bm.iso(),zh}function Vh(e){return!e||e.length<10?null:Bh().parse(e)}function Hh(e,t){return e?e===!0?!0:Array.isArray(e)&&typeof t==`string`?e.includes(t):!1:!1}function Uh(e,t){return e===t||e===t-32}function Wh(e){let t=e.length;if(t===0)return``;let n=e.charCodeAt(0);if(t===4){if((n===116||n===84)&&Uh(e.charCodeAt(1),114)&&Uh(e.charCodeAt(2),117)&&Uh(e.charCodeAt(3),101))return!0;if((n===110||n===78)&&Uh(e.charCodeAt(1),117)&&Uh(e.charCodeAt(2),108)&&Uh(e.charCodeAt(3),108))return null}else if(t===5&&(n===102||n===70)&&Uh(e.charCodeAt(1),97)&&Uh(e.charCodeAt(2),108)&&Uh(e.charCodeAt(3),115)&&Uh(e.charCodeAt(4),101))return!1;if(n>=48&&n<=57||n===45||n===46||n===73||n===78){if(e.charCodeAt(t-1)<=32)return e;if(e===`Infinity`)return 1/0;if(e===`-Infinity`)return-1/0;if(e===`NaN`)return NaN;if(n===48&&t>1){let t=e.charCodeAt(1);if(t>=48&&t<=57)return e}if(n===45&&t>2&&e.charCodeAt(1)===48){let t=e.charCodeAt(2);if(t>=48&&t<=57)return e}if(Rh.test(e)){let t=Number(e);if(!isNaN(t))return t}}return e}function Gh(e){return typeof e==`function`}function Kh(e,t){return t===!1?e:Gh(t)?t(e):Wh(e)}function qh(e,t,n,r){if(Hh(r,t)){let t=Vh(e);if(t!==null)return t}if(n===!0)return Wh(e);if(n===!1||t===void 0)return e;let i=n[t];return i===void 0?e:Kh(e,i)}function Jh(e,t,n){if(t===!1&&!n)return e;for(let r in e)Object.hasOwn(e,r)&&(e[r]=qh(e[r],r,t,n));return e}function Yh(e,t,n,r){return n===!1&&!r||n!==!0&&n!==!1&&!t?e:e.map((e,i)=>{let a=t?.[i];return qh(e,a,n,r)})}function Xh(e,t,n){let r=ah(e,{headers:n.headers,groupColumnsByName:n.groupColumnsByName},t.headerRow);return r?(t.headerRow=r.headers,t.originalHeaders=r.originalHeaders,t.renamedHeadersForMeta=r.renamedHeaders,t.headerRowProcessed=!0,r.skipCurrentRow):(t.headerRowProcessed=!0,!1)}function Zh(e,t,n){if(!t.headerRow||t.headerRow.length===0)return null;let r=t.headerRow.length,i=e.length;if(i===r)return null;let a=oh(e,r,{columnLess:n.columnLess,columnMore:n.columnMore});return a.errorCode?{errorCode:a.errorCode,message:a.errorCode===`TooManyFields`?`Too many fields: expected ${r}, found ${i}`:`Too few fields: expected ${r}, found ${i}`,isValid:a.isValid,reason:a.reason,extras:a.extras}:null}function Qh(e,t,n,r){let i={index:t,line:e.currentRowStartLine,offset:e.currentRowStartOffset,quoted:e.currentRowQuoted.slice(0,r)};return n&&(i.raw=e.currentRawRow),i}function $h(e,t,n){if(t.headerRow){let r=lh(e,t.headerRow,t.originalHeaders,n.groupColumnsByName);return(n.dynamicTyping||n.castDate)&&(r=Jh(r,n.dynamicTyping||!1,n.castDate)),r}let r={};for(let t=0;t<e.length;t++)r[t]=e[t];return r}function eg(e,t,n,r){return!!(t&&e[0]?.trimStart().startsWith(t)||nh(e,n)||r&&rh(e))}function tg(e,t,n,r,i){if(t.useHeaders&&!t.headerRowProcessed&&Xh(e,t,n))return{stop:!1,skipped:!0};if(t.skippedDataRows<n.skipRows)return t.skippedDataRows++,{stop:!1,skipped:!0};let a=Zh(e,t,n),o;if(a){let t={code:a.errorCode,message:a.message,line:i};if(r.push(t),!a.isValid)return n.skipRecordsWithError?(n.invokeOnSkip?.({code:a.errorCode,message:a.reason||`Column mismatch`,line:i},e),{stop:!1,skipped:!0,row:e,error:{code:a.errorCode,message:a.reason||`Column mismatch`,line:i},reason:a.reason||`Column mismatch`}):{stop:!1,skipped:!0,row:e,error:t,reason:a.reason||`Column mismatch`};o=a.extras}if(n.skipRecordsWithEmptyValues&&rh(e))return{stop:!1,skipped:!0};if(n.maxRows!==void 0&&t.dataRowCount>=n.maxRows)return t.truncated=!0,{stop:!0,skipped:!1};t.dataRowCount++;let s;return n.infoOption&&(s=Qh(t,t.dataRowCount-1,n.rawOption,e.length)),{stop:!1,skipped:!1,row:e,info:s,extras:o}}let ng={delimiter:`,`,quote:`"`,escape:`"`,quoteEnabled:!0,relaxQuotes:!1};function rg(){return{buffer:``,position:0}}function ig(e,t){let n=e.length,r=e.indexOf(`
405
405
  `,t),i=e.indexOf(`\r`,t);return r===-1&&i===-1?[-1,0]:i===-1||r!==-1&&r<i?[r,1]:i+1<n?e[i+1]===`
406
- `?[i,2]:[i,1]:[i,-1]}function ng(e,t,n){return n.length===1?e[t]===n:e.startsWith(n,t)}function rg(e,t,n){return e.indexOf(n,t)}function ig(e,t,n,r){let{quote:i,escape:a,delimiter:o,relaxQuotes:s}=n,c=e.length,l=t+1,u=null,d=l,f=t=>{let n=t>d?e.slice(d,t):``;return u===null?n:(n&&u.push(n),u.length===1?u[0]:u.join(``))};for(;l<c;){let n=e[l];if(a&&n===a){if(l+1<c&&e[l+1]===i){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(i),l+=2,d=l;continue}if(a!==i&&l+1<c&&e[l+1]===a){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(a),l+=2,d=l;continue}if(a===i){if(l+1>=c)return r?{value:f(l),quoted:!0,endPos:l+1,needMore:!1}:{value:f(l),quoted:!0,endPos:l,needMore:!0,resumePos:t};let n=e[l+1];if((o.length===1?n===o:ng(e,l+1,o))||n===`
407
- `||n===`\r`)return{value:f(l),quoted:!0,endPos:l+1,needMore:!1};if(s){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(i),l++,d=l;continue}return{value:f(l),quoted:!0,endPos:l+1,needMore:!1}}}if(n===i&&a!==i){if(l+1>=c)return r?{value:f(l),quoted:!0,endPos:l+1,needMore:!1}:{value:f(l),quoted:!0,endPos:l,needMore:!0,resumePos:t};let n=e[l+1];if((o.length===1?n===o:ng(e,l+1,o))||n===`
406
+ `?[i,2]:[i,1]:[i,-1]}function ag(e,t,n){return n.length===1?e[t]===n:e.startsWith(n,t)}function og(e,t,n){return e.indexOf(n,t)}function sg(e,t,n,r){let{quote:i,escape:a,delimiter:o,relaxQuotes:s}=n,c=e.length,l=t+1,u=null,d=l,f=t=>{let n=t>d?e.slice(d,t):``;return u===null?n:(n&&u.push(n),u.length===1?u[0]:u.join(``))};for(;l<c;){let n=e[l];if(a&&n===a){if(l+1<c&&e[l+1]===i){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(i),l+=2,d=l;continue}if(a!==i&&l+1<c&&e[l+1]===a){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(a),l+=2,d=l;continue}if(a===i){if(l+1>=c)return r?{value:f(l),quoted:!0,endPos:l+1,needMore:!1}:{value:f(l),quoted:!0,endPos:l,needMore:!0,resumePos:t};let n=e[l+1];if((o.length===1?n===o:ag(e,l+1,o))||n===`
407
+ `||n===`\r`)return{value:f(l),quoted:!0,endPos:l+1,needMore:!1};if(s){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(i),l++,d=l;continue}return{value:f(l),quoted:!0,endPos:l+1,needMore:!1}}}if(n===i&&a!==i){if(l+1>=c)return r?{value:f(l),quoted:!0,endPos:l+1,needMore:!1}:{value:f(l),quoted:!0,endPos:l,needMore:!0,resumePos:t};let n=e[l+1];if((o.length===1?n===o:ag(e,l+1,o))||n===`
408
408
  `||n===`\r`)return{value:f(l),quoted:!0,endPos:l+1,needMore:!1};if(s){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(i),l++,d=l;continue}return{value:f(l),quoted:!0,endPos:l+1,needMore:!1}}if(n===`\r`){if(l+1<c){if(e[l+1]===`
409
409
  `){l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(`
410
410
  `),l+=2,d=l;continue}l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(`
411
411
  `),l++,d=l;continue}if(!r)return{value:f(l),quoted:!0,endPos:l,needMore:!0,resumePos:t};l>d&&(u??=[]).push(e.slice(d,l)),(u??=[]).push(`
412
- `),l++,d=l;continue}l++}return r?{value:f(l),quoted:!0,endPos:l,needMore:!1,unterminated:!0}:{value:f(l),quoted:!0,endPos:l,needMore:!0,resumePos:t}}function ag(e,t,n,r){let{delimiter:i}=n,a=e.length,o=rg(e,t,i),[s,c]=tg(e,t),l,u=!1;return o===-1&&s===-1?r?{value:e.slice(t),quoted:!1,endPos:a,needMore:!1}:{value:e.slice(t),quoted:!1,endPos:a,needMore:!0,resumePos:t}:(o===-1?(l=s,u=!0):s===-1||o<s?l=o:(l=s,u=!0),u&&c===-1&&!r?{value:e.slice(t,l),quoted:!1,endPos:l,needMore:!0,resumePos:t}:{value:e.slice(t,l),quoted:!1,endPos:l,needMore:!1})}function og(e,t,n,r,i,a){let{delimiter:o,quote:s,quoteEnabled:c}=n,l=o.length,u=e.length,d=i??[],f=a??[];i&&(i.length=0),a&&(a.length=0);let p=t,m=!1,h=t;for(;p<u;){let i=e[p];if(c&&i===s){let i=ig(e,p,n,r);if(i.needMore)return{fields:d,quoted:f,endPos:p,complete:!1,needMore:!0,resumePos:i.resumePos??t,rawStart:h,rawEnd:p};if(i.unterminated&&(m=!0),d.push(i.value),f.push(!0),p=i.endPos,p<u){if(ng(e,p,o)){p+=l,p>=u&&r&&(d.push(``),f.push(!1));continue}let n=e[p];if(n===`
412
+ `),l++,d=l;continue}l++}return r?{value:f(l),quoted:!0,endPos:l,needMore:!1,unterminated:!0}:{value:f(l),quoted:!0,endPos:l,needMore:!0,resumePos:t}}function cg(e,t,n,r){let{delimiter:i}=n,a=e.length,o=og(e,t,i),[s,c]=ig(e,t),l,u=!1;return o===-1&&s===-1?r?{value:e.slice(t),quoted:!1,endPos:a,needMore:!1}:{value:e.slice(t),quoted:!1,endPos:a,needMore:!0,resumePos:t}:(o===-1?(l=s,u=!0):s===-1||o<s?l=o:(l=s,u=!0),u&&c===-1&&!r?{value:e.slice(t,l),quoted:!1,endPos:l,needMore:!0,resumePos:t}:{value:e.slice(t,l),quoted:!1,endPos:l,needMore:!1})}function lg(e,t,n,r,i,a){let{delimiter:o,quote:s,quoteEnabled:c}=n,l=o.length,u=e.length,d=i??[],f=a??[];i&&(i.length=0),a&&(a.length=0);let p=t,m=!1,h=t;for(;p<u;){let i=e[p];if(c&&i===s){let i=sg(e,p,n,r);if(i.needMore)return{fields:d,quoted:f,endPos:p,complete:!1,needMore:!0,resumePos:i.resumePos??t,rawStart:h,rawEnd:p};if(i.unterminated&&(m=!0),d.push(i.value),f.push(!0),p=i.endPos,p<u){if(ag(e,p,o)){p+=l,p>=u&&r&&(d.push(``),f.push(!1));continue}let n=e[p];if(n===`
413
413
  `)return{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`
414
414
  `,rawStart:h,rawEnd:p};if(n===`\r`)return p+1<u?e[p+1]===`
415
415
  `?{fields:d,quoted:f,endPos:p+2,complete:!0,needMore:!1,newline:`\r
416
- `,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`\r`,rawStart:h,rawEnd:p}:r?{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`\r`,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p,complete:!1,needMore:!0,resumePos:t,rawStart:h,rawEnd:p};for(p++;p<u;){if(ng(e,p,o)){p+=l;break}if(e[p]===`
417
- `||e[p]===`\r`)break;p++}continue}continue}let a=ag(e,p,n,r);if(a.needMore)return d.push(a.value),f.push(!1),{fields:d,quoted:f,endPos:a.endPos,complete:!1,needMore:!0,resumePos:a.resumePos??t,rawStart:h,rawEnd:a.endPos};if(d.push(a.value),f.push(!1),p=a.endPos,p<u){if(ng(e,p,o)){p+=l,p>=u&&r&&(d.push(``),f.push(!1));continue}let t=e[p];if(t===`
416
+ `,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`\r`,rawStart:h,rawEnd:p}:r?{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`\r`,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p,complete:!1,needMore:!0,resumePos:t,rawStart:h,rawEnd:p};for(p++;p<u;){if(ag(e,p,o)){p+=l;break}if(e[p]===`
417
+ `||e[p]===`\r`)break;p++}continue}continue}let a=cg(e,p,n,r);if(a.needMore)return d.push(a.value),f.push(!1),{fields:d,quoted:f,endPos:a.endPos,complete:!1,needMore:!0,resumePos:a.resumePos??t,rawStart:h,rawEnd:a.endPos};if(d.push(a.value),f.push(!1),p=a.endPos,p<u){if(ag(e,p,o)){p+=l,p>=u&&r&&(d.push(``),f.push(!1));continue}let t=e[p];if(t===`
418
418
  `)return{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`
419
419
  `,rawStart:h,rawEnd:p};if(t===`\r`)return p+1<u&&e[p+1]===`
420
420
  `?{fields:d,quoted:f,endPos:p+2,complete:!0,needMore:!1,newline:`\r
421
- `,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`\r`,rawStart:h,rawEnd:p}}}return r&&(d.length>0||p>t)?{fields:d,quoted:f,endPos:p,complete:!0,needMore:!1,unterminatedQuote:m||void 0,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p,complete:!1,needMore:!r,resumePos:t,unterminatedQuote:m||void 0,rawStart:h,rawEnd:p}}function sg(e){let t={...$h,...e},n=eg(),r=[],i=[];return{get config(){return t},scanRow(e,n=0,r=!1){return og(e,n,t,r)},feed(e){n.buffer+=e},nextRow(){if(n.position>=n.buffer.length)return null;let e=og(n.buffer,n.position,t,!1,r,i);if(e.needMore)return null;if(e.complete){e.raw=n.buffer.slice(e.rawStart,e.rawEnd),n.position=e.endPos;let t=n.position,r=n.buffer.length;return(t>65536||t>r/2&&t>4096)&&(n.buffer=n.buffer.slice(n.position),n.position=0),e}return null},flush(){if(n.position>=n.buffer.length)return null;let e=og(n.buffer,n.position,t,!0,r,i);return e.fields.length===0&&e.endPos===n.position?null:(e.raw=n.buffer.slice(e.rawStart,e.rawEnd),n.position=e.endPos,e)},reset(){n=eg(),r.length=0,i.length=0},getBuffer(){return n.buffer.slice(n.position)}}}let cg=new WeakMap;function lg(e){let t=cg.get(e);return t||(t=new RegExp(e.source,`${e.flags.replace(/g/g,``)}g`),cg.set(e,t)),t}function*ug(e,t){if(e===``)return;if(typeof t==`string`){let n=t;if(n===``){yield{line:e,lineEndingLength:0,lineLengthWithEnding:e.length};return}let r=0;for(;;){let t=e.indexOf(n,r);if(t===-1){if(r===e.length)return;let t=e.slice(r);yield{line:t,lineEndingLength:0,lineLengthWithEnding:t.length};return}let i=e.slice(r,t),a=n.length;yield{line:i,lineEndingLength:a,lineLengthWithEnding:i.length+a},r=t+n.length}}let n=t.global?t:lg(t),r=0;for(n.lastIndex=0;;){let t=n.exec(e);if(!t)break;let i=t.index,a=i+t[0].length,o=e.slice(r,i),s=t[0].length;yield{line:o,lineEndingLength:s,lineLengthWithEnding:o.length+s},r=a,t[0].length===0&&n.lastIndex++}if(r===e.length)return;let i=e.slice(r);yield{line:i,lineEndingLength:0,lineLengthWithEnding:i.length}}function dg(e){return typeof e==`boolean`?{isValid:e,reason:`Validation failed`}:{isValid:e.isValid,reason:e.reason||`Validation failed`}}function fg(e,t,n){return Kh(e,null,t||!1,n)}function pg(e){return e.length>0?e:void 0}function mg(e,t){return{delimiter:e.delimiter,linebreak:e.linebreak,aborted:!1,truncated:t.truncated,cursor:t.dataRowCount,fields:t.headerRow?ch(t.headerRow):void 0,renamedHeaders:t.renamedHeadersForMeta}}function hg(e,t){return t.trimFieldIsIdentity?e:e.map(t.trimField)}function*gg(e,t,n,r){if(e===``)return;let i=0;for(let{line:a,lineLengthWithEnding:o}of ug(e,t.linebreakRegex)){if(n.lineNumber++,t.toLine!==void 0&&n.lineNumber>t.toLine){n.truncated=!0;break}if(n.lineNumber<=t.skipLines){i+=o;continue}if(a===``&&t.shouldSkipEmpty){i+=o;continue}if(t.maxRowBytes!==void 0&&Eh(a)>t.maxRowBytes)throw Error(`Row exceeds the maximum size of ${t.maxRowBytes} bytes`);t.infoOption&&(n.currentRowStartLine=n.lineNumber,n.currentRowStartOffset=i),t.rawOption&&(n.currentRawRow=a);let e=hg(a.split(t.delimiter),t);if(t.infoOption&&(n.currentRowQuoted=Ph(e.length)),t.comment&&e[0]?.trimStart().startsWith(t.comment)){i+=o;continue}if(t.shouldSkipEmpty&&$m(e,t.shouldSkipEmpty)){i+=o;continue}let s=Qh(e,n,t,r,n.lineNumber);if(i+=o,s.stop){yield s;return}(!s.skipped||s.error)&&(yield s),Mh(n,t.infoOption,t.rawOption,n.lineNumber+1,i)}}function*_g(e,t,n,r){let i=kh(t),a=e.length,o=0;for(t.infoOption&&(n.currentRowStartOffset=0);o<a;){let a=og(e,o,i,!0);if(a.fields.length===0&&a.endPos===o)break;let s=hg(a.fields,t),c=n.lineNumber+1;{let t=a.rawStart,r=a.rawEnd,i=1;for(let n=t;n<r;n++){let t=e.charCodeAt(n);t===10?i++:t===13&&(n+1<r&&e.charCodeAt(n+1)===10&&n++,i++)}n.lineNumber+=i}if(t.toLine!==void 0&&n.lineNumber>t.toLine){n.truncated=!0;break}let l=a.rawEnd;if(n.lineNumber<=t.skipLines){o=a.endPos;continue}if(t.maxRowBytes!==void 0&&Eh(e.slice(a.rawStart,l))>t.maxRowBytes)throw Error(`Row exceeds the maximum size of ${t.maxRowBytes} bytes`);if(t.comment&&s[0]?.trimStart().startsWith(t.comment)){o=a.endPos;continue}if(t.shouldSkipEmpty&&$m(s,t.shouldSkipEmpty)){o=a.endPos;continue}t.infoOption&&(n.currentRowStartLine=c,n.currentRowStartOffset=a.rawStart,n.currentRowQuoted=a.quoted),t.rawOption&&(n.currentRawRow=e.slice(a.rawStart,l)),a.unterminatedQuote&&r.push({code:`MissingQuotes`,message:`Quoted field unterminated`,line:n.lineNumber});let u=Qh(s,n,t,r,n.lineNumber);if(u.stop){yield u;return}(!u.skipped||u.error)&&(yield u),o=a.endPos,t.infoOption&&(n.currentRowStartOffset=a.endPos)}}function vg(e,t={}){let{config:n,processedInput:r}=Oh(e,t),i=jh(n),a=[],o=[],s=n.fastMode?gg(r,n,i,a):_g(r,n,i,a);if(!i.useHeaders){let e=[];for(let r of s){if(r.row&&!r.skipped){let i=r.row;if(t.rowTransform){let e=t.rowTransform(i);if(e==null)continue;i=e}if(t.validate){let{isValid:e,reason:n}=dg(t.validate(i));if(!e){o.push({row:i,reason:n});continue}}(n.dynamicTyping||n.castDate)&&(i=fg(i,n.dynamicTyping,n.castDate)),n.infoOption&&r.info?e.push({record:i,info:r.info}):e.push(i)}else r.row&&r.skipped&&r.error&&o.push({row:r.row,reason:r.reason||r.error.message});if(r.stop)break}let r=mg(n,i);return n.infoOption||t.validate?{headers:void 0,rows:e,invalidRows:pg(o),errors:pg(a),meta:r}:e}let c=[];for(let e of s){if(e.row&&!e.skipped){let r=Xh(e.row,i,n);if(e.extras&&e.extras.length>0&&(r._extra=e.extras),t.rowTransform){let e=t.rowTransform(r);if(e==null)continue;r=e}if(t.validate){let{isValid:n,reason:i}=dg(t.validate(r));if(!n){o.push({row:e.row,reason:i});continue}}n.infoOption&&e.info?c.push({record:r,info:e.info}):c.push(r)}else e.row&&e.skipped&&e.error&&o.push({row:e.row,reason:e.reason||e.error.message});if(e.stop)break}let l=mg(n,i),{objname:u}=t;if(u&&i.headerRow){let e={};for(let t of c){let r=(n.infoOption?t.record:t)[u],i=r==null?``:String(r);e[i]=t}return{headers:l.fields,rows:e,invalidRows:pg(o),errors:pg(a),meta:l}}return{headers:l.fields,rows:c,invalidRows:pg(o),errors:pg(a),meta:l}}let yg=Symbol.for(`csv.FormattedValue`);function bg(e){return typeof e==`object`&&!!e&&e[yg]===!0}function xg(e){return e.length<2}function Sg(e){return e.length<2}var Cg=class extends Yf{constructor(e={}){super({objectMode:e.objectMode!==!1}),this.parseErrorsSink=[],this.buffer=``,this._rowTransform=null,this._rowValidator=null,this.autoDetectDelimiter=!1,this.delimiterDetected=!1,this.chunkBuffer=[],this.totalRowsProcessed=0,this.isFirstChunk=!0,this.chunkAborted=!1,this.beforeFirstChunkApplied=!1,this.bomStripped=!1,this.toLineReached=!1,this.headersEmitted=!1,this.totalCharsProcessed=0,this.backpressure=!1,this.pendingCallback=null,this.options=e,this.chunkSize=e.chunkSize??1e3,this.decoder=new TextDecoder(e.encoding||`utf-8`),this.autoDetectDelimiter=(e.delimiter??`,`)===``;let{config:t}=Dh({options:e});this.parseConfig=t,this.parseState=jh(t),this.scanner=sg(kh(t)),e.rowTransform&&this.transform(e.rowTransform),e.validate&&this.validate(e.validate)}_read(e){if(this.backpressure&&this.pendingCallback){this.backpressure=!1;let e=this.pendingCallback;this.pendingCallback=null,e()}}transform(e){if(typeof e!=`function`)throw TypeError(`The transform should be a function`);return xg(e)?this._rowTransform=(t,n)=>{try{n(null,e(t))}catch(e){n(e)}}:this._rowTransform=e,this}validate(e){if(typeof e!=`function`)throw TypeError(`The validate should be a function`);return Sg(e)?this._rowValidator=(t,n)=>{try{let r=e(t);typeof r==`boolean`?n(null,r):n(null,r.isValid,r.reason)}catch(e){n(e)}}:this._rowValidator=e,this}_transform(e,t,n){if(this.chunkAborted||this.toLineReached){n();return}try{let t=typeof e==`string`?e:this.decoder.decode(e,{stream:!0});if(this.buffer+=t,!this.beforeFirstChunkApplied&&this.options.beforeFirstChunk){this.beforeFirstChunkApplied=!0;let e=this.options.beforeFirstChunk(this.buffer);typeof e==`string`&&(this.buffer=e)}if(this.bomStripped||=(this.buffer=mh(this.buffer),!0),this.autoDetectDelimiter&&!this.delimiterDetected){let e=this.options.comment,t=!1,n=0,r=this.buffer.length;for(;n<r;){let i=n;for(;i<r&&this.buffer[i]!==`
421
+ `,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p+1,complete:!0,needMore:!1,newline:`\r`,rawStart:h,rawEnd:p}}}return r&&(d.length>0||p>t)?{fields:d,quoted:f,endPos:p,complete:!0,needMore:!1,unterminatedQuote:m||void 0,rawStart:h,rawEnd:p}:{fields:d,quoted:f,endPos:p,complete:!1,needMore:!r,resumePos:t,unterminatedQuote:m||void 0,rawStart:h,rawEnd:p}}function ug(e){let t={...ng,...e},n=rg(),r=[],i=[];return{get config(){return t},scanRow(e,n=0,r=!1){return lg(e,n,t,r)},feed(e){n.buffer+=e},nextRow(){if(n.position>=n.buffer.length)return null;let e=lg(n.buffer,n.position,t,!1,r,i);if(e.needMore)return null;if(e.complete){e.raw=n.buffer.slice(e.rawStart,e.rawEnd),n.position=e.endPos;let t=n.position,r=n.buffer.length;return(t>65536||t>r/2&&t>4096)&&(n.buffer=n.buffer.slice(n.position),n.position=0),e}return null},flush(){if(n.position>=n.buffer.length)return null;let e=lg(n.buffer,n.position,t,!0,r,i);return e.fields.length===0&&e.endPos===n.position?null:(e.raw=n.buffer.slice(e.rawStart,e.rawEnd),n.position=e.endPos,e)},reset(){n=rg(),r.length=0,i.length=0},getBuffer(){return n.buffer.slice(n.position)}}}let dg=new WeakMap;function fg(e){let t=dg.get(e);return t||(t=new RegExp(e.source,`${e.flags.replace(/g/g,``)}g`),dg.set(e,t)),t}function*pg(e,t){if(e===``)return;if(typeof t==`string`){let n=t;if(n===``){yield{line:e,lineEndingLength:0,lineLengthWithEnding:e.length};return}let r=0;for(;;){let t=e.indexOf(n,r);if(t===-1){if(r===e.length)return;let t=e.slice(r);yield{line:t,lineEndingLength:0,lineLengthWithEnding:t.length};return}let i=e.slice(r,t),a=n.length;yield{line:i,lineEndingLength:a,lineLengthWithEnding:i.length+a},r=t+n.length}}let n=t.global?t:fg(t),r=0;for(n.lastIndex=0;;){let t=n.exec(e);if(!t)break;let i=t.index,a=i+t[0].length,o=e.slice(r,i),s=t[0].length;yield{line:o,lineEndingLength:s,lineLengthWithEnding:o.length+s},r=a,t[0].length===0&&n.lastIndex++}if(r===e.length)return;let i=e.slice(r);yield{line:i,lineEndingLength:0,lineLengthWithEnding:i.length}}function mg(e){return typeof e==`boolean`?{isValid:e,reason:`Validation failed`}:{isValid:e.isValid,reason:e.reason||`Validation failed`}}function hg(e,t,n){return Yh(e,null,t||!1,n)}function gg(e){return e.length>0?e:void 0}function _g(e,t){return{delimiter:e.delimiter,linebreak:e.linebreak,aborted:!1,truncated:t.truncated,cursor:t.dataRowCount,fields:t.headerRow?dh(t.headerRow):void 0,renamedHeaders:t.renamedHeadersForMeta}}function vg(e,t){return t.trimFieldIsIdentity?e:e.map(t.trimField)}function*yg(e,t,n,r){if(e===``)return;let i=0;for(let{line:a,lineLengthWithEnding:o}of pg(e,t.linebreakRegex)){if(n.lineNumber++,t.toLine!==void 0&&n.lineNumber>t.toLine){n.truncated=!0;break}if(n.lineNumber<=t.skipLines){i+=o;continue}if(a===``&&t.shouldSkipEmpty){i+=o;continue}if(t.maxRowBytes!==void 0&&kh(a)>t.maxRowBytes)throw Error(`Row exceeds the maximum size of ${t.maxRowBytes} bytes`);t.infoOption&&(n.currentRowStartLine=n.lineNumber,n.currentRowStartOffset=i),t.rawOption&&(n.currentRawRow=a);let e=vg(a.split(t.delimiter),t);if(t.infoOption&&(n.currentRowQuoted=Lh(e.length)),t.comment&&e[0]?.trimStart().startsWith(t.comment)){i+=o;continue}if(t.shouldSkipEmpty&&nh(e,t.shouldSkipEmpty)){i+=o;continue}let s=tg(e,n,t,r,n.lineNumber);if(i+=o,s.stop){yield s;return}(!s.skipped||s.error)&&(yield s),Fh(n,t.infoOption,t.rawOption,n.lineNumber+1,i)}}function*bg(e,t,n,r){let i=Mh(t),a=e.length,o=0;for(t.infoOption&&(n.currentRowStartOffset=0);o<a;){let a=lg(e,o,i,!0);if(a.fields.length===0&&a.endPos===o)break;let s=vg(a.fields,t),c=n.lineNumber+1;{let t=a.rawStart,r=a.rawEnd,i=1;for(let n=t;n<r;n++){let t=e.charCodeAt(n);t===10?i++:t===13&&(n+1<r&&e.charCodeAt(n+1)===10&&n++,i++)}n.lineNumber+=i}if(t.toLine!==void 0&&n.lineNumber>t.toLine){n.truncated=!0;break}let l=a.rawEnd;if(n.lineNumber<=t.skipLines){o=a.endPos;continue}if(t.maxRowBytes!==void 0&&kh(e.slice(a.rawStart,l))>t.maxRowBytes)throw Error(`Row exceeds the maximum size of ${t.maxRowBytes} bytes`);if(t.comment&&s[0]?.trimStart().startsWith(t.comment)){o=a.endPos;continue}if(t.shouldSkipEmpty&&nh(s,t.shouldSkipEmpty)){o=a.endPos;continue}t.infoOption&&(n.currentRowStartLine=c,n.currentRowStartOffset=a.rawStart,n.currentRowQuoted=a.quoted),t.rawOption&&(n.currentRawRow=e.slice(a.rawStart,l)),a.unterminatedQuote&&r.push({code:`MissingQuotes`,message:`Quoted field unterminated`,line:n.lineNumber});let u=tg(s,n,t,r,n.lineNumber);if(u.stop){yield u;return}(!u.skipped||u.error)&&(yield u),o=a.endPos,t.infoOption&&(n.currentRowStartOffset=a.endPos)}}function xg(e,t={}){let{config:n,processedInput:r}=jh(e,t),i=Ph(n),a=[],o=[],s=n.fastMode?yg(r,n,i,a):bg(r,n,i,a);if(!i.useHeaders){let e=[];for(let r of s){if(r.row&&!r.skipped){let i=r.row;if(t.rowTransform){let e=t.rowTransform(i);if(e==null)continue;i=e}if(t.validate){let{isValid:e,reason:n}=mg(t.validate(i));if(!e){o.push({row:i,reason:n});continue}}(n.dynamicTyping||n.castDate)&&(i=hg(i,n.dynamicTyping,n.castDate)),n.infoOption&&r.info?e.push({record:i,info:r.info}):e.push(i)}else r.row&&r.skipped&&r.error&&o.push({row:r.row,reason:r.reason||r.error.message});if(r.stop)break}let r=_g(n,i);return n.infoOption||t.validate?{headers:void 0,rows:e,invalidRows:gg(o),errors:gg(a),meta:r}:e}let c=[];for(let e of s){if(e.row&&!e.skipped){let r=$h(e.row,i,n);if(e.extras&&e.extras.length>0&&(r._extra=e.extras),t.rowTransform){let e=t.rowTransform(r);if(e==null)continue;r=e}if(t.validate){let{isValid:n,reason:i}=mg(t.validate(r));if(!n){o.push({row:e.row,reason:i});continue}}n.infoOption&&e.info?c.push({record:r,info:e.info}):c.push(r)}else e.row&&e.skipped&&e.error&&o.push({row:e.row,reason:e.reason||e.error.message});if(e.stop)break}let l=_g(n,i),{objname:u}=t;if(u&&i.headerRow){let e={};for(let t of c){let r=(n.infoOption?t.record:t)[u],i=r==null?``:String(r);e[i]=t}return{headers:l.fields,rows:e,invalidRows:gg(o),errors:gg(a),meta:l}}return{headers:l.fields,rows:c,invalidRows:gg(o),errors:gg(a),meta:l}}let Sg=Symbol.for(`csv.FormattedValue`);function Cg(e){return typeof e==`object`&&!!e&&e[Sg]===!0}function wg(e){return e.length<2}function Tg(e){return e.length<2}var Eg=class extends Qf{constructor(e={}){super({objectMode:e.objectMode!==!1}),this.parseErrorsSink=[],this.buffer=``,this._rowTransform=null,this._rowValidator=null,this.autoDetectDelimiter=!1,this.delimiterDetected=!1,this.chunkBuffer=[],this.totalRowsProcessed=0,this.isFirstChunk=!0,this.chunkAborted=!1,this.beforeFirstChunkApplied=!1,this.bomStripped=!1,this.toLineReached=!1,this.headersEmitted=!1,this.totalCharsProcessed=0,this.backpressure=!1,this.pendingCallback=null,this.options=e,this.chunkSize=e.chunkSize??1e3,this.decoder=new TextDecoder(e.encoding||`utf-8`),this.autoDetectDelimiter=(e.delimiter??`,`)===``;let{config:t}=Ah({options:e});this.parseConfig=t,this.parseState=Ph(t),this.scanner=ug(Mh(t)),e.rowTransform&&this.transform(e.rowTransform),e.validate&&this.validate(e.validate)}_read(e){if(this.backpressure&&this.pendingCallback){this.backpressure=!1;let e=this.pendingCallback;this.pendingCallback=null,e()}}transform(e){if(typeof e!=`function`)throw TypeError(`The transform should be a function`);return wg(e)?this._rowTransform=(t,n)=>{try{n(null,e(t))}catch(e){n(e)}}:this._rowTransform=e,this}validate(e){if(typeof e!=`function`)throw TypeError(`The validate should be a function`);return Tg(e)?this._rowValidator=(t,n)=>{try{let r=e(t);typeof r==`boolean`?n(null,r):n(null,r.isValid,r.reason)}catch(e){n(e)}}:this._rowValidator=e,this}_transform(e,t,n){if(this.chunkAborted||this.toLineReached){n();return}try{let t=typeof e==`string`?e:this.decoder.decode(e,{stream:!0});if(this.buffer+=t,!this.beforeFirstChunkApplied&&this.options.beforeFirstChunk){this.beforeFirstChunkApplied=!0;let e=this.options.beforeFirstChunk(this.buffer);typeof e==`string`&&(this.buffer=e)}if(this.bomStripped||=(this.buffer=_h(this.buffer),!0),this.autoDetectDelimiter&&!this.delimiterDetected){let e=this.options.comment,t=!1,n=0,r=this.buffer.length;for(;n<r;){let i=n;for(;i<r&&this.buffer[i]!==`
422
422
  `&&this.buffer[i]!==`\r`;)i++;let a=this.buffer.slice(n,i).trim();if(a!==``&&(!e||!a.startsWith(e))){t=!0;break}if(n=i,n<r&&this.buffer[n]===`\r`&&n++,n<r&&this.buffer[n]===`
423
- `&&n++,n===i)break}if(t){let e=this.options.skipEmptyLines;this.parseConfig.delimiter=_h(this.buffer,this.parseConfig.quote||`"`,this.options.delimitersToGuess,this.options.comment,e),this.delimiterDetected=!0,this.emit(`delimiter`,this.parseConfig.delimiter),this.scanner=sg(kh(this.parseConfig))}}this.processBuffer(n)}catch(e){n(e)}}_flush(e){if(this.chunkAborted||this.toLineReached){e();return}try{let t=this.decoder.decode();if(t&&(this.buffer+=t),this.buffer){this.processBuffer(t=>{if(t){e(t);return}this.flushCurrentRow(t=>{if(t){e(t);return}this.flushFinalChunk(e)})});return}this.flushCurrentRow(t=>{if(t){e(t);return}this.flushFinalChunk(e)})}catch(t){e(t)}}_destroy(e,t){this.pendingCallback=null,this.backpressure=!1,this.buffer=``,this.chunkBuffer=[],this.scanner.reset(),t(e)}flushCurrentRow(e){if(this.toLineReached){e();return}if(this.parseConfig.fastMode){this.flushFastModeRemainder(e);return}let t=this.scanner.flush();if(!t||t.fields.length===0){e();return}let n=this.parseConfig.trimFieldIsIdentity?t.fields.slice():t.fields.map(this.parseConfig.trimField),r=[],i=this._handleParsedRow({fields:n,charLength:0,raw:t.raw,quoted:t.quoted,pendingRows:r,shouldSkipEmpty:this.options.skipEmptyLines||!1,skipLines:this.options.skipLines??0,callback:e});i===`stop`||i===`error`||this.processPendingRows(r,e)}flushFastModeRemainder(e){let t=this.buffer;if(this.buffer=``,t.endsWith(`\r`)&&(t=t.slice(0,-1)),t===``){e();return}let n=[],r=t.split(this.parseConfig.delimiter),i=this.parseConfig.trimFieldIsIdentity?r:r.map(this.parseConfig.trimField),a=this.parseConfig.infoOption?Ph(i.length):void 0,o=this._handleParsedRow({fields:i,charLength:0,raw:t,quoted:a,pendingRows:n,shouldSkipEmpty:this.options.skipEmptyLines||!1,skipLines:this.options.skipLines??0,callback:e});o===`stop`||o===`error`||this.processPendingRows(n,e)}pushBufferedRows(e){let t=this.options.objectMode===!1;for(let n of e)if(!this.push(t?JSON.stringify(n):n))return!1;return!0}pushRow(e){let t=this.options.objectMode===!1;return this.push(t?JSON.stringify(e):e)}invokeChunkCallback(e,t,n){let r=this.options.chunk(e,t);r instanceof Promise?r.then(e=>{e===!1&&(this.chunkAborted=!0),n()}).catch(e=>n(e)):(r===!1&&(this.chunkAborted=!0),n())}flushFinalChunk(e){if(this.chunkBuffer.length>0&&this.options.chunk){let t=this.chunkBuffer.length,n={cursor:this.totalRowsProcessed-t,rowCount:t,isFirstChunk:this.isFirstChunk,isLastChunk:!0};this.pushBufferedRows(this.chunkBuffer);let r=this.chunkBuffer;this.chunkBuffer=[],this.invokeChunkCallback(r,n,e)}else e()}processBuffer(e){let{skipEmptyLines:t=!1,skipLines:n=0}=this.options,r=t;if(this.parseConfig.fastMode){this.processBufferFastMode(e,r);return}let i=[];this.scanner.feed(this.buffer),this.buffer=``;let a;for(;(a=this.scanner.nextRow())!==null;){let t=a.raw,o=(a.raw?.length??0)+(a.newline?.length??0),s=this.parseConfig.trimFieldIsIdentity?a.fields.slice():a.fields.map(this.parseConfig.trimField),c=this._handleParsedRow({fields:s,charLength:o,raw:t,quoted:a.quoted,pendingRows:i,shouldSkipEmpty:r,skipLines:n,callback:e});if(c===`stop`||c===`error`)return}this.processPendingRows(i,e)}getFastModeCompleteDataEnd(e){let{linebreakRegex:t}=this.parseConfig;if(typeof t==`string`){let n=t;if(n===``)return-1;let r=e.length-n.length;if(r<0)return-1;let i=e.lastIndexOf(n,r);return i===-1?-1:i+n.length}if(t===xh){let t=e.lastIndexOf(`
424
- `),n=e.lastIndexOf(`\r`),r;return r=n>t?n===e.length-1?t:n:t,r===-1?-1:r+1}let n=new RegExp(t.source,`${t.flags}g`),r=-1;for(let t=n.exec(e);t;t=n.exec(e))r=t.index+t[0].length,t[0].length===0&&n.lastIndex++;return r}processBufferFastMode(e,t){let{skipLines:n=0}=this.options,r=[],i=this.getFastModeCompleteDataEnd(this.buffer);if(i===-1){e();return}let a=this.buffer.slice(0,i);this.buffer=this.buffer.slice(i);for(let{line:i,lineLengthWithEnding:o}of ug(a,this.parseConfig.linebreakRegex)){if(i===``&&t){this.parseState.lineNumber++,this.totalCharsProcessed+=o;continue}let a=i.split(this.parseConfig.delimiter),s=this.parseConfig.trimFieldIsIdentity?a:a.map(this.parseConfig.trimField),c=this.parseConfig.infoOption?Ph(s.length):void 0,l=this._handleParsedRow({fields:s,charLength:o,raw:i,quoted:c,pendingRows:r,shouldSkipEmpty:t,skipLines:n,callback:e});if(l===`stop`||l===`error`)return}this.processPendingRows(r,e)}buildRow(e,t){let{dynamicTyping:n,castDate:r,groupColumnsByName:i=!1}=this.options,a;if(this.options.headers&&this.parseState.headerRow){let t=oh(e,this.parseState.headerRow,this.parseState.originalHeaders,i);a=n||r?Gh(t,n||!1,r):t}else a=n||r?Kh(e,this.parseState.headerRow?ch(this.parseState.headerRow):null,n||!1,r):e;return this.parseConfig.infoOption?(t||={index:0,line:this.parseState.currentRowStartLine,offset:this.parseState.currentRowStartOffset,quoted:[...this.parseState.currentRowQuoted],raw:this.parseConfig.rawOption?this.parseState.currentRawRow:void 0},{record:a,info:t}):a}_handleParsedRow(e){let{fields:t,charLength:n,raw:r,quoted:i,pendingRows:a,shouldSkipEmpty:o,skipLines:s,callback:c}=e,l=this.parseState.lineNumber+1;if(r!==void 0){let e=1;for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);n===10?e++:n===13&&(t+1<r.length&&r.charCodeAt(t+1)===10&&t++,e++)}this.parseState.lineNumber+=e}else this.parseState.lineNumber++;let{toLine:u}=this.options;return u!==void 0&&this.parseState.lineNumber>u?(this.toLineReached=!0,this.totalCharsProcessed+=n,this.processPendingRows(a,c),`stop`):this.parseState.lineNumber<=s?(this.totalCharsProcessed+=n,`skip`):(this.parseConfig.infoOption&&(this.parseState.currentRowStartLine=l,this.parseState.currentRowStartOffset=this.totalCharsProcessed,i&&(this.parseState.currentRowQuoted=i)),this.totalCharsProcessed+=n,r!==void 0&&this.parseConfig.maxRowBytes!==void 0&&Eh(r)>this.parseConfig.maxRowBytes?(c(Error(`Row exceeds the maximum size of ${this.parseConfig.maxRowBytes} bytes`)),`error`):(this.parseConfig.rawOption&&r!==void 0&&(this.parseState.currentRawRow=r),this.shouldSkipRow(t,o)?`skip`:this.processCompletedRow(t,a)?`continue`:(this.processPendingRows(a,c),`stop`)))}processCompletedRow(e,t){let n=Qh(e,this.parseState,this.parseConfig,this.parseErrorsSink,this.parseState.lineNumber);if(this.parseErrorsSink.length=0,this.emitHeaders(),n.reason&&this.emit(`data-invalid`,e,n.reason),n.stop)return!1;if(n.skipped)return!0;if(n.row){let e=this.buildRow(n.row,n.info);if(n.extras&&n.extras.length>0){let t=this.parseConfig.infoOption?e.record:e;t._extra=n.extras}t.push(e)}return!0}emitHeaders(){!this.headersEmitted&&this.parseState.headerRow&&(this.headersEmitted=!0,this.emit(`headers`,ch(this.parseState.headerRow)))}shouldSkipRow(e,t){return Zh(e,this.parseConfig.comment,t,!1)}processPendingRows(e,t){if(e.length===0){t();return}if(this.chunkAborted){t();return}if(!this._rowTransform&&!this._rowValidator){let n=0,r=()=>{for(;n<e.length&&!this.chunkAborted;){let i=e[n++];if(this.options.chunk){if(this.chunkBuffer.push(i),this.totalRowsProcessed++,this.chunkBuffer.length>=this.chunkSize){this.flushChunk(e=>{if(e){t(e);return}if(this.chunkAborted){t();return}n%1e3==0?setTimeout(r,0):r()});return}}else if(!this.pushRow(i)){this.backpressure=!0,this.pendingCallback=()=>r();return}}t()};r();return}let n=0,r=()=>{if(n>=e.length){t();return}let i=e[n++];this.transformAndValidateRow(i,(e,i)=>{if(e){t(e);return}if(i&&i.isValid&&i.row!==null){if(this.options.chunk){if(this.chunkBuffer.push(i.row),this.totalRowsProcessed++,this.chunkBuffer.length>=this.chunkSize){this.flushChunk(e=>{if(e){t(e);return}n%1e3==0?setTimeout(r,0):r()});return}}else if(!this.pushRow(i.row)){this.backpressure=!0,this.pendingCallback=()=>r();return}}else i&&!i.isValid&&this.emit(`data-invalid`,i.row,i.reason);n%1e3==0?setTimeout(r,0):r()})};r()}flushChunk(e){if(this.chunkBuffer.length===0||!this.options.chunk){e();return}let t=this.chunkBuffer.length,n={cursor:this.totalRowsProcessed-t,rowCount:t,isFirstChunk:this.isFirstChunk,isLastChunk:!1};this.isFirstChunk=!1;let r=this.chunkBuffer;this.chunkBuffer=[],this.pushBufferedRows(r),this.invokeChunkCallback(r,n,e)}transformAndValidateRow(e,t){this._rowTransform?this._rowTransform(e,(e,n)=>{if(e){t(e);return}if(n==null){t(null,{row:null,isValid:!0});return}this.validateRow(n,t)}):this.validateRow(e,t)}validateRow(e,t){this._rowValidator?this._rowValidator(e,(n,r,i)=>{if(n){t(n);return}t(null,{row:e,isValid:r??!1,reason:i})}):t(null,{row:e,isValid:!0})}};function wg(e={}){return new Cg(e)}function Tg(e){return e.replace(/[\\\]^-]/g,`\\$&`)}function Eg(e){let{quote:t,delimiter:n,escape:r}=e,{enabled:i,char:a}=uh(t),o=dh(r,a);if(!i)return{needsQuoteRegex:null,escapeQuoteRegex:null,escapedQuote:``,quoteEnabled:!1,quote:``,escape:``,delimiter:n,useFastCheck:!1};let s=o.char||a,c=n.length===1&&a.length===1&&s.length===1;return{needsQuoteRegex:c?null:(()=>{let e=`${Tg(n)}${Tg(a)}${s===a?``:Tg(s)}\r\n`;return RegExp(`[${e}]`)})(),escapeQuoteRegex:s===a?new RegExp(lh(a),`g`):RegExp(`${lh(a)}|${lh(s)}`,`g`),escapedQuote:s+a,quoteEnabled:!0,quote:a,escape:s,delimiter:n,useFastCheck:c}}function Dg(e){return e===!0?()=>!0:e===!1||e===void 0?()=>!1:Array.isArray(e)?t=>e[t]===!0:(t,n)=>n?e[n]===!0:!1}function Og(e){let{delimiter:t=`,`,lineEnding:n=`
425
- `,quote:r=`"`,escape:i,quoteColumns:a=!1,quoteHeaders:o=!1,writeHeaders:s,bom:c=!1,trailingNewline:l=!1,escapeFormulae:u=!1,decimalSeparator:d=`.`,typeTransform:f}=e;if(d!==`.`&&d!==`,`)throw new th(`Invalid decimalSeparator: "${d}". Must be "." or ",".`);if(d===t)throw new th(`decimalSeparator cannot be the same as delimiter`);let p=Eg({quote:r,delimiter:t,escape:i});return{delimiter:t,lineEnding:n,quoteAll:a===!0,escapeFormulae:u,decimalSeparator:d,writeHeaders:s??!0,bom:c,trailingNewline:l,typeTransform:f,regex:p,shouldQuoteColumn:Dg(a),shouldQuoteHeader:Dg(o)}}let kg=/^-?\d+(,\d+)?([eE][+-]?\d+)?$/;function Ag(e,t){return t===`,`?String(e).replace(`.`,`,`):String(e)}function jg(e,t){let n=e.trim();return t===`,`&&kg.test(n)?Number(n.replace(`,`,`.`)):Number(n)}function Mg(e,t,n){if(e==null)return;let r=typeof e;if(r===`boolean`&&t.boolean)return t.boolean(e,n);if(e instanceof Date&&t.date)return t.date(e,n);if(r===`number`&&t.number)return t.number(e,n);if(r===`bigint`&&t.bigint)return t.bigint(e,n);if(r===`string`&&t.string)return t.string(e,n);if(r===`object`&&!Array.isArray(e)&&!(e instanceof Date)&&t.object)return t.object(e,n)}function Ng(e,t){if(e==null)return``;if(typeof e==`number`)return Ag(e,t);if(e instanceof Date)return e.toISOString();if(typeof e==`bigint`)return String(e);if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`object`)try{return JSON.stringify(e)}catch{return`[object Object]`}return String(e)}function Pg(e,t,n,r){return e.indexOf(t)!==-1||e.indexOf(n)!==-1||r!==n&&e.indexOf(r)!==-1||e.indexOf(`
426
- `)!==-1||e.indexOf(`\r`)!==-1}function Fg(e,t,n){let{index:r,header:i,isHeader:a,outputRowIndex:o,forceQuote:s,quoteAll:c,escapeFormulae:l,decimalSeparator:u,transform:d}=n,f,p;if(!a&&d){let t=Mg(e,d,{column:i??r,index:o});t==null?f=Ng(e,u):bg(t)?(f=t.value,p=t.quote):f=t}else f=Ng(e,u);if(l&&p!==!1&&hh(f)&&(f=`'`+f),!t.quoteEnabled)return f;let m;if(m=p===void 0?c||s||(t.useFastCheck?Pg(f,t.delimiter,t.quote,t.escape):t.needsQuoteRegex.test(f)):p,m){let e;return e=t.escape===t.quote?f.replace(t.escapeQuoteRegex,t.escapedQuote):f.replace(t.escapeQuoteRegex,e=>e===t.quote?t.escape+t.quote:t.escape+t.escape),t.quote+e+t.quote}return f}function Ig(e,t,n){let{quoteLookup:r,delimiter:i,headers:a,isHeader:o,outputRowIndex:s,quoteAll:c,escapeFormulae:l,decimalSeparator:u,transform:d}=n,f=e.length;if(f===0)return``;let p={index:0,header:a?.[0],isHeader:o,outputRowIndex:s,forceQuote:r(0,a?.[0]),quoteAll:c,escapeFormulae:l,decimalSeparator:u,transform:d},m=Fg(e[0],t,p);for(let n=1;n<f;n++)p.index=n,p.header=a?.[n],p.forceQuote=r(n,p.header),m+=i+Fg(e[n],t,p);return m}function Lg(e,t,n){if(!e.typeTransform?.row)return t;let r=e.typeTransform.row(t,n);return r===null?null:r}function Rg(e,t,n){let{headers:r,columns:i}=t;if(e.length===0)return i&&i.length>0?{keys:null,displayHeaders:i.map(e=>typeof e==`string`?e:e.header??e.key),rows:[]}:Array.isArray(r)?{keys:r,displayHeaders:r,rows:[]}:{keys:null,displayHeaders:null,rows:[]};let a=e[0];if(i&&i.length>0){let t=Zm(i),r=t.keys,a=t.headers,o=[];for(let t=0;t<e.length;t++){let i=Lg(n,e[t],t);if(i===null)continue;let a;a=Vm(i)?Km(i,r):Array.isArray(i)?i:r.map(e=>i[e]),o.push(a)}return{keys:r,displayHeaders:a,rows:o}}if(Vm(a)){let t=e,i=r===!0?Wm(t[0]):Array.isArray(r)?r:null,a=[];for(let e=0;e<t.length;e++){let r=Lg(n,t[e],e);if(r===null)continue;let o;o=Vm(r)?i?Km(r,i):Um(r):Array.isArray(r)?r:i?i.map(e=>r[e]):Object.values(r),a.push(o)}return{keys:i,displayHeaders:i,rows:a}}if(!Array.isArray(a)&&typeof a==`object`){let t=e,i=r===!0?Object.keys(t[0]):Array.isArray(r)?r:null,a=[];for(let e=0;e<t.length;e++){let r=Lg(n,t[e],e);if(r===null)continue;let o=i?i.map(e=>r[e]):Object.values(r);a.push(o)}return{keys:i,displayHeaders:i,rows:a}}let o=e,s=Array.isArray(r)?r:null,c=[];for(let e=0;e<o.length;e++){let t=Lg(n,o[e],e);t!==null&&c.push(t)}return{keys:s,displayHeaders:s,rows:c}}function zg(e,t={}){let n=Og(t),{displayHeaders:r,rows:i}=Rg(e,t,n),a=[],o=r?Ym(r):void 0;o&&n.writeHeaders&&a.push(Ig(o,n.regex,{quoteLookup:n.shouldQuoteHeader,delimiter:n.delimiter,headers:o,isHeader:!0,outputRowIndex:0,quoteAll:n.quoteAll,escapeFormulae:n.escapeFormulae,decimalSeparator:n.decimalSeparator,transform:void 0}));for(let e=0;e<i.length;e++)a.push(Ig(i[e],n.regex,{quoteLookup:n.shouldQuoteColumn,delimiter:n.delimiter,headers:o,isHeader:!1,outputRowIndex:e,quoteAll:n.quoteAll,escapeFormulae:n.escapeFormulae,decimalSeparator:n.decimalSeparator,transform:n.typeTransform}));let s=n.bom?``:``;return s+=a.join(n.lineEnding),a.length>0&&n.trailingNewline&&(s+=n.lineEnding),s}var Bg=class extends Yf{constructor(e={}){super({objectMode:e.objectMode!==!1,writableObjectMode:e.objectMode!==!1}),this.headerWritten=!1,this.keys=null,this.displayHeaders=null,this.sourceRowIndex=0,this.outputRowIndex=0,this.options=e,this.formatConfig=Og(e);let t=this.formatConfig;this.rowOptions={quoteLookup:t.shouldQuoteColumn,delimiter:t.delimiter,headers:void 0,isHeader:!1,outputRowIndex:0,quoteAll:t.quoteAll,escapeFormulae:t.escapeFormulae,decimalSeparator:t.decimalSeparator,transform:t.typeTransform};let n=Zm(e.columns);n?(this.keys=n.keys,this.displayHeaders=n.headers):Array.isArray(e.headers)&&(this.keys=e.headers,this.displayHeaders=e.headers),this.displayHeaders&&=Ym(this.displayHeaders)}detectHeadersFromRow(e){let t=Jm(e);t.length>0&&(this.keys=t,this.displayHeaders=Ym(t))}_transform(e,t,n){try{!this.headerWritten&&this.formatConfig.bom&&this.push(``),this.headerWritten||=(this.options.headers===!0&&!this.keys&&this.detectHeadersFromRow(e),this.formatConfig.writeHeaders&&this.displayHeaders&&this.push(this.formatRow(this.displayHeaders,!0)),!0);let t=e,r=this.sourceRowIndex++;if(this.formatConfig.typeTransform?.row&&(t=this.formatConfig.typeTransform.row(e,r),t===null)){n();return}this.formatAndPush(t),this.outputRowIndex++,n()}catch(e){n(e)}}_destroy(e,t){this.keys=null,this.displayHeaders=null,t(e)}_flush(e){!this.headerWritten&&this.displayHeaders&&this.formatConfig.writeHeaders&&(this.formatConfig.bom&&this.push(``),this.push(this.formatRow(this.displayHeaders,!0)),this.headerWritten=!0);let t=this.formatConfig.writeHeaders&&this.displayHeaders||this.outputRowIndex>0;this.formatConfig.trailingNewline&&t&&this.push(this.formatConfig.lineEnding),e()}formatAndPush(e){let t=qm(e,this.keys);this.push(this.formatRow(t,!1))}formatRow(e,t=!1){let n=this.formatConfig,r=this.rowOptions;r.quoteLookup=t?n.shouldQuoteHeader:n.shouldQuoteColumn,r.headers=this.displayHeaders??void 0,r.isHeader=t,r.outputRowIndex=this.outputRowIndex;let i=Ig(e,n.regex,r);return t||!(n.writeHeaders&&this.displayHeaders)&&this.outputRowIndex===0?i:n.lineEnding+i}};function Vg(e={}){return new Bg(e)}let Hg=[`YYYY-MM-DD[T]HH:mm:ssZ`,`YYYY-MM-DD[T]HH:mm:ss`,`MM-DD-YYYY`,`YYYY-MM-DD`],Ug={true:!0,false:!1,"#N/A":{error:`#N/A`},"#REF!":{error:`#REF!`},"#NAME?":{error:`#NAME?`},"#DIV/0!":{error:`#DIV/0!`},"#NULL!":{error:`#NULL!`},"#VALUE!":{error:`#VALUE!`},"#NUM!":{error:`#NUM!`}};function Wg(e,t){let n=Lm.create(e),r=t?.decimalSeparator??`.`;return function(e){if(e===``)return null;if(typeof e==`string`){let t=jg(e,r);if(!Number.isNaN(t)&&t!==1/0)return t}else{let t=Number(e);if(!Number.isNaN(t)&&t!==1/0)return t}let t=n.parse(e);if(t)return t;let i=Ug[e];return i===void 0?e:i}}function Gg(e,t){let n=e?zm.create(e,{utc:t}):zm.iso(t);return function(e){if(e){if(e.text||e.hyperlink)return e.hyperlink||e.text||``;if(e.formula||e.result)return e.result||``;if(e.richText&&Array.isArray(e.richText))return e.richText.map(e=>e.text).join(``);if(e instanceof Date)return n.format(e);if(e.error)return e.error;if(typeof e==`object`)return JSON.stringify(e)}return e}}function Kg(e){return typeof e==`string`&&/^https?:\/\//i.test(e)}function qg(e){return typeof File<`u`&&e instanceof File}function Jg(e){return typeof Blob<`u`&&e instanceof Blob&&!qg(e)}function Yg(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t[Symbol.asyncIterator]==`function`||typeof t.pipe==`function`&&typeof t.on==`function`}function Xg(e){return{delimiter:e?.delimiter??`,`,quote:e?.quote,escape:e?.escape,delimitersToGuess:e?.delimitersToGuess,lineEnding:e?.lineEnding,headers:e?.headers,skipEmptyLines:e?.skipEmptyLines,trim:e?.trim,ltrim:e?.ltrim,rtrim:e?.rtrim,comment:e?.comment,maxRows:e?.maxRows,toLine:e?.toLine,skipLines:e?.skipLines,skipRows:e?.skipRows,columnMismatch:e?.columnMismatch,groupColumnsByName:e?.groupColumnsByName,relaxQuotes:e?.relaxQuotes,fastMode:e?.fastMode,info:e?.info,raw:e?.raw,skipRecordsWithError:e?.skipRecordsWithError,skipRecordsWithEmptyValues:e?.skipRecordsWithEmptyValues,onSkip:e?.onSkip}}function Zg(e){return{delimiter:e?.delimiter??`,`,quote:e?.quote,escape:e?.escape,lineEnding:e?.lineEnding,quoteColumns:e?.quoteColumns,quoteHeaders:e?.quoteHeaders,decimalSeparator:e?.decimalSeparator??`.`,escapeFormulae:e?.escapeFormulae,writeHeaders:e?.writeHeaders}}var Qg=class{static{this.Writer=Sp}static{this.Reader=ym}constructor(){this.category=``,this.company=``,this.created=new Date,this.description=``,this.keywords=``,this.manager=``,this.modified=this.created,this.properties={},this.calcProperties={},this._worksheets=[],this.subject=``,this.title=``,this.views=[],this.media=[],this.pivotTables=[],this._passthrough={},this._rawDrawings={},this._definedNames=new cr}importSheet(e,t){let n=this.addWorksheet(t??e.name);return n.model={...e.model,id:n.id,name:n.name},n}get xlsx(){return this._xlsx||=new pp(this),this._xlsx}async readCsv(e,t){return Kg(e)?this._readCsvUrl(e,t):qg(e)?this._readCsvFile(e,t):Jg(e)?this._readCsvBlob(e,t):Yg(e)?this._readCsvStream(e,t):this._readCsvContent(e,t)}writeCsv(e,t){return e&&typeof e.write==`function`?this._writeCsvStream(e,t):this._writeCsvString(e)}async writeCsvBuffer(e){let t=this._writeCsvString(e);return new TextEncoder().encode(t)}async readCsvFile(e,t){throw new v(`readCsvFile()`,`not available in browser. Use readCsv(url) or readCsv(file) instead.`)}async writeCsvFile(e,t){throw new v(`writeCsvFile()`,`not available in browser. Use writeCsv() and trigger a download instead.`)}createCsvReadStream(e){let t=this.getWorksheet(e?.sheetName||e?.sheetId),n=e?.map||Gg(e?.dateFormat,e?.dateUTC),r=e?.includeEmptyRows!==!1,i=new Bg(Zg(e));return t?setTimeout(()=>{let e=1;t.eachRow((t,a)=>{if(r)for(;e++<a-1;)i.write([]);let{values:o}=t;o.shift(),i.write(o.map(n)),e=a}),i.end()},0):setTimeout(()=>i.end(),0),i}createCsvWriteStream(e){let t=this.addWorksheet(e?.sheetName),n=e?.dateFormats??Hg,r=e?.decimalSeparator,i=e?.map||Wg(n,{decimalSeparator:r}),a=new Cg(Xg(e)),o=!!e?.headers,s=null;return o&&a.on(`headers`,e=>{s=e,t.addRow(e)}),a.on(`data`,e=>{if(o&&s&&e&&typeof e==`object`&&!Array.isArray(e)){let n=e,r=s.map(e=>n[e]);t.addRow(r.map(i))}else Array.isArray(e)&&t.addRow(e.map(i))}),a}_readCsvContent(e,t){let n;n=typeof e==`string`?e:e instanceof ArrayBuffer||e instanceof Uint8Array?new TextDecoder().decode(e):String(e);let r=this.addWorksheet(t?.sheetName),i=t?.dateFormats??Hg,a=t?.decimalSeparator,o=t?.map||Wg(i,{decimalSeparator:a}),s=vg(n,Xg(t));if(Array.isArray(s))for(let e of s)r.addRow(e.map(o));else{s.headers&&r.addRow(s.headers);for(let e of s.rows){let t=s.headers.map(t=>e[t]);r.addRow(t.map(o))}}return r}async _readCsvStream(e,t){let n=this.addWorksheet(t?.sheetName),r=t?.dateFormats??Hg,i=t?.decimalSeparator,a=t?.map||Wg(r,{decimalSeparator:i}),o=new Cg(Xg(t)),s=!!t?.headers,c=null;return new Promise((t,r)=>{s&&o.on(`headers`,e=>{c=e,n.addRow(e)}),o.on(`data`,e=>{if(s&&c&&e&&typeof e==`object`&&!Array.isArray(e)){let t=e,r=c.map(e=>t[e]);n.addRow(r.map(a))}else Array.isArray(e)&&n.addRow(e.map(a))}),op(e,o).then(()=>t(n)).catch(r)})}async _readCsvUrl(e,t){let n={method:t?.requestBody?`POST`:`GET`,headers:t?.requestHeaders,body:t?.requestBody,credentials:t?.withCredentials?`include`:`same-origin`,signal:t?.signal},r=await fetch(e,n);if(!r.ok)throw new ee(e,r.status,r.statusText);if(t?.stream&&r.body){let e=cp(r.body);return this._readCsvStream(e,t)}let i=await r.text();return this._readCsvContent(i,t)}async _readCsvFile(e,t){if((t?.stream||e.size>10*1024*1024)&&typeof e.stream==`function`){let n=cp(e.stream());return this._readCsvStream(n,t)}return new Promise((n,r)=>{let i=new FileReader,a=t?.encoding??`UTF-8`;t?.onProgress&&(i.onprogress=n=>{t.onProgress(n.loaded,n.total||e.size)}),i.onload=e=>{try{let r=e.target?.result;n(this._readCsvContent(r,t))}catch(e){r(e)}},i.onerror=()=>r(Error(`Failed to read file: ${e.name}`)),i.readAsText(e,a)})}async _readCsvBlob(e,t){let n=await e.text();return this._readCsvContent(n,t)}_writeCsvString(e){let t=this.getWorksheet(e?.sheetName||e?.sheetId);if(!t)return``;let n=e?.map||Gg(e?.dateFormat,e?.dateUTC),r=e?.includeEmptyRows!==!1,i=[],a=1;return t.eachRow((e,t)=>{if(r)for(;a++<t-1;)i.push([]);let{values:o}=e;o.shift(),i.push(o.map(n)),a=t}),zg(i,Zg(e))}async _writeCsvStream(e,t){let n=this.getWorksheet(t?.sheetName||t?.sheetId);if(!n){e.end();return}let r=t?.map||Gg(t?.dateFormat,t?.dateUTC),i=t?.includeEmptyRows!==!1,a=new Bg(Zg(t)),o=op(a,e),s=1;n.eachRow((e,t)=>{if(i)for(;s++<t-1;)a.write([]);let{values:n}=e;n.shift(),a.write(n.map(r)),s=t}),a.end(),await o}static createStreamWriter(e){return new Sp(e)}static createStreamReader(e,t){return new ym(e,t)}get nextId(){for(let e=1;e<this._worksheets.length;e++)if(!this._worksheets[e])return e;return this._worksheets.length||1}addWorksheet(e,t){let n=this.nextId,r=this._worksheets.reduce((e,t)=>(t&&t.orderNo)>e?t.orderNo:e,0),i=new nr({...t,id:n,name:e,orderNo:r+1,workbook:this});return this._worksheets[n]=i,i}removeWorksheetEx(e){delete this._worksheets[e.id]}removeWorksheet(e){let t=this.getWorksheet(e);t&&t.destroy()}getWorksheet(e){if(e===void 0)return this._worksheets.find(Boolean);if(typeof e==`number`)return this._worksheets[e];if(typeof e==`string`)return this._worksheets.find(t=>t&&t.name===e)}get worksheets(){return this._worksheets.slice(1).sort((e,t)=>e.orderNo-t.orderNo).filter(Boolean)}eachSheet(e){this.worksheets.forEach(t=>{e(t,t.id)})}get definedNames(){return this._definedNames}clearThemes(){this._themes=void 0}addImage(e){let t=this.media.length;return this.media.push({...e,type:`image`}),t}getImage(e){return this.media[Number(e)]}get model(){return{creator:this.creator||`Unknown`,lastModifiedBy:this.lastModifiedBy||`Unknown`,lastPrinted:this.lastPrinted,created:this.created,modified:this.modified,properties:this.properties,worksheets:this.worksheets.map(e=>e.model),sheets:this.worksheets.map(e=>e.model).filter(Boolean),definedNames:this._definedNames.model,views:this.views,company:this.company,manager:this.manager,title:this.title,subject:this.subject,keywords:this.keywords,category:this.category,description:this.description,language:this.language,revision:this.revision,contentStatus:this.contentStatus,themes:this._themes,media:this.media,pivotTables:this.pivotTables,calcProperties:this.calcProperties,passthrough:this._passthrough,rawDrawings:this._rawDrawings,defaultFont:this._defaultFont}}set model(e){this.creator=e.creator,this.lastModifiedBy=e.lastModifiedBy,this.lastPrinted=e.lastPrinted,this.created=e.created,this.modified=e.modified,this.company=e.company,this.manager=e.manager,this.title=e.title,this.subject=e.subject,this.keywords=e.keywords,this.category=e.category,this.description=e.description,this.language=e.language,this.revision=e.revision,this.contentStatus=e.contentStatus,this.properties=e.properties,this.calcProperties=e.calcProperties,this._worksheets=[],e.worksheets.forEach(t=>{let{id:n,name:r,state:i}=t,a=e.sheets&&e.sheets.findIndex(e=>e.id===n),o=this._worksheets[n]=new nr({id:n,name:r,orderNo:a===-1?void 0:a,state:i,workbook:this});o.model=t}),this._definedNames.model=e.definedNames,this.views=e.views,this._themes=e.themes,this.media=e.media||[],this.pivotTables=e.pivotTables||e.loadedPivotTables||[],this._passthrough=e.passthrough||{},this._rawDrawings=e.rawDrawings||{},this._defaultFont=e.defaultFont}};let $g=function(e){return e[e.Legal=5]=`Legal`,e[e.Executive=7]=`Executive`,e[e.A4=9]=`A4`,e[e.A5=11]=`A5`,e[e.B5=13]=`B5`,e[e.Envelope_10=20]=`Envelope_10`,e[e.Envelope_DL=27]=`Envelope_DL`,e[e.Envelope_C5=28]=`Envelope_C5`,e[e.Envelope_B5=34]=`Envelope_B5`,e[e.Envelope_Monarch=37]=`Envelope_Monarch`,e[e.Double_Japan_Postcard_Rotated=82]=`Double_Japan_Postcard_Rotated`,e[e.K16_197x273_mm=119]=`K16_197x273_mm`,e}({});return e.Anchor=We,e.BaseError=t,e.Cell=T,e.Column=Ve,e.ColumnOutOfBoundsError=p,e.CsvFormatterStream=Bg,e.CsvParserStream=Cg,e.DataValidations=tt,e.DateFormatter=zm,e.DateParser=Lm,e.DefinedNames=cr,e.DocumentType=ce,e.Enums=w,e.ErrorValue=ue,e.ExcelDownloadError=ee,e.ExcelError=l,e.ExcelFileError=y,e.ExcelNotSupportedError=v,e.ExcelStreamStateError=b,e.FormCheckbox=ct,e.FormulaType=oe,e.Image=Ge,e.ImageError=ne,e.InvalidAddressError=f,e.InvalidValueTypeError=g,e.MaxItemsExceededError=re,e.MergeConflictError=h,e.PaperSize=$g,e.PivotTableError=x,e.Range=C,e.ReadingOrder=le,e.RelationshipType=se,e.Row=Be,e.RowOutOfBoundsError=m,e.Table=et,e.TableError=te,e.ValueType=ae,e.Workbook=Qg,e.WorkbookReader=ym,e.WorkbookWriter=Sp,e.Worksheet=nr,e.WorksheetNameError=d,e.WorksheetReader=gm,e.WorksheetWriter=vp,e.XmlParseError=_,e.base64ToUint8Array=ut,e.concatUint8Arrays=O,e.createCsvFormatterStream=Vg,e.createCsvParserStream=wg,e.dateToExcel=dt,e.decodeCell=Qn,e.decodeCol=Jn,e.decodeRange=er,e.decodeRow=Xn,e.encodeCell=$n,e.encodeCol=Yn,e.encodeRange=tr,e.encodeRow=Zn,e.errorToJSON=o,e.excelToDate=ft,e.getErrorChain=s,e.getRootCause=c,e.getSupportedFormats=Bm,e.isExcelError=u,e.stringToUint8Array=tn,e.toError=a,e.toUint8Array=rn,e.uint8ArrayToBase64=It,e.uint8ArrayToString=nn,e.xmlDecode=xt,e.xmlEncode=E,e})({});
423
+ `&&n++,n===i)break}if(t){let e=this.options.skipEmptyLines;this.parseConfig.delimiter=bh(this.buffer,this.parseConfig.quote||`"`,this.options.delimitersToGuess,this.options.comment,e),this.delimiterDetected=!0,this.emit(`delimiter`,this.parseConfig.delimiter),this.scanner=ug(Mh(this.parseConfig))}}this.processBuffer(n)}catch(e){n(e)}}_flush(e){if(this.chunkAborted||this.toLineReached){e();return}try{let t=this.decoder.decode();if(t&&(this.buffer+=t),this.buffer){this.processBuffer(t=>{if(t){e(t);return}this.flushCurrentRow(t=>{if(t){e(t);return}this.flushFinalChunk(e)})});return}this.flushCurrentRow(t=>{if(t){e(t);return}this.flushFinalChunk(e)})}catch(t){e(t)}}_destroy(e,t){this.pendingCallback=null,this.backpressure=!1,this.buffer=``,this.chunkBuffer=[],this.scanner.reset(),t(e)}flushCurrentRow(e){if(this.toLineReached){e();return}if(this.parseConfig.fastMode){this.flushFastModeRemainder(e);return}let t=this.scanner.flush();if(!t||t.fields.length===0){e();return}let n=this.parseConfig.trimFieldIsIdentity?t.fields.slice():t.fields.map(this.parseConfig.trimField),r=[],i=this._handleParsedRow({fields:n,charLength:0,raw:t.raw,quoted:t.quoted,pendingRows:r,shouldSkipEmpty:this.options.skipEmptyLines||!1,skipLines:this.options.skipLines??0,callback:e});i===`stop`||i===`error`||this.processPendingRows(r,e)}flushFastModeRemainder(e){let t=this.buffer;if(this.buffer=``,t.endsWith(`\r`)&&(t=t.slice(0,-1)),t===``){e();return}let n=[],r=t.split(this.parseConfig.delimiter),i=this.parseConfig.trimFieldIsIdentity?r:r.map(this.parseConfig.trimField),a=this.parseConfig.infoOption?Lh(i.length):void 0,o=this._handleParsedRow({fields:i,charLength:0,raw:t,quoted:a,pendingRows:n,shouldSkipEmpty:this.options.skipEmptyLines||!1,skipLines:this.options.skipLines??0,callback:e});o===`stop`||o===`error`||this.processPendingRows(n,e)}pushBufferedRows(e){let t=this.options.objectMode===!1;for(let n of e)if(!this.push(t?JSON.stringify(n):n))return!1;return!0}pushRow(e){let t=this.options.objectMode===!1;return this.push(t?JSON.stringify(e):e)}invokeChunkCallback(e,t,n){let r=this.options.chunk(e,t);r instanceof Promise?r.then(e=>{e===!1&&(this.chunkAborted=!0),n()}).catch(e=>n(e)):(r===!1&&(this.chunkAborted=!0),n())}flushFinalChunk(e){if(this.chunkBuffer.length>0&&this.options.chunk){let t=this.chunkBuffer.length,n={cursor:this.totalRowsProcessed-t,rowCount:t,isFirstChunk:this.isFirstChunk,isLastChunk:!0};this.pushBufferedRows(this.chunkBuffer);let r=this.chunkBuffer;this.chunkBuffer=[],this.invokeChunkCallback(r,n,e)}else e()}processBuffer(e){let{skipEmptyLines:t=!1,skipLines:n=0}=this.options,r=t;if(this.parseConfig.fastMode){this.processBufferFastMode(e,r);return}let i=[];this.scanner.feed(this.buffer),this.buffer=``;let a;for(;(a=this.scanner.nextRow())!==null;){let t=a.raw,o=(a.raw?.length??0)+(a.newline?.length??0),s=this.parseConfig.trimFieldIsIdentity?a.fields.slice():a.fields.map(this.parseConfig.trimField),c=this._handleParsedRow({fields:s,charLength:o,raw:t,quoted:a.quoted,pendingRows:i,shouldSkipEmpty:r,skipLines:n,callback:e});if(c===`stop`||c===`error`)return}this.processPendingRows(i,e)}getFastModeCompleteDataEnd(e){let{linebreakRegex:t}=this.parseConfig;if(typeof t==`string`){let n=t;if(n===``)return-1;let r=e.length-n.length;if(r<0)return-1;let i=e.lastIndexOf(n,r);return i===-1?-1:i+n.length}if(t===wh){let t=e.lastIndexOf(`
424
+ `),n=e.lastIndexOf(`\r`),r;return r=n>t?n===e.length-1?t:n:t,r===-1?-1:r+1}let n=new RegExp(t.source,`${t.flags}g`),r=-1;for(let t=n.exec(e);t;t=n.exec(e))r=t.index+t[0].length,t[0].length===0&&n.lastIndex++;return r}processBufferFastMode(e,t){let{skipLines:n=0}=this.options,r=[],i=this.getFastModeCompleteDataEnd(this.buffer);if(i===-1){e();return}let a=this.buffer.slice(0,i);this.buffer=this.buffer.slice(i);for(let{line:i,lineLengthWithEnding:o}of pg(a,this.parseConfig.linebreakRegex)){if(i===``&&t){this.parseState.lineNumber++,this.totalCharsProcessed+=o;continue}let a=i.split(this.parseConfig.delimiter),s=this.parseConfig.trimFieldIsIdentity?a:a.map(this.parseConfig.trimField),c=this.parseConfig.infoOption?Lh(s.length):void 0,l=this._handleParsedRow({fields:s,charLength:o,raw:i,quoted:c,pendingRows:r,shouldSkipEmpty:t,skipLines:n,callback:e});if(l===`stop`||l===`error`)return}this.processPendingRows(r,e)}buildRow(e,t){let{dynamicTyping:n,castDate:r,groupColumnsByName:i=!1}=this.options,a;if(this.options.headers&&this.parseState.headerRow){let t=lh(e,this.parseState.headerRow,this.parseState.originalHeaders,i);a=n||r?Jh(t,n||!1,r):t}else a=n||r?Yh(e,this.parseState.headerRow?dh(this.parseState.headerRow):null,n||!1,r):e;return this.parseConfig.infoOption?(t||={index:0,line:this.parseState.currentRowStartLine,offset:this.parseState.currentRowStartOffset,quoted:[...this.parseState.currentRowQuoted],raw:this.parseConfig.rawOption?this.parseState.currentRawRow:void 0},{record:a,info:t}):a}_handleParsedRow(e){let{fields:t,charLength:n,raw:r,quoted:i,pendingRows:a,shouldSkipEmpty:o,skipLines:s,callback:c}=e,l=this.parseState.lineNumber+1;if(r!==void 0){let e=1;for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);n===10?e++:n===13&&(t+1<r.length&&r.charCodeAt(t+1)===10&&t++,e++)}this.parseState.lineNumber+=e}else this.parseState.lineNumber++;let{toLine:u}=this.options;return u!==void 0&&this.parseState.lineNumber>u?(this.toLineReached=!0,this.totalCharsProcessed+=n,this.processPendingRows(a,c),`stop`):this.parseState.lineNumber<=s?(this.totalCharsProcessed+=n,`skip`):(this.parseConfig.infoOption&&(this.parseState.currentRowStartLine=l,this.parseState.currentRowStartOffset=this.totalCharsProcessed,i&&(this.parseState.currentRowQuoted=i)),this.totalCharsProcessed+=n,r!==void 0&&this.parseConfig.maxRowBytes!==void 0&&kh(r)>this.parseConfig.maxRowBytes?(c(Error(`Row exceeds the maximum size of ${this.parseConfig.maxRowBytes} bytes`)),`error`):(this.parseConfig.rawOption&&r!==void 0&&(this.parseState.currentRawRow=r),this.shouldSkipRow(t,o)?`skip`:this.processCompletedRow(t,a)?`continue`:(this.processPendingRows(a,c),`stop`)))}processCompletedRow(e,t){let n=tg(e,this.parseState,this.parseConfig,this.parseErrorsSink,this.parseState.lineNumber);if(this.parseErrorsSink.length=0,this.emitHeaders(),n.reason&&this.emit(`data-invalid`,e,n.reason),n.stop)return!1;if(n.skipped)return!0;if(n.row){let e=this.buildRow(n.row,n.info);if(n.extras&&n.extras.length>0){let t=this.parseConfig.infoOption?e.record:e;t._extra=n.extras}t.push(e)}return!0}emitHeaders(){!this.headersEmitted&&this.parseState.headerRow&&(this.headersEmitted=!0,this.emit(`headers`,dh(this.parseState.headerRow)))}shouldSkipRow(e,t){return eg(e,this.parseConfig.comment,t,!1)}processPendingRows(e,t){if(e.length===0){t();return}if(this.chunkAborted){t();return}if(!this._rowTransform&&!this._rowValidator){let n=0,r=()=>{for(;n<e.length&&!this.chunkAborted;){let i=e[n++];if(this.options.chunk){if(this.chunkBuffer.push(i),this.totalRowsProcessed++,this.chunkBuffer.length>=this.chunkSize){this.flushChunk(e=>{if(e){t(e);return}if(this.chunkAborted){t();return}n%1e3==0?setTimeout(r,0):r()});return}}else if(!this.pushRow(i)){this.backpressure=!0,this.pendingCallback=()=>r();return}}t()};r();return}let n=0,r=()=>{if(n>=e.length){t();return}let i=e[n++];this.transformAndValidateRow(i,(e,i)=>{if(e){t(e);return}if(i&&i.isValid&&i.row!==null){if(this.options.chunk){if(this.chunkBuffer.push(i.row),this.totalRowsProcessed++,this.chunkBuffer.length>=this.chunkSize){this.flushChunk(e=>{if(e){t(e);return}n%1e3==0?setTimeout(r,0):r()});return}}else if(!this.pushRow(i.row)){this.backpressure=!0,this.pendingCallback=()=>r();return}}else i&&!i.isValid&&this.emit(`data-invalid`,i.row,i.reason);n%1e3==0?setTimeout(r,0):r()})};r()}flushChunk(e){if(this.chunkBuffer.length===0||!this.options.chunk){e();return}let t=this.chunkBuffer.length,n={cursor:this.totalRowsProcessed-t,rowCount:t,isFirstChunk:this.isFirstChunk,isLastChunk:!1};this.isFirstChunk=!1;let r=this.chunkBuffer;this.chunkBuffer=[],this.pushBufferedRows(r),this.invokeChunkCallback(r,n,e)}transformAndValidateRow(e,t){this._rowTransform?this._rowTransform(e,(e,n)=>{if(e){t(e);return}if(n==null){t(null,{row:null,isValid:!0});return}this.validateRow(n,t)}):this.validateRow(e,t)}validateRow(e,t){this._rowValidator?this._rowValidator(e,(n,r,i)=>{if(n){t(n);return}t(null,{row:e,isValid:r??!1,reason:i})}):t(null,{row:e,isValid:!0})}};function Dg(e={}){return new Eg(e)}function Og(e){return e.replace(/[\\\]^-]/g,`\\$&`)}function kg(e){let{quote:t,delimiter:n,escape:r}=e,{enabled:i,char:a}=ph(t),o=mh(r,a);if(!i)return{needsQuoteRegex:null,escapeQuoteRegex:null,escapedQuote:``,quoteEnabled:!1,quote:``,escape:``,delimiter:n,useFastCheck:!1};let s=o.char||a,c=n.length===1&&a.length===1&&s.length===1;return{needsQuoteRegex:c?null:(()=>{let e=`${Og(n)}${Og(a)}${s===a?``:Og(s)}\r\n`;return RegExp(`[${e}]`)})(),escapeQuoteRegex:s===a?new RegExp(fh(a),`g`):RegExp(`${fh(a)}|${fh(s)}`,`g`),escapedQuote:s+a,quoteEnabled:!0,quote:a,escape:s,delimiter:n,useFastCheck:c}}function Ag(e){return e===!0?()=>!0:e===!1||e===void 0?()=>!1:Array.isArray(e)?t=>e[t]===!0:(t,n)=>n?e[n]===!0:!1}function jg(e){let{delimiter:t=`,`,lineEnding:n=`
425
+ `,quote:r=`"`,escape:i,quoteColumns:a=!1,quoteHeaders:o=!1,writeHeaders:s,bom:c=!1,trailingNewline:l=!1,escapeFormulae:u=!1,decimalSeparator:d=`.`,typeTransform:f}=e;if(d!==`.`&&d!==`,`)throw new ih(`Invalid decimalSeparator: "${d}". Must be "." or ",".`);if(d===t)throw new ih(`decimalSeparator cannot be the same as delimiter`);let p=kg({quote:r,delimiter:t,escape:i});return{delimiter:t,lineEnding:n,quoteAll:a===!0,escapeFormulae:u,decimalSeparator:d,writeHeaders:s??!0,bom:c,trailingNewline:l,typeTransform:f,regex:p,shouldQuoteColumn:Ag(a),shouldQuoteHeader:Ag(o)}}let Mg=/^-?\d+(,\d+)?([eE][+-]?\d+)?$/;function Ng(e,t){return t===`,`?String(e).replace(`.`,`,`):String(e)}function Pg(e,t){let n=e.trim();return t===`,`&&Mg.test(n)?Number(n.replace(`,`,`.`)):Number(n)}function Fg(e,t,n){if(e==null)return;let r=typeof e;if(r===`boolean`&&t.boolean)return t.boolean(e,n);if(e instanceof Date&&t.date)return t.date(e,n);if(r===`number`&&t.number)return t.number(e,n);if(r===`bigint`&&t.bigint)return t.bigint(e,n);if(r===`string`&&t.string)return t.string(e,n);if(r===`object`&&!Array.isArray(e)&&!(e instanceof Date)&&t.object)return t.object(e,n)}function Ig(e,t){if(e==null)return``;if(typeof e==`number`)return Ng(e,t);if(e instanceof Date)return e.toISOString();if(typeof e==`bigint`)return String(e);if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`object`)try{return JSON.stringify(e)}catch{return`[object Object]`}return String(e)}function Lg(e,t,n,r){return e.indexOf(t)!==-1||e.indexOf(n)!==-1||r!==n&&e.indexOf(r)!==-1||e.indexOf(`
426
+ `)!==-1||e.indexOf(`\r`)!==-1}function Rg(e,t,n){let{index:r,header:i,isHeader:a,outputRowIndex:o,forceQuote:s,quoteAll:c,escapeFormulae:l,decimalSeparator:u,transform:d}=n,f,p;if(!a&&d){let t=Fg(e,d,{column:i??r,index:o});t==null?f=Ig(e,u):Cg(t)?(f=t.value,p=t.quote):f=t}else f=Ig(e,u);if(l&&p!==!1&&vh(f)&&(f=`'`+f),!t.quoteEnabled)return f;let m;if(m=p===void 0?c||s||(t.useFastCheck?Lg(f,t.delimiter,t.quote,t.escape):t.needsQuoteRegex.test(f)):p,m){let e;return e=t.escape===t.quote?f.replace(t.escapeQuoteRegex,t.escapedQuote):f.replace(t.escapeQuoteRegex,e=>e===t.quote?t.escape+t.quote:t.escape+t.escape),t.quote+e+t.quote}return f}function zg(e,t,n){let{quoteLookup:r,delimiter:i,headers:a,isHeader:o,outputRowIndex:s,quoteAll:c,escapeFormulae:l,decimalSeparator:u,transform:d}=n,f=e.length;if(f===0)return``;let p={index:0,header:a?.[0],isHeader:o,outputRowIndex:s,forceQuote:r(0,a?.[0]),quoteAll:c,escapeFormulae:l,decimalSeparator:u,transform:d},m=Rg(e[0],t,p);for(let n=1;n<f;n++)p.index=n,p.header=a?.[n],p.forceQuote=r(n,p.header),m+=i+Rg(e[n],t,p);return m}function Bg(e,t,n){if(!e.typeTransform?.row)return t;let r=e.typeTransform.row(t,n);return r===null?null:r}function Vg(e,t,n){let{headers:r,columns:i}=t;if(e.length===0)return i&&i.length>0?{keys:null,displayHeaders:i.map(e=>typeof e==`string`?e:e.header??e.key),rows:[]}:Array.isArray(r)?{keys:r,displayHeaders:r,rows:[]}:{keys:null,displayHeaders:null,rows:[]};let a=e[0];if(i&&i.length>0){let t=eh(i),r=t.keys,a=t.headers,o=[];for(let t=0;t<e.length;t++){let i=Bg(n,e[t],t);if(i===null)continue;let a;a=Wm(i)?Ym(i,r):Array.isArray(i)?i:r.map(e=>i[e]),o.push(a)}return{keys:r,displayHeaders:a,rows:o}}if(Wm(a)){let t=e,i=r===!0?qm(t[0]):Array.isArray(r)?r:null,a=[];for(let e=0;e<t.length;e++){let r=Bg(n,t[e],e);if(r===null)continue;let o;o=Wm(r)?i?Ym(r,i):Km(r):Array.isArray(r)?r:i?i.map(e=>r[e]):Object.values(r),a.push(o)}return{keys:i,displayHeaders:i,rows:a}}if(!Array.isArray(a)&&typeof a==`object`){let t=e,i=r===!0?Object.keys(t[0]):Array.isArray(r)?r:null,a=[];for(let e=0;e<t.length;e++){let r=Bg(n,t[e],e);if(r===null)continue;let o=i?i.map(e=>r[e]):Object.values(r);a.push(o)}return{keys:i,displayHeaders:i,rows:a}}let o=e,s=Array.isArray(r)?r:null,c=[];for(let e=0;e<o.length;e++){let t=Bg(n,o[e],e);t!==null&&c.push(t)}return{keys:s,displayHeaders:s,rows:c}}function Hg(e,t={}){let n=jg(t),{displayHeaders:r,rows:i}=Vg(e,t,n),a=[],o=r?Qm(r):void 0;o&&n.writeHeaders&&a.push(zg(o,n.regex,{quoteLookup:n.shouldQuoteHeader,delimiter:n.delimiter,headers:o,isHeader:!0,outputRowIndex:0,quoteAll:n.quoteAll,escapeFormulae:n.escapeFormulae,decimalSeparator:n.decimalSeparator,transform:void 0}));for(let e=0;e<i.length;e++)a.push(zg(i[e],n.regex,{quoteLookup:n.shouldQuoteColumn,delimiter:n.delimiter,headers:o,isHeader:!1,outputRowIndex:e,quoteAll:n.quoteAll,escapeFormulae:n.escapeFormulae,decimalSeparator:n.decimalSeparator,transform:n.typeTransform}));let s=n.bom?``:``;return s+=a.join(n.lineEnding),a.length>0&&n.trailingNewline&&(s+=n.lineEnding),s}var Ug=class extends Qf{constructor(e={}){super({objectMode:e.objectMode!==!1,writableObjectMode:e.objectMode!==!1}),this.headerWritten=!1,this.keys=null,this.displayHeaders=null,this.sourceRowIndex=0,this.outputRowIndex=0,this.options=e,this.formatConfig=jg(e);let t=this.formatConfig;this.rowOptions={quoteLookup:t.shouldQuoteColumn,delimiter:t.delimiter,headers:void 0,isHeader:!1,outputRowIndex:0,quoteAll:t.quoteAll,escapeFormulae:t.escapeFormulae,decimalSeparator:t.decimalSeparator,transform:t.typeTransform};let n=eh(e.columns);n?(this.keys=n.keys,this.displayHeaders=n.headers):Array.isArray(e.headers)&&(this.keys=e.headers,this.displayHeaders=e.headers),this.displayHeaders&&=Qm(this.displayHeaders)}detectHeadersFromRow(e){let t=Zm(e);t.length>0&&(this.keys=t,this.displayHeaders=Qm(t))}_transform(e,t,n){try{!this.headerWritten&&this.formatConfig.bom&&this.push(``),this.headerWritten||=(this.options.headers===!0&&!this.keys&&this.detectHeadersFromRow(e),this.formatConfig.writeHeaders&&this.displayHeaders&&this.push(this.formatRow(this.displayHeaders,!0)),!0);let t=e,r=this.sourceRowIndex++;if(this.formatConfig.typeTransform?.row&&(t=this.formatConfig.typeTransform.row(e,r),t===null)){n();return}this.formatAndPush(t),this.outputRowIndex++,n()}catch(e){n(e)}}_destroy(e,t){this.keys=null,this.displayHeaders=null,t(e)}_flush(e){!this.headerWritten&&this.displayHeaders&&this.formatConfig.writeHeaders&&(this.formatConfig.bom&&this.push(``),this.push(this.formatRow(this.displayHeaders,!0)),this.headerWritten=!0);let t=this.formatConfig.writeHeaders&&this.displayHeaders||this.outputRowIndex>0;this.formatConfig.trailingNewline&&t&&this.push(this.formatConfig.lineEnding),e()}formatAndPush(e){let t=Xm(e,this.keys);this.push(this.formatRow(t,!1))}formatRow(e,t=!1){let n=this.formatConfig,r=this.rowOptions;r.quoteLookup=t?n.shouldQuoteHeader:n.shouldQuoteColumn,r.headers=this.displayHeaders??void 0,r.isHeader=t,r.outputRowIndex=this.outputRowIndex;let i=zg(e,n.regex,r);return t||!(n.writeHeaders&&this.displayHeaders)&&this.outputRowIndex===0?i:n.lineEnding+i}};function Wg(e={}){return new Ug(e)}let Gg=[`YYYY-MM-DD[T]HH:mm:ssZ`,`YYYY-MM-DD[T]HH:mm:ss`,`MM-DD-YYYY`,`YYYY-MM-DD`],Kg={true:!0,false:!1,"#N/A":{error:`#N/A`},"#REF!":{error:`#REF!`},"#NAME?":{error:`#NAME?`},"#DIV/0!":{error:`#DIV/0!`},"#NULL!":{error:`#NULL!`},"#VALUE!":{error:`#VALUE!`},"#NUM!":{error:`#NUM!`}};function qg(e,t){let n=Bm.create(e),r=t?.decimalSeparator??`.`;return function(e){if(e===``)return null;if(typeof e==`string`){let t=Pg(e,r);if(!Number.isNaN(t)&&t!==1/0)return t}else{let t=Number(e);if(!Number.isNaN(t)&&t!==1/0)return t}let t=n.parse(e);if(t)return t;let i=Kg[e];return i===void 0?e:i}}function Jg(e,t){let n=e?Hm.create(e,{utc:t}):Hm.iso(t);return function(e){if(e){if(e.text||e.hyperlink)return e.hyperlink||e.text||``;if(e.formula||e.result)return e.result||``;if(e.richText&&Array.isArray(e.richText))return e.richText.map(e=>e.text).join(``);if(e instanceof Date)return n.format(e);if(e.error)return e.error;if(typeof e==`object`)return JSON.stringify(e)}return e}}function Yg(e){return typeof e==`string`&&/^https?:\/\//i.test(e)}function Xg(e){return typeof File<`u`&&e instanceof File}function Zg(e){return typeof Blob<`u`&&e instanceof Blob&&!Xg(e)}function Qg(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t[Symbol.asyncIterator]==`function`||typeof t.pipe==`function`&&typeof t.on==`function`}function $g(e){return{delimiter:e?.delimiter??`,`,quote:e?.quote,escape:e?.escape,delimitersToGuess:e?.delimitersToGuess,lineEnding:e?.lineEnding,headers:e?.headers,skipEmptyLines:e?.skipEmptyLines,trim:e?.trim,ltrim:e?.ltrim,rtrim:e?.rtrim,comment:e?.comment,maxRows:e?.maxRows,toLine:e?.toLine,skipLines:e?.skipLines,skipRows:e?.skipRows,columnMismatch:e?.columnMismatch,groupColumnsByName:e?.groupColumnsByName,relaxQuotes:e?.relaxQuotes,fastMode:e?.fastMode,info:e?.info,raw:e?.raw,skipRecordsWithError:e?.skipRecordsWithError,skipRecordsWithEmptyValues:e?.skipRecordsWithEmptyValues,onSkip:e?.onSkip}}function e_(e){return{delimiter:e?.delimiter??`,`,quote:e?.quote,escape:e?.escape,lineEnding:e?.lineEnding,quoteColumns:e?.quoteColumns,quoteHeaders:e?.quoteHeaders,decimalSeparator:e?.decimalSeparator??`.`,escapeFormulae:e?.escapeFormulae,writeHeaders:e?.writeHeaders}}var t_=class{static{this.Writer=Tp}static{this.Reader=Sm}constructor(){this.category=``,this.company=``,this.created=new Date,this.description=``,this.keywords=``,this.manager=``,this.modified=this.created,this.properties={},this.calcProperties={},this._worksheets=[],this.subject=``,this.title=``,this.views=[],this.media=[],this.pivotTables=[],this._passthrough={},this._rawDrawings={},this._definedNames=new cr}importSheet(e,t){let n=this.addWorksheet(t??e.name);return n.model={...e.model,id:n.id,name:n.name},n}get xlsx(){return this._xlsx||=new gp(this),this._xlsx}async readCsv(e,t){return Yg(e)?this._readCsvUrl(e,t):Xg(e)?this._readCsvFile(e,t):Zg(e)?this._readCsvBlob(e,t):Qg(e)?this._readCsvStream(e,t):this._readCsvContent(e,t)}writeCsv(e,t){return e&&typeof e.write==`function`?this._writeCsvStream(e,t):this._writeCsvString(e)}async writeCsvBuffer(e){let t=this._writeCsvString(e);return new TextEncoder().encode(t)}async readCsvFile(e,t){throw new v(`readCsvFile()`,`not available in browser. Use readCsv(url) or readCsv(file) instead.`)}async writeCsvFile(e,t){throw new v(`writeCsvFile()`,`not available in browser. Use writeCsv() and trigger a download instead.`)}createCsvReadStream(e){let t=this.getWorksheet(e?.sheetName||e?.sheetId),n=e?.map||Jg(e?.dateFormat,e?.dateUTC),r=e?.includeEmptyRows!==!1,i=new Ug(e_(e));return t?setTimeout(()=>{let e=1;t.eachRow((t,a)=>{if(r)for(;e++<a-1;)i.write([]);let{values:o}=t;o.shift(),i.write(o.map(n)),e=a}),i.end()},0):setTimeout(()=>i.end(),0),i}createCsvWriteStream(e){let t=this.addWorksheet(e?.sheetName),n=e?.dateFormats??Gg,r=e?.decimalSeparator,i=e?.map||qg(n,{decimalSeparator:r}),a=new Eg($g(e)),o=!!e?.headers,s=null;return o&&a.on(`headers`,e=>{s=e,t.addRow(e)}),a.on(`data`,e=>{if(o&&s&&e&&typeof e==`object`&&!Array.isArray(e)){let n=e,r=s.map(e=>n[e]);t.addRow(r.map(i))}else Array.isArray(e)&&t.addRow(e.map(i))}),a}_readCsvContent(e,t){let n;n=typeof e==`string`?e:e instanceof ArrayBuffer||e instanceof Uint8Array?new TextDecoder().decode(e):String(e);let r=this.addWorksheet(t?.sheetName),i=t?.dateFormats??Gg,a=t?.decimalSeparator,o=t?.map||qg(i,{decimalSeparator:a}),s=xg(n,$g(t));if(Array.isArray(s))for(let e of s)r.addRow(e.map(o));else{s.headers&&r.addRow(s.headers);for(let e of s.rows){let t=s.headers.map(t=>e[t]);r.addRow(t.map(o))}}return r}async _readCsvStream(e,t){let n=this.addWorksheet(t?.sheetName),r=t?.dateFormats??Gg,i=t?.decimalSeparator,a=t?.map||qg(r,{decimalSeparator:i}),o=new Eg($g(t)),s=!!t?.headers,c=null;return new Promise((t,r)=>{s&&o.on(`headers`,e=>{c=e,n.addRow(e)}),o.on(`data`,e=>{if(s&&c&&e&&typeof e==`object`&&!Array.isArray(e)){let t=e,r=c.map(e=>t[e]);n.addRow(r.map(a))}else Array.isArray(e)&&n.addRow(e.map(a))}),lp(e,o).then(()=>t(n)).catch(r)})}async _readCsvUrl(e,t){let n={method:t?.requestBody?`POST`:`GET`,headers:t?.requestHeaders,body:t?.requestBody,credentials:t?.withCredentials?`include`:`same-origin`,signal:t?.signal},r=await fetch(e,n);if(!r.ok)throw new ee(e,r.status,r.statusText);if(t?.stream&&r.body){let e=dp(r.body);return this._readCsvStream(e,t)}let i=await r.text();return this._readCsvContent(i,t)}async _readCsvFile(e,t){if((t?.stream||e.size>10*1024*1024)&&typeof e.stream==`function`){let n=dp(e.stream());return this._readCsvStream(n,t)}return new Promise((n,r)=>{let i=new FileReader,a=t?.encoding??`UTF-8`;t?.onProgress&&(i.onprogress=n=>{t.onProgress(n.loaded,n.total||e.size)}),i.onload=e=>{try{let r=e.target?.result;n(this._readCsvContent(r,t))}catch(e){r(e)}},i.onerror=()=>r(Error(`Failed to read file: ${e.name}`)),i.readAsText(e,a)})}async _readCsvBlob(e,t){let n=await e.text();return this._readCsvContent(n,t)}_writeCsvString(e){let t=this.getWorksheet(e?.sheetName||e?.sheetId);if(!t)return``;let n=e?.map||Jg(e?.dateFormat,e?.dateUTC),r=e?.includeEmptyRows!==!1,i=[],a=1;return t.eachRow((e,t)=>{if(r)for(;a++<t-1;)i.push([]);let{values:o}=e;o.shift(),i.push(o.map(n)),a=t}),Hg(i,e_(e))}async _writeCsvStream(e,t){let n=this.getWorksheet(t?.sheetName||t?.sheetId);if(!n){e.end();return}let r=t?.map||Jg(t?.dateFormat,t?.dateUTC),i=t?.includeEmptyRows!==!1,a=new Ug(e_(t)),o=lp(a,e),s=1;n.eachRow((e,t)=>{if(i)for(;s++<t-1;)a.write([]);let{values:n}=e;n.shift(),a.write(n.map(r)),s=t}),a.end(),await o}static createStreamWriter(e){return new Tp(e)}static createStreamReader(e,t){return new Sm(e,t)}get nextId(){for(let e=1;e<this._worksheets.length;e++)if(!this._worksheets[e])return e;return this._worksheets.length||1}addWorksheet(e,t){let n=this.nextId,r=this._worksheets.reduce((e,t)=>(t&&t.orderNo)>e?t.orderNo:e,0),i=new nr({...t,id:n,name:e,orderNo:r+1,workbook:this});return this._worksheets[n]=i,i}removeWorksheetEx(e){delete this._worksheets[e.id]}removeWorksheet(e){let t=this.getWorksheet(e);t&&t.destroy()}getWorksheet(e){if(e===void 0)return this._worksheets.find(Boolean);if(typeof e==`number`)return this._worksheets[e];if(typeof e==`string`)return this._worksheets.find(t=>t&&t.name===e)}get worksheets(){return this._worksheets.slice(1).sort((e,t)=>e.orderNo-t.orderNo).filter(Boolean)}eachSheet(e){this.worksheets.forEach(t=>{e(t,t.id)})}get definedNames(){return this._definedNames}clearThemes(){this._themes=void 0}addImage(e){let t=this.media.length;return this.media.push({...e,type:`image`}),t}getImage(e){return this.media[Number(e)]}get model(){return{creator:this.creator||`Unknown`,lastModifiedBy:this.lastModifiedBy||`Unknown`,lastPrinted:this.lastPrinted,created:this.created,modified:this.modified,properties:this.properties,worksheets:this.worksheets.map(e=>e.model),sheets:this.worksheets.map(e=>e.model).filter(Boolean),definedNames:this._definedNames.model,views:this.views,company:this.company,manager:this.manager,title:this.title,subject:this.subject,keywords:this.keywords,category:this.category,description:this.description,language:this.language,revision:this.revision,contentStatus:this.contentStatus,themes:this._themes,media:this.media,pivotTables:this.pivotTables,calcProperties:this.calcProperties,passthrough:this._passthrough,rawDrawings:this._rawDrawings,defaultFont:this._defaultFont}}set model(e){this.creator=e.creator,this.lastModifiedBy=e.lastModifiedBy,this.lastPrinted=e.lastPrinted,this.created=e.created,this.modified=e.modified,this.company=e.company,this.manager=e.manager,this.title=e.title,this.subject=e.subject,this.keywords=e.keywords,this.category=e.category,this.description=e.description,this.language=e.language,this.revision=e.revision,this.contentStatus=e.contentStatus,this.properties=e.properties,this.calcProperties=e.calcProperties,this._worksheets=[],e.worksheets.forEach(t=>{let{id:n,name:r,state:i}=t,a=e.sheets&&e.sheets.findIndex(e=>e.id===n),o=this._worksheets[n]=new nr({id:n,name:r,orderNo:a===-1?void 0:a,state:i,workbook:this});o.model=t}),this._definedNames.model=e.definedNames,this.views=e.views,this._themes=e.themes,this.media=e.media||[],this.pivotTables=e.pivotTables||e.loadedPivotTables||[],this._passthrough=e.passthrough||{},this._rawDrawings=e.rawDrawings||{},this._defaultFont=e.defaultFont}};let n_=function(e){return e[e.Legal=5]=`Legal`,e[e.Executive=7]=`Executive`,e[e.A4=9]=`A4`,e[e.A5=11]=`A5`,e[e.B5=13]=`B5`,e[e.Envelope_10=20]=`Envelope_10`,e[e.Envelope_DL=27]=`Envelope_DL`,e[e.Envelope_C5=28]=`Envelope_C5`,e[e.Envelope_B5=34]=`Envelope_B5`,e[e.Envelope_Monarch=37]=`Envelope_Monarch`,e[e.Double_Japan_Postcard_Rotated=82]=`Double_Japan_Postcard_Rotated`,e[e.K16_197x273_mm=119]=`K16_197x273_mm`,e}({});return e.Anchor=Ue,e.BaseError=t,e.Cell=E,e.Column=Be,e.ColumnOutOfBoundsError=p,e.CsvFormatterStream=Ug,e.CsvParserStream=Eg,e.DataValidations=et,e.DateFormatter=Hm,e.DateParser=Bm,e.DefinedNames=cr,e.DocumentType=ce,e.Enums=T,e.ErrorValue=w,e.ExcelDownloadError=ee,e.ExcelError=l,e.ExcelFileError=y,e.ExcelNotSupportedError=v,e.ExcelStreamStateError=b,e.FormCheckbox=st,e.FormulaType=oe,e.Image=We,e.ImageError=ne,e.InvalidAddressError=f,e.InvalidValueTypeError=g,e.MaxItemsExceededError=re,e.MergeConflictError=h,e.PaperSize=n_,e.PivotTableError=x,e.Range=C,e.ReadingOrder=le,e.RelationshipType=se,e.Row=ze,e.RowOutOfBoundsError=m,e.Table=$e,e.TableError=te,e.ValueType=ae,e.Workbook=t_,e.WorkbookReader=Sm,e.WorkbookWriter=Tp,e.Worksheet=nr,e.WorksheetNameError=d,e.WorksheetReader=ym,e.WorksheetWriter=xp,e.XmlParseError=_,e.base64ToUint8Array=lt,e.concatUint8Arrays=O,e.createCsvFormatterStream=Wg,e.createCsvParserStream=Dg,e.dateToExcel=ut,e.decodeCell=Qn,e.decodeCol=Jn,e.decodeRange=er,e.decodeRow=Xn,e.encodeCell=$n,e.encodeCol=Yn,e.encodeRange=tr,e.encodeRow=Zn,e.errorToJSON=o,e.excelToDate=dt,e.getErrorChain=s,e.getRootCause=c,e.getSupportedFormats=Um,e.isExcelError=u,e.stringToUint8Array=tn,e.toError=a,e.toUint8Array=rn,e.uint8ArrayToBase64=It,e.uint8ArrayToString=nn,e.xmlDecode=bt,e.xmlEncode=D,e})({});