@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 pe=(()=>{const S=Symbol.for("@evotecit/officeimo/OfficeIMOError"),O=Symbol.for("@evotecit/officeimo/NotSupportedError");class P extends Error{code;static[Symbol.hasInstance](p){return this!==P?Function.prototype[Symbol.hasInstance].call(this,p):!!p&&typeof p=="object"&&p[S]===!0}constructor(p,b,x){super(b,x),this.code=p,Object.defineProperty(this,S,{value:!0}),this.name="OfficeIMOError"}}class k extends P{feature;static[Symbol.hasInstance](p){return this!==k?Function.prototype[Symbol.hasInstance].call(this,p):!!p&&typeof p=="object"&&p[O]===!0}constructor(p){super("NOT_SUPPORTED",p+" is not supported yet."),this.feature=p,Object.defineProperty(this,O,{value:!0}),this.name="NotSupportedError"}}return Object.freeze({OfficeIMOError:P,NotSupportedError:k})})(),we=(()=>{function S(l){if(l?.aborted)throw l.reason}function O(l,o){return o?new Promise((s,t)=>{const n=()=>o.removeEventListener("abort",e),e=()=>{n(),t(o.reason)};o.addEventListener("abort",e,{once:!0}),Promise.resolve(l).then(r=>{n(),s(r)},r=>{n(),t(r)}),o.aborted&&e()}):Promise.resolve(l)}async function*P(l,o){S(o);const s=l?.[Symbol.asyncIterator]?.()??l?.[Symbol.iterator]?.();if(!s)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let t=!1,n=!1;try{for(;;){S(o);const e=await O(Promise.resolve(s.next()),o);if(S(o),e.done){t=!0;return}yield e.value}}catch(e){throw n=!0,e}finally{if(!t&&s.return)try{const e=s.return();o?.aborted||n?Promise.resolve(e).catch(()=>{}):await O(Promise.resolve(e),o)}catch(e){if(!o?.aborted&&!n)throw e}}}const k=new WeakMap;function C(l){let o=!1;const s=()=>{if(o)throw new TypeError("A row source can be consumed only once.");o=!0},t={[Symbol.asyncIterator](){return s(),n()}};async function*n(){for await(const e of P(l))yield*e}return k.set(t,(e,r)=>(s(),p(l,e,d=>p(d,e,r)))),t}function y(...l){const o={async*[Symbol.asyncIterator](){for(const s of l)yield*s}};return k.set(o,async(s,t)=>{for(const n of l)await p(n,s,t)}),o}async function p(l,o,s){S(o);const t=k.get(l);if(t)return t(o,s);const n=l?.[Symbol.asyncIterator]?.()??l?.[Symbol.iterator]?.();if(!n)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let e=!1;try{for(;;){S(o);let r=n.next();const d=r;typeof d?.then=="function"&&(r=await O(d,o)),S(o);const h=r;if(h.done){e=!0;return}let u=h.value;typeof u?.then=="function"&&(u=await O(u,o)),S(o);const c=s(u);c!==void 0&&await O(c,o)}}finally{if(!e&&n.return)try{Promise.resolve(n.return()).catch(()=>{})}catch{}}}let b;const x=32;function m(){b=performance.now()+x}function f(){const l=performance.now();return b??=l+x,l>=b}function a(){const l=globalThis.scheduler;return typeof l?.postTask=="function"?l.postTask(()=>{b=performance.now()+x},{priority:"user-visible"}):new Promise(o=>{setTimeout(function(){b=performance.now()+x,o()},0)})}return Object.freeze({checkAbort:S,withAbort:O,inputRows:P,rowsFromBatches:C,concatRows:y,consumeRows:p,beginTask:m,taskYieldDue:f,pause:a})})(),Ie=(()=>{const{checkAbort:S,consumeRows:O,withAbort:P,pause:k,taskYieldDue:C}=we,{OfficeIMOError:y}=pe;async function p(a,i){if(a&&typeof a.getWriter=="function"){const l=a.getWriter();try{return await i({write:o=>l.write(new Uint8Array(o))})}finally{l.releaseLock()}}if(!a||typeof a.write!="function")throw new TypeError("Destination must be a ByteSink or WritableStream.");return i(a)}class b{parts=[];state="open";result;write(i){if(this.state!=="open")throw new y("INVALID_STATE","Byte sink is closed.");this.parts.push(new Uint8Array(i))}toBlob(i="application/octet-stream"){if(this.state==="discarded")throw new y("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 y("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 x{sink;signal;chunkSize;text="";encoder=new TextEncoder;constructor(i,l,o=32768){if(this.sink=i,this.signal=l,this.chunkSize=o,!Number.isInteger(o)||o<2)throw new RangeError("Text chunk size must be at least 2.")}append(i){return S(this.signal),this.text+=i,this.text.length>=this.chunkSize||C()}async flush(i=!1){for(S(this.signal);this.text.length;){let l=Math.min(this.text.length,this.chunkSize);if(/[\ud800-\udbff]/.test(this.text[l-1])&&(l<this.text.length||!i)&&l--,!l)break;const o=this.encoder.encode(this.text.slice(0,l));this.text=this.text.slice(l),await P(Promise.resolve(this.sink.write(o)),this.signal),C()&&await k(),S(this.signal)}}async write(i){this.append(i)&&await this.flush()}async close(){await this.flush(!0)}}async function m(a,i,l){await O(a instanceof Uint8Array?[a]:a,l,o=>{if(!(o instanceof Uint8Array))throw new TypeError("Byte sources must yield Uint8Array chunks.");const s=i.write(o);return C()?Promise.resolve(s).then(()=>(S(l),k())):s})}return Object.freeze({withDestination:p,BlobByteSink:b,ChunkedTextSink:x,writeBytes:m})})(),Me=(()=>{function S(P){if(P===null||typeof P!="object")return!1;try{return!(P instanceof Date)&&!(Symbol.toStringTag in P)&&Object.prototype.toString.call(P)!=="[object Date]"?!1:(Date.prototype.getTime.call(P),!0)}catch{return!1}}return Object.freeze({isDate:S})})(),et=(()=>{function S(P){if(!P||typeof P!="object")throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const{target:k,tooltip:C}=P;if(typeof k!="string"||!/^(?:https?:\/\/|mailto:)/i.test(k)||/[\u0000-\u0020\u007f]/.test(k))throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const y=new URL(k);if((y.protocol==="http:"||y.protocol==="https:")&&(!y.hostname||y.username||y.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:y.href,...C===void 0?{}:{tooltip:C}})}return Object.freeze({copyExportLink:S})})(),ve=(()=>{const{isDate:S}=Me,{copyExportLink:O}=et,P=Symbol.for("@evotecit/officeimo/ExportCell");function k(x){if(!x||typeof x!="object"||Array.isArray(x))throw new TypeError("Cell presentation must be an object.");const m={};for(const f of["background","color","numberFormat","bold","italic","wrapText","alignment"]){const a=x[f];if(a!==void 0){if(["bold","italic","wrapText"].includes(f)){if(typeof a!="boolean")throw new TypeError("Cell presentation "+f+" must be boolean.")}else if(typeof a!="string")throw new TypeError("Cell presentation "+f+" must be text.");if(f==="alignment"&&!["left","center","right","fill","justify","distributed"].includes(a))throw new TypeError("Invalid cell presentation alignment.");m[f]=a}}return Object.freeze(m)}class C{value;static[Symbol.hasInstance](m){return!!m&&typeof m=="object"&&m[P]===!0}text;presentation;link;constructor(m,f={}){this.value=m;const{text:a,presentation:i,link:l}=f;if(a!==void 0&&typeof a!="string")throw new TypeError("Display text must be a string.");y(m),this.text=a,this.presentation=i===void 0?void 0:k(i),this.link=l===void 0?void 0:O(l),Object.defineProperty(this,P,{value:!0}),Object.freeze(this)}}function y(x){const m=typeof x;if(!(x==null||m==="string"||m==="number"||m==="boolean"||S(x)))throw typeof x.then=="function"&&Promise.resolve(x).catch(()=>{}),new TypeError("Export values and formatter results must be synchronous strings, numbers, booleans, Dates or null.")}function p(x){x!==null&&typeof x=="object"&&x instanceof C||y(x)}return Object.freeze({copyCellPresentation:k,ExportCell:C,assertScalar:y,assertExportValue:p})})(),Ce=(()=>{function S(P,k){const C={...P};for(const y of k){if(Object.hasOwn(C,y))continue;const p=P[y];p!==void 0&&(C[y]=p)}return C}return Object.freeze({captureFields:S})})(),We=(()=>{const{OfficeIMOError:S}=pe,{captureFields:O}=Ce;class P{cells=0;text=0;reservedCells=0;reservedText=0;limits;constructor(p={}){if(!p||typeof p!="object"||Array.isArray(p))throw new TypeError("Export limits must be an object.");const b=O(p,["maxRows","maxCells","maxTextCharacters","maxOutputBytes"]);for(const[x,m]of Object.entries(b))if(m!==void 0&&(!Number.isSafeInteger(m)||m<0))throw new RangeError(x+" must be a nonnegative safe integer.");this.limits=Object.freeze(b)}check(p,b){const x=this.limits[p];if(x!==void 0&&b>x)throw new S("RESOURCE_LIMIT",p+" exceeded ("+b+" > "+x+").")}row(p){this.check("maxRows",p)}reserve(p,b){this.check("maxCells",this.cells+this.reservedCells+p),this.check("maxTextCharacters",this.text+this.reservedText+b),this.reservedCells+=p,this.reservedText+=b}release(p,b){this.reservedCells-=p,this.reservedText-=b}cell(p,b){if(b!==void 0&&this.release(1,b),this.limits.maxCells===void 0&&this.limits.maxTextCharacters===void 0)return;this.check("maxCells",this.cells+this.reservedCells+1);const x=typeof p=="string"?p.length:0;this.check("maxTextCharacters",this.text+this.reservedText+x),this.cells++,this.text+=x}}function k(y,p){let b=0;return{write(x){return p.check("maxOutputBytes",b+x.length),b+=x.length,y.write(x)}}}return Object.freeze({ExportBudget:P,boundedSink:k})})(),Ne=(()=>{const{assertExportValue:S}=ve,{checkAbort:O}=we,{isDate:P}=Me,{captureFields:k}=Ce;function C(x,m,f,a=S){const i=x.some(l=>l.value);return(l,o=0)=>{if(Array.isArray(l)&&!i){const s=l.length;if(s>x.length)throw new RangeError("Row has more values than declared columns.");const t=new Array(s);for(let n=0;n<s;n++){const e=l[n];a(e),t[n]=e}return t}if(!l||typeof l!="object"||P(l))throw new TypeError("A row must be an array or object.");if(Array.isArray(l)&&l.length>x.length&&!x.every(s=>s.value))throw new RangeError("Project every column explicitly when selecting from a wider array row.");return x.map((s,t)=>{if(s.value){O(f);const r={rowIndex:o,columnIndex:t,column:s,...m?{sheetName:m.sheetName,worksheetRow:m.firstDataRow+o}:{}},d=s.value(l,r);return a(d),O(f),d}if(Array.isArray(l)){const r=l[t];return a(r),r}const n=s.key??s.header,e=Object.prototype.hasOwnProperty.call(l,n)?l[n]:void 0;return a(e),e})}}const y=["header","key","value","width","type","format","wrapText","alignment","rowHeader","groups","style","valueFormatter"];function p(x,m=!1){if(!Array.isArray(x))throw new TypeError("Declare the columns in export order.");return x.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 a=k(f,y);if(!m&&a.style!==void 0)throw new TypeError("Workbook-local column styles require the advanced Workbook API; use portable ExportCell presentation.");if(typeof a.header!="string"||a.key!==void 0&&typeof a.key!="string")throw new TypeError("Each column needs a string header and an optional string key.");if(a.value!==void 0&&typeof a.value!="function")throw new TypeError("Column value getters must be functions.");if(a.rowHeader!==void 0&&typeof a.rowHeader!="boolean")throw new TypeError("Column rowHeader must be boolean.");if(a.groups!==void 0){if(!Array.isArray(a.groups))throw new TypeError("Column groups must be an array of strings.");const i=Array.from(a.groups);if(i.some(l=>typeof l!="string"))throw new TypeError("Column groups must be an array of strings.");return{...a,groups:Object.freeze(i)}}return a})}return Object.freeze({createRowProjector:C,columnOptionFields:y,copyColumns:p})})(),ht=(()=>{class S{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 y=C-this.mean;this.mean=this.count===1?C:Number.isFinite(y)?this.mean+y/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 O(k,C={}){const y=k.map(p=>p.key??p.header);for(const[p,b]of Object.entries(C)){if(y.filter(x=>x===p).length!==1)throw new TypeError("Totals need an unambiguous declared column key: "+p);if(!["sum","count","average","min","max"].includes(b))throw new TypeError("Invalid total operation.")}return y.map(p=>new S(Object.prototype.hasOwnProperty.call(C,p)?C[p]:void 0))}return Object.freeze({NumericAggregate:S,createTotals:O})})(),tt=(()=>{const{ExportCell:S,assertExportValue:O}=ve,{isDate:P}=Me;function k(y){if(O(y),P(y))return new Date(Date.prototype.getTime.call(y));if(y instanceof S){const{value:p,text:b,presentation:x,link:m}=y;return new S(P(p)?new Date(Date.prototype.getTime.call(p)):p,{...b===void 0?{}:{text:b},...x===void 0?{}:{presentation:x},...m===void 0?{}:{link:m}})}return y}return Object.freeze({copyExportValue:k})})(),Ue=(()=>{const{ExportCell:S,assertScalar:O}=ve,{isDate:P}=Me,{checkAbort:k,inputRows:C,pause:y,taskYieldDue:p}=we,{ExportBudget:b}=We,{OfficeIMOError:x}=pe,{copyColumns:m,createRowProjector:f}=Ne,{createTotals:a}=ht,{copyExportValue:i}=tt,l=new WeakMap;function o(E){if(!E||typeof E!="object"||!l.has(E))throw new TypeError("Create grouped report sources with createGroupedReport.")}function s(E,R){return o(E),{async*[Symbol.asyncIterator](){const I=t(E,R);try{yield*I.events}finally{I.dispose()}}}}function t(E,R){o(E);const I=l.get(E),z=n(I.signal,R);return{signal:z.signal,events:I.events(z.signal),dispose:z.dispose}}function n(E,R){if(!E||!R||E===R)return{signal:E??R,dispose(){}};const I=new AbortController,z=()=>I.abort(E.reason),j=()=>I.abort(R.reason);return E.addEventListener("abort",z,{once:!0}),R.addEventListener("abort",j,{once:!0}),E.aborted?z():R.aborted&&j(),{signal:I.signal,dispose(){E.removeEventListener("abort",z),R.removeEventListener("abort",j)}}}function e(E,R,I){const z=E??R;if(!Number.isSafeInteger(z)||z<0)throw new RangeError(I+" must be a nonnegative safe integer.");return z}function r(E){return E instanceof S?E.value:E}function d(E){if(E==null)return{key:null,id:"null",text:""};if(P(E)){const I=Date.prototype.getTime.call(E);if(!Number.isFinite(I))throw new TypeError("A group key date must be valid.");return{key:new Date(I),id:"date:"+I,text:new Date(I).toISOString()}}if(typeof E=="number"&&!Number.isFinite(E))throw new TypeError("A numeric group key must be finite.");const R=String(E);return{key:E,id:typeof E+":"+R,text:R}}function h(E){return P(E)?new Date(Date.prototype.getTime.call(E)):E}function u(E){return Object.freeze(E.map(R=>R.operation===void 0?null:R.value()))}function c(E,R,I){const z=typeof E=="string"?[E]:Array.isArray(E)?Array.from(E):void 0;if(!z||z.length<1||z.length>4)throw new TypeError("groupBy must declare between one and four grouping levels.");if(I!==void 0&&typeof I!="function")throw new TypeError("groupLabel must be a synchronous function.");if(I&&z.length!==1)throw new TypeError("groupLabel is only available for one grouping level; use descriptor labels for a hierarchy.");const j=new Set;return Object.freeze(z.map(M=>{if(typeof M!="string"&&(!M||typeof M!="object"||Array.isArray(M)))throw new TypeError("A grouping level must name a stable column key or provide a descriptor.");const{key:L,value:B,label:Z}=typeof M=="string"?{key:M,value:void 0,label:void 0}:M;if(typeof L!="string"||!L.length||j.has(L))throw new TypeError("Grouping levels need unique, nonempty stable keys.");if(j.add(L),B!==void 0&&typeof B!="function")throw new TypeError("Grouping value getters must be synchronous functions.");if(Z!==void 0&&typeof Z!="function")throw new TypeError("Grouping labels must be synchronous functions.");if(Z&&I)throw new TypeError("Specify either groupLabel or the grouping descriptor label.");const V=R.indexOf(L);if(V>=0&&B!==void 0)throw new TypeError("A declared grouping column reuses its projected value; do not provide another value getter.");if(V<0&&B===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:L,column:V,value:B,label:Z??I})}))}function g(E){return Object.freeze(E.map(({group:R})=>Object.freeze({...R,key:h(R.key)})))}function w(E,R,I){if(!E)return I;const z=E(h(R));if(typeof z?.then=="function"&&Promise.resolve(z).catch(()=>{}),typeof z!="string")throw new TypeError("Grouping labels must return synchronous text.");return z}function T(E,R){if(!R||typeof R!="object")throw new TypeError("Grouped report options are required.");const{columns:I,groupBy:z,totals:j,groupLabel:M,maxGroups:L,maxGroupKeyCharacters:B,signal:Z,limits:V}=R;if(V!==void 0&&(!V||typeof V!="object"||Array.isArray(V)))throw new TypeError("Grouped source limits must be an object.");if(V!==void 0&&"maxOutputBytes"in V)throw new TypeError("Set maxOutputBytes on the format writer, not the grouped source.");if(!Array.isArray(I)||!I.length)throw new TypeError("A grouped report needs declared columns.");const _=m(I),A=_.map(ee=>ee.key);if(A.some(ee=>typeof ee!="string"||ee.length===0)||new Set(A).size!==A.length)throw new TypeError("Grouped report columns need unique, nonempty stable keys.");const U=c(z,A,M),W=Object.freeze({...j}),q=a(_,W);for(let ee=0;ee<_.length;ee++)if(q[ee].operation!==void 0&&_[ee].type!=="number")throw new TypeError("Grouped numeric totals require a column declared with type:number.");const X=e(L,1e3,"maxGroups"),Y=e(B,1e6,"maxGroupKeyCharacters"),F=new b(V),H=Object.freeze(_.map(ee=>{const{value:ye,...be}=ee;return Object.freeze(be)}));for(const ee of _){F.cell(ee.header);for(const ye of ee.groups??[])F.reserve(0,ye.length);Object.freeze(ee)}let K=!1;const re=ee=>Object.freeze({[Symbol.asyncIterator](){if(K)throw new TypeError("A grouped report source can be consumed only once.");return K=!0,he(ee)}}),ne=re(Z);async function*he(ee){const ye=f(_,void 0,ee),be=new Set,D=[];let G=0,N=0,Q=0;for await(const se of C(E,ee)){const ce=Array.isArray(se)?Array.from(se):se,ae=ye(ce,N),fe=[];for(let $=0;$<_.length;$++)fe.push(i(ae[$])??null);k(ee);const me=U.map(($,te)=>{k(ee);const le=$.column>=0?r(fe[$.column]):$.value(ce,Object.freeze({rowIndex:N,level:te,key:$.key}));return O(le),k(ee),d(le)});F.row(N+1);for(let $=0;$<fe.length;$++){const te=fe[$],le=r(te);if(q[$].operation!==void 0&&le!=null&&(typeof le!="number"||!Number.isFinite(le)))throw new TypeError("Grouped numeric metrics must resolve to finite numbers or null.");F.cell(le),te instanceof S&&te.text!==void 0&&F.reserve(0,te.text.length)}let ie=0;for(;ie<D.length&&D[ie].id===me[ie].id;)ie++;const J=[];for(let $=ie;$<U.length;$++){const te=me[$],de=((J.at(-1)??D[$-1])?.group.groupIndex??-1)+":"+te.id;if(be.has(de))throw new TypeError("Grouped rows must be contiguous; a closed group key occurred again within the same parent.");if(Q===X)throw new x("RESOURCE_LIMIT","maxGroups exceeded.");const ue=w(U[$].label,te.key,te.text);k(ee);const Se=G+de.length+ue.length;if(!Number.isSafeInteger(Se)||Se>Y)throw new x("RESOURCE_LIMIT","maxGroupKeyCharacters exceeded.");F.reserve(0,ue.length),J.push({id:te.id,group:Object.freeze({groupIndex:Q,key:te.key,label:ue,level:$}),rows:0,aggregates:a(_,W)}),G=Se,be.add(de),Q++}for(;D.length>ie;){k(ee);const $=g(D),te=D.pop();yield Object.freeze({kind:"groupEnd",...$.at(-1),path:$,rows:te.rows,totals:u(te.aggregates)})}for(const $ of J){k(ee),D.push($);const te=g(D);yield Object.freeze({kind:"groupStart",...te.at(-1),path:te})}for(let $=0;$<fe.length;$++){const te=r(fe[$]);for(const le of D)le.aggregates[$].accept(te);q[$].accept(te)}for(const $ of D)$.rows++;k(ee),yield Object.freeze({kind:"row",values:Object.freeze(fe),rowIndex:N,groupIndex:D.at(-1).group.groupIndex,path:g(D)}),N++,p()&&(await y(),k(ee))}for(k(ee);D.length;){k(ee);const se=g(D),ce=D.pop();yield Object.freeze({kind:"groupEnd",...se.at(-1),path:se,rows:ce.rows,totals:u(ce.aggregates)})}k(ee),yield Object.freeze({kind:"complete",rows:N,groups:Q,totals:u(q)})}const oe=Object.freeze({columns:H,groupBy:Object.freeze(U.map(ee=>ee.key)),totals:W,events:ne});return l.set(oe,{signal:Z,events:re}),oe}return Object.freeze({assertGroupedReportSource:o,groupedReportEvents:s,groupedReportOperation:t,createGroupedReport:T})})(),rt=(()=>{const{OfficeIMOError:S}=pe;function O(){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 P(C,y){if(!(C instanceof Blob)||typeof y!="string"||!y)throw new TypeError("A Blob and file name are required.");if(typeof document>"u"||typeof URL.createObjectURL!="function")throw new S("PLATFORM_UNAVAILABLE","saveBlob requires a browser document and object URLs.");const p=URL.createObjectURL(C),b=document.createElement("a");try{b.href=p,b.download=y,document.body.append(b),b.click()}finally{b.remove(),setTimeout(()=>URL.revokeObjectURL(p),3e4)}}return Object.freeze({OfficeIMOError:pe.OfficeIMOError,NotSupportedError:pe.NotSupportedError,BlobByteSink:Ie.BlobByteSink,ChunkedTextSink:Ie.ChunkedTextSink,writeBytes:Ie.writeBytes,ExportCell:ve.ExportCell,createGroupedReport:Ue.createGroupedReport,checkAbort:we.checkAbort,withAbort:we.withAbort,inputRows:we.inputRows,pause:we.pause,detectFeatures:O,saveBlob:P})})(),Ge=(()=>{function S(P,k){if(!P)return;const C=P(k);if(C&&typeof C.then=="function")throw Promise.resolve(C).catch(()=>{}),new TypeError("onProgress must be synchronous.")}return Object.freeze({notifyProgress:S})})(),Ve=(()=>{const{assertExportValue:S}=ve,{copyExportValue:O}=tt;function P(y,p){if(!Array.isArray(y)||!y.length||y.length>16)throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");const b=y.map(x=>{if(!Array.isArray(x)||x.length!==p)throw new TypeError("Spanned rows must have the declared column count.");return Object.freeze(x.map(m=>{if(m===null)return null;if(!m||typeof m!="object")throw new TypeError("Uncovered heading/footer cells need an anchor value.");const{value:f,columnSpan:a,rowSpan:i}=m;return Object.freeze({value:O(f),...a===void 0?{}:{columnSpan:a},...i===void 0?{}:{rowSpan:i}})}))});return k(b,p),Object.freeze(b)}function k(y,p){if(!Array.isArray(y)||!y.length||y.length>16)throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");const b=Array.from({length:y.length},()=>new Uint8Array(p));return y.map((x,m)=>{if(!Array.isArray(x)||x.length!==p)throw new TypeError("Spanned rows must have the declared column count.");const f=[];for(let a=0;a<p;a++){const i=x[a];if(b[m][a]){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 l=i.columnSpan??1,o=i.rowSpan??1;if(!Number.isInteger(l)||!Number.isInteger(o)||l<1||o<1||a+l>p||m+o>y.length)throw new RangeError("Heading/footer spans must stay inside the declared matrix.");const s=i.value;S(s);for(let t=m;t<m+o;t++)for(let n=a;n<a+l;n++){if(b[t][n])throw new TypeError("Heading/footer spans overlap.");if((t!==m||n!==a)&&y[t]?.[n]!==null)throw new TypeError("Covered heading/footer cells must be null.");b[t][n]=1}f.push(Object.freeze({first:a,span:l,rowSpan:o,value:s}))}return Object.freeze(f)})}return Object.freeze({captureTableSpans:P,tableSpans:k})})(),Ut=(()=>{const{captureTableSpans:S,tableSpans:O}=Ve;function P(C,y,p){const b=O(S(C,y),y),x=b.map(()=>Array(y).fill(""));for(let m=0;m<b.length;m++)for(const f of b[m]){if((f.span>1||f.rowSpan>1)&&p===void 0)throw new TypeError("CSV spanned headings/footers require an explicit spanMode: repeat or anchors.");const a=f.value;for(let i=m;i<m+(p==="repeat"?f.rowSpan:1);i++)for(let l=f.first;l<f.first+(p==="repeat"?f.span:1);l++)x[i][l]=a}return x}return Object.freeze({csvStructuredRows:P})})(),dt=(()=>{const S=Object.freeze({true:"True",false:"False"});function O(k){if(k===void 0)return S;if(!k||typeof k!="object")throw new TypeError("booleanText must contain true and false strings.");const C=k.true,y=k.false;if(typeof C!="string"||typeof y!="string")throw new TypeError("booleanText must contain true and false strings.");return Object.freeze({true:C,false:y})}return Object.freeze({defaultBooleanText:S,captureBooleanText:O})})(),vt=(()=>{const{captureFields:S}=Ce;function O(k){if(!k||typeof k!="object")throw new TypeError("CSV options are required.");return S(k,["columns","signal","limits","onProgress","valueMode","delimiter","lineEnding","bom","includeHeader","headerRows","footer","spanMode","formulaInjectionProtection","quote","nullValue","booleanText"])}return Object.freeze({captureCsvOptions:O})})(),Ht=(()=>{const{beginTask:S,checkAbort:O,consumeRows:P,taskYieldDue:k,withAbort:C}=we,{BlobByteSink:y,ChunkedTextSink:p,withDestination:b}=Ie,{ExportBudget:x,boundedSink:m}=We,{ExportCell:f}=ve,{isDate:a}=Me,{notifyProgress:i}=Ge,{copyColumns:l,createRowProjector:o}=Ne,{csvStructuredRows:s}=Ut,{captureBooleanText:t}=dt,{captureCsvOptions:n}=vt;function e(c,g,w,T,v){const E=typeof c;let R;if(c==null)R="";else if(E==="string")R=c;else{if(E==="number")return R=Number.isFinite(c)?String(c):"",T==="all"?'"'+R+'"':R;if(E==="boolean")R=v[c?"true":"false"];else if(a(c))R=Number.isFinite(c.getTime())?c.toISOString():"";else throw typeof c.then=="function"&&Promise.resolve(c).catch(()=>{}),new TypeError("CSV cells and formatter results must be synchronous strings, numbers, booleans, Dates or null.")}return w&&(E==="string"||E==="boolean")&&R.charCodeAt(0)<=64&&/^ *[=+\-@\t\r\n]/.test(R)&&(R="'"+R),T==="all"||T==="strings"&&E==="string"||R.includes(g)||/["\r\n]/.test(R)?'"'+(R.includes('"')?R.replace(/"/g,'""'):R)+'"':R}async function r(c,g,w){const T=n(w);return b(g,v=>d(c,v,T))}async function d(c,g,w){S();const T=l(w.columns).map(Y=>Object.freeze(Y)),v=w.delimiter??",",E=w.lineEnding??"\r\n",R=w.quote??"minimal",I=t(w.booleanText);if(![",",";"," "].includes(v))throw new RangeError("Delimiter must be comma, semicolon or tab.");if(!["\r\n","\n","\r"].includes(E))throw new RangeError("Invalid line ending.");if(!["minimal","all","strings"].includes(R))throw new RangeError("Quoting must be minimal, all or strings.");if(w.valueMode!==void 0&&!["raw","display"].includes(w.valueMode))throw new RangeError("valueMode must be raw or display.");if(w.nullValue!==void 0&&typeof w.nullValue!="string")throw new TypeError("nullValue must be a string.");if(w.spanMode!==void 0&&w.spanMode!=="repeat"&&w.spanMode!=="anchors")throw new TypeError("CSV spanMode must be repeat or anchors.");const z=w.includeHeader===!1?[]:w.headerRows===void 0?T.length?[T.map(Y=>Y.header)]:[]:s(w.headerRows,T.length,w.spanMode),j=w.footer===void 0?[]:s(w.footer.rows,T.length,w.spanMode);for(const Y of T)if(Y.valueFormatter!==void 0&&typeof Y.valueFormatter!="function")throw new TypeError("CSV value formatters must be functions.");const M=new x(w.limits);let L=0;const B=g;g=m({async write(Y){await B.write(Y),L+=Y.byteLength}},M);const Z=o(T,void 0,w.signal),V=T.some(Y=>Y.valueFormatter),_=w.signal,A=w.formulaInjectionProtection!==!1,U=new p(g,_);O(_),w.bom&&await C(Promise.resolve(g.write(new Uint8Array([239,187,191]))),_);let W=0;const q=Y=>Y!==null&&typeof Y=="object"&&Y instanceof f?w.valueMode==="display"&&Y.text!==void 0?Y.text:Y.value:Y;function X(Y,F=!1,H=0,K){!F&&V&&H===0&&(K=Object.freeze(T.map((ne,he)=>q(Y[he]))));let re="";for(let ne=H;ne<T.length;ne++){O(_);const he=T[ne],oe=q(Y[ne]);let ee=!F&&he.valueFormatter?he.valueFormatter(oe,{rowIndex:W,columnIndex:ne,column:he,values:K}):oe;if(ee==null&&w.nullValue!==void 0&&(ee=w.nullValue),M.cell(typeof ee=="boolean"?I[ee?"true":"false"]:ee),O(_),re+=(ne?v:"")+e(ee,v,A,R,I),re.length>=U.chunkSize||(ne&127)===127&&k()){if(U.append(re))return U.flush().then(()=>X(Y,F,ne+1,K));re=""}}if(U.append(re+E))return U.flush().then(()=>{i(w.onProgress,{phase:"rows",rows:W+(F?0:1)})})}for(const Y of z)await X(Y,!0);await P(c,_,Y=>{M.row(W+1);const F=X(Z(Y,W));if(F)return F.then(()=>{W++});W++});for(const Y of j)await X(Y,!0);return await U.close(),i(w.onProgress,{phase:"complete",rows:W,bytes:L}),O(_),{rows:W,columns:T.length,bytes:L}}async function h(c,g){const w=n(g),T=new y;try{let v=0;await d(c,T,{...w,onProgress:R=>{R.phase==="complete"?v=R.rows:i(w.onProgress,R)}});const E=T.toBlob("text/csv;charset=utf-8");return i(w.onProgress,{phase:"complete",rows:v,bytes:E.size}),O(w.signal),E}catch(v){throw T.discard(),v}}return Object.freeze({saveBlob:rt.saveBlob,ExportCell:ve.ExportCell,writeCsvTo:r,writeCsv:h})})(),nt=(()=>{const{OfficeIMOError:S}=pe;function O(y){const p=()=>new S("INVALID_PART_URI","Invalid OPC part URI: "+y);if(typeof y!="string"||!y.startsWith("/")||/[^A-Za-z0-9\-._~!$&'()*+,;=:@%/]/.test(y)||y.split("/").slice(1).some(b=>!b||b.endsWith(".")||/^\.+$/.test(b))||/%(?![\da-f]{2})/i.test(y))throw p();for(const b of y.matchAll(/%([\da-f]{2})/gi)){const x=String.fromCharCode(parseInt(b[1],16));if(/[A-Za-z0-9_.~\-/\\]/.test(x))throw p()}try{decodeURIComponent(y)}catch{throw p()}return y.replace(/%[\da-f]{2}/gi,b=>b.toUpperCase())}function P(y){if(y==="/")return"/_rels/.rels";const p=O(y),b=p.lastIndexOf("/");return p.slice(0,b+1)+"_rels/"+p.slice(b+1)+".rels"}function k(y,p){const b=O(p).slice(1).split("/"),x=y==="/"?[]:O(y).slice(1).split("/").slice(0,-1);for(;x.length&&x[0]===b[0];)x.shift(),b.shift();const m="../".repeat(x.length)+b.join("/");return m.split("/",1)[0].includes(":")?"./"+m:m}return Object.freeze({partUri:O,relationshipPartUri:P,relativePartTarget:k})})(),Pe=(()=>{const{OfficeIMOError:S}=pe,{ChunkedTextSink:O}=Ie,P='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',k={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;","\r":"&#13;","\n":"&#10;"," ":"&#9;"};function C(f,a="strip"){if(a!=="strip"&&a!=="reject")throw new TypeError("Invalid XML character policy.");const i=String(f),l=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\ud800-\udfff\ufffe\uffff]/gu;if(a==="reject"&&l.test(i))throw new S("INVALID_XML","Text contains XML 1.0-invalid characters.");return i.replace(l,"")}function y(f,a="strip"){return C(f,a).replace(/[&<>"'\r\n\t]/g,i=>k[i])}function p(f,a="strip"){const i={"\r":"_x000D_","\n":"_x000A_"," ":"_x0009_"},l=C(f,a).replace(/_(?=x[0-9a-f]{4}_)|[\r\n\t]/gi,o=>o==="_"?"_x005F_":i[o]);return y(l,a)}function b(f){if(typeof f!="string"||!/^[A-Za-z_][A-Za-z0-9_.-]*(?::[A-Za-z_][A-Za-z0-9_.-]*)?$/.test(f))throw new S("INVALID_XML","Invalid XML name: "+f);return f}class x{policy;sink;stack=[];roots=0;closed=!1;constructor(a,i="strip",l){this.policy=i,C("",i),this.sink=new O(a,l),this.sink.append(P)}async startElement(a,i={}){this.open(),b(a);const l="<"+a+Object.entries(i).map(([o,s])=>" "+b(o)+'="'+y(s,this.policy)+'"').join("")+">";if(!this.stack.length&&this.roots++)throw new S("INVALID_XML","XML must have one root element.");this.stack.push(a),await this.sink.write(l)}async text(a){if(this.open(),!this.stack.length)throw new S("INVALID_XML","Text needs an open element.");await this.sink.write(y(a,this.policy))}async endElement(){this.open();const a=this.stack.pop();if(!a)throw new S("INVALID_XML","No open XML element.");await this.sink.write("</"+a+">")}async close(){if(this.open(),this.stack.length||this.roots!==1)throw new S("INVALID_XML","XML document is incomplete.");await this.sink.close(),this.closed=!0}open(){if(this.closed)throw new S("INVALID_STATE","XML writer is closed.")}}return Object.freeze({xmlDeclaration:P,cleanXml:C,escapeXml:y,escapeOoxmlAttribute:p,validateXmlName:b,XmlWriter:x})})(),ft=(()=>{const{escapeXml:S,xmlDeclaration:O}=Pe,{isDate:P}=Me;function k(p={},b="strip"){const x=p.created??new Date,m=p.modified??x;if(!P(x)||!P(m)||!Number.isFinite(x.getTime())||!Number.isFinite(m.getTime()))throw new TypeError("Invalid workbook property date.");return O+'<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>'+S(p.creator??"",b)+"</dc:creator><dc:title>"+S(p.title??"",b)+"</dc:title>"+(p.subject===void 0?"":"<dc:subject>"+S(p.subject,b)+"</dc:subject>")+(p.description===void 0?"":"<dc:description>"+S(p.description,b)+"</dc:description>")+'<dcterms:created xsi:type="dcterms:W3CDTF">'+x.toISOString()+'</dcterms:created><dcterms:modified xsi:type="dcterms:W3CDTF">'+m.toISOString()+"</dcterms:modified></cp:coreProperties>"}function C(p={},b="strip"){return O+'<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"><Application>'+S(p.application??"OfficeIMO",b)+"</Application><Company>"+S(p.company??"",b)+"</Company></Properties>"}return Object.freeze({corePropertiesXml:k,appPropertiesXml:C})})(),ut=(()=>{const S=new Uint32Array(256).map((k,C)=>{let y=C;for(let p=0;p<8;p++)y=y&1?3988292384^y>>>1:y>>>1;return y>>>0});class O{crc=4294967295;update(C){let y=this.crc;for(let p=0;p<C.length;p++)y=S[(y^C[p])&255]^y>>>8;this.crc=y}get value(){return(this.crc^4294967295)>>>0}}return Object.freeze({Crc32:O})})(),pt=(()=>{const{checkAbort:S,withAbort:O}=we,{OfficeIMOError:P}=pe,{Crc32:k}=ut,C=4294967295;function y(x){if(!Number.isSafeInteger(x)||x<0||x>=C)throw new P("ZIP64_REQUIRED","Classic ZIP entries and archives must stay below 4 GiB; ZIP64 is not supported yet.");return x}class p{sink;signal;method;writer;reader;drain;crc=new k;size=0;compressedSize=0;failed=!1;failure;closed=!1;cleaned=!1;lifetime=new AbortController;abort=()=>{this.fail(this.signal?.reason)};constructor(m,f,a){if(this.sink=f,this.signal=a,m!=="auto"&&m!=="store")throw new RangeError("compression must be auto or store.");S(a);let i;if(m==="auto"&&typeof CompressionStream=="function")try{i=new CompressionStream("deflate-raw")}catch(l){if(!(l instanceof TypeError))throw l}this.method=i?8:0,this.writer=i?.writable.getWriter(),this.reader=i?.readable.getReader(),a?.addEventListener("abort",this.abort,{once:!0}),this.drain=this.reader?this.consume(this.reader):Promise.resolve()}async consume(m){try{for(;;){const{value:f,done:a}=await O(m.read(),this.lifetime.signal);if(a)return;S(this.signal),this.compressedSize=y(this.compressedSize+f.length),await O(Promise.resolve(this.sink.write(f)),this.lifetime.signal)}}catch(f){this.fail(f)}}fail(m){this.failed||(this.failed=!0,this.failure=m,this.lifetime.abort(m),this.cleaned||(this.writer?.abort(m).catch(()=>{}),this.reader?.cancel(m).catch(()=>{})))}async write(m){if(S(this.signal),this.failed)throw this.failure;if(this.closed)throw new P("INVALID_STATE","ZIP entry is closed.");if(!(m instanceof Uint8Array))throw new TypeError("ZIP chunks must be Uint8Array.");this.size=y(this.size+m.length),this.crc.update(m),this.writer?await O(this.writer.write(new Uint8Array(m)),this.lifetime.signal):(await O(Promise.resolve(this.sink.write(m)),this.lifetime.signal),this.compressedSize=this.size)}async close(){try{if(S(this.signal),this.failed)throw this.failure;if(this.closed)throw new P("INVALID_STATE","ZIP entry is closed.");if(this.closed=!0,this.writer&&await O(this.writer.close(),this.lifetime.signal),await this.drain,this.failed)throw this.failure;return S(this.signal),{crc:this.crc.value,size:this.size,compressedSize:this.compressedSize,method:this.method}}finally{this.cleanup()}}async discard(m){this.fail(m),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:ut.Crc32,zipLimit:C,zipSize:y,EntryWriter:p})})(),Wt=(()=>{const{EntryWriter:S,zipSize:O}=pt,{checkAbort:P,withAbort:k,pause:C,taskYieldDue:y}=we,{OfficeIMOError:p}=pe,{BlobByteSink:b,writeBytes:x}=Ie,{captureFields:m}=Ce,f=new TextEncoder;function a(s){if(typeof s!="string"||!s||/[\u0000-\u001f\\]/.test(s)||s.startsWith("/")||/^[A-Za-z]:/.test(s)||s.split("/").some(t=>!t||t==="."||t===".."))throw new TypeError("ZIP entry names must be relative paths without empty, dot or parent segments.");for(let t=0;t<s.length;t++){const n=s.charCodeAt(t);if(n>=55296&&n<=56319){const e=s.charCodeAt(++t);if(!(e>=56320&&e<=57343))throw new TypeError("ZIP entry names must contain well-formed Unicode.")}else if(n>=56320&&n<=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,t,n=new Uint8Array){const e=new Uint8Array(t+n.length),r=new DataView(e.buffer);return r.setUint32(0,s,!0),e.set(n,t),{bytes:e,data:r}}class l{sink;owned;names=new Set;central=[];offset=0;active;state="open";options;lifetime=new AbortController;disposal;constructor(t,n={}){const e=m(n,["compression","signal","maxOutputBytes"]),{compression:r,maxOutputBytes:d}=e;if(d!==void 0&&(!Number.isSafeInteger(d)||d<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(e),this.owned=t?void 0:new b,this.sink=t??this.owned}async acceptance(t){const n=this.options.signal,e=()=>this.lifetime.abort(n?.reason);n?.addEventListener("abort",e,{once:!0});try{return P(n),P(this.lifetime.signal),await k(Promise.resolve(t()),this.lifetime.signal)}finally{n?.removeEventListener("abort",e)}}async emit(t){if(this.options.maxOutputBytes!==void 0&&this.offset+t.length>this.options.maxOutputBytes)throw new p("RESOURCE_LIMIT","maxOutputBytes exceeded.");this.offset=O(this.offset+t.length),await this.acceptance(()=>this.sink.write(t))}reserve(t){if(P(this.options.signal),this.state!=="open")throw new p("INVALID_STATE","ZIP writer is busy, failed or finalized.");if(a(t),this.names.has(t))throw new TypeError("Duplicate ZIP entry: "+t);if(this.names.size>=65534)throw new p("ZIP64_REQUIRED","ZIP64 is required for 65,535 entries.");return this.names.add(t),this.state="writing",f.encode(t)}local(t,n,e){const r=i(67324752,30,t);return r.data.setUint16(4,20,!0),r.data.setUint16(6,e?2056:2048,!0),r.data.setUint16(8,n.method,!0),r.data.setUint16(12,33,!0),r.data.setUint16(26,t.length,!0),r.bytes}record(t,n,e,r){const d=i(33639248,46,t);d.data.setUint16(4,20,!0),d.data.setUint16(6,20,!0),d.data.setUint16(8,r?2056:2048,!0),d.data.setUint16(10,n.method,!0),d.data.setUint16(14,33,!0),d.data.setUint32(16,n.crc,!0),d.data.setUint32(20,n.compressedSize,!0),d.data.setUint32(24,n.size,!0),d.data.setUint16(28,t.length,!0),d.data.setUint32(42,e,!0),this.central.push(d.bytes)}async openEntry(t){const n=this.reserve(t),e=this.offset;let r;try{r=new S(this.options.compression??"auto",{write:w=>this.emit(w)},this.options.signal),await this.emit(this.local(n,r,!0));const d=r;let h=!1,u=!1,c;const g=async w=>{u=!0,this.state="failed",this.lifetime.abort(w),await d.discard(w),this.owned?.discard(),this.active=void 0};return this.active={write:async w=>{if(h||u||this.state!=="writing")throw new p("INVALID_STATE","Await the current ZIP entry operation.");h=!0;try{await d.write(w)}catch(T){throw await g(T),T}finally{h=!1}},close:()=>{if(c)return c;if(h||u||this.state!=="writing")throw new p("INVALID_STATE","ZIP entry is busy or closed.");return u=!0,c=(async()=>{try{const w=await d.close(),T=i(134695760,16);return T.data.setUint32(4,w.crc,!0),T.data.setUint32(8,w.compressedSize,!0),T.data.setUint32(12,w.size,!0),await this.emit(T.bytes),this.record(n,w,e,!0),this.state="open",this.active=void 0,w}catch(w){throw await g(w),w}})(),c},discard:g}}catch(d){throw this.state="failed",await r?.discard(d),this.owned?.discard(),d}}async add(t,n){const e=await this.openEntry(t);try{typeof n=="function"?await this.acceptance(()=>n(e)):await this.acceptance(()=>x(n,e,this.lifetime.signal)),await e.close()}catch(r){throw await e.discard(r),r}}get bytesWritten(){return this.offset}discard(t){return this.state="failed",this.lifetime.abort(t),this.disposal??=(async()=>{await this.active?.discard(t),this.owned?.discard()})()}async addPrepared(t,n){const e=this.reserve(t),r=this.offset;try{const d=this.local(e,n,!1),h=new DataView(d.buffer);h.setUint32(14,n.crc,!0),h.setUint32(18,n.compressedSize,!0),h.setUint32(22,n.size,!0),await this.emit(d);for(const u of n.chunks)P(this.options.signal),await this.emit(u);this.record(e,n,r,!1),this.state="open"}catch(d){throw this.state="failed",this.owned?.discard(),d}}async finish(){if(P(this.options.signal),this.state!=="open")throw new p("INVALID_STATE","ZIP writer is busy, failed or finalized.");this.state="writing";const t=this.offset;try{for(let e=0;e<this.central.length;e++)await this.emit(this.central[e]),e%256===255&&y()&&await C();const n=i(101010256,22);n.data.setUint16(8,this.central.length,!0),n.data.setUint16(10,this.central.length,!0),n.data.setUint32(12,this.offset-t,!0),n.data.setUint32(16,t,!0),await this.emit(n.bytes),P(this.options.signal),this.state="finished"}catch(n){throw this.state="failed",this.owned?.discard(),n}}async toBlob(t="application/zip"){if(!this.owned)throw new p("INVALID_STATE","This ZIP uses a caller-owned sink; use finish().");return this.state!=="finished"&&await this.finish(),this.owned.toBlob(t)}}return Object.freeze({Crc32:pt.Crc32,validateEntryName:a,ZipWriter:l})})(),st=(()=>{const{partUri:S,relationshipPartUri:O,relativePartTarget:P}=nt,{corePropertiesXml:k,appPropertiesXml:C}=ft,{ZipWriter:y}=Wt,{ChunkedTextSink:p}=Ie,{OfficeIMOError:b}=pe,{escapeXml:x,xmlDeclaration:m}=Pe,{checkAbort:f,pause:a,taskYieldDue:i}=we,{captureFields:l}=Ce,o="http://schemas.openxmlformats.org/package/2006/relationships",s="http://schemas.openxmlformats.org/officeDocument/2006/relationships",t="http://schemas.openxmlformats.org/package/2006/content-types",n={officeDocument:s+"/officeDocument",worksheet:s+"/worksheet",styles:s+"/styles",theme:s+"/theme",customXml:s+"/customXml",coreProperties:o+"/metadata/core-properties",appProperties:s+"/extended-properties"};function e(u){if(typeof u!="string"||!/^[\w!#$&^.+-]+\/[\w!#$&^.+-]+$/.test(u))throw new TypeError("Invalid content type.");return u}class r{defaults=new Map([["rels","application/vnd.openxmlformats-package.relationships+xml"],["xml","application/xml"]]);overrides=new Map;addDefault(c,g){if(!/^[A-Za-z0-9]+$/.test(c))throw new TypeError("Invalid part extension.");const w=c.toLowerCase(),T=this.defaults.get(w);if(T!==void 0&&T!==g)throw new TypeError("Conflicting default content type.");this.defaults.set(w,e(g))}addOverride(c,g){if(c=S(c),this.overrides.has(c.toLowerCase()))throw new TypeError("Duplicate content-type override.");this.overrides.set(c.toLowerCase(),{uri:c,type:e(g)})}toXml(){return m+'<Types xmlns="'+t+'">'+[...this.defaults].map(([c,g])=>'<Default Extension="'+x(c)+'" ContentType="'+x(g)+'"/>').join("")+[...this.overrides.values()].map(({uri:c,type:g})=>'<Override PartName="'+x(c)+'" ContentType="'+x(g)+'"/>').join("")+"</Types>"}}class d{types=new r;parts=new Map;directories=new Set;relationships=new Map;state="open";result;zip;options;constructor(c={}){this.options=Object.freeze(l(c,["compression","signal","maxOutputBytes","invalidCharacterPolicy","sink"])),this.zip=new y(this.options.sink,this.options)}open(){if(this.state!=="open")throw new b("INVALID_STATE","OPC package is finalized.")}reserve(c,g){if(this.open(),typeof c=="string"&&c.length>65536)throw new b("RESOURCE_LIMIT","OPC part name exceeds the ZIP entry-name limit.");c=S(c);let w=0;for(let E=0;E<c.length;E++)if(c[E]==="/"&&++w>64)throw new b("RESOURCE_LIMIT","OPC part name exceeds the directory-depth limit.");if(/\/_rels(?:\/|$)/i.test(c)||c.toLowerCase()==="/[content_types].xml")throw new TypeError("Package metadata part names are reserved.");const T=c.toLowerCase();if(this.parts.has(T))throw new TypeError("Duplicate OPC part: "+c);if(this.directories.has(T))throw new TypeError("OPC part-name prefix collision: "+c+" is an ancestor of an existing part.");const v=[];for(let E=T.lastIndexOf("/");E>0;E=T.lastIndexOf("/",E-1)){const R=T.slice(0,E);if(this.parts.has(R))throw new TypeError("OPC part-name prefix collision: "+c+" descends from "+this.parts.get(R).uri);v.push(R)}this.types.addOverride(c,g);for(const E of v)this.directories.add(E);return c}addPart(c){const{uri:g,contentType:w,data:T}=c,v=T instanceof Uint8Array?new Uint8Array(T):T,E=this.reserve(g,w);this.parts.set(E.toLowerCase(),{uri:E,contentType:w,data:v})}addPrepared(c,g,w){c=this.reserve(c,g),this.parts.set(c.toLowerCase(),{uri:c,prepared:w})}async openPart(c,g){if(!this.options.sink)throw new b("INVALID_STATE","openPart requires a caller-owned package sink.");c=this.reserve(c,g),this.parts.set(c.toLowerCase(),{uri:c,written:!0});try{return await this.zip.openEntry(c.slice(1))}catch(w){throw await this.discard(w),w}}addRelationship(c,g){f(this.options.signal),this.open(),c=c==="/"?c:S(c);const{id:w,type:T,target:v,external:E}=g;if(this.open(),!/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(w))throw new TypeError("Relationship id must be an XML ID.");if(!/^[A-Za-z][A-Za-z0-9+.-]*:[^\s<>"']+$/.test(T))throw new TypeError("Relationship type must be an absolute URI.");const R=E?v:S(v);if(E&&(!R||/[\u0000-\u0020]/.test(R)))throw new TypeError("Invalid external relationship target.");const I=c.toLowerCase(),z=this.relationships.get(I)??new Map;if(z.has(w))throw new TypeError("Duplicate relationship id: "+w);z.set(w,{id:w,type:T,target:R,...E===void 0?{}:{external:E}}),this.relationships.set(I,z)}setProperties(c={},g={}){const w=k(c,this.options.invalidCharacterPolicy),T=C(g,this.options.invalidCharacterPolicy);this.addPart({uri:"/docProps/core.xml",contentType:"application/vnd.openxmlformats-package.core-properties+xml",data:w}),this.addPart({uri:"/docProps/app.xml",contentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml",data:T}),this.addRelationship("/",{id:"core",type:n.coreProperties,target:"/docProps/core.xml"}),this.addRelationship("/",{id:"app",type:n.appProperties,target:"/docProps/app.xml"})}source(c){return typeof c=="string"?async g=>{const w=new p(g,this.options.signal);await w.write(c),await w.close()}:c instanceof Blob?(async function*(){for(let g=0;g<c.size;g+=65536){let w;try{w=await c.slice(g,g+65536).arrayBuffer()}catch(T){throw T?.name!=="NotReadableError"?T:new b("PLATFORM_UNAVAILABLE","This environment cannot read Blob part data. Supply text or byte chunks; read Blobs before sending data to a worker.",{cause:T})}yield new Uint8Array(w)}})():c}finish(){return this.result?this.result:(this.open(),this.state="finalizing",this.result=(async()=>{const c=this.zip;try{for(const[g,w]of this.relationships){if(g!=="/"&&!this.parts.has(g))throw new TypeError("Missing relationship source part: "+g);let T=0;for(const v of w.values()){if(f(this.options.signal),!v.external&&!this.parts.has(v.target.toLowerCase()))throw new TypeError("Missing relationship target: "+v.target);(++T&255)===0&&i()&&(await a(),f(this.options.signal))}}for(const g of this.parts.values())"written"in g||("prepared"in g?await c.addPrepared(g.uri.slice(1),g.prepared):await c.add(g.uri.slice(1),this.source(g.data)));for(const[g,w]of this.relationships){const T=g==="/"?"/":this.parts.get(g).uri;await c.add(O(T).slice(1),async v=>{const E=new p(v,this.options.signal);await E.write(m+'<Relationships xmlns="'+o+'">');for(const R of w.values()){const I='<Relationship Id="'+x(R.id)+'" Type="'+x(R.type)+'" Target="'+x(R.external?R.target:P(T,R.target))+'"'+(R.external?' TargetMode="External"':"")+"/>";E.append(I)&&await E.flush()}await E.write("</Relationships>"),await E.close()})}return await c.add("[Content_Types].xml",this.source(this.types.toXml())),await c.finish(),this.state="complete",c.bytesWritten}catch(g){throw await this.discard(g),g}finally{this.parts.clear(),this.directories.clear(),this.relationships.clear()}})(),this.result)}async toBlob(c="application/zip"){if(this.options.sink)throw new b("INVALID_STATE","This package uses a caller-owned sink; use finish().");return await this.finish(),this.zip.toBlob(c)}async discard(c){this.state="failed",this.parts.clear(),this.directories.clear(),this.relationships.clear(),await this.zip.discard(c)}}return Object.freeze({partUri:nt.partUri,relationshipPartUri:nt.relationshipPartUri,relativePartTarget:nt.relativePartTarget,corePropertiesXml:ft.corePropertiesXml,appPropertiesXml:ft.appPropertiesXml,relationshipsNamespace:o,officeRelationshipsNamespace:s,contentTypesNamespace:t,relationshipTypes:n,ContentTypes:r,OpcPackage:d})})(),it=(()=>{function S(P){if(typeof P!="string"||!/^#?(?:[0-9a-f]{6}|[0-9a-f]{8})$/i.test(P))throw new TypeError("Color must be RGB or ARGB hex.");const k=P.replace(/^#/,"").toUpperCase();return k.length===6?"FF"+k:k}return Object.freeze({colorArgb:S})})(),ot=(()=>{const{OfficeIMOError:S}=pe,{cleanXml:O,escapeOoxmlAttribute:P}=Pe,{colorArgb:k}=it;function C(m,f,a){if(!m||typeof m!="object"||Array.isArray(m))throw new TypeError(a+" must be an object.");if(typeof m.then=="function")throw Promise.resolve(m).catch(()=>{}),new TypeError(a+" must be synchronous.");for(const i of Object.keys(m))if(!f.includes(i))throw new TypeError("Unsupported "+a+" property: "+i)}function y(m,f){if(m!==void 0&&typeof m!="boolean")throw new TypeError(f+" must be boolean.")}class p{policy;maximum;numberFormat;definitions=new Map;constructor(f,a,i){this.policy=f,this.maximum=a,this.numberFormat=i}keys(f){const a=f.map(l=>b(l,this.policy,()=>164)),i=new Set(a.filter(l=>!this.definitions.has(l)));if(this.definitions.size+i.size>this.maximum)throw new S("RESOURCE_LIMIT","maxDifferentialStyles exceeded.");return a}check(f){this.keys(f)}add(f){const a=this.keys(f);for(let i=0;i<f.length;i++)this.definitions.has(a[i])||this.definitions.set(a[i],{id:this.definitions.size,xml:b(f[i],this.policy,this.numberFormat)});return a.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 b(m,f,a){C(m,["font","fill","border","numberFormat"],"conditional style");let i="";if(m.font!==void 0){C(m.font,["bold","italic","underline","strike","color"],"conditional font");let l="";for(const[o,s]of[["bold","b"],["italic","i"],["strike","strike"]])y(m.font[o],o),m.font[o]!==void 0&&(l+="<"+s+' val="'+(m.font[o]?1:0)+'"/>');y(m.font.underline,"underline"),m.font.underline!==void 0&&(l+='<u val="'+(m.font.underline?"single":"none")+'"/>'),m.font.color!==void 0&&(l+='<color rgb="'+k(m.font.color)+'"/>'),l&&(i+="<font>"+l+"</font>")}if(m.numberFormat!==void 0){const l=m.numberFormat;if(typeof l!="string"||!l||l.length>255||!O(l,f))throw new TypeError("Conditional number format requires 1 through 255 XML-valid characters.");i+='<numFmt numFmtId="'+a(l)+'" formatCode="'+P(l,f)+'"/>'}if(m.fill!==void 0){C(m.fill,["color"],"conditional fill");const l=k(m.fill.color);i+='<fill><patternFill patternType="solid"><fgColor rgb="'+l+'"/><bgColor rgb="'+l+'"/></patternFill></fill>'}if(m.border!==void 0){C(m.border,["left","right","top","bottom"],"conditional border");let l="";for(const o of["left","right","top","bottom"]){const s=m.border[o];if(s!==void 0){if(C(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.");l+="<"+o+' style="'+s.style+'">'+(s.color!==void 0?'<color rgb="'+k(s.color)+'"/>':"")+"</"+o+">"}}l&&(i+="<border>"+l+"</border>")}if(!i)throw new TypeError("A conditional style must change at least one property.");return i}return Object.freeze({fields:C,optionalBoolean:y,DifferentialStyles:p,differentialXml:b})})(),Xe=(()=>{const{escapeOoxmlAttribute:S,cleanXml:O,xmlDeclaration:P}=Pe,{OfficeIMOError:k}=pe,{colorArgb:C}=it,{DifferentialStyles:y}=ot,p="http://schemas.openxmlformats.org/spreadsheetml/2006/main",b={General:"General",Integer:"0",Decimal:"0.00",Percent:"0.00%",Date:"yyyy-mm-dd",DateTime:"yyyy-mm-dd hh:mm:ss"};function x(o,s,t){if(!Number.isInteger(o)||o<0||o>=s)throw new RangeError("Unknown "+t+" index.");return o}function m(o,s,t,n){const e=JSON.stringify(t),r=s.get(e);if(r!==void 0)return r;if(o.length>=n)throw new k("RESOURCE_LIMIT","Style component limit exceeded.");const d=o.length;return o.push(t),s.set(e,d),d}function f(o){if(!o||typeof o!="object"||Array.isArray(o))throw new TypeError("A style patch must be a CellStyle object.");if(typeof o.then=="function")throw Promise.resolve(o).catch(()=>{}),new TypeError("Style patches must be synchronous CellStyle objects.")}function a(o){return f(o),Object.freeze({...o,...typeof o.font=="object"?{font:Object.freeze({...o.font})}:{},...typeof o.fill=="object"?{fill:Object.freeze({...o.fill})}:{},...typeof o.border=="object"?{border:Object.freeze(Object.fromEntries(Object.entries(o.border).map(([s,t])=>[s,Object.freeze({...t})])))}:{}})}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((s,t)=>[JSON.stringify(s),t]));fillIndexes=new Map(this.fills.map((s,t)=>[JSON.stringify(s),t]));borderIndexes=new Map(this.borders.map((s,t)=>[JSON.stringify(s),t]));constructor(s="strip",t=64e3,n=1e3){if(this.policy=s,this.maximum=t,!Number.isSafeInteger(t)||t<1||t>64e3)throw new RangeError("maxStyles must be from 1 through 64,000.");if(!Number.isSafeInteger(n)||n<0)throw new RangeError("maxDifferentialStyles must be a nonnegative safe integer.");this.differential=new y(s,n,e=>this.addNumberFormat(e)),O("",s),this.add()}checkDifferentials(s){const t=new Set(s.flatMap(n=>n.numberFormat===void 0?[]:[O(n.numberFormat,this.policy)]).filter(n=>n!=="General"&&!this.formats.has(n)));if(this.formats.size+t.size>65372)throw new RangeError("Too many number formats.");this.differential.check(s)}addDifferentials(s){return this.checkDifferentials(s),this.differential.add(s)}addFont(s){if(s.name!==void 0&&typeof s.name!="string")throw new TypeError("Font name must be a string.");const t=O(s.name??"Calibri",this.policy),n=s.size??11;if(typeof t!="string"||!t||t.length>31)throw new TypeError("Font name must contain 1 through 31 characters.");if(!Number.isFinite(n)||n<=0||n>409)throw new RangeError("Font size must be positive and at most 409.");return m(this.fonts,this.fontIndexes,{name:t,size:n,bold:!!s.bold,italic:!!s.italic,underline:!!s.underline,strike:!!s.strike,color:s.color?C(s.color):""},this.maximum)}addFill(s){const t=s.pattern??(s.color?"solid":"none");if(!["none","gray125","solid"].includes(t)||t==="solid"&&!s.color||t!=="solid"&&s.color)throw new TypeError("A solid fill requires a color; none and gray125 have no color.");return m(this.fills,this.fillIndexes,{pattern:t,color:s.color?C(s.color):""},this.maximum+1)}addBorder(s){const t={};for(const n of["left","right","top","bottom"]){const e=s[n];if(e){if(!["thin","medium","dashed","dotted","thick","double","hair","dashDot","dashDotDot","slantDashDot","mediumDashed","mediumDashDot","mediumDashDotDot"].includes(e.style))throw new TypeError("Invalid border style.");t[n]={style:e.style,...e.color?{color:C(e.color)}:{}}}}return m(this.borders,this.borderIndexes,t,this.maximum)}addNumberFormat(s){if(typeof s!="string"||!s||s.length>255)throw new TypeError("Number format must contain 1 through 255 characters.");if(s=O(s,this.policy),!s)throw new TypeError("Number format must contain XML-valid characters.");if(s==="General")return 0;let t=this.formats.get(s);if(t===void 0){if(this.formats.size>=65372)throw new RangeError("Too many number formats.");t=this.formats.size+164,this.formats.set(s,t)}return t}add(s={}){const t=typeof s.font=="number"?x(s.font,this.fonts.length,"font"):s.font?this.addFont(s.font):0,n=typeof s.fill=="number"?x(s.fill,this.fills.length,"fill"):s.fill?this.addFill(s.fill):0,e=typeof s.border=="number"?x(s.border,this.borders.length,"border"):s.border?this.addBorder(s.border):0;let r=0;if(typeof s.numberFormat=="string")r=this.addNumberFormat(s.numberFormat);else if(s.numberFormat!==void 0&&(r=s.numberFormat,!Number.isInteger(r)||r<0||r>163&&![...this.formats.values()].includes(r)))throw new RangeError("Unknown number format index.");if(s.alignment!==void 0&&!["left","center","right","fill","justify","distributed"].includes(s.alignment))throw new TypeError("Invalid horizontal alignment.");if(s.verticalAlignment!==void 0&&!["top","center","bottom","justify","distributed"].includes(s.verticalAlignment))throw new TypeError("Invalid vertical alignment.");const d={font:t,fill:n,border:e,numberFormat:r,wrapText:!!s.wrapText,alignment:s.alignment??"",verticalAlignment:s.verticalAlignment??""},h=JSON.stringify(d),u=this.indexes.get(h);if(u!==void 0)return u;if(this.styles.length>=this.maximum)throw new k("RESOURCE_LIMIT","Workbook exceeds its cell style limit.");const c=this.styles.length;return this.styles.push(d),this.indexes.set(h,c),c}validateStyle(s){return x(s,this.styles.length,"cell style")}compose(s,t){f(t);const n=this.styles[this.validateStyle(s)];return this.add({font:n.font,fill:n.fill,border:n.border,numberFormat:n.numberFormat,wrapText:n.wrapText,...n.alignment?{alignment:n.alignment}:{},...n.verticalAlignment?{verticalAlignment:n.verticalAlignment}:{},...t,...typeof t.font=="object"?{font:{...this.fonts[n.font],...t.font}}:{},...typeof t.border=="object"?{border:{...this.borders[n.border],...t.border}}:{}})}dateHeader(s,t){return this.compose(s,{numberFormat:this.styles[this.validateStyle(t)].numberFormat})}forColumn(s,t=!1,n,e=!1){const r=!t&&s.style!==void 0?this.styles[this.validateStyle(s.style)]:void 0,d=s.format!==void 0?s.format||b.General:r?.numberFormat||(s.type==="date"||e?b.DateTime:b.General);return this.add({...r?{font:r.font,fill:r.fill,border:r.border}:{},numberFormat:d,wrapText:s.wrapText??r?.wrapText??!1,...s.alignment?{alignment:s.alignment}:r?.alignment?{alignment:r.alignment}:{},...r?.verticalAlignment?{verticalAlignment:r.verticalAlignment}:{},...t?{font:{bold:!0}}:{},...n?{fill:{color:n}}:{}})}toXml(){const s=n=>"<font>"+(n.bold?"<b/>":"")+(n.italic?"<i/>":"")+(n.underline?"<u/>":"")+(n.strike?"<strike/>":"")+'<sz val="'+n.size+'"/>'+(n.color?'<color rgb="'+n.color+'"/>':"")+'<name val="'+S(n.name,this.policy)+'"/></font>',t=n=>"<border>"+["left","right","top","bottom"].map(e=>{const r=n[e];return r?"<"+e+' style="'+r.style+'">'+(r.color?'<color rgb="'+r.color+'"/>':"")+"</"+e+">":"<"+e+"/>"}).join("")+"<diagonal/></border>";return P+'<styleSheet xmlns="'+p+'"><numFmts count="'+this.formats.size+'">'+[...this.formats].map(([n,e])=>'<numFmt numFmtId="'+e+'" formatCode="'+S(n,this.policy)+'"/>').join("")+'</numFmts><fonts count="'+this.fonts.length+'">'+this.fonts.map(s).join("")+'</fonts><fills count="'+this.fills.length+'">'+this.fills.map(n=>'<fill><patternFill patternType="'+n.pattern+'">'+(n.color?'<fgColor rgb="'+n.color+'"/><bgColor indexed="64"/>':"")+"</patternFill></fill>").join("")+'</fills><borders count="'+this.borders.length+'">'+this.borders.map(t).join("")+'</borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="'+this.styles.length+'">'+this.styles.map(n=>{const e=n.wrapText||n.alignment||n.verticalAlignment?"<alignment"+(n.wrapText?' wrapText="1"':"")+(n.alignment?' horizontal="'+n.alignment+'"':"")+(n.verticalAlignment?' vertical="'+n.verticalAlignment+'"':"")+"/>":"";return'<xf numFmtId="'+n.numberFormat+'" fontId="'+n.font+'" fillId="'+n.fill+'" borderId="'+n.border+'" xfId="0"'+(n.numberFormat?' applyNumberFormat="1"':"")+(n.font?' applyFont="1"':"")+(n.fill?' applyFill="1"':"")+(n.border?' applyBorder="1"':"")+(e?' applyAlignment="1"':"")+">"+e+"</xf>"}).join("")+'</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>'+this.differential.toXml()+"</styleSheet>"}}return Object.freeze({colorArgb:it.colorArgb,spreadsheetNamespace:p,NumberFormats:b,validateStylePatch:f,copyStylePatch:a,StyleRegistry:i})})(),Ke=(()=>{const{NotSupportedError:S}=pe,{cleanXml:O,escapeXml:P}=Pe,k=new WeakSet,C=new WeakSet;function y(a){let i=!1;const l=/[\p{L}_\\][\p{L}\p{N}\p{M}_.\\]*/uy;for(let o=0;o<a.length;o++){const s=a[o];if(s==='"'){for(;++o<a.length;)if(a[o]==='"'){if(a[o+1]!=='"')break;o++}}else if(s==="'"){let t="";for(;++o<a.length;){if(a[o]==="'"){if(a[o+1]!=="'")break;o++}t+=a[o]}if(a.slice(o+1).trimStart().startsWith("!")&&/[\[\]]/.test(t))throw new S("external-workbook formulas")}else if(s==="["){let t=1;for(;++o<a.length&&t;){if(a[o]==="'"){o++;continue}a[o]==="["?t++:a[o]==="]"&&t--}if(/^[A-Za-z0-9_.]*!/.test(a.slice(o)))throw new S("external-workbook formulas");o--}else{if(s==="|")throw new S("DDE formulas");{l.lastIndex=o;const t=l.exec(a);t&&(["SUBTOTAL","AGGREGATE","_XLFN.AGGREGATE"].includes(t[0].toUpperCase())&&/^\s*\(/.test(a.slice(l.lastIndex))&&(i=!0),o=l.lastIndex-1)}}}return i}function p(a){if(typeof a!="string")throw new TypeError("Formula text must be a string.");const i=a.trim().replace(/^=/,"");if(!i.trim()||i.length>8192)throw new RangeError("Formulas require 1 through 8,192 characters.");return O(i,"reject"),{text:i,subtotal:y(i)}}class b{cachedValue;style;static[Symbol.hasInstance](i){return i!==null&&typeof i=="object"&&k.has(i)}formula;constructor(i,l,o){this.cachedValue=l,this.style=o;const s=p(i);if(this.formula=s.text,l!==null&&(typeof l!="number"||!Number.isFinite(l)))throw new TypeError("Formula caches must be finite numbers or null for a blank result.");if(o!==void 0&&(!Number.isSafeInteger(o)||o<0))throw new RangeError("Formula style indexes must be nonnegative safe integers.");k.add(this),s.subtotal&&C.add(this),Object.freeze(this)}}function x(a){return C.has(a)}function m(a){if(!(a instanceof b))throw new TypeError("Formula cells must be created with FormulaCell.");return"<f>"+P(a.formula,"reject")+"</f><v>"+(a.cachedValue??"")+"</v>"}return Object.freeze({FormulaCell:b,isSubtotalFormula:x,formulaXml:m})})(),_e=(()=>{const{cleanXml:S,escapeXml:O}=Pe,{assertExportValue:P,assertScalar:k}=ve,{FormulaCell:C}=Ke,{copyExportValue:y}=tt;class p{value;style;constructor(e,r){this.value=e,this.style=r}}function b(n){n instanceof C||(n instanceof p?k(n.value):P(n))}function x(n){return n instanceof C?n:n instanceof p?Object.freeze(new p(y(n.value),n.style)):y(n)}function m(n,e="strip"){const r=S(n,e);if(r.length>32767)throw new RangeError("Excel cell text exceeds 32,767 UTF-16 code units.");return r}function f(n,e){const r=m(n,e),d=h=>'<t xml:space="preserve">'+O(h,e)+"</t>";return/_x[0-9a-f]{4}_/i.test(r)?r.split(/(?<=_)(?=x[0-9a-f]{4}_)/gi).map(h=>"<r>"+d(h)+"</r>").join(""):d(r)}function a(n){if(!Number.isInteger(n)||n<1||n>16384)throw new RangeError("Column index must be from 1 through 16,384.");let e="";for(;n;)n--,e=String.fromCharCode(65+n%26)+e,n=Math.floor(n/26);return e}function i(n,e){return n.slice(0,e).replace(/[\ud800-\udbff]$/,"")}function l(n){let e=0,r=n.length;const d=h=>h==="'"||/\s/u.test(h);for(;e<r&&d(n[e]);)e++;for(;r>e&&d(n[r-1]);)r--;return n.slice(e,r)}function o(n,e,r,d=!0){if(typeof n!="string")throw new TypeError("Sheet name must be a string.");let h=l(S(n,r).replace(/[\[\]:*?/\\]/g,"_"));h=l(i(h,31)),h||(h="Sheet"),h.toLowerCase()==="history"&&(h+="_");let u=h,c=2;for(;e.has(u.toLowerCase());){const g=" ("+c+++")";u=i(h,31-g.length)+g}return d&&e.add(u.toLowerCase()),u}function s(n,e){if(!Number.isFinite(n.getTime()))return null;const r=e==="utc",d=r?n.getUTCFullYear():n.getFullYear();if(d<1900||d>9999)throw new RangeError("Excel dates must be in years 1900 through 9999.");const h=new Date(0);h.setUTCFullYear(d,r?n.getUTCMonth():n.getMonth(),r?n.getUTCDate():n.getDate()),h.setUTCHours(r?n.getUTCHours():n.getHours(),r?n.getUTCMinutes():n.getMinutes(),r?n.getUTCSeconds():n.getSeconds(),r?n.getUTCMilliseconds():n.getMilliseconds());const u=h.getTime();return(u-Date.UTC(1899,11,31))/864e5+(u>=Date.UTC(1900,2,1)?1:0)}return Object.freeze({Cell:p,assertXlsxValue:b,copyValue:x,cellText:m,inlineText:f,columnName:a,sheetName:o,excelDate:s})})(),Ot=(()=>{const{captureFields:S}=Ce;function O(y,p){if(y===void 0)return;if(!Array.isArray(y)||y.length>p)throw new TypeError("Column outlines must be bounded, non-overlapping ranges.");let b=0;return Object.freeze(y.map(x=>{if(!x||typeof x!="object")throw new TypeError("Column outlines require range metadata.");return S(x,["firstColumn","columnCount","level","hidden","collapsed"])}).sort((x,m)=>x.firstColumn-m.firstColumn).map(x=>{const{firstColumn:m,columnCount:f,level:a=0,hidden:i,collapsed:l}=x;if(!Number.isSafeInteger(m)||m<b||!Number.isSafeInteger(f)||f<1||m+f>p)throw new RangeError("Column outline ranges must be disjoint and within the declared columns.");if(!Number.isInteger(a)||a<0||a>7)throw new RangeError("Column outline level must be from zero through seven.");for(const o of[i,l])if(o!==void 0&&typeof o!="boolean")throw new TypeError("Column outline flags must be booleans.");return b=m+f,Object.freeze({firstColumn:m,columnCount:f,level:a,...i===void 0?{}:{hidden:i},...l===void 0?{}:{collapsed:l}})}))}function P(y){for(const p of[y.outlineSummaryBelow,y.outlineSummaryRight])if(p!==void 0&&typeof p!="boolean")throw new TypeError("Outline summary positions must be booleans.")}function k(y){const p=new Map;for(const b of y??[])for(let x=b.firstColumn;x<b.firstColumn+b.columnCount;x++)p.set(x,b);return p}return Object.freeze({captureColumnOutlines:O,validateOutlinePositions:P,columnOutlineMap:k})})(),Pt=(()=>{const{ChunkedTextSink:S}=Ie,{escapeXml:O,xmlDeclaration:P}=Pe,{officeRelationshipsNamespace:k}=st,{columnName:C}=_e,y="http://schemas.openxmlformats.org/drawingml/2006/chart",p="application/vnd.openxmlformats-officedocument.drawingml.chart+xml";function b(s,t,n){const e=' 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"+e+'/><xdr:graphicFrame macro=""><xdr:nvGraphicFramePr><xdr:cNvPr id="'+t+'" name="Chart '+s.id+'" descr="'+O(s.description??s.title??"",n)+'"/><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="'+y+'"><c:chart xmlns:c="'+y+'" r:id="chart'+s.id+'"/></a:graphicData></a:graphic></xdr:graphicFrame><xdr:clientData/></xdr:oneCellAnchor>'}function x(s,t){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">'+O(s,t)+'</a:t></a:r></a:p></c:rich></c:tx><c:overlay val="0"/></c:title>'}function*m(s,t,n,e){yield"<c:"+s+"Ref><c:f>"+O(t,e)+"</c:f><c:"+s+"Cache>",s==="num"&&(yield"<c:formatCode>General</c:formatCode>"),yield'<c:ptCount val="'+n.length+'"/>';for(let r=0;r<n.length;r++)yield'<c:pt idx="'+r+'"><c:v xml:space="preserve">'+O(String(n[r]),e)+"</c:v></c:pt>";yield"</c:"+s+"Cache></c:"+s+"Ref>"}function f(s,t){const n=s.dataLabels;if(!n)return"";const e={center:"ctr",insideEnd:"inEnd",outsideEnd:"outEnd",bestFit:"bestFit",above:"t",below:"b",left:"l",right:"r"};return"<c:dLbls>"+(n.numberFormat===void 0?"":'<c:numFmt formatCode="'+O(n.numberFormat,t)+'" sourceLinked="0"/>')+(n.position===void 0?"":'<c:dLblPos val="'+e[n.position]+'"/>')+'<c:showLegendKey val="0"/><c:showVal val="'+(n.showValue===!1?0:1)+'"/><c:showCatName val="'+(n.showCategoryName?1:0)+'"/><c:showSerName val="'+(n.showSeriesName?1:0)+'"/><c:showPercent val="'+(n.showPercent?1:0)+'"/><c:showBubbleSize val="0"/></c:dLbls>'}function a(s,t){const n=s.type==="barClustered",e=s.valueAxis,r='<c:scaling><c:orientation val="minMax"/>'+(e?.maximum===void 0?"":'<c:max val="'+e.maximum+'"/>')+(e?.minimum===void 0?"":'<c:min val="'+e.minimum+'"/>')+"</c:scaling>",d='<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="'+(n?"l":"b")+'"/>'+(s.categoryAxis?.title?x(s.categoryAxis.title,t):"")+'<c:numFmt formatCode="General" sourceLinked="1"/>'+d+'<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="'+(n?"b":"l")+'"/><c:majorGridlines/>'+(e?.title?x(e.title,t):"")+'<c:numFmt formatCode="'+O(e?.numberFormat??"General",t)+'" sourceLinked="'+(e?.numberFormat===void 0?1:0)+'"/>'+d+'<c:crossAx val="1"/><c:crosses val="autoZero"/><c:crossBetween val="between"/></c:valAx>'}function*i(s,t){const n=s.type==="pie",e=s.type==="line",r=n?"pieChart":e?"lineChart":"barChart",d="'"+s.dataSheetName.replace(/'/g,"''")+"'!",h=s.data.categories.length+1;yield P+'<c:chartSpace xmlns:c="'+y+'" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="'+k+'"><c:date1904 val="0"/>'+(s.language===void 0?"":'<c:lang val="'+O(s.language,t)+'"/>')+"<c:chart>",s.title&&(yield x(s.title,t)),yield'<c:autoTitleDeleted val="'+(s.title?0:1)+'"/><c:plotArea><c:layout/><c:'+r+">",n||(yield e?'<c:grouping val="standard"/>':'<c:barDir val="'+(s.type==="barClustered"?"bar":"col")+'"/><c:grouping val="clustered"/>'),yield'<c:varyColors val="'+(n?1:0)+'"/>';for(let u=0;u<s.data.series.length;u++){const c=s.data.series[u],g="$"+C(u+2);yield'<c:ser><c:idx val="'+u+'"/><c:order val="'+u+'"/><c:tx>';const w=s.binding?s.binding.references.names[u]:d+g+"$1";w===void 0?yield"<c:v>"+O(c.name,t)+"</c:v>":yield*m("str",w,[c.name],t),yield"</c:tx>",c.color&&(yield"<c:spPr>"+(e?'<a:ln w="25400">':"")+'<a:solidFill><a:srgbClr val="'+c.color+'"/></a:solidFill>'+(e?"</a:ln>":"")+"</c:spPr>"),!e&&!n&&(yield'<c:invertIfNegative val="0"/>'),yield"<c:cat>",yield*m("str",s.binding?.references.categories??d+"$A$2:$A$"+h,s.data.categories,t),yield"</c:cat><c:val>",yield*m("num",s.binding?.references.values[u]??d+g+"$2:"+g+"$"+h,c.values,t),yield"</c:val>"+(e?'<c:smooth val="0"/>':"")+"</c:ser>"}yield f(s,t),!n&&!e&&(yield'<c:gapWidth val="150"/><c:overlap val="0"/>'),n||(yield'<c:axId val="1"/><c:axId val="2"/>'),yield"</c:"+r+">",n||(yield a(s,t)),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 l(s,t,n,e){const r=new S(t,e);for(const d of i(s,n))r.append(d)&&await r.flush();await r.close()}return Object.freeze({chartNamespace:y,chartContentType:p,chartAnchorXml:b,writeChartXml:l})})(),Je=(()=>{const{cleanXml:S,escapeXml:O,escapeOoxmlAttribute:P,xmlDeclaration:k}=Pe,{copyExportLink:C}=et,{officeRelationshipsNamespace:y}=st,{chartAnchorXml:p}=Pt,{captureFields:b}=Ce;function x(t,n){if(t=b(t,["row","column","width","height","description"]),!Number.isInteger(t.row)||t.row<1||t.row>1048576||!Number.isInteger(t.column)||t.column<1||t.column>16384)throw new RangeError("Drawing anchors must be one-based worksheet rows and columns.");for(const e of[t.width,t.height])if(!Number.isFinite(e)||e<=0||e>1e5)throw new RangeError("Drawing display dimensions must be positive and at most 100,000 pixels.");if(t.description!==void 0&&typeof t.description!="string")throw new TypeError("Drawing description must be a string.");return Object.freeze({row:t.row,column:t.column,width:t.width,height:t.height,...t.description===void 0?{}:{description:S(t.description,n)}})}function m(t){const n=typeof t=="string"&&/^([A-Z]{1,3})([1-9][0-9]{0,6})$/.exec(t);if(!n)throw new TypeError("Use a single uppercase A1 cell reference.");const e=Number(n[2]);let r=0;for(const d of n[1])r=r*26+d.charCodeAt(0)-64;if(r>16384||e>1048576)throw new RangeError("Cell reference exceeds Excel's worksheet bounds.");return{row:e,column:r}}function f(t,n){t=b(t,["cell","target","tooltip"]),m(t.cell);const e=C(t);return Object.freeze({cell:t.cell,target:e.target,...e.tooltip===void 0?{}:{tooltip:S(e.tooltip,n)}})}function a(t,n,e){if(t=b(t,["data","row","column","width","height","description"]),t.data instanceof Uint8Array&&e?.(t.data.length),!(t.data instanceof Uint8Array)||t.data.length<33||![137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82].every((d,h)=>t.data[h]===d))throw new TypeError("Images require PNG bytes with a valid signature and IHDR header.");const r=new DataView(t.data.buffer,t.data.byteOffset,t.data.byteLength);if(!r.getUint32(16)||!r.getUint32(20))throw new RangeError("PNG dimensions must be positive.");return Object.freeze({...x(t,n),data:new Uint8Array(t.data)})}function i(t,n,e=[]){return"<hyperlinks>"+t.map((r,d)=>'<hyperlink ref="'+r.cell+'" r:id="link'+(d+1)+'"'+(r.tooltip===void 0?"":' tooltip="'+P(r.tooltip,n)+'"')+"/>").join("")+e.map(r=>'<hyperlink ref="'+r.cell+'" location="'+P(r.location,n)+'"/>').join("")+"</hyperlinks>"}function l(t,n,e=[]){const r="http://schemas.openxmlformats.org/drawingml/2006/";return k+'<xdr:wsDr xmlns:xdr="'+r+'spreadsheetDrawing" xmlns:a="'+r+'main" xmlns:r="'+y+'">'+t.map((d,h)=>{const u=' cx="'+Math.round(d.width*9525)+'" cy="'+Math.round(d.height*9525)+'"';return"<xdr:oneCellAnchor><xdr:from><xdr:col>"+(d.column-1)+"</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>"+(d.row-1)+"</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:from><xdr:ext"+u+'/><xdr:pic><xdr:nvPicPr><xdr:cNvPr id="'+(h+1)+'" name="Image '+(h+1)+'" descr="'+O(d.description??"",n)+'"/><xdr:cNvPicPr/></xdr:nvPicPr><xdr:blipFill><a:blip r:embed="image'+(h+1)+'"/><a:stretch><a:fillRect/></a:stretch></xdr:blipFill><xdr:spPr><a:xfrm><a:off x="0" y="0"/><a:ext'+u+'/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></xdr:spPr></xdr:pic><xdr:clientData/></xdr:oneCellAnchor>'}).join("")+e.map((d,h)=>p(d,t.length+h+1,n)).join("")+"</xdr:wsDr>"}return Object.freeze({copyDrawingAnchor:x,cellPosition:m,copyHyperlink:f,copyImage:a,hyperlinksXml:i,drawingXml:l,drawingContentType:"application/vnd.openxmlformats-officedocument.drawing+xml"})})(),Gt=(()=>{const{OfficeIMOError:S}=pe,{cellPosition:O}=Je;function P(p){if(!p.length)return;const b=[...p].sort((o,s)=>o.top-s.top),x=b[Math.floor(b.length/2)].top,m=[],f=[],a=[];for(const o of b)(o.bottom<x?f:o.top>x?a:m).push(o);const i=P(f),l=P(a);return{middle:x,starts:m,ends:[...m].sort((o,s)=>s.bottom-o.bottom),...i?{before:i}:{},...l?{after:l}:{}}}function k(p,b,x){if(p){for(const m of b<=p.middle?p.starts:p.ends){if(b<=p.middle?m.top>b:m.bottom<b)break;x.push(m)}k(b<p.middle?p.before:b>p.middle?p.after:void 0,b,x)}}class C{references;index;currentRow=-1;current=[];lastRow;constructor(b,x,m){if(b.length>m)throw new S("RESOURCE_LIMIT","maxMergedRanges exceeded.");if(!b.length){this.references=Object.freeze([]),this.lastRow=0,this.index=void 0;return}const f=b.map(s=>{if(typeof s!="string"||s.split(":").length!==2)throw new TypeError("Merged ranges require uppercase A1:B2 references.");const[t,n]=s.split(":"),e=O(t),r=O(n);if(r.row<e.row||r.column<e.column||r.row===e.row&&r.column===e.column)throw new RangeError("Merged ranges require ordered distinct cells.");if(r.column>x)throw new RangeError("Merged ranges must stay within declared columns.");return{ref:s,top:e.row,bottom:r.row,left:e.column,right:r.column}}),a=f.flatMap(s=>[{row:s.top,delta:1,region:s},{row:s.bottom+1,delta:-1,region:s}]).sort((s,t)=>s.row-t.row||s.delta-t.delta),i=new Int32Array(65536),l=new Int32Array(65536);function o(s,t,n,e,r,d){if(e<=t&&n<=r){i[s]=i[s]+d,l[s]=l[s]+d;return}const h=t+n>>>1;e<=h&&o(s*2,t,h,e,r,d),r>h&&o(s*2+1,h+1,n,e,r,d),i[s]=l[s]+Math.max(i[s*2],i[s*2+1])}for(const s of a)if(o(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,t)=>Math.max(s,t.bottom),0),this.index=P(f)}covered(b,x){if(!this.index||x>this.lastRow)return!1;this.currentRow!==x&&(this.current=[],k(this.index,x,this.current),this.current.sort((a,i)=>a.left-i.left),this.currentRow=x);let m=0,f=this.current.length-1;for(;m<=f;){const a=m+f>>>1,i=this.current[a];if(b<i.left)f=a-1;else if(b>i.right)m=a+1;else return x!==i.top||b!==i.left}return!1}validateRows(b){if(this.lastRow>b)throw new RangeError("Merged ranges must stay within exported rows.")}}return Object.freeze({MergeRegions:C})})(),Vt=(()=>{const{ExportCell:S}=ve,{tableSpans:O}=Ve,{copyValue:P,columnName:k}=_e;class C{values;ranges;constructor(b,x){const m=O(b,x),f=[];this.values=m.map((a,i)=>{const l=Array(x).fill(void 0);for(const o of a)l[o.first]=P(o.value),(o.span>1||o.rowSpan>1)&&f.push({first:o.first+1,last:o.first+o.span,top:i+1,bottom:i+o.rowSpan});return Object.freeze(l)}),this.ranges=f}get mergeCount(){return this.ranges.length}merges(b){return this.ranges.map(x=>k(x.first)+(x.top+b)+":"+k(x.last)+(x.bottom+b))}matchesLeaf(b){const x=this.values.length;return!this.ranges.some(m=>m.bottom===x)&&this.values[x-1].every((m,f)=>(m instanceof S?m.value:m)===b[f])}}return Object.freeze({StructuredRows:C})})(),It=(()=>{const{ExportCell:S}=ve,{isDate:O}=Me,{Cell:P,cellText:k,columnName:C}=_e,{FormulaCell:y}=Ke,{escapeOoxmlAttribute:p}=Pe,{MergeRegions:b}=Gt,{OfficeIMOError:x}=pe,{createTotals:m}=ht,{StructuredRows:f}=Vt;class a{value;formula;operation;constructor(e,r,d){this.value=e,this.formula=r,this.operation=d}}class i{columns;options;headings;merges;headerRows;firstHeaderRow;regions;widths;sampleRows;structuredFooter;footerRows;mergeCount;aggregates;constructor(e,r,d,h=1e4,u=1e5){this.columns=e,this.options=r;const c=r.title===void 0?0:1;if(r.title!==void 0){if(!e.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(k(r.title.text,d),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 g=Math.max(0,...e.map(I=>I.groups?.length??0));if(r.headerRows===void 0){if(g>16)throw new RangeError("Grouped headings support at most 16 levels.");if(g&&r.includeHeader===!1)throw new TypeError("Grouped headings require leaf headers.")}const w=[],T=[];if(c&&e.length>1&&T.push("A1:"+C(e.length)+"1"),r.headerRows!==void 0&&r.includeHeader!==!1){const I=new f(r.headerRows,e.length);if((r.table||r.autoFilter)&&!I.matchesLeaf(e.map(z=>z.header)))throw new TypeError("Native tables and autofilters require an unmerged final heading row matching the declared leaf headers.");w.push(...I.values),T.push(...I.merges(c))}else if(r.includeHeader!==!1){for(let I=0;I<g;I++){const z=e.map(j=>j.groups?.[I]??"");for(const j of z)k(j,d);for(let j=0;j<e.length;){let M=j;const L=JSON.stringify(e[j].groups?.slice(0,I+1));for(;M+1<e.length&&z[j]&&JSON.stringify(e[M+1].groups?.slice(0,I+1))===L;)M++;if(M>j){T.push(C(j+1)+(I+1+c)+":"+C(M+1)+(I+1+c));for(let B=j+1;B<=M;B++)z[B]=""}j=M+1}w.push(z)}e.length&&w.push(e.map(I=>I.header))}if(this.headerRows=c+w.length,this.firstHeaderRow=e.length&&r.includeHeader!==!1?c+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 f(r.footer.rows,e.length),this.footerRows=this.structuredFooter?.values.length??(r.footer?1:0),this.mergeCount=T.length+(r.mergedCells?.length??0)+(this.structuredFooter?.mergeCount??0),this.mergeCount>h)throw new x("RESOURCE_LIMIT","maxMergedRanges exceeded.");if(this.regions=new b([...T,...r.mergedCells??[]],e.length,h),r.table){for(const I of r.mergedCells??[])if(Number(I.split(":")[1].match(/\d+$/)[0])>=this.headerRows)throw new TypeError("Merged ranges cannot intersect a native table.")}this.headings=w,this.merges=this.regions.references;const v=r.autoSize;if(this.sampleRows=v?v.sampleRows??Math.min(100,Math.floor(u/Math.max(1,e.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 E=v?.minWidth??8,R=v?.maxWidth??60;if(!Number.isFinite(E)||!Number.isFinite(R)||E<0||E>R||R>255)throw new RangeError("Width bounds must satisfy 0 <= minWidth <= maxWidth <= 255.");if(this.widths=e.map(I=>I.width??(v?Math.max(E,Math.min(R,I.header.length+2)):void 0)),r.footer?.values&&r.footer.values.length>e.length)throw new RangeError("Footer has more values than declared columns.");this.aggregates=m(e,r.footer?.totals),r.print&&o(r.print,d)}finalRegions(e,r){return this.structuredFooter?new b([...this.merges,...this.structuredFooter.merges(this.headerRows+e)],this.columns.length,r):this.regions}sample(e){const r=this.options.autoSize?.minWidth??8,d=this.options.autoSize?.maxWidth??60;e.forEach((h,u)=>{if(!this.columns[u]||this.columns[u].width!==void 0)return;const c=h instanceof y?h.cachedValue:h instanceof S?h.text??h.value:h instanceof P?h.value:h,g=O(c)?Number.isFinite(c.getTime())?c.toISOString():"":c==null?"":String(c),w=Math.max(0,...g.slice(0,Math.ceil(d*4)).split(/\r?\n/).map(T=>[...T].length));this.widths[u]=Math.max(this.widths[u]??r,Math.min(d,w+2))})}accept(e,r){this.aggregates[e].accept(r)}footer(e){return this.columns.map((r,d)=>{const h=this.aggregates[d],u=h.operation;if(!u)return this.options.footer?.values?.[d];const c=h.value();return new a(c,l(u,C(d+1),this.headerRows,e),u)})}}function l(n,e,r,d){const h={sum:109,count:102,average:101,min:105,max:104}[n],u=["average","min","max"].includes(n),c=e+(r+1)+":"+e+(r+d),g="SUBTOTAL("+h+","+c+")";return d?u?"IF(SUBTOTAL(102,"+c+')=0,"",'+g+")":g:u?'""':"0"}function o(n,e){if(n.paper!==void 0&&!["A4","Letter"].includes(n.paper))throw new TypeError("Print paper must be A4 or Letter.");if(n.orientation!==void 0&&!["portrait","landscape"].includes(n.orientation))throw new TypeError("Invalid print orientation.");for(const r of[n.fitToWidth,n.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(n.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[n.header,n.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(k(r,e),("&C"+r.replace(/&/g,"&&")).length>255)throw new RangeError("Encoded print header/footer exceeds Excel's 255-character limit.")}}function s(n,e){if(!n)return"";const r={left:.25,right:.25,top:.5,bottom:.5,header:.2,footer:.2,...n.margins};return"<pageMargins"+Object.entries(r).map(([d,h])=>" "+d+'="'+h+'"').join("")+'/><pageSetup paperSize="'+(n.paper==="Letter"?1:9)+'" orientation="'+(n.orientation??"landscape")+'" fitToWidth="'+(n.fitToWidth??1)+'" fitToHeight="'+(n.fitToHeight??0)+'"/>'+(n.header!==void 0||n.footer!==void 0?"<headerFooter>"+(n.header===void 0?"":"<oddHeader>"+p("&C"+n.header.replace(/&/g,"&&"),e)+"</oddHeader>")+(n.footer===void 0?"":"<oddFooter>"+p("&C"+n.footer.replace(/&/g,"&&"),e)+"</oddFooter>")+"</headerFooter>":"")}return Object.freeze({ComputedTotal:a,ReportLayout:i,totalFormula:l,printXml:s})})(),Ye=(()=>{const{columnName:S}=_e;function O(y,p,b="Data"){if(typeof p=="string"){const x=y.flatMap((m,f)=>m.key===p?[f+1]:[]);if(x.length!==1)throw new TypeError(b+" column keys must identify exactly one declared column.");return x[0]}if(!Number.isInteger(p)||p<1||p>y.length)throw new RangeError(b+" column numbers must be one-based and within declared columns.");return p}function P(y,p,b,x){if(!Number.isSafeInteger(b)||b<1||!Number.isSafeInteger(x)||x<1||b+x-1>1048576)throw new RangeError("A data range must fit within Excel's worksheet rows.");const m=S(p);return"'"+y.replace(/'/g,"''")+"'!$"+m+"$"+b+":$"+m+"$"+(b+x-1)}function k(y,p,b){return P(y,p,b,1).split(":")[0]}return Object.freeze({resolveDataColumn:O,qualifiedColumnRange:P,qualifiedCell:k})})(),at=(()=>{const{OfficeIMOError:S}=pe,{columnName:O}=_e,P=new WeakMap;function k(x,m){P.set(x,m)}function C(x){return P.get(x)}function y(x,m,f){const a=P.get(x);if(a===void 0)return f;const i=m+f;let l=0;for(const o of a){if(o.firstRow>i)break;l+=Math.min(o.lastRow,i)-o.firstRow+1}return l}function p(x,m,f,a,i){if(i===void 0)return a?O(x)+(f+1)+":"+O(m)+(f+a):void 0;const l=O(x),o=O(m);let s="",t=f;for(const n of i){if(!Number.isSafeInteger(n.firstRow)||!Number.isSafeInteger(n.lastRow)||n.firstRow<=t||n.lastRow<n.firstRow||n.lastRow>f+a)throw new RangeError("Detail editing ranges must be ordered within serialized worksheet rows.");const e=l+n.firstRow+":"+o+n.lastRow;if(s.length+(s?1:0)+e.length>32767)throw new S("RESOURCE_LIMIT","Detail editing references exceed 32,767 UTF-16 characters; split the worksheet.");s+=(s?" ":"")+e,t=n.lastRow}return s||void 0}return Object.freeze({retainDataRowRanges:k,dataRowRanges:C,dataRowCount:y,dataRowReference:p})})(),Xt=(()=>{const{cleanXml:S,escapeXml:O,escapeOoxmlAttribute:P}=Pe,{cellPosition:k}=Je,{colorArgb:C}=it,{fields:y,optionalBoolean:p,differentialXml:b}=ot,{resolveDataColumn:x}=Ye,{dataRowReference:m}=at;function f(r,d){if(typeof r=="string"){const c=r.split(":");if(c.length>2)throw new TypeError("Conditional ranges require one uppercase A1 cell or rectangle.");const g=k(c[0]),w=k(c[1]??c[0]);if(w.row<g.row||w.column<g.column||w.column>d.length)throw new RangeError("Conditional ranges require ordered cells within declared columns.");return{first:g.column,last:w.column,reference:r,bottom:w.row}}y(r,["column","through"],"conditional data range");const h=x(d,r.column,"Conditional"),u=r.through===void 0?h:x(d,r.through,"Conditional");if(u<h)throw new RangeError("Conditional data ranges require ordered columns.");return{first:h,last:u}}function a(r){if(typeof r!="number"||!Number.isFinite(r))throw new TypeError("Conditional values must be finite numbers.");return String(r)}function i(r,d){if(typeof r!="string")return a(r);if(d!=="equal"&&d!=="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.");S(r,"reject");const h='"'+r.replace(/"/g,'""')+'"';if(h.length>8192)throw new RangeError("Conditional comparison formulas must fit 8,192 characters including quotes.");return h}function l(r){if(typeof r!="string")throw new TypeError("Conditional formulas must be strings.");const d=r.trim().replace(/^=/,"");if(!d.trim()||d.length>8192)throw new RangeError("Conditional formulas require 1 through 8,192 characters.");return S(d,"reject"),d}function o(r,d){if(y(r,r.type==="min"||r.type==="max"?["type"]:["type","value"],"conditional threshold"),r.type==="min"||r.type==="max"){if(r.type!==(d==="first"?"min":d==="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="'+P(l(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 h=a(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="'+h+'"/>'}function s(r){for(let d=1;d<r.length;d++){const h=r[d-1],u=r[d];if("value"in h&&"value"in u&&h.type===u.type&&typeof h.value=="number"&&typeof u.value=="number"&&h.value>u.value)throw new RangeError("Conditional thresholds of the same numeric type must be ordered.")}}function t(r,d,h){if(r===void 0)return[];if(!Array.isArray(r))throw new TypeError("conditionalFormats must be an array.");return r.map(u=>{const c=["type","range"],g=["style","stopIfTrue"];y(u,[...c,...u?.type==="cellIs"?[...g,"operator","value","values"]:u?.type==="expression"?[...g,"formula"]:u?.type==="colorScale"?["stops"]:u?.type==="dataBar"?["color","minimum","maximum","showValue"]:[]],"conditional rule");const w=f(u.range,d);let T="",v="",E;if(u.type==="cellIs"||u.type==="expression")if(p(u.stopIfTrue,"stopIfTrue"),b(u.style,h,()=>164),E={...u.style,...u.style.font?{font:{...u.style.font}}:{},...u.style.fill?{fill:{...u.style.fill}}:{},...u.style.border?{border:Object.fromEntries(Object.entries(u.style.border).filter(([,R])=>R!==void 0).map(([R,I])=>[R,{...I}]))}:{}},u.stopIfTrue!==void 0&&(T+=' stopIfTrue="'+(u.stopIfTrue?1:0)+'"'),u.type==="expression")v="<formula>"+O(l(u.formula),"reject")+"</formula>";else{const R=u.operator==="between"||u.operator==="notBetween";if(!["equal","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","between","notBetween"].includes(u.operator))throw new TypeError("Unsupported conditional comparison operator.");if(R){if("value"in u||!Array.isArray(u.values)||u.values.length!==2)throw new TypeError("between/notBetween require exactly two values.");if(v=u.values.map(I=>"<formula>"+a(I)+"</formula>").join(""),u.values[0]>u.values[1])throw new RangeError("Conditional comparison bounds must be ordered.")}else{if("values"in u||!("value"in u))throw new TypeError("A conditional comparison requires one value.");v="<formula>"+O(i(u.value,u.operator),"reject")+"</formula>"}T+=' operator="'+u.operator+'"'}else if(u.type==="colorScale"){if(!Array.isArray(u.stops)||u.stops.length!==2&&u.stops.length!==3)throw new TypeError("Color scales require two or three stops.");const R=[],I=[];v="<colorScale>"+u.stops.map((z,j)=>(y(z,["threshold","color"],"color stop"),R.push(C(z.color)),I.push(z.threshold),o(z.threshold,j===0?"first":j===u.stops.length-1?"last":"middle"))).join("")+R.map(z=>'<color rgb="'+z+'"/>').join("")+"</colorScale>",s(I)}else if(u.type==="dataBar"){p(u.showValue,"showValue");const R=u.minimum===void 0?{type:"min"}:u.minimum,I=u.maximum===void 0?{type:"max"}:u.maximum;v='<dataBar showValue="'+(u.showValue===!1?0:1)+'">'+o(R,"first")+o(I,"last")+'<color rgb="'+C(u.color)+'"/></dataBar>',s([R,I])}else throw new TypeError("Unsupported conditional rule type.");return{target:w,type:u.type,attributes:T,body:v,...E?{style:E}:{}}})}class n{rules;constructor(d,h){const u=h.addDifferentials(d.flatMap(g=>g.style?[g.style]:[]));let c=0;this.rules=d.map((g,w)=>({target:g.target,xml:'<cfRule type="'+g.type+'" priority="'+(w+1)+'"'+(g.style?' dxfId="'+u[c++]+'"':"")+g.attributes+">"+g.body+"</cfRule>"}))}get count(){return this.rules.length}*xml(d,h,u,c){for(const g of this.rules){if(g.target.bottom!==void 0&&g.target.bottom>u)throw new RangeError("Conditional ranges must stay within exported rows.");const w=g.target.reference??m(g.target.first,g.target.last,d,h,c);w&&(yield'<conditionalFormatting sqref="'+w+'">'+g.xml+"</conditionalFormatting>")}}}return Object.freeze({prepareConditionalFormats:t,ConditionalFormats:n})})(),qt=(()=>{const{OfficeIMOError:S}=pe,{checkAbort:O}=we,{cleanXml:P,escapeOoxmlAttribute:k,escapeXml:C}=Pe,{fields:y,optionalBoolean:p}=ot,{resolveDataColumn:b}=Ye,{dataRowReference:x}=at;function m(l,o,s){if(l!==void 0){if(typeof l!="string")throw new TypeError(s+" must be text.");if(l.length>o)throw new RangeError(s+" exceeds "+o+" UTF-16 units.");return P(l,"reject")}}function f(l,o,s=1e3,t=1e6,n){if(O(n),l===void 0)return Object.freeze({rules:Object.freeze([]),count:0,textCharacters:0});if(!Array.isArray(l))throw new TypeError("dataValidation must be an array.");const e=l.length;if(e>s)throw new S("RESOURCE_LIMIT","maxDataValidations exceeded.");const r=[],d=new Set;let h=0;const u=c=>{if(h+c>t)throw new S("RESOURCE_LIMIT","maxValidationTextCharacters exceeded.");h+=c};for(let c=0;c<e;c++){O(n);const g=l[c];y(g,["type","column","items","allowBlank","showErrorMessage","errorStyle","errorTitle","errorMessage"],"data validation");const{type:w,column:T,items:v,allowBlank:E,showErrorMessage:R,errorStyle:I,errorTitle:z,errorMessage:j}=g;if(w!=="list")throw new TypeError("Only inline-list data validation is supported.");const M=b(o,T,"Validation");if(d.has(M))throw new TypeError("A data column cannot have multiple validation rules.");if(d.add(M),p(E,"allowBlank"),p(R,"showErrorMessage"),I!==void 0&&!["stop","warning","information"].includes(I))throw new TypeError("Unsupported validation error style.");if(!Array.isArray(v))throw new TypeError("Inline validation lists require a nonempty string array.");const L=v.length;if(!L)throw new TypeError("Inline validation lists require a nonempty string array.");if(L>254)throw new RangeError("Inline validation lists must fit 255 UTF-16 units including quotes and separators.");let B='"';for(let A=0;A<L;A++){O(n);const U=v[A];if(typeof U!="string")throw new TypeError("Inline validation choices must be strings.");if(U.length>253||U.includes(","))throw new RangeError("Inline validation choices cannot contain commas and must fit the 255-character list source.");P(U,"reject");const W=U.replace(/"/g,'""');if(B.length+(A?1:0)+W.length+1>255)throw new RangeError("Inline validation lists must fit 255 UTF-16 units including quotes and separators.");B+=(A?",":"")+W}B+='"';const Z=m(z,32,"Validation error title"),V=m(j,255,"Validation error message");u(B.length+(Z?.length??0)+(V?.length??0));const _=' type="list" allowBlank="'+(E===!1?0:1)+'" showErrorMessage="'+(R===!1?0:1)+'" errorStyle="'+(I??"stop")+'"'+(Z===void 0?"":' errorTitle="'+k(Z,"reject")+'"')+(V===void 0?"":' error="'+k(V,"reject")+'"');r.push(Object.freeze({column:M,attributes:_,formula:B}))}return O(n),Object.freeze({rules:Object.freeze(r),count:e,textCharacters:h})}function*a(l,o,s,t){if(!(!l.count||!s||t?.length===0)){yield'<dataValidations count="'+l.count+'">';for(const n of l.rules){const e=x(n.column,n.column,o,s,t);yield"<dataValidation"+n.attributes+' sqref="'+e+'"><formula1>'+C(n.formula,"reject")+"</formula1></dataValidation>"}yield"</dataValidations>"}}return Object.freeze({prepareDataValidations:f,dataValidationsXml:a})})(),jt=(()=>{const{checkAbort:S,consumeRows:O,inputRows:P,pause:k,taskYieldDue:C}=we,{ChunkedTextSink:y,BlobByteSink:p}=Ie,{OfficeIMOError:b}=pe,{notifyProgress:x}=Ge,{copyColumns:m,createRowProjector:f}=Ne,{EntryWriter:a}=pt,{xmlDeclaration:i}=Pe,{officeRelationshipsNamespace:l}=st,{Cell:o,cellText:s,columnName:t,inlineText:n,excelDate:e,copyValue:r}=_e,{spreadsheetNamespace:d,colorArgb:h,validateStylePatch:u,copyStylePatch:c}=Xe,{copyHyperlink:g,copyImage:w,hyperlinksXml:T,cellPosition:v}=Je,{ExportCell:E,assertScalar:R}=ve,{ReportLayout:I,ComputedTotal:z,printXml:j}=It,{cleanXml:M}=Pe,{ConditionalFormats:L,prepareConditionalFormats:B}=Xt,{isDate:Z}=Me,{FormulaCell:V,formulaXml:_,isSubtotalFormula:A}=Ke,{prepareDataValidations:U,dataValidationsXml:W}=qt,{qualifiedCell:q,qualifiedColumnRange:X,resolveDataColumn:Y}=Ye,{dataRowRanges:F,dataRowCount:H}=at,{captureColumnOutlines:K,columnOutlineMap:re,validateOutlinePositions:ne}=Ot,he=65530;function oe(be){if(be>he)throw new RangeError("Excel supports at most 65,530 hyperlinks per worksheet; split the sheet.")}class ee{book;table;preserved;chartData;validations;columns;project;name;declared;options;entry;completion;prepared;buffer;output=new p;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(D,G,N,Q,se=!1,ce=[],ae=!1,fe={rules:[],count:0,textCharacters:0}){this.book=D,this.table=Q,this.preserved=se,this.chartData=ae,this.validations=fe,this.columns=m(N.columns??[],!0).map(ie=>Object.freeze(ie));const me=N.alternatingRowStyle;this.options={...N,...N.autoSize?{autoSize:{...N.autoSize}}:{},...N.mergedCells?{mergedCells:[...N.mergedCells]}:{},...N.title?{title:{...N.title,...N.title.style?{style:c(N.title.style)}:{}}}:{},...N.print?{print:{...N.print,...N.print.margins?{margins:{...N.print.margins}}:{}}}:{},...N.footer?{footer:{...N.footer,...N.footer.values?{values:N.footer.values.map(r)}:{},...N.footer.totals?{totals:{...N.footer.totals}}:{},...N.footer.style?{style:c(N.footer.style)}:{}}}:{},...me?{alternatingRowStyle:c(me)}:{}},this.layout=new I(this.columns,this.options,D.settings.invalidCharacterPolicy,D.settings.limits?.maxMergedRanges??1e4,D.settings.limits?.maxBufferedCells??1e5),this.titleStyle=N.title?D.styles.compose(D.styles.compose(0,{font:{bold:!0,size:18}}),this.options.title.style??{}):0,this.headerRows=this.layout.headerRows;for(const ie of N.hyperlinks??[]){const J=g(ie,D.settings.invalidCharacterPolicy);this.links.push(J),this.linkedCells.add(J.cell)}D.checkLinks(this.links.length),this.declared=this.columns.map((ie,J)=>({column:ie,letter:t(J+1),style:D.styles.forColumn(ie),dateStyle:D.styles.forColumn(ie,!1,void 0,!0),headerStyle:this.headerRows?N.headerStyle??D.styles.forColumn({header:ie.header,...ie.wrapText===void 0?{}:{wrapText:ie.wrapText},...ie.alignment===void 0?{}:{alignment:ie.alignment}},N.boldHeader!==!1,N.headerFill):0})),this.conditional=new L(ce,D.styles),D.retainLink(this.links.length),this.name=typeof G=="function"?G():G,this.project=f(this.columns,{sheetName:this.name,firstDataRow:this.headerRows+1},D.settings.signal,D.valueValidator)}static create(D,G,N,Q,se=!1,ce,ae){return new ee(D,G,N,Q,se,ce,!1,ae)}static createChartData(D,G){return new ee(D,G.dataSheetName,{columns:[{header:"Category"},...G.data.series.map(N=>({header:N.name,type:"number"}))]},void 0,!1,[],!0)}static validate(D,G){const N=m(G.columns??[],!0),Q=U(G.dataValidation,N,D.availableDataValidations,D.availableValidationTextCharacters,D.settings.signal);D.checkConditionalFormats(G.conditionalFormats?.length??0);const se=B(G.conditionalFormats,N,D.settings.invalidCharacterPolicy);D.styles.checkDifferentials(se.flatMap(ae=>ae.style?[ae.style]:[]));const ce=new I(N,G,D.settings.invalidCharacterPolicy,D.settings.limits?.maxMergedRanges??1e4,D.settings.limits?.maxBufferedCells??1e5);if(D.checkMerges(ce.mergeCount),G.title?.style&&u(G.title.style),G.title&&D.styles.compose(D.styles.compose(0,{font:{bold:!0,size:18}}),G.title.style??{}),G.footer?.style&&D.styles.compose(0,G.footer.style),G.hyperlinks!==void 0){if(!Array.isArray(G.hyperlinks))throw new TypeError("Hyperlinks must be an array.");oe(G.hyperlinks.length);const ae=new Set;for(const fe of G.hyperlinks){const me=g(fe,D.settings.invalidCharacterPolicy),ie=v(me.cell);if(ce.regions.covered(ie.column,ie.row))throw new TypeError("Hyperlinks cannot address a covered merged cell.");if(ae.has(me.cell))throw new TypeError("Duplicate hyperlink cell: "+me.cell);ae.add(me.cell)}}if(N.length>16384)throw new RangeError("Excel supports at most 16,384 columns.");if(G.includeHeader===!1&&(G.freezeHeader||G.autoFilter))throw new TypeError("A frozen header or autofilter requires a header row.");G.headerFill!==void 0&&h(G.headerFill),G.headerStyle!==void 0&&D.styles.validateStyle(G.headerStyle),G.alternatingRowStyle!==void 0&&D.styles.compose(0,G.alternatingRowStyle);for(const ae of[G.rowStyle,G.cellStyle,G.rowOutline])if(ae!==void 0&&typeof ae!="function")throw new TypeError("Row and style callbacks must be functions.");if(G.maxOutlineLevel!==void 0&&(!Number.isInteger(G.maxOutlineLevel)||G.maxOutlineLevel<0||G.maxOutlineLevel>7))throw new RangeError("Maximum outline level must be an integer from zero through seven.");if(ne(G),K(G.columnOutlines,N.length),G.rowOutline&&G.maxOutlineLevel===void 0)throw new TypeError("A row outline callback requires maxOutlineLevel before streamed rows are written.");if(!G.rowOutline&&G.maxOutlineLevel!==void 0)throw new TypeError("maxOutlineLevel requires a row outline callback.");for(const ae of[G.rowHeight,G.headerHeight])if(ae!==void 0&&(!Number.isFinite(ae)||ae<=0||ae>409))throw new RangeError("Row height must be positive and at most 409 points.");if(G.freezeColumns!==void 0&&(!Number.isInteger(G.freezeColumns)||G.freezeColumns<0||G.freezeColumns>N.length||G.freezeColumns>=16384))throw new RangeError("Frozen columns must be within the declared columns and leave a valid scrollable column.");if(G.table&&G.includeHeader===!1)throw new TypeError("Excel tables require a header row.");if(G.defaultColumnWidth!==void 0&&(!Number.isFinite(G.defaultColumnWidth)||G.defaultColumnWidth<0||G.defaultColumnWidth>255))throw new RangeError("Default column width must be from 0 through 255 characters.");for(const ae of N){if(ae.width!==void 0&&(!Number.isFinite(ae.width)||ae.width<0||ae.width>255))throw new RangeError("Column width must be from 0 through 255 characters.");if(ae.type!==void 0&&!["string","number","boolean","date"].includes(ae.type)&&!D.writerFor(ae.type))throw new TypeError("Invalid column type: "+ae.type);if(ae.alignment!==void 0&&!["left","center","right","fill","justify","distributed"].includes(ae.alignment))throw new TypeError("Invalid horizontal alignment.");if(s(ae.header,D.settings.invalidCharacterPolicy),ae.style!==void 0&&D.styles.validateStyle(ae.style),ae.format!==void 0&&(typeof ae.format!="string"||ae.format.length>255))throw new TypeError("Column format must be a string of at most 255 characters.")}return{conditional:se,validations:Q}}cell(D,G,N,Q=!1,se,ce,ae,fe=!1,me=!1,ie=!0){const J=this.declared[G],$=D instanceof z?D:void 0;$&&(D=$.value);let te=D instanceof V?D:void 0;te&&(D=te.cachedValue);let le=D instanceof E?D.presentation:void 0,de=D instanceof E?D.link:void 0;D instanceof E&&(D=D.value);const ue=te?.style??(D instanceof o?D.style:void 0),Se=(this.completedRegions??this.layout.regions).covered(G+1,N),Ae=D instanceof o?D.value:D,Te=Se&&(Ae==null||Ae==="");if(!Q&&!fe&&J.column.type&&!Te){const ke=this.book.writerFor(J.column.type);if(ke){if(te)throw new TypeError("An explicit FormulaCell cannot also pass through a custom cell value writer; return it from the writer instead.");D=ke(D instanceof o?D.value:D,{column:J.column,rowIndex:N-this.headerRows-1,worksheetRow:N,columnIndex:G,sheetName:this.name})}}D instanceof V&&(te=D,D=te.cachedValue),D instanceof E&&(le=D.presentation,de=D.link,D=D.value);const Ee=te?.style??(D instanceof o?D.style??ue:ue);if(D instanceof o&&(D=D.value),R(D),Se){if(de)throw new TypeError("Hyperlinks cannot address a covered merged cell.");if(te||$||D!=null&&D!=="")throw new TypeError("A merged range would hide the value at "+J.letter+N+"; covered cells must be empty.");D=void 0}const xe=Z(D)?"date":typeof D;if(!Q&&!fe&&D!=null&&J.column.type&&!this.book.writerFor(J.column.type)&&J.column.type!==xe)throw new TypeError("Cell "+J.letter+N+" does not match column type "+J.column.type+".");let ge=Ee===void 0?Q?J.headerStyle:$?.operation==="count"?0:xe==="date"?J.dateStyle:J.style:this.book.styles.validateStyle(Ee);if(Q&&xe==="date"&&Ee===void 0&&this.options.headerStyle===void 0&&(ge=this.book.styles.dateHeader(ge,J.dateStyle)),me&&(ge=this.titleStyle),!Q&&!fe){if(Ee===void 0){const ze=ge,De=ae?.get(ze);De!==void 0?ge=De:((N-this.headerRows)%2===0&&this.options.alternatingRowStyle&&(ge=this.book.styles.compose(ge,this.options.alternatingRowStyle)),se!==void 0&&(ge=this.book.styles.compose(ge,se)),ae?.set(ze,ge))}const ke=ce&&this.options.cellStyle?.({...ce,value:D,column:J.column,columnIndex:G});ke!==void 0&&(ge=this.book.styles.compose(ge,ke))}fe&&this.options.footer?.style&&Ee===void 0&&(ge=this.book.styles.compose(ge,this.options.footer.style)),le&&Ee===void 0&&(ge=this.book.styles.compose(ge,{...le.background===void 0?{}:{fill:{color:le.background}},...le.color===void 0&&le.bold===void 0&&le.italic===void 0?{}:{font:{...le.color===void 0?{}:{color:le.color},...le.bold===void 0?{}:{bold:le.bold},...le.italic===void 0?{}:{italic:le.italic}}},...le.wrapText===void 0?{}:{wrapText:le.wrapText},...le.alignment===void 0?{}:{alignment:le.alignment},...le.numberFormat===void 0?{}:{numberFormat:le.numberFormat}}));const je=typeof D=="string"?D.length:0;let Oe=this.preserved||Q||fe?je:void 0;if(xe==="string"&&je>32767&&M(D,this.book.settings.invalidCharacterPolicy).length>32767){const ke=J.letter+N;if(de||this.linkedCells.has(ke))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),Oe!==void 0&&(this.book.budget.release(1,Oe),Oe=void 0);const ze=this.book.preserveText(this.name,ke,D);this.book.retainLink(),this.internalLinks.push({cell:ke,location:ze.location}),this.linkedCells.add(ke),D=ze.preview}if(de&&this.appendHyperlink({cell:J.letter+N,...de}),xe==="date"&&(D=e(D,this.book.settings.dateMode)),!Q&&!fe&&ie&&(!te||!A(te))&&this.layout.accept(G,D),!Q&&!fe&&this.chartSources.length)for(const ke of this.chartSources)ke.observe(N-this.headerRows-1,G+1,D);const Re='<c r="'+J.letter+N+'" s="'+ge+'"';if(te&&this.book.retainFormula(te.formula.length),this.book.budget.cell(te?te.formula:D,Oe),te)return Re+(D===null?' t="str"':"")+">"+_(te)+"</c>";if($)return Re+(D===null?' t="str"':"")+"><f>"+$.formula.replace(/"/g,"&quot;")+"</f><v>"+(D??"")+"</v></c>";if(D==null||xe==="number"&&!Number.isFinite(D)||D==null)return Re+"/>";if(xe==="string")return Re+' t="inlineStr"><is>'+n(D,this.book.settings.invalidCharacterPolicy)+"</is></c>";if(xe==="boolean")return Re+' t="b"><v>'+(D?1:0)+"</v></c>";if(xe!=="number"&&xe!=="date")throw new TypeError("Excel cells must be strings, numbers, booleans, Dates or null.");return Re+"><v>"+D+"</v></c>"}*rowXml(D,G,N,Q=!1,se=!1){const ce=se?this.options.title?.height??28:N?this.options.headerHeight:this.options.rowHeight,ae=!N&&!Q&&(this.options.rowStyle||this.options.cellStyle||this.options.rowOutline)?Object.freeze({rowIndex:G-this.headerRows-1,worksheetRow:G,sheetName:this.name,values:Object.freeze(this.columns.map((J,$)=>D[$]instanceof V?D[$].cachedValue:D[$]instanceof o||D[$]instanceof E?D[$].value:D[$]))}):void 0,fe=ae&&this.options.rowStyle?.(ae);fe!==void 0&&u(fe);const me=this.outline(ae),ie=!N&&(fe||this.options.alternatingRowStyle)?new Map:void 0;yield'<row r="'+G+'"'+(ce===void 0?"":' ht="'+ce+'" customHeight="1"')+(me?.level?' outlineLevel="'+me.level+'"':"")+(me?.hidden?' hidden="1"':"")+(me?.collapsed?' collapsed="1"':"")+">";for(let J=0;J<this.columns.length;J++)yield this.cell(D[J],J,G,N,fe,ae,ie,Q,se,me?.hidden!==!0);yield"</row>"}outline(D){if(!D||!this.options.rowOutline)return;const G=this.options.rowOutline(D);if(G===void 0)return;if(G===null||typeof G!="object"||Array.isArray(G))throw new TypeError("Row outline callbacks must return metadata or undefined.");if(typeof G.then=="function")throw Promise.resolve(G).catch(()=>{}),new TypeError("Row outline callbacks must return synchronous metadata.");const{level:N,hidden:Q,collapsed:se}=G,ce=N??0;if(!Number.isInteger(ce)||ce<0||ce>this.options.maxOutlineLevel)throw new RangeError("Row outline level exceeds the declared maximum.");for(const ae of[Q,se])if(ae!==void 0&&typeof ae!="boolean")throw new TypeError("Row outline flags must be booleans.");return Object.freeze({level:ce,...Q===void 0?{}:{hidden:Q},...se===void 0?{}:{collapsed:se}})}writeRow(D,G,N,Q=!1,se=!1){const ce=this.rowXml(D,G,N,Q,se),ae=()=>{for(;;){const fe=ce.next();if(fe.done)return;if(this.buffer.append(fe.value))return this.buffer.flush().then(ae)}};return ae()}async sampleRow(D){if((this.pending.length+1)*this.columns.length>(this.book.settings.limits?.maxBufferedCells??1e5))throw new b("RESOURCE_LIMIT","Width sampling cell limit exceeded; reduce sampleRows or raise its bounded limit.");const G=[];let N=0;for(const Q of this.rowXml(D,this.count+this.headerRows+1,!1)){if(!this.started&&this.pendingCharacters+Q.length>(this.book.settings.limits?.maxBufferedCharacters??1e6)){if(this.options.autoSize?.sampleRows!==void 0)throw new b("RESOURCE_LIMIT","Width sampling text limit exceeded; reduce sampleRows or raise its bounded limit.");this.layout.sample(D),await this.start();for(const se of G)this.buffer.append(se)&&await this.buffer.flush();G.length=0}this.started?this.buffer.append(Q)&&await this.buffer.flush():(this.pendingCharacters+=Q.length,G.push(Q)),!this.started&&(++N&127)===0&&C()&&(await k(),S(this.book.settings.signal))}this.started||(this.layout.sample(D),this.pending.push(G))}reserveLayout(){if(!this.reservedLayout){if(!this.preserved){let D=0;if(this.options.title&&(D+=this.options.title.text.length),this.layout.firstHeaderRow)for(const G of this.layout.headings)for(const N of G){const Q=N instanceof E||N instanceof o?N.value:N;typeof Q=="string"&&(D+=Q.length)}if(this.layout.structuredFooter)for(const G of this.layout.structuredFooter.values)for(const N of G){const Q=N instanceof E?N.value:N;typeof Q=="string"&&(D+=Q.length)}else if(this.options.footer)for(let G=0;G<this.columns.length;G++){const N=this.columns[G],Q=this.options.footer.totals;if(Q&&Object.prototype.hasOwnProperty.call(Q,N.key??N.header))continue;const se=this.options.footer.values?.[G],ce=se instanceof E||se instanceof o?se.value:se;typeof ce=="string"&&(D+=ce.length)}this.book.budget.reserve(this.columns.length*(this.headerRows+this.layout.footerRows),D)}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 a(this.book.settings.compression,{write:J=>{this.book.retainBufferedBytes(J.length),this.output.write(J)}},this.book.settings.signal);const D=this.buffer=new y(this.entry,this.book.settings.signal),G=this.options,N=G.freezeColumns??0,Q=G.freezeHeader?this.headerRows:0,se=N&&Q?"bottomRight":N?"topRight":"bottomLeft",ce=t(N+1)+(Q+1),ae=re(G.columnOutlines),fe=!!G.rowOutline||ae.size>0,me=Math.max(0,...Array.from(ae.values(),J=>J.level??0));await D.write(i+'<worksheet xmlns="'+d+'" xmlns:r="'+l+'">'+(G.print||fe?"<sheetPr>"+(fe?'<outlinePr summaryBelow="'+(G.outlineSummaryBelow===!1?"0":"1")+'"'+(G.outlineSummaryRight===void 0?"":' summaryRight="'+(G.outlineSummaryRight?"1":"0")+'"')+' showOutlineSymbols="1"/>':"")+(G.print?'<pageSetUpPr fitToPage="1"/>':"")+"</sheetPr>":"")+'<sheetViews><sheetView workbookViewId="0">'+(N||Q?"<pane"+(N?' xSplit="'+N+'"':"")+(Q?' ySplit="'+Q+'"':"")+' topLeftCell="'+ce+'" activePane="'+se+'" state="frozen"/><selection pane="'+se+'" activeCell="'+ce+'" sqref="'+ce+'"/>':"")+"</sheetView></sheetViews>"+(fe?'<sheetFormatPr defaultRowHeight="15"'+(G.rowOutline?' outlineLevelRow="'+G.maxOutlineLevel+'"':"")+(ae.size?' outlineLevelCol="'+me+'"':"")+"/>":""));const ie=G.defaultColumnWidth??(this.table?20:void 0);if(this.columns.some((J,$)=>this.layout.widths[$]!==void 0||ie!==void 0||ae.has($))){await D.write("<cols>");for(let J=0;J<this.columns.length;J++){const $=this.layout.widths[J]??ie,te=ae.get(J);($!==void 0||te)&&await D.write('<col min="'+(J+1)+'" max="'+(J+1)+'"'+($===void 0?"":' width="'+$+'" customWidth="1"')+(te?.level?' outlineLevel="'+te.level+'"':"")+(te?.hidden?' hidden="1"':"")+(te?.collapsed?' collapsed="1"':"")+"/>")}await D.write("</cols>")}if(await D.write("<sheetData>"),G.title&&await this.writeRow(this.columns.map((J,$)=>$?"":G.title.text),1,!0,!1,!0),this.layout.firstHeaderRow)for(let J=0;J<this.layout.headings.length;J++)await this.writeRow(this.layout.headings[J],J+this.layout.firstHeaderRow,!0);for(const J of this.pending)for(const $ of J)D.append($)&&await D.flush();this.pending=[],this.pendingCharacters=0}async addRows(D){if(this.book.assertOpen(),this.completion)throw new b("INVALID_STATE","Worksheet is closed.");if(this.busy)throw new b("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 G=performance.now();const N=()=>{performance.now()-G>=50&&(this.progress(),G=performance.now())},Q=()=>{if(this.count++,!this.started&&this.pending.length>=this.layout.sampleRows)return this.start().then(N);if(!this.started&&C())return k().then(()=>{S(this.book.settings.signal),N()});N()};await O(D,this.book.settings.signal,se=>{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 ce=this.project(se,this.count),ae=this.started?this.writeRow(ce,this.count+this.headerRows+1,!1):this.sampleRow(ce);return ae?ae.then(Q):Q()}),this.buffer&&await this.buffer.flush(),this.progress(),S(this.book.settings.signal)}catch(G){throw this.failed=!0,this.error=G,await this.book.discard(G),G}finally{this.busy=!1}}progress(){!this.preserved&&!this.chartData&&x(this.book.settings.onProgress,{phase:"rows",rows:this.book.rowCount,sheetRows:this.reportRowCount,sheetName:this.name})}get rowCount(){return this.count}dataRange(D){if(this.failed)throw this.error;if(!this.completed)throw new b("INVALID_STATE","Close the worksheet before resolving its data range.");const G=Y(this.columns,D),N=F(this);if(N!==void 0){if(N.length>1)throw new b("INVALID_STATE","Grouped details are discontiguous; use the grouped result's detailRanges for explicit formula references.");const Q=N[0];return Q?X(this.name,G,Q.firstRow,Q.lastRow-Q.firstRow+1):void 0}return this.count?X(this.name,G,this.headerRows+1,this.count):void 0}get chartBindingMetadata(){const D=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((G,N)=>{const Q=D?.[N],se=Q instanceof E?Q.value:Q;return this.layout.firstHeaderRow&&se===G.header&&!this.layout.regions.covered(N+1,this.headerRows)?q(this.name,N+1,this.headerRows):void 0})}}retainChartBinding(D){this.chartSources.push(D)}get reportRowCount(){return this.preserved||this.chartData?0:H(this,this.headerRows,this.count)}get hidden(){return this.chartData}addChart(D){if(this.book.assertOpen(),this.completion)throw new b("INVALID_STATE","Worksheet is closed.");if(this.failed)throw this.error;this.nativeCharts.push(this.book.registerChart(D))}get charts(){return this.nativeCharts}releaseCharts(){this.nativeCharts.length=0}addImage(D){if(this.book.assertOpen(),this.completion)throw new b("INVALID_STATE","Worksheet is closed.");if(this.failed)throw this.error;const G=w(D,this.book.settings.invalidCharacterPolicy,N=>this.book.checkImage(N));this.book.retainImage(G.data.length),this.pictures.push(G)}addHyperlink(D){if(this.book.assertOpen(),this.completion)throw new b("INVALID_STATE","Worksheet is closed.");if(this.failed)throw this.error;this.appendHyperlink(D)}appendHyperlink(D){const G=g(D,this.book.settings.invalidCharacterPolicy),N=v(G.cell);if(this.layout.regions.covered(N.column,N.row))throw new TypeError("Hyperlinks cannot address a covered merged cell.");if(this.linkedCells.has(G.cell))throw new TypeError("Duplicate hyperlink cell: "+G.cell);oe(this.links.length+this.internalLinks.length+1),this.book.retainLink(),this.links.push(G),this.linkedCells.add(G.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 t(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 b("INVALID_STATE","Await addRows before closing the worksheet.");try{await this.finish()}catch(D){throw await this.book.discard(D),D}}finish(D){if(this.completion)return this.completion;if(this.failed)throw this.error;return this.completion=(async()=>{try{const G=this.completedRegions=this.layout.finalRegions(this.count,this.book.settings.limits?.maxMergedRanges??1e4);G.validateRows(this.totalRows);for(const se of this.chartSources)se.finish();this.chartSources.length=0;for(const se of this.links){const ce=v(se.cell);if(ce.column>this.columns.length||ce.row>this.totalRows)throw new RangeError("Hyperlinks must address cells within the exported rows and columns.");if(G.covered(ce.column,ce.row))throw new TypeError("Hyperlinks cannot address a covered merged cell.")}if(await this.start(),D)for await(const se of P(D,this.book.settings.signal))this.book.budget.row(this.count+1),await this.writeRow(this.project(se,this.count),this.headerRows+this.count+1,!1),this.count++;if(this.layout.structuredFooter)for(let se=0;se<this.layout.footerRows;se++)await this.writeRow(this.layout.structuredFooter.values[se],this.headerRows+this.count+se+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+":"+t(this.columns.length)+(this.count+this.headerRows)+'"/>'),G.references.length&&await this.buffer.write('<mergeCells count="'+G.references.length+'">'+G.references.map(se=>'<mergeCell ref="'+se+'"/>').join("")+"</mergeCells>");const N=F(this);for(const se of this.conditional.xml(this.headerRows,this.count,this.totalRows,N))await this.buffer.write(se);for(const se of W(this.validations,this.headerRows,this.count,N))await this.buffer.write(se);(this.links.length||this.internalLinks.length)&&await this.buffer.write(T(this.links,this.book.settings.invalidCharacterPolicy,this.internalLinks)),await this.buffer.write(j(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 Q=await this.entry.close();!this.book.settings.sink&&!this.failed&&(this.prepared={...Q,chunks:this.output.takeChunks()}),this.completed=!0}catch(G){throw await this.discard(G),G}})()}takePrepared(){const D=this.prepared;return this.prepared=void 0,D}async discard(D){this.failed=!0,this.error=D,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(D)}}return Object.freeze({Worksheet:ee})})(),Zt=(()=>{const{escapeOoxmlAttribute:S,escapeXml:O,xmlDeclaration:P}=Pe,{cellText:k,columnName:C}=_e,{spreadsheetNamespace:y}=Xe,{ExportCell:p}=ve,{Cell:b}=_e,{totalFormula:x}=It;function m(i,l,o,s){const t=l.name??"Table"+i;if(typeof t!="string"||t.length>255||!/^[A-Za-z_][A-Za-z0-9_.]*$/.test(t)||/^(?:[A-Za-z]{1,3}[1-9][0-9]*|R[1-9][0-9]*C[1-9][0-9]*|R|C)$/i.test(t))throw new TypeError("Table names must be ASCII identifiers, at most 255 characters, and cannot be cell references.");const n=l.style??"TableStyleMedium2",e=/^TableStyle(Light|Medium|Dark)([1-9][0-9]?)$/.exec(n);if(!e||Number(e[2])>({Light:21,Medium:28,Dark:11}[e[1]]??0))throw new TypeError("Unknown built-in Excel table style.");const r=o.map(d=>k(d.header,s));if(!r.length||r.some(d=>!d.trim()||d.length>255)||new Set(r.map(d=>d.toLowerCase())).size!==r.length)throw new TypeError("Excel tables require nonblank, unique headers of at most 255 characters.");return Object.freeze({id:i,name:t,headers:Object.freeze(r),keys:Object.freeze(o.map(d=>d.key??d.header)),options:Object.freeze({...l,style:n})})}function f(i,l,o,s=1,t){const n="A"+s+":"+C(i.headers.length)+(l+s),e="A"+s+":"+C(i.headers.length)+(l+s+(t?1:0)),r=i.options,d=S(i.name,o);return P+'<table xmlns="'+y+'" id="'+i.id+'" name="'+d+'" displayName="'+d+'" ref="'+e+'"'+(t?' totalsRowCount="1"':' totalsRowShown="0"')+'><autoFilter ref="'+n+'"/><tableColumns count="'+i.headers.length+'">'+i.headers.map((h,u)=>{const c=i.keys[u],g=t?.totals&&Object.prototype.hasOwnProperty.call(t.totals,c)?t.totals[c]:void 0,w=t?.values?.[u],T=w instanceof b||w instanceof p?w.value:w,v=g&&["average","min","max"].includes(g),E=g?' totalsRowFunction="'+(v?"custom":g==="count"?"countNums":g)+'"':typeof T=="string"?' totalsRowLabel="'+S(T,o)+'"':"";return'<tableColumn id="'+(u+1)+'" name="'+S(h,o)+'"'+E+(v?"><totalsRowFormula>"+O(x(g,C(u+1),s,l),o)+"</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:m,tableXml:f})})(),$t=(()=>{const{OfficeIMOError:S}=pe,{cleanXml:O}=Pe;class P{sheetName;maximum;policy;reserve;entries=[];characters=0;rows=0;constructor(b,x,m,f){this.sheetName=b,this.maximum=x,this.policy=m,this.reserve=f}add(b,x,m){const f=O(m,this.policy);if(this.characters+f.length>this.maximum)throw new S("RESOURCE_LIMIT","maxOverflowCharacters exceeded; use CSV or raise the bounded preservation limit.");let a=0;for(const o of C(f))a++;if(this.rows+a>1048575)throw new S("RESOURCE_LIMIT","Text overflow exceeds the worksheet row limit.");this.reserve(a*5,f.length+a*(b.length+x.length),this.rows+a);const i=this.rows+2;this.entries.push({sheet:b,cell:x,text:f,first:i,parts:a}),this.rows+=a,this.characters+=f.length;const l="\n[Full text: "+this.sheetName+"!D"+i+"; "+a+" parts]";return{preview:k(f,32767-l.length)+l,location:"'"+this.sheetName.replace(/'/g,"''")+"'!D"+i}}*values(){for(const b of this.entries){let x=0;for(const m of C(b.text))yield[b.sheet,b.cell,++x,m,b.parts]}}clear(){this.entries=[],this.characters=0,this.rows=0}}function k(p,b){let x=Math.min(b,p.length);return x<p.length&&/[\ud800-\udbff]/.test(p[x-1]??"")&&x--,p.slice(0,x)}function*C(p){let b=0;for(;b<p.length;){const x=k(p.slice(b,b+32768),32767);b+=x.length,yield x}}return Object.freeze({TextOverflow:P,clipText:k})})(),qe=(()=>{const{captureFields:S}=Ce,O=["signal","onProgress","limits","sink","dateMode","compression","invalidCharacterPolicy","appProperties","cellValueWriters","oversizedText","creator","title","subject","description","created","modified"],P=["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"],k=["maxRows","maxCells","maxTextCharacters","maxOutputBytes","maxStyles","maxSheets","maxOverflowCharacters","maxHyperlinks","maxImageBytes","maxBufferedCells","maxBufferedCharacters","maxMergedRanges","maxConditionalFormats","maxDifferentialStyles","maxCharts","maxChartPoints","maxChartTextCharacters","maxFormulaCharacters","maxDataValidations","maxValidationTextCharacters"];function C(b){return S(b,k)}function y(b){const x=S(b,O);return{...x,...x.limits===void 0?{}:{limits:C(x.limits)}}}return Object.freeze({workbookOptionFields:O,sheetOptionFields:P,workbookLimitFields:k,captureWorkbookLimits:C,captureWorkbookOptions:y})})(),Kt=(()=>{const{checkAbort:S}=we,{NotSupportedError:O,OfficeIMOError:P}=pe,{cleanXml:k}=Pe,{captureFields:C}=Ce;function y(f,a,i){if(!f||typeof f!="object"||Array.isArray(f))throw new TypeError(i+" must be an object.");for(const l of Object.keys(f))if(!a.includes(l))throw new O(i+"."+l);return C(f,a)}function p(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 b(f){const a=y(f,["kind","sheet","firstRow","rowCount","categoryColumn","series"],"chart.data");if(a.kind!=="range")throw new TypeError("A chart range must declare kind: range.");if(!a.sheet||typeof a.sheet!="object"||Array.isArray(a.sheet))throw new TypeError("A chart range needs its owning worksheet.");const i=a.firstRow===void 0?0:a.firstRow,l=a.rowCount;if(!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(l)||l<1||i+l>1048576)throw new RangeError("Chart data rows must form a nonempty finite Excel range.");if(p(a.categoryColumn),!Array.isArray(a.series)||a.series.length<1||a.series.length>255)throw new RangeError("A chart needs from 1 through 255 series.");const o=a.series.map(s=>{const t=y(s,["column","name","color"],"chart.data.series");if(p(t.column),t.name!==void 0&&typeof t.name!="string")throw new TypeError("Chart series name must be a string.");if(t.color!==void 0&&(typeof t.color!="string"||!/^#?[0-9a-fA-F]{6}$/.test(t.color)))throw new TypeError("Chart colors must be opaque six-digit RGB hex values.");return Object.freeze(t)});return Object.freeze({kind:"range",sheet:a.sheet,firstRow:i,rowCount:l,categoryColumn:a.categoryColumn,series:Object.freeze(o)})}function x(f,a,i,l,o="columnClustered"){S(l);const s=f.rowCount,t=f.firstRow??0,n=s*f.series.length,e=a.categoryColumn;if(n>i.availablePoints)throw new P("RESOURCE_LIMIT","maxChartPoints exceeded.");if(a.source!==f.sheet||!Number.isInteger(a.headerRows)||a.headerRows<0||a.headerRows+t+s>1048576||a.seriesColumns.length!==f.series.length||a.seriesNames.length!==f.series.length||a.valueFormulas.length!==f.series.length||a.nameFormulas.length!==f.series.length)throw new TypeError("Resolved chart range does not match its declared columns and data rows.");for(const z of[a.categoryColumn,...a.seriesColumns])if(!Number.isInteger(z)||z<1||z>16384)throw new RangeError("Resolved chart columns must be one-based Excel columns.");if(a.seriesColumns.includes(e))throw new TypeError("Chart category and numeric series must use different columns.");let r=0;const d=f.series.map((z,j)=>{const M=z.name??a.seriesNames[j];if(typeof M!="string"||M.length>32767)throw new TypeError("Chart series names must fit Excel text cells.");if(r+=M.length,r>i.availableText)throw new P("RESOURCE_LIMIT","maxChartTextCharacters exceeded.");return k(M,i.policy)}),h=f.series.map(z=>z.color?.replace(/^#/,"").toUpperCase()),u=new Array(s),c=f.series.map(()=>new Array(s)),g=f.series.map(()=>0),w=f.series.map(()=>!1);let T=0,v;const E=()=>{if(S(l),!v){if(T!==s||g.some(z=>z!==s))throw new TypeError("Chart range did not receive every declared data row and numeric value.");if(o==="pie"&&!w[0])throw new RangeError("A pie chart needs at least one positive value.");v=Object.freeze({categories:Object.freeze(u),series:Object.freeze(c.map((z,j)=>Object.freeze({name:d[j],values:Object.freeze(z),...h[j]===void 0?{}:{color:h[j]}})))})}},R=Object.freeze({get categories(){return E(),v.categories},get series(){return E(),v.series}}),I=new Map;return a.seriesColumns.forEach((z,j)=>{const M=I.get(z)??[];M.push(j),I.set(z,M)}),Object.freeze({source:a.source,points:n,textCharacters:r,data:R,references:Object.freeze({categories:a.categoryFormula,values:Object.freeze([...a.valueFormulas]),names:Object.freeze(a.nameFormulas.map((z,j)=>f.series[j].name===void 0?z:void 0))}),observe(z,j,M){S(l);const L=z-t;if(!(L<0||L>=s)){if(v)throw new P("INVALID_STATE","Chart cache is already finalized.");if(j===e){if(typeof M!="string"||M.length>32767)throw new TypeError("Chart category cells must contain strings of at most 32,767 UTF-16 units.");if(u[L]!==void 0)throw new P("INVALID_STATE","A chart category cell was observed more than once.");i.retainText(M.length),u[L]=k(M,i.policy),T++}for(const B of I.get(j)??[]){if(typeof M!="number"||!Number.isFinite(M))throw new TypeError("Chart series cells require finite numbers or numeric formula caches.");if(o==="pie"&&M<0)throw new RangeError("Pie charts require nonnegative values.");if(c[B][L]!==void 0)throw new P("INVALID_STATE","A chart value cell was observed more than once.");c[B][L]=M,g[B]=g[B]+1,M>0&&(w[B]=!0)}}},finish:E})}return Object.freeze({captureChartRange:b,prepareChartBinding:x})})(),Jt=(()=>{const{checkAbort:S}=we,{NotSupportedError:O,OfficeIMOError:P}=pe,{cleanXml:k}=Pe,{copyDrawingAnchor:C}=Je,{captureFields:y}=Ce,{captureChartRange:p,prepareChartBinding:b}=Kt;function x(i,l,o){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(o+" must be an object.");for(const s of Object.keys(i))if(!l.includes(s))throw new O(o+"."+s)}function m(i,l,o){return x(i,l,o),y(i,l)}function f(i,l,o,s,t,n){if(S(t),i=m(i,["type","data","row","column","width","height","description","title","language","legend","dataLabels","categoryAxis","valueAxis"],"chart"),!["columnClustered","barClustered","line","pie"].includes(i.type))throw new O("chart type "+i.type);const e=i.type,r=m(i.data,["kind","sheet","firstRow","rowCount","categoryColumn","categories","series"],"chart.data"),d=r.kind==="range"?p(r):void 0;d||x(r,["categories","series"],"chart.data");const h=d?void 0:r.categories,u=d?.series??r.series;if(!d&&!Array.isArray(h))throw new TypeError("Chart categories must be a nonempty array of strings.");if(!Array.isArray(u))throw new RangeError("A chart needs from 1 through 255 series.");const c=d?.rowCount??h.length,g=u.length;if(!c)throw new TypeError("Chart categories must be a nonempty array of strings.");if(!g||g>255)throw new RangeError("A chart needs from 1 through 255 series.");if(!d&&c>1048575)throw new RangeError("Chart data must fit Excel's rows including its header.");if(e==="pie"&&g!==1)throw new TypeError("A pie chart supports exactly one series.");const w=c*g;if(w>o)throw new P("RESOURCE_LIMIT","maxChartPoints exceeded.");let T=0;const v=(W,q)=>{if(typeof W!="string")throw new TypeError(q+" must be a string.");if(W.length>32767)throw new RangeError(q+" exceeds 32,767 UTF-16 units.");if(T+=W.length,T>s)throw new P("RESOURCE_LIMIT","maxChartTextCharacters exceeded.");return k(W,l)},E=(W,q)=>W===void 0?void 0:v(W,q),R=E(i.title,"Chart title"),I=E(i.description,"Chart description"),z=E(i.language,"Chart language");let j;if(z!==void 0)try{if(j=Intl.getCanonicalLocales(z)[0],!j)throw new RangeError}catch{throw new TypeError("Chart language must be a language tag such as pl or pl-PL.")}const M=C({row:i.row,column:i.column,width:i.width,height:i.height,...I===void 0?{}:{description:I}},l);if(i.legend!==void 0&&i.legend!==!1&&!["right","bottom","left","top"].includes(i.legend))throw new TypeError("Unsupported chart legend position.");let L;if(i.dataLabels!==void 0){const W=m(i.dataLabels,["showValue","showCategoryName","showSeriesName","showPercent","position","numberFormat"],"chart.dataLabels");for(const Y of["showValue","showCategoryName","showSeriesName","showPercent"])if(W[Y]!==void 0&&typeof W[Y]!="boolean")throw new TypeError("Chart label flags must be booleans.");if(W.showPercent&&e!=="pie")throw new TypeError("Percent data labels require a pie chart.");const q=e==="pie"?["center","insideEnd","outsideEnd","bestFit"]:e==="line"?["center","above","below","left","right"]:["center","insideEnd","outsideEnd"];if(W.position!==void 0&&!q.includes(W.position))throw new TypeError("Data label position is unsupported for this chart type.");const X=E(W.numberFormat,"Data label number format");if(X!==void 0&&!X.trim())throw new TypeError("Data label number format cannot be blank.");L=Object.freeze({...W,...X===void 0?{}:{numberFormat:X}})}if(e==="pie"&&(i.categoryAxis!==void 0||i.valueAxis!==void 0))throw new TypeError("Pie charts have no axes.");let B,Z;if(i.categoryAxis!==void 0){const W=E(m(i.categoryAxis,["title"],"chart.categoryAxis").title,"Category axis title");B=Object.freeze(W===void 0?{}:{title:W})}if(i.valueAxis!==void 0){const W=m(i.valueAxis,["title","minimum","maximum","numberFormat"],"chart.valueAxis");for(const Y of[W.minimum,W.maximum])if(Y!==void 0&&!Number.isFinite(Y))throw new TypeError("Chart axis bounds must be finite numbers.");if(W.minimum!==void 0&&W.maximum!==void 0&&W.minimum>=W.maximum)throw new RangeError("Chart axis minimum must be below its maximum.");const q=E(W.title,"Value axis title"),X=E(W.numberFormat,"Value axis number format");if(X!==void 0&&!X.trim())throw new TypeError("Value axis number format cannot be blank.");Z=Object.freeze({...W,...q===void 0?{}:{title:q},...X===void 0?{}:{numberFormat:X}})}const V={...M,type:e,...j===void 0?{}:{language:j},...R===void 0?{}:{title:R},...I===void 0?{}:{description:I},...i.legend===void 0?{}:{legend:i.legend},...L===void 0?{}:{dataLabels:L},...B===void 0?{}:{categoryAxis:B},...Z===void 0?{}:{valueAxis:Z}};if(d){if(!n)throw new TypeError("A chart range must belong to the current workbook.");const{descriptor:W,retainText:q}=n(d),X=b(d,W,{availablePoints:o,availableText:s-T,retainText:q,policy:l},t,e);return Object.freeze({...V,data:X.data,binding:X,points:w,textCharacters:T+X.textCharacters})}const _=h,A=[],U=[];for(let W=0;W<c;W++)(W&255)===0&&S(t),A.push(v(_[W],"Chart category"));for(let W=0;W<g;W++){const q=u[W],X=m(q,["name","values","color"],"chart.series"),Y=v(X.name,"Chart series name"),F=X.values,H=X.color;if(!Array.isArray(F)||F.length!==c)throw new TypeError("Chart series values must match the category count.");if(H!==void 0&&(typeof H!="string"||!/^#?[0-9a-fA-F]{6}$/.test(H)))throw new TypeError("Chart colors must be opaque six-digit RGB hex values.");let K=!1;const re=[];for(let ne=0;ne<c;ne++){(ne&255)===0&&S(t);const he=F[ne];if(typeof he!="number"||!Number.isFinite(he))throw new TypeError("Chart values must be finite numbers.");if(e==="pie"&&he<0)throw new RangeError("Pie charts require nonnegative values.");he>0&&(K=!0),re.push(he)}if(e==="pie"&&!K)throw new RangeError("A pie chart needs at least one positive value.");U.push(Object.freeze({name:Y,values:Object.freeze(re),...H===void 0?{}:{color:H.replace(/^#/,"").toUpperCase()}}))}return Object.freeze({...V,data:Object.freeze({categories:Object.freeze(A),series:Object.freeze(U)}),points:w,textCharacters:T})}return Object.freeze({prepareChart:f})})(),mt=(()=>{const{beginTask:S,checkAbort:O,pause:P,taskYieldDue:k}=we,{OfficeIMOError:C}=pe,{notifyProgress:y}=Ge,{ChunkedTextSink:p}=Ie,{ExportBudget:b}=We,{OpcPackage:x,officeRelationshipsNamespace:m,relationshipTypes:f,corePropertiesXml:a}=st,{escapeOoxmlAttribute:i,cleanXml:l,xmlDeclaration:o}=Pe,{StyleRegistry:s,spreadsheetNamespace:t}=Xe,{sheetName:n,assertXlsxValue:e,copyValue:r}=_e,{copyColumns:d}=Ne,{captureFields:h}=Ce,{captureColumnOutlines:u}=Ot,{captureTableSpans:c}=Ve,{assertExportValue:g}=ve,{Worksheet:w}=jt,{defineTable:T,tableXml:v}=Zt,{copyHyperlink:E,drawingXml:R,drawingContentType:I}=Je,{TextOverflow:z}=$t,{captureWorkbookOptions:j,sheetOptionFields:M}=qe,{prepareChart:L}=Jt,{qualifiedColumnRange:B,resolveDataColumn:Z}=Ye,{chartContentType:V,writeChartXml:_}=Pt,A="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",U=Y=>"application/vnd.openxmlformats-officedocument.spreadsheetml."+Y+"+xml";function W(Y,F){const H=h(Y,M),K=d(H.columns??[],!0),re=H.footer&&h(H.footer,["rows","values","totals","style"]),ne=H.print&&h(H.print,["paper","orientation","fitToWidth","fitToHeight","repeatHeaders","margins","header","footer"]);return{...H,columns:K,...H.columnOutlines===void 0?{}:{columnOutlines:u(H.columnOutlines,K.length)},...H.headerRows===void 0?{}:{headerRows:c(H.headerRows,K.length)},...re?{footer:{...re,...re.rows===void 0?{}:{rows:c(re.rows,K.length)},...re.values===void 0?{}:{values:re.values.map(r)}}}:{},...H.table?{table:h(H.table,["name","style","bandedRows","bandedColumns","firstColumn","lastColumn"])}:{},...H.autoSize?{autoSize:h(H.autoSize,["sampleRows","minWidth","maxWidth"])}:{},...H.title?{title:h(H.title,["text","style","height"])}:{},...ne?{print:{...ne,...ne.margins===void 0?{}:{margins:h(ne.margins,["left","right","top","bottom","header","footer"])}}}:{},...H.hyperlinks?{hyperlinks:H.hyperlinks.map(he=>E(he,F))}:{}}}class q{portableValues=!1;static forTable(F){const H=new q(F);return H.portableValues=!0,H}get valueValidator(){return this.portableValues?g: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(F){if(this.assertOpen(),this.registering)throw new C("INVALID_STATE","Workbook registrations cannot be reentered from input getters.");this.registering=!0;try{return F()}finally{this.registering=!1}}budget;settings;constructor(F={}){F=j(F);const H=F.dateMode??"local",K=F.compression??"auto",re=F.invalidCharacterPolicy??"strip";if(H!=="local"&&H!=="utc")throw new RangeError("dateMode must be local or utc.");if(K!=="auto"&&K!=="store")throw new RangeError("compression must be auto or store.");if(F.oversizedText!==void 0&&!["reject","preserve"].includes(F.oversizedText))throw new RangeError("oversizedText must be reject or preserve.");if(l("",re),a(F,re),this.budget=new b(F.limits),this.styles=new s(re,F.limits?.maxStyles,F.limits?.maxDifferentialStyles),F.sink!==void 0&&typeof F.sink.write!="function")throw new TypeError("sink must be a ByteSink.");this.settings=Object.freeze({...F,...F.limits?{limits:Object.freeze({...F.limits})}:{},dateMode:H,compression:K,invalidCharacterPolicy:re}),this.writers=Object.freeze({...F.cellValueWriters});for(const ne of Object.values(this.writers))if(typeof ne!="function")throw new TypeError("Cell value writers must be functions.");S(),this.package=new x({compression:K,invalidCharacterPolicy:re,...F.signal?{signal:F.signal}:{},...F.sink?{sink:F.sink}:{},...F.limits?.maxOutputBytes===void 0?{}:{maxOutputBytes:F.limits.maxOutputBytes}}),this.package.setProperties(F,F.appProperties),this.addXmlPart("/xl/workbook.xml",U("sheet.main"),()=>this.workbookXml()),this.addXmlPart("/xl/styles.xml",U("styles"),()=>this.styles.toXml())}addXmlPart(F,H,K){this.package.addPart({uri:F,contentType:H,data:async re=>{const ne=new p(re,this.settings.signal);await ne.write(K()),await ne.close()}})}workbookXml(){return o+'<workbook xmlns="'+t+'" xmlns:r="'+m+'"><workbookPr date1904="0"/><bookViews><workbookView/></bookViews><sheets>'+this.sheets.map((F,H)=>'<sheet name="'+i(F.name,this.settings.invalidCharacterPolicy)+'" sheetId="'+(H+1)+'"'+(F.hidden?' state="hidden"':"")+' r:id="rId'+(H+1)+'"/>').join("")+"</sheets>"+(this.sheets.some(F=>F.printSettings)?"<definedNames>"+this.sheets.map((F,H)=>{const K="'"+F.name.replace(/'/g,"''")+"'!";return F.printSettings?'<definedName name="_xlnm.Print_Area" localSheetId="'+H+'">'+i(K+"$A$1:$"+F.lastColumn+"$"+F.totalRows,this.settings.invalidCharacterPolicy)+"</definedName>"+(F.printSettings.repeatHeaders&&F.firstHeaderRow?'<definedName name="_xlnm.Print_Titles" localSheetId="'+H+'">'+i(K+"$"+F.firstHeaderRow+":$"+F.headerRowCount,this.settings.invalidCharacterPolicy)+"</definedName>":""):""}).join("")+"</definedNames>":"")+(this.hasAuthoredFormulas?'<calcPr calcMode="auto" fullCalcOnLoad="1" forceFullCalc="1"/>':"")+"</workbook>"}assertOpen(){try{O(this.settings.signal)}catch(F){throw this.discard(F).catch(()=>{}),F}if(this.state==="failed")throw this.failure;if(this.state!=="open")throw new C("INVALID_STATE","Workbook is already finalized.")}writerFor(F){return Object.prototype.hasOwnProperty.call(this.writers,F)?this.writers[F]:void 0}preserveText(F,H,K){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 z(n("Text overflow",this.names,this.settings.invalidCharacterPolicy),this.settings.limits?.maxOverflowCharacters??4e6,this.settings.invalidCharacterPolicy,(re,ne,he)=>{this.budget.row(he),this.budget.reserve(re,ne)})),this.overflow.add(F,H,K)}checkSheetLimit(F){if(F>65526)throw new RangeError("Workbook has too many sheets.");if(this.settings.limits?.maxSheets!==void 0&&F>this.settings.limits.maxSheets)throw new C("RESOURCE_LIMIT","maxSheets exceeded.")}checkLinks(F){if(this.settings.limits?.maxHyperlinks!==void 0&&this.links+F>this.settings.limits.maxHyperlinks)throw new C("RESOURCE_LIMIT","maxHyperlinks exceeded.")}retainLink(F=1){this.checkLinks(F),this.links+=F}checkImage(F){if(this.settings.limits?.maxImageBytes!==void 0&&this.imageBytes+F>this.settings.limits.maxImageBytes)throw new C("RESOURCE_LIMIT","maxImageBytes exceeded.")}retainImage(F){this.checkImage(F),this.imageBytes+=F}retainBufferedBytes(F){this.budget.check("maxOutputBytes",this.bufferedBytes+F),this.bufferedBytes+=F}checkMerges(F){if(this.mergedRanges+F>(this.settings.limits?.maxMergedRanges??1e4))throw new C("RESOURCE_LIMIT","maxMergedRanges exceeded.")}checkConditionalFormats(F){if(this.conditionalFormats+F>(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(F){if(this.formulaCharacters+F>(this.settings.limits?.maxFormulaCharacters??1e6))throw new C("RESOURCE_LIMIT","maxFormulaCharacters exceeded.");this.formulaCharacters+=F,this.hasAuthoredFormulas=!0}checkChartText(F){if(this.chartTextCharacters+F>(this.settings.limits?.maxChartTextCharacters??1e6))throw new C("RESOURCE_LIMIT","maxChartTextCharacters exceeded.")}retainChartText(F){this.checkChartText(F),this.chartTextCharacters+=F}resolveChartBinding(F){const H=F.sheet;if(!this.sheets.includes(H)||H.hidden)throw new TypeError("Bound charts require a visible worksheet in the same workbook.");const K=H.chartBindingMetadata,re=F.firstRow??0;if(H.isBusy||K.closed||re<K.rows)throw new C("INVALID_STATE","Register a chart before its first selected data row is written, while the source worksheet is idle.");const ne=Z(K.columns,F.categoryColumn,"Chart"),he=F.series.map(ee=>Z(K.columns,ee.column,"Chart")),oe=K.headerRows+re+1;return{descriptor:{source:H,sheetName:K.name,headerRows:K.headerRows,categoryColumn:ne,seriesColumns:he,seriesNames:he.map(ee=>K.columns[ee-1].header),categoryFormula:B(K.name,ne,oe,F.rowCount),valueFormulas:he.map(ee=>B(K.name,ee,oe,F.rowCount)),nameFormulas:he.map((ee,ye)=>F.series[ye].name===void 0?K.headerReferences[ee-1]:void 0)},retainText:ee=>this.retainChartText(ee)}}registerChart(F){return this.registration(()=>{if(this.nativeCharts.length>=(this.settings.limits?.maxCharts??100))throw new C("RESOURCE_LIMIT","maxCharts exceeded.");const H=L(F,this.settings.invalidCharacterPolicy,(this.settings.limits?.maxChartPoints??1e5)-this.chartPoints,(this.settings.limits?.maxChartTextCharacters??1e6)-this.chartTextCharacters,this.settings.signal,re=>this.resolveChartBinding(re));this.assertOpen(),this.checkChartText(H.textCharacters),this.checkSheetLimit(this.sheets.length+this.chartSourceSheets+(H.binding?0:1)+(this.overflow?1:0));const K=Object.freeze({...H,id:this.nativeCharts.length+1,dataSheetName:H.binding?H.binding.source.name:n("Chart data "+(this.nativeCharts.length+1),this.names,this.settings.invalidCharacterPolicy)});return this.nativeCharts.push(K),this.chartPoints+=H.points,this.chartTextCharacters+=H.textCharacters,H.binding?H.binding.source.retainChartBinding(H.binding):this.chartSourceSheets++,K})}async openSheet(F){if(this.activeSheet&&this.activeSheet!==F){if(this.activeSheet.isBusy)throw new C("INVALID_STATE","Await the active streamed worksheet before starting another.");await this.activeSheet.finish()}return this.activeSheet=F,this.package.openPart("/xl/worksheets/sheet"+(this.sheets.indexOf(F)+1)+".xml",U("worksheet"))}async discard(F){this.state="failed",this.failure=F,await Promise.allSettled(this.sheets.map(H=>H.discard(F))),await this.package.discard(F),this.overflow?.clear(),this.nativeCharts.length=0}get worksheets(){return Object.freeze([...this.sheets])}get rowCount(){return this.sheets.reduce((F,H)=>F+H.reportRowCount,0)}addWorksheet(F,H={}){return this.registration(()=>{this.checkSheetLimit(this.sheets.length+this.chartSourceSheets+1+(this.overflow?1:0));const K=W(H,this.settings.invalidCharacterPolicy),re=w.validate(this,K);let ne=K.table;if(ne&&ne.name===void 0){let ee=this.tableCount+1;for(;this.tableNames.has(("Table"+ee).toLowerCase());)ee++;ne={...ne,name:"Table"+ee}}const he=ne?T(this.tableCount+1,ne,K.columns??[],this.settings.invalidCharacterPolicy):void 0;if(he&&this.tableNames.has(he.name.toLowerCase()))throw new TypeError("Duplicate Excel table name: "+he.name);n(F,this.names,this.settings.invalidCharacterPolicy,!1);const oe=w.create(this,()=>n(F,this.names,this.settings.invalidCharacterPolicy,!1),K,he,!1,re.conditional,re.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,he&&(this.tableNames.add(he.name.toLowerCase()),this.tableCount++),this.sheets.push(oe),oe})}addPart(F){this.assertOpen();const{uri:H,contentType:K,data:re,relationship:ne}=F,he=ne&&{id:ne.id,type:ne.type,source:ne.source};if(this.assertOpen(),this.package.addPart({uri:H,contentType:K,data:re}),he){const{source:oe,id:ee,type:ye}=he;this.package.addRelationship(oe??"/xl/workbook.xml",{id:ee,type:ye,target:H})}}finish(){try{O(this.settings.signal)}catch(F){return this.discard(F).then(()=>{throw F})}if(this.completion)return this.completion;if(this.state==="failed")return Promise.reject(this.failure);if(this.assertOpen(),this.sheets.some(F=>F.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 F=this.rowCount;for(let K=0;K<this.sheets.length;K++){const re=this.sheets[K],ne="/xl/worksheets/sheet"+(K+1)+".xml";await re.finish();const he=re.takePrepared();he&&this.package.addPrepared(ne,U("worksheet"),he);const oe=re.tableDefinition;if(oe){const ee="/xl/tables/table"+oe.id+".xml";this.addXmlPart(ee,U("table"),()=>v(oe,re.rowCount,this.settings.invalidCharacterPolicy,re.headerRowCount,re.footerSettings)),this.package.addRelationship(ne,{id:"table",type:m+"/table",target:ee})}for(let ee=0;ee<re.hyperlinks.length;ee++)O(this.settings.signal),this.package.addRelationship(ne,{id:"link"+(ee+1),type:m+"/hyperlink",target:re.hyperlinks[ee].target,external:!0}),(ee&255)===255&&k()&&(await P(),O(this.settings.signal));if(re.images.length||re.charts.length){const ee="/xl/drawings/drawing"+(K+1)+".xml";this.addXmlPart(ee,I,()=>R(re.images,this.settings.invalidCharacterPolicy,re.charts)),this.package.addRelationship(ne,{id:"drawing",type:m+"/drawing",target:ee});for(let ye=0;ye<re.images.length;ye++){O(this.settings.signal);const be="/xl/media/sheet"+(K+1)+"-image"+(ye+1)+".png";this.package.addPart({uri:be,contentType:"image/png",data:re.images[ye].data}),this.package.addRelationship(ee,{id:"image"+(ye+1),type:m+"/image",target:be}),(ye&255)===255&&k()&&(await P(),O(this.settings.signal))}for(const ye of re.charts){O(this.settings.signal);const be="/xl/charts/chart"+ye.id+".xml";this.package.addPart({uri:be,contentType:V,data:D=>_(ye,D,this.settings.invalidCharacterPolicy,this.settings.signal)}),this.package.addRelationship(ee,{id:"chart"+ye.id,type:m+"/chart",target:be})}}}if(this.overflow){const K=w.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(K),await K.finish(this.overflow.values());const re=K.takePrepared();re&&this.package.addPrepared("/xl/worksheets/sheet"+this.sheets.length+".xml",U("worksheet"),re),this.overflow.clear()}for(const K of this.nativeCharts){if(O(this.settings.signal),K.binding)continue;const re=w.createChartData(this,K);this.sheets.push(re);function*ne(){for(let oe=0;oe<K.data.categories.length;oe++)yield[K.data.categories[oe],...K.data.series.map(ee=>ee.values[oe])]}await re.finish(ne());const he=re.takePrepared();he&&this.package.addPrepared("/xl/worksheets/sheet"+this.sheets.length+".xml",U("worksheet"),he)}this.package.addRelationship("/",{id:"workbook",type:f.officeDocument,target:"/xl/workbook.xml"});for(let K=0;K<this.sheets.length;K++)O(this.settings.signal),this.package.addRelationship("/xl/workbook.xml",{id:"rId"+(K+1),type:f.worksheet,target:"/xl/worksheets/sheet"+(K+1)+".xml"}),(K&255)===255&&k()&&(await P(),O(this.settings.signal));this.package.addRelationship("/xl/workbook.xml",{id:"styles",type:f.styles,target:"/xl/styles.xml"});const H=await this.package.finish();for(const K of this.sheets)K.releaseCharts();return this.nativeCharts.length=0,y(this.settings.onProgress,{phase:"complete",rows:F,bytes:H}),O(this.settings.signal),this.state="complete",{rows:F,sheets:this.sheets.length,bytes:H}}catch(F){throw await this.discard(F),F}})(),this.completion}toBlob(){try{O(this.settings.signal)}catch(F){return this.discard(F).then(()=>{throw F})}if(this.settings.sink)throw new C("INVALID_STATE","This workbook uses a caller-owned sink; use finish().");if(!this.result){const F=this.finish();this.result=F.then(()=>this.package.toBlob(A))}return this.result}}return Object.freeze({Workbook:q})})(),gt=(()=>{const{ExportCell:S,assertScalar:O}=ve,{captureWorkbookOptions:P,sheetOptionFields:k}=qe,{captureFields:C}=Ce;function y(f){for(const a of["font","fill","border","numberFormat"])if(typeof f?.[a]=="number")throw new TypeError("Workbook-local style indexes require the advanced Workbook API; use style definitions.");return f}function p(f){return f instanceof S||O(f),f}function b(f={}){if(f=C(f,k),f.headerStyle!==void 0)throw new TypeError("Workbook-local header styles require the advanced Workbook API; use boldHeader and headerFill.");y(f.alternatingRowStyle),y(f.title?.style),y(f.footer?.style),f.footer?.values?.forEach(p);const a=f.rowStyle,i=f.cellStyle;for(const l of[a,i])if(l!==void 0&&typeof l!="function")throw new TypeError("Style callbacks must be functions.");return{...f,...a?{rowStyle:l=>y(a(l))}:{},...i?{cellStyle:l=>y(i(l))}:{}}}function x(f={}){f=P(f);const a=f.cellValueWriters;if(!a)return f;const i=Object.create(null);for(const[l,o]of Object.entries(a)){if(typeof o!="function")throw new TypeError("Cell value writers must be functions.");i[l]=(s,t)=>p(o(s,t))}return{...f,cellValueWriters:i}}return Object.freeze({portableSheet:b,portableWorkbook:x})})(),At=(()=>{const{withDestination:S}=Ie,{copyColumns:O}=Ne,{Workbook:P}=mt,{portableSheet:k,portableWorkbook:C}=gt,{captureFields:y}=Ce,{sheetOptionFields:p,workbookOptionFields:b}=qe;function x(l){l=y(l,[...b,"columns","sheet"]);const o=O(l.columns),s=l.sheet&&y(l.sheet,[...p,"name"]);return{...C(l),columns:o,sheet:{...k(s),...s?.name===void 0?{}:{name:s.name}}}}function m(l,o){const{name:s="Data",...t}=o.sheet??{};return l.addWorksheet(s,{boldHeader:!0,autoFilter:t.includeHeader!==!1,autoSize:{minWidth:6,maxWidth:54},...t,columns:o.columns})}async function f(l,o){const s=x(o),{columns:t,sheet:n,...e}=s,r=P.forTable(e);try{return await m(r,s).addRows(l),await r.toBlob()}catch(d){throw await r.discard(d),d}}async function a(l,o,s){const t=x(s);return S(o,async n=>{const{columns:e,sheet:r,...d}=t,h=P.forTable({...d,sink:n});try{const u=m(h,t),c=t.columns.length;await u.addRows(l);const g=await h.finish();return{rows:g.rows,columns:c,bytes:g.bytes}}catch(u){throw await h.discard(u),u}})}return Object.freeze({writeXlsx:f,writeXlsxTo:a})})(),Yt=(()=>{const{assertGroupedReportSource:S}=Ue,{captureFields:O}=Ce,{OfficeIMOError:P}=pe,{fields:k}=ot,{sheetOptionFields:C}=qe,{portableSheet:y}=gt,{resolveDataColumn:p}=Ye,{copyStylePatch:b}=Xe,x=["labelColumn","subtotalLabel","grandTotalLabel","includeGrandTotal","collapseGroups","sheet","groupStyle","subtotalStyle","grandTotalStyle","conditionalFormats","dataValidation"],m=["columns","headerRows","footer","table","mergedCells","hyperlinks","conditionalFormats","dataValidation","rowStyle","cellStyle","rowOutline","maxOutlineLevel"];function f(s,t){return p(s.columns,t,"Grouped detail")+1}function a(s,t,n){if(t!==void 0){if(!Array.isArray(t))throw new TypeError("conditionalFormats must be an array.");if(t.length>n)throw new P("RESOURCE_LIMIT","maxConditionalFormats exceeded.");return t.map(e=>{const r=O(e,["type","range","style","stopIfTrue","operator","value","values","formula","stops","color","minimum","maximum","showValue"]),d=r.range;if(typeof d=="string")throw new TypeError("Grouped conditional formats require detail-column selectors rather than A1 or generated-row ranges.");k(d,["column","through"],"grouped conditional range");const h=O(d,["column","through"]);return{...r,range:{column:f(s,h.column),...h.through===void 0?{}:{through:f(s,h.through)}}}})}}function i(s,t,n){if(t!==void 0){if(!Array.isArray(t))throw new TypeError("dataValidation must be an array.");if(t.length>n)throw new P("RESOURCE_LIMIT","maxDataValidations exceeded.");return t.map(e=>{const r=O(e,["type","column","items","allowBlank","showErrorMessage","errorStyle","errorTitle","errorMessage"]);return{...r,column:f(s,r.column)}})}}function l(s,t,n=1e3,e=1e3){if(S(s),!t||typeof t!="object")throw new TypeError("Grouped XLSX options require host-authored labels.");const r=O(t,x),d=O(r.sheet??{},[...C,"name"]);if(!r.labelColumn||typeof r.labelColumn!="object")throw new TypeError("Grouped XLSX needs a leading label column.");const h=O(r.labelColumn,["header","width","wrapText","alignment"]);if(typeof h.header!="string")throw new TypeError("The leading label column needs a string header.");for(const g of[r.subtotalLabel,r.grandTotalLabel])if(typeof g!="function")throw new TypeError("Grouped summary labels must be functions.");for(const g of[r.includeGrandTotal,r.collapseGroups])if(g!==void 0&&typeof g!="boolean")throw new TypeError("Grouped XLSX flags must be booleans.");for(const g of m)if(d[g]!==void 0)throw new TypeError("Grouped XLSX owns worksheet "+g+".");if(d.autoFilter!==void 0&&d.autoFilter!==!1)throw new TypeError("Grouped summary rows cannot use a native table or autofilter.");for(const g of[r.groupStyle,r.subtotalStyle,r.grandTotalStyle])g!==void 0&&y({alternatingRowStyle:g});for(const g of s.columns)if(Object.prototype.hasOwnProperty.call(s.totals,g.key)&&g.type!=="number")throw new TypeError("Editable grouped totals require explicitly numeric columns.");const u=a(s,r.conditionalFormats,n),c=i(s,r.dataValidation,e);return{...r,labelColumn:h,sheet:y(d),...u===void 0?{}:{conditionalFormats:u},...c===void 0?{}:{dataValidation:c},...r.groupStyle?{groupStyle:b(r.groupStyle)}:{},...r.subtotalStyle?{subtotalStyle:b(r.subtotalStyle)}:{},...r.grandTotalStyle?{grandTotalStyle:b(r.grandTotalStyle)}:{}}}return Object.freeze({groupedOptionFields:x,prepareGroupedSheet:l})})(),wt=(()=>{const{groupedReportOperation:S}=Ue,{checkAbort:O,withAbort:P}=we,{withDestination:k}=Ie,{captureFields:C}=Ce,{Workbook:y}=mt,{FormulaCell:p}=Ke,{columnName:b}=_e,{captureWorkbookLimits:x,workbookOptionFields:m}=qe,{retainDataRowRanges:f}=at,{groupedOptionFields:a,prepareGroupedSheet:i}=Yt,l={average:1,count:2,max:4,min:5,sum:9};function o(c){if(typeof c?.then=="function"&&Promise.resolve(c).catch(()=>{}),typeof c!="string")throw new TypeError("Grouped summary labels must return strings.");return c}function s(c,g,w,T,v){const E=g+w+":"+g+T,R="SUBTOTAL("+l[c]+","+E+")";return new p(c==="average"||c==="min"||c==="max"?"IF(SUBTOTAL(2,"+E+')=0,"",'+R+")":R,v,c==="count"?0:void 0)}async function t(c,g,w,T,v){O(T.signal);const{labelColumn:E,subtotalLabel:R,grandTotalLabel:I,includeGrandTotal:z,collapseGroups:j,sheet:M,groupStyle:L,subtotalStyle:B,grandTotalStyle:Z,conditionalFormats:V,dataValidation:_}=w;let A=0,U;const W=[],q=[],X=[];let Y=0,F=0,H,K;const{name:re="Data",...ne}=M??{},he=[{...E,type:"string"},...g.columns],oe={groupStart:L??{font:{bold:!0}},groupEnd:B??{font:{bold:!0}},complete:Z??{font:{bold:!0}}},ee=c.addWorksheet(re,{boldHeader:!0,autoSize:{minWidth:6,maxWidth:54},...ne,columns:he,...V===void 0?{}:{conditionalFormats:V},..._===void 0?{}:{dataValidation:_},maxOutlineLevel:g.groupBy.length,rowStyle:()=>U&&U.kind!=="row"?oe[U.kind]:void 0,rowOutline:()=>{if(!U||U.kind==="complete")return;const D=U.kind==="row"?U.path.length:U.level;return{level:D,hidden:!!j&&D>0,collapsed:!!j&&U.kind==="groupEnd"}}});f(ee,X);const ye=g.columns.map(D=>Object.prototype.hasOwnProperty.call(g.totals,D.key)?g.totals[D.key]:void 0);async function*be(){for await(const D of T.events){U=D;const G=ee.rowCount+ee.headerRowCount+1;if(D.kind==="groupStart"){const N={groupIndex:D.groupIndex,level:D.level,key:D.key,label:D.label,path:D.path,rows:0,totals:Object.freeze([]),startRow:G,firstDetailRow:0,lastDetailRow:0,summaryRow:0};W.push(N),q.push(N),yield[D.label,...g.columns.map(()=>null)]}else if(D.kind==="row"){A++,v?.(A),Y||=G,F=G;const N=X.at(-1);N&&N.lastRow+1===G?N.lastRow=G:X.push({firstRow:G,lastRow:G});for(const Q of q)Q.firstDetailRow||=G,Q.lastDetailRow=G;yield[null,...D.values]}else if(D.kind==="groupEnd"){const N=q.pop();N.summaryRow=G,N.rows=D.rows,N.totals=D.totals,yield[o(R(D)),...ye.map((Q,se)=>Q?s(Q,b(se+2),N.firstDetailRow,N.lastDetailRow,D.totals[se]):null)]}else K=Object.freeze({rows:D.rows,groups:D.groups,totals:D.totals}),z!==!1&&(H=G,yield[o(I(D)),...ye.map((N,Q)=>N?Y?s(N,b(Q+2),Y,F,D.totals[Q]):D.totals[Q]:null)])}}try{return O(T.signal),await P(ee.addRows(be()),T.signal),await P(ee.close(),T.signal),Object.freeze({worksheet:ee,rows:A,columns:he.length,detailRanges:Object.freeze(X.map(D=>Object.freeze({...D}))),groups:Object.freeze(W.map(D=>Object.freeze({...D}))),grandSummary:K,...H===void 0?{}:{grandTotalRow:H}})}catch(D){throw await c.discard(D),D}}async function n(c,g,w){const T=i(g,w,c.settings.limits?.maxConditionalFormats??1e3,c.availableDataValidations),v=S(g,c.settings.signal);try{return await t(c,g,T,v)}finally{v.dispose()}}function e(c,g){if(!g||typeof g!="object")throw new TypeError("Grouped XLSX options require host-authored labels.");const w=C(g,[...m,...a]);if(w.sink!==void 0||w.cellValueWriters!==void 0)throw new TypeError("Grouped XLSX owns its destination and uses already resolved source values.");const T=w.limits===void 0?void 0:x(w.limits);return{...w,...T===void 0?{}:{limits:T},...i(c,w,T?.maxConditionalFormats??1e3,T?.maxDataValidations??1e3)}}async function r(c,g,w){const{labelColumn:T,subtotalLabel:v,grandTotalLabel:E,includeGrandTotal:R,collapseGroups:I,sheet:z,groupStyle:j,subtotalStyle:M,grandTotalStyle:L,conditionalFormats:B,dataValidation:Z,onProgress:V,..._}=g,A=S(c,_.signal);let U=0,W;const q=V?X=>V({...X,rows:U,...X.sheetRows===void 0?{}:{sheetRows:U}}):void 0;try{W=new y({..._,...A.signal?{signal:A.signal}:{},...q?{onProgress:q}:{},...w?{sink:w}:{}});const X=await t(W,c,g,A,F=>{U=F});if(w){const F=await W.finish();return{result:{rows:U,columns:X.columns,bytes:F.bytes}}}const Y=await W.toBlob();return{blob:Y,result:{rows:U,columns:X.columns,bytes:Y.size}}}catch(X){throw await W?.discard(X),X}finally{A.dispose()}}async function d(c,g){return(await r(c,e(c,g))).blob}async function h(c,g,w){const T=e(c,w);return k(g,async v=>(await r(c,T,v)).result)}return Object.freeze({addGroupedXlsx:n,writeGroupedXlsx:d,writeGroupedXlsxTo:h})})(),Qt=Object.freeze({Workbook:mt.Workbook,writeXlsx:At.writeXlsx,writeXlsxTo:At.writeXlsxTo,writeGroupedXlsx:wt.writeGroupedXlsx,writeGroupedXlsxTo:wt.writeGroupedXlsxTo,addGroupedXlsx:wt.addGroupedXlsx,createGroupedReport:Ue.createGroupedReport,Worksheet:jt.Worksheet,Cell:_e.Cell,FormulaCell:Ke.FormulaCell,StyleRegistry:Xe.StyleRegistry,NumberFormats:Xe.NumberFormats,saveBlob:rt.saveBlob,ExportCell:ve.ExportCell}),Ze=(()=>{const{captureFields:S}=Ce;function O(y,p,b=14400){if(!Number.isFinite(y)||y<=0||y>b)throw new RangeError(p+" must be positive and at most "+b+".");return y}function P(y){if(typeof y!="string"||!/^#?[0-9a-f]{6}$/i.test(y))throw new TypeError("PDF colors must be six-digit RGB hex strings.");const p=y.replace(/^#/,"");return[0,2,4].map(b=>String(Math.round(parseInt(p.slice(b,b+2),16)/255*1e4)/1e4)).join(" ")}function k(y={}){if(!y||typeof y!="object")throw new TypeError("PDF presentation must be an object.");const p=S(y,["background","color","numberFormat","bold","italic","wrapText","alignment"]);p.background!==void 0&&P(p.background),p.color!==void 0&&P(p.color);for(const b of["bold","italic","wrapText"])if(p[b]!==void 0&&typeof p[b]!="boolean")throw new TypeError("PDF presentation "+b+" must be boolean.");if(p.alignment!==void 0&&!["left","center","right"].includes(p.alignment))throw new TypeError("PDF table alignment supports left, center and right.");return Object.freeze(p)}return Object.freeze({positive:O,color:P,presentation:k})})(),yt=(()=>{const{OfficeIMOError:S}=pe,{positive:O,presentation:P}=Ze,k=["fontSize","presentation","keepTogether","keepWithNext","spaceBefore","spaceAfter"],C=["bold","italic","color","alignment"];function y(m){if(m&&typeof m.then=="function")throw Promise.resolve(m).catch(()=>{}),new TypeError("PDF paragraph styles must be synchronous objects.");if(!m||typeof m!="object"||Array.isArray(m)||Object.keys(m).some(t=>!k.includes(t)))throw new TypeError("PDF paragraph styles support fontSize, presentation, keepTogether, keepWithNext, spaceBefore and spaceAfter.");const{fontSize:f,presentation:a,keepTogether:i,keepWithNext:l,spaceBefore:o,spaceAfter:s}=m;f!==void 0&&O(f,"Paragraph font size",144);for(const[t,n]of[["keepTogether",i],["keepWithNext",l]])if(n!==void 0&&typeof n!="boolean")throw new TypeError("Paragraph "+t+" must be boolean.");for(const t of[o,s])if(t!==void 0&&(!Number.isFinite(t)||t<0||t>14400))throw new RangeError("Paragraph spacing must be from zero through 14,400 points.");if(a!==void 0&&(!a||typeof a!="object"||Array.isArray(a)||Object.keys(a).some(t=>!C.includes(t))))throw new TypeError("PDF paragraph presentation supports bold, italic, color and alignment.");return Object.freeze({...f===void 0?{}:{fontSize:f},...a===void 0?{}:{presentation:P(a)},...i===void 0?{}:{keepTogether:i},...l===void 0?{}:{keepWithNext:l},...o===void 0?{}:{spaceBefore:o},...s===void 0?{}:{spaceAfter:s}})}function p(m,f){if(!Number.isSafeInteger(f)||f<0)throw new RangeError("maxParagraphStyles must be a nonnegative safe integer.");const a=Object.create(null);if(m===void 0)return Object.freeze(a);if(m&&typeof m.then=="function")throw Promise.resolve(m).catch(()=>{}),new TypeError("paragraphStyles must be a synchronous record.");if(!m||typeof m!="object"||Array.isArray(m))throw new TypeError("paragraphStyles must be a record of named paragraph styles.");const i=Object.keys(m);if(i.length>f)throw new S("RESOURCE_LIMIT","maxParagraphStyles exceeded.");for(const l of i){if(!l.trim())throw new TypeError("Paragraph style names must be nonempty text.");a[l]=y(m[l])}return Object.freeze(a)}function b(m,f,a){let i={};if(m!==void 0){if(typeof m!="string"||!Object.prototype.hasOwnProperty.call(a,m))throw new TypeError("Unknown PDF paragraph style: "+String(m));i=a[m]}const l=y(f);return Object.freeze({...i,...l,...i.presentation||l.presentation?{presentation:Object.freeze({...i.presentation,...l.presentation})}:{}})}return Object.freeze({captureParagraphStyle:y,captureParagraphStyles:p,resolveParagraphStyle:b})})(),Fe=(()=>{const{OfficeIMOError:S}=pe,{ExportBudget:O}=We,{copyColumns:P}=Ne,{captureTableSpans:k}=Ve,{copyExportValue:C}=tt,{captureFields:y}=Ce,{captureParagraphStyles:p}=yt,{captureBooleanText:b}=dt,{positive:x,color:m,presentation:f}=Ze,a={A3:{width:841.89,height:1190.551},A4:{width:595.276,height:841.89},A5:{width:419.528,height:595.276},LETTER:{width:612,height:792},LEGAL:{width:612,height:1008},TABLOID:{width:792,height:1224}},i=["columns","signal","onProgress","limits","textShaper","textDirection","pageSize","orientation","margins","fonts","tagged","fontSize","title","messageTop","messageBottom","includeHeader","headerRows","footer","headerPresentation","footerPresentation","alternateRowColor","padding","columnWidths","wideTable","pageHeader","pageFooter","pageNumbers","pageNumberLabels","booleanText","formatValue","formatRuns","compression","paragraphStyles"],l=["maxRows","maxCells","maxTextCharacters","maxOutputBytes","maxPages","maxColumns","maxTableBands","maxTableWindowRows","maxCellCharacters","maxTextRuns","maxGroupBlocks","maxRowLines","maxFontBytes","maxPageBytes","maxHyperlinks","maxImageBytes","maxImagePixels","maxImageWorkingBytes","maxVectorCommands","maxDrawingElements","maxStructureElements","maxMarkedContentReferences","maxSections","maxBookmarks","maxListItems","maxParagraphStyles"];function o(h){if(!h||typeof h!="object"||Array.isArray(h))throw new TypeError("PDF options must be an object.");const u=y(h,i),c=u.wideTable;return{...u,...c===void 0?{}:{wideTable:n(c)}}}function s(h){if(!h||typeof h!="object"||Array.isArray(h))throw new TypeError("PDF limits must be an object.");const u=y(h,l);for(const[c,g]of Object.entries(u))if(g!==void 0&&(!Number.isSafeInteger(g)||g<0))throw new RangeError(c+" must be a nonnegative safe integer.");return Object.freeze(u)}function t(h,u){if(!h||typeof h!="object"||Array.isArray(h))throw new TypeError("PDF footer must be an object.");const{values:c,totals:g,rows:w}=h;if(c!==void 0&&!Array.isArray(c))throw new TypeError("PDF footer values must be an array.");return Object.freeze({...c===void 0?{}:{values:Object.freeze(c.map(C))},...g===void 0?{}:{totals:Object.freeze({...g})},...w===void 0?{}:{rows:k(w,u)}})}function n(h){if(h===void 0||h==="fit"||h==="reject")return h;if(!h||typeof h!="object"||Array.isArray(h)||Object.keys(h).some(T=>!["mode","minimumColumnWidth","repeatColumns"].includes(T)))throw new TypeError("wideTable must be fit, reject or a bands policy.");const{mode:u,minimumColumnWidth:c,repeatColumns:g}=h;if(u!=="bands")throw new TypeError("wideTable.mode must be bands.");if(c!==void 0&&x(c,"Minimum PDF column width"),g!==void 0&&!Array.isArray(g))throw new TypeError("repeatColumns must be an array.");const w=g===void 0?[]:[...g];if(w.some(T=>typeof T=="number"?!Number.isSafeInteger(T)||T<0:typeof T!="string"||!T.length))throw new RangeError("repeatColumns must contain nonnegative indices or nonempty stable keys.");if(w.every(T=>typeof T=="number")&&w.some((T,v)=>v>0&&T<=w[v-1]))throw new RangeError("Numeric repeatColumns must contain sorted unique nonnegative indices.");return Object.freeze({mode:u,...c===void 0?{}:{minimumColumnWidth:c},repeatColumns:Object.freeze(w)})}function e(h,u){if(typeof h!="object")return Object.freeze([]);const c=new Set;for(const g of h.repeatColumns??[]){let w;if(typeof g=="number")w=g;else if(w=u.findIndex(T=>T.key===g),w<0||u.some((T,v)=>v!==w&&T.key===g))throw new TypeError("repeatColumns requires an unambiguous selected column key: "+g);if(w>=u.length)throw new RangeError("repeatColumns index exceeds the declared columns.");if(c.has(w))throw new TypeError("repeatColumns selects the same column more than once.");c.add(w)}return Object.freeze([...c].sort((g,w)=>g-w))}function r(h,u=!1){const c={...o(h)};if(c.booleanText=b(c.booleanText),c.limits!==void 0&&(c.limits=s(c.limits)),c.pageSize&&typeof c.pageSize=="object"&&(c.pageSize=Object.freeze(y(c.pageSize,["width","height"]))),c.margins&&typeof c.margins=="object"&&(c.margins=Object.freeze(y(c.margins,["top","right","bottom","left"]))),c.pageNumberLabels!==void 0){const A=c.pageNumberLabels;if(!A||typeof A!="object"||Array.isArray(A))throw new TypeError("pageNumberLabels must provide literal text.");const{prefix:U="Page ",separator:W=" of ",suffix:q=""}=A;if([U,W,q].some(X=>typeof X!="string"))throw new TypeError("Page-number labels must be text.");c.pageNumberLabels=Object.freeze({prefix:U,separator:W,suffix:q})}const g=c.textShaper,w=g?.shapeLine;if(g!==void 0&&(!g||typeof w!="function"))throw new TypeError("textShaper must provide shapeLine.");if(c.textDirection!==void 0&&!["auto","ltr","rtl"].includes(c.textDirection))throw new TypeError("textDirection must be auto, ltr or rtl.");const T=u?[]:P(c.columns).map(A=>Object.freeze(A));if(u&&(c.includeHeader=!1),!T.length&&!u)throw new TypeError("PDF tables need at least one declared column.");const v=c.fonts===void 0?void 0:y(c.fonts,["regular","bold","italic","boldItalic"]),E={...c,columns:T,...g?{textShaper:Object.freeze({shapeLine:w.bind(g)})}:{},...c.tagged?{tagged:Object.freeze(y(c.tagged,["language"]))}:{},...c.headerRows?{headerRows:k(c.headerRows,T.length)}:{},...v?{fonts:Object.freeze(v)}:{},...c.columnWidths?{columnWidths:Object.freeze([...c.columnWidths])}:{},...c.footer===void 0?{}:{footer:t(c.footer,T.length)},headerPresentation:Object.freeze({background:"e7edf5",bold:!0,...f(c.headerPresentation)}),footerPresentation:Object.freeze({background:"eef2f6",bold:!0,...f(c.footerPresentation)})},R=new O(E.limits),I={maxPages:1e4,maxColumns:1024,maxTableBands:64,maxTableWindowRows:256,maxCellCharacters:1e6,maxTextRuns:1e4,maxGroupBlocks:256,maxRowLines:1e5,maxFontBytes:16*1024*1024,maxPageBytes:8*1024*1024,maxHyperlinks:1e5,maxImageBytes:32*1024*1024,maxImagePixels:16*1024*1024,maxVectorCommands:1e5,maxDrawingElements:1e5,maxStructureElements:1e6,maxMarkedContentReferences:2e6,maxListItems:1e5,maxParagraphStyles:256,maxSections:1e3,maxBookmarks:1e4};for(const A of Object.keys(I)){const U=E.limits?.[A];U!==void 0&&(I[A]=U)}const z=p(E.paragraphStyles,I.maxParagraphStyles);if(T.length>I.maxColumns)throw new S("RESOURCE_LIMIT","maxColumns exceeded.");const j=typeof E.pageSize=="string"||E.pageSize===void 0?a[E.pageSize??"A4"]:E.pageSize;if(!j)throw new TypeError("Unsupported PDF page size.");if(x(j.width,"Page width"),x(j.height,"Page height"),E.orientation!==void 0&&!["portrait","landscape"].includes(E.orientation))throw new TypeError("Invalid PDF orientation.");const M=E.orientation==="landscape",L={width:M?Math.max(j.width,j.height):Math.min(j.width,j.height),height:M?Math.min(j.width,j.height):Math.max(j.width,j.height)},B={top:36,right:36,bottom:36,left:36,...typeof E.margins=="number"?{top:E.margins,right:E.margins,bottom:E.margins,left:E.margins}:E.margins};for(const A of Object.values(B))if(!Number.isFinite(A)||A<0)throw new RangeError("PDF margins must be finite and nonnegative.");if(B.left+B.right>=L.width||B.top+B.bottom>=L.height)throw new RangeError("PDF margins leave no content area.");const Z=x(E.fontSize??9,"Font size",144),V=E.padding??4;if(!Number.isFinite(V)||V<0||V>72)throw new RangeError("PDF padding must be from 0 through 72 points.");for(const A of["title","messageTop","messageBottom"])if(E[A]!==void 0&&typeof E[A]!="string")throw new TypeError(A+" must be text.");for(const A of["pageHeader","pageFooter"])if(E[A]!==void 0&&typeof E[A]!="string"&&typeof E[A]!="function")throw new TypeError(A+" must be text or a synchronous callback.");for(const A of["formatValue","formatRuns"])if(E[A]!==void 0&&typeof E[A]!="function")throw new TypeError(A+" must be a synchronous function.");for(const A of["compression","includeHeader","pageNumbers"])if(E[A]!==void 0&&typeof E[A]!="boolean")throw new TypeError(A+" must be boolean.");if(E.alternateRowColor!==void 0&&m(E.alternateRowColor),E.footer?.values&&E.footer.values.length>T.length)throw new RangeError("Footer has more values than declared columns.");if(E.footer?.rows&&(E.footer.values!==void 0||E.footer.totals!==void 0))throw new TypeError("Structured footer rows cannot be combined with values/totals.");if(E.headerRows&&E.includeHeader===!1)throw new TypeError("headerRows requires includeHeader.");if(E.tagged!==void 0){if(!E.tagged||typeof E.tagged!="object"||typeof E.tagged.language!="string"||E.tagged.language.length>63)throw new TypeError("tagged.language must be a language tag such as en or en-US.");try{if(Intl.getCanonicalLocales(E.tagged.language).length!==1)throw new RangeError}catch{throw new TypeError("tagged.language must be a language tag such as en or en-US.")}}const _=E.limits?.maxImageWorkingBytes;return{options:{...E,paragraphStyles:z},paragraphStyles:z,page:L,margins:B,fontSize:Z,padding:V,repeatedColumns:u?Object.freeze([]):e(E.wideTable,T),limits:{...I,..._===void 0?{}:{maxImageWorkingBytes:_}},budget:R}}return Object.freeze({positive:Ze.positive,color:Ze.color,presentation:Ze.presentation,pdfOptionFields:i,pdfLimitFields:l,capturePdfOptions:o,capturePdfLimits:s,captureWideTable:n,settings:r})})(),er=(()=>{function O(C,y,p,b){if(!Number.isSafeInteger(p)||p<0||p>=2**(b*8))throw new RangeError("Invalid PDF cross-reference field.");for(let x=b-1;x>=0;x--)C[y+x]=p%256,p=Math.floor(p/256)}function*P(C,y){if(C.length!==y.length)throw new Error("PDF cross-reference locations must align.");const p=Math.floor(32768/11);for(let b=0;b<C.length;b+=p){const x=Math.min(p,C.length-b),m=new Uint8Array(x*11);for(let f=0;f<x;f++){const a=b+f,i=f*11,l=C[a],o=y.at(a);if(l===void 0)throw new Error("PDF contains unwritten objects.");m[i]=a===0?0:o===void 0?1:2,O(m,i+1,l,8),O(m,i+9,a===0?65535:o??0,2)}yield m}}return Object.freeze({pdfXrefEntryBytes:11,pdfXrefChunks:P})})(),Be=(()=>{const{checkAbort:S,withAbort:O,pause:P,taskYieldDue:k}=we,{OfficeIMOError:C}=pe,{pdfXrefChunks:y,pdfXrefEntryBytes:p}=er,b=256,x=32768,m=4096;class f{count;chunks=[];constructor(t){this.count=t}get length(){return this.count}reserve(){this.count++}set(t,n){const e=this.chunks[Math.floor(t/m)]??=new Uint16Array(m);e[t%m]=n+1}at(t){const n=this.chunks[Math.floor(t/m)]?.[t%m]??0;return n?n-1:void 0}}function a(s){if(!Number.isFinite(s)||Math.abs(s)>1e9)throw new RangeError("PDF coordinates and metrics must be finite and bounded.");return String(Math.round(s*1e3)/1e3)}function i(s){let t="";for(let n=0;n<s.length;n++){const e=s.charCodeAt(n);if(e>=55296&&e<=56319&&!(s.charCodeAt(n+1)>=56320&&s.charCodeAt(n+1)<=57343)||e>=56320&&e<=57343&&!(s.charCodeAt(n-1)>=55296&&s.charCodeAt(n-1)<=56319))throw new TypeError("PDF text contains an unpaired UTF-16 surrogate.");t+=e.toString(16).padStart(4,"0")}return t}class l{sink;signal;maxBytes;compressObjects;offsets=[0];compactIndices;compactBatch;compactArena;compactUnavailable=!1;encoder=new TextEncoder;buffer=new Uint8Array(32768);buffered=0;bytes=0;constructor(t,n,e=Number.MAX_SAFE_INTEGER,r=!1){this.sink=t,this.signal=n,this.maxBytes=e,this.compressObjects=r}reserve(){return this.offsets.push(void 0),this.compactIndices?.reserve(),this.offsets.length-1}async raw(t){if(S(this.signal),!Number.isSafeInteger(this.bytes+t.length)||this.bytes+t.length>this.maxBytes)throw new C("RESOURCE_LIMIT","maxOutputBytes exceeded.");this.bytes+=t.length;for(let n=0;n<t.length;){const e=Math.min(this.buffer.length-this.buffered,t.length-n);this.buffer.set(t.subarray(n,n+e),this.buffered),n+=e,this.buffered+=e,this.buffered===this.buffer.length&&await this.flushBytes()}}async text(t){await this.raw(this.encoder.encode(t))}async flush(){await this.flushCompact(),await this.flushBytes()}async flushBytes(){if(this.buffered){const t=this.buffer.subarray(0,this.buffered);await O(Promise.resolve(this.sink.write(t)),this.signal),this.buffered=0}k()&&await P(),S(this.signal)}tryCompactObject(t,n){S(this.signal),this.validateObject(t);const e=this.compactBatch;if(!e||!this.compressObjects||this.compactUnavailable||typeof CompressionStream!="function"||n.length>x||e.ids.length+1>=b)return!1;const r=String(t).length+String(e.bodyBytes).length+2,d=this.encodeCompactBody(n,e.bodyBytes,x-e.indexBytes-r-e.bodyBytes-2);return d===void 0?!1:(this.storeCompactBody(e,t,d),!0)}async compactObject(t,n){if(S(this.signal),this.validateObject(t),!this.compressObjects||this.compactUnavailable||n.length>x)return this.object(t,n);if(typeof CompressionStream!="function"){if(this.compactIndices)throw new Error("PDF object compression became unavailable.");return this.compactUnavailable=!0,this.object(t,n)}const e=String(t).length+4;let r=this.compactBatch;const d=String(t).length+String(r?.bodyBytes??0).length+2;let h=r&&r.ids.length<b?this.encodeCompactBody(n,r.bodyBytes,x-r.indexBytes-d-r.bodyBytes-2):void 0;if(r&&h===void 0&&(await this.flushCompact(),r=void 0,S(this.signal)),!r){if(h=this.encodeCompactBody(n,0,x-e-1),h===void 0)return this.object(t,n);let u;if(!this.compactIndices)try{u=new CompressionStream("deflate")}catch{return this.compactUnavailable=!0,this.object(t,n)}r={id:this.reserve(),compressor:u,ids:[],bodyOffsets:[],bodyBytes:0,indexBytes:1},this.compactIndices??=new f(this.offsets.length),this.compactBatch=r}this.storeCompactBody(r,t,h),r.ids.length===b&&await this.flushCompact()}storeCompactBody(t,n,e){this.offsets[n]=t.id,this.compactIndices.set(n,t.ids.length),t.indexBytes+=String(n).length+String(t.bodyBytes).length+2,t.ids.push(n),t.bodyOffsets.push(t.bodyBytes),this.compactArena[t.bodyBytes+e]=10,t.bodyBytes+=e+1}encodeCompactBody(t,n,e){if(e<0)return;const r=(this.compactArena??=new Uint8Array(x)).subarray(n,n+e);if(typeof this.encoder.encodeInto=="function"){const h=this.encoder.encodeInto(t,r);return h.read===t.length?h.written:void 0}const d=this.encoder.encode(t);if(!(d.length>e))return r.set(d),d.length}async flushCompact(){const t=this.compactBatch;if(!t)return;this.compactBatch=void 0;let n="";for(let h=0;h<t.ids.length;h++)n+=t.ids[h]+" "+t.bodyOffsets[h]+" ";const e=this.encoder.encode(n+"\n"),r=t.ids.length,d=this.compactArena.subarray(0,t.bodyBytes);t.ids.length=0,t.bodyOffsets.length=0,t.compressor?await this.compressedStream(t.id,d,"/Type /ObjStm /N "+r+" /First "+e.length,t.compressor,e):(this.start(t.id),await this.text(t.id+" 0 obj\n<< /Length "+(e.length+d.length)+" /Type /ObjStm /N "+r+" /First "+e.length+" >>\nstream\n"),await this.raw(e),await this.raw(d),await this.text("\nendstream\nendobj\n"))}async object(t,n){if(this.start(t),typeof n=="string"){await this.text(t+" 0 obj\n"+n+"\nendobj\n");return}let e=t+" 0 obj\n";for(const r of n)for(let d=0;d<r.length;){const h=Math.min(r.length,d+32768-e.length);if(e+=r.slice(d,h),d=h,e.length===32768){const u=e.charCodeAt(e.length-1),c=u>=55296&&u<=56319?e.length-1:e.length;await this.text(e.slice(0,c)),e=e.slice(c)}}await this.text(e+"\nendobj\n")}validateObject(t){if(!Number.isSafeInteger(t)||t<=0||t>=this.offsets.length||this.offsets[t]!==void 0)throw new Error("Invalid PDF object state.")}start(t){this.validateObject(t),this.offsets[t]=this.bytes}async stream(t,n,e="",r=!0,d=!1){const h=typeof n=="string"?this.encoder.encode(n):n;let u;if(r&&typeof CompressionStream=="function"&&h.length)try{u=new CompressionStream("deflate")}catch{}if(!u){this.start(t),await this.text(t+" 0 obj\n<< /Length "+h.length+" "+e+" >>\nstream\n"),await this.raw(h),await this.text("\nendstream\nendobj\n");return}const c=typeof n=="string"||d?h:new Uint8Array(h);await this.compressedStream(t,c,e,u)}async compressedStream(t,n,e,r,d){const u=new ReadableStream({start(T){d&&T.enqueue(d),T.enqueue(n),T.close()}}).pipeThrough(r).getReader(),c=this.reserve();let g=0,w=!1;try{for(this.start(t),await this.text(t+" 0 obj\n<< /Length "+c+" 0 R /Filter /FlateDecode "+e+" >>\nstream\n");;){const T=await O(u.read(),this.signal);if(T.done){w=!0;break}g+=T.value.length,await this.raw(T.value)}await this.text("\nendstream\nendobj\n"),await this.object(c,String(g))}finally{w||u.cancel(this.signal?.reason).catch(()=>{}),u.releaseLock()}}async finish(t,n){await this.flushCompact();for(let r=1;r<this.offsets.length;r++)if(this.offsets[r]===void 0)throw new Error("PDF contains unwritten objects.");if(this.bytes>9999999999)throw new C("RESOURCE_LIMIT","PDF exceeds classic cross-reference offset capacity.");if(this.compactIndices)return this.finishCompact(t,n);const e=this.bytes;await this.text("xref\n0 "+this.offsets.length+"\n0000000000 65535 f \n");for(let r=1;r<this.offsets.length;r++)await this.text(String(this.offsets[r]).padStart(10,"0")+" 00000 n \n");await this.text("trailer\n<< /Size "+this.offsets.length+" /Root "+t+" 0 R /Info "+n+" 0 R >>\nstartxref\n"+e+"\n%%EOF\n"),await this.flush()}async finishCompact(t,n){const e=this.reserve(),r=this.bytes,d=this.offsets.length*p;if(!Number.isSafeInteger(d))throw new C("RESOURCE_LIMIT","PDF cross-reference stream is too large.");this.start(e),await this.text(e+" 0 obj\n<< /Type /XRef /Size "+this.offsets.length+" /W [1 8 2] /Root "+t+" 0 R /Info "+n+" 0 R /Length "+d+" >>\nstream\n");for(const h of y(this.offsets,this.compactIndices))await this.raw(h);await this.text("\nendstream\nendobj\nstartxref\n"+r+"\n%%EOF\n"),await this.flushBytes()}}return Object.freeze({pdfNumber:a,unicodeHex:i,PdfObjects:l})})(),Ft=(()=>{class S{bytes;view;constructor(y){this.bytes=y,this.view=new DataView(y.buffer,y.byteOffset,y.byteLength)}range(y,p){if(!Number.isSafeInteger(y)||!Number.isSafeInteger(p)||y<0||p<0||y+p>this.bytes.length)throw new TypeError("Truncated or invalid TrueType table.")}u16(y){return this.range(y,2),this.view.getUint16(y)}i16(y){return this.range(y,2),this.view.getInt16(y)}u32(y){return this.range(y,4),this.view.getUint32(y)}tag(y){return this.range(y,4),String.fromCharCode(...this.bytes.subarray(y,y+4))}}function O(C){let y=0;for(let p=0;p<C.length;p+=4)y=y+((C[p]??0)*16777216+((C[p+1]??0)<<16)+((C[p+2]??0)<<8)+(C[p+3]??0))>>>0;return y}return Object.freeze({FontReader:S,checksum:O,align4:C=>Math.ceil(C/4)*4})})(),tr=(()=>{const{align4:S}=Ft,{checkAbort:O,pause:P,taskYieldDue:k}=we;function C(i,l,o){const s=p(i,l,o);for(;;){const t=s.next();if(t.done)return t.value}}async function y(i,l,o,s){O(s);const t=p(i,l,o);for(;;){const n=t.next();if(n.done)return O(s),n.value;k()&&await P(),O(s)}}function*p(i,l,o){const s=new Set([0,...l]),t=i.table("glyf"),n=[...s],e=new Map;let r=0;for(let _=0;_<n.length;_++){(++r&1023)===0&&(yield);const A=n[_];if(!Number.isInteger(A)||A<0||A>=i.glyphCount)throw new TypeError("Invalid subset glyph.");const U=i.offsets[A],W=i.offsets[A+1];if(U===W)continue;if(W-U<10)throw new TypeError("Truncated TrueType glyph header.");if(i.i16(t.offset+U)>=0)continue;let q=t.offset+U+10,X;const Y=[];e.set(A,Y);const F=t.offset+W;do{if(q+4>F)throw new TypeError("Truncated TrueType composite.");X=i.u16(q);const H=i.u16(q+2);if(H>=i.glyphCount)throw new TypeError("Invalid TrueType composite dependency.");if(Y.push(H),(++r&1023)===0&&(yield),s.has(H)||(s.add(H),n.push(H)),q+=4+(X&1?4:2)+(X&8?2:X&64?4:X&128?8:0),q>F)throw new TypeError("Truncated TrueType composite transform.")}while(X&32);if(X&256&&(q+2>F||q+2+i.u16(q)>F))throw new TypeError("Truncated composite instructions.")}const d=new Set,h=new Set;function*u(_,A){if((++r&1023)===0&&(yield),h.has(_))throw new TypeError("Cyclic TrueType composite dependency.");if(A>64)throw new TypeError("TrueType composite nesting exceeds 64 levels.");if(!d.has(_)){h.add(_);for(const U of e.get(_)??[])yield*u(U,A+1);h.delete(_),d.add(_)}}for(const _ of s)yield*u(_,0);const c=new Uint32Array(i.glyphCount+1);let g=0;for(let _=0;_<i.glyphCount;_++)c[_]=g,s.has(_)&&(g+=S(i.offsets[_+1]-i.offsets[_])),(_&1023)===1023&&(yield);c[i.glyphCount]=g;const w=new Uint8Array(g);for(const _ of s)yield*m(i.bytes.subarray(t.offset+i.offsets[_],t.offset+i.offsets[_+1]),w,c[_]),(++r&1023)===0&&(yield);const T=new Uint8Array(c.length*4),v=new DataView(T.buffer);for(let _=0;_<c.length;_++)v.setUint32(_*4,c[_]),(_&1023)===1023&&(yield);const E=new Set(["OS/2","cmap","cvt ","fpgm","gasp","glyf","head","hhea","hmtx","loca","maxp","name","post","prep"]),R=yield*x(o),I=yield*b(i,s),z=[];for(const[_,A]of[...i.tables].filter(([U])=>E.has(U)).sort(([U],[W])=>U<W?-1:1)){const U=_==="glyf"?w:_==="loca"?T:_==="cmap"?R:_==="hmtx"?I:void 0,W=U??new Uint8Array(A.length);if(U||(yield*m(i.bytes.subarray(A.offset,A.offset+A.length),W)),_==="head"){const q=new DataView(W.buffer);q.setUint32(8,0),q.setInt16(50,1)}z.push({tag:_,bytes:W})}const j=12+z.length*16+z.reduce((_,A)=>_+S(A.bytes.length),0),M=new Uint8Array(j),L=new DataView(M.buffer);L.setUint32(0,65536),L.setUint16(4,z.length);const B=2**Math.floor(Math.log2(z.length));L.setUint16(6,B*16),L.setUint16(8,Math.log2(B)),L.setUint16(10,z.length*16-B*16);let Z=12+z.length*16,V=0;for(let _=0;_<z.length;_++){const A=z[_],U=12+_*16;for(let W=0;W<4;W++)M[U+W]=A.tag.charCodeAt(W);L.setUint32(U+4,yield*f(A.bytes)),L.setUint32(U+8,Z),L.setUint32(U+12,A.bytes.length),yield*m(A.bytes,M,Z),A.tag==="head"&&(V=Z),Z+=S(A.bytes.length)}return L.setUint32(V+8,2981146554-(yield*f(M))>>>0),M}function*b(i,l){let o=0;const s=i.u16(i.table("hhea").offset+34),t=i.table("hmtx"),n=new Uint8Array(s*4+(i.glyphCount-s)*2);for(const e of l){(++o&1023)===0&&(yield);const r=e<s?e*4:s*4+(e-s)*2,d=e<s?4:2;if(n.set(i.bytes.subarray(t.offset+r,t.offset+r+d),r),e>=s){const h=(s-1)*4;n.set(i.bytes.subarray(t.offset+h,t.offset+h+2),h)}}return n}function*x(i){let l=0;const o=[...i].sort(([e],[r])=>e-r),s=[];for(const[e,r]of o){(++l&1023)===0&&(yield);const d=s.at(-1);d&&e===d.last+1&&r===d.glyph+e-d.first?d.last=e:s.push({first:e,last:e,glyph:r})}const t=new Uint8Array(28+s.length*12),n=new DataView(t.buffer);n.setUint16(2,1),n.setUint16(4,3),n.setUint16(6,10),n.setUint32(8,12),n.setUint16(12,12),n.setUint32(16,t.length-12),n.setUint32(24,s.length);for(let e=0;e<s.length;e++){const r=s[e],d=28+e*12;n.setUint32(d,r.first),n.setUint32(d+4,r.last),n.setUint32(d+8,r.glyph),(e&1023)===1023&&(yield)}return t}function*m(i,l,o=0){for(let s=0;s<i.length;s+=65536)l.set(i.subarray(s,Math.min(i.length,s+65536)),o+s),yield}function*f(i){let l=0;for(let o=0;o<i.length;o+=4)l=l+((i[o]??0)*16777216+((i[o+1]??0)<<16)+((i[o+2]??0)<<8)+(i[o+3]??0))>>>0,(o&65535)===65532&&(yield);return l}return Object.freeze({subsetTrueType:C,subsetTrueTypeCooperatively:y})})(),rr=(()=>{const{NotSupportedError:S}=pe,{FontReader:O}=Ft,{subsetTrueType:P,subsetTrueTypeCooperatively:k}=tr,{checkAbort:C,pause:y,taskYieldDue:p}=we;class b extends O{tables;glyphCount;units;ascent;descent;bbox;widths;offsets;canSubset;cmaps;constructor(a,i){super(a);const l=x(this);let o=i;if(!o)for(;;){const s=l.next();if(s.done){o=s.value;break}}this.tables=o.tables,this.glyphCount=o.glyphCount,this.units=o.units,this.ascent=o.ascent,this.descent=o.descent,this.bbox=o.bbox,this.widths=o.widths,this.offsets=o.offsets,this.canSubset=o.canSubset,this.cmaps=o.cmaps}static async create(a,i){C(i);const l=x(new O(a));for(;;){const o=l.next();if(o.done)return C(i),new b(a,o.value);p()&&await y(),C(i)}}table(a,i=0){const l=this.tables.get(a);if(!l||l.length<i)throw new TypeError("Missing or truncated TrueType table: "+a);return l}glyph(a){for(const i of this.cmaps){const l=i.offset,o=this.u16(l);let s=0;if(o===12){let t=0,n=this.u32(l+12)-1;for(;t<=n;){const e=t+n>>>1,r=l+16+e*12,d=this.u32(r),h=this.u32(r+4);if(a<d)n=e-1;else if(a>h)t=e+1;else{s=this.u32(r+8)+a-d;break}}}else if(a<=65535){const t=this.u16(l+6)/2;let n=0,e=t-1;for(;n<e;){const d=n+e>>>1;a>this.u16(l+14+d*2)?n=d+1:e=d}const r=this.u16(l+16+t*2+n*2);if(a>=r&&a<=this.u16(l+14+n*2)){const d=this.i16(l+16+t*4+n*2),h=l+16+t*6+n*2,u=this.u16(h);if(!u)s=a+d&65535;else{const c=h+u+(a-r)*2;if(c+2>l+i.length)throw new TypeError("cmap glyph array exceeds its table.");s=this.u16(c),s&&(s=s+d&65535)}}}if(s>=this.glyphCount)throw new TypeError("cmap references an invalid glyph.");if(s)return s}return 0}subset(a,i){return this.canSubset?P(this,a,i):this.bytes}async subsetCooperatively(a,i,l){return C(l),this.canSubset?k(this,a,i,l):this.bytes}}function*x(f){const a=new Map,i=(_,A=0)=>{const U=a.get(_);if(!U||U.length<A)throw new TypeError("Missing or truncated TrueType table: "+_);return U};if(f.u32(0)!==65536)throw new S("PDF fonts require a static TrueType .ttf with glyf outlines; collections, CFF and WOFF are unsupported.");const l=f.u16(4);if(!l||l>256)throw new TypeError("Invalid TrueType table count.");f.range(12,l*16);for(let _=0;_<l;_++){const A=12+_*16,U=f.tag(A),W=f.u32(A+8),q=f.u32(A+12);if(f.range(W,q),a.has(U))throw new TypeError("Duplicate TrueType table: "+U);a.set(U,{offset:W,length:q})}if(a.has("fvar"))throw new S("Instantiate a variable font as a static TrueType font before PDF export.");const o=i("head",54),s=i("maxp",6),t=i("hhea",36),n=i("OS/2",10);if(f.u32(o.offset+12)!==1594834165)throw new TypeError("Invalid TrueType head magic.");const e=f.u16(s.offset+4),r=f.u16(o.offset+18);if(!e||r<16||r>16384)throw new TypeError("Invalid TrueType metrics.");const d=f.u16(n.offset+8);if(d&514)throw new S("The font's embedding permissions prohibit outline embedding.");const h=!(d&256),u=1e3/r,c=f.i16(t.offset+4)*u,g=f.i16(t.offset+6)*u,w=[36,38,40,42].map(_=>f.i16(o.offset+_)*u),T=f.u16(t.offset+34);if(!T||T>e)throw new TypeError("Invalid TrueType horizontal metric count.");const v=i("hmtx",T*4+(e-T)*2),E=[];for(let _=0;_<e;_++)E.push(f.u16(v.offset+Math.min(_,T-1)*4)*u),(_&1023)===1023&&(yield);const R=f.i16(o.offset+50);if(R!==0&&R!==1)throw new TypeError("Unsupported TrueType loca index.");const I=i("loca",(e+1)*(R?4:2)),z=i("glyf"),j=[];for(let _=0;_<=e;_++)j.push(R?f.u32(I.offset+_*4):f.u16(I.offset+_*2)*2),(_&1023)===1023&&(yield);for(let _=0;_<=e;_++)if(j[_]>z.length||_&&j[_]<j[_-1])throw new TypeError("Invalid TrueType glyph offsets.");const M=i("cmap",4),L=[],B=new Set,Z=f.u16(M.offset+2);if(4+Z*8>M.length)throw new TypeError("Invalid TrueType cmap directory.");for(let _=0;_<Z;_++){const A=M.offset+4+_*8,U=f.u16(A),W=f.u16(A+2),q=f.u32(A+4);if(U!==0&&!(U===3&&(W===1||W===10)))continue;if(q+4>M.length)throw new TypeError("Invalid cmap subtable offset.");const X=M.offset+q,Y=f.u16(X);if(Y!==4&&Y!==12||B.has(X))continue;if(Y===12&&q+16>M.length)throw new TypeError("Truncated cmap format 12.");const F=Y===12?f.u32(X+4):f.u16(X+2);if(F<16||q+F>M.length)throw new TypeError("Invalid cmap length.");if(Y===12){const H=f.u32(X+12);if(16+H*12>F)throw new TypeError("Invalid cmap groups.");let K=-1;for(let re=0;re<H;re++){const ne=X+16+re*12,he=f.u32(ne),oe=f.u32(ne+4),ee=f.u32(ne+8);if(he<=K||he>oe||oe>1114111||ee+oe-he>=e)throw new TypeError("Invalid cmap scalar/glyph group.");K=oe,(re&1023)===1023&&(yield)}}else{const H=f.u16(X+6)/2;if(!Number.isInteger(H)||!H||16+H*8>F)throw new TypeError("Invalid cmap segments.");let K=-1;for(let re=0;re<H;re++){const ne=f.u16(X+14+re*2),he=f.u16(X+16+H*2+re*2);if(ne<=K||he>ne)throw new TypeError("Invalid cmap segment ordering.");K=ne,(re&1023)===1023&&(yield)}}B.add(X),L.push({offset:X,length:F})}const V=L.sort((_,A)=>f.u16(A.offset)-f.u16(_.offset));if(!L.length)throw new S("TrueType font needs a Unicode cmap format 4 or 12.");return{tables:a,glyphCount:e,units:r,ascent:c,descent:g,bbox:w,widths:E,offsets:j,canSubset:h,cmaps:V}}return Object.freeze({TrueTypeFont:b})})(),$e=(()=>{const{TrueTypeFont:S}=rr,{beginTask:O,checkAbort:P}=we,k=new WeakMap,C=Symbol.for("@evotecit/officeimo/PdfFont");function y(x){let m=k.get(x);if(!m){if(!(x instanceof p)||typeof x.toBytes!="function")throw new TypeError("Invalid PdfFont instance.");const f=new p(x.toBytes());m=k.get(f),k.set(x,m)}return m}class p{static[Symbol.hasInstance](m){return!!m&&typeof m=="object"&&m[C]===!0}brand=!0;constructor(m){if(!(m instanceof Uint8Array))throw new TypeError("PdfFont requires TrueType bytes as a Uint8Array.");if(m.length>64*1024*1024)throw new RangeError("A TrueType font must not exceed 64 MiB.");k.set(this,new S(m.slice())),this.brand,Object.defineProperty(this,C,{value:!0}),Object.freeze(this)}static async create(m,f={}){if(P(f.signal),!(m instanceof Uint8Array))throw new TypeError("PdfFont requires TrueType bytes as a Uint8Array.");const a=f.maxBytes??16*1024*1024;if(!Number.isSafeInteger(a)||a<0||a>64*1024*1024)throw new RangeError("Font preparation maxBytes must be a nonnegative safe integer at most 64 MiB.");if(m.length>a)throw new RangeError("TrueType font exceeds the preparation byte limit.");O();const i=await S.create(new Uint8Array(m),f.signal);P(f.signal);const l=Object.create(p.prototype);return k.set(l,i),Object.defineProperty(l,"brand",{value:!0}),Object.defineProperty(l,C,{value:!0}),Object.freeze(l),l}toBytes(){return y(this).bytes.slice()}}return Object.freeze({fontProgram:y,PdfFont:p})})(),nr=Object.freeze({helveticaWidths:new Map([[32,[278,278]],[33,[278,333]],[34,[355,474]],[35,[556,556]],[36,[556,556]],[37,[889,889]],[38,[667,722]],[39,[191,238]],[40,[333,333]],[41,[333,333]],[42,[389,389]],[43,[584,584]],[44,[278,278]],[45,[333,333]],[46,[278,278]],[47,[278,278]],[48,[556,556]],[49,[556,556]],[50,[556,556]],[51,[556,556]],[52,[556,556]],[53,[556,556]],[54,[556,556]],[55,[556,556]],[56,[556,556]],[57,[556,556]],[58,[278,333]],[59,[278,333]],[60,[584,584]],[61,[584,584]],[62,[584,584]],[63,[556,611]],[64,[1015,975]],[65,[667,722]],[66,[667,722]],[67,[722,722]],[68,[722,722]],[69,[667,667]],[70,[611,611]],[71,[778,778]],[72,[722,722]],[73,[278,278]],[74,[500,556]],[75,[667,722]],[76,[556,611]],[77,[833,833]],[78,[722,722]],[79,[778,778]],[80,[667,667]],[81,[778,778]],[82,[722,722]],[83,[667,667]],[84,[611,611]],[85,[722,722]],[86,[667,667]],[87,[944,944]],[88,[667,667]],[89,[667,667]],[90,[611,611]],[91,[278,333]],[92,[278,278]],[93,[278,333]],[94,[469,584]],[95,[556,556]],[96,[333,333]],[97,[556,556]],[98,[556,611]],[99,[500,556]],[100,[556,611]],[101,[556,556]],[102,[278,333]],[103,[556,611]],[104,[556,611]],[105,[222,278]],[106,[222,278]],[107,[500,556]],[108,[222,278]],[109,[833,889]],[110,[556,611]],[111,[556,611]],[112,[556,611]],[113,[556,611]],[114,[333,389]],[115,[500,556]],[116,[278,333]],[117,[556,611]],[118,[500,556]],[119,[722,778]],[120,[500,556]],[121,[500,556]],[122,[500,500]],[123,[334,389]],[124,[260,280]],[125,[334,389]],[126,[584,584]],[161,[333,333]],[162,[556,556]],[163,[556,556]],[164,[556,556]],[165,[556,556]],[166,[260,280]],[167,[556,556]],[168,[333,333]],[169,[737,737]],[170,[370,370]],[171,[556,556]],[172,[584,584]],[174,[737,737]],[175,[333,333]],[176,[400,400]],[177,[584,584]],[178,[333,333]],[179,[333,333]],[180,[333,333]],[181,[556,611]],[182,[537,556]],[183,[278,278]],[184,[333,333]],[185,[333,333]],[186,[365,365]],[187,[556,556]],[188,[834,834]],[189,[834,834]],[190,[834,834]],[191,[611,611]],[192,[667,722]],[193,[667,722]],[194,[667,722]],[195,[667,722]],[196,[667,722]],[197,[667,722]],[198,[1e3,1e3]],[199,[722,722]],[200,[667,667]],[201,[667,667]],[202,[667,667]],[203,[667,667]],[204,[278,278]],[205,[278,278]],[206,[278,278]],[207,[278,278]],[208,[722,722]],[209,[722,722]],[210,[778,778]],[211,[778,778]],[212,[778,778]],[213,[778,778]],[214,[778,778]],[215,[584,584]],[216,[778,778]],[217,[722,722]],[218,[722,722]],[219,[722,722]],[220,[722,722]],[221,[667,667]],[222,[667,667]],[223,[611,611]],[224,[556,556]],[225,[556,556]],[226,[556,556]],[227,[556,556]],[228,[556,556]],[229,[556,556]],[230,[889,889]],[231,[500,556]],[232,[556,556]],[233,[556,556]],[234,[556,556]],[235,[556,556]],[236,[278,278]],[237,[278,278]],[238,[278,278]],[239,[278,278]],[240,[556,611]],[241,[556,611]],[242,[556,611]],[243,[556,611]],[244,[556,611]],[245,[556,611]],[246,[556,611]],[247,[584,584]],[248,[611,611]],[249,[556,611]],[250,[556,611]],[251,[556,611]],[252,[556,611]],[253,[500,556]],[254,[556,611]],[255,[500,556]],[256,[667,722]],[257,[556,556]],[258,[667,722]],[259,[556,556]],[260,[667,722]],[261,[556,556]],[262,[722,722]],[263,[500,556]],[268,[722,722]],[269,[500,556]],[270,[722,722]],[271,[643,743]],[272,[722,722]],[273,[556,611]],[274,[667,667]],[275,[556,556]],[278,[667,667]],[279,[556,556]],[280,[667,667]],[281,[556,556]],[282,[667,667]],[283,[556,556]],[286,[778,778]],[287,[556,611]],[290,[778,778]],[291,[556,611]],[298,[278,278]],[299,[278,278]],[302,[278,278]],[303,[222,278]],[304,[278,278]],[305,[278,278]],[310,[667,722]],[311,[500,556]],[313,[556,611]],[314,[222,278]],[315,[556,611]],[316,[222,278]],[317,[556,611]],[318,[299,400]],[321,[556,611]],[322,[222,278]],[323,[722,722]],[324,[556,611]],[325,[722,722]],[326,[556,611]],[327,[722,722]],[328,[556,611]],[332,[778,778]],[333,[556,611]],[336,[778,778]],[337,[556,611]],[338,[1e3,1e3]],[339,[944,944]],[340,[722,722]],[341,[333,389]],[342,[722,722]],[343,[333,389]],[344,[722,722]],[345,[333,389]],[346,[667,667]],[347,[500,556]],[350,[667,667]],[351,[500,556]],[352,[667,667]],[353,[500,556]],[354,[611,611]],[355,[278,333]],[356,[611,611]],[357,[317,389]],[362,[722,722]],[363,[556,611]],[366,[722,722]],[367,[556,611]],[368,[722,722]],[369,[556,611]],[370,[722,722]],[371,[556,611]],[376,[667,667]],[377,[611,611]],[378,[500,500]],[379,[611,611]],[380,[500,500]],[381,[611,611]],[382,[500,500]],[402,[556,556]],[536,[667,667]],[537,[500,556]],[710,[333,333]],[711,[333,333]],[728,[333,333]],[729,[333,333]],[730,[333,333]],[731,[333,333]],[732,[333,333]],[733,[333,333]],[8211,[556,556]],[8212,[1e3,1e3]],[8216,[222,278]],[8217,[222,278]],[8218,[222,278]],[8220,[333,500]],[8221,[333,500]],[8222,[333,500]],[8224,[556,556]],[8225,[556,556]],[8226,[350,350]],[8230,[1e3,1e3]],[8240,[1e3,1e3]],[8249,[333,333]],[8250,[333,333]],[8260,[167,167]],[8364,[556,556]],[8482,[1e3,1e3]],[8706,[476,494]],[8710,[612,612]],[8721,[600,600]],[8722,[584,584]],[8730,[453,549]],[8800,[549,549]],[8804,[549,549]],[8805,[549,549]],[9674,[471,494]],[64257,[500,611]],[64258,[500,611]]])}),Dt=(()=>{const{OfficeIMOError:S}=pe,{PdfFont:O,fontProgram:P}=$e,{helveticaWidths:k}=nr,C=new Map([8364,0,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,0,381,0,0,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,0,382,376].map((f,a)=>[f,a+128]));function y(f){return f>=32&&f<=126||f>=160&&f<=255?f:f?C.get(f):void 0}function p(f,a,i){if(f>=55296&&f<=57343)return{supported:!1,code:"unpaired-surrogate",message:"PDF text contains an unpaired UTF-16 surrogate."};if(f<32||f>=127&&f<160)return{supported:!1,code:"unsupported-control",message:"PDF text contains an unsupported control character."};const l=String.fromCodePoint(f);if(/[\p{Mark}\p{Format}]/u.test(l)||!/[\p{Script=Latin}\p{Script=Greek}\p{Script=Cyrillic}\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Common}]/u.test(l)||f>=4352&&f<=4607||f>=127995&&f<=127999)return{supported:!1,code:"unsupported-layout",message:"This PDF table writer supports Unicode scalar layout; complex shaping, combining sequences and bidirectional text require a shaping-capable writer."};if(!a){if(y(f)===void 0)return{supported:!1,code:"embedded-font-required",message:"Text U+"+f.toString(16).toUpperCase()+" needs an embedded Unicode TrueType font; supply fonts.regular."};const s=k.get(f===160?32:f===173?45:f);return s?{supported:!0,width:s[i?1:0]}:{supported:!1,code:"missing-glyph",message:"Standard font has no metric for this character."}}let o=a.glyph(f);if(!o&&f===8239){const s=a.glyph(8201);s&&a.offsets[s]===a.offsets[s+1]&&(o=s)}return o?{supported:!0,glyph:o,width:a.widths[o]}:{supported:!1,code:"missing-glyph",message:"The supplied font has no glyph for U+"+f.toString(16).toUpperCase()+"."}}function b(f,a){if(!f)return;if(!(f.regular instanceof O))throw new TypeError("fonts.regular must be a PdfFont.");const i=new Set;for(const[l,o]of Object.entries(f)){if(!["regular","bold","italic","boldItalic"].includes(l)||!(o instanceof O))throw new TypeError("Invalid PDF font family.");i.add(o)}if(a!==void 0&&[...i].reduce((l,o)=>l+P(o).bytes.length,0)>a)throw new S("RESOURCE_LIMIT","maxFontBytes exceeded.")}function x(f,a,i){const l=f&&(a&&i?f.boldItalic:a?f.bold:i?f.italic:f.regular),o=l??f?.regular;return{font:o,syntheticBold:!!o&&a&&!l,syntheticItalic:!!o&&i&&!l}}return Object.freeze({standardCode:y,resolveScalar:p,validateFonts:b,selectFont:x})})(),sr=(()=>{const{NotSupportedError:S,OfficeIMOError:O}=pe,{fontProgram:P}=$e,{resolveScalar:k,selectFont:C,standardCode:y,validateFonts:p}=Dt,{pdfNumber:b,unicodeHex:x}=Be,{checkAbort:m,pause:f,taskYieldDue:a}=we,i=Object.freeze(Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0")));function l(n){return i[n>>>8]+i[n&255]}class o{index;bold;italic;font;shared;signal;name;object;program;syntheticBold;syntheticItalic;mappings=new Map;standardWidths=new Map;constructor(e,r,d,h,u,c,g,w,T){this.index=e,this.bold=r,this.italic=d,this.font=h,this.shared=w,this.signal=T,this.name=w?.name??"F"+e,this.object=w?.object??u.reserve(),this.program=h?P(h):void 0,this.syntheticBold=c,this.syntheticItalic=g}width(e){if(this.shared)return this.shared.width(e);if(this.program){const u=this.mappings.get(e);if(u)return u.width}else{const u=this.standardWidths.get(e);if(u!==void 0)return u}const r=k(e,this.program,this.bold);if(!r.supported)throw r.code==="unpaired-surrogate"?new TypeError(r.message):new S(r.message);if(!this.program)return this.standardWidths.set(e,r.width),r.width;if(this.mappings.size>=65535)throw new O("RESOURCE_LIMIT","A PDF font supports at most 65,535 distinct Unicode scalars.");const d=this.mappings.size+1,h={cid:d,hex:l(d),glyph:r.glyph,width:r.width,text:String.fromCodePoint(e)};return this.mappings.set(e,h),h.width}lineHeight(e){return Math.max(1.3,this.program?(this.program.ascent-this.program.descent)/1e3+.1:1.3)*e}encode(e){if(this.shared)return this.shared.encode(e);let r="";for(const d of e){const h=d.codePointAt(0);if(this.program){let u=this.mappings.get(h);u||(this.width(h),u=this.mappings.get(h)),r+=u.hex}else this.standardWidths.has(h)||this.width(h),r+=i[y(h)]}return"<"+r+">"}encodeGlyph(e,r){if(this.shared)return this.shared.encodeGlyph(e,r);if(!this.program||!Number.isSafeInteger(e)||e<=0||e>=this.program.glyphCount)throw new TypeError("Invalid shaped TrueType glyph.");const d=e+":"+r;let h=this.mappings.get(d);if(!h){if(this.mappings.size>=65535)throw new O("RESOURCE_LIMIT","A PDF font supports at most 65,535 distinct CID mappings.");const u=this.mappings.size+1;h={cid:u,hex:l(u),glyph:e,width:this.program.widths[e],text:r},this.mappings.set(d,h)}return"<"+h.hex+">"}async write(e,r){if(m(this.signal),!this.program){const B="Helvetica"+(this.bold&&this.italic?"-BoldOblique":this.bold?"-Bold":this.italic?"-Oblique":"");await e.object(this.object,"<< /Type /Font /Subtype /Type1 /BaseFont /"+B+" /Encoding /WinAnsiEncoding >>");return}const d=this.program,h=[...this.mappings],u=new Set(h.map(([,B])=>B.glyph)),c=(d.canSubset?"OIMOAA+":"")+"OfficeIMOFont"+this.index,g=e.reserve(),w=e.reserve(),T=e.reserve(),v=e.reserve(),E=e.reserve(),R=new Map;for(const[B,Z]of h)if(typeof B=="number")R.set(B,Z.glyph);else for(const V of Z.text){const _=V.codePointAt(0),A=d.glyph(_);A&&(R.set(_,A),u.add(A))}const I=await d.subsetCooperatively(u,R,this.signal);await e.stream(g,I,"/Length1 "+I.length,r,!0),await e.object(w,"<< /Type /FontDescriptor /FontName /"+c+" /Flags 32 /FontBBox ["+d.bbox.map(b).join(" ")+"] /ItalicAngle 0 /Ascent "+b(d.ascent)+" /Descent "+b(d.descent)+" /CapHeight "+b(d.ascent)+" /StemV 80 /FontFile2 "+g+" 0 R >>");const z=new Uint8Array((h.length+1)*2),j=new DataView(z.buffer);for(let B=0;B<h.length;B++){const Z=h[B][1];j.setUint16(Z.cid*2,Z.glyph),(B&1023)===1023&&(a()&&await f(),m(this.signal))}await e.stream(v,z,"",r,!0),await e.object(T,"<< /Type /Font /Subtype /CIDFontType2 /BaseFont /"+c+" /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /FontDescriptor "+w+" 0 R /CIDToGIDMap "+v+" 0 R"+(h.length?" /W [1 ["+h.map(([,B])=>b(B.width)).join(" ")+"]]":"")+" >>");let M="/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n/CMapName /OfficeIMOUnicode def\n/CMapType 2 def\n1 begincodespacerange\n<0000> <FFFF>\nendcodespacerange\n";const L=h.filter(([,B])=>B.text.length);for(let B=0;B<L.length;B+=100){const Z=L.slice(B,B+100);M+=Z.length+" beginbfchar\n";for(const[,V]of Z)M+="<"+V.hex+"> <"+x(V.text)+">\n";M+="endbfchar\n",a()&&await f(),m(this.signal)}M+="endcmap\nCMapName currentdict /CMap defineresource pop\nend\nend\n",await e.stream(E,M,"",r),await e.object(this.object,"<< /Type /Font /Subtype /Type0 /BaseFont /"+c+" /Encoding /Identity-H /DescendantFonts ["+T+" 0 R] /ToUnicode "+E+" 0 R >>")}}class s{objects;fonts;maxBytes;signal;resources=[];selections=new Map;programs=new Map;explicitSelections=new Map;registered=new Set;fontBytes=0;constructor(e,r,d=16*1024*1024,h){this.objects=e,this.fonts=r,this.maxBytes=d,this.signal=h,p(r,d);for(const u of Object.values(r??{}))this.registerFont(u)}registerFont(e){if(this.registered.has(e))return;const r=P(e).bytes.length;if(this.fontBytes+r>this.maxBytes)throw new O("RESOURCE_LIMIT","maxFontBytes exceeded.");this.fontBytes+=r,this.registered.add(e)}select(e=!1,r=!1,d){d&&this.registerFont(d);let h=this.selections;if(d){const R=this.explicitSelections.get(d);h=R??new Map,R||this.explicitSelections.set(d,h)}const u=(e?2:0)|(r?1:0),c=h.get(u);if(c)return c;const{font:g,syntheticBold:w,syntheticItalic:T}=d?{font:d,syntheticBold:e,syntheticItalic:r}:C(this.fonts,e,r),v=g?this.programs.get(g):void 0,E=new o(this.resources.length+1,e,r,g,this.objects,w,T,v,this.signal);return v||(this.resources.push(E),g&&this.programs.set(g,E)),h.set(u,E),E}dictionary(){return"<< "+this.resources.map(e=>"/"+e.name+" "+e.object+" 0 R").join(" ")+" >>"}}return Object.freeze({PdfFontResource:o,PdfFontResources:s})})(),Qe=(()=>{const{OfficeIMOError:S}=pe,{ExportCell:O,assertExportValue:P}=ve,{checkAbort:k,pause:C,taskYieldDue:y}=we,{isDate:p}=Me,{defaultBooleanText:b}=dt;function x(s,t){return t.limits.maxTextCharacters===void 0?s:s.replace(/[\t\r\n]/g,n=>n===" "?" ":"")}function m(s,t){if(typeof s=="string")return s;throw s&&typeof s.then=="function"&&Promise.resolve(s).catch(()=>{}),new TypeError(t+" must return a synchronous string.")}function f(s,t,n){if(P(s),s instanceof O&&s.text!==void 0)return s.text;const e=s instanceof O?s.value:s;return t.formatValue?m(t.formatValue(e,n),"formatValue"):e==null?"":p(e)?Number.isFinite(e.getTime())?e.toISOString():"":typeof e=="number"&&!Number.isFinite(e)?"":typeof e=="boolean"?(t.booleanText??b)[e?"true":"false"]:String(e)}function a(s,t,n,e,r,d,h=!0){const u=l(s,t,n,e,r,d,h);for(;;){const c=u.next();if(c.done)return c.value}}async function i(s,t,n,e,r,d,h=!0,u){k(u);const c=l(s,t,n,e,r,d,h);for(;;){const g=c.next();if(g.done)return g.value;y()&&await C(),k(u)}}function*l(s,t,n,e,r,d,h){if(s.length>r)throw new S("RESOURCE_LIMIT","maxCellCharacters exceeded.");const u=[];let c=0;function g(w,T){if(u.length>=d)throw new S("RESOURCE_LIMIT","maxRowLines exceeded.");u.push({text:w.join(""),width:T})}for(const w of s.replace(/\r\n?/g,"\n").replace(/\t/g," ").split("\n")){let T=[],v=[],E=0,R=-1;for(const I of w){(++c&4095)===0&&(yield);const z=t.width(I.codePointAt(0))*n/1e3;if(z>e+.001)throw new RangeError("PDF column is too narrow for a glyph. Increase page/column width or reduce padding/font size.");if(E+z>e+.001){if(!h)throw new RangeError("Unwrapped PDF cell exceeds its column width.");const j=R>=0?R+1:T.length,M=v.slice(0,j).reduce((L,B)=>L+B,0);g(T.slice(0,j),M),T=T.slice(j),v=v.slice(j),E=v.reduce((L,B)=>L+B,0),R=-1;for(let L=0;L<T.length;L++)T[L]===" "&&(R=L);E+z>e+.001&&(g(T,E),T=[],v=[],E=0,R=-1)}T.push(I),v.push(z),E+=z,I===" "&&(R=T.length-1)}g(T,E),(++c&4095)===0&&(yield)}return u}return Object.freeze({pdfBudgetText:x,synchronousText:m,displayText:f,wrapText:a,wrapTextCooperatively:i})})(),ir=(()=>{const{NotSupportedError:S,OfficeIMOError:O}=pe,{checkAbort:P,pause:k,taskYieldDue:C,withAbort:y}=we,p=(a,i)=>i===0||i===a.length||!(a.charCodeAt(i)>=56320&&a.charCodeAt(i)<=57343&&a.charCodeAt(i-1)>=55296&&a.charCodeAt(i-1)<=56319);function b(a,i){const l=[{text:"",owners:[]}];let o=0,s=a.runs[0]?.text.length??0;for(let t=0;t<a.text.length;){for(;t>=s&&o<a.runs.length-1;)s+=a.runs[++o].text.length;const n=a.text.codePointAt(t),e=String.fromCodePoint(n);if(t+=e.length,n>=55296&&n<=57343)throw new TypeError("PDF text contains an unpaired UTF-16 surrogate.");if(t>s&&o<a.runs.length-1)throw new S("A shaped presentation boundary cannot split a UTF-16 scalar.");if(e==="\n"||e==="\r"){if(e==="\r"&&a.text[t]==="\n"&&t++,l.length>=i)throw new O("RESOURCE_LIMIT","maxRowLines exceeded.");l.push({text:"",owners:[]});continue}if(n<32&&n!==9||n>=127&&n<160)throw new S("PDF text contains an unsupported control character.");const r=e===" "?" ":e,d=l.at(-1);if(d.text.length+r.length>4096)throw new O("RESOURCE_LIMIT","Shaped PDF text supports at most 4,096 UTF-16 units per physical paragraph.");d.text+=r;for(let h=0;h<r.length;h++)d.owners.push(o)}return l}function x(a,i,l,o,s,t){if(!Array.isArray(a)||a.length>32768)throw new TypeError("Invalid shaped run array.");let n=0,e=0;const r=new Uint8Array(o-l),d=new Map,h=new Map,u=[];for(const w of a){if(!w||!Array.isArray(w.glyphs)||!s.some(v=>v.font===w.font))throw new TypeError("Shaping must use an exact registered PdfFont identity.");if(n+=w.glyphs.length,n>32768)throw new O("RESOURCE_LIMIT","Shaped PDF text exceeded 32,768 glyphs.");const T=[];for(const v of w.glyphs){const{id:E,clusterStart:R,clusterEnd:I,xAdvance:z,yAdvance:j,xOffset:M,yOffset:L}=v??{},B=s[i.owners[R]??-1];if(!B||B.font!==w.font||!B.program||!Number.isSafeInteger(E)||E<=0||E>=B.program.glyphCount)throw new TypeError("Shaping returned an invalid glyph or font identity.");if(!Number.isSafeInteger(R)||!Number.isSafeInteger(I)||R<l||I<=R||I>o||!p(i.text,R)||!p(i.text,I))throw new TypeError("Shaping returned an invalid UTF-16 cluster range.");if(![z,j,M,L].every(_=>Number.isFinite(_)&&Math.abs(_)<=1e5)||z<0||j!==0)throw new TypeError("Shaping requires finite bounded horizontal glyph metrics.");const Z=t.runs[i.owners[R]];for(let _=R;_<I;_++){const A=t.runs[i.owners[_]];if(s[i.owners[_]].font!==w.font||Z.style.bold!==A.style.bold||Z.style.italic!==A.style.italic||Z.style.color!==A.style.color||Z.link!==A.link)throw new S("A PDF presentation, font or link boundary cannot split an indivisible shaped cluster.");r[_-l]=1}const V=d.get(R);if(V!==void 0&&V!==I)throw new TypeError("Inconsistent shaped cluster ranges.");d.set(R,I),h.set(R,(h.get(R)??0)+z),e+=z,T.push(Object.freeze({id:E,clusterStart:R,clusterEnd:I,xAdvance:z,yAdvance:j,xOffset:M,yOffset:L}))}u.push(Object.freeze({font:w.font,glyphs:Object.freeze(T)}))}if(r.some(w=>!w))throw new TypeError("Shaping omitted logical source text.");const c=[...d].sort((w,T)=>w[0]-T[0]);let g=l;for(const[w,T]of c){if(w!==g)throw new TypeError("Shaped clusters overlap or leave a logical gap.");g=T}return{runs:u,boundaries:c.map(([,w])=>w),advances:h,width:e}}async function m(a,i,l,o,s,t){const n=a.runs.map(c=>i.select(c.style.bold,c.style.italic,c.font)),e=i.select();if(n.some((c,g)=>!c.font&&a.runs[g].text.length))throw new S("Shaped PDF text requires explicit embedded TrueType fonts.");const r=[],d=s.options.textShaper,h=s.options.signal,u=(c,g,w,T)=>{if(r.length>=s.limits.maxRowLines)throw new O("RESOURCE_LIMIT","maxRowLines exceeded.");const v=[];let E=e.lineHeight(l),R=(e.program?.ascent??800)*l/1e3;const I=new Set;let z=-1,j,M=[],L=0;const B=()=>{if(z<0||!j)return;const V=a.runs[z],A=M.filter(U=>U.logicalText).sort((U,W)=>U.clusterStart-W.clusterStart).map(U=>U.logicalText).join("");v.push({text:A,actualText:A,logicalStart:Math.min(...M.map(U=>U.clusterStart)),width:L*l/1e3,font:j,glyphs:M,...V.style.color===void 0?{}:{color:V.style.color},...V.link?{link:V.link}:{}}),M=[],L=0};for(const V of T?.runs??[])for(const _ of V.glyphs){const A=c.owners[_.clusterStart],U=n[A];(z!==A||j!==U)&&(B(),z=A,j=U);const W=I.has(_.clusterStart)?"":c.text.slice(_.clusterStart,_.clusterEnd);I.add(_.clusterStart),M.push({..._,logicalText:W}),L+=_.xAdvance,E=Math.max(E,U.lineHeight(l)),R=Math.max(R,U.program.ascent*l/1e3)}B();const Z=c.text.slice(g,w);r.push({text:Z,actualText:Z,segments:v,width:(T?.width??0)*l/1e3,lineHeight:E,ascent:R})};for(const c of b(a,s.limits.maxRowLines)){if(P(h),!c.text){u(c,0,0);continue}const g=[];for(let I=0;I<c.text.length;){const z=c.owners[I];let j=I+1;for(;j<c.text.length&&c.owners[j]===z;)j++;g.push(Object.freeze({start:I,end:j,font:n[z].font})),I=j}Object.freeze(g);let w=0;const T=async(I,z)=>{if(++w>16385)throw new O("RESOURCE_LIMIT","Shaped line fitting exceeded its bounded work limit.");C()&&await k(),P(h);const j=await y(Promise.resolve(d.shapeLine(Object.freeze({text:c.text,start:I,end:z,runs:g,direction:s.options.textDirection??"auto",...h?{signal:h}:{}}))),h);return P(h),x(j,c,I,z,n,a)},v=await T(0,c.text.length),E=v.boundaries;if(!t){if(v.width*l/1e3>o+.001)throw new RangeError("Unwrapped PDF cell exceeds its column width.");u(c,0,c.text.length,v);continue}let R=0;for(;R<E.length;){const I=R?E[R-1]:0;let z=R,j=0,M=-1;for(;z<E.length;){const B=z?E[z-1]:0,Z=v.advances.get(B)*l/1e3;if(j+Z>o+.001&&z>R||(j+=Z,c.text[E[z]-1]===" "&&(M=z+1),z++,j>o+.001))break}z<E.length&&M>R&&(z=M);let L=I===0&&z===E.length?v:await T(I,E[z-1]);if(L.width*l/1e3>o+.001){let B=R+1,Z=z-1,V,_=0;for(;B<=Z;){const A=Math.floor((B+Z)/2),U=await T(I,E[A-1]);U.width*l/1e3<=o+.001?(V=U,_=A,B=A+1):Z=A-1}if(!V)throw new RangeError("PDF column is too narrow for an indivisible shaped cluster.");L=V,z=_}u(c,I,E[z-1],L),R=z}}return r}return Object.freeze({wrapShapedPdfText:m})})(),lt=(()=>{const{NotSupportedError:S,OfficeIMOError:O}=pe,{copyExportLink:P}=et,{checkAbort:k,pause:C,taskYieldDue:y}=we,{presentation:p,color:b}=Fe,{wrapShapedPdfText:x}=ir,{PdfFont:m}=$e,{pdfBudgetText:f}=Qe;function a(o,s,t,n,e=!0,r=!0){if(typeof o=="string"){if(o.length>t.limits.maxCellCharacters)throw new O("RESOURCE_LIMIT","maxCellCharacters exceeded.");return r&&(o.length||e)&&t.budget.reserve(1,f(o,t.budget).length),Object.freeze({text:o,runs:Object.freeze([Object.freeze({text:o,style:s})])})}const d=o;if(!Array.isArray(d))throw d&&typeof d.then=="function"&&Promise.resolve(d).catch(()=>{}),new TypeError("PDF text must be a string or a synchronous array of text runs.");if(d.length>t.limits.maxTextRuns)throw new O("RESOURCE_LIMIT","maxTextRuns exceeded.");let h=0,u=0;const c=[];for(const g of d){if(!g||typeof g!="object"||Object.keys(g).some(j=>!["text","bold","italic","color","link","font"].includes(j)))throw new TypeError("PDF text runs support text, bold, italic, color, link and font.");const{text:w,bold:T,italic:v,color:E,link:R,font:I}=g;if(typeof w!="string")throw new TypeError("PDF run text must be a string.");if(I!==void 0){if(!(I instanceof m))throw new TypeError("A PDF run font must be a PdfFont.");n.registerFont(I)}if(h+=w.length,h>t.limits.maxCellCharacters)throw new O("RESOURCE_LIMIT","maxCellCharacters exceeded.");r&&(u+=f(w,t.budget).length);const z=p({...s,...T===void 0?{}:{bold:T},...v===void 0?{}:{italic:v},...E===void 0?{}:{color:E}});if(t.options.tagged&&R!==void 0&&w.length&&!w.trim())throw new TypeError("Tagged PDF inline links require nonempty displayed text.");c.push(Object.freeze({text:w,style:z,...I===void 0?{}:{font:I},...R===void 0?{}:{link:P(R)}}))}return r&&(h||e)&&t.budget.reserve(1,u),Object.freeze({text:c.map(g=>g.text).join(""),runs:Object.freeze(c)})}async function i(o,s,t,n,e,r=!0){if(e.options.textShaper)return x(o,s,t,n,e,r);const{signal:d}=e.options,{text:h,runs:u}=o;k(d);const c=u.length===1?u[0]:void 0,g=c&&s.select(c.style.bold,c.style.italic,c.font),w=g?void 0:u.map(A=>s.select(A.style.bold,A.style.italic,A.font)),T=s.select();if(c&&h.length>0&&h.length<4096){const A=c,U=g;let W=0,q=!0;for(let X=0;X<h.length;){const Y=h.codePointAt(X);if(Y===9||Y===10||Y===13){q=!1;break}const F=U.width(Y)*t/1e3;if(F>n+.001||W+F>n+.001){q=!1;break}W+=F,X+=Y>65535?2:1}if(q){if(e.limits.maxRowLines<1)throw new O("RESOURCE_LIMIT","maxRowLines exceeded.");return[{text:h,width:W,segments:[{text:h,width:W,font:U,...A.style.color===void 0?{}:{color:A.style.color},...A.link?{link:A.link}:{}}],lineHeight:U.lineHeight(t),ascent:Math.max(0,(U.program?.ascent??800)*t/1e3)}]}}const v=w??[g],E=[];let R=[],I=[],z=[],j=0,M=-1,L=0,B=u[0]?.text.length??0,Z=0;const V=A=>{if(E.length>=e.limits.maxRowLines)throw new O("RESOURCE_LIMIT","maxRowLines exceeded.");const U=[];let W=0,q=0,X=0;for(let Y=0;Y<A;){const F=z[Y],H=u[F],K=v[F];let re=Y+1;for(;re<A&&z[re]===F;)re++;const ne=I.slice(Y,re).reduce((he,oe)=>he+oe,0);U.push({text:R.slice(Y,re).join(""),width:ne,font:K,...H.style.color===void 0?{}:{color:H.style.color},...H.link?{link:H.link}:{}}),W+=ne,q=Math.max(q,K.lineHeight(t)),X=Math.max(X,(K.program?.ascent??800)*t/1e3),Y=re}if(!U.length){const Y=v[0]??T;U.push({text:"",width:0,font:Y,...u[0]?.style.color===void 0?{}:{color:u[0].style.color}}),q=Y.lineHeight(t),X=(Y.program?.ascent??800)*t/1e3}E.push({text:R.slice(0,A).join(""),width:W,segments:U,lineHeight:q,ascent:X}),R=R.slice(A),I=I.slice(A),z=z.slice(A),j=I.reduce((Y,F)=>Y+F,0),M=-1;for(let Y=0;Y<R.length;Y++)R[Y]===" "&&(M=Y)},_=(A,U)=>{const W=v[U].width(A.codePointAt(0))*t/1e3;if(W>n+.001)throw new RangeError("PDF column is too narrow for a glyph. Increase page/column width or reduce padding/font size.");if(j+W>n+.001){if(!r)throw new RangeError("Unwrapped PDF cell exceeds its column width.");V(M>=0?M+1:R.length),j+W>n+.001&&V(R.length)}R.push(A),I.push(W),z.push(U),j+=W,A===" "&&(M=R.length-1)};for(let A=0;A<h.length;){for(;A>=B&&L<u.length-1;)B+=u[++L].text.length;const U=L,W=h.codePointAt(A),q=String.fromCodePoint(W);if(A+q.length>B&&L<u.length-1){let X=L+1;for(;!u[X].text.length;)X++;const Y=u[U],F=u[X],H=v[U],K=v[X];if(!(H.font===K.font&&(H.font?H.syntheticBold===K.syntheticBold&&H.syntheticItalic===K.syntheticItalic:H.bold===K.bold&&H.italic===K.italic))||b(Y.style.color??"111827")!==b(F.style.color??"111827")||Y.link?.target!==F.link?.target||Y.link?.tooltip!==F.link?.tooltip)throw new S("A PDF presentation boundary cannot split a UTF-16 scalar.")}if(A+=q.length,q==="\r"||q==="\n")q==="\r"&&h[A]==="\n"&&A++,V(R.length);else if(q===" ")for(let X=0;X<4;X++)_(" ",U);else _(q,U);(++Z&4095)===0&&(y()&&await C(),k(d))}return V(R.length),E}return Object.freeze({capturePdfText:a,wrapPdfText:i})})(),or=(()=>{const{OfficeIMOError:S}=pe,{wrapPdfText:O}=lt;function P(p,b){if(typeof b.options.wideTable!="object")return;const m=b.page.width-b.margins.left-b.margins.right,f=b.repeatedColumns,a=new Set(f),i=p.map((n,e)=>e).filter(n=>!a.has(n)),l=f.reduce((n,e)=>n+p[e],0);if(l>m+.001)throw new RangeError("Repeated PDF columns exceed the printable width.");const o=[];let s=[...f],t=l;for(const n of i){const e=p[n];if(l+e>m+.001)throw new RangeError("A PDF column and its repeated identifiers cannot fit a band.");t+e>m+.001&&(o.push(s),s=[...f],t=l),s.push(n),t+=e}if(s.length&&o.push(s),o.length>b.limits.maxTableBands)throw new S("RESOURCE_LIMIT","maxTableBands exceeded.");if(b.limits.maxTableWindowRows<1)throw new S("RESOURCE_LIMIT","maxTableWindowRows must allow at least one row fragment.");return Object.freeze(o.map(n=>{let e=b.margins.left;const r=n.map(d=>{const h=e;return e+=p[d],h});return Object.freeze({columns:Object.freeze(n),lefts:Object.freeze(r)})}))}async function k(p,b,x,m,f){const a=[];for(const i of p){const l=[];for(const o of i.cells){if(o.span===1){const s=b.columns.indexOf(o.first);s>=0&&l.push({...o,source:o.source??o,first:s});continue}for(let s=0;s<b.columns.length;){const t=b.columns[s];if(t<o.first||t>=o.first+o.span){s++;continue}let n=s+1;for(;n<b.columns.length&&b.columns[n]===b.columns[n-1]+1&&b.columns[n]<o.first+o.span;)n++;const e=b.columns.slice(s,n).reduce((d,h)=>d+x[h],0),r=await O(o.captured,f,m.fontSize,e-m.padding*2,m,o.style.wrapText!==!1);l.push({...o,source:o.source??o,first:s,span:n-s,width:e,lines:r,lineHeight:r.reduce((d,h)=>Math.max(d,h.lineHeight),o.font.lineHeight(m.fontSize))}),s=n}}l.sort((o,s)=>o.first-s.first),a.push({...i,source:i.source??i,cells:l})}return a}function C(p,b){if(!p.length||!p[0].length)return p;const x=p[0].length,m=Array.from({length:x},(f,a)=>Math.max(...p.map(i=>Math.max(b.padding*2+i[a].lineHeight,...i[a].cells.filter(l=>(l.rowSpan??1)===1).map(l=>l.lines.length*l.lineHeight+b.padding*2)))));for(const f of p)for(const[a,i]of f.entries())for(const l of i.cells){const o=l.rowSpan??1,s=m.slice(a,a+o).reduce((n,e)=>n+e,0),t=l.lines.length*l.lineHeight+b.padding*2;if(t>s)for(let n=a;n<a+o;n++)m[n]+=(t-s)/o}return p.map(f=>f.map((a,i)=>({...a,structured:!0,height:m[i],cells:a.cells.map(l=>({...l,height:m.slice(i,i+(l.rowSpan??1)).reduce((o,s)=>o+s,0)}))})))}return Object.freeze({planTableBands:P,projectBandRows:k,alignBandBlocks:C})})(),bt=(()=>{const{ExportCell:S}=ve,{copyExportLink:O}=et,{tableSpans:P}=Ve,{createTotals:k}=ht,{presentation:C,positive:y}=Fe,{displayText:p,pdfBudgetText:b}=Qe,{capturePdfText:x,wrapPdfText:m}=lt,{planTableBands:f,projectBandRows:a,alignBandBlocks:i}=or;class l{settings;fonts;bands;widths;lefts;lineHeight;headings;totals;repeatedColumns;structuredBandRows=new WeakMap;dataPresentations=[];constructor(t,n){this.settings=t,this.fonts=n;const{options:e,padding:r,fontSize:d,page:h,margins:u}=t,c=e.columns,g=h.width-u.left-u.right;this.repeatedColumns=new Set(t.repeatedColumns);let w;if(e.columnWidths&&e.columnWidths.length!==c.length)throw new RangeError("columnWidths must declare one point width per column.");const T=typeof e.wideTable=="object"?e.wideTable.minimumColumnWidth??72:0,v=c.map((j,M)=>y(e.columnWidths?.[M]??Math.max(T,j.width===void 0?g/c.length:y(j.width,"Column width",255)*(w??=n.select().width(48)*d/1e3)+r*2),"PDF column width")),E=v.reduce((j,M)=>j+M,0);if(E>g+.001&&e.wideTable==="reject")throw new RangeError("Table widths exceed the printable page width.");this.bands=f(v,t),this.widths=!this.bands&&E>g?v.map(j=>j*g/E):v;let R=u.left;if(this.lefts=this.widths.map(j=>{const M=R;return R+=j,M}),this.widths.some(j=>j<=r*2))throw new RangeError("Page is too narrow for this many columns and the requested padding.");this.lineHeight=n.select().lineHeight(d);const I=c.reduce((j,M)=>Math.max(j,M.groups?.length??0),0);if(I>16)throw new RangeError("Grouped headings support at most 16 levels.");if(I&&e.includeHeader===!1)throw new TypeError("Grouped headings require leaf headings.");const z=[];if(e.includeHeader!==!1){for(let j=0;j<I;j++){const M=[];for(let L=0;L<c.length;){let B=L;const Z=c[L].groups?.[j]??"",V=JSON.stringify(c[L].groups?.slice(0,j+1));for(;Z&&B+1<c.length&&JSON.stringify(c[B+1].groups?.slice(0,j+1))===V;)B++;M.push({first:L,span:B-L+1,text:Z}),L=B+1}z.push(M)}z.push(c.map((j,M)=>({first:M,span:1,text:j.header})))}this.headings=z,this.totals=k(c,e.footer?.totals)}async cell(t,n,e,r,d,h=!1){const{options:u,padding:c,fontSize:g,budget:w}=this.settings,T=u.columns[n],v=t instanceof S?t.presentation:void 0,E=t instanceof S&&t.link?O(t.link):void 0,R=h&&r%2&&u.alternateRowColor?u.alternateRowColor:void 0,I=n*2+(R?1:0),z=h&&v===void 0;let j=z?this.dataPresentations[I]:void 0;if(!j){const W=h?R?{background:R}:{}:d;j=C({...T.alignment===void 0?{}:{alignment:T.alignment},...T.wrapText===void 0?{}:{wrapText:T.wrapText},...W,...v}),z&&(this.dataPresentations[I]=j)}const M=this.fonts.select(j.bold,j.italic),L=e===1?this.widths[n]:this.widths.slice(n,n+e).reduce((W,q)=>W+q,0),B={rowIndex:r,columnIndex:n,column:T},Z=t instanceof S?t.value:t;let V;if(u.formatRuns&&r>=0&&!(t instanceof S&&t.text!==void 0)){const W=u.formatRuns(Z,B);if(!Array.isArray(W))throw W&&typeof W.then=="function"&&Promise.resolve(W).catch(()=>{}),new TypeError("formatRuns must return a synchronous array of PDF text runs.");V=W}else V=p(t,u,B);const _=x(V,j,this.settings,this.fonts);if(u.tagged&&E&&!_.text.trim())throw new TypeError("Tagged PDF cell links require nonempty displayed text.");if(E&&_.runs.some(W=>W.link))throw new TypeError("A PDF cell link cannot be combined with inline run links.");const A=b(_.text,w);this.bands?w.release(1,A.length):w.cell(A,A.length);const U=await m(_,this.fonts,g,L-c*2,this.settings,j.wrapText!==!1);return{first:n,span:e,width:L,font:M,style:j,lineHeight:U.reduce((W,q)=>Math.max(W,q.lineHeight),M.lineHeight(g)),...E?{link:E}:{},...this.bands?{captured:_}:{},lines:U}}row(t){let n=1,e=this.lineHeight;for(let r=0;r<t.length;r++){const d=t[r];n=Math.max(n,d.lines.length),e=Math.max(e,d.lineHeight)}return{cells:t,lines:n,lineHeight:e,height:n*e+this.settings.padding*2}}async headers(){if(this.settings.options.headerRows)return this.block(this.settings.options.headerRows,this.settings.options.headerPresentation??{});const{formatValue:t,...n}=this.settings.options,e=[];for(const r of this.headings){const d=[];for(const h of r)d.push(await this.cell(new S(h.text,{text:h.text}),h.first,h.span,-1,n.headerPresentation??{}));e.push(this.row(d))}return e}async block(t,n){const e=P(t,this.settings.options.columns.length),{formatValue:r,...d}=this.settings.options,h=[];for(const c of e){const g=[];for(const w of c){const T=w.value instanceof S?w.value:new S(w.value),v=new S(T.value,{text:p(T,d,{rowIndex:-1,columnIndex:w.first,column:d.columns[w.first]}),...T.presentation?{presentation:T.presentation}:{},...T.link?{link:T.link}:{}});g.push({...await this.cell(v,w.first,w.span,-1,n),rowSpan:w.rowSpan})}h.push(g)}const u=h.map(c=>Math.max(this.lineHeight+this.settings.padding*2,...c.filter(g=>g.rowSpan===1).map(g=>g.lines.length*g.lineHeight+this.settings.padding*2)));return h.forEach((c,g)=>c.forEach(w=>{const T=u.slice(g,g+w.rowSpan).reduce((E,R)=>E+R,0),v=w.lines.length*w.lineHeight+this.settings.padding*2;if(v>T)for(let E=g;E<g+w.rowSpan;E++)u[E]+=(v-T)/w.rowSpan})),h.map((c,g)=>({cells:c.map(w=>({...w,height:u.slice(g,g+w.rowSpan).reduce((T,v)=>T+v,0)})),lines:Math.max(1,Math.ceil((u[g]-this.settings.padding*2)/this.lineHeight)),lineHeight:this.lineHeight,height:u[g],structured:!0}))}minimumRowLines(t){let n=1;if(this.bands)for(const e of t.cells)this.repeatedColumns.has(e.first)&&(n=Math.max(n,e.lines.length));return n}minimumRowHeight(t){return this.minimumRowLines(t)*t.lineHeight+this.settings.padding*2}repeatedColumn(t){return this.repeatedColumns.has(t)}async blockHeight(t){return(this.bands?(await this.bandRows(t,!0))[0]:t).reduce((e,r)=>e+r.height,0)}async bandRows(t,n=!1){if(!this.bands)throw new Error("Horizontal bands were not planned.");if(!n)return this.projectBandRows(t,!1);let e=this.structuredBandRows.get(t);return e||(e=this.projectBandRows(t,!0),this.structuredBandRows.set(t,e)),e}async projectBandRows(t,n){const e=[],r=new Set;for(const d of this.bands){const h=await a(t,d,this.widths,this.settings,this.fonts);e.push(h.map(u=>({...u,cells:u.cells.map(c=>{const g=c.source,w=r.has(g);return r.add(g),w?{...c,semanticArtifact:!0}:c})})))}return n?i(e,this.settings):e}async data(t,n,e=!1){const{options:r}=this.settings,d=[];for(let h=0;h<r.columns.length;h++){const u=t[h],c=u instanceof S?u.value:u;e||this.totals[h].accept(c);const g=await this.cell(u,h,1,n,e?r.footerPresentation??{}:void 0,!e);d.push(!e&&r.columns[h].rowHeader?{...g,rowHeader:!0}:g)}return this.row(d)}async footer(t){if(!this.settings.options.footer)return;if(this.settings.options.footer.rows)return this.block(this.settings.options.footer.rows,this.settings.options.footerPresentation??{});const n=this.totals.map((e,r)=>e.operation?e.value():this.settings.options.footer?.values?.[r]);return[await this.data(n,t,!0)]}}return Object.freeze({PdfTableLayout:l})})(),ar=(()=>{const{OfficeIMOError:S}=pe,{checkAbort:O}=we;class P{layout;headings;painter;caption;continuation;entries=[];height=0;count=0;firstWindow=!0;firstCapacity;painted=!1;constructor(y,p,b,x,m){this.layout=y,this.headings=p,this.painter=b,this.caption=x,this.continuation=m,this.firstCapacity=b.firstCapacity}get capacity(){return this.firstWindow?this.firstCapacity:this.painter.continuationCapacity}async accept(y){if(this.entries.length&&(this.height+y.height>this.capacity+.001||this.count+y.count>this.layout.settings.limits.maxTableWindowRows)&&await this.flush(),this.firstWindow&&!this.entries.length&&y.height>this.capacity+.001&&y.height<=this.painter.firstFullCapacity+.001&&(await this.painter.moveFirstToFreshPage(),this.firstCapacity=this.painter.firstFullCapacity),y.height>this.capacity+.001)throw new RangeError("PDF band window cannot fit the requested table fragment.");this.entries.push(y),this.height+=y.height,this.count+=y.count,this.count>=this.layout.settings.limits.maxTableWindowRows&&await this.flush()}async row(y,p=!1){const{padding:b,fontSize:x,options:m}=this.layout.settings,f=this.layout.minimumRowLines(y),a=f*y.lineHeight+b*2;if(a>this.painter.firstFullCapacity+.001||a>this.painter.continuationCapacity+.001)throw new RangeError("Repeated PDF identifiers must fit intact below the first and continued band headings/context.");this.entries.length&&y.height<=this.painter.continuationCapacity+.001&&y.height>this.capacity-this.height+.001&&await this.flush(),!p&&this.firstWindow&&!this.entries.length&&y.height>this.capacity+.001&&y.height<=this.painter.firstFullCapacity+.001&&(await this.painter.moveFirstToFreshPage(),this.firstCapacity=this.painter.firstFullCapacity),await this.painter.prepareRow?.(y);let i=0;for(;i<y.lines;){if(O(m.signal),this.entries.length&&this.capacity-this.height+.001<a&&await this.flush(),this.firstWindow&&!this.entries.length&&this.capacity+.001<a&&(await this.painter.moveFirstToFreshPage(),this.firstCapacity=this.painter.firstFullCapacity),this.capacity-this.height+.001<a)throw new RangeError("PDF band window cannot fit its complete repeated identifiers.");const l=Math.min(y.lines-i,Math.floor((this.capacity-this.height-b*2+.001)/y.lineHeight));if(l<1)throw new RangeError("PDF page cannot fit a table line below horizontal band headings.");const o=Math.max(l,f),s=o*y.lineHeight+b*2,t=await this.layout.bandRows([y]),n=[],e=t.map((r,d)=>{let h=!1;const u=r[0].cells.map(w=>{const T=this.layout.bands[d].columns[w.first],v=this.layout.repeatedColumn(T),E=w.span===1&&(w.source?.span??1)===1&&(w.rowSpan??1)===1&&w.height===void 0&&i===0&&(v||l>=w.lines.length),R=v||E?w.lines:w.lines.slice(i,i+l);if(!v&&(R.length>0||w.link!==void 0)&&(h=!0),E)return w;const{height:I,...z}=w;return{...z,lines:R,lineHeight:R.reduce((j,M)=>Math.max(j,M.lineHeight),w.font.lineHeight(x)),...i>0&&v?{semanticArtifact:!0}:{}}}),c=Math.max(1,...u.map(w=>w.lines.length)),g=Math.max(this.layout.lineHeight,...u.filter(w=>w.lines.length>0).map(w=>w.lineHeight));return n.push(i>0&&!h),[{...r[0],cells:u,lines:c,lineHeight:g,height:c*g+b*2}]});await this.accept({rows:e,height:s,count:1,completed:i+l>=y.lines?[y]:[],exhaustedBands:n}),i+=l,i<y.lines&&await this.flush()}}async block(y){const p=await this.layout.bandRows(y,!0),b=p[0].reduce((x,m)=>x+m.height,0);if(y.length>this.layout.settings.limits.maxTableWindowRows)throw new S("RESOURCE_LIMIT","A structured PDF block exceeds maxTableWindowRows.");for(const x of y)await this.painter.prepareRow?.(x);await this.accept({rows:p,height:b,count:y.length,completed:y,exhaustedBands:p.map(()=>!1)})}async keptRows(y,p=!1){const b=y.reduce((m,f)=>m+f.height,0),x=b<=this.painter.continuationCapacity+.001;this.entries.length&&x&&b>this.capacity-this.height+.001&&await this.flush();for(const[m,f]of y.entries())await this.row(f,!x&&m===0&&p)}async flush(y=!1){if(!(!this.entries.length&&(!y||this.painted||!this.headings.some(p=>p.length)))){for(let p=0;p<this.layout.bands.length;p++)O(this.layout.settings.options.signal),!(!this.firstWindow&&this.entries.length>0&&this.entries.every(b=>b.exhaustedBands[p]))&&await this.painter.paint(p,this.headings[p],this.entries.flatMap(b=>b.rows[p]),this.firstWindow?this.caption:this.continuation,this.firstWindow,p===0);for(const p of this.entries)for(const b of p.completed)await this.painter.completeRow?.(b);this.entries=[],this.height=0,this.count=0,this.firstWindow=!1,this.painted=!0}}}return Object.freeze({PdfTableBandFlow:P})})(),lr=(()=>{class S{structure;table;headers;cells=new WeakMap;rows=new WeakMap;columnHeaders=[];ordinaryAttributes=[];headerCount=0;headersPrepared=!1;constructor(k,C,y){this.structure=k,this.table=C,this.headers=y}async prepareHeaders(){if(!this.headersPrepared){for(let k=0;k<this.headers.length;k++){const C=this.headers[k],y=this.structure.element("TR",this.table);this.rows.set(C,y);for(const p of C.cells){const b=p.lines.some(f=>f.text.trim().length>0),x=this.associations(p,k),m=this.structure.element(b?"TH":"TD",y,this.attributes(p,x,b?"Column":void 0));if(this.cells.set(p,m),b){const f={row:k,order:this.headerCount++,identifier:await this.structure.identifier(m)};for(let a=p.first;a<p.first+p.span;a++)(this.columnHeaders[a]??=[]).push(f)}}}this.headersPrepared=!0}}async completeHeaders(){for(const k of this.headers)await this.completeRow(k)}async prepareRow(k,C="data",y=this.table,p){if(this.rows.get(k)!==void 0)return k.cells.map(a=>this.cells.get(a));const x=this.structure.element("TR",y);this.rows.set(k,x);const m=k.cells.map((a,i)=>{const l=p===void 0?a.rowHeader===!0:i===p,o=this.structure.element(l?"TH":"TD",x);return this.cells.set(a,o),o});let f;for(let a=0;a<m.length;a++)(p===void 0?k.cells[a].rowHeader===!0:a===p)&&(f??=[]).push(await this.structure.identifier(m[a]));for(let a=0;a<k.cells.length;a++){const i=k.cells[a];if(!f&&i.span===1&&(i.rowSpan??1)===1){const s=this.ordinaryAttributes[i.first]??=await this.structure.attributeReference(this.attributeDictionary(i,this.associations(i)));this.structure.setAttributes(m[a],s);continue}const l=this.associations(i),o=p===void 0?i.rowHeader===!0:a===p;!o&&f&&l.push(...f),this.structure.setAttributes(m[a],this.attributes(i,l,o?"Row":void 0))}return m}owner(k){return this.cells.get(k)}async completeRow(k){await this.structure.complete(this.rows.get(k))}async finish(){await this.completeHeaders(),await this.structure.complete(this.table)}associations(k,C=Number.POSITIVE_INFINITY){if(k.span===1)return(this.columnHeaders[k.first]??[]).filter(p=>p.row<C).map(p=>p.identifier);const y=new Set;for(let p=k.first;p<k.first+k.span;p++)for(const b of this.columnHeaders[p]??[])b.row<C&&y.add(b);return[...y].sort((p,b)=>p.order-b.order).map(p=>p.identifier)}attributes(k,C,y){return" /A "+this.attributeDictionary(k,C,y)}attributeDictionary(k,C,y){return"<< /O /Table"+(y===void 0?"":" /Scope /"+y)+(k.span>1?" /ColSpan "+k.span:"")+((k.rowSpan??1)>1?" /RowSpan "+k.rowSpan:"")+(C.length?" /Headers ["+C.map(p=>"("+p+")").join(" ")+"]":"")+" >>"}}return Object.freeze({PdfTableStructure:S})})(),cr=(()=>{const{OfficeIMOError:S}=pe,{pdfNumber:O,unicodeHex:P}=Be,k=new TextEncoder;function C(p,b,x,m,f,a,i,l){const o="<< /Type /Annot /Subtype /Link /F 4 /Border [0 0 0] /Rect ["+[b,x,b+m,x+f].map(O).join(" ")+"]"+(i===void 0?"":" /StructParent "+i)+(l===void 0?"":" /P "+l+" 0 R")+" /A << /S /URI /URI <",s="> >>"+(p.tooltip===void 0?"":" /Contents <feff")+" >>",t=o.length+s.length+(p.tooltip===void 0?0:p.tooltip.length*4+1),n=()=>{throw new S("RESOURCE_LIMIT","maxPageBytes exceeded.")};t+p.target.length*2>a&&n();let e=0;for(let d=0;d<p.target.length;d++){const h=p.target.charCodeAt(d);h<128?e++:h<2048?e+=2:h>=55296&&h<=56319&&d+1<p.target.length&&p.target.charCodeAt(d+1)>=56320&&p.target.charCodeAt(d+1)<=57343?(e+=4,d++):e+=3,t+e*2>a&&n()}let r="";for(const d of k.encode(p.target))r+=d.toString(16).padStart(2,"0");return o+r+"> >>"+(p.tooltip===void 0?"":" /Contents <feff"+P(p.tooltip)+">")+" >>"}return Object.freeze({linkAnnotation:C})})(),xt=(()=>{const{OfficeIMOError:S}=pe,{unicodeHex:O}=Be,{captureFields:P}=Ce;function k(p,b){if(p===void 0)return;if(!p||typeof p!="object")throw new TypeError("PDF bookmark must provide a title and optional level.");const{title:x,level:m=1}=p;if(typeof x!="string"||!x.trim())throw new TypeError("PDF bookmark title must be nonempty text.");if(x.length>b.limits.maxCellCharacters)throw new S("RESOURCE_LIMIT","maxCellCharacters exceeded by bookmark title.");if(!Number.isInteger(m)||m<1||m>6)throw new TypeError("PDF bookmark level must be an integer from 1 through 6.");return O(x),Object.freeze({title:x,level:m})}function C(p,b){if(!p||p.kind!=="section")throw new TypeError("PDF section boundary required.");if(Object.keys(p).some(d=>!["kind","title","level","includeHeading","bookmark","headingStyle","pageSize","orientation","margins","pageHeader","pageFooter","pageNumbers"].includes(d)))throw new TypeError("PDF sections support title, heading/bookmark controls, page geometry and decorations only.");const{title:x,level:m,includeHeading:f=!0,bookmark:a=!0,headingStyle:i,pageSize:l,orientation:o,margins:s,pageHeader:t,pageFooter:n,pageNumbers:e}=p,r=k({title:x,...m===void 0?{}:{level:m}},b);for(const[d,h]of[["includeHeading",f],["bookmark",a],["pageNumbers",e]])if(h!==void 0&&typeof h!="boolean")throw new TypeError("PDF section "+d+" must be boolean.");if(i!==void 0&&(typeof i!="string"||!i.trim()))throw new TypeError("PDF section headingStyle must be nonempty text.");return Object.freeze({kind:"section",title:r.title,level:r.level,includeHeading:f,bookmark:a,...i===void 0?{}:{headingStyle:i},...l===void 0?{}:{pageSize:typeof l=="object"?Object.freeze(P(l,["width","height"])):l},...o===void 0?{}:{orientation:o},...s===void 0?{}:{margins:typeof s=="object"?Object.freeze(P(s,["top","right","bottom","left"])):s},...t===void 0?{}:{pageHeader:t},...n===void 0?{}:{pageFooter:n},...e===void 0?{}:{pageNumbers:e}})}return Object.freeze({captureBookmark:k,captureSection:C})})(),hr=(()=>{const{settings:S}=Fe;function O(k,C){const{pageSize:y,orientation:p,margins:b,pageHeader:x,pageFooter:m,pageNumbers:f}=C,a={...k.options,...y===void 0?{}:{pageSize:y},...p===void 0?{}:{orientation:p},...b===void 0?{}:{margins:b},...x===void 0?{}:{pageHeader:x},...m===void 0?{}:{pageFooter:m},...f===void 0?{}:{pageNumbers:f}},i=S(a,!0);return{...k,page:i.page,margins:i.margins,options:a}}return Object.freeze({sectionSettings:O})})(),dr=(()=>{const{OfficeIMOError:S}=pe,{checkAbort:O}=we,{pdfNumber:P}=Be,{color:k}=Fe,{PdfTableBandFlow:C}=ar,{PdfTableStructure:y}=lr,{wrapText:p,wrapTextCooperatively:b,synchronousText:x,pdfBudgetText:m}=Qe,{linkAnnotation:f}=cr,{unicodeHex:a}=Be,{captureSection:i,captureBookmark:l}=xt,{sectionSettings:o}=hr;class s{objects;baseSettings;fonts;parent;resources;layout;structure;outlines;references=[];current=0;commands="";commandParts=[];commandBytes=0;annotations=[];hyperlinks=0;y=0;dataTop=0;continuationTop=0;totalPages;numberSettings;activeSettings;pendingPage;bodyAdded=!1;sectionCount=0;sectionPages=0;sectionTitle;pendingBookmarks=[];pageNumberWidth=0;colors=new Map;textFont;textSize=0;textColor="";textPrefix="";rectangleLefts;rectangleColumns=[];externalObjects=new Map;bandFlow;bandCellBudget=!1;tableElement;tableStructure;activeHeadings;paintedHeaderCells=new WeakSet;paintedHeaderBudgetCells=new WeakSet;summaryRows=new WeakSet;groups=[];continuationCaption;tableCaptionOwner;continuationCaptionPaints=0;constructor(e,r,d,h,u,c,g,w){this.objects=e,this.baseSettings=r,this.fonts=d,this.parent=h,this.resources=u,this.layout=c,this.structure=g,this.outlines=w,this.activeSettings=r}measurePageNumbers(){const e=this.settings,r=this.fonts.select(),d=e.limits.maxPages,u=Math.max(...Array.from({length:Math.min(10,d)},(w,T)=>r.width(d<10?49+T:48+T)))*String(d).length*e.fontSize/1e3,c=e.options.pageNumberLabels;return p((c?.prefix??"Page ")+(c?.separator??" of ")+(c?.suffix??""),r,e.fontSize,Number.MAX_SAFE_INTEGER,e.limits.maxCellCharacters,1,!1)[0].width+u*2+2}get settings(){return this.activeSettings}async ensureStarted(){this.current||await this.start(!1)}async beginSection(e){const r=i(e,this.baseSettings),d=o(this.baseSettings,r);if(++this.sectionCount>this.baseSettings.limits.maxSections)throw new S("RESOURCE_LIMIT","maxSections exceeded.");return this.current&&(this.bodyAdded?await this.finishPage():(this.pendingPage=this.current,this.current=0)),this.activeSettings=d,this.sectionPages=0,this.sectionTitle=r.title,await this.structure?.beginSection(),r}addBookmark(e){const r=l(e,this.settings);if((this.outlines?.count??0)+this.pendingBookmarks.length>=this.settings.limits.maxBookmarks)throw new S("RESOURCE_LIMIT","maxBookmarks exceeded.");this.settings.budget.cell(r.title),this.current?this.outlines?.add(r,this.current,this.y):this.pendingBookmarks.push(r)}add(e){this.retainPageBytes(e.length),this.commands+=e}retainPageBytes(e){if(this.commandBytes+=e,this.commandBytes>this.settings.limits.maxPageBytes)throw new S("RESOURCE_LIMIT","maxPageBytes exceeded.")}rgb(e){let r=this.colors.get(e);return r||(r=k(e),this.colors.size<1024&&this.colors.set(e,r)),r}artifact(e,r="Layout"){return this.structure?"/Artifact << /Type /"+r+" >> BDC\n"+e+"EMC\n":e}text(e,r,d,h,u,c="111827",g){const w=P;if(r!==this.textFont||d!==this.textSize||c!==this.textColor){const v=r.syntheticItalic?.213:0,E=this.rgb(c);this.textPrefix="q "+E+" rg "+E+" RG\nBT /"+r.name+" "+w(d)+" Tf "+(r.syntheticBold?w(d*.025)+" w 2 Tr ":"0 Tr ")+"1 0 "+w(v)+" 1 ",this.textFont=r,this.textSize=d,this.textColor=c}const T=this.textPrefix+w(h)+" "+w(u)+" Tm "+r.encode(e)+" Tj ET Q\n";this.add(this.structure&&g!==void 0?this.structure.mark(g)+T+"EMC\n":this.artifact(T,"Pagination"))}link(e,r,d,h,u,c){if(h<=0)return;if(++this.hyperlinks>this.settings.limits.maxHyperlinks)throw new S("RESOURCE_LIMIT","maxHyperlinks exceeded.");const g=this.objects.reserve(),w=this.structure&&c!==void 0?this.structure.annotation(c,g):void 0,T=f(e,r,d,h,u,this.settings.limits.maxPageBytes-this.commandBytes,w,this.structure?this.current:void 0);this.retainPageBytes(T.length),this.annotations.push({id:g,body:T})}inline(e,r,d,h,u,c=u){const g=!this.structure&&e.actualText!==void 0&&e.actualText.length>0;g&&this.add("/Span << /ActualText <FEFF"+a(e.actualText)+"> >> BDC\n");let w;if(e.actualText!==void 0&&this.structure&&u!==void 0){w=new Map;for(const T of[...e.segments].sort((v,E)=>(v.logicalStart??0)-(E.logicalStart??0))){const v=T.link?this.structure.link(u,T.link):u;w.set(T,{owner:v,mark:this.structure.mark(v,T.actualText)})}}for(const T of e.segments){const v=w?.get(T),E=v?.owner??(T.link&&this.structure&&u!==void 0?this.structure.link(u,T.link):u);if(T.glyphs){const R=T.font,I=P,z=R.syntheticItalic?.213:0,j=this.rgb(T.color??"111827");let M=d,L="q "+j+" rg "+j+" RG\nBT /"+R.name+" "+I(r)+" Tf "+(R.syntheticBold?I(r*.025)+" w 2 Tr ":"0 Tr ");for(const B of T.glyphs)L+="1 0 "+I(z)+" 1 "+I(M+(B.xOffset+z*B.yOffset)*r/1e3)+" "+I(h+B.yOffset*r/1e3)+" Tm "+R.encodeGlyph(B.id,B.logicalText)+" Tj\n",M+=B.xAdvance*r/1e3;L+="ET Q\n",this.add(this.structure&&E!==void 0?(v?.mark??this.structure.mark(E,T.actualText))+L+"EMC\n":this.artifact(L,"Pagination"))}else this.text(T.text,T.font,r,d,h,T.color,E);if(T.link){const R=(T.font.program?.ascent??800)*r/1e3,I=(T.font.program?.descent??-200)*r/1e3,z=E??(this.structure&&c!==void 0?this.structure.link(c,T.link):void 0);this.link(T.link,d,h+I,T.width,R-I,z)}d+=T.width}g&&this.add("EMC\n")}decorationText(e){return e===void 0?"":(O(this.settings.options.signal),x(typeof e=="function"?e(Object.freeze({pageNumber:this.references.length,sectionNumber:this.sectionCount||1,sectionPageNumber:this.sectionPages,...this.sectionTitle===void 0?{}:{sectionTitle:this.sectionTitle}})):e,"Page header/footer"))}decoration(e,r,d,h){if(!e)return;this.settings.budget.cell(m(e,this.settings.budget));const u=this.fonts.select(),c=p(e,u,this.settings.fontSize,h,this.settings.limits.maxCellCharacters,1,!1);this.text(c[0].text,u,this.settings.fontSize,r,d)}async start(e=!0,r){if(this.pendingPage===void 0&&this.references.length>=this.settings.limits.maxPages)throw new S("RESOURCE_LIMIT","maxPages exceeded.");const{page:d,margins:h,options:u,fontSize:c}=this.settings,g=this.fonts.select().lineHeight(c);if(this.pendingPage!==void 0?(this.current=this.pendingPage,this.pendingPage=void 0):(this.current=this.objects.reserve(),this.references.push(this.current)),this.commands="",this.commandParts=[],this.annotations=[],this.commandBytes=0,this.bodyAdded=!1,this.sectionPages++,u.pageNumbers!==!1&&(this.totalPages??=this.objects.reserve(),this.numberSettings??=this.settings,this.pageNumberWidth||(this.pageNumberWidth=this.measurePageNumbers()),this.pageNumberWidth>d.width-h.left-h.right))throw new RangeError("Page is too narrow for page numbers at the declared maxPages and font size.");this.structure?.beginPage(this.current),this.y=d.height-h.top;const w=this.decorationText(u.pageHeader),T=this.decorationText(u.pageFooter);if(w&&h.top<g+4)throw new RangeError("Top margin is too small for a page header.");if((T||u.pageNumbers!==!1)&&h.bottom<g+4)throw new RangeError("Bottom margin is too small for page decorations.");const v=this.fonts.select(),E=((v.program?.ascent??800)+(v.program?.descent??-200))*c/2e3;this.decoration(w,h.left,d.height-h.top/2-E,d.width-h.left-h.right);const R=d.width-h.left-h.right-(u.pageNumbers!==!1?this.pageNumberWidth+this.settings.padding*2:0);if(R<=0&&T)throw new RangeError("Page is too narrow for both footer text and page numbers.");if(this.decoration(T,h.left,h.bottom/2-E,R),u.pageNumbers!==!1){const M=u.pageNumberLabels,L=M?.suffix??"",B=d.width-h.right-this.pageNumberWidth+1,Z=h.bottom/2-E,V=(M?.prefix??"Page ")+this.references.length+(M?.separator??" of "),_=p(V,v,c,this.pageNumberWidth,this.settings.limits.maxCellCharacters,1,!1)[0];this.settings.budget.cell(V+L),this.text(V,v,c,B,Z),this.add(this.artifact("q 1 0 0 1 "+P(B+_.width)+" "+P(Z)+" cm /TotalPages Do Q\n","Pagination"))}for(const M of this.pendingBookmarks.splice(0))this.outlines?.add(M,this.current,this.y);this.references.length===1&&(u.title&&await this.paragraph(u.title,{bold:!0},c*1.5,!1,1),u.messageTop&&await this.paragraph(u.messageTop,{},c,!1));const I=r??(e&&this.layout?this.activeHeadings??=await this.layout.headers():[]),z=I.reduce((M,L)=>M+L.height,0),j=e&&this.layout?this.continuationCaption:void 0;if(j?.lines.length&&(this.continuationCaptionPaints++===0&&(this.tableCaptionOwner=this.captionAnnotations(j,this.tableCaptionOwner)),await this.paragraphs([j],z+g+this.settings.padding*2,!0,{artifact:!0,...this.tableCaptionOwner===void 0?{}:{annotationParent:this.tableCaptionOwner}})),this.continuationTop=d.height-h.top-z-(j?.height??0),this.y-z-g-this.settings.padding*2<h.bottom)throw new RangeError("PDF title and repeated headings leave no room for a data line.");e&&this.layout&&this.structure&&this.tableElement===void 0&&(this.tableElement=this.structure.element("Table",this.groupParent),this.tableStructure=new y(this.structure,this.tableElement,I),await this.tableStructure.prepareHeaders()),await this.drawHeadings(I),this.dataTop=this.y}async drawHeadings(e){for(const r of e){for(const u of r.cells)!this.bandCellBudget&&this.paintedHeaderBudgetCells.has(u.source??u)&&this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters===void 0?"":u.lines.map(c=>c.text).join(""));const d=this.tableStructure?r.cells.map(u=>this.tableStructure.owner(u.source??u)):void 0,h=r.cells.map(u=>this.paintedHeaderCells.has(u.source??u));this.draw(r,0,r.lines,d,h);for(const u of r.cells)this.paintedHeaderCells.add(u.source??u),this.paintedHeaderBudgetCells.add(u.source??u)}}async rowElements(e){const r=e.source??e;return this.tableStructure?.prepareRow(r,"data",this.tableElement,this.summaryRows.has(r)?0:void 0)}draw(e,r,d,h,u=[]){if(!this.layout)throw new Error("A table layout is required before drawing rows.");this.bodyAdded=!0;const{padding:c,fontSize:g}=this.settings,w=P,T=d*e.lineHeight+c*2,v=this.layout.lefts;this.rectangleLefts!==v&&(this.rectangleLefts=v,this.rectangleColumns=[]);let E,R="",I="";for(const[z,j]of e.cells.entries()){this.bandCellBudget&&this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters===void 0?"":(j.height===void 0?j.lines.slice(r,r+d):j.lines).map(U=>U.text).join(""));const M=v[j.first],L=j.height??T;L!==E&&(R=w(this.y-L),I=w(L),E=L);let B=this.rectangleColumns[j.first];(!B||B.x!==M||B.width!==j.width)&&(B={x:M,width:j.width,left:w(M),widthText:w(j.width)},this.rectangleColumns[j.first]=B);const Z=B.left+" "+R+" "+B.widthText+" "+I;j.style.background&&this.add(this.artifact("q "+this.rgb(j.style.background)+" rg "+Z+" re f Q\n")),this.add(this.artifact("q 0.82 0.85 0.89 RG 0.4 w "+Z+" re S Q\n"));const V=h?.[z],_=j.semanticArtifact||u[z],A=j.link&&this.structure&&V!==void 0?this.structure.link(V,j.link):V;for(let U=r;U<Math.min(j.lines.length,j.height?j.lines.length:r+d);U++){const W=j.lines[U],q=j.style.alignment==="right"?j.width-c-W.width:j.style.alignment==="center"?(j.width-W.width)/2:c;this.inline(W,g,M+q,this.y-c-W.ascent-(U-r)*(e.structured?j.lineHeight:e.lineHeight),_?void 0:A,A)}j.link&&this.link(j.link,M,this.y-L,j.width,L,A)}this.y-=e.structured?e.height:T,this.sealCommands()}async block(e){if(this.bandFlow)return this.bandFlow.block(e);const r=e.reduce((h,u)=>h+u.height,0),d=this.settings.margins.bottom;if(r>this.y-d&&(await this.finishPage(),await this.start()),r>this.dataTop-d)throw new RangeError("A structured footer must fit on one page below the repeated headings.");for(const h of e){const u=await this.rowElements(h);this.draw(h,0,h.lines,u),await this.tableStructure?.completeRow(h.source??h)}}async row(e,r=!1){if(this.bandFlow)return this.bandFlow.row(e,r);const d=await this.rowElements(e),{margins:h,padding:u}=this.settings,c=this.continuationTop-h.bottom;!r&&e.height<=c+.001&&e.height>this.y-h.bottom+.001&&(await this.finishPage(),await this.start());let g=0;for(;g<e.lines;){let w=Math.min(e.lines-g,Math.floor((this.y-h.bottom-u*2+.001)/e.lineHeight));if(w<=0&&(await this.finishPage(),await this.start(),w=Math.min(e.lines-g,Math.floor((this.y-h.bottom-u*2+.001)/e.lineHeight))),w<=0)throw new RangeError("PDF page cannot fit a table line.");this.draw(e,g,w,d),g+=w,g<e.lines&&(await this.finishPage(),await this.start())}await this.tableStructure?.completeRow(e.source??e)}async keptRows(e,r=!1){if(this.bandFlow)return this.bandFlow.keptRows(e,r);const d=e.reduce((c,g)=>c+g.height,0),h=this.settings.margins.bottom,u=d<=this.continuationTop-h+.001;u&&d>this.y-h+.001&&(await this.finishPage(),await this.start());for(const[c,g]of e.entries())await this.row(g,!u&&c===0&&r)}async paragraph(e,r={},d=this.settings.fontSize,h=!0,u){await this.ensureStarted();const{margins:c,page:g,limits:w}=this.settings,T=this.fonts.select(r.bold,r.italic),v=T.lineHeight(d);this.settings.budget.cell(m(e,this.settings.budget));const E=await b(e,T,d,g.width-c.left-c.right,w.maxCellCharacters,w.maxRowLines,!0,this.settings.options.signal);if(v>g.height-c.top-c.bottom)throw new RangeError("PDF page cannot fit a paragraph line at the selected font metrics.");if(!h&&this.y-E.length*v-8<c.bottom)throw new RangeError("PDF title/message exceeds the first page's content area.");const R=this.structure?.element(u?"H"+u:"P");for(const I of E){this.y-v<c.bottom&&(await this.finishPage(),await this.start(!1));const z=r.alignment==="right"?g.width-c.right-I.width:r.alignment==="center"?c.left+(g.width-c.left-c.right-I.width)/2:c.left;this.bodyAdded=!0,this.text(I.text,T,d,z,this.y-(T.program?.ascent??800)*d/1e3,r.color,R),this.y-=v}this.y-=8,await this.structure?.complete(R)}async reserveSpace(e,r="Kept PDF content"){await this.ensureStarted();const{page:d,margins:h}=this.settings,u=d.height-h.top-h.bottom;if(e>u+.001)throw new RangeError(r+" exceeds a fresh page's content area.");e>this.y-h.bottom+.001&&await this.pageBreak()}async paragraphs(e,r=0,d=!1,h={}){const u=e.filter(g=>g.lines.length>0);if(!u.length)return;await this.ensureStarted();const c=new Array(u.length).fill(0);for(let g=u.length-1;g>=0;g--){const w=u[g],T=u[g+1];c[g]=w.keepWithNext?T?T.keepTogether||T.keepWithNext?T.height+c[g+1]:T.firstHeight:r:0}d&&u.length&&await this.reserveSpace(u.reduce((g,w)=>g+w.height,0)+c.at(-1),"Kept PDF paragraph group");for(const[g,w]of u.entries()){w.budgetOnPaint&&this.settings.budget.cell(m(w.text.text,this.settings.budget)),(w.keepTogether||w.keepWithNext)&&await this.reserveSpace(w.height+c[g],"Kept PDF paragraph chain");const{margins:T,page:v}=this.settings;if(w.firstHeight>v.height-T.top-T.bottom+.001)throw new RangeError("PDF page cannot fit a paragraph line and its leading spacing.");this.y-w.firstHeight<T.bottom&&await this.pageBreak(),this.y-=w.spaceBefore,w.bookmark&&this.addBookmark(w.bookmark);const E=h.artifact?void 0:h.owner??this.structure?.element(h.role??(w.headingLevel?"H"+w.headingLevel:"P"),h.parent??this.groupParent);let R=!0;for(const I of w.lines){if(I.lineHeight>v.height-T.top-T.bottom+.001)throw new RangeError("PDF page cannot fit a paragraph line at the selected font metrics.");this.y-I.lineHeight<T.bottom&&await this.pageBreak();const z=T.left+(h.indent??0),j=v.width-T.right-z,M=w.style.alignment==="right"?v.width-T.right-I.width:w.style.alignment==="center"?z+(j-I.width)/2:z;R&&h.marker&&this.inline(h.marker.line,w.size,z-h.marker.gap-h.marker.line.width,this.y-I.ascent,h.marker.owner),this.bodyAdded=!0,this.inline(I,w.size,M,this.y-I.ascent,E,h.annotationParent??E),this.y-=I.lineHeight,R=!1}this.y-=w.spaceAfter,h.keepOpen||await this.structure?.complete(E)}}get groupParent(){return this.groups.at(-1)?.element}async beginGroup(e,r,d){if(e!==this.groups.length)throw new Error("PDF analytical groups must open in hierarchical order.");await this.ensureStarted();const h=this.structure?.element("Sect",this.groupParent);this.groups.push({level:e,headingLevel:r.headingLevel??e+2,element:h}),await this.paragraphs([r],d,!0,{role:"H"+(r.headingLevel??e+2),...h===void 0?{}:{parent:h}})}async endGroup(e){const r=this.groups.at(-1);if(!r||r.level!==e)throw new Error("PDF analytical groups must close in hierarchical order.");await this.structure?.complete(r.element),this.outlines?.closeGroup(r.headingLevel),this.groups.pop()}summary(e){this.summaryRows.add(e)}async beginTable(e,r,d=e.lineHeight+this.settings.padding*2,h,u,c=!1,g=!1,w=!1){if(e.bands)return this.beginBands(e,r,d,h,u,g,w);await this.ensureStarted(),this.layout=e,this.paintedHeaderCells=new WeakSet,this.continuationCaption=u,this.continuationCaptionPaints=0,this.tableCaptionOwner=void 0,this.tableElement=this.structure?.element("Table",this.groupParent);const T=r??await e.headers();this.activeHeadings=T;const v=c&&this.bodyAdded&&!this.structure?[]:T,E=v.reduce((R,I)=>R+I.height,0);if(h&&!(g&&w)&&(await this.reserveSpace(h.height+E+d,"Kept PDF table caption and first data fragment"),this.tableCaptionOwner=g?this.captionAnnotations(h):h.lines.length?this.structure?.element("Caption",this.tableElement):void 0,await this.paragraphs([h],E+d,!0,g?{artifact:!0,...this.tableCaptionOwner===void 0?{}:{annotationParent:this.tableCaptionOwner}}:{role:"Caption",keepOpen:!0,...this.tableCaptionOwner===void 0?{}:{owner:this.tableCaptionOwner}})),this.structure&&(this.tableStructure=new y(this.structure,this.tableElement,T),await this.tableStructure.prepareHeaders()),this.y-E-d<this.settings.margins.bottom){await this.finishPage(),await this.start(!0,T);return}this.continuationTop=this.settings.page.height-this.settings.margins.top-T.reduce((R,I)=>R+I.height,0)-(u?.height??0),await this.drawHeadings(v),this.dataTop=this.y}async beginBands(e,r,d,h,u,c,g){await this.ensureStarted();const w=r??await e.headers(),T=await e.bandRows(w,!0),v=T[0].reduce((_,A)=>_+A.height,0),{page:E,margins:R,padding:I}=this.settings,z=E.height-R.top-R.bottom-v-(h?.height??0),j=d<=z+.001?d:e.lineHeight+I*2,M=E.height-R.top-R.bottom-v-(u?.height??0);if(M+.001<e.lineHeight+I*2)throw new RangeError("PDF band headings and continuation context leave no room for a data line.");let L=c&&g;this.y-R.bottom-v-(L?0:h?.height??0)+.001<j&&(await this.pageBreak(),L=!1);const B=this.y-R.bottom-v-(L?0:h?.height??0);if(B+.001<j)throw new RangeError("PDF band caption and headings leave no room for a data line.");let Z=0;this.tableElement=this.structure?.element("Table",this.groupParent),this.paintedHeaderCells=new WeakSet;let V=this.structure&&h?.lines.length?c?this.captionAnnotations(h):this.structure.element("Caption",this.tableElement):void 0;this.structure&&(this.tableStructure=new y(this.structure,this.tableElement,w)),this.layout=void 0,this.continuationCaption=void 0,this.activeHeadings=void 0,this.bandFlow=new C(e,T,{firstCapacity:B,firstFullCapacity:z,continuationCapacity:M,prepareRow:async _=>{await this.tableStructure?.prepareHeaders(),await this.rowElements(_)},completeRow:async _=>{await this.tableStructure?.completeRow(_.source??_)},moveFirstToFreshPage:async()=>{await this.pageBreak(),L=!1},paint:async(_,A,U,W,q,X)=>{q&&X||await this.pageBreak();const Y=e.bands[_];this.layout={lefts:Y.lefts,lineHeight:e.lineHeight,headers:async()=>A},this.bandCellBudget=!0;try{if(W?.lines.length&&!(q&&X&&L)){!q&&Z++===0&&(V=this.captionAnnotations(W,V));const F=V;await this.paragraphs([W],v+j,!0,q&&X&&!c?{role:"Caption",keepOpen:!0,...V===void 0?{}:{owner:V}}:{artifact:!0,...F===void 0?{}:{annotationParent:F}})}await this.tableStructure?.prepareHeaders(),await this.drawHeadings(A),this.dataTop=this.y;for(const F of U){O(this.settings.options.signal);const H=this.tableStructure?F.cells.map(K=>this.tableStructure.owner(K.source??K)):void 0;this.draw(F,0,F.lines,H)}}finally{this.bandCellBudget=!1}}},h,u)}async endTable(){this.bandFlow&&(await this.bandFlow.flush(!0),this.bandFlow=void 0),await this.tableStructure?.finish(),this.layout=void 0,this.tableElement=void 0,this.tableStructure=void 0,this.activeHeadings=void 0,this.continuationCaption=void 0,this.tableCaptionOwner=void 0,this.continuationCaptionPaints=0,this.y-=8}captionAnnotations(e,r){if(!this.structure||!e.text.runs.some(h=>h.link&&h.text.trim()))return r;const d=r??this.structure.element("Caption",this.tableElement);for(const h of e.text.runs)h.link&&h.text.trim()&&this.structure.link(d,h.link,h.text);return d}async pageBreak(){await this.ensureStarted(),await this.finishPage(),await this.start(!1)}registerXObject(e,r){this.externalObjects.set(e,r)}graphicHeight(e,r){const{page:d,margins:h}=this.settings;return r*Math.min(1,(d.width-h.left-h.right)/e,(d.height-h.top-h.bottom)/r)}async graphic(e,r,d,h,u,c){await this.ensureStarted();const{page:g,margins:w}=this.settings,T=g.width-w.left-w.right,v=Math.min(1,T/e,(g.height-w.top-w.bottom)/r);e*=v,r*=v;const E=this.structure&&u!==void 0?this.structure.element("Figure",void 0," /Alt <feff"+a(u)+">"):void 0;if(c){if(u===void 0)throw new TypeError("A captioned PDF graphic requires alternativeText and cannot be decorative.");await this.reserveSpace(c.height+r,"Kept PDF graphic and caption"),await this.paragraphs([c],r,!0,{role:"Caption",...E===void 0?{}:{parent:E}})}this.y-r<w.bottom&&await this.pageBreak();const R=d==="right"?g.width-w.right-e:d==="center"?w.left+(T-e)/2:w.left,I=h(R,this.y-r,e,r);this.bodyAdded=!0,this.add(this.structure&&E!==void 0?this.structure.mark(E)+I+"EMC\n":this.artifact(I)),this.y-=r+8,await this.structure?.complete(E)}async listItem(e,r){if(await this.ensureStarted(),this.structure&&r===void 0)throw new Error("A tagged list item requires a logical list owner.");const d=this.structure?.element("LI",r),h=d===void 0?void 0:this.structure.element("Lbl",d),u=d===void 0?void 0:this.structure.element("LBody",d);await this.paragraphs([e.paragraph],0,!1,{...u===void 0?{}:{parent:u},role:"P",indent:e.indent,marker:{line:e.marker,gap:e.markerGap,...h===void 0?{}:{owner:h}}}),await this.structure?.complete(d)}sealCommands(){this.commands&&(this.commandParts.push(this.commands),this.commands="")}takeCommands(){this.sealCommands();const e=this.commandParts.join("");return this.commandParts=[],e}async finishPage(){const e=this.objects.reserve(),{page:r,options:d}=this.settings;await this.objects.stream(e,this.takeCommands(),"",d.compression!==!1);const h=[];for(const u of this.annotations)h.push(u.id),await this.objects.object(u.id,u.body);await this.objects.object(this.current,"<< /Type /Page /Parent "+this.parent+" 0 R /MediaBox [0 0 "+P(r.width)+" "+P(r.height)+"] /Resources "+this.resources+" 0 R /Contents "+e+" 0 R"+(this.structure?.pageDictionary??"")+(h.length?" /Annots ["+h.map(u=>u+" 0 R").join(" ")+"]":"")+" >>"),this.structure&&await this.structure.finishPage(),this.annotations=[],this.commandBytes=0,this.current=0,await this.objects.flushBytes()}async finish(){if(this.bandFlow&&(await this.bandFlow.flush(!0),this.bandFlow=void 0),await this.ensureStarted(),await this.tableStructure?.finish(),await this.finishPage(),this.totalPages){const e=this.fonts.select(),r=String(this.references.length),d=r+(this.numberSettings.options.pageNumberLabels?.suffix??""),h=this.numberSettings.fontSize;this.settings.budget.cell(r);const u="BT /"+e.name+" "+P(h)+" Tf 1 0 0 1 0 0 Tm "+e.encode(d)+" Tj ET\n",c=p(d,e,h,this.numberSettings.page.width,this.settings.limits.maxCellCharacters,1,!1)[0].width,g=(e.program?.bbox[1]??-250)*h/1e3-1,w=(e.program?.bbox[3]??1e3)*h/1e3+1;await this.objects.stream(this.totalPages,u,"/Type /XObject /Subtype /Form /BBox [-1 "+P(g)+" "+P(c+1)+" "+P(w)+"] /Resources << /Font "+this.fonts.dictionary()+" >>",this.settings.options.compression!==!1)}}xobjects(){const e=[...this.externalObjects].map(([r,d])=>"/"+r+" "+d+" 0 R");return this.totalPages&&e.push("/TotalPages "+this.totalPages+" 0 R"),e.length?" /XObject << "+e.join(" ")+" >>":""}}return Object.freeze({PdfPages:s})})(),fr=(()=>{class S{objects;root;entries=[];levels=[];lastKey=-1;constructor(k,C){this.objects=k,this.root=C}async append(k,C){if(k<=this.lastKey)throw new Error("PDF ParentTree keys must be appended in increasing order.");this.lastKey=k,this.entries.push({key:k,value:C}),this.entries.length===64&&await this.leaf()}async leaf(){if(!this.entries.length)return;const k=this.objects.reserve(),C=this.entries[0].key,y=this.entries.at(-1).key,p="<< /Limits ["+C+" "+y+"] /Nums ["+this.entries.map(b=>b.key+" "+b.value+" 0 R").join(" ")+"] >>";this.entries.length=0,await this.objects.object(k,p),await this.node({id:k,first:C,last:y},0)}async node(k,C){const y=this.levels[C]??=[];if(y.push(k),y.length===64){const p=await this.branch(y);y.length=0,await this.node(p,C+1)}}async branch(k){const C=this.objects.reserve(),y=k[0].first,p=k.at(-1).last;return await this.objects.object(C,"<< /Limits ["+y+" "+p+"] /Kids ["+k.map(b=>b.id+" 0 R").join(" ")+"] >>"),{id:C,first:y,last:p}}async finish(){await this.leaf();for(let C=0;C<this.levels.length-1;C++){const y=this.levels[C];if(y.length){const p=await this.branch(y);y.length=0,await this.node(p,C+1)}}const k=this.levels.at(-1)??[];await this.objects.object(this.root,k.length?"<< /Kids ["+k.map(C=>C.id+" 0 R").join(" ")+"] >>":"<< /Nums [] >>")}}return Object.freeze({PdfParentTree:S})})(),zt=(()=>{const{OfficeIMOError:S}=pe,{checkAbort:O}=we,{unicodeHex:P}=Be,{PdfParentTree:k}=fr;function C(a){return typeof a=="number"?a<0?-a-1+" ":a+" 0 R ":a+" "}function y(a){return"<< /Type /StructElem /S /"+a.role+" /P "+a.parent+" 0 R"+(a.markedPage===void 0?"":" /Pg "+a.markedPage+" 0 R")+(a.identifier===void 0?"":" /ID ("+a.identifier+")")+" /K ["}function p(a,i){const l=32768-i.length-a.attributes.length-4;if(l<0)return;let o="";for(const s of a.children){const t=C(s);if(o.length+t.length>l)return;o+=t}return i+o+"]"+a.attributes+" >>"}class b{objects;root;entries=[];levels=[];lastKey="";constructor(i,l){this.objects=i,this.root=l}async append(i,l){if(i<=this.lastKey)throw new Error("PDF structure IDs must be appended in increasing order.");this.lastKey=i,this.entries.push({key:i,value:l}),this.entries.length===64&&await this.leaf()}async leaf(){if(!this.entries.length)return;const i=this.objects.reserve(),l=this.entries[0].key,o=this.entries.at(-1).key,s="<< /Limits [("+l+") ("+o+")] /Names ["+this.entries.map(t=>"("+t.key+") "+t.value+" 0 R").join(" ")+"] >>";this.entries.length=0,await this.objects.object(i,s),await this.node({id:i,first:l,last:o},0)}async node(i,l){const o=this.levels[l]??=[];if(o.push(i),o.length===64){const s=await this.branch(o);o.length=0,await this.node(s,l+1)}}async branch(i){const l=this.objects.reserve(),o=i[0].first,s=i.at(-1).last;return await this.objects.object(l,"<< /Limits [("+o+") ("+s+")] /Kids ["+i.map(t=>t.id+" 0 R").join(" ")+"] >>"),{id:l,first:o,last:s}}async finish(){await this.leaf();for(let l=0;l<this.levels.length-1;l++){const o=this.levels[l];if(o.length){const s=await this.branch(o);o.length=0,await this.node(s,l+1)}}const i=this.levels.at(-1)??[];await this.objects.object(this.root,i.length?"<< /Kids ["+i.map(l=>l.id+" 0 R").join(" ")+"] >>":"<< /Names [] >>")}}class x{objects;settings;root;document;parentTree;elements=new Map;parentTreeWriter;annotations=[];links=new WeakMap;identifiers;pageParents=[];pageId=0;pageKey=0;nextParentKey=0;references=0;allocated=0;section;constructor(i,l){this.objects=i,this.settings=l,this.root=i.reserve(),this.parentTree=i.reserve(),this.parentTreeWriter=new k(i,this.parentTree),this.document=this.element("Document",this.root)}element(i,l=this.section??this.document,o=""){if(O(this.settings.options.signal),++this.allocated>this.settings.limits.maxStructureElements)throw new S("RESOURCE_LIMIT","maxStructureElements exceeded.");const s=this.objects.reserve(),t={id:s,parent:l,role:i,children:[],attributes:o};this.elements.set(s,t);const n=this.elements.get(l);return i==="Caption"&&n?.role==="Table"?n.children.unshift(s):n?.children.push(s),s}setAttributes(i,l){const o=this.elements.get(i);if(!o)throw new Error("PDF structure attributes require an open logical owner.");o.attributes=l}async attributeReference(i){O(this.settings.options.signal);const l=this.objects.reserve();return await this.objects.object(l,i)," /A "+l+" 0 R"}async beginSection(){await this.complete(this.section),this.section=this.element("Sect",this.document)}async identifier(i){O(this.settings.options.signal);const l=this.elements.get(i);if(!l)throw new Error("PDF structure IDs require an open logical owner.");if(l.identifier!==void 0)return l.identifier;const o="e"+String(i).padStart(16,"0");return this.identifiers??=new b(this.objects,this.objects.reserve()),await this.identifiers.append(o,i),l.identifier=o,o}beginPage(i){this.pageId=i,this.pageParents=[],this.pageKey=this.nextParentKey++}link(i,l,o){let s=this.links.get(l);s||(s=new Map,this.links.set(l,s));const t=s.get(i);if(t!==void 0)return t;const n=this.element("Link",i,o===void 0?"":" /Alt <feff"+P(o)+">");s.set(i,n);const e=this.elements.get(i);return(e.linkIdentities??=[]).push(l),n}annotation(i,l){O(this.settings.options.signal);const o=this.elements.get(i);if(!o||o.role!=="Link")throw new Error("Tagged link annotations require a logical Link owner.");const s=this.nextParentKey++;return o.children.push("<< /Type /OBJR /Obj "+l+" 0 R /Pg "+this.pageId+" 0 R >>"),this.annotations.push({key:s,owner:i}),s}mark(i,l){if(++this.references>this.settings.limits.maxMarkedContentReferences)throw new S("RESOURCE_LIMIT","maxMarkedContentReferences exceeded.");const o=this.elements.get(i);if(!o)throw new Error("Marked content requires an open logical owner.");const s=this.pageParents.length;return this.pageParents.push(i),o.markedPage??=this.pageId,o.children.push(o.markedPage===this.pageId?-(s+1):"<< /Type /MCR /Pg "+this.pageId+" 0 R /MCID "+s+" >>"),"/"+o.role+" << /MCID "+s+(l===void 0?"":" /ActualText <FEFF"+P(l)+">")+" >> BDC\n"}get pageDictionary(){return" /StructParents "+this.pageKey+" /Tabs /S"}get catalogDictionary(){return" /MarkInfo << /Marked true >> /Lang <feff"+P(this.settings.options.tagged.language)+"> /StructTreeRoot "+this.root+" 0 R"}async finishPage(){const i=this.objects.reserve();await this.objects.object(i,"["+this.pageParents.map(l=>l+" 0 R").join(" ")+"]"),await this.parentTreeWriter.append(this.pageKey,i);for(const l of this.annotations)await this.parentTreeWriter.append(l.key,l.owner);this.annotations.length=0,this.pageParents=[]}async complete(i){if(i===void 0)return;const l=this.elements.get(i);if(!l)return;for(const t of l.children)typeof t=="number"&&t>0&&!this.completeBuffered(t)&&await this.complete(t);O(this.settings.options.signal);const o=y(l),s=p(l,o);s!==void 0?this.objects.tryCompactObject(i,s)||await this.objects.compactObject(i,s):await this.objects.object(i,this.body(l,o)),this.releaseElement(l)}completeBuffered(i){const l=this.elements.get(i);if(!l)return!0;for(const s of l.children)if(typeof s=="number"&&s>0&&!this.completeBuffered(s))return!1;O(this.settings.options.signal);const o=p(l,y(l));return o===void 0||!this.objects.tryCompactObject(i,o)?!1:(this.releaseElement(l),!0)}releaseElement(i){if(i.linkIdentities)for(const l of i.linkIdentities){const o=this.links.get(l);o?.delete(i.id),o?.size||this.links.delete(l)}this.elements.delete(i.id)}*body(i,l){yield l;for(const o of i.children)yield C(o);yield"]"+i.attributes+" >>"}async completeRow(i){i?.length&&await this.complete(this.elements.get(i[0])?.parent)}async finish(){await this.complete(this.document),await this.parentTreeWriter.finish(),await this.identifiers?.finish(),await this.objects.object(this.root,"<< /Type /StructTreeRoot /K ["+this.document+" 0 R] /ParentTree "+this.parentTree+" 0 R /ParentTreeNextKey "+this.nextParentKey+(this.identifiers?" /IDTree "+this.identifiers.root+" 0 R":"")+" >>")}}function m(a,i){const l=a.decorative,o=a.alternativeText;if(l!==void 0&&typeof l!="boolean")throw new TypeError("Graphic decorative must be boolean.");if(o!==void 0){if(typeof o!="string"||!o.trim())throw new TypeError("Graphic alternativeText must be nonempty text.");if(o.length>i.limits.maxCellCharacters)throw new S("RESOURCE_LIMIT","maxCellCharacters exceeded by graphic alternativeText.");if(P(o),l)throw new TypeError("A decorative graphic cannot also have alternativeText.")}if(i.options.tagged&&o===void 0&&l!==!0)throw new TypeError("Tagged PDF graphics require alternativeText or decorative:true.");return i.options.tagged&&o!==void 0&&i.budget.cell(o),o}return Object.freeze({PdfStructure:x,graphicAlternative:m})})(),ur=(()=>{const{OfficeIMOError:S}=pe,{checkAbort:O}=we,{pdfNumber:P,unicodeHex:k}=Be;class C{objects;settings;root;items=[];top=[];stack=[];constructor(b,x){this.objects=b,this.settings=x}add(b,x,m){if(O(this.settings.options.signal),this.items.length>=this.settings.limits.maxBookmarks)throw new S("RESOURCE_LIMIT","maxBookmarks exceeded.");this.root??=this.objects.reserve();const f=b.level??1;for(;this.stack.length&&this.stack.at(-1).level>=f;)this.stack.pop();const a=this.stack.at(-1),i=a?.children??this.top,l=i.at(-1),o={id:this.objects.reserve(),title:b.title,page:x,y:m,level:f,parent:a?.id??this.root,children:[],previous:l?.id,next:void 0};l&&(l.next=o.id),i.push(o),this.items.push(o),this.stack.push(o)}get count(){return this.items.length}closeGroup(b){for(;this.stack.length&&this.stack.at(-1).level>=b;)this.stack.pop()}get catalogDictionary(){return this.root===void 0?"":" /Outlines "+this.root+" 0 R"}async finish(){if(this.root===void 0)return;const b=new Map;for(const x of[...this.items].reverse())b.set(x.id,x.children.reduce((m,f)=>m+1+b.get(f.id),0));for(const x of this.items)O(this.settings.options.signal),await this.objects.object(x.id,"<< /Title <feff"+k(x.title)+"> /Parent "+x.parent+" 0 R"+(x.previous===void 0?"":" /Prev "+x.previous+" 0 R")+(x.next===void 0?"":" /Next "+x.next+" 0 R")+(x.children.length?" /First "+x.children[0].id+" 0 R /Last "+x.children.at(-1).id+" 0 R /Count "+b.get(x.id):"")+" /Dest ["+x.page+" 0 R /XYZ null "+P(x.y)+" null] >>");await this.objects.object(this.root,"<< /Type /Outlines /First "+this.top[0].id+" 0 R /Last "+this.top.at(-1).id+" 0 R /Count "+this.items.length+" >>")}}return Object.freeze({PdfOutlines:C})})(),_t=(()=>{const{PdfObjects:S,unicodeHex:O}=Be,{PdfFontResources:P}=sr,{PdfTableLayout:k}=bt,{PdfPages:C}=dr,{PdfStructure:y}=zt,{PdfOutlines:p}=ur;class b{settings;objects;fonts;pages;layout;structure;outlines;root;parent;resources;info;constructor(f,a,i=!1){this.settings=a,this.objects=new S(f,a.options.signal,a.budget.limits.maxOutputBytes,a.options.compression!==!1),this.root=this.objects.reserve(),this.parent=this.objects.reserve(),this.resources=this.objects.reserve(),this.info=this.objects.reserve(),this.structure=a.options.tagged?new y(this.objects,a):void 0,this.outlines=new p(this.objects,a),this.fonts=new P(this.objects,a.options.fonts,a.limits.maxFontBytes,a.options.signal),this.layout=i?new k(a,this.fonts):void 0,this.pages=new C(this.objects,a,this.fonts,this.parent,this.resources,this.layout,this.structure,this.outlines)}async start(){await this.objects.text("%PDF-1.7\n"),await this.objects.raw(Uint8Array.of(37,226,227,207,211,10)),this.layout?.bands?await this.pages.beginTable(this.layout):this.layout&&await this.pages.start(!0)}async finish(){const{options:f}=this.settings,{objects:a,fonts:i,pages:l}=this;await l.finish();for(const o of i.resources)await o.write(a,f.compression!==!1);await a.object(this.resources,"<< /Font "+i.dictionary()+l.xobjects()+" >>"),await a.object(this.parent,"<< /Type /Pages /Count "+l.references.length+" /Kids ["+l.references.map(o=>o+" 0 R").join(" ")+"] >>"),this.structure&&await this.structure.finish(),await this.outlines.finish(),await a.object(this.root,"<< /Type /Catalog /Pages "+this.parent+" 0 R"+(this.structure?.catalogDictionary??"")+this.outlines.catalogDictionary+" >>"),await a.object(this.info,"<< /Producer (OfficeIMO.js)"+(f.title===void 0?"":" /Title <feff"+O(f.title)+">")+" >>"),await a.finish(this.root,this.info)}}return Object.freeze({PdfWriteSession:b})})(),Bt=(()=>{const{BlobByteSink:S,withDestination:O}=Ie,{beginTask:P,checkAbort:k,consumeRows:C,pause:y,taskYieldDue:p}=we,{notifyProgress:b}=Ge,{createRowProjector:x}=Ne,{settings:m}=Fe,{PdfWriteSession:f}=_t;async function a(o,s){const t=new S;try{return await i(o,t,s),t.toBlob("application/pdf")}catch(n){throw t.discard(),n}}async function i(o,s,t){const n=m(t),{options:e,budget:r}=n;return P(),k(e.signal),O(s,async d=>{const h=new f(d,n,!0),{objects:u,pages:c}=h,g=h.layout,w=x(e.columns,void 0,e.signal);let T=0;await h.start();const v=()=>{if(T++,T%256===0&&(b(e.onProgress,{phase:"rows",rows:T,bytes:u.bytes}),p()))return y().then(()=>{k(e.signal)});k(e.signal)};await C(o,e.signal,async R=>{r.row(T+1);const I=w(R,T);return c.row(await g.data(I,T)).then(v)});const E=await g.footer(T);return E&&(e.footer?.rows?await c.block(E):await c.row(E[0])),g.bands&&await c.endTable(),e.messageBottom&&await c.paragraph(e.messageBottom),await h.finish(),b(e.onProgress,{phase:"complete",rows:T,bytes:u.bytes}),k(e.signal),{rows:T,columns:e.columns.length,bytes:u.bytes}})}return Object.freeze({writePdf:a,writePdfTo:i})})(),pr=(()=>{const{NotSupportedError:S,OfficeIMOError:O}=pe,{checkAbort:P,pause:k,taskYieldDue:C,withAbort:y}=we,{Crc32:p}=ut,b=[137,80,78,71,13,10,26,10],x=new Set(["PLTE","tRNS","iCCP","sRGB","gAMA","cHRM","cICP","mDCV","cLLI","sBIT","eXIf","acTL","fcTL","fdAT"]);async function m(t,n,e,r){P(e);const d=l(t,n),h=d.width*d.height,u=t.length+h*d.components+(d.components===4?d.width*8:0);if(r!==void 0&&u>r)throw new O("RESOURCE_LIMIT","maxImageWorkingBytes exceeded by PNG source, image planes and scanlines.");const c=new Uint8Array(t),g=await i(c,d,e);P(e);let w;try{if(typeof DecompressionStream!="function")throw new TypeError("Missing DecompressionStream");w=new DecompressionStream("deflate")}catch(q){throw new O("PLATFORM_UNAVAILABLE",'PNG intake requires native DecompressionStream("deflate").',{cause:q})}const{width:T,height:v,components:E}=g,R=T*E,I=(R+1)*v;if(!Number.isSafeInteger(I)||I>2147483647)throw new O("RESOURCE_LIMIT","PNG filtered data exceeds the supported decoded byte length.");const z=new Uint8Array(T*v*3),j=E===4?new Uint8Array(h):void 0;let M=E===4?new Uint8Array(R):void 0,L=E===4?new Uint8Array(R):void 0;const B=f(c,g,e).pipeThrough(w).getReader();let Z=0,V=0,_=0,A=0,U=0,W=0;try{for(;;){const q=await y(B.read(),e).catch(X=>{throw P(e),new TypeError("Invalid PNG zlib image data.",{cause:X})});if(P(e),q.done)break;if(q.value.length>I-Z)throw new TypeError("PNG inflated bytes exceed the exact IHDR scanline length.");for(let X=0;X<q.value.length;X++){const Y=q.value[X];if(U===0){if(W=Y,W>4)throw new TypeError("Invalid PNG scanline filter.")}else{const F=U-1;let H=Y;if(W!==0){const K=U>E?L?L[F-E]:z[V-E]:0,re=M?M[F]:V>=R?z[V-R]:0,ne=U>E?M?M[F-E]:V>=R?z[V-R-E]:0:0;H=Y+(W===1?K:W===2?re:W===3?Math.floor((K+re)/2):o(K,re,ne))&255}L?L[F]=H:z[V]=H,V++}if(U===R){if(U=0,L&&j){for(let H=0;H<R;H+=4)z[_++]=L[H],z[_++]=L[H+1],z[_++]=L[H+2],j[A++]=L[H+3],(H&16383)===16380&&(C()&&await k(),P(e));const F=L;L=M,M=F}}else U++;(X&16383)===16383&&(C()&&await k(),P(e))}Z+=q.value.length,C()&&await k(),P(e)}if(Z!==I)throw new TypeError("PNG inflated bytes must match the exact IHDR scanline length.");return await a(c,g,I,e),{width:T,height:v,components:3,data:z,...j?{alpha:j}:{}}}catch(q){throw B.cancel(q).catch(()=>{}),q}finally{B.releaseLock()}}function f(t,n,e,r=!1){const d=new DataView(t.buffer,t.byteOffset,t.byteLength);let h=n.firstData,u=h+8,c=u+d.getUint32(h);return new ReadableStream({pull(g){for(P(e);u===c;){if(h=c+4,h===n.dataEnd){g.close();return}u=h+8,c=u+d.getUint32(h)}if(r&&u===n.lastDataByte){g.enqueue(Uint8Array.of(t[u++]^1));return}const w=Math.min(c,u+4096,r&&u<n.lastDataByte?n.lastDataByte:c);g.enqueue(t.subarray(u,w)),u=w}},{highWaterMark:0})}async function a(t,n,e,r){const d=f(t,n,r,!0).pipeThrough(new DecompressionStream("deflate")).getReader();let h=!1,u=0;try{for(;;){let c;try{c=await y(d.read(),r)}catch{P(r),h=!0;break}if(P(r),c.done)break;if(u+=c.value.length,u>e)throw new TypeError("Invalid PNG zlib image data.");C()&&await k(),P(r)}if(!h)throw new TypeError("Invalid PNG zlib image data: trailing bytes after the checksum.")}finally{d.cancel().catch(()=>{}),d.releaseLock()}}async function i(t,n,e){const r=new DataView(t.buffer,t.byteOffset,t.byteLength);let d=0,h=0,u=-1,c=!1;for(let g=8;g<t.length;){if(P(e),g+12>t.length)throw new TypeError("Truncated PNG chunk.");const w=r.getUint32(g),T=g+12+w;if(w>2147483647||T>t.length)throw new TypeError("Truncated or oversized PNG chunk.");const v=String.fromCharCode(...t.subarray(g+4,g+8));if(!/^[A-Za-z]{2}[A-Z][A-Za-z]$/.test(v))throw new TypeError("Invalid PNG chunk type.");const E=new p;for(let R=g+4;R<T-4;R+=65536)E.update(t.subarray(R,Math.min(T-4,R+65536))),C()&&await k(),P(e);if(E.value!==r.getUint32(T-4))throw new TypeError("PNG chunk CRC mismatch: "+v+".");if(g===8&&v!=="IHDR")throw new TypeError("PNG IHDR must be the first chunk.");if(v==="IHDR"){if(g!==8||w!==13)throw new TypeError("PNG requires one 13-byte IHDR first.")}else if(v==="IDAT"){if(c)throw new TypeError("PNG IDAT chunks must be consecutive.");d||=g,h=T,w&&(u=T-5)}else{if(d&&(c=!0),v==="IEND"){if(w!==0||!d||T!==t.length)throw new TypeError("PNG requires a final empty IEND after IDAT.");return{...n,firstData:d,dataEnd:h,lastDataByte:u}}if(x.has(v))throw new S("PNG chunk "+v+"; normalize color, orientation, transparency or animation first");if((t[g+4]&32)===0)throw new S("Required PNG chunk "+v)}g=T}throw new TypeError("PNG requires a complete final IEND chunk.")}function l(t,n){if(t.length<33||b.some((u,c)=>t[c]!==u))throw new TypeError("Invalid PNG signature or truncated IHDR.");const e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(e.getUint32(8)!==13||String.fromCharCode(...t.subarray(12,16))!=="IHDR")throw new TypeError("PNG requires one 13-byte IHDR first.");const r=e.getUint32(16),d=e.getUint32(20);if(!r||!d||r>2147483647||d>2147483647)throw new TypeError("Invalid PNG dimensions.");if(!Number.isSafeInteger(r*d)||r*d>n)throw new O("RESOURCE_LIMIT","PNG dimensions exceed maxImagePixels.");if(t[24]!==8||![2,6].includes(t[25]))throw new S("PNG intake requires 8-bit RGB or RGBA pixels");if(t[26]!==0||t[27]!==0)throw new S("PNG compression or filter method");if(t[28]!==0)throw new S("Interlaced PNG intake");const h=t[25]===6?4:3;if(!Number.isSafeInteger((r*h+1)*d)||(r*h+1)*d>2147483647)throw new O("RESOURCE_LIMIT","PNG filtered data exceeds the supported decoded byte length.");return{width:r,height:d,components:h}}function o(t,n,e){const r=t+n-e,d=Math.abs(r-t),h=Math.abs(r-n),u=Math.abs(r-e);return d<=h&&d<=u?t:h<=u?n:e}return Object.freeze({pngPixels:m})})(),mr=(()=>{const{NotSupportedError:S,OfficeIMOError:O}=pe,{checkAbort:P,pause:k,taskYieldDue:C}=we,{pngPixels:y}=pr;class p{objects;settings;images=new Map;bytes=0;constructor(f,a){this.objects=f,this.settings=a}async prepare(f){const a=this.images.get(f);if(a)return a;const{limits:i,options:l}=this.settings;if(!f||typeof f!="object")throw new TypeError("PDF images require a byte array.");const o=f.data,s=f.format;if(!(o instanceof Uint8Array))throw new TypeError("PDF images require a byte array.");const t=o.length;if(this.bytes+t>i.maxImageBytes)throw new O("RESOURCE_LIMIT","maxImageBytes exceeded.");let n,e,r,d,h;const u=i.maxImageWorkingBytes;if(s==="png")({width:n,height:e,components:r,data:d,alpha:h}=await y(o,i.maxImagePixels,l.signal,u));else if(s==="jpeg")({width:n,height:e,components:r}=b(o));else if(s==="rgb"||s==="rgba")({width:n,height:e}=f),r=s==="rgba"?4:3;else throw new S("PDF images support unprofiled PNG/JPEG or decoded RGB/RGBA pixels.");if(!Number.isSafeInteger(n)||!Number.isSafeInteger(e)||n<1||e<1||!Number.isSafeInteger(n*e)||n*e>i.maxImagePixels)throw new O("RESOURCE_LIMIT","Image dimensions must be positive integers within maxImagePixels.");if((s==="rgb"||s==="rgba")&&t!==n*e*r)throw new RangeError("Raw image bytes must match width × height × channels exactly.");if(s!=="png"&&u!==void 0&&t+(r===4?n*e:0)>u)throw new O("RESOURCE_LIMIT","maxImageWorkingBytes exceeded by image snapshot and alpha plane.");P(l.signal);const c=this.objects.reserve(),g="Image"+(this.images.size+1);this.bytes+=t;const w=d??new Uint8Array(o);let T=w,v=h,E;if(r===4){T=w.subarray(0,n*e*3),v=new Uint8Array(n*e);for(let z=0;z<v.length;z++)T[z*3]=w[z*4],T[z*3+1]=w[z*4+1],T[z*3+2]=w[z*4+2],v[z]=w[z*4+3],(z&16383)===16383&&(C()&&await k(),P(l.signal))}v&&(E=this.objects.reserve(),await this.objects.stream(E,v,"/Type /XObject /Subtype /Image /Width "+n+" /Height "+e+" /ColorSpace /DeviceGray /BitsPerComponent 8",l.compression!==!1,!0));const R="/Type /XObject /Subtype /Image /Width "+n+" /Height "+e+" /ColorSpace /"+(r===1?"DeviceGray":"DeviceRGB")+" /BitsPerComponent 8"+(E?" /SMask "+E+" 0 R":"")+(s==="jpeg"?" /Filter /DCTDecode":"");await this.objects.stream(c,T,R,s==="jpeg"?!1:l.compression!==!1,!0);const I={name:g,id:c,width:n,height:e};return this.images.set(f,I),I}}function b(m){if(m.length<4||m[0]!==255||m[1]!==216||m[m.length-2]!==255||m[m.length-1]!==217)throw new TypeError("JPEG images need complete SOI/EOI markers.");let f;for(let a=2;a<m.length;){if(m[a++]!==255)throw new TypeError("Invalid JPEG marker.");for(;m[a]===255;)a++;const i=m[a++];if(i===218){if(!f)throw new TypeError("JPEG scan precedes its frame header.");return f}if(i===217)break;if(a+2>m.length)throw new TypeError("Truncated JPEG segment.");const l=m[a]*256+m[a+1],o=a+l;if(l<2||o>m.length)throw new TypeError("Truncated JPEG segment.");if(i===226&&l>=14&&String.fromCharCode(...m.subarray(a+2,a+14))==="ICC_PROFILE\0")throw new S("Normalize ICC-profiled JPEG colors before PDF embedding.");if(i===225&&l>=8&&String.fromCharCode(...m.subarray(a+2,a+8))==="Exif\0\0")throw new S("Normalize JPEG EXIF orientation before PDF embedding.");if(i>=192&&i<=207&&![196,200,204].includes(i)){if(![192,193,194].includes(i)||l<8||m[a+2]!==8)throw new S("PDF JPEG images require 8-bit baseline, sequential or progressive frames.");const s=m[a+7];if(![1,3].includes(s)||l!==8+s*3)throw new S("PDF JPEG images require grayscale or RGB components; CMYK is unsupported.");if(s===3){const t=[m[a+8],m[a+11],m[a+14]].join(",");if(t!=="1,2,3"&&t!=="82,71,66")throw new S("Unsupported JPEG component color layout.")}if(f)throw new S("Multiple JPEG frame headers are unsupported.");f={width:m[a+5]*256+m[a+6],height:m[a+3]*256+m[a+4],components:s}}a=o}throw new TypeError("JPEG image has no complete frame and scan.")}return Object.freeze({PdfDocumentImages:p})})(),gr=(()=>{const{OfficeIMOError:S}=pe,{checkAbort:O,pause:P,taskYieldDue:k}=we,{color:C,positive:y}=Fe,{pdfNumber:p}=Be;async function b(m,f,a){const i=y(m.width,"Vector width"),l=y(m.height,"Vector height"),o=m.commands;if(!Array.isArray(o))throw new TypeError("Vector commands must be an array.");if(a+o.length>f.limits.maxVectorCommands)throw new S("RESOURCE_LIMIT","maxVectorCommands exceeded.");const s=o.map(T=>{if(!T||typeof T!="object")throw new TypeError("Invalid vector command.");const v=T.op;if(v==="move"||v==="line")return{op:v,x:T.x,y:T.y};if(v==="cubic")return{op:v,x1:T.x1,y1:T.y1,x2:T.x2,y2:T.y2,x:T.x,y:T.y};if(v==="close")return{op:v};throw new TypeError("Unsupported vector command.")}),t=m.fill,n=m.stroke,e=t===void 0?void 0:C(t),r=n===void 0?void 0:C(n);if(e===void 0&&r===void 0)throw new TypeError("A vector path requires fill or stroke.");const d=y(m.strokeWidth??1,"Vector stroke width",144),h=m.fillRule;if(h!==void 0&&!["nonzero","evenodd"].includes(h))throw new TypeError("Invalid vector fill rule.");const u=[];let c=0,g=!1;const w=(T,v)=>{if(!Number.isFinite(T)||T<0||T>v)throw new RangeError("Vector coordinates must stay inside their declared bounds.");return p(T)};for(let T=0;T<s.length;T++){const v=s[T];let E;if(!v||typeof v!="object")throw new TypeError("Invalid vector command.");if(v.op==="move"||v.op==="line"){if(v.op==="line"&&!g)throw new TypeError("A vector subpath must begin with move.");E=w(v.x,i)+" "+w(v.y,l)+(v.op==="move"?" m\n":" l\n"),g=!0}else if(v.op==="cubic"){if(!g)throw new TypeError("A vector subpath must begin with move.");E=[w(v.x1,i),w(v.y1,l),w(v.x2,i),w(v.y2,l),w(v.x,i),w(v.y,l)].join(" ")+" c\n"}else if(v.op==="close"){if(!g)throw new TypeError("Cannot close an empty vector path.");E="h\n"}else throw new TypeError("Unsupported vector command.");if(c+=E.length,c>f.limits.maxPageBytes-256)throw new S("RESOURCE_LIMIT","maxPageBytes exceeded by vector commands.");u.push(E),(T&1023)===1023&&(k()&&await P(),O(f.options.signal))}if(!g)throw new TypeError("A vector path needs at least one command.");return{width:i,height:l,count:s.length,content:(e===void 0?"":e+" rg\n")+(r===void 0?"":r+" RG\n"+p(d)+" w\n")+u.join("")+(e!==void 0&&r!==void 0?"B":e!==void 0?"f":"S")+(e!==void 0&&h==="evenodd"?"*":"")+"\n"}}return Object.freeze({vectorCommands:b})})(),wr=(()=>{const{NotSupportedError:S,OfficeIMOError:O}=pe,{checkAbort:P,pause:k,taskYieldDue:C}=we,{color:y,positive:p}=Fe,{pdfNumber:b}=Be;function x(t,n,e){if(!t||typeof t!="object"||Array.isArray(t)||Reflect.ownKeys(t).some(r=>typeof r!="string"||!n.includes(r)))throw new TypeError("Unsupported "+e+" properties.");return t}function m(t){x(t,["kind","drawing","alignment","alternativeText","decorative","caption"],"drawing block")}function f(t){if(typeof t!="number"||!Number.isFinite(t)||Math.abs(t)>1e6)throw new RangeError("Drawing coordinates must be finite and within -1,000,000 through 1,000,000 points.");return t}function a(t){const n=x(t,["x","y","width","height"],"drawing clip");return{x:f(n.x),y:f(n.y),width:p(n.width,"Drawing clip width",1e6),height:p(n.height,"Drawing clip height",1e6)}}async function i(t){C()&&await k(),P(t.options.signal)}function l(t,n,e){P(n.options.signal);const r=x(t,["version","width","height","elements"],"drawing");if(r.version!==1)throw new S("Only portable drawing version 1 is supported.");const d=p(r.width,"Drawing width"),h=p(r.height,"Drawing height");let u=e.commands,c=e.elements;const g=new Set;function w(R){x(R,["kind","commands","fill","stroke","strokeWidth","fillRule","lineCap","lineJoin"],"drawing path");const I=R.commands;if(!Array.isArray(I))throw new TypeError("Drawing path commands must be an array.");if(u+I.length>n.limits.maxVectorCommands)throw new O("RESOURCE_LIMIT","maxVectorCommands exceeded.");P(n.options.signal);const z=I.slice(),j=[];let M=!1;u+=z.length;const L=R.fill,B=R.stroke,Z=L===void 0?void 0:y(L),V=B===void 0?void 0:y(B);if(Z===void 0&&V===void 0)throw new TypeError("A drawing path requires fill or stroke.");const _=p(R.strokeWidth??1,"Drawing stroke width"),A=R.fillRule,U=R.lineCap,W=R.lineJoin;if(A!==void 0&&!["nonzero","evenodd"].includes(A))throw new TypeError("Invalid drawing fillRule.");if(U!==void 0&&!["butt","round","square"].includes(U))throw new TypeError("Invalid drawing lineCap.");if(W!==void 0&&!["miter","round","bevel"].includes(W))throw new TypeError("Invalid drawing lineJoin.");for(let q=0;q<z.length;q++){const X=z[q];if(!X||typeof X!="object")throw new TypeError("Invalid drawing path command.");const Y=X.op;if(Y==="move"||Y==="line"){if(x(X,["op","x","y"],"drawing path command"),Y==="line"&&!M)throw new TypeError("A drawing subpath must begin with move.");j.push({op:Y,x:f(X.x),y:f(X.y)}),M=!0}else if(Y==="cubic"){if(x(X,["op","x1","y1","x2","y2","x","y"],"drawing path command"),!M)throw new TypeError("A drawing subpath must begin with move.");j.push({op:"cubic",x1:f(X.x1),y1:f(X.y1),x2:f(X.x2),y2:f(X.y2),x:f(X.x),y:f(X.y)})}else if(Y==="close"){if(x(X,["op"],"drawing path command"),!M)throw new TypeError("Cannot close an empty drawing path.");j.push({op:"close"})}else throw new TypeError("Unsupported drawing path command.");(q&1023)===1023&&P(n.options.signal)}if(!M)throw new TypeError("A drawing path needs at least one command.");return{kind:"path",commands:j,style:(Z===void 0?"":Z+" rg\n")+(V===void 0?"":V+" RG\n"+b(_)+" w\n")+String(["butt","round","square"].indexOf(U??"butt"))+" J\n"+String(["miter","round","bevel"].indexOf(W??"miter"))+" j\n10 M\n",paint:(Z!==void 0&&V!==void 0?"B":Z!==void 0?"f":"S")+(Z!==void 0&&A==="evenodd"?"*":"")+"\n"}}function T(R){x(R,["kind","text","x","y","font","fontSize","color"],"drawing text");const I=R.text,z=R.font;if(typeof I!="string")throw new TypeError("Drawing text must be a string.");if(I.length>n.limits.maxCellCharacters)throw new O("RESOURCE_LIMIT","maxCellCharacters exceeded.");if(/[\r\n\u2028\u2029]/.test(I))throw new S("Drawing text must be a single baseline without line breaks.");if(!["regular","bold","italic","boldItalic"].includes(z))throw new TypeError("Invalid drawing font slot.");const j=f(R.x),M=f(R.y),L=p(R.fontSize,"Drawing font size"),B=y(R.color);return n.budget.cell(I),{kind:"text",text:I,x:j,y:M,size:L,color:B,font:z}}function v(R,I){if(!Array.isArray(R))throw new TypeError("Drawing elements must be an array.");if(I>32&&R.length)throw new RangeError("Drawing groups support at most 32 element levels.");if(c+R.length>n.limits.maxDrawingElements)throw new O("RESOURCE_LIMIT","maxDrawingElements exceeded.");P(n.options.signal);const z=R.slice(),j=[];for(let M=0;M<z.length;M++){if(++c>n.limits.maxDrawingElements)throw new O("RESOURCE_LIMIT","maxDrawingElements exceeded.");const L=z[M];if(!L||typeof L!="object")throw new TypeError("Invalid drawing element.");if(g.has(L))throw new TypeError("Drawing groups cannot contain cycles.");const B=L.kind;if(B==="path")j.push(w(L));else if(B==="text")j.push(T(L));else if(B==="group"){x(L,["kind","clip","elements"],"drawing group");const Z=L.clip,V=Z===void 0?void 0:a(Z);g.add(L),j.push({kind:"group",...V?{clip:V}:{},children:v(L.elements,I+1)}),g.delete(L)}else throw new TypeError("Unsupported drawing element kind.");(M&255)===255&&P(n.options.signal)}return j}const E=v(r.elements,1);return P(n.options.signal),{width:d,height:h,plan:E,commands:u-e.commands,elements:c-e.elements}}async function o(t,n,e,r){const d=l(t,n,r),h=new Map;function u(M){const L=h.get(M);if(L)return L;const B=e.select(M==="bold"||M==="boldItalic",M==="italic"||M==="boldItalic");if(!B.program||B.syntheticBold||B.syntheticItalic)throw new S("Drawing text without an exact embedded font face at fonts."+M);return h.set(M,B),B}let c=0,g=0;async function w(M){for(let L=0;L<M.length;L++){const B=M[L];if(B.kind==="group")await w(B.children);else if(B.kind==="text"){const Z=u(B.font);for(const V of B.text)Z.width(V.codePointAt(0)),(++c&1023)===0&&await i(n)}(++g&255)===0&&await i(n)}}await w(d.plan);const T=[];let v=0;function E(M){if(v+=M.length,v>n.limits.maxPageBytes-256)throw new O("RESOURCE_LIMIT","maxPageBytes exceeded by drawing content.");T.push(M)}let R=0,I=0,z=0;async function j(M){for(let L=0;L<M.length;L++){const B=M[L];if(E("q\n"),B.kind==="group")B.clip&&E([B.clip.x,B.clip.y,B.clip.width,B.clip.height].map(b).join(" ")+" re W n\n"),await j(B.children);else if(B.kind==="path"){E(B.style);for(let Z=0;Z<B.commands.length;Z++){const V=B.commands[Z];E(V.op==="move"||V.op==="line"?b(V.x)+" "+b(V.y)+(V.op==="move"?" m\n":" l\n"):V.op==="cubic"?[V.x1,V.y1,V.x2,V.y2,V.x,V.y].map(b).join(" ")+" c\n":"h\n"),(++I&1023)===0&&await i(n)}E(B.paint)}else{const Z=u(B.font);E(B.color+" rg\nBT /"+Z.name+" "+b(B.size)+" Tf 0 Tr 1 0 0 -1 "+b(B.x)+" "+b(B.y)+" Tm <");let V="";for(const _ of B.text)V+=_,(++R&1023)===0&&(E(Z.encode(V).slice(1,-1)),V="",await i(n));V&&E(Z.encode(V).slice(1,-1)),E("> Tj ET\n")}E("Q\n"),(++z&255)===0&&await i(n)}}return await j(d.plan),P(n.options.signal),{width:d.width,height:d.height,content:T.join(""),commands:d.commands,elements:d.elements}}return Object.freeze({checkDrawingBlock:m,prepareDrawing:o})})(),Tt=(()=>{const{OfficeIMOError:S}=pe,{capturePdfText:O,wrapPdfText:P}=lt,{positive:k}=Fe,{resolveParagraphStyle:C}=yt,{captureBookmark:y}=xt,{captureFields:p}=Ce,{pdfBudgetText:b}=Qe;function x(o,s,t,n=!1){if(!o||o.kind!=="paragraph")throw new TypeError("PDF paragraph groups accept paragraph blocks only.");const{text:e,headingLevel:r,presentation:d,fontSize:h,keepTogether:u,keepWithNext:c,spaceBefore:g,spaceAfter:w,style:T,bookmark:v}=o;if(r!==void 0&&(!Number.isInteger(r)||r<1||r>6))throw new TypeError("Paragraph headingLevel must be an integer from 1 through 6.");const E=C(T,{...h===void 0?{}:{fontSize:h},...d===void 0?{}:{presentation:d},...u===void 0?{}:{keepTogether:u},...c===void 0?{}:{keepWithNext:c},...g===void 0?{}:{spaceBefore:g},...w===void 0?{}:{spaceAfter:w}},s.paragraphStyles),R=E.presentation??Object.freeze({}),I=k(E.fontSize??s.fontSize,"Paragraph font size",144),z=y(v,s);return Object.freeze({text:O(e,R,s,t,!1,!n),style:R,size:I,...n?{budgetOnPaint:!0}:{},...r===void 0?{}:{headingLevel:r},...z===void 0?{}:{bookmark:z},keepTogether:E.keepTogether??!1,keepWithNext:E.keepWithNext??!1,spaceBefore:E.spaceBefore??0,spaceAfter:E.spaceAfter??8})}function m(o,s,t){if(!o||typeof o!="object"||Array.isArray(o)||Object.keys(o).some(n=>!["text","style","fontSize","presentation","spaceBefore","spaceAfter"].includes(n)))throw new TypeError("PDF captions support text, style, fontSize, presentation, spaceBefore and spaceAfter.");return x({...p(o,["text","style","fontSize","presentation","spaceBefore","spaceAfter"]),kind:"paragraph",keepTogether:!0,keepWithNext:!0},s,t,!0)}async function f(o,s,t,n=s.page.width-s.margins.left-s.margins.right){if(!o.text.text)return{...o,lines:[],height:0,firstHeight:0};if(!o.budgetOnPaint){const r=b(o.text.text,s.budget);s.budget.cell(r,r.length)}const e=await P(o.text,t,o.size,k(n,"Paragraph width"),s);return{...o,lines:e,height:o.spaceBefore+e.reduce((r,d)=>r+d.lineHeight,0)+o.spaceAfter,firstHeight:o.spaceBefore+e[0].lineHeight}}function a(o,s){if(o.length>s.limits.maxGroupBlocks)throw new S("RESOURCE_LIMIT","maxGroupBlocks exceeded.");let t=0,n=0;for(const e of o){if(t+=e.text.text.length,n+=e.text.runs.length,t>s.limits.maxCellCharacters)throw new S("RESOURCE_LIMIT","maxCellCharacters exceeded by a paragraph group or keep chain.");if(n>s.limits.maxTextRuns)throw new S("RESOURCE_LIMIT","maxTextRuns exceeded by a paragraph group or keep chain.")}}function i(o){const s=o.filter(n=>n.lines.length>0);let t=0;for(let n=s.length-1;n>=0;n--){const e=s[n];t=e.keepWithNext?e.height+t:e.keepTogether?e.height:e.firstHeight}return t}return Object.freeze({captureParagraph:x,captureCaption:m,prepareParagraph:f,checkParagraphBuffer:a,paragraphStartHeight:i})})(),yr=(()=>{const{capturePdfText:S,wrapPdfText:O}=lt,{captureParagraph:P,prepareParagraph:k}=Tt,{resolveParagraphStyle:C}=yt;function y(x,m){const{items:f,ordered:a=!1,start:i,itemStyle:l,indent:o,markerGap:s}=x,t=i===void 0?1:i;if(typeof a!="boolean")throw new TypeError("PDF list ordered must be boolean.");if(!Number.isSafeInteger(t)||t<1)throw new RangeError("PDF list start must be a positive safe integer.");if(!a&&i!==void 0)throw new TypeError("PDF list start requires ordered:true.");for(const[n,e]of[["indent",o],["markerGap",s]])if(e!==void 0&&(!Number.isFinite(e)||e<0||e>14400))throw new RangeError("PDF list "+n+" must be from zero through 14,400 points.");if(C(l,{},m.paragraphStyles).keepWithNext)throw new TypeError("PDF list item styles cannot use keepWithNext.");return Object.freeze({items:f,ordered:a,start:t,...l===void 0?{}:{itemStyle:l},...o===void 0?{}:{indent:o},...s===void 0?{}:{markerGap:s}})}async function p(x,m,f,a,i){if(!x||typeof x!="object"||Array.isArray(x)||Object.keys(x).some(v=>!["text","style","keepTogether"].includes(v)))throw new TypeError("PDF list items support text, style and keepTogether.");if(!Number.isSafeInteger(m)||m<0||!Number.isSafeInteger(f.start+m))throw new RangeError("PDF list numbering must remain within positive safe integers.");const{text:l,style:o=f.itemStyle,keepTogether:s}=x,t=P({kind:"paragraph",text:l,...o===void 0?{}:{style:o},...s===void 0?{}:{keepTogether:s}},a,i);if(t.keepWithNext)throw new TypeError("PDF list item styles cannot use keepWithNext.");if(!t.text.text.trim().length)throw new TypeError("PDF list items require nonempty text.");const n=f.ordered?String(f.start+m)+".":"•",e=S(n,t.style,a,i);a.budget.cell(n,n.length);const r=a.page.width-a.margins.left-a.margins.right,d=(await O(e,i,t.size,r,a,!1))[0],h=f.markerGap??t.size/2,u=f.indent??Math.max(t.size*2,d.width+h);if(d.width+h>u+.001)throw new RangeError("PDF list indent cannot fit its marker and gap.");if(u>=r)throw new RangeError("PDF list indent leaves no body text area.");const c=await k(t,a,i,r-u),g=c.lines[0],w=Math.max(g.lineHeight,d.lineHeight),T=Math.max(g.ascent,d.ascent);return{marker:d,indent:u,markerGap:h,paragraph:{...c,lines:[{...g,lineHeight:w,ascent:T},...c.lines.slice(1)],height:c.height+w-g.lineHeight,firstHeight:c.spaceBefore+w}}}return Object.freeze({captureListOptions:y,prepareListItem:p})})(),Et=(()=>{const{assertGroupedReportSource:S}=Ue,{captureFields:O}=Ce,{captureWideTable:P}=Fe,{presentation:k}=Ze,C=["labelColumn","subtotalLabel","grandTotalLabel","includeGrandTotal","continuationLabel","groupHeadingLevel"],y=["includeHeader","headerPresentation","footerPresentation","alternateRowColor","columnWidths","wideTable","formatValue","formatRuns",...C];function p(m,f){return S(m),Object.freeze({kind:"groupedTable",report:m,options:b(f)})}function b(m){if(!m||typeof m!="object"||Array.isArray(m)||Object.keys(m).some(r=>!y.includes(r)))throw new TypeError("Grouped PDF table options support table presentation and labels; document settings belong on writePdfDocument.");const f=O(m,y),{labelColumn:a,subtotalLabel:i,grandTotalLabel:l,includeGrandTotal:o,continuationLabel:s,groupHeadingLevel:t}=f;if(!a||typeof a!="object")throw new TypeError("Grouped PDF needs a leading labelColumn.");const{header:n,width:e}=a;if(typeof n!="string")throw new TypeError("The grouped label column header must be text.");for(const[r,d]of[["subtotalLabel",i],["grandTotalLabel",l]])if(typeof d!="function")throw new TypeError(r+" must be a synchronous text callback.");if(s!==void 0&&typeof s!="function")throw new TypeError("continuationLabel must be a synchronous text callback.");if(o!==void 0&&typeof o!="boolean")throw new TypeError("includeGrandTotal must be boolean.");if(t!==void 0&&(!Number.isInteger(t)||t<1||t>6))throw new TypeError("groupHeadingLevel must be an integer from 1 through 6.");return Object.freeze({...f,...f.wideTable===void 0?{}:{wideTable:P(f.wideTable)},labelColumn:Object.freeze({header:n,...e===void 0?{}:{width:e}}),...f.columnWidths===void 0?{}:{columnWidths:Object.freeze([...f.columnWidths])},...f.headerPresentation===void 0?{}:{headerPresentation:k(f.headerPresentation)},...f.footerPresentation===void 0?{}:{footerPresentation:k(f.footerPresentation)}})}return Object.freeze({groupedPdfLabelFields:C,groupedPdfTableFields:y,pdfGroupedTable:p,captureGroupedPdfTableOptions:b})})(),br=(()=>{const{assertGroupedReportSource:S,groupedReportOperation:O}=Ue,{consumeRows:P}=we,{ExportCell:k}=ve,{captureGroupedPdfTableOptions:C}=Et,{settings:y}=Fe,{PdfTableLayout:p}=bt,{captureCaption:b,captureParagraph:x,prepareParagraph:m}=Tt,{synchronousText:f}=Qe;async function a(l,o){const{report:s}=l,{pages:t,fonts:n,prepared:e,controller:r}=o;S(s);const d=e.options.tagged!==void 0,h=C(l.options),{labelColumn:u,subtotalLabel:c,grandTotalLabel:g,includeGrandTotal:w=!0,continuationLabel:T,groupHeadingLevel:v=2,...E}=h,R=Object.freeze([Object.freeze({...u}),...s.columns]);let I=-1;const z=V=>({rowIndex:I,columnIndex:V.columnIndex-1,column:s.columns[V.columnIndex-1]}),j=y({...t.settings.options,...E,columns:R,includeHeader:E.includeHeader??!0,...E.formatValue===void 0?{}:{formatValue:(V,_)=>E.formatValue(V,z(_))},...E.formatRuns===void 0?{}:{formatRuns:(V,_)=>E.formatRuns(V,z(_))}}),M={...j,budget:e.budget},L=new p(M,n);o.acceptColumns(R.length);const B=O(s,r.signal),Z=()=>r.abort(B.signal?.reason);B.signal?.addEventListener("abort",Z,{once:!0}),B.signal?.aborted&&Z();try{const V=await L.headers(),_=await L.blockHeight(V);let A=[],U=!1,W=!1,q=!1,X=0;const Y=new WeakMap;let F;const H=[],K=s.columns.flatMap((N,Q)=>Object.hasOwn(s.totals,N.key)?[Q]:[]),re=(N,Q,se)=>Object.freeze([new k(N,{text:N,presentation:j.options.footerPresentation}),...(se?se.map(ce=>Q[ce]):Q).map(ce=>new k(ce,{presentation:j.options.footerPresentation}))]),ne=new Map,he=N=>{const Q=ne.get(N);if(Q)return Q;const se=[0,...K.map($=>$+1)],ce=se.map($=>{const te=R[$];if(!N)return te;const{groups:le,...de}=te;return de}),ae=$=>{const te=se[$.columnIndex];return{...$,columnIndex:te,column:R[te]}},fe=se.flatMap(($,te)=>$===0||j.repeatedColumns.includes($)?[te]:[]),me=j.options.wideTable,ie={...M,repeatedColumns:Object.freeze(fe),options:{...j.options,columns:ce,...j.options.columnWidths===void 0?{}:{columnWidths:se.map($=>j.options.columnWidths[$])},...typeof me!="object"?{}:{wideTable:{...me,repeatColumns:fe}},...j.options.formatValue===void 0?{}:{formatValue:($,te)=>j.options.formatValue($,ae(te))},...j.options.formatRuns===void 0?{}:{formatRuns:($,te)=>j.options.formatRuns($,ae(te))}}},J=new p(ie,n);return ne.set(N,J),J},oe=async()=>{const N=await m(b({text:A.map(se=>se.label).join("\n"),presentation:{bold:!0},spaceAfter:4},t.settings,n),t.settings,n),Q=await m(b({text:A.map(se=>{if(T===void 0)return se.label;const ce=d?Y.get(se):void 0;if(ce!==void 0)return ce;const ae=f(T(se),"continuationLabel");return d&&Y.set(se,ae),ae}).join("\n"),presentation:{bold:!0},spaceAfter:4},t.settings,n),t.settings,n);return{caption:N,continuation:Q}},ee=async()=>{if(F)if(U||await be(F),H.length&&!q)await t.keptRows([F,...H],W);else if(H.length){await t.row(F,W);for(const N of H)await t.row(N)}else await t.row(F,W);else for(const N of H)await t.row(N);F=void 0,H.length=0,W=!1,q=!1},ye=async()=>{!U&&!F||(await ee(),await t.endTable(),U=!1)},be=async N=>{const{caption:Q,continuation:se}=await oe(),ce=N.height+H.reduce((le,de)=>le+de.height,0),ae=j.page.height-j.margins.top-j.margins.bottom-_-Math.max(Q?.height??0,se.height);q=H.length>0&&ce>ae+.001;const fe=H.length>0&&!q?ce:L.minimumRowHeight(N),me=[];if(d)for(const le of A.slice(X))me.push(await m(x({kind:"paragraph",text:le.label.trim()?le.label:"",headingLevel:v+le.level,presentation:{bold:!0},keepTogether:!0,keepWithNext:!0,spaceAfter:4,...le.label.trim()?{bookmark:{title:le.label,level:v+le.level}}:{}},t.settings,n),t.settings,n));const ie=me.reduce((le,de)=>le+de.height,0),J=d&&X>0?await m(b({text:A.slice(0,X).map(le=>le.label).join("\n"),presentation:{bold:!0},spaceAfter:4},t.settings,n),t.settings,n):void 0,$=d?(J?.height??0)+ie:Q.height;await o.flushParagraphs($+_+fe),J&&await t.paragraphs([J],ie+_+fe,!0,{artifact:!0});let te=ie+(d?0:Q.height)+_+fe;for(const le of me)te-=le.height,await t.beginGroup(X++,le,te);await t.beginTable(L,V,fe,Q,se,!1,d,d),U=!0,W=(Q?.lines.length??0)>0||me.some(le=>le.lines.length>0)},D=async(N,Q,se)=>{if(Q===s.groupBy.length-1){t.summary(N),H.push(N),await ye(),await t.endGroup(Q),X=Q,A=A.slice(0,Q);return}await ye();const{caption:ce,continuation:ae}=await oe(),fe=he(!1),me=await fe.headers(),ie=await fe.data(se,0,!0),J=fe.minimumRowHeight(ie);await o.flushParagraphs(ce.height+await fe.blockHeight(me)+J),await t.beginTable(fe,me,J,ce,ae,!1,!0),t.summary(ie),await t.row(ie,ce.lines.length>0||me.length>0),await t.endTable(),await t.endGroup(Q),X=Q,A=A.slice(0,Q)},G=async N=>{if(await ye(),!w&&N.rows!==0)return;const Q=N.rows===0?L:he(!0),se=N.rows===0?V:await Q.headers();I=-1;let ce;if(w&&(o.acceptRow(!1),ce=await Q.data(re(f(g(N),"grandTotalLabel"),N.totals,N.rows===0?void 0:K),0,!0)),!se.length&&!ce)return;const ae=ce?Q.minimumRowHeight(ce):0;await o.flushParagraphs(await Q.blockHeight(se)+ae),await t.beginTable(Q,se,ae),ce&&(d&&t.summary(ce),await t.row(ce)),await t.endTable()};await P(B.events,B.signal,async N=>{switch(N.kind){case"groupStart":if(await ye(),d&&v+N.level>6)throw new RangeError("groupHeadingLevel and the opened group depth exceed heading level 6.");A=Object.freeze([...A.slice(0,N.level),N]);break;case"row":{F&&await ee(),I=N.rowIndex,o.acceptRow(!0),F=await L.data([new k("",{text:""}),...N.values],N.rowIndex);break}case"groupEnd":{I=-1,o.acceptRow(!1);const Q=d&&N.level!==s.groupBy.length-1,se=re(f(c(N),"subtotalLabel"),N.totals,Q?K:void 0),ce=Q?void 0:await L.data(se,0,!0);d?await D(ce,N.level,se):H.push(ce);break}case"complete":await G(N);break}})}finally{B.signal?.removeEventListener("abort",Z),B.dispose()}}return Object.freeze({renderGroupedPdfTable:a})})(),ct=(()=>{const{BlobByteSink:S,withDestination:O}=Ie,{OfficeIMOError:P}=pe,{beginTask:k,checkAbort:C,consumeRows:y,pause:p,taskYieldDue:b}=we,{notifyProgress:x}=Ge,{copyColumns:m,createRowProjector:f}=Ne,{captureFields:a}=Ce,{settings:i,captureWideTable:l}=Fe,{pdfNumber:o}=Be,{PdfTableLayout:s}=bt,{PdfWriteSession:t}=_t,{PdfDocumentImages:n}=mr,{vectorCommands:e}=gr,{graphicAlternative:r}=zt,{checkDrawingBlock:d,prepareDrawing:h}=wr,{captureParagraph:u,captureCaption:c,prepareParagraph:g,checkParagraphBuffer:w,paragraphStartHeight:T}=Tt,{captureListOptions:v,prepareListItem:E}=yr,{captureSection:R}=xt,{renderGroupedPdfTable:I}=br,z=["columns","includeHeader","headerRows","footer","headerPresentation","footerPresentation","alternateRowColor","columnWidths","wideTable","formatValue","formatRuns"];function j(_,A){const U=Z(A);return Object.freeze({kind:"table",rows:_,options:Object.freeze({...U,columns:Object.freeze(m(U.columns))})})}async function M(_,A={}){const U=new S;try{return await L(_,U,A),U.toBlob("application/pdf")}catch(W){throw U.discard(),W}}async function L(_,A,U={}){const W=i(U,!0),q=new AbortController,X=W.options.signal,Y=()=>q.abort(X?.reason);X?.addEventListener("abort",Y,{once:!0}),X?.aborted&&Y();const F={...W,options:{...W.options,signal:q.signal}},{options:H,budget:K}=F;try{return k(),C(H.signal),await O(A,async re=>{const ne=new t(re,F),{objects:he,pages:oe,fonts:ee}=ne,ye=new n(he,F);let be=0,D=0,G=0,N=0,Q=0,se=0,ce=[];const ae=async(J=0)=>{const $=[];for(const te of ce)$.push(await g(te,oe.settings,ee));ce=[],await oe.paragraphs($,J)},fe=async J=>{const $=u(J,oe.settings,ee);$.text.text&&(ce.length||$.keepWithNext?(ce.push($),w(ce,oe.settings),$.keepWithNext||await ae()):await oe.paragraphs([await g($,oe.settings,ee)]))},me=async J=>J===void 0?void 0:g(J,oe.settings,ee),ie=J=>J===void 0?void 0:c(J,oe.settings,ee);return await ne.start(),await y(_,H.signal,async J=>{if(!J||typeof J!="object")throw new TypeError("PDF document blocks must be objects.");switch(J.kind){case"section":{const $=R(J,F);await ae();const te=await oe.beginSection($);te.includeHeading?await fe({kind:"paragraph",text:te.title,headingLevel:te.level,...te.headingStyle===void 0?{fontSize:oe.settings.fontSize*1.5,presentation:{bold:!0}}:{style:te.headingStyle},keepTogether:!0,keepWithNext:!0,...te.bookmark?{bookmark:{title:te.title,level:te.level}}:{}}):te.bookmark&&oe.addBookmark({title:te.title,level:te.level});break}case"paragraph":await fe(J);break;case"list":{const $=v(J,oe.settings);let te=0,le;await y($.items,H.signal,async de=>{if(++se>F.limits.maxListItems)throw new P("RESOURCE_LIMIT","maxListItems exceeded.");const ue=await E(de,te++,$,oe.settings,ee);te===1&&(await ae(ue.paragraph.keepTogether?ue.paragraph.height:ue.paragraph.firstHeight),le=ne.structure?.element("L")),await oe.listItem(ue,le),b()&&await p(),C(H.signal)}),await ne.structure?.complete(le);break}case"group":{const $=J.blocks,te=J.keepTogether;if(!Array.isArray($))throw new TypeError("PDF paragraph group blocks must be an array.");if(te!==void 0&&typeof te!="boolean")throw new TypeError("PDF paragraph group keepTogether must be boolean.");if($.length>F.limits.maxGroupBlocks)throw new P("RESOURCE_LIMIT","maxGroupBlocks exceeded.");const le=[];for(const ue of $)le.push(u(ue,oe.settings,ee)),w(le,F);if(le.filter(ue=>ue.text.text).at(-1)?.keepWithNext)throw new TypeError("The last paragraph in a group cannot keepWithNext beyond the group's boundary.");const de=[];for(const ue of le)de.push(await g(ue,oe.settings,ee));if(!de.some(ue=>ue.lines.length>0))break;await ae(te!==!1?de.reduce((ue,Se)=>ue+Se.height,0):T(de)),await oe.paragraphs(de,0,te!==!1);break}case"pageBreak":await ae(),await oe.pageBreak();break;case"groupedTable":await I(J,{prepared:F,pages:oe,fonts:ee,controller:q,flushParagraphs:ae,acceptColumns:$=>{G=Math.max(G,$)},acceptRow:$=>{K.row(++D),$&&++be%256===0&&x(H.onProgress,{phase:"rows",rows:be,bytes:he.bytes})}});break;case"table":{const{options:$,rows:te,caption:le,continuationCaption:de}=J,ue=Z($),Se=ie(le),Ae=ie(de),Te=i({...oe.settings.options,...ue,columns:ue?.columns,includeHeader:ue?.includeHeader??!0}),Ee=new s({...Te,budget:K},ee),xe=await me(Se),ge=await me(Ae),je=f(Te.options.columns,void 0,H.signal);let Oe=0,Re=!1;G=Math.max(G,Te.options.columns.length);const ke=await Ee.headers(),ze=await Ee.blockHeight(ke);await y(te,H.signal,async He=>{K.row(++D);const St=await Ee.data(je(He,Oe),Oe),Nt=!Re&&(ce.length>0||!!xe?.lines.length);if(!Re){const Rt=Ee.minimumRowHeight(St);await ae((xe?.height??0)+ze+Rt),await oe.beginTable(Ee,ke,Rt,xe,ge),Re=!0}await oe.row(St,Nt),Oe++,be++,be%256===0&&x(H.onProgress,{phase:"rows",rows:be,bytes:he.bytes}),b()&&await p(),C(H.signal)});const De=await Ee.footer(Oe),Le=!Re&&(ce.length>0||!!xe?.lines.length);if(!Re){if(!ke.length&&!De?.length)break;const He=De?.length?Te.options.footer?.rows?await Ee.blockHeight(De):Ee.minimumRowHeight(De[0]):0;await ae((xe?.height??0)+ze+He),await oe.beginTable(Ee,ke,He,xe,ge)}De&&(Te.options.footer?.rows?await oe.block(De):await oe.row(De[0],Le)),await oe.endTable();break}case"image":{const{width:$,height:te,image:le,caption:de}=J,ue=ie(de),Se=r(J,oe.settings),Ae=B(J.alignment);if(ue&&Se===void 0)throw new TypeError("A captioned PDF graphic requires alternativeText and cannot be decorative.");const Te=await ye.prepare(le),Ee=await me(ue),xe=$??(te===void 0?Te.width*.75:te*Te.width/Te.height),ge=te??xe*Te.height/Te.width;if(!Number.isFinite(xe)||xe<=0||!Number.isFinite(ge)||ge<=0)throw new RangeError("Image display dimensions must be finite and positive.");await ae((Ee?.height??0)+oe.graphicHeight(xe,ge)),oe.registerXObject(Te.name,Te.id),await oe.graphic(xe,ge,Ae,(je,Oe,Re,ke)=>"q "+[Re,0,0,ke,je,Oe].map(o).join(" ")+" cm /"+Te.name+" Do Q\n",Se,Ee);break}case"vector":{const $=ie(J.caption),te=r(J,oe.settings),le=B(J.alignment);if($&&te===void 0)throw new TypeError("A captioned PDF graphic requires alternativeText and cannot be decorative.");const de=await e(J,oe.settings,N),ue=await me($);N+=de.count,await ae((ue?.height??0)+oe.graphicHeight(de.width,de.height)),await oe.graphic(de.width,de.height,le,(Se,Ae,Te,Ee)=>"q "+[Te/de.width,0,0,-Ee/de.height,Se,Ae+Ee].map(o).join(" ")+" cm 0 0 "+o(de.width)+" "+o(de.height)+" re W n\n"+de.content+"Q\n",te,ue);break}case"drawing":{d(J);const $=J.drawing,te=ie(J.caption),le=r(J,oe.settings),de=B(J.alignment);if(te&&le===void 0)throw new TypeError("A captioned PDF graphic requires alternativeText and cannot be decorative.");const ue=await h($,oe.settings,ee,{commands:N,elements:Q}),Se=await me(te);N+=ue.commands,Q+=ue.elements,await ae((Se?.height??0)+oe.graphicHeight(ue.width,ue.height)),await oe.graphic(ue.width,ue.height,de,(Ae,Te,Ee,xe)=>"q "+[Ee/ue.width,0,0,-xe/ue.height,Ae,Te+xe].map(o).join(" ")+" cm 0 0 "+o(ue.width)+" "+o(ue.height)+" re W n\n"+ue.content+"Q\n",le,Se);break}default:throw new TypeError("Unsupported PDF document block.")}b()&&await p(),C(H.signal)}),await ae(),H.messageBottom&&await oe.paragraph(H.messageBottom),await ne.finish(),x(H.onProgress,{phase:"complete",rows:be,bytes:he.bytes}),C(H.signal),{rows:be,columns:G,bytes:he.bytes}})}finally{X?.removeEventListener("abort",Y)}}function B(_){if(_!==void 0&&!["left","center","right"].includes(_))throw new TypeError("Invalid graphic alignment.");return _??"left"}function Z(_){if(!_||typeof _!="object"||Object.keys(_).some(U=>!z.includes(U)))throw new TypeError("Table options support columns, headings, footers, widths and presentation; document settings belong on writePdfDocument.");const A=a(_,z);return{...A,...A.wideTable===void 0?{}:{wideTable:l(A.wideTable)}}}return Object.freeze({pdfTable:j,writePdfDocument:M,writePdfDocumentTo:L})})(),kt=(()=>{const{assertGroupedReportSource:S}=Ue,{BlobByteSink:O}=Ie,{writePdfDocumentTo:P}=ct,{pdfOptionFields:k}=Fe,{captureFields:C}=Ce,{pdfGroupedTable:y,groupedPdfLabelFields:p,groupedPdfTableFields:b}=Et,x=[...k,...p];async function m(i,l){const o=new O;try{return await f(i,o,l),o.toBlob("application/pdf")}catch(s){throw o.discard(),s}}async function f(i,l,o){if(S(i),!o||typeof o!="object")throw new TypeError("Grouped PDF options are required.");const s=C(o,x),t=Object.fromEntries(b.filter(e=>Object.hasOwn(s,e)).map(e=>[e,s[e]])),n={...s};for(const e of b)delete n[e];return delete n.columns,delete n.headerRows,delete n.footer,P([y(i,t)],l,n)}return Object.freeze({pdfGroupedTable:Et.pdfGroupedTable,writeGroupedPdf:m,writeGroupedPdfTo:f})})(),xr=(()=>{const{fontProgram:S}=$e,{resolveScalar:O,selectFont:P,validateFonts:k}=Dt;function C(p,b={}){if(typeof p!="string")throw new TypeError("PDF preflight text must be a string.");if(!b||typeof b!="object")throw new TypeError("PDF preflight options must be an object.");for(const i of["bold","italic"])if(b[i]!==void 0&&typeof b[i]!="boolean")throw new TypeError("PDF preflight "+i+" must be boolean.");k(b.fonts);const x=b.bold??!1,{font:m}=P(b.fonts,x,b.italic??!1),f=m?S(m):void 0,a=new Set;for(let i=0;i<p.length;){const l=p.codePointAt(i),o=l===9?32:l;if(l!==10&&l!==13&&!a.has(o)){const s=O(o,f,x);if(!s.supported)return{...s,index:i,...s.code==="unpaired-surrogate"?{}:{scalar:l}};a.add(o)}i+=l>65535?2:1}return{supported:!0}}return Object.freeze({preflightPdfText:C})})(),Tr=Object.freeze({writePdf:Bt.writePdf,writePdfTo:Bt.writePdfTo,writeGroupedPdf:kt.writeGroupedPdf,writeGroupedPdfTo:kt.writeGroupedPdfTo,pdfGroupedTable:kt.pdfGroupedTable,createGroupedReport:Ue.createGroupedReport,writePdfDocument:ct.writePdfDocument,writePdfDocumentTo:ct.writePdfDocumentTo,pdfTable:ct.pdfTable,PdfFont:$e.PdfFont,preflightPdfText:xr.preflightPdfText,ExportCell:ve.ExportCell,saveBlob:rt.saveBlob}),Ct=(()=>{function S(y,p,...b){const x=O(y,p);if(typeof x!="function")throw new TypeError("DataTables API requires "+p+"().");return Reflect.apply(x,y,b)}function O(y,p){return y!=null&&(typeof y=="object"||typeof y=="function")?y[p]:void 0}function P(y){const p=Array.isArray(y)?y:S(y,"toArray");if(!Array.isArray(p))throw new TypeError("DataTables API must return an array.");return p}function k(y){return P(S(y,"indexes")).map(p=>{if(!Number.isSafeInteger(p)||p<0)throw new TypeError("Invalid DataTables index.");return p})}return Object.freeze({call:S,member:O,array:P,indexes:k})})(),Lt=(()=>{const{ExportCell:S,assertExportValue:O}=ve,{tableSpans:P}=Ve,{member:k}=Ct;function C(x){return O(x),x}function y(x){const m=C(x);return String(m instanceof S?m.text??m.value??"":m??"")}function p(x,m,f){const a=m.map(()=>[]);if(f==="leaf"||!Array.isArray(x)||!x.length)return{rows:[m.map(C)],groups:a};if(f==="structured"){const l=x.map(o=>{if(!Array.isArray(o))throw new TypeError("Invalid DataTables heading structure.");return o.map(s=>s==null?null:Object.freeze({value:C(k(s,"title")),columnSpan:k(s,"colspan"),rowSpan:k(s,"rowspan")}))});return P(l,m.length),{rows:l.map(o=>o.map(s=>s?.value??"")),groups:a,structure:Object.freeze(l.map(o=>Object.freeze(o)))}}const i=x.map((l,o)=>{if(!Array.isArray(l)||l.length!==m.length)throw new TypeError("Invalid DataTables heading structure.");const s=m.map(()=>"");for(let t=0;t<l.length;){const n=l[t],e=k(n,"colspan"),r=k(n,"rowspan");if(n==null||r!==1||!Number.isInteger(e)||e<1||t+e>m.length)throw new TypeError("Grouped export requires horizontal header spans; select headings: 'leaf' for vertical spans.");if(o===x.length-1&&e!==1)throw new TypeError("Grouped export requires one leaf header per column.");const d=y(k(n,"title"));if(s[t]=d,e!==1&&!d)throw new TypeError("Blank spanning headings require headings: 'leaf'.");for(let h=t;h<t+e;h++){if(h!==t&&l[h]!=null)throw new TypeError("Invalid overlapping DataTables heading cells.");o<x.length-1&&a[h].push(d)}t+=e}return s});for(let l=0;l<i.length-1;l++){const o=x[l];for(let s=1;s<o.length;s++)if(o[s]!=null&&a[s][l]&&JSON.stringify(a[s].slice(0,l+1))===JSON.stringify(a[s-1].slice(0,l+1)))throw new TypeError("Adjacent separate headings with equal group paths require headings: 'leaf'.")}return{rows:i,groups:a}}return Object.freeze({value:C,text:y,headings:p})})(),Mt=(()=>{const{checkAbort:S,pause:O,rowsFromBatches:P,taskYieldDue:k}=we,{ExportBudget:C}=We,{captureFields:y}=Ce,{columnOptionFields:p,copyColumns:b}=Ne,{array:x,call:m,indexes:f,member:a}=Ct,{headings:i,text:l,value:o}=Lt;function s(h){h=y(h,["rows","columns","modifier","orthogonal","stripHtml","stripNewlines","decodeEntities","escapeExcelFormula","trim","format","customizeData"]);const u=h.format&&y(h.format,["header","footer","body"]),c=h.customizeData;return{...h,...u?{format:{...u.header?{header:(g,w,T)=>o(u.header(g,w,T))}:{},...u.footer?{footer:(g,w,T)=>o(u.footer(g,w,T))}:{},...u.body?{body:(g,w,T,v)=>o(u.body(g,w,T,v))}:{}}}:{},...c?{customizeData:g=>{const w=c(g);typeof a(w,"then")=="function"&&o(w)}}:{}}}function t(h,u,c,g){if(!u||!Array.isArray(h)||!h.length)return h;const w=c.map((T,v)=>!Object.is(T,u[v]));return w.some(Boolean)?h.map((T,v)=>Array.isArray(T)?T.map((E,R)=>{if(E==null||v+(Number(a(E,"rowspan"))||1)!==h.length)return E;const I=Number(a(E,"colspan"))||1;if(!w.slice(R,R+I).some(Boolean))return E;if(I!==1)throw new TypeError("customizeData cannot change one column of a spanning "+g+" cell.");return{...E,title:c[R]}}):T):h}function n(h,u){if(!h||h.length!==u.length||new Set(h).size!==h.length)return;const c=u.map(g=>h.indexOf(g));return c.every(g=>g>=0)&&new Set(c).size===c.length&&c.some((g,w)=>g!==w)?c:void 0}function e(h,u,c={}){return r(h,u,c)}function r(h,u,c={},g){if(c=y(c,["mode","exportOptions","batchRows","maxBatchCells","headings","includeFooter","serverSide","columnOptions","project","signal","limits","onProgress"]),c.columnOptions!==void 0){const ie=Object.fromEntries(Object.entries(c.columnOptions).map(([J,$])=>[J,y($,p)]));c={...c,columnOptions:ie}}for(const ie of Object.values(c.columnOptions??{}))if(ie.style!==void 0)throw new TypeError("Workbook-local column styles require the advanced Workbook API; use portable ExportCell presentation.");const w=c.mode??"batched",T=c.headings??"grouped";if(!["batched","compatibility"].includes(w))throw new TypeError("Unknown DataTables export mode.");if(!["grouped","leaf","structured"].includes(T))throw new TypeError("Unknown DataTables heading mode.");if(c.serverSide!==void 0&&!["reject","loaded"].includes(c.serverSide))throw new TypeError("Unknown server-side export policy.");const v=c.batchRows??4096,E=c.maxBatchCells??65536;if(!Number.isInteger(v)||v<1||v>4096)throw new RangeError("batchRows must be between 1 and 4,096.");if(!Number.isSafeInteger(E)||E<1)throw new RangeError("maxBatchCells must be a positive safe integer.");const R=c.signal,I=c.project,z=new C(c.limits);if(S(R),a(m(u.page,"info"),"serverSide")&&c.serverSide!=="loaded")throw new TypeError("Server-side DataTables exports require a separate full-data source or explicit serverSide: 'loaded'.");const j=s(c.exportOptions??{}),M={stripHtml:!0,stripNewlines:!0,decodeEntities:!0,trim:!0,...j},L=h.Buttons,B=a(L,"stripData"),Z=typeof B=="function"?B.bind(L):void 0;if(w==="batched"&&!j.format?.body&&typeof B!="function")throw new TypeError("DataTables API requires stripData().");if(w==="batched"&&j.customizeData)throw new TypeError("customizeData requires compatibility mode.");if(j.customizeData&&c.project)throw new TypeError("project cannot identify source indexes after customizeData.");const V={search:"applied",order:"applied",...j.modifier};a(V,"selected")===void 0&&typeof a(a(u,"select"),"info")=="function"&&Number(m(m(u,"rows",j.rows??null,{...V,selected:!0}),"count"))>0&&Object.assign(V,{selected:!0});const _=f(m(u,"rows",j.rows??null,V)),A=f(m(u,"columns",j.columns??""));if(A.length>E)throw new RangeError("A selected row exceeds maxBatchCells.");if(new Set(_).size!==_.length||new Set(A).size!==A.length)throw new TypeError("DataTables export indexes must be unique.");let U;const W=j.customizeData,q=m(u.buttons,"exportData",{...j,modifier:V,...w==="batched"?{rows:[]}:{},...W?{customizeData:ie=>{const J=a(ie,"footer");U={header:[...x(a(ie,"header"))],footer:J==null?void 0:[...x(J)]},W(ie)}}:{}}),X=x(a(q,"header"));if(X.length!==A.length)throw new TypeError("Export header must match the selected columns.");const Y=T==="structured"&&!g?.header,F=g?.header?void 0:a(q,"headerStructure"),H=i(Y?t(F,U?.header,X,"header"):F,X,g?.header?"leaf":T),K=n(U?.header,X);if(K&&H.rows.length>1)throw new TypeError("customizeData cannot reorder columns under grouped headings; select headings: 'leaf' or reorder the table's columns.");if(U&&!K&&U.header.some((ie,J)=>!Object.is(ie,X[J]))&&A.some(ie=>c.columnOptions?.[ie]!==void 0))throw new TypeError("customizeData changed column headings, so columnOptions cannot be matched to columns; rename columns with columnOptions header instead.");const re=K?K.map(ie=>A[ie]):A;for(const ie of A)if(a(c.columnOptions?.[ie],"value")!==void 0)throw new TypeError("DataTables columnOptions describes columns; resolve values with project.");const ne=Object.freeze(b(X.map((ie,J)=>({header:l(ie),key:"dt:"+re[J],...c.columnOptions?.[re[J]],...H.groups[J].length?{groups:Object.freeze(H.groups[J])}:{}}))).map(ie=>Object.freeze(ie)));H.structure||(H.rows[H.rows.length-1]=ne.map(ie=>ie.header));const he=H.structure?.map((ie,J)=>Object.freeze(ie.map(($,te)=>{if(!$||J+($.rowSpan??1)!==H.structure.length)return $;const le=c.columnOptions?.[re[te]]?.header;if(($.columnSpan??1)>1&&re.slice(te,te+($.columnSpan??1)).some(de=>c.columnOptions?.[de]?.header!==void 0))throw new TypeError("A spanning leaf heading cannot have per-column header overrides.");return le===void 0?$:Object.freeze({...$,value:le})}))),oe=c.includeFooter!==!1&&g?.footer!==!0,ee=oe?a(q,"footerStructure"):void 0;if(T!=="structured"&&oe&&Array.isArray(ee)&&ee.length>1)throw new TypeError("Only a single footer row is supported; select includeFooter: false to omit it explicitly.");const ye=oe?a(q,"footer"):void 0,be=ye==null?void 0:x(ye).map(o);if(be&&be.length!==ne.length)throw new TypeError("Export footer must match the selected columns.");const D=be&&Array.isArray(ee)&&ee.length?i(T==="structured"?t(ee,U?.footer,x(ye),"footer"):ee,be,T==="structured"?"structured":"grouped"):void 0,G=w==="compatibility"?x(a(q,"body")):void 0,N=ne.length?G?.length??_.length:0;z.check("maxRows",N);const Q=ne.length?Math.min(v,Math.floor(E/ne.length)):v,se=new Map(A.map((ie,J)=>[ie,J])),ce=w==="batched"&&N?m(u,"cells",[],[]):void 0;if(ce){let ie=0;if(m(ce,"iterator","table",()=>{ie++}),ie!==1)throw new TypeError("A batched export requires exactly one DataTables table.")}const ae=P({[Symbol.asyncIterator]:()=>fe()});async function*fe(){for(let ie=0;ie<N;ie+=Q){S(R);let J;if(G)J=G.slice(ie,ie+Q).map(($,te)=>{if(!Array.isArray($)||$.length!==ne.length)throw new TypeError("Export body row must match the selected columns.");return $.map((le,de)=>me(le,_[ie+te]??ie+te,de,ie+te))});else{const $=_.slice(ie,ie+Q),te=new Array($.length*ne.length);for(let ge=0,je=0;ge<$.length;ge++)for(const Oe of A)te[je++]={row:$[ge],column:Oe};m(ce,"pop"),m(ce,"push",te);const le=ce,de=x(m(le,"render",j.orthogonal??"display")),ue=x(m(le,"indexes")),Se=j.format?.body?x(m(le,"nodes")):void 0;if(de.length!==$.length*ne.length||ue.length!==de.length||Se&&Se.length>de.length)throw new TypeError("The table changed or returned an incomplete export batch.");J=$.map(()=>new Array(ne.length));let Ae,Te,Ee=0,xe=0;for(let ge=0;ge<de.length;ge++){S(R);const je=a(ue[ge],"row"),Oe=a(ue[ge],"column");if(!Te&&(je!==te[ge].row||Oe!==te[ge].column)){Ae=new Map($.map((Le,He)=>[Le,He])),Te=new Set;for(let Le=0;Le<ge;Le++)Te.add(Le)}const Re=Te?Ae.get(je):Ee,ke=Te?se.get(Oe):xe;if(Re===void 0||ke===void 0||Te?.has(Re*ne.length+ke))throw new TypeError("Invalid DataTables cell indexes.");Te?.add(Re*ne.length+ke);let ze=Se?.[ge];if(Se&&Se.length!==de.length){m(le,"pop"),m(le,"push",[{row:je,column:Oe}]);const Le=x(m(le,"nodes"));if(Le.length>1)throw new TypeError("Invalid DataTables cell nodes.");ze=Le[0]}const De=j.format?.body?j.format.body(de[ge],je,Oe,ze):Z(de[ge],M);J[Re][ke]=me(De,je,ke,ie+Re),++xe===ne.length&&(xe=0,Ee++),(ge&127)===127&&k()&&(await O(),S(R))}}S(R),yield J,k()&&(await O(),S(R))}}function me(ie,J,$,te){S(R);const le=o(ie);return I?o(I(le,{sourceRowIndex:J,sourceColumnIndex:A[$],rowIndex:te,columnIndex:$})):le}return Object.freeze({columns:ne,headers:Object.freeze(H.rows.map(ie=>Object.freeze(ie))),footer:be?Object.freeze(be):void 0,...he?{headerStructure:Object.freeze(he)}:{},...D?.structure?{footerStructure:D.structure}:{},rowCount:N,rows:ae})}return Object.freeze({createDataTablesExport:e,captureDataTablesExport:r})})(),Er=(()=>{const{captureFields:S}=Ce,{ExportBudget:O}=We,{captureCsvOptions:P}=vt,{capturePdfOptions:k,capturePdfLimits:C,pdfLimitFields:y}=Fe,{captureWorkbookLimits:p,workbookLimitFields:b,workbookOptionFields:x,sheetOptionFields:m}=qe,f=[...new Set([...b,...y])],a=x.filter(e=>e!=="sink");function i(e){return e===void 0?void 0:new O(S(e,f)).limits}function l(e,r){const d={...e};for(const[h,u]of Object.entries(r??{}))u!==void 0&&(d[h]=u);return d}function o(e={}){const r=S(e,[...a,"sheet"]),d=r.sheet&&S(r.sheet,[...m,"name"]),h=d?.footer&&S(d.footer,["rows","values","totals","style"]);return{...r,...d===void 0?{}:{sheet:{...d,...h===void 0?{}:{footer:h}}},...r.limits===void 0?{}:{limits:p(r.limits)}}}function s(e={}){const r=P(e);return{...r,...r.limits===void 0?{}:{limits:new O(r.limits).limits}}}function t(e={}){const r=k(e);return{...r,...r.limits===void 0?{}:{limits:C(r.limits)}}}return Object.freeze({captureCommonLimits:i,mergeAdapterLimits:l,captureXlsxOptions:o,captureCsvOptions:s,capturePdfOptions:t})})(),kr=(()=>{const{BlobByteSink:S,checkAbort:O,saveBlob:P}=rt,{notifyProgress:k}=Ge,{writeCsvTo:C}=Ht,{writeXlsxTo:y}=Qt,{writePdfTo:p}=Tr,{portableSheet:b,portableWorkbook:x}=gt,{call:m,member:f}=Ct,{value:a}=Lt,{captureDataTablesExport:i}=Mt,{captureFields:l}=Ce,{captureCommonLimits:o,captureXlsxOptions:s,captureCsvOptions:t,capturePdfOptions:n,mergeAdapterLimits:e}=Er,r=["mode","exportOptions","batchRows","maxBatchCells","headings","includeFooter","serverSide","columnOptions","project","signal","limits","onProgress","xlsx","csv","pdf"],d=[...r,"filename","save","onError"];async function h(w,T,v,E,R={}){if(v!=="xlsx"&&v!=="csv"&&v!=="pdf")throw new TypeError("DataTables export format must be xlsx, csv or pdf.");for(const q of["workbook","sheet","sheetName"])if(q in R)throw new TypeError("DataTables writer settings belong in xlsx; use xlsx.sheet.name for the worksheet name.");const I=l(R,r),{signal:z,onProgress:j}=I,M=o(I.limits),L=s(v==="xlsx"?I.xlsx:void 0),B=t(v==="csv"?I.csv:void 0),Z=n(v==="pdf"?I.pdf:void 0),V=L.sheet;v==="xlsx"&&(b(V),x(L));const _=V?.footer&&[V.footer.rows,V.footer.values,V.footer.totals].some(q=>q!==void 0),A=i(w,T,{...I,...M===void 0?{}:{limits:M},...v==="pdf"?{headings:I.headings??"structured"}:{}},{header:v==="pdf"?Z.includeHeader===!1||Z.headerRows!==void 0:v==="xlsx"?V?.includeHeader===!1||V?.headerRows!==void 0:B.includeHeader===!1||B.headerRows!==void 0,footer:v==="pdf"?Z.footer!==void 0:v==="xlsx"?!!_:B.footer!==void 0});let U;const W={...z?{signal:z}:{},...j?{onProgress:q=>k(j,{...q,totalRows:A.rowCount})}:{}};if(v==="xlsx"){const q=A.footerStructure?{rows:A.footerStructure}:A.footer?{values:A.footer}:void 0,X=_?V?.footer:q||V?.footer?{...q,...V?.footer}:void 0;U=await y(A.rows,E,{...L,...W,columns:A.columns,limits:e(L.limits,M),sheet:{...V,...A.headerStructure&&V?.includeHeader!==!1&&V?.headerRows===void 0?{headerRows:A.headerStructure}:{},...X?{footer:X}:{}}})}else if(v==="pdf"){const q=Z.footer??(A.footerStructure?{rows:A.footerStructure}:A.footer?{values:A.footer}:void 0);U=await p(A.rows,E,{...Z,...W,columns:A.columns,limits:e(Z.limits,M),...A.headerStructure&&Z.includeHeader!==!1&&!Z.headerRows?{headerRows:A.headerStructure}:{},...q?{footer:q}:{}})}else{const q=B.footer??(A.footerStructure?{rows:A.footerStructure}:A.footer?{rows:[A.footer.map(X=>({value:X}))]}:void 0);U=await C(A.rows,E,{...B,...W,columns:A.columns,limits:e(B.limits,M),...B.includeHeader!==!1&&B.headerRows===void 0?{headerRows:A.headerStructure??A.headers.map(X=>X.map(Y=>({value:Y})))}:{},...q?{footer:q}:{}})}return O(z),{rows:A.rowCount,columns:A.columns.length,bytes:U.bytes}}async function u(w,T,v,E={}){const R=new S;try{return await h(w,T,v,R,E),R.toBlob(v==="pdf"?"application/pdf":v==="csv"?"text/csv;charset=utf-8":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}catch(I){throw R.discard(),I}}function c(w,T={}){const v=w.ext?.buttons;if(!v||typeof f(w.Buttons,"stripData")!="function")throw new TypeError("Install DataTables Buttons before registering OfficeIMO exports.");if(v.officeimoExcel||v.officeimoCsv||v.officeimoPdf)throw new TypeError("OfficeIMO DataTables buttons are already registered.");for(const[E,R,I]of[["officeimoExcel","xlsx","Excel"],["officeimoCsv","csv","CSV"],["officeimoPdf","pdf","PDF"]])v[E]={text:I,async:1,action:function(z,j,M,L,B){let Z=T;const V=()=>{const _=B;B=void 0,_?.()};(async()=>{try{const _=f(L,"officeimo"),A=f(L,"filename");if(_!==void 0&&(!_||typeof _!="object"))throw new TypeError("Button officeimo settings must be an object.");const U=l(T,d),W=l(_??{},d);if(Z={...U,...W,...A!==void 0?{filename:A}:{},...f(L,"footer")===!1?{includeFooter:!1}:{},...f(L,"exportOptions")?{exportOptions:f(L,"exportOptions")}:{}},f(L,"customize")!==void 0)throw new TypeError("Native customize callbacks are unsupported; use OfficeIMO xlsx/pdf options.");if(R==="xlsx"){const F=s(U.xlsx),H=s(W.xlsx);Z={...Z,xlsx:{...F,...H,...F.sheet||H.sheet?{sheet:{...F.sheet,...H.sheet}}:{}}}}else R==="csv"&&(Z={...Z,csv:{...t(U.csv),...t(W.csv)}});if(R==="pdf"){const F=m(j.buttons,"exportInfo",L),H={...n(U.pdf),...n(W.pdf)};for(const K of["title","messageTop","messageBottom"])if(f(L,K)!==void 0){if(f(L,K)===null){delete H[K];continue}const re=f(F,K);if(re===null||re===""){delete H[K];continue}if(typeof re!="string")throw new TypeError("PDF "+K+" must resolve to text.");H[K]=re}for(const K of["orientation","pageSize"])f(L,K)!==void 0&&Object.assign(H,{[K]:f(L,K)});f(L,"header")===!1&&(H.includeHeader=!1,delete H.headerRows),f(L,"footer")===!1&&delete H.footer,Z={...Z,pdf:H}}else if(f(L,"header")===!1||["title","messageTop","messageBottom"].some(F=>f(L,F)!=null))throw new TypeError("Use OfficeIMO xlsx.sheet title/footer options; native Buttons report layout options are unsupported.");const q=a(typeof Z.filename=="function"?Z.filename(L,j):Z.filename??"Export");if(typeof q!="string"||!q.trim())throw new TypeError("Export filename must be a non-empty string.");const X=a(f(m(j.buttons,"exportInfo",{filename:q,extension:""}),"filename"));if(typeof X!="string"||!X.trim())throw new TypeError("Resolved export filename must be a non-empty string.");const Y=await u(w,j,R,Z);await(Z.save??P)(Y,X.toLowerCase().endsWith("."+R)?X:X+"."+R)}catch(_){V(),Z.onError?await Z.onError(_):console.error("OfficeIMO table export failed.",_)}finally{V()}})().catch(_=>console.error("OfficeIMO export error handler failed.",_))}}}return Object.freeze({createDataTablesExport:Mt.createDataTablesExport,ExportCell:ve.ExportCell,PdfFont:$e.PdfFont,writeDataTableTo:h,exportDataTable:u,registerDataTablesButtons:c})})(),{createDataTablesExport:Cr,ExportCell:Sr,PdfFont:Rr,writeDataTableTo:vr,exportDataTable:Or,registerDataTablesButtons:Pr}=kr;export{Sr as ExportCell,Rr as PdfFont,Cr as createDataTablesExport,Or as exportDataTable,Pr as registerDataTablesButtons,vr as writeDataTableTo};
2
+ const me=(()=>{const S=Symbol.for("@evotecit/officeimo/OfficeIMOError"),O=Symbol.for("@evotecit/officeimo/NotSupportedError");class P extends Error{code;static[Symbol.hasInstance](m){return this!==P?Function.prototype[Symbol.hasInstance].call(this,m):!!m&&typeof m=="object"&&m[S]===!0}constructor(m,b,x){super(b,x),this.code=m,Object.defineProperty(this,S,{value:!0}),this.name="OfficeIMOError"}}class k extends P{feature;static[Symbol.hasInstance](m){return this!==k?Function.prototype[Symbol.hasInstance].call(this,m):!!m&&typeof m=="object"&&m[O]===!0}constructor(m){super("NOT_SUPPORTED",m+" is not supported yet."),this.feature=m,Object.defineProperty(this,O,{value:!0}),this.name="NotSupportedError"}}return Object.freeze({OfficeIMOError:P,NotSupportedError:k})})(),be=(()=>{function S(a){if(a?.aborted)throw a.reason}function O(a,c){return c?new Promise((i,r)=>{const n=()=>c.removeEventListener("abort",e),e=()=>{n(),r(c.reason)};c.addEventListener("abort",e,{once:!0}),Promise.resolve(a).then(t=>{n(),i(t)},t=>{n(),r(t)}),c.aborted&&e()}):Promise.resolve(a)}async function*P(a,c){S(c);const i=a?.[Symbol.asyncIterator]?.()??a?.[Symbol.iterator]?.();if(!i)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let r=!1,n=!1;try{for(;;){S(c);const e=await O(Promise.resolve(i.next()),c);if(S(c),e.done){r=!0;return}yield e.value}}catch(e){throw n=!0,e}finally{if(!r&&i.return)try{const e=i.return();c?.aborted||n?Promise.resolve(e).catch(()=>{}):await O(Promise.resolve(e),c)}catch(e){if(!c?.aborted&&!n)throw e}}}const k=new WeakMap;function C(a){let c=!1;const i=()=>{if(c)throw new TypeError("A row source can be consumed only once.");c=!0},r={[Symbol.asyncIterator](){return i(),n()}};async function*n(){for await(const e of P(a))yield*e}return k.set(r,(e,t)=>(i(),m(a,e,h=>m(h,e,t)))),r}function y(...a){const c={async*[Symbol.asyncIterator](){for(const i of a)yield*i}};return k.set(c,async(i,r)=>{for(const n of a)await m(n,i,r)}),c}async function m(a,c,i){S(c);const r=k.get(a);if(r)return r(c,i);const n=a?.[Symbol.asyncIterator]?.()??a?.[Symbol.iterator]?.();if(!n)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let e=!1;try{for(;;){S(c);let t=n.next();const h=t;typeof h?.then=="function"&&(t=await O(h,c)),S(c);const l=t;if(l.done){e=!0;return}let f=l.value;typeof f?.then=="function"&&(f=await O(f,c)),S(c);const d=i(f);d!==void 0&&await O(d,c)}}finally{if(!e&&n.return)try{Promise.resolve(n.return()).catch(()=>{})}catch{}}}let b;const x=32;function p(){b=performance.now()+x}function u(){const a=performance.now();return b??=a+x,a>=b}function o(){const a=globalThis.scheduler;return typeof a?.postTask=="function"?a.postTask(()=>{b=performance.now()+x},{priority:"user-visible"}):new Promise(c=>{setTimeout(function(){b=performance.now()+x,c()},0)})}return Object.freeze({checkAbort:S,withAbort:O,inputRows:P,rowsFromBatches:C,concatRows:y,consumeRows:m,beginTask:p,taskYieldDue:u,pause:o})})(),Ie=(()=>{const{checkAbort:S,consumeRows:O,withAbort:P,pause:k,taskYieldDue:C}=be,{OfficeIMOError:y}=me;async function m(o,s){if(o&&typeof o.getWriter=="function"){const a=o.getWriter();try{return await s({write:c=>a.write(new Uint8Array(c))})}finally{a.releaseLock()}}if(!o||typeof o.write!="function")throw new TypeError("Destination must be a ByteSink or WritableStream.");return s(o)}class b{parts=[];state="open";result;write(s){if(this.state!=="open")throw new y("INVALID_STATE","Byte sink is closed.");this.parts.push(new Uint8Array(s))}toBlob(s="application/octet-stream"){if(this.state==="discarded")throw new y("INVALID_STATE","Byte sink was discarded.");return this.state="closed",this.result||(this.result=new Blob(this.parts,{type:s}),this.parts=[]),this.result.type===s?this.result:new Blob([this.result],{type:s})}takeChunks(){if(this.state!=="open")throw new y("INVALID_STATE","Byte sink is closed.");const s=this.parts;return this.parts=[],this.state="discarded",s}discard(){this.parts=[],this.result=void 0,this.state="discarded"}}class x{sink;signal;chunkSize;text="";encoder=new TextEncoder;constructor(s,a,c=32768){if(this.sink=s,this.signal=a,this.chunkSize=c,!Number.isInteger(c)||c<2)throw new RangeError("Text chunk size must be at least 2.")}append(s){return S(this.signal),this.text+=s,this.text.length>=this.chunkSize||C()}async flush(s=!1){for(S(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||!s)&&a--,!a)break;const c=this.encoder.encode(this.text.slice(0,a));this.text=this.text.slice(a),await P(Promise.resolve(this.sink.write(c)),this.signal),C()&&await k(),S(this.signal)}}async write(s){this.append(s)&&await this.flush()}async close(){await this.flush(!0)}}async function p(o,s,a){await O(o instanceof Uint8Array?[o]:o,a,c=>{if(!(c instanceof Uint8Array))throw new TypeError("Byte sources must yield Uint8Array chunks.");const i=s.write(c);return C()?Promise.resolve(i).then(()=>(S(a),k())):i})}return Object.freeze({withDestination:m,BlobByteSink:b,ChunkedTextSink:x,writeBytes:p})})(),Me=(()=>{function S(P){if(P===null||typeof P!="object")return!1;try{return!(P instanceof Date)&&!(Symbol.toStringTag in P)&&Object.prototype.toString.call(P)!=="[object Date]"?!1:(Date.prototype.getTime.call(P),!0)}catch{return!1}}return Object.freeze({isDate:S})})(),et=(()=>{function S(P){if(!P||typeof P!="object")throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const{target:k,tooltip:C}=P;if(typeof k!="string"||!/^(?:https?:\/\/|mailto:)/i.test(k)||/[\u0000-\u0020\u007f]/.test(k))throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const y=new URL(k);if((y.protocol==="http:"||y.protocol==="https:")&&(!y.hostname||y.username||y.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:y.href,...C===void 0?{}:{tooltip:C}})}return Object.freeze({copyExportLink:S})})(),ve=(()=>{const{isDate:S}=Me,{copyExportLink:O}=et,P=Symbol.for("@evotecit/officeimo/ExportCell");function k(x){if(!x||typeof x!="object"||Array.isArray(x))throw new TypeError("Cell presentation must be an object.");const p={};for(const u of["background","color","numberFormat","bold","italic","wrapText","alignment"]){const o=x[u];if(o!==void 0){if(["bold","italic","wrapText"].includes(u)){if(typeof o!="boolean")throw new TypeError("Cell presentation "+u+" must be boolean.")}else if(typeof o!="string")throw new TypeError("Cell presentation "+u+" must be text.");if(u==="alignment"&&!["left","center","right","fill","justify","distributed"].includes(o))throw new TypeError("Invalid cell presentation alignment.");p[u]=o}}return Object.freeze(p)}class C{value;static[Symbol.hasInstance](p){return!!p&&typeof p=="object"&&p[P]===!0}text;presentation;link;constructor(p,u={}){this.value=p;const{text:o,presentation:s,link:a}=u;if(o!==void 0&&typeof o!="string")throw new TypeError("Display text must be a string.");y(p),this.text=o,this.presentation=s===void 0?void 0:k(s),this.link=a===void 0?void 0:O(a),Object.defineProperty(this,P,{value:!0}),Object.freeze(this)}}function y(x){const p=typeof x;if(!(x==null||p==="string"||p==="number"||p==="boolean"||S(x)))throw typeof x.then=="function"&&Promise.resolve(x).catch(()=>{}),new TypeError("Export values and formatter results must be synchronous strings, numbers, booleans, Dates or null.")}function m(x){x!==null&&typeof x=="object"&&x instanceof C||y(x)}return Object.freeze({copyCellPresentation:k,ExportCell:C,assertScalar:y,assertExportValue:m})})(),Ce=(()=>{function S(P,k){const C={...P};for(const y of k){if(Object.hasOwn(C,y))continue;const m=P[y];m!==void 0&&(C[y]=m)}return C}return Object.freeze({captureFields:S})})(),We=(()=>{const{OfficeIMOError:S}=me,{captureFields:O}=Ce;class P{cells=0;text=0;reservedCells=0;reservedText=0;limits;constructor(m={}){if(!m||typeof m!="object"||Array.isArray(m))throw new TypeError("Export limits must be an object.");const b=O(m,["maxRows","maxCells","maxTextCharacters","maxOutputBytes"]);for(const[x,p]of Object.entries(b))if(p!==void 0&&(!Number.isSafeInteger(p)||p<0))throw new RangeError(x+" must be a nonnegative safe integer.");this.limits=Object.freeze(b)}check(m,b){const x=this.limits[m];if(x!==void 0&&b>x)throw new S("RESOURCE_LIMIT",m+" exceeded ("+b+" > "+x+").")}row(m){this.check("maxRows",m)}reserve(m,b){this.check("maxCells",this.cells+this.reservedCells+m),this.check("maxTextCharacters",this.text+this.reservedText+b),this.reservedCells+=m,this.reservedText+=b}release(m,b){this.reservedCells-=m,this.reservedText-=b}cell(m,b){if(b!==void 0&&this.release(1,b),this.limits.maxCells===void 0&&this.limits.maxTextCharacters===void 0)return;this.check("maxCells",this.cells+this.reservedCells+1);const x=typeof m=="string"?m.length:0;this.check("maxTextCharacters",this.text+this.reservedText+x),this.cells++,this.text+=x}}function k(y,m){let b=0;return{write(x){return m.check("maxOutputBytes",b+x.length),b+=x.length,y.write(x)}}}return Object.freeze({ExportBudget:P,boundedSink:k})})(),Ne=(()=>{const{assertExportValue:S}=ve,{checkAbort:O}=be,{isDate:P}=Me,{captureFields:k}=Ce;function C(x,p,u,o=S){const s=x.some(a=>a.value);return(a,c=0)=>{if(Array.isArray(a)&&!s){const i=a.length;if(i>x.length)throw new RangeError("Row has more values than declared columns.");const r=new Array(i);for(let n=0;n<i;n++){const e=a[n];o(e),r[n]=e}return r}if(!a||typeof a!="object"||P(a))throw new TypeError("A row must be an array or object.");if(Array.isArray(a)&&a.length>x.length&&!x.every(i=>i.value))throw new RangeError("Project every column explicitly when selecting from a wider array row.");return x.map((i,r)=>{if(i.value){O(u);const t={rowIndex:c,columnIndex:r,column:i,...p?{sheetName:p.sheetName,worksheetRow:p.firstDataRow+c}:{}},h=i.value(a,t);return o(h),O(u),h}if(Array.isArray(a)){const t=a[r];return o(t),t}const n=i.key??i.header,e=Object.prototype.hasOwnProperty.call(a,n)?a[n]:void 0;return o(e),e})}}const y=["header","key","value","width","type","format","wrapText","alignment","rowHeader","groups","style","valueFormatter"];function m(x,p=!1){if(!Array.isArray(x))throw new TypeError("Declare the columns in export order.");return x.map(u=>{if(!u||typeof u!="object"&&typeof u!="function")throw new TypeError("Each column needs a string header and an optional string key.");const o=k(u,y);if(!p&&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 s=Array.from(o.groups);if(s.some(a=>typeof a!="string"))throw new TypeError("Column groups must be an array of strings.");return{...o,groups:Object.freeze(s)}}return o})}return Object.freeze({createRowProjector:C,columnOptionFields:y,copyColumns:m})})(),ht=(()=>{class S{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 y=C-this.mean;this.mean=this.count===1?C:Number.isFinite(y)?this.mean+y/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 O(k,C={}){const y=k.map(m=>m.key??m.header);for(const[m,b]of Object.entries(C)){if(y.filter(x=>x===m).length!==1)throw new TypeError("Totals need an unambiguous declared column key: "+m);if(!["sum","count","average","min","max"].includes(b))throw new TypeError("Invalid total operation.")}return y.map(m=>new S(Object.prototype.hasOwnProperty.call(C,m)?C[m]:void 0))}return Object.freeze({NumericAggregate:S,createTotals:O})})(),tt=(()=>{const{ExportCell:S,assertExportValue:O}=ve,{isDate:P}=Me;function k(y){if(O(y),P(y))return new Date(Date.prototype.getTime.call(y));if(y instanceof S){const{value:m,text:b,presentation:x,link:p}=y;return new S(P(m)?new Date(Date.prototype.getTime.call(m)):m,{...b===void 0?{}:{text:b},...x===void 0?{}:{presentation:x},...p===void 0?{}:{link:p}})}return y}return Object.freeze({copyExportValue:k})})(),Ue=(()=>{const{ExportCell:S,assertScalar:O}=ve,{isDate:P}=Me,{checkAbort:k,inputRows:C,pause:y,taskYieldDue:m}=be,{ExportBudget:b}=We,{OfficeIMOError:x}=me,{copyColumns:p,createRowProjector:u}=Ne,{createTotals:o}=ht,{copyExportValue:s}=tt,a=new WeakMap;function c(E){if(!E||typeof E!="object"||!a.has(E))throw new TypeError("Create grouped report sources with createGroupedReport.")}function i(E,R){return c(E),{async*[Symbol.asyncIterator](){const I=r(E,R);try{yield*I.events}finally{I.dispose()}}}}function r(E,R){c(E);const I=a.get(E),z=n(I.signal,R);return{signal:z.signal,events:I.events(z.signal),dispose:z.dispose}}function n(E,R){if(!E||!R||E===R)return{signal:E??R,dispose(){}};const I=new AbortController,z=()=>I.abort(E.reason),j=()=>I.abort(R.reason);return E.addEventListener("abort",z,{once:!0}),R.addEventListener("abort",j,{once:!0}),E.aborted?z():R.aborted&&j(),{signal:I.signal,dispose(){E.removeEventListener("abort",z),R.removeEventListener("abort",j)}}}function e(E,R,I){const z=E??R;if(!Number.isSafeInteger(z)||z<0)throw new RangeError(I+" must be a nonnegative safe integer.");return z}function t(E){return E instanceof S?E.value:E}function h(E){if(E==null)return{key:null,id:"null",text:""};if(P(E)){const I=Date.prototype.getTime.call(E);if(!Number.isFinite(I))throw new TypeError("A group key date must be valid.");return{key:new Date(I),id:"date:"+I,text:new Date(I).toISOString()}}if(typeof E=="number"&&!Number.isFinite(E))throw new TypeError("A numeric group key must be finite.");const R=String(E);return{key:E,id:typeof E+":"+R,text:R}}function l(E){return P(E)?new Date(Date.prototype.getTime.call(E)):E}function f(E){return Object.freeze(E.map(R=>R.operation===void 0?null:R.value()))}function d(E,R,I){const z=typeof E=="string"?[E]:Array.isArray(E)?Array.from(E):void 0;if(!z||z.length<1||z.length>4)throw new TypeError("groupBy must declare between one and four grouping levels.");if(I!==void 0&&typeof I!="function")throw new TypeError("groupLabel must be a synchronous function.");if(I&&z.length!==1)throw new TypeError("groupLabel is only available for one grouping level; use descriptor labels for a hierarchy.");const j=new Set;return Object.freeze(z.map(M=>{if(typeof M!="string"&&(!M||typeof M!="object"||Array.isArray(M)))throw new TypeError("A grouping level must name a stable column key or provide a descriptor.");const{key:L,value:B,label:q}=typeof M=="string"?{key:M,value:void 0,label:void 0}:M;if(typeof L!="string"||!L.length||j.has(L))throw new TypeError("Grouping levels need unique, nonempty stable keys.");if(j.add(L),B!==void 0&&typeof B!="function")throw new TypeError("Grouping value getters must be synchronous functions.");if(q!==void 0&&typeof q!="function")throw new TypeError("Grouping labels must be synchronous functions.");if(q&&I)throw new TypeError("Specify either groupLabel or the grouping descriptor label.");const G=R.indexOf(L);if(G>=0&&B!==void 0)throw new TypeError("A declared grouping column reuses its projected value; do not provide another value getter.");if(G<0&&B===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:L,column:G,value:B,label:q??I})}))}function g(E){return Object.freeze(E.map(({group:R})=>Object.freeze({...R,key:l(R.key)})))}function w(E,R,I){if(!E)return I;const z=E(l(R));if(typeof z?.then=="function"&&Promise.resolve(z).catch(()=>{}),typeof z!="string")throw new TypeError("Grouping labels must return synchronous text.");return z}function T(E,R){if(!R||typeof R!="object")throw new TypeError("Grouped report options are required.");const{columns:I,groupBy:z,totals:j,groupLabel:M,maxGroups:L,maxGroupKeyCharacters:B,signal:q,limits:G}=R;if(G!==void 0&&(!G||typeof G!="object"||Array.isArray(G)))throw new TypeError("Grouped source limits must be an object.");if(G!==void 0&&"maxOutputBytes"in G)throw new TypeError("Set maxOutputBytes on the format writer, not the grouped source.");if(!Array.isArray(I)||!I.length)throw new TypeError("A grouped report needs declared columns.");const _=p(I),F=_.map(ne=>ne.key);if(F.some(ne=>typeof ne!="string"||ne.length===0)||new Set(F).size!==F.length)throw new TypeError("Grouped report columns need unique, nonempty stable keys.");const W=d(z,F,M),U=Object.freeze({...j}),X=o(_,U);for(let ne=0;ne<_.length;ne++)if(X[ne].operation!==void 0&&_[ne].type!=="number")throw new TypeError("Grouped numeric totals require a column declared with type:number.");const V=e(L,1e3,"maxGroups"),Y=e(B,1e6,"maxGroupKeyCharacters"),re=new b(G),A=Object.freeze(_.map(ne=>{const{value:fe,...ye}=ne;return Object.freeze(ye)}));for(const ne of _){re.cell(ne.header);for(const fe of ne.groups??[])re.reserve(0,fe.length);Object.freeze(ne)}let $=!1;const J=ne=>Object.freeze({[Symbol.asyncIterator](){if($)throw new TypeError("A grouped report source can be consumed only once.");return $=!0,he(ne)}}),te=J(q);async function*he(ne){const fe=u(_,void 0,ne),ye=new Set,D=[];let H=0,N=0,Q=0;for await(const ie of C(E,ne)){const ce=Array.isArray(ie)?Array.from(ie):ie,ae=fe(ce,N),ue=[];for(let Z=0;Z<_.length;Z++)ue.push(s(ae[Z])??null);k(ne);const ge=W.map((Z,ee)=>{k(ne);const le=Z.column>=0?t(ue[Z.column]):Z.value(ce,Object.freeze({rowIndex:N,level:ee,key:Z.key}));return O(le),k(ne),h(le)});re.row(N+1);for(let Z=0;Z<ue.length;Z++){const ee=ue[Z],le=t(ee);if(X[Z].operation!==void 0&&le!=null&&(typeof le!="number"||!Number.isFinite(le)))throw new TypeError("Grouped numeric metrics must resolve to finite numbers or null.");re.cell(le),ee instanceof S&&ee.text!==void 0&&re.reserve(0,ee.text.length)}let oe=0;for(;oe<D.length&&D[oe].id===ge[oe].id;)oe++;const K=[];for(let Z=oe;Z<W.length;Z++){const ee=ge[Z],de=((K.at(-1)??D[Z-1])?.group.groupIndex??-1)+":"+ee.id;if(ye.has(de))throw new TypeError("Grouped rows must be contiguous; a closed group key occurred again within the same parent.");if(Q===V)throw new x("RESOURCE_LIMIT","maxGroups exceeded.");const pe=w(W[Z].label,ee.key,ee.text);k(ne);const Se=H+de.length+pe.length;if(!Number.isSafeInteger(Se)||Se>Y)throw new x("RESOURCE_LIMIT","maxGroupKeyCharacters exceeded.");re.reserve(0,pe.length),K.push({id:ee.id,group:Object.freeze({groupIndex:Q,key:ee.key,label:pe,level:Z}),rows:0,aggregates:o(_,U)}),H=Se,ye.add(de),Q++}for(;D.length>oe;){k(ne);const Z=g(D),ee=D.pop();yield Object.freeze({kind:"groupEnd",...Z.at(-1),path:Z,rows:ee.rows,totals:f(ee.aggregates)})}for(const Z of K){k(ne),D.push(Z);const ee=g(D);yield Object.freeze({kind:"groupStart",...ee.at(-1),path:ee})}for(let Z=0;Z<ue.length;Z++){const ee=t(ue[Z]);for(const le of D)le.aggregates[Z].accept(ee);X[Z].accept(ee)}for(const Z of D)Z.rows++;k(ne),yield Object.freeze({kind:"row",values:Object.freeze(ue),rowIndex:N,groupIndex:D.at(-1).group.groupIndex,path:g(D)}),N++,m()&&(await y(),k(ne))}for(k(ne);D.length;){k(ne);const ie=g(D),ce=D.pop();yield Object.freeze({kind:"groupEnd",...ie.at(-1),path:ie,rows:ce.rows,totals:f(ce.aggregates)})}k(ne),yield Object.freeze({kind:"complete",rows:N,groups:Q,totals:f(X)})}const se=Object.freeze({columns:A,groupBy:Object.freeze(W.map(ne=>ne.key)),totals:U,events:te});return a.set(se,{signal:q,events:J}),se}return Object.freeze({assertGroupedReportSource:c,groupedReportEvents:i,groupedReportOperation:r,createGroupedReport:T})})(),rt=(()=>{const{OfficeIMOError:S}=me;function O(){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 P(C,y){if(!(C instanceof Blob)||typeof y!="string"||!y)throw new TypeError("A Blob and file name are required.");if(typeof document>"u"||typeof URL.createObjectURL!="function")throw new S("PLATFORM_UNAVAILABLE","saveBlob requires a browser document and object URLs.");const m=URL.createObjectURL(C),b=document.createElement("a");try{b.href=m,b.download=y,document.body.append(b),b.click()}finally{b.remove(),setTimeout(()=>URL.revokeObjectURL(m),3e4)}}return Object.freeze({OfficeIMOError:me.OfficeIMOError,NotSupportedError:me.NotSupportedError,BlobByteSink:Ie.BlobByteSink,ChunkedTextSink:Ie.ChunkedTextSink,writeBytes:Ie.writeBytes,ExportCell:ve.ExportCell,createGroupedReport:Ue.createGroupedReport,checkAbort:be.checkAbort,withAbort:be.withAbort,inputRows:be.inputRows,pause:be.pause,detectFeatures:O,saveBlob:P})})(),Ge=(()=>{function S(P,k){if(!P)return;const C=P(k);if(C&&typeof C.then=="function")throw Promise.resolve(C).catch(()=>{}),new TypeError("onProgress must be synchronous.")}return Object.freeze({notifyProgress:S})})(),Ve=(()=>{const{assertExportValue:S}=ve,{copyExportValue:O}=tt;function P(y,m){if(!Array.isArray(y)||!y.length||y.length>16)throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");const b=y.map(x=>{if(!Array.isArray(x)||x.length!==m)throw new TypeError("Spanned rows must have the declared column count.");return Object.freeze(x.map(p=>{if(p===null)return null;if(!p||typeof p!="object")throw new TypeError("Uncovered heading/footer cells need an anchor value.");const{value:u,columnSpan:o,rowSpan:s}=p;return Object.freeze({value:O(u),...o===void 0?{}:{columnSpan:o},...s===void 0?{}:{rowSpan:s}})}))});return k(b,m),Object.freeze(b)}function k(y,m){if(!Array.isArray(y)||!y.length||y.length>16)throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");const b=Array.from({length:y.length},()=>new Uint8Array(m));return y.map((x,p)=>{if(!Array.isArray(x)||x.length!==m)throw new TypeError("Spanned rows must have the declared column count.");const u=[];for(let o=0;o<m;o++){const s=x[o];if(b[p][o]){if(s!==null)throw new TypeError("Covered heading/footer cells must be null.");continue}if(!s||typeof s!="object")throw new TypeError("Uncovered heading/footer cells need an anchor value.");const a=s.columnSpan??1,c=s.rowSpan??1;if(!Number.isInteger(a)||!Number.isInteger(c)||a<1||c<1||o+a>m||p+c>y.length)throw new RangeError("Heading/footer spans must stay inside the declared matrix.");const i=s.value;S(i);for(let r=p;r<p+c;r++)for(let n=o;n<o+a;n++){if(b[r][n])throw new TypeError("Heading/footer spans overlap.");if((r!==p||n!==o)&&y[r]?.[n]!==null)throw new TypeError("Covered heading/footer cells must be null.");b[r][n]=1}u.push(Object.freeze({first:o,span:a,rowSpan:c,value:i}))}return Object.freeze(u)})}return Object.freeze({captureTableSpans:P,tableSpans:k})})(),Ut=(()=>{const{captureTableSpans:S,tableSpans:O}=Ve;function P(C,y,m){const b=O(S(C,y),y),x=b.map(()=>Array(y).fill(""));for(let p=0;p<b.length;p++)for(const u of b[p]){if((u.span>1||u.rowSpan>1)&&m===void 0)throw new TypeError("CSV spanned headings/footers require an explicit spanMode: repeat or anchors.");const o=u.value;for(let s=p;s<p+(m==="repeat"?u.rowSpan:1);s++)for(let a=u.first;a<u.first+(m==="repeat"?u.span:1);a++)x[s][a]=o}return x}return Object.freeze({csvStructuredRows:P})})(),dt=(()=>{const S=Object.freeze({true:"True",false:"False"});function O(k){if(k===void 0)return S;if(!k||typeof k!="object")throw new TypeError("booleanText must contain true and false strings.");const C=k.true,y=k.false;if(typeof C!="string"||typeof y!="string")throw new TypeError("booleanText must contain true and false strings.");return Object.freeze({true:C,false:y})}return Object.freeze({defaultBooleanText:S,captureBooleanText:O})})(),vt=(()=>{const{captureFields:S}=Ce;function O(k){if(!k||typeof k!="object")throw new TypeError("CSV options are required.");return S(k,["columns","signal","limits","onProgress","valueMode","delimiter","lineEnding","bom","includeHeader","headerRows","footer","spanMode","formulaInjectionProtection","quote","nullValue","booleanText"])}return Object.freeze({captureCsvOptions:O})})(),Ht=(()=>{const{beginTask:S,checkAbort:O,consumeRows:P,taskYieldDue:k,withAbort:C}=be,{BlobByteSink:y,ChunkedTextSink:m,withDestination:b}=Ie,{ExportBudget:x,boundedSink:p}=We,{ExportCell:u}=ve,{isDate:o}=Me,{notifyProgress:s}=Ge,{copyColumns:a,createRowProjector:c}=Ne,{csvStructuredRows:i}=Ut,{captureBooleanText:r}=dt,{captureCsvOptions:n}=vt;function e(d,g,w,T,v){const E=typeof d;let R;if(d==null)R="";else if(E==="string")R=d;else{if(E==="number")return R=Number.isFinite(d)?String(d):"",T==="all"?'"'+R+'"':R;if(E==="boolean")R=v[d?"true":"false"];else if(o(d))R=Number.isFinite(d.getTime())?d.toISOString():"";else throw typeof d.then=="function"&&Promise.resolve(d).catch(()=>{}),new TypeError("CSV cells and formatter results must be synchronous strings, numbers, booleans, Dates or null.")}return w&&(E==="string"||E==="boolean")&&R.charCodeAt(0)<=64&&/^ *[=+\-@\t\r\n]/.test(R)&&(R="'"+R),T==="all"||T==="strings"&&E==="string"||R.includes(g)||/["\r\n]/.test(R)?'"'+(R.includes('"')?R.replace(/"/g,'""'):R)+'"':R}async function t(d,g,w){const T=n(w);return b(g,v=>h(d,v,T))}async function h(d,g,w){S();const T=a(w.columns).map(Y=>Object.freeze(Y)),v=w.delimiter??",",E=w.lineEnding??"\r\n",R=w.quote??"minimal",I=r(w.booleanText);if(![",",";"," "].includes(v))throw new RangeError("Delimiter must be comma, semicolon or tab.");if(!["\r\n","\n","\r"].includes(E))throw new RangeError("Invalid line ending.");if(!["minimal","all","strings"].includes(R))throw new RangeError("Quoting must be minimal, all or strings.");if(w.valueMode!==void 0&&!["raw","display"].includes(w.valueMode))throw new RangeError("valueMode must be raw or display.");if(w.nullValue!==void 0&&typeof w.nullValue!="string")throw new TypeError("nullValue must be a string.");if(w.spanMode!==void 0&&w.spanMode!=="repeat"&&w.spanMode!=="anchors")throw new TypeError("CSV spanMode must be repeat or anchors.");const z=w.includeHeader===!1?[]:w.headerRows===void 0?T.length?[T.map(Y=>Y.header)]:[]:i(w.headerRows,T.length,w.spanMode),j=w.footer===void 0?[]:i(w.footer.rows,T.length,w.spanMode);for(const Y of T)if(Y.valueFormatter!==void 0&&typeof Y.valueFormatter!="function")throw new TypeError("CSV value formatters must be functions.");const M=new x(w.limits);let L=0;const B=g;g=p({async write(Y){await B.write(Y),L+=Y.byteLength}},M);const q=c(T,void 0,w.signal),G=T.some(Y=>Y.valueFormatter),_=w.signal,F=w.formulaInjectionProtection!==!1,W=new m(g,_);O(_),w.bom&&await C(Promise.resolve(g.write(new Uint8Array([239,187,191]))),_);let U=0;const X=Y=>Y!==null&&typeof Y=="object"&&Y instanceof u?w.valueMode==="display"&&Y.text!==void 0?Y.text:Y.value:Y;function V(Y,re=!1,A=0,$){!re&&G&&A===0&&($=Object.freeze(T.map((te,he)=>X(Y[he]))));let J="";for(let te=A;te<T.length;te++){O(_);const he=T[te],se=X(Y[te]);let ne=!re&&he.valueFormatter?he.valueFormatter(se,{rowIndex:U,columnIndex:te,column:he,values:$}):se;if(ne==null&&w.nullValue!==void 0&&(ne=w.nullValue),M.cell(typeof ne=="boolean"?I[ne?"true":"false"]:ne),O(_),J+=(te?v:"")+e(ne,v,F,R,I),J.length>=W.chunkSize||(te&127)===127&&k()){if(W.append(J))return W.flush().then(()=>V(Y,re,te+1,$));J=""}}if(W.append(J+E))return W.flush().then(()=>{s(w.onProgress,{phase:"rows",rows:U+(re?0:1)})})}for(const Y of z)await V(Y,!0);await P(d,_,Y=>{M.row(U+1);const re=V(q(Y,U));if(re)return re.then(()=>{U++});U++});for(const Y of j)await V(Y,!0);return await W.close(),s(w.onProgress,{phase:"complete",rows:U,bytes:L}),O(_),{rows:U,columns:T.length,bytes:L}}async function l(d,g){const w=n(g),T=new y;try{let v=0;await h(d,T,{...w,onProgress:R=>{R.phase==="complete"?v=R.rows:s(w.onProgress,R)}});const E=T.toBlob("text/csv;charset=utf-8");return s(w.onProgress,{phase:"complete",rows:v,bytes:E.size}),O(w.signal),E}catch(v){throw T.discard(),v}}return Object.freeze({saveBlob:rt.saveBlob,ExportCell:ve.ExportCell,writeCsvTo:t,writeCsv:l})})(),nt=(()=>{const{OfficeIMOError:S}=me;function O(y){const m=()=>new S("INVALID_PART_URI","Invalid OPC part URI: "+y);if(typeof y!="string"||!y.startsWith("/")||/[^A-Za-z0-9\-._~!$&'()*+,;=:@%/]/.test(y)||y.split("/").slice(1).some(b=>!b||b.endsWith(".")||/^\.+$/.test(b))||/%(?![\da-f]{2})/i.test(y))throw m();for(const b of y.matchAll(/%([\da-f]{2})/gi)){const x=String.fromCharCode(parseInt(b[1],16));if(/[A-Za-z0-9_.~\-/\\]/.test(x))throw m()}try{decodeURIComponent(y)}catch{throw m()}return y.replace(/%[\da-f]{2}/gi,b=>b.toUpperCase())}function P(y){if(y==="/")return"/_rels/.rels";const m=O(y),b=m.lastIndexOf("/");return m.slice(0,b+1)+"_rels/"+m.slice(b+1)+".rels"}function k(y,m){const b=O(m).slice(1).split("/"),x=y==="/"?[]:O(y).slice(1).split("/").slice(0,-1);for(;x.length&&x[0]===b[0];)x.shift(),b.shift();const p="../".repeat(x.length)+b.join("/");return p.split("/",1)[0].includes(":")?"./"+p:p}return Object.freeze({partUri:O,relationshipPartUri:P,relativePartTarget:k})})(),Pe=(()=>{const{OfficeIMOError:S}=me,{ChunkedTextSink:O}=Ie,P='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',k={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;","\r":"&#13;","\n":"&#10;"," ":"&#9;"};function C(u,o="strip"){if(o!=="strip"&&o!=="reject")throw new TypeError("Invalid XML character policy.");const s=String(u),a=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\ud800-\udfff\ufffe\uffff]/gu;if(o==="reject"&&a.test(s))throw new S("INVALID_XML","Text contains XML 1.0-invalid characters.");return s.replace(a,"")}function y(u,o="strip"){return C(u,o).replace(/[&<>"'\r\n\t]/g,s=>k[s])}function m(u,o="strip"){const s={"\r":"_x000D_","\n":"_x000A_"," ":"_x0009_"},a=C(u,o).replace(/_(?=x[0-9a-f]{4}_)|[\r\n\t]/gi,c=>c==="_"?"_x005F_":s[c]);return y(a,o)}function b(u){if(typeof u!="string"||!/^[A-Za-z_][A-Za-z0-9_.-]*(?::[A-Za-z_][A-Za-z0-9_.-]*)?$/.test(u))throw new S("INVALID_XML","Invalid XML name: "+u);return u}class x{policy;sink;stack=[];roots=0;closed=!1;constructor(o,s="strip",a){this.policy=s,C("",s),this.sink=new O(o,a),this.sink.append(P)}async startElement(o,s={}){this.open(),b(o);const a="<"+o+Object.entries(s).map(([c,i])=>" "+b(c)+'="'+y(i,this.policy)+'"').join("")+">";if(!this.stack.length&&this.roots++)throw new S("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 S("INVALID_XML","Text needs an open element.");await this.sink.write(y(o,this.policy))}async endElement(){this.open();const o=this.stack.pop();if(!o)throw new S("INVALID_XML","No open XML element.");await this.sink.write("</"+o+">")}async close(){if(this.open(),this.stack.length||this.roots!==1)throw new S("INVALID_XML","XML document is incomplete.");await this.sink.close(),this.closed=!0}open(){if(this.closed)throw new S("INVALID_STATE","XML writer is closed.")}}return Object.freeze({xmlDeclaration:P,cleanXml:C,escapeXml:y,escapeOoxmlAttribute:m,validateXmlName:b,XmlWriter:x})})(),ft=(()=>{const{escapeXml:S,xmlDeclaration:O}=Pe,{isDate:P}=Me;function k(m={},b="strip"){const x=m.created??new Date,p=m.modified??x;if(!P(x)||!P(p)||!Number.isFinite(x.getTime())||!Number.isFinite(p.getTime()))throw new TypeError("Invalid workbook property date.");return O+'<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>'+S(m.creator??"",b)+"</dc:creator><dc:title>"+S(m.title??"",b)+"</dc:title>"+(m.subject===void 0?"":"<dc:subject>"+S(m.subject,b)+"</dc:subject>")+(m.description===void 0?"":"<dc:description>"+S(m.description,b)+"</dc:description>")+'<dcterms:created xsi:type="dcterms:W3CDTF">'+x.toISOString()+'</dcterms:created><dcterms:modified xsi:type="dcterms:W3CDTF">'+p.toISOString()+"</dcterms:modified></cp:coreProperties>"}function C(m={},b="strip"){return O+'<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"><Application>'+S(m.application??"OfficeIMO",b)+"</Application><Company>"+S(m.company??"",b)+"</Company></Properties>"}return Object.freeze({corePropertiesXml:k,appPropertiesXml:C})})(),ut=(()=>{const S=new Uint32Array(256).map((k,C)=>{let y=C;for(let m=0;m<8;m++)y=y&1?3988292384^y>>>1:y>>>1;return y>>>0});class O{crc=4294967295;update(C){let y=this.crc;for(let m=0;m<C.length;m++)y=S[(y^C[m])&255]^y>>>8;this.crc=y}get value(){return(this.crc^4294967295)>>>0}}return Object.freeze({Crc32:O})})(),pt=(()=>{const{checkAbort:S,withAbort:O}=be,{OfficeIMOError:P}=me,{Crc32:k}=ut,C=4294967295;function y(x){if(!Number.isSafeInteger(x)||x<0||x>=C)throw new P("ZIP64_REQUIRED","Classic ZIP entries and archives must stay below 4 GiB; ZIP64 is not supported yet.");return x}class m{sink;signal;method;writer;reader;drain;crc=new k;size=0;compressedSize=0;failed=!1;failure;closed=!1;cleaned=!1;lifetime=new AbortController;abort=()=>{this.fail(this.signal?.reason)};constructor(p,u,o){if(this.sink=u,this.signal=o,p!=="auto"&&p!=="store")throw new RangeError("compression must be auto or store.");S(o);let s;if(p==="auto"&&typeof CompressionStream=="function")try{s=new CompressionStream("deflate-raw")}catch(a){if(!(a instanceof TypeError))throw a}this.method=s?8:0,this.writer=s?.writable.getWriter(),this.reader=s?.readable.getReader(),o?.addEventListener("abort",this.abort,{once:!0}),this.drain=this.reader?this.consume(this.reader):Promise.resolve()}async consume(p){try{for(;;){const{value:u,done:o}=await O(p.read(),this.lifetime.signal);if(o)return;S(this.signal),this.compressedSize=y(this.compressedSize+u.length),await O(Promise.resolve(this.sink.write(u)),this.lifetime.signal)}}catch(u){this.fail(u)}}fail(p){this.failed||(this.failed=!0,this.failure=p,this.lifetime.abort(p),this.cleaned||(this.writer?.abort(p).catch(()=>{}),this.reader?.cancel(p).catch(()=>{})))}async write(p){if(S(this.signal),this.failed)throw this.failure;if(this.closed)throw new P("INVALID_STATE","ZIP entry is closed.");if(!(p instanceof Uint8Array))throw new TypeError("ZIP chunks must be Uint8Array.");this.size=y(this.size+p.length),this.crc.update(p),this.writer?await O(this.writer.write(new Uint8Array(p)),this.lifetime.signal):(await O(Promise.resolve(this.sink.write(p)),this.lifetime.signal),this.compressedSize=this.size)}async close(){try{if(S(this.signal),this.failed)throw this.failure;if(this.closed)throw new P("INVALID_STATE","ZIP entry is closed.");if(this.closed=!0,this.writer&&await O(this.writer.close(),this.lifetime.signal),await this.drain,this.failed)throw this.failure;return S(this.signal),{crc:this.crc.value,size:this.size,compressedSize:this.compressedSize,method:this.method}}finally{this.cleanup()}}async discard(p){this.fail(p),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:ut.Crc32,zipLimit:C,zipSize:y,EntryWriter:m})})(),Wt=(()=>{const{EntryWriter:S,zipSize:O}=pt,{checkAbort:P,withAbort:k,pause:C,taskYieldDue:y}=be,{OfficeIMOError:m}=me,{BlobByteSink:b,writeBytes:x}=Ie,{captureFields:p}=Ce,u=new TextEncoder;function o(i){if(typeof i!="string"||!i||/[\u0000-\u001f\\]/.test(i)||i.startsWith("/")||/^[A-Za-z]:/.test(i)||i.split("/").some(r=>!r||r==="."||r===".."))throw new TypeError("ZIP entry names must be relative paths without empty, dot or parent segments.");for(let r=0;r<i.length;r++){const n=i.charCodeAt(r);if(n>=55296&&n<=56319){const e=i.charCodeAt(++r);if(!(e>=56320&&e<=57343))throw new TypeError("ZIP entry names must contain well-formed Unicode.")}else if(n>=56320&&n<=57343)throw new TypeError("ZIP entry names must contain well-formed Unicode.")}if(u.encode(i).length>65535)throw new RangeError("ZIP entry name exceeds 65,535 UTF-8 bytes.");return i}function s(i,r,n=new Uint8Array){const e=new Uint8Array(r+n.length),t=new DataView(e.buffer);return t.setUint32(0,i,!0),e.set(n,r),{bytes:e,data:t}}class a{sink;owned;names=new Set;central=[];offset=0;active;state="open";options;lifetime=new AbortController;disposal;constructor(r,n={}){const e=p(n,["compression","signal","maxOutputBytes"]),{compression:t,maxOutputBytes:h}=e;if(h!==void 0&&(!Number.isSafeInteger(h)||h<0))throw new RangeError("maxOutputBytes must be a nonnegative safe integer.");if(t!==void 0&&t!=="auto"&&t!=="store")throw new RangeError("compression must be auto or store.");this.options=Object.freeze(e),this.owned=r?void 0:new b,this.sink=r??this.owned}async acceptance(r){const n=this.options.signal,e=()=>this.lifetime.abort(n?.reason);n?.addEventListener("abort",e,{once:!0});try{return P(n),P(this.lifetime.signal),await k(Promise.resolve(r()),this.lifetime.signal)}finally{n?.removeEventListener("abort",e)}}async emit(r){if(this.options.maxOutputBytes!==void 0&&this.offset+r.length>this.options.maxOutputBytes)throw new m("RESOURCE_LIMIT","maxOutputBytes exceeded.");this.offset=O(this.offset+r.length),await this.acceptance(()=>this.sink.write(r))}reserve(r){if(P(this.options.signal),this.state!=="open")throw new m("INVALID_STATE","ZIP writer is busy, failed or finalized.");if(o(r),this.names.has(r))throw new TypeError("Duplicate ZIP entry: "+r);if(this.names.size>=65534)throw new m("ZIP64_REQUIRED","ZIP64 is required for 65,535 entries.");return this.names.add(r),this.state="writing",u.encode(r)}local(r,n,e){const t=s(67324752,30,r);return t.data.setUint16(4,20,!0),t.data.setUint16(6,e?2056:2048,!0),t.data.setUint16(8,n.method,!0),t.data.setUint16(12,33,!0),t.data.setUint16(26,r.length,!0),t.bytes}record(r,n,e,t){const h=s(33639248,46,r);h.data.setUint16(4,20,!0),h.data.setUint16(6,20,!0),h.data.setUint16(8,t?2056:2048,!0),h.data.setUint16(10,n.method,!0),h.data.setUint16(14,33,!0),h.data.setUint32(16,n.crc,!0),h.data.setUint32(20,n.compressedSize,!0),h.data.setUint32(24,n.size,!0),h.data.setUint16(28,r.length,!0),h.data.setUint32(42,e,!0),this.central.push(h.bytes)}async openEntry(r){const n=this.reserve(r),e=this.offset;let t;try{t=new S(this.options.compression??"auto",{write:w=>this.emit(w)},this.options.signal),await this.emit(this.local(n,t,!0));const h=t;let l=!1,f=!1,d;const g=async w=>{f=!0,this.state="failed",this.lifetime.abort(w),await h.discard(w),this.owned?.discard(),this.active=void 0};return this.active={write:async w=>{if(l||f||this.state!=="writing")throw new m("INVALID_STATE","Await the current ZIP entry operation.");l=!0;try{await h.write(w)}catch(T){throw await g(T),T}finally{l=!1}},close:()=>{if(d)return d;if(l||f||this.state!=="writing")throw new m("INVALID_STATE","ZIP entry is busy or closed.");return f=!0,d=(async()=>{try{const w=await h.close(),T=s(134695760,16);return T.data.setUint32(4,w.crc,!0),T.data.setUint32(8,w.compressedSize,!0),T.data.setUint32(12,w.size,!0),await this.emit(T.bytes),this.record(n,w,e,!0),this.state="open",this.active=void 0,w}catch(w){throw await g(w),w}})(),d},discard:g}}catch(h){throw this.state="failed",await t?.discard(h),this.owned?.discard(),h}}async add(r,n){const e=await this.openEntry(r);try{typeof n=="function"?await this.acceptance(()=>n(e)):await this.acceptance(()=>x(n,e,this.lifetime.signal)),await e.close()}catch(t){throw await e.discard(t),t}}get bytesWritten(){return this.offset}discard(r){return this.state="failed",this.lifetime.abort(r),this.disposal??=(async()=>{await this.active?.discard(r),this.owned?.discard()})()}async addPrepared(r,n){const e=this.reserve(r),t=this.offset;try{const h=this.local(e,n,!1),l=new DataView(h.buffer);l.setUint32(14,n.crc,!0),l.setUint32(18,n.compressedSize,!0),l.setUint32(22,n.size,!0),await this.emit(h);for(const f of n.chunks)P(this.options.signal),await this.emit(f);this.record(e,n,t,!1),this.state="open"}catch(h){throw this.state="failed",this.owned?.discard(),h}}async finish(){if(P(this.options.signal),this.state!=="open")throw new m("INVALID_STATE","ZIP writer is busy, failed or finalized.");this.state="writing";const r=this.offset;try{for(let e=0;e<this.central.length;e++)await this.emit(this.central[e]),e%256===255&&y()&&await C();const n=s(101010256,22);n.data.setUint16(8,this.central.length,!0),n.data.setUint16(10,this.central.length,!0),n.data.setUint32(12,this.offset-r,!0),n.data.setUint32(16,r,!0),await this.emit(n.bytes),P(this.options.signal),this.state="finished"}catch(n){throw this.state="failed",this.owned?.discard(),n}}async toBlob(r="application/zip"){if(!this.owned)throw new m("INVALID_STATE","This ZIP uses a caller-owned sink; use finish().");return this.state!=="finished"&&await this.finish(),this.owned.toBlob(r)}}return Object.freeze({Crc32:pt.Crc32,validateEntryName:o,ZipWriter:a})})(),st=(()=>{const{partUri:S,relationshipPartUri:O,relativePartTarget:P}=nt,{corePropertiesXml:k,appPropertiesXml:C}=ft,{ZipWriter:y}=Wt,{ChunkedTextSink:m}=Ie,{OfficeIMOError:b}=me,{escapeXml:x,xmlDeclaration:p}=Pe,{checkAbort:u,pause:o,taskYieldDue:s}=be,{captureFields:a}=Ce,c="http://schemas.openxmlformats.org/package/2006/relationships",i="http://schemas.openxmlformats.org/officeDocument/2006/relationships",r="http://schemas.openxmlformats.org/package/2006/content-types",n={officeDocument:i+"/officeDocument",worksheet:i+"/worksheet",styles:i+"/styles",theme:i+"/theme",customXml:i+"/customXml",coreProperties:c+"/metadata/core-properties",appProperties:i+"/extended-properties"};function e(f){if(typeof f!="string"||!/^[\w!#$&^.+-]+\/[\w!#$&^.+-]+$/.test(f))throw new TypeError("Invalid content type.");return f}class t{defaults=new Map([["rels","application/vnd.openxmlformats-package.relationships+xml"],["xml","application/xml"]]);overrides=new Map;addDefault(d,g){if(!/^[A-Za-z0-9]+$/.test(d))throw new TypeError("Invalid part extension.");const w=d.toLowerCase(),T=this.defaults.get(w);if(T!==void 0&&T!==g)throw new TypeError("Conflicting default content type.");this.defaults.set(w,e(g))}addOverride(d,g){if(d=S(d),this.overrides.has(d.toLowerCase()))throw new TypeError("Duplicate content-type override.");this.overrides.set(d.toLowerCase(),{uri:d,type:e(g)})}toXml(){return p+'<Types xmlns="'+r+'">'+[...this.defaults].map(([d,g])=>'<Default Extension="'+x(d)+'" ContentType="'+x(g)+'"/>').join("")+[...this.overrides.values()].map(({uri:d,type:g})=>'<Override PartName="'+x(d)+'" ContentType="'+x(g)+'"/>').join("")+"</Types>"}}class h{types=new t;parts=new Map;directories=new Set;relationships=new Map;state="open";result;zip;options;constructor(d={}){this.options=Object.freeze(a(d,["compression","signal","maxOutputBytes","invalidCharacterPolicy","sink"])),this.zip=new y(this.options.sink,this.options)}open(){if(this.state!=="open")throw new b("INVALID_STATE","OPC package is finalized.")}reserve(d,g){if(this.open(),typeof d=="string"&&d.length>65536)throw new b("RESOURCE_LIMIT","OPC part name exceeds the ZIP entry-name limit.");d=S(d);let w=0;for(let E=0;E<d.length;E++)if(d[E]==="/"&&++w>64)throw new b("RESOURCE_LIMIT","OPC part name exceeds the directory-depth limit.");if(/\/_rels(?:\/|$)/i.test(d)||d.toLowerCase()==="/[content_types].xml")throw new TypeError("Package metadata part names are reserved.");const T=d.toLowerCase();if(this.parts.has(T))throw new TypeError("Duplicate OPC part: "+d);if(this.directories.has(T))throw new TypeError("OPC part-name prefix collision: "+d+" is an ancestor of an existing part.");const v=[];for(let E=T.lastIndexOf("/");E>0;E=T.lastIndexOf("/",E-1)){const R=T.slice(0,E);if(this.parts.has(R))throw new TypeError("OPC part-name prefix collision: "+d+" descends from "+this.parts.get(R).uri);v.push(R)}this.types.addOverride(d,g);for(const E of v)this.directories.add(E);return d}addPart(d){const{uri:g,contentType:w,data:T}=d,v=T instanceof Uint8Array?new Uint8Array(T):T,E=this.reserve(g,w);this.parts.set(E.toLowerCase(),{uri:E,contentType:w,data:v})}addPrepared(d,g,w){d=this.reserve(d,g),this.parts.set(d.toLowerCase(),{uri:d,prepared:w})}async openPart(d,g){if(!this.options.sink)throw new b("INVALID_STATE","openPart requires a caller-owned package sink.");d=this.reserve(d,g),this.parts.set(d.toLowerCase(),{uri:d,written:!0});try{return await this.zip.openEntry(d.slice(1))}catch(w){throw await this.discard(w),w}}addRelationship(d,g){u(this.options.signal),this.open(),d=d==="/"?d:S(d);const{id:w,type:T,target:v,external:E}=g;if(this.open(),!/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(w))throw new TypeError("Relationship id must be an XML ID.");if(!/^[A-Za-z][A-Za-z0-9+.-]*:[^\s<>"']+$/.test(T))throw new TypeError("Relationship type must be an absolute URI.");const R=E?v:S(v);if(E&&(!R||/[\u0000-\u0020]/.test(R)))throw new TypeError("Invalid external relationship target.");const I=d.toLowerCase(),z=this.relationships.get(I)??new Map;if(z.has(w))throw new TypeError("Duplicate relationship id: "+w);z.set(w,{id:w,type:T,target:R,...E===void 0?{}:{external:E}}),this.relationships.set(I,z)}setProperties(d={},g={}){const w=k(d,this.options.invalidCharacterPolicy),T=C(g,this.options.invalidCharacterPolicy);this.addPart({uri:"/docProps/core.xml",contentType:"application/vnd.openxmlformats-package.core-properties+xml",data:w}),this.addPart({uri:"/docProps/app.xml",contentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml",data:T}),this.addRelationship("/",{id:"core",type:n.coreProperties,target:"/docProps/core.xml"}),this.addRelationship("/",{id:"app",type:n.appProperties,target:"/docProps/app.xml"})}source(d){return typeof d=="string"?async g=>{const w=new m(g,this.options.signal);await w.write(d),await w.close()}:d instanceof Blob?(async function*(){for(let g=0;g<d.size;g+=65536){let w;try{w=await d.slice(g,g+65536).arrayBuffer()}catch(T){throw T?.name!=="NotReadableError"?T:new b("PLATFORM_UNAVAILABLE","This environment cannot read Blob part data. Supply text or byte chunks; read Blobs before sending data to a worker.",{cause:T})}yield new Uint8Array(w)}})():d}finish(){return this.result?this.result:(this.open(),this.state="finalizing",this.result=(async()=>{const d=this.zip;try{for(const[g,w]of this.relationships){if(g!=="/"&&!this.parts.has(g))throw new TypeError("Missing relationship source part: "+g);let T=0;for(const v of w.values()){if(u(this.options.signal),!v.external&&!this.parts.has(v.target.toLowerCase()))throw new TypeError("Missing relationship target: "+v.target);(++T&255)===0&&s()&&(await o(),u(this.options.signal))}}for(const g of this.parts.values())"written"in g||("prepared"in g?await d.addPrepared(g.uri.slice(1),g.prepared):await d.add(g.uri.slice(1),this.source(g.data)));for(const[g,w]of this.relationships){const T=g==="/"?"/":this.parts.get(g).uri;await d.add(O(T).slice(1),async v=>{const E=new m(v,this.options.signal);await E.write(p+'<Relationships xmlns="'+c+'">');for(const R of w.values()){const I='<Relationship Id="'+x(R.id)+'" Type="'+x(R.type)+'" Target="'+x(R.external?R.target:P(T,R.target))+'"'+(R.external?' TargetMode="External"':"")+"/>";E.append(I)&&await E.flush()}await E.write("</Relationships>"),await E.close()})}return await d.add("[Content_Types].xml",this.source(this.types.toXml())),await d.finish(),this.state="complete",d.bytesWritten}catch(g){throw await this.discard(g),g}finally{this.parts.clear(),this.directories.clear(),this.relationships.clear()}})(),this.result)}async toBlob(d="application/zip"){if(this.options.sink)throw new b("INVALID_STATE","This package uses a caller-owned sink; use finish().");return await this.finish(),this.zip.toBlob(d)}async discard(d){this.state="failed",this.parts.clear(),this.directories.clear(),this.relationships.clear(),await this.zip.discard(d)}}return Object.freeze({partUri:nt.partUri,relationshipPartUri:nt.relationshipPartUri,relativePartTarget:nt.relativePartTarget,corePropertiesXml:ft.corePropertiesXml,appPropertiesXml:ft.appPropertiesXml,relationshipsNamespace:c,officeRelationshipsNamespace:i,contentTypesNamespace:r,relationshipTypes:n,ContentTypes:t,OpcPackage:h})})(),it=(()=>{function S(P){if(typeof P!="string"||!/^#?(?:[0-9a-f]{6}|[0-9a-f]{8})$/i.test(P))throw new TypeError("Color must be RGB or ARGB hex.");const k=P.replace(/^#/,"").toUpperCase();return k.length===6?"FF"+k:k}return Object.freeze({colorArgb:S})})(),ot=(()=>{const{OfficeIMOError:S}=me,{cleanXml:O,escapeOoxmlAttribute:P}=Pe,{colorArgb:k}=it;function C(p,u,o){if(!p||typeof p!="object"||Array.isArray(p))throw new TypeError(o+" must be an object.");if(typeof p.then=="function")throw Promise.resolve(p).catch(()=>{}),new TypeError(o+" must be synchronous.");for(const s of Object.keys(p))if(!u.includes(s))throw new TypeError("Unsupported "+o+" property: "+s)}function y(p,u){if(p!==void 0&&typeof p!="boolean")throw new TypeError(u+" must be boolean.")}class m{policy;maximum;numberFormat;definitions=new Map;constructor(u,o,s){this.policy=u,this.maximum=o,this.numberFormat=s}keys(u){const o=u.map(a=>b(a,this.policy,()=>164)),s=new Set(o.filter(a=>!this.definitions.has(a)));if(this.definitions.size+s.size>this.maximum)throw new S("RESOURCE_LIMIT","maxDifferentialStyles exceeded.");return o}check(u){this.keys(u)}add(u){const o=this.keys(u);for(let s=0;s<u.length;s++)this.definitions.has(o[s])||this.definitions.set(o[s],{id:this.definitions.size,xml:b(u[s],this.policy,this.numberFormat)});return o.map(s=>this.definitions.get(s).id)}toXml(){return this.definitions.size?'<dxfs count="'+this.definitions.size+'">'+[...this.definitions.values()].map(u=>"<dxf>"+u.xml+"</dxf>").join("")+"</dxfs>":""}}function b(p,u,o){C(p,["font","fill","border","numberFormat"],"conditional style");let s="";if(p.font!==void 0){C(p.font,["bold","italic","underline","strike","color"],"conditional font");let a="";for(const[c,i]of[["bold","b"],["italic","i"],["strike","strike"]])y(p.font[c],c),p.font[c]!==void 0&&(a+="<"+i+' val="'+(p.font[c]?1:0)+'"/>');y(p.font.underline,"underline"),p.font.underline!==void 0&&(a+='<u val="'+(p.font.underline?"single":"none")+'"/>'),p.font.color!==void 0&&(a+='<color rgb="'+k(p.font.color)+'"/>'),a&&(s+="<font>"+a+"</font>")}if(p.numberFormat!==void 0){const a=p.numberFormat;if(typeof a!="string"||!a||a.length>255||!O(a,u))throw new TypeError("Conditional number format requires 1 through 255 XML-valid characters.");s+='<numFmt numFmtId="'+o(a)+'" formatCode="'+P(a,u)+'"/>'}if(p.fill!==void 0){C(p.fill,["color"],"conditional fill");const a=k(p.fill.color);s+='<fill><patternFill patternType="solid"><fgColor rgb="'+a+'"/><bgColor rgb="'+a+'"/></patternFill></fill>'}if(p.border!==void 0){C(p.border,["left","right","top","bottom"],"conditional border");let a="";for(const c of["left","right","top","bottom"]){const i=p.border[c];if(i!==void 0){if(C(i,["style","color"],"conditional border edge"),!["thin","medium","dashed","dotted","thick","double","hair","dashDot","dashDotDot","slantDashDot","mediumDashed","mediumDashDot","mediumDashDotDot"].includes(i.style))throw new TypeError("Invalid conditional border style.");a+="<"+c+' style="'+i.style+'">'+(i.color!==void 0?'<color rgb="'+k(i.color)+'"/>':"")+"</"+c+">"}}a&&(s+="<border>"+a+"</border>")}if(!s)throw new TypeError("A conditional style must change at least one property.");return s}return Object.freeze({fields:C,optionalBoolean:y,DifferentialStyles:m,differentialXml:b})})(),Xe=(()=>{const{escapeOoxmlAttribute:S,cleanXml:O,xmlDeclaration:P}=Pe,{OfficeIMOError:k}=me,{colorArgb:C}=it,{DifferentialStyles:y}=ot,m="http://schemas.openxmlformats.org/spreadsheetml/2006/main",b=["thin","medium","dashed","dotted","thick","double","hair","dashDot","dashDotDot","slantDashDot","mediumDashed","mediumDashDot","mediumDashDotDot"];function x(r){if(!r||typeof r!="object")throw new TypeError("A border must be an object of edges.");const n={};for(const e of["left","right","top","bottom"]){const t=r[e];if(t){const{style:h,color:l}=t;if(!b.includes(h))throw new TypeError("Invalid border style.");n[e]={style:h,...l?{color:C(l)}:{}}}}return n}const p={General:"General",Integer:"0",Decimal:"0.00",Percent:"0.00%",Date:"yyyy-mm-dd",DateTime:"yyyy-mm-dd hh:mm:ss"};function u(r,n,e){if(!Number.isInteger(r)||r<0||r>=n)throw new RangeError("Unknown "+e+" index.");return r}function o(r,n,e,t){const h=JSON.stringify(e),l=n.get(h);if(l!==void 0)return l;if(r.length>=t)throw new k("RESOURCE_LIMIT","Style component limit exceeded.");const f=r.length;return r.push(e),n.set(h,f),f}function s(r){if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError("A style patch must be a CellStyle object.");if(typeof r.then=="function")throw Promise.resolve(r).catch(()=>{}),new TypeError("Style patches must be synchronous CellStyle objects.")}function a(r){return s(r),Object.freeze({...r,...typeof r.font=="object"?{font:Object.freeze({...r.font})}:{},...typeof r.fill=="object"?{fill:Object.freeze({...r.fill})}:{},...typeof r.border=="object"?{border:Object.freeze(Object.fromEntries(Object.entries(r.border).map(([n,e])=>[n,Object.freeze({...e})])))}:{}})}class c{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((n,e)=>[JSON.stringify(n),e]));fillIndexes=new Map(this.fills.map((n,e)=>[JSON.stringify(n),e]));borderIndexes=new Map(this.borders.map((n,e)=>[JSON.stringify(n),e]));constructor(n="strip",e=64e3,t=1e3){if(this.policy=n,this.maximum=e,!Number.isSafeInteger(e)||e<1||e>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 y(n,t,h=>this.addNumberFormat(h)),O("",n),this.add()}checkDifferentials(n){const e=new Set(n.flatMap(t=>t.numberFormat===void 0?[]:[O(t.numberFormat,this.policy)]).filter(t=>t!=="General"&&!this.formats.has(t)));if(this.formats.size+e.size>65372)throw new RangeError("Too many number formats.");this.differential.check(n)}addDifferentials(n){return this.checkDifferentials(n),this.differential.add(n)}addFont(n){const{name:e,size:t,bold:h,italic:l,underline:f,strike:d,color:g}=n;if(e!==void 0&&typeof e!="string")throw new TypeError("Font name must be a string.");const w=O(e??"Calibri",this.policy),T=t??11;if(typeof w!="string"||!w||w.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 o(this.fonts,this.fontIndexes,{name:w,size:T,bold:!!h,italic:!!l,underline:!!f,strike:!!d,color:g?C(g):""},this.maximum)}addFill(n){const{color:e}=n,t=n.pattern??(e?"solid":"none");if(!["none","gray125","solid"].includes(t)||t==="solid"&&!e||t!=="solid"&&e)throw new TypeError("A solid fill requires a color; none and gray125 have no color.");return o(this.fills,this.fillIndexes,{pattern:t,color:e?C(e):""},this.maximum+1)}addBorder(n){return o(this.borders,this.borderIndexes,x(n),this.maximum)}addNumberFormat(n){if(typeof n!="string"||!n||n.length>255)throw new TypeError("Number format must contain 1 through 255 characters.");if(n=O(n,this.policy),!n)throw new TypeError("Number format must contain XML-valid characters.");if(n==="General")return 0;let e=this.formats.get(n);if(e===void 0){if(this.formats.size>=65372)throw new RangeError("Too many number formats.");e=this.formats.size+164,this.formats.set(n,e)}return e}add(n={}){const e=typeof n.font=="number"?u(n.font,this.fonts.length,"font"):n.font?this.addFont(n.font):0,t=typeof n.fill=="number"?u(n.fill,this.fills.length,"fill"):n.fill?this.addFill(n.fill):0,h=typeof n.border=="number"?u(n.border,this.borders.length,"border"):n.border?this.addBorder(n.border):0;let l=0;if(typeof n.numberFormat=="string")l=this.addNumberFormat(n.numberFormat);else if(n.numberFormat!==void 0&&(l=n.numberFormat,!Number.isInteger(l)||l<0||l>163&&![...this.formats.values()].includes(l)))throw new RangeError("Unknown number format index.");if(n.alignment!==void 0&&!["left","center","right","fill","justify","distributed"].includes(n.alignment))throw new TypeError("Invalid horizontal alignment.");if(n.verticalAlignment!==void 0&&!["top","center","bottom","justify","distributed"].includes(n.verticalAlignment))throw new TypeError("Invalid vertical alignment.");const f={font:e,fill:t,border:h,numberFormat:l,wrapText:!!n.wrapText,alignment:n.alignment??"",verticalAlignment:n.verticalAlignment??""},d=JSON.stringify(f),g=this.indexes.get(d);if(g!==void 0)return g;if(this.styles.length>=this.maximum)throw new k("RESOURCE_LIMIT","Workbook exceeds its cell style limit.");const w=this.styles.length;return this.styles.push(f),this.indexes.set(d,w),w}validateStyle(n){return u(n,this.styles.length,"cell style")}compose(n,e){s(e);const t=this.styles[this.validateStyle(n)];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}:{},...e,...typeof e.font=="object"?{font:{...this.fonts[t.font],...e.font}}:{},...typeof e.border=="object"?{border:{...this.borders[t.border],...e.border}}:{}})}dateHeader(n,e){return this.compose(n,{numberFormat:this.styles[this.validateStyle(e)].numberFormat})}forColumn(n,e=!1,t,h=!1,l){const f=!e&&n.style!==void 0?this.styles[this.validateStyle(n.style)]:void 0,d=n.format!==void 0?n.format||p.General:f?.numberFormat||(n.type==="date"||h?p.DateTime:p.General);return this.add({...f?{font:f.font,fill:f.fill,border:f.border}:{},numberFormat:d,wrapText:n.wrapText??f?.wrapText??!1,...n.alignment?{alignment:n.alignment}:f?.alignment?{alignment:f.alignment}:{},...f?.verticalAlignment?{verticalAlignment:f.verticalAlignment}:{},...e?{font:{bold:!0}}:{},...t?{fill:{color:t}}:{},...l?{border:l}:{}})}toXml(){const n=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="'+S(t.name,this.policy)+'"/></font>',e=t=>"<border>"+["left","right","top","bottom"].map(h=>{const l=t[h];return l?"<"+h+' style="'+l.style+'">'+(l.color?'<color rgb="'+l.color+'"/>':"")+"</"+h+">":"<"+h+"/>"}).join("")+"<diagonal/></border>";return P+'<styleSheet xmlns="'+m+'"><numFmts count="'+this.formats.size+'">'+[...this.formats].map(([t,h])=>'<numFmt numFmtId="'+h+'" formatCode="'+S(t,this.policy)+'"/>').join("")+'</numFmts><fonts count="'+this.fonts.length+'">'+this.fonts.map(n).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(e).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 h=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"':"")+(h?' applyAlignment="1"':"")+">"+h+"</xf>"}).join("")+'</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>'+this.differential.toXml()+"</styleSheet>"}}return Object.freeze({colorArgb:it.colorArgb,spreadsheetNamespace:m,normalizeBorder:x,NumberFormats:p,validateStylePatch:s,copyStylePatch:a,StyleRegistry:c})})(),Ke=(()=>{const{NotSupportedError:S}=me,{cleanXml:O,escapeXml:P}=Pe,k=new WeakSet,C=new WeakSet;function y(o){let s=!1;const a=/[\p{L}_\\][\p{L}\p{N}\p{M}_.\\]*/uy;for(let c=0;c<o.length;c++){const i=o[c];if(i==='"'){for(;++c<o.length;)if(o[c]==='"'){if(o[c+1]!=='"')break;c++}}else if(i==="'"){let r="";for(;++c<o.length;){if(o[c]==="'"){if(o[c+1]!=="'")break;c++}r+=o[c]}if(o.slice(c+1).trimStart().startsWith("!")&&/[\[\]]/.test(r))throw new S("external-workbook formulas")}else if(i==="["){let r=1;for(;++c<o.length&&r;){if(o[c]==="'"){c++;continue}o[c]==="["?r++:o[c]==="]"&&r--}if(/^[A-Za-z0-9_.]*!/.test(o.slice(c)))throw new S("external-workbook formulas");c--}else{if(i==="|")throw new S("DDE formulas");{a.lastIndex=c;const r=a.exec(o);r&&(["SUBTOTAL","AGGREGATE","_XLFN.AGGREGATE"].includes(r[0].toUpperCase())&&/^\s*\(/.test(o.slice(a.lastIndex))&&(s=!0),c=a.lastIndex-1)}}}return s}function m(o){if(typeof o!="string")throw new TypeError("Formula text must be a string.");const s=o.trim().replace(/^=/,"");if(!s.trim()||s.length>8192)throw new RangeError("Formulas require 1 through 8,192 characters.");return O(s,"reject"),{text:s,subtotal:y(s)}}class b{cachedValue;style;static[Symbol.hasInstance](s){return s!==null&&typeof s=="object"&&k.has(s)}formula;constructor(s,a,c){this.cachedValue=a,this.style=c;const i=m(s);if(this.formula=i.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(c!==void 0&&(!Number.isSafeInteger(c)||c<0))throw new RangeError("Formula style indexes must be nonnegative safe integers.");k.add(this),i.subtotal&&C.add(this),Object.freeze(this)}}function x(o){return C.has(o)}function p(o){if(!(o instanceof b))throw new TypeError("Formula cells must be created with FormulaCell.");return"<f>"+P(o.formula,"reject")+"</f><v>"+(o.cachedValue??"")+"</v>"}return Object.freeze({FormulaCell:b,isSubtotalFormula:x,formulaXml:p})})(),_e=(()=>{const{cleanXml:S,escapeXml:O}=Pe,{assertExportValue:P,assertScalar:k}=ve,{FormulaCell:C}=Ke,{copyExportValue:y}=tt;class m{value;style;constructor(e,t){this.value=e,this.style=t}}function b(n){n instanceof C||(n instanceof m?k(n.value):P(n))}function x(n){return n instanceof C?n:n instanceof m?Object.freeze(new m(y(n.value),n.style)):y(n)}function p(n,e="strip"){const t=S(n,e);if(t.length>32767)throw new RangeError("Excel cell text exceeds 32,767 UTF-16 code units.");return t}function u(n,e){const t=p(n,e),h=l=>'<t xml:space="preserve">'+O(l,e)+"</t>";return/_x[0-9a-f]{4}_/i.test(t)?t.split(/(?<=_)(?=x[0-9a-f]{4}_)/gi).map(l=>"<r>"+h(l)+"</r>").join(""):h(t)}function o(n){if(!Number.isInteger(n)||n<1||n>16384)throw new RangeError("Column index must be from 1 through 16,384.");let e="";for(;n;)n--,e=String.fromCharCode(65+n%26)+e,n=Math.floor(n/26);return e}function s(n,e){return n.slice(0,e).replace(/[\ud800-\udbff]$/,"")}function a(n){let e=0,t=n.length;const h=l=>l==="'"||/\s/u.test(l);for(;e<t&&h(n[e]);)e++;for(;t>e&&h(n[t-1]);)t--;return n.slice(e,t)}function c(n,e,t,h=!0){if(typeof n!="string")throw new TypeError("Sheet name must be a string.");let l=a(S(n,t).replace(/[\[\]:*?/\\]/g,"_"));l=a(s(l,31)),l||(l="Sheet"),l.toLowerCase()==="history"&&(l+="_");let f=l,d=2;for(;e.has(f.toLowerCase());){const g=" ("+d+++")";f=s(l,31-g.length)+g}return h&&e.add(f.toLowerCase()),f}function i(n,e){if(!Number.isFinite(n.getTime()))return null;const t=e==="utc",h=t?n.getUTCFullYear():n.getFullYear();if(h<1900||h>9999)throw new RangeError("Excel dates must be in years 1900 through 9999.");const l=new Date(0);l.setUTCFullYear(h,t?n.getUTCMonth():n.getMonth(),t?n.getUTCDate():n.getDate()),l.setUTCHours(t?n.getUTCHours():n.getHours(),t?n.getUTCMinutes():n.getMinutes(),t?n.getUTCSeconds():n.getSeconds(),t?n.getUTCMilliseconds():n.getMilliseconds());const f=l.getTime();return(f-Date.UTC(1899,11,31))/864e5+(f>=Date.UTC(1900,2,1)?1:0)}return Object.freeze({Cell:m,assertXlsxValue:b,copyValue:x,cellText:p,inlineText:u,columnName:o,sheetName:c,excelDate:i})})(),Ot=(()=>{const{captureFields:S}=Ce;function O(y,m){if(y===void 0)return;if(!Array.isArray(y)||y.length>m)throw new TypeError("Column outlines must be bounded, non-overlapping ranges.");let b=0;return Object.freeze(y.map(x=>{if(!x||typeof x!="object")throw new TypeError("Column outlines require range metadata.");return S(x,["firstColumn","columnCount","level","hidden","collapsed"])}).sort((x,p)=>x.firstColumn-p.firstColumn).map(x=>{const{firstColumn:p,columnCount:u,level:o=0,hidden:s,collapsed:a}=x;if(!Number.isSafeInteger(p)||p<b||!Number.isSafeInteger(u)||u<1||p+u>m)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 c of[s,a])if(c!==void 0&&typeof c!="boolean")throw new TypeError("Column outline flags must be booleans.");return b=p+u,Object.freeze({firstColumn:p,columnCount:u,level:o,...s===void 0?{}:{hidden:s},...a===void 0?{}:{collapsed:a}})}))}function P(y){for(const m of[y.outlineSummaryBelow,y.outlineSummaryRight])if(m!==void 0&&typeof m!="boolean")throw new TypeError("Outline summary positions must be booleans.")}function k(y){const m=new Map;for(const b of y??[])for(let x=b.firstColumn;x<b.firstColumn+b.columnCount;x++)m.set(x,b);return m}return Object.freeze({captureColumnOutlines:O,validateOutlinePositions:P,columnOutlineMap:k})})(),Pt=(()=>{const{ChunkedTextSink:S}=Ie,{escapeXml:O,xmlDeclaration:P}=Pe,{officeRelationshipsNamespace:k}=st,{columnName:C}=_e,y="http://schemas.openxmlformats.org/drawingml/2006/chart",m="application/vnd.openxmlformats-officedocument.drawingml.chart+xml";function b(i,r,n){const e=' cx="'+Math.round(i.width*9525)+'" cy="'+Math.round(i.height*9525)+'"';return"<xdr:oneCellAnchor><xdr:from><xdr:col>"+(i.column-1)+"</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>"+(i.row-1)+"</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:from><xdr:ext"+e+'/><xdr:graphicFrame macro=""><xdr:nvGraphicFramePr><xdr:cNvPr id="'+r+'" name="Chart '+i.id+'" descr="'+O(i.description??i.title??"",n)+'"/><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="'+y+'"><c:chart xmlns:c="'+y+'" r:id="chart'+i.id+'"/></a:graphicData></a:graphic></xdr:graphicFrame><xdr:clientData/></xdr:oneCellAnchor>'}function x(i,r){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">'+O(i,r)+'</a:t></a:r></a:p></c:rich></c:tx><c:overlay val="0"/></c:title>'}function*p(i,r,n,e){yield"<c:"+i+"Ref><c:f>"+O(r,e)+"</c:f><c:"+i+"Cache>",i==="num"&&(yield"<c:formatCode>General</c:formatCode>"),yield'<c:ptCount val="'+n.length+'"/>';for(let t=0;t<n.length;t++)yield'<c:pt idx="'+t+'"><c:v xml:space="preserve">'+O(String(n[t]),e)+"</c:v></c:pt>";yield"</c:"+i+"Cache></c:"+i+"Ref>"}function u(i,r){const n=i.dataLabels;if(!n)return"";const e={center:"ctr",insideEnd:"inEnd",outsideEnd:"outEnd",bestFit:"bestFit",above:"t",below:"b",left:"l",right:"r"};return"<c:dLbls>"+(n.numberFormat===void 0?"":'<c:numFmt formatCode="'+O(n.numberFormat,r)+'" sourceLinked="0"/>')+(n.position===void 0?"":'<c:dLblPos val="'+e[n.position]+'"/>')+'<c:showLegendKey val="0"/><c:showVal val="'+(n.showValue===!1?0:1)+'"/><c:showCatName val="'+(n.showCategoryName?1:0)+'"/><c:showSerName val="'+(n.showSeriesName?1:0)+'"/><c:showPercent val="'+(n.showPercent?1:0)+'"/><c:showBubbleSize val="0"/></c:dLbls>'}function o(i,r){const n=i.type==="barClustered",e=i.valueAxis,t='<c:scaling><c:orientation val="minMax"/>'+(e?.maximum===void 0?"":'<c:max val="'+e.maximum+'"/>')+(e?.minimum===void 0?"":'<c:min val="'+e.minimum+'"/>')+"</c:scaling>",h='<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="'+(n?"l":"b")+'"/>'+(i.categoryAxis?.title?x(i.categoryAxis.title,r):"")+'<c:numFmt formatCode="General" sourceLinked="1"/>'+h+'<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"/>'+t+'<c:delete val="0"/><c:axPos val="'+(n?"b":"l")+'"/><c:majorGridlines/>'+(e?.title?x(e.title,r):"")+'<c:numFmt formatCode="'+O(e?.numberFormat??"General",r)+'" sourceLinked="'+(e?.numberFormat===void 0?1:0)+'"/>'+h+'<c:crossAx val="1"/><c:crosses val="autoZero"/><c:crossBetween val="between"/></c:valAx>'}function*s(i,r){const n=i.type==="pie",e=i.type==="line",t=n?"pieChart":e?"lineChart":"barChart",h="'"+i.dataSheetName.replace(/'/g,"''")+"'!",l=i.data.categories.length+1;yield P+'<c:chartSpace xmlns:c="'+y+'" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="'+k+'"><c:date1904 val="0"/>'+(i.language===void 0?"":'<c:lang val="'+O(i.language,r)+'"/>')+"<c:chart>",i.title&&(yield x(i.title,r)),yield'<c:autoTitleDeleted val="'+(i.title?0:1)+'"/><c:plotArea><c:layout/><c:'+t+">",n||(yield e?'<c:grouping val="standard"/>':'<c:barDir val="'+(i.type==="barClustered"?"bar":"col")+'"/><c:grouping val="clustered"/>'),yield'<c:varyColors val="'+(n?1:0)+'"/>';for(let f=0;f<i.data.series.length;f++){const d=i.data.series[f],g="$"+C(f+2);yield'<c:ser><c:idx val="'+f+'"/><c:order val="'+f+'"/><c:tx>';const w=i.binding?i.binding.references.names[f]:h+g+"$1";w===void 0?yield"<c:v>"+O(d.name,r)+"</c:v>":yield*p("str",w,[d.name],r),yield"</c:tx>",d.color&&(yield"<c:spPr>"+(e?'<a:ln w="25400">':"")+'<a:solidFill><a:srgbClr val="'+d.color+'"/></a:solidFill>'+(e?"</a:ln>":"")+"</c:spPr>"),!e&&!n&&(yield'<c:invertIfNegative val="0"/>'),yield"<c:cat>",yield*p("str",i.binding?.references.categories??h+"$A$2:$A$"+l,i.data.categories,r),yield"</c:cat><c:val>",yield*p("num",i.binding?.references.values[f]??h+g+"$2:"+g+"$"+l,d.values,r),yield"</c:val>"+(e?'<c:smooth val="0"/>':"")+"</c:ser>"}yield u(i,r),!n&&!e&&(yield'<c:gapWidth val="150"/><c:overlap val="0"/>'),n||(yield'<c:axId val="1"/><c:axId val="2"/>'),yield"</c:"+t+">",n||(yield o(i,r)),yield"</c:plotArea>",i.legend!==!1&&(yield'<c:legend><c:legendPos val="'+{right:"r",bottom:"b",left:"l",top:"t"}[i.legend??"right"]+'"/><c:layout/><c:overlay val="0"/></c:legend>'),yield'<c:plotVisOnly val="'+(i.binding?1:0)+'"/><c:dispBlanksAs val="gap"/><c:showDLblsOverMax val="0"/></c:chart></c:chartSpace>'}async function a(i,r,n,e){const t=new S(r,e);for(const h of s(i,n))t.append(h)&&await t.flush();await t.close()}return Object.freeze({chartNamespace:y,chartContentType:m,chartAnchorXml:b,writeChartXml:a})})(),Je=(()=>{const{cleanXml:S,escapeXml:O,escapeOoxmlAttribute:P,xmlDeclaration:k}=Pe,{copyExportLink:C}=et,{officeRelationshipsNamespace:y}=st,{chartAnchorXml:m}=Pt,{captureFields:b}=Ce;function x(r,n){if(r=b(r,["row","column","width","height","description"]),!Number.isInteger(r.row)||r.row<1||r.row>1048576||!Number.isInteger(r.column)||r.column<1||r.column>16384)throw new RangeError("Drawing anchors must be one-based worksheet rows and columns.");for(const e of[r.width,r.height])if(!Number.isFinite(e)||e<=0||e>1e5)throw new RangeError("Drawing display dimensions must be positive and at most 100,000 pixels.");if(r.description!==void 0&&typeof r.description!="string")throw new TypeError("Drawing description must be a string.");return Object.freeze({row:r.row,column:r.column,width:r.width,height:r.height,...r.description===void 0?{}:{description:S(r.description,n)}})}function p(r){const n=typeof r=="string"&&/^([A-Z]{1,3})([1-9][0-9]{0,6})$/.exec(r);if(!n)throw new TypeError("Use a single uppercase A1 cell reference.");const e=Number(n[2]);let t=0;for(const h of n[1])t=t*26+h.charCodeAt(0)-64;if(t>16384||e>1048576)throw new RangeError("Cell reference exceeds Excel's worksheet bounds.");return{row:e,column:t}}function u(r,n){r=b(r,["cell","target","tooltip"]),p(r.cell);const e=C(r);return Object.freeze({cell:r.cell,target:e.target,...e.tooltip===void 0?{}:{tooltip:S(e.tooltip,n)}})}function o(r,n,e){if(r=b(r,["data","row","column","width","height","description"]),r.data instanceof Uint8Array&&e?.(r.data.length),!(r.data instanceof Uint8Array)||r.data.length<33||![137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82].every((h,l)=>r.data[l]===h))throw new TypeError("Images require PNG bytes with a valid signature and IHDR header.");const t=new DataView(r.data.buffer,r.data.byteOffset,r.data.byteLength);if(!t.getUint32(16)||!t.getUint32(20))throw new RangeError("PNG dimensions must be positive.");return Object.freeze({...x(r,n),data:new Uint8Array(r.data)})}function s(r,n,e=[]){return"<hyperlinks>"+r.map((t,h)=>'<hyperlink ref="'+t.cell+'" r:id="link'+(h+1)+'"'+(t.tooltip===void 0?"":' tooltip="'+P(t.tooltip,n)+'"')+"/>").join("")+e.map(t=>'<hyperlink ref="'+t.cell+'" location="'+P(t.location,n)+'"/>').join("")+"</hyperlinks>"}function a(r,n,e=[]){const t="http://schemas.openxmlformats.org/drawingml/2006/";return k+'<xdr:wsDr xmlns:xdr="'+t+'spreadsheetDrawing" xmlns:a="'+t+'main" xmlns:r="'+y+'">'+r.map((h,l)=>{const f=' cx="'+Math.round(h.width*9525)+'" cy="'+Math.round(h.height*9525)+'"';return"<xdr:oneCellAnchor><xdr:from><xdr:col>"+(h.column-1)+"</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>"+(h.row-1)+"</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:from><xdr:ext"+f+'/><xdr:pic><xdr:nvPicPr><xdr:cNvPr id="'+(l+1)+'" name="Image '+(l+1)+'" descr="'+O(h.description??"",n)+'"/><xdr:cNvPicPr/></xdr:nvPicPr><xdr:blipFill><a:blip r:embed="image'+(l+1)+'"/><a:stretch><a:fillRect/></a:stretch></xdr:blipFill><xdr:spPr><a:xfrm><a:off x="0" y="0"/><a:ext'+f+'/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></xdr:spPr></xdr:pic><xdr:clientData/></xdr:oneCellAnchor>'}).join("")+e.map((h,l)=>m(h,r.length+l+1,n)).join("")+"</xdr:wsDr>"}return Object.freeze({copyDrawingAnchor:x,cellPosition:p,copyHyperlink:u,copyImage:o,hyperlinksXml:s,drawingXml:a,drawingContentType:"application/vnd.openxmlformats-officedocument.drawing+xml"})})(),Gt=(()=>{const{OfficeIMOError:S}=me,{cellPosition:O}=Je;function P(m){if(!m.length)return;const b=[...m].sort((c,i)=>c.top-i.top),x=b[Math.floor(b.length/2)].top,p=[],u=[],o=[];for(const c of b)(c.bottom<x?u:c.top>x?o:p).push(c);const s=P(u),a=P(o);return{middle:x,starts:p,ends:[...p].sort((c,i)=>i.bottom-c.bottom),...s?{before:s}:{},...a?{after:a}:{}}}function k(m,b,x){if(m){for(const p of b<=m.middle?m.starts:m.ends){if(b<=m.middle?p.top>b:p.bottom<b)break;x.push(p)}k(b<m.middle?m.before:b>m.middle?m.after:void 0,b,x)}}class C{references;index;currentRow=-1;current=[];lastRow;constructor(b,x,p){if(b.length>p)throw new S("RESOURCE_LIMIT","maxMergedRanges exceeded.");if(!b.length){this.references=Object.freeze([]),this.lastRow=0,this.index=void 0;return}const u=b.map(i=>{if(typeof i!="string"||i.split(":").length!==2)throw new TypeError("Merged ranges require uppercase A1:B2 references.");const[r,n]=i.split(":"),e=O(r),t=O(n);if(t.row<e.row||t.column<e.column||t.row===e.row&&t.column===e.column)throw new RangeError("Merged ranges require ordered distinct cells.");if(t.column>x)throw new RangeError("Merged ranges must stay within declared columns.");return{ref:i,top:e.row,bottom:t.row,left:e.column,right:t.column}}),o=u.flatMap(i=>[{row:i.top,delta:1,region:i},{row:i.bottom+1,delta:-1,region:i}]).sort((i,r)=>i.row-r.row||i.delta-r.delta),s=new Int32Array(65536),a=new Int32Array(65536);function c(i,r,n,e,t,h){if(e<=r&&n<=t){s[i]=s[i]+h,a[i]=a[i]+h;return}const l=r+n>>>1;e<=l&&c(i*2,r,l,e,t,h),t>l&&c(i*2+1,l+1,n,e,t,h),s[i]=a[i]+Math.max(s[i*2],s[i*2+1])}for(const i of o)if(c(1,1,16384,i.region.left,i.region.right,i.delta),s[1]>1)throw new TypeError("Merged ranges must not overlap: "+i.region.ref);this.references=Object.freeze(u.map(i=>i.ref)),this.lastRow=u.reduce((i,r)=>Math.max(i,r.bottom),0),this.index=P(u)}covered(b,x){if(!this.index||x>this.lastRow)return!1;this.currentRow!==x&&(this.current=[],k(this.index,x,this.current),this.current.sort((o,s)=>o.left-s.left),this.currentRow=x);let p=0,u=this.current.length-1;for(;p<=u;){const o=p+u>>>1,s=this.current[o];if(b<s.left)u=o-1;else if(b>s.right)p=o+1;else return x!==s.top||b!==s.left}return!1}validateRows(b){if(this.lastRow>b)throw new RangeError("Merged ranges must stay within exported rows.")}}return Object.freeze({MergeRegions:C})})(),Vt=(()=>{const{ExportCell:S}=ve,{tableSpans:O}=Ve,{copyValue:P,columnName:k}=_e;class C{values;ranges;constructor(b,x){const p=O(b,x),u=[];this.values=p.map((o,s)=>{const a=Array(x).fill(void 0);for(const c of o)a[c.first]=P(c.value),(c.span>1||c.rowSpan>1)&&u.push({first:c.first+1,last:c.first+c.span,top:s+1,bottom:s+c.rowSpan});return Object.freeze(a)}),this.ranges=u}get mergeCount(){return this.ranges.length}merges(b){return this.ranges.map(x=>k(x.first)+(x.top+b)+":"+k(x.last)+(x.bottom+b))}matchesLeaf(b){const x=this.values.length;return!this.ranges.some(p=>p.bottom===x)&&this.values[x-1].every((p,u)=>(p instanceof S?p.value:p)===b[u])}}return Object.freeze({StructuredRows:C})})(),It=(()=>{const{ExportCell:S}=ve,{isDate:O}=Me,{Cell:P,cellText:k,columnName:C}=_e,{FormulaCell:y}=Ke,{escapeOoxmlAttribute:m}=Pe,{MergeRegions:b}=Gt,{OfficeIMOError:x}=me,{createTotals:p}=ht,{StructuredRows:u}=Vt;class o{value;formula;operation;constructor(e,t,h){this.value=e,this.formula=t,this.operation=h}}class s{columns;options;headings;merges;headerRows;firstHeaderRow;regions;widths;sampleRows;structuredFooter;footerRows;mergeCount;aggregates;constructor(e,t,h,l=1e4,f=1e5){this.columns=e,this.options=t;const d=t.title===void 0?0:1;if(t.title!==void 0){if(!e.length)throw new TypeError("Report titles require declared columns.");if(typeof t.title.text!="string")throw new TypeError("Report title text must be a string.");if(k(t.title.text,h),t.title.height!==void 0&&(!Number.isFinite(t.title.height)||t.title.height<=0||t.title.height>409))throw new RangeError("Title height must be positive and at most 409 points.")}const g=Math.max(0,...e.map(I=>I.groups?.length??0));if(t.headerRows===void 0){if(g>16)throw new RangeError("Grouped headings support at most 16 levels.");if(g&&t.includeHeader===!1)throw new TypeError("Grouped headings require leaf headers.")}const w=[],T=[];if(d&&e.length>1&&T.push("A1:"+C(e.length)+"1"),t.headerRows!==void 0&&t.includeHeader!==!1){const I=new u(t.headerRows,e.length);if((t.table||t.autoFilter)&&!I.matchesLeaf(e.map(z=>z.header)))throw new TypeError("Native tables and autofilters require an unmerged final heading row matching the declared leaf headers.");w.push(...I.values),T.push(...I.merges(d))}else if(t.includeHeader!==!1){for(let I=0;I<g;I++){const z=e.map(j=>j.groups?.[I]??"");for(const j of z)k(j,h);for(let j=0;j<e.length;){let M=j;const L=JSON.stringify(e[j].groups?.slice(0,I+1));for(;M+1<e.length&&z[j]&&JSON.stringify(e[M+1].groups?.slice(0,I+1))===L;)M++;if(M>j){T.push(C(j+1)+(I+1+d)+":"+C(M+1)+(I+1+d));for(let B=j+1;B<=M;B++)z[B]=""}j=M+1}w.push(z)}e.length&&w.push(e.map(I=>I.header))}if(this.headerRows=d+w.length,this.firstHeaderRow=e.length&&t.includeHeader!==!1?d+1:0,t.mergedCells!==void 0&&!Array.isArray(t.mergedCells))throw new TypeError("Merged ranges must be an array.");if(t.footer?.rows!==void 0&&(t.footer.values!==void 0||t.footer.totals!==void 0))throw new TypeError("Structured footer rows cannot accompany footer values or totals.");if(this.structuredFooter=t.footer?.rows===void 0?void 0:new u(t.footer.rows,e.length),this.footerRows=this.structuredFooter?.values.length??(t.footer?1:0),this.mergeCount=T.length+(t.mergedCells?.length??0)+(this.structuredFooter?.mergeCount??0),this.mergeCount>l)throw new x("RESOURCE_LIMIT","maxMergedRanges exceeded.");if(this.regions=new b([...T,...t.mergedCells??[]],e.length,l),t.table){for(const I of t.mergedCells??[])if(Number(I.split(":")[1].match(/\d+$/)[0])>=this.headerRows)throw new TypeError("Merged ranges cannot intersect a native table.")}this.headings=w,this.merges=this.regions.references;const v=t.autoSize;if(this.sampleRows=v?v.sampleRows??Math.min(100,Math.floor(f/Math.max(1,e.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 E=v?.minWidth??8,R=v?.maxWidth??60;if(!Number.isFinite(E)||!Number.isFinite(R)||E<0||E>R||R>255)throw new RangeError("Width bounds must satisfy 0 <= minWidth <= maxWidth <= 255.");if(this.widths=e.map(I=>I.width??(v?Math.max(E,Math.min(R,I.header.length+2)):void 0)),t.footer?.values&&t.footer.values.length>e.length)throw new RangeError("Footer has more values than declared columns.");this.aggregates=p(e,t.footer?.totals),t.print&&c(t.print,h)}finalRegions(e,t){return this.structuredFooter?new b([...this.merges,...this.structuredFooter.merges(this.headerRows+e)],this.columns.length,t):this.regions}sample(e){const t=this.options.autoSize?.minWidth??8,h=this.options.autoSize?.maxWidth??60;e.forEach((l,f)=>{if(!this.columns[f]||this.columns[f].width!==void 0)return;const d=l instanceof y?l.cachedValue:l instanceof S?l.text??l.value:l instanceof P?l.value:l,g=O(d)?Number.isFinite(d.getTime())?d.toISOString():"":d==null?"":String(d),w=Math.max(0,...g.slice(0,Math.ceil(h*4)).split(/\r?\n/).map(T=>[...T].length));this.widths[f]=Math.max(this.widths[f]??t,Math.min(h,w+2))})}accept(e,t){this.aggregates[e].accept(t)}footer(e){return this.columns.map((t,h)=>{const l=this.aggregates[h],f=l.operation;if(!f)return this.options.footer?.values?.[h];const d=l.value();return new o(d,a(f,C(h+1),this.headerRows,e),f)})}}function a(n,e,t,h){const l={sum:109,count:102,average:101,min:105,max:104}[n],f=["average","min","max"].includes(n),d=e+(t+1)+":"+e+(t+h),g="SUBTOTAL("+l+","+d+")";return h?f?"IF(SUBTOTAL(102,"+d+')=0,"",'+g+")":g:f?'""':"0"}function c(n,e){if(n.paper!==void 0&&!["A4","Letter"].includes(n.paper))throw new TypeError("Print paper must be A4 or Letter.");if(n.orientation!==void 0&&!["portrait","landscape"].includes(n.orientation))throw new TypeError("Invalid print orientation.");for(const t of[n.fitToWidth,n.fitToHeight])if(t!==void 0&&(!Number.isInteger(t)||t<0||t>32767))throw new RangeError("Print fit dimensions must be integers from 0 through 32,767.");for(const t of Object.values(n.margins??{}))if(!Number.isFinite(t)||t<0||t>10)throw new RangeError("Print margins must be from 0 through 10 inches.");for(const t of[n.header,n.footer])if(t!==void 0){if(typeof t!="string"||t.length>250)throw new TypeError("Print header/footer must be strings of at most 250 UTF-16 units.");if(k(t,e),("&C"+t.replace(/&/g,"&&")).length>255)throw new RangeError("Encoded print header/footer exceeds Excel's 255-character limit.")}}function i(n,e){if(!n)return"";const t={left:.25,right:.25,top:.5,bottom:.5,header:.2,footer:.2,...n.margins};return"<pageMargins"+Object.entries(t).map(([h,l])=>" "+h+'="'+l+'"').join("")+'/><pageSetup paperSize="'+(n.paper==="Letter"?1:9)+'" orientation="'+(n.orientation??"landscape")+'" fitToWidth="'+(n.fitToWidth??1)+'" fitToHeight="'+(n.fitToHeight??0)+'"/>'+(n.header!==void 0||n.footer!==void 0?"<headerFooter>"+(n.header===void 0?"":"<oddHeader>"+m("&C"+n.header.replace(/&/g,"&&"),e)+"</oddHeader>")+(n.footer===void 0?"":"<oddFooter>"+m("&C"+n.footer.replace(/&/g,"&&"),e)+"</oddFooter>")+"</headerFooter>":"")}return Object.freeze({ComputedTotal:o,ReportLayout:s,totalFormula:a,printXml:i})})(),Ye=(()=>{const{columnName:S}=_e;function O(y,m,b="Data"){if(typeof m=="string"){const x=y.flatMap((p,u)=>p.key===m?[u+1]:[]);if(x.length!==1)throw new TypeError(b+" column keys must identify exactly one declared column.");return x[0]}if(!Number.isInteger(m)||m<1||m>y.length)throw new RangeError(b+" column numbers must be one-based and within declared columns.");return m}function P(y,m,b,x){if(!Number.isSafeInteger(b)||b<1||!Number.isSafeInteger(x)||x<1||b+x-1>1048576)throw new RangeError("A data range must fit within Excel's worksheet rows.");const p=S(m);return"'"+y.replace(/'/g,"''")+"'!$"+p+"$"+b+":$"+p+"$"+(b+x-1)}function k(y,m,b){return P(y,m,b,1).split(":")[0]}return Object.freeze({resolveDataColumn:O,qualifiedColumnRange:P,qualifiedCell:k})})(),at=(()=>{const{OfficeIMOError:S}=me,{columnName:O}=_e,P=new WeakMap;function k(x,p){P.set(x,p)}function C(x){return P.get(x)}function y(x,p,u){const o=P.get(x);if(o===void 0)return u;const s=p+u;let a=0;for(const c of o){if(c.firstRow>s)break;a+=Math.min(c.lastRow,s)-c.firstRow+1}return a}function m(x,p,u,o,s){if(s===void 0)return o?O(x)+(u+1)+":"+O(p)+(u+o):void 0;const a=O(x),c=O(p);let i="",r=u;for(const n of s){if(!Number.isSafeInteger(n.firstRow)||!Number.isSafeInteger(n.lastRow)||n.firstRow<=r||n.lastRow<n.firstRow||n.lastRow>u+o)throw new RangeError("Detail editing ranges must be ordered within serialized worksheet rows.");const e=a+n.firstRow+":"+c+n.lastRow;if(i.length+(i?1:0)+e.length>32767)throw new S("RESOURCE_LIMIT","Detail editing references exceed 32,767 UTF-16 characters; split the worksheet.");i+=(i?" ":"")+e,r=n.lastRow}return i||void 0}return Object.freeze({retainDataRowRanges:k,dataRowRanges:C,dataRowCount:y,dataRowReference:m})})(),Xt=(()=>{const{cleanXml:S,escapeXml:O,escapeOoxmlAttribute:P}=Pe,{cellPosition:k}=Je,{colorArgb:C}=it,{fields:y,optionalBoolean:m,differentialXml:b}=ot,{resolveDataColumn:x}=Ye,{dataRowReference:p}=at;function u(t,h){if(typeof t=="string"){const d=t.split(":");if(d.length>2)throw new TypeError("Conditional ranges require one uppercase A1 cell or rectangle.");const g=k(d[0]),w=k(d[1]??d[0]);if(w.row<g.row||w.column<g.column||w.column>h.length)throw new RangeError("Conditional ranges require ordered cells within declared columns.");return{first:g.column,last:w.column,reference:t,bottom:w.row}}y(t,["column","through"],"conditional data range");const l=x(h,t.column,"Conditional"),f=t.through===void 0?l:x(h,t.through,"Conditional");if(f<l)throw new RangeError("Conditional data ranges require ordered columns.");return{first:l,last:f}}function o(t){if(typeof t!="number"||!Number.isFinite(t))throw new TypeError("Conditional values must be finite numbers.");return String(t)}function s(t,h){if(typeof t!="string")return o(t);if(h!=="equal"&&h!=="notEqual")throw new TypeError("Text conditional comparisons support only equal and notEqual.");if(t.length>8190)throw new RangeError("Conditional comparison formulas must fit 8,192 characters including quotes.");S(t,"reject");const l='"'+t.replace(/"/g,'""')+'"';if(l.length>8192)throw new RangeError("Conditional comparison formulas must fit 8,192 characters including quotes.");return l}function a(t){if(typeof t!="string")throw new TypeError("Conditional formulas must be strings.");const h=t.trim().replace(/^=/,"");if(!h.trim()||h.length>8192)throw new RangeError("Conditional formulas require 1 through 8,192 characters.");return S(h,"reject"),h}function c(t,h){if(y(t,t.type==="min"||t.type==="max"?["type"]:["type","value"],"conditional threshold"),t.type==="min"||t.type==="max"){if(t.type!==(h==="first"?"min":h==="last"?"max":""))throw new TypeError("Use min only at the start and max only at the end of a scale.");return'<cfvo type="'+t.type+'"/>'}if(t.type==="formula")return'<cfvo type="formula" val="'+P(a(t.value),"reject")+'"/>';if(!["number","percent","percentile"].includes(t.type))throw new TypeError("Unsupported conditional threshold type.");if(!("value"in t))throw new TypeError("A numeric threshold requires a value.");const l=o(t.value);if(t.type!=="number"&&(t.value<0||t.value>100))throw new RangeError("Conditional percent/percentile thresholds must be from 0 through 100.");return'<cfvo type="'+(t.type==="number"?"num":t.type)+'" val="'+l+'"/>'}function i(t){for(let h=1;h<t.length;h++){const l=t[h-1],f=t[h];if("value"in l&&"value"in f&&l.type===f.type&&typeof l.value=="number"&&typeof f.value=="number"&&l.value>f.value)throw new RangeError("Conditional thresholds of the same numeric type must be ordered.")}}function r(t,h,l){if(t===void 0)return[];if(!Array.isArray(t))throw new TypeError("conditionalFormats must be an array.");return t.map(f=>{const d=["type","range"],g=["style","stopIfTrue"];y(f,[...d,...f?.type==="cellIs"?[...g,"operator","value","values"]:f?.type==="expression"?[...g,"formula"]:f?.type==="colorScale"?["stops"]:f?.type==="dataBar"?["color","minimum","maximum","showValue"]:[]],"conditional rule");const w=u(f.range,h);let T="",v="",E;if(f.type==="cellIs"||f.type==="expression")if(m(f.stopIfTrue,"stopIfTrue"),b(f.style,l,()=>164),E={...f.style,...f.style.font?{font:{...f.style.font}}:{},...f.style.fill?{fill:{...f.style.fill}}:{},...f.style.border?{border:Object.fromEntries(Object.entries(f.style.border).filter(([,R])=>R!==void 0).map(([R,I])=>[R,{...I}]))}:{}},f.stopIfTrue!==void 0&&(T+=' stopIfTrue="'+(f.stopIfTrue?1:0)+'"'),f.type==="expression")v="<formula>"+O(a(f.formula),"reject")+"</formula>";else{const R=f.operator==="between"||f.operator==="notBetween";if(!["equal","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","between","notBetween"].includes(f.operator))throw new TypeError("Unsupported conditional comparison operator.");if(R){if("value"in f||!Array.isArray(f.values)||f.values.length!==2)throw new TypeError("between/notBetween require exactly two values.");if(v=f.values.map(I=>"<formula>"+o(I)+"</formula>").join(""),f.values[0]>f.values[1])throw new RangeError("Conditional comparison bounds must be ordered.")}else{if("values"in f||!("value"in f))throw new TypeError("A conditional comparison requires one value.");v="<formula>"+O(s(f.value,f.operator),"reject")+"</formula>"}T+=' operator="'+f.operator+'"'}else if(f.type==="colorScale"){if(!Array.isArray(f.stops)||f.stops.length!==2&&f.stops.length!==3)throw new TypeError("Color scales require two or three stops.");const R=[],I=[];v="<colorScale>"+f.stops.map((z,j)=>(y(z,["threshold","color"],"color stop"),R.push(C(z.color)),I.push(z.threshold),c(z.threshold,j===0?"first":j===f.stops.length-1?"last":"middle"))).join("")+R.map(z=>'<color rgb="'+z+'"/>').join("")+"</colorScale>",i(I)}else if(f.type==="dataBar"){m(f.showValue,"showValue");const R=f.minimum===void 0?{type:"min"}:f.minimum,I=f.maximum===void 0?{type:"max"}:f.maximum;v='<dataBar showValue="'+(f.showValue===!1?0:1)+'">'+c(R,"first")+c(I,"last")+'<color rgb="'+C(f.color)+'"/></dataBar>',i([R,I])}else throw new TypeError("Unsupported conditional rule type.");return{target:w,type:f.type,attributes:T,body:v,...E?{style:E}:{}}})}class n{rules;constructor(h,l){const f=l.addDifferentials(h.flatMap(g=>g.style?[g.style]:[]));let d=0;this.rules=h.map((g,w)=>({target:g.target,xml:'<cfRule type="'+g.type+'" priority="'+(w+1)+'"'+(g.style?' dxfId="'+f[d++]+'"':"")+g.attributes+">"+g.body+"</cfRule>"}))}get count(){return this.rules.length}*xml(h,l,f,d){for(const g of this.rules){if(g.target.bottom!==void 0&&g.target.bottom>f)throw new RangeError("Conditional ranges must stay within exported rows.");const w=g.target.reference??p(g.target.first,g.target.last,h,l,d);w&&(yield'<conditionalFormatting sqref="'+w+'">'+g.xml+"</conditionalFormatting>")}}}return Object.freeze({prepareConditionalFormats:r,ConditionalFormats:n})})(),qt=(()=>{const{OfficeIMOError:S}=me,{checkAbort:O}=be,{cleanXml:P,escapeOoxmlAttribute:k,escapeXml:C}=Pe,{fields:y,optionalBoolean:m}=ot,{resolveDataColumn:b}=Ye,{dataRowReference:x}=at;function p(a,c,i){if(a!==void 0){if(typeof a!="string")throw new TypeError(i+" must be text.");if(a.length>c)throw new RangeError(i+" exceeds "+c+" UTF-16 units.");return P(a,"reject")}}function u(a,c,i=1e3,r=1e6,n){if(O(n),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 e=a.length;if(e>i)throw new S("RESOURCE_LIMIT","maxDataValidations exceeded.");const t=[],h=new Set;let l=0;const f=d=>{if(l+d>r)throw new S("RESOURCE_LIMIT","maxValidationTextCharacters exceeded.");l+=d};for(let d=0;d<e;d++){O(n);const g=a[d];y(g,["type","column","items","allowBlank","showErrorMessage","errorStyle","errorTitle","errorMessage"],"data validation");const{type:w,column:T,items:v,allowBlank:E,showErrorMessage:R,errorStyle:I,errorTitle:z,errorMessage:j}=g;if(w!=="list")throw new TypeError("Only inline-list data validation is supported.");const M=b(c,T,"Validation");if(h.has(M))throw new TypeError("A data column cannot have multiple validation rules.");if(h.add(M),m(E,"allowBlank"),m(R,"showErrorMessage"),I!==void 0&&!["stop","warning","information"].includes(I))throw new TypeError("Unsupported validation error style.");if(!Array.isArray(v))throw new TypeError("Inline validation lists require a nonempty string array.");const L=v.length;if(!L)throw new TypeError("Inline validation lists require a nonempty string array.");if(L>254)throw new RangeError("Inline validation lists must fit 255 UTF-16 units including quotes and separators.");let B='"';for(let F=0;F<L;F++){O(n);const W=v[F];if(typeof W!="string")throw new TypeError("Inline validation choices must be strings.");if(W.length>253||W.includes(","))throw new RangeError("Inline validation choices cannot contain commas and must fit the 255-character list source.");P(W,"reject");const U=W.replace(/"/g,'""');if(B.length+(F?1:0)+U.length+1>255)throw new RangeError("Inline validation lists must fit 255 UTF-16 units including quotes and separators.");B+=(F?",":"")+U}B+='"';const q=p(z,32,"Validation error title"),G=p(j,255,"Validation error message");f(B.length+(q?.length??0)+(G?.length??0));const _=' type="list" allowBlank="'+(E===!1?0:1)+'" showErrorMessage="'+(R===!1?0:1)+'" errorStyle="'+(I??"stop")+'"'+(q===void 0?"":' errorTitle="'+k(q,"reject")+'"')+(G===void 0?"":' error="'+k(G,"reject")+'"');t.push(Object.freeze({column:M,attributes:_,formula:B}))}return O(n),Object.freeze({rules:Object.freeze(t),count:e,textCharacters:l})}function*o(a,c,i,r){if(!(!a.count||!i||r?.length===0)){yield'<dataValidations count="'+a.count+'">';for(const n of a.rules){const e=x(n.column,n.column,c,i,r);yield"<dataValidation"+n.attributes+' sqref="'+e+'"><formula1>'+C(n.formula,"reject")+"</formula1></dataValidation>"}yield"</dataValidations>"}}return Object.freeze({prepareDataValidations:u,dataValidationsXml:o})})(),jt=(()=>{const{checkAbort:S,consumeRows:O,inputRows:P,pause:k,taskYieldDue:C}=be,{ChunkedTextSink:y,BlobByteSink:m}=Ie,{OfficeIMOError:b}=me,{notifyProgress:x}=Ge,{copyColumns:p,createRowProjector:u}=Ne,{EntryWriter:o}=pt,{xmlDeclaration:s}=Pe,{officeRelationshipsNamespace:a}=st,{Cell:c,cellText:i,columnName:r,inlineText:n,excelDate:e,copyValue:t}=_e,{spreadsheetNamespace:h,colorArgb:l,validateStylePatch:f,copyStylePatch:d}=Xe,{copyHyperlink:g,copyImage:w,hyperlinksXml:T,cellPosition:v}=Je,{ExportCell:E,assertScalar:R}=ve,{ReportLayout:I,ComputedTotal:z,printXml:j}=It,{cleanXml:M}=Pe,{ConditionalFormats:L,prepareConditionalFormats:B}=Xt,{isDate:q}=Me,{FormulaCell:G,formulaXml:_,isSubtotalFormula:F}=Ke,{prepareDataValidations:W,dataValidationsXml:U}=qt,{qualifiedCell:X,qualifiedColumnRange:V,resolveDataColumn:Y}=Ye,{dataRowRanges:re,dataRowCount:A}=at,{captureColumnOutlines:$,columnOutlineMap:J,validateOutlinePositions:te}=Ot,he=65530;function se(ye){if(ye>he)throw new RangeError("Excel supports at most 65,530 hyperlinks per worksheet; split the sheet.")}class ne{book;table;preserved;chartData;validations;columns;project;name;declared;options;entry;completion;prepared;buffer;output=new m;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(D,H,N,Q,ie=!1,ce=[],ae=!1,ue={rules:[],count:0,textCharacters:0}){this.book=D,this.table=Q,this.preserved=ie,this.chartData=ae,this.validations=ue,this.columns=p(N.columns??[],!0).map(oe=>Object.freeze(oe));const ge=N.alternatingRowStyle;this.options={...N,...N.autoSize?{autoSize:{...N.autoSize}}:{},...N.mergedCells?{mergedCells:[...N.mergedCells]}:{},...N.title?{title:{...N.title,...N.title.style?{style:d(N.title.style)}:{}}}:{},...N.print?{print:{...N.print,...N.print.margins?{margins:{...N.print.margins}}:{}}}:{},...N.footer?{footer:{...N.footer,...N.footer.values?{values:N.footer.values.map(t)}:{},...N.footer.totals?{totals:{...N.footer.totals}}:{},...N.footer.style?{style:d(N.footer.style)}:{}}}:{},...ge?{alternatingRowStyle:d(ge)}:{}},this.layout=new I(this.columns,this.options,D.settings.invalidCharacterPolicy,D.settings.limits?.maxMergedRanges??1e4,D.settings.limits?.maxBufferedCells??1e5),this.titleStyle=N.title?D.styles.compose(D.styles.compose(0,{font:{bold:!0,size:18}}),this.options.title.style??{}):0,this.headerRows=this.layout.headerRows;for(const oe of N.hyperlinks??[]){const K=g(oe,D.settings.invalidCharacterPolicy);this.links.push(K),this.linkedCells.add(K.cell)}D.checkLinks(this.links.length),this.declared=this.columns.map((oe,K)=>({column:oe,letter:r(K+1),style:D.styles.forColumn(oe),dateStyle:D.styles.forColumn(oe,!1,void 0,!0),headerStyle:this.headerRows?N.headerStyle??D.styles.forColumn({header:oe.header,...(N.headerWrap??oe.wrapText)===void 0?{}:{wrapText:N.headerWrap??oe.wrapText},...oe.alignment===void 0?{}:{alignment:oe.alignment}},N.boldHeader!==!1,N.headerFill,!1,N.headerBorder):0})),this.conditional=new L(ce,D.styles),D.retainLink(this.links.length),this.name=typeof H=="function"?H():H,this.project=u(this.columns,{sheetName:this.name,firstDataRow:this.headerRows+1},D.settings.signal,D.valueValidator)}static create(D,H,N,Q,ie=!1,ce,ae){return new ne(D,H,N,Q,ie,ce,!1,ae)}static createChartData(D,H){return new ne(D,H.dataSheetName,{columns:[{header:"Category"},...H.data.series.map(N=>({header:N.name,type:"number"}))]},void 0,!1,[],!0)}static validate(D,H){const N=p(H.columns??[],!0),Q=W(H.dataValidation,N,D.availableDataValidations,D.availableValidationTextCharacters,D.settings.signal);D.checkConditionalFormats(H.conditionalFormats?.length??0);const ie=B(H.conditionalFormats,N,D.settings.invalidCharacterPolicy);D.styles.checkDifferentials(ie.flatMap(ae=>ae.style?[ae.style]:[]));const ce=new I(N,H,D.settings.invalidCharacterPolicy,D.settings.limits?.maxMergedRanges??1e4,D.settings.limits?.maxBufferedCells??1e5);if(D.checkMerges(ce.mergeCount),H.title?.style&&f(H.title.style),H.title&&D.styles.compose(D.styles.compose(0,{font:{bold:!0,size:18}}),H.title.style??{}),H.footer?.style&&D.styles.compose(0,H.footer.style),H.hyperlinks!==void 0){if(!Array.isArray(H.hyperlinks))throw new TypeError("Hyperlinks must be an array.");se(H.hyperlinks.length);const ae=new Set;for(const ue of H.hyperlinks){const ge=g(ue,D.settings.invalidCharacterPolicy),oe=v(ge.cell);if(ce.regions.covered(oe.column,oe.row))throw new TypeError("Hyperlinks cannot address a covered merged cell.");if(ae.has(ge.cell))throw new TypeError("Duplicate hyperlink cell: "+ge.cell);ae.add(ge.cell)}}if(N.length>16384)throw new RangeError("Excel supports at most 16,384 columns.");if(H.includeHeader===!1&&(H.freezeHeader||H.autoFilter))throw new TypeError("A frozen header or autofilter requires a header row.");if(H.headerFill!==void 0&&l(H.headerFill),H.headerWrap!==void 0&&typeof H.headerWrap!="boolean")throw new TypeError("headerWrap must be boolean.");H.headerStyle!==void 0&&D.styles.validateStyle(H.headerStyle),H.alternatingRowStyle!==void 0&&D.styles.compose(0,H.alternatingRowStyle);for(const ae of[H.rowStyle,H.cellStyle,H.rowOutline])if(ae!==void 0&&typeof ae!="function")throw new TypeError("Row and style callbacks must be functions.");if(H.maxOutlineLevel!==void 0&&(!Number.isInteger(H.maxOutlineLevel)||H.maxOutlineLevel<0||H.maxOutlineLevel>7))throw new RangeError("Maximum outline level must be an integer from zero through seven.");if(te(H),$(H.columnOutlines,N.length),H.rowOutline&&H.maxOutlineLevel===void 0)throw new TypeError("A row outline callback requires maxOutlineLevel before streamed rows are written.");if(!H.rowOutline&&H.maxOutlineLevel!==void 0)throw new TypeError("maxOutlineLevel requires a row outline callback.");for(const ae of[H.rowHeight,H.headerHeight])if(ae!==void 0&&(!Number.isFinite(ae)||ae<=0||ae>409))throw new RangeError("Row height must be positive and at most 409 points.");if(H.freezeColumns!==void 0&&(!Number.isInteger(H.freezeColumns)||H.freezeColumns<0||H.freezeColumns>N.length||H.freezeColumns>=16384))throw new RangeError("Frozen columns must be within the declared columns and leave a valid scrollable column.");if(H.table&&H.includeHeader===!1)throw new TypeError("Excel tables require a header row.");if(H.defaultColumnWidth!==void 0&&(!Number.isFinite(H.defaultColumnWidth)||H.defaultColumnWidth<0||H.defaultColumnWidth>255))throw new RangeError("Default column width must be from 0 through 255 characters.");for(const ae of N){if(ae.width!==void 0&&(!Number.isFinite(ae.width)||ae.width<0||ae.width>255))throw new RangeError("Column width must be from 0 through 255 characters.");if(ae.type!==void 0&&!["string","number","boolean","date"].includes(ae.type)&&!D.writerFor(ae.type))throw new TypeError("Invalid column type: "+ae.type);if(ae.alignment!==void 0&&!["left","center","right","fill","justify","distributed"].includes(ae.alignment))throw new TypeError("Invalid horizontal alignment.");if(i(ae.header,D.settings.invalidCharacterPolicy),ae.style!==void 0&&D.styles.validateStyle(ae.style),ae.format!==void 0&&(typeof ae.format!="string"||ae.format.length>255))throw new TypeError("Column format must be a string of at most 255 characters.")}return{conditional:ie,validations:Q}}cell(D,H,N,Q=!1,ie,ce,ae,ue=!1,ge=!1,oe=!0){const K=this.declared[H],Z=D instanceof z?D:void 0;Z&&(D=Z.value);let ee=D instanceof G?D:void 0;ee&&(D=ee.cachedValue);let le=D instanceof E?D.presentation:void 0,de=D instanceof E?D.link:void 0;D instanceof E&&(D=D.value);const pe=ee?.style??(D instanceof c?D.style:void 0),Se=(this.completedRegions??this.layout.regions).covered(H+1,N),Ae=D instanceof c?D.value:D,Te=Se&&(Ae==null||Ae==="");if(!Q&&!ue&&K.column.type&&!Te){const ke=this.book.writerFor(K.column.type);if(ke){if(ee)throw new TypeError("An explicit FormulaCell cannot also pass through a custom cell value writer; return it from the writer instead.");D=ke(D instanceof c?D.value:D,{column:K.column,rowIndex:N-this.headerRows-1,worksheetRow:N,columnIndex:H,sheetName:this.name})}}D instanceof G&&(ee=D,D=ee.cachedValue),D instanceof E&&(le=D.presentation,de=D.link,D=D.value);const Ee=ee?.style??(D instanceof c?D.style??pe:pe);if(D instanceof c&&(D=D.value),R(D),Se){if(de)throw new TypeError("Hyperlinks cannot address a covered merged cell.");if(ee||Z||D!=null&&D!=="")throw new TypeError("A merged range would hide the value at "+K.letter+N+"; covered cells must be empty.");D=void 0}const xe=q(D)?"date":typeof D;if(!Q&&!ue&&D!=null&&K.column.type&&!this.book.writerFor(K.column.type)&&K.column.type!==xe)throw new TypeError("Cell "+K.letter+N+" does not match column type "+K.column.type+".");let we=Ee===void 0?Q?K.headerStyle:Z?.operation==="count"?0:xe==="date"?K.dateStyle:K.style:this.book.styles.validateStyle(Ee);if(Q&&xe==="date"&&Ee===void 0&&this.options.headerStyle===void 0&&(we=this.book.styles.dateHeader(we,K.dateStyle)),ge&&(we=this.titleStyle),!Q&&!ue){if(Ee===void 0){const ze=we,De=ae?.get(ze);De!==void 0?we=De:((N-this.headerRows)%2===0&&this.options.alternatingRowStyle&&(we=this.book.styles.compose(we,this.options.alternatingRowStyle)),ie!==void 0&&(we=this.book.styles.compose(we,ie)),ae?.set(ze,we))}const ke=ce&&this.options.cellStyle?.({...ce,value:D,column:K.column,columnIndex:H});ke!==void 0&&(we=this.book.styles.compose(we,ke))}ue&&this.options.footer?.style&&Ee===void 0&&(we=this.book.styles.compose(we,this.options.footer.style)),le&&Ee===void 0&&(we=this.book.styles.compose(we,{...le.background===void 0?{}:{fill:{color:le.background}},...le.color===void 0&&le.bold===void 0&&le.italic===void 0?{}:{font:{...le.color===void 0?{}:{color:le.color},...le.bold===void 0?{}:{bold:le.bold},...le.italic===void 0?{}:{italic:le.italic}}},...le.wrapText===void 0?{}:{wrapText:le.wrapText},...le.alignment===void 0?{}:{alignment:le.alignment},...le.numberFormat===void 0?{}:{numberFormat:le.numberFormat}}));const je=typeof D=="string"?D.length:0;let Oe=this.preserved||Q||ue?je:void 0;if(xe==="string"&&je>32767&&M(D,this.book.settings.invalidCharacterPolicy).length>32767){const ke=K.letter+N;if(de||this.linkedCells.has(ke))throw new TypeError("A text-preservation cell cannot also have an external hyperlink.");se(this.links.length+this.internalLinks.length+1),this.book.checkLinks(1),Oe!==void 0&&(this.book.budget.release(1,Oe),Oe=void 0);const ze=this.book.preserveText(this.name,ke,D);this.book.retainLink(),this.internalLinks.push({cell:ke,location:ze.location}),this.linkedCells.add(ke),D=ze.preview}if(de&&this.appendHyperlink({cell:K.letter+N,...de}),xe==="date"&&(D=e(D,this.book.settings.dateMode)),!Q&&!ue&&oe&&(!ee||!F(ee))&&this.layout.accept(H,D),!Q&&!ue&&this.chartSources.length)for(const ke of this.chartSources)ke.observe(N-this.headerRows-1,H+1,D);const Re='<c r="'+K.letter+N+'" s="'+we+'"';if(ee&&this.book.retainFormula(ee.formula.length),this.book.budget.cell(ee?ee.formula:D,Oe),ee)return Re+(D===null?' t="str"':"")+">"+_(ee)+"</c>";if(Z)return Re+(D===null?' t="str"':"")+"><f>"+Z.formula.replace(/"/g,"&quot;")+"</f><v>"+(D??"")+"</v></c>";if(D==null||xe==="number"&&!Number.isFinite(D)||D==null)return Re+"/>";if(xe==="string")return Re+' t="inlineStr"><is>'+n(D,this.book.settings.invalidCharacterPolicy)+"</is></c>";if(xe==="boolean")return Re+' t="b"><v>'+(D?1:0)+"</v></c>";if(xe!=="number"&&xe!=="date")throw new TypeError("Excel cells must be strings, numbers, booleans, Dates or null.");return Re+"><v>"+D+"</v></c>"}*rowXml(D,H,N,Q=!1,ie=!1){const ce=ie?this.options.title?.height??28:N?this.options.headerHeight:this.options.rowHeight,ae=!N&&!Q&&(this.options.rowStyle||this.options.cellStyle||this.options.rowOutline)?Object.freeze({rowIndex:H-this.headerRows-1,worksheetRow:H,sheetName:this.name,values:Object.freeze(this.columns.map((K,Z)=>D[Z]instanceof G?D[Z].cachedValue:D[Z]instanceof c||D[Z]instanceof E?D[Z].value:D[Z]))}):void 0,ue=ae&&this.options.rowStyle?.(ae);ue!==void 0&&f(ue);const ge=this.outline(ae),oe=!N&&(ue||this.options.alternatingRowStyle)?new Map:void 0;yield'<row r="'+H+'"'+(ce===void 0?"":' ht="'+ce+'" customHeight="1"')+(ge?.level?' outlineLevel="'+ge.level+'"':"")+(ge?.hidden?' hidden="1"':"")+(ge?.collapsed?' collapsed="1"':"")+">";for(let K=0;K<this.columns.length;K++)yield this.cell(D[K],K,H,N,ue,ae,oe,Q,ie,ge?.hidden!==!0);yield"</row>"}outline(D){if(!D||!this.options.rowOutline)return;const H=this.options.rowOutline(D);if(H===void 0)return;if(H===null||typeof H!="object"||Array.isArray(H))throw new TypeError("Row outline callbacks must return metadata or undefined.");if(typeof H.then=="function")throw Promise.resolve(H).catch(()=>{}),new TypeError("Row outline callbacks must return synchronous metadata.");const{level:N,hidden:Q,collapsed:ie}=H,ce=N??0;if(!Number.isInteger(ce)||ce<0||ce>this.options.maxOutlineLevel)throw new RangeError("Row outline level exceeds the declared maximum.");for(const ae of[Q,ie])if(ae!==void 0&&typeof ae!="boolean")throw new TypeError("Row outline flags must be booleans.");return Object.freeze({level:ce,...Q===void 0?{}:{hidden:Q},...ie===void 0?{}:{collapsed:ie}})}writeRow(D,H,N,Q=!1,ie=!1){const ce=this.rowXml(D,H,N,Q,ie),ae=()=>{for(;;){const ue=ce.next();if(ue.done)return;if(this.buffer.append(ue.value))return this.buffer.flush().then(ae)}};return ae()}async sampleRow(D){if((this.pending.length+1)*this.columns.length>(this.book.settings.limits?.maxBufferedCells??1e5))throw new b("RESOURCE_LIMIT","Width sampling cell limit exceeded; reduce sampleRows or raise its bounded limit.");const H=[];let N=0;for(const Q of this.rowXml(D,this.count+this.headerRows+1,!1)){if(!this.started&&this.pendingCharacters+Q.length>(this.book.settings.limits?.maxBufferedCharacters??1e6)){if(this.options.autoSize?.sampleRows!==void 0)throw new b("RESOURCE_LIMIT","Width sampling text limit exceeded; reduce sampleRows or raise its bounded limit.");this.layout.sample(D),await this.start();for(const ie of H)this.buffer.append(ie)&&await this.buffer.flush();H.length=0}this.started?this.buffer.append(Q)&&await this.buffer.flush():(this.pendingCharacters+=Q.length,H.push(Q)),!this.started&&(++N&127)===0&&C()&&(await k(),S(this.book.settings.signal))}this.started||(this.layout.sample(D),this.pending.push(H))}reserveLayout(){if(!this.reservedLayout){if(!this.preserved){let D=0;if(this.options.title&&(D+=this.options.title.text.length),this.layout.firstHeaderRow)for(const H of this.layout.headings)for(const N of H){const Q=N instanceof E||N instanceof c?N.value:N;typeof Q=="string"&&(D+=Q.length)}if(this.layout.structuredFooter)for(const H of this.layout.structuredFooter.values)for(const N of H){const Q=N instanceof E?N.value:N;typeof Q=="string"&&(D+=Q.length)}else if(this.options.footer)for(let H=0;H<this.columns.length;H++){const N=this.columns[H],Q=this.options.footer.totals;if(Q&&Object.prototype.hasOwnProperty.call(Q,N.key??N.header))continue;const ie=this.options.footer.values?.[H],ce=ie instanceof E||ie instanceof c?ie.value:ie;typeof ce=="string"&&(D+=ce.length)}this.book.budget.reserve(this.columns.length*(this.headerRows+this.layout.footerRows),D)}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:K=>{this.book.retainBufferedBytes(K.length),this.output.write(K)}},this.book.settings.signal);const D=this.buffer=new y(this.entry,this.book.settings.signal),H=this.options,N=H.freezeColumns??0,Q=H.freezeHeader?this.headerRows:0,ie=N&&Q?"bottomRight":N?"topRight":"bottomLeft",ce=r(N+1)+(Q+1),ae=J(H.columnOutlines),ue=!!H.rowOutline||ae.size>0,ge=Math.max(0,...Array.from(ae.values(),K=>K.level??0));await D.write(s+'<worksheet xmlns="'+h+'" xmlns:r="'+a+'">'+(H.print||ue?"<sheetPr>"+(ue?'<outlinePr summaryBelow="'+(H.outlineSummaryBelow===!1?"0":"1")+'"'+(H.outlineSummaryRight===void 0?"":' summaryRight="'+(H.outlineSummaryRight?"1":"0")+'"')+' showOutlineSymbols="1"/>':"")+(H.print?'<pageSetUpPr fitToPage="1"/>':"")+"</sheetPr>":"")+'<sheetViews><sheetView workbookViewId="0">'+(N||Q?"<pane"+(N?' xSplit="'+N+'"':"")+(Q?' ySplit="'+Q+'"':"")+' topLeftCell="'+ce+'" activePane="'+ie+'" state="frozen"/><selection pane="'+ie+'" activeCell="'+ce+'" sqref="'+ce+'"/>':"")+"</sheetView></sheetViews>"+(ue?'<sheetFormatPr defaultRowHeight="15"'+(H.rowOutline?' outlineLevelRow="'+H.maxOutlineLevel+'"':"")+(ae.size?' outlineLevelCol="'+ge+'"':"")+"/>":""));const oe=H.defaultColumnWidth??(this.table?20:void 0);if(this.columns.some((K,Z)=>this.layout.widths[Z]!==void 0||oe!==void 0||ae.has(Z))){await D.write("<cols>");for(let K=0;K<this.columns.length;K++){const Z=this.layout.widths[K]??oe,ee=ae.get(K);(Z!==void 0||ee)&&await D.write('<col min="'+(K+1)+'" max="'+(K+1)+'"'+(Z===void 0?"":' width="'+Z+'" customWidth="1"')+(ee?.level?' outlineLevel="'+ee.level+'"':"")+(ee?.hidden?' hidden="1"':"")+(ee?.collapsed?' collapsed="1"':"")+"/>")}await D.write("</cols>")}if(await D.write("<sheetData>"),H.title&&await this.writeRow(this.columns.map((K,Z)=>Z?"":H.title.text),1,!0,!1,!0),this.layout.firstHeaderRow)for(let K=0;K<this.layout.headings.length;K++)await this.writeRow(this.layout.headings[K],K+this.layout.firstHeaderRow,!0);for(const K of this.pending)for(const Z of K)D.append(Z)&&await D.flush();this.pending=[],this.pendingCharacters=0}async addRows(D){if(this.book.assertOpen(),this.completion)throw new b("INVALID_STATE","Worksheet is closed.");if(this.busy)throw new b("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 H=performance.now();const N=()=>{performance.now()-H>=50&&(this.progress(),H=performance.now())},Q=()=>{if(this.count++,!this.started&&this.pending.length>=this.layout.sampleRows)return this.start().then(N);if(!this.started&&C())return k().then(()=>{S(this.book.settings.signal),N()});N()};await O(D,this.book.settings.signal,ie=>{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 ce=this.project(ie,this.count),ae=this.started?this.writeRow(ce,this.count+this.headerRows+1,!1):this.sampleRow(ce);return ae?ae.then(Q):Q()}),this.buffer&&await this.buffer.flush(),this.progress(),S(this.book.settings.signal)}catch(H){throw this.failed=!0,this.error=H,await this.book.discard(H),H}finally{this.busy=!1}}progress(){!this.preserved&&!this.chartData&&x(this.book.settings.onProgress,{phase:"rows",rows:this.book.rowCount,sheetRows:this.reportRowCount,sheetName:this.name})}get rowCount(){return this.count}dataRange(D){if(this.failed)throw this.error;if(!this.completed)throw new b("INVALID_STATE","Close the worksheet before resolving its data range.");const H=Y(this.columns,D),N=re(this);if(N!==void 0){if(N.length>1)throw new b("INVALID_STATE","Grouped details are discontiguous; use the grouped result's detailRanges for explicit formula references.");const Q=N[0];return Q?V(this.name,H,Q.firstRow,Q.lastRow-Q.firstRow+1):void 0}return this.count?V(this.name,H,this.headerRows+1,this.count):void 0}get chartBindingMetadata(){const D=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((H,N)=>{const Q=D?.[N],ie=Q instanceof E?Q.value:Q;return this.layout.firstHeaderRow&&ie===H.header&&!this.layout.regions.covered(N+1,this.headerRows)?X(this.name,N+1,this.headerRows):void 0})}}retainChartBinding(D){this.chartSources.push(D)}get reportRowCount(){return this.preserved||this.chartData?0:A(this,this.headerRows,this.count)}get hidden(){return this.chartData}addChart(D){if(this.book.assertOpen(),this.completion)throw new b("INVALID_STATE","Worksheet is closed.");if(this.failed)throw this.error;this.nativeCharts.push(this.book.registerChart(D))}get charts(){return this.nativeCharts}releaseCharts(){this.nativeCharts.length=0}addImage(D){if(this.book.assertOpen(),this.completion)throw new b("INVALID_STATE","Worksheet is closed.");if(this.failed)throw this.error;const H=w(D,this.book.settings.invalidCharacterPolicy,N=>this.book.checkImage(N));this.book.retainImage(H.data.length),this.pictures.push(H)}addHyperlink(D){if(this.book.assertOpen(),this.completion)throw new b("INVALID_STATE","Worksheet is closed.");if(this.failed)throw this.error;this.appendHyperlink(D)}appendHyperlink(D){const H=g(D,this.book.settings.invalidCharacterPolicy),N=v(H.cell);if(this.layout.regions.covered(N.column,N.row))throw new TypeError("Hyperlinks cannot address a covered merged cell.");if(this.linkedCells.has(H.cell))throw new TypeError("Duplicate hyperlink cell: "+H.cell);se(this.links.length+this.internalLinks.length+1),this.book.retainLink(),this.links.push(H),this.linkedCells.add(H.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 r(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 b("INVALID_STATE","Await addRows before closing the worksheet.");try{await this.finish()}catch(D){throw await this.book.discard(D),D}}finish(D){if(this.completion)return this.completion;if(this.failed)throw this.error;return this.completion=(async()=>{try{const H=this.completedRegions=this.layout.finalRegions(this.count,this.book.settings.limits?.maxMergedRanges??1e4);H.validateRows(this.totalRows);for(const ie of this.chartSources)ie.finish();this.chartSources.length=0;for(const ie of this.links){const ce=v(ie.cell);if(ce.column>this.columns.length||ce.row>this.totalRows)throw new RangeError("Hyperlinks must address cells within the exported rows and columns.");if(H.covered(ce.column,ce.row))throw new TypeError("Hyperlinks cannot address a covered merged cell.")}if(await this.start(),D)for await(const ie of P(D,this.book.settings.signal))this.book.budget.row(this.count+1),await this.writeRow(this.project(ie,this.count),this.headerRows+this.count+1,!1),this.count++;if(this.layout.structuredFooter)for(let ie=0;ie<this.layout.footerRows;ie++)await this.writeRow(this.layout.structuredFooter.values[ie],this.headerRows+this.count+ie+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+":"+r(this.columns.length)+(this.count+this.headerRows)+'"/>'),H.references.length&&await this.buffer.write('<mergeCells count="'+H.references.length+'">'+H.references.map(ie=>'<mergeCell ref="'+ie+'"/>').join("")+"</mergeCells>");const N=re(this);for(const ie of this.conditional.xml(this.headerRows,this.count,this.totalRows,N))await this.buffer.write(ie);for(const ie of U(this.validations,this.headerRows,this.count,N))await this.buffer.write(ie);(this.links.length||this.internalLinks.length)&&await this.buffer.write(T(this.links,this.book.settings.invalidCharacterPolicy,this.internalLinks)),await this.buffer.write(j(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 Q=await this.entry.close();!this.book.settings.sink&&!this.failed&&(this.prepared={...Q,chunks:this.output.takeChunks()}),this.completed=!0}catch(H){throw await this.discard(H),H}})()}takePrepared(){const D=this.prepared;return this.prepared=void 0,D}async discard(D){this.failed=!0,this.error=D,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(D)}}return Object.freeze({Worksheet:ne})})(),Zt=(()=>{const{escapeOoxmlAttribute:S,escapeXml:O,xmlDeclaration:P}=Pe,{cellText:k,columnName:C}=_e,{spreadsheetNamespace:y}=Xe,{ExportCell:m}=ve,{Cell:b}=_e,{totalFormula:x}=It;function p(s,a,c,i){const r=a.name??"Table"+s;if(typeof r!="string"||r.length>255||!/^[A-Za-z_][A-Za-z0-9_.]*$/.test(r)||/^(?:[A-Za-z]{1,3}[1-9][0-9]*|R[1-9][0-9]*C[1-9][0-9]*|R|C)$/i.test(r))throw new TypeError("Table names must be ASCII identifiers, at most 255 characters, and cannot be cell references.");const n=a.style??"TableStyleMedium2",e=/^TableStyle(Light|Medium|Dark)([1-9][0-9]?)$/.exec(n);if(!e||Number(e[2])>({Light:21,Medium:28,Dark:11}[e[1]]??0))throw new TypeError("Unknown built-in Excel table style.");const t=c.map(h=>k(h.header,i));if(!t.length||t.some(h=>!h.trim()||h.length>255)||new Set(t.map(h=>h.toLowerCase())).size!==t.length)throw new TypeError("Excel tables require nonblank, unique headers of at most 255 characters.");return Object.freeze({id:s,name:r,headers:Object.freeze(t),keys:Object.freeze(c.map(h=>h.key??h.header)),options:Object.freeze({...a,style:n})})}function u(s,a,c,i=1,r){const n="A"+i+":"+C(s.headers.length)+(a+i),e="A"+i+":"+C(s.headers.length)+(a+i+(r?1:0)),t=s.options,h=S(s.name,c);return P+'<table xmlns="'+y+'" id="'+s.id+'" name="'+h+'" displayName="'+h+'" ref="'+e+'"'+(r?' totalsRowCount="1"':' totalsRowShown="0"')+'><autoFilter ref="'+n+'"/><tableColumns count="'+s.headers.length+'">'+s.headers.map((l,f)=>{const d=s.keys[f],g=r?.totals&&Object.prototype.hasOwnProperty.call(r.totals,d)?r.totals[d]:void 0,w=r?.values?.[f],T=w instanceof b||w instanceof m?w.value:w,v=g&&["average","min","max"].includes(g),E=g?' totalsRowFunction="'+(v?"custom":g==="count"?"countNums":g)+'"':typeof T=="string"?' totalsRowLabel="'+S(T,c)+'"':"";return'<tableColumn id="'+(f+1)+'" name="'+S(l,c)+'"'+E+(v?"><totalsRowFormula>"+O(x(g,C(f+1),i,a),c)+"</totalsRowFormula></tableColumn>":"/>")}).join("")+'</tableColumns><tableStyleInfo name="'+t.style+'" showFirstColumn="'+(t.firstColumn?1:0)+'" showLastColumn="'+(t.lastColumn?1:0)+'" showRowStripes="'+(t.bandedRows!==!1?1:0)+'" showColumnStripes="'+(t.bandedColumns?1:0)+'"/></table>'}return Object.freeze({defineTable:p,tableXml:u})})(),$t=(()=>{const{OfficeIMOError:S}=me,{cleanXml:O}=Pe;class P{sheetName;maximum;policy;reserve;entries=[];characters=0;rows=0;constructor(b,x,p,u){this.sheetName=b,this.maximum=x,this.policy=p,this.reserve=u}add(b,x,p){const u=O(p,this.policy);if(this.characters+u.length>this.maximum)throw new S("RESOURCE_LIMIT","maxOverflowCharacters exceeded; use CSV or raise the bounded preservation limit.");let o=0;for(const c of C(u))o++;if(this.rows+o>1048575)throw new S("RESOURCE_LIMIT","Text overflow exceeds the worksheet row limit.");this.reserve(o*5,u.length+o*(b.length+x.length),this.rows+o);const s=this.rows+2;this.entries.push({sheet:b,cell:x,text:u,first:s,parts:o}),this.rows+=o,this.characters+=u.length;const a="\n[Full text: "+this.sheetName+"!D"+s+"; "+o+" parts]";return{preview:k(u,32767-a.length)+a,location:"'"+this.sheetName.replace(/'/g,"''")+"'!D"+s}}*values(){for(const b of this.entries){let x=0;for(const p of C(b.text))yield[b.sheet,b.cell,++x,p,b.parts]}}clear(){this.entries=[],this.characters=0,this.rows=0}}function k(m,b){let x=Math.min(b,m.length);return x<m.length&&/[\ud800-\udbff]/.test(m[x-1]??"")&&x--,m.slice(0,x)}function*C(m){let b=0;for(;b<m.length;){const x=k(m.slice(b,b+32768),32767);b+=x.length,yield x}}return Object.freeze({TextOverflow:P,clipText:k})})(),qe=(()=>{const{captureFields:S}=Ce,O=["signal","onProgress","limits","sink","dateMode","compression","invalidCharacterPolicy","appProperties","cellValueWriters","oversizedText","creator","title","subject","description","created","modified"],P=["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"],k=["maxRows","maxCells","maxTextCharacters","maxOutputBytes","maxStyles","maxSheets","maxOverflowCharacters","maxHyperlinks","maxImageBytes","maxBufferedCells","maxBufferedCharacters","maxMergedRanges","maxConditionalFormats","maxDifferentialStyles","maxCharts","maxChartPoints","maxChartTextCharacters","maxFormulaCharacters","maxDataValidations","maxValidationTextCharacters"];function C(b){return S(b,k)}function y(b){const x=S(b,O);return{...x,...x.limits===void 0?{}:{limits:C(x.limits)}}}return Object.freeze({workbookOptionFields:O,sheetOptionFields:P,workbookLimitFields:k,captureWorkbookLimits:C,captureWorkbookOptions:y})})(),Kt=(()=>{const{checkAbort:S}=be,{NotSupportedError:O,OfficeIMOError:P}=me,{cleanXml:k}=Pe,{captureFields:C}=Ce;function y(u,o,s){if(!u||typeof u!="object"||Array.isArray(u))throw new TypeError(s+" must be an object.");for(const a of Object.keys(u))if(!o.includes(a))throw new O(s+"."+a);return C(u,o)}function m(u){if(typeof u=="string"?!u.length:typeof u!="number"||!Number.isInteger(u)||u<1||u>16384)throw new TypeError("Chart columns require a declared key or a one-based column number.")}function b(u){const o=y(u,["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 s=o.firstRow===void 0?0:o.firstRow,a=o.rowCount;if(!Number.isSafeInteger(s)||s<0||!Number.isSafeInteger(a)||a<1||s+a>1048576)throw new RangeError("Chart data rows must form a nonempty finite Excel range.");if(m(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 c=o.series.map(i=>{const r=y(i,["column","name","color"],"chart.data.series");if(m(r.column),r.name!==void 0&&typeof r.name!="string")throw new TypeError("Chart series name must be a string.");if(r.color!==void 0&&(typeof r.color!="string"||!/^#?[0-9a-fA-F]{6}$/.test(r.color)))throw new TypeError("Chart colors must be opaque six-digit RGB hex values.");return Object.freeze(r)});return Object.freeze({kind:"range",sheet:o.sheet,firstRow:s,rowCount:a,categoryColumn:o.categoryColumn,series:Object.freeze(c)})}function x(u,o,s,a,c="columnClustered"){S(a);const i=u.rowCount,r=u.firstRow??0,n=i*u.series.length,e=o.categoryColumn;if(n>s.availablePoints)throw new P("RESOURCE_LIMIT","maxChartPoints exceeded.");if(o.source!==u.sheet||!Number.isInteger(o.headerRows)||o.headerRows<0||o.headerRows+r+i>1048576||o.seriesColumns.length!==u.series.length||o.seriesNames.length!==u.series.length||o.valueFormulas.length!==u.series.length||o.nameFormulas.length!==u.series.length)throw new TypeError("Resolved chart range does not match its declared columns and data rows.");for(const z of[o.categoryColumn,...o.seriesColumns])if(!Number.isInteger(z)||z<1||z>16384)throw new RangeError("Resolved chart columns must be one-based Excel columns.");if(o.seriesColumns.includes(e))throw new TypeError("Chart category and numeric series must use different columns.");let t=0;const h=u.series.map((z,j)=>{const M=z.name??o.seriesNames[j];if(typeof M!="string"||M.length>32767)throw new TypeError("Chart series names must fit Excel text cells.");if(t+=M.length,t>s.availableText)throw new P("RESOURCE_LIMIT","maxChartTextCharacters exceeded.");return k(M,s.policy)}),l=u.series.map(z=>z.color?.replace(/^#/,"").toUpperCase()),f=new Array(i),d=u.series.map(()=>new Array(i)),g=u.series.map(()=>0),w=u.series.map(()=>!1);let T=0,v;const E=()=>{if(S(a),!v){if(T!==i||g.some(z=>z!==i))throw new TypeError("Chart range did not receive every declared data row and numeric value.");if(c==="pie"&&!w[0])throw new RangeError("A pie chart needs at least one positive value.");v=Object.freeze({categories:Object.freeze(f),series:Object.freeze(d.map((z,j)=>Object.freeze({name:h[j],values:Object.freeze(z),...l[j]===void 0?{}:{color:l[j]}})))})}},R=Object.freeze({get categories(){return E(),v.categories},get series(){return E(),v.series}}),I=new Map;return o.seriesColumns.forEach((z,j)=>{const M=I.get(z)??[];M.push(j),I.set(z,M)}),Object.freeze({source:o.source,points:n,textCharacters:t,data:R,references:Object.freeze({categories:o.categoryFormula,values:Object.freeze([...o.valueFormulas]),names:Object.freeze(o.nameFormulas.map((z,j)=>u.series[j].name===void 0?z:void 0))}),observe(z,j,M){S(a);const L=z-r;if(!(L<0||L>=i)){if(v)throw new P("INVALID_STATE","Chart cache is already finalized.");if(j===e){if(typeof M!="string"||M.length>32767)throw new TypeError("Chart category cells must contain strings of at most 32,767 UTF-16 units.");if(f[L]!==void 0)throw new P("INVALID_STATE","A chart category cell was observed more than once.");s.retainText(M.length),f[L]=k(M,s.policy),T++}for(const B of I.get(j)??[]){if(typeof M!="number"||!Number.isFinite(M))throw new TypeError("Chart series cells require finite numbers or numeric formula caches.");if(c==="pie"&&M<0)throw new RangeError("Pie charts require nonnegative values.");if(d[B][L]!==void 0)throw new P("INVALID_STATE","A chart value cell was observed more than once.");d[B][L]=M,g[B]=g[B]+1,M>0&&(w[B]=!0)}}},finish:E})}return Object.freeze({captureChartRange:b,prepareChartBinding:x})})(),Jt=(()=>{const{checkAbort:S}=be,{NotSupportedError:O,OfficeIMOError:P}=me,{cleanXml:k}=Pe,{copyDrawingAnchor:C}=Je,{captureFields:y}=Ce,{captureChartRange:m,prepareChartBinding:b}=Kt;function x(s,a,c){if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError(c+" must be an object.");for(const i of Object.keys(s))if(!a.includes(i))throw new O(c+"."+i)}function p(s,a,c){return x(s,a,c),y(s,a)}function u(s,a,c,i,r,n){if(S(r),s=p(s,["type","data","row","column","width","height","description","title","language","legend","dataLabels","categoryAxis","valueAxis"],"chart"),!["columnClustered","barClustered","line","pie"].includes(s.type))throw new O("chart type "+s.type);const e=s.type,t=p(s.data,["kind","sheet","firstRow","rowCount","categoryColumn","categories","series"],"chart.data"),h=t.kind==="range"?m(t):void 0;h||x(t,["categories","series"],"chart.data");const l=h?void 0:t.categories,f=h?.series??t.series;if(!h&&!Array.isArray(l))throw new TypeError("Chart categories must be a nonempty array of strings.");if(!Array.isArray(f))throw new RangeError("A chart needs from 1 through 255 series.");const d=h?.rowCount??l.length,g=f.length;if(!d)throw new TypeError("Chart categories must be a nonempty array of strings.");if(!g||g>255)throw new RangeError("A chart needs from 1 through 255 series.");if(!h&&d>1048575)throw new RangeError("Chart data must fit Excel's rows including its header.");if(e==="pie"&&g!==1)throw new TypeError("A pie chart supports exactly one series.");const w=d*g;if(w>c)throw new P("RESOURCE_LIMIT","maxChartPoints exceeded.");let T=0;const v=(U,X)=>{if(typeof U!="string")throw new TypeError(X+" must be a string.");if(U.length>32767)throw new RangeError(X+" exceeds 32,767 UTF-16 units.");if(T+=U.length,T>i)throw new P("RESOURCE_LIMIT","maxChartTextCharacters exceeded.");return k(U,a)},E=(U,X)=>U===void 0?void 0:v(U,X),R=E(s.title,"Chart title"),I=E(s.description,"Chart description"),z=E(s.language,"Chart language");let j;if(z!==void 0)try{if(j=Intl.getCanonicalLocales(z)[0],!j)throw new RangeError}catch{throw new TypeError("Chart language must be a language tag such as pl or pl-PL.")}const M=C({row:s.row,column:s.column,width:s.width,height:s.height,...I===void 0?{}:{description:I}},a);if(s.legend!==void 0&&s.legend!==!1&&!["right","bottom","left","top"].includes(s.legend))throw new TypeError("Unsupported chart legend position.");let L;if(s.dataLabels!==void 0){const U=p(s.dataLabels,["showValue","showCategoryName","showSeriesName","showPercent","position","numberFormat"],"chart.dataLabels");for(const Y of["showValue","showCategoryName","showSeriesName","showPercent"])if(U[Y]!==void 0&&typeof U[Y]!="boolean")throw new TypeError("Chart label flags must be booleans.");if(U.showPercent&&e!=="pie")throw new TypeError("Percent data labels require a pie chart.");const X=e==="pie"?["center","insideEnd","outsideEnd","bestFit"]:e==="line"?["center","above","below","left","right"]:["center","insideEnd","outsideEnd"];if(U.position!==void 0&&!X.includes(U.position))throw new TypeError("Data label position is unsupported for this chart type.");const V=E(U.numberFormat,"Data label number format");if(V!==void 0&&!V.trim())throw new TypeError("Data label number format cannot be blank.");L=Object.freeze({...U,...V===void 0?{}:{numberFormat:V}})}if(e==="pie"&&(s.categoryAxis!==void 0||s.valueAxis!==void 0))throw new TypeError("Pie charts have no axes.");let B,q;if(s.categoryAxis!==void 0){const U=E(p(s.categoryAxis,["title"],"chart.categoryAxis").title,"Category axis title");B=Object.freeze(U===void 0?{}:{title:U})}if(s.valueAxis!==void 0){const U=p(s.valueAxis,["title","minimum","maximum","numberFormat"],"chart.valueAxis");for(const Y of[U.minimum,U.maximum])if(Y!==void 0&&!Number.isFinite(Y))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 X=E(U.title,"Value axis title"),V=E(U.numberFormat,"Value axis number format");if(V!==void 0&&!V.trim())throw new TypeError("Value axis number format cannot be blank.");q=Object.freeze({...U,...X===void 0?{}:{title:X},...V===void 0?{}:{numberFormat:V}})}const G={...M,type:e,...j===void 0?{}:{language:j},...R===void 0?{}:{title:R},...I===void 0?{}:{description:I},...s.legend===void 0?{}:{legend:s.legend},...L===void 0?{}:{dataLabels:L},...B===void 0?{}:{categoryAxis:B},...q===void 0?{}:{valueAxis:q}};if(h){if(!n)throw new TypeError("A chart range must belong to the current workbook.");const{descriptor:U,retainText:X}=n(h),V=b(h,U,{availablePoints:c,availableText:i-T,retainText:X,policy:a},r,e);return Object.freeze({...G,data:V.data,binding:V,points:w,textCharacters:T+V.textCharacters})}const _=l,F=[],W=[];for(let U=0;U<d;U++)(U&255)===0&&S(r),F.push(v(_[U],"Chart category"));for(let U=0;U<g;U++){const X=f[U],V=p(X,["name","values","color"],"chart.series"),Y=v(V.name,"Chart series name"),re=V.values,A=V.color;if(!Array.isArray(re)||re.length!==d)throw new TypeError("Chart series values must match the category count.");if(A!==void 0&&(typeof A!="string"||!/^#?[0-9a-fA-F]{6}$/.test(A)))throw new TypeError("Chart colors must be opaque six-digit RGB hex values.");let $=!1;const J=[];for(let te=0;te<d;te++){(te&255)===0&&S(r);const he=re[te];if(typeof he!="number"||!Number.isFinite(he))throw new TypeError("Chart values must be finite numbers.");if(e==="pie"&&he<0)throw new RangeError("Pie charts require nonnegative values.");he>0&&($=!0),J.push(he)}if(e==="pie"&&!$)throw new RangeError("A pie chart needs at least one positive value.");W.push(Object.freeze({name:Y,values:Object.freeze(J),...A===void 0?{}:{color:A.replace(/^#/,"").toUpperCase()}}))}return Object.freeze({...G,data:Object.freeze({categories:Object.freeze(F),series:Object.freeze(W)}),points:w,textCharacters:T})}return Object.freeze({prepareChart:u})})(),mt=(()=>{const{beginTask:S,checkAbort:O,pause:P,taskYieldDue:k}=be,{OfficeIMOError:C}=me,{notifyProgress:y}=Ge,{ChunkedTextSink:m}=Ie,{ExportBudget:b}=We,{OpcPackage:x,officeRelationshipsNamespace:p,relationshipTypes:u,corePropertiesXml:o}=st,{escapeOoxmlAttribute:s,cleanXml:a,xmlDeclaration:c}=Pe,{StyleRegistry:i,spreadsheetNamespace:r,normalizeBorder:n}=Xe,{sheetName:e,assertXlsxValue:t,copyValue:h}=_e,{copyColumns:l}=Ne,{captureFields:f}=Ce,{captureColumnOutlines:d}=Ot,{captureTableSpans:g}=Ve,{assertExportValue:w}=ve,{Worksheet:T}=jt,{defineTable:v,tableXml:E}=Zt,{copyHyperlink:R,drawingXml:I,drawingContentType:z}=Je,{TextOverflow:j}=$t,{captureWorkbookOptions:M,sheetOptionFields:L}=qe,{prepareChart:B}=Jt,{qualifiedColumnRange:q,resolveDataColumn:G}=Ye,{chartContentType:_,writeChartXml:F}=Pt,W="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",U=re=>"application/vnd.openxmlformats-officedocument.spreadsheetml."+re+"+xml";function X(re,A){const $=f(re,L),J=l($.columns??[],!0),te=$.footer&&f($.footer,["rows","values","totals","style"]),he=$.print&&f($.print,["paper","orientation","fitToWidth","fitToHeight","repeatHeaders","margins","header","footer"]);return{...$,columns:J,...$.columnOutlines===void 0?{}:{columnOutlines:d($.columnOutlines,J.length)},...$.headerRows===void 0?{}:{headerRows:g($.headerRows,J.length)},...$.headerBorder===void 0?{}:{headerBorder:n($.headerBorder)},...te?{footer:{...te,...te.rows===void 0?{}:{rows:g(te.rows,J.length)},...te.values===void 0?{}:{values:te.values.map(h)}}}:{},...$.table?{table:f($.table,["name","style","bandedRows","bandedColumns","firstColumn","lastColumn"])}:{},...$.autoSize?{autoSize:f($.autoSize,["sampleRows","minWidth","maxWidth"])}:{},...$.title?{title:f($.title,["text","style","height"])}:{},...he?{print:{...he,...he.margins===void 0?{}:{margins:f(he.margins,["left","right","top","bottom","header","footer"])}}}:{},...$.hyperlinks?{hyperlinks:$.hyperlinks.map(se=>R(se,A))}:{}}}class V{portableValues=!1;static forTable(A){const $=new V(A);return $.portableValues=!0,$}get valueValidator(){return this.portableValues?w:t}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(A){if(this.assertOpen(),this.registering)throw new C("INVALID_STATE","Workbook registrations cannot be reentered from input getters.");this.registering=!0;try{return A()}finally{this.registering=!1}}budget;settings;constructor(A={}){A=M(A);const $=A.dateMode??"local",J=A.compression??"auto",te=A.invalidCharacterPolicy??"strip";if($!=="local"&&$!=="utc")throw new RangeError("dateMode must be local or utc.");if(J!=="auto"&&J!=="store")throw new RangeError("compression must be auto or store.");if(A.oversizedText!==void 0&&!["reject","preserve"].includes(A.oversizedText))throw new RangeError("oversizedText must be reject or preserve.");if(a("",te),o(A,te),this.budget=new b(A.limits),this.styles=new i(te,A.limits?.maxStyles,A.limits?.maxDifferentialStyles),A.sink!==void 0&&typeof A.sink.write!="function")throw new TypeError("sink must be a ByteSink.");this.settings=Object.freeze({...A,...A.limits?{limits:Object.freeze({...A.limits})}:{},dateMode:$,compression:J,invalidCharacterPolicy:te}),this.writers=Object.freeze({...A.cellValueWriters});for(const he of Object.values(this.writers))if(typeof he!="function")throw new TypeError("Cell value writers must be functions.");S(),this.package=new x({compression:J,invalidCharacterPolicy:te,...A.signal?{signal:A.signal}:{},...A.sink?{sink:A.sink}:{},...A.limits?.maxOutputBytes===void 0?{}:{maxOutputBytes:A.limits.maxOutputBytes}}),this.package.setProperties(A,A.appProperties),this.addXmlPart("/xl/workbook.xml",U("sheet.main"),()=>this.workbookXml()),this.addXmlPart("/xl/styles.xml",U("styles"),()=>this.styles.toXml())}addXmlPart(A,$,J){this.package.addPart({uri:A,contentType:$,data:async te=>{const he=new m(te,this.settings.signal);await he.write(J()),await he.close()}})}workbookXml(){return c+'<workbook xmlns="'+r+'" xmlns:r="'+p+'"><workbookPr date1904="0"/><bookViews><workbookView/></bookViews><sheets>'+this.sheets.map((A,$)=>'<sheet name="'+s(A.name,this.settings.invalidCharacterPolicy)+'" sheetId="'+($+1)+'"'+(A.hidden?' state="hidden"':"")+' r:id="rId'+($+1)+'"/>').join("")+"</sheets>"+(this.sheets.some(A=>A.printSettings)?"<definedNames>"+this.sheets.map((A,$)=>{const J="'"+A.name.replace(/'/g,"''")+"'!";return A.printSettings?'<definedName name="_xlnm.Print_Area" localSheetId="'+$+'">'+s(J+"$A$1:$"+A.lastColumn+"$"+A.totalRows,this.settings.invalidCharacterPolicy)+"</definedName>"+(A.printSettings.repeatHeaders&&A.firstHeaderRow?'<definedName name="_xlnm.Print_Titles" localSheetId="'+$+'">'+s(J+"$"+A.firstHeaderRow+":$"+A.headerRowCount,this.settings.invalidCharacterPolicy)+"</definedName>":""):""}).join("")+"</definedNames>":"")+(this.hasAuthoredFormulas?'<calcPr calcMode="auto" fullCalcOnLoad="1" forceFullCalc="1"/>':"")+"</workbook>"}assertOpen(){try{O(this.settings.signal)}catch(A){throw this.discard(A).catch(()=>{}),A}if(this.state==="failed")throw this.failure;if(this.state!=="open")throw new C("INVALID_STATE","Workbook is already finalized.")}writerFor(A){return Object.prototype.hasOwnProperty.call(this.writers,A)?this.writers[A]:void 0}preserveText(A,$,J){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 j(e("Text overflow",this.names,this.settings.invalidCharacterPolicy),this.settings.limits?.maxOverflowCharacters??4e6,this.settings.invalidCharacterPolicy,(te,he,se)=>{this.budget.row(se),this.budget.reserve(te,he)})),this.overflow.add(A,$,J)}checkSheetLimit(A){if(A>65526)throw new RangeError("Workbook has too many sheets.");if(this.settings.limits?.maxSheets!==void 0&&A>this.settings.limits.maxSheets)throw new C("RESOURCE_LIMIT","maxSheets exceeded.")}checkLinks(A){if(this.settings.limits?.maxHyperlinks!==void 0&&this.links+A>this.settings.limits.maxHyperlinks)throw new C("RESOURCE_LIMIT","maxHyperlinks exceeded.")}retainLink(A=1){this.checkLinks(A),this.links+=A}checkImage(A){if(this.settings.limits?.maxImageBytes!==void 0&&this.imageBytes+A>this.settings.limits.maxImageBytes)throw new C("RESOURCE_LIMIT","maxImageBytes exceeded.")}retainImage(A){this.checkImage(A),this.imageBytes+=A}retainBufferedBytes(A){this.budget.check("maxOutputBytes",this.bufferedBytes+A),this.bufferedBytes+=A}checkMerges(A){if(this.mergedRanges+A>(this.settings.limits?.maxMergedRanges??1e4))throw new C("RESOURCE_LIMIT","maxMergedRanges exceeded.")}checkConditionalFormats(A){if(this.conditionalFormats+A>(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(A){if(this.formulaCharacters+A>(this.settings.limits?.maxFormulaCharacters??1e6))throw new C("RESOURCE_LIMIT","maxFormulaCharacters exceeded.");this.formulaCharacters+=A,this.hasAuthoredFormulas=!0}checkChartText(A){if(this.chartTextCharacters+A>(this.settings.limits?.maxChartTextCharacters??1e6))throw new C("RESOURCE_LIMIT","maxChartTextCharacters exceeded.")}retainChartText(A){this.checkChartText(A),this.chartTextCharacters+=A}resolveChartBinding(A){const $=A.sheet;if(!this.sheets.includes($)||$.hidden)throw new TypeError("Bound charts require a visible worksheet in the same workbook.");const J=$.chartBindingMetadata,te=A.firstRow??0;if($.isBusy||J.closed||te<J.rows)throw new C("INVALID_STATE","Register a chart before its first selected data row is written, while the source worksheet is idle.");const he=G(J.columns,A.categoryColumn,"Chart"),se=A.series.map(fe=>G(J.columns,fe.column,"Chart")),ne=J.headerRows+te+1;return{descriptor:{source:$,sheetName:J.name,headerRows:J.headerRows,categoryColumn:he,seriesColumns:se,seriesNames:se.map(fe=>J.columns[fe-1].header),categoryFormula:q(J.name,he,ne,A.rowCount),valueFormulas:se.map(fe=>q(J.name,fe,ne,A.rowCount)),nameFormulas:se.map((fe,ye)=>A.series[ye].name===void 0?J.headerReferences[fe-1]:void 0)},retainText:fe=>this.retainChartText(fe)}}registerChart(A){return this.registration(()=>{if(this.nativeCharts.length>=(this.settings.limits?.maxCharts??100))throw new C("RESOURCE_LIMIT","maxCharts exceeded.");const $=B(A,this.settings.invalidCharacterPolicy,(this.settings.limits?.maxChartPoints??1e5)-this.chartPoints,(this.settings.limits?.maxChartTextCharacters??1e6)-this.chartTextCharacters,this.settings.signal,te=>this.resolveChartBinding(te));this.assertOpen(),this.checkChartText($.textCharacters),this.checkSheetLimit(this.sheets.length+this.chartSourceSheets+($.binding?0:1)+(this.overflow?1:0));const J=Object.freeze({...$,id:this.nativeCharts.length+1,dataSheetName:$.binding?$.binding.source.name:e("Chart data "+(this.nativeCharts.length+1),this.names,this.settings.invalidCharacterPolicy)});return this.nativeCharts.push(J),this.chartPoints+=$.points,this.chartTextCharacters+=$.textCharacters,$.binding?$.binding.source.retainChartBinding($.binding):this.chartSourceSheets++,J})}async openSheet(A){if(this.activeSheet&&this.activeSheet!==A){if(this.activeSheet.isBusy)throw new C("INVALID_STATE","Await the active streamed worksheet before starting another.");await this.activeSheet.finish()}return this.activeSheet=A,this.package.openPart("/xl/worksheets/sheet"+(this.sheets.indexOf(A)+1)+".xml",U("worksheet"))}async discard(A){this.state="failed",this.failure=A,await Promise.allSettled(this.sheets.map($=>$.discard(A))),await this.package.discard(A),this.overflow?.clear(),this.nativeCharts.length=0}get worksheets(){return Object.freeze([...this.sheets])}get rowCount(){return this.sheets.reduce((A,$)=>A+$.reportRowCount,0)}addWorksheet(A,$={}){return this.registration(()=>{this.checkSheetLimit(this.sheets.length+this.chartSourceSheets+1+(this.overflow?1:0));const J=X($,this.settings.invalidCharacterPolicy),te=T.validate(this,J);let he=J.table;if(he&&he.name===void 0){let fe=this.tableCount+1;for(;this.tableNames.has(("Table"+fe).toLowerCase());)fe++;he={...he,name:"Table"+fe}}const se=he?v(this.tableCount+1,he,J.columns??[],this.settings.invalidCharacterPolicy):void 0;if(se&&this.tableNames.has(se.name.toLowerCase()))throw new TypeError("Duplicate Excel table name: "+se.name);e(A,this.names,this.settings.invalidCharacterPolicy,!1);const ne=T.create(this,()=>e(A,this.names,this.settings.invalidCharacterPolicy,!1),J,se,!1,te.conditional,te.validations);return this.assertOpen(),this.checkSheetLimit(this.sheets.length+this.chartSourceSheets+1+(this.overflow?1:0)),this.names.add(ne.name.toLowerCase()),this.mergedRanges+=ne.mergeCount,this.conditionalFormats+=ne.conditionalFormatCount,this.dataValidationCount+=ne.dataValidations.count,this.validationTextCharacters+=ne.dataValidations.textCharacters,se&&(this.tableNames.add(se.name.toLowerCase()),this.tableCount++),this.sheets.push(ne),ne})}addPart(A){this.assertOpen();const{uri:$,contentType:J,data:te,relationship:he}=A,se=he&&{id:he.id,type:he.type,source:he.source};if(this.assertOpen(),this.package.addPart({uri:$,contentType:J,data:te}),se){const{source:ne,id:fe,type:ye}=se;this.package.addRelationship(ne??"/xl/workbook.xml",{id:fe,type:ye,target:$})}}finish(){try{O(this.settings.signal)}catch(A){return this.discard(A).then(()=>{throw A})}if(this.completion)return this.completion;if(this.state==="failed")return Promise.reject(this.failure);if(this.assertOpen(),this.sheets.some(A=>A.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 A=this.rowCount;for(let J=0;J<this.sheets.length;J++){const te=this.sheets[J],he="/xl/worksheets/sheet"+(J+1)+".xml";await te.finish();const se=te.takePrepared();se&&this.package.addPrepared(he,U("worksheet"),se);const ne=te.tableDefinition;if(ne){const fe="/xl/tables/table"+ne.id+".xml";this.addXmlPart(fe,U("table"),()=>E(ne,te.rowCount,this.settings.invalidCharacterPolicy,te.headerRowCount,te.footerSettings)),this.package.addRelationship(he,{id:"table",type:p+"/table",target:fe})}for(let fe=0;fe<te.hyperlinks.length;fe++)O(this.settings.signal),this.package.addRelationship(he,{id:"link"+(fe+1),type:p+"/hyperlink",target:te.hyperlinks[fe].target,external:!0}),(fe&255)===255&&k()&&(await P(),O(this.settings.signal));if(te.images.length||te.charts.length){const fe="/xl/drawings/drawing"+(J+1)+".xml";this.addXmlPart(fe,z,()=>I(te.images,this.settings.invalidCharacterPolicy,te.charts)),this.package.addRelationship(he,{id:"drawing",type:p+"/drawing",target:fe});for(let ye=0;ye<te.images.length;ye++){O(this.settings.signal);const D="/xl/media/sheet"+(J+1)+"-image"+(ye+1)+".png";this.package.addPart({uri:D,contentType:"image/png",data:te.images[ye].data}),this.package.addRelationship(fe,{id:"image"+(ye+1),type:p+"/image",target:D}),(ye&255)===255&&k()&&(await P(),O(this.settings.signal))}for(const ye of te.charts){O(this.settings.signal);const D="/xl/charts/chart"+ye.id+".xml";this.package.addPart({uri:D,contentType:_,data:H=>F(ye,H,this.settings.invalidCharacterPolicy,this.settings.signal)}),this.package.addRelationship(fe,{id:"chart"+ye.id,type:p+"/chart",target:D})}}}if(this.overflow){const J=T.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(J),await J.finish(this.overflow.values());const te=J.takePrepared();te&&this.package.addPrepared("/xl/worksheets/sheet"+this.sheets.length+".xml",U("worksheet"),te),this.overflow.clear()}for(const J of this.nativeCharts){if(O(this.settings.signal),J.binding)continue;const te=T.createChartData(this,J);this.sheets.push(te);function*he(){for(let ne=0;ne<J.data.categories.length;ne++)yield[J.data.categories[ne],...J.data.series.map(fe=>fe.values[ne])]}await te.finish(he());const se=te.takePrepared();se&&this.package.addPrepared("/xl/worksheets/sheet"+this.sheets.length+".xml",U("worksheet"),se)}this.package.addRelationship("/",{id:"workbook",type:u.officeDocument,target:"/xl/workbook.xml"});for(let J=0;J<this.sheets.length;J++)O(this.settings.signal),this.package.addRelationship("/xl/workbook.xml",{id:"rId"+(J+1),type:u.worksheet,target:"/xl/worksheets/sheet"+(J+1)+".xml"}),(J&255)===255&&k()&&(await P(),O(this.settings.signal));this.package.addRelationship("/xl/workbook.xml",{id:"styles",type:u.styles,target:"/xl/styles.xml"});const $=await this.package.finish();for(const J of this.sheets)J.releaseCharts();return this.nativeCharts.length=0,y(this.settings.onProgress,{phase:"complete",rows:A,bytes:$}),O(this.settings.signal),this.state="complete",{rows:A,sheets:this.sheets.length,bytes:$}}catch(A){throw await this.discard(A),A}})(),this.completion}toBlob(){try{O(this.settings.signal)}catch(A){return this.discard(A).then(()=>{throw A})}if(this.settings.sink)throw new C("INVALID_STATE","This workbook uses a caller-owned sink; use finish().");if(!this.result){const A=this.finish();this.result=A.then(()=>this.package.toBlob(W))}return this.result}}return Object.freeze({Workbook:V})})(),gt=(()=>{const{ExportCell:S,assertScalar:O}=ve,{captureWorkbookOptions:P,sheetOptionFields:k}=qe,{captureFields:C}=Ce;function y(u){for(const o of["font","fill","border","numberFormat"])if(typeof u?.[o]=="number")throw new TypeError("Workbook-local style indexes require the advanced Workbook API; use style definitions.");return u}function m(u){return u instanceof S||O(u),u}function b(u={}){if(u=C(u,k),u.headerStyle!==void 0)throw new TypeError("Workbook-local header styles require the advanced Workbook API; use boldHeader, headerFill, headerBorder and headerWrap.");y(u.alternatingRowStyle),y(u.title?.style),y(u.footer?.style),u.footer?.values?.forEach(m);const o=u.rowStyle,s=u.cellStyle;for(const a of[o,s])if(a!==void 0&&typeof a!="function")throw new TypeError("Style callbacks must be functions.");return{...u,...o?{rowStyle:a=>y(o(a))}:{},...s?{cellStyle:a=>y(s(a))}:{}}}function x(u={}){u=P(u);const o=u.cellValueWriters;if(!o)return u;const s=Object.create(null);for(const[a,c]of Object.entries(o)){if(typeof c!="function")throw new TypeError("Cell value writers must be functions.");s[a]=(i,r)=>m(c(i,r))}return{...u,cellValueWriters:s}}return Object.freeze({portableSheet:b,portableWorkbook:x})})(),At=(()=>{const{withDestination:S}=Ie,{copyColumns:O}=Ne,{Workbook:P}=mt,{portableSheet:k,portableWorkbook:C}=gt,{captureFields:y}=Ce,{sheetOptionFields:m,workbookOptionFields:b}=qe;function x(a){a=y(a,[...b,"columns","sheet"]);const c=O(a.columns),i=a.sheet&&y(a.sheet,[...m,"name"]);return{...C(a),columns:c,sheet:{...k(i),...i?.name===void 0?{}:{name:i.name}}}}function p(a,c){const{name:i="Data",...r}=c.sheet??{};return a.addWorksheet(i,{boldHeader:!0,autoFilter:r.includeHeader!==!1,autoSize:{minWidth:6,maxWidth:54},...r,columns:c.columns})}async function u(a,c){const i=x(c),{columns:r,sheet:n,...e}=i,t=P.forTable(e);try{return await p(t,i).addRows(a),await t.toBlob()}catch(h){throw await t.discard(h),h}}async function o(a,c,i){const r=x(i);return S(c,async n=>{const{columns:e,sheet:t,...h}=r,l=P.forTable({...h,sink:n});try{const f=p(l,r),d=r.columns.length;await f.addRows(a);const g=await l.finish();return{rows:g.rows,columns:d,bytes:g.bytes}}catch(f){throw await l.discard(f),f}})}return Object.freeze({writeXlsx:u,writeXlsxTo:o})})(),Yt=(()=>{const{assertGroupedReportSource:S}=Ue,{captureFields:O}=Ce,{OfficeIMOError:P}=me,{fields:k}=ot,{sheetOptionFields:C}=qe,{portableSheet:y}=gt,{resolveDataColumn:m}=Ye,{copyStylePatch:b}=Xe,x=["labelColumn","subtotalLabel","grandTotalLabel","includeGrandTotal","collapseGroups","sheet","groupStyle","subtotalStyle","grandTotalStyle","conditionalFormats","dataValidation"],p=["columns","headerRows","footer","table","mergedCells","hyperlinks","conditionalFormats","dataValidation","rowStyle","cellStyle","rowOutline","maxOutlineLevel"];function u(i,r){return m(i.columns,r,"Grouped detail")+1}function o(i,r,n){if(r!==void 0){if(!Array.isArray(r))throw new TypeError("conditionalFormats must be an array.");if(r.length>n)throw new P("RESOURCE_LIMIT","maxConditionalFormats exceeded.");return r.map(e=>{const t=O(e,["type","range","style","stopIfTrue","operator","value","values","formula","stops","color","minimum","maximum","showValue"]),h=t.range;if(typeof h=="string")throw new TypeError("Grouped conditional formats require detail-column selectors rather than A1 or generated-row ranges.");k(h,["column","through"],"grouped conditional range");const l=O(h,["column","through"]);return{...t,range:{column:u(i,l.column),...l.through===void 0?{}:{through:u(i,l.through)}}}})}}function s(i,r,n){if(r!==void 0){if(!Array.isArray(r))throw new TypeError("dataValidation must be an array.");if(r.length>n)throw new P("RESOURCE_LIMIT","maxDataValidations exceeded.");return r.map(e=>{const t=O(e,["type","column","items","allowBlank","showErrorMessage","errorStyle","errorTitle","errorMessage"]);return{...t,column:u(i,t.column)}})}}function a(i,r,n=1e3,e=1e3){if(S(i),!r||typeof r!="object")throw new TypeError("Grouped XLSX options require host-authored labels.");const t=O(r,x),h=O(t.sheet??{},[...C,"name"]);if(!t.labelColumn||typeof t.labelColumn!="object")throw new TypeError("Grouped XLSX needs a leading label column.");const l=O(t.labelColumn,["header","width","wrapText","alignment"]);if(typeof l.header!="string")throw new TypeError("The leading label column needs a string header.");for(const g of[t.subtotalLabel,t.grandTotalLabel])if(typeof g!="function")throw new TypeError("Grouped summary labels must be functions.");for(const g of[t.includeGrandTotal,t.collapseGroups])if(g!==void 0&&typeof g!="boolean")throw new TypeError("Grouped XLSX flags must be booleans.");for(const g of p)if(h[g]!==void 0)throw new TypeError("Grouped XLSX owns worksheet "+g+".");if(h.autoFilter!==void 0&&h.autoFilter!==!1)throw new TypeError("Grouped summary rows cannot use a native table or autofilter.");for(const g of[t.groupStyle,t.subtotalStyle,t.grandTotalStyle])g!==void 0&&y({alternatingRowStyle:g});for(const g of i.columns)if(Object.prototype.hasOwnProperty.call(i.totals,g.key)&&g.type!=="number")throw new TypeError("Editable grouped totals require explicitly numeric columns.");const f=o(i,t.conditionalFormats,n),d=s(i,t.dataValidation,e);return{...t,labelColumn:l,sheet:y(h),...f===void 0?{}:{conditionalFormats:f},...d===void 0?{}:{dataValidation:d},...t.groupStyle?{groupStyle:b(t.groupStyle)}:{},...t.subtotalStyle?{subtotalStyle:b(t.subtotalStyle)}:{},...t.grandTotalStyle?{grandTotalStyle:b(t.grandTotalStyle)}:{}}}return Object.freeze({groupedOptionFields:x,prepareGroupedSheet:a})})(),wt=(()=>{const{groupedReportOperation:S}=Ue,{checkAbort:O,withAbort:P}=be,{withDestination:k}=Ie,{captureFields:C}=Ce,{Workbook:y}=mt,{FormulaCell:m}=Ke,{columnName:b}=_e,{captureWorkbookLimits:x,workbookOptionFields:p}=qe,{retainDataRowRanges:u}=at,{groupedOptionFields:o,prepareGroupedSheet:s}=Yt,a={average:1,count:2,max:4,min:5,sum:9};function c(d){if(typeof d?.then=="function"&&Promise.resolve(d).catch(()=>{}),typeof d!="string")throw new TypeError("Grouped summary labels must return strings.");return d}function i(d,g,w,T,v){const E=g+w+":"+g+T,R="SUBTOTAL("+a[d]+","+E+")";return new m(d==="average"||d==="min"||d==="max"?"IF(SUBTOTAL(2,"+E+')=0,"",'+R+")":R,v,d==="count"?0:void 0)}async function r(d,g,w,T,v){O(T.signal);const{labelColumn:E,subtotalLabel:R,grandTotalLabel:I,includeGrandTotal:z,collapseGroups:j,sheet:M,groupStyle:L,subtotalStyle:B,grandTotalStyle:q,conditionalFormats:G,dataValidation:_}=w;let F=0,W;const U=[],X=[],V=[];let Y=0,re=0,A,$;const{name:J="Data",...te}=M??{},he=[{...E,type:"string"},...g.columns],se={groupStart:L??{font:{bold:!0}},groupEnd:B??{font:{bold:!0}},complete:q??{font:{bold:!0}}},ne=d.addWorksheet(J,{boldHeader:!0,autoSize:{minWidth:6,maxWidth:54},...te,columns:he,...G===void 0?{}:{conditionalFormats:G},..._===void 0?{}:{dataValidation:_},maxOutlineLevel:g.groupBy.length,rowStyle:()=>W&&W.kind!=="row"?se[W.kind]:void 0,rowOutline:()=>{if(!W||W.kind==="complete")return;const D=W.kind==="row"?W.path.length:W.level;return{level:D,hidden:!!j&&D>0,collapsed:!!j&&W.kind==="groupEnd"}}});u(ne,V);const fe=g.columns.map(D=>Object.prototype.hasOwnProperty.call(g.totals,D.key)?g.totals[D.key]:void 0);async function*ye(){for await(const D of T.events){W=D;const H=ne.rowCount+ne.headerRowCount+1;if(D.kind==="groupStart"){const N={groupIndex:D.groupIndex,level:D.level,key:D.key,label:D.label,path:D.path,rows:0,totals:Object.freeze([]),startRow:H,firstDetailRow:0,lastDetailRow:0,summaryRow:0};U.push(N),X.push(N),yield[D.label,...g.columns.map(()=>null)]}else if(D.kind==="row"){F++,v?.(F),Y||=H,re=H;const N=V.at(-1);N&&N.lastRow+1===H?N.lastRow=H:V.push({firstRow:H,lastRow:H});for(const Q of X)Q.firstDetailRow||=H,Q.lastDetailRow=H;yield[null,...D.values]}else if(D.kind==="groupEnd"){const N=X.pop();N.summaryRow=H,N.rows=D.rows,N.totals=D.totals,yield[c(R(D)),...fe.map((Q,ie)=>Q?i(Q,b(ie+2),N.firstDetailRow,N.lastDetailRow,D.totals[ie]):null)]}else $=Object.freeze({rows:D.rows,groups:D.groups,totals:D.totals}),z!==!1&&(A=H,yield[c(I(D)),...fe.map((N,Q)=>N?Y?i(N,b(Q+2),Y,re,D.totals[Q]):D.totals[Q]:null)])}}try{return O(T.signal),await P(ne.addRows(ye()),T.signal),await P(ne.close(),T.signal),Object.freeze({worksheet:ne,rows:F,columns:he.length,detailRanges:Object.freeze(V.map(D=>Object.freeze({...D}))),groups:Object.freeze(U.map(D=>Object.freeze({...D}))),grandSummary:$,...A===void 0?{}:{grandTotalRow:A}})}catch(D){throw await d.discard(D),D}}async function n(d,g,w){const T=s(g,w,d.settings.limits?.maxConditionalFormats??1e3,d.availableDataValidations),v=S(g,d.settings.signal);try{return await r(d,g,T,v)}finally{v.dispose()}}function e(d,g){if(!g||typeof g!="object")throw new TypeError("Grouped XLSX options require host-authored labels.");const w=C(g,[...p,...o]);if(w.sink!==void 0||w.cellValueWriters!==void 0)throw new TypeError("Grouped XLSX owns its destination and uses already resolved source values.");const T=w.limits===void 0?void 0:x(w.limits);return{...w,...T===void 0?{}:{limits:T},...s(d,w,T?.maxConditionalFormats??1e3,T?.maxDataValidations??1e3)}}async function t(d,g,w){const{labelColumn:T,subtotalLabel:v,grandTotalLabel:E,includeGrandTotal:R,collapseGroups:I,sheet:z,groupStyle:j,subtotalStyle:M,grandTotalStyle:L,conditionalFormats:B,dataValidation:q,onProgress:G,..._}=g,F=S(d,_.signal);let W=0,U;const X=G?V=>G({...V,rows:W,...V.sheetRows===void 0?{}:{sheetRows:W}}):void 0;try{U=new y({..._,...F.signal?{signal:F.signal}:{},...X?{onProgress:X}:{},...w?{sink:w}:{}});const V=await r(U,d,g,F,re=>{W=re});if(w){const re=await U.finish();return{result:{rows:W,columns:V.columns,bytes:re.bytes}}}const Y=await U.toBlob();return{blob:Y,result:{rows:W,columns:V.columns,bytes:Y.size}}}catch(V){throw await U?.discard(V),V}finally{F.dispose()}}async function h(d,g){return(await t(d,e(d,g))).blob}async function l(d,g,w){const T=e(d,w);return k(g,async v=>(await t(d,T,v)).result)}return Object.freeze({addGroupedXlsx:n,writeGroupedXlsx:h,writeGroupedXlsxTo:l})})(),Qt=Object.freeze({Workbook:mt.Workbook,writeXlsx:At.writeXlsx,writeXlsxTo:At.writeXlsxTo,writeGroupedXlsx:wt.writeGroupedXlsx,writeGroupedXlsxTo:wt.writeGroupedXlsxTo,addGroupedXlsx:wt.addGroupedXlsx,createGroupedReport:Ue.createGroupedReport,Worksheet:jt.Worksheet,Cell:_e.Cell,FormulaCell:Ke.FormulaCell,StyleRegistry:Xe.StyleRegistry,NumberFormats:Xe.NumberFormats,saveBlob:rt.saveBlob,ExportCell:ve.ExportCell}),Ze=(()=>{const{captureFields:S}=Ce;function O(y,m,b=14400){if(!Number.isFinite(y)||y<=0||y>b)throw new RangeError(m+" must be positive and at most "+b+".");return y}function P(y){if(typeof y!="string"||!/^#?[0-9a-f]{6}$/i.test(y))throw new TypeError("PDF colors must be six-digit RGB hex strings.");const m=y.replace(/^#/,"");return[0,2,4].map(b=>String(Math.round(parseInt(m.slice(b,b+2),16)/255*1e4)/1e4)).join(" ")}function k(y={}){if(!y||typeof y!="object")throw new TypeError("PDF presentation must be an object.");const m=S(y,["background","color","numberFormat","bold","italic","wrapText","alignment"]);m.background!==void 0&&P(m.background),m.color!==void 0&&P(m.color);for(const b of["bold","italic","wrapText"])if(m[b]!==void 0&&typeof m[b]!="boolean")throw new TypeError("PDF presentation "+b+" must be boolean.");if(m.alignment!==void 0&&!["left","center","right"].includes(m.alignment))throw new TypeError("PDF table alignment supports left, center and right.");return Object.freeze(m)}return Object.freeze({positive:O,color:P,presentation:k})})(),yt=(()=>{const{OfficeIMOError:S}=me,{positive:O,presentation:P}=Ze,k=["fontSize","presentation","keepTogether","keepWithNext","spaceBefore","spaceAfter"],C=["bold","italic","color","alignment"];function y(p){if(p&&typeof p.then=="function")throw Promise.resolve(p).catch(()=>{}),new TypeError("PDF paragraph styles must be synchronous objects.");if(!p||typeof p!="object"||Array.isArray(p)||Object.keys(p).some(r=>!k.includes(r)))throw new TypeError("PDF paragraph styles support fontSize, presentation, keepTogether, keepWithNext, spaceBefore and spaceAfter.");const{fontSize:u,presentation:o,keepTogether:s,keepWithNext:a,spaceBefore:c,spaceAfter:i}=p;u!==void 0&&O(u,"Paragraph font size",144);for(const[r,n]of[["keepTogether",s],["keepWithNext",a]])if(n!==void 0&&typeof n!="boolean")throw new TypeError("Paragraph "+r+" must be boolean.");for(const r of[c,i])if(r!==void 0&&(!Number.isFinite(r)||r<0||r>14400))throw new RangeError("Paragraph spacing must be from zero through 14,400 points.");if(o!==void 0&&(!o||typeof o!="object"||Array.isArray(o)||Object.keys(o).some(r=>!C.includes(r))))throw new TypeError("PDF paragraph presentation supports bold, italic, color and alignment.");return Object.freeze({...u===void 0?{}:{fontSize:u},...o===void 0?{}:{presentation:P(o)},...s===void 0?{}:{keepTogether:s},...a===void 0?{}:{keepWithNext:a},...c===void 0?{}:{spaceBefore:c},...i===void 0?{}:{spaceAfter:i}})}function m(p,u){if(!Number.isSafeInteger(u)||u<0)throw new RangeError("maxParagraphStyles must be a nonnegative safe integer.");const o=Object.create(null);if(p===void 0)return Object.freeze(o);if(p&&typeof p.then=="function")throw Promise.resolve(p).catch(()=>{}),new TypeError("paragraphStyles must be a synchronous record.");if(!p||typeof p!="object"||Array.isArray(p))throw new TypeError("paragraphStyles must be a record of named paragraph styles.");const s=Object.keys(p);if(s.length>u)throw new S("RESOURCE_LIMIT","maxParagraphStyles exceeded.");for(const a of s){if(!a.trim())throw new TypeError("Paragraph style names must be nonempty text.");o[a]=y(p[a])}return Object.freeze(o)}function b(p,u,o){let s={};if(p!==void 0){if(typeof p!="string"||!Object.prototype.hasOwnProperty.call(o,p))throw new TypeError("Unknown PDF paragraph style: "+String(p));s=o[p]}const a=y(u);return Object.freeze({...s,...a,...s.presentation||a.presentation?{presentation:Object.freeze({...s.presentation,...a.presentation})}:{}})}return Object.freeze({captureParagraphStyle:y,captureParagraphStyles:m,resolveParagraphStyle:b})})(),Fe=(()=>{const{OfficeIMOError:S}=me,{ExportBudget:O}=We,{copyColumns:P}=Ne,{captureTableSpans:k}=Ve,{copyExportValue:C}=tt,{captureFields:y}=Ce,{captureParagraphStyles:m}=yt,{captureBooleanText:b}=dt,{positive:x,color:p,presentation:u}=Ze,o={A3:{width:841.89,height:1190.551},A4:{width:595.276,height:841.89},A5:{width:419.528,height:595.276},LETTER:{width:612,height:792},LEGAL:{width:612,height:1008},TABLOID:{width:792,height:1224}},s=["columns","signal","onProgress","limits","textShaper","textDirection","pageSize","orientation","margins","fonts","tagged","fontSize","title","messageTop","messageBottom","includeHeader","headerRows","footer","headerPresentation","footerPresentation","alternateRowColor","padding","columnWidths","wideTable","pageHeader","pageFooter","pageNumbers","pageNumberLabels","booleanText","formatValue","formatRuns","compression","paragraphStyles"],a=["maxRows","maxCells","maxTextCharacters","maxOutputBytes","maxPages","maxColumns","maxTableBands","maxTableWindowRows","maxCellCharacters","maxTextRuns","maxGroupBlocks","maxRowLines","maxFontBytes","maxPageBytes","maxHyperlinks","maxImageBytes","maxImagePixels","maxImageWorkingBytes","maxVectorCommands","maxDrawingElements","maxStructureElements","maxMarkedContentReferences","maxSections","maxBookmarks","maxListItems","maxParagraphStyles"];function c(l){if(!l||typeof l!="object"||Array.isArray(l))throw new TypeError("PDF options must be an object.");const f=y(l,s),d=f.wideTable;return{...f,...d===void 0?{}:{wideTable:n(d)}}}function i(l){if(!l||typeof l!="object"||Array.isArray(l))throw new TypeError("PDF limits must be an object.");const f=y(l,a);for(const[d,g]of Object.entries(f))if(g!==void 0&&(!Number.isSafeInteger(g)||g<0))throw new RangeError(d+" must be a nonnegative safe integer.");return Object.freeze(f)}function r(l,f){if(!l||typeof l!="object"||Array.isArray(l))throw new TypeError("PDF footer must be an object.");const{values:d,totals:g,rows:w}=l;if(d!==void 0&&!Array.isArray(d))throw new TypeError("PDF footer values must be an array.");return Object.freeze({...d===void 0?{}:{values:Object.freeze(d.map(C))},...g===void 0?{}:{totals:Object.freeze({...g})},...w===void 0?{}:{rows:k(w,f)}})}function n(l){if(l===void 0||l==="fit"||l==="reject")return l;if(!l||typeof l!="object"||Array.isArray(l)||Object.keys(l).some(T=>!["mode","minimumColumnWidth","repeatColumns"].includes(T)))throw new TypeError("wideTable must be fit, reject or a bands policy.");const{mode:f,minimumColumnWidth:d,repeatColumns:g}=l;if(f!=="bands")throw new TypeError("wideTable.mode must be bands.");if(d!==void 0&&x(d,"Minimum PDF column width"),g!==void 0&&!Array.isArray(g))throw new TypeError("repeatColumns must be an array.");const w=g===void 0?[]:[...g];if(w.some(T=>typeof T=="number"?!Number.isSafeInteger(T)||T<0:typeof T!="string"||!T.length))throw new RangeError("repeatColumns must contain nonnegative indices or nonempty stable keys.");if(w.every(T=>typeof T=="number")&&w.some((T,v)=>v>0&&T<=w[v-1]))throw new RangeError("Numeric repeatColumns must contain sorted unique nonnegative indices.");return Object.freeze({mode:f,...d===void 0?{}:{minimumColumnWidth:d},repeatColumns:Object.freeze(w)})}function e(l,f){if(typeof l!="object")return Object.freeze([]);const d=new Set;for(const g of l.repeatColumns??[]){let w;if(typeof g=="number")w=g;else if(w=f.findIndex(T=>T.key===g),w<0||f.some((T,v)=>v!==w&&T.key===g))throw new TypeError("repeatColumns requires an unambiguous selected column key: "+g);if(w>=f.length)throw new RangeError("repeatColumns index exceeds the declared columns.");if(d.has(w))throw new TypeError("repeatColumns selects the same column more than once.");d.add(w)}return Object.freeze([...d].sort((g,w)=>g-w))}function t(l,f=!1){const d={...c(l)};if(d.booleanText=b(d.booleanText),d.limits!==void 0&&(d.limits=i(d.limits)),d.pageSize&&typeof d.pageSize=="object"&&(d.pageSize=Object.freeze(y(d.pageSize,["width","height"]))),d.margins&&typeof d.margins=="object"&&(d.margins=Object.freeze(y(d.margins,["top","right","bottom","left"]))),d.pageNumberLabels!==void 0){const F=d.pageNumberLabels;if(!F||typeof F!="object"||Array.isArray(F))throw new TypeError("pageNumberLabels must provide literal text.");const{prefix:W="Page ",separator:U=" of ",suffix:X=""}=F;if([W,U,X].some(V=>typeof V!="string"))throw new TypeError("Page-number labels must be text.");d.pageNumberLabels=Object.freeze({prefix:W,separator:U,suffix:X})}const g=d.textShaper,w=g?.shapeLine;if(g!==void 0&&(!g||typeof w!="function"))throw new TypeError("textShaper must provide shapeLine.");if(d.textDirection!==void 0&&!["auto","ltr","rtl"].includes(d.textDirection))throw new TypeError("textDirection must be auto, ltr or rtl.");const T=f?[]:P(d.columns).map(F=>Object.freeze(F));if(f&&(d.includeHeader=!1),!T.length&&!f)throw new TypeError("PDF tables need at least one declared column.");const v=d.fonts===void 0?void 0:y(d.fonts,["regular","bold","italic","boldItalic"]),E={...d,columns:T,...g?{textShaper:Object.freeze({shapeLine:w.bind(g)})}:{},...d.tagged?{tagged:Object.freeze(y(d.tagged,["language"]))}:{},...d.headerRows?{headerRows:k(d.headerRows,T.length)}:{},...v?{fonts:Object.freeze(v)}:{},...d.columnWidths?{columnWidths:Object.freeze([...d.columnWidths])}:{},...d.footer===void 0?{}:{footer:r(d.footer,T.length)},headerPresentation:Object.freeze({background:"e7edf5",bold:!0,...u(d.headerPresentation)}),footerPresentation:Object.freeze({background:"eef2f6",bold:!0,...u(d.footerPresentation)})},R=new O(E.limits),I={maxPages:1e4,maxColumns:1024,maxTableBands:64,maxTableWindowRows:256,maxCellCharacters:1e6,maxTextRuns:1e4,maxGroupBlocks:256,maxRowLines:1e5,maxFontBytes:16*1024*1024,maxPageBytes:8*1024*1024,maxHyperlinks:1e5,maxImageBytes:32*1024*1024,maxImagePixels:16*1024*1024,maxVectorCommands:1e5,maxDrawingElements:1e5,maxStructureElements:1e6,maxMarkedContentReferences:2e6,maxListItems:1e5,maxParagraphStyles:256,maxSections:1e3,maxBookmarks:1e4};for(const F of Object.keys(I)){const W=E.limits?.[F];W!==void 0&&(I[F]=W)}const z=m(E.paragraphStyles,I.maxParagraphStyles);if(T.length>I.maxColumns)throw new S("RESOURCE_LIMIT","maxColumns exceeded.");const j=typeof E.pageSize=="string"||E.pageSize===void 0?o[E.pageSize??"A4"]:E.pageSize;if(!j)throw new TypeError("Unsupported PDF page size.");if(x(j.width,"Page width"),x(j.height,"Page height"),E.orientation!==void 0&&!["portrait","landscape"].includes(E.orientation))throw new TypeError("Invalid PDF orientation.");const M=E.orientation==="landscape",L={width:M?Math.max(j.width,j.height):Math.min(j.width,j.height),height:M?Math.min(j.width,j.height):Math.max(j.width,j.height)},B={top:36,right:36,bottom:36,left:36,...typeof E.margins=="number"?{top:E.margins,right:E.margins,bottom:E.margins,left:E.margins}:E.margins};for(const F of Object.values(B))if(!Number.isFinite(F)||F<0)throw new RangeError("PDF margins must be finite and nonnegative.");if(B.left+B.right>=L.width||B.top+B.bottom>=L.height)throw new RangeError("PDF margins leave no content area.");const q=x(E.fontSize??9,"Font size",144),G=E.padding??4;if(!Number.isFinite(G)||G<0||G>72)throw new RangeError("PDF padding must be from 0 through 72 points.");for(const F of["title","messageTop","messageBottom"])if(E[F]!==void 0&&typeof E[F]!="string")throw new TypeError(F+" must be text.");for(const F of["pageHeader","pageFooter"])if(E[F]!==void 0&&typeof E[F]!="string"&&typeof E[F]!="function")throw new TypeError(F+" must be text or a synchronous callback.");for(const F of["formatValue","formatRuns"])if(E[F]!==void 0&&typeof E[F]!="function")throw new TypeError(F+" must be a synchronous function.");for(const F of["compression","includeHeader","pageNumbers"])if(E[F]!==void 0&&typeof E[F]!="boolean")throw new TypeError(F+" must be boolean.");if(E.alternateRowColor!==void 0&&p(E.alternateRowColor),E.footer?.values&&E.footer.values.length>T.length)throw new RangeError("Footer has more values than declared columns.");if(E.footer?.rows&&(E.footer.values!==void 0||E.footer.totals!==void 0))throw new TypeError("Structured footer rows cannot be combined with values/totals.");if(E.headerRows&&E.includeHeader===!1)throw new TypeError("headerRows requires includeHeader.");if(E.tagged!==void 0){if(!E.tagged||typeof E.tagged!="object"||typeof E.tagged.language!="string"||E.tagged.language.length>63)throw new TypeError("tagged.language must be a language tag such as en or en-US.");try{if(Intl.getCanonicalLocales(E.tagged.language).length!==1)throw new RangeError}catch{throw new TypeError("tagged.language must be a language tag such as en or en-US.")}}const _=E.limits?.maxImageWorkingBytes;return{options:{...E,paragraphStyles:z},paragraphStyles:z,page:L,margins:B,fontSize:q,padding:G,repeatedColumns:f?Object.freeze([]):e(E.wideTable,T),limits:{...I,..._===void 0?{}:{maxImageWorkingBytes:_}},budget:R}}return Object.freeze({positive:Ze.positive,color:Ze.color,presentation:Ze.presentation,pdfOptionFields:s,pdfLimitFields:a,capturePdfOptions:c,capturePdfLimits:i,captureWideTable:n,settings:t})})(),er=(()=>{function O(C,y,m,b){if(!Number.isSafeInteger(m)||m<0||m>=2**(b*8))throw new RangeError("Invalid PDF cross-reference field.");for(let x=b-1;x>=0;x--)C[y+x]=m%256,m=Math.floor(m/256)}function*P(C,y){if(C.length!==y.length)throw new Error("PDF cross-reference locations must align.");const m=Math.floor(32768/11);for(let b=0;b<C.length;b+=m){const x=Math.min(m,C.length-b),p=new Uint8Array(x*11);for(let u=0;u<x;u++){const o=b+u,s=u*11,a=C[o],c=y.at(o);if(a===void 0)throw new Error("PDF contains unwritten objects.");p[s]=o===0?0:c===void 0?1:2,O(p,s+1,a,8),O(p,s+9,o===0?65535:c??0,2)}yield p}}return Object.freeze({pdfXrefEntryBytes:11,pdfXrefChunks:P})})(),Be=(()=>{const{checkAbort:S,withAbort:O,pause:P,taskYieldDue:k}=be,{OfficeIMOError:C}=me,{pdfXrefChunks:y,pdfXrefEntryBytes:m}=er,b=256,x=32768,p=4096;class u{count;chunks=[];constructor(r){this.count=r}get length(){return this.count}reserve(){this.count++}set(r,n){const e=this.chunks[Math.floor(r/p)]??=new Uint16Array(p);e[r%p]=n+1}at(r){const n=this.chunks[Math.floor(r/p)]?.[r%p]??0;return n?n-1:void 0}}function o(i){if(!Number.isFinite(i)||Math.abs(i)>1e9)throw new RangeError("PDF coordinates and metrics must be finite and bounded.");return String(Math.round(i*1e3)/1e3)}function s(i){let r="";for(let n=0;n<i.length;n++){const e=i.charCodeAt(n);if(e>=55296&&e<=56319&&!(i.charCodeAt(n+1)>=56320&&i.charCodeAt(n+1)<=57343)||e>=56320&&e<=57343&&!(i.charCodeAt(n-1)>=55296&&i.charCodeAt(n-1)<=56319))throw new TypeError("PDF text contains an unpaired UTF-16 surrogate.");r+=e.toString(16).padStart(4,"0")}return r}class a{sink;signal;maxBytes;compressObjects;offsets=[0];compactIndices;compactBatch;compactArena;compactUnavailable=!1;encoder=new TextEncoder;buffer=new Uint8Array(32768);buffered=0;bytes=0;constructor(r,n,e=Number.MAX_SAFE_INTEGER,t=!1){this.sink=r,this.signal=n,this.maxBytes=e,this.compressObjects=t}reserve(){return this.offsets.push(void 0),this.compactIndices?.reserve(),this.offsets.length-1}async raw(r){if(S(this.signal),!Number.isSafeInteger(this.bytes+r.length)||this.bytes+r.length>this.maxBytes)throw new C("RESOURCE_LIMIT","maxOutputBytes exceeded.");this.bytes+=r.length;for(let n=0;n<r.length;){const e=Math.min(this.buffer.length-this.buffered,r.length-n);this.buffer.set(r.subarray(n,n+e),this.buffered),n+=e,this.buffered+=e,this.buffered===this.buffer.length&&await this.flushBytes()}}async text(r){await this.raw(this.encoder.encode(r))}async flush(){await this.flushCompact(),await this.flushBytes()}async flushBytes(){if(this.buffered){const r=this.buffer.subarray(0,this.buffered);await O(Promise.resolve(this.sink.write(r)),this.signal),this.buffered=0}k()&&await P(),S(this.signal)}tryCompactObject(r,n){S(this.signal),this.validateObject(r);const e=this.compactBatch;if(!e||!this.compressObjects||this.compactUnavailable||typeof CompressionStream!="function"||n.length>x||e.ids.length+1>=b)return!1;const t=String(r).length+String(e.bodyBytes).length+2,h=this.encodeCompactBody(n,e.bodyBytes,x-e.indexBytes-t-e.bodyBytes-2);return h===void 0?!1:(this.storeCompactBody(e,r,h),!0)}async compactObject(r,n){if(S(this.signal),this.validateObject(r),!this.compressObjects||this.compactUnavailable||n.length>x)return this.object(r,n);if(typeof CompressionStream!="function"){if(this.compactIndices)throw new Error("PDF object compression became unavailable.");return this.compactUnavailable=!0,this.object(r,n)}const e=String(r).length+4;let t=this.compactBatch;const h=String(r).length+String(t?.bodyBytes??0).length+2;let l=t&&t.ids.length<b?this.encodeCompactBody(n,t.bodyBytes,x-t.indexBytes-h-t.bodyBytes-2):void 0;if(t&&l===void 0&&(await this.flushCompact(),t=void 0,S(this.signal)),!t){if(l=this.encodeCompactBody(n,0,x-e-1),l===void 0)return this.object(r,n);let f;if(!this.compactIndices)try{f=new CompressionStream("deflate")}catch{return this.compactUnavailable=!0,this.object(r,n)}t={id:this.reserve(),compressor:f,ids:[],bodyOffsets:[],bodyBytes:0,indexBytes:1},this.compactIndices??=new u(this.offsets.length),this.compactBatch=t}this.storeCompactBody(t,r,l),t.ids.length===b&&await this.flushCompact()}storeCompactBody(r,n,e){this.offsets[n]=r.id,this.compactIndices.set(n,r.ids.length),r.indexBytes+=String(n).length+String(r.bodyBytes).length+2,r.ids.push(n),r.bodyOffsets.push(r.bodyBytes),this.compactArena[r.bodyBytes+e]=10,r.bodyBytes+=e+1}encodeCompactBody(r,n,e){if(e<0)return;const t=(this.compactArena??=new Uint8Array(x)).subarray(n,n+e);if(typeof this.encoder.encodeInto=="function"){const l=this.encoder.encodeInto(r,t);return l.read===r.length?l.written:void 0}const h=this.encoder.encode(r);if(!(h.length>e))return t.set(h),h.length}async flushCompact(){const r=this.compactBatch;if(!r)return;this.compactBatch=void 0;let n="";for(let l=0;l<r.ids.length;l++)n+=r.ids[l]+" "+r.bodyOffsets[l]+" ";const e=this.encoder.encode(n+"\n"),t=r.ids.length,h=this.compactArena.subarray(0,r.bodyBytes);r.ids.length=0,r.bodyOffsets.length=0,r.compressor?await this.compressedStream(r.id,h,"/Type /ObjStm /N "+t+" /First "+e.length,r.compressor,e):(this.start(r.id),await this.text(r.id+" 0 obj\n<< /Length "+(e.length+h.length)+" /Type /ObjStm /N "+t+" /First "+e.length+" >>\nstream\n"),await this.raw(e),await this.raw(h),await this.text("\nendstream\nendobj\n"))}async object(r,n){if(this.start(r),typeof n=="string"){await this.text(r+" 0 obj\n"+n+"\nendobj\n");return}let e=r+" 0 obj\n";for(const t of n)for(let h=0;h<t.length;){const l=Math.min(t.length,h+32768-e.length);if(e+=t.slice(h,l),h=l,e.length===32768){const f=e.charCodeAt(e.length-1),d=f>=55296&&f<=56319?e.length-1:e.length;await this.text(e.slice(0,d)),e=e.slice(d)}}await this.text(e+"\nendobj\n")}validateObject(r){if(!Number.isSafeInteger(r)||r<=0||r>=this.offsets.length||this.offsets[r]!==void 0)throw new Error("Invalid PDF object state.")}start(r){this.validateObject(r),this.offsets[r]=this.bytes}async stream(r,n,e="",t=!0,h=!1){const l=typeof n=="string"?this.encoder.encode(n):n;let f;if(t&&typeof CompressionStream=="function"&&l.length)try{f=new CompressionStream("deflate")}catch{}if(!f){this.start(r),await this.text(r+" 0 obj\n<< /Length "+l.length+" "+e+" >>\nstream\n"),await this.raw(l),await this.text("\nendstream\nendobj\n");return}const d=typeof n=="string"||h?l:new Uint8Array(l);await this.compressedStream(r,d,e,f)}async compressedStream(r,n,e,t,h){const f=new ReadableStream({start(T){h&&T.enqueue(h),T.enqueue(n),T.close()}}).pipeThrough(t).getReader(),d=this.reserve();let g=0,w=!1;try{for(this.start(r),await this.text(r+" 0 obj\n<< /Length "+d+" 0 R /Filter /FlateDecode "+e+" >>\nstream\n");;){const T=await O(f.read(),this.signal);if(T.done){w=!0;break}g+=T.value.length,await this.raw(T.value)}await this.text("\nendstream\nendobj\n"),await this.object(d,String(g))}finally{w||f.cancel(this.signal?.reason).catch(()=>{}),f.releaseLock()}}async finish(r,n){await this.flushCompact();for(let t=1;t<this.offsets.length;t++)if(this.offsets[t]===void 0)throw new Error("PDF contains unwritten objects.");if(this.bytes>9999999999)throw new C("RESOURCE_LIMIT","PDF exceeds classic cross-reference offset capacity.");if(this.compactIndices)return this.finishCompact(r,n);const e=this.bytes;await this.text("xref\n0 "+this.offsets.length+"\n0000000000 65535 f \n");for(let t=1;t<this.offsets.length;t++)await this.text(String(this.offsets[t]).padStart(10,"0")+" 00000 n \n");await this.text("trailer\n<< /Size "+this.offsets.length+" /Root "+r+" 0 R /Info "+n+" 0 R >>\nstartxref\n"+e+"\n%%EOF\n"),await this.flush()}async finishCompact(r,n){const e=this.reserve(),t=this.bytes,h=this.offsets.length*m;if(!Number.isSafeInteger(h))throw new C("RESOURCE_LIMIT","PDF cross-reference stream is too large.");this.start(e),await this.text(e+" 0 obj\n<< /Type /XRef /Size "+this.offsets.length+" /W [1 8 2] /Root "+r+" 0 R /Info "+n+" 0 R /Length "+h+" >>\nstream\n");for(const l of y(this.offsets,this.compactIndices))await this.raw(l);await this.text("\nendstream\nendobj\nstartxref\n"+t+"\n%%EOF\n"),await this.flushBytes()}}return Object.freeze({pdfNumber:o,unicodeHex:s,PdfObjects:a})})(),Ft=(()=>{class S{bytes;view;constructor(y){this.bytes=y,this.view=new DataView(y.buffer,y.byteOffset,y.byteLength)}range(y,m){if(!Number.isSafeInteger(y)||!Number.isSafeInteger(m)||y<0||m<0||y+m>this.bytes.length)throw new TypeError("Truncated or invalid TrueType table.")}u16(y){return this.range(y,2),this.view.getUint16(y)}i16(y){return this.range(y,2),this.view.getInt16(y)}u32(y){return this.range(y,4),this.view.getUint32(y)}tag(y){return this.range(y,4),String.fromCharCode(...this.bytes.subarray(y,y+4))}}function O(C){let y=0;for(let m=0;m<C.length;m+=4)y=y+((C[m]??0)*16777216+((C[m+1]??0)<<16)+((C[m+2]??0)<<8)+(C[m+3]??0))>>>0;return y}return Object.freeze({FontReader:S,checksum:O,align4:C=>Math.ceil(C/4)*4})})(),tr=(()=>{const{align4:S}=Ft,{checkAbort:O,pause:P,taskYieldDue:k}=be;function C(s,a,c){const i=m(s,a,c);for(;;){const r=i.next();if(r.done)return r.value}}async function y(s,a,c,i){O(i);const r=m(s,a,c);for(;;){const n=r.next();if(n.done)return O(i),n.value;k()&&await P(),O(i)}}function*m(s,a,c){const i=new Set([0,...a]),r=s.table("glyf"),n=[...i],e=new Map;let t=0;for(let _=0;_<n.length;_++){(++t&1023)===0&&(yield);const F=n[_];if(!Number.isInteger(F)||F<0||F>=s.glyphCount)throw new TypeError("Invalid subset glyph.");const W=s.offsets[F],U=s.offsets[F+1];if(W===U)continue;if(U-W<10)throw new TypeError("Truncated TrueType glyph header.");if(s.i16(r.offset+W)>=0)continue;let X=r.offset+W+10,V;const Y=[];e.set(F,Y);const re=r.offset+U;do{if(X+4>re)throw new TypeError("Truncated TrueType composite.");V=s.u16(X);const A=s.u16(X+2);if(A>=s.glyphCount)throw new TypeError("Invalid TrueType composite dependency.");if(Y.push(A),(++t&1023)===0&&(yield),i.has(A)||(i.add(A),n.push(A)),X+=4+(V&1?4:2)+(V&8?2:V&64?4:V&128?8:0),X>re)throw new TypeError("Truncated TrueType composite transform.")}while(V&32);if(V&256&&(X+2>re||X+2+s.u16(X)>re))throw new TypeError("Truncated composite instructions.")}const h=new Set,l=new Set;function*f(_,F){if((++t&1023)===0&&(yield),l.has(_))throw new TypeError("Cyclic TrueType composite dependency.");if(F>64)throw new TypeError("TrueType composite nesting exceeds 64 levels.");if(!h.has(_)){l.add(_);for(const W of e.get(_)??[])yield*f(W,F+1);l.delete(_),h.add(_)}}for(const _ of i)yield*f(_,0);const d=new Uint32Array(s.glyphCount+1);let g=0;for(let _=0;_<s.glyphCount;_++)d[_]=g,i.has(_)&&(g+=S(s.offsets[_+1]-s.offsets[_])),(_&1023)===1023&&(yield);d[s.glyphCount]=g;const w=new Uint8Array(g);for(const _ of i)yield*p(s.bytes.subarray(r.offset+s.offsets[_],r.offset+s.offsets[_+1]),w,d[_]),(++t&1023)===0&&(yield);const T=new Uint8Array(d.length*4),v=new DataView(T.buffer);for(let _=0;_<d.length;_++)v.setUint32(_*4,d[_]),(_&1023)===1023&&(yield);const E=new Set(["OS/2","cmap","cvt ","fpgm","gasp","glyf","head","hhea","hmtx","loca","maxp","name","post","prep"]),R=yield*x(c),I=yield*b(s,i),z=[];for(const[_,F]of[...s.tables].filter(([W])=>E.has(W)).sort(([W],[U])=>W<U?-1:1)){const W=_==="glyf"?w:_==="loca"?T:_==="cmap"?R:_==="hmtx"?I:void 0,U=W??new Uint8Array(F.length);if(W||(yield*p(s.bytes.subarray(F.offset,F.offset+F.length),U)),_==="head"){const X=new DataView(U.buffer);X.setUint32(8,0),X.setInt16(50,1)}z.push({tag:_,bytes:U})}const j=12+z.length*16+z.reduce((_,F)=>_+S(F.bytes.length),0),M=new Uint8Array(j),L=new DataView(M.buffer);L.setUint32(0,65536),L.setUint16(4,z.length);const B=2**Math.floor(Math.log2(z.length));L.setUint16(6,B*16),L.setUint16(8,Math.log2(B)),L.setUint16(10,z.length*16-B*16);let q=12+z.length*16,G=0;for(let _=0;_<z.length;_++){const F=z[_],W=12+_*16;for(let U=0;U<4;U++)M[W+U]=F.tag.charCodeAt(U);L.setUint32(W+4,yield*u(F.bytes)),L.setUint32(W+8,q),L.setUint32(W+12,F.bytes.length),yield*p(F.bytes,M,q),F.tag==="head"&&(G=q),q+=S(F.bytes.length)}return L.setUint32(G+8,2981146554-(yield*u(M))>>>0),M}function*b(s,a){let c=0;const i=s.u16(s.table("hhea").offset+34),r=s.table("hmtx"),n=new Uint8Array(i*4+(s.glyphCount-i)*2);for(const e of a){(++c&1023)===0&&(yield);const t=e<i?e*4:i*4+(e-i)*2,h=e<i?4:2;if(n.set(s.bytes.subarray(r.offset+t,r.offset+t+h),t),e>=i){const l=(i-1)*4;n.set(s.bytes.subarray(r.offset+l,r.offset+l+2),l)}}return n}function*x(s){let a=0;const c=[...s].sort(([e],[t])=>e-t),i=[];for(const[e,t]of c){(++a&1023)===0&&(yield);const h=i.at(-1);h&&e===h.last+1&&t===h.glyph+e-h.first?h.last=e:i.push({first:e,last:e,glyph:t})}const r=new Uint8Array(28+i.length*12),n=new DataView(r.buffer);n.setUint16(2,1),n.setUint16(4,3),n.setUint16(6,10),n.setUint32(8,12),n.setUint16(12,12),n.setUint32(16,r.length-12),n.setUint32(24,i.length);for(let e=0;e<i.length;e++){const t=i[e],h=28+e*12;n.setUint32(h,t.first),n.setUint32(h+4,t.last),n.setUint32(h+8,t.glyph),(e&1023)===1023&&(yield)}return r}function*p(s,a,c=0){for(let i=0;i<s.length;i+=65536)a.set(s.subarray(i,Math.min(s.length,i+65536)),c+i),yield}function*u(s){let a=0;for(let c=0;c<s.length;c+=4)a=a+((s[c]??0)*16777216+((s[c+1]??0)<<16)+((s[c+2]??0)<<8)+(s[c+3]??0))>>>0,(c&65535)===65532&&(yield);return a}return Object.freeze({subsetTrueType:C,subsetTrueTypeCooperatively:y})})(),rr=(()=>{const{NotSupportedError:S}=me,{FontReader:O}=Ft,{subsetTrueType:P,subsetTrueTypeCooperatively:k}=tr,{checkAbort:C,pause:y,taskYieldDue:m}=be;class b extends O{tables;glyphCount;units;ascent;descent;bbox;widths;offsets;canSubset;cmaps;constructor(o,s){super(o);const a=x(this);let c=s;if(!c)for(;;){const i=a.next();if(i.done){c=i.value;break}}this.tables=c.tables,this.glyphCount=c.glyphCount,this.units=c.units,this.ascent=c.ascent,this.descent=c.descent,this.bbox=c.bbox,this.widths=c.widths,this.offsets=c.offsets,this.canSubset=c.canSubset,this.cmaps=c.cmaps}static async create(o,s){C(s);const a=x(new O(o));for(;;){const c=a.next();if(c.done)return C(s),new b(o,c.value);m()&&await y(),C(s)}}table(o,s=0){const a=this.tables.get(o);if(!a||a.length<s)throw new TypeError("Missing or truncated TrueType table: "+o);return a}glyph(o){for(const s of this.cmaps){const a=s.offset,c=this.u16(a);let i=0;if(c===12){let r=0,n=this.u32(a+12)-1;for(;r<=n;){const e=r+n>>>1,t=a+16+e*12,h=this.u32(t),l=this.u32(t+4);if(o<h)n=e-1;else if(o>l)r=e+1;else{i=this.u32(t+8)+o-h;break}}}else if(o<=65535){const r=this.u16(a+6)/2;let n=0,e=r-1;for(;n<e;){const h=n+e>>>1;o>this.u16(a+14+h*2)?n=h+1:e=h}const t=this.u16(a+16+r*2+n*2);if(o>=t&&o<=this.u16(a+14+n*2)){const h=this.i16(a+16+r*4+n*2),l=a+16+r*6+n*2,f=this.u16(l);if(!f)i=o+h&65535;else{const d=l+f+(o-t)*2;if(d+2>a+s.length)throw new TypeError("cmap glyph array exceeds its table.");i=this.u16(d),i&&(i=i+h&65535)}}}if(i>=this.glyphCount)throw new TypeError("cmap references an invalid glyph.");if(i)return i}return 0}subset(o,s){return this.canSubset?P(this,o,s):this.bytes}async subsetCooperatively(o,s,a){return C(a),this.canSubset?k(this,o,s,a):this.bytes}}function*x(u){const o=new Map,s=(_,F=0)=>{const W=o.get(_);if(!W||W.length<F)throw new TypeError("Missing or truncated TrueType table: "+_);return W};if(u.u32(0)!==65536)throw new S("PDF fonts require a static TrueType .ttf with glyf outlines; collections, CFF and WOFF are unsupported.");const a=u.u16(4);if(!a||a>256)throw new TypeError("Invalid TrueType table count.");u.range(12,a*16);for(let _=0;_<a;_++){const F=12+_*16,W=u.tag(F),U=u.u32(F+8),X=u.u32(F+12);if(u.range(U,X),o.has(W))throw new TypeError("Duplicate TrueType table: "+W);o.set(W,{offset:U,length:X})}if(o.has("fvar"))throw new S("Instantiate a variable font as a static TrueType font before PDF export.");const c=s("head",54),i=s("maxp",6),r=s("hhea",36),n=s("OS/2",10);if(u.u32(c.offset+12)!==1594834165)throw new TypeError("Invalid TrueType head magic.");const e=u.u16(i.offset+4),t=u.u16(c.offset+18);if(!e||t<16||t>16384)throw new TypeError("Invalid TrueType metrics.");const h=u.u16(n.offset+8);if(h&514)throw new S("The font's embedding permissions prohibit outline embedding.");const l=!(h&256),f=1e3/t,d=u.i16(r.offset+4)*f,g=u.i16(r.offset+6)*f,w=[36,38,40,42].map(_=>u.i16(c.offset+_)*f),T=u.u16(r.offset+34);if(!T||T>e)throw new TypeError("Invalid TrueType horizontal metric count.");const v=s("hmtx",T*4+(e-T)*2),E=[];for(let _=0;_<e;_++)E.push(u.u16(v.offset+Math.min(_,T-1)*4)*f),(_&1023)===1023&&(yield);const R=u.i16(c.offset+50);if(R!==0&&R!==1)throw new TypeError("Unsupported TrueType loca index.");const I=s("loca",(e+1)*(R?4:2)),z=s("glyf"),j=[];for(let _=0;_<=e;_++)j.push(R?u.u32(I.offset+_*4):u.u16(I.offset+_*2)*2),(_&1023)===1023&&(yield);for(let _=0;_<=e;_++)if(j[_]>z.length||_&&j[_]<j[_-1])throw new TypeError("Invalid TrueType glyph offsets.");const M=s("cmap",4),L=[],B=new Set,q=u.u16(M.offset+2);if(4+q*8>M.length)throw new TypeError("Invalid TrueType cmap directory.");for(let _=0;_<q;_++){const F=M.offset+4+_*8,W=u.u16(F),U=u.u16(F+2),X=u.u32(F+4);if(W!==0&&!(W===3&&(U===1||U===10)))continue;if(X+4>M.length)throw new TypeError("Invalid cmap subtable offset.");const V=M.offset+X,Y=u.u16(V);if(Y!==4&&Y!==12||B.has(V))continue;if(Y===12&&X+16>M.length)throw new TypeError("Truncated cmap format 12.");const re=Y===12?u.u32(V+4):u.u16(V+2);if(re<16||X+re>M.length)throw new TypeError("Invalid cmap length.");if(Y===12){const A=u.u32(V+12);if(16+A*12>re)throw new TypeError("Invalid cmap groups.");let $=-1;for(let J=0;J<A;J++){const te=V+16+J*12,he=u.u32(te),se=u.u32(te+4),ne=u.u32(te+8);if(he<=$||he>se||se>1114111||ne+se-he>=e)throw new TypeError("Invalid cmap scalar/glyph group.");$=se,(J&1023)===1023&&(yield)}}else{const A=u.u16(V+6)/2;if(!Number.isInteger(A)||!A||16+A*8>re)throw new TypeError("Invalid cmap segments.");let $=-1;for(let J=0;J<A;J++){const te=u.u16(V+14+J*2),he=u.u16(V+16+A*2+J*2);if(te<=$||he>te)throw new TypeError("Invalid cmap segment ordering.");$=te,(J&1023)===1023&&(yield)}}B.add(V),L.push({offset:V,length:re})}const G=L.sort((_,F)=>u.u16(F.offset)-u.u16(_.offset));if(!L.length)throw new S("TrueType font needs a Unicode cmap format 4 or 12.");return{tables:o,glyphCount:e,units:t,ascent:d,descent:g,bbox:w,widths:E,offsets:j,canSubset:l,cmaps:G}}return Object.freeze({TrueTypeFont:b})})(),$e=(()=>{const{TrueTypeFont:S}=rr,{beginTask:O,checkAbort:P}=be,k=new WeakMap,C=Symbol.for("@evotecit/officeimo/PdfFont");function y(x){let p=k.get(x);if(!p){if(!(x instanceof m)||typeof x.toBytes!="function")throw new TypeError("Invalid PdfFont instance.");const u=new m(x.toBytes());p=k.get(u),k.set(x,p)}return p}class m{static[Symbol.hasInstance](p){return!!p&&typeof p=="object"&&p[C]===!0}brand=!0;constructor(p){if(!(p instanceof Uint8Array))throw new TypeError("PdfFont requires TrueType bytes as a Uint8Array.");if(p.length>64*1024*1024)throw new RangeError("A TrueType font must not exceed 64 MiB.");k.set(this,new S(p.slice())),this.brand,Object.defineProperty(this,C,{value:!0}),Object.freeze(this)}static async create(p,u={}){if(P(u.signal),!(p instanceof Uint8Array))throw new TypeError("PdfFont requires TrueType bytes as a Uint8Array.");const o=u.maxBytes??16*1024*1024;if(!Number.isSafeInteger(o)||o<0||o>64*1024*1024)throw new RangeError("Font preparation maxBytes must be a nonnegative safe integer at most 64 MiB.");if(p.length>o)throw new RangeError("TrueType font exceeds the preparation byte limit.");O();const s=await S.create(new Uint8Array(p),u.signal);P(u.signal);const a=Object.create(m.prototype);return k.set(a,s),Object.defineProperty(a,"brand",{value:!0}),Object.defineProperty(a,C,{value:!0}),Object.freeze(a),a}toBytes(){return y(this).bytes.slice()}}return Object.freeze({fontProgram:y,PdfFont:m})})(),nr=Object.freeze({helveticaWidths:new Map([[32,[278,278]],[33,[278,333]],[34,[355,474]],[35,[556,556]],[36,[556,556]],[37,[889,889]],[38,[667,722]],[39,[191,238]],[40,[333,333]],[41,[333,333]],[42,[389,389]],[43,[584,584]],[44,[278,278]],[45,[333,333]],[46,[278,278]],[47,[278,278]],[48,[556,556]],[49,[556,556]],[50,[556,556]],[51,[556,556]],[52,[556,556]],[53,[556,556]],[54,[556,556]],[55,[556,556]],[56,[556,556]],[57,[556,556]],[58,[278,333]],[59,[278,333]],[60,[584,584]],[61,[584,584]],[62,[584,584]],[63,[556,611]],[64,[1015,975]],[65,[667,722]],[66,[667,722]],[67,[722,722]],[68,[722,722]],[69,[667,667]],[70,[611,611]],[71,[778,778]],[72,[722,722]],[73,[278,278]],[74,[500,556]],[75,[667,722]],[76,[556,611]],[77,[833,833]],[78,[722,722]],[79,[778,778]],[80,[667,667]],[81,[778,778]],[82,[722,722]],[83,[667,667]],[84,[611,611]],[85,[722,722]],[86,[667,667]],[87,[944,944]],[88,[667,667]],[89,[667,667]],[90,[611,611]],[91,[278,333]],[92,[278,278]],[93,[278,333]],[94,[469,584]],[95,[556,556]],[96,[333,333]],[97,[556,556]],[98,[556,611]],[99,[500,556]],[100,[556,611]],[101,[556,556]],[102,[278,333]],[103,[556,611]],[104,[556,611]],[105,[222,278]],[106,[222,278]],[107,[500,556]],[108,[222,278]],[109,[833,889]],[110,[556,611]],[111,[556,611]],[112,[556,611]],[113,[556,611]],[114,[333,389]],[115,[500,556]],[116,[278,333]],[117,[556,611]],[118,[500,556]],[119,[722,778]],[120,[500,556]],[121,[500,556]],[122,[500,500]],[123,[334,389]],[124,[260,280]],[125,[334,389]],[126,[584,584]],[161,[333,333]],[162,[556,556]],[163,[556,556]],[164,[556,556]],[165,[556,556]],[166,[260,280]],[167,[556,556]],[168,[333,333]],[169,[737,737]],[170,[370,370]],[171,[556,556]],[172,[584,584]],[174,[737,737]],[175,[333,333]],[176,[400,400]],[177,[584,584]],[178,[333,333]],[179,[333,333]],[180,[333,333]],[181,[556,611]],[182,[537,556]],[183,[278,278]],[184,[333,333]],[185,[333,333]],[186,[365,365]],[187,[556,556]],[188,[834,834]],[189,[834,834]],[190,[834,834]],[191,[611,611]],[192,[667,722]],[193,[667,722]],[194,[667,722]],[195,[667,722]],[196,[667,722]],[197,[667,722]],[198,[1e3,1e3]],[199,[722,722]],[200,[667,667]],[201,[667,667]],[202,[667,667]],[203,[667,667]],[204,[278,278]],[205,[278,278]],[206,[278,278]],[207,[278,278]],[208,[722,722]],[209,[722,722]],[210,[778,778]],[211,[778,778]],[212,[778,778]],[213,[778,778]],[214,[778,778]],[215,[584,584]],[216,[778,778]],[217,[722,722]],[218,[722,722]],[219,[722,722]],[220,[722,722]],[221,[667,667]],[222,[667,667]],[223,[611,611]],[224,[556,556]],[225,[556,556]],[226,[556,556]],[227,[556,556]],[228,[556,556]],[229,[556,556]],[230,[889,889]],[231,[500,556]],[232,[556,556]],[233,[556,556]],[234,[556,556]],[235,[556,556]],[236,[278,278]],[237,[278,278]],[238,[278,278]],[239,[278,278]],[240,[556,611]],[241,[556,611]],[242,[556,611]],[243,[556,611]],[244,[556,611]],[245,[556,611]],[246,[556,611]],[247,[584,584]],[248,[611,611]],[249,[556,611]],[250,[556,611]],[251,[556,611]],[252,[556,611]],[253,[500,556]],[254,[556,611]],[255,[500,556]],[256,[667,722]],[257,[556,556]],[258,[667,722]],[259,[556,556]],[260,[667,722]],[261,[556,556]],[262,[722,722]],[263,[500,556]],[268,[722,722]],[269,[500,556]],[270,[722,722]],[271,[643,743]],[272,[722,722]],[273,[556,611]],[274,[667,667]],[275,[556,556]],[278,[667,667]],[279,[556,556]],[280,[667,667]],[281,[556,556]],[282,[667,667]],[283,[556,556]],[286,[778,778]],[287,[556,611]],[290,[778,778]],[291,[556,611]],[298,[278,278]],[299,[278,278]],[302,[278,278]],[303,[222,278]],[304,[278,278]],[305,[278,278]],[310,[667,722]],[311,[500,556]],[313,[556,611]],[314,[222,278]],[315,[556,611]],[316,[222,278]],[317,[556,611]],[318,[299,400]],[321,[556,611]],[322,[222,278]],[323,[722,722]],[324,[556,611]],[325,[722,722]],[326,[556,611]],[327,[722,722]],[328,[556,611]],[332,[778,778]],[333,[556,611]],[336,[778,778]],[337,[556,611]],[338,[1e3,1e3]],[339,[944,944]],[340,[722,722]],[341,[333,389]],[342,[722,722]],[343,[333,389]],[344,[722,722]],[345,[333,389]],[346,[667,667]],[347,[500,556]],[350,[667,667]],[351,[500,556]],[352,[667,667]],[353,[500,556]],[354,[611,611]],[355,[278,333]],[356,[611,611]],[357,[317,389]],[362,[722,722]],[363,[556,611]],[366,[722,722]],[367,[556,611]],[368,[722,722]],[369,[556,611]],[370,[722,722]],[371,[556,611]],[376,[667,667]],[377,[611,611]],[378,[500,500]],[379,[611,611]],[380,[500,500]],[381,[611,611]],[382,[500,500]],[402,[556,556]],[536,[667,667]],[537,[500,556]],[710,[333,333]],[711,[333,333]],[728,[333,333]],[729,[333,333]],[730,[333,333]],[731,[333,333]],[732,[333,333]],[733,[333,333]],[8211,[556,556]],[8212,[1e3,1e3]],[8216,[222,278]],[8217,[222,278]],[8218,[222,278]],[8220,[333,500]],[8221,[333,500]],[8222,[333,500]],[8224,[556,556]],[8225,[556,556]],[8226,[350,350]],[8230,[1e3,1e3]],[8240,[1e3,1e3]],[8249,[333,333]],[8250,[333,333]],[8260,[167,167]],[8364,[556,556]],[8482,[1e3,1e3]],[8706,[476,494]],[8710,[612,612]],[8721,[600,600]],[8722,[584,584]],[8730,[453,549]],[8800,[549,549]],[8804,[549,549]],[8805,[549,549]],[9674,[471,494]],[64257,[500,611]],[64258,[500,611]]])}),Dt=(()=>{const{OfficeIMOError:S}=me,{PdfFont:O,fontProgram:P}=$e,{helveticaWidths:k}=nr,C=new Map([8364,0,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,0,381,0,0,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,0,382,376].map((u,o)=>[u,o+128]));function y(u){return u>=32&&u<=126||u>=160&&u<=255?u:u?C.get(u):void 0}function m(u,o,s){if(u>=55296&&u<=57343)return{supported:!1,code:"unpaired-surrogate",message:"PDF text contains an unpaired UTF-16 surrogate."};if(u<32||u>=127&&u<160)return{supported:!1,code:"unsupported-control",message:"PDF text contains an unsupported control character."};const a=String.fromCodePoint(u);if(/[\p{Mark}\p{Format}]/u.test(a)||!/[\p{Script=Latin}\p{Script=Greek}\p{Script=Cyrillic}\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Common}]/u.test(a)||u>=4352&&u<=4607||u>=127995&&u<=127999)return{supported:!1,code:"unsupported-layout",message:"This PDF table writer supports Unicode scalar layout; complex shaping, combining sequences and bidirectional text require a shaping-capable writer."};if(!o){if(y(u)===void 0)return{supported:!1,code:"embedded-font-required",message:"Text U+"+u.toString(16).toUpperCase()+" needs an embedded Unicode TrueType font; supply fonts.regular."};const i=k.get(u===160?32:u===173?45:u);return i?{supported:!0,width:i[s?1:0]}:{supported:!1,code:"missing-glyph",message:"Standard font has no metric for this character."}}let c=o.glyph(u);if(!c&&u===8239){const i=o.glyph(8201);i&&o.offsets[i]===o.offsets[i+1]&&(c=i)}return c?{supported:!0,glyph:c,width:o.widths[c]}:{supported:!1,code:"missing-glyph",message:"The supplied font has no glyph for U+"+u.toString(16).toUpperCase()+"."}}function b(u,o){if(!u)return;if(!(u.regular instanceof O))throw new TypeError("fonts.regular must be a PdfFont.");const s=new Set;for(const[a,c]of Object.entries(u)){if(!["regular","bold","italic","boldItalic"].includes(a)||!(c instanceof O))throw new TypeError("Invalid PDF font family.");s.add(c)}if(o!==void 0&&[...s].reduce((a,c)=>a+P(c).bytes.length,0)>o)throw new S("RESOURCE_LIMIT","maxFontBytes exceeded.")}function x(u,o,s){const a=u&&(o&&s?u.boldItalic:o?u.bold:s?u.italic:u.regular),c=a??u?.regular;return{font:c,syntheticBold:!!c&&o&&!a,syntheticItalic:!!c&&s&&!a}}return Object.freeze({standardCode:y,resolveScalar:m,validateFonts:b,selectFont:x})})(),sr=(()=>{const{NotSupportedError:S,OfficeIMOError:O}=me,{fontProgram:P}=$e,{resolveScalar:k,selectFont:C,standardCode:y,validateFonts:m}=Dt,{pdfNumber:b,unicodeHex:x}=Be,{checkAbort:p,pause:u,taskYieldDue:o}=be,s=Object.freeze(Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0")));function a(n){return s[n>>>8]+s[n&255]}class c{index;bold;italic;font;shared;signal;name;object;program;syntheticBold;syntheticItalic;mappings=new Map;standardWidths=new Map;constructor(e,t,h,l,f,d,g,w,T){this.index=e,this.bold=t,this.italic=h,this.font=l,this.shared=w,this.signal=T,this.name=w?.name??"F"+e,this.object=w?.object??f.reserve(),this.program=l?P(l):void 0,this.syntheticBold=d,this.syntheticItalic=g}width(e){if(this.shared)return this.shared.width(e);if(this.program){const f=this.mappings.get(e);if(f)return f.width}else{const f=this.standardWidths.get(e);if(f!==void 0)return f}const t=k(e,this.program,this.bold);if(!t.supported)throw t.code==="unpaired-surrogate"?new TypeError(t.message):new S(t.message);if(!this.program)return this.standardWidths.set(e,t.width),t.width;if(this.mappings.size>=65535)throw new O("RESOURCE_LIMIT","A PDF font supports at most 65,535 distinct Unicode scalars.");const h=this.mappings.size+1,l={cid:h,hex:a(h),glyph:t.glyph,width:t.width,text:String.fromCodePoint(e)};return this.mappings.set(e,l),l.width}lineHeight(e){return Math.max(1.3,this.program?(this.program.ascent-this.program.descent)/1e3+.1:1.3)*e}encode(e){if(this.shared)return this.shared.encode(e);let t="";for(const h of e){const l=h.codePointAt(0);if(this.program){let f=this.mappings.get(l);f||(this.width(l),f=this.mappings.get(l)),t+=f.hex}else this.standardWidths.has(l)||this.width(l),t+=s[y(l)]}return"<"+t+">"}encodeGlyph(e,t){if(this.shared)return this.shared.encodeGlyph(e,t);if(!this.program||!Number.isSafeInteger(e)||e<=0||e>=this.program.glyphCount)throw new TypeError("Invalid shaped TrueType glyph.");const h=e+":"+t;let l=this.mappings.get(h);if(!l){if(this.mappings.size>=65535)throw new O("RESOURCE_LIMIT","A PDF font supports at most 65,535 distinct CID mappings.");const f=this.mappings.size+1;l={cid:f,hex:a(f),glyph:e,width:this.program.widths[e],text:t},this.mappings.set(h,l)}return"<"+l.hex+">"}async write(e,t){if(p(this.signal),!this.program){const B="Helvetica"+(this.bold&&this.italic?"-BoldOblique":this.bold?"-Bold":this.italic?"-Oblique":"");await e.object(this.object,"<< /Type /Font /Subtype /Type1 /BaseFont /"+B+" /Encoding /WinAnsiEncoding >>");return}const h=this.program,l=[...this.mappings],f=new Set(l.map(([,B])=>B.glyph)),d=(h.canSubset?"OIMOAA+":"")+"OfficeIMOFont"+this.index,g=e.reserve(),w=e.reserve(),T=e.reserve(),v=e.reserve(),E=e.reserve(),R=new Map;for(const[B,q]of l)if(typeof B=="number")R.set(B,q.glyph);else for(const G of q.text){const _=G.codePointAt(0),F=h.glyph(_);F&&(R.set(_,F),f.add(F))}const I=await h.subsetCooperatively(f,R,this.signal);await e.stream(g,I,"/Length1 "+I.length,t,!0),await e.object(w,"<< /Type /FontDescriptor /FontName /"+d+" /Flags 32 /FontBBox ["+h.bbox.map(b).join(" ")+"] /ItalicAngle 0 /Ascent "+b(h.ascent)+" /Descent "+b(h.descent)+" /CapHeight "+b(h.ascent)+" /StemV 80 /FontFile2 "+g+" 0 R >>");const z=new Uint8Array((l.length+1)*2),j=new DataView(z.buffer);for(let B=0;B<l.length;B++){const q=l[B][1];j.setUint16(q.cid*2,q.glyph),(B&1023)===1023&&(o()&&await u(),p(this.signal))}await e.stream(v,z,"",t,!0),await e.object(T,"<< /Type /Font /Subtype /CIDFontType2 /BaseFont /"+d+" /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /FontDescriptor "+w+" 0 R /CIDToGIDMap "+v+" 0 R"+(l.length?" /W [1 ["+l.map(([,B])=>b(B.width)).join(" ")+"]]":"")+" >>");let M="/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n/CMapName /OfficeIMOUnicode def\n/CMapType 2 def\n1 begincodespacerange\n<0000> <FFFF>\nendcodespacerange\n";const L=l.filter(([,B])=>B.text.length);for(let B=0;B<L.length;B+=100){const q=L.slice(B,B+100);M+=q.length+" beginbfchar\n";for(const[,G]of q)M+="<"+G.hex+"> <"+x(G.text)+">\n";M+="endbfchar\n",o()&&await u(),p(this.signal)}M+="endcmap\nCMapName currentdict /CMap defineresource pop\nend\nend\n",await e.stream(E,M,"",t),await e.object(this.object,"<< /Type /Font /Subtype /Type0 /BaseFont /"+d+" /Encoding /Identity-H /DescendantFonts ["+T+" 0 R] /ToUnicode "+E+" 0 R >>")}}class i{objects;fonts;maxBytes;signal;resources=[];selections=new Map;programs=new Map;explicitSelections=new Map;registered=new Set;fontBytes=0;constructor(e,t,h=16*1024*1024,l){this.objects=e,this.fonts=t,this.maxBytes=h,this.signal=l,m(t,h);for(const f of Object.values(t??{}))this.registerFont(f)}registerFont(e){if(this.registered.has(e))return;const t=P(e).bytes.length;if(this.fontBytes+t>this.maxBytes)throw new O("RESOURCE_LIMIT","maxFontBytes exceeded.");this.fontBytes+=t,this.registered.add(e)}select(e=!1,t=!1,h){h&&this.registerFont(h);let l=this.selections;if(h){const R=this.explicitSelections.get(h);l=R??new Map,R||this.explicitSelections.set(h,l)}const f=(e?2:0)|(t?1:0),d=l.get(f);if(d)return d;const{font:g,syntheticBold:w,syntheticItalic:T}=h?{font:h,syntheticBold:e,syntheticItalic:t}:C(this.fonts,e,t),v=g?this.programs.get(g):void 0,E=new c(this.resources.length+1,e,t,g,this.objects,w,T,v,this.signal);return v||(this.resources.push(E),g&&this.programs.set(g,E)),l.set(f,E),E}dictionary(){return"<< "+this.resources.map(e=>"/"+e.name+" "+e.object+" 0 R").join(" ")+" >>"}}return Object.freeze({PdfFontResource:c,PdfFontResources:i})})(),Qe=(()=>{const{OfficeIMOError:S}=me,{ExportCell:O,assertExportValue:P}=ve,{checkAbort:k,pause:C,taskYieldDue:y}=be,{isDate:m}=Me,{defaultBooleanText:b}=dt;function x(i,r){return r.limits.maxTextCharacters===void 0?i:i.replace(/[\t\r\n]/g,n=>n===" "?" ":"")}function p(i,r){if(typeof i=="string")return i;throw i&&typeof i.then=="function"&&Promise.resolve(i).catch(()=>{}),new TypeError(r+" must return a synchronous string.")}function u(i,r,n){if(P(i),i instanceof O&&i.text!==void 0)return i.text;const e=i instanceof O?i.value:i;return r.formatValue?p(r.formatValue(e,n),"formatValue"):e==null?"":m(e)?Number.isFinite(e.getTime())?e.toISOString():"":typeof e=="number"&&!Number.isFinite(e)?"":typeof e=="boolean"?(r.booleanText??b)[e?"true":"false"]:String(e)}function o(i,r,n,e,t,h,l=!0){const f=a(i,r,n,e,t,h,l);for(;;){const d=f.next();if(d.done)return d.value}}async function s(i,r,n,e,t,h,l=!0,f){k(f);const d=a(i,r,n,e,t,h,l);for(;;){const g=d.next();if(g.done)return g.value;y()&&await C(),k(f)}}function*a(i,r,n,e,t,h,l){if(i.length>t)throw new S("RESOURCE_LIMIT","maxCellCharacters exceeded.");const f=[];let d=0;function g(w,T){if(f.length>=h)throw new S("RESOURCE_LIMIT","maxRowLines exceeded.");f.push({text:w.join(""),width:T})}for(const w of i.replace(/\r\n?/g,"\n").replace(/\t/g," ").split("\n")){let T=[],v=[],E=0,R=-1;for(const I of w){(++d&4095)===0&&(yield);const z=r.width(I.codePointAt(0))*n/1e3;if(z>e+.001)throw new RangeError("PDF column is too narrow for a glyph. Increase page/column width or reduce padding/font size.");if(E+z>e+.001){if(!l)throw new RangeError("Unwrapped PDF cell exceeds its column width.");const j=R>=0?R+1:T.length,M=v.slice(0,j).reduce((L,B)=>L+B,0);g(T.slice(0,j),M),T=T.slice(j),v=v.slice(j),E=v.reduce((L,B)=>L+B,0),R=-1;for(let L=0;L<T.length;L++)T[L]===" "&&(R=L);E+z>e+.001&&(g(T,E),T=[],v=[],E=0,R=-1)}T.push(I),v.push(z),E+=z,I===" "&&(R=T.length-1)}g(T,E),(++d&4095)===0&&(yield)}return f}return Object.freeze({pdfBudgetText:x,synchronousText:p,displayText:u,wrapText:o,wrapTextCooperatively:s})})(),ir=(()=>{const{NotSupportedError:S,OfficeIMOError:O}=me,{checkAbort:P,pause:k,taskYieldDue:C,withAbort:y}=be,m=(o,s)=>s===0||s===o.length||!(o.charCodeAt(s)>=56320&&o.charCodeAt(s)<=57343&&o.charCodeAt(s-1)>=55296&&o.charCodeAt(s-1)<=56319);function b(o,s){const a=[{text:"",owners:[]}];let c=0,i=o.runs[0]?.text.length??0;for(let r=0;r<o.text.length;){for(;r>=i&&c<o.runs.length-1;)i+=o.runs[++c].text.length;const n=o.text.codePointAt(r),e=String.fromCodePoint(n);if(r+=e.length,n>=55296&&n<=57343)throw new TypeError("PDF text contains an unpaired UTF-16 surrogate.");if(r>i&&c<o.runs.length-1)throw new S("A shaped presentation boundary cannot split a UTF-16 scalar.");if(e==="\n"||e==="\r"){if(e==="\r"&&o.text[r]==="\n"&&r++,a.length>=s)throw new O("RESOURCE_LIMIT","maxRowLines exceeded.");a.push({text:"",owners:[]});continue}if(n<32&&n!==9||n>=127&&n<160)throw new S("PDF text contains an unsupported control character.");const t=e===" "?" ":e,h=a.at(-1);if(h.text.length+t.length>4096)throw new O("RESOURCE_LIMIT","Shaped PDF text supports at most 4,096 UTF-16 units per physical paragraph.");h.text+=t;for(let l=0;l<t.length;l++)h.owners.push(c)}return a}function x(o,s,a,c,i,r){if(!Array.isArray(o)||o.length>32768)throw new TypeError("Invalid shaped run array.");let n=0,e=0;const t=new Uint8Array(c-a),h=new Map,l=new Map,f=[];for(const w of o){if(!w||!Array.isArray(w.glyphs)||!i.some(v=>v.font===w.font))throw new TypeError("Shaping must use an exact registered PdfFont identity.");if(n+=w.glyphs.length,n>32768)throw new O("RESOURCE_LIMIT","Shaped PDF text exceeded 32,768 glyphs.");const T=[];for(const v of w.glyphs){const{id:E,clusterStart:R,clusterEnd:I,xAdvance:z,yAdvance:j,xOffset:M,yOffset:L}=v??{},B=i[s.owners[R]??-1];if(!B||B.font!==w.font||!B.program||!Number.isSafeInteger(E)||E<=0||E>=B.program.glyphCount)throw new TypeError("Shaping returned an invalid glyph or font identity.");if(!Number.isSafeInteger(R)||!Number.isSafeInteger(I)||R<a||I<=R||I>c||!m(s.text,R)||!m(s.text,I))throw new TypeError("Shaping returned an invalid UTF-16 cluster range.");if(![z,j,M,L].every(_=>Number.isFinite(_)&&Math.abs(_)<=1e5)||z<0||j!==0)throw new TypeError("Shaping requires finite bounded horizontal glyph metrics.");const q=r.runs[s.owners[R]];for(let _=R;_<I;_++){const F=r.runs[s.owners[_]];if(i[s.owners[_]].font!==w.font||q.style.bold!==F.style.bold||q.style.italic!==F.style.italic||q.style.color!==F.style.color||q.link!==F.link)throw new S("A PDF presentation, font or link boundary cannot split an indivisible shaped cluster.");t[_-a]=1}const G=h.get(R);if(G!==void 0&&G!==I)throw new TypeError("Inconsistent shaped cluster ranges.");h.set(R,I),l.set(R,(l.get(R)??0)+z),e+=z,T.push(Object.freeze({id:E,clusterStart:R,clusterEnd:I,xAdvance:z,yAdvance:j,xOffset:M,yOffset:L}))}f.push(Object.freeze({font:w.font,glyphs:Object.freeze(T)}))}if(t.some(w=>!w))throw new TypeError("Shaping omitted logical source text.");const d=[...h].sort((w,T)=>w[0]-T[0]);let g=a;for(const[w,T]of d){if(w!==g)throw new TypeError("Shaped clusters overlap or leave a logical gap.");g=T}return{runs:f,boundaries:d.map(([,w])=>w),advances:l,width:e}}async function p(o,s,a,c,i,r){const n=o.runs.map(d=>s.select(d.style.bold,d.style.italic,d.font)),e=s.select();if(n.some((d,g)=>!d.font&&o.runs[g].text.length))throw new S("Shaped PDF text requires explicit embedded TrueType fonts.");const t=[],h=i.options.textShaper,l=i.options.signal,f=(d,g,w,T)=>{if(t.length>=i.limits.maxRowLines)throw new O("RESOURCE_LIMIT","maxRowLines exceeded.");const v=[];let E=e.lineHeight(a),R=(e.program?.ascent??800)*a/1e3;const I=new Set;let z=-1,j,M=[],L=0;const B=()=>{if(z<0||!j)return;const G=o.runs[z],F=M.filter(W=>W.logicalText).sort((W,U)=>W.clusterStart-U.clusterStart).map(W=>W.logicalText).join("");v.push({text:F,actualText:F,logicalStart:Math.min(...M.map(W=>W.clusterStart)),width:L*a/1e3,font:j,glyphs:M,...G.style.color===void 0?{}:{color:G.style.color},...G.link?{link:G.link}:{}}),M=[],L=0};for(const G of T?.runs??[])for(const _ of G.glyphs){const F=d.owners[_.clusterStart],W=n[F];(z!==F||j!==W)&&(B(),z=F,j=W);const U=I.has(_.clusterStart)?"":d.text.slice(_.clusterStart,_.clusterEnd);I.add(_.clusterStart),M.push({..._,logicalText:U}),L+=_.xAdvance,E=Math.max(E,W.lineHeight(a)),R=Math.max(R,W.program.ascent*a/1e3)}B();const q=d.text.slice(g,w);t.push({text:q,actualText:q,segments:v,width:(T?.width??0)*a/1e3,lineHeight:E,ascent:R})};for(const d of b(o,i.limits.maxRowLines)){if(P(l),!d.text){f(d,0,0);continue}const g=[];for(let I=0;I<d.text.length;){const z=d.owners[I];let j=I+1;for(;j<d.text.length&&d.owners[j]===z;)j++;g.push(Object.freeze({start:I,end:j,font:n[z].font})),I=j}Object.freeze(g);let w=0;const T=async(I,z)=>{if(++w>16385)throw new O("RESOURCE_LIMIT","Shaped line fitting exceeded its bounded work limit.");C()&&await k(),P(l);const j=await y(Promise.resolve(h.shapeLine(Object.freeze({text:d.text,start:I,end:z,runs:g,direction:i.options.textDirection??"auto",...l?{signal:l}:{}}))),l);return P(l),x(j,d,I,z,n,o)},v=await T(0,d.text.length),E=v.boundaries;if(!r){if(v.width*a/1e3>c+.001)throw new RangeError("Unwrapped PDF cell exceeds its column width.");f(d,0,d.text.length,v);continue}let R=0;for(;R<E.length;){const I=R?E[R-1]:0;let z=R,j=0,M=-1;for(;z<E.length;){const B=z?E[z-1]:0,q=v.advances.get(B)*a/1e3;if(j+q>c+.001&&z>R||(j+=q,d.text[E[z]-1]===" "&&(M=z+1),z++,j>c+.001))break}z<E.length&&M>R&&(z=M);let L=I===0&&z===E.length?v:await T(I,E[z-1]);if(L.width*a/1e3>c+.001){let B=R+1,q=z-1,G,_=0;for(;B<=q;){const F=Math.floor((B+q)/2),W=await T(I,E[F-1]);W.width*a/1e3<=c+.001?(G=W,_=F,B=F+1):q=F-1}if(!G)throw new RangeError("PDF column is too narrow for an indivisible shaped cluster.");L=G,z=_}f(d,I,E[z-1],L),R=z}}return t}return Object.freeze({wrapShapedPdfText:p})})(),lt=(()=>{const{NotSupportedError:S,OfficeIMOError:O}=me,{copyExportLink:P}=et,{checkAbort:k,pause:C,taskYieldDue:y}=be,{presentation:m,color:b}=Fe,{wrapShapedPdfText:x}=ir,{PdfFont:p}=$e,{pdfBudgetText:u}=Qe;function o(c,i,r,n,e=!0,t=!0){if(typeof c=="string"){if(c.length>r.limits.maxCellCharacters)throw new O("RESOURCE_LIMIT","maxCellCharacters exceeded.");return t&&(c.length||e)&&r.budget.reserve(1,u(c,r.budget).length),Object.freeze({text:c,runs:Object.freeze([Object.freeze({text:c,style:i})])})}const h=c;if(!Array.isArray(h))throw h&&typeof h.then=="function"&&Promise.resolve(h).catch(()=>{}),new TypeError("PDF text must be a string or a synchronous array of text runs.");if(h.length>r.limits.maxTextRuns)throw new O("RESOURCE_LIMIT","maxTextRuns exceeded.");let l=0,f=0;const d=[];for(const g of h){if(!g||typeof g!="object"||Object.keys(g).some(j=>!["text","bold","italic","color","link","font"].includes(j)))throw new TypeError("PDF text runs support text, bold, italic, color, link and font.");const{text:w,bold:T,italic:v,color:E,link:R,font:I}=g;if(typeof w!="string")throw new TypeError("PDF run text must be a string.");if(I!==void 0){if(!(I instanceof p))throw new TypeError("A PDF run font must be a PdfFont.");n.registerFont(I)}if(l+=w.length,l>r.limits.maxCellCharacters)throw new O("RESOURCE_LIMIT","maxCellCharacters exceeded.");t&&(f+=u(w,r.budget).length);const z=m({...i,...T===void 0?{}:{bold:T},...v===void 0?{}:{italic:v},...E===void 0?{}:{color:E}});if(r.options.tagged&&R!==void 0&&w.length&&!w.trim())throw new TypeError("Tagged PDF inline links require nonempty displayed text.");d.push(Object.freeze({text:w,style:z,...I===void 0?{}:{font:I},...R===void 0?{}:{link:P(R)}}))}return t&&(l||e)&&r.budget.reserve(1,f),Object.freeze({text:d.map(g=>g.text).join(""),runs:Object.freeze(d)})}async function s(c,i,r,n,e,t=!0){if(e.options.textShaper)return x(c,i,r,n,e,t);const{signal:h}=e.options,{text:l,runs:f}=c;k(h);const d=f.length===1?f[0]:void 0,g=d&&i.select(d.style.bold,d.style.italic,d.font),w=g?void 0:f.map(F=>i.select(F.style.bold,F.style.italic,F.font)),T=i.select();if(d&&l.length>0&&l.length<4096){const F=d,W=g;let U=0,X=!0;for(let V=0;V<l.length;){const Y=l.codePointAt(V);if(Y===9||Y===10||Y===13){X=!1;break}const re=W.width(Y)*r/1e3;if(re>n+.001||U+re>n+.001){X=!1;break}U+=re,V+=Y>65535?2:1}if(X){if(e.limits.maxRowLines<1)throw new O("RESOURCE_LIMIT","maxRowLines exceeded.");return[{text:l,width:U,segments:[{text:l,width:U,font:W,...F.style.color===void 0?{}:{color:F.style.color},...F.link?{link:F.link}:{}}],lineHeight:W.lineHeight(r),ascent:Math.max(0,(W.program?.ascent??800)*r/1e3)}]}}const v=w??[g],E=[];let R=[],I=[],z=[],j=0,M=-1,L=0,B=f[0]?.text.length??0,q=0;const G=F=>{if(E.length>=e.limits.maxRowLines)throw new O("RESOURCE_LIMIT","maxRowLines exceeded.");const W=[];let U=0,X=0,V=0;for(let Y=0;Y<F;){const re=z[Y],A=f[re],$=v[re];let J=Y+1;for(;J<F&&z[J]===re;)J++;const te=I.slice(Y,J).reduce((he,se)=>he+se,0);W.push({text:R.slice(Y,J).join(""),width:te,font:$,...A.style.color===void 0?{}:{color:A.style.color},...A.link?{link:A.link}:{}}),U+=te,X=Math.max(X,$.lineHeight(r)),V=Math.max(V,($.program?.ascent??800)*r/1e3),Y=J}if(!W.length){const Y=v[0]??T;W.push({text:"",width:0,font:Y,...f[0]?.style.color===void 0?{}:{color:f[0].style.color}}),X=Y.lineHeight(r),V=(Y.program?.ascent??800)*r/1e3}E.push({text:R.slice(0,F).join(""),width:U,segments:W,lineHeight:X,ascent:V}),R=R.slice(F),I=I.slice(F),z=z.slice(F),j=I.reduce((Y,re)=>Y+re,0),M=-1;for(let Y=0;Y<R.length;Y++)R[Y]===" "&&(M=Y)},_=(F,W)=>{const U=v[W].width(F.codePointAt(0))*r/1e3;if(U>n+.001)throw new RangeError("PDF column is too narrow for a glyph. Increase page/column width or reduce padding/font size.");if(j+U>n+.001){if(!t)throw new RangeError("Unwrapped PDF cell exceeds its column width.");G(M>=0?M+1:R.length),j+U>n+.001&&G(R.length)}R.push(F),I.push(U),z.push(W),j+=U,F===" "&&(M=R.length-1)};for(let F=0;F<l.length;){for(;F>=B&&L<f.length-1;)B+=f[++L].text.length;const W=L,U=l.codePointAt(F),X=String.fromCodePoint(U);if(F+X.length>B&&L<f.length-1){let V=L+1;for(;!f[V].text.length;)V++;const Y=f[W],re=f[V],A=v[W],$=v[V];if(!(A.font===$.font&&(A.font?A.syntheticBold===$.syntheticBold&&A.syntheticItalic===$.syntheticItalic:A.bold===$.bold&&A.italic===$.italic))||b(Y.style.color??"111827")!==b(re.style.color??"111827")||Y.link?.target!==re.link?.target||Y.link?.tooltip!==re.link?.tooltip)throw new S("A PDF presentation boundary cannot split a UTF-16 scalar.")}if(F+=X.length,X==="\r"||X==="\n")X==="\r"&&l[F]==="\n"&&F++,G(R.length);else if(X===" ")for(let V=0;V<4;V++)_(" ",W);else _(X,W);(++q&4095)===0&&(y()&&await C(),k(h))}return G(R.length),E}return Object.freeze({capturePdfText:o,wrapPdfText:s})})(),or=(()=>{const{OfficeIMOError:S}=me,{wrapPdfText:O}=lt;function P(m,b){if(typeof b.options.wideTable!="object")return;const p=b.page.width-b.margins.left-b.margins.right,u=b.repeatedColumns,o=new Set(u),s=m.map((n,e)=>e).filter(n=>!o.has(n)),a=u.reduce((n,e)=>n+m[e],0);if(a>p+.001)throw new RangeError("Repeated PDF columns exceed the printable width.");const c=[];let i=[...u],r=a;for(const n of s){const e=m[n];if(a+e>p+.001)throw new RangeError("A PDF column and its repeated identifiers cannot fit a band.");r+e>p+.001&&(c.push(i),i=[...u],r=a),i.push(n),r+=e}if(i.length&&c.push(i),c.length>b.limits.maxTableBands)throw new S("RESOURCE_LIMIT","maxTableBands exceeded.");if(b.limits.maxTableWindowRows<1)throw new S("RESOURCE_LIMIT","maxTableWindowRows must allow at least one row fragment.");return Object.freeze(c.map(n=>{let e=b.margins.left;const t=n.map(h=>{const l=e;return e+=m[h],l});return Object.freeze({columns:Object.freeze(n),lefts:Object.freeze(t)})}))}async function k(m,b,x,p,u){const o=[];for(const s of m){const a=[];for(const c of s.cells){if(c.span===1){const i=b.columns.indexOf(c.first);i>=0&&a.push({...c,source:c.source??c,first:i});continue}for(let i=0;i<b.columns.length;){const r=b.columns[i];if(r<c.first||r>=c.first+c.span){i++;continue}let n=i+1;for(;n<b.columns.length&&b.columns[n]===b.columns[n-1]+1&&b.columns[n]<c.first+c.span;)n++;const e=b.columns.slice(i,n).reduce((h,l)=>h+x[l],0),t=await O(c.captured,u,p.fontSize,e-p.padding*2,p,c.style.wrapText!==!1);a.push({...c,source:c.source??c,first:i,span:n-i,width:e,lines:t,lineHeight:t.reduce((h,l)=>Math.max(h,l.lineHeight),c.font.lineHeight(p.fontSize))}),i=n}}a.sort((c,i)=>c.first-i.first),o.push({...s,source:s.source??s,cells:a})}return o}function C(m,b){if(!m.length||!m[0].length)return m;const x=m[0].length,p=Array.from({length:x},(u,o)=>Math.max(...m.map(s=>Math.max(b.padding*2+s[o].lineHeight,...s[o].cells.filter(a=>(a.rowSpan??1)===1).map(a=>a.lines.length*a.lineHeight+b.padding*2)))));for(const u of m)for(const[o,s]of u.entries())for(const a of s.cells){const c=a.rowSpan??1,i=p.slice(o,o+c).reduce((n,e)=>n+e,0),r=a.lines.length*a.lineHeight+b.padding*2;if(r>i)for(let n=o;n<o+c;n++)p[n]+=(r-i)/c}return m.map(u=>u.map((o,s)=>({...o,structured:!0,height:p[s],cells:o.cells.map(a=>({...a,height:p.slice(s,s+(a.rowSpan??1)).reduce((c,i)=>c+i,0)}))})))}return Object.freeze({planTableBands:P,projectBandRows:k,alignBandBlocks:C})})(),bt=(()=>{const{ExportCell:S}=ve,{copyExportLink:O}=et,{tableSpans:P}=Ve,{createTotals:k}=ht,{presentation:C,positive:y}=Fe,{displayText:m,pdfBudgetText:b}=Qe,{capturePdfText:x,wrapPdfText:p}=lt,{planTableBands:u,projectBandRows:o,alignBandBlocks:s}=or;class a{settings;fonts;bands;widths;lefts;lineHeight;headings;totals;repeatedColumns;structuredBandRows=new WeakMap;dataPresentations=[];constructor(r,n){this.settings=r,this.fonts=n;const{options:e,padding:t,fontSize:h,page:l,margins:f}=r,d=e.columns,g=l.width-f.left-f.right;this.repeatedColumns=new Set(r.repeatedColumns);let w;if(e.columnWidths&&e.columnWidths.length!==d.length)throw new RangeError("columnWidths must declare one point width per column.");const T=typeof e.wideTable=="object"?e.wideTable.minimumColumnWidth??72:0,v=d.map((j,M)=>y(e.columnWidths?.[M]??Math.max(T,j.width===void 0?g/d.length:y(j.width,"Column width",255)*(w??=n.select().width(48)*h/1e3)+t*2),"PDF column width")),E=v.reduce((j,M)=>j+M,0);if(E>g+.001&&e.wideTable==="reject")throw new RangeError("Table widths exceed the printable page width.");this.bands=u(v,r),this.widths=!this.bands&&E>g?v.map(j=>j*g/E):v;let R=f.left;if(this.lefts=this.widths.map(j=>{const M=R;return R+=j,M}),this.widths.some(j=>j<=t*2))throw new RangeError("Page is too narrow for this many columns and the requested padding.");this.lineHeight=n.select().lineHeight(h);const I=d.reduce((j,M)=>Math.max(j,M.groups?.length??0),0);if(I>16)throw new RangeError("Grouped headings support at most 16 levels.");if(I&&e.includeHeader===!1)throw new TypeError("Grouped headings require leaf headings.");const z=[];if(e.includeHeader!==!1){for(let j=0;j<I;j++){const M=[];for(let L=0;L<d.length;){let B=L;const q=d[L].groups?.[j]??"",G=JSON.stringify(d[L].groups?.slice(0,j+1));for(;q&&B+1<d.length&&JSON.stringify(d[B+1].groups?.slice(0,j+1))===G;)B++;M.push({first:L,span:B-L+1,text:q}),L=B+1}z.push(M)}z.push(d.map((j,M)=>({first:M,span:1,text:j.header})))}this.headings=z,this.totals=k(d,e.footer?.totals)}async cell(r,n,e,t,h,l=!1){const{options:f,padding:d,fontSize:g,budget:w}=this.settings,T=f.columns[n],v=r instanceof S?r.presentation:void 0,E=r instanceof S&&r.link?O(r.link):void 0,R=l&&t%2&&f.alternateRowColor?f.alternateRowColor:void 0,I=n*2+(R?1:0),z=l&&v===void 0;let j=z?this.dataPresentations[I]:void 0;if(!j){const U=l?R?{background:R}:{}:h;j=C({...T.alignment===void 0?{}:{alignment:T.alignment},...T.wrapText===void 0?{}:{wrapText:T.wrapText},...U,...v}),z&&(this.dataPresentations[I]=j)}const M=this.fonts.select(j.bold,j.italic),L=e===1?this.widths[n]:this.widths.slice(n,n+e).reduce((U,X)=>U+X,0),B={rowIndex:t,columnIndex:n,column:T},q=r instanceof S?r.value:r;let G;if(f.formatRuns&&t>=0&&!(r instanceof S&&r.text!==void 0)){const U=f.formatRuns(q,B);if(!Array.isArray(U))throw U&&typeof U.then=="function"&&Promise.resolve(U).catch(()=>{}),new TypeError("formatRuns must return a synchronous array of PDF text runs.");G=U}else G=m(r,f,B);const _=x(G,j,this.settings,this.fonts);if(f.tagged&&E&&!_.text.trim())throw new TypeError("Tagged PDF cell links require nonempty displayed text.");if(E&&_.runs.some(U=>U.link))throw new TypeError("A PDF cell link cannot be combined with inline run links.");const F=b(_.text,w);this.bands?w.release(1,F.length):w.cell(F,F.length);const W=await p(_,this.fonts,g,L-d*2,this.settings,j.wrapText!==!1);return{first:n,span:e,width:L,font:M,style:j,lineHeight:W.reduce((U,X)=>Math.max(U,X.lineHeight),M.lineHeight(g)),...E?{link:E}:{},...this.bands?{captured:_}:{},lines:W}}row(r){let n=1,e=this.lineHeight;for(let t=0;t<r.length;t++){const h=r[t];n=Math.max(n,h.lines.length),e=Math.max(e,h.lineHeight)}return{cells:r,lines:n,lineHeight:e,height:n*e+this.settings.padding*2}}async headers(){if(this.settings.options.headerRows)return this.block(this.settings.options.headerRows,this.settings.options.headerPresentation??{});const{formatValue:r,...n}=this.settings.options,e=[];for(const t of this.headings){const h=[];for(const l of t)h.push(await this.cell(new S(l.text,{text:l.text}),l.first,l.span,-1,n.headerPresentation??{}));e.push(this.row(h))}return e}async block(r,n){const e=P(r,this.settings.options.columns.length),{formatValue:t,...h}=this.settings.options,l=[];for(const d of e){const g=[];for(const w of d){const T=w.value instanceof S?w.value:new S(w.value),v=new S(T.value,{text:m(T,h,{rowIndex:-1,columnIndex:w.first,column:h.columns[w.first]}),...T.presentation?{presentation:T.presentation}:{},...T.link?{link:T.link}:{}});g.push({...await this.cell(v,w.first,w.span,-1,n),rowSpan:w.rowSpan})}l.push(g)}const f=l.map(d=>Math.max(this.lineHeight+this.settings.padding*2,...d.filter(g=>g.rowSpan===1).map(g=>g.lines.length*g.lineHeight+this.settings.padding*2)));return l.forEach((d,g)=>d.forEach(w=>{const T=f.slice(g,g+w.rowSpan).reduce((E,R)=>E+R,0),v=w.lines.length*w.lineHeight+this.settings.padding*2;if(v>T)for(let E=g;E<g+w.rowSpan;E++)f[E]+=(v-T)/w.rowSpan})),l.map((d,g)=>({cells:d.map(w=>({...w,height:f.slice(g,g+w.rowSpan).reduce((T,v)=>T+v,0)})),lines:Math.max(1,Math.ceil((f[g]-this.settings.padding*2)/this.lineHeight)),lineHeight:this.lineHeight,height:f[g],structured:!0}))}minimumRowLines(r){let n=1;if(this.bands)for(const e of r.cells)this.repeatedColumns.has(e.first)&&(n=Math.max(n,e.lines.length));return n}minimumRowHeight(r){return this.minimumRowLines(r)*r.lineHeight+this.settings.padding*2}repeatedColumn(r){return this.repeatedColumns.has(r)}async blockHeight(r){return(this.bands?(await this.bandRows(r,!0))[0]:r).reduce((e,t)=>e+t.height,0)}async bandRows(r,n=!1){if(!this.bands)throw new Error("Horizontal bands were not planned.");if(!n)return this.projectBandRows(r,!1);let e=this.structuredBandRows.get(r);return e||(e=this.projectBandRows(r,!0),this.structuredBandRows.set(r,e)),e}async projectBandRows(r,n){const e=[],t=new Set;for(const h of this.bands){const l=await o(r,h,this.widths,this.settings,this.fonts);e.push(l.map(f=>({...f,cells:f.cells.map(d=>{const g=d.source,w=t.has(g);return t.add(g),w?{...d,semanticArtifact:!0}:d})})))}return n?s(e,this.settings):e}async data(r,n,e=!1){const{options:t}=this.settings,h=[];for(let l=0;l<t.columns.length;l++){const f=r[l],d=f instanceof S?f.value:f;e||this.totals[l].accept(d);const g=await this.cell(f,l,1,n,e?t.footerPresentation??{}:void 0,!e);h.push(!e&&t.columns[l].rowHeader?{...g,rowHeader:!0}:g)}return this.row(h)}async footer(r){if(!this.settings.options.footer)return;if(this.settings.options.footer.rows)return this.block(this.settings.options.footer.rows,this.settings.options.footerPresentation??{});const n=this.totals.map((e,t)=>e.operation?e.value():this.settings.options.footer?.values?.[t]);return[await this.data(n,r,!0)]}}return Object.freeze({PdfTableLayout:a})})(),ar=(()=>{const{OfficeIMOError:S}=me,{checkAbort:O}=be;class P{layout;headings;painter;caption;continuation;entries=[];height=0;count=0;firstWindow=!0;firstCapacity;painted=!1;constructor(y,m,b,x,p){this.layout=y,this.headings=m,this.painter=b,this.caption=x,this.continuation=p,this.firstCapacity=b.firstCapacity}get capacity(){return this.firstWindow?this.firstCapacity:this.painter.continuationCapacity}async accept(y){if(this.entries.length&&(this.height+y.height>this.capacity+.001||this.count+y.count>this.layout.settings.limits.maxTableWindowRows)&&await this.flush(),this.firstWindow&&!this.entries.length&&y.height>this.capacity+.001&&y.height<=this.painter.firstFullCapacity+.001&&(await this.painter.moveFirstToFreshPage(),this.firstCapacity=this.painter.firstFullCapacity),y.height>this.capacity+.001)throw new RangeError("PDF band window cannot fit the requested table fragment.");this.entries.push(y),this.height+=y.height,this.count+=y.count,this.count>=this.layout.settings.limits.maxTableWindowRows&&await this.flush()}async row(y,m=!1){const{padding:b,fontSize:x,options:p}=this.layout.settings,u=this.layout.minimumRowLines(y),o=u*y.lineHeight+b*2;if(o>this.painter.firstFullCapacity+.001||o>this.painter.continuationCapacity+.001)throw new RangeError("Repeated PDF identifiers must fit intact below the first and continued band headings/context.");this.entries.length&&y.height<=this.painter.continuationCapacity+.001&&y.height>this.capacity-this.height+.001&&await this.flush(),!m&&this.firstWindow&&!this.entries.length&&y.height>this.capacity+.001&&y.height<=this.painter.firstFullCapacity+.001&&(await this.painter.moveFirstToFreshPage(),this.firstCapacity=this.painter.firstFullCapacity),await this.painter.prepareRow?.(y);let s=0;for(;s<y.lines;){if(O(p.signal),this.entries.length&&this.capacity-this.height+.001<o&&await this.flush(),this.firstWindow&&!this.entries.length&&this.capacity+.001<o&&(await this.painter.moveFirstToFreshPage(),this.firstCapacity=this.painter.firstFullCapacity),this.capacity-this.height+.001<o)throw new RangeError("PDF band window cannot fit its complete repeated identifiers.");const a=Math.min(y.lines-s,Math.floor((this.capacity-this.height-b*2+.001)/y.lineHeight));if(a<1)throw new RangeError("PDF page cannot fit a table line below horizontal band headings.");const c=Math.max(a,u),i=c*y.lineHeight+b*2,r=await this.layout.bandRows([y]),n=[],e=r.map((t,h)=>{let l=!1;const f=t[0].cells.map(w=>{const T=this.layout.bands[h].columns[w.first],v=this.layout.repeatedColumn(T),E=w.span===1&&(w.source?.span??1)===1&&(w.rowSpan??1)===1&&w.height===void 0&&s===0&&(v||a>=w.lines.length),R=v||E?w.lines:w.lines.slice(s,s+a);if(!v&&(R.length>0||w.link!==void 0)&&(l=!0),E)return w;const{height:I,...z}=w;return{...z,lines:R,lineHeight:R.reduce((j,M)=>Math.max(j,M.lineHeight),w.font.lineHeight(x)),...s>0&&v?{semanticArtifact:!0}:{}}}),d=Math.max(1,...f.map(w=>w.lines.length)),g=Math.max(this.layout.lineHeight,...f.filter(w=>w.lines.length>0).map(w=>w.lineHeight));return n.push(s>0&&!l),[{...t[0],cells:f,lines:d,lineHeight:g,height:d*g+b*2}]});await this.accept({rows:e,height:i,count:1,completed:s+a>=y.lines?[y]:[],exhaustedBands:n}),s+=a,s<y.lines&&await this.flush()}}async block(y){const m=await this.layout.bandRows(y,!0),b=m[0].reduce((x,p)=>x+p.height,0);if(y.length>this.layout.settings.limits.maxTableWindowRows)throw new S("RESOURCE_LIMIT","A structured PDF block exceeds maxTableWindowRows.");for(const x of y)await this.painter.prepareRow?.(x);await this.accept({rows:m,height:b,count:y.length,completed:y,exhaustedBands:m.map(()=>!1)})}async keptRows(y,m=!1){const b=y.reduce((p,u)=>p+u.height,0),x=b<=this.painter.continuationCapacity+.001;this.entries.length&&x&&b>this.capacity-this.height+.001&&await this.flush();for(const[p,u]of y.entries())await this.row(u,!x&&p===0&&m)}async flush(y=!1){if(!(!this.entries.length&&(!y||this.painted||!this.headings.some(m=>m.length)))){for(let m=0;m<this.layout.bands.length;m++)O(this.layout.settings.options.signal),!(!this.firstWindow&&this.entries.length>0&&this.entries.every(b=>b.exhaustedBands[m]))&&await this.painter.paint(m,this.headings[m],this.entries.flatMap(b=>b.rows[m]),this.firstWindow?this.caption:this.continuation,this.firstWindow,m===0);for(const m of this.entries)for(const b of m.completed)await this.painter.completeRow?.(b);this.entries=[],this.height=0,this.count=0,this.firstWindow=!1,this.painted=!0}}}return Object.freeze({PdfTableBandFlow:P})})(),lr=(()=>{class S{structure;table;headers;cells=new WeakMap;rows=new WeakMap;columnHeaders=[];ordinaryAttributes=[];headerCount=0;headersPrepared=!1;constructor(k,C,y){this.structure=k,this.table=C,this.headers=y}async prepareHeaders(){if(!this.headersPrepared){for(let k=0;k<this.headers.length;k++){const C=this.headers[k],y=this.structure.element("TR",this.table);this.rows.set(C,y);for(const m of C.cells){const b=m.lines.some(u=>u.text.trim().length>0),x=this.associations(m,k),p=this.structure.element(b?"TH":"TD",y,this.attributes(m,x,b?"Column":void 0));if(this.cells.set(m,p),b){const u={row:k,order:this.headerCount++,identifier:await this.structure.identifier(p)};for(let o=m.first;o<m.first+m.span;o++)(this.columnHeaders[o]??=[]).push(u)}}}this.headersPrepared=!0}}async completeHeaders(){for(const k of this.headers)await this.completeRow(k)}async prepareRow(k,C="data",y=this.table,m){if(this.rows.get(k)!==void 0)return k.cells.map(o=>this.cells.get(o));const x=this.structure.element("TR",y);this.rows.set(k,x);const p=k.cells.map((o,s)=>{const a=m===void 0?o.rowHeader===!0:s===m,c=this.structure.element(a?"TH":"TD",x);return this.cells.set(o,c),c});let u;for(let o=0;o<p.length;o++)(m===void 0?k.cells[o].rowHeader===!0:o===m)&&(u??=[]).push(await this.structure.identifier(p[o]));for(let o=0;o<k.cells.length;o++){const s=k.cells[o];if(!u&&s.span===1&&(s.rowSpan??1)===1){const i=this.ordinaryAttributes[s.first]??=await this.structure.attributeReference(this.attributeDictionary(s,this.associations(s)));this.structure.setAttributes(p[o],i);continue}const a=this.associations(s),c=m===void 0?s.rowHeader===!0:o===m;!c&&u&&a.push(...u),this.structure.setAttributes(p[o],this.attributes(s,a,c?"Row":void 0))}return p}owner(k){return this.cells.get(k)}async completeRow(k){await this.structure.complete(this.rows.get(k))}async finish(){await this.completeHeaders(),await this.structure.complete(this.table)}associations(k,C=Number.POSITIVE_INFINITY){if(k.span===1)return(this.columnHeaders[k.first]??[]).filter(m=>m.row<C).map(m=>m.identifier);const y=new Set;for(let m=k.first;m<k.first+k.span;m++)for(const b of this.columnHeaders[m]??[])b.row<C&&y.add(b);return[...y].sort((m,b)=>m.order-b.order).map(m=>m.identifier)}attributes(k,C,y){return" /A "+this.attributeDictionary(k,C,y)}attributeDictionary(k,C,y){return"<< /O /Table"+(y===void 0?"":" /Scope /"+y)+(k.span>1?" /ColSpan "+k.span:"")+((k.rowSpan??1)>1?" /RowSpan "+k.rowSpan:"")+(C.length?" /Headers ["+C.map(m=>"("+m+")").join(" ")+"]":"")+" >>"}}return Object.freeze({PdfTableStructure:S})})(),cr=(()=>{const{OfficeIMOError:S}=me,{pdfNumber:O,unicodeHex:P}=Be,k=new TextEncoder;function C(m,b,x,p,u,o,s,a){const c="<< /Type /Annot /Subtype /Link /F 4 /Border [0 0 0] /Rect ["+[b,x,b+p,x+u].map(O).join(" ")+"]"+(s===void 0?"":" /StructParent "+s)+(a===void 0?"":" /P "+a+" 0 R")+" /A << /S /URI /URI <",i="> >>"+(m.tooltip===void 0?"":" /Contents <feff")+" >>",r=c.length+i.length+(m.tooltip===void 0?0:m.tooltip.length*4+1),n=()=>{throw new S("RESOURCE_LIMIT","maxPageBytes exceeded.")};r+m.target.length*2>o&&n();let e=0;for(let h=0;h<m.target.length;h++){const l=m.target.charCodeAt(h);l<128?e++:l<2048?e+=2:l>=55296&&l<=56319&&h+1<m.target.length&&m.target.charCodeAt(h+1)>=56320&&m.target.charCodeAt(h+1)<=57343?(e+=4,h++):e+=3,r+e*2>o&&n()}let t="";for(const h of k.encode(m.target))t+=h.toString(16).padStart(2,"0");return c+t+"> >>"+(m.tooltip===void 0?"":" /Contents <feff"+P(m.tooltip)+">")+" >>"}return Object.freeze({linkAnnotation:C})})(),xt=(()=>{const{OfficeIMOError:S}=me,{unicodeHex:O}=Be,{captureFields:P}=Ce;function k(m,b){if(m===void 0)return;if(!m||typeof m!="object")throw new TypeError("PDF bookmark must provide a title and optional level.");const{title:x,level:p=1}=m;if(typeof x!="string"||!x.trim())throw new TypeError("PDF bookmark title must be nonempty text.");if(x.length>b.limits.maxCellCharacters)throw new S("RESOURCE_LIMIT","maxCellCharacters exceeded by bookmark title.");if(!Number.isInteger(p)||p<1||p>6)throw new TypeError("PDF bookmark level must be an integer from 1 through 6.");return O(x),Object.freeze({title:x,level:p})}function C(m,b){if(!m||m.kind!=="section")throw new TypeError("PDF section boundary required.");if(Object.keys(m).some(h=>!["kind","title","level","includeHeading","bookmark","headingStyle","pageSize","orientation","margins","pageHeader","pageFooter","pageNumbers"].includes(h)))throw new TypeError("PDF sections support title, heading/bookmark controls, page geometry and decorations only.");const{title:x,level:p,includeHeading:u=!0,bookmark:o=!0,headingStyle:s,pageSize:a,orientation:c,margins:i,pageHeader:r,pageFooter:n,pageNumbers:e}=m,t=k({title:x,...p===void 0?{}:{level:p}},b);for(const[h,l]of[["includeHeading",u],["bookmark",o],["pageNumbers",e]])if(l!==void 0&&typeof l!="boolean")throw new TypeError("PDF section "+h+" must be boolean.");if(s!==void 0&&(typeof s!="string"||!s.trim()))throw new TypeError("PDF section headingStyle must be nonempty text.");return Object.freeze({kind:"section",title:t.title,level:t.level,includeHeading:u,bookmark:o,...s===void 0?{}:{headingStyle:s},...a===void 0?{}:{pageSize:typeof a=="object"?Object.freeze(P(a,["width","height"])):a},...c===void 0?{}:{orientation:c},...i===void 0?{}:{margins:typeof i=="object"?Object.freeze(P(i,["top","right","bottom","left"])):i},...r===void 0?{}:{pageHeader:r},...n===void 0?{}:{pageFooter:n},...e===void 0?{}:{pageNumbers:e}})}return Object.freeze({captureBookmark:k,captureSection:C})})(),hr=(()=>{const{settings:S}=Fe;function O(k,C){const{pageSize:y,orientation:m,margins:b,pageHeader:x,pageFooter:p,pageNumbers:u}=C,o={...k.options,...y===void 0?{}:{pageSize:y},...m===void 0?{}:{orientation:m},...b===void 0?{}:{margins:b},...x===void 0?{}:{pageHeader:x},...p===void 0?{}:{pageFooter:p},...u===void 0?{}:{pageNumbers:u}},s=S(o,!0);return{...k,page:s.page,margins:s.margins,options:o}}return Object.freeze({sectionSettings:O})})(),dr=(()=>{const{OfficeIMOError:S}=me,{checkAbort:O}=be,{pdfNumber:P}=Be,{color:k}=Fe,{PdfTableBandFlow:C}=ar,{PdfTableStructure:y}=lr,{wrapText:m,wrapTextCooperatively:b,synchronousText:x,pdfBudgetText:p}=Qe,{linkAnnotation:u}=cr,{unicodeHex:o}=Be,{captureSection:s,captureBookmark:a}=xt,{sectionSettings:c}=hr;class i{objects;baseSettings;fonts;parent;resources;layout;structure;outlines;references=[];current=0;commands="";commandParts=[];commandBytes=0;annotations=[];hyperlinks=0;y=0;dataTop=0;continuationTop=0;totalPages;numberSettings;activeSettings;pendingPage;bodyAdded=!1;sectionCount=0;sectionPages=0;sectionTitle;pendingBookmarks=[];pageNumberWidth=0;colors=new Map;textFont;textSize=0;textColor="";textPrefix="";rectangleLefts;rectangleColumns=[];externalObjects=new Map;bandFlow;bandCellBudget=!1;tableElement;tableStructure;activeHeadings;paintedHeaderCells=new WeakSet;paintedHeaderBudgetCells=new WeakSet;summaryRows=new WeakSet;groups=[];continuationCaption;tableCaptionOwner;continuationCaptionPaints=0;constructor(e,t,h,l,f,d,g,w){this.objects=e,this.baseSettings=t,this.fonts=h,this.parent=l,this.resources=f,this.layout=d,this.structure=g,this.outlines=w,this.activeSettings=t}measurePageNumbers(){const e=this.settings,t=this.fonts.select(),h=e.limits.maxPages,f=Math.max(...Array.from({length:Math.min(10,h)},(w,T)=>t.width(h<10?49+T:48+T)))*String(h).length*e.fontSize/1e3,d=e.options.pageNumberLabels;return m((d?.prefix??"Page ")+(d?.separator??" of ")+(d?.suffix??""),t,e.fontSize,Number.MAX_SAFE_INTEGER,e.limits.maxCellCharacters,1,!1)[0].width+f*2+2}get settings(){return this.activeSettings}async ensureStarted(){this.current||await this.start(!1)}async beginSection(e){const t=s(e,this.baseSettings),h=c(this.baseSettings,t);if(++this.sectionCount>this.baseSettings.limits.maxSections)throw new S("RESOURCE_LIMIT","maxSections exceeded.");return this.current&&(this.bodyAdded?await this.finishPage():(this.pendingPage=this.current,this.current=0)),this.activeSettings=h,this.sectionPages=0,this.sectionTitle=t.title,await this.structure?.beginSection(),t}addBookmark(e){const t=a(e,this.settings);if((this.outlines?.count??0)+this.pendingBookmarks.length>=this.settings.limits.maxBookmarks)throw new S("RESOURCE_LIMIT","maxBookmarks exceeded.");this.settings.budget.cell(t.title),this.current?this.outlines?.add(t,this.current,this.y):this.pendingBookmarks.push(t)}add(e){this.retainPageBytes(e.length),this.commands+=e}retainPageBytes(e){if(this.commandBytes+=e,this.commandBytes>this.settings.limits.maxPageBytes)throw new S("RESOURCE_LIMIT","maxPageBytes exceeded.")}rgb(e){let t=this.colors.get(e);return t||(t=k(e),this.colors.size<1024&&this.colors.set(e,t)),t}artifact(e,t="Layout"){return this.structure?"/Artifact << /Type /"+t+" >> BDC\n"+e+"EMC\n":e}text(e,t,h,l,f,d="111827",g){const w=P;if(t!==this.textFont||h!==this.textSize||d!==this.textColor){const v=t.syntheticItalic?.213:0,E=this.rgb(d);this.textPrefix="q "+E+" rg "+E+" RG\nBT /"+t.name+" "+w(h)+" Tf "+(t.syntheticBold?w(h*.025)+" w 2 Tr ":"0 Tr ")+"1 0 "+w(v)+" 1 ",this.textFont=t,this.textSize=h,this.textColor=d}const T=this.textPrefix+w(l)+" "+w(f)+" Tm "+t.encode(e)+" Tj ET Q\n";this.add(this.structure&&g!==void 0?this.structure.mark(g)+T+"EMC\n":this.artifact(T,"Pagination"))}link(e,t,h,l,f,d){if(l<=0)return;if(++this.hyperlinks>this.settings.limits.maxHyperlinks)throw new S("RESOURCE_LIMIT","maxHyperlinks exceeded.");const g=this.objects.reserve(),w=this.structure&&d!==void 0?this.structure.annotation(d,g):void 0,T=u(e,t,h,l,f,this.settings.limits.maxPageBytes-this.commandBytes,w,this.structure?this.current:void 0);this.retainPageBytes(T.length),this.annotations.push({id:g,body:T})}inline(e,t,h,l,f,d=f){const g=!this.structure&&e.actualText!==void 0&&e.actualText.length>0;g&&this.add("/Span << /ActualText <FEFF"+o(e.actualText)+"> >> BDC\n");let w;if(e.actualText!==void 0&&this.structure&&f!==void 0){w=new Map;for(const T of[...e.segments].sort((v,E)=>(v.logicalStart??0)-(E.logicalStart??0))){const v=T.link?this.structure.link(f,T.link):f;w.set(T,{owner:v,mark:this.structure.mark(v,T.actualText)})}}for(const T of e.segments){const v=w?.get(T),E=v?.owner??(T.link&&this.structure&&f!==void 0?this.structure.link(f,T.link):f);if(T.glyphs){const R=T.font,I=P,z=R.syntheticItalic?.213:0,j=this.rgb(T.color??"111827");let M=h,L="q "+j+" rg "+j+" RG\nBT /"+R.name+" "+I(t)+" Tf "+(R.syntheticBold?I(t*.025)+" w 2 Tr ":"0 Tr ");for(const B of T.glyphs)L+="1 0 "+I(z)+" 1 "+I(M+(B.xOffset+z*B.yOffset)*t/1e3)+" "+I(l+B.yOffset*t/1e3)+" Tm "+R.encodeGlyph(B.id,B.logicalText)+" Tj\n",M+=B.xAdvance*t/1e3;L+="ET Q\n",this.add(this.structure&&E!==void 0?(v?.mark??this.structure.mark(E,T.actualText))+L+"EMC\n":this.artifact(L,"Pagination"))}else this.text(T.text,T.font,t,h,l,T.color,E);if(T.link){const R=(T.font.program?.ascent??800)*t/1e3,I=(T.font.program?.descent??-200)*t/1e3,z=E??(this.structure&&d!==void 0?this.structure.link(d,T.link):void 0);this.link(T.link,h,l+I,T.width,R-I,z)}h+=T.width}g&&this.add("EMC\n")}decorationText(e){return e===void 0?"":(O(this.settings.options.signal),x(typeof e=="function"?e(Object.freeze({pageNumber:this.references.length,sectionNumber:this.sectionCount||1,sectionPageNumber:this.sectionPages,...this.sectionTitle===void 0?{}:{sectionTitle:this.sectionTitle}})):e,"Page header/footer"))}decoration(e,t,h,l){if(!e)return;this.settings.budget.cell(p(e,this.settings.budget));const f=this.fonts.select(),d=m(e,f,this.settings.fontSize,l,this.settings.limits.maxCellCharacters,1,!1);this.text(d[0].text,f,this.settings.fontSize,t,h)}async start(e=!0,t){if(this.pendingPage===void 0&&this.references.length>=this.settings.limits.maxPages)throw new S("RESOURCE_LIMIT","maxPages exceeded.");const{page:h,margins:l,options:f,fontSize:d}=this.settings,g=this.fonts.select().lineHeight(d);if(this.pendingPage!==void 0?(this.current=this.pendingPage,this.pendingPage=void 0):(this.current=this.objects.reserve(),this.references.push(this.current)),this.commands="",this.commandParts=[],this.annotations=[],this.commandBytes=0,this.bodyAdded=!1,this.sectionPages++,f.pageNumbers!==!1&&(this.totalPages??=this.objects.reserve(),this.numberSettings??=this.settings,this.pageNumberWidth||(this.pageNumberWidth=this.measurePageNumbers()),this.pageNumberWidth>h.width-l.left-l.right))throw new RangeError("Page is too narrow for page numbers at the declared maxPages and font size.");this.structure?.beginPage(this.current),this.y=h.height-l.top;const w=this.decorationText(f.pageHeader),T=this.decorationText(f.pageFooter);if(w&&l.top<g+4)throw new RangeError("Top margin is too small for a page header.");if((T||f.pageNumbers!==!1)&&l.bottom<g+4)throw new RangeError("Bottom margin is too small for page decorations.");const v=this.fonts.select(),E=((v.program?.ascent??800)+(v.program?.descent??-200))*d/2e3;this.decoration(w,l.left,h.height-l.top/2-E,h.width-l.left-l.right);const R=h.width-l.left-l.right-(f.pageNumbers!==!1?this.pageNumberWidth+this.settings.padding*2:0);if(R<=0&&T)throw new RangeError("Page is too narrow for both footer text and page numbers.");if(this.decoration(T,l.left,l.bottom/2-E,R),f.pageNumbers!==!1){const M=f.pageNumberLabels,L=M?.suffix??"",B=h.width-l.right-this.pageNumberWidth+1,q=l.bottom/2-E,G=(M?.prefix??"Page ")+this.references.length+(M?.separator??" of "),_=m(G,v,d,this.pageNumberWidth,this.settings.limits.maxCellCharacters,1,!1)[0];this.settings.budget.cell(G+L),this.text(G,v,d,B,q),this.add(this.artifact("q 1 0 0 1 "+P(B+_.width)+" "+P(q)+" cm /TotalPages Do Q\n","Pagination"))}for(const M of this.pendingBookmarks.splice(0))this.outlines?.add(M,this.current,this.y);this.references.length===1&&(f.title&&await this.paragraph(f.title,{bold:!0},d*1.5,!1,1),f.messageTop&&await this.paragraph(f.messageTop,{},d,!1));const I=t??(e&&this.layout?this.activeHeadings??=await this.layout.headers():[]),z=I.reduce((M,L)=>M+L.height,0),j=e&&this.layout?this.continuationCaption:void 0;if(j?.lines.length&&(this.continuationCaptionPaints++===0&&(this.tableCaptionOwner=this.captionAnnotations(j,this.tableCaptionOwner)),await this.paragraphs([j],z+g+this.settings.padding*2,!0,{artifact:!0,...this.tableCaptionOwner===void 0?{}:{annotationParent:this.tableCaptionOwner}})),this.continuationTop=h.height-l.top-z-(j?.height??0),this.y-z-g-this.settings.padding*2<l.bottom)throw new RangeError("PDF title and repeated headings leave no room for a data line.");e&&this.layout&&this.structure&&this.tableElement===void 0&&(this.tableElement=this.structure.element("Table",this.groupParent),this.tableStructure=new y(this.structure,this.tableElement,I),await this.tableStructure.prepareHeaders()),await this.drawHeadings(I),this.dataTop=this.y}async drawHeadings(e){for(const t of e){for(const f of t.cells)!this.bandCellBudget&&this.paintedHeaderBudgetCells.has(f.source??f)&&this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters===void 0?"":f.lines.map(d=>d.text).join(""));const h=this.tableStructure?t.cells.map(f=>this.tableStructure.owner(f.source??f)):void 0,l=t.cells.map(f=>this.paintedHeaderCells.has(f.source??f));this.draw(t,0,t.lines,h,l);for(const f of t.cells)this.paintedHeaderCells.add(f.source??f),this.paintedHeaderBudgetCells.add(f.source??f)}}async rowElements(e){const t=e.source??e;return this.tableStructure?.prepareRow(t,"data",this.tableElement,this.summaryRows.has(t)?0:void 0)}draw(e,t,h,l,f=[]){if(!this.layout)throw new Error("A table layout is required before drawing rows.");this.bodyAdded=!0;const{padding:d,fontSize:g}=this.settings,w=P,T=h*e.lineHeight+d*2,v=this.layout.lefts;this.rectangleLefts!==v&&(this.rectangleLefts=v,this.rectangleColumns=[]);let E,R="",I="";for(const[z,j]of e.cells.entries()){this.bandCellBudget&&this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters===void 0?"":(j.height===void 0?j.lines.slice(t,t+h):j.lines).map(W=>W.text).join(""));const M=v[j.first],L=j.height??T;L!==E&&(R=w(this.y-L),I=w(L),E=L);let B=this.rectangleColumns[j.first];(!B||B.x!==M||B.width!==j.width)&&(B={x:M,width:j.width,left:w(M),widthText:w(j.width)},this.rectangleColumns[j.first]=B);const q=B.left+" "+R+" "+B.widthText+" "+I;j.style.background&&this.add(this.artifact("q "+this.rgb(j.style.background)+" rg "+q+" re f Q\n")),this.add(this.artifact("q 0.82 0.85 0.89 RG 0.4 w "+q+" re S Q\n"));const G=l?.[z],_=j.semanticArtifact||f[z],F=j.link&&this.structure&&G!==void 0?this.structure.link(G,j.link):G;for(let W=t;W<Math.min(j.lines.length,j.height?j.lines.length:t+h);W++){const U=j.lines[W],X=j.style.alignment==="right"?j.width-d-U.width:j.style.alignment==="center"?(j.width-U.width)/2:d;this.inline(U,g,M+X,this.y-d-U.ascent-(W-t)*(e.structured?j.lineHeight:e.lineHeight),_?void 0:F,F)}j.link&&this.link(j.link,M,this.y-L,j.width,L,F)}this.y-=e.structured?e.height:T,this.sealCommands()}async block(e){if(this.bandFlow)return this.bandFlow.block(e);const t=e.reduce((l,f)=>l+f.height,0),h=this.settings.margins.bottom;if(t>this.y-h&&(await this.finishPage(),await this.start()),t>this.dataTop-h)throw new RangeError("A structured footer must fit on one page below the repeated headings.");for(const l of e){const f=await this.rowElements(l);this.draw(l,0,l.lines,f),await this.tableStructure?.completeRow(l.source??l)}}async row(e,t=!1){if(this.bandFlow)return this.bandFlow.row(e,t);const h=await this.rowElements(e),{margins:l,padding:f}=this.settings,d=this.continuationTop-l.bottom;!t&&e.height<=d+.001&&e.height>this.y-l.bottom+.001&&(await this.finishPage(),await this.start());let g=0;for(;g<e.lines;){let w=Math.min(e.lines-g,Math.floor((this.y-l.bottom-f*2+.001)/e.lineHeight));if(w<=0&&(await this.finishPage(),await this.start(),w=Math.min(e.lines-g,Math.floor((this.y-l.bottom-f*2+.001)/e.lineHeight))),w<=0)throw new RangeError("PDF page cannot fit a table line.");this.draw(e,g,w,h),g+=w,g<e.lines&&(await this.finishPage(),await this.start())}await this.tableStructure?.completeRow(e.source??e)}async keptRows(e,t=!1){if(this.bandFlow)return this.bandFlow.keptRows(e,t);const h=e.reduce((d,g)=>d+g.height,0),l=this.settings.margins.bottom,f=h<=this.continuationTop-l+.001;f&&h>this.y-l+.001&&(await this.finishPage(),await this.start());for(const[d,g]of e.entries())await this.row(g,!f&&d===0&&t)}async paragraph(e,t={},h=this.settings.fontSize,l=!0,f){await this.ensureStarted();const{margins:d,page:g,limits:w}=this.settings,T=this.fonts.select(t.bold,t.italic),v=T.lineHeight(h);this.settings.budget.cell(p(e,this.settings.budget));const E=await b(e,T,h,g.width-d.left-d.right,w.maxCellCharacters,w.maxRowLines,!0,this.settings.options.signal);if(v>g.height-d.top-d.bottom)throw new RangeError("PDF page cannot fit a paragraph line at the selected font metrics.");if(!l&&this.y-E.length*v-8<d.bottom)throw new RangeError("PDF title/message exceeds the first page's content area.");const R=this.structure?.element(f?"H"+f:"P");for(const I of E){this.y-v<d.bottom&&(await this.finishPage(),await this.start(!1));const z=t.alignment==="right"?g.width-d.right-I.width:t.alignment==="center"?d.left+(g.width-d.left-d.right-I.width)/2:d.left;this.bodyAdded=!0,this.text(I.text,T,h,z,this.y-(T.program?.ascent??800)*h/1e3,t.color,R),this.y-=v}this.y-=8,await this.structure?.complete(R)}async reserveSpace(e,t="Kept PDF content"){await this.ensureStarted();const{page:h,margins:l}=this.settings,f=h.height-l.top-l.bottom;if(e>f+.001)throw new RangeError(t+" exceeds a fresh page's content area.");e>this.y-l.bottom+.001&&await this.pageBreak()}async paragraphs(e,t=0,h=!1,l={}){const f=e.filter(g=>g.lines.length>0);if(!f.length)return;await this.ensureStarted();const d=new Array(f.length).fill(0);for(let g=f.length-1;g>=0;g--){const w=f[g],T=f[g+1];d[g]=w.keepWithNext?T?T.keepTogether||T.keepWithNext?T.height+d[g+1]:T.firstHeight:t:0}h&&f.length&&await this.reserveSpace(f.reduce((g,w)=>g+w.height,0)+d.at(-1),"Kept PDF paragraph group");for(const[g,w]of f.entries()){w.budgetOnPaint&&this.settings.budget.cell(p(w.text.text,this.settings.budget)),(w.keepTogether||w.keepWithNext)&&await this.reserveSpace(w.height+d[g],"Kept PDF paragraph chain");const{margins:T,page:v}=this.settings;if(w.firstHeight>v.height-T.top-T.bottom+.001)throw new RangeError("PDF page cannot fit a paragraph line and its leading spacing.");this.y-w.firstHeight<T.bottom&&await this.pageBreak(),this.y-=w.spaceBefore,w.bookmark&&this.addBookmark(w.bookmark);const E=l.artifact?void 0:l.owner??this.structure?.element(l.role??(w.headingLevel?"H"+w.headingLevel:"P"),l.parent??this.groupParent);let R=!0;for(const I of w.lines){if(I.lineHeight>v.height-T.top-T.bottom+.001)throw new RangeError("PDF page cannot fit a paragraph line at the selected font metrics.");this.y-I.lineHeight<T.bottom&&await this.pageBreak();const z=T.left+(l.indent??0),j=v.width-T.right-z,M=w.style.alignment==="right"?v.width-T.right-I.width:w.style.alignment==="center"?z+(j-I.width)/2:z;R&&l.marker&&this.inline(l.marker.line,w.size,z-l.marker.gap-l.marker.line.width,this.y-I.ascent,l.marker.owner),this.bodyAdded=!0,this.inline(I,w.size,M,this.y-I.ascent,E,l.annotationParent??E),this.y-=I.lineHeight,R=!1}this.y-=w.spaceAfter,l.keepOpen||await this.structure?.complete(E)}}get groupParent(){return this.groups.at(-1)?.element}async beginGroup(e,t,h){if(e!==this.groups.length)throw new Error("PDF analytical groups must open in hierarchical order.");await this.ensureStarted();const l=this.structure?.element("Sect",this.groupParent);this.groups.push({level:e,headingLevel:t.headingLevel??e+2,element:l}),await this.paragraphs([t],h,!0,{role:"H"+(t.headingLevel??e+2),...l===void 0?{}:{parent:l}})}async endGroup(e){const t=this.groups.at(-1);if(!t||t.level!==e)throw new Error("PDF analytical groups must close in hierarchical order.");await this.structure?.complete(t.element),this.outlines?.closeGroup(t.headingLevel),this.groups.pop()}summary(e){this.summaryRows.add(e)}async beginTable(e,t,h=e.lineHeight+this.settings.padding*2,l,f,d=!1,g=!1,w=!1){if(e.bands)return this.beginBands(e,t,h,l,f,g,w);await this.ensureStarted(),this.layout=e,this.paintedHeaderCells=new WeakSet,this.continuationCaption=f,this.continuationCaptionPaints=0,this.tableCaptionOwner=void 0,this.tableElement=this.structure?.element("Table",this.groupParent);const T=t??await e.headers();this.activeHeadings=T;const v=d&&this.bodyAdded&&!this.structure?[]:T,E=v.reduce((R,I)=>R+I.height,0);if(l&&!(g&&w)&&(await this.reserveSpace(l.height+E+h,"Kept PDF table caption and first data fragment"),this.tableCaptionOwner=g?this.captionAnnotations(l):l.lines.length?this.structure?.element("Caption",this.tableElement):void 0,await this.paragraphs([l],E+h,!0,g?{artifact:!0,...this.tableCaptionOwner===void 0?{}:{annotationParent:this.tableCaptionOwner}}:{role:"Caption",keepOpen:!0,...this.tableCaptionOwner===void 0?{}:{owner:this.tableCaptionOwner}})),this.structure&&(this.tableStructure=new y(this.structure,this.tableElement,T),await this.tableStructure.prepareHeaders()),this.y-E-h<this.settings.margins.bottom){await this.finishPage(),await this.start(!0,T);return}this.continuationTop=this.settings.page.height-this.settings.margins.top-T.reduce((R,I)=>R+I.height,0)-(f?.height??0),await this.drawHeadings(v),this.dataTop=this.y}async beginBands(e,t,h,l,f,d,g){await this.ensureStarted();const w=t??await e.headers(),T=await e.bandRows(w,!0),v=T[0].reduce((_,F)=>_+F.height,0),{page:E,margins:R,padding:I}=this.settings,z=E.height-R.top-R.bottom-v-(l?.height??0),j=h<=z+.001?h:e.lineHeight+I*2,M=E.height-R.top-R.bottom-v-(f?.height??0);if(M+.001<e.lineHeight+I*2)throw new RangeError("PDF band headings and continuation context leave no room for a data line.");let L=d&&g;this.y-R.bottom-v-(L?0:l?.height??0)+.001<j&&(await this.pageBreak(),L=!1);const B=this.y-R.bottom-v-(L?0:l?.height??0);if(B+.001<j)throw new RangeError("PDF band caption and headings leave no room for a data line.");let q=0;this.tableElement=this.structure?.element("Table",this.groupParent),this.paintedHeaderCells=new WeakSet;let G=this.structure&&l?.lines.length?d?this.captionAnnotations(l):this.structure.element("Caption",this.tableElement):void 0;this.structure&&(this.tableStructure=new y(this.structure,this.tableElement,w)),this.layout=void 0,this.continuationCaption=void 0,this.activeHeadings=void 0,this.bandFlow=new C(e,T,{firstCapacity:B,firstFullCapacity:z,continuationCapacity:M,prepareRow:async _=>{await this.tableStructure?.prepareHeaders(),await this.rowElements(_)},completeRow:async _=>{await this.tableStructure?.completeRow(_.source??_)},moveFirstToFreshPage:async()=>{await this.pageBreak(),L=!1},paint:async(_,F,W,U,X,V)=>{X&&V||await this.pageBreak();const Y=e.bands[_];this.layout={lefts:Y.lefts,lineHeight:e.lineHeight,headers:async()=>F},this.bandCellBudget=!0;try{if(U?.lines.length&&!(X&&V&&L)){!X&&q++===0&&(G=this.captionAnnotations(U,G));const re=G;await this.paragraphs([U],v+j,!0,X&&V&&!d?{role:"Caption",keepOpen:!0,...G===void 0?{}:{owner:G}}:{artifact:!0,...re===void 0?{}:{annotationParent:re}})}await this.tableStructure?.prepareHeaders(),await this.drawHeadings(F),this.dataTop=this.y;for(const re of W){O(this.settings.options.signal);const A=this.tableStructure?re.cells.map($=>this.tableStructure.owner($.source??$)):void 0;this.draw(re,0,re.lines,A)}}finally{this.bandCellBudget=!1}}},l,f)}async endTable(){this.bandFlow&&(await this.bandFlow.flush(!0),this.bandFlow=void 0),await this.tableStructure?.finish(),this.layout=void 0,this.tableElement=void 0,this.tableStructure=void 0,this.activeHeadings=void 0,this.continuationCaption=void 0,this.tableCaptionOwner=void 0,this.continuationCaptionPaints=0,this.y-=8}captionAnnotations(e,t){if(!this.structure||!e.text.runs.some(l=>l.link&&l.text.trim()))return t;const h=t??this.structure.element("Caption",this.tableElement);for(const l of e.text.runs)l.link&&l.text.trim()&&this.structure.link(h,l.link,l.text);return h}async pageBreak(){await this.ensureStarted(),await this.finishPage(),await this.start(!1)}registerXObject(e,t){this.externalObjects.set(e,t)}graphicHeight(e,t){const{page:h,margins:l}=this.settings;return t*Math.min(1,(h.width-l.left-l.right)/e,(h.height-l.top-l.bottom)/t)}async graphic(e,t,h,l,f,d){await this.ensureStarted();const{page:g,margins:w}=this.settings,T=g.width-w.left-w.right,v=Math.min(1,T/e,(g.height-w.top-w.bottom)/t);e*=v,t*=v;const E=this.structure&&f!==void 0?this.structure.element("Figure",void 0," /Alt <feff"+o(f)+">"):void 0;if(d){if(f===void 0)throw new TypeError("A captioned PDF graphic requires alternativeText and cannot be decorative.");await this.reserveSpace(d.height+t,"Kept PDF graphic and caption"),await this.paragraphs([d],t,!0,{role:"Caption",...E===void 0?{}:{parent:E}})}this.y-t<w.bottom&&await this.pageBreak();const R=h==="right"?g.width-w.right-e:h==="center"?w.left+(T-e)/2:w.left,I=l(R,this.y-t,e,t);this.bodyAdded=!0,this.add(this.structure&&E!==void 0?this.structure.mark(E)+I+"EMC\n":this.artifact(I)),this.y-=t+8,await this.structure?.complete(E)}async listItem(e,t){if(await this.ensureStarted(),this.structure&&t===void 0)throw new Error("A tagged list item requires a logical list owner.");const h=this.structure?.element("LI",t),l=h===void 0?void 0:this.structure.element("Lbl",h),f=h===void 0?void 0:this.structure.element("LBody",h);await this.paragraphs([e.paragraph],0,!1,{...f===void 0?{}:{parent:f},role:"P",indent:e.indent,marker:{line:e.marker,gap:e.markerGap,...l===void 0?{}:{owner:l}}}),await this.structure?.complete(h)}sealCommands(){this.commands&&(this.commandParts.push(this.commands),this.commands="")}takeCommands(){this.sealCommands();const e=this.commandParts.join("");return this.commandParts=[],e}async finishPage(){const e=this.objects.reserve(),{page:t,options:h}=this.settings;await this.objects.stream(e,this.takeCommands(),"",h.compression!==!1);const l=[];for(const f of this.annotations)l.push(f.id),await this.objects.object(f.id,f.body);await this.objects.object(this.current,"<< /Type /Page /Parent "+this.parent+" 0 R /MediaBox [0 0 "+P(t.width)+" "+P(t.height)+"] /Resources "+this.resources+" 0 R /Contents "+e+" 0 R"+(this.structure?.pageDictionary??"")+(l.length?" /Annots ["+l.map(f=>f+" 0 R").join(" ")+"]":"")+" >>"),this.structure&&await this.structure.finishPage(),this.annotations=[],this.commandBytes=0,this.current=0,await this.objects.flushBytes()}async finish(){if(this.bandFlow&&(await this.bandFlow.flush(!0),this.bandFlow=void 0),await this.ensureStarted(),await this.tableStructure?.finish(),await this.finishPage(),this.totalPages){const e=this.fonts.select(),t=String(this.references.length),h=t+(this.numberSettings.options.pageNumberLabels?.suffix??""),l=this.numberSettings.fontSize;this.settings.budget.cell(t);const f="BT /"+e.name+" "+P(l)+" Tf 1 0 0 1 0 0 Tm "+e.encode(h)+" Tj ET\n",d=m(h,e,l,this.numberSettings.page.width,this.settings.limits.maxCellCharacters,1,!1)[0].width,g=(e.program?.bbox[1]??-250)*l/1e3-1,w=(e.program?.bbox[3]??1e3)*l/1e3+1;await this.objects.stream(this.totalPages,f,"/Type /XObject /Subtype /Form /BBox [-1 "+P(g)+" "+P(d+1)+" "+P(w)+"] /Resources << /Font "+this.fonts.dictionary()+" >>",this.settings.options.compression!==!1)}}xobjects(){const e=[...this.externalObjects].map(([t,h])=>"/"+t+" "+h+" 0 R");return this.totalPages&&e.push("/TotalPages "+this.totalPages+" 0 R"),e.length?" /XObject << "+e.join(" ")+" >>":""}}return Object.freeze({PdfPages:i})})(),fr=(()=>{class S{objects;root;entries=[];levels=[];lastKey=-1;constructor(k,C){this.objects=k,this.root=C}async append(k,C){if(k<=this.lastKey)throw new Error("PDF ParentTree keys must be appended in increasing order.");this.lastKey=k,this.entries.push({key:k,value:C}),this.entries.length===64&&await this.leaf()}async leaf(){if(!this.entries.length)return;const k=this.objects.reserve(),C=this.entries[0].key,y=this.entries.at(-1).key,m="<< /Limits ["+C+" "+y+"] /Nums ["+this.entries.map(b=>b.key+" "+b.value+" 0 R").join(" ")+"] >>";this.entries.length=0,await this.objects.object(k,m),await this.node({id:k,first:C,last:y},0)}async node(k,C){const y=this.levels[C]??=[];if(y.push(k),y.length===64){const m=await this.branch(y);y.length=0,await this.node(m,C+1)}}async branch(k){const C=this.objects.reserve(),y=k[0].first,m=k.at(-1).last;return await this.objects.object(C,"<< /Limits ["+y+" "+m+"] /Kids ["+k.map(b=>b.id+" 0 R").join(" ")+"] >>"),{id:C,first:y,last:m}}async finish(){await this.leaf();for(let C=0;C<this.levels.length-1;C++){const y=this.levels[C];if(y.length){const m=await this.branch(y);y.length=0,await this.node(m,C+1)}}const k=this.levels.at(-1)??[];await this.objects.object(this.root,k.length?"<< /Kids ["+k.map(C=>C.id+" 0 R").join(" ")+"] >>":"<< /Nums [] >>")}}return Object.freeze({PdfParentTree:S})})(),zt=(()=>{const{OfficeIMOError:S}=me,{checkAbort:O}=be,{unicodeHex:P}=Be,{PdfParentTree:k}=fr;function C(o){return typeof o=="number"?o<0?-o-1+" ":o+" 0 R ":o+" "}function y(o){return"<< /Type /StructElem /S /"+o.role+" /P "+o.parent+" 0 R"+(o.markedPage===void 0?"":" /Pg "+o.markedPage+" 0 R")+(o.identifier===void 0?"":" /ID ("+o.identifier+")")+" /K ["}function m(o,s){const a=32768-s.length-o.attributes.length-4;if(a<0)return;let c="";for(const i of o.children){const r=C(i);if(c.length+r.length>a)return;c+=r}return s+c+"]"+o.attributes+" >>"}class b{objects;root;entries=[];levels=[];lastKey="";constructor(s,a){this.objects=s,this.root=a}async append(s,a){if(s<=this.lastKey)throw new Error("PDF structure IDs must be appended in increasing order.");this.lastKey=s,this.entries.push({key:s,value:a}),this.entries.length===64&&await this.leaf()}async leaf(){if(!this.entries.length)return;const s=this.objects.reserve(),a=this.entries[0].key,c=this.entries.at(-1).key,i="<< /Limits [("+a+") ("+c+")] /Names ["+this.entries.map(r=>"("+r.key+") "+r.value+" 0 R").join(" ")+"] >>";this.entries.length=0,await this.objects.object(s,i),await this.node({id:s,first:a,last:c},0)}async node(s,a){const c=this.levels[a]??=[];if(c.push(s),c.length===64){const i=await this.branch(c);c.length=0,await this.node(i,a+1)}}async branch(s){const a=this.objects.reserve(),c=s[0].first,i=s.at(-1).last;return await this.objects.object(a,"<< /Limits [("+c+") ("+i+")] /Kids ["+s.map(r=>r.id+" 0 R").join(" ")+"] >>"),{id:a,first:c,last:i}}async finish(){await this.leaf();for(let a=0;a<this.levels.length-1;a++){const c=this.levels[a];if(c.length){const i=await this.branch(c);c.length=0,await this.node(i,a+1)}}const s=this.levels.at(-1)??[];await this.objects.object(this.root,s.length?"<< /Kids ["+s.map(a=>a.id+" 0 R").join(" ")+"] >>":"<< /Names [] >>")}}class x{objects;settings;root;document;parentTree;elements=new Map;parentTreeWriter;annotations=[];links=new WeakMap;identifiers;pageParents=[];pageId=0;pageKey=0;nextParentKey=0;references=0;allocated=0;section;constructor(s,a){this.objects=s,this.settings=a,this.root=s.reserve(),this.parentTree=s.reserve(),this.parentTreeWriter=new k(s,this.parentTree),this.document=this.element("Document",this.root)}element(s,a=this.section??this.document,c=""){if(O(this.settings.options.signal),++this.allocated>this.settings.limits.maxStructureElements)throw new S("RESOURCE_LIMIT","maxStructureElements exceeded.");const i=this.objects.reserve(),r={id:i,parent:a,role:s,children:[],attributes:c};this.elements.set(i,r);const n=this.elements.get(a);return s==="Caption"&&n?.role==="Table"?n.children.unshift(i):n?.children.push(i),i}setAttributes(s,a){const c=this.elements.get(s);if(!c)throw new Error("PDF structure attributes require an open logical owner.");c.attributes=a}async attributeReference(s){O(this.settings.options.signal);const a=this.objects.reserve();return await this.objects.object(a,s)," /A "+a+" 0 R"}async beginSection(){await this.complete(this.section),this.section=this.element("Sect",this.document)}async identifier(s){O(this.settings.options.signal);const a=this.elements.get(s);if(!a)throw new Error("PDF structure IDs require an open logical owner.");if(a.identifier!==void 0)return a.identifier;const c="e"+String(s).padStart(16,"0");return this.identifiers??=new b(this.objects,this.objects.reserve()),await this.identifiers.append(c,s),a.identifier=c,c}beginPage(s){this.pageId=s,this.pageParents=[],this.pageKey=this.nextParentKey++}link(s,a,c){let i=this.links.get(a);i||(i=new Map,this.links.set(a,i));const r=i.get(s);if(r!==void 0)return r;const n=this.element("Link",s,c===void 0?"":" /Alt <feff"+P(c)+">");i.set(s,n);const e=this.elements.get(s);return(e.linkIdentities??=[]).push(a),n}annotation(s,a){O(this.settings.options.signal);const c=this.elements.get(s);if(!c||c.role!=="Link")throw new Error("Tagged link annotations require a logical Link owner.");const i=this.nextParentKey++;return c.children.push("<< /Type /OBJR /Obj "+a+" 0 R /Pg "+this.pageId+" 0 R >>"),this.annotations.push({key:i,owner:s}),i}mark(s,a){if(++this.references>this.settings.limits.maxMarkedContentReferences)throw new S("RESOURCE_LIMIT","maxMarkedContentReferences exceeded.");const c=this.elements.get(s);if(!c)throw new Error("Marked content requires an open logical owner.");const i=this.pageParents.length;return this.pageParents.push(s),c.markedPage??=this.pageId,c.children.push(c.markedPage===this.pageId?-(i+1):"<< /Type /MCR /Pg "+this.pageId+" 0 R /MCID "+i+" >>"),"/"+c.role+" << /MCID "+i+(a===void 0?"":" /ActualText <FEFF"+P(a)+">")+" >> BDC\n"}get pageDictionary(){return" /StructParents "+this.pageKey+" /Tabs /S"}get catalogDictionary(){return" /MarkInfo << /Marked true >> /Lang <feff"+P(this.settings.options.tagged.language)+"> /StructTreeRoot "+this.root+" 0 R"}async finishPage(){const s=this.objects.reserve();await this.objects.object(s,"["+this.pageParents.map(a=>a+" 0 R").join(" ")+"]"),await this.parentTreeWriter.append(this.pageKey,s);for(const a of this.annotations)await this.parentTreeWriter.append(a.key,a.owner);this.annotations.length=0,this.pageParents=[]}async complete(s){if(s===void 0)return;const a=this.elements.get(s);if(!a)return;for(const r of a.children)typeof r=="number"&&r>0&&!this.completeBuffered(r)&&await this.complete(r);O(this.settings.options.signal);const c=y(a),i=m(a,c);i!==void 0?this.objects.tryCompactObject(s,i)||await this.objects.compactObject(s,i):await this.objects.object(s,this.body(a,c)),this.releaseElement(a)}completeBuffered(s){const a=this.elements.get(s);if(!a)return!0;for(const i of a.children)if(typeof i=="number"&&i>0&&!this.completeBuffered(i))return!1;O(this.settings.options.signal);const c=m(a,y(a));return c===void 0||!this.objects.tryCompactObject(s,c)?!1:(this.releaseElement(a),!0)}releaseElement(s){if(s.linkIdentities)for(const a of s.linkIdentities){const c=this.links.get(a);c?.delete(s.id),c?.size||this.links.delete(a)}this.elements.delete(s.id)}*body(s,a){yield a;for(const c of s.children)yield C(c);yield"]"+s.attributes+" >>"}async completeRow(s){s?.length&&await this.complete(this.elements.get(s[0])?.parent)}async finish(){await this.complete(this.document),await this.parentTreeWriter.finish(),await this.identifiers?.finish(),await this.objects.object(this.root,"<< /Type /StructTreeRoot /K ["+this.document+" 0 R] /ParentTree "+this.parentTree+" 0 R /ParentTreeNextKey "+this.nextParentKey+(this.identifiers?" /IDTree "+this.identifiers.root+" 0 R":"")+" >>")}}function p(o,s){const a=o.decorative,c=o.alternativeText;if(a!==void 0&&typeof a!="boolean")throw new TypeError("Graphic decorative must be boolean.");if(c!==void 0){if(typeof c!="string"||!c.trim())throw new TypeError("Graphic alternativeText must be nonempty text.");if(c.length>s.limits.maxCellCharacters)throw new S("RESOURCE_LIMIT","maxCellCharacters exceeded by graphic alternativeText.");if(P(c),a)throw new TypeError("A decorative graphic cannot also have alternativeText.")}if(s.options.tagged&&c===void 0&&a!==!0)throw new TypeError("Tagged PDF graphics require alternativeText or decorative:true.");return s.options.tagged&&c!==void 0&&s.budget.cell(c),c}return Object.freeze({PdfStructure:x,graphicAlternative:p})})(),ur=(()=>{const{OfficeIMOError:S}=me,{checkAbort:O}=be,{pdfNumber:P,unicodeHex:k}=Be;class C{objects;settings;root;items=[];top=[];stack=[];constructor(b,x){this.objects=b,this.settings=x}add(b,x,p){if(O(this.settings.options.signal),this.items.length>=this.settings.limits.maxBookmarks)throw new S("RESOURCE_LIMIT","maxBookmarks exceeded.");this.root??=this.objects.reserve();const u=b.level??1;for(;this.stack.length&&this.stack.at(-1).level>=u;)this.stack.pop();const o=this.stack.at(-1),s=o?.children??this.top,a=s.at(-1),c={id:this.objects.reserve(),title:b.title,page:x,y:p,level:u,parent:o?.id??this.root,children:[],previous:a?.id,next:void 0};a&&(a.next=c.id),s.push(c),this.items.push(c),this.stack.push(c)}get count(){return this.items.length}closeGroup(b){for(;this.stack.length&&this.stack.at(-1).level>=b;)this.stack.pop()}get catalogDictionary(){return this.root===void 0?"":" /Outlines "+this.root+" 0 R"}async finish(){if(this.root===void 0)return;const b=new Map;for(const x of[...this.items].reverse())b.set(x.id,x.children.reduce((p,u)=>p+1+b.get(u.id),0));for(const x of this.items)O(this.settings.options.signal),await this.objects.object(x.id,"<< /Title <feff"+k(x.title)+"> /Parent "+x.parent+" 0 R"+(x.previous===void 0?"":" /Prev "+x.previous+" 0 R")+(x.next===void 0?"":" /Next "+x.next+" 0 R")+(x.children.length?" /First "+x.children[0].id+" 0 R /Last "+x.children.at(-1).id+" 0 R /Count "+b.get(x.id):"")+" /Dest ["+x.page+" 0 R /XYZ null "+P(x.y)+" null] >>");await this.objects.object(this.root,"<< /Type /Outlines /First "+this.top[0].id+" 0 R /Last "+this.top.at(-1).id+" 0 R /Count "+this.items.length+" >>")}}return Object.freeze({PdfOutlines:C})})(),_t=(()=>{const{PdfObjects:S,unicodeHex:O}=Be,{PdfFontResources:P}=sr,{PdfTableLayout:k}=bt,{PdfPages:C}=dr,{PdfStructure:y}=zt,{PdfOutlines:m}=ur;class b{settings;objects;fonts;pages;layout;structure;outlines;root;parent;resources;info;constructor(u,o,s=!1){this.settings=o,this.objects=new S(u,o.options.signal,o.budget.limits.maxOutputBytes,o.options.compression!==!1),this.root=this.objects.reserve(),this.parent=this.objects.reserve(),this.resources=this.objects.reserve(),this.info=this.objects.reserve(),this.structure=o.options.tagged?new y(this.objects,o):void 0,this.outlines=new m(this.objects,o),this.fonts=new P(this.objects,o.options.fonts,o.limits.maxFontBytes,o.options.signal),this.layout=s?new k(o,this.fonts):void 0,this.pages=new C(this.objects,o,this.fonts,this.parent,this.resources,this.layout,this.structure,this.outlines)}async start(){await this.objects.text("%PDF-1.7\n"),await this.objects.raw(Uint8Array.of(37,226,227,207,211,10)),this.layout?.bands?await this.pages.beginTable(this.layout):this.layout&&await this.pages.start(!0)}async finish(){const{options:u}=this.settings,{objects:o,fonts:s,pages:a}=this;await a.finish();for(const c of s.resources)await c.write(o,u.compression!==!1);await o.object(this.resources,"<< /Font "+s.dictionary()+a.xobjects()+" >>"),await o.object(this.parent,"<< /Type /Pages /Count "+a.references.length+" /Kids ["+a.references.map(c=>c+" 0 R").join(" ")+"] >>"),this.structure&&await this.structure.finish(),await this.outlines.finish(),await o.object(this.root,"<< /Type /Catalog /Pages "+this.parent+" 0 R"+(this.structure?.catalogDictionary??"")+this.outlines.catalogDictionary+" >>"),await o.object(this.info,"<< /Producer (OfficeIMO.js)"+(u.title===void 0?"":" /Title <feff"+O(u.title)+">")+" >>"),await o.finish(this.root,this.info)}}return Object.freeze({PdfWriteSession:b})})(),Bt=(()=>{const{BlobByteSink:S,withDestination:O}=Ie,{beginTask:P,checkAbort:k,consumeRows:C,pause:y,taskYieldDue:m}=be,{notifyProgress:b}=Ge,{createRowProjector:x}=Ne,{settings:p}=Fe,{PdfWriteSession:u}=_t;async function o(c,i){const r=new S;try{return await s(c,r,i),r.toBlob("application/pdf")}catch(n){throw r.discard(),n}}async function s(c,i,r){const n=p(r),{options:e,budget:t}=n;return P(),k(e.signal),O(i,async h=>{const l=new u(h,n,!0),{objects:f,pages:d}=l,g=l.layout,w=x(e.columns,void 0,e.signal);let T=0;await l.start();const v=()=>{if(T++,T%256===0&&(b(e.onProgress,{phase:"rows",rows:T,bytes:f.bytes}),m()))return y().then(()=>{k(e.signal)});k(e.signal)};await C(c,e.signal,async R=>{t.row(T+1);const I=w(R,T);return d.row(await g.data(I,T)).then(v)});const E=await g.footer(T);return E&&(e.footer?.rows?await d.block(E):await d.row(E[0])),g.bands&&await d.endTable(),e.messageBottom&&await d.paragraph(e.messageBottom),await l.finish(),b(e.onProgress,{phase:"complete",rows:T,bytes:f.bytes}),k(e.signal),{rows:T,columns:e.columns.length,bytes:f.bytes}})}return Object.freeze({writePdf:o,writePdfTo:s})})(),pr=(()=>{const{NotSupportedError:S,OfficeIMOError:O}=me,{checkAbort:P,pause:k,taskYieldDue:C,withAbort:y}=be,{Crc32:m}=ut,b=[137,80,78,71,13,10,26,10],x=new Set(["PLTE","tRNS","iCCP","sRGB","gAMA","cHRM","cICP","mDCV","cLLI","sBIT","eXIf","acTL","fcTL","fdAT"]);async function p(r,n,e,t){P(e);const h=a(r,n),l=h.width*h.height,f=r.length+l*h.components+(h.components===4?h.width*8:0);if(t!==void 0&&f>t)throw new O("RESOURCE_LIMIT","maxImageWorkingBytes exceeded by PNG source, image planes and scanlines.");const d=new Uint8Array(r),g=await s(d,h,e);P(e);let w;try{if(typeof DecompressionStream!="function")throw new TypeError("Missing DecompressionStream");w=new DecompressionStream("deflate")}catch(X){throw new O("PLATFORM_UNAVAILABLE",'PNG intake requires native DecompressionStream("deflate").',{cause:X})}const{width:T,height:v,components:E}=g,R=T*E,I=(R+1)*v;if(!Number.isSafeInteger(I)||I>2147483647)throw new O("RESOURCE_LIMIT","PNG filtered data exceeds the supported decoded byte length.");const z=new Uint8Array(T*v*3),j=E===4?new Uint8Array(l):void 0;let M=E===4?new Uint8Array(R):void 0,L=E===4?new Uint8Array(R):void 0;const B=u(d,g,e).pipeThrough(w).getReader();let q=0,G=0,_=0,F=0,W=0,U=0;try{for(;;){const X=await y(B.read(),e).catch(V=>{throw P(e),new TypeError("Invalid PNG zlib image data.",{cause:V})});if(P(e),X.done)break;if(X.value.length>I-q)throw new TypeError("PNG inflated bytes exceed the exact IHDR scanline length.");for(let V=0;V<X.value.length;V++){const Y=X.value[V];if(W===0){if(U=Y,U>4)throw new TypeError("Invalid PNG scanline filter.")}else{const re=W-1;let A=Y;if(U!==0){const $=W>E?L?L[re-E]:z[G-E]:0,J=M?M[re]:G>=R?z[G-R]:0,te=W>E?M?M[re-E]:G>=R?z[G-R-E]:0:0;A=Y+(U===1?$:U===2?J:U===3?Math.floor(($+J)/2):c($,J,te))&255}L?L[re]=A:z[G]=A,G++}if(W===R){if(W=0,L&&j){for(let A=0;A<R;A+=4)z[_++]=L[A],z[_++]=L[A+1],z[_++]=L[A+2],j[F++]=L[A+3],(A&16383)===16380&&(C()&&await k(),P(e));const re=L;L=M,M=re}}else W++;(V&16383)===16383&&(C()&&await k(),P(e))}q+=X.value.length,C()&&await k(),P(e)}if(q!==I)throw new TypeError("PNG inflated bytes must match the exact IHDR scanline length.");return await o(d,g,I,e),{width:T,height:v,components:3,data:z,...j?{alpha:j}:{}}}catch(X){throw B.cancel(X).catch(()=>{}),X}finally{B.releaseLock()}}function u(r,n,e,t=!1){const h=new DataView(r.buffer,r.byteOffset,r.byteLength);let l=n.firstData,f=l+8,d=f+h.getUint32(l);return new ReadableStream({pull(g){for(P(e);f===d;){if(l=d+4,l===n.dataEnd){g.close();return}f=l+8,d=f+h.getUint32(l)}if(t&&f===n.lastDataByte){g.enqueue(Uint8Array.of(r[f++]^1));return}const w=Math.min(d,f+4096,t&&f<n.lastDataByte?n.lastDataByte:d);g.enqueue(r.subarray(f,w)),f=w}},{highWaterMark:0})}async function o(r,n,e,t){const h=u(r,n,t,!0).pipeThrough(new DecompressionStream("deflate")).getReader();let l=!1,f=0;try{for(;;){let d;try{d=await y(h.read(),t)}catch{P(t),l=!0;break}if(P(t),d.done)break;if(f+=d.value.length,f>e)throw new TypeError("Invalid PNG zlib image data.");C()&&await k(),P(t)}if(!l)throw new TypeError("Invalid PNG zlib image data: trailing bytes after the checksum.")}finally{h.cancel().catch(()=>{}),h.releaseLock()}}async function s(r,n,e){const t=new DataView(r.buffer,r.byteOffset,r.byteLength);let h=0,l=0,f=-1,d=!1;for(let g=8;g<r.length;){if(P(e),g+12>r.length)throw new TypeError("Truncated PNG chunk.");const w=t.getUint32(g),T=g+12+w;if(w>2147483647||T>r.length)throw new TypeError("Truncated or oversized PNG chunk.");const v=String.fromCharCode(...r.subarray(g+4,g+8));if(!/^[A-Za-z]{2}[A-Z][A-Za-z]$/.test(v))throw new TypeError("Invalid PNG chunk type.");const E=new m;for(let R=g+4;R<T-4;R+=65536)E.update(r.subarray(R,Math.min(T-4,R+65536))),C()&&await k(),P(e);if(E.value!==t.getUint32(T-4))throw new TypeError("PNG chunk CRC mismatch: "+v+".");if(g===8&&v!=="IHDR")throw new TypeError("PNG IHDR must be the first chunk.");if(v==="IHDR"){if(g!==8||w!==13)throw new TypeError("PNG requires one 13-byte IHDR first.")}else if(v==="IDAT"){if(d)throw new TypeError("PNG IDAT chunks must be consecutive.");h||=g,l=T,w&&(f=T-5)}else{if(h&&(d=!0),v==="IEND"){if(w!==0||!h||T!==r.length)throw new TypeError("PNG requires a final empty IEND after IDAT.");return{...n,firstData:h,dataEnd:l,lastDataByte:f}}if(x.has(v))throw new S("PNG chunk "+v+"; normalize color, orientation, transparency or animation first");if((r[g+4]&32)===0)throw new S("Required PNG chunk "+v)}g=T}throw new TypeError("PNG requires a complete final IEND chunk.")}function a(r,n){if(r.length<33||b.some((f,d)=>r[d]!==f))throw new TypeError("Invalid PNG signature or truncated IHDR.");const e=new DataView(r.buffer,r.byteOffset,r.byteLength);if(e.getUint32(8)!==13||String.fromCharCode(...r.subarray(12,16))!=="IHDR")throw new TypeError("PNG requires one 13-byte IHDR first.");const t=e.getUint32(16),h=e.getUint32(20);if(!t||!h||t>2147483647||h>2147483647)throw new TypeError("Invalid PNG dimensions.");if(!Number.isSafeInteger(t*h)||t*h>n)throw new O("RESOURCE_LIMIT","PNG dimensions exceed maxImagePixels.");if(r[24]!==8||![2,6].includes(r[25]))throw new S("PNG intake requires 8-bit RGB or RGBA pixels");if(r[26]!==0||r[27]!==0)throw new S("PNG compression or filter method");if(r[28]!==0)throw new S("Interlaced PNG intake");const l=r[25]===6?4:3;if(!Number.isSafeInteger((t*l+1)*h)||(t*l+1)*h>2147483647)throw new O("RESOURCE_LIMIT","PNG filtered data exceeds the supported decoded byte length.");return{width:t,height:h,components:l}}function c(r,n,e){const t=r+n-e,h=Math.abs(t-r),l=Math.abs(t-n),f=Math.abs(t-e);return h<=l&&h<=f?r:l<=f?n:e}return Object.freeze({pngPixels:p})})(),mr=(()=>{const{NotSupportedError:S,OfficeIMOError:O}=me,{checkAbort:P,pause:k,taskYieldDue:C}=be,{pngPixels:y}=pr;class m{objects;settings;images=new Map;bytes=0;constructor(u,o){this.objects=u,this.settings=o}async prepare(u){const o=this.images.get(u);if(o)return o;const{limits:s,options:a}=this.settings;if(!u||typeof u!="object")throw new TypeError("PDF images require a byte array.");const c=u.data,i=u.format;if(!(c instanceof Uint8Array))throw new TypeError("PDF images require a byte array.");const r=c.length;if(this.bytes+r>s.maxImageBytes)throw new O("RESOURCE_LIMIT","maxImageBytes exceeded.");let n,e,t,h,l;const f=s.maxImageWorkingBytes;if(i==="png")({width:n,height:e,components:t,data:h,alpha:l}=await y(c,s.maxImagePixels,a.signal,f));else if(i==="jpeg")({width:n,height:e,components:t}=b(c));else if(i==="rgb"||i==="rgba")({width:n,height:e}=u),t=i==="rgba"?4:3;else throw new S("PDF images support unprofiled PNG/JPEG or decoded RGB/RGBA pixels.");if(!Number.isSafeInteger(n)||!Number.isSafeInteger(e)||n<1||e<1||!Number.isSafeInteger(n*e)||n*e>s.maxImagePixels)throw new O("RESOURCE_LIMIT","Image dimensions must be positive integers within maxImagePixels.");if((i==="rgb"||i==="rgba")&&r!==n*e*t)throw new RangeError("Raw image bytes must match width × height × channels exactly.");if(i!=="png"&&f!==void 0&&r+(t===4?n*e:0)>f)throw new O("RESOURCE_LIMIT","maxImageWorkingBytes exceeded by image snapshot and alpha plane.");P(a.signal);const d=this.objects.reserve(),g="Image"+(this.images.size+1);this.bytes+=r;const w=h??new Uint8Array(c);let T=w,v=l,E;if(t===4){T=w.subarray(0,n*e*3),v=new Uint8Array(n*e);for(let z=0;z<v.length;z++)T[z*3]=w[z*4],T[z*3+1]=w[z*4+1],T[z*3+2]=w[z*4+2],v[z]=w[z*4+3],(z&16383)===16383&&(C()&&await k(),P(a.signal))}v&&(E=this.objects.reserve(),await this.objects.stream(E,v,"/Type /XObject /Subtype /Image /Width "+n+" /Height "+e+" /ColorSpace /DeviceGray /BitsPerComponent 8",a.compression!==!1,!0));const R="/Type /XObject /Subtype /Image /Width "+n+" /Height "+e+" /ColorSpace /"+(t===1?"DeviceGray":"DeviceRGB")+" /BitsPerComponent 8"+(E?" /SMask "+E+" 0 R":"")+(i==="jpeg"?" /Filter /DCTDecode":"");await this.objects.stream(d,T,R,i==="jpeg"?!1:a.compression!==!1,!0);const I={name:g,id:d,width:n,height:e};return this.images.set(u,I),I}}function b(p){if(p.length<4||p[0]!==255||p[1]!==216||p[p.length-2]!==255||p[p.length-1]!==217)throw new TypeError("JPEG images need complete SOI/EOI markers.");let u;for(let o=2;o<p.length;){if(p[o++]!==255)throw new TypeError("Invalid JPEG marker.");for(;p[o]===255;)o++;const s=p[o++];if(s===218){if(!u)throw new TypeError("JPEG scan precedes its frame header.");return u}if(s===217)break;if(o+2>p.length)throw new TypeError("Truncated JPEG segment.");const a=p[o]*256+p[o+1],c=o+a;if(a<2||c>p.length)throw new TypeError("Truncated JPEG segment.");if(s===226&&a>=14&&String.fromCharCode(...p.subarray(o+2,o+14))==="ICC_PROFILE\0")throw new S("Normalize ICC-profiled JPEG colors before PDF embedding.");if(s===225&&a>=8&&String.fromCharCode(...p.subarray(o+2,o+8))==="Exif\0\0")throw new S("Normalize JPEG EXIF orientation before PDF embedding.");if(s>=192&&s<=207&&![196,200,204].includes(s)){if(![192,193,194].includes(s)||a<8||p[o+2]!==8)throw new S("PDF JPEG images require 8-bit baseline, sequential or progressive frames.");const i=p[o+7];if(![1,3].includes(i)||a!==8+i*3)throw new S("PDF JPEG images require grayscale or RGB components; CMYK is unsupported.");if(i===3){const r=[p[o+8],p[o+11],p[o+14]].join(",");if(r!=="1,2,3"&&r!=="82,71,66")throw new S("Unsupported JPEG component color layout.")}if(u)throw new S("Multiple JPEG frame headers are unsupported.");u={width:p[o+5]*256+p[o+6],height:p[o+3]*256+p[o+4],components:i}}o=c}throw new TypeError("JPEG image has no complete frame and scan.")}return Object.freeze({PdfDocumentImages:m})})(),gr=(()=>{const{OfficeIMOError:S}=me,{checkAbort:O,pause:P,taskYieldDue:k}=be,{color:C,positive:y}=Fe,{pdfNumber:m}=Be;async function b(p,u,o){const s=y(p.width,"Vector width"),a=y(p.height,"Vector height"),c=p.commands;if(!Array.isArray(c))throw new TypeError("Vector commands must be an array.");if(o+c.length>u.limits.maxVectorCommands)throw new S("RESOURCE_LIMIT","maxVectorCommands exceeded.");const i=c.map(T=>{if(!T||typeof T!="object")throw new TypeError("Invalid vector command.");const v=T.op;if(v==="move"||v==="line")return{op:v,x:T.x,y:T.y};if(v==="cubic")return{op:v,x1:T.x1,y1:T.y1,x2:T.x2,y2:T.y2,x:T.x,y:T.y};if(v==="close")return{op:v};throw new TypeError("Unsupported vector command.")}),r=p.fill,n=p.stroke,e=r===void 0?void 0:C(r),t=n===void 0?void 0:C(n);if(e===void 0&&t===void 0)throw new TypeError("A vector path requires fill or stroke.");const h=y(p.strokeWidth??1,"Vector stroke width",144),l=p.fillRule;if(l!==void 0&&!["nonzero","evenodd"].includes(l))throw new TypeError("Invalid vector fill rule.");const f=[];let d=0,g=!1;const w=(T,v)=>{if(!Number.isFinite(T)||T<0||T>v)throw new RangeError("Vector coordinates must stay inside their declared bounds.");return m(T)};for(let T=0;T<i.length;T++){const v=i[T];let E;if(!v||typeof v!="object")throw new TypeError("Invalid vector command.");if(v.op==="move"||v.op==="line"){if(v.op==="line"&&!g)throw new TypeError("A vector subpath must begin with move.");E=w(v.x,s)+" "+w(v.y,a)+(v.op==="move"?" m\n":" l\n"),g=!0}else if(v.op==="cubic"){if(!g)throw new TypeError("A vector subpath must begin with move.");E=[w(v.x1,s),w(v.y1,a),w(v.x2,s),w(v.y2,a),w(v.x,s),w(v.y,a)].join(" ")+" c\n"}else if(v.op==="close"){if(!g)throw new TypeError("Cannot close an empty vector path.");E="h\n"}else throw new TypeError("Unsupported vector command.");if(d+=E.length,d>u.limits.maxPageBytes-256)throw new S("RESOURCE_LIMIT","maxPageBytes exceeded by vector commands.");f.push(E),(T&1023)===1023&&(k()&&await P(),O(u.options.signal))}if(!g)throw new TypeError("A vector path needs at least one command.");return{width:s,height:a,count:i.length,content:(e===void 0?"":e+" rg\n")+(t===void 0?"":t+" RG\n"+m(h)+" w\n")+f.join("")+(e!==void 0&&t!==void 0?"B":e!==void 0?"f":"S")+(e!==void 0&&l==="evenodd"?"*":"")+"\n"}}return Object.freeze({vectorCommands:b})})(),wr=(()=>{const{NotSupportedError:S,OfficeIMOError:O}=me,{checkAbort:P,pause:k,taskYieldDue:C}=be,{color:y,positive:m}=Fe,{pdfNumber:b}=Be;function x(r,n,e){if(!r||typeof r!="object"||Array.isArray(r)||Reflect.ownKeys(r).some(t=>typeof t!="string"||!n.includes(t)))throw new TypeError("Unsupported "+e+" properties.");return r}function p(r){x(r,["kind","drawing","alignment","alternativeText","decorative","caption"],"drawing block")}function u(r){if(typeof r!="number"||!Number.isFinite(r)||Math.abs(r)>1e6)throw new RangeError("Drawing coordinates must be finite and within -1,000,000 through 1,000,000 points.");return r}function o(r){const n=x(r,["x","y","width","height"],"drawing clip");return{x:u(n.x),y:u(n.y),width:m(n.width,"Drawing clip width",1e6),height:m(n.height,"Drawing clip height",1e6)}}async function s(r){C()&&await k(),P(r.options.signal)}function a(r,n,e){P(n.options.signal);const t=x(r,["version","width","height","elements"],"drawing");if(t.version!==1)throw new S("Only portable drawing version 1 is supported.");const h=m(t.width,"Drawing width"),l=m(t.height,"Drawing height");let f=e.commands,d=e.elements;const g=new Set;function w(R){x(R,["kind","commands","fill","stroke","strokeWidth","fillRule","lineCap","lineJoin"],"drawing path");const I=R.commands;if(!Array.isArray(I))throw new TypeError("Drawing path commands must be an array.");if(f+I.length>n.limits.maxVectorCommands)throw new O("RESOURCE_LIMIT","maxVectorCommands exceeded.");P(n.options.signal);const z=I.slice(),j=[];let M=!1;f+=z.length;const L=R.fill,B=R.stroke,q=L===void 0?void 0:y(L),G=B===void 0?void 0:y(B);if(q===void 0&&G===void 0)throw new TypeError("A drawing path requires fill or stroke.");const _=m(R.strokeWidth??1,"Drawing stroke width"),F=R.fillRule,W=R.lineCap,U=R.lineJoin;if(F!==void 0&&!["nonzero","evenodd"].includes(F))throw new TypeError("Invalid drawing fillRule.");if(W!==void 0&&!["butt","round","square"].includes(W))throw new TypeError("Invalid drawing lineCap.");if(U!==void 0&&!["miter","round","bevel"].includes(U))throw new TypeError("Invalid drawing lineJoin.");for(let X=0;X<z.length;X++){const V=z[X];if(!V||typeof V!="object")throw new TypeError("Invalid drawing path command.");const Y=V.op;if(Y==="move"||Y==="line"){if(x(V,["op","x","y"],"drawing path command"),Y==="line"&&!M)throw new TypeError("A drawing subpath must begin with move.");j.push({op:Y,x:u(V.x),y:u(V.y)}),M=!0}else if(Y==="cubic"){if(x(V,["op","x1","y1","x2","y2","x","y"],"drawing path command"),!M)throw new TypeError("A drawing subpath must begin with move.");j.push({op:"cubic",x1:u(V.x1),y1:u(V.y1),x2:u(V.x2),y2:u(V.y2),x:u(V.x),y:u(V.y)})}else if(Y==="close"){if(x(V,["op"],"drawing path command"),!M)throw new TypeError("Cannot close an empty drawing path.");j.push({op:"close"})}else throw new TypeError("Unsupported drawing path command.");(X&1023)===1023&&P(n.options.signal)}if(!M)throw new TypeError("A drawing path needs at least one command.");return{kind:"path",commands:j,style:(q===void 0?"":q+" rg\n")+(G===void 0?"":G+" RG\n"+b(_)+" w\n")+String(["butt","round","square"].indexOf(W??"butt"))+" J\n"+String(["miter","round","bevel"].indexOf(U??"miter"))+" j\n10 M\n",paint:(q!==void 0&&G!==void 0?"B":q!==void 0?"f":"S")+(q!==void 0&&F==="evenodd"?"*":"")+"\n"}}function T(R){x(R,["kind","text","x","y","font","fontSize","color"],"drawing text");const I=R.text,z=R.font;if(typeof I!="string")throw new TypeError("Drawing text must be a string.");if(I.length>n.limits.maxCellCharacters)throw new O("RESOURCE_LIMIT","maxCellCharacters exceeded.");if(/[\r\n\u2028\u2029]/.test(I))throw new S("Drawing text must be a single baseline without line breaks.");if(!["regular","bold","italic","boldItalic"].includes(z))throw new TypeError("Invalid drawing font slot.");const j=u(R.x),M=u(R.y),L=m(R.fontSize,"Drawing font size"),B=y(R.color);return n.budget.cell(I),{kind:"text",text:I,x:j,y:M,size:L,color:B,font:z}}function v(R,I){if(!Array.isArray(R))throw new TypeError("Drawing elements must be an array.");if(I>32&&R.length)throw new RangeError("Drawing groups support at most 32 element levels.");if(d+R.length>n.limits.maxDrawingElements)throw new O("RESOURCE_LIMIT","maxDrawingElements exceeded.");P(n.options.signal);const z=R.slice(),j=[];for(let M=0;M<z.length;M++){if(++d>n.limits.maxDrawingElements)throw new O("RESOURCE_LIMIT","maxDrawingElements exceeded.");const L=z[M];if(!L||typeof L!="object")throw new TypeError("Invalid drawing element.");if(g.has(L))throw new TypeError("Drawing groups cannot contain cycles.");const B=L.kind;if(B==="path")j.push(w(L));else if(B==="text")j.push(T(L));else if(B==="group"){x(L,["kind","clip","elements"],"drawing group");const q=L.clip,G=q===void 0?void 0:o(q);g.add(L),j.push({kind:"group",...G?{clip:G}:{},children:v(L.elements,I+1)}),g.delete(L)}else throw new TypeError("Unsupported drawing element kind.");(M&255)===255&&P(n.options.signal)}return j}const E=v(t.elements,1);return P(n.options.signal),{width:h,height:l,plan:E,commands:f-e.commands,elements:d-e.elements}}async function c(r,n,e,t){const h=a(r,n,t),l=new Map;function f(M){const L=l.get(M);if(L)return L;const B=e.select(M==="bold"||M==="boldItalic",M==="italic"||M==="boldItalic");if(!B.program||B.syntheticBold||B.syntheticItalic)throw new S("Drawing text without an exact embedded font face at fonts."+M);return l.set(M,B),B}let d=0,g=0;async function w(M){for(let L=0;L<M.length;L++){const B=M[L];if(B.kind==="group")await w(B.children);else if(B.kind==="text"){const q=f(B.font);for(const G of B.text)q.width(G.codePointAt(0)),(++d&1023)===0&&await s(n)}(++g&255)===0&&await s(n)}}await w(h.plan);const T=[];let v=0;function E(M){if(v+=M.length,v>n.limits.maxPageBytes-256)throw new O("RESOURCE_LIMIT","maxPageBytes exceeded by drawing content.");T.push(M)}let R=0,I=0,z=0;async function j(M){for(let L=0;L<M.length;L++){const B=M[L];if(E("q\n"),B.kind==="group")B.clip&&E([B.clip.x,B.clip.y,B.clip.width,B.clip.height].map(b).join(" ")+" re W n\n"),await j(B.children);else if(B.kind==="path"){E(B.style);for(let q=0;q<B.commands.length;q++){const G=B.commands[q];E(G.op==="move"||G.op==="line"?b(G.x)+" "+b(G.y)+(G.op==="move"?" m\n":" l\n"):G.op==="cubic"?[G.x1,G.y1,G.x2,G.y2,G.x,G.y].map(b).join(" ")+" c\n":"h\n"),(++I&1023)===0&&await s(n)}E(B.paint)}else{const q=f(B.font);E(B.color+" rg\nBT /"+q.name+" "+b(B.size)+" Tf 0 Tr 1 0 0 -1 "+b(B.x)+" "+b(B.y)+" Tm <");let G="";for(const _ of B.text)G+=_,(++R&1023)===0&&(E(q.encode(G).slice(1,-1)),G="",await s(n));G&&E(q.encode(G).slice(1,-1)),E("> Tj ET\n")}E("Q\n"),(++z&255)===0&&await s(n)}}return await j(h.plan),P(n.options.signal),{width:h.width,height:h.height,content:T.join(""),commands:h.commands,elements:h.elements}}return Object.freeze({checkDrawingBlock:p,prepareDrawing:c})})(),Tt=(()=>{const{OfficeIMOError:S}=me,{capturePdfText:O,wrapPdfText:P}=lt,{positive:k}=Fe,{resolveParagraphStyle:C}=yt,{captureBookmark:y}=xt,{captureFields:m}=Ce,{pdfBudgetText:b}=Qe;function x(c,i,r,n=!1){if(!c||c.kind!=="paragraph")throw new TypeError("PDF paragraph groups accept paragraph blocks only.");const{text:e,headingLevel:t,presentation:h,fontSize:l,keepTogether:f,keepWithNext:d,spaceBefore:g,spaceAfter:w,style:T,bookmark:v}=c;if(t!==void 0&&(!Number.isInteger(t)||t<1||t>6))throw new TypeError("Paragraph headingLevel must be an integer from 1 through 6.");const E=C(T,{...l===void 0?{}:{fontSize:l},...h===void 0?{}:{presentation:h},...f===void 0?{}:{keepTogether:f},...d===void 0?{}:{keepWithNext:d},...g===void 0?{}:{spaceBefore:g},...w===void 0?{}:{spaceAfter:w}},i.paragraphStyles),R=E.presentation??Object.freeze({}),I=k(E.fontSize??i.fontSize,"Paragraph font size",144),z=y(v,i);return Object.freeze({text:O(e,R,i,r,!1,!n),style:R,size:I,...n?{budgetOnPaint:!0}:{},...t===void 0?{}:{headingLevel:t},...z===void 0?{}:{bookmark:z},keepTogether:E.keepTogether??!1,keepWithNext:E.keepWithNext??!1,spaceBefore:E.spaceBefore??0,spaceAfter:E.spaceAfter??8})}function p(c,i,r){if(!c||typeof c!="object"||Array.isArray(c)||Object.keys(c).some(n=>!["text","style","fontSize","presentation","spaceBefore","spaceAfter"].includes(n)))throw new TypeError("PDF captions support text, style, fontSize, presentation, spaceBefore and spaceAfter.");return x({...m(c,["text","style","fontSize","presentation","spaceBefore","spaceAfter"]),kind:"paragraph",keepTogether:!0,keepWithNext:!0},i,r,!0)}async function u(c,i,r,n=i.page.width-i.margins.left-i.margins.right){if(!c.text.text)return{...c,lines:[],height:0,firstHeight:0};if(!c.budgetOnPaint){const t=b(c.text.text,i.budget);i.budget.cell(t,t.length)}const e=await P(c.text,r,c.size,k(n,"Paragraph width"),i);return{...c,lines:e,height:c.spaceBefore+e.reduce((t,h)=>t+h.lineHeight,0)+c.spaceAfter,firstHeight:c.spaceBefore+e[0].lineHeight}}function o(c,i){if(c.length>i.limits.maxGroupBlocks)throw new S("RESOURCE_LIMIT","maxGroupBlocks exceeded.");let r=0,n=0;for(const e of c){if(r+=e.text.text.length,n+=e.text.runs.length,r>i.limits.maxCellCharacters)throw new S("RESOURCE_LIMIT","maxCellCharacters exceeded by a paragraph group or keep chain.");if(n>i.limits.maxTextRuns)throw new S("RESOURCE_LIMIT","maxTextRuns exceeded by a paragraph group or keep chain.")}}function s(c){const i=c.filter(n=>n.lines.length>0);let r=0;for(let n=i.length-1;n>=0;n--){const e=i[n];r=e.keepWithNext?e.height+r:e.keepTogether?e.height:e.firstHeight}return r}return Object.freeze({captureParagraph:x,captureCaption:p,prepareParagraph:u,checkParagraphBuffer:o,paragraphStartHeight:s})})(),yr=(()=>{const{capturePdfText:S,wrapPdfText:O}=lt,{captureParagraph:P,prepareParagraph:k}=Tt,{resolveParagraphStyle:C}=yt;function y(x,p){const{items:u,ordered:o=!1,start:s,itemStyle:a,indent:c,markerGap:i}=x,r=s===void 0?1:s;if(typeof o!="boolean")throw new TypeError("PDF list ordered must be boolean.");if(!Number.isSafeInteger(r)||r<1)throw new RangeError("PDF list start must be a positive safe integer.");if(!o&&s!==void 0)throw new TypeError("PDF list start requires ordered:true.");for(const[n,e]of[["indent",c],["markerGap",i]])if(e!==void 0&&(!Number.isFinite(e)||e<0||e>14400))throw new RangeError("PDF list "+n+" must be from zero through 14,400 points.");if(C(a,{},p.paragraphStyles).keepWithNext)throw new TypeError("PDF list item styles cannot use keepWithNext.");return Object.freeze({items:u,ordered:o,start:r,...a===void 0?{}:{itemStyle:a},...c===void 0?{}:{indent:c},...i===void 0?{}:{markerGap:i}})}async function m(x,p,u,o,s){if(!x||typeof x!="object"||Array.isArray(x)||Object.keys(x).some(v=>!["text","style","keepTogether"].includes(v)))throw new TypeError("PDF list items support text, style and keepTogether.");if(!Number.isSafeInteger(p)||p<0||!Number.isSafeInteger(u.start+p))throw new RangeError("PDF list numbering must remain within positive safe integers.");const{text:a,style:c=u.itemStyle,keepTogether:i}=x,r=P({kind:"paragraph",text:a,...c===void 0?{}:{style:c},...i===void 0?{}:{keepTogether:i}},o,s);if(r.keepWithNext)throw new TypeError("PDF list item styles cannot use keepWithNext.");if(!r.text.text.trim().length)throw new TypeError("PDF list items require nonempty text.");const n=u.ordered?String(u.start+p)+".":"•",e=S(n,r.style,o,s);o.budget.cell(n,n.length);const t=o.page.width-o.margins.left-o.margins.right,h=(await O(e,s,r.size,t,o,!1))[0],l=u.markerGap??r.size/2,f=u.indent??Math.max(r.size*2,h.width+l);if(h.width+l>f+.001)throw new RangeError("PDF list indent cannot fit its marker and gap.");if(f>=t)throw new RangeError("PDF list indent leaves no body text area.");const d=await k(r,o,s,t-f),g=d.lines[0],w=Math.max(g.lineHeight,h.lineHeight),T=Math.max(g.ascent,h.ascent);return{marker:h,indent:f,markerGap:l,paragraph:{...d,lines:[{...g,lineHeight:w,ascent:T},...d.lines.slice(1)],height:d.height+w-g.lineHeight,firstHeight:d.spaceBefore+w}}}return Object.freeze({captureListOptions:y,prepareListItem:m})})(),Et=(()=>{const{assertGroupedReportSource:S}=Ue,{captureFields:O}=Ce,{captureWideTable:P}=Fe,{presentation:k}=Ze,C=["labelColumn","subtotalLabel","grandTotalLabel","includeGrandTotal","continuationLabel","groupHeadingLevel"],y=["includeHeader","headerPresentation","footerPresentation","alternateRowColor","columnWidths","wideTable","formatValue","formatRuns",...C];function m(p,u){return S(p),Object.freeze({kind:"groupedTable",report:p,options:b(u)})}function b(p){if(!p||typeof p!="object"||Array.isArray(p)||Object.keys(p).some(t=>!y.includes(t)))throw new TypeError("Grouped PDF table options support table presentation and labels; document settings belong on writePdfDocument.");const u=O(p,y),{labelColumn:o,subtotalLabel:s,grandTotalLabel:a,includeGrandTotal:c,continuationLabel:i,groupHeadingLevel:r}=u;if(!o||typeof o!="object")throw new TypeError("Grouped PDF needs a leading labelColumn.");const{header:n,width:e}=o;if(typeof n!="string")throw new TypeError("The grouped label column header must be text.");for(const[t,h]of[["subtotalLabel",s],["grandTotalLabel",a]])if(typeof h!="function")throw new TypeError(t+" must be a synchronous text callback.");if(i!==void 0&&typeof i!="function")throw new TypeError("continuationLabel must be a synchronous text callback.");if(c!==void 0&&typeof c!="boolean")throw new TypeError("includeGrandTotal must be boolean.");if(r!==void 0&&(!Number.isInteger(r)||r<1||r>6))throw new TypeError("groupHeadingLevel must be an integer from 1 through 6.");return Object.freeze({...u,...u.wideTable===void 0?{}:{wideTable:P(u.wideTable)},labelColumn:Object.freeze({header:n,...e===void 0?{}:{width:e}}),...u.columnWidths===void 0?{}:{columnWidths:Object.freeze([...u.columnWidths])},...u.headerPresentation===void 0?{}:{headerPresentation:k(u.headerPresentation)},...u.footerPresentation===void 0?{}:{footerPresentation:k(u.footerPresentation)}})}return Object.freeze({groupedPdfLabelFields:C,groupedPdfTableFields:y,pdfGroupedTable:m,captureGroupedPdfTableOptions:b})})(),br=(()=>{const{assertGroupedReportSource:S,groupedReportOperation:O}=Ue,{consumeRows:P}=be,{ExportCell:k}=ve,{captureGroupedPdfTableOptions:C}=Et,{settings:y}=Fe,{PdfTableLayout:m}=bt,{captureCaption:b,captureParagraph:x,prepareParagraph:p}=Tt,{synchronousText:u}=Qe;async function o(a,c){const{report:i}=a,{pages:r,fonts:n,prepared:e,controller:t}=c;S(i);const h=e.options.tagged!==void 0,l=C(a.options),{labelColumn:f,subtotalLabel:d,grandTotalLabel:g,includeGrandTotal:w=!0,continuationLabel:T,groupHeadingLevel:v=2,...E}=l,R=Object.freeze([Object.freeze({...f}),...i.columns]);let I=-1;const z=G=>({rowIndex:I,columnIndex:G.columnIndex-1,column:i.columns[G.columnIndex-1]}),j=y({...r.settings.options,...E,columns:R,includeHeader:E.includeHeader??!0,...E.formatValue===void 0?{}:{formatValue:(G,_)=>E.formatValue(G,z(_))},...E.formatRuns===void 0?{}:{formatRuns:(G,_)=>E.formatRuns(G,z(_))}}),M={...j,budget:e.budget},L=new m(M,n);c.acceptColumns(R.length);const B=O(i,t.signal),q=()=>t.abort(B.signal?.reason);B.signal?.addEventListener("abort",q,{once:!0}),B.signal?.aborted&&q();try{const G=await L.headers(),_=await L.blockHeight(G);let F=[],W=!1,U=!1,X=!1,V=0;const Y=new WeakMap;let re;const A=[],$=i.columns.flatMap((N,Q)=>Object.hasOwn(i.totals,N.key)?[Q]:[]),J=(N,Q,ie)=>Object.freeze([new k(N,{text:N,presentation:j.options.footerPresentation}),...(ie?ie.map(ce=>Q[ce]):Q).map(ce=>new k(ce,{presentation:j.options.footerPresentation}))]),te=new Map,he=N=>{const Q=te.get(N);if(Q)return Q;const ie=[0,...$.map(Z=>Z+1)],ce=ie.map(Z=>{const ee=R[Z];if(!N)return ee;const{groups:le,...de}=ee;return de}),ae=Z=>{const ee=ie[Z.columnIndex];return{...Z,columnIndex:ee,column:R[ee]}},ue=ie.flatMap((Z,ee)=>Z===0||j.repeatedColumns.includes(Z)?[ee]:[]),ge=j.options.wideTable,oe={...M,repeatedColumns:Object.freeze(ue),options:{...j.options,columns:ce,...j.options.columnWidths===void 0?{}:{columnWidths:ie.map(Z=>j.options.columnWidths[Z])},...typeof ge!="object"?{}:{wideTable:{...ge,repeatColumns:ue}},...j.options.formatValue===void 0?{}:{formatValue:(Z,ee)=>j.options.formatValue(Z,ae(ee))},...j.options.formatRuns===void 0?{}:{formatRuns:(Z,ee)=>j.options.formatRuns(Z,ae(ee))}}},K=new m(oe,n);return te.set(N,K),K},se=async()=>{const N=await p(b({text:F.map(ie=>ie.label).join("\n"),presentation:{bold:!0},spaceAfter:4},r.settings,n),r.settings,n),Q=await p(b({text:F.map(ie=>{if(T===void 0)return ie.label;const ce=h?Y.get(ie):void 0;if(ce!==void 0)return ce;const ae=u(T(ie),"continuationLabel");return h&&Y.set(ie,ae),ae}).join("\n"),presentation:{bold:!0},spaceAfter:4},r.settings,n),r.settings,n);return{caption:N,continuation:Q}},ne=async()=>{if(re)if(W||await ye(re),A.length&&!X)await r.keptRows([re,...A],U);else if(A.length){await r.row(re,U);for(const N of A)await r.row(N)}else await r.row(re,U);else for(const N of A)await r.row(N);re=void 0,A.length=0,U=!1,X=!1},fe=async()=>{!W&&!re||(await ne(),await r.endTable(),W=!1)},ye=async N=>{const{caption:Q,continuation:ie}=await se(),ce=N.height+A.reduce((le,de)=>le+de.height,0),ae=j.page.height-j.margins.top-j.margins.bottom-_-Math.max(Q?.height??0,ie.height);X=A.length>0&&ce>ae+.001;const ue=A.length>0&&!X?ce:L.minimumRowHeight(N),ge=[];if(h)for(const le of F.slice(V))ge.push(await p(x({kind:"paragraph",text:le.label.trim()?le.label:"",headingLevel:v+le.level,presentation:{bold:!0},keepTogether:!0,keepWithNext:!0,spaceAfter:4,...le.label.trim()?{bookmark:{title:le.label,level:v+le.level}}:{}},r.settings,n),r.settings,n));const oe=ge.reduce((le,de)=>le+de.height,0),K=h&&V>0?await p(b({text:F.slice(0,V).map(le=>le.label).join("\n"),presentation:{bold:!0},spaceAfter:4},r.settings,n),r.settings,n):void 0,Z=h?(K?.height??0)+oe:Q.height;await c.flushParagraphs(Z+_+ue),K&&await r.paragraphs([K],oe+_+ue,!0,{artifact:!0});let ee=oe+(h?0:Q.height)+_+ue;for(const le of ge)ee-=le.height,await r.beginGroup(V++,le,ee);await r.beginTable(L,G,ue,Q,ie,!1,h,h),W=!0,U=(Q?.lines.length??0)>0||ge.some(le=>le.lines.length>0)},D=async(N,Q,ie)=>{if(Q===i.groupBy.length-1){r.summary(N),A.push(N),await fe(),await r.endGroup(Q),V=Q,F=F.slice(0,Q);return}await fe();const{caption:ce,continuation:ae}=await se(),ue=he(!1),ge=await ue.headers(),oe=await ue.data(ie,0,!0),K=ue.minimumRowHeight(oe);await c.flushParagraphs(ce.height+await ue.blockHeight(ge)+K),await r.beginTable(ue,ge,K,ce,ae,!1,!0),r.summary(oe),await r.row(oe,ce.lines.length>0||ge.length>0),await r.endTable(),await r.endGroup(Q),V=Q,F=F.slice(0,Q)},H=async N=>{if(await fe(),!w&&N.rows!==0)return;const Q=N.rows===0?L:he(!0),ie=N.rows===0?G:await Q.headers();I=-1;let ce;if(w&&(c.acceptRow(!1),ce=await Q.data(J(u(g(N),"grandTotalLabel"),N.totals,N.rows===0?void 0:$),0,!0)),!ie.length&&!ce)return;const ae=ce?Q.minimumRowHeight(ce):0;await c.flushParagraphs(await Q.blockHeight(ie)+ae),await r.beginTable(Q,ie,ae),ce&&(h&&r.summary(ce),await r.row(ce)),await r.endTable()};await P(B.events,B.signal,async N=>{switch(N.kind){case"groupStart":if(await fe(),h&&v+N.level>6)throw new RangeError("groupHeadingLevel and the opened group depth exceed heading level 6.");F=Object.freeze([...F.slice(0,N.level),N]);break;case"row":{re&&await ne(),I=N.rowIndex,c.acceptRow(!0),re=await L.data([new k("",{text:""}),...N.values],N.rowIndex);break}case"groupEnd":{I=-1,c.acceptRow(!1);const Q=h&&N.level!==i.groupBy.length-1,ie=J(u(d(N),"subtotalLabel"),N.totals,Q?$:void 0),ce=Q?void 0:await L.data(ie,0,!0);h?await D(ce,N.level,ie):A.push(ce);break}case"complete":await H(N);break}})}finally{B.signal?.removeEventListener("abort",q),B.dispose()}}return Object.freeze({renderGroupedPdfTable:o})})(),ct=(()=>{const{BlobByteSink:S,withDestination:O}=Ie,{OfficeIMOError:P}=me,{beginTask:k,checkAbort:C,consumeRows:y,pause:m,taskYieldDue:b}=be,{notifyProgress:x}=Ge,{copyColumns:p,createRowProjector:u}=Ne,{captureFields:o}=Ce,{settings:s,captureWideTable:a}=Fe,{pdfNumber:c}=Be,{PdfTableLayout:i}=bt,{PdfWriteSession:r}=_t,{PdfDocumentImages:n}=mr,{vectorCommands:e}=gr,{graphicAlternative:t}=zt,{checkDrawingBlock:h,prepareDrawing:l}=wr,{captureParagraph:f,captureCaption:d,prepareParagraph:g,checkParagraphBuffer:w,paragraphStartHeight:T}=Tt,{captureListOptions:v,prepareListItem:E}=yr,{captureSection:R}=xt,{renderGroupedPdfTable:I}=br,z=["columns","includeHeader","headerRows","footer","headerPresentation","footerPresentation","alternateRowColor","columnWidths","wideTable","formatValue","formatRuns"];function j(_,F){const W=q(F);return Object.freeze({kind:"table",rows:_,options:Object.freeze({...W,columns:Object.freeze(p(W.columns))})})}async function M(_,F={}){const W=new S;try{return await L(_,W,F),W.toBlob("application/pdf")}catch(U){throw W.discard(),U}}async function L(_,F,W={}){const U=s(W,!0),X=new AbortController,V=U.options.signal,Y=()=>X.abort(V?.reason);V?.addEventListener("abort",Y,{once:!0}),V?.aborted&&Y();const re={...U,options:{...U.options,signal:X.signal}},{options:A,budget:$}=re;try{return k(),C(A.signal),await O(F,async J=>{const te=new r(J,re),{objects:he,pages:se,fonts:ne}=te,fe=new n(he,re);let ye=0,D=0,H=0,N=0,Q=0,ie=0,ce=[];const ae=async(K=0)=>{const Z=[];for(const ee of ce)Z.push(await g(ee,se.settings,ne));ce=[],await se.paragraphs(Z,K)},ue=async K=>{const Z=f(K,se.settings,ne);Z.text.text&&(ce.length||Z.keepWithNext?(ce.push(Z),w(ce,se.settings),Z.keepWithNext||await ae()):await se.paragraphs([await g(Z,se.settings,ne)]))},ge=async K=>K===void 0?void 0:g(K,se.settings,ne),oe=K=>K===void 0?void 0:d(K,se.settings,ne);return await te.start(),await y(_,A.signal,async K=>{if(!K||typeof K!="object")throw new TypeError("PDF document blocks must be objects.");switch(K.kind){case"section":{const Z=R(K,re);await ae();const ee=await se.beginSection(Z);ee.includeHeading?await ue({kind:"paragraph",text:ee.title,headingLevel:ee.level,...ee.headingStyle===void 0?{fontSize:se.settings.fontSize*1.5,presentation:{bold:!0}}:{style:ee.headingStyle},keepTogether:!0,keepWithNext:!0,...ee.bookmark?{bookmark:{title:ee.title,level:ee.level}}:{}}):ee.bookmark&&se.addBookmark({title:ee.title,level:ee.level});break}case"paragraph":await ue(K);break;case"list":{const Z=v(K,se.settings);let ee=0,le;await y(Z.items,A.signal,async de=>{if(++ie>re.limits.maxListItems)throw new P("RESOURCE_LIMIT","maxListItems exceeded.");const pe=await E(de,ee++,Z,se.settings,ne);ee===1&&(await ae(pe.paragraph.keepTogether?pe.paragraph.height:pe.paragraph.firstHeight),le=te.structure?.element("L")),await se.listItem(pe,le),b()&&await m(),C(A.signal)}),await te.structure?.complete(le);break}case"group":{const Z=K.blocks,ee=K.keepTogether;if(!Array.isArray(Z))throw new TypeError("PDF paragraph group blocks must be an array.");if(ee!==void 0&&typeof ee!="boolean")throw new TypeError("PDF paragraph group keepTogether must be boolean.");if(Z.length>re.limits.maxGroupBlocks)throw new P("RESOURCE_LIMIT","maxGroupBlocks exceeded.");const le=[];for(const pe of Z)le.push(f(pe,se.settings,ne)),w(le,re);if(le.filter(pe=>pe.text.text).at(-1)?.keepWithNext)throw new TypeError("The last paragraph in a group cannot keepWithNext beyond the group's boundary.");const de=[];for(const pe of le)de.push(await g(pe,se.settings,ne));if(!de.some(pe=>pe.lines.length>0))break;await ae(ee!==!1?de.reduce((pe,Se)=>pe+Se.height,0):T(de)),await se.paragraphs(de,0,ee!==!1);break}case"pageBreak":await ae(),await se.pageBreak();break;case"groupedTable":await I(K,{prepared:re,pages:se,fonts:ne,controller:X,flushParagraphs:ae,acceptColumns:Z=>{H=Math.max(H,Z)},acceptRow:Z=>{$.row(++D),Z&&++ye%256===0&&x(A.onProgress,{phase:"rows",rows:ye,bytes:he.bytes})}});break;case"table":{const{options:Z,rows:ee,caption:le,continuationCaption:de}=K,pe=q(Z),Se=oe(le),Ae=oe(de),Te=s({...se.settings.options,...pe,columns:pe?.columns,includeHeader:pe?.includeHeader??!0}),Ee=new i({...Te,budget:$},ne),xe=await ge(Se),we=await ge(Ae),je=u(Te.options.columns,void 0,A.signal);let Oe=0,Re=!1;H=Math.max(H,Te.options.columns.length);const ke=await Ee.headers(),ze=await Ee.blockHeight(ke);await y(ee,A.signal,async He=>{$.row(++D);const St=await Ee.data(je(He,Oe),Oe),Nt=!Re&&(ce.length>0||!!xe?.lines.length);if(!Re){const Rt=Ee.minimumRowHeight(St);await ae((xe?.height??0)+ze+Rt),await se.beginTable(Ee,ke,Rt,xe,we),Re=!0}await se.row(St,Nt),Oe++,ye++,ye%256===0&&x(A.onProgress,{phase:"rows",rows:ye,bytes:he.bytes}),b()&&await m(),C(A.signal)});const De=await Ee.footer(Oe),Le=!Re&&(ce.length>0||!!xe?.lines.length);if(!Re){if(!ke.length&&!De?.length)break;const He=De?.length?Te.options.footer?.rows?await Ee.blockHeight(De):Ee.minimumRowHeight(De[0]):0;await ae((xe?.height??0)+ze+He),await se.beginTable(Ee,ke,He,xe,we)}De&&(Te.options.footer?.rows?await se.block(De):await se.row(De[0],Le)),await se.endTable();break}case"image":{const{width:Z,height:ee,image:le,caption:de}=K,pe=oe(de),Se=t(K,se.settings),Ae=B(K.alignment);if(pe&&Se===void 0)throw new TypeError("A captioned PDF graphic requires alternativeText and cannot be decorative.");const Te=await fe.prepare(le),Ee=await ge(pe),xe=Z??(ee===void 0?Te.width*.75:ee*Te.width/Te.height),we=ee??xe*Te.height/Te.width;if(!Number.isFinite(xe)||xe<=0||!Number.isFinite(we)||we<=0)throw new RangeError("Image display dimensions must be finite and positive.");await ae((Ee?.height??0)+se.graphicHeight(xe,we)),se.registerXObject(Te.name,Te.id),await se.graphic(xe,we,Ae,(je,Oe,Re,ke)=>"q "+[Re,0,0,ke,je,Oe].map(c).join(" ")+" cm /"+Te.name+" Do Q\n",Se,Ee);break}case"vector":{const Z=oe(K.caption),ee=t(K,se.settings),le=B(K.alignment);if(Z&&ee===void 0)throw new TypeError("A captioned PDF graphic requires alternativeText and cannot be decorative.");const de=await e(K,se.settings,N),pe=await ge(Z);N+=de.count,await ae((pe?.height??0)+se.graphicHeight(de.width,de.height)),await se.graphic(de.width,de.height,le,(Se,Ae,Te,Ee)=>"q "+[Te/de.width,0,0,-Ee/de.height,Se,Ae+Ee].map(c).join(" ")+" cm 0 0 "+c(de.width)+" "+c(de.height)+" re W n\n"+de.content+"Q\n",ee,pe);break}case"drawing":{h(K);const Z=K.drawing,ee=oe(K.caption),le=t(K,se.settings),de=B(K.alignment);if(ee&&le===void 0)throw new TypeError("A captioned PDF graphic requires alternativeText and cannot be decorative.");const pe=await l(Z,se.settings,ne,{commands:N,elements:Q}),Se=await ge(ee);N+=pe.commands,Q+=pe.elements,await ae((Se?.height??0)+se.graphicHeight(pe.width,pe.height)),await se.graphic(pe.width,pe.height,de,(Ae,Te,Ee,xe)=>"q "+[Ee/pe.width,0,0,-xe/pe.height,Ae,Te+xe].map(c).join(" ")+" cm 0 0 "+c(pe.width)+" "+c(pe.height)+" re W n\n"+pe.content+"Q\n",le,Se);break}default:throw new TypeError("Unsupported PDF document block.")}b()&&await m(),C(A.signal)}),await ae(),A.messageBottom&&await se.paragraph(A.messageBottom),await te.finish(),x(A.onProgress,{phase:"complete",rows:ye,bytes:he.bytes}),C(A.signal),{rows:ye,columns:H,bytes:he.bytes}})}finally{V?.removeEventListener("abort",Y)}}function B(_){if(_!==void 0&&!["left","center","right"].includes(_))throw new TypeError("Invalid graphic alignment.");return _??"left"}function q(_){if(!_||typeof _!="object"||Object.keys(_).some(W=>!z.includes(W)))throw new TypeError("Table options support columns, headings, footers, widths and presentation; document settings belong on writePdfDocument.");const F=o(_,z);return{...F,...F.wideTable===void 0?{}:{wideTable:a(F.wideTable)}}}return Object.freeze({pdfTable:j,writePdfDocument:M,writePdfDocumentTo:L})})(),kt=(()=>{const{assertGroupedReportSource:S}=Ue,{BlobByteSink:O}=Ie,{writePdfDocumentTo:P}=ct,{pdfOptionFields:k}=Fe,{captureFields:C}=Ce,{pdfGroupedTable:y,groupedPdfLabelFields:m,groupedPdfTableFields:b}=Et,x=[...k,...m];async function p(s,a){const c=new O;try{return await u(s,c,a),c.toBlob("application/pdf")}catch(i){throw c.discard(),i}}async function u(s,a,c){if(S(s),!c||typeof c!="object")throw new TypeError("Grouped PDF options are required.");const i=C(c,x),r=Object.fromEntries(b.filter(e=>Object.hasOwn(i,e)).map(e=>[e,i[e]])),n={...i};for(const e of b)delete n[e];return delete n.columns,delete n.headerRows,delete n.footer,P([y(s,r)],a,n)}return Object.freeze({pdfGroupedTable:Et.pdfGroupedTable,writeGroupedPdf:p,writeGroupedPdfTo:u})})(),xr=(()=>{const{fontProgram:S}=$e,{resolveScalar:O,selectFont:P,validateFonts:k}=Dt;function C(m,b={}){if(typeof m!="string")throw new TypeError("PDF preflight text must be a string.");if(!b||typeof b!="object")throw new TypeError("PDF preflight options must be an object.");for(const s of["bold","italic"])if(b[s]!==void 0&&typeof b[s]!="boolean")throw new TypeError("PDF preflight "+s+" must be boolean.");k(b.fonts);const x=b.bold??!1,{font:p}=P(b.fonts,x,b.italic??!1),u=p?S(p):void 0,o=new Set;for(let s=0;s<m.length;){const a=m.codePointAt(s),c=a===9?32:a;if(a!==10&&a!==13&&!o.has(c)){const i=O(c,u,x);if(!i.supported)return{...i,index:s,...i.code==="unpaired-surrogate"?{}:{scalar:a}};o.add(c)}s+=a>65535?2:1}return{supported:!0}}return Object.freeze({preflightPdfText:C})})(),Tr=Object.freeze({writePdf:Bt.writePdf,writePdfTo:Bt.writePdfTo,writeGroupedPdf:kt.writeGroupedPdf,writeGroupedPdfTo:kt.writeGroupedPdfTo,pdfGroupedTable:kt.pdfGroupedTable,createGroupedReport:Ue.createGroupedReport,writePdfDocument:ct.writePdfDocument,writePdfDocumentTo:ct.writePdfDocumentTo,pdfTable:ct.pdfTable,PdfFont:$e.PdfFont,preflightPdfText:xr.preflightPdfText,ExportCell:ve.ExportCell,saveBlob:rt.saveBlob}),Ct=(()=>{function S(y,m,...b){const x=O(y,m);if(typeof x!="function")throw new TypeError("DataTables API requires "+m+"().");return Reflect.apply(x,y,b)}function O(y,m){return y!=null&&(typeof y=="object"||typeof y=="function")?y[m]:void 0}function P(y){const m=Array.isArray(y)?y:S(y,"toArray");if(!Array.isArray(m))throw new TypeError("DataTables API must return an array.");return m}function k(y){return P(S(y,"indexes")).map(m=>{if(!Number.isSafeInteger(m)||m<0)throw new TypeError("Invalid DataTables index.");return m})}return Object.freeze({call:S,member:O,array:P,indexes:k})})(),Lt=(()=>{const{ExportCell:S,assertExportValue:O}=ve,{tableSpans:P}=Ve,{member:k}=Ct;function C(x){return O(x),x}function y(x){const p=C(x);return String(p instanceof S?p.text??p.value??"":p??"")}function m(x,p,u){const o=p.map(()=>[]);if(u==="leaf"||!Array.isArray(x)||!x.length)return{rows:[p.map(C)],groups:o};if(u==="structured"){const a=x.map(c=>{if(!Array.isArray(c))throw new TypeError("Invalid DataTables heading structure.");return c.map(i=>i==null?null:Object.freeze({value:C(k(i,"title")),columnSpan:k(i,"colspan"),rowSpan:k(i,"rowspan")}))});return P(a,p.length),{rows:a.map(c=>c.map(i=>i?.value??"")),groups:o,structure:Object.freeze(a.map(c=>Object.freeze(c)))}}const s=x.map((a,c)=>{if(!Array.isArray(a)||a.length!==p.length)throw new TypeError("Invalid DataTables heading structure.");const i=p.map(()=>"");for(let r=0;r<a.length;){const n=a[r],e=k(n,"colspan"),t=k(n,"rowspan");if(n==null||t!==1||!Number.isInteger(e)||e<1||r+e>p.length)throw new TypeError("Grouped export requires horizontal header spans; select headings: 'leaf' for vertical spans.");if(c===x.length-1&&e!==1)throw new TypeError("Grouped export requires one leaf header per column.");const h=y(k(n,"title"));if(i[r]=h,e!==1&&!h)throw new TypeError("Blank spanning headings require headings: 'leaf'.");for(let l=r;l<r+e;l++){if(l!==r&&a[l]!=null)throw new TypeError("Invalid overlapping DataTables heading cells.");c<x.length-1&&o[l].push(h)}r+=e}return i});for(let a=0;a<s.length-1;a++){const c=x[a];for(let i=1;i<c.length;i++)if(c[i]!=null&&o[i][a]&&JSON.stringify(o[i].slice(0,a+1))===JSON.stringify(o[i-1].slice(0,a+1)))throw new TypeError("Adjacent separate headings with equal group paths require headings: 'leaf'.")}return{rows:s,groups:o}}return Object.freeze({value:C,text:y,headings:m})})(),Mt=(()=>{const{checkAbort:S,pause:O,rowsFromBatches:P,taskYieldDue:k}=be,{ExportBudget:C}=We,{captureFields:y}=Ce,{columnOptionFields:m,copyColumns:b}=Ne,{array:x,call:p,indexes:u,member:o}=Ct,{headings:s,text:a,value:c}=Lt;function i(l){l=y(l,["rows","columns","modifier","orthogonal","stripHtml","stripNewlines","decodeEntities","escapeExcelFormula","trim","format","customizeData"]);const f=l.format&&y(l.format,["header","footer","body"]),d=l.customizeData;return{...l,...f?{format:{...f.header?{header:(g,w,T)=>c(f.header(g,w,T))}:{},...f.footer?{footer:(g,w,T)=>c(f.footer(g,w,T))}:{},...f.body?{body:(g,w,T,v)=>c(f.body(g,w,T,v))}:{}}}:{},...d?{customizeData:g=>{const w=d(g);typeof o(w,"then")=="function"&&c(w)}}:{}}}function r(l,f,d,g){if(!f||!Array.isArray(l)||!l.length)return l;const w=d.map((T,v)=>!Object.is(T,f[v]));return w.some(Boolean)?l.map((T,v)=>Array.isArray(T)?T.map((E,R)=>{if(E==null||v+(Number(o(E,"rowspan"))||1)!==l.length)return E;const I=Number(o(E,"colspan"))||1;if(!w.slice(R,R+I).some(Boolean))return E;if(I!==1)throw new TypeError("customizeData cannot change one column of a spanning "+g+" cell.");return{...E,title:d[R]}}):T):l}function n(l,f){if(!l||l.length!==f.length||new Set(l).size!==l.length)return;const d=f.map(g=>l.indexOf(g));return d.every(g=>g>=0)&&new Set(d).size===d.length&&d.some((g,w)=>g!==w)?d:void 0}function e(l,f,d={}){return t(l,f,d)}function t(l,f,d={},g){if(d=y(d,["mode","exportOptions","batchRows","maxBatchCells","headings","includeFooter","serverSide","columnOptions","project","signal","limits","onProgress"]),d.columnOptions!==void 0){const oe=Object.fromEntries(Object.entries(d.columnOptions).map(([K,Z])=>[K,y(Z,m)]));d={...d,columnOptions:oe}}for(const oe of Object.values(d.columnOptions??{}))if(oe.style!==void 0)throw new TypeError("Workbook-local column styles require the advanced Workbook API; use portable ExportCell presentation.");const w=d.mode??"batched",T=d.headings??"grouped";if(!["batched","compatibility"].includes(w))throw new TypeError("Unknown DataTables export mode.");if(!["grouped","leaf","structured"].includes(T))throw new TypeError("Unknown DataTables heading mode.");if(d.serverSide!==void 0&&!["reject","loaded"].includes(d.serverSide))throw new TypeError("Unknown server-side export policy.");const v=d.batchRows??4096,E=d.maxBatchCells??65536;if(!Number.isInteger(v)||v<1||v>4096)throw new RangeError("batchRows must be between 1 and 4,096.");if(!Number.isSafeInteger(E)||E<1)throw new RangeError("maxBatchCells must be a positive safe integer.");const R=d.signal,I=d.project,z=new C(d.limits);if(S(R),o(p(f.page,"info"),"serverSide")&&d.serverSide!=="loaded")throw new TypeError("Server-side DataTables exports require a separate full-data source or explicit serverSide: 'loaded'.");const j=i(d.exportOptions??{}),M={stripHtml:!0,stripNewlines:!0,decodeEntities:!0,trim:!0,...j},L=l.Buttons,B=o(L,"stripData"),q=typeof B=="function"?B.bind(L):void 0;if(w==="batched"&&!j.format?.body&&typeof B!="function")throw new TypeError("DataTables API requires stripData().");if(w==="batched"&&j.customizeData)throw new TypeError("customizeData requires compatibility mode.");if(j.customizeData&&d.project)throw new TypeError("project cannot identify source indexes after customizeData.");const G={search:"applied",order:"applied",...j.modifier};o(G,"selected")===void 0&&typeof o(o(f,"select"),"info")=="function"&&Number(p(p(f,"rows",j.rows??null,{...G,selected:!0}),"count"))>0&&Object.assign(G,{selected:!0});const _=u(p(f,"rows",j.rows??null,G)),F=u(p(f,"columns",j.columns??""));if(F.length>E)throw new RangeError("A selected row exceeds maxBatchCells.");if(new Set(_).size!==_.length||new Set(F).size!==F.length)throw new TypeError("DataTables export indexes must be unique.");let W;const U=j.customizeData,X=p(f.buttons,"exportData",{...j,modifier:G,...w==="batched"?{rows:[]}:{},...U?{customizeData:oe=>{const K=o(oe,"footer");W={header:[...x(o(oe,"header"))],footer:K==null?void 0:[...x(K)]},U(oe)}}:{}}),V=x(o(X,"header"));if(V.length!==F.length)throw new TypeError("Export header must match the selected columns.");const Y=T==="structured"&&!g?.header,re=g?.header?void 0:o(X,"headerStructure"),A=s(Y?r(re,W?.header,V,"header"):re,V,g?.header?"leaf":T),$=n(W?.header,V);if($&&A.rows.length>1)throw new TypeError("customizeData cannot reorder columns under grouped headings; select headings: 'leaf' or reorder the table's columns.");if(W&&!$&&W.header.some((oe,K)=>!Object.is(oe,V[K]))&&F.some(oe=>d.columnOptions?.[oe]!==void 0))throw new TypeError("customizeData changed column headings, so columnOptions cannot be matched to columns; rename columns with columnOptions header instead.");const J=$?$.map(oe=>F[oe]):F;for(const oe of F)if(o(d.columnOptions?.[oe],"value")!==void 0)throw new TypeError("DataTables columnOptions describes columns; resolve values with project.");const te=Object.freeze(b(V.map((oe,K)=>({header:a(oe),key:"dt:"+J[K],...d.columnOptions?.[J[K]],...A.groups[K].length?{groups:Object.freeze(A.groups[K])}:{}}))).map(oe=>Object.freeze(oe)));A.structure||(A.rows[A.rows.length-1]=te.map(oe=>oe.header));const he=A.structure?.map((oe,K)=>Object.freeze(oe.map((Z,ee)=>{if(!Z||K+(Z.rowSpan??1)!==A.structure.length)return Z;const le=d.columnOptions?.[J[ee]]?.header;if((Z.columnSpan??1)>1&&J.slice(ee,ee+(Z.columnSpan??1)).some(de=>d.columnOptions?.[de]?.header!==void 0))throw new TypeError("A spanning leaf heading cannot have per-column header overrides.");return le===void 0?Z:Object.freeze({...Z,value:le})}))),se=d.includeFooter!==!1&&g?.footer!==!0,ne=se?o(X,"footerStructure"):void 0;if(T!=="structured"&&se&&Array.isArray(ne)&&ne.length>1)throw new TypeError("Only a single footer row is supported; select includeFooter: false to omit it explicitly.");const fe=se?o(X,"footer"):void 0,ye=fe==null?void 0:x(fe).map(c);if(ye&&ye.length!==te.length)throw new TypeError("Export footer must match the selected columns.");const D=ye&&Array.isArray(ne)&&ne.length?s(T==="structured"?r(ne,W?.footer,x(fe),"footer"):ne,ye,T==="structured"?"structured":"grouped"):void 0,H=w==="compatibility"?x(o(X,"body")):void 0,N=te.length?H?.length??_.length:0;z.check("maxRows",N);const Q=te.length?Math.min(v,Math.floor(E/te.length)):v,ie=new Map(F.map((oe,K)=>[oe,K])),ce=w==="batched"&&N?p(f,"cells",[],[]):void 0;if(ce){let oe=0;if(p(ce,"iterator","table",()=>{oe++}),oe!==1)throw new TypeError("A batched export requires exactly one DataTables table.")}const ae=P({[Symbol.asyncIterator]:()=>ue()});async function*ue(){for(let oe=0;oe<N;oe+=Q){S(R);let K;if(H)K=H.slice(oe,oe+Q).map((Z,ee)=>{if(!Array.isArray(Z)||Z.length!==te.length)throw new TypeError("Export body row must match the selected columns.");return Z.map((le,de)=>ge(le,_[oe+ee]??oe+ee,de,oe+ee))});else{const Z=_.slice(oe,oe+Q),ee=new Array(Z.length*te.length);for(let we=0,je=0;we<Z.length;we++)for(const Oe of F)ee[je++]={row:Z[we],column:Oe};p(ce,"pop"),p(ce,"push",ee);const le=ce,de=x(p(le,"render",j.orthogonal??"display")),pe=x(p(le,"indexes")),Se=j.format?.body?x(p(le,"nodes")):void 0;if(de.length!==Z.length*te.length||pe.length!==de.length||Se&&Se.length>de.length)throw new TypeError("The table changed or returned an incomplete export batch.");K=Z.map(()=>new Array(te.length));let Ae,Te,Ee=0,xe=0;for(let we=0;we<de.length;we++){S(R);const je=o(pe[we],"row"),Oe=o(pe[we],"column");if(!Te&&(je!==ee[we].row||Oe!==ee[we].column)){Ae=new Map(Z.map((Le,He)=>[Le,He])),Te=new Set;for(let Le=0;Le<we;Le++)Te.add(Le)}const Re=Te?Ae.get(je):Ee,ke=Te?ie.get(Oe):xe;if(Re===void 0||ke===void 0||Te?.has(Re*te.length+ke))throw new TypeError("Invalid DataTables cell indexes.");Te?.add(Re*te.length+ke);let ze=Se?.[we];if(Se&&Se.length!==de.length){p(le,"pop"),p(le,"push",[{row:je,column:Oe}]);const Le=x(p(le,"nodes"));if(Le.length>1)throw new TypeError("Invalid DataTables cell nodes.");ze=Le[0]}const De=j.format?.body?j.format.body(de[we],je,Oe,ze):q(de[we],M);K[Re][ke]=ge(De,je,ke,oe+Re),++xe===te.length&&(xe=0,Ee++),(we&127)===127&&k()&&(await O(),S(R))}}S(R),yield K,k()&&(await O(),S(R))}}function ge(oe,K,Z,ee){S(R);const le=c(oe);return I?c(I(le,{sourceRowIndex:K,sourceColumnIndex:F[Z],rowIndex:ee,columnIndex:Z})):le}return Object.freeze({columns:te,headers:Object.freeze(A.rows.map(oe=>Object.freeze(oe))),footer:ye?Object.freeze(ye):void 0,...he?{headerStructure:Object.freeze(he)}:{},...D?.structure?{footerStructure:D.structure}:{},rowCount:N,rows:ae})}return Object.freeze({createDataTablesExport:e,captureDataTablesExport:t})})(),Er=(()=>{const{captureFields:S}=Ce,{ExportBudget:O}=We,{captureCsvOptions:P}=vt,{capturePdfOptions:k,capturePdfLimits:C,pdfLimitFields:y}=Fe,{captureWorkbookLimits:m,workbookLimitFields:b,workbookOptionFields:x,sheetOptionFields:p}=qe,u=[...new Set([...b,...y])],o=x.filter(e=>e!=="sink");function s(e){return e===void 0?void 0:new O(S(e,u)).limits}function a(e,t){const h={...e};for(const[l,f]of Object.entries(t??{}))f!==void 0&&(h[l]=f);return h}function c(e={}){const t=S(e,[...o,"sheet"]),h=t.sheet&&S(t.sheet,[...p,"name"]),l=h?.footer&&S(h.footer,["rows","values","totals","style"]);return{...t,...h===void 0?{}:{sheet:{...h,...l===void 0?{}:{footer:l}}},...t.limits===void 0?{}:{limits:m(t.limits)}}}function i(e={}){const t=P(e);return{...t,...t.limits===void 0?{}:{limits:new O(t.limits).limits}}}function r(e={}){const t=k(e);return{...t,...t.limits===void 0?{}:{limits:C(t.limits)}}}return Object.freeze({captureCommonLimits:s,mergeAdapterLimits:a,captureXlsxOptions:c,captureCsvOptions:i,capturePdfOptions:r})})(),kr=(()=>{const{BlobByteSink:S,checkAbort:O,saveBlob:P}=rt,{notifyProgress:k}=Ge,{writeCsvTo:C}=Ht,{writeXlsxTo:y}=Qt,{writePdfTo:m}=Tr,{portableSheet:b,portableWorkbook:x}=gt,{call:p,member:u}=Ct,{value:o}=Lt,{captureDataTablesExport:s}=Mt,{captureFields:a}=Ce,{captureCommonLimits:c,captureXlsxOptions:i,captureCsvOptions:r,capturePdfOptions:n,mergeAdapterLimits:e}=Er,t=["mode","exportOptions","batchRows","maxBatchCells","headings","includeFooter","serverSide","columnOptions","project","signal","limits","onProgress","xlsx","csv","pdf"],h=[...t,"filename","save","onError"];async function l(w,T,v,E,R={}){if(v!=="xlsx"&&v!=="csv"&&v!=="pdf")throw new TypeError("DataTables export format must be xlsx, csv or pdf.");for(const X of["workbook","sheet","sheetName"])if(X in R)throw new TypeError("DataTables writer settings belong in xlsx; use xlsx.sheet.name for the worksheet name.");const I=a(R,t),{signal:z,onProgress:j}=I,M=c(I.limits),L=i(v==="xlsx"?I.xlsx:void 0),B=r(v==="csv"?I.csv:void 0),q=n(v==="pdf"?I.pdf:void 0),G=L.sheet;v==="xlsx"&&(b(G),x(L));const _=G?.footer&&[G.footer.rows,G.footer.values,G.footer.totals].some(X=>X!==void 0),F=s(w,T,{...I,...M===void 0?{}:{limits:M},...v==="pdf"?{headings:I.headings??"structured"}:{}},{header:v==="pdf"?q.includeHeader===!1||q.headerRows!==void 0:v==="xlsx"?G?.includeHeader===!1||G?.headerRows!==void 0:B.includeHeader===!1||B.headerRows!==void 0,footer:v==="pdf"?q.footer!==void 0:v==="xlsx"?!!_:B.footer!==void 0});let W;const U={...z?{signal:z}:{},...j?{onProgress:X=>k(j,{...X,totalRows:F.rowCount})}:{}};if(v==="xlsx"){const X=F.footerStructure?{rows:F.footerStructure}:F.footer?{values:F.footer}:void 0,V=_?G?.footer:X||G?.footer?{...X,...G?.footer}:void 0;W=await y(F.rows,E,{...L,...U,columns:F.columns,limits:e(L.limits,M),sheet:{...G,...F.headerStructure&&G?.includeHeader!==!1&&G?.headerRows===void 0?{headerRows:F.headerStructure}:{},...V?{footer:V}:{}}})}else if(v==="pdf"){const X=q.footer??(F.footerStructure?{rows:F.footerStructure}:F.footer?{values:F.footer}:void 0);W=await m(F.rows,E,{...q,...U,columns:F.columns,limits:e(q.limits,M),...F.headerStructure&&q.includeHeader!==!1&&!q.headerRows?{headerRows:F.headerStructure}:{},...X?{footer:X}:{}})}else{const X=B.footer??(F.footerStructure?{rows:F.footerStructure}:F.footer?{rows:[F.footer.map(V=>({value:V}))]}:void 0);W=await C(F.rows,E,{...B,...U,columns:F.columns,limits:e(B.limits,M),...B.includeHeader!==!1&&B.headerRows===void 0?{headerRows:F.headerStructure??F.headers.map(V=>V.map(Y=>({value:Y})))}:{},...X?{footer:X}:{}})}return O(z),{rows:F.rowCount,columns:F.columns.length,bytes:W.bytes}}async function f(w,T,v,E={}){const R=new S;try{return await l(w,T,v,R,E),R.toBlob(v==="pdf"?"application/pdf":v==="csv"?"text/csv;charset=utf-8":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}catch(I){throw R.discard(),I}}function d(w,T={}){const v=w.ext?.buttons;if(!v||typeof u(w.Buttons,"stripData")!="function")throw new TypeError("Install DataTables Buttons before registering OfficeIMO exports.");if(v.officeimoExcel||v.officeimoCsv||v.officeimoPdf)throw new TypeError("OfficeIMO DataTables buttons are already registered.");for(const[E,R,I]of[["officeimoExcel","xlsx","Excel"],["officeimoCsv","csv","CSV"],["officeimoPdf","pdf","PDF"]])v[E]={text:I,async:1,action:function(z,j,M,L,B){let q=T;const G=()=>{const _=B;B=void 0,_?.()};(async()=>{try{const _=u(L,"officeimo"),F=u(L,"filename");if(_!==void 0&&(!_||typeof _!="object"))throw new TypeError("Button officeimo settings must be an object.");const W=a(T,h),U=a(_??{},h);if(q={...W,...U,...F!==void 0?{filename:F}:{},...u(L,"footer")===!1?{includeFooter:!1}:{},...u(L,"exportOptions")?{exportOptions:u(L,"exportOptions")}:{}},u(L,"customize")!==void 0)throw new TypeError("Native customize callbacks are unsupported; use OfficeIMO xlsx/pdf options.");if(R==="xlsx"){const re=i(W.xlsx),A=i(U.xlsx);q={...q,xlsx:{...re,...A,...re.sheet||A.sheet?{sheet:{...re.sheet,...A.sheet}}:{}}}}else R==="csv"&&(q={...q,csv:{...r(W.csv),...r(U.csv)}});if(R==="pdf"){const re=p(j.buttons,"exportInfo",L),A={...n(W.pdf),...n(U.pdf)};for(const $ of["title","messageTop","messageBottom"])if(u(L,$)!==void 0){if(u(L,$)===null){delete A[$];continue}const J=u(re,$);if(J===null||J===""){delete A[$];continue}if(typeof J!="string")throw new TypeError("PDF "+$+" must resolve to text.");A[$]=J}for(const $ of["orientation","pageSize"])u(L,$)!==void 0&&Object.assign(A,{[$]:u(L,$)});u(L,"header")===!1&&(A.includeHeader=!1,delete A.headerRows),u(L,"footer")===!1&&delete A.footer,q={...q,pdf:A}}else if(u(L,"header")===!1||["title","messageTop","messageBottom"].some(re=>u(L,re)!=null))throw new TypeError("Use OfficeIMO xlsx.sheet title/footer options; native Buttons report layout options are unsupported.");const X=o(typeof q.filename=="function"?q.filename(L,j):q.filename??"Export");if(typeof X!="string"||!X.trim())throw new TypeError("Export filename must be a non-empty string.");const V=o(u(p(j.buttons,"exportInfo",{filename:X,extension:""}),"filename"));if(typeof V!="string"||!V.trim())throw new TypeError("Resolved export filename must be a non-empty string.");const Y=await f(w,j,R,q);await(q.save??P)(Y,V.toLowerCase().endsWith("."+R)?V:V+"."+R)}catch(_){G(),q.onError?await q.onError(_):console.error("OfficeIMO table export failed.",_)}finally{G()}})().catch(_=>console.error("OfficeIMO export error handler failed.",_))}}}return Object.freeze({createDataTablesExport:Mt.createDataTablesExport,ExportCell:ve.ExportCell,PdfFont:$e.PdfFont,writeDataTableTo:l,exportDataTable:f,registerDataTablesButtons:d})})(),{createDataTablesExport:Cr,ExportCell:Sr,PdfFont:Rr,writeDataTableTo:vr,exportDataTable:Or,registerDataTablesButtons:Pr}=kr;export{Sr as ExportCell,Rr as PdfFont,Cr as createDataTablesExport,Or as exportDataTable,Pr as registerDataTablesButtons,vr as writeDataTableTo};