@evotecit/officeimo 0.1.19 → 0.1.21

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 (42) hide show
  1. package/README.md +6 -3
  2. package/bundles/officeimo-canopyx-adapter.js +121 -59
  3. package/bundles/officeimo-canopyx-adapter.min.js +1 -1
  4. package/bundles/officeimo-canopyx-adapter.min.mjs +1 -1
  5. package/bundles/officeimo-canopyx-adapter.mjs +108 -47
  6. package/bundles/officeimo-canopyx.js +177 -100
  7. package/bundles/officeimo-canopyx.min.js +1 -1
  8. package/bundles/officeimo-canopyx.min.mjs +1 -1
  9. package/bundles/officeimo-canopyx.mjs +144 -68
  10. package/bundles/officeimo-datatables-adapter.js +7 -7
  11. package/bundles/officeimo-datatables-adapter.min.js +1 -1
  12. package/bundles/officeimo-datatables-adapter.min.mjs +1 -1
  13. package/bundles/officeimo-datatables-adapter.mjs +3 -3
  14. package/bundles/officeimo-datatables.js +63 -48
  15. package/bundles/officeimo-datatables.min.js +1 -1
  16. package/bundles/officeimo-datatables.min.mjs +1 -1
  17. package/bundles/officeimo-datatables.mjs +39 -24
  18. package/bundles/officeimo-xlsx.js +59 -44
  19. package/bundles/officeimo-xlsx.min.js +1 -1
  20. package/bundles/officeimo-xlsx.min.mjs +1 -1
  21. package/bundles/officeimo-xlsx.mjs +39 -24
  22. package/bundles/officeimo.js +61 -46
  23. package/bundles/officeimo.min.js +1 -1
  24. package/bundles/officeimo.min.mjs +1 -1
  25. package/bundles/officeimo.mjs +40 -25
  26. package/dist/integrations/canopyx/index.js +4 -2
  27. package/dist/integrations/canopyx/pdf-number.js +9 -6
  28. package/dist/integrations/canopyx/rule-predicates.d.ts +1 -1
  29. package/dist/integrations/canopyx/rule-predicates.js +2 -1
  30. package/dist/integrations/canopyx/rules.d.ts +1 -1
  31. package/dist/integrations/canopyx/rules.js +11 -13
  32. package/dist/integrations/canopyx/source.js +44 -7
  33. package/dist/integrations/canopyx/tones.d.ts +10 -0
  34. package/dist/integrations/canopyx/tones.js +12 -0
  35. package/dist/integrations/canopyx/types.d.ts +8 -1
  36. package/dist/xlsx/options.js +1 -1
  37. package/dist/xlsx/portable.js +1 -1
  38. package/dist/xlsx/styles.js +28 -18
  39. package/dist/xlsx/types.d.ts +5 -1
  40. package/dist/xlsx/workbook.js +3 -1
  41. package/dist/xlsx/worksheet.js +5 -2
  42. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
1
  // Generated by OfficeIMO.JavaScript/scripts/bundles.mjs from tsc output. MIT.
2
- const ge=(()=>{function T(a){if(a?.aborted)throw a.reason}function E(a,l){return l?new Promise((e,n)=>{const t=()=>l.removeEventListener("abort",s),s=()=>{t(),n(l.reason)};l.addEventListener("abort",s,{once:!0}),Promise.resolve(a).then(r=>{t(),e(r)},r=>{t(),n(r)}),l.aborted&&s()}):Promise.resolve(a)}async function*R(a,l){T(l);const e=a?.[Symbol.asyncIterator]?.()??a?.[Symbol.iterator]?.();if(!e)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let n=!1,t=!1;try{for(;;){T(l);const s=await E(Promise.resolve(e.next()),l);if(T(l),s.done){n=!0;return}yield s.value}}catch(s){throw t=!0,s}finally{if(!n&&e.return)try{const s=e.return();l?.aborted||t?Promise.resolve(s).catch(()=>{}):await E(Promise.resolve(s),l)}catch(s){if(!l?.aborted&&!t)throw s}}}const v=new WeakMap;function C(a){let l=!1;const e=()=>{if(l)throw new TypeError("A row source can be consumed only once.");l=!0},n={[Symbol.asyncIterator](){return e(),t()}};async function*t(){for await(const s of R(a))yield*s}return v.set(n,(s,r)=>(e(),h(a,s,w=>h(w,s,r)))),n}function g(...a){const l={async*[Symbol.asyncIterator](){for(const e of a)yield*e}};return v.set(l,async(e,n)=>{for(const t of a)await h(t,e,n)}),l}async function h(a,l,e){T(l);const n=v.get(a);if(n)return n(l,e);const t=a?.[Symbol.asyncIterator]?.()??a?.[Symbol.iterator]?.();if(!t)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let s=!1;try{for(;;){T(l);let r=t.next();const w=r;typeof w?.then=="function"&&(r=await E(w,l)),T(l);const S=r;if(S.done){s=!0;return}let x=S.value;typeof x?.then=="function"&&(x=await E(x,l)),T(l);const p=e(x);p!==void 0&&await E(p,l)}}finally{if(!s&&t.return)try{Promise.resolve(t.return()).catch(()=>{})}catch{}}}let d;const u=32;function f(){d=performance.now()+u}function m(){const a=performance.now();return d??=a+u,a>=d}function o(){const a=globalThis.scheduler;return typeof a?.postTask=="function"?a.postTask(()=>{d=performance.now()+u},{priority:"user-visible"}):new Promise(l=>{setTimeout(function(){d=performance.now()+u,l()},0)})}return Object.freeze({checkAbort:T,withAbort:E,inputRows:R,rowsFromBatches:C,concatRows:g,consumeRows:h,beginTask:f,taskYieldDue:m,pause:o})})(),ce=(()=>{const T=Symbol.for("@evotecit/officeimo/OfficeIMOError"),E=Symbol.for("@evotecit/officeimo/NotSupportedError");class R extends Error{code;static[Symbol.hasInstance](h){return this!==R?Function.prototype[Symbol.hasInstance].call(this,h):!!h&&typeof h=="object"&&h[T]===!0}constructor(h,d,u){super(d,u),this.code=h,Object.defineProperty(this,T,{value:!0}),this.name="OfficeIMOError"}}class v extends R{feature;static[Symbol.hasInstance](h){return this!==v?Function.prototype[Symbol.hasInstance].call(this,h):!!h&&typeof h=="object"&&h[E]===!0}constructor(h){super("NOT_SUPPORTED",h+" is not supported yet."),this.feature=h,Object.defineProperty(this,E,{value:!0}),this.name="NotSupportedError"}}return Object.freeze({OfficeIMOError:R,NotSupportedError:v})})(),Qe=(()=>{function T(R,v){if(!R)return;const C=R(v);if(C&&typeof C.then=="function")throw Promise.resolve(C).catch(()=>{}),new TypeError("onProgress must be synchronous.")}return Object.freeze({notifyProgress:T})})(),Te=(()=>{const{checkAbort:T,consumeRows:E,withAbort:R,pause:v,taskYieldDue:C}=ge,{OfficeIMOError:g}=ce;async function h(o,i){if(o&&typeof o.getWriter=="function"){const a=o.getWriter();try{return await i({write:l=>a.write(new Uint8Array(l))})}finally{a.releaseLock()}}if(!o||typeof o.write!="function")throw new TypeError("Destination must be a ByteSink or WritableStream.");return i(o)}class d{parts=[];state="open";result;write(i){if(this.state!=="open")throw new g("INVALID_STATE","Byte sink is closed.");this.parts.push(new Uint8Array(i))}toBlob(i="application/octet-stream"){if(this.state==="discarded")throw new g("INVALID_STATE","Byte sink was discarded.");return this.state="closed",this.result||(this.result=new Blob(this.parts,{type:i}),this.parts=[]),this.result.type===i?this.result:new Blob([this.result],{type:i})}takeChunks(){if(this.state!=="open")throw new g("INVALID_STATE","Byte sink is closed.");const i=this.parts;return this.parts=[],this.state="discarded",i}discard(){this.parts=[],this.result=void 0,this.state="discarded"}}class u{sink;signal;chunkSize;text="";encoder=new TextEncoder;constructor(i,a,l=32768){if(this.sink=i,this.signal=a,this.chunkSize=l,!Number.isInteger(l)||l<2)throw new RangeError("Text chunk size must be at least 2.")}append(i){return T(this.signal),this.text+=i,this.text.length>=this.chunkSize||C()}async flush(i=!1){for(T(this.signal);this.text.length;){let a=Math.min(this.text.length,this.chunkSize);if(/[\ud800-\udbff]/.test(this.text[a-1])&&(a<this.text.length||!i)&&a--,!a)break;const l=this.encoder.encode(this.text.slice(0,a));this.text=this.text.slice(a),await R(Promise.resolve(this.sink.write(l)),this.signal),C()&&await v(),T(this.signal)}}async write(i){this.append(i)&&await this.flush()}async close(){await this.flush(!0)}}async function f(o,i,a){await E(o instanceof Uint8Array?[o]:o,a,l=>{if(!(l instanceof Uint8Array))throw new TypeError("Byte sources must yield Uint8Array chunks.");const e=i.write(l);return C()?Promise.resolve(e).then(()=>(T(a),v())):e})}return Object.freeze({withDestination:h,BlobByteSink:d,ChunkedTextSink:u,writeBytes:f})})(),be=(()=>{function T(R,v){const C={...R};for(const g of v){if(Object.hasOwn(C,g))continue;const h=R[g];h!==void 0&&(C[g]=h)}return C}return Object.freeze({captureFields:T})})(),et=(()=>{const{OfficeIMOError:T}=ce,{captureFields:E}=be;class R{cells=0;text=0;reservedCells=0;reservedText=0;limits;constructor(h={}){if(!h||typeof h!="object"||Array.isArray(h))throw new TypeError("Export limits must be an object.");const d=E(h,["maxRows","maxCells","maxTextCharacters","maxOutputBytes"]);for(const[u,f]of Object.entries(d))if(f!==void 0&&(!Number.isSafeInteger(f)||f<0))throw new RangeError(u+" must be a nonnegative safe integer.");this.limits=Object.freeze(d)}check(h,d){const u=this.limits[h];if(u!==void 0&&d>u)throw new T("RESOURCE_LIMIT",h+" exceeded ("+d+" > "+u+").")}row(h){this.check("maxRows",h)}reserve(h,d){this.check("maxCells",this.cells+this.reservedCells+h),this.check("maxTextCharacters",this.text+this.reservedText+d),this.reservedCells+=h,this.reservedText+=d}release(h,d){this.reservedCells-=h,this.reservedText-=d}cell(h,d){if(d!==void 0&&this.release(1,d),this.limits.maxCells===void 0&&this.limits.maxTextCharacters===void 0)return;this.check("maxCells",this.cells+this.reservedCells+1);const u=typeof h=="string"?h.length:0;this.check("maxTextCharacters",this.text+this.reservedText+u),this.cells++,this.text+=u}}function v(g,h){let d=0;return{write(u){return h.check("maxOutputBytes",d+u.length),d+=u.length,g.write(u)}}}return Object.freeze({ExportBudget:R,boundedSink:v})})(),Ne=(()=>{const{OfficeIMOError:T}=ce;function E(g){const h=()=>new T("INVALID_PART_URI","Invalid OPC part URI: "+g);if(typeof g!="string"||!g.startsWith("/")||/[^A-Za-z0-9\-._~!$&'()*+,;=:@%/]/.test(g)||g.split("/").slice(1).some(d=>!d||d.endsWith(".")||/^\.+$/.test(d))||/%(?![\da-f]{2})/i.test(g))throw h();for(const d of g.matchAll(/%([\da-f]{2})/gi)){const u=String.fromCharCode(parseInt(d[1],16));if(/[A-Za-z0-9_.~\-/\\]/.test(u))throw h()}try{decodeURIComponent(g)}catch{throw h()}return g.replace(/%[\da-f]{2}/gi,d=>d.toUpperCase())}function R(g){if(g==="/")return"/_rels/.rels";const h=E(g),d=h.lastIndexOf("/");return h.slice(0,d+1)+"_rels/"+h.slice(d+1)+".rels"}function v(g,h){const d=E(h).slice(1).split("/"),u=g==="/"?[]:E(g).slice(1).split("/").slice(0,-1);for(;u.length&&u[0]===d[0];)u.shift(),d.shift();const f="../".repeat(u.length)+d.join("/");return f.split("/",1)[0].includes(":")?"./"+f:f}return Object.freeze({partUri:E,relationshipPartUri:R,relativePartTarget:v})})(),pe=(()=>{const{OfficeIMOError:T}=ce,{ChunkedTextSink:E}=Te,R='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',v={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;","\r":"&#13;","\n":"&#10;"," ":"&#9;"};function C(m,o="strip"){if(o!=="strip"&&o!=="reject")throw new TypeError("Invalid XML character policy.");const i=String(m),a=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\ud800-\udfff\ufffe\uffff]/gu;if(o==="reject"&&a.test(i))throw new T("INVALID_XML","Text contains XML 1.0-invalid characters.");return i.replace(a,"")}function g(m,o="strip"){return C(m,o).replace(/[&<>"'\r\n\t]/g,i=>v[i])}function h(m,o="strip"){const i={"\r":"_x000D_","\n":"_x000A_"," ":"_x0009_"},a=C(m,o).replace(/_(?=x[0-9a-f]{4}_)|[\r\n\t]/gi,l=>l==="_"?"_x005F_":i[l]);return g(a,o)}function d(m){if(typeof m!="string"||!/^[A-Za-z_][A-Za-z0-9_.-]*(?::[A-Za-z_][A-Za-z0-9_.-]*)?$/.test(m))throw new T("INVALID_XML","Invalid XML name: "+m);return m}class u{policy;sink;stack=[];roots=0;closed=!1;constructor(o,i="strip",a){this.policy=i,C("",i),this.sink=new E(o,a),this.sink.append(R)}async startElement(o,i={}){this.open(),d(o);const a="<"+o+Object.entries(i).map(([l,e])=>" "+d(l)+'="'+g(e,this.policy)+'"').join("")+">";if(!this.stack.length&&this.roots++)throw new T("INVALID_XML","XML must have one root element.");this.stack.push(o),await this.sink.write(a)}async text(o){if(this.open(),!this.stack.length)throw new T("INVALID_XML","Text needs an open element.");await this.sink.write(g(o,this.policy))}async endElement(){this.open();const o=this.stack.pop();if(!o)throw new T("INVALID_XML","No open XML element.");await this.sink.write("</"+o+">")}async close(){if(this.open(),this.stack.length||this.roots!==1)throw new T("INVALID_XML","XML document is incomplete.");await this.sink.close(),this.closed=!0}open(){if(this.closed)throw new T("INVALID_STATE","XML writer is closed.")}}return Object.freeze({xmlDeclaration:R,cleanXml:C,escapeXml:g,escapeOoxmlAttribute:h,validateXmlName:d,XmlWriter:u})})(),Se=(()=>{function T(R){if(R===null||typeof R!="object")return!1;try{return!(R instanceof Date)&&!(Symbol.toStringTag in R)&&Object.prototype.toString.call(R)!=="[object Date]"?!1:(Date.prototype.getTime.call(R),!0)}catch{return!1}}return Object.freeze({isDate:T})})(),We=(()=>{const{escapeXml:T,xmlDeclaration:E}=pe,{isDate:R}=Se;function v(h={},d="strip"){const u=h.created??new Date,f=h.modified??u;if(!R(u)||!R(f)||!Number.isFinite(u.getTime())||!Number.isFinite(f.getTime()))throw new TypeError("Invalid workbook property date.");return E+'<cp:coreProperties 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:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:creator>'+T(h.creator??"",d)+"</dc:creator><dc:title>"+T(h.title??"",d)+"</dc:title>"+(h.subject===void 0?"":"<dc:subject>"+T(h.subject,d)+"</dc:subject>")+(h.description===void 0?"":"<dc:description>"+T(h.description,d)+"</dc:description>")+'<dcterms:created xsi:type="dcterms:W3CDTF">'+u.toISOString()+'</dcterms:created><dcterms:modified xsi:type="dcterms:W3CDTF">'+f.toISOString()+"</dcterms:modified></cp:coreProperties>"}function C(h={},d="strip"){return E+'<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"><Application>'+T(h.application??"OfficeIMO",d)+"</Application><Company>"+T(h.company??"",d)+"</Company></Properties>"}return Object.freeze({corePropertiesXml:v,appPropertiesXml:C})})(),tt=(()=>{const T=new Uint32Array(256).map((v,C)=>{let g=C;for(let h=0;h<8;h++)g=g&1?3988292384^g>>>1:g>>>1;return g>>>0});class E{crc=4294967295;update(C){let g=this.crc;for(let h=0;h<C.length;h++)g=T[(g^C[h])&255]^g>>>8;this.crc=g}get value(){return(this.crc^4294967295)>>>0}}return Object.freeze({Crc32:E})})(),qe=(()=>{const{checkAbort:T,withAbort:E}=ge,{OfficeIMOError:R}=ce,{Crc32:v}=tt,C=4294967295;function g(u){if(!Number.isSafeInteger(u)||u<0||u>=C)throw new R("ZIP64_REQUIRED","Classic ZIP entries and archives must stay below 4 GiB; ZIP64 is not supported yet.");return u}class h{sink;signal;method;writer;reader;drain;crc=new v;size=0;compressedSize=0;failed=!1;failure;closed=!1;cleaned=!1;lifetime=new AbortController;abort=()=>{this.fail(this.signal?.reason)};constructor(f,m,o){if(this.sink=m,this.signal=o,f!=="auto"&&f!=="store")throw new RangeError("compression must be auto or store.");T(o);let i;if(f==="auto"&&typeof CompressionStream=="function")try{i=new CompressionStream("deflate-raw")}catch(a){if(!(a instanceof TypeError))throw a}this.method=i?8:0,this.writer=i?.writable.getWriter(),this.reader=i?.readable.getReader(),o?.addEventListener("abort",this.abort,{once:!0}),this.drain=this.reader?this.consume(this.reader):Promise.resolve()}async consume(f){try{for(;;){const{value:m,done:o}=await E(f.read(),this.lifetime.signal);if(o)return;T(this.signal),this.compressedSize=g(this.compressedSize+m.length),await E(Promise.resolve(this.sink.write(m)),this.lifetime.signal)}}catch(m){this.fail(m)}}fail(f){this.failed||(this.failed=!0,this.failure=f,this.lifetime.abort(f),this.cleaned||(this.writer?.abort(f).catch(()=>{}),this.reader?.cancel(f).catch(()=>{})))}async write(f){if(T(this.signal),this.failed)throw this.failure;if(this.closed)throw new R("INVALID_STATE","ZIP entry is closed.");if(!(f instanceof Uint8Array))throw new TypeError("ZIP chunks must be Uint8Array.");this.size=g(this.size+f.length),this.crc.update(f),this.writer?await E(this.writer.write(new Uint8Array(f)),this.lifetime.signal):(await E(Promise.resolve(this.sink.write(f)),this.lifetime.signal),this.compressedSize=this.size)}async close(){try{if(T(this.signal),this.failed)throw this.failure;if(this.closed)throw new R("INVALID_STATE","ZIP entry is closed.");if(this.closed=!0,this.writer&&await E(this.writer.close(),this.lifetime.signal),await this.drain,this.failed)throw this.failure;return T(this.signal),{crc:this.crc.value,size:this.size,compressedSize:this.compressedSize,method:this.method}}finally{this.cleanup()}}async discard(f){this.fail(f),await this.drain,this.closed=!0,this.cleanup()}cleanup(){this.cleaned||(this.cleaned=!0,this.signal?.removeEventListener("abort",this.abort),this.writer?.releaseLock(),this.reader?.releaseLock())}}return Object.freeze({Crc32:tt.Crc32,zipLimit:C,zipSize:g,EntryWriter:h})})(),ut=(()=>{const{EntryWriter:T,zipSize:E}=qe,{checkAbort:R,withAbort:v,pause:C,taskYieldDue:g}=ge,{OfficeIMOError:h}=ce,{BlobByteSink:d,writeBytes:u}=Te,{captureFields:f}=be,m=new TextEncoder;function o(e){if(typeof e!="string"||!e||/[\u0000-\u001f\\]/.test(e)||e.startsWith("/")||/^[A-Za-z]:/.test(e)||e.split("/").some(n=>!n||n==="."||n===".."))throw new TypeError("ZIP entry names must be relative paths without empty, dot or parent segments.");for(let n=0;n<e.length;n++){const t=e.charCodeAt(n);if(t>=55296&&t<=56319){const s=e.charCodeAt(++n);if(!(s>=56320&&s<=57343))throw new TypeError("ZIP entry names must contain well-formed Unicode.")}else if(t>=56320&&t<=57343)throw new TypeError("ZIP entry names must contain well-formed Unicode.")}if(m.encode(e).length>65535)throw new RangeError("ZIP entry name exceeds 65,535 UTF-8 bytes.");return e}function i(e,n,t=new Uint8Array){const s=new Uint8Array(n+t.length),r=new DataView(s.buffer);return r.setUint32(0,e,!0),s.set(t,n),{bytes:s,data:r}}class a{sink;owned;names=new Set;central=[];offset=0;active;state="open";options;lifetime=new AbortController;disposal;constructor(n,t={}){const s=f(t,["compression","signal","maxOutputBytes"]),{compression:r,maxOutputBytes:w}=s;if(w!==void 0&&(!Number.isSafeInteger(w)||w<0))throw new RangeError("maxOutputBytes must be a nonnegative safe integer.");if(r!==void 0&&r!=="auto"&&r!=="store")throw new RangeError("compression must be auto or store.");this.options=Object.freeze(s),this.owned=n?void 0:new d,this.sink=n??this.owned}async acceptance(n){const t=this.options.signal,s=()=>this.lifetime.abort(t?.reason);t?.addEventListener("abort",s,{once:!0});try{return R(t),R(this.lifetime.signal),await v(Promise.resolve(n()),this.lifetime.signal)}finally{t?.removeEventListener("abort",s)}}async emit(n){if(this.options.maxOutputBytes!==void 0&&this.offset+n.length>this.options.maxOutputBytes)throw new h("RESOURCE_LIMIT","maxOutputBytes exceeded.");this.offset=E(this.offset+n.length),await this.acceptance(()=>this.sink.write(n))}reserve(n){if(R(this.options.signal),this.state!=="open")throw new h("INVALID_STATE","ZIP writer is busy, failed or finalized.");if(o(n),this.names.has(n))throw new TypeError("Duplicate ZIP entry: "+n);if(this.names.size>=65534)throw new h("ZIP64_REQUIRED","ZIP64 is required for 65,535 entries.");return this.names.add(n),this.state="writing",m.encode(n)}local(n,t,s){const r=i(67324752,30,n);return r.data.setUint16(4,20,!0),r.data.setUint16(6,s?2056:2048,!0),r.data.setUint16(8,t.method,!0),r.data.setUint16(12,33,!0),r.data.setUint16(26,n.length,!0),r.bytes}record(n,t,s,r){const w=i(33639248,46,n);w.data.setUint16(4,20,!0),w.data.setUint16(6,20,!0),w.data.setUint16(8,r?2056:2048,!0),w.data.setUint16(10,t.method,!0),w.data.setUint16(14,33,!0),w.data.setUint32(16,t.crc,!0),w.data.setUint32(20,t.compressedSize,!0),w.data.setUint32(24,t.size,!0),w.data.setUint16(28,n.length,!0),w.data.setUint32(42,s,!0),this.central.push(w.bytes)}async openEntry(n){const t=this.reserve(n),s=this.offset;let r;try{r=new T(this.options.compression??"auto",{write:I=>this.emit(I)},this.options.signal),await this.emit(this.local(t,r,!0));const w=r;let S=!1,x=!1,p;const y=async I=>{x=!0,this.state="failed",this.lifetime.abort(I),await w.discard(I),this.owned?.discard(),this.active=void 0};return this.active={write:async I=>{if(S||x||this.state!=="writing")throw new h("INVALID_STATE","Await the current ZIP entry operation.");S=!0;try{await w.write(I)}catch(j){throw await y(j),j}finally{S=!1}},close:()=>{if(p)return p;if(S||x||this.state!=="writing")throw new h("INVALID_STATE","ZIP entry is busy or closed.");return x=!0,p=(async()=>{try{const I=await w.close(),j=i(134695760,16);return j.data.setUint32(4,I.crc,!0),j.data.setUint32(8,I.compressedSize,!0),j.data.setUint32(12,I.size,!0),await this.emit(j.bytes),this.record(t,I,s,!0),this.state="open",this.active=void 0,I}catch(I){throw await y(I),I}})(),p},discard:y}}catch(w){throw this.state="failed",await r?.discard(w),this.owned?.discard(),w}}async add(n,t){const s=await this.openEntry(n);try{typeof t=="function"?await this.acceptance(()=>t(s)):await this.acceptance(()=>u(t,s,this.lifetime.signal)),await s.close()}catch(r){throw await s.discard(r),r}}get bytesWritten(){return this.offset}discard(n){return this.state="failed",this.lifetime.abort(n),this.disposal??=(async()=>{await this.active?.discard(n),this.owned?.discard()})()}async addPrepared(n,t){const s=this.reserve(n),r=this.offset;try{const w=this.local(s,t,!1),S=new DataView(w.buffer);S.setUint32(14,t.crc,!0),S.setUint32(18,t.compressedSize,!0),S.setUint32(22,t.size,!0),await this.emit(w);for(const x of t.chunks)R(this.options.signal),await this.emit(x);this.record(s,t,r,!1),this.state="open"}catch(w){throw this.state="failed",this.owned?.discard(),w}}async finish(){if(R(this.options.signal),this.state!=="open")throw new h("INVALID_STATE","ZIP writer is busy, failed or finalized.");this.state="writing";const n=this.offset;try{for(let s=0;s<this.central.length;s++)await this.emit(this.central[s]),s%256===255&&g()&&await C();const t=i(101010256,22);t.data.setUint16(8,this.central.length,!0),t.data.setUint16(10,this.central.length,!0),t.data.setUint32(12,this.offset-n,!0),t.data.setUint32(16,n,!0),await this.emit(t.bytes),R(this.options.signal),this.state="finished"}catch(t){throw this.state="failed",this.owned?.discard(),t}}async toBlob(n="application/zip"){if(!this.owned)throw new h("INVALID_STATE","This ZIP uses a caller-owned sink; use finish().");return this.state!=="finished"&&await this.finish(),this.owned.toBlob(n)}}return Object.freeze({Crc32:qe.Crc32,validateEntryName:o,ZipWriter:a})})(),Me=(()=>{const{partUri:T,relationshipPartUri:E,relativePartTarget:R}=Ne,{corePropertiesXml:v,appPropertiesXml:C}=We,{ZipWriter:g}=ut,{ChunkedTextSink:h}=Te,{OfficeIMOError:d}=ce,{escapeXml:u,xmlDeclaration:f}=pe,{checkAbort:m,pause:o,taskYieldDue:i}=ge,{captureFields:a}=be,l="http://schemas.openxmlformats.org/package/2006/relationships",e="http://schemas.openxmlformats.org/officeDocument/2006/relationships",n="http://schemas.openxmlformats.org/package/2006/content-types",t={officeDocument:e+"/officeDocument",worksheet:e+"/worksheet",styles:e+"/styles",theme:e+"/theme",customXml:e+"/customXml",coreProperties:l+"/metadata/core-properties",appProperties:e+"/extended-properties"};function s(x){if(typeof x!="string"||!/^[\w!#$&^.+-]+\/[\w!#$&^.+-]+$/.test(x))throw new TypeError("Invalid content type.");return x}class r{defaults=new Map([["rels","application/vnd.openxmlformats-package.relationships+xml"],["xml","application/xml"]]);overrides=new Map;addDefault(p,y){if(!/^[A-Za-z0-9]+$/.test(p))throw new TypeError("Invalid part extension.");const I=p.toLowerCase(),j=this.defaults.get(I);if(j!==void 0&&j!==y)throw new TypeError("Conflicting default content type.");this.defaults.set(I,s(y))}addOverride(p,y){if(p=T(p),this.overrides.has(p.toLowerCase()))throw new TypeError("Duplicate content-type override.");this.overrides.set(p.toLowerCase(),{uri:p,type:s(y)})}toXml(){return f+'<Types xmlns="'+n+'">'+[...this.defaults].map(([p,y])=>'<Default Extension="'+u(p)+'" ContentType="'+u(y)+'"/>').join("")+[...this.overrides.values()].map(({uri:p,type:y})=>'<Override PartName="'+u(p)+'" ContentType="'+u(y)+'"/>').join("")+"</Types>"}}class w{types=new r;parts=new Map;directories=new Set;relationships=new Map;state="open";result;zip;options;constructor(p={}){this.options=Object.freeze(a(p,["compression","signal","maxOutputBytes","invalidCharacterPolicy","sink"])),this.zip=new g(this.options.sink,this.options)}open(){if(this.state!=="open")throw new d("INVALID_STATE","OPC package is finalized.")}reserve(p,y){if(this.open(),typeof p=="string"&&p.length>65536)throw new d("RESOURCE_LIMIT","OPC part name exceeds the ZIP entry-name limit.");p=T(p);let I=0;for(let A=0;A<p.length;A++)if(p[A]==="/"&&++I>64)throw new d("RESOURCE_LIMIT","OPC part name exceeds the directory-depth limit.");if(/\/_rels(?:\/|$)/i.test(p)||p.toLowerCase()==="/[content_types].xml")throw new TypeError("Package metadata part names are reserved.");const j=p.toLowerCase();if(this.parts.has(j))throw new TypeError("Duplicate OPC part: "+p);if(this.directories.has(j))throw new TypeError("OPC part-name prefix collision: "+p+" is an ancestor of an existing part.");const M=[];for(let A=j.lastIndexOf("/");A>0;A=j.lastIndexOf("/",A-1)){const _=j.slice(0,A);if(this.parts.has(_))throw new TypeError("OPC part-name prefix collision: "+p+" descends from "+this.parts.get(_).uri);M.push(_)}this.types.addOverride(p,y);for(const A of M)this.directories.add(A);return p}addPart(p){const{uri:y,contentType:I,data:j}=p,M=j instanceof Uint8Array?new Uint8Array(j):j,A=this.reserve(y,I);this.parts.set(A.toLowerCase(),{uri:A,contentType:I,data:M})}addPrepared(p,y,I){p=this.reserve(p,y),this.parts.set(p.toLowerCase(),{uri:p,prepared:I})}async openPart(p,y){if(!this.options.sink)throw new d("INVALID_STATE","openPart requires a caller-owned package sink.");p=this.reserve(p,y),this.parts.set(p.toLowerCase(),{uri:p,written:!0});try{return await this.zip.openEntry(p.slice(1))}catch(I){throw await this.discard(I),I}}addRelationship(p,y){m(this.options.signal),this.open(),p=p==="/"?p:T(p);const{id:I,type:j,target:M,external:A}=y;if(this.open(),!/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(I))throw new TypeError("Relationship id must be an XML ID.");if(!/^[A-Za-z][A-Za-z0-9+.-]*:[^\s<>"']+$/.test(j))throw new TypeError("Relationship type must be an absolute URI.");const _=A?M:T(M);if(A&&(!_||/[\u0000-\u0020]/.test(_)))throw new TypeError("Invalid external relationship target.");const F=p.toLowerCase(),D=this.relationships.get(F)??new Map;if(D.has(I))throw new TypeError("Duplicate relationship id: "+I);D.set(I,{id:I,type:j,target:_,...A===void 0?{}:{external:A}}),this.relationships.set(F,D)}setProperties(p={},y={}){const I=v(p,this.options.invalidCharacterPolicy),j=C(y,this.options.invalidCharacterPolicy);this.addPart({uri:"/docProps/core.xml",contentType:"application/vnd.openxmlformats-package.core-properties+xml",data:I}),this.addPart({uri:"/docProps/app.xml",contentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml",data:j}),this.addRelationship("/",{id:"core",type:t.coreProperties,target:"/docProps/core.xml"}),this.addRelationship("/",{id:"app",type:t.appProperties,target:"/docProps/app.xml"})}source(p){return typeof p=="string"?async y=>{const I=new h(y,this.options.signal);await I.write(p),await I.close()}:p instanceof Blob?(async function*(){for(let y=0;y<p.size;y+=65536){let I;try{I=await p.slice(y,y+65536).arrayBuffer()}catch(j){throw j?.name!=="NotReadableError"?j:new d("PLATFORM_UNAVAILABLE","This environment cannot read Blob part data. Supply text or byte chunks; read Blobs before sending data to a worker.",{cause:j})}yield new Uint8Array(I)}})():p}finish(){return this.result?this.result:(this.open(),this.state="finalizing",this.result=(async()=>{const p=this.zip;try{for(const[y,I]of this.relationships){if(y!=="/"&&!this.parts.has(y))throw new TypeError("Missing relationship source part: "+y);let j=0;for(const M of I.values()){if(m(this.options.signal),!M.external&&!this.parts.has(M.target.toLowerCase()))throw new TypeError("Missing relationship target: "+M.target);(++j&255)===0&&i()&&(await o(),m(this.options.signal))}}for(const y of this.parts.values())"written"in y||("prepared"in y?await p.addPrepared(y.uri.slice(1),y.prepared):await p.add(y.uri.slice(1),this.source(y.data)));for(const[y,I]of this.relationships){const j=y==="/"?"/":this.parts.get(y).uri;await p.add(E(j).slice(1),async M=>{const A=new h(M,this.options.signal);await A.write(f+'<Relationships xmlns="'+l+'">');for(const _ of I.values()){const F='<Relationship Id="'+u(_.id)+'" Type="'+u(_.type)+'" Target="'+u(_.external?_.target:R(j,_.target))+'"'+(_.external?' TargetMode="External"':"")+"/>";A.append(F)&&await A.flush()}await A.write("</Relationships>"),await A.close()})}return await p.add("[Content_Types].xml",this.source(this.types.toXml())),await p.finish(),this.state="complete",p.bytesWritten}catch(y){throw await this.discard(y),y}finally{this.parts.clear(),this.directories.clear(),this.relationships.clear()}})(),this.result)}async toBlob(p="application/zip"){if(this.options.sink)throw new d("INVALID_STATE","This package uses a caller-owned sink; use finish().");return await this.finish(),this.zip.toBlob(p)}async discard(p){this.state="failed",this.parts.clear(),this.directories.clear(),this.relationships.clear(),await this.zip.discard(p)}}return Object.freeze({partUri:Ne.partUri,relationshipPartUri:Ne.relationshipPartUri,relativePartTarget:Ne.relativePartTarget,corePropertiesXml:We.corePropertiesXml,appPropertiesXml:We.appPropertiesXml,relationshipsNamespace:l,officeRelationshipsNamespace:e,contentTypesNamespace:n,relationshipTypes:t,ContentTypes:r,OpcPackage:w})})(),Ue=(()=>{function T(R){if(typeof R!="string"||!/^#?(?:[0-9a-f]{6}|[0-9a-f]{8})$/i.test(R))throw new TypeError("Color must be RGB or ARGB hex.");const v=R.replace(/^#/,"").toUpperCase();return v.length===6?"FF"+v:v}return Object.freeze({colorArgb:T})})(),Xe=(()=>{const{OfficeIMOError:T}=ce,{cleanXml:E,escapeOoxmlAttribute:R}=pe,{colorArgb:v}=Ue;function C(f,m,o){if(!f||typeof f!="object"||Array.isArray(f))throw new TypeError(o+" must be an object.");if(typeof f.then=="function")throw Promise.resolve(f).catch(()=>{}),new TypeError(o+" must be synchronous.");for(const i of Object.keys(f))if(!m.includes(i))throw new TypeError("Unsupported "+o+" property: "+i)}function g(f,m){if(f!==void 0&&typeof f!="boolean")throw new TypeError(m+" must be boolean.")}class h{policy;maximum;numberFormat;definitions=new Map;constructor(m,o,i){this.policy=m,this.maximum=o,this.numberFormat=i}keys(m){const o=m.map(a=>d(a,this.policy,()=>164)),i=new Set(o.filter(a=>!this.definitions.has(a)));if(this.definitions.size+i.size>this.maximum)throw new T("RESOURCE_LIMIT","maxDifferentialStyles exceeded.");return o}check(m){this.keys(m)}add(m){const o=this.keys(m);for(let i=0;i<m.length;i++)this.definitions.has(o[i])||this.definitions.set(o[i],{id:this.definitions.size,xml:d(m[i],this.policy,this.numberFormat)});return o.map(i=>this.definitions.get(i).id)}toXml(){return this.definitions.size?'<dxfs count="'+this.definitions.size+'">'+[...this.definitions.values()].map(m=>"<dxf>"+m.xml+"</dxf>").join("")+"</dxfs>":""}}function d(f,m,o){C(f,["font","fill","border","numberFormat"],"conditional style");let i="";if(f.font!==void 0){C(f.font,["bold","italic","underline","strike","color"],"conditional font");let a="";for(const[l,e]of[["bold","b"],["italic","i"],["strike","strike"]])g(f.font[l],l),f.font[l]!==void 0&&(a+="<"+e+' val="'+(f.font[l]?1:0)+'"/>');g(f.font.underline,"underline"),f.font.underline!==void 0&&(a+='<u val="'+(f.font.underline?"single":"none")+'"/>'),f.font.color!==void 0&&(a+='<color rgb="'+v(f.font.color)+'"/>'),a&&(i+="<font>"+a+"</font>")}if(f.numberFormat!==void 0){const a=f.numberFormat;if(typeof a!="string"||!a||a.length>255||!E(a,m))throw new TypeError("Conditional number format requires 1 through 255 XML-valid characters.");i+='<numFmt numFmtId="'+o(a)+'" formatCode="'+R(a,m)+'"/>'}if(f.fill!==void 0){C(f.fill,["color"],"conditional fill");const a=v(f.fill.color);i+='<fill><patternFill patternType="solid"><fgColor rgb="'+a+'"/><bgColor rgb="'+a+'"/></patternFill></fill>'}if(f.border!==void 0){C(f.border,["left","right","top","bottom"],"conditional border");let a="";for(const l of["left","right","top","bottom"]){const e=f.border[l];if(e!==void 0){if(C(e,["style","color"],"conditional border edge"),!["thin","medium","dashed","dotted","thick","double","hair","dashDot","dashDotDot","slantDashDot","mediumDashed","mediumDashDot","mediumDashDotDot"].includes(e.style))throw new TypeError("Invalid conditional border style.");a+="<"+l+' style="'+e.style+'">'+(e.color!==void 0?'<color rgb="'+v(e.color)+'"/>':"")+"</"+l+">"}}a&&(i+="<border>"+a+"</border>")}if(!i)throw new TypeError("A conditional style must change at least one property.");return i}return Object.freeze({fields:C,optionalBoolean:g,DifferentialStyles:h,differentialXml:d})})(),Fe=(()=>{const{escapeOoxmlAttribute:T,cleanXml:E,xmlDeclaration:R}=pe,{OfficeIMOError:v}=ce,{colorArgb:C}=Ue,{DifferentialStyles:g}=Xe,h="http://schemas.openxmlformats.org/spreadsheetml/2006/main",d={General:"General",Integer:"0",Decimal:"0.00",Percent:"0.00%",Date:"yyyy-mm-dd",DateTime:"yyyy-mm-dd hh:mm:ss"};function u(l,e,n){if(!Number.isInteger(l)||l<0||l>=e)throw new RangeError("Unknown "+n+" index.");return l}function f(l,e,n,t){const s=JSON.stringify(n),r=e.get(s);if(r!==void 0)return r;if(l.length>=t)throw new v("RESOURCE_LIMIT","Style component limit exceeded.");const w=l.length;return l.push(n),e.set(s,w),w}function m(l){if(!l||typeof l!="object"||Array.isArray(l))throw new TypeError("A style patch must be a CellStyle object.");if(typeof l.then=="function")throw Promise.resolve(l).catch(()=>{}),new TypeError("Style patches must be synchronous CellStyle objects.")}function o(l){return m(l),Object.freeze({...l,...typeof l.font=="object"?{font:Object.freeze({...l.font})}:{},...typeof l.fill=="object"?{fill:Object.freeze({...l.fill})}:{},...typeof l.border=="object"?{border:Object.freeze(Object.fromEntries(Object.entries(l.border).map(([e,n])=>[e,Object.freeze({...n})])))}:{}})}class i{policy;maximum;differential;fonts=[{name:"Calibri",size:11,bold:!1,italic:!1,underline:!1,strike:!1,color:""}];fills=[{pattern:"none",color:""},{pattern:"gray125",color:""}];borders=[{}];formats=new Map;styles=[];indexes=new Map;fontIndexes=new Map(this.fonts.map((e,n)=>[JSON.stringify(e),n]));fillIndexes=new Map(this.fills.map((e,n)=>[JSON.stringify(e),n]));borderIndexes=new Map(this.borders.map((e,n)=>[JSON.stringify(e),n]));constructor(e="strip",n=64e3,t=1e3){if(this.policy=e,this.maximum=n,!Number.isSafeInteger(n)||n<1||n>64e3)throw new RangeError("maxStyles must be from 1 through 64,000.");if(!Number.isSafeInteger(t)||t<0)throw new RangeError("maxDifferentialStyles must be a nonnegative safe integer.");this.differential=new g(e,t,s=>this.addNumberFormat(s)),E("",e),this.add()}checkDifferentials(e){const n=new Set(e.flatMap(t=>t.numberFormat===void 0?[]:[E(t.numberFormat,this.policy)]).filter(t=>t!=="General"&&!this.formats.has(t)));if(this.formats.size+n.size>65372)throw new RangeError("Too many number formats.");this.differential.check(e)}addDifferentials(e){return this.checkDifferentials(e),this.differential.add(e)}addFont(e){if(e.name!==void 0&&typeof e.name!="string")throw new TypeError("Font name must be a string.");const n=E(e.name??"Calibri",this.policy),t=e.size??11;if(typeof n!="string"||!n||n.length>31)throw new TypeError("Font name must contain 1 through 31 characters.");if(!Number.isFinite(t)||t<=0||t>409)throw new RangeError("Font size must be positive and at most 409.");return f(this.fonts,this.fontIndexes,{name:n,size:t,bold:!!e.bold,italic:!!e.italic,underline:!!e.underline,strike:!!e.strike,color:e.color?C(e.color):""},this.maximum)}addFill(e){const n=e.pattern??(e.color?"solid":"none");if(!["none","gray125","solid"].includes(n)||n==="solid"&&!e.color||n!=="solid"&&e.color)throw new TypeError("A solid fill requires a color; none and gray125 have no color.");return f(this.fills,this.fillIndexes,{pattern:n,color:e.color?C(e.color):""},this.maximum+1)}addBorder(e){const n={};for(const t of["left","right","top","bottom"]){const s=e[t];if(s){if(!["thin","medium","dashed","dotted","thick","double","hair","dashDot","dashDotDot","slantDashDot","mediumDashed","mediumDashDot","mediumDashDotDot"].includes(s.style))throw new TypeError("Invalid border style.");n[t]={style:s.style,...s.color?{color:C(s.color)}:{}}}}return f(this.borders,this.borderIndexes,n,this.maximum)}addNumberFormat(e){if(typeof e!="string"||!e||e.length>255)throw new TypeError("Number format must contain 1 through 255 characters.");if(e=E(e,this.policy),!e)throw new TypeError("Number format must contain XML-valid characters.");if(e==="General")return 0;let n=this.formats.get(e);if(n===void 0){if(this.formats.size>=65372)throw new RangeError("Too many number formats.");n=this.formats.size+164,this.formats.set(e,n)}return n}add(e={}){const n=typeof e.font=="number"?u(e.font,this.fonts.length,"font"):e.font?this.addFont(e.font):0,t=typeof e.fill=="number"?u(e.fill,this.fills.length,"fill"):e.fill?this.addFill(e.fill):0,s=typeof e.border=="number"?u(e.border,this.borders.length,"border"):e.border?this.addBorder(e.border):0;let r=0;if(typeof e.numberFormat=="string")r=this.addNumberFormat(e.numberFormat);else if(e.numberFormat!==void 0&&(r=e.numberFormat,!Number.isInteger(r)||r<0||r>163&&![...this.formats.values()].includes(r)))throw new RangeError("Unknown number format index.");if(e.alignment!==void 0&&!["left","center","right","fill","justify","distributed"].includes(e.alignment))throw new TypeError("Invalid horizontal alignment.");if(e.verticalAlignment!==void 0&&!["top","center","bottom","justify","distributed"].includes(e.verticalAlignment))throw new TypeError("Invalid vertical alignment.");const w={font:n,fill:t,border:s,numberFormat:r,wrapText:!!e.wrapText,alignment:e.alignment??"",verticalAlignment:e.verticalAlignment??""},S=JSON.stringify(w),x=this.indexes.get(S);if(x!==void 0)return x;if(this.styles.length>=this.maximum)throw new v("RESOURCE_LIMIT","Workbook exceeds its cell style limit.");const p=this.styles.length;return this.styles.push(w),this.indexes.set(S,p),p}validateStyle(e){return u(e,this.styles.length,"cell style")}compose(e,n){m(n);const t=this.styles[this.validateStyle(e)];return this.add({font:t.font,fill:t.fill,border:t.border,numberFormat:t.numberFormat,wrapText:t.wrapText,...t.alignment?{alignment:t.alignment}:{},...t.verticalAlignment?{verticalAlignment:t.verticalAlignment}:{},...n,...typeof n.font=="object"?{font:{...this.fonts[t.font],...n.font}}:{},...typeof n.border=="object"?{border:{...this.borders[t.border],...n.border}}:{}})}dateHeader(e,n){return this.compose(e,{numberFormat:this.styles[this.validateStyle(n)].numberFormat})}forColumn(e,n=!1,t,s=!1){const r=!n&&e.style!==void 0?this.styles[this.validateStyle(e.style)]:void 0,w=e.format!==void 0?e.format||d.General:r?.numberFormat||(e.type==="date"||s?d.DateTime:d.General);return this.add({...r?{font:r.font,fill:r.fill,border:r.border}:{},numberFormat:w,wrapText:e.wrapText??r?.wrapText??!1,...e.alignment?{alignment:e.alignment}:r?.alignment?{alignment:r.alignment}:{},...r?.verticalAlignment?{verticalAlignment:r.verticalAlignment}:{},...n?{font:{bold:!0}}:{},...t?{fill:{color:t}}:{}})}toXml(){const e=t=>"<font>"+(t.bold?"<b/>":"")+(t.italic?"<i/>":"")+(t.underline?"<u/>":"")+(t.strike?"<strike/>":"")+'<sz val="'+t.size+'"/>'+(t.color?'<color rgb="'+t.color+'"/>':"")+'<name val="'+T(t.name,this.policy)+'"/></font>',n=t=>"<border>"+["left","right","top","bottom"].map(s=>{const r=t[s];return r?"<"+s+' style="'+r.style+'">'+(r.color?'<color rgb="'+r.color+'"/>':"")+"</"+s+">":"<"+s+"/>"}).join("")+"<diagonal/></border>";return R+'<styleSheet xmlns="'+h+'"><numFmts count="'+this.formats.size+'">'+[...this.formats].map(([t,s])=>'<numFmt numFmtId="'+s+'" formatCode="'+T(t,this.policy)+'"/>').join("")+'</numFmts><fonts count="'+this.fonts.length+'">'+this.fonts.map(e).join("")+'</fonts><fills count="'+this.fills.length+'">'+this.fills.map(t=>'<fill><patternFill patternType="'+t.pattern+'">'+(t.color?'<fgColor rgb="'+t.color+'"/><bgColor indexed="64"/>':"")+"</patternFill></fill>").join("")+'</fills><borders count="'+this.borders.length+'">'+this.borders.map(n).join("")+'</borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="'+this.styles.length+'">'+this.styles.map(t=>{const s=t.wrapText||t.alignment||t.verticalAlignment?"<alignment"+(t.wrapText?' wrapText="1"':"")+(t.alignment?' horizontal="'+t.alignment+'"':"")+(t.verticalAlignment?' vertical="'+t.verticalAlignment+'"':"")+"/>":"";return'<xf numFmtId="'+t.numberFormat+'" fontId="'+t.font+'" fillId="'+t.fill+'" borderId="'+t.border+'" xfId="0"'+(t.numberFormat?' applyNumberFormat="1"':"")+(t.font?' applyFont="1"':"")+(t.fill?' applyFill="1"':"")+(t.border?' applyBorder="1"':"")+(s?' applyAlignment="1"':"")+">"+s+"</xf>"}).join("")+'</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>'+this.differential.toXml()+"</styleSheet>"}}return Object.freeze({colorArgb:Ue.colorArgb,spreadsheetNamespace:h,NumberFormats:d,validateStylePatch:m,copyStylePatch:o,StyleRegistry:i})})(),rt=(()=>{function T(R){if(!R||typeof R!="object")throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const{target:v,tooltip:C}=R;if(typeof v!="string"||!/^(?:https?:\/\/|mailto:)/i.test(v)||/[\u0000-\u0020\u007f]/.test(v))throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const g=new URL(v);if((g.protocol==="http:"||g.protocol==="https:")&&(!g.hostname||g.username||g.password))throw new TypeError("Hyperlink HTTP targets need a host and must not contain credentials.");if(C!==void 0&&typeof C!="string")throw new TypeError("Hyperlink tooltip must be text.");return Object.freeze({target:g.href,...C===void 0?{}:{tooltip:C}})}return Object.freeze({copyExportLink:T})})(),xe=(()=>{const{isDate:T}=Se,{copyExportLink:E}=rt,R=Symbol.for("@evotecit/officeimo/ExportCell");function v(u){if(!u||typeof u!="object"||Array.isArray(u))throw new TypeError("Cell presentation must be an object.");const f={};for(const m of["background","color","numberFormat","bold","italic","wrapText","alignment"]){const o=u[m];if(o!==void 0){if(["bold","italic","wrapText"].includes(m)){if(typeof o!="boolean")throw new TypeError("Cell presentation "+m+" must be boolean.")}else if(typeof o!="string")throw new TypeError("Cell presentation "+m+" must be text.");if(m==="alignment"&&!["left","center","right","fill","justify","distributed"].includes(o))throw new TypeError("Invalid cell presentation alignment.");f[m]=o}}return Object.freeze(f)}class C{value;static[Symbol.hasInstance](f){return!!f&&typeof f=="object"&&f[R]===!0}text;presentation;link;constructor(f,m={}){this.value=f;const{text:o,presentation:i,link:a}=m;if(o!==void 0&&typeof o!="string")throw new TypeError("Display text must be a string.");g(f),this.text=o,this.presentation=i===void 0?void 0:v(i),this.link=a===void 0?void 0:E(a),Object.defineProperty(this,R,{value:!0}),Object.freeze(this)}}function g(u){const f=typeof u;if(!(u==null||f==="string"||f==="number"||f==="boolean"||T(u)))throw typeof u.then=="function"&&Promise.resolve(u).catch(()=>{}),new TypeError("Export values and formatter results must be synchronous strings, numbers, booleans, Dates or null.")}function h(u){u!==null&&typeof u=="object"&&u instanceof C||g(u)}return Object.freeze({copyCellPresentation:v,ExportCell:C,assertScalar:g,assertExportValue:h})})(),_e=(()=>{const{NotSupportedError:T}=ce,{cleanXml:E,escapeXml:R}=pe,v=new WeakSet,C=new WeakSet;function g(o){let i=!1;const a=/[\p{L}_\\][\p{L}\p{N}\p{M}_.\\]*/uy;for(let l=0;l<o.length;l++){const e=o[l];if(e==='"'){for(;++l<o.length;)if(o[l]==='"'){if(o[l+1]!=='"')break;l++}}else if(e==="'"){let n="";for(;++l<o.length;){if(o[l]==="'"){if(o[l+1]!=="'")break;l++}n+=o[l]}if(o.slice(l+1).trimStart().startsWith("!")&&/[\[\]]/.test(n))throw new T("external-workbook formulas")}else if(e==="["){let n=1;for(;++l<o.length&&n;){if(o[l]==="'"){l++;continue}o[l]==="["?n++:o[l]==="]"&&n--}if(/^[A-Za-z0-9_.]*!/.test(o.slice(l)))throw new T("external-workbook formulas");l--}else{if(e==="|")throw new T("DDE formulas");{a.lastIndex=l;const n=a.exec(o);n&&(["SUBTOTAL","AGGREGATE","_XLFN.AGGREGATE"].includes(n[0].toUpperCase())&&/^\s*\(/.test(o.slice(a.lastIndex))&&(i=!0),l=a.lastIndex-1)}}}return i}function h(o){if(typeof o!="string")throw new TypeError("Formula text must be a string.");const i=o.trim().replace(/^=/,"");if(!i.trim()||i.length>8192)throw new RangeError("Formulas require 1 through 8,192 characters.");return E(i,"reject"),{text:i,subtotal:g(i)}}class d{cachedValue;style;static[Symbol.hasInstance](i){return i!==null&&typeof i=="object"&&v.has(i)}formula;constructor(i,a,l){this.cachedValue=a,this.style=l;const e=h(i);if(this.formula=e.text,a!==null&&(typeof a!="number"||!Number.isFinite(a)))throw new TypeError("Formula caches must be finite numbers or null for a blank result.");if(l!==void 0&&(!Number.isSafeInteger(l)||l<0))throw new RangeError("Formula style indexes must be nonnegative safe integers.");v.add(this),e.subtotal&&C.add(this),Object.freeze(this)}}function u(o){return C.has(o)}function f(o){if(!(o instanceof d))throw new TypeError("Formula cells must be created with FormulaCell.");return"<f>"+R(o.formula,"reject")+"</f><v>"+(o.cachedValue??"")+"</v>"}return Object.freeze({FormulaCell:d,isSubtotalFormula:u,formulaXml:f})})(),He=(()=>{const{ExportCell:T,assertExportValue:E}=xe,{isDate:R}=Se;function v(g){if(E(g),R(g))return new Date(Date.prototype.getTime.call(g));if(g instanceof T){const{value:h,text:d,presentation:u,link:f}=g;return new T(R(h)?new Date(Date.prototype.getTime.call(h)):h,{...d===void 0?{}:{text:d},...u===void 0?{}:{presentation:u},...f===void 0?{}:{link:f}})}return g}return Object.freeze({copyExportValue:v})})(),ke=(()=>{const{cleanXml:T,escapeXml:E}=pe,{assertExportValue:R,assertScalar:v}=xe,{FormulaCell:C}=_e,{copyExportValue:g}=He;class h{value;style;constructor(s,r){this.value=s,this.style=r}}function d(t){t instanceof C||(t instanceof h?v(t.value):R(t))}function u(t){return t instanceof C?t:t instanceof h?Object.freeze(new h(g(t.value),t.style)):g(t)}function f(t,s="strip"){const r=T(t,s);if(r.length>32767)throw new RangeError("Excel cell text exceeds 32,767 UTF-16 code units.");return r}function m(t,s){const r=f(t,s),w=S=>'<t xml:space="preserve">'+E(S,s)+"</t>";return/_x[0-9a-f]{4}_/i.test(r)?r.split(/(?<=_)(?=x[0-9a-f]{4}_)/gi).map(S=>"<r>"+w(S)+"</r>").join(""):w(r)}function o(t){if(!Number.isInteger(t)||t<1||t>16384)throw new RangeError("Column index must be from 1 through 16,384.");let s="";for(;t;)t--,s=String.fromCharCode(65+t%26)+s,t=Math.floor(t/26);return s}function i(t,s){return t.slice(0,s).replace(/[\ud800-\udbff]$/,"")}function a(t){let s=0,r=t.length;const w=S=>S==="'"||/\s/u.test(S);for(;s<r&&w(t[s]);)s++;for(;r>s&&w(t[r-1]);)r--;return t.slice(s,r)}function l(t,s,r,w=!0){if(typeof t!="string")throw new TypeError("Sheet name must be a string.");let S=a(T(t,r).replace(/[\[\]:*?/\\]/g,"_"));S=a(i(S,31)),S||(S="Sheet"),S.toLowerCase()==="history"&&(S+="_");let x=S,p=2;for(;s.has(x.toLowerCase());){const y=" ("+p+++")";x=i(S,31-y.length)+y}return w&&s.add(x.toLowerCase()),x}function e(t,s){if(!Number.isFinite(t.getTime()))return null;const r=s==="utc",w=r?t.getUTCFullYear():t.getFullYear();if(w<1900||w>9999)throw new RangeError("Excel dates must be in years 1900 through 9999.");const S=new Date(0);S.setUTCFullYear(w,r?t.getUTCMonth():t.getMonth(),r?t.getUTCDate():t.getDate()),S.setUTCHours(r?t.getUTCHours():t.getHours(),r?t.getUTCMinutes():t.getMinutes(),r?t.getUTCSeconds():t.getSeconds(),r?t.getUTCMilliseconds():t.getMilliseconds());const x=S.getTime();return(x-Date.UTC(1899,11,31))/864e5+(x>=Date.UTC(1900,2,1)?1:0)}return Object.freeze({Cell:h,assertXlsxValue:d,copyValue:u,cellText:f,inlineText:m,columnName:o,sheetName:l,excelDate:e})})(),Be=(()=>{const{assertExportValue:T}=xe,{checkAbort:E}=ge,{isDate:R}=Se,{captureFields:v}=be;function C(u,f,m,o=T){const i=u.some(a=>a.value);return(a,l=0)=>{if(Array.isArray(a)&&!i){const e=a.length;if(e>u.length)throw new RangeError("Row has more values than declared columns.");const n=new Array(e);for(let t=0;t<e;t++){const s=a[t];o(s),n[t]=s}return n}if(!a||typeof a!="object"||R(a))throw new TypeError("A row must be an array or object.");if(Array.isArray(a)&&a.length>u.length&&!u.every(e=>e.value))throw new RangeError("Project every column explicitly when selecting from a wider array row.");return u.map((e,n)=>{if(e.value){E(m);const r={rowIndex:l,columnIndex:n,column:e,...f?{sheetName:f.sheetName,worksheetRow:f.firstDataRow+l}:{}},w=e.value(a,r);return o(w),E(m),w}if(Array.isArray(a)){const r=a[n];return o(r),r}const t=e.key??e.header,s=Object.prototype.hasOwnProperty.call(a,t)?a[t]:void 0;return o(s),s})}}const g=["header","key","value","width","type","format","wrapText","alignment","rowHeader","groups","style","valueFormatter"];function h(u,f=!1){if(!Array.isArray(u))throw new TypeError("Declare the columns in export order.");return u.map(m=>{if(!m||typeof m!="object"&&typeof m!="function")throw new TypeError("Each column needs a string header and an optional string key.");const o=v(m,g);if(!f&&o.style!==void 0)throw new TypeError("Workbook-local column styles require the advanced Workbook API; use portable ExportCell presentation.");if(typeof o.header!="string"||o.key!==void 0&&typeof o.key!="string")throw new TypeError("Each column needs a string header and an optional string key.");if(o.value!==void 0&&typeof o.value!="function")throw new TypeError("Column value getters must be functions.");if(o.rowHeader!==void 0&&typeof o.rowHeader!="boolean")throw new TypeError("Column rowHeader must be boolean.");if(o.groups!==void 0){if(!Array.isArray(o.groups))throw new TypeError("Column groups must be an array of strings.");const i=Array.from(o.groups);if(i.some(a=>typeof a!="string"))throw new TypeError("Column groups must be an array of strings.");return{...o,groups:Object.freeze(i)}}return o})}return Object.freeze({createRowProjector:C,columnOptionFields:g,copyColumns:h})})(),nt=(()=>{const{captureFields:T}=be;function E(g,h){if(g===void 0)return;if(!Array.isArray(g)||g.length>h)throw new TypeError("Column outlines must be bounded, non-overlapping ranges.");let d=0;return Object.freeze(g.map(u=>{if(!u||typeof u!="object")throw new TypeError("Column outlines require range metadata.");return T(u,["firstColumn","columnCount","level","hidden","collapsed"])}).sort((u,f)=>u.firstColumn-f.firstColumn).map(u=>{const{firstColumn:f,columnCount:m,level:o=0,hidden:i,collapsed:a}=u;if(!Number.isSafeInteger(f)||f<d||!Number.isSafeInteger(m)||m<1||f+m>h)throw new RangeError("Column outline ranges must be disjoint and within the declared columns.");if(!Number.isInteger(o)||o<0||o>7)throw new RangeError("Column outline level must be from zero through seven.");for(const l of[i,a])if(l!==void 0&&typeof l!="boolean")throw new TypeError("Column outline flags must be booleans.");return d=f+m,Object.freeze({firstColumn:f,columnCount:m,level:o,...i===void 0?{}:{hidden:i},...a===void 0?{}:{collapsed:a}})}))}function R(g){for(const h of[g.outlineSummaryBelow,g.outlineSummaryRight])if(h!==void 0&&typeof h!="boolean")throw new TypeError("Outline summary positions must be booleans.")}function v(g){const h=new Map;for(const d of g??[])for(let u=d.firstColumn;u<d.firstColumn+d.columnCount;u++)h.set(u,d);return h}return Object.freeze({captureColumnOutlines:E,validateOutlinePositions:R,columnOutlineMap:v})})(),st=(()=>{const{assertExportValue:T}=xe,{copyExportValue:E}=He;function R(g,h){if(!Array.isArray(g)||!g.length||g.length>16)throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");const d=g.map(u=>{if(!Array.isArray(u)||u.length!==h)throw new TypeError("Spanned rows must have the declared column count.");return Object.freeze(u.map(f=>{if(f===null)return null;if(!f||typeof f!="object")throw new TypeError("Uncovered heading/footer cells need an anchor value.");const{value:m,columnSpan:o,rowSpan:i}=f;return Object.freeze({value:E(m),...o===void 0?{}:{columnSpan:o},...i===void 0?{}:{rowSpan:i}})}))});return v(d,h),Object.freeze(d)}function v(g,h){if(!Array.isArray(g)||!g.length||g.length>16)throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");const d=Array.from({length:g.length},()=>new Uint8Array(h));return g.map((u,f)=>{if(!Array.isArray(u)||u.length!==h)throw new TypeError("Spanned rows must have the declared column count.");const m=[];for(let o=0;o<h;o++){const i=u[o];if(d[f][o]){if(i!==null)throw new TypeError("Covered heading/footer cells must be null.");continue}if(!i||typeof i!="object")throw new TypeError("Uncovered heading/footer cells need an anchor value.");const a=i.columnSpan??1,l=i.rowSpan??1;if(!Number.isInteger(a)||!Number.isInteger(l)||a<1||l<1||o+a>h||f+l>g.length)throw new RangeError("Heading/footer spans must stay inside the declared matrix.");const e=i.value;T(e);for(let n=f;n<f+l;n++)for(let t=o;t<o+a;t++){if(d[n][t])throw new TypeError("Heading/footer spans overlap.");if((n!==f||t!==o)&&g[n]?.[t]!==null)throw new TypeError("Covered heading/footer cells must be null.");d[n][t]=1}m.push(Object.freeze({first:o,span:a,rowSpan:l,value:e}))}return Object.freeze(m)})}return Object.freeze({captureTableSpans:R,tableSpans:v})})(),ot=(()=>{const{ChunkedTextSink:T}=Te,{escapeXml:E,xmlDeclaration:R}=pe,{officeRelationshipsNamespace:v}=Me,{columnName:C}=ke,g="http://schemas.openxmlformats.org/drawingml/2006/chart",h="application/vnd.openxmlformats-officedocument.drawingml.chart+xml";function d(e,n,t){const s=' cx="'+Math.round(e.width*9525)+'" cy="'+Math.round(e.height*9525)+'"';return"<xdr:oneCellAnchor><xdr:from><xdr:col>"+(e.column-1)+"</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>"+(e.row-1)+"</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:from><xdr:ext"+s+'/><xdr:graphicFrame macro=""><xdr:nvGraphicFramePr><xdr:cNvPr id="'+n+'" name="Chart '+e.id+'" descr="'+E(e.description??e.title??"",t)+'"/><xdr:cNvGraphicFramePr/></xdr:nvGraphicFramePr><xdr:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/></xdr:xfrm><a:graphic><a:graphicData uri="'+g+'"><c:chart xmlns:c="'+g+'" r:id="chart'+e.id+'"/></a:graphicData></a:graphic></xdr:graphicFrame><xdr:clientData/></xdr:oneCellAnchor>'}function u(e,n){return'<c:title><c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:r><a:t xml:space="preserve">'+E(e,n)+'</a:t></a:r></a:p></c:rich></c:tx><c:overlay val="0"/></c:title>'}function*f(e,n,t,s){yield"<c:"+e+"Ref><c:f>"+E(n,s)+"</c:f><c:"+e+"Cache>",e==="num"&&(yield"<c:formatCode>General</c:formatCode>"),yield'<c:ptCount val="'+t.length+'"/>';for(let r=0;r<t.length;r++)yield'<c:pt idx="'+r+'"><c:v xml:space="preserve">'+E(String(t[r]),s)+"</c:v></c:pt>";yield"</c:"+e+"Cache></c:"+e+"Ref>"}function m(e,n){const t=e.dataLabels;if(!t)return"";const s={center:"ctr",insideEnd:"inEnd",outsideEnd:"outEnd",bestFit:"bestFit",above:"t",below:"b",left:"l",right:"r"};return"<c:dLbls>"+(t.numberFormat===void 0?"":'<c:numFmt formatCode="'+E(t.numberFormat,n)+'" sourceLinked="0"/>')+(t.position===void 0?"":'<c:dLblPos val="'+s[t.position]+'"/>')+'<c:showLegendKey val="0"/><c:showVal val="'+(t.showValue===!1?0:1)+'"/><c:showCatName val="'+(t.showCategoryName?1:0)+'"/><c:showSerName val="'+(t.showSeriesName?1:0)+'"/><c:showPercent val="'+(t.showPercent?1:0)+'"/><c:showBubbleSize val="0"/></c:dLbls>'}function o(e,n){const t=e.type==="barClustered",s=e.valueAxis,r='<c:scaling><c:orientation val="minMax"/>'+(s?.maximum===void 0?"":'<c:max val="'+s.maximum+'"/>')+(s?.minimum===void 0?"":'<c:min val="'+s.minimum+'"/>')+"</c:scaling>",w='<c:majorTickMark val="none"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/>';return'<c:catAx><c:axId val="1"/><c:scaling><c:orientation val="minMax"/></c:scaling><c:delete val="0"/><c:axPos val="'+(t?"l":"b")+'"/>'+(e.categoryAxis?.title?u(e.categoryAxis.title,n):"")+'<c:numFmt formatCode="General" sourceLinked="1"/>'+w+'<c:crossAx val="2"/><c:crosses val="autoZero"/><c:auto val="1"/><c:lblAlgn val="ctr"/><c:lblOffset val="100"/><c:noMultiLvlLbl val="0"/></c:catAx><c:valAx><c:axId val="2"/>'+r+'<c:delete val="0"/><c:axPos val="'+(t?"b":"l")+'"/><c:majorGridlines/>'+(s?.title?u(s.title,n):"")+'<c:numFmt formatCode="'+E(s?.numberFormat??"General",n)+'" sourceLinked="'+(s?.numberFormat===void 0?1:0)+'"/>'+w+'<c:crossAx val="1"/><c:crosses val="autoZero"/><c:crossBetween val="between"/></c:valAx>'}function*i(e,n){const t=e.type==="pie",s=e.type==="line",r=t?"pieChart":s?"lineChart":"barChart",w="'"+e.dataSheetName.replace(/'/g,"''")+"'!",S=e.data.categories.length+1;yield R+'<c:chartSpace xmlns:c="'+g+'" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="'+v+'"><c:date1904 val="0"/>'+(e.language===void 0?"":'<c:lang val="'+E(e.language,n)+'"/>')+"<c:chart>",e.title&&(yield u(e.title,n)),yield'<c:autoTitleDeleted val="'+(e.title?0:1)+'"/><c:plotArea><c:layout/><c:'+r+">",t||(yield s?'<c:grouping val="standard"/>':'<c:barDir val="'+(e.type==="barClustered"?"bar":"col")+'"/><c:grouping val="clustered"/>'),yield'<c:varyColors val="'+(t?1:0)+'"/>';for(let x=0;x<e.data.series.length;x++){const p=e.data.series[x],y="$"+C(x+2);yield'<c:ser><c:idx val="'+x+'"/><c:order val="'+x+'"/><c:tx>';const I=e.binding?e.binding.references.names[x]:w+y+"$1";I===void 0?yield"<c:v>"+E(p.name,n)+"</c:v>":yield*f("str",I,[p.name],n),yield"</c:tx>",p.color&&(yield"<c:spPr>"+(s?'<a:ln w="25400">':"")+'<a:solidFill><a:srgbClr val="'+p.color+'"/></a:solidFill>'+(s?"</a:ln>":"")+"</c:spPr>"),!s&&!t&&(yield'<c:invertIfNegative val="0"/>'),yield"<c:cat>",yield*f("str",e.binding?.references.categories??w+"$A$2:$A$"+S,e.data.categories,n),yield"</c:cat><c:val>",yield*f("num",e.binding?.references.values[x]??w+y+"$2:"+y+"$"+S,p.values,n),yield"</c:val>"+(s?'<c:smooth val="0"/>':"")+"</c:ser>"}yield m(e,n),!t&&!s&&(yield'<c:gapWidth val="150"/><c:overlap val="0"/>'),t||(yield'<c:axId val="1"/><c:axId val="2"/>'),yield"</c:"+r+">",t||(yield o(e,n)),yield"</c:plotArea>",e.legend!==!1&&(yield'<c:legend><c:legendPos val="'+{right:"r",bottom:"b",left:"l",top:"t"}[e.legend??"right"]+'"/><c:layout/><c:overlay val="0"/></c:legend>'),yield'<c:plotVisOnly val="'+(e.binding?1:0)+'"/><c:dispBlanksAs val="gap"/><c:showDLblsOverMax val="0"/></c:chart></c:chartSpace>'}async function a(e,n,t,s){const r=new T(n,s);for(const w of i(e,t))r.append(w)&&await r.flush();await r.close()}return Object.freeze({chartNamespace:g,chartContentType:h,chartAnchorXml:d,writeChartXml:a})})(),ze=(()=>{const{cleanXml:T,escapeXml:E,escapeOoxmlAttribute:R,xmlDeclaration:v}=pe,{copyExportLink:C}=rt,{officeRelationshipsNamespace:g}=Me,{chartAnchorXml:h}=ot,{captureFields:d}=be;function u(n,t){if(n=d(n,["row","column","width","height","description"]),!Number.isInteger(n.row)||n.row<1||n.row>1048576||!Number.isInteger(n.column)||n.column<1||n.column>16384)throw new RangeError("Drawing anchors must be one-based worksheet rows and columns.");for(const s of[n.width,n.height])if(!Number.isFinite(s)||s<=0||s>1e5)throw new RangeError("Drawing display dimensions must be positive and at most 100,000 pixels.");if(n.description!==void 0&&typeof n.description!="string")throw new TypeError("Drawing description must be a string.");return Object.freeze({row:n.row,column:n.column,width:n.width,height:n.height,...n.description===void 0?{}:{description:T(n.description,t)}})}function f(n){const t=typeof n=="string"&&/^([A-Z]{1,3})([1-9][0-9]{0,6})$/.exec(n);if(!t)throw new TypeError("Use a single uppercase A1 cell reference.");const s=Number(t[2]);let r=0;for(const w of t[1])r=r*26+w.charCodeAt(0)-64;if(r>16384||s>1048576)throw new RangeError("Cell reference exceeds Excel's worksheet bounds.");return{row:s,column:r}}function m(n,t){n=d(n,["cell","target","tooltip"]),f(n.cell);const s=C(n);return Object.freeze({cell:n.cell,target:s.target,...s.tooltip===void 0?{}:{tooltip:T(s.tooltip,t)}})}function o(n,t,s){if(n=d(n,["data","row","column","width","height","description"]),n.data instanceof Uint8Array&&s?.(n.data.length),!(n.data instanceof Uint8Array)||n.data.length<33||![137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82].every((w,S)=>n.data[S]===w))throw new TypeError("Images require PNG bytes with a valid signature and IHDR header.");const r=new DataView(n.data.buffer,n.data.byteOffset,n.data.byteLength);if(!r.getUint32(16)||!r.getUint32(20))throw new RangeError("PNG dimensions must be positive.");return Object.freeze({...u(n,t),data:new Uint8Array(n.data)})}function i(n,t,s=[]){return"<hyperlinks>"+n.map((r,w)=>'<hyperlink ref="'+r.cell+'" r:id="link'+(w+1)+'"'+(r.tooltip===void 0?"":' tooltip="'+R(r.tooltip,t)+'"')+"/>").join("")+s.map(r=>'<hyperlink ref="'+r.cell+'" location="'+R(r.location,t)+'"/>').join("")+"</hyperlinks>"}function a(n,t,s=[]){const r="http://schemas.openxmlformats.org/drawingml/2006/";return v+'<xdr:wsDr xmlns:xdr="'+r+'spreadsheetDrawing" xmlns:a="'+r+'main" xmlns:r="'+g+'">'+n.map((w,S)=>{const x=' cx="'+Math.round(w.width*9525)+'" cy="'+Math.round(w.height*9525)+'"';return"<xdr:oneCellAnchor><xdr:from><xdr:col>"+(w.column-1)+"</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>"+(w.row-1)+"</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:from><xdr:ext"+x+'/><xdr:pic><xdr:nvPicPr><xdr:cNvPr id="'+(S+1)+'" name="Image '+(S+1)+'" descr="'+E(w.description??"",t)+'"/><xdr:cNvPicPr/></xdr:nvPicPr><xdr:blipFill><a:blip r:embed="image'+(S+1)+'"/><a:stretch><a:fillRect/></a:stretch></xdr:blipFill><xdr:spPr><a:xfrm><a:off x="0" y="0"/><a:ext'+x+'/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></xdr:spPr></xdr:pic><xdr:clientData/></xdr:oneCellAnchor>'}).join("")+s.map((w,S)=>h(w,n.length+S+1,t)).join("")+"</xdr:wsDr>"}return Object.freeze({copyDrawingAnchor:u,cellPosition:f,copyHyperlink:m,copyImage:o,hyperlinksXml:i,drawingXml:a,drawingContentType:"application/vnd.openxmlformats-officedocument.drawing+xml"})})(),ft=(()=>{const{OfficeIMOError:T}=ce,{cellPosition:E}=ze;function R(h){if(!h.length)return;const d=[...h].sort((l,e)=>l.top-e.top),u=d[Math.floor(d.length/2)].top,f=[],m=[],o=[];for(const l of d)(l.bottom<u?m:l.top>u?o:f).push(l);const i=R(m),a=R(o);return{middle:u,starts:f,ends:[...f].sort((l,e)=>e.bottom-l.bottom),...i?{before:i}:{},...a?{after:a}:{}}}function v(h,d,u){if(h){for(const f of d<=h.middle?h.starts:h.ends){if(d<=h.middle?f.top>d:f.bottom<d)break;u.push(f)}v(d<h.middle?h.before:d>h.middle?h.after:void 0,d,u)}}class C{references;index;currentRow=-1;current=[];lastRow;constructor(d,u,f){if(d.length>f)throw new T("RESOURCE_LIMIT","maxMergedRanges exceeded.");if(!d.length){this.references=Object.freeze([]),this.lastRow=0,this.index=void 0;return}const m=d.map(e=>{if(typeof e!="string"||e.split(":").length!==2)throw new TypeError("Merged ranges require uppercase A1:B2 references.");const[n,t]=e.split(":"),s=E(n),r=E(t);if(r.row<s.row||r.column<s.column||r.row===s.row&&r.column===s.column)throw new RangeError("Merged ranges require ordered distinct cells.");if(r.column>u)throw new RangeError("Merged ranges must stay within declared columns.");return{ref:e,top:s.row,bottom:r.row,left:s.column,right:r.column}}),o=m.flatMap(e=>[{row:e.top,delta:1,region:e},{row:e.bottom+1,delta:-1,region:e}]).sort((e,n)=>e.row-n.row||e.delta-n.delta),i=new Int32Array(65536),a=new Int32Array(65536);function l(e,n,t,s,r,w){if(s<=n&&t<=r){i[e]=i[e]+w,a[e]=a[e]+w;return}const S=n+t>>>1;s<=S&&l(e*2,n,S,s,r,w),r>S&&l(e*2+1,S+1,t,s,r,w),i[e]=a[e]+Math.max(i[e*2],i[e*2+1])}for(const e of o)if(l(1,1,16384,e.region.left,e.region.right,e.delta),i[1]>1)throw new TypeError("Merged ranges must not overlap: "+e.region.ref);this.references=Object.freeze(m.map(e=>e.ref)),this.lastRow=m.reduce((e,n)=>Math.max(e,n.bottom),0),this.index=R(m)}covered(d,u){if(!this.index||u>this.lastRow)return!1;this.currentRow!==u&&(this.current=[],v(this.index,u,this.current),this.current.sort((o,i)=>o.left-i.left),this.currentRow=u);let f=0,m=this.current.length-1;for(;f<=m;){const o=f+m>>>1,i=this.current[o];if(d<i.left)m=o-1;else if(d>i.right)f=o+1;else return u!==i.top||d!==i.left}return!1}validateRows(d){if(this.lastRow>d)throw new RangeError("Merged ranges must stay within exported rows.")}}return Object.freeze({MergeRegions:C})})(),it=(()=>{class T{operation;count=0;sum=0;mean=0;min=1/0;max=-1/0;constructor(C){this.operation=C}accept(C){if(!(!this.operation||typeof C!="number"||!Number.isFinite(C)))if(this.count++,this.operation==="sum"){if(this.sum+=C,!Number.isFinite(this.sum))throw new RangeError("Numeric total exceeds finite number range.")}else if(this.operation==="average"){const g=C-this.mean;this.mean=this.count===1?C:Number.isFinite(g)?this.mean+g/this.count:this.mean*((this.count-1)/this.count)+C/this.count}else this.operation==="min"?this.min=Math.min(this.min,C):this.operation==="max"&&(this.max=Math.max(this.max,C))}value(){return this.operation==="count"?this.count:this.operation==="sum"?this.sum:this.count?this.operation==="average"?this.mean:this.operation==="min"?this.min:this.max:null}}function E(v,C={}){const g=v.map(h=>h.key??h.header);for(const[h,d]of Object.entries(C)){if(g.filter(u=>u===h).length!==1)throw new TypeError("Totals need an unambiguous declared column key: "+h);if(!["sum","count","average","min","max"].includes(d))throw new TypeError("Invalid total operation.")}return g.map(h=>new T(Object.prototype.hasOwnProperty.call(C,h)?C[h]:void 0))}return Object.freeze({NumericAggregate:T,createTotals:E})})(),mt=(()=>{const{ExportCell:T}=xe,{tableSpans:E}=st,{copyValue:R,columnName:v}=ke;class C{values;ranges;constructor(d,u){const f=E(d,u),m=[];this.values=f.map((o,i)=>{const a=Array(u).fill(void 0);for(const l of o)a[l.first]=R(l.value),(l.span>1||l.rowSpan>1)&&m.push({first:l.first+1,last:l.first+l.span,top:i+1,bottom:i+l.rowSpan});return Object.freeze(a)}),this.ranges=m}get mergeCount(){return this.ranges.length}merges(d){return this.ranges.map(u=>v(u.first)+(u.top+d)+":"+v(u.last)+(u.bottom+d))}matchesLeaf(d){const u=this.values.length;return!this.ranges.some(f=>f.bottom===u)&&this.values[u-1].every((f,m)=>(f instanceof T?f.value:f)===d[m])}}return Object.freeze({StructuredRows:C})})(),at=(()=>{const{ExportCell:T}=xe,{isDate:E}=Se,{Cell:R,cellText:v,columnName:C}=ke,{FormulaCell:g}=_e,{escapeOoxmlAttribute:h}=pe,{MergeRegions:d}=ft,{OfficeIMOError:u}=ce,{createTotals:f}=it,{StructuredRows:m}=mt;class o{value;formula;operation;constructor(s,r,w){this.value=s,this.formula=r,this.operation=w}}class i{columns;options;headings;merges;headerRows;firstHeaderRow;regions;widths;sampleRows;structuredFooter;footerRows;mergeCount;aggregates;constructor(s,r,w,S=1e4,x=1e5){this.columns=s,this.options=r;const p=r.title===void 0?0:1;if(r.title!==void 0){if(!s.length)throw new TypeError("Report titles require declared columns.");if(typeof r.title.text!="string")throw new TypeError("Report title text must be a string.");if(v(r.title.text,w),r.title.height!==void 0&&(!Number.isFinite(r.title.height)||r.title.height<=0||r.title.height>409))throw new RangeError("Title height must be positive and at most 409 points.")}const y=Math.max(0,...s.map(F=>F.groups?.length??0));if(r.headerRows===void 0){if(y>16)throw new RangeError("Grouped headings support at most 16 levels.");if(y&&r.includeHeader===!1)throw new TypeError("Grouped headings require leaf headers.")}const I=[],j=[];if(p&&s.length>1&&j.push("A1:"+C(s.length)+"1"),r.headerRows!==void 0&&r.includeHeader!==!1){const F=new m(r.headerRows,s.length);if((r.table||r.autoFilter)&&!F.matchesLeaf(s.map(D=>D.header)))throw new TypeError("Native tables and autofilters require an unmerged final heading row matching the declared leaf headers.");I.push(...F.values),j.push(...F.merges(p))}else if(r.includeHeader!==!1){for(let F=0;F<y;F++){const D=s.map(q=>q.groups?.[F]??"");for(const q of D)v(q,w);for(let q=0;q<s.length;){let H=q;const te=JSON.stringify(s[q].groups?.slice(0,F+1));for(;H+1<s.length&&D[q]&&JSON.stringify(s[H+1].groups?.slice(0,F+1))===te;)H++;if(H>q){j.push(C(q+1)+(F+1+p)+":"+C(H+1)+(F+1+p));for(let ee=q+1;ee<=H;ee++)D[ee]=""}q=H+1}I.push(D)}s.length&&I.push(s.map(F=>F.header))}if(this.headerRows=p+I.length,this.firstHeaderRow=s.length&&r.includeHeader!==!1?p+1:0,r.mergedCells!==void 0&&!Array.isArray(r.mergedCells))throw new TypeError("Merged ranges must be an array.");if(r.footer?.rows!==void 0&&(r.footer.values!==void 0||r.footer.totals!==void 0))throw new TypeError("Structured footer rows cannot accompany footer values or totals.");if(this.structuredFooter=r.footer?.rows===void 0?void 0:new m(r.footer.rows,s.length),this.footerRows=this.structuredFooter?.values.length??(r.footer?1:0),this.mergeCount=j.length+(r.mergedCells?.length??0)+(this.structuredFooter?.mergeCount??0),this.mergeCount>S)throw new u("RESOURCE_LIMIT","maxMergedRanges exceeded.");if(this.regions=new d([...j,...r.mergedCells??[]],s.length,S),r.table){for(const F of r.mergedCells??[])if(Number(F.split(":")[1].match(/\d+$/)[0])>=this.headerRows)throw new TypeError("Merged ranges cannot intersect a native table.")}this.headings=I,this.merges=this.regions.references;const M=r.autoSize;if(this.sampleRows=M?M.sampleRows??Math.min(100,Math.floor(x/Math.max(1,s.length))):0,!Number.isInteger(this.sampleRows)||this.sampleRows<0||this.sampleRows>1048576)throw new RangeError("Width sampling must use from 0 through 1,048,576 rows within its buffer budgets.");const A=M?.minWidth??8,_=M?.maxWidth??60;if(!Number.isFinite(A)||!Number.isFinite(_)||A<0||A>_||_>255)throw new RangeError("Width bounds must satisfy 0 <= minWidth <= maxWidth <= 255.");if(this.widths=s.map(F=>F.width??(M?Math.max(A,Math.min(_,F.header.length+2)):void 0)),r.footer?.values&&r.footer.values.length>s.length)throw new RangeError("Footer has more values than declared columns.");this.aggregates=f(s,r.footer?.totals),r.print&&l(r.print,w)}finalRegions(s,r){return this.structuredFooter?new d([...this.merges,...this.structuredFooter.merges(this.headerRows+s)],this.columns.length,r):this.regions}sample(s){const r=this.options.autoSize?.minWidth??8,w=this.options.autoSize?.maxWidth??60;s.forEach((S,x)=>{if(!this.columns[x]||this.columns[x].width!==void 0)return;const p=S instanceof g?S.cachedValue:S instanceof T?S.text??S.value:S instanceof R?S.value:S,y=E(p)?Number.isFinite(p.getTime())?p.toISOString():"":p==null?"":String(p),I=Math.max(0,...y.slice(0,Math.ceil(w*4)).split(/\r?\n/).map(j=>[...j].length));this.widths[x]=Math.max(this.widths[x]??r,Math.min(w,I+2))})}accept(s,r){this.aggregates[s].accept(r)}footer(s){return this.columns.map((r,w)=>{const S=this.aggregates[w],x=S.operation;if(!x)return this.options.footer?.values?.[w];const p=S.value();return new o(p,a(x,C(w+1),this.headerRows,s),x)})}}function a(t,s,r,w){const S={sum:109,count:102,average:101,min:105,max:104}[t],x=["average","min","max"].includes(t),p=s+(r+1)+":"+s+(r+w),y="SUBTOTAL("+S+","+p+")";return w?x?"IF(SUBTOTAL(102,"+p+')=0,"",'+y+")":y:x?'""':"0"}function l(t,s){if(t.paper!==void 0&&!["A4","Letter"].includes(t.paper))throw new TypeError("Print paper must be A4 or Letter.");if(t.orientation!==void 0&&!["portrait","landscape"].includes(t.orientation))throw new TypeError("Invalid print orientation.");for(const r of[t.fitToWidth,t.fitToHeight])if(r!==void 0&&(!Number.isInteger(r)||r<0||r>32767))throw new RangeError("Print fit dimensions must be integers from 0 through 32,767.");for(const r of Object.values(t.margins??{}))if(!Number.isFinite(r)||r<0||r>10)throw new RangeError("Print margins must be from 0 through 10 inches.");for(const r of[t.header,t.footer])if(r!==void 0){if(typeof r!="string"||r.length>250)throw new TypeError("Print header/footer must be strings of at most 250 UTF-16 units.");if(v(r,s),("&C"+r.replace(/&/g,"&&")).length>255)throw new RangeError("Encoded print header/footer exceeds Excel's 255-character limit.")}}function e(t,s){if(!t)return"";const r={left:.25,right:.25,top:.5,bottom:.5,header:.2,footer:.2,...t.margins};return"<pageMargins"+Object.entries(r).map(([w,S])=>" "+w+'="'+S+'"').join("")+'/><pageSetup paperSize="'+(t.paper==="Letter"?1:9)+'" orientation="'+(t.orientation??"landscape")+'" fitToWidth="'+(t.fitToWidth??1)+'" fitToHeight="'+(t.fitToHeight??0)+'"/>'+(t.header!==void 0||t.footer!==void 0?"<headerFooter>"+(t.header===void 0?"":"<oddHeader>"+h("&C"+t.header.replace(/&/g,"&&"),s)+"</oddHeader>")+(t.footer===void 0?"":"<oddFooter>"+h("&C"+t.footer.replace(/&/g,"&&"),s)+"</oddFooter>")+"</headerFooter>":"")}return Object.freeze({ComputedTotal:o,ReportLayout:i,totalFormula:a,printXml:e})})(),Pe=(()=>{const{columnName:T}=ke;function E(g,h,d="Data"){if(typeof h=="string"){const u=g.flatMap((f,m)=>f.key===h?[m+1]:[]);if(u.length!==1)throw new TypeError(d+" column keys must identify exactly one declared column.");return u[0]}if(!Number.isInteger(h)||h<1||h>g.length)throw new RangeError(d+" column numbers must be one-based and within declared columns.");return h}function R(g,h,d,u){if(!Number.isSafeInteger(d)||d<1||!Number.isSafeInteger(u)||u<1||d+u-1>1048576)throw new RangeError("A data range must fit within Excel's worksheet rows.");const f=T(h);return"'"+g.replace(/'/g,"''")+"'!$"+f+"$"+d+":$"+f+"$"+(d+u-1)}function v(g,h,d){return R(g,h,d,1).split(":")[0]}return Object.freeze({resolveDataColumn:E,qualifiedColumnRange:R,qualifiedCell:v})})(),Ve=(()=>{const{OfficeIMOError:T}=ce,{columnName:E}=ke,R=new WeakMap;function v(u,f){R.set(u,f)}function C(u){return R.get(u)}function g(u,f,m){const o=R.get(u);if(o===void 0)return m;const i=f+m;let a=0;for(const l of o){if(l.firstRow>i)break;a+=Math.min(l.lastRow,i)-l.firstRow+1}return a}function h(u,f,m,o,i){if(i===void 0)return o?E(u)+(m+1)+":"+E(f)+(m+o):void 0;const a=E(u),l=E(f);let e="",n=m;for(const t of i){if(!Number.isSafeInteger(t.firstRow)||!Number.isSafeInteger(t.lastRow)||t.firstRow<=n||t.lastRow<t.firstRow||t.lastRow>m+o)throw new RangeError("Detail editing ranges must be ordered within serialized worksheet rows.");const s=a+t.firstRow+":"+l+t.lastRow;if(e.length+(e?1:0)+s.length>32767)throw new T("RESOURCE_LIMIT","Detail editing references exceed 32,767 UTF-16 characters; split the worksheet.");e+=(e?" ":"")+s,n=t.lastRow}return e||void 0}return Object.freeze({retainDataRowRanges:v,dataRowRanges:C,dataRowCount:g,dataRowReference:h})})(),pt=(()=>{const{cleanXml:T,escapeXml:E,escapeOoxmlAttribute:R}=pe,{cellPosition:v}=ze,{colorArgb:C}=Ue,{fields:g,optionalBoolean:h,differentialXml:d}=Xe,{resolveDataColumn:u}=Pe,{dataRowReference:f}=Ve;function m(r,w){if(typeof r=="string"){const p=r.split(":");if(p.length>2)throw new TypeError("Conditional ranges require one uppercase A1 cell or rectangle.");const y=v(p[0]),I=v(p[1]??p[0]);if(I.row<y.row||I.column<y.column||I.column>w.length)throw new RangeError("Conditional ranges require ordered cells within declared columns.");return{first:y.column,last:I.column,reference:r,bottom:I.row}}g(r,["column","through"],"conditional data range");const S=u(w,r.column,"Conditional"),x=r.through===void 0?S:u(w,r.through,"Conditional");if(x<S)throw new RangeError("Conditional data ranges require ordered columns.");return{first:S,last:x}}function o(r){if(typeof r!="number"||!Number.isFinite(r))throw new TypeError("Conditional values must be finite numbers.");return String(r)}function i(r,w){if(typeof r!="string")return o(r);if(w!=="equal"&&w!=="notEqual")throw new TypeError("Text conditional comparisons support only equal and notEqual.");if(r.length>8190)throw new RangeError("Conditional comparison formulas must fit 8,192 characters including quotes.");T(r,"reject");const S='"'+r.replace(/"/g,'""')+'"';if(S.length>8192)throw new RangeError("Conditional comparison formulas must fit 8,192 characters including quotes.");return S}function a(r){if(typeof r!="string")throw new TypeError("Conditional formulas must be strings.");const w=r.trim().replace(/^=/,"");if(!w.trim()||w.length>8192)throw new RangeError("Conditional formulas require 1 through 8,192 characters.");return T(w,"reject"),w}function l(r,w){if(g(r,r.type==="min"||r.type==="max"?["type"]:["type","value"],"conditional threshold"),r.type==="min"||r.type==="max"){if(r.type!==(w==="first"?"min":w==="last"?"max":""))throw new TypeError("Use min only at the start and max only at the end of a scale.");return'<cfvo type="'+r.type+'"/>'}if(r.type==="formula")return'<cfvo type="formula" val="'+R(a(r.value),"reject")+'"/>';if(!["number","percent","percentile"].includes(r.type))throw new TypeError("Unsupported conditional threshold type.");if(!("value"in r))throw new TypeError("A numeric threshold requires a value.");const S=o(r.value);if(r.type!=="number"&&(r.value<0||r.value>100))throw new RangeError("Conditional percent/percentile thresholds must be from 0 through 100.");return'<cfvo type="'+(r.type==="number"?"num":r.type)+'" val="'+S+'"/>'}function e(r){for(let w=1;w<r.length;w++){const S=r[w-1],x=r[w];if("value"in S&&"value"in x&&S.type===x.type&&typeof S.value=="number"&&typeof x.value=="number"&&S.value>x.value)throw new RangeError("Conditional thresholds of the same numeric type must be ordered.")}}function n(r,w,S){if(r===void 0)return[];if(!Array.isArray(r))throw new TypeError("conditionalFormats must be an array.");return r.map(x=>{const p=["type","range"],y=["style","stopIfTrue"];g(x,[...p,...x?.type==="cellIs"?[...y,"operator","value","values"]:x?.type==="expression"?[...y,"formula"]:x?.type==="colorScale"?["stops"]:x?.type==="dataBar"?["color","minimum","maximum","showValue"]:[]],"conditional rule");const I=m(x.range,w);let j="",M="",A;if(x.type==="cellIs"||x.type==="expression")if(h(x.stopIfTrue,"stopIfTrue"),d(x.style,S,()=>164),A={...x.style,...x.style.font?{font:{...x.style.font}}:{},...x.style.fill?{fill:{...x.style.fill}}:{},...x.style.border?{border:Object.fromEntries(Object.entries(x.style.border).filter(([,_])=>_!==void 0).map(([_,F])=>[_,{...F}]))}:{}},x.stopIfTrue!==void 0&&(j+=' stopIfTrue="'+(x.stopIfTrue?1:0)+'"'),x.type==="expression")M="<formula>"+E(a(x.formula),"reject")+"</formula>";else{const _=x.operator==="between"||x.operator==="notBetween";if(!["equal","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","between","notBetween"].includes(x.operator))throw new TypeError("Unsupported conditional comparison operator.");if(_){if("value"in x||!Array.isArray(x.values)||x.values.length!==2)throw new TypeError("between/notBetween require exactly two values.");if(M=x.values.map(F=>"<formula>"+o(F)+"</formula>").join(""),x.values[0]>x.values[1])throw new RangeError("Conditional comparison bounds must be ordered.")}else{if("values"in x||!("value"in x))throw new TypeError("A conditional comparison requires one value.");M="<formula>"+E(i(x.value,x.operator),"reject")+"</formula>"}j+=' operator="'+x.operator+'"'}else if(x.type==="colorScale"){if(!Array.isArray(x.stops)||x.stops.length!==2&&x.stops.length!==3)throw new TypeError("Color scales require two or three stops.");const _=[],F=[];M="<colorScale>"+x.stops.map((D,q)=>(g(D,["threshold","color"],"color stop"),_.push(C(D.color)),F.push(D.threshold),l(D.threshold,q===0?"first":q===x.stops.length-1?"last":"middle"))).join("")+_.map(D=>'<color rgb="'+D+'"/>').join("")+"</colorScale>",e(F)}else if(x.type==="dataBar"){h(x.showValue,"showValue");const _=x.minimum===void 0?{type:"min"}:x.minimum,F=x.maximum===void 0?{type:"max"}:x.maximum;M='<dataBar showValue="'+(x.showValue===!1?0:1)+'">'+l(_,"first")+l(F,"last")+'<color rgb="'+C(x.color)+'"/></dataBar>',e([_,F])}else throw new TypeError("Unsupported conditional rule type.");return{target:I,type:x.type,attributes:j,body:M,...A?{style:A}:{}}})}class t{rules;constructor(w,S){const x=S.addDifferentials(w.flatMap(y=>y.style?[y.style]:[]));let p=0;this.rules=w.map((y,I)=>({target:y.target,xml:'<cfRule type="'+y.type+'" priority="'+(I+1)+'"'+(y.style?' dxfId="'+x[p++]+'"':"")+y.attributes+">"+y.body+"</cfRule>"}))}get count(){return this.rules.length}*xml(w,S,x,p){for(const y of this.rules){if(y.target.bottom!==void 0&&y.target.bottom>x)throw new RangeError("Conditional ranges must stay within exported rows.");const I=y.target.reference??f(y.target.first,y.target.last,w,S,p);I&&(yield'<conditionalFormatting sqref="'+I+'">'+y.xml+"</conditionalFormatting>")}}}return Object.freeze({prepareConditionalFormats:n,ConditionalFormats:t})})(),wt=(()=>{const{OfficeIMOError:T}=ce,{checkAbort:E}=ge,{cleanXml:R,escapeOoxmlAttribute:v,escapeXml:C}=pe,{fields:g,optionalBoolean:h}=Xe,{resolveDataColumn:d}=Pe,{dataRowReference:u}=Ve;function f(a,l,e){if(a!==void 0){if(typeof a!="string")throw new TypeError(e+" must be text.");if(a.length>l)throw new RangeError(e+" exceeds "+l+" UTF-16 units.");return R(a,"reject")}}function m(a,l,e=1e3,n=1e6,t){if(E(t),a===void 0)return Object.freeze({rules:Object.freeze([]),count:0,textCharacters:0});if(!Array.isArray(a))throw new TypeError("dataValidation must be an array.");const s=a.length;if(s>e)throw new T("RESOURCE_LIMIT","maxDataValidations exceeded.");const r=[],w=new Set;let S=0;const x=p=>{if(S+p>n)throw new T("RESOURCE_LIMIT","maxValidationTextCharacters exceeded.");S+=p};for(let p=0;p<s;p++){E(t);const y=a[p];g(y,["type","column","items","allowBlank","showErrorMessage","errorStyle","errorTitle","errorMessage"],"data validation");const{type:I,column:j,items:M,allowBlank:A,showErrorMessage:_,errorStyle:F,errorTitle:D,errorMessage:q}=y;if(I!=="list")throw new TypeError("Only inline-list data validation is supported.");const H=d(l,j,"Validation");if(w.has(H))throw new TypeError("A data column cannot have multiple validation rules.");if(w.add(H),h(A,"allowBlank"),h(_,"showErrorMessage"),F!==void 0&&!["stop","warning","information"].includes(F))throw new TypeError("Unsupported validation error style.");if(!Array.isArray(M))throw new TypeError("Inline validation lists require a nonempty string array.");const te=M.length;if(!te)throw new TypeError("Inline validation lists require a nonempty string array.");if(te>254)throw new RangeError("Inline validation lists must fit 255 UTF-16 units including quotes and separators.");let ee='"';for(let le=0;le<te;le++){E(t);const Y=M[le];if(typeof Y!="string")throw new TypeError("Inline validation choices must be strings.");if(Y.length>253||Y.includes(","))throw new RangeError("Inline validation choices cannot contain commas and must fit the 255-character list source.");R(Y,"reject");const U=Y.replace(/"/g,'""');if(ee.length+(le?1:0)+U.length+1>255)throw new RangeError("Inline validation lists must fit 255 UTF-16 units including quotes and separators.");ee+=(le?",":"")+U}ee+='"';const he=f(D,32,"Validation error title"),se=f(q,255,"Validation error message");x(ee.length+(he?.length??0)+(se?.length??0));const de=' type="list" allowBlank="'+(A===!1?0:1)+'" showErrorMessage="'+(_===!1?0:1)+'" errorStyle="'+(F??"stop")+'"'+(he===void 0?"":' errorTitle="'+v(he,"reject")+'"')+(se===void 0?"":' error="'+v(se,"reject")+'"');r.push(Object.freeze({column:H,attributes:de,formula:ee}))}return E(t),Object.freeze({rules:Object.freeze(r),count:s,textCharacters:S})}function*o(a,l,e,n){if(!(!a.count||!e||n?.length===0)){yield'<dataValidations count="'+a.count+'">';for(const t of a.rules){const s=u(t.column,t.column,l,e,n);yield"<dataValidation"+t.attributes+' sqref="'+s+'"><formula1>'+C(t.formula,"reject")+"</formula1></dataValidation>"}yield"</dataValidations>"}}return Object.freeze({prepareDataValidations:m,dataValidationsXml:o})})(),lt=(()=>{const{checkAbort:T,consumeRows:E,inputRows:R,pause:v,taskYieldDue:C}=ge,{ChunkedTextSink:g,BlobByteSink:h}=Te,{OfficeIMOError:d}=ce,{notifyProgress:u}=Qe,{copyColumns:f,createRowProjector:m}=Be,{EntryWriter:o}=qe,{xmlDeclaration:i}=pe,{officeRelationshipsNamespace:a}=Me,{Cell:l,cellText:e,columnName:n,inlineText:t,excelDate:s,copyValue:r}=ke,{spreadsheetNamespace:w,colorArgb:S,validateStylePatch:x,copyStylePatch:p}=Fe,{copyHyperlink:y,copyImage:I,hyperlinksXml:j,cellPosition:M}=ze,{ExportCell:A,assertScalar:_}=xe,{ReportLayout:F,ComputedTotal:D,printXml:q}=at,{cleanXml:H}=pe,{ConditionalFormats:te,prepareConditionalFormats:ee}=pt,{isDate:he}=Se,{FormulaCell:se,formulaXml:de,isSubtotalFormula:le}=_e,{prepareDataValidations:Y,dataValidationsXml:U}=wt,{qualifiedCell:re,qualifiedColumnRange:K,resolveDataColumn:fe}=Pe,{dataRowRanges:k,dataRowCount:z}=Ve,{captureColumnOutlines:L,columnOutlineMap:X,validateOutlinePositions:Z}=nt,Q=65530;function oe(ye){if(ye>Q)throw new RangeError("Excel supports at most 65,530 hyperlinks per worksheet; split the sheet.")}class P{book;table;preserved;chartData;validations;columns;project;name;declared;options;entry;completion;prepared;buffer;output=new h;started=!1;busy=!1;failed=!1;error;count=0;headerRows;layout;completedRegions;titleStyle;pending=[];pendingCharacters=0;reservedLayout=!1;internalLinks=[];links=[];linkedCells=new Set;pictures=[];nativeCharts=[];conditional;completed=!1;chartSources=[];constructor(c,b,O,N,B=!1,J=[],V=!1,ne={rules:[],count:0,textCharacters:0}){this.book=c,this.table=N,this.preserved=B,this.chartData=V,this.validations=ne,this.columns=f(O.columns??[],!0).map(ae=>Object.freeze(ae));const me=O.alternatingRowStyle;this.options={...O,...O.autoSize?{autoSize:{...O.autoSize}}:{},...O.mergedCells?{mergedCells:[...O.mergedCells]}:{},...O.title?{title:{...O.title,...O.title.style?{style:p(O.title.style)}:{}}}:{},...O.print?{print:{...O.print,...O.print.margins?{margins:{...O.print.margins}}:{}}}:{},...O.footer?{footer:{...O.footer,...O.footer.values?{values:O.footer.values.map(r)}:{},...O.footer.totals?{totals:{...O.footer.totals}}:{},...O.footer.style?{style:p(O.footer.style)}:{}}}:{},...me?{alternatingRowStyle:p(me)}:{}},this.layout=new F(this.columns,this.options,c.settings.invalidCharacterPolicy,c.settings.limits?.maxMergedRanges??1e4,c.settings.limits?.maxBufferedCells??1e5),this.titleStyle=O.title?c.styles.compose(c.styles.compose(0,{font:{bold:!0,size:18}}),this.options.title.style??{}):0,this.headerRows=this.layout.headerRows;for(const ae of O.hyperlinks??[]){const W=y(ae,c.settings.invalidCharacterPolicy);this.links.push(W),this.linkedCells.add(W.cell)}c.checkLinks(this.links.length),this.declared=this.columns.map((ae,W)=>({column:ae,letter:n(W+1),style:c.styles.forColumn(ae),dateStyle:c.styles.forColumn(ae,!1,void 0,!0),headerStyle:this.headerRows?O.headerStyle??c.styles.forColumn({header:ae.header,...ae.wrapText===void 0?{}:{wrapText:ae.wrapText},...ae.alignment===void 0?{}:{alignment:ae.alignment}},O.boldHeader!==!1,O.headerFill):0})),this.conditional=new te(J,c.styles),c.retainLink(this.links.length),this.name=typeof b=="function"?b():b,this.project=m(this.columns,{sheetName:this.name,firstDataRow:this.headerRows+1},c.settings.signal,c.valueValidator)}static create(c,b,O,N,B=!1,J,V){return new P(c,b,O,N,B,J,!1,V)}static createChartData(c,b){return new P(c,b.dataSheetName,{columns:[{header:"Category"},...b.data.series.map(O=>({header:O.name,type:"number"}))]},void 0,!1,[],!0)}static validate(c,b){const O=f(b.columns??[],!0),N=Y(b.dataValidation,O,c.availableDataValidations,c.availableValidationTextCharacters,c.settings.signal);c.checkConditionalFormats(b.conditionalFormats?.length??0);const B=ee(b.conditionalFormats,O,c.settings.invalidCharacterPolicy);c.styles.checkDifferentials(B.flatMap(V=>V.style?[V.style]:[]));const J=new F(O,b,c.settings.invalidCharacterPolicy,c.settings.limits?.maxMergedRanges??1e4,c.settings.limits?.maxBufferedCells??1e5);if(c.checkMerges(J.mergeCount),b.title?.style&&x(b.title.style),b.title&&c.styles.compose(c.styles.compose(0,{font:{bold:!0,size:18}}),b.title.style??{}),b.footer?.style&&c.styles.compose(0,b.footer.style),b.hyperlinks!==void 0){if(!Array.isArray(b.hyperlinks))throw new TypeError("Hyperlinks must be an array.");oe(b.hyperlinks.length);const V=new Set;for(const ne of b.hyperlinks){const me=y(ne,c.settings.invalidCharacterPolicy),ae=M(me.cell);if(J.regions.covered(ae.column,ae.row))throw new TypeError("Hyperlinks cannot address a covered merged cell.");if(V.has(me.cell))throw new TypeError("Duplicate hyperlink cell: "+me.cell);V.add(me.cell)}}if(O.length>16384)throw new RangeError("Excel supports at most 16,384 columns.");if(b.includeHeader===!1&&(b.freezeHeader||b.autoFilter))throw new TypeError("A frozen header or autofilter requires a header row.");b.headerFill!==void 0&&S(b.headerFill),b.headerStyle!==void 0&&c.styles.validateStyle(b.headerStyle),b.alternatingRowStyle!==void 0&&c.styles.compose(0,b.alternatingRowStyle);for(const V of[b.rowStyle,b.cellStyle,b.rowOutline])if(V!==void 0&&typeof V!="function")throw new TypeError("Row and style callbacks must be functions.");if(b.maxOutlineLevel!==void 0&&(!Number.isInteger(b.maxOutlineLevel)||b.maxOutlineLevel<0||b.maxOutlineLevel>7))throw new RangeError("Maximum outline level must be an integer from zero through seven.");if(Z(b),L(b.columnOutlines,O.length),b.rowOutline&&b.maxOutlineLevel===void 0)throw new TypeError("A row outline callback requires maxOutlineLevel before streamed rows are written.");if(!b.rowOutline&&b.maxOutlineLevel!==void 0)throw new TypeError("maxOutlineLevel requires a row outline callback.");for(const V of[b.rowHeight,b.headerHeight])if(V!==void 0&&(!Number.isFinite(V)||V<=0||V>409))throw new RangeError("Row height must be positive and at most 409 points.");if(b.freezeColumns!==void 0&&(!Number.isInteger(b.freezeColumns)||b.freezeColumns<0||b.freezeColumns>O.length||b.freezeColumns>=16384))throw new RangeError("Frozen columns must be within the declared columns and leave a valid scrollable column.");if(b.table&&b.includeHeader===!1)throw new TypeError("Excel tables require a header row.");if(b.defaultColumnWidth!==void 0&&(!Number.isFinite(b.defaultColumnWidth)||b.defaultColumnWidth<0||b.defaultColumnWidth>255))throw new RangeError("Default column width must be from 0 through 255 characters.");for(const V of O){if(V.width!==void 0&&(!Number.isFinite(V.width)||V.width<0||V.width>255))throw new RangeError("Column width must be from 0 through 255 characters.");if(V.type!==void 0&&!["string","number","boolean","date"].includes(V.type)&&!c.writerFor(V.type))throw new TypeError("Invalid column type: "+V.type);if(V.alignment!==void 0&&!["left","center","right","fill","justify","distributed"].includes(V.alignment))throw new TypeError("Invalid horizontal alignment.");if(e(V.header,c.settings.invalidCharacterPolicy),V.style!==void 0&&c.styles.validateStyle(V.style),V.format!==void 0&&(typeof V.format!="string"||V.format.length>255))throw new TypeError("Column format must be a string of at most 255 characters.")}return{conditional:B,validations:N}}cell(c,b,O,N=!1,B,J,V,ne=!1,me=!1,ae=!0){const W=this.declared[b],G=c instanceof D?c:void 0;G&&(c=G.value);let $=c instanceof se?c:void 0;$&&(c=$.cachedValue);let ie=c instanceof A?c.presentation:void 0,Re=c instanceof A?c.link:void 0;c instanceof A&&(c=c.value);const Oe=$?.style??(c instanceof l?c.style:void 0),Ae=(this.completedRegions??this.layout.regions).covered(b+1,O),Ye=c instanceof l?c.value:c,dt=Ae&&(Ye==null||Ye==="");if(!N&&!ne&&W.column.type&&!dt){const Ce=this.book.writerFor(W.column.type);if(Ce){if($)throw new TypeError("An explicit FormulaCell cannot also pass through a custom cell value writer; return it from the writer instead.");c=Ce(c instanceof l?c.value:c,{column:W.column,rowIndex:O-this.headerRows-1,worksheetRow:O,columnIndex:b,sheetName:this.name})}}c instanceof se&&($=c,c=$.cachedValue),c instanceof A&&(ie=c.presentation,Re=c.link,c=c.value);const Ie=$?.style??(c instanceof l?c.style??Oe:Oe);if(c instanceof l&&(c=c.value),_(c),Ae){if(Re)throw new TypeError("Hyperlinks cannot address a covered merged cell.");if($||G||c!=null&&c!=="")throw new TypeError("A merged range would hide the value at "+W.letter+O+"; covered cells must be empty.");c=void 0}const Ee=he(c)?"date":typeof c;if(!N&&!ne&&c!=null&&W.column.type&&!this.book.writerFor(W.column.type)&&W.column.type!==Ee)throw new TypeError("Cell "+W.letter+O+" does not match column type "+W.column.type+".");let we=Ie===void 0?N?W.headerStyle:G?.operation==="count"?0:Ee==="date"?W.dateStyle:W.style:this.book.styles.validateStyle(Ie);if(N&&Ee==="date"&&Ie===void 0&&this.options.headerStyle===void 0&&(we=this.book.styles.dateHeader(we,W.dateStyle)),me&&(we=this.titleStyle),!N&&!ne){if(Ie===void 0){const je=we,Ke=V?.get(je);Ke!==void 0?we=Ke:((O-this.headerRows)%2===0&&this.options.alternatingRowStyle&&(we=this.book.styles.compose(we,this.options.alternatingRowStyle)),B!==void 0&&(we=this.book.styles.compose(we,B)),V?.set(je,we))}const Ce=J&&this.options.cellStyle?.({...J,value:c,column:W.column,columnIndex:b});Ce!==void 0&&(we=this.book.styles.compose(we,Ce))}ne&&this.options.footer?.style&&Ie===void 0&&(we=this.book.styles.compose(we,this.options.footer.style)),ie&&Ie===void 0&&(we=this.book.styles.compose(we,{...ie.background===void 0?{}:{fill:{color:ie.background}},...ie.color===void 0&&ie.bold===void 0&&ie.italic===void 0?{}:{font:{...ie.color===void 0?{}:{color:ie.color},...ie.bold===void 0?{}:{bold:ie.bold},...ie.italic===void 0?{}:{italic:ie.italic}}},...ie.wrapText===void 0?{}:{wrapText:ie.wrapText},...ie.alignment===void 0?{}:{alignment:ie.alignment},...ie.numberFormat===void 0?{}:{numberFormat:ie.numberFormat}}));const Je=typeof c=="string"?c.length:0;let De=this.preserved||N||ne?Je:void 0;if(Ee==="string"&&Je>32767&&H(c,this.book.settings.invalidCharacterPolicy).length>32767){const Ce=W.letter+O;if(Re||this.linkedCells.has(Ce))throw new TypeError("A text-preservation cell cannot also have an external hyperlink.");oe(this.links.length+this.internalLinks.length+1),this.book.checkLinks(1),De!==void 0&&(this.book.budget.release(1,De),De=void 0);const je=this.book.preserveText(this.name,Ce,c);this.book.retainLink(),this.internalLinks.push({cell:Ce,location:je.location}),this.linkedCells.add(Ce),c=je.preview}if(Re&&this.appendHyperlink({cell:W.letter+O,...Re}),Ee==="date"&&(c=s(c,this.book.settings.dateMode)),!N&&!ne&&ae&&(!$||!le($))&&this.layout.accept(b,c),!N&&!ne&&this.chartSources.length)for(const Ce of this.chartSources)Ce.observe(O-this.headerRows-1,b+1,c);const ve='<c r="'+W.letter+O+'" s="'+we+'"';if($&&this.book.retainFormula($.formula.length),this.book.budget.cell($?$.formula:c,De),$)return ve+(c===null?' t="str"':"")+">"+de($)+"</c>";if(G)return ve+(c===null?' t="str"':"")+"><f>"+G.formula.replace(/"/g,"&quot;")+"</f><v>"+(c??"")+"</v></c>";if(c==null||Ee==="number"&&!Number.isFinite(c)||c==null)return ve+"/>";if(Ee==="string")return ve+' t="inlineStr"><is>'+t(c,this.book.settings.invalidCharacterPolicy)+"</is></c>";if(Ee==="boolean")return ve+' t="b"><v>'+(c?1:0)+"</v></c>";if(Ee!=="number"&&Ee!=="date")throw new TypeError("Excel cells must be strings, numbers, booleans, Dates or null.");return ve+"><v>"+c+"</v></c>"}*rowXml(c,b,O,N=!1,B=!1){const J=B?this.options.title?.height??28:O?this.options.headerHeight:this.options.rowHeight,V=!O&&!N&&(this.options.rowStyle||this.options.cellStyle||this.options.rowOutline)?Object.freeze({rowIndex:b-this.headerRows-1,worksheetRow:b,sheetName:this.name,values:Object.freeze(this.columns.map((W,G)=>c[G]instanceof se?c[G].cachedValue:c[G]instanceof l||c[G]instanceof A?c[G].value:c[G]))}):void 0,ne=V&&this.options.rowStyle?.(V);ne!==void 0&&x(ne);const me=this.outline(V),ae=!O&&(ne||this.options.alternatingRowStyle)?new Map:void 0;yield'<row r="'+b+'"'+(J===void 0?"":' ht="'+J+'" customHeight="1"')+(me?.level?' outlineLevel="'+me.level+'"':"")+(me?.hidden?' hidden="1"':"")+(me?.collapsed?' collapsed="1"':"")+">";for(let W=0;W<this.columns.length;W++)yield this.cell(c[W],W,b,O,ne,V,ae,N,B,me?.hidden!==!0);yield"</row>"}outline(c){if(!c||!this.options.rowOutline)return;const b=this.options.rowOutline(c);if(b===void 0)return;if(b===null||typeof b!="object"||Array.isArray(b))throw new TypeError("Row outline callbacks must return metadata or undefined.");if(typeof b.then=="function")throw Promise.resolve(b).catch(()=>{}),new TypeError("Row outline callbacks must return synchronous metadata.");const{level:O,hidden:N,collapsed:B}=b,J=O??0;if(!Number.isInteger(J)||J<0||J>this.options.maxOutlineLevel)throw new RangeError("Row outline level exceeds the declared maximum.");for(const V of[N,B])if(V!==void 0&&typeof V!="boolean")throw new TypeError("Row outline flags must be booleans.");return Object.freeze({level:J,...N===void 0?{}:{hidden:N},...B===void 0?{}:{collapsed:B}})}writeRow(c,b,O,N=!1,B=!1){const J=this.rowXml(c,b,O,N,B),V=()=>{for(;;){const ne=J.next();if(ne.done)return;if(this.buffer.append(ne.value))return this.buffer.flush().then(V)}};return V()}async sampleRow(c){if((this.pending.length+1)*this.columns.length>(this.book.settings.limits?.maxBufferedCells??1e5))throw new d("RESOURCE_LIMIT","Width sampling cell limit exceeded; reduce sampleRows or raise its bounded limit.");const b=[];let O=0;for(const N of this.rowXml(c,this.count+this.headerRows+1,!1)){if(!this.started&&this.pendingCharacters+N.length>(this.book.settings.limits?.maxBufferedCharacters??1e6)){if(this.options.autoSize?.sampleRows!==void 0)throw new d("RESOURCE_LIMIT","Width sampling text limit exceeded; reduce sampleRows or raise its bounded limit.");this.layout.sample(c),await this.start();for(const B of b)this.buffer.append(B)&&await this.buffer.flush();b.length=0}this.started?this.buffer.append(N)&&await this.buffer.flush():(this.pendingCharacters+=N.length,b.push(N)),!this.started&&(++O&127)===0&&C()&&(await v(),T(this.book.settings.signal))}this.started||(this.layout.sample(c),this.pending.push(b))}reserveLayout(){if(!this.reservedLayout){if(!this.preserved){let c=0;if(this.options.title&&(c+=this.options.title.text.length),this.layout.firstHeaderRow)for(const b of this.layout.headings)for(const O of b){const N=O instanceof A||O instanceof l?O.value:O;typeof N=="string"&&(c+=N.length)}if(this.layout.structuredFooter)for(const b of this.layout.structuredFooter.values)for(const O of b){const N=O instanceof A?O.value:O;typeof N=="string"&&(c+=N.length)}else if(this.options.footer)for(let b=0;b<this.columns.length;b++){const O=this.columns[b],N=this.options.footer.totals;if(N&&Object.prototype.hasOwnProperty.call(N,O.key??O.header))continue;const B=this.options.footer.values?.[b],J=B instanceof A||B instanceof l?B.value:B;typeof J=="string"&&(c+=J.length)}this.book.budget.reserve(this.columns.length*(this.headerRows+this.layout.footerRows),c)}this.reservedLayout=!0}}async start(){if(this.started)return;this.reserveLayout(),this.started=!0,this.entry=this.book.settings.sink?await this.book.openSheet(this):new o(this.book.settings.compression,{write:W=>{this.book.retainBufferedBytes(W.length),this.output.write(W)}},this.book.settings.signal);const c=this.buffer=new g(this.entry,this.book.settings.signal),b=this.options,O=b.freezeColumns??0,N=b.freezeHeader?this.headerRows:0,B=O&&N?"bottomRight":O?"topRight":"bottomLeft",J=n(O+1)+(N+1),V=X(b.columnOutlines),ne=!!b.rowOutline||V.size>0,me=Math.max(0,...Array.from(V.values(),W=>W.level??0));await c.write(i+'<worksheet xmlns="'+w+'" xmlns:r="'+a+'">'+(b.print||ne?"<sheetPr>"+(ne?'<outlinePr summaryBelow="'+(b.outlineSummaryBelow===!1?"0":"1")+'"'+(b.outlineSummaryRight===void 0?"":' summaryRight="'+(b.outlineSummaryRight?"1":"0")+'"')+' showOutlineSymbols="1"/>':"")+(b.print?'<pageSetUpPr fitToPage="1"/>':"")+"</sheetPr>":"")+'<sheetViews><sheetView workbookViewId="0">'+(O||N?"<pane"+(O?' xSplit="'+O+'"':"")+(N?' ySplit="'+N+'"':"")+' topLeftCell="'+J+'" activePane="'+B+'" state="frozen"/><selection pane="'+B+'" activeCell="'+J+'" sqref="'+J+'"/>':"")+"</sheetView></sheetViews>"+(ne?'<sheetFormatPr defaultRowHeight="15"'+(b.rowOutline?' outlineLevelRow="'+b.maxOutlineLevel+'"':"")+(V.size?' outlineLevelCol="'+me+'"':"")+"/>":""));const ae=b.defaultColumnWidth??(this.table?20:void 0);if(this.columns.some((W,G)=>this.layout.widths[G]!==void 0||ae!==void 0||V.has(G))){await c.write("<cols>");for(let W=0;W<this.columns.length;W++){const G=this.layout.widths[W]??ae,$=V.get(W);(G!==void 0||$)&&await c.write('<col min="'+(W+1)+'" max="'+(W+1)+'"'+(G===void 0?"":' width="'+G+'" customWidth="1"')+($?.level?' outlineLevel="'+$.level+'"':"")+($?.hidden?' hidden="1"':"")+($?.collapsed?' collapsed="1"':"")+"/>")}await c.write("</cols>")}if(await c.write("<sheetData>"),b.title&&await this.writeRow(this.columns.map((W,G)=>G?"":b.title.text),1,!0,!1,!0),this.layout.firstHeaderRow)for(let W=0;W<this.layout.headings.length;W++)await this.writeRow(this.layout.headings[W],W+this.layout.firstHeaderRow,!0);for(const W of this.pending)for(const G of W)c.append(G)&&await c.flush();this.pending=[],this.pendingCharacters=0}async addRows(c){if(this.book.assertOpen(),this.completion)throw new d("INVALID_STATE","Worksheet is closed.");if(this.busy)throw new d("INVALID_STATE","Await the current addRows call before writing more rows to this sheet.");if(this.failed)throw this.error;this.busy=!0;try{this.reserveLayout(),this.layout.sampleRows||await this.start();let b=performance.now();const O=()=>{performance.now()-b>=50&&(this.progress(),b=performance.now())},N=()=>{if(this.count++,!this.started&&this.pending.length>=this.layout.sampleRows)return this.start().then(O);if(!this.started&&C())return v().then(()=>{T(this.book.settings.signal),O()});O()};await E(c,this.book.settings.signal,B=>{if(this.count+this.headerRows+this.layout.footerRows>=1048576)throw new RangeError("Excel supports at most 1,048,576 rows including headers and footers; split the sheet.");if(this.book.budget.row(this.count+1),!this.columns.length)throw new RangeError("Declare columns before adding rows.");const J=this.project(B,this.count),V=this.started?this.writeRow(J,this.count+this.headerRows+1,!1):this.sampleRow(J);return V?V.then(N):N()}),this.buffer&&await this.buffer.flush(),this.progress(),T(this.book.settings.signal)}catch(b){throw this.failed=!0,this.error=b,await this.book.discard(b),b}finally{this.busy=!1}}progress(){!this.preserved&&!this.chartData&&u(this.book.settings.onProgress,{phase:"rows",rows:this.book.rowCount,sheetRows:this.reportRowCount,sheetName:this.name})}get rowCount(){return this.count}dataRange(c){if(this.failed)throw this.error;if(!this.completed)throw new d("INVALID_STATE","Close the worksheet before resolving its data range.");const b=fe(this.columns,c),O=k(this);if(O!==void 0){if(O.length>1)throw new d("INVALID_STATE","Grouped details are discontiguous; use the grouped result's detailRanges for explicit formula references.");const N=O[0];return N?K(this.name,b,N.firstRow,N.lastRow-N.firstRow+1):void 0}return this.count?K(this.name,b,this.headerRows+1,this.count):void 0}get chartBindingMetadata(){const c=this.layout.headings.at(-1);return{name:this.name,columns:this.columns,headerRows:this.headerRows,rows:this.count,closed:this.completed||!!this.completion,headerReferences:this.columns.map((b,O)=>{const N=c?.[O],B=N instanceof A?N.value:N;return this.layout.firstHeaderRow&&B===b.header&&!this.layout.regions.covered(O+1,this.headerRows)?re(this.name,O+1,this.headerRows):void 0})}}retainChartBinding(c){this.chartSources.push(c)}get reportRowCount(){return this.preserved||this.chartData?0:z(this,this.headerRows,this.count)}get hidden(){return this.chartData}addChart(c){if(this.book.assertOpen(),this.completion)throw new d("INVALID_STATE","Worksheet is closed.");if(this.failed)throw this.error;this.nativeCharts.push(this.book.registerChart(c))}get charts(){return this.nativeCharts}releaseCharts(){this.nativeCharts.length=0}addImage(c){if(this.book.assertOpen(),this.completion)throw new d("INVALID_STATE","Worksheet is closed.");if(this.failed)throw this.error;const b=I(c,this.book.settings.invalidCharacterPolicy,O=>this.book.checkImage(O));this.book.retainImage(b.data.length),this.pictures.push(b)}addHyperlink(c){if(this.book.assertOpen(),this.completion)throw new d("INVALID_STATE","Worksheet is closed.");if(this.failed)throw this.error;this.appendHyperlink(c)}appendHyperlink(c){const b=y(c,this.book.settings.invalidCharacterPolicy),O=M(b.cell);if(this.layout.regions.covered(O.column,O.row))throw new TypeError("Hyperlinks cannot address a covered merged cell.");if(this.linkedCells.has(b.cell))throw new TypeError("Duplicate hyperlink cell: "+b.cell);oe(this.links.length+this.internalLinks.length+1),this.book.retainLink(),this.links.push(b),this.linkedCells.add(b.cell)}get hyperlinks(){return this.links}get images(){return this.pictures}get tableDefinition(){return this.count?this.table:void 0}get isBusy(){return this.busy}get headerRowCount(){return this.headerRows}get firstHeaderRow(){return this.layout.firstHeaderRow}get mergeCount(){return this.layout.mergeCount}get conditionalFormatCount(){return this.conditional.count}get dataValidations(){return this.validations}get totalRows(){return Math.max(1,this.headerRows+this.count+this.layout.footerRows)}get lastColumn(){return n(Math.max(1,this.columns.length))}get printSettings(){return this.options.print}get footerSettings(){return this.layout.structuredFooter?void 0:this.options.footer}async close(){if(this.book.assertOpen(),this.busy)throw new d("INVALID_STATE","Await addRows before closing the worksheet.");try{await this.finish()}catch(c){throw await this.book.discard(c),c}}finish(c){if(this.completion)return this.completion;if(this.failed)throw this.error;return this.completion=(async()=>{try{const b=this.completedRegions=this.layout.finalRegions(this.count,this.book.settings.limits?.maxMergedRanges??1e4);b.validateRows(this.totalRows);for(const B of this.chartSources)B.finish();this.chartSources.length=0;for(const B of this.links){const J=M(B.cell);if(J.column>this.columns.length||J.row>this.totalRows)throw new RangeError("Hyperlinks must address cells within the exported rows and columns.");if(b.covered(J.column,J.row))throw new TypeError("Hyperlinks cannot address a covered merged cell.")}if(await this.start(),c)for await(const B of R(c,this.book.settings.signal))this.book.budget.row(this.count+1),await this.writeRow(this.project(B,this.count),this.headerRows+this.count+1,!1),this.count++;if(this.layout.structuredFooter)for(let B=0;B<this.layout.footerRows;B++)await this.writeRow(this.layout.structuredFooter.values[B],this.headerRows+this.count+B+1,!1,!0);else this.options.footer&&await this.writeRow(this.layout.footer(this.count),this.headerRows+this.count+1,!1,!0);await this.buffer.write("</sheetData>"),this.options.autoFilter&&this.headerRows&&!this.tableDefinition&&await this.buffer.write('<autoFilter ref="A'+this.headerRows+":"+n(this.columns.length)+(this.count+this.headerRows)+'"/>'),b.references.length&&await this.buffer.write('<mergeCells count="'+b.references.length+'">'+b.references.map(B=>'<mergeCell ref="'+B+'"/>').join("")+"</mergeCells>");const O=k(this);for(const B of this.conditional.xml(this.headerRows,this.count,this.totalRows,O))await this.buffer.write(B);for(const B of U(this.validations,this.headerRows,this.count,O))await this.buffer.write(B);(this.links.length||this.internalLinks.length)&&await this.buffer.write(j(this.links,this.book.settings.invalidCharacterPolicy,this.internalLinks)),await this.buffer.write(q(this.options.print,this.book.settings.invalidCharacterPolicy)),(this.pictures.length||this.nativeCharts.length)&&await this.buffer.write('<drawing r:id="drawing"/>'),this.tableDefinition&&await this.buffer.write('<tableParts count="1"><tablePart r:id="table"/></tableParts>'),await this.buffer.write("</worksheet>"),await this.buffer.close();const N=await this.entry.close();!this.book.settings.sink&&!this.failed&&(this.prepared={...N,chunks:this.output.takeChunks()}),this.completed=!0}catch(b){throw await this.discard(b),b}})()}takePrepared(){const c=this.prepared;return this.prepared=void 0,c}async discard(c){this.failed=!0,this.error=c,this.pending=[],this.pendingCharacters=0,this.prepared=void 0,this.buffer=void 0,this.nativeCharts.length=0,this.chartSources.length=0,this.output.discard(),await this.entry?.discard(c)}}return Object.freeze({Worksheet:P})})(),gt=(()=>{const{escapeOoxmlAttribute:T,escapeXml:E,xmlDeclaration:R}=pe,{cellText:v,columnName:C}=ke,{spreadsheetNamespace:g}=Fe,{ExportCell:h}=xe,{Cell:d}=ke,{totalFormula:u}=at;function f(i,a,l,e){const n=a.name??"Table"+i;if(typeof n!="string"||n.length>255||!/^[A-Za-z_][A-Za-z0-9_.]*$/.test(n)||/^(?:[A-Za-z]{1,3}[1-9][0-9]*|R[1-9][0-9]*C[1-9][0-9]*|R|C)$/i.test(n))throw new TypeError("Table names must be ASCII identifiers, at most 255 characters, and cannot be cell references.");const t=a.style??"TableStyleMedium2",s=/^TableStyle(Light|Medium|Dark)([1-9][0-9]?)$/.exec(t);if(!s||Number(s[2])>({Light:21,Medium:28,Dark:11}[s[1]]??0))throw new TypeError("Unknown built-in Excel table style.");const r=l.map(w=>v(w.header,e));if(!r.length||r.some(w=>!w.trim()||w.length>255)||new Set(r.map(w=>w.toLowerCase())).size!==r.length)throw new TypeError("Excel tables require nonblank, unique headers of at most 255 characters.");return Object.freeze({id:i,name:n,headers:Object.freeze(r),keys:Object.freeze(l.map(w=>w.key??w.header)),options:Object.freeze({...a,style:t})})}function m(i,a,l,e=1,n){const t="A"+e+":"+C(i.headers.length)+(a+e),s="A"+e+":"+C(i.headers.length)+(a+e+(n?1:0)),r=i.options,w=T(i.name,l);return R+'<table xmlns="'+g+'" id="'+i.id+'" name="'+w+'" displayName="'+w+'" ref="'+s+'"'+(n?' totalsRowCount="1"':' totalsRowShown="0"')+'><autoFilter ref="'+t+'"/><tableColumns count="'+i.headers.length+'">'+i.headers.map((S,x)=>{const p=i.keys[x],y=n?.totals&&Object.prototype.hasOwnProperty.call(n.totals,p)?n.totals[p]:void 0,I=n?.values?.[x],j=I instanceof d||I instanceof h?I.value:I,M=y&&["average","min","max"].includes(y),A=y?' totalsRowFunction="'+(M?"custom":y==="count"?"countNums":y)+'"':typeof j=="string"?' totalsRowLabel="'+T(j,l)+'"':"";return'<tableColumn id="'+(x+1)+'" name="'+T(S,l)+'"'+A+(M?"><totalsRowFormula>"+E(u(y,C(x+1),e,a),l)+"</totalsRowFormula></tableColumn>":"/>")}).join("")+'</tableColumns><tableStyleInfo name="'+r.style+'" showFirstColumn="'+(r.firstColumn?1:0)+'" showLastColumn="'+(r.lastColumn?1:0)+'" showRowStripes="'+(r.bandedRows!==!1?1:0)+'" showColumnStripes="'+(r.bandedColumns?1:0)+'"/></table>'}return Object.freeze({defineTable:f,tableXml:m})})(),yt=(()=>{const{OfficeIMOError:T}=ce,{cleanXml:E}=pe;class R{sheetName;maximum;policy;reserve;entries=[];characters=0;rows=0;constructor(d,u,f,m){this.sheetName=d,this.maximum=u,this.policy=f,this.reserve=m}add(d,u,f){const m=E(f,this.policy);if(this.characters+m.length>this.maximum)throw new T("RESOURCE_LIMIT","maxOverflowCharacters exceeded; use CSV or raise the bounded preservation limit.");let o=0;for(const l of C(m))o++;if(this.rows+o>1048575)throw new T("RESOURCE_LIMIT","Text overflow exceeds the worksheet row limit.");this.reserve(o*5,m.length+o*(d.length+u.length),this.rows+o);const i=this.rows+2;this.entries.push({sheet:d,cell:u,text:m,first:i,parts:o}),this.rows+=o,this.characters+=m.length;const a="\n[Full text: "+this.sheetName+"!D"+i+"; "+o+" parts]";return{preview:v(m,32767-a.length)+a,location:"'"+this.sheetName.replace(/'/g,"''")+"'!D"+i}}*values(){for(const d of this.entries){let u=0;for(const f of C(d.text))yield[d.sheet,d.cell,++u,f,d.parts]}}clear(){this.entries=[],this.characters=0,this.rows=0}}function v(h,d){let u=Math.min(d,h.length);return u<h.length&&/[\ud800-\udbff]/.test(h[u-1]??"")&&u--,h.slice(0,u)}function*C(h){let d=0;for(;d<h.length;){const u=v(h.slice(d,d+32768),32767);d+=u.length,yield u}}return Object.freeze({TextOverflow:R,clipText:v})})(),Le=(()=>{const{captureFields:T}=be,E=["signal","onProgress","limits","sink","dateMode","compression","invalidCharacterPolicy","appProperties","cellValueWriters","oversizedText","creator","title","subject","description","created","modified"],R=["columns","includeHeader","headerRows","freezeHeader","autoFilter","boldHeader","headerFill","headerStyle","alternatingRowStyle","rowStyle","cellStyle","rowOutline","maxOutlineLevel","outlineSummaryBelow","outlineSummaryRight","columnOutlines","rowHeight","headerHeight","defaultColumnWidth","freezeColumns","table","autoSize","footer","print","title","mergedCells","hyperlinks","conditionalFormats","dataValidation"],v=["maxRows","maxCells","maxTextCharacters","maxOutputBytes","maxStyles","maxSheets","maxOverflowCharacters","maxHyperlinks","maxImageBytes","maxBufferedCells","maxBufferedCharacters","maxMergedRanges","maxConditionalFormats","maxDifferentialStyles","maxCharts","maxChartPoints","maxChartTextCharacters","maxFormulaCharacters","maxDataValidations","maxValidationTextCharacters"];function C(d){return T(d,v)}function g(d){const u=T(d,E);return{...u,...u.limits===void 0?{}:{limits:C(u.limits)}}}return Object.freeze({workbookOptionFields:E,sheetOptionFields:R,workbookLimitFields:v,captureWorkbookLimits:C,captureWorkbookOptions:g})})(),bt=(()=>{const{checkAbort:T}=ge,{NotSupportedError:E,OfficeIMOError:R}=ce,{cleanXml:v}=pe,{captureFields:C}=be;function g(m,o,i){if(!m||typeof m!="object"||Array.isArray(m))throw new TypeError(i+" must be an object.");for(const a of Object.keys(m))if(!o.includes(a))throw new E(i+"."+a);return C(m,o)}function h(m){if(typeof m=="string"?!m.length:typeof m!="number"||!Number.isInteger(m)||m<1||m>16384)throw new TypeError("Chart columns require a declared key or a one-based column number.")}function d(m){const o=g(m,["kind","sheet","firstRow","rowCount","categoryColumn","series"],"chart.data");if(o.kind!=="range")throw new TypeError("A chart range must declare kind: range.");if(!o.sheet||typeof o.sheet!="object"||Array.isArray(o.sheet))throw new TypeError("A chart range needs its owning worksheet.");const i=o.firstRow===void 0?0:o.firstRow,a=o.rowCount;if(!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(a)||a<1||i+a>1048576)throw new RangeError("Chart data rows must form a nonempty finite Excel range.");if(h(o.categoryColumn),!Array.isArray(o.series)||o.series.length<1||o.series.length>255)throw new RangeError("A chart needs from 1 through 255 series.");const l=o.series.map(e=>{const n=g(e,["column","name","color"],"chart.data.series");if(h(n.column),n.name!==void 0&&typeof n.name!="string")throw new TypeError("Chart series name must be a string.");if(n.color!==void 0&&(typeof n.color!="string"||!/^#?[0-9a-fA-F]{6}$/.test(n.color)))throw new TypeError("Chart colors must be opaque six-digit RGB hex values.");return Object.freeze(n)});return Object.freeze({kind:"range",sheet:o.sheet,firstRow:i,rowCount:a,categoryColumn:o.categoryColumn,series:Object.freeze(l)})}function u(m,o,i,a,l="columnClustered"){T(a);const e=m.rowCount,n=m.firstRow??0,t=e*m.series.length,s=o.categoryColumn;if(t>i.availablePoints)throw new R("RESOURCE_LIMIT","maxChartPoints exceeded.");if(o.source!==m.sheet||!Number.isInteger(o.headerRows)||o.headerRows<0||o.headerRows+n+e>1048576||o.seriesColumns.length!==m.series.length||o.seriesNames.length!==m.series.length||o.valueFormulas.length!==m.series.length||o.nameFormulas.length!==m.series.length)throw new TypeError("Resolved chart range does not match its declared columns and data rows.");for(const D of[o.categoryColumn,...o.seriesColumns])if(!Number.isInteger(D)||D<1||D>16384)throw new RangeError("Resolved chart columns must be one-based Excel columns.");if(o.seriesColumns.includes(s))throw new TypeError("Chart category and numeric series must use different columns.");let r=0;const w=m.series.map((D,q)=>{const H=D.name??o.seriesNames[q];if(typeof H!="string"||H.length>32767)throw new TypeError("Chart series names must fit Excel text cells.");if(r+=H.length,r>i.availableText)throw new R("RESOURCE_LIMIT","maxChartTextCharacters exceeded.");return v(H,i.policy)}),S=m.series.map(D=>D.color?.replace(/^#/,"").toUpperCase()),x=new Array(e),p=m.series.map(()=>new Array(e)),y=m.series.map(()=>0),I=m.series.map(()=>!1);let j=0,M;const A=()=>{if(T(a),!M){if(j!==e||y.some(D=>D!==e))throw new TypeError("Chart range did not receive every declared data row and numeric value.");if(l==="pie"&&!I[0])throw new RangeError("A pie chart needs at least one positive value.");M=Object.freeze({categories:Object.freeze(x),series:Object.freeze(p.map((D,q)=>Object.freeze({name:w[q],values:Object.freeze(D),...S[q]===void 0?{}:{color:S[q]}})))})}},_=Object.freeze({get categories(){return A(),M.categories},get series(){return A(),M.series}}),F=new Map;return o.seriesColumns.forEach((D,q)=>{const H=F.get(D)??[];H.push(q),F.set(D,H)}),Object.freeze({source:o.source,points:t,textCharacters:r,data:_,references:Object.freeze({categories:o.categoryFormula,values:Object.freeze([...o.valueFormulas]),names:Object.freeze(o.nameFormulas.map((D,q)=>m.series[q].name===void 0?D:void 0))}),observe(D,q,H){T(a);const te=D-n;if(!(te<0||te>=e)){if(M)throw new R("INVALID_STATE","Chart cache is already finalized.");if(q===s){if(typeof H!="string"||H.length>32767)throw new TypeError("Chart category cells must contain strings of at most 32,767 UTF-16 units.");if(x[te]!==void 0)throw new R("INVALID_STATE","A chart category cell was observed more than once.");i.retainText(H.length),x[te]=v(H,i.policy),j++}for(const ee of F.get(q)??[]){if(typeof H!="number"||!Number.isFinite(H))throw new TypeError("Chart series cells require finite numbers or numeric formula caches.");if(l==="pie"&&H<0)throw new RangeError("Pie charts require nonnegative values.");if(p[ee][te]!==void 0)throw new R("INVALID_STATE","A chart value cell was observed more than once.");p[ee][te]=H,y[ee]=y[ee]+1,H>0&&(I[ee]=!0)}}},finish:A})}return Object.freeze({captureChartRange:d,prepareChartBinding:u})})(),xt=(()=>{const{checkAbort:T}=ge,{NotSupportedError:E,OfficeIMOError:R}=ce,{cleanXml:v}=pe,{copyDrawingAnchor:C}=ze,{captureFields:g}=be,{captureChartRange:h,prepareChartBinding:d}=bt;function u(i,a,l){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(l+" must be an object.");for(const e of Object.keys(i))if(!a.includes(e))throw new E(l+"."+e)}function f(i,a,l){return u(i,a,l),g(i,a)}function m(i,a,l,e,n,t){if(T(n),i=f(i,["type","data","row","column","width","height","description","title","language","legend","dataLabels","categoryAxis","valueAxis"],"chart"),!["columnClustered","barClustered","line","pie"].includes(i.type))throw new E("chart type "+i.type);const s=i.type,r=f(i.data,["kind","sheet","firstRow","rowCount","categoryColumn","categories","series"],"chart.data"),w=r.kind==="range"?h(r):void 0;w||u(r,["categories","series"],"chart.data");const S=w?void 0:r.categories,x=w?.series??r.series;if(!w&&!Array.isArray(S))throw new TypeError("Chart categories must be a nonempty array of strings.");if(!Array.isArray(x))throw new RangeError("A chart needs from 1 through 255 series.");const p=w?.rowCount??S.length,y=x.length;if(!p)throw new TypeError("Chart categories must be a nonempty array of strings.");if(!y||y>255)throw new RangeError("A chart needs from 1 through 255 series.");if(!w&&p>1048575)throw new RangeError("Chart data must fit Excel's rows including its header.");if(s==="pie"&&y!==1)throw new TypeError("A pie chart supports exactly one series.");const I=p*y;if(I>l)throw new R("RESOURCE_LIMIT","maxChartPoints exceeded.");let j=0;const M=(U,re)=>{if(typeof U!="string")throw new TypeError(re+" must be a string.");if(U.length>32767)throw new RangeError(re+" exceeds 32,767 UTF-16 units.");if(j+=U.length,j>e)throw new R("RESOURCE_LIMIT","maxChartTextCharacters exceeded.");return v(U,a)},A=(U,re)=>U===void 0?void 0:M(U,re),_=A(i.title,"Chart title"),F=A(i.description,"Chart description"),D=A(i.language,"Chart language");let q;if(D!==void 0)try{if(q=Intl.getCanonicalLocales(D)[0],!q)throw new RangeError}catch{throw new TypeError("Chart language must be a language tag such as pl or pl-PL.")}const H=C({row:i.row,column:i.column,width:i.width,height:i.height,...F===void 0?{}:{description:F}},a);if(i.legend!==void 0&&i.legend!==!1&&!["right","bottom","left","top"].includes(i.legend))throw new TypeError("Unsupported chart legend position.");let te;if(i.dataLabels!==void 0){const U=f(i.dataLabels,["showValue","showCategoryName","showSeriesName","showPercent","position","numberFormat"],"chart.dataLabels");for(const fe of["showValue","showCategoryName","showSeriesName","showPercent"])if(U[fe]!==void 0&&typeof U[fe]!="boolean")throw new TypeError("Chart label flags must be booleans.");if(U.showPercent&&s!=="pie")throw new TypeError("Percent data labels require a pie chart.");const re=s==="pie"?["center","insideEnd","outsideEnd","bestFit"]:s==="line"?["center","above","below","left","right"]:["center","insideEnd","outsideEnd"];if(U.position!==void 0&&!re.includes(U.position))throw new TypeError("Data label position is unsupported for this chart type.");const K=A(U.numberFormat,"Data label number format");if(K!==void 0&&!K.trim())throw new TypeError("Data label number format cannot be blank.");te=Object.freeze({...U,...K===void 0?{}:{numberFormat:K}})}if(s==="pie"&&(i.categoryAxis!==void 0||i.valueAxis!==void 0))throw new TypeError("Pie charts have no axes.");let ee,he;if(i.categoryAxis!==void 0){const U=A(f(i.categoryAxis,["title"],"chart.categoryAxis").title,"Category axis title");ee=Object.freeze(U===void 0?{}:{title:U})}if(i.valueAxis!==void 0){const U=f(i.valueAxis,["title","minimum","maximum","numberFormat"],"chart.valueAxis");for(const fe of[U.minimum,U.maximum])if(fe!==void 0&&!Number.isFinite(fe))throw new TypeError("Chart axis bounds must be finite numbers.");if(U.minimum!==void 0&&U.maximum!==void 0&&U.minimum>=U.maximum)throw new RangeError("Chart axis minimum must be below its maximum.");const re=A(U.title,"Value axis title"),K=A(U.numberFormat,"Value axis number format");if(K!==void 0&&!K.trim())throw new TypeError("Value axis number format cannot be blank.");he=Object.freeze({...U,...re===void 0?{}:{title:re},...K===void 0?{}:{numberFormat:K}})}const se={...H,type:s,...q===void 0?{}:{language:q},..._===void 0?{}:{title:_},...F===void 0?{}:{description:F},...i.legend===void 0?{}:{legend:i.legend},...te===void 0?{}:{dataLabels:te},...ee===void 0?{}:{categoryAxis:ee},...he===void 0?{}:{valueAxis:he}};if(w){if(!t)throw new TypeError("A chart range must belong to the current workbook.");const{descriptor:U,retainText:re}=t(w),K=d(w,U,{availablePoints:l,availableText:e-j,retainText:re,policy:a},n,s);return Object.freeze({...se,data:K.data,binding:K,points:I,textCharacters:j+K.textCharacters})}const de=S,le=[],Y=[];for(let U=0;U<p;U++)(U&255)===0&&T(n),le.push(M(de[U],"Chart category"));for(let U=0;U<y;U++){const re=x[U],K=f(re,["name","values","color"],"chart.series"),fe=M(K.name,"Chart series name"),k=K.values,z=K.color;if(!Array.isArray(k)||k.length!==p)throw new TypeError("Chart series values must match the category count.");if(z!==void 0&&(typeof z!="string"||!/^#?[0-9a-fA-F]{6}$/.test(z)))throw new TypeError("Chart colors must be opaque six-digit RGB hex values.");let L=!1;const X=[];for(let Z=0;Z<p;Z++){(Z&255)===0&&T(n);const Q=k[Z];if(typeof Q!="number"||!Number.isFinite(Q))throw new TypeError("Chart values must be finite numbers.");if(s==="pie"&&Q<0)throw new RangeError("Pie charts require nonnegative values.");Q>0&&(L=!0),X.push(Q)}if(s==="pie"&&!L)throw new RangeError("A pie chart needs at least one positive value.");Y.push(Object.freeze({name:fe,values:Object.freeze(X),...z===void 0?{}:{color:z.replace(/^#/,"").toUpperCase()}}))}return Object.freeze({...se,data:Object.freeze({categories:Object.freeze(le),series:Object.freeze(Y)}),points:I,textCharacters:j})}return Object.freeze({prepareChart:m})})(),Ze=(()=>{const{beginTask:T,checkAbort:E,pause:R,taskYieldDue:v}=ge,{OfficeIMOError:C}=ce,{notifyProgress:g}=Qe,{ChunkedTextSink:h}=Te,{ExportBudget:d}=et,{OpcPackage:u,officeRelationshipsNamespace:f,relationshipTypes:m,corePropertiesXml:o}=Me,{escapeOoxmlAttribute:i,cleanXml:a,xmlDeclaration:l}=pe,{StyleRegistry:e,spreadsheetNamespace:n}=Fe,{sheetName:t,assertXlsxValue:s,copyValue:r}=ke,{copyColumns:w}=Be,{captureFields:S}=be,{captureColumnOutlines:x}=nt,{captureTableSpans:p}=st,{assertExportValue:y}=xe,{Worksheet:I}=lt,{defineTable:j,tableXml:M}=gt,{copyHyperlink:A,drawingXml:_,drawingContentType:F}=ze,{TextOverflow:D}=yt,{captureWorkbookOptions:q,sheetOptionFields:H}=Le,{prepareChart:te}=xt,{qualifiedColumnRange:ee,resolveDataColumn:he}=Pe,{chartContentType:se,writeChartXml:de}=ot,le="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",Y=fe=>"application/vnd.openxmlformats-officedocument.spreadsheetml."+fe+"+xml";function U(fe,k){const z=S(fe,H),L=w(z.columns??[],!0),X=z.footer&&S(z.footer,["rows","values","totals","style"]),Z=z.print&&S(z.print,["paper","orientation","fitToWidth","fitToHeight","repeatHeaders","margins","header","footer"]);return{...z,columns:L,...z.columnOutlines===void 0?{}:{columnOutlines:x(z.columnOutlines,L.length)},...z.headerRows===void 0?{}:{headerRows:p(z.headerRows,L.length)},...X?{footer:{...X,...X.rows===void 0?{}:{rows:p(X.rows,L.length)},...X.values===void 0?{}:{values:X.values.map(r)}}}:{},...z.table?{table:S(z.table,["name","style","bandedRows","bandedColumns","firstColumn","lastColumn"])}:{},...z.autoSize?{autoSize:S(z.autoSize,["sampleRows","minWidth","maxWidth"])}:{},...z.title?{title:S(z.title,["text","style","height"])}:{},...Z?{print:{...Z,...Z.margins===void 0?{}:{margins:S(Z.margins,["left","right","top","bottom","header","footer"])}}}:{},...z.hyperlinks?{hyperlinks:z.hyperlinks.map(Q=>A(Q,k))}:{}}}class re{portableValues=!1;static forTable(k){const z=new re(k);return z.portableValues=!0,z}get valueValidator(){return this.portableValues?y:s}styles;names=new Set;sheets=[];tableNames=new Set;tableCount=0;writers;package;state="open";result;completion;activeSheet;failure;overflow;links=0;imageBytes=0;bufferedBytes=0;mergedRanges=0;conditionalFormats=0;dataValidationCount=0;validationTextCharacters=0;formulaCharacters=0;hasAuthoredFormulas=!1;nativeCharts=[];chartSourceSheets=0;chartPoints=0;chartTextCharacters=0;registering=!1;registration(k){if(this.assertOpen(),this.registering)throw new C("INVALID_STATE","Workbook registrations cannot be reentered from input getters.");this.registering=!0;try{return k()}finally{this.registering=!1}}budget;settings;constructor(k={}){k=q(k);const z=k.dateMode??"local",L=k.compression??"auto",X=k.invalidCharacterPolicy??"strip";if(z!=="local"&&z!=="utc")throw new RangeError("dateMode must be local or utc.");if(L!=="auto"&&L!=="store")throw new RangeError("compression must be auto or store.");if(k.oversizedText!==void 0&&!["reject","preserve"].includes(k.oversizedText))throw new RangeError("oversizedText must be reject or preserve.");if(a("",X),o(k,X),this.budget=new d(k.limits),this.styles=new e(X,k.limits?.maxStyles,k.limits?.maxDifferentialStyles),k.sink!==void 0&&typeof k.sink.write!="function")throw new TypeError("sink must be a ByteSink.");this.settings=Object.freeze({...k,...k.limits?{limits:Object.freeze({...k.limits})}:{},dateMode:z,compression:L,invalidCharacterPolicy:X}),this.writers=Object.freeze({...k.cellValueWriters});for(const Z of Object.values(this.writers))if(typeof Z!="function")throw new TypeError("Cell value writers must be functions.");T(),this.package=new u({compression:L,invalidCharacterPolicy:X,...k.signal?{signal:k.signal}:{},...k.sink?{sink:k.sink}:{},...k.limits?.maxOutputBytes===void 0?{}:{maxOutputBytes:k.limits.maxOutputBytes}}),this.package.setProperties(k,k.appProperties),this.addXmlPart("/xl/workbook.xml",Y("sheet.main"),()=>this.workbookXml()),this.addXmlPart("/xl/styles.xml",Y("styles"),()=>this.styles.toXml())}addXmlPart(k,z,L){this.package.addPart({uri:k,contentType:z,data:async X=>{const Z=new h(X,this.settings.signal);await Z.write(L()),await Z.close()}})}workbookXml(){return l+'<workbook xmlns="'+n+'" xmlns:r="'+f+'"><workbookPr date1904="0"/><bookViews><workbookView/></bookViews><sheets>'+this.sheets.map((k,z)=>'<sheet name="'+i(k.name,this.settings.invalidCharacterPolicy)+'" sheetId="'+(z+1)+'"'+(k.hidden?' state="hidden"':"")+' r:id="rId'+(z+1)+'"/>').join("")+"</sheets>"+(this.sheets.some(k=>k.printSettings)?"<definedNames>"+this.sheets.map((k,z)=>{const L="'"+k.name.replace(/'/g,"''")+"'!";return k.printSettings?'<definedName name="_xlnm.Print_Area" localSheetId="'+z+'">'+i(L+"$A$1:$"+k.lastColumn+"$"+k.totalRows,this.settings.invalidCharacterPolicy)+"</definedName>"+(k.printSettings.repeatHeaders&&k.firstHeaderRow?'<definedName name="_xlnm.Print_Titles" localSheetId="'+z+'">'+i(L+"$"+k.firstHeaderRow+":$"+k.headerRowCount,this.settings.invalidCharacterPolicy)+"</definedName>":""):""}).join("")+"</definedNames>":"")+(this.hasAuthoredFormulas?'<calcPr calcMode="auto" fullCalcOnLoad="1" forceFullCalc="1"/>':"")+"</workbook>"}assertOpen(){try{E(this.settings.signal)}catch(k){throw this.discard(k).catch(()=>{}),k}if(this.state==="failed")throw this.failure;if(this.state!=="open")throw new C("INVALID_STATE","Workbook is already finalized.")}writerFor(k){return Object.prototype.hasOwnProperty.call(this.writers,k)?this.writers[k]:void 0}preserveText(k,z,L){if(this.settings.oversizedText!=="preserve")throw new RangeError("Excel cell text exceeds 32,767 UTF-16 code units.");return this.overflow||(this.checkSheetLimit(this.sheets.length+this.chartSourceSheets+1),this.budget.reserve(5,22),this.overflow=new D(t("Text overflow",this.names,this.settings.invalidCharacterPolicy),this.settings.limits?.maxOverflowCharacters??4e6,this.settings.invalidCharacterPolicy,(X,Z,Q)=>{this.budget.row(Q),this.budget.reserve(X,Z)})),this.overflow.add(k,z,L)}checkSheetLimit(k){if(k>65526)throw new RangeError("Workbook has too many sheets.");if(this.settings.limits?.maxSheets!==void 0&&k>this.settings.limits.maxSheets)throw new C("RESOURCE_LIMIT","maxSheets exceeded.")}checkLinks(k){if(this.settings.limits?.maxHyperlinks!==void 0&&this.links+k>this.settings.limits.maxHyperlinks)throw new C("RESOURCE_LIMIT","maxHyperlinks exceeded.")}retainLink(k=1){this.checkLinks(k),this.links+=k}checkImage(k){if(this.settings.limits?.maxImageBytes!==void 0&&this.imageBytes+k>this.settings.limits.maxImageBytes)throw new C("RESOURCE_LIMIT","maxImageBytes exceeded.")}retainImage(k){this.checkImage(k),this.imageBytes+=k}retainBufferedBytes(k){this.budget.check("maxOutputBytes",this.bufferedBytes+k),this.bufferedBytes+=k}checkMerges(k){if(this.mergedRanges+k>(this.settings.limits?.maxMergedRanges??1e4))throw new C("RESOURCE_LIMIT","maxMergedRanges exceeded.")}checkConditionalFormats(k){if(this.conditionalFormats+k>(this.settings.limits?.maxConditionalFormats??1e3))throw new C("RESOURCE_LIMIT","maxConditionalFormats exceeded.")}get availableDataValidations(){return(this.settings.limits?.maxDataValidations??1e3)-this.dataValidationCount}get availableValidationTextCharacters(){return(this.settings.limits?.maxValidationTextCharacters??1e6)-this.validationTextCharacters}retainFormula(k){if(this.formulaCharacters+k>(this.settings.limits?.maxFormulaCharacters??1e6))throw new C("RESOURCE_LIMIT","maxFormulaCharacters exceeded.");this.formulaCharacters+=k,this.hasAuthoredFormulas=!0}checkChartText(k){if(this.chartTextCharacters+k>(this.settings.limits?.maxChartTextCharacters??1e6))throw new C("RESOURCE_LIMIT","maxChartTextCharacters exceeded.")}retainChartText(k){this.checkChartText(k),this.chartTextCharacters+=k}resolveChartBinding(k){const z=k.sheet;if(!this.sheets.includes(z)||z.hidden)throw new TypeError("Bound charts require a visible worksheet in the same workbook.");const L=z.chartBindingMetadata,X=k.firstRow??0;if(z.isBusy||L.closed||X<L.rows)throw new C("INVALID_STATE","Register a chart before its first selected data row is written, while the source worksheet is idle.");const Z=he(L.columns,k.categoryColumn,"Chart"),Q=k.series.map(P=>he(L.columns,P.column,"Chart")),oe=L.headerRows+X+1;return{descriptor:{source:z,sheetName:L.name,headerRows:L.headerRows,categoryColumn:Z,seriesColumns:Q,seriesNames:Q.map(P=>L.columns[P-1].header),categoryFormula:ee(L.name,Z,oe,k.rowCount),valueFormulas:Q.map(P=>ee(L.name,P,oe,k.rowCount)),nameFormulas:Q.map((P,ue)=>k.series[ue].name===void 0?L.headerReferences[P-1]:void 0)},retainText:P=>this.retainChartText(P)}}registerChart(k){return this.registration(()=>{if(this.nativeCharts.length>=(this.settings.limits?.maxCharts??100))throw new C("RESOURCE_LIMIT","maxCharts exceeded.");const z=te(k,this.settings.invalidCharacterPolicy,(this.settings.limits?.maxChartPoints??1e5)-this.chartPoints,(this.settings.limits?.maxChartTextCharacters??1e6)-this.chartTextCharacters,this.settings.signal,X=>this.resolveChartBinding(X));this.assertOpen(),this.checkChartText(z.textCharacters),this.checkSheetLimit(this.sheets.length+this.chartSourceSheets+(z.binding?0:1)+(this.overflow?1:0));const L=Object.freeze({...z,id:this.nativeCharts.length+1,dataSheetName:z.binding?z.binding.source.name:t("Chart data "+(this.nativeCharts.length+1),this.names,this.settings.invalidCharacterPolicy)});return this.nativeCharts.push(L),this.chartPoints+=z.points,this.chartTextCharacters+=z.textCharacters,z.binding?z.binding.source.retainChartBinding(z.binding):this.chartSourceSheets++,L})}async openSheet(k){if(this.activeSheet&&this.activeSheet!==k){if(this.activeSheet.isBusy)throw new C("INVALID_STATE","Await the active streamed worksheet before starting another.");await this.activeSheet.finish()}return this.activeSheet=k,this.package.openPart("/xl/worksheets/sheet"+(this.sheets.indexOf(k)+1)+".xml",Y("worksheet"))}async discard(k){this.state="failed",this.failure=k,await Promise.allSettled(this.sheets.map(z=>z.discard(k))),await this.package.discard(k),this.overflow?.clear(),this.nativeCharts.length=0}get worksheets(){return Object.freeze([...this.sheets])}get rowCount(){return this.sheets.reduce((k,z)=>k+z.reportRowCount,0)}addWorksheet(k,z={}){return this.registration(()=>{this.checkSheetLimit(this.sheets.length+this.chartSourceSheets+1+(this.overflow?1:0));const L=U(z,this.settings.invalidCharacterPolicy),X=I.validate(this,L);let Z=L.table;if(Z&&Z.name===void 0){let P=this.tableCount+1;for(;this.tableNames.has(("Table"+P).toLowerCase());)P++;Z={...Z,name:"Table"+P}}const Q=Z?j(this.tableCount+1,Z,L.columns??[],this.settings.invalidCharacterPolicy):void 0;if(Q&&this.tableNames.has(Q.name.toLowerCase()))throw new TypeError("Duplicate Excel table name: "+Q.name);t(k,this.names,this.settings.invalidCharacterPolicy,!1);const oe=I.create(this,()=>t(k,this.names,this.settings.invalidCharacterPolicy,!1),L,Q,!1,X.conditional,X.validations);return this.assertOpen(),this.checkSheetLimit(this.sheets.length+this.chartSourceSheets+1+(this.overflow?1:0)),this.names.add(oe.name.toLowerCase()),this.mergedRanges+=oe.mergeCount,this.conditionalFormats+=oe.conditionalFormatCount,this.dataValidationCount+=oe.dataValidations.count,this.validationTextCharacters+=oe.dataValidations.textCharacters,Q&&(this.tableNames.add(Q.name.toLowerCase()),this.tableCount++),this.sheets.push(oe),oe})}addPart(k){this.assertOpen();const{uri:z,contentType:L,data:X,relationship:Z}=k,Q=Z&&{id:Z.id,type:Z.type,source:Z.source};if(this.assertOpen(),this.package.addPart({uri:z,contentType:L,data:X}),Q){const{source:oe,id:P,type:ue}=Q;this.package.addRelationship(oe??"/xl/workbook.xml",{id:P,type:ue,target:z})}}finish(){try{E(this.settings.signal)}catch(k){return this.discard(k).then(()=>{throw k})}if(this.completion)return this.completion;if(this.state==="failed")return Promise.reject(this.failure);if(this.assertOpen(),this.sheets.some(k=>k.isBusy))throw new C("INVALID_STATE","Await addRows before finalizing the workbook.");return this.sheets.length||this.addWorksheet("Sheet1"),this.state="finalizing",this.completion=(async()=>{try{const k=this.rowCount;for(let L=0;L<this.sheets.length;L++){const X=this.sheets[L],Z="/xl/worksheets/sheet"+(L+1)+".xml";await X.finish();const Q=X.takePrepared();Q&&this.package.addPrepared(Z,Y("worksheet"),Q);const oe=X.tableDefinition;if(oe){const P="/xl/tables/table"+oe.id+".xml";this.addXmlPart(P,Y("table"),()=>M(oe,X.rowCount,this.settings.invalidCharacterPolicy,X.headerRowCount,X.footerSettings)),this.package.addRelationship(Z,{id:"table",type:f+"/table",target:P})}for(let P=0;P<X.hyperlinks.length;P++)E(this.settings.signal),this.package.addRelationship(Z,{id:"link"+(P+1),type:f+"/hyperlink",target:X.hyperlinks[P].target,external:!0}),(P&255)===255&&v()&&(await R(),E(this.settings.signal));if(X.images.length||X.charts.length){const P="/xl/drawings/drawing"+(L+1)+".xml";this.addXmlPart(P,F,()=>_(X.images,this.settings.invalidCharacterPolicy,X.charts)),this.package.addRelationship(Z,{id:"drawing",type:f+"/drawing",target:P});for(let ue=0;ue<X.images.length;ue++){E(this.settings.signal);const ye="/xl/media/sheet"+(L+1)+"-image"+(ue+1)+".png";this.package.addPart({uri:ye,contentType:"image/png",data:X.images[ue].data}),this.package.addRelationship(P,{id:"image"+(ue+1),type:f+"/image",target:ye}),(ue&255)===255&&v()&&(await R(),E(this.settings.signal))}for(const ue of X.charts){E(this.settings.signal);const ye="/xl/charts/chart"+ue.id+".xml";this.package.addPart({uri:ye,contentType:se,data:c=>de(ue,c,this.settings.invalidCharacterPolicy,this.settings.signal)}),this.package.addRelationship(P,{id:"chart"+ue.id,type:f+"/chart",target:ye})}}}if(this.overflow){const L=I.create(this,this.overflow.sheetName,{columns:[{header:"Sheet"},{header:"Cell"},{header:"Part"},{header:"Text",width:80,wrapText:!0},{header:"Parts"}],freezeHeader:!0},void 0,!0);this.sheets.push(L),await L.finish(this.overflow.values());const X=L.takePrepared();X&&this.package.addPrepared("/xl/worksheets/sheet"+this.sheets.length+".xml",Y("worksheet"),X),this.overflow.clear()}for(const L of this.nativeCharts){if(E(this.settings.signal),L.binding)continue;const X=I.createChartData(this,L);this.sheets.push(X);function*Z(){for(let oe=0;oe<L.data.categories.length;oe++)yield[L.data.categories[oe],...L.data.series.map(P=>P.values[oe])]}await X.finish(Z());const Q=X.takePrepared();Q&&this.package.addPrepared("/xl/worksheets/sheet"+this.sheets.length+".xml",Y("worksheet"),Q)}this.package.addRelationship("/",{id:"workbook",type:m.officeDocument,target:"/xl/workbook.xml"});for(let L=0;L<this.sheets.length;L++)E(this.settings.signal),this.package.addRelationship("/xl/workbook.xml",{id:"rId"+(L+1),type:m.worksheet,target:"/xl/worksheets/sheet"+(L+1)+".xml"}),(L&255)===255&&v()&&(await R(),E(this.settings.signal));this.package.addRelationship("/xl/workbook.xml",{id:"styles",type:m.styles,target:"/xl/styles.xml"});const z=await this.package.finish();for(const L of this.sheets)L.releaseCharts();return this.nativeCharts.length=0,g(this.settings.onProgress,{phase:"complete",rows:k,bytes:z}),E(this.settings.signal),this.state="complete",{rows:k,sheets:this.sheets.length,bytes:z}}catch(k){throw await this.discard(k),k}})(),this.completion}toBlob(){try{E(this.settings.signal)}catch(k){return this.discard(k).then(()=>{throw k})}if(this.settings.sink)throw new C("INVALID_STATE","This workbook uses a caller-owned sink; use finish().");if(!this.result){const k=this.finish();this.result=k.then(()=>this.package.toBlob(le))}return this.result}}return Object.freeze({Workbook:re})})(),ct=(()=>{const{ExportCell:T,assertScalar:E}=xe,{captureWorkbookOptions:R,sheetOptionFields:v}=Le,{captureFields:C}=be;function g(m){for(const o of["font","fill","border","numberFormat"])if(typeof m?.[o]=="number")throw new TypeError("Workbook-local style indexes require the advanced Workbook API; use style definitions.");return m}function h(m){return m instanceof T||E(m),m}function d(m={}){if(m=C(m,v),m.headerStyle!==void 0)throw new TypeError("Workbook-local header styles require the advanced Workbook API; use boldHeader and headerFill.");g(m.alternatingRowStyle),g(m.title?.style),g(m.footer?.style),m.footer?.values?.forEach(h);const o=m.rowStyle,i=m.cellStyle;for(const a of[o,i])if(a!==void 0&&typeof a!="function")throw new TypeError("Style callbacks must be functions.");return{...m,...o?{rowStyle:a=>g(o(a))}:{},...i?{cellStyle:a=>g(i(a))}:{}}}function u(m={}){m=R(m);const o=m.cellValueWriters;if(!o)return m;const i=Object.create(null);for(const[a,l]of Object.entries(o)){if(typeof l!="function")throw new TypeError("Cell value writers must be functions.");i[a]=(e,n)=>h(l(e,n))}return{...m,cellValueWriters:i}}return Object.freeze({portableSheet:d,portableWorkbook:u})})(),ht=(()=>{const{withDestination:T}=Te,{copyColumns:E}=Be,{Workbook:R}=Ze,{portableSheet:v,portableWorkbook:C}=ct,{captureFields:g}=be,{sheetOptionFields:h,workbookOptionFields:d}=Le;function u(a){a=g(a,[...d,"columns","sheet"]);const l=E(a.columns),e=a.sheet&&g(a.sheet,[...h,"name"]);return{...C(a),columns:l,sheet:{...v(e),...e?.name===void 0?{}:{name:e.name}}}}function f(a,l){const{name:e="Data",...n}=l.sheet??{};return a.addWorksheet(e,{boldHeader:!0,autoFilter:n.includeHeader!==!1,autoSize:{minWidth:6,maxWidth:54},...n,columns:l.columns})}async function m(a,l){const e=u(l),{columns:n,sheet:t,...s}=e,r=R.forTable(s);try{return await f(r,e).addRows(a),await r.toBlob()}catch(w){throw await r.discard(w),w}}async function o(a,l,e){const n=u(e);return T(l,async t=>{const{columns:s,sheet:r,...w}=n,S=R.forTable({...w,sink:t});try{const x=f(S,n),p=n.columns.length;await x.addRows(a);const y=await S.finish();return{rows:y.rows,columns:p,bytes:y.bytes}}catch(x){throw await S.discard(x),x}})}return Object.freeze({writeXlsx:m,writeXlsxTo:o})})(),Ge=(()=>{const{ExportCell:T,assertScalar:E}=xe,{isDate:R}=Se,{checkAbort:v,inputRows:C,pause:g,taskYieldDue:h}=ge,{ExportBudget:d}=et,{OfficeIMOError:u}=ce,{copyColumns:f,createRowProjector:m}=Be,{createTotals:o}=it,{copyExportValue:i}=He,a=new WeakMap;function l(A){if(!A||typeof A!="object"||!a.has(A))throw new TypeError("Create grouped report sources with createGroupedReport.")}function e(A,_){return l(A),{async*[Symbol.asyncIterator](){const F=n(A,_);try{yield*F.events}finally{F.dispose()}}}}function n(A,_){l(A);const F=a.get(A),D=t(F.signal,_);return{signal:D.signal,events:F.events(D.signal),dispose:D.dispose}}function t(A,_){if(!A||!_||A===_)return{signal:A??_,dispose(){}};const F=new AbortController,D=()=>F.abort(A.reason),q=()=>F.abort(_.reason);return A.addEventListener("abort",D,{once:!0}),_.addEventListener("abort",q,{once:!0}),A.aborted?D():_.aborted&&q(),{signal:F.signal,dispose(){A.removeEventListener("abort",D),_.removeEventListener("abort",q)}}}function s(A,_,F){const D=A??_;if(!Number.isSafeInteger(D)||D<0)throw new RangeError(F+" must be a nonnegative safe integer.");return D}function r(A){return A instanceof T?A.value:A}function w(A){if(A==null)return{key:null,id:"null",text:""};if(R(A)){const F=Date.prototype.getTime.call(A);if(!Number.isFinite(F))throw new TypeError("A group key date must be valid.");return{key:new Date(F),id:"date:"+F,text:new Date(F).toISOString()}}if(typeof A=="number"&&!Number.isFinite(A))throw new TypeError("A numeric group key must be finite.");const _=String(A);return{key:A,id:typeof A+":"+_,text:_}}function S(A){return R(A)?new Date(Date.prototype.getTime.call(A)):A}function x(A){return Object.freeze(A.map(_=>_.operation===void 0?null:_.value()))}function p(A,_,F){const D=typeof A=="string"?[A]:Array.isArray(A)?Array.from(A):void 0;if(!D||D.length<1||D.length>4)throw new TypeError("groupBy must declare between one and four grouping levels.");if(F!==void 0&&typeof F!="function")throw new TypeError("groupLabel must be a synchronous function.");if(F&&D.length!==1)throw new TypeError("groupLabel is only available for one grouping level; use descriptor labels for a hierarchy.");const q=new Set;return Object.freeze(D.map(H=>{if(typeof H!="string"&&(!H||typeof H!="object"||Array.isArray(H)))throw new TypeError("A grouping level must name a stable column key or provide a descriptor.");const{key:te,value:ee,label:he}=typeof H=="string"?{key:H,value:void 0,label:void 0}:H;if(typeof te!="string"||!te.length||q.has(te))throw new TypeError("Grouping levels need unique, nonempty stable keys.");if(q.add(te),ee!==void 0&&typeof ee!="function")throw new TypeError("Grouping value getters must be synchronous functions.");if(he!==void 0&&typeof he!="function")throw new TypeError("Grouping labels must be synchronous functions.");if(he&&F)throw new TypeError("Specify either groupLabel or the grouping descriptor label.");const se=_.indexOf(te);if(se>=0&&ee!==void 0)throw new TypeError("A declared grouping column reuses its projected value; do not provide another value getter.");if(se<0&&ee===void 0)throw new TypeError("groupBy must name a declared stable column key; hidden grouping fields need an explicit value getter.");return Object.freeze({key:te,column:se,value:ee,label:he??F})}))}function y(A){return Object.freeze(A.map(({group:_})=>Object.freeze({..._,key:S(_.key)})))}function I(A,_,F){if(!A)return F;const D=A(S(_));if(typeof D?.then=="function"&&Promise.resolve(D).catch(()=>{}),typeof D!="string")throw new TypeError("Grouping labels must return synchronous text.");return D}function j(A,_){if(!_||typeof _!="object")throw new TypeError("Grouped report options are required.");const{columns:F,groupBy:D,totals:q,groupLabel:H,maxGroups:te,maxGroupKeyCharacters:ee,signal:he,limits:se}=_;if(se!==void 0&&(!se||typeof se!="object"||Array.isArray(se)))throw new TypeError("Grouped source limits must be an object.");if(se!==void 0&&"maxOutputBytes"in se)throw new TypeError("Set maxOutputBytes on the format writer, not the grouped source.");if(!Array.isArray(F)||!F.length)throw new TypeError("A grouped report needs declared columns.");const de=f(F),le=de.map(P=>P.key);if(le.some(P=>typeof P!="string"||P.length===0)||new Set(le).size!==le.length)throw new TypeError("Grouped report columns need unique, nonempty stable keys.");const Y=p(D,le,H),U=Object.freeze({...q}),re=o(de,U);for(let P=0;P<de.length;P++)if(re[P].operation!==void 0&&de[P].type!=="number")throw new TypeError("Grouped numeric totals require a column declared with type:number.");const K=s(te,1e3,"maxGroups"),fe=s(ee,1e6,"maxGroupKeyCharacters"),k=new d(se),z=Object.freeze(de.map(P=>{const{value:ue,...ye}=P;return Object.freeze(ye)}));for(const P of de){k.cell(P.header);for(const ue of P.groups??[])k.reserve(0,ue.length);Object.freeze(P)}let L=!1;const X=P=>Object.freeze({[Symbol.asyncIterator](){if(L)throw new TypeError("A grouped report source can be consumed only once.");return L=!0,Q(P)}}),Z=X(he);async function*Q(P){const ue=m(de,void 0,P),ye=new Set,c=[];let b=0,O=0,N=0;for await(const B of C(A,P)){const J=Array.isArray(B)?Array.from(B):B,V=ue(J,O),ne=[];for(let G=0;G<de.length;G++)ne.push(i(V[G])??null);v(P);const me=Y.map((G,$)=>{v(P);const ie=G.column>=0?r(ne[G.column]):G.value(J,Object.freeze({rowIndex:O,level:$,key:G.key}));return E(ie),v(P),w(ie)});k.row(O+1);for(let G=0;G<ne.length;G++){const $=ne[G],ie=r($);if(re[G].operation!==void 0&&ie!=null&&(typeof ie!="number"||!Number.isFinite(ie)))throw new TypeError("Grouped numeric metrics must resolve to finite numbers or null.");k.cell(ie),$ instanceof T&&$.text!==void 0&&k.reserve(0,$.text.length)}let ae=0;for(;ae<c.length&&c[ae].id===me[ae].id;)ae++;const W=[];for(let G=ae;G<Y.length;G++){const $=me[G],Re=((W.at(-1)??c[G-1])?.group.groupIndex??-1)+":"+$.id;if(ye.has(Re))throw new TypeError("Grouped rows must be contiguous; a closed group key occurred again within the same parent.");if(N===K)throw new u("RESOURCE_LIMIT","maxGroups exceeded.");const Oe=I(Y[G].label,$.key,$.text);v(P);const Ae=b+Re.length+Oe.length;if(!Number.isSafeInteger(Ae)||Ae>fe)throw new u("RESOURCE_LIMIT","maxGroupKeyCharacters exceeded.");k.reserve(0,Oe.length),W.push({id:$.id,group:Object.freeze({groupIndex:N,key:$.key,label:Oe,level:G}),rows:0,aggregates:o(de,U)}),b=Ae,ye.add(Re),N++}for(;c.length>ae;){v(P);const G=y(c),$=c.pop();yield Object.freeze({kind:"groupEnd",...G.at(-1),path:G,rows:$.rows,totals:x($.aggregates)})}for(const G of W){v(P),c.push(G);const $=y(c);yield Object.freeze({kind:"groupStart",...$.at(-1),path:$})}for(let G=0;G<ne.length;G++){const $=r(ne[G]);for(const ie of c)ie.aggregates[G].accept($);re[G].accept($)}for(const G of c)G.rows++;v(P),yield Object.freeze({kind:"row",values:Object.freeze(ne),rowIndex:O,groupIndex:c.at(-1).group.groupIndex,path:y(c)}),O++,h()&&(await g(),v(P))}for(v(P);c.length;){v(P);const B=y(c),J=c.pop();yield Object.freeze({kind:"groupEnd",...B.at(-1),path:B,rows:J.rows,totals:x(J.aggregates)})}v(P),yield Object.freeze({kind:"complete",rows:O,groups:N,totals:x(re)})}const oe=Object.freeze({columns:z,groupBy:Object.freeze(Y.map(P=>P.key)),totals:U,events:Z});return a.set(oe,{signal:he,events:X}),oe}return Object.freeze({assertGroupedReportSource:l,groupedReportEvents:e,groupedReportOperation:n,createGroupedReport:j})})(),Ct=(()=>{const{assertGroupedReportSource:T}=Ge,{captureFields:E}=be,{OfficeIMOError:R}=ce,{fields:v}=Xe,{sheetOptionFields:C}=Le,{portableSheet:g}=ct,{resolveDataColumn:h}=Pe,{copyStylePatch:d}=Fe,u=["labelColumn","subtotalLabel","grandTotalLabel","includeGrandTotal","collapseGroups","sheet","groupStyle","subtotalStyle","grandTotalStyle","conditionalFormats","dataValidation"],f=["columns","headerRows","footer","table","mergedCells","hyperlinks","conditionalFormats","dataValidation","rowStyle","cellStyle","rowOutline","maxOutlineLevel"];function m(e,n){return h(e.columns,n,"Grouped detail")+1}function o(e,n,t){if(n!==void 0){if(!Array.isArray(n))throw new TypeError("conditionalFormats must be an array.");if(n.length>t)throw new R("RESOURCE_LIMIT","maxConditionalFormats exceeded.");return n.map(s=>{const r=E(s,["type","range","style","stopIfTrue","operator","value","values","formula","stops","color","minimum","maximum","showValue"]),w=r.range;if(typeof w=="string")throw new TypeError("Grouped conditional formats require detail-column selectors rather than A1 or generated-row ranges.");v(w,["column","through"],"grouped conditional range");const S=E(w,["column","through"]);return{...r,range:{column:m(e,S.column),...S.through===void 0?{}:{through:m(e,S.through)}}}})}}function i(e,n,t){if(n!==void 0){if(!Array.isArray(n))throw new TypeError("dataValidation must be an array.");if(n.length>t)throw new R("RESOURCE_LIMIT","maxDataValidations exceeded.");return n.map(s=>{const r=E(s,["type","column","items","allowBlank","showErrorMessage","errorStyle","errorTitle","errorMessage"]);return{...r,column:m(e,r.column)}})}}function a(e,n,t=1e3,s=1e3){if(T(e),!n||typeof n!="object")throw new TypeError("Grouped XLSX options require host-authored labels.");const r=E(n,u),w=E(r.sheet??{},[...C,"name"]);if(!r.labelColumn||typeof r.labelColumn!="object")throw new TypeError("Grouped XLSX needs a leading label column.");const S=E(r.labelColumn,["header","width","wrapText","alignment"]);if(typeof S.header!="string")throw new TypeError("The leading label column needs a string header.");for(const y of[r.subtotalLabel,r.grandTotalLabel])if(typeof y!="function")throw new TypeError("Grouped summary labels must be functions.");for(const y of[r.includeGrandTotal,r.collapseGroups])if(y!==void 0&&typeof y!="boolean")throw new TypeError("Grouped XLSX flags must be booleans.");for(const y of f)if(w[y]!==void 0)throw new TypeError("Grouped XLSX owns worksheet "+y+".");if(w.autoFilter!==void 0&&w.autoFilter!==!1)throw new TypeError("Grouped summary rows cannot use a native table or autofilter.");for(const y of[r.groupStyle,r.subtotalStyle,r.grandTotalStyle])y!==void 0&&g({alternatingRowStyle:y});for(const y of e.columns)if(Object.prototype.hasOwnProperty.call(e.totals,y.key)&&y.type!=="number")throw new TypeError("Editable grouped totals require explicitly numeric columns.");const x=o(e,r.conditionalFormats,t),p=i(e,r.dataValidation,s);return{...r,labelColumn:S,sheet:g(w),...x===void 0?{}:{conditionalFormats:x},...p===void 0?{}:{dataValidation:p},...r.groupStyle?{groupStyle:d(r.groupStyle)}:{},...r.subtotalStyle?{subtotalStyle:d(r.subtotalStyle)}:{},...r.grandTotalStyle?{grandTotalStyle:d(r.grandTotalStyle)}:{}}}return Object.freeze({groupedOptionFields:u,prepareGroupedSheet:a})})(),$e=(()=>{const{groupedReportOperation:T}=Ge,{checkAbort:E,withAbort:R}=ge,{withDestination:v}=Te,{captureFields:C}=be,{Workbook:g}=Ze,{FormulaCell:h}=_e,{columnName:d}=ke,{captureWorkbookLimits:u,workbookOptionFields:f}=Le,{retainDataRowRanges:m}=Ve,{groupedOptionFields:o,prepareGroupedSheet:i}=Ct,a={average:1,count:2,max:4,min:5,sum:9};function l(p){if(typeof p?.then=="function"&&Promise.resolve(p).catch(()=>{}),typeof p!="string")throw new TypeError("Grouped summary labels must return strings.");return p}function e(p,y,I,j,M){const A=y+I+":"+y+j,_="SUBTOTAL("+a[p]+","+A+")";return new h(p==="average"||p==="min"||p==="max"?"IF(SUBTOTAL(2,"+A+')=0,"",'+_+")":_,M,p==="count"?0:void 0)}async function n(p,y,I,j,M){E(j.signal);const{labelColumn:A,subtotalLabel:_,grandTotalLabel:F,includeGrandTotal:D,collapseGroups:q,sheet:H,groupStyle:te,subtotalStyle:ee,grandTotalStyle:he,conditionalFormats:se,dataValidation:de}=I;let le=0,Y;const U=[],re=[],K=[];let fe=0,k=0,z,L;const{name:X="Data",...Z}=H??{},Q=[{...A,type:"string"},...y.columns],oe={groupStart:te??{font:{bold:!0}},groupEnd:ee??{font:{bold:!0}},complete:he??{font:{bold:!0}}},P=p.addWorksheet(X,{boldHeader:!0,autoSize:{minWidth:6,maxWidth:54},...Z,columns:Q,...se===void 0?{}:{conditionalFormats:se},...de===void 0?{}:{dataValidation:de},maxOutlineLevel:y.groupBy.length,rowStyle:()=>Y&&Y.kind!=="row"?oe[Y.kind]:void 0,rowOutline:()=>{if(!Y||Y.kind==="complete")return;const c=Y.kind==="row"?Y.path.length:Y.level;return{level:c,hidden:!!q&&c>0,collapsed:!!q&&Y.kind==="groupEnd"}}});m(P,K);const ue=y.columns.map(c=>Object.prototype.hasOwnProperty.call(y.totals,c.key)?y.totals[c.key]:void 0);async function*ye(){for await(const c of j.events){Y=c;const b=P.rowCount+P.headerRowCount+1;if(c.kind==="groupStart"){const O={groupIndex:c.groupIndex,level:c.level,key:c.key,label:c.label,path:c.path,rows:0,totals:Object.freeze([]),startRow:b,firstDetailRow:0,lastDetailRow:0,summaryRow:0};U.push(O),re.push(O),yield[c.label,...y.columns.map(()=>null)]}else if(c.kind==="row"){le++,M?.(le),fe||=b,k=b;const O=K.at(-1);O&&O.lastRow+1===b?O.lastRow=b:K.push({firstRow:b,lastRow:b});for(const N of re)N.firstDetailRow||=b,N.lastDetailRow=b;yield[null,...c.values]}else if(c.kind==="groupEnd"){const O=re.pop();O.summaryRow=b,O.rows=c.rows,O.totals=c.totals,yield[l(_(c)),...ue.map((N,B)=>N?e(N,d(B+2),O.firstDetailRow,O.lastDetailRow,c.totals[B]):null)]}else L=Object.freeze({rows:c.rows,groups:c.groups,totals:c.totals}),D!==!1&&(z=b,yield[l(F(c)),...ue.map((O,N)=>O?fe?e(O,d(N+2),fe,k,c.totals[N]):c.totals[N]:null)])}}try{return E(j.signal),await R(P.addRows(ye()),j.signal),await R(P.close(),j.signal),Object.freeze({worksheet:P,rows:le,columns:Q.length,detailRanges:Object.freeze(K.map(c=>Object.freeze({...c}))),groups:Object.freeze(U.map(c=>Object.freeze({...c}))),grandSummary:L,...z===void 0?{}:{grandTotalRow:z}})}catch(c){throw await p.discard(c),c}}async function t(p,y,I){const j=i(y,I,p.settings.limits?.maxConditionalFormats??1e3,p.availableDataValidations),M=T(y,p.settings.signal);try{return await n(p,y,j,M)}finally{M.dispose()}}function s(p,y){if(!y||typeof y!="object")throw new TypeError("Grouped XLSX options require host-authored labels.");const I=C(y,[...f,...o]);if(I.sink!==void 0||I.cellValueWriters!==void 0)throw new TypeError("Grouped XLSX owns its destination and uses already resolved source values.");const j=I.limits===void 0?void 0:u(I.limits);return{...I,...j===void 0?{}:{limits:j},...i(p,I,j?.maxConditionalFormats??1e3,j?.maxDataValidations??1e3)}}async function r(p,y,I){const{labelColumn:j,subtotalLabel:M,grandTotalLabel:A,includeGrandTotal:_,collapseGroups:F,sheet:D,groupStyle:q,subtotalStyle:H,grandTotalStyle:te,conditionalFormats:ee,dataValidation:he,onProgress:se,...de}=y,le=T(p,de.signal);let Y=0,U;const re=se?K=>se({...K,rows:Y,...K.sheetRows===void 0?{}:{sheetRows:Y}}):void 0;try{U=new g({...de,...le.signal?{signal:le.signal}:{},...re?{onProgress:re}:{},...I?{sink:I}:{}});const K=await n(U,p,y,le,k=>{Y=k});if(I){const k=await U.finish();return{result:{rows:Y,columns:K.columns,bytes:k.bytes}}}const fe=await U.toBlob();return{blob:fe,result:{rows:Y,columns:K.columns,bytes:fe.size}}}catch(K){throw await U?.discard(K),K}finally{le.dispose()}}async function w(p,y){return(await r(p,s(p,y))).blob}async function S(p,y,I){const j=s(p,I);return v(y,async M=>(await r(p,j,M)).result)}return Object.freeze({addGroupedXlsx:t,writeGroupedXlsx:w,writeGroupedXlsxTo:S})})(),Tt=(()=>{const{OfficeIMOError:T}=ce;function E(){let C=!1;if(typeof CompressionStream=="function")try{new CompressionStream("deflate-raw"),C=!0}catch{}return{blob:typeof Blob=="function",streams:typeof WritableStream=="function",deflateRaw:C,download:typeof document<"u"&&typeof URL.createObjectURL=="function"}}function R(C,g){if(!(C instanceof Blob)||typeof g!="string"||!g)throw new TypeError("A Blob and file name are required.");if(typeof document>"u"||typeof URL.createObjectURL!="function")throw new T("PLATFORM_UNAVAILABLE","saveBlob requires a browser document and object URLs.");const h=URL.createObjectURL(C),d=document.createElement("a");try{d.href=h,d.download=g,document.body.append(d),d.click()}finally{d.remove(),setTimeout(()=>URL.revokeObjectURL(h),3e4)}}return Object.freeze({OfficeIMOError:ce.OfficeIMOError,NotSupportedError:ce.NotSupportedError,BlobByteSink:Te.BlobByteSink,ChunkedTextSink:Te.ChunkedTextSink,writeBytes:Te.writeBytes,ExportCell:xe.ExportCell,createGroupedReport:Ge.createGroupedReport,checkAbort:ge.checkAbort,withAbort:ge.withAbort,inputRows:ge.inputRows,pause:ge.pause,detectFeatures:E,saveBlob:R})})(),kt=Object.freeze({Workbook:Ze.Workbook,writeXlsx:ht.writeXlsx,writeXlsxTo:ht.writeXlsxTo,writeGroupedXlsx:$e.writeGroupedXlsx,writeGroupedXlsxTo:$e.writeGroupedXlsxTo,addGroupedXlsx:$e.addGroupedXlsx,createGroupedReport:Ge.createGroupedReport,Worksheet:lt.Worksheet,Cell:ke.Cell,FormulaCell:_e.FormulaCell,StyleRegistry:Fe.StyleRegistry,NumberFormats:Fe.NumberFormats,saveBlob:Tt.saveBlob,ExportCell:xe.ExportCell}),{Workbook:Et,writeXlsx:Rt,writeXlsxTo:vt,writeGroupedXlsx:St,writeGroupedXlsxTo:Ot,addGroupedXlsx:At,createGroupedReport:It,Worksheet:Ft,Cell:jt,FormulaCell:_t,StyleRegistry:zt,NumberFormats:Pt,saveBlob:Lt,ExportCell:Dt}=kt;export{jt as Cell,Dt as ExportCell,_t as FormulaCell,Pt as NumberFormats,zt as StyleRegistry,Et as Workbook,Ft as Worksheet,At as addGroupedXlsx,It as createGroupedReport,Lt as saveBlob,St as writeGroupedXlsx,Ot as writeGroupedXlsxTo,Rt as writeXlsx,vt as writeXlsxTo};
2
+ const ye=(()=>{function C(a){if(a?.aborted)throw a.reason}function E(a,m){return m?new Promise((s,n)=>{const t=()=>m.removeEventListener("abort",r),r=()=>{t(),n(m.reason)};m.addEventListener("abort",r,{once:!0}),Promise.resolve(a).then(e=>{t(),s(e)},e=>{t(),n(e)}),m.aborted&&r()}):Promise.resolve(a)}async function*v(a,m){C(m);const s=a?.[Symbol.asyncIterator]?.()??a?.[Symbol.iterator]?.();if(!s)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let n=!1,t=!1;try{for(;;){C(m);const r=await E(Promise.resolve(s.next()),m);if(C(m),r.done){n=!0;return}yield r.value}}catch(r){throw t=!0,r}finally{if(!n&&s.return)try{const r=s.return();m?.aborted||t?Promise.resolve(r).catch(()=>{}):await E(Promise.resolve(r),m)}catch(r){if(!m?.aborted&&!t)throw r}}}const S=new WeakMap;function T(a){let m=!1;const s=()=>{if(m)throw new TypeError("A row source can be consumed only once.");m=!0},n={[Symbol.asyncIterator](){return s(),t()}};async function*t(){for await(const r of v(a))yield*r}return S.set(n,(r,e)=>(s(),c(a,r,p=>c(p,r,e)))),n}function g(...a){const m={async*[Symbol.asyncIterator](){for(const s of a)yield*s}};return S.set(m,async(s,n)=>{for(const t of a)await c(t,s,n)}),m}async function c(a,m,s){C(m);const n=S.get(a);if(n)return n(m,s);const t=a?.[Symbol.asyncIterator]?.()??a?.[Symbol.iterator]?.();if(!t)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let r=!1;try{for(;;){C(m);let e=t.next();const p=e;typeof p?.then=="function"&&(e=await E(p,m)),C(m);const k=e;if(k.done){r=!0;return}let y=k.value;typeof y?.then=="function"&&(y=await E(y,m)),C(m);const w=s(y);w!==void 0&&await E(w,m)}}finally{if(!r&&t.return)try{Promise.resolve(t.return()).catch(()=>{})}catch{}}}let d;const h=32;function u(){d=performance.now()+h}function f(){const a=performance.now();return d??=a+h,a>=d}function o(){const a=globalThis.scheduler;return typeof a?.postTask=="function"?a.postTask(()=>{d=performance.now()+h},{priority:"user-visible"}):new Promise(m=>{setTimeout(function(){d=performance.now()+h,m()},0)})}return Object.freeze({checkAbort:C,withAbort:E,inputRows:v,rowsFromBatches:T,concatRows:g,consumeRows:c,beginTask:u,taskYieldDue:f,pause:o})})(),he=(()=>{const C=Symbol.for("@evotecit/officeimo/OfficeIMOError"),E=Symbol.for("@evotecit/officeimo/NotSupportedError");class v extends Error{code;static[Symbol.hasInstance](c){return this!==v?Function.prototype[Symbol.hasInstance].call(this,c):!!c&&typeof c=="object"&&c[C]===!0}constructor(c,d,h){super(d,h),this.code=c,Object.defineProperty(this,C,{value:!0}),this.name="OfficeIMOError"}}class S extends v{feature;static[Symbol.hasInstance](c){return this!==S?Function.prototype[Symbol.hasInstance].call(this,c):!!c&&typeof c=="object"&&c[E]===!0}constructor(c){super("NOT_SUPPORTED",c+" is not supported yet."),this.feature=c,Object.defineProperty(this,E,{value:!0}),this.name="NotSupportedError"}}return Object.freeze({OfficeIMOError:v,NotSupportedError:S})})(),Qe=(()=>{function C(v,S){if(!v)return;const T=v(S);if(T&&typeof T.then=="function")throw Promise.resolve(T).catch(()=>{}),new TypeError("onProgress must be synchronous.")}return Object.freeze({notifyProgress:C})})(),Ce=(()=>{const{checkAbort:C,consumeRows:E,withAbort:v,pause:S,taskYieldDue:T}=ye,{OfficeIMOError:g}=he;async function c(o,i){if(o&&typeof o.getWriter=="function"){const a=o.getWriter();try{return await i({write:m=>a.write(new Uint8Array(m))})}finally{a.releaseLock()}}if(!o||typeof o.write!="function")throw new TypeError("Destination must be a ByteSink or WritableStream.");return i(o)}class d{parts=[];state="open";result;write(i){if(this.state!=="open")throw new g("INVALID_STATE","Byte sink is closed.");this.parts.push(new Uint8Array(i))}toBlob(i="application/octet-stream"){if(this.state==="discarded")throw new g("INVALID_STATE","Byte sink was discarded.");return this.state="closed",this.result||(this.result=new Blob(this.parts,{type:i}),this.parts=[]),this.result.type===i?this.result:new Blob([this.result],{type:i})}takeChunks(){if(this.state!=="open")throw new g("INVALID_STATE","Byte sink is closed.");const i=this.parts;return this.parts=[],this.state="discarded",i}discard(){this.parts=[],this.result=void 0,this.state="discarded"}}class h{sink;signal;chunkSize;text="";encoder=new TextEncoder;constructor(i,a,m=32768){if(this.sink=i,this.signal=a,this.chunkSize=m,!Number.isInteger(m)||m<2)throw new RangeError("Text chunk size must be at least 2.")}append(i){return C(this.signal),this.text+=i,this.text.length>=this.chunkSize||T()}async flush(i=!1){for(C(this.signal);this.text.length;){let a=Math.min(this.text.length,this.chunkSize);if(/[\ud800-\udbff]/.test(this.text[a-1])&&(a<this.text.length||!i)&&a--,!a)break;const m=this.encoder.encode(this.text.slice(0,a));this.text=this.text.slice(a),await v(Promise.resolve(this.sink.write(m)),this.signal),T()&&await S(),C(this.signal)}}async write(i){this.append(i)&&await this.flush()}async close(){await this.flush(!0)}}async function u(o,i,a){await E(o instanceof Uint8Array?[o]:o,a,m=>{if(!(m instanceof Uint8Array))throw new TypeError("Byte sources must yield Uint8Array chunks.");const s=i.write(m);return T()?Promise.resolve(s).then(()=>(C(a),S())):s})}return Object.freeze({withDestination:c,BlobByteSink:d,ChunkedTextSink:h,writeBytes:u})})(),be=(()=>{function C(v,S){const T={...v};for(const g of S){if(Object.hasOwn(T,g))continue;const c=v[g];c!==void 0&&(T[g]=c)}return T}return Object.freeze({captureFields:C})})(),et=(()=>{const{OfficeIMOError:C}=he,{captureFields:E}=be;class v{cells=0;text=0;reservedCells=0;reservedText=0;limits;constructor(c={}){if(!c||typeof c!="object"||Array.isArray(c))throw new TypeError("Export limits must be an object.");const d=E(c,["maxRows","maxCells","maxTextCharacters","maxOutputBytes"]);for(const[h,u]of Object.entries(d))if(u!==void 0&&(!Number.isSafeInteger(u)||u<0))throw new RangeError(h+" must be a nonnegative safe integer.");this.limits=Object.freeze(d)}check(c,d){const h=this.limits[c];if(h!==void 0&&d>h)throw new C("RESOURCE_LIMIT",c+" exceeded ("+d+" > "+h+").")}row(c){this.check("maxRows",c)}reserve(c,d){this.check("maxCells",this.cells+this.reservedCells+c),this.check("maxTextCharacters",this.text+this.reservedText+d),this.reservedCells+=c,this.reservedText+=d}release(c,d){this.reservedCells-=c,this.reservedText-=d}cell(c,d){if(d!==void 0&&this.release(1,d),this.limits.maxCells===void 0&&this.limits.maxTextCharacters===void 0)return;this.check("maxCells",this.cells+this.reservedCells+1);const h=typeof c=="string"?c.length:0;this.check("maxTextCharacters",this.text+this.reservedText+h),this.cells++,this.text+=h}}function S(g,c){let d=0;return{write(h){return c.check("maxOutputBytes",d+h.length),d+=h.length,g.write(h)}}}return Object.freeze({ExportBudget:v,boundedSink:S})})(),Ne=(()=>{const{OfficeIMOError:C}=he;function E(g){const c=()=>new C("INVALID_PART_URI","Invalid OPC part URI: "+g);if(typeof g!="string"||!g.startsWith("/")||/[^A-Za-z0-9\-._~!$&'()*+,;=:@%/]/.test(g)||g.split("/").slice(1).some(d=>!d||d.endsWith(".")||/^\.+$/.test(d))||/%(?![\da-f]{2})/i.test(g))throw c();for(const d of g.matchAll(/%([\da-f]{2})/gi)){const h=String.fromCharCode(parseInt(d[1],16));if(/[A-Za-z0-9_.~\-/\\]/.test(h))throw c()}try{decodeURIComponent(g)}catch{throw c()}return g.replace(/%[\da-f]{2}/gi,d=>d.toUpperCase())}function v(g){if(g==="/")return"/_rels/.rels";const c=E(g),d=c.lastIndexOf("/");return c.slice(0,d+1)+"_rels/"+c.slice(d+1)+".rels"}function S(g,c){const d=E(c).slice(1).split("/"),h=g==="/"?[]:E(g).slice(1).split("/").slice(0,-1);for(;h.length&&h[0]===d[0];)h.shift(),d.shift();const u="../".repeat(h.length)+d.join("/");return u.split("/",1)[0].includes(":")?"./"+u:u}return Object.freeze({partUri:E,relationshipPartUri:v,relativePartTarget:S})})(),we=(()=>{const{OfficeIMOError:C}=he,{ChunkedTextSink:E}=Ce,v='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',S={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;","\r":"&#13;","\n":"&#10;"," ":"&#9;"};function T(f,o="strip"){if(o!=="strip"&&o!=="reject")throw new TypeError("Invalid XML character policy.");const i=String(f),a=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\ud800-\udfff\ufffe\uffff]/gu;if(o==="reject"&&a.test(i))throw new C("INVALID_XML","Text contains XML 1.0-invalid characters.");return i.replace(a,"")}function g(f,o="strip"){return T(f,o).replace(/[&<>"'\r\n\t]/g,i=>S[i])}function c(f,o="strip"){const i={"\r":"_x000D_","\n":"_x000A_"," ":"_x0009_"},a=T(f,o).replace(/_(?=x[0-9a-f]{4}_)|[\r\n\t]/gi,m=>m==="_"?"_x005F_":i[m]);return g(a,o)}function d(f){if(typeof f!="string"||!/^[A-Za-z_][A-Za-z0-9_.-]*(?::[A-Za-z_][A-Za-z0-9_.-]*)?$/.test(f))throw new C("INVALID_XML","Invalid XML name: "+f);return f}class h{policy;sink;stack=[];roots=0;closed=!1;constructor(o,i="strip",a){this.policy=i,T("",i),this.sink=new E(o,a),this.sink.append(v)}async startElement(o,i={}){this.open(),d(o);const a="<"+o+Object.entries(i).map(([m,s])=>" "+d(m)+'="'+g(s,this.policy)+'"').join("")+">";if(!this.stack.length&&this.roots++)throw new C("INVALID_XML","XML must have one root element.");this.stack.push(o),await this.sink.write(a)}async text(o){if(this.open(),!this.stack.length)throw new C("INVALID_XML","Text needs an open element.");await this.sink.write(g(o,this.policy))}async endElement(){this.open();const o=this.stack.pop();if(!o)throw new C("INVALID_XML","No open XML element.");await this.sink.write("</"+o+">")}async close(){if(this.open(),this.stack.length||this.roots!==1)throw new C("INVALID_XML","XML document is incomplete.");await this.sink.close(),this.closed=!0}open(){if(this.closed)throw new C("INVALID_STATE","XML writer is closed.")}}return Object.freeze({xmlDeclaration:v,cleanXml:T,escapeXml:g,escapeOoxmlAttribute:c,validateXmlName:d,XmlWriter:h})})(),Se=(()=>{function C(v){if(v===null||typeof v!="object")return!1;try{return!(v instanceof Date)&&!(Symbol.toStringTag in v)&&Object.prototype.toString.call(v)!=="[object Date]"?!1:(Date.prototype.getTime.call(v),!0)}catch{return!1}}return Object.freeze({isDate:C})})(),Ge=(()=>{const{escapeXml:C,xmlDeclaration:E}=we,{isDate:v}=Se;function S(c={},d="strip"){const h=c.created??new Date,u=c.modified??h;if(!v(h)||!v(u)||!Number.isFinite(h.getTime())||!Number.isFinite(u.getTime()))throw new TypeError("Invalid workbook property date.");return E+'<cp:coreProperties 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:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:creator>'+C(c.creator??"",d)+"</dc:creator><dc:title>"+C(c.title??"",d)+"</dc:title>"+(c.subject===void 0?"":"<dc:subject>"+C(c.subject,d)+"</dc:subject>")+(c.description===void 0?"":"<dc:description>"+C(c.description,d)+"</dc:description>")+'<dcterms:created xsi:type="dcterms:W3CDTF">'+h.toISOString()+'</dcterms:created><dcterms:modified xsi:type="dcterms:W3CDTF">'+u.toISOString()+"</dcterms:modified></cp:coreProperties>"}function T(c={},d="strip"){return E+'<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"><Application>'+C(c.application??"OfficeIMO",d)+"</Application><Company>"+C(c.company??"",d)+"</Company></Properties>"}return Object.freeze({corePropertiesXml:S,appPropertiesXml:T})})(),tt=(()=>{const C=new Uint32Array(256).map((S,T)=>{let g=T;for(let c=0;c<8;c++)g=g&1?3988292384^g>>>1:g>>>1;return g>>>0});class E{crc=4294967295;update(T){let g=this.crc;for(let c=0;c<T.length;c++)g=C[(g^T[c])&255]^g>>>8;this.crc=g}get value(){return(this.crc^4294967295)>>>0}}return Object.freeze({Crc32:E})})(),qe=(()=>{const{checkAbort:C,withAbort:E}=ye,{OfficeIMOError:v}=he,{Crc32:S}=tt,T=4294967295;function g(h){if(!Number.isSafeInteger(h)||h<0||h>=T)throw new v("ZIP64_REQUIRED","Classic ZIP entries and archives must stay below 4 GiB; ZIP64 is not supported yet.");return h}class c{sink;signal;method;writer;reader;drain;crc=new S;size=0;compressedSize=0;failed=!1;failure;closed=!1;cleaned=!1;lifetime=new AbortController;abort=()=>{this.fail(this.signal?.reason)};constructor(u,f,o){if(this.sink=f,this.signal=o,u!=="auto"&&u!=="store")throw new RangeError("compression must be auto or store.");C(o);let i;if(u==="auto"&&typeof CompressionStream=="function")try{i=new CompressionStream("deflate-raw")}catch(a){if(!(a instanceof TypeError))throw a}this.method=i?8:0,this.writer=i?.writable.getWriter(),this.reader=i?.readable.getReader(),o?.addEventListener("abort",this.abort,{once:!0}),this.drain=this.reader?this.consume(this.reader):Promise.resolve()}async consume(u){try{for(;;){const{value:f,done:o}=await E(u.read(),this.lifetime.signal);if(o)return;C(this.signal),this.compressedSize=g(this.compressedSize+f.length),await E(Promise.resolve(this.sink.write(f)),this.lifetime.signal)}}catch(f){this.fail(f)}}fail(u){this.failed||(this.failed=!0,this.failure=u,this.lifetime.abort(u),this.cleaned||(this.writer?.abort(u).catch(()=>{}),this.reader?.cancel(u).catch(()=>{})))}async write(u){if(C(this.signal),this.failed)throw this.failure;if(this.closed)throw new v("INVALID_STATE","ZIP entry is closed.");if(!(u instanceof Uint8Array))throw new TypeError("ZIP chunks must be Uint8Array.");this.size=g(this.size+u.length),this.crc.update(u),this.writer?await E(this.writer.write(new Uint8Array(u)),this.lifetime.signal):(await E(Promise.resolve(this.sink.write(u)),this.lifetime.signal),this.compressedSize=this.size)}async close(){try{if(C(this.signal),this.failed)throw this.failure;if(this.closed)throw new v("INVALID_STATE","ZIP entry is closed.");if(this.closed=!0,this.writer&&await E(this.writer.close(),this.lifetime.signal),await this.drain,this.failed)throw this.failure;return C(this.signal),{crc:this.crc.value,size:this.size,compressedSize:this.compressedSize,method:this.method}}finally{this.cleanup()}}async discard(u){this.fail(u),await this.drain,this.closed=!0,this.cleanup()}cleanup(){this.cleaned||(this.cleaned=!0,this.signal?.removeEventListener("abort",this.abort),this.writer?.releaseLock(),this.reader?.releaseLock())}}return Object.freeze({Crc32:tt.Crc32,zipLimit:T,zipSize:g,EntryWriter:c})})(),ut=(()=>{const{EntryWriter:C,zipSize:E}=qe,{checkAbort:v,withAbort:S,pause:T,taskYieldDue:g}=ye,{OfficeIMOError:c}=he,{BlobByteSink:d,writeBytes:h}=Ce,{captureFields:u}=be,f=new TextEncoder;function o(s){if(typeof s!="string"||!s||/[\u0000-\u001f\\]/.test(s)||s.startsWith("/")||/^[A-Za-z]:/.test(s)||s.split("/").some(n=>!n||n==="."||n===".."))throw new TypeError("ZIP entry names must be relative paths without empty, dot or parent segments.");for(let n=0;n<s.length;n++){const t=s.charCodeAt(n);if(t>=55296&&t<=56319){const r=s.charCodeAt(++n);if(!(r>=56320&&r<=57343))throw new TypeError("ZIP entry names must contain well-formed Unicode.")}else if(t>=56320&&t<=57343)throw new TypeError("ZIP entry names must contain well-formed Unicode.")}if(f.encode(s).length>65535)throw new RangeError("ZIP entry name exceeds 65,535 UTF-8 bytes.");return s}function i(s,n,t=new Uint8Array){const r=new Uint8Array(n+t.length),e=new DataView(r.buffer);return e.setUint32(0,s,!0),r.set(t,n),{bytes:r,data:e}}class a{sink;owned;names=new Set;central=[];offset=0;active;state="open";options;lifetime=new AbortController;disposal;constructor(n,t={}){const r=u(t,["compression","signal","maxOutputBytes"]),{compression:e,maxOutputBytes:p}=r;if(p!==void 0&&(!Number.isSafeInteger(p)||p<0))throw new RangeError("maxOutputBytes must be a nonnegative safe integer.");if(e!==void 0&&e!=="auto"&&e!=="store")throw new RangeError("compression must be auto or store.");this.options=Object.freeze(r),this.owned=n?void 0:new d,this.sink=n??this.owned}async acceptance(n){const t=this.options.signal,r=()=>this.lifetime.abort(t?.reason);t?.addEventListener("abort",r,{once:!0});try{return v(t),v(this.lifetime.signal),await S(Promise.resolve(n()),this.lifetime.signal)}finally{t?.removeEventListener("abort",r)}}async emit(n){if(this.options.maxOutputBytes!==void 0&&this.offset+n.length>this.options.maxOutputBytes)throw new c("RESOURCE_LIMIT","maxOutputBytes exceeded.");this.offset=E(this.offset+n.length),await this.acceptance(()=>this.sink.write(n))}reserve(n){if(v(this.options.signal),this.state!=="open")throw new c("INVALID_STATE","ZIP writer is busy, failed or finalized.");if(o(n),this.names.has(n))throw new TypeError("Duplicate ZIP entry: "+n);if(this.names.size>=65534)throw new c("ZIP64_REQUIRED","ZIP64 is required for 65,535 entries.");return this.names.add(n),this.state="writing",f.encode(n)}local(n,t,r){const e=i(67324752,30,n);return e.data.setUint16(4,20,!0),e.data.setUint16(6,r?2056:2048,!0),e.data.setUint16(8,t.method,!0),e.data.setUint16(12,33,!0),e.data.setUint16(26,n.length,!0),e.bytes}record(n,t,r,e){const p=i(33639248,46,n);p.data.setUint16(4,20,!0),p.data.setUint16(6,20,!0),p.data.setUint16(8,e?2056:2048,!0),p.data.setUint16(10,t.method,!0),p.data.setUint16(14,33,!0),p.data.setUint32(16,t.crc,!0),p.data.setUint32(20,t.compressedSize,!0),p.data.setUint32(24,t.size,!0),p.data.setUint16(28,n.length,!0),p.data.setUint32(42,r,!0),this.central.push(p.bytes)}async openEntry(n){const t=this.reserve(n),r=this.offset;let e;try{e=new C(this.options.compression??"auto",{write:I=>this.emit(I)},this.options.signal),await this.emit(this.local(t,e,!0));const p=e;let k=!1,y=!1,w;const b=async I=>{y=!0,this.state="failed",this.lifetime.abort(I),await p.discard(I),this.owned?.discard(),this.active=void 0};return this.active={write:async I=>{if(k||y||this.state!=="writing")throw new c("INVALID_STATE","Await the current ZIP entry operation.");k=!0;try{await p.write(I)}catch(F){throw await b(F),F}finally{k=!1}},close:()=>{if(w)return w;if(k||y||this.state!=="writing")throw new c("INVALID_STATE","ZIP entry is busy or closed.");return y=!0,w=(async()=>{try{const I=await p.close(),F=i(134695760,16);return F.data.setUint32(4,I.crc,!0),F.data.setUint32(8,I.compressedSize,!0),F.data.setUint32(12,I.size,!0),await this.emit(F.bytes),this.record(t,I,r,!0),this.state="open",this.active=void 0,I}catch(I){throw await b(I),I}})(),w},discard:b}}catch(p){throw this.state="failed",await e?.discard(p),this.owned?.discard(),p}}async add(n,t){const r=await this.openEntry(n);try{typeof t=="function"?await this.acceptance(()=>t(r)):await this.acceptance(()=>h(t,r,this.lifetime.signal)),await r.close()}catch(e){throw await r.discard(e),e}}get bytesWritten(){return this.offset}discard(n){return this.state="failed",this.lifetime.abort(n),this.disposal??=(async()=>{await this.active?.discard(n),this.owned?.discard()})()}async addPrepared(n,t){const r=this.reserve(n),e=this.offset;try{const p=this.local(r,t,!1),k=new DataView(p.buffer);k.setUint32(14,t.crc,!0),k.setUint32(18,t.compressedSize,!0),k.setUint32(22,t.size,!0),await this.emit(p);for(const y of t.chunks)v(this.options.signal),await this.emit(y);this.record(r,t,e,!1),this.state="open"}catch(p){throw this.state="failed",this.owned?.discard(),p}}async finish(){if(v(this.options.signal),this.state!=="open")throw new c("INVALID_STATE","ZIP writer is busy, failed or finalized.");this.state="writing";const n=this.offset;try{for(let r=0;r<this.central.length;r++)await this.emit(this.central[r]),r%256===255&&g()&&await T();const t=i(101010256,22);t.data.setUint16(8,this.central.length,!0),t.data.setUint16(10,this.central.length,!0),t.data.setUint32(12,this.offset-n,!0),t.data.setUint32(16,n,!0),await this.emit(t.bytes),v(this.options.signal),this.state="finished"}catch(t){throw this.state="failed",this.owned?.discard(),t}}async toBlob(n="application/zip"){if(!this.owned)throw new c("INVALID_STATE","This ZIP uses a caller-owned sink; use finish().");return this.state!=="finished"&&await this.finish(),this.owned.toBlob(n)}}return Object.freeze({Crc32:qe.Crc32,validateEntryName:o,ZipWriter:a})})(),Me=(()=>{const{partUri:C,relationshipPartUri:E,relativePartTarget:v}=Ne,{corePropertiesXml:S,appPropertiesXml:T}=Ge,{ZipWriter:g}=ut,{ChunkedTextSink:c}=Ce,{OfficeIMOError:d}=he,{escapeXml:h,xmlDeclaration:u}=we,{checkAbort:f,pause:o,taskYieldDue:i}=ye,{captureFields:a}=be,m="http://schemas.openxmlformats.org/package/2006/relationships",s="http://schemas.openxmlformats.org/officeDocument/2006/relationships",n="http://schemas.openxmlformats.org/package/2006/content-types",t={officeDocument:s+"/officeDocument",worksheet:s+"/worksheet",styles:s+"/styles",theme:s+"/theme",customXml:s+"/customXml",coreProperties:m+"/metadata/core-properties",appProperties:s+"/extended-properties"};function r(y){if(typeof y!="string"||!/^[\w!#$&^.+-]+\/[\w!#$&^.+-]+$/.test(y))throw new TypeError("Invalid content type.");return y}class e{defaults=new Map([["rels","application/vnd.openxmlformats-package.relationships+xml"],["xml","application/xml"]]);overrides=new Map;addDefault(w,b){if(!/^[A-Za-z0-9]+$/.test(w))throw new TypeError("Invalid part extension.");const I=w.toLowerCase(),F=this.defaults.get(I);if(F!==void 0&&F!==b)throw new TypeError("Conflicting default content type.");this.defaults.set(I,r(b))}addOverride(w,b){if(w=C(w),this.overrides.has(w.toLowerCase()))throw new TypeError("Duplicate content-type override.");this.overrides.set(w.toLowerCase(),{uri:w,type:r(b)})}toXml(){return u+'<Types xmlns="'+n+'">'+[...this.defaults].map(([w,b])=>'<Default Extension="'+h(w)+'" ContentType="'+h(b)+'"/>').join("")+[...this.overrides.values()].map(({uri:w,type:b})=>'<Override PartName="'+h(w)+'" ContentType="'+h(b)+'"/>').join("")+"</Types>"}}class p{types=new e;parts=new Map;directories=new Set;relationships=new Map;state="open";result;zip;options;constructor(w={}){this.options=Object.freeze(a(w,["compression","signal","maxOutputBytes","invalidCharacterPolicy","sink"])),this.zip=new g(this.options.sink,this.options)}open(){if(this.state!=="open")throw new d("INVALID_STATE","OPC package is finalized.")}reserve(w,b){if(this.open(),typeof w=="string"&&w.length>65536)throw new d("RESOURCE_LIMIT","OPC part name exceeds the ZIP entry-name limit.");w=C(w);let I=0;for(let A=0;A<w.length;A++)if(w[A]==="/"&&++I>64)throw new d("RESOURCE_LIMIT","OPC part name exceeds the directory-depth limit.");if(/\/_rels(?:\/|$)/i.test(w)||w.toLowerCase()==="/[content_types].xml")throw new TypeError("Package metadata part names are reserved.");const F=w.toLowerCase();if(this.parts.has(F))throw new TypeError("Duplicate OPC part: "+w);if(this.directories.has(F))throw new TypeError("OPC part-name prefix collision: "+w+" is an ancestor of an existing part.");const B=[];for(let A=F.lastIndexOf("/");A>0;A=F.lastIndexOf("/",A-1)){const z=F.slice(0,A);if(this.parts.has(z))throw new TypeError("OPC part-name prefix collision: "+w+" descends from "+this.parts.get(z).uri);B.push(z)}this.types.addOverride(w,b);for(const A of B)this.directories.add(A);return w}addPart(w){const{uri:b,contentType:I,data:F}=w,B=F instanceof Uint8Array?new Uint8Array(F):F,A=this.reserve(b,I);this.parts.set(A.toLowerCase(),{uri:A,contentType:I,data:B})}addPrepared(w,b,I){w=this.reserve(w,b),this.parts.set(w.toLowerCase(),{uri:w,prepared:I})}async openPart(w,b){if(!this.options.sink)throw new d("INVALID_STATE","openPart requires a caller-owned package sink.");w=this.reserve(w,b),this.parts.set(w.toLowerCase(),{uri:w,written:!0});try{return await this.zip.openEntry(w.slice(1))}catch(I){throw await this.discard(I),I}}addRelationship(w,b){f(this.options.signal),this.open(),w=w==="/"?w:C(w);const{id:I,type:F,target:B,external:A}=b;if(this.open(),!/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(I))throw new TypeError("Relationship id must be an XML ID.");if(!/^[A-Za-z][A-Za-z0-9+.-]*:[^\s<>"']+$/.test(F))throw new TypeError("Relationship type must be an absolute URI.");const z=A?B:C(B);if(A&&(!z||/[\u0000-\u0020]/.test(z)))throw new TypeError("Invalid external relationship target.");const j=w.toLowerCase(),P=this.relationships.get(j)??new Map;if(P.has(I))throw new TypeError("Duplicate relationship id: "+I);P.set(I,{id:I,type:F,target:z,...A===void 0?{}:{external:A}}),this.relationships.set(j,P)}setProperties(w={},b={}){const I=S(w,this.options.invalidCharacterPolicy),F=T(b,this.options.invalidCharacterPolicy);this.addPart({uri:"/docProps/core.xml",contentType:"application/vnd.openxmlformats-package.core-properties+xml",data:I}),this.addPart({uri:"/docProps/app.xml",contentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml",data:F}),this.addRelationship("/",{id:"core",type:t.coreProperties,target:"/docProps/core.xml"}),this.addRelationship("/",{id:"app",type:t.appProperties,target:"/docProps/app.xml"})}source(w){return typeof w=="string"?async b=>{const I=new c(b,this.options.signal);await I.write(w),await I.close()}:w instanceof Blob?(async function*(){for(let b=0;b<w.size;b+=65536){let I;try{I=await w.slice(b,b+65536).arrayBuffer()}catch(F){throw F?.name!=="NotReadableError"?F:new d("PLATFORM_UNAVAILABLE","This environment cannot read Blob part data. Supply text or byte chunks; read Blobs before sending data to a worker.",{cause:F})}yield new Uint8Array(I)}})():w}finish(){return this.result?this.result:(this.open(),this.state="finalizing",this.result=(async()=>{const w=this.zip;try{for(const[b,I]of this.relationships){if(b!=="/"&&!this.parts.has(b))throw new TypeError("Missing relationship source part: "+b);let F=0;for(const B of I.values()){if(f(this.options.signal),!B.external&&!this.parts.has(B.target.toLowerCase()))throw new TypeError("Missing relationship target: "+B.target);(++F&255)===0&&i()&&(await o(),f(this.options.signal))}}for(const b of this.parts.values())"written"in b||("prepared"in b?await w.addPrepared(b.uri.slice(1),b.prepared):await w.add(b.uri.slice(1),this.source(b.data)));for(const[b,I]of this.relationships){const F=b==="/"?"/":this.parts.get(b).uri;await w.add(E(F).slice(1),async B=>{const A=new c(B,this.options.signal);await A.write(u+'<Relationships xmlns="'+m+'">');for(const z of I.values()){const j='<Relationship Id="'+h(z.id)+'" Type="'+h(z.type)+'" Target="'+h(z.external?z.target:v(F,z.target))+'"'+(z.external?' TargetMode="External"':"")+"/>";A.append(j)&&await A.flush()}await A.write("</Relationships>"),await A.close()})}return await w.add("[Content_Types].xml",this.source(this.types.toXml())),await w.finish(),this.state="complete",w.bytesWritten}catch(b){throw await this.discard(b),b}finally{this.parts.clear(),this.directories.clear(),this.relationships.clear()}})(),this.result)}async toBlob(w="application/zip"){if(this.options.sink)throw new d("INVALID_STATE","This package uses a caller-owned sink; use finish().");return await this.finish(),this.zip.toBlob(w)}async discard(w){this.state="failed",this.parts.clear(),this.directories.clear(),this.relationships.clear(),await this.zip.discard(w)}}return Object.freeze({partUri:Ne.partUri,relationshipPartUri:Ne.relationshipPartUri,relativePartTarget:Ne.relativePartTarget,corePropertiesXml:Ge.corePropertiesXml,appPropertiesXml:Ge.appPropertiesXml,relationshipsNamespace:m,officeRelationshipsNamespace:s,contentTypesNamespace:n,relationshipTypes:t,ContentTypes:e,OpcPackage:p})})(),Be=(()=>{function C(v){if(typeof v!="string"||!/^#?(?:[0-9a-f]{6}|[0-9a-f]{8})$/i.test(v))throw new TypeError("Color must be RGB or ARGB hex.");const S=v.replace(/^#/,"").toUpperCase();return S.length===6?"FF"+S:S}return Object.freeze({colorArgb:C})})(),Ue=(()=>{const{OfficeIMOError:C}=he,{cleanXml:E,escapeOoxmlAttribute:v}=we,{colorArgb:S}=Be;function T(u,f,o){if(!u||typeof u!="object"||Array.isArray(u))throw new TypeError(o+" must be an object.");if(typeof u.then=="function")throw Promise.resolve(u).catch(()=>{}),new TypeError(o+" must be synchronous.");for(const i of Object.keys(u))if(!f.includes(i))throw new TypeError("Unsupported "+o+" property: "+i)}function g(u,f){if(u!==void 0&&typeof u!="boolean")throw new TypeError(f+" must be boolean.")}class c{policy;maximum;numberFormat;definitions=new Map;constructor(f,o,i){this.policy=f,this.maximum=o,this.numberFormat=i}keys(f){const o=f.map(a=>d(a,this.policy,()=>164)),i=new Set(o.filter(a=>!this.definitions.has(a)));if(this.definitions.size+i.size>this.maximum)throw new C("RESOURCE_LIMIT","maxDifferentialStyles exceeded.");return o}check(f){this.keys(f)}add(f){const o=this.keys(f);for(let i=0;i<f.length;i++)this.definitions.has(o[i])||this.definitions.set(o[i],{id:this.definitions.size,xml:d(f[i],this.policy,this.numberFormat)});return o.map(i=>this.definitions.get(i).id)}toXml(){return this.definitions.size?'<dxfs count="'+this.definitions.size+'">'+[...this.definitions.values()].map(f=>"<dxf>"+f.xml+"</dxf>").join("")+"</dxfs>":""}}function d(u,f,o){T(u,["font","fill","border","numberFormat"],"conditional style");let i="";if(u.font!==void 0){T(u.font,["bold","italic","underline","strike","color"],"conditional font");let a="";for(const[m,s]of[["bold","b"],["italic","i"],["strike","strike"]])g(u.font[m],m),u.font[m]!==void 0&&(a+="<"+s+' val="'+(u.font[m]?1:0)+'"/>');g(u.font.underline,"underline"),u.font.underline!==void 0&&(a+='<u val="'+(u.font.underline?"single":"none")+'"/>'),u.font.color!==void 0&&(a+='<color rgb="'+S(u.font.color)+'"/>'),a&&(i+="<font>"+a+"</font>")}if(u.numberFormat!==void 0){const a=u.numberFormat;if(typeof a!="string"||!a||a.length>255||!E(a,f))throw new TypeError("Conditional number format requires 1 through 255 XML-valid characters.");i+='<numFmt numFmtId="'+o(a)+'" formatCode="'+v(a,f)+'"/>'}if(u.fill!==void 0){T(u.fill,["color"],"conditional fill");const a=S(u.fill.color);i+='<fill><patternFill patternType="solid"><fgColor rgb="'+a+'"/><bgColor rgb="'+a+'"/></patternFill></fill>'}if(u.border!==void 0){T(u.border,["left","right","top","bottom"],"conditional border");let a="";for(const m of["left","right","top","bottom"]){const s=u.border[m];if(s!==void 0){if(T(s,["style","color"],"conditional border edge"),!["thin","medium","dashed","dotted","thick","double","hair","dashDot","dashDotDot","slantDashDot","mediumDashed","mediumDashDot","mediumDashDotDot"].includes(s.style))throw new TypeError("Invalid conditional border style.");a+="<"+m+' style="'+s.style+'">'+(s.color!==void 0?'<color rgb="'+S(s.color)+'"/>':"")+"</"+m+">"}}a&&(i+="<border>"+a+"</border>")}if(!i)throw new TypeError("A conditional style must change at least one property.");return i}return Object.freeze({fields:T,optionalBoolean:g,DifferentialStyles:c,differentialXml:d})})(),Fe=(()=>{const{escapeOoxmlAttribute:C,cleanXml:E,xmlDeclaration:v}=we,{OfficeIMOError:S}=he,{colorArgb:T}=Be,{DifferentialStyles:g}=Ue,c="http://schemas.openxmlformats.org/spreadsheetml/2006/main",d=["thin","medium","dashed","dotted","thick","double","hair","dashDot","dashDotDot","slantDashDot","mediumDashed","mediumDashDot","mediumDashDotDot"];function h(n){if(!n||typeof n!="object")throw new TypeError("A border must be an object of edges.");const t={};for(const r of["left","right","top","bottom"]){const e=n[r];if(e){const{style:p,color:k}=e;if(!d.includes(p))throw new TypeError("Invalid border style.");t[r]={style:p,...k?{color:T(k)}:{}}}}return t}const u={General:"General",Integer:"0",Decimal:"0.00",Percent:"0.00%",Date:"yyyy-mm-dd",DateTime:"yyyy-mm-dd hh:mm:ss"};function f(n,t,r){if(!Number.isInteger(n)||n<0||n>=t)throw new RangeError("Unknown "+r+" index.");return n}function o(n,t,r,e){const p=JSON.stringify(r),k=t.get(p);if(k!==void 0)return k;if(n.length>=e)throw new S("RESOURCE_LIMIT","Style component limit exceeded.");const y=n.length;return n.push(r),t.set(p,y),y}function i(n){if(!n||typeof n!="object"||Array.isArray(n))throw new TypeError("A style patch must be a CellStyle object.");if(typeof n.then=="function")throw Promise.resolve(n).catch(()=>{}),new TypeError("Style patches must be synchronous CellStyle objects.")}function a(n){return i(n),Object.freeze({...n,...typeof n.font=="object"?{font:Object.freeze({...n.font})}:{},...typeof n.fill=="object"?{fill:Object.freeze({...n.fill})}:{},...typeof n.border=="object"?{border:Object.freeze(Object.fromEntries(Object.entries(n.border).map(([t,r])=>[t,Object.freeze({...r})])))}:{}})}class m{policy;maximum;differential;fonts=[{name:"Calibri",size:11,bold:!1,italic:!1,underline:!1,strike:!1,color:""}];fills=[{pattern:"none",color:""},{pattern:"gray125",color:""}];borders=[{}];formats=new Map;styles=[];indexes=new Map;fontIndexes=new Map(this.fonts.map((t,r)=>[JSON.stringify(t),r]));fillIndexes=new Map(this.fills.map((t,r)=>[JSON.stringify(t),r]));borderIndexes=new Map(this.borders.map((t,r)=>[JSON.stringify(t),r]));constructor(t="strip",r=64e3,e=1e3){if(this.policy=t,this.maximum=r,!Number.isSafeInteger(r)||r<1||r>64e3)throw new RangeError("maxStyles must be from 1 through 64,000.");if(!Number.isSafeInteger(e)||e<0)throw new RangeError("maxDifferentialStyles must be a nonnegative safe integer.");this.differential=new g(t,e,p=>this.addNumberFormat(p)),E("",t),this.add()}checkDifferentials(t){const r=new Set(t.flatMap(e=>e.numberFormat===void 0?[]:[E(e.numberFormat,this.policy)]).filter(e=>e!=="General"&&!this.formats.has(e)));if(this.formats.size+r.size>65372)throw new RangeError("Too many number formats.");this.differential.check(t)}addDifferentials(t){return this.checkDifferentials(t),this.differential.add(t)}addFont(t){const{name:r,size:e,bold:p,italic:k,underline:y,strike:w,color:b}=t;if(r!==void 0&&typeof r!="string")throw new TypeError("Font name must be a string.");const I=E(r??"Calibri",this.policy),F=e??11;if(typeof I!="string"||!I||I.length>31)throw new TypeError("Font name must contain 1 through 31 characters.");if(!Number.isFinite(F)||F<=0||F>409)throw new RangeError("Font size must be positive and at most 409.");return o(this.fonts,this.fontIndexes,{name:I,size:F,bold:!!p,italic:!!k,underline:!!y,strike:!!w,color:b?T(b):""},this.maximum)}addFill(t){const{color:r}=t,e=t.pattern??(r?"solid":"none");if(!["none","gray125","solid"].includes(e)||e==="solid"&&!r||e!=="solid"&&r)throw new TypeError("A solid fill requires a color; none and gray125 have no color.");return o(this.fills,this.fillIndexes,{pattern:e,color:r?T(r):""},this.maximum+1)}addBorder(t){return o(this.borders,this.borderIndexes,h(t),this.maximum)}addNumberFormat(t){if(typeof t!="string"||!t||t.length>255)throw new TypeError("Number format must contain 1 through 255 characters.");if(t=E(t,this.policy),!t)throw new TypeError("Number format must contain XML-valid characters.");if(t==="General")return 0;let r=this.formats.get(t);if(r===void 0){if(this.formats.size>=65372)throw new RangeError("Too many number formats.");r=this.formats.size+164,this.formats.set(t,r)}return r}add(t={}){const r=typeof t.font=="number"?f(t.font,this.fonts.length,"font"):t.font?this.addFont(t.font):0,e=typeof t.fill=="number"?f(t.fill,this.fills.length,"fill"):t.fill?this.addFill(t.fill):0,p=typeof t.border=="number"?f(t.border,this.borders.length,"border"):t.border?this.addBorder(t.border):0;let k=0;if(typeof t.numberFormat=="string")k=this.addNumberFormat(t.numberFormat);else if(t.numberFormat!==void 0&&(k=t.numberFormat,!Number.isInteger(k)||k<0||k>163&&![...this.formats.values()].includes(k)))throw new RangeError("Unknown number format index.");if(t.alignment!==void 0&&!["left","center","right","fill","justify","distributed"].includes(t.alignment))throw new TypeError("Invalid horizontal alignment.");if(t.verticalAlignment!==void 0&&!["top","center","bottom","justify","distributed"].includes(t.verticalAlignment))throw new TypeError("Invalid vertical alignment.");const y={font:r,fill:e,border:p,numberFormat:k,wrapText:!!t.wrapText,alignment:t.alignment??"",verticalAlignment:t.verticalAlignment??""},w=JSON.stringify(y),b=this.indexes.get(w);if(b!==void 0)return b;if(this.styles.length>=this.maximum)throw new S("RESOURCE_LIMIT","Workbook exceeds its cell style limit.");const I=this.styles.length;return this.styles.push(y),this.indexes.set(w,I),I}validateStyle(t){return f(t,this.styles.length,"cell style")}compose(t,r){i(r);const e=this.styles[this.validateStyle(t)];return this.add({font:e.font,fill:e.fill,border:e.border,numberFormat:e.numberFormat,wrapText:e.wrapText,...e.alignment?{alignment:e.alignment}:{},...e.verticalAlignment?{verticalAlignment:e.verticalAlignment}:{},...r,...typeof r.font=="object"?{font:{...this.fonts[e.font],...r.font}}:{},...typeof r.border=="object"?{border:{...this.borders[e.border],...r.border}}:{}})}dateHeader(t,r){return this.compose(t,{numberFormat:this.styles[this.validateStyle(r)].numberFormat})}forColumn(t,r=!1,e,p=!1,k){const y=!r&&t.style!==void 0?this.styles[this.validateStyle(t.style)]:void 0,w=t.format!==void 0?t.format||u.General:y?.numberFormat||(t.type==="date"||p?u.DateTime:u.General);return this.add({...y?{font:y.font,fill:y.fill,border:y.border}:{},numberFormat:w,wrapText:t.wrapText??y?.wrapText??!1,...t.alignment?{alignment:t.alignment}:y?.alignment?{alignment:y.alignment}:{},...y?.verticalAlignment?{verticalAlignment:y.verticalAlignment}:{},...r?{font:{bold:!0}}:{},...e?{fill:{color:e}}:{},...k?{border:k}:{}})}toXml(){const t=e=>"<font>"+(e.bold?"<b/>":"")+(e.italic?"<i/>":"")+(e.underline?"<u/>":"")+(e.strike?"<strike/>":"")+'<sz val="'+e.size+'"/>'+(e.color?'<color rgb="'+e.color+'"/>':"")+'<name val="'+C(e.name,this.policy)+'"/></font>',r=e=>"<border>"+["left","right","top","bottom"].map(p=>{const k=e[p];return k?"<"+p+' style="'+k.style+'">'+(k.color?'<color rgb="'+k.color+'"/>':"")+"</"+p+">":"<"+p+"/>"}).join("")+"<diagonal/></border>";return v+'<styleSheet xmlns="'+c+'"><numFmts count="'+this.formats.size+'">'+[...this.formats].map(([e,p])=>'<numFmt numFmtId="'+p+'" formatCode="'+C(e,this.policy)+'"/>').join("")+'</numFmts><fonts count="'+this.fonts.length+'">'+this.fonts.map(t).join("")+'</fonts><fills count="'+this.fills.length+'">'+this.fills.map(e=>'<fill><patternFill patternType="'+e.pattern+'">'+(e.color?'<fgColor rgb="'+e.color+'"/><bgColor indexed="64"/>':"")+"</patternFill></fill>").join("")+'</fills><borders count="'+this.borders.length+'">'+this.borders.map(r).join("")+'</borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="'+this.styles.length+'">'+this.styles.map(e=>{const p=e.wrapText||e.alignment||e.verticalAlignment?"<alignment"+(e.wrapText?' wrapText="1"':"")+(e.alignment?' horizontal="'+e.alignment+'"':"")+(e.verticalAlignment?' vertical="'+e.verticalAlignment+'"':"")+"/>":"";return'<xf numFmtId="'+e.numberFormat+'" fontId="'+e.font+'" fillId="'+e.fill+'" borderId="'+e.border+'" xfId="0"'+(e.numberFormat?' applyNumberFormat="1"':"")+(e.font?' applyFont="1"':"")+(e.fill?' applyFill="1"':"")+(e.border?' applyBorder="1"':"")+(p?' applyAlignment="1"':"")+">"+p+"</xf>"}).join("")+'</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>'+this.differential.toXml()+"</styleSheet>"}}return Object.freeze({colorArgb:Be.colorArgb,spreadsheetNamespace:c,normalizeBorder:h,NumberFormats:u,validateStylePatch:i,copyStylePatch:a,StyleRegistry:m})})(),rt=(()=>{function C(v){if(!v||typeof v!="object")throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const{target:S,tooltip:T}=v;if(typeof S!="string"||!/^(?:https?:\/\/|mailto:)/i.test(S)||/[\u0000-\u0020\u007f]/.test(S))throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const g=new URL(S);if((g.protocol==="http:"||g.protocol==="https:")&&(!g.hostname||g.username||g.password))throw new TypeError("Hyperlink HTTP targets need a host and must not contain credentials.");if(T!==void 0&&typeof T!="string")throw new TypeError("Hyperlink tooltip must be text.");return Object.freeze({target:g.href,...T===void 0?{}:{tooltip:T}})}return Object.freeze({copyExportLink:C})})(),xe=(()=>{const{isDate:C}=Se,{copyExportLink:E}=rt,v=Symbol.for("@evotecit/officeimo/ExportCell");function S(h){if(!h||typeof h!="object"||Array.isArray(h))throw new TypeError("Cell presentation must be an object.");const u={};for(const f of["background","color","numberFormat","bold","italic","wrapText","alignment"]){const o=h[f];if(o!==void 0){if(["bold","italic","wrapText"].includes(f)){if(typeof o!="boolean")throw new TypeError("Cell presentation "+f+" must be boolean.")}else if(typeof o!="string")throw new TypeError("Cell presentation "+f+" must be text.");if(f==="alignment"&&!["left","center","right","fill","justify","distributed"].includes(o))throw new TypeError("Invalid cell presentation alignment.");u[f]=o}}return Object.freeze(u)}class T{value;static[Symbol.hasInstance](u){return!!u&&typeof u=="object"&&u[v]===!0}text;presentation;link;constructor(u,f={}){this.value=u;const{text:o,presentation:i,link:a}=f;if(o!==void 0&&typeof o!="string")throw new TypeError("Display text must be a string.");g(u),this.text=o,this.presentation=i===void 0?void 0:S(i),this.link=a===void 0?void 0:E(a),Object.defineProperty(this,v,{value:!0}),Object.freeze(this)}}function g(h){const u=typeof h;if(!(h==null||u==="string"||u==="number"||u==="boolean"||C(h)))throw typeof h.then=="function"&&Promise.resolve(h).catch(()=>{}),new TypeError("Export values and formatter results must be synchronous strings, numbers, booleans, Dates or null.")}function c(h){h!==null&&typeof h=="object"&&h instanceof T||g(h)}return Object.freeze({copyCellPresentation:S,ExportCell:T,assertScalar:g,assertExportValue:c})})(),ze=(()=>{const{NotSupportedError:C}=he,{cleanXml:E,escapeXml:v}=we,S=new WeakSet,T=new WeakSet;function g(o){let i=!1;const a=/[\p{L}_\\][\p{L}\p{N}\p{M}_.\\]*/uy;for(let m=0;m<o.length;m++){const s=o[m];if(s==='"'){for(;++m<o.length;)if(o[m]==='"'){if(o[m+1]!=='"')break;m++}}else if(s==="'"){let n="";for(;++m<o.length;){if(o[m]==="'"){if(o[m+1]!=="'")break;m++}n+=o[m]}if(o.slice(m+1).trimStart().startsWith("!")&&/[\[\]]/.test(n))throw new C("external-workbook formulas")}else if(s==="["){let n=1;for(;++m<o.length&&n;){if(o[m]==="'"){m++;continue}o[m]==="["?n++:o[m]==="]"&&n--}if(/^[A-Za-z0-9_.]*!/.test(o.slice(m)))throw new C("external-workbook formulas");m--}else{if(s==="|")throw new C("DDE formulas");{a.lastIndex=m;const n=a.exec(o);n&&(["SUBTOTAL","AGGREGATE","_XLFN.AGGREGATE"].includes(n[0].toUpperCase())&&/^\s*\(/.test(o.slice(a.lastIndex))&&(i=!0),m=a.lastIndex-1)}}}return i}function c(o){if(typeof o!="string")throw new TypeError("Formula text must be a string.");const i=o.trim().replace(/^=/,"");if(!i.trim()||i.length>8192)throw new RangeError("Formulas require 1 through 8,192 characters.");return E(i,"reject"),{text:i,subtotal:g(i)}}class d{cachedValue;style;static[Symbol.hasInstance](i){return i!==null&&typeof i=="object"&&S.has(i)}formula;constructor(i,a,m){this.cachedValue=a,this.style=m;const s=c(i);if(this.formula=s.text,a!==null&&(typeof a!="number"||!Number.isFinite(a)))throw new TypeError("Formula caches must be finite numbers or null for a blank result.");if(m!==void 0&&(!Number.isSafeInteger(m)||m<0))throw new RangeError("Formula style indexes must be nonnegative safe integers.");S.add(this),s.subtotal&&T.add(this),Object.freeze(this)}}function h(o){return T.has(o)}function u(o){if(!(o instanceof d))throw new TypeError("Formula cells must be created with FormulaCell.");return"<f>"+v(o.formula,"reject")+"</f><v>"+(o.cachedValue??"")+"</v>"}return Object.freeze({FormulaCell:d,isSubtotalFormula:h,formulaXml:u})})(),He=(()=>{const{ExportCell:C,assertExportValue:E}=xe,{isDate:v}=Se;function S(g){if(E(g),v(g))return new Date(Date.prototype.getTime.call(g));if(g instanceof C){const{value:c,text:d,presentation:h,link:u}=g;return new C(v(c)?new Date(Date.prototype.getTime.call(c)):c,{...d===void 0?{}:{text:d},...h===void 0?{}:{presentation:h},...u===void 0?{}:{link:u}})}return g}return Object.freeze({copyExportValue:S})})(),ke=(()=>{const{cleanXml:C,escapeXml:E}=we,{assertExportValue:v,assertScalar:S}=xe,{FormulaCell:T}=ze,{copyExportValue:g}=He;class c{value;style;constructor(r,e){this.value=r,this.style=e}}function d(t){t instanceof T||(t instanceof c?S(t.value):v(t))}function h(t){return t instanceof T?t:t instanceof c?Object.freeze(new c(g(t.value),t.style)):g(t)}function u(t,r="strip"){const e=C(t,r);if(e.length>32767)throw new RangeError("Excel cell text exceeds 32,767 UTF-16 code units.");return e}function f(t,r){const e=u(t,r),p=k=>'<t xml:space="preserve">'+E(k,r)+"</t>";return/_x[0-9a-f]{4}_/i.test(e)?e.split(/(?<=_)(?=x[0-9a-f]{4}_)/gi).map(k=>"<r>"+p(k)+"</r>").join(""):p(e)}function o(t){if(!Number.isInteger(t)||t<1||t>16384)throw new RangeError("Column index must be from 1 through 16,384.");let r="";for(;t;)t--,r=String.fromCharCode(65+t%26)+r,t=Math.floor(t/26);return r}function i(t,r){return t.slice(0,r).replace(/[\ud800-\udbff]$/,"")}function a(t){let r=0,e=t.length;const p=k=>k==="'"||/\s/u.test(k);for(;r<e&&p(t[r]);)r++;for(;e>r&&p(t[e-1]);)e--;return t.slice(r,e)}function m(t,r,e,p=!0){if(typeof t!="string")throw new TypeError("Sheet name must be a string.");let k=a(C(t,e).replace(/[\[\]:*?/\\]/g,"_"));k=a(i(k,31)),k||(k="Sheet"),k.toLowerCase()==="history"&&(k+="_");let y=k,w=2;for(;r.has(y.toLowerCase());){const b=" ("+w+++")";y=i(k,31-b.length)+b}return p&&r.add(y.toLowerCase()),y}function s(t,r){if(!Number.isFinite(t.getTime()))return null;const e=r==="utc",p=e?t.getUTCFullYear():t.getFullYear();if(p<1900||p>9999)throw new RangeError("Excel dates must be in years 1900 through 9999.");const k=new Date(0);k.setUTCFullYear(p,e?t.getUTCMonth():t.getMonth(),e?t.getUTCDate():t.getDate()),k.setUTCHours(e?t.getUTCHours():t.getHours(),e?t.getUTCMinutes():t.getMinutes(),e?t.getUTCSeconds():t.getSeconds(),e?t.getUTCMilliseconds():t.getMilliseconds());const y=k.getTime();return(y-Date.UTC(1899,11,31))/864e5+(y>=Date.UTC(1900,2,1)?1:0)}return Object.freeze({Cell:c,assertXlsxValue:d,copyValue:h,cellText:u,inlineText:f,columnName:o,sheetName:m,excelDate:s})})(),Xe=(()=>{const{assertExportValue:C}=xe,{checkAbort:E}=ye,{isDate:v}=Se,{captureFields:S}=be;function T(h,u,f,o=C){const i=h.some(a=>a.value);return(a,m=0)=>{if(Array.isArray(a)&&!i){const s=a.length;if(s>h.length)throw new RangeError("Row has more values than declared columns.");const n=new Array(s);for(let t=0;t<s;t++){const r=a[t];o(r),n[t]=r}return n}if(!a||typeof a!="object"||v(a))throw new TypeError("A row must be an array or object.");if(Array.isArray(a)&&a.length>h.length&&!h.every(s=>s.value))throw new RangeError("Project every column explicitly when selecting from a wider array row.");return h.map((s,n)=>{if(s.value){E(f);const e={rowIndex:m,columnIndex:n,column:s,...u?{sheetName:u.sheetName,worksheetRow:u.firstDataRow+m}:{}},p=s.value(a,e);return o(p),E(f),p}if(Array.isArray(a)){const e=a[n];return o(e),e}const t=s.key??s.header,r=Object.prototype.hasOwnProperty.call(a,t)?a[t]:void 0;return o(r),r})}}const g=["header","key","value","width","type","format","wrapText","alignment","rowHeader","groups","style","valueFormatter"];function c(h,u=!1){if(!Array.isArray(h))throw new TypeError("Declare the columns in export order.");return h.map(f=>{if(!f||typeof f!="object"&&typeof f!="function")throw new TypeError("Each column needs a string header and an optional string key.");const o=S(f,g);if(!u&&o.style!==void 0)throw new TypeError("Workbook-local column styles require the advanced Workbook API; use portable ExportCell presentation.");if(typeof o.header!="string"||o.key!==void 0&&typeof o.key!="string")throw new TypeError("Each column needs a string header and an optional string key.");if(o.value!==void 0&&typeof o.value!="function")throw new TypeError("Column value getters must be functions.");if(o.rowHeader!==void 0&&typeof o.rowHeader!="boolean")throw new TypeError("Column rowHeader must be boolean.");if(o.groups!==void 0){if(!Array.isArray(o.groups))throw new TypeError("Column groups must be an array of strings.");const i=Array.from(o.groups);if(i.some(a=>typeof a!="string"))throw new TypeError("Column groups must be an array of strings.");return{...o,groups:Object.freeze(i)}}return o})}return Object.freeze({createRowProjector:T,columnOptionFields:g,copyColumns:c})})(),nt=(()=>{const{captureFields:C}=be;function E(g,c){if(g===void 0)return;if(!Array.isArray(g)||g.length>c)throw new TypeError("Column outlines must be bounded, non-overlapping ranges.");let d=0;return Object.freeze(g.map(h=>{if(!h||typeof h!="object")throw new TypeError("Column outlines require range metadata.");return C(h,["firstColumn","columnCount","level","hidden","collapsed"])}).sort((h,u)=>h.firstColumn-u.firstColumn).map(h=>{const{firstColumn:u,columnCount:f,level:o=0,hidden:i,collapsed:a}=h;if(!Number.isSafeInteger(u)||u<d||!Number.isSafeInteger(f)||f<1||u+f>c)throw new RangeError("Column outline ranges must be disjoint and within the declared columns.");if(!Number.isInteger(o)||o<0||o>7)throw new RangeError("Column outline level must be from zero through seven.");for(const m of[i,a])if(m!==void 0&&typeof m!="boolean")throw new TypeError("Column outline flags must be booleans.");return d=u+f,Object.freeze({firstColumn:u,columnCount:f,level:o,...i===void 0?{}:{hidden:i},...a===void 0?{}:{collapsed:a}})}))}function v(g){for(const c of[g.outlineSummaryBelow,g.outlineSummaryRight])if(c!==void 0&&typeof c!="boolean")throw new TypeError("Outline summary positions must be booleans.")}function S(g){const c=new Map;for(const d of g??[])for(let h=d.firstColumn;h<d.firstColumn+d.columnCount;h++)c.set(h,d);return c}return Object.freeze({captureColumnOutlines:E,validateOutlinePositions:v,columnOutlineMap:S})})(),st=(()=>{const{assertExportValue:C}=xe,{copyExportValue:E}=He;function v(g,c){if(!Array.isArray(g)||!g.length||g.length>16)throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");const d=g.map(h=>{if(!Array.isArray(h)||h.length!==c)throw new TypeError("Spanned rows must have the declared column count.");return Object.freeze(h.map(u=>{if(u===null)return null;if(!u||typeof u!="object")throw new TypeError("Uncovered heading/footer cells need an anchor value.");const{value:f,columnSpan:o,rowSpan:i}=u;return Object.freeze({value:E(f),...o===void 0?{}:{columnSpan:o},...i===void 0?{}:{rowSpan:i}})}))});return S(d,c),Object.freeze(d)}function S(g,c){if(!Array.isArray(g)||!g.length||g.length>16)throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");const d=Array.from({length:g.length},()=>new Uint8Array(c));return g.map((h,u)=>{if(!Array.isArray(h)||h.length!==c)throw new TypeError("Spanned rows must have the declared column count.");const f=[];for(let o=0;o<c;o++){const i=h[o];if(d[u][o]){if(i!==null)throw new TypeError("Covered heading/footer cells must be null.");continue}if(!i||typeof i!="object")throw new TypeError("Uncovered heading/footer cells need an anchor value.");const a=i.columnSpan??1,m=i.rowSpan??1;if(!Number.isInteger(a)||!Number.isInteger(m)||a<1||m<1||o+a>c||u+m>g.length)throw new RangeError("Heading/footer spans must stay inside the declared matrix.");const s=i.value;C(s);for(let n=u;n<u+m;n++)for(let t=o;t<o+a;t++){if(d[n][t])throw new TypeError("Heading/footer spans overlap.");if((n!==u||t!==o)&&g[n]?.[t]!==null)throw new TypeError("Covered heading/footer cells must be null.");d[n][t]=1}f.push(Object.freeze({first:o,span:a,rowSpan:m,value:s}))}return Object.freeze(f)})}return Object.freeze({captureTableSpans:v,tableSpans:S})})(),ot=(()=>{const{ChunkedTextSink:C}=Ce,{escapeXml:E,xmlDeclaration:v}=we,{officeRelationshipsNamespace:S}=Me,{columnName:T}=ke,g="http://schemas.openxmlformats.org/drawingml/2006/chart",c="application/vnd.openxmlformats-officedocument.drawingml.chart+xml";function d(s,n,t){const r=' cx="'+Math.round(s.width*9525)+'" cy="'+Math.round(s.height*9525)+'"';return"<xdr:oneCellAnchor><xdr:from><xdr:col>"+(s.column-1)+"</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>"+(s.row-1)+"</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:from><xdr:ext"+r+'/><xdr:graphicFrame macro=""><xdr:nvGraphicFramePr><xdr:cNvPr id="'+n+'" name="Chart '+s.id+'" descr="'+E(s.description??s.title??"",t)+'"/><xdr:cNvGraphicFramePr/></xdr:nvGraphicFramePr><xdr:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/></xdr:xfrm><a:graphic><a:graphicData uri="'+g+'"><c:chart xmlns:c="'+g+'" r:id="chart'+s.id+'"/></a:graphicData></a:graphic></xdr:graphicFrame><xdr:clientData/></xdr:oneCellAnchor>'}function h(s,n){return'<c:title><c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:r><a:t xml:space="preserve">'+E(s,n)+'</a:t></a:r></a:p></c:rich></c:tx><c:overlay val="0"/></c:title>'}function*u(s,n,t,r){yield"<c:"+s+"Ref><c:f>"+E(n,r)+"</c:f><c:"+s+"Cache>",s==="num"&&(yield"<c:formatCode>General</c:formatCode>"),yield'<c:ptCount val="'+t.length+'"/>';for(let e=0;e<t.length;e++)yield'<c:pt idx="'+e+'"><c:v xml:space="preserve">'+E(String(t[e]),r)+"</c:v></c:pt>";yield"</c:"+s+"Cache></c:"+s+"Ref>"}function f(s,n){const t=s.dataLabels;if(!t)return"";const r={center:"ctr",insideEnd:"inEnd",outsideEnd:"outEnd",bestFit:"bestFit",above:"t",below:"b",left:"l",right:"r"};return"<c:dLbls>"+(t.numberFormat===void 0?"":'<c:numFmt formatCode="'+E(t.numberFormat,n)+'" sourceLinked="0"/>')+(t.position===void 0?"":'<c:dLblPos val="'+r[t.position]+'"/>')+'<c:showLegendKey val="0"/><c:showVal val="'+(t.showValue===!1?0:1)+'"/><c:showCatName val="'+(t.showCategoryName?1:0)+'"/><c:showSerName val="'+(t.showSeriesName?1:0)+'"/><c:showPercent val="'+(t.showPercent?1:0)+'"/><c:showBubbleSize val="0"/></c:dLbls>'}function o(s,n){const t=s.type==="barClustered",r=s.valueAxis,e='<c:scaling><c:orientation val="minMax"/>'+(r?.maximum===void 0?"":'<c:max val="'+r.maximum+'"/>')+(r?.minimum===void 0?"":'<c:min val="'+r.minimum+'"/>')+"</c:scaling>",p='<c:majorTickMark val="none"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/>';return'<c:catAx><c:axId val="1"/><c:scaling><c:orientation val="minMax"/></c:scaling><c:delete val="0"/><c:axPos val="'+(t?"l":"b")+'"/>'+(s.categoryAxis?.title?h(s.categoryAxis.title,n):"")+'<c:numFmt formatCode="General" sourceLinked="1"/>'+p+'<c:crossAx val="2"/><c:crosses val="autoZero"/><c:auto val="1"/><c:lblAlgn val="ctr"/><c:lblOffset val="100"/><c:noMultiLvlLbl val="0"/></c:catAx><c:valAx><c:axId val="2"/>'+e+'<c:delete val="0"/><c:axPos val="'+(t?"b":"l")+'"/><c:majorGridlines/>'+(r?.title?h(r.title,n):"")+'<c:numFmt formatCode="'+E(r?.numberFormat??"General",n)+'" sourceLinked="'+(r?.numberFormat===void 0?1:0)+'"/>'+p+'<c:crossAx val="1"/><c:crosses val="autoZero"/><c:crossBetween val="between"/></c:valAx>'}function*i(s,n){const t=s.type==="pie",r=s.type==="line",e=t?"pieChart":r?"lineChart":"barChart",p="'"+s.dataSheetName.replace(/'/g,"''")+"'!",k=s.data.categories.length+1;yield v+'<c:chartSpace xmlns:c="'+g+'" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="'+S+'"><c:date1904 val="0"/>'+(s.language===void 0?"":'<c:lang val="'+E(s.language,n)+'"/>')+"<c:chart>",s.title&&(yield h(s.title,n)),yield'<c:autoTitleDeleted val="'+(s.title?0:1)+'"/><c:plotArea><c:layout/><c:'+e+">",t||(yield r?'<c:grouping val="standard"/>':'<c:barDir val="'+(s.type==="barClustered"?"bar":"col")+'"/><c:grouping val="clustered"/>'),yield'<c:varyColors val="'+(t?1:0)+'"/>';for(let y=0;y<s.data.series.length;y++){const w=s.data.series[y],b="$"+T(y+2);yield'<c:ser><c:idx val="'+y+'"/><c:order val="'+y+'"/><c:tx>';const I=s.binding?s.binding.references.names[y]:p+b+"$1";I===void 0?yield"<c:v>"+E(w.name,n)+"</c:v>":yield*u("str",I,[w.name],n),yield"</c:tx>",w.color&&(yield"<c:spPr>"+(r?'<a:ln w="25400">':"")+'<a:solidFill><a:srgbClr val="'+w.color+'"/></a:solidFill>'+(r?"</a:ln>":"")+"</c:spPr>"),!r&&!t&&(yield'<c:invertIfNegative val="0"/>'),yield"<c:cat>",yield*u("str",s.binding?.references.categories??p+"$A$2:$A$"+k,s.data.categories,n),yield"</c:cat><c:val>",yield*u("num",s.binding?.references.values[y]??p+b+"$2:"+b+"$"+k,w.values,n),yield"</c:val>"+(r?'<c:smooth val="0"/>':"")+"</c:ser>"}yield f(s,n),!t&&!r&&(yield'<c:gapWidth val="150"/><c:overlap val="0"/>'),t||(yield'<c:axId val="1"/><c:axId val="2"/>'),yield"</c:"+e+">",t||(yield o(s,n)),yield"</c:plotArea>",s.legend!==!1&&(yield'<c:legend><c:legendPos val="'+{right:"r",bottom:"b",left:"l",top:"t"}[s.legend??"right"]+'"/><c:layout/><c:overlay val="0"/></c:legend>'),yield'<c:plotVisOnly val="'+(s.binding?1:0)+'"/><c:dispBlanksAs val="gap"/><c:showDLblsOverMax val="0"/></c:chart></c:chartSpace>'}async function a(s,n,t,r){const e=new C(n,r);for(const p of i(s,t))e.append(p)&&await e.flush();await e.close()}return Object.freeze({chartNamespace:g,chartContentType:c,chartAnchorXml:d,writeChartXml:a})})(),_e=(()=>{const{cleanXml:C,escapeXml:E,escapeOoxmlAttribute:v,xmlDeclaration:S}=we,{copyExportLink:T}=rt,{officeRelationshipsNamespace:g}=Me,{chartAnchorXml:c}=ot,{captureFields:d}=be;function h(n,t){if(n=d(n,["row","column","width","height","description"]),!Number.isInteger(n.row)||n.row<1||n.row>1048576||!Number.isInteger(n.column)||n.column<1||n.column>16384)throw new RangeError("Drawing anchors must be one-based worksheet rows and columns.");for(const r of[n.width,n.height])if(!Number.isFinite(r)||r<=0||r>1e5)throw new RangeError("Drawing display dimensions must be positive and at most 100,000 pixels.");if(n.description!==void 0&&typeof n.description!="string")throw new TypeError("Drawing description must be a string.");return Object.freeze({row:n.row,column:n.column,width:n.width,height:n.height,...n.description===void 0?{}:{description:C(n.description,t)}})}function u(n){const t=typeof n=="string"&&/^([A-Z]{1,3})([1-9][0-9]{0,6})$/.exec(n);if(!t)throw new TypeError("Use a single uppercase A1 cell reference.");const r=Number(t[2]);let e=0;for(const p of t[1])e=e*26+p.charCodeAt(0)-64;if(e>16384||r>1048576)throw new RangeError("Cell reference exceeds Excel's worksheet bounds.");return{row:r,column:e}}function f(n,t){n=d(n,["cell","target","tooltip"]),u(n.cell);const r=T(n);return Object.freeze({cell:n.cell,target:r.target,...r.tooltip===void 0?{}:{tooltip:C(r.tooltip,t)}})}function o(n,t,r){if(n=d(n,["data","row","column","width","height","description"]),n.data instanceof Uint8Array&&r?.(n.data.length),!(n.data instanceof Uint8Array)||n.data.length<33||![137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82].every((p,k)=>n.data[k]===p))throw new TypeError("Images require PNG bytes with a valid signature and IHDR header.");const e=new DataView(n.data.buffer,n.data.byteOffset,n.data.byteLength);if(!e.getUint32(16)||!e.getUint32(20))throw new RangeError("PNG dimensions must be positive.");return Object.freeze({...h(n,t),data:new Uint8Array(n.data)})}function i(n,t,r=[]){return"<hyperlinks>"+n.map((e,p)=>'<hyperlink ref="'+e.cell+'" r:id="link'+(p+1)+'"'+(e.tooltip===void 0?"":' tooltip="'+v(e.tooltip,t)+'"')+"/>").join("")+r.map(e=>'<hyperlink ref="'+e.cell+'" location="'+v(e.location,t)+'"/>').join("")+"</hyperlinks>"}function a(n,t,r=[]){const e="http://schemas.openxmlformats.org/drawingml/2006/";return S+'<xdr:wsDr xmlns:xdr="'+e+'spreadsheetDrawing" xmlns:a="'+e+'main" xmlns:r="'+g+'">'+n.map((p,k)=>{const y=' cx="'+Math.round(p.width*9525)+'" cy="'+Math.round(p.height*9525)+'"';return"<xdr:oneCellAnchor><xdr:from><xdr:col>"+(p.column-1)+"</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>"+(p.row-1)+"</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:from><xdr:ext"+y+'/><xdr:pic><xdr:nvPicPr><xdr:cNvPr id="'+(k+1)+'" name="Image '+(k+1)+'" descr="'+E(p.description??"",t)+'"/><xdr:cNvPicPr/></xdr:nvPicPr><xdr:blipFill><a:blip r:embed="image'+(k+1)+'"/><a:stretch><a:fillRect/></a:stretch></xdr:blipFill><xdr:spPr><a:xfrm><a:off x="0" y="0"/><a:ext'+y+'/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></xdr:spPr></xdr:pic><xdr:clientData/></xdr:oneCellAnchor>'}).join("")+r.map((p,k)=>c(p,n.length+k+1,t)).join("")+"</xdr:wsDr>"}return Object.freeze({copyDrawingAnchor:h,cellPosition:u,copyHyperlink:f,copyImage:o,hyperlinksXml:i,drawingXml:a,drawingContentType:"application/vnd.openxmlformats-officedocument.drawing+xml"})})(),ft=(()=>{const{OfficeIMOError:C}=he,{cellPosition:E}=_e;function v(c){if(!c.length)return;const d=[...c].sort((m,s)=>m.top-s.top),h=d[Math.floor(d.length/2)].top,u=[],f=[],o=[];for(const m of d)(m.bottom<h?f:m.top>h?o:u).push(m);const i=v(f),a=v(o);return{middle:h,starts:u,ends:[...u].sort((m,s)=>s.bottom-m.bottom),...i?{before:i}:{},...a?{after:a}:{}}}function S(c,d,h){if(c){for(const u of d<=c.middle?c.starts:c.ends){if(d<=c.middle?u.top>d:u.bottom<d)break;h.push(u)}S(d<c.middle?c.before:d>c.middle?c.after:void 0,d,h)}}class T{references;index;currentRow=-1;current=[];lastRow;constructor(d,h,u){if(d.length>u)throw new C("RESOURCE_LIMIT","maxMergedRanges exceeded.");if(!d.length){this.references=Object.freeze([]),this.lastRow=0,this.index=void 0;return}const f=d.map(s=>{if(typeof s!="string"||s.split(":").length!==2)throw new TypeError("Merged ranges require uppercase A1:B2 references.");const[n,t]=s.split(":"),r=E(n),e=E(t);if(e.row<r.row||e.column<r.column||e.row===r.row&&e.column===r.column)throw new RangeError("Merged ranges require ordered distinct cells.");if(e.column>h)throw new RangeError("Merged ranges must stay within declared columns.");return{ref:s,top:r.row,bottom:e.row,left:r.column,right:e.column}}),o=f.flatMap(s=>[{row:s.top,delta:1,region:s},{row:s.bottom+1,delta:-1,region:s}]).sort((s,n)=>s.row-n.row||s.delta-n.delta),i=new Int32Array(65536),a=new Int32Array(65536);function m(s,n,t,r,e,p){if(r<=n&&t<=e){i[s]=i[s]+p,a[s]=a[s]+p;return}const k=n+t>>>1;r<=k&&m(s*2,n,k,r,e,p),e>k&&m(s*2+1,k+1,t,r,e,p),i[s]=a[s]+Math.max(i[s*2],i[s*2+1])}for(const s of o)if(m(1,1,16384,s.region.left,s.region.right,s.delta),i[1]>1)throw new TypeError("Merged ranges must not overlap: "+s.region.ref);this.references=Object.freeze(f.map(s=>s.ref)),this.lastRow=f.reduce((s,n)=>Math.max(s,n.bottom),0),this.index=v(f)}covered(d,h){if(!this.index||h>this.lastRow)return!1;this.currentRow!==h&&(this.current=[],S(this.index,h,this.current),this.current.sort((o,i)=>o.left-i.left),this.currentRow=h);let u=0,f=this.current.length-1;for(;u<=f;){const o=u+f>>>1,i=this.current[o];if(d<i.left)f=o-1;else if(d>i.right)u=o+1;else return h!==i.top||d!==i.left}return!1}validateRows(d){if(this.lastRow>d)throw new RangeError("Merged ranges must stay within exported rows.")}}return Object.freeze({MergeRegions:T})})(),it=(()=>{class C{operation;count=0;sum=0;mean=0;min=1/0;max=-1/0;constructor(T){this.operation=T}accept(T){if(!(!this.operation||typeof T!="number"||!Number.isFinite(T)))if(this.count++,this.operation==="sum"){if(this.sum+=T,!Number.isFinite(this.sum))throw new RangeError("Numeric total exceeds finite number range.")}else if(this.operation==="average"){const g=T-this.mean;this.mean=this.count===1?T:Number.isFinite(g)?this.mean+g/this.count:this.mean*((this.count-1)/this.count)+T/this.count}else this.operation==="min"?this.min=Math.min(this.min,T):this.operation==="max"&&(this.max=Math.max(this.max,T))}value(){return this.operation==="count"?this.count:this.operation==="sum"?this.sum:this.count?this.operation==="average"?this.mean:this.operation==="min"?this.min:this.max:null}}function E(S,T={}){const g=S.map(c=>c.key??c.header);for(const[c,d]of Object.entries(T)){if(g.filter(h=>h===c).length!==1)throw new TypeError("Totals need an unambiguous declared column key: "+c);if(!["sum","count","average","min","max"].includes(d))throw new TypeError("Invalid total operation.")}return g.map(c=>new C(Object.prototype.hasOwnProperty.call(T,c)?T[c]:void 0))}return Object.freeze({NumericAggregate:C,createTotals:E})})(),mt=(()=>{const{ExportCell:C}=xe,{tableSpans:E}=st,{copyValue:v,columnName:S}=ke;class T{values;ranges;constructor(d,h){const u=E(d,h),f=[];this.values=u.map((o,i)=>{const a=Array(h).fill(void 0);for(const m of o)a[m.first]=v(m.value),(m.span>1||m.rowSpan>1)&&f.push({first:m.first+1,last:m.first+m.span,top:i+1,bottom:i+m.rowSpan});return Object.freeze(a)}),this.ranges=f}get mergeCount(){return this.ranges.length}merges(d){return this.ranges.map(h=>S(h.first)+(h.top+d)+":"+S(h.last)+(h.bottom+d))}matchesLeaf(d){const h=this.values.length;return!this.ranges.some(u=>u.bottom===h)&&this.values[h-1].every((u,f)=>(u instanceof C?u.value:u)===d[f])}}return Object.freeze({StructuredRows:T})})(),at=(()=>{const{ExportCell:C}=xe,{isDate:E}=Se,{Cell:v,cellText:S,columnName:T}=ke,{FormulaCell:g}=ze,{escapeOoxmlAttribute:c}=we,{MergeRegions:d}=ft,{OfficeIMOError:h}=he,{createTotals:u}=it,{StructuredRows:f}=mt;class o{value;formula;operation;constructor(r,e,p){this.value=r,this.formula=e,this.operation=p}}class i{columns;options;headings;merges;headerRows;firstHeaderRow;regions;widths;sampleRows;structuredFooter;footerRows;mergeCount;aggregates;constructor(r,e,p,k=1e4,y=1e5){this.columns=r,this.options=e;const w=e.title===void 0?0:1;if(e.title!==void 0){if(!r.length)throw new TypeError("Report titles require declared columns.");if(typeof e.title.text!="string")throw new TypeError("Report title text must be a string.");if(S(e.title.text,p),e.title.height!==void 0&&(!Number.isFinite(e.title.height)||e.title.height<=0||e.title.height>409))throw new RangeError("Title height must be positive and at most 409 points.")}const b=Math.max(0,...r.map(j=>j.groups?.length??0));if(e.headerRows===void 0){if(b>16)throw new RangeError("Grouped headings support at most 16 levels.");if(b&&e.includeHeader===!1)throw new TypeError("Grouped headings require leaf headers.")}const I=[],F=[];if(w&&r.length>1&&F.push("A1:"+T(r.length)+"1"),e.headerRows!==void 0&&e.includeHeader!==!1){const j=new f(e.headerRows,r.length);if((e.table||e.autoFilter)&&!j.matchesLeaf(r.map(P=>P.header)))throw new TypeError("Native tables and autofilters require an unmerged final heading row matching the declared leaf headers.");I.push(...j.values),F.push(...j.merges(w))}else if(e.includeHeader!==!1){for(let j=0;j<b;j++){const P=r.map(q=>q.groups?.[j]??"");for(const q of P)S(q,p);for(let q=0;q<r.length;){let H=q;const re=JSON.stringify(r[q].groups?.slice(0,j+1));for(;H+1<r.length&&P[q]&&JSON.stringify(r[H+1].groups?.slice(0,j+1))===re;)H++;if(H>q){F.push(T(q+1)+(j+1+w)+":"+T(H+1)+(j+1+w));for(let Q=q+1;Q<=H;Q++)P[Q]=""}q=H+1}I.push(P)}r.length&&I.push(r.map(j=>j.header))}if(this.headerRows=w+I.length,this.firstHeaderRow=r.length&&e.includeHeader!==!1?w+1:0,e.mergedCells!==void 0&&!Array.isArray(e.mergedCells))throw new TypeError("Merged ranges must be an array.");if(e.footer?.rows!==void 0&&(e.footer.values!==void 0||e.footer.totals!==void 0))throw new TypeError("Structured footer rows cannot accompany footer values or totals.");if(this.structuredFooter=e.footer?.rows===void 0?void 0:new f(e.footer.rows,r.length),this.footerRows=this.structuredFooter?.values.length??(e.footer?1:0),this.mergeCount=F.length+(e.mergedCells?.length??0)+(this.structuredFooter?.mergeCount??0),this.mergeCount>k)throw new h("RESOURCE_LIMIT","maxMergedRanges exceeded.");if(this.regions=new d([...F,...e.mergedCells??[]],r.length,k),e.table){for(const j of e.mergedCells??[])if(Number(j.split(":")[1].match(/\d+$/)[0])>=this.headerRows)throw new TypeError("Merged ranges cannot intersect a native table.")}this.headings=I,this.merges=this.regions.references;const B=e.autoSize;if(this.sampleRows=B?B.sampleRows??Math.min(100,Math.floor(y/Math.max(1,r.length))):0,!Number.isInteger(this.sampleRows)||this.sampleRows<0||this.sampleRows>1048576)throw new RangeError("Width sampling must use from 0 through 1,048,576 rows within its buffer budgets.");const A=B?.minWidth??8,z=B?.maxWidth??60;if(!Number.isFinite(A)||!Number.isFinite(z)||A<0||A>z||z>255)throw new RangeError("Width bounds must satisfy 0 <= minWidth <= maxWidth <= 255.");if(this.widths=r.map(j=>j.width??(B?Math.max(A,Math.min(z,j.header.length+2)):void 0)),e.footer?.values&&e.footer.values.length>r.length)throw new RangeError("Footer has more values than declared columns.");this.aggregates=u(r,e.footer?.totals),e.print&&m(e.print,p)}finalRegions(r,e){return this.structuredFooter?new d([...this.merges,...this.structuredFooter.merges(this.headerRows+r)],this.columns.length,e):this.regions}sample(r){const e=this.options.autoSize?.minWidth??8,p=this.options.autoSize?.maxWidth??60;r.forEach((k,y)=>{if(!this.columns[y]||this.columns[y].width!==void 0)return;const w=k instanceof g?k.cachedValue:k instanceof C?k.text??k.value:k instanceof v?k.value:k,b=E(w)?Number.isFinite(w.getTime())?w.toISOString():"":w==null?"":String(w),I=Math.max(0,...b.slice(0,Math.ceil(p*4)).split(/\r?\n/).map(F=>[...F].length));this.widths[y]=Math.max(this.widths[y]??e,Math.min(p,I+2))})}accept(r,e){this.aggregates[r].accept(e)}footer(r){return this.columns.map((e,p)=>{const k=this.aggregates[p],y=k.operation;if(!y)return this.options.footer?.values?.[p];const w=k.value();return new o(w,a(y,T(p+1),this.headerRows,r),y)})}}function a(t,r,e,p){const k={sum:109,count:102,average:101,min:105,max:104}[t],y=["average","min","max"].includes(t),w=r+(e+1)+":"+r+(e+p),b="SUBTOTAL("+k+","+w+")";return p?y?"IF(SUBTOTAL(102,"+w+')=0,"",'+b+")":b:y?'""':"0"}function m(t,r){if(t.paper!==void 0&&!["A4","Letter"].includes(t.paper))throw new TypeError("Print paper must be A4 or Letter.");if(t.orientation!==void 0&&!["portrait","landscape"].includes(t.orientation))throw new TypeError("Invalid print orientation.");for(const e of[t.fitToWidth,t.fitToHeight])if(e!==void 0&&(!Number.isInteger(e)||e<0||e>32767))throw new RangeError("Print fit dimensions must be integers from 0 through 32,767.");for(const e of Object.values(t.margins??{}))if(!Number.isFinite(e)||e<0||e>10)throw new RangeError("Print margins must be from 0 through 10 inches.");for(const e of[t.header,t.footer])if(e!==void 0){if(typeof e!="string"||e.length>250)throw new TypeError("Print header/footer must be strings of at most 250 UTF-16 units.");if(S(e,r),("&C"+e.replace(/&/g,"&&")).length>255)throw new RangeError("Encoded print header/footer exceeds Excel's 255-character limit.")}}function s(t,r){if(!t)return"";const e={left:.25,right:.25,top:.5,bottom:.5,header:.2,footer:.2,...t.margins};return"<pageMargins"+Object.entries(e).map(([p,k])=>" "+p+'="'+k+'"').join("")+'/><pageSetup paperSize="'+(t.paper==="Letter"?1:9)+'" orientation="'+(t.orientation??"landscape")+'" fitToWidth="'+(t.fitToWidth??1)+'" fitToHeight="'+(t.fitToHeight??0)+'"/>'+(t.header!==void 0||t.footer!==void 0?"<headerFooter>"+(t.header===void 0?"":"<oddHeader>"+c("&C"+t.header.replace(/&/g,"&&"),r)+"</oddHeader>")+(t.footer===void 0?"":"<oddFooter>"+c("&C"+t.footer.replace(/&/g,"&&"),r)+"</oddFooter>")+"</headerFooter>":"")}return Object.freeze({ComputedTotal:o,ReportLayout:i,totalFormula:a,printXml:s})})(),Pe=(()=>{const{columnName:C}=ke;function E(g,c,d="Data"){if(typeof c=="string"){const h=g.flatMap((u,f)=>u.key===c?[f+1]:[]);if(h.length!==1)throw new TypeError(d+" column keys must identify exactly one declared column.");return h[0]}if(!Number.isInteger(c)||c<1||c>g.length)throw new RangeError(d+" column numbers must be one-based and within declared columns.");return c}function v(g,c,d,h){if(!Number.isSafeInteger(d)||d<1||!Number.isSafeInteger(h)||h<1||d+h-1>1048576)throw new RangeError("A data range must fit within Excel's worksheet rows.");const u=C(c);return"'"+g.replace(/'/g,"''")+"'!$"+u+"$"+d+":$"+u+"$"+(d+h-1)}function S(g,c,d){return v(g,c,d,1).split(":")[0]}return Object.freeze({resolveDataColumn:E,qualifiedColumnRange:v,qualifiedCell:S})})(),Ve=(()=>{const{OfficeIMOError:C}=he,{columnName:E}=ke,v=new WeakMap;function S(h,u){v.set(h,u)}function T(h){return v.get(h)}function g(h,u,f){const o=v.get(h);if(o===void 0)return f;const i=u+f;let a=0;for(const m of o){if(m.firstRow>i)break;a+=Math.min(m.lastRow,i)-m.firstRow+1}return a}function c(h,u,f,o,i){if(i===void 0)return o?E(h)+(f+1)+":"+E(u)+(f+o):void 0;const a=E(h),m=E(u);let s="",n=f;for(const t of i){if(!Number.isSafeInteger(t.firstRow)||!Number.isSafeInteger(t.lastRow)||t.firstRow<=n||t.lastRow<t.firstRow||t.lastRow>f+o)throw new RangeError("Detail editing ranges must be ordered within serialized worksheet rows.");const r=a+t.firstRow+":"+m+t.lastRow;if(s.length+(s?1:0)+r.length>32767)throw new C("RESOURCE_LIMIT","Detail editing references exceed 32,767 UTF-16 characters; split the worksheet.");s+=(s?" ":"")+r,n=t.lastRow}return s||void 0}return Object.freeze({retainDataRowRanges:S,dataRowRanges:T,dataRowCount:g,dataRowReference:c})})(),pt=(()=>{const{cleanXml:C,escapeXml:E,escapeOoxmlAttribute:v}=we,{cellPosition:S}=_e,{colorArgb:T}=Be,{fields:g,optionalBoolean:c,differentialXml:d}=Ue,{resolveDataColumn:h}=Pe,{dataRowReference:u}=Ve;function f(e,p){if(typeof e=="string"){const w=e.split(":");if(w.length>2)throw new TypeError("Conditional ranges require one uppercase A1 cell or rectangle.");const b=S(w[0]),I=S(w[1]??w[0]);if(I.row<b.row||I.column<b.column||I.column>p.length)throw new RangeError("Conditional ranges require ordered cells within declared columns.");return{first:b.column,last:I.column,reference:e,bottom:I.row}}g(e,["column","through"],"conditional data range");const k=h(p,e.column,"Conditional"),y=e.through===void 0?k:h(p,e.through,"Conditional");if(y<k)throw new RangeError("Conditional data ranges require ordered columns.");return{first:k,last:y}}function o(e){if(typeof e!="number"||!Number.isFinite(e))throw new TypeError("Conditional values must be finite numbers.");return String(e)}function i(e,p){if(typeof e!="string")return o(e);if(p!=="equal"&&p!=="notEqual")throw new TypeError("Text conditional comparisons support only equal and notEqual.");if(e.length>8190)throw new RangeError("Conditional comparison formulas must fit 8,192 characters including quotes.");C(e,"reject");const k='"'+e.replace(/"/g,'""')+'"';if(k.length>8192)throw new RangeError("Conditional comparison formulas must fit 8,192 characters including quotes.");return k}function a(e){if(typeof e!="string")throw new TypeError("Conditional formulas must be strings.");const p=e.trim().replace(/^=/,"");if(!p.trim()||p.length>8192)throw new RangeError("Conditional formulas require 1 through 8,192 characters.");return C(p,"reject"),p}function m(e,p){if(g(e,e.type==="min"||e.type==="max"?["type"]:["type","value"],"conditional threshold"),e.type==="min"||e.type==="max"){if(e.type!==(p==="first"?"min":p==="last"?"max":""))throw new TypeError("Use min only at the start and max only at the end of a scale.");return'<cfvo type="'+e.type+'"/>'}if(e.type==="formula")return'<cfvo type="formula" val="'+v(a(e.value),"reject")+'"/>';if(!["number","percent","percentile"].includes(e.type))throw new TypeError("Unsupported conditional threshold type.");if(!("value"in e))throw new TypeError("A numeric threshold requires a value.");const k=o(e.value);if(e.type!=="number"&&(e.value<0||e.value>100))throw new RangeError("Conditional percent/percentile thresholds must be from 0 through 100.");return'<cfvo type="'+(e.type==="number"?"num":e.type)+'" val="'+k+'"/>'}function s(e){for(let p=1;p<e.length;p++){const k=e[p-1],y=e[p];if("value"in k&&"value"in y&&k.type===y.type&&typeof k.value=="number"&&typeof y.value=="number"&&k.value>y.value)throw new RangeError("Conditional thresholds of the same numeric type must be ordered.")}}function n(e,p,k){if(e===void 0)return[];if(!Array.isArray(e))throw new TypeError("conditionalFormats must be an array.");return e.map(y=>{const w=["type","range"],b=["style","stopIfTrue"];g(y,[...w,...y?.type==="cellIs"?[...b,"operator","value","values"]:y?.type==="expression"?[...b,"formula"]:y?.type==="colorScale"?["stops"]:y?.type==="dataBar"?["color","minimum","maximum","showValue"]:[]],"conditional rule");const I=f(y.range,p);let F="",B="",A;if(y.type==="cellIs"||y.type==="expression")if(c(y.stopIfTrue,"stopIfTrue"),d(y.style,k,()=>164),A={...y.style,...y.style.font?{font:{...y.style.font}}:{},...y.style.fill?{fill:{...y.style.fill}}:{},...y.style.border?{border:Object.fromEntries(Object.entries(y.style.border).filter(([,z])=>z!==void 0).map(([z,j])=>[z,{...j}]))}:{}},y.stopIfTrue!==void 0&&(F+=' stopIfTrue="'+(y.stopIfTrue?1:0)+'"'),y.type==="expression")B="<formula>"+E(a(y.formula),"reject")+"</formula>";else{const z=y.operator==="between"||y.operator==="notBetween";if(!["equal","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","between","notBetween"].includes(y.operator))throw new TypeError("Unsupported conditional comparison operator.");if(z){if("value"in y||!Array.isArray(y.values)||y.values.length!==2)throw new TypeError("between/notBetween require exactly two values.");if(B=y.values.map(j=>"<formula>"+o(j)+"</formula>").join(""),y.values[0]>y.values[1])throw new RangeError("Conditional comparison bounds must be ordered.")}else{if("values"in y||!("value"in y))throw new TypeError("A conditional comparison requires one value.");B="<formula>"+E(i(y.value,y.operator),"reject")+"</formula>"}F+=' operator="'+y.operator+'"'}else if(y.type==="colorScale"){if(!Array.isArray(y.stops)||y.stops.length!==2&&y.stops.length!==3)throw new TypeError("Color scales require two or three stops.");const z=[],j=[];B="<colorScale>"+y.stops.map((P,q)=>(g(P,["threshold","color"],"color stop"),z.push(T(P.color)),j.push(P.threshold),m(P.threshold,q===0?"first":q===y.stops.length-1?"last":"middle"))).join("")+z.map(P=>'<color rgb="'+P+'"/>').join("")+"</colorScale>",s(j)}else if(y.type==="dataBar"){c(y.showValue,"showValue");const z=y.minimum===void 0?{type:"min"}:y.minimum,j=y.maximum===void 0?{type:"max"}:y.maximum;B='<dataBar showValue="'+(y.showValue===!1?0:1)+'">'+m(z,"first")+m(j,"last")+'<color rgb="'+T(y.color)+'"/></dataBar>',s([z,j])}else throw new TypeError("Unsupported conditional rule type.");return{target:I,type:y.type,attributes:F,body:B,...A?{style:A}:{}}})}class t{rules;constructor(p,k){const y=k.addDifferentials(p.flatMap(b=>b.style?[b.style]:[]));let w=0;this.rules=p.map((b,I)=>({target:b.target,xml:'<cfRule type="'+b.type+'" priority="'+(I+1)+'"'+(b.style?' dxfId="'+y[w++]+'"':"")+b.attributes+">"+b.body+"</cfRule>"}))}get count(){return this.rules.length}*xml(p,k,y,w){for(const b of this.rules){if(b.target.bottom!==void 0&&b.target.bottom>y)throw new RangeError("Conditional ranges must stay within exported rows.");const I=b.target.reference??u(b.target.first,b.target.last,p,k,w);I&&(yield'<conditionalFormatting sqref="'+I+'">'+b.xml+"</conditionalFormatting>")}}}return Object.freeze({prepareConditionalFormats:n,ConditionalFormats:t})})(),wt=(()=>{const{OfficeIMOError:C}=he,{checkAbort:E}=ye,{cleanXml:v,escapeOoxmlAttribute:S,escapeXml:T}=we,{fields:g,optionalBoolean:c}=Ue,{resolveDataColumn:d}=Pe,{dataRowReference:h}=Ve;function u(a,m,s){if(a!==void 0){if(typeof a!="string")throw new TypeError(s+" must be text.");if(a.length>m)throw new RangeError(s+" exceeds "+m+" UTF-16 units.");return v(a,"reject")}}function f(a,m,s=1e3,n=1e6,t){if(E(t),a===void 0)return Object.freeze({rules:Object.freeze([]),count:0,textCharacters:0});if(!Array.isArray(a))throw new TypeError("dataValidation must be an array.");const r=a.length;if(r>s)throw new C("RESOURCE_LIMIT","maxDataValidations exceeded.");const e=[],p=new Set;let k=0;const y=w=>{if(k+w>n)throw new C("RESOURCE_LIMIT","maxValidationTextCharacters exceeded.");k+=w};for(let w=0;w<r;w++){E(t);const b=a[w];g(b,["type","column","items","allowBlank","showErrorMessage","errorStyle","errorTitle","errorMessage"],"data validation");const{type:I,column:F,items:B,allowBlank:A,showErrorMessage:z,errorStyle:j,errorTitle:P,errorMessage:q}=b;if(I!=="list")throw new TypeError("Only inline-list data validation is supported.");const H=d(m,F,"Validation");if(p.has(H))throw new TypeError("A data column cannot have multiple validation rules.");if(p.add(H),c(A,"allowBlank"),c(z,"showErrorMessage"),j!==void 0&&!["stop","warning","information"].includes(j))throw new TypeError("Unsupported validation error style.");if(!Array.isArray(B))throw new TypeError("Inline validation lists require a nonempty string array.");const re=B.length;if(!re)throw new TypeError("Inline validation lists require a nonempty string array.");if(re>254)throw new RangeError("Inline validation lists must fit 255 UTF-16 units including quotes and separators.");let Q='"';for(let le=0;le<re;le++){E(t);const ee=B[le];if(typeof ee!="string")throw new TypeError("Inline validation choices must be strings.");if(ee.length>253||ee.includes(","))throw new RangeError("Inline validation choices cannot contain commas and must fit the 255-character list source.");v(ee,"reject");const M=ee.replace(/"/g,'""');if(Q.length+(le?1:0)+M.length+1>255)throw new RangeError("Inline validation lists must fit 255 UTF-16 units including quotes and separators.");Q+=(le?",":"")+M}Q+='"';const de=u(P,32,"Validation error title"),ne=u(q,255,"Validation error message");y(Q.length+(de?.length??0)+(ne?.length??0));const ue=' type="list" allowBlank="'+(A===!1?0:1)+'" showErrorMessage="'+(z===!1?0:1)+'" errorStyle="'+(j??"stop")+'"'+(de===void 0?"":' errorTitle="'+S(de,"reject")+'"')+(ne===void 0?"":' error="'+S(ne,"reject")+'"');e.push(Object.freeze({column:H,attributes:ue,formula:Q}))}return E(t),Object.freeze({rules:Object.freeze(e),count:r,textCharacters:k})}function*o(a,m,s,n){if(!(!a.count||!s||n?.length===0)){yield'<dataValidations count="'+a.count+'">';for(const t of a.rules){const r=h(t.column,t.column,m,s,n);yield"<dataValidation"+t.attributes+' sqref="'+r+'"><formula1>'+T(t.formula,"reject")+"</formula1></dataValidation>"}yield"</dataValidations>"}}return Object.freeze({prepareDataValidations:f,dataValidationsXml:o})})(),lt=(()=>{const{checkAbort:C,consumeRows:E,inputRows:v,pause:S,taskYieldDue:T}=ye,{ChunkedTextSink:g,BlobByteSink:c}=Ce,{OfficeIMOError:d}=he,{notifyProgress:h}=Qe,{copyColumns:u,createRowProjector:f}=Xe,{EntryWriter:o}=qe,{xmlDeclaration:i}=we,{officeRelationshipsNamespace:a}=Me,{Cell:m,cellText:s,columnName:n,inlineText:t,excelDate:r,copyValue:e}=ke,{spreadsheetNamespace:p,colorArgb:k,validateStylePatch:y,copyStylePatch:w}=Fe,{copyHyperlink:b,copyImage:I,hyperlinksXml:F,cellPosition:B}=_e,{ExportCell:A,assertScalar:z}=xe,{ReportLayout:j,ComputedTotal:P,printXml:q}=at,{cleanXml:H}=we,{ConditionalFormats:re,prepareConditionalFormats:Q}=pt,{isDate:de}=Se,{FormulaCell:ne,formulaXml:ue,isSubtotalFormula:le}=ze,{prepareDataValidations:ee,dataValidationsXml:M}=wt,{qualifiedCell:ie,qualifiedColumnRange:Y,resolveDataColumn:pe}=Pe,{dataRowRanges:ce,dataRowCount:R}=Ve,{captureColumnOutlines:_,columnOutlineMap:L,validateOutlinePositions:U}=nt,Z=65530;function te(fe){if(fe>Z)throw new RangeError("Excel supports at most 65,530 hyperlinks per worksheet; split the sheet.")}class N{book;table;preserved;chartData;validations;columns;project;name;declared;options;entry;completion;prepared;buffer;output=new c;started=!1;busy=!1;failed=!1;error;count=0;headerRows;layout;completedRegions;titleStyle;pending=[];pendingCharacters=0;reservedLayout=!1;internalLinks=[];links=[];linkedCells=new Set;pictures=[];nativeCharts=[];conditional;completed=!1;chartSources=[];constructor(l,x,O,D,X=!1,K=[],V=!1,se={rules:[],count:0,textCharacters:0}){this.book=l,this.table=D,this.preserved=X,this.chartData=V,this.validations=se,this.columns=u(O.columns??[],!0).map(ae=>Object.freeze(ae));const me=O.alternatingRowStyle;this.options={...O,...O.autoSize?{autoSize:{...O.autoSize}}:{},...O.mergedCells?{mergedCells:[...O.mergedCells]}:{},...O.title?{title:{...O.title,...O.title.style?{style:w(O.title.style)}:{}}}:{},...O.print?{print:{...O.print,...O.print.margins?{margins:{...O.print.margins}}:{}}}:{},...O.footer?{footer:{...O.footer,...O.footer.values?{values:O.footer.values.map(e)}:{},...O.footer.totals?{totals:{...O.footer.totals}}:{},...O.footer.style?{style:w(O.footer.style)}:{}}}:{},...me?{alternatingRowStyle:w(me)}:{}},this.layout=new j(this.columns,this.options,l.settings.invalidCharacterPolicy,l.settings.limits?.maxMergedRanges??1e4,l.settings.limits?.maxBufferedCells??1e5),this.titleStyle=O.title?l.styles.compose(l.styles.compose(0,{font:{bold:!0,size:18}}),this.options.title.style??{}):0,this.headerRows=this.layout.headerRows;for(const ae of O.hyperlinks??[]){const G=b(ae,l.settings.invalidCharacterPolicy);this.links.push(G),this.linkedCells.add(G.cell)}l.checkLinks(this.links.length),this.declared=this.columns.map((ae,G)=>({column:ae,letter:n(G+1),style:l.styles.forColumn(ae),dateStyle:l.styles.forColumn(ae,!1,void 0,!0),headerStyle:this.headerRows?O.headerStyle??l.styles.forColumn({header:ae.header,...(O.headerWrap??ae.wrapText)===void 0?{}:{wrapText:O.headerWrap??ae.wrapText},...ae.alignment===void 0?{}:{alignment:ae.alignment}},O.boldHeader!==!1,O.headerFill,!1,O.headerBorder):0})),this.conditional=new re(K,l.styles),l.retainLink(this.links.length),this.name=typeof x=="function"?x():x,this.project=f(this.columns,{sheetName:this.name,firstDataRow:this.headerRows+1},l.settings.signal,l.valueValidator)}static create(l,x,O,D,X=!1,K,V){return new N(l,x,O,D,X,K,!1,V)}static createChartData(l,x){return new N(l,x.dataSheetName,{columns:[{header:"Category"},...x.data.series.map(O=>({header:O.name,type:"number"}))]},void 0,!1,[],!0)}static validate(l,x){const O=u(x.columns??[],!0),D=ee(x.dataValidation,O,l.availableDataValidations,l.availableValidationTextCharacters,l.settings.signal);l.checkConditionalFormats(x.conditionalFormats?.length??0);const X=Q(x.conditionalFormats,O,l.settings.invalidCharacterPolicy);l.styles.checkDifferentials(X.flatMap(V=>V.style?[V.style]:[]));const K=new j(O,x,l.settings.invalidCharacterPolicy,l.settings.limits?.maxMergedRanges??1e4,l.settings.limits?.maxBufferedCells??1e5);if(l.checkMerges(K.mergeCount),x.title?.style&&y(x.title.style),x.title&&l.styles.compose(l.styles.compose(0,{font:{bold:!0,size:18}}),x.title.style??{}),x.footer?.style&&l.styles.compose(0,x.footer.style),x.hyperlinks!==void 0){if(!Array.isArray(x.hyperlinks))throw new TypeError("Hyperlinks must be an array.");te(x.hyperlinks.length);const V=new Set;for(const se of x.hyperlinks){const me=b(se,l.settings.invalidCharacterPolicy),ae=B(me.cell);if(K.regions.covered(ae.column,ae.row))throw new TypeError("Hyperlinks cannot address a covered merged cell.");if(V.has(me.cell))throw new TypeError("Duplicate hyperlink cell: "+me.cell);V.add(me.cell)}}if(O.length>16384)throw new RangeError("Excel supports at most 16,384 columns.");if(x.includeHeader===!1&&(x.freezeHeader||x.autoFilter))throw new TypeError("A frozen header or autofilter requires a header row.");if(x.headerFill!==void 0&&k(x.headerFill),x.headerWrap!==void 0&&typeof x.headerWrap!="boolean")throw new TypeError("headerWrap must be boolean.");x.headerStyle!==void 0&&l.styles.validateStyle(x.headerStyle),x.alternatingRowStyle!==void 0&&l.styles.compose(0,x.alternatingRowStyle);for(const V of[x.rowStyle,x.cellStyle,x.rowOutline])if(V!==void 0&&typeof V!="function")throw new TypeError("Row and style callbacks must be functions.");if(x.maxOutlineLevel!==void 0&&(!Number.isInteger(x.maxOutlineLevel)||x.maxOutlineLevel<0||x.maxOutlineLevel>7))throw new RangeError("Maximum outline level must be an integer from zero through seven.");if(U(x),_(x.columnOutlines,O.length),x.rowOutline&&x.maxOutlineLevel===void 0)throw new TypeError("A row outline callback requires maxOutlineLevel before streamed rows are written.");if(!x.rowOutline&&x.maxOutlineLevel!==void 0)throw new TypeError("maxOutlineLevel requires a row outline callback.");for(const V of[x.rowHeight,x.headerHeight])if(V!==void 0&&(!Number.isFinite(V)||V<=0||V>409))throw new RangeError("Row height must be positive and at most 409 points.");if(x.freezeColumns!==void 0&&(!Number.isInteger(x.freezeColumns)||x.freezeColumns<0||x.freezeColumns>O.length||x.freezeColumns>=16384))throw new RangeError("Frozen columns must be within the declared columns and leave a valid scrollable column.");if(x.table&&x.includeHeader===!1)throw new TypeError("Excel tables require a header row.");if(x.defaultColumnWidth!==void 0&&(!Number.isFinite(x.defaultColumnWidth)||x.defaultColumnWidth<0||x.defaultColumnWidth>255))throw new RangeError("Default column width must be from 0 through 255 characters.");for(const V of O){if(V.width!==void 0&&(!Number.isFinite(V.width)||V.width<0||V.width>255))throw new RangeError("Column width must be from 0 through 255 characters.");if(V.type!==void 0&&!["string","number","boolean","date"].includes(V.type)&&!l.writerFor(V.type))throw new TypeError("Invalid column type: "+V.type);if(V.alignment!==void 0&&!["left","center","right","fill","justify","distributed"].includes(V.alignment))throw new TypeError("Invalid horizontal alignment.");if(s(V.header,l.settings.invalidCharacterPolicy),V.style!==void 0&&l.styles.validateStyle(V.style),V.format!==void 0&&(typeof V.format!="string"||V.format.length>255))throw new TypeError("Column format must be a string of at most 255 characters.")}return{conditional:X,validations:D}}cell(l,x,O,D=!1,X,K,V,se=!1,me=!1,ae=!0){const G=this.declared[x],W=l instanceof P?l:void 0;W&&(l=W.value);let $=l instanceof ne?l:void 0;$&&(l=$.cachedValue);let oe=l instanceof A?l.presentation:void 0,Re=l instanceof A?l.link:void 0;l instanceof A&&(l=l.value);const Oe=$?.style??(l instanceof m?l.style:void 0),Ae=(this.completedRegions??this.layout.regions).covered(x+1,O),Ye=l instanceof m?l.value:l,dt=Ae&&(Ye==null||Ye==="");if(!D&&!se&&G.column.type&&!dt){const Te=this.book.writerFor(G.column.type);if(Te){if($)throw new TypeError("An explicit FormulaCell cannot also pass through a custom cell value writer; return it from the writer instead.");l=Te(l instanceof m?l.value:l,{column:G.column,rowIndex:O-this.headerRows-1,worksheetRow:O,columnIndex:x,sheetName:this.name})}}l instanceof ne&&($=l,l=$.cachedValue),l instanceof A&&(oe=l.presentation,Re=l.link,l=l.value);const Ie=$?.style??(l instanceof m?l.style??Oe:Oe);if(l instanceof m&&(l=l.value),z(l),Ae){if(Re)throw new TypeError("Hyperlinks cannot address a covered merged cell.");if($||W||l!=null&&l!=="")throw new TypeError("A merged range would hide the value at "+G.letter+O+"; covered cells must be empty.");l=void 0}const Ee=de(l)?"date":typeof l;if(!D&&!se&&l!=null&&G.column.type&&!this.book.writerFor(G.column.type)&&G.column.type!==Ee)throw new TypeError("Cell "+G.letter+O+" does not match column type "+G.column.type+".");let ge=Ie===void 0?D?G.headerStyle:W?.operation==="count"?0:Ee==="date"?G.dateStyle:G.style:this.book.styles.validateStyle(Ie);if(D&&Ee==="date"&&Ie===void 0&&this.options.headerStyle===void 0&&(ge=this.book.styles.dateHeader(ge,G.dateStyle)),me&&(ge=this.titleStyle),!D&&!se){if(Ie===void 0){const je=ge,Ke=V?.get(je);Ke!==void 0?ge=Ke:((O-this.headerRows)%2===0&&this.options.alternatingRowStyle&&(ge=this.book.styles.compose(ge,this.options.alternatingRowStyle)),X!==void 0&&(ge=this.book.styles.compose(ge,X)),V?.set(je,ge))}const Te=K&&this.options.cellStyle?.({...K,value:l,column:G.column,columnIndex:x});Te!==void 0&&(ge=this.book.styles.compose(ge,Te))}se&&this.options.footer?.style&&Ie===void 0&&(ge=this.book.styles.compose(ge,this.options.footer.style)),oe&&Ie===void 0&&(ge=this.book.styles.compose(ge,{...oe.background===void 0?{}:{fill:{color:oe.background}},...oe.color===void 0&&oe.bold===void 0&&oe.italic===void 0?{}:{font:{...oe.color===void 0?{}:{color:oe.color},...oe.bold===void 0?{}:{bold:oe.bold},...oe.italic===void 0?{}:{italic:oe.italic}}},...oe.wrapText===void 0?{}:{wrapText:oe.wrapText},...oe.alignment===void 0?{}:{alignment:oe.alignment},...oe.numberFormat===void 0?{}:{numberFormat:oe.numberFormat}}));const Je=typeof l=="string"?l.length:0;let De=this.preserved||D||se?Je:void 0;if(Ee==="string"&&Je>32767&&H(l,this.book.settings.invalidCharacterPolicy).length>32767){const Te=G.letter+O;if(Re||this.linkedCells.has(Te))throw new TypeError("A text-preservation cell cannot also have an external hyperlink.");te(this.links.length+this.internalLinks.length+1),this.book.checkLinks(1),De!==void 0&&(this.book.budget.release(1,De),De=void 0);const je=this.book.preserveText(this.name,Te,l);this.book.retainLink(),this.internalLinks.push({cell:Te,location:je.location}),this.linkedCells.add(Te),l=je.preview}if(Re&&this.appendHyperlink({cell:G.letter+O,...Re}),Ee==="date"&&(l=r(l,this.book.settings.dateMode)),!D&&!se&&ae&&(!$||!le($))&&this.layout.accept(x,l),!D&&!se&&this.chartSources.length)for(const Te of this.chartSources)Te.observe(O-this.headerRows-1,x+1,l);const ve='<c r="'+G.letter+O+'" s="'+ge+'"';if($&&this.book.retainFormula($.formula.length),this.book.budget.cell($?$.formula:l,De),$)return ve+(l===null?' t="str"':"")+">"+ue($)+"</c>";if(W)return ve+(l===null?' t="str"':"")+"><f>"+W.formula.replace(/"/g,"&quot;")+"</f><v>"+(l??"")+"</v></c>";if(l==null||Ee==="number"&&!Number.isFinite(l)||l==null)return ve+"/>";if(Ee==="string")return ve+' t="inlineStr"><is>'+t(l,this.book.settings.invalidCharacterPolicy)+"</is></c>";if(Ee==="boolean")return ve+' t="b"><v>'+(l?1:0)+"</v></c>";if(Ee!=="number"&&Ee!=="date")throw new TypeError("Excel cells must be strings, numbers, booleans, Dates or null.");return ve+"><v>"+l+"</v></c>"}*rowXml(l,x,O,D=!1,X=!1){const K=X?this.options.title?.height??28:O?this.options.headerHeight:this.options.rowHeight,V=!O&&!D&&(this.options.rowStyle||this.options.cellStyle||this.options.rowOutline)?Object.freeze({rowIndex:x-this.headerRows-1,worksheetRow:x,sheetName:this.name,values:Object.freeze(this.columns.map((G,W)=>l[W]instanceof ne?l[W].cachedValue:l[W]instanceof m||l[W]instanceof A?l[W].value:l[W]))}):void 0,se=V&&this.options.rowStyle?.(V);se!==void 0&&y(se);const me=this.outline(V),ae=!O&&(se||this.options.alternatingRowStyle)?new Map:void 0;yield'<row r="'+x+'"'+(K===void 0?"":' ht="'+K+'" customHeight="1"')+(me?.level?' outlineLevel="'+me.level+'"':"")+(me?.hidden?' hidden="1"':"")+(me?.collapsed?' collapsed="1"':"")+">";for(let G=0;G<this.columns.length;G++)yield this.cell(l[G],G,x,O,se,V,ae,D,X,me?.hidden!==!0);yield"</row>"}outline(l){if(!l||!this.options.rowOutline)return;const x=this.options.rowOutline(l);if(x===void 0)return;if(x===null||typeof x!="object"||Array.isArray(x))throw new TypeError("Row outline callbacks must return metadata or undefined.");if(typeof x.then=="function")throw Promise.resolve(x).catch(()=>{}),new TypeError("Row outline callbacks must return synchronous metadata.");const{level:O,hidden:D,collapsed:X}=x,K=O??0;if(!Number.isInteger(K)||K<0||K>this.options.maxOutlineLevel)throw new RangeError("Row outline level exceeds the declared maximum.");for(const V of[D,X])if(V!==void 0&&typeof V!="boolean")throw new TypeError("Row outline flags must be booleans.");return Object.freeze({level:K,...D===void 0?{}:{hidden:D},...X===void 0?{}:{collapsed:X}})}writeRow(l,x,O,D=!1,X=!1){const K=this.rowXml(l,x,O,D,X),V=()=>{for(;;){const se=K.next();if(se.done)return;if(this.buffer.append(se.value))return this.buffer.flush().then(V)}};return V()}async sampleRow(l){if((this.pending.length+1)*this.columns.length>(this.book.settings.limits?.maxBufferedCells??1e5))throw new d("RESOURCE_LIMIT","Width sampling cell limit exceeded; reduce sampleRows or raise its bounded limit.");const x=[];let O=0;for(const D of this.rowXml(l,this.count+this.headerRows+1,!1)){if(!this.started&&this.pendingCharacters+D.length>(this.book.settings.limits?.maxBufferedCharacters??1e6)){if(this.options.autoSize?.sampleRows!==void 0)throw new d("RESOURCE_LIMIT","Width sampling text limit exceeded; reduce sampleRows or raise its bounded limit.");this.layout.sample(l),await this.start();for(const X of x)this.buffer.append(X)&&await this.buffer.flush();x.length=0}this.started?this.buffer.append(D)&&await this.buffer.flush():(this.pendingCharacters+=D.length,x.push(D)),!this.started&&(++O&127)===0&&T()&&(await S(),C(this.book.settings.signal))}this.started||(this.layout.sample(l),this.pending.push(x))}reserveLayout(){if(!this.reservedLayout){if(!this.preserved){let l=0;if(this.options.title&&(l+=this.options.title.text.length),this.layout.firstHeaderRow)for(const x of this.layout.headings)for(const O of x){const D=O instanceof A||O instanceof m?O.value:O;typeof D=="string"&&(l+=D.length)}if(this.layout.structuredFooter)for(const x of this.layout.structuredFooter.values)for(const O of x){const D=O instanceof A?O.value:O;typeof D=="string"&&(l+=D.length)}else if(this.options.footer)for(let x=0;x<this.columns.length;x++){const O=this.columns[x],D=this.options.footer.totals;if(D&&Object.prototype.hasOwnProperty.call(D,O.key??O.header))continue;const X=this.options.footer.values?.[x],K=X instanceof A||X instanceof m?X.value:X;typeof K=="string"&&(l+=K.length)}this.book.budget.reserve(this.columns.length*(this.headerRows+this.layout.footerRows),l)}this.reservedLayout=!0}}async start(){if(this.started)return;this.reserveLayout(),this.started=!0,this.entry=this.book.settings.sink?await this.book.openSheet(this):new o(this.book.settings.compression,{write:G=>{this.book.retainBufferedBytes(G.length),this.output.write(G)}},this.book.settings.signal);const l=this.buffer=new g(this.entry,this.book.settings.signal),x=this.options,O=x.freezeColumns??0,D=x.freezeHeader?this.headerRows:0,X=O&&D?"bottomRight":O?"topRight":"bottomLeft",K=n(O+1)+(D+1),V=L(x.columnOutlines),se=!!x.rowOutline||V.size>0,me=Math.max(0,...Array.from(V.values(),G=>G.level??0));await l.write(i+'<worksheet xmlns="'+p+'" xmlns:r="'+a+'">'+(x.print||se?"<sheetPr>"+(se?'<outlinePr summaryBelow="'+(x.outlineSummaryBelow===!1?"0":"1")+'"'+(x.outlineSummaryRight===void 0?"":' summaryRight="'+(x.outlineSummaryRight?"1":"0")+'"')+' showOutlineSymbols="1"/>':"")+(x.print?'<pageSetUpPr fitToPage="1"/>':"")+"</sheetPr>":"")+'<sheetViews><sheetView workbookViewId="0">'+(O||D?"<pane"+(O?' xSplit="'+O+'"':"")+(D?' ySplit="'+D+'"':"")+' topLeftCell="'+K+'" activePane="'+X+'" state="frozen"/><selection pane="'+X+'" activeCell="'+K+'" sqref="'+K+'"/>':"")+"</sheetView></sheetViews>"+(se?'<sheetFormatPr defaultRowHeight="15"'+(x.rowOutline?' outlineLevelRow="'+x.maxOutlineLevel+'"':"")+(V.size?' outlineLevelCol="'+me+'"':"")+"/>":""));const ae=x.defaultColumnWidth??(this.table?20:void 0);if(this.columns.some((G,W)=>this.layout.widths[W]!==void 0||ae!==void 0||V.has(W))){await l.write("<cols>");for(let G=0;G<this.columns.length;G++){const W=this.layout.widths[G]??ae,$=V.get(G);(W!==void 0||$)&&await l.write('<col min="'+(G+1)+'" max="'+(G+1)+'"'+(W===void 0?"":' width="'+W+'" customWidth="1"')+($?.level?' outlineLevel="'+$.level+'"':"")+($?.hidden?' hidden="1"':"")+($?.collapsed?' collapsed="1"':"")+"/>")}await l.write("</cols>")}if(await l.write("<sheetData>"),x.title&&await this.writeRow(this.columns.map((G,W)=>W?"":x.title.text),1,!0,!1,!0),this.layout.firstHeaderRow)for(let G=0;G<this.layout.headings.length;G++)await this.writeRow(this.layout.headings[G],G+this.layout.firstHeaderRow,!0);for(const G of this.pending)for(const W of G)l.append(W)&&await l.flush();this.pending=[],this.pendingCharacters=0}async addRows(l){if(this.book.assertOpen(),this.completion)throw new d("INVALID_STATE","Worksheet is closed.");if(this.busy)throw new d("INVALID_STATE","Await the current addRows call before writing more rows to this sheet.");if(this.failed)throw this.error;this.busy=!0;try{this.reserveLayout(),this.layout.sampleRows||await this.start();let x=performance.now();const O=()=>{performance.now()-x>=50&&(this.progress(),x=performance.now())},D=()=>{if(this.count++,!this.started&&this.pending.length>=this.layout.sampleRows)return this.start().then(O);if(!this.started&&T())return S().then(()=>{C(this.book.settings.signal),O()});O()};await E(l,this.book.settings.signal,X=>{if(this.count+this.headerRows+this.layout.footerRows>=1048576)throw new RangeError("Excel supports at most 1,048,576 rows including headers and footers; split the sheet.");if(this.book.budget.row(this.count+1),!this.columns.length)throw new RangeError("Declare columns before adding rows.");const K=this.project(X,this.count),V=this.started?this.writeRow(K,this.count+this.headerRows+1,!1):this.sampleRow(K);return V?V.then(D):D()}),this.buffer&&await this.buffer.flush(),this.progress(),C(this.book.settings.signal)}catch(x){throw this.failed=!0,this.error=x,await this.book.discard(x),x}finally{this.busy=!1}}progress(){!this.preserved&&!this.chartData&&h(this.book.settings.onProgress,{phase:"rows",rows:this.book.rowCount,sheetRows:this.reportRowCount,sheetName:this.name})}get rowCount(){return this.count}dataRange(l){if(this.failed)throw this.error;if(!this.completed)throw new d("INVALID_STATE","Close the worksheet before resolving its data range.");const x=pe(this.columns,l),O=ce(this);if(O!==void 0){if(O.length>1)throw new d("INVALID_STATE","Grouped details are discontiguous; use the grouped result's detailRanges for explicit formula references.");const D=O[0];return D?Y(this.name,x,D.firstRow,D.lastRow-D.firstRow+1):void 0}return this.count?Y(this.name,x,this.headerRows+1,this.count):void 0}get chartBindingMetadata(){const l=this.layout.headings.at(-1);return{name:this.name,columns:this.columns,headerRows:this.headerRows,rows:this.count,closed:this.completed||!!this.completion,headerReferences:this.columns.map((x,O)=>{const D=l?.[O],X=D instanceof A?D.value:D;return this.layout.firstHeaderRow&&X===x.header&&!this.layout.regions.covered(O+1,this.headerRows)?ie(this.name,O+1,this.headerRows):void 0})}}retainChartBinding(l){this.chartSources.push(l)}get reportRowCount(){return this.preserved||this.chartData?0:R(this,this.headerRows,this.count)}get hidden(){return this.chartData}addChart(l){if(this.book.assertOpen(),this.completion)throw new d("INVALID_STATE","Worksheet is closed.");if(this.failed)throw this.error;this.nativeCharts.push(this.book.registerChart(l))}get charts(){return this.nativeCharts}releaseCharts(){this.nativeCharts.length=0}addImage(l){if(this.book.assertOpen(),this.completion)throw new d("INVALID_STATE","Worksheet is closed.");if(this.failed)throw this.error;const x=I(l,this.book.settings.invalidCharacterPolicy,O=>this.book.checkImage(O));this.book.retainImage(x.data.length),this.pictures.push(x)}addHyperlink(l){if(this.book.assertOpen(),this.completion)throw new d("INVALID_STATE","Worksheet is closed.");if(this.failed)throw this.error;this.appendHyperlink(l)}appendHyperlink(l){const x=b(l,this.book.settings.invalidCharacterPolicy),O=B(x.cell);if(this.layout.regions.covered(O.column,O.row))throw new TypeError("Hyperlinks cannot address a covered merged cell.");if(this.linkedCells.has(x.cell))throw new TypeError("Duplicate hyperlink cell: "+x.cell);te(this.links.length+this.internalLinks.length+1),this.book.retainLink(),this.links.push(x),this.linkedCells.add(x.cell)}get hyperlinks(){return this.links}get images(){return this.pictures}get tableDefinition(){return this.count?this.table:void 0}get isBusy(){return this.busy}get headerRowCount(){return this.headerRows}get firstHeaderRow(){return this.layout.firstHeaderRow}get mergeCount(){return this.layout.mergeCount}get conditionalFormatCount(){return this.conditional.count}get dataValidations(){return this.validations}get totalRows(){return Math.max(1,this.headerRows+this.count+this.layout.footerRows)}get lastColumn(){return n(Math.max(1,this.columns.length))}get printSettings(){return this.options.print}get footerSettings(){return this.layout.structuredFooter?void 0:this.options.footer}async close(){if(this.book.assertOpen(),this.busy)throw new d("INVALID_STATE","Await addRows before closing the worksheet.");try{await this.finish()}catch(l){throw await this.book.discard(l),l}}finish(l){if(this.completion)return this.completion;if(this.failed)throw this.error;return this.completion=(async()=>{try{const x=this.completedRegions=this.layout.finalRegions(this.count,this.book.settings.limits?.maxMergedRanges??1e4);x.validateRows(this.totalRows);for(const X of this.chartSources)X.finish();this.chartSources.length=0;for(const X of this.links){const K=B(X.cell);if(K.column>this.columns.length||K.row>this.totalRows)throw new RangeError("Hyperlinks must address cells within the exported rows and columns.");if(x.covered(K.column,K.row))throw new TypeError("Hyperlinks cannot address a covered merged cell.")}if(await this.start(),l)for await(const X of v(l,this.book.settings.signal))this.book.budget.row(this.count+1),await this.writeRow(this.project(X,this.count),this.headerRows+this.count+1,!1),this.count++;if(this.layout.structuredFooter)for(let X=0;X<this.layout.footerRows;X++)await this.writeRow(this.layout.structuredFooter.values[X],this.headerRows+this.count+X+1,!1,!0);else this.options.footer&&await this.writeRow(this.layout.footer(this.count),this.headerRows+this.count+1,!1,!0);await this.buffer.write("</sheetData>"),this.options.autoFilter&&this.headerRows&&!this.tableDefinition&&await this.buffer.write('<autoFilter ref="A'+this.headerRows+":"+n(this.columns.length)+(this.count+this.headerRows)+'"/>'),x.references.length&&await this.buffer.write('<mergeCells count="'+x.references.length+'">'+x.references.map(X=>'<mergeCell ref="'+X+'"/>').join("")+"</mergeCells>");const O=ce(this);for(const X of this.conditional.xml(this.headerRows,this.count,this.totalRows,O))await this.buffer.write(X);for(const X of M(this.validations,this.headerRows,this.count,O))await this.buffer.write(X);(this.links.length||this.internalLinks.length)&&await this.buffer.write(F(this.links,this.book.settings.invalidCharacterPolicy,this.internalLinks)),await this.buffer.write(q(this.options.print,this.book.settings.invalidCharacterPolicy)),(this.pictures.length||this.nativeCharts.length)&&await this.buffer.write('<drawing r:id="drawing"/>'),this.tableDefinition&&await this.buffer.write('<tableParts count="1"><tablePart r:id="table"/></tableParts>'),await this.buffer.write("</worksheet>"),await this.buffer.close();const D=await this.entry.close();!this.book.settings.sink&&!this.failed&&(this.prepared={...D,chunks:this.output.takeChunks()}),this.completed=!0}catch(x){throw await this.discard(x),x}})()}takePrepared(){const l=this.prepared;return this.prepared=void 0,l}async discard(l){this.failed=!0,this.error=l,this.pending=[],this.pendingCharacters=0,this.prepared=void 0,this.buffer=void 0,this.nativeCharts.length=0,this.chartSources.length=0,this.output.discard(),await this.entry?.discard(l)}}return Object.freeze({Worksheet:N})})(),gt=(()=>{const{escapeOoxmlAttribute:C,escapeXml:E,xmlDeclaration:v}=we,{cellText:S,columnName:T}=ke,{spreadsheetNamespace:g}=Fe,{ExportCell:c}=xe,{Cell:d}=ke,{totalFormula:h}=at;function u(i,a,m,s){const n=a.name??"Table"+i;if(typeof n!="string"||n.length>255||!/^[A-Za-z_][A-Za-z0-9_.]*$/.test(n)||/^(?:[A-Za-z]{1,3}[1-9][0-9]*|R[1-9][0-9]*C[1-9][0-9]*|R|C)$/i.test(n))throw new TypeError("Table names must be ASCII identifiers, at most 255 characters, and cannot be cell references.");const t=a.style??"TableStyleMedium2",r=/^TableStyle(Light|Medium|Dark)([1-9][0-9]?)$/.exec(t);if(!r||Number(r[2])>({Light:21,Medium:28,Dark:11}[r[1]]??0))throw new TypeError("Unknown built-in Excel table style.");const e=m.map(p=>S(p.header,s));if(!e.length||e.some(p=>!p.trim()||p.length>255)||new Set(e.map(p=>p.toLowerCase())).size!==e.length)throw new TypeError("Excel tables require nonblank, unique headers of at most 255 characters.");return Object.freeze({id:i,name:n,headers:Object.freeze(e),keys:Object.freeze(m.map(p=>p.key??p.header)),options:Object.freeze({...a,style:t})})}function f(i,a,m,s=1,n){const t="A"+s+":"+T(i.headers.length)+(a+s),r="A"+s+":"+T(i.headers.length)+(a+s+(n?1:0)),e=i.options,p=C(i.name,m);return v+'<table xmlns="'+g+'" id="'+i.id+'" name="'+p+'" displayName="'+p+'" ref="'+r+'"'+(n?' totalsRowCount="1"':' totalsRowShown="0"')+'><autoFilter ref="'+t+'"/><tableColumns count="'+i.headers.length+'">'+i.headers.map((k,y)=>{const w=i.keys[y],b=n?.totals&&Object.prototype.hasOwnProperty.call(n.totals,w)?n.totals[w]:void 0,I=n?.values?.[y],F=I instanceof d||I instanceof c?I.value:I,B=b&&["average","min","max"].includes(b),A=b?' totalsRowFunction="'+(B?"custom":b==="count"?"countNums":b)+'"':typeof F=="string"?' totalsRowLabel="'+C(F,m)+'"':"";return'<tableColumn id="'+(y+1)+'" name="'+C(k,m)+'"'+A+(B?"><totalsRowFormula>"+E(h(b,T(y+1),s,a),m)+"</totalsRowFormula></tableColumn>":"/>")}).join("")+'</tableColumns><tableStyleInfo name="'+e.style+'" showFirstColumn="'+(e.firstColumn?1:0)+'" showLastColumn="'+(e.lastColumn?1:0)+'" showRowStripes="'+(e.bandedRows!==!1?1:0)+'" showColumnStripes="'+(e.bandedColumns?1:0)+'"/></table>'}return Object.freeze({defineTable:u,tableXml:f})})(),yt=(()=>{const{OfficeIMOError:C}=he,{cleanXml:E}=we;class v{sheetName;maximum;policy;reserve;entries=[];characters=0;rows=0;constructor(d,h,u,f){this.sheetName=d,this.maximum=h,this.policy=u,this.reserve=f}add(d,h,u){const f=E(u,this.policy);if(this.characters+f.length>this.maximum)throw new C("RESOURCE_LIMIT","maxOverflowCharacters exceeded; use CSV or raise the bounded preservation limit.");let o=0;for(const m of T(f))o++;if(this.rows+o>1048575)throw new C("RESOURCE_LIMIT","Text overflow exceeds the worksheet row limit.");this.reserve(o*5,f.length+o*(d.length+h.length),this.rows+o);const i=this.rows+2;this.entries.push({sheet:d,cell:h,text:f,first:i,parts:o}),this.rows+=o,this.characters+=f.length;const a="\n[Full text: "+this.sheetName+"!D"+i+"; "+o+" parts]";return{preview:S(f,32767-a.length)+a,location:"'"+this.sheetName.replace(/'/g,"''")+"'!D"+i}}*values(){for(const d of this.entries){let h=0;for(const u of T(d.text))yield[d.sheet,d.cell,++h,u,d.parts]}}clear(){this.entries=[],this.characters=0,this.rows=0}}function S(c,d){let h=Math.min(d,c.length);return h<c.length&&/[\ud800-\udbff]/.test(c[h-1]??"")&&h--,c.slice(0,h)}function*T(c){let d=0;for(;d<c.length;){const h=S(c.slice(d,d+32768),32767);d+=h.length,yield h}}return Object.freeze({TextOverflow:v,clipText:S})})(),Le=(()=>{const{captureFields:C}=be,E=["signal","onProgress","limits","sink","dateMode","compression","invalidCharacterPolicy","appProperties","cellValueWriters","oversizedText","creator","title","subject","description","created","modified"],v=["columns","includeHeader","headerRows","freezeHeader","autoFilter","boldHeader","headerFill","headerBorder","headerWrap","headerStyle","alternatingRowStyle","rowStyle","cellStyle","rowOutline","maxOutlineLevel","outlineSummaryBelow","outlineSummaryRight","columnOutlines","rowHeight","headerHeight","defaultColumnWidth","freezeColumns","table","autoSize","footer","print","title","mergedCells","hyperlinks","conditionalFormats","dataValidation"],S=["maxRows","maxCells","maxTextCharacters","maxOutputBytes","maxStyles","maxSheets","maxOverflowCharacters","maxHyperlinks","maxImageBytes","maxBufferedCells","maxBufferedCharacters","maxMergedRanges","maxConditionalFormats","maxDifferentialStyles","maxCharts","maxChartPoints","maxChartTextCharacters","maxFormulaCharacters","maxDataValidations","maxValidationTextCharacters"];function T(d){return C(d,S)}function g(d){const h=C(d,E);return{...h,...h.limits===void 0?{}:{limits:T(h.limits)}}}return Object.freeze({workbookOptionFields:E,sheetOptionFields:v,workbookLimitFields:S,captureWorkbookLimits:T,captureWorkbookOptions:g})})(),bt=(()=>{const{checkAbort:C}=ye,{NotSupportedError:E,OfficeIMOError:v}=he,{cleanXml:S}=we,{captureFields:T}=be;function g(f,o,i){if(!f||typeof f!="object"||Array.isArray(f))throw new TypeError(i+" must be an object.");for(const a of Object.keys(f))if(!o.includes(a))throw new E(i+"."+a);return T(f,o)}function c(f){if(typeof f=="string"?!f.length:typeof f!="number"||!Number.isInteger(f)||f<1||f>16384)throw new TypeError("Chart columns require a declared key or a one-based column number.")}function d(f){const o=g(f,["kind","sheet","firstRow","rowCount","categoryColumn","series"],"chart.data");if(o.kind!=="range")throw new TypeError("A chart range must declare kind: range.");if(!o.sheet||typeof o.sheet!="object"||Array.isArray(o.sheet))throw new TypeError("A chart range needs its owning worksheet.");const i=o.firstRow===void 0?0:o.firstRow,a=o.rowCount;if(!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(a)||a<1||i+a>1048576)throw new RangeError("Chart data rows must form a nonempty finite Excel range.");if(c(o.categoryColumn),!Array.isArray(o.series)||o.series.length<1||o.series.length>255)throw new RangeError("A chart needs from 1 through 255 series.");const m=o.series.map(s=>{const n=g(s,["column","name","color"],"chart.data.series");if(c(n.column),n.name!==void 0&&typeof n.name!="string")throw new TypeError("Chart series name must be a string.");if(n.color!==void 0&&(typeof n.color!="string"||!/^#?[0-9a-fA-F]{6}$/.test(n.color)))throw new TypeError("Chart colors must be opaque six-digit RGB hex values.");return Object.freeze(n)});return Object.freeze({kind:"range",sheet:o.sheet,firstRow:i,rowCount:a,categoryColumn:o.categoryColumn,series:Object.freeze(m)})}function h(f,o,i,a,m="columnClustered"){C(a);const s=f.rowCount,n=f.firstRow??0,t=s*f.series.length,r=o.categoryColumn;if(t>i.availablePoints)throw new v("RESOURCE_LIMIT","maxChartPoints exceeded.");if(o.source!==f.sheet||!Number.isInteger(o.headerRows)||o.headerRows<0||o.headerRows+n+s>1048576||o.seriesColumns.length!==f.series.length||o.seriesNames.length!==f.series.length||o.valueFormulas.length!==f.series.length||o.nameFormulas.length!==f.series.length)throw new TypeError("Resolved chart range does not match its declared columns and data rows.");for(const P of[o.categoryColumn,...o.seriesColumns])if(!Number.isInteger(P)||P<1||P>16384)throw new RangeError("Resolved chart columns must be one-based Excel columns.");if(o.seriesColumns.includes(r))throw new TypeError("Chart category and numeric series must use different columns.");let e=0;const p=f.series.map((P,q)=>{const H=P.name??o.seriesNames[q];if(typeof H!="string"||H.length>32767)throw new TypeError("Chart series names must fit Excel text cells.");if(e+=H.length,e>i.availableText)throw new v("RESOURCE_LIMIT","maxChartTextCharacters exceeded.");return S(H,i.policy)}),k=f.series.map(P=>P.color?.replace(/^#/,"").toUpperCase()),y=new Array(s),w=f.series.map(()=>new Array(s)),b=f.series.map(()=>0),I=f.series.map(()=>!1);let F=0,B;const A=()=>{if(C(a),!B){if(F!==s||b.some(P=>P!==s))throw new TypeError("Chart range did not receive every declared data row and numeric value.");if(m==="pie"&&!I[0])throw new RangeError("A pie chart needs at least one positive value.");B=Object.freeze({categories:Object.freeze(y),series:Object.freeze(w.map((P,q)=>Object.freeze({name:p[q],values:Object.freeze(P),...k[q]===void 0?{}:{color:k[q]}})))})}},z=Object.freeze({get categories(){return A(),B.categories},get series(){return A(),B.series}}),j=new Map;return o.seriesColumns.forEach((P,q)=>{const H=j.get(P)??[];H.push(q),j.set(P,H)}),Object.freeze({source:o.source,points:t,textCharacters:e,data:z,references:Object.freeze({categories:o.categoryFormula,values:Object.freeze([...o.valueFormulas]),names:Object.freeze(o.nameFormulas.map((P,q)=>f.series[q].name===void 0?P:void 0))}),observe(P,q,H){C(a);const re=P-n;if(!(re<0||re>=s)){if(B)throw new v("INVALID_STATE","Chart cache is already finalized.");if(q===r){if(typeof H!="string"||H.length>32767)throw new TypeError("Chart category cells must contain strings of at most 32,767 UTF-16 units.");if(y[re]!==void 0)throw new v("INVALID_STATE","A chart category cell was observed more than once.");i.retainText(H.length),y[re]=S(H,i.policy),F++}for(const Q of j.get(q)??[]){if(typeof H!="number"||!Number.isFinite(H))throw new TypeError("Chart series cells require finite numbers or numeric formula caches.");if(m==="pie"&&H<0)throw new RangeError("Pie charts require nonnegative values.");if(w[Q][re]!==void 0)throw new v("INVALID_STATE","A chart value cell was observed more than once.");w[Q][re]=H,b[Q]=b[Q]+1,H>0&&(I[Q]=!0)}}},finish:A})}return Object.freeze({captureChartRange:d,prepareChartBinding:h})})(),xt=(()=>{const{checkAbort:C}=ye,{NotSupportedError:E,OfficeIMOError:v}=he,{cleanXml:S}=we,{copyDrawingAnchor:T}=_e,{captureFields:g}=be,{captureChartRange:c,prepareChartBinding:d}=bt;function h(i,a,m){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(m+" must be an object.");for(const s of Object.keys(i))if(!a.includes(s))throw new E(m+"."+s)}function u(i,a,m){return h(i,a,m),g(i,a)}function f(i,a,m,s,n,t){if(C(n),i=u(i,["type","data","row","column","width","height","description","title","language","legend","dataLabels","categoryAxis","valueAxis"],"chart"),!["columnClustered","barClustered","line","pie"].includes(i.type))throw new E("chart type "+i.type);const r=i.type,e=u(i.data,["kind","sheet","firstRow","rowCount","categoryColumn","categories","series"],"chart.data"),p=e.kind==="range"?c(e):void 0;p||h(e,["categories","series"],"chart.data");const k=p?void 0:e.categories,y=p?.series??e.series;if(!p&&!Array.isArray(k))throw new TypeError("Chart categories must be a nonempty array of strings.");if(!Array.isArray(y))throw new RangeError("A chart needs from 1 through 255 series.");const w=p?.rowCount??k.length,b=y.length;if(!w)throw new TypeError("Chart categories must be a nonempty array of strings.");if(!b||b>255)throw new RangeError("A chart needs from 1 through 255 series.");if(!p&&w>1048575)throw new RangeError("Chart data must fit Excel's rows including its header.");if(r==="pie"&&b!==1)throw new TypeError("A pie chart supports exactly one series.");const I=w*b;if(I>m)throw new v("RESOURCE_LIMIT","maxChartPoints exceeded.");let F=0;const B=(M,ie)=>{if(typeof M!="string")throw new TypeError(ie+" must be a string.");if(M.length>32767)throw new RangeError(ie+" exceeds 32,767 UTF-16 units.");if(F+=M.length,F>s)throw new v("RESOURCE_LIMIT","maxChartTextCharacters exceeded.");return S(M,a)},A=(M,ie)=>M===void 0?void 0:B(M,ie),z=A(i.title,"Chart title"),j=A(i.description,"Chart description"),P=A(i.language,"Chart language");let q;if(P!==void 0)try{if(q=Intl.getCanonicalLocales(P)[0],!q)throw new RangeError}catch{throw new TypeError("Chart language must be a language tag such as pl or pl-PL.")}const H=T({row:i.row,column:i.column,width:i.width,height:i.height,...j===void 0?{}:{description:j}},a);if(i.legend!==void 0&&i.legend!==!1&&!["right","bottom","left","top"].includes(i.legend))throw new TypeError("Unsupported chart legend position.");let re;if(i.dataLabels!==void 0){const M=u(i.dataLabels,["showValue","showCategoryName","showSeriesName","showPercent","position","numberFormat"],"chart.dataLabels");for(const pe of["showValue","showCategoryName","showSeriesName","showPercent"])if(M[pe]!==void 0&&typeof M[pe]!="boolean")throw new TypeError("Chart label flags must be booleans.");if(M.showPercent&&r!=="pie")throw new TypeError("Percent data labels require a pie chart.");const ie=r==="pie"?["center","insideEnd","outsideEnd","bestFit"]:r==="line"?["center","above","below","left","right"]:["center","insideEnd","outsideEnd"];if(M.position!==void 0&&!ie.includes(M.position))throw new TypeError("Data label position is unsupported for this chart type.");const Y=A(M.numberFormat,"Data label number format");if(Y!==void 0&&!Y.trim())throw new TypeError("Data label number format cannot be blank.");re=Object.freeze({...M,...Y===void 0?{}:{numberFormat:Y}})}if(r==="pie"&&(i.categoryAxis!==void 0||i.valueAxis!==void 0))throw new TypeError("Pie charts have no axes.");let Q,de;if(i.categoryAxis!==void 0){const M=A(u(i.categoryAxis,["title"],"chart.categoryAxis").title,"Category axis title");Q=Object.freeze(M===void 0?{}:{title:M})}if(i.valueAxis!==void 0){const M=u(i.valueAxis,["title","minimum","maximum","numberFormat"],"chart.valueAxis");for(const pe of[M.minimum,M.maximum])if(pe!==void 0&&!Number.isFinite(pe))throw new TypeError("Chart axis bounds must be finite numbers.");if(M.minimum!==void 0&&M.maximum!==void 0&&M.minimum>=M.maximum)throw new RangeError("Chart axis minimum must be below its maximum.");const ie=A(M.title,"Value axis title"),Y=A(M.numberFormat,"Value axis number format");if(Y!==void 0&&!Y.trim())throw new TypeError("Value axis number format cannot be blank.");de=Object.freeze({...M,...ie===void 0?{}:{title:ie},...Y===void 0?{}:{numberFormat:Y}})}const ne={...H,type:r,...q===void 0?{}:{language:q},...z===void 0?{}:{title:z},...j===void 0?{}:{description:j},...i.legend===void 0?{}:{legend:i.legend},...re===void 0?{}:{dataLabels:re},...Q===void 0?{}:{categoryAxis:Q},...de===void 0?{}:{valueAxis:de}};if(p){if(!t)throw new TypeError("A chart range must belong to the current workbook.");const{descriptor:M,retainText:ie}=t(p),Y=d(p,M,{availablePoints:m,availableText:s-F,retainText:ie,policy:a},n,r);return Object.freeze({...ne,data:Y.data,binding:Y,points:I,textCharacters:F+Y.textCharacters})}const ue=k,le=[],ee=[];for(let M=0;M<w;M++)(M&255)===0&&C(n),le.push(B(ue[M],"Chart category"));for(let M=0;M<b;M++){const ie=y[M],Y=u(ie,["name","values","color"],"chart.series"),pe=B(Y.name,"Chart series name"),ce=Y.values,R=Y.color;if(!Array.isArray(ce)||ce.length!==w)throw new TypeError("Chart series values must match the category count.");if(R!==void 0&&(typeof R!="string"||!/^#?[0-9a-fA-F]{6}$/.test(R)))throw new TypeError("Chart colors must be opaque six-digit RGB hex values.");let _=!1;const L=[];for(let U=0;U<w;U++){(U&255)===0&&C(n);const Z=ce[U];if(typeof Z!="number"||!Number.isFinite(Z))throw new TypeError("Chart values must be finite numbers.");if(r==="pie"&&Z<0)throw new RangeError("Pie charts require nonnegative values.");Z>0&&(_=!0),L.push(Z)}if(r==="pie"&&!_)throw new RangeError("A pie chart needs at least one positive value.");ee.push(Object.freeze({name:pe,values:Object.freeze(L),...R===void 0?{}:{color:R.replace(/^#/,"").toUpperCase()}}))}return Object.freeze({...ne,data:Object.freeze({categories:Object.freeze(le),series:Object.freeze(ee)}),points:I,textCharacters:F})}return Object.freeze({prepareChart:f})})(),Ze=(()=>{const{beginTask:C,checkAbort:E,pause:v,taskYieldDue:S}=ye,{OfficeIMOError:T}=he,{notifyProgress:g}=Qe,{ChunkedTextSink:c}=Ce,{ExportBudget:d}=et,{OpcPackage:h,officeRelationshipsNamespace:u,relationshipTypes:f,corePropertiesXml:o}=Me,{escapeOoxmlAttribute:i,cleanXml:a,xmlDeclaration:m}=we,{StyleRegistry:s,spreadsheetNamespace:n,normalizeBorder:t}=Fe,{sheetName:r,assertXlsxValue:e,copyValue:p}=ke,{copyColumns:k}=Xe,{captureFields:y}=be,{captureColumnOutlines:w}=nt,{captureTableSpans:b}=st,{assertExportValue:I}=xe,{Worksheet:F}=lt,{defineTable:B,tableXml:A}=gt,{copyHyperlink:z,drawingXml:j,drawingContentType:P}=_e,{TextOverflow:q}=yt,{captureWorkbookOptions:H,sheetOptionFields:re}=Le,{prepareChart:Q}=xt,{qualifiedColumnRange:de,resolveDataColumn:ne}=Pe,{chartContentType:ue,writeChartXml:le}=ot,ee="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",M=ce=>"application/vnd.openxmlformats-officedocument.spreadsheetml."+ce+"+xml";function ie(ce,R){const _=y(ce,re),L=k(_.columns??[],!0),U=_.footer&&y(_.footer,["rows","values","totals","style"]),Z=_.print&&y(_.print,["paper","orientation","fitToWidth","fitToHeight","repeatHeaders","margins","header","footer"]);return{..._,columns:L,..._.columnOutlines===void 0?{}:{columnOutlines:w(_.columnOutlines,L.length)},..._.headerRows===void 0?{}:{headerRows:b(_.headerRows,L.length)},..._.headerBorder===void 0?{}:{headerBorder:t(_.headerBorder)},...U?{footer:{...U,...U.rows===void 0?{}:{rows:b(U.rows,L.length)},...U.values===void 0?{}:{values:U.values.map(p)}}}:{},..._.table?{table:y(_.table,["name","style","bandedRows","bandedColumns","firstColumn","lastColumn"])}:{},..._.autoSize?{autoSize:y(_.autoSize,["sampleRows","minWidth","maxWidth"])}:{},..._.title?{title:y(_.title,["text","style","height"])}:{},...Z?{print:{...Z,...Z.margins===void 0?{}:{margins:y(Z.margins,["left","right","top","bottom","header","footer"])}}}:{},..._.hyperlinks?{hyperlinks:_.hyperlinks.map(te=>z(te,R))}:{}}}class Y{portableValues=!1;static forTable(R){const _=new Y(R);return _.portableValues=!0,_}get valueValidator(){return this.portableValues?I:e}styles;names=new Set;sheets=[];tableNames=new Set;tableCount=0;writers;package;state="open";result;completion;activeSheet;failure;overflow;links=0;imageBytes=0;bufferedBytes=0;mergedRanges=0;conditionalFormats=0;dataValidationCount=0;validationTextCharacters=0;formulaCharacters=0;hasAuthoredFormulas=!1;nativeCharts=[];chartSourceSheets=0;chartPoints=0;chartTextCharacters=0;registering=!1;registration(R){if(this.assertOpen(),this.registering)throw new T("INVALID_STATE","Workbook registrations cannot be reentered from input getters.");this.registering=!0;try{return R()}finally{this.registering=!1}}budget;settings;constructor(R={}){R=H(R);const _=R.dateMode??"local",L=R.compression??"auto",U=R.invalidCharacterPolicy??"strip";if(_!=="local"&&_!=="utc")throw new RangeError("dateMode must be local or utc.");if(L!=="auto"&&L!=="store")throw new RangeError("compression must be auto or store.");if(R.oversizedText!==void 0&&!["reject","preserve"].includes(R.oversizedText))throw new RangeError("oversizedText must be reject or preserve.");if(a("",U),o(R,U),this.budget=new d(R.limits),this.styles=new s(U,R.limits?.maxStyles,R.limits?.maxDifferentialStyles),R.sink!==void 0&&typeof R.sink.write!="function")throw new TypeError("sink must be a ByteSink.");this.settings=Object.freeze({...R,...R.limits?{limits:Object.freeze({...R.limits})}:{},dateMode:_,compression:L,invalidCharacterPolicy:U}),this.writers=Object.freeze({...R.cellValueWriters});for(const Z of Object.values(this.writers))if(typeof Z!="function")throw new TypeError("Cell value writers must be functions.");C(),this.package=new h({compression:L,invalidCharacterPolicy:U,...R.signal?{signal:R.signal}:{},...R.sink?{sink:R.sink}:{},...R.limits?.maxOutputBytes===void 0?{}:{maxOutputBytes:R.limits.maxOutputBytes}}),this.package.setProperties(R,R.appProperties),this.addXmlPart("/xl/workbook.xml",M("sheet.main"),()=>this.workbookXml()),this.addXmlPart("/xl/styles.xml",M("styles"),()=>this.styles.toXml())}addXmlPart(R,_,L){this.package.addPart({uri:R,contentType:_,data:async U=>{const Z=new c(U,this.settings.signal);await Z.write(L()),await Z.close()}})}workbookXml(){return m+'<workbook xmlns="'+n+'" xmlns:r="'+u+'"><workbookPr date1904="0"/><bookViews><workbookView/></bookViews><sheets>'+this.sheets.map((R,_)=>'<sheet name="'+i(R.name,this.settings.invalidCharacterPolicy)+'" sheetId="'+(_+1)+'"'+(R.hidden?' state="hidden"':"")+' r:id="rId'+(_+1)+'"/>').join("")+"</sheets>"+(this.sheets.some(R=>R.printSettings)?"<definedNames>"+this.sheets.map((R,_)=>{const L="'"+R.name.replace(/'/g,"''")+"'!";return R.printSettings?'<definedName name="_xlnm.Print_Area" localSheetId="'+_+'">'+i(L+"$A$1:$"+R.lastColumn+"$"+R.totalRows,this.settings.invalidCharacterPolicy)+"</definedName>"+(R.printSettings.repeatHeaders&&R.firstHeaderRow?'<definedName name="_xlnm.Print_Titles" localSheetId="'+_+'">'+i(L+"$"+R.firstHeaderRow+":$"+R.headerRowCount,this.settings.invalidCharacterPolicy)+"</definedName>":""):""}).join("")+"</definedNames>":"")+(this.hasAuthoredFormulas?'<calcPr calcMode="auto" fullCalcOnLoad="1" forceFullCalc="1"/>':"")+"</workbook>"}assertOpen(){try{E(this.settings.signal)}catch(R){throw this.discard(R).catch(()=>{}),R}if(this.state==="failed")throw this.failure;if(this.state!=="open")throw new T("INVALID_STATE","Workbook is already finalized.")}writerFor(R){return Object.prototype.hasOwnProperty.call(this.writers,R)?this.writers[R]:void 0}preserveText(R,_,L){if(this.settings.oversizedText!=="preserve")throw new RangeError("Excel cell text exceeds 32,767 UTF-16 code units.");return this.overflow||(this.checkSheetLimit(this.sheets.length+this.chartSourceSheets+1),this.budget.reserve(5,22),this.overflow=new q(r("Text overflow",this.names,this.settings.invalidCharacterPolicy),this.settings.limits?.maxOverflowCharacters??4e6,this.settings.invalidCharacterPolicy,(U,Z,te)=>{this.budget.row(te),this.budget.reserve(U,Z)})),this.overflow.add(R,_,L)}checkSheetLimit(R){if(R>65526)throw new RangeError("Workbook has too many sheets.");if(this.settings.limits?.maxSheets!==void 0&&R>this.settings.limits.maxSheets)throw new T("RESOURCE_LIMIT","maxSheets exceeded.")}checkLinks(R){if(this.settings.limits?.maxHyperlinks!==void 0&&this.links+R>this.settings.limits.maxHyperlinks)throw new T("RESOURCE_LIMIT","maxHyperlinks exceeded.")}retainLink(R=1){this.checkLinks(R),this.links+=R}checkImage(R){if(this.settings.limits?.maxImageBytes!==void 0&&this.imageBytes+R>this.settings.limits.maxImageBytes)throw new T("RESOURCE_LIMIT","maxImageBytes exceeded.")}retainImage(R){this.checkImage(R),this.imageBytes+=R}retainBufferedBytes(R){this.budget.check("maxOutputBytes",this.bufferedBytes+R),this.bufferedBytes+=R}checkMerges(R){if(this.mergedRanges+R>(this.settings.limits?.maxMergedRanges??1e4))throw new T("RESOURCE_LIMIT","maxMergedRanges exceeded.")}checkConditionalFormats(R){if(this.conditionalFormats+R>(this.settings.limits?.maxConditionalFormats??1e3))throw new T("RESOURCE_LIMIT","maxConditionalFormats exceeded.")}get availableDataValidations(){return(this.settings.limits?.maxDataValidations??1e3)-this.dataValidationCount}get availableValidationTextCharacters(){return(this.settings.limits?.maxValidationTextCharacters??1e6)-this.validationTextCharacters}retainFormula(R){if(this.formulaCharacters+R>(this.settings.limits?.maxFormulaCharacters??1e6))throw new T("RESOURCE_LIMIT","maxFormulaCharacters exceeded.");this.formulaCharacters+=R,this.hasAuthoredFormulas=!0}checkChartText(R){if(this.chartTextCharacters+R>(this.settings.limits?.maxChartTextCharacters??1e6))throw new T("RESOURCE_LIMIT","maxChartTextCharacters exceeded.")}retainChartText(R){this.checkChartText(R),this.chartTextCharacters+=R}resolveChartBinding(R){const _=R.sheet;if(!this.sheets.includes(_)||_.hidden)throw new TypeError("Bound charts require a visible worksheet in the same workbook.");const L=_.chartBindingMetadata,U=R.firstRow??0;if(_.isBusy||L.closed||U<L.rows)throw new T("INVALID_STATE","Register a chart before its first selected data row is written, while the source worksheet is idle.");const Z=ne(L.columns,R.categoryColumn,"Chart"),te=R.series.map(J=>ne(L.columns,J.column,"Chart")),N=L.headerRows+U+1;return{descriptor:{source:_,sheetName:L.name,headerRows:L.headerRows,categoryColumn:Z,seriesColumns:te,seriesNames:te.map(J=>L.columns[J-1].header),categoryFormula:de(L.name,Z,N,R.rowCount),valueFormulas:te.map(J=>de(L.name,J,N,R.rowCount)),nameFormulas:te.map((J,fe)=>R.series[fe].name===void 0?L.headerReferences[J-1]:void 0)},retainText:J=>this.retainChartText(J)}}registerChart(R){return this.registration(()=>{if(this.nativeCharts.length>=(this.settings.limits?.maxCharts??100))throw new T("RESOURCE_LIMIT","maxCharts exceeded.");const _=Q(R,this.settings.invalidCharacterPolicy,(this.settings.limits?.maxChartPoints??1e5)-this.chartPoints,(this.settings.limits?.maxChartTextCharacters??1e6)-this.chartTextCharacters,this.settings.signal,U=>this.resolveChartBinding(U));this.assertOpen(),this.checkChartText(_.textCharacters),this.checkSheetLimit(this.sheets.length+this.chartSourceSheets+(_.binding?0:1)+(this.overflow?1:0));const L=Object.freeze({..._,id:this.nativeCharts.length+1,dataSheetName:_.binding?_.binding.source.name:r("Chart data "+(this.nativeCharts.length+1),this.names,this.settings.invalidCharacterPolicy)});return this.nativeCharts.push(L),this.chartPoints+=_.points,this.chartTextCharacters+=_.textCharacters,_.binding?_.binding.source.retainChartBinding(_.binding):this.chartSourceSheets++,L})}async openSheet(R){if(this.activeSheet&&this.activeSheet!==R){if(this.activeSheet.isBusy)throw new T("INVALID_STATE","Await the active streamed worksheet before starting another.");await this.activeSheet.finish()}return this.activeSheet=R,this.package.openPart("/xl/worksheets/sheet"+(this.sheets.indexOf(R)+1)+".xml",M("worksheet"))}async discard(R){this.state="failed",this.failure=R,await Promise.allSettled(this.sheets.map(_=>_.discard(R))),await this.package.discard(R),this.overflow?.clear(),this.nativeCharts.length=0}get worksheets(){return Object.freeze([...this.sheets])}get rowCount(){return this.sheets.reduce((R,_)=>R+_.reportRowCount,0)}addWorksheet(R,_={}){return this.registration(()=>{this.checkSheetLimit(this.sheets.length+this.chartSourceSheets+1+(this.overflow?1:0));const L=ie(_,this.settings.invalidCharacterPolicy),U=F.validate(this,L);let Z=L.table;if(Z&&Z.name===void 0){let J=this.tableCount+1;for(;this.tableNames.has(("Table"+J).toLowerCase());)J++;Z={...Z,name:"Table"+J}}const te=Z?B(this.tableCount+1,Z,L.columns??[],this.settings.invalidCharacterPolicy):void 0;if(te&&this.tableNames.has(te.name.toLowerCase()))throw new TypeError("Duplicate Excel table name: "+te.name);r(R,this.names,this.settings.invalidCharacterPolicy,!1);const N=F.create(this,()=>r(R,this.names,this.settings.invalidCharacterPolicy,!1),L,te,!1,U.conditional,U.validations);return this.assertOpen(),this.checkSheetLimit(this.sheets.length+this.chartSourceSheets+1+(this.overflow?1:0)),this.names.add(N.name.toLowerCase()),this.mergedRanges+=N.mergeCount,this.conditionalFormats+=N.conditionalFormatCount,this.dataValidationCount+=N.dataValidations.count,this.validationTextCharacters+=N.dataValidations.textCharacters,te&&(this.tableNames.add(te.name.toLowerCase()),this.tableCount++),this.sheets.push(N),N})}addPart(R){this.assertOpen();const{uri:_,contentType:L,data:U,relationship:Z}=R,te=Z&&{id:Z.id,type:Z.type,source:Z.source};if(this.assertOpen(),this.package.addPart({uri:_,contentType:L,data:U}),te){const{source:N,id:J,type:fe}=te;this.package.addRelationship(N??"/xl/workbook.xml",{id:J,type:fe,target:_})}}finish(){try{E(this.settings.signal)}catch(R){return this.discard(R).then(()=>{throw R})}if(this.completion)return this.completion;if(this.state==="failed")return Promise.reject(this.failure);if(this.assertOpen(),this.sheets.some(R=>R.isBusy))throw new T("INVALID_STATE","Await addRows before finalizing the workbook.");return this.sheets.length||this.addWorksheet("Sheet1"),this.state="finalizing",this.completion=(async()=>{try{const R=this.rowCount;for(let L=0;L<this.sheets.length;L++){const U=this.sheets[L],Z="/xl/worksheets/sheet"+(L+1)+".xml";await U.finish();const te=U.takePrepared();te&&this.package.addPrepared(Z,M("worksheet"),te);const N=U.tableDefinition;if(N){const J="/xl/tables/table"+N.id+".xml";this.addXmlPart(J,M("table"),()=>A(N,U.rowCount,this.settings.invalidCharacterPolicy,U.headerRowCount,U.footerSettings)),this.package.addRelationship(Z,{id:"table",type:u+"/table",target:J})}for(let J=0;J<U.hyperlinks.length;J++)E(this.settings.signal),this.package.addRelationship(Z,{id:"link"+(J+1),type:u+"/hyperlink",target:U.hyperlinks[J].target,external:!0}),(J&255)===255&&S()&&(await v(),E(this.settings.signal));if(U.images.length||U.charts.length){const J="/xl/drawings/drawing"+(L+1)+".xml";this.addXmlPart(J,P,()=>j(U.images,this.settings.invalidCharacterPolicy,U.charts)),this.package.addRelationship(Z,{id:"drawing",type:u+"/drawing",target:J});for(let fe=0;fe<U.images.length;fe++){E(this.settings.signal);const l="/xl/media/sheet"+(L+1)+"-image"+(fe+1)+".png";this.package.addPart({uri:l,contentType:"image/png",data:U.images[fe].data}),this.package.addRelationship(J,{id:"image"+(fe+1),type:u+"/image",target:l}),(fe&255)===255&&S()&&(await v(),E(this.settings.signal))}for(const fe of U.charts){E(this.settings.signal);const l="/xl/charts/chart"+fe.id+".xml";this.package.addPart({uri:l,contentType:ue,data:x=>le(fe,x,this.settings.invalidCharacterPolicy,this.settings.signal)}),this.package.addRelationship(J,{id:"chart"+fe.id,type:u+"/chart",target:l})}}}if(this.overflow){const L=F.create(this,this.overflow.sheetName,{columns:[{header:"Sheet"},{header:"Cell"},{header:"Part"},{header:"Text",width:80,wrapText:!0},{header:"Parts"}],freezeHeader:!0},void 0,!0);this.sheets.push(L),await L.finish(this.overflow.values());const U=L.takePrepared();U&&this.package.addPrepared("/xl/worksheets/sheet"+this.sheets.length+".xml",M("worksheet"),U),this.overflow.clear()}for(const L of this.nativeCharts){if(E(this.settings.signal),L.binding)continue;const U=F.createChartData(this,L);this.sheets.push(U);function*Z(){for(let N=0;N<L.data.categories.length;N++)yield[L.data.categories[N],...L.data.series.map(J=>J.values[N])]}await U.finish(Z());const te=U.takePrepared();te&&this.package.addPrepared("/xl/worksheets/sheet"+this.sheets.length+".xml",M("worksheet"),te)}this.package.addRelationship("/",{id:"workbook",type:f.officeDocument,target:"/xl/workbook.xml"});for(let L=0;L<this.sheets.length;L++)E(this.settings.signal),this.package.addRelationship("/xl/workbook.xml",{id:"rId"+(L+1),type:f.worksheet,target:"/xl/worksheets/sheet"+(L+1)+".xml"}),(L&255)===255&&S()&&(await v(),E(this.settings.signal));this.package.addRelationship("/xl/workbook.xml",{id:"styles",type:f.styles,target:"/xl/styles.xml"});const _=await this.package.finish();for(const L of this.sheets)L.releaseCharts();return this.nativeCharts.length=0,g(this.settings.onProgress,{phase:"complete",rows:R,bytes:_}),E(this.settings.signal),this.state="complete",{rows:R,sheets:this.sheets.length,bytes:_}}catch(R){throw await this.discard(R),R}})(),this.completion}toBlob(){try{E(this.settings.signal)}catch(R){return this.discard(R).then(()=>{throw R})}if(this.settings.sink)throw new T("INVALID_STATE","This workbook uses a caller-owned sink; use finish().");if(!this.result){const R=this.finish();this.result=R.then(()=>this.package.toBlob(ee))}return this.result}}return Object.freeze({Workbook:Y})})(),ct=(()=>{const{ExportCell:C,assertScalar:E}=xe,{captureWorkbookOptions:v,sheetOptionFields:S}=Le,{captureFields:T}=be;function g(f){for(const o of["font","fill","border","numberFormat"])if(typeof f?.[o]=="number")throw new TypeError("Workbook-local style indexes require the advanced Workbook API; use style definitions.");return f}function c(f){return f instanceof C||E(f),f}function d(f={}){if(f=T(f,S),f.headerStyle!==void 0)throw new TypeError("Workbook-local header styles require the advanced Workbook API; use boldHeader, headerFill, headerBorder and headerWrap.");g(f.alternatingRowStyle),g(f.title?.style),g(f.footer?.style),f.footer?.values?.forEach(c);const o=f.rowStyle,i=f.cellStyle;for(const a of[o,i])if(a!==void 0&&typeof a!="function")throw new TypeError("Style callbacks must be functions.");return{...f,...o?{rowStyle:a=>g(o(a))}:{},...i?{cellStyle:a=>g(i(a))}:{}}}function h(f={}){f=v(f);const o=f.cellValueWriters;if(!o)return f;const i=Object.create(null);for(const[a,m]of Object.entries(o)){if(typeof m!="function")throw new TypeError("Cell value writers must be functions.");i[a]=(s,n)=>c(m(s,n))}return{...f,cellValueWriters:i}}return Object.freeze({portableSheet:d,portableWorkbook:h})})(),ht=(()=>{const{withDestination:C}=Ce,{copyColumns:E}=Xe,{Workbook:v}=Ze,{portableSheet:S,portableWorkbook:T}=ct,{captureFields:g}=be,{sheetOptionFields:c,workbookOptionFields:d}=Le;function h(a){a=g(a,[...d,"columns","sheet"]);const m=E(a.columns),s=a.sheet&&g(a.sheet,[...c,"name"]);return{...T(a),columns:m,sheet:{...S(s),...s?.name===void 0?{}:{name:s.name}}}}function u(a,m){const{name:s="Data",...n}=m.sheet??{};return a.addWorksheet(s,{boldHeader:!0,autoFilter:n.includeHeader!==!1,autoSize:{minWidth:6,maxWidth:54},...n,columns:m.columns})}async function f(a,m){const s=h(m),{columns:n,sheet:t,...r}=s,e=v.forTable(r);try{return await u(e,s).addRows(a),await e.toBlob()}catch(p){throw await e.discard(p),p}}async function o(a,m,s){const n=h(s);return C(m,async t=>{const{columns:r,sheet:e,...p}=n,k=v.forTable({...p,sink:t});try{const y=u(k,n),w=n.columns.length;await y.addRows(a);const b=await k.finish();return{rows:b.rows,columns:w,bytes:b.bytes}}catch(y){throw await k.discard(y),y}})}return Object.freeze({writeXlsx:f,writeXlsxTo:o})})(),We=(()=>{const{ExportCell:C,assertScalar:E}=xe,{isDate:v}=Se,{checkAbort:S,inputRows:T,pause:g,taskYieldDue:c}=ye,{ExportBudget:d}=et,{OfficeIMOError:h}=he,{copyColumns:u,createRowProjector:f}=Xe,{createTotals:o}=it,{copyExportValue:i}=He,a=new WeakMap;function m(A){if(!A||typeof A!="object"||!a.has(A))throw new TypeError("Create grouped report sources with createGroupedReport.")}function s(A,z){return m(A),{async*[Symbol.asyncIterator](){const j=n(A,z);try{yield*j.events}finally{j.dispose()}}}}function n(A,z){m(A);const j=a.get(A),P=t(j.signal,z);return{signal:P.signal,events:j.events(P.signal),dispose:P.dispose}}function t(A,z){if(!A||!z||A===z)return{signal:A??z,dispose(){}};const j=new AbortController,P=()=>j.abort(A.reason),q=()=>j.abort(z.reason);return A.addEventListener("abort",P,{once:!0}),z.addEventListener("abort",q,{once:!0}),A.aborted?P():z.aborted&&q(),{signal:j.signal,dispose(){A.removeEventListener("abort",P),z.removeEventListener("abort",q)}}}function r(A,z,j){const P=A??z;if(!Number.isSafeInteger(P)||P<0)throw new RangeError(j+" must be a nonnegative safe integer.");return P}function e(A){return A instanceof C?A.value:A}function p(A){if(A==null)return{key:null,id:"null",text:""};if(v(A)){const j=Date.prototype.getTime.call(A);if(!Number.isFinite(j))throw new TypeError("A group key date must be valid.");return{key:new Date(j),id:"date:"+j,text:new Date(j).toISOString()}}if(typeof A=="number"&&!Number.isFinite(A))throw new TypeError("A numeric group key must be finite.");const z=String(A);return{key:A,id:typeof A+":"+z,text:z}}function k(A){return v(A)?new Date(Date.prototype.getTime.call(A)):A}function y(A){return Object.freeze(A.map(z=>z.operation===void 0?null:z.value()))}function w(A,z,j){const P=typeof A=="string"?[A]:Array.isArray(A)?Array.from(A):void 0;if(!P||P.length<1||P.length>4)throw new TypeError("groupBy must declare between one and four grouping levels.");if(j!==void 0&&typeof j!="function")throw new TypeError("groupLabel must be a synchronous function.");if(j&&P.length!==1)throw new TypeError("groupLabel is only available for one grouping level; use descriptor labels for a hierarchy.");const q=new Set;return Object.freeze(P.map(H=>{if(typeof H!="string"&&(!H||typeof H!="object"||Array.isArray(H)))throw new TypeError("A grouping level must name a stable column key or provide a descriptor.");const{key:re,value:Q,label:de}=typeof H=="string"?{key:H,value:void 0,label:void 0}:H;if(typeof re!="string"||!re.length||q.has(re))throw new TypeError("Grouping levels need unique, nonempty stable keys.");if(q.add(re),Q!==void 0&&typeof Q!="function")throw new TypeError("Grouping value getters must be synchronous functions.");if(de!==void 0&&typeof de!="function")throw new TypeError("Grouping labels must be synchronous functions.");if(de&&j)throw new TypeError("Specify either groupLabel or the grouping descriptor label.");const ne=z.indexOf(re);if(ne>=0&&Q!==void 0)throw new TypeError("A declared grouping column reuses its projected value; do not provide another value getter.");if(ne<0&&Q===void 0)throw new TypeError("groupBy must name a declared stable column key; hidden grouping fields need an explicit value getter.");return Object.freeze({key:re,column:ne,value:Q,label:de??j})}))}function b(A){return Object.freeze(A.map(({group:z})=>Object.freeze({...z,key:k(z.key)})))}function I(A,z,j){if(!A)return j;const P=A(k(z));if(typeof P?.then=="function"&&Promise.resolve(P).catch(()=>{}),typeof P!="string")throw new TypeError("Grouping labels must return synchronous text.");return P}function F(A,z){if(!z||typeof z!="object")throw new TypeError("Grouped report options are required.");const{columns:j,groupBy:P,totals:q,groupLabel:H,maxGroups:re,maxGroupKeyCharacters:Q,signal:de,limits:ne}=z;if(ne!==void 0&&(!ne||typeof ne!="object"||Array.isArray(ne)))throw new TypeError("Grouped source limits must be an object.");if(ne!==void 0&&"maxOutputBytes"in ne)throw new TypeError("Set maxOutputBytes on the format writer, not the grouped source.");if(!Array.isArray(j)||!j.length)throw new TypeError("A grouped report needs declared columns.");const ue=u(j),le=ue.map(N=>N.key);if(le.some(N=>typeof N!="string"||N.length===0)||new Set(le).size!==le.length)throw new TypeError("Grouped report columns need unique, nonempty stable keys.");const ee=w(P,le,H),M=Object.freeze({...q}),ie=o(ue,M);for(let N=0;N<ue.length;N++)if(ie[N].operation!==void 0&&ue[N].type!=="number")throw new TypeError("Grouped numeric totals require a column declared with type:number.");const Y=r(re,1e3,"maxGroups"),pe=r(Q,1e6,"maxGroupKeyCharacters"),ce=new d(ne),R=Object.freeze(ue.map(N=>{const{value:J,...fe}=N;return Object.freeze(fe)}));for(const N of ue){ce.cell(N.header);for(const J of N.groups??[])ce.reserve(0,J.length);Object.freeze(N)}let _=!1;const L=N=>Object.freeze({[Symbol.asyncIterator](){if(_)throw new TypeError("A grouped report source can be consumed only once.");return _=!0,Z(N)}}),U=L(de);async function*Z(N){const J=f(ue,void 0,N),fe=new Set,l=[];let x=0,O=0,D=0;for await(const X of T(A,N)){const K=Array.isArray(X)?Array.from(X):X,V=J(K,O),se=[];for(let W=0;W<ue.length;W++)se.push(i(V[W])??null);S(N);const me=ee.map((W,$)=>{S(N);const oe=W.column>=0?e(se[W.column]):W.value(K,Object.freeze({rowIndex:O,level:$,key:W.key}));return E(oe),S(N),p(oe)});ce.row(O+1);for(let W=0;W<se.length;W++){const $=se[W],oe=e($);if(ie[W].operation!==void 0&&oe!=null&&(typeof oe!="number"||!Number.isFinite(oe)))throw new TypeError("Grouped numeric metrics must resolve to finite numbers or null.");ce.cell(oe),$ instanceof C&&$.text!==void 0&&ce.reserve(0,$.text.length)}let ae=0;for(;ae<l.length&&l[ae].id===me[ae].id;)ae++;const G=[];for(let W=ae;W<ee.length;W++){const $=me[W],Re=((G.at(-1)??l[W-1])?.group.groupIndex??-1)+":"+$.id;if(fe.has(Re))throw new TypeError("Grouped rows must be contiguous; a closed group key occurred again within the same parent.");if(D===Y)throw new h("RESOURCE_LIMIT","maxGroups exceeded.");const Oe=I(ee[W].label,$.key,$.text);S(N);const Ae=x+Re.length+Oe.length;if(!Number.isSafeInteger(Ae)||Ae>pe)throw new h("RESOURCE_LIMIT","maxGroupKeyCharacters exceeded.");ce.reserve(0,Oe.length),G.push({id:$.id,group:Object.freeze({groupIndex:D,key:$.key,label:Oe,level:W}),rows:0,aggregates:o(ue,M)}),x=Ae,fe.add(Re),D++}for(;l.length>ae;){S(N);const W=b(l),$=l.pop();yield Object.freeze({kind:"groupEnd",...W.at(-1),path:W,rows:$.rows,totals:y($.aggregates)})}for(const W of G){S(N),l.push(W);const $=b(l);yield Object.freeze({kind:"groupStart",...$.at(-1),path:$})}for(let W=0;W<se.length;W++){const $=e(se[W]);for(const oe of l)oe.aggregates[W].accept($);ie[W].accept($)}for(const W of l)W.rows++;S(N),yield Object.freeze({kind:"row",values:Object.freeze(se),rowIndex:O,groupIndex:l.at(-1).group.groupIndex,path:b(l)}),O++,c()&&(await g(),S(N))}for(S(N);l.length;){S(N);const X=b(l),K=l.pop();yield Object.freeze({kind:"groupEnd",...X.at(-1),path:X,rows:K.rows,totals:y(K.aggregates)})}S(N),yield Object.freeze({kind:"complete",rows:O,groups:D,totals:y(ie)})}const te=Object.freeze({columns:R,groupBy:Object.freeze(ee.map(N=>N.key)),totals:M,events:U});return a.set(te,{signal:de,events:L}),te}return Object.freeze({assertGroupedReportSource:m,groupedReportEvents:s,groupedReportOperation:n,createGroupedReport:F})})(),Tt=(()=>{const{assertGroupedReportSource:C}=We,{captureFields:E}=be,{OfficeIMOError:v}=he,{fields:S}=Ue,{sheetOptionFields:T}=Le,{portableSheet:g}=ct,{resolveDataColumn:c}=Pe,{copyStylePatch:d}=Fe,h=["labelColumn","subtotalLabel","grandTotalLabel","includeGrandTotal","collapseGroups","sheet","groupStyle","subtotalStyle","grandTotalStyle","conditionalFormats","dataValidation"],u=["columns","headerRows","footer","table","mergedCells","hyperlinks","conditionalFormats","dataValidation","rowStyle","cellStyle","rowOutline","maxOutlineLevel"];function f(s,n){return c(s.columns,n,"Grouped detail")+1}function o(s,n,t){if(n!==void 0){if(!Array.isArray(n))throw new TypeError("conditionalFormats must be an array.");if(n.length>t)throw new v("RESOURCE_LIMIT","maxConditionalFormats exceeded.");return n.map(r=>{const e=E(r,["type","range","style","stopIfTrue","operator","value","values","formula","stops","color","minimum","maximum","showValue"]),p=e.range;if(typeof p=="string")throw new TypeError("Grouped conditional formats require detail-column selectors rather than A1 or generated-row ranges.");S(p,["column","through"],"grouped conditional range");const k=E(p,["column","through"]);return{...e,range:{column:f(s,k.column),...k.through===void 0?{}:{through:f(s,k.through)}}}})}}function i(s,n,t){if(n!==void 0){if(!Array.isArray(n))throw new TypeError("dataValidation must be an array.");if(n.length>t)throw new v("RESOURCE_LIMIT","maxDataValidations exceeded.");return n.map(r=>{const e=E(r,["type","column","items","allowBlank","showErrorMessage","errorStyle","errorTitle","errorMessage"]);return{...e,column:f(s,e.column)}})}}function a(s,n,t=1e3,r=1e3){if(C(s),!n||typeof n!="object")throw new TypeError("Grouped XLSX options require host-authored labels.");const e=E(n,h),p=E(e.sheet??{},[...T,"name"]);if(!e.labelColumn||typeof e.labelColumn!="object")throw new TypeError("Grouped XLSX needs a leading label column.");const k=E(e.labelColumn,["header","width","wrapText","alignment"]);if(typeof k.header!="string")throw new TypeError("The leading label column needs a string header.");for(const b of[e.subtotalLabel,e.grandTotalLabel])if(typeof b!="function")throw new TypeError("Grouped summary labels must be functions.");for(const b of[e.includeGrandTotal,e.collapseGroups])if(b!==void 0&&typeof b!="boolean")throw new TypeError("Grouped XLSX flags must be booleans.");for(const b of u)if(p[b]!==void 0)throw new TypeError("Grouped XLSX owns worksheet "+b+".");if(p.autoFilter!==void 0&&p.autoFilter!==!1)throw new TypeError("Grouped summary rows cannot use a native table or autofilter.");for(const b of[e.groupStyle,e.subtotalStyle,e.grandTotalStyle])b!==void 0&&g({alternatingRowStyle:b});for(const b of s.columns)if(Object.prototype.hasOwnProperty.call(s.totals,b.key)&&b.type!=="number")throw new TypeError("Editable grouped totals require explicitly numeric columns.");const y=o(s,e.conditionalFormats,t),w=i(s,e.dataValidation,r);return{...e,labelColumn:k,sheet:g(p),...y===void 0?{}:{conditionalFormats:y},...w===void 0?{}:{dataValidation:w},...e.groupStyle?{groupStyle:d(e.groupStyle)}:{},...e.subtotalStyle?{subtotalStyle:d(e.subtotalStyle)}:{},...e.grandTotalStyle?{grandTotalStyle:d(e.grandTotalStyle)}:{}}}return Object.freeze({groupedOptionFields:h,prepareGroupedSheet:a})})(),$e=(()=>{const{groupedReportOperation:C}=We,{checkAbort:E,withAbort:v}=ye,{withDestination:S}=Ce,{captureFields:T}=be,{Workbook:g}=Ze,{FormulaCell:c}=ze,{columnName:d}=ke,{captureWorkbookLimits:h,workbookOptionFields:u}=Le,{retainDataRowRanges:f}=Ve,{groupedOptionFields:o,prepareGroupedSheet:i}=Tt,a={average:1,count:2,max:4,min:5,sum:9};function m(w){if(typeof w?.then=="function"&&Promise.resolve(w).catch(()=>{}),typeof w!="string")throw new TypeError("Grouped summary labels must return strings.");return w}function s(w,b,I,F,B){const A=b+I+":"+b+F,z="SUBTOTAL("+a[w]+","+A+")";return new c(w==="average"||w==="min"||w==="max"?"IF(SUBTOTAL(2,"+A+')=0,"",'+z+")":z,B,w==="count"?0:void 0)}async function n(w,b,I,F,B){E(F.signal);const{labelColumn:A,subtotalLabel:z,grandTotalLabel:j,includeGrandTotal:P,collapseGroups:q,sheet:H,groupStyle:re,subtotalStyle:Q,grandTotalStyle:de,conditionalFormats:ne,dataValidation:ue}=I;let le=0,ee;const M=[],ie=[],Y=[];let pe=0,ce=0,R,_;const{name:L="Data",...U}=H??{},Z=[{...A,type:"string"},...b.columns],te={groupStart:re??{font:{bold:!0}},groupEnd:Q??{font:{bold:!0}},complete:de??{font:{bold:!0}}},N=w.addWorksheet(L,{boldHeader:!0,autoSize:{minWidth:6,maxWidth:54},...U,columns:Z,...ne===void 0?{}:{conditionalFormats:ne},...ue===void 0?{}:{dataValidation:ue},maxOutlineLevel:b.groupBy.length,rowStyle:()=>ee&&ee.kind!=="row"?te[ee.kind]:void 0,rowOutline:()=>{if(!ee||ee.kind==="complete")return;const l=ee.kind==="row"?ee.path.length:ee.level;return{level:l,hidden:!!q&&l>0,collapsed:!!q&&ee.kind==="groupEnd"}}});f(N,Y);const J=b.columns.map(l=>Object.prototype.hasOwnProperty.call(b.totals,l.key)?b.totals[l.key]:void 0);async function*fe(){for await(const l of F.events){ee=l;const x=N.rowCount+N.headerRowCount+1;if(l.kind==="groupStart"){const O={groupIndex:l.groupIndex,level:l.level,key:l.key,label:l.label,path:l.path,rows:0,totals:Object.freeze([]),startRow:x,firstDetailRow:0,lastDetailRow:0,summaryRow:0};M.push(O),ie.push(O),yield[l.label,...b.columns.map(()=>null)]}else if(l.kind==="row"){le++,B?.(le),pe||=x,ce=x;const O=Y.at(-1);O&&O.lastRow+1===x?O.lastRow=x:Y.push({firstRow:x,lastRow:x});for(const D of ie)D.firstDetailRow||=x,D.lastDetailRow=x;yield[null,...l.values]}else if(l.kind==="groupEnd"){const O=ie.pop();O.summaryRow=x,O.rows=l.rows,O.totals=l.totals,yield[m(z(l)),...J.map((D,X)=>D?s(D,d(X+2),O.firstDetailRow,O.lastDetailRow,l.totals[X]):null)]}else _=Object.freeze({rows:l.rows,groups:l.groups,totals:l.totals}),P!==!1&&(R=x,yield[m(j(l)),...J.map((O,D)=>O?pe?s(O,d(D+2),pe,ce,l.totals[D]):l.totals[D]:null)])}}try{return E(F.signal),await v(N.addRows(fe()),F.signal),await v(N.close(),F.signal),Object.freeze({worksheet:N,rows:le,columns:Z.length,detailRanges:Object.freeze(Y.map(l=>Object.freeze({...l}))),groups:Object.freeze(M.map(l=>Object.freeze({...l}))),grandSummary:_,...R===void 0?{}:{grandTotalRow:R}})}catch(l){throw await w.discard(l),l}}async function t(w,b,I){const F=i(b,I,w.settings.limits?.maxConditionalFormats??1e3,w.availableDataValidations),B=C(b,w.settings.signal);try{return await n(w,b,F,B)}finally{B.dispose()}}function r(w,b){if(!b||typeof b!="object")throw new TypeError("Grouped XLSX options require host-authored labels.");const I=T(b,[...u,...o]);if(I.sink!==void 0||I.cellValueWriters!==void 0)throw new TypeError("Grouped XLSX owns its destination and uses already resolved source values.");const F=I.limits===void 0?void 0:h(I.limits);return{...I,...F===void 0?{}:{limits:F},...i(w,I,F?.maxConditionalFormats??1e3,F?.maxDataValidations??1e3)}}async function e(w,b,I){const{labelColumn:F,subtotalLabel:B,grandTotalLabel:A,includeGrandTotal:z,collapseGroups:j,sheet:P,groupStyle:q,subtotalStyle:H,grandTotalStyle:re,conditionalFormats:Q,dataValidation:de,onProgress:ne,...ue}=b,le=C(w,ue.signal);let ee=0,M;const ie=ne?Y=>ne({...Y,rows:ee,...Y.sheetRows===void 0?{}:{sheetRows:ee}}):void 0;try{M=new g({...ue,...le.signal?{signal:le.signal}:{},...ie?{onProgress:ie}:{},...I?{sink:I}:{}});const Y=await n(M,w,b,le,ce=>{ee=ce});if(I){const ce=await M.finish();return{result:{rows:ee,columns:Y.columns,bytes:ce.bytes}}}const pe=await M.toBlob();return{blob:pe,result:{rows:ee,columns:Y.columns,bytes:pe.size}}}catch(Y){throw await M?.discard(Y),Y}finally{le.dispose()}}async function p(w,b){return(await e(w,r(w,b))).blob}async function k(w,b,I){const F=r(w,I);return S(b,async B=>(await e(w,F,B)).result)}return Object.freeze({addGroupedXlsx:t,writeGroupedXlsx:p,writeGroupedXlsxTo:k})})(),Ct=(()=>{const{OfficeIMOError:C}=he;function E(){let T=!1;if(typeof CompressionStream=="function")try{new CompressionStream("deflate-raw"),T=!0}catch{}return{blob:typeof Blob=="function",streams:typeof WritableStream=="function",deflateRaw:T,download:typeof document<"u"&&typeof URL.createObjectURL=="function"}}function v(T,g){if(!(T instanceof Blob)||typeof g!="string"||!g)throw new TypeError("A Blob and file name are required.");if(typeof document>"u"||typeof URL.createObjectURL!="function")throw new C("PLATFORM_UNAVAILABLE","saveBlob requires a browser document and object URLs.");const c=URL.createObjectURL(T),d=document.createElement("a");try{d.href=c,d.download=g,document.body.append(d),d.click()}finally{d.remove(),setTimeout(()=>URL.revokeObjectURL(c),3e4)}}return Object.freeze({OfficeIMOError:he.OfficeIMOError,NotSupportedError:he.NotSupportedError,BlobByteSink:Ce.BlobByteSink,ChunkedTextSink:Ce.ChunkedTextSink,writeBytes:Ce.writeBytes,ExportCell:xe.ExportCell,createGroupedReport:We.createGroupedReport,checkAbort:ye.checkAbort,withAbort:ye.withAbort,inputRows:ye.inputRows,pause:ye.pause,detectFeatures:E,saveBlob:v})})(),kt=Object.freeze({Workbook:Ze.Workbook,writeXlsx:ht.writeXlsx,writeXlsxTo:ht.writeXlsxTo,writeGroupedXlsx:$e.writeGroupedXlsx,writeGroupedXlsxTo:$e.writeGroupedXlsxTo,addGroupedXlsx:$e.addGroupedXlsx,createGroupedReport:We.createGroupedReport,Worksheet:lt.Worksheet,Cell:ke.Cell,FormulaCell:ze.FormulaCell,StyleRegistry:Fe.StyleRegistry,NumberFormats:Fe.NumberFormats,saveBlob:Ct.saveBlob,ExportCell:xe.ExportCell}),{Workbook:Et,writeXlsx:Rt,writeXlsxTo:vt,writeGroupedXlsx:St,writeGroupedXlsxTo:Ot,addGroupedXlsx:At,createGroupedReport:It,Worksheet:Ft,Cell:jt,FormulaCell:zt,StyleRegistry:_t,NumberFormats:Pt,saveBlob:Lt,ExportCell:Dt}=kt;export{jt as Cell,Dt as ExportCell,zt as FormulaCell,Pt as NumberFormats,_t as StyleRegistry,Et as Workbook,Ft as Worksheet,At as addGroupedXlsx,It as createGroupedReport,Lt as saveBlob,St as writeGroupedXlsx,Ot as writeGroupedXlsxTo,Rt as writeXlsx,vt as writeXlsxTo};